Core/Pets: Fixed flashing pet attack button (#18906)
Port TrinityCore Commit: https://github.com/TrinityCore/TrinityCore/commit/d1cbd8a837116a0fadae06cf5714a345035eb799
This commit is contained in:
@@ -63,7 +63,6 @@ namespace Game.AI
|
|||||||
|
|
||||||
me.AttackStop();
|
me.AttackStop();
|
||||||
me.InterruptNonMeleeSpells(false);
|
me.InterruptNonMeleeSpells(false);
|
||||||
me.SendMeleeAttackStop(); // Should stop pet's attack button from flashing
|
|
||||||
me.GetCharmInfo().SetIsCommandAttack(false);
|
me.GetCharmInfo().SetIsCommandAttack(false);
|
||||||
ClearCharmInfoFlags();
|
ClearCharmInfoFlags();
|
||||||
HandleReturnMovement();
|
HandleReturnMovement();
|
||||||
@@ -299,7 +298,6 @@ namespace Game.AI
|
|||||||
// next target selection
|
// next target selection
|
||||||
me.AttackStop();
|
me.AttackStop();
|
||||||
me.InterruptNonMeleeSpells(false);
|
me.InterruptNonMeleeSpells(false);
|
||||||
me.SendMeleeAttackStop(); // Stops the pet's 'Attack' button from flashing
|
|
||||||
|
|
||||||
// Before returning to owner, see if there are more things to attack
|
// Before returning to owner, see if there are more things to attack
|
||||||
Unit nextTarget = SelectNextTarget(false);
|
Unit nextTarget = SelectNextTarget(false);
|
||||||
@@ -445,6 +443,8 @@ namespace Game.AI
|
|||||||
me.GetMotionMaster().MoveFollow(me.GetCharmerOrOwner(), SharedConst.PetFollowDist, me.GetFollowAngle());
|
me.GetMotionMaster().MoveFollow(me.GetCharmerOrOwner(), SharedConst.PetFollowDist, me.GetFollowAngle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me.ClearInPetCombat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoAttack(Unit target, bool chase)
|
void DoAttack(Unit target, bool chase)
|
||||||
@@ -454,9 +454,12 @@ namespace Game.AI
|
|||||||
|
|
||||||
if (me.Attack(target, true))
|
if (me.Attack(target, true))
|
||||||
{
|
{
|
||||||
|
// properly fix fake combat after pet is sent to attack
|
||||||
Unit owner = me.GetOwner();
|
Unit owner = me.GetOwner();
|
||||||
if (owner)
|
if (owner != null)
|
||||||
owner.SetInCombatWith(target);
|
owner.AddUnitFlag(UnitFlags.PetInCombat);
|
||||||
|
|
||||||
|
me.AddUnitFlag(UnitFlags.PetInCombat);
|
||||||
|
|
||||||
// Play sound to let the player know the pet is attacking something it picked on its own
|
// Play sound to let the player know the pet is attacking something it picked on its own
|
||||||
if (me.HasReactState(ReactStates.Aggressive) && !me.GetCharmInfo().IsCommandAttack())
|
if (me.HasReactState(ReactStates.Aggressive) && !me.GetCharmInfo().IsCommandAttack())
|
||||||
@@ -525,10 +528,10 @@ namespace Game.AI
|
|||||||
|
|
||||||
if (!victim.IsAlive())
|
if (!victim.IsAlive())
|
||||||
{
|
{
|
||||||
|
// if target is invalid, pet should evade automaticly
|
||||||
// Clear target to prevent getting stuck on dead targets
|
// Clear target to prevent getting stuck on dead targets
|
||||||
me.AttackStop();
|
//me.AttackStop();
|
||||||
me.InterruptNonMeleeSpells(false);
|
//me.InterruptNonMeleeSpells(false);
|
||||||
me.SendMeleeAttackStop();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,10 @@ namespace Game.Entities
|
|||||||
if (IsTypeId(TypeId.Player))
|
if (IsTypeId(TypeId.Player))
|
||||||
ToPlayer().SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
|
ToPlayer().SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
|
||||||
ClearInCombat();
|
ClearInCombat();
|
||||||
|
|
||||||
|
// just in case
|
||||||
|
if (IsPetInCombat() && GetTypeId() != TypeId.Player)
|
||||||
|
ClearInPetCombat();
|
||||||
}
|
}
|
||||||
public void CombatStopWithPets(bool includingCast = false)
|
public void CombatStopWithPets(bool includingCast = false)
|
||||||
{
|
{
|
||||||
@@ -270,10 +274,17 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
ToPlayer().OnCombatExit();
|
ToPlayer().OnCombatExit();
|
||||||
|
|
||||||
RemoveUnitFlag(UnitFlags.PetInCombat);
|
|
||||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.LeaveCombat);
|
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.LeaveCombat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearInPetCombat()
|
||||||
|
{
|
||||||
|
RemoveUnitFlag(UnitFlags.PetInCombat);
|
||||||
|
Unit owner = GetOwner();
|
||||||
|
if (owner != null)
|
||||||
|
owner.RemoveUnitFlag(UnitFlags.PetInCombat);
|
||||||
|
}
|
||||||
|
|
||||||
void RemoveAllAttackers()
|
void RemoveAllAttackers()
|
||||||
{
|
{
|
||||||
while (!attackerList.Empty())
|
while (!attackerList.Empty())
|
||||||
@@ -327,10 +338,10 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
return m_deathState;
|
return m_deathState;
|
||||||
}
|
}
|
||||||
public bool IsInCombat()
|
|
||||||
{
|
public bool IsInCombat() { return HasUnitFlag(UnitFlags.InCombat); }
|
||||||
return HasUnitFlag(UnitFlags.InCombat);
|
public bool IsPetInCombat() { return HasUnitFlag(UnitFlags.PetInCombat); }
|
||||||
}
|
|
||||||
public bool Attack(Unit victim, bool meleeAttack)
|
public bool Attack(Unit victim, bool meleeAttack)
|
||||||
{
|
{
|
||||||
if (victim == null || victim.GetGUID() == GetGUID())
|
if (victim == null || victim.GetGUID() == GetGUID())
|
||||||
@@ -1323,10 +1334,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (var unit in m_Controlled)
|
foreach (var unit in m_Controlled)
|
||||||
{
|
|
||||||
unit.SetInCombatState(PvP, enemy);
|
unit.SetInCombatState(PvP, enemy);
|
||||||
unit.AddUnitFlag(UnitFlags.PetInCombat);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcSkillsAndAuras(enemy, ProcFlags.EnterCombat, ProcFlags.None, ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null);
|
ProcSkillsAndAuras(enemy, ProcFlags.EnterCombat, ProcFlags.None, ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
pet.AttackStop();
|
pet.AttackStop();
|
||||||
|
pet.ClearInPetCombat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePetActionHelper(Unit pet, ObjectGuid guid1, uint spellid, ActiveStates flag, ObjectGuid guid2, float x, float y, float z)
|
void HandlePetActionHelper(Unit pet, ObjectGuid guid1, uint spellid, ActiveStates flag, ObjectGuid guid2, float x, float y, float z)
|
||||||
@@ -154,6 +155,7 @@ namespace Game
|
|||||||
case CommandStates.Follow: //spellid=1792 //FOLLOW
|
case CommandStates.Follow: //spellid=1792 //FOLLOW
|
||||||
pet.AttackStop();
|
pet.AttackStop();
|
||||||
pet.InterruptNonMeleeSpells(false);
|
pet.InterruptNonMeleeSpells(false);
|
||||||
|
pet.ClearInPetCombat();
|
||||||
pet.GetMotionMaster().MoveFollow(GetPlayer(), SharedConst.PetFollowDist, pet.GetFollowAngle());
|
pet.GetMotionMaster().MoveFollow(GetPlayer(), SharedConst.PetFollowDist, pet.GetFollowAngle());
|
||||||
charmInfo.SetCommandState(CommandStates.Follow);
|
charmInfo.SetCommandState(CommandStates.Follow);
|
||||||
|
|
||||||
@@ -210,9 +212,6 @@ namespace Game
|
|||||||
}
|
}
|
||||||
else // charmed player
|
else // charmed player
|
||||||
{
|
{
|
||||||
if (pet.GetVictim() && pet.GetVictim() != TargetUnit)
|
|
||||||
pet.AttackStop();
|
|
||||||
|
|
||||||
charmInfo.SetIsCommandAttack(true);
|
charmInfo.SetIsCommandAttack(true);
|
||||||
charmInfo.SetIsAtStay(false);
|
charmInfo.SetIsAtStay(false);
|
||||||
charmInfo.SetIsFollowing(false);
|
charmInfo.SetIsFollowing(false);
|
||||||
@@ -267,6 +266,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
case ReactStates.Passive: //passive
|
case ReactStates.Passive: //passive
|
||||||
pet.AttackStop();
|
pet.AttackStop();
|
||||||
|
pet.ClearInPetCombat();
|
||||||
goto case ReactStates.Defensive;
|
goto case ReactStates.Defensive;
|
||||||
case ReactStates.Defensive: //recovery
|
case ReactStates.Defensive: //recovery
|
||||||
case ReactStates.Aggressive: //activete
|
case ReactStates.Aggressive: //activete
|
||||||
@@ -363,8 +363,6 @@ namespace Game
|
|||||||
// This is true if pet has no target or has target but targets differs.
|
// This is true if pet has no target or has target but targets differs.
|
||||||
if (pet.GetVictim() != unit_target)
|
if (pet.GetVictim() != unit_target)
|
||||||
{
|
{
|
||||||
if (pet.GetVictim())
|
|
||||||
pet.AttackStop();
|
|
||||||
pet.GetMotionMaster().Clear();
|
pet.GetMotionMaster().Clear();
|
||||||
if (pet.ToCreature().IsAIEnabled)
|
if (pet.ToCreature().IsAIEnabled)
|
||||||
pet.ToCreature().GetAI().AttackStart(unit_target);
|
pet.ToCreature().GetAI().AttackStart(unit_target);
|
||||||
|
|||||||
@@ -1054,19 +1054,9 @@ namespace Game.Spells
|
|||||||
// creature/player specific target checks
|
// creature/player specific target checks
|
||||||
if (unitTarget != null)
|
if (unitTarget != null)
|
||||||
{
|
{
|
||||||
if (HasAttribute(SpellAttr1.CantTargetInCombat))
|
// spells cannot be cast if player is in fake combat also
|
||||||
{
|
if (HasAttribute(SpellAttr1.CantTargetInCombat) && (unitTarget.IsInCombat() || unitTarget.IsPetInCombat()))
|
||||||
if (unitTarget.IsInCombat())
|
return SpellCastResult.TargetAffectingCombat;
|
||||||
return SpellCastResult.TargetAffectingCombat;
|
|
||||||
// player with active pet counts as a player in combat
|
|
||||||
else if (unitTarget.IsTypeId(TypeId.Player))
|
|
||||||
{
|
|
||||||
Pet pet = unitTarget.ToPlayer().GetPet();
|
|
||||||
if (pet)
|
|
||||||
if (pet.GetVictim() && !pet.HasUnitState(UnitState.Controlled))
|
|
||||||
return SpellCastResult.TargetAffectingCombat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// only spells with SPELL_ATTR3_ONLY_TARGET_GHOSTS can target ghosts
|
// only spells with SPELL_ATTR3_ONLY_TARGET_GHOSTS can target ghosts
|
||||||
if (HasAttribute(SpellAttr3.OnlyTargetGhosts) != unitTarget.HasAuraType(AuraType.Ghost))
|
if (HasAttribute(SpellAttr3.OnlyTargetGhosts) != unitTarget.HasAuraType(AuraType.Ghost))
|
||||||
|
|||||||
Reference in New Issue
Block a user