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

@@ -46,14 +46,15 @@ enum Says
SAY_DEATH = 5
};
enum Misc
{
NPC_SOARING_EAGLE = 24858,
SE_LOC_X_MAX = 400,
SE_LOC_X_MIN = 335,
SE_LOC_Y_MAX = 1435,
SE_LOC_Y_MIN = 1370
};
constexpr auto NPC_SOARING_EAGLE = 24858;
//enum Misc
//{
// SE_LOC_X_MAX = 400,
// SE_LOC_X_MIN = 335,
// SE_LOC_Y_MAX = 1435,
// SE_LOC_Y_MIN = 1370
//};
enum Events
{

View File

@@ -182,22 +182,20 @@ public:
void FireWall()
{
uint8 WallNum;
Creature* wall = nullptr;
for (uint8 i = 0; i < 4; ++i)
{
if (i == 0 || i == 2)
WallNum = 3;
else
WallNum = 2;
uint8 WallNum = i == 0 || i == 2 ? 3 : 2;
for (uint8 j = 0; j < WallNum; j++)
{
if (WallNum == 3)
wall = me->SummonCreature(NPC_FIRE_BOMB, FireWallCoords[i][0], FireWallCoords[i][1] + 5 * (j - 1), FireWallCoords[i][2], FireWallCoords[i][3], TEMPSUMMON_TIMED_DESPAWN, 15000);
else
wall = me->SummonCreature(NPC_FIRE_BOMB, FireWallCoords[i][0] - 2 + 4 * j, FireWallCoords[i][1], FireWallCoords[i][2], FireWallCoords[i][3], TEMPSUMMON_TIMED_DESPAWN, 15000);
if (wall) wall->CastSpell(wall, SPELL_FIRE_WALL, true);
Creature* wall = WallNum == 3
? me->SummonCreature(NPC_FIRE_BOMB, FireWallCoords[i][0], FireWallCoords[i][1] + 5 * (j - 1), FireWallCoords[i][2], FireWallCoords[i][3], TEMPSUMMON_TIMED_DESPAWN, 15000)
: me->SummonCreature(NPC_FIRE_BOMB, FireWallCoords[i][0] - 2 + 4 * j, FireWallCoords[i][1], FireWallCoords[i][2], FireWallCoords[i][3], TEMPSUMMON_TIMED_DESPAWN, 15000);
if (wall)
{
wall->CastSpell(wall, SPELL_FIRE_WALL, true);
}
}
}
}
@@ -534,7 +532,7 @@ public:
void UpdateAI(uint32 diff) override
{
if (!instance || !(instance->GetData(DATA_JANALAIEVENT) == IN_PROGRESS))
if (!instance || instance->GetData(DATA_JANALAIEVENT) != IN_PROGRESS)
{
me->DisappearAndDie();
return;
@@ -614,7 +612,7 @@ public:
void UpdateAI(uint32 diff) override
{
if (!instance || !(instance->GetData(DATA_JANALAIEVENT) == IN_PROGRESS))
if (!instance || instance->GetData(DATA_JANALAIEVENT) != IN_PROGRESS)
{
me->DisappearAndDie();
return;

View File

@@ -62,8 +62,8 @@ enum Talks
SAY_KILL_ONE,
SAY_KILL_TWO,
SAY_DEATH,
SAY_NALORAKK_EVENT1, // Unimplemented
SAY_NALORAKK_EVENT2 // Unimplemented
SAY_NALORAKK_EVENT1, // Not implemented
SAY_NALORAKK_EVENT2 // Not implemented
};
class boss_nalorakk : public CreatureScript

View File

@@ -252,10 +252,9 @@ public:
void SpawnAdds()
{
Creature* creature = nullptr;
for (uint8 i = 0; i < 4; ++i)
{
creature = me->SummonCreature(SpiritInfo[i].entry, SpiritInfo[i].x, SpiritInfo[i].y, SpiritInfo[i].z, SpiritInfo[i].orient, TEMPSUMMON_DEAD_DESPAWN, 0);
Creature* creature = me->SummonCreature(SpiritInfo[i].entry, SpiritInfo[i].x, SpiritInfo[i].y, SpiritInfo[i].z, SpiritInfo[i].orient, TEMPSUMMON_DEAD_DESPAWN, 0);
if (creature)
{
creature->CastSpell(creature, SPELL_SPIRIT_AURA, true);