refactor(Scripts/EasternKingdoms): code cleanup (part 5) - also fix potential crash (#6923)

This commit is contained in:
Francesco Borzì
2021-07-19 11:23:27 +02:00
committed by GitHub
parent fab0fc421b
commit e5f1104849
37 changed files with 118 additions and 144 deletions

View File

@@ -2,7 +2,6 @@
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
* Rescripted By Lee (Talamortis)
*/
#include "karazhan.h"
@@ -285,7 +284,6 @@ public:
void SummonInfernal()
{
InfernalPoint* point = 0;
Position pos;
if ((me->GetMapId() == 532))
@@ -294,7 +292,7 @@ public:
}
else
{
point = Acore::Containers::SelectRandomContainerElement(positions);
InfernalPoint* point = Acore::Containers::SelectRandomContainerElement(positions);
pos.Relocate(point->x, point->y, INFERNAL_Z, frand(0.0f, float(M_PI * 2)));
}
@@ -360,14 +358,16 @@ public:
{
if (SWPainTimer <= diff)
{
Unit* target = nullptr;
if (phase == 1)
target = me->GetVictim(); // Target the Tank
else // anyone but the tank
target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
// if phase == 1 target the tank, otherwise anyone but the tank
Unit* target = phase == 1
? me->GetVictim()
: SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
if (target)
{
DoCast(target, SPELL_SW_PAIN);
}
SWPainTimer = 20000;
}
@@ -411,8 +411,7 @@ public:
{
if (AmplifyDamageTimer <= diff)
{
Unit* target = nullptr;
target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
if (target)
{
@@ -421,7 +420,9 @@ public:
}
}
else
{
AmplifyDamageTimer -= diff;
}
}
if (phase != 3)
@@ -483,9 +484,11 @@ public:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
{
if (me->GetVictim())
{
DoModifyThreatPercent(me->GetVictim(), -100);
if (target)
me->AddThreat(target, 1000000.0f);
}
me->AddThreat(target, 1000000.0f);
}
}

View File

@@ -392,15 +392,10 @@ public:
{
ElementalsSpawned = true;
Creature* ElementalOne = nullptr;
Creature* ElementalTwo = nullptr;
Creature* ElementalThree = nullptr;
Creature* ElementalFour = nullptr;
ElementalOne = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11168.1f, -1939.29f, 232.092f, 1.46f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
ElementalTwo = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11138.2f, -1915.38f, 232.092f, 3.00f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
ElementalThree = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11161.7f, -1885.36f, 232.092f, 4.59f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
ElementalFour = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11192.4f, -1909.36f, 232.092f, 6.19f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
Creature* ElementalOne = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11168.1f, -1939.29f, 232.092f, 1.46f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
Creature* ElementalTwo = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11138.2f, -1915.38f, 232.092f, 3.00f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
Creature* ElementalThree = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11161.7f, -1885.36f, 232.092f, 4.59f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
Creature* ElementalFour = me->SummonCreature(CREATURE_WATER_ELEMENTAL, -11192.4f, -1909.36f, 232.092f, 6.19f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000);
if (ElementalOne)
{

View File

@@ -86,10 +86,10 @@ public:
void JustDied(Unit* /*killer*/) override
{
ObjectGuid TerestianGUID = instance->GetGuidData(DATA_TERESTIAN);
if (TerestianGUID)
ObjectGuid TerestianGuid = instance->GetGuidData(DATA_TERESTIAN);
if (TerestianGuid)
{
Unit* Terestian = ObjectAccessor::GetUnit(*me, TerestianGUID);
Unit* Terestian = ObjectAccessor::GetUnit(*me, TerestianGuid);
if (Terestian && Terestian->IsAlive())
DoCast(Terestian, SPELL_BROKEN_PACT, true);
}

View File

@@ -1,3 +1,6 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/
#include "Creature.h"
#include "GameObject.h"

View File

@@ -474,9 +474,9 @@ public:
void EnterCombat(Unit* /*who*/) override {}
uint32 NextStep(uint32 Step)
uint32 NextStep(uint32 nextStep)
{
switch(Step)
switch(nextStep)
{
case 1:
me->MonsterYell(SAY_DIALOG_MEDIVH_1, LANG_UNIVERSAL, 0);

View File

@@ -1,20 +1,8 @@
/*
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*/
#ifndef DEF_KARAZHAN_H
#define DEF_KARAZHAN_H