2010-10-07 15:54:07 +02:00
/*
2020-01-02 06:44:10 +01:00
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
2010-10-07 15:54:07 +02:00
*
* 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/>.
2008-10-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#ifndef _OBJECT_H
#define _OBJECT_H
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include "Common.h"
2017-11-30 20:45:44 +01:00
#include "Duration.h"
2018-02-10 16:43:01 -03:00
#include "EventProcessor.h"
2010-06-08 13:05:47 -06:00
#include "GridReference.h"
2017-05-15 22:55:16 +02:00
#include "GridRefManager.h"
2017-01-21 14:44:31 +01:00
#include "ModelIgnoreFlags.h"
2017-05-21 23:18:43 +02:00
#include "MovementInfo.h"
#include "ObjectDefines.h"
2017-05-15 22:55:16 +02:00
#include "ObjectGuid.h"
2019-01-16 20:48:01 +01:00
#include "Optional.h"
2018-01-28 11:37:20 +01:00
#include "PhaseShift.h"
2017-05-15 22:55:16 +02:00
#include "Position.h"
#include "SharedDefines.h"
2020-11-15 21:59:18 +01:00
#include "SpellDefines.h"
2016-07-10 00:11:19 +02:00
#include "UpdateFields.h"
2017-05-15 22:55:16 +02:00
#include <list>
#include <unordered_map>
2009-10-17 15:51:44 -07:00
2017-05-14 12:49:48 +02:00
class AreaTrigger ;
class Conversation ;
2013-03-25 10:36:30 +01:00
class Corpse ;
2008-10-02 16:23:55 -05:00
class Creature ;
2013-03-25 10:36:30 +01:00
class CreatureAI ;
class DynamicObject ;
2008-10-17 18:13:04 -05:00
class GameObject ;
2013-03-25 10:36:30 +01:00
class InstanceScript ;
2017-05-14 12:49:48 +02:00
class Map ;
2019-06-03 20:40:34 +02:00
class Object ;
2013-03-25 10:36:30 +01:00
class Player ;
2016-11-06 23:30:49 +01:00
class Scenario ;
2018-02-10 16:43:01 -03:00
class Spell ;
class SpellCastTargets ;
2021-09-04 15:13:15 +02:00
class SpellEffectInfo ;
2018-02-10 16:43:01 -03:00
class SpellInfo ;
2009-03-19 14:41:30 -06:00
class TempSummon ;
2010-07-30 21:54:46 -07:00
class Transport ;
2013-03-25 10:36:30 +01:00
class Unit ;
class UpdateData ;
class WorldObject ;
class WorldPacket ;
class ZoneScript ;
2018-02-10 16:43:01 -03:00
struct FactionTemplateEntry ;
2017-06-08 00:25:06 +02:00
struct PositionFullTerrainStatus ;
2017-05-28 16:34:44 +02:00
struct QuaternionData ;
2017-05-14 12:49:48 +02:00
2018-02-10 16:43:01 -03:00
namespace WorldPackets
{
namespace CombatLog
{
class CombatLogServerPacket ;
}
}
2014-05-01 10:10:13 +02:00
typedef std :: unordered_map < Player * , UpdateData > UpdateDataMapType ;
2010-07-30 21:54:46 -07:00
2018-10-04 18:50:21 +02:00
struct CreateObjectBits
{
bool NoBirthAnim : 1 ;
bool EnablePortals : 1 ;
bool PlayHoverAnim : 1 ;
bool MovementUpdate : 1 ;
bool MovementTransport : 1 ;
bool Stationary : 1 ;
bool CombatVictim : 1 ;
bool ServerTime : 1 ;
bool Vehicle : 1 ;
bool AnimKit : 1 ;
bool Rotation : 1 ;
bool AreaTrigger : 1 ;
bool GameObject : 1 ;
bool SmoothPhasing : 1 ;
bool ThisIsYou : 1 ;
bool SceneObject : 1 ;
bool ActivePlayer : 1 ;
bool Conversation : 1 ;
void Clear ()
{
memset ( this , 0 , sizeof ( CreateObjectBits ));
}
};
2019-06-03 20:40:34 +02:00
namespace UF
2016-07-11 17:14:42 +02:00
{
2019-06-03 20:40:34 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
inline bool SetUpdateFieldValue ( UpdateFieldSetter < T >& setter , typename UpdateFieldSetter < T >:: value_type && value )
2016-07-13 00:07:09 +02:00
{
2019-06-03 20:40:34 +02:00
return setter . SetValue ( std :: move ( value ));
2016-07-13 00:07:09 +02:00
}
2016-07-11 17:14:42 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
inline typename DynamicUpdateFieldSetter < T >:: insert_result AddDynamicUpdateFieldValue ( DynamicUpdateFieldSetter < T >& setter )
2016-07-11 17:14:42 +02:00
{
2019-06-03 20:40:34 +02:00
return setter . AddValue ();
2016-07-11 17:14:42 +02:00
}
2019-06-03 20:40:34 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
inline typename DynamicUpdateFieldSetter < T >:: insert_result InsertDynamicUpdateFieldValue ( DynamicUpdateFieldSetter < T >& setter , uint32 index )
2016-07-10 14:41:18 +02:00
{
2019-06-03 20:40:34 +02:00
return setter . InsertValue ( index );
2016-07-10 14:41:18 +02:00
}
2019-06-03 20:40:34 +02:00
template < typename T >
inline void RemoveDynamicUpdateFieldValue ( DynamicUpdateFieldSetter < T >& setter , uint32 index )
2016-07-10 14:41:18 +02:00
{
2019-06-03 20:40:34 +02:00
setter . RemoveValue ( index );
2016-07-10 14:41:18 +02:00
}
2019-06-03 20:40:34 +02:00
template < typename T >
inline void ClearDynamicUpdateFieldValues ( DynamicUpdateFieldSetter < T >& setter )
2016-07-10 14:41:18 +02:00
{
2019-06-03 20:40:34 +02:00
setter . Clear ();
2016-07-10 14:41:18 +02:00
}
2019-10-25 19:29:52 +02:00
template < typename T >
inline void RemoveOptionalUpdateFieldValue ( OptionalUpdateFieldSetter < T >& setter )
{
setter . RemoveValue ();
}
2019-06-03 20:40:34 +02:00
}
2016-07-10 14:41:18 +02:00
2017-12-29 22:32:07 +01:00
float const DEFAULT_COLLISION_HEIGHT = 2.03128f ; // Most common value in dbc
2016-03-11 16:37:14 +01:00
class TC_GAME_API Object
2008-10-02 16:23:55 -05:00
{
public :
2012-05-30 08:01:02 +02:00
virtual ~ Object ();
2009-10-17 15:51:44 -07:00
2011-08-01 14:23:27 +02:00
bool IsInWorld () const { return m_inWorld ; }
2009-10-17 15:51:44 -07:00
2011-08-30 13:46:36 +02:00
virtual void AddToWorld ();
virtual void RemoveFromWorld ();
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
ObjectGuid const & GetGUID () const { return m_guid ; }
uint32 GetEntry () const { return m_objectData -> EntryID ; }
void SetEntry ( uint32 entry ) { SetUpdateFieldValue ( m_values . ModifyValue ( & Object :: m_objectData ). ModifyValue ( & UF :: ObjectData :: EntryID ), entry ); }
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
float GetObjectScale () const { return m_objectData -> Scale ; }
virtual void SetObjectScale ( float scale ) { SetUpdateFieldValue ( m_values . ModifyValue ( & Object :: m_objectData ). ModifyValue ( & UF :: ObjectData :: Scale ), scale ); }
uint32 GetDynamicFlags () const { return m_objectData -> DynamicFlags ; }
bool HasDynamicFlag ( uint32 flag ) const { return ( * m_objectData -> DynamicFlags & flag ) != 0 ; }
void AddDynamicFlag ( uint32 flag ) { SetUpdateFieldFlagValue ( m_values . ModifyValue ( & Object :: m_objectData ). ModifyValue ( & UF :: ObjectData :: DynamicFlags ), flag ); }
void RemoveDynamicFlag ( uint32 flag ) { RemoveUpdateFieldFlagValue ( m_values . ModifyValue ( & Object :: m_objectData ). ModifyValue ( & UF :: ObjectData :: DynamicFlags ), flag ); }
void SetDynamicFlags ( uint32 flag ) { SetUpdateFieldValue ( m_values . ModifyValue ( & Object :: m_objectData ). ModifyValue ( & UF :: ObjectData :: DynamicFlags ), flag ); }
2012-05-30 08:01:02 +02:00
2009-08-06 10:38:46 -05:00
TypeID GetTypeId () const { return m_objectTypeId ; }
2014-07-17 15:42:57 +02:00
bool isType ( uint16 mask ) const { return ( mask & m_objectType ) != 0 ; }
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
virtual void BuildCreateUpdateBlockForPlayer ( UpdateData * data , Player * target ) const ;
2009-12-19 19:46:07 +01:00
void SendUpdateToPlayer ( Player * player );
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
void BuildValuesUpdateBlockForPlayer ( UpdateData * data , Player const * target ) const ;
void BuildValuesUpdateBlockForPlayerWithFlag ( UpdateData * data , UF :: UpdateFieldFlag flags , Player const * target ) const ;
2020-02-09 17:47:25 +01:00
void BuildDestroyUpdateBlock ( UpdateData * data ) const ;
2011-09-15 14:08:17 +02:00
void BuildOutOfRangeUpdateBlock ( UpdateData * data ) const ;
2020-04-23 20:22:53 +02:00
ByteBuffer PrepareValuesUpdateBuffer () const ;
2009-10-17 15:51:44 -07:00
2015-01-01 20:38:19 +01:00
virtual void DestroyForPlayer ( Player * target ) const ;
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
virtual void ClearUpdateMask ( bool remove );
2009-10-17 15:51:44 -07:00
2020-04-18 10:59:35 +02:00
virtual std :: string GetNameForLocaleIdx ( LocaleConstant locale ) const = 0 ;
2008-10-02 16:23:55 -05:00
virtual bool hasQuest ( uint32 /* quest_id */ ) const { return false ; }
virtual bool hasInvolvedQuest ( uint32 /* quest_id */ ) const { return false ; }
2017-12-15 22:11:02 -02:00
void SetIsNewObject ( bool enable ) { m_isNewObject = enable ; }
2013-10-27 22:27:46 +01:00
virtual void BuildUpdate ( UpdateDataMapType & ) { }
2011-09-29 12:43:05 +02:00
void BuildFieldsUpdate ( Player * , UpdateDataMapType & ) const ;
2009-10-17 15:51:44 -07:00
2017-07-29 21:40:28 +02:00
inline bool IsPlayer () const { return GetTypeId () == TYPEID_PLAYER ; }
Player * ToPlayer () { if ( IsPlayer ()) return reinterpret_cast < Player *> ( this ); else return nullptr ; }
Player const * ToPlayer () const { if ( IsPlayer ()) return reinterpret_cast < Player const *> ( this ); else return nullptr ; }
2012-08-07 13:27:33 +02:00
2017-07-29 21:40:28 +02:00
inline bool IsCreature () const { return GetTypeId () == TYPEID_UNIT ; }
Creature * ToCreature () { if ( IsCreature ()) return reinterpret_cast < Creature *> ( this ); else return nullptr ; }
Creature const * ToCreature () const { if ( IsCreature ()) return reinterpret_cast < Creature const *> ( this ); else return nullptr ; }
2012-08-07 13:27:33 +02:00
2017-07-29 21:40:28 +02:00
inline bool IsUnit () const { return isType ( TYPEMASK_UNIT ); }
Unit * ToUnit () { if ( IsUnit ()) return reinterpret_cast < Unit *> ( this ); else return nullptr ; }
Unit const * ToUnit () const { if ( IsUnit ()) return reinterpret_cast < Unit const *> ( this ); else return nullptr ; }
2010-03-07 15:20:19 +01:00
2017-07-29 21:40:28 +02:00
inline bool IsGameObject () const { return GetTypeId () == TYPEID_GAMEOBJECT ; }
GameObject * ToGameObject () { if ( IsGameObject ()) return reinterpret_cast < GameObject *> ( this ); else return nullptr ; }
GameObject const * ToGameObject () const { if ( IsGameObject ()) return reinterpret_cast < GameObject const *> ( this ); else return nullptr ; }
2011-08-26 12:05:47 +02:00
2017-07-29 21:40:28 +02:00
inline bool IsCorpse () const { return GetTypeId () == TYPEID_CORPSE ; }
Corpse * ToCorpse () { if ( IsCorpse ()) return reinterpret_cast < Corpse *> ( this ); else return nullptr ; }
Corpse const * ToCorpse () const { if ( IsCorpse ()) return reinterpret_cast < Corpse const *> ( this ); else return nullptr ; }
2009-10-17 15:51:44 -07:00
2017-07-29 21:40:28 +02:00
inline bool IsDynObject () const { return GetTypeId () == TYPEID_DYNAMICOBJECT ; }
DynamicObject * ToDynObject () { if ( IsDynObject ()) return reinterpret_cast < DynamicObject *> ( this ); else return nullptr ; }
DynamicObject const * ToDynObject () const { if ( IsDynObject ()) return reinterpret_cast < DynamicObject const *> ( this ); else return nullptr ; }
2012-08-07 13:27:33 +02:00
2017-07-29 21:40:28 +02:00
inline bool IsAreaTrigger () const { return GetTypeId () == TYPEID_AREATRIGGER ; }
AreaTrigger * ToAreaTrigger () { if ( IsAreaTrigger ()) return reinterpret_cast < AreaTrigger *> ( this ); else return nullptr ; }
AreaTrigger const * ToAreaTrigger () const { if ( IsAreaTrigger ()) return reinterpret_cast < AreaTrigger const *> ( this ); else return nullptr ; }
2013-05-26 04:56:43 +03:00
2017-07-29 21:40:28 +02:00
inline bool IsConversation () const { return GetTypeId () == TYPEID_CONVERSATION ; }
Conversation * ToConversation () { if ( GetTypeId () == TYPEID_CONVERSATION ) return reinterpret_cast < Conversation *> ( this ); else return nullptr ; }
Conversation const * ToConversation () const { if ( GetTypeId () == TYPEID_CONVERSATION ) return reinterpret_cast < Conversation const *> ( this ); else return nullptr ; }
2017-05-14 11:40:55 +02:00
2019-06-03 20:40:34 +02:00
UF :: UpdateFieldHolder m_values ;
UF :: UpdateField < UF :: ObjectData , 0 , TYPEID_OBJECT > m_objectData ;
template < typename T >
void ForceUpdateFieldChange ( UF :: UpdateFieldSetter < T > const & /*setter*/ )
{
AddToObjectUpdateIfNeeded ();
}
2012-08-07 13:27:33 +02:00
protected :
2012-05-30 08:01:02 +02:00
Object ();
2009-10-17 15:51:44 -07:00
2014-10-29 21:13:21 +01:00
void _Create ( ObjectGuid const & guid );
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
void SetUpdateFieldValue ( UF :: UpdateFieldSetter < T > setter , typename UF :: UpdateFieldSetter < T >:: value_type value )
2019-06-03 20:40:34 +02:00
{
if ( UF :: SetUpdateFieldValue ( setter , std :: move ( value )))
AddToObjectUpdateIfNeeded ();
}
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
void SetUpdateFieldFlagValue ( UF :: UpdateFieldSetter < T > setter , typename UF :: UpdateFieldSetter < T >:: value_type flag )
2019-06-03 20:40:34 +02:00
{
static_assert ( std :: is_integral < T >:: value , "SetUpdateFieldFlagValue must be used with integral types" );
SetUpdateFieldValue ( setter , setter . GetValue () | flag );
}
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
void RemoveUpdateFieldFlagValue ( UF :: UpdateFieldSetter < T > setter , typename UF :: UpdateFieldSetter < T >:: value_type flag )
2019-06-03 20:40:34 +02:00
{
static_assert ( std :: is_integral < T >:: value , "RemoveUpdateFieldFlagValue must be used with integral types" );
SetUpdateFieldValue ( setter , setter . GetValue () & ~ flag );
}
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
template < typename T >
2020-11-21 12:18:22 +01:00
typename UF :: DynamicUpdateFieldSetter < T >:: insert_result AddDynamicUpdateFieldValue ( UF :: DynamicUpdateFieldSetter < T > setter )
2019-06-03 20:40:34 +02:00
{
AddToObjectUpdateIfNeeded ();
return UF :: AddDynamicUpdateFieldValue ( setter );
}
template < typename T >
2020-11-21 12:18:22 +01:00
typename UF :: DynamicUpdateFieldSetter < T >:: insert_result InsertDynamicUpdateFieldValue ( UF :: DynamicUpdateFieldSetter < T > setter , uint32 index )
2019-06-03 20:40:34 +02:00
{
AddToObjectUpdateIfNeeded ();
return UF :: InsertDynamicUpdateFieldValue ( setter , index );
}
template < typename T >
void RemoveDynamicUpdateFieldValue ( UF :: DynamicUpdateFieldSetter < T > setter , uint32 index )
{
AddToObjectUpdateIfNeeded ();
UF :: RemoveDynamicUpdateFieldValue ( setter , index );
}
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
template < typename T >
void ClearDynamicUpdateFieldValues ( UF :: DynamicUpdateFieldSetter < T > setter )
2008-10-02 16:23:55 -05:00
{
2019-06-03 20:40:34 +02:00
AddToObjectUpdateIfNeeded ();
UF :: ClearDynamicUpdateFieldValues ( setter );
}
2019-10-25 19:29:52 +02:00
template < typename T >
void RemoveOptionalUpdateFieldValue ( UF :: OptionalUpdateFieldSetter < T > setter )
{
AddToObjectUpdateIfNeeded ();
UF :: RemoveOptionalUpdateFieldValue ( setter );
}
2019-06-03 20:40:34 +02:00
// stat system helpers
template < typename T >
2020-11-21 12:18:22 +01:00
void SetUpdateFieldStatValue ( UF :: UpdateFieldSetter < T > setter , typename UF :: UpdateFieldSetter < T >:: value_type value )
2019-06-03 20:40:34 +02:00
{
static_assert ( std :: is_arithmetic < T >:: value , "SetUpdateFieldStatValue must be used with arithmetic types" );
SetUpdateFieldValue ( setter , std :: max ( value , T ( 0 )));
}
template < typename T >
2020-11-21 12:18:22 +01:00
void ApplyModUpdateFieldValue ( UF :: UpdateFieldSetter < T > setter , typename UF :: UpdateFieldSetter < T >:: value_type mod , bool apply )
2019-06-03 20:40:34 +02:00
{
static_assert ( std :: is_arithmetic < T >:: value , "SetUpdateFieldStatValue must be used with arithmetic types" );
T value = setter . GetValue ();
if ( apply )
value += mod ;
else
value -= mod ;
SetUpdateFieldValue ( setter , value );
}
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
template < typename T >
void ApplyPercentModUpdateFieldValue ( UF :: UpdateFieldSetter < T > setter , float percent , bool apply )
{
static_assert ( std :: is_arithmetic < T >:: value , "SetUpdateFieldStatValue must be used with arithmetic types" );
T value = setter . GetValue ();
2014-10-26 22:06:48 +01:00
2019-06-03 20:40:34 +02:00
// don't want to include Util.h here
//ApplyPercentModFloatVar(value, percent, apply);
if ( percent == - 100.0f )
percent = - 99.99f ;
value *= ( apply ? ( 100.0f + percent ) / 100.0f : 100.0f / ( 100.0f + percent ));
2009-10-17 15:51:44 -07:00
2019-06-03 20:40:34 +02:00
SetUpdateFieldValue ( setter , value );
}
2021-03-04 20:47:54 +01:00
template < typename Action >
void DoWithSuppressingObjectUpdates ( Action && action )
{
bool wasUpdatedBeforeAction = m_objectUpdated ;
action ();
if ( m_objectUpdated && ! wasUpdatedBeforeAction )
{
RemoveFromObjectUpdate ();
m_objectUpdated = false ;
}
}
2019-06-03 20:40:34 +02:00
void BuildMovementUpdate ( ByteBuffer * data , CreateObjectBits flags ) const ;
virtual UF :: UpdateFieldFlag GetUpdateFieldFlagsFor ( Player const * target ) const ;
virtual void BuildValuesCreate ( ByteBuffer * data , Player const * target ) const = 0 ;
virtual void BuildValuesUpdate ( ByteBuffer * data , Player const * target ) const = 0 ;
2020-04-23 20:22:53 +02:00
public :
2019-06-03 20:40:34 +02:00
virtual void BuildValuesUpdateWithFlag ( ByteBuffer * data , UF :: UpdateFieldFlag flags , Player const * target ) const ;
2009-10-17 15:51:44 -07:00
2020-04-23 20:22:53 +02:00
protected :
2019-06-03 20:40:34 +02:00
uint16 m_objectType ;
TypeID m_objectTypeId ;
CreateObjectBits m_updateFlag ;
2012-07-22 14:20:26 +02:00
2015-02-25 00:13:14 +01:00
virtual void AddToObjectUpdate () = 0 ;
virtual void RemoveFromObjectUpdate () = 0 ;
void AddToObjectUpdateIfNeeded ();
2008-10-02 16:23:55 -05:00
bool m_objectUpdated ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
private :
2019-06-03 20:40:34 +02:00
ObjectGuid m_guid ;
2008-10-02 16:23:55 -05:00
bool m_inWorld ;
2017-12-15 22:11:02 -02:00
bool m_isNewObject ;
2009-10-17 15:51:44 -07:00
2014-04-29 16:35:11 +02:00
Object ( Object const & right ) = delete ;
Object & operator = ( Object const & right ) = delete ;
2008-10-02 16:23:55 -05:00
};
2009-10-17 15:51:44 -07:00
2009-12-26 11:38:30 +01:00
template < class T >
class GridObject
{
public :
2014-04-20 16:48:35 +02:00
virtual ~ GridObject () { }
2011-11-10 17:31:45 -05:00
bool IsInGrid () const { return _gridRef . isValid (); }
void AddToGrid ( GridRefManager < T >& m ) { ASSERT ( ! IsInGrid ()); _gridRef . link ( & m , ( T * ) this ); }
void RemoveFromGrid () { ASSERT ( IsInGrid ()); _gridRef . unlink (); }
private :
GridReference < T > _gridRef ;
2009-12-26 11:38:30 +01:00
};
2021-03-14 21:23:07 +02:00
template < class T_VALUES , class T_FLAGS , class FLAG_TYPE , size_t ARRAY_SIZE >
2010-11-13 17:18:09 +01:00
class FlaggedValuesArray32
{
public :
FlaggedValuesArray32 ()
{
2017-05-19 00:41:18 +02:00
for ( uint32 i = 0 ; i < ARRAY_SIZE ; ++ i )
m_values [ i ] = T_VALUES ( 0 );
2010-11-13 17:18:09 +01:00
m_flags = 0 ;
}
T_FLAGS GetFlags () const { return m_flags ; }
bool HasFlag ( FLAG_TYPE flag ) const { return m_flags & ( 1 << flag ); }
void AddFlag ( FLAG_TYPE flag ) { m_flags |= ( 1 << flag ); }
void DelFlag ( FLAG_TYPE flag ) { m_flags &= ~ ( 1 << flag ); }
T_VALUES GetValue ( FLAG_TYPE flag ) const { return m_values [ flag ]; }
void SetValue ( FLAG_TYPE flag , T_VALUES value ) { m_values [ flag ] = value ; }
void AddValue ( FLAG_TYPE flag , T_VALUES value ) { m_values [ flag ] += value ; }
private :
T_VALUES m_values [ ARRAY_SIZE ];
T_FLAGS m_flags ;
};
2016-03-11 16:37:14 +01:00
class TC_GAME_API WorldObject : public Object , public WorldLocation
2009-08-29 14:58:45 -05:00
{
2010-08-08 20:32:14 +02:00
protected :
2011-12-20 17:05:08 -05:00
explicit WorldObject ( bool isWorldObject ); //note: here it means if it is in grid object list or world object list
2009-08-29 14:58:45 -05:00
public :
virtual ~ WorldObject ();
2009-10-17 15:51:44 -07:00
2018-02-10 16:43:01 -03:00
virtual void Update ( uint32 /*time_diff*/ ) { }
2009-10-17 15:51:44 -07:00
2017-06-08 00:25:06 +02:00
void AddToWorld () override ;
void RemoveFromWorld () override ;
2010-11-16 21:17:49 +01:00
2010-04-07 22:59:46 +02:00
void GetNearPoint2D ( float & x , float & y , float distance , float absAngle ) const ;
2011-04-29 20:47:02 +02:00
void GetNearPoint ( WorldObject const * searcher , float & x , float & y , float & z , float searcher_size , float distance2d , float absAngle ) const ;
2013-03-04 11:45:57 +01:00
void GetClosePoint ( float & x , float & y , float & z , float size , float distance2d = 0 , float angle = 0 ) const ;
2009-08-29 23:20:16 -05:00
void MovePosition ( Position & pos , float dist , float angle );
2014-04-25 21:19:30 +02:00
Position GetNearPosition ( float dist , float angle );
2010-07-21 02:06:51 +02:00
void MovePositionToFirstCollision ( Position & pos , float dist , float angle );
2014-04-25 21:19:30 +02:00
Position GetFirstCollisionPosition ( float dist , float angle );
Position GetRandomNearPosition ( float radius );
2013-03-25 10:36:30 +01:00
void GetContactPoint ( WorldObject const * obj , float & x , float & y , float & z , float distance2d = CONTACT_DISTANCE ) const ;
2009-10-17 15:51:44 -07:00
2017-03-23 00:43:04 +01:00
virtual float GetCombatReach () const { return 0.0f ; } // overridden (only) in Unit
2008-10-02 16:23:55 -05:00
void UpdateGroundPositionZ ( float x , float y , float & z ) const ;
2012-01-14 15:34:41 +01:00
void UpdateAllowedPositionZ ( float x , float y , float & z ) const ;
2009-10-17 15:51:44 -07:00
2020-09-04 13:38:24 +02:00
void GetRandomPoint ( Position const & srcPos , float distance , float & rand_x , float & rand_y , float & rand_z ) const ;
Position GetRandomPoint ( Position const & srcPos , float distance ) const ;
2009-10-17 15:51:44 -07:00
2009-08-25 11:42:18 -05:00
uint32 GetInstanceId () const { return m_InstanceId ; }
2009-10-17 15:51:44 -07:00
2018-01-28 11:37:20 +01:00
bool IsInPhase ( WorldObject const * obj ) const
{
return GetPhaseShift (). CanSee ( obj -> GetPhaseShift ());
}
2018-01-03 20:04:19 +01:00
static bool InSamePhase ( WorldObject const * a , WorldObject const * b )
{
return a && b && a -> IsInPhase ( b );
}
2018-01-28 11:37:20 +01:00
PhaseShift & GetPhaseShift () { return _phaseShift ; }
PhaseShift const & GetPhaseShift () const { return _phaseShift ; }
PhaseShift & GetSuppressedPhaseShift () { return _suppressedPhaseShift ; }
PhaseShift const & GetSuppressedPhaseShift () const { return _suppressedPhaseShift ; }
2015-07-22 23:24:56 +01:00
int32 GetDBPhase () const { return _dbPhase ; }
2015-03-16 07:28:49 +01:00
// if negative it is used as PhaseGroupId
void SetDBPhase ( int32 p ) { _dbPhase = p ; }
2009-10-17 15:51:44 -07:00
2017-06-08 00:25:06 +02:00
uint32 GetZoneId () const { return m_zoneId ; }
uint32 GetAreaId () const { return m_areaId ; }
void GetZoneAndAreaId ( uint32 & zoneid , uint32 & areaid ) const { zoneid = m_zoneId , areaid = m_areaId ; }
2018-02-26 17:40:40 +01:00
bool IsOutdoors () const { return m_outdoors ; }
2017-02-13 20:42:06 +01:00
bool IsInWorldPvpZone () const ;
2009-10-17 15:51:44 -07:00
2017-09-15 03:53:02 +02:00
InstanceScript * GetInstanceScript () const ;
2009-10-17 15:51:44 -07:00
2012-10-24 13:29:34 +02:00
std :: string const & GetName () const { return m_name ; }
2020-04-18 10:59:35 +02:00
void SetName ( std :: string newname ) { m_name = std :: move ( newname ); }
2009-10-17 15:51:44 -07:00
2020-04-18 10:59:35 +02:00
std :: string GetNameForLocaleIdx ( LocaleConstant /*locale*/ ) const override { return m_name ; }
2009-10-17 15:51:44 -07:00
2013-03-25 10:36:30 +01:00
float GetDistance ( WorldObject const * obj ) const ;
2020-09-04 13:38:24 +02:00
float GetDistance ( Position const & pos ) const ;
2013-03-04 11:45:57 +01:00
float GetDistance ( float x , float y , float z ) const ;
2013-03-25 10:36:30 +01:00
float GetDistance2d ( WorldObject const * obj ) const ;
2013-03-04 11:45:57 +01:00
float GetDistance2d ( float x , float y ) const ;
2013-03-25 10:36:30 +01:00
float GetDistanceZ ( WorldObject const * obj ) const ;
2009-10-17 15:51:44 -07:00
2013-03-25 10:36:30 +01:00
bool IsSelfOrInSameMap ( WorldObject const * obj ) const ;
bool IsInMap ( WorldObject const * obj ) const ;
2013-03-04 11:45:57 +01:00
bool IsWithinDist3d ( float x , float y , float z , float dist ) const ;
2013-03-25 10:36:30 +01:00
bool IsWithinDist3d ( Position const * pos , float dist ) const ;
2013-03-04 11:45:57 +01:00
bool IsWithinDist2d ( float x , float y , float dist ) const ;
2013-03-25 10:36:30 +01:00
bool IsWithinDist2d ( Position const * pos , float dist ) const ;
2010-02-06 00:28:19 +01:00
// use only if you will sure about placing both object at same map
2013-03-04 11:45:57 +01:00
bool IsWithinDist ( WorldObject const * obj , float dist2compare , bool is3D = true ) const ;
2017-03-23 00:43:04 +01:00
bool IsWithinDistInMap ( WorldObject const * obj , float dist2compare , bool is3D = true , bool incOwnRadius = true , bool incTargetRadius = true ) const ;
2017-06-10 15:08:35 +02:00
bool IsWithinLOS ( float x , float y , float z , LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS , VMAP :: ModelIgnoreFlags ignoreFlags = VMAP :: ModelIgnoreFlags :: Nothing ) const ;
bool IsWithinLOSInMap ( WorldObject const * obj , LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS , VMAP :: ModelIgnoreFlags ignoreFlags = VMAP :: ModelIgnoreFlags :: Nothing ) const ;
2015-11-03 11:20:30 +01:00
Position GetHitSpherePointFor ( Position const & dest ) const ;
void GetHitSpherePointFor ( Position const & dest , float & x , float & y , float & z ) const ;
2009-05-14 16:50:47 -05:00
bool GetDistanceOrder ( WorldObject const * obj1 , WorldObject const * obj2 , bool is3D = true ) const ;
bool IsInRange ( WorldObject const * obj , float minRange , float maxRange , bool is3D = true ) const ;
bool IsInRange2d ( float x , float y , float minRange , float maxRange ) const ;
bool IsInRange3d ( float x , float y , float z , float minRange , float maxRange ) const ;
2014-08-21 16:56:11 +02:00
bool isInFront ( WorldObject const * target , float arc = float ( M_PI )) const ;
bool isInBack ( WorldObject const * target , float arc = float ( M_PI )) const ;
2009-10-17 15:51:44 -07:00
2016-09-10 14:14:34 +02:00
bool IsInBetween ( Position const & pos1 , Position const & pos2 , float size = 0 ) const ;
bool IsInBetween ( WorldObject const * obj1 , WorldObject const * obj2 , float size = 0 ) const { return obj1 && obj2 && IsInBetween ( obj1 -> GetPosition (), obj2 -> GetPosition (), size ); }
2009-10-17 15:51:44 -07:00
2010-01-22 20:03:47 +01:00
virtual void CleanupsBeforeDelete ( bool finalCleanup = true ); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
2009-10-17 15:51:44 -07:00
2017-07-26 00:53:25 +02:00
virtual void SendMessageToSet ( WorldPacket const * data , bool self ) const ;
virtual void SendMessageToSetInRange ( WorldPacket const * data , float dist , bool self ) const ;
virtual void SendMessageToSet ( WorldPacket const * data , Player const * skipped_rcvr ) const ;
2009-10-17 15:51:44 -07:00
2018-02-10 16:43:01 -03:00
void SendCombatLogMessage ( WorldPackets :: CombatLog :: CombatLogServerPacket * combatLog ) const ;
2017-07-29 21:40:28 +02:00
virtual uint8 GetLevelForTarget ( WorldObject const * /*target*/ ) const { return 1 ; }
2010-11-13 17:18:09 +01:00
2016-12-03 16:45:30 +01:00
void PlayDistanceSound ( uint32 soundId , Player * target = nullptr );
2020-12-27 22:43:36 +01:00
void PlayDirectSound ( uint32 soundId , Player * target = nullptr , uint32 broadcastTextId = 0 );
2016-10-05 22:34:04 +02:00
void PlayDirectMusic ( uint32 musicId , Player * target = nullptr );
2009-10-17 15:51:44 -07:00
2017-05-07 21:48:41 +01:00
virtual void SaveRespawnTime ( uint32 /*forceDelay*/ = 0 , bool /*saveToDB*/ = true ) { }
2008-10-02 16:23:55 -05:00
void AddObjectToRemoveList ();
2009-10-17 15:51:44 -07:00
2010-11-13 17:18:09 +01:00
float GetGridActivationRange () const ;
float GetVisibilityRange () const ;
2020-08-14 17:06:03 +02:00
float GetSightRange ( WorldObject const * target = nullptr ) const ;
2015-07-15 18:43:19 +02:00
bool CanSeeOrDetect ( WorldObject const * obj , bool ignoreStealth = false , bool distanceCheck = false , bool checkAlert = false ) const ;
2010-11-13 17:18:09 +01:00
FlaggedValuesArray32 < int32 , uint32 , StealthType , TOTAL_STEALTH_TYPES > m_stealth ;
FlaggedValuesArray32 < int32 , uint32 , StealthType , TOTAL_STEALTH_TYPES > m_stealthDetect ;
FlaggedValuesArray32 < int32 , uint32 , InvisibilityType , TOTAL_INVISIBILITY_TYPES > m_invisibility ;
FlaggedValuesArray32 < int32 , uint32 , InvisibilityType , TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect ;
2009-10-17 15:51:44 -07:00
2010-11-13 17:18:09 +01:00
FlaggedValuesArray32 < int32 , uint32 , ServerSideVisibilityType , TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility ;
FlaggedValuesArray32 < int32 , uint32 , ServerSideVisibilityType , TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
virtual void SetMap ( Map * map );
2009-08-10 23:47:47 -05:00
virtual void ResetMap ();
2011-09-15 14:08:17 +02:00
Map * GetMap () const { ASSERT ( m_currMap ); return m_currMap ; }
Map * FindMap () const { return m_currMap ; }
2009-07-16 11:49:00 +08:00
//used to check all object's GetMap() calls when object is not in world!
2009-10-17 15:51:44 -07:00
2009-05-30 22:15:05 -05:00
void SetZoneScript ();
2011-09-15 14:08:17 +02:00
ZoneScript * GetZoneScript () const { return m_zoneScript ; }
2009-10-17 15:51:44 -07:00
2016-11-06 23:30:49 +01:00
Scenario * GetScenario () const ;
2021-03-28 16:52:07 +02:00
TempSummon * SummonCreature ( uint32 entry , Position const & pos , TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN , uint32 despawnTime = 0 , uint32 vehId = 0 , ObjectGuid privateObjectOwner = ObjectGuid :: Empty );
TempSummon * SummonCreature ( uint32 entry , Position const & pos , TempSummonType despawnType , Milliseconds const & despawnTime , uint32 vehId = 0 , ObjectGuid privateObjectOwner = ObjectGuid :: Empty ) { return SummonCreature ( entry , pos , despawnType , uint32 ( despawnTime . count ()), vehId , privateObjectOwner ); }
TempSummon * SummonCreature ( uint32 entry , float x , float y , float z , float o = 0 , TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN , uint32 despawnTime = 0 , ObjectGuid privateObjectOwner = ObjectGuid :: Empty );
2018-02-16 02:19:19 +01:00
GameObject * SummonGameObject ( uint32 entry , Position const & pos , QuaternionData const & rot , uint32 respawnTime /* s */ , GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN );
2017-05-28 16:34:44 +02:00
GameObject * SummonGameObject ( uint32 entry , float x , float y , float z , float ang , QuaternionData const & rot , uint32 respawnTime /* s */ );
2020-08-14 17:06:03 +02:00
Creature * SummonTrigger ( float x , float y , float z , float ang , uint32 dur , CreatureAI * ( * GetAI )( Creature * ) = nullptr );
void SummonCreatureGroup ( uint8 group , std :: list < TempSummon *>* list = nullptr );
2009-10-17 15:51:44 -07:00
2011-08-30 13:46:36 +02:00
Creature * FindNearestCreature ( uint32 entry , float range , bool alive = true ) const ;
GameObject * FindNearestGameObject ( uint32 entry , float range ) const ;
2012-09-08 23:15:29 +01:00
GameObject * FindNearestGameObjectOfType ( GameobjectTypes type , float range ) const ;
2017-02-17 21:33:18 +01:00
Player * SelectNearestPlayer ( float distance ) const ;
2009-10-17 15:51:44 -07:00
2018-02-10 16:43:01 -03:00
virtual ObjectGuid GetOwnerGUID () const = 0 ;
virtual ObjectGuid GetCharmerOrOwnerGUID () const { return GetOwnerGUID (); }
ObjectGuid GetCharmerOrOwnerOrOwnGUID () const ;
Unit * GetOwner () const ;
Unit * GetCharmerOrOwner () const ;
Unit * GetCharmerOrOwnerOrSelf () const ;
Player * GetCharmerOrOwnerPlayerOrPlayerItself () const ;
Player * GetAffectingPlayer () const ;
Player * GetSpellModOwner () const ;
2021-09-04 15:13:15 +02:00
int32 CalculateSpellDamage ( Unit const * target , SpellEffectInfo const & spellEffectInfo , int32 const * basePoints = nullptr , float * variance = nullptr , uint32 castItemId = 0 , int32 itemLevel = - 1 ) const ;
2018-02-10 16:43:01 -03:00
// target dependent range checks
float GetSpellMaxRangeForTarget ( Unit const * target , SpellInfo const * spellInfo ) const ;
float GetSpellMinRangeForTarget ( Unit const * target , SpellInfo const * spellInfo ) const ;
float ApplyEffectModifiers ( SpellInfo const * spellInfo , uint8 effIndex , float value ) const ;
int32 CalcSpellDuration ( SpellInfo const * spellInfo ) const ;
int32 ModSpellDuration ( SpellInfo const * spellInfo , WorldObject const * target , int32 duration , bool positive , uint32 effectMask ) const ;
void ModSpellCastTime ( SpellInfo const * spellInfo , int32 & castTime , Spell * spell = nullptr ) const ;
void ModSpellDurationTime ( SpellInfo const * spellInfo , int32 & durationTime , Spell * spell = nullptr ) const ;
virtual float MeleeSpellMissChance ( Unit const * victim , WeaponAttackType attType , SpellInfo const * spellInfo ) const ;
virtual SpellMissInfo MeleeSpellHitResult ( Unit * victim , SpellInfo const * spellInfo ) const ;
SpellMissInfo MagicSpellHitResult ( Unit * victim , SpellInfo const * spellInfo ) const ;
SpellMissInfo SpellHitResult ( Unit * victim , SpellInfo const * spellInfo , bool canReflect = false ) const ;
2018-03-10 19:51:36 -03:00
void SendSpellMiss ( Unit * target , uint32 spellID , SpellMissInfo missInfo );
2018-02-10 16:43:01 -03:00
virtual uint32 GetFaction () const = 0 ;
virtual void SetFaction ( uint32 /*faction*/ ) { }
FactionTemplateEntry const * GetFactionTemplateEntry () const ;
ReputationRank GetReactionTo ( WorldObject const * target ) const ;
static ReputationRank GetFactionReactionTo ( FactionTemplateEntry const * factionTemplateEntry , WorldObject const * target );
bool IsHostileTo ( WorldObject const * target ) const ;
bool IsHostileToPlayers () const ;
bool IsFriendlyTo ( WorldObject const * target ) const ;
bool IsNeutralToAll () const ;
// CastSpell's third arg can be a variety of things - check out CastSpellExtraArgs' constructors!
void CastSpell ( SpellCastTargets const & targets , uint32 spellId , CastSpellExtraArgs const & args = { });
void CastSpell ( WorldObject * target , uint32 spellId , CastSpellExtraArgs const & args = { });
void CastSpell ( Position const & dest , uint32 spellId , CastSpellExtraArgs const & args = { });
2018-03-10 19:40:05 -03:00
bool IsValidAttackTarget ( WorldObject const * target , SpellInfo const * bySpell = nullptr ) const ;
bool IsValidAssistTarget ( WorldObject const * target , SpellInfo const * bySpell = nullptr ) const ;
2018-02-10 16:43:01 -03:00
Unit * GetMagicHitRedirectTarget ( Unit * victim , SpellInfo const * spellInfo );
virtual uint32 GetCastSpellXSpellVisualId ( SpellInfo const * spellInfo ) const ;
2016-10-13 01:23:02 -03:00
template < typename Container >
void GetGameObjectListWithEntryInGrid ( Container & gameObjectContainer , uint32 entry , float maxSearchRange = 250.0f ) const ;
template < typename Container >
void GetCreatureListWithEntryInGrid ( Container & creatureContainer , uint32 entry , float maxSearchRange = 250.0f ) const ;
template < typename Container >
void GetPlayerListInGrid ( Container & playerContainer , float maxSearchRange ) const ;
2009-10-17 15:51:44 -07:00
2009-08-28 14:19:14 -05:00
void DestroyForNearbyPlayers ();
2010-02-27 15:25:14 +02:00
virtual void UpdateObjectVisibility ( bool forced = true );
2018-02-26 17:40:40 +01:00
virtual void UpdateObjectVisibilityOnCreate () { UpdateObjectVisibility ( true ); }
2017-06-08 00:25:06 +02:00
void UpdatePositionData ();
2016-03-02 23:54:37 +01:00
2014-08-09 20:17:40 +01:00
void BuildUpdate ( UpdateDataMapType & ) override ;
2015-02-25 00:13:14 +01:00
void AddToObjectUpdate () override ;
void RemoveFromObjectUpdate () override ;
2009-10-17 15:51:44 -07:00
2010-02-27 15:25:14 +02:00
//relocation and visibility system functions
2009-12-19 10:12:40 +01:00
void AddToNotify ( uint16 f ) { m_notifyflags |= f ;}
2014-07-17 15:42:57 +02:00
bool isNeedNotify ( uint16 f ) const { return ( m_notifyflags & f ) != 0 ; }
2010-02-27 15:25:14 +02:00
uint16 GetNotifyFlags () const { return m_notifyflags ; }
2017-07-01 20:18:02 +02:00
void ResetAllNotifies () { m_notifyflags = 0 ; }
2009-12-19 10:12:40 +01:00
2009-02-25 20:52:20 -06:00
bool isActiveObject () const { return m_isActive ; }
void setActive ( bool isActiveObject );
2018-02-17 15:09:54 +01:00
bool IsFarVisible () const { return m_isFarVisible ; }
void SetFarVisible ( bool on );
2019-01-16 20:48:01 +01:00
bool IsVisibilityOverridden () const { return m_visibilityDistanceOverride . is_initialized (); }
void SetVisibilityDistanceOverride ( VisibilityDistanceType type );
2009-02-26 16:29:55 -06:00
void SetWorldObject ( bool apply );
2011-12-20 17:05:08 -05:00
bool IsPermanentWorldObject () const { return m_isWorldObject ; }
bool IsWorldObject () const ;
2010-05-16 17:45:45 +02:00
uint32 LastUsedScriptID ;
2010-07-30 21:54:46 -07:00
// Transports
2011-09-15 14:08:17 +02:00
Transport * GetTransport () const { return m_transport ; }
2013-10-16 18:37:29 +02:00
float GetTransOffsetX () const { return m_movementInfo . transport . pos . GetPositionX (); }
float GetTransOffsetY () const { return m_movementInfo . transport . pos . GetPositionY (); }
float GetTransOffsetZ () const { return m_movementInfo . transport . pos . GetPositionZ (); }
float GetTransOffsetO () const { return m_movementInfo . transport . pos . GetOrientation (); }
2017-05-15 22:55:16 +02:00
Position const & GetTransOffset () const { return m_movementInfo . transport . pos ; }
2013-10-16 18:37:29 +02:00
uint32 GetTransTime () const { return m_movementInfo . transport . time ; }
int8 GetTransSeat () const { return m_movementInfo . transport . seat ; }
2014-09-14 16:14:12 +02:00
virtual ObjectGuid GetTransGUID () const ;
2011-09-15 14:08:17 +02:00
void SetTransport ( Transport * t ) { m_transport = t ; }
2010-07-30 21:54:46 -07:00
MovementInfo m_movementInfo ;
2013-10-16 18:37:29 +02:00
virtual float GetStationaryX () const { return GetPositionX (); }
virtual float GetStationaryY () const { return GetPositionY (); }
virtual float GetStationaryZ () const { return GetPositionZ (); }
virtual float GetStationaryO () const { return GetOrientation (); }
2017-06-08 00:25:06 +02:00
float GetFloorZ () const ;
2017-12-14 16:56:30 +01:00
virtual float GetCollisionHeight () const { return 0.0f ; }
2017-12-29 22:32:07 +01:00
float GetMapWaterOrGroundLevel ( float x , float y , float z , float * ground = nullptr ) const ;
float GetMapHeight ( float x , float y , float z , bool vmap = true , float distanceToSearch = 50.0f ) const ; // DEFAULT_HEIGHT_SEARCH in map.h
2017-06-08 00:25:06 +02:00
2018-02-10 16:43:01 -03:00
// Event handler
EventProcessor m_Events ;
2015-09-16 17:06:24 +02:00
virtual uint16 GetAIAnimKitId () const { return 0 ; }
virtual uint16 GetMovementAnimKitId () const { return 0 ; }
virtual uint16 GetMeleeAnimKitId () const { return 0 ; }
2015-05-25 01:50:03 +02:00
2021-03-14 21:23:07 +02:00
// Watcher
bool IsPrivateObject () const { return ! _privateObjectOwner . IsEmpty (); }
ObjectGuid GetPrivateObjectOwner () const { return _privateObjectOwner ; }
void SetPrivateObjectOwner ( ObjectGuid const & owner ) { _privateObjectOwner = owner ; }
2021-03-28 16:38:04 +02:00
bool CheckPrivateObjectOwnerVisibility ( WorldObject const * seer ) const ;
2021-03-14 21:23:07 +02:00
2008-10-02 16:23:55 -05:00
protected :
std :: string m_name ;
2008-10-27 08:41:55 -05:00
bool m_isActive ;
2018-02-17 15:09:54 +01:00
bool m_isFarVisible ;
2019-01-16 20:48:01 +01:00
Optional < float > m_visibilityDistanceOverride ;
2018-02-10 16:43:01 -03:00
bool const m_isWorldObject ;
2011-09-15 14:08:17 +02:00
ZoneScript * m_zoneScript ;
2009-10-17 15:51:44 -07:00
2010-07-30 21:54:46 -07:00
// transports
2011-09-15 14:08:17 +02:00
Transport * m_transport ;
2010-07-30 21:54:46 -07:00
2017-06-08 00:25:06 +02:00
virtual void ProcessPositionDataChanged ( PositionFullTerrainStatus const & data );
uint32 m_zoneId ;
uint32 m_areaId ;
float m_staticFloorZ ;
2018-02-26 17:40:40 +01:00
bool m_outdoors ;
2017-06-08 00:25:06 +02:00
2009-08-25 11:42:18 -05:00
//these functions are used mostly for Relocate() and Corpse/Player specific stuff...
//use them ONLY in LoadFromDB()/Create() funcs and nowhere else!
//mapId/instanceId should be set in SetMap() function!
void SetLocationMapId ( uint32 _mapId ) { m_mapId = _mapId ; }
void SetLocationInstanceId ( uint32 _instanceId ) { m_InstanceId = _instanceId ; }
2009-10-17 15:51:44 -07:00
2017-05-05 13:31:25 +02:00
virtual bool IsNeverVisibleFor ( WorldObject const * /*seer*/ ) const { return ! IsInWorld (); }
2011-10-13 17:01:55 -04:00
virtual bool IsAlwaysVisibleFor ( WorldObject const * /*seer*/ ) const { return false ; }
virtual bool IsInvisibleDueToDespawn () const { return false ; }
//difference from IsAlwaysVisibleFor: 1. after distance check; 2. use owner or charmer as seer
virtual bool IsAlwaysDetectableFor ( WorldObject const * /*seer*/ ) const { return false ; }
2008-10-02 16:23:55 -05:00
private :
2017-06-08 00:25:06 +02:00
Map * m_currMap ; // current object's Map location
2009-10-17 15:51:44 -07:00
2017-06-08 00:25:06 +02:00
uint32 m_InstanceId ; // in map copy with instance id
2018-01-28 11:37:20 +01:00
PhaseShift _phaseShift ;
2017-06-08 00:25:06 +02:00
PhaseShift _suppressedPhaseShift ; // contains phases for current area but not applied due to conditions
2015-03-16 07:28:49 +01:00
int32 _dbPhase ;
2009-12-19 10:12:40 +01:00
uint16 m_notifyflags ;
2021-03-14 21:23:07 +02:00
ObjectGuid _privateObjectOwner ;
2017-03-23 00:43:04 +01:00
virtual bool _IsWithinDist ( WorldObject const * obj , float dist2compare , bool is3D , bool incOwnRadius = true , bool incTargetRadius = true ) const ;
2011-10-13 14:02:07 -04:00
2013-03-04 11:45:57 +01:00
bool CanNeverSee ( WorldObject const * obj ) const ;
2011-10-13 17:01:55 -04:00
virtual bool CanAlwaysSee ( WorldObject const * /*obj*/ ) const { return false ; }
2015-07-15 18:43:19 +02:00
bool CanDetect ( WorldObject const * obj , bool ignoreStealth , bool checkAlert = false ) const ;
2011-10-13 17:01:55 -04:00
bool CanDetectInvisibilityOf ( WorldObject const * obj ) const ;
2015-07-15 18:43:19 +02:00
bool CanDetectStealthOf ( WorldObject const * obj , bool checkAlert = false ) const ;
2008-10-02 16:23:55 -05:00
};
2010-05-30 04:23:27 +02:00
namespace Trinity
{
// Binary predicate to sort WorldObjects based on the distance to a reference WorldObject
class ObjectDistanceOrderPred
{
public :
2014-08-14 16:09:14 +02:00
ObjectDistanceOrderPred ( WorldObject const * refObj , bool ascending = true ) : _refObj ( refObj ), _ascending ( ascending ) { }
bool operator ()( WorldObject const * left , WorldObject const * right ) const
2010-05-30 04:23:27 +02:00
{
2014-08-14 16:09:14 +02:00
return _refObj -> GetDistanceOrder ( left , right ) == _ascending ;
2010-05-30 04:23:27 +02:00
}
2014-08-14 16:09:14 +02:00
2010-05-30 04:23:27 +02:00
private :
2014-08-14 16:09:14 +02:00
WorldObject const * _refObj ;
bool _ascending ;
2010-05-30 04:23:27 +02:00
};
}
2008-10-02 16:23:55 -05:00
#endif