mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Units: add new functionality for units to block or enable combat interactions (#25168)
* Core/Units: add new functionality for units to block or enable combat entirely via helper to reflect what CREATURE_DIFFICULTYFLAGS_IGNORE_COMBAT and client AI functions imply * yeah... * Nuke Creature::IsCombatDisallowed helper as its unused by now * no combat extra flag may now be changed on transforms if the transformed entry does not have the flag
This commit is contained in:
@@ -44,12 +44,9 @@
|
||||
return false;
|
||||
if (a->HasUnitState(UNIT_STATE_IN_FLIGHT) || b->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
||||
return false;
|
||||
if (Creature const* aCreature = a->ToCreature())
|
||||
if (aCreature->IsCombatDisallowed())
|
||||
return false;
|
||||
if (Creature const* bCreature = b->ToCreature())
|
||||
if (bCreature->IsCombatDisallowed())
|
||||
return false;
|
||||
// ... both units must not be ignoring combat
|
||||
if (a->IsIgnoringCombat() || b->IsIgnoringCombat())
|
||||
return false;
|
||||
if (a->IsFriendlyTo(b) || b->IsFriendlyTo(a))
|
||||
return false;
|
||||
Player const* playerA = a->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
|
||||
@@ -614,6 +614,8 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
|
||||
ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
|
||||
}
|
||||
|
||||
SetIgnoringCombat((cInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_COMBAT) != 0);
|
||||
|
||||
LoadTemplateRoot();
|
||||
InitializeMovementFlags();
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool IsCivilian() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) != 0; }
|
||||
bool IsTrigger() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) != 0; }
|
||||
bool IsGuard() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD) != 0; }
|
||||
bool IsCombatDisallowed() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_COMBAT) != 0; }
|
||||
|
||||
void InitializeMovementFlags();
|
||||
void UpdateMovementFlags();
|
||||
|
||||
@@ -382,6 +382,7 @@ Unit::Unit(bool isWorldObject) :
|
||||
_oldFactionId = 0;
|
||||
_isWalkingBeforeCharm = false;
|
||||
_instantCast = false;
|
||||
_isIgnoringCombat = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1686,6 +1686,11 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
float GetCollisionHeight() const override;
|
||||
|
||||
// returns if the unit is ignoring any combat interaction
|
||||
bool IsIgnoringCombat() const { return _isIgnoringCombat; }
|
||||
// enables/disables combat interaction of this unit.
|
||||
void SetIgnoringCombat(bool apply) { _isIgnoringCombat = apply; }
|
||||
|
||||
std::string GetDebugInfo() const override;
|
||||
protected:
|
||||
explicit Unit (bool isWorldObject);
|
||||
@@ -1832,6 +1837,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
SpellHistory* m_spellHistory;
|
||||
PositionUpdateInfo _positionUpdateInfo;
|
||||
|
||||
bool _isIgnoringCombat;
|
||||
};
|
||||
|
||||
namespace Trinity
|
||||
|
||||
Reference in New Issue
Block a user