Core/Creatures: Implemented unkillable flag (prevent health from going below 1)

This commit is contained in:
Shauren
2023-03-11 00:07:57 +01:00
parent 379b1ec6ae
commit 7ea438ebdc
2 changed files with 12 additions and 0 deletions

View File

@@ -146,6 +146,14 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
using Unit::SetImmuneToNPC;
void SetImmuneToNPC(bool apply) override { Unit::SetImmuneToNPC(apply, HasReactState(REACT_PASSIVE)); }
void SetUnkillable(bool unkillable)
{
if (unkillable)
_staticFlags |= CREATURE_STATIC_FLAG_UNKILLABLE;
else
_staticFlags &= ~CREATURE_STATIC_FLAG_UNKILLABLE;
}
/// @todo Rename these properly
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
bool CanResetTalents(Player* player) const;

View File

@@ -857,6 +857,10 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons
duel_hasEnded = true;
}
else if (victim->IsCreature() && damageTaken >= health && victim->ToCreature()->HasFlag(CREATURE_STATIC_FLAG_UNKILLABLE))
{
damageTaken = health - 1;
}
else if (victim->IsVehicle() && damageTaken >= (health-1) && victim->GetCharmer() && victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER)
{
Player* victimRider = victim->GetCharmer()->ToPlayer();