diff options
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 23 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 38 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 14 |
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 |