diff options
author | maximius <none@none> | 2009-09-26 02:09:26 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-09-26 02:09:26 -0700 |
commit | f8a6434fc0c2ea7cfd325830bac6a208e171f0ab (patch) | |
tree | cb5feaedb834a02cb328525971f59140edb28c3b /src | |
parent | 2853aa1cd1bb3026d697672aefb6eace902f90b1 (diff) |
*Replace a ton of switches with RAND(), and overload RAND() to support up to 16 parameters.
*Add a safety check to prevent knocking players off of transports, just in case they die while on one.
*Fix a couple incorrect spell defines.
--HG--
branch : trunk
Diffstat (limited to 'src')
22 files changed, 323 insertions, 248 deletions
diff --git a/src/bindings/scripts/base/guard_ai.cpp b/src/bindings/scripts/base/guard_ai.cpp index b55eae2dbad..1001d3a1170 100644 --- a/src/bindings/scripts/base/guard_ai.cpp +++ b/src/bindings/scripts/base/guard_ai.cpp @@ -46,14 +46,7 @@ void guardAI::Reset() void guardAI::EnterCombat(Unit *who) { if (m_creature->GetEntry() == 15184) - { - switch(rand()%3) - { - case 0: DoScriptText(SAY_GUARD_SIL_AGGRO1, m_creature, who); break; - case 1: DoScriptText(SAY_GUARD_SIL_AGGRO1, m_creature, who); break; - case 2: DoScriptText(SAY_GUARD_SIL_AGGRO1, m_creature, who); break; - } - } + DoScriptText(RAND(SAY_GUARD_SIL_AGGRO1,SAY_GUARD_SIL_AGGRO2,SAY_GUARD_SIL_AGGRO3), m_creature, who); if (SpellEntry const *spell = m_creature->reachWithSpellAttack(who)) DoCastSpell(who, spell); diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp index 218a1dafc39..2a2d64e412e 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_curator.cpp @@ -65,11 +65,7 @@ struct TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI void KilledUnit(Unit *victim) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_KILL1, m_creature); break; - case 1: DoScriptText(SAY_KILL2, m_creature); break; - } + DoScriptText(RAND(SAY_KILL1,SAY_KILL2), m_creature); } void JustDied(Unit *victim) @@ -151,10 +147,9 @@ struct TRINITY_DLL_DECL boss_curatorAI : public ScriptedAI } else { - switch(rand()%4) + if(urand(0,1) == 0) { - case 0: DoScriptText(SAY_SUMMON1, m_creature); break; - case 1: DoScriptText(SAY_SUMMON2, m_creature); break; + DoScriptText(RAND(SAY_SUMMON1,SAY_SUMMON2), m_creature); } } } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp index 508e718797d..381685297ab 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_maiden_of_virtue.cpp @@ -62,15 +62,8 @@ struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI void KilledUnit(Unit* Victim) { - if (rand()%2) - return; - - switch(rand()%3) - { - case 0: DoScriptText(SAY_SLAY1, m_creature);break; - case 1: DoScriptText(SAY_SLAY2, m_creature);break; - case 2: DoScriptText(SAY_SLAY3, m_creature);break; - } + if (urand(0,1) == 0) + DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature); } void JustDied(Unit* Killer) @@ -80,7 +73,7 @@ struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI void EnterCombat(Unit *who) { - DoScriptText(SAY_AGGRO, m_creature); + DoScriptText(SAY_AGGRO, m_creature); } void UpdateAI(const uint32 diff) @@ -92,25 +85,21 @@ struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI { DoCast(m_creature, SPELL_BERSERK,true); Enraged = true; - }else Enrage_Timer -=diff; + } else Enrage_Timer -=diff; if (Holyground_Timer < diff) { DoCast(m_creature, SPELL_HOLYGROUND, true); //Triggered so it doesn't interrupt her at all Holyground_Timer = 3000; - }else Holyground_Timer -= diff; + } else Holyground_Timer -= diff; if (Repentance_Timer < diff) { DoCast(m_creature->getVictim(),SPELL_REPENTANCE); + DoScriptText(RAND(SAY_REPENTANCE1,SAY_REPENTANCE2), m_creature); - switch(rand()%2) - { - case 0: DoScriptText(SAY_REPENTANCE1, m_creature);break; - case 1: DoScriptText(SAY_REPENTANCE2, m_creature);break; - } Repentance_Timer = 25000 + rand()%10000; //A little randomness on that spell - }else Repentance_Timer -= diff; + } else Repentance_Timer -= diff; if (Holyfire_Timer < diff) { @@ -118,7 +107,7 @@ struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI DoCast(target,SPELL_HOLYFIRE); Holyfire_Timer = 8000 + rand()%15000; //Anywhere from 8 to 23 seconds, good luck having several of those in a row! - }else Holyfire_Timer -= diff; + } else Holyfire_Timer -= diff; if (Holywrath_Timer < diff) { @@ -127,7 +116,7 @@ struct TRINITY_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI Holywrath_Timer = 20000+(rand()%5000); //20-30 secs sounds nice - }else Holywrath_Timer -= diff; + } else Holywrath_Timer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp index 53b1c2d11b2..8920f7e62a0 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_midnight.cpp @@ -86,12 +86,7 @@ struct TRINITY_DLL_DECL boss_midnightAI : public ScriptedAI Attumen = pAttumen->GetGUID(); pAttumen->AI()->AttackStart(m_creature->getVictim()); SetMidnight(pAttumen, m_creature->GetGUID()); - switch(rand()%3) - { - case 0: DoScriptText(SAY_APPEAR1, pAttumen); break; - case 1: DoScriptText(SAY_APPEAR2, pAttumen); break; - case 2: DoScriptText(SAY_APPEAR3, pAttumen); break; - } + DoScriptText(RAND(SAY_APPEAR1,SAY_APPEAR2,SAY_APPEAR3), pAttumen); } } else if (Phase == 2 && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 25) @@ -190,11 +185,7 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI void KilledUnit(Unit *victim) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_KILL1, m_creature); break; - case 1: DoScriptText(SAY_KILL2, m_creature); break; - } + DoScriptText(RAND(SAY_KILL1,SAY_KILL2), m_creature); } void JustDied(Unit *victim) @@ -244,11 +235,7 @@ struct TRINITY_DLL_DECL boss_attumenAI : public ScriptedAI if (RandomYellTimer < diff) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_RANDOM1, m_creature); break; - case 1: DoScriptText(SAY_RANDOM2, m_creature); break; - } + DoScriptText(RAND(SAY_RANDOM1,SAY_RANDOM2), m_creature); RandomYellTimer = 30000 + (rand()%31)*1000; } else RandomYellTimer -= diff; diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp index d32c670e133..3f8dcbba2f4 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_moroes.cpp @@ -121,12 +121,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI void KilledUnit(Unit* victim) { - switch (rand()%3) - { - case 0: DoScriptText(SAY_KILL_1, m_creature); break; - case 1: DoScriptText(SAY_KILL_2, m_creature); break; - case 2: DoScriptText(SAY_KILL_3, m_creature); break; - } + DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2,SAY_KILL_3), m_creature); } void JustDied(Unit* victim) @@ -237,7 +232,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI { Temp->AI()->AttackStart(m_creature->getVictim()); DoZoneInCombat(Temp); - }else + } else EnterEvadeMode(); } } @@ -274,7 +269,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI } } CheckAdds_Timer = 5000; - }else CheckAdds_Timer -= diff; + } else CheckAdds_Timer -= diff; if (!Enrage) { @@ -285,13 +280,13 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI InVanish = true; Vanish_Timer = 30000; Wait_Timer = 5000; - }else Vanish_Timer -= diff; + } else Vanish_Timer -= diff; if (Gouge_Timer < diff) { DoCast(m_creature->getVictim(), SPELL_GOUGE); Gouge_Timer = 40000; - }else Gouge_Timer -= diff; + } else Gouge_Timer -= diff; if (Blind_Timer < diff) { @@ -304,24 +299,20 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI } else Blind_Timer = 1000; - }else Blind_Timer -= diff; + } else Blind_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; - } + DoScriptText(RAND(SAY_SPECIAL_1,SAY_SPECIAL_2), m_creature); if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) target->CastSpell(target, SPELL_GARROTE,true); InVanish = false; - }else Wait_Timer -= diff; + } else Wait_Timer -= diff; } if (!InVanish) diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp index d960cfb2222..d152b3b5c78 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp @@ -212,12 +212,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI void KilledUnit(Unit *victim) { - switch(rand()%3) - { - case 0: DoScriptText(SAY_SLAY1, m_creature); break; - case 1: DoScriptText(SAY_SLAY2, m_creature); break; - case 2: DoScriptText(SAY_SLAY3, m_creature); break; - } + DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2,SAY_SLAY3), m_creature); } void JustDied(Unit *victim) @@ -364,11 +359,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI DoCast(Infernal, SPELL_INFERNAL_RELAY); } - switch(rand()%2) - { - case 0: DoScriptText(SAY_SUMMON1, m_creature); break; - case 1: DoScriptText(SAY_SUMMON2, m_creature); break; - } + DoScriptText(RAND(SAY_SUMMON1,SAY_SUMMON2), m_creature); } void UpdateAI(const uint32 diff) diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp index 490828db73b..23cffc9abb1 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_shade_of_aran.cpp @@ -147,11 +147,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI void KilledUnit(Unit *victim) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_KILL1, m_creature); break; - case 1: DoScriptText(SAY_KILL2, m_creature); break; - } + DoScriptText(RAND(SAY_KILL1,SAY_KILL2), m_creature); } void JustDied(Unit *victim) @@ -167,12 +163,7 @@ struct TRINITY_DLL_DECL boss_aranAI : public ScriptedAI void EnterCombat(Unit *who) { - switch(rand()%3) - { - case 0: DoScriptText(SAY_AGGRO1, m_creature); break; - case 1: DoScriptText(SAY_AGGRO2, m_creature); break; - case 2: DoScriptText(SAY_AGGRO3, m_creature); break; - } + DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), m_creature); if (pInstance) { diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp index ea5b0bade36..639591e25a5 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_terestian_illhoof.cpp @@ -226,11 +226,7 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI void KilledUnit(Unit *victim) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_SLAY1, m_creature); break; - case 1: DoScriptText(SAY_SLAY2, m_creature); break; - } + DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), m_creature); } void JustDied(Unit *killer) @@ -297,11 +293,7 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI { CAST_AI(mob_demon_chainAI, Chains->AI())->SacrificeGUID = target->GetGUID(); Chains->CastSpell(Chains, SPELL_DEMON_CHAINS, true); - switch(rand()%2) - { - case 0: DoScriptText(SAY_SACRIFICE1, m_creature); break; - case 1: DoScriptText(SAY_SACRIFICE2, m_creature); break; - } + DoScriptText(RAND(SAY_SACRIFICE1,SAY_SACRIFICE2), m_creature); SacrificeTimer = 30000; } } @@ -324,11 +316,7 @@ struct TRINITY_DLL_DECL boss_terestianAI : public ScriptedAI PortalGUID[i] = Portal->GetGUID(); } SummonedPortals = true; - switch(rand()%2) - { - case 0: DoScriptText(SAY_SUMMON1, m_creature); break; - case 1: DoScriptText(SAY_SUMMON2, m_creature); break; - } + DoScriptText(RAND(SAY_SUMMON1,SAY_SUMMON2), m_creature); } uint32 random = rand()%2; Creature* Imp = m_creature->SummonCreature(CREATURE_FIENDISHIMP, PortalLocations[random][0], PortalLocations[random][1], PORTAL_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15000); diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp index 5d68c54c88f..51827bd3fb3 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/bosses_opera.cpp @@ -580,11 +580,7 @@ struct TRINITY_DLL_DECL boss_croneAI : public ScriptedAI void EnterCombat(Unit* who) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_CRONE_AGGRO, m_creature); break; - case 1: DoScriptText(SAY_CRONE_AGGRO2, m_creature); break; - } + DoScriptText(RAND(SAY_CRONE_AGGRO,SAY_CRONE_AGGRO2), m_creature); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp index 2e8454631d5..2953db13571 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_priestess_delrissa.cpp @@ -1110,21 +1110,16 @@ struct TRINITY_DLL_DECL boss_apokoAI : public boss_priestess_lackey_commonAI if (Totem_Timer < diff) { - switch(rand()%3) - { - case 0: DoCast(m_creature, SPELL_WINDFURY_TOTEM); break; - case 1: DoCast(m_creature, SPELL_FIRE_NOVA_TOTEM); break; - case 2: DoCast(m_creature, SPELL_EARTHBIND_TOTEM); break; - } + DoCast(m_creature, RAND(SPELL_WINDFURY_TOTEM,SPELL_FIRE_NOVA_TOTEM,SPELL_EARTHBIND_TOTEM)); ++Totem_Amount; Totem_Timer = Totem_Amount*2000; - }else Totem_Timer -= diff; + } else Totem_Timer -= diff; if (War_Stomp_Timer < diff) { DoCast(m_creature, SPELL_WAR_STOMP); War_Stomp_Timer = 10000; - }else War_Stomp_Timer -= diff; + } else War_Stomp_Timer -= diff; if (Purge_Timer < diff) { @@ -1132,13 +1127,13 @@ struct TRINITY_DLL_DECL boss_apokoAI : public boss_priestess_lackey_commonAI DoCast(pUnit, SPELL_PURGE); Purge_Timer = 15000; - }else Purge_Timer -= diff; + } else Purge_Timer -= diff; if (Frost_Shock_Timer < diff) { DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK); Frost_Shock_Timer = 7000; - }else Frost_Shock_Timer -= diff; + } else Frost_Shock_Timer -= diff; if (Healing_Wave_Timer < diff) { @@ -1153,7 +1148,7 @@ struct TRINITY_DLL_DECL boss_apokoAI : public boss_priestess_lackey_commonAI Healing_Wave_Timer = 5000; // } // } - }else Healing_Wave_Timer -= diff; + } else Healing_Wave_Timer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp index b7c9961da9e..7b0dd626ecf 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/magisters_terrace/boss_selin_fireheart.cpp @@ -191,11 +191,7 @@ struct TRINITY_DLL_DECL boss_selin_fireheartAI : public ScriptedAI void KilledUnit(Unit* victim) { - switch(rand()%2) - { - case 0: DoScriptText(SAY_KILL_1, m_creature); break; - case 1: DoScriptText(SAY_KILL_2, m_creature); break; - } + DoScriptText(RAND(SAY_KILL_1,SAY_KILL_2), m_creature); } void MovementInform(uint32 type, uint32 id) diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp index 7af3bcce6b6..141b0150555 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/molten_core/molten_core.cpp @@ -49,16 +49,8 @@ CreatureAI* GetAI_mob_ancient_core_hound(Creature* pCreature) ai->Spell[0].First_Cast = 10000; ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - uint32 RandDebuff = 0; - switch(rand()%6) - { - case 0 : RandDebuff = SPELL_GROUND_STOMP; break; - case 1 : RandDebuff = SPELL_ANCIENT_DREAD; break; - case 2 : RandDebuff = SPELL_CAUTERIZING_FLAMES; break; - case 3 : RandDebuff = SPELL_WITHERING_HEAT; break; - case 4 : RandDebuff = SPELL_ANCIENT_DESPAIR; break; - case 5 : RandDebuff = SPELL_ANCIENT_HYSTERIA; break; - } + uint32 RandDebuff = RAND(SPELL_GROUND_STOMP,SPELL_ANCIENT_DREAD,SPELL_CAUTERIZING_FLAMES, + SPELL_WITHERING_HEAT,SPELL_ANCIENT_DESPAIR,SPELL_ANCIENT_HYSTERIA); ai->Spell[1].Enabled = true; ai->Spell[1].Spell_Id = RandDebuff; diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp index 19d7549c786..34e5e6d820a 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter2.cpp @@ -77,26 +77,12 @@ struct TRINITY_DLL_DECL npc_crusade_persuadedAI : public ScriptedAI me->SetReactState(REACT_PASSIVE); DoCastAOE(58111, true); - switch(rand()%6) - { - case 0: DoScriptText(SAY_PERSUADE1, caster);break; - case 1: DoScriptText(SAY_PERSUADE2, caster);break; - case 2: DoScriptText(SAY_PERSUADE3, caster);break; - case 3: DoScriptText(SAY_PERSUADE4, caster);break; - case 4: DoScriptText(SAY_PERSUADE5, caster);break; - case 5: DoScriptText(SAY_PERSUADE6, caster);break; - case 6: DoScriptText(SAY_PERSUADE7, caster);break; - } + DoScriptText(RAND(SAY_PERSUADE1,SAY_PERSUADE2,SAY_PERSUADE3, + SAY_PERSUADE4,SAY_PERSUADE5,SAY_PERSUADE6, + SAY_PERSUADE7), caster); - switch(rand()%5) - { - case 0: DoScriptText(SAY_CRUSADER1, me);break; - case 1: DoScriptText(SAY_CRUSADER2, me);break; - case 2: DoScriptText(SAY_CRUSADER3, me);break; - case 3: DoScriptText(SAY_CRUSADER4, me);break; - case 4: DoScriptText(SAY_CRUSADER5, me);break; - case 5: DoScriptText(SAY_CRUSADER6, me);break; - } + DoScriptText(RAND(SAY_CRUSADER1,SAY_CRUSADER2,SAY_CRUSADER3, + SAY_CRUSADER4,SAY_CRUSADER5,SAY_CRUSADER6), me); } } } @@ -488,12 +474,8 @@ struct TRINITY_DLL_DECL mob_high_inquisitor_valrothAI : public ScriptedAI void Shout() { - switch(rand()%20) - { - case 0: DoScriptText(SAY_VALROTH3, me);break; - case 1: DoScriptText(SAY_VALROTH4, me);break; - case 2: DoScriptText(SAY_VALROTH5, me);break; - } + if(rand()%100 < 15) + DoScriptText(RAND(SAY_VALROTH3,SAY_VALROTH4,SAY_VALROTH5), me); } void JustDied(Unit* killer) diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp index 9bcc7129816..d41cc852791 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp @@ -1297,62 +1297,49 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI { DoCast(me, SPELL_ANTI_MAGIC_ZONE1); uiAnti_magic_zone = 25000 + rand()%5000; - }else uiAnti_magic_zone -= diff; + } else uiAnti_magic_zone -= diff; if (uiDeath_strike < diff) { DoCast(me->getVictim(), SPELL_DEATH_STRIKE); uiDeath_strike = 5000 + rand()%5000; - }else uiDeath_strike -= diff; + } else uiDeath_strike -= diff; if (uiDeath_embrace < diff) { DoCast(me->getVictim(), SPELL_DEATH_EMBRACE); uiDeath_embrace = 5000 + rand()%5000; - }else uiDeath_embrace -= diff; + } else uiDeath_embrace -= diff; if (uiIcy_touch < diff) { DoCast(me->getVictim(), SPELL_ICY_TOUCH1); uiIcy_touch = 5000 + rand()%5000; - }else uiIcy_touch -= diff; + } else uiIcy_touch -= diff; if (uiUnholy_blight < diff) { DoCast(me->getVictim(), SPELL_UNHOLY_BLIGHT); uiUnholy_blight = 5000 + rand()%5000; - }else uiUnholy_blight -= diff; + } else uiUnholy_blight -= diff; if (uiFight_speech < diff) { - switch(rand()%15) - { - case 0: DoScriptText(SAY_LIGHT_OF_DAWN09, me);break; - case 1: DoScriptText(SAY_LIGHT_OF_DAWN10, me);break; - case 2: DoScriptText(SAY_LIGHT_OF_DAWN11, me);break; - case 3: DoScriptText(SAY_LIGHT_OF_DAWN12, me);break; - case 4: DoScriptText(SAY_LIGHT_OF_DAWN13, me);break; - case 5: DoScriptText(SAY_LIGHT_OF_DAWN14, me);break; - case 6: DoScriptText(SAY_LIGHT_OF_DAWN15, me);break; - case 7: DoScriptText(SAY_LIGHT_OF_DAWN16, me);break; - case 8: DoScriptText(SAY_LIGHT_OF_DAWN17, me);break; - case 9: DoScriptText(SAY_LIGHT_OF_DAWN18, me);break; - case 10: DoScriptText(SAY_LIGHT_OF_DAWN19, me);break; - case 11: DoScriptText(SAY_LIGHT_OF_DAWN20, me);break; - case 12: DoScriptText(SAY_LIGHT_OF_DAWN21, me);break; - case 13: DoScriptText(SAY_LIGHT_OF_DAWN22, me);break; - case 14: DoScriptText(SAY_LIGHT_OF_DAWN23, me);break; - case 15: DoScriptText(SAY_LIGHT_OF_DAWN24, me);break; - } + DoScriptText(RAND(SAY_LIGHT_OF_DAWN09,SAY_LIGHT_OF_DAWN10,SAY_LIGHT_OF_DAWN11, + SAY_LIGHT_OF_DAWN12,SAY_LIGHT_OF_DAWN13,SAY_LIGHT_OF_DAWN14, + SAY_LIGHT_OF_DAWN15,SAY_LIGHT_OF_DAWN16,SAY_LIGHT_OF_DAWN17, + SAY_LIGHT_OF_DAWN18,SAY_LIGHT_OF_DAWN19,SAY_LIGHT_OF_DAWN20, + SAY_LIGHT_OF_DAWN21,SAY_LIGHT_OF_DAWN22,SAY_LIGHT_OF_DAWN23, + SAY_LIGHT_OF_DAWN24), me); uiFight_speech = 15000 + rand()%5000; - }else uiFight_speech -= diff; + } else uiFight_speech -= diff; // Check spawns if (uiSpawncheck < diff) { SpawnNPC(); uiSpawncheck = 1000; - }else uiSpawncheck -= diff; + } else uiSpawncheck -= diff; // Check targets if (uiTargetcheck < diff) @@ -1370,7 +1357,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI NPCChangeTarget(uiThassarianGUID); uiTargetcheck = 10000; - }else uiTargetcheck -= diff; + } else uiTargetcheck -= diff; // Battle end if (uiFight_duration < diff + 5000) @@ -1476,7 +1463,7 @@ struct TRINITY_DLL_DECL npc_highlord_darion_mograineAI : public npc_escortAI SetHoldState(false); - }else uiFight_duration -= diff; + } else uiFight_duration -= diff; DoMeleeAttackIfReady(); } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp index 67deee09d0b..75b5b7662da 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_brutallus.cpp @@ -130,12 +130,7 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI void KilledUnit(Unit* victim) { - switch(rand()%3) - { - case 0: DoScriptText(YELL_KILL1, m_creature); break; - case 1: DoScriptText(YELL_KILL2, m_creature); break; - case 2: DoScriptText(YELL_KILL3, m_creature); break; - } + DoScriptText(RAND(YELL_KILL1,YELL_KILL2,YELL_KILL3), m_creature); } void JustDied(Unit* Killer) @@ -155,7 +150,8 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI { if (!Intro) return; - if (Madrigosa){ + if (Madrigosa) + { Madrigosa->setDeathState(ALIVE); Madrigosa->setActive(true); IsIntro = true; @@ -176,7 +172,7 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI if (!Madrigosa) return; - switch(IntroPhase) + switch (IntroPhase) { case 0: DoScriptText(YELL_MADR_ICE_BARRIER, Madrigosa); @@ -260,17 +256,20 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI { if (IsIntro) { - if (IntroPhaseTimer < diff){ + if (IntroPhaseTimer < diff) DoIntro(); - }else IntroPhaseTimer -= diff; + else IntroPhaseTimer -= diff; - if (IntroPhase == 3 + 1){ - if (IntroFrostBoltTimer < diff){ - if (Madrigosa){ + if (IntroPhase == 3 + 1) + { + if (IntroFrostBoltTimer < diff) + { + if (Madrigosa) + { Madrigosa->CastSpell(m_creature, SPELL_INTRO_FROSTBOLT, false); IntroFrostBoltTimer = 2000; } - }else IntroFrostBoltTimer -= diff; + } else IntroFrostBoltTimer -= diff; } } @@ -281,33 +280,28 @@ struct TRINITY_DLL_DECL boss_brutallusAI : public ScriptedAI { DoCast(m_creature->getVictim(), SPELL_METEOR_SLASH); SlashTimer = 11000; - }else SlashTimer -= diff; + } else SlashTimer -= diff; if (StompTimer < diff) { - switch(rand()%3) - { - case 0: DoScriptText(YELL_LOVE1, m_creature); break; - case 1: DoScriptText(YELL_LOVE2, m_creature); break; - case 2: DoScriptText(YELL_LOVE3, m_creature); break; - } + DoScriptText(RAND(YELL_LOVE1,YELL_LOVE2,YELL_LOVE3), m_creature); DoCast(m_creature->getVictim(), SPELL_STOMP); StompTimer = 30000; - }else StompTimer -= diff; + } else StompTimer -= diff; if (BurnTimer < diff) { if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0)) target->CastSpell(target, SPELL_BURN, true); BurnTimer = 60000; - }else BurnTimer -= diff; + } else BurnTimer -= diff; if (BerserkTimer < diff && !Enraged) { DoScriptText(YELL_BERSERK, m_creature); DoCast(m_creature, SPELL_BERSERK); Enraged = true; - }else BerserkTimer -= diff; + } else BerserkTimer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp index 5240a2a23ef..d1e5d1b583c 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/sunwell_plateau/boss_felmyst.cpp @@ -196,11 +196,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI void KilledUnit(Unit* victim) { - switch(rand()%2) - { - case 0: DoScriptText(YELL_KILL1, m_creature); break; - case 1: DoScriptText(YELL_KILL2, m_creature); break; - } + DoScriptText(RAND(YELL_KILL1,YELL_KILL2), m_creature); } void JustRespawned() diff --git a/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp b/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp index c8d110fe751..3e0408fca90 100644 --- a/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp +++ b/src/bindings/scripts/scripts/northrend/gundrak/boss_moorabi.cpp @@ -10,19 +10,19 @@ Script Data End */ //Spells -#define SPELL_DETERMINED_STAB 55104 -#define SPELL_GROUND_TREMOR 55142 -#define SPELL_NUMBING_SHOUT 55106 +#define SPELL_DETERMINED_STAB 55104 +#define SPELL_GROUND_TREMOR 55142 +#define SPELL_NUMBING_SHOUT 55106 -#define SPELL_DETERMINED_GORE 55102 -#define SPELL_DETERMINED_GORE_1 59444 -#define SPELL_QUAKE 55101 -#define SPELL_NUMBING_ROAR 55100 +#define SPELL_DETERMINED_GORE 55102 +#define SPELL_DETERMINED_GORE_1 59444 +#define SPELL_QUAKE 55101 +#define SPELL_NUMBING_ROAR 55100 -#define SPELL_MOJO_FRENZY 55163 -#define SPELL_TRANSFORMATION 55098 //Periodic, The caster transforms into a powerful mammoth, increasing Physical damage done by 25% and granting immunity to Stun effects. +#define SPELL_MOJO_FRENZY 55163 +#define SPELL_TRANSFORMATION 55098 //Periodic, The caster transforms into a powerful mammoth, increasing Physical damage done by 25% and granting immunity to Stun effects. -#define ACHIEVEMENT_LESS_RABI 2040 +#define ACHIEVEMENT_LESS_RABI 2040 //Yell #define SAY_AGGRO -1604010 diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp index 01593ed3843..e2dda84fdd8 100644 --- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp +++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp @@ -39,9 +39,9 @@ #define SPELL_SMOKE_TRAIL 63575 -#define SPELL_MIMIRON_INFERNO 62910 // Not Blizzlike +#define SPELL_MIMIRON_INFERNO 62910 -#define SPELL_HODIR_FURY 62297 // Not Blizzlike +#define SPELL_HODIR_FURY 62297 #define SPELL_ELECTROSHOCK 62522 diff --git a/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp b/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp index 97cd1e8268f..4815b63ba8c 100644 --- a/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp +++ b/src/bindings/scripts/scripts/northrend/violet_hold/boss_zuramat.cpp @@ -13,8 +13,8 @@ update creature_template set scriptname = '' where entry = ''; //Spells #define SPELL_SHROUD_OF_DARKNESS 54524 -#define SPELL_SUMMON_VOID_SENTRY 54524 -#define SPELL_VOID_SHIFT 54524 +#define SPELL_SUMMON_VOID_SENTRY 54369 +#define SPELL_VOID_SHIFT 54361 #define NPC_VOID_SENTRY 29364 @@ -58,12 +58,8 @@ struct TRINITY_DLL_DECL boss_zuramatAI : public ScriptedAI { if (victim == m_creature) return; - switch(rand()%3) - { - case 0: DoScriptText(SAY_SLAY_1, m_creature);break; - case 1: DoScriptText(SAY_SLAY_2, m_creature);break; - case 2: DoScriptText(SAY_SLAY_3, m_creature);break; - } + + DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2,SAY_SLAY_3), m_creature); } }; diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h index 58c78522888..be11a35095b 100644 --- a/src/game/CreatureAIImpl.h +++ b/src/game/CreatureAIImpl.h @@ -90,6 +90,229 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c } } +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7) +{ + switch(rand()%7) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8) +{ + switch(rand()%8) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9) +{ + switch(rand()%9) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10) +{ + switch(rand()%10) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10, const T& v11) +{ + switch(rand()%11) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + case 10: return v11; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10, const T& v11, const T& v12) +{ + switch(rand()%12) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + case 10: return v11; + case 11: return v12; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10, const T& v11, const T& v12, const T& v13) +{ + switch(rand()%13) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + case 10: return v11; + case 11: return v12; + case 12: return v13; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14) +{ + switch(rand()%14) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + case 10: return v11; + case 11: return v12; + case 12: return v13; + case 13: return v14; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15) +{ + switch(rand()%15) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + case 10: return v11; + case 11: return v12; + case 12: return v13; + case 13: return v14; + case 14: return v15; + } +} + +template<class T> +inline +const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, + const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15, const T& v16) +{ + switch(rand()%16) + { + default: + case 0: return v1; + case 1: return v2; + case 2: return v3; + case 3: return v4; + case 4: return v5; + case 5: return v6; + case 6: return v7; + case 7: return v8; + case 8: return v9; + case 9: return v10; + case 10: return v11; + case 11: return v12; + case 12: return v13; + case 13: return v14; + case 14: return v15; + case 15: return v16; + } +} + class EventMap : private std::map<uint32, uint32> { private: diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index bf606c6c488..cb6cc3e7869 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -354,14 +354,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 int32 temp = 0; if (action.text.TextId2 && action.text.TextId3) - { - switch( rand()%3 ) - { - case 0: temp = action.text.TextId1; break; - case 1: temp = action.text.TextId2; break; - case 2: temp = action.text.TextId3; break; - } - } + temp = RAND(action.text.TextId1,action.text.TextId2,action.text.TextId3); else if (action.text.TextId2 && urand(0,1)) temp = action.text.TextId2; else diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 5a342306174..ee4acd372d3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -4461,7 +4461,7 @@ bool Player::FallGround(bool noDeath/* = false*/) void Player::KillPlayer() { - if(IsFlying()) FallGround(); + if(IsFlying() && !GetTransport()) FallGround(); SetMovement(MOVE_ROOT); |