TrinityCore
SmartScript Class Reference

#include <SmartScript.h>

Public Types

typedef std::unordered_map< uint32, uint32CounterMap
 

Public Member Functions

 SmartScript ()
 
 ~SmartScript ()
 
void OnInitialize (WorldObject *obj, AreaTriggerEntry const *at=nullptr, SceneTemplate const *scene=nullptr, Quest const *qst=nullptr, uint32 evnt=0)
 
void GetScript ()
 
void FillScript (SmartAIEventList e, WorldObject *obj, AreaTriggerEntry const *at, SceneTemplate const *scene, Quest const *quest, uint32 event=0)
 
void ProcessEventsFor (SMART_EVENT e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr, std::string const &varString="")
 
void ProcessEvent (SmartScriptHolder &e, Unit *unit=nullptr, uint32 var0=0, uint32 var1=0, bool bvar=false, SpellInfo const *spell=nullptr, GameObject *gob=nullptr, std::string const &varString="")
 
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, std::string const &varString="")
 
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, std::string const &varString="")
 
void GetTargets (ObjectVector &targets, SmartScriptHolder const &e, WorldObject *invoker=nullptr) const
 
void GetWorldObjectsInDist (ObjectVector &objects, float dist) const
 
void SetPathId (uint32 id)
 
uint32 GetPathId () const
 
WorldObjectGetBaseObject () const
 
WorldObjectGetBaseObjectOrUnitInvoker (Unit *invoker)
 
bool HasAnyEventWithFlag (uint32 flag) const
 
void OnUpdate (const uint32 diff)
 
void OnMoveInLineOfSight (Unit *who)
 
UnitDoSelectLowestHpFriendly (float range, uint32 MinHPDiff) const
 
UnitDoSelectLowestHpPercentFriendly (float range, uint32 minHpPct, uint32 maxHpPct) const
 
void DoFindFriendlyCC (std::vector< Creature * > &creatures, float range) const
 
void DoFindFriendlyMissingBuff (std::vector< Creature * > &creatures, float range, uint32 spellid) const
 
UnitDoFindClosestFriendlyInRange (float range, bool playerOnly) const
 
bool IsSmart (Creature *c, bool silent=false) const
 
bool IsSmart (GameObject *g, bool silent=false) const
 
bool IsSmart (bool silent=false) const
 
void StoreTargetList (ObjectVector const &targets, uint32 id)
 
void AddToStoredTargetList (ObjectVector const &targets, uint32 id)
 
ObjectVector const * GetStoredTargetVector (uint32 id, WorldObject const &ref) const
 
void StoreCounter (uint32 id, uint32 value, uint32 reset)
 
uint32 GetCounterValue (uint32 id) const
 
GameObjectFindGameObjectNear (WorldObject *searchObject, ObjectGuid::LowType guid) const
 
CreatureFindCreatureNear (WorldObject *searchObject, ObjectGuid::LowType guid) const
 
void OnReset ()
 
void ResetBaseObject ()
 
void SetTimedActionList (SmartScriptHolder &e, uint32 entry, Unit *invoker, uint32 startFromEventId=0)
 
UnitGetLastInvoker (Unit *invoker=nullptr) const
 

Static Public Member Functions

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

Public Attributes

ObjectGuid mLastInvoker
 
CounterMap mCounterList
 

Private Member Functions

void IncPhase (uint32 p)
 
void DecPhase (uint32 p)
 
void SetPhase (uint32 p)
 
bool IsInPhase (uint32 p) const
 
void SortEvents (SmartAIEventList &events)
 
void RaisePriority (SmartScriptHolder &e)
 
void RetryLater (SmartScriptHolder &e, bool ignoreChanceRoll=false)
 
void InstallEvents ()
 
void RemoveStoredEvent (uint32 id)
 

Private Attributes

SmartAIEventList mEvents
 
SmartAIEventList mInstallEvents
 
SmartAIEventList mTimedActionList
 
ObjectGuid mTimedActionListInvoker
 
bool isProcessingTimedActionList
 
Creatureme
 
ObjectGuid meOrigGUID
 
GameObjectgo
 
ObjectGuid goOrigGUID
 
Playerplayer
 
AreaTriggerEntry const * trigger
 
AreaTriggerareaTrigger
 
SceneTemplate const * sceneTemplate
 
Quest const * quest
 
uint32 event
 
SmartScriptType mScriptType
 
uint32 mEventPhase
 
uint32 mPathId
 
SmartAIEventStoredList mStoredEvents
 
std::vector< uint32mRemIDs
 
uint32 mTextTimer
 
uint32 mLastTextID
 
uint32 mTalkerEntry
 
bool mUseTextTimer
 
uint32 mCurrentPriority
 
bool mEventSortingRequired
 
uint32 mNestedEventsCounter
 
uint32 mAllEventFlags
 
ObjectVectorMap _storedTargets
 

Static Private Attributes

static constexpr uint32 MAX_NESTED_EVENTS = 10
 

Detailed Description

Definition at line 35 of file SmartScript.h.

Member Typedef Documentation

◆ CounterMap

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

Definition at line 96 of file SmartScript.h.

Constructor & Destructor Documentation

◆ SmartScript()

SmartScript::SmartScript ( )

Definition at line 48 of file SmartScript.cpp.

◆ ~SmartScript()

SmartScript::~SmartScript ( )

Definition at line 72 of file SmartScript.cpp.

Member Function Documentation

◆ AddToStoredTargetList()

void SmartScript::AddToStoredTargetList ( ObjectVector const &  targets,
uint32  id 
)

Definition at line 122 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ CheckTimer()

bool SmartScript::CheckTimer ( SmartScriptHolder const &  e) const

Definition at line 3706 of file SmartScript.cpp.

◆ 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,
SMART_ACTION  action,
uint32  action_param1,
uint32  action_param2,
uint32  action_param3,
uint32  action_param4,
uint32  action_param5,
uint32  action_param6,
uint32  action_param7,
SMARTAI_TARGETS  t,
uint32  target_param1,
uint32  target_param2,
uint32  target_param3,
uint32  target_param4,
uint32  phaseMask 
)
static

Definition at line 2550 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecPhase()

void SmartScript::DecPhase ( uint32  p)
private

Definition at line 4230 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoFindClosestFriendlyInRange()

Unit * SmartScript::DoFindClosestFriendlyInRange ( float  range,
bool  playerOnly 
) const

Definition at line 4163 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoFindFriendlyCC()

void SmartScript::DoFindFriendlyCC ( std::vector< Creature * > &  creatures,
float  range 
) const

Definition at line 4143 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoFindFriendlyMissingBuff()

void SmartScript::DoFindFriendlyMissingBuff ( std::vector< Creature * > &  creatures,
float  range,
uint32  spellid 
) const

Definition at line 4153 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoSelectLowestHpFriendly()

Unit * SmartScript::DoSelectLowestHpFriendly ( float  range,
uint32  MinHPDiff 
) const

Definition at line 4118 of file SmartScript.cpp.

+ Here is the call graph for this function:

◆ DoSelectLowestHpPercentFriendly()

Unit * SmartScript::DoSelectLowestHpPercentFriendly ( float  range,
uint32  minHpPct,
uint32  maxHpPct 
) const

Definition at line 4131 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FillScript()

void SmartScript::FillScript ( SmartAIEventList  e,
WorldObject obj,
AreaTriggerEntry const *  at,
SceneTemplate const *  scene,
Quest const *  quest,
uint32  event = 0 
)

Definition at line 3909 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindCreatureNear()

Creature * SmartScript::FindCreatureNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const

Definition at line 171 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindGameObjectNear()

GameObject * SmartScript::FindGameObjectNear ( WorldObject searchObject,
ObjectGuid::LowType  guid 
) const

Definition at line 162 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetBaseObject()

WorldObject * SmartScript::GetBaseObject ( ) const

Definition at line 3737 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ GetBaseObjectOrUnitInvoker()

WorldObject * SmartScript::GetBaseObjectOrUnitInvoker ( Unit invoker)

Definition at line 3751 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCounterValue()

uint32 SmartScript::GetCounterValue ( uint32  id) const

Definition at line 154 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ GetLastInvoker()

Unit * SmartScript::GetLastInvoker ( Unit invoker = nullptr) const

Definition at line 4212 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPathId()

uint32 SmartScript::GetPathId ( ) const
inline

Definition at line 57 of file SmartScript.h.

+ Here is the caller graph for this function:

◆ GetScript()

void SmartScript::GetScript ( )

Definition at line 3953 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetStoredTargetVector()

ObjectVector const * SmartScript::GetStoredTargetVector ( uint32  id,
WorldObject const &  ref 
) const

Definition at line 130 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ GetTargets()

void SmartScript::GetTargets ( ObjectVector targets,
SmartScriptHolder const &  e,
WorldObject invoker = nullptr 
) const

Definition at line 2583 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetWorldObjectsInDist()

void SmartScript::GetWorldObjectsInDist ( ObjectVector objects,
float  dist 
) const

Definition at line 2996 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasAnyEventWithFlag()

bool SmartScript::HasAnyEventWithFlag ( uint32  flag) const
inline

Definition at line 60 of file SmartScript.h.

◆ IncPhase()

void SmartScript::IncPhase ( uint32  p)
private

Definition at line 4224 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitTimer()

void SmartScript::InitTimer ( SmartScriptHolder e)
static

Definition at line 3583 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InstallEvents()

void SmartScript::InstallEvents ( )
private

Definition at line 3711 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ IsCharmedCreature()

bool SmartScript::IsCharmedCreature ( WorldObject obj)
static

Definition at line 3771 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsCreature()

bool SmartScript::IsCreature ( WorldObject obj)
static

Definition at line 3766 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsGameObject()

bool SmartScript::IsGameObject ( WorldObject obj)
static

Definition at line 3782 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInPhase()

bool SmartScript::IsInPhase ( uint32  p) const
private

Definition at line 4243 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ IsPlayer()

bool SmartScript::IsPlayer ( WorldObject obj)
static

Definition at line 3761 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsSmart() [1/3]

bool SmartScript::IsSmart ( bool  silent = false) const

Definition at line 106 of file SmartScript.cpp.

+ Here is the call graph for this function:

◆ IsSmart() [2/3]

bool SmartScript::IsSmart ( Creature c,
bool  silent = false 
) const

Definition at line 76 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsSmart() [3/3]

bool SmartScript::IsSmart ( GameObject g,
bool  silent = false 
) const

Definition at line 91 of file SmartScript.cpp.

+ Here is the call graph for this function:

◆ IsUnit()

bool SmartScript::IsUnit ( WorldObject obj)
static

Definition at line 3756 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnInitialize()

void SmartScript::OnInitialize ( WorldObject obj,
AreaTriggerEntry const *  at = nullptr,
SceneTemplate const *  scene = nullptr,
Quest const *  qst = nullptr,
uint32  evnt = 0 
)

Definition at line 3998 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnMoveInLineOfSight()

void SmartScript::OnMoveInLineOfSight ( Unit who)

Definition at line 4109 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnReset()

void SmartScript::OnReset ( )

Definition at line 185 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnUpdate()

void SmartScript::OnUpdate ( const uint32  diff)

Definition at line 3787 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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,
std::string const &  varString = "" 
)

Definition at line 266 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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,
std::string const &  varString = "" 
)

Definition at line 3007 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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,
std::string const &  varString = "" 
)

Definition at line 240 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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,
std::string const &  varString = "" 
)

Definition at line 2538 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RaisePriority()

void SmartScript::RaisePriority ( SmartScriptHolder e)
private

Definition at line 3887 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ RecalcTimer()

void SmartScript::RecalcTimer ( SmartScriptHolder e,
uint32  min,
uint32  max 
)
static

Definition at line 3602 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveStoredEvent()

void SmartScript::RemoveStoredEvent ( uint32  id)
private

Definition at line 3722 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ ResetBaseObject()

void SmartScript::ResetBaseObject ( )

Definition at line 206 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RetryLater()

void SmartScript::RetryLater ( SmartScriptHolder e,
bool  ignoreChanceRoll = false 
)
private

Definition at line 3898 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPathId()

void SmartScript::SetPathId ( uint32  id)
inline

Definition at line 56 of file SmartScript.h.

+ Here is the caller graph for this function:

◆ SetPhase()

void SmartScript::SetPhase ( uint32  p)
private

Definition at line 4238 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ SetTimedActionList()

void SmartScript::SetTimedActionList ( SmartScriptHolder e,
uint32  entry,
Unit invoker,
uint32  startFromEventId = 0 
)

Definition at line 4175 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SortEvents()

void SmartScript::SortEvents ( SmartAIEventList events)
private

Definition at line 3882 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ StoreCounter()

void SmartScript::StoreCounter ( uint32  id,
uint32  value,
uint32  reset 
)

Definition at line 138 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StoreTargetList()

void SmartScript::StoreTargetList ( ObjectVector const &  targets,
uint32  id 
)

Definition at line 115 of file SmartScript.cpp.

+ Here is the caller graph for this function:

◆ UpdateTimer()

void SmartScript::UpdateTimer ( SmartScriptHolder e,
uint32 const  diff 
)

Definition at line 3609 of file SmartScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _storedTargets

ObjectVectorMap SmartScript::_storedTargets
private

Definition at line 145 of file SmartScript.h.

◆ areaTrigger

AreaTrigger* SmartScript::areaTrigger
private

Definition at line 122 of file SmartScript.h.

◆ event

uint32 SmartScript::event
private

Definition at line 125 of file SmartScript.h.

◆ go

GameObject* SmartScript::go
private

Definition at line 118 of file SmartScript.h.

◆ goOrigGUID

ObjectGuid SmartScript::goOrigGUID
private

Definition at line 119 of file SmartScript.h.

◆ isProcessingTimedActionList

bool SmartScript::isProcessingTimedActionList
private

Definition at line 115 of file SmartScript.h.

◆ mAllEventFlags

uint32 SmartScript::mAllEventFlags
private

Definition at line 140 of file SmartScript.h.

◆ MAX_NESTED_EVENTS

constexpr uint32 SmartScript::MAX_NESTED_EVENTS = 10
staticconstexprprivate

Definition at line 143 of file SmartScript.h.

◆ mCounterList

CounterMap SmartScript::mCounterList

Definition at line 97 of file SmartScript.h.

◆ mCurrentPriority

uint32 SmartScript::mCurrentPriority
private

Definition at line 137 of file SmartScript.h.

◆ me

Creature* SmartScript::me
private

Definition at line 116 of file SmartScript.h.

◆ meOrigGUID

ObjectGuid SmartScript::meOrigGUID
private

Definition at line 117 of file SmartScript.h.

◆ mEventPhase

uint32 SmartScript::mEventPhase
private

Definition at line 127 of file SmartScript.h.

◆ mEvents

SmartAIEventList SmartScript::mEvents
private

Definition at line 111 of file SmartScript.h.

◆ mEventSortingRequired

bool SmartScript::mEventSortingRequired
private

Definition at line 138 of file SmartScript.h.

◆ mInstallEvents

SmartAIEventList SmartScript::mInstallEvents
private

Definition at line 112 of file SmartScript.h.

◆ mLastInvoker

ObjectGuid SmartScript::mLastInvoker

Definition at line 95 of file SmartScript.h.

◆ mLastTextID

uint32 SmartScript::mLastTextID
private

Definition at line 134 of file SmartScript.h.

◆ mNestedEventsCounter

uint32 SmartScript::mNestedEventsCounter
private

Definition at line 139 of file SmartScript.h.

◆ mPathId

uint32 SmartScript::mPathId
private

Definition at line 129 of file SmartScript.h.

◆ mRemIDs

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

Definition at line 131 of file SmartScript.h.

◆ mScriptType

SmartScriptType SmartScript::mScriptType
private

Definition at line 126 of file SmartScript.h.

◆ mStoredEvents

SmartAIEventStoredList SmartScript::mStoredEvents
private

Definition at line 130 of file SmartScript.h.

◆ mTalkerEntry

uint32 SmartScript::mTalkerEntry
private

Definition at line 135 of file SmartScript.h.

◆ mTextTimer

uint32 SmartScript::mTextTimer
private

Definition at line 133 of file SmartScript.h.

◆ mTimedActionList

SmartAIEventList SmartScript::mTimedActionList
private

Definition at line 113 of file SmartScript.h.

◆ mTimedActionListInvoker

ObjectGuid SmartScript::mTimedActionListInvoker
private

Definition at line 114 of file SmartScript.h.

◆ mUseTextTimer

bool SmartScript::mUseTextTimer
private

Definition at line 136 of file SmartScript.h.

◆ player

Player* SmartScript::player
private

Definition at line 120 of file SmartScript.h.

◆ quest

Quest const* SmartScript::quest
private

Definition at line 124 of file SmartScript.h.

◆ sceneTemplate

SceneTemplate const* SmartScript::sceneTemplate
private

Definition at line 123 of file SmartScript.h.

◆ trigger

AreaTriggerEntry const* SmartScript::trigger
private

Definition at line 121 of file SmartScript.h.


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