Core/DynamicObject: Research dynamicobject types, added DynamicObjectType enum
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
DynamicObject::DynamicObject() : WorldObject()
|
||||
DynamicObject::DynamicObject() : WorldObject(),
|
||||
_aura(NULL), _caster(NULL), _duration(0), _isViewpoint(false)
|
||||
{
|
||||
m_objectType |= TYPEMASK_DYNAMICOBJECT;
|
||||
m_objectTypeId = TYPEID_DYNAMICOBJECT;
|
||||
@@ -35,19 +36,14 @@ DynamicObject::DynamicObject() : WorldObject()
|
||||
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION);
|
||||
|
||||
m_valuesCount = DYNAMICOBJECT_END;
|
||||
|
||||
m_aura = NULL;
|
||||
m_duration = 0;
|
||||
m_caster = NULL;
|
||||
m_isViewpoint = false;
|
||||
}
|
||||
|
||||
DynamicObject::~DynamicObject()
|
||||
{
|
||||
// make sure all references were properly removed
|
||||
ASSERT(!m_aura);
|
||||
ASSERT(!m_caster);
|
||||
ASSERT(!m_isViewpoint);
|
||||
ASSERT(!_aura);
|
||||
ASSERT(!_caster);
|
||||
ASSERT(!_isViewpoint);
|
||||
}
|
||||
|
||||
void DynamicObject::AddToWorld()
|
||||
@@ -66,10 +62,10 @@ void DynamicObject::RemoveFromWorld()
|
||||
///- Remove the dynamicObject from the accessor and from all lists of objects in world
|
||||
if (IsInWorld())
|
||||
{
|
||||
if (m_isViewpoint)
|
||||
if (_isViewpoint)
|
||||
RemoveCasterViewpoint();
|
||||
|
||||
if (m_aura)
|
||||
if (_aura)
|
||||
RemoveAura();
|
||||
|
||||
// dynobj could get removed in Aura::RemoveAura
|
||||
@@ -82,7 +78,7 @@ void DynamicObject::RemoveFromWorld()
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, const Position &pos, float radius, bool active)
|
||||
bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type)
|
||||
{
|
||||
SetMap(caster->GetMap());
|
||||
Relocate(pos);
|
||||
@@ -103,7 +99,7 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, const P
|
||||
// If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but
|
||||
// precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells
|
||||
// I saw sniffed...
|
||||
SetUInt32Value(DYNAMICOBJECT_BYTES, 0x00000001);
|
||||
SetByteValue(DYNAMICOBJECT_BYTES, 0, type);
|
||||
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
|
||||
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
|
||||
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());
|
||||
@@ -115,24 +111,24 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, const P
|
||||
void DynamicObject::Update(uint32 p_time)
|
||||
{
|
||||
// caster has to be always avalible and in the same map
|
||||
ASSERT(m_caster);
|
||||
ASSERT(m_caster->GetMap() == GetMap());
|
||||
ASSERT(_caster);
|
||||
ASSERT(_caster->GetMap() == GetMap());
|
||||
|
||||
bool expired = false;
|
||||
|
||||
if (m_aura)
|
||||
if (_aura)
|
||||
{
|
||||
if (!m_aura->IsRemoved())
|
||||
m_aura->UpdateOwner(p_time, this);
|
||||
if (!_aura->IsRemoved())
|
||||
_aura->UpdateOwner(p_time, this);
|
||||
|
||||
// m_aura may be set to null in Aura::UpdateOwner call
|
||||
if (m_aura && (m_aura->IsRemoved() || m_aura->IsExpired()))
|
||||
if (_aura && (_aura->IsRemoved() || _aura->IsExpired()))
|
||||
expired = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetDuration() > int32(p_time))
|
||||
m_duration -= p_time;
|
||||
_duration -= p_time;
|
||||
else
|
||||
expired = true;
|
||||
}
|
||||
@@ -155,18 +151,18 @@ void DynamicObject::Remove()
|
||||
|
||||
int32 DynamicObject::GetDuration() const
|
||||
{
|
||||
if (!m_aura)
|
||||
return m_duration;
|
||||
if (!_aura)
|
||||
return _duration;
|
||||
else
|
||||
return m_aura->GetDuration();
|
||||
return _aura->GetDuration();
|
||||
}
|
||||
|
||||
void DynamicObject::SetDuration(int32 newDuration)
|
||||
{
|
||||
if (!m_aura)
|
||||
m_duration = newDuration;
|
||||
if (!_aura)
|
||||
_duration = newDuration;
|
||||
else
|
||||
m_aura->SetDuration(newDuration);
|
||||
_aura->SetDuration(newDuration);
|
||||
}
|
||||
|
||||
void DynamicObject::Delay(int32 delaytime)
|
||||
@@ -174,51 +170,51 @@ void DynamicObject::Delay(int32 delaytime)
|
||||
SetDuration(GetDuration() - delaytime);
|
||||
}
|
||||
|
||||
void DynamicObject::SetAura(Aura * aura)
|
||||
void DynamicObject::SetAura(Aura* aura)
|
||||
{
|
||||
ASSERT (!m_aura && aura);
|
||||
m_aura = aura;
|
||||
ASSERT(!_aura && aura);
|
||||
_aura = aura;
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveAura()
|
||||
{
|
||||
ASSERT (m_aura);
|
||||
if (!m_aura->IsRemoved())
|
||||
m_aura->_Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
delete m_aura;
|
||||
m_aura = NULL;
|
||||
ASSERT(_aura);
|
||||
if (!_aura->IsRemoved())
|
||||
_aura->_Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
delete _aura;
|
||||
_aura = NULL;
|
||||
}
|
||||
|
||||
void DynamicObject::SetCasterViewpoint()
|
||||
{
|
||||
if (Player * caster = m_caster->ToPlayer())
|
||||
if (Player* caster = _caster->ToPlayer())
|
||||
{
|
||||
caster->SetViewpoint(this, true);
|
||||
m_isViewpoint = true;
|
||||
_isViewpoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveCasterViewpoint()
|
||||
{
|
||||
if (Player * caster = m_caster->ToPlayer())
|
||||
if (Player * caster = _caster->ToPlayer())
|
||||
{
|
||||
caster->SetViewpoint(this, false);
|
||||
m_isViewpoint = false;
|
||||
_isViewpoint = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::BindToCaster()
|
||||
{
|
||||
ASSERT(!m_caster);
|
||||
m_caster = ObjectAccessor::GetUnit(*this, GetCasterGUID());
|
||||
ASSERT(m_caster);
|
||||
ASSERT(m_caster->GetMap() == GetMap());
|
||||
m_caster->_RegisterDynObject(this);
|
||||
ASSERT(!_caster);
|
||||
_caster = ObjectAccessor::GetUnit(*this, GetCasterGUID());
|
||||
ASSERT(_caster);
|
||||
ASSERT(_caster->GetMap() == GetMap());
|
||||
_caster->_RegisterDynObject(this);
|
||||
}
|
||||
|
||||
void DynamicObject::UnbindFromCaster()
|
||||
{
|
||||
ASSERT(m_caster);
|
||||
m_caster->_UnregisterDynObject(this);
|
||||
m_caster = NULL;
|
||||
ASSERT(_caster);
|
||||
_caster->_UnregisterDynObject(this);
|
||||
_caster = NULL;
|
||||
}
|
||||
|
||||
@@ -25,42 +25,49 @@ class Unit;
|
||||
class Aura;
|
||||
struct SpellEntry;
|
||||
|
||||
enum DynamicObjectType
|
||||
{
|
||||
DYNAMIC_OBJECT_PORTAL = 0x0, // unused
|
||||
DYNAMIC_OBJECT_AREA_SPELL = 0x1,
|
||||
DYNAMIC_OBJECT_FARSIGHT_FOCUS = 0x2,
|
||||
};
|
||||
|
||||
class DynamicObject : public WorldObject, public GridObject<DynamicObject>
|
||||
{
|
||||
public:
|
||||
explicit DynamicObject();
|
||||
DynamicObject();
|
||||
~DynamicObject();
|
||||
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
|
||||
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, const Position &pos, float radius, bool active);
|
||||
bool Create(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type);
|
||||
void Update(uint32 p_time);
|
||||
void Remove();
|
||||
void SetDuration(int32 newDuration);
|
||||
int32 GetDuration() const;
|
||||
void Delay(int32 delaytime);
|
||||
void SetAura(Aura * aura);
|
||||
void SetAura(Aura* aura);
|
||||
void RemoveAura();
|
||||
void SetCasterViewpoint();
|
||||
void RemoveCasterViewpoint();
|
||||
Unit * GetCaster() const { return m_caster; }
|
||||
Unit* GetCaster() const { return _caster; }
|
||||
void BindToCaster();
|
||||
void UnbindFromCaster();
|
||||
uint32 GetSpellId() const { return GetUInt32Value(DYNAMICOBJECT_SPELLID); }
|
||||
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
|
||||
float GetRadius() const { return GetFloatValue(DYNAMICOBJECT_RADIUS); }
|
||||
|
||||
void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
|
||||
void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
|
||||
void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
|
||||
void Whisper(int32 textId,uint64 receiver) { MonsterWhisper(textId,receiver); }
|
||||
void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
|
||||
void Say(int32 textId, uint32 language, uint64 targetGuid) { MonsterSay(textId, language, targetGuid); }
|
||||
void Yell(int32 textId, uint32 language, uint64 targetGuid) { MonsterYell(textId, language, targetGuid); }
|
||||
void TextEmote(int32 textId, uint64 targetGuid) { MonsterTextEmote(textId, targetGuid); }
|
||||
void Whisper(int32 textId,uint64 receiver) { MonsterWhisper(textId, receiver); }
|
||||
void YellToZone(int32 textId, uint32 language, uint64 targetGuid) { MonsterYellToZone(textId, language, targetGuid); }
|
||||
|
||||
protected:
|
||||
int32 m_duration; // for non-aura dynobjects
|
||||
Aura * m_aura;
|
||||
Unit * m_caster;
|
||||
bool m_isViewpoint;
|
||||
Aura* _aura;
|
||||
Unit* _caster;
|
||||
int32 _duration; // for non-aura dynobjects
|
||||
bool _isViewpoint;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2541,15 +2541,16 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
|
||||
// Caster not in world, might be spell triggered from aura removal
|
||||
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))
|
||||
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))
|
||||
{
|
||||
delete dynObj;
|
||||
return;
|
||||
}
|
||||
|
||||
dynObj->GetMap()->Add(dynObj);
|
||||
|
||||
if (Aura * aura = Aura::TryCreate(m_spellInfo, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
|
||||
if (Aura* aura = Aura::TryCreate(m_spellInfo, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
|
||||
{
|
||||
m_spellAura = aura;
|
||||
m_spellAura->_RegisterForTargets();
|
||||
@@ -2557,6 +2558,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT(m_spellAura->GetDynobjOwner());
|
||||
m_spellAura->_ApplyEffectForTargets(effIndex);
|
||||
}
|
||||
@@ -3382,14 +3384,15 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex)
|
||||
// Caster not in world, might be spell triggered from aura removal
|
||||
if (!m_caster->IsInWorld())
|
||||
return;
|
||||
DynamicObject* dynObj = new DynamicObject;
|
||||
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, m_targets.m_dstPos, radius, true))
|
||||
|
||||
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))
|
||||
{
|
||||
delete dynObj;
|
||||
return;
|
||||
}
|
||||
|
||||
dynObj->SetDuration(duration);
|
||||
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002);
|
||||
|
||||
dynObj->setActive(true); //must before add to map to be put in world container
|
||||
dynObj->GetMap()->Add(dynObj); //grid will also be loaded
|
||||
|
||||
Reference in New Issue
Block a user