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 ( )
Todo:
: this import is not necessary for compilation and marked as unused by the IDE
48{
49 go = nullptr;
50 me = nullptr;
51 trigger = nullptr;
52 mEventPhase = 0;
53 mPathId = 0;
54 mTextTimer = 0;
55 mLastTextID = 0;
56 mUseTextTimer = false;
57 mTalkerEntry = 0;
63 _allowPhaseReset = true;
64}
@ SMART_SCRIPT_TYPE_CREATURE
Definition SmartScriptMgr.h:1793
@ SMARTAI_TEMPLATE_BASIC
Definition SmartScriptMgr.h:1538
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 ( )
67{
68}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5530{
5531 _summonList.insert(guid);
5532}
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 
)
3479{
3480 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));
3481}
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:3483

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
5078{
5079 return e.active;
5080}

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
3484{
3485 SmartScriptHolder script;
3486 script.event.type = e;
3487 script.event.raw.param1 = event_param1;
3488 script.event.raw.param2 = event_param2;
3489 script.event.raw.param3 = event_param3;
3490 script.event.raw.param4 = event_param4;
3491 script.event.raw.param5 = event_param5;
3492 script.event.raw.param6 = event_param6;
3493 script.event.event_phase_mask = phaseMask;
3494 script.event.event_flags = event_flags;
3495 script.event.event_chance = 100;
3496
3497 script.action.type = action;
3498 script.action.raw.param1 = action_param1;
3499 script.action.raw.param2 = action_param2;
3500 script.action.raw.param3 = action_param3;
3501 script.action.raw.param4 = action_param4;
3502 script.action.raw.param5 = action_param5;
3503 script.action.raw.param6 = action_param6;
3504
3505 script.target.type = t;
3506 script.target.raw.param1 = target_param1;
3507 script.target.raw.param2 = target_param2;
3508 script.target.raw.param3 = target_param3;
3509 script.target.raw.param4 = target_param4;
3510
3512 InitTimer(script);
3513 return script;
3514}
static void InitTimer(SmartScriptHolder &e)
Definition SmartScript.cpp:4931
uint32 param3
Definition SmartScriptMgr.h:1062
uint32 param5
Definition SmartScriptMgr.h:1064
uint32 param1
Definition SmartScriptMgr.h:1060
SMART_ACTION type
Definition SmartScriptMgr.h:746
struct SmartAction::@75::@195 raw
uint32 param4
Definition SmartScriptMgr.h:1063
uint32 param6
Definition SmartScriptMgr.h:1503
uint32 param2
Definition SmartScriptMgr.h:1061
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:1996
SmartAction action
Definition SmartScriptMgr.h:2007
SmartScriptType source_type
Definition SmartScriptMgr.h:2002
SmartEvent event
Definition SmartScriptMgr.h:2006
SmartTarget target
Definition SmartScriptMgr.h:2008
uint32 param4
Definition SmartScriptMgr.h:1761
uint32 param1
Definition SmartScriptMgr.h:1758
uint32 param3
Definition SmartScriptMgr.h:1760
struct SmartTarget::@201::@225 raw
SMARTAI_TARGETS type
Definition SmartScriptMgr.h:1610
uint32 param2
Definition SmartScriptMgr.h:1759

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
5496{
5497 if (p >= mEventPhase)
5498 {
5499 SetPhase(0);
5500 }
5501 else
5502 {
5503 SetPhase(mEventPhase - p);
5504 }
5505}
void SetPhase(uint32 p)
Definition SmartScript.cpp:5507

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
5401{
5402 if (!me)
5403 return nullptr;
5404
5405 Unit* unit = nullptr;
5406 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
5408 Cell::VisitObjects(me, searcher, range);
5409 return unit;
5410}
Definition Unit.h:664
Definition GridNotifiers.h:397
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References me, and Cell::VisitObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
5381{
5382 if (!me)
5383 return;
5384
5385 Acore::FriendlyCCedInRange u_check(me, range);
5387 Cell::VisitObjects(me, searcher, range);
5388}
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:809
Definition GridNotifiers.h:464

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
5391{
5392 if (!me)
5393 return;
5394
5395 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
5397 Cell::VisitObjects(me, searcher, range);
5398}
Definition GridNotifiers.h:827

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
5354{
5355 if (!me)
5356 return nullptr;
5357
5358 Unit* unit = nullptr;
5359
5360 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
5362 Cell::VisitObjects(me, searcher, range);
5363 return unit;
5364}
Definition GridNotifiers.h:766

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
5367{
5368 if (!me)
5369 {
5370 return nullptr;
5371 }
5372
5373 Unit* unit = nullptr;
5374 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
5376 Cell::VisitObjects(me, searcher, range);
5377 return unit;
5378}
Definition GridNotifiers.h:785

References me, and Cell::VisitObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
5189{
5190 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
5191
5192 if (e.empty())
5193 {
5194 if (obj)
5195 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
5196
5197 if (at)
5198 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
5199 return;
5200 }
5201 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
5202 {
5203#ifndef ACORE_DEBUG
5204 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
5205 continue;
5206#endif
5207
5208 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
5209 {
5210 if (obj && obj->GetMap()->IsDungeon())
5211 {
5212 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
5213 {
5214 mEvents.push_back((*i));
5215 }
5216 }
5217 continue;
5218 }
5219 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
5220 }
5221}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition SmartScriptMgr.h:1962
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition SmartScriptMgr.h:1958
bool IsDungeon() const
Definition Map.h:297
uint8 GetSpawnMode() const
Definition Map.h:269
uint32 GetEntry() const
Definition Object.h:117
SmartAIEventList mEvents
Definition SmartScript.h:222
Map * GetMap() const
Definition Object.h:625

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

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

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

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
5448{
5449 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5450 if (GetBaseObject())
5452 // xinef: used for area triggers invoker cast
5453 else if (invoker)
5455 return nullptr;
5456}
ObjectGuid mLastInvoker
Definition SmartScript.h:200
WorldObject * GetBaseObject() const
Definition SmartScript.h:64
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:115

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

Referenced by GetTargets(), and ProcessAction().

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
5224{
5226 if (me)
5227 {
5228 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
5229 if (e.empty())
5230 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5231
5232 FillScript(e, me, nullptr);
5233
5234 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
5235 {
5236 if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_DONT_OVERRIDE_ENTRY_SAI))
5237 {
5238 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
5239 FillScript(e, me, nullptr);
5240 }
5241 }
5242 }
5243 else if (go)
5244 {
5245 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
5246 if (e.empty())
5247 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
5248 FillScript(e, go, nullptr);
5249 }
5250 else if (trigger)
5251 {
5252 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
5253 FillScript(e, nullptr, trigger);
5254 }
5255}
@ 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:2093
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2269
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:5188
uint32 entry
Definition ObjectMgr.h:422
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
3517{
3518 WorldObject* scriptTrigger = nullptr;
3519 if (invoker)
3520 scriptTrigger = invoker;
3521 else if (WorldObject* tempLastInvoker = GetLastInvoker())
3522 scriptTrigger = tempLastInvoker;
3523
3524 WorldObject* baseObject = GetBaseObject();
3525
3526 switch (e.GetTargetType())
3527 {
3528 case SMART_TARGET_SELF:
3529 if (baseObject)
3530 targets.push_back(baseObject);
3531 break;
3533 if (me)
3534 if (Unit* victim = me->GetVictim())
3535 targets.push_back(victim);
3536 break;
3538 if (me)
3539 {
3540 if (e.target.hostileRandom.powerType)
3541 {
3542 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)))
3543 targets.push_back(u);
3544 }
3545 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3546 targets.push_back(u);
3547 }
3548 break;
3550 if (me)
3551 {
3552 if (e.target.hostileRandom.powerType)
3553 {
3554 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)))
3555 targets.push_back(u);
3556 }
3557 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3558 targets.push_back(u);
3559 }
3560 break;
3562 if (me)
3563 {
3564 if (e.target.hostileRandom.powerType)
3565 {
3566 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)))
3567 targets.push_back(u);
3568 }
3569 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3570 targets.push_back(u);
3571 }
3572 break;
3574 if (me)
3575 {
3576 if (e.target.hostileRandom.powerType)
3577 {
3578 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)))
3579 targets.push_back(u);
3580 }
3581 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
3582 targets.push_back(u);
3583 }
3584 break;
3586 if (me)
3587 {
3588 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)))
3589 targets.push_back(u);
3590 }
3591 break;
3593 if (scriptTrigger)
3594 targets.push_back(scriptTrigger);
3595 break;
3597 if (scriptTrigger && IsUnit(scriptTrigger))
3598 if (scriptTrigger->ToUnit()->GetVehicle() && scriptTrigger->ToUnit()->GetVehicle()->GetBase())
3599 targets.push_back(scriptTrigger->ToUnit()->GetVehicle()->GetBase());
3600 break;
3602 if (scriptTrigger)
3603 {
3604 if (Player* player = scriptTrigger->ToPlayer())
3605 {
3606 if (Group* group = player->GetGroup())
3607 {
3608 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3609 if (Player* member = groupRef->GetSource())
3610 {
3611 if (member->IsInMap(player))
3612 targets.push_back(member);
3613
3614 if (e.target.invokerParty.includePets)
3615 if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*member, member->GetPetGUID()))
3616 if (pet->IsPet() && pet->IsInMap(player))
3617 targets.push_back(pet);
3618 }
3619 }
3620 // We still add the player to the list if there is no group. If we do
3621 // this even if there is a group (thus the else-check), it will add the
3622 // same player to the list twice. We don't want that to happen.
3623 else
3624 targets.push_back(scriptTrigger);
3625 }
3626 }
3627 break;
3629 {
3630 WorldObject* ref = baseObject;
3631 if (!ref)
3632 ref = scriptTrigger;
3633
3634 if (!ref)
3635 {
3636 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3637 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3638 break;
3639 }
3640
3641 ObjectVector units;
3642 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3643
3644 for (WorldObject* unit : units)
3645 {
3646 if (!IsCreature(unit))
3647 continue;
3648
3649 if (me && me->GetGUID() == unit->GetGUID())
3650 continue;
3651
3652 // check alive state - 1 alive, 2 dead, 0 both
3653 if (uint32 state = e.target.unitRange.livingState)
3654 {
3655 if (unit->ToCreature()->IsAlive() && state == 2)
3656 continue;
3657 if (!unit->ToCreature()->IsAlive() && state == 1)
3658 continue;
3659 }
3660
3661 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))
3662 targets.push_back(unit);
3663 }
3664
3665 break;
3666 }
3668 {
3669 ObjectVector units;
3670 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3671
3672 for (WorldObject* unit : units)
3673 {
3674 if (!IsCreature(unit))
3675 continue;
3676
3677 if (me && me->GetGUID() == unit->GetGUID())
3678 continue;
3679
3680 // check alive state - 1 alive, 2 dead, 0 both
3681 if (uint32 state = e.target.unitDistance.livingState)
3682 {
3683 if (unit->ToCreature()->IsAlive() && state == 2)
3684 continue;
3685 if (!unit->ToCreature()->IsAlive() && state == 1)
3686 continue;
3687 }
3688
3689 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3690 targets.push_back(unit);
3691 }
3692
3693 break;
3694 }
3696 {
3697 ObjectVector units;
3698 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3699
3700 for (WorldObject* unit : units)
3701 {
3702 if (!IsGameObject(unit))
3703 continue;
3704
3705 if (go && go->GetGUID() == unit->GetGUID())
3706 continue;
3707
3708 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3709 targets.push_back(unit);
3710 }
3711
3712 break;
3713 }
3715 {
3716
3717 WorldObject* ref = baseObject;
3718 if (!ref)
3719 ref = scriptTrigger;
3720
3721 if (!ref)
3722 {
3723 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3724 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3725 break;
3726 }
3727
3728 ObjectVector units;
3729 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3730
3731 for (WorldObject* unit : units)
3732 {
3733 if (!IsGameObject(unit))
3734 continue;
3735
3736 if (go && go->GetGUID() == unit->GetGUID())
3737 continue;
3738
3739 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))
3740 targets.push_back(unit);
3741 }
3742
3743 break;
3744 }
3746 {
3747 if (!scriptTrigger && !baseObject)
3748 {
3749 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3750 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3751 break;
3752 }
3753
3754 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3755 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3756 targets.push_back(target);
3757 break;
3758 }
3760 {
3761 if (!scriptTrigger && !GetBaseObject())
3762 {
3763 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3764 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3765 break;
3766 }
3767
3768 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3769 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3770 targets.push_back(target);
3771 break;
3772 }
3774 {
3775 ObjectVector units;
3776 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3777
3778 if (!units.empty() && baseObject)
3779 for (WorldObject* unit : units)
3780 if (IsPlayer(unit) && !unit->ToPlayer()->IsGameMaster() && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3781 targets.push_back(unit);
3782
3783 if (e.target.playerRange.maxCount)
3784 Acore::Containers::RandomResize(targets, e.target.playerRange.maxCount);
3785
3786 break;
3787 }
3789 {
3790 ObjectVector units;
3791 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3792
3793 for (WorldObject* unit : units)
3794 if (IsPlayer(unit))
3795 targets.push_back(unit);
3796 break;
3797 }
3799 {
3800 WorldObject* ref = baseObject;
3801 if (!ref)
3802 ref = scriptTrigger;
3803
3804 if (!ref)
3805 {
3806 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3807 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3808 break;
3809 }
3810
3811 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3812 targets.assign(stored->begin(), stored->end());
3813 break;
3814 }
3816 {
3817 WorldObject* ref = baseObject;
3818
3819 if (!ref)
3820 ref = scriptTrigger;
3821
3822 if (!ref)
3823 {
3824 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3825 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3826 break;
3827 }
3828
3829 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3830 if (target)
3831 targets.push_back(target);
3832 break;
3833 }
3835 {
3836 WorldObject* ref = baseObject;
3837
3838 if (!ref)
3839 ref = scriptTrigger;
3840
3841 if (!ref)
3842 {
3843 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3844 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3845 break;
3846 }
3847
3848 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3849 if (target)
3850 targets.push_back(target);
3851 break;
3852 }
3854 {
3855 WorldObject* ref = baseObject;
3856
3857 if (!ref)
3858 ref = scriptTrigger;
3859
3860 if (!ref)
3861 {
3862 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3863 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3864 break;
3865 }
3866
3867 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3868 targets.push_back(target);
3869 break;
3870 }
3872 /*
3873 * Owners/Summoners should be WorldObjects. This allows to have other objects
3874 * such as gameobjects to execute SmartScripts using this type of target.
3875 * Otherwise, only Units like creatures can summon other creatures.
3876 */
3877 {
3878 if (me)
3879 {
3881 {
3882 targets.push_back(owner);
3883 }
3884 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3885 {
3886 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3887 }
3888 }
3889 else if (go)
3890 {
3892 {
3893 targets.push_back(owner);
3894 }
3895 }
3896
3897 // xinef: Get owner of owner
3898 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3899 {
3900 if (WorldObject* owner = targets.front())
3901 {
3902 targets.clear();
3903
3904 if (IsCreature(owner))
3905 {
3906 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3907 targets.push_back(base);
3908 }
3909 else if (IsGameObject(owner))
3910 {
3911 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3912 targets.push_back(base);
3913 }
3914 else if (IsPlayer(owner))
3915 {
3916 if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
3917 targets.push_back(base);
3918 }
3919 }
3920 }
3921 break;
3922 }
3924 {
3925 if (me)
3926 {
3927 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
3928 if (Unit* temp = ref->GetVictim())
3929 // Xinef: added distance check
3930 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3931 targets.push_back(temp);
3932 }
3933 break;
3934 }
3936 {
3937 if (me)
3938 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3939 targets.push_back(target);
3940
3941 break;
3942 }
3944 {
3945 if (me)
3946 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3947 targets.push_back(target);
3948
3949 break;
3950 }
3952 {
3953 ObjectVector units;
3954 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3955
3956 for (WorldObject* unit : units)
3957 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3958 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3959 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3960 targets.push_back(unit);
3961
3962 if (e.target.o > 0)
3963 Acore::Containers::RandomResize(targets, e.target.o);
3964
3965 break;
3966 }
3968 {
3969 ObjectVector units;
3970 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3971 // 1 = Tanks, 2 = Healer, 4 = Damage
3972 uint32 roleMask = e.target.roleSelection.roleMask;
3973 for (WorldObject* unit : units)
3974 if (Player* targetPlayer = unit->ToPlayer())
3975 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3976 {
3977 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3978 {
3979 if (targetPlayer->HasTankSpec())
3980 {
3981 targets.push_back(unit);
3982 continue;
3983 }
3984 }
3985 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3986 {
3987 if (targetPlayer->HasHealSpec())
3988 {
3989 targets.push_back(unit);
3990 continue;
3991 }
3992 }
3993 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3994 {
3995 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3996 {
3997 targets.push_back(unit);
3998 continue;
3999 }
4000 }
4001 }
4002
4003 if (e.target.roleSelection.resize > 0)
4004 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
4005
4006 break;
4007 }
4009 {
4010 if (me && me->IsVehicle())
4011 {
4012 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
4013 {
4014 targets.push_back(target);
4015 }
4016 }
4017 break;
4018 }
4020 {
4021 if (me)
4022 {
4023 if (Group* lootGroup = me->GetLootRecipientGroup())
4024 {
4025 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
4026 {
4027 if (Player* recipient = it->GetSource())
4028 {
4029 targets.push_back(recipient);
4030 }
4031 }
4032 }
4033 else
4034 {
4035 if (Player* recipient = me->GetLootRecipient())
4036 {
4037 targets.push_back(recipient);
4038 }
4039 }
4040 }
4041 break;
4042 }
4044 {
4045 if (me)
4046 {
4047 for (ObjectGuid const& guid : _summonList)
4048 {
4049 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
4050 {
4051 if (Creature* creature = me->GetMap()->GetCreature(guid))
4052 {
4053 targets.push_back(creature);
4054 }
4055 }
4056 }
4057 }
4058 break;
4059 }
4061 {
4062 InstanceScript* instance = nullptr;
4063
4064 if (e.IsAreatriggerScript() && scriptTrigger)
4065 instance = scriptTrigger->GetInstanceScript();
4066 else
4067 instance = GetBaseObject()->GetInstanceScript();
4068
4069 if (!instance)
4070 {
4071 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
4072 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
4073 return;
4074 }
4075
4076 if (e.target.instanceStorage.type == 1)
4077 {
4078 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
4079 targets.push_back(creature);
4080 }
4081 else if (e.target.instanceStorage.type == 2)
4082 {
4083 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
4084 targets.push_back(go);
4085 }
4086
4087 break;
4088 }
4090 {
4091 if (me)
4092 {
4093 if (CreatureGroup* group = me->GetFormation())
4094 {
4095 uint32 formationType = e.target.formation.type;
4096 uint32 entry = e.target.formation.entry;
4097 bool excludeSelf = e.target.formation.excludeSelf;
4098
4099 if (formationType == 1) // Leader only
4100 {
4101 if (Creature* leader = group->GetLeader())
4102 {
4103 if ((!excludeSelf || leader != me) && (!entry || leader->GetEntry() == entry))
4104 targets.push_back(leader);
4105 }
4106 }
4107 else // 0 = Members only, 2 = All
4108 {
4109 for (auto const& itr : group->GetMembers())
4110 {
4111 Creature* member = itr.first;
4112
4113 if (!member)
4114 continue;
4115
4116 if (excludeSelf && member == me)
4117 continue;
4118
4119 if (entry && member->GetEntry() != entry)
4120 continue;
4121
4122 if (formationType == 0 && member == group->GetLeader())
4123 continue;
4124
4125 targets.push_back(member);
4126 }
4127 }
4128 }
4129 }
4130 break;
4131 }
4132 case SMART_TARGET_NONE:
4134 default:
4135 break;
4136 }
4137}
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:1787
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition SmartScriptMgr.h:1786
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition SmartScriptMgr.h:1788
@ SMART_TARGET_LOOT_RECIPIENTS
Definition SmartScriptMgr.h:1576
@ SMART_TARGET_CLOSEST_CREATURE
Definition SmartScriptMgr.h:1568
@ SMART_TARGET_CREATURE_DISTANCE
Definition SmartScriptMgr.h:1560
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition SmartScriptMgr.h:1555
@ SMART_TARGET_INVOKER_PARTY
Definition SmartScriptMgr.h:1565
@ SMART_TARGET_FORMATION
Definition SmartScriptMgr.h:1591
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition SmartScriptMgr.h:1575
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition SmartScriptMgr.h:1569
@ SMART_TARGET_VEHICLE_PASSENGER
Definition SmartScriptMgr.h:1578
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition SmartScriptMgr.h:1562
@ SMART_TARGET_CREATURE_GUID
Definition SmartScriptMgr.h:1559
@ SMART_TARGET_PLAYER_RANGE
Definition SmartScriptMgr.h:1566
@ SMART_TARGET_SUMMONED_CREATURES
Definition SmartScriptMgr.h:1589
@ SMART_TARGET_VICTIM
Definition SmartScriptMgr.h:1551
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition SmartScriptMgr.h:1564
@ SMART_TARGET_CREATURE_RANGE
Definition SmartScriptMgr.h:1558
@ SMART_TARGET_CLOSEST_PLAYER
Definition SmartScriptMgr.h:1570
@ SMART_TARGET_HOSTILE_RANDOM
Definition SmartScriptMgr.h:1554
@ SMART_TARGET_GAMEOBJECT_GUID
Definition SmartScriptMgr.h:1563
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition SmartScriptMgr.h:1552
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition SmartScriptMgr.h:1572
@ SMART_TARGET_SELF
Definition SmartScriptMgr.h:1550
@ SMART_TARGET_PLAYER_WITH_AURA
Definition SmartScriptMgr.h:1586
@ SMART_TARGET_ROLE_SELECTION
Definition SmartScriptMgr.h:1588
@ SMART_TARGET_ACTION_INVOKER
Definition SmartScriptMgr.h:1556
@ SMART_TARGET_POSITION
Definition SmartScriptMgr.h:1557
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition SmartScriptMgr.h:1553
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition SmartScriptMgr.h:1571
@ SMART_TARGET_INSTANCE_STORAGE
Definition SmartScriptMgr.h:1590
@ SMART_TARGET_FARTHEST
Definition SmartScriptMgr.h:1577
@ SMART_TARGET_THREAT_LIST
Definition SmartScriptMgr.h:1573
@ SMART_TARGET_CLOSEST_ENEMY
Definition SmartScriptMgr.h:1574
@ SMART_TARGET_NONE
Definition SmartScriptMgr.h:1549
@ SMART_TARGET_PLAYER_DISTANCE
Definition SmartScriptMgr.h:1567
@ SMART_TARGET_STORED
Definition SmartScriptMgr.h:1561
std::vector< WorldObject * > ObjectVector
Definition SmartScriptMgr.h:2033
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:2414
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:169
Definition InstanceScript.h:143
Creature * GetCreature(uint32 type)
Definition InstanceScript.cpp:116
GameObject * GetGameObject(uint32 type)
Definition InstanceScript.cpp:121
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2349
Definition ObjectGuid.h:118
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:1084
static bool IsUnit(WorldObject *obj)
Definition SmartScript.cpp:5458
static bool IsPlayer(WorldObject *obj)
Definition SmartScript.cpp:5463
static bool IsCreature(WorldObject *obj)
Definition SmartScript.cpp:5468
WorldObject * GetLastInvoker(WorldObject *invoker=nullptr) const
Definition SmartScript.cpp:5447
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition SmartScript.cpp:4139
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition SmartScript.h:151
static bool IsGameObject(WorldObject *obj)
Definition SmartScript.cpp:5484
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition SmartScript.h:100
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition SmartScript.cpp:5400
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:111
bool IsVehicle() const
Definition Unit.h:800
Vehicle * GetVehicle() const
Definition Unit.h:1927
TempSummon * ToTempSummon()
Definition Unit.h:731
Unit * GetCharmerOrOwner() const
Definition Unit.h:1286
bool IsSummon() const
Definition Unit.h:794
Unit * GetVictim() const
Definition Unit.h:903
Vehicle * GetVehicleKit() const
Definition Unit.h:1926
ObjectGuid GetCharmerOrOwnerGUID() const
Definition Unit.h:1295
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:1238
Player * SelectNearestPlayer(float distance=0) const
Definition Object.cpp:2525
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition Object.cpp:1460
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:79
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:199
Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition ObjectAccessor.cpp:234
Definition UnitAI.h:135
Definition UnitAI.h:170

References _summonList, Creature::AI(), SmartTarget::aura, SmartTarget::closestAttackable, SmartTarget::closestFriendly, SmartTarget::creature, SmartTarget::dbGuid, SmartTarget::dead, SmartTarget::dist, SmartTarget::distMax, SmartTarget::distMin, DoFindClosestFriendlyInRange(), SmartTarget::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, SmartTarget::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(), ObjectAccessor::GetWorldObject(), GetWorldObjectsInDist(), go, SmartTarget::goClosest, SmartTarget::goDistance, SmartTarget::goGUID, SmartTarget::goRange, SmartTarget::hostileRandom, SmartTarget::id, SmartTarget::includePets, SmartTarget::index, SmartTarget::instanceStorage, SmartTarget::invokerParty, SmartScriptHolder::IsAreatriggerScript(), IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), IsUnit(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxCount, SmartTarget::maxDist, MaxThreat, me, SmartTarget::minDist, MinDistance, MinThreat, SmartTarget::negation, SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, Random, Acore::Containers::RandomResize(), SmartTarget::resize, SmartTarget::roleMask, SmartTarget::roleSelection, SmartTarget::seatMask, WorldObject::SelectNearestPlayer(), Creature::SelectNearestTarget(), UnitAI::SelectTarget(), SMART_TARGET_ACTION_INVOKER, SMART_TARGET_ACTION_INVOKER_VEHICLE, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_ENEMY, SMART_TARGET_CLOSEST_FRIENDLY, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_FARTHEST, SMART_TARGET_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_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
4140{
4141 WorldObject* obj = GetBaseObject();
4142 if (!obj)
4143 return;
4144
4145 Acore::AllWorldObjectsInRange u_check(obj, dist);
4147 Cell::VisitObjects(obj, searcher, dist);
4148}
Definition GridNotifiers.h:1616
Definition GridNotifiers.h:230

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

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

◆ IncPhase()

void SmartScript::IncPhase ( uint32  p)
private
5490{
5491 // protect phase from overflowing
5492 SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
5493}
@ 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
4932{
4933 switch (e.GetEventType())
4934 {
4935 //set only events which have initial timers
4939 break;
4940 case SMART_EVENT_UPDATE:
4943 case SMART_EVENT_RANGE:
4950 break;
4954 break;
4958 break;
4959 default:
4960 e.active = true;
4961 break;
4962 }
4963}
@ 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:4964
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:2020
uint32 GetEventType() const
Definition SmartScriptMgr.h:2012

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
5083{
5084 if (!mInstallEvents.empty())
5085 {
5086 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
5087 mEvents.push_back(*i);//must be before UpdateTimers
5088
5089 mInstallEvents.clear();
5090 }
5091}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3405{
3406 if (!GetBaseObject())
3407 return;
3409 {
3410 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3411 return;
3412 }
3413 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3414 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3415 {
3417 {
3418 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);
3419 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);
3420 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);
3421 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);
3422 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);
3423 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);
3424 break;
3425 }
3427 {
3428 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);
3429 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);
3430 break;
3431 }
3433 {
3434 if (!me)
3435 return;
3436 //store cage as id1
3437 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);
3438
3439 //reset(close) cage on hostage(me) respawn
3440 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);
3441
3442 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);
3443 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);
3444
3445 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);
3446 //phase 1: give quest credit on movepoint reached
3448 //phase 1: despawn after time on movepoint reached
3449 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);
3450
3451 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3452 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);
3453 break;
3454 }
3456 {
3457 if (!go)
3458 return;
3459 //store hostage as id1
3460 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);
3461 //store invoker as id2
3462 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);
3463 //signal hostage
3464 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);
3465 //when hostage raeched end point, give credit to invoker
3466 if (e.action.installTtemplate.param2)
3467 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);
3468 else
3469 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);
3470 break;
3471 }
3473 default:
3474 return;
3475 }
3476}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:110
std::uint8_t uint8
Definition Define.h:109
@ POINT_MOTION_TYPE
Definition MotionMaster.h:48
SMARTAI_TEMPLATE
Definition SmartScriptMgr.h:1537
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition SmartScriptMgr.h:1542
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition SmartScriptMgr.h:1543
@ SMARTAI_TEMPLATE_CASTER
Definition SmartScriptMgr.h:1539
@ SMARTAI_TEMPLATE_TURRET
Definition SmartScriptMgr.h:1540
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition SmartScriptMgr.h:1951
@ 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:3478

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
5474{
5475 if (!obj)
5476 return false;
5477
5478 if (Creature* creatureObj = obj->ToCreature())
5479 return creatureObj->IsCharmed();
5480
5481 return false;
5482}
Creature * ToCreature()
Definition Object.h:206

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5469{
5470 return obj && obj->IsCreature();
5471}
bool IsCreature() const
Definition Object.h:205

References Object::IsCreature().

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5485{
5486 return obj && obj->IsGameObject();
5487}
bool IsGameObject() const
Definition Object.h:213

References Object::IsGameObject().

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5520{
5521 if (mEventPhase == 0)
5522 {
5523 return false;
5524 }
5525
5526 return ((1 << (mEventPhase - 1)) & p) != 0;
5527}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5464{
5465 return obj && obj->IsPlayer();
5466}
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
101{
102 if (me)
103 return IsSmart(me, silent);
104 if (go)
105 return IsSmart(go, silent);
106
107 return false;
108}
bool IsSmart(Creature *c, bool silent=false) const
Definition SmartScript.cpp:70

References go, IsSmart(), and me.

◆ IsSmart() [2/3]

bool SmartScript::IsSmart ( Creature c,
bool  silent = false 
) const
71{
72 if (!c)
73 return false;
74
75 bool smart = true;
76 if (!dynamic_cast<SmartAI*>(c->AI()))
77 smart = false;
78
79 if (!smart && !silent)
80 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));
81
82 return smart;
83}
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
86{
87 if (!g)
88 return false;
89
90 bool smart = true;
91 if (!dynamic_cast<SmartGameObjectAI*>(g->AI()))
92 smart = false;
93
94 if (!smart && !silent)
95 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));
96
97 return smart;
98}
GameObjectAI * AI() const
Definition GameObject.h:307
Definition SmartAI.h:288

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5459{
5460 return obj && (obj->IsCreature() || obj->IsPlayer());
5461}

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

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

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
5258{
5259 if (obj)//handle object based scripts
5260 {
5261 switch (obj->GetTypeId())
5262 {
5263 case TYPEID_UNIT:
5265 me = obj->ToCreature();
5266 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
5267 break;
5268 case TYPEID_GAMEOBJECT:
5270 go = obj->ToGameObject();
5271 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
5272 break;
5273 default:
5274 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
5275 return;
5276 }
5277 }
5278 else if (at)
5279 {
5281 trigger = at;
5282 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
5283 }
5284 else
5285 {
5286 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
5287 return;
5288 }
5289
5290 GetScript();//load copy of script
5291
5292 for (SmartScriptHolder& event : mEvents)
5293 InitTimer(event);//calculate timers for first time use
5294
5296 InstallEvents();
5298}
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition SmartScriptMgr.h:1794
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition SmartScriptMgr.h:1795
@ 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:136
void InstallEvents()
Definition SmartScript.cpp:5082
void GetScript()
Definition SmartScript.cpp:5223

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)
5301{
5302 if (!me)
5303 return;
5304
5306}
@ SMART_EVENT_IC_LOS
Definition SmartScriptMgr.h:125
@ SMART_EVENT_OOC_LOS
Definition SmartScriptMgr.h:109
bool IsEngaged() const override
Definition Creature.cpp:2919

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

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

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)
5094{
5096 return;
5097
5098 InstallEvents();//before UpdateTimers
5099
5101 {
5103 mEventSortingRequired = false;
5104 }
5105
5106 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
5107 UpdateTimer(*i, diff);
5108
5109 if (!mStoredEvents.empty())
5110 {
5111 SmartAIEventStoredList::iterator i, icurr;
5112 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
5113 {
5114 icurr = i++;
5115 UpdateTimer(*icurr, diff);
5116 }
5117 }
5118
5119 bool needCleanup = true;
5120 if (!mTimedActionList.empty())
5121 {
5123 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5124 {
5125 if ((*i).enableTimed)
5126 {
5127 UpdateTimer(*i, diff);
5128 needCleanup = false;
5129 }
5130 }
5131
5133 }
5134 if (needCleanup)
5135 mTimedActionList.clear();
5136
5137 if (!mRemIDs.empty())
5138 {
5139 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
5141
5142 // xinef: clear list after cleaning...
5143 mRemIDs.clear();
5144 }
5145 if (mUseTextTimer && me)
5146 {
5147 if (mTextTimer < diff)
5148 {
5149 uint32 textID = mLastTextID;
5150 mLastTextID = 0;
5151 uint32 entry = mTalkerEntry;
5152 mTalkerEntry = 0;
5153 mTextTimer = 0;
5154 mUseTextTimer = false;
5155 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
5156 }
5157 else mTextTimer -= diff;
5158 }
5159}
@ SMART_EVENT_TEXT_OVER
Definition SmartScriptMgr.h:151
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition SmartScript.cpp:4971
void SortEvents(SmartAIEventList &events)
Definition SmartScript.cpp:5161
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 
)
165{
166 e.runOnce = true;//used for repeat check
167
168 //calc random
170 {
171 uint32 rnd = urand(1, 100);
172 if (e.event.event_chance <= rnd)
173 return;
174 }
175
176 // Remove SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL flag after processing roll chances as it's not needed anymore
177 e.event.event_flags &= ~SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL;
178
179 if (unit)
180 mLastInvoker = unit->GetGUID();
181 else if (gob)
182 mLastInvoker = gob->GetGUID();
183
184 if (WorldObject* tempInvoker = GetLastInvoker())
185 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: Invoker: {} ({})", tempInvoker->GetName(), tempInvoker->GetGUID().ToString());
186
187 bool isControlled = e.action.moveToPos.controlled > 0;
188
189 ObjectVector targets;
190 WorldObject* invoker = nullptr;
191 if (unit)
192 invoker = unit;
193 else if (gob)
194 invoker = gob;
195
196 GetTargets(targets, e, invoker);
197
198 switch (e.GetActionType())
199 {
201 {
202 Creature* talker = e.target.type == 0 ? me : nullptr;
203 WorldObject* talkTarget = nullptr;
204
205 for (WorldObject* target : targets)
206 {
207 if (IsCreature((target)) && !target->ToCreature()->IsPet()) // Prevented sending text to pets.
208 {
210 {
211 talker = me;
212 talkTarget = target->ToCreature();
213 }
214 else
215 talker = target->ToCreature();
216 break;
217 }
218 else if (IsPlayer((target)))
219 {
220 talker = me; // xinef: added
221 talkTarget = target->ToPlayer();
222 break;
223 }
224 }
225
226 if (!talkTarget)
227 talkTarget = GetLastInvoker();
228
229 if (!talker)
230 break;
231
232 if (!sCreatureTextMgr->TextExist(talker->GetEntry(), uint8(e.action.talk.textGroupID)))
233 {
234 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());
235 break;
236 }
237
238 mTalkerEntry = talker->GetEntry();
241 mUseTextTimer = true;
242
243 talker->AI()->Talk(e.action.talk.textGroupID, talkTarget, Milliseconds(e.action.talk.delay));
244 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} ({}), textId: {}", talker->GetName(), talker->GetGUID().ToString(), mLastTextID);
245 break;
246 }
248 {
249 for (WorldObject* target : targets)
250 {
251 if (IsCreature(target))
252 sCreatureTextMgr->SendChat(target->ToCreature(), uint8(e.action.simpleTalk.textGroupID), IsPlayer(GetLastInvoker()) ? GetLastInvoker() : 0);
253 else if (IsPlayer(target) && me)
254 {
255 WorldObject* templastInvoker = GetLastInvoker();
256 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());
257 }
258
259 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: {} ({}), textGroupId: {}",
260 target->GetName(), target->GetGUID().ToString(), uint8(e.action.simpleTalk.textGroupID));
261 }
262 break;
263 }
265 {
266 for (WorldObject* target : targets)
267 {
268 if (IsUnit(target))
269 {
270 target->ToUnit()->HandleEmoteCommand(e.action.emote.emote);
271 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: {} ({}), emote: {}",
272 target->GetName(), target->GetGUID().ToString(), e.action.emote.emote);
273 }
274 }
275 break;
276 }
278 {
279 for (WorldObject* target : targets)
280 {
281 if (IsUnit(target))
282 {
283 if (e.action.sound.distance == 1)
284 target->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
285 else
286 target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
287 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} ({}), sound: {}, onlyself: {}",
288 target->GetName(), target->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
289 }
290 }
291 break;
292 }
294 {
295 uint32 sounds[4];
296 sounds[0] = e.action.randomSound.sound1;
297 sounds[1] = e.action.randomSound.sound2;
298 sounds[2] = e.action.randomSound.sound3;
299 sounds[3] = e.action.randomSound.sound4;
300 uint32 temp[4];
301 uint32 count = 0;
302 for (unsigned int sound : sounds)
303 {
304 if (sound)
305 {
306 temp[count] = sound;
307 ++count;
308 }
309 }
310
311 if (count == 0)
312 {
313 break;
314 }
315
316 for (WorldObject* target : targets)
317 {
318 if (IsUnit(target))
319 {
320 uint32 sound = temp[urand(0, count - 1)];
321 target->PlayDirectSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
322 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
323 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
324 }
325 }
326
327 break;
328 }
330 {
331 ObjectVector targets;
332
333 if (e.action.music.type > 0)
334 {
335 if (me && me->FindMap())
336 {
337 Map::PlayerList const& players = me->GetMap()->GetPlayers();
338
339 if (!players.IsEmpty())
340 {
341 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
342 if (Player* player = i->GetSource())
343 {
344 if (player->GetZoneId() == me->GetZoneId())
345 {
346 if (e.action.music.type > 1)
347 {
348 if (player->GetAreaId() == me->GetAreaId())
349 targets.push_back(player);
350 }
351 else
352 targets.push_back(player);
353 }
354 }
355 }
356 }
357 }
358 else
359 GetTargets(targets, e);
360
361 if (!targets.empty())
362 {
363 for (WorldObject* target : targets)
364 {
365 if (IsUnit(target))
366 {
367 target->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0);
368 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: {} ({}), sound: {}, onlySelf: {}, type: {}",
369 target->GetName(), target->GetGUID().ToString(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type);
370 }
371 }
372 }
373 break;
374 }
376 {
377 ObjectVector targets;
378
379 if (e.action.randomMusic.type > 0)
380 {
381 if (me && me->FindMap())
382 {
383 Map::PlayerList const& players = me->GetMap()->GetPlayers();
384
385 if (!players.IsEmpty())
386 {
387 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
388 if (Player* player = i->GetSource())
389 {
390 if (player->GetZoneId() == me->GetZoneId())
391 {
392 if (e.action.randomMusic.type > 1)
393 {
394 if (player->GetAreaId() == me->GetAreaId())
395 targets.push_back(player);
396 }
397 else
398 targets.push_back(player);
399 }
400 }
401 }
402 }
403 }
404 else
405 GetTargets(targets, e);
406
407 if (targets.empty())
408 break;
409
410 uint32 sounds[4];
411 sounds[0] = e.action.randomMusic.sound1;
412 sounds[1] = e.action.randomMusic.sound2;
413 sounds[2] = e.action.randomMusic.sound3;
414 sounds[3] = e.action.randomMusic.sound4;
415 uint32 temp[4];
416 uint32 count = 0;
417 for (unsigned int sound : sounds)
418 {
419 if (sound)
420 {
421 temp[count] = sound;
422 ++count;
423 }
424 }
425
426 if (count == 0)
427 {
428 break;
429 }
430
431 for (WorldObject* target : targets)
432 {
433 if (IsUnit(target))
434 {
435 uint32 sound = temp[urand(0, count - 1)];
436 target->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0);
437 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: {} ({}), sound: {}, onlyself: {}, type: {}",
438 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type);
439 }
440 }
441
442 break;
443 }
445 {
446 for (WorldObject* target : targets)
447 {
448 if (IsCreature(target))
449 {
451 {
452 target->ToCreature()->SetFaction(e.action.faction.factionID);
453 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
454 target->GetEntry(), target->GetGUID().ToString(), e.action.faction.factionID);
455 }
456 else
457 {
458 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(target->ToCreature()->GetEntry()))
459 {
460 if (target->ToCreature()->GetFaction() != ci->faction)
461 {
462 target->ToCreature()->SetFaction(ci->faction);
463 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
464 target->GetEntry(), target->GetGUID().ToString(), ci->faction);
465 }
466 }
467 }
468 }
469 }
470 break;
471 }
473 {
474 for (WorldObject* target : targets)
475 {
476 if (!IsCreature(target))
477 continue;
478
480 {
481 //set model based on entry from creature_template
483 {
484 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
485 {
486 CreatureModel const* model = ObjectMgr::ChooseDisplayId(ci);
487 target->ToCreature()->SetDisplayId(model->CreatureDisplayID, model->DisplayScale);
488 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
489 target->GetEntry(), target->GetGUID().ToString(), model->CreatureDisplayID);
490 }
491 }
492 //if no param1, then use value from param2 (modelId)
493 else
494 {
495 target->ToCreature()->SetDisplayId(e.action.morphOrMount.model);
496 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
497 target->GetEntry(), target->GetGUID().ToString(), e.action.morphOrMount.model);
498 }
499 }
500 else
501 {
502 target->ToCreature()->DeMorph();
503 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} demorphs.",
504 target->GetEntry(), target->GetGUID().ToString());
505 }
506 }
507 break;
508 }
510 {
511 for (WorldObject* target : targets)
512 {
513 if (IsPlayer(target))
514 {
515 target->ToPlayer()->FailQuest(e.action.quest.quest);
516 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow {} fails quest {}",
517 target->GetGUID().ToString(), e.action.quest.quest);
518 }
519 }
520 break;
521 }
523 {
524 for (WorldObject* target : targets)
525 {
526 if (Player* player = target->ToPlayer())
527 {
528 if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.questOffer.questID))
529 {
530 if (me && e.action.questOffer.directAdd == 0)
531 {
532 if (player->CanTakeQuest(q, true))
533 {
534 if (WorldSession* session = player->GetSession())
535 {
536 PlayerMenu menu(session);
537 menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true);
538 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - offering quest {}",
539 player->GetGUID().ToString(), e.action.questOffer.questID);
540 }
541 }
542 }
543 else
544 {
545 player->AddQuestAndCheckCompletion(q, nullptr);
546 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - quest {} added",
547 player->GetGUID().ToString(), e.action.questOffer.questID);
548 }
549 }
550 }
551 }
552 break;
553 }
555 {
556 for (WorldObject* target : targets)
557 {
558 if (!IsCreature(target))
559 continue;
560
561 target->ToCreature()->SetReactState(ReactStates(e.action.react.state));
562 }
563 break;
564 }
566 {
567 std::vector<uint32> emotes;
568 std::copy_if(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(),
569 std::back_inserter(emotes), [](uint32 emote) { return emote != 0; });
570
571 for (WorldObject* target : targets)
572 {
573 if (IsUnit(target))
574 {
576 target->ToUnit()->HandleEmoteCommand(emote);
577 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow {} handle random emote {}",
578 target->GetGUID().ToString(), emote);
579 }
580 }
581 break;
582 }
584 {
585 if (!me)
586 break;
587
588 for (ThreatReference* ref : me->GetThreatMgr().GetModifiableThreatList())
589 {
590 ref->ModifyThreatByPercent(std::max<int32>(-100, int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC)));
591 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}",
592 me->GetGUID().ToString(), ref->GetVictim()->GetGUID().ToString(), int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC));
593 }
594 break;
595 }
597 {
598 if (!me)
599 break;
600
601 for (WorldObject* target : targets)
602 {
603 if (IsUnit(target))
604 {
605 me->GetThreatMgr().ModifyThreatByPercent(target->ToUnit(), std::max<int32>(-100, int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC)));
606 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature {} modify threat for unit {}, value {}",
607 me->GetGUID().ToString(), target->GetGUID().ToString(), int32(e.action.threatPCT.threatINC) - int32(e.action.threatPCT.threatDEC));
608 }
609 }
610 break;
611 }
613 {
614 for (WorldObject* target : targets)
615 {
616 // Special handling for vehicles
617 if (IsUnit(target))
618 if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
619 for (auto & Seat : vehicle->Seats)
620 if (Player* player = ObjectAccessor::GetPlayer(*target, Seat.second.Passenger.Guid))
621 player->AreaExploredOrEventHappens(e.action.quest.quest);
622
623 if (IsPlayer(target))
624 {
625 target->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest);
626
627 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow {} credited quest {}",
628 target->GetGUID().ToString(), e.action.quest.quest);
629 }
630 }
631 break;
632 }
634 {
635 if (targets.empty())
636 break;
637
638 Unit* caster = me;
639 // Areatrigger Cast!
640 if (e.IsAreatriggerScript())
641 caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
642
645
646 bool failedSpellCast = false, successfulSpellCast = false;
647
648 for (WorldObject* target : targets)
649 {
650 // may be nullptr
651 if (go)
652 go->CastSpell(target->ToUnit(), e.action.cast.spell);
653
654 if (!IsUnit(target))
655 continue;
656
657 if (caster && caster != me) // Areatrigger cast
658 {
659 caster->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
660 }
661 else if (me)
662 {
663 // If target has the aura, skip
664 if ((e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) && target->ToUnit()->HasAura(e.action.cast.spell))
665 continue;
666
667 // If the threatlist is a singleton, cancel
669 if (me->GetThreatMgr().GetThreatListSize() <= 1)
670 break;
671
672 // If target does not use mana, skip
673 if ((e.action.cast.castFlags & SMARTCAST_TARGET_POWER_MANA) && !target->ToUnit()->GetPower(POWER_MANA))
674 continue;
675
676 // Interrupts current spellcast
679
680 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
681 float distanceToTarget = me->GetDistance(target->ToUnit());
682 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
683 float spellMinRange = me->GetSpellMinRangeForTarget(target->ToUnit(), spellInfo);
684 float meleeRange = me->GetMeleeRange(target->ToUnit());
685
686 bool isWithinLOSInMap = me->IsWithinLOSInMap(target->ToUnit(), VMAP::ModelIgnoreFlags::M2);
687 bool isWithinMeleeRange = distanceToTarget <= meleeRange;
688 bool isRangedAttack = spellMaxRange > NOMINAL_MELEE_RANGE;
689 bool isTargetRooted = target->ToUnit()->HasUnitState(UNIT_STATE_ROOT);
690 // To prevent running back and forth when OOM, we must have more than 10% mana.
691 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);
692 bool isSpellIgnoreLOS = spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT);
693
694 // If target is rooted we move out of melee range before casting, but not further than spell max range.
695 if (isWithinLOSInMap && isWithinMeleeRange && isRangedAttack && isTargetRooted && canCastSpell && !me->IsVehicle())
696 {
697 failedSpellCast = true; // Mark spellcast as failed so we can retry it later
698
699 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
700 continue;
701
702 float minDistance = std::max(meleeRange, spellMinRange) - distanceToTarget + NOMINAL_MELEE_RANGE;
703 CAST_AI(SmartAI, me->AI())->DistanceYourself(std::min(minDistance, spellMaxRange));
704 continue;
705 }
706
707 if (distanceToTarget > spellMaxRange && isWithinLOSInMap)
708 {
709 failedSpellCast = true;
710
711 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
712 continue;
713
715 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
716
717 continue;
718 }
719 else if (distanceToTarget < spellMinRange || !(isWithinLOSInMap || isSpellIgnoreLOS))
720 {
721 failedSpellCast = true;
722
723 if (me->IsRooted()) // Rooted inhabit type, never move/reposition
724 continue;
725
726 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, 0.f);
728 CAST_AI(SmartAI, me->AI())->SetCombatMovement(true, true);
729 continue;
730 }
731
732 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
734 {
736 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
737 else
738 triggerFlags = TRIGGERED_FULL_MASK;
739 }
740
741 SpellCastResult result = me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
742 bool spellCastFailed = (result != SPELL_CAST_OK && result != SPELL_FAILED_SPELL_IN_PROGRESS);
743
745 {
746 if (result == SPELL_FAILED_OUT_OF_RANGE)
747 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
748 else if (result != SPELL_CAST_OK)
749 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(false, 0.f);
750 }
751
752 if (spellCastFailed)
753 failedSpellCast = true;
754 else
755 successfulSpellCast = true;
756
757 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
758 me->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
759 }
760 }
761
762 // If there is at least 1 failed cast and no successful casts at all, retry again on next loop
763 if (failedSpellCast && !successfulSpellCast)
764 {
765 RetryLater(e, true);
766 // Don't execute linked events
767 return;
768 }
769
770 break;
771 }
773 {
774 if (targets.empty())
775 break;
776
779
780 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
782 {
784 {
785 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
786 }
787 else
788 {
789 triggerFlags = TRIGGERED_FULL_MASK;
790 }
791 }
792
793 for (WorldObject* target : targets)
794 {
795 Unit* uTarget = target->ToUnit();
796 if (!uTarget)
797 continue;
798
800 {
802 {
803 uTarget->InterruptNonMeleeSpells(false);
804 }
805
806 uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
807 }
808 }
809 break;
810 }
812 {
813 // Can be used for area trigger cast
814 WorldObject* tempLastInvoker = GetLastInvoker(unit);
815 if (!tempLastInvoker)
816 break;
817
818 if (targets.empty())
819 break;
820
823
824 for (WorldObject* target : targets)
825 {
826 if (!IsUnit(target))
827 continue;
828
829 if (!IsUnit(tempLastInvoker))
830 continue;
831
832 if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
833 {
835 {
836 tempLastInvoker->ToUnit()->InterruptNonMeleeSpells(false);
837 }
838
839 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
841 {
843 {
844 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
845 }
846 else
847 {
848 triggerFlags = TRIGGERED_FULL_MASK;
849 }
850 }
851
852 tempLastInvoker->ToUnit()->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
853 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
854 tempLastInvoker->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
855 }
856 else
857 {
858 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
859 e.action.cast.spell, target->GetGUID().ToString());
860 }
861 }
862 break;
863 }
865 {
866 for (WorldObject* target : targets)
867 {
868 if (IsUnit(target))
869 {
870 target->ToUnit()->AddAura(e.action.cast.spell, target->ToUnit());
871 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura {} to unit {}",
872 e.action.cast.spell, target->GetGUID().ToString());
873 }
874 }
875 break;
876 }
878 {
879 for (WorldObject* target : targets)
880 {
881 if (IsGameObject(target))
882 {
883 GameObject* go = target->ToGameObject();
884
885 // Activate
887 {
889 }
890
892 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject {} activated", go->GetGUID().ToString());
893 }
894 }
895
896 break;
897 }
899 {
900 for (WorldObject* target : targets)
901 {
902 if (IsGameObject(target))
903 {
904 target->ToGameObject()->ResetDoorOrButton();
905 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject {} (entry: {}) reset",
906 target->GetGUID().ToString(), target->GetEntry());
907 }
908 }
909 break;
910 }
912 {
913 for (WorldObject* target : targets)
914 {
915 if (IsUnit(target))
916 {
917 target->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
918 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit {} set emotestate to {}",
919 target->GetGUID().ToString(), e.action.emote.emote);
920 }
921 }
922 break;
923 }
925 {
926 for (WorldObject* target : targets)
927 {
928 if (IsUnit(target))
929 {
930 if (!e.action.unitFlag.type)
931 {
932 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
933 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS",
934 target->GetGUID().ToString(), e.action.unitFlag.flag);
935 }
936 else
937 {
938 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
939 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS_2",
940 target->GetGUID().ToString(), e.action.unitFlag.flag);
941 }
942 }
943 }
944 break;
945 }
947 {
948 for (WorldObject* target : targets)
949 {
950 if (IsUnit(target))
951 {
952 if (!e.action.unitFlag.type)
953 {
954 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
955 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS",
956 target->GetGUID().ToString(), e.action.unitFlag.flag);
957 }
958 else
959 {
960 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
961 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS_2",
962 target->GetGUID().ToString(), e.action.unitFlag.flag);
963 }
964 }
965 }
966 break;
967 }
969 {
970 if (!IsSmart())
971 break;
972
973 CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack);
974 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
976 break;
977 }
979 {
980 if (!IsSmart())
981 break;
982
983 bool move = e.action.combatMove.move;
984 CAST_AI(SmartAI, me->AI())->SetCombatMovement(move, true);
985 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature {} bool on = {}",
987 break;
988 }
990 {
991 if (!GetBaseObject())
992 break;
993
995 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature {} set event phase {}",
997 break;
998 }
1000 {
1001 if (!GetBaseObject())
1002 break;
1003
1006 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature {} inc event phase by {}, "
1007 "decrease by {}", GetBaseObject()->GetGUID().ToString(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
1008 break;
1009 }
1010 case SMART_ACTION_EVADE:
1011 {
1012 if (!GetBaseObject())
1013 break;
1014
1015 for (WorldObject* target : targets)
1016 if (IsCreature(target))
1017 if (target->ToCreature()->IsAIEnabled)
1018 target->ToCreature()->AI()->EnterEvadeMode();
1019
1020 break;
1021 }
1023 {
1024 // Xinef: do not allow to flee without control (stun, fear etc)
1026 break;
1027
1029 if (e.action.flee.withEmote)
1030 {
1032 sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
1033 }
1034 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature {} DoFleeToGetAssistance", me->GetGUID().ToString());
1035 break;
1036 }
1038 {
1039 if (!me)
1040 break;
1041
1042 // Suppress evade during script-initiated combat stop so
1043 // JustExitedCombat does not trigger EnterEvadeMode.
1044 if (SmartAI* sai = CAST_AI(SmartAI, me->AI()))
1045 sai->SetSuppressEvade(true);
1046
1047 me->CombatStop(true);
1048
1049 if (SmartAI* sai = CAST_AI(SmartAI, me->AI()))
1050 sai->SetSuppressEvade(false);
1051
1052 break;
1053 }
1055 {
1056 for (WorldObject* target : targets)
1057 {
1058 if (!IsUnit(target))
1059 continue;
1060
1061 Unit* unitTarget = target->ToUnit();
1062 // If invoker was pet or charm
1063 Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself();
1064 if (player && GetBaseObject())
1065 {
1066 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1067 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {}, group credit for quest {}",
1068 player->GetGUID().ToString(), e.action.quest.quest);
1069 }
1070
1071 // Special handling for vehicles
1072 if (Vehicle* vehicle = unitTarget->GetVehicleKit())
1073 {
1074 for (auto& Seat : vehicle->Seats)
1075 {
1076 if (Player* player = ObjectAccessor::GetPlayer(*unitTarget, Seat.second.Passenger.Guid))
1077 {
1078 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
1079 }
1080 }
1081 }
1082 }
1083 break;
1084 }
1086 {
1087 for (WorldObject* target : targets)
1088 {
1089 if (!IsUnit(target))
1090 continue;
1091
1092 if (e.action.removeAura.spell)
1093 {
1095 {
1096 if (Aura* aur = target->ToUnit()->GetAura(e.action.removeAura.spell))
1097 aur->ModCharges(-static_cast<int32>(e.action.removeAura.charges), AURA_REMOVE_BY_EXPIRE);
1098 }
1099 else
1100 target->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
1101 }
1102 else
1103 target->ToUnit()->RemoveAllAuras();
1104
1105 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {}, spell {}",
1106 target->GetGUID().ToString(), e.action.removeAura.spell);
1107 }
1108 break;
1109 }
1111 {
1112 if (!IsSmart())
1113 break;
1114
1116 {
1117 CAST_AI(SmartAI, me->AI())->StopFollow(false);
1118 break;
1119 }
1120
1121 for (WorldObject* target : targets)
1122 {
1123 if (IsUnit(target))
1124 {
1125 float angle = e.action.follow.angle > 6 ? (e.action.follow.angle * M_PI / 180.0f) : e.action.follow.angle;
1126 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);
1127 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature {} following target {}",
1128 me->GetGUID().ToString(), target->GetGUID().ToString());
1129 break;
1130 }
1131 }
1132 break;
1133 }
1135 {
1136 if (!GetBaseObject())
1137 break;
1138
1139 std::vector<uint32> phases;
1140 std::copy_if(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(),
1141 std::back_inserter(phases), [](uint32 phase) { return phase != 0; });
1142
1144 SetPhase(phase);
1145 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature {} sets event phase to {}",
1146 GetBaseObject()->GetGUID().ToString(), phase);
1147 break;
1148 }
1150 {
1151 if (!GetBaseObject())
1152 break;
1153
1155 SetPhase(phase);
1156 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature {} sets event phase to {}",
1157 GetBaseObject()->GetGUID().ToString(), phase);
1158 break;
1159 }
1161 {
1162 if (trigger && IsPlayer(unit))
1163 {
1165 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player {}, Killcredit: {}",
1167 }
1168 else if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members
1169 {
1170 if (!me)
1171 break;
1172
1173 if (Player* player = me->GetLootRecipient())
1174 {
1176 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1178 }
1179 }
1180 else // Specific target type
1181 {
1182 for (WorldObject* target : targets)
1183 {
1184 if (!IsUnit(target))
1185 continue;
1186
1188 if (!player)
1189 continue;
1190
1192 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1193 target->GetGUID().ToString(), e.action.killedMonster.creature);
1194 }
1195 }
1196 break;
1197 }
1199 {
1200 WorldObject* obj = GetBaseObject();
1201 if (!obj)
1202 obj = unit;
1203
1204 if (!obj)
1205 break;
1206
1207 InstanceScript* instance = obj->GetInstanceScript();
1208 if (!instance)
1209 {
1210 LOG_ERROR("scripts.ai.sai", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1211 break;
1212 }
1213
1214 switch (e.action.setInstanceData.type)
1215 {
1216 case 0:
1217 {
1219 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: Field: {}, data: {}", e.action.setInstanceData.field, e.action.setInstanceData.data);
1220 } break;
1221 case 1:
1222 {
1224 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));
1225 } break;
1226 default:
1227 {
1228 break;
1229 }
1230 }
1231 break;
1232 }
1234 {
1235 WorldObject* obj = GetBaseObject();
1236 if (!obj)
1237 obj = unit;
1238
1239 if (!obj)
1240 break;
1241
1242 InstanceScript* instance = obj->GetInstanceScript();
1243 if (!instance)
1244 {
1245 LOG_ERROR("sql.sql", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1246 break;
1247 }
1248
1249 if (targets.empty())
1250 break;
1251
1252 instance->SetGuidData(e.action.setInstanceData64.field, targets.front()->GetGUID());
1253 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: {}, data: {}",
1254 e.action.setInstanceData64.field, targets.front()->GetGUID().ToString());
1255 break;
1256 }
1258 {
1259 for (WorldObject* target : targets)
1260 if (IsCreature(target))
1261 target->ToCreature()->UpdateEntry(e.action.updateTemplate.creature, target->ToCreature()->GetCreatureData(), e.action.updateTemplate.updateLevel != 0);
1262 break;
1263 }
1264 case SMART_ACTION_DIE:
1265 {
1266 if (e.action.die.milliseconds)
1267 {
1268 if (me && !me->isDead())
1269 {
1271 {
1272 // We need to check again to see if we didn't die in the process.
1273 if (me && !me->isDead())
1274 {
1275 me->KillSelf();
1276 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1277 }
1279 }
1280 }
1281 else if (me && !me->isDead())
1282 {
1283 me->KillSelf();
1284 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1285 }
1286 break;
1287 }
1289 {
1290 if (targets.empty())
1291 break;
1292
1293 if (!me->GetMap()->IsDungeon())
1294 {
1295 ObjectVector units;
1296 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
1297
1298 if (!units.empty() && GetBaseObject())
1299 for (WorldObject* unit : units)
1300 if (IsPlayer(unit) && !unit->ToPlayer()->isDead())
1301 {
1302 me->EngageWithTarget(unit->ToPlayer());
1303 }
1304 }
1305 else
1306 {
1307 for (WorldObject* target : targets)
1308 {
1309 if (IsCreature(target))
1310 {
1311 target->ToCreature()->SetInCombatWithZone();
1312 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature {}, target: {}",
1313 me->GetGUID().ToString(), target->GetGUID().ToString());
1314 }
1315 }
1316 }
1317
1318 break;
1319 }
1321 {
1322 for (WorldObject* target : targets)
1323 {
1324 if (IsCreature(target))
1325 {
1326 target->ToCreature()->CallForHelp(float(e.action.callHelp.range));
1328 {
1330 sCreatureTextMgr->SendChatPacket(target, builder, CHAT_MSG_MONSTER_EMOTE);
1331 }
1332 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature {}, target: {}",
1333 me->GetGUID().ToString(), target->GetGUID().ToString());
1334 }
1335 }
1336 break;
1337 }
1339 {
1340 if (me)
1341 {
1343 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature {}, State: {}",
1345 }
1346 break;
1347 }
1349 {
1350 for (WorldObject* target : targets)
1351 {
1353 {
1355 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_FORCE_DESPAWN has removeObjectFromWorld set. delay and forceRespawnTimer ignored.");
1356
1357 if (Creature* creature = target->ToCreature())
1358 creature->AddObjectToRemoveList();
1359 else if (GameObject* go = target->ToGameObject())
1361 }
1362 else
1363 {
1364 Milliseconds despawnDelay(e.action.forceDespawn.delay);
1365
1366 // Wait at least one world update tick before despawn, so it doesn't break linked actions.
1367 if (despawnDelay <= 0ms)
1368 despawnDelay = 1ms;
1369
1370 Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
1371 if (Creature* creature = target->ToCreature())
1372 creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1373 else if (GameObject* go = target->ToGameObject())
1374 go->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1375 }
1376 }
1377
1378 break;
1379 }
1381 {
1382 for (WorldObject* target : targets)
1383 {
1384 if (IsUnit(target))
1385 target->ToUnit()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1386 else if (IsGameObject(target))
1387 target->ToGameObject()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1388 }
1389 break;
1390 }
1392 {
1393 for (WorldObject* target : targets)
1394 {
1395 if (!IsUnit(target))
1396 continue;
1397
1399 {
1400 if (e.action.morphOrMount.creature > 0)
1401 {
1402 if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
1403 target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo)->CreatureDisplayID);
1404 }
1405 else
1406 target->ToUnit()->Mount(e.action.morphOrMount.model);
1407 }
1408 else
1409 target->ToUnit()->Dismount();
1410 }
1411 break;
1412 }
1414 {
1415 for (WorldObject* target : targets)
1416 {
1417 if (IsCreature(target))
1418 {
1419 SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI());
1420 if (!ai)
1421 continue;
1422
1423 if (e.action.invincHP.percent)
1424 ai->SetInvincibilityHpLevel(target->ToCreature()->CountPctFromMaxHealth(e.action.invincHP.percent));
1425 else
1427 }
1428 }
1429 break;
1430 }
1432 {
1433 for (WorldObject* target : targets)
1434 {
1435 if (Creature* cTarget = target->ToCreature())
1436 {
1437 CreatureAI* ai = cTarget->AI();
1438 // Make sure we check that the sender is either a creature or gameobject
1439 if (IsSmart(cTarget, true) && (me || go))
1440 {
1441 if (me)
1443 else
1444 ENSURE_AI(SmartAI, ai)->SetData(e.action.setData.field, e.action.setData.data, go);
1445 }
1446 else
1448 }
1449 else if (GameObject* oTarget = target->ToGameObject())
1450 {
1451 GameObjectAI* ai = oTarget->AI();
1452 // Make sure we check that the sender is either a creature or gameobject
1453 if (IsSmart(oTarget, true) && (me || go))
1454 {
1455 if (me)
1457 else
1459 }
1460 else
1462 }
1463 }
1464 break;
1465 }
1467 {
1468 if (!me)
1469 break;
1470
1471 float x, y, z;
1472 me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance);
1474 break;
1475 }
1477 {
1478 if (!me)
1479 break;
1480
1482 break;
1483 }
1485 {
1486 for (WorldObject* target : targets)
1487 if (IsUnit(target))
1488 target->ToUnit()->SetVisible(e.action.visibility.state);
1489
1490 break;
1491 }
1493 {
1494 for (WorldObject* target : targets)
1495 target->setActive(e.action.setActive.state);
1496 break;
1497 }
1499 {
1500 if (!me)
1501 break;
1502
1503 if (targets.empty())
1504 break;
1505
1506 // attack random target
1507 if (Unit* target = Acore::Containers::SelectRandomContainerElement(targets)->ToUnit())
1508 me->AI()->AttackStart(target);
1509 break;
1510 }
1512 {
1513 for (WorldObject* target : targets)
1514 if (Unit* unitTarget = target->ToUnit())
1515 unitTarget->AttackStop();
1516 break;
1517 }
1519 {
1521 bool preferUnit = flags.HasFlag(SmartActionSummonCreatureFlags::PreferUnit);
1522 WorldObject* summoner = preferUnit ? unit : Coalesce<WorldObject>(GetBaseObject(), unit);
1523 if (!summoner)
1524 break;
1525
1526 bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
1527
1529 {
1530 float range = (float)e.target.randomPoint.range;
1531 Position randomPoint;
1532 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1533 for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
1534 {
1535 if (e.target.randomPoint.self > 0)
1536 randomPoint = me->GetRandomPoint(me->GetPosition(), range);
1537 else
1538 randomPoint = me->GetRandomPoint(srcPos, range);
1539 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, 0, nullptr, personalSpawn))
1540 {
1541 if (unit && e.action.summonCreature.attackInvoker)
1542 summon->AI()->AttackStart(unit);
1544 summon->AI()->AttackStart(me);
1545 }
1546 }
1547 break;
1548 }
1549
1550 float x, y, z, o;
1551 for (WorldObject* target : targets)
1552 {
1553 target->GetPosition(x, y, z, o);
1554 x += e.target.x;
1555 y += e.target.y;
1556 z += e.target.z;
1557 o += e.target.o;
1558 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, nullptr, personalSpawn))
1559 {
1560 if (e.action.summonCreature.attackInvoker == 2) // pussywizard: proper attackInvoker implementation
1561 summon->AI()->AttackStart(unit);
1563 summon->AI()->AttackStart(target->ToUnit());
1565 summon->AI()->AttackStart(me);
1566 }
1567 }
1568
1570 break;
1571
1573 {
1574 if (unit && e.action.summonCreature.attackInvoker)
1575 summon->AI()->AttackStart(unit);
1577 summon->AI()->AttackStart(me);
1578 }
1579 break;
1580 }
1582 {
1583 if (!GetBaseObject())
1584 break;
1585
1586 if (!targets.empty())
1587 {
1588 float x, y, z, o;
1589 for (WorldObject* target : targets)
1590 {
1591 // xinef: allow gameobjects to summon gameobjects!
1592 //if (!IsUnit((*itr)))
1593 // continue;
1594
1595 target->GetPosition(x, y, z, o);
1596 x += e.target.x;
1597 y += e.target.y;
1598 z += e.target.z;
1599 o += e.target.o;
1602 else
1603 target->SummonGameObject(e.action.summonGO.entry, GetBaseObject()->GetPositionX(), GetBaseObject()->GetPositionY(), GetBaseObject()->GetPositionZ(), GetBaseObject()->GetOrientation(), 0, 0, 0, 0, e.action.summonGO.despawnTime);
1604 }
1605 }
1606
1608 break;
1609
1611 break;
1612 }
1614 {
1615 for (WorldObject* target : targets)
1616 {
1617 if (!IsUnit(target))
1618 continue;
1619
1620 Unit::Kill(target->ToUnit(), target->ToUnit());
1621 }
1622
1623 break;
1624 }
1626 {
1627 InstallTemplate(e);
1628 break;
1629 }
1631 {
1632 for (WorldObject* target : targets)
1633 {
1634 if (!IsPlayer(target))
1635 continue;
1636
1637 target->ToPlayer()->AddItem(e.action.item.entry, e.action.item.count);
1638 }
1639 break;
1640 }
1642 {
1643 for (WorldObject* target : targets)
1644 {
1645 if (!IsPlayer(target))
1646 continue;
1647
1648 target->ToPlayer()->DestroyItemCount(e.action.item.entry, e.action.item.count, true);
1649 }
1650 break;
1651 }
1653 {
1655 break;
1656 }
1658 {
1659 for (WorldObject* target : targets)
1660 {
1661 if (IsPlayer(target))
1662 target->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
1663 else if (IsCreature(target))
1664 target->ToCreature()->NearTeleportTo(e.target.x, e.target.y, e.target.z, e.target.o);
1665 }
1666 break;
1667 }
1669 {
1670 if (!IsSmart())
1671 break;
1672
1673 CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly);
1674 // Xinef: Set speed if any
1675 if (e.action.setFly.speed)
1676 me->SetSpeed(MOVE_RUN, float(e.action.setFly.speed / 100.0f), true);
1677
1678 // Xinef: this wil be executed only if state is different
1680 break;
1681 }
1683 {
1684 for (WorldObject* target : targets)
1685 {
1686 if (IsCreature(target))
1687 {
1688 target->ToCreature()->SetWalk(e.action.setRun.run ? false : true);
1689 }
1690 }
1691
1692 break;
1693 }
1695 {
1696 if (!IsSmart())
1697 break;
1698
1699 CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim);
1700 break;
1701 }
1703 {
1704 if (!targets.empty())
1705 {
1706 for (WorldObject* target : targets)
1707 {
1708 if (IsCreature(target))
1709 {
1710 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
1712 else
1713 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
1714 }
1715 else if (IsGameObject(target))
1716 {
1717 if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, target->ToGameObject()->AI()))
1719 else
1720 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
1721 }
1722 }
1723 }
1724 else
1726 break;
1727 }
1729 {
1730 if (!IsSmart())
1731 break;
1732
1733 ForcedMovement forcedMovement = static_cast<ForcedMovement>(e.action.wpStart.forcedMovement);
1734 uint32 entry = e.action.wpStart.pathID;
1735 bool repeat = e.action.wpStart.repeat != 0;
1736
1737 for (WorldObject* target : targets)
1738 {
1739 if (IsPlayer(target))
1740 {
1742 break;
1743 }
1744 }
1745
1747 CAST_AI(SmartAI, me->AI())->StartPath(forcedMovement, entry, repeat, unit);
1748
1749 uint32 quest = e.action.wpStart.quest;
1750 uint32 DespawnTime = e.action.wpStart.despawnTime;
1751 CAST_AI(SmartAI, me->AI())->mEscortQuestID = quest;
1752 CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
1753 break;
1754 }
1756 {
1757 if (!IsSmart())
1758 break;
1759
1760 uint32 delay = e.action.wpPause.delay;
1761 CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_ESCORT_REACHED ? false : true);
1762 break;
1763 }
1765 {
1766 if (!IsSmart())
1767 break;
1768
1769 uint32 DespawnTime = e.action.wpStop.despawnTime;
1770 uint32 quest = e.action.wpStop.quest;
1771 bool fail = e.action.wpStop.fail;
1772 CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
1773 break;
1774 }
1776 {
1777 if (!IsSmart())
1778 break;
1779
1780 CAST_AI(SmartAI, me->AI())->SetWPPauseTimer(0);
1781 break;
1782 }
1784 {
1785 if (!me)
1786 break;
1787
1788 if (e.action.orientation.random > 0)
1789 {
1790 float randomOri = frand(0.0f, 2 * M_PI);
1791 me->SetFacingTo(randomOri);
1793 me->SetOrientation(randomOri);
1794 break;
1795 }
1796
1798 {
1799 float turnOri = me->GetOrientation() + (static_cast<float>(e.action.orientation.turnAngle) * M_PI / 180.0f);
1800 me->SetFacingTo(turnOri);
1802 me->SetOrientation(turnOri);
1803 break;
1804 }
1805
1807 {
1811 }
1812 else if (e.GetTargetType() == SMART_TARGET_POSITION)
1813 {
1814 me->SetFacingTo(e.target.o);
1817 }
1818 else if (!targets.empty())
1819 {
1820 me->SetFacingToObject(*targets.begin());
1822 me->SetInFront(*targets.begin());
1823 }
1824
1825 break;
1826 }
1828 {
1829 for (WorldObject* target : targets)
1830 {
1831 if (!IsPlayer(target))
1832 continue;
1833
1834 target->ToPlayer()->SendMovieStart(e.action.movie.entry);
1835 }
1836 break;
1837 }
1839 {
1840 if (!IsSmart())
1841 break;
1842
1843 WorldObject* target = nullptr;
1844
1846
1847 switch (e.GetTargetType())
1848 {
1850 {
1851 G3D::Vector3 dest(e.target.x, e.target.y, e.target.z);
1853 if (TransportBase* trans = me->GetDirectTransport())
1854 trans->CalculatePassengerPosition(dest.x, dest.y, dest.z);
1855
1857 0.f, e.target.o, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1858
1859 break;
1860 }
1862 {
1863 if (me)
1864 {
1865 float range = (float)e.target.randomPoint.range;
1866 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1867 Position randomPoint = me->GetRandomPoint(srcPos, range);
1870 randomPoint.m_positionX,
1871 randomPoint.m_positionY,
1872 randomPoint.m_positionZ,
1874 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE
1875 );
1876
1877 }
1878
1879 break;
1880 }
1881 // Can use target floats as offset
1882 default:
1883 {
1884 // we want to move to random element
1885 if (targets.empty())
1886 return;
1887 else
1889
1890 float x, y, z;
1891 target->GetPosition(x, y, z);
1892
1894 target->GetNearPoint(me, x, y, z, target->GetCombatReach() + e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1895 else if (e.action.moveToPos.ContactDistance)
1896 target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1897
1899 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1900
1901 break;
1902 }
1903 }
1904
1905 break;
1906 }
1908 {
1909 for (WorldObject* target : targets)
1910 {
1911 if (IsCreature(target))
1912 {
1914
1915 Creature* ctarget = target->ToCreature();
1917 0.f, 0.f, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1918 }
1919 }
1920
1921 break;
1922 }
1924 {
1925 for (WorldObject* target : targets)
1926 {
1927 if (IsCreature(target))
1928 target->ToCreature()->Respawn();
1929 else if (IsGameObject(target))
1930 {
1931 // do not modify respawndelay of already spawned gameobjects
1932 if (target->ToGameObject()->isSpawnedByDefault())
1933 target->ToGameObject()->Respawn();
1934 else
1936 }
1937 }
1938 break;
1939 }
1941 {
1942 for (WorldObject* target : targets)
1943 if (IsPlayer(target))
1944 target->ToPlayer()->PlayerTalkClass->SendCloseGossip();
1945 break;
1946 }
1947 case SMART_ACTION_EQUIP:
1948 {
1949 for (WorldObject* target : targets)
1950 {
1951 if (Creature* npc = target->ToCreature())
1952 {
1953 std::array<uint32, MAX_EQUIPMENT_ITEMS> slot;
1954 if (int8 equipId = static_cast<int8>(e.action.equip.entry))
1955 {
1956 EquipmentInfo const* eInfo = sObjectMgr->GetEquipmentInfo(npc->GetEntry(), equipId);
1957 if (!eInfo)
1958 {
1959 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id {} for creature {}", equipId, npc->GetEntry());
1960 break;
1961 }
1962
1963 npc->SetCurrentEquipmentId(equipId);
1964
1965 std::copy(std::begin(eInfo->ItemEntry), std::end(eInfo->ItemEntry), std::begin(slot));
1966 }
1967 else
1968 std::copy(std::begin(e.action.equip.slots), std::end(e.action.equip.slots), std::begin(slot));
1969
1970 for (uint32 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1971 if (!e.action.equip.mask || (e.action.equip.mask & (1 << i)))
1972 npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, slot[i]);
1973 }
1974 }
1975 break;
1976 }
1978 {
1979 SmartEvent ne = SmartEvent();
1982 if (!ne.event_chance) ne.event_chance = 100;
1983
1988
1989 ne.event_flags = 0;
1992
1993 SmartAction ac = SmartAction();
1996
1998 ev.event = ne;
1999 ev.event_id = e.action.timeEvent.id;
2000 ev.target = e.target;
2001 ev.action = ac;
2002 InitTimer(ev);
2003 mStoredEvents.push_back(ev);
2004 break;
2005 }
2008
2009 // xinef: remove this event if not repeatable
2011 mRemIDs.push_back(e.action.timeEvent.id);
2012 break;
2014 mRemIDs.push_back(e.action.timeEvent.id);
2015 break;
2017 {
2018 for (WorldObject* target : targets)
2019 {
2020 if (IsCreature(target))
2021 {
2022 if (!meOrigGUID)
2024 if (!goOrigGUID)
2026 go = nullptr;
2027 me = target->ToCreature();
2028 break;
2029 }
2030 else if (IsGameObject(target))
2031 {
2032 if (!meOrigGUID)
2034 if (!goOrigGUID)
2036 go = target->ToGameObject();
2037 me = nullptr;
2038 break;
2039 }
2040 }
2041
2042 break;
2043 }
2046 break;
2048 OnReset();
2049 break;
2051 {
2052 if (!IsSmart())
2053 break;
2054
2055 float attackDistance = float(e.action.setRangedMovement.distance);
2056 float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI);
2057
2058 for (WorldObject* target : targets)
2059 if (Creature* creature = target->ToCreature())
2060 if (IsSmart(creature) && creature->GetVictim())
2061 if (!creature->HasUnitState(UNIT_STATE_NO_COMBAT_MOVEMENT))
2062 creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, attackAngle);
2063
2064 break;
2065 }
2067 {
2069 {
2070 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2071 break;
2072 }
2073
2074 for (WorldObject* target : targets)
2075 {
2076 if (Creature* creature = target->ToCreature())
2077 {
2078 if (IsSmart(creature))
2079 CAST_AI(SmartAI, creature->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
2080 }
2081 else if (GameObject* go = target->ToGameObject())
2082 {
2083 if (IsSmart(go))
2085 }
2086 }
2087 break;
2088 }
2090 {
2091 for (WorldObject* target : targets)
2092 if (IsCreature(target))
2093 target->ToUnit()->ReplaceAllNpcFlags(NPCFlags(e.action.unitFlag.flag));
2094 break;
2095 }
2097 {
2098 for (WorldObject* target : targets)
2099 if (IsCreature(target))
2100 target->ToUnit()->SetNpcFlag(NPCFlags(e.action.unitFlag.flag));
2101 break;
2102 }
2104 {
2105 for (WorldObject* target : targets)
2106 if (IsCreature(target))
2107 target->ToUnit()->RemoveNpcFlag(NPCFlags(e.action.unitFlag.flag));
2108 break;
2109 }
2111 {
2112 if (targets.empty())
2113 break;
2114
2115 ObjectVector casters;
2117
2118 for (WorldObject* caster : casters)
2119 {
2120 if (!IsUnit(caster))
2121 continue;
2122
2123 Unit* casterUnit = caster->ToUnit();
2124
2125 bool interruptedSpell = false;
2126
2127 for (WorldObject* target : targets)
2128 {
2129 if (!IsUnit(target))
2130 continue;
2131
2133 {
2134 if (!interruptedSpell && e.action.crossCast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
2135 {
2136 casterUnit->InterruptNonMeleeSpells(false);
2137 interruptedSpell = true;
2138 }
2139
2140 casterUnit->CastSpell(target->ToUnit(), e.action.crossCast.spell, (e.action.crossCast.flags & SMARTCAST_TRIGGERED) != 0);
2141 }
2142 else
2143 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target ({}) already has the aura", e.action.crossCast.spell, target->GetGUID().ToString());
2144 }
2145 }
2146 break;
2147 }
2149 {
2150 std::vector<uint32> actionLists;
2152 std::back_inserter(actionLists), [](uint32 actionList) { return actionList != 0; });
2153
2156 {
2157 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2158 break;
2159 }
2160
2161 for (WorldObject* target : targets)
2162 {
2163 if (Creature* creature = target->ToCreature())
2164 {
2165 if (IsSmart(creature))
2166 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2167 }
2168 else if (GameObject* go = target->ToGameObject())
2169 {
2170 if (IsSmart(go))
2171 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2172 }
2173 }
2174 break;
2175 }
2177 {
2180 {
2181 LOG_ERROR("sql.sql", "SmartScript: Entry {} SourceType {} Event {} Action {} is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
2182 break;
2183 }
2184
2185 for (WorldObject* target : targets)
2186 {
2187 if (Creature* creature = target->ToCreature())
2188 {
2189 if (IsSmart(creature))
2190 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2191 }
2192 else if (GameObject* go = target->ToGameObject())
2193 {
2194 if (IsSmart(go))
2195 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2196 }
2197 }
2198 break;
2199 }
2201 {
2202 for (WorldObject* target : targets)
2203 if (IsPlayer(target))
2204 target->ToPlayer()->ActivateTaxiPathTo(e.action.taxi.id);
2205 break;
2206 }
2208 {
2209 bool foundTarget = false;
2210
2211 for (WorldObject* target : targets)
2212 {
2213 if (IsCreature((target)))
2214 {
2215 foundTarget = true;
2216
2219 else
2220 target->ToCreature()->GetMotionMaster()->MoveIdle();
2221 }
2222 }
2223
2224 if (!foundTarget && me && IsCreature(me) && me->IsAlive())
2225 {
2228 else
2230 }
2231 break;
2232 }
2234 {
2235 for (WorldObject* target : targets)
2236 if (IsUnit(target))
2237 target->ToUnit()->SetByteFlag(UNIT_FIELD_BYTES_1, e.action.setunitByte.type, e.action.setunitByte.byte1);
2238 break;
2239 }
2241 {
2242 for (WorldObject* target : targets)
2243 if (IsUnit(target))
2244 target->ToUnit()->RemoveByteFlag(UNIT_FIELD_BYTES_1, e.action.delunitByte.type, e.action.delunitByte.byte1);
2245 break;
2246 }
2248 {
2249 for (WorldObject* target : targets)
2250 if (IsUnit(target))
2251 target->ToUnit()->InterruptNonMeleeSpells(e.action.interruptSpellCasting.withDelayed != 0, e.action.interruptSpellCasting.spell_id, e.action.interruptSpellCasting.withInstant != 0);
2252 break;
2253 }
2255 {
2256 for (WorldObject* target : targets)
2257 if (IsGameObject(target))
2258 target->ToGameObject()->SendCustomAnim(e.action.sendGoCustomAnim.anim);
2259 break;
2260 }
2262 {
2263 for (WorldObject* target : targets)
2264 if (IsUnit(target))
2265 target->ToUnit()->SetUInt32Value(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2266 break;
2267 }
2269 {
2270 for (WorldObject* target : targets)
2271 if (IsUnit(target))
2272 target->ToUnit()->SetFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2273 break;
2274 }
2276 {
2277 for (WorldObject* target : targets)
2278 if (IsUnit(target))
2279 target->ToUnit()->RemoveFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
2280 break;
2281 }
2283 {
2285 {
2286 if (me)
2287 {
2288 float range = (float)e.target.randomPoint.range;
2289 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
2290 Position randomPoint = me->GetRandomPoint(srcPos, range);
2291 me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2292 }
2293
2294 break;
2295 }
2296
2297 if (targets.empty())
2298 break;
2299
2300 // xinef: my implementation
2301 if (e.action.jump.selfJump)
2302 {
2304 if (me)
2305 me->GetMotionMaster()->MoveJump(target->GetPositionX() + e.target.x, target->GetPositionY() + e.target.y, target->GetPositionZ() + e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2306 }
2307 else
2308 {
2309 for (WorldObject* target : targets)
2310 if (WorldObject* obj = (target))
2311 {
2312 if (Creature* creature = obj->ToCreature())
2313 creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2314 }
2315 }
2316
2317 break;
2318 }
2320 {
2321 for (WorldObject* target : targets)
2322 if (IsGameObject(target))
2323 target->ToGameObject()->SetLootState((LootState)e.action.setGoLootState.state);
2324 break;
2325 }
2327 {
2328 for (WorldObject* target : targets)
2329 if (IsGameObject(target))
2330 target->ToGameObject()->SetGoState((GOState)e.action.goState.state);
2331 break;
2332 }
2334 {
2335 WorldObject* ref = GetBaseObject();
2336
2337 if (!ref)
2338 ref = unit;
2339
2340 if (!ref)
2341 break;
2342
2343 ObjectVector const* storedTargets = GetStoredTargetVector(e.action.sendTargetToTarget.id, *ref);
2344 if (!storedTargets)
2345 break;
2346
2347 for (WorldObject* target : targets)
2348 {
2349 if (IsCreature(target))
2350 {
2351 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
2352 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2353 else
2354 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
2355 }
2356 else if (IsGameObject(target))
2357 {
2359 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2360 else
2361 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
2362 }
2363 }
2364 break;
2365 }
2367 {
2368 if (!GetBaseObject())
2369 break;
2370
2371 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId {}, gossipNpcTextId {}",
2373
2374 for (WorldObject* target : targets)
2375 if (Player* player = target->ToPlayer())
2376 {
2379 else
2380 ClearGossipMenuFor(player);
2381
2383 }
2384
2385 break;
2386 }
2388 {
2389 if (!targets.empty())
2390 {
2391 float x, y, z, o;
2392 for (WorldObject* target : targets)
2393 if (IsCreature(target))
2394 {
2396 {
2397 target->ToCreature()->GetRespawnPosition(x, y, z, &o);
2398 target->ToCreature()->SetHomePosition(x, y, z, o);
2399 }
2400 else
2401 target->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
2402 }
2403 }
2404 else if (me && e.GetTargetType() == SMART_TARGET_POSITION)
2405 {
2407 {
2408 float x, y, z, o;
2409 me->GetRespawnPosition(x, y, z, &o);
2410 me->SetHomePosition(x, y, z, o);
2411 }
2412 else
2414 }
2415 break;
2416 }
2418 {
2419 for (WorldObject* target : targets)
2420 if (IsCreature(target))
2421 target->ToCreature()->SetRegeneratingHealth(e.action.setHealthRegen.regenHealth);
2422
2423 break;
2424 }
2426 {
2427 for (WorldObject* target : targets)
2428 if (IsCreature(target))
2429 target->ToCreature()->SetControlled(e.action.setRoot.root != 0, UNIT_STATE_ROOT);
2430 break;
2431 }
2433 {
2434 for (WorldObject* target : targets)
2435 if (IsGameObject(target))
2436 target->ToGameObject()->SetUInt32Value(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2437 break;
2438 }
2440 {
2441 for (WorldObject* target : targets)
2442 if (IsGameObject(target))
2443 target->ToGameObject()->SetFlag(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2444 break;
2445 }
2447 {
2448 for (WorldObject* target : targets)
2449 if (IsGameObject(target))
2450 target->ToGameObject()->RemoveFlag(GAMEOBJECT_FLAGS, e.action.goFlag.flag);
2451 break;
2452 }
2454 {
2455 std::list<TempSummon*> summonList;
2457
2458 for (std::list<TempSummon*>::const_iterator itr = summonList.begin(); itr != summonList.end(); ++itr)
2459 {
2460 if (unit && e.action.creatureGroup.attackInvoker)
2461 (*itr)->AI()->AttackStart(unit);
2463 (*itr)->AI()->AttackStart(me);
2464 }
2465
2466 break;
2467 }
2469 {
2470 for (WorldObject* target : targets)
2471 if (IsUnit(target))
2472 target->ToUnit()->SetPower(Powers(e.action.power.powerType), e.action.power.newPower);
2473 break;
2474 }
2476 {
2477 for (WorldObject* target : targets)
2478 if (IsUnit(target))
2479 target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) + e.action.power.newPower);
2480 break;
2481 }
2483 {
2484 for (WorldObject* target : targets)
2485 if (IsUnit(target))
2486 target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) - e.action.power.newPower);
2487 break;
2488 }
2490 {
2491 uint32 eventId = e.action.gameEventStop.id;
2492 if (!sGameEventMgr->IsActiveEvent(eventId))
2493 {
2494 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: {})", eventId);
2495 break;
2496 }
2497 sGameEventMgr->StopEvent(eventId, true);
2498 break;
2499 }
2501 {
2502 uint32 eventId = e.action.gameEventStart.id;
2503 if (sGameEventMgr->IsActiveEvent(eventId))
2504 {
2505 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: {})", eventId);
2506 break;
2507 }
2508 sGameEventMgr->StartEvent(eventId, true);
2509 break;
2510 }
2512 {
2513 PathSource pathSource = static_cast<PathSource>(e.action.startClosestWaypoint.pathSource);
2514
2515 if (pathSource != PathSource::WAYPOINT_MGR && pathSource != PathSource::SMART_WAYPOINT_MGR)
2516 {
2517 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_START_CLOSEST_WAYPOINT: Invalid PathSource {} for entryOrGuid {} source_type {} event_id {} link {}",
2518 static_cast<uint32>(pathSource), e.entryOrGuid, e.source_type, e.event_id, e.link);
2519 break;
2520 }
2521
2522 float distanceToClosest = std::numeric_limits<float>::max();
2523 uint32 closestWpId = 0;
2524
2525 for (WorldObject* target : targets)
2526 {
2527 if (Creature* creature = target->ToCreature())
2528 {
2529 if (IsSmart(creature))
2530 {
2531 for (uint32 pathId = e.action.startClosestWaypoint.pathId1; pathId <= e.action.startClosestWaypoint.pathId2; ++pathId)
2532 {
2533 WaypointPath const* path = nullptr;
2534
2535 switch (pathSource)
2536 {
2538 path = sSmartWaypointMgr->GetPath(pathId);
2539 break;
2541 path = sWaypointMgr->GetPath(pathId);
2542 break;
2543 }
2544
2545 if (!path || path->Nodes.empty())
2546 continue;
2547
2548 {
2549 WaypointNode const& wpData = path->Nodes[0];
2550 float distToThisPath = creature->GetExactDistSq(wpData.X, wpData.Y, wpData.Z);
2551
2552 if (distToThisPath < distanceToClosest)
2553 {
2554 distanceToClosest = distToThisPath;
2555 closestWpId = pathId;
2556 }
2557 }
2558 }
2559
2560 if (closestWpId)
2561 {
2562 bool repeat = e.action.startClosestWaypoint.repeat;
2564
2565 CAST_AI(SmartAI, creature->AI())->StartPath(forcedMovement, closestWpId, repeat, nullptr, pathSource);
2566 }
2567 }
2568 }
2569 }
2570 break;
2571 }
2573 {
2574 for (WorldObject* target : targets)
2575 if (IsUnit(target))
2576 target->ToUnit()->ExitVehicle();
2577
2578 break;
2579 }
2581 {
2582 for (WorldObject* target : targets)
2583 if (IsUnit(target))
2584 {
2586 target->ToUnit()->SendMovementFlagUpdate();
2587 }
2588
2589 break;
2590 }
2592 {
2593 for (WorldObject* target : targets)
2594 if (IsCreature(target))
2595 target->ToCreature()->m_CombatDistance = e.action.combatDistance.dist;
2596
2597 break;
2598 }
2600 {
2601 for (WorldObject* const target : targets)
2602 if (IsCreature(target))
2603 target->ToCreature()->m_SightDistance = e.action.sightDistance.dist;
2604 break;
2605 }
2606 case SMART_ACTION_FLEE:
2607 {
2608 for (WorldObject* const target : targets)
2609 if (IsCreature(target))
2610 target->ToCreature()->GetMotionMaster()->MoveFleeing(me, e.action.flee.withEmote);
2611 break;
2612 }
2614 {
2615 if (!me->CanHaveThreatList())
2616 break;
2617 for (WorldObject* const target : targets)
2618 if (IsUnit(target))
2619 me->GetThreatMgr().AddThreat(target->ToUnit(), float(e.action.threat.threatINC) - float(e.action.threat.threatDEC), nullptr, true, true);
2620 break;
2621 }
2623 {
2624 for (WorldObject* const target : targets)
2625 if (IsCreature(target))
2626 target->ToCreature()->LoadEquipment(e.action.loadEquipment.id, e.action.loadEquipment.force != 0);
2627 break;
2628 }
2630 {
2633 break;
2634 }
2636 {
2637 for (WorldObject* const target : targets)
2638 if (IsUnit(target))
2639 target->ToUnit()->Dismount();
2640 break;
2641 }
2643 {
2644 for (WorldObject* target : targets)
2645 if (IsUnit(target))
2646 target->ToUnit()->SetHover(e.action.setHover.state);
2647 break;
2648 }
2650 {
2651 for (WorldObject* target : targets)
2652 if (IsUnit(target))
2653 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, true);
2654
2655 break;
2656 }
2658 {
2659 for (WorldObject* target : targets)
2660 if (IsUnit(target))
2661 target->ToUnit()->ApplySpellImmune(e.action.immunity.id, e.action.immunity.type, e.action.immunity.value, false);
2662 break;
2663 }
2664 case SMART_ACTION_FALL:
2665 {
2666 for (WorldObject* target : targets)
2667 if (IsUnit(target))
2668 target->ToUnit()->GetMotionMaster()->MoveFall();
2669
2670 break;
2671 }
2673 {
2675 break;
2676 }
2678 {
2679 for (WorldObject* const target : targets)
2680 if (IsUnit(target))
2681 target->ToUnit()->RemoveAllGameObjects();
2682 break;
2683 }
2685 {
2686 for (WorldObject* const target : targets)
2687 {
2688 if (IsUnit(target))
2689 {
2691 target->ToUnit()->StopMoving();
2693 target->ToUnit()->GetMotionMaster()->MovementExpired();
2694 }
2695 }
2696 break;
2697 }
2699 {
2700 for (WorldObject* target : targets)
2701 if (IsUnit(target))
2702 target->ToUnit()->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
2703
2704 break;
2705 }
2707 {
2708 for (WorldObject* target : targets)
2709 if (IsUnit(target))
2710 if (Player* player = target->ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself())
2711 {
2713 break;
2714 }
2715
2716 break;
2717 }
2719 {
2720 if (me && me->FindMap())
2721 me->FindMap()->LoadGrid(e.target.x, e.target.y);
2722 else if (go && go->FindMap())
2723 go->FindMap()->LoadGrid(e.target.x, e.target.y);
2724 break;
2725 }
2727 {
2728 std::string text = sObjectMgr->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE);
2729
2730 if (!targets.empty())
2731 for (WorldObject* target : targets)
2732 if (IsPlayer(target))
2733 !e.action.playerTalk.flag ? target->ToPlayer()->Say(text, LANG_UNIVERSAL) : target->ToPlayer()->Yell(text, LANG_UNIVERSAL);
2734
2735 break;
2736 }
2738 {
2739 if (!me)
2740 break;
2741
2742 for (WorldObject* target : targets)
2743 {
2744 if (IsUnit(target))
2745 {
2747 {
2749 }
2750
2752 {
2753 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.castCustom.spell);
2754 CustomSpellValues values;
2755 if (e.action.castCustom.bp1)
2757 if (e.action.castCustom.bp2)
2759 if (e.action.castCustom.bp3)
2762
2763 float spellMaxRange = me->GetSpellMaxRangeForTarget(target->ToUnit(), spellInfo);
2765 {
2766 // 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.
2767 if (result == SPELL_FAILED_OUT_OF_RANGE || result == SPELL_CAST_OK)
2768 // if we are just out of range, we only chase until we are back in spell range.
2769 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(true, std::max(spellMaxRange - NOMINAL_MELEE_RANGE, 0.0f));
2770 else // move into melee on any other fail
2771 // if spell fail for any other reason, we chase to melee range, or stay where we are if spellcast was successful.
2772 CAST_AI(SmartAI, me->AI())->SetCurrentRangeMode(false, 0.f);
2773 }
2774 }
2775 }
2776 }
2777 break;
2778 }
2780 {
2781 if (!me)
2782 break;
2783
2784 if (targets.empty())
2785 break;
2786
2788
2789 float a = static_cast<float>(e.action.summonVortex.a);
2790 float k = static_cast<float>(e.action.summonVortex.k) / 1000.0f;
2791 float r_max = static_cast<float>(e.action.summonVortex.r_max);
2792 float delta_phi = M_PI * static_cast<float>(e.action.summonVortex.phi_delta) / 180.0f;
2793
2794 // r(phi) = a * e ^ (k * phi)
2795 // r(phi + delta_phi) = a * e ^ (k * (phi + delta_phi))
2796 // r(phi + delta_phi) = a * e ^ (k * phi) * e ^ (k * delta_phi)
2797 // r(phi + delta_phi) = r(phi) * e ^ (k * delta_phi)
2798 float factor = std::exp(k * delta_phi);
2799
2800 // r(0) = a * e ^ (k * 0) = a * e ^ 0 = a * 1 = a
2801 float summonRadius = a;
2802
2803 for (WorldObject* target : targets)
2804 {
2805 // Offset by orientation, should not count into radius calculation,
2806 // but is needed for vortex direction (polar coordinates)
2807 float phi = target->GetOrientation();
2808
2809 do
2810 {
2811 Position summonPosition(*target);
2812 summonPosition.RelocatePolarOffset(phi, summonRadius);
2813
2815
2816 phi += delta_phi;
2817 summonRadius *= factor;
2818 } while (summonRadius <= r_max);
2819 }
2820
2821 break;
2822 }
2824 {
2825 if (!me)
2826 break;
2827
2829
2830 float distInARow = static_cast<float>(e.action.coneSummon.distanceBetweenSummons);
2831 float coneAngle = static_cast<float>(e.action.coneSummon.coneAngle) * M_PI / 180.0f;
2832
2833 for (uint32 radius = 0; radius <= e.action.coneSummon.coneLength; radius += e.action.coneSummon.distanceBetweenRings)
2834 {
2835 float deltaAngle = 0.0f;
2836 if (radius > 0)
2837 deltaAngle = distInARow / radius;
2838
2839 uint32 count = 1;
2840 if (deltaAngle > 0)
2841 count += coneAngle / deltaAngle;
2842
2843 float currentAngle = -static_cast<float>(count) * deltaAngle / 2.0f;
2844
2846 currentAngle += G3D::fuzzyGt(e.target.o, 0.0f) ? (e.target.o - me->GetOrientation()) : 0.0f;
2847 else if (!targets.empty())
2848 {
2849 currentAngle += (me->GetAngle(targets.front()) - me->GetOrientation());
2850 }
2851
2852 for (uint32 index = 0; index < count; ++index)
2853 {
2854 Position spawnPosition(*me);
2855 spawnPosition.RelocatePolarOffset(currentAngle, radius);
2856 currentAngle += deltaAngle;
2857
2859 }
2860 }
2861
2862 break;
2863 }
2865 {
2866 for (WorldObject* target : targets)
2867 {
2868 if (Player* playerTarget = target->ToPlayer())
2869 {
2870 playerTarget->RemoveArenaSpellCooldowns();
2871 playerTarget->RemoveAurasDueToSpell(57724); // Spell Shaman Debuff - Sated (Heroism)
2872 playerTarget->RemoveAurasDueToSpell(57723); // Spell Shaman Debuff - Exhaustion (Bloodlust)
2873 playerTarget->RemoveAurasDueToSpell(2825); // Bloodlust
2874 playerTarget->RemoveAurasDueToSpell(32182); // Heroism
2875 }
2876 }
2877
2878 break;
2879 }
2881 {
2884 {
2885 if (targets.empty())
2886 break;
2887
2888 for (WorldObject* objTarget : targets)
2889 {
2890 if (Creature const* unitTarget = objTarget->ToCreature())
2891 {
2892 if (unitTarget->IsAIEnabled)
2893 {
2894 unitTarget->AI()->DoAction(actionId);
2895 }
2896 }
2897 else if (GameObject const* gobjTarget = objTarget->ToGameObject())
2898 {
2899 gobjTarget->AI()->DoAction(actionId);
2900 }
2901 }
2902
2903 }
2904 else
2905 {
2906 InstanceScript* instanceScript = nullptr;
2907 if (WorldObject* baseObj = GetBaseObject())
2908 {
2909 instanceScript = baseObj->GetInstanceScript();
2910 }
2911 // Action is triggered by AreaTrigger
2912 else if (trigger && IsPlayer(unit))
2913 {
2914 instanceScript = unit->GetInstanceScript();
2915 }
2916
2917 if (instanceScript)
2918 {
2919 instanceScript->DoAction(actionId);
2920 }
2921 }
2922 break;
2923 }
2925 {
2926 if (!IsSmart())
2927 break;
2928
2929 CAST_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0);
2930 break;
2931 }
2933 {
2934 for (WorldObject* const target : targets)
2935 {
2936 if (IsCreature(target))
2938 }
2939 break;
2940 }
2942 {
2943 for (WorldObject* target : targets)
2944 if (Unit* targetUnit = target->ToUnit())
2945 targetUnit->SetHealth(targetUnit->CountPctFromMaxHealth(e.action.setHealthPct.percent));
2946 break;
2947 }
2949 {
2950 uint32 speedInteger = e.action.movementSpeed.speedInteger;
2951 uint32 speedFraction = e.action.movementSpeed.speedFraction;
2952 float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(float(speedFraction ? speedFraction : 1)) + 1));
2953
2954 for (WorldObject* target : targets)
2955 if (IsCreature(target))
2956 target->ToCreature()->SetSpeed(UnitMoveType(e.action.movementSpeed.movementType), speed);
2957
2958 break;
2959 }
2961 {
2962 for (WorldObject* target : targets)
2963 {
2964 if (!IsPlayer(target))
2965 continue;
2966
2968 }
2969 break;
2970 }
2972 {
2973 WorldObject* obj = GetBaseObject();
2974 if (!obj)
2975 break;
2976
2979 e.action.groupSpawn.force != 0);
2980 break;
2981 }
2983 {
2984 WorldObject* obj = GetBaseObject();
2985 if (!obj)
2986 break;
2987
2989 e.action.groupSpawn.ignoreRespawn != 0); // reuse ignoreRespawn as deleteRespawnTimes
2990 break;
2991 }
2993 {
2994 for (WorldObject* target : targets)
2995 {
2996 ObjectGuid guidToSend = me ? me->GetGUID() : go->GetGUID();
2997
2999 {
3000 if (WorldObject* invoker = GetLastInvoker())
3001 {
3002 guidToSend = invoker->GetGUID();
3003 }
3004 }
3005
3006 if (Creature* creature = target->ToCreature())
3007 {
3008 creature->AI()->SetGUID(guidToSend, e.action.setGuid.index);
3009 }
3010 else if (GameObject* object = target->ToGameObject())
3011 {
3012 object->AI()->SetGUID(guidToSend, e.action.setGuid.index);
3013 }
3014 }
3015 break;
3016 }
3018 {
3019 // Enable Scripted Spawns
3020 switch (e.action.scriptSpawn.state)
3021 {
3022 case 0: // Disable Respawn
3023 {
3024 for (WorldObject* target : targets)
3025 {
3026 if (Creature* c = target->ToCreature())
3027 {
3028 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3030 c->DespawnOrUnsummon();
3031 }
3032 }
3033 break;
3034 }
3035 case 1: // Respawn Once
3036 {
3037 for (WorldObject* target : targets)
3038 {
3039 if (Creature* c = target->ToCreature())
3040 {
3041 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3042 c->Respawn(true);
3043 CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
3044 }
3045 }
3046 break;
3047 }
3048 case 2: // Enable Respawning
3049 {
3050 for (WorldObject* target : targets)
3051 {
3052 if (Creature* c = target->ToCreature())
3053 {
3054 CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
3055
3056 // If 0, respawn immediately
3059 else
3060 c->Respawn(true);
3061
3062 // If 0, use DB values
3064 c->SetRespawnDelay(e.action.scriptSpawn.respawnDelay);
3065
3066 // If 0, use default
3068 c->SetCorpseDelay(e.action.scriptSpawn.corpseDelay);
3069 }
3070 }
3071 break;
3072 }
3073 default:
3074 break;
3075 }
3076 break;
3077 }
3079 {
3080 float scale = static_cast<float>(e.action.setScale.scale) / 100.0f;
3081
3082 for (WorldObject* target : targets)
3083 {
3084 if (IsUnit(target))
3085 target->ToUnit()->SetObjectScale(scale);
3086 else if (IsGameObject(target))
3087 target->ToGameObject()->SetObjectScale(scale);
3088 }
3089 break;
3090 }
3092 {
3093 if (!me)
3094 break;
3095
3097
3098 float startAngle = me->GetOrientation() + (static_cast<float>(e.action.radialSummon.startAngle) * M_PI / 180.0f);
3099 float stepAngle = static_cast<float>(e.action.radialSummon.stepAngle) * M_PI / 180.0f;
3100
3101 if (e.action.radialSummon.dist)
3102 {
3103 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3104 {
3105 Position summonPos = me->GetPosition();
3106 summonPos.RelocatePolarOffset(itr * stepAngle, static_cast<float>(e.action.radialSummon.dist));
3108 }
3109 break;
3110 }
3111
3112 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
3113 {
3114 float currentAngle = startAngle + (itr * stepAngle);
3116 }
3117
3118 break;
3119 }
3121 {
3122 for (WorldObject* target : targets)
3123 {
3124 if (IsUnit(target))
3125 {
3128 }
3129 }
3130 break;
3131 }
3133 {
3135 {
3136 for (WorldObject* target : targets)
3137 if (IsUnit(target))
3138 target->ToCreature()->GetMotionMaster()->MoveIdle();
3139
3140 break;
3141 }
3142
3143 uint8 membCount = targets.size();
3144 uint8 itr = 1;
3145 float dist = float(e.action.followGroup.dist / 100);
3146 switch (e.action.followGroup.followType)
3147 {
3148 case FOLLOW_TYPE_CIRCLE:
3149 {
3150 float angle = (membCount > 4 ? (M_PI * 2)/membCount : (M_PI / 2)); // 90 degrees is the maximum angle
3151 for (WorldObject* target : targets)
3152 {
3153 if (IsCreature(target))
3154 {
3155 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, angle * itr);
3156 itr++;
3157 }
3158 }
3159 break;
3160 }
3162 {
3163 for (WorldObject* target : targets)
3164 {
3165 if (IsCreature(target))
3166 {
3167 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1));
3168 itr++;
3169 }
3170 }
3171 break;
3172 }
3174 {
3175 for (WorldObject* target : targets)
3176 {
3177 if (IsCreature(target))
3178 {
3179 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI + (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1)));
3180 itr++;
3181 }
3182 }
3183 break;
3184 }
3185 case FOLLOW_TYPE_LINE:
3186 {
3187 for (WorldObject* target : targets)
3188 {
3189 if (IsCreature(target))
3190 {
3191 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? 0.f : M_PI);
3192 itr++;
3193 }
3194 }
3195 break;
3196 }
3197 case FOLLOW_TYPE_COLUMN:
3198 {
3199 for (WorldObject* target : targets)
3200 {
3201 if (IsCreature(target))
3202 {
3203 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? (M_PI / 2) : (M_PI * 1.5f));
3204 itr++;
3205 }
3206 }
3207 break;
3208 }
3210 {
3211 for (WorldObject* target : targets)
3212 {
3213 if (IsCreature(target))
3214 {
3215 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? M_PI - (M_PI / 4) : M_PI + (M_PI / 4));
3216 itr++;
3217 }
3218 }
3219 break;
3220 }
3221 default:
3222 break;
3223 }
3224
3225 break;
3226 }
3228 {
3229 switch (e.action.orientationTarget.type)
3230 {
3231 case 0: // Reset
3232 {
3233 for (WorldObject* target : targets)
3234 target->ToCreature()->SetFacingTo((target->ToCreature()->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->ToCreature()->GetTransGUID() ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition()).GetOrientation());
3235
3236 break;
3237 }
3238 case 1: // Target target.o
3239 {
3240 for (WorldObject* target : targets)
3241 target->ToCreature()->SetFacingTo(e.target.o);
3242
3243 break;
3244 }
3245 case 2: // Target source
3246 {
3247 for (WorldObject* target : targets)
3248 target->ToCreature()->SetFacingToObject(me);
3249
3250 break;
3251 }
3252 case 3: // Target parameters
3253 {
3254 ObjectVector facingTargets;
3256
3257 for (WorldObject* facingTarget : facingTargets)
3258 for (WorldObject* target : targets)
3259 target->ToCreature()->SetFacingToObject(facingTarget);
3260
3261 break;
3262 }
3263 default:
3264 break;
3265 }
3266 break;
3267 }
3269 {
3270 if (e.action.wpData.pathId)
3271 {
3272 for (WorldObject* target : targets)
3273 {
3274 if (IsCreature(target))
3275 {
3276 target->ToCreature()->LoadPath(e.action.wpData.pathId);
3278 }
3279 }
3280 }
3281
3282 break;
3283 }
3285 {
3287 {
3288 for (WorldObject* target : targets)
3289 {
3290 if (IsCreature(target))
3291 {
3293 target->ToCreature()->LoadPath(path);
3295 }
3296 }
3297 }
3298
3299 break;
3300 }
3302 {
3303 for (WorldObject* target : targets)
3304 if (IsUnit(target))
3305 target->ToUnit()->StopMoving();
3306
3307 break;
3308 }
3310 {
3311 for (WorldObject* target : targets)
3312 if (IsUnit(target))
3313 target->ToUnit()->PauseMovement(e.action.move.timer);
3314
3315 break;
3316 }
3318 {
3319 for (WorldObject* target : targets)
3320 if (IsUnit(target))
3321 target->ToUnit()->ResumeMovement(e.action.move.timer);
3322
3323 break;
3324 }
3326 {
3327 sWorldState->HandleExternalEvent(static_cast<WorldStateEvent>(e.action.worldStateScript.eventId), e.action.worldStateScript.param);
3328 break;
3329 }
3331 {
3332 for (WorldObject* target : targets)
3333 if (IsCreature(target))
3334 {
3335 target->ToCreature()->SetReputationRewardDisabled(static_cast<bool>(e.action.reward.reputation));
3336 target->ToCreature()->SetLootRewardDisabled(static_cast<bool>(e.action.reward.loot));
3337 }
3338 break;
3339 }
3341 {
3342 for (WorldObject* target : targets)
3343 if (IsUnit(target))
3344 target->ToUnit()->SetAnimTier(AnimTier(e.action.animTier.animTier));
3345 break;
3346 }
3348 {
3349 for (WorldObject* target : targets)
3350 {
3351 if (Creature* creature = target->ToCreature())
3352 {
3353 creature->SetGossipMenuId(e.action.setGossipMenu.gossipMenuId);
3354 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_GOSSIP_MENU: Creature {} set gossip menu to {}",
3355 creature->GetGUID().ToString(), e.action.setGossipMenu.gossipMenuId);
3356 }
3357 }
3358 break;
3359 }
3361 {
3362 if (!GetBaseObject())
3363 break;
3364
3366 break;
3367 }
3368 default:
3369 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
3370 break;
3371 }
3372
3373 if (e.link && e.link != e.event_id)
3374 {
3375 auto linked = FindLinkedEvent(e.link);
3376 if (linked.has_value())
3377 {
3378 auto& linkedEvent = linked.value().get();
3379 if (linkedEvent.GetEventType() == SMART_EVENT_LINK)
3380 executionStack.emplace_back(SmartScriptFrame{ linkedEvent, unit, var0, var1, bvar, spell, gob });
3381 else
3382 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());
3383 }
3384 else
3385 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Link Event {} not found, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
3386 }
3387}
npc
Definition BattlegroundSA.h:47
#define DEFAULT_LOCALE
Definition Common.h:131
#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:1723
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:1966
SMARTAI_TARGETS
Definition SmartScriptMgr.h:1548
@ SMART_TARGET_RANDOM_POINT
Definition SmartScriptMgr.h:1587
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2270
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_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:1986
@ FOLLOW_TYPE_SEMI_CIRCLE_BEHIND
Definition SmartScriptMgr.h:1987
@ FOLLOW_TYPE_SEMI_CIRCLE_FRONT
Definition SmartScriptMgr.h:1988
@ FOLLOW_TYPE_COLUMN
Definition SmartScriptMgr.h:1990
@ FOLLOW_TYPE_ANGULAR
Definition SmartScriptMgr.h:1991
@ FOLLOW_TYPE_LINE
Definition SmartScriptMgr.h:1989
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:734
@ SMART_ESCORT_TARGETS
Definition SmartScriptMgr.h:40
@ SMARTCAST_TRIGGERED
Definition SmartScriptMgr.h:1972
@ SMARTCAST_ENABLE_COMBAT_MOVE_ON_LOS
Definition SmartScriptMgr.h:1980
@ SMARTCAST_COMBAT_MOVE
Definition SmartScriptMgr.h:1977
@ SMARTCAST_INTERRUPT_PREVIOUS
Definition SmartScriptMgr.h:1971
@ SMARTCAST_AURA_NOT_PRESENT
Definition SmartScriptMgr.h:1976
@ SMARTCAST_THREATLIST_NOT_SINGLE
Definition SmartScriptMgr.h:1978
@ SMARTCAST_TARGET_POWER_MANA
Definition SmartScriptMgr.h:1979
@ 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:836
#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:565
@ 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:160
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:2017
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition Creature.cpp:3049
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:2840
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:1410
bool isSpawnedByDefault() const
Definition GameObject.h:196
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2462
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1284
GameobjectTypes GetGoType() const
Definition GameObject.h:203
void Respawn()
Definition GameObject.cpp:1299
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition GameObject.cpp:927
void CastSpell(Unit *target, uint32 spell)
Definition GameObject.cpp:2077
virtual bool SetBossState(uint32 id, EncounterState state)
Definition InstanceScript.cpp:396
virtual void DoAction(int32)
Definition InstanceScript.h:286
static std::string GetBossStateName(uint8 state)
Definition InstanceScript.cpp:837
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:2549
void LoadGrid(float x, float y)
Definition Map.cpp:213
PlayerList const & GetPlayers() const
Definition Map.h:329
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false)
Definition Map.cpp:2633
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:913
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:234
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:447
void MovePoint(uint32 id, const Position &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 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:244
static ObjectGuid const Empty
Definition ObjectGuid.h:120
std::string ToString() const
Definition ObjectGuid.cpp:47
static CreatureModel const * ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=nullptr)
Definition ObjectMgr.cpp:1644
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:871
virtual void SetObjectScale(float scale)
Definition Object.h:121
Definition GossipDef.h:259
CinematicMgr & GetCinematicMgr()
Definition Player.h:1397
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition PlayerQuest.cpp:1853
void PrepareGossipMenu(WorldObject *source, uint32 menuId=0, bool showQuests=false)
Definition PlayerGossip.cpp:32
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:12766
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:5489
void StoreTargetList(ObjectVector const &targets, uint32 id)
Definition SmartScript.h:93
void RetryLater(SmartScriptHolder &e, bool ignoreChanceRoll=false)
Definition SmartScript.cpp:5177
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:3516
void OnReset()
Definition SmartScript.cpp:110
void InstallTemplate(SmartScriptHolder const &e)
Definition SmartScript.cpp:3404
ObjectGuid goOrigGUID
Definition SmartScript.h:229
void DecPhase(uint32 p)
Definition SmartScript.cpp:5495
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:28
uint8 getGender() const
Definition Unit.h:848
void SetFacingToObject(WorldObject *object, Milliseconds timed=0ms)
Definition Unit.cpp:16456
void SetFacingTo(float ori)
Definition Unit.cpp:16446
float GetSpeed(UnitMoveType mtype) const
Definition Unit.cpp:11291
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
Definition Unit.cpp:4316
float GetSpellMinRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:11900
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:7715
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:13964
MotionMaster * GetMotionMaster()
Definition Unit.h:1759
void SetUnitMovementFlags(uint32 f)
Definition Unit.h:776
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:1432
bool IsAlive() const
Definition Unit.h:1794
void StopMoving()
Definition Unit.cpp:13023
void SendPlaySpellVisual(uint32 id)
Definition Unit.cpp:15165
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5999
virtual void SetSheath(SheathState sheathed)
Definition Unit.h:1778
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:11880
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:774
TransportBase * GetDirectTransport() const
Definition Unit.cpp:15021
void SendMovementFlagUpdate(bool self=false)
Definition Unit.cpp:13077
void EngageWithTarget(Unit *who)
Definition Unit.cpp:7519
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:1375
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:5171
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:11296
ThreatManager & GetThreatMgr()
Definition Unit.h:951
ObjectGuid GetTransGUID() const override
Definition Unit.cpp:15010
bool IsAIEnabled
Definition Unit.h:2098
bool HasUnitState(const uint32 f) const
Definition Unit.h:736
float GetPowerPct(Powers power) const
Definition Unit.h:1137
void SetDisableGravity(bool disable)
Definition Unit.cpp:16497
float GetMeleeRange(Unit const *target) const
Definition Unit.cpp:801
uint32 GetPower(Powers power) const
Definition Unit.h:1135
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7486
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition Unit.h:1234
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition Unit.cpp:11420
void SetInFront(WorldObject const *target)
Definition Unit.cpp:16440
bool isDead() const
Definition Unit.h:1796
Definition Vehicle.h:28
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition Object.cpp:2393
Map * FindMap() const
Definition Object.h:626
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:1403
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:2692
void SummonGameObjectGroup(uint8 group, std::list< GameObject * > *list=nullptr)
Definition Object.cpp:2484
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:2765
std::string const & GetName() const
Definition Object.h:528
void AddObjectToRemoveList()
Definition Object.cpp:2173
EventProcessor m_Events
Definition Object.h:736
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1295
uint32 GetAreaId() const
Definition Object.cpp:3119
uint32 GetZoneId() const
Definition Object.cpp:3111
float GetObjectSize() const
Definition Object.cpp:2837
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:2407
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition Object.cpp:1558
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:2470
virtual float GetCombatReach() const
Definition Object.h:506
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2442
Player session in the World.
Definition WorldSession.h:384
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:52
virtual void SetGuidData(uint32, ObjectGuid)
Definition ZoneScript.h:45
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:133
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250
Definition ObjectAccessor.h:61
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:220
Definition CreatureData.h: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 m_positionZ
Definition Position.h:57
float m_positionX
Definition Position.h:55
float GetPositionZ() const
Definition Position.h:123
float m_positionY
Definition Position.h:56
float GetOrientation() const
Definition Position.h:124
void SetOrientation(float orientation)
Definition Position.h:116
float GetPositionX() const
Definition Position.h:121
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetPositionY() const
Definition Position.h:122
void RelocatePolarOffset(float angle, float dist, float z=0.0f)
Definition Position.cpp:34
float GetAngle(const Position *pos) const
Definition Position.cpp:85
Definition SmartScriptMgr.h:745
struct SmartAction::@75::@98 combatMove
uint32 followState
Definition SmartScriptMgr.h:1454
uint32 visualId
Definition SmartScriptMgr.h:1449
uint32 targetParam2
Definition SmartScriptMgr.h:849
struct SmartAction::@75::@100 incEventPhase
struct SmartAction::@75::@106 killedMonster
SAIBool disableForceDestination
Definition SmartScriptMgr.h:1206
std::array< uint32, SMART_ACTION_PARAM_COUNT > emotes
Definition SmartScriptMgr.h:832
uint32 forcedMovement
Definition SmartScriptMgr.h:1031
uint32 repeatMax
Definition SmartScriptMgr.h:1108
uint32 phaseMin
Definition SmartScriptMgr.h:934
uint32 targetsLimit
Definition SmartScriptMgr.h:840
struct SmartAction::@75::@181 movementSpeed
struct SmartAction::@75::@186 setScale
SAIBool transport
Definition SmartScriptMgr.h:1202
struct SmartAction::@75::@192 wpDataRandom
struct SmartAction::@75::@82 randomSound
struct SmartAction::@75::@120 summonGO
uint32 startAngle
Definition SmartScriptMgr.h:1442
SAIBool reset
Definition SmartScriptMgr.h:1093
std::array< uint32, SMART_ACTION_PARAM_COUNT > actionLists
Definition SmartScriptMgr.h:1156
struct SmartAction::@75::@185 scriptSpawn
uint32 delay
Definition SmartScriptMgr.h:755
struct SmartAction::@75::@163 startClosestWaypoint
uint32 random
Definition SmartScriptMgr.h:1337
uint32 quickChange
Definition SmartScriptMgr.h:1336
uint32 targetParam4
Definition SmartScriptMgr.h:1466
uint32 dist
Definition SmartScriptMgr.h:919
uint32 group
Definition SmartScriptMgr.h:1259
SAIBool disable
Definition SmartScriptMgr.h:1391
struct SmartAction::@75::@180 corpseDelay
struct SmartAction::@75::@194 worldStateScript
struct SmartAction::@75::@111 callHelp
uint32 spell
Definition SmartScriptMgr.h:837
uint32 minHP
Definition SmartScriptMgr.h:986
SAIBool force
Definition SmartScriptMgr.h:1313
struct SmartAction::@75::@177 summonVortex
uint32 flags
Definition SmartScriptMgr.h:846
struct SmartAction::@75::@97 autoAttack
SAIBool loot
Definition SmartScriptMgr.h:1509
uint32 distanceBetweenSummons
Definition SmartScriptMgr.h:1352
uint32 data
Definition SmartScriptMgr.h:946
struct SmartAction::@75::@105 randomPhaseRange
uint32 entry
Definition SmartScriptMgr.h:921
struct SmartAction::@75::@91 crossCast
struct SmartAction::@75::@129 setSwim
uint32 quest
Definition SmartScriptMgr.h:816
struct SmartAction::@75::@150 moveToPosTarget
struct SmartAction::@75::@172 orientation
struct SmartAction::@75::@78 simpleTalk
uint32 triggerFlags
Definition SmartScriptMgr.h:839
struct SmartAction::@75::@87 questOffer
uint32 bp1
Definition SmartScriptMgr.h:1367
uint32 distance
Definition SmartScriptMgr.h:779
SAIBool removeObjectFromWorld
Definition SmartScriptMgr.h:981
uint32 min
Definition SmartScriptMgr.h:1105
uint32 spawnTimerMax
Definition SmartScriptMgr.h:1426
uint32 subtract
Definition SmartScriptMgr.h:1094
struct SmartAction::@75::@110 die
uint32 a
Definition SmartScriptMgr.h:1376
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:1418
struct SmartAction::@75::@191 wpData
uint32 percent
Definition SmartScriptMgr.h:987
uint32 dec
Definition SmartScriptMgr.h:903
uint32 milliseconds
Definition SmartScriptMgr.h:963
struct SmartAction::@75::@125 item
uint32 summonEntry
Definition SmartScriptMgr.h:1349
struct SmartAction::@75::@84 randomMusic
uint32 followType
Definition SmartScriptMgr.h:1455
uint32 instanceTarget
Definition SmartScriptMgr.h:1386
struct SmartAction::@75::@196 reward
uint32 credit
Definition SmartScriptMgr.h:922
uint32 controlled
Definition SmartScriptMgr.h:1203
uint32 alternative
Definition SmartScriptMgr.h:855
uint32 targetParam1
Definition SmartScriptMgr.h:848
uint32 mapID
Definition SmartScriptMgr.h:1086
uint32 stopMovement
Definition SmartScriptMgr.h:1343
struct SmartAction::@75::@134 movie
struct SmartAction::@75::@94 summonCreature
uint32 charges
Definition SmartScriptMgr.h:914
struct SmartAction::@75::@113 forceDespawn
struct SmartAction::@75::@103 follow
uint32 model
Definition SmartScriptMgr.h:772
uint32 duration
Definition SmartScriptMgr.h:753
SAIBool attackInvoker
Definition SmartScriptMgr.h:868
SAIBool useTalkTarget
Definition SmartScriptMgr.h:754
SAIBool run
Definition SmartScriptMgr.h:1069
struct SmartAction::@75::@200 groupSpawn
struct SmartAction::@75::@176 castCustom
uint32 value
Definition SmartScriptMgr.h:1092
struct SmartAction::@75::@140 timedActionList
uint32 movementExpired
Definition SmartScriptMgr.h:1344
struct SmartAction::@75::@117 moveRandom
uint32 targetParam3
Definition SmartScriptMgr.h:850
uint32 respawnDelay
Definition SmartScriptMgr.h:1427
SAIBool swim
Definition SmartScriptMgr.h:1081
uint32 combatReach
Definition SmartScriptMgr.h:1205
uint32 sound2
Definition SmartScriptMgr.h:785
struct SmartAction::@75::@188 spellVisual
uint32 spawnPos
Definition SmartScriptMgr.h:1307
struct SmartAction::@75::@92 activateObject
struct SmartAction::@75::@167 setHomePos
struct SmartAction::@75::@161 gameEventStop
uint32 pathId2
Definition SmartScriptMgr.h:1283
uint32 creature
Definition SmartScriptMgr.h:771
struct SmartAction::@75::@190 orientationTarget
uint32 spawnTimerMin
Definition SmartScriptMgr.h:1425
struct SmartAction::@75::@132 storeTargets
struct SmartAction::@75::@114 invincHP
uint32 angle
Definition SmartScriptMgr.h:920
uint32 field
Definition SmartScriptMgr.h:945
struct SmartAction::@75::@199 gameobjectGroup
uint32 range
Definition SmartScriptMgr.h:860
struct SmartAction::@75::@95 threatPCT
struct SmartAction::@75::@89 randomEmote
struct SmartAction::@75::@162 gameEventStart
uint32 flag
Definition SmartScriptMgr.h:1126
uint32 sound3
Definition SmartScriptMgr.h:786
uint32 targetsummon
Definition SmartScriptMgr.h:1020
struct SmartAction::@75::@145 jump
uint32 chance
Definition SmartScriptMgr.h:1109
struct SmartAction::@75::@131 setCounter
uint32 state
Definition SmartScriptMgr.h:827
struct SmartAction::@75::@90 cast
struct SmartAction::@75::@108 setInstanceData64
uint32 sound1
Definition SmartScriptMgr.h:784
struct SmartAction::@75::@80 morphOrMount
struct SmartAction::@75::@116 setData
uint32 forceRespawnTimer
Definition SmartScriptMgr.h:980
uint32 speed
Definition SmartScriptMgr.h:1075
uint32 sound4
Definition SmartScriptMgr.h:787
struct SmartAction::@75::@147 flee
uint32 targetType
Definition SmartScriptMgr.h:847
uint32 repetitions
Definition SmartScriptMgr.h:1441
struct SmartAction::@75::@174 coneSummon
uint32 aliveState
Definition SmartScriptMgr.h:924
SAIBool onlySelf
Definition SmartScriptMgr.h:778
uint32 attackScriptOwner
Definition SmartScriptMgr.h:869
uint32 speedxy
Definition SmartScriptMgr.h:1179
uint32 pointId
Definition SmartScriptMgr.h:1201
SAIBool attack
Definition SmartScriptMgr.h:887
uint32 repeatMin
Definition SmartScriptMgr.h:1107
struct SmartAction::@75::@122 wpStart
uint32 scale
Definition SmartScriptMgr.h:1434
SAIBool fly
Definition SmartScriptMgr.h:1074
uint32 textGroupID
Definition SmartScriptMgr.h:752
uint32 castFlags
Definition SmartScriptMgr.h:838
struct SmartAction::@75::@179 disableEvade
std::array< uint32, SMART_ACTION_PARAM_COUNT > phases
Definition SmartScriptMgr.h:929
SAIBool dontDespawn
Definition SmartScriptMgr.h:1429
uint32 turnAngle
Definition SmartScriptMgr.h:1338
uint32 textId
Definition SmartScriptMgr.h:1359
uint32 gossipMenuId
Definition SmartScriptMgr.h:1217
uint32 speedz
Definition SmartScriptMgr.h:1180
SAIBool repeat
Definition SmartScriptMgr.h:1033
struct SmartAction::@75::@173 stopMotion
uint32 gossipNpcTextId
Definition SmartScriptMgr.h:1218
uint32 mask
Definition SmartScriptMgr.h:992
uint32 pathId1
Definition SmartScriptMgr.h:1282
uint32 phi_delta
Definition SmartScriptMgr.h:1379
uint32 count
Definition SmartScriptMgr.h:1054
struct SmartAction::@75::@112 setSheath
uint32 inc
Definition SmartScriptMgr.h:902
uint32 phaseMax
Definition SmartScriptMgr.h:935
struct SmartAction::@75::@130 teleport
uint32 timer
Definition SmartScriptMgr.h:1396
uint32 ContactDistance
Definition SmartScriptMgr.h:1204
struct SmartAction::@75::@79 faction
PathSource pathSource
Definition SmartScriptMgr.h:1286
struct SmartAction::@75::@135 equip
uint32 k
Definition SmartScriptMgr.h:1377
uint32 distanceBetweenRings
Definition SmartScriptMgr.h:1351
uint32 coneLength
Definition SmartScriptMgr.h:1353
uint32 counterId
Definition SmartScriptMgr.h:1091
SAIBool withEmote
Definition SmartScriptMgr.h:969
struct SmartAction::@75::@146 movementFlag
uint32 param
Definition SmartScriptMgr.h:1491
uint32 max
Definition SmartScriptMgr.h:1106
uint32 selfJump
Definition SmartScriptMgr.h:1181
struct SmartAction::@75::@183 cinematic
uint32 maxId
Definition SmartScriptMgr.h:1319
uint32 r_max
Definition SmartScriptMgr.h:1378
struct SmartAction::@75::@136 unitFlag
uint32 speedFraction
Definition SmartScriptMgr.h:1403
struct SmartAction::@75::@88 react
struct SmartAction::@75::@119 setActive
struct SmartAction::@75::@159 creatureGroup
SAIBool fail
Definition SmartScriptMgr.h:1048
struct SmartAction::@75::@124 wpStop
SAIBool directAdd
Definition SmartScriptMgr.h:822
uint32 bp2
Definition SmartScriptMgr.h:1368
uint32 disableGravity
Definition SmartScriptMgr.h:1076
uint32 sound
Definition SmartScriptMgr.h:777
uint32 threatINC
Definition SmartScriptMgr.h:875
uint32 coneAngle
Definition SmartScriptMgr.h:1354
uint32 summonDuration
Definition SmartScriptMgr.h:1350
struct SmartAction::@75::@148 RespawnTarget
struct SmartAction::@75::@175 playerTalk
uint32 threatDEC
Definition SmartScriptMgr.h:876
SAIBool reputation
Definition SmartScriptMgr.h:1508
uint32 ignoreRespawn
Definition SmartScriptMgr.h:1530
uint32 stepAngle
Definition SmartScriptMgr.h:1443
struct SmartAction::@75::@153 sendTargetToTarget
uint32 reactState
Definition SmartScriptMgr.h:1036
uint32 speedInteger
Definition SmartScriptMgr.h:1402
struct SmartAction::@75::@77 talk
uint32 index
Definition SmartScriptMgr.h:1419
struct SmartAction::@75::@123 wpPause
struct SmartAction::@75::@83 music
uint32 actionId
Definition SmartScriptMgr.h:1384
struct SmartAction::@75::@169 randomTimedEvent
uint32 despawnTime
Definition SmartScriptMgr.h:1019
struct SmartAction::@75::@128 setFly
uint32 goRespawnTime
Definition SmartScriptMgr.h:1196
struct SmartAction::@75::@115 ingamePhaseMask
uint32 factionID
Definition SmartScriptMgr.h:766
uint32 eventId
Definition SmartScriptMgr.h:1490
uint32 groupId
Definition SmartScriptMgr.h:1529
struct SmartAction::@75::@189 followGroup
uint32 pathId
Definition SmartScriptMgr.h:1471
SAIBool move
Definition SmartScriptMgr.h:892
struct SmartAction::@75::@178 doAction
struct SmartAction::@75::@149 moveToPos
std::array< uint32, MAX_EQUIPMENT_ITEMS > slots
Definition SmartScriptMgr.h:1121
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:821
uint32 bp3
Definition SmartScriptMgr.h:1369
uint32 pathID
Definition SmartScriptMgr.h:1032
uint32 emote
Definition SmartScriptMgr.h:811
struct SmartAction::@75::@102 removeAura
uint32 id
Definition SmartScriptMgr.h:1026
uint32 minId
Definition SmartScriptMgr.h:1318
uint32 phase
Definition SmartScriptMgr.h:897
uint32 sheath
Definition SmartScriptMgr.h:974
uint32 isNegative
Definition SmartScriptMgr.h:1385
uint32 creditType
Definition SmartScriptMgr.h:923
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:2021
uint32 link
Definition SmartScriptMgr.h:2004
bool IsAreatriggerScript() const
Definition SmartScriptMgr.h:2016
uint32 event_id
Definition SmartScriptMgr.h:2003
int32 entryOrGuid
Definition SmartScriptMgr.h:2001
uint32 GetScriptType() const
Definition SmartScriptMgr.h:2011
uint32 GetTargetType() const
Definition SmartScriptMgr.h:2014
uint32 GetActionType() const
Definition SmartScriptMgr.h:2013
struct SmartTarget::@201::@205 unitRange
float o
Definition SmartScriptMgr.h:1611
uint32 maxDist
Definition SmartScriptMgr.h:1617
uint32 range
Definition SmartScriptMgr.h:1738
float x
Definition SmartScriptMgr.h:1611
uint32 self
Definition SmartScriptMgr.h:1740
uint32 amount
Definition SmartScriptMgr.h:1739
struct SmartTarget::@201::@222 randomPoint
float y
Definition SmartScriptMgr.h:1611
float z
Definition SmartScriptMgr.h:1611
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_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 
)
4151{
4152 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
4153 return;
4154
4156 return;
4157
4159 return;
4160
4161 switch (e.GetEventType())
4162 {
4163 case SMART_EVENT_LINK://special handling
4164 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4165 break;
4166 //called from Update tick
4167 case SMART_EVENT_UPDATE:
4169 break;
4171 if (me && me->IsEngaged())
4172 return;
4174 break;
4176 if (!me || !me->IsEngaged())
4177 return;
4179 break;
4181 {
4182 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
4183 return;
4184 uint32 perc = (uint32)me->GetHealthPct();
4185 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4186 return;
4188 break;
4189 }
4191 {
4192 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
4193 return;
4194 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
4195 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4196 return;
4198 break;
4199 }
4201 {
4202 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
4203 return;
4205 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4206 return;
4208 break;
4209 }
4211 {
4212 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
4213 return;
4215 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
4216 return;
4218 break;
4219 }
4220 case SMART_EVENT_RANGE:
4221 {
4222 if (!me || !me->IsEngaged() || !me->GetVictim())
4223 return;
4224
4227 else
4228 RecalcTimer(e, 1200, 1200); // make it predictable
4229
4230 break;
4231 }
4233 {
4234 if (!me || !me->IsEngaged())
4235 return;
4236
4237 Unit* victim = me->GetVictim();
4238
4239 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
4240 return;
4241
4242 if (e.event.targetCasting.spellId > 0)
4243 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
4244 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
4245 return;
4246
4248 break;
4249 }
4251 {
4252 if (!me || !me->IsEngaged())
4253 return;
4254
4256 if (!target || !target->IsInCombat())
4257 {
4258 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4259 RecalcTimer(e, 1000, 3000);
4260 return;
4261 }
4263 break;
4264 }
4266 {
4267 if (!me || !me->IsEngaged())
4268 return;
4269
4270 std::vector<Creature*> creatures;
4272 if (creatures.empty())
4273 {
4274 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
4275 RecalcTimer(e, 1000, 3000);
4276 return;
4277 }
4279 break;
4280 }
4282 {
4284 {
4285 return;
4286 }
4287
4288 std::vector<Creature*> creatures;
4290
4291 if (creatures.empty())
4292 return;
4293
4295 break;
4296 }
4298 {
4299 if (!me)
4300 return;
4301 uint32 count = me->GetAuraCount(e.event.aura.spell);
4302 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
4304 break;
4305 }
4307 {
4308 if (!me || !me->GetVictim())
4309 return;
4311 if (count < e.event.aura.count)
4312 return;
4314 break;
4315 }
4317 {
4318 if (bvar == (e.event.charm.onRemove != 1))
4319 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4320 break;
4321 }
4322 //no params
4323 case SMART_EVENT_AGGRO:
4324 case SMART_EVENT_DEATH:
4325 case SMART_EVENT_EVADE:
4338 case SMART_EVENT_RESET:
4342 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4343 break;
4344
4346 switch (e.event.gossipHello.filter)
4347 {
4348 case 0:
4349 // no filter set, always execute action
4350 break;
4351 case 1:
4352 // GossipHello only filter set, skip action if reportUse
4353 if (var0)
4354 {
4355 return;
4356 }
4357 break;
4358 case 2:
4359 // reportUse only filter set, skip action if GossipHello
4360 if (!var0)
4361 {
4362 return;
4363 }
4364 break;
4365 default:
4366 // Ignore any other value
4367 break;
4368 }
4369
4370 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
4371 break;
4373 {
4374 if (!me)
4375 return;
4376
4377 if (Unit* victim = me->GetVictim())
4378 {
4380 if (!victim->HasInArc(static_cast<float>(M_PI), me))
4382 }
4383
4384 break;
4385 }
4387 {
4388 if (!me)
4389 return;
4390
4391 if (Unit* victim = me->GetVictim())
4392 if ((!e.event.meleeRange.invert && me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))) ||
4393 (e.event.meleeRange.invert && !me->IsWithinMeleeRange(victim, static_cast<float>(e.event.meleeRange.dist))))
4395
4396 break;
4397 }
4399 if (e.event.emote.emote == var0)
4400 {
4401 ProcessAction(e, unit);
4402 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
4403 }
4404 break;
4405 case SMART_EVENT_KILL:
4406 {
4407 if (!me || !unit)
4408 return;
4409 if (e.event.kill.playerOnly && !unit->IsPlayer())
4410 return;
4411 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4412 return;
4414 ProcessAction(e, unit);
4415 break;
4416 }
4419 {
4420 if (!spell)
4421 return;
4422 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4423 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4424 {
4426 ProcessAction(e, unit, 0, 0, bvar, spell);
4427 }
4428 break;
4429 }
4431 {
4432 if (!me || me->IsEngaged())
4433 return;
4434 //can trigger if closer than fMaxAllowedRange
4435 float range = (float)e.event.los.maxDist;
4436
4437 //if range is ok and we are actually in LOS
4438 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4439 {
4441 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4442 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4443 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4444 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4445 {
4446 if (e.event.los.playerOnly && !unit->IsPlayer())
4447 return;
4449 ProcessAction(e, unit);
4450 }
4451 }
4452 break;
4453 }
4454 case SMART_EVENT_IC_LOS:
4455 {
4456 if (!me || !me->IsEngaged())
4457 return;
4458 //can trigger if closer than fMaxAllowedRange
4459 float range = (float)e.event.los.maxDist;
4460
4461 //if range is ok and we are actually in LOS
4462 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4463 {
4465 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4466 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4467 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4468 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4469 {
4470 if (e.event.los.playerOnly && !unit->IsPlayer())
4471 return;
4473 ProcessAction(e, unit);
4474 }
4475 }
4476 break;
4477 }
4479 {
4480 if (!GetBaseObject())
4481 return;
4483 return;
4485 return;
4486 ProcessAction(e);
4487 break;
4488 }
4492 {
4493 if (!IsCreature(unit))
4494 return;
4495 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4496 return;
4498 ProcessAction(e, unit);
4499 break;
4500 }
4504 {
4505 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4506 return;
4508 ProcessAction(e, unit);
4509 break;
4510 }
4512 {
4513 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4514 return;
4516 return;
4517 ProcessAction(e, unit, var0, var1);
4518 break;
4519 }
4522 {
4523 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4524 return;
4525 ProcessAction(e, unit, var0);
4526 break;
4527 }
4533 {
4534 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4535 return;
4536 ProcessAction(e, unit);
4537 break;
4538 }
4540 {
4541 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4542 return;
4544 ProcessAction(e, unit, var0);
4545 break;
4546 }
4548 {
4550 return;
4552 ProcessAction(e, unit, var0);
4553 break;
4554 }
4557 {
4558 if (e.event.quest.quest && var0 != e.event.quest.quest)
4559 return;
4560 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4561 ProcessAction(e, unit, var0);
4562 break;
4563 }
4565 {
4567 return;
4568 ProcessAction(e, unit, var0);
4569 break;
4570 }
4572 {
4573 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4574 return;
4575 ProcessAction(e, unit, var0);
4576 break;
4577 }
4579 {
4581 return;
4582 ProcessAction(e, unit, var0);
4583 break;
4584 }
4586 {
4587 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4588 return;
4590 ProcessAction(e, unit, var0, var1, false, nullptr, gob);
4591 break;
4592 }
4595 {
4596 if (!unit)
4597 return;
4599 ProcessAction(e, unit);
4600 break;
4601 }
4603 {
4604 if (e.event.timedEvent.id == var0)
4605 ProcessAction(e, unit);
4606 break;
4607 }
4609 {
4610 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4611 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4612 return;
4613 ProcessAction(e, unit, var0, var1);
4614 break;
4615 }
4617 {
4619 return;
4620
4621 ProcessAction(e);
4622 break;
4623 }
4626 {
4627 if (e.event.gameEvent.gameEventId != var0)
4628 return;
4629 ProcessAction(e, nullptr, var0);
4630 break;
4631 }
4633 {
4634 if (e.event.goStateChanged.state != var0)
4635 return;
4636 ProcessAction(e, unit, var0, var1);
4637 break;
4638 }
4640 {
4641 if (e.event.eventInform.eventId != var0)
4642 return;
4643 ProcessAction(e, nullptr, var0);
4644 break;
4645 }
4647 {
4648 if (e.event.doAction.eventId != var0)
4649 return;
4651 ProcessAction(e, unit, var0);
4652 break;
4653 }
4655 {
4656 if (!me || !me->IsEngaged())
4657 return;
4658
4659 Unit* unitTarget = nullptr;
4660 switch (e.GetTargetType())
4661 {
4669 {
4670 ObjectVector targets;
4671 GetTargets(targets, e);
4672 for (WorldObject* target : targets)
4673 {
4674 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4675 {
4676 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4677 if (healthPct > e.event.friendlyHealthPct.hpPct)
4678 {
4679 continue;
4680 }
4681
4682 unitTarget = target->ToUnit();
4683 break;
4684 }
4685 }
4686
4687 break;
4688 }
4689 case SMART_TARGET_SELF:
4692 break;
4693 default:
4694 return;
4695 }
4696
4697 if (!unitTarget)
4698 return;
4699
4701 break;
4702 }
4704 {
4705 if (!me)
4706 return;
4707
4708 WorldObject* creature = nullptr;
4709
4710 if (e.event.distance.guid != 0)
4711 {
4712 creature = FindCreatureNear(me, e.event.distance.guid);
4713
4714 if (!creature)
4715 return;
4716
4717 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4718 return;
4719 }
4720 else if (e.event.distance.entry != 0)
4721 {
4722 std::list<Creature*> list;
4724
4725 if (!list.empty())
4726 creature = list.front();
4727 }
4728
4729 if (creature)
4731
4732 break;
4733 }
4735 {
4736 if (!me)
4737 return;
4738
4739 WorldObject* gameobject = nullptr;
4740
4741 if (e.event.distance.guid != 0)
4742 {
4743 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4744
4745 if (!gameobject)
4746 return;
4747
4748 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4749 return;
4750 }
4751 else if (e.event.distance.entry != 0)
4752 {
4753 std::list<GameObject*> list;
4755
4756 if (!list.empty())
4757 gameobject = list.front();
4758 }
4759
4760 if (gameobject)
4762
4763 break;
4764 }
4766 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4767 return;
4768
4770 break;
4772 {
4773 uint32 playerCount = 0;
4774 ObjectVector targets;
4775 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4776
4777 if (!targets.empty())
4778 {
4779 for (WorldObject* target : targets)
4780 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4781 playerCount++;
4782
4783 if (playerCount >= e.event.nearPlayer.minCount)
4784 ProcessAction(e, unit);
4785 }
4787 break;
4788 }
4790 {
4791 uint32 playerCount = 0;
4792 ObjectVector targets;
4793 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4794
4795 if (!targets.empty())
4796 {
4797 for (WorldObject* target : targets)
4798 if (IsPlayer(target) && !target->ToPlayer()->IsGameMaster())
4799 playerCount++;
4800
4801 if (playerCount < e.event.nearPlayerNegation.maxCount)
4802 ProcessAction(e, unit);
4803 }
4805 break;
4806 }
4808 {
4809 uint32 unitCount = 0;
4810 ObjectVector targets;
4811 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4812
4813 if (!targets.empty())
4814 {
4815 if (e.event.nearUnit.type)
4816 {
4817 for (WorldObject* target : targets)
4818 {
4819 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4820 unitCount++;
4821 }
4822 }
4823 else
4824 {
4825 for (WorldObject* target : targets)
4826 {
4827 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4828 unitCount++;
4829 }
4830 }
4831
4832 if (unitCount >= e.event.nearUnit.count)
4833 ProcessAction(e, unit);
4834 }
4836 break;
4837 }
4839 {
4840 uint32 unitCount = 0;
4841 ObjectVector targets;
4842 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4843
4844 if (!targets.empty())
4845 {
4847 {
4848 for (WorldObject* target : targets)
4849 {
4850 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4851 unitCount++;
4852 }
4853 }
4854 else
4855 {
4856 for (WorldObject* target : targets)
4857 {
4858 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4859 unitCount++;
4860 }
4861 }
4862
4863 if (unitCount < e.event.nearUnitNegation.count)
4864 ProcessAction(e, unit);
4865 }
4867 break;
4868 }
4870 {
4871 if (!me || !me->IsEngaged())
4872 return;
4873
4874 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4875 {
4876 if (Unit* target = ref->GetVictim())
4877 {
4878 if (!IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4879 continue;
4880
4881 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4882 continue;
4883
4884 ProcessAction(e, target);
4886 return;
4887 }
4888 }
4889
4890 // No targets found
4892
4893 break;
4894 }
4896 {
4897 if (!me || !me->IsEngaged())
4898 return;
4899
4900 for (ThreatReference const* ref : me->GetThreatMgr().GetUnsortedThreatList())
4901 {
4902 if (Unit* target = ref->GetVictim())
4903 {
4904 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4905 continue;
4906
4907 ProcessAction(e, target);
4909 return;
4910 }
4911 }
4912
4913 // If no targets are found and it's off cooldown, check again
4914 RecalcTimer(e, 1200, 1200);
4915 break;
4916 }
4919 {
4920 if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
4921 return;
4922 ProcessAction(e, unit);
4923 break;
4924 }
4925 default:
4926 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4927 break;
4928 }
4929}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition SmartScriptMgr.h:1960
@ 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:556
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:5390
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition SmartScript.cpp:5380
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:164
static bool IsCharmedCreature(WorldObject *obj)
Definition SmartScript.cpp:5473
uint32 GetPathId() const
Definition SmartScript.h:63
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition SmartScript.cpp:5353
bool IsInPhase(uint32 p) const
Definition SmartScript.cpp:5519
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition SmartScript.cpp:5366
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:3389
Definition Spell.h:298
float GetHealthPct() const
Definition Unit.h:1110
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:4286
uint32 GetMaxHealth() const
Definition Unit.h:1109
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:783
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:5960
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1136
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7258
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:7253
bool IsInCombat() const
Definition Unit.h:935
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1576
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2545
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition Object.cpp:2559
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1377
bool HasInArc(float arcangle, const Position *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, 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 
)
137{
138 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
139 {
140 SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
141 if (eventType == SMART_EVENT_LINK)//special handling
142 continue;
143
144 if (eventType == e)
145 {
146 ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
147 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
148
149 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
150 {
151 ASSERT(executionStack.empty());
152 executionStack.emplace_back(SmartScriptFrame{ *i, unit, var0, var1, bvar, spell, gob });
153 while (!executionStack.empty())
154 {
155 auto [stack_holder , stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
156 executionStack.pop_back();
157 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
158 }
159 }
160 }
161 }
162}
#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:4150
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 
)
3390{
3391 // xinef: extended by selfs victim
3392 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3393 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3394
3395 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3396 {
3397 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3398 RecalcTimer(e, min, max);
3399 }
3400 else
3401 RecalcTimer(e, 5000, 5000);
3402}

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
5167{
5168 e.timer = 1200;
5169 // Change priority only if it's set to default, otherwise keep the current order of events
5171 {
5173 mEventSortingRequired = true;
5174 }
5175}
uint32 timer
Definition SmartScriptMgr.h:2018
uint32 priority
Definition SmartScriptMgr.h:2019

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
4965{
4966 // min/max was checked at loading!
4967 e.timer = urand(uint32(min), uint32(max));
4968 e.active = e.timer ? false : true;
4969}

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5535{
5536 _summonList.erase(guid);
5537}

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:184
Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:210

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

Referenced by OnReset(), and ProcessAction().

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private
5178{
5179 RaisePriority(e);
5180
5181 // This allows to retry the action later without rolling again the chance roll (which might fail and end up not executing the action)
5182 if (ignoreChanceRoll)
5184
5185 e.runOnce = false;
5186}
void RaisePriority(SmartScriptHolder &e)
Definition SmartScript.cpp:5166

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
5508{
5509 uint32 oldPhase = mEventPhase;
5510
5511 mEventPhase = p;
5512
5513 if (oldPhase != mEventPhase)
5514 {
5516 }
5517}

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 
)
5413{
5414 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
5415 // any SmartScriptHolder contained like the "e" parameter passed to this function
5417 {
5418 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());
5419 return;
5420 }
5421
5422 // 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
5424 {
5425 return;
5426 }
5427
5428 mTimedActionList.clear();
5430 if (mTimedActionList.empty())
5431 return;
5432 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5433 {
5434 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
5435
5436 if (e.action.timedActionList.timerType == 0)
5437 i->event.type = SMART_EVENT_UPDATE_OOC;
5438 else if (e.action.timedActionList.timerType == 1)
5439 i->event.type = SMART_EVENT_UPDATE_IC;
5440 else if (e.action.timedActionList.timerType > 1)
5441 i->event.type = SMART_EVENT_UPDATE;
5442
5443 InitTimer((*i));
5444 }
5445}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition SmartScriptMgr.h:1802
SAIBool allowOverride
Definition SmartScriptMgr.h:1151
uint32 timerType
Definition SmartScriptMgr.h:1150

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

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

◆ SortEvents()

void SmartScript::SortEvents ( SmartAIEventList events)
private
5162{
5163 std::sort(events.begin(), events.end());
5164}
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:2036

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4972{
4973 if (e.GetEventType() == SMART_EVENT_LINK)
4974 return;
4975
4977 return;
4978
4979 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4980 return;
4981
4982 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4983 return;
4984
4985 if (e.timer < diff)
4986 {
4987 // delay spell cast for another AI tick if another spell is being cast
4989 {
4991 {
4993 {
4994 RaisePriority(e);
4995 return;
4996 }
4997 }
4998 }
4999
5000 // Delay flee for assist event if casting
5002 {
5003 e.timer = 1200;
5004 return;
5005 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
5006
5007 e.active = true;//activate events with cooldown
5008 switch (e.GetEventType())//process ONLY timed events
5009 {
5014 case SMART_EVENT_UPDATE:
5021 case SMART_EVENT_RANGE:
5035 {
5036 ASSERT(executionStack.empty());
5037 executionStack.emplace_back(SmartScriptFrame{ e, nullptr, 0, 0, false, nullptr, nullptr });
5038 while (!executionStack.empty())
5039 {
5040 auto [stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob] = executionStack.back();
5041 executionStack.pop_back();
5042 ProcessEvent(stack_holder, stack_unit, stack_var0, stack_var1, stack_bvar, stack_spell, stack_gob);
5043 }
5045 {
5046 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
5047 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
5048 {
5049 //find the first event which is not the current one and enable it
5050 if (i->event_id > e.event_id)
5051 {
5052 i->enableTimed = true;
5053 break;
5054 }
5055 }
5056 }
5057 break;
5058 }
5059 }
5060
5062 {
5063 // Reset priority to default one only if the event hasn't been rescheduled again to next loop
5064 if (e.timer > 1)
5065 {
5066 // Re-sort events if this was moved to the top of the queue
5067 mEventSortingRequired = true;
5068 // Reset priority to default one
5070 }
5071 }
5072 }
5073 else
5074 e.timer -= diff;
5075}
@ UNIT_STATE_CASTING
Definition UnitDefines.h:188
bool enableTimed
Definition SmartScriptMgr.h:2022

References SmartScriptHolder::action, SmartScriptHolder::active, ASSERT, SmartAction::cast, SmartAction::castFlags, SmartScriptHolder::DEFAULT_PRIORITY, SmartScriptHolder::enableTimed, SmartScriptHolder::event, SmartScriptHolder::event_id, SmartEvent::event_phase_mask, executionStack, SmartScriptHolder::GetActionType(), SmartScriptHolder::GetEventType(), SmartScriptHolder::GetScriptType(), Unit::HasUnitState(), 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, SmartScriptHolder::timer, and UNIT_STATE_CASTING.

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ executionStack

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

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

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

◆ mCounterList

CounterMap SmartScript::mCounterList

◆ mCurrentPriority

uint32 SmartScript::mCurrentPriority
private

Referenced by RaisePriority(), and SmartScript().

◆ me

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Referenced by ProcessAction(), and ResetBaseObject().

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

◆ mEvents

◆ mEventSortingRequired

bool SmartScript::mEventSortingRequired
private

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Referenced by AddEvent(), and InstallEvents().

◆ mLastInvoker

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

◆ mPathId

uint32 SmartScript::mPathId
private

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

◆ mRemIDs

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

Referenced by OnUpdate(), and ProcessAction().

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

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

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

◆ mTemplate

SMARTAI_TEMPLATE SmartScript::mTemplate
private

Referenced by InstallTemplate(), and SmartScript().

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

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

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

◆ trigger

AreaTrigger const* SmartScript::trigger
private

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