aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNay <dnpd.dd@gmail.com>2013-08-29 16:36:42 -0700
committerNay <dnpd.dd@gmail.com>2013-08-29 16:36:42 -0700
commitec837b1d7dadac45b71a1833c3ed5097d5f9d91f (patch)
tree72e439b5e3068238d4e698c2562bd21d99357fc2 /src
parent213998e2d7ad90965ac7f305dfe92473c0de529c (diff)
parentc3afc0057161981606981d7d13d2ab19f64976ca (diff)
Merge pull request #10666 from xjose93/SmartScripts-StartEvent
Implement SMART_ACTION_GAME_EVENT_STOP (111) and SMART_ACTION_GAME_EVENT_START (112).
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp23
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp38
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h14
3 files changed, 74 insertions, 1 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 41dae740e59..3285ce4dec9 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -34,6 +34,7 @@
#include "SmartScript.h"
#include "SpellMgr.h"
#include "Vehicle.h"
+#include "GameEventMgr.h"
class TrinityStringTextBuilder
{
@@ -2116,6 +2117,28 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
delete targets;
break;
}
+ case SMART_ACTION_GAME_EVENT_STOP:
+ {
+ uint32 eventId = e.action.gameEventStop.id;
+ if (!sGameEventMgr->IsActiveEvent(eventId))
+ {
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: %u)", eventId);
+ return;
+ }
+ sGameEventMgr->StopEvent(eventId, true);
+ break;
+ }
+ case SMART_ACTION_GAME_EVENT_START:
+ {
+ uint32 eventId = e.action.gameEventStart.id;
+ if (sGameEventMgr->IsActiveEvent(eventId))
+ {
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: %u)", eventId);
+ return;
+ }
+ sGameEventMgr->StartEvent(eventId, true);
+ break;
+ }
default:
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 1e20d2e6fbb..37aad3f4fa4 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -866,6 +866,44 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return false;
}
break;
+ case SMART_ACTION_GAME_EVENT_STOP:
+ {
+ uint32 eventId = e.action.gameEventStop.id;
+
+ GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
+ if (eventId < 1 || eventId >= events.size())
+ {
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %u SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStop);
+ return false;
+ }
+
+ GameEventData const& eventData = events[eventId];
+ if (!eventData.isValid())
+ {
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %u SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStop);
+ return false;
+ }
+ break;
+ }
+ case SMART_ACTION_GAME_EVENT_START:
+ {
+ uint32 eventId = e.action.gameEventStart.id;
+
+ GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
+ if (eventId < 1 || eventId >= events.size())
+ {
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %u SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStart);
+ return false;
+ }
+
+ GameEventData const& eventData = events[eventId];
+ if (!eventData.isValid())
+ {
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %u SourceType %u Event %u Action %u uses non-existent event, eventId %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.gameEventStart);
+ return false;
+ }
+ break;
+ }
case SMART_ACTION_FOLLOW:
case SMART_ACTION_SET_ORIENTATION:
case SMART_ACTION_STORE_TARGET_LIST:
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 05880c07ff4..4c0f5d1b25b 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -501,8 +501,10 @@ enum SMART_ACTION
SMART_ACTION_SET_POWER = 108, // PowerType, newPower
SMART_ACTION_ADD_POWER = 109, // PowerType, newPower
SMART_ACTION_REMOVE_POWER = 110, // PowerType, newPower
+ SMART_ACTION_GAME_EVENT_STOP = 111, // GameEventId
+ SMART_ACTION_GAME_EVENT_START = 112, // GameEventId
- SMART_ACTION_END = 111
+ SMART_ACTION_END = 113
};
struct SmartAction
@@ -956,6 +958,16 @@ struct SmartAction
uint32 newPower;
} power;
+ struct
+ {
+ uint32 id;
+ } gameEventStop;
+
+ struct
+ {
+ uint32 id;
+ } gameEventStart;
+
//! Note for any new future actions
//! All parameters must have type uint32