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

#include "SmartScript.h"

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

 SmartScript ()
 
 ~SmartScript ()
 
void OnInitialize (WorldObject *obj, AreaTrigger const *at=nullptr)
 
void GetScript ()
 
void FillScript (SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
 
void ProcessEventsFor (SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
void ProcessEvent (SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
bool CheckTimer (SmartScriptHolder const &e) const
 
void UpdateTimer (SmartScriptHolder &e, uint32 const diff)
 
void ProcessAction (SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
void ProcessTimedAction (SmartScriptHolder &e, uint32 const &min, uint32 const &max, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr)
 
void GetTargets (ObjectVector &targets, SmartScriptHolder const &e, Unit *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
 
void StoreTargetList (ObjectVector const &targets, uint32 id)
 
bool IsSmart (Creature *c=nullptr)
 
bool IsSmartGO (GameObject *g=nullptr)
 
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)
 
UnitGetLastInvoker (Unit *invoker=nullptr) const
 
void SetActualCombatDist (uint32 dist)
 
void RestoreMaxCombatDist ()
 
uint32 GetActualCombatDist () const
 
uint32 GetMaxCombatDist () const
 
void SetCasterActualDist (float dist)
 
void RestoreCasterMaxDist ()
 
Powers GetCasterPowerType () const
 
float GetCasterActualDist () const
 
float GetCasterMaxDist () const
 
bool AllowPhaseReset () const
 
void SetPhaseReset (bool allow)
 
void AddCreatureSummon (ObjectGuid const &guid)
 
void RemoveCreatureSummon (ObjectGuid const &guid)
 

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

void IncPhase (uint32 p)
 
void DecPhase (uint32 p)
 
void SetPhase (uint32 p)
 
bool IsInPhase (uint32 p) const
 
void InstallEvents ()
 
void RemoveStoredEvent (uint32 id)
 
SmartScriptHolder FindLinkedEvent (uint32 link)
 

Private Attributes

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

Detailed Description

Member Typedef Documentation

◆ CounterMap

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

Constructor & Destructor Documentation

◆ SmartScript()

SmartScript::SmartScript ( )
Todo:
: this import is not necessary for compilation and marked as unused by the IDE
46{
47 go = nullptr;
48 me = nullptr;
49 trigger = nullptr;
50 mEventPhase = 0;
51 mPathId = 0;
52 mTextTimer = 0;
53 mLastTextID = 0;
54 mUseTextTimer = false;
55 mTalkerEntry = 0;
59
60 // Xinef: Fix Combat Movement
63
65 smartCasterMaxDist = 0.0f;
67
68 _allowPhaseReset = true;
69}
@ SMART_SCRIPT_TYPE_CREATURE
Definition: SmartScriptMgr.h:1693
@ SMARTAI_TEMPLATE_BASIC
Definition: SmartScriptMgr.h:1452
@ POWER_MANA
Definition: SharedDefines.h:269
uint32 mEventPhase
Definition: SmartScript.h:254
SMARTAI_TEMPLATE mTemplate
Definition: SmartScript.h:280
Creature * me
Definition: SmartScript.h:248
uint32 mPathId
Definition: SmartScript.h:257
SmartScriptType mScriptType
Definition: SmartScript.h:253
uint32 smartCasterActualDist
Definition: SmartScript.h:271
bool _allowPhaseReset
Definition: SmartScript.h:276
bool mUseTextTimer
Definition: SmartScript.h:264
uint32 mLastTextID
Definition: SmartScript.h:262
uint32 mTextTimer
Definition: SmartScript.h:261
GameObject * go
Definition: SmartScript.h:250
uint32 mMaxCombatDist
Definition: SmartScript.h:268
uint32 mActualCombatDist
Definition: SmartScript.h:267
AreaTrigger const * trigger
Definition: SmartScript.h:252
Powers smartCasterPowerType
Definition: SmartScript.h:273
uint32 mTalkerEntry
Definition: SmartScript.h:263
uint32 smartCasterMaxDist
Definition: SmartScript.h:272
bool isProcessingTimedActionList
Definition: SmartScript.h:247

References _allowPhaseReset, go, isProcessingTimedActionList, mActualCombatDist, me, mEventPhase, mLastTextID, mMaxCombatDist, mPathId, mScriptType, mTalkerEntry, mTemplate, mTextTimer, mUseTextTimer, POWER_MANA, SMART_SCRIPT_TYPE_CREATURE, SMARTAI_TEMPLATE_BASIC, smartCasterActualDist, smartCasterMaxDist, smartCasterPowerType, and trigger.

◆ ~SmartScript()

SmartScript::~SmartScript ( )
72{
73
74}

Member Function Documentation

◆ AddCreatureSummon()

void SmartScript::AddCreatureSummon ( ObjectGuid const &  guid)
5091{
5092 _summonList.insert(guid);
5093}
GuidUnorderedSet _summonList
Definition: SmartScript.h:313

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 
)
3137{
3138 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));
3139}
SmartAIEventList mInstallEvents
Definition: SmartScript.h:245
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:3141

References CreateSmartEvent(), and mInstallEvents.

Referenced by InstallTemplate().

◆ AllowPhaseReset()

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

References _allowPhaseReset.

Referenced by OnReset().

◆ CheckTimer()

bool SmartScript::CheckTimer ( SmartScriptHolder const &  e) const
4643{
4644 return e.active;
4645}

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
3142{
3143 SmartScriptHolder script;
3144 script.event.type = e;
3145 script.event.raw.param1 = event_param1;
3146 script.event.raw.param2 = event_param2;
3147 script.event.raw.param3 = event_param3;
3148 script.event.raw.param4 = event_param4;
3149 script.event.raw.param5 = event_param5;
3150 script.event.raw.param6 = event_param6;
3151 script.event.event_phase_mask = phaseMask;
3152 script.event.event_flags = event_flags;
3153 script.event.event_chance = 100;
3154
3155 script.action.type = action;
3156 script.action.raw.param1 = action_param1;
3157 script.action.raw.param2 = action_param2;
3158 script.action.raw.param3 = action_param3;
3159 script.action.raw.param4 = action_param4;
3160 script.action.raw.param5 = action_param5;
3161 script.action.raw.param6 = action_param6;
3162
3163 script.target.type = t;
3164 script.target.raw.param1 = target_param1;
3165 script.target.raw.param2 = target_param2;
3166 script.target.raw.param3 = target_param3;
3167 script.target.raw.param4 = target_param4;
3168
3170 InitTimer(script);
3171 return script;
3172}
static void InitTimer(SmartScriptHolder &e)
Definition: SmartScript.cpp:4517
uint32 param1
Definition: SmartScriptMgr.h:510
uint32 event_flags
Definition: SmartScriptMgr.h:224
uint32 event_phase_mask
Definition: SmartScriptMgr.h:222
uint32 param2
Definition: SmartScriptMgr.h:511
struct SmartEvent::@30::@72 raw
uint32 param4
Definition: SmartScriptMgr.h:513
uint32 param3
Definition: SmartScriptMgr.h:512
uint32 param6
Definition: SmartScriptMgr.h:515
uint32 event_chance
Definition: SmartScriptMgr.h:223
uint32 param5
Definition: SmartScriptMgr.h:514
SMART_EVENT type
Definition: SmartScriptMgr.h:221
uint32 param3
Definition: SmartScriptMgr.h:1046
uint32 param5
Definition: SmartScriptMgr.h:1048
uint32 param1
Definition: SmartScriptMgr.h:1044
struct SmartAction::@73::@188 raw
SMART_ACTION type
Definition: SmartScriptMgr.h:732
uint32 param4
Definition: SmartScriptMgr.h:1047
uint32 param6
Definition: SmartScriptMgr.h:1445
uint32 param2
Definition: SmartScriptMgr.h:1045
uint32 param4
Definition: SmartScriptMgr.h:1673
uint32 param1
Definition: SmartScriptMgr.h:1670
uint32 param3
Definition: SmartScriptMgr.h:1672
SMARTAI_TARGETS type
Definition: SmartScriptMgr.h:1523
uint32 param2
Definition: SmartScriptMgr.h:1671
struct SmartTarget::@189::@213 raw
Definition: SmartScriptMgr.h:1887
SmartAction action
Definition: SmartScriptMgr.h:1898
SmartScriptType source_type
Definition: SmartScriptMgr.h:1893
SmartEvent event
Definition: SmartScriptMgr.h:1897
SmartTarget target
Definition: SmartScriptMgr.h:1899

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

Referenced by AddEvent().

◆ DecPhase()

void SmartScript::DecPhase ( uint32  p)
private
5057{
5058 if (p >= mEventPhase)
5059 {
5060 SetPhase(0);
5061 }
5062 else
5063 {
5064 SetPhase(mEventPhase - p);
5065 }
5066}
void SetPhase(uint32 p)
Definition: SmartScript.cpp:5068

References mEventPhase, and SetPhase().

Referenced by ProcessAction().

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const
4962{
4963 if (!me)
4964 return nullptr;
4965
4966 Unit* unit = nullptr;
4967 Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
4969 Cell::VisitAllObjects(me, searcher, range);
4970 return unit;
4971}
Definition: Unit.h:1302
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:207
Definition: GridNotifiers.h:403

References me, and Cell::VisitAllObjects().

Referenced by GetTargets().

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const
4942{
4943 if (!me)
4944 return;
4945
4946 Acore::FriendlyCCedInRange u_check(me, range);
4948 Cell::VisitGridObjects(me, searcher, range);
4949}
creatures
Definition: boss_prince_malchezaar.cpp:51
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GridNotifiers.h:470
Definition: GridNotifiers.h:815

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const
4952{
4953 if (!me)
4954 return;
4955
4956 Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
4958 Cell::VisitGridObjects(me, searcher, range);
4959}
Definition: GridNotifiers.h:833

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const
4915{
4916 if (!me)
4917 return nullptr;
4918
4919 Unit* unit = nullptr;
4920
4921 Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
4923 Cell::VisitGridObjects(me, searcher, range);
4924 return unit;
4925}
Definition: GridNotifiers.h:772

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const
4928{
4929 if (!me)
4930 {
4931 return nullptr;
4932 }
4933
4934 Unit* unit = nullptr;
4935 Acore::MostHPPercentMissingInRange u_check(me, range, minHpPct, maxHpPct);
4937 Cell::VisitGridObjects(me, searcher, range);
4938 return unit;
4939}
Definition: GridNotifiers.h:791

References me, and Cell::VisitGridObjects().

Referenced by ProcessEvent().

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTrigger const *  at 
)
4721{
4722 (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks
4723
4724 if (e.empty())
4725 {
4726 if (obj)
4727 LOG_DEBUG("sql.sql", "SmartScript: EventMap for Entry {} is empty but is using SmartScript.", obj->GetEntry());
4728
4729 if (at)
4730 LOG_DEBUG("sql.sql", "SmartScript: EventMap for AreaTrigger {} is empty but is using SmartScript.", at->entry);
4731 return;
4732 }
4733 for (SmartAIEventList::iterator i = e.begin(); i != e.end(); ++i)
4734 {
4735#ifndef ACORE_DEBUG
4736 if ((*i).event.event_flags & SMART_EVENT_FLAG_DEBUG_ONLY)
4737 continue;
4738#endif
4739
4740 if ((*i).event.event_flags & SMART_EVENT_FLAG_DIFFICULTY_ALL)//if has instance flag add only if in it
4741 {
4742 if (obj && obj->GetMap()->IsDungeon())
4743 {
4744 if ((1 << (obj->GetMap()->GetSpawnMode() + 1)) & (*i).event.event_flags)
4745 {
4746 mEvents.push_back((*i));
4747 }
4748 }
4749 continue;
4750 }
4751 mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
4752 }
4753}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
@ SMART_EVENT_FLAG_DIFFICULTY_ALL
Definition: SmartScriptMgr.h:1858
@ SMART_EVENT_FLAG_DEBUG_ONLY
Definition: SmartScriptMgr.h:1854
SmartAIEventList mEvents
Definition: SmartScript.h:244
uint32 GetEntry() const
Definition: Object.h:109
Map * GetMap() const
Definition: Object.h:517
bool IsDungeon() const
Definition: Map.h:448
uint8 GetSpawnMode() const
Definition: Map.h:420

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

Referenced by GetScript().

◆ FindCreatureNear()

Creature * SmartScript::FindCreatureNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const
inline
167 {
168 auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid);
169 if (bounds.first == bounds.second)
170 return nullptr;
171
172 auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
173 {
174 return pair.second->IsAlive();
175 });
176
177 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
178 }
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:519

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindGameObjectNear()

GameObject * SmartScript::FindGameObjectNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const
inline
158 {
159 auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
160 if (bounds.first == bounds.second)
161 return nullptr;
162
163 return bounds.first->second;
164 }
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:522

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

Referenced by GetTargets(), and ProcessEvent().

◆ FindLinkedEvent()

SmartScriptHolder SmartScript::FindLinkedEvent ( uint32  link)
inlineprivate
298 {
299 if (!mEvents.empty())
300 {
301 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
302 {
303 if (i->event_id == link)
304 {
305 return (*i);
306 }
307 }
308 }
310 return s;
311 }

References mEvents.

◆ GetActualCombatDist()

uint32 SmartScript::GetActualCombatDist ( ) const
inline
222{ return mActualCombatDist; }

References mActualCombatDist.

Referenced by SmartAI::AttackStart().

◆ GetBaseObject()

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

References go, and me.

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

◆ GetCasterActualDist()

float SmartScript::GetCasterActualDist ( ) const
inline

◆ GetCasterMaxDist()

float SmartScript::GetCasterMaxDist ( ) const
inline
230{ return smartCasterMaxDist; }

References smartCasterMaxDist.

Referenced by ProcessAction().

◆ GetCasterPowerType()

Powers SmartScript::GetCasterPowerType ( ) const
inline
228{ return smartCasterPowerType; }

References smartCasterPowerType.

Referenced by ProcessAction().

◆ GetCounterValue()

uint32 SmartScript::GetCounterValue ( uint32  id)
inline
150 {
151 CounterMap::iterator itr = mCounterList.find(id);
152 if (itr != mCounterList.end())
153 return itr->second;
154 return 0;
155 }
CounterMap mCounterList
Definition: SmartScript.h:217

References mCounterList.

Referenced by ProcessEvent().

◆ GetLastInvoker()

Unit * SmartScript::GetLastInvoker ( Unit invoker = nullptr) const
5009{
5010 // Xinef: Look for invoker only on map of base object... Prevents multithreaded crashes
5011 if (GetBaseObject())
5013 // xinef: used for area triggers invoker cast
5014 else if (invoker)
5015 return ObjectAccessor::GetUnit(*invoker, mLastInvoker);
5016 return nullptr;
5017}
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:202
ObjectGuid mLastInvoker
Definition: SmartScript.h:215
WorldObject * GetBaseObject() const
Definition: SmartScript.h:54

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

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

◆ GetMaxCombatDist()

uint32 SmartScript::GetMaxCombatDist ( ) const
inline
223{ return mMaxCombatDist; }

References mMaxCombatDist.

Referenced by ProcessAction().

◆ GetPathId()

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

References mPathId.

Referenced by ProcessEvent().

◆ GetScript()

void SmartScript::GetScript ( )
4756{
4758 if (me)
4759 {
4760 e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
4761 if (e.empty())
4762 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
4763
4764 FillScript(e, me, nullptr);
4765
4766 if (CreatureTemplate const* cInfo = me->GetCreatureTemplate())
4767 {
4768 if (cInfo->HasFlagsExtra(CREATURE_FLAG_DONT_OVERRIDE_ENTRY_SAI))
4769 {
4770 e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
4771 FillScript(e, me, nullptr);
4772 }
4773 }
4774 }
4775 else if (go)
4776 {
4777 e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
4778 if (e.empty())
4779 e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
4780 FillScript(e, go, nullptr);
4781 }
4782 else if (trigger)
4783 {
4784 e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
4785 FillScript(e, nullptr, trigger);
4786 }
4787}
std::int32_t int32
Definition: Define.h:104
std::vector< SmartScriptHolder > SmartAIEventList
Definition: SmartScriptMgr.h:1974
#define sSmartScriptMgr
Definition: SmartScriptMgr.h:2148
@ CREATURE_FLAG_DONT_OVERRIDE_ENTRY_SAI
Definition: CreatureData.h:76
void FillScript(SmartAIEventList e, WorldObject *obj, AreaTrigger const *at)
Definition: SmartScript.cpp:4720
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:67
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:199
Definition: CreatureData.h:176
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:146
uint32 entry
Definition: ObjectMgr.h:422

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

Referenced by OnInitialize().

◆ GetStoredTargetVector()

ObjectVector const * SmartScript::GetStoredTargetVector ( uint32  id,
WorldObject const &  ref 
) const
inline
116 {
117 auto itr = _storedTargets.find(id);
118 if (itr != _storedTargets.end())
119 return itr->second.GetObjectVector(ref);
120 return nullptr;
121 }
ObjectVectorMap _storedTargets
Definition: SmartScript.h:278

References _storedTargets.

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

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
Unit invoker = nullptr 
) const
3175{
3176 Unit* scriptTrigger = nullptr;
3177 if (invoker)
3178 scriptTrigger = invoker;
3179 else if (Unit* tempLastInvoker = GetLastInvoker())
3180 scriptTrigger = tempLastInvoker;
3181
3182 WorldObject* baseObject = GetBaseObject();
3183
3184 switch (e.GetTargetType())
3185 {
3186 case SMART_TARGET_SELF:
3187 if (baseObject)
3188 targets.push_back(baseObject);
3189 break;
3191 if (me)
3192 if (Unit* victim = me->GetVictim())
3193 targets.push_back(victim);
3194 break;
3196 if (me)
3197 {
3198 if (e.target.hostileRandom.powerType)
3199 {
3200 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
3201 targets.push_back(u);
3202 }
3203 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3204 targets.push_back(u);
3205 }
3206 break;
3208 if (me)
3209 {
3210 if (e.target.hostileRandom.powerType)
3211 {
3212 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)))
3213 targets.push_back(u);
3214 }
3215 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3216 targets.push_back(u);
3217 }
3218 break;
3220 if (me)
3221 {
3222 if (e.target.hostileRandom.powerType)
3223 {
3224 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)))
3225 targets.push_back(u);
3226 }
3227 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3228 targets.push_back(u);
3229 }
3230 break;
3232 if (me)
3233 {
3234 if (e.target.hostileRandom.powerType)
3235 {
3236 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
3237 targets.push_back(u);
3238 }
3239 else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
3240 targets.push_back(u);
3241 }
3242 break;
3244 if (me)
3245 {
3246 if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, FarthestTargetSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos)))
3247 targets.push_back(u);
3248 }
3249 break;
3251 if (scriptTrigger)
3252 targets.push_back(scriptTrigger);
3253 break;
3255 if (scriptTrigger && scriptTrigger->GetVehicle() && scriptTrigger->GetVehicle()->GetBase())
3256 targets.push_back(scriptTrigger->GetVehicle()->GetBase());
3257 break;
3259 if (scriptTrigger)
3260 {
3261 if (Player* player = scriptTrigger->ToPlayer())
3262 {
3263 if (Group* group = player->GetGroup())
3264 {
3265 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
3266 if (Player* member = groupRef->GetSource())
3267 if (member->IsInMap(player))
3268 targets.push_back(member);
3269 }
3270 // We still add the player to the list if there is no group. If we do
3271 // this even if there is a group (thus the else-check), it will add the
3272 // same player to the list twice. We don't want that to happen.
3273 else
3274 targets.push_back(scriptTrigger);
3275 }
3276 }
3277 break;
3279 {
3280 WorldObject* ref = baseObject;
3281 if (!ref)
3282 ref = scriptTrigger;
3283
3284 if (!ref)
3285 {
3286 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_RANGE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker",
3287 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3288 break;
3289 }
3290
3291 ObjectVector units;
3292 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
3293
3294 for (WorldObject* unit : units)
3295 {
3296 if (!IsCreature(unit))
3297 continue;
3298
3299 if (me && me->GetGUID() == unit->GetGUID())
3300 continue;
3301
3302 // check alive state - 1 alive, 2 dead, 0 both
3303 if (uint32 state = e.target.unitRange.livingState)
3304 {
3305 if (unit->ToCreature()->IsAlive() && state == 2)
3306 continue;
3307 if (!unit->ToCreature()->IsAlive() && state == 1)
3308 continue;
3309 }
3310
3311 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))
3312 targets.push_back(unit);
3313 }
3314
3315 break;
3316 }
3318 {
3319 ObjectVector units;
3320 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitDistance.dist));
3321
3322 for (WorldObject* unit : units)
3323 {
3324 if (!IsCreature(unit))
3325 continue;
3326
3327 if (me && me->GetGUID() == unit->GetGUID())
3328 continue;
3329
3330 // check alive state - 1 alive, 2 dead, 0 both
3331 if (uint32 state = e.target.unitDistance.livingState)
3332 {
3333 if (unit->ToCreature()->IsAlive() && state == 2)
3334 continue;
3335 if (!unit->ToCreature()->IsAlive() && state == 1)
3336 continue;
3337 }
3338
3339 if ((e.target.unitDistance.creature && unit->ToCreature()->GetEntry() == e.target.unitDistance.creature) || !e.target.unitDistance.creature)
3340 targets.push_back(unit);
3341 }
3342
3343 break;
3344 }
3346 {
3347 ObjectVector units;
3348 GetWorldObjectsInDist(units, static_cast<float>(e.target.goDistance.dist));
3349
3350 for (WorldObject* unit : units)
3351 {
3352 if (!IsGameObject(unit))
3353 continue;
3354
3355 if (go && go->GetGUID() == unit->GetGUID())
3356 continue;
3357
3358 if ((e.target.goDistance.entry && unit->ToGameObject()->GetEntry() == e.target.goDistance.entry) || !e.target.goDistance.entry)
3359 targets.push_back(unit);
3360 }
3361
3362 break;
3363 }
3365 {
3366
3367 WorldObject* ref = baseObject;
3368 if (!ref)
3369 ref = scriptTrigger;
3370
3371 if (!ref)
3372 {
3373 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_RANGE: Entry: {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3374 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3375 break;
3376 }
3377
3378 ObjectVector units;
3379 GetWorldObjectsInDist(units, static_cast<float>(e.target.goRange.maxDist));
3380
3381 for (WorldObject* unit : units)
3382 {
3383 if (!IsGameObject(unit))
3384 continue;
3385
3386 if (go && go->GetGUID() == unit->GetGUID())
3387 continue;
3388
3389 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))
3390 targets.push_back(unit);
3391 }
3392
3393 break;
3394 }
3396 {
3397 if (!scriptTrigger && !baseObject)
3398 {
3399 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CREATURE_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3400 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3401 break;
3402 }
3403
3404 Creature* target = FindCreatureNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.unitGUID.dbGuid);
3405 if (target && (!e.target.unitGUID.entry || target->GetEntry() == e.target.unitGUID.entry))
3406 targets.push_back(target);
3407 break;
3408 }
3410 {
3411 if (!scriptTrigger && !GetBaseObject())
3412 {
3413 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_GAMEOBJECT_GUID: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3414 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3415 break;
3416 }
3417
3418 GameObject* target = FindGameObjectNear(scriptTrigger ? scriptTrigger : GetBaseObject(), e.target.goGUID.dbGuid);
3419 if (target && (!e.target.goGUID.entry || target->GetEntry() == e.target.goGUID.entry))
3420 targets.push_back(target);
3421 break;
3422 }
3424 {
3425 ObjectVector units;
3426 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerRange.maxDist));
3427
3428 if (!units.empty() && baseObject)
3429 for (WorldObject* unit : units)
3430 if (IsPlayer(unit) && baseObject->IsInRange(unit, float(e.target.playerRange.minDist), float(e.target.playerRange.maxDist)))
3431 targets.push_back(unit);
3432 break;
3433 }
3435 {
3436 ObjectVector units;
3437 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3438
3439 for (WorldObject* unit : units)
3440 if (IsPlayer(unit))
3441 targets.push_back(unit);
3442 break;
3443 }
3445 {
3446 WorldObject* ref = baseObject;
3447 if (!ref)
3448 ref = scriptTrigger;
3449
3450 if (!ref)
3451 {
3452 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_STORED: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3453 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3454 break;
3455 }
3456
3457 if (ObjectVector const* stored = GetStoredTargetVector(e.target.stored.id, *ref))
3458 targets.assign(stored->begin(), stored->end());
3459 break;
3460 }
3462 {
3463 WorldObject* ref = baseObject;
3464
3465 if (!ref)
3466 ref = scriptTrigger;
3467
3468 if (!ref)
3469 {
3470 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_CREATURE: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3471 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3472 break;
3473 }
3474
3475 Creature* target = GetClosestCreatureWithEntry(ref, e.target.unitClosest.entry, (float)(e.target.unitClosest.dist ? e.target.unitClosest.dist : 100), !e.target.unitClosest.dead);
3476 if (target)
3477 targets.push_back(target);
3478 break;
3479 }
3481 {
3482 WorldObject* ref = baseObject;
3483
3484 if (!ref)
3485 ref = scriptTrigger;
3486
3487 if (!ref)
3488 {
3489 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_GAMEOBJECT: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3490 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3491 break;
3492 }
3493
3494 GameObject* target = GetClosestGameObjectWithEntry(ref, e.target.goClosest.entry, (float)(e.target.goClosest.dist ? e.target.goClosest.dist : 100), e.target.goClosest.onlySpawned);
3495 if (target)
3496 targets.push_back(target);
3497 break;
3498 }
3500 {
3501 WorldObject* ref = baseObject;
3502
3503 if (!ref)
3504 ref = scriptTrigger;
3505
3506 if (!ref)
3507 {
3508 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_CLOSEST_PLAYER: Entry {} SourceType {} Event {} Action {} Target {} is missing base object or invoker.",
3509 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3510 break;
3511 }
3512
3513 if (Player* target = ref->SelectNearestPlayer((float)e.target.playerDistance.dist))
3514 targets.push_back(target);
3515 break;
3516 }
3518 /*
3519 * Owners/Summoners should be WorldObjects. This allows to have other objects
3520 * such as gameobjects to execute SmartScripts using this type of target.
3521 * Otherwise, only Units like creatures can summon other creatures.
3522 */
3523 {
3524 if (me)
3525 {
3527 {
3528 targets.push_back(owner);
3529 }
3530 else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
3531 {
3532 targets.push_back(me->ToTempSummon()->GetSummonerUnit());
3533 }
3534 }
3535 else if (go)
3536 {
3538 {
3539 targets.push_back(owner);
3540 }
3541 }
3542
3543 // xinef: Get owner of owner
3544 if (e.target.owner.useCharmerOrOwner && !targets.empty())
3545 {
3546 if (WorldObject* owner = targets.front())
3547 {
3548 targets.clear();
3549
3550 if (owner->ToCreature())
3551 {
3552 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
3553 {
3554 targets.push_back(base);
3555 }
3556 }
3557 else
3558 {
3559 if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
3560 {
3561 targets.push_back(base);
3562 }
3563 }
3564 }
3565 }
3566 break;
3567 }
3569 {
3570 if (me)
3571 {
3573 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
3574 if (Unit* temp = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
3575 // Xinef: added distance check
3576 if (e.target.threatList.maxDist == 0 || me->IsWithinCombatRange(temp, (float)e.target.threatList.maxDist))
3577 targets.push_back(temp);
3578 }
3579 break;
3580 }
3582 {
3583 if (me)
3584 if (Unit* target = me->SelectNearestTarget(e.target.closestAttackable.maxDist, e.target.closestAttackable.playerOnly))
3585 targets.push_back(target);
3586
3587 break;
3588 }
3590 {
3591 if (me)
3592 if (Unit* target = DoFindClosestFriendlyInRange(e.target.closestFriendly.maxDist, e.target.closestFriendly.playerOnly))
3593 targets.push_back(target);
3594
3595 break;
3596 }
3598 {
3599 ObjectVector units;
3600 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3601
3602 for (WorldObject* unit : units)
3603 if (IsPlayer(unit) && unit->ToPlayer()->IsAlive() && !unit->ToPlayer()->IsGameMaster())
3604 if (GetBaseObject()->IsInRange(unit, (float)e.target.playerWithAura.distMin, (float)e.target.playerWithAura.distMax))
3605 if (bool(e.target.playerWithAura.negation) != unit->ToPlayer()->HasAura(e.target.playerWithAura.spellId))
3606 targets.push_back(unit);
3607
3608 if (e.target.o > 0)
3609 Acore::Containers::RandomResize(targets, e.target.o);
3610
3611 break;
3612 }
3614 {
3615 ObjectVector units;
3616 GetWorldObjectsInDist(units, static_cast<float>(e.target.playerDistance.dist));
3617 // 1 = Tanks, 2 = Healer, 4 = Damage
3618 uint32 roleMask = e.target.roleSelection.roleMask;
3619 for (WorldObject* unit : units)
3620 if (Player* targetPlayer = unit->ToPlayer())
3621 if (targetPlayer->IsAlive() && !targetPlayer->IsGameMaster())
3622 {
3623 if (roleMask & SMART_TARGET_ROLE_FLAG_TANKS)
3624 {
3625 if (targetPlayer->HasTankSpec())
3626 {
3627 targets.push_back(unit);
3628 continue;
3629 }
3630 }
3631 if (roleMask & SMART_TARGET_ROLE_FLAG_HEALERS)
3632 {
3633 if (targetPlayer->HasHealSpec())
3634 {
3635 targets.push_back(unit);
3636 continue;
3637 }
3638 }
3639 if (roleMask & SMART_TARGET_ROLE_FLAG_DAMAGERS)
3640 {
3641 if (targetPlayer->HasCasterSpec() || targetPlayer->HasMeleeSpec())
3642 {
3643 targets.push_back(unit);
3644 continue;
3645 }
3646 }
3647 }
3648
3649 if (e.target.roleSelection.resize > 0)
3650 Acore::Containers::RandomResize(targets, e.target.roleSelection.resize);
3651
3652 break;
3653 }
3655 {
3656 if (me && me->IsVehicle())
3657 {
3658 if (Unit* target = me->GetVehicleKit()->GetPassenger(e.target.vehicle.seatMask))
3659 {
3660 targets.push_back(target);
3661 }
3662 }
3663 break;
3664 }
3666 {
3667 if (me)
3668 {
3669 if (Group* lootGroup = me->GetLootRecipientGroup())
3670 {
3671 for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
3672 {
3673 if (Player* recipient = it->GetSource())
3674 {
3675 targets.push_back(recipient);
3676 }
3677 }
3678 }
3679 else
3680 {
3681 if (Player* recipient = me->GetLootRecipient())
3682 {
3683 targets.push_back(recipient);
3684 }
3685 }
3686 }
3687 break;
3688 }
3690 {
3691 if (me)
3692 {
3693 for (ObjectGuid const& guid : _summonList)
3694 {
3695 if (!e.target.summonedCreatures.entry || guid.GetEntry() == e.target.summonedCreatures.entry)
3696 {
3697 if (Creature* creature = me->GetMap()->GetCreature(guid))
3698 {
3699 targets.push_back(creature);
3700 }
3701 }
3702 }
3703 }
3704 break;
3705 }
3707 {
3708 if (InstanceScript* instance = GetBaseObject()->GetInstanceScript())
3709 {
3710 if (e.target.instanceStorage.type == 1)
3711 {
3712 if (Creature* creature = instance->GetCreature(e.target.instanceStorage.index))
3713 {
3714 targets.push_back(creature);
3715 }
3716 }
3717 else if (e.target.instanceStorage.type == 2)
3718 {
3719 if (GameObject* go = instance->GetGameObject(e.target.instanceStorage.index))
3720 {
3721 targets.push_back(go);
3722 }
3723 }
3724 }
3725 else
3726 {
3727 LOG_ERROR("scripts.ai.sai", "SMART_TARGET_INSTANCE_STORAGE: Entry {} SourceType {} Event {} Action {} Target {} called outside an instance map.",
3728 e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
3729 }
3730
3731 break;
3732 }
3733 case SMART_TARGET_NONE:
3735 default:
3736 break;
3737 }
3738}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition: ScriptedCreature.cpp:808
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool onlySpawned)
Definition: ScriptedCreature.cpp:813
@ SMART_TARGET_ROLE_FLAG_HEALERS
Definition: SmartScriptMgr.h:1687
@ SMART_TARGET_ROLE_FLAG_TANKS
Definition: SmartScriptMgr.h:1686
@ SMART_TARGET_ROLE_FLAG_DAMAGERS
Definition: SmartScriptMgr.h:1688
@ SMART_TARGET_LOOT_RECIPIENTS
Definition: SmartScriptMgr.h:1490
@ SMART_TARGET_CLOSEST_CREATURE
Definition: SmartScriptMgr.h:1482
@ SMART_TARGET_CREATURE_DISTANCE
Definition: SmartScriptMgr.h:1474
@ SMART_TARGET_HOSTILE_RANDOM_NOT_TOP
Definition: SmartScriptMgr.h:1469
@ SMART_TARGET_INVOKER_PARTY
Definition: SmartScriptMgr.h:1479
@ SMART_TARGET_CLOSEST_FRIENDLY
Definition: SmartScriptMgr.h:1489
@ SMART_TARGET_CLOSEST_GAMEOBJECT
Definition: SmartScriptMgr.h:1483
@ SMART_TARGET_VEHICLE_PASSENGER
Definition: SmartScriptMgr.h:1492
@ SMART_TARGET_GAMEOBJECT_RANGE
Definition: SmartScriptMgr.h:1476
@ SMART_TARGET_CREATURE_GUID
Definition: SmartScriptMgr.h:1473
@ SMART_TARGET_PLAYER_RANGE
Definition: SmartScriptMgr.h:1480
@ SMART_TARGET_SUMMONED_CREATURES
Definition: SmartScriptMgr.h:1503
@ SMART_TARGET_VICTIM
Definition: SmartScriptMgr.h:1465
@ SMART_TARGET_GAMEOBJECT_DISTANCE
Definition: SmartScriptMgr.h:1478
@ SMART_TARGET_CREATURE_RANGE
Definition: SmartScriptMgr.h:1472
@ SMART_TARGET_CLOSEST_PLAYER
Definition: SmartScriptMgr.h:1484
@ SMART_TARGET_HOSTILE_RANDOM
Definition: SmartScriptMgr.h:1468
@ SMART_TARGET_GAMEOBJECT_GUID
Definition: SmartScriptMgr.h:1477
@ SMART_TARGET_HOSTILE_SECOND_AGGRO
Definition: SmartScriptMgr.h:1466
@ SMART_TARGET_OWNER_OR_SUMMONER
Definition: SmartScriptMgr.h:1486
@ SMART_TARGET_SELF
Definition: SmartScriptMgr.h:1464
@ SMART_TARGET_PLAYER_WITH_AURA
Definition: SmartScriptMgr.h:1500
@ SMART_TARGET_ROLE_SELECTION
Definition: SmartScriptMgr.h:1502
@ SMART_TARGET_ACTION_INVOKER
Definition: SmartScriptMgr.h:1470
@ SMART_TARGET_POSITION
Definition: SmartScriptMgr.h:1471
@ SMART_TARGET_HOSTILE_LAST_AGGRO
Definition: SmartScriptMgr.h:1467
@ SMART_TARGET_ACTION_INVOKER_VEHICLE
Definition: SmartScriptMgr.h:1485
@ SMART_TARGET_INSTANCE_STORAGE
Definition: SmartScriptMgr.h:1504
@ SMART_TARGET_FARTHEST
Definition: SmartScriptMgr.h:1491
@ SMART_TARGET_THREAT_LIST
Definition: SmartScriptMgr.h:1487
@ SMART_TARGET_CLOSEST_ENEMY
Definition: SmartScriptMgr.h:1488
@ SMART_TARGET_NONE
Definition: SmartScriptMgr.h:1463
@ SMART_TARGET_PLAYER_DISTANCE
Definition: SmartScriptMgr.h:1481
@ SMART_TARGET_STORED
Definition: SmartScriptMgr.h:1475
std::vector< WorldObject * > ObjectVector
Definition: SmartScriptMgr.h:1915
Powers
Definition: SharedDefines.h:268
void RandomResize(C &container, std::size_t requestedSize)
Definition: Containers.h:81
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:118
Definition: UnitAI.h:124
Definition: UnitAI.h:154
Unit * SelectTarget(SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:110
static bool IsPlayer(WorldObject *obj)
Definition: SmartScript.cpp:5024
Unit * GetLastInvoker(Unit *invoker=nullptr) const
Definition: SmartScript.cpp:5008
static bool IsCreature(WorldObject *obj)
Definition: SmartScript.cpp:5029
void GetWorldObjectsInDist(ObjectVector &objects, float dist) const
Definition: SmartScript.cpp:3740
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:166
static bool IsGameObject(WorldObject *obj)
Definition: SmartScript.cpp:5045
ObjectVector const * GetStoredTargetVector(uint32 id, WorldObject const &ref) const
Definition: SmartScript.h:115
Unit * DoFindClosestFriendlyInRange(float range, bool playerOnly) const
Definition: SmartScript.cpp:4961
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:157
std::list< HostileReference * > StorageType
Definition: ThreatMgr.h:148
ThreatContainer::StorageType const & GetThreatList() const
Definition: ThreatMgr.h:274
Definition: Creature.h:46
Player * GetLootRecipient() const
Definition: Creature.cpp:1244
Group * GetLootRecipientGroup() const
Definition: Creature.cpp:1251
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Definition: Creature.cpp:2323
CreatureAI * AI() const
Definition: Creature.h:136
Unit * GetSummonerUnit() const
Definition: TemporarySummon.cpp:44
Definition: GameObject.h:122
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:175
Player * ToPlayer()
Definition: Object.h:195
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Player * SelectNearestPlayer(float distance=0) const
Definition: Object.cpp:2461
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition: Object.cpp:1404
Definition: ObjectGuid.h:120
Definition: Player.h:1056
bool IsVehicle() const
Definition: Unit.h:1428
Vehicle * GetVehicle() const
Definition: Unit.h:2368
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:667
TempSummon * ToTempSummon()
Definition: Unit.h:2414
bool IsSummon() const
Definition: Unit.h:1422
Unit * GetVictim() const
Definition: Unit.h:1398
ThreatMgr & GetThreatMgr()
Definition: Unit.h:2159
Vehicle * GetVehicleKit() const
Definition: Unit.h:2367
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.h:1844
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:39
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:226
Definition: Group.h:169
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
Definition: InstanceScript.h:141
Creature * GetCreature(ObjectGuid const guid)
Definition: Map.cpp:3307

References _summonList, Creature::AI(), SmartTarget::aura, SmartTarget::closestAttackable, SmartTarget::closestFriendly, SmartTarget::creature, SmartTarget::dbGuid, SmartTarget::dead, SmartTarget::dist, SmartTarget::distMax, SmartTarget::distMin, DoFindClosestFriendlyInRange(), SmartTarget::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event_id, SmartTarget::farthest, FindCreatureNear(), FindGameObjectNear(), SmartScriptHolder::GetActionType(), Vehicle::GetBase(), GetBaseObject(), Unit::GetCharmerOrOwnerGUID(), GetClosestCreatureWithEntry(), GetClosestGameObjectWithEntry(), Map::GetCreature(), Object::GetEntry(), Object::GetGUID(), GetLastInvoker(), Creature::GetLootRecipient(), Creature::GetLootRecipientGroup(), WorldObject::GetMap(), GameObject::GetOwnerGUID(), Vehicle::GetPassenger(), SmartScriptHolder::GetScriptType(), GetStoredTargetVector(), TempSummon::GetSummonerUnit(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), Unit::GetVehicle(), Unit::GetVehicleKit(), Unit::GetVictim(), ObjectAccessor::GetWorldObject(), GetWorldObjectsInDist(), go, SmartTarget::goClosest, SmartTarget::goDistance, SmartTarget::goGUID, SmartTarget::goRange, SmartTarget::hostileRandom, SmartTarget::id, SmartTarget::index, SmartTarget::instanceStorage, IsCreature(), IsGameObject(), SmartTarget::isInLos, WorldObject::IsInRange(), IsPlayer(), Unit::IsSummon(), Unit::IsVehicle(), Unit::IsWithinCombatRange(), SmartTarget::livingState, LOG_ERROR, SmartTarget::maxDist, me, SmartTarget::minDist, SmartTarget::negation, GroupReference::next(), SmartTarget::o, SmartTarget::onlySpawned, SmartTarget::owner, SmartTarget::playerDistance, SmartTarget::playerOnly, SmartTarget::playerRange, SmartTarget::playerWithAura, SmartTarget::powerType, Acore::Containers::RandomResize(), SmartTarget::resize, SmartTarget::roleMask, SmartTarget::roleSelection, SmartTarget::seatMask, WorldObject::SelectNearestPlayer(), Creature::SelectNearestTarget(), UnitAI::SelectTarget(), SMART_TARGET_ACTION_INVOKER, SMART_TARGET_ACTION_INVOKER_VEHICLE, SMART_TARGET_CLOSEST_CREATURE, SMART_TARGET_CLOSEST_ENEMY, SMART_TARGET_CLOSEST_FRIENDLY, SMART_TARGET_CLOSEST_GAMEOBJECT, SMART_TARGET_CLOSEST_PLAYER, SMART_TARGET_CREATURE_DISTANCE, SMART_TARGET_CREATURE_GUID, SMART_TARGET_CREATURE_RANGE, SMART_TARGET_FARTHEST, SMART_TARGET_GAMEOBJECT_DISTANCE, SMART_TARGET_GAMEOBJECT_GUID, SMART_TARGET_GAMEOBJECT_RANGE, SMART_TARGET_HOSTILE_LAST_AGGRO, SMART_TARGET_HOSTILE_RANDOM, SMART_TARGET_HOSTILE_RANDOM_NOT_TOP, SMART_TARGET_HOSTILE_SECOND_AGGRO, SMART_TARGET_INSTANCE_STORAGE, SMART_TARGET_INVOKER_PARTY, SMART_TARGET_LOOT_RECIPIENTS, SMART_TARGET_NONE, SMART_TARGET_OWNER_OR_SUMMONER, SMART_TARGET_PLAYER_DISTANCE, SMART_TARGET_PLAYER_RANGE, SMART_TARGET_PLAYER_WITH_AURA, SMART_TARGET_POSITION, SMART_TARGET_ROLE_FLAG_DAMAGERS, SMART_TARGET_ROLE_FLAG_HEALERS, SMART_TARGET_ROLE_FLAG_TANKS, SMART_TARGET_ROLE_SELECTION, SMART_TARGET_SELF, SMART_TARGET_STORED, SMART_TARGET_SUMMONED_CREATURES, SMART_TARGET_THREAT_LIST, SMART_TARGET_VEHICLE_PASSENGER, SMART_TARGET_VICTIM, SmartTarget::spellId, SmartTarget::stored, SmartTarget::summonedCreatures, SmartScriptHolder::target, SmartTarget::threatList, Object::ToPlayer(), Unit::ToTempSummon(), 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
3741{
3742 WorldObject* obj = GetBaseObject();
3743 if (!obj)
3744 return;
3745
3746 Acore::AllWorldObjectsInRange u_check(obj, dist);
3748 Cell::VisitAllObjects(obj, searcher, dist);
3749}
Definition: GridNotifiers.h:236
Definition: GridNotifiers.h:1582

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

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

◆ IncPhase()

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

References mEventPhase, SetPhase(), and SMART_EVENT_PHASE_12.

Referenced by ProcessAction().

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static
4518{
4519 switch (e.GetEventType())
4520 {
4521 //set only events which have initial timers
4525 break;
4526 case SMART_EVENT_UPDATE:
4529 case SMART_EVENT_RANGE:
4535 break;
4539 break;
4543 break;
4544 default:
4545 e.active = true;
4546 break;
4547 }
4548}
@ SMART_EVENT_FRIENDLY_HEALTH_PCT
Definition: SmartScriptMgr.h:192
@ SMART_EVENT_NEAR_PLAYERS_NEGATION
Definition: SmartScriptMgr.h:210
@ SMART_EVENT_AREA_CASTING
Definition: SmartScriptMgr.h:213
@ SMART_EVENT_DISTANCE_GAMEOBJECT
Definition: SmartScriptMgr.h:194
@ SMART_EVENT_RANGE
Definition: SmartScriptMgr.h:127
@ SMART_EVENT_NEAR_UNIT_NEGATION
Definition: SmartScriptMgr.h:212
@ SMART_EVENT_UPDATE_IC
Definition: SmartScriptMgr.h:118
@ SMART_EVENT_AREA_RANGE
Definition: SmartScriptMgr.h:214
@ SMART_EVENT_UPDATE
Definition: SmartScriptMgr.h:178
@ SMART_EVENT_IS_BEHIND_TARGET
Definition: SmartScriptMgr.h:185
@ SMART_EVENT_UPDATE_OOC
Definition: SmartScriptMgr.h:119
@ SMART_EVENT_NEAR_UNIT
Definition: SmartScriptMgr.h:211
@ SMART_EVENT_DISTANCE_CREATURE
Definition: SmartScriptMgr.h:193
@ SMART_EVENT_NEAR_PLAYERS
Definition: SmartScriptMgr.h:209
static void RecalcTimer(SmartScriptHolder &e, uint32 min, uint32 max)
Definition: SmartScript.cpp:4549
struct SmartEvent::@30::@68 nearPlayer
struct SmartEvent::@30::@32 minMaxRepeat
struct SmartEvent::@30::@70 nearUnit
uint32 repeat
Definition: SmartScriptMgr.h:461
uint32 min
Definition: SmartScriptMgr.h:229
uint32 firstTimer
Definition: SmartScriptMgr.h:476
uint32 max
Definition: SmartScriptMgr.h:230
uint32 timer
Definition: SmartScriptMgr.h:496
struct SmartEvent::@30::@66 distance
bool active
Definition: SmartScriptMgr.h:1908
uint32 GetEventType() const
Definition: SmartScriptMgr.h:1903

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

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

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private
4648{
4649 if (!mInstallEvents.empty())
4650 {
4651 for (SmartAIEventList::iterator i = mInstallEvents.begin(); i != mInstallEvents.end(); ++i)
4652 mEvents.push_back(*i);//must be before UpdateTimers
4653
4654 mInstallEvents.clear();
4655 }
4656}

References mEvents, and mInstallEvents.

Referenced by OnInitialize(), and OnUpdate().

◆ InstallTemplate()

void SmartScript::InstallTemplate ( SmartScriptHolder const &  e)
3063{
3064 if (!GetBaseObject())
3065 return;
3067 {
3068 LOG_ERROR("sql.sql", "SmartScript::InstallTemplate: Entry {} SourceType {} AI Template can not be set more then once, skipped.", e.entryOrGuid, e.GetScriptType());
3069 return;
3070 }
3071 mTemplate = (SMARTAI_TEMPLATE)e.action.installTtemplate.id;
3072 switch ((SMARTAI_TEMPLATE)e.action.installTtemplate.id)
3073 {
3075 {
3076 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);
3077 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);
3078 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);
3079 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);
3080 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);
3081 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);
3082 break;
3083 }
3085 {
3086 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);
3087 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);
3088 break;
3089 }
3091 {
3092 if (!me)
3093 return;
3094 //store cage as id1
3095 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);
3096
3097 //reset(close) cage on hostage(me) respawn
3098 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);
3099
3100 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);
3101 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);
3102
3103 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);
3104 //phase 1: give quest credit on movepoint reached
3106 //phase 1: despawn after time on movepoint reached
3107 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);
3108
3109 if (sCreatureTextMgr->TextExist(me->GetEntry(), (uint8)e.action.installTtemplate.param5))
3110 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);
3111 break;
3112 }
3114 {
3115 if (!go)
3116 return;
3117 //store hostage as id1
3118 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);
3119 //store invoker as id2
3120 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);
3121 //signal hostage
3122 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);
3123 //when hostage raeched end point, give credit to invoker
3124 if (e.action.installTtemplate.param2)
3125 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);
3126 else
3127 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);
3128 break;
3129 }
3131 default:
3132 return;
3133 }
3134}
std::uint8_t uint8
Definition: Define.h:110
SMARTAI_TEMPLATE
Definition: SmartScriptMgr.h:1451
@ SMARTAI_TEMPLATE_CAGED_GO_PART
Definition: SmartScriptMgr.h:1456
@ SMARTAI_TEMPLATE_CAGED_NPC_PART
Definition: SmartScriptMgr.h:1457
@ SMARTAI_TEMPLATE_CASTER
Definition: SmartScriptMgr.h:1453
@ SMARTAI_TEMPLATE_TURRET
Definition: SmartScriptMgr.h:1454
@ SMART_EVENT_FLAG_NOT_REPEATABLE
Definition: SmartScriptMgr.h:1847
@ SMART_ACTION_STORE_TARGET_LIST
Definition: SmartScriptMgr.h:602
@ SMART_ACTION_FORCE_DESPAWN
Definition: SmartScriptMgr.h:579
@ SMART_ACTION_CAST
Definition: SmartScriptMgr.h:549
@ SMART_ACTION_ALLOW_COMBAT_MOVEMENT
Definition: SmartScriptMgr.h:559
@ SMART_ACTION_MOVE_FORWARD
Definition: SmartScriptMgr.h:584
@ SMART_ACTION_CALL_KILLEDMONSTER
Definition: SmartScriptMgr.h:571
@ SMART_ACTION_TALK
Definition: SmartScriptMgr.h:539
@ SMART_ACTION_SET_DATA
Definition: SmartScriptMgr.h:583
@ SMART_ACTION_SET_RUN
Definition: SmartScriptMgr.h:597
@ SMART_ACTION_SET_EVENT_PHASE
Definition: SmartScriptMgr.h:560
@ SMART_ACTION_RESET_GOBJECT
Definition: SmartScriptMgr.h:570
@ SMART_EVENT_DATA_SET
Definition: SmartScriptMgr.h:156
@ SMART_EVENT_JUST_CREATED
Definition: SmartScriptMgr.h:181
@ SMART_EVENT_MOVEMENTINFORM
Definition: SmartScriptMgr.h:152
@ SMART_EVENT_MANA_PCT
Definition: SmartScriptMgr.h:121
@ SMART_EVENT_GO_STATE_CHANGED
Definition: SmartScriptMgr.h:188
@ SMART_RANDOM_POINT
Definition: SmartScriptMgr.h:58
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:46
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:119
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:3136

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
5035{
5036 if (!obj)
5037 return false;
5038
5039 if (Creature* creatureObj = obj->ToCreature())
5040 return creatureObj->IsCharmed();
5041
5042 return false;
5043}
Creature * ToCreature()
Definition: Object.h:197

References Object::ToCreature().

Referenced by ProcessEvent().

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static
5030{
5031 return obj && obj->GetTypeId() == TYPEID_UNIT;
5032}
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
TypeID GetTypeId() const
Definition: Object.h:121

References Object::GetTypeId(), and TYPEID_UNIT.

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

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static
5046{
5047 return obj && obj->GetTypeId() == TYPEID_GAMEOBJECT;
5048}
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:39

References Object::GetTypeId(), and TYPEID_GAMEOBJECT.

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

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private
5081{
5082 if (mEventPhase == 0)
5083 {
5084 return false;
5085 }
5086
5087 return ((1 << (mEventPhase - 1)) & p) != 0;
5088}

References mEventPhase.

Referenced by ProcessEvent(), and UpdateTimer().

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static
5025{
5026 return obj && obj->GetTypeId() == TYPEID_PLAYER;
5027}
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38

References Object::GetTypeId(), and TYPEID_PLAYER.

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

◆ IsSmart()

bool SmartScript::IsSmart ( Creature c = nullptr)
inline
87 {
88 bool smart = true;
89 if (c && c->GetAIName() != "SmartAI")
90 smart = false;
91
92 if (!me || me->GetAIName() != "SmartAI")
93 smart = false;
94
95 if (!smart)
96 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));
97
98 return smart;
99 }
std::string const & GetAIName() const
Definition: Creature.cpp:2954

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

Referenced by ProcessAction().

◆ IsSmartGO()

bool SmartScript::IsSmartGO ( GameObject g = nullptr)
inline
102 {
103 bool smart = true;
104 if (g && g->GetAIName() != "SmartGameObjectAI")
105 smart = false;
106
107 if (!go || go->GetAIName() != "SmartGameObjectAI")
108 smart = false;
109 if (!smart)
110 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));
111
112 return smart;
113 }
std::string const & GetAIName() const
Definition: GameObject.cpp:100

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

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static
5020{
5021 return obj && (obj->GetTypeId() == TYPEID_UNIT || obj->GetTypeId() == TYPEID_PLAYER);
5022}

References Object::GetTypeId(), TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by ProcessAction(), and ProcessEvent().

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTrigger const *  at = nullptr 
)
4790{
4791 if (obj)//handle object based scripts
4792 {
4793 switch (obj->GetTypeId())
4794 {
4795 case TYPEID_UNIT:
4797 me = obj->ToCreature();
4798 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is Creature {}", me->GetEntry());
4799 break;
4800 case TYPEID_GAMEOBJECT:
4802 go = obj->ToGameObject();
4803 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is GameObject {}", go->GetEntry());
4804 break;
4805 default:
4806 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: Unhandled TypeID !WARNING!");
4807 return;
4808 }
4809 }
4810 else if (at)
4811 {
4813 trigger = at;
4814 LOG_DEBUG("sql.sql", "SmartScript::OnInitialize: source is AreaTrigger {}", trigger->entry);
4815 }
4816 else
4817 {
4818 LOG_ERROR("scripts.ai.sai", "SmartScript::OnInitialize: !WARNING! Initialized objects are nullptr.");
4819 return;
4820 }
4821
4822 GetScript();//load copy of script
4823
4824 uint32 maxDisableDist = 0;
4825 uint32 minEnableDist = 0;
4826 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
4827 {
4828 InitTimer((*i));//calculate timers for first time use
4829 if (i->GetEventType() == SMART_EVENT_RANGE && i->GetActionType() == SMART_ACTION_ALLOW_COMBAT_MOVEMENT)
4830 {
4831 if (i->action.combatMove.move == 1 && i->event.minMaxRepeat.rangeMin > minEnableDist)
4832 minEnableDist = i->event.minMaxRepeat.rangeMin;
4833 else if (i->action.combatMove.move == 0 && (i->event.minMaxRepeat.rangeMax < maxDisableDist || maxDisableDist == 0))
4834 maxDisableDist = i->event.minMaxRepeat.rangeMax;
4835 }
4836
4837 // Xinef: if smartcast combat move flag is present
4838 if (i->GetActionType() == SMART_ACTION_CAST && (i->action.cast.castFlags & SMARTCAST_COMBAT_MOVE))
4839 {
4840 if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i->action.cast.spell))
4841 {
4842 float maxRange = spellInfo->GetMaxRange(spellInfo->IsPositive());
4843 float minRange = spellInfo->GetMinRange(spellInfo->IsPositive());
4844
4845 if (maxRange > 0 && minRange <= maxRange)
4846 {
4847 smartCasterMaxDist = minRange + ((maxRange - minRange) * 0.65f);
4848 smartCasterPowerType = (Powers)spellInfo->PowerType;
4849 }
4850 }
4851 }
4852 }
4853 if (maxDisableDist > 0 && minEnableDist >= maxDisableDist)
4854 mMaxCombatDist = uint32(maxDisableDist + ((minEnableDist - maxDisableDist) / 2));
4855
4857 InstallEvents();
4859}
@ SMART_SCRIPT_TYPE_GAMEOBJECT
Definition: SmartScriptMgr.h:1694
@ SMART_SCRIPT_TYPE_AREATRIGGER
Definition: SmartScriptMgr.h:1695
@ SMART_EVENT_AI_INIT
Definition: SmartScriptMgr.h:155
@ SMARTCAST_COMBAT_MOVE
Definition: SmartScriptMgr.h:1870
#define sSpellMgr
Definition: SpellMgr.h:825
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:100
void InstallEvents()
Definition: SmartScript.cpp:4647
void GetScript()
Definition: SmartScript.cpp:4755
GameObject * ToGameObject()
Definition: Object.h:202
Definition: SpellInfo.h:314

References AreaTrigger::entry, Object::GetEntry(), SpellInfo::GetMaxRange(), SpellInfo::GetMinRange(), GetScript(), Object::GetTypeId(), go, InitTimer(), InstallEvents(), SpellInfo::IsPositive(), LOG_DEBUG, LOG_ERROR, me, mEvents, mMaxCombatDist, mScriptType, SpellInfo::PowerType, ProcessEventsFor(), SMART_ACTION_ALLOW_COMBAT_MOVEMENT, SMART_ACTION_CAST, SMART_EVENT_AI_INIT, SMART_EVENT_JUST_CREATED, SMART_EVENT_RANGE, SMART_SCRIPT_TYPE_AREATRIGGER, SMART_SCRIPT_TYPE_CREATURE, SMART_SCRIPT_TYPE_GAMEOBJECT, SMARTCAST_COMBAT_MOVE, smartCasterMaxDist, smartCasterPowerType, sSpellMgr, 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)
4862{
4863 if (!me)
4864 return;
4865
4867}
@ SMART_EVENT_IC_LOS
Definition: SmartScriptMgr.h:144
@ SMART_EVENT_OOC_LOS
Definition: SmartScriptMgr.h:128
bool IsEngaged() const
Definition: Unit.h:1699

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

Referenced by SmartAI::MoveInLineOfSight().

◆ OnReset()

void SmartScript::OnReset ( )
77{
78 // xinef: check if we allow phase reset
79 if (AllowPhaseReset())
80 SetPhase(0);
81
83 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
84 {
85 if (!((*i).event.event_flags & SMART_EVENT_FLAG_DONT_RESET))
86 {
87 InitTimer((*i));
88 (*i).runOnce = false;
89 }
90 }
93 mCounterList.clear();
94
95 // Xinef: Fix Combat Movement
98}
@ SMART_EVENT_FLAG_DONT_RESET
Definition: SmartScriptMgr.h:1855
@ SMART_EVENT_RESET
Definition: SmartScriptMgr.h:143
void RestoreCasterMaxDist()
Definition: SmartScript.h:227
bool AllowPhaseReset() const
Definition: SmartScript.h:232
void RestoreMaxCombatDist()
Definition: SmartScript.h:221
void ResetBaseObject()
Definition: SmartScript.h:181
void Clear()
Definition: ObjectGuid.h:140

References AllowPhaseReset(), ObjectGuid::Clear(), InitTimer(), mCounterList, mEvents, mLastInvoker, ProcessEventsFor(), ResetBaseObject(), RestoreCasterMaxDist(), RestoreMaxCombatDist(), SetPhase(), SMART_EVENT_FLAG_DONT_RESET, and SMART_EVENT_RESET.

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

◆ OnUpdate()

void SmartScript::OnUpdate ( const uint32  diff)
4659{
4661 return;
4662
4663 InstallEvents();//before UpdateTimers
4664
4665 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
4666 UpdateTimer(*i, diff);
4667
4668 if (!mStoredEvents.empty())
4669 {
4670 SmartAIEventStoredList::iterator i, icurr;
4671 for (i = mStoredEvents.begin(); i != mStoredEvents.end();)
4672 {
4673 icurr = i++;
4674 UpdateTimer(*icurr, diff);
4675 }
4676 }
4677
4678 bool needCleanup = true;
4679 if (!mTimedActionList.empty())
4680 {
4682 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4683 {
4684 if ((*i).enableTimed)
4685 {
4686 UpdateTimer(*i, diff);
4687 needCleanup = false;
4688 }
4689 }
4690
4692 }
4693 if (needCleanup)
4694 mTimedActionList.clear();
4695
4696 if (!mRemIDs.empty())
4697 {
4698 for (std::list<uint32>::const_iterator i = mRemIDs.begin(); i != mRemIDs.end(); ++i)
4700
4701 // xinef: clear list after cleaning...
4702 mRemIDs.clear();
4703 }
4704 if (mUseTextTimer && me)
4705 {
4706 if (mTextTimer < diff)
4707 {
4708 uint32 textID = mLastTextID;
4709 mLastTextID = 0;
4710 uint32 entry = mTalkerEntry;
4711 mTalkerEntry = 0;
4712 mTextTimer = 0;
4713 mUseTextTimer = false;
4714 ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
4715 }
4716 else mTextTimer -= diff;
4717 }
4718}
@ SMART_EVENT_TEXT_OVER
Definition: SmartScriptMgr.h:170
void UpdateTimer(SmartScriptHolder &e, uint32 const diff)
Definition: SmartScript.cpp:4556
SmartAIEventStoredList mStoredEvents
Definition: SmartScript.h:258
std::list< uint32 > mRemIDs
Definition: SmartScript.h:259
SmartAIEventList mTimedActionList
Definition: SmartScript.h:246
void RemoveStoredEvent(uint32 id)
Definition: SmartScript.h:283

References GetBaseObject(), InstallEvents(), isProcessingTimedActionList, me, mEvents, mLastTextID, mRemIDs, mScriptType, mStoredEvents, mTalkerEntry, mTextTimer, mTimedActionList, mUseTextTimer, ProcessEventsFor(), RemoveStoredEvent(), SMART_EVENT_TEXT_OVER, SMART_SCRIPT_TYPE_CREATURE, SMART_SCRIPT_TYPE_GAMEOBJECT, 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 
)
120{
121 //calc random
122 if (e.event.event_chance < 100 && e.event.event_chance)
123 {
124 uint32 rnd = urand(1, 100);
125 if (e.event.event_chance <= rnd)
126 return;
127 }
128 e.runOnce = true;//used for repeat check
129
130 if (unit)
131 mLastInvoker = unit->GetGUID();
132
133 if (Unit* tempInvoker = GetLastInvoker())
134 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: Invoker: {} ({})", tempInvoker->GetName(), tempInvoker->GetGUID().ToString());
135
136 bool isControlled = e.action.moveToPos.controlled > 0;
137
138 ObjectVector targets;
139 GetTargets(targets, e, unit);
140
141 switch (e.GetActionType())
142 {
144 {
145 Creature* talker = e.target.type == 0 ? me : nullptr;
146 Unit* talkTarget = nullptr;
147
148 for (WorldObject* target : targets)
149 {
150 if (IsCreature((target)) && !target->ToCreature()->IsPet()) // Prevented sending text to pets.
151 {
153 {
154 talker = me;
155 talkTarget = target->ToCreature();
156 }
157 else
158 talker = target->ToCreature();
159 break;
160 }
161 else if (IsPlayer((target)))
162 {
163 talker = me; // xinef: added
164 talkTarget = target->ToPlayer();
165 break;
166 }
167 }
168
169 if (!talkTarget)
170 talkTarget = GetLastInvoker();
171
172 if (!talker)
173 break;
174
175 if (!sCreatureTextMgr->TextExist(talker->GetEntry(), uint8(e.action.talk.textGroupID)))
176 {
177 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());
178 break;
179 }
180
181 mTalkerEntry = talker->GetEntry();
184 mUseTextTimer = true;
185 sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), talkTarget);
186 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} ({}), textId: {}", talker->GetName(), talker->GetGUID().ToString(), mLastTextID);
187 break;
188 }
190 {
191 for (WorldObject* target : targets)
192 {
193 if (IsCreature(target))
194 sCreatureTextMgr->SendChat(target->ToCreature(), uint8(e.action.simpleTalk.textGroupID), IsPlayer(GetLastInvoker()) ? GetLastInvoker() : 0);
195 else if (IsPlayer(target) && me)
196 {
197 Unit* templastInvoker = GetLastInvoker();
198 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());
199 }
200
201 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: {} ({}), textGroupId: {}",
202 target->GetName(), target->GetGUID().ToString(), uint8(e.action.simpleTalk.textGroupID));
203 }
204 break;
205 }
207 {
208 for (WorldObject* target : targets)
209 {
210 if (IsUnit(target))
211 {
212 target->ToUnit()->HandleEmoteCommand(e.action.emote.emote);
213 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: {} ({}), emote: {}",
214 target->GetName(), target->GetGUID().ToString(), e.action.emote.emote);
215 }
216 }
217 break;
218 }
220 {
221 for (WorldObject* target : targets)
222 {
223 if (IsUnit(target))
224 {
225 if (e.action.sound.distance == 1)
226 target->PlayDistanceSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
227 else
228 target->PlayDirectSound(e.action.sound.sound, e.action.sound.onlySelf ? target->ToPlayer() : nullptr);
229 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: {} ({}), sound: {}, onlyself: {}",
230 target->GetName(), target->GetGUID().ToString(), e.action.sound.sound, e.action.sound.onlySelf);
231 }
232 }
233 break;
234 }
236 {
237 uint32 sounds[4];
238 sounds[0] = e.action.randomSound.sound1;
239 sounds[1] = e.action.randomSound.sound2;
240 sounds[2] = e.action.randomSound.sound3;
241 sounds[3] = e.action.randomSound.sound4;
242 uint32 temp[4];
243 uint32 count = 0;
244 for (unsigned int sound : sounds)
245 {
246 if (sound)
247 {
248 temp[count] = sound;
249 ++count;
250 }
251 }
252
253 if (count == 0)
254 {
255 break;
256 }
257
258 for (WorldObject* target : targets)
259 {
260 if (IsUnit(target))
261 {
262 uint32 sound = temp[urand(0, count - 1)];
263 target->PlayDirectSound(sound, e.action.randomSound.onlySelf ? target->ToPlayer() : nullptr);
264 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_SOUND: target: {} ({}), sound: {}, onlyself: {}",
265 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomSound.onlySelf);
266 }
267 }
268
269 break;
270 }
272 {
273 ObjectVector targets;
274
275 if (e.action.music.type > 0)
276 {
277 if (me && me->FindMap())
278 {
279 Map::PlayerList const& players = me->GetMap()->GetPlayers();
280
281 if (!players.IsEmpty())
282 {
283 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
284 if (Player* player = i->GetSource())
285 {
286 if (player->GetZoneId() == me->GetZoneId())
287 {
288 if (e.action.music.type > 1)
289 {
290 if (player->GetAreaId() == me->GetAreaId())
291 targets.push_back(player);
292 }
293 else
294 targets.push_back(player);
295 }
296 }
297 }
298 }
299 }
300 else
301 GetTargets(targets, e);
302
303 if (!targets.empty())
304 {
305 for (WorldObject* target : targets)
306 {
307 if (IsUnit(target))
308 {
309 target->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0);
310 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: {} ({}), sound: {}, onlySelf: {}, type: {}",
311 target->GetName(), target->GetGUID().ToString(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type);
312 }
313 }
314 }
315 break;
316 }
318 {
319 ObjectVector targets;
320
321 if (e.action.randomMusic.type > 0)
322 {
323 if (me && me->FindMap())
324 {
325 Map::PlayerList const& players = me->GetMap()->GetPlayers();
326
327 if (!players.IsEmpty())
328 {
329 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
330 if (Player* player = i->GetSource())
331 {
332 if (player->GetZoneId() == me->GetZoneId())
333 {
334 if (e.action.randomMusic.type > 1)
335 {
336 if (player->GetAreaId() == me->GetAreaId())
337 targets.push_back(player);
338 }
339 else
340 targets.push_back(player);
341 }
342 }
343 }
344 }
345 }
346 else
347 GetTargets(targets, e);
348
349 if (targets.empty())
350 break;
351
352 uint32 sounds[4];
353 sounds[0] = e.action.randomMusic.sound1;
354 sounds[1] = e.action.randomMusic.sound2;
355 sounds[2] = e.action.randomMusic.sound3;
356 sounds[3] = e.action.randomMusic.sound4;
357 uint32 temp[4];
358 uint32 count = 0;
359 for (unsigned int sound : sounds)
360 {
361 if (sound)
362 {
363 temp[count] = sound;
364 ++count;
365 }
366 }
367
368 if (count == 0)
369 {
370 break;
371 }
372
373 for (WorldObject* target : targets)
374 {
375 if (IsUnit(target))
376 {
377 uint32 sound = temp[urand(0, count - 1)];
378 target->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0);
379 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: {} ({}), sound: {}, onlyself: {}, type: {}",
380 target->GetName(), target->GetGUID().ToString(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type);
381 }
382 }
383
384 break;
385 }
387 {
388 for (WorldObject* target : targets)
389 {
390 if (IsCreature(target))
391 {
393 {
394 target->ToCreature()->SetFaction(e.action.faction.factionID);
395 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
396 target->GetEntry(), target->GetGUID().ToString(), e.action.faction.factionID);
397 }
398 else
399 {
400 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(target->ToCreature()->GetEntry()))
401 {
402 if (target->ToCreature()->GetFaction() != ci->faction)
403 {
404 target->ToCreature()->SetFaction(ci->faction);
405 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_FACTION: Creature entry {}, GuidLow {} set faction to {}",
406 target->GetEntry(), target->GetGUID().ToString(), ci->faction);
407 }
408 }
409 }
410 }
411 }
412 break;
413 }
415 {
416 for (WorldObject* target : targets)
417 {
418 if (!IsCreature(target))
419 continue;
420
422 {
423 //set model based on entry from creature_template
425 {
426 if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
427 {
428 uint32 displayId = ObjectMgr::ChooseDisplayId(ci);
429 target->ToCreature()->SetDisplayId(displayId);
430 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
431 target->GetEntry(), target->GetGUID().ToString(), displayId);
432 }
433 }
434 //if no param1, then use value from param2 (modelId)
435 else
436 {
437 target->ToCreature()->SetDisplayId(e.action.morphOrMount.model);
438 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} set displayid to {}",
439 target->GetEntry(), target->GetGUID().ToString(), e.action.morphOrMount.model);
440 }
441 }
442 else
443 {
444 target->ToCreature()->DeMorph();
445 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry {}, GuidLow {} demorphs.",
446 target->GetEntry(), target->GetGUID().ToString());
447 }
448 }
449 break;
450 }
452 {
453 for (WorldObject* target : targets)
454 {
455 if (IsPlayer(target))
456 {
457 target->ToPlayer()->FailQuest(e.action.quest.quest);
458 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FAIL_QUEST: Player guidLow {} fails quest {}",
459 target->GetGUID().ToString(), e.action.quest.quest);
460 }
461 }
462 break;
463 }
465 {
466 for (WorldObject* target : targets)
467 {
468 if (Player* player = target->ToPlayer())
469 {
470 if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.questOffer.questID))
471 {
472 if (me && e.action.questOffer.directAdd == 0)
473 {
474 if (player->CanTakeQuest(q, true))
475 {
476 if (WorldSession* session = player->GetSession())
477 {
478 PlayerMenu menu(session);
479 menu.SendQuestGiverQuestDetails(q, me->GetGUID(), true);
480 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - offering quest {}",
481 player->GetGUID().ToString(), e.action.questOffer.questID);
482 }
483 }
484 }
485 else
486 {
487 player->AddQuestAndCheckCompletion(q, nullptr);
488 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_OFFER_QUEST: Player guidLow {} - quest {} added",
489 player->GetGUID().ToString(), e.action.questOffer.questID);
490 }
491 }
492 }
493 }
494 break;
495 }
497 {
498 for (WorldObject* target : targets)
499 {
500 if (!IsCreature(target))
501 continue;
502
503 target->ToCreature()->SetReactState(ReactStates(e.action.react.state));
504 }
505 break;
506 }
508 {
509 std::vector<uint32> emotes;
510 std::copy_if(e.action.randomEmote.emotes.begin(), e.action.randomEmote.emotes.end(),
511 std::back_inserter(emotes), [](uint32 emote) { return emote != 0; });
512
513 for (WorldObject* target : targets)
514 {
515 if (IsUnit(target))
516 {
518 target->ToUnit()->HandleEmoteCommand(emote);
519 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_EMOTE: Creature guidLow {} handle random emote {}",
520 target->GetGUID().ToString(), emote);
521 }
522 }
523 break;
524 }
526 {
527 if (!me)
528 break;
529
531 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
532 {
533 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
534 {
536 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_ALL_PCT: Creature {} modify threat for unit {}, value {}",
537 me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
538 }
539 }
540 break;
541 }
543 {
544 if (!me)
545 break;
546
547 for (WorldObject* target : targets)
548 {
549 if (IsUnit(target))
550 {
552 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_THREAT_SINGLE_PCT: Creature guidLow {} modify threat for unit {}, value {}",
553 me->GetGUID().ToString(), target->GetGUID().ToString(), e.action.threatPCT.threatINC ? (int32)e.action.threatPCT.threatINC : -(int32)e.action.threatPCT.threatDEC);
554 }
555 }
556 break;
557 }
559 {
560 for (WorldObject* target : targets)
561 {
562 // Special handling for vehicles
563 if (IsUnit(target))
564 if (Vehicle* vehicle = target->ToUnit()->GetVehicleKit())
565 for (auto & Seat : vehicle->Seats)
566 if (Player* player = ObjectAccessor::GetPlayer(*target, Seat.second.Passenger.Guid))
567 player->AreaExploredOrEventHappens(e.action.quest.quest);
568
569 if (IsPlayer(target))
570 {
571 target->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest);
572
573 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: Player guidLow {} credited quest {}",
574 target->GetGUID().ToString(), e.action.quest.quest);
575 }
576 }
577 break;
578 }
580 {
581 if (targets.empty())
582 break;
583
584 Unit* caster = me;
585 // Areatrigger Cast!
587 caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
588
591
592 for (WorldObject* target : targets)
593 {
594 // may be nullptr
595 if (go)
596 go->CastSpell(target->ToUnit(), e.action.cast.spell);
597
598 if (!IsUnit(target))
599 continue;
600
601 if (caster && caster != me) // Areatrigger cast
602 {
603 caster->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
604 }
605 else if (me)
606 {
607 // If target has the aura, skip
608 if ((e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) && target->ToUnit()->HasAura(e.action.cast.spell))
609 continue;
610
611 // If the threatlist is a singleton, cancel
613 if (me->GetThreatMgr().GetThreatListSize() <= 1)
614 break;
615
616 // If target does not use mana, skip
617 if ((e.action.cast.castFlags & SMARTCAST_TARGET_POWER_MANA) && !target->ToUnit()->GetPower(POWER_MANA))
618 continue;
619
620 // Interrupts current spellcast
623
624 // Flag usable only if caster has max dist set.
626 {
627 // Check mana case only and operate movement accordingly, LoS and range is checked in targetet movement generator.
628 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
629 int32 currentPower = me->GetPower(GetCasterPowerType());
630
631 if ((spellInfo && (currentPower < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()) || me->IsSpellProhibited(spellInfo->GetSchoolMask()))) || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
632 {
634 CAST_AI(SmartAI, me->AI())->SetForcedCombatMove(0);
635 }
636 else if (GetCasterActualDist() == 0.0f && me->GetPowerPct(GetCasterPowerType()) > 30.0f)
637 {
639 CAST_AI(SmartAI, me->AI())->SetForcedCombatMove(GetCasterActualDist());
640 }
641 }
642
643 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
645 {
647 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
648 else
649 triggerFlags = TRIGGERED_FULL_MASK;
650 }
651
652 me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
653 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
654 me->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
655 }
656 }
657 break;
658 }
660 {
661 if (targets.empty())
662 break;
663
666
667 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
669 {
671 {
672 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
673 }
674 else
675 {
676 triggerFlags = TRIGGERED_FULL_MASK;
677 }
678 }
679
680 for (WorldObject* target : targets)
681 {
682 Unit* uTarget = target->ToUnit();
683 if (!uTarget)
684 continue;
685
687 {
689 {
690 uTarget->InterruptNonMeleeSpells(false);
691 }
692
693 uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
694 }
695 }
696 break;
697 }
699 {
700 // Can be used for area trigger cast
701 Unit* tempLastInvoker = GetLastInvoker(unit);
702 if (!tempLastInvoker)
703 break;
704
705 if (targets.empty())
706 break;
707
710
711 for (WorldObject* target : targets)
712 {
713 if (!IsUnit(target))
714 continue;
715
716 if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
717 {
719 {
720 tempLastInvoker->InterruptNonMeleeSpells(false);
721 }
722
723 TriggerCastFlags triggerFlags = TRIGGERED_NONE;
725 {
727 {
728 triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
729 }
730 else
731 {
732 triggerFlags = TRIGGERED_FULL_MASK;
733 }
734 }
735
736 tempLastInvoker->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
737 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
738 tempLastInvoker->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
739 }
740 else
741 {
742 LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
743 e.action.cast.spell, target->GetGUID().ToString());
744 }
745 }
746 break;
747 }
749 {
750 for (WorldObject* target : targets)
751 {
752 if (IsUnit(target))
753 {
754 target->ToUnit()->AddAura(e.action.cast.spell, target->ToUnit());
755 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_AURA: Adding aura {} to unit {}",
756 e.action.cast.spell, target->GetGUID().ToString());
757 }
758 }
759 break;
760 }
762 {
763 for (WorldObject* target : targets)
764 {
765 if (IsGameObject(target))
766 {
767 GameObject* go = target->ToGameObject();
768
769 // Activate
771 {
773 }
774
776 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject {} activated", go->GetGUID().ToString());
777 }
778 }
779
780 break;
781 }
783 {
784 for (WorldObject* target : targets)
785 {
786 if (IsGameObject(target))
787 {
788 target->ToGameObject()->ResetDoorOrButton();
789 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_RESET_GOBJECT. Gameobject {} (entry: {}) reset",
790 target->GetGUID().ToString(), target->GetEntry());
791 }
792 }
793 break;
794 }
796 {
797 for (WorldObject* target : targets)
798 {
799 if (IsUnit(target))
800 {
801 target->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
802 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit {} set emotestate to {}",
803 target->GetGUID().ToString(), e.action.emote.emote);
804 }
805 }
806 break;
807 }
809 {
810 for (WorldObject* target : targets)
811 {
812 if (IsUnit(target))
813 {
814 if (!e.action.unitFlag.type)
815 {
816 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
817 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS",
818 target->GetGUID().ToString(), e.action.unitFlag.flag);
819 }
820 else
821 {
822 target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
823 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit {} added flag {} to UNIT_FIELD_FLAGS_2",
824 target->GetGUID().ToString(), e.action.unitFlag.flag);
825 }
826 }
827 }
828 break;
829 }
831 {
832 for (WorldObject* target : targets)
833 {
834 if (IsUnit(target))
835 {
836 if (!e.action.unitFlag.type)
837 {
838 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag);
839 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS",
840 target->GetGUID().ToString(), e.action.unitFlag.flag);
841 }
842 else
843 {
844 target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag);
845 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit {} removed flag {} to UNIT_FIELD_FLAGS_2",
846 target->GetGUID().ToString(), e.action.unitFlag.flag);
847 }
848 }
849 }
850 break;
851 }
853 {
854 if (!IsSmart())
855 break;
856
857 CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack);
858 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
860 break;
861 }
863 {
864 if (!IsSmart())
865 break;
866
867 // Xinef: Fix Combat Movement
868 bool move = e.action.combatMove.move;
869 if (move && GetMaxCombatDist() && e.GetEventType() == SMART_EVENT_MANA_PCT)
870 {
872 CAST_AI(SmartAI, me->AI())->SetForcedCombatMove(0);
873 }
874 else
875 CAST_AI(SmartAI, me->AI())->SetCombatMove(move);
876 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature {} bool on = {}",
878 break;
879 }
881 {
882 if (!GetBaseObject())
883 break;
884
886 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature {} set event phase {}",
888 break;
889 }
891 {
892 if (!GetBaseObject())
893 break;
894
897 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_INC_EVENT_PHASE: Creature {} inc event phase by {}, "
898 "decrease by {}", GetBaseObject()->GetGUID().ToString(), e.action.incEventPhase.inc, e.action.incEventPhase.dec);
899 break;
900 }
902 {
903 if (!GetBaseObject())
904 break;
905
906 for (WorldObject* target : targets)
907 if (IsCreature(target))
908 if (target->ToCreature()->IsAIEnabled)
909 target->ToCreature()->AI()->EnterEvadeMode();
910
911 break;
912 }
914 {
915 // Xinef: do not allow to flee without control (stun, fear etc)
917 break;
918
920 if (e.action.flee.withEmote)
921 {
923 sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
924 }
925 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature {} DoFleeToGetAssistance", me->GetGUID().ToString());
926 break;
927 }
929 {
930 if (!me)
931 break;
932
933 me->CombatStop(true);
934 break;
935 }
937 {
938 for (WorldObject* target : targets)
939 {
940 if (!IsUnit(target))
941 continue;
942
943 Unit* unitTarget = target->ToUnit();
944 // If invoker was pet or charm
945 Player* player = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself();
946 if (player && GetBaseObject())
947 {
948 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
949 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {}, group credit for quest {}",
950 player->GetGUID().ToString(), e.action.quest.quest);
951 }
952
953 // Special handling for vehicles
954 if (Vehicle* vehicle = unitTarget->GetVehicleKit())
955 {
956 for (auto& Seat : vehicle->Seats)
957 {
958 if (Player* player = ObjectAccessor::GetPlayer(*unitTarget, Seat.second.Passenger.Guid))
959 {
960 player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
961 }
962 }
963 }
964 }
965 break;
966 }
968 {
969 for (WorldObject* target : targets)
970 {
971 if (!IsUnit(target))
972 continue;
973
974 if (e.action.removeAura.spell)
975 {
977 {
978 if (Aura* aur = target->ToUnit()->GetAura(e.action.removeAura.spell))
979 aur->ModCharges(-static_cast<int32>(e.action.removeAura.charges), AURA_REMOVE_BY_EXPIRE);
980 }
981 else
982 target->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
983 }
984 else
985 target->ToUnit()->RemoveAllAuras();
986
987 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {}, spell {}",
988 target->GetGUID().ToString(), e.action.removeAura.spell);
989 }
990 break;
991 }
993 {
994 if (!IsSmart())
995 break;
996
998 {
999 CAST_AI(SmartAI, me->AI())->StopFollow(false);
1000 break;
1001 }
1002
1003 for (WorldObject* target : targets)
1004 {
1005 if (IsUnit(target))
1006 {
1007 float angle = e.action.follow.angle > 6 ? (e.action.follow.angle * M_PI / 180.0f) : e.action.follow.angle;
1008 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);
1009 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature {} following target {}",
1010 me->GetGUID().ToString(), target->GetGUID().ToString());
1011 break;
1012 }
1013 }
1014 break;
1015 }
1017 {
1018 if (!GetBaseObject())
1019 break;
1020
1021 std::vector<uint32> phases;
1022 std::copy_if(e.action.randomPhase.phases.begin(), e.action.randomPhase.phases.end(),
1023 std::back_inserter(phases), [](uint32 phase) { return phase != 0; });
1024
1026 SetPhase(phase);
1027 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE: Creature {} sets event phase to {}",
1028 GetBaseObject()->GetGUID().ToString(), phase);
1029 break;
1030 }
1032 {
1033 if (!GetBaseObject())
1034 break;
1035
1037 SetPhase(phase);
1038 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_RANDOM_PHASE_RANGE: Creature {} sets event phase to {}",
1039 GetBaseObject()->GetGUID().ToString(), phase);
1040 break;
1041 }
1043 {
1044 if (trigger && IsPlayer(unit))
1045 {
1047 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player {}, Killcredit: {}",
1049 }
1050 else if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members
1051 {
1052 if (!me)
1053 break;
1054
1055 if (Player* player = me->GetLootRecipient())
1056 {
1058 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1060 }
1061 }
1062 else // Specific target type
1063 {
1064 for (WorldObject* target : targets)
1065 {
1066 if (!IsUnit(target))
1067 continue;
1068
1070 if (!player)
1071 continue;
1072
1074 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player {}, Killcredit: {}",
1075 target->GetGUID().ToString(), e.action.killedMonster.creature);
1076 }
1077 }
1078 break;
1079 }
1081 {
1082 WorldObject* obj = GetBaseObject();
1083 if (!obj)
1084 obj = unit;
1085
1086 if (!obj)
1087 break;
1088
1089 InstanceScript* instance = obj->GetInstanceScript();
1090 if (!instance)
1091 {
1092 LOG_ERROR("scripts.ai.sai", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1093 break;
1094 }
1095
1096 switch (e.action.setInstanceData.type)
1097 {
1098 case 0:
1099 {
1101 LOG_DEBUG("scripts.ai.sai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA: Field: {}, data: {}", e.action.setInstanceData.field, e.action.setInstanceData.data);
1102 } break;
1103 case 1:
1104 {
1106 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));
1107 } break;
1108 default:
1109 {
1110 break;
1111 }
1112 }
1113 break;
1114 }
1116 {
1117 WorldObject* obj = GetBaseObject();
1118 if (!obj)
1119 obj = unit;
1120
1121 if (!obj)
1122 break;
1123
1124 InstanceScript* instance = obj->GetInstanceScript();
1125 if (!instance)
1126 {
1127 LOG_ERROR("sql.sql", "SmartScript: Event {} attempt to set instance data without instance script. EntryOrGuid {}", e.GetEventType(), e.entryOrGuid);
1128 break;
1129 }
1130
1131 if (targets.empty())
1132 break;
1133
1134 instance->SetGuidData(e.action.setInstanceData64.field, targets.front()->GetGUID());
1135 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: {}, data: {}",
1136 e.action.setInstanceData64.field, targets.front()->GetGUID().ToString());
1137 break;
1138 }
1140 {
1141 for (WorldObject* target : targets)
1142 if (IsCreature(target))
1143 target->ToCreature()->UpdateEntry(e.action.updateTemplate.creature, target->ToCreature()->GetCreatureData(), e.action.updateTemplate.updateLevel != 0);
1144 break;
1145 }
1146 case SMART_ACTION_DIE:
1147 {
1148 if (e.action.die.milliseconds)
1149 {
1150 if (me && !me->isDead())
1151 {
1153 {
1154 // We need to check again to see if we didn't die in the process.
1155 if (me && !me->isDead())
1156 {
1157 me->KillSelf();
1158 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1159 }
1161 }
1162 }
1163 else if (me && !me->isDead())
1164 {
1165 me->KillSelf();
1166 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
1167 }
1168 break;
1169 }
1171 {
1172 if (targets.empty())
1173 break;
1174
1175 if (!me->GetMap()->IsDungeon())
1176 {
1177 ObjectVector units;
1178 GetWorldObjectsInDist(units, static_cast<float>(e.target.unitRange.maxDist));
1179
1180 if (!units.empty() && GetBaseObject())
1181 for (WorldObject* unit : units)
1182 if (IsPlayer(unit) && !unit->ToPlayer()->isDead())
1183 {
1184 me->SetInCombatWith(unit->ToPlayer());
1185 unit->ToPlayer()->SetInCombatWith(me);
1186 me->AddThreat(unit->ToPlayer(), 0.0f);
1187 }
1188 }
1189 else
1190 {
1191 for (WorldObject* target : targets)
1192 {
1193 if (IsCreature(target))
1194 {
1195 target->ToCreature()->SetInCombatWithZone();
1196 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: Creature {}, target: {}",
1197 me->GetGUID().ToString(), target->GetGUID().ToString());
1198 }
1199 }
1200 }
1201
1202 break;
1203 }
1205 {
1206 for (WorldObject* target : targets)
1207 {
1208 if (IsCreature(target))
1209 {
1210 target->ToCreature()->CallForHelp(float(e.action.callHelp.range));
1212 {
1214 sCreatureTextMgr->SendChatPacket(target, builder, CHAT_MSG_MONSTER_EMOTE);
1215 }
1216 LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature {}, target: {}",
1217 me->GetGUID().ToString(), target->GetGUID().ToString());
1218 }
1219 }
1220 break;
1221 }
1223 {
1224 if (me)
1225 {
1227 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_SET_SHEATH: Creature {}, State: {}",
1229 }
1230 break;
1231 }
1233 {
1234 for (WorldObject* target : targets)
1235 {
1236 Milliseconds despawnDelay(e.action.forceDespawn.delay);
1237
1238 // Wait at least one world update tick before despawn, so it doesn't break linked actions.
1239 if (despawnDelay <= 0ms)
1240 {
1241 despawnDelay = 1ms;
1242 }
1243
1244 Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
1245 if (Creature* creature = target->ToCreature())
1246 {
1247 creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1248 }
1249 else if (GameObject* go = target->ToGameObject())
1250 {
1251 go->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
1252 }
1253 }
1254
1255 break;
1256 }
1258 {
1259 for (WorldObject* target : targets)
1260 {
1261 if (IsUnit(target))
1262 target->ToUnit()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1263 else if (IsGameObject(target))
1264 target->ToGameObject()->SetPhaseMask(e.action.ingamePhaseMask.mask, true);
1265 }
1266 break;
1267 }
1269 {
1270 for (WorldObject* target : targets)
1271 {
1272 if (!IsUnit(target))
1273 continue;
1274
1276 {
1277 if (e.action.morphOrMount.creature > 0)
1278 {
1279 if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
1280 target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo));
1281 }
1282 else
1283 target->ToUnit()->Mount(e.action.morphOrMount.model);
1284 }
1285 else
1286 target->ToUnit()->Dismount();
1287 }
1288 break;
1289 }
1291 {
1292 for (WorldObject* target : targets)
1293 {
1294 if (IsCreature(target))
1295 {
1296 SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI());
1297 if (!ai)
1298 continue;
1299
1300 if (e.action.invincHP.percent)
1301 ai->SetInvincibilityHpLevel(target->ToCreature()->CountPctFromMaxHealth(e.action.invincHP.percent));
1302 else
1304 }
1305 }
1306 break;
1307 }
1309 {
1310 for (WorldObject* target : targets)
1311 {
1312 if (IsCreature(target))
1313 target->ToCreature()->AI()->SetData(e.action.setData.field, e.action.setData.data);
1314 else if (IsGameObject(target))
1315 target->ToGameObject()->AI()->SetData(e.action.setData.field, e.action.setData.data);
1316 }
1317 break;
1318 }
1320 {
1321 if (!me)
1322 break;
1323
1324 float x, y, z;
1325 me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance);
1327 break;
1328 }
1330 {
1331 if (!me)
1332 break;
1333
1335 break;
1336 }
1338 {
1339 for (WorldObject* target : targets)
1340 if (IsUnit(target))
1341 target->ToUnit()->SetVisible(!!e.action.visibility.state);
1342
1343 break;
1344 }
1346 {
1347 for (WorldObject* target : targets)
1348 target->setActive(!!e.action.setActive.state);
1349 break;
1350 }
1352 {
1353 if (!me)
1354 break;
1355
1356 if (targets.empty())
1357 break;
1358
1359 // attack random target
1360 if (Unit* target = Acore::Containers::SelectRandomContainerElement(targets)->ToUnit())
1361 me->AI()->AttackStart(target);
1362 break;
1363 }
1365 {
1366 for (WorldObject* target : targets)
1367 if (Unit* unitTarget = target->ToUnit())
1368 unitTarget->AttackStop();
1369 break;
1370 }
1372 {
1374 bool preferUnit = flags.HasFlag(SmartActionSummonCreatureFlags::PreferUnit);
1375 WorldObject* summoner = preferUnit ? unit : Coalesce<WorldObject>(GetBaseObject(), unit);
1376 if (!summoner)
1377 break;
1378
1379 bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
1380
1382 {
1383 float range = (float)e.target.randomPoint.range;
1384 Position randomPoint;
1385 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1386 for (uint32 i = 0; i < e.target.randomPoint.amount; i++)
1387 {
1388 if (e.target.randomPoint.self > 0)
1389 randomPoint = me->GetRandomPoint(me->GetPosition(), range);
1390 else
1391 randomPoint = me->GetRandomPoint(srcPos, range);
1392 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, randomPoint, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, 0, nullptr, personalSpawn))
1393 {
1394 if (unit && e.action.summonCreature.attackInvoker)
1395 summon->AI()->AttackStart(unit);
1397 summon->AI()->AttackStart(me);
1398 }
1399 }
1400 break;
1401 }
1402
1403 float x, y, z, o;
1404 for (WorldObject* target : targets)
1405 {
1406 target->GetPosition(x, y, z, o);
1407 x += e.target.x;
1408 y += e.target.y;
1409 z += e.target.z;
1410 o += e.target.o;
1411 if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, nullptr, personalSpawn))
1412 {
1413 if (e.action.summonCreature.attackInvoker == 2) // pussywizard: proper attackInvoker implementation
1414 summon->AI()->AttackStart(unit);
1416 summon->AI()->AttackStart(target->ToUnit());
1418 summon->AI()->AttackStart(me);
1419 }
1420 }
1421
1423 break;
1424
1426 {
1427 if (unit && e.action.summonCreature.attackInvoker)
1428 summon->AI()->AttackStart(unit);
1430 summon->AI()->AttackStart(me);
1431 }
1432 break;
1433 }
1435 {
1436 if (!GetBaseObject())
1437 break;
1438
1439 if (!targets.empty())
1440 {
1441 float x, y, z, o;
1442 for (WorldObject* target : targets)
1443 {
1444 // xinef: allow gameobjects to summon gameobjects!
1445 //if(!IsUnit((*itr)))
1446 // continue;
1447
1448 target->GetPosition(x, y, z, o);
1449 x += e.target.x;
1450 y += e.target.y;
1451 z += e.target.z;
1452 o += e.target.o;
1455 else
1456 target->SummonGameObject(e.action.summonGO.entry, GetBaseObject()->GetPositionX(), GetBaseObject()->GetPositionY(), GetBaseObject()->GetPositionZ(), GetBaseObject()->GetOrientation(), 0, 0, 0, 0, e.action.summonGO.despawnTime);
1457 }
1458 }
1459
1461 break;
1462
1464 break;
1465 }
1467 {
1468 for (WorldObject* target : targets)
1469 {
1470 if (!IsUnit(target))
1471 continue;
1472
1473 Unit::Kill(target->ToUnit(), target->ToUnit());
1474 }
1475
1476 break;
1477 }
1479 {
1480 InstallTemplate(e);
1481 break;
1482 }
1484 {
1485 for (WorldObject* target : targets)
1486 {
1487 if (!IsPlayer(target))
1488 continue;
1489
1490 target->ToPlayer()->AddItem(e.action.item.entry, e.action.item.count);
1491 }
1492 break;
1493 }
1495 {
1496 for (WorldObject* target : targets)
1497 {
1498 if (!IsPlayer(target))
1499 continue;
1500
1501 target->ToPlayer()->DestroyItemCount(e.action.item.entry, e.action.item.count, true);
1502 }
1503 break;
1504 }
1506 {
1508 break;
1509 }
1511 {
1512 for (WorldObject* target : targets)
1513 {
1514 if (IsPlayer(target))
1515 target->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
1516 else if (IsCreature(target))
1517 target->ToCreature()->NearTeleportTo(e.target.x, e.target.y, e.target.z, e.target.o);
1518 }
1519 break;
1520 }
1522 {
1523 if (!IsSmart())
1524 break;
1525
1526 CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly);
1527 // Xinef: Set speed if any
1528 if (e.action.setFly.speed)
1529 me->SetSpeed(MOVE_RUN, float(e.action.setFly.speed / 100.0f), true);
1530
1531 // Xinef: this wil be executed only if state is different
1533 break;
1534 }
1536 {
1537 for (WorldObject* target : targets)
1538 {
1539 if (IsCreature(target))
1540 {
1541 if (IsSmart(target->ToCreature()))
1542 CAST_AI(SmartAI, target->ToCreature()->AI())->SetRun(e.action.setRun.run);
1543 else
1544 target->ToCreature()->SetWalk(e.action.setRun.run ? false : true); // Xinef: reversed
1545 }
1546 }
1547
1548 break;
1549 }
1551 {
1552 if (!IsSmart())
1553 break;
1554
1555 CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim);
1556 break;
1557 }
1559 {
1560 if (!targets.empty())
1561 {
1562 for (WorldObject* target : targets)
1563 {
1564 if (IsCreature(target))
1565 {
1566 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
1568 else
1569 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartAI, skipping");
1570 }
1571 else if (IsGameObject(target))
1572 {
1573 if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, target->ToGameObject()->AI()))
1575 else
1576 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SET_COUNTER is not using SmartGameObjectAI, skipping");
1577 }
1578 }
1579 }
1580 else
1582 break;
1583 }
1585 {
1586 if (!IsSmart())
1587 break;
1588
1589 bool run = e.action.wpStart.run != 0;
1590 uint32 entry = e.action.wpStart.pathID;
1591 bool repeat = e.action.wpStart.repeat != 0;
1592
1593 for (WorldObject* target : targets)
1594 {
1595 if (IsPlayer(target))
1596 {
1598 break;
1599 }
1600 }
1601
1603 CAST_AI(SmartAI, me->AI())->StartPath(run, entry, repeat, unit);
1604
1605 uint32 quest = e.action.wpStart.quest;
1606 uint32 DespawnTime = e.action.wpStart.despawnTime;
1607 CAST_AI(SmartAI, me->AI())->mEscortQuestID = quest;
1608 CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
1609 break;
1610 }
1612 {
1613 if (!IsSmart())
1614 break;
1615
1616 uint32 delay = e.action.wpPause.delay;
1617 CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_WAYPOINT_REACHED ? false : true);
1618 break;
1619 }
1621 {
1622 if (!IsSmart())
1623 break;
1624
1625 uint32 DespawnTime = e.action.wpStop.despawnTime;
1626 uint32 quest = e.action.wpStop.quest;
1627 bool fail = e.action.wpStop.fail;
1628 CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
1629 break;
1630 }
1632 {
1633 if (!IsSmart())
1634 break;
1635
1636 CAST_AI(SmartAI, me->AI())->SetWPPauseTimer(0);
1637 break;
1638 }
1640 {
1641 if (!me)
1642 break;
1643
1644 if (e.action.orientation.random > 0)
1645 {
1646 float randomOri = frand(0.0f, 2 * M_PI);
1647 me->SetFacingTo(randomOri);
1649 me->SetOrientation(randomOri);
1650 break;
1651 }
1652
1654 {
1655 float turnOri = me->GetOrientation() + (static_cast<float>(e.action.orientation.turnAngle) * M_PI / 180.0f);
1656 me->SetFacingTo(turnOri);
1658 me->SetOrientation(turnOri);
1659 break;
1660 }
1661
1663 {
1667 }
1668 else if (e.GetTargetType() == SMART_TARGET_POSITION)
1669 {
1670 me->SetFacingTo(e.target.o);
1673 }
1674 else if (!targets.empty())
1675 {
1676 me->SetFacingToObject(*targets.begin());
1678 me->SetInFront(*targets.begin());
1679 }
1680
1681 break;
1682 }
1684 {
1685 for (WorldObject* target : targets)
1686 {
1687 if (!IsPlayer(target))
1688 continue;
1689
1690 target->ToPlayer()->SendMovieStart(e.action.movie.entry);
1691 }
1692 break;
1693 }
1695 {
1696 if (!IsSmart())
1697 break;
1698
1699 WorldObject* target = nullptr;
1700
1702 {
1703 if (me)
1704 {
1705 float range = (float)e.target.randomPoint.range;
1706 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
1707 Position randomPoint = me->GetRandomPoint(srcPos, range);
1710 randomPoint.m_positionX,
1711 randomPoint.m_positionY,
1712 randomPoint.m_positionZ,
1713 true,
1714 true,
1716 );
1717 }
1718
1719 break;
1720 }
1721
1722 /*if (e.GetTargetType() == SMART_TARGET_CREATURE_RANGE || e.GetTargetType() == SMART_TARGET_CREATURE_GUID ||
1723 e.GetTargetType() == SMART_TARGET_CREATURE_DISTANCE || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_RANGE ||
1724 e.GetTargetType() == SMART_TARGET_GAMEOBJECT_GUID || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_DISTANCE ||
1725 e.GetTargetType() == SMART_TARGET_CLOSEST_CREATURE || e.GetTargetType() == SMART_TARGET_CLOSEST_GAMEOBJECT ||
1726 e.GetTargetType() == SMART_TARGET_OWNER_OR_SUMMONER || e.GetTargetType() == SMART_TARGET_ACTION_INVOKER ||
1727 e.GetTargetType() == SMART_TARGET_CLOSEST_ENEMY || e.GetTargetType() == SMART_TARGET_CLOSEST_FRIENDLY ||
1728 e.GetTargetType() == SMART_TARGET_SELF || e.GetTargetType() == SMART_TARGET_STORED)) */
1729 {
1730 // we want to move to random element
1731 if (!targets.empty())
1733 }
1734
1735 if (!target)
1736 {
1737 G3D::Vector3 dest(e.target.x, e.target.y, e.target.z);
1739 if (TransportBase* trans = me->GetDirectTransport())
1740 trans->CalculatePassengerPosition(dest.x, dest.y, dest.z);
1741
1742 me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, true, true,
1744 }
1745 else // Xinef: we can use dest.x, dest.y, dest.z to make offset
1746 {
1747 float x, y, z;
1748 target->GetPosition(x, y, z);
1750 {
1751 target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
1752 }
1753 me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, x + e.target.x, y + e.target.y, z + e.target.z, true, true, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1754 }
1755 break;
1756 }
1758 {
1759 for (WorldObject* target : targets)
1760 {
1761 if (IsCreature(target))
1762 {
1763 Creature* ctarget = target->ToCreature();
1764 ctarget->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, e.target.x, e.target.y, e.target.z, true, true, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE);
1765 }
1766 }
1767
1768 break;
1769 }
1771 {
1772 for (WorldObject* target : targets)
1773 {
1774 if (IsCreature(target))
1775 target->ToCreature()->Respawn();
1776 else if (IsGameObject(target))
1777 {
1778 // do not modify respawndelay of already spawned gameobjects
1779 if (target->ToGameObject()->isSpawnedByDefault())
1780 target->ToGameObject()->Respawn();
1781 else
1783 }
1784 }
1785 break;
1786 }
1788 {
1789 for (WorldObject* target : targets)
1790 if (IsPlayer(target))
1792 break;
1793 }
1794 case SMART_ACTION_EQUIP:
1795 {
1796 for (WorldObject* target : targets)
1797 {
1798 if (Creature* npc = target->ToCreature())
1799 {
1800 std::array<uint32, MAX_EQUIPMENT_ITEMS> slot;
1801 if (int8 equipId = static_cast<int8>(e.action.equip.entry))
1802 {
1803 EquipmentInfo const* eInfo = sObjectMgr->GetEquipmentInfo(npc->GetEntry(), equipId);
1804 if (!eInfo)
1805 {
1806 LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id {} for creature {}", equipId, npc->GetEntry());
1807 break;
1808 }
1809
1810 npc->SetCurrentEquipmentId(equipId);
1811
1812 std::copy(std::begin(eInfo->ItemEntry), std::end(eInfo->ItemEntry), std::begin(slot));
1813 }
1814 else
1815 std::copy(std::begin(e.action.equip.slots), std::end(e.action.equip.slots), std::begin(slot));
1816
1817 for (uint32 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
1818 if (!e.action.equip.mask || (e.action.equip.mask & (1 << i)))
1819 npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, slot[i]);
1820 }
1821 }
1822 break;
1823 }
1825 {
1826 SmartEvent ne = SmartEvent();
1829 if (!ne.event_chance) ne.event_chance = 100;
1830
1835
1836 ne.event_flags = 0;
1839
1840 SmartAction ac = SmartAction();
1843
1845 ev.event = ne;
1846 ev.event_id = e.action.timeEvent.id;
1847 ev.target = e.target;
1848 ev.action = ac;
1849 InitTimer(ev);
1850 mStoredEvents.push_back(ev);
1851 break;
1852 }
1855
1856 // xinef: remove this event if not repeatable
1858 mRemIDs.push_back(e.action.timeEvent.id);
1859 break;
1861 mRemIDs.push_back(e.action.timeEvent.id);
1862 break;
1864 {
1865 for (WorldObject* target : targets)
1866 {
1867 if (IsCreature(target))
1868 {
1869 if (!meOrigGUID)
1871 if (!goOrigGUID)
1873 go = nullptr;
1874 me = target->ToCreature();
1875 break;
1876 }
1877 else if (IsGameObject(target))
1878 {
1879 if (!meOrigGUID)
1881 if (!goOrigGUID)
1883 go = target->ToGameObject();
1884 me = nullptr;
1885 break;
1886 }
1887 }
1888
1889 break;
1890 }
1893 break;
1895 OnReset();
1896 break;
1898 {
1899 if (!IsSmart())
1900 break;
1901
1902 float attackDistance = float(e.action.setRangedMovement.distance);
1903 float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI);
1904
1905 for (WorldObject* target : targets)
1906 if (Creature* creature = target->ToCreature())
1907 if (IsSmart(creature) && creature->GetVictim())
1908 if (CAST_AI(SmartAI, creature->AI())->CanCombatMove())
1909 creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, attackAngle);
1910
1911 break;
1912 }
1914 {
1916 {
1917 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());
1918 break;
1919 }
1920
1921 for (WorldObject* target : targets)
1922 {
1923 if (Creature* creature = target->ToCreature())
1924 {
1925 if (IsSmart(creature))
1926 CAST_AI(SmartAI, creature->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
1927 }
1928 else if (GameObject* go = target->ToGameObject())
1929 {
1930 if (IsSmartGO(go))
1932 }
1933 }
1934 break;
1935 }
1937 {
1938 for (WorldObject* target : targets)
1939 if (IsCreature(target))
1941 break;
1942 }
1944 {
1945 for (WorldObject* target : targets)
1946 if (IsCreature(target))
1948 break;
1949 }
1951 {
1952 for (WorldObject* target : targets)
1953 if (IsCreature(target))
1955 break;
1956 }
1958 {
1959 if (targets.empty())
1960 break;
1961
1962 ObjectVector casters;
1964
1965 for (WorldObject* caster : casters)
1966 {
1967 if (!IsUnit(caster))
1968 continue;
1969
1970 Unit* casterUnit = caster->ToUnit();
1971
1972 bool interruptedSpell = false;
1973
1974 for (WorldObject* target : targets)
1975 {
1976 if (!IsUnit(target))
1977 continue;
1978
1980 {
1981 if (!interruptedSpell && e.action.crossCast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
1982 {
1983 casterUnit->InterruptNonMeleeSpells(false);
1984 interruptedSpell = true;
1985 }
1986
1987 casterUnit->CastSpell(target->ToUnit(), e.action.crossCast.spell, (e.action.crossCast.flags & SMARTCAST_TRIGGERED) != 0);
1988 }
1989 else
1990 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());
1991 }
1992 }
1993 break;
1994 }
1996 {
1997 std::vector<uint32> actionLists;
1999 std::back_inserter(actionLists), [](uint32 actionList) { return actionList != 0; });
2000
2003 {
2004 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());
2005 break;
2006 }
2007
2008 for (WorldObject* target : targets)
2009 {
2010 if (Creature* creature = target->ToCreature())
2011 {
2012 if (IsSmart(creature))
2013 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2014 }
2015 else if (GameObject* go = target->ToGameObject())
2016 {
2017 if (IsSmartGO(go))
2018 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2019 }
2020 }
2021 break;
2022 }
2024 {
2027 {
2028 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());
2029 break;
2030 }
2031
2032 for (WorldObject* target : targets)
2033 {
2034 if (Creature* creature = target->ToCreature())
2035 {
2036 if (IsSmart(creature))
2037 CAST_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
2038 }
2039 else if (GameObject* go = target->ToGameObject())
2040 {
2041 if (IsSmartGO(go))
2042 CAST_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker());
2043 }
2044 }
2045 break;
2046 }
2048 {
2049 for (WorldObject* target : targets)
2050 if (IsPlayer(target))
2052 break;
2053 }
2055 {
2056 bool foundTarget = false;
2057
2058 for (WorldObject* target : targets)
2059 {
2060 if (IsCreature((target)))
2061 {
2062 foundTarget = true;
2063
2066 else
2067 target->ToCreature()->GetMotionMaster()->MoveIdle();
2068 }
2069 }
2070
2071 if (!foundTarget && me && IsCreature(me) && me->IsAlive())
2072 {
2075 else
2077 }
2078 break;
2079 }
2081 {
2082 for (WorldObject* target : targets)
2083 if (IsUnit(target))
2085 break;
2086 }
2088 {
2089 for (WorldObject* target : targets)
2090 if (IsUnit(target))
2092 break;
2093 }
2095 {
2096 for (WorldObject* target : targets)
2097 if (IsUnit(target))
2099 break;
2100 }
2102 {
2103 for (WorldObject* target : targets)
2104 if (IsGameObject(target))
2106 break;
2107 }
2109 {
2110 for (WorldObject* target : targets)
2111 if (IsUnit(target))
2113 break;
2114 }
2116 {
2117 for (WorldObject* target : targets)
2118 if (IsUnit(target))
2120 break;
2121 }
2123 {
2124 for (WorldObject* target : targets)
2125 if (IsUnit(target))
2127 break;
2128 }
2130 {
2132 {
2133 if (me)
2134 {
2135 float range = (float)e.target.randomPoint.range;
2136 Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
2137 Position randomPoint = me->GetRandomPoint(srcPos, range);
2138 me->GetMotionMaster()->MoveJump(randomPoint, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2139 }
2140
2141 break;
2142 }
2143
2144 if (targets.empty())
2145 break;
2146
2147 // xinef: my implementation
2148 if (e.action.jump.selfJump)
2149 {
2151 if (me)
2152 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);
2153 }
2154 else
2155 {
2156 for (WorldObject* target : targets)
2157 if (WorldObject* obj = (target))
2158 {
2159 if (Creature* creature = obj->ToCreature())
2160 creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
2161 }
2162 }
2163
2164 break;
2165 }
2167 {
2168 for (WorldObject* target : targets)
2169 if (IsGameObject(target))
2171 break;
2172 }
2174 {
2175 for (WorldObject* target : targets)
2176 if (IsGameObject(target))
2178 break;
2179 }
2181 {
2182 WorldObject* ref = GetBaseObject();
2183
2184 if (!ref)
2185 ref = unit;
2186
2187 if (!ref)
2188 break;
2189
2190 ObjectVector const* storedTargets = GetStoredTargetVector(e.action.sendTargetToTarget.id, *ref);
2191 if (!storedTargets)
2192 break;
2193
2194 for (WorldObject* target : targets)
2195 {
2196 if (IsCreature(target))
2197 {
2198 if (SmartAI* ai = CAST_AI(SmartAI, target->ToCreature()->AI()))
2199 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2200 else
2201 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
2202 }
2203 else if (IsGameObject(target))
2204 {
2206 ai->GetScript()->StoreTargetList(ObjectVector(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
2207 else
2208 LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
2209 }
2210 }
2211 break;
2212 }
2214 {
2215 if (!GetBaseObject())
2216 break;
2217
2218 LOG_DEBUG("sql.sql", "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId {}, gossipNpcTextId {}",
2220
2221 for (WorldObject* target : targets)
2222 if (Player* player = target->ToPlayer())
2223 {
2226 else
2227 ClearGossipMenuFor(player);
2228
2230 }
2231
2232 break;
2233 }
2235 {
2236 if (!targets.empty())
2237 {
2238 float x, y, z, o;
2239 for (WorldObject* target : targets)
2240 if (IsCreature(target))
2241 {
2243 {
2244 target->ToCreature()->GetRespawnPosition(x, y, z, &o);
2245 target->ToCreature()->SetHomePosition(x, y, z, o);
2246 }
2247 else
2248 target->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
2249 }
2250 }
2251 else if (me && e.GetTargetType() == SMART_TARGET_POSITION)
2252 {
2254 {
2255 float x, y, z, o;
2256 me->GetRespawnPosition(x, y, z, &o);
2257 me->SetHomePosition(x, y, z, o);
2258 }
2259 else
2261 }
2262 break;
2263 }
2265 {
2266 for (WorldObject* target : targets)
2267 if (IsCreature(target))
2269
2270 break;
2271 }
2273 {
2274 for (WorldObject* target : targets)
2275 if (IsCreature(target))
2277 break;
2278 }
2280 {
2281 for (WorldObject* target : targets)
2282 if (IsGameObject(target))
2284 break;
2285 }
2287 {
2288 for (WorldObject* target : targets)
2289 if (IsGameObject(target))
2291 break;
2292 }
2294 {
2295 for (WorldObject* target : targets)
2296 if (IsGameObject(target))
2298 break;
2299 }
2301 {
2302 std::list<TempSummon*> summonList;
2304
2305 for (std::list<TempSummon*>::const_iterator itr = summonList.begin(); itr != summonList.end(); ++itr)
2306 {
2307 if (unit && e.action.creatureGroup.attackInvoker)
2308 (*itr)->AI()->AttackStart(unit);
2310 (*itr)->AI()->AttackStart(me);
2311 }
2312
2313 break;
2314 }
2316 {
2317 for (WorldObject* target : targets)
2318 if (IsUnit(target))
2320 break;
2321 }
2323 {
2324 for (WorldObject* target : targets)
2325 if (IsUnit(target))
2327 break;
2328 }
2330 {
2331 for (WorldObject* target : targets)
2332 if (IsUnit(target))
2334 break;
2335 }
2337 {
2338 uint32 eventId = e.action.gameEventStop.id;
2339 if (!sGameEventMgr->IsActiveEvent(eventId))
2340 {
2341 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: {})", eventId);
2342 break;
2343 }
2344 sGameEventMgr->StopEvent(eventId, true);
2345 break;
2346 }
2348 {
2349 uint32 eventId = e.action.gameEventStart.id;
2350 if (sGameEventMgr->IsActiveEvent(eventId))
2351 {
2352 LOG_ERROR("scripts.ai.sai", "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: {})", eventId);
2353 break;
2354 }
2355 sGameEventMgr->StartEvent(eventId, true);
2356 break;
2357 }
2359 {
2360 std::vector<uint32> waypoints;
2361 std::copy_if(e.action.closestWaypointFromList.wps.begin(), e.action.closestWaypointFromList.wps.end(),
2362 std::back_inserter(waypoints), [](uint32 wp) { return wp != 0; });
2363
2364 float distanceToClosest = std::numeric_limits<float>::max();
2365 WayPoint* closestWp = nullptr;
2366
2367 for (WorldObject* target : targets)
2368 {
2369 if (Creature* creature = target->ToCreature())
2370 {
2371 if (IsSmart(creature))
2372 {
2373 for (uint32 wp : waypoints)
2374 {
2375 WPPath* path = sSmartWaypointMgr->GetPath(wp);
2376 if (!path || path->empty())
2377 continue;
2378
2379 auto itrWp = path->find(0);
2380 if (itrWp != path->end())
2381 {
2382 if (WayPoint* wp = itrWp->second)
2383 {
2384 float distToThisPath = creature->GetDistance(wp->x, wp->y, wp->z);
2385 if (distToThisPath < distanceToClosest)
2386 {
2387 distanceToClosest = distToThisPath;
2388 closestWp = wp;
2389 }
2390 }
2391 }
2392 }
2393
2394 if (closestWp)
2395 CAST_AI(SmartAI, creature->AI())->StartPath(false, closestWp->id, true);
2396 }
2397 }
2398 }
2399 break;
2400 }
2402 {
2403 for (WorldObject* target : targets)
2404 if (IsUnit(target))
2405 target->ToUnit()->ExitVehicle();
2406
2407 break;
2408 }
2410 {
2411 for (WorldObject* target : targets)
2412 if (IsUnit(target))
2413 {
2415 target->ToUnit()->SendMovementFlagUpdate();
2416 }
2417
2418 break;
2419 }
2421 {
2422 for (WorldObject* target : targets)
2423 if (IsCreature(target))
2425
2426 break;
2427 }
2429 {
2432 else
2434
2437 break;
2438 }
2440 {
2441 for (WorldObject* const target : targets)
2442 if (IsCreature(target))
2444 break;
2445 }
2446 case SMART_ACTION_FLEE:
2447 {
2448 for (WorldObject* const target : targets)
2449 if (IsCreature(target))
2451 break;
2452 }
2454 {
2455 for (WorldObject* const target : targets)
2456 if (IsUnit(target))
2457 me->AddThreat(target->ToUnit(), float(e.action.threatPCT.threatINC) - float(e.action.threatPCT.threatDEC));
2458 break;
2459 }
2461 {
2462 for (WorldObject* const target : targets)
2463 if (IsCreature(target))
2465 break;
2466 }
2468 {
2471 break;
2472 }
2474 {
2475 for (WorldObject* target : targets)
2476 if (IsUnit(target))
2477 target->ToUnit()->SetHover(e.action.setHover.state);
2478 break;
2479 }
2481 {
2482 for (WorldObject* target : targets)
2483 if (IsUnit(target))
2485
2486 break;
2487 }
2489 {
2490 for (WorldObject* target : targets)
2491 if (IsUnit(target))
2493 break;
2494 }
2495 case SMART_ACTION_FALL:
2496 {
2497 for (WorldObject* target : targets)
2498 if (IsUnit(target))
2499 target->ToUnit()->GetMotionMaster()->MoveFall();
2500
2501 break;
2502 }
2504 {
2506 break;
2507 }
2509 {
2510 for (WorldObject* const target : targets)
2511 if (IsUnit(target))
2512 target->ToUnit()->RemoveAllGameObjects();
2513 break;
2514 }
2516 {
2517 for (WorldObject* const target : targets)
2518 {
2519 if (IsUnit(target))
2520 {
2522 target->ToUnit()->StopMoving();
2524 target->ToUnit()->GetMotionMaster()->MovementExpired();
2525 }
2526 }
2527 break;
2528 }
2530 {
2531 for (WorldObject* target : targets)
2532 if (IsUnit(target))
2534
2535 break;
2536 }
2538 {
2539 for (WorldObject* target : targets)
2540 if (IsUnit(target))
2541 if (Player* player = target->ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself())
2542 {
2544 break;
2545 }
2546
2547 break;
2548 }
2550 {
2551 if (me && me->FindMap())
2552 me->FindMap()->LoadGrid(e.target.x, e.target.y);
2553 break;
2554 }
2556 {
2557 char const* text = sObjectMgr->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE);
2558
2559 if (!targets.empty())
2560 for (WorldObject* target : targets)
2561 if (IsPlayer(target))
2562 !e.action.playerTalk.flag ? target->ToPlayer()->Say(text, LANG_UNIVERSAL) : target->ToPlayer()->Yell(text, LANG_UNIVERSAL);
2563
2564 break;
2565 }
2567 {
2568 if (!me)
2569 break;
2570
2571 for (WorldObject* target : targets)
2572 {
2573 if (IsUnit(target))
2574 {
2576 {
2578 }
2579
2581 {
2582 // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed
2583 // unless target is outside spell range, out of mana, or LOS.
2584
2585 bool _allowMove = false;
2586 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.castCustom.spell); // AssertSpellInfo?
2587 int32 mana = me->GetPower(POWER_MANA);
2588
2589 if (me->GetDistance(target->ToUnit()) > spellInfo->GetMaxRange(true) ||
2590 me->GetDistance(target->ToUnit()) < spellInfo->GetMinRange(true) ||
2591 !me->IsWithinLOSInMap(target->ToUnit()) ||
2592 mana < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()))
2593 _allowMove = true;
2594
2595 CAST_AI(SmartAI, me->AI())->SetCombatMove(_allowMove);
2596 }
2597
2599 {
2600 CustomSpellValues values;
2601 if (e.action.castCustom.bp1)
2603 if (e.action.castCustom.bp2)
2605 if (e.action.castCustom.bp3)
2608 }
2609 }
2610 }
2611 break;
2612 }
2614 {
2615 if (!me)
2616 break;
2617
2618 if (targets.empty())
2619 break;
2620
2622
2623 float a = static_cast<float>(e.action.summonVortex.a);
2624 float k = static_cast<float>(e.action.summonVortex.k) / 1000.0f;
2625 float r_max = static_cast<float>(e.action.summonVortex.r_max);
2626 float delta_phi = M_PI * static_cast<float>(e.action.summonVortex.phi_delta) / 180.0f;
2627
2628 // r(phi) = a * e ^ (k * phi)
2629 // r(phi + delta_phi) = a * e ^ (k * (phi + delta_phi))
2630 // r(phi + delta_phi) = a * e ^ (k * phi) * e ^ (k * delta_phi)
2631 // r(phi + delta_phi) = r(phi) * e ^ (k * delta_phi)
2632 float factor = std::exp(k * delta_phi);
2633
2634 // r(0) = a * e ^ (k * 0) = a * e ^ 0 = a * 1 = a
2635 float summonRadius = a;
2636
2637 for (WorldObject* target : targets)
2638 {
2639 // Offset by orientation, should not count into radius calculation,
2640 // but is needed for vortex direction (polar coordinates)
2641 float phi = target->GetOrientation();
2642
2643 do
2644 {
2645 Position summonPosition(*target);
2646 summonPosition.RelocatePolarOffset(phi, summonRadius);
2647
2649
2650 phi += delta_phi;
2651 summonRadius *= factor;
2652 } while (summonRadius <= r_max);
2653 }
2654
2655 break;
2656 }
2658 {
2659 if (!me)
2660 break;
2661
2663
2664 float distInARow = static_cast<float>(e.action.coneSummon.distanceBetweenSummons);
2665 float coneAngle = static_cast<float>(e.action.coneSummon.coneAngle) * M_PI / 180.0f;
2666
2667 for (uint32 radius = 0; radius <= e.action.coneSummon.coneLength; radius += e.action.coneSummon.distanceBetweenRings)
2668 {
2669 float deltaAngle = 0.0f;
2670 if (radius > 0)
2671 deltaAngle = distInARow / radius;
2672
2673 uint32 count = 1;
2674 if (deltaAngle > 0)
2675 count += coneAngle / deltaAngle;
2676
2677 float currentAngle = -static_cast<float>(count) * deltaAngle / 2.0f;
2678
2680 currentAngle += G3D::fuzzyGt(e.target.o, 0.0f) ? (e.target.o - me->GetOrientation()) : 0.0f;
2681 else if (!targets.empty())
2682 {
2683 currentAngle += (me->GetAngle(targets.front()) - me->GetOrientation());
2684 }
2685
2686 for (uint32 index = 0; index < count; ++index)
2687 {
2688 Position spawnPosition(*me);
2689 spawnPosition.RelocatePolarOffset(currentAngle, radius);
2690 currentAngle += deltaAngle;
2691
2693 }
2694 }
2695
2696 break;
2697 }
2699 {
2700 for (WorldObject* target : targets)
2701 {
2702 if (Player* playerTarget = target->ToPlayer())
2703 {
2704 playerTarget->RemoveArenaSpellCooldowns();
2705 playerTarget->RemoveAurasDueToSpell(57724); // Spell Shaman Debuff - Sated (Heroism)
2706 playerTarget->RemoveAurasDueToSpell(57723); // Spell Shaman Debuff - Exhaustion (Bloodlust)
2707 playerTarget->RemoveAurasDueToSpell(2825); // Bloodlust
2708 playerTarget->RemoveAurasDueToSpell(32182); // Heroism
2709 }
2710 }
2711
2712 break;
2713 }
2715 {
2718 {
2719 if (targets.empty())
2720 break;
2721
2722 for (WorldObject* objTarget : targets)
2723 {
2724 if (Creature const* unitTarget = objTarget->ToCreature())
2725 {
2726 if (unitTarget->IsAIEnabled)
2727 {
2728 unitTarget->AI()->DoAction(actionId);
2729 }
2730 }
2731 else if (GameObject const* gobjTarget = objTarget->ToGameObject())
2732 {
2733 gobjTarget->AI()->DoAction(actionId);
2734 }
2735 }
2736
2737 }
2738 else
2739 {
2740 InstanceScript* instanceScript = nullptr;
2741 if (WorldObject* baseObj = GetBaseObject())
2742 {
2743 instanceScript = baseObj->GetInstanceScript();
2744 }
2745 // Action is triggered by AreaTrigger
2746 else if (trigger && IsPlayer(unit))
2747 {
2748 instanceScript = unit->GetInstanceScript();
2749 }
2750
2751 if (instanceScript)
2752 {
2753 instanceScript->DoAction(actionId);
2754 }
2755 }
2756 break;
2757 }
2759 {
2760 if (!IsSmart())
2761 break;
2762
2763 CAST_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0);
2764 break;
2765 }
2767 {
2768 for (WorldObject* const target : targets)
2769 {
2770 if (IsCreature(target))
2772 }
2773 break;
2774 }
2776 {
2777 for (WorldObject* target : targets)
2778 if (Unit* targetUnit = target->ToUnit())
2779 targetUnit->SetHealth(targetUnit->CountPctFromMaxHealth(e.action.setHealthPct.percent));
2780 break;
2781 }
2783 {
2784 uint32 speedInteger = e.action.movementSpeed.speedInteger;
2785 uint32 speedFraction = e.action.movementSpeed.speedFraction;
2786 float speed = float(speedInteger) + float(speedFraction) / std::pow(10, std::floor(std::log10(float(speedFraction ? speedFraction : 1)) + 1));
2787
2788 for (WorldObject* target : targets)
2789 if (IsCreature(target))
2791
2792 break;
2793 }
2795 {
2796 for (WorldObject* target : targets)
2797 {
2798 if (!IsPlayer(target))
2799 continue;
2800
2802 }
2803 break;
2804 }
2806 {
2807 for (WorldObject* target : targets)
2808 {
2809 ObjectGuid guidToSend = me ? me->GetGUID() : go->GetGUID();
2810
2812 {
2813 if (Unit* invoker = GetLastInvoker())
2814 {
2815 guidToSend = invoker->GetGUID();
2816 }
2817 }
2818
2819 if (Creature* creature = target->ToCreature())
2820 {
2821 creature->AI()->SetGUID(guidToSend, e.action.setGuid.index);
2822 }
2823 else if (GameObject* object = target->ToGameObject())
2824 {
2825 object->AI()->SetGUID(guidToSend, e.action.setGuid.index);
2826 }
2827 }
2828 break;
2829 }
2831 {
2832 for (WorldObject* target : targets)
2833 {
2834 if (IsUnit(target))
2835 {
2836 target->ToUnit()->SetImmuneToAll(!e.action.disable.state);
2837 target->ToUnit()->SetVisible(e.action.disable.state);
2838 }
2839 }
2840 break;
2841 }
2843 {
2844 float scale = static_cast<float>(e.action.setScale.scale) / 100.0f;
2845
2846 for (WorldObject* target : targets)
2847 {
2848 if (IsUnit(target))
2849 {
2850 target->ToUnit()->SetObjectScale(scale);
2851 }
2852 }
2853 break;
2854 }
2856 {
2857 if (!me)
2858 break;
2859
2861
2862 float startAngle = me->GetOrientation() + (static_cast<float>(e.action.radialSummon.startAngle) * M_PI / 180.0f);
2863 float stepAngle = static_cast<float>(e.action.radialSummon.stepAngle) * M_PI / 180.0f;
2864
2865 if (e.action.radialSummon.dist)
2866 {
2867 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
2868 {
2869 Position summonPos = me->GetPosition();
2870 summonPos.RelocatePolarOffset(itr * stepAngle, static_cast<float>(e.action.radialSummon.dist));
2872 }
2873 break;
2874 }
2875
2876 for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
2877 {
2878 float currentAngle = startAngle + (itr * stepAngle);
2880 }
2881
2882 break;
2883 }
2885 {
2886 for (WorldObject* target : targets)
2887 {
2888 if (IsUnit(target))
2889 {
2892 }
2893 }
2894 break;
2895 }
2897 {
2899 {
2900 for (WorldObject* target : targets)
2901 if (IsUnit(target))
2902 target->ToCreature()->GetMotionMaster()->MoveIdle();
2903
2904 break;
2905 }
2906
2907 uint8 membCount = targets.size();
2908 uint8 itr = 1;
2909 float dist = float(e.action.followGroup.dist / 100);
2910 switch (e.action.followGroup.followType)
2911 {
2912 case FOLLOW_TYPE_CIRCLE:
2913 {
2914 float angle = (membCount > 4 ? (M_PI * 2)/membCount : (M_PI / 2)); // 90 degrees is the maximum angle
2915 for (WorldObject* target : targets)
2916 {
2917 if (IsCreature(target))
2918 {
2919 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, angle * itr);
2920 itr++;
2921 }
2922 }
2923 break;
2924 }
2926 {
2927 for (WorldObject* target : targets)
2928 {
2929 if (IsCreature(target))
2930 {
2931 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1));
2932 itr++;
2933 }
2934 }
2935 break;
2936 }
2938 {
2939 for (WorldObject* target : targets)
2940 {
2941 if (IsCreature(target))
2942 {
2943 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist, (M_PI + (M_PI / 2.0f) + (M_PI / membCount) * (itr - 1)));
2944 itr++;
2945 }
2946 }
2947 break;
2948 }
2949 case FOLLOW_TYPE_LINE:
2950 {
2951 for (WorldObject* target : targets)
2952 {
2953 if (IsCreature(target))
2954 {
2955 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? 0.f : M_PI);
2956 itr++;
2957 }
2958 }
2959 break;
2960 }
2961 case FOLLOW_TYPE_COLUMN:
2962 {
2963 for (WorldObject* target : targets)
2964 {
2965 if (IsCreature(target))
2966 {
2967 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? (M_PI / 2) : (M_PI * 1.5f));
2968 itr++;
2969 }
2970 }
2971 break;
2972 }
2974 {
2975 for (WorldObject* target : targets)
2976 {
2977 if (IsCreature(target))
2978 {
2979 target->ToCreature()->GetMotionMaster()->MoveFollow(me, dist * (((itr - 1) / 2) + 1), itr % 2 ? M_PI - (M_PI / 4) : M_PI + (M_PI / 4));
2980 itr++;
2981 }
2982 }
2983 break;
2984 }
2985 default:
2986 break;
2987 }
2988
2989 break;
2990 }
2992 {
2993 switch (e.action.orientationTarget.type)
2994 {
2995 case 0: // Reset
2996 {
2997 for (WorldObject* target : targets)
2998 target->ToCreature()->SetFacingTo((target->ToCreature()->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && target->ToCreature()->GetTransGUID() ? target->ToCreature()->GetTransportHomePosition() : target->ToCreature()->GetHomePosition()).GetOrientation());
2999
3000 break;
3001 }
3002 case 1: // Target target.o
3003 {
3004 for (WorldObject* target : targets)
3005 target->ToCreature()->SetFacingTo(e.target.o);
3006
3007 break;
3008 }
3009 case 2: // Target source
3010 {
3011 for (WorldObject* target : targets)
3012 target->ToCreature()->SetFacingToObject(me);
3013
3014 break;
3015 }
3016 case 3: // Target parameters
3017 {
3018 ObjectVector facingTargets;
3020
3021 for (WorldObject* facingTarget : facingTargets)
3022 for (WorldObject* target : targets)
3023 target->ToCreature()->SetFacingToObject(facingTarget);
3024
3025 break;
3026 }
3027 default:
3028 break;
3029 }
3030 break;
3031 }
3032 default:
3033 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
3034 break;
3035 }
3036
3037 if (e.link && e.link != e.event_id)
3038 {
3040 if (linked.GetActionType() && linked.GetEventType() == SMART_EVENT_LINK)
3041 ProcessEvent(linked, unit, var0, var1, bvar, spell, gob);
3042 else
3043 LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Link Event {} not found or invalid, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
3044 }
3045}
#define DEFAULT_LOCALE
Definition: Common.h:81
std::int8_t int8
Definition: Define.h:106
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:27
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
float frand(float min, float max)
Definition: Random.cpp:57
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
#define CAST_AI(a, b)
Definition: ScriptedCreature.h:28
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const guid)
Definition: ScriptedGossip.cpp:45
void ClearGossipMenuFor(Player *player)
Definition: ScriptedGossip.cpp:22
SMARTAI_TARGETS
Definition: SmartScriptMgr.h:1462
@ SMART_TARGET_RANDOM_POINT
Definition: SmartScriptMgr.h:1501
#define sSmartWaypointMgr
Definition: SmartScriptMgr.h:2149
SMART_ACTION
Definition: SmartScriptMgr.h:537
@ SMART_ACTION_REMOVE_TIMED_EVENT
Definition: SmartScriptMgr.h:612
@ SMART_ACTION_NONE
Definition: SmartScriptMgr.h:538
@ SMART_ACTION_SET_GO_FLAG
Definition: SmartScriptMgr.h:642
@ SMART_ACTION_WP_RESUME
Definition: SmartScriptMgr.h:603
@ SMART_ACTION_UPDATE_TEMPLATE
Definition: SmartScriptMgr.h:574
@ SMART_ACTION_SET_HEALTH_REGEN
Definition: SmartScriptMgr.h:640
@ SMART_ACTION_ACTIVATE_GOBJECT
Definition: SmartScriptMgr.h:547
@ SMART_ACTION_GAME_EVENT_START
Definition: SmartScriptMgr.h:650
@ SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST
Definition: SmartScriptMgr.h:626
@ SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1
Definition: SmartScriptMgr.h:629
@ SMART_ACTION_SET_INST_DATA64
Definition: SmartScriptMgr.h:573
@ SMART_ACTION_SET_FACTION
Definition: SmartScriptMgr.h:540
@ SMART_ACTION_THREAT_SINGLE_PCT
Definition: SmartScriptMgr.h:551
@ SMART_ACTION_OFFER_QUEST
Definition: SmartScriptMgr.h:545
@ SMART_ACTION_REMOVE_ALL_GAMEOBJECTS
Definition: SmartScriptMgr.h:664
@ SMART_ACTION_RISE_UP
Definition: SmartScriptMgr.h:652
@ SMART_ACTION_SET_INGAME_PHASE_MASK
Definition: SmartScriptMgr.h:582
@ SMART_ACTION_SET_UNIT_FIELD_BYTES_1
Definition: SmartScriptMgr.h:628
@ SMART_ACTION_CLOSE_GOSSIP
Definition: SmartScriptMgr.h:610
@ SMART_ACTION_DISABLE_EVADE
Definition: SmartScriptMgr.h:655
@ SMART_ACTION_CONE_SUMMON
Definition: SmartScriptMgr.h:702
@ SMART_ACTION_ADD_GO_FLAG
Definition: SmartScriptMgr.h:643
@ SMART_ACTION_ADD_DYNAMIC_FLAG
Definition: SmartScriptMgr.h:633
@ SMART_ACTION_KILL_UNIT
Definition: SmartScriptMgr.h:589
@ SMART_ACTION_LOAD_EQUIPMENT
Definition: SmartScriptMgr.h:662
@ SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS
Definition: SmartScriptMgr.h:553
@ SMART_ACTION_ATTACK_START
Definition: SmartScriptMgr.h:587
@ SMART_ACTION_SET_UNIT_FLAG
Definition: SmartScriptMgr.h:556
@ SMART_ACTION_NO_ENVIRONMENT_UPDATE
Definition: SmartScriptMgr.h:695
@ SMART_ACTION_CALL_GROUPEVENTHAPPENS
Definition: SmartScriptMgr.h:564
@ SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL
Definition: SmartScriptMgr.h:581
@ SMART_ACTION_INVOKER_CAST
Definition: SmartScriptMgr.h:672
@ SMART_ACTION_SET_SCALE
Definition: SmartScriptMgr.h:710
@ SMART_ACTION_JUMP_TO_POS
Definition: SmartScriptMgr.h:635
@ SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST
Definition: SmartScriptMgr.h:625
@ SMART_ACTION_SEND_GOSSIP_MENU
Definition: SmartScriptMgr.h:636
@ SMART_ACTION_SET_COUNTER
Definition: SmartScriptMgr.h:601
@ SMART_ACTION_FLEE_FOR_ASSIST
Definition: SmartScriptMgr.h:563
@ SMART_ACTION_EQUIP
Definition: SmartScriptMgr.h:609
@ SMART_ACTION_SET_ROOT
Definition: SmartScriptMgr.h:641
@ SMART_ACTION_ATTACK_STOP
Definition: SmartScriptMgr.h:707
@ SMART_ACTION_SUMMON_GO
Definition: SmartScriptMgr.h:588
@ SMART_ACTION_SET_HOVER
Definition: SmartScriptMgr.h:689
@ SMART_ACTION_WP_PAUSE
Definition: SmartScriptMgr.h:592
@ SMART_ACTION_SIMPLE_TALK
Definition: SmartScriptMgr.h:622
@ SMART_ACTION_STOP_MOTION
Definition: SmartScriptMgr.h:694
@ SMART_ACTION_VORTEX_SUMMON
Definition: SmartScriptMgr.h:704
@ SMART_ACTION_MUSIC
Definition: SmartScriptMgr.h:698
@ SMART_ACTION_SET_ORIENTATION_TARGET
Definition: SmartScriptMgr.h:714
@ SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS
Definition: SmartScriptMgr.h:686
@ SMART_ACTION_ADD_AURA
Definition: SmartScriptMgr.h:613
@ SMART_ACTION_THREAT_ALL_PCT
Definition: SmartScriptMgr.h:552
@ SMART_ACTION_RESPAWN_TARGET
Definition: SmartScriptMgr.h:608
@ SMART_ACTION_FOLLOW_GROUP
Definition: SmartScriptMgr.h:713
@ SMART_ACTION_SOUND
Definition: SmartScriptMgr.h:542
@ SMART_ACTION_MOVE_TO_POS_TARGET
Definition: SmartScriptMgr.h:683
@ SMART_ACTION_SET_MOVEMENT_SPEED
Definition: SmartScriptMgr.h:674
@ SMART_ACTION_PLAY_CINEMATIC
Definition: SmartScriptMgr.h:673
@ SMART_ACTION_ADD_NPC_FLAG
Definition: SmartScriptMgr.h:620
@ SMART_ACTION_EVADE
Definition: SmartScriptMgr.h:562
@ SMART_ACTION_FAIL_QUEST
Definition: SmartScriptMgr.h:544
@ SMART_ACTION_INTERRUPT_SPELL
Definition: SmartScriptMgr.h:630
@ SMART_ACTION_ADD_POWER
Definition: SmartScriptMgr.h:647
@ SMART_ACTION_REMOVE_DYNAMIC_FLAG
Definition: SmartScriptMgr.h:634
@ SMART_ACTION_RANDOM_SOUND
Definition: SmartScriptMgr.h:653
@ SMART_ACTION_RANDOM_MUSIC
Definition: SmartScriptMgr.h:699
@ SMART_ACTION_SET_COMBAT_DISTANCE
Definition: SmartScriptMgr.h:687
@ SMART_ACTION_SET_POWER
Definition: SmartScriptMgr.h:646
@ SMART_ACTION_SEND_TARGET_TO_TARGET
Definition: SmartScriptMgr.h:638
@ SMART_ACTION_REMOVE_POWER
Definition: SmartScriptMgr.h:648
@ SMART_ACTION_ADD_IMMUNITY
Definition: SmartScriptMgr.h:690
@ SMART_ACTION_SET_DYNAMIC_FLAG
Definition: SmartScriptMgr.h:632
@ SMART_ACTION_FALL
Definition: SmartScriptMgr.h:692
@ SMART_ACTION_GO_SET_GO_STATE
Definition: SmartScriptMgr.h:656
@ SMART_ACTION_CUSTOM_CAST
Definition: SmartScriptMgr.h:701
@ SMART_ACTION_REMOVE_ITEM
Definition: SmartScriptMgr.h:595
@ SMART_ACTION_SEND_GO_CUSTOM_ANIM
Definition: SmartScriptMgr.h:631
@ SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL
Definition: SmartScriptMgr.h:541
@ SMART_ACTION_REMOVE_UNIT_FLAG
Definition: SmartScriptMgr.h:557
@ SMART_ACTION_RANDOM_PHASE
Definition: SmartScriptMgr.h:568
@ SMART_ACTION_SET_EMOTE_STATE
Definition: SmartScriptMgr.h:555
@ SMART_ACTION_CROSS_CAST
Definition: SmartScriptMgr.h:624
@ SMART_ACTION_WP_STOP
Definition: SmartScriptMgr.h:593
@ SMART_ACTION_GAME_EVENT_STOP
Definition: SmartScriptMgr.h:649
@ SMART_ACTION_CALL_SCRIPT_RESET
Definition: SmartScriptMgr.h:616
@ SMART_ACTION_CU_ENCOUNTER_START
Definition: SmartScriptMgr.h:705
@ SMART_ACTION_WP_START
Definition: SmartScriptMgr.h:591
@ SMART_ACTION_COMBAT_STOP
Definition: SmartScriptMgr.h:565
@ SMART_ACTION_EXIT_VEHICLE
Definition: SmartScriptMgr.h:685
@ SMART_ACTION_SET_HEALTH_PCT
Definition: SmartScriptMgr.h:676
@ SMART_ACTION_AUTO_ATTACK
Definition: SmartScriptMgr.h:558
@ SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL
Definition: SmartScriptMgr.h:580
@ SMART_ACTION_SET_VISIBILITY
Definition: SmartScriptMgr.h:585
@ SMART_ACTION_RANDOM_PHASE_RANGE
Definition: SmartScriptMgr.h:569
@ SMART_ACTION_GO_SET_LOOT_STATE
Definition: SmartScriptMgr.h:637
@ SMART_ACTION_PLAYER_TALK
Definition: SmartScriptMgr.h:703
@ SMART_ACTION_SELF_CAST
Definition: SmartScriptMgr.h:623
@ SMART_ACTION_SET_SWIM
Definition: SmartScriptMgr.h:599
@ SMART_ACTION_SET_SIGHT_DIST
Definition: SmartScriptMgr.h:659
@ SMART_ACTION_SET_INST_DATA
Definition: SmartScriptMgr.h:572
@ SMART_ACTION_REMOVE_GO_FLAG
Definition: SmartScriptMgr.h:644
@ SMART_ACTION_LOAD_GRID
Definition: SmartScriptMgr.h:697
@ SMART_ACTION_CALL_FOR_HELP
Definition: SmartScriptMgr.h:577
@ SMART_ACTION_SUMMON_RADIAL
Definition: SmartScriptMgr.h:711
@ SMART_ACTION_ADD_THREAT
Definition: SmartScriptMgr.h:661
@ SMART_ACTION_TELEPORT
Definition: SmartScriptMgr.h:600
@ SMART_ACTION_PLAYMOVIE
Definition: SmartScriptMgr.h:606
@ SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT
Definition: SmartScriptMgr.h:663
@ SMART_ACTION_FOLLOW
Definition: SmartScriptMgr.h:567
@ SMART_ACTION_PLAY_EMOTE
Definition: SmartScriptMgr.h:543
@ SMART_ACTION_SET_CORPSE_DELAY
Definition: SmartScriptMgr.h:654
@ SMART_ACTION_SET_GUID
Definition: SmartScriptMgr.h:708
@ SMART_ACTION_SET_SHEATH
Definition: SmartScriptMgr.h:578
@ SMART_ACTION_SET_ORIENTATION
Definition: SmartScriptMgr.h:604
@ SMART_ACTION_SET_NPC_FLAG
Definition: SmartScriptMgr.h:619
@ SMART_ACTION_MOVE_TO_POS
Definition: SmartScriptMgr.h:607
@ SMART_ACTION_RANDOM_EMOTE
Definition: SmartScriptMgr.h:548
@ SMART_ACTION_INC_EVENT_PHASE
Definition: SmartScriptMgr.h:561
@ SMART_ACTION_CREATE_TIMED_EVENT
Definition: SmartScriptMgr.h:605
@ SMART_ACTION_SET_EVENT_FLAG_RESET
Definition: SmartScriptMgr.h:693
@ SMART_ACTION_DIE
Definition: SmartScriptMgr.h:575
@ SMART_ACTION_RESET_SCRIPT_BASE_OBJECT
Definition: SmartScriptMgr.h:615
@ SMART_ACTION_REMOVE_NPC_FLAG
Definition: SmartScriptMgr.h:621
@ SMART_ACTION_SET_FLY
Definition: SmartScriptMgr.h:598
@ SMART_ACTION_INSTALL_AI_TEMPLATE
Definition: SmartScriptMgr.h:596
@ SMART_ACTION_SUMMON_CREATURE
Definition: SmartScriptMgr.h:550
@ SMART_ACTION_CALL_TIMED_ACTIONLIST
Definition: SmartScriptMgr.h:618
@ SMART_ACTION_SET_IN_COMBAT_WITH_ZONE
Definition: SmartScriptMgr.h:576
@ SMART_ACTION_DO_ACTION
Definition: SmartScriptMgr.h:706
@ SMART_ACTION_SET_HOME_POS
Definition: SmartScriptMgr.h:639
@ SMART_ACTION_ADD_ITEM
Definition: SmartScriptMgr.h:594
@ SMART_ACTION_SET_ACTIVE
Definition: SmartScriptMgr.h:586
@ SMART_ACTION_SET_RANGED_MOVEMENT
Definition: SmartScriptMgr.h:617
@ SMART_ACTION_ACTIVATE_TAXI
Definition: SmartScriptMgr.h:590
@ SMART_ACTION_DISABLE
Definition: SmartScriptMgr.h:709
@ SMART_ACTION_START_CLOSEST_WAYPOINT
Definition: SmartScriptMgr.h:651
@ SMART_ACTION_SET_CASTER_COMBAT_DIST
Definition: SmartScriptMgr.h:688
@ SMART_ACTION_SUMMON_CREATURE_GROUP
Definition: SmartScriptMgr.h:645
@ SMART_ACTION_REMOVE_IMMUNITY
Definition: SmartScriptMgr.h:691
@ SMART_ACTION_PLAY_SPELL_VISUAL
Definition: SmartScriptMgr.h:712
@ SMART_ACTION_SET_REACT_STATE
Definition: SmartScriptMgr.h:546
@ SMART_ACTION_RANDOM_MOVE
Definition: SmartScriptMgr.h:627
@ SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT
Definition: SmartScriptMgr.h:614
@ SMART_ACTION_TRIGGER_TIMED_EVENT
Definition: SmartScriptMgr.h:611
@ SMART_ACTION_REMOVEAURASFROMSPELL
Definition: SmartScriptMgr.h:566
@ SMART_ACTION_FLEE
Definition: SmartScriptMgr.h:660
@ SMART_ACTION_ZONE_UNDER_ATTACK
Definition: SmartScriptMgr.h:696
@ FOLLOW_TYPE_CIRCLE
Definition: SmartScriptMgr.h:1877
@ FOLLOW_TYPE_SEMI_CIRCLE_BEHIND
Definition: SmartScriptMgr.h:1878
@ FOLLOW_TYPE_SEMI_CIRCLE_FRONT
Definition: SmartScriptMgr.h:1879
@ FOLLOW_TYPE_COLUMN
Definition: SmartScriptMgr.h:1881
@ FOLLOW_TYPE_ANGULAR
Definition: SmartScriptMgr.h:1882
@ FOLLOW_TYPE_LINE
Definition: SmartScriptMgr.h:1880
SMART_EVENT
Definition: SmartScriptMgr.h:117
@ SMART_EVENT_TIMED_EVENT_TRIGGERED
Definition: SmartScriptMgr.h:177
@ SMART_EVENT_LINK
Definition: SmartScriptMgr.h:179
@ SMART_EVENT_WAYPOINT_REACHED
Definition: SmartScriptMgr.h:158
SmartActionSummonCreatureFlags
Definition: SmartScriptMgr.h:720
@ SMART_ESCORT_TARGETS
Definition: SmartScriptMgr.h:59
std::unordered_map< uint32, WayPoint * > WPPath
Definition: SmartScriptMgr.h:1913
@ SMARTCAST_TRIGGERED
Definition: SmartScriptMgr.h:1865
@ SMARTCAST_INTERRUPT_PREVIOUS
Definition: SmartScriptMgr.h:1864
@ SMARTCAST_AURA_NOT_PRESENT
Definition: SmartScriptMgr.h:1869
@ SMARTCAST_THREATLIST_NOT_SINGLE
Definition: SmartScriptMgr.h:1871
@ SMARTCAST_TARGET_POWER_MANA
Definition: SmartScriptMgr.h:1872
npc
Definition: BattlegroundSA.h:75
#define MAX_EQUIPMENT_ITEMS
Definition: CreatureData.h:39
LootState
Definition: GameObject.h:111
@ GO_READY
Definition: GameObject.h:113
GOState
Definition: GameObjectData.h:689
TempSummonType
Definition: Object.h:41
@ TEMPSUMMON_TIMED_DESPAWN
Definition: Object.h:44
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: Object.h:46
@ UNIT_NPC_FLAGS
Definition: UpdateFields.h:139
@ 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
@ MOVEMENTFLAG_ONTRANSPORT
Definition: Unit.h:561
ReactStates
Definition: Unit.h:1034
SheathState
Definition: Unit.h:125
@ UNIT_STATE_LOST_CONTROL
Definition: Unit.h:366
@ UNIT_STATE_ROOT
Definition: Unit.h:335
@ UNIT_STATE_NO_ENVIRONMENT_UPD
Definition: Unit.h:353
UnitMoveType
Definition: Unit.h:377
@ MOVE_RUN
Definition: Unit.h:379
@ UNIT_FLAG_SILENCED
Definition: Unit.h:461
#define sGameEventMgr
Definition: GameEventMgr.h:186
#define sObjectMgr
Definition: ObjectMgr.h:1640
EncounterState
Definition: InstanceScript.h:56
@ BROADCAST_TEXT_CALL_FOR_HELP
Definition: Language.h:24
@ BROADCAST_TEXT_FLEE_FOR_ASSIST
Definition: Language.h:25
@ MOTION_SLOT_CONTROLLED
Definition: MotionMaster.h:63
@ MOTION_SLOT_ACTIVE
Definition: MotionMaster.h:62
@ CHASE_MOTION_TYPE
Definition: MotionMaster.h:43
@ AURA_REMOVE_BY_EXPIRE
Definition: SpellAuraDefines.h:395
@ SPELLVALUE_BASE_POINT1
Definition: SpellDefines.h:115
@ SPELLVALUE_BASE_POINT2
Definition: SpellDefines.h:116
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:114
TriggerCastFlags
Definition: SpellDefines.h:130
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition: SpellDefines.h:148
@ TRIGGERED_NONE
Definition: SpellDefines.h:131
@ TEXT_RANGE_NORMAL
Definition: CreatureTextMgr.h:30
phase
Definition: boss_skadi.cpp:103
@ GAMEOBJECT_TYPE_DOOR
Definition: SharedDefines.h:1560
@ CHAT_MSG_MONSTER_EMOTE
Definition: SharedDefines.h:3168
@ CHAT_MSG_ADDON
Definition: SharedDefines.h:3151
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
@ LANG_ADDON
Definition: SharedDefines.h:753
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
std::string ToString(Type &&val, Params &&... params)
Definition: StringConvert.h:250
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:135
Player * GetPlayer(Map const *, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:223
bool IsEmpty() const
Definition: LinkedList.h:97
Definition: LinkedList.h:139
Definition: EnumFlag.h:66
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
Definition: EventProcessor.h:108
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:27
Definition: SmartAI.h:45
SmartScript * GetScript()
Definition: SmartAI.h:73
void SetInvincibilityHpLevel(uint32 level)
Definition: SmartAI.h:181
Definition: SmartAI.h:253
void IncPhase(uint32 p)
Definition: SmartScript.cpp:5050
void SetActualCombatDist(uint32 dist)
Definition: SmartScript.h:220
bool IsSmart(Creature *c=nullptr)
Definition: SmartScript.h:86
bool IsSmartGO(GameObject *g=nullptr)
Definition: SmartScript.h:101
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:3751
void StoreTargetList(ObjectVector const &targets, uint32 id)
Definition: SmartScript.h:79
SmartScriptHolder FindLinkedEvent(uint32 link)
Definition: SmartScript.h:297
static bool IsUnit(WorldObject *obj)
Definition: SmartScript.cpp:5019
float GetCasterActualDist() const
Definition: SmartScript.h:229
void StoreCounter(uint32 id, uint32 value, uint32 reset, uint32 subtract)
Definition: SmartScript.h:123
float GetCasterMaxDist() const
Definition: SmartScript.h:230
void SetPhaseReset(bool allow)
Definition: SmartScript.h:233
void GetTargets(ObjectVector &targets, SmartScriptHolder const &e, Unit *invoker=nullptr) const
Definition: SmartScript.cpp:3174
uint32 GetMaxCombatDist() const
Definition: SmartScript.h:223
void SetCasterActualDist(float dist)
Definition: SmartScript.h:226
void OnReset()
Definition: SmartScript.cpp:76
void InstallTemplate(SmartScriptHolder const &e)
Definition: SmartScript.cpp:3062
ObjectGuid goOrigGUID
Definition: SmartScript.h:251
Powers GetCasterPowerType() const
Definition: SmartScript.h:228
void DecPhase(uint32 p)
Definition: SmartScript.cpp:5056
ObjectGuid meOrigGUID
Definition: SmartScript.h:249
Definition: SmartScriptMgr.h:33
uint32 id
Definition: SmartScriptMgr.h:44
Definition: SmartScriptMgr.h:220
uint32 repeatMin
Definition: SmartScriptMgr.h:231
uint32 repeatMax
Definition: SmartScriptMgr.h:232
Definition: SmartScriptMgr.h:731
uint32 followState
Definition: SmartScriptMgr.h:1421
uint32 visualId
Definition: SmartScriptMgr.h:1416
struct SmartAction::@73::@147 moveToPos
uint32 targetParam2
Definition: SmartScriptMgr.h:834
struct SmartAction::@73::@131 timeEvent
struct SmartAction::@73::@133 equip
std::array< uint32, SMART_ACTION_PARAM_COUNT > emotes
Definition: SmartScriptMgr.h:817
struct SmartAction::@73::@92 summonCreature
struct SmartAction::@73::@163 casterDistance
struct SmartAction::@73::@153 setRoot
uint32 repeatMax
Definition: SmartScriptMgr.h:1092
uint32 phaseMin
Definition: SmartScriptMgr.h:919
uint32 targetsLimit
Definition: SmartScriptMgr.h:825
struct SmartAction::@73::@151 setRangedMovement
SAIBool transport
Definition: SmartScriptMgr.h:1186
struct SmartAction::@73::@164 setHomePos
struct SmartAction::@73::@127 setSwim
uint32 newPower
Definition: SmartScriptMgr.h:1243
struct SmartAction::@73::@120 wpStart
uint32 startAngle
Definition: SmartScriptMgr.h:1409
SAIBool reset
Definition: SmartScriptMgr.h:1077
std::array< uint32, SMART_ACTION_PARAM_COUNT > actionLists
Definition: SmartScriptMgr.h:1140
uint32 delay
Definition: SmartScriptMgr.h:964
struct SmartAction::@73::@173 castCustom
struct SmartAction::@73::@178 movementSpeed
uint32 random
Definition: SmartScriptMgr.h:1309
struct SmartAction::@73::@122 wpStop
uint32 quickChange
Definition: SmartScriptMgr.h:1308
struct SmartAction::@73::@100 removeAura
uint32 targetParam4
Definition: SmartScriptMgr.h:1433
SAIBool root
Definition: SmartScriptMgr.h:1220
uint32 dist
Definition: SmartScriptMgr.h:904
uint32 group
Definition: SmartScriptMgr.h:1235
SAIBool disable
Definition: SmartScriptMgr.h:1363
uint32 spell
Definition: SmartScriptMgr.h:822
std::array< uint32, SMART_ACTION_PARAM_COUNT > wps
Definition: SmartScriptMgr.h:1258
uint32 minHP
Definition: SmartScriptMgr.h:970
struct SmartAction::@73::@180 cinematic
SAIBool force
Definition: SmartScriptMgr.h:1285
uint32 flags
Definition: SmartScriptMgr.h:831
struct SmartAction::@73::@170 stopMotion
uint32 distanceBetweenSummons
Definition: SmartScriptMgr.h:1324
uint32 data
Definition: SmartScriptMgr.h:931
uint32 powerType
Definition: SmartScriptMgr.h:1242
SAIBool regenHealth
Definition: SmartScriptMgr.h:1215
uint32 entry
Definition: SmartScriptMgr.h:906
struct SmartAction::@73::@185 spellVisual
uint32 quest
Definition: SmartScriptMgr.h:801
struct SmartAction::@73::@126 setFly
struct SmartAction::@73::@137 delunitByte
uint32 triggerFlags
Definition: SmartScriptMgr.h:824
uint32 bp1
Definition: SmartScriptMgr.h:1339
uint32 distance
Definition: SmartScriptMgr.h:764
struct SmartAction::@73::@102 randomPhase
struct SmartAction::@73::@168 immunity
uint32 min
Definition: SmartScriptMgr.h:1089
SAIBool withDelayed
Definition: SmartScriptMgr.h:1151
SAIBool withInstant
Definition: SmartScriptMgr.h:1153
uint32 subtract
Definition: SmartScriptMgr.h:1078
struct SmartAction::@73::@104 killedMonster
uint32 a
Definition: SmartScriptMgr.h:1348
SAIBool invokerGUID
Definition: SmartScriptMgr.h:1390
uint32 percent
Definition: SmartScriptMgr.h:971
uint32 dec
Definition: SmartScriptMgr.h:888
struct SmartAction::@73::@150 sendTargetToTarget
uint32 milliseconds
Definition: SmartScriptMgr.h:948
struct SmartAction::@73::@89 crossCast
struct SmartAction::@73::@111 forceDespawn
struct SmartAction::@73::@114 setData
struct SmartAction::@73::@134 unitFlag
uint32 summonEntry
Definition: SmartScriptMgr.h:1321
uint32 followType
Definition: SmartScriptMgr.h:1422
uint32 instanceTarget
Definition: SmartScriptMgr.h:1358
uint32 credit
Definition: SmartScriptMgr.h:907
struct SmartAction::@73::@128 teleport
uint32 controlled
Definition: SmartScriptMgr.h:1187
uint32 alternative
Definition: SmartScriptMgr.h:840
uint32 targetParam1
Definition: SmartScriptMgr.h:833
uint32 mapID
Definition: SmartScriptMgr.h:1070
uint32 stopMovement
Definition: SmartScriptMgr.h:1315
struct SmartAction::@73::@181 setGuid
struct SmartAction::@73::@103 randomPhaseRange
uint32 charges
Definition: SmartScriptMgr.h:899
struct SmartAction::@73::@177 corpseDelay
struct SmartAction::@73::@98 incEventPhase
struct SmartAction::@73::@183 setScale
uint32 model
Definition: SmartScriptMgr.h:757
struct SmartAction::@73::@152 setHealthRegen
uint32 duration
Definition: SmartScriptMgr.h:739
struct SmartAction::@73::@141 interruptSpellCasting
SAIBool attackInvoker
Definition: SmartScriptMgr.h:853
SAIBool useTalkTarget
Definition: SmartScriptMgr.h:740
SAIBool run
Definition: SmartScriptMgr.h:1015
struct SmartAction::@73::@159 gameEventStart
struct SmartAction::@73::@142 sendGoCustomAnim
uint32 value
Definition: SmartScriptMgr.h:1076
uint32 movementExpired
Definition: SmartScriptMgr.h:1316
struct SmartAction::@73::@106 setInstanceData64
uint32 targetParam3
Definition: SmartScriptMgr.h:835
struct SmartAction::@73::@179 setHealthPct
SAIBool swim
Definition: SmartScriptMgr.h:1065
struct SmartAction::@73::@165 loadEquipment
uint32 sound2
Definition: SmartScriptMgr.h:770
struct SmartAction::@73::@176 disableEvade
struct SmartAction::@73::@109 callHelp
uint32 spawnPos
Definition: SmartScriptMgr.h:1279
uint32 creature
Definition: SmartScriptMgr.h:756
struct SmartAction::@73::@97 setEventPhase
struct SmartAction::@73::@86 react
uint32 angle
Definition: SmartScriptMgr.h:905
uint32 field
Definition: SmartScriptMgr.h:930
struct SmartAction::@73::@90 activateObject
uint32 range
Definition: SmartScriptMgr.h:845
uint32 flag
Definition: SmartScriptMgr.h:1110
struct SmartAction::@73::@96 combatMove
struct SmartAction::@73::@145 flee
uint32 sound3
Definition: SmartScriptMgr.h:771
struct SmartAction::@73::@156 creatureGroup
uint32 targetsummon
Definition: SmartScriptMgr.h:1004
uint32 chance
Definition: SmartScriptMgr.h:1093
uint32 state
Definition: SmartScriptMgr.h:812
uint32 byte1
Definition: SmartScriptMgr.h:1121
struct SmartAction::@73::@148 sendGossipMenu
struct SmartAction::@73::@125 setRun
uint32 sound1
Definition: SmartScriptMgr.h:769
SAIBool updateLevel
Definition: SmartScriptMgr.h:943
struct SmartAction::@73::@154 goFlag
uint32 forceRespawnTimer
Definition: SmartScriptMgr.h:965
uint32 speed
Definition: SmartScriptMgr.h:1059
struct SmartAction::@73::@82 randomMusic
struct SmartAction::@73::@167 setHover
uint32 sound4
Definition: SmartScriptMgr.h:772
uint32 targetType
Definition: SmartScriptMgr.h:832
uint32 repetitions
Definition: SmartScriptMgr.h:1408
struct SmartAction::@73::@80 randomSound
struct SmartAction::@73::@112 invincHP
uint32 aliveState
Definition: SmartScriptMgr.h:909
SAIBool onlySelf
Definition: SmartScriptMgr.h:763
uint32 attackScriptOwner
Definition: SmartScriptMgr.h:854
uint32 speedxy
Definition: SmartScriptMgr.h:1163
uint32 pointId
Definition: SmartScriptMgr.h:1185
SAIBool attack
Definition: SmartScriptMgr.h:872
uint32 repeatMin
Definition: SmartScriptMgr.h:1091
uint32 anim
Definition: SmartScriptMgr.h:1158
struct SmartAction::@73::@118 summonGO
struct SmartAction::@73::@121 wpPause
uint32 scale
Definition: SmartScriptMgr.h:1401
SAIBool fly
Definition: SmartScriptMgr.h:1058
uint32 textGroupID
Definition: SmartScriptMgr.h:738
uint32 castFlags
Definition: SmartScriptMgr.h:823
std::array< uint32, SMART_ACTION_PARAM_COUNT > phases
Definition: SmartScriptMgr.h:914
uint32 spell_id
Definition: SmartScriptMgr.h:1152
uint32 turnAngle
Definition: SmartScriptMgr.h:1310
uint32 textId
Definition: SmartScriptMgr.h:1331
uint32 gossipMenuId
Definition: SmartScriptMgr.h:1193
struct SmartAction::@73::@123 item
uint32 speedz
Definition: SmartScriptMgr.h:1164
SAIBool repeat
Definition: SmartScriptMgr.h:1017
uint32 gossipNpcTextId
Definition: SmartScriptMgr.h:1194
struct SmartAction::@73::@88 cast
uint32 mask
Definition: SmartScriptMgr.h:976
struct SmartAction::@73::@149 setGoLootState
uint32 phi_delta
Definition: SmartScriptMgr.h:1351
uint32 count
Definition: SmartScriptMgr.h:1038
struct SmartAction::@73::@160 closestWaypointFromList
uint32 inc
Definition: SmartScriptMgr.h:887
struct SmartAction::@73::@101 follow
uint32 phaseMax
Definition: SmartScriptMgr.h:920
struct SmartAction::@73::@143 jump
uint32 timer
Definition: SmartScriptMgr.h:1368
uint32 ContactDistance
Definition: SmartScriptMgr.h:1188
struct SmartAction::@73::@139 randTimedActionList
uint32 k
Definition: SmartScriptMgr.h:1349
uint32 distanceBetweenRings
Definition: SmartScriptMgr.h:1323
uint32 coneLength
Definition: SmartScriptMgr.h:1325
struct SmartAction::@73::@75 talk
struct SmartAction::@73::@186 followGroup
uint32 counterId
Definition: SmartScriptMgr.h:1075
SAIBool withEmote
Definition: SmartScriptMgr.h:954
struct SmartAction::@73::@175 doAction
uint32 max
Definition: SmartScriptMgr.h:1090
uint32 selfJump
Definition: SmartScriptMgr.h:1165
struct SmartAction::@73::@169 orientation
uint32 maxId
Definition: SmartScriptMgr.h:1291
struct SmartAction::@73::@110 setSheath
struct SmartAction::@73::@172 playerTalk
struct SmartAction::@73::@95 autoAttack
struct SmartAction::@73::@130 storeTargets
uint32 r_max
Definition: SmartScriptMgr.h:1350
uint32 speedFraction
Definition: SmartScriptMgr.h:1375
struct SmartAction::@73::@78 morphOrMount
SAIBool fail
Definition: SmartScriptMgr.h:1032
struct SmartAction::@73::@85 questOffer
SAIBool directAdd
Definition: SmartScriptMgr.h:807
uint32 bp2
Definition: SmartScriptMgr.h:1340
uint32 disableGravity
Definition: SmartScriptMgr.h:1060
uint32 sound
Definition: SmartScriptMgr.h:762
uint32 threatINC
Definition: SmartScriptMgr.h:860
struct SmartAction::@73::@162 sightDistance
struct SmartAction::@73::@129 setCounter
struct SmartAction::@73::@136 setunitByte
uint32 coneAngle
Definition: SmartScriptMgr.h:1326
uint32 summonDuration
Definition: SmartScriptMgr.h:1322
struct SmartAction::@73::@171 coneSummon
struct SmartAction::@73::@117 setActive
uint32 threatDEC
Definition: SmartScriptMgr.h:861
struct SmartAction::@73::@113 ingamePhaseMask
struct SmartAction::@73::@87 randomEmote
uint32 stepAngle
Definition: SmartScriptMgr.h:1410
uint32 reactState
Definition: SmartScriptMgr.h:1020
struct SmartAction::@73::@174 summonVortex
struct SmartAction::@73::@93 threatPCT
struct SmartAction::@73::@157 power
uint32 speedInteger
Definition: SmartScriptMgr.h:1374
struct SmartAction::@73::@144 movementFlag
struct SmartAction::@73::@105 setInstanceData
struct SmartAction::@73::@115 moveRandom
struct SmartAction::@73::@146 RespawnTarget
uint32 index
Definition: SmartScriptMgr.h:1391
uint32 actionId
Definition: SmartScriptMgr.h:1356
uint32 despawnTime
Definition: SmartScriptMgr.h:1003
uint32 goRespawnTime
Definition: SmartScriptMgr.h:1180
struct SmartAction::@73::@155 goState
struct SmartAction::@73::@158 gameEventStop
uint32 factionID
Definition: SmartScriptMgr.h:751
struct SmartAction::@73::@77 faction
struct SmartAction::@73::@107 updateTemplate
SAIBool move
Definition: SmartScriptMgr.h:877
struct SmartAction::@73::@119 taxi
struct SmartAction::@73::@138 timedActionList
struct SmartAction::@73::@108 die
std::array< uint32, MAX_EQUIPMENT_ITEMS > slots
Definition: SmartScriptMgr.h:1105
uint32 movementType
Definition: SmartScriptMgr.h:1373
uint32 questID
Definition: SmartScriptMgr.h:806
uint32 bp3
Definition: SmartScriptMgr.h:1341
uint32 pathID
Definition: SmartScriptMgr.h:1016
struct SmartAction::@73::@132 movie
uint32 emote
Definition: SmartScriptMgr.h:796
struct SmartAction::@73::@76 simpleTalk
struct SmartAction::@73::@161 combatDistance
uint32 id
Definition: SmartScriptMgr.h:1010
uint32 minId
Definition: SmartScriptMgr.h:1290
uint32 phase
Definition: SmartScriptMgr.h:882
uint32 sheath
Definition: SmartScriptMgr.h:959
struct SmartAction::@73::@81 music
uint32 isNegative
Definition: SmartScriptMgr.h:1357
struct SmartAction::@73::@187 orientationTarget
uint32 creditType
Definition: SmartScriptMgr.h:908
struct SmartAction::@73::@116 visibility
struct SmartAction::@73::@184 radialSummon
struct SmartAction::@73::@166 randomTimedEvent
struct SmartTarget::@189::@210 randomPoint
float o
Definition: SmartScriptMgr.h:1524
uint32 maxDist
Definition: SmartScriptMgr.h:1530
uint32 range
Definition: SmartScriptMgr.h:1650
float x
Definition: SmartScriptMgr.h:1524
uint32 self
Definition: SmartScriptMgr.h:1652
uint32 amount
Definition: SmartScriptMgr.h:1651
float y
Definition: SmartScriptMgr.h:1524
float z
Definition: SmartScriptMgr.h:1524
struct SmartTarget::@189::@193 unitRange
bool runOnce
Definition: SmartScriptMgr.h:1909
uint32 link
Definition: SmartScriptMgr.h:1895
uint32 event_id
Definition: SmartScriptMgr.h:1894
int32 entryOrGuid
Definition: SmartScriptMgr.h:1892
uint32 GetScriptType() const
Definition: SmartScriptMgr.h:1902
uint32 GetTargetType() const
Definition: SmartScriptMgr.h:1905
uint32 GetActionType() const
Definition: SmartScriptMgr.h:1904
float GetThreatListSize() const
Definition: ThreatMgr.h:222
void ModifyThreatByPercent(Unit *victim, int32 percent)
Definition: ThreatMgr.cpp:508
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:330
void Respawn(bool force=false)
Definition: Creature.cpp:1974
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition: Creature.cpp:2861
bool SetDisableGravity(bool disable, bool packetOnly=false, bool updateAnimationTier=true) override
Definition: Creature.cpp:3109
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:332
void LoadEquipment(int8 id=1, bool force=false)
Definition: Creature.cpp:1746
void SendZoneUnderAttackMessage(Player *attacker)
Send a message to LocalDefense channel for players opposition team in the zone.
Definition: Creature.cpp:2725
void SetRegeneratingHealth(bool c)
Definition: Creature.h:312
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:337
void SetReactState(ReactStates st)
Definition: Creature.h:90
float m_SightDistance
Definition: Creature.h:365
void DoFleeToGetAssistance()
Definition: Creature.cpp:997
float m_CombatDistance
Definition: Creature.h:365
void SetCorpseDelay(uint32 delay)
Definition: Creature.h:72
bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const
Definition: Creature.cpp:2749
Definition: CreatureData.h:349
uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]
Definition: CreatureData.h:350
Definition: GossipDef.h:258
void SendCloseGossip()
Definition: GossipDef.cpp:241
void SetGoState(GOState state)
Definition: GameObject.cpp:2477
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition: GameObject.cpp:1427
bool isSpawnedByDefault() const
Definition: GameObject.h:197
void SetLootState(LootState s, Unit *unit=nullptr)
Definition: GameObject.cpp:2442
GameObjectAI * AI() const
Definition: GameObject.h:310
void SetRespawnTime(int32 respawn)
Definition: GameObject.cpp:1301
GameobjectTypes GetGoType() const
Definition: GameObject.h:205
void Respawn()
Definition: GameObject.cpp:1316
void SendCustomAnim(uint32 anim)
Definition: GameObject.cpp:2141
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition: GameObject.cpp:930
void CastSpell(Unit *target, uint32 spell)
Definition: GameObject.cpp:2076
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:845
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:860
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:930
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:889
virtual void SetObjectScale(float scale)
Definition: Object.h:113
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
Unit * ToUnit()
Definition: Object.h:200
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:911
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition: Object.cpp:2343
Map * FindMap() const
Definition: Object.h:518
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1192
bool IsWithinLOSInMap(WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
Definition: Object.cpp:1347
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ=0, Position const *startPos=nullptr) const
Definition: Object.cpp:2614
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:2687
std::string const & GetName() const
Definition: Object.h:446
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
uint32 GetAreaId() const
Definition: Object.cpp:3108
uint32 GetZoneId() const
Definition: Object.cpp:3100
float GetObjectSize() const
Definition: Object.cpp:2759
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:2357
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1502
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition: Object.cpp:2420
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition: Object.cpp:2392
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
std::string ToString() const
Definition: ObjectGuid.cpp:47
Definition: Position.h:28
float m_positionZ
Definition: Position.h:58
float m_positionX
Definition: Position.h:56
float GetPositionZ() const
Definition: Position.h:119
float m_positionY
Definition: Position.h:57
float GetOrientation() const
Definition: Position.h:120
void SetOrientation(float orientation)
Definition: Position.h:112
float GetPositionX() const
Definition: Position.h:117
void GetPosition(float &x, float &y) const
Definition: Position.h:122
float GetPositionY() const
Definition: Position.h:118
void RelocatePolarOffset(float angle, float dist, float z=0.0f)
Definition: Position.cpp:33
float GetAngle(const Position *pos) const
Definition: Position.cpp:77
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition: PlayerQuest.cpp:1804
bool ActivateTaxiPathTo(std::vector< uint32 > const &nodes, Creature *npc=nullptr, uint32 spellid=1)
Definition: Player.cpp:10149
void SendCinematicStart(uint32 CinematicSequenceId) const
Definition: Player.cpp:5612
void Yell(std::string_view text, Language language, WorldObject const *=nullptr) override
Handles yelled message in regular chat based on declared language and in config pre-defined Range.
Definition: Player.cpp:9271
void Say(std::string_view text, Language language, WorldObject const *=nullptr) override
Handles said message in regular chat based on declared language and in config pre-defined Range.
Definition: Player.cpp:9251
void PrepareGossipMenu(WorldObject *source, uint32 menuId=0, bool showQuests=false)
Definition: PlayerGossip.cpp:31
PlayerMenu * PlayerTalkClass
Definition: Player.h:2201
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition: Player.cpp:12650
void SetVisible(bool x)
Definition: Unit.cpp:14220
uint8 getGender() const
Definition: Unit.h:1440
void SetFacingTo(float ori)
Definition: Unit.cpp:20884
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10440
float GetSpeed(UnitMoveType mtype) const
Definition: Unit.cpp:14409
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
Definition: Unit.cpp:13383
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true, bool bySelf=false)
Definition: Unit.cpp:4081
void RemoveAllGameObjects()
Definition: Unit.cpp:6201
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition: Unit.cpp:14639
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:10615
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:17956
void SetPower(Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
Definition: Unit.cpp:15552
MotionMaster * GetMotionMaster()
Definition: Unit.h:2276
void SetUnitMovementFlags(uint32 f)
Definition: Unit.h:2290
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:1226
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition: Unit.cpp:13575
void SetFacingToObject(WorldObject *object)
Definition: Unit.cpp:20894
bool IsAlive() const
Definition: Unit.h:1822
void StopMoving()
Definition: Unit.cpp:16918
void SendPlaySpellVisual(uint32 id)
Definition: Unit.cpp:19175
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5636
void AddUnitState(uint32 f)
Definition: Unit.h:1409
virtual void SetSheath(SheathState sheathed)
Definition: Unit.h:1506
void SetControlled(bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
Definition: Unit.cpp:18288
EventProcessor m_Events
Definition: Unit.h:2108
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2288
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1476
TransportBase * GetDirectTransport() const
Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)
Definition: Unit.cpp:19031
void SendMovementFlagUpdate(bool self=false)
Definition: Unit.cpp:16972
virtual bool SetHover(bool enable, bool packetOnly=false, bool updateAnimationTier=true)
Definition: Unit.cpp:21020
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:1169
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:14414
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:19020
bool IsAIEnabled
Definition: Unit.h:2364
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1410
float GetPowerPct(Powers power) const
Definition: Unit.h:1465
uint32 GetPower(Powers power) const
Definition: Unit.h:1475
void KillSelf(bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition: Unit.h:1565
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:20878
bool AttackStop()
Definition: Unit.cpp:10407
void SetImmuneToAll(bool apply, bool keepCombat=false)
Definition: Unit.h:1692
bool isDead() const
Definition: Unit.h:1824
void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:19992
Definition: Vehicle.h:30
Definition: VehicleDefines.h:107
static uint32 ChooseDisplayId(CreatureTemplate const *cinfo, CreatureData const *data=nullptr)
Definition: ObjectMgr.cpp:1726
virtual bool SetBossState(uint32 id, EncounterState state)
Definition: InstanceScript.cpp:350
virtual void DoAction(int32)
Definition: InstanceScript.h:263
static std::string GetBossStateName(uint8 state)
Definition: InstanceScript.cpp:743
void LoadGrid(float x, float y)
Definition: Map.cpp:492
PlayerList const & GetPlayers() const
Definition: Map.h:485
Definition: MapRefMgr.h:26
iterator begin()
Definition: MapRefMgr.h:36
iterator end()
Definition: MapRefMgr.h:37
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:53
virtual void SetGuidData(uint32, ObjectGuid)
Definition: ZoneScript.h:46
void MoveChase(Unit *target, std::optional< ChaseRange > dist={}, std::optional< ChaseAngle > angle={})
Definition: MotionMaster.cpp:300
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:859
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:394
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition: MotionMaster.h:211
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=0)
Definition: MotionMaster.h:227
void MoveIdle()
Definition: MotionMaster.cpp:232
void MoveFall(uint32 id=0, bool addFlagForNPC=false)
Definition: MotionMaster.cpp:587
void MoveFleeing(Unit *enemy, uint32 time=0)
Definition: MotionMaster.cpp:699
void MoveRandom(float wanderDistance=0.0f)
Definition: MotionMaster.cpp:239
Definition: QuestDef.h:207
Player session in the World.
Definition: WorldSession.h:330
Definition: SpellAuras.h:87
Definition: SpellDefines.h:162
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: SpellDefines.h:164
float GetMinRange(bool positive=false) const
Definition: SpellInfo.cpp:2300
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:1974
float GetMaxRange(bool positive=false, Unit *caster=nullptr, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:2309
Definition: ChatTextBuilder.h:31

References SmartScriptHolder::action, SmartAction::activateObject, EventProcessor::AddEventAtOffset(), Unit::AddThreat(), Creature::AI(), SmartAction::aliveState, SmartAction::alternative, SmartTarget::amount, SmartAction::angle, SmartAction::attack, SmartAction::attackInvoker, SmartAction::attackScriptOwner, UnitAI::AttackStart(), AURA_REMOVE_BY_EXPIRE, SmartAction::autoAttack, MapRefMgr::begin(), BROADCAST_TEXT_CALL_FOR_HELP, BROADCAST_TEXT_FLEE_FOR_ASSIST, SmartAction::callHelp, SmartAction::cast, CAST_AI, SmartAction::castFlags, Unit::CastSpell(), GameObject::CastSpell(), SmartAction::charges, CHAT_MSG_ADDON, CHAT_MSG_MONSTER_EMOTE, ObjectMgr::ChooseDisplayId(), SmartAction::combatMove, Unit::CombatStop(), SmartAction::ContactDistance, SmartAction::controlled, SmartAction::count, SmartAction::counterId, SmartAction::creature, SmartAction::credit, SmartAction::creditType, SmartAction::data, SmartAction::dec, DecPhase(), SmartAction::delay, GameObject::DespawnOrUnsummon(), SmartAction::despawnTime, SmartAction::die, SmartAction::directAdd, SmartAction::disableGravity, SmartAction::dist, SmartAction::distance, Creature::DoFleeToGetAssistance(), SmartAction::duration, SmartAction::emote, SmartAction::emotes, MapRefMgr::end(), SmartAction::entry, SmartScriptHolder::entryOrGuid, SmartScriptHolder::event, SmartEvent::event_chance, SmartAction::faction, SmartAction::factionID, SmartAction::fail, SmartAction::field, WorldObject::FindMap(), SmartAction::flag, SmartAction::flags, SmartAction::flee, SmartAction::fly, SmartAction::follow, SmartAction::forceDespawn, SmartAction::forceRespawnTimer, frand(), GAMEOBJECT_TYPE_DOOR, SmartScriptHolder::GetActionType(), WorldObject::GetAreaId(), GetBaseObject(), InstanceScript::GetBossStateName(), GetCasterActualDist(), GetCasterMaxDist(), GetCasterPowerType(), Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), WorldObject::GetClosePoint(), Unit::GetDirectTransport(), Object::GetEntry(), SmartScriptHolder::GetEventType(), Unit::getGender(), GameObject::GetGoType(), Object::GetGUID(), Creature::GetHomePosition(), WorldObject::GetInstanceScript(), GetLastInvoker(), Creature::GetLootRecipient(), WorldObject::GetMap(), GetMaxCombatDist(), Unit::GetMaxPower(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldObject::GetObjectSize(), Position::GetOrientation(), ObjectAccessor::GetPlayer(), Map::GetPlayers(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetPower(), Unit::GetPowerPct(), WorldObject::GetRandomPoint(), SpellInfo::GetSchoolMask(), SmartScriptHolder::GetScriptType(), Unit::GetSpeed(), GetTargets(), SmartScriptHolder::GetTargetType(), ThreatMgr::GetThreatList(), ThreatMgr::GetThreatListSize(), Unit::GetThreatMgr(), Unit::GetTransGUID(), Creature::GetTransportHomePosition(), ObjectAccessor::GetUnit(), Unit::GetVehicleKit(), GetWorldObjectsInDist(), WorldObject::GetZoneId(), go, GO_READY, Player::GroupEventHappens(), Unit::HasAura(), EnumFlag< T >::HasFlag(), Object::HasFlag(), Unit::HasUnitMovementFlag(), Unit::HasUnitState(), SmartAction::id, SmartAction::inc, SmartAction::incEventPhase, IncPhase(), SmartAction::ingamePhaseMask, InstallTemplate(), Unit::InterruptNonMeleeSpells(), SmartAction::invincHP, IsCreature(), Unit::isDead(), Map::IsDungeon(), LinkedListHead::IsEmpty(), IsGameObject(), IsPlayer(), IsSmart(), Creature::IsSpellProhibited(), IsUnit(), SmartAction::item, Unit::Kill(), SmartAction::killedMonster, Unit::KillSelf(), LANG_ADDON, LANG_UNIVERSAL, LOG_DEBUG, LOG_ERROR, Unit::m_Events, Position::m_positionX, Position::m_positionY, Position::m_positionZ, SmartAction::mapID, SmartAction::mask, SmartTarget::maxDist, me, SmartAction::milliseconds, SmartAction::minHP, mLastInvoker, mLastTextID, SmartAction::model, ThreatMgr::ModifyThreatByPercent(), SmartAction::morphOrMount, MOTION_SLOT_ACTIVE, MOTION_SLOT_CONTROLLED, SmartAction::move, MOVE_RUN, MOVEMENTFLAG_ONTRANSPORT, MotionMaster::MovePoint(), SmartAction::moveRandom, SmartAction::moveToPos, SmartAction::movie, mTalkerEntry, mTextTimer, mUseTextTimer, SmartAction::music, SmartTarget::o, SmartAction::onlySelf, SmartAction::orientation, SmartAction::pathID, SmartAction::percent, SmartAction::phase, SmartAction::phaseMax, SmartAction::phaseMin, SmartAction::phases, SmartAction::pointId, POWER_MANA, SmartAction::quest, SmartAction::questID, SmartAction::questOffer, SmartAction::quickChange, SmartAction::random, SmartAction::randomEmote, SmartAction::randomMusic, SmartAction::randomPhase, SmartAction::randomPhaseRange, SmartTarget::randomPoint, Acore::Containers::RandomResize(), SmartAction::randomSound, SmartAction::range, SmartTarget::range, SmartAction::react, SmartAction::reactState, SmartAction::removeAura, SmartAction::repeat, SmartAction::reset, RestoreCasterMaxDist(), Player::RewardPlayerAndGroupAtEvent(), SmartAction::run, SmartScriptHolder::runOnce, sCreatureTextMgr, Acore::Containers::SelectRandomContainerElement(), SmartTarget::self, PlayerMenu::SendQuestGiverQuestDetails(), SmartAction::setActive, SetActualCombatDist(), InstanceScript::SetBossState(), SetCasterActualDist(), SmartAction::setCounter, SmartAction::setData, ZoneScript::SetData(), Creature::SetDisableGravity(), SmartAction::setEventPhase, Unit::SetFacingTo(), Unit::SetFacingToObject(), SmartAction::setFly, ZoneScript::SetGuidData(), Unit::SetInCombatWith(), Unit::SetInFront(), SmartAction::setInstanceData, SmartAction::setInstanceData64, SmartAI::SetInvincibilityHpLevel(), GameObject::SetLootState(), Position::SetOrientation(), SetPhase(), Creature::SetReactState(), SmartAction::setRun, SmartAction::setSheath, Unit::SetSheath(), Unit::SetSpeed(), SmartAction::setSwim, SmartAction::sheath, SmartAction::simpleTalk, SMART_ACTION_ACTIVATE_GOBJECT, SMART_ACTION_ADD_AURA, SMART_ACTION_ADD_ITEM, SMART_ACTION_ALLOW_COMBAT_MOVEMENT, SMART_ACTION_ATTACK_START, SMART_ACTION_ATTACK_STOP, SMART_ACTION_AUTO_ATTACK, SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS, SMART_ACTION_CALL_FOR_HELP, SMART_ACTION_CALL_GROUPEVENTHAPPENS, SMART_ACTION_CALL_KILLEDMONSTER, SMART_ACTION_CAST, SMART_ACTION_COMBAT_STOP, SMART_ACTION_DIE, SMART_ACTION_EVADE, SMART_ACTION_FAIL_QUEST, SMART_ACTION_FLEE_FOR_ASSIST, SMART_ACTION_FOLLOW, SMART_ACTION_FORCE_DESPAWN, SMART_ACTION_INC_EVENT_PHASE, SMART_ACTION_INSTALL_AI_TEMPLATE, SMART_ACTION_INVOKER_CAST, SMART_ACTION_KILL_UNIT, SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL, SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL, SMART_ACTION_MOVE_FORWARD, SMART_ACTION_MOVE_TO_POS, SMART_ACTION_MUSIC, SMART_ACTION_OFFER_QUEST, SMART_ACTION_PLAY_EMOTE, SMART_ACTION_PLAYMOVIE, SMART_ACTION_RANDOM_EMOTE, SMART_ACTION_RANDOM_MUSIC, SMART_ACTION_RANDOM_PHASE, SMART_ACTION_RANDOM_PHASE_RANGE, SMART_ACTION_RANDOM_SOUND, SMART_ACTION_REMOVE_ITEM, SMART_ACTION_REMOVE_UNIT_FLAG, SMART_ACTION_REMOVEAURASFROMSPELL, SMART_ACTION_RESET_GOBJECT, SMART_ACTION_RISE_UP, SMART_ACTION_SELF_CAST, SMART_ACTION_SET_ACTIVE, SMART_ACTION_SET_COUNTER, SMART_ACTION_SET_DATA, SMART_ACTION_SET_EMOTE_STATE, SMART_ACTION_SET_EVENT_PHASE, SMART_ACTION_SET_FACTION, SMART_ACTION_SET_FLY, SMART_ACTION_SET_IN_COMBAT_WITH_ZONE, SMART_ACTION_SET_INGAME_PHASE_MASK, SMART_ACTION_SET_INST_DATA, SMART_ACTION_SET_INST_DATA64, SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL, SMART_ACTION_SET_ORIENTATION, SMART_ACTION_SET_REACT_STATE, SMART_ACTION_SET_RUN, SMART_ACTION_SET_SHEATH, SMART_ACTION_SET_SWIM, SMART_ACTION_SET_UNIT_FLAG, SMART_ACTION_SET_VISIBILITY, SMART_ACTION_SIMPLE_TALK, SMART_ACTION_SOUND, SMART_ACTION_STORE_TARGET_LIST, SMART_ACTION_SUMMON_CREATURE, SMART_ACTION_SUMMON_GO, SMART_ACTION_TALK, SMART_ACTION_TELEPORT, SMART_ACTION_THREAT_ALL_PCT, SMART_ACTION_THREAT_SINGLE_PCT, SMART_ACTION_UPDATE_TEMPLATE, SMART_ACTION_WP_PAUSE, SMART_ACTION_WP_RESUME, SMART_ACTION_WP_START, SMART_ACTION_WP_STOP, SMART_ESCORT_TARGETS, SMART_EVENT_MANA_PCT, SMART_EVENT_WAYPOINT_REACHED, SMART_RANDOM_POINT, SMART_SCRIPT_TYPE_AREATRIGGER, SMART_TARGET_NONE, SMART_TARGET_POSITION, SMART_TARGET_RANDOM_POINT, SMART_TARGET_SELF, SMARTCAST_AURA_NOT_PRESENT, SMARTCAST_COMBAT_MOVE, SMARTCAST_INTERRUPT_PREVIOUS, SMARTCAST_TARGET_POWER_MANA, SMARTCAST_THREATLIST_NOT_SINGLE, SMARTCAST_TRIGGERED, sObjectMgr, SmartAction::sound, SmartAction::sound1, SmartAction::sound2, SmartAction::sound3, SmartAction::sound4, SmartAction::speed, SmartAction::spell, sSpellMgr, SmartAction::state, StoreCounter(), StoreTargetList(), SmartAction::storeTargets, SmartAction::subtract, SmartAction::summonCreature, WorldObject::SummonCreature(), WorldObject::SummonGameObject(), SmartAction::summonGO, WorldObject::SummonTrigger(), SmartAction::swim, SmartAction::talk, SmartScriptHolder::target, SmartAction::targetsLimit, SmartAction::targetsummon, TEAM_NEUTRAL, SmartAction::teleport, TEXT_RANGE_NORMAL, SmartAction::textGroupID, SmartAction::threatDEC, SmartAction::threatINC, SmartAction::threatPCT, Object::ToCreature(), Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), SmartAction::transport, trigger, TRIGGERED_FULL_MASK, TRIGGERED_NONE, SmartAction::triggerFlags, SmartAction::turnAngle, SmartAction::type, SmartTarget::type, UNIT_FIELD_FLAGS, UNIT_FIELD_FLAGS_2, UNIT_FLAG_SILENCED, UNIT_NPC_EMOTESTATE, UNIT_STATE_LOST_CONTROL, SmartAction::unitFlag, SmartTarget::unitRange, SmartAction::updateLevel, SmartAction::updateTemplate, urand(), GameObject::UseDoorOrButton(), SmartAction::useTalkTarget, SmartAction::value, SmartAction::visibility, SmartAction::withEmote, SmartAction::wpPause, SmartAction::wpStart, SmartAction::wpStop, SmartTarget::x, SmartTarget::y, and SmartTarget::z.

Referenced by ProcessEvent(), and ProcessTimedAction().

◆ ProcessEvent()

void SmartScript::ProcessEvent ( SmartScriptHolder e,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
3752{
3753 if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
3754 return;
3755
3757 return;
3758
3760 return;
3761
3762 switch (e.GetEventType())
3763 {
3764 case SMART_EVENT_LINK://special handling
3765 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3766 break;
3767 //called from Update tick
3768 case SMART_EVENT_UPDATE:
3770 break;
3772 if (me && me->IsEngaged())
3773 return;
3775 break;
3777 if (!me || !me->IsEngaged())
3778 return;
3780 break;
3782 {
3783 if (!me || !me->IsEngaged() || !me->GetMaxHealth())
3784 return;
3785 uint32 perc = (uint32)me->GetHealthPct();
3786 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
3787 return;
3789 break;
3790 }
3792 {
3793 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxHealth())
3794 return;
3795 uint32 perc = (uint32)me->GetVictim()->GetHealthPct();
3796 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
3797 return;
3799 break;
3800 }
3802 {
3803 if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
3804 return;
3806 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
3807 return;
3809 break;
3810 }
3812 {
3813 if (!me || !me->IsEngaged() || !me->GetVictim() || !me->GetVictim()->GetMaxPower(POWER_MANA))
3814 return;
3816 if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
3817 return;
3819 break;
3820 }
3821 case SMART_EVENT_RANGE:
3822 {
3823 if (!me || !me->IsEngaged() || !me->GetVictim())
3824 return;
3825
3828 else
3829 RecalcTimer(e, 1200, 1200); // make it predictable
3830
3831 break;
3832 }
3834 {
3835 if (!me || !me->IsEngaged())
3836 return;
3837
3838 Unit* victim = me->GetVictim();
3839
3840 if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
3841 return;
3842
3843 if (e.event.targetCasting.spellId > 0)
3844 if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
3845 if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
3846 return;
3847
3849 break;
3850 }
3852 {
3853 if (!me || !me->IsEngaged())
3854 return;
3855
3857 if (!target || !target->IsInCombat())
3858 {
3859 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
3860 RecalcTimer(e, 1000, 3000);
3861 return;
3862 }
3864 break;
3865 }
3867 {
3868 if (!me || !me->IsEngaged())
3869 return;
3870
3871 std::vector<Creature*> creatures;
3873 if (creatures.empty())
3874 {
3875 // Xinef: if there are at least two same npcs, they will perform the same action immediately even if this is useless...
3876 RecalcTimer(e, 1000, 3000);
3877 return;
3878 }
3880 break;
3881 }
3883 {
3885 {
3886 return;
3887 }
3888
3889 std::vector<Creature*> creatures;
3891
3892 if (creatures.empty())
3893 return;
3894
3896 break;
3897 }
3899 {
3900 if (!me)
3901 return;
3902 uint32 count = me->GetAuraCount(e.event.aura.spell);
3903 if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
3905 break;
3906 }
3908 {
3909 if (!me || !me->GetVictim())
3910 return;
3912 if (count < e.event.aura.count)
3913 return;
3915 break;
3916 }
3918 {
3919 if (bvar == (e.event.charm.onRemove != 1))
3920 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3921 break;
3922 }
3923 //no params
3924 case SMART_EVENT_AGGRO:
3925 case SMART_EVENT_DEATH:
3926 case SMART_EVENT_EVADE:
3939 case SMART_EVENT_RESET:
3943 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3944 break;
3945
3947 switch (e.event.gossipHello.filter)
3948 {
3949 case 0:
3950 // no filter set, always execute action
3951 break;
3952 case 1:
3953 // GossipHello only filter set, skip action if reportUse
3954 if (var0)
3955 {
3956 return;
3957 }
3958 break;
3959 case 2:
3960 // reportUse only filter set, skip action if GossipHello
3961 if (!var0)
3962 {
3963 return;
3964 }
3965 break;
3966 default:
3967 // Ignore any other value
3968 break;
3969 }
3970
3971 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3972 break;
3974 {
3975 if (!me)
3976 return;
3977
3978 if (Unit* victim = me->GetVictim())
3979 {
3981 if (!victim->HasInArc(static_cast<float>(M_PI), me))
3983 }
3984
3985 break;
3986 }
3988 if (e.event.emote.emote == var0)
3989 {
3990 ProcessAction(e, unit);
3991 RecalcTimer(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax);
3992 }
3993 break;
3994 case SMART_EVENT_KILL:
3995 {
3996 if (!me || !unit)
3997 return;
3998 if (e.event.kill.playerOnly && unit->GetTypeId() != TYPEID_PLAYER)
3999 return;
4000 if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
4001 return;
4003 ProcessAction(e, unit);
4004 break;
4005 }
4008 {
4009 if (!spell)
4010 return;
4011 if ((!e.event.spellHit.spell || spell->Id == e.event.spellHit.spell) &&
4012 (!e.event.spellHit.school || (spell->SchoolMask & e.event.spellHit.school)))
4013 {
4015 ProcessAction(e, unit, 0, 0, bvar, spell);
4016 }
4017 break;
4018 }
4020 {
4021 if (!me || me->IsEngaged())
4022 return;
4023 //can trigger if closer than fMaxAllowedRange
4024 float range = (float)e.event.los.maxDist;
4025
4026 //if range is ok and we are actually in LOS
4027 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4028 {
4030 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4031 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4032 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4033 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4034 {
4035 if (e.event.los.playerOnly && unit->GetTypeId() != TYPEID_PLAYER)
4036 return;
4038 ProcessAction(e, unit);
4039 }
4040 }
4041 break;
4042 }
4043 case SMART_EVENT_IC_LOS:
4044 {
4045 if (!me || !me->IsEngaged())
4046 return;
4047 //can trigger if closer than fMaxAllowedRange
4048 float range = (float)e.event.los.maxDist;
4049
4050 //if range is ok and we are actually in LOS
4051 if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
4052 {
4054 //if friendly event&&who is not hostile OR hostile event&&who is hostile
4055 if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
4056 (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
4057 (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
4058 {
4059 if (e.event.los.playerOnly && unit->GetTypeId() != TYPEID_PLAYER)
4060 return;
4062 ProcessAction(e, unit);
4063 }
4064 }
4065 break;
4066 }
4068 {
4069 if (!GetBaseObject())
4070 return;
4072 return;
4074 return;
4075 ProcessAction(e);
4076 break;
4077 }
4080 {
4081 if (!IsCreature(unit))
4082 return;
4083 if (e.event.summoned.creature && unit->GetEntry() != e.event.summoned.creature)
4084 return;
4086 ProcessAction(e, unit);
4087 break;
4088 }
4092 {
4093 if (var0 > e.event.minMaxRepeat.max || var0 < e.event.minMaxRepeat.min)
4094 return;
4096 ProcessAction(e, unit);
4097 break;
4098 }
4100 {
4101 if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
4102 return;
4103 ProcessAction(e, unit, var0, var1);
4104 break;
4105 }
4108 {
4109 if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
4110 return;
4111 ProcessAction(e, unit, var0);
4112 break;
4113 }
4119 {
4120 if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
4121 return;
4122 ProcessAction(e, unit);
4123 break;
4124 }
4126 {
4127 if (e.event.summoned.creature && e.event.summoned.creature != var0)
4128 return;
4130 ProcessAction(e, unit, var0);
4131 break;
4132 }
4134 {
4136 return;
4138 ProcessAction(e, unit, var0);
4139 break;
4140 }
4143 {
4144 if (e.event.quest.quest && var0 != e.event.quest.quest)
4145 return;
4146 RecalcTimer(e, e.event.quest.cooldownMin, e.event.quest.cooldownMax);
4147 ProcessAction(e, unit, var0);
4148 break;
4149 }
4151 {
4153 return;
4154 ProcessAction(e, unit, var0);
4155 break;
4156 }
4158 {
4159 if (e.event.areatrigger.id && var0 != e.event.areatrigger.id)
4160 return;
4161 ProcessAction(e, unit, var0);
4162 break;
4163 }
4165 {
4167 return;
4168 ProcessAction(e, unit, var0);
4169 break;
4170 }
4172 {
4173 if (e.event.dataSet.id != var0 || e.event.dataSet.value != var1)
4174 return;
4176 ProcessAction(e, unit, var0, var1);
4177 break;
4178 }
4181 {
4182 if (!unit)
4183 return;
4185 ProcessAction(e, unit);
4186 break;
4187 }
4189 {
4190 if (e.event.timedEvent.id == var0)
4191 ProcessAction(e, unit);
4192 break;
4193 }
4195 {
4196 LOG_DEBUG("sql.sql", "SmartScript: Gossip Select: menu {} action {}", var0, var1); //little help for scripters
4197 if (e.event.gossip.sender != var0 || e.event.gossip.action != var1)
4198 return;
4199 ProcessAction(e, unit, var0, var1);
4200 break;
4201 }
4203 {
4205 {
4206 return;
4207 }
4208
4210 break;
4211 }
4214 {
4215 if (e.event.gameEvent.gameEventId != var0)
4216 return;
4217 ProcessAction(e, nullptr, var0);
4218 break;
4219 }
4221 {
4222 if (e.event.goStateChanged.state != var0)
4223 return;
4224 ProcessAction(e, unit, var0, var1);
4225 break;
4226 }
4228 {
4229 if (e.event.eventInform.eventId != var0)
4230 return;
4231 ProcessAction(e, nullptr, var0);
4232 break;
4233 }
4235 {
4236 if (e.event.doAction.eventId != var0)
4237 return;
4238 ProcessAction(e, unit, var0);
4239 break;
4240 }
4242 {
4243 if (!me || !me->IsEngaged())
4244 return;
4245
4246 Unit* unitTarget = nullptr;
4247 switch (e.GetTargetType())
4248 {
4256 {
4257 ObjectVector targets;
4258 GetTargets(targets, e);
4259 for (WorldObject* target : targets)
4260 {
4261 if (IsUnit(target) && me->IsFriendlyTo(target->ToUnit()) && target->ToUnit()->IsAlive() && target->ToUnit()->IsInCombat())
4262 {
4263 uint32 healthPct = uint32(target->ToUnit()->GetHealthPct());
4264 if (healthPct > e.event.friendlyHealthPct.hpPct)
4265 {
4266 continue;
4267 }
4268
4269 unitTarget = target->ToUnit();
4270 break;
4271 }
4272 }
4273
4274 break;
4275 }
4276 case SMART_TARGET_SELF:
4279 break;
4280 default:
4281 return;
4282 }
4283
4284 if (!unitTarget)
4285 return;
4286
4288 break;
4289 }
4291 {
4292 if (!me)
4293 return;
4294
4295 WorldObject* creature = nullptr;
4296
4297 if (e.event.distance.guid != 0)
4298 {
4299 creature = FindCreatureNear(me, e.event.distance.guid);
4300
4301 if (!creature)
4302 return;
4303
4304 if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
4305 return;
4306 }
4307 else if (e.event.distance.entry != 0)
4308 {
4309 std::list<Creature*> list;
4311
4312 if (!list.empty())
4313 creature = list.front();
4314 }
4315
4316 if (creature)
4318
4319 break;
4320 }
4322 {
4323 if (!me)
4324 return;
4325
4326 WorldObject* gameobject = nullptr;
4327
4328 if (e.event.distance.guid != 0)
4329 {
4330 gameobject = FindGameObjectNear(me, e.event.distance.guid);
4331
4332 if (!gameobject)
4333 return;
4334
4335 if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
4336 return;
4337 }
4338 else if (e.event.distance.entry != 0)
4339 {
4340 std::list<GameObject*> list;
4342
4343 if (!list.empty())
4344 gameobject = list.front();
4345 }
4346
4347 if (gameobject)
4349
4350 break;
4351 }
4353 if (e.event.counter.id != var0 || GetCounterValue(e.event.counter.id) != e.event.counter.value)
4354 return;
4355
4357 break;
4359 {
4360 uint32 playerCount = 0;
4361 ObjectVector targets;
4362 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayer.radius));
4363
4364 if (!targets.empty())
4365 {
4366 for (WorldObject* target : targets)
4367 {
4368 if (IsPlayer(target))
4369 playerCount++;
4370
4371 if (playerCount >= e.event.nearPlayer.minCount)
4372 ProcessAction(e, target->ToUnit());
4373 }
4374 }
4376 break;
4377 }
4379 {
4380 uint32 playerCount = 0;
4381 ObjectVector targets;
4382 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearPlayerNegation.radius));
4383
4384 if (!targets.empty())
4385 {
4386 for (WorldObject* target : targets)
4387 {
4388 if (IsPlayer(target))
4389 playerCount++;
4390 }
4391
4392 if (playerCount < e.event.nearPlayerNegation.maxCount)
4393 ProcessAction(e, unit);
4394 }
4396 break;
4397 }
4399 {
4400 uint32 unitCount = 0;
4401 ObjectVector targets;
4402 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnit.range));
4403
4404 if (!targets.empty())
4405 {
4406 if (e.event.nearUnit.type)
4407 {
4408 for (WorldObject* target : targets)
4409 {
4410 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnit.entry)
4411 unitCount++;
4412 }
4413 }
4414 else
4415 {
4416 for (WorldObject* target : targets)
4417 {
4418 if (IsCreature(target) && target->GetEntry() == e.event.nearUnit.entry)
4419 unitCount++;
4420 }
4421 }
4422
4423 if (unitCount >= e.event.nearUnit.count)
4424 ProcessAction(e, unit);
4425 }
4427 break;
4428 }
4430 {
4431 uint32 unitCount = 0;
4432 ObjectVector targets;
4433 GetWorldObjectsInDist(targets, static_cast<float>(e.event.nearUnitNegation.range));
4434
4435 if (!targets.empty())
4436 {
4438 {
4439 for (WorldObject* target : targets)
4440 {
4441 if (IsGameObject(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4442 unitCount++;
4443 }
4444 }
4445 else
4446 {
4447 for (WorldObject* target : targets)
4448 {
4449 if (IsCreature(target) && target->GetEntry() == e.event.nearUnitNegation.entry)
4450 unitCount++;
4451 }
4452 }
4453
4454 if (unitCount < e.event.nearUnitNegation.count)
4455 ProcessAction(e, unit);
4456 }
4458 break;
4459 }
4461 {
4462 if (!me || !me->IsEngaged())
4463 return;
4464
4466 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4467 {
4468 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4469 {
4470 if (!target || !IsPlayer(target) || !target->IsNonMeleeSpellCast(false, false, true))
4471 continue;
4472
4473 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4474 continue;
4475
4476 ProcessAction(e, target);
4478 return;
4479 }
4480
4481 // If no targets are found and it's off cooldown, check again in 1200ms
4482 RecalcTimer(e, 1200, 1200);
4483 break;
4484 }
4485
4486 break;
4487 }
4489 {
4490 if (!me || !me->IsEngaged())
4491 return;
4492
4494 for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
4495 {
4496 if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
4497 {
4498 if (!(me->IsInRange(target, (float)e.event.minMaxRepeat.rangeMin, (float)e.event.minMaxRepeat.rangeMax)))
4499 continue;
4500
4501 ProcessAction(e, target);
4503 return;
4504 }
4505 }
4506
4507 // If no targets are found and it's off cooldown, check again
4508 RecalcTimer(e, 1200, 1200);
4509 break;
4510 }
4511 default:
4512 LOG_ERROR("sql.sql", "SmartScript::ProcessEvent: Unhandled Event type {}", e.GetEventType());
4513 break;
4514 }
4515}
@ SMART_EVENT_FLAG_WHILE_CHARMED
Definition: SmartScriptMgr.h:1856
@ SMART_SCRIPT_RESPAWN_CONDITION_AREA
Definition: SmartScriptMgr.h:532
@ SMART_SCRIPT_RESPAWN_CONDITION_MAP
Definition: SmartScriptMgr.h:531
@ SMART_EVENT_EVADE
Definition: SmartScriptMgr.h:125
@ SMART_EVENT_ACTION_DONE
Definition: SmartScriptMgr.h:190
@ SMART_EVENT_SUMMON_DESPAWNED
Definition: SmartScriptMgr.h:153
@ SMART_EVENT_SPELLHIT
Definition: SmartScriptMgr.h:126
@ SMART_EVENT_RECEIVE_EMOTE
Definition: SmartScriptMgr.h:140
@ SMART_EVENT_QUEST_FAIL
Definition: SmartScriptMgr.h:169
@ SMART_EVENT_RECEIVE_HEAL
Definition: SmartScriptMgr.h:171
@ SMART_EVENT_CHARMED_TARGET
Definition: SmartScriptMgr.h:148
@ SMART_EVENT_TARGET_MANA_PCT
Definition: SmartScriptMgr.h:136
@ SMART_EVENT_QUEST_COMPLETION
Definition: SmartScriptMgr.h:167
@ SMART_EVENT_HEALTH_PCT
Definition: SmartScriptMgr.h:120
@ SMART_EVENT_EVENT_PHASE_CHANGE
Definition: SmartScriptMgr.h:184
@ SMART_EVENT_AREATRIGGER_ONTRIGGER
Definition: SmartScriptMgr.h:164
@ SMART_EVENT_ON_SPELLCLICK
Definition: SmartScriptMgr.h:191
@ SMART_EVENT_PASSENGER_REMOVED
Definition: SmartScriptMgr.h:146
@ SMART_EVENT_INSTANCE_PLAYER_ENTER
Definition: SmartScriptMgr.h:163
@ SMART_EVENT_WAYPOINT_PAUSED
Definition: SmartScriptMgr.h:173
@ SMART_EVENT_REACHED_HOME
Definition: SmartScriptMgr.h:139
@ SMART_EVENT_TRANSPORT_ADDCREATURE
Definition: SmartScriptMgr.h:160
@ SMART_EVENT_REWARD_QUEST
Definition: SmartScriptMgr.h:138
@ SMART_EVENT_GO_EVENT_INFORM
Definition: SmartScriptMgr.h:189
@ SMART_EVENT_JUST_SUMMONED
Definition: SmartScriptMgr.h:172
@ SMART_EVENT_CHARMED
Definition: SmartScriptMgr.h:147
@ SMART_EVENT_WAYPOINT_START
Definition: SmartScriptMgr.h:157
@ SMART_EVENT_SPELLHIT_TARGET
Definition: SmartScriptMgr.h:149
@ SMART_EVENT_GAME_EVENT_START
Definition: SmartScriptMgr.h:186
@ SMART_EVENT_KILL
Definition: SmartScriptMgr.h:123
@ SMART_EVENT_TRANSPORT_REMOVE_PLAYER
Definition: SmartScriptMgr.h:161
@ SMART_EVENT_GOSSIP_HELLO
Definition: SmartScriptMgr.h:182
@ SMART_EVENT_GOSSIP_SELECT
Definition: SmartScriptMgr.h:180
@ SMART_EVENT_CORPSE_REMOVED
Definition: SmartScriptMgr.h:154
@ SMART_EVENT_PASSENGER_BOARDED
Definition: SmartScriptMgr.h:145
@ SMART_EVENT_TRANSPORT_ADDPLAYER
Definition: SmartScriptMgr.h:159
@ SMART_EVENT_WAYPOINT_ENDED
Definition: SmartScriptMgr.h:176
@ SMART_EVENT_ACCEPTED_QUEST
Definition: SmartScriptMgr.h:137
@ SMART_EVENT_COUNTER_SET
Definition: SmartScriptMgr.h:195
@ SMART_EVENT_FRIENDLY_MISSING_BUFF
Definition: SmartScriptMgr.h:134
@ SMART_EVENT_WAYPOINT_RESUMED
Definition: SmartScriptMgr.h:174
@ SMART_EVENT_TARGET_BUFFED
Definition: SmartScriptMgr.h:142
@ SMART_EVENT_RESPAWN
Definition: SmartScriptMgr.h:129
@ SMART_EVENT_QUEST_ACCEPTED
Definition: SmartScriptMgr.h:165
@ SMART_EVENT_FRIENDLY_HEALTH
Definition: SmartScriptMgr.h:132
@ SMART_EVENT_QUEST_REWARDED
Definition: SmartScriptMgr.h:168
@ SMART_EVENT_DEATH
Definition: SmartScriptMgr.h:124
@ SMART_EVENT_TRANSPORT_RELOCATE
Definition: SmartScriptMgr.h:162
@ SMART_EVENT_GAME_EVENT_END
Definition: SmartScriptMgr.h:187
@ SMART_EVENT_DAMAGED
Definition: SmartScriptMgr.h:150
@ SMART_EVENT_FOLLOW_COMPLETED
Definition: SmartScriptMgr.h:183
@ SMART_EVENT_QUEST_OBJ_COMPLETION
Definition: SmartScriptMgr.h:166
@ SMART_EVENT_WAYPOINT_STOPPED
Definition: SmartScriptMgr.h:175
@ SMART_EVENT_SUMMONED_UNIT_DIES
Definition: SmartScriptMgr.h:202
@ SMART_EVENT_FRIENDLY_IS_CC
Definition: SmartScriptMgr.h:133
@ SMART_EVENT_AGGRO
Definition: SmartScriptMgr.h:122
@ SMART_EVENT_TARGET_HEALTH_PCT
Definition: SmartScriptMgr.h:130
@ SMART_EVENT_VICTIM_CASTING
Definition: SmartScriptMgr.h:131
@ SMART_EVENT_DAMAGED_TARGET
Definition: SmartScriptMgr.h:151
@ SMART_EVENT_HAS_AURA
Definition: SmartScriptMgr.h:141
@ SMART_EVENT_SUMMONED_UNIT
Definition: SmartScriptMgr.h:135
@ CURRENT_GENERIC_SPELL
Definition: Unit.h:991
uint32 GetCounterValue(uint32 id)
Definition: SmartScript.h:149
void DoFindFriendlyMissingBuff(std::vector< Creature * > &creatures, float range, uint32 spellid) const
Definition: SmartScript.cpp:4951
void DoFindFriendlyCC(std::vector< Creature * > &creatures, float range) const
Definition: SmartScript.cpp:4941
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:119
static bool IsCharmedCreature(WorldObject *obj)
Definition: SmartScript.cpp:5034
uint32 GetPathId() const
Definition: SmartScript.h:53
Unit * DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) const
Definition: SmartScript.cpp:4914
bool IsInPhase(uint32 p) const
Definition: SmartScript.cpp:5080
Unit * DoSelectLowestHpPercentFriendly(float range, uint32 minHpPct, uint32 maxHpPct) const
Definition: SmartScript.cpp:4927
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:3047
struct SmartEvent::@30::@69 nearPlayerNegation
uint32 map
Definition: SmartScriptMgr.h:268
uint32 entry
Definition: SmartScriptMgr.h:459
struct SmartEvent::@30::@71 nearUnitNegation
struct SmartEvent::@30::@61 gameEvent
uint32 id
Definition: SmartScriptMgr.h:354
LOSHostilityMode
Definition: SmartScriptMgr.h:520
uint32 cooldownMax
Definition: SmartScriptMgr.h:240
struct SmartEvent::@30::@53 instancePlayerEnter
uint32 pointID
Definition: SmartScriptMgr.h:367
uint32 radius
Definition: SmartScriptMgr.h:288
uint32 maxDist
Definition: SmartScriptMgr.h:259
struct SmartEvent::@30::@51 transportAddCreature
uint32 sender
Definition: SmartScriptMgr.h:411
struct SmartEvent::@30::@45 aura
struct SmartEvent::@30::@57 gossipHello
uint32 school
Definition: SmartScriptMgr.h:248
uint32 rangeMin
Definition: SmartScriptMgr.h:233
uint32 eventId
Definition: SmartScriptMgr.h:438
struct SmartEvent::@30::@34 spellHit
struct SmartEvent::@30::@35 los
uint32 guid
Definition: SmartScriptMgr.h:458
struct SmartEvent::@30::@49 dataSet
uint32 dist
Definition: SmartScriptMgr.h:460
struct SmartEvent::@30::@48 movementInform
uint32 spellId
Definition: SmartScriptMgr.h:282
uint32 emote
Definition: SmartScriptMgr.h:325
uint32 hpPct
Definition: SmartScriptMgr.h:452
uint32 filter
Definition: SmartScriptMgr.h:406
uint32 hostilityMode
Hostility mode of the event. 0: hostile, 1: not hostile, 2: any.
Definition: SmartScriptMgr.h:258
uint32 hpDeficit
Definition: SmartScriptMgr.h:287
struct SmartEvent::@30::@33 kill
uint32 area
Definition: SmartScriptMgr.h:269
uint32 count
Definition: SmartScriptMgr.h:333
uint32 onlyInCombat
Definition: SmartScriptMgr.h:306
struct SmartEvent::@30::@41 missingBuff
struct SmartEvent::@30::@50 waypoint
uint32 value
Definition: SmartScriptMgr.h:360
struct SmartEvent::@30::@42 summoned
uint32 pathID
Definition: SmartScriptMgr.h:368
SAIBool playerOnly
Definition: SmartScriptMgr.h:241
struct SmartEvent::@30::@54 areatrigger
struct SmartEvent::@30::@60 eventPhaseChange
uint32 creatureEntry
Definition: SmartScriptMgr.h:396
struct SmartEvent::@30::@65 friendlyHealthPct
struct SmartEvent::@30::@58 gossip
uint32 action
Definition: SmartScriptMgr.h:412
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:247
uint32 maxCount
Definition: SmartScriptMgr.h:483
uint32 gameEventId
Definition: SmartScriptMgr.h:428
uint32 textGroupID
Definition: SmartScriptMgr.h:395
uint32 cooldownMin
Definition: SmartScriptMgr.h:239
uint32 onRemove
Definition: SmartScriptMgr.h:340
uint32 quest
Definition: SmartScriptMgr.h:318
struct SmartEvent::@30::@67 counter
uint32 state
Definition: SmartScriptMgr.h:433
struct SmartEvent::@30::@36 respawn
struct SmartEvent::@30::@56 timedEvent
struct SmartEvent::@30::@39 friendlyHealth
uint32 rangeMax
Definition: SmartScriptMgr.h:234
uint32 team
Definition: SmartScriptMgr.h:383
uint32 range
Definition: SmartScriptMgr.h:495
uint32 minCount
Definition: SmartScriptMgr.h:474
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:242
uint32 phasemask
Definition: SmartScriptMgr.h:423
void GetGameObjectListWithEntryInGrid(std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition: Object.cpp:2481
void GetCreatureListWithEntryInGrid(std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
Definition: Object.cpp:2488
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1321
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition: Position.cpp:140
float GetHealthPct() const
Definition: Unit.h:1462
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:4051
uint32 GetMaxHealth() const
Definition: Unit.h:1455
uint32 GetAuraCount(uint32 spellId) const
Definition: Unit.cpp:5620
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10249
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:10244
bool IsInCombat() const
Definition: Unit.h:1702
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:2075
Definition: Spell.h:284

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

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 
)
101{
102 for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
103 {
104 SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
105 if (eventType == SMART_EVENT_LINK)//special handling
106 continue;
107
108 if (eventType == e)
109 {
110 ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
111 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
112
113 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
114 ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
115 }
116 }
117}
#define sConditionMgr
Definition: ConditionMgr.h:289
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:236
Definition: ConditionMgr.h:181

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

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

◆ ProcessTimedAction()

void SmartScript::ProcessTimedAction ( SmartScriptHolder e,
uint32 const &  min,
uint32 const &  max,
Unit unit = nullptr,
uint32  var0 = 0,
uint32  var1 = 0,
bool  bvar = false,
SpellInfo const *  spell = nullptr,
GameObject gob = nullptr 
)
3048{
3049 // xinef: extended by selfs victim
3050 ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
3051 ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject(), me ? me->GetVictim() : nullptr);
3052
3053 if (sConditionMgr->IsObjectMeetToConditions(info, conds))
3054 {
3055 ProcessAction(e, unit, var0, var1, bvar, spell, gob);
3056 RecalcTimer(e, min, max);
3057 }
3058 else
3059 RecalcTimer(e, 5000, 5000);
3060}

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

Referenced by ProcessEvent().

◆ RecalcTimer()

void SmartScript::RecalcTimer ( SmartScriptHolder e,
uint32  min,
uint32  max 
)
static
4550{
4551 // min/max was checked at loading!
4552 e.timer = urand(uint32(min), uint32(max));
4553 e.active = e.timer ? false : true;
4554}
uint32 timer
Definition: SmartScriptMgr.h:1907

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

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

◆ RemoveCreatureSummon()

void SmartScript::RemoveCreatureSummon ( ObjectGuid const &  guid)
5096{
5097 _summonList.erase(guid);
5098}

References _summonList.

Referenced by SmartAI::SummonedCreatureDespawn().

◆ RemoveStoredEvent()

void SmartScript::RemoveStoredEvent ( uint32  id)
inlineprivate
284 {
285 if (!mStoredEvents.empty())
286 {
287 for (SmartAIEventStoredList::iterator i = mStoredEvents.begin(); i != mStoredEvents.end(); ++i)
288 {
289 if (i->event_id == id)
290 {
291 mStoredEvents.erase(i);
292 return;
293 }
294 }
295 }
296 }

References mStoredEvents.

Referenced by OnUpdate().

◆ ResetBaseObject()

void SmartScript::ResetBaseObject ( )
inline
182 {
183 WorldObject* lookupRoot = me;
184 if (!lookupRoot)
185 lookupRoot = go;
186
187 if (lookupRoot)
188 {
189 if (meOrigGUID)
190 {
191 if (Creature* m = ObjectAccessor::GetCreature(*lookupRoot, meOrigGUID))
192 {
193 me = m;
194 go = nullptr;
195 }
196 }
197
198 if (goOrigGUID)
199 {
201 {
202 me = nullptr;
203 go = o;
204 }
205 }
206 }
207
210 }
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:187
Creature * GetCreature(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:213

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

Referenced by OnReset().

◆ RestoreCasterMaxDist()

void SmartScript::RestoreCasterMaxDist ( )
inline

◆ RestoreMaxCombatDist()

void SmartScript::RestoreMaxCombatDist ( )
inline

References mActualCombatDist, and mMaxCombatDist.

Referenced by OnReset().

◆ SetActualCombatDist()

void SmartScript::SetActualCombatDist ( uint32  dist)
inline
220{ mActualCombatDist = dist; }

References mActualCombatDist.

Referenced by ProcessAction().

◆ SetCasterActualDist()

void SmartScript::SetCasterActualDist ( float  dist)
inline
226{ smartCasterActualDist = dist; }

References smartCasterActualDist.

Referenced by ProcessAction().

◆ SetPathId()

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

References mPathId.

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

◆ SetPhase()

void SmartScript::SetPhase ( uint32  p)
private
5069{
5070 uint32 oldPhase = mEventPhase;
5071
5072 mEventPhase = p;
5073
5074 if (oldPhase != mEventPhase)
5075 {
5077 }
5078}

References mEventPhase, ProcessEventsFor(), and SMART_EVENT_EVENT_PHASE_CHANGE.

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

◆ SetPhaseReset()

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

References _allowPhaseReset.

◆ SetScript9()

void SmartScript::SetScript9 ( SmartScriptHolder e,
uint32  entry 
)
4974{
4975 //do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
4976 // any SmartScriptHolder contained like the "e" parameter passed to this function
4978 {
4979 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());
4980 return;
4981 }
4982
4983 // 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
4985 {
4986 return;
4987 }
4988
4989 mTimedActionList.clear();
4991 if (mTimedActionList.empty())
4992 return;
4993 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4994 {
4995 i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
4996
4997 if (e.action.timedActionList.timerType == 0)
4998 i->event.type = SMART_EVENT_UPDATE_OOC;
4999 else if (e.action.timedActionList.timerType == 1)
5000 i->event.type = SMART_EVENT_UPDATE_IC;
5001 else if (e.action.timedActionList.timerType > 1)
5002 i->event.type = SMART_EVENT_UPDATE;
5003
5004 InitTimer((*i));
5005 }
5006}
@ SMART_SCRIPT_TYPE_TIMED_ACTIONLIST
Definition: SmartScriptMgr.h:1702
SAIBool allowOverride
Definition: SmartScriptMgr.h:1135
uint32 timerType
Definition: SmartScriptMgr.h:1134

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

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

◆ StoreCounter()

void SmartScript::StoreCounter ( uint32  id,
uint32  value,
uint32  reset,
uint32  subtract 
)
inline
124 {
125 CounterMap::iterator itr = mCounterList.find(id);
126 if (itr != mCounterList.end())
127 {
128 if (!reset && !subtract)
129 {
130 itr->second += value;
131 }
132 else if (subtract)
133 {
134 itr->second -= value;
135 }
136 else
137 {
138 itr->second = value;
139 }
140 }
141 else
142 {
143 mCounterList.insert(std::make_pair(id, value));
144 }
145
147 }

References mCounterList, ProcessEventsFor(), and SMART_EVENT_COUNTER_SET.

Referenced by ProcessAction().

◆ StoreTargetList()

void SmartScript::StoreTargetList ( ObjectVector const &  targets,
uint32  id 
)
inline
80 {
81 // insert or replace
82 _storedTargets.erase(id);
83 _storedTargets.emplace(id, ObjectGuidVector(targets));
84 }
Definition: SmartScriptMgr.h:1918

References _storedTargets.

Referenced by ProcessAction().

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)
4557{
4558 if (e.GetEventType() == SMART_EVENT_LINK)
4559 return;
4560
4562 return;
4563
4564 if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsEngaged()))
4565 return;
4566
4567 if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsEngaged()))//can be used with me=nullptr (go script)
4568 return;
4569
4570 if (e.timer < diff)
4571 {
4572 // delay spell cast for another AI tick if another spell is being cast
4574 {
4576 {
4578 {
4579 e.timer = 1200;
4580 return;
4581 }
4582 }
4583 }
4584
4585 // Delay flee for assist event if casting
4587 {
4588 e.timer = 1200;
4589 return;
4590 } // @TODO: Can't these be handled by the action themselves instead? Less expensive
4591
4592 e.active = true;//activate events with cooldown
4593 switch (e.GetEventType())//process ONLY timed events
4594 {
4599 case SMART_EVENT_UPDATE:
4606 case SMART_EVENT_RANGE:
4619 {
4620 ProcessEvent(e);
4622 {
4623 e.enableTimed = false;//disable event if it is in an ActionList and was processed once
4624 for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
4625 {
4626 //find the first event which is not the current one and enable it
4627 if (i->event_id > e.event_id)
4628 {
4629 i->enableTimed = true;
4630 break;
4631 }
4632 }
4633 }
4634 break;
4635 }
4636 }
4637 }
4638 else
4639 e.timer -= diff;
4640}
@ UNIT_STATE_CASTING
Definition: Unit.h:340
bool enableTimed
Definition: SmartScriptMgr.h:1910

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

Referenced by OnUpdate().

Member Data Documentation

◆ _allowPhaseReset

bool SmartScript::_allowPhaseReset
private

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

◆ _summonList

GuidUnorderedSet SmartScript::_summonList
private

◆ go

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Referenced by ResetBaseObject().

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

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

◆ mActualCombatDist

uint32 SmartScript::mActualCombatDist
private

◆ mCounterList

CounterMap SmartScript::mCounterList

◆ me

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Referenced by ResetBaseObject().

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

◆ mEvents

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Referenced by AddEvent(), and InstallEvents().

◆ mLastInvoker

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

◆ mMaxCombatDist

uint32 SmartScript::mMaxCombatDist
private

◆ mPathId

uint32 SmartScript::mPathId
private

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

◆ mRemIDs

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

Referenced by OnUpdate().

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

◆ mStoredDecimals

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

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

Referenced by OnUpdate(), and RemoveStoredEvent().

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

◆ mTemplate

SMARTAI_TEMPLATE SmartScript::mTemplate
private

Referenced by InstallTemplate(), and SmartScript().

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

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

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

◆ smartCasterActualDist

uint32 SmartScript::smartCasterActualDist
private

◆ smartCasterMaxDist

uint32 SmartScript::smartCasterMaxDist
private

◆ smartCasterPowerType

Powers SmartScript::smartCasterPowerType
private

◆ trigger

AreaTrigger const* SmartScript::trigger
private