fix(Core/Objects): increase sight range of objects & correct general defau… (#9180)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2503,10 +2503,20 @@ bool Creature::LoadCreaturesAddon(bool reload)
|
|||||||
|
|
||||||
// Check if Creature is Large
|
// Check if Creature is Large
|
||||||
if (cainfo->isLarge)
|
if (cainfo->isLarge)
|
||||||
SetVisibilityDistanceOverride(true);
|
{
|
||||||
|
SetVisibilityDistanceOverride(cainfo->visibilityDistanceType);
|
||||||
|
}
|
||||||
|
|
||||||
if (cainfo->emote != 0)
|
if (cainfo->emote != 0)
|
||||||
|
{
|
||||||
SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);
|
SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if visibility distance different
|
||||||
|
if (cainfo->visibilityDistanceType != VisibilityDistanceType::Normal)
|
||||||
|
{
|
||||||
|
SetVisibilityDistanceOverride(cainfo->visibilityDistanceType);
|
||||||
|
}
|
||||||
|
|
||||||
//Load Path
|
//Load Path
|
||||||
if (cainfo->path_id != 0)
|
if (cainfo->path_id != 0)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#define MAX_CREATURE_QUEST_ITEMS 6
|
#define MAX_CREATURE_QUEST_ITEMS 6
|
||||||
|
|
||||||
#define MAX_EQUIPMENT_ITEMS 3
|
#define MAX_EQUIPMENT_ITEMS 3
|
||||||
|
enum class VisibilityDistanceType : uint8;
|
||||||
// TODO: Implement missing flags from TC in places that custom flags from xinef&pussywizzard use flag values.
|
// TODO: Implement missing flags from TC in places that custom flags from xinef&pussywizzard use flag values.
|
||||||
// EnumUtils: DESCRIBE THIS
|
// EnumUtils: DESCRIBE THIS
|
||||||
enum CreatureFlagsExtra : uint32
|
enum CreatureFlagsExtra : uint32
|
||||||
@@ -342,6 +342,7 @@ struct CreatureAddon
|
|||||||
uint32 emote;
|
uint32 emote;
|
||||||
bool isLarge;
|
bool isLarge;
|
||||||
std::vector<uint32> auras;
|
std::vector<uint32> auras;
|
||||||
|
VisibilityDistanceType visibilityDistanceType;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonContainer;
|
typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonContainer;
|
||||||
|
|||||||
@@ -400,7 +400,9 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
|
|||||||
|
|
||||||
// Check if GameObject is Large
|
// Check if GameObject is Large
|
||||||
if (goinfo->IsLargeGameObject())
|
if (goinfo->IsLargeGameObject())
|
||||||
SetVisibilityDistanceOverride(true);
|
{
|
||||||
|
SetVisibilityDistanceOverride(VisibilityDistanceType::Large);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,16 @@
|
|||||||
#include "LuaEngine.h"
|
#include "LuaEngine.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max)] =
|
||||||
|
{
|
||||||
|
DEFAULT_VISIBILITY_DISTANCE,
|
||||||
|
VISIBILITY_DISTANCE_TINY,
|
||||||
|
VISIBILITY_DISTANCE_SMALL,
|
||||||
|
VISIBILITY_DISTANCE_LARGE,
|
||||||
|
VISIBILITY_DISTANCE_GIGANTIC,
|
||||||
|
MAX_VISIBILITY_DISTANCE
|
||||||
|
};
|
||||||
|
|
||||||
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
||||||
{
|
{
|
||||||
m_objectTypeId = TYPEID_OBJECT;
|
m_objectTypeId = TYPEID_OBJECT;
|
||||||
@@ -1099,7 +1109,7 @@ WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
|
|||||||
#ifdef ELUNA
|
#ifdef ELUNA
|
||||||
elunaEvents(nullptr),
|
elunaEvents(nullptr),
|
||||||
#endif
|
#endif
|
||||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isVisibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
LastUsedScriptID(0), m_name(""), m_isActive(false), m_visibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
|
||||||
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
|
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
|
||||||
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
|
||||||
{
|
{
|
||||||
@@ -1170,12 +1180,15 @@ void WorldObject::setActive(bool on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldObject::SetVisibilityDistanceOverride(bool isVisibilityDistanceOverride)
|
void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
|
||||||
{
|
{
|
||||||
|
ASSERT(type < VisibilityDistanceType::Max);
|
||||||
if (GetTypeId() == TYPEID_PLAYER)
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_isVisibilityDistanceOverride = isVisibilityDistanceOverride;
|
m_visibilityDistanceOverride = VisibilityDistances[AsUnderlyingType(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||||
@@ -1814,15 +1827,25 @@ float WorldObject::GetGridActivationRange() const
|
|||||||
float WorldObject::GetVisibilityRange() const
|
float WorldObject::GetVisibilityRange() const
|
||||||
{
|
{
|
||||||
if (IsVisibilityOverridden() && GetTypeId() == TYPEID_UNIT)
|
if (IsVisibilityOverridden() && GetTypeId() == TYPEID_UNIT)
|
||||||
|
{
|
||||||
return MAX_VISIBILITY_DISTANCE;
|
return MAX_VISIBILITY_DISTANCE;
|
||||||
|
}
|
||||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||||
{
|
{
|
||||||
if (IsInWintergrasp())
|
{
|
||||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
if (IsInWintergrasp())
|
||||||
else if (IsVisibilityOverridden())
|
{
|
||||||
return MAX_VISIBILITY_DISTANCE;
|
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||||
else
|
}
|
||||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
else if (IsVisibilityOverridden())
|
||||||
|
{
|
||||||
|
return MAX_VISIBILITY_DISTANCE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "ObjectDefines.h"
|
#include "ObjectDefines.h"
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
|
#include "Optional.h"
|
||||||
#include "UpdateData.h"
|
#include "UpdateData.h"
|
||||||
#include "UpdateMask.h"
|
#include "UpdateMask.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -842,8 +843,9 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] bool isActiveObject() const { return m_isActive; }
|
[[nodiscard]] bool isActiveObject() const { return m_isActive; }
|
||||||
void setActive(bool isActiveObject);
|
void setActive(bool isActiveObject);
|
||||||
[[nodiscard]] bool IsVisibilityOverridden() const { return m_isVisibilityDistanceOverride; }
|
[[nodiscard]] bool IsFarVisible() const { return m_isFarVisible; }
|
||||||
void SetVisibilityDistanceOverride(bool isVisibilityDistanceOverride);
|
[[nodiscard]] bool IsVisibilityOverridden() const { return m_visibilityDistanceOverride.has_value(); }
|
||||||
|
void SetVisibilityDistanceOverride(VisibilityDistanceType type);
|
||||||
void SetWorldObject(bool apply);
|
void SetWorldObject(bool apply);
|
||||||
[[nodiscard]] bool IsPermanentWorldObject() const { return m_isWorldObject; }
|
[[nodiscard]] bool IsPermanentWorldObject() const { return m_isWorldObject; }
|
||||||
[[nodiscard]] bool IsWorldObject() const;
|
[[nodiscard]] bool IsWorldObject() const;
|
||||||
@@ -900,7 +902,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
bool m_isActive;
|
bool m_isActive;
|
||||||
bool m_isVisibilityDistanceOverride;
|
bool m_isFarVisible;
|
||||||
|
Optional<float> m_visibilityDistanceOverride;
|
||||||
const bool m_isWorldObject;
|
const bool m_isWorldObject;
|
||||||
ZoneScript* m_zoneScript;
|
ZoneScript* m_zoneScript;
|
||||||
|
|
||||||
|
|||||||
@@ -20,19 +20,26 @@
|
|||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
|
|
||||||
#define CONTACT_DISTANCE 0.5f
|
#define CONTACT_DISTANCE 0.5f
|
||||||
#define INTERACTION_DISTANCE 5.5f
|
#define INTERACTION_DISTANCE 5.5f
|
||||||
#define ATTACK_DISTANCE 5.0f
|
#define ATTACK_DISTANCE 5.0f
|
||||||
#define MAX_SEARCHER_DISTANCE 150.0f // pussywizard: replace the use of MAX_VISIBILITY_DISTANCE in searchers, because MAX_VISIBILITY_DISTANCE is quite too big for this purpose
|
#define VISIBILITY_COMPENSATION 15.0f // increase searchers
|
||||||
#define MAX_VISIBILITY_DISTANCE 250.0f // max distance for visible objects, experimental
|
#define INSPECT_DISTANCE 28.0f
|
||||||
#define VISIBILITY_INC_FOR_GOBJECTS 30.0f // pussywizard
|
#define VISIBILITY_INC_FOR_GOBJECTS 30.0f // pussywizard
|
||||||
#define VISIBILITY_COMPENSATION 15.0f // increase searchers
|
#define SPELL_SEARCHER_COMPENSATION 30.0f // increase searchers size in case we have large npc near cell border
|
||||||
#define SPELL_SEARCHER_COMPENSATION 30.0f // increase searchers size in case we have large npc near cell border
|
#define TRADE_DISTANCE 11.11f
|
||||||
#define VISIBILITY_DIST_WINTERGRASP 175.0f
|
#define MAX_VISIBILITY_DISTANCE 250.0f // max distance for visible objects, experimental
|
||||||
#define SIGHT_RANGE_UNIT 50.0f
|
#define SIGHT_RANGE_UNIT 50.0f
|
||||||
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents
|
#define MAX_SEARCHER_DISTANCE 150.0f // pussywizard: replace the use of MAX_VISIBILITY_DISTANCE in searchers, because MAX_VISIBILITY_DISTANCE is quite too big for this purpose
|
||||||
#define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards
|
#define VISIBILITY_DISTANCE_GIGANTIC 400.0f
|
||||||
#define DEFAULT_VISIBILITY_BGARENAS 150.0f // default visible distance in BG/Arenas, 150 yards
|
#define VISIBILITY_DISTANCE_LARGE 200.0f
|
||||||
|
#define VISIBILITY_DISTANCE_NORMAL 100.0f
|
||||||
|
#define VISIBILITY_DISTANCE_SMALL 50.0f
|
||||||
|
#define VISIBILITY_DISTANCE_TINY 25.0f
|
||||||
|
#define DEFAULT_VISIBILITY_DISTANCE 100.0f // default visible distance, 100 yards on continents
|
||||||
|
#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 170 yards
|
||||||
|
#define VISIBILITY_DIST_WINTERGRASP 175.0f
|
||||||
|
#define DEFAULT_VISIBILITY_BGARENAS 533.0f // default visible distance in BG/Arenas, roughly 533 yards
|
||||||
|
|
||||||
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects
|
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects
|
||||||
#define DEFAULT_COMBAT_REACH 1.5f
|
#define DEFAULT_COMBAT_REACH 1.5f
|
||||||
@@ -49,6 +56,18 @@ inline uint32 MAKE_PAIR32(uint16 l, uint16 h);
|
|||||||
inline uint16 PAIR32_HIPART(uint32 x);
|
inline uint16 PAIR32_HIPART(uint32 x);
|
||||||
inline uint16 PAIR32_LOPART(uint32 x);
|
inline uint16 PAIR32_LOPART(uint32 x);
|
||||||
|
|
||||||
|
enum class VisibilityDistanceType : uint8
|
||||||
|
{
|
||||||
|
Normal = 0,
|
||||||
|
Tiny = 1,
|
||||||
|
Small = 2,
|
||||||
|
Large = 3,
|
||||||
|
Gigantic = 4,
|
||||||
|
Infinite = 5,
|
||||||
|
|
||||||
|
Max
|
||||||
|
};
|
||||||
|
|
||||||
uint32 PAIR64_HIPART(uint64 x)
|
uint32 PAIR64_HIPART(uint64 x)
|
||||||
{
|
{
|
||||||
return (uint32)((x >> 32) & UI64LIT(0x00000000FFFFFFFF));
|
return (uint32)((x >> 32) & UI64LIT(0x00000000FFFFFFFF));
|
||||||
|
|||||||
@@ -717,8 +717,8 @@ void ObjectMgr::LoadCreatureTemplateAddons()
|
|||||||
{
|
{
|
||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7
|
// 0 1 2 3 4 5 6 7
|
||||||
QueryResult result = WorldDatabase.Query("SELECT entry, path_id, mount, bytes1, bytes2, emote, isLarge, auras FROM creature_template_addon");
|
QueryResult result = WorldDatabase.Query("SELECT entry, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_template_addon");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -747,7 +747,7 @@ void ObjectMgr::LoadCreatureTemplateAddons()
|
|||||||
creatureAddon.bytes1 = fields[3].GetUInt32();
|
creatureAddon.bytes1 = fields[3].GetUInt32();
|
||||||
creatureAddon.bytes2 = fields[4].GetUInt32();
|
creatureAddon.bytes2 = fields[4].GetUInt32();
|
||||||
creatureAddon.emote = fields[5].GetUInt32();
|
creatureAddon.emote = fields[5].GetUInt32();
|
||||||
creatureAddon.isLarge = fields[6].GetBool();
|
creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].GetUInt8());
|
||||||
|
|
||||||
Tokenizer tokens(fields[7].GetString(), ' ');
|
Tokenizer tokens(fields[7].GetString(), ' ');
|
||||||
uint8 i = 0;
|
uint8 i = 0;
|
||||||
@@ -778,6 +778,11 @@ void ObjectMgr::LoadCreatureTemplateAddons()
|
|||||||
creatureAddon.emote = 0;
|
creatureAddon.emote = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (creatureAddon.visibilityDistanceType >= VisibilityDistanceType::Max)
|
||||||
|
{
|
||||||
|
LOG_ERROR("sql.sql", "Creature (Entry: %u) has invalid visibilityDistanceType (%u) defined in `creature_template_addon`.", entry, AsUnderlyingType(creatureAddon.visibilityDistanceType));
|
||||||
|
creatureAddon.visibilityDistanceType = VisibilityDistanceType::Normal;
|
||||||
|
}
|
||||||
++count;
|
++count;
|
||||||
} while (result->NextRow());
|
} while (result->NextRow());
|
||||||
|
|
||||||
@@ -1135,8 +1140,8 @@ void ObjectMgr::LoadCreatureAddons()
|
|||||||
{
|
{
|
||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7
|
// 0 1 2 3 4 5 6 7
|
||||||
QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, isLarge, auras FROM creature_addon");
|
QueryResult result = WorldDatabase.Query("SELECT guid, path_id, mount, bytes1, bytes2, emote, visibilityDistanceType, auras FROM creature_addon");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -1172,7 +1177,7 @@ void ObjectMgr::LoadCreatureAddons()
|
|||||||
creatureAddon.bytes1 = fields[3].GetUInt32();
|
creatureAddon.bytes1 = fields[3].GetUInt32();
|
||||||
creatureAddon.bytes2 = fields[4].GetUInt32();
|
creatureAddon.bytes2 = fields[4].GetUInt32();
|
||||||
creatureAddon.emote = fields[5].GetUInt32();
|
creatureAddon.emote = fields[5].GetUInt32();
|
||||||
creatureAddon.isLarge = fields[6].GetBool();
|
creatureAddon.visibilityDistanceType = VisibilityDistanceType(fields[6].GetUInt8());
|
||||||
|
|
||||||
Tokenizer tokens(fields[7].GetString(), ' ');
|
Tokenizer tokens(fields[7].GetString(), ' ');
|
||||||
uint8 i = 0;
|
uint8 i = 0;
|
||||||
@@ -1203,6 +1208,12 @@ void ObjectMgr::LoadCreatureAddons()
|
|||||||
creatureAddon.emote = 0;
|
creatureAddon.emote = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (creatureAddon.visibilityDistanceType >= VisibilityDistanceType::Max)
|
||||||
|
{
|
||||||
|
LOG_ERROR("sql.sql", "Creature (GUID: %u) has invalid visibilityDistanceType (%u) defined in `creature_addon`.", guid, AsUnderlyingType(creatureAddon.visibilityDistanceType));
|
||||||
|
creatureAddon.visibilityDistanceType = VisibilityDistanceType::Normal;
|
||||||
|
}
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
} while (result->NextRow());
|
} while (result->NextRow());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user