Results 1 to 6 of 6

Thread: Bug Report: GetHealth() return -1 on neutral creep

  1. #1
    Basic Member
    Join Date
    Dec 2016
    Posts
    121

    Bug Report: GetHealth() return -1 on neutral creep

    This bug only happens when my bot work as Dire bot, the API works fine when bot work as Radiant bot so I didn't find them out in first place.

    console print out as Dire bot when jungle:
    Code:
    [VScript] attack nearby neutralcreep
    [VScript] creep_hp =-1
    [VScript] creep_hp =-1
    console print out as Radiant bot when jungle:
    Code:
    [VScript] attack nearby neutralcreep
    [VScript] creep_hp =660
    [VScript] 660
    [VScript] creep_hp =34
    [VScript] attacking  npc_dota_neutral_satyr_hellcaller
    [VScript] alchemist current_action=gojungle
    [VScript] alchemist current_action_p=7.49

    jungle code:

    Code:
    function gofarmjungle(camp_distance, camp_loc)
    	local npcBot = GetBot();
    	local com_state = "gofarmjungle";
    	if (npcBot:IsChanneling( )) then
    		return com_state;
    	end
    	local NearbyNeutralCreeps = npcBot:GetNearbyNeutralCreeps( 800 );
    	local highest_hp = 0;
    	local target_creep = nil;
    	
    	if (camp_loc ~= nil and GetUnitToLocationDistance(npcBot, camp_loc) <= 400 and #NearbyNeutralCreeps > 0) then
    		print('attack nearby neutralcreep');
    		for creep_k, creep in pairs( NearbyNeutralCreeps ) do  --get weakest enemy creep nearby
    			local creep_hp = creep:GetHealth();
    			print('creep_hp ='..creep_hp);
    			if (creep:GetUnitName() == "npc_dota_neutral_dark_troll_warlord") then
    				creep_hp = 1;
    			elseif (creep:GetUnitName() == "npc_dota_neutral_ghost" or creep:GetUnitName() == "npc_dota_neutral_prowler_shaman" or creep:GetUnitName() == "npc_dota_neutral_granite_golem" or creep:GetUnitName() == "npc_dota_neutral_enraged_wildkin") then
    				creep_hp = 9999;
    			end
    			
    			if(creep:IsAlive() and highest_hp < creep_hp) then 	----always focus on creep with high hp when jungle
    				highest_hp = creep_hp;
    				target_creep = creep;
    				print(highest_hp);
    			end
    		end
    		local name = target_creep:GetUnitName();
    		npcBot:Action_AttackUnit(target_creep, false); 
    		print('attacking  '..name);		
    	elseif (camp_loc ~= nil and (GetUnitToLocationDistance(npcBot, camp_loc) > 400 or (not IsLocationVisible(camp_loc)) ) ) then
    		npcBot:Action_MoveToLocation(camp_loc);	
    		local dis = GetUnitToLocationDistance(npcBot, camp_loc);
    		if ( dis > 400) then
    			print('distance = '..dis);
    		end
    		if (not IsLocationVisible(camp_loc)) then
    			print('camp_loc invisible');
    		end
    	elseif (camp_loc == nil) then
    		print('camp_loc == nil');
    	end
    	return com_state;
    end
    Last edited by lunarbreez; 04-20-2017 at 03:10 PM.

  2. #2
    Basic Member
    Join Date
    Dec 2016
    Posts
    178
    previously some function does not trigger for enemy creeps and neutral ones like GetAttackTime()
    i dont know GetHealth() works fine or not but this may happen because u find all N. creeps in 800 units around hero and function trigger when u reach specific camp in 400. this means that if hero stand between two camps and be close to one of them, it will consider all creeps on second camp too.

    check the creep unit name that return GetHealth() -1, and find out is this creep belongs to camp_loc or not?
    hope this helpyou

  3. #3
    Basic Member
    Join Date
    Dec 2016
    Posts
    121
    Quote Originally Posted by SIKIM View Post
    previously some function does not trigger for enemy creeps and neutral ones like GetAttackTime()
    i dont know GetHealth() works fine or not but this may happen because u find all N. creeps in 800 units around hero and function trigger when u reach specific camp in 400. this means that if hero stand between two camps and be close to one of them, it will consider all creeps on second camp too.

    check the creep unit name that return GetHealth() -1, and find out is this creep belongs to camp_loc or not?
    hope this helpyou
    All N.creep GetHealth() -1 if bot is on dire side, even if creep not belongs to camp_loc there is no reason they return a -1 value. Bot should be able to get creep hp from GetUnitList() no matter how far they are, as long as they can be seen.

  4. #4
    Basic Member
    Join Date
    Dec 2016
    Posts
    178
    Quote Originally Posted by lunarbreez View Post
    All N.creep GetHealth() -1 if bot is on dire side, even if creep not belongs to camp_loc there is no reason they return a -1 value. Bot should be able to get creep hp from GetUnitList() no matter how far they are, as long as they can be seen.
    The only thing comes to my mind is "you have no vision to creep in NearbyNeutralCreeps". but u said that this happen when you stand in dire side and that's weird.
    If I were u:
    1- Check that npcBot have vision to creep
    2- Change #Nearby... to table.getn( Nearby... )
    3- i your output above, bot select creep Satyr Tormenter( npc_dota_neutral_satyr_hellcaller ) to attack but this creep has 1100 HP( not 660 i checked in wiki ). check your iteration and try to access all properties of each creep in each frame. for example try to see GetHealth() and GetUnitName() in parallel even GetHealth() returns -1.

    all of this are recommended just to make sure that this problem arises from api rather than your awosome code!

    Hope this helpful

  5. #5
    Basic Member
    Join Date
    Dec 2016
    Posts
    121
    Quote Originally Posted by SIKIM View Post
    The only thing comes to my mind is "you have no vision to creep in NearbyNeutralCreeps". but u said that this happen when you stand in dire side and that's weird.
    If I were u:
    1- Check that npcBot have vision to creep
    2- Change #Nearby... to table.getn( Nearby... )
    3- i your output above, bot select creep Satyr Tormenter( npc_dota_neutral_satyr_hellcaller ) to attack but this creep has 1100 HP( not 660 i checked in wiki ). check your iteration and try to access all properties of each creep in each frame. for example try to see GetHealth() and GetUnitName() in parallel even GetHealth() returns -1.

    all of this are recommended just to make sure that this problem arises from api rather than your awosome code!

    Hope this helpful
    1. Yes I have vision on that creep, and creep you can't see should not be got by GetNearbyNeutralCreeps() according to "no cheat" rule, if bot can get a creep he can't see, it's still an API problem.
    2. creep_hp = -1 won't be printed out if there is a problem with #NearbyNeutralCreeps, it's printed out because "if #NearbyNeutralCreeps > 0" works fine.
    3. Bot works fine on Radiant side, so when I copy the console output it already did some damage to creep, which means any number from 1 to 1100 is reasonable for creep Satyr Tormenter.

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    178
    I cant find anyway to solve this issue?

    Do u have any update for this problem?

Posting Permissions

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