18 #ifndef TRINITY_SMARTSCRIPT_H
19 #define TRINITY_SMARTSCRIPT_H
52 SmartScriptHolder CreateEvent(
SMART_EVENT e,
uint32 event_flags,
uint32 event_param1,
uint32 event_param2,
uint32 event_param3,
uint32 event_param4,
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 phaseMask = 0);
53 void AddEvent(
SMART_EVENT e,
uint32 event_flags,
uint32 event_param1,
uint32 event_param2,
uint32 event_param3,
uint32 event_param4,
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 phaseMask = 0);
86 void OnUpdate(
const uint32 diff);
87 void OnMoveInLineOfSight(
Unit* who);
89 Unit* DoSelectLowestHpFriendly(
float range,
uint32 MinHPDiff);
90 void DoFindFriendlyCC(std::list<Creature*>& _list,
float range);
91 void DoFindFriendlyMissingBuff(std::list<Creature*>& list,
float range,
uint32 spellid);
92 Unit* DoFindClosestFriendlyInRange(
float range,
bool playerOnly);
99 if (mTargetStorage->find(
id) != mTargetStorage->end())
102 if ((*mTargetStorage)[id]->Equals(targets))
105 delete (*mTargetStorage)[id];
108 (*mTargetStorage)[id] =
new ObjectGuidList(targets, GetBaseObject());
114 if (c && c->GetAIName() !=
"SmartAI")
117 if (!me || me->GetAIName() !=
"SmartAI")
121 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target Creature (GUID: " UI64FMTD " Entry: %u) is not using SmartAI, action called by Creature (GUID: " UI64FMTD " Entry: %u) skipped to prevent crash.",
uint64(c ? c->GetSpawnId() :
UI64LIT(0)), c ? c->GetEntry() : 0,
uint64(me ? me->GetSpawnId() :
UI64LIT(0)), me ? me->GetEntry() : 0);
129 if (g && g->GetAIName() !=
"SmartGameObjectAI")
132 if (!go || go->GetAIName() !=
"SmartGameObjectAI")
135 TC_LOG_ERROR(
"sql.sql",
"SmartScript: Action target GameObject (GUID: " UI64FMTD " Entry: %u) is not using SmartGameObjectAI, action called by GameObject (GUID: " UI64FMTD " Entry: %u) skipped to prevent crash.",
uint64(g ? g->GetSpawnId() :
UI64LIT(0)), g ? g->GetEntry() : 0,
uint64(go ? go->GetSpawnId() :
UI64LIT(0)), go ? go->GetEntry() : 0);
142 ObjectListMap::iterator itr = mTargetStorage->find(
id);
143 if (itr != mTargetStorage->end())
144 return (*itr).second->GetObjectList();
150 CounterMap::const_iterator itr = mCounterList.find(
id);
151 if (itr != mCounterList.end())
154 value += GetCounterValue(
id);
155 mCounterList.erase(
id);
158 mCounterList.insert(std::make_pair(
id, value));
164 CounterMap::iterator itr = mCounterList.find(
id);
165 if (itr != mCounterList.end())
172 CounterMap::iterator itr = mCounterList.find(
id);
173 if (itr != mCounterList.end())
181 if (bounds.first == bounds.second)
184 return bounds.first->second;
190 if (bounds.first == bounds.second)
193 auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type
const& pair)
195 return pair.second->IsAlive();
198 return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
212 if (!meOrigGUID.IsEmpty())
220 if (!goOrigGUID.IsEmpty())
235 Unit* GetLastInvoker();
251 if (mEventPhase > (
uint32)p)
282 void InstallEvents();
286 if (!mStoredEvents.empty())
288 for (SmartAIEventList::iterator i = mStoredEvents.begin(); i != mStoredEvents.end(); ++i)
290 if (i->event_id ==
id)
292 mStoredEvents.erase(i);
void ResetBaseObject()
Definition: SmartScript.h:204
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
SmartScriptType
Definition: SmartScriptMgr.h:1208
uint32 mLastTextID
Definition: SmartScript.h:277
uint32 mEventPhase
Definition: SmartScript.h:270
void StoreTargetList(ObjectList *targets, uint32 id)
Definition: SmartScript.h:94
SmartAIEventList mTimedActionList
Definition: SmartScript.h:262
Map * GetMap() const
Definition: Object.h:543
WorldObject * GetBaseObject()
Definition: SmartScript.h:56
Definition: SpellInfo.h:326
CounterMap mCounterList
Definition: SmartScript.h:238
std::unordered_map< uint32, uint32 > CounterMap
Definition: SmartScript.h:237
std::vector< SmartScriptHolder > SmartAIEventList
Definition: SmartScriptMgr.h:1468
SmartAIEventList mStoredEvents
Definition: SmartScript.h:273
ObjectListMap * mTargetStorage
Definition: SmartScript.h:201
SmartScriptType mScriptType
Definition: SmartScript.h:269
Definition: SmartScriptMgr.h:181
AreaTriggerEntry const * trigger
Definition: SmartScript.h:268
bool isProcessingTimedActionList
Definition: SmartScript.h:263
uint32 mTextTimer
Definition: SmartScript.h:276
bool IsSmart(Creature *c=NULL)
Definition: SmartScript.h:111
#define UI64LIT(N)
Definition: Define.h:138
Definition: ObjectGuid.h:32
bool IsInPhase(uint32 p) const
Definition: SmartScript.h:257
arena_t NULL
Definition: jemalloc_internal.h:624
SMART_ACTION
Definition: SmartScriptMgr.h:437
Definition: SmartScriptMgr.h:1393
void DecPhase(int32 p=1)
Definition: SmartScript.h:249
SMARTAI_TEMPLATE
Definition: SmartScriptMgr.h:1060
uint64_t uint64
Definition: g3dmath.h:170
Definition: Creature.h:467
uint64 LowType
Definition: ObjectGuid.h:199
T max(const T &x, const T &y)
Definition: g3dmath.h:320
bool IsPlayer(WorldObject *obj)
Definition: SmartScript.h:71
TypeID GetTypeId() const
Definition: Object.h:113
std::list< WorldObject * > ObjectList
Definition: SmartScriptMgr.h:1391
T min(const T &x, const T &y)
Definition: g3dmath.h:305
void IncPhase(int32 p=1)
Definition: SmartScript.h:241
ObjectGuid meOrigGUID
Definition: SmartScript.h:265
ObjectGuid mLastInvoker
Definition: SmartScript.h:236
bool IsSmartGO(GameObject *g=NULL)
Definition: SmartScript.h:126
SMARTAI_TEMPLATE mTemplate
Definition: SmartScript.h:281
#define UI64FMTD
Definition: Define.h:137
Definition: ObjectGuid.h:34
int32_t int32
Definition: Define.h:146
SMART_EVENT
Definition: SmartScriptMgr.h:102
uint32_t uint32
Definition: Define.h:150
void SetPathId(uint32 id)
Definition: SmartScript.h:54
void RemoveStoredEvent(uint32 id)
Definition: SmartScript.h:284
Definition: GameObject.h:880
bool IsGameObject(WorldObject *obj)
Definition: SmartScript.h:81
std::unordered_map< uint32, ObjectGuidList * > ObjectListMap
Definition: SmartScriptMgr.h:1443
GameObject * go
Definition: SmartScript.h:266
void StoreCounter(uint32 id, uint32 value, uint32 reset)
Definition: SmartScript.h:148
uint32 mTalkerEntry
Definition: SmartScript.h:278
GameObject * FindGameObjectNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:178
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
uint32 mPathId
Definition: SmartScript.h:272
uint32 GetPathId() const
Definition: SmartScript.h:55
Definition: ObjectGuid.h:33
#define TC_GAME_API
Definition: Define.h:134
bool IsUnit(WorldObject *obj)
Definition: SmartScript.h:66
void SetPhase(uint32 p=0)
Definition: SmartScript.h:258
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:143
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:469
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:472
ObjectGuid goOrigGUID
Definition: SmartScript.h:267
uint32 GetCounterId(uint32 id)
Definition: SmartScript.h:162
Definition: DBCStructure.h:74
uint32 GetCounterValue(uint32 id)
Definition: SmartScript.h:170
const FieldDescriptor value
Definition: descriptor.h:1522
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
Definition: SmartScriptMgr.h:1361
SmartAIEventList mEvents
Definition: SmartScript.h:260
uint32_t uint32
Definition: g3dmath.h:168
SmartAIEventList mInstallEvents
Definition: SmartScript.h:261
Creature * FindCreatureNear(WorldObject *searchObject, ObjectGuid::LowType guid) const
Definition: SmartScript.h:187
bool IsCreature(WorldObject *obj)
Definition: SmartScript.h:76
Creature * me
Definition: SmartScript.h:264
bool mUseTextTimer
Definition: SmartScript.h:279
Definition: SmartScript.h:31
std::list< uint32 > mRemIDs
Definition: SmartScript.h:274
SMARTAI_TARGETS
Definition: SmartScriptMgr.h:1071
ObjectList * GetTargetList(uint32 id)
Definition: SmartScript.h:140