aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlaymoira <none@none>2009-03-21 07:56:52 +0100
committerBlaymoira <none@none>2009-03-21 07:56:52 +0100
commit4413bfb54862e057a9fdcb9d191d1453957612d7 (patch)
tree6ec2d9b4129d1cd7936dec979619692310644e39 /src
parent3120990ebd47e734074d96cd11fabf7ff75ae5dd (diff)
*Redefinition of eventAI EVENT_T_OOC_LOS. Read updated docs/EventAI.txt for details. - by nofantasy
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/ScriptMgr.cpp20
-rw-r--r--src/bindings/scripts/docs/EventAI.txt2
-rw-r--r--src/bindings/scripts/scripts/creature/mob_event_ai.cpp22
3 files changed, 33 insertions, 11 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp
index a32d6442a89..4920b5f99a3 100644
--- a/src/bindings/scripts/ScriptMgr.cpp
+++ b/src/bindings/scripts/ScriptMgr.cpp
@@ -1002,9 +1002,27 @@ void LoadDatabase()
error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
+
+ case EVENT_T_OOC_LOS:
+ {
+ if (temp.event_param2 > VISIBLE_RANGE || temp.event_param2 <= 0)
+ {
+ error_db_log("SD2: Creature %u are using event(%u), but param2 (MaxAllowedRange=%u) are not within allowed range.", temp.creature_id, i, temp.event_param2);
+ temp.event_param2 = VISIBLE_RANGE;
+ }
+
+ if (temp.event_param3 == 0 && temp.event_param4 == 0 && temp.event_flags & EFLAG_REPEATABLE)
+ {
+ error_db_log("SD2: Creature %u are using event(%u) with EFLAG_REPEATABLE, but param3(RepeatMin) and param4(RepeatMax) are 0. Repeatable disabled.", temp.creature_id, i);
+ temp.event_flags &= ~EFLAG_REPEATABLE;
+ }
+ if (temp.event_param4 < temp.event_param3)
+ error_db_log("SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
+ }
+ break;
+
case EVENT_T_RANGE:
- case EVENT_T_OOC_LOS:
case EVENT_T_FRIENDLY_HP:
case EVENT_T_FRIENDLY_IS_CC:
case EVENT_T_FRIENDLY_MISSING_BUFF:
diff --git a/src/bindings/scripts/docs/EventAI.txt b/src/bindings/scripts/docs/EventAI.txt
index 780e817993d..c759d40c5cd 100644
--- a/src/bindings/scripts/docs/EventAI.txt
+++ b/src/bindings/scripts/docs/EventAI.txt
@@ -64,7 +64,7 @@ Events will not repeat until the creature exits combat unless EFLAG_REPEATABLE i
7 EVENT_T_EVADE NONE Expires upon creature EnterEvadeMode().
8 EVENT_T_SPELLHIT SpellID, School, RepeatMin, RepeatMax Expires upon Spell hit. If (param1) is set will only expire on that spell. If (param2) will only expire on spells of that school (-1 for all). Will repeat every (Param3) and (Param4) .
9 EVENT_T_RANGE MinDist, MaxDist, RepeatMin, RepeatMax Expires when the highest threat target distance is greater than (Param1) and less than (Param2). Will repeat every (Param3) and (Param4) .
-10 EVENT_T_OOC_LOS NoHostile, NoFriendly, RepeatMin, RepeatMax Expires when a Player moves within visible distance to creature. Does not expire for Hostile Players if (Param1) is not 0. Does not expire for Friendly Players if (Param2) is not 0. Will repeat every (Param3) and (Param4) . Does not expire for creatures or pet or when the creature is in combat.
+10 EVENT_T_OOC_LOS Hostile-or-Not, MaxAllowedRange, RepeatMin, RepeatMax Expires when a Unit moves within distance(MaxAllowedRange) to creature. If Param1=0 it will expire if Unit are Hostile. If Param1=1 it will only expire if Unit are not Hostile(generally determined by faction). Will repeat every (Param3) and (Param4). Does not expire when the creature is in combat.
11 EVENT_T_SPAWNED NONE Expires at initial spawn and at creature respawn (useful for setting ranged movement type)
12 EVENT_T_TARGET_HP HPMax%, HPMin%, RepeatMin, RepeatMax Expires when Current Target's HP is between (Param1) and (Param2). Will repeat every (Param3) and (Param4) .
13 EVENT_T_TARGET_CASTING RepeatMin, RepeatatMax Expires when the current target is casting a spell. Will repeat every (Param1) and (Param2) .
diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
index f37d7e2e624..15dfd922679 100644
--- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
+++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
@@ -1231,21 +1231,25 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI
return;
//Check for OOC LOS Event
- for (std::list<EventHolder>::iterator i = EventList.begin(); i != EventList.end(); ++i)
+ if (!m_creature->getVictim())
{
- switch ((*i).Event.event_type)
+ for (std::list<EventHolder>::iterator itr = EventList.begin(); itr != EventList.end(); ++itr)
{
- case EVENT_T_OOC_LOS:
+ if ((*itr).Event.event_type == EVENT_T_OOC_LOS)
{
- if ((*i).Event.event_param1 && m_creature->IsHostileTo(who))
- break;
+ //can trigger if closer than fMaxAllowedRange
+ float fMaxAllowedRange = (*itr).Event.event_param2;
- if ((*i).Event.event_param2 && !m_creature->IsHostileTo(who))
- break;
+ //if range is ok and we are actually in LOS
+ if (m_creature->IsWithinDistInMap(who, fMaxAllowedRange) && m_creature->IsWithinLOSInMap(who))
+ {
+ //if friendly event&&who is not hostile OR hostile event&&who is hostile
+ if (((*itr).Event.event_param1 && !m_creature->IsHostileTo(who)) ||
+ ((!(*itr).Event.event_param1) && m_creature->IsHostileTo(who)))
+ ProcessEvent(*itr, who);
- ProcessEvent(*i, who);
+ }
}
- break;
}
}