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

Help Me With Captain Mode

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

  • Help Me With Captain Mode

    I've implemented a dummy Captains Mode on hero selection. Here is the code
    Code:
    function Think()
    	if GetGameMode() == GAMEMODE_AP then
    		AllPickLogic();
    	elseif GetGameMode() == GAMEMODE_CM then
    		CaptainModeLogic();
    	end
    end
    
    local ListPickedHeroes = {};
    local AllHeroesSelected = false;
    
    function CaptainModeLogic()
    	if (GetGameState() ~= GAME_STATE_HERO_SELECTION) then
            return
        end
    	
    	if GetHeroPickState() == HEROPICK_STATE_CM_CAPTAINPICK then	
    		PickCaptain();
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN1 then
    		BansHero();
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN2 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN3 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN4 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT1 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT2 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT3 then
    		PicksHero();		
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT4 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN5 then
    		BansHero();
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN6 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN7 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN8 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT5 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT6 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT7 then
    		PicksHero();		
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT8 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN9 then
    		BansHero();
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_BAN10 then
    		BansHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT9 then
    		PicksHero();		
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_SELECT10 then
    		PicksHero();	
    	elseif GetHeroPickState() == HEROPICK_STATE_CM_PICK then
    		SelectsHero();	
    	end
    	
    end
    
    function PickCaptain()
    	if not IsHumanPlayerExist() or DotaTime() > -1 then
    		if GetCMCaptain() == -1 then
    			local CaptBot = GetFirstBot();
    			if CaptBot ~= nil then
    				SetCMCaptain(CaptBot)
    			end
    		end
    	end
    end
    
    function IsHumanPlayerExist()
        local Players = GetTeamPlayers(GetTeam())
        for _,id in pairs(Players) do
            if not IsPlayerBot(id) then
    			return true;
            end
        end
        return false;
    end
    
    function GetFirstBot()
    	local BotId = nil;
    	local Players = GetTeamPlayers(GetTeam())
        for _,id in pairs(Players) do
            if IsPlayerBot(id) then
    			BotId = id;
    			return BotId;
            end
        end
    	return BotId;
    end
    
    
    function RandomHero()
    	
    	local hero = "";
    	while ( hero == "" or IsCMPickedHero(GetTeam(), hero) or IsCMPickedHero(GetOpposingTeam(), hero) or IsCMBannedHero(hero) ) 
    	do
            hero = allBotHeroes[RandomInt(1, #allBotHeroes)];
        end
    	return hero;
    end
    
    function BansHero()
    	if not IsPlayerBot(GetCMCaptain()) or not IsPlayerInHeroSelectionControl(GetCMCaptain()) then
    		return
    	end	
    	
    	local BannedHero = RandomHero();
    	print(BannedHero.." is Banned")
    	CMBanHero(BannedHero);
    end
    
    function PicksHero()
    	if not IsPlayerBot(GetCMCaptain()) or not IsPlayerInHeroSelectionControl(GetCMCaptain()) then
    		return
    	end	
    	
    	local PickedHero = RandomHero();
    	print(PickedHero.." is Picked")
    	table.insert(ListPickedHeroes, PickedHero);
    	CMPickHero(PickedHero);
    end
    
    function WasHumansDonePicking()
    	local Players = GetTeamPlayers(GetTeam())
        for _,id in pairs(Players) 
    	do
            if not IsPlayerBot(id) then
    			if GetSelectedHeroName(id) == nil or GetSelectedHeroName(id) == "" then
    				return false;
    			end	
            end
        end
    	return true;
    end
    
    function SelectsHero()
    	if not AllHeroesSelected and ( WasHumansDonePicking() or GetCMPhaseTimeRemaining() < 1 ) then
    		local Players = GetTeamPlayers(GetTeam())
    		local RestBotPlayers = {};
    		for _,id in pairs(Players) 
    		do
    			local hero_name =  GetSelectedHeroName(id);
    			if hero_name ~= nil and hero_name ~= "" then
    				print(hero_name.." removed")
    				UpdateSelectedHeroes(hero_name)
    			else
    				table.insert(RestBotPlayers, id)
    			end	
    		end
    		for i = 1, #RestBotPlayers
    		do
    			print("ID "..RestBotPlayers[i].." picked "..ListPickedHeroes[i])
    			SelectHero(RestBotPlayers[i], ListPickedHeroes[i])
    		end
    		AllHeroesSelected = true;
    	end
    end
    
    function UpdateSelectedHeroes(selected)
    	for i=1, #ListPickedHeroes
    	do
    		if ListPickedHeroes[i] == selected then
    			table.remove(ListPickedHeroes, i);
    			return;
    		end
    	end
    end
    The questions is, Why did everytime I tried to disconnecting before the game ends and then try to make a new game, my dota 2 always crashes no matter what game mode I'm in? And why it's picking so fast? I'm as a Captain can't pick or ban the hero I wanted to. Is there anything wrong with code? Help me please.....

    Edit : Edit the code to the fixed version, but still I need to add some picking and baning logic, and some timer to mimic the thinking bot
    Last edited by arz_on4dt; 03-22-2017, 04:48 PM.

  • #2
    Just use Draft Bot code as i am or at least look at his code if you want to rewrite.

    Comment


    • #3
      Originally posted by Yavimaya View Post
      Just use Draft Bot code as i am or at least look at his code if you want to rewrite.
      No, it's just too confusing to see another people's code. If there is an error I don't know where to fixed it. So it's better to writing my own code, so I can clearly see where are my mistakes at. .

      Comment


      • #4
        You do realize you just asked us to read your code and find your mistakes then refused to look at another persons code cause its too hard to read another's code and find mistakes?

        Sorry, I have nothing more useful to contribute cause I don't know squat about hero selection process really.

        Comment


        • #5
          LOL iron!
          yea i find reading others code pretty easy, i find writing my own code from scratch almost impossible.

          just reading the start of your code, i tried similar.... took your AP code and added the elseif gamemode == AP..... to add AP to the CM code, but at character load it crashed every time... for no reason.

          so i dont know, i havent read through yours yet, but so far simply adding the different game modes the easiest way possible may just be crashy.
          Last edited by Yavimaya; 03-22-2017, 02:12 PM.

          Comment


          • #6
            btw, adamQ got breakers charge working by overtaking the roam and attack desires if you havent seen and want to get SB working (he only works 90% - still cancels charge sometimes, but when he locks in he locks in properly, but will tower dive too)

            Comment


            • #7
              OK.. Thanks for the replay . Found the mistakes already. I almost finished it .
              Last edited by arz_on4dt; 03-22-2017, 02:28 PM.

              Comment


              • #8
                I'd love to see bots playing this mode, similar to the HOTS bots playing Draft mode; those bots pick and ban heroes at an average pace.

                Comment


                • #9
                  I've finished it . But still though. I can only play one game. If I continuously play the game (whatever the game mode I'm in) the game will crash. I have to exit Dota 2 first, open it again then start to play. The same thing happen with Draft Bot. Any Idea? Or is it only me that experiencing that issue?
                  Last edited by arz_on4dt; 03-22-2017, 04:39 PM.

                  Comment


                  • #10
                    Originally posted by arz_on4dt View Post
                    I've finished it . But still though. I can only play one game. If I continuously play the game (whatever the game mode I'm in) the game will crash. I have to exit Dota 2 first, open it again then start to play. The same thing happen with Draft Bot. Any Idea? Or is it only me that experiencing that issue?
                    No, i have experienced this since the start of january or so.
                    i never associated it with the draft bot script, i havent played much else since i started compiling them, but im pretty sure it happens every single time i host any game with any script.

                    edit: just tested, only happening with captains mode.
                    interesting that it isnt just a bug in the draft bot script - unless you both did the same thing wrong.
                    Last edited by Yavimaya; 03-22-2017, 05:20 PM.

                    Comment


                    • #11
                      Originally posted by Yavimaya View Post
                      No, i have experienced this since the start of january or so.
                      i never associated it with the draft bot script, i havent played much else since i started compiling them, but im pretty sure it happens every single time i host any game with any script.
                      I never experiencing that if the game mode was always all pick. If I tried the game mode other than all pick (so far only captains mode) with my script or draft bot script, both of them have to restart dota 2 after one game on captains mode in order to not crashed the game. If I continuously play any game modes with any script it will crash. And I can't find any script error in the crash dump file.

                      Comment


                      • #12
                        Make sure if you are crashing really early in the game like loading the character selection screen or something that you check the end of the previous console tear-off. I've had crash errors actually pop before the game switched to the next console tear-off file so the last console log showed nothing but the one before it had my crash near the end. Rare, but check anyway

                        Comment


                        • #13
                          Originally posted by ironmano View Post
                          Make sure if you are crashing really early in the game like loading the character selection screen or something that you check the end of the previous console tear-off. I've had crash errors actually pop before the game switched to the next console tear-off file so the last console log showed nothing but the one before it had my crash near the end. Rare, but check anyway
                          The crash happen right after I click start game in a lobby then game shows black screen with Dota 2 logo and after that Dota 2 just closed and bring me to the desktop. It always like that. Every time I've finished a game with non All Pick mode (only Captains Mode so far) the game always behave like that. I've tried this :
                          1. Starting and finished a game in All Pick -> Starting and then disconnected in the middle of the game with another All Pick -> Starting and finished another game in All Pick -> Starting and finished a game in Captains Mode -> Starting a game in All Pick and the game just crash right after the Dota 2 logo showed up after I clicked Start Game in the lobby.
                          2. Starting and finished a game in Captains Draft -> Starting a game in Captains Draft and the game just crashes right after the Dota 2 logo showed up after I clicked Start Game in the lobby.
                          3. Starting and finished a game in Captains Draft -> Starting a game in All Pick and the game just crashes right after the Dota 2 logo showed up after I clicked Start Game in the lobby.
                          4. Starting and finished a game in Captains Draft -> Closed and Re-Open Dota 2 -> Starting and finished a game in Captains Draft -> If I try to start any game modes, the game just crashes.
                          5. Starting and finished a game in Captains Draft -> Closed and Re-Open Dota 2 -> Starting and finished a game in All Pick -> If I try to start any game modes other than Captains Draft it'll never crash.
                          6. Starting and finished a game in Captains Draft -> Start Solo Bot Match without a lobby and the game just crashes.

                          Is Captains Draft currently not fully supported yet? Or Do I have to clear something in hero_selection.lua in the Captains Mode part?
                          BTW this is the Dump File

                          Edit : I mean Captains Mode not Captains Draft.
                          Last edited by arz_on4dt; 03-23-2017, 03:29 AM.

                          Comment


                          • #14
                            after hosting captains mode, even if you quit as soon as it loads into the match, you cant even demo a hero let alone start another match.

                            Comment


                            • #15
                              Originally posted by Yavimaya View Post
                              after hosting captains mode, even if you quit as soon as it loads into the match, you cant even demo a hero let alone start another match.
                              That's been my experience with any bot match where no human players are present

                              Comment

                              Working...
                              X