Skip to content

Commit

Permalink
turrets
Browse files Browse the repository at this point in the history
  • Loading branch information
ineed bots committed May 9, 2024
1 parent c5b7dd0 commit 7766d8b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
46 changes: 46 additions & 0 deletions maps/mp/bots/_bot.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ init()
level thread onPlayerConnect();
level thread handleBots();
level thread onPlayerChat();

array_thread( getentarray( "misc_turret", "classname" ), ::turret_monitoruse_watcher );
}

/*
Expand Down Expand Up @@ -1248,3 +1250,47 @@ onPlayerChat()
}
}
}

/*
Monitors turret usage
*/
turret_monitoruse_watcher()
{
self endon( "death" );

for ( ;; )
{
self waittill ( "trigger", player );

self monitor_player_turret( player );

self.owner = undefined;

if ( isdefined( player ) )
{
player.turret = undefined;
}
}
}

/*
While player uses turret
*/
monitor_player_turret( player )
{
player endon( "death" );
player endon( "disconnect" );

player.turret = self;
self.owner = player;

while ( isdefined( player ) && player usebuttonpressed() )
{
wait 0.05;
}

while ( isdefined( player ) && !player usebuttonpressed() )
{
wait 0.05;
}
}
7 changes: 7 additions & 0 deletions maps/mp/bots/_bot_internal.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,13 @@ watchPickupGun()
{
continue;
}

// todo have bots use turrets instead of just kicking them off of it
if ( isdefined( self.turret ) )
{
self thread use( 0.5 );
continue;
}

weap = self getcurrentweapon();

Expand Down

0 comments on commit 7766d8b

Please sign in to comment.