1
0
mirror of https://github.com/ineedbots/iw5_bot_warfare.git synced 2025-09-01 10:37:25 +00:00

Cleanup trace for bones

Cleanup waypointcount
cleanup str concat
This commit is contained in:
ineed bots
2024-04-04 13:19:51 -06:00
parent f31a306b0a
commit 1bf8314acd
3 changed files with 96 additions and 72 deletions

View File

@@ -1303,6 +1303,23 @@ targetObjUpdateNoTrace( obj )
obj.didlook = false;
}
/*
Returns true if myEye can see the bone of self
*/
checkTraceForBone( myEye, bone )
{
boneLoc = self gettagorigin( bone );
if ( !isdefined( boneLoc ) )
{
return false;
}
trace = bullettrace( myEye, boneLoc, false, undefined );
return ( sighttracepassed( myEye, boneLoc, false, undefined ) && ( trace[ "fraction" ] >= 1.0 || trace[ "surfacetype" ] == "glass" ) );
}
/*
The main target thread, will update the bot's main target. Will auto target enemy players and handle script targets.
*/
@@ -1447,21 +1464,9 @@ target_loop()
}
else
{
targetHead = player gettagorigin( "j_head" );
targetAnkleLeft = player gettagorigin( "j_ankle_le" );
targetAnkleRight = player gettagorigin( "j_ankle_ri" );
traceHead = bullettrace( myEye, targetHead, false, undefined );
traceAnkleLeft = bullettrace( myEye, targetAnkleLeft, false, undefined );
traceAnkleRight = bullettrace( myEye, targetAnkleRight, false, undefined );
canTargetPlayer = ( ( sighttracepassed( myEye, targetHead, false, undefined ) ||
sighttracepassed( myEye, targetAnkleLeft, false, undefined ) ||
sighttracepassed( myEye, targetAnkleRight, false, undefined ) )
&& ( ( traceHead[ "fraction" ] >= 1.0 || traceHead[ "surfacetype" ] == "glass" ) ||
( traceAnkleLeft[ "fraction" ] >= 1.0 || traceAnkleLeft[ "surfacetype" ] == "glass" ) ||
( traceAnkleRight[ "fraction" ] >= 1.0 || traceAnkleRight[ "surfacetype" ] == "glass" ) )
canTargetPlayer = ( ( player checkTraceForBone( myEye, "j_head" ) ||
player checkTraceForBone( myEye, "j_ankle_le" ) ||
player checkTraceForBone( myEye, "j_ankle_ri" ) )
&& ( ignoreSmoke ||
SmokeTrace( myEye, player.origin, level.smokeradius ) ||
@@ -2372,9 +2377,9 @@ walk_loop()
dist = 16;
if ( level.waypointcount )
if ( level.waypoints.size )
{
goal = level.waypoints[ randomint( level.waypointcount ) ].origin;
goal = level.waypoints[ randomint( level.waypoints.size ) ].origin;
}
else
{