From 1707edbcfd072733914dd5175496d09aecd36728 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Mon, 27 Aug 2012 18:52:42 +0200 Subject: [PATCH] [12127] Add wrapper to access spell locations * Add SpellCastTargets::getSource to get the source position (for TARGET_FLAG_SOURCE_LOCATION) * Add SpellCastTargets::getDestination to get the destination position (for TARGET_FLAG_DEST_LOCATION) --- src/game/Spell.cpp | 12 ++-------- src/game/Spell.h | 26 ++++++++++------------ src/game/SpellEffects.cpp | 46 ++++++++++----------------------------- src/shared/revision_nr.h | 2 +- 4 files changed, 26 insertions(+), 60 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index b4a982e45..49b369bbf 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2324,20 +2324,12 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& if (targetMode == TARGET_AREAEFFECT_GO_AROUND_SOURCE) { if (m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION) - { - x = m_targets.m_srcX; - y = m_targets.m_srcY; - z = m_targets.m_srcZ; - } + m_targets.getSource(x, y, z); else m_caster->GetPosition(x, y, z); } else - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } + m_targets.getDestination(x, y, z); // It may be possible to fill targets for some spell effects // automatically (SPELL_EFFECT_WMO_REPAIR(88) for example) but diff --git a/src/game/Spell.h b/src/game/Spell.h index 629181cdc..a032f277c 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -151,24 +151,29 @@ class SpellCastTargets return *this; } + void setUnitTarget(Unit* target); ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; } Unit* getUnitTarget() const { return m_unitTarget; } - void setUnitTarget(Unit* target); + void setDestination(float x, float y, float z); void setSource(float x, float y, float z); + void getDestination(float& x, float& y, float& z) const { x = m_destX; y = m_destY; z = m_destZ; } + void getSource(float& x, float& y, float& z) const { x = m_srcX; y = m_srcY, z = m_srcZ; } + void setGOTarget(GameObject* target); ObjectGuid getGOTargetGuid() const { return m_GOTargetGUID; } GameObject* getGOTarget() const { return m_GOTarget; } - void setGOTarget(GameObject* target); - ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; } void setCorpseTarget(Corpse* corpse); + ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; } + void setItemTarget(Item* item); ObjectGuid getItemTargetGuid() const { return m_itemTargetGUID; } Item* getItemTarget() const { return m_itemTarget; } uint32 getItemTargetEntry() const { return m_itemTargetEntry; } - void setItemTarget(Item* item); + void setTradeItemTarget(Player* caster); + void updateTradeSlotItem() { if (m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) @@ -190,6 +195,7 @@ class SpellCastTargets float GetSpeed() const { return m_speed; } uint32 m_targetMask; + private: // objects (can be used at spell creating and after Update at casting Unit* m_unitTarget; @@ -771,17 +777,9 @@ namespace MaNGOS break; case PUSH_DEST_CENTER: if (i_spell.m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION) - { - i_centerX = i_spell.m_targets.m_srcX; - i_centerY = i_spell.m_targets.m_srcY; - i_centerZ = i_spell.m_targets.m_srcZ; - } + i_spell.m_targets.getSource(i_centerX, i_centerY, i_centerZ); else - { - i_centerX = i_spell.m_targets.m_destX; - i_centerY = i_spell.m_targets.m_destY; - i_centerZ = i_spell.m_targets.m_destZ; - } + i_spell.m_targets.getDestination(i_centerX, i_centerY, i_centerZ); break; case PUSH_TARGET_CENTER: if (Unit* target = i_spell.m_targets.getUnitTarget()) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 2eee572ac..6517f913e 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3781,9 +3781,7 @@ void Spell::EffectJump(SpellEffectEntry const* effect) float x, y, z, o; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; + m_targets.getDestination(x, y, z); if(effect->EffectImplicitTargetA == TARGET_BEHIND_VICTIM) { @@ -3818,10 +3816,10 @@ void Spell::EffectJump(SpellEffectEntry const* effect) return; } - m_caster->NearTeleportTo(x, y, z, o, true); + m_caster->NearTeleportTo(x, y, z, o, true); // TODO Implement this as jump movement? } -void Spell::EffectTeleportUnits(SpellEffectEntry const* effect) +void Spell::EffectTeleportUnits(SpellEffectEntry const* effect) // TODO - Use target settings for this effect! { if (!unitTarget || unitTarget->IsTaxiFlying()) return; @@ -4860,11 +4858,7 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect) // Set middle position if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - summonPositions[0].x = m_targets.m_destX; - summonPositions[0].y = m_targets.m_destY; - summonPositions[0].z = m_targets.m_destZ; - } + m_targets.getDestination(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z); else { m_caster->GetPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z); @@ -6604,11 +6598,7 @@ void Spell::EffectSummonObjectWild(SpellEffectEntry const* effect) float x, y, z; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } + m_targets.getDestination(x, y, z); else m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); @@ -8955,11 +8945,7 @@ void Spell::EffectSummonObject(SpellEffectEntry const* effect) float x, y, z; // If dest location if present if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } + m_targets.getDestination(x, y, z); // Summon in random point all other units if location present else m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); @@ -9223,9 +9209,7 @@ void Spell::EffectCharge2(SpellEffectEntry const* /*effect*/) float x, y, z; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; + m_targets.getDestination(x, y, z); if (unitTarget->GetTypeId() != TYPEID_PLAYER) ((Creature*)unitTarget)->StopMoving(); @@ -9441,13 +9425,9 @@ void Spell::EffectTransmitted(SpellEffectEntry const* effect) float fx, fy, fz; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - fx = m_targets.m_destX; - fy = m_targets.m_destY; - fz = m_targets.m_destZ; - } - //FIXME: this can be better check for most objects but still hack - else if(effect->EffectRadiusIndex && m_spellInfo->speed==0) + m_targets.getDestination(fx, fy, fz); + // FIXME: this can be better check for most objects but still hack + else if (effect->EffectRadiusIndex && m_spellInfo->speed == 0) { float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(effect->EffectRadiusIndex)); m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); @@ -9966,11 +9946,7 @@ void Spell::EffectKnockBackFromPosition(SpellEffectIndex eff_idx) float x, y, z; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } + m_targets.getDestination(x, y, z); else m_caster->GetPosition(x, y, z); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d2aeba622..38ec2460a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12126" + #define REVISION_NR "12127" #endif // __REVISION_NR_H__