Core/Spells: Replace SpellTargetPosition structure with WorldLocation
Port From (https://github.com/TrinityCore/TrinityCore/commit/0e36fd93601f10949c848c1fc30ee3b70f2cecfa)
This commit is contained in:
@@ -3223,7 +3223,7 @@ namespace Game.Entities
|
|||||||
public float GetTransOffsetY() { return m_movementInfo.transport.pos.GetPositionY(); }
|
public float GetTransOffsetY() { return m_movementInfo.transport.pos.GetPositionY(); }
|
||||||
public float GetTransOffsetZ() { return m_movementInfo.transport.pos.GetPositionZ(); }
|
public float GetTransOffsetZ() { return m_movementInfo.transport.pos.GetPositionZ(); }
|
||||||
public float GetTransOffsetO() { return m_movementInfo.transport.pos.GetOrientation(); }
|
public float GetTransOffsetO() { return m_movementInfo.transport.pos.GetOrientation(); }
|
||||||
Position GetTransOffset() { return m_movementInfo.transport.pos; }
|
public Position GetTransOffset() { return m_movementInfo.transport.pos; }
|
||||||
public uint GetTransTime() { return m_movementInfo.transport.time; }
|
public uint GetTransTime() { return m_movementInfo.transport.time; }
|
||||||
public sbyte GetTransSeat() { return m_movementInfo.transport.seat; }
|
public sbyte GetTransSeat() { return m_movementInfo.transport.seat; }
|
||||||
public virtual ObjectGuid GetTransGUID()
|
public virtual ObjectGuid GetTransGUID()
|
||||||
|
|||||||
+20
-30
@@ -654,12 +654,12 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
if (targetType.GetTarget() == Targets.DestNearbyEntryOrDB)
|
if (targetType.GetTarget() == Targets.DestNearbyEntryOrDB)
|
||||||
{
|
{
|
||||||
SpellTargetPosition st = Global.SpellMgr.GetSpellTargetPosition(m_spellInfo.Id, spellEffectInfo.EffectIndex);
|
WorldLocation st = Global.SpellMgr.GetSpellTargetPosition(m_spellInfo.Id, spellEffectInfo.EffectIndex);
|
||||||
if (st != null)
|
if (st != null)
|
||||||
{
|
{
|
||||||
SpellDestination dest = new(m_caster);
|
SpellDestination dest = new(m_caster);
|
||||||
if (st.target_mapId == m_caster.GetMapId() && m_caster.IsInDist(st.target_X, st.target_Y, st.target_Z, range))
|
if (st.GetMapId() == m_caster.GetMapId() && m_caster.IsInDist(st, range))
|
||||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation);
|
dest = new(st.GetPosition());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float randomRadius1 = spellEffectInfo.CalcRadius(m_caster, targetIndex);
|
float randomRadius1 = spellEffectInfo.CalcRadius(m_caster, targetIndex);
|
||||||
@@ -1012,14 +1012,14 @@ namespace Game.Spells
|
|||||||
dest = new SpellDestination(playerCaster.GetHomebind());
|
dest = new SpellDestination(playerCaster.GetHomebind());
|
||||||
break;
|
break;
|
||||||
case Targets.DestDb:
|
case Targets.DestDb:
|
||||||
SpellTargetPosition st = Global.SpellMgr.GetSpellTargetPosition(m_spellInfo.Id, spellEffectInfo.EffectIndex);
|
WorldLocation st = Global.SpellMgr.GetSpellTargetPosition(m_spellInfo.Id, spellEffectInfo.EffectIndex);
|
||||||
if (st != null)
|
if (st != null)
|
||||||
{
|
{
|
||||||
// @todo fix this check
|
// @todo fix this check
|
||||||
if (m_spellInfo.HasEffect(SpellEffectName.TeleportUnits) || m_spellInfo.HasEffect(SpellEffectName.TeleportWithSpellVisualKitLoadingScreen) || m_spellInfo.HasEffect(SpellEffectName.Bind))
|
if (spellEffectInfo.IsEffect(SpellEffectName.TeleportUnits) || spellEffectInfo.IsEffect(SpellEffectName.TeleportWithSpellVisualKitLoadingScreen) || spellEffectInfo.IsEffect(SpellEffectName.Bind))
|
||||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation, st.target_mapId);
|
dest = new(st);
|
||||||
else if (st.target_mapId == m_caster.GetMapId())
|
else if (st.GetMapId() == m_caster.GetMapId())
|
||||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation);
|
dest = new(st.GetPosition());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -8763,38 +8763,28 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public class SpellDestination
|
public class SpellDestination
|
||||||
{
|
{
|
||||||
public SpellDestination()
|
public SpellDestination() { }
|
||||||
|
|
||||||
|
public SpellDestination(float x, float y, float z, float orientation = 0.0f, uint mapId = 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
Position = new WorldLocation();
|
Position = new(mapId, x, y, z, orientation);
|
||||||
TransportGUID = ObjectGuid.Empty;
|
|
||||||
TransportOffset = new Position();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellDestination(float x, float y, float z, float orientation = 0.0f, uint mapId = 0xFFFFFFFF) : this()
|
public SpellDestination(Position pos)
|
||||||
{
|
{
|
||||||
Position.Relocate(x, y, z, orientation);
|
Position = new(0xFFFFFFFF, pos);
|
||||||
TransportGUID = ObjectGuid.Empty;
|
|
||||||
Position.SetMapId(mapId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellDestination(Position pos) : this()
|
public SpellDestination(WorldLocation loc)
|
||||||
{
|
{
|
||||||
Position.Relocate(pos);
|
Position = loc;
|
||||||
TransportGUID = ObjectGuid.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellDestination(WorldLocation loc) : this()
|
public SpellDestination(WorldObject obj)
|
||||||
{
|
{
|
||||||
Position.WorldRelocate(loc);
|
Position = new(obj.GetMapId(), obj);
|
||||||
TransportGUID.Clear();
|
TransportGUID = obj.GetTransGUID();
|
||||||
TransportOffset.Relocate(0, 0, 0, 0);
|
TransportOffset = obj.GetTransOffset();
|
||||||
}
|
|
||||||
|
|
||||||
public SpellDestination(WorldObject wObj) : this()
|
|
||||||
{
|
|
||||||
TransportGUID = wObj.GetTransGUID();
|
|
||||||
TransportOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO());
|
|
||||||
Position.Relocate(wObj.GetPosition());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Relocate(Position pos)
|
public void Relocate(Position pos)
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ namespace Game.Entities
|
|||||||
return mSpellLearnedBySpells.LookupByKey(learnedSpellId);
|
return mSpellLearnedBySpells.LookupByKey(learnedSpellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellTargetPosition GetSpellTargetPosition(uint spell_id, uint effIndex)
|
public WorldLocation GetSpellTargetPosition(uint spell_id, uint effIndex)
|
||||||
{
|
{
|
||||||
return mSpellTargetPositions.LookupByKey(new KeyValuePair<uint, uint>(spell_id, effIndex));
|
return mSpellTargetPositions.LookupByKey(new KeyValuePair<uint, uint>(spell_id, effIndex));
|
||||||
}
|
}
|
||||||
@@ -1020,20 +1020,16 @@ namespace Game.Entities
|
|||||||
uint spellId = result.Read<uint>(0);
|
uint spellId = result.Read<uint>(0);
|
||||||
uint effIndex = result.Read<byte>(1);
|
uint effIndex = result.Read<byte>(1);
|
||||||
|
|
||||||
SpellTargetPosition st = new();
|
WorldLocation st = new(result.Read<uint>(2), result.Read<float>(3), result.Read<float>(4), result.Read<float>(5));
|
||||||
st.target_mapId = result.Read<uint>(2);
|
|
||||||
st.target_X = result.Read<float>(3);
|
|
||||||
st.target_Y = result.Read<float>(4);
|
|
||||||
st.target_Z = result.Read<float>(5);
|
|
||||||
|
|
||||||
var mapEntry = CliDB.MapStorage.LookupByKey(st.target_mapId);
|
var mapEntry = CliDB.MapStorage.LookupByKey(st.GetMapId());
|
||||||
if (mapEntry == null)
|
if (mapEntry == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, "Spell (ID: {0}, EffectIndex: {1}) is using a non-existant MapID (ID: {2})", spellId, effIndex, st.target_mapId);
|
Log.outError(LogFilter.Sql, "Spell (ID: {0}, EffectIndex: {1}) is using a non-existant MapID (ID: {2})", spellId, effIndex, st.GetMapId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st.target_X == 0 && st.target_Y == 0 && st.target_Z == 0)
|
if (st.GetPositionX() == 0 && st.GetPositionY() == 0 && st.GetPositionZ() == 0)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, "Spell (ID: {0}, EffectIndex: {1}) target coordinates not provided.", spellId, effIndex);
|
Log.outError(LogFilter.Sql, "Spell (ID: {0}, EffectIndex: {1}) target coordinates not provided.", spellId, effIndex);
|
||||||
continue;
|
continue;
|
||||||
@@ -1053,14 +1049,14 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!result.IsNull(6))
|
if (!result.IsNull(6))
|
||||||
st.target_Orientation = result.Read<float>(6);
|
st.SetOrientation(result.Read<float>(6));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// target facing is in degrees for 6484 & 9268... (blizz sucks)
|
// target facing is in degrees for 6484 & 9268...
|
||||||
if (spellInfo.GetEffect(effIndex).PositionFacing > 2 * MathF.PI)
|
if (spellInfo.GetEffect(effIndex).PositionFacing > 2 * MathF.PI)
|
||||||
st.target_Orientation = spellInfo.GetEffect(effIndex).PositionFacing * MathF.PI / 180;
|
st.SetOrientation(spellInfo.GetEffect(effIndex).PositionFacing * MathF.PI / 180);
|
||||||
else
|
else
|
||||||
st.target_Orientation = spellInfo.GetEffect(effIndex).PositionFacing;
|
st.SetOrientation(spellInfo.GetEffect(effIndex).PositionFacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasTarget(Targets target)
|
bool hasTarget(Targets target)
|
||||||
@@ -1071,8 +1067,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (hasTarget(Targets.DestDb) || hasTarget(Targets.DestNearbyEntryOrDB))
|
if (hasTarget(Targets.DestDb) || hasTarget(Targets.DestNearbyEntryOrDB))
|
||||||
{
|
{
|
||||||
var key = new KeyValuePair<uint, uint>(spellId, effIndex);
|
mSpellTargetPositions[(spellId, effIndex)] = st;
|
||||||
mSpellTargetPositions[key] = st;
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -4947,7 +4942,7 @@ namespace Game.Entities
|
|||||||
Dictionary<uint, SpellLearnSkillNode> mSpellLearnSkills = new();
|
Dictionary<uint, SpellLearnSkillNode> mSpellLearnSkills = new();
|
||||||
MultiMap<uint, SpellLearnSpellNode> mSpellLearnSpells = new();
|
MultiMap<uint, SpellLearnSpellNode> mSpellLearnSpells = new();
|
||||||
MultiMap<uint, SpellLearnSpellNode> mSpellLearnedBySpells = new();
|
MultiMap<uint, SpellLearnSpellNode> mSpellLearnedBySpells = new();
|
||||||
Dictionary<KeyValuePair<uint, uint>, SpellTargetPosition> mSpellTargetPositions = new();
|
Dictionary<(uint, uint), WorldLocation> mSpellTargetPositions = new();
|
||||||
MultiMap<uint, SpellGroup> mSpellSpellGroup = new();
|
MultiMap<uint, SpellGroup> mSpellSpellGroup = new();
|
||||||
MultiMap<SpellGroup, int> mSpellGroupSpell = new();
|
MultiMap<SpellGroup, int> mSpellGroupSpell = new();
|
||||||
Dictionary<SpellGroup, SpellGroupStackRule> mSpellGroupStack = new();
|
Dictionary<SpellGroup, SpellGroupStackRule> mSpellGroupStack = new();
|
||||||
@@ -5226,15 +5221,6 @@ namespace Game.Entities
|
|||||||
public EnchantProcAttributes AttributesMask; // bitmask, see EnchantProcAttributes
|
public EnchantProcAttributes AttributesMask; // bitmask, see EnchantProcAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SpellTargetPosition
|
|
||||||
{
|
|
||||||
public uint target_mapId;
|
|
||||||
public float target_X;
|
|
||||||
public float target_Y;
|
|
||||||
public float target_Z;
|
|
||||||
public float target_Orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CreatureImmunities
|
public class CreatureImmunities
|
||||||
{
|
{
|
||||||
public BitSet School = new((int)SpellSchools.Max);
|
public BitSet School = new((int)SpellSchools.Max);
|
||||||
|
|||||||
Reference in New Issue
Block a user