Results 1 to 2 of 2

Thread: What is the point of the function CanBeSeen()

  1. #1
    Basic Member
    Join Date
    May 2017
    Posts
    1

    What is the point of the function CanBeSeen()

    I'm pretty new to bot scripting and have come across some functions that are a little strange to me. I noticed that any units, once out of vision, are deleted and cannot be referenced. I tried saving Hero/Lane Creep units for later use and they get deleted the moment they go out of vision. Also, GetUnitList(nUnitType) only ever gives you all units that are in vision to your team, so my question is then, what is the point of the function CanBeSeen() since after testing, it only ever returns true. You can basically just check if the unit itself is nil in order to see if it can be seen or not. Dead enemy Heroes seem to be the same as out-of-vision ones so their units are deleted as well. I'm just curious if there's any reason to be using this function at all?

    Also, it would be very nice to have some documentation on which unit-scoped functions do/don't work on enemy units.... took me a long time to realize that there are a lot of functions that just don't work on enemies, and I thought the issue was on my end :/. It makes sense, since the use of those functions (such as GetCurrentActionType(), GetAttackTarget(), etc.) would be construed as cheating, but it would be nice to know exactly which ones without having to test them.

  2. #2
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,590
    In the old version, the handle was not deleted, so caching the handle would allow you to check if it is still visible or not in case of bots.
    Also keep in mind that handles are not bot-related. A handle is not a pointer to a bot, but to a unit. That means that the handle can return a human player, a bot player, a summoned unit (Enigma's Edis, Chen's dominated creeps) or neutral/lane creeps.

    If you go out of view from a neutral camp (i.e. stacking) you can use CanBeSeen() on a neutral creep to know if you need to send the bot to the camp BEFORE attacking a creep or just to attack the visible creep directly. Another example is to dominate something. You can't dominate what is out of view. Or a bot needs to call CanBeSeen() on a human player to know what to do. And the list goes on. Half of the handle functions apply to any unit (but there is still a matter of consistency as mentioned here).

    These are just simple examples, but I think you get the idea. You mustn't limit yourself only to bots when learning the API
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •