Core/Creatures: Implemented unsummoning and resummoning critter pets on flying mounts and teleports (and related static flags)
Port From (https://github.com/TrinityCore/TrinityCore/commit/f2ce5072d62e2835c4426220ebf8ade5fa67a79b)
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Game.Entities
|
||||
long _lastDamagedTime; // Part of Evade mechanics
|
||||
MultiMap<byte, byte> m_textRepeat = new();
|
||||
|
||||
CreatureStaticFlagsHolder _staticFlags;
|
||||
protected CreatureStaticFlagsHolder _staticFlags;
|
||||
|
||||
// Regenerate health
|
||||
bool _regenerateHealth; // Set on creation
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace Game.Entities
|
||||
MultiMap<uint, uint> m_overrideSpells = new();
|
||||
public Spell m_spellModTakingSpell;
|
||||
uint m_oldpetspell;
|
||||
ObjectGuid m_temporaryUnsummonedBattlePet;
|
||||
Dictionary<uint, StoredAuraTeleportLocation> m_storedAuraTeleportLocations = new();
|
||||
SpellCastRequest _pendingSpellCastRequest;
|
||||
|
||||
|
||||
@@ -667,6 +667,7 @@ namespace Game.Entities
|
||||
StopCastingCharm();
|
||||
StopCastingBindSight();
|
||||
UnsummonPetTemporaryIfAny();
|
||||
UnsummonBattlePetTemporaryIfAny();
|
||||
SetPower(PowerType.ComboPoints, 0);
|
||||
GetSession().DoLootReleaseAll();
|
||||
m_lootRolls.Clear();
|
||||
@@ -1079,6 +1080,35 @@ namespace Game.Entities
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
}
|
||||
|
||||
public void UnsummonBattlePetTemporaryIfAny(bool onFlyingMount = false)
|
||||
{
|
||||
Creature battlepet = GetSummonedBattlePet();
|
||||
if (battlepet == null || !battlepet.IsSummon())
|
||||
return;
|
||||
|
||||
if (onFlyingMount && !battlepet.ToTempSummon().IsDismissedOnFlyingMount())
|
||||
return;
|
||||
|
||||
if (battlepet.ToTempSummon().IsAutoResummoned())
|
||||
m_temporaryUnsummonedBattlePet = battlepet.GetBattlePetCompanionGUID();
|
||||
|
||||
GetSession().GetBattlePetMgr().DismissPet();
|
||||
}
|
||||
|
||||
public void ResummonBattlePetTemporaryUnSummonedIfAny()
|
||||
{
|
||||
if (m_temporaryUnsummonedBattlePet.IsEmpty())
|
||||
return;
|
||||
|
||||
// not resummon in not appropriate state
|
||||
if (IsPetNeedBeTemporaryUnsummoned())
|
||||
return;
|
||||
|
||||
GetSession().GetBattlePetMgr().SummonPet(m_temporaryUnsummonedBattlePet);
|
||||
|
||||
m_temporaryUnsummonedBattlePet.Clear();
|
||||
}
|
||||
|
||||
public bool IsPetNeedBeTemporaryUnsummoned()
|
||||
{
|
||||
return !IsInWorld || !IsAlive() || HasUnitMovementFlag(MovementFlag.Flying) || HasExtraUnitMovementFlag2(MovementFlags3.AdvFlying);
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (IsTrigger() && m_spells[0] != 0)
|
||||
m_ControlledByPlayer = true;
|
||||
|
||||
|
||||
CreatureSummonedData summonedData = Global.ObjectMgr.GetCreatureSummonedData(GetEntry());
|
||||
if (summonedData != null)
|
||||
{
|
||||
@@ -410,12 +410,12 @@ namespace Game.Entities
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override string GetDebugInfo()
|
||||
{
|
||||
return $"{base.GetDebugInfo()}\nTempSummonType : {GetSummonType()} Summoner: {GetSummonerGUID()} Timer: {GetTimer()}";
|
||||
}
|
||||
|
||||
|
||||
public override void SaveToDB(uint mapid, List<Difficulty> spawnDifficulties) { }
|
||||
|
||||
public ObjectGuid GetSummonerGUID() { return m_summonerGUID; }
|
||||
@@ -435,11 +435,31 @@ namespace Game.Entities
|
||||
public uint? GetCreatureIdVisibleToSummoner() { return m_creatureIdVisibleToSummoner; }
|
||||
|
||||
public uint? GetDisplayIdVisibleToSummoner() { return m_displayIdVisibleToSummoner; }
|
||||
|
||||
|
||||
public bool CanFollowOwner() { return m_canFollowOwner; }
|
||||
|
||||
public void SetCanFollowOwner(bool can) { m_canFollowOwner = can; }
|
||||
|
||||
public bool IsDismissedOnFlyingMount()
|
||||
{
|
||||
return !HasFlag(CreatureStaticFlags5.DontDismissOnFlyingMount);
|
||||
}
|
||||
|
||||
public void SetDontDismissOnFlyingMount(bool dontDismissOnFlyingMount)
|
||||
{
|
||||
_staticFlags.ApplyFlag(CreatureStaticFlags5.DontDismissOnFlyingMount, dontDismissOnFlyingMount);
|
||||
}
|
||||
|
||||
public bool IsAutoResummoned()
|
||||
{
|
||||
return !HasFlag(CreatureStaticFlags6.DoNotAutoResummon);
|
||||
}
|
||||
|
||||
public void SetDontAutoResummon(bool dontAutoResummon)
|
||||
{
|
||||
_staticFlags.ApplyFlag(CreatureStaticFlags6.DoNotAutoResummon, dontAutoResummon);
|
||||
}
|
||||
|
||||
public SummonPropertiesRecord m_Properties;
|
||||
TempSummonType m_type;
|
||||
TimeSpan m_timer;
|
||||
|
||||
@@ -1533,6 +1533,7 @@ namespace Game.Entities
|
||||
{
|
||||
player.EnablePetControlsOnDismount();
|
||||
player.ResummonPetTemporaryUnSummonedIfAny();
|
||||
player.ResummonBattlePetTemporaryUnSummonedIfAny();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user