naev 0.12.6
player.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include <time.h>
7
8#include "nstring.h"
9#include "pilot.h"
10
12enum {
13 PLAYER_TURN_LEFT,
14 PLAYER_TURN_RIGHT,
15 PLAYER_REVERSE,
16 PLAYER_ACCEL,
17 PLAYER_DESTROYED,
18 PLAYER_FACE,
19 PLAYER_LANDACK,
20 PLAYER_CREATING,
21 PLAYER_AUTONAV,
22 PLAYER_NOLAND,
23 PLAYER_CINEMATICS,
24 PLAYER_CINEMATICS_GUI,
26 PLAYER_CINEMATICS_2X,
28 PLAYER_HOOK_LAND,
30 PLAYER_HOOK_JUMPIN,
32 PLAYER_HOOK_HYPER,
34 PLAYER_MFLY,
35 PLAYER_NOSAVE,
36 PLAYER_FLAGS_MAX
37};
38
40enum {
41 PLAYER_LAND_OK,
42 PLAYER_LAND_AGAIN,
43 PLAYER_LAND_DENIED,
44};
45
46typedef char PlayerFlags[PLAYER_FLAGS_MAX];
47
48/* flag functions */
49#define player_isFlag( f ) ( player.flags[f] )
50#define player_setFlag( f ) ( player.flags[f] = 1 )
51#define player_rmFlag( f ) ( player.flags[f] = 0 )
52
53/* Control restoration reasons. */
54enum {
55 PINPUT_NULL,
56 PINPUT_MOVEMENT,
57 PINPUT_AUTONAV,
58 PINPUT_BRAKING
59};
60
64typedef struct PlayerOutfit_s {
65 const Outfit *o;
66 int q;
68
72typedef struct PlayerShip_s {
75 weapon_sets[PILOT_WEAPON_SETS];
78
79 /* Fleet data. */
81
82 /* Some meta-data. */
83 double time_played;
84 char *acquired;
85 ntime_t acquired_date;
90 unsigned int ships_destroyed[SHIP_CLASS_TOTAL];
92 unsigned int jumped_times;
93 unsigned int landed_times;
94 unsigned int death_counter;
96
100typedef struct Player_s {
101 /* Player intrinsics. */
104 char *name;
105
106 /* Player data. */
107 PlayerFlags flags;
109 double mousex;
110 double mousey;
111 double
114 char *chapter;
117
118 /* Loaded game version. */
120
121 /* Options that we save. */
122 char *gui;
123 double radar_res;
126
127 /* Player fleets. */
130
131 /* Meta-data. */
132 time_t last_played;
133 double time_played;
139 unsigned int ships_destroyed[SHIP_CLASS_TOTAL];
141 unsigned int jumped_times;
142 unsigned int landed_times;
143 unsigned int death_counter;
144
145 /* Meta-meta-data. */
147} Player_t;
148
149/*
150 * Local player.
151 */
152extern Player_t player;
153
154/*
155 * Common player sounds.
156 */
157extern int snd_target;
158extern int snd_jump;
159extern int snd_nav;
160extern int snd_hail;
161extern int snd_hypPowUp;
162extern int snd_hypEng;
163extern int snd_hypPowDown;
164extern int snd_hypPowUpJump;
165extern int snd_hypJump;
166
167/*
168 * creation/cleanup
169 */
170int player_init( void );
171void player_new( void );
172PlayerShip_t *player_newShip( const Ship *ship, const char *def_name, int trade,
173 const char *acquired, int noname );
174void player_cleanup( void );
175
176/*
177 * Hook voodoo.
178 */
179void player_runHooks( void );
180
181/*
182 * Rendering.
183 */
184void player_renderUnderlay( double dt );
185void player_render( double dt );
186
187/*
188 * Message stuff, in gui.c
189 */
190void player_messageToggle( int enable );
191NONNULL( 1 ) PRINTF_FORMAT( 1, 2 ) void player_message( const char *fmt, ... );
192NONNULL( 1 ) void player_messageRaw( const char *str );
193
194/*
195 * Misc.
196 */
197void player_resetSpeed( void );
198void player_restoreControl( int reason, const char *str );
199void player_checkLandAck( void );
200void player_nolandMsg( const char *str );
201void player_clear( void );
202void player_warp( double x, double y );
203int player_hasCredits( credits_t amount );
204credits_t player_modCredits( credits_t amount );
205void player_hailStart( void );
206/* Sounds. */
207void player_soundPlay( int sound, int once );
208void player_soundPlayGUI( int sound, int once );
209void player_soundStop( void );
210void player_soundPause( void );
211void player_soundResume( void );
212
213/*
214 * Player ships.
215 */
216int player_ships( char **sships, glTexture **tships );
217void player_shipsSort( void );
218const PlayerShip_t *player_getShipStack( void );
219int player_nships( void );
220int player_hasShip( const char *shipname );
221Pilot *player_getShip( const char *shipname );
222PlayerShip_t *player_getPlayerShip( const char *shipname );
223void player_swapShip( const char *shipname, int move_cargo );
224credits_t player_shipPrice( const char *shipname, int count_unique );
225void player_rmShip( const char *shipname );
226void player_rmPlayerShip( PlayerShip_t *ps );
227
228/*
229 * Player outfits.
230 */
231int player_outfitOwned( const Outfit *o );
232int player_outfitOwnedTotal( const Outfit *o );
233const PlayerOutfit_t *player_getOutfits( void );
234int player_getOutfitsFiltered( const Outfit ***outfits,
235 int ( *filter )( const Outfit *o ),
236 const char *name );
237int player_numOutfits( void );
238int player_addOutfit( const Outfit *o, int quantity );
239int player_rmOutfit( const Outfit *o, int quantity );
240
241/*
242 * Player missions.
243 */
244void player_missionFinished( int id );
245int player_missionAlreadyDone( int id );
247 void ); /* Returns array that should not be freed. */
248
249/*
250 * Player events.
251 */
252void player_eventFinished( int id );
253int player_eventAlreadyDone( int id );
255 void ); /* Returns array that should not be freed. */
256
257/*
258 * Licenses.
259 */
260NONNULL( 1 ) void player_addLicense( const char *license );
261int player_hasLicense( const char *license );
262const char **player_getLicenses( void );
263
264/*
265 * Escorts.
266 */
267int player_addEscorts( void );
268
269/*
270 * Pilot related stuff.
271 */
272void player_dead( void );
273void player_destroyed( void );
274void player_think( Pilot *pplayer, const double dt );
275void player_update( Pilot *pplayer, const double dt );
276void player_updateSpecific( Pilot *pplayer, const double dt );
277void player_brokeHyperspace( void );
278void player_hyperspacePreempt( int );
279int player_getHypPreempt( void );
280double player_dt_default( void );
281
282/*
283 * Targeting.
284 */
285/* Clearing. */
286void player_targetClear( void );
287void player_targetClearAll( void );
288/* Spobs. */
289void player_targetSpobSet( int id );
290void player_targetSpob( void );
291/* Asteroids. */
292void player_targetAsteroidSet( int id_field, int id );
293/* Hyperspace. */
294void player_targetHyperspaceSet( int id, int autonavcont );
295void player_targetHyperspace( void );
296/* Pilots. */
297void player_targetSet( unsigned int id );
298void player_targetHostile( void );
299void player_targetNext( int mode );
300void player_targetPrev( int mode );
301void player_targetNearest( void );
302void player_targetEscort( int prev );
303
304/*
305 * Keybind actions.
306 */
307void player_weapSetPress( int id, double value, int repeat );
308int player_land( int loud );
309void player_approach( void );
310int player_jump( void );
311void player_screenshot( void );
312void player_accel( double acc );
313void player_accelOver( void );
314void player_hail( void );
315void player_hailSpob( void );
316void player_autohail( void );
317void player_scan( void );
318void player_toggleMouseFly( void );
319void player_cooldownBrake( void );
320void player_stealth( void );
void player_messageRaw(const char *str)
Adds a mesg to the queue to be displayed on screen.
Definition gui.c:293
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
Definition gui.c:353
void player_messageToggle(int enable)
Toggles if player should receive messages.
Definition gui.c:283
void player_hailStart(void)
Starts the hail sounds and aborts autoNav.
Definition player.c:2011
void player_stealth(void)
Input binding for toggling stealth for the player.
Definition player.c:4824
void player_weapSetPress(int id, double value, int repeat)
Handles keyboard events involving the player's weapon-set keys. It's valid to call this while gamepla...
Definition player.c:1491
int player_eventAlreadyDone(int id)
Checks to see if player has already completed a event.
Definition player.c:3180
int player_nships(void)
Gets the amount of ships player has in storage.
Definition player.c:2814
int snd_jump
Definition player.c:104
int snd_nav
Definition player.c:105
void player_soundResume(void)
Resumes the ship's sounds.
Definition player.c:993
int player_rmOutfit(const Outfit *o, int quantity)
Remove an outfit from the player's outfit stack.
Definition player.c:3053
void player_runHooks(void)
Runs hooks for the player.
Definition player.c:3248
void player_updateSpecific(Pilot *pplayer, const double dt)
Does a player specific update.
Definition player.c:1395
int player_getOutfitsFiltered(const Outfit ***outfits, int(*filter)(const Outfit *o), const char *name)
Prepares two arrays for displaying in an image array.
Definition player.c:2953
int player_hasLicense(const char *license)
Checks to see if player has license.
Definition player.c:3207
void player_autohail(void)
Automatically tries to hail a pilot that hailed the player.
Definition player.c:2521
void player_dead(void)
Player got pwned.
Definition player.c:2684
void player_swapShip(const char *shipname, int move_cargo)
Swaps player's current ship with their ship named shipname.
Definition player.c:590
void player_cooldownBrake(void)
Starts braking or active cooldown.
Definition player.c:2623
void player_accel(double acc)
Start accelerating.
Definition player.c:2206
int player_ships(char **sships, glTexture **tships)
Returns a buffer with all the player's ships names.
Definition player.c:2787
void player_targetEscort(int prev)
Targets the pilot.
Definition player.c:2349
void player_targetAsteroidSet(int field, int id)
Sets the player's target asteroid.
Definition player.c:1596
int player_addOutfit(const Outfit *o, int quantity)
Adds an outfit to the player outfit stack.
Definition player.c:2988
void player_soundPlay(int sound, int once)
Plays a sound at the player.
Definition player.c:958
void player_new(void)
Creates a new player.
Definition player.c:256
int snd_hypJump
Definition player.c:112
void player_warp(double x, double y)
Warps the player to the new position.
Definition player.c:1007
int snd_hypEng
Definition player.c:109
void player_checkLandAck(void)
Revokes landing authorization if the player's reputation is too low.
Definition player.c:1791
int player_numOutfits(void)
Gets the amount of different outfits in the player outfit stack.
Definition player.c:2976
void player_targetSet(unsigned int id)
Sets the player's target.
Definition player.c:2230
void player_render(double dt)
Renders the player.
Definition player.c:1055
void player_hailSpob(void)
Opens communication with the player's spob target.
Definition player.c:2503
credits_t player_shipPrice(const char *shipname, int count_unique)
Calculates the price of one of the player's ships.
Definition player.c:733
void player_resetSpeed(void)
Resets the player speed stuff.
Definition player.c:1521
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
Definition player.c:2804
void player_targetHyperspaceSet(int id, int nomsg)
Sets the player's hyperspace target.
Definition player.c:1905
int snd_hail
Definition player.c:106
void player_cleanup(void)
Cleans up player stuff like player_stack.
Definition player.c:800
void player_targetHyperspace(void)
Gets a hyperspace target.
Definition player.c:1940
int snd_hypPowDown
Definition player.c:110
PlayerShip_t * player_newShip(const Ship *ship, const char *def_name, int trade, const char *acquired, int noname)
Creates a new ship for player.
Definition player.c:470
void player_rmShip(const char *shipname)
Removes one of the player's ships.
Definition player.c:775
int player_outfitOwnedTotal(const Outfit *o)
Definition player.c:2912
void player_hyperspacePreempt(int preempt)
Enables or disables jump points preempting spobs in autoface and target clearing.
Definition player.c:1980
PlayerShip_t * player_getPlayerShip(const char *shipname)
Gets a specific ship.
Definition player.c:2863
void player_toggleMouseFly(void)
Toggles mouse flying.
Definition player.c:2601
void player_targetNearest(void)
Player targets nearest pilot.
Definition player.c:2393
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
Definition player.c:2001
void player_update(Pilot *pplayer, const double dt)
Player update function.
Definition player.c:1379
const char ** player_getLicenses()
Gets the array (array.h) of license names in the player's inventory.
Definition player.c:3240
void player_brokeHyperspace(void)
Player actually broke hyperspace (entering new system).
Definition player.c:2102
int player_getHypPreempt(void)
Returns whether the jump point target should preempt the spob target.
Definition player.c:1990
int player_missionAlreadyDone(int id)
Checks to see if player has already completed a mission.
Definition player.c:3125
void player_renderUnderlay(double dt)
Renders the player underlay.
Definition player.c:1099
int player_addEscorts(void)
Adds the player's escorts.
Definition player.c:3288
void player_soundStop(void)
Stops playing player sounds.
Definition player.c:966
void player_restoreControl(int reason, const char *str)
Aborts autonav and other states that take control of the ship.
Definition player.c:1535
void player_addLicense(const char *license)
Gives the player a license.
Definition player.c:3225
credits_t player_modCredits(credits_t amount)
Modifies the amount of credits the player has.
Definition player.c:1047
int * player_eventsDoneList(void)
Gets a list of all the events the player has done.
Definition player.c:3196
int snd_hypPowUpJump
Definition player.c:111
int player_jump(void)
Actually attempts to jump in hyperspace.
Definition player.c:2029
void player_targetSpobSet(int id)
Sets the player's target spob.
Definition player.c:1559
void player_clear(void)
Clears the targets.
Definition player.c:1019
int snd_hypPowUp
Definition player.c:108
int player_hasShip(const char *shipname)
Sees if player has a ship of a name.
Definition player.c:2825
void player_accelOver(void)
Done accelerating.
Definition player.c:2220
void player_think(Pilot *pplayer, const double dt)
Basically uses keyboard input instead of AI input. Used in pilot.c.
Definition player.c:1252
int snd_target
Definition player.c:103
int player_land(int loud)
Try to land or target closest spob if no land target.
Definition player.c:1653
void player_soundPause(void)
Pauses the ship's sounds.
Definition player.c:982
Player_t player
Definition player.c:77
int player_hasCredits(credits_t amount)
Checks to see if the player has enough credits.
Definition player.c:1036
void player_shipsSort(void)
Sorts the players ships.
Definition player.c:2769
void player_missionFinished(int id)
Marks a mission as completed.
Definition player.c:3094
int player_outfitOwned(const Outfit *o)
Gets how many of the outfit the player owns.
Definition player.c:2882
void player_targetClearAll(void)
Clears all player targets: hyperspace, spob, asteroid, etc...
Definition player.c:2336
void player_nolandMsg(const char *str)
Sets the no land message.
Definition player.c:1822
void player_targetPrev(int mode)
Cycles to previous target.
Definition player.c:2307
const PlayerOutfit_t * player_getOutfits(void)
Gets an array (array.h) of the player's outfits.
Definition player.c:2940
void player_soundPlayGUI(int sound, int once)
Plays a GUI sound (unaffected by time accel).
Definition player.c:947
void player_targetClear(void)
Clears the player's ship, spob or hyperspace target, in that order.
Definition player.c:2315
void player_targetHostile(void)
Targets the nearest hostile enemy to the player.
Definition player.c:2258
void player_eventFinished(int id)
Marks a event as completed.
Definition player.c:3151
void player_screenshot(void)
Takes a screenshot.
Definition player.c:2415
void player_approach(void)
Logic to make the player approach a target pilot to board or spob to land on.
Definition player.c:1839
void player_destroyed(void)
Player blew up in a fireball.
Definition player.c:2698
void player_targetSpob(void)
Cycle through spob targets.
Definition player.c:1620
int player_init(void)
Initializes player stuff.
Definition player.c:199
int * player_missionsDoneList(void)
Gets a list of all the missions the player has done.
Definition player.c:3141
Pilot * player_getShip(const char *shipname)
Gets a specific ship.
Definition player.c:2844
void player_targetNext(int mode)
Cycles to next target.
Definition player.c:2297
void player_hail(void)
Opens communication with the player's target.
Definition player.c:2476
A ship outfit, depends radically on the type.
Definition outfit.h:372
A weapon set represents a set of weapons that have an action.
Definition pilot.h:207
The representation of an in-game pilot.
Definition pilot.h:263
Wrapper for outfits.
Definition player.h:64
const Outfit * o
Definition player.h:65
Player ship.
Definition player.h:72
double time_played
Definition player.h:83
double dmg_done_armour
Definition player.h:87
unsigned int death_counter
Definition player.h:94
double dmg_taken_armour
Definition player.h:89
ntime_t acquired_date
Definition player.h:85
int deployed
Definition player.h:80
double dmg_taken_shield
Definition player.h:88
unsigned int landed_times
Definition player.h:93
Pilot * p
Definition player.h:73
int autoweap
Definition player.h:76
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
Definition player.h:90
char * acquired
Definition player.h:84
unsigned int jumped_times
Definition player.h:92
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
Definition player.h:75
double dmg_done_shield
Definition player.h:86
int favourite
Definition player.h:77
Pilot * p
Definition player.h:102
double radar_res
Definition player.h:123
double dmg_done_shield
Definition player.h:135
double mousex
Definition player.h:109
int autonav
Definition player.h:108
unsigned int jumped_times
Definition player.h:141
PlayerShip_t ps
Definition player.h:103
char * name
Definition player.h:104
char * loaded_version
Definition player.h:119
double dmg_done_armour
Definition player.h:136
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
Definition player.h:139
int fleet_used
Definition player.h:128
time_t last_played
Definition player.h:132
double dmg_taken_armour
Definition player.h:138
char * gui
Definition player.h:122
double speed_autonav
Definition player.h:113
time_t time_since_save
Definition player.h:146
int map_minimal
Definition player.h:125
double time_played
Definition player.h:133
char * chapter
Definition player.h:114
time_t date_created
Definition player.h:134
int fleet_capacity
Definition player.h:129
double dmg_taken_shield
Definition player.h:137
double speed
Definition player.h:112
char * difficulty
Definition player.h:115
double mousey
Definition player.h:110
unsigned int death_counter
Definition player.h:143
PlayerFlags flags
Definition player.h:107
int discover_off
Definition player.h:116
unsigned int landed_times
Definition player.h:142
int eq_outfitMode
Definition player.h:124
Represents a space ship.
Definition ship.h:97
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43