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:1766
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1519
uint32 mEventPhase
Definition SmartScript.h:230
SMARTAI_TEMPLATE mTemplate
Definition SmartScript.h:249
Creature * me
Definition SmartScript.h:224
uint32 mPathId
Definition SmartScript.h:233
SmartScriptType mScriptType
Definition SmartScript.h:229
bool _allowPhaseReset
Definition SmartScript.h:245
bool mUseTextTimer
Definition SmartScript.h:240
uint32 mLastTextID
Definition SmartScript.h:238
uint32 mTextTimer
Definition SmartScript.h:237
GameObject * go
Definition SmartScript.h:226
AreaTrigger const * trigger
Definition SmartScript.h:228
uint32 mCurrentPriority
Definition SmartScript.h:241
uint32 mTalkerEntry
Definition SmartScript.h:239
bool isProcessingTimedActionList
Definition SmartScript.h:223
bool mEventSortingRequired
Definition SmartScript.h:242

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

◆ ~SmartScript()

SmartScript::~SmartScript ( )
66{
67}

Member Function Documentation

◆ AddCreatureSummon()

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

References _summonList.

Referenced by SmartAI::JustSummoned().

◆ AddEvent()

void SmartScript::AddEvent ( SMART_EVENT  e,
uint32  event_flags,
uint32  event_param1,
uint32  event_param2,
uint32  event_param3,
uint32  event_param4,
uint32  event_param5,
uint32  event_param6,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
3410{
3411 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));
3412}
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:3414

References CreateSmartEvent(), and mInstallEvents.

Referenced by InstallTemplate().

◆ AllowPhaseReset()

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

References _allowPhaseReset.

Referenced by OnReset().

◆ CheckTimer()

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

References SmartScriptHolder::active.

◆ CreateSmartEvent()

SmartScriptHolder SmartScript::CreateSmartEvent ( SMART_EVENT  e,
uint32  event_flags,
uint32  event_param1,
uint32  event_param2,
uint32  event_param3,
uint32  event_param4,
uint32  event_param5,
uint32  event_param6,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
static
3415{
3416 SmartScriptHolder script;
3417 script.event.type = e;
3418 script.event.raw.param1 = event_param1;
3419 script.event.raw.param2 = event_param2;
3420 script.event.raw.param3 = event_param3;
3421 script.event.raw.param4 = event_param4;
3422 script.event.raw.param5 = event_param5;
3423 script.event.raw.param6 = event_param6;
3424 script.event.event_phase_mask = phaseMask;
3425 script.event.event_flags = event_flags;
3426 script.event.event_chance = 100;
3427
3428 script.action.type = action;
3429 script.action.raw.param1 = action_param1;
3430 script.action.raw.param2 = action_param2;
3431 script.action.raw.param3 = action_param3;
3432 script.action.raw.param4 = action_param4;
3433 script.action.raw.param5 = action_param5;
3434 script.action.raw.param6 = action_param6;
3435
3436 script.target.type = t;
3437 script.target.raw.param1 = target_param1;
3438 script.target.raw.param2 = target_param2;
3439 script.target.raw.param3 = target_param3;
3440 script.target.raw.param4 = target_param4;
3441
3443 InitTimer(script);
3444 return script;
3445}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4824
uint32 param3
Definition SmartScriptMgr.h:1074
uint32 param5
Definition SmartScriptMgr.h:1076
uint32 param1
Definition SmartScriptMgr.h:1072
SMART_ACTION type
Definition SmartScriptMgr.h:759
uint32 param4
Definition SmartScriptMgr.h:1075
uint32 param6
Definition SmartScriptMgr.h:1506
struct SmartAction::@75::@194 raw
uint32 param2
Definition SmartScriptMgr.h:1073
uint32 param1
Definition SmartScriptMgr.h:530
uint32 event_flags
Definition SmartScriptMgr.h:228
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition SmartScriptMgr.h:226
uint32 param2
Definition SmartScriptMgr.h:531
uint32 param4
Definition SmartScriptMgr.h:533
uint32 param3
Definition SmartScriptMgr.h:532
uint32 param6
Definition SmartScriptMgr.h:535
uint32 event_chance
Definition SmartScriptMgr.h:227
uint32 param5
Definition SmartScriptMgr.h:534
SMART_EVENT type
Definition SmartScriptMgr.h:225
Definition SmartScriptMgr.h:1967
SmartAction action
Definition SmartScriptMgr.h:1978
SmartScriptType source_type
Definition SmartScriptMgr.h:1973
SmartEvent event
Definition SmartScriptMgr.h:1977
SmartTarget target
Definition SmartScriptMgr.h:1979
uint32 param4
Definition SmartScriptMgr.h:1741
uint32 param1
Definition SmartScriptMgr.h:1738
uint32 param3
Definition SmartScriptMgr.h:1740
struct SmartTarget::@196::@220 raw
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1590
uint32 param2
Definition SmartScriptMgr.h:1739

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

Referenced by AddEvent(), and ProcessAction().

◆ DecPhase()

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

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

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

References me, and Cell::VisitAllObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

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

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

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

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

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

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

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

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ FillScript()

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

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

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

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

References go, and me.

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

◆ GetCounterValue()

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

References mCounterList.

Referenced by ProcessEvent().

◆ GetLastInvoker()

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

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

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

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

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

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

Referenced by OnInitialize().

◆ GetStoredTargetVector()

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

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3448{
3449 WorldObject* scriptTrigger = nullptr;
3450 if (invoker)
3451 scriptTrigger = invoker;
3452 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3453 scriptTrigger = tempLastInvoker;
3454
3455 WorldObject* baseObject = GetBaseObject();
3456
3457 switch (e.GetTargetType())
3458 {
3459 case SMART_TARGET_SELF:
3460 if (baseObject)
3461 targets.push_back(baseObject);
3462 break;
3464 if (me)
3465 if (Unit* victim = me->GetVictim())
3466 targets.push_back(victim);
3467 break;
3469 if (me)
3470 {
3471 if (e.target.hostileRandom.powerType)
3472 {
3473 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)))
3474 targets.push_back(u);
3475 }
3476 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3477 targets.push_back(u);
3478 }
3479 break;
3481 if (me)
3482 {
3483 if (e.target.hostileRandom.powerType)
3484 {
3485 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)))
3486 targets.push_back(u);
3487 }
3488 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3489 targets.push_back(u);
3490 }
3491 break;
3493 if (me)
3494 {
3495 if (e.target.hostileRandom.powerType)
3496 {
3497 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)))
3498 targets.push_back(u);
3499 }
3500 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3501 targets.push_back(u);
3502 }
3503 break;
3505 if (me)
3506 {
3507 if (e.target.hostileRandom.powerType)
3508 {
3509 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)))
3510 targets.push_back(u);
3511 }
3512 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3513 targets.push_back(u);
3514 }
3515 break;
3517 if (me)
3518 {
3519 if (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)))
3520 targets.push_back(u);
3521 }
3522 break;
3524 if (scriptTrigger)
3525 targets.push_back(scriptTrigger);
3526 break;
3528 if (scriptTrigger && IsUnit(scriptTrigger))
3529 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3530 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3531 break;
3533 if (scriptTrigger)
3534 {
3535 if (Player* player = scriptTrigger->ToPlayer())
3536 {
3537 if (Group* group = player->GetGroup())
3538 {
3539 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3540 if (Player* member = groupRef->GetSource())
3541 {
3542 if (member->IsInMap(player))
3543 targets.push_back(member);
3544
3545 if (e.target.invokerParty.includePets)
3546 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3547 if (pet->IsPet() && pet->IsInMap(player))
3548 targets.push_back(pet);
3549 }
3550 }
3551 // We still add the player to the list if there is no group. If we do
3552 // this even if there is a group (thus the else-check), it will add the
3553 // same player to the list twice. We don't want that to happen.
3554 else
3555 targets.push_back(scriptTrigger);
3556 }
3557 }
3558 break;
3560 {
3561 WorldObject* ref = baseObject;
3562 if (!ref)
3563 ref = scriptTrigger;
3564
3565 if (!ref)
3566 {
3567 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3568 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3569 break;
3570 }
3571
3572 ObjectVector units;
3573 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3574
3575 for (WorldObject* unit : units)
3576 {
3577 if (!IsCreature(unit))
3578 continue;
3579
3580 if (me && me->GetGUID() == unit->GetGUID())
3581 continue;
3582
3583 // check alive state - 1 alive, 2 dead, 0 both
3584 if (uint32 state = e.target.unitRange.livingState)
3585 {
3586 if (unit->ToCreature()->IsAlive() && state == 2)
3587 continue;
3588 if (!unit->ToCreature()->IsAlive() && state == 1)
3589 continue;
3590 }
3591
3592 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))
3593 targets.push_back(unit);
3594 }
3595
3596 break;
3597 }
3599 {
3600 ObjectVector units;
3601 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3602
3603 for (WorldObject* unit : units)
3604 {
3605 if (!IsCreature(unit))
3606 continue;
3607
3608 if (me && me->GetGUID() == unit->GetGUID())
3609 continue;
3610
3611 // check alive state - 1 alive, 2 dead, 0 both
3612 if (uint32 state = e.target.unitDistance.livingState)
3613 {
3614 if (unit->ToCreature()->IsAlive() && state == 2)
3615 continue;
3616 if (!unit->ToCreature()->IsAlive() && state == 1)
3617 continue;
3618 }
3619
3620 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3621 targets.push_back(unit);
3622 }
3623
3624 break;
3625 }
3627 {
3628 ObjectVector units;
3629 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3630
3631 for (WorldObject* unit : units)
3632 {
3633 if (!IsGameObject(unit))
3634 continue;
3635
3636 if (go && go->GetGUID() == unit->GetGUID())
3637 continue;
3638
3639 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3640 targets.push_back(unit);
3641 }
3642
3643 break;
3644 }
3646 {
3647
3648 WorldObject* ref = baseObject;
3649 if (!ref)
3650 ref = scriptTrigger;
3651
3652 if (!ref)
3653 {
3654 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3655 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3656 break;
3657 }
3658
3659 ObjectVector units;
3660 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3661
3662 for (WorldObject* unit : units)
3663 {
3664 if (!IsGameObject(unit))
3665 continue;
3666
3667 if (go && go->GetGUID() == unit->GetGUID())
3668 continue;
3669
3670 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))
3671 targets.push_back(unit);
3672 }
3673
3674 break;
3675 }
3677 {
3678 if (!scriptTrigger && !baseObject)
3679 {
3680 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3681 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3682 break;
3683 }
3684
3685 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3686 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3687 targets.push_back(target);
3688 break;
3689 }
3691 {
3692 if (!scriptTrigger && !GetBaseObject())
3693 {
3694 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3695 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3696 break;
3697 }
3698
3699 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3700 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3701 targets.push_back(target);
3702 break;
3703 }
3705 {
3706 ObjectVector units;
3707 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3708
3709 if (!units.empty() && baseObject)
3710 for (WorldObject* unit : units)
3711 if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3712 targets.push_back(unit);
3713
3714 if (e.target.playerRange.maxCount)
3715 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3716
3717 break;
3718 }
3720 {
3721 ObjectVector units;
3722 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3723
3724 for (WorldObject* unit : units)
3725 if (IsPlayer(unit))
3726 targets.push_back(unit);
3727 break;
3728 }
3730 {
3731 WorldObject* ref = baseObject;
3732 if (!ref)
3733 ref = scriptTrigger;
3734
3735 if (!ref)
3736 {
3737 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3738 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3739 break;
3740 }
3741
3742 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3743 targets.assign(stored->begin(), stored->end());
3744 break;
3745 }
3747 {
3748 WorldObject* ref = baseObject;
3749
3750 if (!ref)
3751 ref = scriptTrigger;
3752
3753 if (!ref)
3754 {
3755 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3756 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3757 break;
3758 }
3759
3760 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3761 if (target)
3762 targets.push_back(target);
3763 break;
3764 }
3766 {
3767 WorldObject* ref = baseObject;
3768
3769 if (!ref)
3770 ref = scriptTrigger;
3771
3772 if (!ref)
3773 {
3774 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3775 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3776 break;
3777 }
3778
3779 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3780 if (target)
3781 targets.push_back(target);
3782 break;
3783 }
3785 {
3786 WorldObject* ref = baseObject;
3787
3788 if (!ref)
3789 ref = scriptTrigger;
3790
3791 if (!ref)
3792 {
3793 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3794 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3795 break;
3796 }
3797
3798 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3799 targets.push_back(target);
3800 break;
3801 }
3803 /*
3804 * Owners/Summoners should be WorldObjects. This allows to have other objects
3805 * such as gameobjects to execute SmartScripts using this type of target.
3806 * Otherwise, only Units like creatures can summon other creatures.
3807 */
3808 {
3809 if (me)
3810 {
3812 {
3813 targets.push_back(owner);
3814 }
3815 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3816 {
3817 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3818 }
3819 }
3820 else if (go)
3821 {
3823 {
3824 targets.push_back(owner);
3825 }
3826 }
3827
3828 // xinef: Get owner of owner
3829 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3830 {
3831 if (WorldObject* owner = targets.front())
3832 {
3833 targets.clear();
3834
3835 if (owner->ToCreature())
3836 {
3837 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3838 {
3839 targets.push_back(base);
3840 }
3841 }
3842 else
3843 {
3844 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3845 {
3846 targets.push_back(base);
3847 }
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 if (InstanceScript* instance = GetBaseObject()->GetInstanceScript())
3994 {
3995 if (e.target.instanceStorage.type == 1)
3996 {
3997 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
3998 {
3999 targets.push_back(creature);
4000 }
4001 }
4002 else if (e.target.instanceStorage.type == 2)
4003 {
4004 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4005 {
4006 targets.push_back(go);
4007 }
4008 }
4009 }
4010 else
4011 {
4012 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4013 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4014 }
4015
4016 break;
4017 }
4018 case SMART_TARGET_NONE:
4020 default:
4021 break;
4022 }
4023}
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:865
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition ScriptedCreature.cpp:870
Powers
Definition SharedDefines.h:268
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition SmartScriptMgr.h:1760
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1759
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1761
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1557
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1549
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1541
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1536
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1546
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1559
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1543
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1540
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1547
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1570
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1532
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1545
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1539
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1535
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1544
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1533
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1531
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1567
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1569
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1537
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1538
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1534
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1571
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1558
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1554
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1530
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1548
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1542
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2004
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:2392
CreatureAI * AI() const
Definition Creature.h:141
Definition GameObject.h:120
ObjectGuid GetOwnerGUID() const
Definition GameObject.h:173
Definition GroupReference.h:27
Definition Group.h:169
Definition InstanceScript.h:143
Creature * GetCreature(ObjectGuid const guid)
Definition Map.cpp:2389
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:1083
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5351
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5356
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5361
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5340
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4025
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5377
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5293
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:142
Unit * GetSummonerUnit() const
Definition TemporarySummon.cpp:44
std::list< HostileReference * > StorageType
Definition ThreatMgr.h:147
ThreatContainer::StorageType const & GetThreatList() const
Definition ThreatMgr.h:273
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:110
bool IsVehicle() const
Definition Unit.h:750
Vehicle * GetVehicle() const
Definition Unit.h:1839
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition Unit.cpp:649
TempSummon * ToTempSummon()
Definition Unit.h:686
bool IsSummon() const
Definition Unit.h:744
Unit * GetVictim() const
Definition Unit.h:848
ThreatMgr & GetThreatMgr()
Definition Unit.h:898
Vehicle * GetVehicleKit() const
Definition Unit.h:1838
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1222
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:228
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2468
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1397
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::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), ObjectAccessor::GetCreatureOrPetOrVehicle(), Object::GetEntry(), Object::GetGUID(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), Creature::GetLootRecipientGroup(), WorldObject::GetMap(), GameObject::GetOwnerGUID(), Vehicle::GetPassenger(), SmartScriptHolder::GetScriptType(), GetStoredTargetVector(), TempSummon::GetSummonerUnit(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), Unit::GetVehicle(), Unit::GetVehicleKit(), Unit::GetVictim(), ObjectAccessor::GetWorldObject(), GetWorldObjectsInDist(), go, SmartTarget::goClosest, SmartTarget::goDistance, SmartTarget::goGUID, SmartTarget::goRange, SmartTarget::hostileRandom, SmartTarget::id, SmartTarget::includePets, SmartTarget::index, SmartTarget::instanceStorage, SmartTarget::invokerParty, IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, MaxThreat, me, SmartTarget::minDist, MinDistance, MinThreat, SmartTarget::negation, SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, Random, Acore::Containers::RandomResize(), SmartTarget::resize, SmartTarget::roleMask, SmartTarget::roleSelection, SmartTarget::seatMask, WorldObject::SelectNearestPlayer(), Creature::SelectNearestTarget(), UnitAI::SelectTarget(), SMART_TARGET_ACTION_INVOKER, SMART_TARGET_ACTION_INVOKER_VEHICLE, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_ENEMY, SMART_TARGET_CLOSEST_FRIENDLY, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_FARTHEST, SMART_TARGET_GAMEOBJECT_DISTANCE, SMART_TARGET_GAMEOBJECT_GUID, SMART_TARGET_GAMEOBJECT_RANGE, SMART_TARGET_HOSTILE_LAST_AGGRO, SMART_TARGET_HOSTILE_RANDOM, SMART_TARGET_HOSTILE_RANDOM_NOT_TOP, SMART_TARGET_HOSTILE_SECOND_AGGRO, SMART_TARGET_INSTANCE_STORAGE, SMART_TARGET_INVOKER_PARTY, SMART_TARGET_LOOT_RECIPIENTS, SMART_TARGET_NONE, SMART_TARGET_OWNER_OR_SUMMONER, SMART_TARGET_PLAYER_DISTANCE, SMART_TARGET_PLAYER_RANGE, SMART_TARGET_PLAYER_WITH_AURA, SMART_TARGET_POSITION, SMART_TARGET_ROLE_FLAG_DAMAGERS, SMART_TARGET_ROLE_FLAG_HEALERS, SMART_TARGET_ROLE_FLAG_TANKS, SMART_TARGET_ROLE_SELECTION, SMART_TARGET_SELF, SMART_TARGET_STORED, SMART_TARGET_SUMMONED_CREATURES, SMART_TARGET_THREAT_LIST, SMART_TARGET_VEHICLE_PASSENGER, SMART_TARGET_VICTIM, SmartTarget::spellId, SmartTarget::stored, SmartTarget::summonedCreatures, SmartScriptHolder::target, SmartTarget::threatList, Object::ToPlayer(), Unit::ToTempSummon(), Object::ToUnit(), SmartTarget::type, SmartTarget::unitClosest, SmartTarget::unitDistance, SmartTarget::unitGUID, SmartTarget::unitRange, SmartTarget::useCharmerOrOwner, and SmartTarget::vehicle.

Referenced by ProcessAction(), and ProcessEvent().

◆ GetWorldObjectsInDist()

void SmartScript::GetWorldObjectsInDist ( ObjectVector objects,
float  dist 
) const
4026{
4027 WorldObject* obj = GetBaseObject();
4028 if (!obj)
4029 return;
4030
4031 Acore::AllWorldObjectsInRange u_check(obj, dist);
4033 Cell::VisitAllObjects(obj, searcher, dist);
4034}
Definition GridNotifiers.h:1612
Definition GridNotifiers.h:229

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

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

◆ IncPhase()

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

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

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

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

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

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private
4976{
4977 if (!mInstallEvents.empty())
4978 {
4979 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
4980 mEvents.push_back(*i);//must be before UpdateTimers
4981
4982 mInstallEvents.clear();
4983 }
4984}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3336{
3337 if (!GetBaseObject())
3338 return;
3340 {
3341 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3342 return;
3343 }
3344 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3345 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3346 {
3348 {
3349 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);
3350 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);
3351 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);
3352 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);
3353 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);
3354 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);
3355 break;
3356 }
3358 {
3359 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);
3360 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);
3361 break;
3362 }
3364 {
3365 if (!me)
3366 return;
3367 //store cage as id1
3368 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);
3369
3370 //reset(close) cage on hostage(me) respawn
3371 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);
3372
3373 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);
3374 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);
3375
3376 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);
3377 //phase 1: give quest credit on movepoint reached
3379 //phase 1: despawn after time on movepoint reached
3380 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);
3381
3382 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3383 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);
3384 break;
3385 }
3387 {
3388 if (!go)
3389 return;
3390 //store hostage as id1
3391 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);
3392 //store invoker as id2
3393 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);
3394 //signal hostage
3395 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);
3396 //when hostage raeched end point, give credit to invoker
3397 if (e.action.installTtemplate.param2)
3398 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);
3399 else
3400 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);
3401 break;
3402 }
3404 default:
3405 return;
3406 }
3407}
#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:1518
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1523
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1524
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1520
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1521
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1924
@ 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:3409

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

Referenced by ProcessAction().

◆ IsCharmedCreature()

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

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

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

References Object::IsCreature().

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

◆ IsGameObject()

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

References Object::IsGameObject().

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

◆ IsInPhase()

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

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

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

References Object::IsPlayer().

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

◆ IsSmart() [1/3]

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

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

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

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

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

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

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

◆ IsUnit()

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

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

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

◆ OnInitialize()

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

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

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

◆ OnMoveInLineOfSight()

void SmartScript::OnMoveInLineOfSight ( Unit who)
5194{
5195 if (!me)
5196 return;
5197
5199}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:144
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:128
bool IsEngaged() const
Definition Unit.h:876

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:1932
@ 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:1999

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

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

◆ OnUpdate()

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

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

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

◆ ProcessAction()

void SmartScript::ProcessAction ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
164{
165 e.runOnce = true;//used for repeat check
166
167 //calc random
169 {
170 uint32 rnd = urand(1, 100);
171 if (e.event.event_chance <= rnd)
172 return;
173 }
174
175 // Remove SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL flag after processing roll chances as it's not needed anymore
176 e.event.event_flags &= ~SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL;
177
178 if (unit)
179 mLastInvoker = unit->GetGUID();
180 else if (gob)
181 mLastInvoker = gob->GetGUID();
182
183 if (WorldObject* tempInvoker = GetLastInvoker())
184 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: Invoker: {} ({})", tempInvoker->GetName(), tempInvoker->GetGUID().ToString());
185
186 bool isControlled = e.action.moveToPos.controlled > 0;
187
188 ObjectVector targets;
189 WorldObject* invoker = nullptr;
190 if (unit)
191 invoker = unit;
192 else if (gob)
193 invoker = gob;
194
195 GetTargets(targets, e, invoker);
196
197 switch (e.GetActionType())
198 {
200 {
201 Creature* talker = e.target.type == 0 ? me : nullptr;
202 WorldObject* talkTarget = nullptr;
203
204 for (WorldObject* target : targets)
205 {
206 if (IsCreature((target)) && !target->ToCreature()->IsPet()) // Prevented sending text to pets.
207 {
209 {
210 talker = me;
211 talkTarget = target->ToCreature();
212 }
213 else
214 talker = target->ToCreature();
215 break;
216 }
217 else if (IsPlayer((target)))
218 {
219 talker = me; // xinef: added
220 talkTarget = target->ToPlayer();
221 break;
222 }
223 }
224
225 if (!talkTarget)
226 talkTarget = GetLastInvoker();
227
228 if (!talker)
229 break;
230
231 if (!sCreatureTextMgr->TextExist(talker->GetEntry(), uint8(e.action.talk.textGroupID)))
232 {
233 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: EntryOrGuid {} SourceType {} EventType {} TargetType {} using non-existent Text id {} for talker {}, ignored.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetTargetType(), e.action.talk.textGroupID, talker->GetEntry());
234 break;
235 }
236
237 mTalkerEntry = talker->GetEntry();
240 mUseTextTimer = true;
241 sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), talkTarget);
242 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} ({}), textId: {}", talker->GetName(), talker->GetGUID().ToString(), mLastTextID);
243 break;
244 }
246 {
247 for (WorldObject* target : targets)
248 {
249 if (IsCreature(target))
250 sCreatureTextMgr->SendChat(target->ToCreature(), uint8(e.action.simpleTalk.textGroupID), IsPlayer(GetLastInvoker()) ? GetLastInvoker() : 0);
251 else if (IsPlayer(target) && me)
252 {
253 WorldObject* templastInvoker = GetLastInvoker();
254 sCreatureTextMgr->SendChat(me, uint8(e.action.simpleTalk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target->ToPlayer());
255 }
256
257 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: {} ({}), textGroupId: {}",
258 target->GetName(), target->GetGUID().ToString(), uint8(e.action.simpleTalk.textGroupID));
259 }
260 break;
261 }
263 {
264 for (WorldObject* target : targets)
265 {
266 if (IsUnit(target))
267 {
268 target->ToUnit()->HandleEmoteCommand(e.action.emote.emote);
269 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: {} ({}), emote: {}",
270 target->GetName(), target->GetGUID().ToString(), e.action.emote.emote);
271 }
272 }
273 break;
274 }
276 {
277 for (WorldObject* target : targets)
278 {
279 if (IsUnit(target))
280 {
281 if (e.action.sound.distance == 1)
282 target->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
283 else
284 target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
285 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} ({}), sound: {}, onlyself: {}",
286 target->GetName(), target->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
287 }
288 }
289 break;
290 }
292 {
293 uint32 sounds[4];
294 sounds[0] = e.action.randomSound.sound1;
295 sounds[1] = e.action.randomSound.sound2;
296 sounds[2] = e.action.randomSound.sound3;
297 sounds[3] = e.action.randomSound.sound4;
298 uint32 temp[4];
299 uint32 count = 0;
300 for (unsigned int sound : sounds)
301 {
302 if (sound)
303 {
304 temp[count] = sound;
305 ++count;
306 }
307 }
308
309 if (count == 0)
310 {
311 break;
312 }
313
314 for (WorldObject* target : targets)
315 {
316 if (IsUnit(target))
317 {
318 uint32 sound = temp[urand(0, count - 1)];
319 target->PlayDirectSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
320 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
321 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
322 }
323 }
324
325 break;
326 }
328 {
329 ObjectVector targets;
330
331 if (e.action.music.type > 0)
332 {
333 if (me && me->FindMap())
334 {
335 Map::PlayerList const& players = me->GetMap()->GetPlayers();
336
337 if (!players.IsEmpty())
338 {
339 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
340 if (Player* player = i->GetSource())
341 {
342 if (player->GetZoneId() == me->GetZoneId())
343 {
344 if (e.action.music.type > 1)
345 {
346 if (player->GetAreaId() == me->GetAreaId())
347 targets.push_back(player);
348 }
349 else
350 targets.push_back(player);
351 }
352 }
353 }
354 }
355 }
356 else
357 GetTargets(targets, e);
358
359 if (!targets.empty())
360 {
361 for (WorldObject* target : targets)
362 {
363 if (IsUnit(target))
364 {
365 target->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0);
366 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: {} ({}), sound: {}, onlySelf: {}, type: {}",
367 target->GetName(), target->GetGUID().ToString(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type);
368 }
369 }
370 }
371 break;
372 }
374 {
375 ObjectVector targets;
376
377 if (e.action.randomMusic.type > 0)
378 {
379 if (me && me->FindMap())
380 {
381 Map::PlayerList const& players = me->GetMap()->GetPlayers();
382
383 if (!players.IsEmpty())
384 {
385 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
386 if (Player* player = i->GetSource())
387 {
388 if (player->GetZoneId() == me->GetZoneId())
389 {
390 if (e.action.randomMusic.type > 1)
391 {
392 if (player->GetAreaId() == me->GetAreaId())
393 targets.push_back(player);
394 }
395 else
396 targets.push_back(player);
397 }
398 }
399 }
400 }
401 }
402 else
403 GetTargets(targets, e);
404
405 if (targets.empty())
406 break;
407
408 uint32 sounds[4];
409 sounds[0] = e.action.randomMusic.sound1;
410 sounds[1] = e.action.randomMusic.sound2;
411 sounds[2] = e.action.randomMusic.sound3;
412 sounds[3] = e.action.randomMusic.sound4;
413 uint32 temp[4];
414 uint32 count = 0;
415 for (unsigned int sound : sounds)
416 {
417 if (sound)
418 {
419 temp[count] = sound;
420 ++count;
421 }
422 }
423
424 if (count == 0)
425 {
426 break;
427 }
428
429 for (WorldObject* target : targets)
430 {
431 if (IsUnit(target))
432 {
433 uint32 sound = temp[urand(0, count - 1)];
434 target->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0);
435 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: {} ({}), sound: {}, onlyself: {}, type: {}",
436 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type);
437 }
438 }
439
440 break;
441 }
443 {
444 for (WorldObject* target : targets)
445 {
446 if (IsCreature(target))
447 {
449 {
450 target->ToCreature()->SetFaction(e.action.faction.factionID);
451 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
452 target->GetEntry(), target->GetGUID().ToString(), e.action.faction.factionID);
453 }
454 else
455 {
456 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(target->ToCreature()->GetEntry()))
457 {
458 if (target->ToCreature()->GetFaction() != ci->faction)
459 {
460 target->ToCreature()->SetFaction(ci->faction);
461 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
462 target->GetEntry(), target->GetGUID().ToString(), ci->faction);
463 }
464 }
465 }
466 }
467 }
468 break;
469 }
471 {
472 for (WorldObject* target : targets)
473 {
474 if (!IsCreature(target))
475 continue;
476
478 {
479 //set model based on entry from creature_template
481 {
482 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
483 {
484 CreatureModel const* model = ObjectMgr::ChooseDisplayId(ci);
485 target->ToCreature()->SetDisplayId(model->CreatureDisplayID, model->DisplayScale);
486 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
487 target->GetEntry(), target->GetGUID().ToString(), model->CreatureDisplayID);
488 }
489 }
490 //if no param1, then use value from param2 (modelId)
491 else
492 {
493 target->ToCreature()->SetDisplayId(e.action.morphOrMount.model);
494 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
495 target->GetEntry(), target->GetGUID().ToString(), e.action.morphOrMount.model);
496 }
497 }
498 else
499 {
500 target->ToCreature()->DeMorph();
501 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} demorphs.",
502 target->GetEntry(), target->GetGUID().ToString());
503 }
504 }
505 break;
506 }
508 {
509 for (WorldObject* target : targets)
510 {
511 if (IsPlayer(target))
512 {
513 target->ToPlayer()->FailQuest(e.action.quest.quest);
514 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow {} fails quest {}",
515 target->GetGUID().ToString(), e.action.quest.quest);
516 }
517 }
518 break;
519 }
521 {
522 for (WorldObject* target : targets)
523 {
524 if (Player* player = target->ToPlayer())
525 {
526 if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.questOffer.questID))
527 {
528 if (me && e.action.questOffer.directAdd == 0)
529 {
530 if (player->CanTakeQuest(q, true))
531 {
532 if (WorldSession* session = player->GetSession())
533 {
534 PlayerMenu menu(session);
535 menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true);
536 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - offering quest {}",
537 player->GetGUID().ToString(), e.action.questOffer.questID);
538 }
539 }
540 }
541 else
542 {
543 player->AddQuestAndCheckCompletion(q, nullptr);
544 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - quest {} added",
545 player->GetGUID().ToString(), e.action.questOffer.questID);
546 }
547 }
548 }
549 }
550 break;
551 }
553 {
554 for (WorldObject* target : targets)
555 {
556 if (!IsCreature(target))
557 continue;
558
559 target->ToCreature()->SetReactState(ReactStates(e.action.react.state));
560 }
561 break;
562 }
564 {
565 std::vector<uint32> emotes;
566 std::copy_if(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(),
567 std::back_inserter(emotes), [](uint32 emote) { return emote != 0; });
568
569 for (WorldObject* target : targets)
570 {
571 if (IsUnit(target))
572 {
574 target->ToUnit()->HandleEmoteCommand(emote);
575 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow {} handle random emote {}",
576 target->GetGUID().ToString(), emote);
577 }
578 }
579 break;
580 }
582 {
583 if (!me)
584 break;
585
587 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
588 {
589 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
590 {
592 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}",
593 me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
594 }
595 }
596 break;
597 }
599 {
600 if (!me)
601 break;
602
603 for (WorldObject* target : targets)
604 {
605 if (IsUnit(target))
606 {
607 me->GetThreatMgr().ModifyThreatByPercent(target->ToUnit(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
608 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow {} modify threat for unit {}, value {}",
609 me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
610 }
611 }
612 break;
613 }
615 {
616 for (WorldObject* target : targets)
617 {
618 // Special handling for vehicles
619 if (IsUnit(target))
620 if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
621 for (auto & Seat : vehicle->Seats)
622 if (Player* player = ObjectAccessor::GetPlayer(*target, Seat.second.Passenger.Guid))
623 player->AreaExploredOrEventHappens(e.action.quest.quest);
624
625 if (IsPlayer(target))
626 {
627 target->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest);
628
629 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow {} credited quest {}",
630 target->GetGUID().ToString(), e.action.quest.quest);
631 }
632 }
633 break;
634 }
636 {
637 if (targets.empty())
638 break;
639
640 Unit* caster = me;
641 // Areatrigger Cast!
643 caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
644
647
648 bool failedSpellCast = false, successfulSpellCast = false;
649
650 for (WorldObject* target : targets)
651 {
652 // may be nullptr
653 if (go)
654 go->CastSpell(target->ToUnit(), e.action.cast.spell);
655
656 if (!IsUnit(target))
657 continue;
658
659 if (caster && caster != me) // Areatrigger cast
660 {
661 caster->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
662 }
663 else if (me)
664 {
665 // If target has the aura, skip
666 if ((e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) && target->ToUnit()->HasAura(e.action.cast.spell))
667 continue;
668
669 // If the threatlist is a singleton, cancel
671 if (me->GetThreatMgr().GetThreatListSize() <= 1)
672 break;
673
674 // If target does not use mana, skip
675 if ((e.action.cast.castFlags & SMARTCAST_TARGET_POWER_MANA) && !target->ToUnit()->GetPower(POWER_MANA))
676 continue;
677
678 // Interrupts current spellcast
681
682 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
683 float distanceToTarget = me->GetDistance(target->ToUnit());
684 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
685 float spellMinRange = me->GetSpellMinRangeForTarget(target->ToUnit(), spellInfo);
686 float meleeRange = me->GetMeleeRange(target->ToUnit());
687
688 bool isWithinLOSInMap = me->IsWithinLOSInMap(target->ToUnit());
689 bool isWithinMeleeRange = distanceToTarget <= meleeRange;
690 bool isRangedAttack = spellMaxRange > NOMINAL_MELEE_RANGE;
691 bool isTargetRooted = target->ToUnit()->HasUnitState(UNIT_STATE_ROOT);
692 // To prevent running back and forth when OOM, we must have more than 10% mana.
693 bool canCastSpell = me->GetPowerPct(POWER_MANA) > 10.0f && spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()) < (int32)me->GetPower(POWER_MANA) && !me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
694 bool isSpellIgnoreLOS = spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT);
695
696 // If target is rooted we move out of melee range before casting, but not further than spell max range.
697 if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle())
698 {
699 failedSpellCast = true; // Mark spellcast as failed so we can retry it later
700
701 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
702 continue;
703
704 float minDistance = std::max(meleeRange, spellMinRange) - distanceToTarget + NOMINAL_MELEE_RANGE;
705 CAST_AI(SmartAI, me->AI())->MoveAway(std::min(minDistance, spellMaxRange));
706 continue;
707 }
708
709 // Let us not try to cast spell if we know it is going to fail anyway. Stick to chasing and continue.
710 if (distanceToTarget > spellMaxRange && isWithinLOSInMap)
711 {
712 failedSpellCast = true;
713
714 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
715 continue;
716
717 CAST_AI(SmartAI, me->AI())->SetCombatMove(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
718 continue;
719 }
720 else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS))
721 {
722 failedSpellCast = true;
723
724 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
725 continue;
726
727 CAST_AI(SmartAI, me->AI())->SetCombatMove(true);
728 continue;
729 }
730
731 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
733 {
735 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
736 else
737 triggerFlags = TRIGGERED_FULL_MASK;
738 }
739
740 SpellCastResult result = me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
741 bool spellCastFailed = (result != SPELL_CAST_OK && result != SPELL_FAILED_SPELL_IN_PROGRESS);
742
744 {
745 if (!me->isMoving()) // Don't try to reposition while we are moving
746 {
747 // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed unless target is outside spell range, out of mana, or LOS.
748 if (result == SPELL_FAILED_OUT_OF_RANGE)
749 // if we are just out of range, we only chase until we are back in spell range.
750 CAST_AI(SmartAI, me->AI())->SetCombatMove(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
751 else
752 // if spell fail for any other reason, we chase to melee range, or stay where we are if spellcast was successful.
753 CAST_AI(SmartAI, me->AI())->SetCombatMove(spellCastFailed);
754 }
755 }
756
757 if (spellCastFailed)
758 failedSpellCast = true;
759 else
760 successfulSpellCast = true;
761
762 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
763 me->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
764 }
765 }
766
767 // If there is at least 1 failed cast and no successful casts at all, retry again on next loop
768 if (failedSpellCast && !successfulSpellCast)
769 {
770 RetryLater(e, true);
771 // Don't execute linked events
772 return;
773 }
774
775 break;
776 }
778 {
779 if (targets.empty())
780 break;
781
784
785 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
787 {
789 {
790 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
791 }
792 else
793 {
794 triggerFlags = TRIGGERED_FULL_MASK;
795 }
796 }
797
798 for (WorldObject* target : targets)
799 {
800 Unit* uTarget = target->ToUnit();
801 if (!uTarget)
802 continue;
803
805 {
807 {
808 uTarget->InterruptNonMeleeSpells(false);
809 }
810
811 uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
812 }
813 }
814 break;
815 }
817 {
818 // Can be used for area trigger cast
819 WorldObject* tempLastInvoker = GetLastInvoker(unit);
820 if (!tempLastInvoker)
821 break;
822
823 if (targets.empty())
824 break;
825
828
829 for (WorldObject* target : targets)
830 {
831 if (!IsUnit(target))
832 continue;
833
834 if (!IsUnit(tempLastInvoker))
835 continue;
836
837 if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
838 {
840 {
841 tempLastInvoker->ToUnit()->InterruptNonMeleeSpells(false);
842 }
843
844 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
846 {
848 {
849 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
850 }
851 else
852 {
853 triggerFlags = TRIGGERED_FULL_MASK;
854 }
855 }
856
857 tempLastInvoker->ToUnit()->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
858 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
859 tempLastInvoker->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
860 }
861 else
862 {
863 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
864 e.action.cast.spell, target->GetGUID().ToString());
865 }
866 }
867 break;
868 }
870 {
871 for (WorldObject* target : targets)
872 {
873 if (IsUnit(target))
874 {
875 target->ToUnit()->AddAura(e.action.cast.spell, target->ToUnit());
876 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura {} to unit {}",
877 e.action.cast.spell, target->GetGUID().ToString());
878 }
879 }
880 break;
881 }
883 {
884 for (WorldObject* target : targets)
885 {
886 if (IsGameObject(target))
887 {
888 GameObject* go = target->ToGameObject();
889
890 // Activate
892 {
894 }
895
897 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject {} activated", go->GetGUID().ToString());
898 }
899 }
900
901 break;
902 }
904 {
905 for (WorldObject* target : targets)
906 {
907 if (IsGameObject(target))
908 {
909 target->ToGameObject()->ResetDoorOrButton();
910 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject {} (entry: {}) reset",
911 target->GetGUID().ToString(), target->GetEntry());
912 }
913 }
914 break;
915 }
917 {
918 for (WorldObject* target : targets)
919 {
920 if (IsUnit(target))
921 {
922 target->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
923 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit {} set emotestate to {}",
924 target->GetGUID().ToString(), e.action.emote.emote);
925 }
926 }
927 break;
928 }
930 {
931 for (WorldObject* target : targets)
932 {
933 if (IsUnit(target))
934 {
935 if (!e.action.unitFlag.type)
936 {
937 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
938 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS",
939 target->GetGUID().ToString(), e.action.unitFlag.flag);
940 }
941 else
942 {
943 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
944 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS_2",
945 target->GetGUID().ToString(), e.action.unitFlag.flag);
946 }
947 }
948 }
949 break;
950 }
952 {
953 for (WorldObject* target : targets)
954 {
955 if (IsUnit(target))
956 {
957 if (!e.action.unitFlag.type)
958 {
959 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
960 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS",
961 target->GetGUID().ToString(), e.action.unitFlag.flag);
962 }
963 else
964 {
965 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
966 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS_2",
967 target->GetGUID().ToString(), e.action.unitFlag.flag);
968 }
969 }
970 }
971 break;
972 }
974 {
975 if (!IsSmart())
976 break;
977
978 CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack);
979 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
981 break;
982 }
984 {
985 if (!IsSmart())
986 break;
987
988 bool move = e.action.combatMove.move;
989 CAST_AI(SmartAI, me->AI())->SetCombatMove(move);
990 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature {} bool on = {}",
992 break;
993 }
995 {
996 if (!GetBaseObject())
997 break;
998
1000 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature {} set event phase {}",
1001 GetBaseObject()->GetGUID().ToString(), e.action.setEventPhase.phase);
1002 break;
1003 }
1005 {
1006 if (!GetBaseObject())
1007 break;
1008
1011 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature {} inc event phase by {}, "
1012 "decrease by {}", GetBaseObject()->GetGUID().ToString(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
1013 break;
1014 }
1015 case SMART_ACTION_EVADE:
1016 {
1017 if (!GetBaseObject())
1018 break;
1019
1020 for (WorldObject* target : targets)
1021 if (IsCreature(target))
1022 if (target->ToCreature()->IsAIEnabled)
1023 target->ToCreature()->AI()->EnterEvadeMode();
1024
1025 break;
1026 }
1028 {
1029 // Xinef: do not allow to flee without control (stun, fear etc)
1031 break;
1032
1034 if (e.action.flee.withEmote)
1035 {
1037 sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
1038 }
1039 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature {} DoFleeToGetAssistance", me->GetGUID().ToString());
1040 break;
1041 }
1043 {
1044 if (!me)
1045 break;
1046
1047 me->CombatStop(true);
1048 break;
1049 }
1051 {
1052 for (WorldObject* target : targets)
1053 {
1054 if (!IsUnit(target))
1055 continue;
1056
1057 Unit* unitTarget = target->ToUnit();
1058 // If invoker was pet or charm
1059 Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself();
1060 if (player && GetBaseObject())
1061 {
1062 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1063 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {}, group credit for quest {}",
1064 player->GetGUID().ToString(), e.action.quest.quest);
1065 }
1066
1067 // Special handling for vehicles
1068 if (Vehicle* vehicle = unitTarget->GetVehicleKit())
1069 {
1070 for (auto& Seat : vehicle->Seats)
1071 {
1072 if (Player* player = ObjectAccessor::GetPlayer(*unitTarget, Seat.second.Passenger.Guid))
1073 {
1074 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1075 }
1076 }
1077 }
1078 }
1079 break;
1080 }
1082 {
1083 for (WorldObject* target : targets)
1084 {
1085 if (!IsUnit(target))
1086 continue;
1087
1088 if (e.action.removeAura.spell)
1089 {
1091 {
1092 if (Aura* aur = target->ToUnit()->GetAura(e.action.removeAura.spell))
1093 aur->ModCharges(-static_cast<int32>(e.action.removeAura.charges), AURA_REMOVE_BY_EXPIRE);
1094 }
1095 else
1096 target->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
1097 }
1098 else
1099 target->ToUnit()->RemoveAllAuras();
1100
1101 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {}, spell {}",
1102 target->GetGUID().ToString(), e.action.removeAura.spell);
1103 }
1104 break;
1105 }
1107 {
1108 if (!IsSmart())
1109 break;
1110
1112 {
1113 CAST_AI(SmartAI, me->AI())->StopFollow(false);
1114 break;
1115 }
1116
1117 for (WorldObject* target : targets)
1118 {
1119 if (IsUnit(target))
1120 {
1121 float angle = e.action.follow.angle > 6 ? (e.action.follow.angle * M_PI / 180.0f) : e.action.follow.angle;
1122 CAST_AI(SmartAI, me->AI())->SetFollow(target->ToUnit(), float(e.action.follow.dist) + 0.1f, angle, e.action.follow.credit, e.action.follow.entry, e.action.follow.creditType, e.action.follow.aliveState);
1123 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature {} following target {}",
1124 me->GetGUID().ToString(), target->GetGUID().ToString());
1125 break;
1126 }
1127 }
1128 break;
1129 }
1131 {
1132 if (!GetBaseObject())
1133 break;
1134
1135 std::vector<uint32> phases;
1136 std::copy_if(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(),
1137 std::back_inserter(phases), [](uint32 phase) { return phase != 0; });
1138
1140 SetPhase(phase);
1141 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature {} sets event phase to {}",
1142 GetBaseObject()->GetGUID().ToString(), phase);
1143 break;
1144 }
1146 {
1147 if (!GetBaseObject())
1148 break;
1149
1151 SetPhase(phase);
1152 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature {} sets event phase to {}",
1153 GetBaseObject()->GetGUID().ToString(), phase);
1154 break;
1155 }
1157 {
1158 if (trigger && IsPlayer(unit))
1159 {
1161 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player {}, Killcredit: {}",
1163 }
1164 else if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members
1165 {
1166 if (!me)
1167 break;
1168
1169 if (Player* player = me->GetLootRecipient())
1170 {
1172 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1174 }
1175 }
1176 else // Specific target type
1177 {
1178 for (WorldObject* target : targets)
1179 {
1180 if (!IsUnit(target))
1181 continue;
1182
1184 if (!player)
1185 continue;
1186
1188 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1189 target->GetGUID().ToString(), e.action.killedMonster.creature);
1190 }
1191 }
1192 break;
1193 }
1195 {
1196 WorldObject* obj = GetBaseObject();
1197 if (!obj)
1198 obj = unit;
1199
1200 if (!obj)
1201 break;
1202
1203 InstanceScript* instance = obj->GetInstanceScript();
1204 if (!instance)
1205 {
1206 LOG_ERROR("scripts.ai.sai", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1207 break;
1208 }
1209
1210 switch (e.action.setInstanceData.type)
1211 {
1212 case 0:
1213 {
1215 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: Field: {}, data: {}", e.action.setInstanceData.field, e.action.setInstanceData.data);
1216 } break;
1217 case 1:
1218 {
1220 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: SetBossState BossId: {}, State: {} ({})", e.action.setInstanceData.field, e.action.setInstanceData.data, InstanceScript::GetBossStateName(e.action.setInstanceData.data));
1221 } break;
1222 default:
1223 {
1224 break;
1225 }
1226 }
1227 break;
1228 }
1230 {
1231 WorldObject* obj = GetBaseObject();
1232 if (!obj)
1233 obj = unit;
1234
1235 if (!obj)
1236 break;
1237
1238 InstanceScript* instance = obj->GetInstanceScript();
1239 if (!instance)
1240 {
1241 LOG_ERROR("sql.sql", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1242 break;
1243 }
1244
1245 if (targets.empty())
1246 break;
1247
1248 instance->SetGuidData(e.action.setInstanceData64.field, targets.front()->GetGUID());
1249 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: {}, data: {}",
1250 e.action.setInstanceData64.field, targets.front()->GetGUID().ToString());
1251 break;
1252 }
1254 {
1255 for (WorldObject* target : targets)
1256 if (IsCreature(target))
1257 target->ToCreature()->UpdateEntry(e.action.updateTemplate.creature, target->ToCreature()->GetCreatureData(), e.action.updateTemplate.updateLevel != 0);
1258 break;
1259 }
1260 case SMART_ACTION_DIE:
1261 {
1262 if (e.action.die.milliseconds)
1263 {
1264 if (me && !me->isDead())
1265 {
1267 {
1268 // We need to check again to see if we didn't die in the process.
1269 if (me && !me->isDead())
1270 {
1271 me->KillSelf();
1272 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1273 }
1275 }
1276 }
1277 else if (me && !me->isDead())
1278 {
1279 me->KillSelf();
1280 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1281 }
1282 break;
1283 }
1285 {
1286 if (targets.empty())
1287 break;
1288
1289 if (!me->GetMap()->IsDungeon())
1290 {
1291 ObjectVector units;
1292 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
1293
1294 if (!units.empty() && GetBaseObject())
1295 for (WorldObject* unit : units)
1296 if (IsPlayer(unit) && !unit->ToPlayer()->isDead())
1297 {
1298 me->SetInCombatWith(unit->ToPlayer());
1299 unit->ToPlayer()->SetInCombatWith(me);
1300 me->AddThreat(unit->ToPlayer(), 0.0f);
1301 }
1302 }
1303 else
1304 {
1305 for (WorldObject* target : targets)
1306 {
1307 if (IsCreature(target))
1308 {
1309 target->ToCreature()->SetInCombatWithZone();
1310 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature {}, target: {}",
1311 me->GetGUID().ToString(), target->GetGUID().ToString());
1312 }
1313 }
1314 }
1315
1316 break;
1317 }
1319 {
1320 for (WorldObject* target : targets)
1321 {
1322 if (IsCreature(target))
1323 {
1324 target->ToCreature()->CallForHelp(float(e.action.callHelp.range));
1326 {
1328 sCreatureTextMgr->SendChatPacket(target, builder, CHAT_MSG_MONSTER_EMOTE);
1329 }
1330 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature {}, target: {}",
1331 me->GetGUID().ToString(), target->GetGUID().ToString());
1332 }
1333 }
1334 break;
1335 }
1337 {
1338 if (me)
1339 {
1341 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature {}, State: {}",
1343 }
1344 break;
1345 }
1347 {
1348 for (WorldObject* target : targets)
1349 {
1351 {
1353 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_FORCE_DESPAWN has removeObjectFromWorld set. delay and forceRespawnTimer ignored.");
1354
1355 if (Creature* creature = target->ToCreature())
1356 creature->AddObjectToRemoveList();
1357 else if (GameObject* go = target->ToGameObject())
1359 }
1360 else
1361 {
1362 Milliseconds despawnDelay(e.action.forceDespawn.delay);
1363
1364 // Wait at least one world update tick before despawn, so it doesn't break linked actions.
1365 if (despawnDelay <= 0ms)
1366 despawnDelay = 1ms;
1367
1368 Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
1369 if (Creature* creature = target->ToCreature())
1370 creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1371 else if (GameObject* go = target->ToGameObject())
1372 go->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1373 }
1374 }
1375
1376 break;
1377 }
1379 {
1380 for (WorldObject* target : targets)
1381 {
1382 if (IsUnit(target))
1383 target->ToUnit()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1384 else if (IsGameObject(target))
1385 target->ToGameObject()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1386 }
1387 break;
1388 }
1390 {
1391 for (WorldObject* target : targets)
1392 {
1393 if (!IsUnit(target))
1394 continue;
1395
1397 {
1398 if (e.action.morphOrMount.creature > 0)
1399 {
1400 if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
1401 target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo)->CreatureDisplayID);
1402 }
1403 else
1404 target->ToUnit()->Mount(e.action.morphOrMount.model);
1405 }
1406 else
1407 target->ToUnit()->Dismount();
1408 }
1409 break;
1410 }
1412 {
1413 for (WorldObject* target : targets)
1414 {
1415 if (IsCreature(target))
1416 {
1417 SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI());
1418 if (!ai)
1419 continue;
1420
1421 if (e.action.invincHP.percent)
1422 ai->SetInvincibilityHpLevel(target->ToCreature()->CountPctFromMaxHealth(e.action.invincHP.percent));
1423 else
1425 }
1426 }
1427 break;
1428 }
1430 {
1431 for (WorldObject* target : targets)
1432 {
1433 if (Creature* cTarget = target->ToCreature())
1434 {
1435 CreatureAI* ai = cTarget->AI();
1436 // Make sure we check that the sender is either a creature or gameobject
1437 if (IsSmart(cTarget, true) && (me || go))
1438 {
1439 if (me)
1441 else
1442 ENSURE_AI(SmartAI, ai)->SetData(e.action.setData.field, e.action.setData.data, go);
1443 }
1444 else
1446 }
1447 else if (GameObject* oTarget = target->ToGameObject())
1448 {
1449 GameObjectAI* ai = oTarget->AI();
1450 // Make sure we check that the sender is either a creature or gameobject
1451 if (IsSmart(oTarget, true) && (me || go))
1452 {
1453 if (me)
1455 else
1457 }
1458 else
1460 }
1461 }
1462 break;
1463 }
1465 {
1466 if (!me)
1467 break;
1468
1469 float x, y, z;
1470 me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance);
1472 break;
1473 }
1475 {
1476 if (!me)
1477 break;
1478
1480 break;
1481 }
1483 {
1484 for (WorldObject* target : targets)
1485 if (IsUnit(target))
1486 target->ToUnit()->SetVisible(!!e.action.visibility.state);
1487
1488 break;
1489 }
1491 {
1492 for (WorldObject* target : targets)
1493 target->setActive(!!e.action.setActive.state);
1494 break;
1495 }
1497 {
1498 if (!me)
1499 break;
1500
1501 if (targets.empty())
1502 break;
1503
1504 // attack random target
1505 if (Unit* target = Acore::Containers::SelectRandomContainerElement(targets)->ToUnit())
1506 me->AI()->AttackStart(target);
1507 break;
1508 }
1510 {
1511 for (WorldObject* target : targets)
1512 if (Unit* unitTarget = target->ToUnit())
1513 unitTarget->AttackStop();
1514 break;
1515 }
1517 {
1519 bool preferUnit = flags.HasFlag(SmartActionSummonCreatureFlags::PreferUnit);
1520 WorldObject* summoner = preferUnit ? unit : Coalesce<WorldObject>(GetBaseObject(), unit);
1521 if (!summoner)
1522 break;
1523
1524 bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
1525
1527 {
1528 float range = (float)e.target.randomPoint.range;
1529 Position randomPoint;
1530 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1531 for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
1532 {
1533 if (e.target.randomPoint.self > 0)
1534 randomPoint = me->GetRandomPoint(me->GetPosition(), range);
1535 else
1536 randomPoint = me->GetRandomPoint(srcPos, range);
1537 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, 0, nullptr, personalSpawn))
1538 {
1539 if (unit && e.action.summonCreature.attackInvoker)
1540 summon->AI()->AttackStart(unit);
1542 summon->AI()->AttackStart(me);
1543 }
1544 }
1545 break;
1546 }
1547
1548 float x, y, z, o;
1549 for (WorldObject* target : targets)
1550 {
1551 target->GetPosition(x, y, z, o);
1552 x += e.target.x;
1553 y += e.target.y;
1554 z += e.target.z;
1555 o += e.target.o;
1556 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, nullptr, personalSpawn))
1557 {
1558 if (e.action.summonCreature.attackInvoker == 2) // pussywizard: proper attackInvoker implementation
1559 summon->AI()->AttackStart(unit);
1561 summon->AI()->AttackStart(target->ToUnit());
1563 summon->AI()->AttackStart(me);
1564 }
1565 }
1566
1568 break;
1569
1571 {
1572 if (unit && e.action.summonCreature.attackInvoker)
1573 summon->AI()->AttackStart(unit);
1575 summon->AI()->AttackStart(me);
1576 }
1577 break;
1578 }
1580 {
1581 if (!GetBaseObject())
1582 break;
1583
1584 if (!targets.empty())
1585 {
1586 float x, y, z, o;
1587 for (WorldObject* target : targets)
1588 {
1589 // xinef: allow gameobjects to summon gameobjects!
1590 //if (!IsUnit((*itr)))
1591 // continue;
1592
1593 target->GetPosition(x, y, z, o);
1594 x += e.target.x;
1595 y += e.target.y;
1596 z += e.target.z;
1597 o += e.target.o;
1600 else
1601 target->SummonGameObject(e.action.summonGO.entry, GetBaseObject()->GetPositionX(), GetBaseObject()->GetPositionY(), GetBaseObject()->GetPositionZ(), GetBaseObject()->GetOrientation(), 0, 0, 0, 0, e.action.summonGO.despawnTime);
1602 }
1603 }
1604
1606 break;
1607
1609 break;
1610 }
1612 {
1613 for (WorldObject* target : targets)
1614 {
1615 if (!IsUnit(target))
1616 continue;
1617
1618 Unit::Kill(target->ToUnit(), target->ToUnit());
1619 }
1620
1621 break;
1622 }
1624 {
1625 InstallTemplate(e);
1626 break;
1627 }
1629 {
1630 for (WorldObject* target : targets)
1631 {
1632 if (!IsPlayer(target))
1633 continue;
1634
1635 target->ToPlayer()->AddItem(e.action.item.entry, e.action.item.count);
1636 }
1637 break;
1638 }
1640 {
1641 for (WorldObject* target : targets)
1642 {
1643 if (!IsPlayer(target))
1644 continue;
1645
1646 target->ToPlayer()->DestroyItemCount(e.action.item.entry, e.action.item.count, true);
1647 }
1648 break;
1649 }
1651 {
1653 break;
1654 }
1656 {
1657 for (WorldObject* target : targets)
1658 {
1659 if (IsPlayer(target))
1660 target->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
1661 else if (IsCreature(target))
1662 target->ToCreature()->NearTeleportTo(e.target.x, e.target.y, e.target.z, e.target.o);
1663 }
1664 break;
1665 }
1667 {
1668 if (!IsSmart())
1669 break;
1670
1671 CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly);
1672 // Xinef: Set speed if any
1673 if (e.action.setFly.speed)
1674 me->SetSpeed(MOVE_RUN, float(e.action.setFly.speed / 100.0f), true);
1675
1676 // Xinef: this wil be executed only if state is different
1678 break;
1679 }
1681 {
1682 for (WorldObject* target : targets)
1683 {
1684 if (IsCreature(target))
1685 {
1686 if (IsSmart(target->ToCreature()))
1687 CAST_AI(SmartAI, target->ToCreature()->AI())->SetRun(e.action.setRun.run);
1688 else
1689 target->ToCreature()->SetWalk(e.action.setRun.run ? false : true); // Xinef: reversed
1690 }
1691 }
1692
1693 break;
1694 }
1696 {
1697 if (!IsSmart())
1698 break;
1699
1700 CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim);
1701 break;
1702 }
1704 {
1705 if (!targets.empty())
1706 {
1707 for (WorldObject* target : targets)
1708 {
1709 if (IsCreature(target))
1710 {
1711 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
1713 else
1714 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
1715 }
1716 else if (IsGameObject(target))
1717 {
1718 if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, target->ToGameObject()->AI()))
1720 else
1721 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
1722 }
1723 }
1724 }
1725 else
1727 break;
1728 }
1730 {
1731 if (!IsSmart())
1732 break;
1733
1734 bool run = e.action.wpStart.run != 0;
1735 uint32 entry = e.action.wpStart.pathID;
1736 bool repeat = e.action.wpStart.repeat != 0;
1737
1738 for (WorldObject* target : targets)
1739 {
1740 if (IsPlayer(target))
1741 {
1743 break;
1744 }
1745 }
1746
1748 CAST_AI(SmartAI, me->AI())->StartPath(run, entry, repeat, unit);
1749
1750 uint32 quest = e.action.wpStart.quest;
1751 uint32 DespawnTime = e.action.wpStart.despawnTime;
1752 CAST_AI(SmartAI, me->AI())->mEscortQuestID = quest;
1753 CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
1754 break;
1755 }
1757 {
1758 if (!IsSmart())
1759 break;
1760
1761 uint32 delay = e.action.wpPause.delay;
1762 CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_WAYPOINT_REACHED ? false : true);
1763 break;
1764 }
1766 {
1767 if (!IsSmart())
1768 break;
1769
1770 uint32 DespawnTime = e.action.wpStop.despawnTime;
1771 uint32 quest = e.action.wpStop.quest;
1772 bool fail = e.action.wpStop.fail;
1773 CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
1774 break;
1775 }
1777 {
1778 if (!IsSmart())
1779 break;
1780
1781 CAST_AI(SmartAI, me->AI())->SetWPPauseTimer(0);
1782 break;
1783 }
1785 {
1786 if (!me)
1787 break;
1788
1789 if (e.action.orientation.random > 0)
1790 {
1791 float randomOri = frand(0.0f, 2 * M_PI);
1792 me->SetFacingTo(randomOri);
1794 me->SetOrientation(randomOri);
1795 break;
1796 }
1797
1799 {
1800 float turnOri = me->GetOrientation() + (static_cast<float>(e.action.orientation.turnAngle) * M_PI / 180.0f);
1801 me->SetFacingTo(turnOri);
1803 me->SetOrientation(turnOri);
1804 break;
1805 }
1806
1808 {
1812 }
1813 else if (e.GetTargetType() == SMART_TARGET_POSITION)
1814 {
1815 me->SetFacingTo(e.target.o);
1818 }
1819 else if (!targets.empty())
1820 {
1821 me->SetFacingToObject(*targets.begin());
1823 me->SetInFront(*targets.begin());
1824 }
1825
1826 break;
1827 }
1829 {
1830 for (WorldObject* target : targets)
1831 {
1832 if (!IsPlayer(target))
1833 continue;
1834
1835 target->ToPlayer()->SendMovieStart(e.action.movie.entry);
1836 }
1837 break;
1838 }
1840 {
1841 if (!IsSmart())
1842 break;
1843
1844 WorldObject* target = nullptr;
1845
1846 switch (e.GetTargetType())
1847 {
1849 {
1850 G3D::Vector3 dest(e.target.x, e.target.y, e.target.z);
1852 if (TransportBase* trans = me->GetDirectTransport())
1853 trans->CalculatePassengerPosition(dest.x, dest.y, dest.z);
1854
1855 me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, true, true,
1856 isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE, e.target.o);
1857
1858 break;
1859 }
1861 {
1862 if (me)
1863 {
1864 float range = (float)e.target.randomPoint.range;
1865 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1866 Position randomPoint = me->GetRandomPoint(srcPos, range);
1869 randomPoint.m_positionX,
1870 randomPoint.m_positionY,
1871 randomPoint.m_positionZ,
1872 true,
1873 true,
1875 );
1876
1877 }
1878
1879 break;
1880 }
1881 // Can use target floats as offset
1882 default:
1883 {
1884 // we want to move to random element
1885 if (targets.empty())
1886 return;
1887 else
1889
1890 float x, y, z;
1891 target->GetPosition(x, y, z);
1892
1894 target->GetNearPoint(me, x, y, z, target->GetCombatReach() + e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1895 else if (e.action.moveToPos.ContactDistance)
1896 target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1897
1898 me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, x + e.target.x, y + e.target.y, z + e.target.z, true, true, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1899
1900 break;
1901 }
1902 }
1903
1904 break;
1905 }
1907 {
1908 for (WorldObject* target : targets)
1909 {
1910 if (IsCreature(target))
1911 {
1912 Creature* ctarget = target->ToCreature();
1913 ctarget->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, e.target.x, e.target.y, e.target.z, true, true, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1914 }
1915 }
1916
1917 break;
1918 }
1920 {
1921 for (WorldObject* target : targets)
1922 {
1923 if (IsCreature(target))
1924 target->ToCreature()->Respawn();
1925 else if (IsGameObject(target))
1926 {
1927 // do not modify respawndelay of already spawned gameobjects
1928 if (target->ToGameObject()->isSpawnedByDefault())
1929 target->ToGameObject()->Respawn();
1930 else
1932 }
1933 }
1934 break;
1935 }
1937 {
1938 for (WorldObject* target : targets)
1939 if (IsPlayer(target))
1940 target->ToPlayer()->PlayerTalkClass->SendCloseGossip();
1941 break;
1942 }
1943 case SMART_ACTION_EQUIP:
1944 {
1945 for (WorldObject* target : targets)
1946 {
1947 if (Creature* npc = target->ToCreature())
1948 {
1949 std::array<uint32, MAX_EQUIPMENT_ITEMS> slot;
1950 if (int8 equipId = static_cast<int8>(e.action.equip.entry))
1951 {
1952 EquipmentInfo const* eInfo = sObjectMgr->GetEquipmentInfo(npc->GetEntry(), equipId);
1953 if (!eInfo)
1954 {
1955 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id {} for creature {}", equipId, npc->GetEntry());
1956 break;
1957 }
1958
1959 npc->SetCurrentEquipmentId(equipId);
1960
1961 std::copy(std::begin(eInfo->ItemEntry), std::end(eInfo->ItemEntry), std::begin(slot));
1962 }
1963 else
1964 std::copy(std::begin(e.action.equip.slots), std::end(e.action.equip.slots), std::begin(slot));
1965
1966 for (uint32 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1967 if (!e.action.equip.mask || (e.action.equip.mask & (1 << i)))
1968 npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, slot[i]);
1969 }
1970 }
1971 break;
1972 }
1974 {
1975 SmartEvent ne = SmartEvent();
1978 if (!ne.event_chance) ne.event_chance = 100;
1979
1984
1985 ne.event_flags = 0;
1988
1989 SmartAction ac = SmartAction();
1992
1994 ev.event = ne;
1995 ev.event_id = e.action.timeEvent.id;
1996 ev.target = e.target;
1997 ev.action = ac;
1998 InitTimer(ev);
1999 mStoredEvents.push_back(ev);
2000 break;
2001 }
2004
2005 // xinef: remove this event if not repeatable
2007 mRemIDs.push_back(e.action.timeEvent.id);
2008 break;
2010 mRemIDs.push_back(e.action.timeEvent.id);
2011 break;
2013 {
2014 for (WorldObject* target : targets)
2015 {
2016 if (IsCreature(target))
2017 {
2018 if (!meOrigGUID)
2020 if (!goOrigGUID)
2022 go = nullptr;
2023 me = target->ToCreature();
2024 break;
2025 }
2026 else if (IsGameObject(target))
2027 {
2028 if (!meOrigGUID)
2030 if (!goOrigGUID)
2032 go = target->ToGameObject();
2033 me = nullptr;
2034 break;
2035 }
2036 }
2037
2038 break;
2039 }
2042 break;
2044 OnReset();
2045 break;
2047 {
2048 if (!IsSmart())
2049 break;
2050
2051 float attackDistance = float(e.action.setRangedMovement.distance);
2052 float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI);
2053
2054 for (WorldObject* target : targets)
2055 if (Creature* creature = target->ToCreature())
2056 if (IsSmart(creature) && creature->GetVictim())
2057 if (CAST_AI(SmartAI, creature->AI())->CanCombatMove())
2058 creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, attackAngle);
2059
2060 break;
2061 }
2063 {
2065 {
2066 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2067 break;
2068 }
2069
2070 for (WorldObject* target : targets)
2071 {
2072 if (Creature* creature = target->ToCreature())
2073 {
2074 if (IsSmart(creature))
2075 CAST_AI(SmartAI, creature->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
2076 }
2077 else if (GameObject* go = target->ToGameObject())
2078 {
2079 if (IsSmart(go))
2081 }
2082 }
2083 break;
2084 }
2086 {
2087 for (WorldObject* target : targets)
2088 if (IsCreature(target))
2089 target->ToUnit()->ReplaceAllNpcFlags(NPCFlags(e.action.unitFlag.flag));
2090 break;
2091 }
2093 {
2094 for (WorldObject* target : targets)
2095 if (IsCreature(target))
2096 target->ToUnit()->SetNpcFlag(NPCFlags(e.action.unitFlag.flag));
2097 break;
2098 }
2100 {
2101 for (WorldObject* target : targets)
2102 if (IsCreature(target))
2103 target->ToUnit()->RemoveNpcFlag(NPCFlags(e.action.unitFlag.flag));
2104 break;
2105 }
2107 {
2108 if (targets.empty())
2109 break;
2110
2111 ObjectVector casters;
2113
2114 for (WorldObject* caster : casters)
2115 {
2116 if (!IsUnit(caster))
2117 continue;
2118
2119 Unit* casterUnit = caster->ToUnit();
2120
2121 bool interruptedSpell = false;
2122
2123 for (WorldObject* target : targets)
2124 {
2125 if (!IsUnit(target))
2126 continue;
2127
2129 {
2130 if (!interruptedSpell && e.action.crossCast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
2131 {
2132 casterUnit->InterruptNonMeleeSpells(false);
2133 interruptedSpell = true;
2134 }
2135
2136 casterUnit->CastSpell(target->ToUnit(), e.action.crossCast.spell, (e.action.crossCast.flags & SMARTCAST_TRIGGERED) != 0);
2137 }
2138 else
2139 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target ({}) already has the aura", e.action.crossCast.spell, target->GetGUID().ToString());
2140 }
2141 }
2142 break;
2143 }
2145 {
2146 std::vector<uint32> actionLists;
2148 std::back_inserter(actionLists), [](uint32 actionList) { return actionList != 0; });
2149
2152 {
2153 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2154 break;
2155 }
2156
2157 for (WorldObject* target : targets)
2158 {
2159 if (Creature* creature = target->ToCreature())
2160 {
2161 if (IsSmart(creature))
2162 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2163 }
2164 else if (GameObject* go = target->ToGameObject())
2165 {
2166 if (IsSmart(go))
2167 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2168 }
2169 }
2170 break;
2171 }
2173 {
2176 {
2177 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2178 break;
2179 }
2180
2181 for (WorldObject* target : targets)
2182 {
2183 if (Creature* creature = target->ToCreature())
2184 {
2185 if (IsSmart(creature))
2186 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2187 }
2188 else if (GameObject* go = target->ToGameObject())
2189 {
2190 if (IsSmart(go))
2191 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2192 }
2193 }
2194 break;
2195 }
2197 {
2198 for (WorldObject* target : targets)
2199 if (IsPlayer(target))
2200 target->ToPlayer()->ActivateTaxiPathTo(e.action.taxi.id);
2201 break;
2202 }
2204 {
2205 bool foundTarget = false;
2206
2207 for (WorldObject* target : targets)
2208 {
2209 if (IsCreature((target)))
2210 {
2211 foundTarget = true;
2212
2215 else
2216 target->ToCreature()->GetMotionMaster()->MoveIdle();
2217 }
2218 }
2219
2220 if (!foundTarget && me && IsCreature(me) && me->IsAlive())
2221 {
2224 else
2226 }
2227 break;
2228 }
2230 {
2231 for (WorldObject* target : targets)
2232 if (IsUnit(target))
2233 target->ToUnit()->SetByteFlag(UNIT_FIELD_BYTES_1, e.action.setunitByte.type, e.action.setunitByte.byte1);
2234 break;
2235 }
2237 {
2238 for (WorldObject* target : targets)
2239 if (IsUnit(target))
2240 target->ToUnit()->RemoveByteFlag(UNIT_FIELD_BYTES_1, e.action.delunitByte.type, e.action.delunitByte.byte1);
2241 break;
2242 }
2244 {
2245 for (WorldObject* target : targets)
2246 if (IsUnit(target))
2247 target->ToUnit()->InterruptNonMeleeSpells(e.action.interruptSpellCasting.withDelayed != 0, e.action.interruptSpellCasting.spell_id, e.action.interruptSpellCasting.withInstant != 0);
2248 break;
2249 }
2251 {
2252 for (WorldObject* target : targets)
2253 if (IsGameObject(target))
2254 target->ToGameObject()->SendCustomAnim(e.action.sendGoCustomAnim.anim);
2255 break;
2256 }
2258 {
2259 for (WorldObject* target : targets)
2260 if (IsUnit(target))
2261 target->ToUnit()->SetUInt32Value(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2262 break;
2263 }
2265 {
2266 for (WorldObject* target : targets)
2267 if (IsUnit(target))
2268 target->ToUnit()->SetFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2269 break;
2270 }
2272 {
2273 for (WorldObject* target : targets)
2274 if (IsUnit(target))
2275 target->ToUnit()->RemoveFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2276 break;
2277 }
2279 {
2281 {
2282 if (me)
2283 {
2284 float range = (float)e.target.randomPoint.range;
2285 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
2286 Position randomPoint = me->GetRandomPoint(srcPos, range);
2287 me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2288 }
2289
2290 break;
2291 }
2292
2293 if (targets.empty())
2294 break;
2295
2296 // xinef: my implementation
2297 if (e.action.jump.selfJump)
2298 {
2300 if (me)
2301 me->GetMotionMaster()->MoveJump(target->GetPositionX() + e.target.x, target->GetPositionY() + e.target.y, target->GetPositionZ() + e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2302 }
2303 else
2304 {
2305 for (WorldObject* target : targets)
2306 if (WorldObject* obj = (target))
2307 {
2308 if (Creature* creature = obj->ToCreature())
2309 creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2310 }
2311 }
2312
2313 break;
2314 }
2316 {
2317 for (WorldObject* target : targets)
2318 if (IsGameObject(target))
2319 target->ToGameObject()->SetLootState((LootState)e.action.setGoLootState.state);
2320 break;
2321 }
2323 {
2324 for (WorldObject* target : targets)
2325 if (IsGameObject(target))
2326 target->ToGameObject()->SetGoState((GOState)e.action.goState.state);
2327 break;
2328 }
2330 {
2331 WorldObject* ref = GetBaseObject();
2332
2333 if (!ref)
2334 ref = unit;
2335
2336 if (!ref)
2337 break;
2338
2339 ObjectVector const* storedTargets = GetStoredTargetVector(e.action.sendTargetToTarget.id, *ref);
2340 if (!storedTargets)
2341 break;
2342
2343 for (WorldObject* target : targets)
2344 {
2345 if (IsCreature(target))
2346 {
2347 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
2348 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2349 else
2350 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
2351 }
2352 else if (IsGameObject(target))
2353 {
2355 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2356 else
2357 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
2358 }
2359 }
2360 break;
2361 }
2363 {
2364 if (!GetBaseObject())
2365 break;
2366
2367 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId {}, gossipNpcTextId {}",
2369
2370 for (WorldObject* target : targets)
2371 if (Player* player = target->ToPlayer())
2372 {
2375 else
2376 ClearGossipMenuFor(player);
2377
2379 }
2380
2381 break;
2382 }
2384 {
2385 if (!targets.empty())
2386 {
2387 float x, y, z, o;
2388 for (WorldObject* target : targets)
2389 if (IsCreature(target))
2390 {
2392 {
2393 target->ToCreature()->GetRespawnPosition(x, y, z, &o);
2394 target->ToCreature()->SetHomePosition(x, y, z, o);
2395 }
2396 else
2397 target->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
2398 }
2399 }
2400 else if (me && e.GetTargetType() == SMART_TARGET_POSITION)
2401 {
2403 {
2404 float x, y, z, o;
2405 me->GetRespawnPosition(x, y, z, &o);
2406 me->SetHomePosition(x, y, z, o);
2407 }
2408 else
2410 }
2411 break;
2412 }
2414 {
2415 for (WorldObject* target : targets)
2416 if (IsCreature(target))
2417 target->ToCreature()->SetRegeneratingHealth(e.action.setHealthRegen.regenHealth);
2418
2419 break;
2420 }
2422 {
2423 for (WorldObject* target : targets)
2424 if (IsCreature(target))
2425 target->ToCreature()->SetControlled(e.action.setRoot.root != 0, UNIT_STATE_ROOT);
2426 break;
2427 }
2429 {
2430 for (WorldObject* target : targets)
2431 if (IsGameObject(target))
2432 target->ToGameObject()->SetUInt32Value(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2433 break;
2434 }
2436 {
2437 for (WorldObject* target : targets)
2438 if (IsGameObject(target))
2439 target->ToGameObject()->SetFlag(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2440 break;
2441 }
2443 {
2444 for (WorldObject* target : targets)
2445 if (IsGameObject(target))
2446 target->ToGameObject()->RemoveFlag(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2447 break;
2448 }
2450 {
2451 std::list<TempSummon*> summonList;
2453
2454 for (std::list<TempSummon*>::const_iterator itr = summonList.begin(); itr != summonList.end(); ++itr)
2455 {
2456 if (unit && e.action.creatureGroup.attackInvoker)
2457 (*itr)->AI()->AttackStart(unit);
2459 (*itr)->AI()->AttackStart(me);
2460 }
2461
2462 break;
2463 }
2465 {
2466 for (WorldObject* target : targets)
2467 if (IsUnit(target))
2468 target->ToUnit()->SetPower(Powers(e.action.power.powerType), e.action.power.newPower);
2469 break;
2470 }
2472 {
2473 for (WorldObject* target : targets)
2474 if (IsUnit(target))
2475 target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) + e.action.power.newPower);
2476 break;
2477 }
2479 {
2480 for (WorldObject* target : targets)
2481 if (IsUnit(target))
2482 target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) - e.action.power.newPower);
2483 break;
2484 }
2486 {
2487 uint32 eventId = e.action.gameEventStop.id;
2488 if (!sGameEventMgr->IsActiveEvent(eventId))
2489 {
2490 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: {})", eventId);
2491 break;
2492 }
2493 sGameEventMgr->StopEvent(eventId, true);
2494 break;
2495 }
2497 {
2498 uint32 eventId = e.action.gameEventStart.id;
2499 if (sGameEventMgr->IsActiveEvent(eventId))
2500 {
2501 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: {})", eventId);
2502 break;
2503 }
2504 sGameEventMgr->StartEvent(eventId, true);
2505 break;
2506 }
2508 {
2509 float distanceToClosest = std::numeric_limits<float>::max();
2510 uint32 closestWpId = 0;
2511
2512 for (WorldObject* target : targets)
2513 {
2514 if (Creature* creature = target->ToCreature())
2515 {
2516 if (IsSmart(creature))
2517 {
2519 {
2520 WPPath* path = sSmartWaypointMgr->GetPath(wp);
2521 if (!path || path->empty())
2522 continue;
2523
2524 auto itrWp = path->find(1);
2525 if (itrWp != path->end())
2526 {
2527 if (WayPoint* wpData = itrWp->second)
2528 {
2529 float distToThisPath = creature->GetExactDistSq(wpData->x, wpData->y, wpData->z);
2530 if (distToThisPath < distanceToClosest)
2531 {
2532 distanceToClosest = distToThisPath;
2533 closestWpId = wp;
2534 }
2535 }
2536 }
2537 }
2538
2539 if (closestWpId)
2540 {
2541 bool repeat = e.action.startClosestWaypoint.repeat;
2542 bool run = e.action.startClosestWaypoint.run;
2543
2544 CAST_AI(SmartAI, creature->AI())->StartPath(repeat, closestWpId, run);
2545 }
2546 }
2547 }
2548 }
2549 break;
2550 }
2552 {
2553 for (WorldObject* target : targets)
2554 if (IsUnit(target))
2555 target->ToUnit()->ExitVehicle();
2556
2557 break;
2558 }
2560 {
2561 for (WorldObject* target : targets)
2562 if (IsUnit(target))
2563 {
2565 target->ToUnit()->SendMovementFlagUpdate();
2566 }
2567
2568 break;
2569 }
2571 {
2572 for (WorldObject* target : targets)
2573 if (IsCreature(target))
2574 target->ToCreature()->m_CombatDistance = e.action.combatDistance.dist;
2575
2576 break;
2577 }
2579 {
2580 for (WorldObject* const target : targets)
2581 if (IsCreature(target))
2582 target->ToCreature()->m_SightDistance = e.action.sightDistance.dist;
2583 break;
2584 }
2585 case SMART_ACTION_FLEE:
2586 {
2587 for (WorldObject* const target : targets)
2588 if (IsCreature(target))
2589 target->ToCreature()->GetMotionMaster()->MoveFleeing(me, e.action.flee.withEmote);
2590 break;
2591 }
2593 {
2594 for (WorldObject* const target : targets)
2595 if (IsUnit(target))
2596 me->AddThreat(target->ToUnit(), float(e.action.threatPCT.threatINC) - float(e.action.threatPCT.threatDEC));
2597 break;
2598 }
2600 {
2601 for (WorldObject* const target : targets)
2602 if (IsCreature(target))
2603 target->ToCreature()->LoadEquipment(e.action.loadEquipment.id, e.action.loadEquipment.force != 0);
2604 break;
2605 }
2607 {
2610 break;
2611 }
2613 {
2614 for (WorldObject* const target : targets)
2615 if (IsUnit(target))
2616 target->ToUnit()->Dismount();
2617 break;
2618 }
2620 {
2621 for (WorldObject* target : targets)
2622 if (IsUnit(target))
2623 target->ToUnit()->SetHover(e.action.setHover.state);
2624 break;
2625 }
2627 {
2628 for (WorldObject* target : targets)
2629 if (IsUnit(target))
2630 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, true);
2631
2632 break;
2633 }
2635 {
2636 for (WorldObject* target : targets)
2637 if (IsUnit(target))
2638 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, false);
2639 break;
2640 }
2641 case SMART_ACTION_FALL:
2642 {
2643 for (WorldObject* target : targets)
2644 if (IsUnit(target))
2645 target->ToUnit()->GetMotionMaster()->MoveFall();
2646
2647 break;
2648 }
2650 {
2652 break;
2653 }
2655 {
2656 for (WorldObject* const target : targets)
2657 if (IsUnit(target))
2658 target->ToUnit()->RemoveAllGameObjects();
2659 break;
2660 }
2662 {
2663 for (WorldObject* const target : targets)
2664 {
2665 if (IsUnit(target))
2666 {
2668 target->ToUnit()->StopMoving();
2670 target->ToUnit()->GetMotionMaster()->MovementExpired();
2671 }
2672 }
2673 break;
2674 }
2676 {
2677 for (WorldObject* target : targets)
2678 if (IsUnit(target))
2679 target->ToUnit()->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
2680
2681 break;
2682 }
2684 {
2685 for (WorldObject* target : targets)
2686 if (IsUnit(target))
2687 if (Player* player = target->ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself())
2688 {
2690 break;
2691 }
2692
2693 break;
2694 }
2696 {
2697 if (me && me->FindMap())
2698 me->FindMap()->LoadGrid(e.target.x, e.target.y);
2699 break;
2700 }
2702 {
2703 std::string text = sObjectMgr->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE);
2704
2705 if (!targets.empty())
2706 for (WorldObject* target : targets)
2707 if (IsPlayer(target))
2708 !e.action.playerTalk.flag ? target->ToPlayer()->Say(text, LANG_UNIVERSAL) : target->ToPlayer()->Yell(text, LANG_UNIVERSAL);
2709
2710 break;
2711 }
2713 {
2714 if (!me)
2715 break;
2716
2717 for (WorldObject* target : targets)
2718 {
2719 if (IsUnit(target))
2720 {
2722 {
2724 }
2725
2727 {
2728 // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed
2729 // unless target is outside spell range, out of mana, or LOS.
2730
2731 bool _allowMove = false;
2732 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.castCustom.spell); // AssertSpellInfo?
2733 int32 mana = me->GetPower(POWER_MANA);
2734
2735 if (me->GetDistance(target->ToUnit()) > spellInfo->GetMaxRange(true) ||
2736 me->GetDistance(target->ToUnit()) < spellInfo->GetMinRange(true) ||
2737 !me->IsWithinLOSInMap(target->ToUnit()) ||
2738 mana < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()))
2739 _allowMove = true;
2740
2741 CAST_AI(SmartAI, me->AI())->SetCombatMove(_allowMove);
2742 }
2743
2745 {
2746 CustomSpellValues values;
2747 if (e.action.castCustom.bp1)
2749 if (e.action.castCustom.bp2)
2751 if (e.action.castCustom.bp3)
2754 }
2755 }
2756 }
2757 break;
2758 }
2760 {
2761 if (!me)
2762 break;
2763
2764 if (targets.empty())
2765 break;
2766
2768
2769 float a = static_cast<float>(e.action.summonVortex.a);
2770 float k = static_cast<float>(e.action.summonVortex.k) / 1000.0f;
2771 float r_max = static_cast<float>(e.action.summonVortex.r_max);
2772 float delta_phi = M_PI * static_cast<float>(e.action.summonVortex.phi_delta) / 180.0f;
2773
2774 // r(phi) = a * e ^ (k * phi)
2775 // r(phi + delta_phi) = a * e ^ (k * (phi + delta_phi))
2776 // r(phi + delta_phi) = a * e ^ (k * phi) * e ^ (k * delta_phi)
2777 // r(phi + delta_phi) = r(phi) * e ^ (k * delta_phi)
2778 float factor = std::exp(k * delta_phi);
2779
2780 // r(0) = a * e ^ (k * 0) = a * e ^ 0 = a * 1 = a
2781 float summonRadius = a;
2782
2783 for (WorldObject* target : targets)
2784 {
2785 // Offset by orientation, should not count into radius calculation,
2786 // but is needed for vortex direction (polar coordinates)
2787 float phi = target->GetOrientation();
2788
2789 do
2790 {
2791 Position summonPosition(*target);
2792 summonPosition.RelocatePolarOffset(phi, summonRadius);
2793
2795
2796 phi += delta_phi;
2797 summonRadius *= factor;
2798 } while (summonRadius <= r_max);
2799 }
2800
2801 break;
2802 }
2804 {
2805 if (!me)
2806 break;
2807
2809
2810 float distInARow = static_cast<float>(e.action.coneSummon.distanceBetweenSummons);
2811 float coneAngle = static_cast<float>(e.action.coneSummon.coneAngle) * M_PI / 180.0f;
2812
2813 for (uint32 radius = 0; radius <= e.action.coneSummon.coneLength; radius += e.action.coneSummon.distanceBetweenRings)
2814 {
2815 float deltaAngle = 0.0f;
2816 if (radius > 0)
2817 deltaAngle = distInARow / radius;
2818
2819 uint32 count = 1;
2820 if (deltaAngle > 0)
2821 count += coneAngle / deltaAngle;
2822
2823 float currentAngle = -static_cast<float>(count) * deltaAngle / 2.0f;
2824
2826 currentAngle += G3D::fuzzyGt(e.target.o, 0.0f) ? (e.target.o - me->GetOrientation()) : 0.0f;
2827 else if (!targets.empty())
2828 {
2829 currentAngle += (me->GetAngle(targets.front()) - me->GetOrientation());
2830 }
2831
2832 for (uint32 index = 0; index < count; ++index)
2833 {
2834 Position spawnPosition(*me);
2835 spawnPosition.RelocatePolarOffset(currentAngle, radius);
2836 currentAngle += deltaAngle;
2837
2839 }
2840 }
2841
2842 break;
2843 }
2845 {
2846 for (WorldObject* target : targets)
2847 {
2848 if (Player* playerTarget = target->ToPlayer())
2849 {
2850 playerTarget->RemoveArenaSpellCooldowns();
2851 playerTarget->RemoveAurasDueToSpell(57724); // Spell Shaman Debuff - Sated (Heroism)
2852 playerTarget->RemoveAurasDueToSpell(57723); // Spell Shaman Debuff - Exhaustion (Bloodlust)
2853 playerTarget->RemoveAurasDueToSpell(2825); // Bloodlust
2854 playerTarget->RemoveAurasDueToSpell(32182); // Heroism
2855 }
2856 }
2857
2858 break;
2859 }
2861 {
2864 {
2865 if (targets.empty())
2866 break;
2867
2868 for (WorldObject* objTarget : targets)
2869 {
2870 if (Creature const* unitTarget = objTarget->ToCreature())
2871 {
2872 if (unitTarget->IsAIEnabled)
2873 {
2874 unitTarget->AI()->DoAction(actionId);
2875 }
2876 }
2877 else if (GameObject const* gobjTarget = objTarget->ToGameObject())
2878 {
2879 gobjTarget->AI()->DoAction(actionId);
2880 }
2881 }
2882
2883 }
2884 else
2885 {
2886 InstanceScript* instanceScript = nullptr;
2887 if (WorldObject* baseObj = GetBaseObject())
2888 {
2889 instanceScript = baseObj->GetInstanceScript();
2890 }
2891 // Action is triggered by AreaTrigger
2892 else if (trigger && IsPlayer(unit))
2893 {
2894 instanceScript = unit->GetInstanceScript();
2895 }
2896
2897 if (instanceScript)
2898 {
2899 instanceScript->DoAction(actionId);
2900 }
2901 }
2902 break;
2903 }
2905 {
2906 if (!IsSmart())
2907 break;
2908
2909 CAST_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0);
2910 break;
2911 }
2913 {
2914 for (WorldObject* const target : targets)
2915 {
2916 if (IsCreature(target))
2918 }
2919 break;
2920 }
2922 {
2923 for (WorldObject* target : targets)
2924 if (Unit* targetUnit = target->ToUnit())
2925 targetUnit->SetHealth(targetUnit->CountPctFromMaxHealth(e.action.setHealthPct.percent));
2926 break;
2927 }
2929 {
2930 uint32 speedInteger = e.action.movementSpeed.speedInteger;
2931 uint32 speedFraction = e.action.movementSpeed.speedFraction;
2932 float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(float(speedFraction ? speedFraction : 1)) + 1));
2933
2934 for (WorldObject* target : targets)
2935 if (IsCreature(target))
2936 target->ToCreature()->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
2937
2938 break;
2939 }
2941 {
2942 for (WorldObject* target : targets)
2943 {
2944 if (!IsPlayer(target))
2945 continue;
2946
2948 }
2949 break;
2950 }
2952 {
2953 for (WorldObject* target : targets)
2954 {
2955 ObjectGuid guidToSend = me ? me->GetGUID() : go->GetGUID();
2956
2958 {
2959 if (WorldObject* invoker = GetLastInvoker())
2960 {
2961 guidToSend = invoker->GetGUID();
2962 }
2963 }
2964
2965 if (Creature* creature = target->ToCreature())
2966 {
2967 creature->AI()->SetGUID(guidToSend, e.action.setGuid.index);
2968 }
2969 else if (GameObject* object = target->ToGameObject())
2970 {
2971 object->AI()->SetGUID(guidToSend, e.action.setGuid.index);
2972 }
2973 }
2974 break;
2975 }
2977 {
2978 // Enable Scripted Spawns
2979 switch (e.action.scriptSpawn.state)
2980 {
2981 case 0: // Disable Respawn
2982 {
2983 for (WorldObject* target : targets)
2984 {
2985 if (Creature* c = target->ToCreature())
2986 {
2987 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
2989 c->DespawnOrUnsummon();
2990 }
2991 }
2992 break;
2993 }
2994 case 1: // Respawn Once
2995 {
2996 for (WorldObject* target : targets)
2997 {
2998 if (Creature* c = target->ToCreature())
2999 {
3000 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3001 c->Respawn(true);
3002 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3003 }
3004 }
3005 break;
3006 }
3007 case 2: // Enable Respawning
3008 {
3009 for (WorldObject* target : targets)
3010 {
3011 if (Creature* c = target->ToCreature())
3012 {
3013 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3014
3015 // If 0, respawn immediately
3018 else
3019 c->Respawn(true);
3020
3021 // If 0, use DB values
3023 c->SetRespawnDelay(e.action.scriptSpawn.respawnDelay);
3024
3025 // If 0, use default
3027 c->SetCorpseDelay(e.action.scriptSpawn.corpseDelay);
3028 }
3029 }
3030 break;
3031 }
3032 default:
3033 break;
3034 }
3035 break;
3036 }
3038 {
3039 float scale = static_cast<float>(e.action.setScale.scale) / 100.0f;
3040
3041 for (WorldObject* target : targets)
3042 {
3043 if (IsUnit(target))
3044 {
3045 target->ToUnit()->SetObjectScale(scale);
3046 }
3047 }
3048 break;
3049 }
3051 {
3052 if (!me)
3053 break;
3054
3056
3057 float startAngle = me->GetOrientation() + (static_cast<float>(e.action.radialSummon.startAngle) * M_PI / 180.0f);
3058 float stepAngle = static_cast<float>(e.action.radialSummon.stepAngle) * M_PI / 180.0f;
3059
3060 if (e.action.radialSummon.dist)
3061 {
3062 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3063 {
3064 Position summonPos = me->GetPosition();
3065 summonPos.RelocatePolarOffset(itr * stepAngle, static_cast<float>(e.action.radialSummon.dist));
3067 }
3068 break;
3069 }
3070
3071 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3072 {
3073 float currentAngle = startAngle + (itr * stepAngle);
3075 }
3076
3077 break;
3078 }
3080 {
3081 for (WorldObject* target : targets)
3082 {
3083 if (IsUnit(target))
3084 {
3087 }
3088 }
3089 break;
3090 }
3092 {
3094 {
3095 for (WorldObject* target : targets)
3096 if (IsUnit(target))
3097 target->ToCreature()->GetMotionMaster()->MoveIdle();
3098
3099 break;
3100 }
3101
3102 uint8 membCount = targets.size();
3103 uint8 itr = 1;
3104 float dist = float(e.action.followGroup.dist / 100);
3105 switch (e.action.followGroup.followType)
3106 {
3107 case FOLLOW_TYPE_CIRCLE:
3108 {
3109 float angle = (membCount > 4 ? (M_PI * 2)/membCount : (M_PI / 2)); // 90 degrees is the maximum angle
3110 for (WorldObject* target : targets)
3111 {
3112 if (IsCreature(target))
3113 {
3114 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, angle * itr);
3115 itr++;
3116 }
3117 }
3118 break;
3119 }
3121 {
3122 for (WorldObject* target : targets)
3123 {
3124 if (IsCreature(target))
3125 {
3126 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1));
3127 itr++;
3128 }
3129 }
3130 break;
3131 }
3133 {
3134 for (WorldObject* target : targets)
3135 {
3136 if (IsCreature(target))
3137 {
3138 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI + (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1)));
3139 itr++;
3140 }
3141 }
3142 break;
3143 }
3144 case FOLLOW_TYPE_LINE:
3145 {
3146 for (WorldObject* target : targets)
3147 {
3148 if (IsCreature(target))
3149 {
3150 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? 0.f : M_PI);
3151 itr++;
3152 }
3153 }
3154 break;
3155 }
3156 case FOLLOW_TYPE_COLUMN:
3157 {
3158 for (WorldObject* target : targets)
3159 {
3160 if (IsCreature(target))
3161 {
3162 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? (M_PI / 2) : (M_PI * 1.5f));
3163 itr++;
3164 }
3165 }
3166 break;
3167 }
3169 {
3170 for (WorldObject* target : targets)
3171 {
3172 if (IsCreature(target))
3173 {
3174 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? M_PI - (M_PI / 4) : M_PI + (M_PI / 4));
3175 itr++;
3176 }
3177 }
3178 break;
3179 }
3180 default:
3181 break;
3182 }
3183
3184 break;
3185 }
3187 {
3188 switch (e.action.orientationTarget.type)
3189 {
3190 case 0: // Reset
3191 {
3192 for (WorldObject* target : targets)
3193 target->ToCreature()->SetFacingTo((target->ToCreature()->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->ToCreature()->GetTransGUID() ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition()).GetOrientation());
3194
3195 break;
3196 }
3197 case 1: // Target target.o
3198 {
3199 for (WorldObject* target : targets)
3200 target->ToCreature()->SetFacingTo(e.target.o);
3201
3202 break;
3203 }
3204 case 2: // Target source
3205 {
3206 for (WorldObject* target : targets)
3207 target->ToCreature()->SetFacingToObject(me);
3208
3209 break;
3210 }
3211 case 3: // Target parameters
3212 {
3213 ObjectVector facingTargets;
3215
3216 for (WorldObject* facingTarget : facingTargets)
3217 for (WorldObject* target : targets)
3218 target->ToCreature()->SetFacingToObject(facingTarget);
3219
3220 break;
3221 }
3222 default:
3223 break;
3224 }
3225 break;
3226 }
3228 {
3229 if (e.action.wpData.pathId)
3230 {
3231 for (WorldObject* target : targets)
3232 {
3233 if (IsCreature(target))
3234 {
3235 target->ToCreature()->LoadPath(e.action.wpData.pathId);
3237 }
3238 }
3239 }
3240
3241 break;
3242 }
3244 {
3246 {
3247 for (WorldObject* target : targets)
3248 {
3249 if (IsCreature(target))
3250 {
3252 target->ToCreature()->LoadPath(path);
3254 }
3255 }
3256 }
3257
3258 break;
3259 }
3261 {
3262 for (WorldObject* target : targets)
3263 if (IsUnit(target))
3264 target->ToUnit()->StopMoving();
3265
3266 break;
3267 }
3269 {
3270 for (WorldObject* target : targets)
3271 if (IsUnit(target))
3272 target->ToUnit()->PauseMovement(e.action.move.timer);
3273
3274 break;
3275 }
3277 {
3278 for (WorldObject* target : targets)
3279 if (IsUnit(target))
3280 target->ToUnit()->ResumeMovement(e.action.move.timer);
3281
3282 break;
3283 }
3285 {
3286 sWorldState->HandleExternalEvent(static_cast<WorldStateEvent>(e.action.worldStateScript.eventId), e.action.worldStateScript.param);
3287 break;
3288 }
3290 {
3291 for (WorldObject* target : targets)
3292 if (IsCreature(target))
3293 {
3294 target->ToCreature()->SetReputationRewardDisabled(static_cast<bool>(e.action.reward.reputation));
3295 target->ToCreature()->SetLootRewardDisabled(static_cast<bool>(e.action.reward.loot));
3296 }
3297 break;
3298 }
3299 default:
3300 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
3301 break;
3302 }
3303
3304 if (e.link && e.link != e.event_id)
3305 {
3306 auto linked = FindLinkedEvent(e.link);
3307 if (linked.has_value())
3308 {
3309 auto& linkedEvent = linked.value().get();
3310 if (linkedEvent.GetEventType() == SMART_EVENT_LINK)
3311 executionStack.emplace_back(SmartScriptFrame{ linkedEvent, unit, var0, var1, bvar, spell, gob });
3312 else
3313 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());
3314 }
3315 else
3316 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Link Event {} not found, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
3317 }
3318}
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:688
LootState
Definition GameObject.h:109
@ GO_READY
Definition GameObject.h:111
EncounterState
Definition InstanceScript.h:57
@ BROADCAST_TEXT_CALL_FOR_HELP
Definition Language.h:24
@ BROADCAST_TEXT_FLEE_FOR_ASSIST
Definition Language.h:25
@ MOTION_SLOT_CONTROLLED
Definition MotionMaster.h:65
@ MOTION_SLOT_ACTIVE
Definition MotionMaster.h:64
#define NOMINAL_MELEE_RANGE
Definition ObjectDefines.h:48
#define sObjectMgr
Definition ObjectMgr.h:1650
TempSummonType
Definition Object.h:46
@ TEMPSUMMON_TIMED_DESPAWN
Definition Object.h:49
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:51
float frand(float min, float max)
Definition Random.cpp:57
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const guid)
Definition ScriptedGossip.cpp:45
void ClearGossipMenuFor(Player *player)
Definition ScriptedGossip.cpp:22
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1560
@ POWER_MANA
Definition SharedDefines.h:269
@ CHAT_MSG_MONSTER_EMOTE
Definition SharedDefines.h:3407
@ CHAT_MSG_ADDON
Definition SharedDefines.h:3390
@ LANG_UNIVERSAL
Definition SharedDefines.h:735
@ LANG_ADDON
Definition SharedDefines.h:753
@ SPELL_ATTR2_IGNORE_LINE_OF_SIGHT
Definition SharedDefines.h:458
@ TEAM_NEUTRAL
Definition SharedDefines.h:762
SpellCastResult
Definition SharedDefines.h:948
@ SPELL_FAILED_OUT_OF_RANGE
Definition SharedDefines.h:1046
@ SPELL_CAST_OK
Definition SharedDefines.h:1138
@ SPELL_FAILED_SPELL_IN_PROGRESS
Definition SharedDefines.h:1054
@ SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL
Definition SmartScriptMgr.h:1939
SMARTAI_TARGETS
Definition SmartScriptMgr.h:1529
@ SMART_TARGET_RANDOM_POINT
Definition SmartScriptMgr.h:1568
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2240
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:1957
@ FOLLOW_TYPE_SEMI_CIRCLE_BEHIND
Definition SmartScriptMgr.h:1958
@ FOLLOW_TYPE_SEMI_CIRCLE_FRONT
Definition SmartScriptMgr.h:1959
@ FOLLOW_TYPE_COLUMN
Definition SmartScriptMgr.h:1961
@ FOLLOW_TYPE_ANGULAR
Definition SmartScriptMgr.h:1962
@ FOLLOW_TYPE_LINE
Definition SmartScriptMgr.h:1960
SMART_EVENT
Definition SmartScriptMgr.h:117
@ SMART_EVENT_TIMED_EVENT_TRIGGERED
Definition SmartScriptMgr.h:177
@ SMART_EVENT_LINK
Definition SmartScriptMgr.h:179
@ SMART_EVENT_WAYPOINT_REACHED
Definition SmartScriptMgr.h:158
SmartActionSummonCreatureFlags
Definition SmartScriptMgr.h:747
@ SMART_ESCORT_TARGETS
Definition SmartScriptMgr.h:59
std::unordered_map< uint32, WayPoint * > WPPath
Definition SmartScriptMgr.h:2002
@ SMARTCAST_TRIGGERED
Definition SmartScriptMgr.h:1945
@ SMARTCAST_COMBAT_MOVE
Definition SmartScriptMgr.h:1950
@ SMARTCAST_INTERRUPT_PREVIOUS
Definition SmartScriptMgr.h:1944
@ SMARTCAST_AURA_NOT_PRESENT
Definition SmartScriptMgr.h:1949
@ SMARTCAST_THREATLIST_NOT_SINGLE
Definition SmartScriptMgr.h:1951
@ SMARTCAST_TARGET_POWER_MANA
Definition SmartScriptMgr.h:1952
@ AURA_REMOVE_BY_EXPIRE
Definition SpellAuraDefines.h:395
@ SPELLVALUE_BASE_POINT1
Definition SpellDefines.h:114
@ SPELLVALUE_BASE_POINT2
Definition SpellDefines.h:115
@ SPELLVALUE_BASE_POINT0
Definition SpellDefines.h:113
TriggerCastFlags
Definition SpellDefines.h:132
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition SpellDefines.h:150
@ TRIGGERED_NONE
Definition SpellDefines.h:133
#define sSpellMgr
Definition SpellMgr.h:825
#define CAST_AI(a, b)
Definition UnitAI.h:26
#define ENSURE_AI(a, b)
Definition UnitAI.h:27
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:374
NPCFlags
Non Player Character flags.
Definition UnitDefines.h:313
SheathState
Definition UnitDefines.h:125
@ UNIT_STATE_LOST_CONTROL
Definition UnitDefines.h:212
@ UNIT_STATE_ROOT
Definition UnitDefines.h:180
@ UNIT_STATE_NO_ENVIRONMENT_UPD
Definition UnitDefines.h:198
UnitMoveType
Definition UnitDefines.h:348
@ MOVE_RUN
Definition UnitDefines.h:350
@ UNIT_FLAG_SILENCED
Definition UnitDefines.h:263
ReactStates
Definition Unit.h:548
@ UNIT_FIELD_FLAGS_2
Definition UpdateFields.h:118
@ UNIT_VIRTUAL_ITEM_SLOT_ID
Definition UpdateFields.h:116
@ UNIT_FIELD_FLAGS
Definition UpdateFields.h:117
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
@ UNIT_FIELD_BYTES_1
Definition UpdateFields.h:131
@ UNIT_DYNAMIC_FLAGS
Definition UpdateFields.h:136
@ GAMEOBJECT_FLAGS
Definition UpdateFields.h:399
#define sWorldState
Definition WorldState.h:376
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:70
void SetReputationRewardDisabled(bool disable)
Definition Creature.h:363
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:340
void Respawn(bool force=false)
Definition Creature.cpp:2043
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition Creature.cpp:2955
bool SetDisableGravity(bool disable, bool packetOnly=false, bool updateAnimationTier=true) override
Enable or disable the creature's fly mode by adding or removing: MOVEMENTFLAG_FLYING....
Definition Creature.cpp:3220
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:342
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
Definition Creature.cpp:2816
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:347
void DoFleeToGetAssistance()
Definition Creature.cpp:1066
bool IsRooted() const
Definition Creature.h:84
void SetCorpseDelay(uint32 delay)
Definition Creature.h:70
void SetLootRewardDisabled(bool disable)
Definition Creature.h:365
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:95
void LoadPath(uint32 pathid)
Definition Creature.h:351
Definition SpellDefines.h:165
void AddSpellMod(SpellValueMod mod, int32 value)
Definition SpellDefines.h:167
Definition EnumFlag.h:66
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
Definition EventProcessor.h:107
Definition GameObjectAI.h:33
virtual void SetData(uint32, uint32)
Definition GameObjectAI.h:62
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition GameObject.cpp:1414
bool isSpawnedByDefault() const
Definition GameObject.h:195
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2427
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1288
GameobjectTypes GetGoType() const
Definition GameObject.h:202
void Respawn()
Definition GameObject.cpp:1303
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition GameObject.cpp:936
void CastSpell(Unit *target, uint32 spell)
Definition GameObject.cpp:2070
virtual bool SetBossState(uint32 id, EncounterState state)
Definition InstanceScript.cpp:385
virtual void DoAction(int32)
Definition InstanceScript.h:274
static std::string GetBossStateName(uint8 state)
Definition InstanceScript.cpp:826
Definition LinkedList.h:139
bool IsEmpty() const
Definition LinkedList.h:97
Definition MapRefMgr.h:26
iterator begin()
Definition MapRefMgr.h:36
iterator end()
Definition MapRefMgr.h:37
void LoadGrid(float x, float y)
Definition Map.cpp:227
PlayerList const & GetPlayers() const
Definition Map.h:324
void MovementExpired(bool reset=true)
Definition MotionMaster.h:180
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition MotionMaster.h:213
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=0)
Definition MotionMaster.h:229
void MovePath(uint32 path_id, bool repeatable)
Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:852
void MoveIdle()
Definition MotionMaster.cpp:232
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE, bool inheritWalkState=true, bool inheritSpeed=true)
The unit will follow this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:409
void MoveRandom(float wanderDistance=0.0f)
Enable a random movement in desired range around the unit. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:242
static ObjectGuid const Empty
Definition ObjectGuid.h:120
std::string ToString() const
Definition ObjectGuid.cpp:47
static CreatureModel const * ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=nullptr)
Definition ObjectMgr.cpp:1647
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:889
virtual void SetObjectScale(float scale)
Definition Object.h:120
Definition GossipDef.h:259
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition PlayerQuest.cpp:1818
void SendCinematicStart(uint32 CinematicSequenceId) const
Definition Player.cpp:5740
void PrepareGossipMenu(WorldObject *source, uint32 menuId=0, bool showQuests=false)
Definition PlayerGossip.cpp:32
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:12713
Definition QuestDef.h:210
void SetInvincibilityHpLevel(uint32 level)
Definition SmartAI.h:185
void SetData(uint32 id, uint32 value) override
Definition SmartAI.h:161
void IncPhase(uint32 p)
Definition SmartScript.cpp:5382
void StoreTargetList(ObjectVector const &targets, uint32 id)
Definition SmartScript.h:93
void RetryLater(SmartScriptHolder &e, bool ignoreChanceRoll=false)
Definition SmartScript.cpp:5070
void StoreCounter(uint32 id, uint32 value, uint32 reset, uint32 subtract)
Definition SmartScript.h:108
std::optional< std::reference_wrapper< SmartScriptHolder > > FindLinkedEvent(uint32 link)
Definition SmartScript.h:267
std::deque< SmartScriptFrame > executionStack
Definition SmartScript.h:284
void SetPhaseReset(bool allow)
Definition SmartScript.h:205
void GetTargets(ObjectVector &targets, SmartScriptHolder const &e, WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:3447
void OnReset()
Definition SmartScript.cpp:109
void InstallTemplate(SmartScriptHolder const &e)
Definition SmartScript.cpp:3335
ObjectGuid goOrigGUID
Definition SmartScript.h:227
void DecPhase(uint32 p)
Definition SmartScript.cpp:5388
ObjectGuid meOrigGUID
Definition SmartScript.h:225
Definition SpellInfo.h:316
float GetMinRange(bool positive=false) const
Definition SpellInfo.cpp:2326
SpellSchoolMask GetSchoolMask() const
Definition SpellInfo.cpp:1998
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:415
float GetMaxRange(bool positive=false, Unit *caster=nullptr, Spell *spell=nullptr) const
Definition SpellInfo.cpp:2335
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:798
void SetFacingTo(float ori)
Definition Unit.cpp:20368
void CombatStop(bool includingCast=false)
Definition Unit.cpp:10522
float GetSpeed(UnitMoveType mtype) const
Definition Unit.cpp:14516
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
Definition Unit.cpp:4176
float GetSpellMinRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:15259
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition Unit.cpp:14745
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:10702
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:17790
MotionMaster * GetMotionMaster()
Definition Unit.h:1673
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:1250
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition Unit.cpp:13666
void SetFacingToObject(WorldObject *object)
Definition Unit.cpp:20378
bool IsAlive() const
Definition Unit.h:1707
void StopMoving()
Definition Unit.cpp:16724
void SendPlaySpellVisual(uint32 id)
Definition Unit.cpp:18999
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5777
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:1692
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:15239
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:729
TransportBase * GetDirectTransport() const
Definition Unit.cpp:18855
void SendMovementFlagUpdate(bool self=false)
Definition Unit.cpp:16778
bool isMoving() const
Definition Unit.h:1622
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:1193
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4965
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:14521
ObjectGuid GetTransGUID() const override
Definition Unit.cpp:18844
bool IsAIEnabled
Definition Unit.h:2012
bool HasUnitState(const uint32 f) const
Definition Unit.h:691
float GetPowerPct(Powers power) const
Definition Unit.h:1060
float GetMeleeRange(Unit const *target) const
Definition Unit.cpp:683
uint32 GetPower(Powers power) const
Definition Unit.h:1058
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.h:1161
void SetInFront(WorldObject const *target)
Definition Unit.cpp:20362
bool isDead() const
Definition Unit.h:1709
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:2350
Map * FindMap() const
Definition Object.h:588
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1185
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:1340
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:2635
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:2708
std::string const & GetName() const
Definition Object.h:514
void AddObjectToRemoveList()
Definition Object.cpp:2142
EventProcessor m_Events
Definition Object.h:693
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1238
uint32 GetAreaId() const
Definition Object.cpp:3152
uint32 GetZoneId() const
Definition Object.cpp:3144
float GetObjectSize() const
Definition Object.cpp:2780
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:2364
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition Object.cpp:1495
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:2427
virtual float GetCombatReach() const
Definition Object.h:492
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2399
Player session in the World.
Definition WorldSession.h:330
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:52
virtual void SetGuidData(uint32, ObjectGuid)
Definition ZoneScript.h:45
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:133
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250
Definition ObjectAccessor.h:61
Player * GetPlayer(Map const *, ObjectGuid const guid)
Definition ObjectAccessor.cpp:220
Definition CreatureData.h:169
uint32 CreatureDisplayID
Definition CreatureData.h:179
float DisplayScale
Definition CreatureData.h:180
Definition CreatureData.h:360
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition CreatureData.h:361
Definition Position.h:27
float m_positionZ
Definition Position.h:57
float m_positionX
Definition Position.h:55
float GetPositionZ() const
Definition Position.h:123
float m_positionY
Definition Position.h:56
float GetOrientation() const
Definition Position.h:124
void SetOrientation(float orientation)
Definition Position.h:116
float GetPositionX() const
Definition Position.h:121
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetPositionY() const
Definition Position.h:122
void RelocatePolarOffset(float angle, float dist, float z=0.0f)
Definition Position.cpp:34
float GetAngle(const Position *pos) const
Definition Position.cpp:78
Definition SmartScriptMgr.h:758
struct SmartAction::@75::@193 worldStateScript
struct SmartAction::@75::@98 combatMove
uint32 followState
Definition SmartScriptMgr.h:1458
uint32 visualId
Definition SmartScriptMgr.h:1453
uint32 targetParam2
Definition SmartScriptMgr.h:861
struct SmartAction::@75::@100 incEventPhase
struct SmartAction::@75::@106 killedMonster
std::array< uint32, SMART_ACTION_PARAM_COUNT > emotes
Definition SmartScriptMgr.h:844
struct SmartAction::@75::@166 setHomePos
uint32 repeatMax
Definition SmartScriptMgr.h:1120
uint32 phaseMin
Definition SmartScriptMgr.h:946
uint32 targetsLimit
Definition SmartScriptMgr.h:852
SAIBool transport
Definition SmartScriptMgr.h:1214
struct SmartAction::@75::@82 randomSound
struct SmartAction::@75::@120 summonGO
uint32 startAngle
Definition SmartScriptMgr.h:1446
SAIBool reset
Definition SmartScriptMgr.h:1105
std::array< uint32, SMART_ACTION_PARAM_COUNT > actionLists
Definition SmartScriptMgr.h:1168
uint32 delay
Definition SmartScriptMgr.h:991
uint32 random
Definition SmartScriptMgr.h:1341
struct SmartAction::@75::@182 cinematic
uint32 quickChange
Definition SmartScriptMgr.h:1340
uint32 targetParam4
Definition SmartScriptMgr.h:1470
uint32 dist
Definition SmartScriptMgr.h:931
uint32 group
Definition SmartScriptMgr.h:1264
SAIBool disable
Definition SmartScriptMgr.h:1395
struct SmartAction::@75::@111 callHelp
uint32 spell
Definition SmartScriptMgr.h:849
uint32 minHP
Definition SmartScriptMgr.h:998
uint32 flags
Definition SmartScriptMgr.h:858
struct SmartAction::@75::@97 autoAttack
SAIBool loot
Definition SmartScriptMgr.h:1512
uint32 distanceBetweenSummons
Definition SmartScriptMgr.h:1356
uint32 data
Definition SmartScriptMgr.h:958
struct SmartAction::@75::@105 randomPhaseRange
struct SmartAction::@75::@168 randomTimedEvent
uint32 entry
Definition SmartScriptMgr.h:933
struct SmartAction::@75::@184 scriptSpawn
struct SmartAction::@75::@177 doAction
struct SmartAction::@75::@91 crossCast
struct SmartAction::@75::@129 setSwim
uint32 quest
Definition SmartScriptMgr.h:828
struct SmartAction::@75::@78 simpleTalk
struct SmartAction::@75::@175 castCustom
uint32 triggerFlags
Definition SmartScriptMgr.h:851
struct SmartAction::@75::@87 questOffer
uint32 bp1
Definition SmartScriptMgr.h:1371
uint32 distance
Definition SmartScriptMgr.h:791
SAIBool removeObjectFromWorld
Definition SmartScriptMgr.h:993
uint32 min
Definition SmartScriptMgr.h:1117
uint32 spawnTimerMax
Definition SmartScriptMgr.h:1430
uint32 subtract
Definition SmartScriptMgr.h:1106
struct SmartAction::@75::@110 die
uint32 a
Definition SmartScriptMgr.h:1380
struct SmartAction::@75::@104 randomPhase
struct SmartAction::@75::@133 timeEvent
SAIBool invokerGUID
Definition SmartScriptMgr.h:1422
uint32 percent
Definition SmartScriptMgr.h:999
uint32 dec
Definition SmartScriptMgr.h:915
uint32 milliseconds
Definition SmartScriptMgr.h:975
struct SmartAction::@75::@125 item
uint32 summonEntry
Definition SmartScriptMgr.h:1353
struct SmartAction::@75::@84 randomMusic
struct SmartAction::@75::@152 sendTargetToTarget
uint32 followType
Definition SmartScriptMgr.h:1459
uint32 instanceTarget
Definition SmartScriptMgr.h:1390
uint32 credit
Definition SmartScriptMgr.h:934
uint32 controlled
Definition SmartScriptMgr.h:1215
uint32 alternative
Definition SmartScriptMgr.h:867
uint32 targetParam1
Definition SmartScriptMgr.h:860
uint32 mapID
Definition SmartScriptMgr.h:1098
uint32 stopMovement
Definition SmartScriptMgr.h:1347
struct SmartAction::@75::@134 movie
struct SmartAction::@75::@94 summonCreature
uint32 charges
Definition SmartScriptMgr.h:926
struct SmartAction::@75::@113 forceDespawn
struct SmartAction::@75::@185 setScale
struct SmartAction::@75::@103 follow
struct SmartAction::@75::@173 coneSummon
struct SmartAction::@75::@187 spellVisual
uint32 model
Definition SmartScriptMgr.h:784
struct SmartAction::@75::@191 wpDataRandom
uint32 duration
Definition SmartScriptMgr.h:766
SAIBool attackInvoker
Definition SmartScriptMgr.h:880
SAIBool useTalkTarget
Definition SmartScriptMgr.h:767
SAIBool run
Definition SmartScriptMgr.h:1043
uint32 value
Definition SmartScriptMgr.h:1104
struct SmartAction::@75::@140 timedActionList
uint32 movementExpired
Definition SmartScriptMgr.h:1348
struct SmartAction::@75::@117 moveRandom
struct SmartAction::@75::@150 sendGossipMenu
uint32 targetParam3
Definition SmartScriptMgr.h:862
uint32 respawnDelay
Definition SmartScriptMgr.h:1431
SAIBool swim
Definition SmartScriptMgr.h:1093
uint32 combatReach
Definition SmartScriptMgr.h:1217
uint32 sound2
Definition SmartScriptMgr.h:797
uint32 spawnPos
Definition SmartScriptMgr.h:1311
struct SmartAction::@75::@92 activateObject
struct SmartAction::@75::@161 gameEventStart
struct SmartAction::@75::@186 radialSummon
struct SmartAction::@75::@179 corpseDelay
struct SmartAction::@75::@183 setGuid
uint32 pathId2
Definition SmartScriptMgr.h:1288
uint32 creature
Definition SmartScriptMgr.h:783
struct SmartAction::@75::@190 wpData
uint32 spawnTimerMin
Definition SmartScriptMgr.h:1429
struct SmartAction::@75::@132 storeTargets
struct SmartAction::@75::@114 invincHP
uint32 angle
Definition SmartScriptMgr.h:932
uint32 field
Definition SmartScriptMgr.h:957
uint32 range
Definition SmartScriptMgr.h:872
struct SmartAction::@75::@95 threatPCT
struct SmartAction::@75::@89 randomEmote
uint32 flag
Definition SmartScriptMgr.h:1138
uint32 sound3
Definition SmartScriptMgr.h:798
uint32 targetsummon
Definition SmartScriptMgr.h:1032
struct SmartAction::@75::@145 jump
struct SmartAction::@75::@188 followGroup
uint32 chance
Definition SmartScriptMgr.h:1121
struct SmartAction::@75::@131 setCounter
uint32 state
Definition SmartScriptMgr.h:839
struct SmartAction::@75::@90 cast
struct SmartAction::@75::@108 setInstanceData64
struct SmartAction::@75::@180 movementSpeed
uint32 sound1
Definition SmartScriptMgr.h:796
struct SmartAction::@75::@80 morphOrMount
struct SmartAction::@75::@116 setData
uint32 forceRespawnTimer
Definition SmartScriptMgr.h:992
uint32 speed
Definition SmartScriptMgr.h:1087
uint32 sound4
Definition SmartScriptMgr.h:799
struct SmartAction::@75::@147 flee
uint32 targetType
Definition SmartScriptMgr.h:859
uint32 repetitions
Definition SmartScriptMgr.h:1445
struct SmartAction::@75::@162 startClosestWaypoint
uint32 aliveState
Definition SmartScriptMgr.h:936
SAIBool onlySelf
Definition SmartScriptMgr.h:790
uint32 attackScriptOwner
Definition SmartScriptMgr.h:881
uint32 speedxy
Definition SmartScriptMgr.h:1191
uint32 pointId
Definition SmartScriptMgr.h:1213
SAIBool attack
Definition SmartScriptMgr.h:899
uint32 repeatMin
Definition SmartScriptMgr.h:1119
struct SmartAction::@75::@122 wpStart
uint32 scale
Definition SmartScriptMgr.h:1438
SAIBool fly
Definition SmartScriptMgr.h:1086
struct SmartAction::@75::@189 orientationTarget
uint32 textGroupID
Definition SmartScriptMgr.h:765
uint32 castFlags
Definition SmartScriptMgr.h:850
std::array< uint32, SMART_ACTION_PARAM_COUNT > phases
Definition SmartScriptMgr.h:941
SAIBool dontDespawn
Definition SmartScriptMgr.h:1433
struct SmartAction::@75::@172 stopMotion
struct SmartAction::@75::@174 playerTalk
uint32 turnAngle
Definition SmartScriptMgr.h:1342
uint32 textId
Definition SmartScriptMgr.h:1363
uint32 gossipMenuId
Definition SmartScriptMgr.h:1222
uint32 speedz
Definition SmartScriptMgr.h:1192
SAIBool repeat
Definition SmartScriptMgr.h:1045
uint32 gossipNpcTextId
Definition SmartScriptMgr.h:1223
uint32 mask
Definition SmartScriptMgr.h:1004
uint32 pathId1
Definition SmartScriptMgr.h:1287
uint32 phi_delta
Definition SmartScriptMgr.h:1383
uint32 count
Definition SmartScriptMgr.h:1066
struct SmartAction::@75::@112 setSheath
uint32 inc
Definition SmartScriptMgr.h:914
uint32 phaseMax
Definition SmartScriptMgr.h:947
struct SmartAction::@75::@130 teleport
uint32 timer
Definition SmartScriptMgr.h:1400
struct SmartAction::@75::@176 summonVortex
uint32 ContactDistance
Definition SmartScriptMgr.h:1216
struct SmartAction::@75::@79 faction
struct SmartAction::@75::@135 equip
uint32 k
Definition SmartScriptMgr.h:1381
uint32 distanceBetweenRings
Definition SmartScriptMgr.h:1355
struct SmartAction::@75::@171 orientation
uint32 coneLength
Definition SmartScriptMgr.h:1357
uint32 counterId
Definition SmartScriptMgr.h:1103
SAIBool withEmote
Definition SmartScriptMgr.h:981
struct SmartAction::@75::@146 movementFlag
uint32 param
Definition SmartScriptMgr.h:1494
uint32 max
Definition SmartScriptMgr.h:1118
uint32 selfJump
Definition SmartScriptMgr.h:1193
uint32 maxId
Definition SmartScriptMgr.h:1323
uint32 r_max
Definition SmartScriptMgr.h:1382
struct SmartAction::@75::@136 unitFlag
uint32 speedFraction
Definition SmartScriptMgr.h:1407
struct SmartAction::@75::@153 setRangedMovement
struct SmartAction::@75::@88 react
struct SmartAction::@75::@119 setActive
SAIBool fail
Definition SmartScriptMgr.h:1060
struct SmartAction::@75::@124 wpStop
SAIBool directAdd
Definition SmartScriptMgr.h:834
uint32 bp2
Definition SmartScriptMgr.h:1372
uint32 disableGravity
Definition SmartScriptMgr.h:1088
uint32 sound
Definition SmartScriptMgr.h:789
struct SmartAction::@75::@195 reward
uint32 threatINC
Definition SmartScriptMgr.h:887
struct SmartAction::@75::@178 disableEvade
struct SmartAction::@75::@158 creatureGroup
struct SmartAction::@75::@160 gameEventStop
uint32 coneAngle
Definition SmartScriptMgr.h:1358
uint32 summonDuration
Definition SmartScriptMgr.h:1354
struct SmartAction::@75::@148 RespawnTarget
uint32 threatDEC
Definition SmartScriptMgr.h:888
SAIBool reputation
Definition SmartScriptMgr.h:1511
uint32 stepAngle
Definition SmartScriptMgr.h:1447
uint32 reactState
Definition SmartScriptMgr.h:1048
uint32 speedInteger
Definition SmartScriptMgr.h:1406
struct SmartAction::@75::@77 talk
uint32 index
Definition SmartScriptMgr.h:1423
struct SmartAction::@75::@123 wpPause
struct SmartAction::@75::@83 music
uint32 actionId
Definition SmartScriptMgr.h:1388
uint32 despawnTime
Definition SmartScriptMgr.h:1031
struct SmartAction::@75::@128 setFly
uint32 goRespawnTime
Definition SmartScriptMgr.h:1208
struct SmartAction::@75::@115 ingamePhaseMask
uint32 factionID
Definition SmartScriptMgr.h:778
uint32 eventId
Definition SmartScriptMgr.h:1493
uint32 pathId
Definition SmartScriptMgr.h:1475
SAIBool move
Definition SmartScriptMgr.h:904
struct SmartAction::@75::@149 moveToPos
std::array< uint32, MAX_EQUIPMENT_ITEMS > slots
Definition SmartScriptMgr.h:1133
struct SmartAction::@75::@127 setRun
struct SmartAction::@75::@99 setEventPhase
struct SmartAction::@75::@107 setInstanceData
uint32 questID
Definition SmartScriptMgr.h:833
uint32 bp3
Definition SmartScriptMgr.h:1373
uint32 pathID
Definition SmartScriptMgr.h:1044
uint32 emote
Definition SmartScriptMgr.h:823
struct SmartAction::@75::@102 removeAura
uint32 id
Definition SmartScriptMgr.h:1038
uint32 minId
Definition SmartScriptMgr.h:1322
uint32 phase
Definition SmartScriptMgr.h:909
uint32 sheath
Definition SmartScriptMgr.h:986
uint32 isNegative
Definition SmartScriptMgr.h:1389
uint32 creditType
Definition SmartScriptMgr.h:935
struct SmartAction::@75::@141 randTimedActionList
Definition SmartScriptMgr.h:224
uint32 repeatMin
Definition SmartScriptMgr.h:235
uint32 repeatMax
Definition SmartScriptMgr.h:236
bool runOnce
Definition SmartScriptMgr.h:1990
uint32 link
Definition SmartScriptMgr.h:1975
uint32 event_id
Definition SmartScriptMgr.h:1974
int32 entryOrGuid
Definition SmartScriptMgr.h:1972
uint32 GetScriptType() const
Definition SmartScriptMgr.h:1982
uint32 GetTargetType() const
Definition SmartScriptMgr.h:1985
uint32 GetActionType() const
Definition SmartScriptMgr.h:1984
float o
Definition SmartScriptMgr.h:1591
uint32 maxDist
Definition SmartScriptMgr.h:1597
uint32 range
Definition SmartScriptMgr.h:1718
float x
Definition SmartScriptMgr.h:1591
uint32 self
Definition SmartScriptMgr.h:1720
struct SmartTarget::@196::@217 randomPoint
uint32 amount
Definition SmartScriptMgr.h:1719
struct SmartTarget::@196::@200 unitRange
float y
Definition SmartScriptMgr.h:1591
float z
Definition SmartScriptMgr.h:1591
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::disableGravity, CreatureModel::DisplayScale, SmartAction::dist, SmartAction::distance, SmartAction::distanceBetweenRings, SmartAction::distanceBetweenSummons, SmartAction::doAction, InstanceScript::DoAction(), Creature::DoFleeToGetAssistance(), SmartAction::dontDespawn, SmartAction::duration, SmartAction::emote, SmartAction::emotes, ObjectGuid::Empty, MapRefMgr::end(), ENSURE_AI, SmartAction::entry, SmartScriptHolder::entryOrGuid, SmartAction::equip, SmartScriptHolder::event, SmartEvent::event_chance, SmartEvent::event_flags, SmartScriptHolder::event_id, SmartAction::eventId, executionStack, SmartAction::faction, SmartAction::factionID, SmartAction::fail, SmartAction::field, FindLinkedEvent(), WorldObject::FindMap(), SmartAction::flag, SmartAction::flags, SmartAction::flee, SmartAction::fly, SmartAction::follow, FOLLOW_TYPE_ANGULAR, FOLLOW_TYPE_CIRCLE, FOLLOW_TYPE_COLUMN, FOLLOW_TYPE_LINE, FOLLOW_TYPE_SEMI_CIRCLE_BEHIND, FOLLOW_TYPE_SEMI_CIRCLE_FRONT, SmartAction::followGroup, SmartAction::followState, SmartAction::followType, SmartAction::force, SmartAction::forceDespawn, SmartAction::forceRespawnTimer, frand(), SmartAction::gameEventStart, SmartAction::gameEventStop, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_DOOR, SmartScriptHolder::GetActionType(), Position::GetAngle(), WorldObject::GetAreaId(), GetBaseObject(), InstanceScript::GetBossStateName(), Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), WorldObject::GetClosePoint(), WorldObject::GetCombatReach(), Unit::GetDirectTransport(), WorldObject::GetDistance(), Object::GetEntry(), SmartScriptHolder::GetEventType(), Unit::getGender(), GameObject::GetGoType(), Object::GetGUID(), Creature::GetHomePosition(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), WorldObject::GetMap(), SpellInfo::GetMaxRange(), Unit::GetMeleeRange(), SpellInfo::GetMinRange(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldObject::GetNearPoint(), WorldObject::GetObjectSize(), Position::GetOrientation(), ObjectAccessor::GetPlayer(), Map::GetPlayers(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetPower(), Unit::GetPowerPct(), WorldObject::GetRandomPoint(), Creature::GetRespawnPosition(), SpellInfo::GetSchoolMask(), SmartScriptHolder::GetScriptType(), Unit::GetSpeed(), Unit::GetSpellMaxRangeForTarget(), Unit::GetSpellMinRangeForTarget(), GetStoredTargetVector(), GetTargets(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), ThreatMgr::GetThreatListSize(), Unit::GetThreatMgr(), Unit::GetTransGUID(), Creature::GetTransportHomePosition(), ObjectAccessor::GetUnit(), Unit::GetVehicleKit(), GetWorldObjectsInDist(), WorldObject::GetZoneId(), go, GO_READY, SmartAction::goFlag, goOrigGUID, SmartAction::goRespawnTime, SmartAction::gossipMenuId, SmartAction::gossipNpcTextId, SmartAction::goState, SmartAction::group, Player::GroupEventHappens(), SpellInfo::HasAttribute(), Unit::HasAura(), EnumFlag< T >::HasFlag(), Object::HasFlag(), Unit::HasUnitMovementFlag(), Unit::HasUnitState(), SmartAction::id, SmartAction::immunity, SmartAction::inc, SmartAction::incEventPhase, IncPhase(), SmartAction::index, SmartAction::ingamePhaseMask, InitTimer(), InstallTemplate(), SmartAction::instanceTarget, Unit::InterruptNonMeleeSpells(), SmartAction::interruptSpellCasting, SmartAction::invincHP, SmartAction::invokerGUID, Unit::IsAlive(), IsCreature(), Unit::isDead(), Map::IsDungeon(), LinkedListHead::IsEmpty(), IsGameObject(), Unit::isMoving(), SmartAction::isNegative, IsPlayer(), Creature::IsRooted(), IsSmart(), IsUnit(), Unit::IsVehicle(), WorldObject::IsWithinLOSInMap(), SmartAction::item, EquipmentInfo::ItemEntry, SmartAction::jump, SmartAction::k, Unit::Kill(), SmartAction::killedMonster, Unit::KillSelf(), LANG_ADDON, LANG_UNIVERSAL, SmartScriptHolder::link, SmartAction::loadEquipment, Map::LoadGrid(), LOG_DEBUG, LOG_ERROR, SmartAction::loot, WorldObject::m_Events, Position::m_positionX, Position::m_positionY, Position::m_positionZ, SmartAction::mapID, SmartAction::mask, SmartEvent::max, SmartAction::max, MAX_EQUIPMENT_ITEMS, SmartTarget::maxDist, SmartAction::maxId, me, meOrigGUID, SmartAction::milliseconds, SmartEvent::min, SmartAction::min, SmartAction::minHP, SmartAction::minId, SmartEvent::minMaxRepeat, mLastInvoker, mLastTextID, SmartAction::model, ThreatMgr::ModifyThreatByPercent(), SmartAction::morphOrMount, MOTION_SLOT_ACTIVE, MOTION_SLOT_CONTROLLED, SmartAction::move, MOVE_RUN, MotionMaster::MoveIdle(), MotionMaster::MoveJump(), SmartAction::movementExpired, SmartAction::movementFlag, MOVEMENTFLAG_ONTRANSPORT, SmartAction::movementSpeed, SmartAction::movementType, MotionMaster::MovePoint(), SmartAction::moveRandom, MotionMaster::MoveRandom(), SmartAction::moveToPos, SmartAction::movie, mRemIDs, mStoredEvents, mTalkerEntry, mTextTimer, mUseTextTimer, SmartAction::music, SmartAction::newPower, NOMINAL_MELEE_RANGE, SmartTarget::o, SmartAction::onlySelf, OnReset(), SmartAction::orientation, SmartAction::orientationTarget, SmartAction::param, SmartAction::pathID, SmartAction::pathId, SmartAction::pathId1, SmartAction::pathId2, SmartAction::percent, PersonalSpawn, SmartAction::phase, SmartAction::phaseMax, SmartAction::phaseMin, SmartAction::phases, SmartAction::phi_delta, SmartAction::playerTalk, SmartAction::pointId, SmartAction::power, POWER_MANA, SmartAction::powerType, PreferUnit, ProcessEventsFor(), SmartAction::quest, SmartAction::questID, SmartAction::questOffer, SmartAction::quickChange, SmartAction::r_max, SmartAction::radialSummon, SmartAction::random, SmartAction::randomEmote, SmartAction::randomMusic, SmartAction::randomPhase, SmartAction::randomPhaseRange, SmartTarget::randomPoint, Acore::Containers::RandomResize(), SmartAction::randomSound, SmartAction::randomTimedEvent, SmartAction::randTimedActionList, SmartAction::range, SmartTarget::range, SmartAction::react, SmartAction::reactState, SmartAction::regenHealth, Position::RelocatePolarOffset(), SmartAction::removeAura, Unit::RemoveAurasDueToSpell(), SmartAction::removeObjectFromWorld, SmartAction::repeat, SmartEvent::repeatMax, SmartAction::repeatMax, SmartEvent::repeatMin, SmartAction::repeatMin, SmartAction::repetitions, SmartAction::reputation, SmartAction::reset, ResetBaseObject(), SmartAction::respawnDelay, SmartAction::RespawnTarget, RetryLater(), SmartAction::reward, Player::RewardPlayerAndGroupAtEvent(), SmartAction::root, SmartAction::run, SmartScriptHolder::runOnce, SmartAction::scale, sCreatureTextMgr, SmartAction::scriptSpawn, Acore::Containers::SelectRandomContainerElement(), SmartTarget::self, SmartAction::selfJump, SmartAction::sendGoCustomAnim, SmartAction::sendGossipMenu, SendGossipMenuFor(), Unit::SendPlaySpellVisual(), PlayerMenu::SendQuestGiverQuestDetails(), SmartAction::sendTargetToTarget, Creature::SendZoneUnderAttackMessage(), SmartAction::setActive, InstanceScript::SetBossState(), SmartAction::setCounter, GameObjectAI::SetData(), UnitAI::SetData(), SmartAction::setData, ZoneScript::SetData(), Creature::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, SmartAction::setGoLootState, SmartAction::setGuid, ZoneScript::SetGuidData(), SmartAction::setHealthPct, SmartAction::setHealthRegen, SmartAction::setHomePos, Creature::SetHomePosition(), SmartAction::setHover, Unit::SetInCombatWith(), Unit::SetInFront(), SmartAction::setInstanceData, SmartAction::setInstanceData64, SmartAI::SetInvincibilityHpLevel(), GameObject::SetLootState(), Position::SetOrientation(), SetPhase(), SetPhaseReset(), SmartAction::setRangedMovement, Creature::SetReactState(), SmartAction::setRoot, SmartAction::setRun, SmartAction::setScale, SetScript9(), SmartAction::setSheath, Unit::SetSheath(), Unit::SetSpeed(), SmartAction::setSwim, SmartAction::setunitByte, sGameEventMgr, SmartAction::sheath, SmartAction::sightDistance, SmartAction::simpleTalk, SmartAction::slots, SMART_ACTION_ACTIVATE_GOBJECT, SMART_ACTION_ACTIVATE_TAXI, SMART_ACTION_ADD_AURA, SMART_ACTION_ADD_DYNAMIC_FLAG, SMART_ACTION_ADD_GO_FLAG, SMART_ACTION_ADD_IMMUNITY, SMART_ACTION_ADD_ITEM, SMART_ACTION_ADD_NPC_FLAG, SMART_ACTION_ADD_POWER, SMART_ACTION_ADD_THREAT, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, SMART_ACTION_ATTACK_START, SMART_ACTION_ATTACK_STOP, SMART_ACTION_AUTO_ATTACK, SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS, SMART_ACTION_CALL_FOR_HELP, SMART_ACTION_CALL_GROUPEVENTHAPPENS, SMART_ACTION_CALL_KILLEDMONSTER, SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST, SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST, SMART_ACTION_CALL_SCRIPT_RESET, SMART_ACTION_CALL_TIMED_ACTIONLIST, SMART_ACTION_CAST, SMART_ACTION_CLOSE_GOSSIP, SMART_ACTION_COMBAT_STOP, SMART_ACTION_CONE_SUMMON, SMART_ACTION_CREATE_TIMED_EVENT, SMART_ACTION_CROSS_CAST, SMART_ACTION_CU_ENCOUNTER_START, SMART_ACTION_CUSTOM_CAST, SMART_ACTION_DIE, SMART_ACTION_DISABLE_EVADE, SMART_ACTION_DISABLE_REWARD, SMART_ACTION_DISMOUNT, SMART_ACTION_DO_ACTION, SMART_ACTION_EQUIP, SMART_ACTION_EVADE, SMART_ACTION_EXIT_VEHICLE, SMART_ACTION_FAIL_QUEST, SMART_ACTION_FALL, SMART_ACTION_FLEE, SMART_ACTION_FLEE_FOR_ASSIST, SMART_ACTION_FOLLOW, SMART_ACTION_FOLLOW_GROUP, SMART_ACTION_FORCE_DESPAWN, SMART_ACTION_GAME_EVENT_START, SMART_ACTION_GAME_EVENT_STOP, SMART_ACTION_GO_SET_GO_STATE, SMART_ACTION_GO_SET_LOOT_STATE, SMART_ACTION_INC_EVENT_PHASE, SMART_ACTION_INSTALL_AI_TEMPLATE, SMART_ACTION_INTERRUPT_SPELL, SMART_ACTION_INVOKER_CAST, SMART_ACTION_JUMP_TO_POS, SMART_ACTION_KILL_UNIT, SMART_ACTION_LOAD_EQUIPMENT, SMART_ACTION_LOAD_GRID, SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL, SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL, SMART_ACTION_MOVE_FORWARD, SMART_ACTION_MOVE_TO_POS, SMART_ACTION_MOVE_TO_POS_TARGET, SMART_ACTION_MOVEMENT_PAUSE, SMART_ACTION_MOVEMENT_RESUME, SMART_ACTION_MOVEMENT_STOP, SMART_ACTION_MUSIC, SMART_ACTION_NO_ENVIRONMENT_UPDATE, SMART_ACTION_NONE, SMART_ACTION_OFFER_QUEST, SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT, SMART_ACTION_PLAY_CINEMATIC, SMART_ACTION_PLAY_EMOTE, SMART_ACTION_PLAY_SPELL_VISUAL, SMART_ACTION_PLAYER_TALK, SMART_ACTION_PLAYMOVIE, SMART_ACTION_RANDOM_EMOTE, SMART_ACTION_RANDOM_MOVE, SMART_ACTION_RANDOM_MUSIC, SMART_ACTION_RANDOM_PHASE, SMART_ACTION_RANDOM_PHASE_RANGE, SMART_ACTION_RANDOM_SOUND, SMART_ACTION_REMOVE_ALL_GAMEOBJECTS, SMART_ACTION_REMOVE_DYNAMIC_FLAG, SMART_ACTION_REMOVE_GO_FLAG, SMART_ACTION_REMOVE_IMMUNITY, SMART_ACTION_REMOVE_ITEM, SMART_ACTION_REMOVE_NPC_FLAG, SMART_ACTION_REMOVE_POWER, SMART_ACTION_REMOVE_TIMED_EVENT, SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1, SMART_ACTION_REMOVE_UNIT_FLAG, SMART_ACTION_REMOVEAURASFROMSPELL, SMART_ACTION_RESET_GOBJECT, SMART_ACTION_RESET_SCRIPT_BASE_OBJECT, SMART_ACTION_RESPAWN_TARGET, SMART_ACTION_RISE_UP, SMART_ACTION_SCRIPTED_SPAWN, SMART_ACTION_SELF_CAST, SMART_ACTION_SEND_GO_CUSTOM_ANIM, SMART_ACTION_SEND_GOSSIP_MENU, SMART_ACTION_SEND_TARGET_TO_TARGET, SMART_ACTION_SET_ACTIVE, SMART_ACTION_SET_COMBAT_DISTANCE, SMART_ACTION_SET_CORPSE_DELAY, SMART_ACTION_SET_COUNTER, SMART_ACTION_SET_DATA, SMART_ACTION_SET_DYNAMIC_FLAG, SMART_ACTION_SET_EMOTE_STATE, SMART_ACTION_SET_EVENT_FLAG_RESET, SMART_ACTION_SET_EVENT_PHASE, SMART_ACTION_SET_FACTION, SMART_ACTION_SET_FLY, SMART_ACTION_SET_GO_FLAG, SMART_ACTION_SET_GUID, SMART_ACTION_SET_HEALTH_PCT, SMART_ACTION_SET_HEALTH_REGEN, SMART_ACTION_SET_HOME_POS, SMART_ACTION_SET_HOVER, SMART_ACTION_SET_IN_COMBAT_WITH_ZONE, SMART_ACTION_SET_INGAME_PHASE_MASK, SMART_ACTION_SET_INST_DATA, SMART_ACTION_SET_INST_DATA64, SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL, SMART_ACTION_SET_MOVEMENT_SPEED, SMART_ACTION_SET_NPC_FLAG, SMART_ACTION_SET_ORIENTATION, SMART_ACTION_SET_ORIENTATION_TARGET, SMART_ACTION_SET_POWER, SMART_ACTION_SET_RANGED_MOVEMENT, SMART_ACTION_SET_REACT_STATE, SMART_ACTION_SET_ROOT, SMART_ACTION_SET_RUN, SMART_ACTION_SET_SCALE, SMART_ACTION_SET_SHEATH, SMART_ACTION_SET_SIGHT_DIST, SMART_ACTION_SET_SWIM, SMART_ACTION_SET_UNIT_FIELD_BYTES_1, SMART_ACTION_SET_UNIT_FLAG, SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS, SMART_ACTION_SET_VISIBILITY, SMART_ACTION_SIMPLE_TALK, SMART_ACTION_SOUND, SMART_ACTION_START_CLOSEST_WAYPOINT, SMART_ACTION_STOP_MOTION, SMART_ACTION_STORE_TARGET_LIST, SMART_ACTION_SUMMON_CREATURE, SMART_ACTION_SUMMON_CREATURE_GROUP, SMART_ACTION_SUMMON_GO, SMART_ACTION_SUMMON_RADIAL, SMART_ACTION_TALK, SMART_ACTION_TELEPORT, SMART_ACTION_THREAT_ALL_PCT, SMART_ACTION_THREAT_SINGLE_PCT, SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT, SMART_ACTION_TRIGGER_TIMED_EVENT, SMART_ACTION_UPDATE_TEMPLATE, SMART_ACTION_VORTEX_SUMMON, SMART_ACTION_WAYPOINT_DATA_RANDOM, SMART_ACTION_WAYPOINT_DATA_START, SMART_ACTION_WORLD_SCRIPT, SMART_ACTION_WP_PAUSE, SMART_ACTION_WP_RESUME, SMART_ACTION_WP_START, SMART_ACTION_WP_STOP, SMART_ACTION_ZONE_UNDER_ATTACK, SMART_ESCORT_TARGETS, SMART_EVENT_FLAG_NOT_REPEATABLE, SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL, SMART_EVENT_LINK, SMART_EVENT_TIMED_EVENT_TRIGGERED, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_WAYPOINT_REACHED, SMART_RANDOM_POINT, SMART_SCRIPT_TYPE_AREATRIGGER, SMART_TARGET_NONE, SMART_TARGET_POSITION, SMART_TARGET_RANDOM_POINT, SMART_TARGET_SELF, SMARTCAST_AURA_NOT_PRESENT, SMARTCAST_COMBAT_MOVE, SMARTCAST_INTERRUPT_PREVIOUS, SMARTCAST_TARGET_POWER_MANA, SMARTCAST_THREATLIST_NOT_SINGLE, SMARTCAST_TRIGGERED, sObjectMgr, SmartAction::sound, SmartAction::sound1, SmartAction::sound2, SmartAction::sound3, SmartAction::sound4, SmartAction::spawnPos, SmartAction::spawnTimerMax, SmartAction::spawnTimerMin, SmartAction::speed, SmartAction::speedFraction, SmartAction::speedInteger, SmartAction::speedxy, SmartAction::speedz, SmartAction::spell, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_CAST_OK, SPELL_FAILED_OUT_OF_RANGE, SPELL_FAILED_SPELL_IN_PROGRESS, SmartAction::spell_id, SPELLVALUE_BASE_POINT0, SPELLVALUE_BASE_POINT1, SPELLVALUE_BASE_POINT2, SmartAction::spellVisual, sSmartWaypointMgr, sSpellMgr, SmartAction::startAngle, SmartAction::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, SmartAction::talk, SmartScriptHolder::target, SmartAction::targetParam1, SmartAction::targetParam2, SmartAction::targetParam3, SmartAction::targetParam4, SmartAction::targetsLimit, SmartAction::targetsummon, SmartAction::targetType, SmartAction::taxi, TEAM_NEUTRAL, SmartAction::teleport, TEMPSUMMON_CORPSE_DESPAWN, TEMPSUMMON_TIMED_DESPAWN, TEXT_RANGE_NORMAL, SmartAction::textGroupID, SmartAction::textId, SmartAction::threatDEC, SmartAction::threatINC, SmartAction::threatPCT, SmartAction::timedActionList, SmartAction::timeEvent, SmartAction::timer, Object::ToCreature(), Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), SmartAction::transport, trigger, TRIGGERED_FULL_MASK, TRIGGERED_NONE, SmartAction::triggerFlags, SmartAction::turnAngle, SmartEvent::type, SmartAction::type, SmartTarget::type, UNIT_DYNAMIC_FLAGS, UNIT_FIELD_BYTES_1, UNIT_FIELD_FLAGS, UNIT_FIELD_FLAGS_2, UNIT_FLAG_SILENCED, UNIT_NPC_EMOTESTATE, UNIT_STATE_LOST_CONTROL, UNIT_STATE_NO_ENVIRONMENT_UPD, UNIT_STATE_ROOT, UNIT_VIRTUAL_ITEM_SLOT_ID, SmartAction::unitFlag, SmartTarget::unitRange, SmartAction::updateLevel, SmartAction::updateTemplate, urand(), GameObject::UseDoorOrButton(), SmartAction::useTalkTarget, SmartAction::value, SmartAction::visibility, SmartAction::visualId, SmartAction::withDelayed, SmartAction::withEmote, SmartAction::withInstant, SmartAction::worldStateScript, SmartAction::wpData, SmartAction::wpDataRandom, SmartAction::wpPause, SmartAction::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 
)
4037{
4038 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4039 return;
4040
4042 return;
4043
4045 return;
4046
4047 switch (e.GetEventType())
4048 {
4049 case SMART_EVENT_LINK://special handling
4050 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4051 break;
4052 //called from Update tick
4053 case SMART_EVENT_UPDATE:
4055 break;
4057 if (me && me->IsEngaged())
4058 return;
4060 break;
4062 if (!me || !me->IsEngaged())
4063 return;
4065 break;
4067 {
4068 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4069 return;
4070 uint32 perc = (uint32)me->GetHealthPct();
4071 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4072 return;
4074 break;
4075 }
4077 {
4078 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4079 return;
4080 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4081 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4082 return;
4084 break;
4085 }
4087 {
4088 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4089 return;
4091 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4092 return;
4094 break;
4095 }
4097 {
4098 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4099 return;
4101 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4102 return;
4104 break;
4105 }
4106 case SMART_EVENT_RANGE:
4107 {
4108 if (!me || !me->IsEngaged() || !me->GetVictim())
4109 return;
4110
4113 else
4114 RecalcTimer(e, 1200, 1200); // make it predictable
4115
4116 break;
4117 }
4119 {
4120 if (!me || !me->IsEngaged())
4121 return;
4122
4123 Unit* victim = me->GetVictim();
4124
4125 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4126 return;
4127
4128 if (e.event.targetCasting.spellId > 0)
4129 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4130 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4131 return;
4132
4134 break;
4135 }
4137 {
4138 if (!me || !me->IsEngaged())
4139 return;
4140
4142 if (!target || !target->IsInCombat())
4143 {
4144 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4145 RecalcTimer(e, 1000, 3000);
4146 return;
4147 }
4149 break;
4150 }
4152 {
4153 if (!me || !me->IsEngaged())
4154 return;
4155
4156 std::vector<Creature*> creatures;
4158 if (creatures.empty())
4159 {
4160 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4161 RecalcTimer(e, 1000, 3000);
4162 return;
4163 }
4165 break;
4166 }
4168 {
4170 {
4171 return;
4172 }
4173
4174 std::vector<Creature*> creatures;
4176
4177 if (creatures.empty())
4178 return;
4179
4181 break;
4182 }
4184 {
4185 if (!me)
4186 return;
4187 uint32 count = me->GetAuraCount(e.event.aura.spell);
4188 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4190 break;
4191 }
4193 {
4194 if (!me || !me->GetVictim())
4195 return;
4197 if (count < e.event.aura.count)
4198 return;
4200 break;
4201 }
4203 {
4204 if (bvar == (e.event.charm.onRemove != 1))
4205 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4206 break;
4207 }
4208 //no params
4209 case SMART_EVENT_AGGRO:
4210 case SMART_EVENT_DEATH:
4211 case SMART_EVENT_EVADE:
4224 case SMART_EVENT_RESET:
4228 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4229 break;
4230
4232 switch (e.event.gossipHello.filter)
4233 {
4234 case 0:
4235 // no filter set, always execute action
4236 break;
4237 case 1:
4238 // GossipHello only filter set, skip action if reportUse
4239 if (var0)
4240 {
4241 return;
4242 }
4243 break;
4244 case 2:
4245 // reportUse only filter set, skip action if GossipHello
4246 if (!var0)
4247 {
4248 return;
4249 }
4250 break;
4251 default:
4252 // Ignore any other value
4253 break;
4254 }
4255
4256 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4257 break;
4259 {
4260 if (!me)
4261 return;
4262
4263 if (Unit* victim = me->GetVictim())
4264 {
4266 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4268 }
4269
4270 break;
4271 }
4273 {
4274 if (!me)
4275 return;
4276
4277 if (Unit* victim = me->GetVictim())
4278 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4279 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4281
4282 break;
4283 }
4285 if (e.event.emote.emote == var0)
4286 {
4287 ProcessAction(e, unit);
4288 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4289 }
4290 break;
4291 case SMART_EVENT_KILL:
4292 {
4293 if (!me || !unit)
4294 return;
4295 if (e.event.kill.playerOnly && !unit->IsPlayer())
4296 return;
4297 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4298 return;
4300 ProcessAction(e, unit);
4301 break;
4302 }
4305 {
4306 if (!spell)
4307 return;
4308 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4309 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4310 {
4312 ProcessAction(e, unit, 0, 0, bvar, spell);
4313 }
4314 break;
4315 }
4317 {
4318 if (!me || me->IsEngaged())
4319 return;
4320 //can trigger if closer than fMaxAllowedRange
4321 float range = (float)e.event.los.maxDist;
4322
4323 //if range is ok and we are actually in LOS
4324 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4325 {
4327 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4328 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4329 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4330 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4331 {
4332 if (e.event.los.playerOnly && !unit->IsPlayer())
4333 return;
4335 ProcessAction(e, unit);
4336 }
4337 }
4338 break;
4339 }
4340 case SMART_EVENT_IC_LOS:
4341 {
4342 if (!me || !me->IsEngaged())
4343 return;
4344 //can trigger if closer than fMaxAllowedRange
4345 float range = (float)e.event.los.maxDist;
4346
4347 //if range is ok and we are actually in LOS
4348 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4349 {
4351 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4352 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4353 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4354 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4355 {
4356 if (e.event.los.playerOnly && !unit->IsPlayer())
4357 return;
4359 ProcessAction(e, unit);
4360 }
4361 }
4362 break;
4363 }
4365 {
4366 if (!GetBaseObject())
4367 return;
4369 return;
4371 return;
4372 ProcessAction(e);
4373 break;
4374 }
4378 {
4379 if (!IsCreature(unit))
4380 return;
4381 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4382 return;
4384 ProcessAction(e, unit);
4385 break;
4386 }
4390 {
4391 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4392 return;
4394 ProcessAction(e, unit);
4395 break;
4396 }
4398 {
4399 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4400 return;
4401 ProcessAction(e, unit, var0, var1);
4402 break;
4403 }
4406 {
4407 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4408 return;
4409 ProcessAction(e, unit, var0);
4410 break;
4411 }
4417 {
4418 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4419 return;
4420 ProcessAction(e, unit);
4421 break;
4422 }
4424 {
4425 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4426 return;
4428 ProcessAction(e, unit, var0);
4429 break;
4430 }
4432 {
4434 return;
4436 ProcessAction(e, unit, var0);
4437 break;
4438 }
4441 {
4442 if (e.event.quest.quest && var0 != e.event.quest.quest)
4443 return;
4444 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4445 ProcessAction(e, unit, var0);
4446 break;
4447 }
4449 {
4451 return;
4452 ProcessAction(e, unit, var0);
4453 break;
4454 }
4456 {
4457 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4458 return;
4459 ProcessAction(e, unit, var0);
4460 break;
4461 }
4463 {
4465 return;
4466 ProcessAction(e, unit, var0);
4467 break;
4468 }
4470 {
4471 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4472 return;
4474 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4475 break;
4476 }
4479 {
4480 if (!unit)
4481 return;
4483 ProcessAction(e, unit);
4484 break;
4485 }
4487 {
4488 if (e.event.timedEvent.id == var0)
4489 ProcessAction(e, unit);
4490 break;
4491 }
4493 {
4494 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4495 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4496 return;
4497 ProcessAction(e, unit, var0, var1);
4498 break;
4499 }
4501 {
4503 return;
4504
4505 WorldObject* templastInvoker = GetLastInvoker();
4506 if (!templastInvoker)
4507 return;
4508
4509 if (!IsUnit(templastInvoker))
4510 return;
4511
4512 ProcessAction(e, templastInvoker->ToUnit());
4513 break;
4514 }
4517 {
4518 if (e.event.gameEvent.gameEventId != var0)
4519 return;
4520 ProcessAction(e, nullptr, var0);
4521 break;
4522 }
4524 {
4525 if (e.event.goStateChanged.state != var0)
4526 return;
4527 ProcessAction(e, unit, var0, var1);
4528 break;
4529 }
4531 {
4532 if (e.event.eventInform.eventId != var0)
4533 return;
4534 ProcessAction(e, nullptr, var0);
4535 break;
4536 }
4538 {
4539 if (e.event.doAction.eventId != var0)
4540 return;
4541 ProcessAction(e, unit, var0);
4542 break;
4543 }
4545 {
4546 if (!me || !me->IsEngaged())
4547 return;
4548
4549 Unit* unitTarget = nullptr;
4550 switch (e.GetTargetType())
4551 {
4559 {
4560 ObjectVector targets;
4561 GetTargets(targets, e);
4562 for (WorldObject* target : targets)
4563 {
4564 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4565 {
4566 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4567 if (healthPct > e.event.friendlyHealthPct.hpPct)
4568 {
4569 continue;
4570 }
4571
4572 unitTarget = target->ToUnit();
4573 break;
4574 }
4575 }
4576
4577 break;
4578 }
4579 case SMART_TARGET_SELF:
4582 break;
4583 default:
4584 return;
4585 }
4586
4587 if (!unitTarget)
4588 return;
4589
4591 break;
4592 }
4594 {
4595 if (!me)
4596 return;
4597
4598 WorldObject* creature = nullptr;
4599
4600 if (e.event.distance.guid != 0)
4601 {
4602 creature = FindCreatureNear(me, e.event.distance.guid);
4603
4604 if (!creature)
4605 return;
4606
4607 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4608 return;
4609 }
4610 else if (e.event.distance.entry != 0)
4611 {
4612 std::list<Creature*> list;
4614
4615 if (!list.empty())
4616 creature = list.front();
4617 }
4618
4619 if (creature)
4621
4622 break;
4623 }
4625 {
4626 if (!me)
4627 return;
4628
4629 WorldObject* gameobject = nullptr;
4630
4631 if (e.event.distance.guid != 0)
4632 {
4633 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4634
4635 if (!gameobject)
4636 return;
4637
4638 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4639 return;
4640 }
4641 else if (e.event.distance.entry != 0)
4642 {
4643 std::list<GameObject*> list;
4645
4646 if (!list.empty())
4647 gameobject = list.front();
4648 }
4649
4650 if (gameobject)
4652
4653 break;
4654 }
4656 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4657 return;
4658
4660 break;
4662 {
4663 uint32 playerCount = 0;
4664 ObjectVector targets;
4665 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4666
4667 if (!targets.empty())
4668 {
4669 for (WorldObject* target : targets)
4670 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4671 playerCount++;
4672
4673 if (playerCount >= e.event.nearPlayer.minCount)
4674 ProcessAction(e, unit);
4675 }
4677 break;
4678 }
4680 {
4681 uint32 playerCount = 0;
4682 ObjectVector targets;
4683 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4684
4685 if (!targets.empty())
4686 {
4687 for (WorldObject* target : targets)
4688 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4689 playerCount++;
4690
4691 if (playerCount < e.event.nearPlayerNegation.maxCount)
4692 ProcessAction(e, unit);
4693 }
4695 break;
4696 }
4698 {
4699 uint32 unitCount = 0;
4700 ObjectVector targets;
4701 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4702
4703 if (!targets.empty())
4704 {
4705 if (e.event.nearUnit.type)
4706 {
4707 for (WorldObject* target : targets)
4708 {
4709 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4710 unitCount++;
4711 }
4712 }
4713 else
4714 {
4715 for (WorldObject* target : targets)
4716 {
4717 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4718 unitCount++;
4719 }
4720 }
4721
4722 if (unitCount >= e.event.nearUnit.count)
4723 ProcessAction(e, unit);
4724 }
4726 break;
4727 }
4729 {
4730 uint32 unitCount = 0;
4731 ObjectVector targets;
4732 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4733
4734 if (!targets.empty())
4735 {
4737 {
4738 for (WorldObject* target : targets)
4739 {
4740 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4741 unitCount++;
4742 }
4743 }
4744 else
4745 {
4746 for (WorldObject* target : targets)
4747 {
4748 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4749 unitCount++;
4750 }
4751 }
4752
4753 if (unitCount < e.event.nearUnitNegation.count)
4754 ProcessAction(e, unit);
4755 }
4757 break;
4758 }
4760 {
4761 if (!me || !me->IsEngaged())
4762 return;
4763
4765 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4766 {
4767 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4768 {
4769 if (!target || !IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4770 continue;
4771
4772 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4773 continue;
4774
4775 ProcessAction(e, target);
4777 return;
4778 }
4779
4780 // If no targets are found and it's off cooldown, check again in 1200ms
4781 RecalcTimer(e, 1200, 1200);
4782 break;
4783 }
4784
4785 break;
4786 }
4788 {
4789 if (!me || !me->IsEngaged())
4790 return;
4791
4793 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4794 {
4795 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4796 {
4797 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4798 continue;
4799
4800 ProcessAction(e, target);
4802 return;
4803 }
4804 }
4805
4806 // If no targets are found and it's off cooldown, check again
4807 RecalcTimer(e, 1200, 1200);
4808 break;
4809 }
4812 {
4813 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4814 return;
4815 ProcessAction(e, unit);
4816 break;
4817 }
4818 default:
4819 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4820 break;
4821 }
4822}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1933
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:552
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:551
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:125
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:190
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:126
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:140
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:169
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:171
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:148
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:136
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:167
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:120
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:184
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:164
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:191
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:163
@ SMART_EVENT_WAYPOINT_PAUSED
Definition SmartScriptMgr.h:173
@ SMART_EVENT_WAYPOINT_DATA_ENDED
Definition SmartScriptMgr.h:217
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:139
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:160
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:138
@ SMART_EVENT_WAYPOINT_DATA_REACHED
Definition SmartScriptMgr.h:216
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:189
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:172
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:147
@ SMART_EVENT_WAYPOINT_START
Definition SmartScriptMgr.h:157
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:149
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:186
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:123
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:161
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:182
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:180
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:215
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:145
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:159
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:176
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:137
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:195
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:134
@ SMART_EVENT_WAYPOINT_RESUMED
Definition SmartScriptMgr.h:174
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:142
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:129
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:165
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:132
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:124
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:162
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:187
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:150
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:183
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:166
@ SMART_EVENT_WAYPOINT_STOPPED
Definition SmartScriptMgr.h:175
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:202
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:133
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:122
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:130
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:131
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:151
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:141
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:135
@ CURRENT_GENERIC_SPELL
Definition Unit.h:539
uint32 GetWaypointPath() const
Definition Creature.h:350
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5283
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5273
void ProcessAction(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:163
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5366
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5246
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5412
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5259
void ProcessTimedAction(SmartScriptHolder &e, uint32 const &min, uint32 const &max, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:3320
Definition Spell.h:287
float GetHealthPct() const
Definition Unit.h:1033
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4146
uint32 GetMaxHealth() const
Definition Unit.h:1032
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:665
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5738
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1059
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10302
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:10297
bool IsInCombat() const
Definition Unit.h:879
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1495
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2488
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2502
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition Object.cpp:1314
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition Position.cpp:141
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:272
uint32 pointId
Definition SmartScriptMgr.h:524
uint32 invert
Definition SmartScriptMgr.h:510
uint32 entry
Definition SmartScriptMgr.h:463
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:358
LOSHostilityMode
Definition SmartScriptMgr.h:540
uint32 cooldownMax
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:371
uint32 radius
Definition SmartScriptMgr.h:292
uint32 maxDist
Definition SmartScriptMgr.h:263
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:415
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:252
uint32 rangeMin
Definition SmartScriptMgr.h:237
uint32 eventId
Definition SmartScriptMgr.h:442
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:464
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:286
uint32 emote
Definition SmartScriptMgr.h:329
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:456
uint32 filter
Definition SmartScriptMgr.h:410
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:262
uint32 hpDeficit
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:273
uint32 count
Definition SmartScriptMgr.h:337
uint32 onlyInCombat
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:364
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:372
SAIBool playerOnly
Definition SmartScriptMgr.h:245
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:525
uint32 creatureEntry
Definition SmartScriptMgr.h:400
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:416
struct SmartEvent::@30::@64 doAction
struct SmartEvent::@30::@46 charm
struct SmartEvent::@30::@63 eventInform
struct SmartEvent::@30::@38 targetCasting
uint32 spell
Definition SmartScriptMgr.h:251
uint32 maxCount
Definition SmartScriptMgr.h:487
uint32 gameEventId
Definition SmartScriptMgr.h:432
uint32 textGroupID
Definition SmartScriptMgr.h:399
uint32 cooldownMin
Definition SmartScriptMgr.h:243
uint32 onRemove
Definition SmartScriptMgr.h:344
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:322
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:437
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:238
uint32 team
Definition SmartScriptMgr.h:387
uint32 range
Definition SmartScriptMgr.h:499
uint32 minCount
Definition SmartScriptMgr.h:478
struct SmartEvent::@30::@37 minMax
struct SmartEvent::@30::@55 textOver
struct SmartEvent::@30::@40 friendlyCC
struct SmartEvent::@30::@62 goStateChanged
uint32 creature
Definition SmartScriptMgr.h:246
uint32 phasemask
Definition SmartScriptMgr.h:427

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

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

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

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

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

◆ ProcessTimedAction()

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

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

Referenced by ProcessEvent().

◆ RaisePriority()

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

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

Referenced by RetryLater(), and UpdateTimer().

◆ RecalcTimer()

void SmartScript::RecalcTimer ( SmartScriptHolder e,
uint32  min,
uint32  max 
)
static
4858{
4859 // min/max was checked at loading!
4860 e.timer = urand(uint32(min), uint32(max));
4861 e.active = e.timer ? false : true;
4862}

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

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

◆ RemoveCreatureSummon()

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

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

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

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

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

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

Referenced by OnReset(), and ProcessAction().

◆ RetryLater()

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

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

Referenced by ProcessAction().

◆ SetPathId()

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

References mPathId.

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

◆ SetPhase()

void SmartScript::SetPhase ( uint32  p)
private
5401{
5402 uint32 oldPhase = mEventPhase;
5403
5404 mEventPhase = p;
5405
5406 if (oldPhase != mEventPhase)
5407 {
5409 }
5410}

References mEventPhase, ProcessEventsFor(), and SMART_EVENT_EVENT_PHASE_CHANGE.

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

◆ SetPhaseReset()

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

References _allowPhaseReset.

Referenced by ProcessAction().

◆ SetScript9()

void SmartScript::SetScript9 ( SmartScriptHolder e,
uint32  entry 
)
5306{
5307 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5308 // any SmartScriptHolder contained like the "e" parameter passed to this function
5310 {
5311 LOG_ERROR("scripts.ai.sai", "Entry {} SourceType {} Event {} Action {} is trying to overwrite timed action list from a timed action, this is not allowed!.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
5312 return;
5313 }
5314
5315 // Do NOT allow to start a new actionlist if a previous one is already running, unless explicitly allowed. We need to always finish the current actionlist
5317 {
5318 return;
5319 }
5320
5321 mTimedActionList.clear();
5323 if (mTimedActionList.empty())
5324 return;
5325 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5326 {
5327 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5328
5329 if (e.action.timedActionList.timerType == 0)
5330 i->event.type = SMART_EVENT_UPDATE_OOC;
5331 else if (e.action.timedActionList.timerType == 1)
5332 i->event.type = SMART_EVENT_UPDATE_IC;
5333 else if (e.action.timedActionList.timerType > 1)
5334 i->event.type = SMART_EVENT_UPDATE;
5335
5336 InitTimer((*i));
5337 }
5338}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1775
SAIBool allowOverride
Definition SmartScriptMgr.h:1163
uint32 timerType
Definition SmartScriptMgr.h:1162

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

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

◆ SortEvents()

void SmartScript::SortEvents ( SmartAIEventList events)
private
5055{
5056 std::sort(events.begin(), events.end());
5057}
events
Definition boss_sartura.cpp:43

Referenced by OnUpdate().

◆ StoreCounter()

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

References mCounterList, ProcessEventsFor(), and SMART_EVENT_COUNTER_SET.

Referenced by ProcessAction().

◆ StoreTargetList()

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

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

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

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: