Core/Spells: Implemented SummonPropertiesFlags: UseSummonerFaction & IgnoreSummonerPhase

Port From (https://github.com/TrinityCore/TrinityCore/commit/a832435b9787c1997da87a124ff99bf06251aa07)
This commit is contained in:
hondacrx
2021-11-16 13:23:42 -05:00
parent a7936eb46c
commit 3ab092a655
7 changed files with 101 additions and 84 deletions
+3 -1
View File
@@ -588,6 +588,8 @@ namespace Game.DataStorage
public uint Faction;
public SummonTitle Title;
public int Slot;
public SummonPropFlags Flags;
public uint Flags;
public SummonPropertiesFlags GetFlags() { return (SummonPropertiesFlags)Flags; }
}
}
+8 -6
View File
@@ -171,7 +171,6 @@ namespace Game.Entities
if (owner != null && IsTrigger() && m_spells[0] != 0)
{
SetFaction(owner.GetFaction());
SetLevel(owner.GetLevel());
if (owner.IsTypeId(TypeId.Player))
m_ControlledByPlayer = true;
@@ -196,10 +195,13 @@ namespace Game.Entities
}
}
if (m_Properties.Faction != 0)
SetFaction(m_Properties.Faction);
else if (IsVehicle() && owner != null) // properties should be vehicle
SetFaction(owner.GetFaction());
uint faction = m_Properties.Faction;
if (m_Properties.GetFlags().HasFlag(SummonPropertiesFlags.UseSummonerFaction)) // TODO: Determine priority between faction and flag
if (owner)
faction = owner.GetFaction();
if (faction != 0)
SetFaction(faction);
}
public virtual void InitSummon()
@@ -307,7 +309,7 @@ namespace Game.Entities
SetReactState(ReactStates.Passive);
SetCreatorGUID(GetOwner().GetGUID());
SetFaction(GetOwner().GetFaction());
SetFaction(GetOwner().GetFaction());// TODO: Is this correct? Overwrite the use of SummonPropertiesFlags::UseSummonerFaction
GetOwner().SetMinion(this, true);
}
+38 -34
View File
@@ -217,7 +217,7 @@ namespace Game.Entities
Global.ScriptMgr.OnRelocate(this, _currentFrame.Node.NodeIndex, _currentFrame.Node.ContinentID, _currentFrame.Node.Loc.X, _currentFrame.Node.Loc.Y, _currentFrame.Node.Loc.Z);
Log.outDebug(LogFilter.Transport, "Transport {0} ({1}) moved to node {2} {3} {4} {5} {6}", GetEntry(), GetName(), _currentFrame.Node.NodeIndex, _currentFrame.Node.ContinentID,
Log.outDebug(LogFilter.Transport, "Transport {0} ({1}) moved to node {2} {3} {4} {5} {6}", GetEntry(), GetName(), _currentFrame.Node.NodeIndex, _currentFrame.Node.ContinentID,
_currentFrame.Node.Loc.X, _currentFrame.Node.Loc.Y, _currentFrame.Node.Loc.Z);
// Departure event
@@ -418,32 +418,32 @@ namespace Game.Entities
case SummonCategory.Wild:
case SummonCategory.Ally:
case SummonCategory.Unk:
{
switch (properties.Title)
{
switch (properties.Title)
{
case SummonTitle.Minion:
case SummonTitle.Guardian:
case SummonTitle.Runeblade:
case SummonTitle.Minion:
case SummonTitle.Guardian:
case SummonTitle.Runeblade:
mask = UnitTypeMask.Guardian;
break;
case SummonTitle.Totem:
case SummonTitle.LightWell:
mask = UnitTypeMask.Totem;
break;
case SummonTitle.Vehicle:
case SummonTitle.Mount:
mask = UnitTypeMask.Summon;
break;
case SummonTitle.Companion:
mask = UnitTypeMask.Minion;
break;
default:
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.JoinSummonerSpawnGroup)) // Mirror Image, Summon Gargoyle
mask = UnitTypeMask.Guardian;
break;
case SummonTitle.Totem:
case SummonTitle.LightWell:
mask = UnitTypeMask.Totem;
break;
case SummonTitle.Vehicle:
case SummonTitle.Mount:
mask = UnitTypeMask.Summon;
break;
case SummonTitle.Companion:
mask = UnitTypeMask.Minion;
break;
default:
if (properties.Flags.HasAnyFlag(SummonPropFlags.Unk10)) // Mirror Image, Summon Gargoyle
mask = UnitTypeMask.Guardian;
break;
}
break;
break;
}
break;
}
default:
return null;
}
@@ -476,7 +476,11 @@ namespace Game.Entities
if (!summon.Create(map.GenerateLowGuid(HighGuid.Creature), map, entry, new Position(x, y, z, o), null, vehId))
return null;
PhasingHandler.InheritPhaseShift(summon, summoner ? (WorldObject)summoner : this);
WorldObject phaseShiftOwner = this;
if (summoner != null && !(properties != null && properties.GetFlags().HasFlag(SummonPropertiesFlags.IgnoreSummonerPhase)))
phaseShiftOwner = summoner;
PhasingHandler.InheritPhaseShift(summon, phaseShiftOwner);
summon.SetCreatedBySpell(spellId);
@@ -674,7 +678,7 @@ namespace Game.Entities
z = nextFrame.Node.Loc.Z,
o = nextFrame.InitialOrientation;
foreach(WorldObject obj in _passengers.ToList())
foreach (WorldObject obj in _passengers.ToList())
{
float destX, destY, destZ, destO;
obj.m_movementInfo.transport.pos.GetPosition(out destX, out destY, out destZ, out destO);
@@ -723,14 +727,14 @@ namespace Game.Entities
switch (passenger.GetTypeId())
{
case TypeId.Unit:
{
Creature creature = passenger.ToCreature();
GetMap().CreatureRelocation(creature, x, y, z, o, false);
creature.GetTransportHomePosition(out x, out y, out z, out o);
CalculatePassengerPosition(ref x, ref y, ref z, ref o);
creature.SetHomePosition(x, y, z, o);
break;
}
{
Creature creature = passenger.ToCreature();
GetMap().CreatureRelocation(creature, x, y, z, o, false);
creature.GetTransportHomePosition(out x, out y, out z, out o);
CalculatePassengerPosition(ref x, ref y, ref z, ref o);
creature.SetHomePosition(x, y, z, o);
break;
}
case TypeId.Player:
if (passenger.IsInWorld && !passenger.ToPlayer().IsBeingTeleported())
{
+2 -2
View File
@@ -3979,7 +3979,7 @@ namespace Game.Maps
mask = UnitTypeMask.Minion;
break;
default:
if (Convert.ToBoolean(properties.Flags & SummonPropFlags.Unk10)) // Mirror Image, Summon Gargoyle
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.JoinSummonerSpawnGroup)) // Mirror Image, Summon Gargoyle
mask = UnitTypeMask.Guardian;
break;
}
@@ -4016,7 +4016,7 @@ namespace Game.Maps
return null;
// Set the summon to the summoner's phase
if (summoner)
if (summoner != null && !(properties != null && properties.GetFlags().HasFlag(SummonPropertiesFlags.IgnoreSummonerPhase)))
PhasingHandler.InheritPhaseShift(summon, summoner);
summon.SetCreatedBySpell(spellId);
+13 -14
View File
@@ -1602,13 +1602,13 @@ namespace Game.Spells
caster = m_originalCaster;
ObjectGuid privateObjectOwner = caster.GetGUID();
if (!properties.Flags.HasAnyFlag(SummonPropFlags.PersonalSpawn | SummonPropFlags.PersonalGroupSpawn))
if (!properties.GetFlags().HasAnyFlag(SummonPropertiesFlags.OnlyVisibleToSummoner | SummonPropertiesFlags.OnlyVisibleToSummonerGroup))
privateObjectOwner = ObjectGuid.Empty;
if (caster.IsPrivateObject())
privateObjectOwner = caster.GetPrivateObjectOwner();
if (properties.Flags.HasAnyFlag(SummonPropFlags.PersonalGroupSpawn))
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.OnlyVisibleToSummonerGroup))
if (caster.IsPlayer() && m_originalCaster.ToPlayer().GetGroup())
privateObjectOwner = caster.ToPlayer().GetGroup().GetGUID();
@@ -1652,7 +1652,7 @@ namespace Game.Spells
case SummonCategory.Wild:
case SummonCategory.Ally:
case SummonCategory.Unk:
if (Convert.ToBoolean(properties.Flags & SummonPropFlags.Unk10))
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.JoinSummonerSpawnGroup))
{
SummonGuardian(effectInfo, entry, properties, numSummons, privateObjectOwner);
break;
@@ -1730,11 +1730,19 @@ namespace Game.Spells
continue;
if (properties.Control == SummonCategory.Ally)
{
summon.SetOwnerGUID(caster.GetGUID());
summon.SetFaction(caster.GetFaction());
uint faction = properties.Faction;
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.UseSummonerFaction)) // TODO: Determine priority between faction and flag
{
Unit summoner = summon.GetSummoner();
if (summoner != null)
faction = summoner.GetFaction();
}
if (faction != 0)
summon.SetFaction(faction);
ExecuteLogEffectSummonObject(effectInfo.Effect, summon);
}
return;
@@ -1781,12 +1789,6 @@ namespace Game.Spells
args.AddSpellMod(SpellValueMod.BasePoint0, basePoints);
unitCaster.CastSpell(summon, spellId, args);
uint faction = properties.Faction;
if (faction == 0)
faction = unitCaster.GetFaction();
summon.SetFaction(faction);
break;
}
}
@@ -4873,9 +4875,6 @@ namespace Game.Spells
if (summon.HasUnitTypeMask(UnitTypeMask.Guardian))
((Guardian)summon).InitStatsForLevel(level);
if (properties != null && properties.Control == SummonCategory.Ally)
summon.SetFaction(unitCaster.GetFaction());
if (summon.HasUnitTypeMask(UnitTypeMask.Minion) && m_targets.HasDst())
((Minion)summon).SetFollowAngle(unitCaster.GetAbsoluteAngle(summon.GetPosition()));
+1 -1
View File
@@ -2191,7 +2191,7 @@ namespace Game.Entities
var summonProperties = CliDB.SummonPropertiesStorage.LookupByKey(effect.EffectMiscValue[1]);
if (summonProperties != null)
{
if (summonProperties.Slot == (int)SummonSlot.MiniPet && summonProperties.Flags.HasAnyFlag(SummonPropFlags.Companion))
if (summonProperties.Slot == (int)SummonSlot.MiniPet && summonProperties.GetFlags().HasFlag(SummonPropertiesFlags.SummonFromBattlePetJournal))
{
var battlePetSpecies = battlePetSpeciesByCreature.LookupByKey(effect.EffectMiscValue[0]);
if (battlePetSpecies != null)