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

#include "SmartScript.h"

Classes

struct  SmartScriptFrame
 

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ CounterMap

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

Constructor & Destructor Documentation

◆ SmartScript()

SmartScript::SmartScript ( )
Todo:
: this import is not necessary for compilation and marked as unused by the IDE
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:1772
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1525
uint32 mEventPhase
Definition SmartScript.h:232
SMARTAI_TEMPLATE mTemplate
Definition SmartScript.h:251
Creature * me
Definition SmartScript.h:226
uint32 mPathId
Definition SmartScript.h:235
SmartScriptType mScriptType
Definition SmartScript.h:231
bool _allowPhaseReset
Definition SmartScript.h:247
bool mUseTextTimer
Definition SmartScript.h:242
uint32 mLastTextID
Definition SmartScript.h:240
uint32 mTextTimer
Definition SmartScript.h:239
GameObject * go
Definition SmartScript.h:228
AreaTrigger const * trigger
Definition SmartScript.h:230
uint32 mCurrentPriority
Definition SmartScript.h:243
uint32 mTalkerEntry
Definition SmartScript.h:241
bool isProcessingTimedActionList
Definition SmartScript.h:225
bool mEventSortingRequired
Definition SmartScript.h:244

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

◆ ~SmartScript()

SmartScript::~SmartScript ( )
66{
67}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5456{
5457 _summonList.insert(guid);
5458}
GuidUnorderedSet _summonList
Definition SmartScript.h:284

References _summonList.

Referenced by SmartAI::JustSummoned().

◆ AddEvent()

void SmartScript::AddEvent ( SMART_EVENT  e,
uint32  event_flags,
uint32  event_param1,
uint32  event_param2,
uint32  event_param3,
uint32  event_param4,
uint32  event_param5,
uint32  event_param6,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
3446{
3447 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));
3448}
SmartAIEventList mInstallEvents
Definition SmartScript.h:223
static SmartScriptHolder CreateSmartEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
Definition SmartScript.cpp:3450

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
5004{
5005 return e.active;
5006}

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
3451{
3452 SmartScriptHolder script;
3453 script.event.type = e;
3454 script.event.raw.param1 = event_param1;
3455 script.event.raw.param2 = event_param2;
3456 script.event.raw.param3 = event_param3;
3457 script.event.raw.param4 = event_param4;
3458 script.event.raw.param5 = event_param5;
3459 script.event.raw.param6 = event_param6;
3460 script.event.event_phase_mask = phaseMask;
3461 script.event.event_flags = event_flags;
3462 script.event.event_chance = 100;
3463
3464 script.action.type = action;
3465 script.action.raw.param1 = action_param1;
3466 script.action.raw.param2 = action_param2;
3467 script.action.raw.param3 = action_param3;
3468 script.action.raw.param4 = action_param4;
3469 script.action.raw.param5 = action_param5;
3470 script.action.raw.param6 = action_param6;
3471
3472 script.target.type = t;
3473 script.target.raw.param1 = target_param1;
3474 script.target.raw.param2 = target_param2;
3475 script.target.raw.param3 = target_param3;
3476 script.target.raw.param4 = target_param4;
3477
3479 InitTimer(script);
3480 return script;
3481}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4857
uint32 param3
Definition SmartScriptMgr.h:1061
uint32 param5
Definition SmartScriptMgr.h:1063
uint32 param1
Definition SmartScriptMgr.h:1059
SMART_ACTION type
Definition SmartScriptMgr.h:745
struct SmartAction::@75::@195 raw
uint32 param4
Definition SmartScriptMgr.h:1062
uint32 param6
Definition SmartScriptMgr.h:1502
uint32 param2
Definition SmartScriptMgr.h:1060
uint32 param1
Definition SmartScriptMgr.h:514
uint32 event_flags
Definition SmartScriptMgr.h:209
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition SmartScriptMgr.h:207
uint32 param2
Definition SmartScriptMgr.h:515
uint32 param4
Definition SmartScriptMgr.h:517
uint32 param3
Definition SmartScriptMgr.h:516
uint32 param6
Definition SmartScriptMgr.h:519
uint32 event_chance
Definition SmartScriptMgr.h:208
uint32 param5
Definition SmartScriptMgr.h:518
SMART_EVENT type
Definition SmartScriptMgr.h:206
Definition SmartScriptMgr.h:1975
SmartAction action
Definition SmartScriptMgr.h:1986
SmartScriptType source_type
Definition SmartScriptMgr.h:1981
SmartEvent event
Definition SmartScriptMgr.h:1985
SmartTarget target
Definition SmartScriptMgr.h:1987
uint32 param4
Definition SmartScriptMgr.h:1747
struct SmartTarget::@199::@223 raw
uint32 param1
Definition SmartScriptMgr.h:1744
uint32 param3
Definition SmartScriptMgr.h:1746
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1596
uint32 param2
Definition SmartScriptMgr.h:1745

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
5422{
5423 if (p >= mEventPhase)
5424 {
5425 SetPhase(0);
5426 }
5427 else
5428 {
5429 SetPhase(mEventPhase - p);
5430 }
5431}
void SetPhase(uint32 p)
Definition SmartScript.cpp:5433

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5327{
5328 if (!me)
5329 return nullptr;
5330
5331 Unit* unit = nullptr;
5332 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5334 Cell::VisitObjects(me, searcher, range);
5335 return unit;
5336}
Definition Unit.h:655
Definition GridNotifiers.h:397
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References me, and Cell::VisitObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5307{
5308 if (!me)
5309 return;
5310
5311 Acore::FriendlyCCedInRange u_check(me, range);
5313 Cell::VisitObjects(me, searcher, range);
5314}
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:809
Definition GridNotifiers.h:464

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
5317{
5318 if (!me)
5319 return;
5320
5321 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5323 Cell::VisitObjects(me, searcher, range);
5324}
Definition GridNotifiers.h:827

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5280{
5281 if (!me)
5282 return nullptr;
5283
5284 Unit* unit = nullptr;
5285
5286 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5288 Cell::VisitObjects(me, searcher, range);
5289 return unit;
5290}
Definition GridNotifiers.h:766

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5293{
5294 if (!me)
5295 {
5296 return nullptr;
5297 }
5298
5299 Unit* unit = nullptr;
5300 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5302 Cell::VisitObjects(me, searcher, range);
5303 return unit;
5304}
Definition GridNotifiers.h:785

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5115{
5116 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5117
5118 if (e.empty())
5119 {
5120 if (obj)
5121 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5122
5123 if (at)
5124 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5125 return;
5126 }
5127 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5128 {
5129#ifndef ACORE_DEBUG
5130 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5131 continue;
5132#endif
5133
5134 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5135 {
5136 if (obj && obj->GetMap()->IsDungeon())
5137 {
5138 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5139 {
5140 mEvents.push_back((*i));
5141 }
5142 }
5143 continue;
5144 }
5145 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5146 }
5147}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition SmartScriptMgr.h:1941
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition SmartScriptMgr.h:1937
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:222
Map * GetMap() const
Definition Object.h:620

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

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

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

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

References mEvents.

Referenced by ProcessAction().

◆ GetBaseObject()

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

References go, and me.

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

◆ GetCounterValue()

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

References mCounterList.

Referenced by ProcessEvent().

◆ GetEvents()

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

References mEvents.

Referenced by SmartAI::InitializeAI().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5374{
5375 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5376 if (GetBaseObject())
5378 // xinef: used for area triggers invoker cast
5379 else if (invoker)
5381 return nullptr;
5382}
ObjectGuid mLastInvoker
Definition SmartScript.h:200
WorldObject * GetBaseObject() const
Definition SmartScript.h:64
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:115

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

Referenced by GetTargets(), and ProcessAction().

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5150{
5152 if (me)
5153 {
5154 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5155 if (e.empty())
5156 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5157
5158 FillScript(e, me, nullptr);
5159
5160 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5161 {
5162 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5163 {
5164 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5165 FillScript(e, me, nullptr);
5166 }
5167 }
5168 }
5169 else if (go)
5170 {
5171 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5172 if (e.empty())
5173 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5174 FillScript(e, go, nullptr);
5175 }
5176 else if (trigger)
5177 {
5178 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5179 FillScript(e, nullptr, trigger);
5180 }
5181}
@ 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:2071
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2247
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:205
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition SmartScript.cpp:5114
uint32 entry
Definition ObjectMgr.h:422
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:249

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3484{
3485 WorldObject* scriptTrigger = nullptr;
3486 if (invoker)
3487 scriptTrigger = invoker;
3488 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3489 scriptTrigger = tempLastInvoker;
3490
3491 WorldObject* baseObject = GetBaseObject();
3492
3493 switch (e.GetTargetType())
3494 {
3495 case SMART_TARGET_SELF:
3496 if (baseObject)
3497 targets.push_back(baseObject);
3498 break;
3500 if (me)
3501 if (Unit* victim = me->GetVictim())
3502 targets.push_back(victim);
3503 break;
3505 if (me)
3506 {
3507 if (e.target.hostileRandom.powerType)
3508 {
3509 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)))
3510 targets.push_back(u);
3511 }
3512 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3513 targets.push_back(u);
3514 }
3515 break;
3517 if (me)
3518 {
3519 if (e.target.hostileRandom.powerType)
3520 {
3521 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)))
3522 targets.push_back(u);
3523 }
3524 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3525 targets.push_back(u);
3526 }
3527 break;
3529 if (me)
3530 {
3531 if (e.target.hostileRandom.powerType)
3532 {
3533 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)))
3534 targets.push_back(u);
3535 }
3536 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3537 targets.push_back(u);
3538 }
3539 break;
3541 if (me)
3542 {
3543 if (e.target.hostileRandom.powerType)
3544 {
3545 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)))
3546 targets.push_back(u);
3547 }
3548 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3549 targets.push_back(u);
3550 }
3551 break;
3553 if (me)
3554 {
3555 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, RangeSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos, e.target.farthest.minDist)))
3556 targets.push_back(u);
3557 }
3558 break;
3560 if (scriptTrigger)
3561 targets.push_back(scriptTrigger);
3562 break;
3564 if (scriptTrigger && IsUnit(scriptTrigger))
3565 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3566 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3567 break;
3569 if (scriptTrigger)
3570 {
3571 if (Player* player = scriptTrigger->ToPlayer())
3572 {
3573 if (Group* group = player->GetGroup())
3574 {
3575 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3576 if (Player* member = groupRef->GetSource())
3577 {
3578 if (member->IsInMap(player))
3579 targets.push_back(member);
3580
3581 if (e.target.invokerParty.includePets)
3582 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3583 if (pet->IsPet() && pet->IsInMap(player))
3584 targets.push_back(pet);
3585 }
3586 }
3587 // We still add the player to the list if there is no group. If we do
3588 // this even if there is a group (thus the else-check), it will add the
3589 // same player to the list twice. We don't want that to happen.
3590 else
3591 targets.push_back(scriptTrigger);
3592 }
3593 }
3594 break;
3596 {
3597 WorldObject* ref = baseObject;
3598 if (!ref)
3599 ref = scriptTrigger;
3600
3601 if (!ref)
3602 {
3603 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3604 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3605 break;
3606 }
3607
3608 ObjectVector units;
3609 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3610
3611 for (WorldObject* unit : units)
3612 {
3613 if (!IsCreature(unit))
3614 continue;
3615
3616 if (me && me->GetGUID() == unit->GetGUID())
3617 continue;
3618
3619 // check alive state - 1 alive, 2 dead, 0 both
3620 if (uint32 state = e.target.unitRange.livingState)
3621 {
3622 if (unit->ToCreature()->IsAlive() && state == 2)
3623 continue;
3624 if (!unit->ToCreature()->IsAlive() && state == 1)
3625 continue;
3626 }
3627
3628 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))
3629 targets.push_back(unit);
3630 }
3631
3632 break;
3633 }
3635 {
3636 ObjectVector units;
3637 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3638
3639 for (WorldObject* unit : units)
3640 {
3641 if (!IsCreature(unit))
3642 continue;
3643
3644 if (me && me->GetGUID() == unit->GetGUID())
3645 continue;
3646
3647 // check alive state - 1 alive, 2 dead, 0 both
3648 if (uint32 state = e.target.unitDistance.livingState)
3649 {
3650 if (unit->ToCreature()->IsAlive() && state == 2)
3651 continue;
3652 if (!unit->ToCreature()->IsAlive() && state == 1)
3653 continue;
3654 }
3655
3656 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3657 targets.push_back(unit);
3658 }
3659
3660 break;
3661 }
3663 {
3664 ObjectVector units;
3665 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3666
3667 for (WorldObject* unit : units)
3668 {
3669 if (!IsGameObject(unit))
3670 continue;
3671
3672 if (go && go->GetGUID() == unit->GetGUID())
3673 continue;
3674
3675 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3676 targets.push_back(unit);
3677 }
3678
3679 break;
3680 }
3682 {
3683
3684 WorldObject* ref = baseObject;
3685 if (!ref)
3686 ref = scriptTrigger;
3687
3688 if (!ref)
3689 {
3690 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3691 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3692 break;
3693 }
3694
3695 ObjectVector units;
3696 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3697
3698 for (WorldObject* unit : units)
3699 {
3700 if (!IsGameObject(unit))
3701 continue;
3702
3703 if (go && go->GetGUID() == unit->GetGUID())
3704 continue;
3705
3706 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))
3707 targets.push_back(unit);
3708 }
3709
3710 break;
3711 }
3713 {
3714 if (!scriptTrigger && !baseObject)
3715 {
3716 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3717 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3718 break;
3719 }
3720
3721 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3722 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3723 targets.push_back(target);
3724 break;
3725 }
3727 {
3728 if (!scriptTrigger && !GetBaseObject())
3729 {
3730 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3731 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3732 break;
3733 }
3734
3735 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3736 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3737 targets.push_back(target);
3738 break;
3739 }
3741 {
3742 ObjectVector units;
3743 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3744
3745 if (!units.empty() && baseObject)
3746 for (WorldObject* unit : units)
3747 if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3748 targets.push_back(unit);
3749
3750 if (e.target.playerRange.maxCount)
3751 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3752
3753 break;
3754 }
3756 {
3757 ObjectVector units;
3758 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3759
3760 for (WorldObject* unit : units)
3761 if (IsPlayer(unit))
3762 targets.push_back(unit);
3763 break;
3764 }
3766 {
3767 WorldObject* ref = baseObject;
3768 if (!ref)
3769 ref = scriptTrigger;
3770
3771 if (!ref)
3772 {
3773 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3774 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3775 break;
3776 }
3777
3778 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3779 targets.assign(stored->begin(), stored->end());
3780 break;
3781 }
3783 {
3784 WorldObject* ref = baseObject;
3785
3786 if (!ref)
3787 ref = scriptTrigger;
3788
3789 if (!ref)
3790 {
3791 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3792 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3793 break;
3794 }
3795
3796 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3797 if (target)
3798 targets.push_back(target);
3799 break;
3800 }
3802 {
3803 WorldObject* ref = baseObject;
3804
3805 if (!ref)
3806 ref = scriptTrigger;
3807
3808 if (!ref)
3809 {
3810 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3811 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3812 break;
3813 }
3814
3815 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3816 if (target)
3817 targets.push_back(target);
3818 break;
3819 }
3821 {
3822 WorldObject* ref = baseObject;
3823
3824 if (!ref)
3825 ref = scriptTrigger;
3826
3827 if (!ref)
3828 {
3829 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3830 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3831 break;
3832 }
3833
3834 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3835 targets.push_back(target);
3836 break;
3837 }
3839 /*
3840 * Owners/Summoners should be WorldObjects. This allows to have other objects
3841 * such as gameobjects to execute SmartScripts using this type of target.
3842 * Otherwise, only Units like creatures can summon other creatures.
3843 */
3844 {
3845 if (me)
3846 {
3848 {
3849 targets.push_back(owner);
3850 }
3851 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3852 {
3853 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3854 }
3855 }
3856 else if (go)
3857 {
3859 {
3860 targets.push_back(owner);
3861 }
3862 }
3863
3864 // xinef: Get owner of owner
3865 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3866 {
3867 if (WorldObject* owner = targets.front())
3868 {
3869 targets.clear();
3870
3871 if (IsCreature(owner))
3872 {
3873 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3874 targets.push_back(base);
3875 }
3876 else if (IsGameObject(owner))
3877 {
3878 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3879 targets.push_back(base);
3880 }
3881 else if (IsPlayer(owner))
3882 {
3883 if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
3884 targets.push_back(base);
3885 }
3886 }
3887 }
3888 break;
3889 }
3891 {
3892 if (me)
3893 {
3895 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
3896 if (Unit* temp = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
3897 // Xinef: added distance check
3898 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3899 targets.push_back(temp);
3900 }
3901 break;
3902 }
3904 {
3905 if (me)
3906 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3907 targets.push_back(target);
3908
3909 break;
3910 }
3912 {
3913 if (me)
3914 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3915 targets.push_back(target);
3916
3917 break;
3918 }
3920 {
3921 ObjectVector units;
3922 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3923
3924 for (WorldObject* unit : units)
3925 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3926 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3927 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3928 targets.push_back(unit);
3929
3930 if (e.target.o > 0)
3931 Acore::Containers::RandomResize(targets, e.target.o);
3932
3933 break;
3934 }
3936 {
3937 ObjectVector units;
3938 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3939 // 1 = Tanks, 2 = Healer, 4 = Damage
3940 uint32 roleMask = e.target.roleSelection.roleMask;
3941 for (WorldObject* unit : units)
3942 if (Player* targetPlayer = unit->ToPlayer())
3943 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3944 {
3945 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3946 {
3947 if (targetPlayer->HasTankSpec())
3948 {
3949 targets.push_back(unit);
3950 continue;
3951 }
3952 }
3953 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3954 {
3955 if (targetPlayer->HasHealSpec())
3956 {
3957 targets.push_back(unit);
3958 continue;
3959 }
3960 }
3961 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3962 {
3963 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3964 {
3965 targets.push_back(unit);
3966 continue;
3967 }
3968 }
3969 }
3970
3971 if (e.target.roleSelection.resize > 0)
3972 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
3973
3974 break;
3975 }
3977 {
3978 if (me && me->IsVehicle())
3979 {
3980 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
3981 {
3982 targets.push_back(target);
3983 }
3984 }
3985 break;
3986 }
3988 {
3989 if (me)
3990 {
3991 if (Group* lootGroup = me->GetLootRecipientGroup())
3992 {
3993 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
3994 {
3995 if (Player* recipient = it->GetSource())
3996 {
3997 targets.push_back(recipient);
3998 }
3999 }
4000 }
4001 else
4002 {
4003 if (Player* recipient = me->GetLootRecipient())
4004 {
4005 targets.push_back(recipient);
4006 }
4007 }
4008 }
4009 break;
4010 }
4012 {
4013 if (me)
4014 {
4015 for (ObjectGuid const& guid : _summonList)
4016 {
4017 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
4018 {
4019 if (Creature* creature = me->GetMap()->GetCreature(guid))
4020 {
4021 targets.push_back(creature);
4022 }
4023 }
4024 }
4025 }
4026 break;
4027 }
4029 {
4030 InstanceScript* instance = nullptr;
4031
4032 if (e.IsAreatriggerScript() && scriptTrigger)
4033 instance = scriptTrigger->GetInstanceScript();
4034 else
4035 instance = GetBaseObject()->GetInstanceScript();
4036
4037 if (!instance)
4038 {
4039 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4040 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4041 return;
4042 }
4043
4044 if (e.target.instanceStorage.type == 1)
4045 {
4046 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
4047 targets.push_back(creature);
4048 }
4049 else if (e.target.instanceStorage.type == 2)
4050 {
4051 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4052 targets.push_back(go);
4053 }
4054
4055 break;
4056 }
4057 case SMART_TARGET_NONE:
4059 default:
4060 break;
4061 }
4062}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:905
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition ScriptedCreature.cpp:910
Powers
Definition SharedDefines.h:279
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition SmartScriptMgr.h:1766
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1765
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1767
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1563
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1547
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1542
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1562
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1565
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1549
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1546
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1576
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1538
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1545
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1557
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1541
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1539
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1559
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1537
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1573
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1575
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1543
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1544
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1540
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1558
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1577
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1564
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1560
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1561
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1536
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1554
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1548
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2012
Definition Creature.h:47
Player * GetLootRecipient() const
Definition Creature.cpp:1267
Group * GetLootRecipientGroup() const
Definition Creature.cpp:1274
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition Creature.cpp:2340
CreatureAI * AI() const
Definition Creature.h:144
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(uint32 type)
Definition InstanceScript.cpp:115
GameObject * GetGameObject(uint32 type)
Definition InstanceScript.cpp:120
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2357
Definition ObjectGuid.h:118
Player * ToPlayer()
Definition Object.h:201
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
Unit * ToUnit()
Definition Object.h:209
Definition Player.h:1066
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5384
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5389
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5394
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5373
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4064
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5410
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5326
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:277
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:790
Vehicle * GetVehicle() const
Definition Unit.h:1905
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition Unit.cpp:649
TempSummon * ToTempSummon()
Definition Unit.h:721
Unit * GetCharmerOrOwner() const
Definition Unit.h:1271
bool IsSummon() const
Definition Unit.h:784
Unit * GetVictim() const
Definition Unit.h:893
ThreatMgr & GetThreatMgr()
Definition Unit.h:943
Vehicle * GetVehicleKit() const
Definition Unit.h:1904
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1280
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:229
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1214
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2470
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1430
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:199
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition ObjectAccessor.cpp:234
Definition UnitAI.h:135
Definition UnitAI.h:170

References _summonList, Creature::AI(), SmartTarget::aura, SmartTarget::closestAttackable, SmartTarget::closestFriendly, SmartTarget::creature, SmartTarget::dbGuid, SmartTarget::dead, SmartTarget::dist, SmartTarget::distMax, SmartTarget::distMin, DoFindClosestFriendlyInRange(), SmartTarget::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, SmartTarget::farthest, FindCreatureNear(), FindGameObjectNear(), SmartScriptHolder::GetActionType(), Vehicle::GetBase(), GetBaseObject(), Unit::GetCharmerOrOwner(), Unit::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), InstanceScript::GetCreature(), ObjectAccessor::GetCreatureOrPetOrVehicle(), Object::GetEntry(), InstanceScript::GetGameObject(), 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, SmartScriptHolder::IsAreatriggerScript(), IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, MaxThreat, me, SmartTarget::minDist, MinDistance, MinThreat, SmartTarget::negation, SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, Random, Acore::Containers::RandomResize(), SmartTarget::resize, SmartTarget::roleMask, SmartTarget::roleSelection, SmartTarget::seatMask, WorldObject::SelectNearestPlayer(), Creature::SelectNearestTarget(), UnitAI::SelectTarget(), SMART_TARGET_ACTION_INVOKER, SMART_TARGET_ACTION_INVOKER_VEHICLE, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_ENEMY, SMART_TARGET_CLOSEST_FRIENDLY, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_FARTHEST, SMART_TARGET_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
4065{
4066 WorldObject* obj = GetBaseObject();
4067 if (!obj)
4068 return;
4069
4070 Acore::AllWorldObjectsInRange u_check(obj, dist);
4072 Cell::VisitObjects(obj, searcher, dist);
4073}
Definition GridNotifiers.h:1616
Definition GridNotifiers.h:230

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

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

◆ IncPhase()

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

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
4858{
4859 switch (e.GetEventType())
4860 {
4861 //set only events which have initial timers
4865 break;
4866 case SMART_EVENT_UPDATE:
4869 case SMART_EVENT_RANGE:
4876 break;
4880 break;
4884 break;
4885 default:
4886 e.active = true;
4887 break;
4888 }
4889}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition SmartScriptMgr.h:173
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition SmartScriptMgr.h:191
@ SMART_EVENT_AREA_CASTING
Definition SmartScriptMgr.h:194
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition SmartScriptMgr.h:175
@ SMART_EVENT_RANGE
Definition SmartScriptMgr.h:108
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition SmartScriptMgr.h:193
@ SMART_EVENT_UPDATE_IC
Definition SmartScriptMgr.h:99
@ SMART_EVENT_IS_IN_MELEE_RANGE
Definition SmartScriptMgr.h:199
@ SMART_EVENT_AREA_RANGE
Definition SmartScriptMgr.h:195
@ SMART_EVENT_UPDATE
Definition SmartScriptMgr.h:159
@ SMART_EVENT_IS_BEHIND_TARGET
Definition SmartScriptMgr.h:166
@ SMART_EVENT_UPDATE_OOC
Definition SmartScriptMgr.h:100
@ SMART_EVENT_NEAR_UNIT
Definition SmartScriptMgr.h:192
@ SMART_EVENT_DISTANCE_CREATURE
Definition SmartScriptMgr.h:174
@ SMART_EVENT_NEAR_PLAYERS
Definition SmartScriptMgr.h:190
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition SmartScript.cpp:4890
struct SmartEvent::@30::@68 nearPlayer
struct SmartEvent::@30::@32 minMaxRepeat
struct SmartEvent::@30::@70 nearUnit
uint32 repeat
Definition SmartScriptMgr.h:449
uint32 min
Definition SmartScriptMgr.h:214
uint32 firstTimer
Definition SmartScriptMgr.h:464
uint32 max
Definition SmartScriptMgr.h:215
uint32 timer
Definition SmartScriptMgr.h:484
struct SmartEvent::@30::@66 distance
bool active
Definition SmartScriptMgr.h:1999
uint32 GetEventType() const
Definition SmartScriptMgr.h:1991

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
5009{
5010 if (!mInstallEvents.empty())
5011 {
5012 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
5013 mEvents.push_back(*i);//must be before UpdateTimers
5014
5015 mInstallEvents.clear();
5016 }
5017}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3372{
3373 if (!GetBaseObject())
3374 return;
3376 {
3377 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3378 return;
3379 }
3380 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3381 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3382 {
3384 {
3385 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);
3386 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);
3387 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);
3388 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);
3389 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);
3390 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);
3391 break;
3392 }
3394 {
3395 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);
3396 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);
3397 break;
3398 }
3400 {
3401 if (!me)
3402 return;
3403 //store cage as id1
3404 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);
3405
3406 //reset(close) cage on hostage(me) respawn
3407 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);
3408
3409 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);
3410 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);
3411
3412 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);
3413 //phase 1: give quest credit on movepoint reached
3415 //phase 1: despawn after time on movepoint reached
3416 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);
3417
3418 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3419 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);
3420 break;
3421 }
3423 {
3424 if (!go)
3425 return;
3426 //store hostage as id1
3427 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);
3428 //store invoker as id2
3429 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);
3430 //signal hostage
3431 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);
3432 //when hostage raeched end point, give credit to invoker
3433 if (e.action.installTtemplate.param2)
3434 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);
3435 else
3436 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);
3437 break;
3438 }
3440 default:
3441 return;
3442 }
3443}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:110
std::uint8_t uint8
Definition Define.h:109
@ POINT_MOTION_TYPE
Definition MotionMaster.h:48
SMARTAI_TEMPLATE
Definition SmartScriptMgr.h:1524
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1529
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1530
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1526
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1527
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1930
@ SMART_ACTION_STORE_TARGET_LIST
Definition SmartScriptMgr.h:606
@ SMART_ACTION_FORCE_DESPAWN
Definition SmartScriptMgr.h:583
@ SMART_ACTION_CAST
Definition SmartScriptMgr.h:553
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition SmartScriptMgr.h:563
@ SMART_ACTION_MOVE_FORWARD
Definition SmartScriptMgr.h:588
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition SmartScriptMgr.h:575
@ SMART_ACTION_TALK
Definition SmartScriptMgr.h:543
@ SMART_ACTION_SET_DATA
Definition SmartScriptMgr.h:587
@ SMART_ACTION_SET_RUN
Definition SmartScriptMgr.h:601
@ SMART_ACTION_SET_EVENT_PHASE
Definition SmartScriptMgr.h:564
@ SMART_ACTION_RESET_GOBJECT
Definition SmartScriptMgr.h:574
@ SMART_EVENT_DATA_SET
Definition SmartScriptMgr.h:137
@ SMART_EVENT_JUST_CREATED
Definition SmartScriptMgr.h:162
@ SMART_EVENT_MOVEMENTINFORM
Definition SmartScriptMgr.h:133
@ SMART_EVENT_MANA_PCT
Definition SmartScriptMgr.h:102
@ SMART_EVENT_GO_STATE_CHANGED
Definition SmartScriptMgr.h:169
@ SMART_RANDOM_POINT
Definition SmartScriptMgr.h:39
void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
Definition SmartScript.cpp:3445

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
5400{
5401 if (!obj)
5402 return false;
5403
5404 if (Creature* creatureObj = obj->ToCreature())
5405 return creatureObj->IsCharmed();
5406
5407 return false;
5408}
Creature * ToCreature()
Definition Object.h:205

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5395{
5396 return obj && obj->IsCreature();
5397}
bool IsCreature() const
Definition Object.h:204

References Object::IsCreature().

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5411{
5412 return obj && obj->IsGameObject();
5413}
bool IsGameObject() const
Definition Object.h:212

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5446{
5447 if (mEventPhase == 0)
5448 {
5449 return false;
5450 }
5451
5452 return ((1 << (mEventPhase - 1)) & p) != 0;
5453}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5390{
5391 return obj && obj->IsPlayer();
5392}
bool IsPlayer() const
Definition Object.h:200

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

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

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

bool SmartScript::IsSmart ( GameObject g,
bool  silent = false 
) const
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:276

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5385{
5386 return obj && (obj->IsCreature() || obj->IsPlayer());
5387}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5184{
5185 if (obj)//handle object based scripts
5186 {
5187 switch (obj->GetTypeId())
5188 {
5189 case TYPEID_UNIT:
5191 me = obj->ToCreature();
5192 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5193 break;
5194 case TYPEID_GAMEOBJECT:
5196 go = obj->ToGameObject();
5197 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5198 break;
5199 default:
5200 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5201 return;
5202 }
5203 }
5204 else if (at)
5205 {
5207 trigger = at;
5208 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5209 }
5210 else
5211 {
5212 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5213 return;
5214 }
5215
5216 GetScript();//load copy of script
5217
5218 for (SmartScriptHolder& event : mEvents)
5219 InitTimer(event);//calculate timers for first time use
5220
5222 InstallEvents();
5224}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1773
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1774
@ SMART_EVENT_AI_INIT
Definition SmartScriptMgr.h:136
TypeID GetTypeId() const
Definition Object.h:128
GameObject * ToGameObject()
Definition Object.h:213
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:5008
void GetScript()
Definition SmartScript.cpp:5149

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)
5227{
5228 if (!me)
5229 return;
5230
5232}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:125
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:109
bool IsEngaged() const
Definition Unit.h:921

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:1938
@ SMART_EVENT_RESET
Definition SmartScriptMgr.h:124
void Clear()
Definition ObjectGuid.h:138
bool AllowPhaseReset() const
Definition SmartScript.h:204
void ResetBaseObject()
Definition SmartScript.h:166
static constexpr uint32 DEFAULT_PRIORITY
Definition SmartScriptMgr.h:2009

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)
5020{
5022 return;
5023
5024 InstallEvents();//before UpdateTimers
5025
5027 {
5029 mEventSortingRequired = false;
5030 }
5031
5032 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
5033 UpdateTimer(*i, diff);
5034
5035 if (!mStoredEvents.empty())
5036 {
5037 SmartAIEventStoredList::iterator i, icurr;
5038 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
5039 {
5040 icurr = i++;
5041 UpdateTimer(*icurr, diff);
5042 }
5043 }
5044
5045 bool needCleanup = true;
5046 if (!mTimedActionList.empty())
5047 {
5049 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5050 {
5051 if ((*i).enableTimed)
5052 {
5053 UpdateTimer(*i, diff);
5054 needCleanup = false;
5055 }
5056 }
5057
5059 }
5060 if (needCleanup)
5061 mTimedActionList.clear();
5062
5063 if (!mRemIDs.empty())
5064 {
5065 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5067
5068 // xinef: clear list after cleaning...
5069 mRemIDs.clear();
5070 }
5071 if (mUseTextTimer && me)
5072 {
5073 if (mTextTimer < diff)
5074 {
5075 uint32 textID = mLastTextID;
5076 mLastTextID = 0;
5077 uint32 entry = mTalkerEntry;
5078 mTalkerEntry = 0;
5079 mTextTimer = 0;
5080 mUseTextTimer = false;
5081 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5082 }
5083 else mTextTimer -= diff;
5084 }
5085}
@ SMART_EVENT_TEXT_OVER
Definition SmartScriptMgr.h:151
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition SmartScript.cpp:4897
void SortEvents(SmartAIEventList &events)
Definition SmartScript.cpp:5087
SmartAIEventStoredList mStoredEvents
Definition SmartScript.h:236
std::list< uint32 > mRemIDs
Definition SmartScript.h:237
SmartAIEventList mTimedActionList
Definition SmartScript.h:224
void RemoveStoredEvent(uint32 id)
Definition SmartScript.h:254

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

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

◆ ProcessAction()

void SmartScript::ProcessAction ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
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
242 talker->AI()->Talk(e.action.talk.textGroupID, talkTarget, Milliseconds(e.action.talk.delay));
243 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} ({}), textId: {}", talker->GetName(), talker->GetGUID().ToString(), mLastTextID);
244 break;
245 }
247 {
248 for (WorldObject* target : targets)
249 {
250 if (IsCreature(target))
251 sCreatureTextMgr->SendChat(target->ToCreature(), uint8(e.action.simpleTalk.textGroupID), IsPlayer(GetLastInvoker()) ? GetLastInvoker() : 0);
252 else if (IsPlayer(target) && me)
253 {
254 WorldObject* templastInvoker = GetLastInvoker();
255 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());
256 }
257
258 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: {} ({}), textGroupId: {}",
259 target->GetName(), target->GetGUID().ToString(), uint8(e.action.simpleTalk.textGroupID));
260 }
261 break;
262 }
264 {
265 for (WorldObject* target : targets)
266 {
267 if (IsUnit(target))
268 {
269 target->ToUnit()->HandleEmoteCommand(e.action.emote.emote);
270 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: {} ({}), emote: {}",
271 target->GetName(), target->GetGUID().ToString(), e.action.emote.emote);
272 }
273 }
274 break;
275 }
277 {
278 for (WorldObject* target : targets)
279 {
280 if (IsUnit(target))
281 {
282 if (e.action.sound.distance == 1)
283 target->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
284 else
285 target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
286 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} ({}), sound: {}, onlyself: {}",
287 target->GetName(), target->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
288 }
289 }
290 break;
291 }
293 {
294 uint32 sounds[4];
295 sounds[0] = e.action.randomSound.sound1;
296 sounds[1] = e.action.randomSound.sound2;
297 sounds[2] = e.action.randomSound.sound3;
298 sounds[3] = e.action.randomSound.sound4;
299 uint32 temp[4];
300 uint32 count = 0;
301 for (unsigned int sound : sounds)
302 {
303 if (sound)
304 {
305 temp[count] = sound;
306 ++count;
307 }
308 }
309
310 if (count == 0)
311 {
312 break;
313 }
314
315 for (WorldObject* target : targets)
316 {
317 if (IsUnit(target))
318 {
319 uint32 sound = temp[urand(0, count - 1)];
320 target->PlayDirectSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
321 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
322 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
323 }
324 }
325
326 break;
327 }
329 {
330 ObjectVector targets;
331
332 if (e.action.music.type > 0)
333 {
334 if (me && me->FindMap())
335 {
336 Map::PlayerList const& players = me->GetMap()->GetPlayers();
337
338 if (!players.IsEmpty())
339 {
340 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
341 if (Player* player = i->GetSource())
342 {
343 if (player->GetZoneId() == me->GetZoneId())
344 {
345 if (e.action.music.type > 1)
346 {
347 if (player->GetAreaId() == me->GetAreaId())
348 targets.push_back(player);
349 }
350 else
351 targets.push_back(player);
352 }
353 }
354 }
355 }
356 }
357 else
358 GetTargets(targets, e);
359
360 if (!targets.empty())
361 {
362 for (WorldObject* target : targets)
363 {
364 if (IsUnit(target))
365 {
366 target->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0);
367 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: {} ({}), sound: {}, onlySelf: {}, type: {}",
368 target->GetName(), target->GetGUID().ToString(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type);
369 }
370 }
371 }
372 break;
373 }
375 {
376 ObjectVector targets;
377
378 if (e.action.randomMusic.type > 0)
379 {
380 if (me && me->FindMap())
381 {
382 Map::PlayerList const& players = me->GetMap()->GetPlayers();
383
384 if (!players.IsEmpty())
385 {
386 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
387 if (Player* player = i->GetSource())
388 {
389 if (player->GetZoneId() == me->GetZoneId())
390 {
391 if (e.action.randomMusic.type > 1)
392 {
393 if (player->GetAreaId() == me->GetAreaId())
394 targets.push_back(player);
395 }
396 else
397 targets.push_back(player);
398 }
399 }
400 }
401 }
402 }
403 else
404 GetTargets(targets, e);
405
406 if (targets.empty())
407 break;
408
409 uint32 sounds[4];
410 sounds[0] = e.action.randomMusic.sound1;
411 sounds[1] = e.action.randomMusic.sound2;
412 sounds[2] = e.action.randomMusic.sound3;
413 sounds[3] = e.action.randomMusic.sound4;
414 uint32 temp[4];
415 uint32 count = 0;
416 for (unsigned int sound : sounds)
417 {
418 if (sound)
419 {
420 temp[count] = sound;
421 ++count;
422 }
423 }
424
425 if (count == 0)
426 {
427 break;
428 }
429
430 for (WorldObject* target : targets)
431 {
432 if (IsUnit(target))
433 {
434 uint32 sound = temp[urand(0, count - 1)];
435 target->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0);
436 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: {} ({}), sound: {}, onlyself: {}, type: {}",
437 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type);
438 }
439 }
440
441 break;
442 }
444 {
445 for (WorldObject* target : targets)
446 {
447 if (IsCreature(target))
448 {
450 {
451 target->ToCreature()->SetFaction(e.action.faction.factionID);
452 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
453 target->GetEntry(), target->GetGUID().ToString(), e.action.faction.factionID);
454 }
455 else
456 {
457 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(target->ToCreature()->GetEntry()))
458 {
459 if (target->ToCreature()->GetFaction() != ci->faction)
460 {
461 target->ToCreature()->SetFaction(ci->faction);
462 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
463 target->GetEntry(), target->GetGUID().ToString(), ci->faction);
464 }
465 }
466 }
467 }
468 }
469 break;
470 }
472 {
473 for (WorldObject* target : targets)
474 {
475 if (!IsCreature(target))
476 continue;
477
479 {
480 //set model based on entry from creature_template
482 {
483 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
484 {
485 CreatureModel const* model = ObjectMgr::ChooseDisplayId(ci);
486 target->ToCreature()->SetDisplayId(model->CreatureDisplayID, model->DisplayScale);
487 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
488 target->GetEntry(), target->GetGUID().ToString(), model->CreatureDisplayID);
489 }
490 }
491 //if no param1, then use value from param2 (modelId)
492 else
493 {
494 target->ToCreature()->SetDisplayId(e.action.morphOrMount.model);
495 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
496 target->GetEntry(), target->GetGUID().ToString(), e.action.morphOrMount.model);
497 }
498 }
499 else
500 {
501 target->ToCreature()->DeMorph();
502 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} demorphs.",
503 target->GetEntry(), target->GetGUID().ToString());
504 }
505 }
506 break;
507 }
509 {
510 for (WorldObject* target : targets)
511 {
512 if (IsPlayer(target))
513 {
514 target->ToPlayer()->FailQuest(e.action.quest.quest);
515 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow {} fails quest {}",
516 target->GetGUID().ToString(), e.action.quest.quest);
517 }
518 }
519 break;
520 }
522 {
523 for (WorldObject* target : targets)
524 {
525 if (Player* player = target->ToPlayer())
526 {
527 if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.questOffer.questID))
528 {
529 if (me && e.action.questOffer.directAdd == 0)
530 {
531 if (player->CanTakeQuest(q, true))
532 {
533 if (WorldSession* session = player->GetSession())
534 {
535 PlayerMenu menu(session);
536 menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true);
537 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - offering quest {}",
538 player->GetGUID().ToString(), e.action.questOffer.questID);
539 }
540 }
541 }
542 else
543 {
544 player->AddQuestAndCheckCompletion(q, nullptr);
545 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - quest {} added",
546 player->GetGUID().ToString(), e.action.questOffer.questID);
547 }
548 }
549 }
550 }
551 break;
552 }
554 {
555 for (WorldObject* target : targets)
556 {
557 if (!IsCreature(target))
558 continue;
559
560 target->ToCreature()->SetReactState(ReactStates(e.action.react.state));
561 }
562 break;
563 }
565 {
566 std::vector<uint32> emotes;
567 std::copy_if(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(),
568 std::back_inserter(emotes), [](uint32 emote) { return emote != 0; });
569
570 for (WorldObject* target : targets)
571 {
572 if (IsUnit(target))
573 {
575 target->ToUnit()->HandleEmoteCommand(emote);
576 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow {} handle random emote {}",
577 target->GetGUID().ToString(), emote);
578 }
579 }
580 break;
581 }
583 {
584 if (!me)
585 break;
586
588 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
589 {
590 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
591 {
593 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}",
594 me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
595 }
596 }
597 break;
598 }
600 {
601 if (!me)
602 break;
603
604 for (WorldObject* target : targets)
605 {
606 if (IsUnit(target))
607 {
608 me->GetThreatMgr().ModifyThreatByPercent(target->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
609 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow {} modify threat for unit {}, value {}",
610 me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
611 }
612 }
613 break;
614 }
616 {
617 for (WorldObject* target : targets)
618 {
619 // Special handling for vehicles
620 if (IsUnit(target))
621 if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
622 for (auto & Seat : vehicle->Seats)
623 if (Player* player = ObjectAccessor::GetPlayer(*target, Seat.second.Passenger.Guid))
624 player->AreaExploredOrEventHappens(e.action.quest.quest);
625
626 if (IsPlayer(target))
627 {
628 target->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest);
629
630 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow {} credited quest {}",
631 target->GetGUID().ToString(), e.action.quest.quest);
632 }
633 }
634 break;
635 }
637 {
638 if (targets.empty())
639 break;
640
641 Unit* caster = me;
642 // Areatrigger Cast!
643 if (e.IsAreatriggerScript())
644 caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
645
648
649 bool failedSpellCast = false, successfulSpellCast = false;
650
651 for (WorldObject* target : targets)
652 {
653 // may be nullptr
654 if (go)
655 go->CastSpell(target->ToUnit(), e.action.cast.spell);
656
657 if (!IsUnit(target))
658 continue;
659
660 if (caster && caster != me) // Areatrigger cast
661 {
662 caster->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
663 }
664 else if (me)
665 {
666 // If target has the aura, skip
667 if ((e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) && target->ToUnit()->HasAura(e.action.cast.spell))
668 continue;
669
670 // If the threatlist is a singleton, cancel
672 if (me->GetThreatMgr().GetThreatListSize() <= 1)
673 break;
674
675 // If target does not use mana, skip
676 if ((e.action.cast.castFlags & SMARTCAST_TARGET_POWER_MANA) && !target->ToUnit()->GetPower(POWER_MANA))
677 continue;
678
679 // Interrupts current spellcast
682
683 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
684 float distanceToTarget = me->GetDistance(target->ToUnit());
685 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
686 float spellMinRange = me->GetSpellMinRangeForTarget(target->ToUnit(), spellInfo);
687 float meleeRange = me->GetMeleeRange(target->ToUnit());
688
689 bool isWithinLOSInMap = me->IsWithinLOSInMap(target->ToUnit(), VMAP::ModelIgnoreFlags::M2);
690 bool isWithinMeleeRange = distanceToTarget <= meleeRange;
691 bool isRangedAttack = spellMaxRange > NOMINAL_MELEE_RANGE;
692 bool isTargetRooted = target->ToUnit()->HasUnitState(UNIT_STATE_ROOT);
693 // To prevent running back and forth when OOM, we must have more than 10% mana.
694 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);
695 bool isSpellIgnoreLOS = spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT);
696
697 // If target is rooted we move out of melee range before casting, but not further than spell max range.
698 if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle())
699 {
700 failedSpellCast = true; // Mark spellcast as failed so we can retry it later
701
702 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
703 continue;
704
705 float minDistance = std::max(meleeRange, spellMinRange) - distanceToTarget + NOMINAL_MELEE_RANGE;
706 CAST_AI(SmartAI, me->AI())->DistanceYourself(std::min(minDistance, spellMaxRange));
707 continue;
708 }
709
710 if (distanceToTarget > spellMaxRange && isWithinLOSInMap)
711 {
712 failedSpellCast = true;
713
714 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
715 continue;
716
718 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
719
720 continue;
721 }
722 else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS))
723 {
724 failedSpellCast = true;
725
726 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
727 continue;
728
729 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, 0.f);
731 CAST_AI(SmartAI, me->AI())->SetCombatMovement(true, true);
732 continue;
733 }
734
735 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
737 {
739 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
740 else
741 triggerFlags = TRIGGERED_FULL_MASK;
742 }
743
744 SpellCastResult result = me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
745 bool spellCastFailed = (result != SPELL_CAST_OK && result != SPELL_FAILED_SPELL_IN_PROGRESS);
746
748 {
749 if (result == SPELL_FAILED_OUT_OF_RANGE)
750 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
751 else if (result != SPELL_CAST_OK)
752 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(false, 0.f);
753 }
754
755 if (spellCastFailed)
756 failedSpellCast = true;
757 else
758 successfulSpellCast = true;
759
760 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
761 me->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
762 }
763 }
764
765 // If there is at least 1 failed cast and no successful casts at all, retry again on next loop
766 if (failedSpellCast && !successfulSpellCast)
767 {
768 RetryLater(e, true);
769 // Don't execute linked events
770 return;
771 }
772
773 break;
774 }
776 {
777 if (targets.empty())
778 break;
779
782
783 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
785 {
787 {
788 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
789 }
790 else
791 {
792 triggerFlags = TRIGGERED_FULL_MASK;
793 }
794 }
795
796 for (WorldObject* target : targets)
797 {
798 Unit* uTarget = target->ToUnit();
799 if (!uTarget)
800 continue;
801
803 {
805 {
806 uTarget->InterruptNonMeleeSpells(false);
807 }
808
809 uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
810 }
811 }
812 break;
813 }
815 {
816 // Can be used for area trigger cast
817 WorldObject* tempLastInvoker = GetLastInvoker(unit);
818 if (!tempLastInvoker)
819 break;
820
821 if (targets.empty())
822 break;
823
826
827 for (WorldObject* target : targets)
828 {
829 if (!IsUnit(target))
830 continue;
831
832 if (!IsUnit(tempLastInvoker))
833 continue;
834
835 if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
836 {
838 {
839 tempLastInvoker->ToUnit()->InterruptNonMeleeSpells(false);
840 }
841
842 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
844 {
846 {
847 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
848 }
849 else
850 {
851 triggerFlags = TRIGGERED_FULL_MASK;
852 }
853 }
854
855 tempLastInvoker->ToUnit()->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
856 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
857 tempLastInvoker->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
858 }
859 else
860 {
861 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
862 e.action.cast.spell, target->GetGUID().ToString());
863 }
864 }
865 break;
866 }
868 {
869 for (WorldObject* target : targets)
870 {
871 if (IsUnit(target))
872 {
873 target->ToUnit()->AddAura(e.action.cast.spell, target->ToUnit());
874 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura {} to unit {}",
875 e.action.cast.spell, target->GetGUID().ToString());
876 }
877 }
878 break;
879 }
881 {
882 for (WorldObject* target : targets)
883 {
884 if (IsGameObject(target))
885 {
886 GameObject* go = target->ToGameObject();
887
888 // Activate
890 {
892 }
893
895 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject {} activated", go->GetGUID().ToString());
896 }
897 }
898
899 break;
900 }
902 {
903 for (WorldObject* target : targets)
904 {
905 if (IsGameObject(target))
906 {
907 target->ToGameObject()->ResetDoorOrButton();
908 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject {} (entry: {}) reset",
909 target->GetGUID().ToString(), target->GetEntry());
910 }
911 }
912 break;
913 }
915 {
916 for (WorldObject* target : targets)
917 {
918 if (IsUnit(target))
919 {
920 target->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
921 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit {} set emotestate to {}",
922 target->GetGUID().ToString(), e.action.emote.emote);
923 }
924 }
925 break;
926 }
928 {
929 for (WorldObject* target : targets)
930 {
931 if (IsUnit(target))
932 {
933 if (!e.action.unitFlag.type)
934 {
935 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
936 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS",
937 target->GetGUID().ToString(), e.action.unitFlag.flag);
938 }
939 else
940 {
941 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
942 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS_2",
943 target->GetGUID().ToString(), e.action.unitFlag.flag);
944 }
945 }
946 }
947 break;
948 }
950 {
951 for (WorldObject* target : targets)
952 {
953 if (IsUnit(target))
954 {
955 if (!e.action.unitFlag.type)
956 {
957 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
958 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS",
959 target->GetGUID().ToString(), e.action.unitFlag.flag);
960 }
961 else
962 {
963 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
964 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS_2",
965 target->GetGUID().ToString(), e.action.unitFlag.flag);
966 }
967 }
968 }
969 break;
970 }
972 {
973 if (!IsSmart())
974 break;
975
976 CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack);
977 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
979 break;
980 }
982 {
983 if (!IsSmart())
984 break;
985
986 bool move = e.action.combatMove.move;
987 CAST_AI(SmartAI, me->AI())->SetCombatMovement(move, true);
988 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature {} bool on = {}",
990 break;
991 }
993 {
994 if (!GetBaseObject())
995 break;
996
998 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature {} set event phase {}",
1000 break;
1001 }
1003 {
1004 if (!GetBaseObject())
1005 break;
1006
1009 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature {} inc event phase by {}, "
1010 "decrease by {}", GetBaseObject()->GetGUID().ToString(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
1011 break;
1012 }
1013 case SMART_ACTION_EVADE:
1014 {
1015 if (!GetBaseObject())
1016 break;
1017
1018 for (WorldObject* target : targets)
1019 if (IsCreature(target))
1020 if (target->ToCreature()->IsAIEnabled)
1021 target->ToCreature()->AI()->EnterEvadeMode();
1022
1023 break;
1024 }
1026 {
1027 // Xinef: do not allow to flee without control (stun, fear etc)
1029 break;
1030
1032 if (e.action.flee.withEmote)
1033 {
1035 sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
1036 }
1037 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature {} DoFleeToGetAssistance", me->GetGUID().ToString());
1038 break;
1039 }
1041 {
1042 if (!me)
1043 break;
1044
1045 me->CombatStop(true);
1046 break;
1047 }
1049 {
1050 for (WorldObject* target : targets)
1051 {
1052 if (!IsUnit(target))
1053 continue;
1054
1055 Unit* unitTarget = target->ToUnit();
1056 // If invoker was pet or charm
1057 Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself();
1058 if (player && GetBaseObject())
1059 {
1060 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1061 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {}, group credit for quest {}",
1062 player->GetGUID().ToString(), e.action.quest.quest);
1063 }
1064
1065 // Special handling for vehicles
1066 if (Vehicle* vehicle = unitTarget->GetVehicleKit())
1067 {
1068 for (auto& Seat : vehicle->Seats)
1069 {
1070 if (Player* player = ObjectAccessor::GetPlayer(*unitTarget, Seat.second.Passenger.Guid))
1071 {
1072 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1073 }
1074 }
1075 }
1076 }
1077 break;
1078 }
1080 {
1081 for (WorldObject* target : targets)
1082 {
1083 if (!IsUnit(target))
1084 continue;
1085
1086 if (e.action.removeAura.spell)
1087 {
1089 {
1090 if (Aura* aur = target->ToUnit()->GetAura(e.action.removeAura.spell))
1091 aur->ModCharges(-static_cast<int32>(e.action.removeAura.charges), AURA_REMOVE_BY_EXPIRE);
1092 }
1093 else
1094 target->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
1095 }
1096 else
1097 target->ToUnit()->RemoveAllAuras();
1098
1099 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {}, spell {}",
1100 target->GetGUID().ToString(), e.action.removeAura.spell);
1101 }
1102 break;
1103 }
1105 {
1106 if (!IsSmart())
1107 break;
1108
1110 {
1111 CAST_AI(SmartAI, me->AI())->StopFollow(false);
1112 break;
1113 }
1114
1115 for (WorldObject* target : targets)
1116 {
1117 if (IsUnit(target))
1118 {
1119 float angle = e.action.follow.angle > 6 ? (e.action.follow.angle * M_PI / 180.0f) : e.action.follow.angle;
1120 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);
1121 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature {} following target {}",
1122 me->GetGUID().ToString(), target->GetGUID().ToString());
1123 break;
1124 }
1125 }
1126 break;
1127 }
1129 {
1130 if (!GetBaseObject())
1131 break;
1132
1133 std::vector<uint32> phases;
1134 std::copy_if(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(),
1135 std::back_inserter(phases), [](uint32 phase) { return phase != 0; });
1136
1138 SetPhase(phase);
1139 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature {} sets event phase to {}",
1140 GetBaseObject()->GetGUID().ToString(), phase);
1141 break;
1142 }
1144 {
1145 if (!GetBaseObject())
1146 break;
1147
1149 SetPhase(phase);
1150 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature {} sets event phase to {}",
1151 GetBaseObject()->GetGUID().ToString(), phase);
1152 break;
1153 }
1155 {
1156 if (trigger && IsPlayer(unit))
1157 {
1159 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player {}, Killcredit: {}",
1161 }
1162 else if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members
1163 {
1164 if (!me)
1165 break;
1166
1167 if (Player* player = me->GetLootRecipient())
1168 {
1170 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1172 }
1173 }
1174 else // Specific target type
1175 {
1176 for (WorldObject* target : targets)
1177 {
1178 if (!IsUnit(target))
1179 continue;
1180
1182 if (!player)
1183 continue;
1184
1186 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1187 target->GetGUID().ToString(), e.action.killedMonster.creature);
1188 }
1189 }
1190 break;
1191 }
1193 {
1194 WorldObject* obj = GetBaseObject();
1195 if (!obj)
1196 obj = unit;
1197
1198 if (!obj)
1199 break;
1200
1201 InstanceScript* instance = obj->GetInstanceScript();
1202 if (!instance)
1203 {
1204 LOG_ERROR("scripts.ai.sai", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1205 break;
1206 }
1207
1208 switch (e.action.setInstanceData.type)
1209 {
1210 case 0:
1211 {
1213 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: Field: {}, data: {}", e.action.setInstanceData.field, e.action.setInstanceData.data);
1214 } break;
1215 case 1:
1216 {
1218 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));
1219 } break;
1220 default:
1221 {
1222 break;
1223 }
1224 }
1225 break;
1226 }
1228 {
1229 WorldObject* obj = GetBaseObject();
1230 if (!obj)
1231 obj = unit;
1232
1233 if (!obj)
1234 break;
1235
1236 InstanceScript* instance = obj->GetInstanceScript();
1237 if (!instance)
1238 {
1239 LOG_ERROR("sql.sql", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1240 break;
1241 }
1242
1243 if (targets.empty())
1244 break;
1245
1246 instance->SetGuidData(e.action.setInstanceData64.field, targets.front()->GetGUID());
1247 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: {}, data: {}",
1248 e.action.setInstanceData64.field, targets.front()->GetGUID().ToString());
1249 break;
1250 }
1252 {
1253 for (WorldObject* target : targets)
1254 if (IsCreature(target))
1255 target->ToCreature()->UpdateEntry(e.action.updateTemplate.creature, target->ToCreature()->GetCreatureData(), e.action.updateTemplate.updateLevel != 0);
1256 break;
1257 }
1258 case SMART_ACTION_DIE:
1259 {
1260 if (e.action.die.milliseconds)
1261 {
1262 if (me && !me->isDead())
1263 {
1265 {
1266 // We need to check again to see if we didn't die in the process.
1267 if (me && !me->isDead())
1268 {
1269 me->KillSelf();
1270 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1271 }
1273 }
1274 }
1275 else if (me && !me->isDead())
1276 {
1277 me->KillSelf();
1278 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1279 }
1280 break;
1281 }
1283 {
1284 if (targets.empty())
1285 break;
1286
1287 if (!me->GetMap()->IsDungeon())
1288 {
1289 ObjectVector units;
1290 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
1291
1292 if (!units.empty() && GetBaseObject())
1293 for (WorldObject* unit : units)
1294 if (IsPlayer(unit) && !unit->ToPlayer()->isDead())
1295 {
1296 me->SetInCombatWith(unit->ToPlayer());
1297 unit->ToPlayer()->SetInCombatWith(me);
1298 me->AddThreat(unit->ToPlayer(), 0.0f);
1299 }
1300 }
1301 else
1302 {
1303 for (WorldObject* target : targets)
1304 {
1305 if (IsCreature(target))
1306 {
1307 target->ToCreature()->SetInCombatWithZone();
1308 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature {}, target: {}",
1309 me->GetGUID().ToString(), target->GetGUID().ToString());
1310 }
1311 }
1312 }
1313
1314 break;
1315 }
1317 {
1318 for (WorldObject* target : targets)
1319 {
1320 if (IsCreature(target))
1321 {
1322 target->ToCreature()->CallForHelp(float(e.action.callHelp.range));
1324 {
1326 sCreatureTextMgr->SendChatPacket(target, builder, CHAT_MSG_MONSTER_EMOTE);
1327 }
1328 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature {}, target: {}",
1329 me->GetGUID().ToString(), target->GetGUID().ToString());
1330 }
1331 }
1332 break;
1333 }
1335 {
1336 if (me)
1337 {
1339 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature {}, State: {}",
1341 }
1342 break;
1343 }
1345 {
1346 for (WorldObject* target : targets)
1347 {
1349 {
1351 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_FORCE_DESPAWN has removeObjectFromWorld set. delay and forceRespawnTimer ignored.");
1352
1353 if (Creature* creature = target->ToCreature())
1354 creature->AddObjectToRemoveList();
1355 else if (GameObject* go = target->ToGameObject())
1357 }
1358 else
1359 {
1360 Milliseconds despawnDelay(e.action.forceDespawn.delay);
1361
1362 // Wait at least one world update tick before despawn, so it doesn't break linked actions.
1363 if (despawnDelay <= 0ms)
1364 despawnDelay = 1ms;
1365
1366 Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
1367 if (Creature* creature = target->ToCreature())
1368 creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1369 else if (GameObject* go = target->ToGameObject())
1370 go->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1371 }
1372 }
1373
1374 break;
1375 }
1377 {
1378 for (WorldObject* target : targets)
1379 {
1380 if (IsUnit(target))
1381 target->ToUnit()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1382 else if (IsGameObject(target))
1383 target->ToGameObject()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1384 }
1385 break;
1386 }
1388 {
1389 for (WorldObject* target : targets)
1390 {
1391 if (!IsUnit(target))
1392 continue;
1393
1395 {
1396 if (e.action.morphOrMount.creature > 0)
1397 {
1398 if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
1399 target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo)->CreatureDisplayID);
1400 }
1401 else
1402 target->ToUnit()->Mount(e.action.morphOrMount.model);
1403 }
1404 else
1405 target->ToUnit()->Dismount();
1406 }
1407 break;
1408 }
1410 {
1411 for (WorldObject* target : targets)
1412 {
1413 if (IsCreature(target))
1414 {
1415 SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI());
1416 if (!ai)
1417 continue;
1418
1419 if (e.action.invincHP.percent)
1420 ai->SetInvincibilityHpLevel(target->ToCreature()->CountPctFromMaxHealth(e.action.invincHP.percent));
1421 else
1423 }
1424 }
1425 break;
1426 }
1428 {
1429 for (WorldObject* target : targets)
1430 {
1431 if (Creature* cTarget = target->ToCreature())
1432 {
1433 CreatureAI* ai = cTarget->AI();
1434 // Make sure we check that the sender is either a creature or gameobject
1435 if (IsSmart(cTarget, true) && (me || go))
1436 {
1437 if (me)
1439 else
1440 ENSURE_AI(SmartAI, ai)->SetData(e.action.setData.field, e.action.setData.data, go);
1441 }
1442 else
1444 }
1445 else if (GameObject* oTarget = target->ToGameObject())
1446 {
1447 GameObjectAI* ai = oTarget->AI();
1448 // Make sure we check that the sender is either a creature or gameobject
1449 if (IsSmart(oTarget, true) && (me || go))
1450 {
1451 if (me)
1453 else
1455 }
1456 else
1458 }
1459 }
1460 break;
1461 }
1463 {
1464 if (!me)
1465 break;
1466
1467 float x, y, z;
1468 me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance);
1470 break;
1471 }
1473 {
1474 if (!me)
1475 break;
1476
1478 break;
1479 }
1481 {
1482 for (WorldObject* target : targets)
1483 if (IsUnit(target))
1484 target->ToUnit()->SetVisible(e.action.visibility.state);
1485
1486 break;
1487 }
1489 {
1490 for (WorldObject* target : targets)
1491 target->setActive(e.action.setActive.state);
1492 break;
1493 }
1495 {
1496 if (!me)
1497 break;
1498
1499 if (targets.empty())
1500 break;
1501
1502 // attack random target
1503 if (Unit* target = Acore::Containers::SelectRandomContainerElement(targets)->ToUnit())
1504 me->AI()->AttackStart(target);
1505 break;
1506 }
1508 {
1509 for (WorldObject* target : targets)
1510 if (Unit* unitTarget = target->ToUnit())
1511 unitTarget->AttackStop();
1512 break;
1513 }
1515 {
1517 bool preferUnit = flags.HasFlag(SmartActionSummonCreatureFlags::PreferUnit);
1518 WorldObject* summoner = preferUnit ? unit : Coalesce<WorldObject>(GetBaseObject(), unit);
1519 if (!summoner)
1520 break;
1521
1522 bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
1523
1525 {
1526 float range = (float)e.target.randomPoint.range;
1527 Position randomPoint;
1528 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1529 for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
1530 {
1531 if (e.target.randomPoint.self > 0)
1532 randomPoint = me->GetRandomPoint(me->GetPosition(), range);
1533 else
1534 randomPoint = me->GetRandomPoint(srcPos, range);
1535 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, 0, nullptr, personalSpawn))
1536 {
1537 if (unit && e.action.summonCreature.attackInvoker)
1538 summon->AI()->AttackStart(unit);
1540 summon->AI()->AttackStart(me);
1541 }
1542 }
1543 break;
1544 }
1545
1546 float x, y, z, o;
1547 for (WorldObject* target : targets)
1548 {
1549 target->GetPosition(x, y, z, o);
1550 x += e.target.x;
1551 y += e.target.y;
1552 z += e.target.z;
1553 o += e.target.o;
1554 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, nullptr, personalSpawn))
1555 {
1556 if (e.action.summonCreature.attackInvoker == 2) // pussywizard: proper attackInvoker implementation
1557 summon->AI()->AttackStart(unit);
1559 summon->AI()->AttackStart(target->ToUnit());
1561 summon->AI()->AttackStart(me);
1562 }
1563 }
1564
1566 break;
1567
1569 {
1570 if (unit && e.action.summonCreature.attackInvoker)
1571 summon->AI()->AttackStart(unit);
1573 summon->AI()->AttackStart(me);
1574 }
1575 break;
1576 }
1578 {
1579 if (!GetBaseObject())
1580 break;
1581
1582 if (!targets.empty())
1583 {
1584 float x, y, z, o;
1585 for (WorldObject* target : targets)
1586 {
1587 // xinef: allow gameobjects to summon gameobjects!
1588 //if (!IsUnit((*itr)))
1589 // continue;
1590
1591 target->GetPosition(x, y, z, o);
1592 x += e.target.x;
1593 y += e.target.y;
1594 z += e.target.z;
1595 o += e.target.o;
1598 else
1599 target->SummonGameObject(e.action.summonGO.entry, GetBaseObject()->GetPositionX(), GetBaseObject()->GetPositionY(), GetBaseObject()->GetPositionZ(), GetBaseObject()->GetOrientation(), 0, 0, 0, 0, e.action.summonGO.despawnTime);
1600 }
1601 }
1602
1604 break;
1605
1607 break;
1608 }
1610 {
1611 for (WorldObject* target : targets)
1612 {
1613 if (!IsUnit(target))
1614 continue;
1615
1616 Unit::Kill(target->ToUnit(), target->ToUnit());
1617 }
1618
1619 break;
1620 }
1622 {
1623 InstallTemplate(e);
1624 break;
1625 }
1627 {
1628 for (WorldObject* target : targets)
1629 {
1630 if (!IsPlayer(target))
1631 continue;
1632
1633 target->ToPlayer()->AddItem(e.action.item.entry, e.action.item.count);
1634 }
1635 break;
1636 }
1638 {
1639 for (WorldObject* target : targets)
1640 {
1641 if (!IsPlayer(target))
1642 continue;
1643
1644 target->ToPlayer()->DestroyItemCount(e.action.item.entry, e.action.item.count, true);
1645 }
1646 break;
1647 }
1649 {
1651 break;
1652 }
1654 {
1655 for (WorldObject* target : targets)
1656 {
1657 if (IsPlayer(target))
1658 target->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
1659 else if (IsCreature(target))
1660 target->ToCreature()->NearTeleportTo(e.target.x, e.target.y, e.target.z, e.target.o);
1661 }
1662 break;
1663 }
1665 {
1666 if (!IsSmart())
1667 break;
1668
1669 CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly);
1670 // Xinef: Set speed if any
1671 if (e.action.setFly.speed)
1672 me->SetSpeed(MOVE_RUN, float(e.action.setFly.speed / 100.0f), true);
1673
1674 // Xinef: this wil be executed only if state is different
1676 break;
1677 }
1679 {
1680 for (WorldObject* target : targets)
1681 {
1682 if (IsCreature(target))
1683 {
1684 target->ToCreature()->SetWalk(e.action.setRun.run ? false : true);
1685 }
1686 }
1687
1688 break;
1689 }
1691 {
1692 if (!IsSmart())
1693 break;
1694
1695 CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim);
1696 break;
1697 }
1699 {
1700 if (!targets.empty())
1701 {
1702 for (WorldObject* target : targets)
1703 {
1704 if (IsCreature(target))
1705 {
1706 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
1708 else
1709 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
1710 }
1711 else if (IsGameObject(target))
1712 {
1713 if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, target->ToGameObject()->AI()))
1715 else
1716 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
1717 }
1718 }
1719 }
1720 else
1722 break;
1723 }
1725 {
1726 if (!IsSmart())
1727 break;
1728
1729 ForcedMovement forcedMovement = static_cast<ForcedMovement>(e.action.wpStart.forcedMovement);
1730 uint32 entry = e.action.wpStart.pathID;
1731 bool repeat = e.action.wpStart.repeat != 0;
1732
1733 for (WorldObject* target : targets)
1734 {
1735 if (IsPlayer(target))
1736 {
1738 break;
1739 }
1740 }
1741
1743 CAST_AI(SmartAI, me->AI())->StartPath(forcedMovement, entry, repeat, unit);
1744
1745 uint32 quest = e.action.wpStart.quest;
1746 uint32 DespawnTime = e.action.wpStart.despawnTime;
1747 CAST_AI(SmartAI, me->AI())->mEscortQuestID = quest;
1748 CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
1749 break;
1750 }
1752 {
1753 if (!IsSmart())
1754 break;
1755
1756 uint32 delay = e.action.wpPause.delay;
1757 CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_ESCORT_REACHED ? false : true);
1758 break;
1759 }
1761 {
1762 if (!IsSmart())
1763 break;
1764
1765 uint32 DespawnTime = e.action.wpStop.despawnTime;
1766 uint32 quest = e.action.wpStop.quest;
1767 bool fail = e.action.wpStop.fail;
1768 CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
1769 break;
1770 }
1772 {
1773 if (!IsSmart())
1774 break;
1775
1776 CAST_AI(SmartAI, me->AI())->SetWPPauseTimer(0);
1777 break;
1778 }
1780 {
1781 if (!me)
1782 break;
1783
1784 if (e.action.orientation.random > 0)
1785 {
1786 float randomOri = frand(0.0f, 2 * M_PI);
1787 me->SetFacingTo(randomOri);
1789 me->SetOrientation(randomOri);
1790 break;
1791 }
1792
1794 {
1795 float turnOri = me->GetOrientation() + (static_cast<float>(e.action.orientation.turnAngle) * M_PI / 180.0f);
1796 me->SetFacingTo(turnOri);
1798 me->SetOrientation(turnOri);
1799 break;
1800 }
1801
1803 {
1807 }
1808 else if (e.GetTargetType() == SMART_TARGET_POSITION)
1809 {
1810 me->SetFacingTo(e.target.o);
1813 }
1814 else if (!targets.empty())
1815 {
1816 me->SetFacingToObject(*targets.begin());
1818 me->SetInFront(*targets.begin());
1819 }
1820
1821 break;
1822 }
1824 {
1825 for (WorldObject* target : targets)
1826 {
1827 if (!IsPlayer(target))
1828 continue;
1829
1830 target->ToPlayer()->SendMovieStart(e.action.movie.entry);
1831 }
1832 break;
1833 }
1835 {
1836 if (!IsSmart())
1837 break;
1838
1839 WorldObject* target = nullptr;
1840
1842
1843 switch (e.GetTargetType())
1844 {
1846 {
1847 G3D::Vector3 dest(e.target.x, e.target.y, e.target.z);
1849 if (TransportBase* trans = me->GetDirectTransport())
1850 trans->CalculatePassengerPosition(dest.x, dest.y, dest.z);
1851
1853 0.f, e.target.o, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1854
1855 break;
1856 }
1858 {
1859 if (me)
1860 {
1861 float range = (float)e.target.randomPoint.range;
1862 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1863 Position randomPoint = me->GetRandomPoint(srcPos, range);
1866 randomPoint.m_positionX,
1867 randomPoint.m_positionY,
1868 randomPoint.m_positionZ,
1870 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE
1871 );
1872
1873 }
1874
1875 break;
1876 }
1877 // Can use target floats as offset
1878 default:
1879 {
1880 // we want to move to random element
1881 if (targets.empty())
1882 return;
1883 else
1885
1886 float x, y, z;
1887 target->GetPosition(x, y, z);
1888
1890 target->GetNearPoint(me, x, y, z, target->GetCombatReach() + e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1891 else if (e.action.moveToPos.ContactDistance)
1892 target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1893
1895 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1896
1897 break;
1898 }
1899 }
1900
1901 break;
1902 }
1904 {
1905 for (WorldObject* target : targets)
1906 {
1907 if (IsCreature(target))
1908 {
1910
1911 Creature* ctarget = target->ToCreature();
1913 0.f, 0.f, true, isForced, 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 (!creature->HasUnitState(UNIT_STATE_NO_COMBAT_MOVEMENT))
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 PathSource pathSource = static_cast<PathSource>(e.action.startClosestWaypoint.pathSource);
2510
2511 if (pathSource != PathSource::WAYPOINT_MGR && pathSource != PathSource::SMART_WAYPOINT_MGR)
2512 {
2513 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_START_CLOSEST_WAYPOINT: Invalid PathSource {} for entryOrGuid {} source_type {} event_id {} link {}",
2514 static_cast<uint32>(pathSource), e.entryOrGuid, e.source_type, e.event_id, e.link);
2515 break;
2516 }
2517
2518 float distanceToClosest = std::numeric_limits<float>::max();
2519 uint32 closestWpId = 0;
2520
2521 for (WorldObject* target : targets)
2522 {
2523 if (Creature* creature = target->ToCreature())
2524 {
2525 if (IsSmart(creature))
2526 {
2527 for (uint32 pathId = e.action.startClosestWaypoint.pathId1; pathId <= e.action.startClosestWaypoint.pathId2; ++pathId)
2528 {
2529 WaypointPath const* path = nullptr;
2530
2531 switch (pathSource)
2532 {
2534 path = sSmartWaypointMgr->GetPath(pathId);
2535 break;
2537 path = sWaypointMgr->GetPath(pathId);
2538 break;
2539 }
2540
2541 if (!path || path->empty())
2542 continue;
2543
2544 auto itrWp = path->find(1);
2545 if (itrWp != path->end())
2546 {
2547 WaypointData const& wpData = itrWp->second;
2548 float distToThisPath = creature->GetExactDistSq(wpData.x, wpData.y, wpData.z);
2549
2550 if (distToThisPath < distanceToClosest)
2551 {
2552 distanceToClosest = distToThisPath;
2553 closestWpId = pathId;
2554 }
2555 }
2556 }
2557
2558 if (closestWpId)
2559 {
2560 bool repeat = e.action.startClosestWaypoint.repeat;
2562
2563 CAST_AI(SmartAI, creature->AI())->StartPath(forcedMovement, closestWpId, repeat, nullptr, pathSource);
2564 }
2565 }
2566 }
2567 }
2568 break;
2569 }
2571 {
2572 for (WorldObject* target : targets)
2573 if (IsUnit(target))
2574 target->ToUnit()->ExitVehicle();
2575
2576 break;
2577 }
2579 {
2580 for (WorldObject* target : targets)
2581 if (IsUnit(target))
2582 {
2584 target->ToUnit()->SendMovementFlagUpdate();
2585 }
2586
2587 break;
2588 }
2590 {
2591 for (WorldObject* target : targets)
2592 if (IsCreature(target))
2593 target->ToCreature()->m_CombatDistance = e.action.combatDistance.dist;
2594
2595 break;
2596 }
2598 {
2599 for (WorldObject* const target : targets)
2600 if (IsCreature(target))
2601 target->ToCreature()->m_SightDistance = e.action.sightDistance.dist;
2602 break;
2603 }
2604 case SMART_ACTION_FLEE:
2605 {
2606 for (WorldObject* const target : targets)
2607 if (IsCreature(target))
2608 target->ToCreature()->GetMotionMaster()->MoveFleeing(me, e.action.flee.withEmote);
2609 break;
2610 }
2612 {
2613 for (WorldObject* const target : targets)
2614 if (IsUnit(target))
2615 me->AddThreat(target->ToUnit(), float(e.action.threatPCT.threatINC) - float(e.action.threatPCT.threatDEC));
2616 break;
2617 }
2619 {
2620 for (WorldObject* const target : targets)
2621 if (IsCreature(target))
2622 target->ToCreature()->LoadEquipment(e.action.loadEquipment.id, e.action.loadEquipment.force != 0);
2623 break;
2624 }
2626 {
2629 break;
2630 }
2632 {
2633 for (WorldObject* const target : targets)
2634 if (IsUnit(target))
2635 target->ToUnit()->Dismount();
2636 break;
2637 }
2639 {
2640 for (WorldObject* target : targets)
2641 if (IsUnit(target))
2642 target->ToUnit()->SetHover(e.action.setHover.state);
2643 break;
2644 }
2646 {
2647 for (WorldObject* target : targets)
2648 if (IsUnit(target))
2649 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, true);
2650
2651 break;
2652 }
2654 {
2655 for (WorldObject* target : targets)
2656 if (IsUnit(target))
2657 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, false);
2658 break;
2659 }
2660 case SMART_ACTION_FALL:
2661 {
2662 for (WorldObject* target : targets)
2663 if (IsUnit(target))
2664 target->ToUnit()->GetMotionMaster()->MoveFall();
2665
2666 break;
2667 }
2669 {
2671 break;
2672 }
2674 {
2675 for (WorldObject* const target : targets)
2676 if (IsUnit(target))
2677 target->ToUnit()->RemoveAllGameObjects();
2678 break;
2679 }
2681 {
2682 for (WorldObject* const target : targets)
2683 {
2684 if (IsUnit(target))
2685 {
2687 target->ToUnit()->StopMoving();
2689 target->ToUnit()->GetMotionMaster()->MovementExpired();
2690 }
2691 }
2692 break;
2693 }
2695 {
2696 for (WorldObject* target : targets)
2697 if (IsUnit(target))
2698 target->ToUnit()->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
2699
2700 break;
2701 }
2703 {
2704 for (WorldObject* target : targets)
2705 if (IsUnit(target))
2706 if (Player* player = target->ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself())
2707 {
2709 break;
2710 }
2711
2712 break;
2713 }
2715 {
2716 if (me && me->FindMap())
2717 me->FindMap()->LoadGrid(e.target.x, e.target.y);
2718 else if (go && go->FindMap())
2719 go->FindMap()->LoadGrid(e.target.x, e.target.y);
2720 break;
2721 }
2723 {
2724 std::string text = sObjectMgr->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE);
2725
2726 if (!targets.empty())
2727 for (WorldObject* target : targets)
2728 if (IsPlayer(target))
2729 !e.action.playerTalk.flag ? target->ToPlayer()->Say(text, LANG_UNIVERSAL) : target->ToPlayer()->Yell(text, LANG_UNIVERSAL);
2730
2731 break;
2732 }
2734 {
2735 if (!me)
2736 break;
2737
2738 for (WorldObject* target : targets)
2739 {
2740 if (IsUnit(target))
2741 {
2743 {
2745 }
2746
2748 {
2749 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.castCustom.spell);
2750 CustomSpellValues values;
2751 if (e.action.castCustom.bp1)
2753 if (e.action.castCustom.bp2)
2755 if (e.action.castCustom.bp3)
2758
2759 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
2761 {
2762 // 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.
2763 if (result == SPELL_FAILED_OUT_OF_RANGE || result == SPELL_CAST_OK)
2764 // if we are just out of range, we only chase until we are back in spell range.
2765 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
2766 else // move into melee on any other fail
2767 // if spell fail for any other reason, we chase to melee range, or stay where we are if spellcast was successful.
2768 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(false, 0.f);
2769 }
2770 }
2771 }
2772 }
2773 break;
2774 }
2776 {
2777 if (!me)
2778 break;
2779
2780 if (targets.empty())
2781 break;
2782
2784
2785 float a = static_cast<float>(e.action.summonVortex.a);
2786 float k = static_cast<float>(e.action.summonVortex.k) / 1000.0f;
2787 float r_max = static_cast<float>(e.action.summonVortex.r_max);
2788 float delta_phi = M_PI * static_cast<float>(e.action.summonVortex.phi_delta) / 180.0f;
2789
2790 // r(phi) = a * e ^ (k * phi)
2791 // r(phi + delta_phi) = a * e ^ (k * (phi + delta_phi))
2792 // r(phi + delta_phi) = a * e ^ (k * phi) * e ^ (k * delta_phi)
2793 // r(phi + delta_phi) = r(phi) * e ^ (k * delta_phi)
2794 float factor = std::exp(k * delta_phi);
2795
2796 // r(0) = a * e ^ (k * 0) = a * e ^ 0 = a * 1 = a
2797 float summonRadius = a;
2798
2799 for (WorldObject* target : targets)
2800 {
2801 // Offset by orientation, should not count into radius calculation,
2802 // but is needed for vortex direction (polar coordinates)
2803 float phi = target->GetOrientation();
2804
2805 do
2806 {
2807 Position summonPosition(*target);
2808 summonPosition.RelocatePolarOffset(phi, summonRadius);
2809
2811
2812 phi += delta_phi;
2813 summonRadius *= factor;
2814 } while (summonRadius <= r_max);
2815 }
2816
2817 break;
2818 }
2820 {
2821 if (!me)
2822 break;
2823
2825
2826 float distInARow = static_cast<float>(e.action.coneSummon.distanceBetweenSummons);
2827 float coneAngle = static_cast<float>(e.action.coneSummon.coneAngle) * M_PI / 180.0f;
2828
2829 for (uint32 radius = 0; radius <= e.action.coneSummon.coneLength; radius += e.action.coneSummon.distanceBetweenRings)
2830 {
2831 float deltaAngle = 0.0f;
2832 if (radius > 0)
2833 deltaAngle = distInARow / radius;
2834
2835 uint32 count = 1;
2836 if (deltaAngle > 0)
2837 count += coneAngle / deltaAngle;
2838
2839 float currentAngle = -static_cast<float>(count) * deltaAngle / 2.0f;
2840
2842 currentAngle += G3D::fuzzyGt(e.target.o, 0.0f) ? (e.target.o - me->GetOrientation()) : 0.0f;
2843 else if (!targets.empty())
2844 {
2845 currentAngle += (me->GetAngle(targets.front()) - me->GetOrientation());
2846 }
2847
2848 for (uint32 index = 0; index < count; ++index)
2849 {
2850 Position spawnPosition(*me);
2851 spawnPosition.RelocatePolarOffset(currentAngle, radius);
2852 currentAngle += deltaAngle;
2853
2855 }
2856 }
2857
2858 break;
2859 }
2861 {
2862 for (WorldObject* target : targets)
2863 {
2864 if (Player* playerTarget = target->ToPlayer())
2865 {
2866 playerTarget->RemoveArenaSpellCooldowns();
2867 playerTarget->RemoveAurasDueToSpell(57724); // Spell Shaman Debuff - Sated (Heroism)
2868 playerTarget->RemoveAurasDueToSpell(57723); // Spell Shaman Debuff - Exhaustion (Bloodlust)
2869 playerTarget->RemoveAurasDueToSpell(2825); // Bloodlust
2870 playerTarget->RemoveAurasDueToSpell(32182); // Heroism
2871 }
2872 }
2873
2874 break;
2875 }
2877 {
2880 {
2881 if (targets.empty())
2882 break;
2883
2884 for (WorldObject* objTarget : targets)
2885 {
2886 if (Creature const* unitTarget = objTarget->ToCreature())
2887 {
2888 if (unitTarget->IsAIEnabled)
2889 {
2890 unitTarget->AI()->DoAction(actionId);
2891 }
2892 }
2893 else if (GameObject const* gobjTarget = objTarget->ToGameObject())
2894 {
2895 gobjTarget->AI()->DoAction(actionId);
2896 }
2897 }
2898
2899 }
2900 else
2901 {
2902 InstanceScript* instanceScript = nullptr;
2903 if (WorldObject* baseObj = GetBaseObject())
2904 {
2905 instanceScript = baseObj->GetInstanceScript();
2906 }
2907 // Action is triggered by AreaTrigger
2908 else if (trigger && IsPlayer(unit))
2909 {
2910 instanceScript = unit->GetInstanceScript();
2911 }
2912
2913 if (instanceScript)
2914 {
2915 instanceScript->DoAction(actionId);
2916 }
2917 }
2918 break;
2919 }
2921 {
2922 if (!IsSmart())
2923 break;
2924
2925 CAST_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0);
2926 break;
2927 }
2929 {
2930 for (WorldObject* const target : targets)
2931 {
2932 if (IsCreature(target))
2934 }
2935 break;
2936 }
2938 {
2939 for (WorldObject* target : targets)
2940 if (Unit* targetUnit = target->ToUnit())
2941 targetUnit->SetHealth(targetUnit->CountPctFromMaxHealth(e.action.setHealthPct.percent));
2942 break;
2943 }
2945 {
2946 uint32 speedInteger = e.action.movementSpeed.speedInteger;
2947 uint32 speedFraction = e.action.movementSpeed.speedFraction;
2948 float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(float(speedFraction ? speedFraction : 1)) + 1));
2949
2950 for (WorldObject* target : targets)
2951 if (IsCreature(target))
2952 target->ToCreature()->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
2953
2954 break;
2955 }
2957 {
2958 for (WorldObject* target : targets)
2959 {
2960 if (!IsPlayer(target))
2961 continue;
2962
2964 }
2965 break;
2966 }
2968 {
2969 for (WorldObject* target : targets)
2970 {
2971 ObjectGuid guidToSend = me ? me->GetGUID() : go->GetGUID();
2972
2974 {
2975 if (WorldObject* invoker = GetLastInvoker())
2976 {
2977 guidToSend = invoker->GetGUID();
2978 }
2979 }
2980
2981 if (Creature* creature = target->ToCreature())
2982 {
2983 creature->AI()->SetGUID(guidToSend, e.action.setGuid.index);
2984 }
2985 else if (GameObject* object = target->ToGameObject())
2986 {
2987 object->AI()->SetGUID(guidToSend, e.action.setGuid.index);
2988 }
2989 }
2990 break;
2991 }
2993 {
2994 // Enable Scripted Spawns
2995 switch (e.action.scriptSpawn.state)
2996 {
2997 case 0: // Disable Respawn
2998 {
2999 for (WorldObject* target : targets)
3000 {
3001 if (Creature* c = target->ToCreature())
3002 {
3003 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3005 c->DespawnOrUnsummon();
3006 }
3007 }
3008 break;
3009 }
3010 case 1: // Respawn Once
3011 {
3012 for (WorldObject* target : targets)
3013 {
3014 if (Creature* c = target->ToCreature())
3015 {
3016 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3017 c->Respawn(true);
3018 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3019 }
3020 }
3021 break;
3022 }
3023 case 2: // Enable Respawning
3024 {
3025 for (WorldObject* target : targets)
3026 {
3027 if (Creature* c = target->ToCreature())
3028 {
3029 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3030
3031 // If 0, respawn immediately
3034 else
3035 c->Respawn(true);
3036
3037 // If 0, use DB values
3039 c->SetRespawnDelay(e.action.scriptSpawn.respawnDelay);
3040
3041 // If 0, use default
3043 c->SetCorpseDelay(e.action.scriptSpawn.corpseDelay);
3044 }
3045 }
3046 break;
3047 }
3048 default:
3049 break;
3050 }
3051 break;
3052 }
3054 {
3055 float scale = static_cast<float>(e.action.setScale.scale) / 100.0f;
3056
3057 for (WorldObject* target : targets)
3058 {
3059 if (IsUnit(target))
3060 {
3061 target->ToUnit()->SetObjectScale(scale);
3062 }
3063 }
3064 break;
3065 }
3067 {
3068 if (!me)
3069 break;
3070
3072
3073 float startAngle = me->GetOrientation() + (static_cast<float>(e.action.radialSummon.startAngle) * M_PI / 180.0f);
3074 float stepAngle = static_cast<float>(e.action.radialSummon.stepAngle) * M_PI / 180.0f;
3075
3076 if (e.action.radialSummon.dist)
3077 {
3078 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3079 {
3080 Position summonPos = me->GetPosition();
3081 summonPos.RelocatePolarOffset(itr * stepAngle, static_cast<float>(e.action.radialSummon.dist));
3083 }
3084 break;
3085 }
3086
3087 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3088 {
3089 float currentAngle = startAngle + (itr * stepAngle);
3091 }
3092
3093 break;
3094 }
3096 {
3097 for (WorldObject* target : targets)
3098 {
3099 if (IsUnit(target))
3100 {
3103 }
3104 }
3105 break;
3106 }
3108 {
3110 {
3111 for (WorldObject* target : targets)
3112 if (IsUnit(target))
3113 target->ToCreature()->GetMotionMaster()->MoveIdle();
3114
3115 break;
3116 }
3117
3118 uint8 membCount = targets.size();
3119 uint8 itr = 1;
3120 float dist = float(e.action.followGroup.dist / 100);
3121 switch (e.action.followGroup.followType)
3122 {
3123 case FOLLOW_TYPE_CIRCLE:
3124 {
3125 float angle = (membCount > 4 ? (M_PI * 2)/membCount : (M_PI / 2)); // 90 degrees is the maximum angle
3126 for (WorldObject* target : targets)
3127 {
3128 if (IsCreature(target))
3129 {
3130 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, angle * itr);
3131 itr++;
3132 }
3133 }
3134 break;
3135 }
3137 {
3138 for (WorldObject* target : targets)
3139 {
3140 if (IsCreature(target))
3141 {
3142 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1));
3143 itr++;
3144 }
3145 }
3146 break;
3147 }
3149 {
3150 for (WorldObject* target : targets)
3151 {
3152 if (IsCreature(target))
3153 {
3154 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI + (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1)));
3155 itr++;
3156 }
3157 }
3158 break;
3159 }
3160 case FOLLOW_TYPE_LINE:
3161 {
3162 for (WorldObject* target : targets)
3163 {
3164 if (IsCreature(target))
3165 {
3166 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? 0.f : M_PI);
3167 itr++;
3168 }
3169 }
3170 break;
3171 }
3172 case FOLLOW_TYPE_COLUMN:
3173 {
3174 for (WorldObject* target : targets)
3175 {
3176 if (IsCreature(target))
3177 {
3178 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? (M_PI / 2) : (M_PI * 1.5f));
3179 itr++;
3180 }
3181 }
3182 break;
3183 }
3185 {
3186 for (WorldObject* target : targets)
3187 {
3188 if (IsCreature(target))
3189 {
3190 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? M_PI - (M_PI / 4) : M_PI + (M_PI / 4));
3191 itr++;
3192 }
3193 }
3194 break;
3195 }
3196 default:
3197 break;
3198 }
3199
3200 break;
3201 }
3203 {
3204 switch (e.action.orientationTarget.type)
3205 {
3206 case 0: // Reset
3207 {
3208 for (WorldObject* target : targets)
3209 target->ToCreature()->SetFacingTo((target->ToCreature()->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->ToCreature()->GetTransGUID() ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition()).GetOrientation());
3210
3211 break;
3212 }
3213 case 1: // Target target.o
3214 {
3215 for (WorldObject* target : targets)
3216 target->ToCreature()->SetFacingTo(e.target.o);
3217
3218 break;
3219 }
3220 case 2: // Target source
3221 {
3222 for (WorldObject* target : targets)
3223 target->ToCreature()->SetFacingToObject(me);
3224
3225 break;
3226 }
3227 case 3: // Target parameters
3228 {
3229 ObjectVector facingTargets;
3231
3232 for (WorldObject* facingTarget : facingTargets)
3233 for (WorldObject* target : targets)
3234 target->ToCreature()->SetFacingToObject(facingTarget);
3235
3236 break;
3237 }
3238 default:
3239 break;
3240 }
3241 break;
3242 }
3244 {
3245 if (e.action.wpData.pathId)
3246 {
3247 for (WorldObject* target : targets)
3248 {
3249 if (IsCreature(target))
3250 {
3251 target->ToCreature()->LoadPath(e.action.wpData.pathId);
3253 }
3254 }
3255 }
3256
3257 break;
3258 }
3260 {
3262 {
3263 for (WorldObject* target : targets)
3264 {
3265 if (IsCreature(target))
3266 {
3268 target->ToCreature()->LoadPath(path);
3270 }
3271 }
3272 }
3273
3274 break;
3275 }
3277 {
3278 for (WorldObject* target : targets)
3279 if (IsUnit(target))
3280 target->ToUnit()->StopMoving();
3281
3282 break;
3283 }
3285 {
3286 for (WorldObject* target : targets)
3287 if (IsUnit(target))
3288 target->ToUnit()->PauseMovement(e.action.move.timer);
3289
3290 break;
3291 }
3293 {
3294 for (WorldObject* target : targets)
3295 if (IsUnit(target))
3296 target->ToUnit()->ResumeMovement(e.action.move.timer);
3297
3298 break;
3299 }
3301 {
3302 sWorldState->HandleExternalEvent(static_cast<WorldStateEvent>(e.action.worldStateScript.eventId), e.action.worldStateScript.param);
3303 break;
3304 }
3306 {
3307 for (WorldObject* target : targets)
3308 if (IsCreature(target))
3309 {
3310 target->ToCreature()->SetReputationRewardDisabled(static_cast<bool>(e.action.reward.reputation));
3311 target->ToCreature()->SetLootRewardDisabled(static_cast<bool>(e.action.reward.loot));
3312 }
3313 break;
3314 }
3316 {
3317 for (WorldObject* target : targets)
3318 if (IsUnit(target))
3319 target->ToUnit()->SetAnimTier(AnimTier(e.action.animTier.animTier));
3320 break;
3321 }
3323 {
3324 for (WorldObject* target : targets)
3325 {
3326 if (Creature* creature = target->ToCreature())
3327 {
3328 creature->SetGossipMenuId(e.action.setGossipMenu.gossipMenuId);
3329 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_GOSSIP_MENU: Creature {} set gossip menu to {}",
3330 creature->GetGUID().ToString(), e.action.setGossipMenu.gossipMenuId);
3331 }
3332 }
3333 break;
3334 }
3335 default:
3336 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
3337 break;
3338 }
3339
3340 if (e.link && e.link != e.event_id)
3341 {
3342 auto linked = FindLinkedEvent(e.link);
3343 if (linked.has_value())
3344 {
3345 auto& linkedEvent = linked.value().get();
3346 if (linkedEvent.GetEventType() == SMART_EVENT_LINK)
3347 executionStack.emplace_back(SmartScriptFrame{ linkedEvent, unit, var0, var1, bvar, spell, gob });
3348 else
3349 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());
3350 }
3351 else
3352 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Link Event {} not found, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
3353 }
3354}
npc
Definition BattlegroundSA.h:47
#define DEFAULT_LOCALE
Definition Common.h:131
#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:704
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
PathSource
Definition MotionMaster.h:93
@ SMART_WAYPOINT_MGR
ForcedMovement
Definition MotionMaster.h:84
@ FORCED_MOVEMENT_NONE
Definition MotionMaster.h:85
AnimTier
Definition MotionMaster.h:99
#define NOMINAL_MELEE_RANGE
Definition ObjectDefines.h:47
#define sObjectMgr
Definition ObjectMgr.h:1686
TempSummonType
Definition Object.h:47
@ TEMPSUMMON_TIMED_DESPAWN
Definition Object.h:50
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:52
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:1571
@ POWER_MANA
Definition SharedDefines.h:280
@ CHAT_MSG_MONSTER_EMOTE
Definition SharedDefines.h:3408
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3391
@ LANG_UNIVERSAL
Definition SharedDefines.h:746
@ LANG_ADDON
Definition SharedDefines.h:764
@ SPELL_ATTR2_IGNORE_LINE_OF_SIGHT
Definition SharedDefines.h:469
@ TEAM_NEUTRAL
Definition SharedDefines.h:773
SpellCastResult
Definition SharedDefines.h:959
@ SPELL_FAILED_OUT_OF_RANGE
Definition SharedDefines.h:1057
@ SPELL_CAST_OK
Definition SharedDefines.h:1149
@ SPELL_FAILED_SPELL_IN_PROGRESS
Definition SharedDefines.h:1065
@ SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL
Definition SmartScriptMgr.h:1945
SMARTAI_TARGETS
Definition SmartScriptMgr.h:1535
@ SMART_TARGET_RANDOM_POINT
Definition SmartScriptMgr.h:1574
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2248
SMART_ACTION
Definition SmartScriptMgr.h:541
@ SMART_ACTION_REMOVE_TIMED_EVENT
Definition SmartScriptMgr.h:616
@ SMART_ACTION_NONE
Definition SmartScriptMgr.h:542
@ SMART_ACTION_SET_GO_FLAG
Definition SmartScriptMgr.h:646
@ SMART_ACTION_UPDATE_TEMPLATE
Definition SmartScriptMgr.h:578
@ SMART_ACTION_SET_HEALTH_REGEN
Definition SmartScriptMgr.h:644
@ SMART_ACTION_SET_GOSSIP_MENU
Definition SmartScriptMgr.h:727
@ SMART_ACTION_ACTIVATE_GOBJECT
Definition SmartScriptMgr.h:551
@ SMART_ACTION_GAME_EVENT_START
Definition SmartScriptMgr.h:654
@ SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:630
@ SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1
Definition SmartScriptMgr.h:633
@ SMART_ACTION_SET_INST_DATA64
Definition SmartScriptMgr.h:577
@ SMART_ACTION_SET_FACTION
Definition SmartScriptMgr.h:544
@ SMART_ACTION_THREAT_SINGLE_PCT
Definition SmartScriptMgr.h:555
@ SMART_ACTION_OFFER_QUEST
Definition SmartScriptMgr.h:549
@ SMART_ACTION_REMOVE_ALL_GAMEOBJECTS
Definition SmartScriptMgr.h:668
@ SMART_ACTION_RISE_UP
Definition SmartScriptMgr.h:656
@ SMART_ACTION_SET_INGAME_PHASE_MASK
Definition SmartScriptMgr.h:586
@ SMART_ACTION_SET_UNIT_FIELD_BYTES_1
Definition SmartScriptMgr.h:632
@ SMART_ACTION_CLOSE_GOSSIP
Definition SmartScriptMgr.h:614
@ SMART_ACTION_DISABLE_EVADE
Definition SmartScriptMgr.h:659
@ SMART_ACTION_CONE_SUMMON
Definition SmartScriptMgr.h:706
@ SMART_ACTION_ADD_GO_FLAG
Definition SmartScriptMgr.h:647
@ SMART_ACTION_ESCORT_START
Definition SmartScriptMgr.h:595
@ SMART_ACTION_ADD_DYNAMIC_FLAG
Definition SmartScriptMgr.h:637
@ SMART_ACTION_KILL_UNIT
Definition SmartScriptMgr.h:593
@ SMART_ACTION_LOAD_EQUIPMENT
Definition SmartScriptMgr.h:666
@ SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS
Definition SmartScriptMgr.h:557
@ SMART_ACTION_ATTACK_START
Definition SmartScriptMgr.h:591
@ SMART_ACTION_MOVEMENT_RESUME
Definition SmartScriptMgr.h:723
@ SMART_ACTION_SET_UNIT_FLAG
Definition SmartScriptMgr.h:560
@ SMART_ACTION_NO_ENVIRONMENT_UPDATE
Definition SmartScriptMgr.h:699
@ SMART_ACTION_CALL_GROUPEVENTHAPPENS
Definition SmartScriptMgr.h:568
@ SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL
Definition SmartScriptMgr.h:585
@ SMART_ACTION_INVOKER_CAST
Definition SmartScriptMgr.h:676
@ SMART_ACTION_MOVEMENT_STOP
Definition SmartScriptMgr.h:721
@ SMART_ACTION_SET_SCALE
Definition SmartScriptMgr.h:714
@ SMART_ACTION_JUMP_TO_POS
Definition SmartScriptMgr.h:639
@ SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:629
@ SMART_ACTION_SEND_GOSSIP_MENU
Definition SmartScriptMgr.h:640
@ SMART_ACTION_SET_COUNTER
Definition SmartScriptMgr.h:605
@ SMART_ACTION_FLEE_FOR_ASSIST
Definition SmartScriptMgr.h:567
@ SMART_ACTION_EQUIP
Definition SmartScriptMgr.h:613
@ SMART_ACTION_SET_ROOT
Definition SmartScriptMgr.h:645
@ SMART_ACTION_ATTACK_STOP
Definition SmartScriptMgr.h:711
@ SMART_ACTION_SUMMON_GO
Definition SmartScriptMgr.h:592
@ SMART_ACTION_SET_HOVER
Definition SmartScriptMgr.h:693
@ SMART_ACTION_SIMPLE_TALK
Definition SmartScriptMgr.h:626
@ SMART_ACTION_STOP_MOTION
Definition SmartScriptMgr.h:698
@ SMART_ACTION_VORTEX_SUMMON
Definition SmartScriptMgr.h:708
@ SMART_ACTION_WORLD_SCRIPT
Definition SmartScriptMgr.h:724
@ SMART_ACTION_MUSIC
Definition SmartScriptMgr.h:702
@ SMART_ACTION_SET_ORIENTATION_TARGET
Definition SmartScriptMgr.h:718
@ SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS
Definition SmartScriptMgr.h:690
@ SMART_ACTION_ADD_AURA
Definition SmartScriptMgr.h:617
@ SMART_ACTION_THREAT_ALL_PCT
Definition SmartScriptMgr.h:556
@ SMART_ACTION_WAYPOINT_START
Definition SmartScriptMgr.h:719
@ SMART_ACTION_ESCORT_STOP
Definition SmartScriptMgr.h:597
@ SMART_ACTION_RESPAWN_TARGET
Definition SmartScriptMgr.h:612
@ SMART_ACTION_FOLLOW_GROUP
Definition SmartScriptMgr.h:717
@ SMART_ACTION_SOUND
Definition SmartScriptMgr.h:546
@ SMART_ACTION_ESCORT_PAUSE
Definition SmartScriptMgr.h:596
@ SMART_ACTION_MOVE_TO_POS_TARGET
Definition SmartScriptMgr.h:687
@ SMART_ACTION_SET_MOVEMENT_SPEED
Definition SmartScriptMgr.h:678
@ SMART_ACTION_PLAY_CINEMATIC
Definition SmartScriptMgr.h:677
@ SMART_ACTION_ADD_NPC_FLAG
Definition SmartScriptMgr.h:624
@ SMART_ACTION_EVADE
Definition SmartScriptMgr.h:566
@ SMART_ACTION_FAIL_QUEST
Definition SmartScriptMgr.h:548
@ SMART_ACTION_INTERRUPT_SPELL
Definition SmartScriptMgr.h:634
@ SMART_ACTION_ADD_POWER
Definition SmartScriptMgr.h:651
@ SMART_ACTION_SET_ANIM_TIER
Definition SmartScriptMgr.h:726
@ SMART_ACTION_REMOVE_DYNAMIC_FLAG
Definition SmartScriptMgr.h:638
@ SMART_ACTION_RANDOM_SOUND
Definition SmartScriptMgr.h:657
@ SMART_ACTION_RANDOM_MUSIC
Definition SmartScriptMgr.h:703
@ SMART_ACTION_SET_COMBAT_DISTANCE
Definition SmartScriptMgr.h:691
@ SMART_ACTION_SET_POWER
Definition SmartScriptMgr.h:650
@ SMART_ACTION_SEND_TARGET_TO_TARGET
Definition SmartScriptMgr.h:642
@ SMART_ACTION_REMOVE_POWER
Definition SmartScriptMgr.h:652
@ SMART_ACTION_ADD_IMMUNITY
Definition SmartScriptMgr.h:694
@ SMART_ACTION_SET_DYNAMIC_FLAG
Definition SmartScriptMgr.h:636
@ SMART_ACTION_FALL
Definition SmartScriptMgr.h:696
@ SMART_ACTION_GO_SET_GO_STATE
Definition SmartScriptMgr.h:660
@ SMART_ACTION_CUSTOM_CAST
Definition SmartScriptMgr.h:705
@ SMART_ACTION_REMOVE_ITEM
Definition SmartScriptMgr.h:599
@ SMART_ACTION_SEND_GO_CUSTOM_ANIM
Definition SmartScriptMgr.h:635
@ SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL
Definition SmartScriptMgr.h:545
@ SMART_ACTION_REMOVE_UNIT_FLAG
Definition SmartScriptMgr.h:561
@ SMART_ACTION_RANDOM_PHASE
Definition SmartScriptMgr.h:572
@ SMART_ACTION_SET_EMOTE_STATE
Definition SmartScriptMgr.h:559
@ SMART_ACTION_CROSS_CAST
Definition SmartScriptMgr.h:628
@ SMART_ACTION_GAME_EVENT_STOP
Definition SmartScriptMgr.h:653
@ SMART_ACTION_SCRIPTED_SPAWN
Definition SmartScriptMgr.h:713
@ SMART_ACTION_ESCORT_RESUME
Definition SmartScriptMgr.h:607
@ SMART_ACTION_CALL_SCRIPT_RESET
Definition SmartScriptMgr.h:620
@ SMART_ACTION_CU_ENCOUNTER_START
Definition SmartScriptMgr.h:709
@ SMART_ACTION_COMBAT_STOP
Definition SmartScriptMgr.h:569
@ SMART_ACTION_EXIT_VEHICLE
Definition SmartScriptMgr.h:689
@ SMART_ACTION_SET_HEALTH_PCT
Definition SmartScriptMgr.h:680
@ SMART_ACTION_AUTO_ATTACK
Definition SmartScriptMgr.h:562
@ SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL
Definition SmartScriptMgr.h:584
@ SMART_ACTION_SET_VISIBILITY
Definition SmartScriptMgr.h:589
@ SMART_ACTION_RANDOM_PHASE_RANGE
Definition SmartScriptMgr.h:573
@ SMART_ACTION_MOVEMENT_PAUSE
Definition SmartScriptMgr.h:722
@ SMART_ACTION_GO_SET_LOOT_STATE
Definition SmartScriptMgr.h:641
@ SMART_ACTION_PLAYER_TALK
Definition SmartScriptMgr.h:707
@ SMART_ACTION_SELF_CAST
Definition SmartScriptMgr.h:627
@ SMART_ACTION_SET_SWIM
Definition SmartScriptMgr.h:603
@ SMART_ACTION_SET_SIGHT_DIST
Definition SmartScriptMgr.h:663
@ SMART_ACTION_SET_INST_DATA
Definition SmartScriptMgr.h:576
@ SMART_ACTION_REMOVE_GO_FLAG
Definition SmartScriptMgr.h:648
@ SMART_ACTION_LOAD_GRID
Definition SmartScriptMgr.h:701
@ SMART_ACTION_CALL_FOR_HELP
Definition SmartScriptMgr.h:581
@ SMART_ACTION_SUMMON_RADIAL
Definition SmartScriptMgr.h:715
@ SMART_ACTION_ADD_THREAT
Definition SmartScriptMgr.h:665
@ SMART_ACTION_DISMOUNT
Definition SmartScriptMgr.h:692
@ SMART_ACTION_TELEPORT
Definition SmartScriptMgr.h:604
@ SMART_ACTION_PLAYMOVIE
Definition SmartScriptMgr.h:610
@ SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT
Definition SmartScriptMgr.h:667
@ SMART_ACTION_FOLLOW
Definition SmartScriptMgr.h:571
@ SMART_ACTION_PLAY_EMOTE
Definition SmartScriptMgr.h:547
@ SMART_ACTION_SET_CORPSE_DELAY
Definition SmartScriptMgr.h:658
@ SMART_ACTION_WAYPOINT_DATA_RANDOM
Definition SmartScriptMgr.h:720
@ SMART_ACTION_SET_GUID
Definition SmartScriptMgr.h:712
@ SMART_ACTION_SET_SHEATH
Definition SmartScriptMgr.h:582
@ SMART_ACTION_SET_ORIENTATION
Definition SmartScriptMgr.h:608
@ SMART_ACTION_SET_NPC_FLAG
Definition SmartScriptMgr.h:623
@ SMART_ACTION_MOVE_TO_POS
Definition SmartScriptMgr.h:611
@ SMART_ACTION_RANDOM_EMOTE
Definition SmartScriptMgr.h:552
@ SMART_ACTION_INC_EVENT_PHASE
Definition SmartScriptMgr.h:565
@ SMART_ACTION_CREATE_TIMED_EVENT
Definition SmartScriptMgr.h:609
@ SMART_ACTION_SET_EVENT_FLAG_RESET
Definition SmartScriptMgr.h:697
@ SMART_ACTION_DIE
Definition SmartScriptMgr.h:579
@ SMART_ACTION_RESET_SCRIPT_BASE_OBJECT
Definition SmartScriptMgr.h:619
@ SMART_ACTION_REMOVE_NPC_FLAG
Definition SmartScriptMgr.h:625
@ SMART_ACTION_SET_FLY
Definition SmartScriptMgr.h:602
@ SMART_ACTION_INSTALL_AI_TEMPLATE
Definition SmartScriptMgr.h:600
@ SMART_ACTION_SUMMON_CREATURE
Definition SmartScriptMgr.h:554
@ SMART_ACTION_CALL_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:622
@ SMART_ACTION_SET_IN_COMBAT_WITH_ZONE
Definition SmartScriptMgr.h:580
@ SMART_ACTION_DO_ACTION
Definition SmartScriptMgr.h:710
@ SMART_ACTION_SET_HOME_POS
Definition SmartScriptMgr.h:643
@ SMART_ACTION_ADD_ITEM
Definition SmartScriptMgr.h:598
@ SMART_ACTION_SET_ACTIVE
Definition SmartScriptMgr.h:590
@ SMART_ACTION_SET_RANGED_MOVEMENT
Definition SmartScriptMgr.h:621
@ SMART_ACTION_ACTIVATE_TAXI
Definition SmartScriptMgr.h:594
@ SMART_ACTION_START_CLOSEST_WAYPOINT
Definition SmartScriptMgr.h:655
@ SMART_ACTION_SUMMON_CREATURE_GROUP
Definition SmartScriptMgr.h:649
@ SMART_ACTION_REMOVE_IMMUNITY
Definition SmartScriptMgr.h:695
@ SMART_ACTION_PLAY_SPELL_VISUAL
Definition SmartScriptMgr.h:716
@ SMART_ACTION_SET_REACT_STATE
Definition SmartScriptMgr.h:550
@ SMART_ACTION_DISABLE_REWARD
Definition SmartScriptMgr.h:725
@ SMART_ACTION_RANDOM_MOVE
Definition SmartScriptMgr.h:631
@ SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT
Definition SmartScriptMgr.h:618
@ SMART_ACTION_TRIGGER_TIMED_EVENT
Definition SmartScriptMgr.h:615
@ SMART_ACTION_REMOVEAURASFROMSPELL
Definition SmartScriptMgr.h:570
@ SMART_ACTION_FLEE
Definition SmartScriptMgr.h:664
@ SMART_ACTION_ZONE_UNDER_ATTACK
Definition SmartScriptMgr.h:700
@ FOLLOW_TYPE_CIRCLE
Definition SmartScriptMgr.h:1965
@ FOLLOW_TYPE_SEMI_CIRCLE_BEHIND
Definition SmartScriptMgr.h:1966
@ FOLLOW_TYPE_SEMI_CIRCLE_FRONT
Definition SmartScriptMgr.h:1967
@ FOLLOW_TYPE_COLUMN
Definition SmartScriptMgr.h:1969
@ FOLLOW_TYPE_ANGULAR
Definition SmartScriptMgr.h:1970
@ FOLLOW_TYPE_LINE
Definition SmartScriptMgr.h:1968
SMART_EVENT
Definition SmartScriptMgr.h:98
@ SMART_EVENT_TIMED_EVENT_TRIGGERED
Definition SmartScriptMgr.h:158
@ SMART_EVENT_ESCORT_REACHED
Definition SmartScriptMgr.h:139
@ SMART_EVENT_LINK
Definition SmartScriptMgr.h:160
uint32 SAIBool
Definition SmartScriptMgr.h:31
SmartActionSummonCreatureFlags
Definition SmartScriptMgr.h:733
@ SMART_ESCORT_TARGETS
Definition SmartScriptMgr.h:40
@ SMARTCAST_TRIGGERED
Definition SmartScriptMgr.h:1951
@ SMARTCAST_ENABLE_COMBAT_MOVE_ON_LOS
Definition SmartScriptMgr.h:1959
@ SMARTCAST_COMBAT_MOVE
Definition SmartScriptMgr.h:1956
@ SMARTCAST_INTERRUPT_PREVIOUS
Definition SmartScriptMgr.h:1950
@ SMARTCAST_AURA_NOT_PRESENT
Definition SmartScriptMgr.h:1955
@ SMARTCAST_THREATLIST_NOT_SINGLE
Definition SmartScriptMgr.h:1957
@ SMARTCAST_TARGET_POWER_MANA
Definition SmartScriptMgr.h:1958
@ 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:826
#define CAST_AI(a, b)
Definition UnitAI.h:26
#define ENSURE_AI(a, b)
Definition UnitAI.h:27
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:378
NPCFlags
Non Player Character flags.
Definition UnitDefines.h:317
SheathState
Definition UnitDefines.h:125
@ UNIT_STATE_LOST_CONTROL
Definition UnitDefines.h:216
@ UNIT_STATE_ROOT
Definition UnitDefines.h:180
@ UNIT_STATE_NO_ENVIRONMENT_UPD
Definition UnitDefines.h:198
@ UNIT_STATE_NO_COMBAT_MOVEMENT
Definition UnitDefines.h:201
UnitMoveType
Definition UnitDefines.h:352
@ MOVE_RUN
Definition UnitDefines.h:354
@ UNIT_FLAG_SILENCED
Definition UnitDefines.h:267
ReactStates
Definition Unit.h:554
@ UNIT_FIELD_FLAGS_2
Definition UpdateFields.h:118
@ UNIT_VIRTUAL_ITEM_SLOT_ID
Definition UpdateFields.h:116
@ UNIT_FIELD_FLAGS
Definition UpdateFields.h:117
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
@ UNIT_FIELD_BYTES_1
Definition UpdateFields.h:131
@ UNIT_DYNAMIC_FLAGS
Definition UpdateFields.h:136
@ GAMEOBJECT_FLAGS
Definition UpdateFields.h:399
#define sWaypointMgr
Definition WaypointMgr.h:79
std::map< uint32, WaypointData > WaypointPath
Definition WaypointMgr.h:48
#define sWorldState
Definition WorldState.h:377
WorldStateEvent
Definition WorldState.h:42
Say
Definition boss_broodlord_lashlayer.cpp:29
Seats
Definition boss_flame_leviathan.cpp:168
phase
Definition boss_skadi.cpp:99
Definition ChatTextBuilder.h:31
Definition SpellAuras.h:87
Definition CreatureAI.h:71
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0ms)
Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
Definition CreatureAI.cpp:53
void SetReputationRewardDisabled(bool disable)
Definition Creature.h:361
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:338
void Respawn(bool force=false)
Definition Creature.cpp:1991
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition Creature.cpp:2906
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:340
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
Definition Creature.cpp:2767
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:345
void DoFleeToGetAssistance()
Definition Creature.cpp:1055
bool IsRooted() const
Definition Creature.h:88
void SetCorpseDelay(uint32 delay)
Definition Creature.h:74
void SetLootRewardDisabled(bool disable)
Definition Creature.h:363
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:99
void LoadPath(uint32 pathid)
Definition Creature.h:349
Definition SpellDefines.h:165
void AddSpellMod(SpellValueMod mod, int32 value)
Definition SpellDefines.h:167
Definition EnumFlag.h:66
void AddEventAtOffset(BasicEvent *event, Milliseconds offset, uint8 eventGroup=0)
Definition EventProcessor.h:108
Definition GameObjectAI.h:33
virtual void SetData(uint32, uint32)
Definition GameObjectAI.h:62
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition GameObject.cpp:1394
bool isSpawnedByDefault() const
Definition GameObject.h:195
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2416
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1268
GameobjectTypes GetGoType() const
Definition GameObject.h:202
void Respawn()
Definition GameObject.cpp:1283
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition GameObject.cpp:916
void CastSpell(Unit *target, uint32 spell)
Definition GameObject.cpp:2061
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:214
PlayerList const & GetPlayers() const
Definition Map.h:326
void MoveWaypoint(uint32 path_id, bool repeatable, PathSource pathSource=PathSource::WAYPOINT_MGR)
Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:901
void MovementExpired(bool reset=true)
Definition MotionMaster.h:205
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=0)
Definition MotionMaster.h:254
void MoveIdle()
Definition MotionMaster.cpp:233
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:446
void MovePoint(uint32 id, const Position &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true, std::optional< AnimTier > animTier=std::nullopt)
Definition MotionMaster.h:238
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:243
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:1635
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:871
virtual void SetObjectScale(float scale)
Definition Object.h:120
Definition GossipDef.h:259
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition PlayerQuest.cpp:1850
void SendCinematicStart(uint32 CinematicSequenceId) const
Definition Player.cpp:5690
void PrepareGossipMenu(WorldObject *source, uint32 menuId=0, bool showQuests=false)
Definition PlayerGossip.cpp:32
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:12723
Definition QuestDef.h:210
void SetInvincibilityHpLevel(uint32 level)
Definition SmartAI.h:185
void SetData(uint32 id, uint32 value) override
Definition SmartAI.h:164
void IncPhase(uint32 p)
Definition SmartScript.cpp:5415
void StoreTargetList(ObjectVector const &targets, uint32 id)
Definition SmartScript.h:93
void RetryLater(SmartScriptHolder &e, bool ignoreChanceRoll=false)
Definition SmartScript.cpp:5103
void StoreCounter(uint32 id, uint32 value, uint32 reset, uint32 subtract)
Definition SmartScript.h:108
std::optional< std::reference_wrapper< SmartScriptHolder > > FindLinkedEvent(uint32 link)
Definition SmartScript.h:269
std::deque< SmartScriptFrame > executionStack
Definition SmartScript.h:286
void SetPhaseReset(bool allow)
Definition SmartScript.h:205
void GetTargets(ObjectVector &targets, SmartScriptHolder const &e, WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:3483
void OnReset()
Definition SmartScript.cpp:109
void InstallTemplate(SmartScriptHolder const &e)
Definition SmartScript.cpp:3371
ObjectGuid goOrigGUID
Definition SmartScript.h:229
void DecPhase(uint32 p)
Definition SmartScript.cpp:5421
ObjectGuid meOrigGUID
Definition SmartScript.h:227
Definition SpellInfo.h:316
SpellSchoolMask GetSchoolMask() const
Definition SpellInfo.cpp:1878
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:415
int32 CalcPowerCost(Unit const *caster, SpellSchoolMask schoolMask, Spell *spell=nullptr) const
Definition SpellInfo.cpp:2297
float GetThreatListSize() const
Definition ThreatMgr.h:225
void ModifyThreatByPercent(Unit *victim, int32 percent)
Definition ThreatMgr.cpp:576
Definition VehicleDefines.h:130
virtual void SetData(uint32, uint32)
Definition UnitAI.h:219
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:27
uint8 getGender() const
Definition Unit.h:838
void SetFacingToObject(WorldObject *object, Milliseconds timed=0ms)
Definition Unit.cpp:20521
void SetFacingTo(float ori)
Definition Unit.cpp:20511
void CombatStop(bool includingCast=false)
Definition Unit.cpp:10651
float GetSpeed(UnitMoveType mtype) const
Definition Unit.cpp:14601
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
Definition Unit.cpp:4180
float GetSpellMinRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:15285
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition Unit.cpp:14771
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:10831
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:17973
MotionMaster * GetMotionMaster()
Definition Unit.h:1738
void SetUnitMovementFlags(uint32 f)
Definition Unit.h:766
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:1251
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition Unit.cpp:13745
bool IsAlive() const
Definition Unit.h:1773
void StopMoving()
Definition Unit.cpp:16879
void SendPlaySpellVisual(uint32 id)
Definition Unit.cpp:19173
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5851
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:1757
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:15265
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:764
TransportBase * GetDirectTransport() const
Definition Unit.cpp:19029
void SendMovementFlagUpdate(bool self=false)
Definition Unit.cpp:16933
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:1194
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:5032
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:14606
ObjectGuid GetTransGUID() const override
Definition Unit.cpp:19018
bool IsAIEnabled
Definition Unit.h:2079
bool HasUnitState(const uint32 f) const
Definition Unit.h:726
float GetPowerPct(Powers power) const
Definition Unit.h:1122
void SetDisableGravity(bool disable)
Definition Unit.cpp:20562
float GetMeleeRange(Unit const *target) const
Definition Unit.cpp:683
uint32 GetPower(Powers power) const
Definition Unit.h:1120
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.h:1219
void SetInFront(WorldObject const *target)
Definition Unit.cpp:20505
bool isDead() const
Definition Unit.h:1775
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:2352
Map * FindMap() const
Definition Object.h:621
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:1373
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:2637
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:2710
std::string const & GetName() const
Definition Object.h:524
void AddObjectToRemoveList()
Definition Object.cpp:2144
EventProcessor m_Events
Definition Object.h:730
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1271
uint32 GetAreaId() const
Definition Object.cpp:3064
uint32 GetZoneId() const
Definition Object.cpp:3056
float GetObjectSize() const
Definition Object.cpp:2782
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:2366
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition Object.cpp:1528
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:2429
virtual float GetCombatReach() const
Definition Object.h:502
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2401
Player session in the World.
Definition WorldSession.h:375
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:356
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition CreatureData.h:357
Definition Position.h:27
float m_positionZ
Definition Position.h:57
float m_positionX
Definition Position.h:55
float GetPositionZ() const
Definition Position.h:123
float m_positionY
Definition Position.h:56
float GetOrientation() const
Definition Position.h:124
void SetOrientation(float orientation)
Definition Position.h:116
float GetPositionX() const
Definition Position.h:121
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetPositionY() const
Definition Position.h:122
void RelocatePolarOffset(float angle, float dist, float z=0.0f)
Definition Position.cpp:34
float GetAngle(const Position *pos) const
Definition Position.cpp:85
Definition SmartScriptMgr.h:744
struct SmartAction::@75::@98 combatMove
uint32 followState
Definition SmartScriptMgr.h:1453
uint32 visualId
Definition SmartScriptMgr.h:1448
uint32 targetParam2
Definition SmartScriptMgr.h:848
struct SmartAction::@75::@100 incEventPhase
struct SmartAction::@75::@106 killedMonster
SAIBool disableForceDestination
Definition SmartScriptMgr.h:1205
std::array< uint32, SMART_ACTION_PARAM_COUNT > emotes
Definition SmartScriptMgr.h:831
uint32 forcedMovement
Definition SmartScriptMgr.h:1030
uint32 repeatMax
Definition SmartScriptMgr.h:1107
uint32 phaseMin
Definition SmartScriptMgr.h:933
uint32 targetsLimit
Definition SmartScriptMgr.h:839
struct SmartAction::@75::@181 movementSpeed
struct SmartAction::@75::@186 setScale
SAIBool transport
Definition SmartScriptMgr.h:1201
struct SmartAction::@75::@192 wpDataRandom
struct SmartAction::@75::@82 randomSound
struct SmartAction::@75::@120 summonGO
uint32 startAngle
Definition SmartScriptMgr.h:1441
SAIBool reset
Definition SmartScriptMgr.h:1092
std::array< uint32, SMART_ACTION_PARAM_COUNT > actionLists
Definition SmartScriptMgr.h:1155
struct SmartAction::@75::@185 scriptSpawn
uint32 delay
Definition SmartScriptMgr.h:754
struct SmartAction::@75::@163 startClosestWaypoint
uint32 random
Definition SmartScriptMgr.h:1336
uint32 quickChange
Definition SmartScriptMgr.h:1335
uint32 targetParam4
Definition SmartScriptMgr.h:1465
uint32 dist
Definition SmartScriptMgr.h:918
uint32 group
Definition SmartScriptMgr.h:1258
SAIBool disable
Definition SmartScriptMgr.h:1390
struct SmartAction::@75::@180 corpseDelay
struct SmartAction::@75::@194 worldStateScript
struct SmartAction::@75::@111 callHelp
uint32 spell
Definition SmartScriptMgr.h:836
uint32 minHP
Definition SmartScriptMgr.h:985
struct SmartAction::@75::@177 summonVortex
uint32 flags
Definition SmartScriptMgr.h:845
struct SmartAction::@75::@97 autoAttack
SAIBool loot
Definition SmartScriptMgr.h:1508
uint32 distanceBetweenSummons
Definition SmartScriptMgr.h:1351
uint32 data
Definition SmartScriptMgr.h:945
struct SmartAction::@75::@105 randomPhaseRange
uint32 entry
Definition SmartScriptMgr.h:920
struct SmartAction::@75::@91 crossCast
struct SmartAction::@75::@129 setSwim
uint32 quest
Definition SmartScriptMgr.h:815
struct SmartAction::@75::@150 moveToPosTarget
struct SmartAction::@75::@172 orientation
struct SmartAction::@75::@78 simpleTalk
uint32 triggerFlags
Definition SmartScriptMgr.h:838
struct SmartAction::@75::@87 questOffer
uint32 bp1
Definition SmartScriptMgr.h:1366
uint32 distance
Definition SmartScriptMgr.h:778
SAIBool removeObjectFromWorld
Definition SmartScriptMgr.h:980
uint32 min
Definition SmartScriptMgr.h:1104
uint32 spawnTimerMax
Definition SmartScriptMgr.h:1425
uint32 subtract
Definition SmartScriptMgr.h:1093
struct SmartAction::@75::@110 die
uint32 a
Definition SmartScriptMgr.h:1375
struct SmartAction::@75::@151 sendGossipMenu
struct SmartAction::@75::@104 randomPhase
struct SmartAction::@75::@198 setGossipMenu
struct SmartAction::@75::@133 timeEvent
SAIBool invokerGUID
Definition SmartScriptMgr.h:1417
struct SmartAction::@75::@191 wpData
uint32 percent
Definition SmartScriptMgr.h:986
uint32 dec
Definition SmartScriptMgr.h:902
uint32 milliseconds
Definition SmartScriptMgr.h:962
struct SmartAction::@75::@125 item
uint32 summonEntry
Definition SmartScriptMgr.h:1348
struct SmartAction::@75::@84 randomMusic
uint32 followType
Definition SmartScriptMgr.h:1454
uint32 instanceTarget
Definition SmartScriptMgr.h:1385
struct SmartAction::@75::@196 reward
uint32 credit
Definition SmartScriptMgr.h:921
uint32 controlled
Definition SmartScriptMgr.h:1202
uint32 alternative
Definition SmartScriptMgr.h:854
uint32 targetParam1
Definition SmartScriptMgr.h:847
uint32 mapID
Definition SmartScriptMgr.h:1085
uint32 stopMovement
Definition SmartScriptMgr.h:1342
struct SmartAction::@75::@134 movie
struct SmartAction::@75::@94 summonCreature
uint32 charges
Definition SmartScriptMgr.h:913
struct SmartAction::@75::@113 forceDespawn
struct SmartAction::@75::@103 follow
uint32 model
Definition SmartScriptMgr.h:771
uint32 duration
Definition SmartScriptMgr.h:752
SAIBool attackInvoker
Definition SmartScriptMgr.h:867
SAIBool useTalkTarget
Definition SmartScriptMgr.h:753
SAIBool run
Definition SmartScriptMgr.h:1068
struct SmartAction::@75::@176 castCustom
uint32 value
Definition SmartScriptMgr.h:1091
struct SmartAction::@75::@140 timedActionList
uint32 movementExpired
Definition SmartScriptMgr.h:1343
struct SmartAction::@75::@117 moveRandom
uint32 targetParam3
Definition SmartScriptMgr.h:849
uint32 respawnDelay
Definition SmartScriptMgr.h:1426
SAIBool swim
Definition SmartScriptMgr.h:1080
uint32 combatReach
Definition SmartScriptMgr.h:1204
uint32 sound2
Definition SmartScriptMgr.h:784
struct SmartAction::@75::@188 spellVisual
uint32 spawnPos
Definition SmartScriptMgr.h:1306
struct SmartAction::@75::@92 activateObject
struct SmartAction::@75::@167 setHomePos
struct SmartAction::@75::@161 gameEventStop
uint32 pathId2
Definition SmartScriptMgr.h:1282
uint32 creature
Definition SmartScriptMgr.h:770
struct SmartAction::@75::@190 orientationTarget
uint32 spawnTimerMin
Definition SmartScriptMgr.h:1424
struct SmartAction::@75::@132 storeTargets
struct SmartAction::@75::@114 invincHP
uint32 angle
Definition SmartScriptMgr.h:919
uint32 field
Definition SmartScriptMgr.h:944
uint32 range
Definition SmartScriptMgr.h:859
struct SmartAction::@75::@95 threatPCT
struct SmartAction::@75::@89 randomEmote
struct SmartAction::@75::@162 gameEventStart
uint32 flag
Definition SmartScriptMgr.h:1125
uint32 sound3
Definition SmartScriptMgr.h:785
uint32 targetsummon
Definition SmartScriptMgr.h:1019
struct SmartAction::@75::@145 jump
uint32 chance
Definition SmartScriptMgr.h:1108
struct SmartAction::@75::@131 setCounter
uint32 state
Definition SmartScriptMgr.h:826
struct SmartAction::@75::@90 cast
struct SmartAction::@75::@108 setInstanceData64
uint32 sound1
Definition SmartScriptMgr.h:783
struct SmartAction::@75::@80 morphOrMount
struct SmartAction::@75::@116 setData
uint32 forceRespawnTimer
Definition SmartScriptMgr.h:979
uint32 speed
Definition SmartScriptMgr.h:1074
uint32 sound4
Definition SmartScriptMgr.h:786
struct SmartAction::@75::@147 flee
uint32 targetType
Definition SmartScriptMgr.h:846
uint32 repetitions
Definition SmartScriptMgr.h:1440
struct SmartAction::@75::@174 coneSummon
uint32 aliveState
Definition SmartScriptMgr.h:923
SAIBool onlySelf
Definition SmartScriptMgr.h:777
uint32 attackScriptOwner
Definition SmartScriptMgr.h:868
uint32 speedxy
Definition SmartScriptMgr.h:1178
uint32 pointId
Definition SmartScriptMgr.h:1200
SAIBool attack
Definition SmartScriptMgr.h:886
uint32 repeatMin
Definition SmartScriptMgr.h:1106
struct SmartAction::@75::@122 wpStart
uint32 scale
Definition SmartScriptMgr.h:1433
SAIBool fly
Definition SmartScriptMgr.h:1073
uint32 textGroupID
Definition SmartScriptMgr.h:751
uint32 castFlags
Definition SmartScriptMgr.h:837
struct SmartAction::@75::@179 disableEvade
std::array< uint32, SMART_ACTION_PARAM_COUNT > phases
Definition SmartScriptMgr.h:928
SAIBool dontDespawn
Definition SmartScriptMgr.h:1428
uint32 turnAngle
Definition SmartScriptMgr.h:1337
uint32 textId
Definition SmartScriptMgr.h:1358
uint32 gossipMenuId
Definition SmartScriptMgr.h:1216
uint32 speedz
Definition SmartScriptMgr.h:1179
SAIBool repeat
Definition SmartScriptMgr.h:1032
struct SmartAction::@75::@173 stopMotion
uint32 gossipNpcTextId
Definition SmartScriptMgr.h:1217
uint32 mask
Definition SmartScriptMgr.h:991
uint32 pathId1
Definition SmartScriptMgr.h:1281
uint32 phi_delta
Definition SmartScriptMgr.h:1378
uint32 count
Definition SmartScriptMgr.h:1053
struct SmartAction::@75::@112 setSheath
uint32 inc
Definition SmartScriptMgr.h:901
uint32 phaseMax
Definition SmartScriptMgr.h:934
struct SmartAction::@75::@130 teleport
uint32 timer
Definition SmartScriptMgr.h:1395
uint32 ContactDistance
Definition SmartScriptMgr.h:1203
struct SmartAction::@75::@79 faction
PathSource pathSource
Definition SmartScriptMgr.h:1285
struct SmartAction::@75::@135 equip
uint32 k
Definition SmartScriptMgr.h:1376
uint32 distanceBetweenRings
Definition SmartScriptMgr.h:1350
uint32 coneLength
Definition SmartScriptMgr.h:1352
uint32 counterId
Definition SmartScriptMgr.h:1090
SAIBool withEmote
Definition SmartScriptMgr.h:968
struct SmartAction::@75::@146 movementFlag
uint32 param
Definition SmartScriptMgr.h:1490
uint32 max
Definition SmartScriptMgr.h:1105
uint32 selfJump
Definition SmartScriptMgr.h:1180
struct SmartAction::@75::@183 cinematic
uint32 maxId
Definition SmartScriptMgr.h:1318
uint32 r_max
Definition SmartScriptMgr.h:1377
struct SmartAction::@75::@136 unitFlag
uint32 speedFraction
Definition SmartScriptMgr.h:1402
struct SmartAction::@75::@88 react
struct SmartAction::@75::@119 setActive
struct SmartAction::@75::@159 creatureGroup
SAIBool fail
Definition SmartScriptMgr.h:1047
struct SmartAction::@75::@124 wpStop
SAIBool directAdd
Definition SmartScriptMgr.h:821
uint32 bp2
Definition SmartScriptMgr.h:1367
uint32 disableGravity
Definition SmartScriptMgr.h:1075
uint32 sound
Definition SmartScriptMgr.h:776
uint32 threatINC
Definition SmartScriptMgr.h:874
uint32 coneAngle
Definition SmartScriptMgr.h:1353
uint32 summonDuration
Definition SmartScriptMgr.h:1349
struct SmartAction::@75::@148 RespawnTarget
struct SmartAction::@75::@175 playerTalk
uint32 threatDEC
Definition SmartScriptMgr.h:875
SAIBool reputation
Definition SmartScriptMgr.h:1507
uint32 stepAngle
Definition SmartScriptMgr.h:1442
struct SmartAction::@75::@153 sendTargetToTarget
uint32 reactState
Definition SmartScriptMgr.h:1035
uint32 speedInteger
Definition SmartScriptMgr.h:1401
struct SmartAction::@75::@77 talk
uint32 index
Definition SmartScriptMgr.h:1418
struct SmartAction::@75::@123 wpPause
struct SmartAction::@75::@83 music
uint32 actionId
Definition SmartScriptMgr.h:1383
struct SmartAction::@75::@169 randomTimedEvent
uint32 despawnTime
Definition SmartScriptMgr.h:1018
struct SmartAction::@75::@128 setFly
uint32 goRespawnTime
Definition SmartScriptMgr.h:1195
struct SmartAction::@75::@115 ingamePhaseMask
uint32 factionID
Definition SmartScriptMgr.h:765
uint32 eventId
Definition SmartScriptMgr.h:1489
struct SmartAction::@75::@189 followGroup
uint32 pathId
Definition SmartScriptMgr.h:1470
SAIBool move
Definition SmartScriptMgr.h:891
struct SmartAction::@75::@178 doAction
struct SmartAction::@75::@149 moveToPos
std::array< uint32, MAX_EQUIPMENT_ITEMS > slots
Definition SmartScriptMgr.h:1120
struct SmartAction::@75::@127 setRun
struct SmartAction::@75::@187 radialSummon
struct SmartAction::@75::@99 setEventPhase
struct SmartAction::@75::@107 setInstanceData
uint32 questID
Definition SmartScriptMgr.h:820
uint32 bp3
Definition SmartScriptMgr.h:1368
uint32 pathID
Definition SmartScriptMgr.h:1031
uint32 emote
Definition SmartScriptMgr.h:810
struct SmartAction::@75::@102 removeAura
uint32 id
Definition SmartScriptMgr.h:1025
uint32 minId
Definition SmartScriptMgr.h:1317
uint32 phase
Definition SmartScriptMgr.h:896
uint32 sheath
Definition SmartScriptMgr.h:973
uint32 isNegative
Definition SmartScriptMgr.h:1384
uint32 creditType
Definition SmartScriptMgr.h:922
struct SmartAction::@75::@141 randTimedActionList
struct SmartAction::@75::@154 setRangedMovement
struct SmartAction::@75::@184 setGuid
Definition SmartScriptMgr.h:205
uint32 repeatMin
Definition SmartScriptMgr.h:216
uint32 repeatMax
Definition SmartScriptMgr.h:217
bool runOnce
Definition SmartScriptMgr.h:2000
uint32 link
Definition SmartScriptMgr.h:1983
bool IsAreatriggerScript() const
Definition SmartScriptMgr.h:1995
uint32 event_id
Definition SmartScriptMgr.h:1982
int32 entryOrGuid
Definition SmartScriptMgr.h:1980
uint32 GetScriptType() const
Definition SmartScriptMgr.h:1990
uint32 GetTargetType() const
Definition SmartScriptMgr.h:1993
uint32 GetActionType() const
Definition SmartScriptMgr.h:1992
float o
Definition SmartScriptMgr.h:1597
uint32 maxDist
Definition SmartScriptMgr.h:1603
uint32 range
Definition SmartScriptMgr.h:1724
float x
Definition SmartScriptMgr.h:1597
uint32 self
Definition SmartScriptMgr.h:1726
struct SmartTarget::@199::@220 randomPoint
uint32 amount
Definition SmartScriptMgr.h:1725
float y
Definition SmartScriptMgr.h:1597
struct SmartTarget::@199::@203 unitRange
float z
Definition SmartScriptMgr.h:1597
Definition WaypointMgr.h:38
float z
Definition WaypointMgr.h:40
float x
Definition WaypointMgr.h:40
float y
Definition WaypointMgr.h:40

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::animTier, SmartAction::attack, SmartAction::attackInvoker, SmartAction::attackScriptOwner, UnitAI::AttackStart(), AURA_REMOVE_BY_EXPIRE, SmartAction::autoAttack, MapRefMgr::begin(), SmartAction::bp1, SmartAction::bp2, SmartAction::bp3, BROADCAST_TEXT_CALL_FOR_HELP, BROADCAST_TEXT_FLEE_FOR_ASSIST, SmartAction::byte1, SpellInfo::CalcPowerCost(), SmartAction::callHelp, SmartAction::cast, CAST_AI, SmartAction::castCustom, Unit::CastCustomSpell(), SmartAction::castFlags, Unit::CastSpell(), GameObject::CastSpell(), SmartAction::chance, SmartAction::charges, CHAT_MSG_ADDON, CHAT_MSG_MONSTER_EMOTE, ObjectMgr::ChooseDisplayId(), SmartAction::cinematic, ClearGossipMenuFor(), SmartAction::combatDistance, SmartAction::combatMove, SmartAction::combatReach, Unit::CombatStop(), SmartAction::coneAngle, SmartAction::coneLength, SmartAction::coneSummon, SmartAction::ContactDistance, SmartAction::controlled, SmartAction::corpseDelay, SmartAction::count, SmartAction::counterId, CreateSmartEvent(), SmartAction::creature, CreatureModel::CreatureDisplayID, SmartAction::creatureGroup, SmartAction::credit, SmartAction::creditType, SmartAction::crossCast, SmartAction::data, SmartAction::dec, DecPhase(), DEFAULT_LOCALE, SmartAction::delay, SmartAction::delunitByte, GameObject::DespawnOrUnsummon(), SmartAction::despawnTime, SmartAction::die, SmartAction::directAdd, SmartAction::disable, SmartAction::disableEvade, SmartAction::disableForceDestination, SmartAction::disableGravity, CreatureModel::DisplayScale, SmartAction::dist, SmartAction::distance, SmartAction::distanceBetweenRings, SmartAction::distanceBetweenSummons, SmartAction::doAction, InstanceScript::DoAction(), Creature::DoFleeToGetAssistance(), SmartAction::dontDespawn, SmartAction::duration, SmartAction::emote, SmartAction::emotes, ObjectGuid::Empty, MapRefMgr::end(), ENSURE_AI, SmartAction::entry, SmartScriptHolder::entryOrGuid, SmartAction::equip, SmartScriptHolder::event, SmartEvent::event_chance, SmartEvent::event_flags, SmartScriptHolder::event_id, SmartAction::eventId, executionStack, SmartAction::faction, SmartAction::factionID, SmartAction::fail, SmartAction::field, FindLinkedEvent(), WorldObject::FindMap(), SmartAction::flag, SmartAction::flags, SmartAction::flee, SmartAction::fly, SmartAction::follow, FOLLOW_TYPE_ANGULAR, FOLLOW_TYPE_CIRCLE, FOLLOW_TYPE_COLUMN, FOLLOW_TYPE_LINE, FOLLOW_TYPE_SEMI_CIRCLE_BEHIND, FOLLOW_TYPE_SEMI_CIRCLE_FRONT, SmartAction::followGroup, SmartAction::followState, SmartAction::followType, SmartAction::force, FORCED_MOVEMENT_NONE, SmartAction::forceDespawn, SmartAction::forcedMovement, SmartAction::forceRespawnTimer, frand(), SmartAction::gameEventStart, SmartAction::gameEventStop, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_DOOR, SmartScriptHolder::GetActionType(), Position::GetAngle(), WorldObject::GetAreaId(), GetBaseObject(), InstanceScript::GetBossStateName(), Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), WorldObject::GetClosePoint(), WorldObject::GetCombatReach(), Unit::GetDirectTransport(), WorldObject::GetDistance(), Object::GetEntry(), SmartScriptHolder::GetEventType(), Unit::getGender(), GameObject::GetGoType(), Object::GetGUID(), Creature::GetHomePosition(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), WorldObject::GetMap(), Unit::GetMeleeRange(), 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(), 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(), SmartScriptHolder::IsAreatriggerScript(), IsCreature(), Unit::isDead(), Map::IsDungeon(), LinkedListHead::IsEmpty(), IsGameObject(), SmartAction::isNegative, IsPlayer(), Creature::IsRooted(), IsSmart(), IsUnit(), Unit::IsVehicle(), WorldObject::IsWithinLOSInMap(), SmartAction::item, EquipmentInfo::ItemEntry, SmartAction::jump, SmartAction::k, Unit::Kill(), SmartAction::killedMonster, Unit::KillSelf(), LANG_ADDON, LANG_UNIVERSAL, SmartScriptHolder::link, SmartAction::loadEquipment, Map::LoadGrid(), LOG_DEBUG, LOG_ERROR, SmartAction::loot, VMAP::M2, WorldObject::m_Events, Position::m_positionX, Position::m_positionY, Position::m_positionZ, SmartAction::mapID, SmartAction::mask, SmartEvent::max, SmartAction::max, MAX_EQUIPMENT_ITEMS, SmartTarget::maxDist, SmartAction::maxId, me, meOrigGUID, SmartAction::milliseconds, SmartEvent::min, SmartAction::min, SmartAction::minHP, SmartAction::minId, SmartEvent::minMaxRepeat, mLastInvoker, mLastTextID, SmartAction::model, 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::moveToPosTarget, 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::pathSource, SmartAction::percent, PersonalSpawn, SmartAction::phase, SmartAction::phaseMax, SmartAction::phaseMin, SmartAction::phases, SmartAction::phi_delta, SmartAction::playerTalk, SmartAction::pointId, SmartAction::power, POWER_MANA, SmartAction::powerType, PreferUnit, ProcessEventsFor(), SmartAction::quest, SmartAction::questID, SmartAction::questOffer, SmartAction::quickChange, SmartAction::r_max, SmartAction::radialSummon, SmartAction::random, SmartAction::randomEmote, SmartAction::randomMusic, SmartAction::randomPhase, SmartAction::randomPhaseRange, SmartTarget::randomPoint, Acore::Containers::RandomResize(), SmartAction::randomSound, SmartAction::randomTimedEvent, SmartAction::randTimedActionList, SmartAction::range, SmartTarget::range, SmartAction::react, SmartAction::reactState, SmartAction::regenHealth, Position::RelocatePolarOffset(), SmartAction::removeAura, Unit::RemoveAurasDueToSpell(), SmartAction::removeObjectFromWorld, SmartAction::repeat, SmartEvent::repeatMax, SmartAction::repeatMax, SmartEvent::repeatMin, SmartAction::repeatMin, SmartAction::repetitions, SmartAction::reputation, SmartAction::reset, ResetBaseObject(), SmartAction::respawnDelay, SmartAction::RespawnTarget, RetryLater(), SmartAction::reward, Player::RewardPlayerAndGroupAtEvent(), SmartAction::root, SmartAction::run, SmartScriptHolder::runOnce, SmartAction::scale, sCreatureTextMgr, SmartAction::scriptSpawn, Acore::Containers::SelectRandomContainerElement(), SmartTarget::self, SmartAction::selfJump, SmartAction::sendGoCustomAnim, SmartAction::sendGossipMenu, SendGossipMenuFor(), Unit::SendPlaySpellVisual(), PlayerMenu::SendQuestGiverQuestDetails(), SmartAction::sendTargetToTarget, Creature::SendZoneUnderAttackMessage(), SmartAction::setActive, InstanceScript::SetBossState(), SmartAction::setCounter, GameObjectAI::SetData(), UnitAI::SetData(), SmartAction::setData, ZoneScript::SetData(), Unit::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, SmartAction::setGoLootState, SmartAction::setGossipMenu, SmartAction::setGuid, ZoneScript::SetGuidData(), SmartAction::setHealthPct, SmartAction::setHealthRegen, SmartAction::setHomePos, Creature::SetHomePosition(), SmartAction::setHover, Unit::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_ESCORT_PAUSE, SMART_ACTION_ESCORT_RESUME, SMART_ACTION_ESCORT_START, SMART_ACTION_ESCORT_STOP, SMART_ACTION_EVADE, SMART_ACTION_EXIT_VEHICLE, SMART_ACTION_FAIL_QUEST, SMART_ACTION_FALL, SMART_ACTION_FLEE, SMART_ACTION_FLEE_FOR_ASSIST, SMART_ACTION_FOLLOW, SMART_ACTION_FOLLOW_GROUP, SMART_ACTION_FORCE_DESPAWN, SMART_ACTION_GAME_EVENT_START, SMART_ACTION_GAME_EVENT_STOP, SMART_ACTION_GO_SET_GO_STATE, SMART_ACTION_GO_SET_LOOT_STATE, SMART_ACTION_INC_EVENT_PHASE, SMART_ACTION_INSTALL_AI_TEMPLATE, SMART_ACTION_INTERRUPT_SPELL, SMART_ACTION_INVOKER_CAST, SMART_ACTION_JUMP_TO_POS, SMART_ACTION_KILL_UNIT, SMART_ACTION_LOAD_EQUIPMENT, SMART_ACTION_LOAD_GRID, SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL, SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL, SMART_ACTION_MOVE_FORWARD, SMART_ACTION_MOVE_TO_POS, SMART_ACTION_MOVE_TO_POS_TARGET, SMART_ACTION_MOVEMENT_PAUSE, SMART_ACTION_MOVEMENT_RESUME, SMART_ACTION_MOVEMENT_STOP, SMART_ACTION_MUSIC, SMART_ACTION_NO_ENVIRONMENT_UPDATE, SMART_ACTION_NONE, SMART_ACTION_OFFER_QUEST, SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT, SMART_ACTION_PLAY_CINEMATIC, SMART_ACTION_PLAY_EMOTE, SMART_ACTION_PLAY_SPELL_VISUAL, SMART_ACTION_PLAYER_TALK, SMART_ACTION_PLAYMOVIE, SMART_ACTION_RANDOM_EMOTE, SMART_ACTION_RANDOM_MOVE, SMART_ACTION_RANDOM_MUSIC, SMART_ACTION_RANDOM_PHASE, SMART_ACTION_RANDOM_PHASE_RANGE, SMART_ACTION_RANDOM_SOUND, SMART_ACTION_REMOVE_ALL_GAMEOBJECTS, SMART_ACTION_REMOVE_DYNAMIC_FLAG, SMART_ACTION_REMOVE_GO_FLAG, SMART_ACTION_REMOVE_IMMUNITY, SMART_ACTION_REMOVE_ITEM, SMART_ACTION_REMOVE_NPC_FLAG, SMART_ACTION_REMOVE_POWER, SMART_ACTION_REMOVE_TIMED_EVENT, SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1, SMART_ACTION_REMOVE_UNIT_FLAG, SMART_ACTION_REMOVEAURASFROMSPELL, SMART_ACTION_RESET_GOBJECT, SMART_ACTION_RESET_SCRIPT_BASE_OBJECT, SMART_ACTION_RESPAWN_TARGET, SMART_ACTION_RISE_UP, SMART_ACTION_SCRIPTED_SPAWN, SMART_ACTION_SELF_CAST, SMART_ACTION_SEND_GO_CUSTOM_ANIM, SMART_ACTION_SEND_GOSSIP_MENU, SMART_ACTION_SEND_TARGET_TO_TARGET, SMART_ACTION_SET_ACTIVE, SMART_ACTION_SET_ANIM_TIER, SMART_ACTION_SET_COMBAT_DISTANCE, SMART_ACTION_SET_CORPSE_DELAY, SMART_ACTION_SET_COUNTER, SMART_ACTION_SET_DATA, SMART_ACTION_SET_DYNAMIC_FLAG, SMART_ACTION_SET_EMOTE_STATE, SMART_ACTION_SET_EVENT_FLAG_RESET, SMART_ACTION_SET_EVENT_PHASE, SMART_ACTION_SET_FACTION, SMART_ACTION_SET_FLY, SMART_ACTION_SET_GO_FLAG, SMART_ACTION_SET_GOSSIP_MENU, SMART_ACTION_SET_GUID, SMART_ACTION_SET_HEALTH_PCT, SMART_ACTION_SET_HEALTH_REGEN, SMART_ACTION_SET_HOME_POS, SMART_ACTION_SET_HOVER, SMART_ACTION_SET_IN_COMBAT_WITH_ZONE, SMART_ACTION_SET_INGAME_PHASE_MASK, SMART_ACTION_SET_INST_DATA, SMART_ACTION_SET_INST_DATA64, SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL, SMART_ACTION_SET_MOVEMENT_SPEED, SMART_ACTION_SET_NPC_FLAG, SMART_ACTION_SET_ORIENTATION, SMART_ACTION_SET_ORIENTATION_TARGET, SMART_ACTION_SET_POWER, SMART_ACTION_SET_RANGED_MOVEMENT, SMART_ACTION_SET_REACT_STATE, SMART_ACTION_SET_ROOT, SMART_ACTION_SET_RUN, SMART_ACTION_SET_SCALE, SMART_ACTION_SET_SHEATH, SMART_ACTION_SET_SIGHT_DIST, SMART_ACTION_SET_SWIM, SMART_ACTION_SET_UNIT_FIELD_BYTES_1, SMART_ACTION_SET_UNIT_FLAG, SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS, SMART_ACTION_SET_VISIBILITY, SMART_ACTION_SIMPLE_TALK, SMART_ACTION_SOUND, SMART_ACTION_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_START, SMART_ACTION_WORLD_SCRIPT, SMART_ACTION_ZONE_UNDER_ATTACK, SMART_ESCORT_TARGETS, SMART_EVENT_ESCORT_REACHED, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL, SMART_EVENT_LINK, SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_RANDOM_POINT, SMART_TARGET_NONE, SMART_TARGET_POSITION, SMART_TARGET_RANDOM_POINT, SMART_TARGET_SELF, SMART_WAYPOINT_MGR, SMARTCAST_AURA_NOT_PRESENT, SMARTCAST_COMBAT_MOVE, SMARTCAST_ENABLE_COMBAT_MOVE_ON_LOS, SMARTCAST_INTERRUPT_PREVIOUS, SMARTCAST_TARGET_POWER_MANA, SMARTCAST_THREATLIST_NOT_SINGLE, SMARTCAST_TRIGGERED, sObjectMgr, SmartAction::sound, SmartAction::sound1, SmartAction::sound2, SmartAction::sound3, SmartAction::sound4, SmartScriptHolder::source_type, SmartAction::spawnPos, SmartAction::spawnTimerMax, SmartAction::spawnTimerMin, SmartAction::speed, SmartAction::speedFraction, SmartAction::speedInteger, SmartAction::speedxy, SmartAction::speedz, SmartAction::spell, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_CAST_OK, SPELL_FAILED_OUT_OF_RANGE, SPELL_FAILED_SPELL_IN_PROGRESS, SmartAction::spell_id, SPELLVALUE_BASE_POINT0, SPELLVALUE_BASE_POINT1, SPELLVALUE_BASE_POINT2, SmartAction::spellVisual, sSmartWaypointMgr, sSpellMgr, SmartAction::startAngle, SmartAction::startClosestWaypoint, SmartAction::state, SmartAction::stepAngle, SmartAction::stopMotion, SmartAction::stopMovement, StoreCounter(), StoreTargetList(), SmartAction::storeTargets, SmartAction::subtract, SmartAction::summonCreature, WorldObject::SummonCreature(), WorldObject::SummonCreatureGroup(), SmartAction::summonDuration, SmartAction::summonEntry, WorldObject::SummonGameObject(), SmartAction::summonGO, WorldObject::SummonTrigger(), SmartAction::summonVortex, sWaypointMgr, SmartAction::swim, sWorldState, CreatureAI::Talk(), SmartAction::talk, SmartScriptHolder::target, SmartAction::targetParam1, SmartAction::targetParam2, SmartAction::targetParam3, SmartAction::targetParam4, SmartAction::targetsLimit, SmartAction::targetsummon, SmartAction::targetType, SmartAction::taxi, TEAM_NEUTRAL, SmartAction::teleport, TEMPSUMMON_CORPSE_DESPAWN, TEMPSUMMON_TIMED_DESPAWN, TEXT_RANGE_NORMAL, SmartAction::textGroupID, SmartAction::textId, SmartAction::threatDEC, SmartAction::threatINC, SmartAction::threatPCT, SmartAction::timedActionList, SmartAction::timeEvent, SmartAction::timer, Object::ToCreature(), Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), SmartAction::transport, trigger, TRIGGERED_FULL_MASK, TRIGGERED_NONE, SmartAction::triggerFlags, SmartAction::turnAngle, SmartEvent::type, SmartAction::type, SmartTarget::type, UNIT_DYNAMIC_FLAGS, UNIT_FIELD_BYTES_1, UNIT_FIELD_FLAGS, UNIT_FIELD_FLAGS_2, UNIT_FLAG_SILENCED, UNIT_NPC_EMOTESTATE, UNIT_STATE_LOST_CONTROL, UNIT_STATE_NO_COMBAT_MOVEMENT, UNIT_STATE_NO_ENVIRONMENT_UPD, UNIT_STATE_ROOT, UNIT_VIRTUAL_ITEM_SLOT_ID, SmartAction::unitFlag, SmartTarget::unitRange, SmartAction::updateLevel, SmartAction::updateTemplate, urand(), GameObject::UseDoorOrButton(), SmartAction::useTalkTarget, SmartAction::value, SmartAction::visibility, SmartAction::visualId, WAYPOINT_MGR, SmartAction::withDelayed, SmartAction::withEmote, SmartAction::withInstant, SmartAction::worldStateScript, SmartAction::wpData, SmartAction::wpDataRandom, SmartAction::wpPause, SmartAction::wpStart, SmartAction::wpStop, SmartTarget::x, WaypointData::x, SmartTarget::y, WaypointData::y, SmartTarget::z, and WaypointData::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 
)
4076{
4077 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4078 return;
4079
4081 return;
4082
4084 return;
4085
4086 switch (e.GetEventType())
4087 {
4088 case SMART_EVENT_LINK://special handling
4089 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4090 break;
4091 //called from Update tick
4092 case SMART_EVENT_UPDATE:
4094 break;
4096 if (me && me->IsEngaged())
4097 return;
4099 break;
4101 if (!me || !me->IsEngaged())
4102 return;
4104 break;
4106 {
4107 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4108 return;
4109 uint32 perc = (uint32)me->GetHealthPct();
4110 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4111 return;
4113 break;
4114 }
4116 {
4117 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4118 return;
4119 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4120 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4121 return;
4123 break;
4124 }
4126 {
4127 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4128 return;
4130 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4131 return;
4133 break;
4134 }
4136 {
4137 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4138 return;
4140 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4141 return;
4143 break;
4144 }
4145 case SMART_EVENT_RANGE:
4146 {
4147 if (!me || !me->IsEngaged() || !me->GetVictim())
4148 return;
4149
4152 else
4153 RecalcTimer(e, 1200, 1200); // make it predictable
4154
4155 break;
4156 }
4158 {
4159 if (!me || !me->IsEngaged())
4160 return;
4161
4162 Unit* victim = me->GetVictim();
4163
4164 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4165 return;
4166
4167 if (e.event.targetCasting.spellId > 0)
4168 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4169 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4170 return;
4171
4173 break;
4174 }
4176 {
4177 if (!me || !me->IsEngaged())
4178 return;
4179
4181 if (!target || !target->IsInCombat())
4182 {
4183 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4184 RecalcTimer(e, 1000, 3000);
4185 return;
4186 }
4188 break;
4189 }
4191 {
4192 if (!me || !me->IsEngaged())
4193 return;
4194
4195 std::vector<Creature*> creatures;
4197 if (creatures.empty())
4198 {
4199 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4200 RecalcTimer(e, 1000, 3000);
4201 return;
4202 }
4204 break;
4205 }
4207 {
4209 {
4210 return;
4211 }
4212
4213 std::vector<Creature*> creatures;
4215
4216 if (creatures.empty())
4217 return;
4218
4220 break;
4221 }
4223 {
4224 if (!me)
4225 return;
4226 uint32 count = me->GetAuraCount(e.event.aura.spell);
4227 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4229 break;
4230 }
4232 {
4233 if (!me || !me->GetVictim())
4234 return;
4236 if (count < e.event.aura.count)
4237 return;
4239 break;
4240 }
4242 {
4243 if (bvar == (e.event.charm.onRemove != 1))
4244 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4245 break;
4246 }
4247 //no params
4248 case SMART_EVENT_AGGRO:
4249 case SMART_EVENT_DEATH:
4250 case SMART_EVENT_EVADE:
4263 case SMART_EVENT_RESET:
4267 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4268 break;
4269
4271 switch (e.event.gossipHello.filter)
4272 {
4273 case 0:
4274 // no filter set, always execute action
4275 break;
4276 case 1:
4277 // GossipHello only filter set, skip action if reportUse
4278 if (var0)
4279 {
4280 return;
4281 }
4282 break;
4283 case 2:
4284 // reportUse only filter set, skip action if GossipHello
4285 if (!var0)
4286 {
4287 return;
4288 }
4289 break;
4290 default:
4291 // Ignore any other value
4292 break;
4293 }
4294
4295 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4296 break;
4298 {
4299 if (!me)
4300 return;
4301
4302 if (Unit* victim = me->GetVictim())
4303 {
4305 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4307 }
4308
4309 break;
4310 }
4312 {
4313 if (!me)
4314 return;
4315
4316 if (Unit* victim = me->GetVictim())
4317 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4318 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4320
4321 break;
4322 }
4324 if (e.event.emote.emote == var0)
4325 {
4326 ProcessAction(e, unit);
4327 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4328 }
4329 break;
4330 case SMART_EVENT_KILL:
4331 {
4332 if (!me || !unit)
4333 return;
4334 if (e.event.kill.playerOnly && !unit->IsPlayer())
4335 return;
4336 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4337 return;
4339 ProcessAction(e, unit);
4340 break;
4341 }
4344 {
4345 if (!spell)
4346 return;
4347 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4348 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4349 {
4351 ProcessAction(e, unit, 0, 0, bvar, spell);
4352 }
4353 break;
4354 }
4356 {
4357 if (!me || me->IsEngaged())
4358 return;
4359 //can trigger if closer than fMaxAllowedRange
4360 float range = (float)e.event.los.maxDist;
4361
4362 //if range is ok and we are actually in LOS
4363 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4364 {
4366 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4367 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4368 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4369 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4370 {
4371 if (e.event.los.playerOnly && !unit->IsPlayer())
4372 return;
4374 ProcessAction(e, unit);
4375 }
4376 }
4377 break;
4378 }
4379 case SMART_EVENT_IC_LOS:
4380 {
4381 if (!me || !me->IsEngaged())
4382 return;
4383 //can trigger if closer than fMaxAllowedRange
4384 float range = (float)e.event.los.maxDist;
4385
4386 //if range is ok and we are actually in LOS
4387 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4388 {
4390 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4391 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4392 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4393 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4394 {
4395 if (e.event.los.playerOnly && !unit->IsPlayer())
4396 return;
4398 ProcessAction(e, unit);
4399 }
4400 }
4401 break;
4402 }
4404 {
4405 if (!GetBaseObject())
4406 return;
4408 return;
4410 return;
4411 ProcessAction(e);
4412 break;
4413 }
4417 {
4418 if (!IsCreature(unit))
4419 return;
4420 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4421 return;
4423 ProcessAction(e, unit);
4424 break;
4425 }
4429 {
4430 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4431 return;
4433 ProcessAction(e, unit);
4434 break;
4435 }
4437 {
4438 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4439 return;
4441 return;
4442 ProcessAction(e, unit, var0, var1);
4443 break;
4444 }
4447 {
4448 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4449 return;
4450 ProcessAction(e, unit, var0);
4451 break;
4452 }
4458 {
4459 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4460 return;
4461 ProcessAction(e, unit);
4462 break;
4463 }
4465 {
4466 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4467 return;
4469 ProcessAction(e, unit, var0);
4470 break;
4471 }
4473 {
4475 return;
4477 ProcessAction(e, unit, var0);
4478 break;
4479 }
4482 {
4483 if (e.event.quest.quest && var0 != e.event.quest.quest)
4484 return;
4485 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4486 ProcessAction(e, unit, var0);
4487 break;
4488 }
4490 {
4492 return;
4493 ProcessAction(e, unit, var0);
4494 break;
4495 }
4497 {
4498 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4499 return;
4500 ProcessAction(e, unit, var0);
4501 break;
4502 }
4504 {
4506 return;
4507 ProcessAction(e, unit, var0);
4508 break;
4509 }
4511 {
4512 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4513 return;
4515 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4516 break;
4517 }
4520 {
4521 if (!unit)
4522 return;
4524 ProcessAction(e, unit);
4525 break;
4526 }
4528 {
4529 if (e.event.timedEvent.id == var0)
4530 ProcessAction(e, unit);
4531 break;
4532 }
4534 {
4535 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4536 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4537 return;
4538 ProcessAction(e, unit, var0, var1);
4539 break;
4540 }
4542 {
4544 return;
4545
4546 ProcessAction(e);
4547 break;
4548 }
4551 {
4552 if (e.event.gameEvent.gameEventId != var0)
4553 return;
4554 ProcessAction(e, nullptr, var0);
4555 break;
4556 }
4558 {
4559 if (e.event.goStateChanged.state != var0)
4560 return;
4561 ProcessAction(e, unit, var0, var1);
4562 break;
4563 }
4565 {
4566 if (e.event.eventInform.eventId != var0)
4567 return;
4568 ProcessAction(e, nullptr, var0);
4569 break;
4570 }
4572 {
4573 if (e.event.doAction.eventId != var0)
4574 return;
4576 ProcessAction(e, unit, var0);
4577 break;
4578 }
4580 {
4581 if (!me || !me->IsEngaged())
4582 return;
4583
4584 Unit* unitTarget = nullptr;
4585 switch (e.GetTargetType())
4586 {
4594 {
4595 ObjectVector targets;
4596 GetTargets(targets, e);
4597 for (WorldObject* target : targets)
4598 {
4599 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4600 {
4601 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4602 if (healthPct > e.event.friendlyHealthPct.hpPct)
4603 {
4604 continue;
4605 }
4606
4607 unitTarget = target->ToUnit();
4608 break;
4609 }
4610 }
4611
4612 break;
4613 }
4614 case SMART_TARGET_SELF:
4617 break;
4618 default:
4619 return;
4620 }
4621
4622 if (!unitTarget)
4623 return;
4624
4626 break;
4627 }
4629 {
4630 if (!me)
4631 return;
4632
4633 WorldObject* creature = nullptr;
4634
4635 if (e.event.distance.guid != 0)
4636 {
4637 creature = FindCreatureNear(me, e.event.distance.guid);
4638
4639 if (!creature)
4640 return;
4641
4642 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4643 return;
4644 }
4645 else if (e.event.distance.entry != 0)
4646 {
4647 std::list<Creature*> list;
4649
4650 if (!list.empty())
4651 creature = list.front();
4652 }
4653
4654 if (creature)
4656
4657 break;
4658 }
4660 {
4661 if (!me)
4662 return;
4663
4664 WorldObject* gameobject = nullptr;
4665
4666 if (e.event.distance.guid != 0)
4667 {
4668 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4669
4670 if (!gameobject)
4671 return;
4672
4673 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4674 return;
4675 }
4676 else if (e.event.distance.entry != 0)
4677 {
4678 std::list<GameObject*> list;
4680
4681 if (!list.empty())
4682 gameobject = list.front();
4683 }
4684
4685 if (gameobject)
4687
4688 break;
4689 }
4691 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4692 return;
4693
4695 break;
4697 {
4698 uint32 playerCount = 0;
4699 ObjectVector targets;
4700 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4701
4702 if (!targets.empty())
4703 {
4704 for (WorldObject* target : targets)
4705 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4706 playerCount++;
4707
4708 if (playerCount >= e.event.nearPlayer.minCount)
4709 ProcessAction(e, unit);
4710 }
4712 break;
4713 }
4715 {
4716 uint32 playerCount = 0;
4717 ObjectVector targets;
4718 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4719
4720 if (!targets.empty())
4721 {
4722 for (WorldObject* target : targets)
4723 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4724 playerCount++;
4725
4726 if (playerCount < e.event.nearPlayerNegation.maxCount)
4727 ProcessAction(e, unit);
4728 }
4730 break;
4731 }
4733 {
4734 uint32 unitCount = 0;
4735 ObjectVector targets;
4736 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4737
4738 if (!targets.empty())
4739 {
4740 if (e.event.nearUnit.type)
4741 {
4742 for (WorldObject* target : targets)
4743 {
4744 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4745 unitCount++;
4746 }
4747 }
4748 else
4749 {
4750 for (WorldObject* target : targets)
4751 {
4752 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4753 unitCount++;
4754 }
4755 }
4756
4757 if (unitCount >= e.event.nearUnit.count)
4758 ProcessAction(e, unit);
4759 }
4761 break;
4762 }
4764 {
4765 uint32 unitCount = 0;
4766 ObjectVector targets;
4767 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4768
4769 if (!targets.empty())
4770 {
4772 {
4773 for (WorldObject* target : targets)
4774 {
4775 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4776 unitCount++;
4777 }
4778 }
4779 else
4780 {
4781 for (WorldObject* target : targets)
4782 {
4783 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4784 unitCount++;
4785 }
4786 }
4787
4788 if (unitCount < e.event.nearUnitNegation.count)
4789 ProcessAction(e, unit);
4790 }
4792 break;
4793 }
4795 {
4796 if (!me || !me->IsEngaged())
4797 return;
4798
4800 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4801 {
4802 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4803 {
4804 if (!target || !IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4805 continue;
4806
4807 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4808 continue;
4809
4810 ProcessAction(e, target);
4812 return;
4813 }
4814 }
4815
4816 // No targets found
4818 break;
4819 }
4821 {
4822 if (!me || !me->IsEngaged())
4823 return;
4824
4826 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4827 {
4828 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4829 {
4830 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4831 continue;
4832
4833 ProcessAction(e, target);
4835 return;
4836 }
4837 }
4838
4839 // If no targets are found and it's off cooldown, check again
4840 RecalcTimer(e, 1200, 1200);
4841 break;
4842 }
4845 {
4846 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4847 return;
4848 ProcessAction(e, unit);
4849 break;
4850 }
4851 default:
4852 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4853 break;
4854 }
4855}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1939
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:536
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:535
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:106
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:171
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:134
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:107
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:121
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:150
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:152
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:129
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:117
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:148
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:101
@ SMART_EVENT_ESCORT_START
Definition SmartScriptMgr.h:138
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:165
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:145
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:172
@ SMART_EVENT_ESCORT_PAUSED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_ESCORT_RESUMED
Definition SmartScriptMgr.h:155
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:127
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:144
@ SMART_EVENT_ESCORT_ENDED
Definition SmartScriptMgr.h:157
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:120
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:141
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:119
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:170
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:128
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:130
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:167
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:104
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:142
@ SMART_EVENT_ESCORT_STOPPED
Definition SmartScriptMgr.h:156
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:163
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:161
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:135
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:196
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:126
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:140
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:198
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:118
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:176
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:115
@ SMART_EVENT_WAYPOINT_REACHED
Definition SmartScriptMgr.h:197
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:123
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:110
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:113
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:149
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:105
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:143
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:131
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:164
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:147
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:183
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:114
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:103
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:111
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:112
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:132
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:122
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:116
@ CURRENT_GENERIC_SPELL
Definition Unit.h:545
uint32 GetWaypointPath() const
Definition Creature.h:348
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5316
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5306
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:5399
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5279
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5445
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5292
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:3356
Definition Spell.h:295
float GetHealthPct() const
Definition Unit.h:1095
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4150
uint32 GetMaxHealth() const
Definition Unit.h:1094
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:665
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5812
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1121
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10431
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:10426
bool IsInCombat() const
Definition Unit.h:924
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1561
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2490
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2504
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1347
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:148
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:253
uint32 pointId
Definition SmartScriptMgr.h:508
uint32 invert
Definition SmartScriptMgr.h:494
uint32 entry
Definition SmartScriptMgr.h:447
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:339
LOSHostilityMode
Definition SmartScriptMgr.h:524
uint32 cooldownMax
Definition SmartScriptMgr.h:225
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:353
uint32 radius
Definition SmartScriptMgr.h:273
uint32 maxDist
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:397
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:233
uint32 rangeMin
Definition SmartScriptMgr.h:218
uint32 eventId
Definition SmartScriptMgr.h:424
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:446
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:448
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:267
uint32 emote
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:440
uint32 filter
Definition SmartScriptMgr.h:392
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:243
uint32 hpDeficit
Definition SmartScriptMgr.h:272
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:254
uint32 count
Definition SmartScriptMgr.h:318
uint32 onlyInCombat
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:346
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:354
SAIBool playerOnly
Definition SmartScriptMgr.h:226
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:340
uint32 creatureEntry
Definition SmartScriptMgr.h:382
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:398
struct SmartEvent::@30::@64 doAction
struct SmartEvent::@30::@46 charm
struct SmartEvent::@30::@63 eventInform
struct SmartEvent::@30::@38 targetCasting
uint32 spell
Definition SmartScriptMgr.h:232
uint32 maxCount
Definition SmartScriptMgr.h:471
uint32 gameEventId
Definition SmartScriptMgr.h:414
uint32 textGroupID
Definition SmartScriptMgr.h:381
uint32 cooldownMin
Definition SmartScriptMgr.h:224
uint32 onRemove
Definition SmartScriptMgr.h:325
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:303
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:419
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:219
uint32 team
Definition SmartScriptMgr.h:369
uint32 range
Definition SmartScriptMgr.h:483
uint32 minCount
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@37 minMax
struct SmartEvent::@30::@55 textOver
struct SmartEvent::@30::@40 friendlyCC
struct SmartEvent::@30::@62 goStateChanged
uint32 creature
Definition SmartScriptMgr.h:227
uint32 phasemask
Definition SmartScriptMgr.h:409

References SmartEvent::action, SmartScriptHolder::active, SmartEvent::Any, SmartEvent::area, SmartEvent::areatrigger, SmartEvent::aura, SmartEvent::charm, SmartEvent::cooldownMax, SmartEvent::cooldownMin, SmartEvent::count, SmartEvent::counter, SmartEvent::creature, SmartEvent::creatureEntry, CURRENT_GENERIC_SPELL, SmartEvent::dataSet, SmartEvent::dist, SmartEvent::distance, SmartEvent::doAction, DoFindFriendlyCC(), DoFindFriendlyMissingBuff(), DoSelectLowestHpFriendly(), DoSelectLowestHpPercentFriendly(), SmartEvent::emote, SmartEvent::entry, SmartScriptHolder::event, SmartEvent::event_flags, SmartEvent::event_phase_mask, SmartEvent::eventId, SmartEvent::eventInform, SmartEvent::eventPhaseChange, SmartEvent::filter, FindCreatureNear(), FindGameObjectNear(), SmartEvent::friendlyCC, SmartEvent::friendlyHealth, SmartEvent::friendlyHealthPct, SmartEvent::gameEvent, SmartEvent::gameEventId, Unit::GetAuraCount(), GetBaseObject(), GetCounterValue(), WorldObject::GetCreatureListWithEntryInGrid(), Unit::GetCurrentSpell(), Object::GetEntry(), SmartScriptHolder::GetEventType(), WorldObject::GetGameObjectListWithEntryInGrid(), Unit::GetHealthPct(), Unit::GetMaxHealth(), Unit::GetMaxPower(), GetPathId(), Unit::GetPowerPct(), GetTargets(), SmartScriptHolder::GetTargetType(), 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_ESCORT_ENDED, SMART_EVENT_ESCORT_PAUSED, SMART_EVENT_ESCORT_REACHED, SMART_EVENT_ESCORT_RESUMED, SMART_EVENT_ESCORT_START, SMART_EVENT_ESCORT_STOPPED, SMART_EVENT_EVADE, SMART_EVENT_EVENT_PHASE_CHANGE, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_FLAG_WHILE_CHARMED, SMART_EVENT_FOLLOW_COMPLETED, SMART_EVENT_FRIENDLY_HEALTH, SMART_EVENT_FRIENDLY_HEALTH_PCT, SMART_EVENT_FRIENDLY_IS_CC, SMART_EVENT_FRIENDLY_MISSING_BUFF, SMART_EVENT_GAME_EVENT_END, SMART_EVENT_GAME_EVENT_START, SMART_EVENT_GO_EVENT_INFORM, SMART_EVENT_GO_STATE_CHANGED, SMART_EVENT_GOSSIP_HELLO, SMART_EVENT_GOSSIP_SELECT, SMART_EVENT_HAS_AURA, SMART_EVENT_HEALTH_PCT, SMART_EVENT_IC_LOS, SMART_EVENT_INSTANCE_PLAYER_ENTER, SMART_EVENT_IS_BEHIND_TARGET, SMART_EVENT_IS_IN_MELEE_RANGE, SMART_EVENT_JUST_CREATED, SMART_EVENT_JUST_SUMMONED, SMART_EVENT_KILL, SMART_EVENT_LINK, SMART_EVENT_MANA_PCT, SMART_EVENT_MOVEMENTINFORM, SMART_EVENT_NEAR_PLAYERS, SMART_EVENT_NEAR_PLAYERS_NEGATION, SMART_EVENT_NEAR_UNIT, SMART_EVENT_NEAR_UNIT_NEGATION, SMART_EVENT_ON_SPELLCLICK, SMART_EVENT_OOC_LOS, SMART_EVENT_PASSENGER_BOARDED, SMART_EVENT_PASSENGER_REMOVED, SMART_EVENT_QUEST_ACCEPTED, SMART_EVENT_QUEST_COMPLETION, SMART_EVENT_QUEST_FAIL, SMART_EVENT_QUEST_OBJ_COMPLETION, SMART_EVENT_QUEST_REWARDED, SMART_EVENT_RANGE, SMART_EVENT_REACHED_HOME, SMART_EVENT_RECEIVE_EMOTE, SMART_EVENT_RECEIVE_HEAL, SMART_EVENT_RESET, SMART_EVENT_RESPAWN, SMART_EVENT_REWARD_QUEST, SMART_EVENT_SPELLHIT, SMART_EVENT_SPELLHIT_TARGET, SMART_EVENT_SUMMON_DESPAWNED, SMART_EVENT_SUMMONED_UNIT, SMART_EVENT_SUMMONED_UNIT_DIES, SMART_EVENT_SUMMONED_UNIT_EVADE, SMART_EVENT_TARGET_BUFFED, SMART_EVENT_TARGET_HEALTH_PCT, SMART_EVENT_TARGET_MANA_PCT, SMART_EVENT_TEXT_OVER, SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_EVENT_TRANSPORT_ADDCREATURE, SMART_EVENT_TRANSPORT_ADDPLAYER, SMART_EVENT_TRANSPORT_RELOCATE, SMART_EVENT_TRANSPORT_REMOVE_PLAYER, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_UPDATE_OOC, SMART_EVENT_VICTIM_CASTING, SMART_EVENT_WAYPOINT_ENDED, SMART_EVENT_WAYPOINT_REACHED, SMART_SCRIPT_RESPAWN_CONDITION_AREA, SMART_SCRIPT_RESPAWN_CONDITION_MAP, SMART_TARGET_ACTION_INVOKER, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_PLAYER_DISTANCE, SMART_TARGET_PLAYER_RANGE, SMART_TARGET_SELF, SmartEvent::spell, SmartEvent::spellHit, SmartEvent::spellId, SmartEvent::state, SmartEvent::summoned, SmartEvent::targetCasting, SmartEvent::team, SmartEvent::textGroupID, SmartEvent::textOver, SmartEvent::timedEvent, SmartEvent::timer, Object::ToUnit(), SmartEvent::transportAddCreature, SmartEvent::type, SmartEvent::value, SmartEvent::waypoint, and SmartEvent::wpData.

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

void SmartScript::ProcessEventsFor ( SMART_EVENT  e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
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:292
std::list< Condition * > ConditionList
Definition ConditionMgr.h:239
#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:4075
Definition ConditionMgr.h:184

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 
)
3357{
3358 // xinef: extended by selfs victim
3359 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3360 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3361
3362 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3363 {
3364 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3365 RecalcTimer(e, min, max);
3366 }
3367 else
3368 RecalcTimer(e, 5000, 5000);
3369}

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
5093{
5094 e.timer = 1200;
5095 // Change priority only if it's set to default, otherwise keep the current order of events
5097 {
5099 mEventSortingRequired = true;
5100 }
5101}
uint32 timer
Definition SmartScriptMgr.h:1997
uint32 priority
Definition SmartScriptMgr.h:1998

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
4891{
4892 // min/max was checked at loading!
4893 e.timer = urand(uint32(min), uint32(max));
4894 e.active = e.timer ? false : true;
4895}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5461{
5462 _summonList.erase(guid);
5463}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

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

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

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

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

Referenced by OnReset(), and ProcessAction().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
5104{
5105 RaisePriority(e);
5106
5107 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5108 if (ignoreChanceRoll)
5110
5111 e.runOnce = false;
5112}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5092

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
5434{
5435 uint32 oldPhase = mEventPhase;
5436
5437 mEventPhase = p;
5438
5439 if (oldPhase != mEventPhase)
5440 {
5442 }
5443}

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 
)
5339{
5340 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5341 // any SmartScriptHolder contained like the "e" parameter passed to this function
5343 {
5344 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());
5345 return;
5346 }
5347
5348 // 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
5350 {
5351 return;
5352 }
5353
5354 mTimedActionList.clear();
5356 if (mTimedActionList.empty())
5357 return;
5358 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5359 {
5360 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5361
5362 if (e.action.timedActionList.timerType == 0)
5363 i->event.type = SMART_EVENT_UPDATE_OOC;
5364 else if (e.action.timedActionList.timerType == 1)
5365 i->event.type = SMART_EVENT_UPDATE_IC;
5366 else if (e.action.timedActionList.timerType > 1)
5367 i->event.type = SMART_EVENT_UPDATE;
5368
5369 InitTimer((*i));
5370 }
5371}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1781
SAIBool allowOverride
Definition SmartScriptMgr.h:1150
uint32 timerType
Definition SmartScriptMgr.h:1149

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
5088{
5089 std::sort(events.begin(), events.end());
5090}
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:2015

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4898{
4899 if (e.GetEventType() == SMART_EVENT_LINK)
4900 return;
4901
4903 return;
4904
4905 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4906 return;
4907
4908 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4909 return;
4910
4911 if (e.timer < diff)
4912 {
4913 // delay spell cast for another AI tick if another spell is being cast
4915 {
4917 {
4919 {
4920 RaisePriority(e);
4921 return;
4922 }
4923 }
4924 }
4925
4926 // Delay flee for assist event if casting
4928 {
4929 e.timer = 1200;
4930 return;
4931 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
4932
4933 e.active = true;//activate events with cooldown
4934 switch (e.GetEventType())//process ONLY timed events
4935 {
4940 case SMART_EVENT_UPDATE:
4947 case SMART_EVENT_RANGE:
4961 {
4962 ASSERT(executionStack.empty());
4963 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
4964 while (!executionStack.empty())
4965 {
4966 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
4967 executionStack.pop_back();
4968 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
4969 }
4971 {
4972 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
4973 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4974 {
4975 //find the first event which is not the current one and enable it
4976 if (i->event_id > e.event_id)
4977 {
4978 i->enableTimed = true;
4979 break;
4980 }
4981 }
4982 }
4983 break;
4984 }
4985 }
4986
4988 {
4989 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
4990 if (e.timer > 1)
4991 {
4992 // Re-sort events if this was moved to the top of the queue
4993 mEventSortingRequired = true;
4994 // Reset priority to default one
4996 }
4997 }
4998 }
4999 else
5000 e.timer -= diff;
5001}
@ UNIT_STATE_CASTING
Definition UnitDefines.h:185
bool enableTimed
Definition SmartScriptMgr.h:2001

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: