1. Post #1
    Gold Member
    AzuiSleet's Avatar
    September 2007
    758 Posts
    I did gm_botcontroller a while back, since someone asked me for one since Jinto's gmsv_bot is gone.
    gm_aigraph is for whoever was asking for access to the ai graph.

    Botcontroller has mostly the same functions and syntax as gmsv_bot.
    aigraph is just nodes, links = ParseGraphFile("garrysmod/maps/graphs/gm_construct.ain")

    http://azuisleet.gayluadad.net/gmode...controller.zip
    http://azuisleet.gayluadad.net/gmode/gm_aigraph.zip


  2. Post #2
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    Give me all your fucking babies.

    I love you.
    Reply With Quote Edit / Delete Reply Australia Show Events Funny Funny x 4Agree Agree x 1Dumb Dumb x 1 (list)

  3. Post #3
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    wtfdoublepost
    Reply With Quote Edit / Delete Reply Australia Show Events Funny Funny x 2Agree Agree x 1 (list)

  4. Post #4
    kevkev's Avatar
    April 2007
    1,093 Posts
    Can you give us some more details about the bot controller? there is no readme in the file.

  5. Post #5
    Gold Member
    AzuiSleet's Avatar
    September 2007
    758 Posts
    It's the same syntax as
    http://www.facepunch.com/showthread.php?t=330732
    I might have changed some stuff so check the .cpp file.

  6. Post #6
    Gold Member
    AzuiSleet's Avatar
    September 2007
    758 Posts
    (double post)

  7. Post #7
    Levybreak's Avatar
    March 2008
    718 Posts
    gm_aigraph is for whoever was asking for access to the ai graph.
    That was me, oh so long ago. :D

  8. Post #8
    Turd92's Avatar
    March 2008
    182 Posts
    This is fantastic, thanks Azu!

  9. Post #9
    Gold Member
    Bragdras's Avatar
    October 2007
    3,113 Posts
    Could you provide some more information?

  10. Post #10
    Turd92's Avatar
    March 2008
    182 Posts
    Is there a way to parse graph files that are in the GCFs? I have to extract them myself for it to open the .ains.

  11. Post #11
    Levybreak's Avatar
    March 2008
    718 Posts
    Is there a way to parse graph files that are in the GCFs? I have to extract them myself for it to open the .ains.
    I haven't tried it, but can it read ain's that are packed into the bsp?

  12. Post #12
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    Azu mentioned to me that he wanted to make one that used the Steam file system, so you could read graph files in the GCFs, but he was too tired at the time to do it.

  13. Post #13
    Turd92's Avatar
    March 2008
    182 Posts
    Oh well, to even have these modules is just brilliant so I'm not too bothered. Thanks again :D

    Oh and I've only tried gm_construct so far Levy, I'll give it a go in a few minutes.

    EDIT: Doesn't seem like you can, unfortunately.

  14. Post #14
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    Just copy gm_construct.ain out of the GCF, hurr.
    Reply With Quote Edit / Delete Reply Australia Show Events Bad Reading Bad Reading x 1 (list)

  15. Post #15
    Turd92's Avatar
    March 2008
    182 Posts
    I haven't tried it, but can it read ain's that are packed into the bsp?
    I was answering that, Deco. I tried a user made map that has it's graph file included in the BSP, not one from any GCF.

    EDIT: Found out that GCFScape can open BSP files, just tried it and managed to extract the .ain from rd_zombocity_f2.bsp :D

  16. Post #16
    DawG_09's Avatar
    July 2009
    20 Posts
    Anyone got a example for gm_botcontroller? I tried Jinto's but it fails attempting to call field create a nil value.

  17. Post #17
    Respected User
    JSharpe's Avatar
    January 2008
    889 Posts
    I too would like to see how the botcontroller is used.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 2 (list)

  18. Post #18
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    require("botcontroller")
    
    local bots = {}
    concommand.Add("new_bot", function(p, c, a)
    	local controller, entity = bot.CreateBot(a[1] or "MingeBag")
    	debug.setmetatable(entity, _R.Player)
    	table.insert(bots, {
    		controller = controller,
    		entity = entity,
    		viewangle = Angle(0, 0, 0),
    		aim_at_player = true,
    	})
    end)
    local function botThink()
    	for id, bot in pairs(bots) do
    		if bot.entity and bot.entity:IsValid() then
    			if bot.aim_at_player then
    				local closest, dist = nil, 8192
    				for _,pl in pairs(player.GetAll()) do
    					local length = (pl:GetPos()-bot.entity:GetPos()):Length()
    					if pl:UserID() ~= bot.entity:UserID() and length < dist then
    						dist = length
    						closest = pl
    					end
    				end
    				if closest then
    					bot.viewangle = (closest:GetShootPos()-bot.entity:GetShootPos()):Normalize():Angle()
    				end
    			else
    				bot.viewangle.y = bot.viewangle.y+50*FrameTime()
    				if bot.viewangle.y > 360 then bot.viewangle.y = 0 end
    			end
    			--bot.entity:SetLocalAngles(bot.viewangle)
    			bot.controller:Move(
    				190,				-- forward ( walk )
    				50,					-- side ( strafe )
    				0,					-- up ( swim, I think )
    				bot.viewangle,		-- view angles
    				0,					-- buttons
    				0,					-- impulse
    				0,					-- weapon select
    				0					-- weapon sub type
    			)
    			bot.controller:PostClientMessagesSent()
    		else
    			table.remove(bots, id)
    		end
    	end
    end
    hook.Add("Think", "BotThink", botThink)
    

    Made this ages ago. Have fun.
    Reply With Quote Edit / Delete Reply Australia Show Events Artistic Artistic x 1 (list)

  19. Post #19
    Respected User
    JSharpe's Avatar
    January 2008
    889 Posts
    Cheers, going to make some thing out of this for sure.

  20. Post #20
    devmon's Avatar
    July 2007
    256 Posts
    What does this do?
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 4Bad Reading Bad Reading x 3 (list)

  21. Post #21
    Respected User
    JSharpe's Avatar
    January 2008
    889 Posts
    What does this do?
    the gm_botcontroller allows us to, control bots. Make them go to places, say shit etc etc.

    the gm_aigraph, gives us access, to the ai graph.

  22. Post #22
    Gold Member
    Silverlan's Avatar
    October 2005
    745 Posts
    the gm_botcontroller allows us to, control bots. Make them go to places, say shit etc etc.
    You can't change the bot's eye angles though, he always looks in the default direction. player.SetEyeAngles doesn't work on bots, and the viewangles in bot.Move only set his movement direction, but not where he's looking to.

  23. Post #23
    Salads's Avatar
    November 2008
    176 Posts
    You can't change the bot's eye angles though, he always looks in the default direction. player.SetEyeAngles doesn't work on bots, and the viewangles in bot.Move only set his movement direction, but not where he's looking to.
    Sure you can, player.SnapEyeAngles

  24. Post #24
    Gold Member
    Silverlan's Avatar
    October 2005
    745 Posts
    Sure you can, player.SnapEyeAngles
    That doesn't seem to work neither on bots. At least it didn't when I tried just now.

  25. Post #25
    Salads's Avatar
    November 2008
    176 Posts
    That doesn't seem to work neither on bots. At least it didn't when I tried just now.
    It works fine for me. Try setting it consistently so their eye angles don't revert back.

  26. Post #26
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,349 Posts
    Going to make a video of AI bots in gmod (like the css ones).

  27. Post #27
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    That doesn't seem to work neither on bots. At least it didn't when I tried just now.
    That "debug.setmetable(bot_entity, _R.Player)" line is there for a reason.

  28. Post #28
    Gold Member
    Silverlan's Avatar
    October 2005
    745 Posts
    That "debug.setmetable(bot_entity, _R.Player)" line is there for a reason.
    I know, I did use that. Otherwise I'd have gotten lua errors on running player.SnapEyeAngles.
    Anyway, I found out what the problem was. I called player.SnapEyeAngles right before running controller.Move.
    It works fine if you call it after that.

  29. Post #29
    supercombine222's Avatar
    September 2009
    51 Posts
    how do i install sorry if bump
    Reply With Quote Edit / Delete Reply Puerto Rico Show Events Dumb Dumb x 17Agree Agree x 1 (list)

  30. Post #30
    Marcho700's Avatar
    March 2010
    128 Posts
    how do i install sorry if bump
    Dear god... *sigh*
    Reply With Quote Edit / Delete Reply Finland Show Events Dumb Dumb x 7Late Late x 1 (list)

  31. Post #31
    likes men
    Python1320's Avatar
    May 2007
    1,709 Posts
    Anyone wanting to do a linux port of the botcontroller?
    No?
    Fine... I'll try to do it myself :(
    Okay, here: http://g.iriz.org/~srcds/modules/gms...ller_linux.dll

    EDIT: Scratch that. It crashes when the bot dies. Gives me an invalid pointer error with huge backtrack but nothing tracing back to the botcontroller code..
    EDIT2: Okay, it crashes only on my production server so it's some addon or module. Use at your own risk..
    Reply With Quote Edit / Delete Reply Finland Show Events Funny Funny x 1Informative Informative x 1 (list)

  32. Post #32
    Gold Member
    Silverlan's Avatar
    October 2005
    745 Posts
    It seems that the botcontroller doesn't work properly anymore. Calling 'PostClientMessagesSent' crashes the game instantly.
    Any ideas what could cause this?

  33. Post #33
    Ruzza's Avatar
    December 2011
    1,137 Posts
    Broken Symbols I think?

  34. Post #34
    Gold Member
    Silverlan's Avatar
    October 2005
    745 Posts
    The only thing regarding the function of 'PostClientMessagesSent' I've found was this:
    void CBaseEntity::PostClientMessagesSent( void )
    {
    	// Remove nointerp flags from entity after every frame
    	if ( IsEffectActive( EF_NOINTERP ) )
    	{
    		RemoveEffects( EF_NOINTERP );
    	}
    }

    Doing that in lua instead of calling the function directly doesn't crash the game, however the bot refuses to do anything.

  35. Post #35
    Gold Member
    Silverlan's Avatar
    October 2005
    745 Posts
    Bump.
    Anyone got any ideas on how to fix this?

    Edited:
    Nevermind, I've fixed it.
    All I had to do was remove the 'PostClientMessagesSent' function from the iplayerinfo header and recompile the module.
    Seems to work fine now.

    Edited:
    Here's the fixed version, if anyone wants it:
    http://www.gamefront.com/files/21671...controller.rar

    I removed PostClientMessagesSent, so make sure not to call that anymore.
    Reply With Quote Edit / Delete Reply Windows 7 Germany Show Events Winner Winner x 2 (list)

  36. Post #36
    Gold Member
    Mitsudigi's Avatar
    July 2005
    422 Posts
    Crashes after running bot.CreateBot() successfully :(

    I see the bot spawn then 1 second later, end of hl2.exe
    Reply With Quote Edit / Delete Reply Windows 7 Canada Show Events Late Late x 1 (list)

  37. Post #37
    Gold Member
    Pigbear's Avatar
    September 2011
    1,756 Posts
    Crashes after running bot.CreateBot() successfully :(

    I see the bot spawn then 1 second later, end of hl2.exe
    Fail. Last post what May 8th 2012, Its broken.

    (User was banned for this post ("Bumping to complain about bumping" - mahalis))
    Reply With Quote Edit / Delete Reply Windows XP United States Show Events Dumb Dumb x 3Funny Funny x 1Lua King Lua King x 1 (list)

  38. Post #38
    Gold Member
    Mitsudigi's Avatar
    July 2005
    422 Posts
    Fail. Last post what May 8th 2012, Its broken.
    And? I hope Garry added this to 13 or we'll probably never see it.
    Reply With Quote Edit / Delete Reply Windows 7 Canada Show Events Optimistic Optimistic x 1 (list)