Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: GetTarget() is not accessible from the team context

  1. #1
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,680

    GetTarget() is not accessible from the team context

    Test case:

    Code:
    -- team_desires.lua
    
    function TeamThink ()
    	if (GetTeamMember(2) ~= nil) then
    		print("team " .. GetTeamMember(2):GetUnitName() .. " * " .. tostring(GetTeamMember(2):GetTarget()))
    	end
    end

    Code:
    -- bot_lina.lua
    
    function Think ()
    	if (GetTeamMember(1) ~= nil and GetBot():GetTarget() == nil) then
    		GetBot():SetTarget(GetTeamMember(1))
    	end
    
    	print("self " .. GetBot():GetUnitName() .. " * " .. tostring(GetBot():GetTarget()))
    end
    Output:


    [VScript] team npc_dota_hero_lina * nil
    [VScript] self npc_dota_hero_lina * table: 0x0024d918
    [VScript] team npc_dota_hero_lina * nil
    [VScript] self npc_dota_hero_lina * table: 0x0024d918
    [VScript] team npc_dota_hero_lina * nil
    [VScript] self npc_dota_hero_lina * table: 0x0024d918
    I see no reason why this should not work, especially since it's a helper function designed to traverse modes (and why not - team-wide decisions). Now I know GetRoamTarget() is the mutual target, but, again, why would GetTarget() always return nil ?! Keep in mind GetAttackTarget() is accessible from TeamThink() so this inconsistency is even more boggling.
    Last edited by The Nomad; 06-23-2017 at 04:27 AM.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  2. #2
    Basic Member
    Join Date
    Dec 2016
    Posts
    120
    Ok lets see

    FIRST: it seems that lina placed at first player but u check target of second player in TeamThink(). change 2 to 1.
    of course in both files, lina name is shown.

    SECOND: TeamThink() runs from the first moment of hero selection. but bot_<heroes> not. u can test this by using GameTime() or DotaTime()( just to ensure that )

    for this i will send u some codes in next few hours.

    GetAttackTarget() return target that bot is currently attacking.
    Last edited by SIKIM; 06-23-2017 at 09:33 PM.

  3. #3
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,680
    That was a stripped down code to not output the whole mile-long code. I placed conditions so that they ouptut since pre-game time. Sorry I didn't clarify that.
    The parameters are fine: Think() is called by Lina and sets target as the first player. TeamThink() output output what Lina has as target.

    I know about GetAttackTarget(). I am not trying to get the currently attacked target, but the desired target.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  4. #4
    Basic Member
    Join Date
    Dec 2016
    Posts
    120
    Quote Originally Posted by The Nomad View Post
    That was a stripped down code to not output the whole mile-long code. I placed conditions so that they ouptut since pre-game time. Sorry I didn't clarify that.
    The parameters are fine: Think() is called by Lina and sets target as the first player. TeamThink() output output what Lina has as target.

    I know about GetAttackTarget(). I am not trying to get the currently attacked target, but the desired target.
    the only thing comes to my mind is time or differences between GetBot() and GetTeamMember(). in bot_lina, u set the target once the game started. but maybe TeamThink() started eariler than bot_lina( may be ). if not, it seems that there are differences between the information of GetBot() and GetTeamMember() given to the script.

    Check This:
    in some where like utility.lua
    Code:
    function AreAllFivePicked()
    	local ready = true;
    	for i=1,5 do
    		local member = GetTeamMember( i );
                    -- i set TEAMMATES table in hero selection when a player picks a hero
    		if( member == nil or TEAMMATES[member:GetPlayerID()] == nil ) then
    			ready = false;
    		end
    	end
    	return ready;
    end
    COACH_READY 	=	false;
    function READYALL()
    	return ( AreAllFivePicked() and COACH_READY );
    	
    end
    in TeamThink()
    Code:
    	if( COACH_READY == false ) then
    		COACH_READY 	=	true;
    	end
    	if( READYALL() == false ) then
    		--print( "we are not");
    		return;
    	end
    there maybe some syntax error, of course.

  5. #5
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,680
    Quote Originally Posted by SIKIM View Post
    the only thing comes to my mind is time or differences between GetBot() and GetTeamMember(). in bot_lina, u set the target once the game started. but maybe TeamThink() started eariler than bot_lina( may be ). if not, it seems that there are differences between the information of GetBot() and GetTeamMember() given to the script.
    I understand but I already told you I start both Think() functions during pregame at the same time.

    I would say that the team Think() function is on a separate thread than the bot one and changes there might not be accessible. I had a similar issue where a global variable was not visible to TeamThink() unless I used _G.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    120
    Quote Originally Posted by The Nomad View Post
    I understand but I already told you I start both Think() functions during pregame at the same time.

    I would say that the team Think() function is on a separate thread than the bot one and changes there might not be accessible. I had a similar issue where a global variable was not visible to TeamThink() unless I used _G.
    So, if it is, maybe u need to declare global variable for this issue. I did this for many purposes like using smoke, wards and global range abilities. there is a long way to reach matured API.

  7. #7
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,680
    Quote Originally Posted by SIKIM View Post
    there is a long way to reach matured API.
    Yup I agree. However, if there are bugs, we need to fix them too
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  8. #8
    Valve Developer
    Join Date
    Sep 2011
    Posts
    1,665
    I suspect that something in the default bot is stomping your SetTarget() value. Are you doing a full overwrite?

    There's nothing about the team-vs-unit scope that should impact this, it's a value stored on the bot itself, which both contexts access.

    If people would find these kind of accessors useful, I can add more that are specific to script usage.

  9. #9
    Basic Member
    Join Date
    Dec 2016
    Posts
    120
    Quote Originally Posted by ChrisC View Post
    I suspect that something in the default bot is stomping your SetTarget() value. Are you doing a full overwrite?
    I think Nomad is same as me.
    Quote Originally Posted by ChrisC View Post
    If people would find these kind of accessors useful, I can add more that are specific to script usage.
    This may irrelevant to this post, but i think ActionPush_MoveToLocation() use some static pre-allocated points on the map. for example even in full overwrite, when a player wants to move RUNE_BOUNTY_# from Shop Home, it uses a default path to final point. some points are located in upstairs or with few distance away behind the towers. Is there anyway to access these points in script?

  10. #10
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,680
    Quote Originally Posted by ChrisC View Post
    I suspect that something in the default bot is stomping your SetTarget() value.
    I used an empty test-case. Just with Think and TeamThink, nothing else to change them. And SetTarget() was set in only one frame.

    Quote Originally Posted by ChrisC View Post
    Are you doing a full overwrite?
    Yup. Try the above code and tell me if you can reproduce it while GetGameState() is pre game. I used a local var to make sure that SetTarget() is set once.

    Quote Originally Posted by ChrisC View Post
    There's nothing about the team-vs-unit scope that should impact this, it's a value stored on the bot itself, which both contexts access.
    It is not the first weird behavior I encountered. I also had an issue in the item's purchase Think and the bot's Think. I'll try to remember which it was if you want It was similar in behavior but a different scenario.
    Maybe it can help you track the bug.

    Quote Originally Posted by ChrisC View Post
    If people would find these kind of accessors useful, I can add more that are specific to script usage.
    That'd be great
    Last edited by The Nomad; 06-28-2017 at 10:49 AM.
    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
  •