Core/Spells: Cleanup in Spell.h:

- Codestyle (fix function naming) and cleanup changes in SpellCastTargets class, also access variables of this class by getters/setters
 - Move IsQuestTameSpell function to SpellMgr.h
 - Move UnitList typedef to Unit.h
Additionally - add missing copyright notice to SpellAuraEffects.h
This commit is contained in:
QAston
2011-06-23 13:28:52 +02:00
parent 9d9472e5cc
commit 3137a82c7c
19 changed files with 630 additions and 588 deletions
+1 -1
View File
@@ -212,7 +212,7 @@ void PetAI::UpdateAI(const uint32 diff)
targetSpellStore.erase(targetSpellStore.begin() + index);
SpellCastTargets targets;
targets.setUnitTarget(target);
targets.SetUnitTarget(target);
if (!me->HasInArc(M_PI, target))
{
+5 -5
View File
@@ -845,7 +845,7 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered,
originalCaster=owner->GetGUID();
SpellCastTargets targets;
targets.setUnitTarget(Victim);
targets.SetUnitTarget(Victim);
if (castItem)
sLog->outStaticDebug("WORLD: cast Item spellId - %i", spellInfo->Id);
@@ -888,7 +888,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit*
}
SpellCastTargets targets;
targets.setUnitTarget(Victim);
targets.SetUnitTarget(Victim);
if (!originalCaster && triggeredByAura)
originalCaster = triggeredByAura->GetCasterGUID();
@@ -927,9 +927,9 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
Spell* spell = new Spell(this, spellInfo, triggered, originalCaster);
SpellCastTargets targets;
targets.setDst(x, y, z, GetOrientation());
targets.SetDst(x, y, z, GetOrientation());
if (OriginalVictim)
targets.setUnitTarget(OriginalVictim);
targets.SetUnitTarget(OriginalVictim);
spell->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura);
}
@@ -963,7 +963,7 @@ void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castI
Spell* spell = new Spell(this, spellInfo, triggered, originalCaster);
SpellCastTargets targets;
targets.setGOTarget(go);
targets.SetGOTarget(go);
spell->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura);
}
+2
View File
@@ -338,6 +338,8 @@ class Totem;
class Transport;
class Vehicle;
typedef std::list<Unit*> UnitList;
struct SpellImmune
{
uint32 type;
@@ -332,7 +332,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
if (unit_target->GetTypeId() == TYPEID_PLAYER)
pet->SendUpdateToPlayer((Player*)unit_target);
}
else if (Unit *unit_target2 = spell->m_targets.getUnitTarget())
else if (Unit *unit_target2 = spell->m_targets.GetUnitTarget())
{
pet->SetInFront(unit_target2);
if (unit_target2->GetTypeId() == TYPEID_PLAYER)
@@ -348,7 +348,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
{
pet->ToCreature()->AddCreatureSpellCooldown(spellid);
unit_target = spell->m_targets.getUnitTarget();
unit_target = spell->m_targets.GetUnitTarget();
//10% chance to play special pet attack talk, else growl
//actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
@@ -769,7 +769,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
return;
SpellCastTargets targets;
targets.read(recvPacket, caster);
targets.Read(recvPacket, caster);
HandleClientCastFlags(recvPacket, castFlags, targets);
caster->ClearUnitState(UNIT_STAT_FOLLOW);
@@ -32,14 +32,19 @@
#include "ScriptMgr.h"
#include "GameObjectAI.h"
void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets & targets)
void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets)
{
// some spell cast packet including more data (for projectiles?)
if (castFlags & 0x02)
{
// not sure about these two
recvPacket >> targets.m_elevation;
recvPacket >> targets.m_speed;
float elevation, speed;
recvPacket >> elevation;
recvPacket >> speed;
targets.SetElevation(elevation);
targets.SetSpeed(speed);
uint8 hasMovementData;
recvPacket >> hasMovementData;
if (hasMovementData)
@@ -156,10 +161,10 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
}
SpellCastTargets targets;
targets.read(recvPacket, pUser);
targets.Read(recvPacket, pUser);
HandleClientCastFlags(recvPacket, castFlags, targets);
if (!pItem->IsTargetValidForItemUse(targets.getUnitTarget()))
if (!pItem->IsTargetValidForItemUse(targets.GetUnitTarget()))
{
// free gray item after use fail
pUser->SendEquipError(EQUIP_ERR_NONE, pItem, NULL);
@@ -168,7 +173,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId))
{
// for implicit area/coord target spells
if (!targets.getUnitTarget())
if (!targets.GetUnitTarget())
Spell::SendCastResult(_player, spellInfo, castCount, SPELL_FAILED_NO_VALID_TARGETS);
// for explicit target spells
else
@@ -384,13 +389,13 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
// client provided targets
SpellCastTargets targets;
targets.read(recvPacket, mover);
targets.Read(recvPacket, mover);
HandleClientCastFlags(recvPacket, castFlags, targets);
// auto-selection buff level base at target level (in spellInfo)
if (targets.getUnitTarget())
if (targets.GetUnitTarget())
{
SpellEntry const *actualSpellInfo = sSpellMgr->SelectAuraRankForPlayerLevel(spellInfo, targets.getUnitTarget()->getLevel());
SpellEntry const *actualSpellInfo = sSpellMgr->SelectAuraRankForPlayerLevel(spellInfo, targets.GetUnitTarget()->getLevel());
// if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message
if (actualSpellInfo)
@@ -353,7 +353,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
my_spell = new Spell(_player, spellEntry, true);
my_spell->m_CastItem = castItem;
my_targets.setTradeItemTarget(_player);
my_targets.SetTradeItemTarget(_player);
my_spell->m_targets = my_targets;
SpellCastResult res = my_spell->CheckCast(true);
@@ -388,7 +388,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
his_spell = new Spell(trader, spellEntry, true);
his_spell->m_CastItem = castItem;
his_targets.setTradeItemTarget(trader);
his_targets.SetTradeItemTarget(trader);
his_spell->m_targets = his_targets;
SpellCastResult res = his_spell->CheckCast(true);
@@ -2421,7 +2421,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
{
if ((*iter)->GetCurrentSpell(i)
&& (*iter)->GetCurrentSpell(i)->m_targets.getUnitTargetGUID() == target->GetGUID())
&& (*iter)->GetCurrentSpell(i)->m_targets.GetUnitTargetGUID() == target->GetGUID())
{
(*iter)->InterruptSpell(CurrentSpellTypes(i), false);
}
@@ -4778,7 +4778,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
// AT REMOVE
else
{
if ((IsQuestTameSpell(GetId())) && caster && caster->isAlive() && target->isAlive())
if ((IsQuestTameSpell(GetSpellProto())) && caster && caster->isAlive() && target->isAlive())
{
uint32 finalSpelId = 0;
switch(GetId())
@@ -5409,7 +5409,6 @@ void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, boo
else if (mode & AURA_EFFECT_HANDLE_REAPPLY && apply)
{
uint64 casterGUID = IsSpellRequiringFocusedTarget(GetSpellProto()) ? GetCasterGUID() : target->GetGUID();
// change the stack amount to be equal to stack amount of our aura
if (Aura* triggeredAura = target->GetAura(triggeredSpellId, casterGUID))
triggeredAura->ModStackAmount(GetBase()->GetStackAmount() - triggeredAura->GetStackAmount());
@@ -1,9 +1,25 @@
/*
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITY_SPELLAURAEFFECTS_H
#define TRINITY_SPELLAURAEFFECTS_H
class Unit;
class DynamicObject;
class AuraEffect;
class Aura;
File diff suppressed because it is too large Load Diff
+65 -97
View File
@@ -34,6 +34,8 @@ class ByteBuffer;
struct SpellEntry;
#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS)
enum SpellCastTargetFlags
{
TARGET_FLAG_SELF = 0x00000000,
@@ -117,117 +119,75 @@ enum SpellNotifyPushType
PUSH_CHAIN,
};
bool IsQuestTameSpell(uint32 spellId);
namespace Trinity
{
struct SpellNotifierCreatureAndPlayer;
}
typedef std::list<Unit*> UnitList;
class SpellCastTargets
{
public:
SpellCastTargets();
~SpellCastTargets();
SpellCastTargets& operator=(const SpellCastTargets &target)
{
m_unitTarget = target.m_unitTarget;
m_itemTarget = target.m_itemTarget;
m_GOTarget = target.m_GOTarget;
SpellCastTargets& operator=(const SpellCastTargets &target);
m_unitTargetGUID = target.m_unitTargetGUID;
m_GOTargetGUID = target.m_GOTargetGUID;
m_CorpseTargetGUID = target.m_CorpseTargetGUID;
m_itemTargetGUID = target.m_itemTargetGUID;
void Read(ByteBuffer& data, Unit* caster);
void Write(ByteBuffer& data);
m_itemTargetEntry = target.m_itemTargetEntry;
uint32 GetTargetMask() const { return m_targetMask; }
void SetTargetMask(uint32 newMask) { m_targetMask = newMask; }
m_srcTransGUID = target.m_srcTransGUID;
m_srcTransOffset = target.m_srcTransOffset;
m_srcPos = target.m_srcPos;
uint64 GetUnitTargetGUID() const { return m_unitTargetGUID; }
Unit* GetUnitTarget() const { return m_unitTarget; }
void SetUnitTarget(Unit* target);
m_dstTransGUID = target.m_dstTransGUID;
m_dstTransOffset = target.m_dstTransOffset;
m_dstPos = target.m_dstPos;
Position const* GetSrc() const;
void SetSrc(float x, float y, float z);
void SetSrc(Position const& pos);
void SetSrc(WorldObject const& wObj);
void ModSrc(Position const& pos);
m_elevation = target.m_elevation;
m_speed = target.m_speed;
WorldLocation const* GetDst() const;
void SetDst(float x, float y, float z, float orientation, uint32 mapId = MAPID_INVALID);
void SetDst(Position const& pos);
void SetDst(WorldObject const& wObj);
void SetDst(SpellCastTargets const& spellTargets);
void ModDst(Position const& pos);
m_strTarget = target.m_strTarget;
uint64 GetGOTargetGUID() const { return m_GOTargetGUID; }
GameObject* GetGOTarget() const { return m_GOTarget; }
void SetGOTarget(GameObject* target);
m_targetMask = target.m_targetMask;
uint64 GetCorpseTargetGUID() const { return m_CorpseTargetGUID; }
void SetCorpseTarget(Corpse* corpse);
return *this;
}
void read (ByteBuffer & data, Unit* caster);
void write (ByteBuffer & data);
uint32 getTargetMask() const { return m_targetMask; }
void setTargetMask(uint32 newMask) { m_targetMask = newMask; }
uint64 getUnitTargetGUID() const { return m_unitTargetGUID; }
Unit *getUnitTarget() const { return m_unitTarget; }
void setUnitTarget(Unit* target);
void setSrc(float x, float y, float z);
void setSrc(Position &pos);
void setSrc(WorldObject &wObj);
void modSrc(Position &pos);
void setDst(float x, float y, float z, float orientation, uint32 mapId = MAPID_INVALID);
void setDst(Position &pos);
void setDst(WorldObject &wObj);
void setDst(SpellCastTargets &spellTargets);
void modDst(Position &pos);
uint64 getGOTargetGUID() const { return m_GOTargetGUID; }
GameObject *getGOTarget() const { return m_GOTarget; }
void setGOTarget(GameObject *target);
uint64 getCorpseTargetGUID() const { return m_CorpseTargetGUID; }
void setCorpseTarget(Corpse* corpse);
uint64 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))
{
m_itemTargetGUID = m_itemTarget->GetGUID();
m_itemTargetEntry = m_itemTarget->GetEntry();
}
}
uint64 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();
bool IsEmpty() const { return m_GOTargetGUID == 0 && m_unitTargetGUID == 0 && m_itemTarget == 0 && m_CorpseTargetGUID == 0; }
bool HasSrc() const { return getTargetMask() & TARGET_FLAG_SOURCE_LOCATION; }
bool HasDst() const { return getTargetMask() & TARGET_FLAG_DEST_LOCATION; }
bool HasSrc() const { return GetTargetMask() & TARGET_FLAG_SOURCE_LOCATION; }
bool HasDst() const { return GetTargetMask() & TARGET_FLAG_DEST_LOCATION; }
bool HasTraj() const { return m_speed != 0; }
float GetElevation() const { return m_elevation; }
void SetElevation(float elevation) { m_elevation = elevation; }
float GetSpeed() const { return m_speed; }
void SetSpeed(float speed) { m_speed = speed; }
float GetDist2d() const { return m_srcPos.GetExactDist2d(&m_dstPos); }
float GetSpeedXY() const { return m_speed * cos(m_elevation); }
float GetSpeedZ() const { return m_speed * sin(m_elevation); }
void Update(Unit* caster);
void OutDebug();
uint64 m_srcTransGUID;
Position m_srcTransOffset;
Position m_srcPos;
uint64 m_dstTransGUID;
Position m_dstTransOffset;
WorldLocation m_dstPos;
float m_elevation, m_speed;
std::string m_strTarget;
void OutDebug() const;
private:
uint32 m_targetMask;
// objects (can be used at spell creating and after Update at casting
Unit *m_unitTarget;
GameObject *m_GOTarget;
Item *m_itemTarget;
Unit* m_unitTarget;
GameObject* m_GOTarget;
Item* m_itemTarget;
// object GUID/etc, can be used always
uint64 m_unitTargetGUID;
@@ -235,6 +195,17 @@ class SpellCastTargets
uint64 m_CorpseTargetGUID;
uint64 m_itemTargetGUID;
uint32 m_itemTargetEntry;
uint64 m_srcTransGUID;
Position m_srcTransOffset;
Position m_srcPos;
uint64 m_dstTransGUID;
Position m_dstTransOffset;
WorldLocation m_dstPos;
float m_elevation, m_speed;
std::string m_strTarget;
};
struct SpellValue
@@ -247,7 +218,7 @@ struct SpellValue
RadiusMod = 1.0f;
AuraStackAmount = 1;
}
int32 EffectBasePoints[3];
int32 EffectBasePoints[MAX_SPELL_EFFECTS];
uint32 MaxAffectedTargets;
float RadiusMod;
uint8 AuraStackAmount;
@@ -263,14 +234,6 @@ enum SpellState
SPELL_STATE_DELAYED = 5
};
enum ReplenishType
{
REPLENISH_UNDEFINED = 0,
REPLENISH_HEALTH = 20,
REPLENISH_MANA = 21,
REPLENISH_RAGE = 22
};
enum SpellTargets
{
SPELL_TARGETS_NONE = 0,
@@ -282,6 +245,11 @@ enum SpellTargets
SPELL_TARGETS_GO
};
namespace Trinity
{
struct SpellNotifierCreatureAndPlayer;
}
class Spell
{
friend struct Trinity::SpellNotifierCreatureAndPlayer;
@@ -416,7 +384,7 @@ class Spell
void EffectCastButtons(SpellEffIndex effIndex);
void EffectRechargeManaGem(SpellEffIndex effIndex);
typedef std::set<Aura *> UsedSpellMods;
typedef std::set<Aura*> UsedSpellMods;
Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, bool skipCheck = false);
~Spell();
@@ -469,8 +437,8 @@ class Spell
bool CheckTarget(Unit* target, uint32 eff);
bool CanAutoCast(Unit* target);
void CheckSrc() { if (!m_targets.HasSrc()) m_targets.setSrc(*m_caster); }
void CheckDst() { if (!m_targets.HasDst()) m_targets.setDst(*m_caster); }
void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); }
void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); }
static void SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE);
void SendCastResult(SpellCastResult result);
@@ -565,7 +533,7 @@ class Spell
//Spell data
SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example)
WeaponAttackType m_attackType; // For weapon based attack
int32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare
int32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare
int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare
bool m_canReflect; // can reflect this spell?
bool m_autoRepeat;
+53 -53
View File
@@ -1162,7 +1162,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (Unit* device = seat->GetPassenger(2))
if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
{
float dist = (*itr)->GetExactDistSq(&m_targets.m_dstPos);
float dist = (*itr)->GetExactDistSq(m_targets.GetDst());
if (dist < minDist)
{
minDist = dist;
@@ -1170,13 +1170,13 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
}
}
}
if (target && target->IsWithinDist2d(&m_targets.m_dstPos, GetSpellRadius(m_spellInfo, effIndex, false) * 2)) // now we use *2 because the location of the seat is not correct
if (target && target->IsWithinDist2d(m_targets.GetDst(), GetSpellRadius(m_spellInfo, effIndex, false) * 2)) // now we use *2 because the location of the seat is not correct
passenger->EnterVehicle(target, 0);
else
{
passenger->ExitVehicle();
float x, y, z;
m_targets.m_dstPos.GetPosition(x, y, z);
m_targets.GetDst()->GetPosition(x, y, z);
passenger->GetMotionMaster()->MoveJump(x, y, z, m_targets.GetSpeedXY(), m_targets.GetSpeedZ());
}
}
@@ -1499,10 +1499,10 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
bp = 46585;
if (m_targets.HasDst())
targets.setDst(m_targets.m_dstPos);
targets.SetDst(*m_targets.GetDst());
else
{
targets.setDst(*m_caster);
targets.SetDst(*m_caster);
// Corpse not found - take reagents (only not triggered cast can take them)
triggered = false;
}
@@ -1513,7 +1513,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
// Raise dead - take reagents and trigger summon spells
case 48289:
if (m_targets.HasDst())
targets.setDst(m_targets.m_dstPos);
targets.SetDst(*m_targets.GetDst());
spell_id = CalculateDamage(0, NULL);
break;
@@ -1532,7 +1532,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
return;
}
targets.setUnitTarget(unitTarget);
targets.SetUnitTarget(unitTarget);
Spell* spell = new Spell(m_caster, spellInfo, triggered, m_originalCasterGUID, true);
if (bp) spell->SetSpellValue(SPELLVALUE_BASE_POINT0, bp);
spell->prepare(&targets);
@@ -1834,7 +1834,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
m_caster->ToPlayer()->RemoveSpellCooldown(spellInfo->Id);
float x, y, z;
m_targets.m_dstPos.GetPosition(x, y, z);
m_targets.GetDst()->GetPosition(x, y, z);
m_caster->CastSpell(x, y, z, spellInfo->Id, true, m_CastItem, 0, m_originalCasterGUID);
}
@@ -1844,10 +1844,10 @@ void Spell::EffectJump(SpellEffIndex effIndex)
return;
float x, y, z;
if (m_targets.getUnitTarget())
m_targets.getUnitTarget()->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE);
else if (m_targets.getGOTarget())
m_targets.getGOTarget()->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE);
if (m_targets.GetUnitTarget())
m_targets.GetUnitTarget()->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE);
else if (m_targets.GetGOTarget())
m_targets.GetGOTarget()->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE);
else
{
sLog->outError("Spell::EffectJump - unsupported target mode for spell ID %u", m_spellInfo->Id);
@@ -1868,15 +1868,15 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex)
float x, y, z;
if (m_targets.HasDst())
{
m_targets.m_dstPos.GetPosition(x, y, z);
m_targets.GetDst()->GetPosition(x, y, z);
if (m_spellInfo->EffectImplicitTargetA[effIndex] == TARGET_DEST_TARGET_BACK)
{
// explicit cast data from client or server-side cast
// some spell at client send caster
Unit* pTarget = NULL;
if (m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster)
pTarget = m_targets.getUnitTarget();
if (m_targets.GetUnitTarget() && m_targets.GetUnitTarget() != m_caster)
pTarget = m_targets.GetUnitTarget();
else if (m_caster->getVictim())
pTarget = m_caster->getVictim();
else if (m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -1934,18 +1934,18 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
if (Player* pTarget = unitTarget->ToPlayer())
{
if (pTarget->GetTeamId() == TEAM_ALLIANCE)
m_targets.setDst(442.24f, -835.25f, 44.30f, 0.06f, 628);
m_targets.SetDst(442.24f, -835.25f, 44.30f, 0.06f, 628);
else
m_targets.setDst(1120.43f, -762.11f, 47.92f, 2.94f, 628);
m_targets.SetDst(1120.43f, -762.11f, 47.92f, 2.94f, 628);
}
break;
case 66551: // teleports inside (Isle of Conquest)
if (Player* pTarget = unitTarget->ToPlayer())
{
if (pTarget->GetTeamId() == TEAM_ALLIANCE)
m_targets.setDst(389.57f, -832.38f, 48.65f, 3.00f, 628);
m_targets.SetDst(389.57f, -832.38f, 48.65f, 3.00f, 628);
else
m_targets.setDst(1174.85f, -763.24f, 48.72f, 6.26f, 628);
m_targets.SetDst(1174.85f, -763.24f, 48.72f, 6.26f, 628);
}
break;
}
@@ -1958,13 +1958,13 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
}
// Init dest coordinates
uint32 mapid = m_targets.m_dstPos.GetMapId();
uint32 mapid = m_targets.GetDst()->GetMapId();
if (mapid == MAPID_INVALID)
mapid = unitTarget->GetMapId();
float x, y, z, orientation;
m_targets.m_dstPos.GetPosition(x, y, z, orientation);
if (!orientation && m_targets.getUnitTarget())
orientation = m_targets.getUnitTarget()->GetOrientation();
m_targets.GetDst()->GetPosition(x, y, z, orientation);
if (!orientation && m_targets.GetUnitTarget())
orientation = m_targets.GetUnitTarget()->GetOrientation();
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation);
if (mapid == unitTarget->GetMapId())
@@ -2535,7 +2535,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
if (!caster->IsInWorld())
return;
DynamicObject* dynObj = new DynamicObject();
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, m_targets.m_dstPos, radius, false, DYNAMIC_OBJECT_AREA_SPELL))
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *m_targets.GetDst(), radius, false, DYNAMIC_OBJECT_AREA_SPELL))
{
delete dynObj;
return;
@@ -2896,8 +2896,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
// prevent crash at access and unexpected charges counting with item update queue corrupt
if (m_CastItem == m_targets.getItemTarget())
m_targets.setItemTarget(NULL);
if (m_CastItem == m_targets.GetItemTarget())
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
@@ -2914,8 +2914,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
// prevent crash at access and unexpected charges counting with item update queue corrupt
if (m_CastItem == m_targets.getItemTarget())
m_targets.setItemTarget(NULL);
if (m_CastItem == m_targets.GetItemTarget())
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
@@ -2936,8 +2936,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
if (msg == EQUIP_ERR_CANT_DO_RIGHT_NOW) dest = EQUIPMENT_SLOT_MAINHAND;
// prevent crash at access and unexpected charges counting with item update queue corrupt
if (m_CastItem == m_targets.getItemTarget())
m_targets.setItemTarget(NULL);
if (m_CastItem == m_targets.GetItemTarget())
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
@@ -3305,7 +3305,7 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/)
if (unitTarget->HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING))
return;
float angle = unitTarget->GetAngle(&m_targets.m_dstPos);
float angle = unitTarget->GetAngle(m_targets.GetDst());
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
{
@@ -3348,7 +3348,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex)
return;
DynamicObject* dynObj = new DynamicObject();
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, m_targets.m_dstPos, radius, true, DYNAMIC_OBJECT_FARSIGHT_FOCUS))
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *m_targets.GetDst(), radius, true, DYNAMIC_OBJECT_FARSIGHT_FOCUS))
{
delete dynObj;
return;
@@ -3455,7 +3455,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
// and add a scroll
DoCreateItem(effIndex, m_spellInfo->EffectItemType[effIndex]);
itemTarget=NULL;
m_targets.setItemTarget(NULL);
m_targets.SetItemTarget(NULL);
}
else
{
@@ -3608,7 +3608,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
{
Spell* spell = new Spell(m_caster, spellInfo, true);
SpellCastTargets targets;
targets.setItemTarget(item);
targets.SetItemTarget(item);
spell->prepare(&targets);
}
}
@@ -4248,7 +4248,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
float x, y, z;
if (m_targets.HasDst())
m_targets.m_dstPos.GetPosition(x, y, z);
m_targets.GetDst()->GetPosition(x, y, z);
else
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
@@ -4759,7 +4759,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
float radius = GetSpellRadius(m_spellInfo, effIndex, true);
for (uint8 i = 0; i < 15; ++i)
{
m_caster->GetRandomPoint(m_targets.m_dstPos, radius, x, y, z);
m_caster->GetRandomPoint(*m_targets.GetDst(), radius, x, y, z);
m_caster->CastSpell(x, y, z, 54522, true);
}
break;
@@ -5309,15 +5309,15 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
if (m_spellInfo->SpellFamilyFlags[1]&0x10000)
{
// Get diseases on target of spell
if (m_targets.getUnitTarget() && // Glyph of Disease - cast on unit target too to refresh aura
(m_targets.getUnitTarget() != unitTarget || m_caster->GetAura(63334)))
if (m_targets.GetUnitTarget() && // Glyph of Disease - cast on unit target too to refresh aura
(m_targets.GetUnitTarget() != unitTarget || m_caster->GetAura(63334)))
{
// And spread them on target
// Blood Plague
if (m_targets.getUnitTarget()->GetAura(55078))
if (m_targets.GetUnitTarget()->GetAura(55078))
m_caster->CastSpell(unitTarget, 55078, true);
// Frost Fever
if (m_targets.getUnitTarget()->GetAura(55095))
if (m_targets.GetUnitTarget()->GetAura(55095))
m_caster->CastSpell(unitTarget, 55095, true);
}
}
@@ -5674,7 +5674,7 @@ void Spell::EffectFeedPet(SpellEffIndex effIndex)
Player* _player = m_caster->ToPlayer();
Item* foodItem = m_targets.getItemTarget();
Item* foodItem = m_targets.GetItemTarget();
if (!foodItem)
return;
@@ -5749,7 +5749,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
float x, y, z;
// If dest location if present
if (m_targets.HasDst())
m_targets.m_dstPos.GetPosition(x, y, z);
m_targets.GetDst()->GetPosition(x, y, z);
// Summon in random point all other units if location present
else
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
@@ -5863,7 +5863,7 @@ void Spell::EffectLeap(SpellEffIndex /*effIndex*/)
if (!m_targets.HasDst())
return;
unitTarget->NearTeleportTo(m_targets.m_dstPos.GetPositionX(), m_targets.m_dstPos.GetPositionY(), m_targets.m_dstPos.GetPositionZ(), m_targets.m_dstPos.GetOrientation(), unitTarget == m_caster);
unitTarget->NearTeleportTo(m_targets.GetDst()->GetPositionX(), m_targets.GetDst()->GetPositionY(), m_targets.GetDst()->GetPositionZ(), m_targets.GetDst()->GetOrientation(), unitTarget == m_caster);
}
void Spell::EffectReputation(SpellEffIndex effIndex)
@@ -5984,7 +5984,7 @@ void Spell::EffectSkinning(SpellEffIndex /*effIndex*/)
void Spell::EffectCharge(SpellEffIndex /*effIndex*/)
{
Unit* target = m_targets.getUnitTarget();
Unit* target = m_targets.GetUnitTarget();
if (!target)
return;
@@ -6002,7 +6002,7 @@ void Spell::EffectChargeDest(SpellEffIndex /*effIndex*/)
if (m_targets.HasDst())
{
float x, y, z;
m_targets.m_dstPos.GetPosition(x, y, z);
m_targets.GetDst()->GetPosition(x, y, z);
m_caster->GetMotionMaster()->MoveCharge(x, y, z);
}
}
@@ -6050,7 +6050,7 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex)
if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_KNOCK_BACK_DEST)
{
if (m_targets.HasDst())
m_targets.m_dstPos.GetPosition(x, y);
m_targets.GetDst()->GetPosition(x, y);
else
return;
}
@@ -6068,8 +6068,8 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex)
float speedz = float(damage/10);
if (!speedxy)
{
if (m_targets.getUnitTarget())
m_caster->JumpTo(m_targets.getUnitTarget(), speedz);
if (m_targets.GetUnitTarget())
m_caster->JumpTo(m_targets.GetUnitTarget(), speedz);
}
else
{
@@ -6136,7 +6136,7 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_PULL_TOWARDS_DEST)
{
if (m_targets.HasDst())
pos.Relocate(m_targets.m_dstPos);
pos.Relocate(*m_targets.GetDst());
else
return;
}
@@ -6303,7 +6303,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
float fx, fy, fz;
if (m_targets.HasDst())
m_targets.m_dstPos.GetPosition(fx, fy, fz);
m_targets.GetDst()->GetPosition(fx, fy, fz);
//FIXME: this can be better check for most objects but still hack
else if (m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed == 0)
{
@@ -6893,7 +6893,7 @@ void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 coun
{
// Summon 1 unit in dest location
if (count == 0)
pos.Relocate(m_targets.m_dstPos);
pos.Relocate(*m_targets.GetDst());
// Summon in random point all other units if location present
else
{
@@ -6906,10 +6906,10 @@ void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 coun
break;
case TARGET_DEST_DEST_RANDOM:
case TARGET_DEST_TARGET_RANDOM:
m_caster->GetRandomPoint(m_targets.m_dstPos, radius, pos);
m_caster->GetRandomPoint(*m_targets.GetDst(), radius, pos);
break;
default:
pos.Relocate(m_targets.m_dstPos);
pos.Relocate(*m_targets.GetDst());
break;
}
}
+5
View File
@@ -289,6 +289,11 @@ inline bool IsLootCraftingSpell(SpellEntry const *spellInfo)
(spellInfo->TotemCategory[0] != 0 || spellInfo->EffectItemType[0]==0)));
}
inline bool IsQuestTameSpell(SpellEntry const* spellInfo)
{
return spellInfo->Effect[0] == SPELL_EFFECT_THREAT && spellInfo->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[1] == SPELL_AURA_DUMMY;
}
bool IsHigherHankOfSpell(uint32 spellId_1, uint32 spellId_2);
bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1, SpellSpecific spellSpec2);
bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1, SpellSpecific spellSpec2);
+10 -5
View File
@@ -266,26 +266,31 @@ SpellEntry const* SpellScript::GetSpellInfo()
return m_spell->GetSpellInfo();
}
WorldLocation* SpellScript::GetTargetDest()
WorldLocation const* SpellScript::GetTargetDest()
{
if (m_spell->m_targets.HasDst())
return &m_spell->m_targets.m_dstPos;
return m_spell->m_targets.GetDst();
return NULL;
}
void SpellScript::SetTargetDest(WorldLocation& loc)
{
m_spell->m_targets.SetDst(loc);
}
Unit* SpellScript::GetTargetUnit()
{
return m_spell->m_targets.getUnitTarget();
return m_spell->m_targets.GetUnitTarget();
}
GameObject* SpellScript::GetTargetGObj()
{
return m_spell->m_targets.getGOTarget();
return m_spell->m_targets.GetGOTarget();
}
Item* SpellScript::GetTargetItem()
{
return m_spell->m_targets.getItemTarget();
return m_spell->m_targets.GetItemTarget();
}
Unit* SpellScript::GetHitUnit()
+3 -1
View File
@@ -261,7 +261,9 @@ class SpellScript : public _SpellScript
// accessors to the "focus" targets of the spell
// note: do not confuse these with spell hit targets
// returns: WorldLocation which was selected as a spell destination or NULL
WorldLocation* GetTargetDest();
WorldLocation const* GetTargetDest();
void SetTargetDest(WorldLocation& loc);
// returns: Unit which was selected as a spell target or NULL
Unit* GetTargetUnit();
@@ -47,8 +47,7 @@ public:
}
if (pInstance->GetData(EVENT_STATE)!= CANNON_NOT_USED)
return false;
if (targets.getGOTarget() && targets.getGOTarget()->GetTypeId() == TYPEID_GAMEOBJECT &&
targets.getGOTarget()->GetEntry() == GO_DEFIAS_CANNON)
if (targets.GetGOTarget() && targets.GetGOTarget()->GetEntry() == GO_DEFIAS_CANNON)
{
pInstance->SetData(EVENT_STATE, CANNON_GUNPOWDER_USED);
}
@@ -1478,9 +1478,10 @@ class spell_valanar_kinetic_bomb : public SpellScriptLoader
void ChangeSummonPos(SpellEffIndex /*effIndex*/)
{
WorldLocation* summonPos = GetTargetDest();
WorldLocation summonPos = *GetTargetDest();
Position offset = {0.0f, 0.0f, 20.0f, 0.0f};
summonPos->RelocateOffset(offset); // +20 in height
summonPos.RelocateOffset(offset);
SetTargetDest(summonPos);
}
void Register()
@@ -1260,7 +1260,7 @@ class spell_rimefang_icy_blast : public SpellScriptLoader
void HandleTriggerMissile(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Position* pos = GetTargetDest())
if (Position const* pos = GetTargetDest())
if (TempSummon* summon = GetCaster()->SummonCreature(NPC_ICY_BLAST, *pos, TEMPSUMMON_TIMED_DESPAWN, 40000))
summon->CastSpell(summon, SPELL_ICY_BLAST_AREA, true);
}
@@ -988,7 +988,7 @@ class spell_razorscale_devouring_flame : public SpellScriptLoader
PreventHitDefaultEffect(effIndex);
Unit* caster = GetCaster();
uint32 entry = uint32(GetSpellInfo()->EffectMiscValue[effIndex]);
WorldLocation* summonLocation = GetTargetDest();
WorldLocation const* summonLocation = GetTargetDest();
if (!caster || !summonLocation)
return;
@@ -988,11 +988,11 @@ public:
Vashj = (Unit::GetCreature((*pPlayer), pInstance->GetData64(DATA_LADYVASHJ)));
if (Vashj && (CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->AI())->Phase == 2))
{
if (targets.getGOTarget() && targets.getGOTarget()->GetTypeId() == TYPEID_GAMEOBJECT)
if (GameObject* gObj = targets.GetGOTarget())
{
uint32 identifier;
uint8 channel_identifier;
switch(targets.getGOTarget()->GetEntry())
switch(gObj->GetEntry())
{
case 185052:
identifier = DATA_SHIELDGENERATOR1;
@@ -1035,12 +1035,12 @@ public:
pPlayer->DestroyItemCount(31088, 1, true);
return true;
}
else if (targets.getUnitTarget()->GetTypeId() == TYPEID_UNIT)
else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT)
return false;
else if (targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER)
else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_PLAYER)
{
pPlayer->DestroyItemCount(31088, 1, true);
pPlayer->CastSpell(targets.getUnitTarget(), 38134, true);
pPlayer->CastSpell(targets.GetUnitTarget(), 38134, true);
return true;
}
}