mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-15 16:26:08 +00:00
fix(Core/Creature): Creatures will periodically call for assistance. (#5065)
This commit is contained in:
@@ -169,7 +169,7 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(),
|
||||
m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_originalAnimTier(UNIT_BYTE1_FLAG_GROUND), m_AlreadyCallAssistance(false),
|
||||
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
|
||||
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(nullptr), m_cannotReachTarget(false), m_cannotReachTimer(0),
|
||||
_isMissingSwimmingFlagOutOfCombat(false)
|
||||
_isMissingSwimmingFlagOutOfCombat(false), m_assistanceTimer(0)
|
||||
{
|
||||
m_regenTimer = CREATURE_REGEN_INTERVAL;
|
||||
m_valuesCount = UNIT_END;
|
||||
@@ -656,6 +656,24 @@ void Creature::Update(uint32 diff)
|
||||
}
|
||||
}
|
||||
|
||||
// Call for assistance if not disabled
|
||||
if (m_assistanceTimer)
|
||||
{
|
||||
if (m_assistanceTimer <= diff)
|
||||
{
|
||||
if (CanPeriodicallyCallForAssistance())
|
||||
{
|
||||
SetNoCallAssistance(false);
|
||||
CallAssistance();
|
||||
}
|
||||
m_assistanceTimer = sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_assistanceTimer -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsInEvadeMode() && IsAIEnabled)
|
||||
{
|
||||
// do not allow the AI to be changed during update
|
||||
@@ -3237,3 +3255,18 @@ void Creature::SetLastDamagedTimePtr(std::shared_ptr<time_t> const& val)
|
||||
{
|
||||
_lastDamagedTime = val;
|
||||
}
|
||||
|
||||
bool Creature::CanPeriodicallyCallForAssistance() const
|
||||
{
|
||||
if (!IsInCombat())
|
||||
return false;
|
||||
|
||||
// Unable to call for assistance
|
||||
if (HasUnitState(UNIT_STATE_DIED | UNIT_STATE_POSSESSED))
|
||||
return false;
|
||||
|
||||
if (!CanHaveThreatList())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user