[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)
This commit is contained in:
Schmoozerd 2012-08-27 18:52:42 +02:00 committed by Antz
parent 147a1b04fe
commit 1707edbcfd
4 changed files with 26 additions and 60 deletions

View file

@ -2324,20 +2324,12 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
if (targetMode == TARGET_AREAEFFECT_GO_AROUND_SOURCE) if (targetMode == TARGET_AREAEFFECT_GO_AROUND_SOURCE)
{ {
if (m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
{ m_targets.getSource(x, y, z);
x = m_targets.m_srcX;
y = m_targets.m_srcY;
z = m_targets.m_srcZ;
}
else else
m_caster->GetPosition(x, y, z); m_caster->GetPosition(x, y, z);
} }
else else
{ m_targets.getDestination(x, y, z);
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
// It may be possible to fill targets for some spell effects // It may be possible to fill targets for some spell effects
// automatically (SPELL_EFFECT_WMO_REPAIR(88) for example) but // automatically (SPELL_EFFECT_WMO_REPAIR(88) for example) but

View file

@ -151,24 +151,29 @@ class SpellCastTargets
return *this; return *this;
} }
void setUnitTarget(Unit* target);
ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; } ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; }
Unit* getUnitTarget() const { return m_unitTarget; } Unit* getUnitTarget() const { return m_unitTarget; }
void setUnitTarget(Unit* target);
void setDestination(float x, float y, float z); void setDestination(float x, float y, float z);
void setSource(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; } ObjectGuid getGOTargetGuid() const { return m_GOTargetGUID; }
GameObject* getGOTarget() const { return m_GOTarget; } GameObject* getGOTarget() const { return m_GOTarget; }
void setGOTarget(GameObject* target);
ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; }
void setCorpseTarget(Corpse* corpse); void setCorpseTarget(Corpse* corpse);
ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; }
void setItemTarget(Item* item);
ObjectGuid getItemTargetGuid() const { return m_itemTargetGUID; } ObjectGuid getItemTargetGuid() const { return m_itemTargetGUID; }
Item* getItemTarget() const { return m_itemTarget; } Item* getItemTarget() const { return m_itemTarget; }
uint32 getItemTargetEntry() const { return m_itemTargetEntry; } uint32 getItemTargetEntry() const { return m_itemTargetEntry; }
void setItemTarget(Item* item);
void setTradeItemTarget(Player* caster); void setTradeItemTarget(Player* caster);
void updateTradeSlotItem() void updateTradeSlotItem()
{ {
if (m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) if (m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM))
@ -190,6 +195,7 @@ class SpellCastTargets
float GetSpeed() const { return m_speed; } float GetSpeed() const { return m_speed; }
uint32 m_targetMask; uint32 m_targetMask;
private: private:
// objects (can be used at spell creating and after Update at casting // objects (can be used at spell creating and after Update at casting
Unit* m_unitTarget; Unit* m_unitTarget;
@ -771,17 +777,9 @@ namespace MaNGOS
break; break;
case PUSH_DEST_CENTER: case PUSH_DEST_CENTER:
if (i_spell.m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION) if (i_spell.m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
{ i_spell.m_targets.getSource(i_centerX, i_centerY, i_centerZ);
i_centerX = i_spell.m_targets.m_srcX;
i_centerY = i_spell.m_targets.m_srcY;
i_centerZ = i_spell.m_targets.m_srcZ;
}
else else
{ i_spell.m_targets.getDestination(i_centerX, i_centerY, i_centerZ);
i_centerX = i_spell.m_targets.m_destX;
i_centerY = i_spell.m_targets.m_destY;
i_centerZ = i_spell.m_targets.m_destZ;
}
break; break;
case PUSH_TARGET_CENTER: case PUSH_TARGET_CENTER:
if (Unit* target = i_spell.m_targets.getUnitTarget()) if (Unit* target = i_spell.m_targets.getUnitTarget())

View file

@ -3781,9 +3781,7 @@ void Spell::EffectJump(SpellEffectEntry const* effect)
float x, y, z, o; float x, y, z, o;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ {
x = m_targets.m_destX; m_targets.getDestination(x, y, z);
y = m_targets.m_destY;
z = m_targets.m_destZ;
if(effect->EffectImplicitTargetA == TARGET_BEHIND_VICTIM) if(effect->EffectImplicitTargetA == TARGET_BEHIND_VICTIM)
{ {
@ -3818,10 +3816,10 @@ void Spell::EffectJump(SpellEffectEntry const* effect)
return; 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()) if (!unitTarget || unitTarget->IsTaxiFlying())
return; return;
@ -4860,11 +4858,7 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect)
// Set middle position // Set middle position
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ m_targets.getDestination(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z);
summonPositions[0].x = m_targets.m_destX;
summonPositions[0].y = m_targets.m_destY;
summonPositions[0].z = m_targets.m_destZ;
}
else else
{ {
m_caster->GetPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z); 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; float x, y, z;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ m_targets.getDestination(x, y, z);
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
else else
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
@ -8955,11 +8945,7 @@ void Spell::EffectSummonObject(SpellEffectEntry const* effect)
float x, y, z; float x, y, z;
// If dest location if present // If dest location if present
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ m_targets.getDestination(x, y, z);
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
// Summon in random point all other units if location present // Summon in random point all other units if location present
else else
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
@ -9223,9 +9209,7 @@ void Spell::EffectCharge2(SpellEffectEntry const* /*effect*/)
float x, y, z; float x, y, z;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ {
x = m_targets.m_destX; m_targets.getDestination(x, y, z);
y = m_targets.m_destY;
z = m_targets.m_destZ;
if (unitTarget->GetTypeId() != TYPEID_PLAYER) if (unitTarget->GetTypeId() != TYPEID_PLAYER)
((Creature*)unitTarget)->StopMoving(); ((Creature*)unitTarget)->StopMoving();
@ -9441,13 +9425,9 @@ void Spell::EffectTransmitted(SpellEffectEntry const* effect)
float fx, fy, fz; float fx, fy, fz;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ m_targets.getDestination(fx, fy, fz);
fx = m_targets.m_destX; // FIXME: this can be better check for most objects but still hack
fy = m_targets.m_destY; else if (effect->EffectRadiusIndex && m_spellInfo->speed == 0)
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)
{ {
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(effect->EffectRadiusIndex)); float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(effect->EffectRadiusIndex));
m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); 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; float x, y, z;
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{ m_targets.getDestination(x, y, z);
x = m_targets.m_destX;
y = m_targets.m_destY;
z = m_targets.m_destZ;
}
else else
m_caster->GetPosition(x, y, z); m_caster->GetPosition(x, y, z);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12126" #define REVISION_NR "12127"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__