AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SmartScript Class Reference

#include "SmartScript.h"

Classes

struct  SmartScriptFrame
 

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

 SmartScript ()
 
 ~SmartScript ()
 
void OnInitialize (WorldObject *obj, AreaTrigger const *at=nullptr)
 
void GetScript ()
 
void FillScript (SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
 
void ProcessEventsFor (SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
void ProcessEvent (SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
bool CheckTimer (SmartScriptHolder const &e) const
 
void UpdateTimer (SmartScriptHolder &e, uint32 const diff)
 
void ProcessAction (SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
void ProcessTimedAction (SmartScriptHolder &e, uint32 const &min, uint32 const &max, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
void GetTargets (ObjectVector &targets, SmartScriptHolder const &e, WorldObject *invoker=nullptr) const
 
void GetWorldObjectsInDist (ObjectVector &objects, float dist) const
 
void InstallTemplate (SmartScriptHolder const &e)
 
void AddEvent (SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
 
void SetPathId (uint32 id)
 
uint32 GetPathId () const
 
WorldObjectGetBaseObject () const
 
void OnUpdate (const uint32 diff)
 
void OnMoveInLineOfSight (Unit *who)
 
UnitDoSelectLowestHpFriendly (float range, uint32 MinHPDiff) const
 
UnitDoSelectLowestHpPercentFriendly (float range, uint32 minHpPct, uint32 maxHpPct) const
 
void DoFindFriendlyCC (std::vector< Creature * > &creatures, float range) const
 
void DoFindFriendlyMissingBuff (std::vector< Creature * > &creatures, float range, uint32 spellid) const
 
UnitDoFindClosestFriendlyInRange (float range, bool playerOnly) const
 
bool IsSmart (Creature *c, bool silent=false) const
 
bool IsSmart (GameObject *g, bool silent=false) const
 
bool IsSmart (bool silent=false) const
 
void StoreTargetList (ObjectVector const &targets, uint32 id)
 
ObjectVector const * GetStoredTargetVector (uint32 id, WorldObject const &ref) const
 
void StoreCounter (uint32 id, uint32 value, uint32 reset, uint32 subtract)
 
uint32 GetCounterValue (uint32 id)
 
GameObjectFindGameObjectNear (WorldObject *searchObject, ObjectGuid::LowType guid) const
 
CreatureFindCreatureNear (WorldObject *searchObject, ObjectGuid::LowType guid) const
 
void OnReset ()
 
void ResetBaseObject ()
 
void SetScript9 (SmartScriptHolder &e, uint32 entry)
 
WorldObjectGetLastInvoker (WorldObject *invoker=nullptr) const
 
bool AllowPhaseReset () const
 
void SetPhaseReset (bool allow)
 
void AddCreatureSummon (ObjectGuid const &guid)
 
void RemoveCreatureSummon (ObjectGuid const &guid)
 
SmartAIEventList const & GetEvents () const
 

Static Public Member Functions

static void RecalcTimer (SmartScriptHolder &e, uint32 min, uint32 max)
 
static void InitTimer (SmartScriptHolder &e)
 
static SmartScriptHolder CreateSmartEvent (SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
 
static bool IsUnit (WorldObject *obj)
 
static bool IsPlayer (WorldObject *obj)
 
static bool IsCreature (WorldObject *obj)
 
static bool IsCharmedCreature (WorldObject *obj)
 
static bool IsGameObject (WorldObject *obj)
 

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

void IncPhase (uint32 p)
 
void DecPhase (uint32 p)
 
void SetPhase (uint32 p)
 
bool IsInPhase (uint32 p) const
 
void SortEvents (SmartAIEventList &events)
 
void RaisePriority (SmartScriptHolder &e)
 
void RetryLater (SmartScriptHolder &e, bool ignoreChanceRoll=false)
 
void InstallEvents ()
 
void RemoveStoredEvent (uint32 id)
 
std::optional< std::reference_wrapper< SmartScriptHolder > > FindLinkedEvent (uint32 link)
 

Private Attributes

SmartAIEventList mEvents
 
SmartAIEventList mInstallEvents
 
SmartAIEventList mTimedActionList
 
bool isProcessingTimedActionList
 
Creatureme
 
ObjectGuid meOrigGUID
 
GameObjectgo
 
ObjectGuid goOrigGUID
 
AreaTrigger const * trigger
 
SmartScriptType mScriptType
 
uint32 mEventPhase
 
std::unordered_map< int32, int32mStoredDecimals
 
uint32 mPathId
 
SmartAIEventStoredList mStoredEvents
 
std::list< uint32mRemIDs
 
uint32 mTextTimer
 
uint32 mLastTextID
 
uint32 mTalkerEntry
 
bool mUseTextTimer
 
uint32 mCurrentPriority
 
bool mEventSortingRequired
 
bool _allowPhaseReset
 
ObjectVectorMap _storedTargets
 
SMARTAI_TEMPLATE mTemplate
 
GuidUnorderedSet _summonList
 
std::deque< SmartScriptFrameexecutionStack
 

Detailed Description

Member Typedef Documentation

◆ CounterMap

typedef std::unordered_map<uint32, uint32> SmartScript::CounterMap

Constructor & Destructor Documentation

◆ SmartScript()

SmartScript::SmartScript ( )
Todo:
: this import is not necessary for compilation and marked as unused by the IDE
48{
49 go = nullptr;
50 me = nullptr;
51 trigger = nullptr;
52 mEventPhase = 0;
53 mPathId = 0;
54 mTextTimer = 0;
55 mLastTextID = 0;
56 mUseTextTimer = false;
57 mTalkerEntry = 0;
63 _allowPhaseReset = true;
64}
@ SMART_SCRIPT_TYPE_CREATURE
Definition SmartScriptMgr.h:1794
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1539
uint32 mEventPhase
Definition SmartScript.h:232
SMARTAI_TEMPLATE mTemplate
Definition SmartScript.h:251
Creature * me
Definition SmartScript.h:226
uint32 mPathId
Definition SmartScript.h:235
SmartScriptType mScriptType
Definition SmartScript.h:231
bool _allowPhaseReset
Definition SmartScript.h:247
bool mUseTextTimer
Definition SmartScript.h:242
uint32 mLastTextID
Definition SmartScript.h:240
uint32 mTextTimer
Definition SmartScript.h:239
GameObject * go
Definition SmartScript.h:228
AreaTrigger const * trigger
Definition SmartScript.h:230
uint32 mCurrentPriority
Definition SmartScript.h:243
uint32 mTalkerEntry
Definition SmartScript.h:241
bool isProcessingTimedActionList
Definition SmartScript.h:225
bool mEventSortingRequired
Definition SmartScript.h:244

References _allowPhaseReset, go, isProcessingTimedActionList, mCurrentPriority, me, mEventPhase, mEventSortingRequired, mLastTextID, mPathId, mScriptType, mTalkerEntry, mTemplate, mTextTimer, mUseTextTimer, SMART_SCRIPT_TYPE_CREATURE, SMARTAI_TEMPLATE_BASIC, and trigger.

◆ ~SmartScript()

SmartScript::~SmartScript ( )
67{
68}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5577{
5578 _summonList.insert(guid);
5579}
GuidUnorderedSet _summonList
Definition SmartScript.h:284

References _summonList.

Referenced by SmartAI::JustSummoned().

◆ AddEvent()

void SmartScript::AddEvent ( SMART_EVENT  e,
uint32  event_flags,
uint32  event_param1,
uint32  event_param2,
uint32  event_param3,
uint32  event_param4,
uint32  event_param5,
uint32  event_param6,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
3508{
3509 mInstallEvents.push_back(CreateSmartEvent(e, event_flags, event_param1, event_param2, event_param3, event_param4, event_param5, event_param6, action, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, t, target_param1, target_param2, target_param3, target_param4, phaseMask));
3510}
SmartAIEventList mInstallEvents
Definition SmartScript.h:223
static SmartScriptHolder CreateSmartEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
Definition SmartScript.cpp:3512

References CreateSmartEvent(), and mInstallEvents.

Referenced by InstallTemplate().

◆ AllowPhaseReset()

bool SmartScript::AllowPhaseReset ( ) const
inline
204{ return _allowPhaseReset; }

References _allowPhaseReset.

Referenced by OnReset().

◆ CheckTimer()

bool SmartScript::CheckTimer ( SmartScriptHolder const &  e) const
5125{
5126 return e.active;
5127}

References SmartScriptHolder::active.

◆ CreateSmartEvent()

SmartScriptHolder SmartScript::CreateSmartEvent ( SMART_EVENT  e,
uint32  event_flags,
uint32  event_param1,
uint32  event_param2,
uint32  event_param3,
uint32  event_param4,
uint32  event_param5,
uint32  event_param6,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
static
3513{
3514 SmartScriptHolder script;
3515 script.event.type = e;
3516 script.event.raw.param1 = event_param1;
3517 script.event.raw.param2 = event_param2;
3518 script.event.raw.param3 = event_param3;
3519 script.event.raw.param4 = event_param4;
3520 script.event.raw.param5 = event_param5;
3521 script.event.raw.param6 = event_param6;
3522 script.event.event_phase_mask = phaseMask;
3523 script.event.event_flags = event_flags;
3524 script.event.event_chance = 100;
3525
3526 script.action.type = action;
3527 script.action.raw.param1 = action_param1;
3528 script.action.raw.param2 = action_param2;
3529 script.action.raw.param3 = action_param3;
3530 script.action.raw.param4 = action_param4;
3531 script.action.raw.param5 = action_param5;
3532 script.action.raw.param6 = action_param6;
3533
3534 script.target.type = t;
3535 script.target.raw.param1 = target_param1;
3536 script.target.raw.param2 = target_param2;
3537 script.target.raw.param3 = target_param3;
3538 script.target.raw.param4 = target_param4;
3539
3541 InitTimer(script);
3542 return script;
3543}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4978
uint32 param3
Definition SmartScriptMgr.h:1063
uint32 param5
Definition SmartScriptMgr.h:1065
uint32 param1
Definition SmartScriptMgr.h:1061
SMART_ACTION type
Definition SmartScriptMgr.h:747
struct SmartAction::@75::@195 raw
uint32 param4
Definition SmartScriptMgr.h:1064
uint32 param6
Definition SmartScriptMgr.h:1504
uint32 param2
Definition SmartScriptMgr.h:1062
uint32 param1
Definition SmartScriptMgr.h:514
uint32 event_flags
Definition SmartScriptMgr.h:209
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition SmartScriptMgr.h:207
uint32 param2
Definition SmartScriptMgr.h:515
uint32 param4
Definition SmartScriptMgr.h:517
uint32 param3
Definition SmartScriptMgr.h:516
uint32 param6
Definition SmartScriptMgr.h:519
uint32 event_chance
Definition SmartScriptMgr.h:208
uint32 param5
Definition SmartScriptMgr.h:518
SMART_EVENT type
Definition SmartScriptMgr.h:206
Definition SmartScriptMgr.h:1997
SmartAction action
Definition SmartScriptMgr.h:2008
SmartScriptType source_type
Definition SmartScriptMgr.h:2003
SmartEvent event
Definition SmartScriptMgr.h:2007
SmartTarget target
Definition SmartScriptMgr.h:2009
uint32 param4
Definition SmartScriptMgr.h:1762
uint32 param1
Definition SmartScriptMgr.h:1759
uint32 param3
Definition SmartScriptMgr.h:1761
struct SmartTarget::@201::@225 raw
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1611
uint32 param2
Definition SmartScriptMgr.h:1760

References SmartScriptHolder::action, SmartScriptHolder::event, SmartEvent::event_chance, SmartEvent::event_flags, SmartEvent::event_phase_mask, InitTimer(), SmartEvent::param1, SmartAction::param1, SmartTarget::param1, SmartEvent::param2, SmartAction::param2, SmartTarget::param2, SmartEvent::param3, SmartAction::param3, SmartTarget::param3, SmartEvent::param4, SmartAction::param4, SmartTarget::param4, SmartEvent::param5, SmartAction::param5, SmartEvent::param6, SmartAction::param6, SmartEvent::raw, SmartAction::raw, SmartTarget::raw, SMART_SCRIPT_TYPE_CREATURE, SmartScriptHolder::source_type, SmartScriptHolder::target, SmartEvent::type, SmartAction::type, and SmartTarget::type.

Referenced by AddEvent(), and ProcessAction().

◆ DecPhase()

void SmartScript::DecPhase ( uint32  p)
private
5543{
5544 if (p >= mEventPhase)
5545 {
5546 SetPhase(0);
5547 }
5548 else
5549 {
5550 SetPhase(mEventPhase - p);
5551 }
5552}
void SetPhase(uint32 p)
Definition SmartScript.cpp:5554

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5448{
5449 if (!me)
5450 return nullptr;
5451
5452 Unit* unit = nullptr;
5453 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5455 Cell::VisitObjects(me, searcher, range);
5456 return unit;
5457}
Definition Unit.h:664
Definition GridNotifiers.h:427
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References me, and Cell::VisitObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5428{
5429 if (!me)
5430 return;
5431
5432 Acore::FriendlyCCedInRange u_check(me, range);
5434 Cell::VisitObjects(me, searcher, range);
5435}
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:839
Definition GridNotifiers.h:494

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
5438{
5439 if (!me)
5440 return;
5441
5442 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5444 Cell::VisitObjects(me, searcher, range);
5445}
Definition GridNotifiers.h:857

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5401{
5402 if (!me)
5403 return nullptr;
5404
5405 Unit* unit = nullptr;
5406
5407 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5409 Cell::VisitObjects(me, searcher, range);
5410 return unit;
5411}
Definition GridNotifiers.h:796

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5414{
5415 if (!me)
5416 {
5417 return nullptr;
5418 }
5419
5420 Unit* unit = nullptr;
5421 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5423 Cell::VisitObjects(me, searcher, range);
5424 return unit;
5425}
Definition GridNotifiers.h:815

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5236{
5237 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5238
5239 if (e.empty())
5240 {
5241 if (obj)
5242 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5243
5244 if (at)
5245 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5246 return;
5247 }
5248 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5249 {
5250#ifndef ACORE_DEBUG
5251 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5252 continue;
5253#endif
5254
5255 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5256 {
5257 if (obj && obj->GetMap()->IsDungeon())
5258 {
5259 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5260 {
5261 mEvents.push_back((*i));
5262 }
5263 }
5264 continue;
5265 }
5266 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5267 }
5268}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition SmartScriptMgr.h:1963
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition SmartScriptMgr.h:1959
bool IsDungeon() const
Definition Map.h:297
uint8 GetSpawnMode() const
Definition Map.h:269
uint32 GetEntry() const
Definition Object.h:117
SmartAIEventList mEvents
Definition SmartScript.h:222
Map * GetMap() const
Definition Object.h:625

References AreaTrigger::entry, Object::GetEntry(), WorldObject::GetMap(), Map::GetSpawnMode(), Map::IsDungeon(), LOG_DEBUG, mEvents, SMART_EVENT_FLAG_DEBUG_ONLY, and SMART_EVENT_FLAG_DIFFICULTY_ALL.

Referenced by GetScript().

◆ FindCreatureNear()

Creature * SmartScript::FindCreatureNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const
inline
152 {
153 auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid);
154 if (bounds.first == bounds.second)
155 return nullptr;
156
157 auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
158 {
159 return pair.second->IsAlive();
160 });
161
162 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
163 }
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:355

References Map::GetCreatureBySpawnIdStore(), and WorldObject::GetMap().

Referenced by GetTargets(), and ProcessEvent().

◆ FindGameObjectNear()

GameObject * SmartScript::FindGameObjectNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const
inline
143 {
144 auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
145 if (bounds.first == bounds.second)
146 return nullptr;
147
148 return bounds.first->second;
149 }
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:358

References Map::GetGameObjectBySpawnIdStore(), and WorldObject::GetMap().

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

std::optional< std::reference_wrapper< SmartScriptHolder > > SmartScript::FindLinkedEvent ( uint32  link)
inlineprivate
270 {
271 if (!mEvents.empty())
272 {
273 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
274 {
275 if (i->event_id == link)
276 {
277 return std::ref(*i);
278 }
279 }
280 }
281 return std::nullopt;
282 }

References mEvents.

Referenced by ProcessAction().

◆ GetBaseObject()

WorldObject * SmartScript::GetBaseObject ( ) const
inline
65 {
66 WorldObject* obj = nullptr;
67 if (me)
68 obj = me;
69 else if (go)
70 obj = go;
71 return obj;
72 }
Definition Object.h:475

References go, and me.

Referenced by GetLastInvoker(), GetTargets(), GetWorldObjectsInDist(), InstallTemplate(), OnUpdate(), ProcessAction(), ProcessEvent(), ProcessEventsFor(), and ProcessTimedAction().

◆ GetCounterValue()

uint32 SmartScript::GetCounterValue ( uint32  id)
inline
135 {
136 CounterMap::iterator itr = mCounterList.find(id);
137 if (itr != mCounterList.end())
138 return itr->second;
139 return 0;
140 }
CounterMap mCounterList
Definition SmartScript.h:202

References mCounterList.

Referenced by ProcessEvent().

◆ GetEvents()

SmartAIEventList const & SmartScript::GetEvents ( ) const
inline
210{ return mEvents; }

References mEvents.

Referenced by SmartAI::InitializeAI().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5495{
5496 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5497 if (GetBaseObject())
5499 // xinef: used for area triggers invoker cast
5500 else if (invoker)
5502 return nullptr;
5503}
ObjectGuid mLastInvoker
Definition SmartScript.h:200
WorldObject * GetBaseObject() const
Definition SmartScript.h:64
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:115

References GetBaseObject(), ObjectAccessor::GetWorldObject(), and mLastInvoker.

Referenced by GetTargets(), and ProcessAction().

◆ GetPathId()

uint32 SmartScript::GetPathId ( ) const
inline
63{ return mPathId; }

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5271{
5273 if (me)
5274 {
5275 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5276 if (e.empty())
5277 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5278
5279 FillScript(e, me, nullptr);
5280
5281 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5282 {
5283 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5284 {
5285 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5286 FillScript(e, me, nullptr);
5287 }
5288 }
5289 }
5290 else if (go)
5291 {
5292 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5293 if (e.empty())
5294 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5295 FillScript(e, go, nullptr);
5296 }
5297 else if (trigger)
5298 {
5299 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5300 FillScript(e, nullptr, trigger);
5301 }
5302}
@ CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI
Definition CreatureData.h:73
std::int32_t int32
Definition Define.h:103
std::vector< SmartScriptHolder > SmartAIEventList
Definition SmartScriptMgr.h:2094
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2270
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:207
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition SmartScript.cpp:5235
uint32 entry
Definition ObjectMgr.h:424
Definition CreatureData.h:187

References CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI, AreaTrigger::entry, FillScript(), Creature::GetCreatureTemplate(), Object::GetEntry(), Creature::GetSpawnId(), GameObject::GetSpawnId(), go, me, mScriptType, sSmartScriptMgr, and trigger.

Referenced by OnInitialize().

◆ GetStoredTargetVector()

ObjectVector const * SmartScript::GetStoredTargetVector ( uint32  id,
WorldObject const &  ref 
) const
inline
101 {
102 auto itr = _storedTargets.find(id);
103 if (itr != _storedTargets.end())
104 return itr->second.GetObjectVector(ref);
105 return nullptr;
106 }
ObjectVectorMap _storedTargets
Definition SmartScript.h:249

References _storedTargets.

Referenced by SmartAI::EndPath(), GetTargets(), and ProcessAction().

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3546{
3547 WorldObject* scriptTrigger = nullptr;
3548 if (invoker)
3549 scriptTrigger = invoker;
3550 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3551 scriptTrigger = tempLastInvoker;
3552
3553 WorldObject* baseObject = GetBaseObject();
3554
3555 switch (e.GetTargetType())
3556 {
3557 case SMART_TARGET_SELF:
3558 if (baseObject)
3559 targets.push_back(baseObject);
3560 break;
3562 if (me)
3563 if (Unit* victim = me->GetVictim())
3564 targets.push_back(victim);
3565 break;
3567 if (me)
3568 {
3569 if (e.target.hostileRandom.powerType)
3570 {
3571 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false)))
3572 targets.push_back(u);
3573 }
3574 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3575 targets.push_back(u);
3576 }
3577 break;
3579 if (me)
3580 {
3581 if (e.target.hostileRandom.powerType)
3582 {
3583 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
3584 targets.push_back(u);
3585 }
3586 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3587 targets.push_back(u);
3588 }
3589 break;
3591 if (me)
3592 {
3593 if (e.target.hostileRandom.powerType)
3594 {
3595 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
3596 targets.push_back(u);
3597 }
3598 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3599 targets.push_back(u);
3600 }
3601 break;
3603 if (me)
3604 {
3605 if (e.target.hostileRandom.powerType)
3606 {
3607 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false)))
3608 targets.push_back(u);
3609 }
3610 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3611 targets.push_back(u);
3612 }
3613 break;
3615 if (me)
3616 {
3617 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, RangeSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos, e.target.farthest.minDist)))
3618 targets.push_back(u);
3619 }
3620 break;
3622 if (scriptTrigger)
3623 targets.push_back(scriptTrigger);
3624 break;
3626 if (scriptTrigger && IsUnit(scriptTrigger))
3627 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3628 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3629 break;
3631 if (scriptTrigger)
3632 {
3633 if (Player* player = scriptTrigger->ToPlayer())
3634 {
3635 if (Group* group = player->GetGroup())
3636 {
3637 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3638 if (Player* member = groupRef->GetSource())
3639 {
3640 if (member->IsInMap(player))
3641 targets.push_back(member);
3642
3643 if (e.target.invokerParty.includePets)
3644 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3645 if (pet->IsPet() && pet->IsInMap(player))
3646 targets.push_back(pet);
3647 }
3648 }
3649 // We still add the player to the list if there is no group. If we do
3650 // this even if there is a group (thus the else-check), it will add the
3651 // same player to the list twice. We don't want that to happen.
3652 else
3653 targets.push_back(scriptTrigger);
3654 }
3655 }
3656 break;
3658 {
3659 WorldObject* ref = baseObject;
3660 if (!ref)
3661 ref = scriptTrigger;
3662
3663 if (!ref)
3664 {
3665 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3666 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3667 break;
3668 }
3669
3670 ObjectVector units;
3671 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3672
3673 for (WorldObject* unit : units)
3674 {
3675 if (!IsCreature(unit))
3676 continue;
3677
3678 if (me && me->GetGUID() == unit->GetGUID())
3679 continue;
3680
3681 // check alive state - 1 alive, 2 dead, 0 both
3682 if (uint32 state = e.target.unitRange.livingState)
3683 {
3684 if (unit->ToCreature()->IsAlive() && state == 2)
3685 continue;
3686 if (!unit->ToCreature()->IsAlive() && state == 1)
3687 continue;
3688 }
3689
3690 if (((e.target.unitRange.creature && unit->ToCreature()->GetEntry() == e.target.unitRange.creature) || !e.target.unitRange.creature) && ref->IsInRange(unit, (float)e.target.unitRange.minDist, (float)e.target.unitRange.maxDist))
3691 targets.push_back(unit);
3692 }
3693
3694 break;
3695 }
3697 {
3698 ObjectVector units;
3699 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3700
3701 for (WorldObject* unit : units)
3702 {
3703 if (!IsCreature(unit))
3704 continue;
3705
3706 if (me && me->GetGUID() == unit->GetGUID())
3707 continue;
3708
3709 // check alive state - 1 alive, 2 dead, 0 both
3710 if (uint32 state = e.target.unitDistance.livingState)
3711 {
3712 if (unit->ToCreature()->IsAlive() && state == 2)
3713 continue;
3714 if (!unit->ToCreature()->IsAlive() && state == 1)
3715 continue;
3716 }
3717
3718 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3719 targets.push_back(unit);
3720 }
3721
3722 break;
3723 }
3725 {
3726 ObjectVector units;
3727 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3728
3729 for (WorldObject* unit : units)
3730 {
3731 if (!IsGameObject(unit))
3732 continue;
3733
3734 if (go && go->GetGUID() == unit->GetGUID())
3735 continue;
3736
3737 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3738 targets.push_back(unit);
3739 }
3740
3741 break;
3742 }
3744 {
3745
3746 WorldObject* ref = baseObject;
3747 if (!ref)
3748 ref = scriptTrigger;
3749
3750 if (!ref)
3751 {
3752 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3753 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3754 break;
3755 }
3756
3757 ObjectVector units;
3758 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3759
3760 for (WorldObject* unit : units)
3761 {
3762 if (!IsGameObject(unit))
3763 continue;
3764
3765 if (go && go->GetGUID() == unit->GetGUID())
3766 continue;
3767
3768 if (((e.target.goRange.entry && IsGameObject(unit) && unit->ToGameObject()->GetEntry() == e.target.goRange.entry) || !e.target.goRange.entry) && ref->IsInRange((unit), (float)e.target.goRange.minDist, (float)e.target.goRange.maxDist))
3769 targets.push_back(unit);
3770 }
3771
3772 break;
3773 }
3775 {
3776 if (!scriptTrigger && !baseObject)
3777 {
3778 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3779 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3780 break;
3781 }
3782
3783 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3784 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3785 targets.push_back(target);
3786 break;
3787 }
3789 {
3790 if (!scriptTrigger && !GetBaseObject())
3791 {
3792 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3793 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3794 break;
3795 }
3796
3797 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3798 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3799 targets.push_back(target);
3800 break;
3801 }
3803 {
3804 ObjectVector units;
3805 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3806
3807 if (!units.empty() && baseObject)
3808 for (WorldObject* unit : units)
3809 if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3810 targets.push_back(unit);
3811
3812 if (e.target.playerRange.maxCount)
3813 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3814
3815 break;
3816 }
3818 {
3819 ObjectVector units;
3820 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3821
3822 for (WorldObject* unit : units)
3823 if (IsPlayer(unit))
3824 targets.push_back(unit);
3825 break;
3826 }
3828 {
3829 WorldObject* ref = baseObject;
3830 if (!ref)
3831 ref = scriptTrigger;
3832
3833 if (!ref)
3834 {
3835 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3836 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3837 break;
3838 }
3839
3840 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3841 targets.assign(stored->begin(), stored->end());
3842 break;
3843 }
3845 {
3846 WorldObject* ref = baseObject;
3847
3848 if (!ref)
3849 ref = scriptTrigger;
3850
3851 if (!ref)
3852 {
3853 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3854 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3855 break;
3856 }
3857
3858 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3859 if (target)
3860 targets.push_back(target);
3861 break;
3862 }
3864 {
3865 WorldObject* ref = baseObject;
3866
3867 if (!ref)
3868 ref = scriptTrigger;
3869
3870 if (!ref)
3871 {
3872 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3873 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3874 break;
3875 }
3876
3877 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3878 if (target)
3879 targets.push_back(target);
3880 break;
3881 }
3883 {
3884 WorldObject* ref = baseObject;
3885
3886 if (!ref)
3887 ref = scriptTrigger;
3888
3889 if (!ref)
3890 {
3891 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3892 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3893 break;
3894 }
3895
3896 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3897 targets.push_back(target);
3898 break;
3899 }
3901 /*
3902 * Owners/Summoners should be WorldObjects. This allows to have other objects
3903 * such as gameobjects to execute SmartScripts using this type of target.
3904 * Otherwise, only Units like creatures can summon other creatures.
3905 */
3906 {
3907 if (me)
3908 {
3910 {
3911 targets.push_back(owner);
3912 }
3913 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3914 {
3915 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3916 }
3917 }
3918 else if (go)
3919 {
3921 {
3922 targets.push_back(owner);
3923 }
3924 }
3925
3926 // xinef: Get owner of owner
3927 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3928 {
3929 if (WorldObject* owner = targets.front())
3930 {
3931 targets.clear();
3932
3933 if (IsCreature(owner))
3934 {
3935 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3936 targets.push_back(base);
3937 }
3938 else if (IsGameObject(owner))
3939 {
3940 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3941 targets.push_back(base);
3942 }
3943 else if (IsPlayer(owner))
3944 {
3945 if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
3946 targets.push_back(base);
3947 }
3948 }
3949 }
3950 break;
3951 }
3953 {
3954 if (me)
3955 {
3956 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
3957 if (Unit* temp = ref->GetVictim())
3958 // Xinef: added distance check
3959 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3960 targets.push_back(temp);
3961 }
3962 break;
3963 }
3965 {
3966 if (me)
3967 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3968 targets.push_back(target);
3969
3970 break;
3971 }
3973 {
3974 if (me)
3975 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3976 targets.push_back(target);
3977
3978 break;
3979 }
3981 {
3982 ObjectVector units;
3983 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3984
3985 for (WorldObject* unit : units)
3986 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3987 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3988 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3989 targets.push_back(unit);
3990
3991 if (e.target.o > 0)
3992 Acore::Containers::RandomResize(targets, e.target.o);
3993
3994 break;
3995 }
3997 {
3998 ObjectVector units;
3999 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
4000 // 1 = Tanks, 2 = Healer, 4 = Damage
4001 uint32 roleMask = e.target.roleSelection.roleMask;
4002 for (WorldObject* unit : units)
4003 if (Player* targetPlayer = unit->ToPlayer())
4004 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
4005 {
4006 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
4007 {
4008 if (targetPlayer->HasTankSpec())
4009 {
4010 targets.push_back(unit);
4011 continue;
4012 }
4013 }
4014 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
4015 {
4016 if (targetPlayer->HasHealSpec())
4017 {
4018 targets.push_back(unit);
4019 continue;
4020 }
4021 }
4022 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
4023 {
4024 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
4025 {
4026 targets.push_back(unit);
4027 continue;
4028 }
4029 }
4030 }
4031
4032 if (e.target.roleSelection.resize > 0)
4033 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
4034
4035 break;
4036 }
4038 {
4039 if (me && me->IsVehicle())
4040 {
4041 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
4042 {
4043 targets.push_back(target);
4044 }
4045 }
4046 break;
4047 }
4049 {
4050 if (me)
4051 {
4052 if (Group* lootGroup = me->GetLootRecipientGroup())
4053 {
4054 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
4055 {
4056 if (Player* recipient = it->GetSource())
4057 {
4058 targets.push_back(recipient);
4059 }
4060 }
4061 }
4062 else
4063 {
4064 if (Player* recipient = me->GetLootRecipient())
4065 {
4066 targets.push_back(recipient);
4067 }
4068 }
4069 }
4070 break;
4071 }
4073 {
4074 if (me)
4075 {
4076 for (ObjectGuid const& guid : _summonList)
4077 {
4078 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
4079 {
4080 if (Creature* creature = me->GetMap()->GetCreature(guid))
4081 {
4082 targets.push_back(creature);
4083 }
4084 }
4085 }
4086 }
4087 break;
4088 }
4090 {
4091 InstanceScript* instance = nullptr;
4092
4093 if (e.IsAreatriggerScript() && scriptTrigger)
4094 instance = scriptTrigger->GetInstanceScript();
4095 else
4096 instance = GetBaseObject()->GetInstanceScript();
4097
4098 if (!instance)
4099 {
4100 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4101 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4102 return;
4103 }
4104
4105 if (e.target.instanceStorage.type == 1)
4106 {
4107 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
4108 targets.push_back(creature);
4109 }
4110 else if (e.target.instanceStorage.type == 2)
4111 {
4112 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4113 targets.push_back(go);
4114 }
4115
4116 break;
4117 }
4119 {
4120 if (me)
4121 {
4122 if (CreatureGroup* group = me->GetFormation())
4123 {
4124 uint32 formationType = e.target.formation.type;
4125 uint32 entry = e.target.formation.entry;
4126 bool excludeSelf = e.target.formation.excludeSelf;
4127
4128 if (formationType == 1) // Leader only
4129 {
4130 if (Creature* leader = group->GetLeader())
4131 {
4132 if ((!excludeSelf || leader != me) && (!entry || leader->GetEntry() == entry))
4133 targets.push_back(leader);
4134 }
4135 }
4136 else // 0 = Members only, 2 = All
4137 {
4138 for (auto const& itr : group->GetMembers())
4139 {
4140 Creature* member = itr.first;
4141
4142 if (!member)
4143 continue;
4144
4145 if (excludeSelf && member == me)
4146 continue;
4147
4148 if (entry && member->GetEntry() != entry)
4149 continue;
4150
4151 if (formationType == 0 && member == group->GetLeader())
4152 continue;
4153
4154 targets.push_back(member);
4155 }
4156 }
4157 }
4158 }
4159 break;
4160 }
4161 case SMART_TARGET_NONE:
4163 default:
4164 break;
4165 }
4166}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:933
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition ScriptedCreature.cpp:938
Powers
Definition SharedDefines.h:256
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition SmartScriptMgr.h:1788
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1787
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1789
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1577
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1569
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1561
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1566
@ SMART_TARGET_FORMATION
Definition SmartScriptMgr.h:1592
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1576
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1570
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1579
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1563
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1560
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1567
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1590
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1565
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1559
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1571
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1564
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1573
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1587
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1589
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1557
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1558
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1554
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1572
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1591
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1578
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1574
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1575
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1568
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1562
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2034
Definition CreatureGroups.h:90
Definition Creature.h:47
CreatureGroup const * GetFormation() const
Definition Creature.h:372
Player * GetLootRecipient() const
Definition Creature.cpp:1293
Group * GetLootRecipientGroup() const
Definition Creature.cpp:1300
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition Creature.cpp:2416
CreatureAI * AI() const
Definition Creature.h:144
Definition GameObject.h:120
ObjectGuid GetOwnerGUID() const
Definition GameObject.h:174
Definition GroupReference.h:27
Definition Group.h:176
Definition InstanceScript.h:143
Creature * GetCreature(uint32 type)
Definition InstanceScript.cpp:116
GameObject * GetGameObject(uint32 type)
Definition InstanceScript.cpp:121
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2362
Definition ObjectGuid.h:118
Player * ToPlayer()
Definition Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Unit * ToUnit()
Definition Object.h:210
Definition Player.h:1084
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5505
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5510
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5515
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5494
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4168
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5531
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5447
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:142
Unit * GetSummonerUnit() const
Definition TemporarySummon.cpp:44
Definition ThreatManager.h:267
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:111
bool IsVehicle() const
Definition Unit.h:800
Vehicle * GetVehicle() const
Definition Unit.h:1930
TempSummon * ToTempSummon()
Definition Unit.h:731
Unit * GetCharmerOrOwner() const
Definition Unit.h:1286
bool IsSummon() const
Definition Unit.h:794
Unit * GetVictim() const
Definition Unit.h:903
Vehicle * GetVehicleKit() const
Definition Unit.h:1929
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1295
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:239
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1238
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2525
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1460
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:199
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition ObjectAccessor.cpp:234
Definition UnitAI.h:135
Definition UnitAI.h:170

References _summonList, Creature::AI(), SmartTarget::aura, SmartTarget::closestAttackable, SmartTarget::closestFriendly, SmartTarget::creature, SmartTarget::dbGuid, SmartTarget::dead, SmartTarget::dist, SmartTarget::distMax, SmartTarget::distMin, DoFindClosestFriendlyInRange(), SmartTarget::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, SmartTarget::excludeSelf, SmartTarget::farthest, FindCreatureNear(), FindGameObjectNear(), SmartTarget::formation, SmartScriptHolder::GetActionType(), Vehicle::GetBase(), GetBaseObject(), Unit::GetCharmerOrOwner(), Unit::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), InstanceScript::GetCreature(), ObjectAccessor::GetCreatureOrPetOrVehicle(), Object::GetEntry(), Creature::GetFormation(), InstanceScript::GetGameObject(), Object::GetGUID(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), Creature::GetLootRecipientGroup(), WorldObject::GetMap(), GameObject::GetOwnerGUID(), Vehicle::GetPassenger(), SmartScriptHolder::GetScriptType(), GetStoredTargetVector(), TempSummon::GetSummonerUnit(), SmartScriptHolder::GetTargetType(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), ThreatManager::GetUnsortedThreatList(), Unit::GetVehicle(), Unit::GetVehicleKit(), Unit::GetVictim(), ObjectAccessor::GetWorldObject(), GetWorldObjectsInDist(), go, SmartTarget::goClosest, SmartTarget::goDistance, SmartTarget::goGUID, SmartTarget::goRange, SmartTarget::hostileRandom, SmartTarget::id, SmartTarget::includePets, SmartTarget::index, SmartTarget::instanceStorage, SmartTarget::invokerParty, SmartScriptHolder::IsAreatriggerScript(), IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, MaxThreat, me, SmartTarget::minDist, MinDistance, MinThreat, SmartTarget::negation, SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, Random, Acore::Containers::RandomResize(), SmartTarget::resize, SmartTarget::roleMask, SmartTarget::roleSelection, SmartTarget::seatMask, WorldObject::SelectNearestPlayer(), Creature::SelectNearestTarget(), UnitAI::SelectTarget(), SMART_TARGET_ACTION_INVOKER, SMART_TARGET_ACTION_INVOKER_VEHICLE, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_ENEMY, SMART_TARGET_CLOSEST_FRIENDLY, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_FARTHEST, SMART_TARGET_FORMATION, SMART_TARGET_GAMEOBJECT_DISTANCE, SMART_TARGET_GAMEOBJECT_GUID, SMART_TARGET_GAMEOBJECT_RANGE, SMART_TARGET_HOSTILE_LAST_AGGRO, SMART_TARGET_HOSTILE_RANDOM, SMART_TARGET_HOSTILE_RANDOM_NOT_TOP, SMART_TARGET_HOSTILE_SECOND_AGGRO, SMART_TARGET_INSTANCE_STORAGE, SMART_TARGET_INVOKER_PARTY, SMART_TARGET_LOOT_RECIPIENTS, SMART_TARGET_NONE, SMART_TARGET_OWNER_OR_SUMMONER, SMART_TARGET_PLAYER_DISTANCE, SMART_TARGET_PLAYER_RANGE, SMART_TARGET_PLAYER_WITH_AURA, SMART_TARGET_POSITION, SMART_TARGET_ROLE_FLAG_DAMAGERS, SMART_TARGET_ROLE_FLAG_HEALERS, SMART_TARGET_ROLE_FLAG_TANKS, SMART_TARGET_ROLE_SELECTION, SMART_TARGET_SELF, SMART_TARGET_STORED, SMART_TARGET_SUMMONED_CREATURES, SMART_TARGET_THREAT_LIST, SMART_TARGET_VEHICLE_PASSENGER, SMART_TARGET_VICTIM, SmartTarget::spellId, SmartTarget::stored, SmartTarget::summonedCreatures, SmartScriptHolder::target, SmartTarget::threatList, Object::ToPlayer(), Unit::ToTempSummon(), Object::ToUnit(), SmartTarget::type, SmartTarget::unitClosest, SmartTarget::unitDistance, SmartTarget::unitGUID, SmartTarget::unitRange, SmartTarget::useCharmerOrOwner, and SmartTarget::vehicle.

Referenced by ProcessAction(), and ProcessEvent().

◆ GetWorldObjectsInDist()

void SmartScript::GetWorldObjectsInDist ( ObjectVector objects,
float  dist 
) const
4169{
4170 WorldObject* obj = GetBaseObject();
4171 if (!obj)
4172 return;
4173
4174 Acore::AllWorldObjectsInRange u_check(obj, dist);
4176 Cell::VisitObjects(obj, searcher, dist);
4177}
Definition GridNotifiers.h:1646
Definition GridNotifiers.h:260

References GetBaseObject(), and Cell::VisitObjects().

Referenced by GetTargets(), ProcessAction(), and ProcessEvent().

◆ IncPhase()

void SmartScript::IncPhase ( uint32  p)
private
5537{
5538 // protect phase from overflowing
5539 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5540}
@ SMART_EVENT_PHASE_12
Definition SmartScriptMgr.h:57

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
4979{
4980 switch (e.GetEventType())
4981 {
4982 //set only events which have initial timers
4986 break;
4987 case SMART_EVENT_UPDATE:
4990 case SMART_EVENT_RANGE:
4997 break;
5001 break;
5005 break;
5006 default:
5007 e.active = true;
5008 break;
5009 }
5010}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition SmartScriptMgr.h:173
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition SmartScriptMgr.h:191
@ SMART_EVENT_AREA_CASTING
Definition SmartScriptMgr.h:194
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition SmartScriptMgr.h:175
@ SMART_EVENT_RANGE
Definition SmartScriptMgr.h:108
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition SmartScriptMgr.h:193
@ SMART_EVENT_UPDATE_IC
Definition SmartScriptMgr.h:99
@ SMART_EVENT_IS_IN_MELEE_RANGE
Definition SmartScriptMgr.h:199
@ SMART_EVENT_AREA_RANGE
Definition SmartScriptMgr.h:195
@ SMART_EVENT_UPDATE
Definition SmartScriptMgr.h:159
@ SMART_EVENT_IS_BEHIND_TARGET
Definition SmartScriptMgr.h:166
@ SMART_EVENT_UPDATE_OOC
Definition SmartScriptMgr.h:100
@ SMART_EVENT_NEAR_UNIT
Definition SmartScriptMgr.h:192
@ SMART_EVENT_DISTANCE_CREATURE
Definition SmartScriptMgr.h:174
@ SMART_EVENT_NEAR_PLAYERS
Definition SmartScriptMgr.h:190
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition SmartScript.cpp:5011
struct SmartEvent::@30::@68 nearPlayer
struct SmartEvent::@30::@32 minMaxRepeat
struct SmartEvent::@30::@70 nearUnit
uint32 repeat
Definition SmartScriptMgr.h:449
uint32 min
Definition SmartScriptMgr.h:214
uint32 firstTimer
Definition SmartScriptMgr.h:464
uint32 max
Definition SmartScriptMgr.h:215
uint32 timer
Definition SmartScriptMgr.h:484
struct SmartEvent::@30::@66 distance
bool active
Definition SmartScriptMgr.h:2021
uint32 GetEventType() const
Definition SmartScriptMgr.h:2013

References SmartScriptHolder::active, SmartEvent::distance, SmartScriptHolder::event, SmartEvent::firstTimer, SmartScriptHolder::GetEventType(), SmartEvent::max, SmartEvent::min, SmartEvent::minMaxRepeat, SmartEvent::nearPlayer, SmartEvent::nearUnit, RecalcTimer(), SmartEvent::repeat, SMART_EVENT_AREA_CASTING, SMART_EVENT_AREA_RANGE, SMART_EVENT_DISTANCE_CREATURE, SMART_EVENT_DISTANCE_GAMEOBJECT, SMART_EVENT_FRIENDLY_HEALTH_PCT, SMART_EVENT_IS_BEHIND_TARGET, SMART_EVENT_IS_IN_MELEE_RANGE, SMART_EVENT_NEAR_PLAYERS, SMART_EVENT_NEAR_PLAYERS_NEGATION, SMART_EVENT_NEAR_UNIT, SMART_EVENT_NEAR_UNIT_NEGATION, SMART_EVENT_RANGE, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_UPDATE_OOC, and SmartEvent::timer.

Referenced by CreateSmartEvent(), OnInitialize(), OnReset(), ProcessAction(), and SetScript9().

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private
5130{
5131 if (!mInstallEvents.empty())
5132 {
5133 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
5134 mEvents.push_back(*i);//must be before UpdateTimers
5135
5136 mInstallEvents.clear();
5137 }
5138}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3434{
3435 if (!GetBaseObject())
3436 return;
3438 {
3439 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3440 return;
3441 }
3442 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3443 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3444 {
3446 {
3447 AddEvent(SMART_EVENT_UPDATE_IC, 0, 0, 0, e.action.installTtemplate.param2, e.action.installTtemplate.param3, 0, 0, SMART_ACTION_CAST, e.action.installTtemplate.param1, e.target.raw.param1, 0, 0, 0, 0, SMART_TARGET_VICTIM, 0, 0, 0, 0, 1);
3448 AddEvent(SMART_EVENT_RANGE, 0, e.action.installTtemplate.param4, 300, 0, 0, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3449 AddEvent(SMART_EVENT_RANGE, 0, 0, e.action.installTtemplate.param4 > 10 ? e.action.installTtemplate.param4 - 10 : 0, 0, 0, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 0, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3450 AddEvent(SMART_EVENT_MANA_PCT, 0, e.action.installTtemplate.param5 - 15 > 100 ? 100 : e.action.installTtemplate.param5 + 15, 100, 1000, 1000, 0, 0, SMART_ACTION_SET_EVENT_PHASE, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3451 AddEvent(SMART_EVENT_MANA_PCT, 0, 0, e.action.installTtemplate.param5, 1000, 1000, 0, 0, SMART_ACTION_SET_EVENT_PHASE, 0, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3452 AddEvent(SMART_EVENT_MANA_PCT, 0, 0, e.action.installTtemplate.param5, 1000, 1000, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3453 break;
3454 }
3456 {
3457 AddEvent(SMART_EVENT_UPDATE_IC, 0, 0, 0, e.action.installTtemplate.param2, e.action.installTtemplate.param3, 0, 0, SMART_ACTION_CAST, e.action.installTtemplate.param1, e.target.raw.param1, 0, 0, 0, 0, SMART_TARGET_VICTIM, 0, 0, 0, 0, 0);
3458 AddEvent(SMART_EVENT_JUST_CREATED, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 0, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3459 break;
3460 }
3462 {
3463 if (!me)
3464 return;
3465 //store cage as id1
3466 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 1, 0, 0, 0, 0, 0, SMART_TARGET_CLOSEST_GAMEOBJECT, e.action.installTtemplate.param1, 10, 0, 0, 0);
3467
3468 //reset(close) cage on hostage(me) respawn
3469 AddEvent(SMART_EVENT_UPDATE, SMART_EVENT_FLAG_NOT_REPEATABLE, 0, 0, 0, 0, 0, 0, SMART_ACTION_RESET_GOBJECT, 0, 0, 0, 0, 0, 0, SMART_TARGET_GAMEOBJECT_DISTANCE, e.action.installTtemplate.param1, 5, 0, 0, 0);
3470
3471 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_SET_RUN, e.action.installTtemplate.param3, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3472 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_SET_EVENT_PHASE, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3473
3474 AddEvent(SMART_EVENT_UPDATE, SMART_EVENT_FLAG_NOT_REPEATABLE, 1000, 1000, 0, 0, 0, 0, SMART_ACTION_MOVE_FORWARD, e.action.installTtemplate.param4, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3475 //phase 1: give quest credit on movepoint reached
3477 //phase 1: despawn after time on movepoint reached
3478 AddEvent(SMART_EVENT_MOVEMENTINFORM, 0, POINT_MOTION_TYPE, SMART_RANDOM_POINT, 0, 0, 0, 0, SMART_ACTION_FORCE_DESPAWN, e.action.installTtemplate.param2, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3479
3480 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3481 AddEvent(SMART_EVENT_MOVEMENTINFORM, 0, POINT_MOTION_TYPE, SMART_RANDOM_POINT, 0, 0, 0, 0, SMART_ACTION_TALK, e.action.installTtemplate.param5, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3482 break;
3483 }
3485 {
3486 if (!go)
3487 return;
3488 //store hostage as id1
3489 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 1, 0, 0, 0, 0, 0, SMART_TARGET_CLOSEST_CREATURE, e.action.installTtemplate.param1, 10, 0, 0, 0);
3490 //store invoker as id2
3491 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 2, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3492 //signal hostage
3493 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_SET_DATA, 0, 0, 0, 0, 0, 0, SMART_TARGET_STORED, 1, 0, 0, 0, 0);
3494 //when hostage raeched end point, give credit to invoker
3495 if (e.action.installTtemplate.param2)
3496 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_CALL_KILLEDMONSTER, e.action.installTtemplate.param1, 0, 0, 0, 0, 0, SMART_TARGET_STORED, 2, 0, 0, 0, 0);
3497 else
3498 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_CALL_KILLEDMONSTER, e.action.installTtemplate.param1, 0, 0, 0, 0, 0, SMART_TARGET_STORED, 2, 0, 0, 0, 0);
3499 break;
3500 }
3502 default:
3503 return;
3504 }
3505}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:110
std::uint8_t uint8
Definition Define.h:109
@ POINT_MOTION_TYPE
Definition MotionMaster.h:48
SMARTAI_TEMPLATE
Definition SmartScriptMgr.h:1538
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1543
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1544
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1540
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1541
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1952
@ SMART_ACTION_STORE_TARGET_LIST
Definition SmartScriptMgr.h:606
@ SMART_ACTION_FORCE_DESPAWN
Definition SmartScriptMgr.h:583
@ SMART_ACTION_CAST
Definition SmartScriptMgr.h:553
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition SmartScriptMgr.h:563
@ SMART_ACTION_MOVE_FORWARD
Definition SmartScriptMgr.h:588
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition SmartScriptMgr.h:575
@ SMART_ACTION_TALK
Definition SmartScriptMgr.h:543
@ SMART_ACTION_SET_DATA
Definition SmartScriptMgr.h:587
@ SMART_ACTION_SET_RUN
Definition SmartScriptMgr.h:601
@ SMART_ACTION_SET_EVENT_PHASE
Definition SmartScriptMgr.h:564
@ SMART_ACTION_RESET_GOBJECT
Definition SmartScriptMgr.h:574
@ SMART_EVENT_DATA_SET
Definition SmartScriptMgr.h:137
@ SMART_EVENT_JUST_CREATED
Definition SmartScriptMgr.h:162
@ SMART_EVENT_MOVEMENTINFORM
Definition SmartScriptMgr.h:133
@ SMART_EVENT_MANA_PCT
Definition SmartScriptMgr.h:102
@ SMART_EVENT_GO_STATE_CHANGED
Definition SmartScriptMgr.h:169
@ SMART_RANDOM_POINT
Definition SmartScriptMgr.h:39
void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
Definition SmartScript.cpp:3507

References SmartScriptHolder::action, AddEvent(), SmartScriptHolder::entryOrGuid, GetBaseObject(), Object::GetEntry(), SmartScriptHolder::GetScriptType(), go, SmartAction::id, SmartAction::installTtemplate, LOG_ERROR, me, mTemplate, SmartAction::param1, SmartTarget::param1, SmartAction::param2, SmartAction::param3, SmartAction::param4, SmartAction::param5, POINT_MOTION_TYPE, SmartTarget::raw, sCreatureTextMgr, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, SMART_ACTION_CALL_KILLEDMONSTER, SMART_ACTION_CAST, SMART_ACTION_FORCE_DESPAWN, SMART_ACTION_MOVE_FORWARD, SMART_ACTION_RESET_GOBJECT, SMART_ACTION_SET_DATA, SMART_ACTION_SET_EVENT_PHASE, SMART_ACTION_SET_RUN, SMART_ACTION_STORE_TARGET_LIST, SMART_ACTION_TALK, SMART_EVENT_DATA_SET, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_GO_STATE_CHANGED, SMART_EVENT_JUST_CREATED, SMART_EVENT_MANA_PCT, SMART_EVENT_MOVEMENTINFORM, SMART_EVENT_RANGE, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_RANDOM_POINT, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_GAMEOBJECT_DISTANCE, SMART_TARGET_NONE, SMART_TARGET_STORED, SMART_TARGET_VICTIM, SMARTAI_TEMPLATE_BASIC, SMARTAI_TEMPLATE_CAGED_GO_PART, SMARTAI_TEMPLATE_CAGED_NPC_PART, SMARTAI_TEMPLATE_CASTER, SMARTAI_TEMPLATE_TURRET, and SmartScriptHolder::target.

Referenced by ProcessAction().

◆ IsCharmedCreature()

bool SmartScript::IsCharmedCreature ( WorldObject obj)
static
5521{
5522 if (!obj)
5523 return false;
5524
5525 if (Creature* creatureObj = obj->ToCreature())
5526 return creatureObj->IsCharmed();
5527
5528 return false;
5529}
Creature * ToCreature()
Definition Object.h:206

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5516{
5517 return obj && obj->IsCreature();
5518}
bool IsCreature() const
Definition Object.h:205

References Object::IsCreature().

Referenced by GetTargets(), ProcessAction(), and ProcessEvent().

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5532{
5533 return obj && obj->IsGameObject();
5534}
bool IsGameObject() const
Definition Object.h:213

References Object::IsGameObject().

Referenced by GetTargets(), ProcessAction(), and ProcessEvent().

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5567{
5568 if (mEventPhase == 0)
5569 {
5570 return false;
5571 }
5572
5573 return ((1 << (mEventPhase - 1)) & p) != 0;
5574}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5511{
5512 return obj && obj->IsPlayer();
5513}
bool IsPlayer() const
Definition Object.h:201

References Object::IsPlayer().

Referenced by SmartAI::EndPath(), GetTargets(), SmartAI::IsEscortInvokerInRange(), ProcessAction(), and ProcessEvent().

◆ IsSmart() [1/3]

bool SmartScript::IsSmart ( bool  silent = false) const
101{
102 if (me)
103 return IsSmart(me, silent);
104 if (go)
105 return IsSmart(go, silent);
106
107 return false;
108}
bool IsSmart(Creature *c, bool silent=false) const
Definition SmartScript.cpp:70

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

bool SmartScript::IsSmart ( Creature c,
bool  silent = false 
) const
71{
72 if (!c)
73 return false;
74
75 bool smart = true;
76 if (!dynamic_cast<SmartAI*>(c->AI()))
77 smart = false;
78
79 if (!smart && !silent)
80 LOG_ERROR("sql.sql", "SmartScript: Action target Creature(entry: {}) is not using SmartAI, action skipped to prevent crash.", c ? c->GetEntry() : (me ? me->GetEntry() : 0));
81
82 return smart;
83}
Definition SmartAI.h:46

References Creature::AI(), Object::GetEntry(), LOG_ERROR, and me.

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

bool SmartScript::IsSmart ( GameObject g,
bool  silent = false 
) const
86{
87 if (!g)
88 return false;
89
90 bool smart = true;
91 if (!dynamic_cast<SmartGameObjectAI*>(g->AI()))
92 smart = false;
93
94 if (!smart && !silent)
95 LOG_ERROR("sql.sql", "SmartScript: Action target GameObject(entry: {}) is not using SmartGameObjectAI, action skipped to prevent crash.", g ? g->GetEntry() : (go ? go->GetEntry() : 0));
96
97 return smart;
98}
GameObjectAI * AI() const
Definition GameObject.h:307
Definition SmartAI.h:288

References GameObject::AI(), Object::GetEntry(), go, and LOG_ERROR.

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5506{
5507 return obj && (obj->IsCreature() || obj->IsPlayer());
5508}

References Object::IsCreature(), and Object::IsPlayer().

Referenced by GetTargets(), ProcessAction(), and ProcessEvent().

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5305{
5306 if (obj)//handle object based scripts
5307 {
5308 switch (obj->GetTypeId())
5309 {
5310 case TYPEID_UNIT:
5312 me = obj->ToCreature();
5313 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5314 break;
5315 case TYPEID_GAMEOBJECT:
5317 go = obj->ToGameObject();
5318 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5319 break;
5320 default:
5321 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5322 return;
5323 }
5324 }
5325 else if (at)
5326 {
5328 trigger = at;
5329 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5330 }
5331 else
5332 {
5333 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5334 return;
5335 }
5336
5337 GetScript();//load copy of script
5338
5339 for (SmartScriptHolder& event : mEvents)
5340 InitTimer(event);//calculate timers for first time use
5341
5343 InstallEvents();
5345}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1795
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1796
@ SMART_EVENT_AI_INIT
Definition SmartScriptMgr.h:136
TypeID GetTypeId() const
Definition Object.h:129
GameObject * ToGameObject()
Definition Object.h:214
void ProcessEventsFor(SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:136
void InstallEvents()
Definition SmartScript.cpp:5129
void GetScript()
Definition SmartScript.cpp:5270

References AreaTrigger::entry, Object::GetEntry(), GetScript(), Object::GetTypeId(), go, InitTimer(), InstallEvents(), LOG_DEBUG, LOG_ERROR, me, mEvents, mScriptType, ProcessEventsFor(), SMART_EVENT_AI_INIT, SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_AREATRIGGER, SMART_SCRIPT_TYPE_CREATURE, SMART_SCRIPT_TYPE_GAMEOBJECT, Object::ToCreature(), Object::ToGameObject(), trigger, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

Referenced by SmartAI::InitializeAI(), SmartGameObjectAI::InitializeAI(), and SmartTrigger::OnTrigger().

◆ OnMoveInLineOfSight()

void SmartScript::OnMoveInLineOfSight ( Unit who)
5348{
5349 if (!me)
5350 return;
5351
5353}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:125
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:109
bool IsEngaged() const override
Definition Creature.cpp:2928

References Creature::IsEngaged(), me, ProcessEventsFor(), SMART_EVENT_IC_LOS, and SMART_EVENT_OOC_LOS.

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

void SmartScript::OnReset ( )
111{
112 // xinef: check if we allow phase reset
113 if (AllowPhaseReset())
114 SetPhase(0);
115
117 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
118 {
119 if (!((*i).event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
120 {
121 InitTimer((*i));
122 (*i).runOnce = false;
123 }
124
125 if ((*i).priority != SmartScriptHolder::DEFAULT_PRIORITY)
126 {
129 }
130 }
133 mCounterList.clear();
134}
@ SMART_EVENT_FLAG_DONT_RESET
Definition SmartScriptMgr.h:1960
@ SMART_EVENT_RESET
Definition SmartScriptMgr.h:124
void Clear()
Definition ObjectGuid.h:138
bool AllowPhaseReset() const
Definition SmartScript.h:204
void ResetBaseObject()
Definition SmartScript.h:166
static constexpr uint32 DEFAULT_PRIORITY
Definition SmartScriptMgr.h:2031

References AllowPhaseReset(), ObjectGuid::Clear(), SmartScriptHolder::DEFAULT_PRIORITY, InitTimer(), mCounterList, mEvents, mEventSortingRequired, mLastInvoker, ProcessEventsFor(), ResetBaseObject(), SetPhase(), SMART_EVENT_FLAG_DONT_RESET, and SMART_EVENT_RESET.

Referenced by SmartAI::EnterEvadeMode(), SmartAI::JustReachedHome(), ProcessAction(), and SmartGameObjectAI::Reset().

◆ OnUpdate()

void SmartScript::OnUpdate ( const uint32  diff)
5141{
5143 return;
5144
5145 InstallEvents();//before UpdateTimers
5146
5148 {
5150 mEventSortingRequired = false;
5151 }
5152
5153 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
5154 UpdateTimer(*i, diff);
5155
5156 if (!mStoredEvents.empty())
5157 {
5158 SmartAIEventStoredList::iterator i, icurr;
5159 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
5160 {
5161 icurr = i++;
5162 UpdateTimer(*icurr, diff);
5163 }
5164 }
5165
5166 bool needCleanup = true;
5167 if (!mTimedActionList.empty())
5168 {
5170 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5171 {
5172 if ((*i).enableTimed)
5173 {
5174 UpdateTimer(*i, diff);
5175 needCleanup = false;
5176 }
5177 }
5178
5180 }
5181 if (needCleanup)
5182 mTimedActionList.clear();
5183
5184 if (!mRemIDs.empty())
5185 {
5186 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5188
5189 // xinef: clear list after cleaning...
5190 mRemIDs.clear();
5191 }
5192 if (mUseTextTimer && me)
5193 {
5194 if (mTextTimer < diff)
5195 {
5196 uint32 textID = mLastTextID;
5197 mLastTextID = 0;
5198 uint32 entry = mTalkerEntry;
5199 mTalkerEntry = 0;
5200 mTextTimer = 0;
5201 mUseTextTimer = false;
5202 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5203 }
5204 else mTextTimer -= diff;
5205 }
5206}
@ SMART_EVENT_TEXT_OVER
Definition SmartScriptMgr.h:151
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition SmartScript.cpp:5018
void SortEvents(SmartAIEventList &events)
Definition SmartScript.cpp:5208
SmartAIEventStoredList mStoredEvents
Definition SmartScript.h:236
std::list< uint32 > mRemIDs
Definition SmartScript.h:237
SmartAIEventList mTimedActionList
Definition SmartScript.h:224
void RemoveStoredEvent(uint32 id)
Definition SmartScript.h:254

References GetBaseObject(), InstallEvents(), isProcessingTimedActionList, me, mEvents, mEventSortingRequired, mLastTextID, mRemIDs, mScriptType, mStoredEvents, mTalkerEntry, mTextTimer, mTimedActionList, mUseTextTimer, ProcessEventsFor(), RemoveStoredEvent(), SMART_EVENT_TEXT_OVER, SMART_SCRIPT_TYPE_CREATURE, SMART_SCRIPT_TYPE_GAMEOBJECT, SortEvents(), and UpdateTimer().

Referenced by SmartAI::UpdateAI(), and SmartGameObjectAI::UpdateAI().

◆ ProcessAction()

void SmartScript::ProcessAction ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
165{
166 e.runOnce = true;//used for repeat check
167
168 //calc random
170 {
171 uint32 rnd = urand(1, 100);
172 if (e.event.event_chance <= rnd)
173 return;
174 }
175
176 // Remove SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL flag after processing roll chances as it's not needed anymore
177 e.event.event_flags &= ~SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL;
178
179 if (unit)
180 mLastInvoker = unit->GetGUID();
181 else if (gob)
182 mLastInvoker = gob->GetGUID();
183
184 if (WorldObject* tempInvoker = GetLastInvoker())
185 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: Invoker: {} ({})", tempInvoker->GetName(), tempInvoker->GetGUID().ToString());
186
187 bool isControlled = e.action.moveToPos.controlled > 0;
188
189 ObjectVector targets;
190 WorldObject* invoker = nullptr;
191 if (unit)
192 invoker = unit;
193 else if (gob)
194 invoker = gob;
195
196 GetTargets(targets, e, invoker);
197
198 switch (e.GetActionType())
199 {
201 {
202 Creature* talker = e.target.type == 0 ? me : nullptr;
203 WorldObject* talkTarget = nullptr;
204
205 for (WorldObject* target : targets)
206 {
207 if (IsCreature((target)) && !target->ToCreature()->IsPet()) // Prevented sending text to pets.
208 {
210 {
211 talker = me;
212 talkTarget = target->ToCreature();
213 }
214 else
215 talker = target->ToCreature();
216 break;
217 }
218 else if (IsPlayer((target)))
219 {
220 talker = me; // xinef: added
221 talkTarget = target->ToPlayer();
222 break;
223 }
224 }
225
226 if (!talkTarget)
227 talkTarget = GetLastInvoker();
228
229 if (!talker)
230 break;
231
232 if (!sCreatureTextMgr->TextExist(talker->GetEntry(), uint8(e.action.talk.textGroupID)))
233 {
234 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: EntryOrGuid {} SourceType {} EventType {} TargetType {} using non-existent Text id {} for talker {}, ignored.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetTargetType(), e.action.talk.textGroupID, talker->GetEntry());
235 break;
236 }
237
238 mTalkerEntry = talker->GetEntry();
241 mUseTextTimer = true;
242
243 talker->AI()->Talk(e.action.talk.textGroupID, talkTarget, Milliseconds(e.action.talk.delay));
244 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} ({}), textId: {}", talker->GetName(), talker->GetGUID().ToString(), mLastTextID);
245 break;
246 }
248 {
249 for (WorldObject* target : targets)
250 {
251 if (IsCreature(target))
252 sCreatureTextMgr->SendChat(target->ToCreature(), uint8(e.action.simpleTalk.textGroupID), IsPlayer(GetLastInvoker()) ? GetLastInvoker() : 0);
253 else if (IsPlayer(target) && me)
254 {
255 WorldObject* templastInvoker = GetLastInvoker();
256 sCreatureTextMgr->SendChat(me, uint8(e.action.simpleTalk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target->ToPlayer());
257 }
258
259 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: {} ({}), textGroupId: {}",
260 target->GetName(), target->GetGUID().ToString(), uint8(e.action.simpleTalk.textGroupID));
261 }
262 break;
263 }
265 {
266 for (WorldObject* target : targets)
267 {
268 if (IsUnit(target))
269 {
270 target->ToUnit()->HandleEmoteCommand(e.action.emote.emote);
271 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: {} ({}), emote: {}",
272 target->GetName(), target->GetGUID().ToString(), e.action.emote.emote);
273 }
274 }
275 break;
276 }
278 {
279 for (WorldObject* target : targets)
280 {
281 if (IsUnit(target))
282 {
283 if (e.action.sound.distance == 1)
284 target->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
285 else
286 target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
287 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} ({}), sound: {}, onlyself: {}",
288 target->GetName(), target->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
289 }
290 }
291 break;
292 }
294 {
295 uint32 sounds[4];
296 sounds[0] = e.action.randomSound.sound1;
297 sounds[1] = e.action.randomSound.sound2;
298 sounds[2] = e.action.randomSound.sound3;
299 sounds[3] = e.action.randomSound.sound4;
300 uint32 temp[4];
301 uint32 count = 0;
302 for (unsigned int sound : sounds)
303 {
304 if (sound)
305 {
306 temp[count] = sound;
307 ++count;
308 }
309 }
310
311 if (count == 0)
312 {
313 break;
314 }
315
316 for (WorldObject* target : targets)
317 {
318 if (IsUnit(target))
319 {
320 uint32 sound = temp[urand(0, count - 1)];
321 target->PlayDirectSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
322 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
323 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
324 }
325 }
326
327 break;
328 }
330 {
331 ObjectVector targets;
332
333 if (e.action.music.type > 0)
334 {
335 if (me && me->FindMap())
336 {
337 Map::PlayerList const& players = me->GetMap()->GetPlayers();
338
339 if (!players.IsEmpty())
340 {
341 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
342 if (Player* player = i->GetSource())
343 {
344 if (player->GetZoneId() == me->GetZoneId())
345 {
346 if (e.action.music.type > 1)
347 {
348 if (player->GetAreaId() == me->GetAreaId())
349 targets.push_back(player);
350 }
351 else
352 targets.push_back(player);
353 }
354 }
355 }
356 }
357 }
358 else
359 GetTargets(targets, e);
360
361 if (!targets.empty())
362 {
363 for (WorldObject* target : targets)
364 {
365 if (IsUnit(target))
366 {
367 target->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0);
368 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: {} ({}), sound: {}, onlySelf: {}, type: {}",
369 target->GetName(), target->GetGUID().ToString(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type);
370 }
371 }
372 }
373 break;
374 }
376 {
377 ObjectVector targets;
378
379 if (e.action.randomMusic.type > 0)
380 {
381 if (me && me->FindMap())
382 {
383 Map::PlayerList const& players = me->GetMap()->GetPlayers();
384
385 if (!players.IsEmpty())
386 {
387 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
388 if (Player* player = i->GetSource())
389 {
390 if (player->GetZoneId() == me->GetZoneId())
391 {
392 if (e.action.randomMusic.type > 1)
393 {
394 if (player->GetAreaId() == me->GetAreaId())
395 targets.push_back(player);
396 }
397 else
398 targets.push_back(player);
399 }
400 }
401 }
402 }
403 }
404 else
405 GetTargets(targets, e);
406
407 if (targets.empty())
408 break;
409
410 uint32 sounds[4];
411 sounds[0] = e.action.randomMusic.sound1;
412 sounds[1] = e.action.randomMusic.sound2;
413 sounds[2] = e.action.randomMusic.sound3;
414 sounds[3] = e.action.randomMusic.sound4;
415 uint32 temp[4];
416 uint32 count = 0;
417 for (unsigned int sound : sounds)
418 {
419 if (sound)
420 {
421 temp[count] = sound;
422 ++count;
423 }
424 }
425
426 if (count == 0)
427 {
428 break;
429 }
430
431 for (WorldObject* target : targets)
432 {
433 if (IsUnit(target))
434 {
435 uint32 sound = temp[urand(0, count - 1)];
436 target->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0);
437 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: {} ({}), sound: {}, onlyself: {}, type: {}",
438 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type);
439 }
440 }
441
442 break;
443 }
445 {
446 for (WorldObject* target : targets)
447 {
448 if (IsCreature(target))
449 {
451 {
452 target->ToCreature()->SetFaction(e.action.faction.factionID);
453 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
454 target->GetEntry(), target->GetGUID().ToString(), e.action.faction.factionID);
455 }
456 else
457 {
458 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(target->ToCreature()->GetEntry()))
459 {
460 if (target->ToCreature()->GetFaction() != ci->faction)
461 {
462 target->ToCreature()->SetFaction(ci->faction);
463 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
464 target->GetEntry(), target->GetGUID().ToString(), ci->faction);
465 }
466 }
467 }
468 }
469 }
470 break;
471 }
473 {
474 for (WorldObject* target : targets)
475 {
476 if (!IsCreature(target))
477 continue;
478
480 {
481 //set model based on entry from creature_template
483 {
484 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
485 {
486 CreatureModel const* model = ObjectMgr::ChooseDisplayId(ci);
487 target->ToCreature()->SetDisplayId(model->CreatureDisplayID, model->DisplayScale);
488 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
489 target->GetEntry(), target->GetGUID().ToString(), model->CreatureDisplayID);
490 }
491 }
492 //if no param1, then use value from param2 (modelId)
493 else
494 {
495 target->ToCreature()->SetDisplayId(e.action.morphOrMount.model);
496 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
497 target->GetEntry(), target->GetGUID().ToString(), e.action.morphOrMount.model);
498 }
499 }
500 else
501 {
502 target->ToCreature()->DeMorph();
503 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} demorphs.",
504 target->GetEntry(), target->GetGUID().ToString());
505 }
506 }
507 break;
508 }
510 {
511 for (WorldObject* target : targets)
512 {
513 if (IsPlayer(target))
514 {
515 target->ToPlayer()->FailQuest(e.action.quest.quest);
516 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow {} fails quest {}",
517 target->GetGUID().ToString(), e.action.quest.quest);
518 }
519 }
520 break;
521 }
523 {
524 for (WorldObject* target : targets)
525 {
526 if (Player* player = target->ToPlayer())
527 {
528 if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.questOffer.questID))
529 {
530 if (me && e.action.questOffer.directAdd == 0)
531 {
532 if (player->CanTakeQuest(q, true))
533 {
534 if (WorldSession* session = player->GetSession())
535 {
536 PlayerMenu menu(session);
537 menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true);
538 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - offering quest {}",
539 player->GetGUID().ToString(), e.action.questOffer.questID);
540 }
541 }
542 }
543 else
544 {
545 player->AddQuestAndCheckCompletion(q, nullptr);
546 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - quest {} added",
547 player->GetGUID().ToString(), e.action.questOffer.questID);
548 }
549 }
550 }
551 }
552 break;
553 }
555 {
556 for (WorldObject* target : targets)
557 {
558 if (!IsCreature(target))
559 continue;
560
561 target->ToCreature()->SetReactState(ReactStates(e.action.react.state));
562 }
563 break;
564 }
566 {
567 std::vector<uint32> emotes;
568 std::copy_if(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(),
569 std::back_inserter(emotes), [](uint32 emote) { return emote != 0; });
570
571 for (WorldObject* target : targets)
572 {
573 if (IsUnit(target))
574 {
576 target->ToUnit()->HandleEmoteCommand(emote);
577 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow {} handle random emote {}",
578 target->GetGUID().ToString(), emote);
579 }
580 }
581 break;
582 }
584 {
585 if (!me)
586 break;
587
588 for (ThreatReference* ref : me->GetThreatMgr().GetModifiableThreatList())
589 {
590 ref->ModifyThreatByPercent(std::max<int32>(-100, int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC)));
591 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}",
592 me->GetGUID().ToString(), ref->GetVictim()->GetGUID().ToString(), int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC));
593 }
594 break;
595 }
597 {
598 if (!me)
599 break;
600
601 for (WorldObject* target : targets)
602 {
603 if (IsUnit(target))
604 {
605 me->GetThreatMgr().ModifyThreatByPercent(target->ToUnit(), std::max<int32>(-100, int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC)));
606 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature {} modify threat for unit {}, value {}",
607 me->GetGUID().ToString(), target->GetGUID().ToString(), int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC));
608 }
609 }
610 break;
611 }
613 {
614 for (WorldObject* target : targets)
615 {
616 // Special handling for vehicles
617 if (IsUnit(target))
618 if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
619 for (auto & Seat : vehicle->Seats)
620 if (Player* player = ObjectAccessor::GetPlayer(*target, Seat.second.Passenger.Guid))
621 player->AreaExploredOrEventHappens(e.action.quest.quest);
622
623 if (IsPlayer(target))
624 {
625 target->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest);
626
627 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow {} credited quest {}",
628 target->GetGUID().ToString(), e.action.quest.quest);
629 }
630 }
631 break;
632 }
634 {
635 if (targets.empty())
636 break;
637
638 Unit* caster = me;
639 // Areatrigger Cast!
640 if (e.IsAreatriggerScript())
641 caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
642
645
646 bool failedSpellCast = false, successfulSpellCast = false;
647
648 for (WorldObject* target : targets)
649 {
650 // may be nullptr
651 if (go)
652 go->CastSpell(target->ToUnit(), e.action.cast.spell);
653
654 if (!IsUnit(target))
655 continue;
656
657 if (caster && caster != me) // Areatrigger cast
658 {
659 caster->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
660 }
661 else if (me)
662 {
663 // If target has the aura, skip
664 if ((e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) && target->ToUnit()->HasAura(e.action.cast.spell))
665 continue;
666
667 // If the threatlist is a singleton, cancel
669 if (me->GetThreatMgr().GetThreatListSize() <= 1)
670 break;
671
672 // If target does not use mana, skip
673 if ((e.action.cast.castFlags & SMARTCAST_TARGET_POWER_MANA) && !target->ToUnit()->GetPower(POWER_MANA))
674 continue;
675
676 // Interrupts current spellcast
679
680 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
681 float distanceToTarget = me->GetDistance(target->ToUnit());
682 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
683 float spellMinRange = me->GetSpellMinRangeForTarget(target->ToUnit(), spellInfo);
684 float meleeRange = me->GetMeleeRange(target->ToUnit());
685
686 bool isWithinLOSInMap = me->IsWithinLOSInMap(target->ToUnit(), VMAP::ModelIgnoreFlags::M2);
687 bool isWithinMeleeRange = distanceToTarget <= meleeRange;
688 bool isRangedAttack = spellMaxRange > NOMINAL_MELEE_RANGE;
689 bool isTargetRooted = target->ToUnit()->HasUnitState(UNIT_STATE_ROOT);
690 // To prevent running back and forth when OOM, we must have more than 10% mana.
691 bool canCastSpell = me->GetPowerPct(POWER_MANA) > 10.0f && spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()) < (int32)me->GetPower(POWER_MANA) && !me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
692 bool isSpellIgnoreLOS = spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT);
693
694 // If target is rooted we move out of melee range before casting, but not further than spell max range.
695 if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle())
696 {
697 failedSpellCast = true; // Mark spellcast as failed so we can retry it later
698
699 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
700 continue;
701
702 float minDistance = std::max(meleeRange, spellMinRange) - distanceToTarget + NOMINAL_MELEE_RANGE;
703 CAST_AI(SmartAI, me->AI())->DistanceYourself(std::min(minDistance, spellMaxRange));
704 continue;
705 }
706
707 if (distanceToTarget > spellMaxRange && isWithinLOSInMap)
708 {
709 failedSpellCast = true;
710
711 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
712 continue;
713
715 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
716
717 continue;
718 }
719 else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS))
720 {
721 failedSpellCast = true;
722
723 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
724 continue;
725
726 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, 0.f);
728 CAST_AI(SmartAI, me->AI())->SetCombatMovement(true, true);
729 continue;
730 }
731
732 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
734 {
736 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
737 else
738 triggerFlags = TRIGGERED_FULL_MASK;
739 }
740
741 SpellCastResult result = me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
742 bool spellCastFailed = (result != SPELL_CAST_OK && result != SPELL_FAILED_SPELL_IN_PROGRESS);
743
745 {
746 if (result == SPELL_FAILED_OUT_OF_RANGE)
747 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
748 else if (result != SPELL_CAST_OK)
749 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(false, 0.f);
750 }
751
752 if (spellCastFailed)
753 failedSpellCast = true;
754 else
755 successfulSpellCast = true;
756
757 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
758 me->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
759 }
760 }
761
762 // If there is at least 1 failed cast and no successful casts at all, retry again on next loop
763 if (failedSpellCast && !successfulSpellCast)
764 {
765 RetryLater(e, true);
766 // Don't execute linked events
767 return;
768 }
769
770 break;
771 }
773 {
774 if (targets.empty())
775 break;
776
779
780 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
782 {
784 {
785 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
786 }
787 else
788 {
789 triggerFlags = TRIGGERED_FULL_MASK;
790 }
791 }
792
793 for (WorldObject* target : targets)
794 {
795 Unit* uTarget = target->ToUnit();
796 if (!uTarget)
797 continue;
798
800 {
802 {
803 uTarget->InterruptNonMeleeSpells(false);
804 }
805
806 uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
807 }
808 }
809 break;
810 }
812 {
813 // Can be used for area trigger cast
814 WorldObject* tempLastInvoker = GetLastInvoker(unit);
815 if (!tempLastInvoker)
816 break;
817
818 if (targets.empty())
819 break;
820
823
824 for (WorldObject* target : targets)
825 {
826 if (!IsUnit(target))
827 continue;
828
829 if (!IsUnit(tempLastInvoker))
830 continue;
831
832 if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
833 {
835 {
836 tempLastInvoker->ToUnit()->InterruptNonMeleeSpells(false);
837 }
838
839 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
841 {
843 {
844 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
845 }
846 else
847 {
848 triggerFlags = TRIGGERED_FULL_MASK;
849 }
850 }
851
852 tempLastInvoker->ToUnit()->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
853 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
854 tempLastInvoker->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
855 }
856 else
857 {
858 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
859 e.action.cast.spell, target->GetGUID().ToString());
860 }
861 }
862 break;
863 }
865 {
866 for (WorldObject* target : targets)
867 {
868 if (IsUnit(target))
869 {
870 target->ToUnit()->AddAura(e.action.cast.spell, target->ToUnit());
871 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura {} to unit {}",
872 e.action.cast.spell, target->GetGUID().ToString());
873 }
874 }
875 break;
876 }
878 {
879 for (WorldObject* target : targets)
880 {
881 if (IsGameObject(target))
882 {
883 GameObject* go = target->ToGameObject();
884
885 // Activate
887 {
889 }
890
892 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject {} activated", go->GetGUID().ToString());
893 }
894 }
895
896 break;
897 }
899 {
900 for (WorldObject* target : targets)
901 {
902 if (IsGameObject(target))
903 {
904 target->ToGameObject()->ResetDoorOrButton();
905 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject {} (entry: {}) reset",
906 target->GetGUID().ToString(), target->GetEntry());
907 }
908 }
909 break;
910 }
912 {
913 for (WorldObject* target : targets)
914 {
915 if (IsUnit(target))
916 {
917 target->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
918 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit {} set emotestate to {}",
919 target->GetGUID().ToString(), e.action.emote.emote);
920 }
921 }
922 break;
923 }
925 {
926 for (WorldObject* target : targets)
927 {
928 if (IsUnit(target))
929 {
930 if (!e.action.unitFlag.type)
931 {
932 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
933 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS",
934 target->GetGUID().ToString(), e.action.unitFlag.flag);
935 }
936 else
937 {
938 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
939 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS_2",
940 target->GetGUID().ToString(), e.action.unitFlag.flag);
941 }
942 }
943 }
944 break;
945 }
947 {
948 for (WorldObject* target : targets)
949 {
950 if (IsUnit(target))
951 {
952 if (!e.action.unitFlag.type)
953 {
954 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
955 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS",
956 target->GetGUID().ToString(), e.action.unitFlag.flag);
957 }
958 else
959 {
960 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
961 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS_2",
962 target->GetGUID().ToString(), e.action.unitFlag.flag);
963 }
964 }
965 }
966 break;
967 }
969 {
970 if (!IsSmart())
971 break;
972
973 CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack);
974 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
976 break;
977 }
979 {
980 if (!IsSmart())
981 break;
982
983 bool move = e.action.combatMove.move;
984 CAST_AI(SmartAI, me->AI())->SetCombatMovement(move, true);
985 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature {} bool on = {}",
987 break;
988 }
990 {
991 if (!GetBaseObject())
992 break;
993
995 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature {} set event phase {}",
997 break;
998 }
1000 {
1001 if (!GetBaseObject())
1002 break;
1003
1006 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature {} inc event phase by {}, "
1007 "decrease by {}", GetBaseObject()->GetGUID().ToString(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
1008 break;
1009 }
1010 case SMART_ACTION_EVADE:
1011 {
1012 if (!GetBaseObject())
1013 break;
1014
1015 for (WorldObject* target : targets)
1016 if (IsCreature(target))
1017 if (target->ToCreature()->IsAIEnabled)
1018 target->ToCreature()->AI()->EnterEvadeMode();
1019
1020 break;
1021 }
1023 {
1024 // Xinef: do not allow to flee without control (stun, fear etc)
1026 break;
1027
1029 if (e.action.flee.withEmote)
1030 {
1032 sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
1033 }
1034 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature {} DoFleeToGetAssistance", me->GetGUID().ToString());
1035 break;
1036 }
1038 {
1039 if (!me)
1040 break;
1041
1042 // Suppress evade during script-initiated combat stop so
1043 // JustExitedCombat does not trigger EnterEvadeMode.
1044 if (SmartAI* sai = CAST_AI(SmartAI, me->AI()))
1045 sai->SetSuppressEvade(true);
1046
1047 me->CombatStop(true);
1048
1049 if (SmartAI* sai = CAST_AI(SmartAI, me->AI()))
1050 sai->SetSuppressEvade(false);
1051
1052 break;
1053 }
1055 {
1056 for (WorldObject* target : targets)
1057 {
1058 if (!IsUnit(target))
1059 continue;
1060
1061 Unit* unitTarget = target->ToUnit();
1062 // If invoker was pet or charm
1063 Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself();
1064 if (player && GetBaseObject())
1065 {
1066 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1067 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {}, group credit for quest {}",
1068 player->GetGUID().ToString(), e.action.quest.quest);
1069 }
1070
1071 // Special handling for vehicles
1072 if (Vehicle* vehicle = unitTarget->GetVehicleKit())
1073 {
1074 for (auto& Seat : vehicle->Seats)
1075 {
1076 if (Player* player = ObjectAccessor::GetPlayer(*unitTarget, Seat.second.Passenger.Guid))
1077 {
1078 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1079 }
1080 }
1081 }
1082 }
1083 break;
1084 }
1086 {
1087 for (WorldObject* target : targets)
1088 {
1089 if (!IsUnit(target))
1090 continue;
1091
1092 if (e.action.removeAura.spell)
1093 {
1095 {
1096 if (Aura* aur = target->ToUnit()->GetAura(e.action.removeAura.spell))
1097 aur->ModCharges(-static_cast<int32>(e.action.removeAura.charges), AURA_REMOVE_BY_EXPIRE);
1098 }
1099 else
1100 target->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
1101 }
1102 else
1103 target->ToUnit()->RemoveAllAuras();
1104
1105 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {}, spell {}",
1106 target->GetGUID().ToString(), e.action.removeAura.spell);
1107 }
1108 break;
1109 }
1111 {
1112 if (!IsSmart())
1113 break;
1114
1116 {
1117 CAST_AI(SmartAI, me->AI())->StopFollow(false);
1118 break;
1119 }
1120
1121 for (WorldObject* target : targets)
1122 {
1123 if (IsUnit(target))
1124 {
1125 float angle = e.action.follow.angle > 6 ? (e.action.follow.angle * M_PI / 180.0f) : e.action.follow.angle;
1126 CAST_AI(SmartAI, me->AI())->SetFollow(target->ToUnit(), float(e.action.follow.dist) + 0.1f, angle, e.action.follow.credit, e.action.follow.entry, e.action.follow.creditType, e.action.follow.aliveState);
1127 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature {} following target {}",
1128 me->GetGUID().ToString(), target->GetGUID().ToString());
1129 break;
1130 }
1131 }
1132 break;
1133 }
1135 {
1136 if (!GetBaseObject())
1137 break;
1138
1139 std::vector<uint32> phases;
1140 std::copy_if(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(),
1141 std::back_inserter(phases), [](uint32 phase) { return phase != 0; });
1142
1144 SetPhase(phase);
1145 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature {} sets event phase to {}",
1146 GetBaseObject()->GetGUID().ToString(), phase);
1147 break;
1148 }
1150 {
1151 if (!GetBaseObject())
1152 break;
1153
1155 SetPhase(phase);
1156 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature {} sets event phase to {}",
1157 GetBaseObject()->GetGUID().ToString(), phase);
1158 break;
1159 }
1161 {
1162 if (trigger && IsPlayer(unit))
1163 {
1165 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player {}, Killcredit: {}",
1167 }
1168 else if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members
1169 {
1170 if (!me)
1171 break;
1172
1173 if (Player* player = me->GetLootRecipient())
1174 {
1176 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1178 }
1179 }
1180 else // Specific target type
1181 {
1182 for (WorldObject* target : targets)
1183 {
1184 if (!IsUnit(target))
1185 continue;
1186
1188 if (!player)
1189 continue;
1190
1192 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1193 target->GetGUID().ToString(), e.action.killedMonster.creature);
1194 }
1195 }
1196 break;
1197 }
1199 {
1200 WorldObject* obj = GetBaseObject();
1201 if (!obj)
1202 obj = unit;
1203
1204 if (!obj)
1205 break;
1206
1207 InstanceScript* instance = obj->GetInstanceScript();
1208 if (!instance)
1209 {
1210 LOG_ERROR("scripts.ai.sai", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1211 break;
1212 }
1213
1214 switch (e.action.setInstanceData.type)
1215 {
1216 case 0:
1217 {
1219 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: Field: {}, data: {}", e.action.setInstanceData.field, e.action.setInstanceData.data);
1220 } break;
1221 case 1:
1222 {
1224 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: SetBossState BossId: {}, State: {} ({})", e.action.setInstanceData.field, e.action.setInstanceData.data, InstanceScript::GetBossStateName(e.action.setInstanceData.data));
1225 } break;
1226 default:
1227 {
1228 break;
1229 }
1230 }
1231 break;
1232 }
1234 {
1235 WorldObject* obj = GetBaseObject();
1236 if (!obj)
1237 obj = unit;
1238
1239 if (!obj)
1240 break;
1241
1242 InstanceScript* instance = obj->GetInstanceScript();
1243 if (!instance)
1244 {
1245 LOG_ERROR("sql.sql", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1246 break;
1247 }
1248
1249 if (targets.empty())
1250 break;
1251
1252 instance->SetGuidData(e.action.setInstanceData64.field, targets.front()->GetGUID());
1253 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: {}, data: {}",
1254 e.action.setInstanceData64.field, targets.front()->GetGUID().ToString());
1255 break;
1256 }
1258 {
1259 for (WorldObject* target : targets)
1260 if (IsCreature(target))
1261 target->ToCreature()->UpdateEntry(e.action.updateTemplate.creature, target->ToCreature()->GetCreatureData(), e.action.updateTemplate.updateLevel != 0);
1262 break;
1263 }
1264 case SMART_ACTION_DIE:
1265 {
1266 if (e.action.die.milliseconds)
1267 {
1268 if (me && !me->isDead())
1269 {
1271 {
1272 // We need to check again to see if we didn't die in the process.
1273 if (me && !me->isDead())
1274 {
1275 me->KillSelf();
1276 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1277 }
1279 }
1280 }
1281 else if (me && !me->isDead())
1282 {
1283 me->KillSelf();
1284 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1285 }
1286 break;
1287 }
1289 {
1290 if (targets.empty())
1291 break;
1292
1293 if (!me->GetMap()->IsDungeon())
1294 {
1295 ObjectVector units;
1296 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
1297
1298 if (!units.empty() && GetBaseObject())
1299 for (WorldObject* unit : units)
1300 if (IsPlayer(unit) && !unit->ToPlayer()->isDead())
1301 {
1302 me->EngageWithTarget(unit->ToPlayer());
1303 }
1304 }
1305 else
1306 {
1307 for (WorldObject* target : targets)
1308 {
1309 if (IsCreature(target))
1310 {
1311 target->ToCreature()->SetInCombatWithZone();
1312 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature {}, target: {}",
1313 me->GetGUID().ToString(), target->GetGUID().ToString());
1314 }
1315 }
1316 }
1317
1318 break;
1319 }
1321 {
1322 for (WorldObject* target : targets)
1323 {
1324 if (IsCreature(target))
1325 {
1326 target->ToCreature()->CallForHelp(float(e.action.callHelp.range));
1328 {
1330 sCreatureTextMgr->SendChatPacket(target, builder, CHAT_MSG_MONSTER_EMOTE);
1331 }
1332 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature {}, target: {}",
1333 me->GetGUID().ToString(), target->GetGUID().ToString());
1334 }
1335 }
1336 break;
1337 }
1339 {
1340 if (me)
1341 {
1343 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature {}, State: {}",
1345 }
1346 break;
1347 }
1349 {
1350 for (WorldObject* target : targets)
1351 {
1353 {
1355 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_FORCE_DESPAWN has removeObjectFromWorld set. delay and forceRespawnTimer ignored.");
1356
1357 if (Creature* creature = target->ToCreature())
1358 creature->AddObjectToRemoveList();
1359 else if (GameObject* go = target->ToGameObject())
1361 }
1362 else
1363 {
1364 Milliseconds despawnDelay(e.action.forceDespawn.delay);
1365
1366 // Wait at least one world update tick before despawn, so it doesn't break linked actions.
1367 if (despawnDelay <= 0ms)
1368 despawnDelay = 1ms;
1369
1370 Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
1371 if (Creature* creature = target->ToCreature())
1372 creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1373 else if (GameObject* go = target->ToGameObject())
1374 go->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1375 }
1376 }
1377
1378 break;
1379 }
1381 {
1382 for (WorldObject* target : targets)
1383 {
1384 if (IsUnit(target))
1385 target->ToUnit()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1386 else if (IsGameObject(target))
1387 target->ToGameObject()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1388 }
1389 break;
1390 }
1392 {
1393 for (WorldObject* target : targets)
1394 {
1395 if (!IsUnit(target))
1396 continue;
1397
1399 {
1400 if (e.action.morphOrMount.creature > 0)
1401 {
1402 if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
1403 target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo)->CreatureDisplayID);
1404 }
1405 else
1406 target->ToUnit()->Mount(e.action.morphOrMount.model);
1407 }
1408 else
1409 target->ToUnit()->Dismount();
1410 }
1411 break;
1412 }
1414 {
1415 for (WorldObject* target : targets)
1416 {
1417 if (IsCreature(target))
1418 {
1419 SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI());
1420 if (!ai)
1421 continue;
1422
1423 if (e.action.invincHP.percent)
1424 ai->SetInvincibilityHpLevel(target->ToCreature()->CountPctFromMaxHealth(e.action.invincHP.percent));
1425 else
1427 }
1428 }
1429 break;
1430 }
1432 {
1433 for (WorldObject* target : targets)
1434 {
1435 if (Creature* cTarget = target->ToCreature())
1436 {
1437 CreatureAI* ai = cTarget->AI();
1438 // Make sure we check that the sender is either a creature or gameobject
1439 if (IsSmart(cTarget, true) && (me || go))
1440 {
1441 if (me)
1443 else
1444 ENSURE_AI(SmartAI, ai)->SetData(e.action.setData.field, e.action.setData.data, go);
1445 }
1446 else
1448 }
1449 else if (GameObject* oTarget = target->ToGameObject())
1450 {
1451 GameObjectAI* ai = oTarget->AI();
1452 // Make sure we check that the sender is either a creature or gameobject
1453 if (IsSmart(oTarget, true) && (me || go))
1454 {
1455 if (me)
1457 else
1459 }
1460 else
1462 }
1463 }
1464 break;
1465 }
1467 {
1468 WorldObject* invoker = me ? static_cast<WorldObject*>(me) : static_cast<WorldObject*>(go);
1469
1470 for (WorldObject* target : targets)
1471 {
1472 if (Creature* cTarget = target->ToCreature())
1473 {
1474 if (SmartAI* smartAI = CAST_AI(SmartAI, cTarget->AI()))
1475 {
1476 uint32 const newValue = smartAI->GetData(e.action.setData.field) + e.action.setData.data;
1477 smartAI->SetData(e.action.setData.field, newValue, invoker);
1478 }
1479 else
1480 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_INC_DATA is not using SmartAI, skipping");
1481 }
1482 else if (GameObject* oTarget = target->ToGameObject())
1483 {
1484 if (SmartGameObjectAI* smartGOAI = CAST_AI(SmartGameObjectAI, oTarget->AI()))
1485 {
1486 uint32 const newValue = smartGOAI->GetData(e.action.setData.field) + e.action.setData.data;
1487 smartGOAI->SetData(e.action.setData.field, newValue, invoker);
1488 }
1489 else
1490 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_INC_DATA is not using SmartGameObjectAI, skipping");
1491 }
1492 }
1493 break;
1494 }
1496 {
1497 if (!me)
1498 break;
1499
1500 float x, y, z;
1501 me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance);
1503 break;
1504 }
1506 {
1507 if (!me)
1508 break;
1509
1511 break;
1512 }
1514 {
1515 for (WorldObject* target : targets)
1516 if (IsUnit(target))
1517 target->ToUnit()->SetVisible(e.action.visibility.state);
1518
1519 break;
1520 }
1522 {
1523 for (WorldObject* target : targets)
1524 target->setActive(e.action.setActive.state);
1525 break;
1526 }
1528 {
1529 if (!me)
1530 break;
1531
1532 if (targets.empty())
1533 break;
1534
1535 // attack random target
1536 if (Unit* target = Acore::Containers::SelectRandomContainerElement(targets)->ToUnit())
1537 me->AI()->AttackStart(target);
1538 break;
1539 }
1541 {
1542 for (WorldObject* target : targets)
1543 if (Unit* unitTarget = target->ToUnit())
1544 unitTarget->AttackStop();
1545 break;
1546 }
1548 {
1550 bool preferUnit = flags.HasFlag(SmartActionSummonCreatureFlags::PreferUnit);
1551 WorldObject* summoner = preferUnit ? unit : Coalesce<WorldObject>(GetBaseObject(), unit);
1552 if (!summoner)
1553 break;
1554
1555 bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
1556
1558 {
1559 float range = (float)e.target.randomPoint.range;
1560 Position randomPoint;
1561 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1562 for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
1563 {
1564 if (e.target.randomPoint.self > 0)
1565 randomPoint = me->GetRandomPoint(me->GetPosition(), range);
1566 else
1567 randomPoint = me->GetRandomPoint(srcPos, range);
1568 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, 0, nullptr, personalSpawn))
1569 {
1570 if (unit && e.action.summonCreature.attackInvoker)
1571 summon->AI()->AttackStart(unit);
1573 summon->AI()->AttackStart(me);
1574 }
1575 }
1576 break;
1577 }
1578
1579 float x, y, z, o;
1580 for (WorldObject* target : targets)
1581 {
1582 target->GetPosition(x, y, z, o);
1583 x += e.target.x;
1584 y += e.target.y;
1585 z += e.target.z;
1586 o += e.target.o;
1587 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, nullptr, personalSpawn))
1588 {
1589 if (e.action.summonCreature.attackInvoker == 2) // pussywizard: proper attackInvoker implementation
1590 summon->AI()->AttackStart(unit);
1592 summon->AI()->AttackStart(target->ToUnit());
1594 summon->AI()->AttackStart(me);
1595 }
1596 }
1597
1599 break;
1600
1602 {
1603 if (unit && e.action.summonCreature.attackInvoker)
1604 summon->AI()->AttackStart(unit);
1606 summon->AI()->AttackStart(me);
1607 }
1608 break;
1609 }
1611 {
1612 if (!GetBaseObject())
1613 break;
1614
1615 if (!targets.empty())
1616 {
1617 float x, y, z, o;
1618 for (WorldObject* target : targets)
1619 {
1620 // xinef: allow gameobjects to summon gameobjects!
1621 //if (!IsUnit((*itr)))
1622 // continue;
1623
1624 target->GetPosition(x, y, z, o);
1625 x += e.target.x;
1626 y += e.target.y;
1627 z += e.target.z;
1628 o += e.target.o;
1631 else
1632 target->SummonGameObject(e.action.summonGO.entry, GetBaseObject()->GetPositionX(), GetBaseObject()->GetPositionY(), GetBaseObject()->GetPositionZ(), GetBaseObject()->GetOrientation(), 0, 0, 0, 0, e.action.summonGO.despawnTime);
1633 }
1634 }
1635
1637 break;
1638
1640 break;
1641 }
1643 {
1644 for (WorldObject* target : targets)
1645 {
1646 if (!IsUnit(target))
1647 continue;
1648
1649 Unit::Kill(target->ToUnit(), target->ToUnit());
1650 }
1651
1652 break;
1653 }
1655 {
1656 InstallTemplate(e);
1657 break;
1658 }
1660 {
1661 for (WorldObject* target : targets)
1662 {
1663 if (!IsPlayer(target))
1664 continue;
1665
1666 target->ToPlayer()->AddItem(e.action.item.entry, e.action.item.count);
1667 }
1668 break;
1669 }
1671 {
1672 for (WorldObject* target : targets)
1673 {
1674 if (!IsPlayer(target))
1675 continue;
1676
1677 target->ToPlayer()->DestroyItemCount(e.action.item.entry, e.action.item.count, true);
1678 }
1679 break;
1680 }
1682 {
1684 break;
1685 }
1687 {
1688 for (WorldObject* target : targets)
1689 {
1690 if (IsPlayer(target))
1691 target->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
1692 else if (IsCreature(target))
1693 target->ToCreature()->NearTeleportTo(e.target.x, e.target.y, e.target.z, e.target.o);
1694 }
1695 break;
1696 }
1698 {
1699 if (!IsSmart())
1700 break;
1701
1702 CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly);
1703 // Xinef: Set speed if any
1704 if (e.action.setFly.speed)
1705 me->SetSpeed(MOVE_RUN, float(e.action.setFly.speed / 100.0f), true);
1706
1707 // Xinef: this wil be executed only if state is different
1709 break;
1710 }
1712 {
1713 for (WorldObject* target : targets)
1714 {
1715 if (IsCreature(target))
1716 {
1717 target->ToCreature()->SetWalk(e.action.setRun.run ? false : true);
1718 }
1719 }
1720
1721 break;
1722 }
1724 {
1725 if (!IsSmart())
1726 break;
1727
1728 CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim);
1729 break;
1730 }
1732 {
1733 if (!targets.empty())
1734 {
1735 for (WorldObject* target : targets)
1736 {
1737 if (IsCreature(target))
1738 {
1739 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
1741 else
1742 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
1743 }
1744 else if (IsGameObject(target))
1745 {
1746 if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, target->ToGameObject()->AI()))
1748 else
1749 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
1750 }
1751 }
1752 }
1753 else
1755 break;
1756 }
1758 {
1759 if (!IsSmart())
1760 break;
1761
1762 ForcedMovement forcedMovement = static_cast<ForcedMovement>(e.action.wpStart.forcedMovement);
1763 uint32 entry = e.action.wpStart.pathID;
1764 bool repeat = e.action.wpStart.repeat != 0;
1765
1766 for (WorldObject* target : targets)
1767 {
1768 if (IsPlayer(target))
1769 {
1771 break;
1772 }
1773 }
1774
1776 CAST_AI(SmartAI, me->AI())->StartPath(forcedMovement, entry, repeat, unit);
1777
1778 uint32 quest = e.action.wpStart.quest;
1779 uint32 DespawnTime = e.action.wpStart.despawnTime;
1780 CAST_AI(SmartAI, me->AI())->mEscortQuestID = quest;
1781 CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
1782 break;
1783 }
1785 {
1786 if (!IsSmart())
1787 break;
1788
1789 uint32 delay = e.action.wpPause.delay;
1790 CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_ESCORT_REACHED ? false : true);
1791 break;
1792 }
1794 {
1795 if (!IsSmart())
1796 break;
1797
1798 uint32 DespawnTime = e.action.wpStop.despawnTime;
1799 uint32 quest = e.action.wpStop.quest;
1800 bool fail = e.action.wpStop.fail;
1801 CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
1802 break;
1803 }
1805 {
1806 if (!IsSmart())
1807 break;
1808
1809 CAST_AI(SmartAI, me->AI())->SetWPPauseTimer(0);
1810 break;
1811 }
1813 {
1814 if (!me)
1815 break;
1816
1817 if (e.action.orientation.random > 0)
1818 {
1819 float randomOri = frand(0.0f, 2 * M_PI);
1820 me->SetFacingTo(randomOri);
1822 me->SetOrientation(randomOri);
1823 break;
1824 }
1825
1827 {
1828 float turnOri = me->GetOrientation() + (static_cast<float>(e.action.orientation.turnAngle) * M_PI / 180.0f);
1829 me->SetFacingTo(turnOri);
1831 me->SetOrientation(turnOri);
1832 break;
1833 }
1834
1836 {
1840 }
1841 else if (e.GetTargetType() == SMART_TARGET_POSITION)
1842 {
1843 me->SetFacingTo(e.target.o);
1846 }
1847 else if (!targets.empty())
1848 {
1849 me->SetFacingToObject(*targets.begin());
1851 me->SetInFront(*targets.begin());
1852 }
1853
1854 break;
1855 }
1857 {
1858 for (WorldObject* target : targets)
1859 {
1860 if (!IsPlayer(target))
1861 continue;
1862
1863 target->ToPlayer()->SendMovieStart(e.action.movie.entry);
1864 }
1865 break;
1866 }
1868 {
1869 if (!IsSmart())
1870 break;
1871
1872 WorldObject* target = nullptr;
1873
1875
1876 switch (e.GetTargetType())
1877 {
1879 {
1880 G3D::Vector3 dest(e.target.x, e.target.y, e.target.z);
1882 if (TransportBase* trans = me->GetDirectTransport())
1883 trans->CalculatePassengerPosition(dest.x, dest.y, dest.z);
1884
1886 0.f, e.target.o, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1887
1888 break;
1889 }
1891 {
1892 if (me)
1893 {
1894 float range = (float)e.target.randomPoint.range;
1895 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1896 Position randomPoint = me->GetRandomPoint(srcPos, range);
1899 randomPoint.m_positionX,
1900 randomPoint.m_positionY,
1901 randomPoint.m_positionZ,
1903 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE
1904 );
1905
1906 }
1907
1908 break;
1909 }
1910 // Can use target floats as offset
1911 default:
1912 {
1913 // we want to move to random element
1914 if (targets.empty())
1915 return;
1916 else
1918
1919 float x, y, z;
1920 target->GetPosition(x, y, z);
1921
1923 target->GetNearPoint(me, x, y, z, target->GetCombatReach() + e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1924 else if (e.action.moveToPos.ContactDistance)
1925 target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1926
1928 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1929
1930 break;
1931 }
1932 }
1933
1934 break;
1935 }
1937 {
1938 for (WorldObject* target : targets)
1939 {
1940 if (IsCreature(target))
1941 {
1943
1944 Creature* ctarget = target->ToCreature();
1946 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1947 }
1948 }
1949
1950 break;
1951 }
1953 {
1954 for (WorldObject* target : targets)
1955 {
1956 if (IsCreature(target))
1957 target->ToCreature()->Respawn();
1958 else if (IsGameObject(target))
1959 {
1960 // do not modify respawndelay of already spawned gameobjects
1961 if (target->ToGameObject()->isSpawnedByDefault())
1962 target->ToGameObject()->Respawn();
1963 else
1965 }
1966 }
1967 break;
1968 }
1970 {
1971 for (WorldObject* target : targets)
1972 if (IsPlayer(target))
1973 target->ToPlayer()->PlayerTalkClass->SendCloseGossip();
1974 break;
1975 }
1976 case SMART_ACTION_EQUIP:
1977 {
1978 for (WorldObject* target : targets)
1979 {
1980 if (Creature* npc = target->ToCreature())
1981 {
1982 std::array<uint32, MAX_EQUIPMENT_ITEMS> slot;
1983 if (int8 equipId = static_cast<int8>(e.action.equip.entry))
1984 {
1985 EquipmentInfo const* eInfo = sObjectMgr->GetEquipmentInfo(npc->GetEntry(), equipId);
1986 if (!eInfo)
1987 {
1988 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id {} for creature {}", equipId, npc->GetEntry());
1989 break;
1990 }
1991
1992 npc->SetCurrentEquipmentId(equipId);
1993
1994 std::copy(std::begin(eInfo->ItemEntry), std::end(eInfo->ItemEntry), std::begin(slot));
1995 }
1996 else
1997 std::copy(std::begin(e.action.equip.slots), std::end(e.action.equip.slots), std::begin(slot));
1998
1999 for (uint32 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
2000 if (!e.action.equip.mask || (e.action.equip.mask & (1 << i)))
2001 npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, slot[i]);
2002 }
2003 }
2004 break;
2005 }
2007 {
2008 SmartEvent ne = SmartEvent();
2011 if (!ne.event_chance) ne.event_chance = 100;
2012
2017
2018 ne.event_flags = 0;
2021
2022 SmartAction ac = SmartAction();
2025
2027 ev.event = ne;
2028 ev.event_id = e.action.timeEvent.id;
2029 ev.target = e.target;
2030 ev.action = ac;
2031 InitTimer(ev);
2032 mStoredEvents.push_back(ev);
2033 break;
2034 }
2037
2038 // xinef: remove this event if not repeatable
2040 mRemIDs.push_back(e.action.timeEvent.id);
2041 break;
2043 mRemIDs.push_back(e.action.timeEvent.id);
2044 break;
2046 {
2047 for (WorldObject* target : targets)
2048 {
2049 if (IsCreature(target))
2050 {
2051 if (!meOrigGUID)
2053 if (!goOrigGUID)
2055 go = nullptr;
2056 me = target->ToCreature();
2057 break;
2058 }
2059 else if (IsGameObject(target))
2060 {
2061 if (!meOrigGUID)
2063 if (!goOrigGUID)
2065 go = target->ToGameObject();
2066 me = nullptr;
2067 break;
2068 }
2069 }
2070
2071 break;
2072 }
2075 break;
2077 OnReset();
2078 break;
2080 {
2081 if (!IsSmart())
2082 break;
2083
2084 float attackDistance = float(e.action.setRangedMovement.distance);
2085 float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI);
2086
2087 for (WorldObject* target : targets)
2088 if (Creature* creature = target->ToCreature())
2089 if (IsSmart(creature) && creature->GetVictim())
2090 if (!creature->HasUnitState(UNIT_STATE_NO_COMBAT_MOVEMENT))
2091 creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, attackAngle);
2092
2093 break;
2094 }
2096 {
2098 {
2099 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2100 break;
2101 }
2102
2103 for (WorldObject* target : targets)
2104 {
2105 if (Creature* creature = target->ToCreature())
2106 {
2107 if (IsSmart(creature))
2108 CAST_AI(SmartAI, creature->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
2109 }
2110 else if (GameObject* go = target->ToGameObject())
2111 {
2112 if (IsSmart(go))
2114 }
2115 }
2116 break;
2117 }
2119 {
2120 for (WorldObject* target : targets)
2121 if (IsCreature(target))
2122 target->ToUnit()->ReplaceAllNpcFlags(NPCFlags(e.action.unitFlag.flag));
2123 break;
2124 }
2126 {
2127 for (WorldObject* target : targets)
2128 if (IsCreature(target))
2129 target->ToUnit()->SetNpcFlag(NPCFlags(e.action.unitFlag.flag));
2130 break;
2131 }
2133 {
2134 for (WorldObject* target : targets)
2135 if (IsCreature(target))
2136 target->ToUnit()->RemoveNpcFlag(NPCFlags(e.action.unitFlag.flag));
2137 break;
2138 }
2140 {
2141 if (targets.empty())
2142 break;
2143
2144 ObjectVector casters;
2146
2147 for (WorldObject* caster : casters)
2148 {
2149 if (!IsUnit(caster))
2150 continue;
2151
2152 Unit* casterUnit = caster->ToUnit();
2153
2154 bool interruptedSpell = false;
2155
2156 for (WorldObject* target : targets)
2157 {
2158 if (!IsUnit(target))
2159 continue;
2160
2162 {
2163 if (!interruptedSpell && e.action.crossCast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
2164 {
2165 casterUnit->InterruptNonMeleeSpells(false);
2166 interruptedSpell = true;
2167 }
2168
2169 casterUnit->CastSpell(target->ToUnit(), e.action.crossCast.spell, (e.action.crossCast.flags & SMARTCAST_TRIGGERED) != 0);
2170 }
2171 else
2172 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target ({}) already has the aura", e.action.crossCast.spell, target->GetGUID().ToString());
2173 }
2174 }
2175 break;
2176 }
2178 {
2179 std::vector<uint32> actionLists;
2181 std::back_inserter(actionLists), [](uint32 actionList) { return actionList != 0; });
2182
2185 {
2186 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2187 break;
2188 }
2189
2190 for (WorldObject* target : targets)
2191 {
2192 if (Creature* creature = target->ToCreature())
2193 {
2194 if (IsSmart(creature))
2195 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2196 }
2197 else if (GameObject* go = target->ToGameObject())
2198 {
2199 if (IsSmart(go))
2200 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2201 }
2202 }
2203 break;
2204 }
2206 {
2209 {
2210 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2211 break;
2212 }
2213
2214 for (WorldObject* target : targets)
2215 {
2216 if (Creature* creature = target->ToCreature())
2217 {
2218 if (IsSmart(creature))
2219 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2220 }
2221 else if (GameObject* go = target->ToGameObject())
2222 {
2223 if (IsSmart(go))
2224 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2225 }
2226 }
2227 break;
2228 }
2230 {
2231 for (WorldObject* target : targets)
2232 if (IsPlayer(target))
2233 target->ToPlayer()->ActivateTaxiPathTo(e.action.taxi.id);
2234 break;
2235 }
2237 {
2238 bool foundTarget = false;
2239
2240 for (WorldObject* target : targets)
2241 {
2242 if (IsCreature((target)))
2243 {
2244 foundTarget = true;
2245
2248 else
2249 target->ToCreature()->GetMotionMaster()->MoveIdle();
2250 }
2251 }
2252
2253 if (!foundTarget && me && IsCreature(me) && me->IsAlive())
2254 {
2257 else
2259 }
2260 break;
2261 }
2263 {
2264 for (WorldObject* target : targets)
2265 if (IsUnit(target))
2266 target->ToUnit()->SetByteFlag(UNIT_FIELD_BYTES_1, e.action.setunitByte.type, e.action.setunitByte.byte1);
2267 break;
2268 }
2270 {
2271 for (WorldObject* target : targets)
2272 if (IsUnit(target))
2273 target->ToUnit()->RemoveByteFlag(UNIT_FIELD_BYTES_1, e.action.delunitByte.type, e.action.delunitByte.byte1);
2274 break;
2275 }
2277 {
2278 for (WorldObject* target : targets)
2279 if (IsUnit(target))
2280 target->ToUnit()->InterruptNonMeleeSpells(e.action.interruptSpellCasting.withDelayed != 0, e.action.interruptSpellCasting.spell_id, e.action.interruptSpellCasting.withInstant != 0);
2281 break;
2282 }
2284 {
2285 for (WorldObject* target : targets)
2286 if (IsGameObject(target))
2287 target->ToGameObject()->SendCustomAnim(e.action.sendGoCustomAnim.anim);
2288 break;
2289 }
2291 {
2292 for (WorldObject* target : targets)
2293 if (IsUnit(target))
2294 target->ToUnit()->SetUInt32Value(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2295 break;
2296 }
2298 {
2299 for (WorldObject* target : targets)
2300 if (IsUnit(target))
2301 target->ToUnit()->SetFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2302 break;
2303 }
2305 {
2306 for (WorldObject* target : targets)
2307 if (IsUnit(target))
2308 target->ToUnit()->RemoveFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2309 break;
2310 }
2312 {
2314 {
2315 if (me)
2316 {
2317 float range = (float)e.target.randomPoint.range;
2318 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
2319 Position randomPoint = me->GetRandomPoint(srcPos, range);
2320 me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2321 }
2322
2323 break;
2324 }
2325
2326 if (targets.empty())
2327 break;
2328
2329 // xinef: my implementation
2330 if (e.action.jump.selfJump)
2331 {
2333 if (me)
2334 me->GetMotionMaster()->MoveJump(target->GetPositionX() + e.target.x, target->GetPositionY() + e.target.y, target->GetPositionZ() + e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2335 }
2336 else
2337 {
2338 for (WorldObject* target : targets)
2339 if (WorldObject* obj = (target))
2340 {
2341 if (Creature* creature = obj->ToCreature())
2342 creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2343 }
2344 }
2345
2346 break;
2347 }
2349 {
2350 for (WorldObject* target : targets)
2351 if (IsGameObject(target))
2352 target->ToGameObject()->SetLootState((LootState)e.action.setGoLootState.state);
2353 break;
2354 }
2356 {
2357 for (WorldObject* target : targets)
2358 if (IsGameObject(target))
2359 target->ToGameObject()->SetGoState((GOState)e.action.goState.state);
2360 break;
2361 }
2363 {
2364 WorldObject* ref = GetBaseObject();
2365
2366 if (!ref)
2367 ref = unit;
2368
2369 if (!ref)
2370 break;
2371
2372 ObjectVector const* storedTargets = GetStoredTargetVector(e.action.sendTargetToTarget.id, *ref);
2373 if (!storedTargets)
2374 break;
2375
2376 for (WorldObject* target : targets)
2377 {
2378 if (IsCreature(target))
2379 {
2380 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
2381 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2382 else
2383 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
2384 }
2385 else if (IsGameObject(target))
2386 {
2388 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2389 else
2390 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
2391 }
2392 }
2393 break;
2394 }
2396 {
2397 if (!GetBaseObject())
2398 break;
2399
2400 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId {}, gossipNpcTextId {}",
2402
2403 for (WorldObject* target : targets)
2404 if (Player* player = target->ToPlayer())
2405 {
2408 else
2409 ClearGossipMenuFor(player);
2410
2412 }
2413
2414 break;
2415 }
2417 {
2418 if (!targets.empty())
2419 {
2420 float x, y, z, o;
2421 for (WorldObject* target : targets)
2422 if (IsCreature(target))
2423 {
2425 {
2426 target->ToCreature()->GetRespawnPosition(x, y, z, &o);
2427 target->ToCreature()->SetHomePosition(x, y, z, o);
2428 }
2429 else
2430 target->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
2431 }
2432 }
2433 else if (me && e.GetTargetType() == SMART_TARGET_POSITION)
2434 {
2436 {
2437 float x, y, z, o;
2438 me->GetRespawnPosition(x, y, z, &o);
2439 me->SetHomePosition(x, y, z, o);
2440 }
2441 else
2443 }
2444 break;
2445 }
2447 {
2448 for (WorldObject* target : targets)
2449 if (IsCreature(target))
2450 target->ToCreature()->SetRegeneratingHealth(e.action.setHealthRegen.regenHealth);
2451
2452 break;
2453 }
2455 {
2456 for (WorldObject* target : targets)
2457 if (IsCreature(target))
2458 target->ToCreature()->SetControlled(e.action.setRoot.root != 0, UNIT_STATE_ROOT);
2459 break;
2460 }
2462 {
2463 for (WorldObject* target : targets)
2464 if (IsGameObject(target))
2465 target->ToGameObject()->SetUInt32Value(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2466 break;
2467 }
2469 {
2470 for (WorldObject* target : targets)
2471 if (IsGameObject(target))
2472 target->ToGameObject()->SetFlag(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2473 break;
2474 }
2476 {
2477 for (WorldObject* target : targets)
2478 if (IsGameObject(target))
2479 target->ToGameObject()->RemoveFlag(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2480 break;
2481 }
2483 {
2484 std::list<TempSummon*> summonList;
2486
2487 for (std::list<TempSummon*>::const_iterator itr = summonList.begin(); itr != summonList.end(); ++itr)
2488 {
2489 if (unit && e.action.creatureGroup.attackInvoker)
2490 (*itr)->AI()->AttackStart(unit);
2492 (*itr)->AI()->AttackStart(me);
2493 }
2494
2495 break;
2496 }
2498 {
2499 for (WorldObject* target : targets)
2500 if (IsUnit(target))
2501 target->ToUnit()->SetPower(Powers(e.action.power.powerType), e.action.power.newPower);
2502 break;
2503 }
2505 {
2506 for (WorldObject* target : targets)
2507 if (IsUnit(target))
2508 target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) + e.action.power.newPower);
2509 break;
2510 }
2512 {
2513 for (WorldObject* target : targets)
2514 if (IsUnit(target))
2515 target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) - e.action.power.newPower);
2516 break;
2517 }
2519 {
2520 uint32 eventId = e.action.gameEventStop.id;
2521 if (!sGameEventMgr->IsActiveEvent(eventId))
2522 {
2523 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: {})", eventId);
2524 break;
2525 }
2526 sGameEventMgr->StopEvent(eventId, true);
2527 break;
2528 }
2530 {
2531 uint32 eventId = e.action.gameEventStart.id;
2532 if (sGameEventMgr->IsActiveEvent(eventId))
2533 {
2534 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: {})", eventId);
2535 break;
2536 }
2537 sGameEventMgr->StartEvent(eventId, true);
2538 break;
2539 }
2541 {
2542 PathSource pathSource = static_cast<PathSource>(e.action.startClosestWaypoint.pathSource);
2543
2544 if (pathSource != PathSource::WAYPOINT_MGR && pathSource != PathSource::SMART_WAYPOINT_MGR)
2545 {
2546 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_START_CLOSEST_WAYPOINT: Invalid PathSource {} for entryOrGuid {} source_type {} event_id {} link {}",
2547 static_cast<uint32>(pathSource), e.entryOrGuid, e.source_type, e.event_id, e.link);
2548 break;
2549 }
2550
2551 float distanceToClosest = std::numeric_limits<float>::max();
2552 uint32 closestWpId = 0;
2553
2554 for (WorldObject* target : targets)
2555 {
2556 if (Creature* creature = target->ToCreature())
2557 {
2558 if (IsSmart(creature))
2559 {
2560 for (uint32 pathId = e.action.startClosestWaypoint.pathId1; pathId <= e.action.startClosestWaypoint.pathId2; ++pathId)
2561 {
2562 WaypointPath const* path = nullptr;
2563
2564 switch (pathSource)
2565 {
2567 path = sSmartWaypointMgr->GetPath(pathId);
2568 break;
2570 path = sWaypointMgr->GetPath(pathId);
2571 break;
2572 }
2573
2574 if (!path || path->Nodes.empty())
2575 continue;
2576
2577 {
2578 WaypointNode const& wpData = path->Nodes[0];
2579 float distToThisPath = creature->GetExactDistSq(wpData.X, wpData.Y, wpData.Z);
2580
2581 if (distToThisPath < distanceToClosest)
2582 {
2583 distanceToClosest = distToThisPath;
2584 closestWpId = pathId;
2585 }
2586 }
2587 }
2588
2589 if (closestWpId)
2590 {
2591 bool repeat = e.action.startClosestWaypoint.repeat;
2593
2594 CAST_AI(SmartAI, creature->AI())->StartPath(forcedMovement, closestWpId, repeat, nullptr, pathSource);
2595 }
2596 }
2597 }
2598 }
2599 break;
2600 }
2602 {
2603 for (WorldObject* target : targets)
2604 if (IsUnit(target))
2605 target->ToUnit()->ExitVehicle();
2606
2607 break;
2608 }
2610 {
2611 for (WorldObject* target : targets)
2612 if (IsUnit(target))
2613 {
2615 target->ToUnit()->SendMovementFlagUpdate();
2616 }
2617
2618 break;
2619 }
2621 {
2622 for (WorldObject* target : targets)
2623 if (IsCreature(target))
2624 target->ToCreature()->m_CombatDistance = e.action.combatDistance.dist;
2625
2626 break;
2627 }
2629 {
2630 for (WorldObject* const target : targets)
2631 if (IsCreature(target))
2632 target->ToCreature()->m_SightDistance = e.action.sightDistance.dist;
2633 break;
2634 }
2635 case SMART_ACTION_FLEE:
2636 {
2637 for (WorldObject* const target : targets)
2638 if (IsCreature(target))
2639 target->ToCreature()->GetMotionMaster()->MoveFleeing(me, e.action.flee.withEmote);
2640 break;
2641 }
2643 {
2644 if (!me->CanHaveThreatList())
2645 break;
2646 for (WorldObject* const target : targets)
2647 if (IsUnit(target))
2648 me->GetThreatMgr().AddThreat(target->ToUnit(), float(e.action.threat.threatINC) - float(e.action.threat.threatDEC), nullptr, true, true);
2649 break;
2650 }
2652 {
2653 for (WorldObject* const target : targets)
2654 if (IsCreature(target))
2655 target->ToCreature()->LoadEquipment(e.action.loadEquipment.id, e.action.loadEquipment.force != 0);
2656 break;
2657 }
2659 {
2662 break;
2663 }
2665 {
2666 for (WorldObject* const target : targets)
2667 if (IsUnit(target))
2668 target->ToUnit()->Dismount();
2669 break;
2670 }
2672 {
2673 for (WorldObject* target : targets)
2674 if (IsUnit(target))
2675 target->ToUnit()->SetHover(e.action.setHover.state);
2676 break;
2677 }
2679 {
2680 for (WorldObject* target : targets)
2681 if (IsUnit(target))
2682 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, true);
2683
2684 break;
2685 }
2687 {
2688 for (WorldObject* target : targets)
2689 if (IsUnit(target))
2690 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, false);
2691 break;
2692 }
2693 case SMART_ACTION_FALL:
2694 {
2695 for (WorldObject* target : targets)
2696 if (IsUnit(target))
2697 target->ToUnit()->GetMotionMaster()->MoveFall();
2698
2699 break;
2700 }
2702 {
2704 break;
2705 }
2707 {
2708 for (WorldObject* const target : targets)
2709 if (IsUnit(target))
2710 target->ToUnit()->RemoveAllGameObjects();
2711 break;
2712 }
2714 {
2715 for (WorldObject* const target : targets)
2716 {
2717 if (IsUnit(target))
2718 {
2720 target->ToUnit()->StopMoving();
2722 target->ToUnit()->GetMotionMaster()->MovementExpired();
2723 }
2724 }
2725 break;
2726 }
2728 {
2729 for (WorldObject* target : targets)
2730 if (IsUnit(target))
2731 target->ToUnit()->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
2732
2733 break;
2734 }
2736 {
2737 for (WorldObject* target : targets)
2738 if (IsUnit(target))
2739 if (Player* player = target->ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself())
2740 {
2742 break;
2743 }
2744
2745 break;
2746 }
2748 {
2749 if (me && me->FindMap())
2750 me->FindMap()->LoadGrid(e.target.x, e.target.y);
2751 else if (go && go->FindMap())
2752 go->FindMap()->LoadGrid(e.target.x, e.target.y);
2753 break;
2754 }
2756 {
2757 std::string text = sObjectMgr->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE);
2758
2759 if (!targets.empty())
2760 for (WorldObject* target : targets)
2761 if (IsPlayer(target))
2762 !e.action.playerTalk.flag ? target->ToPlayer()->Say(text, LANG_UNIVERSAL) : target->ToPlayer()->Yell(text, LANG_UNIVERSAL);
2763
2764 break;
2765 }
2767 {
2768 if (!me)
2769 break;
2770
2771 for (WorldObject* target : targets)
2772 {
2773 if (IsUnit(target))
2774 {
2776 {
2778 }
2779
2781 {
2782 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.castCustom.spell);
2783 CustomSpellValues values;
2784 if (e.action.castCustom.bp1)
2786 if (e.action.castCustom.bp2)
2788 if (e.action.castCustom.bp3)
2791
2792 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
2794 {
2795 // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed unless target is outside spell range, out of mana, or LOS.
2796 if (result == SPELL_FAILED_OUT_OF_RANGE || result == SPELL_CAST_OK)
2797 // if we are just out of range, we only chase until we are back in spell range.
2798 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
2799 else // move into melee on any other fail
2800 // if spell fail for any other reason, we chase to melee range, or stay where we are if spellcast was successful.
2801 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(false, 0.f);
2802 }
2803 }
2804 }
2805 }
2806 break;
2807 }
2809 {
2810 if (!me)
2811 break;
2812
2813 if (targets.empty())
2814 break;
2815
2817
2818 float a = static_cast<float>(e.action.summonVortex.a);
2819 float k = static_cast<float>(e.action.summonVortex.k) / 1000.0f;
2820 float r_max = static_cast<float>(e.action.summonVortex.r_max);
2821 float delta_phi = M_PI * static_cast<float>(e.action.summonVortex.phi_delta) / 180.0f;
2822
2823 // r(phi) = a * e ^ (k * phi)
2824 // r(phi + delta_phi) = a * e ^ (k * (phi + delta_phi))
2825 // r(phi + delta_phi) = a * e ^ (k * phi) * e ^ (k * delta_phi)
2826 // r(phi + delta_phi) = r(phi) * e ^ (k * delta_phi)
2827 float factor = std::exp(k * delta_phi);
2828
2829 // r(0) = a * e ^ (k * 0) = a * e ^ 0 = a * 1 = a
2830 float summonRadius = a;
2831
2832 for (WorldObject* target : targets)
2833 {
2834 // Offset by orientation, should not count into radius calculation,
2835 // but is needed for vortex direction (polar coordinates)
2836 float phi = target->GetOrientation();
2837
2838 do
2839 {
2840 Position summonPosition(*target);
2841 summonPosition.RelocatePolarOffset(phi, summonRadius);
2842
2844
2845 phi += delta_phi;
2846 summonRadius *= factor;
2847 } while (summonRadius <= r_max);
2848 }
2849
2850 break;
2851 }
2853 {
2854 if (!me)
2855 break;
2856
2858
2859 float distInARow = static_cast<float>(e.action.coneSummon.distanceBetweenSummons);
2860 float coneAngle = static_cast<float>(e.action.coneSummon.coneAngle) * M_PI / 180.0f;
2861
2862 for (uint32 radius = 0; radius <= e.action.coneSummon.coneLength; radius += e.action.coneSummon.distanceBetweenRings)
2863 {
2864 float deltaAngle = 0.0f;
2865 if (radius > 0)
2866 deltaAngle = distInARow / radius;
2867
2868 uint32 count = 1;
2869 if (deltaAngle > 0)
2870 count += coneAngle / deltaAngle;
2871
2872 float currentAngle = -static_cast<float>(count) * deltaAngle / 2.0f;
2873
2875 currentAngle += G3D::fuzzyGt(e.target.o, 0.0f) ? (e.target.o - me->GetOrientation()) : 0.0f;
2876 else if (!targets.empty())
2877 {
2878 currentAngle += (me->GetAngle(targets.front()) - me->GetOrientation());
2879 }
2880
2881 for (uint32 index = 0; index < count; ++index)
2882 {
2883 Position spawnPosition(*me);
2884 spawnPosition.RelocatePolarOffset(currentAngle, radius);
2885 currentAngle += deltaAngle;
2886
2888 }
2889 }
2890
2891 break;
2892 }
2894 {
2895 for (WorldObject* target : targets)
2896 {
2897 if (Player* playerTarget = target->ToPlayer())
2898 {
2899 playerTarget->RemoveArenaSpellCooldowns();
2900 playerTarget->RemoveAurasDueToSpell(57724); // Spell Shaman Debuff - Sated (Heroism)
2901 playerTarget->RemoveAurasDueToSpell(57723); // Spell Shaman Debuff - Exhaustion (Bloodlust)
2902 playerTarget->RemoveAurasDueToSpell(2825); // Bloodlust
2903 playerTarget->RemoveAurasDueToSpell(32182); // Heroism
2904 }
2905 }
2906
2907 break;
2908 }
2910 {
2913 {
2914 if (targets.empty())
2915 break;
2916
2917 for (WorldObject* objTarget : targets)
2918 {
2919 if (Creature const* unitTarget = objTarget->ToCreature())
2920 {
2921 if (unitTarget->IsAIEnabled)
2922 {
2923 unitTarget->AI()->DoAction(actionId);
2924 }
2925 }
2926 else if (GameObject const* gobjTarget = objTarget->ToGameObject())
2927 {
2928 gobjTarget->AI()->DoAction(actionId);
2929 }
2930 }
2931
2932 }
2933 else
2934 {
2935 InstanceScript* instanceScript = nullptr;
2936 if (WorldObject* baseObj = GetBaseObject())
2937 {
2938 instanceScript = baseObj->GetInstanceScript();
2939 }
2940 // Action is triggered by AreaTrigger
2941 else if (trigger && IsPlayer(unit))
2942 {
2943 instanceScript = unit->GetInstanceScript();
2944 }
2945
2946 if (instanceScript)
2947 {
2948 instanceScript->DoAction(actionId);
2949 }
2950 }
2951 break;
2952 }
2954 {
2955 if (!IsSmart())
2956 break;
2957
2958 CAST_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0);
2959 break;
2960 }
2962 {
2963 for (WorldObject* const target : targets)
2964 {
2965 if (IsCreature(target))
2967 }
2968 break;
2969 }
2971 {
2972 for (WorldObject* target : targets)
2973 if (Unit* targetUnit = target->ToUnit())
2974 targetUnit->SetHealth(targetUnit->CountPctFromMaxHealth(e.action.setHealthPct.percent));
2975 break;
2976 }
2978 {
2979 uint32 speedInteger = e.action.movementSpeed.speedInteger;
2980 uint32 speedFraction = e.action.movementSpeed.speedFraction;
2981 float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(float(speedFraction ? speedFraction : 1)) + 1));
2982
2983 for (WorldObject* target : targets)
2984 if (IsCreature(target))
2985 target->ToCreature()->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
2986
2987 break;
2988 }
2990 {
2991 for (WorldObject* target : targets)
2992 {
2993 if (!IsPlayer(target))
2994 continue;
2995
2997 }
2998 break;
2999 }
3001 {
3002 WorldObject* obj = GetBaseObject();
3003 if (!obj)
3004 break;
3005
3008 e.action.groupSpawn.force != 0);
3009 break;
3010 }
3012 {
3013 WorldObject* obj = GetBaseObject();
3014 if (!obj)
3015 break;
3016
3018 e.action.groupSpawn.ignoreRespawn != 0); // reuse ignoreRespawn as deleteRespawnTimes
3019 break;
3020 }
3022 {
3023 for (WorldObject* target : targets)
3024 {
3025 ObjectGuid guidToSend = me ? me->GetGUID() : go->GetGUID();
3026
3028 {
3029 if (WorldObject* invoker = GetLastInvoker())
3030 {
3031 guidToSend = invoker->GetGUID();
3032 }
3033 }
3034
3035 if (Creature* creature = target->ToCreature())
3036 {
3037 creature->AI()->SetGUID(guidToSend, e.action.setGuid.index);
3038 }
3039 else if (GameObject* object = target->ToGameObject())
3040 {
3041 object->AI()->SetGUID(guidToSend, e.action.setGuid.index);
3042 }
3043 }
3044 break;
3045 }
3047 {
3048 // Enable Scripted Spawns
3049 switch (e.action.scriptSpawn.state)
3050 {
3051 case 0: // Disable Respawn
3052 {
3053 for (WorldObject* target : targets)
3054 {
3055 if (Creature* c = target->ToCreature())
3056 {
3057 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3059 c->DespawnOrUnsummon();
3060 }
3061 }
3062 break;
3063 }
3064 case 1: // Respawn Once
3065 {
3066 for (WorldObject* target : targets)
3067 {
3068 if (Creature* c = target->ToCreature())
3069 {
3070 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3071 c->Respawn(true);
3072 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3073 }
3074 }
3075 break;
3076 }
3077 case 2: // Enable Respawning
3078 {
3079 for (WorldObject* target : targets)
3080 {
3081 if (Creature* c = target->ToCreature())
3082 {
3083 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3084
3085 // If 0, respawn immediately
3088 else
3089 c->Respawn(true);
3090
3091 // If 0, use DB values
3093 c->SetRespawnDelay(e.action.scriptSpawn.respawnDelay);
3094
3095 // If 0, use default
3097 c->SetCorpseDelay(e.action.scriptSpawn.corpseDelay);
3098 }
3099 }
3100 break;
3101 }
3102 default:
3103 break;
3104 }
3105 break;
3106 }
3108 {
3109 float scale = static_cast<float>(e.action.setScale.scale) / 100.0f;
3110
3111 for (WorldObject* target : targets)
3112 {
3113 if (IsUnit(target))
3114 target->ToUnit()->SetObjectScale(scale);
3115 else if (IsGameObject(target))
3116 target->ToGameObject()->SetObjectScale(scale);
3117 }
3118 break;
3119 }
3121 {
3122 if (!me)
3123 break;
3124
3126
3127 float startAngle = me->GetOrientation() + (static_cast<float>(e.action.radialSummon.startAngle) * M_PI / 180.0f);
3128 float stepAngle = static_cast<float>(e.action.radialSummon.stepAngle) * M_PI / 180.0f;
3129
3130 if (e.action.radialSummon.dist)
3131 {
3132 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3133 {
3134 Position summonPos = me->GetPosition();
3135 summonPos.RelocatePolarOffset(itr * stepAngle, static_cast<float>(e.action.radialSummon.dist));
3137 }
3138 break;
3139 }
3140
3141 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3142 {
3143 float currentAngle = startAngle + (itr * stepAngle);
3145 }
3146
3147 break;
3148 }
3150 {
3151 for (WorldObject* target : targets)
3152 {
3153 if (IsUnit(target))
3154 {
3157 }
3158 }
3159 break;
3160 }
3162 {
3164 {
3165 for (WorldObject* target : targets)
3166 if (IsUnit(target))
3167 target->ToCreature()->GetMotionMaster()->MoveIdle();
3168
3169 break;
3170 }
3171
3172 uint8 membCount = targets.size();
3173 uint8 itr = 1;
3174 float dist = float(e.action.followGroup.dist / 100);
3175 switch (e.action.followGroup.followType)
3176 {
3177 case FOLLOW_TYPE_CIRCLE:
3178 {
3179 float angle = (membCount > 4 ? (M_PI * 2)/membCount : (M_PI / 2)); // 90 degrees is the maximum angle
3180 for (WorldObject* target : targets)
3181 {
3182 if (IsCreature(target))
3183 {
3184 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, angle * itr);
3185 itr++;
3186 }
3187 }
3188 break;
3189 }
3191 {
3192 for (WorldObject* target : targets)
3193 {
3194 if (IsCreature(target))
3195 {
3196 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1));
3197 itr++;
3198 }
3199 }
3200 break;
3201 }
3203 {
3204 for (WorldObject* target : targets)
3205 {
3206 if (IsCreature(target))
3207 {
3208 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI + (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1)));
3209 itr++;
3210 }
3211 }
3212 break;
3213 }
3214 case FOLLOW_TYPE_LINE:
3215 {
3216 for (WorldObject* target : targets)
3217 {
3218 if (IsCreature(target))
3219 {
3220 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? 0.f : M_PI);
3221 itr++;
3222 }
3223 }
3224 break;
3225 }
3226 case FOLLOW_TYPE_COLUMN:
3227 {
3228 for (WorldObject* target : targets)
3229 {
3230 if (IsCreature(target))
3231 {
3232 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? (M_PI / 2) : (M_PI * 1.5f));
3233 itr++;
3234 }
3235 }
3236 break;
3237 }
3239 {
3240 for (WorldObject* target : targets)
3241 {
3242 if (IsCreature(target))
3243 {
3244 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? M_PI - (M_PI / 4) : M_PI + (M_PI / 4));
3245 itr++;
3246 }
3247 }
3248 break;
3249 }
3250 default:
3251 break;
3252 }
3253
3254 break;
3255 }
3257 {
3258 switch (e.action.orientationTarget.type)
3259 {
3260 case 0: // Reset
3261 {
3262 for (WorldObject* target : targets)
3263 target->ToCreature()->SetFacingTo((target->ToCreature()->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->ToCreature()->GetTransGUID() ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition()).GetOrientation());
3264
3265 break;
3266 }
3267 case 1: // Target target.o
3268 {
3269 for (WorldObject* target : targets)
3270 target->ToCreature()->SetFacingTo(e.target.o);
3271
3272 break;
3273 }
3274 case 2: // Target source
3275 {
3276 for (WorldObject* target : targets)
3277 target->ToCreature()->SetFacingToObject(me);
3278
3279 break;
3280 }
3281 case 3: // Target parameters
3282 {
3283 ObjectVector facingTargets;
3285
3286 for (WorldObject* facingTarget : facingTargets)
3287 for (WorldObject* target : targets)
3288 target->ToCreature()->SetFacingToObject(facingTarget);
3289
3290 break;
3291 }
3292 default:
3293 break;
3294 }
3295 break;
3296 }
3298 {
3299 if (e.action.wpData.pathId)
3300 {
3301 for (WorldObject* target : targets)
3302 {
3303 if (IsCreature(target))
3304 {
3305 target->ToCreature()->LoadPath(e.action.wpData.pathId);
3307 }
3308 }
3309 }
3310
3311 break;
3312 }
3314 {
3316 {
3317 for (WorldObject* target : targets)
3318 {
3319 if (IsCreature(target))
3320 {
3322 target->ToCreature()->LoadPath(path);
3324 }
3325 }
3326 }
3327
3328 break;
3329 }
3331 {
3332 for (WorldObject* target : targets)
3333 if (IsUnit(target))
3334 target->ToUnit()->StopMoving();
3335
3336 break;
3337 }
3339 {
3340 for (WorldObject* target : targets)
3341 if (IsUnit(target))
3342 target->ToUnit()->PauseMovement(e.action.move.timer);
3343
3344 break;
3345 }
3347 {
3348 for (WorldObject* target : targets)
3349 if (IsUnit(target))
3350 target->ToUnit()->ResumeMovement(e.action.move.timer);
3351
3352 break;
3353 }
3355 {
3356 sWorldState->HandleExternalEvent(static_cast<WorldStateEvent>(e.action.worldStateScript.eventId), e.action.worldStateScript.param);
3357 break;
3358 }
3360 {
3361 for (WorldObject* target : targets)
3362 if (IsCreature(target))
3363 {
3364 target->ToCreature()->SetReputationRewardDisabled(static_cast<bool>(e.action.reward.reputation));
3365 target->ToCreature()->SetLootRewardDisabled(static_cast<bool>(e.action.reward.loot));
3366 }
3367 break;
3368 }
3370 {
3371 for (WorldObject* target : targets)
3372 if (IsUnit(target))
3373 target->ToUnit()->SetAnimTier(AnimTier(e.action.animTier.animTier));
3374 break;
3375 }
3377 {
3378 for (WorldObject* target : targets)
3379 {
3380 if (Creature* creature = target->ToCreature())
3381 {
3382 creature->SetGossipMenuId(e.action.setGossipMenu.gossipMenuId);
3383 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_GOSSIP_MENU: Creature {} set gossip menu to {}",
3384 creature->GetGUID().ToString(), e.action.setGossipMenu.gossipMenuId);
3385 }
3386 }
3387 break;
3388 }
3390 {
3391 if (!GetBaseObject())
3392 break;
3393
3395 break;
3396 }
3397 default:
3398 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
3399 break;
3400 }
3401
3402 if (e.link && e.link != e.event_id)
3403 {
3404 auto linked = FindLinkedEvent(e.link);
3405 if (linked.has_value())
3406 {
3407 auto& linkedEvent = linked.value().get();
3408 if (linkedEvent.GetEventType() == SMART_EVENT_LINK)
3409 executionStack.emplace_back(SmartScriptFrame{ linkedEvent, unit, var0, var1, bvar, spell, gob });
3410 else
3411 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Link Event {} found but has wrong type (should be 61, is {}).", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link, linkedEvent.GetEventType());
3412 }
3413 else
3414 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Link Event {} not found, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
3415 }
3416}
npc
Definition BattlegroundSA.h:47
#define DEFAULT_LOCALE
Definition Common.h:131
#define MAX_EQUIPMENT_ITEMS
Definition CreatureData.h:36
@ TEXT_RANGE_NORMAL
Definition CreatureTextMgr.h:30
std::int8_t int8
Definition Define.h:105
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:27
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
#define sGameEventMgr
Definition GameEventMgr.h:201
GOState
Definition GameObjectData.h:707
LootState
Definition GameObject.h:109
@ GO_READY
Definition GameObject.h:111
EncounterState
Definition InstanceScript.h:57
@ BROADCAST_TEXT_CALL_FOR_HELP
Definition Language.h:24
@ BROADCAST_TEXT_FLEE_FOR_ASSIST
Definition Language.h:25
@ MOTION_SLOT_CONTROLLED
Definition MotionMaster.h:66
@ MOTION_SLOT_ACTIVE
Definition MotionMaster.h:65
PathSource
Definition MotionMaster.h:94
@ SMART_WAYPOINT_MGR
ForcedMovement
Definition MotionMaster.h:85
@ FORCED_MOVEMENT_NONE
Definition MotionMaster.h:86
AnimTier
Definition MotionMaster.h:100
#define NOMINAL_MELEE_RANGE
Definition ObjectDefines.h:47
#define sObjectMgr
Definition ObjectMgr.h:1732
TempSummonType
Definition Object.h:48
@ TEMPSUMMON_TIMED_DESPAWN
Definition Object.h:51
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:53
float frand(float min, float max)
Definition Random.cpp:57
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
Definition ScriptedGossip.cpp:45
void ClearGossipMenuFor(Player *player)
Definition ScriptedGossip.cpp:22
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1564
@ POWER_MANA
Definition SharedDefines.h:257
@ CHAT_MSG_MONSTER_EMOTE
Definition SharedDefines.h:3401
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3384
@ LANG_UNIVERSAL
Definition SharedDefines.h:723
@ LANG_ADDON
Definition SharedDefines.h:741
@ SPELL_ATTR2_IGNORE_LINE_OF_SIGHT
Definition SharedDefines.h:446
@ TEAM_NEUTRAL
Definition SharedDefines.h:750
SpellCastResult
Definition SharedDefines.h:936
@ SPELL_FAILED_OUT_OF_RANGE
Definition SharedDefines.h:1034
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
@ SPELL_FAILED_SPELL_IN_PROGRESS
Definition SharedDefines.h:1042
@ SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL
Definition SmartScriptMgr.h:1967
SMARTAI_TARGETS
Definition SmartScriptMgr.h:1549
@ SMART_TARGET_RANDOM_POINT
Definition SmartScriptMgr.h:1588
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2271
SMART_ACTION
Definition SmartScriptMgr.h:541
@ SMART_ACTION_REMOVE_TIMED_EVENT
Definition SmartScriptMgr.h:616
@ SMART_ACTION_NONE
Definition SmartScriptMgr.h:542
@ SMART_ACTION_SET_GO_FLAG
Definition SmartScriptMgr.h:646
@ SMART_ACTION_UPDATE_TEMPLATE
Definition SmartScriptMgr.h:578
@ SMART_ACTION_SET_HEALTH_REGEN
Definition SmartScriptMgr.h:644
@ SMART_ACTION_SET_GOSSIP_MENU
Definition SmartScriptMgr.h:727
@ SMART_ACTION_ACTIVATE_GOBJECT
Definition SmartScriptMgr.h:551
@ SMART_ACTION_GAME_EVENT_START
Definition SmartScriptMgr.h:654
@ SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:630
@ SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1
Definition SmartScriptMgr.h:633
@ SMART_ACTION_SET_INST_DATA64
Definition SmartScriptMgr.h:577
@ SMART_ACTION_SET_FACTION
Definition SmartScriptMgr.h:544
@ SMART_ACTION_THREAT_SINGLE_PCT
Definition SmartScriptMgr.h:555
@ SMART_ACTION_OFFER_QUEST
Definition SmartScriptMgr.h:549
@ SMART_ACTION_REMOVE_ALL_GAMEOBJECTS
Definition SmartScriptMgr.h:668
@ SMART_ACTION_RISE_UP
Definition SmartScriptMgr.h:656
@ SMART_ACTION_SET_INGAME_PHASE_MASK
Definition SmartScriptMgr.h:586
@ SMART_ACTION_SET_UNIT_FIELD_BYTES_1
Definition SmartScriptMgr.h:632
@ SMART_ACTION_CLOSE_GOSSIP
Definition SmartScriptMgr.h:614
@ SMART_ACTION_DISABLE_EVADE
Definition SmartScriptMgr.h:659
@ SMART_ACTION_INC_DATA
Definition SmartScriptMgr.h:729
@ SMART_ACTION_CONE_SUMMON
Definition SmartScriptMgr.h:706
@ SMART_ACTION_ADD_GO_FLAG
Definition SmartScriptMgr.h:647
@ SMART_ACTION_ESCORT_START
Definition SmartScriptMgr.h:595
@ SMART_ACTION_ADD_DYNAMIC_FLAG
Definition SmartScriptMgr.h:637
@ SMART_ACTION_KILL_UNIT
Definition SmartScriptMgr.h:593
@ SMART_ACTION_LOAD_EQUIPMENT
Definition SmartScriptMgr.h:666
@ SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS
Definition SmartScriptMgr.h:557
@ SMART_ACTION_ATTACK_START
Definition SmartScriptMgr.h:591
@ SMART_ACTION_MOVEMENT_RESUME
Definition SmartScriptMgr.h:723
@ SMART_ACTION_SET_UNIT_FLAG
Definition SmartScriptMgr.h:560
@ SMART_ACTION_NO_ENVIRONMENT_UPDATE
Definition SmartScriptMgr.h:699
@ SMART_ACTION_CALL_GROUPEVENTHAPPENS
Definition SmartScriptMgr.h:568
@ SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL
Definition SmartScriptMgr.h:585
@ SMART_ACTION_INVOKER_CAST
Definition SmartScriptMgr.h:676
@ SMART_ACTION_MOVEMENT_STOP
Definition SmartScriptMgr.h:721
@ SMART_ACTION_SET_SCALE
Definition SmartScriptMgr.h:714
@ SMART_ACTION_JUMP_TO_POS
Definition SmartScriptMgr.h:639
@ SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:629
@ SMART_ACTION_SEND_GOSSIP_MENU
Definition SmartScriptMgr.h:640
@ SMART_ACTION_SET_COUNTER
Definition SmartScriptMgr.h:605
@ SMART_ACTION_FLEE_FOR_ASSIST
Definition SmartScriptMgr.h:567
@ SMART_ACTION_EQUIP
Definition SmartScriptMgr.h:613
@ SMART_ACTION_SET_ROOT
Definition SmartScriptMgr.h:645
@ SMART_ACTION_ATTACK_STOP
Definition SmartScriptMgr.h:711
@ SMART_ACTION_SUMMON_GO
Definition SmartScriptMgr.h:592
@ SMART_ACTION_SET_HOVER
Definition SmartScriptMgr.h:693
@ SMART_ACTION_SIMPLE_TALK
Definition SmartScriptMgr.h:626
@ SMART_ACTION_STOP_MOTION
Definition SmartScriptMgr.h:698
@ SMART_ACTION_VORTEX_SUMMON
Definition SmartScriptMgr.h:708
@ SMART_ACTION_WORLD_SCRIPT
Definition SmartScriptMgr.h:724
@ SMART_ACTION_MUSIC
Definition SmartScriptMgr.h:702
@ SMART_ACTION_SET_ORIENTATION_TARGET
Definition SmartScriptMgr.h:718
@ SMART_ACTION_SPAWN_SPAWNGROUP
Definition SmartScriptMgr.h:673
@ SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS
Definition SmartScriptMgr.h:690
@ SMART_ACTION_ADD_AURA
Definition SmartScriptMgr.h:617
@ SMART_ACTION_THREAT_ALL_PCT
Definition SmartScriptMgr.h:556
@ SMART_ACTION_WAYPOINT_START
Definition SmartScriptMgr.h:719
@ SMART_ACTION_ESCORT_STOP
Definition SmartScriptMgr.h:597
@ SMART_ACTION_RESPAWN_TARGET
Definition SmartScriptMgr.h:612
@ SMART_ACTION_FOLLOW_GROUP
Definition SmartScriptMgr.h:717
@ SMART_ACTION_SOUND
Definition SmartScriptMgr.h:546
@ SMART_ACTION_ESCORT_PAUSE
Definition SmartScriptMgr.h:596
@ SMART_ACTION_MOVE_TO_POS_TARGET
Definition SmartScriptMgr.h:687
@ SMART_ACTION_SET_MOVEMENT_SPEED
Definition SmartScriptMgr.h:678
@ SMART_ACTION_PLAY_CINEMATIC
Definition SmartScriptMgr.h:677
@ SMART_ACTION_ADD_NPC_FLAG
Definition SmartScriptMgr.h:624
@ SMART_ACTION_EVADE
Definition SmartScriptMgr.h:566
@ SMART_ACTION_FAIL_QUEST
Definition SmartScriptMgr.h:548
@ SMART_ACTION_INTERRUPT_SPELL
Definition SmartScriptMgr.h:634
@ SMART_ACTION_ADD_POWER
Definition SmartScriptMgr.h:651
@ SMART_ACTION_SET_ANIM_TIER
Definition SmartScriptMgr.h:726
@ SMART_ACTION_REMOVE_DYNAMIC_FLAG
Definition SmartScriptMgr.h:638
@ SMART_ACTION_RANDOM_SOUND
Definition SmartScriptMgr.h:657
@ SMART_ACTION_RANDOM_MUSIC
Definition SmartScriptMgr.h:703
@ SMART_ACTION_SET_COMBAT_DISTANCE
Definition SmartScriptMgr.h:691
@ SMART_ACTION_SET_POWER
Definition SmartScriptMgr.h:650
@ SMART_ACTION_SEND_TARGET_TO_TARGET
Definition SmartScriptMgr.h:642
@ SMART_ACTION_REMOVE_POWER
Definition SmartScriptMgr.h:652
@ SMART_ACTION_ADD_IMMUNITY
Definition SmartScriptMgr.h:694
@ SMART_ACTION_SET_DYNAMIC_FLAG
Definition SmartScriptMgr.h:636
@ SMART_ACTION_FALL
Definition SmartScriptMgr.h:696
@ SMART_ACTION_GO_SET_GO_STATE
Definition SmartScriptMgr.h:660
@ SMART_ACTION_CUSTOM_CAST
Definition SmartScriptMgr.h:705
@ SMART_ACTION_REMOVE_ITEM
Definition SmartScriptMgr.h:599
@ SMART_ACTION_SEND_GO_CUSTOM_ANIM
Definition SmartScriptMgr.h:635
@ SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL
Definition SmartScriptMgr.h:545
@ SMART_ACTION_REMOVE_UNIT_FLAG
Definition SmartScriptMgr.h:561
@ SMART_ACTION_RANDOM_PHASE
Definition SmartScriptMgr.h:572
@ SMART_ACTION_SET_EMOTE_STATE
Definition SmartScriptMgr.h:559
@ SMART_ACTION_CROSS_CAST
Definition SmartScriptMgr.h:628
@ SMART_ACTION_GAME_EVENT_STOP
Definition SmartScriptMgr.h:653
@ SMART_ACTION_SCRIPTED_SPAWN
Definition SmartScriptMgr.h:713
@ SMART_ACTION_ESCORT_RESUME
Definition SmartScriptMgr.h:607
@ SMART_ACTION_CALL_SCRIPT_RESET
Definition SmartScriptMgr.h:620
@ SMART_ACTION_CU_ENCOUNTER_START
Definition SmartScriptMgr.h:709
@ SMART_ACTION_COMBAT_STOP
Definition SmartScriptMgr.h:569
@ SMART_ACTION_EXIT_VEHICLE
Definition SmartScriptMgr.h:689
@ SMART_ACTION_SET_HEALTH_PCT
Definition SmartScriptMgr.h:680
@ SMART_ACTION_AUTO_ATTACK
Definition SmartScriptMgr.h:562
@ SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL
Definition SmartScriptMgr.h:584
@ SMART_ACTION_SET_VISIBILITY
Definition SmartScriptMgr.h:589
@ SMART_ACTION_RANDOM_PHASE_RANGE
Definition SmartScriptMgr.h:573
@ SMART_ACTION_MOVEMENT_PAUSE
Definition SmartScriptMgr.h:722
@ SMART_ACTION_GO_SET_LOOT_STATE
Definition SmartScriptMgr.h:641
@ SMART_ACTION_PLAYER_TALK
Definition SmartScriptMgr.h:707
@ SMART_ACTION_SELF_CAST
Definition SmartScriptMgr.h:627
@ SMART_ACTION_SET_SWIM
Definition SmartScriptMgr.h:603
@ SMART_ACTION_SET_SIGHT_DIST
Definition SmartScriptMgr.h:663
@ SMART_ACTION_SET_INST_DATA
Definition SmartScriptMgr.h:576
@ SMART_ACTION_REMOVE_GO_FLAG
Definition SmartScriptMgr.h:648
@ SMART_ACTION_LOAD_GRID
Definition SmartScriptMgr.h:701
@ SMART_ACTION_CALL_FOR_HELP
Definition SmartScriptMgr.h:581
@ SMART_ACTION_SUMMON_RADIAL
Definition SmartScriptMgr.h:715
@ SMART_ACTION_ADD_THREAT
Definition SmartScriptMgr.h:665
@ SMART_ACTION_DISMOUNT
Definition SmartScriptMgr.h:692
@ SMART_ACTION_TELEPORT
Definition SmartScriptMgr.h:604
@ SMART_ACTION_PLAYMOVIE
Definition SmartScriptMgr.h:610
@ SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT
Definition SmartScriptMgr.h:667
@ SMART_ACTION_FOLLOW
Definition SmartScriptMgr.h:571
@ SMART_ACTION_PLAY_EMOTE
Definition SmartScriptMgr.h:547
@ SMART_ACTION_DESPAWN_SPAWNGROUP
Definition SmartScriptMgr.h:674
@ SMART_ACTION_SET_CORPSE_DELAY
Definition SmartScriptMgr.h:658
@ SMART_ACTION_WAYPOINT_DATA_RANDOM
Definition SmartScriptMgr.h:720
@ SMART_ACTION_SET_GUID
Definition SmartScriptMgr.h:712
@ SMART_ACTION_SET_SHEATH
Definition SmartScriptMgr.h:582
@ SMART_ACTION_SET_ORIENTATION
Definition SmartScriptMgr.h:608
@ SMART_ACTION_SET_NPC_FLAG
Definition SmartScriptMgr.h:623
@ SMART_ACTION_MOVE_TO_POS
Definition SmartScriptMgr.h:611
@ SMART_ACTION_RANDOM_EMOTE
Definition SmartScriptMgr.h:552
@ SMART_ACTION_INC_EVENT_PHASE
Definition SmartScriptMgr.h:565
@ SMART_ACTION_CREATE_TIMED_EVENT
Definition SmartScriptMgr.h:609
@ SMART_ACTION_SET_EVENT_FLAG_RESET
Definition SmartScriptMgr.h:697
@ SMART_ACTION_SUMMON_GAMEOBJECT_GROUP
Definition SmartScriptMgr.h:728
@ SMART_ACTION_DIE
Definition SmartScriptMgr.h:579
@ SMART_ACTION_RESET_SCRIPT_BASE_OBJECT
Definition SmartScriptMgr.h:619
@ SMART_ACTION_REMOVE_NPC_FLAG
Definition SmartScriptMgr.h:625
@ SMART_ACTION_SET_FLY
Definition SmartScriptMgr.h:602
@ SMART_ACTION_INSTALL_AI_TEMPLATE
Definition SmartScriptMgr.h:600
@ SMART_ACTION_SUMMON_CREATURE
Definition SmartScriptMgr.h:554
@ SMART_ACTION_CALL_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:622
@ SMART_ACTION_SET_IN_COMBAT_WITH_ZONE
Definition SmartScriptMgr.h:580
@ SMART_ACTION_DO_ACTION
Definition SmartScriptMgr.h:710
@ SMART_ACTION_SET_HOME_POS
Definition SmartScriptMgr.h:643
@ SMART_ACTION_ADD_ITEM
Definition SmartScriptMgr.h:598
@ SMART_ACTION_SET_ACTIVE
Definition SmartScriptMgr.h:590
@ SMART_ACTION_SET_RANGED_MOVEMENT
Definition SmartScriptMgr.h:621
@ SMART_ACTION_ACTIVATE_TAXI
Definition SmartScriptMgr.h:594
@ SMART_ACTION_START_CLOSEST_WAYPOINT
Definition SmartScriptMgr.h:655
@ SMART_ACTION_SUMMON_CREATURE_GROUP
Definition SmartScriptMgr.h:649
@ SMART_ACTION_REMOVE_IMMUNITY
Definition SmartScriptMgr.h:695
@ SMART_ACTION_PLAY_SPELL_VISUAL
Definition SmartScriptMgr.h:716
@ SMART_ACTION_SET_REACT_STATE
Definition SmartScriptMgr.h:550
@ SMART_ACTION_DISABLE_REWARD
Definition SmartScriptMgr.h:725
@ SMART_ACTION_RANDOM_MOVE
Definition SmartScriptMgr.h:631
@ SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT
Definition SmartScriptMgr.h:618
@ SMART_ACTION_TRIGGER_TIMED_EVENT
Definition SmartScriptMgr.h:615
@ SMART_ACTION_REMOVEAURASFROMSPELL
Definition SmartScriptMgr.h:570
@ SMART_ACTION_FLEE
Definition SmartScriptMgr.h:664
@ SMART_ACTION_ZONE_UNDER_ATTACK
Definition SmartScriptMgr.h:700
@ FOLLOW_TYPE_CIRCLE
Definition SmartScriptMgr.h:1987
@ FOLLOW_TYPE_SEMI_CIRCLE_BEHIND
Definition SmartScriptMgr.h:1988
@ FOLLOW_TYPE_SEMI_CIRCLE_FRONT
Definition SmartScriptMgr.h:1989
@ FOLLOW_TYPE_COLUMN
Definition SmartScriptMgr.h:1991
@ FOLLOW_TYPE_ANGULAR
Definition SmartScriptMgr.h:1992
@ FOLLOW_TYPE_LINE
Definition SmartScriptMgr.h:1990
SMART_EVENT
Definition SmartScriptMgr.h:98
@ SMART_EVENT_TIMED_EVENT_TRIGGERED
Definition SmartScriptMgr.h:158
@ SMART_EVENT_ESCORT_REACHED
Definition SmartScriptMgr.h:139
@ SMART_EVENT_LINK
Definition SmartScriptMgr.h:160
uint32 SAIBool
Definition SmartScriptMgr.h:31
SmartActionSummonCreatureFlags
Definition SmartScriptMgr.h:735
@ SMART_ESCORT_TARGETS
Definition SmartScriptMgr.h:40
@ SMARTCAST_TRIGGERED
Definition SmartScriptMgr.h:1973
@ SMARTCAST_ENABLE_COMBAT_MOVE_ON_LOS
Definition SmartScriptMgr.h:1981
@ SMARTCAST_COMBAT_MOVE
Definition SmartScriptMgr.h:1978
@ SMARTCAST_INTERRUPT_PREVIOUS
Definition SmartScriptMgr.h:1972
@ SMARTCAST_AURA_NOT_PRESENT
Definition SmartScriptMgr.h:1977
@ SMARTCAST_THREATLIST_NOT_SINGLE
Definition SmartScriptMgr.h:1979
@ SMARTCAST_TARGET_POWER_MANA
Definition SmartScriptMgr.h:1980
@ AURA_REMOVE_BY_EXPIRE
Definition SpellAuraDefines.h:395
@ SPELLVALUE_BASE_POINT1
Definition SpellDefines.h:114
@ SPELLVALUE_BASE_POINT2
Definition SpellDefines.h:115
@ SPELLVALUE_BASE_POINT0
Definition SpellDefines.h:113
TriggerCastFlags
Definition SpellDefines.h:132
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition SpellDefines.h:150
@ TRIGGERED_NONE
Definition SpellDefines.h:133
#define sSpellMgr
Definition SpellMgr.h:847
#define CAST_AI(a, b)
Definition UnitAI.h:26
#define ENSURE_AI(a, b)
Definition UnitAI.h:27
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:381
NPCFlags
Non Player Character flags.
Definition UnitDefines.h:320
SheathState
Definition UnitDefines.h:128
@ UNIT_STATE_LOST_CONTROL
Definition UnitDefines.h:219
@ UNIT_STATE_ROOT
Definition UnitDefines.h:183
@ UNIT_STATE_NO_ENVIRONMENT_UPD
Definition UnitDefines.h:201
@ UNIT_STATE_NO_COMBAT_MOVEMENT
Definition UnitDefines.h:204
UnitMoveType
Definition UnitDefines.h:355
@ MOVE_RUN
Definition UnitDefines.h:357
@ UNIT_FLAG_SILENCED
Definition UnitDefines.h:270
ReactStates
Definition Unit.h:565
@ UNIT_FIELD_FLAGS_2
Definition UpdateFields.h:118
@ UNIT_VIRTUAL_ITEM_SLOT_ID
Definition UpdateFields.h:116
@ UNIT_FIELD_FLAGS
Definition UpdateFields.h:117
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
@ UNIT_FIELD_BYTES_1
Definition UpdateFields.h:131
@ UNIT_DYNAMIC_FLAGS
Definition UpdateFields.h:136
@ GAMEOBJECT_FLAGS
Definition UpdateFields.h:399
#define sWaypointMgr
Definition WaypointMgr.h:54
#define sWorldState
Definition WorldState.h:377
WorldStateEvent
Definition WorldState.h:42
Say
Definition boss_broodlord_lashlayer.cpp:29
Seats
Definition boss_flame_leviathan.cpp:160
Definition ChatTextBuilder.h:31
Definition SpellAuras.h:87
void StartCinematic(uint32 const cinematicSequenceId)
Definition CinematicMgr.cpp:31
Definition CreatureAI.h:69
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0ms)
Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
Definition CreatureAI.cpp:67
void SetReputationRewardDisabled(bool disable)
Definition Creature.h:378
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:347
void Respawn(bool force=false)
Definition Creature.cpp:2019
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition Creature.cpp:3058
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:349
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
Definition Creature.cpp:2842
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:354
void DoFleeToGetAssistance()
Definition Creature.cpp:1073
bool IsRooted() const
Definition Creature.h:89
void SetCorpseDelay(uint32 delay)
Definition Creature.h:74
void SetLootRewardDisabled(bool disable)
Definition Creature.h:380
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:100
void LoadPath(uint32 pathid)
Definition Creature.h:358
Definition SpellDefines.h:165
void AddSpellMod(SpellValueMod mod, int32 value)
Definition SpellDefines.h:167
Definition EnumFlag.h:66
void AddEventAtOffset(BasicEvent *event, Milliseconds offset, uint8 eventGroup=0)
Definition EventProcessor.h:108
Definition GameObjectAI.h:33
virtual void SetData(uint32, uint32)
Definition GameObjectAI.h:62
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition GameObject.cpp:1410
bool isSpawnedByDefault() const
Definition GameObject.h:196
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2462
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1284
GameobjectTypes GetGoType() const
Definition GameObject.h:203
void Respawn()
Definition GameObject.cpp:1299
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition GameObject.cpp:927
void CastSpell(Unit *target, uint32 spell)
Definition GameObject.cpp:2077
virtual bool SetBossState(uint32 id, EncounterState state)
Definition InstanceScript.cpp:396
virtual void DoAction(int32)
Definition InstanceScript.h:286
static std::string GetBossStateName(uint8 state)
Definition InstanceScript.cpp:837
Definition LinkedList.h:139
bool IsEmpty() const
Definition LinkedList.h:97
Definition MapRefMgr.h:26
iterator begin()
Definition MapRefMgr.h:36
iterator end()
Definition MapRefMgr.h:37
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false)
Definition Map.cpp:2562
void LoadGrid(float x, float y)
Definition Map.cpp:213
PlayerList const & GetPlayers() const
Definition Map.h:329
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false)
Definition Map.cpp:2646
void MoveWaypoint(uint32 path_id, bool repeatable, PathSource pathSource=PathSource::WAYPOINT_MGR)
Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:913
void MovementExpired(bool reset=true)
Definition MotionMaster.h:206
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=0)
Definition MotionMaster.h:256
void MoveIdle()
Definition MotionMaster.cpp:234
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE, bool inheritWalkState=true, bool inheritSpeed=true)
The unit will follow this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:447
void MovePoint(uint32 id, const Position &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true, std::optional< AnimTier > animTier=std::nullopt)
Definition MotionMaster.h:240
void MoveRandom(float wanderDistance=0.0f)
Enable a random movement in desired range around the unit. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:244
static ObjectGuid const Empty
Definition ObjectGuid.h:120
std::string ToString() const
Definition ObjectGuid.cpp:47
static CreatureModel const * ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=nullptr)
Definition ObjectMgr.cpp:1644
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:871
virtual void SetObjectScale(float scale)
Definition Object.h:121
Definition GossipDef.h:259
CinematicMgr & GetCinematicMgr()
Definition Player.h:1399
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition PlayerQuest.cpp:1854
void PrepareGossipMenu(WorldObject *source, uint32 menuId=0, bool showQuests=false)
Definition PlayerGossip.cpp:32
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:12843
Definition QuestDef.h:210
void SetInvincibilityHpLevel(uint32 level)
Definition SmartAI.h:189
void SetData(uint32 id, uint32 value) override
Definition SmartAI.h:167
void IncPhase(uint32 p)
Definition SmartScript.cpp:5536
void StoreTargetList(ObjectVector const &targets, uint32 id)
Definition SmartScript.h:93
void RetryLater(SmartScriptHolder &e, bool ignoreChanceRoll=false)
Definition SmartScript.cpp:5224
void StoreCounter(uint32 id, uint32 value, uint32 reset, uint32 subtract)
Definition SmartScript.h:108
std::optional< std::reference_wrapper< SmartScriptHolder > > FindLinkedEvent(uint32 link)
Definition SmartScript.h:269
std::deque< SmartScriptFrame > executionStack
Definition SmartScript.h:286
void SetPhaseReset(bool allow)
Definition SmartScript.h:205
void GetTargets(ObjectVector &targets, SmartScriptHolder const &e, WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:3545
void OnReset()
Definition SmartScript.cpp:110
void InstallTemplate(SmartScriptHolder const &e)
Definition SmartScript.cpp:3433
ObjectGuid goOrigGUID
Definition SmartScript.h:229
void DecPhase(uint32 p)
Definition SmartScript.cpp:5542
ObjectGuid meOrigGUID
Definition SmartScript.h:227
Definition SpellInfo.h:340
SpellSchoolMask GetSchoolMask() const
Definition SpellInfo.cpp:1894
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:441
int32 CalcPowerCost(Unit const *caster, SpellSchoolMask schoolMask, Spell *spell=nullptr) const
Definition SpellInfo.cpp:2803
void ModifyThreatByPercent(Unit *target, int32 percent)
Definition ThreatManager.h:150
size_t GetThreatListSize() const
Definition ThreatManager.cpp:298
Definition VehicleDefines.h:130
virtual void SetData(uint32, uint32)
Definition UnitAI.h:219
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:28
uint8 getGender() const
Definition Unit.h:848
void SetFacingToObject(WorldObject *object, Milliseconds timed=0ms)
Definition Unit.cpp:16486
void SetFacingTo(float ori)
Definition Unit.cpp:16476
float GetSpeed(UnitMoveType mtype) const
Definition Unit.cpp:11321
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
Definition Unit.cpp:4334
float GetSpellMinRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:11933
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:7733
static void Kill(Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.cpp:13997
MotionMaster * GetMotionMaster()
Definition Unit.h:1762
void SetUnitMovementFlags(uint32 f)
Definition Unit.h:776
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1446
bool IsAlive() const
Definition Unit.h:1797
void StopMoving()
Definition Unit.cpp:13056
void SendPlaySpellVisual(uint32 id)
Definition Unit.cpp:15207
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:6017
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:1781
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:11913
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:774
TransportBase * GetDirectTransport() const
Definition Unit.cpp:15063
void SendMovementFlagUpdate(bool self=false)
Definition Unit.cpp:13110
void EngageWithTarget(Unit *who)
Definition Unit.cpp:7537
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1389
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:5189
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:11326
ThreatManager & GetThreatMgr()
Definition Unit.h:951
ObjectGuid GetTransGUID() const override
Definition Unit.cpp:15052
bool IsAIEnabled
Definition Unit.h:2101
bool HasUnitState(const uint32 f) const
Definition Unit.h:736
float GetPowerPct(Powers power) const
Definition Unit.h:1137
void SetDisableGravity(bool disable)
Definition Unit.cpp:16527
float GetMeleeRange(Unit const *target) const
Definition Unit.cpp:801
uint32 GetPower(Powers power) const
Definition Unit.h:1135
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7504
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.h:1234
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition Unit.cpp:11453
void SetInFront(WorldObject const *target)
Definition Unit.cpp:16470
bool isDead() const
Definition Unit.h:1799
Definition Vehicle.h:28
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition Object.cpp:2393
Map * FindMap() const
Definition Object.h:626
bool IsWithinLOSInMap(WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
Definition Object.cpp:1403
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ=0, Position const *startPos=nullptr) const
Definition Object.cpp:2692
void SummonGameObjectGroup(uint8 group, std::list< GameObject * > *list=nullptr)
Definition Object.cpp:2484
bool GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0, WorldObject const *forWho=nullptr, bool force=false) const
Definition Object.cpp:2765
std::string const & GetName() const
Definition Object.h:528
void AddObjectToRemoveList()
Definition Object.cpp:2173
EventProcessor m_Events
Definition Object.h:736
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1295
uint32 GetAreaId() const
Definition Object.cpp:3119
uint32 GetZoneId() const
Definition Object.cpp:3111
float GetObjectSize() const
Definition Object.cpp:2837
GameObject * SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition Object.cpp:2407
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition Object.cpp:1558
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:2470
virtual float GetCombatReach() const
Definition Object.h:506
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2442
Player session in the World.
Definition WorldSession.h:394
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:52
virtual void SetGuidData(uint32, ObjectGuid)
Definition ZoneScript.h:45
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:133
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250
Definition ObjectAccessor.h:61
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:220
Definition CreatureData.h:170
uint32 CreatureDisplayID
Definition CreatureData.h:180
float DisplayScale
Definition CreatureData.h:181
Definition CreatureData.h:360
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition CreatureData.h:361
Definition Position.h:27
float m_positionZ
Definition Position.h:57
float m_positionX
Definition Position.h:55
float GetPositionZ() const
Definition Position.h:123
float m_positionY
Definition Position.h:56
float GetOrientation() const
Definition Position.h:124
void SetOrientation(float orientation)
Definition Position.h:116
float GetPositionX() const
Definition Position.h:121
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetPositionY() const
Definition Position.h:122
void RelocatePolarOffset(float angle, float dist, float z=0.0f)
Definition Position.cpp:34
float GetAngle(const Position *pos) const
Definition Position.cpp:85
Definition SmartScriptMgr.h:746
struct SmartAction::@75::@98 combatMove
uint32 followState
Definition SmartScriptMgr.h:1455
uint32 visualId
Definition SmartScriptMgr.h:1450
uint32 targetParam2
Definition SmartScriptMgr.h:850
struct SmartAction::@75::@100 incEventPhase
struct SmartAction::@75::@106 killedMonster
SAIBool disableForceDestination
Definition SmartScriptMgr.h:1207
std::array< uint32, SMART_ACTION_PARAM_COUNT > emotes
Definition SmartScriptMgr.h:833
uint32 forcedMovement
Definition SmartScriptMgr.h:1032
uint32 repeatMax
Definition SmartScriptMgr.h:1109
uint32 phaseMin
Definition SmartScriptMgr.h:935
uint32 targetsLimit
Definition SmartScriptMgr.h:841
struct SmartAction::@75::@181 movementSpeed
struct SmartAction::@75::@186 setScale
SAIBool transport
Definition SmartScriptMgr.h:1203
struct SmartAction::@75::@192 wpDataRandom
struct SmartAction::@75::@82 randomSound
struct SmartAction::@75::@120 summonGO
uint32 startAngle
Definition SmartScriptMgr.h:1443
SAIBool reset
Definition SmartScriptMgr.h:1094
std::array< uint32, SMART_ACTION_PARAM_COUNT > actionLists
Definition SmartScriptMgr.h:1157
struct SmartAction::@75::@185 scriptSpawn
uint32 delay
Definition SmartScriptMgr.h:756
struct SmartAction::@75::@163 startClosestWaypoint
uint32 random
Definition SmartScriptMgr.h:1338
uint32 quickChange
Definition SmartScriptMgr.h:1337
uint32 targetParam4
Definition SmartScriptMgr.h:1467
uint32 dist
Definition SmartScriptMgr.h:920
uint32 group
Definition SmartScriptMgr.h:1260
SAIBool disable
Definition SmartScriptMgr.h:1392
struct SmartAction::@75::@180 corpseDelay
struct SmartAction::@75::@194 worldStateScript
struct SmartAction::@75::@111 callHelp
uint32 spell
Definition SmartScriptMgr.h:838
uint32 minHP
Definition SmartScriptMgr.h:987
SAIBool force
Definition SmartScriptMgr.h:1314
struct SmartAction::@75::@177 summonVortex
uint32 flags
Definition SmartScriptMgr.h:847
struct SmartAction::@75::@97 autoAttack
SAIBool loot
Definition SmartScriptMgr.h:1510
uint32 distanceBetweenSummons
Definition SmartScriptMgr.h:1353
uint32 data
Definition SmartScriptMgr.h:947
struct SmartAction::@75::@105 randomPhaseRange
uint32 entry
Definition SmartScriptMgr.h:922
struct SmartAction::@75::@91 crossCast
struct SmartAction::@75::@129 setSwim
uint32 quest
Definition SmartScriptMgr.h:817
struct SmartAction::@75::@150 moveToPosTarget
struct SmartAction::@75::@172 orientation
struct SmartAction::@75::@78 simpleTalk
uint32 triggerFlags
Definition SmartScriptMgr.h:840
struct SmartAction::@75::@87 questOffer
uint32 bp1
Definition SmartScriptMgr.h:1368
uint32 distance
Definition SmartScriptMgr.h:780
SAIBool removeObjectFromWorld
Definition SmartScriptMgr.h:982
uint32 min
Definition SmartScriptMgr.h:1106
uint32 spawnTimerMax
Definition SmartScriptMgr.h:1427
uint32 subtract
Definition SmartScriptMgr.h:1095
struct SmartAction::@75::@110 die
uint32 a
Definition SmartScriptMgr.h:1377
struct SmartAction::@75::@151 sendGossipMenu
struct SmartAction::@75::@104 randomPhase
struct SmartAction::@75::@198 setGossipMenu
struct SmartAction::@75::@133 timeEvent
SAIBool invokerGUID
Definition SmartScriptMgr.h:1419
struct SmartAction::@75::@191 wpData
uint32 percent
Definition SmartScriptMgr.h:988
uint32 dec
Definition SmartScriptMgr.h:904
uint32 milliseconds
Definition SmartScriptMgr.h:964
struct SmartAction::@75::@125 item
uint32 summonEntry
Definition SmartScriptMgr.h:1350
struct SmartAction::@75::@84 randomMusic
uint32 followType
Definition SmartScriptMgr.h:1456
uint32 instanceTarget
Definition SmartScriptMgr.h:1387
struct SmartAction::@75::@196 reward
uint32 credit
Definition SmartScriptMgr.h:923
uint32 controlled
Definition SmartScriptMgr.h:1204
uint32 alternative
Definition SmartScriptMgr.h:856
uint32 targetParam1
Definition SmartScriptMgr.h:849
uint32 mapID
Definition SmartScriptMgr.h:1087
uint32 stopMovement
Definition SmartScriptMgr.h:1344
struct SmartAction::@75::@134 movie
struct SmartAction::@75::@94 summonCreature
uint32 charges
Definition SmartScriptMgr.h:915
struct SmartAction::@75::@113 forceDespawn
struct SmartAction::@75::@103 follow
uint32 model
Definition SmartScriptMgr.h:773
uint32 duration
Definition SmartScriptMgr.h:754
SAIBool attackInvoker
Definition SmartScriptMgr.h:869
SAIBool useTalkTarget
Definition SmartScriptMgr.h:755
SAIBool run
Definition SmartScriptMgr.h:1070
struct SmartAction::@75::@200 groupSpawn
struct SmartAction::@75::@176 castCustom
uint32 value
Definition SmartScriptMgr.h:1093
struct SmartAction::@75::@140 timedActionList
uint32 movementExpired
Definition SmartScriptMgr.h:1345
struct SmartAction::@75::@117 moveRandom
uint32 targetParam3
Definition SmartScriptMgr.h:851
uint32 respawnDelay
Definition SmartScriptMgr.h:1428
SAIBool swim
Definition SmartScriptMgr.h:1082
uint32 combatReach
Definition SmartScriptMgr.h:1206
uint32 sound2
Definition SmartScriptMgr.h:786
struct SmartAction::@75::@188 spellVisual
uint32 spawnPos
Definition SmartScriptMgr.h:1308
struct SmartAction::@75::@92 activateObject
struct SmartAction::@75::@167 setHomePos
struct SmartAction::@75::@161 gameEventStop
uint32 pathId2
Definition SmartScriptMgr.h:1284
uint32 creature
Definition SmartScriptMgr.h:772
struct SmartAction::@75::@190 orientationTarget
uint32 spawnTimerMin
Definition SmartScriptMgr.h:1426
struct SmartAction::@75::@132 storeTargets
struct SmartAction::@75::@114 invincHP
uint32 angle
Definition SmartScriptMgr.h:921
uint32 field
Definition SmartScriptMgr.h:946
struct SmartAction::@75::@199 gameobjectGroup
uint32 range
Definition SmartScriptMgr.h:861
struct SmartAction::@75::@95 threatPCT
struct SmartAction::@75::@89 randomEmote
struct SmartAction::@75::@162 gameEventStart
uint32 flag
Definition SmartScriptMgr.h:1127
uint32 sound3
Definition SmartScriptMgr.h:787
uint32 targetsummon
Definition SmartScriptMgr.h:1021
struct SmartAction::@75::@145 jump
uint32 chance
Definition SmartScriptMgr.h:1110
struct SmartAction::@75::@131 setCounter
uint32 state
Definition SmartScriptMgr.h:828
struct SmartAction::@75::@90 cast
struct SmartAction::@75::@108 setInstanceData64
uint32 sound1
Definition SmartScriptMgr.h:785
struct SmartAction::@75::@80 morphOrMount
struct SmartAction::@75::@116 setData
uint32 forceRespawnTimer
Definition SmartScriptMgr.h:981
uint32 speed
Definition SmartScriptMgr.h:1076
uint32 sound4
Definition SmartScriptMgr.h:788
struct SmartAction::@75::@147 flee
uint32 targetType
Definition SmartScriptMgr.h:848
uint32 repetitions
Definition SmartScriptMgr.h:1442
struct SmartAction::@75::@174 coneSummon
uint32 aliveState
Definition SmartScriptMgr.h:925
SAIBool onlySelf
Definition SmartScriptMgr.h:779
uint32 attackScriptOwner
Definition SmartScriptMgr.h:870
uint32 speedxy
Definition SmartScriptMgr.h:1180
uint32 pointId
Definition SmartScriptMgr.h:1202
SAIBool attack
Definition SmartScriptMgr.h:888
uint32 repeatMin
Definition SmartScriptMgr.h:1108
struct SmartAction::@75::@122 wpStart
uint32 scale
Definition SmartScriptMgr.h:1435
SAIBool fly
Definition SmartScriptMgr.h:1075
uint32 textGroupID
Definition SmartScriptMgr.h:753
uint32 castFlags
Definition SmartScriptMgr.h:839
struct SmartAction::@75::@179 disableEvade
std::array< uint32, SMART_ACTION_PARAM_COUNT > phases
Definition SmartScriptMgr.h:930
SAIBool dontDespawn
Definition SmartScriptMgr.h:1430
uint32 turnAngle
Definition SmartScriptMgr.h:1339
uint32 textId
Definition SmartScriptMgr.h:1360
uint32 gossipMenuId
Definition SmartScriptMgr.h:1218
uint32 speedz
Definition SmartScriptMgr.h:1181
SAIBool repeat
Definition SmartScriptMgr.h:1034
struct SmartAction::@75::@173 stopMotion
uint32 gossipNpcTextId
Definition SmartScriptMgr.h:1219
uint32 mask
Definition SmartScriptMgr.h:993
uint32 pathId1
Definition SmartScriptMgr.h:1283
uint32 phi_delta
Definition SmartScriptMgr.h:1380
uint32 count
Definition SmartScriptMgr.h:1055
struct SmartAction::@75::@112 setSheath
uint32 inc
Definition SmartScriptMgr.h:903
uint32 phaseMax
Definition SmartScriptMgr.h:936
struct SmartAction::@75::@130 teleport
uint32 timer
Definition SmartScriptMgr.h:1397
uint32 ContactDistance
Definition SmartScriptMgr.h:1205
struct SmartAction::@75::@79 faction
PathSource pathSource
Definition SmartScriptMgr.h:1287
struct SmartAction::@75::@135 equip
uint32 k
Definition SmartScriptMgr.h:1378
uint32 distanceBetweenRings
Definition SmartScriptMgr.h:1352
uint32 coneLength
Definition SmartScriptMgr.h:1354
uint32 counterId
Definition SmartScriptMgr.h:1092
SAIBool withEmote
Definition SmartScriptMgr.h:970
struct SmartAction::@75::@146 movementFlag
uint32 param
Definition SmartScriptMgr.h:1492
uint32 max
Definition SmartScriptMgr.h:1107
uint32 selfJump
Definition SmartScriptMgr.h:1182
struct SmartAction::@75::@183 cinematic
uint32 maxId
Definition SmartScriptMgr.h:1320
uint32 r_max
Definition SmartScriptMgr.h:1379
struct SmartAction::@75::@136 unitFlag
uint32 speedFraction
Definition SmartScriptMgr.h:1404
struct SmartAction::@75::@88 react
struct SmartAction::@75::@119 setActive
struct SmartAction::@75::@159 creatureGroup
SAIBool fail
Definition SmartScriptMgr.h:1049
struct SmartAction::@75::@124 wpStop
SAIBool directAdd
Definition SmartScriptMgr.h:823
uint32 bp2
Definition SmartScriptMgr.h:1369
uint32 disableGravity
Definition SmartScriptMgr.h:1077
uint32 sound
Definition SmartScriptMgr.h:778
uint32 threatINC
Definition SmartScriptMgr.h:876
uint32 coneAngle
Definition SmartScriptMgr.h:1355
uint32 summonDuration
Definition SmartScriptMgr.h:1351
struct SmartAction::@75::@148 RespawnTarget
struct SmartAction::@75::@175 playerTalk
uint32 threatDEC
Definition SmartScriptMgr.h:877
SAIBool reputation
Definition SmartScriptMgr.h:1509
uint32 ignoreRespawn
Definition SmartScriptMgr.h:1531
uint32 stepAngle
Definition SmartScriptMgr.h:1444
struct SmartAction::@75::@153 sendTargetToTarget
uint32 reactState
Definition SmartScriptMgr.h:1037
uint32 speedInteger
Definition SmartScriptMgr.h:1403
struct SmartAction::@75::@77 talk
uint32 index
Definition SmartScriptMgr.h:1420
struct SmartAction::@75::@123 wpPause
struct SmartAction::@75::@83 music
uint32 actionId
Definition SmartScriptMgr.h:1385
struct SmartAction::@75::@169 randomTimedEvent
uint32 despawnTime
Definition SmartScriptMgr.h:1020
struct SmartAction::@75::@128 setFly
uint32 goRespawnTime
Definition SmartScriptMgr.h:1197
struct SmartAction::@75::@115 ingamePhaseMask
uint32 factionID
Definition SmartScriptMgr.h:767
uint32 eventId
Definition SmartScriptMgr.h:1491
uint32 groupId
Definition SmartScriptMgr.h:1530
struct SmartAction::@75::@189 followGroup
uint32 pathId
Definition SmartScriptMgr.h:1472
SAIBool move
Definition SmartScriptMgr.h:893
struct SmartAction::@75::@178 doAction
struct SmartAction::@75::@149 moveToPos
std::array< uint32, MAX_EQUIPMENT_ITEMS > slots
Definition SmartScriptMgr.h:1122
struct SmartAction::@75::@127 setRun
struct SmartAction::@75::@187 radialSummon
struct SmartAction::@75::@99 setEventPhase
struct SmartAction::@75::@107 setInstanceData
uint32 questID
Definition SmartScriptMgr.h:822
uint32 bp3
Definition SmartScriptMgr.h:1370
uint32 pathID
Definition SmartScriptMgr.h:1033
uint32 emote
Definition SmartScriptMgr.h:812
struct SmartAction::@75::@102 removeAura
uint32 id
Definition SmartScriptMgr.h:1027
uint32 minId
Definition SmartScriptMgr.h:1319
uint32 phase
Definition SmartScriptMgr.h:898
uint32 sheath
Definition SmartScriptMgr.h:975
uint32 isNegative
Definition SmartScriptMgr.h:1386
uint32 creditType
Definition SmartScriptMgr.h:924
struct SmartAction::@75::@141 randTimedActionList
struct SmartAction::@75::@154 setRangedMovement
struct SmartAction::@75::@184 setGuid
Definition SmartScriptMgr.h:205
uint32 repeatMin
Definition SmartScriptMgr.h:216
uint32 repeatMax
Definition SmartScriptMgr.h:217
bool runOnce
Definition SmartScriptMgr.h:2022
uint32 link
Definition SmartScriptMgr.h:2005
bool IsAreatriggerScript() const
Definition SmartScriptMgr.h:2017
uint32 event_id
Definition SmartScriptMgr.h:2004
int32 entryOrGuid
Definition SmartScriptMgr.h:2002
uint32 GetScriptType() const
Definition SmartScriptMgr.h:2012
uint32 GetTargetType() const
Definition SmartScriptMgr.h:2015
uint32 GetActionType() const
Definition SmartScriptMgr.h:2014
struct SmartTarget::@201::@205 unitRange
float o
Definition SmartScriptMgr.h:1612
uint32 maxDist
Definition SmartScriptMgr.h:1618
uint32 range
Definition SmartScriptMgr.h:1739
float x
Definition SmartScriptMgr.h:1612
uint32 self
Definition SmartScriptMgr.h:1741
uint32 amount
Definition SmartScriptMgr.h:1740
struct SmartTarget::@201::@222 randomPoint
float y
Definition SmartScriptMgr.h:1612
float z
Definition SmartScriptMgr.h:1612
Definition WaypointDefines.h:37
float X
Definition WaypointDefines.h:48
float Z
Definition WaypointDefines.h:48
float Y
Definition WaypointDefines.h:48
Definition WaypointDefines.h:60
std::vector< WaypointNode > Nodes
Definition WaypointDefines.h:68

References SmartAction::a, SmartScriptHolder::action, SmartAction::actionId, SmartAction::actionLists, SmartAction::activateObject, EventProcessor::AddEventAtOffset(), WorldObject::AddObjectToRemoveList(), CustomSpellValues::AddSpellMod(), ThreatManager::AddThreat(), Creature::AI(), GameObject::AI(), SmartAction::aliveState, SmartAction::alternative, SmartTarget::amount, SmartAction::angle, SmartAction::anim, SmartAction::animTier, SmartAction::attack, SmartAction::attackInvoker, SmartAction::attackScriptOwner, UnitAI::AttackStart(), AURA_REMOVE_BY_EXPIRE, SmartAction::autoAttack, MapRefMgr::begin(), SmartAction::bp1, SmartAction::bp2, SmartAction::bp3, BROADCAST_TEXT_CALL_FOR_HELP, BROADCAST_TEXT_FLEE_FOR_ASSIST, SmartAction::byte1, SpellInfo::CalcPowerCost(), SmartAction::callHelp, Unit::CanHaveThreatList(), SmartAction::cast, CAST_AI, SmartAction::castCustom, Unit::CastCustomSpell(), SmartAction::castFlags, Unit::CastSpell(), GameObject::CastSpell(), SmartAction::chance, SmartAction::charges, CHAT_MSG_ADDON, CHAT_MSG_MONSTER_EMOTE, ObjectMgr::ChooseDisplayId(), SmartAction::cinematic, ClearGossipMenuFor(), SmartAction::combatDistance, SmartAction::combatMove, SmartAction::combatReach, Unit::CombatStop(), SmartAction::coneAngle, SmartAction::coneLength, SmartAction::coneSummon, SmartAction::ContactDistance, SmartAction::controlled, SmartAction::corpseDelay, SmartAction::count, SmartAction::counterId, CreateSmartEvent(), SmartAction::creature, CreatureModel::CreatureDisplayID, SmartAction::creatureGroup, SmartAction::credit, SmartAction::creditType, SmartAction::crossCast, SmartAction::data, SmartAction::dec, DecPhase(), DEFAULT_LOCALE, SmartAction::delay, SmartAction::delunitByte, GameObject::DespawnOrUnsummon(), SmartAction::despawnTime, SmartAction::die, SmartAction::directAdd, SmartAction::disable, SmartAction::disableEvade, SmartAction::disableForceDestination, SmartAction::disableGravity, CreatureModel::DisplayScale, SmartAction::dist, SmartAction::distance, SmartAction::distanceBetweenRings, SmartAction::distanceBetweenSummons, SmartAction::doAction, InstanceScript::DoAction(), Creature::DoFleeToGetAssistance(), SmartAction::dontDespawn, SmartAction::duration, SmartAction::emote, SmartAction::emotes, ObjectGuid::Empty, MapRefMgr::end(), Unit::EngageWithTarget(), ENSURE_AI, SmartAction::entry, SmartScriptHolder::entryOrGuid, SmartAction::equip, SmartScriptHolder::event, SmartEvent::event_chance, SmartEvent::event_flags, SmartScriptHolder::event_id, SmartAction::eventId, executionStack, SmartAction::faction, SmartAction::factionID, SmartAction::fail, SmartAction::field, FindLinkedEvent(), WorldObject::FindMap(), SmartAction::flag, SmartAction::flags, SmartAction::flee, SmartAction::fly, SmartAction::follow, FOLLOW_TYPE_ANGULAR, FOLLOW_TYPE_CIRCLE, FOLLOW_TYPE_COLUMN, FOLLOW_TYPE_LINE, FOLLOW_TYPE_SEMI_CIRCLE_BEHIND, FOLLOW_TYPE_SEMI_CIRCLE_FRONT, SmartAction::followGroup, SmartAction::followState, SmartAction::followType, SmartAction::force, FORCED_MOVEMENT_NONE, SmartAction::forceDespawn, SmartAction::forcedMovement, SmartAction::forceRespawnTimer, frand(), SmartAction::gameEventStart, SmartAction::gameEventStop, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_DOOR, SmartAction::gameobjectGroup, SmartScriptHolder::GetActionType(), Position::GetAngle(), WorldObject::GetAreaId(), GetBaseObject(), InstanceScript::GetBossStateName(), Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), WorldObject::GetClosePoint(), WorldObject::GetCombatReach(), Unit::GetDirectTransport(), WorldObject::GetDistance(), Object::GetEntry(), SmartScriptHolder::GetEventType(), Unit::getGender(), GameObject::GetGoType(), Object::GetGUID(), Creature::GetHomePosition(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), WorldObject::GetMap(), Unit::GetMeleeRange(), ThreatManager::GetModifiableThreatList(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldObject::GetNearPoint(), WorldObject::GetObjectSize(), Position::GetOrientation(), ObjectAccessor::GetPlayer(), Map::GetPlayers(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetPower(), Unit::GetPowerPct(), WorldObject::GetRandomPoint(), Creature::GetRespawnPosition(), SpellInfo::GetSchoolMask(), SmartScriptHolder::GetScriptType(), Unit::GetSpeed(), Unit::GetSpellMaxRangeForTarget(), Unit::GetSpellMinRangeForTarget(), GetStoredTargetVector(), GetTargets(), SmartScriptHolder::GetTargetType(), ThreatManager::GetThreatListSize(), Unit::GetThreatMgr(), Unit::GetTransGUID(), Creature::GetTransportHomePosition(), Unit::GetVehicleKit(), GetWorldObjectsInDist(), WorldObject::GetZoneId(), go, GO_READY, SmartAction::goFlag, goOrigGUID, SmartAction::goRespawnTime, SmartAction::gossipMenuId, SmartAction::gossipNpcTextId, SmartAction::goState, SmartAction::group, Player::GroupEventHappens(), SmartAction::groupId, SmartAction::groupSpawn, SpellInfo::HasAttribute(), Unit::HasAura(), EnumFlag< T >::HasFlag(), Object::HasFlag(), Unit::HasUnitMovementFlag(), Unit::HasUnitState(), SmartAction::id, SmartAction::ignoreRespawn, SmartAction::immunity, SmartAction::inc, SmartAction::incEventPhase, IncPhase(), SmartAction::index, SmartAction::ingamePhaseMask, InitTimer(), InstallTemplate(), SmartAction::instanceTarget, Unit::InterruptNonMeleeSpells(), SmartAction::interruptSpellCasting, SmartAction::invincHP, SmartAction::invokerGUID, Unit::IsAlive(), SmartScriptHolder::IsAreatriggerScript(), IsCreature(), Unit::isDead(), Map::IsDungeon(), LinkedListHead::IsEmpty(), IsGameObject(), SmartAction::isNegative, IsPlayer(), Creature::IsRooted(), IsSmart(), IsUnit(), Unit::IsVehicle(), WorldObject::IsWithinLOSInMap(), SmartAction::item, EquipmentInfo::ItemEntry, SmartAction::jump, SmartAction::k, Unit::Kill(), SmartAction::killedMonster, Unit::KillSelf(), LANG_ADDON, LANG_UNIVERSAL, SmartScriptHolder::link, SmartAction::loadEquipment, Map::LoadGrid(), LOG_DEBUG, LOG_ERROR, SmartAction::loot, VMAP::M2, WorldObject::m_Events, Position::m_positionX, Position::m_positionY, Position::m_positionZ, SmartAction::mapID, SmartAction::mask, SmartEvent::max, SmartAction::max, MAX_EQUIPMENT_ITEMS, SmartTarget::maxDist, SmartAction::maxId, me, meOrigGUID, SmartAction::milliseconds, SmartEvent::min, SmartAction::min, SmartAction::minHP, SmartAction::minId, SmartEvent::minMaxRepeat, mLastInvoker, mLastTextID, SmartAction::model, ThreatManager::ModifyThreatByPercent(), SmartAction::morphOrMount, MOTION_SLOT_ACTIVE, MOTION_SLOT_CONTROLLED, SmartAction::move, MOVE_RUN, MotionMaster::MoveIdle(), MotionMaster::MoveJump(), SmartAction::movementExpired, SmartAction::movementFlag, MOVEMENTFLAG_ONTRANSPORT, SmartAction::movementSpeed, SmartAction::movementType, MotionMaster::MovePoint(), SmartAction::moveRandom, MotionMaster::MoveRandom(), SmartAction::moveToPos, SmartAction::moveToPosTarget, SmartAction::movie, mRemIDs, mStoredEvents, mTalkerEntry, mTextTimer, mUseTextTimer, SmartAction::music, SmartAction::newPower, WaypointPath::Nodes, NOMINAL_MELEE_RANGE, SmartTarget::o, SmartAction::onlySelf, OnReset(), SmartAction::orientation, SmartAction::orientationTarget, SmartAction::param, SmartAction::pathID, SmartAction::pathId, SmartAction::pathId1, SmartAction::pathId2, SmartAction::pathSource, SmartAction::percent, PersonalSpawn, SmartAction::phase, SmartAction::phaseMax, SmartAction::phaseMin, SmartAction::phases, SmartAction::phi_delta, SmartAction::playerTalk, SmartAction::pointId, SmartAction::power, POWER_MANA, SmartAction::powerType, PreferUnit, ProcessEventsFor(), SmartAction::quest, SmartAction::questID, SmartAction::questOffer, SmartAction::quickChange, SmartAction::r_max, SmartAction::radialSummon, SmartAction::random, SmartAction::randomEmote, SmartAction::randomMusic, SmartAction::randomPhase, SmartAction::randomPhaseRange, SmartTarget::randomPoint, Acore::Containers::RandomResize(), SmartAction::randomSound, SmartAction::randomTimedEvent, SmartAction::randTimedActionList, SmartAction::range, SmartTarget::range, SmartAction::react, SmartAction::reactState, SmartAction::regenHealth, Position::RelocatePolarOffset(), SmartAction::removeAura, Unit::RemoveAurasDueToSpell(), SmartAction::removeObjectFromWorld, SmartAction::repeat, SmartEvent::repeatMax, SmartAction::repeatMax, SmartEvent::repeatMin, SmartAction::repeatMin, SmartAction::repetitions, SmartAction::reputation, SmartAction::reset, ResetBaseObject(), SmartAction::respawnDelay, SmartAction::RespawnTarget, RetryLater(), SmartAction::reward, Player::RewardPlayerAndGroupAtEvent(), SmartAction::root, SmartAction::run, SmartScriptHolder::runOnce, SmartAction::scale, sCreatureTextMgr, SmartAction::scriptSpawn, Acore::Containers::SelectRandomContainerElement(), SmartTarget::self, SmartAction::selfJump, SmartAction::sendGoCustomAnim, SmartAction::sendGossipMenu, SendGossipMenuFor(), Unit::SendPlaySpellVisual(), PlayerMenu::SendQuestGiverQuestDetails(), SmartAction::sendTargetToTarget, Creature::SendZoneUnderAttackMessage(), SmartAction::setActive, InstanceScript::SetBossState(), SmartAction::setCounter, GameObjectAI::SetData(), UnitAI::SetData(), SmartAction::setData, ZoneScript::SetData(), Unit::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, SmartAction::setGoLootState, SmartAction::setGossipMenu, SmartAction::setGuid, ZoneScript::SetGuidData(), SmartAction::setHealthPct, SmartAction::setHealthRegen, SmartAction::setHomePos, Creature::SetHomePosition(), SmartAction::setHover, Unit::SetInFront(), SmartAction::setInstanceData, SmartAction::setInstanceData64, SmartAI::SetInvincibilityHpLevel(), GameObject::SetLootState(), Position::SetOrientation(), SetPhase(), SetPhaseReset(), SmartAction::setRangedMovement, Creature::SetReactState(), SmartAction::setRoot, SmartAction::setRun, SmartAction::setScale, SetScript9(), SmartAction::setSheath, Unit::SetSheath(), Unit::SetSpeed(), SmartAction::setSwim, SmartAction::setunitByte, sGameEventMgr, SmartAction::sheath, SmartAction::sightDistance, SmartAction::simpleTalk, SmartAction::slots, SMART_ACTION_ACTIVATE_GOBJECT, SMART_ACTION_ACTIVATE_TAXI, SMART_ACTION_ADD_AURA, SMART_ACTION_ADD_DYNAMIC_FLAG, SMART_ACTION_ADD_GO_FLAG, SMART_ACTION_ADD_IMMUNITY, SMART_ACTION_ADD_ITEM, SMART_ACTION_ADD_NPC_FLAG, SMART_ACTION_ADD_POWER, SMART_ACTION_ADD_THREAT, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, SMART_ACTION_ATTACK_START, SMART_ACTION_ATTACK_STOP, SMART_ACTION_AUTO_ATTACK, SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS, SMART_ACTION_CALL_FOR_HELP, SMART_ACTION_CALL_GROUPEVENTHAPPENS, SMART_ACTION_CALL_KILLEDMONSTER, SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST, SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST, SMART_ACTION_CALL_SCRIPT_RESET, SMART_ACTION_CALL_TIMED_ACTIONLIST, SMART_ACTION_CAST, SMART_ACTION_CLOSE_GOSSIP, SMART_ACTION_COMBAT_STOP, SMART_ACTION_CONE_SUMMON, SMART_ACTION_CREATE_TIMED_EVENT, SMART_ACTION_CROSS_CAST, SMART_ACTION_CU_ENCOUNTER_START, SMART_ACTION_CUSTOM_CAST, SMART_ACTION_DESPAWN_SPAWNGROUP, SMART_ACTION_DIE, SMART_ACTION_DISABLE_EVADE, SMART_ACTION_DISABLE_REWARD, SMART_ACTION_DISMOUNT, SMART_ACTION_DO_ACTION, SMART_ACTION_EQUIP, SMART_ACTION_ESCORT_PAUSE, SMART_ACTION_ESCORT_RESUME, SMART_ACTION_ESCORT_START, SMART_ACTION_ESCORT_STOP, SMART_ACTION_EVADE, SMART_ACTION_EXIT_VEHICLE, SMART_ACTION_FAIL_QUEST, SMART_ACTION_FALL, SMART_ACTION_FLEE, SMART_ACTION_FLEE_FOR_ASSIST, SMART_ACTION_FOLLOW, SMART_ACTION_FOLLOW_GROUP, SMART_ACTION_FORCE_DESPAWN, SMART_ACTION_GAME_EVENT_START, SMART_ACTION_GAME_EVENT_STOP, SMART_ACTION_GO_SET_GO_STATE, SMART_ACTION_GO_SET_LOOT_STATE, SMART_ACTION_INC_DATA, SMART_ACTION_INC_EVENT_PHASE, SMART_ACTION_INSTALL_AI_TEMPLATE, SMART_ACTION_INTERRUPT_SPELL, SMART_ACTION_INVOKER_CAST, SMART_ACTION_JUMP_TO_POS, SMART_ACTION_KILL_UNIT, SMART_ACTION_LOAD_EQUIPMENT, SMART_ACTION_LOAD_GRID, SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL, SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL, SMART_ACTION_MOVE_FORWARD, SMART_ACTION_MOVE_TO_POS, SMART_ACTION_MOVE_TO_POS_TARGET, SMART_ACTION_MOVEMENT_PAUSE, SMART_ACTION_MOVEMENT_RESUME, SMART_ACTION_MOVEMENT_STOP, SMART_ACTION_MUSIC, SMART_ACTION_NO_ENVIRONMENT_UPDATE, SMART_ACTION_NONE, SMART_ACTION_OFFER_QUEST, SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT, SMART_ACTION_PLAY_CINEMATIC, SMART_ACTION_PLAY_EMOTE, SMART_ACTION_PLAY_SPELL_VISUAL, SMART_ACTION_PLAYER_TALK, SMART_ACTION_PLAYMOVIE, SMART_ACTION_RANDOM_EMOTE, SMART_ACTION_RANDOM_MOVE, SMART_ACTION_RANDOM_MUSIC, SMART_ACTION_RANDOM_PHASE, SMART_ACTION_RANDOM_PHASE_RANGE, SMART_ACTION_RANDOM_SOUND, SMART_ACTION_REMOVE_ALL_GAMEOBJECTS, SMART_ACTION_REMOVE_DYNAMIC_FLAG, SMART_ACTION_REMOVE_GO_FLAG, SMART_ACTION_REMOVE_IMMUNITY, SMART_ACTION_REMOVE_ITEM, SMART_ACTION_REMOVE_NPC_FLAG, SMART_ACTION_REMOVE_POWER, SMART_ACTION_REMOVE_TIMED_EVENT, SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1, SMART_ACTION_REMOVE_UNIT_FLAG, SMART_ACTION_REMOVEAURASFROMSPELL, SMART_ACTION_RESET_GOBJECT, SMART_ACTION_RESET_SCRIPT_BASE_OBJECT, SMART_ACTION_RESPAWN_TARGET, SMART_ACTION_RISE_UP, SMART_ACTION_SCRIPTED_SPAWN, SMART_ACTION_SELF_CAST, SMART_ACTION_SEND_GO_CUSTOM_ANIM, SMART_ACTION_SEND_GOSSIP_MENU, SMART_ACTION_SEND_TARGET_TO_TARGET, SMART_ACTION_SET_ACTIVE, SMART_ACTION_SET_ANIM_TIER, SMART_ACTION_SET_COMBAT_DISTANCE, SMART_ACTION_SET_CORPSE_DELAY, SMART_ACTION_SET_COUNTER, SMART_ACTION_SET_DATA, SMART_ACTION_SET_DYNAMIC_FLAG, SMART_ACTION_SET_EMOTE_STATE, SMART_ACTION_SET_EVENT_FLAG_RESET, SMART_ACTION_SET_EVENT_PHASE, SMART_ACTION_SET_FACTION, SMART_ACTION_SET_FLY, SMART_ACTION_SET_GO_FLAG, SMART_ACTION_SET_GOSSIP_MENU, SMART_ACTION_SET_GUID, SMART_ACTION_SET_HEALTH_PCT, SMART_ACTION_SET_HEALTH_REGEN, SMART_ACTION_SET_HOME_POS, SMART_ACTION_SET_HOVER, SMART_ACTION_SET_IN_COMBAT_WITH_ZONE, SMART_ACTION_SET_INGAME_PHASE_MASK, SMART_ACTION_SET_INST_DATA, SMART_ACTION_SET_INST_DATA64, SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL, SMART_ACTION_SET_MOVEMENT_SPEED, SMART_ACTION_SET_NPC_FLAG, SMART_ACTION_SET_ORIENTATION, SMART_ACTION_SET_ORIENTATION_TARGET, SMART_ACTION_SET_POWER, SMART_ACTION_SET_RANGED_MOVEMENT, SMART_ACTION_SET_REACT_STATE, SMART_ACTION_SET_ROOT, SMART_ACTION_SET_RUN, SMART_ACTION_SET_SCALE, SMART_ACTION_SET_SHEATH, SMART_ACTION_SET_SIGHT_DIST, SMART_ACTION_SET_SWIM, SMART_ACTION_SET_UNIT_FIELD_BYTES_1, SMART_ACTION_SET_UNIT_FLAG, SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS, SMART_ACTION_SET_VISIBILITY, SMART_ACTION_SIMPLE_TALK, SMART_ACTION_SOUND, SMART_ACTION_SPAWN_SPAWNGROUP, SMART_ACTION_START_CLOSEST_WAYPOINT, SMART_ACTION_STOP_MOTION, SMART_ACTION_STORE_TARGET_LIST, SMART_ACTION_SUMMON_CREATURE, SMART_ACTION_SUMMON_CREATURE_GROUP, SMART_ACTION_SUMMON_GAMEOBJECT_GROUP, SMART_ACTION_SUMMON_GO, SMART_ACTION_SUMMON_RADIAL, SMART_ACTION_TALK, SMART_ACTION_TELEPORT, SMART_ACTION_THREAT_ALL_PCT, SMART_ACTION_THREAT_SINGLE_PCT, SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT, SMART_ACTION_TRIGGER_TIMED_EVENT, SMART_ACTION_UPDATE_TEMPLATE, SMART_ACTION_VORTEX_SUMMON, SMART_ACTION_WAYPOINT_DATA_RANDOM, SMART_ACTION_WAYPOINT_START, SMART_ACTION_WORLD_SCRIPT, SMART_ACTION_ZONE_UNDER_ATTACK, SMART_ESCORT_TARGETS, SMART_EVENT_ESCORT_REACHED, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL, SMART_EVENT_LINK, SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_RANDOM_POINT, SMART_TARGET_NONE, SMART_TARGET_POSITION, SMART_TARGET_RANDOM_POINT, SMART_TARGET_SELF, SMART_WAYPOINT_MGR, SMARTCAST_AURA_NOT_PRESENT, SMARTCAST_COMBAT_MOVE, SMARTCAST_ENABLE_COMBAT_MOVE_ON_LOS, SMARTCAST_INTERRUPT_PREVIOUS, SMARTCAST_TARGET_POWER_MANA, SMARTCAST_THREATLIST_NOT_SINGLE, SMARTCAST_TRIGGERED, sObjectMgr, SmartAction::sound, SmartAction::sound1, SmartAction::sound2, SmartAction::sound3, SmartAction::sound4, SmartScriptHolder::source_type, Map::SpawnGroupDespawn(), Map::SpawnGroupSpawn(), SmartAction::spawnPos, SmartAction::spawnTimerMax, SmartAction::spawnTimerMin, SmartAction::speed, SmartAction::speedFraction, SmartAction::speedInteger, SmartAction::speedxy, SmartAction::speedz, SmartAction::spell, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_CAST_OK, SPELL_FAILED_OUT_OF_RANGE, SPELL_FAILED_SPELL_IN_PROGRESS, SmartAction::spell_id, SPELLVALUE_BASE_POINT0, SPELLVALUE_BASE_POINT1, SPELLVALUE_BASE_POINT2, SmartAction::spellVisual, sSmartWaypointMgr, sSpellMgr, SmartAction::startAngle, SmartAction::startClosestWaypoint, SmartAction::state, SmartAction::stepAngle, SmartAction::stopMotion, SmartAction::stopMovement, StoreCounter(), StoreTargetList(), SmartAction::storeTargets, SmartAction::subtract, SmartAction::summonCreature, WorldObject::SummonCreature(), WorldObject::SummonCreatureGroup(), SmartAction::summonDuration, SmartAction::summonEntry, WorldObject::SummonGameObject(), WorldObject::SummonGameObjectGroup(), SmartAction::summonGO, WorldObject::SummonTrigger(), SmartAction::summonVortex, sWaypointMgr, SmartAction::swim, sWorldState, CreatureAI::Talk(), SmartAction::talk, SmartScriptHolder::target, SmartAction::targetParam1, SmartAction::targetParam2, SmartAction::targetParam3, SmartAction::targetParam4, SmartAction::targetsLimit, SmartAction::targetsummon, SmartAction::targetType, SmartAction::taxi, TEAM_NEUTRAL, SmartAction::teleport, TEMPSUMMON_CORPSE_DESPAWN, TEMPSUMMON_TIMED_DESPAWN, TEXT_RANGE_NORMAL, SmartAction::textGroupID, SmartAction::textId, SmartAction::threat, SmartAction::threatDEC, SmartAction::threatINC, SmartAction::threatPCT, SmartAction::timedActionList, SmartAction::timeEvent, SmartAction::timer, Object::ToCreature(), Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), SmartAction::transport, trigger, TRIGGERED_FULL_MASK, TRIGGERED_NONE, SmartAction::triggerFlags, SmartAction::turnAngle, SmartEvent::type, SmartAction::type, SmartTarget::type, UNIT_DYNAMIC_FLAGS, UNIT_FIELD_BYTES_1, UNIT_FIELD_FLAGS, UNIT_FIELD_FLAGS_2, UNIT_FLAG_SILENCED, UNIT_NPC_EMOTESTATE, UNIT_STATE_LOST_CONTROL, UNIT_STATE_NO_COMBAT_MOVEMENT, UNIT_STATE_NO_ENVIRONMENT_UPD, UNIT_STATE_ROOT, UNIT_VIRTUAL_ITEM_SLOT_ID, SmartAction::unitFlag, SmartTarget::unitRange, SmartAction::updateLevel, SmartAction::updateTemplate, urand(), GameObject::UseDoorOrButton(), SmartAction::useTalkTarget, SmartAction::value, SmartAction::visibility, SmartAction::visualId, WAYPOINT_MGR, SmartAction::withDelayed, SmartAction::withEmote, SmartAction::withInstant, SmartAction::worldStateScript, SmartAction::wpData, SmartAction::wpDataRandom, SmartAction::wpPause, SmartAction::wpStart, SmartAction::wpStop, SmartTarget::x, WaypointNode::X, SmartTarget::y, WaypointNode::Y, SmartTarget::z, and WaypointNode::Z.

Referenced by ProcessEvent(), and ProcessTimedAction().

◆ ProcessEvent()

void SmartScript::ProcessEvent ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
4180{
4181 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4182 return;
4183
4185 return;
4186
4188 return;
4189
4190 switch (e.GetEventType())
4191 {
4192 case SMART_EVENT_LINK://special handling
4193 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4194 break;
4195 //called from Update tick
4196 case SMART_EVENT_UPDATE:
4198 break;
4200 if (me && me->IsEngaged())
4201 return;
4203 break;
4205 if (!me || !me->IsEngaged())
4206 return;
4208 break;
4210 {
4211 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4212 return;
4213 uint32 perc = (uint32)me->GetHealthPct();
4214 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4215 return;
4217 break;
4218 }
4220 {
4221 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4222 return;
4223 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4224 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4225 return;
4227 break;
4228 }
4230 {
4231 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4232 return;
4234 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4235 return;
4237 break;
4238 }
4240 {
4241 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4242 return;
4244 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4245 return;
4247 break;
4248 }
4249 case SMART_EVENT_RANGE:
4250 {
4251 if (!me || !me->IsEngaged() || !me->GetVictim())
4252 return;
4253
4256 else
4257 RecalcTimer(e, 1200, 1200); // make it predictable
4258
4259 break;
4260 }
4262 {
4263 if (!me || !me->IsEngaged())
4264 return;
4265
4266 Unit* victim = me->GetVictim();
4267
4268 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4269 return;
4270
4271 if (e.event.targetCasting.spellId > 0)
4272 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4273 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4274 return;
4275
4277 break;
4278 }
4280 {
4281 if (!me || !me->IsEngaged())
4282 return;
4283
4285 if (!target || !target->IsInCombat())
4286 {
4287 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4288 RecalcTimer(e, 1000, 3000);
4289 return;
4290 }
4292 break;
4293 }
4295 {
4296 if (!me || !me->IsEngaged())
4297 return;
4298
4299 std::vector<Creature*> creatures;
4301 if (creatures.empty())
4302 {
4303 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4304 RecalcTimer(e, 1000, 3000);
4305 return;
4306 }
4308 break;
4309 }
4311 {
4313 {
4314 return;
4315 }
4316
4317 std::vector<Creature*> creatures;
4319
4320 if (creatures.empty())
4321 return;
4322
4324 break;
4325 }
4327 {
4328 if (!me)
4329 return;
4330 uint32 count = me->GetAuraCount(e.event.aura.spell);
4331 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4333 break;
4334 }
4336 {
4337 if (!me || !me->GetVictim())
4338 return;
4340 if (count < e.event.aura.count)
4341 return;
4343 break;
4344 }
4346 {
4347 if (bvar == (e.event.charm.onRemove != 1))
4348 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4349 break;
4350 }
4351 //no params
4352 case SMART_EVENT_AGGRO:
4353 case SMART_EVENT_DEATH:
4354 case SMART_EVENT_EVADE:
4367 case SMART_EVENT_RESET:
4371 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4372 break;
4373
4375 switch (e.event.gossipHello.filter)
4376 {
4377 case 0:
4378 // no filter set, always execute action
4379 break;
4380 case 1:
4381 // GossipHello only filter set, skip action if reportUse
4382 if (var0)
4383 {
4384 return;
4385 }
4386 break;
4387 case 2:
4388 // reportUse only filter set, skip action if GossipHello
4389 if (!var0)
4390 {
4391 return;
4392 }
4393 break;
4394 default:
4395 // Ignore any other value
4396 break;
4397 }
4398
4399 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4400 break;
4402 {
4403 if (!me)
4404 return;
4405
4406 if (Unit* victim = me->GetVictim())
4407 {
4409 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4411 }
4412
4413 break;
4414 }
4416 {
4417 if (!me)
4418 return;
4419
4420 if (Unit* victim = me->GetVictim())
4421 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4422 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4424
4425 break;
4426 }
4428 if (e.event.emote.emote == var0)
4429 {
4430 ProcessAction(e, unit);
4431 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4432 }
4433 break;
4434 case SMART_EVENT_KILL:
4435 {
4436 if (!me || !unit)
4437 return;
4438 if (e.event.kill.playerOnly && !unit->IsPlayer())
4439 return;
4440 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4441 return;
4443 ProcessAction(e, unit);
4444 break;
4445 }
4448 {
4449 if (!spell)
4450 return;
4451 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4452 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4453 {
4455 ProcessAction(e, unit, 0, 0, bvar, spell);
4456 }
4457 break;
4458 }
4460 {
4461 if (!me || me->IsEngaged())
4462 return;
4463 //can trigger if closer than fMaxAllowedRange
4464 float range = (float)e.event.los.maxDist;
4465
4466 //if range is ok and we are actually in LOS
4467 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4468 {
4470 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4471 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4472 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4473 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4474 {
4475 if (e.event.los.playerOnly && !unit->IsPlayer())
4476 return;
4478 ProcessAction(e, unit);
4479 }
4480 }
4481 break;
4482 }
4483 case SMART_EVENT_IC_LOS:
4484 {
4485 if (!me || !me->IsEngaged())
4486 return;
4487 //can trigger if closer than fMaxAllowedRange
4488 float range = (float)e.event.los.maxDist;
4489
4490 //if range is ok and we are actually in LOS
4491 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4492 {
4494 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4495 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4496 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4497 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4498 {
4499 if (e.event.los.playerOnly && !unit->IsPlayer())
4500 return;
4502 ProcessAction(e, unit);
4503 }
4504 }
4505 break;
4506 }
4508 {
4509 if (!GetBaseObject())
4510 return;
4512 return;
4514 return;
4515 ProcessAction(e);
4516 break;
4517 }
4521 {
4522 if (!IsCreature(unit))
4523 return;
4524 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4525 return;
4527 ProcessAction(e, unit);
4528 break;
4529 }
4532 {
4533 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4534 return;
4536 ProcessAction(e, unit);
4537 break;
4538 }
4540 {
4541 if (e.event.minMaxRepeat.rangeMin) // health check mode
4542 {
4543 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4544 return;
4546 return;
4547 ProcessAction(e, unit);
4548 }
4549 else
4550 {
4551 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4552 return;
4554 ProcessAction(e, unit);
4555 }
4556 break;
4557 }
4559 {
4560 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4561 return;
4563 return;
4564 ProcessAction(e, unit, var0, var1);
4565 break;
4566 }
4569 {
4570 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4571 return;
4572 ProcessAction(e, unit, var0);
4573 break;
4574 }
4580 {
4581 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4582 return;
4583 ProcessAction(e, unit);
4584 break;
4585 }
4587 {
4588 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4589 return;
4591 ProcessAction(e, unit, var0);
4592 break;
4593 }
4595 {
4597 return;
4599 ProcessAction(e, unit, var0);
4600 break;
4601 }
4604 {
4605 if (e.event.quest.quest && var0 != e.event.quest.quest)
4606 return;
4607 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4608 ProcessAction(e, unit, var0);
4609 break;
4610 }
4612 {
4614 return;
4615 ProcessAction(e, unit, var0);
4616 break;
4617 }
4619 {
4620 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4621 return;
4622 ProcessAction(e, unit, var0);
4623 break;
4624 }
4626 {
4628 return;
4629 ProcessAction(e, unit, var0);
4630 break;
4631 }
4633 {
4634 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4635 return;
4637 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4638 break;
4639 }
4642 {
4643 if (!unit)
4644 return;
4646 ProcessAction(e, unit);
4647 break;
4648 }
4650 {
4651 if (e.event.timedEvent.id == var0)
4652 ProcessAction(e, unit);
4653 break;
4654 }
4656 {
4657 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4658 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4659 return;
4660 ProcessAction(e, unit, var0, var1);
4661 break;
4662 }
4664 {
4666 return;
4667
4668 ProcessAction(e);
4669 break;
4670 }
4673 {
4674 if (e.event.gameEvent.gameEventId != var0)
4675 return;
4676 ProcessAction(e, nullptr, var0);
4677 break;
4678 }
4680 {
4681 if (e.event.goStateChanged.state != var0)
4682 return;
4683 ProcessAction(e, unit, var0, var1);
4684 break;
4685 }
4687 {
4688 if (e.event.eventInform.eventId != var0)
4689 return;
4690 ProcessAction(e, nullptr, var0);
4691 break;
4692 }
4694 {
4695 if (e.event.doAction.eventId != var0)
4696 return;
4698 ProcessAction(e, unit, var0);
4699 break;
4700 }
4702 {
4703 if (!me || !me->IsEngaged())
4704 return;
4705
4706 Unit* unitTarget = nullptr;
4707 switch (e.GetTargetType())
4708 {
4716 {
4717 ObjectVector targets;
4718 GetTargets(targets, e);
4719 for (WorldObject* target : targets)
4720 {
4721 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4722 {
4723 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4724 if (healthPct > e.event.friendlyHealthPct.hpPct)
4725 {
4726 continue;
4727 }
4728
4729 unitTarget = target->ToUnit();
4730 break;
4731 }
4732 }
4733
4734 break;
4735 }
4736 case SMART_TARGET_SELF:
4739 break;
4740 default:
4741 return;
4742 }
4743
4744 if (!unitTarget)
4745 return;
4746
4748 break;
4749 }
4751 {
4752 if (!me)
4753 return;
4754
4755 WorldObject* creature = nullptr;
4756
4757 if (e.event.distance.guid != 0)
4758 {
4759 creature = FindCreatureNear(me, e.event.distance.guid);
4760
4761 if (!creature)
4762 return;
4763
4764 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4765 return;
4766 }
4767 else if (e.event.distance.entry != 0)
4768 {
4769 std::list<Creature*> list;
4771
4772 if (!list.empty())
4773 creature = list.front();
4774 }
4775
4776 if (creature)
4778
4779 break;
4780 }
4782 {
4783 if (!me)
4784 return;
4785
4786 WorldObject* gameobject = nullptr;
4787
4788 if (e.event.distance.guid != 0)
4789 {
4790 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4791
4792 if (!gameobject)
4793 return;
4794
4795 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4796 return;
4797 }
4798 else if (e.event.distance.entry != 0)
4799 {
4800 std::list<GameObject*> list;
4802
4803 if (!list.empty())
4804 gameobject = list.front();
4805 }
4806
4807 if (gameobject)
4809
4810 break;
4811 }
4813 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4814 return;
4815
4817 break;
4819 {
4820 uint32 playerCount = 0;
4821 ObjectVector targets;
4822 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4823
4824 if (!targets.empty())
4825 {
4826 for (WorldObject* target : targets)
4827 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4828 playerCount++;
4829
4830 if (playerCount >= e.event.nearPlayer.minCount)
4831 ProcessAction(e, unit);
4832 }
4834 break;
4835 }
4837 {
4838 uint32 playerCount = 0;
4839 ObjectVector targets;
4840 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4841
4842 if (!targets.empty())
4843 {
4844 for (WorldObject* target : targets)
4845 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4846 playerCount++;
4847
4848 if (playerCount < e.event.nearPlayerNegation.maxCount)
4849 ProcessAction(e, unit);
4850 }
4852 break;
4853 }
4855 {
4856 uint32 unitCount = 0;
4857 ObjectVector targets;
4858 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4859
4860 if (!targets.empty())
4861 {
4862 if (e.event.nearUnit.type)
4863 {
4864 for (WorldObject* target : targets)
4865 {
4866 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4867 unitCount++;
4868 }
4869 }
4870 else
4871 {
4872 for (WorldObject* target : targets)
4873 {
4874 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4875 unitCount++;
4876 }
4877 }
4878
4879 if (unitCount >= e.event.nearUnit.count)
4880 ProcessAction(e, unit);
4881 }
4883 break;
4884 }
4886 {
4887 uint32 unitCount = 0;
4888 ObjectVector targets;
4889 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4890
4891 if (!targets.empty())
4892 {
4894 {
4895 for (WorldObject* target : targets)
4896 {
4897 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4898 unitCount++;
4899 }
4900 }
4901 else
4902 {
4903 for (WorldObject* target : targets)
4904 {
4905 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4906 unitCount++;
4907 }
4908 }
4909
4910 if (unitCount < e.event.nearUnitNegation.count)
4911 ProcessAction(e, unit);
4912 }
4914 break;
4915 }
4917 {
4918 if (!me || !me->IsEngaged())
4919 return;
4920
4921 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4922 {
4923 if (Unit* target = ref->GetVictim())
4924 {
4925 if (!IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4926 continue;
4927
4928 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4929 continue;
4930
4931 ProcessAction(e, target);
4933 return;
4934 }
4935 }
4936
4937 // No targets found
4939
4940 break;
4941 }
4943 {
4944 if (!me || !me->IsEngaged())
4945 return;
4946
4947 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4948 {
4949 if (Unit* target = ref->GetVictim())
4950 {
4951 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4952 continue;
4953
4954 ProcessAction(e, target);
4956 return;
4957 }
4958 }
4959
4960 // If no targets are found and it's off cooldown, check again
4961 RecalcTimer(e, 1200, 1200);
4962 break;
4963 }
4966 {
4967 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4968 return;
4969 ProcessAction(e, unit);
4970 break;
4971 }
4972 default:
4973 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4974 break;
4975 }
4976}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1961
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:536
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:535
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:106
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:171
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:134
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:107
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:121
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:150
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:152
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:129
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:117
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:148
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:101
@ SMART_EVENT_ESCORT_START
Definition SmartScriptMgr.h:138
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:165
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:145
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:172
@ SMART_EVENT_ESCORT_PAUSED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_ESCORT_RESUMED
Definition SmartScriptMgr.h:155
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:127
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:144
@ SMART_EVENT_ESCORT_ENDED
Definition SmartScriptMgr.h:157
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:120
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:141
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:119
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:170
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:128
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:130
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:167
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:104
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:142
@ SMART_EVENT_ESCORT_STOPPED
Definition SmartScriptMgr.h:156
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:163
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:161
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:135
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:196
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:126
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:140
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:198
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:118
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:176
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:115
@ SMART_EVENT_WAYPOINT_REACHED
Definition SmartScriptMgr.h:197
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:123
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:110
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:113
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:149
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:105
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:143
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:131
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:164
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:147
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:183
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:114
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:103
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:111
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:112
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:132
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:122
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:116
@ CURRENT_GENERIC_SPELL
Definition Unit.h:556
uint32 GetWaypointPath() const
Definition Creature.h:357
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5437
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5427
void ProcessAction(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:164
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5520
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5400
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5566
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5413
void ProcessTimedAction(SmartScriptHolder &e, uint32 const &min, uint32 const &max, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:3418
Definition Spell.h:298
float GetHealthPct() const
Definition Unit.h:1110
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4304
uint32 GetMaxHealth() const
Definition Unit.h:1109
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:783
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5978
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1136
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7276
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:1117
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:7271
bool IsInCombat() const
Definition Unit.h:935
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1576
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2545
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2559
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1377
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:148
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:253
uint32 pointId
Definition SmartScriptMgr.h:508
uint32 invert
Definition SmartScriptMgr.h:494
uint32 entry
Definition SmartScriptMgr.h:447
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:339
LOSHostilityMode
Definition SmartScriptMgr.h:524
uint32 cooldownMax
Definition SmartScriptMgr.h:225
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:353
uint32 radius
Definition SmartScriptMgr.h:273
uint32 maxDist
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:397
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:233
uint32 rangeMin
Definition SmartScriptMgr.h:218
uint32 eventId
Definition SmartScriptMgr.h:424
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:446
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:448
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:267
uint32 emote
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:440
uint32 filter
Definition SmartScriptMgr.h:392
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:243
uint32 hpDeficit
Definition SmartScriptMgr.h:272
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:254
uint32 count
Definition SmartScriptMgr.h:318
uint32 onlyInCombat
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:346
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:354
SAIBool playerOnly
Definition SmartScriptMgr.h:226
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:340
uint32 creatureEntry
Definition SmartScriptMgr.h:382
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:398
struct SmartEvent::@30::@64 doAction
struct SmartEvent::@30::@46 charm
struct SmartEvent::@30::@63 eventInform
struct SmartEvent::@30::@38 targetCasting
uint32 spell
Definition SmartScriptMgr.h:232
uint32 maxCount
Definition SmartScriptMgr.h:471
uint32 gameEventId
Definition SmartScriptMgr.h:414
uint32 textGroupID
Definition SmartScriptMgr.h:381
uint32 cooldownMin
Definition SmartScriptMgr.h:224
uint32 onRemove
Definition SmartScriptMgr.h:325
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:303
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:419
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:219
uint32 team
Definition SmartScriptMgr.h:369
uint32 range
Definition SmartScriptMgr.h:483
uint32 minCount
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@37 minMax
struct SmartEvent::@30::@55 textOver
struct SmartEvent::@30::@40 friendlyCC
struct SmartEvent::@30::@62 goStateChanged
uint32 creature
Definition SmartScriptMgr.h:227
uint32 phasemask
Definition SmartScriptMgr.h:409

References SmartEvent::action, SmartScriptHolder::active, SmartEvent::Any, SmartEvent::area, SmartEvent::areatrigger, SmartEvent::aura, SmartEvent::charm, SmartEvent::cooldownMax, SmartEvent::cooldownMin, SmartEvent::count, SmartEvent::counter, SmartEvent::creature, SmartEvent::creatureEntry, CURRENT_GENERIC_SPELL, SmartEvent::dataSet, SmartEvent::dist, SmartEvent::distance, SmartEvent::doAction, DoFindFriendlyCC(), DoFindFriendlyMissingBuff(), DoSelectLowestHpFriendly(), DoSelectLowestHpPercentFriendly(), SmartEvent::emote, SmartEvent::entry, SmartScriptHolder::event, SmartEvent::event_flags, SmartEvent::event_phase_mask, SmartEvent::eventId, SmartEvent::eventInform, SmartEvent::eventPhaseChange, SmartEvent::filter, FindCreatureNear(), FindGameObjectNear(), SmartEvent::friendlyCC, SmartEvent::friendlyHealth, SmartEvent::friendlyHealthPct, SmartEvent::gameEvent, SmartEvent::gameEventId, Unit::GetAuraCount(), GetBaseObject(), GetCounterValue(), WorldObject::GetCreatureListWithEntryInGrid(), Unit::GetCurrentSpell(), Object::GetEntry(), SmartScriptHolder::GetEventType(), WorldObject::GetGameObjectListWithEntryInGrid(), Unit::GetHealthPct(), Unit::GetMaxHealth(), Unit::GetMaxPower(), GetPathId(), Unit::GetPowerPct(), GetTargets(), SmartScriptHolder::GetTargetType(), Unit::GetThreatMgr(), ThreatManager::GetUnsortedThreatList(), Unit::GetVictim(), Creature::GetWaypointPath(), GetWorldObjectsInDist(), SmartEvent::gossip, SmartEvent::gossipHello, SmartEvent::goStateChanged, SmartEvent::guid, Unit::HealthBelowPctDamaged(), SmartEvent::Hostile, SmartEvent::hostilityMode, SmartEvent::hpDeficit, SmartEvent::hpPct, SmartEvent::id, SpellInfo::Id, SmartEvent::instancePlayerEnter, SmartEvent::invert, IsCharmedCreature(), IsCreature(), Creature::IsEngaged(), Unit::IsFriendlyTo(), IsGameObject(), Unit::IsHostileTo(), Unit::IsInCombat(), IsInPhase(), WorldObject::IsInRange(), Unit::IsNonMeleeSpellCast(), Object::IsPlayer(), IsPlayer(), IsUnit(), WorldObject::IsWithinDistInMap(), WorldObject::IsWithinLOSInMap(), Unit::IsWithinMeleeRange(), SmartEvent::kill, LOG_DEBUG, LOG_ERROR, SmartEvent::los, SmartEvent::map, SmartEvent::max, SmartEvent::maxCount, SmartEvent::maxDist, me, SmartEvent::meleeRange, SmartEvent::min, SmartEvent::minCount, SmartEvent::minMax, SmartEvent::minMaxRepeat, SmartEvent::missingBuff, SmartEvent::movementInform, SmartEvent::nearPlayer, SmartEvent::nearPlayerNegation, SmartEvent::nearUnit, SmartEvent::nearUnitNegation, SmartEvent::NotHostile, SmartEvent::onlyInCombat, SmartEvent::onRemove, SmartEvent::pathId, SmartEvent::pathID, SmartEvent::phasemask, SmartEvent::playerOnly, SmartEvent::pointID, SmartEvent::pointId, POWER_MANA, ProcessAction(), ProcessTimedAction(), SmartEvent::quest, SmartEvent::radius, SmartEvent::range, SmartEvent::rangeMax, SmartEvent::rangeMin, RecalcTimer(), SmartEvent::repeat, SmartEvent::repeatMax, SmartEvent::repeatMin, SmartEvent::respawn, SmartScriptHolder::runOnce, SmartEvent::school, SpellInfo::SchoolMask, Acore::Containers::SelectRandomContainerElement(), SmartEvent::sender, SMART_EVENT_ACCEPTED_QUEST, SMART_EVENT_ACTION_DONE, SMART_EVENT_AGGRO, SMART_EVENT_AI_INIT, SMART_EVENT_AREA_CASTING, SMART_EVENT_AREA_RANGE, SMART_EVENT_AREATRIGGER_ONTRIGGER, SMART_EVENT_CHARMED, SMART_EVENT_CHARMED_TARGET, SMART_EVENT_CORPSE_REMOVED, SMART_EVENT_COUNTER_SET, SMART_EVENT_DAMAGED, SMART_EVENT_DAMAGED_TARGET, SMART_EVENT_DATA_SET, SMART_EVENT_DEATH, SMART_EVENT_DISTANCE_CREATURE, SMART_EVENT_DISTANCE_GAMEOBJECT, SMART_EVENT_ESCORT_ENDED, SMART_EVENT_ESCORT_PAUSED, SMART_EVENT_ESCORT_REACHED, SMART_EVENT_ESCORT_RESUMED, SMART_EVENT_ESCORT_START, SMART_EVENT_ESCORT_STOPPED, SMART_EVENT_EVADE, SMART_EVENT_EVENT_PHASE_CHANGE, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_FLAG_WHILE_CHARMED, SMART_EVENT_FOLLOW_COMPLETED, SMART_EVENT_FRIENDLY_HEALTH, SMART_EVENT_FRIENDLY_HEALTH_PCT, SMART_EVENT_FRIENDLY_IS_CC, SMART_EVENT_FRIENDLY_MISSING_BUFF, SMART_EVENT_GAME_EVENT_END, SMART_EVENT_GAME_EVENT_START, SMART_EVENT_GO_EVENT_INFORM, SMART_EVENT_GO_STATE_CHANGED, SMART_EVENT_GOSSIP_HELLO, SMART_EVENT_GOSSIP_SELECT, SMART_EVENT_HAS_AURA, SMART_EVENT_HEALTH_PCT, SMART_EVENT_IC_LOS, SMART_EVENT_INSTANCE_PLAYER_ENTER, SMART_EVENT_IS_BEHIND_TARGET, SMART_EVENT_IS_IN_MELEE_RANGE, SMART_EVENT_JUST_CREATED, SMART_EVENT_JUST_SUMMONED, SMART_EVENT_KILL, SMART_EVENT_LINK, SMART_EVENT_MANA_PCT, SMART_EVENT_MOVEMENTINFORM, SMART_EVENT_NEAR_PLAYERS, SMART_EVENT_NEAR_PLAYERS_NEGATION, SMART_EVENT_NEAR_UNIT, SMART_EVENT_NEAR_UNIT_NEGATION, SMART_EVENT_ON_SPELLCLICK, SMART_EVENT_OOC_LOS, SMART_EVENT_PASSENGER_BOARDED, SMART_EVENT_PASSENGER_REMOVED, SMART_EVENT_QUEST_ACCEPTED, SMART_EVENT_QUEST_COMPLETION, SMART_EVENT_QUEST_FAIL, SMART_EVENT_QUEST_OBJ_COMPLETION, SMART_EVENT_QUEST_REWARDED, SMART_EVENT_RANGE, SMART_EVENT_REACHED_HOME, SMART_EVENT_RECEIVE_EMOTE, SMART_EVENT_RECEIVE_HEAL, SMART_EVENT_RESET, SMART_EVENT_RESPAWN, SMART_EVENT_REWARD_QUEST, SMART_EVENT_SPELLHIT, SMART_EVENT_SPELLHIT_TARGET, SMART_EVENT_SUMMON_DESPAWNED, SMART_EVENT_SUMMONED_UNIT, SMART_EVENT_SUMMONED_UNIT_DIES, SMART_EVENT_SUMMONED_UNIT_EVADE, SMART_EVENT_TARGET_BUFFED, SMART_EVENT_TARGET_HEALTH_PCT, SMART_EVENT_TARGET_MANA_PCT, SMART_EVENT_TEXT_OVER, SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_EVENT_TRANSPORT_ADDCREATURE, SMART_EVENT_TRANSPORT_ADDPLAYER, SMART_EVENT_TRANSPORT_RELOCATE, SMART_EVENT_TRANSPORT_REMOVE_PLAYER, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_UPDATE_OOC, SMART_EVENT_VICTIM_CASTING, SMART_EVENT_WAYPOINT_ENDED, SMART_EVENT_WAYPOINT_REACHED, SMART_SCRIPT_RESPAWN_CONDITION_AREA, SMART_SCRIPT_RESPAWN_CONDITION_MAP, SMART_TARGET_ACTION_INVOKER, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_PLAYER_DISTANCE, SMART_TARGET_PLAYER_RANGE, SMART_TARGET_SELF, SmartEvent::spell, SmartEvent::spellHit, SmartEvent::spellId, SmartEvent::state, SmartEvent::summoned, SmartEvent::targetCasting, SmartEvent::team, SmartEvent::textGroupID, SmartEvent::textOver, SmartEvent::timedEvent, SmartEvent::timer, Object::ToUnit(), SmartEvent::transportAddCreature, SmartEvent::type, SmartEvent::value, SmartEvent::waypoint, and SmartEvent::wpData.

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

void SmartScript::ProcessEventsFor ( SMART_EVENT  e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
137{
138 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
139 {
140 SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
141 if (eventType == SMART_EVENT_LINK)//special handling
142 continue;
143
144 if (eventType == e)
145 {
146 ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
147 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
148
149 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
150 {
151 ASSERT(executionStack.empty());
152 executionStack.emplace_back(SmartScriptFrame{ *i, unit, var0, var1, bvar, spell, gob });
153 while (!executionStack.empty())
154 {
155 auto [stack_holder , stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
156 executionStack.pop_back();
157 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
158 }
159 }
160 }
161 }
162}
#define sConditionMgr
Definition ConditionMgr.h:296
std::list< Condition * > ConditionList
Definition ConditionMgr.h:240
#define ASSERT
Definition Errors.h:68
void ProcessEvent(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:4179
Definition ConditionMgr.h:185

References ASSERT, executionStack, GetBaseObject(), Unit::GetVictim(), me, mEvents, ProcessEvent(), sConditionMgr, and SMART_EVENT_LINK.

Referenced by SmartAI::CorpseRemoved(), SmartAI::DamageDealt(), SmartAI::DamageTaken(), SmartGameObjectAI::Destroyed(), SmartAI::DoAction(), SmartAI::EndPath(), SmartAI::EnterEvadeMode(), SmartGameObjectAI::EventInform(), SmartGameObjectAI::GossipHello(), SmartGameObjectAI::GossipSelect(), SmartAI::HealReceived(), SmartAI::InitializeAI(), SmartGameObjectAI::InitializeAI(), SmartAI::IsSummonedBy(), SmartAI::JustDied(), SmartAI::JustEngagedWith(), SmartAI::JustReachedHome(), SmartAI::JustRespawned(), SmartAI::JustSummoned(), SmartGameObjectAI::JustSummoned(), SmartAI::KilledUnit(), SmartAI::MovementInform(), SmartAI::MovepointReached(), SmartAI::OnCharmed(), SmartGameObjectAI::OnGameEvent(), OnInitialize(), OnMoveInLineOfSight(), OnReset(), SmartAI::OnSpellClick(), SmartGameObjectAI::OnStateChanged(), SmartTrigger::OnTrigger(), OnUpdate(), SmartAI::PassengerBoarded(), SmartAI::PathEndReached(), SmartAI::PausePath(), ProcessAction(), SmartGameObjectAI::QuestAccept(), SmartGameObjectAI::QuestReward(), SmartAI::ReceiveEmote(), SmartGameObjectAI::Reset(), SmartAI::SetData(), SmartGameObjectAI::SetData(), SetPhase(), SmartAI::sGossipHello(), SmartAI::sGossipSelect(), SmartAI::sOnGameEvent(), SmartAI::SpellHit(), SmartGameObjectAI::SpellHit(), SmartAI::SpellHitTarget(), SmartAI::sQuestAccept(), SmartAI::sQuestReward(), SmartAI::StartPath(), SmartAI::StopFollow(), SmartAI::StopPath(), StoreCounter(), SmartAI::SummonedCreatureDespawn(), SmartGameObjectAI::SummonedCreatureDespawn(), SmartAI::SummonedCreatureDies(), SmartGameObjectAI::SummonedCreatureDies(), SmartAI::SummonedCreatureEvade(), SmartGameObjectAI::SummonedCreatureEvade(), SmartAI::UpdatePath(), SmartAI::WaypointPathEnded(), and SmartAI::WaypointReached().

◆ ProcessTimedAction()

void SmartScript::ProcessTimedAction ( SmartScriptHolder e,
uint32 const &  min,
uint32 const &  max,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
3419{
3420 // xinef: extended by selfs victim
3421 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3422 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3423
3424 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3425 {
3426 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3427 RecalcTimer(e, min, max);
3428 }
3429 else
3430 RecalcTimer(e, 5000, 5000);
3431}

References SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, GetBaseObject(), Unit::GetVictim(), me, ProcessAction(), RecalcTimer(), sConditionMgr, and SmartScriptHolder::source_type.

Referenced by ProcessEvent().

◆ RaisePriority()

void SmartScript::RaisePriority ( SmartScriptHolder e)
private
5214{
5215 e.timer = 1200;
5216 // Change priority only if it's set to default, otherwise keep the current order of events
5218 {
5220 mEventSortingRequired = true;
5221 }
5222}
uint32 timer
Definition SmartScriptMgr.h:2019
uint32 priority
Definition SmartScriptMgr.h:2020

References SmartScriptHolder::DEFAULT_PRIORITY, mCurrentPriority, mEventSortingRequired, SmartScriptHolder::priority, and SmartScriptHolder::timer.

Referenced by RetryLater(), and UpdateTimer().

◆ RecalcTimer()

void SmartScript::RecalcTimer ( SmartScriptHolder e,
uint32  min,
uint32  max 
)
static
5012{
5013 // min/max was checked at loading!
5014 e.timer = urand(uint32(min), uint32(max));
5015 e.active = e.timer ? false : true;
5016}

References SmartScriptHolder::active, SmartScriptHolder::timer, and urand().

Referenced by InitTimer(), ProcessEvent(), and ProcessTimedAction().

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5582{
5583 _summonList.erase(guid);
5584}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

void SmartScript::RemoveStoredEvent ( uint32  id)
inlineprivate
255 {
256 if (!mStoredEvents.empty())
257 {
258 for (SmartAIEventStoredList::iterator i = mStoredEvents.begin(); i != mStoredEvents.end(); ++i)
259 {
260 if (i->event_id == id)
261 {
262 mStoredEvents.erase(i);
263 return;
264 }
265 }
266 }
267 }

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

void SmartScript::ResetBaseObject ( )
inline
167 {
168 WorldObject* lookupRoot = me;
169 if (!lookupRoot)
170 lookupRoot = go;
171
172 if (lookupRoot)
173 {
174 if (meOrigGUID)
175 {
176 if (Creature* m = ObjectAccessor::GetCreature(*lookupRoot, meOrigGUID))
177 {
178 me = m;
179 go = nullptr;
180 }
181 }
182
183 if (goOrigGUID)
184 {
186 {
187 me = nullptr;
188 go = o;
189 }
190 }
191 }
192
195 }
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:184
Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:210

References ObjectGuid::Clear(), ObjectAccessor::GetCreature(), ObjectAccessor::GetGameObject(), go, goOrigGUID, me, and meOrigGUID.

Referenced by OnReset(), and ProcessAction().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
5225{
5226 RaisePriority(e);
5227
5228 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5229 if (ignoreChanceRoll)
5231
5232 e.runOnce = false;
5233}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5213

References SmartScriptHolder::event, SmartEvent::event_flags, RaisePriority(), SmartScriptHolder::runOnce, and SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL.

Referenced by ProcessAction().

◆ SetPathId()

void SmartScript::SetPathId ( uint32  id)
inline
62{ mPathId = id; }

References mPathId.

Referenced by SmartAI::EndPath(), and SmartAI::LoadPath().

◆ SetPhase()

void SmartScript::SetPhase ( uint32  p)
private
5555{
5556 uint32 oldPhase = mEventPhase;
5557
5558 mEventPhase = p;
5559
5560 if (oldPhase != mEventPhase)
5561 {
5563 }
5564}

References mEventPhase, ProcessEventsFor(), and SMART_EVENT_EVENT_PHASE_CHANGE.

Referenced by DecPhase(), IncPhase(), OnReset(), and ProcessAction().

◆ SetPhaseReset()

void SmartScript::SetPhaseReset ( bool  allow)
inline
205{ _allowPhaseReset = allow; }

References _allowPhaseReset.

Referenced by ProcessAction().

◆ SetScript9()

void SmartScript::SetScript9 ( SmartScriptHolder e,
uint32  entry 
)
5460{
5461 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5462 // any SmartScriptHolder contained like the "e" parameter passed to this function
5464 {
5465 LOG_ERROR("scripts.ai.sai", "Entry {} SourceType {} Event {} Action {} is trying to overwrite timed action list from a timed action, this is not allowed!.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
5466 return;
5467 }
5468
5469 // Do NOT allow to start a new actionlist if a previous one is already running, unless explicitly allowed. We need to always finish the current actionlist
5471 {
5472 return;
5473 }
5474
5475 mTimedActionList.clear();
5477 if (mTimedActionList.empty())
5478 return;
5479 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5480 {
5481 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5482
5483 if (e.action.timedActionList.timerType == 0)
5484 i->event.type = SMART_EVENT_UPDATE_OOC;
5485 else if (e.action.timedActionList.timerType == 1)
5486 i->event.type = SMART_EVENT_UPDATE_IC;
5487 else if (e.action.timedActionList.timerType > 1)
5488 i->event.type = SMART_EVENT_UPDATE;
5489
5490 InitTimer((*i));
5491 }
5492}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1803
SAIBool allowOverride
Definition SmartScriptMgr.h:1152
uint32 timerType
Definition SmartScriptMgr.h:1151

References SmartScriptHolder::action, SmartAction::allowOverride, SmartScriptHolder::entryOrGuid, SmartScriptHolder::GetActionType(), SmartScriptHolder::GetEventType(), SmartScriptHolder::GetScriptType(), InitTimer(), isProcessingTimedActionList, LOG_ERROR, mTimedActionList, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_UPDATE_OOC, SMART_SCRIPT_TYPE_TIMED_ACTIONLIST, sSmartScriptMgr, SmartAction::timedActionList, and SmartAction::timerType.

Referenced by ProcessAction(), SmartAI::SetScript9(), and SmartGameObjectAI::SetScript9().

◆ SortEvents()

void SmartScript::SortEvents ( SmartAIEventList events)
private
5209{
5210 std::sort(events.begin(), events.end());
5211}
events
Definition boss_sartura.cpp:43

Referenced by OnUpdate().

◆ StoreCounter()

void SmartScript::StoreCounter ( uint32  id,
uint32  value,
uint32  reset,
uint32  subtract 
)
inline
109 {
110 CounterMap::iterator itr = mCounterList.find(id);
111 if (itr != mCounterList.end())
112 {
113 if (!reset && !subtract)
114 {
115 itr->second += value;
116 }
117 else if (subtract)
118 {
119 itr->second -= value;
120 }
121 else
122 {
123 itr->second = value;
124 }
125 }
126 else
127 {
128 mCounterList.insert(std::make_pair(id, value));
129 }
130
132 }

References mCounterList, ProcessEventsFor(), and SMART_EVENT_COUNTER_SET.

Referenced by ProcessAction().

◆ StoreTargetList()

void SmartScript::StoreTargetList ( ObjectVector const &  targets,
uint32  id 
)
inline
94 {
95 // insert or replace
96 _storedTargets.erase(id);
97 _storedTargets.emplace(id, ObjectGuidVector(targets));
98 }
Definition SmartScriptMgr.h:2037

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
5019{
5020 if (e.GetEventType() == SMART_EVENT_LINK)
5021 return;
5022
5024 return;
5025
5026 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
5027 return;
5028
5029 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
5030 return;
5031
5032 if (e.timer < diff)
5033 {
5034 // delay spell cast for another AI tick if another spell is being cast
5036 {
5038 {
5040 {
5041 RaisePriority(e);
5042 return;
5043 }
5044 }
5045 }
5046
5047 // Delay flee for assist event if casting
5049 {
5050 e.timer = 1200;
5051 return;
5052 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
5053
5054 e.active = true;//activate events with cooldown
5055 switch (e.GetEventType())//process ONLY timed events
5056 {
5061 case SMART_EVENT_UPDATE:
5068 case SMART_EVENT_RANGE:
5082 {
5083 ASSERT(executionStack.empty());
5084 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
5085 while (!executionStack.empty())
5086 {
5087 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
5088 executionStack.pop_back();
5089 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
5090 }
5092 {
5093 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
5094 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5095 {
5096 //find the first event which is not the current one and enable it
5097 if (i->event_id > e.event_id)
5098 {
5099 i->enableTimed = true;
5100 break;
5101 }
5102 }
5103 }
5104 break;
5105 }
5106 }
5107
5109 {
5110 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
5111 if (e.timer > 1)
5112 {
5113 // Re-sort events if this was moved to the top of the queue
5114 mEventSortingRequired = true;
5115 // Reset priority to default one
5117 }
5118 }
5119 }
5120 else
5121 e.timer -= diff;
5122}
@ UNIT_STATE_CASTING
Definition UnitDefines.h:188
bool enableTimed
Definition SmartScriptMgr.h:2023

References SmartScriptHolder::action, SmartScriptHolder::active, ASSERT, SmartAction::cast, SmartAction::castFlags, SmartScriptHolder::DEFAULT_PRIORITY, SmartScriptHolder::enableTimed, SmartScriptHolder::event, SmartScriptHolder::event_id, SmartEvent::event_phase_mask, executionStack, SmartScriptHolder::GetActionType(), SmartScriptHolder::GetEventType(), SmartScriptHolder::GetScriptType(), Unit::HasUnitState(), Creature::IsEngaged(), IsInPhase(), me, mEventSortingRequired, mTimedActionList, SmartScriptHolder::priority, ProcessEvent(), RaisePriority(), SMART_ACTION_CAST, SMART_ACTION_FLEE_FOR_ASSIST, SMART_EVENT_AREA_CASTING, SMART_EVENT_AREA_RANGE, SMART_EVENT_DISTANCE_CREATURE, SMART_EVENT_DISTANCE_GAMEOBJECT, SMART_EVENT_FRIENDLY_HEALTH, SMART_EVENT_FRIENDLY_HEALTH_PCT, SMART_EVENT_FRIENDLY_IS_CC, SMART_EVENT_FRIENDLY_MISSING_BUFF, SMART_EVENT_HAS_AURA, SMART_EVENT_HEALTH_PCT, SMART_EVENT_IS_BEHIND_TARGET, SMART_EVENT_IS_IN_MELEE_RANGE, SMART_EVENT_LINK, SMART_EVENT_MANA_PCT, SMART_EVENT_NEAR_PLAYERS, SMART_EVENT_NEAR_PLAYERS_NEGATION, SMART_EVENT_NEAR_UNIT, SMART_EVENT_NEAR_UNIT_NEGATION, SMART_EVENT_RANGE, SMART_EVENT_TARGET_BUFFED, SMART_EVENT_TARGET_HEALTH_PCT, SMART_EVENT_TARGET_MANA_PCT, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_UPDATE_OOC, SMART_EVENT_VICTIM_CASTING, SMART_SCRIPT_TYPE_TIMED_ACTIONLIST, SMARTCAST_INTERRUPT_PREVIOUS, SmartScriptHolder::timer, and UNIT_STATE_CASTING.

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ executionStack

std::deque<SmartScriptFrame> SmartScript::executionStack
private

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

Referenced by OnUpdate(), SetScript9(), and SmartScript().

◆ mCounterList

CounterMap SmartScript::mCounterList

◆ mCurrentPriority

uint32 SmartScript::mCurrentPriority
private

Referenced by RaisePriority(), and SmartScript().

◆ me

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

◆ mEvents

◆ mEventSortingRequired

bool SmartScript::mEventSortingRequired
private

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Referenced by AddEvent(), and InstallEvents().

◆ mLastInvoker

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

◆ mPathId

uint32 SmartScript::mPathId
private

Referenced by GetPathId(), SetPathId(), and SmartScript().

◆ mRemIDs

std::list<uint32> SmartScript::mRemIDs
private

Referenced by OnUpdate(), and ProcessAction().

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

std::unordered_map<int32, int32> SmartScript::mStoredDecimals
private

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

◆ mTemplate

SMARTAI_TEMPLATE SmartScript::mTemplate
private

Referenced by InstallTemplate(), and SmartScript().

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

Referenced by OnUpdate(), SetScript9(), and UpdateTimer().

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

◆ trigger

AreaTrigger const* SmartScript::trigger
private

The documentation for this class was generated from the following files: