From 03234a0657eca4836b1015556973629893c76958 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 30 Jan 2009 01:14:48 -0600 Subject: [PATCH] *Fix some bugged AI which cause creatures enter evade mode repeatedly. *Let player enter combat when attacked but not hit by creatures. --HG-- branch : trunk --- src/bindings/scripts/include/sc_creature.cpp | 3 --- src/bindings/scripts/scripts/creature/mob_event_ai.cpp | 2 -- src/bindings/scripts/scripts/npc/npc_escortAI.cpp | 2 -- .../scripts/zone/black_temple/boss_shade_of_akama.cpp | 1 - .../hellfire_citadel/shattered_halls/boss_nethekurse.cpp | 2 -- .../scripts/scripts/zone/shattrath/shattrath_city.cpp | 1 - .../scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp | 2 -- .../scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp | 5 ----- src/game/AggressorAI.cpp | 3 --- src/game/GuardAI.cpp | 3 --- src/game/PetAI.cpp | 2 -- src/game/ReactorAI.cpp | 2 -- src/game/Unit.cpp | 5 +++++ 13 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index 82e7ab04ca..c2ae15d9ab 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -85,7 +85,6 @@ void ScriptedAI::AttackStart(Unit* who, bool melee) if (m_creature->Attack(who, melee)) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); if (!InCombat) { @@ -108,7 +107,6 @@ void ScriptedAI::AttackStart(Unit* who) if (m_creature->Attack(who, true)) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); if (!InCombat) { @@ -834,7 +832,6 @@ void Scripted_NoMovementAI::AttackStart(Unit* who) if (m_creature->Attack(who, true)) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); if (!InCombat) { diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 6b46b7aecd..17b2c1b5ac 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -1150,8 +1150,6 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI if (m_creature->Attack(who, MeleeEnabled)) { //Begin melee attack if we are within range - m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); if (!InCombat) { diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp index 88505c44ca..20e6345b9f 100644 --- a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp +++ b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp @@ -35,8 +35,6 @@ void npc_escortAI::AttackStart(Unit *who) if ( m_creature->Attack(who, true) ) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp index a29a2db932..be2c183040 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp @@ -440,7 +440,6 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI Akama->AddThreat(m_creature, 10000000.0f); m_creature->Attack(Akama, true); Akama->Attack(m_creature, true); - m_creature->SetInCombatWith(Akama); } } } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp index d152536359..c8027abaa5 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp @@ -170,8 +170,6 @@ struct TRINITY_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI if (m_creature->Attack(who, true)) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { diff --git a/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp b/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp index 22f71e09be..0709342d42 100644 --- a/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp +++ b/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp @@ -522,7 +522,6 @@ struct TRINITY_DLL_DECL npc_dirty_larryAI : public ScriptedAI Malone->setFaction(14); Malone->GetMotionMaster()->MoveChase(player); } - m_creature->SetInCombatWith(player); DoStartMovement(player); AttackStart(player); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp index d4433c7afe..febecd13ce 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp @@ -104,8 +104,6 @@ struct TRINITY_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI if (m_creature->Attack(who, true)) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp index d46f7cf519..39627a30cf 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp @@ -1211,8 +1211,6 @@ struct TRINITY_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_ if (m_creature->Attack(who, true)) { m_creature->AddThreat(who, 0.0f); - m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); if (!InCombat) { @@ -1497,9 +1495,6 @@ struct TRINITY_DLL_DECL mob_phoenix_egg_tkAI : public ScriptedAI { if (m_creature->Attack(who, false)) { - m_creature->SetInCombatWith(who); - who->SetInCombatWith(m_creature); - if (!InCombat) { InCombat = true; diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 99e39618f5..a11584eab6 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -148,9 +148,6 @@ AggressorAI::AttackStart(Unit *u) if(i_creature.Attack(u,true)) { - i_creature.SetInCombatWith(u); - u->SetInCombatWith(&i_creature); - i_creature.AddThreat(u, 0.0f); // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); i_victimGuid = u->GetGUID(); diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index e5a7ce8709..273fa32272 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -139,9 +139,6 @@ void GuardAI::AttackStart(Unit *u) // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); if(i_creature.Attack(u,true)) { - i_creature.SetInCombatWith(u); - u->SetInCombatWith(&i_creature); - i_creature.AddThreat(u, 0.0f); i_victimGuid = u->GetGUID(); i_creature.GetMotionMaster()->MoveChase(u); diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 85c2a77c92..bce8a4d8f5 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -73,8 +73,6 @@ void PetAI::AttackStart(Unit *u) if(i_pet.Attack(u,true)) { - i_pet.SetInCombatWith(u); - i_pet.clearUnitState(UNIT_STAT_FOLLOW); // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function // thus with the following clear the original TMG gets invalidated and crash, doh diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index dd796b74f3..7ade73495c 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -50,8 +50,6 @@ ReactorAI::AttackStart(Unit *p) if(i_creature.Attack(p,true)) { DEBUG_LOG("Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId()); - i_creature.SetInCombatWith(p); - p->SetInCombatWith(&i_creature); i_creature.AddThreat(p, 0.0f); i_victimGuid = p->GetGUID(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7c8c917996..a2b4aba30f 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8203,6 +8203,11 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) ((WorldObject*)this)->SendMessageToSet(&data, true); ((Creature*)this)->CallAssistance(); + + // should not let player enter combat by right clicking target + SetInCombatWith(victim); + if(victim->GetTypeId() == TYPEID_PLAYER) + victim->SetInCombatWith(this); } // delay offhand weapon attack to next attack time