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 GetTransOffsetZ() { return m_movementInfo.transport.pos.GetPositionZ(); }
|
||||
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 sbyte GetTransSeat() { return m_movementInfo.transport.seat; }
|
||||
public virtual ObjectGuid GetTransGUID()
|
||||
|
||||
+20
-30
@@ -654,12 +654,12 @@ namespace Game.Spells
|
||||
}
|
||||
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)
|
||||
{
|
||||
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))
|
||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation);
|
||||
if (st.GetMapId() == m_caster.GetMapId() && m_caster.IsInDist(st, range))
|
||||
dest = new(st.GetPosition());
|
||||
else
|
||||
{
|
||||
float randomRadius1 = spellEffectInfo.CalcRadius(m_caster, targetIndex);
|
||||
@@ -1012,14 +1012,14 @@ namespace Game.Spells
|
||||
dest = new SpellDestination(playerCaster.GetHomebind());
|
||||
break;
|
||||
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)
|
||||
{
|
||||
// @todo fix this check
|
||||
if (m_spellInfo.HasEffect(SpellEffectName.TeleportUnits) || m_spellInfo.HasEffect(SpellEffectName.TeleportWithSpellVisualKitLoadingScreen) || m_spellInfo.HasEffect(SpellEffectName.Bind))
|
||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation, st.target_mapId);
|
||||
else if (st.target_mapId == m_caster.GetMapId())
|
||||
dest = new SpellDestination(st.target_X, st.target_Y, st.target_Z, st.target_Orientation);
|
||||
if (spellEffectInfo.IsEffect(SpellEffectName.TeleportUnits) || spellEffectInfo.IsEffect(SpellEffectName.TeleportWithSpellVisualKitLoadingScreen) || spellEffectInfo.IsEffect(SpellEffectName.Bind))
|
||||
dest = new(st);
|
||||
else if (st.GetMapId() == m_caster.GetMapId())
|
||||
dest = new(st.GetPosition());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -8763,38 +8763,28 @@ namespace Game.Spells
|
||||
|
||||
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();
|
||||
TransportGUID = ObjectGuid.Empty;
|
||||
TransportOffset = new Position();
|
||||
Position = new(mapId, x, y, z, orientation);
|
||||
}
|
||||
|
||||
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);
|
||||
TransportGUID = ObjectGuid.Empty;
|
||||
Position.SetMapId(mapId);
|
||||
Position = new(0xFFFFFFFF, pos);
|
||||
}
|
||||
|
||||
public SpellDestination(Position pos) : this()
|
||||
public SpellDestination(WorldLocation loc)
|
||||
{
|
||||
Position.Relocate(pos);
|
||||
TransportGUID = ObjectGuid.Empty;
|
||||
Position = loc;
|
||||
}
|
||||
|
||||
public SpellDestination(WorldLocation loc) : this()
|
||||
public SpellDestination(WorldObject obj)
|
||||
{
|
||||
Position.WorldRelocate(loc);
|
||||
TransportGUID.Clear();
|
||||
TransportOffset.Relocate(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public SpellDestination(WorldObject wObj) : this()
|
||||
{
|
||||
TransportGUID = wObj.GetTransGUID();
|
||||
TransportOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO());
|
||||
Position.Relocate(wObj.GetPosition());
|
||||
Position = new(obj.GetMapId(), obj);
|
||||
TransportGUID = obj.GetTransGUID();
|
||||
TransportOffset = obj.GetTransOffset();
|
||||
}
|
||||
|
||||
public void Relocate(Position pos)
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace Game.Entities
|
||||
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));
|
||||
}
|
||||
@@ -1020,20 +1020,16 @@ namespace Game.Entities
|
||||
uint spellId = result.Read<uint>(0);
|
||||
uint effIndex = result.Read<byte>(1);
|
||||
|
||||
SpellTargetPosition st = new();
|
||||
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);
|
||||
WorldLocation st = new(result.Read<uint>(2), result.Read<float>(3), result.Read<float>(4), result.Read<float>(5));
|
||||
|
||||
var mapEntry = CliDB.MapStorage.LookupByKey(st.target_mapId);
|
||||
var mapEntry = CliDB.MapStorage.LookupByKey(st.GetMapId());
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
continue;
|
||||
@@ -1053,14 +1049,14 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
if (!result.IsNull(6))
|
||||
st.target_Orientation = result.Read<float>(6);
|
||||
st.SetOrientation(result.Read<float>(6));
|
||||
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)
|
||||
st.target_Orientation = spellInfo.GetEffect(effIndex).PositionFacing * MathF.PI / 180;
|
||||
st.SetOrientation(spellInfo.GetEffect(effIndex).PositionFacing * MathF.PI / 180);
|
||||
else
|
||||
st.target_Orientation = spellInfo.GetEffect(effIndex).PositionFacing;
|
||||
st.SetOrientation(spellInfo.GetEffect(effIndex).PositionFacing);
|
||||
}
|
||||
|
||||
bool hasTarget(Targets target)
|
||||
@@ -1071,8 +1067,7 @@ namespace Game.Entities
|
||||
|
||||
if (hasTarget(Targets.DestDb) || hasTarget(Targets.DestNearbyEntryOrDB))
|
||||
{
|
||||
var key = new KeyValuePair<uint, uint>(spellId, effIndex);
|
||||
mSpellTargetPositions[key] = st;
|
||||
mSpellTargetPositions[(spellId, effIndex)] = st;
|
||||
++count;
|
||||
}
|
||||
else
|
||||
@@ -4947,7 +4942,7 @@ namespace Game.Entities
|
||||
Dictionary<uint, SpellLearnSkillNode> mSpellLearnSkills = new();
|
||||
MultiMap<uint, SpellLearnSpellNode> mSpellLearnSpells = 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<SpellGroup, int> mSpellGroupSpell = new();
|
||||
Dictionary<SpellGroup, SpellGroupStackRule> mSpellGroupStack = new();
|
||||
@@ -5226,15 +5221,6 @@ namespace Game.Entities
|
||||
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 BitSet School = new((int)SpellSchools.Max);
|
||||
|
||||
Reference in New Issue
Block a user