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

#include "SmartScript.h"

Classes

struct  SmartScriptFrame
 

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ CounterMap

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

Constructor & Destructor Documentation

◆ SmartScript()

SmartScript::SmartScript ( )
Todo:
: this import is not necessary for compilation and marked as unused by the IDE
47{
48 go = nullptr;
49 me = nullptr;
50 trigger = nullptr;
51 mEventPhase = 0;
52 mPathId = 0;
53 mTextTimer = 0;
54 mLastTextID = 0;
55 mUseTextTimer = false;
56 mTalkerEntry = 0;
62 _allowPhaseReset = true;
63}
@ SMART_SCRIPT_TYPE_CREATURE
Definition SmartScriptMgr.h:1774
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1527
uint32 mEventPhase
Definition SmartScript.h:230
SMARTAI_TEMPLATE mTemplate
Definition SmartScript.h:249
Creature * me
Definition SmartScript.h:224
uint32 mPathId
Definition SmartScript.h:233
SmartScriptType mScriptType
Definition SmartScript.h:229
bool _allowPhaseReset
Definition SmartScript.h:245
bool mUseTextTimer
Definition SmartScript.h:240
uint32 mLastTextID
Definition SmartScript.h:238
uint32 mTextTimer
Definition SmartScript.h:237
GameObject * go
Definition SmartScript.h:226
AreaTrigger const * trigger
Definition SmartScript.h:228
uint32 mCurrentPriority
Definition SmartScript.h:241
uint32 mTalkerEntry
Definition SmartScript.h:239
bool isProcessingTimedActionList
Definition SmartScript.h:223
bool mEventSortingRequired
Definition SmartScript.h:242

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

◆ ~SmartScript()

SmartScript::~SmartScript ( )
66{
67}

Member Function Documentation

◆ AddCreatureSummon()

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

References _summonList.

Referenced by SmartAI::JustSummoned().

◆ AddEvent()

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

References CreateSmartEvent(), and mInstallEvents.

Referenced by InstallTemplate().

◆ AllowPhaseReset()

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

References _allowPhaseReset.

Referenced by OnReset().

◆ CheckTimer()

bool SmartScript::CheckTimer ( SmartScriptHolder const &  e) const
4973{
4974 return e.active;
4975}

References SmartScriptHolder::active.

◆ CreateSmartEvent()

SmartScriptHolder SmartScript::CreateSmartEvent ( SMART_EVENT  e,
uint32  event_flags,
uint32  event_param1,
uint32  event_param2,
uint32  event_param3,
uint32  event_param4,
uint32  event_param5,
uint32  event_param6,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
static
3414{
3415 SmartScriptHolder script;
3416 script.event.type = e;
3417 script.event.raw.param1 = event_param1;
3418 script.event.raw.param2 = event_param2;
3419 script.event.raw.param3 = event_param3;
3420 script.event.raw.param4 = event_param4;
3421 script.event.raw.param5 = event_param5;
3422 script.event.raw.param6 = event_param6;
3423 script.event.event_phase_mask = phaseMask;
3424 script.event.event_flags = event_flags;
3425 script.event.event_chance = 100;
3426
3427 script.action.type = action;
3428 script.action.raw.param1 = action_param1;
3429 script.action.raw.param2 = action_param2;
3430 script.action.raw.param3 = action_param3;
3431 script.action.raw.param4 = action_param4;
3432 script.action.raw.param5 = action_param5;
3433 script.action.raw.param6 = action_param6;
3434
3435 script.target.type = t;
3436 script.target.raw.param1 = target_param1;
3437 script.target.raw.param2 = target_param2;
3438 script.target.raw.param3 = target_param3;
3439 script.target.raw.param4 = target_param4;
3440
3442 InitTimer(script);
3443 return script;
3444}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4826
uint32 param3
Definition SmartScriptMgr.h:1075
uint32 param5
Definition SmartScriptMgr.h:1077
uint32 param1
Definition SmartScriptMgr.h:1073
SMART_ACTION type
Definition SmartScriptMgr.h:759
struct SmartAction::@75::@195 raw
uint32 param4
Definition SmartScriptMgr.h:1076
uint32 param6
Definition SmartScriptMgr.h:1514
uint32 param2
Definition SmartScriptMgr.h:1074
uint32 param1
Definition SmartScriptMgr.h:530
uint32 event_flags
Definition SmartScriptMgr.h:228
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition SmartScriptMgr.h:226
uint32 param2
Definition SmartScriptMgr.h:531
uint32 param4
Definition SmartScriptMgr.h:533
uint32 param3
Definition SmartScriptMgr.h:532
uint32 param6
Definition SmartScriptMgr.h:535
uint32 event_chance
Definition SmartScriptMgr.h:227
uint32 param5
Definition SmartScriptMgr.h:534
SMART_EVENT type
Definition SmartScriptMgr.h:225
Definition SmartScriptMgr.h:1976
SmartAction action
Definition SmartScriptMgr.h:1987
SmartScriptType source_type
Definition SmartScriptMgr.h:1982
SmartEvent event
Definition SmartScriptMgr.h:1986
SmartTarget target
Definition SmartScriptMgr.h:1988
uint32 param4
Definition SmartScriptMgr.h:1749
struct SmartTarget::@197::@221 raw
uint32 param1
Definition SmartScriptMgr.h:1746
uint32 param3
Definition SmartScriptMgr.h:1748
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1598
uint32 param2
Definition SmartScriptMgr.h:1747

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

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5296{
5297 if (!me)
5298 return nullptr;
5299
5300 Unit* unit = nullptr;
5301 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5303 Cell::VisitObjects(me, searcher, range);
5304 return unit;
5305}
Definition Unit.h:620
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
5276{
5277 if (!me)
5278 return;
5279
5280 Acore::FriendlyCCedInRange u_check(me, range);
5282 Cell::VisitObjects(me, searcher, range);
5283}
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
5286{
5287 if (!me)
5288 return;
5289
5290 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5292 Cell::VisitObjects(me, searcher, range);
5293}
Definition GridNotifiers.h:827

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5249{
5250 if (!me)
5251 return nullptr;
5252
5253 Unit* unit = nullptr;
5254
5255 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5257 Cell::VisitObjects(me, searcher, range);
5258 return unit;
5259}
Definition GridNotifiers.h:766

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

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

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ FillScript()

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

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

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

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

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

References mEvents.

Referenced by ProcessAction().

◆ GetBaseObject()

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

References go, and me.

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

◆ GetCounterValue()

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

References mCounterList.

Referenced by ProcessEvent().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5343{
5344 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5345 if (GetBaseObject())
5347 // xinef: used for area triggers invoker cast
5348 else if (invoker)
5350 return nullptr;
5351}
ObjectGuid mLastInvoker
Definition SmartScript.h:200
WorldObject * GetBaseObject() const
Definition SmartScript.h:64
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition ObjectAccessor.cpp:115

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

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

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

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

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

Referenced by OnInitialize().

◆ GetStoredTargetVector()

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

References _storedTargets.

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

◆ GetTargets()

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

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

Referenced by ProcessAction(), and ProcessEvent().

◆ GetWorldObjectsInDist()

void SmartScript::GetWorldObjectsInDist ( ObjectVector objects,
float  dist 
) const
4028{
4029 WorldObject* obj = GetBaseObject();
4030 if (!obj)
4031 return;
4032
4033 Acore::AllWorldObjectsInRange u_check(obj, dist);
4035 Cell::VisitObjects(obj, searcher, dist);
4036}
Definition GridNotifiers.h:1617
Definition GridNotifiers.h:230

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

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

◆ IncPhase()

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

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

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

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

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3335{
3336 if (!GetBaseObject())
3337 return;
3339 {
3340 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3341 return;
3342 }
3343 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3344 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3345 {
3347 {
3348 AddEvent(SMART_EVENT_UPDATE_IC, 0, 0, 0, e.action.installTtemplate.param2, e.action.installTtemplate.param3, 0, 0, SMART_ACTION_CAST, e.action.installTtemplate.param1, e.target.raw.param1, 0, 0, 0, 0, SMART_TARGET_VICTIM, 0, 0, 0, 0, 1);
3349 AddEvent(SMART_EVENT_RANGE, 0, e.action.installTtemplate.param4, 300, 0, 0, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3350 AddEvent(SMART_EVENT_RANGE, 0, 0, e.action.installTtemplate.param4 > 10 ? e.action.installTtemplate.param4 - 10 : 0, 0, 0, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 0, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3351 AddEvent(SMART_EVENT_MANA_PCT, 0, e.action.installTtemplate.param5 - 15 > 100 ? 100 : e.action.installTtemplate.param5 + 15, 100, 1000, 1000, 0, 0, SMART_ACTION_SET_EVENT_PHASE, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3352 AddEvent(SMART_EVENT_MANA_PCT, 0, 0, e.action.installTtemplate.param5, 1000, 1000, 0, 0, SMART_ACTION_SET_EVENT_PHASE, 0, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3353 AddEvent(SMART_EVENT_MANA_PCT, 0, 0, e.action.installTtemplate.param5, 1000, 1000, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3354 break;
3355 }
3357 {
3358 AddEvent(SMART_EVENT_UPDATE_IC, 0, 0, 0, e.action.installTtemplate.param2, e.action.installTtemplate.param3, 0, 0, SMART_ACTION_CAST, e.action.installTtemplate.param1, e.target.raw.param1, 0, 0, 0, 0, SMART_TARGET_VICTIM, 0, 0, 0, 0, 0);
3359 AddEvent(SMART_EVENT_JUST_CREATED, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 0, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3360 break;
3361 }
3363 {
3364 if (!me)
3365 return;
3366 //store cage as id1
3367 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 1, 0, 0, 0, 0, 0, SMART_TARGET_CLOSEST_GAMEOBJECT, e.action.installTtemplate.param1, 10, 0, 0, 0);
3368
3369 //reset(close) cage on hostage(me) respawn
3370 AddEvent(SMART_EVENT_UPDATE, SMART_EVENT_FLAG_NOT_REPEATABLE, 0, 0, 0, 0, 0, 0, SMART_ACTION_RESET_GOBJECT, 0, 0, 0, 0, 0, 0, SMART_TARGET_GAMEOBJECT_DISTANCE, e.action.installTtemplate.param1, 5, 0, 0, 0);
3371
3372 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_SET_RUN, e.action.installTtemplate.param3, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3373 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_SET_EVENT_PHASE, 1, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3374
3375 AddEvent(SMART_EVENT_UPDATE, SMART_EVENT_FLAG_NOT_REPEATABLE, 1000, 1000, 0, 0, 0, 0, SMART_ACTION_MOVE_FORWARD, e.action.installTtemplate.param4, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3376 //phase 1: give quest credit on movepoint reached
3378 //phase 1: despawn after time on movepoint reached
3379 AddEvent(SMART_EVENT_MOVEMENTINFORM, 0, POINT_MOTION_TYPE, SMART_RANDOM_POINT, 0, 0, 0, 0, SMART_ACTION_FORCE_DESPAWN, e.action.installTtemplate.param2, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3380
3381 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3382 AddEvent(SMART_EVENT_MOVEMENTINFORM, 0, POINT_MOTION_TYPE, SMART_RANDOM_POINT, 0, 0, 0, 0, SMART_ACTION_TALK, e.action.installTtemplate.param5, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 1);
3383 break;
3384 }
3386 {
3387 if (!go)
3388 return;
3389 //store hostage as id1
3390 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 1, 0, 0, 0, 0, 0, SMART_TARGET_CLOSEST_CREATURE, e.action.installTtemplate.param1, 10, 0, 0, 0);
3391 //store invoker as id2
3392 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 2, 0, 0, 0, 0, 0, SMART_TARGET_NONE, 0, 0, 0, 0, 0);
3393 //signal hostage
3394 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_SET_DATA, 0, 0, 0, 0, 0, 0, SMART_TARGET_STORED, 1, 0, 0, 0, 0);
3395 //when hostage raeched end point, give credit to invoker
3396 if (e.action.installTtemplate.param2)
3397 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, 0, 0, SMART_ACTION_CALL_KILLEDMONSTER, e.action.installTtemplate.param1, 0, 0, 0, 0, 0, SMART_TARGET_STORED, 2, 0, 0, 0, 0);
3398 else
3399 AddEvent(SMART_EVENT_GO_STATE_CHANGED, 0, 2, 0, 0, 0, 0, 0, SMART_ACTION_CALL_KILLEDMONSTER, e.action.installTtemplate.param1, 0, 0, 0, 0, 0, SMART_TARGET_STORED, 2, 0, 0, 0, 0);
3400 break;
3401 }
3403 default:
3404 return;
3405 }
3406}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:119
std::uint8_t uint8
Definition Define.h:109
@ POINT_MOTION_TYPE
Definition MotionMaster.h:48
SMARTAI_TEMPLATE
Definition SmartScriptMgr.h:1526
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1531
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1532
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1528
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1529
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1932
@ SMART_ACTION_STORE_TARGET_LIST
Definition SmartScriptMgr.h:622
@ SMART_ACTION_FORCE_DESPAWN
Definition SmartScriptMgr.h:599
@ SMART_ACTION_CAST
Definition SmartScriptMgr.h:569
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition SmartScriptMgr.h:579
@ SMART_ACTION_MOVE_FORWARD
Definition SmartScriptMgr.h:604
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition SmartScriptMgr.h:591
@ SMART_ACTION_TALK
Definition SmartScriptMgr.h:559
@ SMART_ACTION_SET_DATA
Definition SmartScriptMgr.h:603
@ SMART_ACTION_SET_RUN
Definition SmartScriptMgr.h:617
@ SMART_ACTION_SET_EVENT_PHASE
Definition SmartScriptMgr.h:580
@ SMART_ACTION_RESET_GOBJECT
Definition SmartScriptMgr.h:590
@ SMART_EVENT_DATA_SET
Definition SmartScriptMgr.h:156
@ SMART_EVENT_JUST_CREATED
Definition SmartScriptMgr.h:181
@ SMART_EVENT_MOVEMENTINFORM
Definition SmartScriptMgr.h:152
@ SMART_EVENT_MANA_PCT
Definition SmartScriptMgr.h:121
@ SMART_EVENT_GO_STATE_CHANGED
Definition SmartScriptMgr.h:188
@ SMART_RANDOM_POINT
Definition SmartScriptMgr.h:58
void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
Definition SmartScript.cpp:3408

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

Referenced by ProcessAction().

◆ IsCharmedCreature()

bool SmartScript::IsCharmedCreature ( WorldObject obj)
static
5369{
5370 if (!obj)
5371 return false;
5372
5373 if (Creature* creatureObj = obj->ToCreature())
5374 return creatureObj->IsCharmed();
5375
5376 return false;
5377}
Creature * ToCreature()
Definition Object.h:206

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

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

References Object::IsCreature().

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

◆ IsGameObject()

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

References Object::IsGameObject().

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

◆ IsInPhase()

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

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5359{
5360 return obj && obj->IsPlayer();
5361}
bool IsPlayer() const
Definition Object.h:201

References Object::IsPlayer().

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

◆ IsSmart() [1/3]

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

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

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

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

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

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

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

◆ IsUnit()

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

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5153{
5154 if (obj)//handle object based scripts
5155 {
5156 switch (obj->GetTypeId())
5157 {
5158 case TYPEID_UNIT:
5160 me = obj->ToCreature();
5161 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5162 break;
5163 case TYPEID_GAMEOBJECT:
5165 go = obj->ToGameObject();
5166 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5167 break;
5168 default:
5169 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5170 return;
5171 }
5172 }
5173 else if (at)
5174 {
5176 trigger = at;
5177 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5178 }
5179 else
5180 {
5181 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5182 return;
5183 }
5184
5185 GetScript();//load copy of script
5186
5187 for (SmartScriptHolder& event : mEvents)
5188 InitTimer(event);//calculate timers for first time use
5189
5191 InstallEvents();
5193}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1775
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1776
@ SMART_EVENT_AI_INIT
Definition SmartScriptMgr.h:155
TypeID GetTypeId() const
Definition Object.h:128
GameObject * ToGameObject()
Definition Object.h:214
void ProcessEventsFor(SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:135
void InstallEvents()
Definition SmartScript.cpp:4977
void GetScript()
Definition SmartScript.cpp:5118

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

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

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

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

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

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

◆ ProcessAction()

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

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

Referenced by ProcessEvent(), and ProcessTimedAction().

◆ ProcessEvent()

void SmartScript::ProcessEvent ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
4039{
4040 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4041 return;
4042
4044 return;
4045
4047 return;
4048
4049 switch (e.GetEventType())
4050 {
4051 case SMART_EVENT_LINK://special handling
4052 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4053 break;
4054 //called from Update tick
4055 case SMART_EVENT_UPDATE:
4057 break;
4059 if (me && me->IsEngaged())
4060 return;
4062 break;
4064 if (!me || !me->IsEngaged())
4065 return;
4067 break;
4069 {
4070 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4071 return;
4072 uint32 perc = (uint32)me->GetHealthPct();
4073 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4074 return;
4076 break;
4077 }
4079 {
4080 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4081 return;
4082 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4083 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4084 return;
4086 break;
4087 }
4089 {
4090 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4091 return;
4093 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4094 return;
4096 break;
4097 }
4099 {
4100 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4101 return;
4103 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4104 return;
4106 break;
4107 }
4108 case SMART_EVENT_RANGE:
4109 {
4110 if (!me || !me->IsEngaged() || !me->GetVictim())
4111 return;
4112
4115 else
4116 RecalcTimer(e, 1200, 1200); // make it predictable
4117
4118 break;
4119 }
4121 {
4122 if (!me || !me->IsEngaged())
4123 return;
4124
4125 Unit* victim = me->GetVictim();
4126
4127 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4128 return;
4129
4130 if (e.event.targetCasting.spellId > 0)
4131 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4132 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4133 return;
4134
4136 break;
4137 }
4139 {
4140 if (!me || !me->IsEngaged())
4141 return;
4142
4144 if (!target || !target->IsInCombat())
4145 {
4146 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4147 RecalcTimer(e, 1000, 3000);
4148 return;
4149 }
4151 break;
4152 }
4154 {
4155 if (!me || !me->IsEngaged())
4156 return;
4157
4158 std::vector<Creature*> creatures;
4160 if (creatures.empty())
4161 {
4162 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4163 RecalcTimer(e, 1000, 3000);
4164 return;
4165 }
4167 break;
4168 }
4170 {
4172 {
4173 return;
4174 }
4175
4176 std::vector<Creature*> creatures;
4178
4179 if (creatures.empty())
4180 return;
4181
4183 break;
4184 }
4186 {
4187 if (!me)
4188 return;
4189 uint32 count = me->GetAuraCount(e.event.aura.spell);
4190 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4192 break;
4193 }
4195 {
4196 if (!me || !me->GetVictim())
4197 return;
4199 if (count < e.event.aura.count)
4200 return;
4202 break;
4203 }
4205 {
4206 if (bvar == (e.event.charm.onRemove != 1))
4207 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4208 break;
4209 }
4210 //no params
4211 case SMART_EVENT_AGGRO:
4212 case SMART_EVENT_DEATH:
4213 case SMART_EVENT_EVADE:
4226 case SMART_EVENT_RESET:
4230 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4231 break;
4232
4234 switch (e.event.gossipHello.filter)
4235 {
4236 case 0:
4237 // no filter set, always execute action
4238 break;
4239 case 1:
4240 // GossipHello only filter set, skip action if reportUse
4241 if (var0)
4242 {
4243 return;
4244 }
4245 break;
4246 case 2:
4247 // reportUse only filter set, skip action if GossipHello
4248 if (!var0)
4249 {
4250 return;
4251 }
4252 break;
4253 default:
4254 // Ignore any other value
4255 break;
4256 }
4257
4258 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4259 break;
4261 {
4262 if (!me)
4263 return;
4264
4265 if (Unit* victim = me->GetVictim())
4266 {
4268 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4270 }
4271
4272 break;
4273 }
4275 {
4276 if (!me)
4277 return;
4278
4279 if (Unit* victim = me->GetVictim())
4280 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4281 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4283
4284 break;
4285 }
4287 if (e.event.emote.emote == var0)
4288 {
4289 ProcessAction(e, unit);
4290 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4291 }
4292 break;
4293 case SMART_EVENT_KILL:
4294 {
4295 if (!me || !unit)
4296 return;
4297 if (e.event.kill.playerOnly && !unit->IsPlayer())
4298 return;
4299 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4300 return;
4302 ProcessAction(e, unit);
4303 break;
4304 }
4307 {
4308 if (!spell)
4309 return;
4310 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4311 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4312 {
4314 ProcessAction(e, unit, 0, 0, bvar, spell);
4315 }
4316 break;
4317 }
4319 {
4320 if (!me || me->IsEngaged())
4321 return;
4322 //can trigger if closer than fMaxAllowedRange
4323 float range = (float)e.event.los.maxDist;
4324
4325 //if range is ok and we are actually in LOS
4326 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4327 {
4329 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4330 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4331 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4332 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4333 {
4334 if (e.event.los.playerOnly && !unit->IsPlayer())
4335 return;
4337 ProcessAction(e, unit);
4338 }
4339 }
4340 break;
4341 }
4342 case SMART_EVENT_IC_LOS:
4343 {
4344 if (!me || !me->IsEngaged())
4345 return;
4346 //can trigger if closer than fMaxAllowedRange
4347 float range = (float)e.event.los.maxDist;
4348
4349 //if range is ok and we are actually in LOS
4350 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4351 {
4353 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4354 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4355 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4356 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4357 {
4358 if (e.event.los.playerOnly && !unit->IsPlayer())
4359 return;
4361 ProcessAction(e, unit);
4362 }
4363 }
4364 break;
4365 }
4367 {
4368 if (!GetBaseObject())
4369 return;
4371 return;
4373 return;
4374 ProcessAction(e);
4375 break;
4376 }
4380 {
4381 if (!IsCreature(unit))
4382 return;
4383 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4384 return;
4386 ProcessAction(e, unit);
4387 break;
4388 }
4392 {
4393 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4394 return;
4396 ProcessAction(e, unit);
4397 break;
4398 }
4400 {
4401 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4402 return;
4403 ProcessAction(e, unit, var0, var1);
4404 break;
4405 }
4408 {
4409 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4410 return;
4411 ProcessAction(e, unit, var0);
4412 break;
4413 }
4419 {
4420 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4421 return;
4422 ProcessAction(e, unit);
4423 break;
4424 }
4426 {
4427 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4428 return;
4430 ProcessAction(e, unit, var0);
4431 break;
4432 }
4434 {
4436 return;
4438 ProcessAction(e, unit, var0);
4439 break;
4440 }
4443 {
4444 if (e.event.quest.quest && var0 != e.event.quest.quest)
4445 return;
4446 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4447 ProcessAction(e, unit, var0);
4448 break;
4449 }
4451 {
4453 return;
4454 ProcessAction(e, unit, var0);
4455 break;
4456 }
4458 {
4459 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4460 return;
4461 ProcessAction(e, unit, var0);
4462 break;
4463 }
4465 {
4467 return;
4468 ProcessAction(e, unit, var0);
4469 break;
4470 }
4472 {
4473 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4474 return;
4476 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4477 break;
4478 }
4481 {
4482 if (!unit)
4483 return;
4485 ProcessAction(e, unit);
4486 break;
4487 }
4489 {
4490 if (e.event.timedEvent.id == var0)
4491 ProcessAction(e, unit);
4492 break;
4493 }
4495 {
4496 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4497 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4498 return;
4499 ProcessAction(e, unit, var0, var1);
4500 break;
4501 }
4503 {
4505 return;
4506
4507 WorldObject* templastInvoker = GetLastInvoker();
4508 if (!templastInvoker)
4509 return;
4510
4511 if (!IsUnit(templastInvoker))
4512 return;
4513
4514 ProcessAction(e, templastInvoker->ToUnit());
4515 break;
4516 }
4519 {
4520 if (e.event.gameEvent.gameEventId != var0)
4521 return;
4522 ProcessAction(e, nullptr, var0);
4523 break;
4524 }
4526 {
4527 if (e.event.goStateChanged.state != var0)
4528 return;
4529 ProcessAction(e, unit, var0, var1);
4530 break;
4531 }
4533 {
4534 if (e.event.eventInform.eventId != var0)
4535 return;
4536 ProcessAction(e, nullptr, var0);
4537 break;
4538 }
4540 {
4541 if (e.event.doAction.eventId != var0)
4542 return;
4543 ProcessAction(e, unit, var0);
4544 break;
4545 }
4547 {
4548 if (!me || !me->IsEngaged())
4549 return;
4550
4551 Unit* unitTarget = nullptr;
4552 switch (e.GetTargetType())
4553 {
4561 {
4562 ObjectVector targets;
4563 GetTargets(targets, e);
4564 for (WorldObject* target : targets)
4565 {
4566 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4567 {
4568 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4569 if (healthPct > e.event.friendlyHealthPct.hpPct)
4570 {
4571 continue;
4572 }
4573
4574 unitTarget = target->ToUnit();
4575 break;
4576 }
4577 }
4578
4579 break;
4580 }
4581 case SMART_TARGET_SELF:
4584 break;
4585 default:
4586 return;
4587 }
4588
4589 if (!unitTarget)
4590 return;
4591
4593 break;
4594 }
4596 {
4597 if (!me)
4598 return;
4599
4600 WorldObject* creature = nullptr;
4601
4602 if (e.event.distance.guid != 0)
4603 {
4604 creature = FindCreatureNear(me, e.event.distance.guid);
4605
4606 if (!creature)
4607 return;
4608
4609 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4610 return;
4611 }
4612 else if (e.event.distance.entry != 0)
4613 {
4614 std::list<Creature*> list;
4616
4617 if (!list.empty())
4618 creature = list.front();
4619 }
4620
4621 if (creature)
4623
4624 break;
4625 }
4627 {
4628 if (!me)
4629 return;
4630
4631 WorldObject* gameobject = nullptr;
4632
4633 if (e.event.distance.guid != 0)
4634 {
4635 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4636
4637 if (!gameobject)
4638 return;
4639
4640 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4641 return;
4642 }
4643 else if (e.event.distance.entry != 0)
4644 {
4645 std::list<GameObject*> list;
4647
4648 if (!list.empty())
4649 gameobject = list.front();
4650 }
4651
4652 if (gameobject)
4654
4655 break;
4656 }
4658 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4659 return;
4660
4662 break;
4664 {
4665 uint32 playerCount = 0;
4666 ObjectVector targets;
4667 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4668
4669 if (!targets.empty())
4670 {
4671 for (WorldObject* target : targets)
4672 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4673 playerCount++;
4674
4675 if (playerCount >= e.event.nearPlayer.minCount)
4676 ProcessAction(e, unit);
4677 }
4679 break;
4680 }
4682 {
4683 uint32 playerCount = 0;
4684 ObjectVector targets;
4685 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4686
4687 if (!targets.empty())
4688 {
4689 for (WorldObject* target : targets)
4690 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4691 playerCount++;
4692
4693 if (playerCount < e.event.nearPlayerNegation.maxCount)
4694 ProcessAction(e, unit);
4695 }
4697 break;
4698 }
4700 {
4701 uint32 unitCount = 0;
4702 ObjectVector targets;
4703 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4704
4705 if (!targets.empty())
4706 {
4707 if (e.event.nearUnit.type)
4708 {
4709 for (WorldObject* target : targets)
4710 {
4711 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4712 unitCount++;
4713 }
4714 }
4715 else
4716 {
4717 for (WorldObject* target : targets)
4718 {
4719 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4720 unitCount++;
4721 }
4722 }
4723
4724 if (unitCount >= e.event.nearUnit.count)
4725 ProcessAction(e, unit);
4726 }
4728 break;
4729 }
4731 {
4732 uint32 unitCount = 0;
4733 ObjectVector targets;
4734 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4735
4736 if (!targets.empty())
4737 {
4739 {
4740 for (WorldObject* target : targets)
4741 {
4742 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4743 unitCount++;
4744 }
4745 }
4746 else
4747 {
4748 for (WorldObject* target : targets)
4749 {
4750 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4751 unitCount++;
4752 }
4753 }
4754
4755 if (unitCount < e.event.nearUnitNegation.count)
4756 ProcessAction(e, unit);
4757 }
4759 break;
4760 }
4762 {
4763 if (!me || !me->IsEngaged())
4764 return;
4765
4767 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4768 {
4769 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4770 {
4771 if (!target || !IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4772 continue;
4773
4774 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4775 continue;
4776
4777 ProcessAction(e, target);
4779 return;
4780 }
4781
4782 // If no targets are found and it's off cooldown, check again in 1200ms
4783 RecalcTimer(e, 1200, 1200);
4784 break;
4785 }
4786
4787 break;
4788 }
4790 {
4791 if (!me || !me->IsEngaged())
4792 return;
4793
4795 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4796 {
4797 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4798 {
4799 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4800 continue;
4801
4802 ProcessAction(e, target);
4804 return;
4805 }
4806 }
4807
4808 // If no targets are found and it's off cooldown, check again
4809 RecalcTimer(e, 1200, 1200);
4810 break;
4811 }
4814 {
4815 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4816 return;
4817 ProcessAction(e, unit);
4818 break;
4819 }
4820 default:
4821 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4822 break;
4823 }
4824}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1941
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:552
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:551
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:125
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:190
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:126
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:140
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:169
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:171
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:148
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:136
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:167
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:120
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:184
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:164
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:191
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:163
@ SMART_EVENT_WAYPOINT_PAUSED
Definition SmartScriptMgr.h:173
@ SMART_EVENT_WAYPOINT_DATA_ENDED
Definition SmartScriptMgr.h:217
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:139
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:160
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:138
@ SMART_EVENT_WAYPOINT_DATA_REACHED
Definition SmartScriptMgr.h:216
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:189
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:172
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:147
@ SMART_EVENT_WAYPOINT_START
Definition SmartScriptMgr.h:157
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:149
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:186
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:123
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:161
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:182
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:180
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:215
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:145
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:159
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:176
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:137
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:195
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:134
@ SMART_EVENT_WAYPOINT_RESUMED
Definition SmartScriptMgr.h:174
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:142
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:129
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:165
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:132
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:124
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:162
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:187
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:150
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:183
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:166
@ SMART_EVENT_WAYPOINT_STOPPED
Definition SmartScriptMgr.h:175
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:202
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:133
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:122
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:130
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:131
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:151
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:141
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:135
@ CURRENT_GENERIC_SPELL
Definition Unit.h:539
uint32 GetWaypointPath() const
Definition Creature.h:351
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5285
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5275
void ProcessAction(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:163
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5368
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5248
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5414
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5261
void ProcessTimedAction(SmartScriptHolder &e, uint32 const &min, uint32 const &max, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:3319
Definition Spell.h:294
float GetHealthPct() const
Definition Unit.h:1035
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4155
uint32 GetMaxHealth() const
Definition Unit.h:1034
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:666
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5747
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1061
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10311
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:10306
bool IsInCombat() const
Definition Unit.h:881
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1497
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2472
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2486
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition Object.cpp:1326
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:141
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:272
uint32 pointId
Definition SmartScriptMgr.h:524
uint32 invert
Definition SmartScriptMgr.h:510
uint32 entry
Definition SmartScriptMgr.h:463
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:358
LOSHostilityMode
Definition SmartScriptMgr.h:540
uint32 cooldownMax
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:371
uint32 radius
Definition SmartScriptMgr.h:292
uint32 maxDist
Definition SmartScriptMgr.h:263
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:415
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:252
uint32 rangeMin
Definition SmartScriptMgr.h:237
uint32 eventId
Definition SmartScriptMgr.h:442
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:464
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:286
uint32 emote
Definition SmartScriptMgr.h:329
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:456
uint32 filter
Definition SmartScriptMgr.h:410
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:262
uint32 hpDeficit
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:273
uint32 count
Definition SmartScriptMgr.h:337
uint32 onlyInCombat
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:364
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:372
SAIBool playerOnly
Definition SmartScriptMgr.h:245
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:525
uint32 creatureEntry
Definition SmartScriptMgr.h:400
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:416
struct SmartEvent::@30::@64 doAction
struct SmartEvent::@30::@46 charm
struct SmartEvent::@30::@63 eventInform
struct SmartEvent::@30::@38 targetCasting
uint32 spell
Definition SmartScriptMgr.h:251
uint32 maxCount
Definition SmartScriptMgr.h:487
uint32 gameEventId
Definition SmartScriptMgr.h:432
uint32 textGroupID
Definition SmartScriptMgr.h:399
uint32 cooldownMin
Definition SmartScriptMgr.h:243
uint32 onRemove
Definition SmartScriptMgr.h:344
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:322
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:437
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:238
uint32 team
Definition SmartScriptMgr.h:387
uint32 range
Definition SmartScriptMgr.h:499
uint32 minCount
Definition SmartScriptMgr.h:478
struct SmartEvent::@30::@37 minMax
struct SmartEvent::@30::@55 textOver
struct SmartEvent::@30::@40 friendlyCC
struct SmartEvent::@30::@62 goStateChanged
uint32 creature
Definition SmartScriptMgr.h:246
uint32 phasemask
Definition SmartScriptMgr.h:427

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

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

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

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

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

◆ ProcessTimedAction()

void SmartScript::ProcessTimedAction ( SmartScriptHolder e,
uint32 const &  min,
uint32 const &  max,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
3320{
3321 // xinef: extended by selfs victim
3322 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3323 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3324
3325 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3326 {
3327 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3328 RecalcTimer(e, min, max);
3329 }
3330 else
3331 RecalcTimer(e, 5000, 5000);
3332}

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

Referenced by ProcessEvent().

◆ RaisePriority()

void SmartScript::RaisePriority ( SmartScriptHolder e)
private
5062{
5063 e.timer = 1200;
5064 // Change priority only if it's set to default, otherwise keep the current order of events
5066 {
5068 mEventSortingRequired = true;
5069 }
5070}
uint32 timer
Definition SmartScriptMgr.h:1998
uint32 priority
Definition SmartScriptMgr.h:1999

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

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

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

◆ RemoveCreatureSummon()

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

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

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

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

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

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

Referenced by OnReset(), and ProcessAction().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
5073{
5074 RaisePriority(e);
5075
5076 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5077 if (ignoreChanceRoll)
5079
5080 e.runOnce = false;
5081}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5061

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

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

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
5057{
5058 std::sort(events.begin(), events.end());
5059}
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:2018

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

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

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

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ executionStack

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

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

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

◆ mCounterList

CounterMap SmartScript::mCounterList

◆ mCurrentPriority

uint32 SmartScript::mCurrentPriority
private

Referenced by RaisePriority(), and SmartScript().

◆ me

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

◆ mEvents

◆ mEventSortingRequired

bool SmartScript::mEventSortingRequired
private

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Referenced by AddEvent(), and InstallEvents().

◆ mLastInvoker

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

◆ mPathId

uint32 SmartScript::mPathId
private

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

◆ mRemIDs

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

Referenced by OnUpdate(), and ProcessAction().

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

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

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

◆ mTemplate

SMARTAI_TEMPLATE SmartScript::mTemplate
private

Referenced by InstallTemplate(), and SmartScript().

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

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

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

◆ trigger

AreaTrigger const* SmartScript::trigger
private

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