diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Spell.cpp | 2 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 34 | ||||
-rw-r--r-- | src/game/SpellAuras.h | 22 | ||||
-rw-r--r-- | src/game/Unit.cpp | 9 |
4 files changed, 39 insertions, 28 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 98439997306..b31c31e795c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1226,7 +1226,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if (aura_effmask) { Unit * caster = m_originalCaster ? m_originalCaster : m_caster; - Aura * Aur = new Aura(m_spellInfo, aura_effmask, m_currentBasePoints, unit, caster, m_CastItem, m_caster); + Aura * Aur = new Aura(m_spellInfo, aura_effmask, m_currentBasePoints, unit, m_caster, caster, m_CastItem); if (!Aur->IsAreaAura()) { diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index b17aa9ad946..a828affef27 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -343,7 +343,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &AuraEffect::HandleUnused, //288 not used by any spells (3.09) except 1 test spell. }; -Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem, Unit * source) : +Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, WorldObject *source, Unit *caster, Item* castItem) : m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target), m_timeCla(1000), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE), m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_auraStateMask(0), m_updated(false), m_isRemoved(false) @@ -453,7 +453,7 @@ Aura::~Aura() delete m_partAuras[i]; } -AuraEffect::AuraEffect(Aura * parentAura, uint8 effIndex, int32 * currentBasePoints , Unit * caster, Item* castItem) : +AuraEffect::AuraEffect(Aura * parentAura, uint8 effIndex, int32 * currentBasePoints , Unit *caster, Item* castItem, WorldObject *source) : m_parentAura(parentAura), m_spellmod(NULL), m_periodicTimer(0), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false), m_target(parentAura->GetTarget()), m_tickNumber(0) { @@ -496,6 +496,7 @@ m_target(parentAura->GetTarget()), m_tickNumber(0) } Player* modOwner = caster ? caster->GetSpellModOwner() : NULL; + m_sourceGUID = source ? source->GetGUID() : (caster ? caster->GetGUID() : 0); m_amplitude = m_spellProto->EffectAmplitude[m_effIndex]; //apply casting time mods for channeled spells @@ -512,12 +513,13 @@ m_target(parentAura->GetTarget()), m_tickNumber(0) } AreaAuraEffect::AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster, Item * castItem, Unit * source) -: AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem) +: AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source) { m_removeTime = FRIENDLY_AA_REMOVE_TIME; m_isAreaAura = true; Unit* caster_ptr = source ? source : caster ? caster : m_target; + //this can be removed, already set in auraeffect m_sourceGUID = caster_ptr->GetGUID(); if (m_spellProto->Effect[effIndex] == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY) @@ -567,8 +569,8 @@ AreaAuraEffect::~AreaAuraEffect() { } -PersistentAreaAuraEffect::PersistentAreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster,Item * castItem) -: AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem) +PersistentAreaAuraEffect::PersistentAreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster,Item * castItem, DynamicObject *source) +: AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source) { m_isPersistent = true; } @@ -577,16 +579,21 @@ PersistentAreaAuraEffect::~PersistentAreaAuraEffect() { } -AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem, Unit* source) +AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem, WorldObject* source) { - assert (parentAura); + // TODO: source should belong to aura, but not areaeffect. multiple areaaura/persistent aura should use one source + assert(parentAura); if (IsAreaAuraEffect(parentAura->GetSpellProto()->Effect[effIndex])) - return new AreaAuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source); + { + //TODO: determine source here + if(source && source->isType(TYPEMASK_UNIT)) + return new AreaAuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, (Unit*)source); + } else if (parentAura->GetSpellProto()->Effect[effIndex] == SPELL_EFFECT_APPLY_AURA) - return new AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem); + return new AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source); else if (parentAura->GetSpellProto()->Effect[effIndex] == SPELL_EFFECT_PERSISTENT_AREA_AURA) return new PersistentAreaAuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem); - else return NULL; + return NULL; } Unit* Aura::GetCaster() const @@ -600,14 +607,15 @@ Unit* Aura::GetCaster() const return unit && unit->IsInWorld() ? unit : NULL; } -Unit* AreaAuraEffect::GetSource() const +Unit* AuraEffect::GetSource() const { - if(m_sourceGUID==m_target->GetGUID()) + if(m_sourceGUID == m_target->GetGUID()) return m_target; //return ObjectAccessor::GetUnit(*m_target,m_caster_guid); //must return caster even if it's in another grid/map Unit *unit = ObjectAccessor::GetObjectInWorld(m_sourceGUID, (Unit*)NULL); + //only player can be not in world while in objectaccessor return unit && unit->IsInWorld() ? unit : NULL; } @@ -6811,7 +6819,7 @@ void AuraEffect::HandleAuraControlVehicle(bool apply, bool Real, bool /*changeAm if(m_target->GetTypeId() != TYPEID_UNIT || !((Creature*)m_target)->isVehicle()) return; - Unit *caster = GetCaster(); + Unit *caster = GetSource(); if(!caster || caster == m_target) return; diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index f936b4e4174..76433ac4acd 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -54,7 +54,7 @@ class TRINITY_DLL_SPEC Aura friend void Player::SendAurasForTarget(Unit *target); public: virtual ~Aura(); - Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL, Unit * source=NULL); + explicit Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, WorldObject *source = NULL, Unit *caster = NULL, Item *castItem = NULL); SpellEntry const* GetSpellProto() const { return m_spellProto; } uint32 GetId() const{ return m_spellProto->Id; } @@ -171,7 +171,7 @@ class TRINITY_DLL_SPEC Aura class TRINITY_DLL_SPEC AuraEffect { public: - friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem, Unit * source); + friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem, WorldObject *source); friend void Aura::SetStackAmount(uint8 stackAmount, bool applied); //aura handlers void HandleNULL(bool, bool, bool) @@ -333,8 +333,9 @@ class TRINITY_DLL_SPEC AuraEffect // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras void HandleShapeshiftBoosts(bool apply); - inline Unit * GetCaster() const{ return m_parentAura->GetCaster(); } - inline uint64 GetCasterGUID() const{ return m_parentAura->GetCasterGUID(); } + Unit * GetCaster() const { return m_parentAura->GetCaster(); } + uint64 GetCasterGUID() const{ return m_parentAura->GetCasterGUID(); } + Unit* GetSource() const; // { return m_parentAura->GetSource(); } Aura * GetParentAura() const { return m_parentAura; } SpellEntry const* GetSpellProto() const { return m_spellProto; } @@ -369,9 +370,10 @@ class TRINITY_DLL_SPEC AuraEffect void CleanupTriggeredSpells(); protected: - AuraEffect (Aura * parentAura, uint8 effIndex, int32 * currentBasePoints , Unit * caster,Item * castItem); + explicit AuraEffect(Aura * parentAura, uint8 effIndex, int32 *currentBasePoints , Unit *caster, Item *castItem, WorldObject *source); Aura * const m_parentAura; Unit * const m_target; + uint64 m_sourceGUID; // Spell::m_caster/trap? for normal aura, totem/paladin for areaaura, dynobj for persistent aura SpellEntry const *m_spellProto; uint32 m_tickNumber; @@ -394,23 +396,23 @@ class TRINITY_DLL_SPEC AuraEffect class TRINITY_DLL_SPEC AreaAuraEffect : public AuraEffect { public: - AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster=NULL, Item * castItem=NULL, Unit * source=NULL); + AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster=NULL, Item * castItem=NULL, Unit * source = NULL); ~AreaAuraEffect(); - Unit* GetSource() const; void Update(uint32 diff); private: float m_radius; int32 m_removeTime; AreaAuraType m_areaAuraType; - uint64 m_sourceGUID; // used for check range }; class TRINITY_DLL_SPEC PersistentAreaAuraEffect : public AuraEffect { public: - PersistentAreaAuraEffect(Aura * parentAura, uint32 eff, int32 *currentBasePoints, Unit *caster = NULL, Item* castItem = NULL); + PersistentAreaAuraEffect(Aura * parentAura, uint32 eff, int32 *currentBasePoints, Unit *caster = NULL, Item* castItem = NULL, DynamicObject * source = NULL); ~PersistentAreaAuraEffect(); void Update(uint32 diff); }; -AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem = NULL, Unit * source=NULL); + +AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit *caster, Item *castItem = NULL, WorldObject *source = NULL); + #endif diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7c04f8e9c70..17b618cb3cd 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -13762,7 +13762,8 @@ void Unit::AddAura(uint32 spellId, Unit* target) if (!eff_mask) return; - Aura *Aur = new Aura(spellInfo, eff_mask, NULL, target, this, NULL, target); + //TODO: we use target as source for now, but that may not be true + Aura *Aur = new Aura(spellInfo, eff_mask, NULL, target, target, this, NULL); target->AddAura(Aur); } @@ -13787,10 +13788,10 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, Unit* c { int32 amount[3]; amount[effIndex] = *basePoints; - aur = new Aura(spellInfo, 1<<effIndex, amount, this ,caster, NULL,source); + aur = new Aura(spellInfo, 1<<effIndex, amount, this, source, caster, NULL); } else - aur = new Aura(spellInfo, 1<<effIndex, NULL, this ,caster, NULL,source); + aur = new Aura(spellInfo, 1<<effIndex, NULL, this, source ,caster, NULL); if(!AddAura(aur)) return NULL; @@ -13959,7 +13960,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) } m_Vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24); - m_Vehicle->setFaction(getFaction()); + //m_Vehicle->setFaction(getFaction()); addUnitState(UNIT_STAT_ONVEHICLE); //movementInfo is set in AddPassenger |