Core/Unit: Store charmer and charmed pointers on Unit directly, no more map lookups for Unit::GetCharmer and Unit::GetCharmed
Port From (https://github.com/TrinityCore/TrinityCore/commit/a5989dcee9150565e7f4b8e3f7a62a414a484a3f)
This commit is contained in:
@@ -1253,7 +1253,7 @@ namespace Game.DungeonFinding
|
|||||||
error = LfgTeleportResult.Exhaustion;
|
error = LfgTeleportResult.Exhaustion;
|
||||||
else if (player.GetVehicle())
|
else if (player.GetVehicle())
|
||||||
error = LfgTeleportResult.OnTransport;
|
error = LfgTeleportResult.OnTransport;
|
||||||
else if (!player.GetCharmGUID().IsEmpty())
|
else if (!player.GetCharmedGUID().IsEmpty())
|
||||||
error = LfgTeleportResult.ImmuneToSummons;
|
error = LfgTeleportResult.ImmuneToSummons;
|
||||||
else if (player.HasAura(9454)) // check Freeze debuff
|
else if (player.HasAura(9454)) // check Freeze debuff
|
||||||
error = LfgTeleportResult.NoReturnLocation;
|
error = LfgTeleportResult.NoReturnLocation;
|
||||||
|
|||||||
@@ -970,7 +970,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public void StopCastingCharm()
|
public void StopCastingCharm()
|
||||||
{
|
{
|
||||||
Unit charm = GetCharm();
|
Unit charm = GetCharmed();
|
||||||
if (!charm)
|
if (!charm)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -981,12 +981,12 @@ namespace Game.Entities
|
|||||||
else if (charm.IsVehicle())
|
else if (charm.IsVehicle())
|
||||||
ExitVehicle();
|
ExitVehicle();
|
||||||
}
|
}
|
||||||
if (!GetCharmGUID().IsEmpty())
|
if (!GetCharmedGUID().IsEmpty())
|
||||||
charm.RemoveCharmAuras();
|
charm.RemoveCharmAuras();
|
||||||
|
|
||||||
if (!GetCharmGUID().IsEmpty())
|
if (!GetCharmedGUID().IsEmpty())
|
||||||
{
|
{
|
||||||
Log.outFatal(LogFilter.Player, "Player {0} (GUID: {1} is not able to uncharm unit (GUID: {2} Entry: {3}, Type: {4})", GetName(), GetGUID(), GetCharmGUID(), charm.GetEntry(), charm.GetTypeId());
|
Log.outFatal(LogFilter.Player, "Player {0} (GUID: {1} is not able to uncharm unit (GUID: {2} Entry: {3}, Type: {4})", GetName(), GetGUID(), GetCharmedGUID(), charm.GetEntry(), charm.GetTypeId());
|
||||||
if (!charm.GetCharmerGUID().IsEmpty())
|
if (!charm.GetCharmerGUID().IsEmpty())
|
||||||
{
|
{
|
||||||
Log.outFatal(LogFilter.Player, "Charmed unit has charmer guid {0}", charm.GetCharmerGUID());
|
Log.outFatal(LogFilter.Player, "Charmed unit has charmer guid {0}", charm.GetCharmerGUID());
|
||||||
@@ -1036,7 +1036,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
public void PossessSpellInitialize()
|
public void PossessSpellInitialize()
|
||||||
{
|
{
|
||||||
Unit charm = GetCharm();
|
Unit charm = GetCharmed();
|
||||||
if (!charm)
|
if (!charm)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ namespace Game.Entities
|
|||||||
base.InitSummon();
|
base.InitSummon();
|
||||||
|
|
||||||
if (GetOwner().IsTypeId(TypeId.Player) && GetOwner().GetMinionGUID() == GetGUID()
|
if (GetOwner().IsTypeId(TypeId.Player) && GetOwner().GetMinionGUID() == GetGUID()
|
||||||
&& GetOwner().GetCharmGUID().IsEmpty())
|
&& GetOwner().GetCharmedGUID().IsEmpty())
|
||||||
{
|
{
|
||||||
GetOwner().ToPlayer().CharmSpellInitialize();
|
GetOwner().ToPlayer().CharmSpellInitialize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ namespace Game.Entities
|
|||||||
//Charm
|
//Charm
|
||||||
public List<Unit> m_Controlled = new();
|
public List<Unit> m_Controlled = new();
|
||||||
List<Player> m_sharedVision = new();
|
List<Player> m_sharedVision = new();
|
||||||
|
Unit m_charmer; // Unit that is charming ME
|
||||||
|
Unit m_charmed; // Unit that is being charmed BY ME
|
||||||
CharmInfo m_charmInfo;
|
CharmInfo m_charmInfo;
|
||||||
protected bool m_ControlledByPlayer;
|
protected bool m_ControlledByPlayer;
|
||||||
public ObjectGuid LastCharmerGUID { get; set; }
|
public ObjectGuid LastCharmerGUID { get; set; }
|
||||||
|
|||||||
@@ -1335,7 +1335,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we have charmed npc, stun him also (everywhere)
|
// if we have charmed npc, stun him also (everywhere)
|
||||||
Unit charm = player.GetCharm();
|
Unit charm = player.GetCharmed();
|
||||||
if (charm)
|
if (charm)
|
||||||
if (charm.GetTypeId() == TypeId.Unit)
|
if (charm.GetTypeId() == TypeId.Unit)
|
||||||
charm.AddUnitFlag(UnitFlags.Stunned);
|
charm.AddUnitFlag(UnitFlags.Stunned);
|
||||||
@@ -1383,7 +1383,7 @@ namespace Game.Entities
|
|||||||
player.ResummonPetTemporaryUnSummonedIfAny();
|
player.ResummonPetTemporaryUnSummonedIfAny();
|
||||||
|
|
||||||
// if we have charmed npc, remove stun also
|
// if we have charmed npc, remove stun also
|
||||||
Unit charm = player.GetCharm();
|
Unit charm = player.GetCharmed();
|
||||||
if (charm)
|
if (charm)
|
||||||
if (charm.GetTypeId() == TypeId.Unit && charm.HasUnitFlag(UnitFlags.Stunned) && !charm.HasUnitState(UnitState.Stunned))
|
if (charm.GetTypeId() == TypeId.Unit && charm.HasUnitFlag(UnitFlags.Stunned) && !charm.HasUnitState(UnitState.Stunned))
|
||||||
charm.RemoveUnitFlag(UnitFlags.Stunned);
|
charm.RemoveUnitFlag(UnitFlags.Stunned);
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
SetMinionGUID(unit.GetGUID());
|
SetMinionGUID(unit.GetGUID());
|
||||||
// show another pet bar if there is no charm bar
|
// show another pet bar if there is no charm bar
|
||||||
if (GetTypeId() == TypeId.Player && GetCharmGUID().IsEmpty())
|
if (GetTypeId() == TypeId.Player && GetCharmedGUID().IsEmpty())
|
||||||
{
|
{
|
||||||
if (unit.IsPet())
|
if (unit.IsPet())
|
||||||
ToPlayer().PetSpellInitialize();
|
ToPlayer().PetSpellInitialize();
|
||||||
@@ -501,7 +501,13 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!IsPlayer() || charmer.IsCreature())
|
if (!IsPlayer() || charmer.IsCreature())
|
||||||
GetAI().OnCharmed(false); // AI will potentially schedule a charm ai update
|
{
|
||||||
|
UnitAI charmedAI = GetAI();
|
||||||
|
if (charmedAI != null)
|
||||||
|
charmedAI.OnCharmed(false); // AI will potentially schedule a charm ai update
|
||||||
|
else
|
||||||
|
ScheduleAIChange();
|
||||||
|
}
|
||||||
|
|
||||||
Player player = ToPlayer();
|
Player player = ToPlayer();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
@@ -545,10 +551,8 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
if (IsTypeId(TypeId.Player))
|
if (IsTypeId(TypeId.Player))
|
||||||
{
|
{
|
||||||
if (GetCharmGUID().IsEmpty())
|
if (!SetCharmedData(charm))
|
||||||
SetCharmGUID(charm.GetGUID());
|
Log.outFatal(LogFilter.Unit, "Player {0} is trying to charm unit {1}, but it already has a charmed unit {2}", GetName(), charm.GetEntry(), GetCharmedGUID());
|
||||||
else
|
|
||||||
Log.outFatal(LogFilter.Unit, "Player {0} is trying to charm unit {1}, but it already has a charmed unit {2}", GetName(), charm.GetEntry(), GetCharmGUID());
|
|
||||||
|
|
||||||
charm.m_ControlledByPlayer = true;
|
charm.m_ControlledByPlayer = true;
|
||||||
// @todo maybe we can use this flag to check if controlled by player
|
// @todo maybe we can use this flag to check if controlled by player
|
||||||
@@ -560,9 +564,7 @@ namespace Game.Entities
|
|||||||
// PvP, FFAPvP
|
// PvP, FFAPvP
|
||||||
charm.SetPvpFlags(GetPvpFlags());
|
charm.SetPvpFlags(GetPvpFlags());
|
||||||
|
|
||||||
if (charm.GetCharmGUID().IsEmpty())
|
if (!charm.SetCharmerData(this))
|
||||||
charm.SetCharmerGUID(GetGUID());
|
|
||||||
else
|
|
||||||
Log.outFatal(LogFilter.Unit, "Unit {0} is being charmed, but it already has a charmer {1}", charm.GetEntry(), charm.GetCharmerGUID());
|
Log.outFatal(LogFilter.Unit, "Unit {0} is being charmed, but it already has a charmer {1}", charm.GetEntry(), charm.GetCharmerGUID());
|
||||||
|
|
||||||
_isWalkingBeforeCharm = charm.IsWalking();
|
_isWalkingBeforeCharm = charm.IsWalking();
|
||||||
@@ -578,15 +580,11 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (IsTypeId(TypeId.Player))
|
if (IsTypeId(TypeId.Player))
|
||||||
{
|
{
|
||||||
if (GetCharmGUID() == charm.GetGUID())
|
if (!ClearCharmedData(charm))
|
||||||
SetCharmGUID(ObjectGuid.Empty);
|
Log.outFatal(LogFilter.Unit, "Player {0} is trying to uncharm unit {1}, but it has another charmed unit {2}", GetName(), charm.GetEntry(), GetCharmedGUID());
|
||||||
else
|
|
||||||
Log.outFatal(LogFilter.Unit, "Player {0} is trying to uncharm unit {1}, but it has another charmed unit {2}", GetName(), charm.GetEntry(), GetCharmGUID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charm.GetCharmerGUID() == GetGUID())
|
if (!charm.ClearCharmerData(this))
|
||||||
charm.SetCharmerGUID(ObjectGuid.Empty);
|
|
||||||
else
|
|
||||||
Log.outFatal(LogFilter.Unit, "Unit {0} is being uncharmed, but it has another charmer {1}", charm.GetEntry(), charm.GetCharmerGUID());
|
Log.outFatal(LogFilter.Unit, "Unit {0} is being uncharmed, but it has another charmer {1}", charm.GetEntry(), charm.GetCharmerGUID());
|
||||||
|
|
||||||
Player player = charm.GetCharmerOrOwnerPlayerOrPlayerItself();
|
Player player = charm.GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||||
@@ -625,7 +623,7 @@ namespace Game.Entities
|
|||||||
public Unit GetFirstControlled()
|
public Unit GetFirstControlled()
|
||||||
{
|
{
|
||||||
// Sequence: charmed, pet, other guardians
|
// Sequence: charmed, pet, other guardians
|
||||||
Unit unit = GetCharm();
|
Unit unit = GetCharmed();
|
||||||
if (!unit)
|
if (!unit)
|
||||||
{
|
{
|
||||||
ObjectGuid guid = GetMinionGUID();
|
ObjectGuid guid = GetMinionGUID();
|
||||||
@@ -665,8 +663,8 @@ namespace Game.Entities
|
|||||||
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its pet {1}", GetEntry(), GetPetGUID());
|
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its pet {1}", GetEntry(), GetPetGUID());
|
||||||
if (!GetMinionGUID().IsEmpty())
|
if (!GetMinionGUID().IsEmpty())
|
||||||
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its minion {1}", GetEntry(), GetMinionGUID());
|
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its minion {1}", GetEntry(), GetMinionGUID());
|
||||||
if (!GetCharmGUID().IsEmpty())
|
if (!GetCharmedGUID().IsEmpty())
|
||||||
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its charm {1}", GetEntry(), GetCharmGUID());
|
Log.outFatal(LogFilter.Unit, "Unit {0} is not able to release its charm {1}", GetEntry(), GetCharmedGUID());
|
||||||
if (!IsPet()) // pets don't use the flag for this
|
if (!IsPet()) // pets don't use the flag for this
|
||||||
RemoveUnitFlag(UnitFlags.PetInCombat); // m_controlled is now empty, so we know none of our minions are in combat
|
RemoveUnitFlag(UnitFlags.PetInCombat); // m_controlled is now empty, so we know none of our minions are in combat
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -465,10 +465,12 @@ namespace Game.Entities
|
|||||||
|
|
||||||
RemoveAllFollowers();
|
RemoveAllFollowers();
|
||||||
|
|
||||||
if (!GetCharmerGUID().IsEmpty())
|
if (IsCharmed())
|
||||||
{
|
RemoveCharmedBy(null);
|
||||||
Log.outFatal(LogFilter.Unit, "Unit {0} has charmer guid when removed from world", GetEntry());
|
|
||||||
}
|
Cypher.Assert(!GetCharmedGUID().IsEmpty(), $"Unit {GetEntry()} has charmed guid when removed from world");
|
||||||
|
Cypher.Assert(!GetCharmerGUID().IsEmpty(), $"Unit {GetEntry()} has charmer guid when removed from world");
|
||||||
|
|
||||||
Unit owner = GetOwner();
|
Unit owner = GetOwner();
|
||||||
if (owner != null)
|
if (owner != null)
|
||||||
{
|
{
|
||||||
@@ -665,7 +667,7 @@ namespace Game.Entities
|
|||||||
if (m_gameObj.Empty())
|
if (m_gameObj.Empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (var i =0; i < m_gameObj.Count; ++i)
|
for (var i = 0; i < m_gameObj.Count; ++i)
|
||||||
{
|
{
|
||||||
var obj = m_gameObj[i];
|
var obj = m_gameObj[i];
|
||||||
if (spellid == 0 || obj.GetSpellId() == spellid)
|
if (spellid == 0 || obj.GetSpellId() == spellid)
|
||||||
@@ -797,7 +799,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHoverHeight(float hoverHeight) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.HoverHeight), hoverHeight); }
|
public void SetHoverHeight(float hoverHeight) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.HoverHeight), hoverHeight); }
|
||||||
|
|
||||||
public override float GetCollisionHeight()
|
public override float GetCollisionHeight()
|
||||||
@@ -1209,31 +1211,17 @@ namespace Game.Entities
|
|||||||
AIUpdateTick(0, true);
|
AIUpdateTick(0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool IsPossessing()
|
public bool IsPossessing()
|
||||||
{
|
{
|
||||||
Unit u = GetCharm();
|
Unit u = GetCharmed();
|
||||||
if (u != null)
|
if (u != null)
|
||||||
return u.IsPossessed();
|
return u.IsPossessed();
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public Unit GetCharm()
|
|
||||||
{
|
|
||||||
ObjectGuid charm_guid = GetCharmGUID();
|
|
||||||
if (!charm_guid.IsEmpty())
|
|
||||||
{
|
|
||||||
Unit pet = Global.ObjAccessor.GetUnit(this, charm_guid);
|
|
||||||
if (pet != null)
|
|
||||||
return pet;
|
|
||||||
|
|
||||||
Log.outError(LogFilter.Unit, "Unit.GetCharm: Charmed creature {0} not exist.", charm_guid);
|
|
||||||
SetCharmGUID(ObjectGuid.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public bool IsCharmed() { return !GetCharmerGUID().IsEmpty(); }
|
public bool IsCharmed() { return !GetCharmerGUID().IsEmpty(); }
|
||||||
|
|
||||||
public bool IsPossessed() { return HasUnitState(UnitState.Possessed); }
|
public bool IsPossessed() { return HasUnitState(UnitState.Possessed); }
|
||||||
|
|
||||||
public void OnPhaseChange()
|
public void OnPhaseChange()
|
||||||
@@ -1498,7 +1486,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
bool HasInterruptFlag(SpellAuraInterruptFlags flags) { return m_interruptMask.HasAnyFlag(flags); }
|
bool HasInterruptFlag(SpellAuraInterruptFlags flags) { return m_interruptMask.HasAnyFlag(flags); }
|
||||||
bool HasInterruptFlag(SpellAuraInterruptFlags2 flags) { return m_interruptMask2.HasAnyFlag(flags); }
|
bool HasInterruptFlag(SpellAuraInterruptFlags2 flags) { return m_interruptMask2.HasAnyFlag(flags); }
|
||||||
|
|
||||||
public void AddInterruptMask(SpellAuraInterruptFlags flags, SpellAuraInterruptFlags2 flags2)
|
public void AddInterruptMask(SpellAuraInterruptFlags flags, SpellAuraInterruptFlags2 flags2)
|
||||||
{
|
{
|
||||||
m_interruptMask |= flags;
|
m_interruptMask |= flags;
|
||||||
@@ -1567,44 +1555,44 @@ namespace Game.Entities
|
|||||||
displayPower = PowerType.Mana;
|
displayPower = PowerType.Mana;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
var powerTypeAuras = GetAuraEffectsByType(AuraType.ModPowerDisplay);
|
||||||
|
if (!powerTypeAuras.Empty())
|
||||||
{
|
{
|
||||||
var powerTypeAuras = GetAuraEffectsByType(AuraType.ModPowerDisplay);
|
AuraEffect powerTypeAura = powerTypeAuras.First();
|
||||||
if (!powerTypeAuras.Empty())
|
displayPower = (PowerType)powerTypeAura.GetMiscValue();
|
||||||
|
}
|
||||||
|
else if (GetTypeId() == TypeId.Player)
|
||||||
|
{
|
||||||
|
ChrClassesRecord cEntry = CliDB.ChrClassesStorage.LookupByKey(GetClass());
|
||||||
|
if (cEntry != null && cEntry.DisplayPower < PowerType.Max)
|
||||||
|
displayPower = cEntry.DisplayPower;
|
||||||
|
}
|
||||||
|
else if (GetTypeId() == TypeId.Unit)
|
||||||
|
{
|
||||||
|
Vehicle vehicle = GetVehicleKit();
|
||||||
|
if (vehicle)
|
||||||
{
|
{
|
||||||
AuraEffect powerTypeAura = powerTypeAuras.First();
|
PowerDisplayRecord powerDisplay = CliDB.PowerDisplayStorage.LookupByKey(vehicle.GetVehicleInfo().PowerDisplayID[0]);
|
||||||
displayPower = (PowerType)powerTypeAura.GetMiscValue();
|
if (powerDisplay != null)
|
||||||
|
displayPower = (PowerType)powerDisplay.ActualType;
|
||||||
|
else if (GetClass() == Class.Rogue)
|
||||||
|
displayPower = PowerType.Energy;
|
||||||
}
|
}
|
||||||
else if (GetTypeId() == TypeId.Player)
|
else
|
||||||
{
|
{
|
||||||
ChrClassesRecord cEntry = CliDB.ChrClassesStorage.LookupByKey(GetClass());
|
Pet pet = ToPet();
|
||||||
if (cEntry != null && cEntry.DisplayPower < PowerType.Max)
|
if (pet)
|
||||||
displayPower = cEntry.DisplayPower;
|
|
||||||
}
|
|
||||||
else if (GetTypeId() == TypeId.Unit)
|
|
||||||
{
|
|
||||||
Vehicle vehicle = GetVehicleKit();
|
|
||||||
if (vehicle)
|
|
||||||
{
|
{
|
||||||
PowerDisplayRecord powerDisplay = CliDB.PowerDisplayStorage.LookupByKey(vehicle.GetVehicleInfo().PowerDisplayID[0]);
|
if (pet.GetPetType() == PetType.Hunter) // Hunter pets have focus
|
||||||
if (powerDisplay != null)
|
displayPower = PowerType.Focus;
|
||||||
displayPower = (PowerType)powerDisplay.ActualType;
|
else if (pet.IsPetGhoul() || pet.IsPetAbomination()) // DK pets have energy
|
||||||
else if (GetClass() == Class.Rogue)
|
|
||||||
displayPower = PowerType.Energy;
|
displayPower = PowerType.Energy;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Pet pet = ToPet();
|
|
||||||
if (pet)
|
|
||||||
{
|
|
||||||
if (pet.GetPetType() == PetType.Hunter) // Hunter pets have focus
|
|
||||||
displayPower = PowerType.Focus;
|
|
||||||
else if (pet.IsPetGhoul() || pet.IsPetAbomination()) // DK pets have energy
|
|
||||||
displayPower = PowerType.Energy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPowerType(displayPower);
|
SetPowerType(displayPower);
|
||||||
@@ -1848,7 +1836,7 @@ namespace Game.Entities
|
|||||||
public void SetMountDisplayId(uint mountDisplayId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.MountDisplayID), mountDisplayId); }
|
public void SetMountDisplayId(uint mountDisplayId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.MountDisplayID), mountDisplayId); }
|
||||||
uint GetCosmeticMountDisplayId() { return m_unitData.CosmeticMountDisplayID; }
|
uint GetCosmeticMountDisplayId() { return m_unitData.CosmeticMountDisplayID; }
|
||||||
public void SetCosmeticMountDisplayId(uint mountDisplayId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CosmeticMountDisplayID), mountDisplayId); }
|
public void SetCosmeticMountDisplayId(uint mountDisplayId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CosmeticMountDisplayID), mountDisplayId); }
|
||||||
|
|
||||||
public virtual float GetFollowAngle() { return MathFunctions.PiOver2; }
|
public virtual float GetFollowAngle() { return MathFunctions.PiOver2; }
|
||||||
|
|
||||||
public override ObjectGuid GetOwnerGUID() { return m_unitData.SummonedBy; }
|
public override ObjectGuid GetOwnerGUID() { return m_unitData.SummonedBy; }
|
||||||
@@ -1876,10 +1864,6 @@ namespace Game.Entities
|
|||||||
public void SetCreatorGUID(ObjectGuid creator) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CreatedBy), creator); }
|
public void SetCreatorGUID(ObjectGuid creator) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CreatedBy), creator); }
|
||||||
public ObjectGuid GetMinionGUID() { return m_unitData.Summon; }
|
public ObjectGuid GetMinionGUID() { return m_unitData.Summon; }
|
||||||
public void SetMinionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Summon), guid); }
|
public void SetMinionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Summon), guid); }
|
||||||
public ObjectGuid GetCharmerGUID() { return m_unitData.CharmedBy; }
|
|
||||||
public void SetCharmerGUID(ObjectGuid owner) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CharmedBy), owner); }
|
|
||||||
public ObjectGuid GetCharmGUID() { return m_unitData.Charm; }
|
|
||||||
public void SetCharmGUID(ObjectGuid charm) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Charm), charm); }
|
|
||||||
public ObjectGuid GetPetGUID() { return m_SummonSlot[0]; }
|
public ObjectGuid GetPetGUID() { return m_SummonSlot[0]; }
|
||||||
public void SetPetGUID(ObjectGuid guid) { m_SummonSlot[0] = guid; }
|
public void SetPetGUID(ObjectGuid guid) { m_SummonSlot[0] = guid; }
|
||||||
public ObjectGuid GetCritterGUID() { return m_unitData.Critter; }
|
public ObjectGuid GetCritterGUID() { return m_unitData.Critter; }
|
||||||
@@ -1887,9 +1871,53 @@ namespace Game.Entities
|
|||||||
public ObjectGuid GetBattlePetCompanionGUID() { return m_unitData.BattlePetCompanionGUID; }
|
public ObjectGuid GetBattlePetCompanionGUID() { return m_unitData.BattlePetCompanionGUID; }
|
||||||
public void SetBattlePetCompanionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.BattlePetCompanionGUID), guid); }
|
public void SetBattlePetCompanionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.BattlePetCompanionGUID), guid); }
|
||||||
|
|
||||||
public void SetWildBattlePetLevel(uint wildBattlePetLevel) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.WildBattlePetLevel), wildBattlePetLevel); }
|
public bool SetCharmerData(Unit unit)
|
||||||
public uint GetWildBattlePetLevel() { return m_unitData.WildBattlePetLevel; }
|
{
|
||||||
|
if (!GetCharmerGUID().IsEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CharmedBy), unit.GetGUID());
|
||||||
|
m_charmer = unit;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ClearCharmerData(Unit verify)
|
||||||
|
{
|
||||||
|
if (GetCharmerGUID() != verify.GetGUID())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.CharmedBy), ObjectGuid.Empty);
|
||||||
|
m_charmer = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectGuid GetCharmerGUID() { return m_unitData.CharmedBy; }
|
||||||
|
|
||||||
|
public Unit GetCharmer() { return m_charmer; }
|
||||||
|
|
||||||
|
public bool SetCharmedData(Unit unit)
|
||||||
|
{
|
||||||
|
if (!GetCharmedGUID().IsEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_charmed = unit;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ClearCharmedData(Unit verify)
|
||||||
|
{
|
||||||
|
if (GetCharmedGUID() != verify.GetGUID())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Charm), ObjectGuid.Empty);
|
||||||
|
m_charmed = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectGuid GetCharmedGUID() { return m_unitData.Charm; }
|
||||||
|
|
||||||
|
public Unit GetCharmed() { return m_charmed; }
|
||||||
|
|
||||||
public override ObjectGuid GetCharmerOrOwnerGUID()
|
public override ObjectGuid GetCharmerOrOwnerGUID()
|
||||||
{
|
{
|
||||||
return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID();
|
return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID();
|
||||||
@@ -1909,20 +1937,15 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
return ToPlayer();
|
return ToPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unit GetCharmer()
|
|
||||||
{
|
|
||||||
ObjectGuid charmerid = GetCharmerGUID();
|
|
||||||
if (!charmerid.IsEmpty())
|
|
||||||
return Global.ObjAccessor.GetUnit(this, charmerid);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Unit GetCharmerOrOwner()
|
public override Unit GetCharmerOrOwner()
|
||||||
{
|
{
|
||||||
return !GetCharmerGUID().IsEmpty() ? GetCharmer() : GetOwner();
|
return IsCharmed() ? GetCharmer() : GetOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetWildBattlePetLevel(uint wildBattlePetLevel) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.WildBattlePetLevel), wildBattlePetLevel); }
|
||||||
|
public uint GetWildBattlePetLevel() { return m_unitData.WildBattlePetLevel; }
|
||||||
|
|
||||||
public bool HasUnitFlag(UnitFlags flags) { return (m_unitData.Flags & (uint)flags) != 0; }
|
public bool HasUnitFlag(UnitFlags flags) { return (m_unitData.Flags & (uint)flags) != 0; }
|
||||||
public void AddUnitFlag(UnitFlags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Flags), (uint)flags); }
|
public void AddUnitFlag(UnitFlags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Flags), (uint)flags); }
|
||||||
public void RemoveUnitFlag(UnitFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Flags), (uint)flags); }
|
public void RemoveUnitFlag(UnitFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Flags), (uint)flags); }
|
||||||
@@ -2823,7 +2846,6 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long ModifyHealth(long dVal)
|
public long ModifyHealth(long dVal)
|
||||||
{
|
{
|
||||||
long gain = 0;
|
long gain = 0;
|
||||||
@@ -2865,6 +2887,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetHealthGain(long dVal)
|
public long GetHealthGain(long dVal)
|
||||||
{
|
{
|
||||||
long gain = 0;
|
long gain = 0;
|
||||||
@@ -3095,7 +3118,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
public uint GetComboPoints() { return (uint)GetPower(PowerType.ComboPoints); }
|
public uint GetComboPoints() { return (uint)GetPower(PowerType.ComboPoints); }
|
||||||
|
|
||||||
public void AddComboPoints(sbyte count, Spell spell = null)
|
public void AddComboPoints(sbyte count, Spell spell = null)
|
||||||
{
|
{
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pet != GetPlayer().GetPet() && pet != GetPlayer().GetCharm())
|
if (pet != GetPlayer().GetPet() && pet != GetPlayer().GetCharmed())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Network, "HandlePetStopAttack: {0} isn't a pet or charmed creature of player {1}", packet.PetGUID.ToString(), GetPlayer().GetName());
|
Log.outError(LogFilter.Network, "HandlePetStopAttack: {0} isn't a pet or charmed creature of player {1}", packet.PetGUID.ToString(), GetPlayer().GetName());
|
||||||
return;
|
return;
|
||||||
@@ -609,7 +609,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pet != GetPlayer().GetGuardianPet() && pet != GetPlayer().GetCharm())
|
if (pet != GetPlayer().GetGuardianPet() && pet != GetPlayer().GetCharmed())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Network, "WorldSession.HandlePetSpellAutocast: {0} isn't pet of player {1} ({2}).",
|
Log.outError(LogFilter.Network, "WorldSession.HandlePetSpellAutocast: {0} isn't pet of player {1} ({2}).",
|
||||||
packet.PetGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString());
|
packet.PetGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString());
|
||||||
@@ -660,7 +660,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This opcode is also sent from charmed and possessed units (players and creatures)
|
// This opcode is also sent from charmed and possessed units (players and creatures)
|
||||||
if (caster != GetPlayer().GetGuardianPet() && caster != GetPlayer().GetCharm())
|
if (caster != GetPlayer().GetGuardianPet() && caster != GetPlayer().GetCharmed())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: {0} isn't pet of player {1} ({2}).", petCastSpell.PetGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString());
|
Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: {0} isn't pet of player {1} ({2}).", petCastSpell.PetGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pet != GetPlayer().GetGuardianPet() && pet != GetPlayer().GetCharm())
|
if (pet != GetPlayer().GetGuardianPet() && pet != GetPlayer().GetCharmed())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Network, "HandlePetCancelAura: {0} is not a pet of player '{1}'", packet.PetGUID.ToString(), GetPlayer().GetName());
|
Log.outError(LogFilter.Network, "HandlePetCancelAura: {0} is not a pet of player '{1}'", packet.PetGUID.ToString(), GetPlayer().GetName());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Game
|
|||||||
[WorldPacketHandler(ClientOpcodes.MoveDismissVehicle, Processing = PacketProcessing.ThreadSafe)]
|
[WorldPacketHandler(ClientOpcodes.MoveDismissVehicle, Processing = PacketProcessing.ThreadSafe)]
|
||||||
void HandleMoveDismissVehicle(MoveDismissVehicle packet)
|
void HandleMoveDismissVehicle(MoveDismissVehicle packet)
|
||||||
{
|
{
|
||||||
ObjectGuid vehicleGUID = GetPlayer().GetCharmGUID();
|
ObjectGuid vehicleGUID = GetPlayer().GetCharmedGUID();
|
||||||
if (vehicleGUID.IsEmpty()) // something wrong here...
|
if (vehicleGUID.IsEmpty()) // something wrong here...
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -3158,7 +3158,7 @@ namespace Game.Spells
|
|||||||
// Unsummon summon as possessed creatures on spell cancel
|
// Unsummon summon as possessed creatures on spell cancel
|
||||||
if (m_spellInfo.IsChanneled() && unitCaster.IsTypeId(TypeId.Player))
|
if (m_spellInfo.IsChanneled() && unitCaster.IsTypeId(TypeId.Player))
|
||||||
{
|
{
|
||||||
Unit charm = unitCaster.GetCharm();
|
Unit charm = unitCaster.GetCharmed();
|
||||||
if (charm != null)
|
if (charm != null)
|
||||||
if (charm.IsTypeId(TypeId.Unit) && charm.ToCreature().HasUnitTypeMask(UnitTypeMask.Puppet)
|
if (charm.IsTypeId(TypeId.Unit) && charm.ToCreature().HasUnitTypeMask(UnitTypeMask.Puppet)
|
||||||
&& charm.m_unitData.CreatedBySpell == m_spellInfo.Id)
|
&& charm.m_unitData.CreatedBySpell == m_spellInfo.Id)
|
||||||
@@ -5032,7 +5032,7 @@ namespace Game.Spells
|
|||||||
return SpellCastResult.AlreadyHaveSummon;
|
return SpellCastResult.AlreadyHaveSummon;
|
||||||
goto case SummonCategory.Puppet;
|
goto case SummonCategory.Puppet;
|
||||||
case SummonCategory.Puppet:
|
case SummonCategory.Puppet:
|
||||||
if (!unitCaster.GetCharmGUID().IsEmpty())
|
if (!unitCaster.GetCharmedGUID().IsEmpty())
|
||||||
return SpellCastResult.AlreadyHaveCharm;
|
return SpellCastResult.AlreadyHaveCharm;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5073,7 +5073,7 @@ namespace Game.Spells
|
|||||||
return SpellCastResult.AlreadyHaveSummon;
|
return SpellCastResult.AlreadyHaveSummon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unitCaster.GetCharmGUID().IsEmpty())
|
if (!unitCaster.GetCharmedGUID().IsEmpty())
|
||||||
return SpellCastResult.AlreadyHaveCharm;
|
return SpellCastResult.AlreadyHaveCharm;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5281,7 +5281,7 @@ namespace Game.Spells
|
|||||||
if (!m_spellInfo.HasAttribute(SpellAttr1.DismissPet) && !unitCaster1.GetPetGUID().IsEmpty())
|
if (!m_spellInfo.HasAttribute(SpellAttr1.DismissPet) && !unitCaster1.GetPetGUID().IsEmpty())
|
||||||
return SpellCastResult.AlreadyHaveSummon;
|
return SpellCastResult.AlreadyHaveSummon;
|
||||||
|
|
||||||
if (!unitCaster1.GetCharmGUID().IsEmpty())
|
if (!unitCaster1.GetCharmedGUID().IsEmpty())
|
||||||
return SpellCastResult.AlreadyHaveCharm;
|
return SpellCastResult.AlreadyHaveCharm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ namespace Scripts.Spells.Hunter
|
|||||||
if (!caster.GetPetGUID().IsEmpty())
|
if (!caster.GetPetGUID().IsEmpty())
|
||||||
return SpellCastResult.AlreadyHaveSummon;
|
return SpellCastResult.AlreadyHaveSummon;
|
||||||
|
|
||||||
if (!caster.GetCharmGUID().IsEmpty())
|
if (!caster.GetCharmedGUID().IsEmpty())
|
||||||
return SpellCastResult.AlreadyHaveCharm;
|
return SpellCastResult.AlreadyHaveCharm;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user