[7723] New AI call EnterCombat called at enter creature to combat (and re-enter if leave by some reason). Author: VladimirMangos
--HG-- branch : trunk
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+5
-4
@@ -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())
|
||||
|
||||
+1
-1
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user