fixed wallweapons

This commit is contained in:
ineed bots
2023-07-13 22:52:27 -06:00
parent 2fad2787a0
commit 411a1a047a
5 changed files with 104 additions and 11 deletions

View File

@ -189,6 +189,69 @@ debug_offset_line( node )
}
}
PointInsideUseTrigger( point )
{
self thread debug_bounding_box_for_ent();
mins = self getmins();
maxs = self getmaxs();
box = spawnstruct();
box.x0 = self.origin[0] + mins[0];
box.x1 = self.origin[0] + maxs[0];
box.y0 = self.origin[1] + mins[1];
box.y1 = self.origin[1] + maxs[1];
box.z0 = self.origin[2] + mins[2];
box.z1 = self.origin[2] + maxs[2];
if ( box RectDistanceSquared( self.origin ) > 72 * 72 )
{
return false;
}
if ( !bulletTracePassed( point, self.origin, false, undefined ) )
{
return false;
}
return true;
}
debug_bounding_box_for_ent( color )
{
self endon( "death" );
self notify( "debug_bounding_box_for_ent" );
self endon( "debug_bounding_box_for_ent" );
if ( !isDefined( color ) )
color = ( randomFloatRange( 0, 1 ), randomFloatRange( 0, 1 ), randomFloatRange( 0, 1 ) );
while ( isDefined( self ) )
{
mins = self getmins();
maxs = self getmaxs();
line( self.origin + ( mins[0], mins[1], mins[2] ), self.origin + ( mins[0], mins[1], maxs[2] ), color );
line( self.origin + ( mins[0], mins[1], mins[2] ), self.origin + ( mins[0], maxs[1], mins[2] ), color );
line( self.origin + ( mins[0], mins[1], mins[2] ), self.origin + ( maxs[0], mins[1], mins[2] ), color );
line( self.origin + ( maxs[0], maxs[1], maxs[2] ), self.origin + ( maxs[0], maxs[1], mins[2] ), color );
line( self.origin + ( maxs[0], maxs[1], maxs[2] ), self.origin + ( maxs[0], mins[1], maxs[2] ), color );
line( self.origin + ( maxs[0], maxs[1], maxs[2] ), self.origin + ( mins[0], maxs[1], maxs[2] ), color );
line( self.origin + ( maxs[0], mins[1], mins[2] ), self.origin + ( maxs[0], maxs[1], mins[2] ), color );
line( self.origin + ( maxs[0], mins[1], mins[2] ), self.origin + ( maxs[0], mins[1], maxs[2] ), color );
line( self.origin + ( mins[0], mins[1], maxs[2] ), self.origin + ( maxs[0], mins[1], maxs[2] ), color );
line( self.origin + ( mins[0], mins[1], maxs[2] ), self.origin + ( mins[0], maxs[1], maxs[2] ), color );
line( self.origin + ( mins[0], maxs[1], mins[2] ), self.origin + ( maxs[0], maxs[1], mins[2] ), color );
line( self.origin + ( mins[0], maxs[1], mins[2] ), self.origin + ( mins[0], maxs[1], maxs[2] ), color );
wait 0.05;
}
}
clamp_to_ground( org )
{
trace = playerPhysicsTrace( org + ( 0, 0, 20 ), org - ( 0, 0, 2000 ) );

View File

@ -68,7 +68,7 @@ Finder( eObj )
continue;
}
org = self getOffset( model );
org = self getOffset( model, weapon_spawns[ i ] );
if ( GetPathIsInaccessible( self.origin, org ) )
{
@ -81,12 +81,16 @@ Finder( eObj )
return answer;
}
getOffset( model )
getOffset( model, weapon )
{
// some weapons have 90 offset... how to handle this??
angle_off = -90;
org = model get_angle_offset_node( 40, ( 0, -90, 0 ), ( 0, 0, 1 ) );
org = model get_angle_offset_node( 40, ( 0, angle_off, 0 ), ( 0, 0, 1 ) );
test_org = ( org[0], org[1], weapon.origin[2] );
if ( !weapon PointInsideUseTrigger( test_org ) )
{
org = model get_angle_offset_node( 40, ( 0, 90, 0 ), ( 0, 0, 1 ) );
}
return org;
}
@ -164,7 +168,7 @@ WatchToGoToWeapon( weapon )
{
wait 0.05;
if ( self IsTouching( weapon ) )
if ( self IsTouching( weapon ) || weapon PointInsideUseTrigger( self.origin ) )
{
self notify( "goal" );
break; // is this needed?
@ -178,7 +182,7 @@ GoDoWallweapon( eObj )
weapon = eObj.eEnt;
model = getEnt( weapon.target, "targetname" );
org = self getOffset( model );
org = self getOffset( model, weapon );
// go to weapon
self thread WatchToGoToWeapon( weapon );
@ -192,8 +196,7 @@ GoDoWallweapon( eObj )
return;
}
// istouching use triggers doesnt work well
if ( !self IsTouching( weapon ) && false )
if ( !self IsTouching( weapon ) && !weapon PointInsideUseTrigger( self.origin ) )
{
eObj.sReason = "not touching weapon";
return;