aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts
diff options
context:
space:
mode:
authorNeo2003 <none@none>2008-10-05 12:10:02 -0500
committerNeo2003 <none@none>2008-10-05 12:10:02 -0500
commit843f789f58b73b5af6d8be46fe97448a341ceb8d (patch)
tree52484d985ce6206afdd4e1932f1e83243087b2de /src/bindings/scripts
parent0c3db399c565401dc1f771f14370421c320c555b (diff)
[svn] * Added fleeing and call assistance in script until we move all AI functions to core
--HG-- branch : trunk
Diffstat (limited to 'src/bindings/scripts')
-rw-r--r--src/bindings/scripts/include/sc_creature.h3
-rw-r--r--src/bindings/scripts/scripts/creature/mob_event_ai.cpp25
2 files changed, 25 insertions, 3 deletions
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 9433a6b7331..949689bffc7 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -72,6 +72,9 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI
//Bool for if we are in combat or not
bool InCombat;
+ //For fleeing
+ bool IsFleeing;
+
//*************
//Pure virtual functions
//*************
diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
index 4e772ed4b23..4298156af84 100644
--- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
+++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
@@ -79,6 +79,7 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
bool MeleeEnabled; //If we allow melee auto attack
uint32 AttackDistance; //Distance to attack from
float AttackAngle; //Angle of attack
+ uint32 TimetoFleeLeft; //For fleeing
void AttackTarget(Unit* pTarget, bool Follow)
{
@@ -774,8 +775,9 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
break;
case ACTION_T_FLEE:
{
- //TODO: Replace with Flee movement generator
- m_creature->CastSpell(m_creature, SPELL_RUN_AWAY, true);
+ TimetoFleeLeft = 8000;
+ m_creature->DoFleeToGetAssistance();
+ IsFleeing = true;
}
break;
case ACTION_T_QUEST_EVENT_ALL:
@@ -954,6 +956,7 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
void JustRespawned()
{
InCombat = false;
+ IsFleeing = false;
Reset();
//Handle Spawned Events
@@ -1014,6 +1017,7 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
m_creature->SetLootRecipient(NULL);
InCombat = false;
+ IsFleeing = false;
Reset();
//Handle Evade events
@@ -1034,6 +1038,7 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
void JustDied(Unit* killer)
{
InCombat = false;
+ IsFleeing = false;
Reset();
//Handle Evade events
@@ -1131,7 +1136,7 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
if (!who)
return;
- if (who->isTargetableForAttack())
+ if (who->isTargetableForAttack() && !IsFleeing)
{
//Begin melee attack if we are within range
if (CombatMovementEnabled)
@@ -1225,6 +1230,20 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
if (!m_creature->isAlive())
return;
+ if ((TimetoFleeLeft < diff || (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE)) && IsFleeing)
+ {
+ m_creature->GetMotionMaster()->Clear(false);
+ m_creature->SetNoCallAssistence(false);
+ m_creature->CallAssistence();
+ m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
+ IsFleeing = false;
+ }
+ else
+ TimetoFleeLeft -= diff;
+
+ if(IsFleeing)
+ return;
+
//Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events
if (EventUpdateTime < diff)
{