Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/playerman/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions code/playerman/playercontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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])
Expand Down
11 changes: 11 additions & 0 deletions code/scripting/api/libs/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading