Skip to content

Commit

Permalink
StaticFlags: Implement IGNORE_SANCTUARY (#542)
Browse files Browse the repository at this point in the history
* StaticFlags: Implement IGNORE_SANCTUARY

* StaticFlags: Simplify Ignore Sanctuary
  • Loading branch information
insunaa authored Oct 6, 2024
1 parent 74d69d4 commit 26d23af
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,20 @@ void Creature::SetIgnoreFeignDeath(bool state)
m_settings.RemoveFlag(CreatureStaticFlags2::IGNORE_FEIGN_DEATH);
}

bool Creature::IsIgnoringSanctuary() const
{
return m_settings.HasFlag(CreatureStaticFlags2::IGNORE_SANCTUARY);
}

void Creature::SetIgnoreSanctuary(bool state)
{
if (state)
m_settings.SetFlag(CreatureStaticFlags2::IGNORE_SANCTUARY);
else
m_settings.RemoveFlag(CreatureStaticFlags2::IGNORE_SANCTUARY);
}


void Creature::SetNoWoundedSlowdown(bool state)
{
if (state)
Expand Down
2 changes: 2 additions & 0 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@ class Creature : public Unit
void SetNoReputation(bool state) { m_noReputation = state; }
bool IsIgnoringFeignDeath() const override;
void SetIgnoreFeignDeath(bool state);
bool IsIgnoringSanctuary() const override;
void SetIgnoreSanctuary(bool state);

void SetNoWoundedSlowdown(bool state);
bool IsNoWoundedSlowdown() const;
Expand Down
8 changes: 7 additions & 1 deletion src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12260,7 +12260,13 @@ bool Unit::IsAllowedDamageInArea(Unit* attacker, Unit* pVictim)

// can't damage player controlled unit by player controlled unit in sanctuary
AreaTableEntry const* area = GetAreaEntryByAreaID(pVictim->GetAreaId());
return !(area && area->flags & AREA_FLAG_SANCTUARY);
if (!area || !(area->flags & AREA_FLAG_SANCTUARY))
return true;

if (pVictim->IsIgnoringSanctuary())
return true;
else
return false;
}

class UnitVisitObjectsInRangeNotifyEvent : public BasicEvent
Expand Down
1 change: 1 addition & 0 deletions src/game/Entities/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2461,6 +2461,7 @@ class Unit : public WorldObject
bool IsFeigningDeathSuccessfully() const { return hasUnitState(UNIT_STAT_FEIGN_DEATH); }
void SetFeignDeath(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0, bool dynamic = true, bool success = true);
virtual bool IsIgnoringFeignDeath() const { return false; }
virtual bool IsIgnoringSanctuary() const { return false; }

virtual bool IsSlowedInCombat() const { return false; }

Expand Down

0 comments on commit 26d23af

Please sign in to comment.