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

IsCourierAvailable()

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

  • IsCourierAvailable()

    @ChrisC - can we make this API take a handle to a courier or an index number for courier so that we can use it on a specific courier if we have more than one?

    As I "extremely slowly" work on my WebBased-AI (really busy with real-life work stuff the past few weeks) I am imagining that bots might be very good at micro-ing 3+ couriers at the same time.

    PS - any chance for a UNIT_LIST_COURIER aggregator for GetUnitList()? Pretty please?

    PSS - the wiki really needs an update (many functions, constants, etc missing)

    PSSS - any update on GetUnitPotentialValue() being fixed

  • #2
    PSSSS - based on some feedback on my FullOverwrite of bots - it looks like the courier state flags are a bit messed up after the "fix" to the courier action type a patch or two ago.

    I have the following code:
    Code:
        if bot:IsAlive() and (bot:GetStashValue() > 500 or bot:GetCourierValue() > 0 or U.HasImportantItem()) and state ~= COURIER_STATE_DELIVERING_ITEMS then
            bot:ActionImmediate_Courier(courier, COURIER_ACTION_TAKE_AND_TRANSFER_ITEMS)
            return
        end
    I am told that the bots now fight over the courier, which indicates to me the COURIER_STATE_DELIVERING_ITEMS is possibly not being set correctly (or quickly enough) when a bot calls the above.

    Comment


    • #3
      There may be a slight delay, but I'm seeing them switch to it properly.

      Comment


      • #4
        there are probably multiple bots who have stash value over 500?
        they are always going to fight in that case.
        even the script i use that checks highest value stash, they fight for a bit in the prints, but the guy with highest stash ends up getting it.

        Comment


        • #5
          Originally posted by Yavimaya View Post
          there are probably multiple bots who have stash value over 500?
          they are always going to fight in that case.
          even the script i use that checks highest value stash, they fight for a bit in the prints, but the guy with highest stash ends up getting it.
          That should be the case though because of the AND rules I have in place:
          bot:IsAlive() and (bot:GetStashValue() > 500 or bot:GetCourierValue() > 0 or U.HasImportantItem()) and state ~= COURIER_STATE_DELIVERING_ITEMS

          The last part should make it "fail" when another bot is getting their items delivered.

          Comment


          • #6
            Re-reading the complaint, it seems it was more that a human was playing alongside my bots and the bots were stealing the courier from the human. Makes me wonder if the courier states are not set when a human does an action?

            Comment


            • #7
              there is a "delay" if you will, but it isnt a real delay, it is the same as most skill usage, it is repeated a few times before it actually happens (or maybe it is my bad scripting that does that).
              so even though you have that tagged on at the end, before it goes into that state, all bots will succeed in using the courier, it will just be the last guy that used it before the state change that actually gets his things delivered.
              now this doesnt fix your player usage issue, but it is my best explanation of why the bots would fight over it.

              for the player, you need to add a "not IsPlayerbot()" to make them not take it from humans - or atleast is the easiest way.

              e.g. the guts of the code i use:

              Code:
              if IsCourierAvailable() and not IsCourierNearShop(npcCourier) then
              	
              		if npcBot:IsAlive() and npcBot:GetStashValue() > 0 and not IsInvFull(npcBot) then
              			local numPlayer =  GetTeamPlayers(GetTeam());
              			local maxVal = 0;
              			_G.TransTarget = nil;
              			for i = 1, #numPlayer
              			do
              			--print(numPlayer[i]..tostring(IsPlayerBot(numPlayer[i])));
              				if GetTeamMember(i) ~= nil and IsPlayerBot(numPlayer[i]) and GetTeamMember(i):IsAlive() then
              					local SVal = GetTeamMember(i):GetStashValue();
              					if SVal ~= 0 and SVal > maxVal then
              						maxVal = SVal;
              						_G.TransTarget = GetTeamMember(i);
              					end
              				end
              			end
              				if _G.TransTarget ~= nil and  _G.TransTarget:IsAlive() then
              				--print(_G.TransTarget:GetUnitName().."       taketransf")
              				_G.TransTarget:ActionImmediate_Courier( npcCourier, COURIER_ACTION_TAKE_AND_TRANSFER_ITEMS )
              				return
              				end
              		elseif not npcBot:IsAlive() and npcBot:GetCourierValue() > 0 and npcCourier:DistanceFromFountain() == 0 then
              			--print(npcBot:GetUnitName().."          return stash")
              			npcBot:ActionImmediate_Courier( npcCourier, COURIER_ACTION_RETURN_STASH_ITEMS );
              			return
              		end
              		
              	elseif GetCourierState( npcCourier ) == COURIER_STATE_MOVING and (_G.TransTarget ~= nil and not _G.TransTarget:IsAlive()) then    -- _G. sets global?
              		--print(npcBot:GetUnitName().."             bot dead return")
              		npcBot:ActionImmediate_Courier( npcCourier, COURIER_ACTION_RETURN );
              		return
              	end
              Last edited by Yavimaya; 06-29-2017, 05:08 PM.

              Comment


              • #8
                Apart from making IsCourierAvaiable() unit-scoped, I think we could use 2 new functions: the one that is used by the 7.00 UI that counts how many slots a player uses on the courier (the little number over the courier icon) and the function that is used to draw the player's main hero icon when using it. I think that way we can at least use a not-nil condition on that. I know it is not always updated even on the UI as well as it gets overwritten when multiple players use it, but I think it'll help a great deal in bot games. I assume it returns the last player that used the courier when the courier is busy.
                Explanations on the normal, high and very high brackets in replays: here, here & here
                Why maphacks won't work in D2: here

                Comment


                • #9
                  Here is a way to change this without breaking people's code:

                  global IsCourierAvailable() -> returns true if at least 1 courier is available
                  unit based IsAvailable() -> returns true if the courier is available

                  Comment


                  • #10
                    But then we'd maybe need an extended class for couriers (returned by GetCourier(id)), I think? It's be silly to have courier-context abilities available to any unit. Plus it will allow more customizaiton for couriers (by adding our own functions for instance) A very nice approach was done the same way for custom games where each object had its own set of functions (which was limited by inheritance ).

                    And yes I agree with both nostrademous and Platinum_dota2.

                    On a related note: I still find couriers "frozen" in the middle of the field in native bot games. Not sure if it is a courier issue or a bot issue since I expect the bots to use a transfer&return just like humans.. There are also moments when the courier doesn't respond to my "call" from the HUD button (even in normal all-pick games, not just bots).
                    Last edited by The Nomad; 07-03-2017, 11:52 AM.
                    Explanations on the normal, high and very high brackets in replays: here, here & here
                    Why maphacks won't work in D2: here

                    Comment


                    • #11
                      Can you please add a way to distinguish couriers that return to base from those that return items to stash?
                      Explanations on the normal, high and very high brackets in replays: here, here & here
                      Why maphacks won't work in D2: here

                      Comment

                      Working...
                      X