Skip to content
Permalink
Browse files

Core/Objects: Visibility improvements

based on commit by kittnz @ tc
  • Loading branch information...
AbraKabastard committed May 24, 2019
1 parent 0b6a55b commit c32638932f7eedba7a68a657d5f1efd666003eae
@@ -0,0 +1,5 @@
ALTER TABLE `creature_addon`
ADD COLUMN `visibilityDistanceType` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `emote`;

ALTER TABLE `creature_template_addon`
ADD COLUMN `visibilityDistanceType` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `emote`;
@@ -2150,7 +2150,11 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (cainfo->emote != 0)
SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);

//Load Path
// Check if visibility distance different
if (cainfo->visibilityDistanceType != VISDIST_DEFAULT)
SetVisibilityDistanceOverride(cainfo->visibilityDistanceType);

// Load Path
if (cainfo->path_id != 0)
m_path_id = cainfo->path_id;

@@ -308,6 +308,7 @@ struct CreatureDataAddon
uint32 bytes1;
uint32 bytes2;
uint32 emote;
VisibilityDistanceType visibilityDistanceType;
CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
};

@@ -224,6 +224,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa

AIM_Initialize();

// Check if GameObject is Large
if (goinfo->IsLargeGameObject())
SetVisibilityDistanceOverride(VISDIST_LARGE);

return true;
}

@@ -504,6 +504,21 @@ struct GameObjectInfo
}
}

bool IsLargeGameObject() const
{
switch (type)
{
case GAMEOBJECT_TYPE_BUTTON: return button.large != 0;
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.large != 0;
case GAMEOBJECT_TYPE_GENERIC: return _generic.large != 0;
case GAMEOBJECT_TYPE_TRAP: return trap.large != 0;
case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.large != 0;
case GAMEOBJECT_TYPE_GOOBER: return goober.large != 0;
case GAMEOBJECT_TYPE_CAPTURE_POINT: return capturePoint.large != 0;
default: return false;
}
}

std::string GetAIName() const
{
return AIName;
@@ -1089,6 +1089,7 @@ WorldObject::WorldObject(bool isWorldObject):
, m_isWorldObject(isWorldObject)
, m_name("")
, m_isActive(false)
, m_visibilityDistanceOverride(0)
, m_zoneScript(NULL)
, m_currMap(NULL)
, m_InstanceId(0)
@@ -1151,6 +1152,30 @@ void WorldObject::setActive(bool on)
}
}

void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
{
if (GetTypeId() == TYPEID_PLAYER)
return;

switch (type)
{
case VISDIST_TINY:
m_visibilityDistanceOverride = VISIBILITY_DISTANCE_TINY;
break;
case VISDIST_SMALL:
m_visibilityDistanceOverride = VISIBILITY_DISTANCE_SMALL;
break;
case VISDIST_LARGE:
m_visibilityDistanceOverride = VISIBILITY_DISTANCE_LARGE;
break;
case VISDIST_GIGANTIC:
m_visibilityDistanceOverride = VISIBILITY_DISTANCE_GIGANTIC;
break;
default:
m_visibilityDistanceOverride = 0;
}
}

void WorldObject::CleanupsBeforeDelete()
{
if (IsInWorld())
@@ -1549,7 +1574,9 @@ float WorldObject::GetGridActivationRange() const

float WorldObject::GetVisibilityRange() const
{
if (isActiveObject() && !ToPlayer())
if (IsVisibilityOverridden() && !ToPlayer())
return m_visibilityDistanceOverride;
else if (isActiveObject() && !ToPlayer())
return MAX_VISIBILITY_DISTANCE;
else
return GetMap()->GetVisibilityRange();
@@ -1561,7 +1588,9 @@ float WorldObject::GetSightRange(const WorldObject* target) const
{
if (ToPlayer())
{
if (target && target->isActiveObject() && !target->ToPlayer())
if (target && target->IsVisibilityOverridden() && !target->ToPlayer())
return target->m_visibilityDistanceOverride;
else if (target && target->isActiveObject() && !target->ToPlayer())
return MAX_VISIBILITY_DISTANCE;
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
return DEFAULT_VISIBILITY_INSTANCE;
@@ -31,15 +31,20 @@
#include <set>
#include <string>

#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
#define INSPECT_DISTANCE 28.0f
#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible object show
#define SIGHT_RANGE_UNIT 50.0f
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 120 yards
#define DEFAULT_VISIBILITY_BGARENAS 533.0f // default visible distance in BG/Arenas, 180 yards
#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
#define INSPECT_DISTANCE 28.0f
#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible object show
#define SIGHT_RANGE_UNIT 50.0f
#define VISIBILITY_DISTANCE_GIGANTIC 400.0f
#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 VISIBILITY_DISTANCE_NORMAL // default visible distance, 100 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 170 yards
#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_COMBAT_REACH 1.5f
@@ -111,6 +116,16 @@ enum PhaseMasks
PHASEMASK_ANYWHERE = 0xFFFFFFFF
};

enum VisibilityDistanceType
{
VISDIST_DEFAULT = 0,
VISDIST_TINY,
VISDIST_SMALL,
VISDIST_LARGE,
VISDIST_GIGANTIC,
VISDIST_MAX
};

class WorldPacket;
class UpdateData;
class ByteBuffer;
@@ -913,6 +928,8 @@ class WorldObject : public Object, public WorldLocation
return m_isActive;
}
void setActive(bool isActiveObject);
bool IsVisibilityOverridden() const { return m_visibilityDistanceOverride != 0; }
void SetVisibilityDistanceOverride(VisibilityDistanceType type);
void SetWorldObject(bool apply);
bool IsPermanentWorldObject() const { return m_isWorldObject; }
bool IsWorldObject() const;
@@ -932,6 +949,7 @@ class WorldObject : public Object, public WorldLocation
bool m_isActive;
const bool m_isWorldObject;
ZoneScript* m_zoneScript;
float m_visibilityDistanceOverride;

//these functions are used mostly for Relocate() and Corpse/Player specific stuff...
//use them ONLY in LoadFromDB()/Create() funcs and nowhere else!
@@ -885,7 +885,12 @@ void ObjectMgr::LoadCreatureAddons()
continue;

if (!sEmotesStore.LookupEntry(addon->emote))
sLog.outErrorDb("Creature (GUID: %u) has invalid emote (%u) defined in creature_template_addon.", addon->guidOrEntry, addon->emote);
sLog.outErrorDb("Creature (Entry: %u) has invalid emote (%u) defined in creature_template_addon.",
addon->guidOrEntry, addon->emote);

if (addon->visibilityDistanceType >= VisibilityDistanceType::VISDIST_MAX)
sLog.outErrorDb("Creature (Entry: %u) has invalid visibilityDistanceType (%u) defined in `creature_template_addon`.",
addon->guidOrEntry, addon->visibilityDistanceType);

ConvertCreatureAddonAuras(const_cast<CreatureDataAddon*>(addon), "creature_template_addon", "Entry");

@@ -907,6 +912,12 @@ void ObjectMgr::LoadCreatureAddons()
if (!sEmotesStore.LookupEntry(addon->emote))
sLog.outErrorDb("Creature (GUID: %u) has invalid emote (%u) defined in creature_addon.", addon->guidOrEntry, addon->emote);

if (addon->visibilityDistanceType >= VisibilityDistanceType::VISDIST_MAX)
{
sLog.outErrorDb("Creature (GUID: %u) has invalid visibilityDistanceType (%u) defined in `creature_addon`.",
addon->guidOrEntry, addon->visibilityDistanceType);
}

ConvertCreatureAddonAuras(const_cast<CreatureDataAddon*>(addon), "creature_addon", "GUIDLow");

if (mCreatureDataMap.find(addon->guidOrEntry) == mCreatureDataMap.end())
@@ -825,7 +825,7 @@ ExternalMailInterval = 1
SkillChance.Prospecting = 0
Event.Announce = 0
BeepAtStart = 1
Motd = "Welcome to an Oregon Core server."
Motd = "Welcome to an OregonCore server."
Server.LoginInfo = 0
Command.LookupMaxResults = 0
HealthInPercents = 1
@@ -1181,15 +1181,15 @@ GM.TicketSystem.ChanceOfGMSurvey = 0
# Visibility.Distance.Instances
# Visibility.Distance.BGArenas
# Visibility distance for different ingame object in different maps.
# Visibility on continents on retail ~90 yards. In BG/Arenas ~533.
# Visibility on continents on retail ~100 yards. In BG/Arenas ~533.
# For instances default ~170.
# Max limited by active player zone: ~ 533
# Min limit is max aggro radius (45) * Rate.Creature.Aggro
#
###############################################################################

Visibility.GroupMode = 1
Visibility.Distance.Continents = 90
Visibility.Distance.Continents = 100
Visibility.Distance.Instances = 170
Visibility.Distance.BGArenas = 533

@@ -22,9 +22,9 @@ extern Database WorldDatabase;

const char CreatureInfosrcfmt[] = "iiiiiiiisssiiiiiiiiiiifffiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiisiifffflliiis";
const char CreatureInfodstfmt[] = "iiiiiiiisssiiiiiiiiiiifffiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiisiifffflliiii";
const char CreatureDataAddonInfofmt[] = "iiiiiis";
const char CreatureDataAddonInfofmt[] = "iiiiiiis";
const char CreatureModelfmt[] = "iffffbi";
const char CreatureInfoAddonInfofmt[] = "iiiiiis";
const char CreatureInfoAddonInfofmt[] = "iiiiiiis";
const char EquipmentInfofmt[] = "iiii";
const char EquipmentInfoRawfmt[] = "iiiiiiiiii";
const char GameObjectInfosrcfmt[] = "iiissiifiiiiiiiiiiiiiiiiiiiiiiiiss";

0 comments on commit c326389

Please sign in to comment.
You can’t perform that action at this time.