aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrazom62 <none@none>2010-03-23 19:15:17 +0100
committerTrazom62 <none@none>2010-03-23 19:15:17 +0100
commit1e9de7dbd776316a138d965dba84696e5ec354e0 (patch)
tree81aa0572d7f7dbe5248fb8e68277f5d84315da54 /src
parentcfc094040f7ce3924fd024c93c82eaf0b0498c8d (diff)
Implement Four-Horsemen achievements (requires DB Data).
Fixes issue #1107. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/InstanceData.cpp11
-rw-r--r--src/game/InstanceData.h3
-rw-r--r--src/scripts/northrend/naxxramas/boss_four_horsemen.cpp13
-rw-r--r--src/scripts/northrend/naxxramas/instance_naxxramas.cpp48
-rw-r--r--src/scripts/northrend/naxxramas/naxxramas.h5
5 files changed, 77 insertions, 3 deletions
diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp
index cc42a453ea8..3ff804818ea 100644
--- a/src/game/InstanceData.cpp
+++ b/src/game/InstanceData.cpp
@@ -322,6 +322,17 @@ void InstanceData::DoCompleteAchievement(uint32 achievement)
pPlayer->CompletedAchievement(AE);
}
+// Update Achievement Criteria for all players in instance
+void InstanceData::DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1, uint32 miscvalue2, Unit *unit, uint32 time)
+{
+ Map::PlayerList const &PlayerList = instance->GetPlayers();
+
+ if (!PlayerList.isEmpty())
+ for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+ if (Player *pPlayer = i->getSource())
+ pPlayer->UpdateAchievementCriteria(type, miscvalue1, miscvalue2, unit, time);
+}
+
// Remove Auras due to Spell on all players in instance
void InstanceData::DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
{
diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h
index e6fcb25b355..eb4581a84b9 100644
--- a/src/game/InstanceData.h
+++ b/src/game/InstanceData.h
@@ -158,6 +158,9 @@ class InstanceData : public ZoneScript
// Complete Achievement for all players in instance
void DoCompleteAchievement(uint32 achievement);
+ // Update Achievement Criteria for all players in instance
+ void DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
+
// Remove Auras due to Spell on all players in instance
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell);
diff --git a/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp b/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp
index acb0d9e6eed..3152fa7e621 100644
--- a/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp
+++ b/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp
@@ -104,6 +104,9 @@ struct boss_four_horsemenAI : public BossAI
if (!encounterActionReset)
DoEncounterAction(NULL, false, true, false);
+ if (instance)
+ instance->SetData(DATA_HORSEMEN0 + id, NOT_STARTED);
+
me->SetReactState(REACT_AGGRESSIVE);
uiEventStarterGUID = 0;
nextWP = 0;
@@ -274,10 +277,18 @@ struct boss_four_horsemenAI : public BossAI
{
events.Reset();
summons.DespawnAll();
- if(instance && DoEncounterAction(NULL, false, false, true))
+
+ if (instance)
+ instance->SetData(DATA_HORSEMEN0 + id, DONE);
+
+ if (instance && DoEncounterAction(NULL, false, false, true))
{
instance->SetBossState(BOSS_HORSEMEN, DONE);
instance->SaveToDB();
+
+ // Achievements related to the 4-horsemen are given through spell 59450 which does not exist.
+ // There is thus no way it can be given by casting the spell on the players.
+ instance->DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 59450);
}
DoScriptText(SAY_DEATH[id], me);
diff --git a/src/scripts/northrend/naxxramas/instance_naxxramas.cpp b/src/scripts/northrend/naxxramas/instance_naxxramas.cpp
index 48ff18356e0..f9c28a479aa 100644
--- a/src/scripts/northrend/naxxramas/instance_naxxramas.cpp
+++ b/src/scripts/northrend/naxxramas/instance_naxxramas.cpp
@@ -104,7 +104,7 @@ inline uint32 GetEruptionSection(float x, float y)
struct instance_naxxramas : public InstanceData
{
instance_naxxramas(Map* pMap) : InstanceData(pMap)
- , Sapphiron(NULL), pGothikGate(NULL), HorsemenChest(NULL), HorsemenNum(0)
+ , Sapphiron(NULL), pGothikGate(NULL), HorsemenChest(NULL)
{
SetBossNumber(MAX_BOSS_NUMBER);
LoadDoorData(doorData);
@@ -114,7 +114,6 @@ struct instance_naxxramas : public InstanceData
std::set<GameObject*> HeiganEruption[4];
GameObject* pGothikGate, *HorsemenChest;
Creature* Sapphiron;
- uint32 HorsemenNum;
uint64 uiFaerlina;
uint64 uiThane;
uint64 uiLady;
@@ -129,6 +128,9 @@ struct instance_naxxramas : public InstanceData
uint64 uiKelthuzadTrigger;
uint64 uiPortals[4];
+ time_t minHorsemenDiedTime;
+ time_t maxHorsemenDiedTime;
+
void OnCreatureCreate(Creature* pCreature, bool add)
{
switch(pCreature->GetEntry())
@@ -187,6 +189,26 @@ struct instance_naxxramas : public InstanceData
if (pGothikGate)
pGothikGate->SetGoState(GOState(value));
break;
+
+ case DATA_HORSEMEN0:
+ case DATA_HORSEMEN1:
+ case DATA_HORSEMEN2:
+ case DATA_HORSEMEN3:
+ if (value == NOT_STARTED)
+ {
+ minHorsemenDiedTime = 0;
+ maxHorsemenDiedTime = 0;
+ }
+ else if (value == DONE)
+ {
+ time_t now = time(NULL);
+
+ if (minHorsemenDiedTime == 0)
+ minHorsemenDiedTime = now;
+
+ maxHorsemenDiedTime = now;
+ }
+ break;
}
}
@@ -251,6 +273,28 @@ struct instance_naxxramas : public InstanceData
}
}
}
+
+ bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* source, Unit const* target = NULL, uint32 miscvalue1 = 0)
+ {
+ switch(criteria_id)
+ {
+ case 7600: // Criteria for achievement 2176: And They Would All Go Down Together 15sec of each other 10-man
+ if (Difficulty(instance->GetSpawnMode()) == RAID_DIFFICULTY_10MAN_NORMAL && (maxHorsemenDiedTime - minHorsemenDiedTime) < 15)
+ return true;
+ return false;
+ case 7601: // Criteria for achievement 2177: And They Would All Go Down Together 15sec of each other 25-man
+ if (Difficulty(instance->GetSpawnMode()) == RAID_DIFFICULTY_25MAN_NORMAL && (maxHorsemenDiedTime - minHorsemenDiedTime) < 15)
+ return true;
+ return false;
+ case 13233: // Criteria for achievement 2186: The Immortal (25-man)
+ // TODO.
+ break;
+ case 13237: // Criteria for achievement 2187: The Undying (10-man)
+ // TODO.
+ break;
+ }
+ return false;
+ }
};
InstanceData* GetInstanceData_instance_naxxramas(Map* pMap)
diff --git a/src/scripts/northrend/naxxramas/naxxramas.h b/src/scripts/northrend/naxxramas/naxxramas.h
index 38e38b2ad53..9b1fac2ff5b 100644
--- a/src/scripts/northrend/naxxramas/naxxramas.h
+++ b/src/scripts/northrend/naxxramas/naxxramas.h
@@ -44,6 +44,11 @@ enum Data
DATA_HEIGAN_ERUPT,
DATA_GOTHIK_GATE,
DATA_SAPPHIRON_BIRTH,
+
+ DATA_HORSEMEN0,
+ DATA_HORSEMEN1,
+ DATA_HORSEMEN2,
+ DATA_HORSEMEN3,
};
enum Data64