mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Core/Spells: Replace SpellTargetPosition structure with WorldLocation
This commit is contained in:
@@ -73,40 +73,9 @@
|
||||
|
||||
extern NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EFFECTS];
|
||||
|
||||
SpellDestination::SpellDestination()
|
||||
SpellDestination::SpellDestination(WorldObject const& wObj) : _position(wObj.GetMapId(), wObj),
|
||||
_transportGUID(wObj.GetTransGUID()), _transportOffset(wObj.GetTransOffset())
|
||||
{
|
||||
_position.Relocate(0, 0, 0, 0);
|
||||
_transportGUID.Clear();
|
||||
_transportOffset.Relocate(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
SpellDestination::SpellDestination(float x, float y, float z, float orientation, uint32 mapId)
|
||||
{
|
||||
_position.Relocate(x, y, z, orientation);
|
||||
_transportGUID.Clear();
|
||||
_position.m_mapId = mapId;
|
||||
_transportOffset.Relocate(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
SpellDestination::SpellDestination(Position const& pos)
|
||||
{
|
||||
_position.Relocate(pos);
|
||||
_transportGUID.Clear();
|
||||
_transportOffset.Relocate(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
SpellDestination::SpellDestination(WorldLocation const& loc)
|
||||
{
|
||||
_position.WorldRelocate(loc);
|
||||
_transportGUID.Clear();
|
||||
_transportOffset.Relocate(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
SpellDestination::SpellDestination(WorldObject const& wObj)
|
||||
{
|
||||
_transportGUID = wObj.GetTransGUID();
|
||||
_transportOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO());
|
||||
_position.Relocate(wObj);
|
||||
}
|
||||
|
||||
void SpellDestination::Relocate(Position const& pos)
|
||||
@@ -1178,8 +1147,8 @@ void Spell::SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo,
|
||||
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex))
|
||||
{
|
||||
SpellDestination dest(*m_caster);
|
||||
if (st->target_mapId == m_caster->GetMapId() && m_caster->IsInDist(st->target_X, st->target_Y, st->target_Z, range))
|
||||
dest = 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 = st->GetPosition();
|
||||
else
|
||||
{
|
||||
float randomRadius = spellEffectInfo.CalcRadius(m_caster, targetIndex);
|
||||
@@ -1503,16 +1472,16 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
|
||||
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex))
|
||||
{
|
||||
/// @todo fix this check
|
||||
if (m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN) || m_spellInfo->HasEffect(SPELL_EFFECT_BIND))
|
||||
dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId);
|
||||
else if (st->target_mapId == m_caster->GetMapId())
|
||||
dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
|
||||
if (spellEffectInfo.IsEffect(SPELL_EFFECT_TELEPORT_UNITS) || spellEffectInfo.IsEffect(SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN) || spellEffectInfo.IsEffect(SPELL_EFFECT_BIND))
|
||||
dest = *st;
|
||||
else if (st->GetMapId() == m_caster->GetMapId())
|
||||
dest = st->GetPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("spells", "SPELL: unknown target coordinates for spell ID {}", m_spellInfo->Id);
|
||||
if (WorldObject* target = m_targets.GetObjectTarget())
|
||||
dest = SpellDestination(*target);
|
||||
dest = *target;
|
||||
}
|
||||
break;
|
||||
case TARGET_DEST_CASTER_FISHING:
|
||||
@@ -1630,7 +1599,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
|
||||
case TARGET_DEST_CASTER_FRONT_RIGHT:
|
||||
case TARGET_DEST_CASTER_BACK_RIGHT:
|
||||
{
|
||||
static float const DefaultTotemDistance = 3.0f;
|
||||
constexpr float DefaultTotemDistance = 3.0f;
|
||||
if (!spellEffectInfo.HasRadius(targetIndex))
|
||||
dist = DefaultTotemDistance;
|
||||
break;
|
||||
|
||||
@@ -328,10 +328,10 @@ enum SpellCastTargetFlags : uint32
|
||||
|
||||
struct TC_GAME_API SpellDestination
|
||||
{
|
||||
SpellDestination();
|
||||
SpellDestination(float x, float y, float z, float orientation = 0.0f, uint32 mapId = MAPID_INVALID);
|
||||
SpellDestination(Position const& pos);
|
||||
SpellDestination(WorldLocation const& loc);
|
||||
SpellDestination() { }
|
||||
SpellDestination(float x, float y, float z, float orientation = 0.0f, uint32 mapId = MAPID_INVALID) : _position(mapId, x, y, z, orientation) { }
|
||||
SpellDestination(Position const& pos) : _position(MAPID_INVALID, pos) { }
|
||||
SpellDestination(WorldLocation const& loc) : _position(loc) { }
|
||||
SpellDestination(WorldObject const& wObj);
|
||||
|
||||
void Relocate(Position const& pos);
|
||||
|
||||
@@ -36,7 +36,6 @@ class WorldObject;
|
||||
struct Condition;
|
||||
struct SpellChainNode;
|
||||
struct SpellModifier;
|
||||
struct SpellTargetPosition;
|
||||
enum WeaponAttackType : uint8;
|
||||
|
||||
enum SpellTargetSelectionCategories
|
||||
|
||||
@@ -1173,21 +1173,16 @@ void SpellMgr::LoadSpellTargetPositions()
|
||||
uint32 spellId = fields[0].GetUInt32();
|
||||
SpellEffIndex effIndex = SpellEffIndex(fields[1].GetUInt8());
|
||||
|
||||
SpellTargetPosition st;
|
||||
SpellTargetPosition st(fields[2].GetUInt16(), fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat());
|
||||
|
||||
st.target_mapId = fields[2].GetUInt16();
|
||||
st.target_X = fields[3].GetFloat();
|
||||
st.target_Y = fields[4].GetFloat();
|
||||
st.target_Z = fields[5].GetFloat();
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId);
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(st.GetMapId());
|
||||
if (!mapEntry)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Spell (Id: {}, EffectIndex: {}) is using a non-existant MapID (ID: {}).", spellId, uint32(effIndex), st.target_mapId);
|
||||
TC_LOG_ERROR("sql.sql", "Spell (Id: {}, EffectIndex: {}) is using a non-existant MapID (ID: {}).", spellId, uint32(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)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Spell (Id: {}, EffectIndex: {}): target coordinates not provided.", spellId, uint32(effIndex));
|
||||
continue;
|
||||
@@ -1207,14 +1202,14 @@ void SpellMgr::LoadSpellTargetPositions()
|
||||
}
|
||||
|
||||
if (!fields[6].IsNull())
|
||||
st.target_Orientation = fields[6].GetFloat();
|
||||
st.SetOrientation(fields[6].GetFloat());
|
||||
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 * float(M_PI))
|
||||
st.target_Orientation = spellInfo->GetEffect(effIndex).PositionFacing * float(M_PI) / 180;
|
||||
st.SetOrientation(spellInfo->GetEffect(effIndex).PositionFacing * float(M_PI) / 180);
|
||||
else
|
||||
st.target_Orientation = spellInfo->GetEffect(effIndex).PositionFacing;
|
||||
st.SetOrientation(spellInfo->GetEffect(effIndex).PositionFacing);
|
||||
}
|
||||
|
||||
auto hasTarget = [&](Targets target)
|
||||
|
||||
@@ -407,14 +407,7 @@ struct SpellThreatEntry
|
||||
typedef std::unordered_map<uint32, SpellThreatEntry> SpellThreatMap;
|
||||
|
||||
// coordinates for spells (accessed using SpellMgr functions)
|
||||
struct SpellTargetPosition
|
||||
{
|
||||
uint32 target_mapId;
|
||||
float target_X;
|
||||
float target_Y;
|
||||
float target_Z;
|
||||
float target_Orientation;
|
||||
};
|
||||
using SpellTargetPosition = WorldLocation;
|
||||
|
||||
typedef std::map<std::pair<uint32 /*spell_id*/, SpellEffIndex /*effIndex*/>, SpellTargetPosition> SpellTargetPositionMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user