Skip to content

Core/Misc: implement a way to specify a range (in yards) at which a creature or gameobject becomes visible to players.#18067

Closed
SnapperRy wants to merge 4 commits into
TrinityCore:3.3.5from
SnapperRy:visibility_range
Closed

Core/Misc: implement a way to specify a range (in yards) at which a creature or gameobject becomes visible to players.#18067
SnapperRy wants to merge 4 commits into
TrinityCore:3.3.5from
SnapperRy:visibility_range

Conversation

@SnapperRy

@SnapperRy SnapperRy commented Oct 10, 2016

Copy link
Copy Markdown
Contributor

Changes proposed:

  • Allow a way to specify (in creature_template_addon and gameobject_template_addon) a range at which a creature or gameobject becomes visible to players.

This can be used to make creatures like Fel Reaver and Putridus the Ancient, as well as gameobjects like the Wintergrasp walls and towers, visible from a very far distance (up to maximum grid size).

Also remove unneeded CONFIG_SIGHT_MONSTER, since it was just used as an alternative to already used variables.

Target branch(es): 3.3.5

Tests performed: tested and working.

Known issues and TODO list:

  • The grid the creature is on must be loaded in order for it to execute waypoint movements and other such things. This is forced here for the sake of testing, but needs a better solution, probably.

Basic way to test:

UPDATE `creature_template_addon` SET `visibilityRange`=500 WHERE `entry`=18733; -- Fel Reaver

if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
return DEFAULT_VISIBILITY_INSTANCE;
return GetMap()->GetVisibilityRange();
return GetMap()->GetVisibilityRange() * 5;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hacky, needs a better solution.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation aside, are there any big reasons against having players activate nearby grids rather than only the one they're currently in?

Would solve this issue as well as make waypoint movement more realistic (right now every npc only starts movement when someone can see them).

Could be a configurable option, since it would more than double the amount of grids loaded. Opinions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple multiply which makes more performance loss than a DDOS :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Palabola yeah, that's just here to show that "it works". Not meant to stay there when (if) this is merged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any update on this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet. Haven't been able to find a good way to update a specific creature without having to keep the whole grid loaded.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SnapperRy Any thoughts on what I mentioned to you on IRC about it?

Comment thread src/server/game/Globals/ObjectMgr.cpp Outdated
Tokenizer tokens(fields[6].GetString(), ' ');
if (creatureAddon.visibilityRange > MAX_VISIBILITY_DISTANCE)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry %u) has invalid value %u for visibilityRange field in `creature_template_addon`. Value cannot exceed %u.", entry, creatureAddon.visibilityRange, MAX_VISIBILITY_DISTANCE);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/travis/build/TrinityCore/TrinityCore/src/server/game/Globals/ObjectMgr.cpp:552:199: fatal error: 
      format specifies type 'unsigned int' but the argument has type 'float'
      [-Wformat]
  ...%u.", entry, creatureAddon.visibilityRange, MAX_VISIBILITY_DISTANCE);
     ~~                                          ^~~~~~~~~~~~~~~~~~~~~~~
     %f

}
}

if (uint32 visibilityRange = cainfo->visibilityRange)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be ==

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's declaring a variable inside the if and assigning it the value of cainfo->visibilityRange

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright

@Kittnz

Kittnz commented Oct 11, 2016

Copy link
Copy Markdown
Contributor

Also there are some Type of gobs are always seen very far away, specially quest gob's.

@SnapperRy

Copy link
Copy Markdown
Contributor Author

Yep, there are a good amount of them. Also creatures, mostly some Northrend rares and the giants meant to gank low level people.

if (creatureAddon.visibilityRange > MAX_VISIBILITY_DISTANCE)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry %u) has invalid value %u for visibilityRange field in `creature_template_addon`. Value cannot exceed %f.", entry, creatureAddon.visibilityRange, MAX_VISIBILITY_DISTANCE);
creatureAddon.visibilityRange = MAX_VISIBILITY_DISTANCE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/travis/build/TrinityCore/TrinityCore/src/server/game/Globals/ObjectMgr.cpp:553:45: fatal error: 
      implicit conversion from 'float' to 'uint32' (aka 'unsigned int') changes
      value from 533.33331 to 533 [-Wliteral-conversion]
            creatureAddon.visibilityRange = MAX_VISIBILITY_DISTANCE;
                                          ~ ^~~~~~~~~~~~~~~~~~~~~~~
/home/travis/build/TrinityCore/TrinityCore/src/server/game/Entities/Object/Object.h:38:37: note: 
      expanded from macro 'MAX_VISIBILITY_DISTANCE'
#define MAX_VISIBILITY_DISTANCE     SIZE_OF_GRIDS           // max dista...
                                    ^~~~~~~~~~~~~
/home/travis/build/TrinityCore/TrinityCore/src/server/game/Grids/GridDefines.h:39:34: note: 
      expanded from macro 'SIZE_OF_GRIDS'
#define SIZE_OF_GRIDS            533.3333f
                                 ^~~~~~~~~

@Kittnz

Kittnz commented Oct 21, 2016

Copy link
Copy Markdown
Contributor

Alright, after testing things out on retail again. I want to document them a bit here.

This PR is wrong at the moment. Some NPCs && Game Objects can been seen zone wide.

Few examples I have come across:

  • Wintergrasp Walls are seen zone wide. If you are in the zone, the gob gets visibility updated to you.
  • Fel Reaver is also seen zone wide. If you leave the zone it disappears, if you enter the zone again it becomes visible again.
  • Some types of NPCs can be seen far away, mostly flying NPCs (in dungeons they are seen zone wide too)
  • Some types of gobs are seen with a limited range like this in pr, set distance for specific type of gob.

@Shauren

Shauren commented Oct 21, 2016

Copy link
Copy Markdown
Member

@Kittnz you need to take one more thing into account, namely, cross realm zones. Sometimes (not always) adjacent zones are hosted on two different servers and if the new server does not have any instance of your old zone under its control then it also has no spawns (prevents exploits such as blocking things with firewalls to camp rare spawns).
Your method of testing can't reliably be applied since CRZ was added on retail.

@ghost

ghost commented Nov 8, 2016

Copy link
Copy Markdown

Putridus the Ancient used to set off my NPC_Scan all the time in Dalaran. He is located in Icecrown.

http://wowrarespawns.blogspot.com/2011/11/putridus-ancient.html#more - Nov 4, 2011
http://www.wowhead.com/npc=32487/putridus-the-ancient#comments:id=519231 - Dec 19, 2008

Killyana added a commit that referenced this pull request Nov 27, 2016
Closes  #4207
The set active will be removed once this PR #18067 merged
Spells cooldown is a generic issue
Aokromes pushed a commit to Aokromes/TrinityCore that referenced this pull request Nov 27, 2016
Closes  TrinityCore#4207
The set active will be removed once this PR TrinityCore#18067 merged
Spells cooldown is a generic issue
@Kittnz

Kittnz commented Dec 8, 2016

Copy link
Copy Markdown
Contributor

In sniffs we can see [0] UpdateType: FarObjects
and those objects can be seen very far away...

ServerToClient: SMSG_UPDATE_OBJECT (0x00A9) Length: 16 ConnIdx: 0 Time: 03/10/2010 00:21:45.000 Number: xxxxxx
Count: 1
[0] UpdateType: FarObjects
[0] Object Count: 1
[0] [0] Object GUID: Full: 0xxxxxxxxxxxxxxxxxxxx Type: Creature Entry: xxxxxxxx Low: xxx

@Takenbacon

Copy link
Copy Markdown
Contributor

@Kittnz The definition of 'FarObjects' from WPP is UPDATETYPE_OUT_OF_RANGE_OBJECTS in the core which 'unloads' the object.

@Kittnz

Kittnz commented Dec 9, 2016

Copy link
Copy Markdown
Contributor

Oh ok, didn't really look into it much.

@Kittnz

Kittnz commented Jan 17, 2017

Copy link
Copy Markdown
Contributor

https://youtu.be/Js8GbzFzOMk?t=157
Could be interesting, the zone wide scripting capability would be really good.

@Keader

Keader commented May 17, 2017

Copy link
Copy Markdown
Contributor

Someone can take over this ?
Would be nice to have it on TC.

@ghost

ghost commented May 18, 2017

Copy link
Copy Markdown

I will need some assistance with this one.

src/server/game/AI/SmartScripts/SmartScript.cpp:2523:43: fatal error: 
      no member named 'visibilityRange' in 'Creature'
                    (*itr)->ToCreature()->visibilityRange = e.action.vis...
                    ~~~~~~~~~~~~~~~~~~~~  ^

I thought I had grasped the concept of replacing m_SightDistance with visibilityRange and related code, but I was wrong. See the previous commits if you want to check the changes I made. Tell me if they should be reverted or not.

@ariel- ariel- Jun 3, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit reverted what SnapperRy came up with as a workaround. Is it 100% sure that it's intended or a side-effect of conflict solving?

SnapperRy and others added 4 commits June 3, 2017 00:53
@ariel- ariel- force-pushed the visibility_range branch from ebf271d to ca06951 Compare June 3, 2017 04:02
@ariel-

ariel- commented Jun 3, 2017

Copy link
Copy Markdown
Contributor

Rebased to fix conflicts and reduce changeset

@Kittnz

Kittnz commented Jun 3, 2017

Copy link
Copy Markdown
Contributor

There are different levels of range that you will be able to see gobs or npcs. Maybe there is a flag somewhere to know how far the specific gob can be seen in the zone.

@Keader

Keader commented Jun 28, 2017

Copy link
Copy Markdown
Contributor

Need fix conflicts again @ariel- :)

@ariel-

ariel- commented Jun 28, 2017

Copy link
Copy Markdown
Contributor

Pretty pointless to do until main logic is redone to not use "x 5" hack

@Shauren

Shauren commented Jun 28, 2017

Copy link
Copy Markdown
Member

Yeah, very much noped this one.

@Shauren Shauren closed this Jun 28, 2017
Aszune pushed a commit to Aszune/TrinityCoreRP that referenced this pull request Apr 3, 2018
Closes  TrinityCore#4207
The set active will be removed once this PR TrinityCore#18067 merged
Spells cooldown is a generic issue
(cherry picked from commit 0df7d22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants