Skip to content

Commit 0d88fe0

Browse files
author
NoFantasy
committed
[457] Removed: improper HasInArc()-check in MoveInLineOfSight()
Removed: improper HasInArc()-check in MoveInLineOfSight() Adjusted: mob_event_ai ACTION_T_QUEST_EVENT_ALL using GroupEventHappens() git-svn-id: https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2@457 5f9c896b-1e26-0410-94da-f77f675e2462
1 parent 6ee2241 commit 0d88fe0

6 files changed

Lines changed: 56 additions & 78 deletions

File tree

docs/EventAI.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Params are always read from Param1, then Param2, then Param3.
101101
23 ACTION_T_INC_PHASE Value Increments the phase by (param1). May be negative to decrement phase but should not be 0.
102102
24 ACTION_T_EVADE No Params Forces the creature to evade. Wiping all threat and dropping combat.
103103
25 ACTION_T_FLEE No Params Causes the creature to flee. Please use this action instead of directly casting this spell so we may change this when a more correct approach is found.
104-
26 ACTION_T_QUEST_EVENT_ALL QuestId Calls AreaExploredOrEventHappens with (param1) for all players on the threat list
104+
26 ACTION_T_QUEST_EVENT_ALL QuestId Calls GroupEventHappens with (param1). Only used if it's _expected_ event should complete for all players in current party
105105
27 ACTION_T_CASTCREATUREGO_ALL QuestId, SpellId Calls CastedCreatureOrGo for all players on the threat list with QuestID(Param1) and SpellId(Param2)
106106
28 ACTION_T_REMOVEAURASFROMSPELL Target, Spellid Removes all auras on Target caused by Spellid
107107
29 ACTION_T_RANGED_MOVEMENT Distance, Angle Changes the movement generator type to a ranged type. Note: Default melee type can still be done with this. Specify 0 angle and 0 distance.

include/sc_creature.cpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,15 @@ void ScriptedAI::MoveInLineOfSight(Unit *who)
3333
return;
3434

3535
float attackRadius = m_creature->GetAttackDistance(who);
36-
if(m_creature->IsWithinDistInMap(who, attackRadius))
36+
if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) )
3737
{
38-
// Check first that object is in an angle in front of this one before LoS check
39-
if( m_creature->HasInArc(M_PI/2.0f, who) && m_creature->IsWithinLOSInMap(who) )
38+
DoStartAttackAndMovement(who);
39+
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
40+
41+
if (!InCombat)
4042
{
41-
DoStartAttackAndMovement(who);
42-
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
43-
44-
if (!InCombat)
45-
{
46-
Aggro(who);
47-
InCombat = true;
48-
}
43+
Aggro(who);
44+
InCombat = true;
4945
}
5046
}
5147
}
@@ -558,19 +554,15 @@ void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who)
558554
return;
559555

560556
float attackRadius = m_creature->GetAttackDistance(who);
561-
if(m_creature->IsWithinDistInMap(who, attackRadius))
557+
if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) )
562558
{
563-
// Check first that object is in an angle in front of this one before LoS check
564-
if( m_creature->HasInArc(M_PI/2.0f, who) && m_creature->IsWithinLOSInMap(who) )
559+
DoStartAttackNoMovement(who);
560+
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
561+
562+
if (!InCombat)
565563
{
566-
DoStartAttackNoMovement(who);
567-
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
568-
569-
if (!InCombat)
570-
{
571-
Aggro(who);
572-
InCombat = true;
573-
}
564+
Aggro(who);
565+
InCombat = true;
574566
}
575567
}
576568
}

scripts/creature/mob_event_ai.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,11 @@ struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI
619619
case ACTION_T_QUEST_EVENT_ALL:
620620
{
621621
Unit* Temp = NULL;
622-
623-
std::list<HostilReference*>::iterator i = m_creature->getThreatManager().getThreatList().begin();
624-
for (; i != m_creature->getThreatManager().getThreatList().end(); ++i)
622+
if( pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER )
625623
{
626-
Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid());
627-
if (Temp && Temp->GetTypeId() == TYPEID_PLAYER)
628-
((Player*)Temp)->AreaExploredOrEventHappens(param1);
624+
Temp = Unit::GetUnit((*m_creature),pActionInvoker->GetGUID());
625+
if( Temp )
626+
((Player*)Temp)->GroupEventHappens(param1,m_creature);
629627
}
630628
}
631629
break;

scripts/npc/npc_escortAI.cpp

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,31 @@ void npc_escortAI::MoveInLineOfSight(Unit *who)
5858
return;
5959

6060
float attackRadius = m_creature->GetAttackDistance(who);
61-
if(m_creature->IsWithinDistInMap(who, attackRadius))
61+
if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) )
6262
{
63-
// Check first that object is in an angle in front of this one before LoS check
64-
if( m_creature->HasInArc(M_PI/2.0f, who) && m_creature->IsWithinLOSInMap(who) )
63+
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
64+
65+
//Begin attack
66+
if ( m_creature->Attack(who, true) )
67+
{
68+
m_creature->GetMotionMaster()->MovementExpired();
69+
m_creature->GetMotionMaster()->MoveChase(who);
70+
m_creature->AddThreat(who, 0.0f);
71+
m_creature->resetAttackTimer();
72+
73+
if (who->GetTypeId() == TYPEID_PLAYER)
74+
m_creature->SetLootRecipient((Player*)who);
75+
}
76+
77+
if (!InCombat)
6578
{
66-
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
67-
68-
//Begin attack
69-
if ( m_creature->Attack(who, true) )
70-
{
71-
m_creature->GetMotionMaster()->MovementExpired();
72-
m_creature->GetMotionMaster()->MoveChase(who);
73-
m_creature->AddThreat(who, 0.0f);
74-
m_creature->resetAttackTimer();
75-
76-
if (who->GetTypeId() == TYPEID_PLAYER)
77-
m_creature->SetLootRecipient((Player*)who);
78-
}
79-
80-
if (!InCombat)
81-
{
82-
InCombat = true;
83-
84-
//Store last position
85-
m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);
86-
debug_log("SD2: EscortAI has entered combat via LOS and stored last location");
87-
88-
Aggro(who);
89-
}
79+
InCombat = true;
80+
81+
//Store last position
82+
m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);
83+
debug_log("SD2: EscortAI has entered combat via LOS and stored last location");
84+
85+
Aggro(who);
9086
}
9187
}
9288
}

scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,15 @@ struct MANGOS_DLL_DECL boss_murmurAI : public ScriptedAI
7676
return;
7777

7878
float attackRadius = m_creature->GetAttackDistance(who);
79-
if(m_creature->IsWithinDistInMap(who, attackRadius))
79+
if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
8080
{
81-
// Check first that object is in an angle in front of this one before LoS check
82-
if( m_creature->HasInArc(M_PI/2.0f, who) && m_creature->IsWithinLOSInMap(who) )
81+
DoStartAttackNoMovement(who);
82+
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
83+
84+
if (!InCombat)
8385
{
84-
DoStartAttackNoMovement(who);
85-
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
86-
87-
if (!InCombat)
88-
{
89-
Aggro(who);
90-
InCombat = true;
91-
}
86+
Aggro(who);
87+
InCombat = true;
9288
}
9389
}
9490
}

scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,15 @@ struct MANGOS_DLL_DECL advisorbase_ai : public ScriptedAI
208208
return;
209209

210210
float attackRadius = m_creature->GetAttackDistance(who);
211-
if(m_creature->IsWithinDistInMap(who, attackRadius))
211+
if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) )
212212
{
213-
// Check first that object is in an angle in front of this one before LoS check
214-
if( m_creature->HasInArc(M_PI/2.0f, who) && m_creature->IsWithinLOSInMap(who) )
215-
{
216-
DoStartAttackAndMovement(who);
217-
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
213+
DoStartAttackAndMovement(who);
214+
who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
218215

219-
if (!InCombat)
220-
{
221-
Aggro(who);
222-
InCombat = true;
223-
}
216+
if (!InCombat)
217+
{
218+
Aggro(who);
219+
InCombat = true;
224220
}
225221
}
226222
}

0 commit comments

Comments
 (0)