diff options
author | BroodWyrm <none@none> | 2009-05-15 16:38:48 +0200 |
---|---|---|
committer | BroodWyrm <none@none> | 2009-05-15 16:38:48 +0200 |
commit | b5b9f281176a728599ff7a00b9927f478ee9ce90 (patch) | |
tree | 3100b90d2d90813aacbdc6c61c224432b9907c80 | |
parent | 80a6d723f5e406b9972b8b8d0b371dd12b9af951 (diff) |
*Rewrite Moroes Script to fix reset bug
--HG--
branch : trunk
-rw-r--r-- | src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp | 151 |
1 files changed, 57 insertions, 94 deletions
diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp index 20bf8076b27..dbf8a3427df 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp @@ -62,7 +62,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { boss_moroesAI(Creature *c) : ScriptedAI(c) { - FirstTime = true; + for(int i = 0; i < 4; i++) + { + AddId[i] = 0; + } pInstance = ((ScriptedInstance*)c->GetInstanceData()); } @@ -77,7 +80,6 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI uint32 CheckAdds_Timer; uint32 AddId[4]; - bool FirstTime; bool InVanish; bool Enrage; @@ -91,12 +93,10 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI Enrage = false; InVanish = false; - - SpawnAdds(); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if(m_creature->GetHealth() > 0) + { + SpawnAdds(); + } if(pInstance) pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); @@ -106,6 +106,8 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { if(pInstance) pInstance->SetData(DATA_MOROES_EVENT, IN_PROGRESS); + + DoZoneInCombat(); } void Aggro(Unit* who) @@ -129,7 +131,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI void JustDied(Unit* victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, m_creature); if (pInstance) pInstance->SetData(DATA_MOROES_EVENT, DONE); @@ -153,27 +155,15 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI } } - uint8 CheckAdd(uint64 guid) - { - Unit* pUnit = Unit::GetUnit((*m_creature), guid); - if (pUnit) - { - if (!pUnit->isAlive()) - return 1; // Exists but is dead - else - return 2; // Exists and is alive - } - return 0; // Does not exist - } - void SpawnAdds() { - Creature *pCreature = NULL; - - if (FirstTime) + DeSpawnAdds(); + if(isAddlistEmpty()) { + Creature *pCreature = NULL; std::vector<uint32> AddList; + for(uint8 i = 0; i < 6; ++i) AddList.push_back(Adds[i]); @@ -193,48 +183,44 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI } ++i; } - - FirstTime = false; - } - else + }else { - for(uint8 i = 0; i < 4; ++i) + for(int i = 0; i < 4; i++) { - switch(CheckAdd(AddGUID[i])) + Creature *pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + if (pCreature) { - case 0: - pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if (pCreature) - AddGUID[i] = pCreature->GetGUID(); - break; - case 1: - pCreature = (Unit::GetCreature((*m_creature), AddGUID[i])); - if (pCreature) - { - pCreature->Respawn(); - pCreature->AI()->EnterEvadeMode(); - } - break; - case 2: - pCreature = (Unit::GetCreature((*m_creature), AddGUID[i])); - if (!pCreature->IsInEvadeMode()) - pCreature->AI()->EnterEvadeMode(); - break; + AddGUID[i] = pCreature->GetGUID(); } } } } + bool isAddlistEmpty() + { + for(int i = 0; i < 4; i++) + { + if(AddId[i] == 0) + return true; + } + return false; + } + void DeSpawnAdds() { for(uint8 i = 0; i < 4 ; ++i) { - Unit* Temp = NULL; + Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + Temp = Creature::GetCreature((*m_creature),AddGUID[i]); if (Temp && Temp->isAlive()) + { + (*Temp).GetMotionMaster()->Clear(true); Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + Temp->RemoveCorpse(); + } + } } } @@ -243,13 +229,13 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { for(uint8 i = 0; i < 4; ++i) { - Unit* Temp = NULL; + Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + Temp = Creature::GetCreature((*m_creature),AddGUID[i]); if (Temp && Temp->isAlive()) { - ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); + Temp->AI()->AttackStart(m_creature->getVictim()); DoZoneInCombat(Temp); }else EnterEvadeMode(); @@ -295,37 +281,12 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI //Cast Vanish, then Garrote random victim if (Vanish_Timer < diff) { - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); DoCast(m_creature, SPELL_VANISH); InVanish = true; Vanish_Timer = 30000; Wait_Timer = 5000; }else Vanish_Timer -= diff; - if (InVanish) - { - if (Wait_Timer < diff) - { - switch(rand()%2) - { - case 0: DoScriptText(SAY_SPECIAL_1, m_creature); break; - case 1: DoScriptText(SAY_SPECIAL_2, m_creature); break; - } - - if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - target->CastSpell(target, SPELL_GARROTE,true); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->AI()->AttackStart(m_creature->getVictim()); - InVanish = false; - }else Wait_Timer -= diff; - } - - //Gouge highest aggro, and attack second highest if (Gouge_Timer < diff) { DoCast(m_creature->getVictim(), SPELL_GOUGE); @@ -334,27 +295,29 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI if (Blind_Timer < diff) { - Unit* target = NULL; - std::list<HostilReference*> t_list = m_creature->getThreatManager().getThreatList(); + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 5, true); + if (target && m_creature->IsWithinMeleeRange(target)) + DoCast(target, SPELL_BLIND); - if (t_list.empty()) - return; + Blind_Timer = 40000; + }else Blind_Timer -= diff; + } - std::vector<Unit*> target_list; - for (std::list<HostilReference*>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + if (InVanish) + { + if (Wait_Timer < diff) + { + switch(rand()%2) { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if (target && target->GetDistance2d(m_creature) < 5) - target_list.push_back(target); + case 0: DoScriptText(SAY_SPECIAL_1, m_creature); break; + case 1: DoScriptText(SAY_SPECIAL_2, m_creature); break; } - if (target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); - if (target) - DoCast(target, SPELL_BLIND); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + target->CastSpell(target, SPELL_GARROTE,true); - Blind_Timer = 40000; - }else Blind_Timer -= diff; + InVanish = false; + }else Wait_Timer -= diff; } if (!InVanish) |