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
This commit is contained in:
1 parent
8c2dbb58df
commit
9340f8d9df
4 files changed
+14
-7
No files matched your search
@@ -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();
|
||||
|
||||
@@ -647,6 +647,9 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
|
||||
if (GetMovementTemplate().IsRooted())
|
||||
SetControlled(true, UNIT_STATE_ROOT);
|
||||
|
||||
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_COMBAT)
|
||||
SetIgnoringCombat(true);
|
||||
|
||||
UpdateMovementFlags();
|
||||
LoadCreaturesAddon();
|
||||
LoadTemplateImmunities();
|
||||
|
||||
@@ -328,7 +328,7 @@ Unit::Unit(bool isWorldObject) :
|
||||
m_removedAurasCount(0), i_motionMaster(new MotionMaster(this)), m_vehicle(nullptr),
|
||||
m_vehicleKit(nullptr), m_unitTypeMask(UNIT_MASK_NONE), m_Diminishing(),
|
||||
m_isEngaged(false), m_combatManager(this), m_threatManager(this), _lastDamagedTime(0),
|
||||
m_spellHistory(new SpellHistory(this))
|
||||
m_spellHistory(new SpellHistory(this)), _isIgnoringCombat(false)
|
||||
{
|
||||
m_objectType |= TYPEMASK_UNIT;
|
||||
m_objectTypeId = TYPEID_UNIT;
|
||||
|
||||
@@ -1922,6 +1922,11 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
float GetCollisionHeight() const override;
|
||||
|
||||
// returns if the unit is allowed to enter combat
|
||||
bool IsIgnoringCombat() const { return _isIgnoringCombat; }
|
||||
// enables/disables combat permission of this unit
|
||||
void SetIgnoringCombat(bool apply) { _isIgnoringCombat = apply; }
|
||||
|
||||
protected:
|
||||
explicit Unit (bool isWorldObject);
|
||||
|
||||
@@ -2063,6 +2068,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
FormationFollowerGUIDContainer _formationFollowers;
|
||||
|
||||
std::array<std::unordered_set<AbstractPursuer*>, AsUnderlyingType(PursuingType::Max)> _unitsPursuingMe;
|
||||
|
||||
bool _isIgnoringCombat;
|
||||
};
|
||||
|
||||
namespace Trinity
|
||||
|
||||
Reference in new issue
Block a user