diff options
Diffstat (limited to 'src/scripts')
22 files changed, 323 insertions, 280 deletions
diff --git a/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp b/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp index 7ab783e6e93..f6e94307f2f 100644 --- a/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp +++ b/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp @@ -173,8 +173,8 @@ struct boss_vaelAI : public ScriptedAI while (i < 3) // max 3 tries to get a random target with power_mana { ++i; - if (pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true)) //not aggro leader - if (pTarget->getPowerType() == POWER_MANA) + pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); //not aggro leader + if (pTarget && pTarget->getPowerType() == POWER_MANA) i = 3; } if (pTarget) // cast on self (see below) diff --git a/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp b/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp index 79af5c3030c..3b0ce186592 100644 --- a/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp +++ b/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp @@ -1511,7 +1511,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI // Death for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiGhoulGUID[i]))) + pTemp = Unit::GetCreature(*me, uiGhoulGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_ACHERUS_GHOUL, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1520,7 +1521,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiAbominationGUID[i]))) + pTemp = Unit::GetCreature(*me, uiAbominationGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_WARRIOR_OF_THE_FROZEN_WASTES, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1529,7 +1531,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiWarriorGUID[i]))) + pTemp = Unit::GetCreature(*me, uiWarriorGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_RAMPAGING_ABOMINATION, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1538,7 +1541,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiBehemothGUID[i]))) + pTemp = Unit::GetCreature(*me, uiBehemothGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_FLESH_BEHEMOTH, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1549,7 +1553,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI // Dawn for (uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiDefenderGUID[i]))) + pTemp = Unit::GetCreature(*me, uiDefenderGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_DEFENDER_OF_THE_LIGHT, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2089); @@ -1559,7 +1564,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiEarthshatterGUID[i]))) + pTemp = Unit::GetCreature(*me, uiEarthshatterGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_RIMBLAT_EARTHSHATTER, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2089); @@ -1567,28 +1573,32 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI uiEarthshatterGUID[i] = pTemp->GetGUID(); } } - if (!(pTemp = Unit::GetCreature(*me, uiKorfaxGUID))) + pTemp = Unit::GetCreature(*me, uiKorfaxGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_KORFAX_CHAMPION_OF_THE_LIGHT, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); pTemp->setFaction(2089); me->AddThreat(pTemp, 0.0f); uiKorfaxGUID = pTemp->GetGUID(); } - if (!(pTemp = Unit::GetCreature(*me, uiMaxwellGUID))) + pTemp = Unit::GetCreature(*me, uiMaxwellGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_LORD_MAXWELL_TYROSUS, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); pTemp->setFaction(2089); me->AddThreat(pTemp, 0.0f); uiMaxwellGUID = pTemp->GetGUID(); } - if (!(pTemp = Unit::GetCreature(*me, uiEligorGUID))) + pTemp = Unit::GetCreature(*me, uiEligorGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_COMMANDER_ELIGOR_DAWNBRINGER, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); pTemp->setFaction(2089); me->AddThreat(pTemp, 0.0f); uiEligorGUID = pTemp->GetGUID(); } - if (!(pTemp = Unit::GetCreature(*me, uiRayneGUID))) + pTemp = Unit::GetCreature(*me, uiRayneGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_RAYNE, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2089); diff --git a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp index 32555a550c2..6b6efa0f934 100644 --- a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp +++ b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp @@ -60,7 +60,7 @@ struct boss_azshir_the_sleeplessAI : public ScriptedAI DoCast(me->getVictim(), SPELL_SOULSIPHON); return; - SoulSiphon_Timer = 20000; + //SoulSiphon_Timer = 20000; } else SoulSiphon_Timer -= diff; } diff --git a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp index b3f250769b2..34d6d1bf295 100644 --- a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp +++ b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp @@ -116,12 +116,7 @@ static Locations Spawn[]= {1765.28,1347.46,17.55} //spawn point for smoke }; -struct Summon -{ - const std::string text; -}; - -static Summon Text[]= +static const char* Text[]= { {"Horseman rise..."}, {"Your time is nigh..."}, @@ -615,14 +610,14 @@ struct boss_headless_horsemanAI : public ScriptedAI if (count < 3) { if (plr) - plr->Say(Text[count].text,0); + plr->Say(Text[count],0); } else { DoCast(me, SPELL_RHYME_BIG); if (plr) { - plr->Say(Text[count].text,0); + plr->Say(Text[count],0); plr->HandleEmoteCommand(ANIM_EMOTE_SHOUT); } wp_reached = true; diff --git a/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp b/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp index 17ab1f3c5b1..7baa9292142 100644 --- a/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp +++ b/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp @@ -559,11 +559,10 @@ struct boss_alyson_antilleAI : public boss_hexlord_addAI else { if (urand(0,1)) - { - if (pTarget = DoSelectLowestHpFriendly(50, 0)) - DoCast(pTarget, SPELL_DISPEL_MAGIC, false); - } - else if (pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0)) + pTarget = DoSelectLowestHpFriendly(50, 0); + else + pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (pTarget) DoCast(pTarget, SPELL_DISPEL_MAGIC, false); } flashheal_timer = 2500; diff --git a/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp b/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp index 21a7630018b..77e9f9b929f 100644 --- a/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp +++ b/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp @@ -167,8 +167,8 @@ struct boss_marliAI : public ScriptedAI while (i < 3) // max 3 tries to get a random target with power_mana { ++i; - if (pTarget = SelectTarget(SELECT_TARGET_RANDOM,1, 100, true)) // not aggro leader - if (pTarget->getPowerType() == POWER_MANA) + pTarget = SelectTarget(SELECT_TARGET_RANDOM,1, 100, true); // not aggro leader + if (pTarget && pTarget->getPowerType() == POWER_MANA) i = 3; } if (pTarget) diff --git a/src/scripts/kalimdor/silithus.cpp b/src/scripts/kalimdor/silithus.cpp index d7495b4187e..c2c356692f1 100644 --- a/src/scripts/kalimdor/silithus.cpp +++ b/src/scripts/kalimdor/silithus.cpp @@ -688,15 +688,19 @@ struct npc_anachronos_the_ancientAI : public ScriptedAI Fandral->CastSpell(-8127,1525,17.5,33806,true); break; case 51: - while (mob = plr->FindNearestCreature(15423,50,me)) - mob->RemoveFromWorld(); - while (mob = plr->FindNearestCreature(15424,50,me)) - mob->RemoveFromWorld(); - while (mob = plr->FindNearestCreature(15414,50,me)) - mob->RemoveFromWorld(); - while (mob = plr->FindNearestCreature(15422,50,me)) - mob->RemoveFromWorld(); + { + uint32 entries[4] = { 15423, 15424, 15414, 15422 }; + for (uint8 i = 0; i < 4; ++i) + { + mob = plr->FindNearestCreature(entries[i],50,me); + while (mob) + { + mob->RemoveFromWorld(); + mob = plr->FindNearestCreature(15423,50,me); + } + } break; + } case 52: Fandral->GetMotionMaster()->MoveCharge(-8028.75, 1538.795, 2.61,4); DoScriptText(ANACHRONOS_SAY_9, me,Fandral); diff --git a/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp b/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp index fa035693008..9cbc514b468 100644 --- a/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp +++ b/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp @@ -182,18 +182,26 @@ struct boss_krik_thirAI : public ScriptedAI { DoScriptText(SAY_DEATH, me); - if (pInstance) - { - pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, DONE); - //Achievement: Watch him die - Creature *pAdd1, *pAdd2, *pAdd3; - if ((pAdd1 = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_GASHRA))) && pAdd1->isAlive() && - (pAdd2 = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_SILTHIK))) && pAdd2->isAlive() && - (pAdd3 = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_NARJIL))) && pAdd3->isAlive() && - IsHeroic()) - pInstance->DoCompleteAchievement(ACHIEV_WATH_HIM_DIE); - } + if (!pInstance) + return; + + pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, DONE); + //Achievement: Watch him die + Creature *pAdd = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_GASHRA)); + if (!pAdd || !pAdd->isAlive()) + return; + + pAdd = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_SILTHIK)); + if (!pAdd || !pAdd->isAlive()) + return; + + pAdd = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_NARJIL)); + if (!pAdd || !pAdd->isAlive()) + return; + + pInstance->DoCompleteAchievement(ACHIEV_WATH_HIM_DIE); } + void KilledUnit(Unit * victim) { if (victim == me) diff --git a/src/scripts/northrend/borean_tundra.cpp b/src/scripts/northrend/borean_tundra.cpp index b36463b581f..728e065e14a 100644 --- a/src/scripts/northrend/borean_tundra.cpp +++ b/src/scripts/northrend/borean_tundra.cpp @@ -647,6 +647,13 @@ enum eNesingwaryTrapper SPELL_TRAPPED = 46104, }; +#define CaribouTrapsNum 15 +const uint32 CaribouTraps[CaribouTrapsNum] = +{ + GO_CARIBOU_TRAP_1, GO_CARIBOU_TRAP_2, GO_CARIBOU_TRAP_3, GO_CARIBOU_TRAP_4, GO_CARIBOU_TRAP_5, + GO_CARIBOU_TRAP_6, GO_CARIBOU_TRAP_7, GO_CARIBOU_TRAP_8, GO_CARIBOU_TRAP_9, GO_CARIBOU_TRAP_10, + GO_CARIBOU_TRAP_11, GO_CARIBOU_TRAP_12, GO_CARIBOU_TRAP_13, GO_CARIBOU_TRAP_14, GO_CARIBOU_TRAP_15, +}; //#define SAY_NESINGWARY_1 -1571008 struct npc_nesingwary_trapperAI : public ScriptedAI @@ -725,24 +732,15 @@ struct npc_nesingwary_trapperAI : public ScriptedAI case 7: { GameObject *go_caribou = NULL; - if ((go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_1, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_2, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_3, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_4, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_5, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_6, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_7, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_8, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_9, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_10, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_11, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_12, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_13, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_14, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f))) + for (uint8 i = 0; i < CaribouTrapsNum; ++i) { - go_caribou->SetGoState(GO_STATE_ACTIVE); - go_caribouGUID = go_caribou->GetGUID(); + go_caribou = me->FindNearestGameObject(CaribouTraps[i], 5.0f); + if (go_caribou) + { + go_caribou->SetGoState(GO_STATE_ACTIVE); + go_caribouGUID = go_caribou->GetGUID(); + break; + } } Phase = 8; uiPhaseTimer = 1000; @@ -2029,6 +2027,16 @@ enum eHelpThemselves GO_MAMMOTH_TRAP_22 = 188044, }; +#define MammothTrapsNum 22 +const uint32 MammothTraps[MammothTrapsNum] = +{ + GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5, + GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10, + GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15, + GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20, + GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22 +}; + struct npc_trapped_mammoth_calfAI : public ScriptedAI { npc_trapped_mammoth_calfAI(Creature* c) : ScriptedAI(c) {} @@ -2038,34 +2046,19 @@ struct npc_trapped_mammoth_calfAI : public ScriptedAI void Reset() { - GameObject *pTrap; - uiTimer = 1500; bStarted = false; - if ((pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_1,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_2,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_3,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_4,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_5,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_6,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_7,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_8,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_9,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_10,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_11,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_12,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_13,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_14,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_15,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_16,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_17,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_18,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_19,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_20,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_21,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_22,1.0f))) - pTrap->SetGoState(GO_STATE_ACTIVE); + GameObject* pTrap; + for (uint8 i = 0; i < MammothTrapsNum; ++i) + { + pTrap = me->FindNearestGameObject(MammothTraps[i],11.0f); + if (pTrap) + { + pTrap->SetGoState(GO_STATE_ACTIVE); + return; + } + } } void UpdateAI(const uint32 diff) @@ -2091,34 +2084,20 @@ struct npc_trapped_mammoth_calfAI : public ScriptedAI void MovementInform(uint32 uiType, uint32 /*uiId*/) { - GameObject* pTrap; + if (uiType != POINT_MOTION_TYPE) return; me->DisappearAndDie(); - - if ((pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_1,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_2,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_3,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_4,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_5,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_6,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_7,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_8,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_9,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_10,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_11,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_12,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_13,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_14,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_15,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_16,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_17,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_18,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_19,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_20,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_21,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_22,11.0f))) - pTrap->SetLootState(GO_JUST_DEACTIVATED); + GameObject* pTrap; + for (uint8 i = 0; i < MammothTrapsNum; ++i) + { + pTrap = me->FindNearestGameObject(MammothTraps[i],11.0f); + if (pTrap) + { + pTrap->SetLootState(GO_JUST_DEACTIVATED); + return; + } + } } }; @@ -2233,8 +2212,10 @@ struct npc_valiance_keep_cannoneerAI : public ScriptedAI if (uiTimer <= diff) { me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); - GameObject* pCannon; - if ((pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_1,10)) || (pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_2,10))) + GameObject* pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_1,10); + if (!pCannon) + pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_2,10); + if (pCannon) pCannon->Use(me); uiTimer = urand(13000,18000); } diff --git a/src/scripts/northrend/icecrown.cpp b/src/scripts/northrend/icecrown.cpp index 5c47f22f825..84bc655ac22 100644 --- a/src/scripts/northrend/icecrown.cpp +++ b/src/scripts/northrend/icecrown.cpp @@ -301,29 +301,32 @@ struct npc_alorah_and_grimminAI : public ScriptedAI { npc_alorah_and_grimminAI(Creature* pCreature) : ScriptedAI(pCreature) {} - uint8 uiCast; + bool uiCast; void Reset() { - uiCast = 1; + uiCast = false; } void UpdateAI(const uint32 /*uiDiff*/) { - if (uiCast = 1) + if (uiCast) + return; + uiCast = true; + Creature* pTarget = NULL; + + switch(me->GetEntry()) { - Creature* pTarget1 = me->FindNearestCreature(NPC_EYDIS_DARKBANE, 10.0f); - Creature* pTarget2 = me->FindNearestCreature(NPC_FJOLA_LIGHTBANE, 10.0f); - switch(me->GetEntry()) - { - case NPC_PRIESTESS_ALORAH: - DoCast(pTarget1, SPELL_CHAIN); - uiCast = 0; - case NPC_PRIEST_GRIMMIN: - DoCast(pTarget2, SPELL_CHAIN); - uiCast = 0; - } + case NPC_PRIESTESS_ALORAH: + pTarget = me->FindNearestCreature(NPC_EYDIS_DARKBANE, 10.0f); + break; + case NPC_PRIEST_GRIMMIN: + pTarget = me->FindNearestCreature(NPC_FJOLA_LIGHTBANE, 10.0f); + break; } + if (pTarget) + DoCast(pTarget, SPELL_CHAIN); + if (!UpdateVictim()) return; } diff --git a/src/scripts/northrend/naxxramas/instance_naxxramas.cpp b/src/scripts/northrend/naxxramas/instance_naxxramas.cpp index 15b3aecace0..706789a73f1 100644 --- a/src/scripts/northrend/naxxramas/instance_naxxramas.cpp +++ b/src/scripts/northrend/naxxramas/instance_naxxramas.cpp @@ -286,7 +286,7 @@ struct instance_naxxramas : public InstanceData } } - bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* source, Unit const* target = NULL, uint32 miscvalue1 = 0) + bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target = NULL*/, uint32 /*miscvalue1 = 0*/) { switch(criteria_id) { diff --git a/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp b/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp index 378f2633907..3e24aaeb6c0 100644 --- a/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp +++ b/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp @@ -1072,7 +1072,7 @@ struct mob_acolyte_of_shadronAI : public ScriptedAI if (pInstance) { Unit *pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 0, 999, true); - Creature* pShadron = NULL; + Creature* pSartharion = Unit::GetCreature(*me, pInstance->GetData64(DATA_SARTHARION)); if (Creature* pShadron = Unit::GetCreature(*me, pInstance->GetData64(DATA_SHADRON))) //if not solo figth, buff main boss, else place debuff on mini-boss. both spells TARGET_SCRIPT diff --git a/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp b/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp index b365de8996f..d69f0eee846 100644 --- a/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp +++ b/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp @@ -197,7 +197,8 @@ struct boss_kelesethAI : public ScriptedAI DoScriptText(SAY_SKELETONS, me); for (uint8 i = 0; i < 5; ++i) { - if (Skeleton = me->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1] , SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) + Skeleton = me->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1] , SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); + if (Skeleton) { Skeleton->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); Skeleton->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY() , me->GetPositionZ()); diff --git a/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp b/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp index 74a94d99dc0..297fe37b7d8 100644 --- a/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp +++ b/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp @@ -103,17 +103,24 @@ struct boss_palehoofAI : public ScriptedAI { pInstance->SetData(DATA_GORTOK_PALEHOOF_EVENT, NOT_STARTED); - Creature* pTemp; - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FRENZIED_WORGEN))) && !pTemp->isAlive()) + Creature* pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FRENZIED_WORGEN)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FEROCIOUS_RHINO))) && !pTemp->isAlive()) + + pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FEROCIOUS_RHINO)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_MASSIVE_JORMUNGAR))) && !pTemp->isAlive()) + + pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_MASSIVE_JORMUNGAR)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_RAVENOUS_FURBOLG))) && !pTemp->isAlive()) + + pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_RAVENOUS_FURBOLG)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if (GameObject* pGo = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GORTOK_PALEHOOF_SPHERE))) + GameObject* pGo = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GORTOK_PALEHOOF_SPHERE)); + if (pGo) { pGo->SetGoState(GO_STATE_READY); pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); diff --git a/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp b/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp index 250238f1c12..092339be6d5 100644 --- a/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp +++ b/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp @@ -233,21 +233,24 @@ struct mob_frozen_orb_stalkerAI : public Scripted_NoMovementAI void UpdateAI(const uint32 /*diff*/) { - if (!spawned) + if (spawned) + return; + + spawned = true; + if (!pInstance) + return; + + Unit* pToravon = me->GetCreature(*me, pInstance->GetData64(DATA_TORAVON)); + if (!pToravon) + return; + + uint8 num_orbs = RAID_MODE(1, 3); + for (uint8 i=0; i<num_orbs; ++i) { - Unit* pToravon; - if (pInstance && (pToravon = me->GetCreature(*me, pInstance->GetData64(DATA_TORAVON)))) - { - uint8 num_orbs = RAID_MODE(1, 3); - for (uint8 i=0; i<num_orbs; ++i) - { - Position pos; - me->GetNearPoint(pToravon, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, 10.0f, 0.0f); - me->SetPosition(pos, true); - DoCast(me, SPELL_FROZEN_ORB_SUMMON); - } - } - spawned = true; + Position pos; + me->GetNearPoint(pToravon, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, 10.0f, 0.0f); + me->SetPosition(pos, true); + DoCast(me, SPELL_FROZEN_ORB_SUMMON); } } }; diff --git a/src/scripts/northrend/violet_hold/instance_violet_hold.cpp b/src/scripts/northrend/violet_hold/instance_violet_hold.cpp index 4d993eccd27..d124404610f 100644 --- a/src/scripts/northrend/violet_hold/instance_violet_hold.cpp +++ b/src/scripts/northrend/violet_hold/instance_violet_hold.cpp @@ -274,7 +274,8 @@ struct instance_violet_hold : public ScriptedInstance { case BOSS_MORAGG: HandleGameObject(uiMoraggCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiMoragg)) + pBoss = instance->GetCreature(uiMoragg); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_EREKEM: @@ -282,7 +283,8 @@ struct instance_violet_hold : public ScriptedInstance HandleGameObject(uiErekemRightGuardCell, bForceRespawn); HandleGameObject(uiErekemLeftGuardCell, bForceRespawn); - if (pBoss = instance->GetCreature(uiErekem)) + pBoss = instance->GetCreature(uiErekem); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); if (Creature* pGuard1 = instance->GetCreature(uiErekemGuard[0])) @@ -303,22 +305,26 @@ struct instance_violet_hold : public ScriptedInstance break; case BOSS_ICHORON: HandleGameObject(uiIchoronCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiIchoron)) + instance->GetCreature(uiIchoron); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_LAVANTHOR: HandleGameObject(uiLavanthorCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiLavanthor)) + pBoss = instance->GetCreature(uiLavanthor); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_XEVOZZ: HandleGameObject(uiXevozzCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiXevozz)) + pBoss = instance->GetCreature(uiXevozz); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_ZURAMAT: HandleGameObject(uiZuramatCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiZuramat)) + pBoss = instance->GetCreature(uiZuramat); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; } diff --git a/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp b/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp index c4fe561a3aa..14bf249c3b5 100644 --- a/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp +++ b/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp @@ -88,7 +88,7 @@ struct boss_murmurAI : public ScriptedAI // Sonic Boom instant damage (needs core fix instead of this) void SpellHitTarget(Unit *pTarget, const SpellEntry *spell) { - if (pTarget && pTarget->isAlive() && spell && spell->Id == SPELL_SONIC_BOOM_EFFECT) + if (pTarget && pTarget->isAlive() && spell && spell->Id == uint32(SPELL_SONIC_BOOM_EFFECT)) me->DealDamage(pTarget,(pTarget->GetHealth()*90)/100,NULL,SPELL_DIRECT_DAMAGE,SPELL_SCHOOL_MASK_NATURE,spell); } diff --git a/src/scripts/outland/black_temple/illidari_council.cpp b/src/scripts/outland/black_temple/illidari_council.cpp index cb3ac18be70..82cc2876b5a 100644 --- a/src/scripts/outland/black_temple/illidari_council.cpp +++ b/src/scripts/outland/black_temple/illidari_council.cpp @@ -220,15 +220,16 @@ struct mob_illidari_councilAI : public ScriptedAI Creature* pMember = NULL; for (uint8 i = 0; i < 4; ++i) { - if (pMember = (Unit::GetCreature((*me), Council[i]))) + pMember = Unit::GetCreature((*me), Council[i]); + if (!pMember) + continue; + + if (!pMember->isAlive()) { - if (!pMember->isAlive()) - { - pMember->RemoveCorpse(); - pMember->Respawn(); - } - pMember->AI()->EnterEvadeMode(); + pMember->RemoveCorpse(); + pMember->Respawn(); } + pMember->AI()->EnterEvadeMode(); } if (pInstance) diff --git a/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp b/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp index 0df1e2b5653..61c9ed9d527 100644 --- a/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp +++ b/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp @@ -204,7 +204,7 @@ struct boss_leotheras_the_blindAI : public ScriptedAI pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, NOT_STARTED); } - void CheckChannelers(bool DoEvade = true) + void CheckChannelers(/*bool DoEvade = true*/) { for (uint8 i = 0; i < 3; ++i) { @@ -646,7 +646,7 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI pInstance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, 0); Creature *leotheras = Unit::GetCreature(*me, leotherasGUID); if (leotheras && leotheras->isAlive()) - CAST_AI(boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(false); + CAST_AI(boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(/*false*/); } } diff --git a/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp b/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp index 649f0382468..181911f77a4 100644 --- a/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp +++ b/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp @@ -98,7 +98,7 @@ struct boss_nazanAI : public ScriptedAI void SpellHitTarget(Unit *pTarget, const SpellEntry* entry) { - if (pTarget && entry->Id == SPELL_FIREBALL) + if (pTarget && entry->Id == uint32(SPELL_FIREBALL)) me->SummonCreature(ENTRY_LIQUID_FIRE,pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(),pTarget->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,30000); } @@ -260,13 +260,18 @@ struct boss_vazruden_the_heraldAI : public ScriptedAI if (summoned) { Creature *Nazan = Unit::GetCreature(*me, NazanGUID); - Creature *Vazruden = Unit::GetCreature(*me, VazrudenGUID); - if (Nazan || (Nazan = me->FindNearestCreature(ENTRY_NAZAN, 5000))) + if (!Nazan) + Nazan = me->FindNearestCreature(ENTRY_NAZAN, 5000); + if (Nazan) { Nazan->DisappearAndDie(); NazanGUID = 0; } - if (Vazruden || (Vazruden = me->FindNearestCreature(ENTRY_VAZRUDEN, 5000))) + + Creature *Vazruden = Unit::GetCreature(*me, VazrudenGUID); + if (!Vazruden) + Vazruden = me->FindNearestCreature(ENTRY_VAZRUDEN, 5000); + if (Vazruden) { Vazruden->DisappearAndDie(); VazrudenGUID = 0; diff --git a/src/scripts/world/go_scripts.cpp b/src/scripts/world/go_scripts.cpp index 4cc377984ad..28ba7b47e97 100644 --- a/src/scripts/world/go_scripts.cpp +++ b/src/scripts/world/go_scripts.cpp @@ -635,35 +635,37 @@ enum eJotunheimCage bool GOHello_go_jotunheim_cage(Player* pPlayer, GameObject* pGO) { - Creature* pPrisoner; - pPrisoner = NULL; - - if ((pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_HUMAN, 5.0f, true)) || - (pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_TROLL, 5.0f, true)) || - (pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_ORC, 5.0f, true)) || - (pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_NE, 5.0f, true))) + Creature* pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_HUMAN, 5.0f, true); + if (!pPrisoner) { - if (pPrisoner && pPrisoner->isAlive()) + pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_TROLL, 5.0f, true); + if (!pPrisoner) { - pPrisoner->DisappearAndDie(); - pPlayer->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0); - switch(pPrisoner->GetEntry()) - { - case NPC_EBON_BLADE_PRISONER_HUMAN: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_H,true); - break; - case NPC_EBON_BLADE_PRISONER_NE: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_NE,true); - break; - case NPC_EBON_BLADE_PRISONER_TROLL: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_TROLL,true); - break; - case NPC_EBON_BLADE_PRISONER_ORC: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_ORC,true); - break; - } + pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_ORC, 5.0f, true); + if (!pPrisoner) + pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_NE, 5.0f, true); } } + if (!pPrisoner || !pPrisoner->isAlive()) + return false; + + pPrisoner->DisappearAndDie(); + pPlayer->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0); + switch(pPrisoner->GetEntry()) + { + case NPC_EBON_BLADE_PRISONER_HUMAN: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_H,true); + break; + case NPC_EBON_BLADE_PRISONER_NE: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_NE,true); + break; + case NPC_EBON_BLADE_PRISONER_TROLL: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_TROLL,true); + break; + case NPC_EBON_BLADE_PRISONER_ORC: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_ORC,true); + break; + } return true; } enum eTableTheka @@ -758,14 +760,26 @@ enum ePrisonersOfWyrmskull bool GOHello_go_dragonflayer_cage(Player *pPlayer, GameObject *pGO) { - Creature *pPrisoner = NULL; - Quest const* qInfo = objmgr.GetQuestTemplate(QUEST_PRISONERS_OF_WYRMSKULL); + if (pPlayer->GetQuestStatus(QUEST_PRISONERS_OF_WYRMSKULL) != QUEST_STATUS_INCOMPLETE) + return true; + + Creature* pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PRIEST, 2.0f); + if (!pPrisoner) + { + pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_MAGE, 2.0f); + if (!pPrisoner) + { + pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_WARRIOR, 2.0f); + if (!pPrisoner) + pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PALADIN, 2.0f); + } + } + + if (!pPrisoner || !pPrisoner->isAlive()) + return true; - if (pPlayer->GetQuestStatus(QUEST_PRISONERS_OF_WYRMSKULL) == QUEST_STATUS_INCOMPLETE && - ((pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PRIEST,2.0f)) || - (pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_MAGE,2.0f)) || - (pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_WARRIOR,2.0f)) || - (pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PALADIN,2.0f))) && pPrisoner->isAlive()) + Quest const* qInfo = objmgr.GetQuestTemplate(QUEST_PRISONERS_OF_WYRMSKULL); + if (qInfo) { //TODO: prisoner should help player for a short period of time pPlayer->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0],0); @@ -787,15 +801,17 @@ enum eTadpoles bool GOHello_go_tadpole_cage(Player *pPlayer, GameObject *pGO) { - Creature *pTadpole; - if (pPlayer->GetQuestStatus(QUEST_OH_NOES_THE_TADPOLES) == QUEST_STATUS_INCOMPLETE && - (pTadpole = pGO->FindNearestCreature(NPC_WINTERFIN_TADPOLE,1.0f))) + if (pPlayer->GetQuestStatus(QUEST_OH_NOES_THE_TADPOLES) == QUEST_STATUS_INCOMPLETE) + { + Creature *pTadpole = pGO->FindNearestCreature(NPC_WINTERFIN_TADPOLE,1.0f); + if (pTadpole) { pGO->UseDoorOrButton(); pTadpole->DisappearAndDie(); pPlayer->KilledMonsterCredit(NPC_WINTERFIN_TADPOLE,0); //FIX: Summon minion tadpole } + } return true; } @@ -814,14 +830,18 @@ enum eReallyDoneItThisTime bool GOHello_go_black_cage(Player *pPlayer, GameObject *pGO) { - Creature *pPrisoner; - if (((pPlayer->GetTeamId() == TEAM_ALLIANCE && pPlayer->GetQuestStatus(QUEST_ALLIANCE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE) || - (pPlayer->GetTeamId() == TEAM_HORDE && pPlayer->GetQuestStatus(QUEST_HORDE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE)) && - ((pPrisoner = pGO->FindNearestCreature(NPC_CAPTIVE_ASPIRANT,1.0f)) || (pPrisoner = pGO->FindNearestCreature(NPC_KUL,1.0f)))) + if ((pPlayer->GetTeamId() == TEAM_ALLIANCE && pPlayer->GetQuestStatus(QUEST_ALLIANCE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE) || + (pPlayer->GetTeamId() == TEAM_HORDE && pPlayer->GetQuestStatus(QUEST_HORDE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE)) { - pGO->UseDoorOrButton(); - pPrisoner->DisappearAndDie(); - pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); + Creature *pPrisoner = pGO->FindNearestCreature(NPC_CAPTIVE_ASPIRANT,1.0f); + if (!pPrisoner) + pPrisoner = pGO->FindNearestCreature(NPC_KUL,1.0f); + if (pPrisoner) + { + pGO->UseDoorOrButton(); + pPrisoner->DisappearAndDie(); + pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); + } } return true; } @@ -893,14 +913,13 @@ enum eProphecy bool GOHello_go_stillpine_cage(Player *pPlayer, GameObject *pGO) { - Creature *pPrisoner; - if (pPlayer->GetQuestStatus(QUEST_PROPHECY_OF_AKIDA) == QUEST_STATUS_INCOMPLETE && - (pPrisoner = pGO->FindNearestCreature(NPC_STILLPINE_CAPTIVE,1.0f))) - { - pGO->UseDoorOrButton(); - pPrisoner->DisappearAndDie(); - pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); - } + if (pPlayer->GetQuestStatus(QUEST_PROPHECY_OF_AKIDA) == QUEST_STATUS_INCOMPLETE) + if (Creature *pPrisoner = pGO->FindNearestCreature(NPC_STILLPINE_CAPTIVE,1.0f)) + { + pGO->UseDoorOrButton(); + pPrisoner->DisappearAndDie(); + pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); + } return true; } diff --git a/src/scripts/world/item_scripts.cpp b/src/scripts/world/item_scripts.cpp index 85866c0ed43..241f6020caa 100644 --- a/src/scripts/world/item_scripts.cpp +++ b/src/scripts/world/item_scripts.cpp @@ -253,36 +253,40 @@ enum ePileFakeFur GO_HIGH_QUALITY_FUR = 187983, NPC_NESINGWARY_TRAPPER = 25835 }; + +#define CaribouTrapsNum 15 +const uint32 CaribouTraps[CaribouTrapsNum] = +{ + GO_CARIBOU_TRAP_1, GO_CARIBOU_TRAP_2, GO_CARIBOU_TRAP_3, GO_CARIBOU_TRAP_4, GO_CARIBOU_TRAP_5, + GO_CARIBOU_TRAP_6, GO_CARIBOU_TRAP_7, GO_CARIBOU_TRAP_8, GO_CARIBOU_TRAP_9, GO_CARIBOU_TRAP_10, + GO_CARIBOU_TRAP_11, GO_CARIBOU_TRAP_12, GO_CARIBOU_TRAP_13, GO_CARIBOU_TRAP_14, GO_CARIBOU_TRAP_15, +}; + + bool ItemUse_item_pile_fake_furs(Player *pPlayer, Item * /*pItem*/, SpellCastTargets const & /*targets*/) { - GameObject *pGo; - if ((pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_1, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_2, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_3, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_4, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_5, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_6, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_7, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_8, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_9, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_10, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_11, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_12, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_13, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_14, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f))) + GameObject *pGo = NULL; + for (uint8 i = 0; i < CaribouTrapsNum; ++i) { - if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f)) - return true; - float x, y, z; - pGo->GetClosePoint(x, y, z, pGo->GetObjectSize() / 3, 7.0f); - pGo->SummonGameObject(GO_HIGH_QUALITY_FUR, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), 0, 0, 0, 0, 0, 1000); - if (TempSummon* summon = pPlayer->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, pGo->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) - { - summon->SetVisibility(VISIBILITY_OFF); - summon->SetReactState(REACT_PASSIVE); - summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); - } + pGo = pPlayer->FindNearestGameObject(CaribouTraps[i], 5.0f); + if (pGo) + break; + } + + if (!pGo) + return false; + + if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f)) + return true; + + float x, y, z; + pGo->GetClosePoint(x, y, z, pGo->GetObjectSize() / 3, 7.0f); + pGo->SummonGameObject(GO_HIGH_QUALITY_FUR, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), 0, 0, 0, 0, 0, 1000); + if (TempSummon* summon = pPlayer->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, pGo->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) + { + summon->SetVisibility(VISIBILITY_OFF); + summon->SetReactState(REACT_PASSIVE); + summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); } return false; } @@ -348,41 +352,38 @@ enum eHelpThemselves GO_MAMMOTH_TRAP_22 = 188044, }; +#define MammothTrapsNum 22 +const uint32 MammothTraps[MammothTrapsNum] = +{ + GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5, + GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10, + GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15, + GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20, + GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22 +}; + bool ItemUse_item_dehta_trap_smasher(Player* pPlayer, Item* /*pItem*/, const SpellCastTargets & /*pTargets*/) { + if (pPlayer->GetQuestStatus(QUEST_CANNOT_HELP_THEMSELVES) != QUEST_STATUS_INCOMPLETE) + return false; + Creature* pMammoth; - GameObject* pTrap; + pMammoth = pPlayer->FindNearestCreature(NPC_TRAPPED_MAMMOTH_CALF,5.0f); + if (!pMammoth) + return false; - if (pPlayer->GetQuestStatus(QUEST_CANNOT_HELP_THEMSELVES) == QUEST_STATUS_INCOMPLETE && - (pMammoth = pPlayer->FindNearestCreature(NPC_TRAPPED_MAMMOTH_CALF,5.0f)) && - ((pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_1,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_2,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_3,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_4,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_5,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_6,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_7,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_8,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_9,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_10,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_11,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_12,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_13,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_14,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_15,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_16,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_17,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_18,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_19,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_20,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_21,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_22,5.0f)))) + GameObject* pTrap; + for (uint8 i = 0; i < MammothTrapsNum; ++i) { - pMammoth->AI()->DoAction(1); - pTrap->SetGoState(GO_STATE_READY); - pPlayer->KilledMonsterCredit(NPC_TRAPPED_MAMMOTH_CALF,0); - } - + pTrap = pPlayer->FindNearestGameObject(MammothTraps[i],11.0f); + if (pTrap) + { + pMammoth->AI()->DoAction(1); + pTrap->SetGoState(GO_STATE_READY); + pPlayer->KilledMonsterCredit(NPC_TRAPPED_MAMMOTH_CALF,0); + return true; + } + } return false; } |