aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-06-15 19:36:30 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-06-15 19:36:30 +0200
commit26dd770b8e017eb1f95f67c37c2d1aa2d1bb9b44 (patch)
tree8cf9814bd92845d32d7dcd15c42b18f47f36c1f3 /src/server/game/AI
parent31c987ad8a585be66223b867171240d91ff1b519 (diff)
parente55835a6a9ae09dd4b65de494cba712c322a2419 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Entities/DynamicObject/DynamicObject.h src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Transport/Transport.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Entities/Vehicle/Vehicle.cpp src/server/game/Handlers/MovementHandler.cpp src/server/game/Server/WorldSession.cpp src/server/game/Spells/Spell.cpp src/server/scripts/Spells/spell_dk.cpp src/server/shared/Utilities/Util.cpp
Diffstat (limited to 'src/server/game/AI')
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp4
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp44
2 files changed, 27 insertions, 21 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index 7c640f9a66d..8032568434f 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -183,7 +183,11 @@ void PetAI::UpdateAI(uint32 diff)
}
if (spellInfo->HasEffect(SPELL_EFFECT_JUMP_DEST))
+ {
+ if (!spellUsed)
+ delete spell;
continue; // Pets must only jump to target
+ }
// No enemy, check friendly
if (!spellUsed)
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 97fe3b80f10..23386f82d73 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -488,9 +488,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_CAST:
{
- if (!me)
- break;
-
ObjectList* targets = GetTargets(e, unit);
if (!targets)
break;
@@ -502,31 +499,36 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!(e.action.cast.flags & SMARTCAST_AURA_NOT_PRESENT) || !(*itr)->ToUnit()->HasAura(e.action.cast.spell))
{
- if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
- me->InterruptNonMeleeSpells(false);
-
- if (e.action.cast.flags & SMARTCAST_COMBAT_MOVE)
+ if (me)
{
- // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed
- // unless target is outside spell range, out of mana, or LOS.
+ if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
+ me->InterruptNonMeleeSpells(false);
- bool _allowMove = false;
- SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(e.action.cast.spell);
- int32 mana = me->GetPower(POWER_MANA);
+ if (e.action.cast.flags & SMARTCAST_COMBAT_MOVE)
+ {
+ // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed
+ // unless target is outside spell range, out of mana, or LOS.
+
+ bool _allowMove = false;
+ SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(e.action.cast.spell);
+ int32 mana = me->GetPower(POWER_MANA);
- if (me->GetDistance(*itr) > spellInfo->GetMaxRange(true) ||
- me->GetDistance(*itr) < spellInfo->GetMinRange(true) ||
- !me->IsWithinLOSInMap(*itr) ||
- mana < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()))
+ if (me->GetDistance(*itr) > spellInfo->GetMaxRange(true) ||
+ me->GetDistance(*itr) < spellInfo->GetMinRange(true) ||
+ !me->IsWithinLOSInMap(*itr) ||
+ mana < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()))
_allowMove = true;
- CAST_AI(SmartAI, me->AI())->SetCombatMove(_allowMove);
- }
+ CAST_AI(SmartAI, me->AI())->SetCombatMove(_allowMove);
+ }
- me->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
+ me->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
+ }
+ else if (go)
+ go->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
- TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST:: Creature %u casts spell %u on target %u with castflags %u",
- me->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
+ 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);
}
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()));