From 411a1a047a9a2f04379196c75956bbccbe7892b5 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 13 Jul 2023 22:52:27 -0600 Subject: [PATCH] fixed wallweapons --- maps/bots/_bot.gsc | 2 +- maps/bots/_bot_internal.gsc | 4 +- maps/bots/_bot_utility.gsc | 25 +++++++++++ maps/bots/objectives/_utility.gsc | 63 ++++++++++++++++++++++++++++ maps/bots/objectives/_wallweapon.gsc | 21 ++++++---- 5 files changed, 104 insertions(+), 11 deletions(-) diff --git a/maps/bots/_bot.gsc b/maps/bots/_bot.gsc index 3a44a2c..4ae833e 100644 --- a/maps/bots/_bot.gsc +++ b/maps/bots/_bot.gsc @@ -171,7 +171,7 @@ onPlayerDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, onActorDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, iModelIndex, iTimeOffset ) { - if ( isDefined( eAttacker ) && isPlayer( eAttacker ) && eAttacker isBot() && getDvarInt( "bots_t8_mode" ) ) + if ( isDefined( eAttacker ) && isPlayer( eAttacker ) && eAttacker isBot() && getDvarInt( "bots_t8_mode" ) && ( !isDefined( self.magic_bullet_shield ) || !self.magic_bullet_shield ) ) { iDamage += int( self.maxhealth * randomFloatRange( 0.25, 1.25 ) ); } diff --git a/maps/bots/_bot_internal.gsc b/maps/bots/_bot_internal.gsc index 0e72a38..babbc11 100644 --- a/maps/bots/_bot_internal.gsc +++ b/maps/bots/_bot_internal.gsc @@ -905,7 +905,9 @@ target_loop() ( traceAnkleRight["fraction"] >= 1.0 || traceAnkleRight["surfacetype"] == "glass" ) ) && ( getConeDot( enemy.origin, self.origin, myAngles ) >= myFov || - ( isObjDef && obj.trace_time ) ) ); + ( isObjDef && obj.trace_time ) ) + + && ( !isDefined( enemy.magic_bullet_shield ) || !enemy.magic_bullet_shield ) ); if ( isDefined( self.bot.target_this_frame ) && self.bot.target_this_frame == enemy ) { diff --git a/maps/bots/_bot_utility.gsc b/maps/bots/_bot_utility.gsc index ee147f9..f81ae2f 100644 --- a/maps/bots/_bot_utility.gsc +++ b/maps/bots/_bot_utility.gsc @@ -648,6 +648,31 @@ DistanceSquared2D( to, from ) return DistanceSquared( to, from ); } +RectDistanceSquared( origin ) +{ + dx = 0; + dy = 0; + dz = 0; + + if ( origin[0] < self.x0 ) + dx = origin[0] - self.x0; + else if ( origin[0] > self.x1 ) + dx = origin[0] - self.x1; + + if ( origin[1] < self.y0 ) + dy = origin[1] - self.y0; + else if ( origin[1] > self.y1 ) + dy = origin[1] - self.y1; + + + if ( origin[2] < self.z0 ) + dz = origin[2] - self.z0; + else if ( origin[2] > self.z1 ) + dz = origin[2] - self.z1; + + return dx * dx + dy * dy + dz * dz; +} + /* Rounds to the nearest whole number. */ diff --git a/maps/bots/objectives/_utility.gsc b/maps/bots/objectives/_utility.gsc index 794ee6b..160c598 100644 --- a/maps/bots/objectives/_utility.gsc +++ b/maps/bots/objectives/_utility.gsc @@ -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 ) ); diff --git a/maps/bots/objectives/_wallweapon.gsc b/maps/bots/objectives/_wallweapon.gsc index c506c02..120b0dc 100644 --- a/maps/bots/objectives/_wallweapon.gsc +++ b/maps/bots/objectives/_wallweapon.gsc @@ -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;