mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Scripts: added nullptr checks to DamageTaken hooks
Since cb9e72e521 attacker may not be in world when hook is called
This commit is contained in:
@@ -168,7 +168,7 @@ public:
|
||||
|
||||
void DamageTaken(Unit* done_by, uint32 &damage) override
|
||||
{
|
||||
if (done_by->GetGUID() != malchezaar)
|
||||
if (!done_by || done_by->GetGUID() != malchezaar)
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ public:
|
||||
|
||||
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) override
|
||||
{
|
||||
if (m_bIsDuelInProgress && pDoneBy->IsControlledByPlayer())
|
||||
if (m_bIsDuelInProgress && pDoneBy && pDoneBy->IsControlledByPlayer())
|
||||
{
|
||||
if (pDoneBy->GetGUID() != m_uiDuelerGUID && pDoneBy->GetOwnerGUID() != m_uiDuelerGUID) // other players cannot help
|
||||
uiDamage = 0;
|
||||
|
||||
@@ -204,7 +204,7 @@ struct boss_kalecgos : public BossAI
|
||||
|
||||
void DamageTaken(Unit* who, uint32 &damage) override
|
||||
{
|
||||
if (damage >= me->GetHealth() && who->GetGUID() != me->GetGUID())
|
||||
if (damage >= me->GetHealth() && (!who || who->GetGUID() != me->GetGUID()))
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ struct boss_kalecgos_human : public ScriptedAI
|
||||
|
||||
void DamageTaken(Unit* who, uint32 &damage) override
|
||||
{
|
||||
if (who->GetGUID() != _sathGUID)
|
||||
if (!who || who->GetGUID() != _sathGUID)
|
||||
damage = 0;
|
||||
|
||||
if (HealthBelowPct(75) && _events.IsInPhase(PHASE_SAY_ONE))
|
||||
@@ -484,7 +484,7 @@ struct boss_sathrovarr : public BossAI
|
||||
|
||||
void DamageTaken(Unit* who, uint32 &damage) override
|
||||
{
|
||||
if (damage >= me->GetHealth() && who->GetGUID() != me->GetGUID())
|
||||
if (damage >= me->GetHealth() && (!who || who->GetGUID() != me->GetGUID()))
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ public:
|
||||
//Take 0 damage
|
||||
uiDamage = 0;
|
||||
|
||||
if (Player* player = pDoneBy->ToPlayer())
|
||||
player->AreaExploredOrEventHappens(QUEST_BEAT);
|
||||
if (pDoneBy && pDoneBy->GetTypeId() == TYPEID_PLAYER)
|
||||
pDoneBy->ToPlayer()->AreaExploredOrEventHappens(QUEST_BEAT);
|
||||
EnterEvadeMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ hyjal_trashAI::hyjal_trashAI(Creature* creature) : EscortAI(creature)
|
||||
|
||||
void hyjal_trashAI::DamageTaken(Unit* done_by, uint32 &damage)
|
||||
{
|
||||
if (done_by->GetTypeId() == TYPEID_PLAYER || done_by->IsPet())
|
||||
if (!done_by || done_by->GetTypeId() == TYPEID_PLAYER || done_by->IsPet())
|
||||
{
|
||||
damageTaken += damage;
|
||||
instance->SetData(DATA_RAIDDAMAGE, damage);//store raid's damage
|
||||
|
||||
@@ -119,7 +119,7 @@ class boss_viscidus : public CreatureScript
|
||||
|
||||
++_hitcounter;
|
||||
|
||||
if (attacker->HasUnitState(UNIT_STATE_MELEE_ATTACKING) && _hitcounter >= HITCOUNTER_EXPLODE)
|
||||
if (attacker && attacker->HasUnitState(UNIT_STATE_MELEE_ATTACKING) && _hitcounter >= HITCOUNTER_EXPLODE)
|
||||
{
|
||||
Talk(EMOTE_EXPLODE);
|
||||
events.Reset();
|
||||
|
||||
@@ -196,7 +196,7 @@ class npc_tiger_matriarch : public CreatureScript
|
||||
|
||||
void DamageTaken(Unit* attacker, uint32& damage) override
|
||||
{
|
||||
if (!attacker->IsSummon())
|
||||
if (!attacker || !attacker->IsSummon())
|
||||
return;
|
||||
|
||||
if (HealthBelowPct(20))
|
||||
|
||||
@@ -129,8 +129,9 @@ public:
|
||||
{
|
||||
Damage = 0;
|
||||
|
||||
if (Player* player = pDoneBy->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
player->GroupEventHappens(QUEST_MISSING_DIPLO_PT16, me);
|
||||
if (pDoneBy)
|
||||
if (Player* player = pDoneBy->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
player->GroupEventHappens(QUEST_MISSING_DIPLO_PT16, me);
|
||||
|
||||
Talk(EMOTE_SURRENDER);
|
||||
EnterEvadeMode();
|
||||
|
||||
@@ -981,7 +981,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript
|
||||
return false;
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* , uint32& damage) override
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
|
||||
{
|
||||
if (me->HealthBelowPctDamaged(65, damage) && !me->HasAura(SPELL_TASTE_OF_BLOOD))
|
||||
DoCast(me, SPELL_TASTE_OF_BLOOD, true);
|
||||
@@ -1251,7 +1251,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript
|
||||
return false;
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* , uint32& damage) override
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
|
||||
{
|
||||
if (me->HealthBelowPctDamaged(65, damage) && me->HasAura(SPELL_TASTE_OF_BLOOD))
|
||||
DoCast(me, SPELL_TASTE_OF_BLOOD, true);
|
||||
|
||||
@@ -584,7 +584,7 @@ struct npc_gothik_minion_baseAI : public ScriptedAI
|
||||
|
||||
void DamageTaken(Unit* attacker, uint32 &damage) override
|
||||
{ // do not allow minions to take damage before the gate is opened
|
||||
if (!_gateIsOpen && !isOnSameSide(attacker))
|
||||
if (!_gateIsOpen && (!attacker || !isOnSameSide(attacker)))
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -713,7 +713,7 @@ class boss_flame_leviathan_defense_turret : public CreatureScript
|
||||
|
||||
bool CanAIAttack(Unit const* who) const override
|
||||
{
|
||||
if (who->GetTypeId() != TYPEID_PLAYER || !who->GetVehicle() || who->GetVehicleBase()->GetEntry() != NPC_SEAT)
|
||||
if (!who || who->GetTypeId() != TYPEID_PLAYER || !who->GetVehicle() || who->GetVehicleBase()->GetEntry() != NPC_SEAT)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -838,9 +838,10 @@ class boss_elder_stonebark : public CreatureScript
|
||||
|
||||
void DamageTaken(Unit* who, uint32& damage) override
|
||||
{
|
||||
if (who == me)
|
||||
if (!who || who == me)
|
||||
return;
|
||||
|
||||
///HACK: should be handled by proc
|
||||
if (me->HasAura(SPELL_PETRIFIED_BARK))
|
||||
{
|
||||
CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
|
||||
|
||||
@@ -716,7 +716,8 @@ class boss_leviathan_mk_ii : public CreatureScript
|
||||
{
|
||||
me->SetStandState(UNIT_STAND_STATE_DEAD);
|
||||
|
||||
if (IsEncounterFinished(who))
|
||||
Unit* ref = who ? who : me;
|
||||
if (IsEncounterFinished(ref))
|
||||
return;
|
||||
|
||||
me->CastStop();
|
||||
@@ -960,7 +961,8 @@ class boss_vx_001 : public CreatureScript
|
||||
me->SetStandState(UNIT_STAND_STATE_DEAD);
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
|
||||
|
||||
if (IsEncounterFinished(who))
|
||||
Unit* ref = who ? who : me;
|
||||
if (IsEncounterFinished(ref))
|
||||
return;
|
||||
|
||||
me->CastStop();
|
||||
@@ -1138,7 +1140,8 @@ class boss_aerial_command_unit : public CreatureScript
|
||||
{
|
||||
me->SetStandState(UNIT_STAND_STATE_DEAD);
|
||||
|
||||
if (IsEncounterFinished(who))
|
||||
Unit* ref = who ? who : me;
|
||||
if (IsEncounterFinished(ref))
|
||||
return;
|
||||
|
||||
me->CastStop();
|
||||
|
||||
@@ -912,7 +912,7 @@ class boss_thorim : public CreatureScript
|
||||
|
||||
bool CanStartPhase2(Unit* actor) const
|
||||
{
|
||||
if (actor->GetTypeId() != TYPEID_PLAYER || !me->IsWithinDistInMap(actor, 10.0f))
|
||||
if (!actor || actor->GetTypeId() != TYPEID_PLAYER || !me->IsWithinDistInMap(actor, 10.0f))
|
||||
return false;
|
||||
|
||||
Creature* runicColossus = instance->GetCreature(DATA_RUNIC_COLOSSUS);
|
||||
@@ -1171,7 +1171,7 @@ class npc_thorim_pre_phase : public CreatureScript
|
||||
void DamageTaken(Unit* attacker, uint32& damage) override
|
||||
{
|
||||
// nullify spell damage
|
||||
if (!attacker->GetAffectingPlayer())
|
||||
if (!attacker || !attacker->GetAffectingPlayer())
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ class npc_scourge_hulk : public CreatureScript
|
||||
|
||||
void DamageTaken(Unit* attacker, uint32 &damage) override
|
||||
{
|
||||
if (damage >= me->GetHealth() && attacker->GetEntry() == NPC_SVALA_SORROWGRAVE)
|
||||
if (damage >= me->GetHealth() && attacker && attacker->GetEntry() == NPC_SVALA_SORROWGRAVE)
|
||||
killedByRitualStrike = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
void DamageTaken(Unit* pDoneBy, uint32& uiDamage) override
|
||||
{
|
||||
if (uiDamage > me->GetHealth() && pDoneBy->GetTypeId() == TYPEID_PLAYER)
|
||||
if (uiDamage > me->GetHealth() && pDoneBy && pDoneBy->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
uiDamage = 0;
|
||||
pDoneBy->CastSpell(pDoneBy, SPELL_KILL_CREDIT, true);
|
||||
|
||||
@@ -703,8 +703,7 @@ struct boss_illidan_stormrage : public BossAI
|
||||
|
||||
void DamageTaken(Unit* who, uint32 &damage) override
|
||||
{
|
||||
|
||||
if (damage >= me->GetHealth() && who->GetGUID() != me->GetGUID())
|
||||
if (damage >= me->GetHealth() && (!who || who->GetGUID() != me->GetGUID()))
|
||||
{
|
||||
damage = me->GetHealth() - 1;
|
||||
if (!_dead)
|
||||
|
||||
@@ -275,7 +275,7 @@ struct IllidariCouncilBossAI : public BossAI
|
||||
|
||||
void DamageTaken(Unit* who, uint32 &damage) override
|
||||
{
|
||||
if (damage >= me->GetHealth() && who->GetGUID() != me->GetGUID())
|
||||
if (damage >= me->GetHealth() && (!who || who->GetGUID() != me->GetGUID()))
|
||||
damage = me->GetHealth() - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
|
||||
void DamageTaken(Unit* done_by, uint32 &damage) override
|
||||
{
|
||||
if (done_by->GetGUID() != victimGUID && done_by->GetGUID() != me->GetGUID())
|
||||
if (!done_by || (done_by->GetGUID() != victimGUID && done_by->GetGUID() != me->GetGUID()))
|
||||
{
|
||||
damage = 0;
|
||||
ModifyThreatByPercent(done_by, -100);
|
||||
|
||||
@@ -573,7 +573,9 @@ class boss_kaelthas : public CreatureScript
|
||||
if (_phase == PHASE_NONE)
|
||||
{
|
||||
DoAction(ACTION_START_ENCOUNTER);
|
||||
me->SetTarget(attacker->GetGUID());
|
||||
|
||||
if (attacker)
|
||||
me->SetTarget(attacker->GetGUID());
|
||||
}
|
||||
|
||||
if (!_hasFullPower && me->HealthBelowPctDamaged(50, damage))
|
||||
|
||||
@@ -100,9 +100,10 @@ public:
|
||||
|
||||
void DamageTaken(Unit* done_by, uint32 &damage) override
|
||||
{
|
||||
Player* player = done_by->ToPlayer();
|
||||
if (!done_by || !me->HealthBelowPctDamaged(30, damage))
|
||||
return;
|
||||
|
||||
if (player && me->HealthBelowPctDamaged(30, damage))
|
||||
if (Player* player = done_by->ToPlayer())
|
||||
{
|
||||
if (Group* group = player->GetGroup())
|
||||
{
|
||||
|
||||
@@ -1781,7 +1781,8 @@ public:
|
||||
|
||||
void DamageTaken(Unit* doneBy, uint32& damage) override
|
||||
{
|
||||
_damageTimes[doneBy->GetGUID()] = GameTime::GetGameTime();
|
||||
if (doneBy)
|
||||
_damageTimes[doneBy->GetGUID()] = GameTime::GetGameTime();
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user