diff options
Diffstat (limited to 'src/server/game/AI/SmartScripts')
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 16 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 6 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 37 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.h | 10 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 4 |
5 files changed, 35 insertions, 38 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 41f783f4289..bdad018c622 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -61,7 +61,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) mDespawnState = 0; mEscortInvokerCheckTimer = 1000; - mFollowGuid = 0; + mFollowGuid.Clear(); mFollowDist = 0; mFollowAngle = 0; mFollowCredit = 0; @@ -540,7 +540,7 @@ void SmartAI::JustRespawned() mJustReset = true; JustReachedHome(); GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN); - mFollowGuid = 0;//do not reset follower on Reset(), we need it after combat evade + mFollowGuid.Clear();//do not reset follower on Reset(), we need it after combat evade mFollowDist = 0; mFollowAngle = 0; mFollowCredit = 0; @@ -674,8 +674,8 @@ void SmartAI::OnCharmed(bool apply) { GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, NULL, 0, 0, apply); - if (!apply && !me->IsInEvadeMode() && me->GetUInt64Value(UNIT_FIELD_CHARMEDBY)) - if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetUInt64Value(UNIT_FIELD_CHARMEDBY))) + if (!apply && !me->IsInEvadeMode() && me->GetCharmerGUID()) + if (Unit* charmer = ObjectAccessor::GetUnit(*me, me->GetCharmerGUID())) AttackStart(charmer); } @@ -694,11 +694,11 @@ void SmartAI::SetData(uint32 id, uint32 value) GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value); } -void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/) { } +void SmartAI::SetGUID(ObjectGuid /*guid*/, int32 /*id*/) { } -uint64 SmartAI::GetGUID(int32 /*id*/) const +ObjectGuid SmartAI::GetGUID(int32 /*id*/) const { - return 0; + return ObjectGuid::Empty; } void SmartAI::SetRun(bool run) @@ -800,7 +800,7 @@ void SmartAI::StopFollow() player->GroupEventHappens(mFollowCredit, me); } - mFollowGuid = 0; + mFollowGuid.Clear(); mFollowDist = 0; mFollowAngle = 0; mFollowCredit = 0; diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index b0d5d4f8343..a5abf2a33e3 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -154,10 +154,10 @@ class SmartAI : public CreatureAI void SetData(uint32 id, uint32 value) override; // Used in scripts to share variables - void SetGUID(uint64 guid, int32 id = 0) override; + void SetGUID(ObjectGuid guid, int32 id = 0) override; // Used in scripts to share variables - uint64 GetGUID(int32 id = 0) const override; + ObjectGuid GetGUID(int32 id = 0) const override; //core related static int Permissible(const Creature*); @@ -199,7 +199,7 @@ class SmartAI : public CreatureAI uint32 mFollowArrivedTimer; uint32 mFollowCredit; uint32 mFollowArrivedEntry; - uint64 mFollowGuid; + ObjectGuid mFollowGuid; float mFollowDist; float mFollowAngle; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 1ec20830140..75fedb5bb57 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -51,9 +51,6 @@ SmartScript::SmartScript() mUseTextTimer = false; mTalkerEntry = 0; mTemplate = SMARTAI_TEMPLATE_BASIC; - meOrigGUID = 0; - goOrigGUID = 0; - mLastInvoker = 0; mScriptType = SMART_SCRIPT_TYPE_CREATURE; isProcessingTimedActionList = false; } @@ -79,7 +76,7 @@ void SmartScript::OnReset() } } ProcessEventsFor(SMART_EVENT_RESET); - mLastInvoker = 0; + mLastInvoker.Clear(); } void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob) @@ -509,10 +506,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u go->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) != 0); TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST:: %s: %u casts spell %u on target %u with castflags %u", - GetLogNameForGuid(me ? me->GetGUID() : go->GetGUID()), me ? me->GetGUIDLow() : go->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags); + (me ? me->GetGUID() : go->GetGUID()).GetTypeName(), me ? me->GetGUIDLow() : go->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags); } else - TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId())); + TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (%s) already has the aura", e.action.cast.spell, (*itr)->GetGUID().ToString().c_str()); } delete targets; @@ -543,7 +540,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags); } else - TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId())); + TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (%s) already has the aura", e.action.cast.spell, (*itr)->GetGUID().ToString().c_str()); } delete targets; @@ -939,9 +936,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!targets) break; - instance->SetData64(e.action.setInstanceData64.field, targets->front()->GetGUID()); - TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: " UI64FMTD, - e.action.setInstanceData64.field, targets->front()->GetGUID()); + instance->SetGuidData(e.action.setInstanceData64.field, targets->front()->GetGUID()); + TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: %s", + e.action.setInstanceData64.field, targets->front()->GetGUID().ToString().c_str()); delete targets; break; @@ -1558,20 +1555,20 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsCreature(*itr)) { - if (!meOrigGUID) - meOrigGUID = me ? me->GetGUID() : 0; - if (!goOrigGUID) - goOrigGUID = go ? go->GetGUID() : 0; + if (!meOrigGUID && me) + meOrigGUID = me->GetGUID(); + if (!goOrigGUID && go) + goOrigGUID = go->GetGUID(); go = NULL; me = (*itr)->ToCreature(); break; } else if (IsGameObject(*itr)) { - if (!meOrigGUID) - meOrigGUID = me ? me->GetGUID() : 0; - if (!goOrigGUID) - goOrigGUID = go ? go->GetGUID() : 0; + if (!meOrigGUID && me) + meOrigGUID = me->GetGUID(); + if (!goOrigGUID && go) + goOrigGUID = go->GetGUID(); go = (*itr)->ToGameObject(); me = NULL; break; @@ -1713,7 +1710,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u unit->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) != 0); } else - TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*it)->GetGUID(), (*it)->GetEntry(), uint32((*it)->GetTypeId())); + TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (%s) already has the aura", e.action.cast.spell, (*it)->GetGUID().ToString().c_str()); } } @@ -2627,7 +2624,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* { if (me) { - uint64 charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID(); + ObjectGuid charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID(); if (!charmerOrOwnerGuid) charmerOrOwnerGuid = me->GetCreatorGUID(); diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 0931756a026..9ff9e870eec 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -197,14 +197,14 @@ class SmartScript go = o; } } - goOrigGUID = 0; - meOrigGUID = 0; + goOrigGUID.Clear(); + meOrigGUID.Clear(); } //TIMED_ACTIONLIST (script type 9 aka script9) void SetScript9(SmartScriptHolder& e, uint32 entry); Unit* GetLastInvoker(); - uint64 mLastInvoker; + ObjectGuid mLastInvoker; private: void IncPhase(int32 p = 1) @@ -224,9 +224,9 @@ class SmartScript SmartAIEventList mTimedActionList; bool isProcessingTimedActionList; Creature* me; - uint64 meOrigGUID; + ObjectGuid meOrigGUID; GameObject* go; - uint64 goOrigGUID; + ObjectGuid goOrigGUID; AreaTriggerEntry const* trigger; SmartScriptType mScriptType; uint32 mEventPhase; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 296c3161845..83e9377d3ca 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1352,7 +1352,7 @@ struct SmartScriptHolder typedef std::unordered_map<uint32, WayPoint*> WPPath; typedef std::list<WorldObject*> ObjectList; -typedef std::list<uint64> GuidList; + class ObjectGuidList { ObjectList* m_objectList; @@ -1385,7 +1385,7 @@ public: if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr)) m_objectList->push_back(obj); else - TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr); + TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: %s", itr->ToString().c_str()); } } |
