diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index e5d5a48fe..440b1335d 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -91,6 +91,27 @@ VendorItem const* VendorItemData::FindItem(uint32 item_id) const return NULL; } +bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) +{ + Unit* victim = Unit::GetUnit(m_owner, m_victim); + if (victim) + { + while (!m_assistants.empty()) + { + Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin()); + m_assistants.pop_front(); + + if (assistant) + { + assistant->SetNoCallAssistence(true); + if(assistant->AI()) + assistant->AI()->AttackStart(victim); + } + } + } + return true; +} + Creature::Creature() : Unit(), i_AI(NULL), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), @@ -1669,7 +1690,7 @@ void Creature::CallAssistence() { SetNoCallAssistence(true); - float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS); + float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS); if(radius > 0) { std::list assistList; @@ -1689,11 +1710,16 @@ void Creature::CallAssistence() cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap()); } - for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) + if (!assistList.empty()) { - (*iter)->SetNoCallAssistence(true); - if((*iter)->AI()) - (*iter)->AI()->AttackStart(getVictim()); + AssistDelayEvent *e = new AssistDelayEvent(getVictim()->GetGUID(), *this); + while (!assistList.empty()) + { + // Pushing guids because in delay can happen some creature gets despawned => invalid pointer + e->AddAssistant((*assistList.begin())->GetGUID()); + assistList.pop_front(); + } + m_Events.AddEvent(e, m_Events.CalculateTime(sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY))); } } } diff --git a/src/game/Creature.h b/src/game/Creature.h index 997faf652..03f317d81 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -27,6 +27,8 @@ #include "Database/DatabaseEnv.h" #include "Cell.h" +#include + struct SpellEntry; class CreatureAI; @@ -646,4 +648,20 @@ class MANGOS_DLL_SPEC Creature : public Unit GridReference m_gridRef; CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry()) }; + +class AssistDelayEvent : public BasicEvent +{ + public: + AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { } + + bool Execute(uint64 e_time, uint32 p_time); + void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); } + private: + AssistDelayEvent(); + + uint64 m_victim; + std::list m_assistants; + Unit& m_owner; +}; + #endif diff --git a/src/game/World.cpp b/src/game/World.cpp index 3c4a66402..cb50c09f4 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -757,7 +757,8 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_EVENT_ANNOUNCE] = sConfig.GetIntDefault("Event.Announce",0); - m_configs[CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyAssistenceRadius",10); + m_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyAssistanceRadius",10); + m_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY] = sConfig.GetIntDefault("CreatureFamilyAssistanceDelay",1500); m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff",3); diff --git a/src/game/World.h b/src/game/World.h index b5a66e7d6..0b2693ba1 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -144,7 +144,8 @@ enum WorldConfigs CONFIG_CHATFLOOD_MESSAGE_DELAY, CONFIG_CHATFLOOD_MUTE_TIME, CONFIG_EVENT_ANNOUNCE, - CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS, + CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS, + CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY, CONFIG_WORLD_BOSS_LEVEL_DIFF, CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in index 4c69f2de5..093f65f3c 100644 --- a/src/mangosd/mangosd.conf.dist.in +++ b/src/mangosd/mangosd.conf.dist.in @@ -613,11 +613,15 @@ TalentsInspecting = 1 # 1.5 - 150% # 0 - off (0%) # -# CreatureFamilyAssistenceRadius -# Creature family assistence radius +# CreatureFamilyAssistanceRadius +# Creature family assistance radius # Default: 10 # 0 - off # +# CreatureFamilyAssistanceDelay +# Reaction time for creature assistance call +# Default: 1500 (1.5s) +# # WorldBossLevelDiff # Difference for boss dynamic level with target # Default: 3 @@ -674,7 +678,8 @@ TalentsInspecting = 1 ThreatRadius = 100 Rate.Creature.Aggro = 1 -CreatureFamilyAssistenceRadius = 10 +CreatureFamilyAssistanceRadius = 10 +CreatureFamilyAssistanceDelay = 1500 WorldBossLevelDiff = 3 Corpse.Decay.NORMAL = 60 Corpse.Decay.RARE = 300 diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c11091573..b826c3e6f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6844" + #define REVISION_NR "6845" #endif // __REVISION_NR_H__