mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 17:19:07 +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;
|
||||
}
|
||||
|
||||
@@ -358,6 +358,8 @@ public:
|
||||
}
|
||||
void RefreshSwimmingFlag(bool recheck = false);
|
||||
|
||||
void SetAssistanceTimer(uint32 value) { m_assistanceTimer = value; }
|
||||
|
||||
protected:
|
||||
bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
|
||||
bool InitEntry(uint32 entry, const CreatureData* data = nullptr);
|
||||
@@ -417,6 +419,8 @@ protected:
|
||||
private:
|
||||
void ForcedDespawn(uint32 timeMSToDespawn = 0);
|
||||
|
||||
[[nodiscard]] bool CanPeriodicallyCallForAssistance() const;
|
||||
|
||||
//WaypointMovementGenerator vars
|
||||
uint32 m_waypointID;
|
||||
uint32 m_path_id;
|
||||
@@ -434,6 +438,8 @@ private:
|
||||
|
||||
bool _isMissingSwimmingFlagOutOfCombat;
|
||||
|
||||
uint32 m_assistanceTimer;
|
||||
|
||||
void applyInhabitFlags();
|
||||
};
|
||||
|
||||
|
||||
@@ -9902,6 +9902,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
||||
|
||||
creature->SendAIReaction(AI_REACTION_HOSTILE);
|
||||
creature->CallAssistance();
|
||||
creature->SetAssistanceTimer(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD));
|
||||
}
|
||||
|
||||
// delay offhand weapon attack to next attack time
|
||||
@@ -13058,6 +13059,8 @@ void Unit::ClearInCombat()
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
|
||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS, creature->GetCreatureTemplate()->dynamicflags);
|
||||
|
||||
creature->SetAssistanceTimer(0);
|
||||
|
||||
// Xinef: will be recalculated at follow movement generator initialization
|
||||
if (!IsPet() && !IsCharmed())
|
||||
return;
|
||||
|
||||
@@ -251,6 +251,7 @@ enum WorldIntConfigs
|
||||
CONFIG_CHATFLOOD_MUTE_TIME,
|
||||
CONFIG_EVENT_ANNOUNCE,
|
||||
CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY,
|
||||
CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD,
|
||||
CONFIG_CREATURE_FAMILY_FLEE_DELAY,
|
||||
CONFIG_WORLD_BOSS_LEVEL_DIFF,
|
||||
CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF,
|
||||
|
||||
@@ -1040,7 +1040,8 @@ void World::LoadConfigSettings(bool reload)
|
||||
|
||||
m_float_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS] = sConfigMgr->GetOption<float>("CreatureFamilyFleeAssistanceRadius", 30.0f);
|
||||
m_float_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS] = sConfigMgr->GetOption<float>("CreatureFamilyAssistanceRadius", 10.0f);
|
||||
m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY] = sConfigMgr->GetOption<int32>("CreatureFamilyAssistanceDelay", 1500);
|
||||
m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY] = sConfigMgr->GetOption<int32>("CreatureFamilyAssistanceDelay", 2000);
|
||||
m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_PERIOD] = sConfigMgr->GetOption<int32>("CreatureFamilyAssistancePeriod", 3000);
|
||||
m_int_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY] = sConfigMgr->GetOption<int32>("CreatureFamilyFleeDelay", 7000);
|
||||
|
||||
m_int_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfigMgr->GetOption<int32>("WorldBossLevelDiff", 3);
|
||||
|
||||
@@ -1449,9 +1449,17 @@ CreatureFamilyAssistanceRadius = 10
|
||||
#
|
||||
# CreatureFamilyAssistanceDelay
|
||||
# Description: Time (in milliseconds) before creature assistance call.
|
||||
# Default: 1500 - (1.5 Seconds)
|
||||
# Default: 2000 - (2 Seconds)
|
||||
|
||||
CreatureFamilyAssistanceDelay = 1500
|
||||
CreatureFamilyAssistanceDelay = 2000
|
||||
|
||||
#
|
||||
# CreatureFamilyAssistancePeriod
|
||||
# Description: Time (in milliseconds) before next creature assistance call.
|
||||
# Default: 3000 - (3 Seconds)
|
||||
0 - (Disabled)
|
||||
|
||||
CreatureFamilyAssistancePeriod = 3000
|
||||
|
||||
#
|
||||
# CreatureFamilyFleeDelay
|
||||
|
||||
Reference in New Issue
Block a user