1. Post #1
    dill pickle pringle EXTREME

    May 2005
    487 Posts
    Provides various functions for the creation and control of bots.

    Changelog:
    [list][*]Moved the controller functions into the bot controller metatable. [/list]
    Download( source included ): Link

    Functions:
    [list][*]bot.Create( [name] ) - Creates a bot with the given name and returns a controller and the newly created bot entity.[*]BOTCONTROLLER:Run( [forward], [side], [up], [viewangles], [buttons], [impulse], [weapon select], [weapon subtype] ) - Run the bot, move it around, etc.[*]BOTCONTROLLER:ExecCommand( [command] ) - Runs the given command on the bot.[*]BOTCONTROLLER:RemoveAllItems( ) - Remove all the bot's items.[*]BOTCONTROLLER:SetActiveWeapon( [weapon] ) - Gives the bot a weapon.[*]BOTCONTROLLER:SetConVar( [var], [value] ) - Sets a client convar on the bot.[*]BOTCONTROLLER:IsEFlagSet( [flag] ) - Checks if an effect flag is set.[*]BOTCONTROLLER:PostClientMessagesSent( )[/list]
    Defines:
    [list][*]EFL_BOT_FROZEN[/list]
    Example:
    
    // Bot module.
    require( "bot" );
    //require( "botx" );
    
    // create our bot.
    local controller, entity 	= bot.Create( "MingeBag 2.0" );
    //local buttons			= botx.CreateButtonsHelper();
    local viewangle 		= Angle( 0, 0, 0 );
    local aim_at_player		= true;
    
    // just make it walk forward.
    local function botThink( )
    	// no bot?
    	if( !entity:IsValid() ) then return; end
    
    	// aim at nearest player.
    	if( aim_at_player ) then
    		// closest dist.
    		local closest, dist = nil, 8192;
    		local list, pl = player.GetAll();
    		for _, pl in pairs( list ) do
    			// closer?
    			local length = ( pl:GetPos() - entity:GetPos() ):Length();
    			if( pl != entity && length < dist ) then
    				dist = length;
    				closest = pl;
    			
    			end
    		
    		end
    		
    		// found?
    		if( closest ) then
    			// aim.
    			viewangle = ( closest:GetShootPos() - entity:GetShootPos() ):Normalize():Angle();
    
    		end
    	
    	
    	// increment angle.
    	else
    		viewangle.y = viewangle.y + 50 * FrameTime();
    		if( viewangle.y > 360 ) then viewangle.y = 0; end
    		
    	end
    	
    	// set bot angle.
    	entity:SetLocalAngles( viewangle );
    	
    	// walk.
    	controller:Run(
    		190,					// forward ( walk )
    		0,					// side ( strafe )
    		0,					// up ( swim, I think )
    		viewangle,				// view angles
    		0,					// buttons
    		0,					// impulse
    		0,					// weapon select
    		0					// weapon sub type
    	);
    
    	//
    	controller:PostClientMessagesSent( );
    	
    end
    hook.Add( "Think", "BotThink", botThink );
    
    
    
    
    Reply With Quote Edit / Delete Reply United States Show Events Winner Winner x 3 (list)

  2. Post #2
    Gold Member
    DaApocalypse's Avatar
    December 2005
    664 Posts
    Great release!
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 2 (list)

  3. Post #3
    Gold Member
    Termy58's Avatar
    September 2006
    1,675 Posts
    I remember testing it great job!

  4. Post #4
    Gold Member
    zerglingv2's Avatar
    February 2006
    1,403 Posts
    but its no vmf suite :crying: good job

  5. Post #5
    Gold Member
    Megiddo's Avatar
    January 2005
    246 Posts
    Nice, I see you used my lua module server plugin method. Glad I could help someone. :D

  6. Post #6
    Gold Member
    Elspin's Avatar
    December 2006
    2,785 Posts
    Jinto, you win all the internet.

    Edit:

    Jinto posted:
    
    // Bot module.
    require( "bot" );
    
    // create our bot.
    local controller, entity 	= bot.Create( "MingeBag 2.0" );
    local viewangle 		= Angle( 0, 0, 0 );
    local aim_at_player		= true;
    
    // just make it walk forward.
    local function botThink( )
    	// no bot?
    	if( !entity:IsValid() ) then return; end
    
    	// aim at nearest player.
    	if( aim_at_player ) then
    		// closest dist.
    		local closest, dist = nil, 8192;
    		local list, pl = player.GetAll();
    		for _, pl in pairs( list ) do
    			// closer?
    			local length = ( pl:GetPos() - entity:GetPos() ):Length();
    			if( pl != entity && length < dist ) then
    				dist = length;
    				closest = pl;
    			
    			end
    		
    		end
    		
    		// found?
    		if( closest ) then
    			// aim.
    			viewangle = ( closest:GetShootPos() - entity:GetShootPos() ):Normalize():Angle();
    
    		end
    	
    	
    	// increment angle.
    	else
    		viewangle.y = viewangle.y + 50 * FrameTime();
    		if( viewangle.y > 360 ) then viewangle.y = 0; end
    		
    	end
    	
    	// set bot angle.
    	entity:SetLocalAngles( viewangle );
    	
    	// walk.
    	bot.Run(
    		controller,				// the bot controller that was created with bot.Create
    		190,					// forward ( walk )
    		0,					// side ( strafe )
    		0,					// up ( swim, I think )
    		viewangle,				// view angles
    		0,					// buttons
    		0,					// impulse
    		0,					// weapon select
    		0					// weapon sub type
    	);
    
    	//
    	bot.PostClientMessagesSent( controller );
    	
    end
    hook.Add( "Think", "BotThink", botThink );
    
    I understood about 0% of that. God damn that's hard.
    Reply With Quote Edit / Delete Reply Canada Show Events Funny Funny x 1 (list)

  7. Post #7
    Get your own DarkRP Server!
    FPtje's Avatar
    January 2006
    4,717 Posts
    I understood -100% of that :D
    oh well...

    Bot=bot whee=whee

    Jinto made me happy :D
    Reply With Quote Edit / Delete Reply Netherlands Show Events Funny Funny x 1 (list)

  8. Post #8
    Devenger's Avatar
    February 2006
    228 Posts
    So we could potentially (laggily) create bot players and give them a basic AI via Lua inputs?
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 1 (list)

  9. Post #9
    hacker on steroids
    Conna's Avatar
    May 2006
    363 Posts
    Fantastic Jinto.

  10. Post #10
    dill pickle pringle EXTREME

    May 2005
    487 Posts
    I moved the controller functions into the bot controller metatable. Should be easier to use now. Link is in the first post.

    bot.SetActiveWeapon( mybot, "weapon_pistol" );
    Becomes.
    mybot:SetActiveWeapon( "weapon_pistol" );

  11. Post #11
    Meet the Pyro
    InsanePyro's Avatar
    April 2006
    4,373 Posts
    I DEMAND CSS BOTS/NPCs!

  12. Post #12
    hacker on steroids
    Conna's Avatar
    May 2006
    363 Posts
    I lol'd.

  13. Post #13
    HTF
    Gold Member
    HTF's Avatar
    January 2007
    501 Posts
    Nice work, pretty epic.

  14. Post #14
    DONT KNOW WHETHER YOU GUYS ARE AWARE BUT UNITY3D COSTS LOTS OF MONEY AND THE FREE VERSION ISNT VERY GOOD
    SteveUK's Avatar
    May 2005
    2,193 Posts
    Very cool module, hopefully we'll see some AI around soon.

  15. Post #15
    Hoffa's Avatar
    May 2007
    505 Posts
    awesome :excited:

  16. Post #16
    The Mathias's Avatar
    April 2007
    26 Posts
    This is pretty sweet. You can use player functions with them too, right?

  17. Post #17
    DONT KNOW WHETHER YOU GUYS ARE AWARE BUT UNITY3D COSTS LOTS OF MONEY AND THE FREE VERSION ISNT VERY GOOD
    SteveUK's Avatar
    May 2005
    2,193 Posts
    The Mathias posted:
    This is pretty sweet. You can use player functions with them too, right?
    Yup.

  18. Post #18
    Suicidal_B's Avatar
    December 2006
    130 Posts
    Niceness, but i can't get him to shoot? i've set weapon_physcannon and it stopped shooting on default, then i tried
    controller:ExecCommand( "+attack; -attack" );
    right after controller:Run

    what did i do wrong?

  19. Post #19
    dill pickle pringle EXTREME

    May 2005
    487 Posts
    Suicidal_B posted:
    Niceness, but i can't get him to shoot? i've set weapon_physcannon and it stopped shooting on default, then i tried
    controller:ExecCommand( "+attack; -attack" );
    right after controller:Run

    what did i do wrong?
    The buttons argument of BOTCONTROLLER:Run is a bitmask of all the keys you want them to have held this frame.

    // walk.
        controller:Run(
            190,                    // forward ( walk )
            0,          // side ( strafe )
            0,          // up ( swim, I think )
            viewangle,        // view angles
            IN_JUMP + IN_DUCK,          // buttons
            0,          // impulse
            0,          // weapon select
            0               // weapon sub type
        );
    

  20. Post #20
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    Awesome, I'll give a try at an AI :D

    How do I disable the default bot behaviour?

    Also, what does this do
    bot.PostClientMessagesSent( controller )

  21. Post #21
    Suicidal_B's Avatar
    December 2006
    130 Posts
    jA_cOp posted:
    Awesome, I'll give a try at an AI :D

    How do I disable the default bot behaviour?

    Also, what does this do
    bot.PostClientMessagesSent( controller )
    My d/l doesn't say controller in between, but yeah i also have that question (will try keys now, thanks)

    Edit: Another thing, the bot often goes in some kind of slomo reverse, it still aims right but walks backward (sometimes forward too) really really slowly, with a slow animation, any fix for that?

  22. Post #22
    dill pickle pringle EXTREME

    May 2005
    487 Posts
    Code:
    bot_zombie 1
    Disable the default gmod bot behaviour. As for the funky animation, I get that too, never found a workaround for it.

  23. Post #23
    Suicidal_B's Avatar
    December 2006
    130 Posts
    Hmm, the angle it shoots in isn't the same as the angle its looking at, any thoughts? i'm just trying some basic stuff on gm_construct and it keeps shooting towards behind the spawn, no matter what angle.

    Then i gave it a physgun and it pointed to same place behind spawnpoint, so if you could be so nice, look into it


    Edit: I do find this awesome though, despite my many questions

  24. Post #24
    CapsAdmin's Avatar
    August 2005
    3,773 Posts
    Wow.

    Edit:

    Elspin posted:
    Jinto, you win all the internet.

    Edit:



    I understood about 0% of that. God damn that's hard.
    Just read the comments and I'm pretty sure you'll understand it just fine (The green text.)

  25. Post #25
    Gold Member
    smallfry's Avatar
    January 2007
    1,118 Posts
    Can they use .nav files?

  26. Post #26
    Gold Member
    earthHunter's Avatar
    May 2006
    35 Posts
    This is great. I can't wait to try it out with CapsAdmin.

  27. Post #27
    DONT KNOW WHETHER YOU GUYS ARE AWARE BUT UNITY3D COSTS LOTS OF MONEY AND THE FREE VERSION ISNT VERY GOOD
    SteveUK's Avatar
    May 2005
    2,193 Posts
    smallfry posted:
    Can they use .nav files?
    If you programmed them to.

  28. Post #28
    Gold Member
    morpheous's Avatar
    February 2005
    15 Posts
    Thought I'd let you know...



    Fantastic module; eagerly awaiting the first scripts using this.

  29. Post #29
    Suicidal_B's Avatar
    December 2006
    130 Posts
    I'm working on a basic friendly bot (as in not meant to deathmatch)
    When it finds a prop near it runs to it and stops before hitting it, then tries to punt it away using the physcannon (yellow gravgun), though that keeps failing (i'm thinking its looking over the prop or something, the bot doesn't seem to aim up/down)
    Either way it's great fun, thanks loads

  30. Post #30
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    Bot.Controller:Run( 0, 0, 0, Bot.Entity.Master:GetPos() - Bot.Entity:GetPos():Angle() , IN_FORWARD, 0, 0, 0 )

    That's run every frame - and is supposed to make it follow its creator. However, when I start the think hook that runs it gmod crashes.

    Any idea why?

  31. Post #31
    Suicidal_B's Avatar
    December 2006
    130 Posts
    Why are you using Bot.Entity, use entity or controller (entity in his case i guess)

    Edit: you also didn't normalize the angle
    viewangle = ( ply:GetPos() - entity:GetShootPos() ):Normalize():Angle();

  32. Post #32
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    Suicidal_B posted:
    Why are you using Bot.Entity, use entity or controller (entity in his case i guess)

    Edit: you also didn't normalize the angle
    viewangle = ( ply:GetPos() - entity:GetShootPos() ):Normalize():Angle();
    Thanks, but the error was actually I was missing some parens :)
    There is no need to normalize it either. And bot.Entity is a variable by me :)

  33. Post #33
    Gold Member
    BulletofHell's Avatar
    August 2006
    1,495 Posts
    Uh. I can't get this to work, I may be doing something wrong, I put this in the console:

    Code:
     bot.Create [MingeBag]
    Or bot.Create( [MingeBag] )
    Halp pl0x?

    It says it's an unknown command.

  34. Post #34
    Sieni.us's Avatar
    July 2006
    9 Posts
    What compiler you did use to make this?

    I want to learn C++ but i need good compiler & need to learn use it before learning C++.

  35. Post #35
    Gold Member
    Catdaemon's Avatar
    February 2005
    2,818 Posts
    BulletofHell posted:
    Uh. I can't get this to work, I may be doing something wrong, I put this in the console:

    Code:
     bot.Create [MingeBag]
    Or bot.Create( [MingeBag] )
    Halp pl0x?

    It says it's an unknown command.
    This is a lua module, you can't use it with the console.

  36. Post #36
    Suicidal_B's Avatar
    December 2006
    130 Posts
    jA_cOp posted:
    Thanks, but the error was actually I was missing some parens :)
    There is no need to normalize it either. And bot.Entity is a variable by me :)
    Oh okay :)

  37. Post #37
    Gold Member
    BulletofHell's Avatar
    August 2006
    1,495 Posts
    Catdaemon posted:
    This is a lua module, you can't use it with the console.
    Ok, I sound really fucking retarded, but what the hell is a lua module? And how to I activate it, or whatever?
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 1 (list)

  38. Post #38
    Gold Member
    ferdam's Avatar
    June 2005
    1,794 Posts
    Sorry, I'm a noob but where do I extract ?

    thanks !

  39. Post #39
    Gold Member
    BulletofHell's Avatar
    August 2006
    1,495 Posts
    Garrysmod/Garrysmod. Now can someone answer my question?

  40. Post #40
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    BulletofHell posted:
    Ok, I sound really fucking retarded, but what the hell is a lua module? And how to I activate it, or whatever?
    You don't. This module adds lua commands for scripters to use. If you want to try the example script though - type
    Code:
    lua_openscript bot.lua
    in the console.

    If you want bot scripts, just wait for a release using this :)