feat(Core/Scripting): Implement SetInvincibility() to prevent creatur… (#20508)

This commit is contained in:
Andrew
2024-11-11 00:22:03 -03:00
committed by GitHub
parent d817f67658
commit e741a9a87f
3 changed files with 24 additions and 21 deletions

View File

@@ -198,7 +198,7 @@ struct ScriptedAI : public CreatureAI
void AttackStartNoMove(Unit* target);
// Called at any Damage from any attacker (before damage apply)
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override {}
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override;
//Called at World update tick
void UpdateAI(uint32 diff) override;
@@ -438,9 +438,14 @@ struct ScriptedAI : public CreatureAI
Player* SelectTargetFromPlayerList(float maxdist, uint32 excludeAura = 0, bool mustBeInLOS = false) const;
// Allows dropping to 1 HP but prevents creature from dying.
void SetInvincibility(bool apply) { _invincible = apply; };
[[nodiscard]] bool IsInvincible() const { return _invincible; };
private:
Difficulty _difficulty;
bool _isHeroic;
bool _invincible;
std::unordered_set<uint32> _uniqueTimedEvents;
};