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 );

Register
Events
Popular
More
Post #1


Winner x 3

Agree x 2


Funny x 1






Dumb x 1