aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorm7nu3l <mgcarrasco2012@gmail.com>2013-02-03 14:46:17 -0300
committerm7nu3l <mgcarrasco2012@gmail.com>2013-02-03 14:46:17 -0300
commit124b5ed6e7f9be9ffe6453e1defef3df5d409d8c (patch)
tree9b346f184ad4042050129dcb37202985c640d47e /src
parent118c1d8c2cc59ced924803233a935963c3784ed9 (diff)
Core/AI: Implemented functionality for _isCombatMovementAllowed in ScriptedAI, only when AttackStart is called.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp8
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h9
2 files changed, 16 insertions, 1 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 9709cb0ecc2..090c73f456f 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -108,6 +108,14 @@ void ScriptedAI::AttackStartNoMove(Unit* who)
DoStartNoMovement(who);
}
+void ScriptedAI::AttackStart(Unit* who)
+{
+ if (IsCombatMovementAllowed())
+ CreatureAI::AttackStart(who);
+ else
+ AttackStartNoMove(who);
+}
+
void ScriptedAI::UpdateAI(uint32 const /*diff*/)
{
//Check if we have a current target
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index 50363f20ed5..15068557aca 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -136,6 +136,9 @@ struct ScriptedAI : public CreatureAI
//Called at creature aggro either by MoveInLOS or Attack Start
void EnterCombat(Unit* /*victim*/) {}
+ // Called before EnterCombat even before the creature is in combat.
+ void AttackStart(Unit* /*target*/);
+
// *************
//AI Helper Functions
// *************
@@ -191,7 +194,11 @@ struct ScriptedAI : public CreatureAI
void SetEquipmentSlots(bool loadDefault, int32 mainHand = EQUIP_NO_CHANGE, int32 offHand = EQUIP_NO_CHANGE, int32 ranged = EQUIP_NO_CHANGE);
- //Generally used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims
+ // Used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims
+ // NOTE: If you use SetCombatMovement while the creature is in combat, it will do NOTHING - This only affects AttackStart
+ // You should make the necessary to make it happen so.
+ // Remember that if you modified _isCombatMovementAllowed (e.g: using SetCombatMovement) it will not be reset at Reset().
+ // It will keep the last value you set.
void SetCombatMovement(bool allowMovement);
bool IsCombatMovementAllowed() const { return _isCombatMovementAllowed; }