Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

[Suggestion] Functions related to vision of entities and visiblity

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Suggestion] Functions related to vision of entities and visiblity

    We noticed a lack of functions that allow you to check wheter an entity is being viewed, what the entity can view and team related view-ability.

    Currently we have BaseNPC.CanEntityBeSeenByMyTeam(handle hEntity), but this lacks functionality.

    We would like to suggest the following functions
    • bool CDOTA_BaseNPC:CanBeSeenByTeam( teamID )
    • table CDOTA_BaseNPC:GetSeenEntities()
    • table CDOTA_BaseNPC:GetEntitiesThatSeeMe()


    The first could also replace the already implemented function, since it can be implemented to also provide the functionality "CanEntityBeSeenByMyTeam" provides.

    The second function will provide a list of entities that see the specified entity.

    The third function will provide a list of entities that this entity can see.

  • #2
    The first function can be implemented in LUA using CanEntityBeSeenByMyTeam (assuming hEntity is the player entity in the "my" context)

    The second function will provide a list of entities that see the specified entity.
    Player entities? or just any entity... Keep in mind not every entity has a field of view.
    The third function will provide a list of entities that this entity can see.
    Not quite sure what you mean by this.. Do you mean entities within this entities field of view?


    Considering how long we've waited for the fog of view fix for bigger maps, I doubt we are going to see anything similar to these functions anytime soon
    Last edited by arhowk; 07-21-2015, 11:03 AM.
    Every time you have an issue, spend at least 5 minutes on each of these four sites Google, Wiki, Github, and ModDota
    If you still can't figure out your issue, post your issue on moddota in as much detail as possible with a SSCCE. If you do not complete these requirements, than you will be rejected by the community. Try not to contact individual users for help as we are very busy.

    Comment


    • #3
      Originally posted by arhowk View Post
      The first function can be implemented in LUA using CanEntityBeSeenByMyTeam (assuming hEntity is the player entity in the "my" context)
      I think you're misunderstanding the use-case of the first suggested function by OP. Using CDOTABaseNPC:CanEntityBeSeenByMyTeam(handle hEntity) implies the programming situation to be that there's two variables (entities) known to the programmer, namely: entity A (source) and entity B (target). In the situation of A:CanEntityBeSeenByMyTeam(B), NPC B is the NPC you want to do the visibility check on and NPC A is the NPC the function gets its team from. You could program a work-around for the first function using this, but a solution built using this method would only work under certain assumptions.

      The main gripes here are accessing an NPC A from the team that is supposed to see NPC B and doing this optimally. What if that's not possible in your current programming scope and you just have access team ID (which is always defined)? What if using that workaround leads to an unnecessarily high time complexity? (Ex. finding entities to perform CDOTABaseNPC:CanEntityBeSeenByMyTeam(handle hEntity) from in a thinking context every 0.1 seconds)

      Originally posted by arhowk View Post
      Player entities? or just any entity... Keep in mind not every entity has a field of view.
      I think it's only logical that a function like this should only return entities if those are actually affected by the fog-of-war system themselves. (NPCs, buildings, trees) Maybe a flag or filter would be needed in this proposed function to filter out specific types of entities? Or something similar qua function structure to the Find-functions in CEntities?

      The second suggested function, table CDOTA_BaseNPC:GetSeenEntities(), should be able to be easily implemented using CEntities:FindUnitsInRadius and using CDOTABaseNPC:CanEntityBeSeenByMyTeam(handle hEntity) a few times, but that solution seems to generate an extremely high time complexity to me. In a worst case scenario this would lead to something like this:
      Code:
      --Note: This code is more about the complexity than the actual functionality, so I did not test or profile it.
      local npc = self -- The CDOTA_BaseNPC entity that wants to find all entities that it can see
      local units =  FindUnitsInRadius(
      	        	npc:GetTeam(),
      	                npc:GetAbsOrigin(),
      	                nil,
      	                npc:GetCurrentVisionRange(),
      	                DOTA_UNIT_TARGET_TEAM_BOTH,
      	                DOTA_UNIT_TARGET_ALL,
      	                DOTA_UNIT_TARGET_FLAG_NONE,
      	                FIND_ANY_ORDER,
      	                false) --O(x) complexity --where 'x' is unknown time-complexity of FindUnitsInRadius
      local result = {}
      for k,v in pairs(units) do --O(n) * O(y) * O(1) complexity --where 'n' is the size of the table 'units'
           if npc:CanEntityBeSeenByMyTeam(v) then --O(y) complexity --where 'y' is unknown time-complexity of CanEntityBeSeenByMyTeam
                table.insert(result, v) --O(1)
           end
      end
      return result
      This nets you O(x) + O(n) * O(y) time complexity, which could be disastrously inefficient depending on the amount of units in your NPC's sight range and the time complexity of Source's FindUnitsInRadius and CanEntityBeSeenByMyTeam functions.

      You could solve function 3 in an even worse way by using a structure similar to the above solution by looping through all the entities and then checking if they see 'npc' and then adding them to the result table if they do. You could optimize it by keeping track of the team IDs that've seen 'npc' and making a check every time you loop through an entity if their team has already seen entity 'npc' and then adding the entity to the result table straight away if the entity's team has already seen 'npc'.

      TL;DR:
      • bool CDOTA_BaseNPC:CanBeSeenByTeam( teamID ) cannot be solved with existing API functionality. There are workarounds for other similar functions, but those would not work in cases where you only have a team ID, and not an entity, in your programming scope.
      • table CDOTA_BaseNPC:GetSeenEntities() can be solved in an inefficient way with existing API functionality.
      • table CDOTA_BaseNPC:GetEntitiesThatSeeMe() can be solved in an extremely inefficient way with existing API functionality.


      I'd say all these functions are worth it to implement after thinking about some common use-cases of these functions. (ex. Slark ultimate, AoE spell that only hits enemies that are not in fog of war from the caster's perspective, NPC AI, etc.) If not these exact iterations, then at least the functionality they bring to the table.

      Comment


      • #4
        Like Daimao stated, it's not that the goals that we wish to reach are out of scope, but the current API does not allow for it in an efficient and painless way.

        Also, I would deem it reasonable that these functions get implemented seeing that a lot of AI related and spell related stuff are tied in directly to field of view.

        Comment

        Working...
        X