Results 1 to 9 of 9

Thread: Some work for ChrisC!

  1. #1

    Some work for ChrisC!

    Alright, I finished all the basic pieces I needed: Skill/item build modules, courier managements, shopping module, enemy tracking, rune module, item usage module and some item usages, laning etc.

    The constants I'm using so far that I would like the API to have:

    • Side shops and secret shops locations: I suggest GetSideShopLocation(nLane) and GetSecretShopLocation(nLane), which returns nil for LANE_MID for side shops. and the team's secret shop for LANE_MID (nil is also fine). Or you can add constants like SIDE_SHOP_LOCATION_TOP etc. *EDIT: Nvm, found the API function, but it is missing from the wiki.
    • Fountain Location: I suggest GetFountainLocation(nTeam)
    • I'm manually considering attack damage and armor types (basic, fortified etc. for armor and basic, piercing etc. for attack damage), it would be great if you could add the attack types and consider armor types in "GetActualIncomingDamage".


    The main thing I still need from the API is a navigation module that avoids enemy heroes and towers (with some estimation of the total length of the chose (or to be chosen) path and an API function that gives access to the points on the path, like X units forward).

    I'll start working on this again in a few weeks, moving forward, I have to heavily work on team flights and rotations, for that I would like the following from the API:
    • What is the "danger" zone of enemy heroes, based on their ability and attack ranges
    • Initiation/blink range of enemy heroes, based on how far they can blink
    • Disable (stun, nightmare, root etc.) and slow range of enemy heroes, based on their abilities and items.
    • Improved (and/or different) versions of GetEstimatedDamageToTarget:
      • Something that is ability scoped and considers DPS abilities (and in case of uncertain damage, like Whirling Death, it returns a lower bound that is accurate)
      • improve GetEstimatedDamageToTarget to give a lower bound in case of uncertainty (like the above)
      • GetEstimatedDamageInRange that works similar to the above but also takes a range as an input parameter (if it makes it easier, having it not take a target handle is also fine)


    Some problems in the wiki:
    • COURIER_ACTION_STASH_ITEMS -> COURIER_ACTION_TAKE_STASH_ITEMS
    • Action_ImmedaitePing -> ActionImmediate_Ping
    • GetShopLocation is missing form the wiki *


    Some crash causes that should just give an error instead of crashing the game:
    • writing "=" instead of "==" in a conditional statement
    • not closing/opening (, [, { properly
    • writing name of a file wrong in dofile/require
    • trying to make courier perform an action that hasn't been implemented (like Action_MoveToLocation)


    Thank you in advance ChrisC! Let me know if any of these are not doable or you need suggestions for them, I would be happy to help!

    PS. I decided to make a separate thread since this rant became more than just adding some functions to the API!

    Edit: I also forgot to ask for the lane positioning functions (similar to GetPositionAlongLane) that go through middle of lanes (the current one is good for tracking creeps, but is better to use something that goes through the middle of the lane for positioning)

    Edit2: I forgot to say this, it seems like GetHealthRegen is off by some small (but not super small!) amount. for naga
    [Regen - (BaseRegen+RegenPerStr * Str)] was around 0.01 to 0.1 off (without having hp regen items of course)!
    Last edited by Platinum_dota2; 06-20-2017 at 12:18 AM.

  2. #2
    Basic Member
    Join Date
    Dec 2016
    Posts
    106
    writing name of a file wrong in dofile/require
    and also 2 files cannot require each other at the same time

  3. #3
    Quote Originally Posted by SIKIM View Post
    and also 2 files cannot require each other at the same time
    Doesn't this create a deadlock (or stack overflow) and make the OS kill Dota? I never read about what require exactly does, but if my guess is right, I don't think Chris can fix this!

  4. #4
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,652
    Quote Originally Posted by Platinum_dota2 View Post
    The constants I'm using so far that I would like the API to have:

    • Side shops and secret shops locations: I suggest GetSideShopLocation(nLane) and GetSecretShopLocation(nLane), which returns nil for LANE_MID for side shops. and the team's secret shop for LANE_MID (nil is also fine). Or you can add constants like SIDE_SHOP_LOCATION_TOP etc.
    Code:
    -- these 2 tables should be in a different file that is required only once at the beginning !
    Shops =
    {
    	SHOP_HOME_RADIANT	= 0,
    	SHOP_SIDE_RADIANT	= 1,
    	SHOP_SECRET_RADIANT	= 2,
    	SHOP_HOME_DIRE		= 3,
    	SHOP_SIDE_DIRE 		= 4,
    	SHOP_SECRET_DIRE 	= 5
    }
    
    ShopTypes =
    {
    	SHOP_HOME 	= 0,
    	SHOP_SIDE	= 1,
    	SHOP_SECRET = 2
    }
    
    -- file1.lua
    local DOTA = {}
    DOTA.ShopLocation = {}
    
    -- this should only be called once
    function DOTA.SetShopLocations ()
    	-- shops
    	DOTA.ShopLocation[Shops.SHOP_HOME_RADIANT]	 	= GetShopLocation(TEAM_RADIANT, 	SHOP_HOME);
    	DOTA.ShopLocation[Shops.SHOP_SIDE_RADIANT] 		= GetShopLocation(TEAM_NONE, 		SHOP_SIDE);
    	DOTA.ShopLocation[Shops.SHOP_SECRET_RADIANT]	= GetShopLocation(TEAM_NONE, 		SHOP_SECRET);
    	DOTA.ShopLocation[Shops.SHOP_HOME_DIRE] 		= GetShopLocation(TEAM_DIRE, 		SHOP_HOME);
    	DOTA.ShopLocation[Shops.SHOP_SIDE_DIRE] 		= GetShopLocation(TEAM_NONE, 		SHOP_SIDE2);
    	DOTA.ShopLocation[Shops.SHOP_SECRET_DIRE] 		= GetShopLocation(TEAM_NONE, 		SHOP_SECRET2);	
    end
    
    return DOTA;
    Then:
    Code:
    -- file2.lua
    local Locations = require("file1");
    
    -- this should only be called once
    Locations.SetShopLocations()
    
    print("The dire secret shop location is " .. tostring(Locations.ShopLocation[Shops.SHOP_SECRET_DIRE]));
    Quote Originally Posted by Platinum_dota2 View Post
    The constants I'm using so far that I would like the API to have:

    • Fountain Location: I suggest GetFountainLocation(nTeam)
    Code:
    function GetHomeBase (TeamID)
    	return GetShopLocation(TeamID, SHOP_HOME);
    end
    
    print("My Home base is " .. tostring(GetHomeBase(GetTeam()));
    Does this suffice?

    Quote Originally Posted by Platinum_dota2 View Post
    Doesn't this create a deadlock (or stack overflow) and make the OS kill Dota? I never read about what require exactly does, but if my guess is right, I don't think Chris can fix this!
    No, it creates a circular dependency. And it's true that he can't, since it's a Lua thing. Require loads each module in its package list. Then checks what dependencies that module has (determined by its own require() calls). If a requires b and b requires a, it's called a circular dependency and the package loader crashes since it doesn't know which to load first: the chicken or the egg.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  5. #5
    About shops: Didn't know (forgot) GetShopLocation exists (that's why Valve should keep wiki updated!). Thanks for the rest of the code, but it has no use for me. I'll add this to the wiki issues in the post.

    About Fountain: If I wanted to use hacky things, what I'm currently doing (using constants) would be more accurate.

    About the require issue: So it is a form of deadlock then (wasn't sure if Lua loads packages recursively until stack overflows or it gets stuck at loading)! I don't care what is the precise term for it, but the point stands, I don't think Chris can fix it!

    Edit: Nvm, actually the crash may be easier to fix than I thought, since Lua detects loops and give a "loop or previous error loading module" error.
    Last edited by Platinum_dota2; 06-19-2017 at 07:36 PM.

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    106
    Quote Originally Posted by Platinum_dota2 View Post
    Doesn't this create a deadlock (or stack overflow) and make the OS kill Dota? I never read about what require exactly does, but if my guess is right, I don't think Chris can fix this!
    Yes, Chris cant fix this because this is a major problem of LUA( i think ). I had this issue and remove one of require(s)( or dofiles ) and then dota never crash.

  7. #7
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,652
    Quote Originally Posted by Platinum_dota2 View Post
    About shops: Didn't know (forgot) GetShopLocation exists (that's why Valve should keep wiki updated!). Thanks for the rest of the code, but it has no use for me. I'll add this to the wiki issues in the post.
    How come? I thought you wanted a function that returns the current team's shops. Unless I misunderstood. I think native stuff should either be done if it's overly complex or if it is very expensive. Otherwise, customizing it in Lua seems the way to go since it's easy as hell. Even if it'd be done natively, I expect it to have the same code as above since that's what GetShopLocation() does. But that's just my opinion
    As for the code, it's fine, it's your choice whether to use it or not. That took me 2 minutes to write so no harm done. But it does do what you requested and it's not even expensive. If anybody wants to use it, feel free.

    Quote Originally Posted by Platinum_dota2 View Post
    About Fountain: If I wanted to use hacky things, what I'm currently doing (using constants) would be more accurate.
    I don't think there will ever be something more accurate than the home base shop. Why is it a hack ? What other location do you want? If you want the one further down, then you're confusing it with the start location. Just put a variable when the bot spawns and assume it's his home location. That's how I do it, it works and it will always be accurate. What's more, it will NEVER overlap with another bot if I want to, say, make it TP back or retreat. Or did you want the actual fountain unit and I misunderstood. Either way, a constant is not the way to go since, if they change the map again, it won't be accurate. I guess considering one day IceFrog might go the extra mile and move the shop out of the fountain (please don't !!!), I guess the safest way is still the spawn location

    Quote Originally Posted by Platinum_dota2 View Post
    About the require issue: So it is a form of deadlock then (wasn't sure if Lua loads packages recursively until stack overflows or it gets stuck at loading)! I don't care what is the precise term for it, but the point stands, I don't think Chris can fix it!
    A deadlock is something else. You can't use it as a synonym for circular dependency. They have nothing in common. A deadlock occurs when 2 objects want to assume ownership or authority over a third one and after one of them manages to, the second one will keep waiting and its thread is considered "dead" since it's trying to lock onto something that it can't and waits forever. And even if he could, I really don't think this is a priority. Just do a proper design and avoid circular dependencies and it's fine. That's the fix: avoiding circular dependencies.

    Quote Originally Posted by Platinum_dota2 View Post
    Lua detects loops and give a "loop or previous error loading module" error.
    It does.


    As for Chris, I think some help with items is in order. There were some suggestions to replace the component inner table with strings since it's more intuitive. I had a draft done some time ago but I didn't maintain it after the item changes since 15 patches ago and it's easier since most functions use item internal names. Also, a function to check IsItemPurchasedFromHomeShop() since some items can be purchased from both, the home and side shop. And of course... the API Requests thread
    Last edited by The Nomad; 06-20-2017 at 02:25 AM.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  8. #8
    @The Nomad: How did all of these points manage to go so far above your head, I'll never know! But I also don't have more time to argue nor care!

  9. #9
    Quote Originally Posted by SIKIM View Post
    Yes, Chris cant fix this because this is a major problem of LUA( i think ). I had this issue and remove one of require(s)( or dofiles ) and then dota never crash.
    Yes, Lua (similar to C#) tries to prevent you from using circular dependencies because they don't wanna deal with creating the resource graph and detecting deadlocks (it is a bit more complicated than this, but you get the idea). You still can do this (read the first solution), but you have to be careful to not create a stackoverflow problem (or an inifinite loop in general) or some type of deadlock. I don't think Lua is capable of detecting these issues (similar to Java), but some other languages can do this (not the inifinite loop problem in general tho, that's called "the halting problem" and is not solvable), so I get why you guessed this may be doable in lua. Even though this is a poor design choice, it can work if you are careful with avoiding the above issues.

    The crash is also avoidable (since Lua gives an error and doesn't crash itself), but needs some work from Chris (which depending on how hard it is, may not be worth it).

Posting Permissions

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