Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[6844] Implemented configurable assistance aggro delaying. Some typos…

… fixed.

Do not forget to update your config files.
Signed-off-by: ApoC <apoc@nymfe.net>
  • Loading branch information...
commit 43e51bdf71c52da7f8d1e257c41204e4fcccf402 1 parent 2ae30c8
@apoc apoc authored
View
36 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<Creature*> assistList;
@@ -1689,11 +1710,16 @@ void Creature::CallAssistence()
cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap());
}
- for(std::list<Creature*>::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)));
}
}
}
View
18 src/game/Creature.h
@@ -27,6 +27,8 @@
#include "Database/DatabaseEnv.h"
#include "Cell.h"
+#include <list>
+
struct SpellEntry;
class CreatureAI;
@@ -646,4 +648,20 @@ class MANGOS_DLL_SPEC Creature : public Unit
GridReference<Creature> 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<uint64> m_assistants;
+ Unit& m_owner;
+};
+
#endif
View
3  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);
View
3  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,
View
11 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
View
2  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__
Please sign in to comment.
Something went wrong with that request. Please try again.