FS2_Open
Open source remastering of the Freespace 2 engine
playercontrol.cpp File Reference
#include "autopilot/autopilot.h"
#include "camera/camera.h"
#include "debugconsole/console.h"
#include "external_dll/trackirpublic.h"
#include "freespace2/freespace.h"
#include "gamesequence/gamesequence.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/linklist.h"
#include "hud/hud.h"
#include "hud/hudmessage.h"
#include "hud/hudsquadmsg.h"
#include "hud/hudtargetbox.h"
#include "io/joy.h"
#include "io/joy_ff.h"
#include "io/mouse.h"
#include "io/timer.h"
#include "mission/missiongoals.h"
#include "mission/missionmessage.h"
#include "network/multi_obj.h"
#include "network/multiutil.h"
#include "object/object.h"
#include "object/objectdock.h"
#include "observer/observer.h"
#include "parse/parselo.h"
#include "playerman/player.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#include "weapon/weapon.h"
#include "io/key.h"

Go to the source code of this file.

Macros

#define MIN_DIST_TO_DEAD_CAMERA   50.0f
 

Functions

void playercontrol_read_stick (int *axis, float frame_time)
 Reads and combines the axes from the player's joystick and mouse. More...
 
void player_set_padlock_state ()
 
void chase_angles_to_value (angles *ap, angles *bp, int scale)
 Slew angles chase towards a value like they're on a spring. More...
 
void view_modify (angles *ma, angles *da, float max_p, float max_h, float frame_time)
 
void do_view_track_target (float frame_time)
 
void do_view_slew (float frame_time)
 
void do_view_chase (float frame_time)
 
 DCF (camera_speed,"Sets the camera zoom scale")
 
void do_view_external (float frame_time)
 
void do_thrust_keys (control_info *ci)
 
void player_control_reset_ci (control_info *ci)
 
void read_keyboard_controls (control_info *ci, float frame_time, physics_info *pi)
 
void copy_control_info (control_info *dest_ci, control_info *src_ci)
 
void read_player_controls (object *objp, float frametime)
 
void player_controls_init ()
 
void player_clear_speed_matching ()
 
void player_match_target_speed (char *no_target_text, char *match_off_text, char *match_on_text)
 
void toggle_player_object ()
 
void player_init_all_alone_msg ()
 
void player_set_pilot_defaults (player *p)
 
void player_save_target_and_weapon_link_prefs ()
 
void player_restore_target_and_weapon_link_prefs ()
 
void player_level_init ()
 
void player_init ()
 
void player_stop_looped_sounds ()
 
void player_maybe_start_repair_sound ()
 
void player_stop_repair_sound ()
 
void player_maybe_start_cargo_scan_sound ()
 
void player_stop_cargo_scan_sound ()
 
int player_process_pending_praise ()
 See if there is a praise message to deliver to the player. We want to delay the praise messages a bit, to make them more realistic. More...
 
int player_inspect_cap_subsys_cargo (float frametime, char *outstr)
 
int player_inspect_cargo (float frametime, char *outstr)
 
float player_farthest_weapon_range ()
 
void player_generate_killer_weapon_name (int weapon_info_index, int killer_species, char *weapon_name)
 
void player_generate_death_message (player *player_p)
 
void player_show_death_message ()
 
void player_set_next_all_alone_msg_timestamp ()
 
void player_maybe_play_all_alone_msg ()
 
void player_get_padlock_orient (matrix *eye_orient)
 
void player_display_padlock_view ()
 
camid player_get_cam ()
 

Variables

player Players [MAX_PLAYERS]
 
int Player_num
 
playerPlayer = NULL
 
int Player_use_ai = 0
 
int lua_game_control = 0
 
physics_info Descent_physics
 
angles chase_slew_angles
 
int view_centering = 0
 
int toggle_glide = 0
 
int press_glide = 0
 
int Show_killer_weapon = 0
 
angles Viewer_slew_angles_delta
 
angles Viewer_external_angles_delta
 
float camera_zoom_scale = 1.0f
 
int use_descent = 0
 
LOCAL physics_info phys_save
 
vec3d Dead_camera_pos
 
vec3d Dead_player_last_vel
 

Macro Definition Documentation

#define MIN_DIST_TO_DEAD_CAMERA   50.0f

Definition at line 1972 of file playercontrol.cpp.

Function Documentation

void chase_angles_to_value ( angles ap,
angles bp,
int  scale 
)

Slew angles chase towards a value like they're on a spring.

When furthest away, move fastest. Minimum speed set so that doesn't take too long. When gets close, clamps to the value.

Definition at line 88 of file playercontrol.cpp.

void copy_control_info ( control_info dest_ci,
control_info src_ci 
)

Definition at line 820 of file playercontrol.cpp.

DCF ( camera_speed  ,
"Sets the camera zoom scale  
)

Definition at line 294 of file playercontrol.cpp.

void do_thrust_keys ( control_info ci)

Separate out the reading of thrust keys, so we can call this from external view as well as from normal view

Definition at line 341 of file playercontrol.cpp.

void do_view_chase ( float  frame_time)

Definition at line 277 of file playercontrol.cpp.

void do_view_external ( float  frame_time)

Definition at line 306 of file playercontrol.cpp.

void do_view_slew ( float  frame_time)

When PAD0 is pressed, keypad controls viewer direction slewing.

Definition at line 272 of file playercontrol.cpp.

void do_view_track_target ( float  frame_time)

Definition at line 204 of file playercontrol.cpp.

void player_clear_speed_matching ( )

Clear current speed matching and auto-speed matching flags

Definition at line 998 of file playercontrol.cpp.

void player_control_reset_ci ( control_info ci)

Called by single and multiplayer modes to reset information inside of control info structure

Definition at line 351 of file playercontrol.cpp.

void player_controls_init ( )

Definition at line 979 of file playercontrol.cpp.

void player_display_padlock_view ( )

Definition at line 1933 of file playercontrol.cpp.

float player_farthest_weapon_range ( )

Get the maximum weapon range for the player (of both primary and secondary)

Returns
Maximum weapon range

Definition at line 1634 of file playercontrol.cpp.

void player_generate_death_message ( player player_p)

Generates the message for death of a player given the information stored in the player object.

Definition at line 1675 of file playercontrol.cpp.

void player_generate_killer_weapon_name ( int  weapon_info_index,
int  killer_species,
char *  weapon_name 
)

Determine text name for the weapon that killed the player.

Parameters
weapon_info_indexWeapon type that killed the player (can be -1 if no weapon involved)
killer_speciesSpecies of ship that fired weapon
weapon_name(Output parameter) Stores weapon name generated in this function

Definition at line 1651 of file playercontrol.cpp.

camid player_get_cam ( )

Get the player's eye position and orient

Definition at line 1976 of file playercontrol.cpp.

void player_get_padlock_orient ( matrix eye_orient)

Definition at line 1909 of file playercontrol.cpp.

void player_init ( )

Initializes global variables once a game – needed because of mallocing that goes on in structures in the player file

Definition at line 1286 of file playercontrol.cpp.

void player_init_all_alone_msg ( )

Initialise the data required for determining whether 'all alone' message should play

Definition at line 1100 of file playercontrol.cpp.

int player_inspect_cap_subsys_cargo ( float  frametime,
char *  outstr 
)
Returns
1 if player should display outstr on HUD; 0 if don't display cargo on HUD

Definition at line 1517 of file playercontrol.cpp.

int player_inspect_cargo ( float  frametime,
char *  outstr 
)

See if the player should be inspecting cargo, and update progress.

Parameters
frametimeTime since last frame in seconds
outstr(output parm) holds string that HUD should display
Returns
1 if player should display outstr on HUD; 0if don't display cargo on HUD

Definition at line 1410 of file playercontrol.cpp.

void player_level_init ( )

Initialise player statistics on a per mission basis

Todo:
Don't use memset(0) approach to setting up Player->ci

Definition at line 1201 of file playercontrol.cpp.

void player_match_target_speed ( char *  no_target_text,
char *  match_off_text,
char *  match_on_text 
)

Computes the forward_thrust_time needed for the player ship to match velocities with the currently selected target

Parameters
no_target_textDefault parm (NULL), used to override HUD output when no target exists
match_off_textDefault parm (NULL), used to overide HUD output when matching toggled off
match_on_textDefault parm (NULL), used to overide HUD output when matching toggled on

Definition at line 1016 of file playercontrol.cpp.

void player_maybe_play_all_alone_msg ( )

Maybe play message from Terran Command 'You're all alone now, pilot'

Definition at line 1810 of file playercontrol.cpp.

void player_maybe_start_cargo_scan_sound ( )

Start the cargo scanning sound if it hasn't already been started

Definition at line 1338 of file playercontrol.cpp.

void player_maybe_start_repair_sound ( )

Start the repair sound if it hasn't already been started. Called when a player ship is being repaired by a support ship

Definition at line 1315 of file playercontrol.cpp.

int player_process_pending_praise ( )

See if there is a praise message to deliver to the player. We want to delay the praise messages a bit, to make them more realistic.

Returns
1 if a praise message was delivered to the player, or a praise is pending; 0 if no praise is pending

Definition at line 1364 of file playercontrol.cpp.

void player_restore_target_and_weapon_link_prefs ( )

Store some player preferences to Player->save_flags

Definition at line 1175 of file playercontrol.cpp.

void player_save_target_and_weapon_link_prefs ( )

Store some player preferences to Player->save_flags

Definition at line 1141 of file playercontrol.cpp.

void player_set_next_all_alone_msg_timestamp ( )

Definition at line 1802 of file playercontrol.cpp.

void player_set_padlock_state ( )

Definition at line 1871 of file playercontrol.cpp.

void player_set_pilot_defaults ( player p)

Called when a new pilot is created

Definition at line 1129 of file playercontrol.cpp.

void player_show_death_message ( )

Display what/who killed the player

Definition at line 1765 of file playercontrol.cpp.

void player_stop_cargo_scan_sound ( )

Stop the player repair sound if it is already playing

Definition at line 1349 of file playercontrol.cpp.

void player_stop_looped_sounds ( )

Stop any looping sounds associated with the Player, called from game_stop_looped_sounds().

Definition at line 1298 of file playercontrol.cpp.

void player_stop_repair_sound ( )

Stop the player repair sound if it is already playing

Definition at line 1326 of file playercontrol.cpp.

void playercontrol_read_stick ( int axis,
float  frame_time 
)

Reads and combines the axes from the player's joystick and mouse.

Parameters
[out]axisPointer to axes array
[in]frame_timeThe frame time when this was called

Definition at line 364 of file playercontrol.cpp.

void read_keyboard_controls ( control_info ci,
float  frame_time,
physics_info pi 
)

Definition at line 420 of file playercontrol.cpp.

void read_player_controls ( object objp,
float  frametime 
)

Definition at line 847 of file playercontrol.cpp.

void toggle_player_object ( )

Definition at line 1084 of file playercontrol.cpp.

void view_modify ( angles ma,
angles da,
float  max_p,
float  max_h,
float  frame_time 
)

Definition at line 117 of file playercontrol.cpp.

Variable Documentation

float camera_zoom_scale = 1.0f

Definition at line 292 of file playercontrol.cpp.

angles chase_slew_angles

Definition at line 60 of file playercontrol.cpp.

vec3d Dead_camera_pos

Definition at line 67 of file shiphit.cpp.

vec3d Dead_player_last_vel

Definition at line 178 of file fredstubs.cpp.

physics_info Descent_physics

Definition at line 58 of file playercontrol.cpp.

int lua_game_control = 0

Definition at line 56 of file playercontrol.cpp.

LOCAL physics_info phys_save

Definition at line 1082 of file playercontrol.cpp.

player* Player = NULL

Definition at line 51 of file playercontrol.cpp.

int Player_num

Definition at line 50 of file playercontrol.cpp.

int Player_use_ai = 0

Definition at line 54 of file playercontrol.cpp.

player Players[MAX_PLAYERS]

Definition at line 48 of file playercontrol.cpp.

int press_glide = 0

Definition at line 64 of file playercontrol.cpp.

int Show_killer_weapon = 0

Definition at line 72 of file playercontrol.cpp.

int toggle_glide = 0

Definition at line 63 of file playercontrol.cpp.

int use_descent = 0

Definition at line 1081 of file playercontrol.cpp.

int view_centering = 0

Definition at line 61 of file playercontrol.cpp.

angles Viewer_external_angles_delta

Definition at line 115 of file playercontrol.cpp.

angles Viewer_slew_angles_delta

Definition at line 114 of file playercontrol.cpp.