[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:
@@ -793,10 +793,6 @@ struct TRINITY_DLL_DECL mob_toxic_sporebatAI : public ScriptedAI
|
|||||||
|
|
||||||
void UpdateAI (const uint32 diff)
|
void UpdateAI (const uint32 diff)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*if(!m_creature->isInCombat())
|
|
||||||
m_creature->SetInCombatState(false);*/
|
|
||||||
|
|
||||||
//Random movement
|
//Random movement
|
||||||
if (movement_timer < diff)
|
if (movement_timer < diff)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -357,7 +357,7 @@ struct TRINITY_DLL_DECL boss_the_lurker_belowAI : public Scripted_NoMovementAI
|
|||||||
}else PhaseTimer-=diff;
|
}else PhaseTimer-=diff;
|
||||||
|
|
||||||
if(!m_creature->isInCombat())
|
if(!m_creature->isInCombat())
|
||||||
m_creature->SetInCombatState(false);
|
DoZoneInCombat();
|
||||||
|
|
||||||
if(!Spawned)
|
if(!Spawned)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
|||||||
// Called for reaction at stopping attack at no attackers or targets
|
// Called for reaction at stopping attack at no attackers or targets
|
||||||
virtual void EnterEvadeMode();
|
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)
|
// Called at any Damage from any attacker (before damage apply)
|
||||||
// Note: it for recalculation damage or special reaction at damage
|
// Note: it for recalculation damage or special reaction at damage
|
||||||
// for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also
|
// 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
|
//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 cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them
|
||||||
if(param3 & CAST_AURA_NOT_PRESENT)
|
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
|
//Check for on combat start events
|
||||||
if (!bEmptyList)
|
if (!bEmptyList)
|
||||||
@@ -1154,7 +1154,7 @@ void CreatureEventAI::Aggro(Unit *who)
|
|||||||
{
|
{
|
||||||
case EVENT_T_AGGRO:
|
case EVENT_T_AGGRO:
|
||||||
(*i).Enabled = true;
|
(*i).Enabled = true;
|
||||||
ProcessEvent(*i, who);
|
ProcessEvent(*i, enemy);
|
||||||
break;
|
break;
|
||||||
//Reset all in combat timers
|
//Reset all in combat timers
|
||||||
case EVENT_T_TIMER:
|
case EVENT_T_TIMER:
|
||||||
@@ -1189,13 +1189,8 @@ void CreatureEventAI::AttackStart(Unit *who)
|
|||||||
if (!who)
|
if (!who)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool inCombat = m_creature->isInCombat();
|
|
||||||
|
|
||||||
if (m_creature->Attack(who, MeleeEnabled))
|
if (m_creature->Attack(who, MeleeEnabled))
|
||||||
{
|
{
|
||||||
if (!inCombat)
|
|
||||||
Aggro(who);
|
|
||||||
|
|
||||||
if (CombatMovementEnabled)
|
if (CombatMovementEnabled)
|
||||||
{
|
{
|
||||||
m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle);
|
m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle);
|
||||||
|
|||||||
@@ -263,11 +263,11 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
|
|||||||
void JustRespawned();
|
void JustRespawned();
|
||||||
void Reset();
|
void Reset();
|
||||||
void JustReachedHome();
|
void JustReachedHome();
|
||||||
|
void EnterCombat(Unit *enemy);
|
||||||
void EnterEvadeMode();
|
void EnterEvadeMode();
|
||||||
void JustDied(Unit* killer);
|
void JustDied(Unit* killer);
|
||||||
void KilledUnit(Unit* victim);
|
void KilledUnit(Unit* victim);
|
||||||
void JustSummoned(Creature* pUnit);
|
void JustSummoned(Creature* pUnit);
|
||||||
void Aggro(Unit *who);
|
|
||||||
void AttackStart(Unit *who);
|
void AttackStart(Unit *who);
|
||||||
void MoveInLineOfSight(Unit *who);
|
void MoveInLineOfSight(Unit *who);
|
||||||
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
|
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
|
||||||
|
|||||||
+5
-4
@@ -9679,7 +9679,7 @@ void Unit::SetInCombatWith(Unit* enemy)
|
|||||||
Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
|
Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
|
||||||
if(eOwner->IsPvP())
|
if(eOwner->IsPvP())
|
||||||
{
|
{
|
||||||
SetInCombatState(true);
|
SetInCombatState(true,enemy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9689,11 +9689,11 @@ void Unit::SetInCombatWith(Unit* enemy)
|
|||||||
Unit const* myOwner = GetCharmerOrOwnerOrSelf();
|
Unit const* myOwner = GetCharmerOrOwnerOrSelf();
|
||||||
if(((Player const*)eOwner)->duel->opponent == myOwner)
|
if(((Player const*)eOwner)->duel->opponent == myOwner)
|
||||||
{
|
{
|
||||||
SetInCombatState(true);
|
SetInCombatState(true,enemy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetInCombatState(false);
|
SetInCombatState(false,enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::CombatStart(Unit* target)
|
void Unit::CombatStart(Unit* target)
|
||||||
@@ -9705,6 +9705,7 @@ void Unit::CombatStart(Unit* target)
|
|||||||
&& !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled)
|
&& !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled)
|
||||||
{
|
{
|
||||||
((Creature*)target)->AI()->AttackStart(this);
|
((Creature*)target)->AI()->AttackStart(this);
|
||||||
|
((Creature*)target)->AI()->EnterCombat(this);
|
||||||
if(((Creature*)target)->GetFormation())
|
if(((Creature*)target)->GetFormation())
|
||||||
{
|
{
|
||||||
((Creature*)target)->GetFormation()->MemberAttackStart((Creature*)target, this);
|
((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
|
// only alive units can be in combat
|
||||||
if(!isAlive())
|
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); }
|
bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
|
||||||
void CombatStart(Unit* target);
|
void CombatStart(Unit* target);
|
||||||
void SetInCombatState(bool PvP);
|
void SetInCombatState(bool PvP, Unit* enemy = NULL);
|
||||||
void SetInCombatWith(Unit* enemy);
|
void SetInCombatWith(Unit* enemy);
|
||||||
void ClearInCombat();
|
void ClearInCombat();
|
||||||
uint32 GetCombatTimer() const { return m_CombatTimer; }
|
uint32 GetCombatTimer() const { return m_CombatTimer; }
|
||||||
|
|||||||
Reference in New Issue
Block a user