Skip to content

Commit f23d35c

Browse files
authored
add scripted flight cursor sensitivity (#7149)
1 parent ff11370 commit f23d35c

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

code/playerman/player.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ extern bool Player_use_ai;
227227
extern angles chase_slew_angles; // The viewing angles in which viewer_slew_angles will chase to.
228228

229229
extern angles Player_flight_cursor;
230+
extern float Player_flight_cursor_sensitivity;
230231

231232
enum class FlightMode {
232233
ShipLocked = 0,

code/playerman/playercontrol.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ physics_info Descent_physics; // used when we want to control the player like
6262
angles chase_slew_angles;
6363

6464
angles Player_flight_cursor;
65+
float Player_flight_cursor_sensitivity;
6566

6667
FlightMode Player_flight_mode = FlightMode::ShipLocked;
6768
bool Perspective_locked = false;
@@ -1079,8 +1080,8 @@ void read_player_controls(object *objp, float frametime)
10791080
if (sip->aims_at_flight_cursor)
10801081
max_aim_angle = sip->flight_cursor_aim_extent;
10811082

1082-
Player_flight_cursor.p += Player->ci.pitch * 0.015f;
1083-
Player_flight_cursor.h += Player->ci.heading * 0.015f;
1083+
Player_flight_cursor.p += Player->ci.pitch * 0.015f * Player_flight_cursor_sensitivity;
1084+
Player_flight_cursor.h += Player->ci.heading * 0.015f * Player_flight_cursor_sensitivity;
10841085

10851086
float mag = powf(powf(Player_flight_cursor.p, 2.0f) + powf(Player_flight_cursor.h, 2.0f), 0.5f);
10861087
if (mag > max_aim_angle) {
@@ -1446,6 +1447,7 @@ void player_level_init()
14461447
Viewer_external_info.current_distance = 0.0f;
14471448

14481449
Player_flight_cursor = vmd_zero_angles;
1450+
Player_flight_cursor_sensitivity = 1.0f;
14491451

14501452

14511453
if (Default_start_chase_view != The_mission.flags[Mission::Mission_Flags::Toggle_start_chase_view])

code/scripting/api/libs/controls.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,17 @@ ADE_FUNC(resetFlightCursor, l_Mouse, nullptr, "Resets flight cursor position to
403403
return ADE_RETURN_NIL;
404404
}
405405

406+
ADE_VIRTVAR(FlightCursorSensitivity, l_Mouse, "number", "Flight cursor movement sensitivity multiplier", "number", "Flight cursor sensitivity multiplier")
407+
{
408+
float val_sens;
409+
410+
if (ADE_SETTING_VAR && ade_get_args(L, "*f", &val_sens)) {
411+
Player_flight_cursor_sensitivity = val_sens;
412+
}
413+
414+
return ade_set_args(L, "f", Player_flight_cursor_sensitivity);
415+
}
416+
406417
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")
407418
{
408419
using namespace io::mouse;

0 commit comments

Comments
 (0)