diff options
Diffstat (limited to 'src/game/Object.h')
-rw-r--r-- | src/game/Object.h | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/src/game/Object.h b/src/game/Object.h index ef8a04c5c09..a4b7506ca30 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -50,13 +50,14 @@ enum TypeMask TYPEMASK_OBJECT = 0x0001, TYPEMASK_ITEM = 0x0002, TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004 - TYPEMASK_UNIT = 0x0008, + TYPEMASK_UNIT = 0x0008, //creature or player TYPEMASK_PLAYER = 0x0010, TYPEMASK_GAMEOBJECT = 0x0020, TYPEMASK_DYNAMICOBJECT = 0x0040, TYPEMASK_CORPSE = 0x0080, TYPEMASK_AIGROUP = 0x0100, - TYPEMASK_AREATRIGGER = 0x0200 + TYPEMASK_AREATRIGGER = 0x0200, + TYPEMASK_SEER = TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT }; enum TypeID @@ -72,6 +73,7 @@ enum TypeID TYPEID_AIGROUP = 8, TYPEID_AREATRIGGER = 9 }; +#define MAX_TYPEID 10 uint32 GuidHigh2TypeId(uint32 guid_hi); @@ -87,6 +89,12 @@ enum TempSummonType TEMPSUMMON_MANUAL_DESPAWN = 8 // despawns when UnSummon() is called }; +enum PhaseMasks +{ + PHASEMASK_NORMAL = 0x00000001, + PHASEMASK_ANYWHERE = 0xFFFFFFFF +}; + class WorldPacket; class UpdateData; class ByteBuffer; @@ -96,6 +104,8 @@ class Player; class UpdateMask; class InstanceData; class GameObject; +class TempSummon; +class Vehicle; typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType; @@ -123,6 +133,8 @@ class TRINITY_DLL_SPEC Object if(m_inWorld) return; + assert(m_uint32Values); + m_inWorld = true; // synchronize values mirror with values array (changes will send in updatecreate opcode any way @@ -133,10 +145,10 @@ class TRINITY_DLL_SPEC Object if(!m_inWorld) return; - // if we remove from world then sending changes not required - if(m_uint32Values) - ClearUpdateMask(true); m_inWorld = false; + + // if we remove from world then sending changes not required + ClearUpdateMask(true); } const uint64& GetGUID() const { return GetUInt64Value(0); } @@ -208,6 +220,9 @@ class TRINITY_DLL_SPEC Object void SetStatFloatValue( uint16 index, float value); void SetStatInt32Value( uint16 index, int32 value); + bool AddUInt64Value( uint16 index, const uint64 &value ); + bool RemoveUInt64Value( uint16 index, const uint64 &value ); + void ApplyModUInt32Value(uint16 index, int32 val, bool apply); void ApplyModInt32Value(uint16 index, int32 val, bool apply); void ApplyModUInt64Value(uint16 index, int32 val, bool apply); @@ -300,8 +315,6 @@ class TRINITY_DLL_SPEC Object uint16 GetValuesCount() const { return m_valuesCount; } - void InitValues() { _InitValues(); } - virtual bool hasQuest(uint32 /* quest_id */) const { return false; } virtual bool hasInvolvedQuest(uint32 /* quest_id */) const { return false; } @@ -357,7 +370,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object virtual void Update ( uint32 /*time_diff*/ ) { } - void _Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid ); + void _Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint32 phaseMask); void Relocate(float x, float y, float z, float orientation) { @@ -419,11 +432,16 @@ class TRINITY_DLL_SPEC WorldObject : public Object void GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z ) const; void SetMapId(uint32 newMap) { m_mapId = newMap; } - uint32 GetMapId() const { return m_mapId; } + virtual void SetPhaseMask(uint32 newPhaseMask, bool update); + uint32 GetPhaseMask() const { return m_phaseMask; } + bool InSamePhase(WorldObject const* obj) const { return InSamePhase(obj->GetPhaseMask()); } + bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); } + uint32 GetZoneId() const; uint32 GetAreaId() const; + void GetZoneAndAreaId(uint32& zoneid, uint32& areaid) const; InstanceData* GetInstanceData(); @@ -438,13 +456,18 @@ class TRINITY_DLL_SPEC WorldObject : public Object float GetDistance2d(const WorldObject* obj) const; float GetDistance2d(const float x, const float y) const; float GetDistanceZ(const WorldObject* obj) const; - bool IsInMap(const WorldObject* obj) const { return GetMapId()==obj->GetMapId() && GetInstanceId()==obj->GetInstanceId(); } + bool IsInMap(const WorldObject* obj) const + { + return IsInWorld() && obj->IsInWorld() && GetMapId()==obj->GetMapId() && + GetInstanceId()==obj->GetInstanceId() && InSamePhase(obj); + } bool IsWithinDistInMap(const WorldObject* obj, const float dist2compare, const bool is3D = true) const; bool IsWithinLOS(const float x, const float y, const float z ) const; bool IsWithinLOSInMap(const WorldObject* obj) const; float GetAngle( const WorldObject* obj ) const; float GetAngle( const float x, const float y ) const; + void GetSinCos(const float x, const float y, float &vsin, float &vcos); bool HasInArc( const float arcangle, const WorldObject* obj ) const; virtual void SendMessageToSet(WorldPacket *data, bool self, bool to_possessor = true); @@ -462,8 +485,12 @@ class TRINITY_DLL_SPEC WorldObject : public Object void MonsterYell(int32 textId, uint32 language, uint64 TargetGuid); void MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false); void MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper = false); + void MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid); void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 TargetGuid) const; + void PlayDistanceSound(uint32 sound_id, Player* target = NULL); + void PlayDirectSound(uint32 sound_id, Player* target = NULL); + void SendObjectDeSpawnAnim(uint64 guid); virtual void SaveRespawnTime() {} @@ -485,9 +512,10 @@ class TRINITY_DLL_SPEC WorldObject : public Object Map * GetMap() const; Map * FindMap() const; Map const* GetBaseMap() const; - Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); + TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); + Vehicle* SummonVehicle(uint32 entry, float x, float y, float z, float ang); GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); - Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); + Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); bool isActiveObject() const { return m_isActive; } void setActive(bool isActiveObject); void SetWorldObject(bool apply); @@ -502,7 +530,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object bool m_isActive; private: - uint32 m_mapId; + uint32 m_mapId; // object at map with map_id + uint32 m_InstanceId; // in map copy with instance id + uint32 m_phaseMask; // in area phase state float m_positionX; float m_positionY; @@ -510,8 +540,6 @@ class TRINITY_DLL_SPEC WorldObject : public Object float m_orientation; bool mSemaphoreTeleport; - - uint32 m_InstanceId; }; #endif |