Page 2 of 2 FirstFirst 1 2
Results 11 to 18 of 18

Thread: Pop Up Gold and Number Animation

  1. #11
    Basic Member
    Join Date
    May 2014
    Posts
    270
    Quote Originally Posted by antigame View Post
    Yeah, I thought so also try to optimize your ItemPurchaseThink function if you can because it's a bad sign when those messages appear too many times (once in a while is okay though).
    Yah, that's happen because of that logic error. It only appears 3 or 5 times if I didn't get that error. Can I ask a question. How to make courier not delivering the item if the bot is dead and it's courier value > 0. I've added this
    Code:
    if not npcBot:IsAlive() then
    		return
    	end
    in the begining of the CourierUsageThink() but the courier still delivering the item to the place where the bot die.

  2. #12
    Basic Member
    Join Date
    Jun 2013
    Posts
    275
    You need to have the bot command the courier to return to base.

    With your 'if' there, it's basically just preventing any further commands from reaching the courier if the hero is dead.

    To clarify: If it's mid deliver you need to make it return. Blocking commands from reaching it if the bot is not currently using it should prevent it from delivering. I have a similar statement myself.
    Last edited by Cornbane; 02-03-2017 at 08:51 AM.

  3. #13
    Basic Member
    Join Date
    May 2014
    Posts
    270
    Owh OK, Thank you. I'll try it. Do you mean like this?

    Code:
           if not npcBot:IsAlive() and GetCourierState( npcCourier ) == COURIER_STATE_DELIVERING_ITEMS  and npcBot:GetCourierValue( ) > 0  then
    		npcBot:Action_Courier( npcCourier, COURIER_ACTION_RETURN );
    		if npcCourier:DistanceFromFountain() < 100 then
    			npcBot:Action_Courier( npcCourier, COURIER_ACTION_RETURN_STASH_ITEMS );
    		end
    		return
    	end
    Last edited by arz_on4dt; 02-03-2017 at 09:07 AM.

  4. #14
    Basic Member
    Join Date
    Dec 2016
    Posts
    733
    Quote Originally Posted by arz_on4dt View Post
    Edit 3 : Yep, it's the buy sell tp that gone too fast. There is a logic error in my code. After I changed it to this. It never shows up again.
    Code:
    local npcBot = GetBot();
    	if ( npcBot:DistanceFromFountain() <= 100 or npcBot:DistanceFromSecretShop() <= 100 ) and DotaTime() > 30*60  then
    		for _,item in pairs(earlyGameItem)
    		do
    			local itemSlot = npcBot:FindItemSlot(item);
    			if itemSlot >= 0 then
    				if item == "item_stout_shield"  then
    					if not HasCGorABBuild() then
    						npcBot:Action_SellItem(npcBot:GetItemInSlot(itemSlot));
    					end
    				elseif item == "item_tpscroll" then
    					if HasItem(npcBot, "item_travel_boots_1") then
    						print(npcBot:GetUnitName()..'sell tp')
    						npcBot:Action_SellItem(npcBot:GetItemInSlot(itemSlot));
    					end
    				else
    					npcBot:Action_SellItem(npcBot:GetItemInSlot(itemSlot));
    				end
    			end
    		end		
    	end
    I can tell you why this fixed it if you don't know and want to know

  5. #15
    Basic Member
    Join Date
    May 2014
    Posts
    270
    Quote Originally Posted by nostrademous View Post
    I can tell you why this fixed it if you don't know and want to know
    I knew it. It's because the second condition of if statement is never correct if the bot doesn't have BoT, so even though the item value is "item_tp_scroll" it'll still be passed through the else condition, in result the bot will sell the tp, isn't it?

  6. #16
    Quote Originally Posted by Cornbane View Post
    It's odd to me if 2 milliseconds is considered taking too long. Some of my larger functions can take up to 30ms depending on some situations and conditions and I don't get this kind of spam.
    Think of 2 ms in this way: If there are 10 bots, the code will take 20 ms in each frame, so bots cannot update themselves more than 50 times per second. Also if your code takes 30ms regularly for a single hero, you will have issues. From my experience, a bot's IQ drops when the code is slow. One of the main differences between Hard and Unfair difficulties is that Hard has a 100-200 ms reaction delay and Unfair has 75-150ms delay (and yes, this is actually very important)

  7. #17
    Basic Member
    Join Date
    Dec 2016
    Posts
    733
    Quote Originally Posted by arz_on4dt View Post
    I knew it. It's because the second condition of if statement is never correct if the bot doesn't have BoT, so even though the item value is "item_tp_scroll" it'll still be passed through the else condition, in result the bot will sell the tp, isn't it?
    Right on

  8. #18
    Basic Member
    Join Date
    Jun 2013
    Posts
    275
    Quote Originally Posted by Platinum_dota2 View Post
    Think of 2 ms in this way: If there are 10 bots, the code will take 20 ms in each frame, so bots cannot update themselves more than 50 times per second. Also if your code takes 30ms regularly for a single hero, you will have issues. From my experience, a bot's IQ drops when the code is slow. One of the main differences between Hard and Unfair difficulties is that Hard has a 100-200 ms reaction delay and Unfair has 75-150ms delay (and yes, this is actually very important)
    It's not 30ms regularly. It's "depending on some situations and conditions", so they only get called every so often. Some of my custom functions are quite hefty on the first pass. Gathering cache-able information for example, which ultimately leads to subsequent passes being much faster.

    EDIT

    Upon closer inspection, I have been reading the debug window wrong. It's actually 0.30ms.
    Last edited by Cornbane; 02-04-2017 at 05:59 PM.

Posting Permissions

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