aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-09 19:55:15 -0500
committermegamage <none@none>2009-06-09 19:55:15 -0500
commit853432b201c6ae5b14c9cae445bb254a4795b4e5 (patch)
tree8c90729c1965ea80196165233a17ecc13f1fc4ba
parent4167ca4f840941b949fd318e4158ecf3cc268647 (diff)
*Fix a bug that creature ignore LOS in assistance case.
--HG-- branch : trunk
-rw-r--r--src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp6
-rw-r--r--src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp8
-rw-r--r--src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp16
-rw-r--r--src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp5
-rw-r--r--src/game/Creature.cpp12
-rw-r--r--src/game/Creature.h2
-rw-r--r--src/game/CreatureAI.cpp4
-rw-r--r--src/game/CreatureEventAI.cpp9
-rw-r--r--src/game/GridNotifiers.h2
9 files changed, 27 insertions, 37 deletions
diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
index f99f9a130aa..34bda60c1b7 100644
--- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
+++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
@@ -240,9 +240,9 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
void MoveInLineOfSight(Unit *who)
{
- if(who && !m_creature->getVictim() && m_creature->canStartAttack(who))
- AttackStart(who);
- if (!Intro && who && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who))
+ ScriptedAI::MoveInLineOfSight(who);
+
+ if (!Intro && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who))
{
DoScriptText(SAY_INTRO, m_creature);
Intro = true;
diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp
index 77ba7fd7ce2..b6a9f0fecae 100644
--- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp
+++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp
@@ -434,14 +434,10 @@ void hyjalAI::EnterCombat(Unit *who)
void hyjalAI::MoveInLineOfSight(Unit *who)
{
- if(IsDummy)return;
- if (IsBeingEscorted && !GetAttack())
- return;
-
- if(m_creature->getVictim() || !m_creature->canStartAttack(who))
+ if(IsDummy)
return;
- AttackStart(who);
+ npc_escortAI::MoveInLineOfSight(who);
}
void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
diff --git a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp
index aaded603f80..6ee3aba6d12 100644
--- a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp
+++ b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp
@@ -649,22 +649,16 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI
WaveTimer = 0;
}
- void EnterCombat(Unit* who){}
-
void MoveInLineOfSight(Unit* who)
{
- if( who->GetTypeId() == TYPEID_PLAYER && !m_creature->canStartAttack(who) && !Progress)
+ if(!Progress && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 10.0f))
{
if( CAST_PLR(who)->GetQuestStatus(QUEST_POWERING_OUR_DEFENSES) == QUEST_STATUS_INCOMPLETE )
{
- float Radius = 10.0;
- if( m_creature->IsWithinDistInMap(who, Radius) )
- {
- PlayerGUID = who->GetGUID();
- WaveTimer = 1000;
- EndTimer = 60000;
- Progress = true;
- }
+ PlayerGUID = who->GetGUID();
+ WaveTimer = 1000;
+ EndTimer = 60000;
+ Progress = true;
}
}
}
diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp
index 12c7c3fa2ad..df0ac6851af 100644
--- a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp
+++ b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp
@@ -170,10 +170,7 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
void MoveInLineOfSight(Unit *who)
{
if(!Intro && !Flying)
- {
- if(!m_creature->getVictim() && m_creature->canStartAttack(who))
- ScriptedAI::AttackStart(who);
- }
+ ScriptedAI::MoveInLineOfSight(who);
}
void MovementInform(uint32 type, uint32 id)
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 7f249b36fbd..4e4cd734d5f 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1646,15 +1646,17 @@ bool Creature::IsWithinSightDist(Unit const* u) const
return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER));
}
-bool Creature::canStartAttack(Unit const* who) const
+bool Creature::canStartAttack(Unit const* who, bool force) const
{
- if(isCivilian() || IsNeutralToAll()
+ if(isCivilian()
|| !who->isInAccessiblePlaceFor(this)
- || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE
- || !IsWithinDistInMap(who, GetAttackDistance(who)))
+ || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return false;
- if(!canAttack(who, false))
+ if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who))))
+ return false;
+
+ if(!canAttack(who, force))
return false;
return IsWithinLOSInMap(who);
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 6c966f50aea..155ba3e8dd8 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -643,7 +643,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
bool IsWithinSightDist(Unit const* u) const;
- bool canStartAttack(Unit const* u) const;
+ bool canStartAttack(Unit const* u, bool force) const;
float GetAttackDistance(Unit const* pl) const;
Unit* SelectNearestTarget(float dist = 0) const;
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 143dfec99d3..1c3179b2e23 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -100,11 +100,11 @@ void CreatureAI::MoveInLineOfSight(Unit *who)
if(me->getVictim())
return;
- if(me->canStartAttack(who))
+ if(me->canStartAttack(who, false))
AttackStart(who);
else if(who->getVictim() && me->IsFriendlyTo(who)
&& me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
- && me->canAttack(who->getVictim()))
+ && me->canStartAttack(who->getVictim(), true))
AttackStart(who->getVictim());
}
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp
index 834741fd2ae..3eb3a75c874 100644
--- a/src/game/CreatureEventAI.cpp
+++ b/src/game/CreatureEventAI.cpp
@@ -957,11 +957,12 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
}
}
- //if (m_creature->isCivilian() && m_creature->IsNeutralToAll())
- // return;
-
- if(me->canStartAttack(who))
+ if(me->canStartAttack(who, false))
AttackStart(who);
+ else if(who->getVictim() && me->IsFriendlyTo(who)
+ && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
+ && me->canStartAttack(who->getVictim(), true))
+ AttackStart(who->getVictim());
}
void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
index 667891c0e38..5418bd09b16 100644
--- a/src/game/GridNotifiers.h
+++ b/src/game/GridNotifiers.h
@@ -997,7 +997,7 @@ namespace Trinity
}
else
{
- if(!m_creature->canStartAttack(u))
+ if(!m_creature->canStartAttack(u, false))
return false;
}