chore(Scripts/Misc): Cleanup some more JustDied hooks (#9768)

This commit is contained in:
Kitzunu
2021-12-31 16:00:40 +01:00
committed by GitHub
parent 0556f0b3d5
commit 69683a3472
22 changed files with 34 additions and 31 deletions
+1 -2
View File
@@ -577,8 +577,7 @@ namespace lfg
rDungeonId = (*dungeons.begin()); rDungeonId = (*dungeons.begin());
sScriptMgr->OnPlayerQueueRandomDungeon(player, rDungeonId); sScriptMgr->OnPlayerQueueRandomDungeon(player, rDungeonId);
} }
// No break on purpose (Random can only be dungeon or heroic dungeon) [[fallthrough]]; // On purpose (Random can only be dungeon or heroic dungeon)
[[fallthrough]];
case LFG_TYPE_HEROIC: case LFG_TYPE_HEROIC:
case LFG_TYPE_DUNGEON: case LFG_TYPE_DUNGEON:
if (isRaid) if (isRaid)
@@ -562,8 +562,6 @@ void GameObject::Update(uint32 diff)
m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
break; break;
} }
// NO BREAK for switch (m_lootState)
[[fallthrough]]; [[fallthrough]];
} }
case GO_READY: case GO_READY:
+4 -2
View File
@@ -17198,8 +17198,10 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
killer->ToCreature()->AI()->KilledUnit(victim); killer->ToCreature()->AI()->KilledUnit(victim);
// Call creature just died function // Call creature just died function
if (creature->IsAIEnabled) if (CreatureAI* ai = creature->AI())
creature->AI()->JustDied(killer ? killer : victim); {
ai->JustDied(killer);
}
if (TempSummon* summon = creature->ToTempSummon()) if (TempSummon* summon = creature->ToTempSummon())
if (Unit* summoner = summon->GetSummonerUnit()) if (Unit* summoner = summon->GetSummonerUnit())
@@ -569,7 +569,11 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
Talk(SAY_VALROTH_DEATH); Talk(SAY_VALROTH_DEATH);
killer->CastSpell(me, SPELL_SUMMON_VALROTH_REMAINS, true);
if (killer)
{
killer->CastSpell(me, SPELL_SUMMON_VALROTH_REMAINS, true);
}
} }
}; };
}; };
@@ -159,7 +159,7 @@ struct boss_jarien : public BossAI
me->SummonCreature(NPC_SPIRIT_OF_JARIEN, me->GetPosition()); me->SummonCreature(NPC_SPIRIT_OF_JARIEN, me->GetPosition());
if (_sothosDied) if (_sothosDied && killer)
{ {
HandleBothDead(me, true, killer); HandleBothDead(me, true, killer);
} }
@@ -281,7 +281,7 @@ struct boss_sothos : public BossAI
me->SummonCreature(NPC_SPIRIT_OF_SOTHOS, me->GetPosition()); me->SummonCreature(NPC_SPIRIT_OF_SOTHOS, me->GetPosition());
if (_jarienDied) if (_jarienDied && killer)
{ {
HandleBothDead(me, false, killer); HandleBothDead(me, false, killer);
} }
+2 -2
View File
@@ -330,7 +330,7 @@ struct npc_love_in_air_hummel : public ScriptedAI
speachTimer = 1; speachTimer = 1;
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
me->AI()->Talk(SAY_HUMMEL_5); me->AI()->Talk(SAY_HUMMEL_5);
Map::PlayerList const& players = me->GetMap()->GetPlayers(); Map::PlayerList const& players = me->GetMap()->GetPlayers();
@@ -465,7 +465,7 @@ struct npc_love_in_air_hummel_helper : public ScriptedAI
} }
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
me->AI()->Talk(SAY_HUMMEL_HELPER_SAY_5); me->AI()->Talk(SAY_HUMMEL_HELPER_SAY_5);
} }
@@ -75,7 +75,7 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (killer == me) if (killer && killer == me)
return; return;
Talk(SAY_DEATH); Talk(SAY_DEATH);
me->GetInstanceScript()->SetData(DATA_ESCORT_PROGRESS, ENCOUNTER_PROGRESS_EPOCH_KILLED); me->GetInstanceScript()->SetData(DATA_ESCORT_PROGRESS, ENCOUNTER_PROGRESS_EPOCH_KILLED);
@@ -494,7 +494,7 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (killer == me) if (killer && killer == me)
return; return;
summons.DespawnAll(); summons.DespawnAll();
@@ -194,7 +194,7 @@ public:
} }
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
me->SetRespawnTime(DAY); me->SetRespawnTime(DAY);
events.Reset(); events.Reset();
@@ -347,7 +347,7 @@ public:
me->CallForHelp(500.0f); me->CallForHelp(500.0f);
} }
void JustDied(Unit* /*pKiller*/) override void JustDied(Unit* /*killer*/) override
{ {
RespawnDragons(true); RespawnDragons(true);
_JustDied(); _JustDied();
@@ -494,7 +494,7 @@ public:
if (me->IsDamageEnoughForLootingAndReward()) if (me->IsDamageEnoughForLootingAndReward())
halion->LowerPlayerDamageReq(halion->GetMaxHealth()); halion->LowerPlayerDamageReq(halion->GetMaxHealth());
if (halion->IsAlive()) if (killer && halion->IsAlive())
Unit::Kill(killer, halion); Unit::Kill(killer, halion);
} }
@@ -570,7 +570,7 @@ public:
ScriptedAI::MoveInLineOfSight(who); ScriptedAI::MoveInLineOfSight(who);
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
if (me->GetEntry() == NPC_UNSTOPPABLE_ABOMINATION && me->GetInstanceScript()) if (me->GetEntry() == NPC_UNSTOPPABLE_ABOMINATION && me->GetInstanceScript())
{ {
@@ -473,7 +473,7 @@ public:
} }
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
Talk(me->GetEntry() == NPC_STALAGG ? SAY_STAL_DEATH : SAY_FEUG_DEATH); Talk(me->GetEntry() == NPC_STALAGG ? SAY_STAL_DEATH : SAY_FEUG_DEATH);
Talk(me->GetEntry() == NPC_STALAGG ? EMOTE_STAL_DEATH : EMOTE_FEUG_DEATH); Talk(me->GetEntry() == NPC_STALAGG ? EMOTE_STAL_DEATH : EMOTE_FEUG_DEATH);
@@ -1169,7 +1169,7 @@ public:
uint32 timer; uint32 timer;
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
if (me->GetEntry() == NPC_MR_BIGGLESWORTH && me->GetInstanceScript()) if (me->GetEntry() == NPC_MR_BIGGLESWORTH && me->GetInstanceScript())
{ {
@@ -718,7 +718,7 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (me->GetEntry() == killer->GetEntry()) if (killer && me->GetEntry() == killer->GetEntry())
return; return;
me->Yell("Matron, flee! They are ruthless....", LANG_UNIVERSAL); me->Yell("Matron, flee! They are ruthless....", LANG_UNIVERSAL);
me->PlayDirectSound(SOUND_STONEBARK_DEATH); me->PlayDirectSound(SOUND_STONEBARK_DEATH);
@@ -824,7 +824,7 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (me->GetEntry() == killer->GetEntry()) if (killer && me->GetEntry() == killer->GetEntry())
return; return;
me->Yell("Matron, one has fallen!", LANG_UNIVERSAL); me->Yell("Matron, one has fallen!", LANG_UNIVERSAL);
me->PlayDirectSound(SOUND_BRIGHTLEAF_DEATH); me->PlayDirectSound(SOUND_BRIGHTLEAF_DEATH);
@@ -945,7 +945,7 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (me->GetEntry() == killer->GetEntry()) if (killer && me->GetEntry() == killer->GetEntry())
return; return;
me->Yell("Freya! They come for you.", LANG_UNIVERSAL); me->Yell("Freya! They come for you.", LANG_UNIVERSAL);
me->PlayDirectSound(SOUND_IRONBRANCH_DEATH); me->PlayDirectSound(SOUND_IRONBRANCH_DEATH);
@@ -1011,7 +1011,7 @@ public:
{ {
boss_freya_iron_rootAI(Creature* pCreature) : NullCreatureAI(pCreature) { } boss_freya_iron_rootAI(Creature* pCreature) : NullCreatureAI(pCreature) { }
void JustDied(Unit*) override void JustDied(Unit* /*killer*/) override
{ {
if (!me->IsSummon()) if (!me->IsSummon())
return; return;
@@ -1139,7 +1139,7 @@ public:
AttackStart(target); AttackStart(target);
} }
void JustDied(Unit*) override void JustDied(Unit* /*killer*/) override
{ {
if (Creature* freya = ObjectAccessor::GetCreature(*me, _freyaGUID)) if (Creature* freya = ObjectAccessor::GetCreature(*me, _freyaGUID))
{ {
@@ -782,7 +782,7 @@ public:
me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS)); me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS));
} }
void JustDied(Unit*) override void JustDied(Unit* /*killer*/) override
{ {
me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS)); me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS));
} }
@@ -87,7 +87,7 @@ public:
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (killer->GetGUID() != me->GetGUID()) if (killer && killer->GetGUID() != me->GetGUID())
if (InstanceScript* pInstance = me->GetInstanceScript()) if (InstanceScript* pInstance = me->GetInstanceScript())
pInstance->SetData(DATA_ON_THE_ROCKS_ACHIEV, 0); pInstance->SetData(DATA_ON_THE_ROCKS_ACHIEV, 0);
@@ -149,7 +149,7 @@ public:
pInstance->SetData(EVENT_EMALON, IN_PROGRESS); pInstance->SetData(EVENT_EMALON, IN_PROGRESS);
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
summons.DespawnAll(); summons.DespawnAll();
events.Reset(); events.Reset();
@@ -97,7 +97,7 @@ public:
pInstance->SetData(EVENT_KORALON, IN_PROGRESS); pInstance->SetData(EVENT_KORALON, IN_PROGRESS);
} }
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
if (pInstance) if (pInstance)
pInstance->SetData(EVENT_KORALON, DONE); pInstance->SetData(EVENT_KORALON, DONE);
@@ -41,7 +41,7 @@ public:
uint32 faction; uint32 faction;
EventMap events; EventMap events;
void JustDied(Unit* ) override void JustDied(Unit* /*killer*/) override
{ {
if (me->GetEntry() == NPC_KEEP_CANNON) if (me->GetEntry() == NPC_KEEP_CANNON)
{ {
@@ -523,7 +523,7 @@ public:
} }
} }
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
Talk(ANGER_SAY_DEATH); Talk(ANGER_SAY_DEATH);
if (me->IsSummon()) if (me->IsSummon())
@@ -214,7 +214,7 @@ public:
trigger_deathAI(Creature* creature) : NullCreatureAI(creature) { } trigger_deathAI(Creature* creature) : NullCreatureAI(creature) { }
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (me->m_spells[0]) if (killer && me->m_spells[0])
me->CastSpell(killer, me->m_spells[0], true); me->CastSpell(killer, me->m_spells[0], true);
} }
}; };