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

#include "SmartScript.h"

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

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
46{
47 go = nullptr;
48 me = nullptr;
49 trigger = nullptr;
50 mEventPhase = 0;
51 mPathId = 0;
52 mTextTimer = 0;
53 mLastTextID = 0;
54 mUseTextTimer = false;
55 mTalkerEntry = 0;
61 _allowPhaseReset = true;
62}
@ SMART_SCRIPT_TYPE_CREATURE
Definition: SmartScriptMgr.h:1734
@ SMARTAI_TEMPLATE_BASIC
Definition: SmartScriptMgr.h:1492
uint32 mEventPhase
Definition: SmartScript.h:220
SMARTAI_TEMPLATE mTemplate
Definition: SmartScript.h:239
Creature * me
Definition: SmartScript.h:214
uint32 mPathId
Definition: SmartScript.h:223
SmartScriptType mScriptType
Definition: SmartScript.h:219
bool _allowPhaseReset
Definition: SmartScript.h:235
bool mUseTextTimer
Definition: SmartScript.h:230
uint32 mLastTextID
Definition: SmartScript.h:228
uint32 mTextTimer
Definition: SmartScript.h:227
GameObject * go
Definition: SmartScript.h:216
AreaTrigger const * trigger
Definition: SmartScript.h:218
uint32 mCurrentPriority
Definition: SmartScript.h:231
uint32 mTalkerEntry
Definition: SmartScript.h:229
bool isProcessingTimedActionList
Definition: SmartScript.h:213
bool mEventSortingRequired
Definition: SmartScript.h:232

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

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5342{
5343 _summonList.insert(guid);
5344}
GuidUnorderedSet _summonList
Definition: SmartScript.h:272

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 
)
3356{
3357 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));
3358}
SmartAIEventList mInstallEvents
Definition: SmartScript.h:211
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:3360

References CreateSmartEvent(), and mInstallEvents.

Referenced by InstallTemplate().

◆ AllowPhaseReset()

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

References _allowPhaseReset.

Referenced by OnReset().

◆ CheckTimer()

bool SmartScript::CheckTimer ( SmartScriptHolder const &  e) const
4890{
4891 return e.active;
4892}

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
3361{
3362 SmartScriptHolder script;
3363 script.event.type = e;
3364 script.event.raw.param1 = event_param1;
3365 script.event.raw.param2 = event_param2;
3366 script.event.raw.param3 = event_param3;
3367 script.event.raw.param4 = event_param4;
3368 script.event.raw.param5 = event_param5;
3369 script.event.raw.param6 = event_param6;
3370 script.event.event_phase_mask = phaseMask;
3371 script.event.event_flags = event_flags;
3372 script.event.event_chance = 100;
3373
3374 script.action.type = action;
3375 script.action.raw.param1 = action_param1;
3376 script.action.raw.param2 = action_param2;
3377 script.action.raw.param3 = action_param3;
3378 script.action.raw.param4 = action_param4;
3379 script.action.raw.param5 = action_param5;
3380 script.action.raw.param6 = action_param6;
3381
3382 script.target.type = t;
3383 script.target.raw.param1 = target_param1;
3384 script.target.raw.param2 = target_param2;
3385 script.target.raw.param3 = target_param3;
3386 script.target.raw.param4 = target_param4;
3387
3389 InitTimer(script);
3390 return script;
3391}
static void InitTimer(SmartScriptHolder &e)
Definition: SmartScript.cpp:4752
uint32 param1
Definition: SmartScriptMgr.h:520
uint32 event_flags
Definition: SmartScriptMgr.h:228
uint32 event_phase_mask
Definition: SmartScriptMgr.h:226
uint32 param2
Definition: SmartScriptMgr.h:521
uint32 param4
Definition: SmartScriptMgr.h:523
struct SmartEvent::@30::@73 raw
uint32 param3
Definition: SmartScriptMgr.h:522
uint32 param6
Definition: SmartScriptMgr.h:525
uint32 event_chance
Definition: SmartScriptMgr.h:227
uint32 param5
Definition: SmartScriptMgr.h:524
SMART_EVENT type
Definition: SmartScriptMgr.h:225
uint32 param3
Definition: SmartScriptMgr.h:1062
uint32 param5
Definition: SmartScriptMgr.h:1064
uint32 param1
Definition: SmartScriptMgr.h:1060
SMART_ACTION type
Definition: SmartScriptMgr.h:747
uint32 param4
Definition: SmartScriptMgr.h:1063
uint32 param6
Definition: SmartScriptMgr.h:1485
struct SmartAction::@74::@192 raw
uint32 param2
Definition: SmartScriptMgr.h:1061
uint32 param4
Definition: SmartScriptMgr.h:1714
uint32 param1
Definition: SmartScriptMgr.h:1711
uint32 param3
Definition: SmartScriptMgr.h:1713
struct SmartTarget::@193::@217 raw
SMARTAI_TARGETS type
Definition: SmartScriptMgr.h:1563
uint32 param2
Definition: SmartScriptMgr.h:1712
Definition: SmartScriptMgr.h:1934
SmartAction action
Definition: SmartScriptMgr.h:1945
SmartScriptType source_type
Definition: SmartScriptMgr.h:1940
SmartEvent event
Definition: SmartScriptMgr.h:1944
SmartTarget target
Definition: SmartScriptMgr.h:1946

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

◆ DecPhase()

void SmartScript::DecPhase ( uint32  p)
private
5308{
5309 if (p >= mEventPhase)
5310 {
5311 SetPhase(0);
5312 }
5313 else
5314 {
5315 SetPhase(mEventPhase - p);
5316 }
5317}
void SetPhase(uint32 p)
Definition: SmartScript.cpp:5319

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5213{
5214 if (!me)
5215 return nullptr;
5216
5217 Unit* unit = nullptr;
5218 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5220 Cell::VisitAllObjects(me, searcher, range);
5221 return unit;
5222}
Definition: Unit.h:630
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:207
Definition: GridNotifiers.h:406

References me, and Cell::VisitAllObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5193{
5194 if (!me)
5195 return;
5196
5197 Acore::FriendlyCCedInRange u_check(me, range);
5199 Cell::VisitGridObjects(me, searcher, range);
5200}
creatures
Definition: boss_prince_malchezaar.cpp:51
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GridNotifiers.h:473
Definition: GridNotifiers.h:818

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
5203{
5204 if (!me)
5205 return;
5206
5207 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5209 Cell::VisitGridObjects(me, searcher, range);
5210}
Definition: GridNotifiers.h:836

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5166{
5167 if (!me)
5168 return nullptr;
5169
5170 Unit* unit = nullptr;
5171
5172 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5174 Cell::VisitGridObjects(me, searcher, range);
5175 return unit;
5176}
Definition: GridNotifiers.h:775

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5179{
5180 if (!me)
5181 {
5182 return nullptr;
5183 }
5184
5185 Unit* unit = nullptr;
5186 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5188 Cell::VisitGridObjects(me, searcher, range);
5189 return unit;
5190}
Definition: GridNotifiers.h:794

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5001{
5002 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5003
5004 if (e.empty())
5005 {
5006 if (obj)
5007 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5008
5009 if (at)
5010 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5011 return;
5012 }
5013 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5014 {
5015#ifndef ACORE_DEBUG
5016 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5017 continue;
5018#endif
5019
5020 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5021 {
5022 if (obj && obj->GetMap()->IsDungeon())
5023 {
5024 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5025 {
5026 mEvents.push_back((*i));
5027 }
5028 }
5029 continue;
5030 }
5031 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5032 }
5033}
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition: SmartScriptMgr.h:1902
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition: SmartScriptMgr.h:1898
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
SmartAIEventList mEvents
Definition: SmartScript.h:210
uint32 GetEntry() const
Definition: Object.h:112
Map * GetMap() const
Definition: Object.h:531
bool IsDungeon() const
Definition: Map.h:448
uint8 GetSpawnMode() const
Definition: Map.h:420

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
142 {
143 auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid);
144 if (bounds.first == bounds.second)
145 return nullptr;
146
147 auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
148 {
149 return pair.second->IsAlive();
150 });
151
152 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
153 }
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:520

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindGameObjectNear()

GameObject * SmartScript::FindGameObjectNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const
inline
133 {
134 auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
135 if (bounds.first == bounds.second)
136 return nullptr;
137
138 return bounds.first->second;
139 }
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:523

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

SmartScriptHolder SmartScript::FindLinkedEvent ( uint32  link)
inlineprivate
257 {
258 if (!mEvents.empty())
259 {
260 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
261 {
262 if (i->event_id == link)
263 {
264 return (*i);
265 }
266 }
267 }
269 return s;
270 }

References mEvents.

◆ GetBaseObject()

WorldObject * SmartScript::GetBaseObject ( ) const
inline
55 {
56 WorldObject* obj = nullptr;
57 if (me)
58 obj = me;
59 else if (go)
60 obj = go;
61 return obj;
62 }
Definition: Object.h:405

References go, and me.

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

◆ GetCounterValue()

uint32 SmartScript::GetCounterValue ( uint32  id)
inline
125 {
126 CounterMap::iterator itr = mCounterList.find(id);
127 if (itr != mCounterList.end())
128 return itr->second;
129 return 0;
130 }
CounterMap mCounterList
Definition: SmartScript.h:192

References mCounterList.

Referenced by ProcessEvent().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5260{
5261 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5262 if (GetBaseObject())
5264 // xinef: used for area triggers invoker cast
5265 else if (invoker)
5267 return nullptr;
5268}
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:118
ObjectGuid mLastInvoker
Definition: SmartScript.h:190
WorldObject * GetBaseObject() const
Definition: SmartScript.h:54

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

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

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5036{
5038 if (me)
5039 {
5040 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5041 if (e.empty())
5042 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5043
5044 FillScript(e, me, nullptr);
5045
5046 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5047 {
5048 if (cInfo->HasFlagsExtra(CREATURE_FLAG_DONT_OVERRIDE_ENTRY_SAI))
5049 {
5050 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5051 FillScript(e, me, nullptr);
5052 }
5053 }
5054 }
5055 else if (go)
5056 {
5057 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5058 if (e.empty())
5059 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5060 FillScript(e, go, nullptr);
5061 }
5062 else if (trigger)
5063 {
5064 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5065 FillScript(e, nullptr, trigger);
5066 }
5067}
@ CREATURE_FLAG_DONT_OVERRIDE_ENTRY_SAI
Definition: CreatureData.h:73
std::vector< SmartScriptHolder > SmartAIEventList
Definition: SmartScriptMgr.h:2030
#define sSmartScriptMgr
Definition: SmartScriptMgr.h:2204
std::int32_t int32
Definition: Define.h:103
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition: SmartScript.cpp:5000
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:68
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:206
Definition: CreatureData.h:189
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:145
uint32 entry
Definition: ObjectMgr.h:422

References CREATURE_FLAG_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
91 {
92 auto itr = _storedTargets.find(id);
93 if (itr != _storedTargets.end())
94 return itr->second.GetObjectVector(ref);
95 return nullptr;
96 }
ObjectVectorMap _storedTargets
Definition: SmartScript.h:237

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3394{
3395 WorldObject* scriptTrigger = nullptr;
3396 if (invoker)
3397 scriptTrigger = invoker;
3398 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3399 scriptTrigger = tempLastInvoker;
3400
3401 WorldObject* baseObject = GetBaseObject();
3402
3403 switch (e.GetTargetType())
3404 {
3405 case SMART_TARGET_SELF:
3406 if (baseObject)
3407 targets.push_back(baseObject);
3408 break;
3410 if (me)
3411 if (Unit* victim = me->GetVictim())
3412 targets.push_back(victim);
3413 break;
3415 if (me)
3416 {
3417 if (e.target.hostileRandom.powerType)
3418 {
3419 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
3420 targets.push_back(u);
3421 }
3422 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3423 targets.push_back(u);
3424 }
3425 break;
3427 if (me)
3428 {
3429 if (e.target.hostileRandom.powerType)
3430 {
3431 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)))
3432 targets.push_back(u);
3433 }
3434 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3435 targets.push_back(u);
3436 }
3437 break;
3439 if (me)
3440 {
3441 if (e.target.hostileRandom.powerType)
3442 {
3443 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)))
3444 targets.push_back(u);
3445 }
3446 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3447 targets.push_back(u);
3448 }
3449 break;
3451 if (me)
3452 {
3453 if (e.target.hostileRandom.powerType)
3454 {
3455 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
3456 targets.push_back(u);
3457 }
3458 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3459 targets.push_back(u);
3460 }
3461 break;
3463 if (me)
3464 {
3465 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, FarthestTargetSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos, e.target.farthest.minDist)))
3466 targets.push_back(u);
3467 }
3468 break;
3470 if (scriptTrigger)
3471 targets.push_back(scriptTrigger);
3472 break;
3474 if (scriptTrigger && IsUnit(scriptTrigger))
3475 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3476 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3477 break;
3479 if (scriptTrigger)
3480 {
3481 if (Player* player = scriptTrigger->ToPlayer())
3482 {
3483 if (Group* group = player->GetGroup())
3484 {
3485 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3486 if (Player* member = groupRef->GetSource())
3487 if (member->IsInMap(player))
3488 targets.push_back(member);
3489 }
3490 // We still add the player to the list if there is no group. If we do
3491 // this even if there is a group (thus the else-check), it will add the
3492 // same player to the list twice. We don't want that to happen.
3493 else
3494 targets.push_back(scriptTrigger);
3495 }
3496 }
3497 break;
3499 {
3500 WorldObject* ref = baseObject;
3501 if (!ref)
3502 ref = scriptTrigger;
3503
3504 if (!ref)
3505 {
3506 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3507 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3508 break;
3509 }
3510
3511 ObjectVector units;
3512 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3513
3514 for (WorldObject* unit : units)
3515 {
3516 if (!IsCreature(unit))
3517 continue;
3518
3519 if (me && me->GetGUID() == unit->GetGUID())
3520 continue;
3521
3522 // check alive state - 1 alive, 2 dead, 0 both
3523 if (uint32 state = e.target.unitRange.livingState)
3524 {
3525 if (unit->ToCreature()->IsAlive() && state == 2)
3526 continue;
3527 if (!unit->ToCreature()->IsAlive() && state == 1)
3528 continue;
3529 }
3530
3531 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))
3532 targets.push_back(unit);
3533 }
3534
3535 break;
3536 }
3538 {
3539 ObjectVector units;
3540 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3541
3542 for (WorldObject* unit : units)
3543 {
3544 if (!IsCreature(unit))
3545 continue;
3546
3547 if (me && me->GetGUID() == unit->GetGUID())
3548 continue;
3549
3550 // check alive state - 1 alive, 2 dead, 0 both
3551 if (uint32 state = e.target.unitDistance.livingState)
3552 {
3553 if (unit->ToCreature()->IsAlive() && state == 2)
3554 continue;
3555 if (!unit->ToCreature()->IsAlive() && state == 1)
3556 continue;
3557 }
3558
3559 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3560 targets.push_back(unit);
3561 }
3562
3563 break;
3564 }
3566 {
3567 ObjectVector units;
3568 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3569
3570 for (WorldObject* unit : units)
3571 {
3572 if (!IsGameObject(unit))
3573 continue;
3574
3575 if (go && go->GetGUID() == unit->GetGUID())
3576 continue;
3577
3578 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3579 targets.push_back(unit);
3580 }
3581
3582 break;
3583 }
3585 {
3586
3587 WorldObject* ref = baseObject;
3588 if (!ref)
3589 ref = scriptTrigger;
3590
3591 if (!ref)
3592 {
3593 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3594 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3595 break;
3596 }
3597
3598 ObjectVector units;
3599 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3600
3601 for (WorldObject* unit : units)
3602 {
3603 if (!IsGameObject(unit))
3604 continue;
3605
3606 if (go && go->GetGUID() == unit->GetGUID())
3607 continue;
3608
3609 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))
3610 targets.push_back(unit);
3611 }
3612
3613 break;
3614 }
3616 {
3617 if (!scriptTrigger && !baseObject)
3618 {
3619 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3620 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3621 break;
3622 }
3623
3624 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3625 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3626 targets.push_back(target);
3627 break;
3628 }
3630 {
3631 if (!scriptTrigger && !GetBaseObject())
3632 {
3633 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3634 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3635 break;
3636 }
3637
3638 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3639 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3640 targets.push_back(target);
3641 break;
3642 }
3644 {
3645 ObjectVector units;
3646 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3647
3648 if (!units.empty() && baseObject)
3649 for (WorldObject* unit : units)
3650 if (IsPlayer(unit) && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3651 targets.push_back(unit);
3652 if (e.target.playerRange.maxCount)
3653 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3654 break;
3655 }
3657 {
3658 ObjectVector units;
3659 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3660
3661 for (WorldObject* unit : units)
3662 if (IsPlayer(unit))
3663 targets.push_back(unit);
3664 break;
3665 }
3667 {
3668 WorldObject* ref = baseObject;
3669 if (!ref)
3670 ref = scriptTrigger;
3671
3672 if (!ref)
3673 {
3674 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3675 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3676 break;
3677 }
3678
3679 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3680 targets.assign(stored->begin(), stored->end());
3681 break;
3682 }
3684 {
3685 WorldObject* ref = baseObject;
3686
3687 if (!ref)
3688 ref = scriptTrigger;
3689
3690 if (!ref)
3691 {
3692 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3693 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3694 break;
3695 }
3696
3697 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3698 if (target)
3699 targets.push_back(target);
3700 break;
3701 }
3703 {
3704 WorldObject* ref = baseObject;
3705
3706 if (!ref)
3707 ref = scriptTrigger;
3708
3709 if (!ref)
3710 {
3711 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3712 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3713 break;
3714 }
3715
3716 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3717 if (target)
3718 targets.push_back(target);
3719 break;
3720 }
3722 {
3723 WorldObject* ref = baseObject;
3724
3725 if (!ref)
3726 ref = scriptTrigger;
3727
3728 if (!ref)
3729 {
3730 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3731 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3732 break;
3733 }
3734
3735 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3736 targets.push_back(target);
3737 break;
3738 }
3740 /*
3741 * Owners/Summoners should be WorldObjects. This allows to have other objects
3742 * such as gameobjects to execute SmartScripts using this type of target.
3743 * Otherwise, only Units like creatures can summon other creatures.
3744 */
3745 {
3746 if (me)
3747 {
3749 {
3750 targets.push_back(owner);
3751 }
3752 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3753 {
3754 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3755 }
3756 }
3757 else if (go)
3758 {
3760 {
3761 targets.push_back(owner);
3762 }
3763 }
3764
3765 // xinef: Get owner of owner
3766 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3767 {
3768 if (WorldObject* owner = targets.front())
3769 {
3770 targets.clear();
3771
3772 if (owner->ToCreature())
3773 {
3774 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3775 {
3776 targets.push_back(base);
3777 }
3778 }
3779 else
3780 {
3781 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3782 {
3783 targets.push_back(base);
3784 }
3785 }
3786 }
3787 }
3788 break;
3789 }
3791 {
3792 if (me)
3793 {
3795 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
3796 if (Unit* temp = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
3797 // Xinef: added distance check
3798 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3799 targets.push_back(temp);
3800 }
3801 break;
3802 }
3804 {
3805 if (me)
3806 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3807 targets.push_back(target);
3808
3809 break;
3810 }
3812 {
3813 if (me)
3814 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3815 targets.push_back(target);
3816
3817 break;
3818 }
3820 {
3821 ObjectVector units;
3822 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3823
3824 for (WorldObject* unit : units)
3825 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3826 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3827 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3828 targets.push_back(unit);
3829
3830 if (e.target.o > 0)
3831 Acore::Containers::RandomResize(targets, e.target.o);
3832
3833 break;
3834 }
3836 {
3837 ObjectVector units;
3838 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3839 // 1 = Tanks, 2 = Healer, 4 = Damage
3840 uint32 roleMask = e.target.roleSelection.roleMask;
3841 for (WorldObject* unit : units)
3842 if (Player* targetPlayer = unit->ToPlayer())
3843 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3844 {
3845 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3846 {
3847 if (targetPlayer->HasTankSpec())
3848 {
3849 targets.push_back(unit);
3850 continue;
3851 }
3852 }
3853 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3854 {
3855 if (targetPlayer->HasHealSpec())
3856 {
3857 targets.push_back(unit);
3858 continue;
3859 }
3860 }
3861 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3862 {
3863 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3864 {
3865 targets.push_back(unit);
3866 continue;
3867 }
3868 }
3869 }
3870
3871 if (e.target.roleSelection.resize > 0)
3872 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
3873
3874 break;
3875 }
3877 {
3878 if (me && me->IsVehicle())
3879 {
3880 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
3881 {
3882 targets.push_back(target);
3883 }
3884 }
3885 break;
3886 }
3888 {
3889 if (me)
3890 {
3891 if (Group* lootGroup = me->GetLootRecipientGroup())
3892 {
3893 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
3894 {
3895 if (Player* recipient = it->GetSource())
3896 {
3897 targets.push_back(recipient);
3898 }
3899 }
3900 }
3901 else
3902 {
3903 if (Player* recipient = me->GetLootRecipient())
3904 {
3905 targets.push_back(recipient);
3906 }
3907 }
3908 }
3909 break;
3910 }
3912 {
3913 if (me)
3914 {
3915 for (ObjectGuid const& guid : _summonList)
3916 {
3917 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
3918 {
3919 if (Creature* creature = me->GetMap()->GetCreature(guid))
3920 {
3921 targets.push_back(creature);
3922 }
3923 }
3924 }
3925 }
3926 break;
3927 }
3929 {
3930 if (InstanceScript* instance = GetBaseObject()->GetInstanceScript())
3931 {
3932 if (e.target.instanceStorage.type == 1)
3933 {
3934 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
3935 {
3936 targets.push_back(creature);
3937 }
3938 }
3939 else if (e.target.instanceStorage.type == 2)
3940 {
3941 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
3942 {
3943 targets.push_back(go);
3944 }
3945 }
3946 }
3947 else
3948 {
3949 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
3950 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3951 }
3952
3953 break;
3954 }
3955 case SMART_TARGET_NONE:
3957 default:
3958 break;
3959 }
3960}
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition: SmartScriptMgr.h:1728
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition: SmartScriptMgr.h:1727
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition: SmartScriptMgr.h:1729
@ SMART_TARGET_LOOT_RECIPIENTS
Definition: SmartScriptMgr.h:1530
@ SMART_TARGET_CLOSEST_CREATURE
Definition: SmartScriptMgr.h:1522
@ SMART_TARGET_CREATURE_DISTANCE
Definition: SmartScriptMgr.h:1514
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition: SmartScriptMgr.h:1509
@ SMART_TARGET_INVOKER_PARTY
Definition: SmartScriptMgr.h:1519
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition: SmartScriptMgr.h:1529
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition: SmartScriptMgr.h:1523
@ SMART_TARGET_VEHICLE_PASSENGER
Definition: SmartScriptMgr.h:1532
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition: SmartScriptMgr.h:1516
@ SMART_TARGET_CREATURE_GUID
Definition: SmartScriptMgr.h:1513
@ SMART_TARGET_PLAYER_RANGE
Definition: SmartScriptMgr.h:1520
@ SMART_TARGET_SUMMONED_CREATURES
Definition: SmartScriptMgr.h:1543
@ SMART_TARGET_VICTIM
Definition: SmartScriptMgr.h:1505
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition: SmartScriptMgr.h:1518
@ SMART_TARGET_CREATURE_RANGE
Definition: SmartScriptMgr.h:1512
@ SMART_TARGET_CLOSEST_PLAYER
Definition: SmartScriptMgr.h:1524
@ SMART_TARGET_HOSTILE_RANDOM
Definition: SmartScriptMgr.h:1508
@ SMART_TARGET_GAMEOBJECT_GUID
Definition: SmartScriptMgr.h:1517
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition: SmartScriptMgr.h:1506
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition: SmartScriptMgr.h:1526
@ SMART_TARGET_SELF
Definition: SmartScriptMgr.h:1504
@ SMART_TARGET_PLAYER_WITH_AURA
Definition: SmartScriptMgr.h:1540
@ SMART_TARGET_ROLE_SELECTION
Definition: SmartScriptMgr.h:1542
@ SMART_TARGET_ACTION_INVOKER
Definition: SmartScriptMgr.h:1510
@ SMART_TARGET_POSITION
Definition: SmartScriptMgr.h:1511
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition: SmartScriptMgr.h:1507
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition: SmartScriptMgr.h:1525
@ SMART_TARGET_INSTANCE_STORAGE
Definition: SmartScriptMgr.h:1544
@ SMART_TARGET_FARTHEST
Definition: SmartScriptMgr.h:1531
@ SMART_TARGET_THREAT_LIST
Definition: SmartScriptMgr.h:1527
@ SMART_TARGET_CLOSEST_ENEMY
Definition: SmartScriptMgr.h:1528
@ SMART_TARGET_NONE
Definition: SmartScriptMgr.h:1503
@ SMART_TARGET_PLAYER_DISTANCE
Definition: SmartScriptMgr.h:1521
@ SMART_TARGET_STORED
Definition: SmartScriptMgr.h:1515
std::vector< WorldObject * > ObjectVector
Definition: SmartScriptMgr.h:1971
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition: ScriptedCreature.cpp:817
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition: ScriptedCreature.cpp:822
Powers
Definition: SharedDefines.h:268
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint32_t uint32
Definition: Define.h:107
void RandomResize(C &container, std::size_t requestedSize)
Definition: Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:202
Definition: UnitAI.h:135
Definition: UnitAI.h:165
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:110
static bool IsUnit(WorldObject *obj)
Definition: SmartScript.cpp:5270
static bool IsPlayer(WorldObject *obj)
Definition: SmartScript.cpp:5275
static bool IsCreature(WorldObject *obj)
Definition: SmartScript.cpp:5280
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition: SmartScript.cpp:5259
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition: SmartScript.cpp:3962
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:141
static bool IsGameObject(WorldObject *obj)
Definition: SmartScript.cpp:5296
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition: SmartScript.h:90
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition: SmartScript.cpp:5212
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:132
std::list< HostileReference * > StorageType
Definition: ThreatMgr.h:148
ThreatContainer::StorageType const & GetThreatList() const
Definition: ThreatMgr.h:274
Definition: Creature.h:46
Player * GetLootRecipient() const
Definition: Creature.cpp:1301
Group * GetLootRecipientGroup() const
Definition: Creature.cpp:1308
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition: Creature.cpp:2383
CreatureAI * AI() const
Definition: Creature.h:143
Unit * GetSummonerUnit() const
Definition: TemporarySummon.cpp:44
Definition: GameObject.h:121
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:174
Player * ToPlayer()
Definition: Object.h:198
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Unit * ToUnit()
Definition: Object.h:206
Player * SelectNearestPlayer(float distance=0) const
Definition: Object.cpp:2470
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition: Object.cpp:1404
Definition: ObjectGuid.h:118
Definition: Player.h:1064
bool IsVehicle() const
Definition: Unit.h:757
Vehicle * GetVehicle() const
Definition: Unit.h:1697
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:649
TempSummon * ToTempSummon()
Definition: Unit.h:1743
bool IsSummon() const
Definition: Unit.h:751
Unit * GetVictim() const
Definition: Unit.h:727
ThreatMgr & GetThreatMgr()
Definition: Unit.h:1488
Vehicle * GetVehicleKit() const
Definition: Unit.h:1696
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.h:1173
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:224
Definition: Group.h:169
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
Definition: InstanceScript.h:142
Creature * GetCreature(ObjectGuid const guid)
Definition: Map.cpp:3314

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(), Object::GetEntry(), Object::GetGUID(), 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::index, SmartTarget::instanceStorage, IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, me, SmartTarget::minDist, SmartTarget::negation, GroupReference::next(), SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, 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
3963{
3964 WorldObject* obj = GetBaseObject();
3965 if (!obj)
3966 return;
3967
3968 Acore::AllWorldObjectsInRange u_check(obj, dist);
3970 Cell::VisitAllObjects(obj, searcher, dist);
3971}
Definition: GridNotifiers.h:239
Definition: GridNotifiers.h:1586

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

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

◆ IncPhase()

void SmartScript::IncPhase ( uint32  p)
private
5302{
5303 // protect phase from overflowing
5304 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5305}
@ SMART_EVENT_PHASE_12
Definition: SmartScriptMgr.h:77

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
4753{
4754 switch (e.GetEventType())
4755 {
4756 //set only events which have initial timers
4760 break;
4761 case SMART_EVENT_UPDATE:
4764 case SMART_EVENT_RANGE:
4770 break;
4774 break;
4778 break;
4779 default:
4780 e.active = true;
4781 break;
4782 }
4783}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition: SmartScriptMgr.h:193
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition: SmartScriptMgr.h:211
@ SMART_EVENT_AREA_CASTING
Definition: SmartScriptMgr.h:214
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition: SmartScriptMgr.h:195
@ SMART_EVENT_RANGE
Definition: SmartScriptMgr.h:128
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition: SmartScriptMgr.h:213
@ SMART_EVENT_UPDATE_IC
Definition: SmartScriptMgr.h:119
@ SMART_EVENT_AREA_RANGE
Definition: SmartScriptMgr.h:215
@ SMART_EVENT_UPDATE
Definition: SmartScriptMgr.h:179
@ SMART_EVENT_IS_BEHIND_TARGET
Definition: SmartScriptMgr.h:186
@ SMART_EVENT_UPDATE_OOC
Definition: SmartScriptMgr.h:120
@ SMART_EVENT_NEAR_UNIT
Definition: SmartScriptMgr.h:212
@ SMART_EVENT_DISTANCE_CREATURE
Definition: SmartScriptMgr.h:194
@ SMART_EVENT_NEAR_PLAYERS
Definition: SmartScriptMgr.h:210
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition: SmartScript.cpp:4784
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:1956
uint32 GetEventType() const
Definition: SmartScriptMgr.h:1950

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_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(), and SetScript9().

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private
4895{
4896 if (!mInstallEvents.empty())
4897 {
4898 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
4899 mEvents.push_back(*i);//must be before UpdateTimers
4900
4901 mInstallEvents.clear();
4902 }
4903}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3282{
3283 if (!GetBaseObject())
3284 return;
3286 {
3287 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3288 return;
3289 }
3290 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3291 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3292 {
3294 {
3295 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);
3296 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);
3297 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);
3298 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);
3299 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);
3300 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);
3301 break;
3302 }
3304 {
3305 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);
3306 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);
3307 break;
3308 }
3310 {
3311 if (!me)
3312 return;
3313 //store cage as id1
3314 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);
3315
3316 //reset(close) cage on hostage(me) respawn
3317 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);
3318
3319 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);
3320 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);
3321
3322 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);
3323 //phase 1: give quest credit on movepoint reached
3325 //phase 1: despawn after time on movepoint reached
3326 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);
3327
3328 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3329 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);
3330 break;
3331 }
3333 {
3334 if (!go)
3335 return;
3336 //store hostage as id1
3337 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);
3338 //store invoker as id2
3339 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);
3340 //signal hostage
3341 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);
3342 //when hostage raeched end point, give credit to invoker
3343 if (e.action.installTtemplate.param2)
3344 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);
3345 else
3346 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);
3347 break;
3348 }
3350 default:
3351 return;
3352 }
3353}
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:119
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:46
SMARTAI_TEMPLATE
Definition: SmartScriptMgr.h:1491
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition: SmartScriptMgr.h:1496
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition: SmartScriptMgr.h:1497
@ SMARTAI_TEMPLATE_CASTER
Definition: SmartScriptMgr.h:1493
@ SMARTAI_TEMPLATE_TURRET
Definition: SmartScriptMgr.h:1494
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition: SmartScriptMgr.h:1891
@ SMART_ACTION_STORE_TARGET_LIST
Definition: SmartScriptMgr.h:612
@ SMART_ACTION_FORCE_DESPAWN
Definition: SmartScriptMgr.h:589
@ SMART_ACTION_CAST
Definition: SmartScriptMgr.h:559
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition: SmartScriptMgr.h:569
@ SMART_ACTION_MOVE_FORWARD
Definition: SmartScriptMgr.h:594
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition: SmartScriptMgr.h:581
@ SMART_ACTION_TALK
Definition: SmartScriptMgr.h:549
@ SMART_ACTION_SET_DATA
Definition: SmartScriptMgr.h:593
@ SMART_ACTION_SET_RUN
Definition: SmartScriptMgr.h:607
@ SMART_ACTION_SET_EVENT_PHASE
Definition: SmartScriptMgr.h:570
@ SMART_ACTION_RESET_GOBJECT
Definition: SmartScriptMgr.h:580
@ SMART_EVENT_DATA_SET
Definition: SmartScriptMgr.h:157
@ SMART_EVENT_JUST_CREATED
Definition: SmartScriptMgr.h:182
@ SMART_EVENT_MOVEMENTINFORM
Definition: SmartScriptMgr.h:153
@ SMART_EVENT_MANA_PCT
Definition: SmartScriptMgr.h:122
@ SMART_EVENT_GO_STATE_CHANGED
Definition: SmartScriptMgr.h:189
@ SMART_RANDOM_POINT
Definition: SmartScriptMgr.h:59
std::uint8_t uint8
Definition: Define.h:109
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:3355

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
5286{
5287 if (!obj)
5288 return false;
5289
5290 if (Creature* creatureObj = obj->ToCreature())
5291 return creatureObj->IsCharmed();
5292
5293 return false;
5294}
Creature * ToCreature()
Definition: Object.h:202

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5281{
5282 return obj && obj->IsCreature();
5283}
bool IsCreature() const
Definition: Object.h:201

References Object::IsCreature().

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5297{
5298 return obj && obj->IsGameObject();
5299}
bool IsGameObject() const
Definition: Object.h:209

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5332{
5333 if (mEventPhase == 0)
5334 {
5335 return false;
5336 }
5337
5338 return ((1 << (mEventPhase - 1)) & p) != 0;
5339}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5276{
5277 return obj && obj->IsPlayer();
5278}
bool IsPlayer() const
Definition: Object.h:197

References Object::IsPlayer().

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

◆ IsSmart() [1/3]

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

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

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

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

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5271{
5272 return obj && (obj->IsCreature() || obj->IsPlayer());
5273}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5070{
5071 if (obj)//handle object based scripts
5072 {
5073 switch (obj->GetTypeId())
5074 {
5075 case TYPEID_UNIT:
5077 me = obj->ToCreature();
5078 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5079 break;
5080 case TYPEID_GAMEOBJECT:
5082 go = obj->ToGameObject();
5083 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5084 break;
5085 default:
5086 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5087 return;
5088 }
5089 }
5090 else if (at)
5091 {
5093 trigger = at;
5094 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5095 }
5096 else
5097 {
5098 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5099 return;
5100 }
5101
5102 GetScript();//load copy of script
5103
5104 for (SmartScriptHolder& event : mEvents)
5105 InitTimer(event);//calculate timers for first time use
5106
5108 InstallEvents();
5110}
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition: SmartScriptMgr.h:1735
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition: SmartScriptMgr.h:1736
@ SMART_EVENT_AI_INIT
Definition: SmartScriptMgr.h:156
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:134
void InstallEvents()
Definition: SmartScript.cpp:4894
void GetScript()
Definition: SmartScript.cpp:5035
TypeID GetTypeId() const
Definition: Object.h:124
GameObject * ToGameObject()
Definition: Object.h:210

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)
5113{
5114 if (!me)
5115 return;
5116
5118}
@ SMART_EVENT_IC_LOS
Definition: SmartScriptMgr.h:145
@ SMART_EVENT_OOC_LOS
Definition: SmartScriptMgr.h:129
bool IsEngaged() const
Definition: Unit.h:1029

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

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

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(), and SmartGameObjectAI::Reset().

◆ OnUpdate()

void SmartScript::OnUpdate ( const uint32  diff)
4906{
4908 return;
4909
4910 InstallEvents();//before UpdateTimers
4911
4913 {
4915 mEventSortingRequired = false;
4916 }
4917
4918 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
4919 UpdateTimer(*i, diff);
4920
4921 if (!mStoredEvents.empty())
4922 {
4923 SmartAIEventStoredList::iterator i, icurr;
4924 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
4925 {
4926 icurr = i++;
4927 UpdateTimer(*icurr, diff);
4928 }
4929 }
4930
4931 bool needCleanup = true;
4932 if (!mTimedActionList.empty())
4933 {
4935 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4936 {
4937 if ((*i).enableTimed)
4938 {
4939 UpdateTimer(*i, diff);
4940 needCleanup = false;
4941 }
4942 }
4943
4945 }
4946 if (needCleanup)
4947 mTimedActionList.clear();
4948
4949 if (!mRemIDs.empty())
4950 {
4951 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
4953
4954 // xinef: clear list after cleaning...
4955 mRemIDs.clear();
4956 }
4957 if (mUseTextTimer && me)
4958 {
4959 if (mTextTimer < diff)
4960 {
4961 uint32 textID = mLastTextID;
4962 mLastTextID = 0;
4963 uint32 entry = mTalkerEntry;
4964 mTalkerEntry = 0;
4965 mTextTimer = 0;
4966 mUseTextTimer = false;
4967 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
4968 }
4969 else mTextTimer -= diff;
4970 }
4971}
@ SMART_EVENT_TEXT_OVER
Definition: SmartScriptMgr.h:171
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition: SmartScript.cpp:4791
void SortEvents(SmartAIEventList &events)
Definition: SmartScript.cpp:4973
SmartAIEventStoredList mStoredEvents
Definition: SmartScript.h:224
std::list< uint32 > mRemIDs
Definition: SmartScript.h:225
SmartAIEventList mTimedActionList
Definition: SmartScript.h:212
void RemoveStoredEvent(uint32 id)
Definition: SmartScript.h:242

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

References SmartScriptHolder::action, SmartAction::activateObject, EventProcessor::AddEventAtOffset(), WorldObject::AddObjectToRemoveList(), Unit::AddThreat(), Creature::AI(), SmartAction::aliveState, SmartAction::alternative, SmartTarget::amount, SmartAction::angle, SmartAction::attack, SmartAction::attackInvoker, SmartAction::attackScriptOwner, UnitAI::AttackStart(), AURA_REMOVE_BY_EXPIRE, SmartAction::autoAttack, MapRefMgr::begin(), BROADCAST_TEXT_CALL_FOR_HELP, BROADCAST_TEXT_FLEE_FOR_ASSIST, SpellInfo::CalcPowerCost(), SmartAction::callHelp, SmartAction::cast, CAST_AI, SmartAction::castFlags, Unit::CastSpell(), GameObject::CastSpell(), SmartAction::charges, CHAT_MSG_ADDON, CHAT_MSG_MONSTER_EMOTE, ObjectMgr::ChooseDisplayId(), SmartAction::combatMove, SmartAction::combatReach, Unit::CombatStop(), SmartAction::ContactDistance, SmartAction::controlled, SmartAction::count, SmartAction::counterId, SmartAction::creature, CreatureModel::CreatureDisplayID, SmartAction::credit, SmartAction::creditType, SmartAction::data, SmartAction::dec, DecPhase(), SmartAction::delay, GameObject::DespawnOrUnsummon(), SmartAction::despawnTime, SmartAction::die, SmartAction::directAdd, SmartAction::disableGravity, CreatureModel::DisplayScale, SmartAction::dist, SmartAction::distance, Creature::DoFleeToGetAssistance(), SmartAction::duration, SmartAction::emote, SmartAction::emotes, MapRefMgr::end(), ENSURE_AI, SmartAction::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event, SmartEvent::event_chance, SmartEvent::event_flags, SmartAction::faction, SmartAction::factionID, SmartAction::fail, SmartAction::field, WorldObject::FindMap(), SmartAction::flag, SmartAction::flags, SmartAction::flee, SmartAction::fly, SmartAction::follow, SmartAction::forceDespawn, SmartAction::forceRespawnTimer, frand(), GAMEOBJECT_TYPE_DOOR, SmartScriptHolder::GetActionType(), Position::GetAngle(), WorldObject::GetAreaId(), GetBaseObject(), InstanceScript::GetBossStateName(), Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), WorldObject::GetClosePoint(), WorldObject::GetCombatReach(), Unit::GetDirectTransport(), WorldObject::GetDistance(), Object::GetEntry(), SmartScriptHolder::GetEventType(), Unit::getGender(), GameObject::GetGoType(), Object::GetGUID(), Creature::GetHomePosition(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), WorldObject::GetMap(), Unit::GetMeleeRange(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldObject::GetNearPoint(), WorldObject::GetObjectSize(), Position::GetOrientation(), ObjectAccessor::GetPlayer(), Map::GetPlayers(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetPower(), Unit::GetPowerPct(), WorldObject::GetRandomPoint(), SpellInfo::GetSchoolMask(), SmartScriptHolder::GetScriptType(), Unit::GetSpeed(), Unit::GetSpellMaxRangeForTarget(), Unit::GetSpellMinRangeForTarget(), GetTargets(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), ThreatMgr::GetThreatListSize(), Unit::GetThreatMgr(), Unit::GetTransGUID(), Creature::GetTransportHomePosition(), ObjectAccessor::GetUnit(), Unit::GetVehicleKit(), GetWorldObjectsInDist(), WorldObject::GetZoneId(), go, GO_READY, Player::GroupEventHappens(), SpellInfo::HasAttribute(), Unit::HasAura(), EnumFlag< T >::HasFlag(), Object::HasFlag(), Unit::HasUnitMovementFlag(), Unit::HasUnitState(), SmartAction::id, SmartAction::inc, SmartAction::incEventPhase, IncPhase(), SmartAction::ingamePhaseMask, InstallTemplate(), Unit::InterruptNonMeleeSpells(), SmartAction::invincHP, IsCreature(), Unit::isDead(), Map::IsDungeon(), LinkedListHead::IsEmpty(), IsGameObject(), IsPlayer(), IsSmart(), IsUnit(), WorldObject::IsWithinLOSInMap(), SmartAction::item, Unit::Kill(), SmartAction::killedMonster, Unit::KillSelf(), LANG_ADDON, LANG_UNIVERSAL, LOG_DEBUG, LOG_ERROR, Unit::m_Events, Position::m_positionX, Position::m_positionY, Position::m_positionZ, SmartAction::mapID, SmartAction::mask, SmartTarget::maxDist, me, SmartAction::milliseconds, SmartAction::minHP, mLastInvoker, mLastTextID, SmartAction::model, ThreatMgr::ModifyThreatByPercent(), SmartAction::morphOrMount, MOTION_SLOT_ACTIVE, MOTION_SLOT_CONTROLLED, SmartAction::move, MOVE_RUN, MOVEMENTFLAG_ONTRANSPORT, MotionMaster::MovePoint(), SmartAction::moveRandom, SmartAction::moveToPos, SmartAction::movie, mTalkerEntry, mTextTimer, mUseTextTimer, SmartAction::music, NOMINAL_MELEE_RANGE, SmartTarget::o, SmartAction::onlySelf, SmartAction::orientation, SmartAction::pathID, SmartAction::percent, SmartAction::phase, SmartAction::phaseMax, SmartAction::phaseMin, SmartAction::phases, SmartAction::pointId, POWER_MANA, SmartAction::quest, SmartAction::questID, SmartAction::questOffer, SmartAction::quickChange, SmartAction::random, SmartAction::randomEmote, SmartAction::randomMusic, SmartAction::randomPhase, SmartAction::randomPhaseRange, SmartTarget::randomPoint, Acore::Containers::RandomResize(), SmartAction::randomSound, SmartAction::range, SmartTarget::range, SmartAction::react, SmartAction::reactState, SmartAction::removeAura, SmartAction::removeObjectFromWorld, SmartAction::repeat, SmartAction::reset, RetryLater(), Player::RewardPlayerAndGroupAtEvent(), SmartAction::run, SmartScriptHolder::runOnce, sCreatureTextMgr, Acore::Containers::SelectRandomContainerElement(), SmartTarget::self, PlayerMenu::SendQuestGiverQuestDetails(), SmartAction::setActive, InstanceScript::SetBossState(), SmartAction::setCounter, GameObjectAI::SetData(), UnitAI::SetData(), SmartAction::setData, ZoneScript::SetData(), Creature::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, ZoneScript::SetGuidData(), Unit::SetInCombatWith(), Unit::SetInFront(), SmartAction::setInstanceData, SmartAction::setInstanceData64, SmartAI::SetInvincibilityHpLevel(), GameObject::SetLootState(), Position::SetOrientation(), SetPhase(), Creature::SetReactState(), SmartAction::setRun, SmartAction::setSheath, Unit::SetSheath(), Unit::SetSpeed(), SmartAction::setSwim, SmartAction::sheath, SmartAction::simpleTalk, SMART_ACTION_ACTIVATE_GOBJECT, SMART_ACTION_ADD_AURA, SMART_ACTION_ADD_ITEM, 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_CAST, SMART_ACTION_COMBAT_STOP, SMART_ACTION_DIE, SMART_ACTION_EVADE, SMART_ACTION_FAIL_QUEST, SMART_ACTION_FLEE_FOR_ASSIST, SMART_ACTION_FOLLOW, SMART_ACTION_FORCE_DESPAWN, SMART_ACTION_INC_EVENT_PHASE, SMART_ACTION_INSTALL_AI_TEMPLATE, SMART_ACTION_INVOKER_CAST, SMART_ACTION_KILL_UNIT, 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_MUSIC, SMART_ACTION_OFFER_QUEST, SMART_ACTION_PLAY_EMOTE, SMART_ACTION_PLAYMOVIE, SMART_ACTION_RANDOM_EMOTE, SMART_ACTION_RANDOM_MUSIC, SMART_ACTION_RANDOM_PHASE, SMART_ACTION_RANDOM_PHASE_RANGE, SMART_ACTION_RANDOM_SOUND, SMART_ACTION_REMOVE_ITEM, SMART_ACTION_REMOVE_UNIT_FLAG, SMART_ACTION_REMOVEAURASFROMSPELL, SMART_ACTION_RESET_GOBJECT, SMART_ACTION_RISE_UP, SMART_ACTION_SELF_CAST, SMART_ACTION_SET_ACTIVE, SMART_ACTION_SET_COUNTER, SMART_ACTION_SET_DATA, SMART_ACTION_SET_EMOTE_STATE, SMART_ACTION_SET_EVENT_PHASE, SMART_ACTION_SET_FACTION, SMART_ACTION_SET_FLY, 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_ORIENTATION, SMART_ACTION_SET_REACT_STATE, SMART_ACTION_SET_RUN, SMART_ACTION_SET_SHEATH, SMART_ACTION_SET_SWIM, SMART_ACTION_SET_UNIT_FLAG, SMART_ACTION_SET_VISIBILITY, SMART_ACTION_SIMPLE_TALK, SMART_ACTION_SOUND, SMART_ACTION_STORE_TARGET_LIST, SMART_ACTION_SUMMON_CREATURE, SMART_ACTION_SUMMON_GO, SMART_ACTION_TALK, SMART_ACTION_TELEPORT, SMART_ACTION_THREAT_ALL_PCT, SMART_ACTION_THREAT_SINGLE_PCT, SMART_ACTION_UPDATE_TEMPLATE, SMART_ACTION_WP_PAUSE, SMART_ACTION_WP_RESUME, SMART_ACTION_WP_START, SMART_ACTION_WP_STOP, SMART_ESCORT_TARGETS, SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL, 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::speed, SmartAction::spell, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_CAST_OK, SPELL_FAILED_OUT_OF_RANGE, SPELL_FAILED_SPELL_IN_PROGRESS, sSpellMgr, SmartAction::state, StoreCounter(), StoreTargetList(), SmartAction::storeTargets, SmartAction::subtract, SmartAction::summonCreature, WorldObject::SummonCreature(), WorldObject::SummonGameObject(), SmartAction::summonGO, WorldObject::SummonTrigger(), SmartAction::swim, SmartAction::talk, SmartScriptHolder::target, SmartAction::targetsLimit, SmartAction::targetsummon, TEAM_NEUTRAL, SmartAction::teleport, TEXT_RANGE_NORMAL, SmartAction::textGroupID, SmartAction::threatDEC, SmartAction::threatINC, SmartAction::threatPCT, Object::ToCreature(), Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), SmartAction::transport, trigger, TRIGGERED_FULL_MASK, TRIGGERED_NONE, SmartAction::triggerFlags, SmartAction::turnAngle, SmartAction::type, SmartTarget::type, UNIT_FIELD_FLAGS, UNIT_FIELD_FLAGS_2, UNIT_FLAG_SILENCED, UNIT_NPC_EMOTESTATE, UNIT_STATE_LOST_CONTROL, UNIT_STATE_ROOT, SmartAction::unitFlag, SmartTarget::unitRange, SmartAction::updateLevel, SmartAction::updateTemplate, urand(), GameObject::UseDoorOrButton(), SmartAction::useTalkTarget, SmartAction::value, SmartAction::visibility, SmartAction::withEmote, 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 
)
3974{
3975 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
3976 return;
3977
3979 return;
3980
3982 return;
3983
3984 switch (e.GetEventType())
3985 {
3986 case SMART_EVENT_LINK://special handling
3987 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3988 break;
3989 //called from Update tick
3990 case SMART_EVENT_UPDATE:
3992 break;
3994 if (me && me->IsEngaged())
3995 return;
3997 break;
3999 if (!me || !me->IsEngaged())
4000 return;
4002 break;
4004 {
4005 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4006 return;
4007 uint32 perc = (uint32)me->GetHealthPct();
4008 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4009 return;
4011 break;
4012 }
4014 {
4015 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4016 return;
4017 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4018 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4019 return;
4021 break;
4022 }
4024 {
4025 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4026 return;
4028 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4029 return;
4031 break;
4032 }
4034 {
4035 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4036 return;
4038 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4039 return;
4041 break;
4042 }
4043 case SMART_EVENT_RANGE:
4044 {
4045 if (!me || !me->IsEngaged() || !me->GetVictim())
4046 return;
4047
4050 else
4051 RecalcTimer(e, 1200, 1200); // make it predictable
4052
4053 break;
4054 }
4056 {
4057 if (!me || !me->IsEngaged())
4058 return;
4059
4060 Unit* victim = me->GetVictim();
4061
4062 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4063 return;
4064
4065 if (e.event.targetCasting.spellId > 0)
4066 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4067 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4068 return;
4069
4071 break;
4072 }
4074 {
4075 if (!me || !me->IsEngaged())
4076 return;
4077
4079 if (!target || !target->IsInCombat())
4080 {
4081 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4082 RecalcTimer(e, 1000, 3000);
4083 return;
4084 }
4086 break;
4087 }
4089 {
4090 if (!me || !me->IsEngaged())
4091 return;
4092
4093 std::vector<Creature*> creatures;
4095 if (creatures.empty())
4096 {
4097 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4098 RecalcTimer(e, 1000, 3000);
4099 return;
4100 }
4102 break;
4103 }
4105 {
4107 {
4108 return;
4109 }
4110
4111 std::vector<Creature*> creatures;
4113
4114 if (creatures.empty())
4115 return;
4116
4118 break;
4119 }
4121 {
4122 if (!me)
4123 return;
4124 uint32 count = me->GetAuraCount(e.event.aura.spell);
4125 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4127 break;
4128 }
4130 {
4131 if (!me || !me->GetVictim())
4132 return;
4134 if (count < e.event.aura.count)
4135 return;
4137 break;
4138 }
4140 {
4141 if (bvar == (e.event.charm.onRemove != 1))
4142 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4143 break;
4144 }
4145 //no params
4146 case SMART_EVENT_AGGRO:
4147 case SMART_EVENT_DEATH:
4148 case SMART_EVENT_EVADE:
4161 case SMART_EVENT_RESET:
4165 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4166 break;
4167
4169 switch (e.event.gossipHello.filter)
4170 {
4171 case 0:
4172 // no filter set, always execute action
4173 break;
4174 case 1:
4175 // GossipHello only filter set, skip action if reportUse
4176 if (var0)
4177 {
4178 return;
4179 }
4180 break;
4181 case 2:
4182 // reportUse only filter set, skip action if GossipHello
4183 if (!var0)
4184 {
4185 return;
4186 }
4187 break;
4188 default:
4189 // Ignore any other value
4190 break;
4191 }
4192
4193 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4194 break;
4196 {
4197 if (!me)
4198 return;
4199
4200 if (Unit* victim = me->GetVictim())
4201 {
4203 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4205 }
4206
4207 break;
4208 }
4210 if (e.event.emote.emote == var0)
4211 {
4212 ProcessAction(e, unit);
4213 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4214 }
4215 break;
4216 case SMART_EVENT_KILL:
4217 {
4218 if (!me || !unit)
4219 return;
4220 if (e.event.kill.playerOnly && !unit->IsPlayer())
4221 return;
4222 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4223 return;
4225 ProcessAction(e, unit);
4226 break;
4227 }
4230 {
4231 if (!spell)
4232 return;
4233 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4234 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4235 {
4237 ProcessAction(e, unit, 0, 0, bvar, spell);
4238 }
4239 break;
4240 }
4242 {
4243 if (!me || me->IsEngaged())
4244 return;
4245 //can trigger if closer than fMaxAllowedRange
4246 float range = (float)e.event.los.maxDist;
4247
4248 //if range is ok and we are actually in LOS
4249 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4250 {
4252 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4253 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4254 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4255 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4256 {
4257 if (e.event.los.playerOnly && !unit->IsPlayer())
4258 return;
4260 ProcessAction(e, unit);
4261 }
4262 }
4263 break;
4264 }
4265 case SMART_EVENT_IC_LOS:
4266 {
4267 if (!me || !me->IsEngaged())
4268 return;
4269 //can trigger if closer than fMaxAllowedRange
4270 float range = (float)e.event.los.maxDist;
4271
4272 //if range is ok and we are actually in LOS
4273 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4274 {
4276 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4277 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4278 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4279 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4280 {
4281 if (e.event.los.playerOnly && !unit->IsPlayer())
4282 return;
4284 ProcessAction(e, unit);
4285 }
4286 }
4287 break;
4288 }
4290 {
4291 if (!GetBaseObject())
4292 return;
4294 return;
4296 return;
4297 ProcessAction(e);
4298 break;
4299 }
4303 {
4304 if (!IsCreature(unit))
4305 return;
4306 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4307 return;
4309 ProcessAction(e, unit);
4310 break;
4311 }
4315 {
4316 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4317 return;
4319 ProcessAction(e, unit);
4320 break;
4321 }
4323 {
4324 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4325 return;
4326 ProcessAction(e, unit, var0, var1);
4327 break;
4328 }
4331 {
4332 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4333 return;
4334 ProcessAction(e, unit, var0);
4335 break;
4336 }
4342 {
4343 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4344 return;
4345 ProcessAction(e, unit);
4346 break;
4347 }
4349 {
4350 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4351 return;
4353 ProcessAction(e, unit, var0);
4354 break;
4355 }
4357 {
4359 return;
4361 ProcessAction(e, unit, var0);
4362 break;
4363 }
4366 {
4367 if (e.event.quest.quest && var0 != e.event.quest.quest)
4368 return;
4369 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4370 ProcessAction(e, unit, var0);
4371 break;
4372 }
4374 {
4376 return;
4377 ProcessAction(e, unit, var0);
4378 break;
4379 }
4381 {
4382 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4383 return;
4384 ProcessAction(e, unit, var0);
4385 break;
4386 }
4388 {
4390 return;
4391 ProcessAction(e, unit, var0);
4392 break;
4393 }
4395 {
4396 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4397 return;
4399 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4400 break;
4401 }
4404 {
4405 if (!unit)
4406 return;
4408 ProcessAction(e, unit);
4409 break;
4410 }
4412 {
4413 if (e.event.timedEvent.id == var0)
4414 ProcessAction(e, unit);
4415 break;
4416 }
4418 {
4419 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4420 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4421 return;
4422 ProcessAction(e, unit, var0, var1);
4423 break;
4424 }
4426 {
4428 return;
4429
4430 WorldObject* templastInvoker = GetLastInvoker();
4431 if (!templastInvoker)
4432 return;
4433
4434 if (!IsUnit(templastInvoker))
4435 return;
4436
4437 ProcessAction(e, templastInvoker->ToUnit());
4438 break;
4439 }
4442 {
4443 if (e.event.gameEvent.gameEventId != var0)
4444 return;
4445 ProcessAction(e, nullptr, var0);
4446 break;
4447 }
4449 {
4450 if (e.event.goStateChanged.state != var0)
4451 return;
4452 ProcessAction(e, unit, var0, var1);
4453 break;
4454 }
4456 {
4457 if (e.event.eventInform.eventId != var0)
4458 return;
4459 ProcessAction(e, nullptr, var0);
4460 break;
4461 }
4463 {
4464 if (e.event.doAction.eventId != var0)
4465 return;
4466 ProcessAction(e, unit, var0);
4467 break;
4468 }
4470 {
4471 if (!me || !me->IsEngaged())
4472 return;
4473
4474 Unit* unitTarget = nullptr;
4475 switch (e.GetTargetType())
4476 {
4484 {
4485 ObjectVector targets;
4486 GetTargets(targets, e);
4487 for (WorldObject* target : targets)
4488 {
4489 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4490 {
4491 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4492 if (healthPct > e.event.friendlyHealthPct.hpPct)
4493 {
4494 continue;
4495 }
4496
4497 unitTarget = target->ToUnit();
4498 break;
4499 }
4500 }
4501
4502 break;
4503 }
4504 case SMART_TARGET_SELF:
4507 break;
4508 default:
4509 return;
4510 }
4511
4512 if (!unitTarget)
4513 return;
4514
4516 break;
4517 }
4519 {
4520 if (!me)
4521 return;
4522
4523 WorldObject* creature = nullptr;
4524
4525 if (e.event.distance.guid != 0)
4526 {
4527 creature = FindCreatureNear(me, e.event.distance.guid);
4528
4529 if (!creature)
4530 return;
4531
4532 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4533 return;
4534 }
4535 else if (e.event.distance.entry != 0)
4536 {
4537 std::list<Creature*> list;
4539
4540 if (!list.empty())
4541 creature = list.front();
4542 }
4543
4544 if (creature)
4546
4547 break;
4548 }
4550 {
4551 if (!me)
4552 return;
4553
4554 WorldObject* gameobject = nullptr;
4555
4556 if (e.event.distance.guid != 0)
4557 {
4558 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4559
4560 if (!gameobject)
4561 return;
4562
4563 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4564 return;
4565 }
4566 else if (e.event.distance.entry != 0)
4567 {
4568 std::list<GameObject*> list;
4570
4571 if (!list.empty())
4572 gameobject = list.front();
4573 }
4574
4575 if (gameobject)
4577
4578 break;
4579 }
4581 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4582 return;
4583
4585 break;
4587 {
4588 uint32 playerCount = 0;
4589 ObjectVector targets;
4590 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4591
4592 if (!targets.empty())
4593 {
4594 for (WorldObject* target : targets)
4595 {
4596 if (IsPlayer(target))
4597 playerCount++;
4598 }
4599 if (playerCount >= e.event.nearPlayer.minCount)
4600 ProcessAction(e, unit);
4601 }
4603 break;
4604 }
4606 {
4607 uint32 playerCount = 0;
4608 ObjectVector targets;
4609 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4610
4611 if (!targets.empty())
4612 {
4613 for (WorldObject* target : targets)
4614 {
4615 if (IsPlayer(target))
4616 playerCount++;
4617 }
4618
4619 if (playerCount < e.event.nearPlayerNegation.maxCount)
4620 ProcessAction(e, unit);
4621 }
4623 break;
4624 }
4626 {
4627 uint32 unitCount = 0;
4628 ObjectVector targets;
4629 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4630
4631 if (!targets.empty())
4632 {
4633 if (e.event.nearUnit.type)
4634 {
4635 for (WorldObject* target : targets)
4636 {
4637 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4638 unitCount++;
4639 }
4640 }
4641 else
4642 {
4643 for (WorldObject* target : targets)
4644 {
4645 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4646 unitCount++;
4647 }
4648 }
4649
4650 if (unitCount >= e.event.nearUnit.count)
4651 ProcessAction(e, unit);
4652 }
4654 break;
4655 }
4657 {
4658 uint32 unitCount = 0;
4659 ObjectVector targets;
4660 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4661
4662 if (!targets.empty())
4663 {
4665 {
4666 for (WorldObject* target : targets)
4667 {
4668 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4669 unitCount++;
4670 }
4671 }
4672 else
4673 {
4674 for (WorldObject* target : targets)
4675 {
4676 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4677 unitCount++;
4678 }
4679 }
4680
4681 if (unitCount < e.event.nearUnitNegation.count)
4682 ProcessAction(e, unit);
4683 }
4685 break;
4686 }
4688 {
4689 if (!me || !me->IsEngaged())
4690 return;
4691
4693 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4694 {
4695 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4696 {
4697 if (!target || !IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4698 continue;
4699
4700 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4701 continue;
4702
4703 ProcessAction(e, target);
4705 return;
4706 }
4707
4708 // If no targets are found and it's off cooldown, check again in 1200ms
4709 RecalcTimer(e, 1200, 1200);
4710 break;
4711 }
4712
4713 break;
4714 }
4716 {
4717 if (!me || !me->IsEngaged())
4718 return;
4719
4721 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4722 {
4723 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4724 {
4725 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4726 continue;
4727
4728 ProcessAction(e, target);
4730 return;
4731 }
4732 }
4733
4734 // If no targets are found and it's off cooldown, check again
4735 RecalcTimer(e, 1200, 1200);
4736 break;
4737 }
4740 {
4741 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4742 return;
4743 ProcessAction(e, unit);
4744 break;
4745 }
4746 default:
4747 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4748 break;
4749 }
4750}
@ CURRENT_GENERIC_SPELL
Definition: Unit.h:538
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition: SmartScriptMgr.h:1900
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition: SmartScriptMgr.h:542
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition: SmartScriptMgr.h:541
@ SMART_EVENT_EVADE
Definition: SmartScriptMgr.h:126
@ SMART_EVENT_ACTION_DONE
Definition: SmartScriptMgr.h:191
@ SMART_EVENT_SUMMON_DESPAWNED
Definition: SmartScriptMgr.h:154
@ SMART_EVENT_SPELLHIT
Definition: SmartScriptMgr.h:127
@ SMART_EVENT_RECEIVE_EMOTE
Definition: SmartScriptMgr.h:141
@ SMART_EVENT_QUEST_FAIL
Definition: SmartScriptMgr.h:170
@ SMART_EVENT_RECEIVE_HEAL
Definition: SmartScriptMgr.h:172
@ SMART_EVENT_CHARMED_TARGET
Definition: SmartScriptMgr.h:149
@ SMART_EVENT_TARGET_MANA_PCT
Definition: SmartScriptMgr.h:137
@ SMART_EVENT_QUEST_COMPLETION
Definition: SmartScriptMgr.h:168
@ SMART_EVENT_HEALTH_PCT
Definition: SmartScriptMgr.h:121
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition: SmartScriptMgr.h:185
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition: SmartScriptMgr.h:165
@ SMART_EVENT_ON_SPELLCLICK
Definition: SmartScriptMgr.h:192
@ SMART_EVENT_PASSENGER_REMOVED
Definition: SmartScriptMgr.h:147
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition: SmartScriptMgr.h:164
@ SMART_EVENT_WAYPOINT_PAUSED
Definition: SmartScriptMgr.h:174
@ SMART_EVENT_WAYPOINT_DATA_ENDED
Definition: SmartScriptMgr.h:218
@ SMART_EVENT_REACHED_HOME
Definition: SmartScriptMgr.h:140
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition: SmartScriptMgr.h:161
@ SMART_EVENT_REWARD_QUEST
Definition: SmartScriptMgr.h:139
@ SMART_EVENT_WAYPOINT_DATA_REACHED
Definition: SmartScriptMgr.h:217
@ SMART_EVENT_GO_EVENT_INFORM
Definition: SmartScriptMgr.h:190
@ SMART_EVENT_JUST_SUMMONED
Definition: SmartScriptMgr.h:173
@ SMART_EVENT_CHARMED
Definition: SmartScriptMgr.h:148
@ SMART_EVENT_WAYPOINT_START
Definition: SmartScriptMgr.h:158
@ SMART_EVENT_SPELLHIT_TARGET
Definition: SmartScriptMgr.h:150
@ SMART_EVENT_GAME_EVENT_START
Definition: SmartScriptMgr.h:187
@ SMART_EVENT_KILL
Definition: SmartScriptMgr.h:124
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition: SmartScriptMgr.h:162
@ SMART_EVENT_GOSSIP_HELLO
Definition: SmartScriptMgr.h:183
@ SMART_EVENT_GOSSIP_SELECT
Definition: SmartScriptMgr.h:181
@ SMART_EVENT_CORPSE_REMOVED
Definition: SmartScriptMgr.h:155
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition: SmartScriptMgr.h:216
@ SMART_EVENT_PASSENGER_BOARDED
Definition: SmartScriptMgr.h:146
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition: SmartScriptMgr.h:160
@ SMART_EVENT_WAYPOINT_ENDED
Definition: SmartScriptMgr.h:177
@ SMART_EVENT_ACCEPTED_QUEST
Definition: SmartScriptMgr.h:138
@ SMART_EVENT_COUNTER_SET
Definition: SmartScriptMgr.h:196
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition: SmartScriptMgr.h:135
@ SMART_EVENT_WAYPOINT_RESUMED
Definition: SmartScriptMgr.h:175
@ SMART_EVENT_TARGET_BUFFED
Definition: SmartScriptMgr.h:143
@ SMART_EVENT_RESPAWN
Definition: SmartScriptMgr.h:130
@ SMART_EVENT_QUEST_ACCEPTED
Definition: SmartScriptMgr.h:166
@ SMART_EVENT_FRIENDLY_HEALTH
Definition: SmartScriptMgr.h:133
@ SMART_EVENT_QUEST_REWARDED
Definition: SmartScriptMgr.h:169
@ SMART_EVENT_DEATH
Definition: SmartScriptMgr.h:125
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition: SmartScriptMgr.h:163
@ SMART_EVENT_GAME_EVENT_END
Definition: SmartScriptMgr.h:188
@ SMART_EVENT_DAMAGED
Definition: SmartScriptMgr.h:151
@ SMART_EVENT_FOLLOW_COMPLETED
Definition: SmartScriptMgr.h:184
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition: SmartScriptMgr.h:167
@ SMART_EVENT_WAYPOINT_STOPPED
Definition: SmartScriptMgr.h:176
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition: SmartScriptMgr.h:203
@ SMART_EVENT_FRIENDLY_IS_CC
Definition: SmartScriptMgr.h:134
@ SMART_EVENT_AGGRO
Definition: SmartScriptMgr.h:123
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition: SmartScriptMgr.h:131
@ SMART_EVENT_VICTIM_CASTING
Definition: SmartScriptMgr.h:132
@ SMART_EVENT_DAMAGED_TARGET
Definition: SmartScriptMgr.h:152
@ SMART_EVENT_HAS_AURA
Definition: SmartScriptMgr.h:142
@ SMART_EVENT_SUMMONED_UNIT
Definition: SmartScriptMgr.h:136
uint32 GetCounterValue(uint32 id)
Definition: SmartScript.h:124
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition: SmartScript.cpp:5202
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition: SmartScript.cpp:5192
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:153
static bool IsCharmedCreature(WorldObject *obj)
Definition: SmartScript.cpp:5285
uint32 GetPathId() const
Definition: SmartScript.h:53
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition: SmartScript.cpp:5165
bool IsInPhase(uint32 p) const
Definition: SmartScript.cpp:5331
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition: SmartScript.cpp:5178
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:3266
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition: SmartScriptMgr.h:272
uint32 pointId
Definition: SmartScriptMgr.h:514
uint32 entry
Definition: SmartScriptMgr.h:463
struct SmartEvent::@30::@71 nearUnitNegation
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition: SmartScriptMgr.h:358
struct SmartEvent::@30::@72 wpData
LOSHostilityMode
Definition: SmartScriptMgr.h:530
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
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
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:515
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
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
uint32 GetWaypointPath() const
Definition: Creature.h:347
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition: Object.cpp:2490
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition: Object.cpp:2497
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1321
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition: Position.cpp:140
float GetHealthPct() const
Definition: Unit.h:790
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:4064
uint32 GetMaxHealth() const
Definition: Unit.h:783
uint32 GetAuraCount(uint32 spellId) const
Definition: Unit.cpp:5636
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:805
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10186
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:10181
bool IsInCombat() const
Definition: Unit.h:1032
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1404
Definition: Spell.h:284

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, IsCharmedCreature(), IsCreature(), Unit::IsEngaged(), Unit::IsFriendlyTo(), IsGameObject(), Unit::IsHostileTo(), Unit::IsInCombat(), IsInPhase(), WorldObject::IsInRange(), Unit::IsNonMeleeSpellCast(), Object::IsPlayer(), IsPlayer(), IsUnit(), WorldObject::IsWithinDistInMap(), WorldObject::IsWithinLOSInMap(), SmartEvent::kill, LOG_DEBUG, LOG_ERROR, SmartEvent::los, SmartEvent::map, SmartEvent::max, SmartEvent::maxCount, SmartEvent::maxDist, me, 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_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 
)
135{
136 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
137 {
138 SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
139 if (eventType == SMART_EVENT_LINK)//special handling
140 continue;
141
142 if (eventType == e)
143 {
144 ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
145 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
146
147 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
148 ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
149 }
150 }
151}
#define sConditionMgr
Definition: ConditionMgr.h:289
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:236
Definition: ConditionMgr.h:181

References 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(), 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 
)
3267{
3268 // xinef: extended by selfs victim
3269 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3270 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3271
3272 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3273 {
3274 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3275 RecalcTimer(e, min, max);
3276 }
3277 else
3278 RecalcTimer(e, 5000, 5000);
3279}

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
4979{
4980 e.timer = 1200;
4981 // Change priority only if it's set to default, otherwise keep the current order of events
4983 {
4985 mEventSortingRequired = true;
4986 }
4987}
uint32 timer
Definition: SmartScriptMgr.h:1954
uint32 priority
Definition: SmartScriptMgr.h:1955

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
4785{
4786 // min/max was checked at loading!
4787 e.timer = urand(uint32(min), uint32(max));
4788 e.active = e.timer ? false : true;
4789}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5347{
5348 _summonList.erase(guid);
5349}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

void SmartScript::RemoveStoredEvent ( uint32  id)
inlineprivate
243 {
244 if (!mStoredEvents.empty())
245 {
246 for (SmartAIEventStoredList::iterator i = mStoredEvents.begin(); i != mStoredEvents.end(); ++i)
247 {
248 if (i->event_id == id)
249 {
250 mStoredEvents.erase(i);
251 return;
252 }
253 }
254 }
255 }

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

void SmartScript::ResetBaseObject ( )
inline
157 {
158 WorldObject* lookupRoot = me;
159 if (!lookupRoot)
160 lookupRoot = go;
161
162 if (lookupRoot)
163 {
164 if (meOrigGUID)
165 {
166 if (Creature* m = ObjectAccessor::GetCreature(*lookupRoot, meOrigGUID))
167 {
168 me = m;
169 go = nullptr;
170 }
171 }
172
173 if (goOrigGUID)
174 {
176 {
177 me = nullptr;
178 go = o;
179 }
180 }
181 }
182
185 }
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:187
Creature * GetCreature(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:213

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

Referenced by OnReset().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
4990{
4991 RaisePriority(e);
4992
4993 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
4994 if (ignoreChanceRoll)
4996
4997 e.runOnce = false;
4998}
void RaisePriority(SmartScriptHolder &e)
Definition: SmartScript.cpp:4978

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
52{ mPathId = id; }

References mPathId.

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

◆ SetPhase()

void SmartScript::SetPhase ( uint32  p)
private
5320{
5321 uint32 oldPhase = mEventPhase;
5322
5323 mEventPhase = p;
5324
5325 if (oldPhase != mEventPhase)
5326 {
5328 }
5329}

References mEventPhase, ProcessEventsFor(), and SMART_EVENT_EVENT_PHASE_CHANGE.

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

◆ SetPhaseReset()

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

References _allowPhaseReset.

◆ SetScript9()

void SmartScript::SetScript9 ( SmartScriptHolder e,
uint32  entry 
)
5225{
5226 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5227 // any SmartScriptHolder contained like the "e" parameter passed to this function
5229 {
5230 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());
5231 return;
5232 }
5233
5234 // 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
5236 {
5237 return;
5238 }
5239
5240 mTimedActionList.clear();
5242 if (mTimedActionList.empty())
5243 return;
5244 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5245 {
5246 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5247
5248 if (e.action.timedActionList.timerType == 0)
5249 i->event.type = SMART_EVENT_UPDATE_OOC;
5250 else if (e.action.timedActionList.timerType == 1)
5251 i->event.type = SMART_EVENT_UPDATE_IC;
5252 else if (e.action.timedActionList.timerType > 1)
5253 i->event.type = SMART_EVENT_UPDATE;
5254
5255 InitTimer((*i));
5256 }
5257}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition: SmartScriptMgr.h:1743
SAIBool allowOverride
Definition: SmartScriptMgr.h:1151
uint32 timerType
Definition: SmartScriptMgr.h:1150

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

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

◆ SortEvents()

void SmartScript::SortEvents ( SmartAIEventList events)
private
4974{
4975 std::sort(events.begin(), events.end());
4976}
events
Definition: boss_sartura.cpp:43

Referenced by OnUpdate().

◆ StoreCounter()

void SmartScript::StoreCounter ( uint32  id,
uint32  value,
uint32  reset,
uint32  subtract 
)
inline
99 {
100 CounterMap::iterator itr = mCounterList.find(id);
101 if (itr != mCounterList.end())
102 {
103 if (!reset && !subtract)
104 {
105 itr->second += value;
106 }
107 else if (subtract)
108 {
109 itr->second -= value;
110 }
111 else
112 {
113 itr->second = value;
114 }
115 }
116 else
117 {
118 mCounterList.insert(std::make_pair(id, value));
119 }
120
122 }

References mCounterList, ProcessEventsFor(), and SMART_EVENT_COUNTER_SET.

Referenced by ProcessAction().

◆ StoreTargetList()

void SmartScript::StoreTargetList ( ObjectVector const &  targets,
uint32  id 
)
inline
84 {
85 // insert or replace
86 _storedTargets.erase(id);
87 _storedTargets.emplace(id, ObjectGuidVector(targets));
88 }
Definition: SmartScriptMgr.h:1974

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4792{
4793 if (e.GetEventType() == SMART_EVENT_LINK)
4794 return;
4795
4797 return;
4798
4799 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4800 return;
4801
4802 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4803 return;
4804
4805 if (e.timer < diff)
4806 {
4807 // delay spell cast for another AI tick if another spell is being cast
4809 {
4811 {
4813 {
4814 RaisePriority(e);
4815 return;
4816 }
4817 }
4818 }
4819
4820 // Delay flee for assist event if casting
4822 {
4823 e.timer = 1200;
4824 return;
4825 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
4826
4827 e.active = true;//activate events with cooldown
4828 switch (e.GetEventType())//process ONLY timed events
4829 {
4834 case SMART_EVENT_UPDATE:
4841 case SMART_EVENT_RANGE:
4854 {
4855 ProcessEvent(e);
4857 {
4858 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
4859 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4860 {
4861 //find the first event which is not the current one and enable it
4862 if (i->event_id > e.event_id)
4863 {
4864 i->enableTimed = true;
4865 break;
4866 }
4867 }
4868 }
4869 break;
4870 }
4871 }
4872
4874 {
4875 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
4876 if (e.timer > 1)
4877 {
4878 // Re-sort events if this was moved to the top of the queue
4879 mEventSortingRequired = true;
4880 // Reset priority to default one
4882 }
4883 }
4884 }
4885 else
4886 e.timer -= diff;
4887}
@ UNIT_STATE_CASTING
Definition: UnitDefines.h:164
bool enableTimed
Definition: SmartScriptMgr.h:1958

References SmartScriptHolder::action, SmartScriptHolder::active, SmartAction::cast, SmartAction::castFlags, SmartScriptHolder::DEFAULT_PRIORITY, SmartScriptHolder::enableTimed, SmartScriptHolder::event, SmartScriptHolder::event_id, SmartEvent::event_phase_mask, 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_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

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

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

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

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

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

Referenced by OnUpdate(), and RemoveStoredEvent().

◆ 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