The "brain" of our botĪs scary as this code may look to some, it is actually pretty simple: Pretty straight forward right? Walk to a random spot and sit idle for 2 seconds before walking to another random spot.Īs nice as this is its not what we want, up next is a much better AI. The function is done here, but will start back at the top of the loop and make the bot walk somewhere else end end
Rand( -1, 1 ), 0 ) * 400 ) - Walk to a random place within about 400 units (yielding) self: StartActivity( ACT_IDLE ) - Idle animation coroutine. loco:SetDesiredSpeed( 200 ) - Walk speed self: MoveToPos( self: GetPos() + Vector( math. While ( true ) do - Here is the loop, it will run forever self: StartActivity( ACT_WALK ) - Walk animation self. So after your ai has finished running everything it can do, it will go back and do it again. The function is a coroutine, or pretty much a giant looping section of code, except you can pause it for a period of time using coroutine.wait( time ).Ĭoroutines allow you to do things in a timed order, letting you pause the function so we can make the bot face the player or play an animation.Īnd since its all inside a while true loop, it will run for as long as the bot exists. This next part is where most of our AI will be set up. Now that the bot can find enemies we need to get it to actually do something other then just having an enemy. Return true end end - We found nothing so we will set our enemy as nil (nothing) and return false self: SetEnemy( nil) Here we loop through every entity the above search finds and see if it's the one we want for k,v in ipairs( _ents ) do if ( v: IsPlayer() ) then - We found one so lets set it as our enemy and return true self: SetEnemy(v) FindInSphere( self: GetPos(), self.SearchRadius ) ents.FindInCone() to replicate eyesight local _ents = ents. Search around us for entities - This can be done any way you want eg. If the enemy is dead( we have to check if its a player before we use Alive() ) elseif ( self: GetEnemy():IsPlayer() and !self: GetEnemy():Alive() ) then return self: FindEnemy() - Return false if the search finds nothing end - The enemy is neither too far nor too dead so we can return true return true else - The enemy isn't valid so lets look for a new one return self: FindEnemy()Įnd end - ENT:FindEnemy() - Returns true and sets our enemy if we find one - function ENT: FindEnemy() If our current enemy is valid if ( self: GetEnemy() and IsValid( self: GetEnemy()) ) then - If the enemy is too far if ( self: GetRangeTo( self: GetEnemy():GetPos()) > self.LoseTargetDist ) then - If the enemy is lost then call FindEnemy() to look for a new one - FindEnemy() will return true if an enemy is found, making this function return true return self: FindEnemy() Now you no longer have to open chat to click :Dįixed script errors when you aim at a npc/playermodel which doesn't have "ValveBiped.Bip01_Head1" (The code for version 1.- ENT:Get/SetEnemy() - Simple functions used in keeping our enemy saved - function ENT: SetEnemy(ent)Įnd - ENT:HaveEnemy() - Returns true if we have an enemy - function ENT: HaveEnemy() Variables now save for the current session Old name was NPC and Player Aimbot and Wallhack, had to re-name otherwise it may have been taken off of the workshop for containing the word "hack"Ĭrosshair colour willl save across sessionsĬrosshair slider (slide to the right for bigger crosshair)įixed the bug where triggerbot stopped you from being able to pickup props. If you don't use mouse button 1 to fire your weapons then the triggerbot even when turned off will stop you from being able to pickup props.
I shall try and release an update once a week. Work in progress, stuff will be added overtime It's also even cooler if you setup a map with npcs and go third person, makes it feel like gta/watchdogs, such fun! This was made for me and my friends to use on our sandbox server to mess about and pretend that we are hacking XD MarioDox has Garry's Mod 15 Jul 10:20pmĪdd colors for friendly/enemy/neutral/player Triggerbot - No need for fast reactions now! A update has fixed the script errors from that.Īimbot/assist - When you aim at a player or npc it will flick your crosshair to their head.Įsp - Draws a red halo around the npc/player which is visible through walls.Ĭustom crosshairs! - Now you will always be able to see where you are aiming! None so far other than the aimbot doesn't lock onto npcs/playermodels which don't have the default skeleton.
Open up console and type in "lua_openscript_cl a"