mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[8422] Implement far sight like spells work for long distance.
* Added basic infrastructure for visibility update in case difference player and current view point. Just for note: seletect additional arg way beacuse repeatable search object will slow but store pointer will not safe, so use middle case: get view point pointer early as possible at visibility updates. * Implement dynamic object and creature activisation while it's target of far sight spell effect * Use this for SPELL_AURA_BIND_SIGHT, SPELL_AURA_FAR_SIGHT and SPELL_EFFECT_ADD_FARSIGHT. * Note2: some spyglass like spells let look _around_ at long distance, this hard implement in current grid loading system Without additional changes and not implemented (you will see empty area without creatures in likes case) * Also fixed warning spam at CMSG_MOVE_SET_CAN_FLY_ACK receive by use proper packet sructure reading.
This commit is contained in:
parent
db1c9924a9
commit
45dd7140b5
28 changed files with 228 additions and 144 deletions
|
|
@ -25,8 +25,9 @@
|
|||
#include "GridNotifiers.h"
|
||||
#include "CellImpl.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
DynamicObject::DynamicObject() : WorldObject()
|
||||
DynamicObject::DynamicObject() : WorldObject(), m_isActiveObject(false)
|
||||
{
|
||||
m_objectType |= TYPEMASK_DYNAMICOBJECT;
|
||||
m_objectTypeId = TYPEID_DYNAMICOBJECT;
|
||||
|
|
@ -81,6 +82,11 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
|
|||
m_radius = radius;
|
||||
m_effIndex = effIndex;
|
||||
m_spellId = spellId;
|
||||
|
||||
// set to active for far sight case
|
||||
if(SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId))
|
||||
m_isActiveObject = IsSpellHaveEffect(spellEntry,SPELL_EFFECT_ADD_FARSIGHT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -107,20 +113,24 @@ void DynamicObject::Update(uint32 p_time)
|
|||
else
|
||||
deleteThis = true;
|
||||
|
||||
// TODO: make a timer and update this in larger intervals
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
// have radius and work as persistent effect
|
||||
if(m_radius)
|
||||
{
|
||||
// TODO: make a timer and update this in larger intervals
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
MaNGOS::DynamicObjectUpdater notifier(*this, caster);
|
||||
MaNGOS::DynamicObjectUpdater notifier(*this, caster);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier);
|
||||
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier);
|
||||
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier);
|
||||
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier);
|
||||
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, world_object_notifier, *GetMap());
|
||||
cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap());
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, world_object_notifier, *GetMap());
|
||||
cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap());
|
||||
}
|
||||
|
||||
if(deleteThis)
|
||||
{
|
||||
|
|
@ -143,7 +153,15 @@ void DynamicObject::Delay(int32 delaytime)
|
|||
(*iunit)->DelayAura(m_spellId, m_effIndex, delaytime);
|
||||
}
|
||||
|
||||
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||
bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
|
||||
{
|
||||
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||
if(!IsInWorld() || !u->IsInWorld())
|
||||
return false;
|
||||
|
||||
// always seen by owner
|
||||
if(GetCasterGUID()==u->GetGUID())
|
||||
return true;
|
||||
|
||||
// normal case
|
||||
return IsWithinDistInMap(viewPoint, World::GetMaxVisibleDistanceForObject() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue