Permalink
Browse files

Add EVENT_T_TIMER to EventAI. This is a generic timer that ticks out …

…of combat and in combat

Signed-off-by: Schmoozerd <schmoozerd@cmangos>
  • Loading branch information...
1 parent e5ed1b2 commit bae96467fdbd7dc8d75406de78b93a376d96cd8b @Reamer Reamer committed with Schmoozerd Sep 14, 2012
Showing with 43 additions and 9 deletions.
  1. +21 −3 doc/EventAI.txt
  2. +16 −3 src/game/CreatureEventAI.cpp
  3. +4 −2 src/game/CreatureEventAI.h
  4. +2 −1 src/game/CreatureEventAIMgr.cpp
View
@@ -64,7 +64,7 @@ Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_E
# Internal Name Event Param Usage (Param1, Param2, Param3, Param4) Description
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-0 EVENT_T_TIMER InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY IN COMBAT.
+0 EVENT_T_TIMER_IN_COMBAT InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY IN COMBAT.
1 EVENT_T_TIMER_OOC InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4), EXPIRES ONLY OUT OF COMBAT BUT NOT DURING EVADE.
2 EVENT_T_HP HPMax%, HPMin%, RepeatMin, RepeatMax Expires when the NPC's HP% is between (Param1) and (Param2). Will repeat between every (Param3) and (Param4) If Event Conditions Are Still Met.
3 EVENT_T_MANA ManaMax%, ManaMin%, RepeatMin, RepeatMax Expires when the NPC's Mana% is between (Param1) and (Param2). Will repeat between every (Param3) and (Param4) If Event Conditions Are Still Met.
@@ -91,6 +91,7 @@ Some events such as EVENT_T_AGGRO, EVENT_T_DEATH, EVENT_T_SPAWNED, and EVENT_T_E
26 EVENT_T_SUMMONED_JUST_DESPAWN CreatureId, RepeatMin, RepeatMax Expires before creature with entry = (Param1) is despawn (Param1 = 0 means all spawns). Will repeat every (Param2) and (Param3).
27 EVENT_T_MISSING_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a creature not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4).
28 EVENT_T_TARGET_MISSING_AURA SpellID, AmmountInStack, RepeatMin, RepeatMax Expires when a target unit not has spell (Param1) auras applied in a stack greater or equal to value provided in (Param2). Will repeat every (Param3) and (Param4).
+29 EVENT_T_TIMER_GENERIC InitialMin, InitialMax, RepeatMin, RepeatMax Expires at first between (Param1) and (Param2) and then will repeat between every (Param3) and (Param4).
=========================================
Action Types
@@ -162,7 +163,7 @@ BOTH - This event can trigger both in and out of combat.
Events that do not have lables on them are events that are directly involved with the in and out of combat state.
------------------
-0 = EVENT_T_TIMER:
+0 = EVENT_T_TIMER_IN_COMBAT:
------------------
Parameter 1: InitialMin - Minumum Time used to calculate Random Initial Expire
Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire
@@ -180,7 +181,7 @@ Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Event Ex
Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Event Expire
Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Event Expire
-OUT OF COMBAT ONLY - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on.
+OUT OF COMBAT ONLY (Not while evading) - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on.
This is commonly used for events that occur and repeat outside of combat like random NPC Say or Random Emotes.
---------------
@@ -428,6 +429,23 @@ Parameter 2: Amount - This is the amount or less of SpellID's auras at creature
Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+---------------------------------
+28 = EVENT_T_TARGET_MISSING_AURA:
+---------------------------------
+Parameter 1: SpellId - This is the SpellID That the Aura Check will look for to be missing
+Parameter 2: Amount - This is the amount or less of SpellID's auras at creature required for event expire.
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+---------------------------
+29 = EVENT_T_TIMER_GENERIC:
+---------------------------
+Parameter 1: InitialMin - Minumum Time used to calculate Random Initial Expire
+Parameter 2: InitialMax - Maximum Time used to calculate Random Initial Expire
+Parameter 3: RepeatMin - Minimum Time used to calculate Random Repeat Expire
+Parameter 4: RepeatMax - Maximum Time used to calculate Random Repeat Expire
+
+IN COMBAT and OUT OF COMBAT - Expires first between (Param1) and (Param2) and then between every (Param3) and (Param4) from then on.
=========================================
@@ -148,7 +148,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// Check event conditions based on the event type, also reset events
switch (event.event_type)
{
- case EVENT_T_TIMER:
+ case EVENT_T_TIMER_IN_COMBAT:
if (!m_creature->isInCombat())
return false;
@@ -162,6 +162,10 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.timer.repeatMin, event.timer.repeatMax);
break;
+ case EVENT_T_TIMER_GENERIC:
+ // Repeat Timers
+ pHolder.UpdateRepeatTimer(m_creature, event.timer.repeatMin, event.timer.repeatMax);
+ break;
case EVENT_T_HP:
{
if (!m_creature->isInCombat() || !m_creature->GetMaxHealth())
@@ -876,6 +880,14 @@ void CreatureEventAI::JustRespawned()
if (m_bEmptyList)
return;
+ // Reset generic timer
+ for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
+ {
+ if (i->Event.event_type == EVENT_T_TIMER_GENERIC)
+ if (i->UpdateRepeatTimer(m_creature, i->Event.timer.initialMin, i->Event.timer.initialMax))
+ i->Enabled = true;
+ }
+
// Handle Spawned Events
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
if (SpawnedEventConditionsCheck((*i).Event))
@@ -1036,7 +1048,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
ProcessEvent(*i, enemy);
break;
// Reset all in combat timers
- case EVENT_T_TIMER:
+ case EVENT_T_TIMER_IN_COMBAT:
if ((*i).UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
(*i).Enabled = true;
break;
@@ -1177,9 +1189,10 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
switch ((*i).Event.event_type)
{
case EVENT_T_TIMER_OOC:
+ case EVENT_T_TIMER_GENERIC:
ProcessEvent(*i);
break;
- case EVENT_T_TIMER:
+ case EVENT_T_TIMER_IN_COMBAT:
case EVENT_T_MANA:
case EVENT_T_HP:
case EVENT_T_TARGET_HP:
@@ -33,7 +33,7 @@ class WorldObject;
enum EventAI_Type
{
- EVENT_T_TIMER = 0, // InitialMin, InitialMax, RepeatMin, RepeatMax
+ EVENT_T_TIMER_IN_COMBAT = 0, // InitialMin, InitialMax, RepeatMin, RepeatMax
EVENT_T_TIMER_OOC = 1, // InitialMin, InitialMax, RepeatMin, RepeatMax
EVENT_T_HP = 2, // HPMax%, HPMin%, RepeatMin, RepeatMax
EVENT_T_MANA = 3, // ManaMax%,ManaMin% RepeatMin, RepeatMax
@@ -62,6 +62,7 @@ enum EventAI_Type
EVENT_T_SUMMONED_JUST_DESPAWN = 26, // CreatureId, RepeatMin, RepeatMax
EVENT_T_MISSING_AURA = 27, // Param1 = SpellID, Param2 = Number of time stacked expected, Param3/4 Repeat Min/Max
EVENT_T_TARGET_MISSING_AURA = 28, // Param1 = SpellID, Param2 = Number of time stacked expected, Param3/4 Repeat Min/Max
+ EVENT_T_TIMER_GENERIC = 29, // InitialMin, InitialMax, RepeatMin, RepeatMax
EVENT_T_END,
};
@@ -419,8 +420,9 @@ struct CreatureEventAI_Event
union
{
- // EVENT_T_TIMER = 0
+ // EVENT_T_TIMER_IN_COMBAT = 0
// EVENT_T_TIMER_OOC = 1
+ // EVENT_T_TIMER_GENERIC = 29
struct
{
uint32 initialMin;
@@ -311,8 +311,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
// Individual event checks
switch (temp.event_type)
{
- case EVENT_T_TIMER:
+ case EVENT_T_TIMER_IN_COMBAT:
case EVENT_T_TIMER_OOC:
+ case EVENT_T_TIMER_GENERIC:
if (temp.timer.initialMax < temp.timer.initialMin)
sLog.outErrorDb("CreatureEventAI: Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i);
if (temp.timer.repeatMax < temp.timer.repeatMin)

0 comments on commit bae9646

Please sign in to comment.