Skip to content

Commit 153348e

Browse files
authored
Merge pull request ReactiveDrop#1049 from anf3is/fix/aim-above-extreme
Fix marines unexpectedly aiming at targets above the camera
2 parents 03aa4b2 + d27539d commit 153348e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/game/client/swarm/asw_input.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ ConVar joy_disable_movement_in_ui( "joy_disable_movement_in_ui", "1", FCVAR_NONE
5555
ConVar rd_input_controller_mode_mouse( "rd_input_controller_mode_mouse", "-1", FCVAR_NONE );
5656
ConVar rd_input_controller_mode_keyboard( "rd_input_controller_mode_keyboard", "-1", FCVAR_NONE );
5757

58+
ConVar rd_aim_ignore_above_camera_z( "rd_aim_ignore_above_camera_z", "-60", FCVAR_NONE, "Targets above the camera by this Z distance are ignored in top-down mode" );
59+
5860
extern kbutton_t in_attack;
5961
extern kbutton_t in_walk;
6062
extern int g_asw_iPlayerListOpen;
@@ -457,6 +459,19 @@ C_BaseEntity* HUDToWorld(float screenx, float screeny,
457459
if (asw_DebugAutoAim.GetBool())
458460
ASW_StoreClearAll();
459461

462+
// Check bad aim angles
463+
if ( pPlayer->GetASWControls() == ASWC_TOPDOWN &&
464+
!ASWInput()->ControllerModeActiveMouse() && pBestAlien )
465+
{
466+
Vector vecAlienPos = pBestAlien->GetAimTargetRadiusPos( vecWeaponPos );
467+
468+
// Don't aim at stuff a bit below camera and higher
469+
if ( vecAlienPos.z > vCameraLocation.z + rd_aim_ignore_above_camera_z.GetFloat() )
470+
{
471+
pBestAlien = NULL;
472+
}
473+
}
474+
460475
// if we have our cursor over a target (and not using the controller), make sure we have LOS to him before we continue
461476
if ( !ASWInput()->ControllerModeActiveMouse() && pBestAlien )
462477
{
@@ -505,6 +520,11 @@ C_BaseEntity* HUDToWorld(float screenx, float screeny,
505520
if ( vecAlienPos.DistToSqr(vecWeaponPos) > ASW_MAX_AUTO_AIM_RANGE )
506521
continue;
507522

523+
// Don't aim at stuff a bit below camera and higher
524+
if ( pPlayer->GetASWControls() == ASWC_TOPDOWN &&
525+
vecAlienPos.z > vCameraLocation.z + rd_aim_ignore_above_camera_z.GetFloat() )
526+
continue;
527+
508528
Vector vDirection = vecAlienPos - vecWeaponPos;
509529
float fZDist = vDirection.z;
510530
if ( fZDist > 250.0f )

0 commit comments

Comments
 (0)