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

#include "SmartScript.h"

Classes

struct  SmartScriptFrame
 

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ CounterMap

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

Constructor & Destructor Documentation

◆ SmartScript()

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

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

◆ ~SmartScript()

SmartScript::~SmartScript ( )
67{
68}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5500{
5501 _summonList.insert(guid);
5502}
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 
)
3449{
3450 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));
3451}
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:3453

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
5048{
5049 return e.active;
5050}

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
3454{
3455 SmartScriptHolder script;
3456 script.event.type = e;
3457 script.event.raw.param1 = event_param1;
3458 script.event.raw.param2 = event_param2;
3459 script.event.raw.param3 = event_param3;
3460 script.event.raw.param4 = event_param4;
3461 script.event.raw.param5 = event_param5;
3462 script.event.raw.param6 = event_param6;
3463 script.event.event_phase_mask = phaseMask;
3464 script.event.event_flags = event_flags;
3465 script.event.event_chance = 100;
3466
3467 script.action.type = action;
3468 script.action.raw.param1 = action_param1;
3469 script.action.raw.param2 = action_param2;
3470 script.action.raw.param3 = action_param3;
3471 script.action.raw.param4 = action_param4;
3472 script.action.raw.param5 = action_param5;
3473 script.action.raw.param6 = action_param6;
3474
3475 script.target.type = t;
3476 script.target.raw.param1 = target_param1;
3477 script.target.raw.param2 = target_param2;
3478 script.target.raw.param3 = target_param3;
3479 script.target.raw.param4 = target_param4;
3480
3482 InitTimer(script);
3483 return script;
3484}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4901
uint32 param3
Definition SmartScriptMgr.h:1062
uint32 param5
Definition SmartScriptMgr.h:1064
uint32 param1
Definition SmartScriptMgr.h:1060
SMART_ACTION type
Definition SmartScriptMgr.h:746
struct SmartAction::@75::@195 raw
uint32 param4
Definition SmartScriptMgr.h:1063
uint32 param6
Definition SmartScriptMgr.h:1503
uint32 param2
Definition SmartScriptMgr.h:1061
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:1989
SmartAction action
Definition SmartScriptMgr.h:2000
SmartScriptType source_type
Definition SmartScriptMgr.h:1995
SmartEvent event
Definition SmartScriptMgr.h:1999
SmartTarget target
Definition SmartScriptMgr.h:2001
uint32 param4
Definition SmartScriptMgr.h:1754
uint32 param1
Definition SmartScriptMgr.h:1751
uint32 param3
Definition SmartScriptMgr.h:1753
struct SmartTarget::@200::@224 raw
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1603
uint32 param2
Definition SmartScriptMgr.h:1752

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
5466{
5467 if (p >= mEventPhase)
5468 {
5469 SetPhase(0);
5470 }
5471 else
5472 {
5473 SetPhase(mEventPhase - p);
5474 }
5475}
void SetPhase(uint32 p)
Definition SmartScript.cpp:5477

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5371{
5372 if (!me)
5373 return nullptr;
5374
5375 Unit* unit = nullptr;
5376 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5378 Cell::VisitObjects(me, searcher, range);
5379 return unit;
5380}
Definition Unit.h:664
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
5351{
5352 if (!me)
5353 return;
5354
5355 Acore::FriendlyCCedInRange u_check(me, range);
5357 Cell::VisitObjects(me, searcher, range);
5358}
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
5361{
5362 if (!me)
5363 return;
5364
5365 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5367 Cell::VisitObjects(me, searcher, range);
5368}
Definition GridNotifiers.h:827

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5324{
5325 if (!me)
5326 return nullptr;
5327
5328 Unit* unit = nullptr;
5329
5330 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5332 Cell::VisitObjects(me, searcher, range);
5333 return unit;
5334}
Definition GridNotifiers.h:766

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5337{
5338 if (!me)
5339 {
5340 return nullptr;
5341 }
5342
5343 Unit* unit = nullptr;
5344 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5346 Cell::VisitObjects(me, searcher, range);
5347 return unit;
5348}
Definition GridNotifiers.h:785

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5159{
5160 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5161
5162 if (e.empty())
5163 {
5164 if (obj)
5165 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5166
5167 if (at)
5168 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5169 return;
5170 }
5171 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5172 {
5173#ifndef ACORE_DEBUG
5174 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5175 continue;
5176#endif
5177
5178 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5179 {
5180 if (obj && obj->GetMap()->IsDungeon())
5181 {
5182 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5183 {
5184 mEvents.push_back((*i));
5185 }
5186 }
5187 continue;
5188 }
5189 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5190 }
5191}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition SmartScriptMgr.h:1955
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition SmartScriptMgr.h:1951
bool IsDungeon() const
Definition Map.h:295
uint8 GetSpawnMode() const
Definition Map.h:267
uint32 GetEntry() const
Definition Object.h:117
SmartAIEventList mEvents
Definition SmartScript.h:222
Map * GetMap() const
Definition Object.h:625

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

Referenced by GetScript().

◆ FindCreatureNear()

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

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

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

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

References mEvents.

Referenced by ProcessAction().

◆ GetBaseObject()

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

References go, and me.

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

◆ GetCounterValue()

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

References mCounterList.

Referenced by ProcessEvent().

◆ GetEvents()

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

References mEvents.

Referenced by SmartAI::InitializeAI().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5418{
5419 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5420 if (GetBaseObject())
5422 // xinef: used for area triggers invoker cast
5423 else if (invoker)
5425 return nullptr;
5426}
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 ( )
5194{
5196 if (me)
5197 {
5198 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5199 if (e.empty())
5200 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5201
5202 FillScript(e, me, nullptr);
5203
5204 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5205 {
5206 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5207 {
5208 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5209 FillScript(e, me, nullptr);
5210 }
5211 }
5212 }
5213 else if (go)
5214 {
5215 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5216 if (e.empty())
5217 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5218 FillScript(e, go, nullptr);
5219 }
5220 else if (trigger)
5221 {
5222 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5223 FillScript(e, nullptr, trigger);
5224 }
5225}
@ CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI
Definition CreatureData.h:73
std::int32_t int32
Definition Define.h:103
std::vector< SmartScriptHolder > SmartAIEventList
Definition SmartScriptMgr.h:2086
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2262
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:206
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition SmartScript.cpp:5158
uint32 entry
Definition ObjectMgr.h:422
Definition CreatureData.h:187

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

Referenced by OnInitialize().

◆ GetStoredTargetVector()

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

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3487{
3488 WorldObject* scriptTrigger = nullptr;
3489 if (invoker)
3490 scriptTrigger = invoker;
3491 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3492 scriptTrigger = tempLastInvoker;
3493
3494 WorldObject* baseObject = GetBaseObject();
3495
3496 switch (e.GetTargetType())
3497 {
3498 case SMART_TARGET_SELF:
3499 if (baseObject)
3500 targets.push_back(baseObject);
3501 break;
3503 if (me)
3504 if (Unit* victim = me->GetVictim())
3505 targets.push_back(victim);
3506 break;
3508 if (me)
3509 {
3510 if (e.target.hostileRandom.powerType)
3511 {
3512 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)))
3513 targets.push_back(u);
3514 }
3515 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3516 targets.push_back(u);
3517 }
3518 break;
3520 if (me)
3521 {
3522 if (e.target.hostileRandom.powerType)
3523 {
3524 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)))
3525 targets.push_back(u);
3526 }
3527 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3528 targets.push_back(u);
3529 }
3530 break;
3532 if (me)
3533 {
3534 if (e.target.hostileRandom.powerType)
3535 {
3536 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)))
3537 targets.push_back(u);
3538 }
3539 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3540 targets.push_back(u);
3541 }
3542 break;
3544 if (me)
3545 {
3546 if (e.target.hostileRandom.powerType)
3547 {
3548 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)))
3549 targets.push_back(u);
3550 }
3551 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3552 targets.push_back(u);
3553 }
3554 break;
3556 if (me)
3557 {
3558 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)))
3559 targets.push_back(u);
3560 }
3561 break;
3563 if (scriptTrigger)
3564 targets.push_back(scriptTrigger);
3565 break;
3567 if (scriptTrigger && IsUnit(scriptTrigger))
3568 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3569 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3570 break;
3572 if (scriptTrigger)
3573 {
3574 if (Player* player = scriptTrigger->ToPlayer())
3575 {
3576 if (Group* group = player->GetGroup())
3577 {
3578 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3579 if (Player* member = groupRef->GetSource())
3580 {
3581 if (member->IsInMap(player))
3582 targets.push_back(member);
3583
3584 if (e.target.invokerParty.includePets)
3585 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3586 if (pet->IsPet() && pet->IsInMap(player))
3587 targets.push_back(pet);
3588 }
3589 }
3590 // We still add the player to the list if there is no group. If we do
3591 // this even if there is a group (thus the else-check), it will add the
3592 // same player to the list twice. We don't want that to happen.
3593 else
3594 targets.push_back(scriptTrigger);
3595 }
3596 }
3597 break;
3599 {
3600 WorldObject* ref = baseObject;
3601 if (!ref)
3602 ref = scriptTrigger;
3603
3604 if (!ref)
3605 {
3606 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3607 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3608 break;
3609 }
3610
3611 ObjectVector units;
3612 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3613
3614 for (WorldObject* unit : units)
3615 {
3616 if (!IsCreature(unit))
3617 continue;
3618
3619 if (me && me->GetGUID() == unit->GetGUID())
3620 continue;
3621
3622 // check alive state - 1 alive, 2 dead, 0 both
3623 if (uint32 state = e.target.unitRange.livingState)
3624 {
3625 if (unit->ToCreature()->IsAlive() && state == 2)
3626 continue;
3627 if (!unit->ToCreature()->IsAlive() && state == 1)
3628 continue;
3629 }
3630
3631 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))
3632 targets.push_back(unit);
3633 }
3634
3635 break;
3636 }
3638 {
3639 ObjectVector units;
3640 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3641
3642 for (WorldObject* unit : units)
3643 {
3644 if (!IsCreature(unit))
3645 continue;
3646
3647 if (me && me->GetGUID() == unit->GetGUID())
3648 continue;
3649
3650 // check alive state - 1 alive, 2 dead, 0 both
3651 if (uint32 state = e.target.unitDistance.livingState)
3652 {
3653 if (unit->ToCreature()->IsAlive() && state == 2)
3654 continue;
3655 if (!unit->ToCreature()->IsAlive() && state == 1)
3656 continue;
3657 }
3658
3659 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3660 targets.push_back(unit);
3661 }
3662
3663 break;
3664 }
3666 {
3667 ObjectVector units;
3668 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3669
3670 for (WorldObject* unit : units)
3671 {
3672 if (!IsGameObject(unit))
3673 continue;
3674
3675 if (go && go->GetGUID() == unit->GetGUID())
3676 continue;
3677
3678 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3679 targets.push_back(unit);
3680 }
3681
3682 break;
3683 }
3685 {
3686
3687 WorldObject* ref = baseObject;
3688 if (!ref)
3689 ref = scriptTrigger;
3690
3691 if (!ref)
3692 {
3693 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3694 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3695 break;
3696 }
3697
3698 ObjectVector units;
3699 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3700
3701 for (WorldObject* unit : units)
3702 {
3703 if (!IsGameObject(unit))
3704 continue;
3705
3706 if (go && go->GetGUID() == unit->GetGUID())
3707 continue;
3708
3709 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))
3710 targets.push_back(unit);
3711 }
3712
3713 break;
3714 }
3716 {
3717 if (!scriptTrigger && !baseObject)
3718 {
3719 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3720 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3721 break;
3722 }
3723
3724 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3725 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3726 targets.push_back(target);
3727 break;
3728 }
3730 {
3731 if (!scriptTrigger && !GetBaseObject())
3732 {
3733 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3734 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3735 break;
3736 }
3737
3738 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3739 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3740 targets.push_back(target);
3741 break;
3742 }
3744 {
3745 ObjectVector units;
3746 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3747
3748 if (!units.empty() && baseObject)
3749 for (WorldObject* unit : units)
3750 if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3751 targets.push_back(unit);
3752
3753 if (e.target.playerRange.maxCount)
3754 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3755
3756 break;
3757 }
3759 {
3760 ObjectVector units;
3761 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3762
3763 for (WorldObject* unit : units)
3764 if (IsPlayer(unit))
3765 targets.push_back(unit);
3766 break;
3767 }
3769 {
3770 WorldObject* ref = baseObject;
3771 if (!ref)
3772 ref = scriptTrigger;
3773
3774 if (!ref)
3775 {
3776 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3777 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3778 break;
3779 }
3780
3781 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3782 targets.assign(stored->begin(), stored->end());
3783 break;
3784 }
3786 {
3787 WorldObject* ref = baseObject;
3788
3789 if (!ref)
3790 ref = scriptTrigger;
3791
3792 if (!ref)
3793 {
3794 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3795 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3796 break;
3797 }
3798
3799 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3800 if (target)
3801 targets.push_back(target);
3802 break;
3803 }
3805 {
3806 WorldObject* ref = baseObject;
3807
3808 if (!ref)
3809 ref = scriptTrigger;
3810
3811 if (!ref)
3812 {
3813 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3814 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3815 break;
3816 }
3817
3818 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3819 if (target)
3820 targets.push_back(target);
3821 break;
3822 }
3824 {
3825 WorldObject* ref = baseObject;
3826
3827 if (!ref)
3828 ref = scriptTrigger;
3829
3830 if (!ref)
3831 {
3832 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3833 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3834 break;
3835 }
3836
3837 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3838 targets.push_back(target);
3839 break;
3840 }
3842 /*
3843 * Owners/Summoners should be WorldObjects. This allows to have other objects
3844 * such as gameobjects to execute SmartScripts using this type of target.
3845 * Otherwise, only Units like creatures can summon other creatures.
3846 */
3847 {
3848 if (me)
3849 {
3851 {
3852 targets.push_back(owner);
3853 }
3854 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3855 {
3856 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3857 }
3858 }
3859 else if (go)
3860 {
3862 {
3863 targets.push_back(owner);
3864 }
3865 }
3866
3867 // xinef: Get owner of owner
3868 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3869 {
3870 if (WorldObject* owner = targets.front())
3871 {
3872 targets.clear();
3873
3874 if (IsCreature(owner))
3875 {
3876 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3877 targets.push_back(base);
3878 }
3879 else if (IsGameObject(owner))
3880 {
3881 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3882 targets.push_back(base);
3883 }
3884 else if (IsPlayer(owner))
3885 {
3886 if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
3887 targets.push_back(base);
3888 }
3889 }
3890 }
3891 break;
3892 }
3894 {
3895 if (me)
3896 {
3897 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
3898 if (Unit* temp = ref->GetVictim())
3899 // Xinef: added distance check
3900 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3901 targets.push_back(temp);
3902 }
3903 break;
3904 }
3906 {
3907 if (me)
3908 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3909 targets.push_back(target);
3910
3911 break;
3912 }
3914 {
3915 if (me)
3916 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3917 targets.push_back(target);
3918
3919 break;
3920 }
3922 {
3923 ObjectVector units;
3924 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3925
3926 for (WorldObject* unit : units)
3927 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3928 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3929 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3930 targets.push_back(unit);
3931
3932 if (e.target.o > 0)
3933 Acore::Containers::RandomResize(targets, e.target.o);
3934
3935 break;
3936 }
3938 {
3939 ObjectVector units;
3940 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3941 // 1 = Tanks, 2 = Healer, 4 = Damage
3942 uint32 roleMask = e.target.roleSelection.roleMask;
3943 for (WorldObject* unit : units)
3944 if (Player* targetPlayer = unit->ToPlayer())
3945 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3946 {
3947 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3948 {
3949 if (targetPlayer->HasTankSpec())
3950 {
3951 targets.push_back(unit);
3952 continue;
3953 }
3954 }
3955 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3956 {
3957 if (targetPlayer->HasHealSpec())
3958 {
3959 targets.push_back(unit);
3960 continue;
3961 }
3962 }
3963 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3964 {
3965 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3966 {
3967 targets.push_back(unit);
3968 continue;
3969 }
3970 }
3971 }
3972
3973 if (e.target.roleSelection.resize > 0)
3974 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
3975
3976 break;
3977 }
3979 {
3980 if (me && me->IsVehicle())
3981 {
3982 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
3983 {
3984 targets.push_back(target);
3985 }
3986 }
3987 break;
3988 }
3990 {
3991 if (me)
3992 {
3993 if (Group* lootGroup = me->GetLootRecipientGroup())
3994 {
3995 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
3996 {
3997 if (Player* recipient = it->GetSource())
3998 {
3999 targets.push_back(recipient);
4000 }
4001 }
4002 }
4003 else
4004 {
4005 if (Player* recipient = me->GetLootRecipient())
4006 {
4007 targets.push_back(recipient);
4008 }
4009 }
4010 }
4011 break;
4012 }
4014 {
4015 if (me)
4016 {
4017 for (ObjectGuid const& guid : _summonList)
4018 {
4019 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
4020 {
4021 if (Creature* creature = me->GetMap()->GetCreature(guid))
4022 {
4023 targets.push_back(creature);
4024 }
4025 }
4026 }
4027 }
4028 break;
4029 }
4031 {
4032 InstanceScript* instance = nullptr;
4033
4034 if (e.IsAreatriggerScript() && scriptTrigger)
4035 instance = scriptTrigger->GetInstanceScript();
4036 else
4037 instance = GetBaseObject()->GetInstanceScript();
4038
4039 if (!instance)
4040 {
4041 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4042 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4043 return;
4044 }
4045
4046 if (e.target.instanceStorage.type == 1)
4047 {
4048 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
4049 targets.push_back(creature);
4050 }
4051 else if (e.target.instanceStorage.type == 2)
4052 {
4053 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4054 targets.push_back(go);
4055 }
4056
4057 break;
4058 }
4060 {
4061 if (me)
4062 {
4063 if (CreatureGroup* group = me->GetFormation())
4064 {
4065 uint32 formationType = e.target.formation.type;
4066 uint32 entry = e.target.formation.entry;
4067 bool excludeSelf = e.target.formation.excludeSelf;
4068
4069 if (formationType == 1) // Leader only
4070 {
4071 if (Creature* leader = group->GetLeader())
4072 {
4073 if ((!excludeSelf || leader != me) && (!entry || leader->GetEntry() == entry))
4074 targets.push_back(leader);
4075 }
4076 }
4077 else // 0 = Members only, 2 = All
4078 {
4079 for (auto const& itr : group->GetMembers())
4080 {
4081 Creature* member = itr.first;
4082
4083 if (!member)
4084 continue;
4085
4086 if (excludeSelf && member == me)
4087 continue;
4088
4089 if (entry && member->GetEntry() != entry)
4090 continue;
4091
4092 if (formationType == 0 && member == group->GetLeader())
4093 continue;
4094
4095 targets.push_back(member);
4096 }
4097 }
4098 }
4099 }
4100 break;
4101 }
4102 case SMART_TARGET_NONE:
4104 default:
4105 break;
4106 }
4107}
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:933
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition ScriptedCreature.cpp:938
Powers
Definition SharedDefines.h:256
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition SmartScriptMgr.h:1780
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1779
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1781
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1569
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1561
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1548
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1558
@ SMART_TARGET_FORMATION
Definition SmartScriptMgr.h:1584
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1568
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1562
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1571
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1559
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1582
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1544
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1557
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1563
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1547
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1545
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1565
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1543
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1579
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1581
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1549
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1546
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1564
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1583
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1570
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1566
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1567
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1542
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1560
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1554
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2026
Definition CreatureGroups.h:90
Definition Creature.h:47
CreatureGroup const * GetFormation() const
Definition Creature.h:370
Player * GetLootRecipient() const
Definition Creature.cpp:1268
Group * GetLootRecipientGroup() const
Definition Creature.cpp:1275
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition Creature.cpp:2354
CreatureAI * AI() const
Definition Creature.h:143
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:2336
Definition ObjectGuid.h:118
Player * ToPlayer()
Definition Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Unit * ToUnit()
Definition Object.h:210
Definition Player.h:1084
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5428
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5433
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5438
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5417
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4109
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5454
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5370
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:142
Unit * GetSummonerUnit() const
Definition TemporarySummon.cpp:44
Definition ThreatManager.h:267
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:111
bool IsVehicle() const
Definition Unit.h:800
Vehicle * GetVehicle() const
Definition Unit.h:1926
TempSummon * ToTempSummon()
Definition Unit.h:731
Unit * GetCharmerOrOwner() const
Definition Unit.h:1286
bool IsSummon() const
Definition Unit.h:794
Unit * GetVictim() const
Definition Unit.h:903
Vehicle * GetVehicleKit() const
Definition Unit.h:1925
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1295
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:229
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1238
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2526
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1460
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:199
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition ObjectAccessor.cpp:234
Definition UnitAI.h:135
Definition UnitAI.h:170

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

Referenced by ProcessAction(), and ProcessEvent().

◆ GetWorldObjectsInDist()

void SmartScript::GetWorldObjectsInDist ( ObjectVector objects,
float  dist 
) const
4110{
4111 WorldObject* obj = GetBaseObject();
4112 if (!obj)
4113 return;
4114
4115 Acore::AllWorldObjectsInRange u_check(obj, dist);
4117 Cell::VisitObjects(obj, searcher, dist);
4118}
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
5460{
5461 // protect phase from overflowing
5462 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5463}
@ 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
4902{
4903 switch (e.GetEventType())
4904 {
4905 //set only events which have initial timers
4909 break;
4910 case SMART_EVENT_UPDATE:
4913 case SMART_EVENT_RANGE:
4920 break;
4924 break;
4928 break;
4929 default:
4930 e.active = true;
4931 break;
4932 }
4933}
@ 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:4934
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:2013
uint32 GetEventType() const
Definition SmartScriptMgr.h:2005

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
5053{
5054 if (!mInstallEvents.empty())
5055 {
5056 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
5057 mEvents.push_back(*i);//must be before UpdateTimers
5058
5059 mInstallEvents.clear();
5060 }
5061}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3375{
3376 if (!GetBaseObject())
3377 return;
3379 {
3380 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3381 return;
3382 }
3383 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3384 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3385 {
3387 {
3388 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);
3389 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);
3390 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);
3391 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);
3392 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);
3393 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);
3394 break;
3395 }
3397 {
3398 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);
3399 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);
3400 break;
3401 }
3403 {
3404 if (!me)
3405 return;
3406 //store cage as id1
3407 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);
3408
3409 //reset(close) cage on hostage(me) respawn
3410 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);
3411
3412 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);
3413 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);
3414
3415 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);
3416 //phase 1: give quest credit on movepoint reached
3418 //phase 1: despawn after time on movepoint reached
3419 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);
3420
3421 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3422 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);
3423 break;
3424 }
3426 {
3427 if (!go)
3428 return;
3429 //store hostage as id1
3430 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);
3431 //store invoker as id2
3432 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);
3433 //signal hostage
3434 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);
3435 //when hostage raeched end point, give credit to invoker
3436 if (e.action.installTtemplate.param2)
3437 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);
3438 else
3439 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);
3440 break;
3441 }
3443 default:
3444 return;
3445 }
3446}
#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:1530
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1535
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1536
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1532
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1533
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1944
@ 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:3448

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
5444{
5445 if (!obj)
5446 return false;
5447
5448 if (Creature* creatureObj = obj->ToCreature())
5449 return creatureObj->IsCharmed();
5450
5451 return false;
5452}
Creature * ToCreature()
Definition Object.h:206

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5439{
5440 return obj && obj->IsCreature();
5441}
bool IsCreature() const
Definition Object.h:205

References Object::IsCreature().

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5455{
5456 return obj && obj->IsGameObject();
5457}
bool IsGameObject() const
Definition Object.h:213

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5490{
5491 if (mEventPhase == 0)
5492 {
5493 return false;
5494 }
5495
5496 return ((1 << (mEventPhase - 1)) & p) != 0;
5497}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5434{
5435 return obj && obj->IsPlayer();
5436}
bool IsPlayer() const
Definition Object.h:201

References Object::IsPlayer().

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

◆ IsSmart() [1/3]

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

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

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

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

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

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

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5429{
5430 return obj && (obj->IsCreature() || obj->IsPlayer());
5431}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5228{
5229 if (obj)//handle object based scripts
5230 {
5231 switch (obj->GetTypeId())
5232 {
5233 case TYPEID_UNIT:
5235 me = obj->ToCreature();
5236 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5237 break;
5238 case TYPEID_GAMEOBJECT:
5240 go = obj->ToGameObject();
5241 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5242 break;
5243 default:
5244 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5245 return;
5246 }
5247 }
5248 else if (at)
5249 {
5251 trigger = at;
5252 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5253 }
5254 else
5255 {
5256 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5257 return;
5258 }
5259
5260 GetScript();//load copy of script
5261
5262 for (SmartScriptHolder& event : mEvents)
5263 InitTimer(event);//calculate timers for first time use
5264
5266 InstallEvents();
5268}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1787
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1788
@ SMART_EVENT_AI_INIT
Definition SmartScriptMgr.h:136
TypeID GetTypeId() const
Definition Object.h:129
GameObject * ToGameObject()
Definition Object.h:214
void ProcessEventsFor(SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:136
void InstallEvents()
Definition SmartScript.cpp:5052
void GetScript()
Definition SmartScript.cpp:5193

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)
5271{
5272 if (!me)
5273 return;
5274
5276}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:125
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:109
bool IsEngaged() const override
Definition Creature.cpp:2858

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

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

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)
5064{
5066 return;
5067
5068 InstallEvents();//before UpdateTimers
5069
5071 {
5073 mEventSortingRequired = false;
5074 }
5075
5076 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
5077 UpdateTimer(*i, diff);
5078
5079 if (!mStoredEvents.empty())
5080 {
5081 SmartAIEventStoredList::iterator i, icurr;
5082 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
5083 {
5084 icurr = i++;
5085 UpdateTimer(*icurr, diff);
5086 }
5087 }
5088
5089 bool needCleanup = true;
5090 if (!mTimedActionList.empty())
5091 {
5093 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5094 {
5095 if ((*i).enableTimed)
5096 {
5097 UpdateTimer(*i, diff);
5098 needCleanup = false;
5099 }
5100 }
5101
5103 }
5104 if (needCleanup)
5105 mTimedActionList.clear();
5106
5107 if (!mRemIDs.empty())
5108 {
5109 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5111
5112 // xinef: clear list after cleaning...
5113 mRemIDs.clear();
5114 }
5115 if (mUseTextTimer && me)
5116 {
5117 if (mTextTimer < diff)
5118 {
5119 uint32 textID = mLastTextID;
5120 mLastTextID = 0;
5121 uint32 entry = mTalkerEntry;
5122 mTalkerEntry = 0;
5123 mTextTimer = 0;
5124 mUseTextTimer = false;
5125 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5126 }
5127 else mTextTimer -= diff;
5128 }
5129}
@ SMART_EVENT_TEXT_OVER
Definition SmartScriptMgr.h:151
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition SmartScript.cpp:4941
void SortEvents(SmartAIEventList &events)
Definition SmartScript.cpp:5131
SmartAIEventStoredList mStoredEvents
Definition SmartScript.h:236
std::list< uint32 > mRemIDs
Definition SmartScript.h:237
SmartAIEventList mTimedActionList
Definition SmartScript.h:224
void RemoveStoredEvent(uint32 id)
Definition SmartScript.h:254

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

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

◆ ProcessAction()

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

References SmartAction::a, SmartScriptHolder::action, SmartAction::actionId, SmartAction::actionLists, SmartAction::activateObject, EventProcessor::AddEventAtOffset(), WorldObject::AddObjectToRemoveList(), CustomSpellValues::AddSpellMod(), ThreatManager::AddThreat(), Creature::AI(), GameObject::AI(), SmartAction::aliveState, SmartAction::alternative, SmartTarget::amount, SmartAction::angle, SmartAction::anim, SmartAction::animTier, SmartAction::attack, SmartAction::attackInvoker, SmartAction::attackScriptOwner, UnitAI::AttackStart(), AURA_REMOVE_BY_EXPIRE, SmartAction::autoAttack, MapRefMgr::begin(), SmartAction::bp1, SmartAction::bp2, SmartAction::bp3, BROADCAST_TEXT_CALL_FOR_HELP, BROADCAST_TEXT_FLEE_FOR_ASSIST, SmartAction::byte1, SpellInfo::CalcPowerCost(), SmartAction::callHelp, Unit::CanHaveThreatList(), SmartAction::cast, CAST_AI, SmartAction::castCustom, Unit::CastCustomSpell(), SmartAction::castFlags, Unit::CastSpell(), GameObject::CastSpell(), SmartAction::chance, SmartAction::charges, CHAT_MSG_ADDON, CHAT_MSG_MONSTER_EMOTE, ObjectMgr::ChooseDisplayId(), SmartAction::cinematic, ClearGossipMenuFor(), SmartAction::combatDistance, SmartAction::combatMove, SmartAction::combatReach, Unit::CombatStop(), SmartAction::coneAngle, SmartAction::coneLength, SmartAction::coneSummon, SmartAction::ContactDistance, SmartAction::controlled, SmartAction::corpseDelay, SmartAction::count, SmartAction::counterId, CreateSmartEvent(), SmartAction::creature, CreatureModel::CreatureDisplayID, SmartAction::creatureGroup, SmartAction::credit, SmartAction::creditType, SmartAction::crossCast, SmartAction::data, SmartAction::dec, DecPhase(), DEFAULT_LOCALE, SmartAction::delay, SmartAction::delunitByte, GameObject::DespawnOrUnsummon(), SmartAction::despawnTime, SmartAction::die, SmartAction::directAdd, SmartAction::disable, SmartAction::disableEvade, SmartAction::disableForceDestination, SmartAction::disableGravity, CreatureModel::DisplayScale, SmartAction::dist, SmartAction::distance, SmartAction::distanceBetweenRings, SmartAction::distanceBetweenSummons, SmartAction::doAction, InstanceScript::DoAction(), Creature::DoFleeToGetAssistance(), SmartAction::dontDespawn, SmartAction::duration, SmartAction::emote, SmartAction::emotes, ObjectGuid::Empty, MapRefMgr::end(), Unit::EngageWithTarget(), ENSURE_AI, SmartAction::entry, SmartScriptHolder::entryOrGuid, SmartAction::equip, SmartScriptHolder::event, SmartEvent::event_chance, SmartEvent::event_flags, SmartScriptHolder::event_id, SmartAction::eventId, executionStack, SmartAction::faction, SmartAction::factionID, SmartAction::fail, SmartAction::field, FindLinkedEvent(), WorldObject::FindMap(), SmartAction::flag, SmartAction::flags, SmartAction::flee, SmartAction::fly, SmartAction::follow, FOLLOW_TYPE_ANGULAR, FOLLOW_TYPE_CIRCLE, FOLLOW_TYPE_COLUMN, FOLLOW_TYPE_LINE, FOLLOW_TYPE_SEMI_CIRCLE_BEHIND, FOLLOW_TYPE_SEMI_CIRCLE_FRONT, SmartAction::followGroup, SmartAction::followState, SmartAction::followType, SmartAction::force, FORCED_MOVEMENT_NONE, SmartAction::forceDespawn, SmartAction::forcedMovement, SmartAction::forceRespawnTimer, frand(), SmartAction::gameEventStart, SmartAction::gameEventStop, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_DOOR, SmartAction::gameobjectGroup, SmartScriptHolder::GetActionType(), Position::GetAngle(), WorldObject::GetAreaId(), GetBaseObject(), InstanceScript::GetBossStateName(), Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), WorldObject::GetClosePoint(), WorldObject::GetCombatReach(), Unit::GetDirectTransport(), WorldObject::GetDistance(), Object::GetEntry(), SmartScriptHolder::GetEventType(), Unit::getGender(), GameObject::GetGoType(), Object::GetGUID(), Creature::GetHomePosition(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), WorldObject::GetMap(), Unit::GetMeleeRange(), ThreatManager::GetModifiableThreatList(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldObject::GetNearPoint(), WorldObject::GetObjectSize(), Position::GetOrientation(), ObjectAccessor::GetPlayer(), Map::GetPlayers(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetPower(), Unit::GetPowerPct(), WorldObject::GetRandomPoint(), Creature::GetRespawnPosition(), SpellInfo::GetSchoolMask(), SmartScriptHolder::GetScriptType(), Unit::GetSpeed(), Unit::GetSpellMaxRangeForTarget(), Unit::GetSpellMinRangeForTarget(), GetStoredTargetVector(), GetTargets(), SmartScriptHolder::GetTargetType(), ThreatManager::GetThreatListSize(), Unit::GetThreatMgr(), Unit::GetTransGUID(), Creature::GetTransportHomePosition(), Unit::GetVehicleKit(), GetWorldObjectsInDist(), WorldObject::GetZoneId(), go, GO_READY, SmartAction::goFlag, goOrigGUID, SmartAction::goRespawnTime, SmartAction::gossipMenuId, SmartAction::gossipNpcTextId, SmartAction::goState, SmartAction::group, Player::GroupEventHappens(), 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, ThreatManager::ModifyThreatByPercent(), SmartAction::morphOrMount, MOTION_SLOT_ACTIVE, MOTION_SLOT_CONTROLLED, SmartAction::move, MOVE_RUN, MotionMaster::MoveIdle(), MotionMaster::MoveJump(), SmartAction::movementExpired, SmartAction::movementFlag, MOVEMENTFLAG_ONTRANSPORT, SmartAction::movementSpeed, SmartAction::movementType, MotionMaster::MovePoint(), SmartAction::moveRandom, MotionMaster::MoveRandom(), SmartAction::moveToPos, SmartAction::moveToPosTarget, SmartAction::movie, mRemIDs, mStoredEvents, mTalkerEntry, mTextTimer, mUseTextTimer, SmartAction::music, SmartAction::newPower, WaypointPath::Nodes, NOMINAL_MELEE_RANGE, SmartTarget::o, SmartAction::onlySelf, OnReset(), SmartAction::orientation, SmartAction::orientationTarget, SmartAction::param, SmartAction::pathID, SmartAction::pathId, SmartAction::pathId1, SmartAction::pathId2, SmartAction::pathSource, SmartAction::percent, PersonalSpawn, SmartAction::phase, SmartAction::phaseMax, SmartAction::phaseMin, SmartAction::phases, SmartAction::phi_delta, SmartAction::playerTalk, SmartAction::pointId, SmartAction::power, POWER_MANA, SmartAction::powerType, PreferUnit, ProcessEventsFor(), SmartAction::quest, SmartAction::questID, SmartAction::questOffer, SmartAction::quickChange, SmartAction::r_max, SmartAction::radialSummon, SmartAction::random, SmartAction::randomEmote, SmartAction::randomMusic, SmartAction::randomPhase, SmartAction::randomPhaseRange, SmartTarget::randomPoint, Acore::Containers::RandomResize(), SmartAction::randomSound, SmartAction::randomTimedEvent, SmartAction::randTimedActionList, SmartAction::range, SmartTarget::range, SmartAction::react, SmartAction::reactState, SmartAction::regenHealth, Position::RelocatePolarOffset(), SmartAction::removeAura, Unit::RemoveAurasDueToSpell(), SmartAction::removeObjectFromWorld, SmartAction::repeat, SmartEvent::repeatMax, SmartAction::repeatMax, SmartEvent::repeatMin, SmartAction::repeatMin, SmartAction::repetitions, SmartAction::reputation, SmartAction::reset, ResetBaseObject(), SmartAction::respawnDelay, SmartAction::RespawnTarget, RetryLater(), SmartAction::reward, Player::RewardPlayerAndGroupAtEvent(), SmartAction::root, SmartAction::run, SmartScriptHolder::runOnce, SmartAction::scale, sCreatureTextMgr, SmartAction::scriptSpawn, Acore::Containers::SelectRandomContainerElement(), SmartTarget::self, SmartAction::selfJump, SmartAction::sendGoCustomAnim, SmartAction::sendGossipMenu, SendGossipMenuFor(), Unit::SendPlaySpellVisual(), PlayerMenu::SendQuestGiverQuestDetails(), SmartAction::sendTargetToTarget, Creature::SendZoneUnderAttackMessage(), SmartAction::setActive, InstanceScript::SetBossState(), SmartAction::setCounter, GameObjectAI::SetData(), UnitAI::SetData(), SmartAction::setData, ZoneScript::SetData(), Unit::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, SmartAction::setGoLootState, SmartAction::setGossipMenu, SmartAction::setGuid, ZoneScript::SetGuidData(), SmartAction::setHealthPct, SmartAction::setHealthRegen, SmartAction::setHomePos, Creature::SetHomePosition(), SmartAction::setHover, Unit::SetInFront(), SmartAction::setInstanceData, SmartAction::setInstanceData64, SmartAI::SetInvincibilityHpLevel(), GameObject::SetLootState(), Position::SetOrientation(), SetPhase(), SetPhaseReset(), SmartAction::setRangedMovement, Creature::SetReactState(), SmartAction::setRoot, SmartAction::setRun, SmartAction::setScale, SetScript9(), SmartAction::setSheath, Unit::SetSheath(), Unit::SetSpeed(), SmartAction::setSwim, SmartAction::setunitByte, sGameEventMgr, SmartAction::sheath, SmartAction::sightDistance, SmartAction::simpleTalk, SmartAction::slots, SMART_ACTION_ACTIVATE_GOBJECT, SMART_ACTION_ACTIVATE_TAXI, SMART_ACTION_ADD_AURA, SMART_ACTION_ADD_DYNAMIC_FLAG, SMART_ACTION_ADD_GO_FLAG, SMART_ACTION_ADD_IMMUNITY, SMART_ACTION_ADD_ITEM, SMART_ACTION_ADD_NPC_FLAG, SMART_ACTION_ADD_POWER, SMART_ACTION_ADD_THREAT, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, SMART_ACTION_ATTACK_START, SMART_ACTION_ATTACK_STOP, SMART_ACTION_AUTO_ATTACK, SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS, SMART_ACTION_CALL_FOR_HELP, SMART_ACTION_CALL_GROUPEVENTHAPPENS, SMART_ACTION_CALL_KILLEDMONSTER, SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST, SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST, SMART_ACTION_CALL_SCRIPT_RESET, SMART_ACTION_CALL_TIMED_ACTIONLIST, SMART_ACTION_CAST, SMART_ACTION_CLOSE_GOSSIP, SMART_ACTION_COMBAT_STOP, SMART_ACTION_CONE_SUMMON, SMART_ACTION_CREATE_TIMED_EVENT, SMART_ACTION_CROSS_CAST, SMART_ACTION_CU_ENCOUNTER_START, SMART_ACTION_CUSTOM_CAST, SMART_ACTION_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_GAMEOBJECT_GROUP, SMART_ACTION_SUMMON_GO, SMART_ACTION_SUMMON_RADIAL, SMART_ACTION_TALK, SMART_ACTION_TELEPORT, SMART_ACTION_THREAT_ALL_PCT, SMART_ACTION_THREAT_SINGLE_PCT, SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT, SMART_ACTION_TRIGGER_TIMED_EVENT, SMART_ACTION_UPDATE_TEMPLATE, SMART_ACTION_VORTEX_SUMMON, SMART_ACTION_WAYPOINT_DATA_RANDOM, SMART_ACTION_WAYPOINT_START, SMART_ACTION_WORLD_SCRIPT, SMART_ACTION_ZONE_UNDER_ATTACK, SMART_ESCORT_TARGETS, SMART_EVENT_ESCORT_REACHED, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL, SMART_EVENT_LINK, SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_RANDOM_POINT, SMART_TARGET_NONE, SMART_TARGET_POSITION, SMART_TARGET_RANDOM_POINT, SMART_TARGET_SELF, SMART_WAYPOINT_MGR, SMARTCAST_AURA_NOT_PRESENT, SMARTCAST_COMBAT_MOVE, SMARTCAST_ENABLE_COMBAT_MOVE_ON_LOS, SMARTCAST_INTERRUPT_PREVIOUS, SMARTCAST_TARGET_POWER_MANA, SMARTCAST_THREATLIST_NOT_SINGLE, SMARTCAST_TRIGGERED, sObjectMgr, SmartAction::sound, SmartAction::sound1, SmartAction::sound2, SmartAction::sound3, SmartAction::sound4, SmartScriptHolder::source_type, SmartAction::spawnPos, SmartAction::spawnTimerMax, SmartAction::spawnTimerMin, SmartAction::speed, SmartAction::speedFraction, SmartAction::speedInteger, SmartAction::speedxy, SmartAction::speedz, SmartAction::spell, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_CAST_OK, SPELL_FAILED_OUT_OF_RANGE, SPELL_FAILED_SPELL_IN_PROGRESS, SmartAction::spell_id, SPELLVALUE_BASE_POINT0, SPELLVALUE_BASE_POINT1, SPELLVALUE_BASE_POINT2, SmartAction::spellVisual, sSmartWaypointMgr, sSpellMgr, SmartAction::startAngle, SmartAction::startClosestWaypoint, SmartAction::state, SmartAction::stepAngle, SmartAction::stopMotion, SmartAction::stopMovement, StoreCounter(), StoreTargetList(), SmartAction::storeTargets, SmartAction::subtract, SmartAction::summonCreature, WorldObject::SummonCreature(), WorldObject::SummonCreatureGroup(), SmartAction::summonDuration, SmartAction::summonEntry, WorldObject::SummonGameObject(), WorldObject::SummonGameObjectGroup(), SmartAction::summonGO, WorldObject::SummonTrigger(), SmartAction::summonVortex, sWaypointMgr, SmartAction::swim, sWorldState, CreatureAI::Talk(), SmartAction::talk, SmartScriptHolder::target, SmartAction::targetParam1, SmartAction::targetParam2, SmartAction::targetParam3, SmartAction::targetParam4, SmartAction::targetsLimit, SmartAction::targetsummon, SmartAction::targetType, SmartAction::taxi, TEAM_NEUTRAL, SmartAction::teleport, TEMPSUMMON_CORPSE_DESPAWN, TEMPSUMMON_TIMED_DESPAWN, TEXT_RANGE_NORMAL, SmartAction::textGroupID, SmartAction::textId, SmartAction::threat, SmartAction::threatDEC, SmartAction::threatINC, SmartAction::threatPCT, SmartAction::timedActionList, SmartAction::timeEvent, SmartAction::timer, Object::ToCreature(), Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), SmartAction::transport, trigger, TRIGGERED_FULL_MASK, TRIGGERED_NONE, SmartAction::triggerFlags, SmartAction::turnAngle, SmartEvent::type, SmartAction::type, SmartTarget::type, UNIT_DYNAMIC_FLAGS, UNIT_FIELD_BYTES_1, UNIT_FIELD_FLAGS, UNIT_FIELD_FLAGS_2, UNIT_FLAG_SILENCED, UNIT_NPC_EMOTESTATE, UNIT_STATE_LOST_CONTROL, UNIT_STATE_NO_COMBAT_MOVEMENT, UNIT_STATE_NO_ENVIRONMENT_UPD, UNIT_STATE_ROOT, UNIT_VIRTUAL_ITEM_SLOT_ID, SmartAction::unitFlag, SmartTarget::unitRange, SmartAction::updateLevel, SmartAction::updateTemplate, urand(), GameObject::UseDoorOrButton(), SmartAction::useTalkTarget, SmartAction::value, SmartAction::visibility, SmartAction::visualId, WAYPOINT_MGR, SmartAction::withDelayed, SmartAction::withEmote, SmartAction::withInstant, SmartAction::worldStateScript, SmartAction::wpData, SmartAction::wpDataRandom, SmartAction::wpPause, SmartAction::wpStart, SmartAction::wpStop, SmartTarget::x, WaypointNode::X, SmartTarget::y, WaypointNode::Y, SmartTarget::z, and WaypointNode::Z.

Referenced by ProcessEvent(), and ProcessTimedAction().

◆ ProcessEvent()

void SmartScript::ProcessEvent ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
4121{
4122 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4123 return;
4124
4126 return;
4127
4129 return;
4130
4131 switch (e.GetEventType())
4132 {
4133 case SMART_EVENT_LINK://special handling
4134 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4135 break;
4136 //called from Update tick
4137 case SMART_EVENT_UPDATE:
4139 break;
4141 if (me && me->IsEngaged())
4142 return;
4144 break;
4146 if (!me || !me->IsEngaged())
4147 return;
4149 break;
4151 {
4152 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4153 return;
4154 uint32 perc = (uint32)me->GetHealthPct();
4155 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4156 return;
4158 break;
4159 }
4161 {
4162 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4163 return;
4164 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4165 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4166 return;
4168 break;
4169 }
4171 {
4172 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4173 return;
4175 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4176 return;
4178 break;
4179 }
4181 {
4182 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4183 return;
4185 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4186 return;
4188 break;
4189 }
4190 case SMART_EVENT_RANGE:
4191 {
4192 if (!me || !me->IsEngaged() || !me->GetVictim())
4193 return;
4194
4197 else
4198 RecalcTimer(e, 1200, 1200); // make it predictable
4199
4200 break;
4201 }
4203 {
4204 if (!me || !me->IsEngaged())
4205 return;
4206
4207 Unit* victim = me->GetVictim();
4208
4209 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4210 return;
4211
4212 if (e.event.targetCasting.spellId > 0)
4213 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4214 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4215 return;
4216
4218 break;
4219 }
4221 {
4222 if (!me || !me->IsEngaged())
4223 return;
4224
4226 if (!target || !target->IsInCombat())
4227 {
4228 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4229 RecalcTimer(e, 1000, 3000);
4230 return;
4231 }
4233 break;
4234 }
4236 {
4237 if (!me || !me->IsEngaged())
4238 return;
4239
4240 std::vector<Creature*> creatures;
4242 if (creatures.empty())
4243 {
4244 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4245 RecalcTimer(e, 1000, 3000);
4246 return;
4247 }
4249 break;
4250 }
4252 {
4254 {
4255 return;
4256 }
4257
4258 std::vector<Creature*> creatures;
4260
4261 if (creatures.empty())
4262 return;
4263
4265 break;
4266 }
4268 {
4269 if (!me)
4270 return;
4271 uint32 count = me->GetAuraCount(e.event.aura.spell);
4272 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4274 break;
4275 }
4277 {
4278 if (!me || !me->GetVictim())
4279 return;
4281 if (count < e.event.aura.count)
4282 return;
4284 break;
4285 }
4287 {
4288 if (bvar == (e.event.charm.onRemove != 1))
4289 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4290 break;
4291 }
4292 //no params
4293 case SMART_EVENT_AGGRO:
4294 case SMART_EVENT_DEATH:
4295 case SMART_EVENT_EVADE:
4308 case SMART_EVENT_RESET:
4312 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4313 break;
4314
4316 switch (e.event.gossipHello.filter)
4317 {
4318 case 0:
4319 // no filter set, always execute action
4320 break;
4321 case 1:
4322 // GossipHello only filter set, skip action if reportUse
4323 if (var0)
4324 {
4325 return;
4326 }
4327 break;
4328 case 2:
4329 // reportUse only filter set, skip action if GossipHello
4330 if (!var0)
4331 {
4332 return;
4333 }
4334 break;
4335 default:
4336 // Ignore any other value
4337 break;
4338 }
4339
4340 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4341 break;
4343 {
4344 if (!me)
4345 return;
4346
4347 if (Unit* victim = me->GetVictim())
4348 {
4350 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4352 }
4353
4354 break;
4355 }
4357 {
4358 if (!me)
4359 return;
4360
4361 if (Unit* victim = me->GetVictim())
4362 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4363 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4365
4366 break;
4367 }
4369 if (e.event.emote.emote == var0)
4370 {
4371 ProcessAction(e, unit);
4372 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4373 }
4374 break;
4375 case SMART_EVENT_KILL:
4376 {
4377 if (!me || !unit)
4378 return;
4379 if (e.event.kill.playerOnly && !unit->IsPlayer())
4380 return;
4381 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4382 return;
4384 ProcessAction(e, unit);
4385 break;
4386 }
4389 {
4390 if (!spell)
4391 return;
4392 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4393 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4394 {
4396 ProcessAction(e, unit, 0, 0, bvar, spell);
4397 }
4398 break;
4399 }
4401 {
4402 if (!me || me->IsEngaged())
4403 return;
4404 //can trigger if closer than fMaxAllowedRange
4405 float range = (float)e.event.los.maxDist;
4406
4407 //if range is ok and we are actually in LOS
4408 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4409 {
4411 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4412 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4413 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4414 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4415 {
4416 if (e.event.los.playerOnly && !unit->IsPlayer())
4417 return;
4419 ProcessAction(e, unit);
4420 }
4421 }
4422 break;
4423 }
4424 case SMART_EVENT_IC_LOS:
4425 {
4426 if (!me || !me->IsEngaged())
4427 return;
4428 //can trigger if closer than fMaxAllowedRange
4429 float range = (float)e.event.los.maxDist;
4430
4431 //if range is ok and we are actually in LOS
4432 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4433 {
4435 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4436 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4437 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4438 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4439 {
4440 if (e.event.los.playerOnly && !unit->IsPlayer())
4441 return;
4443 ProcessAction(e, unit);
4444 }
4445 }
4446 break;
4447 }
4449 {
4450 if (!GetBaseObject())
4451 return;
4453 return;
4455 return;
4456 ProcessAction(e);
4457 break;
4458 }
4462 {
4463 if (!IsCreature(unit))
4464 return;
4465 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4466 return;
4468 ProcessAction(e, unit);
4469 break;
4470 }
4474 {
4475 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4476 return;
4478 ProcessAction(e, unit);
4479 break;
4480 }
4482 {
4483 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4484 return;
4486 return;
4487 ProcessAction(e, unit, var0, var1);
4488 break;
4489 }
4492 {
4493 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4494 return;
4495 ProcessAction(e, unit, var0);
4496 break;
4497 }
4503 {
4504 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4505 return;
4506 ProcessAction(e, unit);
4507 break;
4508 }
4510 {
4511 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4512 return;
4514 ProcessAction(e, unit, var0);
4515 break;
4516 }
4518 {
4520 return;
4522 ProcessAction(e, unit, var0);
4523 break;
4524 }
4527 {
4528 if (e.event.quest.quest && var0 != e.event.quest.quest)
4529 return;
4530 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4531 ProcessAction(e, unit, var0);
4532 break;
4533 }
4535 {
4537 return;
4538 ProcessAction(e, unit, var0);
4539 break;
4540 }
4542 {
4543 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4544 return;
4545 ProcessAction(e, unit, var0);
4546 break;
4547 }
4549 {
4551 return;
4552 ProcessAction(e, unit, var0);
4553 break;
4554 }
4556 {
4557 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4558 return;
4560 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4561 break;
4562 }
4565 {
4566 if (!unit)
4567 return;
4569 ProcessAction(e, unit);
4570 break;
4571 }
4573 {
4574 if (e.event.timedEvent.id == var0)
4575 ProcessAction(e, unit);
4576 break;
4577 }
4579 {
4580 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4581 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4582 return;
4583 ProcessAction(e, unit, var0, var1);
4584 break;
4585 }
4587 {
4589 return;
4590
4591 ProcessAction(e);
4592 break;
4593 }
4596 {
4597 if (e.event.gameEvent.gameEventId != var0)
4598 return;
4599 ProcessAction(e, nullptr, var0);
4600 break;
4601 }
4603 {
4604 if (e.event.goStateChanged.state != var0)
4605 return;
4606 ProcessAction(e, unit, var0, var1);
4607 break;
4608 }
4610 {
4611 if (e.event.eventInform.eventId != var0)
4612 return;
4613 ProcessAction(e, nullptr, var0);
4614 break;
4615 }
4617 {
4618 if (e.event.doAction.eventId != var0)
4619 return;
4621 ProcessAction(e, unit, var0);
4622 break;
4623 }
4625 {
4626 if (!me || !me->IsEngaged())
4627 return;
4628
4629 Unit* unitTarget = nullptr;
4630 switch (e.GetTargetType())
4631 {
4639 {
4640 ObjectVector targets;
4641 GetTargets(targets, e);
4642 for (WorldObject* target : targets)
4643 {
4644 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4645 {
4646 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4647 if (healthPct > e.event.friendlyHealthPct.hpPct)
4648 {
4649 continue;
4650 }
4651
4652 unitTarget = target->ToUnit();
4653 break;
4654 }
4655 }
4656
4657 break;
4658 }
4659 case SMART_TARGET_SELF:
4662 break;
4663 default:
4664 return;
4665 }
4666
4667 if (!unitTarget)
4668 return;
4669
4671 break;
4672 }
4674 {
4675 if (!me)
4676 return;
4677
4678 WorldObject* creature = nullptr;
4679
4680 if (e.event.distance.guid != 0)
4681 {
4682 creature = FindCreatureNear(me, e.event.distance.guid);
4683
4684 if (!creature)
4685 return;
4686
4687 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4688 return;
4689 }
4690 else if (e.event.distance.entry != 0)
4691 {
4692 std::list<Creature*> list;
4694
4695 if (!list.empty())
4696 creature = list.front();
4697 }
4698
4699 if (creature)
4701
4702 break;
4703 }
4705 {
4706 if (!me)
4707 return;
4708
4709 WorldObject* gameobject = nullptr;
4710
4711 if (e.event.distance.guid != 0)
4712 {
4713 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4714
4715 if (!gameobject)
4716 return;
4717
4718 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4719 return;
4720 }
4721 else if (e.event.distance.entry != 0)
4722 {
4723 std::list<GameObject*> list;
4725
4726 if (!list.empty())
4727 gameobject = list.front();
4728 }
4729
4730 if (gameobject)
4732
4733 break;
4734 }
4736 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4737 return;
4738
4740 break;
4742 {
4743 uint32 playerCount = 0;
4744 ObjectVector targets;
4745 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4746
4747 if (!targets.empty())
4748 {
4749 for (WorldObject* target : targets)
4750 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4751 playerCount++;
4752
4753 if (playerCount >= e.event.nearPlayer.minCount)
4754 ProcessAction(e, unit);
4755 }
4757 break;
4758 }
4760 {
4761 uint32 playerCount = 0;
4762 ObjectVector targets;
4763 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4764
4765 if (!targets.empty())
4766 {
4767 for (WorldObject* target : targets)
4768 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4769 playerCount++;
4770
4771 if (playerCount < e.event.nearPlayerNegation.maxCount)
4772 ProcessAction(e, unit);
4773 }
4775 break;
4776 }
4778 {
4779 uint32 unitCount = 0;
4780 ObjectVector targets;
4781 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4782
4783 if (!targets.empty())
4784 {
4785 if (e.event.nearUnit.type)
4786 {
4787 for (WorldObject* target : targets)
4788 {
4789 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4790 unitCount++;
4791 }
4792 }
4793 else
4794 {
4795 for (WorldObject* target : targets)
4796 {
4797 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4798 unitCount++;
4799 }
4800 }
4801
4802 if (unitCount >= e.event.nearUnit.count)
4803 ProcessAction(e, unit);
4804 }
4806 break;
4807 }
4809 {
4810 uint32 unitCount = 0;
4811 ObjectVector targets;
4812 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4813
4814 if (!targets.empty())
4815 {
4817 {
4818 for (WorldObject* target : targets)
4819 {
4820 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4821 unitCount++;
4822 }
4823 }
4824 else
4825 {
4826 for (WorldObject* target : targets)
4827 {
4828 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4829 unitCount++;
4830 }
4831 }
4832
4833 if (unitCount < e.event.nearUnitNegation.count)
4834 ProcessAction(e, unit);
4835 }
4837 break;
4838 }
4840 {
4841 if (!me || !me->IsEngaged())
4842 return;
4843
4844 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4845 {
4846 if (Unit* target = ref->GetVictim())
4847 {
4848 if (!IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4849 continue;
4850
4851 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4852 continue;
4853
4854 ProcessAction(e, target);
4856 return;
4857 }
4858 }
4859
4860 // No targets found
4862
4863 break;
4864 }
4866 {
4867 if (!me || !me->IsEngaged())
4868 return;
4869
4870 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4871 {
4872 if (Unit* target = ref->GetVictim())
4873 {
4874 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4875 continue;
4876
4877 ProcessAction(e, target);
4879 return;
4880 }
4881 }
4882
4883 // If no targets are found and it's off cooldown, check again
4884 RecalcTimer(e, 1200, 1200);
4885 break;
4886 }
4889 {
4890 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4891 return;
4892 ProcessAction(e, unit);
4893 break;
4894 }
4895 default:
4896 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4897 break;
4898 }
4899}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1953
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:536
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:535
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:106
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:171
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:134
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:107
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:121
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:150
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:152
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:129
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:117
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:148
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:101
@ SMART_EVENT_ESCORT_START
Definition SmartScriptMgr.h:138
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:165
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:145
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:172
@ SMART_EVENT_ESCORT_PAUSED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_ESCORT_RESUMED
Definition SmartScriptMgr.h:155
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:127
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:144
@ SMART_EVENT_ESCORT_ENDED
Definition SmartScriptMgr.h:157
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:120
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:141
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:119
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:170
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:128
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:130
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:167
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:104
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:142
@ SMART_EVENT_ESCORT_STOPPED
Definition SmartScriptMgr.h:156
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:163
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:161
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:135
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:196
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:126
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:140
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:198
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:118
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:176
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:115
@ SMART_EVENT_WAYPOINT_REACHED
Definition SmartScriptMgr.h:197
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:123
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:110
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:113
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:149
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:105
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:143
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:131
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:164
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:147
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:183
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:114
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:103
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:111
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:112
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:132
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:122
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:116
@ CURRENT_GENERIC_SPELL
Definition Unit.h:556
uint32 GetWaypointPath() const
Definition Creature.h:355
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5360
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5350
void ProcessAction(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:164
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5443
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5323
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5489
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5336
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:3359
Definition Spell.h:298
float GetHealthPct() const
Definition Unit.h:1110
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4272
uint32 GetMaxHealth() const
Definition Unit.h:1109
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:782
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5943
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1136
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7241
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:7236
bool IsInCombat() const
Definition Unit.h:935
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1576
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2546
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2560
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1377
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:148
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:253
uint32 pointId
Definition SmartScriptMgr.h:508
uint32 invert
Definition SmartScriptMgr.h:494
uint32 entry
Definition SmartScriptMgr.h:447
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:339
LOSHostilityMode
Definition SmartScriptMgr.h:524
uint32 cooldownMax
Definition SmartScriptMgr.h:225
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:353
uint32 radius
Definition SmartScriptMgr.h:273
uint32 maxDist
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:397
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:233
uint32 rangeMin
Definition SmartScriptMgr.h:218
uint32 eventId
Definition SmartScriptMgr.h:424
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:446
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:448
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:267
uint32 emote
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:440
uint32 filter
Definition SmartScriptMgr.h:392
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:243
uint32 hpDeficit
Definition SmartScriptMgr.h:272
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:254
uint32 count
Definition SmartScriptMgr.h:318
uint32 onlyInCombat
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:346
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:354
SAIBool playerOnly
Definition SmartScriptMgr.h:226
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:340
uint32 creatureEntry
Definition SmartScriptMgr.h:382
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:398
struct SmartEvent::@30::@64 doAction
struct SmartEvent::@30::@46 charm
struct SmartEvent::@30::@63 eventInform
struct SmartEvent::@30::@38 targetCasting
uint32 spell
Definition SmartScriptMgr.h:232
uint32 maxCount
Definition SmartScriptMgr.h:471
uint32 gameEventId
Definition SmartScriptMgr.h:414
uint32 textGroupID
Definition SmartScriptMgr.h:381
uint32 cooldownMin
Definition SmartScriptMgr.h:224
uint32 onRemove
Definition SmartScriptMgr.h:325
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:303
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:419
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:219
uint32 team
Definition SmartScriptMgr.h:369
uint32 range
Definition SmartScriptMgr.h:483
uint32 minCount
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@37 minMax
struct SmartEvent::@30::@55 textOver
struct SmartEvent::@30::@40 friendlyCC
struct SmartEvent::@30::@62 goStateChanged
uint32 creature
Definition SmartScriptMgr.h:227
uint32 phasemask
Definition SmartScriptMgr.h:409

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

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

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

◆ ProcessTimedAction()

void SmartScript::ProcessTimedAction ( SmartScriptHolder e,
uint32 const &  min,
uint32 const &  max,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
3360{
3361 // xinef: extended by selfs victim
3362 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3363 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3364
3365 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3366 {
3367 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3368 RecalcTimer(e, min, max);
3369 }
3370 else
3371 RecalcTimer(e, 5000, 5000);
3372}

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
5137{
5138 e.timer = 1200;
5139 // Change priority only if it's set to default, otherwise keep the current order of events
5141 {
5143 mEventSortingRequired = true;
5144 }
5145}
uint32 timer
Definition SmartScriptMgr.h:2011
uint32 priority
Definition SmartScriptMgr.h:2012

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
4935{
4936 // min/max was checked at loading!
4937 e.timer = urand(uint32(min), uint32(max));
4938 e.active = e.timer ? false : true;
4939}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5505{
5506 _summonList.erase(guid);
5507}

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
5148{
5149 RaisePriority(e);
5150
5151 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5152 if (ignoreChanceRoll)
5154
5155 e.runOnce = false;
5156}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5136

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
5478{
5479 uint32 oldPhase = mEventPhase;
5480
5481 mEventPhase = p;
5482
5483 if (oldPhase != mEventPhase)
5484 {
5486 }
5487}

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 
)
5383{
5384 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5385 // any SmartScriptHolder contained like the "e" parameter passed to this function
5387 {
5388 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());
5389 return;
5390 }
5391
5392 // 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
5394 {
5395 return;
5396 }
5397
5398 mTimedActionList.clear();
5400 if (mTimedActionList.empty())
5401 return;
5402 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5403 {
5404 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5405
5406 if (e.action.timedActionList.timerType == 0)
5407 i->event.type = SMART_EVENT_UPDATE_OOC;
5408 else if (e.action.timedActionList.timerType == 1)
5409 i->event.type = SMART_EVENT_UPDATE_IC;
5410 else if (e.action.timedActionList.timerType > 1)
5411 i->event.type = SMART_EVENT_UPDATE;
5412
5413 InitTimer((*i));
5414 }
5415}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1795
SAIBool allowOverride
Definition SmartScriptMgr.h:1151
uint32 timerType
Definition SmartScriptMgr.h:1150

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
5132{
5133 std::sort(events.begin(), events.end());
5134}
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:2029

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4942{
4943 if (e.GetEventType() == SMART_EVENT_LINK)
4944 return;
4945
4947 return;
4948
4949 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4950 return;
4951
4952 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4953 return;
4954
4955 if (e.timer < diff)
4956 {
4957 // delay spell cast for another AI tick if another spell is being cast
4959 {
4961 {
4963 {
4964 RaisePriority(e);
4965 return;
4966 }
4967 }
4968 }
4969
4970 // Delay flee for assist event if casting
4972 {
4973 e.timer = 1200;
4974 return;
4975 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
4976
4977 e.active = true;//activate events with cooldown
4978 switch (e.GetEventType())//process ONLY timed events
4979 {
4984 case SMART_EVENT_UPDATE:
4991 case SMART_EVENT_RANGE:
5005 {
5006 ASSERT(executionStack.empty());
5007 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
5008 while (!executionStack.empty())
5009 {
5010 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
5011 executionStack.pop_back();
5012 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
5013 }
5015 {
5016 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
5017 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5018 {
5019 //find the first event which is not the current one and enable it
5020 if (i->event_id > e.event_id)
5021 {
5022 i->enableTimed = true;
5023 break;
5024 }
5025 }
5026 }
5027 break;
5028 }
5029 }
5030
5032 {
5033 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
5034 if (e.timer > 1)
5035 {
5036 // Re-sort events if this was moved to the top of the queue
5037 mEventSortingRequired = true;
5038 // Reset priority to default one
5040 }
5041 }
5042 }
5043 else
5044 e.timer -= diff;
5045}
@ UNIT_STATE_CASTING
Definition UnitDefines.h:188
bool enableTimed
Definition SmartScriptMgr.h:2015

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

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ executionStack

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

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

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

◆ mCounterList

CounterMap SmartScript::mCounterList

◆ mCurrentPriority

uint32 SmartScript::mCurrentPriority
private

Referenced by RaisePriority(), and SmartScript().

◆ me

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

◆ mEvents

◆ mEventSortingRequired

bool SmartScript::mEventSortingRequired
private

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Referenced by AddEvent(), and InstallEvents().

◆ mLastInvoker

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

◆ mPathId

uint32 SmartScript::mPathId
private

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

◆ mRemIDs

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

Referenced by OnUpdate(), and ProcessAction().

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

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

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

◆ mTemplate

SMARTAI_TEMPLATE SmartScript::mTemplate
private

Referenced by InstallTemplate(), and SmartScript().

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

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

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

◆ trigger

AreaTrigger const* SmartScript::trigger
private

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