diff options
author | megamage <none@none> | 2009-04-27 19:14:37 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-27 19:14:37 -0500 |
commit | 2b753d0f23593849dc2b440406e6f7006c104c53 (patch) | |
tree | 2314d720fb6210e27e93ccb7a0eed83b5dae8b17 /src | |
parent | d4c75dddea881d544524ac4373f097f15a603c18 (diff) |
[7723] New AI call EnterCombat called at enter creature to combat (and re-enter if leave by some reason). Author: VladimirMangos
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp | 4 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp | 2 | ||||
-rw-r--r-- | src/game/CreatureAI.h | 3 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 11 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 9 | ||||
-rw-r--r-- | src/game/Unit.h | 2 |
7 files changed, 14 insertions, 19 deletions
diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp index aaedc7adcbd..6a481f21b19 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp @@ -793,10 +793,6 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI void UpdateAI (const uint32 diff) { - - /*if(!m_creature->isInCombat()) - m_creature->SetInCombatState(false);*/ - //Random movement if (movement_timer < diff) { diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp index 653799f08f5..b911c1e5a87 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp @@ -357,7 +357,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI }else PhaseTimer-=diff; if(!m_creature->isInCombat()) - m_creature->SetInCombatState(false); + DoZoneInCombat(); if(!Spawned) { diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 695dae447c3..d83a9eb2cd8 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -206,6 +206,9 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI // Called for reaction at stopping attack at no attackers or targets virtual void EnterEvadeMode(); + // Called for reaction at enter to combat if not in combat yet (enemy can be NULL) + virtual void EnterCombat(Unit* /*enemy*/) {} + // Called at any Damage from any attacker (before damage apply) // Note: it for recalculation damage or special reaction at damage // for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index a4d08b3dfed..b201aafe4dd 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -625,7 +625,7 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u } //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered - bool canCast = !(caster->IsNonMeleeSpellCasted(false) && !(param3 & CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); + bool canCast = !caster->IsNonMeleeSpellCasted(false) || (param3 & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them if(param3 & CAST_AURA_NOT_PRESENT) @@ -1143,7 +1143,7 @@ void CreatureEventAI::JustSummoned(Creature* pUnit) } } -void CreatureEventAI::Aggro(Unit *who) +void CreatureEventAI::EnterCombat(Unit *enemy) { //Check for on combat start events if (!bEmptyList) @@ -1154,7 +1154,7 @@ void CreatureEventAI::Aggro(Unit *who) { case EVENT_T_AGGRO: (*i).Enabled = true; - ProcessEvent(*i, who); + ProcessEvent(*i, enemy); break; //Reset all in combat timers case EVENT_T_TIMER: @@ -1189,13 +1189,8 @@ void CreatureEventAI::AttackStart(Unit *who) if (!who) return; - bool inCombat = m_creature->isInCombat(); - if (m_creature->Attack(who, MeleeEnabled)) { - if (!inCombat) - Aggro(who); - if (CombatMovementEnabled) { m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle); diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 6c21f1abdce..7e67dffefcd 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -263,11 +263,11 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI void JustRespawned(); void Reset(); void JustReachedHome(); + void EnterCombat(Unit *enemy); void EnterEvadeMode(); void JustDied(Unit* killer); void KilledUnit(Unit* victim); void JustSummoned(Creature* pUnit); - void Aggro(Unit *who); void AttackStart(Unit *who); void MoveInLineOfSight(Unit *who); void SpellHit(Unit* pUnit, const SpellEntry* pSpell); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7f197c16ac9..01cdcdcbf38 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9679,7 +9679,7 @@ void Unit::SetInCombatWith(Unit* enemy) Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); if(eOwner->IsPvP()) { - SetInCombatState(true); + SetInCombatState(true,enemy); return; } @@ -9689,11 +9689,11 @@ void Unit::SetInCombatWith(Unit* enemy) Unit const* myOwner = GetCharmerOrOwnerOrSelf(); if(((Player const*)eOwner)->duel->opponent == myOwner) { - SetInCombatState(true); + SetInCombatState(true,enemy); return; } } - SetInCombatState(false); + SetInCombatState(false,enemy); } void Unit::CombatStart(Unit* target) @@ -9705,6 +9705,7 @@ void Unit::CombatStart(Unit* target) && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled) { ((Creature*)target)->AI()->AttackStart(this); + ((Creature*)target)->AI()->EnterCombat(this); if(((Creature*)target)->GetFormation()) { ((Creature*)target)->GetFormation()->MemberAttackStart((Creature*)target, this); @@ -9729,7 +9730,7 @@ void Unit::CombatStart(Unit* target) } } -void Unit::SetInCombatState(bool PvP) +void Unit::SetInCombatState(bool PvP, Unit* enemy) { // only alive units can be in combat if(!isAlive()) diff --git a/src/game/Unit.h b/src/game/Unit.h index 983f6a023ef..cbfa701a398 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1149,7 +1149,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } void CombatStart(Unit* target); - void SetInCombatState(bool PvP); + void SetInCombatState(bool PvP, Unit* enemy = NULL); void SetInCombatWith(Unit* enemy); void ClearInCombat(); uint32 GetCombatTimer() const { return m_CombatTimer; } |