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)
 

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
47{
48 go = nullptr;
49 me = nullptr;
50 trigger = nullptr;
51 mEventPhase = 0;
52 mPathId = 0;
53 mTextTimer = 0;
54 mLastTextID = 0;
55 mUseTextTimer = false;
56 mTalkerEntry = 0;
62 _allowPhaseReset = true;
63}
@ SMART_SCRIPT_TYPE_CREATURE
Definition SmartScriptMgr.h:1763
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1516
uint32 mEventPhase
Definition SmartScript.h:230
SMARTAI_TEMPLATE mTemplate
Definition SmartScript.h:249
Creature * me
Definition SmartScript.h:224
uint32 mPathId
Definition SmartScript.h:233
SmartScriptType mScriptType
Definition SmartScript.h:229
bool _allowPhaseReset
Definition SmartScript.h:245
bool mUseTextTimer
Definition SmartScript.h:240
uint32 mLastTextID
Definition SmartScript.h:238
uint32 mTextTimer
Definition SmartScript.h:237
GameObject * go
Definition SmartScript.h:226
AreaTrigger const * trigger
Definition SmartScript.h:228
uint32 mCurrentPriority
Definition SmartScript.h:241
uint32 mTalkerEntry
Definition SmartScript.h:239
bool isProcessingTimedActionList
Definition SmartScript.h:223
bool mEventSortingRequired
Definition SmartScript.h:242

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 ( )
66{
67}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5423{
5424 _summonList.insert(guid);
5425}
GuidUnorderedSet _summonList
Definition SmartScript.h:282

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 
)
3409{
3410 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));
3411}
SmartAIEventList mInstallEvents
Definition SmartScript.h:221
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:3413

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
4971{
4972 return e.active;
4973}

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
3414{
3415 SmartScriptHolder script;
3416 script.event.type = e;
3417 script.event.raw.param1 = event_param1;
3418 script.event.raw.param2 = event_param2;
3419 script.event.raw.param3 = event_param3;
3420 script.event.raw.param4 = event_param4;
3421 script.event.raw.param5 = event_param5;
3422 script.event.raw.param6 = event_param6;
3423 script.event.event_phase_mask = phaseMask;
3424 script.event.event_flags = event_flags;
3425 script.event.event_chance = 100;
3426
3427 script.action.type = action;
3428 script.action.raw.param1 = action_param1;
3429 script.action.raw.param2 = action_param2;
3430 script.action.raw.param3 = action_param3;
3431 script.action.raw.param4 = action_param4;
3432 script.action.raw.param5 = action_param5;
3433 script.action.raw.param6 = action_param6;
3434
3435 script.target.type = t;
3436 script.target.raw.param1 = target_param1;
3437 script.target.raw.param2 = target_param2;
3438 script.target.raw.param3 = target_param3;
3439 script.target.raw.param4 = target_param4;
3440
3442 InitTimer(script);
3443 return script;
3444}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4824
uint32 param3
Definition SmartScriptMgr.h:1074
uint32 param5
Definition SmartScriptMgr.h:1076
uint32 param1
Definition SmartScriptMgr.h:1072
SMART_ACTION type
Definition SmartScriptMgr.h:759
uint32 param4
Definition SmartScriptMgr.h:1075
uint32 param6
Definition SmartScriptMgr.h:1503
struct SmartAction::@75::@194 raw
uint32 param2
Definition SmartScriptMgr.h:1073
uint32 param1
Definition SmartScriptMgr.h:530
uint32 event_flags
Definition SmartScriptMgr.h:228
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition SmartScriptMgr.h:226
uint32 param2
Definition SmartScriptMgr.h:531
uint32 param4
Definition SmartScriptMgr.h:533
uint32 param3
Definition SmartScriptMgr.h:532
uint32 param6
Definition SmartScriptMgr.h:535
uint32 event_chance
Definition SmartScriptMgr.h:227
uint32 param5
Definition SmartScriptMgr.h:534
SMART_EVENT type
Definition SmartScriptMgr.h:225
Definition SmartScriptMgr.h:1964
SmartAction action
Definition SmartScriptMgr.h:1975
SmartScriptType source_type
Definition SmartScriptMgr.h:1970
SmartEvent event
Definition SmartScriptMgr.h:1974
SmartTarget target
Definition SmartScriptMgr.h:1976
uint32 param4
Definition SmartScriptMgr.h:1738
uint32 param1
Definition SmartScriptMgr.h:1735
uint32 param3
Definition SmartScriptMgr.h:1737
struct SmartTarget::@196::@220 raw
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1587
uint32 param2
Definition SmartScriptMgr.h:1736

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
5389{
5390 if (p >= mEventPhase)
5391 {
5392 SetPhase(0);
5393 }
5394 else
5395 {
5396 SetPhase(mEventPhase - p);
5397 }
5398}
void SetPhase(uint32 p)
Definition SmartScript.cpp:5400

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5294{
5295 if (!me)
5296 return nullptr;
5297
5298 Unit* unit = nullptr;
5299 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5301 Cell::VisitAllObjects(me, searcher, range);
5302 return unit;
5303}
Definition Unit.h:620
Definition GridNotifiers.h:406
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:185

References me, and Cell::VisitAllObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5274{
5275 if (!me)
5276 return;
5277
5278 Acore::FriendlyCCedInRange u_check(me, range);
5280 Cell::VisitGridObjects(me, searcher, range);
5281}
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:818
Definition GridNotifiers.h:473
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
5284{
5285 if (!me)
5286 return;
5287
5288 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5290 Cell::VisitGridObjects(me, searcher, range);
5291}
Definition GridNotifiers.h:836

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5247{
5248 if (!me)
5249 return nullptr;
5250
5251 Unit* unit = nullptr;
5252
5253 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5255 Cell::VisitGridObjects(me, searcher, range);
5256 return unit;
5257}
Definition GridNotifiers.h:775

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5260{
5261 if (!me)
5262 {
5263 return nullptr;
5264 }
5265
5266 Unit* unit = nullptr;
5267 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5269 Cell::VisitGridObjects(me, searcher, range);
5270 return unit;
5271}
Definition GridNotifiers.h:794

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5082{
5083 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5084
5085 if (e.empty())
5086 {
5087 if (obj)
5088 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5089
5090 if (at)
5091 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5092 return;
5093 }
5094 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5095 {
5096#ifndef ACORE_DEBUG
5097 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5098 continue;
5099#endif
5100
5101 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5102 {
5103 if (obj && obj->GetMap()->IsDungeon())
5104 {
5105 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5106 {
5107 mEvents.push_back((*i));
5108 }
5109 }
5110 continue;
5111 }
5112 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5113 }
5114}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:169
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition SmartScriptMgr.h:1932
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition SmartScriptMgr.h:1928
bool IsDungeon() const
Definition Map.h:295
uint8 GetSpawnMode() const
Definition Map.h:267
uint32 GetEntry() const
Definition Object.h:116
SmartAIEventList mEvents
Definition SmartScript.h:220
Map * GetMap() const
Definition Object.h:537

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:367

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:370

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

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

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:411

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().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5341{
5342 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5343 if (GetBaseObject())
5345 // xinef: used for area triggers invoker cast
5346 else if (invoker)
5348 return nullptr;
5349}
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(), ProcessAction(), and ProcessEvent().

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5117{
5119 if (me)
5120 {
5121 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5122 if (e.empty())
5123 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5124
5125 FillScript(e, me, nullptr);
5126
5127 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5128 {
5129 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5130 {
5131 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5132 FillScript(e, me, nullptr);
5133 }
5134 }
5135 }
5136 else if (go)
5137 {
5138 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5139 if (e.empty())
5140 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5141 FillScript(e, go, nullptr);
5142 }
5143 else if (trigger)
5144 {
5145 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5146 FillScript(e, nullptr, trigger);
5147 }
5148}
@ CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI
Definition CreatureData.h:72
std::int32_t int32
Definition Define.h:103
std::vector< SmartScriptHolder > SmartAIEventList
Definition SmartScriptMgr.h:2060
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2236
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:65
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:209
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition SmartScript.cpp:5081
uint32 entry
Definition ObjectMgr.h:421
Definition CreatureData.h:186

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:247

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3447{
3448 WorldObject* scriptTrigger = nullptr;
3449 if (invoker)
3450 scriptTrigger = invoker;
3451 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3452 scriptTrigger = tempLastInvoker;
3453
3454 WorldObject* baseObject = GetBaseObject();
3455
3456 switch (e.GetTargetType())
3457 {
3458 case SMART_TARGET_SELF:
3459 if (baseObject)
3460 targets.push_back(baseObject);
3461 break;
3463 if (me)
3464 if (Unit* victim = me->GetVictim())
3465 targets.push_back(victim);
3466 break;
3468 if (me)
3469 {
3470 if (e.target.hostileRandom.powerType)
3471 {
3472 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)))
3473 targets.push_back(u);
3474 }
3475 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3476 targets.push_back(u);
3477 }
3478 break;
3480 if (me)
3481 {
3482 if (e.target.hostileRandom.powerType)
3483 {
3484 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)))
3485 targets.push_back(u);
3486 }
3487 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3488 targets.push_back(u);
3489 }
3490 break;
3492 if (me)
3493 {
3494 if (e.target.hostileRandom.powerType)
3495 {
3496 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)))
3497 targets.push_back(u);
3498 }
3499 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3500 targets.push_back(u);
3501 }
3502 break;
3504 if (me)
3505 {
3506 if (e.target.hostileRandom.powerType)
3507 {
3508 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)))
3509 targets.push_back(u);
3510 }
3511 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3512 targets.push_back(u);
3513 }
3514 break;
3516 if (me)
3517 {
3518 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, FarthestTargetSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos, e.target.farthest.minDist)))
3519 targets.push_back(u);
3520 }
3521 break;
3523 if (scriptTrigger)
3524 targets.push_back(scriptTrigger);
3525 break;
3527 if (scriptTrigger && IsUnit(scriptTrigger))
3528 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3529 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3530 break;
3532 if (scriptTrigger)
3533 {
3534 if (Player* player = scriptTrigger->ToPlayer())
3535 {
3536 if (Group* group = player->GetGroup())
3537 {
3538 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3539 if (Player* member = groupRef->GetSource())
3540 {
3541 if (member->IsInMap(player))
3542 targets.push_back(member);
3543
3544 if (e.target.invokerParty.includePets)
3545 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3546 if (pet->IsPet() && pet->IsInMap(player))
3547 targets.push_back(pet);
3548 }
3549 }
3550 // We still add the player to the list if there is no group. If we do
3551 // this even if there is a group (thus the else-check), it will add the
3552 // same player to the list twice. We don't want that to happen.
3553 else
3554 targets.push_back(scriptTrigger);
3555 }
3556 }
3557 break;
3559 {
3560 WorldObject* ref = baseObject;
3561 if (!ref)
3562 ref = scriptTrigger;
3563
3564 if (!ref)
3565 {
3566 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3567 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3568 break;
3569 }
3570
3571 ObjectVector units;
3572 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3573
3574 for (WorldObject* unit : units)
3575 {
3576 if (!IsCreature(unit))
3577 continue;
3578
3579 if (me && me->GetGUID() == unit->GetGUID())
3580 continue;
3581
3582 // check alive state - 1 alive, 2 dead, 0 both
3583 if (uint32 state = e.target.unitRange.livingState)
3584 {
3585 if (unit->ToCreature()->IsAlive() && state == 2)
3586 continue;
3587 if (!unit->ToCreature()->IsAlive() && state == 1)
3588 continue;
3589 }
3590
3591 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))
3592 targets.push_back(unit);
3593 }
3594
3595 break;
3596 }
3598 {
3599 ObjectVector units;
3600 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3601
3602 for (WorldObject* unit : units)
3603 {
3604 if (!IsCreature(unit))
3605 continue;
3606
3607 if (me && me->GetGUID() == unit->GetGUID())
3608 continue;
3609
3610 // check alive state - 1 alive, 2 dead, 0 both
3611 if (uint32 state = e.target.unitDistance.livingState)
3612 {
3613 if (unit->ToCreature()->IsAlive() && state == 2)
3614 continue;
3615 if (!unit->ToCreature()->IsAlive() && state == 1)
3616 continue;
3617 }
3618
3619 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3620 targets.push_back(unit);
3621 }
3622
3623 break;
3624 }
3626 {
3627 ObjectVector units;
3628 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3629
3630 for (WorldObject* unit : units)
3631 {
3632 if (!IsGameObject(unit))
3633 continue;
3634
3635 if (go && go->GetGUID() == unit->GetGUID())
3636 continue;
3637
3638 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3639 targets.push_back(unit);
3640 }
3641
3642 break;
3643 }
3645 {
3646
3647 WorldObject* ref = baseObject;
3648 if (!ref)
3649 ref = scriptTrigger;
3650
3651 if (!ref)
3652 {
3653 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3654 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3655 break;
3656 }
3657
3658 ObjectVector units;
3659 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3660
3661 for (WorldObject* unit : units)
3662 {
3663 if (!IsGameObject(unit))
3664 continue;
3665
3666 if (go && go->GetGUID() == unit->GetGUID())
3667 continue;
3668
3669 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))
3670 targets.push_back(unit);
3671 }
3672
3673 break;
3674 }
3676 {
3677 if (!scriptTrigger && !baseObject)
3678 {
3679 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3680 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3681 break;
3682 }
3683
3684 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3685 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3686 targets.push_back(target);
3687 break;
3688 }
3690 {
3691 if (!scriptTrigger && !GetBaseObject())
3692 {
3693 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3694 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3695 break;
3696 }
3697
3698 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3699 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3700 targets.push_back(target);
3701 break;
3702 }
3704 {
3705 ObjectVector units;
3706 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3707
3708 if (!units.empty() && baseObject)
3709 for (WorldObject* unit : units)
3710 if (IsPlayer(unit) && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3711 targets.push_back(unit);
3712 if (e.target.playerRange.maxCount)
3713 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3714 break;
3715 }
3717 {
3718 ObjectVector units;
3719 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3720
3721 for (WorldObject* unit : units)
3722 if (IsPlayer(unit))
3723 targets.push_back(unit);
3724 break;
3725 }
3727 {
3728 WorldObject* ref = baseObject;
3729 if (!ref)
3730 ref = scriptTrigger;
3731
3732 if (!ref)
3733 {
3734 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3735 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3736 break;
3737 }
3738
3739 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3740 targets.assign(stored->begin(), stored->end());
3741 break;
3742 }
3744 {
3745 WorldObject* ref = baseObject;
3746
3747 if (!ref)
3748 ref = scriptTrigger;
3749
3750 if (!ref)
3751 {
3752 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: 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 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3758 if (target)
3759 targets.push_back(target);
3760 break;
3761 }
3763 {
3764 WorldObject* ref = baseObject;
3765
3766 if (!ref)
3767 ref = scriptTrigger;
3768
3769 if (!ref)
3770 {
3771 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3772 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3773 break;
3774 }
3775
3776 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3777 if (target)
3778 targets.push_back(target);
3779 break;
3780 }
3782 {
3783 WorldObject* ref = baseObject;
3784
3785 if (!ref)
3786 ref = scriptTrigger;
3787
3788 if (!ref)
3789 {
3790 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3791 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3792 break;
3793 }
3794
3795 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3796 targets.push_back(target);
3797 break;
3798 }
3800 /*
3801 * Owners/Summoners should be WorldObjects. This allows to have other objects
3802 * such as gameobjects to execute SmartScripts using this type of target.
3803 * Otherwise, only Units like creatures can summon other creatures.
3804 */
3805 {
3806 if (me)
3807 {
3809 {
3810 targets.push_back(owner);
3811 }
3812 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3813 {
3814 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3815 }
3816 }
3817 else if (go)
3818 {
3820 {
3821 targets.push_back(owner);
3822 }
3823 }
3824
3825 // xinef: Get owner of owner
3826 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3827 {
3828 if (WorldObject* owner = targets.front())
3829 {
3830 targets.clear();
3831
3832 if (owner->ToCreature())
3833 {
3834 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3835 {
3836 targets.push_back(base);
3837 }
3838 }
3839 else
3840 {
3841 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3842 {
3843 targets.push_back(base);
3844 }
3845 }
3846 }
3847 }
3848 break;
3849 }
3851 {
3852 if (me)
3853 {
3855 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
3856 if (Unit* temp = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
3857 // Xinef: added distance check
3858 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3859 targets.push_back(temp);
3860 }
3861 break;
3862 }
3864 {
3865 if (me)
3866 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3867 targets.push_back(target);
3868
3869 break;
3870 }
3872 {
3873 if (me)
3874 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3875 targets.push_back(target);
3876
3877 break;
3878 }
3880 {
3881 ObjectVector units;
3882 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3883
3884 for (WorldObject* unit : units)
3885 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3886 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3887 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3888 targets.push_back(unit);
3889
3890 if (e.target.o > 0)
3891 Acore::Containers::RandomResize(targets, e.target.o);
3892
3893 break;
3894 }
3896 {
3897 ObjectVector units;
3898 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3899 // 1 = Tanks, 2 = Healer, 4 = Damage
3900 uint32 roleMask = e.target.roleSelection.roleMask;
3901 for (WorldObject* unit : units)
3902 if (Player* targetPlayer = unit->ToPlayer())
3903 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3904 {
3905 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3906 {
3907 if (targetPlayer->HasTankSpec())
3908 {
3909 targets.push_back(unit);
3910 continue;
3911 }
3912 }
3913 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3914 {
3915 if (targetPlayer->HasHealSpec())
3916 {
3917 targets.push_back(unit);
3918 continue;
3919 }
3920 }
3921 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3922 {
3923 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3924 {
3925 targets.push_back(unit);
3926 continue;
3927 }
3928 }
3929 }
3930
3931 if (e.target.roleSelection.resize > 0)
3932 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
3933
3934 break;
3935 }
3937 {
3938 if (me && me->IsVehicle())
3939 {
3940 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
3941 {
3942 targets.push_back(target);
3943 }
3944 }
3945 break;
3946 }
3948 {
3949 if (me)
3950 {
3951 if (Group* lootGroup = me->GetLootRecipientGroup())
3952 {
3953 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
3954 {
3955 if (Player* recipient = it->GetSource())
3956 {
3957 targets.push_back(recipient);
3958 }
3959 }
3960 }
3961 else
3962 {
3963 if (Player* recipient = me->GetLootRecipient())
3964 {
3965 targets.push_back(recipient);
3966 }
3967 }
3968 }
3969 break;
3970 }
3972 {
3973 if (me)
3974 {
3975 for (ObjectGuid const& guid : _summonList)
3976 {
3977 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
3978 {
3979 if (Creature* creature = me->GetMap()->GetCreature(guid))
3980 {
3981 targets.push_back(creature);
3982 }
3983 }
3984 }
3985 }
3986 break;
3987 }
3989 {
3990 if (InstanceScript* instance = GetBaseObject()->GetInstanceScript())
3991 {
3992 if (e.target.instanceStorage.type == 1)
3993 {
3994 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
3995 {
3996 targets.push_back(creature);
3997 }
3998 }
3999 else if (e.target.instanceStorage.type == 2)
4000 {
4001 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4002 {
4003 targets.push_back(go);
4004 }
4005 }
4006 }
4007 else
4008 {
4009 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4010 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4011 }
4012
4013 break;
4014 }
4015 case SMART_TARGET_NONE:
4017 default:
4018 break;
4019 }
4020}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:865
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition ScriptedCreature.cpp:870
Powers
Definition SharedDefines.h:268
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition SmartScriptMgr.h:1757
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1756
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1758
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1554
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1546
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1538
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1533
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1543
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1547
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1540
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1537
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1544
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1567
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1529
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1542
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1536
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1548
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1532
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1541
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1530
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1528
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1564
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1566
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1534
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1535
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1531
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1549
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1568
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1527
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1545
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1539
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2001
Definition Creature.h:43
Player * GetLootRecipient() const
Definition Creature.cpp:1312
Group * GetLootRecipientGroup() const
Definition Creature.cpp:1319
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition Creature.cpp:2387
CreatureAI * AI() const
Definition Creature.h:141
Definition GameObject.h:120
ObjectGuid GetOwnerGUID() const
Definition GameObject.h:173
Definition GroupReference.h:27
Definition Group.h:169
Definition InstanceScript.h:143
Creature * GetCreature(ObjectGuid const guid)
Definition Map.cpp:2498
Definition ObjectGuid.h:118
Player * ToPlayer()
Definition Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
Unit * ToUnit()
Definition Object.h:210
Definition Player.h:1082
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5351
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5356
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5361
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5340
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4022
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5377
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5293
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:142
Unit * GetSummonerUnit() const
Definition TemporarySummon.cpp:44
std::list< HostileReference * > StorageType
Definition ThreatMgr.h:147
ThreatContainer::StorageType const & GetThreatList() const
Definition ThreatMgr.h:273
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:110
bool IsVehicle() const
Definition Unit.h:750
Vehicle * GetVehicle() const
Definition Unit.h:1830
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition Unit.cpp:649
TempSummon * ToTempSummon()
Definition Unit.h:686
bool IsSummon() const
Definition Unit.h:744
Unit * GetVictim() const
Definition Unit.h:846
ThreatMgr & GetThreatMgr()
Definition Unit.h:896
Vehicle * GetVehicleKit() const
Definition Unit.h:1829
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1220
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:228
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2486
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1415
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:169
Definition UnitAI.h:135

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::farthest, FindCreatureNear(), FindGameObjectNear(), SmartScriptHolder::GetActionType(), Vehicle::GetBase(), GetBaseObject(), Unit::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), ObjectAccessor::GetCreatureOrPetOrVehicle(), Object::GetEntry(), Object::GetGUID(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), Creature::GetLootRecipientGroup(), WorldObject::GetMap(), GameObject::GetOwnerGUID(), Vehicle::GetPassenger(), SmartScriptHolder::GetScriptType(), GetStoredTargetVector(), TempSummon::GetSummonerUnit(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), 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, 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_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
4023{
4024 WorldObject* obj = GetBaseObject();
4025 if (!obj)
4026 return;
4027
4028 Acore::AllWorldObjectsInRange u_check(obj, dist);
4030 Cell::VisitAllObjects(obj, searcher, dist);
4031}
Definition GridNotifiers.h:1586
Definition GridNotifiers.h:239

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

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

◆ IncPhase()

void SmartScript::IncPhase ( uint32  p)
private
5383{
5384 // protect phase from overflowing
5385 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5386}
@ SMART_EVENT_PHASE_12
Definition SmartScriptMgr.h:76

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
4825{
4826 switch (e.GetEventType())
4827 {
4828 //set only events which have initial timers
4832 break;
4833 case SMART_EVENT_UPDATE:
4836 case SMART_EVENT_RANGE:
4843 break;
4847 break;
4851 break;
4852 default:
4853 e.active = true;
4854 break;
4855 }
4856}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition SmartScriptMgr.h:192
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition SmartScriptMgr.h:210
@ SMART_EVENT_AREA_CASTING
Definition SmartScriptMgr.h:213
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition SmartScriptMgr.h:194
@ SMART_EVENT_RANGE
Definition SmartScriptMgr.h:127
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition SmartScriptMgr.h:212
@ SMART_EVENT_UPDATE_IC
Definition SmartScriptMgr.h:118
@ SMART_EVENT_IS_IN_MELEE_RANGE
Definition SmartScriptMgr.h:218
@ SMART_EVENT_AREA_RANGE
Definition SmartScriptMgr.h:214
@ SMART_EVENT_UPDATE
Definition SmartScriptMgr.h:178
@ SMART_EVENT_IS_BEHIND_TARGET
Definition SmartScriptMgr.h:185
@ SMART_EVENT_UPDATE_OOC
Definition SmartScriptMgr.h:119
@ SMART_EVENT_NEAR_UNIT
Definition SmartScriptMgr.h:211
@ SMART_EVENT_DISTANCE_CREATURE
Definition SmartScriptMgr.h:193
@ SMART_EVENT_NEAR_PLAYERS
Definition SmartScriptMgr.h:209
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition SmartScript.cpp:4857
struct SmartEvent::@30::@68 nearPlayer
struct SmartEvent::@30::@32 minMaxRepeat
struct SmartEvent::@30::@70 nearUnit
uint32 repeat
Definition SmartScriptMgr.h:465
uint32 min
Definition SmartScriptMgr.h:233
uint32 firstTimer
Definition SmartScriptMgr.h:480
uint32 max
Definition SmartScriptMgr.h:234
uint32 timer
Definition SmartScriptMgr.h:500
struct SmartEvent::@30::@66 distance
bool active
Definition SmartScriptMgr.h:1986
uint32 GetEventType() const
Definition SmartScriptMgr.h:1980

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
4976{
4977 if (!mInstallEvents.empty())
4978 {
4979 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
4980 mEvents.push_back(*i);//must be before UpdateTimers
4981
4982 mInstallEvents.clear();
4983 }
4984}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3335{
3336 if (!GetBaseObject())
3337 return;
3339 {
3340 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3341 return;
3342 }
3343 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3344 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3345 {
3347 {
3348 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);
3349 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);
3350 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);
3351 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);
3352 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);
3353 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);
3354 break;
3355 }
3357 {
3358 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);
3359 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);
3360 break;
3361 }
3363 {
3364 if (!me)
3365 return;
3366 //store cage as id1
3367 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);
3368
3369 //reset(close) cage on hostage(me) respawn
3370 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);
3371
3372 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);
3373 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);
3374
3375 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);
3376 //phase 1: give quest credit on movepoint reached
3378 //phase 1: despawn after time on movepoint reached
3379 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);
3380
3381 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3382 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);
3383 break;
3384 }
3386 {
3387 if (!go)
3388 return;
3389 //store hostage as id1
3390 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);
3391 //store invoker as id2
3392 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);
3393 //signal hostage
3394 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);
3395 //when hostage raeched end point, give credit to invoker
3396 if (e.action.installTtemplate.param2)
3397 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);
3398 else
3399 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);
3400 break;
3401 }
3403 default:
3404 return;
3405 }
3406}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:119
std::uint8_t uint8
Definition Define.h:109
@ POINT_MOTION_TYPE
Definition MotionMaster.h:48
SMARTAI_TEMPLATE
Definition SmartScriptMgr.h:1515
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1520
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1521
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1517
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1518
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1921
@ SMART_ACTION_STORE_TARGET_LIST
Definition SmartScriptMgr.h:622
@ SMART_ACTION_FORCE_DESPAWN
Definition SmartScriptMgr.h:599
@ SMART_ACTION_CAST
Definition SmartScriptMgr.h:569
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition SmartScriptMgr.h:579
@ SMART_ACTION_MOVE_FORWARD
Definition SmartScriptMgr.h:604
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition SmartScriptMgr.h:591
@ SMART_ACTION_TALK
Definition SmartScriptMgr.h:559
@ SMART_ACTION_SET_DATA
Definition SmartScriptMgr.h:603
@ SMART_ACTION_SET_RUN
Definition SmartScriptMgr.h:617
@ SMART_ACTION_SET_EVENT_PHASE
Definition SmartScriptMgr.h:580
@ SMART_ACTION_RESET_GOBJECT
Definition SmartScriptMgr.h:590
@ SMART_EVENT_DATA_SET
Definition SmartScriptMgr.h:156
@ SMART_EVENT_JUST_CREATED
Definition SmartScriptMgr.h:181
@ SMART_EVENT_MOVEMENTINFORM
Definition SmartScriptMgr.h:152
@ SMART_EVENT_MANA_PCT
Definition SmartScriptMgr.h:121
@ SMART_EVENT_GO_STATE_CHANGED
Definition SmartScriptMgr.h:188
@ SMART_RANDOM_POINT
Definition SmartScriptMgr.h:58
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:3408

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
5367{
5368 if (!obj)
5369 return false;
5370
5371 if (Creature* creatureObj = obj->ToCreature())
5372 return creatureObj->IsCharmed();
5373
5374 return false;
5375}
Creature * ToCreature()
Definition Object.h:206

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5362{
5363 return obj && obj->IsCreature();
5364}
bool IsCreature() const
Definition Object.h:205

References Object::IsCreature().

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5378{
5379 return obj && obj->IsGameObject();
5380}
bool IsGameObject() const
Definition Object.h:213

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5413{
5414 if (mEventPhase == 0)
5415 {
5416 return false;
5417 }
5418
5419 return ((1 << (mEventPhase - 1)) & p) != 0;
5420}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5357{
5358 return obj && obj->IsPlayer();
5359}
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
100{
101 if (me)
102 return IsSmart(me, silent);
103 if (go)
104 return IsSmart(go, silent);
105
106 return false;
107}
bool IsSmart(Creature *c, bool silent=false) const
Definition SmartScript.cpp:69

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

bool SmartScript::IsSmart ( Creature c,
bool  silent = false 
) const
70{
71 if (!c)
72 return false;
73
74 bool smart = true;
75 if (!dynamic_cast<SmartAI*>(c->AI()))
76 smart = false;
77
78 if (!smart && !silent)
79 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));
80
81 return smart;
82}
Definition SmartAI.h:44

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
85{
86 if (!g)
87 return false;
88
89 bool smart = true;
90 if (!dynamic_cast<SmartGameObjectAI*>(g->AI()))
91 smart = false;
92
93 if (!smart && !silent)
94 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));
95
96 return smart;
97}
GameObjectAI * AI() const
Definition GameObject.h:305
Definition SmartAI.h:263

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5352{
5353 return obj && (obj->IsCreature() || obj->IsPlayer());
5354}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5151{
5152 if (obj)//handle object based scripts
5153 {
5154 switch (obj->GetTypeId())
5155 {
5156 case TYPEID_UNIT:
5158 me = obj->ToCreature();
5159 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5160 break;
5161 case TYPEID_GAMEOBJECT:
5163 go = obj->ToGameObject();
5164 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5165 break;
5166 default:
5167 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5168 return;
5169 }
5170 }
5171 else if (at)
5172 {
5174 trigger = at;
5175 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5176 }
5177 else
5178 {
5179 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5180 return;
5181 }
5182
5183 GetScript();//load copy of script
5184
5185 for (SmartScriptHolder& event : mEvents)
5186 InitTimer(event);//calculate timers for first time use
5187
5189 InstallEvents();
5191}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1764
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1765
@ SMART_EVENT_AI_INIT
Definition SmartScriptMgr.h:155
TypeID GetTypeId() const
Definition Object.h:128
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:135
void InstallEvents()
Definition SmartScript.cpp:4975
void GetScript()
Definition SmartScript.cpp:5116

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)
5194{
5195 if (!me)
5196 return;
5197
5199}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:144
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:128
bool IsEngaged() const
Definition Unit.h:874

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

void SmartScript::OnReset ( )
110{
111 // xinef: check if we allow phase reset
112 if (AllowPhaseReset())
113 SetPhase(0);
114
116 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
117 {
118 if (!((*i).event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
119 {
120 InitTimer((*i));
121 (*i).runOnce = false;
122 }
123
124 if ((*i).priority != SmartScriptHolder::DEFAULT_PRIORITY)
125 {
128 }
129 }
132 mCounterList.clear();
133}
@ SMART_EVENT_FLAG_DONT_RESET
Definition SmartScriptMgr.h:1929
@ SMART_EVENT_RESET
Definition SmartScriptMgr.h:143
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:1996

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)
4987{
4989 return;
4990
4991 InstallEvents();//before UpdateTimers
4992
4994 {
4996 mEventSortingRequired = false;
4997 }
4998
4999 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
5000 UpdateTimer(*i, diff);
5001
5002 if (!mStoredEvents.empty())
5003 {
5004 SmartAIEventStoredList::iterator i, icurr;
5005 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
5006 {
5007 icurr = i++;
5008 UpdateTimer(*icurr, diff);
5009 }
5010 }
5011
5012 bool needCleanup = true;
5013 if (!mTimedActionList.empty())
5014 {
5016 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5017 {
5018 if ((*i).enableTimed)
5019 {
5020 UpdateTimer(*i, diff);
5021 needCleanup = false;
5022 }
5023 }
5024
5026 }
5027 if (needCleanup)
5028 mTimedActionList.clear();
5029
5030 if (!mRemIDs.empty())
5031 {
5032 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5034
5035 // xinef: clear list after cleaning...
5036 mRemIDs.clear();
5037 }
5038 if (mUseTextTimer && me)
5039 {
5040 if (mTextTimer < diff)
5041 {
5042 uint32 textID = mLastTextID;
5043 mLastTextID = 0;
5044 uint32 entry = mTalkerEntry;
5045 mTalkerEntry = 0;
5046 mTextTimer = 0;
5047 mUseTextTimer = false;
5048 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5049 }
5050 else mTextTimer -= diff;
5051 }
5052}
@ SMART_EVENT_TEXT_OVER
Definition SmartScriptMgr.h:170
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition SmartScript.cpp:4864
void SortEvents(SmartAIEventList &events)
Definition SmartScript.cpp:5054
SmartAIEventStoredList mStoredEvents
Definition SmartScript.h:234
std::list< uint32 > mRemIDs
Definition SmartScript.h:235
SmartAIEventList mTimedActionList
Definition SmartScript.h:222
void RemoveStoredEvent(uint32 id)
Definition SmartScript.h:252

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

References SmartAction::a, SmartScriptHolder::action, SmartAction::actionId, SmartAction::actionLists, SmartAction::activateObject, EventProcessor::AddEventAtOffset(), WorldObject::AddObjectToRemoveList(), CustomSpellValues::AddSpellMod(), Unit::AddThreat(), Creature::AI(), GameObject::AI(), SmartAction::aliveState, SmartAction::alternative, SmartTarget::amount, SmartAction::angle, SmartAction::anim, 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, 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::closestWaypointFromList, 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::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(), 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, SmartAction::forceDespawn, SmartAction::forceRespawnTimer, frand(), SmartAction::gameEventStart, SmartAction::gameEventStop, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_DOOR, 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(), SpellInfo::GetMaxRange(), Unit::GetMeleeRange(), SpellInfo::GetMinRange(), 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(), ThreatMgr::GetThreatList(), ThreatMgr::GetThreatListSize(), Unit::GetThreatMgr(), Unit::GetTransGUID(), Creature::GetTransportHomePosition(), ObjectAccessor::GetUnit(), Unit::GetVehicleKit(), GetWorldObjectsInDist(), WorldObject::GetZoneId(), go, GO_READY, SmartAction::goFlag, goOrigGUID, SmartAction::goRespawnTime, SmartAction::gossipMenuId, SmartAction::gossipNpcTextId, SmartAction::goState, SmartAction::group, Player::GroupEventHappens(), SpellInfo::HasAttribute(), Unit::HasAura(), EnumFlag< T >::HasFlag(), Object::HasFlag(), Unit::HasUnitMovementFlag(), Unit::HasUnitState(), WayPoint::id, SmartAction::id, 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(), IsCreature(), Unit::isDead(), Map::IsDungeon(), LinkedListHead::IsEmpty(), IsGameObject(), Unit::isMoving(), 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, 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, ThreatMgr::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::movie, mRemIDs, mStoredEvents, mTalkerEntry, mTextTimer, mUseTextTimer, SmartAction::music, SmartAction::newPower, NOMINAL_MELEE_RANGE, SmartTarget::o, SmartAction::onlySelf, OnReset(), SmartAction::orientation, SmartAction::orientationTarget, SmartAction::param, SmartAction::pathID, SmartAction::pathId, SmartAction::pathId1, SmartAction::pathId2, 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(), Creature::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, SmartAction::setGoLootState, SmartAction::setGuid, ZoneScript::SetGuidData(), SmartAction::setHealthPct, SmartAction::setHealthRegen, SmartAction::setHomePos, Creature::SetHomePosition(), SmartAction::setHover, Unit::SetInCombatWith(), 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_DIE, SMART_ACTION_DISABLE_EVADE, SMART_ACTION_DISABLE_REWARD, SMART_ACTION_DISMOUNT, SMART_ACTION_DO_ACTION, SMART_ACTION_EQUIP, 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_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_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_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_START_CLOSEST_WAYPOINT, SMART_ACTION_STOP_MOTION, SMART_ACTION_STORE_TARGET_LIST, SMART_ACTION_SUMMON_CREATURE, SMART_ACTION_SUMMON_CREATURE_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_DATA_START, SMART_ACTION_WORLD_SCRIPT, SMART_ACTION_WP_PAUSE, SMART_ACTION_WP_RESUME, SMART_ACTION_WP_START, SMART_ACTION_WP_STOP, SMART_ACTION_ZONE_UNDER_ATTACK, SMART_ESCORT_TARGETS, 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_EVENT_WAYPOINT_REACHED, SMART_RANDOM_POINT, SMART_SCRIPT_TYPE_AREATRIGGER, SMART_TARGET_NONE, SMART_TARGET_POSITION, SMART_TARGET_RANDOM_POINT, SMART_TARGET_SELF, SMARTCAST_AURA_NOT_PRESENT, SMARTCAST_COMBAT_MOVE, SMARTCAST_INTERRUPT_PREVIOUS, SMARTCAST_TARGET_POWER_MANA, SMARTCAST_THREATLIST_NOT_SINGLE, SMARTCAST_TRIGGERED, sObjectMgr, SmartAction::sound, SmartAction::sound1, SmartAction::sound2, SmartAction::sound3, SmartAction::sound4, 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::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(), SmartAction::summonGO, WorldObject::SummonTrigger(), SmartAction::summonVortex, SmartAction::swim, sWorldState, 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::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_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, SmartAction::withDelayed, SmartAction::withEmote, SmartAction::withInstant, SmartAction::worldStateScript, SmartAction::wpData, SmartAction::wpDataRandom, SmartAction::wpPause, SmartAction::wps, SmartAction::wpStart, SmartAction::wpStop, SmartTarget::x, SmartTarget::y, and SmartTarget::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 
)
4034{
4035 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4036 return;
4037
4039 return;
4040
4042 return;
4043
4044 switch (e.GetEventType())
4045 {
4046 case SMART_EVENT_LINK://special handling
4047 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4048 break;
4049 //called from Update tick
4050 case SMART_EVENT_UPDATE:
4052 break;
4054 if (me && me->IsEngaged())
4055 return;
4057 break;
4059 if (!me || !me->IsEngaged())
4060 return;
4062 break;
4064 {
4065 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4066 return;
4067 uint32 perc = (uint32)me->GetHealthPct();
4068 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4069 return;
4071 break;
4072 }
4074 {
4075 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4076 return;
4077 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4078 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4079 return;
4081 break;
4082 }
4084 {
4085 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4086 return;
4088 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4089 return;
4091 break;
4092 }
4094 {
4095 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4096 return;
4098 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4099 return;
4101 break;
4102 }
4103 case SMART_EVENT_RANGE:
4104 {
4105 if (!me || !me->IsEngaged() || !me->GetVictim())
4106 return;
4107
4110 else
4111 RecalcTimer(e, 1200, 1200); // make it predictable
4112
4113 break;
4114 }
4116 {
4117 if (!me || !me->IsEngaged())
4118 return;
4119
4120 Unit* victim = me->GetVictim();
4121
4122 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4123 return;
4124
4125 if (e.event.targetCasting.spellId > 0)
4126 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4127 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4128 return;
4129
4131 break;
4132 }
4134 {
4135 if (!me || !me->IsEngaged())
4136 return;
4137
4139 if (!target || !target->IsInCombat())
4140 {
4141 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4142 RecalcTimer(e, 1000, 3000);
4143 return;
4144 }
4146 break;
4147 }
4149 {
4150 if (!me || !me->IsEngaged())
4151 return;
4152
4153 std::vector<Creature*> creatures;
4155 if (creatures.empty())
4156 {
4157 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4158 RecalcTimer(e, 1000, 3000);
4159 return;
4160 }
4162 break;
4163 }
4165 {
4167 {
4168 return;
4169 }
4170
4171 std::vector<Creature*> creatures;
4173
4174 if (creatures.empty())
4175 return;
4176
4178 break;
4179 }
4181 {
4182 if (!me)
4183 return;
4184 uint32 count = me->GetAuraCount(e.event.aura.spell);
4185 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4187 break;
4188 }
4190 {
4191 if (!me || !me->GetVictim())
4192 return;
4194 if (count < e.event.aura.count)
4195 return;
4197 break;
4198 }
4200 {
4201 if (bvar == (e.event.charm.onRemove != 1))
4202 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4203 break;
4204 }
4205 //no params
4206 case SMART_EVENT_AGGRO:
4207 case SMART_EVENT_DEATH:
4208 case SMART_EVENT_EVADE:
4221 case SMART_EVENT_RESET:
4225 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4226 break;
4227
4229 switch (e.event.gossipHello.filter)
4230 {
4231 case 0:
4232 // no filter set, always execute action
4233 break;
4234 case 1:
4235 // GossipHello only filter set, skip action if reportUse
4236 if (var0)
4237 {
4238 return;
4239 }
4240 break;
4241 case 2:
4242 // reportUse only filter set, skip action if GossipHello
4243 if (!var0)
4244 {
4245 return;
4246 }
4247 break;
4248 default:
4249 // Ignore any other value
4250 break;
4251 }
4252
4253 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4254 break;
4256 {
4257 if (!me)
4258 return;
4259
4260 if (Unit* victim = me->GetVictim())
4261 {
4263 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4265 }
4266
4267 break;
4268 }
4270 {
4271 if (!me)
4272 return;
4273
4274 if (Unit* victim = me->GetVictim())
4275 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4276 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4278
4279 break;
4280 }
4282 if (e.event.emote.emote == var0)
4283 {
4284 ProcessAction(e, unit);
4285 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4286 }
4287 break;
4288 case SMART_EVENT_KILL:
4289 {
4290 if (!me || !unit)
4291 return;
4292 if (e.event.kill.playerOnly && !unit->IsPlayer())
4293 return;
4294 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4295 return;
4297 ProcessAction(e, unit);
4298 break;
4299 }
4302 {
4303 if (!spell)
4304 return;
4305 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4306 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4307 {
4309 ProcessAction(e, unit, 0, 0, bvar, spell);
4310 }
4311 break;
4312 }
4314 {
4315 if (!me || me->IsEngaged())
4316 return;
4317 //can trigger if closer than fMaxAllowedRange
4318 float range = (float)e.event.los.maxDist;
4319
4320 //if range is ok and we are actually in LOS
4321 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4322 {
4324 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4325 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4326 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4327 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4328 {
4329 if (e.event.los.playerOnly && !unit->IsPlayer())
4330 return;
4332 ProcessAction(e, unit);
4333 }
4334 }
4335 break;
4336 }
4337 case SMART_EVENT_IC_LOS:
4338 {
4339 if (!me || !me->IsEngaged())
4340 return;
4341 //can trigger if closer than fMaxAllowedRange
4342 float range = (float)e.event.los.maxDist;
4343
4344 //if range is ok and we are actually in LOS
4345 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4346 {
4348 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4349 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4350 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4351 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4352 {
4353 if (e.event.los.playerOnly && !unit->IsPlayer())
4354 return;
4356 ProcessAction(e, unit);
4357 }
4358 }
4359 break;
4360 }
4362 {
4363 if (!GetBaseObject())
4364 return;
4366 return;
4368 return;
4369 ProcessAction(e);
4370 break;
4371 }
4375 {
4376 if (!IsCreature(unit))
4377 return;
4378 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4379 return;
4381 ProcessAction(e, unit);
4382 break;
4383 }
4387 {
4388 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4389 return;
4391 ProcessAction(e, unit);
4392 break;
4393 }
4395 {
4396 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4397 return;
4398 ProcessAction(e, unit, var0, var1);
4399 break;
4400 }
4403 {
4404 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4405 return;
4406 ProcessAction(e, unit, var0);
4407 break;
4408 }
4414 {
4415 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4416 return;
4417 ProcessAction(e, unit);
4418 break;
4419 }
4421 {
4422 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4423 return;
4425 ProcessAction(e, unit, var0);
4426 break;
4427 }
4429 {
4431 return;
4433 ProcessAction(e, unit, var0);
4434 break;
4435 }
4438 {
4439 if (e.event.quest.quest && var0 != e.event.quest.quest)
4440 return;
4441 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4442 ProcessAction(e, unit, var0);
4443 break;
4444 }
4446 {
4448 return;
4449 ProcessAction(e, unit, var0);
4450 break;
4451 }
4453 {
4454 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4455 return;
4456 ProcessAction(e, unit, var0);
4457 break;
4458 }
4460 {
4462 return;
4463 ProcessAction(e, unit, var0);
4464 break;
4465 }
4467 {
4468 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4469 return;
4471 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4472 break;
4473 }
4476 {
4477 if (!unit)
4478 return;
4480 ProcessAction(e, unit);
4481 break;
4482 }
4484 {
4485 if (e.event.timedEvent.id == var0)
4486 ProcessAction(e, unit);
4487 break;
4488 }
4490 {
4491 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4492 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4493 return;
4494 ProcessAction(e, unit, var0, var1);
4495 break;
4496 }
4498 {
4500 return;
4501
4502 WorldObject* templastInvoker = GetLastInvoker();
4503 if (!templastInvoker)
4504 return;
4505
4506 if (!IsUnit(templastInvoker))
4507 return;
4508
4509 ProcessAction(e, templastInvoker->ToUnit());
4510 break;
4511 }
4514 {
4515 if (e.event.gameEvent.gameEventId != var0)
4516 return;
4517 ProcessAction(e, nullptr, var0);
4518 break;
4519 }
4521 {
4522 if (e.event.goStateChanged.state != var0)
4523 return;
4524 ProcessAction(e, unit, var0, var1);
4525 break;
4526 }
4528 {
4529 if (e.event.eventInform.eventId != var0)
4530 return;
4531 ProcessAction(e, nullptr, var0);
4532 break;
4533 }
4535 {
4536 if (e.event.doAction.eventId != var0)
4537 return;
4538 ProcessAction(e, unit, var0);
4539 break;
4540 }
4542 {
4543 if (!me || !me->IsEngaged())
4544 return;
4545
4546 Unit* unitTarget = nullptr;
4547 switch (e.GetTargetType())
4548 {
4556 {
4557 ObjectVector targets;
4558 GetTargets(targets, e);
4559 for (WorldObject* target : targets)
4560 {
4561 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4562 {
4563 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4564 if (healthPct > e.event.friendlyHealthPct.hpPct)
4565 {
4566 continue;
4567 }
4568
4569 unitTarget = target->ToUnit();
4570 break;
4571 }
4572 }
4573
4574 break;
4575 }
4576 case SMART_TARGET_SELF:
4579 break;
4580 default:
4581 return;
4582 }
4583
4584 if (!unitTarget)
4585 return;
4586
4588 break;
4589 }
4591 {
4592 if (!me)
4593 return;
4594
4595 WorldObject* creature = nullptr;
4596
4597 if (e.event.distance.guid != 0)
4598 {
4599 creature = FindCreatureNear(me, e.event.distance.guid);
4600
4601 if (!creature)
4602 return;
4603
4604 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4605 return;
4606 }
4607 else if (e.event.distance.entry != 0)
4608 {
4609 std::list<Creature*> list;
4611
4612 if (!list.empty())
4613 creature = list.front();
4614 }
4615
4616 if (creature)
4618
4619 break;
4620 }
4622 {
4623 if (!me)
4624 return;
4625
4626 WorldObject* gameobject = nullptr;
4627
4628 if (e.event.distance.guid != 0)
4629 {
4630 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4631
4632 if (!gameobject)
4633 return;
4634
4635 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4636 return;
4637 }
4638 else if (e.event.distance.entry != 0)
4639 {
4640 std::list<GameObject*> list;
4642
4643 if (!list.empty())
4644 gameobject = list.front();
4645 }
4646
4647 if (gameobject)
4649
4650 break;
4651 }
4653 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4654 return;
4655
4657 break;
4659 {
4660 uint32 playerCount = 0;
4661 ObjectVector targets;
4662 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4663
4664 if (!targets.empty())
4665 {
4666 for (WorldObject* target : targets)
4667 {
4668 if (IsPlayer(target))
4669 playerCount++;
4670 }
4671 if (playerCount >= e.event.nearPlayer.minCount)
4672 ProcessAction(e, unit);
4673 }
4675 break;
4676 }
4678 {
4679 uint32 playerCount = 0;
4680 ObjectVector targets;
4681 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4682
4683 if (!targets.empty())
4684 {
4685 for (WorldObject* target : targets)
4686 {
4687 if (IsPlayer(target))
4688 playerCount++;
4689 }
4690
4691 if (playerCount < e.event.nearPlayerNegation.maxCount)
4692 ProcessAction(e, unit);
4693 }
4695 break;
4696 }
4698 {
4699 uint32 unitCount = 0;
4700 ObjectVector targets;
4701 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4702
4703 if (!targets.empty())
4704 {
4705 if (e.event.nearUnit.type)
4706 {
4707 for (WorldObject* target : targets)
4708 {
4709 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4710 unitCount++;
4711 }
4712 }
4713 else
4714 {
4715 for (WorldObject* target : targets)
4716 {
4717 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4718 unitCount++;
4719 }
4720 }
4721
4722 if (unitCount >= e.event.nearUnit.count)
4723 ProcessAction(e, unit);
4724 }
4726 break;
4727 }
4729 {
4730 uint32 unitCount = 0;
4731 ObjectVector targets;
4732 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4733
4734 if (!targets.empty())
4735 {
4737 {
4738 for (WorldObject* target : targets)
4739 {
4740 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4741 unitCount++;
4742 }
4743 }
4744 else
4745 {
4746 for (WorldObject* target : targets)
4747 {
4748 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4749 unitCount++;
4750 }
4751 }
4752
4753 if (unitCount < e.event.nearUnitNegation.count)
4754 ProcessAction(e, unit);
4755 }
4757 break;
4758 }
4760 {
4761 if (!me || !me->IsEngaged())
4762 return;
4763
4765 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4766 {
4767 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4768 {
4769 if (!target || !IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4770 continue;
4771
4772 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4773 continue;
4774
4775 ProcessAction(e, target);
4777 return;
4778 }
4779
4780 // If no targets are found and it's off cooldown, check again in 1200ms
4781 RecalcTimer(e, 1200, 1200);
4782 break;
4783 }
4784
4785 break;
4786 }
4788 {
4789 if (!me || !me->IsEngaged())
4790 return;
4791
4793 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4794 {
4795 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4796 {
4797 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4798 continue;
4799
4800 ProcessAction(e, target);
4802 return;
4803 }
4804 }
4805
4806 // If no targets are found and it's off cooldown, check again
4807 RecalcTimer(e, 1200, 1200);
4808 break;
4809 }
4812 {
4813 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4814 return;
4815 ProcessAction(e, unit);
4816 break;
4817 }
4818 default:
4819 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4820 break;
4821 }
4822}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1930
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:552
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:551
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:125
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:190
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:126
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:140
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:169
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:171
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:148
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:136
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:167
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:120
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:184
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:164
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:191
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:163
@ SMART_EVENT_WAYPOINT_PAUSED
Definition SmartScriptMgr.h:173
@ SMART_EVENT_WAYPOINT_DATA_ENDED
Definition SmartScriptMgr.h:217
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:139
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:160
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:138
@ SMART_EVENT_WAYPOINT_DATA_REACHED
Definition SmartScriptMgr.h:216
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:189
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:172
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:147
@ SMART_EVENT_WAYPOINT_START
Definition SmartScriptMgr.h:157
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:149
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:186
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:123
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:161
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:182
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:180
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:215
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:145
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:159
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:176
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:137
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:195
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:134
@ SMART_EVENT_WAYPOINT_RESUMED
Definition SmartScriptMgr.h:174
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:142
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:129
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:165
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:132
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:124
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:162
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:187
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:150
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:183
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:166
@ SMART_EVENT_WAYPOINT_STOPPED
Definition SmartScriptMgr.h:175
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:202
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:133
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:122
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:130
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:131
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:151
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:141
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:135
@ CURRENT_GENERIC_SPELL
Definition Unit.h:539
uint32 GetWaypointPath() const
Definition Creature.h:350
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5283
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5273
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:163
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5366
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5246
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5412
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5259
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:3319
Definition Spell.h:287
float GetHealthPct() const
Definition Unit.h:1031
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4132
uint32 GetMaxHealth() const
Definition Unit.h:1030
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:665
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5715
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1057
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10281
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:10276
bool IsInCombat() const
Definition Unit.h:877
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1493
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2506
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2513
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition Object.cpp:1332
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:141
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:272
uint32 pointId
Definition SmartScriptMgr.h:524
uint32 invert
Definition SmartScriptMgr.h:510
uint32 entry
Definition SmartScriptMgr.h:463
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:358
LOSHostilityMode
Definition SmartScriptMgr.h:540
uint32 cooldownMax
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:371
uint32 radius
Definition SmartScriptMgr.h:292
uint32 maxDist
Definition SmartScriptMgr.h:263
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:415
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:252
uint32 rangeMin
Definition SmartScriptMgr.h:237
uint32 eventId
Definition SmartScriptMgr.h:442
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:464
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:286
uint32 emote
Definition SmartScriptMgr.h:329
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:456
uint32 filter
Definition SmartScriptMgr.h:410
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:262
uint32 hpDeficit
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:273
uint32 count
Definition SmartScriptMgr.h:337
uint32 onlyInCombat
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:364
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:372
SAIBool playerOnly
Definition SmartScriptMgr.h:245
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:525
uint32 creatureEntry
Definition SmartScriptMgr.h:400
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:416
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:251
uint32 maxCount
Definition SmartScriptMgr.h:487
uint32 gameEventId
Definition SmartScriptMgr.h:432
uint32 textGroupID
Definition SmartScriptMgr.h:399
uint32 cooldownMin
Definition SmartScriptMgr.h:243
uint32 onRemove
Definition SmartScriptMgr.h:344
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:322
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:437
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:238
uint32 team
Definition SmartScriptMgr.h:387
uint32 range
Definition SmartScriptMgr.h:499
uint32 minCount
Definition SmartScriptMgr.h:478
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:246
uint32 phasemask
Definition SmartScriptMgr.h:427

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(), GetLastInvoker(), Unit::GetMaxHealth(), Unit::GetMaxPower(), GetPathId(), Unit::GetPowerPct(), GetTargets(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), Unit::GetVictim(), Creature::GetWaypointPath(), GetWorldObjectsInDist(), SmartEvent::gossip, SmartEvent::gossipHello, SmartEvent::goStateChanged, SmartEvent::guid, SmartEvent::Hostile, SmartEvent::hostilityMode, SmartEvent::hpDeficit, SmartEvent::hpPct, SmartEvent::id, SpellInfo::Id, SmartEvent::instancePlayerEnter, SmartEvent::invert, IsCharmedCreature(), IsCreature(), Unit::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_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_DATA_ENDED, SMART_EVENT_WAYPOINT_DATA_REACHED, SMART_EVENT_WAYPOINT_ENDED, SMART_EVENT_WAYPOINT_PAUSED, SMART_EVENT_WAYPOINT_REACHED, SMART_EVENT_WAYPOINT_RESUMED, SMART_EVENT_WAYPOINT_START, SMART_EVENT_WAYPOINT_STOPPED, 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 
)
136{
137 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
138 {
139 SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
140 if (eventType == SMART_EVENT_LINK)//special handling
141 continue;
142
143 if (eventType == e)
144 {
145 ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
146 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
147
148 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
149 {
150 ASSERT(executionStack.empty());
151 executionStack.emplace_back(SmartScriptFrame{ *i, unit, var0, var1, bvar, spell, gob });
152 while (!executionStack.empty())
153 {
154 auto [stack_holder , stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
155 executionStack.pop_back();
156 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
157 }
158 }
159 }
160 }
161}
#define sConditionMgr
Definition ConditionMgr.h:290
std::list< Condition * > ConditionList
Definition ConditionMgr.h:237
#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:4033
Definition ConditionMgr.h:182

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(), and SmartAI::UpdatePath().

◆ 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 
)
3320{
3321 // xinef: extended by selfs victim
3322 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3323 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3324
3325 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3326 {
3327 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3328 RecalcTimer(e, min, max);
3329 }
3330 else
3331 RecalcTimer(e, 5000, 5000);
3332}

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
5060{
5061 e.timer = 1200;
5062 // Change priority only if it's set to default, otherwise keep the current order of events
5064 {
5066 mEventSortingRequired = true;
5067 }
5068}
uint32 timer
Definition SmartScriptMgr.h:1984
uint32 priority
Definition SmartScriptMgr.h:1985

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
4858{
4859 // min/max was checked at loading!
4860 e.timer = urand(uint32(min), uint32(max));
4861 e.active = e.timer ? false : true;
4862}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5428{
5429 _summonList.erase(guid);
5430}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

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

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
5071{
5072 RaisePriority(e);
5073
5074 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5075 if (ignoreChanceRoll)
5077
5078 e.runOnce = false;
5079}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5059

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
5401{
5402 uint32 oldPhase = mEventPhase;
5403
5404 mEventPhase = p;
5405
5406 if (oldPhase != mEventPhase)
5407 {
5409 }
5410}

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 
)
5306{
5307 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5308 // any SmartScriptHolder contained like the "e" parameter passed to this function
5310 {
5311 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());
5312 return;
5313 }
5314
5315 // 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
5317 {
5318 return;
5319 }
5320
5321 mTimedActionList.clear();
5323 if (mTimedActionList.empty())
5324 return;
5325 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5326 {
5327 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5328
5329 if (e.action.timedActionList.timerType == 0)
5330 i->event.type = SMART_EVENT_UPDATE_OOC;
5331 else if (e.action.timedActionList.timerType == 1)
5332 i->event.type = SMART_EVENT_UPDATE_IC;
5333 else if (e.action.timedActionList.timerType > 1)
5334 i->event.type = SMART_EVENT_UPDATE;
5335
5336 InitTimer((*i));
5337 }
5338}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1772
SAIBool allowOverride
Definition SmartScriptMgr.h:1163
uint32 timerType
Definition SmartScriptMgr.h:1162

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
5055{
5056 std::sort(events.begin(), events.end());
5057}
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:2004

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4865{
4866 if (e.GetEventType() == SMART_EVENT_LINK)
4867 return;
4868
4870 return;
4871
4872 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4873 return;
4874
4875 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4876 return;
4877
4878 if (e.timer < diff)
4879 {
4880 // delay spell cast for another AI tick if another spell is being cast
4882 {
4884 {
4886 {
4887 RaisePriority(e);
4888 return;
4889 }
4890 }
4891 }
4892
4893 // Delay flee for assist event if casting
4895 {
4896 e.timer = 1200;
4897 return;
4898 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
4899
4900 e.active = true;//activate events with cooldown
4901 switch (e.GetEventType())//process ONLY timed events
4902 {
4907 case SMART_EVENT_UPDATE:
4914 case SMART_EVENT_RANGE:
4928 {
4929 ASSERT(executionStack.empty());
4930 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
4931 while (!executionStack.empty())
4932 {
4933 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
4934 executionStack.pop_back();
4935 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
4936 }
4938 {
4939 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
4940 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4941 {
4942 //find the first event which is not the current one and enable it
4943 if (i->event_id > e.event_id)
4944 {
4945 i->enableTimed = true;
4946 break;
4947 }
4948 }
4949 }
4950 break;
4951 }
4952 }
4953
4955 {
4956 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
4957 if (e.timer > 1)
4958 {
4959 // Re-sort events if this was moved to the top of the queue
4960 mEventSortingRequired = true;
4961 // Reset priority to default one
4963 }
4964 }
4965 }
4966 else
4967 e.timer -= diff;
4968}
@ UNIT_STATE_CASTING
Definition UnitDefines.h:185
bool enableTimed
Definition SmartScriptMgr.h:1988

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(), Unit::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: