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

#include "SmartScript.h"

Classes

struct  SmartScriptFrame
 

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ CounterMap

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

Constructor & Destructor Documentation

◆ SmartScript()

SmartScript::SmartScript ( )
69{
70 go = nullptr;
71 me = nullptr;
72 trigger = nullptr;
73 mEventPhase = 0;
74 mPathId = 0;
75 mTextTimer = 0;
76 mLastTextID = 0;
77 mUseTextTimer = false;
78 mTalkerEntry = 0;
84 _allowPhaseReset = true;
85}
@ SMART_SCRIPT_TYPE_CREATURE
Definition SmartScriptMgr.h:1803
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1539
uint32 mEventPhase
Definition SmartScript.h:232
SMARTAI_TEMPLATE mTemplate
Definition SmartScript.h:251
Creature * me
Definition SmartScript.h:226
uint32 mPathId
Definition SmartScript.h:235
SmartScriptType mScriptType
Definition SmartScript.h:231
bool _allowPhaseReset
Definition SmartScript.h:247
bool mUseTextTimer
Definition SmartScript.h:242
uint32 mLastTextID
Definition SmartScript.h:240
uint32 mTextTimer
Definition SmartScript.h:239
GameObject * go
Definition SmartScript.h:228
AreaTrigger const * trigger
Definition SmartScript.h:230
uint32 mCurrentPriority
Definition SmartScript.h:243
uint32 mTalkerEntry
Definition SmartScript.h:241
bool isProcessingTimedActionList
Definition SmartScript.h:225
bool mEventSortingRequired
Definition SmartScript.h:244

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

◆ ~SmartScript()

SmartScript::~SmartScript ( )
88{
89}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5641{
5642 _summonList.insert(guid);
5643}
GuidUnorderedSet _summonList
Definition SmartScript.h:284

References _summonList.

Referenced by SmartAI::JustSummoned().

◆ AddEvent()

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

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
5189{
5190 return e.active;
5191}

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
3534{
3535 SmartScriptHolder script;
3536 script.event.type = e;
3537 script.event.raw.param1 = event_param1;
3538 script.event.raw.param2 = event_param2;
3539 script.event.raw.param3 = event_param3;
3540 script.event.raw.param4 = event_param4;
3541 script.event.raw.param5 = event_param5;
3542 script.event.raw.param6 = event_param6;
3543 script.event.event_phase_mask = phaseMask;
3544 script.event.event_flags = event_flags;
3545 script.event.event_chance = 100;
3546
3547 script.action.type = action;
3548 script.action.raw.param1 = action_param1;
3549 script.action.raw.param2 = action_param2;
3550 script.action.raw.param3 = action_param3;
3551 script.action.raw.param4 = action_param4;
3552 script.action.raw.param5 = action_param5;
3553 script.action.raw.param6 = action_param6;
3554
3555 script.target.type = t;
3556 script.target.raw.param1 = target_param1;
3557 script.target.raw.param2 = target_param2;
3558 script.target.raw.param3 = target_param3;
3559 script.target.raw.param4 = target_param4;
3560
3562 InitTimer(script);
3563 return script;
3564}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:5042
uint32 param3
Definition SmartScriptMgr.h:1063
uint32 param5
Definition SmartScriptMgr.h:1065
uint32 param1
Definition SmartScriptMgr.h:1061
SMART_ACTION type
Definition SmartScriptMgr.h:747
struct SmartAction::@75::@195 raw
uint32 param4
Definition SmartScriptMgr.h:1064
uint32 param6
Definition SmartScriptMgr.h:1504
uint32 param2
Definition SmartScriptMgr.h:1062
uint32 param1
Definition SmartScriptMgr.h:514
uint32 event_flags
Definition SmartScriptMgr.h:209
struct SmartEvent::@30::@74 raw
uint32 event_phase_mask
Definition SmartScriptMgr.h:207
uint32 param2
Definition SmartScriptMgr.h:515
uint32 param4
Definition SmartScriptMgr.h:517
uint32 param3
Definition SmartScriptMgr.h:516
uint32 param6
Definition SmartScriptMgr.h:519
uint32 event_chance
Definition SmartScriptMgr.h:208
uint32 param5
Definition SmartScriptMgr.h:518
SMART_EVENT type
Definition SmartScriptMgr.h:206
Definition SmartScriptMgr.h:2006
SmartAction action
Definition SmartScriptMgr.h:2017
SmartScriptType source_type
Definition SmartScriptMgr.h:2012
SmartEvent event
Definition SmartScriptMgr.h:2016
SmartTarget target
Definition SmartScriptMgr.h:2018
uint32 param4
Definition SmartScriptMgr.h:1763
uint32 param1
Definition SmartScriptMgr.h:1760
uint32 param3
Definition SmartScriptMgr.h:1762
struct SmartTarget::@201::@225 raw
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1612
uint32 param2
Definition SmartScriptMgr.h:1761

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

Referenced by AddEvent(), and ProcessAction().

◆ DecPhase()

void SmartScript::DecPhase ( uint32  p)
private
5607{
5608 if (p >= mEventPhase)
5609 {
5610 SetPhase(0);
5611 }
5612 else
5613 {
5614 SetPhase(mEventPhase - p);
5615 }
5616}
void SetPhase(uint32 p)
Definition SmartScript.cpp:5618

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5512{
5513 if (!me)
5514 return nullptr;
5515
5516 Unit* unit = nullptr;
5517 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5519 Cell::VisitObjects(me, searcher, range);
5520 return unit;
5521}
Definition Unit.h:665
Definition GridNotifiers.h:429
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References me, and Cell::VisitObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5492{
5493 if (!me)
5494 return;
5495
5496 Acore::FriendlyCCedInRange u_check(me, range);
5498 Cell::VisitObjects(me, searcher, range);
5499}
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:841
Definition GridNotifiers.h:496

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
5502{
5503 if (!me)
5504 return;
5505
5506 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5508 Cell::VisitObjects(me, searcher, range);
5509}
Definition GridNotifiers.h:859

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5465{
5466 if (!me)
5467 return nullptr;
5468
5469 Unit* unit = nullptr;
5470
5471 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5473 Cell::VisitObjects(me, searcher, range);
5474 return unit;
5475}
Definition GridNotifiers.h:798

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5478{
5479 if (!me)
5480 {
5481 return nullptr;
5482 }
5483
5484 Unit* unit = nullptr;
5485 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5487 Cell::VisitObjects(me, searcher, range);
5488 return unit;
5489}
Definition GridNotifiers.h:817

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5300{
5301 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5302
5303 if (e.empty())
5304 {
5305 if (obj)
5306 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5307
5308 if (at)
5309 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5310 return;
5311 }
5312 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5313 {
5314#ifndef ACORE_DEBUG
5315 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5316 continue;
5317#endif
5318
5319 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5320 {
5321 if (obj && obj->GetMap()->IsDungeon())
5322 {
5323 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5324 {
5325 mEvents.push_back((*i));
5326 }
5327 }
5328 continue;
5329 }
5330 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5331 }
5332}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition SmartScriptMgr.h:1972
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition SmartScriptMgr.h:1968
bool IsDungeon() const
Definition Map.h:299
uint8 GetSpawnMode() const
Definition Map.h:271
uint32 GetEntry() const
Definition Object.h:117
SmartAIEventList mEvents
Definition SmartScript.h:222
Map * GetMap() const
Definition Object.h:631

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

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

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

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

References mEvents.

Referenced by ProcessAction().

◆ GetBaseObject()

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

References go, and me.

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

◆ GetCounterValue()

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

References mCounterList.

Referenced by ProcessEvent().

◆ GetEvents()

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

References mEvents.

Referenced by SmartAI::InitializeAI().

◆ GetLastInvoker()

WorldObject * SmartScript::GetLastInvoker ( WorldObject invoker = nullptr) const
5559{
5560 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5561 if (GetBaseObject())
5563 // xinef: used for area triggers invoker cast
5564 else if (invoker)
5566 return nullptr;
5567}
ObjectGuid mLastInvoker
Definition SmartScript.h:200
WorldObject * GetBaseObject() const
Definition SmartScript.h:64
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:139

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

Referenced by GetTargets(), and ProcessAction().

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5335{
5337 if (me)
5338 {
5339 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5340 if (e.empty())
5341 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5342
5343 FillScript(e, me, nullptr);
5344
5345 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5346 {
5347 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5348 {
5349 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5350 FillScript(e, me, nullptr);
5351 }
5352 }
5353 }
5354 else if (go)
5355 {
5356 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5357 if (e.empty())
5358 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5359 FillScript(e, go, nullptr);
5360 }
5361 else if (trigger)
5362 {
5363 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5364 FillScript(e, nullptr, trigger);
5365 }
5366}
@ CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI
Definition CreatureData.h:73
std::int32_t int32
Definition Define.h:103
std::vector< SmartScriptHolder > SmartAIEventList
Definition SmartScriptMgr.h:2103
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2279
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:207
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition SmartScript.cpp:5299
uint32 entry
Definition ObjectMgr.h:424
Definition CreatureData.h:187

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

Referenced by OnInitialize().

◆ GetStoredTargetVector()

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

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const
3567{
3568 WorldObject* scriptTrigger = nullptr;
3569 if (invoker)
3570 scriptTrigger = invoker;
3571 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3572 scriptTrigger = tempLastInvoker;
3573
3574 WorldObject* baseObject = GetBaseObject();
3575
3576 switch (e.GetTargetType())
3577 {
3578 case SMART_TARGET_SELF:
3579 if (baseObject)
3580 targets.push_back(baseObject);
3581 break;
3583 if (me)
3584 if (Unit* victim = me->GetVictim())
3585 targets.push_back(victim);
3586 break;
3588 if (me)
3589 {
3590 if (e.target.hostileRandom.powerType)
3591 {
3592 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false)))
3593 targets.push_back(u);
3594 }
3595 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3596 targets.push_back(u);
3597 }
3598 break;
3600 if (me)
3601 {
3602 if (e.target.hostileRandom.powerType)
3603 {
3604 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)))
3605 targets.push_back(u);
3606 }
3607 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3608 targets.push_back(u);
3609 }
3610 break;
3612 if (me)
3613 {
3614 if (e.target.hostileRandom.powerType)
3615 {
3616 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)))
3617 targets.push_back(u);
3618 }
3619 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3620 targets.push_back(u);
3621 }
3622 break;
3624 if (me)
3625 {
3626 if (e.target.hostileRandom.powerType)
3627 {
3628 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false)))
3629 targets.push_back(u);
3630 }
3631 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3632 targets.push_back(u);
3633 }
3634 break;
3636 if (me)
3637 {
3638 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, RangeSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos, e.target.farthest.minDist)))
3639 targets.push_back(u);
3640 }
3641 break;
3643 if (scriptTrigger)
3644 targets.push_back(scriptTrigger);
3645 break;
3647 if (scriptTrigger && IsUnit(scriptTrigger))
3648 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3649 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3650 break;
3652 if (scriptTrigger)
3653 {
3654 if (Player* player = scriptTrigger->ToPlayer())
3655 {
3656 if (Group* group = player->GetGroup())
3657 {
3658 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3659 if (Player* member = groupRef->GetSource())
3660 {
3661 if (member->IsInMap(player))
3662 targets.push_back(member);
3663
3664 if (e.target.invokerParty.includePets)
3665 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3666 if (pet->IsPet() && pet->IsInMap(player))
3667 targets.push_back(pet);
3668 }
3669 }
3670 // We still add the player to the list if there is no group. If we do
3671 // this even if there is a group (thus the else-check), it will add the
3672 // same player to the list twice. We don't want that to happen.
3673 else
3674 targets.push_back(scriptTrigger);
3675 }
3676 }
3677 break;
3679 {
3680 WorldObject* ref = baseObject;
3681 if (!ref)
3682 ref = scriptTrigger;
3683
3684 if (!ref)
3685 {
3686 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3687 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3688 break;
3689 }
3690
3691 ObjectVector units;
3692 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3693
3694 for (WorldObject* unit : units)
3695 {
3696 if (!IsCreature(unit))
3697 continue;
3698
3699 if (me && me->GetGUID() == unit->GetGUID())
3700 continue;
3701
3702 // check alive state - 1 alive, 2 dead, 0 both
3703 if (uint32 state = e.target.unitRange.livingState)
3704 {
3705 if (unit->ToCreature()->IsAlive() && state == 2)
3706 continue;
3707 if (!unit->ToCreature()->IsAlive() && state == 1)
3708 continue;
3709 }
3710
3711 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))
3712 targets.push_back(unit);
3713 }
3714
3715 break;
3716 }
3718 {
3719 ObjectVector units;
3720 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3721
3722 for (WorldObject* unit : units)
3723 {
3724 if (!IsCreature(unit))
3725 continue;
3726
3727 if (me && me->GetGUID() == unit->GetGUID())
3728 continue;
3729
3730 // check alive state - 1 alive, 2 dead, 0 both
3731 if (uint32 state = e.target.unitDistance.livingState)
3732 {
3733 if (unit->ToCreature()->IsAlive() && state == 2)
3734 continue;
3735 if (!unit->ToCreature()->IsAlive() && state == 1)
3736 continue;
3737 }
3738
3739 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3740 targets.push_back(unit);
3741 }
3742
3743 break;
3744 }
3746 {
3747 ObjectVector units;
3748 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3749
3750 for (WorldObject* unit : units)
3751 {
3752 if (!IsGameObject(unit))
3753 continue;
3754
3755 if (go && go->GetGUID() == unit->GetGUID())
3756 continue;
3757
3758 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3759 targets.push_back(unit);
3760 }
3761
3762 break;
3763 }
3765 {
3766
3767 WorldObject* ref = baseObject;
3768 if (!ref)
3769 ref = scriptTrigger;
3770
3771 if (!ref)
3772 {
3773 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3774 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3775 break;
3776 }
3777
3778 ObjectVector units;
3779 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3780
3781 for (WorldObject* unit : units)
3782 {
3783 if (!IsGameObject(unit))
3784 continue;
3785
3786 if (go && go->GetGUID() == unit->GetGUID())
3787 continue;
3788
3789 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))
3790 targets.push_back(unit);
3791 }
3792
3793 break;
3794 }
3796 {
3797 if (!scriptTrigger && !baseObject)
3798 {
3799 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3800 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3801 break;
3802 }
3803
3804 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3805 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3806 targets.push_back(target);
3807 break;
3808 }
3810 {
3811 if (!scriptTrigger && !GetBaseObject())
3812 {
3813 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3814 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3815 break;
3816 }
3817
3818 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3819 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3820 targets.push_back(target);
3821 break;
3822 }
3824 {
3825 ObjectVector units;
3826 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3827
3828 if (!units.empty() && baseObject)
3829 for (WorldObject* unit : units)
3830 if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3831 targets.push_back(unit);
3832
3833 if (e.target.playerRange.maxCount)
3834 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3835
3836 break;
3837 }
3839 {
3840 ObjectVector units;
3841 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3842
3843 for (WorldObject* unit : units)
3844 if (IsPlayer(unit))
3845 targets.push_back(unit);
3846 break;
3847 }
3849 {
3850 WorldObject* ref = baseObject;
3851 if (!ref)
3852 ref = scriptTrigger;
3853
3854 if (!ref)
3855 {
3856 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3857 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3858 break;
3859 }
3860
3861 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3862 targets.assign(stored->begin(), stored->end());
3863 break;
3864 }
3866 {
3867 WorldObject* ref = baseObject;
3868
3869 if (!ref)
3870 ref = scriptTrigger;
3871
3872 if (!ref)
3873 {
3874 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3875 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3876 break;
3877 }
3878
3879 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3880 if (target)
3881 targets.push_back(target);
3882 break;
3883 }
3885 {
3886 WorldObject* ref = baseObject;
3887
3888 if (!ref)
3889 ref = scriptTrigger;
3890
3891 if (!ref)
3892 {
3893 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3894 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3895 break;
3896 }
3897
3898 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3899 if (target)
3900 targets.push_back(target);
3901 break;
3902 }
3904 {
3905 WorldObject* ref = baseObject;
3906
3907 if (!ref)
3908 ref = scriptTrigger;
3909
3910 if (!ref)
3911 {
3912 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3913 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3914 break;
3915 }
3916
3917 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3918 targets.push_back(target);
3919 break;
3920 }
3922 /*
3923 * Owners/Summoners should be WorldObjects. This allows to have other objects
3924 * such as gameobjects to execute SmartScripts using this type of target.
3925 * Otherwise, only Units like creatures can summon other creatures.
3926 */
3927 {
3928 if (me)
3929 {
3931 {
3932 targets.push_back(owner);
3933 }
3934 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3935 {
3936 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3937 }
3938 }
3939 else if (go)
3940 {
3942 {
3943 targets.push_back(owner);
3944 }
3945 }
3946
3947 // xinef: Get owner of owner
3948 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3949 {
3950 if (WorldObject* owner = targets.front())
3951 {
3952 targets.clear();
3953
3954 if (IsCreature(owner))
3955 {
3956 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3957 targets.push_back(base);
3958 }
3959 else if (IsGameObject(owner))
3960 {
3961 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3962 targets.push_back(base);
3963 }
3964 else if (IsPlayer(owner))
3965 {
3966 if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
3967 targets.push_back(base);
3968 }
3969 }
3970 }
3971 break;
3972 }
3974 {
3975 if (me)
3976 {
3977 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
3978 if (Unit* temp = ref->GetVictim())
3979 // Xinef: added distance check
3980 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3981 targets.push_back(temp);
3982 }
3983 break;
3984 }
3986 {
3987 if (me)
3988 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3989 targets.push_back(target);
3990
3991 break;
3992 }
3994 {
3995 if (me)
3996 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3997 targets.push_back(target);
3998
3999 break;
4000 }
4002 {
4003 ObjectVector units;
4004 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
4005
4006 for (WorldObject* unit : units)
4007 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
4008 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
4009 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
4010 targets.push_back(unit);
4011
4012 if (e.target.o > 0)
4013 Acore::Containers::RandomResize(targets, e.target.o);
4014
4015 break;
4016 }
4018 {
4019 ObjectVector units;
4020 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
4021 // 1 = Tanks, 2 = Healer, 4 = Damage
4022 uint32 roleMask = e.target.roleSelection.roleMask;
4023 for (WorldObject* unit : units)
4024 if (Player* targetPlayer = unit->ToPlayer())
4025 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
4026 {
4027 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
4028 {
4029 if (targetPlayer->HasTankSpec())
4030 {
4031 targets.push_back(unit);
4032 continue;
4033 }
4034 }
4035 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
4036 {
4037 if (targetPlayer->HasHealSpec())
4038 {
4039 targets.push_back(unit);
4040 continue;
4041 }
4042 }
4043 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
4044 {
4045 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
4046 {
4047 targets.push_back(unit);
4048 continue;
4049 }
4050 }
4051 }
4052
4053 if (e.target.roleSelection.resize > 0)
4054 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
4055
4056 break;
4057 }
4059 {
4060 if (me && me->IsVehicle())
4061 {
4062 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
4063 {
4064 targets.push_back(target);
4065 }
4066 }
4067 break;
4068 }
4070 {
4071 if (me)
4072 {
4073 if (Group* lootGroup = me->GetLootRecipientGroup())
4074 {
4075 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
4076 {
4077 if (Player* recipient = it->GetSource())
4078 {
4079 targets.push_back(recipient);
4080 }
4081 }
4082 }
4083 else
4084 {
4085 if (Player* recipient = me->GetLootRecipient())
4086 {
4087 targets.push_back(recipient);
4088 }
4089 }
4090 }
4091 break;
4092 }
4094 {
4095 if (me)
4096 {
4097 for (ObjectGuid const& guid : _summonList)
4098 {
4099 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
4100 {
4101 if (Creature* creature = me->GetMap()->GetCreature(guid))
4102 {
4103 targets.push_back(creature);
4104 }
4105 }
4106 }
4107 }
4108 break;
4109 }
4111 {
4112 InstanceScript* instance = nullptr;
4113
4114 if (e.IsAreatriggerScript() && scriptTrigger)
4115 instance = scriptTrigger->GetInstanceScript();
4116 else
4117 instance = GetBaseObject()->GetInstanceScript();
4118
4119 if (!instance)
4120 {
4121 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4122 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4123 return;
4124 }
4125
4126 if (e.target.instanceStorage.type == 1)
4127 {
4128 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
4129 targets.push_back(creature);
4130 }
4131 else if (e.target.instanceStorage.type == 2)
4132 {
4133 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4134 targets.push_back(go);
4135 }
4136
4137 break;
4138 }
4140 {
4141 if (me)
4142 {
4143 if (CreatureGroup* group = me->GetFormation())
4144 {
4145 uint32 formationType = e.target.formation.type;
4146 uint32 entry = e.target.formation.entry;
4147 bool excludeSelf = e.target.formation.excludeSelf;
4148
4149 if (formationType == 1) // Leader only
4150 {
4151 if (Creature* leader = group->GetLeader())
4152 {
4153 if ((!excludeSelf || leader != me) && (!entry || leader->GetEntry() == entry))
4154 targets.push_back(leader);
4155 }
4156 }
4157 else // 0 = Members only, 2 = All
4158 {
4159 for (auto const& itr : group->GetMembers())
4160 {
4161 Creature* member = itr.first;
4162
4163 if (!member)
4164 continue;
4165
4166 if (excludeSelf && member == me)
4167 continue;
4168
4169 if (entry && member->GetEntry() != entry)
4170 continue;
4171
4172 if (formationType == 0 && member == group->GetLeader())
4173 continue;
4174
4175 targets.push_back(member);
4176 }
4177 }
4178 }
4179 }
4180 break;
4181 }
4183 {
4184 WorldObject* ref = GetBaseObject();
4185
4186 if (!ref)
4187 {
4188 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_SHARED_OWNER_ENTITIES: Entry {} SourceType {} Event {} Action {} Target {} is missing base object.",
4189 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4190 break;
4191 }
4192
4193 ObjectGuid ownerGUID = GetSummonerOrOwnerGUID(ref);
4194 if (!ownerGUID)
4195 break;
4196
4197 bool const wantGameObject = e.target.sharedOwnerEntities.type == 2;
4198 uint32 const entry = e.target.sharedOwnerEntities.entry;
4199
4200 float const dist = e.target.sharedOwnerEntities.maxDist ? (float)e.target.sharedOwnerEntities.maxDist : ref->GetVisibilityRange();
4201
4202 ObjectVector units;
4203 GetWorldObjectsInDist(units, dist);
4204
4205 for (WorldObject* unit : units)
4206 {
4207 // an object is never a sibling of itself
4208 if (unit->GetGUID() == ref->GetGUID())
4209 continue;
4210
4211 if (wantGameObject ? !IsGameObject(unit) : !IsCreature(unit))
4212 continue;
4213
4214 if (entry && unit->GetEntry() != entry)
4215 continue;
4216
4217 if (GetSummonerOrOwnerGUID(unit) != ownerGUID)
4218 continue;
4219
4220 targets.push_back(unit);
4221 }
4222
4223 break;
4224 }
4225 case SMART_TARGET_NONE:
4227 default:
4228 break;
4229 }
4230}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:933
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition ScriptedCreature.cpp:938
Powers
Definition SharedDefines.h:256
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition SmartScriptMgr.h:1797
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1796
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1798
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1577
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1569
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1561
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1566
@ SMART_TARGET_FORMATION
Definition SmartScriptMgr.h:1592
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1576
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1570
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1579
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1563
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1560
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1567
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1590
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1565
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1559
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1571
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1564
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1573
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1587
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1589
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1557
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1558
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1554
@ SMART_TARGET_SHARED_OWNER_ENTITIES
Definition SmartScriptMgr.h:1593
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1572
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1591
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1578
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1574
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1575
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1568
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1562
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2043
Definition CreatureGroups.h:90
Definition Creature.h:47
CreatureGroup const * GetFormation() const
Definition Creature.h:372
Player * GetLootRecipient() const
Definition Creature.cpp:1293
Group * GetLootRecipientGroup() const
Definition Creature.cpp:1300
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Select nearest hostile unit within the given distance (regardless of threat list).
Definition Creature.cpp:2427
CreatureAI * AI() const
Definition Creature.h:144
Definition GameObject.h:120
ObjectGuid GetOwnerGUID() const
Definition GameObject.h:174
Definition GroupReference.h:27
Definition Group.h:177
Definition InstanceScript.h:143
Creature * GetCreature(uint32 type)
Definition InstanceScript.cpp:120
GameObject * GetGameObject(uint32 type)
Definition InstanceScript.cpp:125
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2414
Definition ObjectGuid.h:121
Player * ToPlayer()
Definition Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Unit * ToUnit()
Definition Object.h:210
Definition Player.h:1086
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5569
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5574
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5579
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5558
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4232
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5595
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5511
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:142
Unit * GetSummonerUnit() const
Definition TemporarySummon.cpp:44
Definition ThreatManager.h:267
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:112
bool IsVehicle() const
Definition Unit.h:801
Vehicle * GetVehicle() const
Definition Unit.h:1926
TempSummon * ToTempSummon()
Definition Unit.h:732
Unit * GetCharmerOrOwner() const
Definition Unit.h:1287
bool IsSummon() const
Definition Unit.h:795
Unit * GetVictim() const
Definition Unit.h:904
Vehicle * GetVehicleKit() const
Definition Unit.h:1925
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1296
Unit * GetBase() const
May be called from scripts.
Definition Vehicle.h:37
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:239
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1242
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2580
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1464
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:223
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition ObjectAccessor.cpp:258
Definition UnitAI.h:135
Definition UnitAI.h:170

References _summonList, Creature::AI(), SmartTarget::aura, SmartTarget::closestAttackable, SmartTarget::closestFriendly, SmartTarget::creature, SmartTarget::dbGuid, SmartTarget::dead, SmartTarget::dist, SmartTarget::distMax, SmartTarget::distMin, DoFindClosestFriendlyInRange(), SmartTarget::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, SmartTarget::excludeSelf, SmartTarget::farthest, FindCreatureNear(), FindGameObjectNear(), SmartTarget::formation, SmartScriptHolder::GetActionType(), Vehicle::GetBase(), GetBaseObject(), Unit::GetCharmerOrOwner(), Unit::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), InstanceScript::GetCreature(), ObjectAccessor::GetCreatureOrPetOrVehicle(), Object::GetEntry(), Creature::GetFormation(), InstanceScript::GetGameObject(), Object::GetGUID(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), Creature::GetLootRecipientGroup(), WorldObject::GetMap(), GameObject::GetOwnerGUID(), Vehicle::GetPassenger(), SmartScriptHolder::GetScriptType(), GetStoredTargetVector(), TempSummon::GetSummonerUnit(), SmartScriptHolder::GetTargetType(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), ThreatManager::GetUnsortedThreatList(), Unit::GetVehicle(), Unit::GetVehicleKit(), Unit::GetVictim(), WorldObject::GetVisibilityRange(), ObjectAccessor::GetWorldObject(), GetWorldObjectsInDist(), go, SmartTarget::goClosest, SmartTarget::goDistance, SmartTarget::goGUID, SmartTarget::goRange, SmartTarget::hostileRandom, SmartTarget::id, SmartTarget::includePets, SmartTarget::index, SmartTarget::instanceStorage, SmartTarget::invokerParty, SmartScriptHolder::IsAreatriggerScript(), IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, MaxThreat, me, SmartTarget::minDist, MinDistance, MinThreat, SmartTarget::negation, SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, Random, Acore::Containers::RandomResize(), SmartTarget::resize, SmartTarget::roleMask, SmartTarget::roleSelection, SmartTarget::seatMask, WorldObject::SelectNearestPlayer(), Creature::SelectNearestTarget(), UnitAI::SelectTarget(), SmartTarget::sharedOwnerEntities, SMART_TARGET_ACTION_INVOKER, SMART_TARGET_ACTION_INVOKER_VEHICLE, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_ENEMY, SMART_TARGET_CLOSEST_FRIENDLY, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_FARTHEST, SMART_TARGET_FORMATION, SMART_TARGET_GAMEOBJECT_DISTANCE, SMART_TARGET_GAMEOBJECT_GUID, SMART_TARGET_GAMEOBJECT_RANGE, SMART_TARGET_HOSTILE_LAST_AGGRO, SMART_TARGET_HOSTILE_RANDOM, SMART_TARGET_HOSTILE_RANDOM_NOT_TOP, SMART_TARGET_HOSTILE_SECOND_AGGRO, SMART_TARGET_INSTANCE_STORAGE, SMART_TARGET_INVOKER_PARTY, SMART_TARGET_LOOT_RECIPIENTS, SMART_TARGET_NONE, SMART_TARGET_OWNER_OR_SUMMONER, SMART_TARGET_PLAYER_DISTANCE, SMART_TARGET_PLAYER_RANGE, SMART_TARGET_PLAYER_WITH_AURA, SMART_TARGET_POSITION, SMART_TARGET_ROLE_FLAG_DAMAGERS, SMART_TARGET_ROLE_FLAG_HEALERS, SMART_TARGET_ROLE_FLAG_TANKS, SMART_TARGET_ROLE_SELECTION, SMART_TARGET_SELF, SMART_TARGET_SHARED_OWNER_ENTITIES, 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
4233{
4234 WorldObject* obj = GetBaseObject();
4235 if (!obj)
4236 return;
4237
4238 Acore::AllWorldObjectsInRange u_check(obj, dist);
4240 Cell::VisitObjects(obj, searcher, dist);
4241}
Definition GridNotifiers.h:1648
Definition GridNotifiers.h:262

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

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

◆ IncPhase()

void SmartScript::IncPhase ( uint32  p)
private
5601{
5602 // protect phase from overflowing
5603 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5604}
@ SMART_EVENT_PHASE_12
Definition SmartScriptMgr.h:57

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
5043{
5044 switch (e.GetEventType())
5045 {
5046 //set only events which have initial timers
5050 break;
5051 case SMART_EVENT_UPDATE:
5054 case SMART_EVENT_RANGE:
5061 break;
5065 break;
5069 break;
5070 default:
5071 e.active = true;
5072 break;
5073 }
5074}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition SmartScriptMgr.h:173
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition SmartScriptMgr.h:191
@ SMART_EVENT_AREA_CASTING
Definition SmartScriptMgr.h:194
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition SmartScriptMgr.h:175
@ SMART_EVENT_RANGE
Definition SmartScriptMgr.h:108
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition SmartScriptMgr.h:193
@ SMART_EVENT_UPDATE_IC
Definition SmartScriptMgr.h:99
@ SMART_EVENT_IS_IN_MELEE_RANGE
Definition SmartScriptMgr.h:199
@ SMART_EVENT_AREA_RANGE
Definition SmartScriptMgr.h:195
@ SMART_EVENT_UPDATE
Definition SmartScriptMgr.h:159
@ SMART_EVENT_IS_BEHIND_TARGET
Definition SmartScriptMgr.h:166
@ SMART_EVENT_UPDATE_OOC
Definition SmartScriptMgr.h:100
@ SMART_EVENT_NEAR_UNIT
Definition SmartScriptMgr.h:192
@ SMART_EVENT_DISTANCE_CREATURE
Definition SmartScriptMgr.h:174
@ SMART_EVENT_NEAR_PLAYERS
Definition SmartScriptMgr.h:190
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition SmartScript.cpp:5075
struct SmartEvent::@30::@68 nearPlayer
struct SmartEvent::@30::@32 minMaxRepeat
struct SmartEvent::@30::@70 nearUnit
uint32 repeat
Definition SmartScriptMgr.h:449
uint32 min
Definition SmartScriptMgr.h:214
uint32 firstTimer
Definition SmartScriptMgr.h:464
uint32 max
Definition SmartScriptMgr.h:215
uint32 timer
Definition SmartScriptMgr.h:484
struct SmartEvent::@30::@66 distance
bool active
Definition SmartScriptMgr.h:2030
uint32 GetEventType() const
Definition SmartScriptMgr.h:2022

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

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

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private
5194{
5195 if (!mInstallEvents.empty())
5196 {
5197 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
5198 mEvents.push_back(*i);//must be before UpdateTimers
5199
5200 mInstallEvents.clear();
5201 }
5202}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3455{
3456 if (!GetBaseObject())
3457 return;
3459 {
3460 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3461 return;
3462 }
3463 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3464 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3465 {
3467 {
3468 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);
3469 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);
3470 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);
3471 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);
3472 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);
3473 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);
3474 break;
3475 }
3477 {
3478 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);
3479 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);
3480 break;
3481 }
3483 {
3484 if (!me)
3485 return;
3486 //store cage as id1
3487 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);
3488
3489 //reset(close) cage on hostage(me) respawn
3490 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);
3491
3492 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);
3493 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);
3494
3495 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);
3496 //phase 1: give quest credit on movepoint reached
3498 //phase 1: despawn after time on movepoint reached
3499 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);
3500
3501 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3502 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);
3503 break;
3504 }
3506 {
3507 if (!go)
3508 return;
3509 //store hostage as id1
3510 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);
3511 //store invoker as id2
3512 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);
3513 //signal hostage
3514 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);
3515 //when hostage raeched end point, give credit to invoker
3516 if (e.action.installTtemplate.param2)
3517 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);
3518 else
3519 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);
3520 break;
3521 }
3523 default:
3524 return;
3525 }
3526}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:123
std::uint8_t uint8
Definition Define.h:109
@ POINT_MOTION_TYPE
Definition MotionMaster.h:48
SMARTAI_TEMPLATE
Definition SmartScriptMgr.h:1538
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1543
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1544
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1540
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1541
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1961
@ SMART_ACTION_STORE_TARGET_LIST
Definition SmartScriptMgr.h:606
@ SMART_ACTION_FORCE_DESPAWN
Definition SmartScriptMgr.h:583
@ SMART_ACTION_CAST
Definition SmartScriptMgr.h:553
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition SmartScriptMgr.h:563
@ SMART_ACTION_MOVE_FORWARD
Definition SmartScriptMgr.h:588
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition SmartScriptMgr.h:575
@ SMART_ACTION_TALK
Definition SmartScriptMgr.h:543
@ SMART_ACTION_SET_DATA
Definition SmartScriptMgr.h:587
@ SMART_ACTION_SET_RUN
Definition SmartScriptMgr.h:601
@ SMART_ACTION_SET_EVENT_PHASE
Definition SmartScriptMgr.h:564
@ SMART_ACTION_RESET_GOBJECT
Definition SmartScriptMgr.h:574
@ SMART_EVENT_DATA_SET
Definition SmartScriptMgr.h:137
@ SMART_EVENT_JUST_CREATED
Definition SmartScriptMgr.h:162
@ SMART_EVENT_MOVEMENTINFORM
Definition SmartScriptMgr.h:133
@ SMART_EVENT_MANA_PCT
Definition SmartScriptMgr.h:102
@ SMART_EVENT_GO_STATE_CHANGED
Definition SmartScriptMgr.h:169
@ SMART_RANDOM_POINT
Definition SmartScriptMgr.h:39
void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, uint32 event_param6, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 target_param4, uint32 phaseMask)
Definition SmartScript.cpp:3528

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
5585{
5586 if (!obj)
5587 return false;
5588
5589 if (Creature* creatureObj = obj->ToCreature())
5590 return creatureObj->IsCharmed();
5591
5592 return false;
5593}
Creature * ToCreature()
Definition Object.h:206

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5580{
5581 return obj && obj->IsCreature();
5582}
bool IsCreature() const
Definition Object.h:205

References Object::IsCreature().

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5596{
5597 return obj && obj->IsGameObject();
5598}
bool IsGameObject() const
Definition Object.h:213

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5631{
5632 if (mEventPhase == 0)
5633 {
5634 return false;
5635 }
5636
5637 return ((1 << (mEventPhase - 1)) & p) != 0;
5638}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5575{
5576 return obj && obj->IsPlayer();
5577}
bool IsPlayer() const
Definition Object.h:201

References Object::IsPlayer().

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

◆ IsSmart() [1/3]

bool SmartScript::IsSmart ( bool  silent = false) const
122{
123 if (me)
124 return IsSmart(me, silent);
125 if (go)
126 return IsSmart(go, silent);
127
128 return false;
129}
bool IsSmart(Creature *c, bool silent=false) const
Definition SmartScript.cpp:91

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

bool SmartScript::IsSmart ( Creature c,
bool  silent = false 
) const
92{
93 if (!c)
94 return false;
95
96 bool smart = true;
97 if (!dynamic_cast<SmartAI*>(c->AI()))
98 smart = false;
99
100 if (!smart && !silent)
101 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));
102
103 return smart;
104}
Definition SmartAI.h:46

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

Referenced by IsSmart(), and ProcessAction().

◆ IsSmart() [3/3]

bool SmartScript::IsSmart ( GameObject g,
bool  silent = false 
) const
107{
108 if (!g)
109 return false;
110
111 bool smart = true;
112 if (!dynamic_cast<SmartGameObjectAI*>(g->AI()))
113 smart = false;
114
115 if (!smart && !silent)
116 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));
117
118 return smart;
119}
GameObjectAI * AI() const
Definition GameObject.h:307
Definition SmartAI.h:289

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5570{
5571 return obj && (obj->IsCreature() || obj->IsPlayer());
5572}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5369{
5370 if (obj)//handle object based scripts
5371 {
5372 switch (obj->GetTypeId())
5373 {
5374 case TYPEID_UNIT:
5376 me = obj->ToCreature();
5377 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5378 break;
5379 case TYPEID_GAMEOBJECT:
5381 go = obj->ToGameObject();
5382 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5383 break;
5384 default:
5385 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5386 return;
5387 }
5388 }
5389 else if (at)
5390 {
5392 trigger = at;
5393 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5394 }
5395 else
5396 {
5397 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5398 return;
5399 }
5400
5401 GetScript();//load copy of script
5402
5403 for (SmartScriptHolder& event : mEvents)
5404 InitTimer(event);//calculate timers for first time use
5405
5407 InstallEvents();
5409}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:40
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1804
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1805
@ SMART_EVENT_AI_INIT
Definition SmartScriptMgr.h:136
TypeID GetTypeId() const
Definition Object.h:129
GameObject * ToGameObject()
Definition Object.h:214
void ProcessEventsFor(SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:157
void InstallEvents()
Definition SmartScript.cpp:5193
void GetScript()
Definition SmartScript.cpp:5334

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)
5412{
5413 if (!me)
5414 return;
5415
5417}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:125
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:109
bool IsEngaged() const override
Definition Creature.cpp:2939

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

void SmartScript::OnReset ( )
132{
133 // xinef: check if we allow phase reset
134 if (AllowPhaseReset())
135 SetPhase(0);
136
138 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
139 {
140 if (!((*i).event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
141 {
142 InitTimer((*i));
143 (*i).runOnce = false;
144 }
145
146 if ((*i).priority != SmartScriptHolder::DEFAULT_PRIORITY)
147 {
150 }
151 }
154 mCounterList.clear();
155}
@ SMART_EVENT_FLAG_DONT_RESET
Definition SmartScriptMgr.h:1969
@ SMART_EVENT_RESET
Definition SmartScriptMgr.h:124
void Clear()
Definition ObjectGuid.h:141
bool AllowPhaseReset() const
Definition SmartScript.h:204
void ResetBaseObject()
Definition SmartScript.h:166
static constexpr uint32 DEFAULT_PRIORITY
Definition SmartScriptMgr.h:2040

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

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

◆ OnUpdate()

void SmartScript::OnUpdate ( const uint32  diff)
5205{
5207 return;
5208
5209 InstallEvents();//before UpdateTimers
5210
5212 {
5214 mEventSortingRequired = false;
5215 }
5216
5217 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
5218 UpdateTimer(*i, diff);
5219
5220 if (!mStoredEvents.empty())
5221 {
5222 SmartAIEventStoredList::iterator i, icurr;
5223 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
5224 {
5225 icurr = i++;
5226 UpdateTimer(*icurr, diff);
5227 }
5228 }
5229
5230 bool needCleanup = true;
5231 if (!mTimedActionList.empty())
5232 {
5234 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5235 {
5236 if ((*i).enableTimed)
5237 {
5238 UpdateTimer(*i, diff);
5239 needCleanup = false;
5240 }
5241 }
5242
5244 }
5245 if (needCleanup)
5246 mTimedActionList.clear();
5247
5248 if (!mRemIDs.empty())
5249 {
5250 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5252
5253 // xinef: clear list after cleaning...
5254 mRemIDs.clear();
5255 }
5256 if (mUseTextTimer && me)
5257 {
5258 if (mTextTimer < diff)
5259 {
5260 uint32 textID = mLastTextID;
5261 mLastTextID = 0;
5262 uint32 entry = mTalkerEntry;
5263 mTalkerEntry = 0;
5264 mTextTimer = 0;
5265 mUseTextTimer = false;
5266 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5267 }
5268 else mTextTimer -= diff;
5269 }
5270}
@ SMART_EVENT_TEXT_OVER
Definition SmartScriptMgr.h:151
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition SmartScript.cpp:5082
void SortEvents(SmartAIEventList &events)
Definition SmartScript.cpp:5272
SmartAIEventStoredList mStoredEvents
Definition SmartScript.h:236
std::list< uint32 > mRemIDs
Definition SmartScript.h:237
SmartAIEventList mTimedActionList
Definition SmartScript.h:224
void RemoveStoredEvent(uint32 id)
Definition SmartScript.h:254

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

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

◆ ProcessAction()

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

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

Referenced by ProcessEvent(), and ProcessTimedAction().

◆ ProcessEvent()

void SmartScript::ProcessEvent ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
4244{
4245 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4246 return;
4247
4249 return;
4250
4252 return;
4253
4254 switch (e.GetEventType())
4255 {
4256 case SMART_EVENT_LINK://special handling
4257 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4258 break;
4259 //called from Update tick
4260 case SMART_EVENT_UPDATE:
4262 break;
4264 if (me && me->IsEngaged())
4265 return;
4267 break;
4269 if (!me || !me->IsEngaged())
4270 return;
4272 break;
4274 {
4275 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4276 return;
4277 uint32 perc = (uint32)me->GetHealthPct();
4278 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4279 return;
4281 break;
4282 }
4284 {
4285 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4286 return;
4287 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4288 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4289 return;
4291 break;
4292 }
4294 {
4295 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4296 return;
4298 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4299 return;
4301 break;
4302 }
4304 {
4305 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4306 return;
4308 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4309 return;
4311 break;
4312 }
4313 case SMART_EVENT_RANGE:
4314 {
4315 if (!me || !me->IsEngaged() || !me->GetVictim())
4316 return;
4317
4320 else
4321 RecalcTimer(e, 1200, 1200); // make it predictable
4322
4323 break;
4324 }
4326 {
4327 if (!me || !me->IsEngaged())
4328 return;
4329
4330 Unit* victim = me->GetVictim();
4331
4332 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4333 return;
4334
4335 if (e.event.targetCasting.spellId > 0)
4336 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4337 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4338 return;
4339
4341 break;
4342 }
4344 {
4345 if (!me || !me->IsEngaged())
4346 return;
4347
4349 if (!target || !target->IsInCombat())
4350 {
4351 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4352 RecalcTimer(e, 1000, 3000);
4353 return;
4354 }
4356 break;
4357 }
4359 {
4360 if (!me || !me->IsEngaged())
4361 return;
4362
4363 std::vector<Creature*> creatures;
4365 if (creatures.empty())
4366 {
4367 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4368 RecalcTimer(e, 1000, 3000);
4369 return;
4370 }
4372 break;
4373 }
4375 {
4377 {
4378 return;
4379 }
4380
4381 std::vector<Creature*> creatures;
4383
4384 if (creatures.empty())
4385 return;
4386
4388 break;
4389 }
4391 {
4392 if (!me)
4393 return;
4394 uint32 count = me->GetAuraCount(e.event.aura.spell);
4395 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4397 break;
4398 }
4400 {
4401 if (!me || !me->GetVictim())
4402 return;
4404 if (count < e.event.aura.count)
4405 return;
4407 break;
4408 }
4410 {
4411 if (bvar == (e.event.charm.onRemove != 1))
4412 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4413 break;
4414 }
4415 //no params
4416 case SMART_EVENT_AGGRO:
4417 case SMART_EVENT_DEATH:
4418 case SMART_EVENT_EVADE:
4431 case SMART_EVENT_RESET:
4435 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4436 break;
4437
4439 switch (e.event.gossipHello.filter)
4440 {
4441 case 0:
4442 // no filter set, always execute action
4443 break;
4444 case 1:
4445 // GossipHello only filter set, skip action if reportUse
4446 if (var0)
4447 {
4448 return;
4449 }
4450 break;
4451 case 2:
4452 // reportUse only filter set, skip action if GossipHello
4453 if (!var0)
4454 {
4455 return;
4456 }
4457 break;
4458 default:
4459 // Ignore any other value
4460 break;
4461 }
4462
4463 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4464 break;
4466 {
4467 if (!me)
4468 return;
4469
4470 if (Unit* victim = me->GetVictim())
4471 {
4473 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4475 }
4476
4477 break;
4478 }
4480 {
4481 if (!me)
4482 return;
4483
4484 if (Unit* victim = me->GetVictim())
4485 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4486 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4488
4489 break;
4490 }
4492 if (e.event.emote.emote == var0)
4493 {
4494 ProcessAction(e, unit);
4495 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4496 }
4497 break;
4498 case SMART_EVENT_KILL:
4499 {
4500 if (!me || !unit)
4501 return;
4502 if (e.event.kill.playerOnly && !unit->IsPlayer())
4503 return;
4504 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4505 return;
4507 ProcessAction(e, unit);
4508 break;
4509 }
4512 {
4513 if (!spell)
4514 return;
4515 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4516 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4517 {
4519 ProcessAction(e, unit, 0, 0, bvar, spell);
4520 }
4521 break;
4522 }
4524 {
4525 if (!me || me->IsEngaged())
4526 return;
4527 //can trigger if closer than fMaxAllowedRange
4528 float range = (float)e.event.los.maxDist;
4529
4530 //if range is ok and we are actually in LOS
4531 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4532 {
4534 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4535 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4536 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4537 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4538 {
4539 if (e.event.los.playerOnly && !unit->IsPlayer())
4540 return;
4542 ProcessAction(e, unit);
4543 }
4544 }
4545 break;
4546 }
4547 case SMART_EVENT_IC_LOS:
4548 {
4549 if (!me || !me->IsEngaged())
4550 return;
4551 //can trigger if closer than fMaxAllowedRange
4552 float range = (float)e.event.los.maxDist;
4553
4554 //if range is ok and we are actually in LOS
4555 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4556 {
4558 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4559 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4560 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4561 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4562 {
4563 if (e.event.los.playerOnly && !unit->IsPlayer())
4564 return;
4566 ProcessAction(e, unit);
4567 }
4568 }
4569 break;
4570 }
4572 {
4573 if (!GetBaseObject())
4574 return;
4576 return;
4578 return;
4579 ProcessAction(e);
4580 break;
4581 }
4585 {
4586 if (!IsCreature(unit))
4587 return;
4588 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4589 return;
4591 ProcessAction(e, unit);
4592 break;
4593 }
4596 {
4597 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4598 return;
4600 ProcessAction(e, unit);
4601 break;
4602 }
4604 {
4605 if (e.event.minMaxRepeat.rangeMin) // health check mode
4606 {
4607 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4608 return;
4610 return;
4611 ProcessAction(e, unit);
4612 }
4613 else
4614 {
4615 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4616 return;
4618 ProcessAction(e, unit);
4619 }
4620 break;
4621 }
4623 {
4624 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4625 return;
4627 return;
4628 ProcessAction(e, unit, var0, var1);
4629 break;
4630 }
4633 {
4634 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4635 return;
4636 ProcessAction(e, unit, var0);
4637 break;
4638 }
4644 {
4645 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4646 return;
4647 ProcessAction(e, unit);
4648 break;
4649 }
4651 {
4652 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4653 return;
4655 ProcessAction(e, unit, var0);
4656 break;
4657 }
4659 {
4661 return;
4663 ProcessAction(e, unit, var0);
4664 break;
4665 }
4668 {
4669 if (e.event.quest.quest && var0 != e.event.quest.quest)
4670 return;
4671 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4672 ProcessAction(e, unit, var0);
4673 break;
4674 }
4676 {
4678 return;
4679 ProcessAction(e, unit, var0);
4680 break;
4681 }
4683 {
4684 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4685 return;
4686 ProcessAction(e, unit, var0);
4687 break;
4688 }
4690 {
4692 return;
4693 ProcessAction(e, unit, var0);
4694 break;
4695 }
4697 {
4698 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4699 return;
4701 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4702 break;
4703 }
4706 {
4707 if (!unit)
4708 return;
4710 ProcessAction(e, unit);
4711 break;
4712 }
4714 {
4715 if (e.event.timedEvent.id == var0)
4716 ProcessAction(e, unit);
4717 break;
4718 }
4720 {
4721 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4722 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4723 return;
4724 ProcessAction(e, unit, var0, var1);
4725 break;
4726 }
4728 {
4730 return;
4731
4732 ProcessAction(e);
4733 break;
4734 }
4737 {
4738 if (e.event.gameEvent.gameEventId != var0)
4739 return;
4740 ProcessAction(e, nullptr, var0);
4741 break;
4742 }
4744 {
4745 if (e.event.goStateChanged.state != var0)
4746 return;
4747 ProcessAction(e, unit, var0, var1);
4748 break;
4749 }
4751 {
4752 if (e.event.eventInform.eventId != var0)
4753 return;
4754 ProcessAction(e, nullptr, var0);
4755 break;
4756 }
4758 {
4759 if (e.event.doAction.eventId != var0)
4760 return;
4762 ProcessAction(e, unit, var0);
4763 break;
4764 }
4766 {
4767 if (!me || !me->IsEngaged())
4768 return;
4769
4770 Unit* unitTarget = nullptr;
4771 switch (e.GetTargetType())
4772 {
4780 {
4781 ObjectVector targets;
4782 GetTargets(targets, e);
4783 for (WorldObject* target : targets)
4784 {
4785 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4786 {
4787 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4788 if (healthPct > e.event.friendlyHealthPct.hpPct)
4789 {
4790 continue;
4791 }
4792
4793 unitTarget = target->ToUnit();
4794 break;
4795 }
4796 }
4797
4798 break;
4799 }
4800 case SMART_TARGET_SELF:
4803 break;
4804 default:
4805 return;
4806 }
4807
4808 if (!unitTarget)
4809 return;
4810
4812 break;
4813 }
4815 {
4816 if (!me)
4817 return;
4818
4819 WorldObject* creature = nullptr;
4820
4821 if (e.event.distance.guid != 0)
4822 {
4823 creature = FindCreatureNear(me, e.event.distance.guid);
4824
4825 if (!creature)
4826 return;
4827
4828 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4829 return;
4830 }
4831 else if (e.event.distance.entry != 0)
4832 {
4833 std::list<Creature*> list;
4835
4836 if (!list.empty())
4837 creature = list.front();
4838 }
4839
4840 if (creature)
4842
4843 break;
4844 }
4846 {
4847 if (!me)
4848 return;
4849
4850 WorldObject* gameobject = nullptr;
4851
4852 if (e.event.distance.guid != 0)
4853 {
4854 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4855
4856 if (!gameobject)
4857 return;
4858
4859 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4860 return;
4861 }
4862 else if (e.event.distance.entry != 0)
4863 {
4864 std::list<GameObject*> list;
4866
4867 if (!list.empty())
4868 gameobject = list.front();
4869 }
4870
4871 if (gameobject)
4873
4874 break;
4875 }
4877 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4878 return;
4879
4881 break;
4883 {
4884 uint32 playerCount = 0;
4885 ObjectVector targets;
4886 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4887
4888 if (!targets.empty())
4889 {
4890 for (WorldObject* target : targets)
4891 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4892 playerCount++;
4893
4894 if (playerCount >= e.event.nearPlayer.minCount)
4895 ProcessAction(e, unit);
4896 }
4898 break;
4899 }
4901 {
4902 uint32 playerCount = 0;
4903 ObjectVector targets;
4904 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4905
4906 if (!targets.empty())
4907 {
4908 for (WorldObject* target : targets)
4909 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4910 playerCount++;
4911
4912 if (playerCount < e.event.nearPlayerNegation.maxCount)
4913 ProcessAction(e, unit);
4914 }
4916 break;
4917 }
4919 {
4920 uint32 unitCount = 0;
4921 ObjectVector targets;
4922 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4923
4924 if (!targets.empty())
4925 {
4926 if (e.event.nearUnit.type)
4927 {
4928 for (WorldObject* target : targets)
4929 {
4930 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4931 unitCount++;
4932 }
4933 }
4934 else
4935 {
4936 for (WorldObject* target : targets)
4937 {
4938 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4939 unitCount++;
4940 }
4941 }
4942
4943 if (unitCount >= e.event.nearUnit.count)
4944 ProcessAction(e, unit);
4945 }
4947 break;
4948 }
4950 {
4951 uint32 unitCount = 0;
4952 ObjectVector targets;
4953 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4954
4955 if (!targets.empty())
4956 {
4958 {
4959 for (WorldObject* target : targets)
4960 {
4961 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4962 unitCount++;
4963 }
4964 }
4965 else
4966 {
4967 for (WorldObject* target : targets)
4968 {
4969 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4970 unitCount++;
4971 }
4972 }
4973
4974 if (unitCount < e.event.nearUnitNegation.count)
4975 ProcessAction(e, unit);
4976 }
4978 break;
4979 }
4981 {
4982 if (!me || !me->IsEngaged())
4983 return;
4984
4985 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4986 {
4987 if (Unit* target = ref->GetVictim())
4988 {
4989 if (!IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4990 continue;
4991
4992 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4993 continue;
4994
4995 ProcessAction(e, target);
4997 return;
4998 }
4999 }
5000
5001 // No targets found
5003
5004 break;
5005 }
5007 {
5008 if (!me || !me->IsEngaged())
5009 return;
5010
5011 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
5012 {
5013 if (Unit* target = ref->GetVictim())
5014 {
5015 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
5016 continue;
5017
5018 ProcessAction(e, target);
5020 return;
5021 }
5022 }
5023
5024 // If no targets are found and it's off cooldown, check again
5025 RecalcTimer(e, 1200, 1200);
5026 break;
5027 }
5030 {
5031 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
5032 return;
5033 ProcessAction(e, unit);
5034 break;
5035 }
5036 default:
5037 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
5038 break;
5039 }
5040}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1970
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition SmartScriptMgr.h:536
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition SmartScriptMgr.h:535
@ SMART_EVENT_EVADE
Definition SmartScriptMgr.h:106
@ SMART_EVENT_ACTION_DONE
Definition SmartScriptMgr.h:171
@ SMART_EVENT_SUMMON_DESPAWNED
Definition SmartScriptMgr.h:134
@ SMART_EVENT_SPELLHIT
Definition SmartScriptMgr.h:107
@ SMART_EVENT_RECEIVE_EMOTE
Definition SmartScriptMgr.h:121
@ SMART_EVENT_QUEST_FAIL
Definition SmartScriptMgr.h:150
@ SMART_EVENT_RECEIVE_HEAL
Definition SmartScriptMgr.h:152
@ SMART_EVENT_CHARMED_TARGET
Definition SmartScriptMgr.h:129
@ SMART_EVENT_TARGET_MANA_PCT
Definition SmartScriptMgr.h:117
@ SMART_EVENT_QUEST_COMPLETION
Definition SmartScriptMgr.h:148
@ SMART_EVENT_HEALTH_PCT
Definition SmartScriptMgr.h:101
@ SMART_EVENT_ESCORT_START
Definition SmartScriptMgr.h:138
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition SmartScriptMgr.h:165
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition SmartScriptMgr.h:145
@ SMART_EVENT_ON_SPELLCLICK
Definition SmartScriptMgr.h:172
@ SMART_EVENT_ESCORT_PAUSED
Definition SmartScriptMgr.h:154
@ SMART_EVENT_ESCORT_RESUMED
Definition SmartScriptMgr.h:155
@ SMART_EVENT_PASSENGER_REMOVED
Definition SmartScriptMgr.h:127
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition SmartScriptMgr.h:144
@ SMART_EVENT_ESCORT_ENDED
Definition SmartScriptMgr.h:157
@ SMART_EVENT_REACHED_HOME
Definition SmartScriptMgr.h:120
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition SmartScriptMgr.h:141
@ SMART_EVENT_REWARD_QUEST
Definition SmartScriptMgr.h:119
@ SMART_EVENT_GO_EVENT_INFORM
Definition SmartScriptMgr.h:170
@ SMART_EVENT_JUST_SUMMONED
Definition SmartScriptMgr.h:153
@ SMART_EVENT_CHARMED
Definition SmartScriptMgr.h:128
@ SMART_EVENT_SPELLHIT_TARGET
Definition SmartScriptMgr.h:130
@ SMART_EVENT_GAME_EVENT_START
Definition SmartScriptMgr.h:167
@ SMART_EVENT_KILL
Definition SmartScriptMgr.h:104
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition SmartScriptMgr.h:142
@ SMART_EVENT_ESCORT_STOPPED
Definition SmartScriptMgr.h:156
@ SMART_EVENT_GOSSIP_HELLO
Definition SmartScriptMgr.h:163
@ SMART_EVENT_GOSSIP_SELECT
Definition SmartScriptMgr.h:161
@ SMART_EVENT_CORPSE_REMOVED
Definition SmartScriptMgr.h:135
@ SMART_EVENT_SUMMONED_UNIT_EVADE
Definition SmartScriptMgr.h:196
@ SMART_EVENT_PASSENGER_BOARDED
Definition SmartScriptMgr.h:126
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition SmartScriptMgr.h:140
@ SMART_EVENT_WAYPOINT_ENDED
Definition SmartScriptMgr.h:198
@ SMART_EVENT_ACCEPTED_QUEST
Definition SmartScriptMgr.h:118
@ SMART_EVENT_COUNTER_SET
Definition SmartScriptMgr.h:176
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition SmartScriptMgr.h:115
@ SMART_EVENT_WAYPOINT_REACHED
Definition SmartScriptMgr.h:197
@ SMART_EVENT_TARGET_BUFFED
Definition SmartScriptMgr.h:123
@ SMART_EVENT_RESPAWN
Definition SmartScriptMgr.h:110
@ SMART_EVENT_QUEST_ACCEPTED
Definition SmartScriptMgr.h:146
@ SMART_EVENT_FRIENDLY_HEALTH
Definition SmartScriptMgr.h:113
@ SMART_EVENT_QUEST_REWARDED
Definition SmartScriptMgr.h:149
@ SMART_EVENT_DEATH
Definition SmartScriptMgr.h:105
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition SmartScriptMgr.h:143
@ SMART_EVENT_GAME_EVENT_END
Definition SmartScriptMgr.h:168
@ SMART_EVENT_DAMAGED
Definition SmartScriptMgr.h:131
@ SMART_EVENT_FOLLOW_COMPLETED
Definition SmartScriptMgr.h:164
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition SmartScriptMgr.h:147
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition SmartScriptMgr.h:183
@ SMART_EVENT_FRIENDLY_IS_CC
Definition SmartScriptMgr.h:114
@ SMART_EVENT_AGGRO
Definition SmartScriptMgr.h:103
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition SmartScriptMgr.h:111
@ SMART_EVENT_VICTIM_CASTING
Definition SmartScriptMgr.h:112
@ SMART_EVENT_DAMAGED_TARGET
Definition SmartScriptMgr.h:132
@ SMART_EVENT_HAS_AURA
Definition SmartScriptMgr.h:122
@ SMART_EVENT_SUMMONED_UNIT
Definition SmartScriptMgr.h:116
@ CURRENT_GENERIC_SPELL
Definition Unit.h:557
uint32 GetWaypointPath() const
Definition Creature.h:357
uint32 GetCounterValue(uint32 id)
Definition SmartScript.h:134
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition SmartScript.cpp:5501
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5491
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:185
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5584
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5464
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5630
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5477
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:3439
Definition Spell.h:298
float GetHealthPct() const
Definition Unit.h:1111
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4282
uint32 GetMaxHealth() const
Definition Unit.h:1110
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:782
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5978
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1137
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7302
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:1118
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:7297
bool IsInCombat() const
Definition Unit.h:936
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1577
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2600
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2614
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1381
bool HasInArc(float arcangle, Position const *pos, float targetRadius=0.0f) const
Definition Position.cpp:148
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition SmartScriptMgr.h:253
uint32 pointId
Definition SmartScriptMgr.h:508
uint32 invert
Definition SmartScriptMgr.h:494
uint32 entry
Definition SmartScriptMgr.h:447
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition SmartScriptMgr.h:339
LOSHostilityMode
Definition SmartScriptMgr.h:524
uint32 cooldownMax
Definition SmartScriptMgr.h:225
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition SmartScriptMgr.h:353
uint32 radius
Definition SmartScriptMgr.h:273
uint32 maxDist
Definition SmartScriptMgr.h:244
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition SmartScriptMgr.h:397
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition SmartScriptMgr.h:233
uint32 rangeMin
Definition SmartScriptMgr.h:218
uint32 eventId
Definition SmartScriptMgr.h:424
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition SmartScriptMgr.h:446
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition SmartScriptMgr.h:448
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition SmartScriptMgr.h:267
uint32 emote
Definition SmartScriptMgr.h:310
struct SmartEvent::@30::@72 nearUnitNegation
uint32 hpPct
Definition SmartScriptMgr.h:440
uint32 filter
Definition SmartScriptMgr.h:392
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition SmartScriptMgr.h:243
uint32 hpDeficit
Definition SmartScriptMgr.h:272
struct SmartEvent::@30::@33 kill
struct SmartEvent::@30::@71 meleeRange
uint32 area
Definition SmartScriptMgr.h:254
uint32 count
Definition SmartScriptMgr.h:318
uint32 onlyInCombat
Definition SmartScriptMgr.h:291
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition SmartScriptMgr.h:346
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition SmartScriptMgr.h:354
SAIBool playerOnly
Definition SmartScriptMgr.h:226
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 pathId
Definition SmartScriptMgr.h:340
uint32 creatureEntry
Definition SmartScriptMgr.h:382
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition SmartScriptMgr.h:398
struct SmartEvent::@30::@64 doAction
struct SmartEvent::@30::@46 charm
struct SmartEvent::@30::@63 eventInform
struct SmartEvent::@30::@38 targetCasting
uint32 spell
Definition SmartScriptMgr.h:232
uint32 maxCount
Definition SmartScriptMgr.h:471
uint32 gameEventId
Definition SmartScriptMgr.h:414
uint32 textGroupID
Definition SmartScriptMgr.h:381
uint32 cooldownMin
Definition SmartScriptMgr.h:224
uint32 onRemove
Definition SmartScriptMgr.h:325
struct SmartEvent::@30::@73 wpData
uint32 quest
Definition SmartScriptMgr.h:303
struct SmartEvent::@30::@67 counter
uint32 state
Definition SmartScriptMgr.h:419
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition SmartScriptMgr.h:219
uint32 team
Definition SmartScriptMgr.h:369
uint32 range
Definition SmartScriptMgr.h:483
uint32 minCount
Definition SmartScriptMgr.h:462
struct SmartEvent::@30::@37 minMax
struct SmartEvent::@30::@55 textOver
struct SmartEvent::@30::@40 friendlyCC
struct SmartEvent::@30::@62 goStateChanged
uint32 creature
Definition SmartScriptMgr.h:227
uint32 phasemask
Definition SmartScriptMgr.h:409

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

Referenced by ProcessEventsFor(), and UpdateTimer().

◆ ProcessEventsFor()

void SmartScript::ProcessEventsFor ( SMART_EVENT  e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
158{
159 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
160 {
161 SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
162 if (eventType == SMART_EVENT_LINK)//special handling
163 continue;
164
165 if (eventType == e)
166 {
167 ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
168 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
169
170 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
171 {
172 ASSERT(executionStack.empty());
173 executionStack.emplace_back(SmartScriptFrame{ *i, unit, var0, var1, bvar, spell, gob });
174 while (!executionStack.empty())
175 {
176 auto [stack_holder , stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
177 executionStack.pop_back();
178 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
179 }
180 }
181 }
182 }
183}
#define sConditionMgr
Definition ConditionMgr.h:296
std::list< Condition * > ConditionList
Definition ConditionMgr.h:240
#define ASSERT
Definition Errors.h:68
void ProcessEvent(SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
Definition SmartScript.cpp:4243
Definition ConditionMgr.h:185

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

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

◆ ProcessTimedAction()

void SmartScript::ProcessTimedAction ( SmartScriptHolder e,
uint32 const &  min,
uint32 const &  max,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
3440{
3441 // xinef: extended by selfs victim
3442 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3443 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3444
3445 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3446 {
3447 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3448 RecalcTimer(e, min, max);
3449 }
3450 else
3451 RecalcTimer(e, 5000, 5000);
3452}

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
5278{
5279 e.timer = 1200;
5280 // Change priority only if it's set to default, otherwise keep the current order of events
5282 {
5284 mEventSortingRequired = true;
5285 }
5286}
uint32 timer
Definition SmartScriptMgr.h:2028
uint32 priority
Definition SmartScriptMgr.h:2029

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
5076{
5077 // min/max was checked at loading!
5078 e.timer = urand(uint32(min), uint32(max));
5079 e.active = e.timer ? false : true;
5080}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5646{
5647 _summonList.erase(guid);
5648}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

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

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

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

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

Referenced by OnReset(), and ProcessAction().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
5289{
5290 RaisePriority(e);
5291
5292 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5293 if (ignoreChanceRoll)
5295
5296 e.runOnce = false;
5297}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5277

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
5619{
5620 uint32 oldPhase = mEventPhase;
5621
5622 mEventPhase = p;
5623
5624 if (oldPhase != mEventPhase)
5625 {
5627 }
5628}

References mEventPhase, ProcessEventsFor(), and SMART_EVENT_EVENT_PHASE_CHANGE.

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

◆ SetPhaseReset()

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

References _allowPhaseReset.

Referenced by ProcessAction().

◆ SetScript9()

void SmartScript::SetScript9 ( SmartScriptHolder e,
uint32  entry 
)
5524{
5525 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5526 // any SmartScriptHolder contained like the "e" parameter passed to this function
5528 {
5529 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());
5530 return;
5531 }
5532
5533 // 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
5535 {
5536 return;
5537 }
5538
5539 mTimedActionList.clear();
5541 if (mTimedActionList.empty())
5542 return;
5543 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5544 {
5545 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5546
5547 if (e.action.timedActionList.timerType == 0)
5548 i->event.type = SMART_EVENT_UPDATE_OOC;
5549 else if (e.action.timedActionList.timerType == 1)
5550 i->event.type = SMART_EVENT_UPDATE_IC;
5551 else if (e.action.timedActionList.timerType > 1)
5552 i->event.type = SMART_EVENT_UPDATE;
5553
5554 InitTimer((*i));
5555 }
5556}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1812
SAIBool allowOverride
Definition SmartScriptMgr.h:1152
uint32 timerType
Definition SmartScriptMgr.h:1151

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

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

◆ SortEvents()

void SmartScript::SortEvents ( SmartAIEventList events)
private
5273{
5274 std::sort(events.begin(), events.end());
5275}
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:2046

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
5083{
5084 if (e.GetEventType() == SMART_EVENT_LINK)
5085 return;
5086
5088 return;
5089
5090 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
5091 return;
5092
5093 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
5094 return;
5095
5096 if (e.timer < diff)
5097 {
5098 // delay spell cast for another AI tick if another spell is being cast
5100 {
5102 {
5104 {
5105 RaisePriority(e);
5106 return;
5107 }
5108 }
5109 }
5110
5111 // Delay flee for assist event if casting
5113 {
5114 e.timer = 1200;
5115 return;
5116 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
5117
5118 e.active = true;//activate events with cooldown
5119 switch (e.GetEventType())//process ONLY timed events
5120 {
5125 case SMART_EVENT_UPDATE:
5132 case SMART_EVENT_RANGE:
5146 {
5147 ASSERT(executionStack.empty());
5148 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
5149 while (!executionStack.empty())
5150 {
5151 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
5152 executionStack.pop_back();
5153 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
5154 }
5156 {
5157 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
5158 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5159 {
5160 //find the first event which is not the current one and enable it
5161 if (i->event_id > e.event_id)
5162 {
5163 i->enableTimed = true;
5164 break;
5165 }
5166 }
5167 }
5168 break;
5169 }
5170 }
5171
5173 {
5174 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
5175 if (e.timer > 1)
5176 {
5177 // Re-sort events if this was moved to the top of the queue
5178 mEventSortingRequired = true;
5179 // Reset priority to default one
5181 }
5182 }
5183 }
5184 else
5185 e.timer -= diff;
5186}
bool IsActionPreventedByCasting() const
Definition Unit.cpp:4375
bool enableTimed
Definition SmartScriptMgr.h:2032

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::IsActionPreventedByCasting(), Creature::IsEngaged(), IsInPhase(), me, mEventSortingRequired, mTimedActionList, SmartScriptHolder::priority, ProcessEvent(), RaisePriority(), SMART_ACTION_CAST, SMART_ACTION_FLEE_FOR_ASSIST, SMART_EVENT_AREA_CASTING, SMART_EVENT_AREA_RANGE, SMART_EVENT_DISTANCE_CREATURE, SMART_EVENT_DISTANCE_GAMEOBJECT, SMART_EVENT_FRIENDLY_HEALTH, SMART_EVENT_FRIENDLY_HEALTH_PCT, SMART_EVENT_FRIENDLY_IS_CC, SMART_EVENT_FRIENDLY_MISSING_BUFF, SMART_EVENT_HAS_AURA, SMART_EVENT_HEALTH_PCT, SMART_EVENT_IS_BEHIND_TARGET, SMART_EVENT_IS_IN_MELEE_RANGE, SMART_EVENT_LINK, SMART_EVENT_MANA_PCT, SMART_EVENT_NEAR_PLAYERS, SMART_EVENT_NEAR_PLAYERS_NEGATION, SMART_EVENT_NEAR_UNIT, SMART_EVENT_NEAR_UNIT_NEGATION, SMART_EVENT_RANGE, SMART_EVENT_TARGET_BUFFED, SMART_EVENT_TARGET_HEALTH_PCT, SMART_EVENT_TARGET_MANA_PCT, SMART_EVENT_UPDATE, SMART_EVENT_UPDATE_IC, SMART_EVENT_UPDATE_OOC, SMART_EVENT_VICTIM_CASTING, SMART_SCRIPT_TYPE_TIMED_ACTIONLIST, SMARTCAST_INTERRUPT_PREVIOUS, and SmartScriptHolder::timer.

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ executionStack

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

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

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

◆ mCounterList

CounterMap SmartScript::mCounterList

◆ mCurrentPriority

uint32 SmartScript::mCurrentPriority
private

Referenced by RaisePriority(), and SmartScript().

◆ me

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

◆ mEvents

◆ mEventSortingRequired

bool SmartScript::mEventSortingRequired
private

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Referenced by AddEvent(), and InstallEvents().

◆ mLastInvoker

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

◆ mPathId

uint32 SmartScript::mPathId
private

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

◆ mRemIDs

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

Referenced by OnUpdate(), and ProcessAction().

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

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

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

◆ mTemplate

SMARTAI_TEMPLATE SmartScript::mTemplate
private

Referenced by InstallTemplate(), and SmartScript().

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

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

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

◆ trigger

AreaTrigger const* SmartScript::trigger
private

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