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

#include "SmartScript.h"

Classes

struct  SmartScriptFrame
 

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ CounterMap

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

Constructor & Destructor Documentation

◆ SmartScript()

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

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

◆ ~SmartScript()

SmartScript::~SmartScript ( )
66{
67}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5404{
5405 _summonList.insert(guid);
5406}
GuidUnorderedSet _summonList
Definition: SmartScript.h:282

References _summonList.

Referenced by SmartAI::JustSummoned().

◆ AddEvent()

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

References CreateSmartEvent(), and mInstallEvents.

Referenced by InstallTemplate().

◆ AllowPhaseReset()

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

References _allowPhaseReset.

Referenced by OnReset().

◆ CheckTimer()

bool SmartScript::CheckTimer ( SmartScriptHolder const &  e) const
4952{
4953 return e.active;
4954}

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
3395{
3396 SmartScriptHolder script;
3397 script.event.type = e;
3398 script.event.raw.param1 = event_param1;
3399 script.event.raw.param2 = event_param2;
3400 script.event.raw.param3 = event_param3;
3401 script.event.raw.param4 = event_param4;
3402 script.event.raw.param5 = event_param5;
3403 script.event.raw.param6 = event_param6;
3404 script.event.event_phase_mask = phaseMask;
3405 script.event.event_flags = event_flags;
3406 script.event.event_chance = 100;
3407
3408 script.action.type = action;
3409 script.action.raw.param1 = action_param1;
3410 script.action.raw.param2 = action_param2;
3411 script.action.raw.param3 = action_param3;
3412 script.action.raw.param4 = action_param4;
3413 script.action.raw.param5 = action_param5;
3414 script.action.raw.param6 = action_param6;
3415
3416 script.target.type = t;
3417 script.target.raw.param1 = target_param1;
3418 script.target.raw.param2 = target_param2;
3419 script.target.raw.param3 = target_param3;
3420 script.target.raw.param4 = target_param4;
3421
3423 InitTimer(script);
3424 return script;
3425}
static void InitTimer(SmartScriptHolder &e)
Definition: SmartScript.cpp:4805
uint32 param1
Definition: SmartScriptMgr.h:530
uint32 event_flags
Definition: SmartScriptMgr.h:228
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition: SmartScriptMgr.h:226
uint32 param2
Definition: SmartScriptMgr.h:531
uint32 param4
Definition: SmartScriptMgr.h:533
uint32 param3
Definition: SmartScriptMgr.h:532
uint32 param6
Definition: SmartScriptMgr.h:535
uint32 event_chance
Definition: SmartScriptMgr.h:227
uint32 param5
Definition: SmartScriptMgr.h:534
SMART_EVENT type
Definition: SmartScriptMgr.h:225
uint32 param3
Definition: SmartScriptMgr.h:1073
uint32 param5
Definition: SmartScriptMgr.h:1075
uint32 param1
Definition: SmartScriptMgr.h:1071
SMART_ACTION type
Definition: SmartScriptMgr.h:758
uint32 param4
Definition: SmartScriptMgr.h:1074
uint32 param6
Definition: SmartScriptMgr.h:1502
struct SmartAction::@75::@194 raw
uint32 param2
Definition: SmartScriptMgr.h:1072
uint32 param4
Definition: SmartScriptMgr.h:1731
uint32 param1
Definition: SmartScriptMgr.h:1728
uint32 param3
Definition: SmartScriptMgr.h:1730
SMARTAI_TARGETS type
Definition: SmartScriptMgr.h:1580
uint32 param2
Definition: SmartScriptMgr.h:1729
struct SmartTarget::@195::@219 raw
Definition: SmartScriptMgr.h:1957
SmartAction action
Definition: SmartScriptMgr.h:1968
SmartScriptType source_type
Definition: SmartScriptMgr.h:1963
SmartEvent event
Definition: SmartScriptMgr.h:1967
SmartTarget target
Definition: SmartScriptMgr.h:1969

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
5370{
5371 if (p >= mEventPhase)
5372 {
5373 SetPhase(0);
5374 }
5375 else
5376 {
5377 SetPhase(mEventPhase - p);
5378 }
5379}
void SetPhase(uint32 p)
Definition: SmartScript.cpp:5381

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5275{
5276 if (!me)
5277 return nullptr;
5278
5279 Unit* unit = nullptr;
5280 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5282 Cell::VisitAllObjects(me, searcher, range);
5283 return unit;
5284}
Definition: Unit.h:630
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:206
Definition: GridNotifiers.h:406

References me, and Cell::VisitAllObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5255{
5256 if (!me)
5257 return;
5258
5259 Acore::FriendlyCCedInRange u_check(me, range);
5261 Cell::VisitGridObjects(me, searcher, range);
5262}
creatures
Definition: boss_prince_malchezaar.cpp:51
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:178
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
5265{
5266 if (!me)
5267 return;
5268
5269 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5271 Cell::VisitGridObjects(me, searcher, range);
5272}
Definition: GridNotifiers.h:836

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5228{
5229 if (!me)
5230 return nullptr;
5231
5232 Unit* unit = nullptr;
5233
5234 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5236 Cell::VisitGridObjects(me, searcher, range);
5237 return unit;
5238}
Definition: GridNotifiers.h:775

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5241{
5242 if (!me)
5243 {
5244 return nullptr;
5245 }
5246
5247 Unit* unit = nullptr;
5248 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5250 Cell::VisitGridObjects(me, searcher, range);
5251 return unit;
5252}
Definition: GridNotifiers.h:794

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5063{
5064 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5065
5066 if (e.empty())
5067 {
5068 if (obj)
5069 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5070
5071 if (at)
5072 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5073 return;
5074 }
5075 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5076 {
5077#ifndef ACORE_DEBUG
5078 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5079 continue;
5080#endif
5081
5082 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5083 {
5084 if (obj && obj->GetMap()->IsDungeon())
5085 {
5086 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5087 {
5088 mEvents.push_back((*i));
5089 }
5090 }
5091 continue;
5092 }
5093 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5094 }
5095}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition: SmartScriptMgr.h:1925
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition: SmartScriptMgr.h:1921
SmartAIEventList mEvents
Definition: SmartScript.h:220
uint32 GetEntry() const
Definition: Object.h:115
Map * GetMap() const
Definition: Object.h:536
bool IsDungeon() const
Definition: Map.h:446
uint8 GetSpawnMode() const
Definition: Map.h:418

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

Referenced by GetScript().

◆ FindCreatureNear()

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

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindGameObjectNear()

GameObject * SmartScript::FindGameObjectNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const
inline
143 {
144 auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
145 if (bounds.first == bounds.second)
146 return nullptr;
147
148 return bounds.first->second;
149 }
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:521

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

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

References mEvents.

◆ GetBaseObject()

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

References go, and me.

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

◆ GetCounterValue()

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

References mCounterList.

Referenced by ProcessEvent().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5322{
5323 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5324 if (GetBaseObject())
5326 // xinef: used for area triggers invoker cast
5327 else if (invoker)
5329 return nullptr;
5330}
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:115
ObjectGuid mLastInvoker
Definition: SmartScript.h:200
WorldObject * GetBaseObject() const
Definition: SmartScript.h:64

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

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

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5098{
5100 if (me)
5101 {
5102 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5103 if (e.empty())
5104 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5105
5106 FillScript(e, me, nullptr);
5107
5108 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5109 {
5110 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5111 {
5112 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5113 FillScript(e, me, nullptr);
5114 }
5115 }
5116 }
5117 else if (go)
5118 {
5119 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5120 if (e.empty())
5121 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5122 FillScript(e, go, nullptr);
5123 }
5124 else if (trigger)
5125 {
5126 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5127 FillScript(e, nullptr, trigger);
5128 }
5129}
std::int32_t int32
Definition: Define.h:103
std::vector< SmartScriptHolder > SmartAIEventList
Definition: SmartScriptMgr.h:2053
#define sSmartScriptMgr
Definition: SmartScriptMgr.h:2228
@ CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI
Definition: CreatureData.h:72
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition: SmartScript.cpp:5062
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:65
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:205
Definition: CreatureData.h:186
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:144
uint32 entry
Definition: ObjectMgr.h:421

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

Referenced by OnInitialize().

◆ GetStoredTargetVector()

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

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3428{
3429 WorldObject* scriptTrigger = nullptr;
3430 if (invoker)
3431 scriptTrigger = invoker;
3432 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3433 scriptTrigger = tempLastInvoker;
3434
3435 WorldObject* baseObject = GetBaseObject();
3436
3437 switch (e.GetTargetType())
3438 {
3439 case SMART_TARGET_SELF:
3440 if (baseObject)
3441 targets.push_back(baseObject);
3442 break;
3444 if (me)
3445 if (Unit* victim = me->GetVictim())
3446 targets.push_back(victim);
3447 break;
3449 if (me)
3450 {
3451 if (e.target.hostileRandom.powerType)
3452 {
3453 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)))
3454 targets.push_back(u);
3455 }
3456 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3457 targets.push_back(u);
3458 }
3459 break;
3461 if (me)
3462 {
3463 if (e.target.hostileRandom.powerType)
3464 {
3465 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)))
3466 targets.push_back(u);
3467 }
3468 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3469 targets.push_back(u);
3470 }
3471 break;
3473 if (me)
3474 {
3475 if (e.target.hostileRandom.powerType)
3476 {
3477 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)))
3478 targets.push_back(u);
3479 }
3480 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3481 targets.push_back(u);
3482 }
3483 break;
3485 if (me)
3486 {
3487 if (e.target.hostileRandom.powerType)
3488 {
3489 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)))
3490 targets.push_back(u);
3491 }
3492 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3493 targets.push_back(u);
3494 }
3495 break;
3497 if (me)
3498 {
3499 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)))
3500 targets.push_back(u);
3501 }
3502 break;
3504 if (scriptTrigger)
3505 targets.push_back(scriptTrigger);
3506 break;
3508 if (scriptTrigger && IsUnit(scriptTrigger))
3509 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3510 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3511 break;
3513 if (scriptTrigger)
3514 {
3515 if (Player* player = scriptTrigger->ToPlayer())
3516 {
3517 if (Group* group = player->GetGroup())
3518 {
3519 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3520 if (Player* member = groupRef->GetSource())
3521 {
3522 if (member->IsInMap(player))
3523 targets.push_back(member);
3524
3525 if (e.target.invokerParty.includePets)
3526 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3527 if (pet->IsPet() && pet->IsInMap(player))
3528 targets.push_back(pet);
3529 }
3530 }
3531 // We still add the player to the list if there is no group. If we do
3532 // this even if there is a group (thus the else-check), it will add the
3533 // same player to the list twice. We don't want that to happen.
3534 else
3535 targets.push_back(scriptTrigger);
3536 }
3537 }
3538 break;
3540 {
3541 WorldObject* ref = baseObject;
3542 if (!ref)
3543 ref = scriptTrigger;
3544
3545 if (!ref)
3546 {
3547 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3548 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3549 break;
3550 }
3551
3552 ObjectVector units;
3553 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3554
3555 for (WorldObject* unit : units)
3556 {
3557 if (!IsCreature(unit))
3558 continue;
3559
3560 if (me && me->GetGUID() == unit->GetGUID())
3561 continue;
3562
3563 // check alive state - 1 alive, 2 dead, 0 both
3564 if (uint32 state = e.target.unitRange.livingState)
3565 {
3566 if (unit->ToCreature()->IsAlive() && state == 2)
3567 continue;
3568 if (!unit->ToCreature()->IsAlive() && state == 1)
3569 continue;
3570 }
3571
3572 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))
3573 targets.push_back(unit);
3574 }
3575
3576 break;
3577 }
3579 {
3580 ObjectVector units;
3581 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3582
3583 for (WorldObject* unit : units)
3584 {
3585 if (!IsCreature(unit))
3586 continue;
3587
3588 if (me && me->GetGUID() == unit->GetGUID())
3589 continue;
3590
3591 // check alive state - 1 alive, 2 dead, 0 both
3592 if (uint32 state = e.target.unitDistance.livingState)
3593 {
3594 if (unit->ToCreature()->IsAlive() && state == 2)
3595 continue;
3596 if (!unit->ToCreature()->IsAlive() && state == 1)
3597 continue;
3598 }
3599
3600 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3601 targets.push_back(unit);
3602 }
3603
3604 break;
3605 }
3607 {
3608 ObjectVector units;
3609 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3610
3611 for (WorldObject* unit : units)
3612 {
3613 if (!IsGameObject(unit))
3614 continue;
3615
3616 if (go && go->GetGUID() == unit->GetGUID())
3617 continue;
3618
3619 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3620 targets.push_back(unit);
3621 }
3622
3623 break;
3624 }
3626 {
3627
3628 WorldObject* ref = baseObject;
3629 if (!ref)
3630 ref = scriptTrigger;
3631
3632 if (!ref)
3633 {
3634 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3635 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3636 break;
3637 }
3638
3639 ObjectVector units;
3640 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3641
3642 for (WorldObject* unit : units)
3643 {
3644 if (!IsGameObject(unit))
3645 continue;
3646
3647 if (go && go->GetGUID() == unit->GetGUID())
3648 continue;
3649
3650 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))
3651 targets.push_back(unit);
3652 }
3653
3654 break;
3655 }
3657 {
3658 if (!scriptTrigger && !baseObject)
3659 {
3660 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3661 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3662 break;
3663 }
3664
3665 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3666 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3667 targets.push_back(target);
3668 break;
3669 }
3671 {
3672 if (!scriptTrigger && !GetBaseObject())
3673 {
3674 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: 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 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3680 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3681 targets.push_back(target);
3682 break;
3683 }
3685 {
3686 ObjectVector units;
3687 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3688
3689 if (!units.empty() && baseObject)
3690 for (WorldObject* unit : units)
3691 if (IsPlayer(unit) && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3692 targets.push_back(unit);
3693 if (e.target.playerRange.maxCount)
3694 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3695 break;
3696 }
3698 {
3699 ObjectVector units;
3700 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3701
3702 for (WorldObject* unit : units)
3703 if (IsPlayer(unit))
3704 targets.push_back(unit);
3705 break;
3706 }
3708 {
3709 WorldObject* ref = baseObject;
3710 if (!ref)
3711 ref = scriptTrigger;
3712
3713 if (!ref)
3714 {
3715 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3716 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3717 break;
3718 }
3719
3720 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3721 targets.assign(stored->begin(), stored->end());
3722 break;
3723 }
3725 {
3726 WorldObject* ref = baseObject;
3727
3728 if (!ref)
3729 ref = scriptTrigger;
3730
3731 if (!ref)
3732 {
3733 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3734 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3735 break;
3736 }
3737
3738 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3739 if (target)
3740 targets.push_back(target);
3741 break;
3742 }
3744 {
3745 WorldObject* ref = baseObject;
3746
3747 if (!ref)
3748 ref = scriptTrigger;
3749
3750 if (!ref)
3751 {
3752 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3753 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3754 break;
3755 }
3756
3757 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3758 if (target)
3759 targets.push_back(target);
3760 break;
3761 }
3763 {
3764 WorldObject* ref = baseObject;
3765
3766 if (!ref)
3767 ref = scriptTrigger;
3768
3769 if (!ref)
3770 {
3771 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3772 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3773 break;
3774 }
3775
3776 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3777 targets.push_back(target);
3778 break;
3779 }
3781 /*
3782 * Owners/Summoners should be WorldObjects. This allows to have other objects
3783 * such as gameobjects to execute SmartScripts using this type of target.
3784 * Otherwise, only Units like creatures can summon other creatures.
3785 */
3786 {
3787 if (me)
3788 {
3790 {
3791 targets.push_back(owner);
3792 }
3793 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3794 {
3795 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3796 }
3797 }
3798 else if (go)
3799 {
3801 {
3802 targets.push_back(owner);
3803 }
3804 }
3805
3806 // xinef: Get owner of owner
3807 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3808 {
3809 if (WorldObject* owner = targets.front())
3810 {
3811 targets.clear();
3812
3813 if (owner->ToCreature())
3814 {
3815 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3816 {
3817 targets.push_back(base);
3818 }
3819 }
3820 else
3821 {
3822 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3823 {
3824 targets.push_back(base);
3825 }
3826 }
3827 }
3828 }
3829 break;
3830 }
3832 {
3833 if (me)
3834 {
3836 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
3837 if (Unit* temp = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
3838 // Xinef: added distance check
3839 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3840 targets.push_back(temp);
3841 }
3842 break;
3843 }
3845 {
3846 if (me)
3847 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3848 targets.push_back(target);
3849
3850 break;
3851 }
3853 {
3854 if (me)
3855 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3856 targets.push_back(target);
3857
3858 break;
3859 }
3861 {
3862 ObjectVector units;
3863 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3864
3865 for (WorldObject* unit : units)
3866 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3867 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3868 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3869 targets.push_back(unit);
3870
3871 if (e.target.o > 0)
3872 Acore::Containers::RandomResize(targets, e.target.o);
3873
3874 break;
3875 }
3877 {
3878 ObjectVector units;
3879 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3880 // 1 = Tanks, 2 = Healer, 4 = Damage
3881 uint32 roleMask = e.target.roleSelection.roleMask;
3882 for (WorldObject* unit : units)
3883 if (Player* targetPlayer = unit->ToPlayer())
3884 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3885 {
3886 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3887 {
3888 if (targetPlayer->HasTankSpec())
3889 {
3890 targets.push_back(unit);
3891 continue;
3892 }
3893 }
3894 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3895 {
3896 if (targetPlayer->HasHealSpec())
3897 {
3898 targets.push_back(unit);
3899 continue;
3900 }
3901 }
3902 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3903 {
3904 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3905 {
3906 targets.push_back(unit);
3907 continue;
3908 }
3909 }
3910 }
3911
3912 if (e.target.roleSelection.resize > 0)
3913 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
3914
3915 break;
3916 }
3918 {
3919 if (me && me->IsVehicle())
3920 {
3921 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
3922 {
3923 targets.push_back(target);
3924 }
3925 }
3926 break;
3927 }
3929 {
3930 if (me)
3931 {
3932 if (Group* lootGroup = me->GetLootRecipientGroup())
3933 {
3934 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
3935 {
3936 if (Player* recipient = it->GetSource())
3937 {
3938 targets.push_back(recipient);
3939 }
3940 }
3941 }
3942 else
3943 {
3944 if (Player* recipient = me->GetLootRecipient())
3945 {
3946 targets.push_back(recipient);
3947 }
3948 }
3949 }
3950 break;
3951 }
3953 {
3954 if (me)
3955 {
3956 for (ObjectGuid const& guid : _summonList)
3957 {
3958 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
3959 {
3960 if (Creature* creature = me->GetMap()->GetCreature(guid))
3961 {
3962 targets.push_back(creature);
3963 }
3964 }
3965 }
3966 }
3967 break;
3968 }
3970 {
3971 if (InstanceScript* instance = GetBaseObject()->GetInstanceScript())
3972 {
3973 if (e.target.instanceStorage.type == 1)
3974 {
3975 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
3976 {
3977 targets.push_back(creature);
3978 }
3979 }
3980 else if (e.target.instanceStorage.type == 2)
3981 {
3982 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
3983 {
3984 targets.push_back(go);
3985 }
3986 }
3987 }
3988 else
3989 {
3990 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
3991 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3992 }
3993
3994 break;
3995 }
3996 case SMART_TARGET_NONE:
3998 default:
3999 break;
4000 }
4001}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
std::uint32_t uint32
Definition: Define.h:107
Powers
Definition: SharedDefines.h:268
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition: SmartScriptMgr.h:1750
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition: SmartScriptMgr.h:1749
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition: SmartScriptMgr.h:1751
@ SMART_TARGET_LOOT_RECIPIENTS
Definition: SmartScriptMgr.h:1547
@ SMART_TARGET_CLOSEST_CREATURE
Definition: SmartScriptMgr.h:1539
@ SMART_TARGET_CREATURE_DISTANCE
Definition: SmartScriptMgr.h:1531
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition: SmartScriptMgr.h:1526
@ SMART_TARGET_INVOKER_PARTY
Definition: SmartScriptMgr.h:1536
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition: SmartScriptMgr.h:1546
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition: SmartScriptMgr.h:1540
@ SMART_TARGET_VEHICLE_PASSENGER
Definition: SmartScriptMgr.h:1549
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition: SmartScriptMgr.h:1533
@ SMART_TARGET_CREATURE_GUID
Definition: SmartScriptMgr.h:1530
@ SMART_TARGET_PLAYER_RANGE
Definition: SmartScriptMgr.h:1537
@ SMART_TARGET_SUMMONED_CREATURES
Definition: SmartScriptMgr.h:1560
@ SMART_TARGET_VICTIM
Definition: SmartScriptMgr.h:1522
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition: SmartScriptMgr.h:1535
@ SMART_TARGET_CREATURE_RANGE
Definition: SmartScriptMgr.h:1529
@ SMART_TARGET_CLOSEST_PLAYER
Definition: SmartScriptMgr.h:1541
@ SMART_TARGET_HOSTILE_RANDOM
Definition: SmartScriptMgr.h:1525
@ SMART_TARGET_GAMEOBJECT_GUID
Definition: SmartScriptMgr.h:1534
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition: SmartScriptMgr.h:1523
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition: SmartScriptMgr.h:1543
@ SMART_TARGET_SELF
Definition: SmartScriptMgr.h:1521
@ SMART_TARGET_PLAYER_WITH_AURA
Definition: SmartScriptMgr.h:1557
@ SMART_TARGET_ROLE_SELECTION
Definition: SmartScriptMgr.h:1559
@ SMART_TARGET_ACTION_INVOKER
Definition: SmartScriptMgr.h:1527
@ SMART_TARGET_POSITION
Definition: SmartScriptMgr.h:1528
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition: SmartScriptMgr.h:1524
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition: SmartScriptMgr.h:1542
@ SMART_TARGET_INSTANCE_STORAGE
Definition: SmartScriptMgr.h:1561
@ SMART_TARGET_FARTHEST
Definition: SmartScriptMgr.h:1548
@ SMART_TARGET_THREAT_LIST
Definition: SmartScriptMgr.h:1544
@ SMART_TARGET_CLOSEST_ENEMY
Definition: SmartScriptMgr.h:1545
@ SMART_TARGET_NONE
Definition: SmartScriptMgr.h:1520
@ SMART_TARGET_PLAYER_DISTANCE
Definition: SmartScriptMgr.h:1538
@ SMART_TARGET_STORED
Definition: SmartScriptMgr.h:1532
std::vector< WorldObject * > ObjectVector
Definition: SmartScriptMgr.h:1994
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition: ScriptedCreature.cpp:850
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition: ScriptedCreature.cpp:855
void RandomResize(C &container, std::size_t requestedSize)
Definition: Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:199
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const)
Definition: ObjectAccessor.cpp:234
Definition: UnitAI.h:135
Definition: UnitAI.h: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:5332
static bool IsPlayer(WorldObject *obj)
Definition: SmartScript.cpp:5337
static bool IsCreature(WorldObject *obj)
Definition: SmartScript.cpp:5342
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition: SmartScript.cpp:5321
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition: SmartScript.cpp:4003
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition: SmartScript.cpp:5358
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition: SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition: SmartScript.cpp:5274
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:142
std::list< HostileReference * > StorageType
Definition: ThreatMgr.h:147
ThreatContainer::StorageType const & GetThreatList() const
Definition: ThreatMgr.h:273
Definition: Creature.h:43
Player * GetLootRecipient() const
Definition: Creature.cpp:1306
Group * GetLootRecipientGroup() const
Definition: Creature.cpp:1313
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition: Creature.cpp:2388
CreatureAI * AI() const
Definition: Creature.h:140
Unit * GetSummonerUnit() const
Definition: TemporarySummon.cpp:44
Definition: GameObject.h:120
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:173
Player * ToPlayer()
Definition: Object.h:201
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
Unit * ToUnit()
Definition: Object.h:209
Player * SelectNearestPlayer(float distance=0) const
Definition: Object.cpp:2484
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition: Object.cpp:1415
Definition: ObjectGuid.h:118
Definition: Player.h:1081
bool IsVehicle() const
Definition: Unit.h:757
Vehicle * GetVehicle() const
Definition: Unit.h:1786
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:648
TempSummon * ToTempSummon()
Definition: Unit.h:696
bool IsSummon() const
Definition: Unit.h:751
Unit * GetVictim() const
Definition: Unit.h:853
ThreatMgr & GetThreatMgr()
Definition: Unit.h:903
Vehicle * GetVehicleKit() const
Definition: Unit.h:1785
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.h:1220
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:227
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:3317

References _summonList, Creature::AI(), SmartTarget::aura, SmartTarget::closestAttackable, SmartTarget::closestFriendly, SmartTarget::creature, SmartTarget::dbGuid, SmartTarget::dead, SmartTarget::dist, SmartTarget::distMax, SmartTarget::distMin, DoFindClosestFriendlyInRange(), SmartTarget::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, SmartTarget::farthest, FindCreatureNear(), FindGameObjectNear(), SmartScriptHolder::GetActionType(), Vehicle::GetBase(), GetBaseObject(), Unit::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), ObjectAccessor::GetCreatureOrPetOrVehicle(), Object::GetEntry(), Object::GetGUID(), GetLastInvoker(), Creature::GetLootRecipient(), Creature::GetLootRecipientGroup(), WorldObject::GetMap(), GameObject::GetOwnerGUID(), Vehicle::GetPassenger(), SmartScriptHolder::GetScriptType(), GetStoredTargetVector(), TempSummon::GetSummonerUnit(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), Unit::GetVehicle(), Unit::GetVehicleKit(), Unit::GetVictim(), ObjectAccessor::GetWorldObject(), GetWorldObjectsInDist(), go, SmartTarget::goClosest, SmartTarget::goDistance, SmartTarget::goGUID, SmartTarget::goRange, SmartTarget::hostileRandom, SmartTarget::id, SmartTarget::includePets, SmartTarget::index, SmartTarget::instanceStorage, SmartTarget::invokerParty, IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, 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
4004{
4005 WorldObject* obj = GetBaseObject();
4006 if (!obj)
4007 return;
4008
4009 Acore::AllWorldObjectsInRange u_check(obj, dist);
4011 Cell::VisitAllObjects(obj, searcher, dist);
4012}
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
5364{
5365 // protect phase from overflowing
5366 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5367}
@ SMART_EVENT_PHASE_12
Definition: SmartScriptMgr.h:76

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
4806{
4807 switch (e.GetEventType())
4808 {
4809 //set only events which have initial timers
4813 break;
4814 case SMART_EVENT_UPDATE:
4817 case SMART_EVENT_RANGE:
4824 break;
4828 break;
4832 break;
4833 default:
4834 e.active = true;
4835 break;
4836 }
4837}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition: SmartScriptMgr.h:192
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition: SmartScriptMgr.h:210
@ SMART_EVENT_AREA_CASTING
Definition: SmartScriptMgr.h:213
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition: SmartScriptMgr.h:194
@ SMART_EVENT_RANGE
Definition: SmartScriptMgr.h:127
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition: SmartScriptMgr.h:212
@ SMART_EVENT_UPDATE_IC
Definition: SmartScriptMgr.h:118
@ SMART_EVENT_IS_IN_MELEE_RANGE
Definition: SmartScriptMgr.h:218
@ SMART_EVENT_AREA_RANGE
Definition: SmartScriptMgr.h:214
@ SMART_EVENT_UPDATE
Definition: SmartScriptMgr.h:178
@ SMART_EVENT_IS_BEHIND_TARGET
Definition: SmartScriptMgr.h:185
@ SMART_EVENT_UPDATE_OOC
Definition: SmartScriptMgr.h:119
@ SMART_EVENT_NEAR_UNIT
Definition: SmartScriptMgr.h:211
@ SMART_EVENT_DISTANCE_CREATURE
Definition: SmartScriptMgr.h:193
@ SMART_EVENT_NEAR_PLAYERS
Definition: SmartScriptMgr.h:209
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition: SmartScript.cpp:4838
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:1979
uint32 GetEventType() const
Definition: SmartScriptMgr.h:1973

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

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

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private
4957{
4958 if (!mInstallEvents.empty())
4959 {
4960 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
4961 mEvents.push_back(*i);//must be before UpdateTimers
4962
4963 mInstallEvents.clear();
4964 }
4965}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3316{
3317 if (!GetBaseObject())
3318 return;
3320 {
3321 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3322 return;
3323 }
3324 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3325 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3326 {
3328 {
3329 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);
3330 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);
3331 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);
3332 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);
3333 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);
3334 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);
3335 break;
3336 }
3338 {
3339 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);
3340 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);
3341 break;
3342 }
3344 {
3345 if (!me)
3346 return;
3347 //store cage as id1
3348 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);
3349
3350 //reset(close) cage on hostage(me) respawn
3351 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);
3352
3353 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);
3354 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);
3355
3356 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);
3357 //phase 1: give quest credit on movepoint reached
3359 //phase 1: despawn after time on movepoint reached
3360 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);
3361
3362 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3363 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);
3364 break;
3365 }
3367 {
3368 if (!go)
3369 return;
3370 //store hostage as id1
3371 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);
3372 //store invoker as id2
3373 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);
3374 //signal hostage
3375 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);
3376 //when hostage raeched end point, give credit to invoker
3377 if (e.action.installTtemplate.param2)
3378 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);
3379 else
3380 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);
3381 break;
3382 }
3384 default:
3385 return;
3386 }
3387}
std::uint8_t uint8
Definition: Define.h:109
SMARTAI_TEMPLATE
Definition: SmartScriptMgr.h:1508
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition: SmartScriptMgr.h:1513
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition: SmartScriptMgr.h:1514
@ SMARTAI_TEMPLATE_CASTER
Definition: SmartScriptMgr.h:1510
@ SMARTAI_TEMPLATE_TURRET
Definition: SmartScriptMgr.h:1511
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition: SmartScriptMgr.h:1914
@ SMART_ACTION_STORE_TARGET_LIST
Definition: SmartScriptMgr.h:622
@ SMART_ACTION_FORCE_DESPAWN
Definition: SmartScriptMgr.h:599
@ SMART_ACTION_CAST
Definition: SmartScriptMgr.h:569
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition: SmartScriptMgr.h:579
@ SMART_ACTION_MOVE_FORWARD
Definition: SmartScriptMgr.h:604
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition: SmartScriptMgr.h:591
@ SMART_ACTION_TALK
Definition: SmartScriptMgr.h:559
@ SMART_ACTION_SET_DATA
Definition: SmartScriptMgr.h:603
@ SMART_ACTION_SET_RUN
Definition: SmartScriptMgr.h:617
@ SMART_ACTION_SET_EVENT_PHASE
Definition: SmartScriptMgr.h:580
@ SMART_ACTION_RESET_GOBJECT
Definition: SmartScriptMgr.h:590
@ SMART_EVENT_DATA_SET
Definition: SmartScriptMgr.h:156
@ SMART_EVENT_JUST_CREATED
Definition: SmartScriptMgr.h:181
@ SMART_EVENT_MOVEMENTINFORM
Definition: SmartScriptMgr.h:152
@ SMART_EVENT_MANA_PCT
Definition: SmartScriptMgr.h:121
@ SMART_EVENT_GO_STATE_CHANGED
Definition: SmartScriptMgr.h:188
@ SMART_RANDOM_POINT
Definition: SmartScriptMgr.h:58
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:118
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:48
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:3389

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
5348{
5349 if (!obj)
5350 return false;
5351
5352 if (Creature* creatureObj = obj->ToCreature())
5353 return creatureObj->IsCharmed();
5354
5355 return false;
5356}
Creature * ToCreature()
Definition: Object.h:205

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5343{
5344 return obj && obj->IsCreature();
5345}
bool IsCreature() const
Definition: Object.h:204

References Object::IsCreature().

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

◆ IsGameObject()

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

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5394{
5395 if (mEventPhase == 0)
5396 {
5397 return false;
5398 }
5399
5400 return ((1 << (mEventPhase - 1)) & p) != 0;
5401}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5338{
5339 return obj && obj->IsPlayer();
5340}
bool IsPlayer() const
Definition: Object.h:200

References Object::IsPlayer().

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

◆ IsSmart() [1/3]

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

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

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

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

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

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

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5333{
5334 return obj && (obj->IsCreature() || obj->IsPlayer());
5335}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5132{
5133 if (obj)//handle object based scripts
5134 {
5135 switch (obj->GetTypeId())
5136 {
5137 case TYPEID_UNIT:
5139 me = obj->ToCreature();
5140 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5141 break;
5142 case TYPEID_GAMEOBJECT:
5144 go = obj->ToGameObject();
5145 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5146 break;
5147 default:
5148 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5149 return;
5150 }
5151 }
5152 else if (at)
5153 {
5155 trigger = at;
5156 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5157 }
5158 else
5159 {
5160 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5161 return;
5162 }
5163
5164 GetScript();//load copy of script
5165
5166 for (SmartScriptHolder& event : mEvents)
5167 InitTimer(event);//calculate timers for first time use
5168
5170 InstallEvents();
5172}
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition: SmartScriptMgr.h:1757
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition: SmartScriptMgr.h:1758
@ SMART_EVENT_AI_INIT
Definition: SmartScriptMgr.h:155
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
void ProcessEventsFor(SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition: SmartScript.cpp:135
void InstallEvents()
Definition: SmartScript.cpp:4956
void GetScript()
Definition: SmartScript.cpp:5097
TypeID GetTypeId() const
Definition: Object.h:127
GameObject * ToGameObject()
Definition: Object.h:213

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)
5175{
5176 if (!me)
5177 return;
5178
5180}
@ SMART_EVENT_IC_LOS
Definition: SmartScriptMgr.h:144
@ SMART_EVENT_OOC_LOS
Definition: SmartScriptMgr.h:128
bool IsEngaged() const
Definition: Unit.h:881

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

void SmartScript::OnReset ( )
110{
111 // xinef: check if we allow phase reset
112 if (AllowPhaseReset())
113 SetPhase(0);
114
116 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
117 {
118 if (!((*i).event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
119 {
120 InitTimer((*i));
121 (*i).runOnce = false;
122 }
123
124 if ((*i).priority != SmartScriptHolder::DEFAULT_PRIORITY)
125 {
128 }
129 }
132 mCounterList.clear();
133}
@ SMART_EVENT_FLAG_DONT_RESET
Definition: SmartScriptMgr.h:1922
@ SMART_EVENT_RESET
Definition: SmartScriptMgr.h:143
bool AllowPhaseReset() const
Definition: SmartScript.h:204
void ResetBaseObject()
Definition: SmartScript.h:166
static constexpr uint32 DEFAULT_PRIORITY
Definition: SmartScriptMgr.h:1989
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)
4968{
4970 return;
4971
4972 InstallEvents();//before UpdateTimers
4973
4975 {
4977 mEventSortingRequired = false;
4978 }
4979
4980 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
4981 UpdateTimer(*i, diff);
4982
4983 if (!mStoredEvents.empty())
4984 {
4985 SmartAIEventStoredList::iterator i, icurr;
4986 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
4987 {
4988 icurr = i++;
4989 UpdateTimer(*icurr, diff);
4990 }
4991 }
4992
4993 bool needCleanup = true;
4994 if (!mTimedActionList.empty())
4995 {
4997 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4998 {
4999 if ((*i).enableTimed)
5000 {
5001 UpdateTimer(*i, diff);
5002 needCleanup = false;
5003 }
5004 }
5005
5007 }
5008 if (needCleanup)
5009 mTimedActionList.clear();
5010
5011 if (!mRemIDs.empty())
5012 {
5013 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5015
5016 // xinef: clear list after cleaning...
5017 mRemIDs.clear();
5018 }
5019 if (mUseTextTimer && me)
5020 {
5021 if (mTextTimer < diff)
5022 {
5023 uint32 textID = mLastTextID;
5024 mLastTextID = 0;
5025 uint32 entry = mTalkerEntry;
5026 mTalkerEntry = 0;
5027 mTextTimer = 0;
5028 mUseTextTimer = false;
5029 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5030 }
5031 else mTextTimer -= diff;
5032 }
5033}
@ SMART_EVENT_TEXT_OVER
Definition: SmartScriptMgr.h:170
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition: SmartScript.cpp:4845
void SortEvents(SmartAIEventList &events)
Definition: SmartScript.cpp:5035
SmartAIEventStoredList mStoredEvents
Definition: SmartScript.h:234
std::list< uint32 > mRemIDs
Definition: SmartScript.h:235
SmartAIEventList mTimedActionList
Definition: SmartScript.h:222
void RemoveStoredEvent(uint32 id)
Definition: SmartScript.h:252

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

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

◆ ProcessAction()

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

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

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

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

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

Referenced by SmartAI::CorpseRemoved(), SmartAI::DamageDealt(), SmartAI::DamageTaken(), SmartGameObjectAI::Destroyed(), SmartAI::DoAction(), SmartAI::EndPath(), SmartAI::EnterEvadeMode(), SmartGameObjectAI::EventInform(), SmartGameObjectAI::GossipHello(), SmartGameObjectAI::GossipSelect(), SmartAI::HealReceived(), SmartAI::InitializeAI(), SmartGameObjectAI::InitializeAI(), SmartAI::IsSummonedBy(), SmartAI::JustDied(), SmartAI::JustEngagedWith(), SmartAI::JustReachedHome(), SmartAI::JustRespawned(), SmartAI::JustSummoned(), SmartGameObjectAI::JustSummoned(), SmartAI::KilledUnit(), SmartAI::MovementInform(), SmartAI::MovepointReached(), SmartAI::OnCharmed(), SmartGameObjectAI::OnGameEvent(), OnInitialize(), OnMoveInLineOfSight(), OnReset(), SmartAI::OnSpellClick(), SmartGameObjectAI::OnStateChanged(), SmartTrigger::OnTrigger(), OnUpdate(), SmartAI::PassengerBoarded(), SmartAI::PathEndReached(), SmartAI::PausePath(), 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 
)
3301{
3302 // xinef: extended by selfs victim
3303 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3304 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3305
3306 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3307 {
3308 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3309 RecalcTimer(e, min, max);
3310 }
3311 else
3312 RecalcTimer(e, 5000, 5000);
3313}

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
5041{
5042 e.timer = 1200;
5043 // Change priority only if it's set to default, otherwise keep the current order of events
5045 {
5047 mEventSortingRequired = true;
5048 }
5049}
uint32 timer
Definition: SmartScriptMgr.h:1977
uint32 priority
Definition: SmartScriptMgr.h:1978

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
4839{
4840 // min/max was checked at loading!
4841 e.timer = urand(uint32(min), uint32(max));
4842 e.active = e.timer ? false : true;
4843}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5409{
5410 _summonList.erase(guid);
5411}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

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

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

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

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

Referenced by OnReset().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
5052{
5053 RaisePriority(e);
5054
5055 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5056 if (ignoreChanceRoll)
5058
5059 e.runOnce = false;
5060}
void RaisePriority(SmartScriptHolder &e)
Definition: SmartScript.cpp:5040

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

Referenced by ProcessAction().

◆ SetPathId()

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

References mPathId.

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

◆ SetPhase()

void SmartScript::SetPhase ( uint32  p)
private
5382{
5383 uint32 oldPhase = mEventPhase;
5384
5385 mEventPhase = p;
5386
5387 if (oldPhase != mEventPhase)
5388 {
5390 }
5391}

References mEventPhase, ProcessEventsFor(), and SMART_EVENT_EVENT_PHASE_CHANGE.

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

◆ SetPhaseReset()

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

References _allowPhaseReset.

◆ SetScript9()

void SmartScript::SetScript9 ( SmartScriptHolder e,
uint32  entry 
)
5287{
5288 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5289 // any SmartScriptHolder contained like the "e" parameter passed to this function
5291 {
5292 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());
5293 return;
5294 }
5295
5296 // 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
5298 {
5299 return;
5300 }
5301
5302 mTimedActionList.clear();
5304 if (mTimedActionList.empty())
5305 return;
5306 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5307 {
5308 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5309
5310 if (e.action.timedActionList.timerType == 0)
5311 i->event.type = SMART_EVENT_UPDATE_OOC;
5312 else if (e.action.timedActionList.timerType == 1)
5313 i->event.type = SMART_EVENT_UPDATE_IC;
5314 else if (e.action.timedActionList.timerType > 1)
5315 i->event.type = SMART_EVENT_UPDATE;
5316
5317 InitTimer((*i));
5318 }
5319}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition: SmartScriptMgr.h:1765
SAIBool allowOverride
Definition: SmartScriptMgr.h:1162
uint32 timerType
Definition: SmartScriptMgr.h:1161

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
5036{
5037 std::sort(events.begin(), events.end());
5038}
events
Definition: boss_sartura.cpp:43

Referenced by OnUpdate().

◆ StoreCounter()

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

References mCounterList, ProcessEventsFor(), and SMART_EVENT_COUNTER_SET.

Referenced by ProcessAction().

◆ StoreTargetList()

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

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4846{
4847 if (e.GetEventType() == SMART_EVENT_LINK)
4848 return;
4849
4851 return;
4852
4853 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4854 return;
4855
4856 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4857 return;
4858
4859 if (e.timer < diff)
4860 {
4861 // delay spell cast for another AI tick if another spell is being cast
4863 {
4865 {
4867 {
4868 RaisePriority(e);
4869 return;
4870 }
4871 }
4872 }
4873
4874 // Delay flee for assist event if casting
4876 {
4877 e.timer = 1200;
4878 return;
4879 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
4880
4881 e.active = true;//activate events with cooldown
4882 switch (e.GetEventType())//process ONLY timed events
4883 {
4888 case SMART_EVENT_UPDATE:
4895 case SMART_EVENT_RANGE:
4909 {
4910 ASSERT(executionStack.empty());
4911 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
4912 while (!executionStack.empty())
4913 {
4914 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
4915 executionStack.pop_back();
4916 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
4917 }
4919 {
4920 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
4921 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4922 {
4923 //find the first event which is not the current one and enable it
4924 if (i->event_id > e.event_id)
4925 {
4926 i->enableTimed = true;
4927 break;
4928 }
4929 }
4930 }
4931 break;
4932 }
4933 }
4934
4936 {
4937 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
4938 if (e.timer > 1)
4939 {
4940 // Re-sort events if this was moved to the top of the queue
4941 mEventSortingRequired = true;
4942 // Reset priority to default one
4944 }
4945 }
4946 }
4947 else
4948 e.timer -= diff;
4949}
@ UNIT_STATE_CASTING
Definition: UnitDefines.h:164
bool enableTimed
Definition: SmartScriptMgr.h:1981

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

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ executionStack

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

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ 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