094f55e879
* Now cache whether the current spell is channeled on DynamicObjects, and prevent deletion of the object if it is from a channeled spell - Fixes premature channel ending when the object despawns before the cast finshes * Now update SpellAuraHolders for channeled spells on Spell::update to ensure the durations remain synced Now cache whether the spell is channeled * Now add aura holder to spell cast for synced updates in channeled area auras Implemented method to sync periodic ticks with remaining aura duration * Add aura holders to channeled spell caster holder list when a unit enters the area of a dynamic object Now sync persistent effect ticks with the remaining aura duration * No longer process channeled spell holders on target unit update, instead they are now updated in the caster's spell update Now buffer unit spell updates (mostly only applicable for players) rather than updating twice per world update if the unit is a player Fixed an issue where channeled AoE spells initiated with CastSpell were having a unique target set, which caused them to cancel if the unit moved out of the area of effect * Replaced const_iterator usage with plain iterators when performing changes * Implemented additional aura remove types * Implemented passive periodic aura tick syncing on application - the aura still currently updates separately, so it can eventually desync Added new aura remove types to area/persistent aura removal calls Fixed an issue with persistent area auras where all holders of the same spell from different casters would be removed if a unit left the range of one Removed redundant arcane missiles cancellation * Updated RemoveSpellAuraHolder channel handling to coincide with new system * Fixed an issue causing double interrupts for channeled spells which are delayed to 0 duration Implemented removal of aura holders from channeled spells, which can occur when other actions remove the holder (eg, Divine Shield) Now remove all remaining holders on units when a channel is ended * Fixed another case where channeled spells were being interrupted more than once * Fixed a bug which was preventing pushback during channeling from having any effect on the aura holder, allowing the full amount of ticks sometimes (depending on spell duration and hit timing) * Fixed aura tick timers not being updated on area aura application * Fixed totems not updating on the final tick before despawn * Area auras now tick in accordance with the caster's update timer to ensure ticks remain synced and none are lost (eg totems) * Fixed order of finish and channel update on FinishSpell * Removed double interrupt call on mod possess end * Now handle removal of holders from the channeled holders list during spell updates more robustly * Now handle some aura remove modes in spell update for efficiency, while allowing others to be handled normally * No longer check through list of channeled holders on AddChanneledHolders, instead we check before calling for better efficiency * Updated some comments, removed some debug logging * Fixed missing parenthesis - merge broke?
87 lines
3.4 KiB
C++
87 lines
3.4 KiB
C++
/*
|
|
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
|
|
* Copyright (C) 2009-2011 MaNGOSZero <https://github.com/mangos/zero>
|
|
* Copyright (C) 2011-2016 Nostalrius <https://nostalrius.org>
|
|
* Copyright (C) 2016-2017 Elysium Project <https://github.com/elysium-project>
|
|
*
|
|
* 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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef MANGOSSERVER_DYNAMICOBJECT_H
|
|
#define MANGOSSERVER_DYNAMICOBJECT_H
|
|
|
|
#include "Object.h"
|
|
#include "DBCEnums.h"
|
|
#include "Unit.h"
|
|
|
|
enum DynamicObjectType
|
|
{
|
|
DYNAMIC_OBJECT_PORTAL = 0x0, // unused
|
|
DYNAMIC_OBJECT_AREA_SPELL = 0x1,
|
|
DYNAMIC_OBJECT_FARSIGHT_FOCUS = 0x2,
|
|
};
|
|
|
|
class SpellEntry;
|
|
|
|
class DynamicObject : public WorldObject
|
|
{
|
|
public:
|
|
typedef std::map<ObjectGuid, uint32> AffectedMap;
|
|
explicit DynamicObject();
|
|
|
|
void AddToWorld();
|
|
void RemoveFromWorld();
|
|
|
|
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius, DynamicObjectType type);
|
|
void Update(uint32 update_diff, uint32 p_time) override;
|
|
void Delete();
|
|
uint32 GetSpellId() const { return m_spellId; }
|
|
SpellEffectIndex GetEffIndex() const { return m_effIndex; }
|
|
uint32 GetDuration() const { return m_aliveDuration; }
|
|
ObjectGuid const& GetCasterGuid() const { return GetGuidValue(DYNAMICOBJECT_CASTER); }
|
|
Unit* GetCaster() const;
|
|
float GetRadius() const { return m_radius; }
|
|
DynamicObjectType GetType() const { return (DynamicObjectType)GetByteValue(DYNAMICOBJECT_BYTES,0); }
|
|
bool NeedsRefresh(Unit *unit) const;
|
|
bool IsChanneled() const { return m_channeled; }
|
|
void AddAffected(Unit *unit) { m_affected[unit->GetObjectGuid()] = 0; }
|
|
void RemoveAffected(Unit *unit) { m_affected.erase(unit->GetObjectGuid()); }
|
|
void Delay(int32 delaytime);
|
|
|
|
bool IsHostileTo(Unit const* unit) const;
|
|
bool IsFriendlyTo(Unit const* unit) const;
|
|
|
|
float GetObjectBoundingRadius() const // overwrite WorldObject version
|
|
{
|
|
return 0.0f; // dynamic object not have real interact size
|
|
}
|
|
|
|
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
|
|
|
|
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; }
|
|
|
|
protected:
|
|
uint32 m_spellId;
|
|
SpellEffectIndex m_effIndex;
|
|
int32 m_aliveDuration;
|
|
float m_radius; // radius apply persistent effect, 0 = no persistent effect
|
|
bool m_positive;
|
|
bool m_channeled;
|
|
AffectedMap m_affected;
|
|
private:
|
|
GridReference<DynamicObject> m_gridRef;
|
|
};
|
|
#endif
|