diff --git a/code/playerman/player.h b/code/playerman/player.h index d3b54b2730f..2bf6f6098a3 100644 --- a/code/playerman/player.h +++ b/code/playerman/player.h @@ -227,6 +227,7 @@ extern bool Player_use_ai; extern angles chase_slew_angles; // The viewing angles in which viewer_slew_angles will chase to. extern angles Player_flight_cursor; +extern float Player_flight_cursor_sensitivity; enum class FlightMode { ShipLocked = 0, diff --git a/code/playerman/playercontrol.cpp b/code/playerman/playercontrol.cpp index c9708e13fb2..a663dc5a9c2 100644 --- a/code/playerman/playercontrol.cpp +++ b/code/playerman/playercontrol.cpp @@ -62,6 +62,7 @@ physics_info Descent_physics; // used when we want to control the player like angles chase_slew_angles; angles Player_flight_cursor; +float Player_flight_cursor_sensitivity; FlightMode Player_flight_mode = FlightMode::ShipLocked; bool Perspective_locked = false; @@ -1079,8 +1080,8 @@ void read_player_controls(object *objp, float frametime) if (sip->aims_at_flight_cursor) max_aim_angle = sip->flight_cursor_aim_extent; - Player_flight_cursor.p += Player->ci.pitch * 0.015f; - Player_flight_cursor.h += Player->ci.heading * 0.015f; + Player_flight_cursor.p += Player->ci.pitch * 0.015f * Player_flight_cursor_sensitivity; + Player_flight_cursor.h += Player->ci.heading * 0.015f * Player_flight_cursor_sensitivity; float mag = powf(powf(Player_flight_cursor.p, 2.0f) + powf(Player_flight_cursor.h, 2.0f), 0.5f); if (mag > max_aim_angle) { @@ -1446,6 +1447,7 @@ void player_level_init() Viewer_external_info.current_distance = 0.0f; Player_flight_cursor = vmd_zero_angles; + Player_flight_cursor_sensitivity = 1.0f; if (Default_start_chase_view != The_mission.flags[Mission::Mission_Flags::Toggle_start_chase_view]) diff --git a/code/scripting/api/libs/controls.cpp b/code/scripting/api/libs/controls.cpp index 415b36ff01f..36e0b24d8bd 100644 --- a/code/scripting/api/libs/controls.cpp +++ b/code/scripting/api/libs/controls.cpp @@ -403,6 +403,17 @@ ADE_FUNC(resetFlightCursor, l_Mouse, nullptr, "Resets flight cursor position to return ADE_RETURN_NIL; } +ADE_VIRTVAR(FlightCursorSensitivity, l_Mouse, "number", "Flight cursor movement sensitivity multiplier", "number", "Flight cursor sensitivity multiplier") +{ + float val_sens; + + if (ADE_SETTING_VAR && ade_get_args(L, "*f", &val_sens)) { + Player_flight_cursor_sensitivity = val_sens; + } + + return ade_set_args(L, "f", Player_flight_cursor_sensitivity); +} + ADE_FUNC(setCursorImage, l_Mouse, "string filename", "Sets mouse cursor image, and allows you to lock/unlock the image. (A locked cursor may only be changed with the unlock parameter)", "boolean", "true if successful, false otherwise") { using namespace io::mouse;