aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-11-11 11:03:32 +0100
committerSpp <spp@jorge.gr>2013-11-11 11:03:32 +0100
commit65cd07a288267861c684fe3e27bb6bc51f190d89 (patch)
tree113c32e5fbd8b3b6d3d558408d41c0cfb3181881 /src/server/game/AI/SmartScripts
parent395eb83b88706692c52d5b596b8bc3a0f6e5ccc6 (diff)
Core: Improve error messages for linked_respawn table (and minor cosmetic changes here and there)
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp40
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h4
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h17
4 files changed, 32 insertions, 31 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index ae6719aa8f3..92637b17f25 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -56,7 +56,7 @@ class SmartAI : public CreatureAI
void EndPath(bool fail = false);
void ResumePath();
WayPoint* GetNextWayPoint();
- bool HasEscortState(uint32 uiEscortState) { return (mEscortState & uiEscortState); }
+ bool HasEscortState(uint32 uiEscortState) const { return (mEscortState & uiEscortState) != 0; }
void AddEscortState(uint32 uiEscortState) { mEscortState |= uiEscortState; }
void RemoveEscortState(uint32 uiEscortState) { mEscortState &= ~uiEscortState; }
void SetAutoAttack(bool on) { mCanAutoAttack = on; }
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 09f656e5bf1..d2d5027ce7d 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -168,12 +168,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
- if (IsCreature((*itr)) && !(*itr)->ToCreature()->IsPet()) // Prevented sending text to pets.
+ if (IsCreature(*itr) && !(*itr)->ToCreature()->IsPet()) // Prevented sending text to pets.
{
talker = (*itr)->ToCreature();
break;
}
- else if (IsPlayer((*itr)))
+ else if (IsPlayer(*itr))
{
targetPlayer = (*itr)->ToPlayer();
break;
@@ -542,17 +542,17 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsUnit(*itr))
continue;
- if (!(e.action.cast.flags & SMARTCAST_AURA_NOT_PRESENT) || !(*itr)->ToUnit()->HasAura(e.action.cast.spell))
- {
- if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
- tempLastInvoker->InterruptNonMeleeSpells(false);
+ if (!(e.action.cast.flags & SMARTCAST_AURA_NOT_PRESENT) || !(*itr)->ToUnit()->HasAura(e.action.cast.spell))
+ {
+ if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
+ tempLastInvoker->InterruptNonMeleeSpells(false);
- tempLastInvoker->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
- TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker %u casts spell %u on target %u with castflags %u",
- tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
- }
- else
- TC_LOG_DEBUG("scripts.ai", "Spell %u not casted 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()));
+ tempLastInvoker->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
+ TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker %u casts spell %u on target %u with castflags %u",
+ tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
+ }
+ else
+ TC_LOG_DEBUG("scripts.ai", "Spell %u not casted 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()));
}
delete targets;
@@ -784,13 +784,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
- if (!IsUnit((*itr)))
+ if (!IsUnit(*itr))
continue;
- if (e.action.removeAura.spell == 0)
- (*itr)->ToUnit()->RemoveAllAuras();
- else
+ if (e.action.removeAura.spell)
(*itr)->ToUnit()->RemoveAurasDueToSpell(e.action.removeAura.spell);
+ else
+ (*itr)->ToUnit()->RemoveAllAuras();
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit %u, spell %u",
(*itr)->GetGUIDLow(), e.action.removeAura.spell);
@@ -810,7 +810,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
- if (IsUnit((*itr)))
+ if (IsUnit(*itr))
{
CAST_AI(SmartAI, me->AI())->SetFollow((*itr)->ToUnit(), (float)e.action.follow.dist, (float)e.action.follow.angle, e.action.follow.credit, e.action.follow.entry, e.action.follow.creditType);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_FOLLOW: Creature %u following target %u",
@@ -1674,6 +1674,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsUnit(*itr))
continue;
+ Unit* unit = (*itr)->ToUnit();
+
bool interruptedSpell = false;
for (ObjectList::const_iterator it = targets->begin(); it != targets->end(); ++it)
@@ -1685,11 +1687,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (!interruptedSpell && e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
{
- (*itr)->ToUnit()->InterruptNonMeleeSpells(false);
+ unit->InterruptNonMeleeSpells(false);
interruptedSpell = true;
}
- (*itr)->ToUnit()->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
+ unit->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
}
else
TC_LOG_DEBUG("scripts.ai", "Spell %u not casted 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()));
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index e320e122d0f..f9eff2ec96e 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -244,7 +244,7 @@ class SmartScript
SMARTAI_TEMPLATE mTemplate;
void InstallEvents();
- void RemoveStoredEvent (uint32 id)
+ void RemoveStoredEvent(uint32 id)
{
if (!mStoredEvents.empty())
{
@@ -258,7 +258,7 @@ class SmartScript
}
}
}
- SmartScriptHolder FindLinkedEvent (uint32 link)
+ SmartScriptHolder FindLinkedEvent(uint32 link)
{
if (!mEvents.empty())
{
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 9494d4e7734..35abdcc47f0 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -735,7 +735,7 @@ struct SmartAction
} summonGO;
struct
- {
+ {
uint32 state;
} active;
@@ -1280,9 +1280,9 @@ enum SmartCastFlags
{
SMARTCAST_INTERRUPT_PREVIOUS = 0x01, //Interrupt any spell casting
SMARTCAST_TRIGGERED = 0x02, //Triggered (this makes spell cost zero mana and have no cast time)
- //CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range
- //CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range
- //CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself
+ //SMARTCAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range
+ //SMARTCAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range
+ //SMARTCAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself
SMARTCAST_AURA_NOT_PRESENT = 0x20 //Only casts the spell if the target does not have an aura from the spell
};
@@ -1302,11 +1302,10 @@ struct SmartScriptHolder
SmartAction action;
SmartTarget target;
- public:
- uint32 GetScriptType() const { return (uint32)source_type; }
- uint32 GetEventType() const { return (uint32)event.type; }
- uint32 GetActionType() const { return (uint32)action.type; }
- uint32 GetTargetType() const { return (uint32)target.type; }
+ uint32 GetScriptType() const { return (uint32)source_type; }
+ uint32 GetEventType() const { return (uint32)event.type; }
+ uint32 GetActionType() const { return (uint32)action.type; }
+ uint32 GetTargetType() const { return (uint32)target.type; }
uint32 timer;
bool active;