mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/SAI: Implemented new action SMART_ACTION_TRIGGER_GAME_EVENT
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "CreatureTextMgrImpl.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameEventSender.h"
|
||||
#include "GameObject.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
@@ -2467,6 +2468,19 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
Trinity::Containers::EraseIf(mTimedActionList, [e](SmartScriptHolder const& script) { return script.event_id > e.event_id; });
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_TRIGGER_GAME_EVENT:
|
||||
{
|
||||
WorldObject* sourceObject = GetBaseObjectOrUnit(unit);
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
if (e.action.triggerGameEvent.useSaiTargetAsGameEventSource)
|
||||
GameEvents::Trigger(e.action.triggerGameEvent.eventId, sourceObject, target);
|
||||
else
|
||||
GameEvents::Trigger(e.action.triggerGameEvent.eventId, target, sourceObject);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry " SI64FMTD " SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
break;
|
||||
|
||||
@@ -1005,6 +1005,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
|
||||
case SMART_ACTION_ACTIVATE_GAMEOBJECT: return sizeof(SmartAction::activateGameObject);
|
||||
case SMART_ACTION_ADD_TO_STORED_TARGET_LIST: return sizeof(SmartAction::addToStoredTargets);
|
||||
case SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER: return sizeof(SmartAction::becomePersonalClone);
|
||||
case SMART_ACTION_TRIGGER_GAME_EVENT: return sizeof(SmartAction::triggerGameEvent);
|
||||
default:
|
||||
TC_LOG_WARN("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.",
|
||||
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
@@ -2316,6 +2317,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_TRIGGER_GAME_EVENT:
|
||||
{
|
||||
TC_SAI_IS_BOOLEAN_VALID(e, e.action.triggerGameEvent.useSaiTargetAsGameEventSource);
|
||||
break;
|
||||
}
|
||||
// Unused
|
||||
case SMART_ACTION_SET_UNIT_FLAG:
|
||||
case SMART_ACTION_REMOVE_UNIT_FLAG:
|
||||
|
||||
@@ -603,7 +603,8 @@ enum SMART_ACTION
|
||||
SMART_ACTION_ACTIVATE_GAMEOBJECT = 147, // GameObjectActions
|
||||
SMART_ACTION_ADD_TO_STORED_TARGET_LIST = 148, // varID
|
||||
SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER = 149, // summonType 1-8, duration in ms
|
||||
SMART_ACTION_END = 150
|
||||
SMART_ACTION_TRIGGER_GAME_EVENT = 150, // eventId, useSaiTargetAsGameEventSource
|
||||
SMART_ACTION_END = 151
|
||||
};
|
||||
|
||||
enum class SmartActionSummonCreatureFlags
|
||||
@@ -1217,6 +1218,12 @@ struct SmartAction
|
||||
uint32 duration;
|
||||
} becomePersonalClone;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 eventId;
|
||||
SAIBool useSaiTargetAsGameEventSource;
|
||||
} triggerGameEvent;
|
||||
|
||||
//! Note for any new future actions
|
||||
//! All parameters must have type uint32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user