naev 0.10.4
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_PRIMARY,
20 PLAYER_PRIMARY_L,
21 PLAYER_SECONDARY,
22 PLAYER_SECONDARY_L,
23 PLAYER_LANDACK,
24 PLAYER_CREATING,
25 PLAYER_AUTONAV,
26 PLAYER_NOLAND,
27 PLAYER_CINEMATICS,
28 PLAYER_CINEMATICS_GUI,
29 PLAYER_CINEMATICS_2X,
30 PLAYER_HOOK_LAND,
31 PLAYER_HOOK_JUMPIN,
32 PLAYER_HOOK_HYPER,
33 PLAYER_MFLY,
34 PLAYER_NOSAVE,
35 PLAYER_FLAGS_MAX
36};
37
39enum {
40 PLAYER_LAND_OK,
41 PLAYER_LAND_AGAIN,
42 PLAYER_LAND_DENIED,
43};
44
45typedef char PlayerFlags[ PLAYER_FLAGS_MAX ];
46
47/* flag functions */
48#define player_isFlag(f) (player.flags[f])
49#define player_setFlag(f) (player.flags[f] = 1)
50#define player_rmFlag(f) (player.flags[f] = 0)
51
52/* Control restoration reasons. */
53enum {
54 PINPUT_NULL,
55 PINPUT_MOVEMENT,
56 PINPUT_AUTONAV,
57 PINPUT_BRAKING
58};
59
60#include "player_autonav.h"
61
65typedef struct PlayerOutfit_s {
66 const Outfit *o;
67 int q;
69
73typedef struct PlayerShip_s {
75 PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS];
79 /* Fleet data. */
82 /* Some meta-data. */
83 double time_played;
84 char *acquired;
90 unsigned int ships_destroyed[SHIP_CLASS_TOTAL];
91 unsigned int jumped_times;
92 unsigned int landed_times;
93 unsigned int death_counter;
95
99typedef struct Player_s {
100 /* Player intrinsics. */
103 char *name;
105 /* Player data. */
106 PlayerFlags flags;
111 double tc_max;
113 double mousex;
114 double mousey;
115 double speed;
116 char *chapter;
120 /* Loaded game version. */
123 /* Options that we save. */
124 char *gui;
125 double radar_res;
129 /* Player fleets. */
133 /* Meta-data. */
134 time_t last_played;
135 double time_played;
141 unsigned int ships_destroyed[SHIP_CLASS_TOTAL];
142 unsigned int jumped_times;
143 unsigned int landed_times;
144 unsigned int death_counter;
146 /* Meta-meta-data. */
148} Player_t;
149
150/*
151 * Local player.
152 */
153extern Player_t player;
155/*
156 * Common player sounds.
157 */
158extern int snd_target;
159extern int snd_jump;
160extern int snd_nav;
161extern int snd_hail;
162extern int snd_hypPowUp;
163extern int snd_hypEng;
164extern int snd_hypPowDown;
165extern int snd_hypPowUpJump;
166extern int snd_hypJump;
168/*
169 * creation/cleanup
170 */
171int player_init (void);
172void player_new (void);
173PlayerShip_t* player_newShip( const Ship* ship, const char *def_name,
174 int trade, const char *acquired, int noname );
175void player_cleanup (void);
176
177/*
178 * Hook voodoo.
179 */
180void player_runHooks (void);
181
182/*
183 * Rendering.
184 */
185void player_renderUnderlay( double dt );
186void player_render( double dt );
187
188/*
189 * Message stuff, in gui.c
190 */
191void player_messageToggle( int enable );
192NONNULL( 1 ) PRINTF_FORMAT( 1, 2 ) void player_message( const char *fmt, ... );
193NONNULL( 1 ) void player_messageRaw ( const char *str );
194
195/*
196 * Misc.
197 */
198void player_resetSpeed (void);
199void player_restoreControl( int reason, const char *str );
200void player_checkLandAck (void);
201void player_nolandMsg( const char *str );
202void player_clear (void);
203void player_warp( double x, double y );
204int player_hasCredits( credits_t amount );
205credits_t player_modCredits( credits_t amount );
206void player_hailStart (void);
207/* Sounds. */
208void player_soundPlay( int sound, int once );
209void player_soundPlayGUI( int sound, int once );
210void player_soundStop (void);
211void player_soundPause (void);
212void player_soundResume (void);
213
214/*
215 * Player ships.
216 */
217int player_ships( char** sships, glTexture** tships );
218void player_shipsSort (void);
220int player_nships (void);
221int player_hasShip( const char *shipname );
222Pilot *player_getShip( const char *shipname );
223PlayerShip_t* player_getPlayerShip( const char *shipname );
224void player_swapShip( const char *shipname, int move_cargo );
225credits_t player_shipPrice( const char *shipname );
226void player_rmShip( const char *shipname );
227
228/*
229 * Player outfits.
230 */
231int player_outfitOwned( const Outfit *o );
232int player_outfitOwnedTotal( const Outfit* o );
234int player_getOutfitsFiltered( const Outfit **outfits,
235 int(*filter)( const Outfit *o ), const char *name );
236int player_numOutfits (void);
237int player_addOutfit( const Outfit *o, int quantity );
238int player_rmOutfit( const Outfit *o, int quantity );
239
240/*
241 * Player missions.
242 */
243void player_missionFinished( int id );
244int player_missionAlreadyDone( int id );
245int* player_missionsDoneList (void); /* Returns array that should not be freed. */
246
247/*
248 * Player events.
249 */
250void player_eventFinished( int id );
251int player_eventAlreadyDone( int id );
252int* player_eventsDoneList (void); /* Returns array that should not be freed. */
253
254/*
255 * Licenses.
256 */
257NONNULL( 1 ) void player_addLicense( const char *license );
258int player_hasLicense( const char *license );
259const char **player_getLicenses (void);
260
261/*
262 * Escorts.
263 */
264int player_addEscorts (void);
265
266/*
267 * Pilot related stuff.
268 */
269void player_dead (void);
270void player_destroyed (void);
271void player_think( Pilot* pplayer, const double dt );
272void player_update( Pilot *pplayer, const double dt );
273void player_updateSpecific( Pilot *pplayer, const double dt );
274void player_brokeHyperspace (void);
275void player_hyperspacePreempt( int );
276int player_getHypPreempt(void);
277double player_dt_default (void);
278
279/*
280 * Targeting.
281 */
282/* Clearing. */
283void player_targetClear (void);
284void player_targetClearAll (void);
285/* Spobs. */
286void player_targetSpobSet( int id );
287void player_targetSpob (void);
288/* Asteroids. */
289void player_targetAsteroidSet( int id_field, int id );
290/* Hyperspace. */
291void player_targetHyperspaceSet( int id, int autonavcont );
292void player_targetHyperspace (void);
293/* Pilots. */
294void player_targetSet( unsigned int id );
295void player_targetHostile (void);
296void player_targetNext( int mode );
297void player_targetPrev( int mode );
298void player_targetNearest (void);
299void player_targetEscort( int prev );
300
301/*
302 * Keybind actions.
303 */
304void player_weapSetPress( int id, double value, int repeat );
305int player_land( int loud );
306void player_board (void);
307int player_jump (void);
308void player_screenshot (void);
309void player_accel( double acc );
310void player_accelOver (void);
311void player_hail (void);
312void player_hailSpob (void);
313void player_autohail (void);
314void player_toggleMouseFly (void);
315void player_brake (void);
316void 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:330
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:1881
void player_stealth(void)
Input binding for toggling stealth for the player.
Definition: player.c:4565
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:1392
int player_eventAlreadyDone(int id)
Checks to see if player has already completed a event.
Definition: player.c:2971
int player_nships(void)
Gets the amount of ships player has in storage.
Definition: player.c:2633
int snd_jump
Definition: player.c:97
int snd_nav
Definition: player.c:98
void player_soundResume(void)
Resumes the ship's sounds.
Definition: player.c:893
int player_rmOutfit(const Outfit *o, int quantity)
Remove an outfit from the player's outfit stack.
Definition: player.c:2859
void player_runHooks(void)
Runs hooks for the player.
Definition: player.c:3034
void player_updateSpecific(Pilot *pplayer, const double dt)
Does a player specific update.
Definition: player.c:1304
int player_hasLicense(const char *license)
Checks to see if player has license.
Definition: player.c:2996
void player_autohail(void)
Automatically tries to hail a pilot that hailed the player.
Definition: player.c:2405
void player_dead(void)
Player got pwned.
Definition: player.c:2515
void player_swapShip(const char *shipname, int move_cargo)
Swaps player's current ship with their ship named shipname.
Definition: player.c:501
void player_accel(double acc)
Start accelerating.
Definition: player.c:2088
int player_ships(char **sships, glTexture **tships)
Returns a buffer with all the player's ships names.
Definition: player.c:2606
void player_targetEscort(int prev)
Targets the pilot.
Definition: player.c:2232
void player_targetAsteroidSet(int field, int id)
Sets the player's target asteroid.
Definition: player.c:1492
int player_addOutfit(const Outfit *o, int quantity)
Adds an outfit to the player outfit stack.
Definition: player.c:2803
void player_soundPlay(int sound, int once)
Plays a sound at the player.
Definition: player.c:858
void player_new(void)
Creates a new player.
Definition: player.c:238
int snd_hypJump
Definition: player.c:105
void player_warp(double x, double y)
Warps the player to the new position.
Definition: player.c:907
int snd_hypEng
Definition: player.c:102
credits_t player_shipPrice(const char *shipname)
Calculates the price of one of the player's ships.
Definition: player.c:639
void player_checkLandAck(void)
Revokes landing authorization if the player's reputation is too low.
Definition: player.c:1703
int player_numOutfits(void)
Gets the amount of different outfits in the player outfit stack.
Definition: player.c:2791
void player_targetSet(unsigned int id)
Sets the player's target.
Definition: player.c:2112
void player_render(double dt)
Renders the player.
Definition: player.c:955
void player_hailSpob(void)
Opens communication with the player's spob target.
Definition: player.c:2386
void player_resetSpeed(void)
Resets the player speed stuff.
Definition: player.c:1416
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
Definition: player.c:2623
void player_targetHyperspaceSet(int id, int nomsg)
Sets the player's hyperspace target.
Definition: player.c:1778
int snd_hail
Definition: player.c:99
void player_cleanup(void)
Cleans up player stuff like player_stack.
Definition: player.c:697
void player_targetHyperspace(void)
Gets a hyperspace target.
Definition: player.c:1813
int snd_hypPowDown
Definition: player.c:103
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:382
void player_rmShip(const char *shipname)
Removes one of the player's ships.
Definition: player.c:669
int player_outfitOwnedTotal(const Outfit *o)
Definition: player.c:2729
void player_hyperspacePreempt(int preempt)
Enables or disables jump points preempting spobs in autoface and target clearing.
Definition: player.c:1851
PlayerShip_t * player_getPlayerShip(const char *shipname)
Gets a specific ship.
Definition: player.c:2682
void player_toggleMouseFly(void)
Toggles mouse flying.
Definition: player.c:2438
void player_targetNearest(void)
Player targets nearest pilot.
Definition: player.c:2275
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
Definition: player.c:1871
void player_update(Pilot *pplayer, const double dt)
Player update function.
Definition: player.c:1288
const char ** player_getLicenses()
Gets the array (array.h) of license names in the player's inventory.
Definition: player.c:3026
void player_brokeHyperspace(void)
Player actually broke hyperspace (entering new system).
Definition: player.c:1976
int player_getHypPreempt(void)
Returns whether the jump point target should preempt the spob target.
Definition: player.c:1861
int player_missionAlreadyDone(int id)
Checks to see if player has already completed a mission.
Definition: player.c:2927
void player_renderUnderlay(double dt)
Renders the player underlay.
Definition: player.c:993
int player_addEscorts(void)
Adds the player's escorts.
Definition: player.c:3074
void player_soundStop(void)
Stops playing player sounds.
Definition: player.c:866
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:2770
void player_restoreControl(int reason, const char *str)
Aborts autonav and other states that take control of the ship.
Definition: player.c:1429
void player_addLicense(const char *license)
Gives the player a license.
Definition: player.c:3012
credits_t player_modCredits(credits_t amount)
Modifies the amount of credits the player has.
Definition: player.c:947
int * player_eventsDoneList(void)
Gets a list of all the events the player has done.
Definition: player.c:2985
int snd_hypPowUpJump
Definition: player.c:104
int player_jump(void)
Actually attempts to jump in hyperspace.
Definition: player.c:1900
void player_targetSpobSet(int id)
Sets the player's target spob.
Definition: player.c:1453
void player_clear(void)
Clears the targets.
Definition: player.c:919
int snd_hypPowUp
Definition: player.c:101
int player_hasShip(const char *shipname)
Sees if player has a ship of a name.
Definition: player.c:2644
void player_accelOver(void)
Done accelerating.
Definition: player.c:2102
void player_think(Pilot *pplayer, const double dt)
Basically uses keyboard input instead of AI input. Used in pilot.c.
Definition: player.c:1142
int snd_target
Definition: player.c:96
int player_land(int loud)
Try to land or target closest spob if no land target.
Definition: player.c:1549
void player_soundPause(void)
Pauses the ship's sounds.
Definition: player.c:882
Player_t player
Definition: player.c:73
int player_hasCredits(credits_t amount)
Checks to see if the player has enough credits.
Definition: player.c:936
void player_shipsSort(void)
Sorts the players ships.
Definition: player.c:2589
void player_brake(void)
Starts braking or active cooldown.
Definition: player.c:2461
void player_missionFinished(int id)
Marks a mission as completed.
Definition: player.c:2896
int player_outfitOwned(const Outfit *o)
Gets how many of the outfit the player owns.
Definition: player.c:2701
void player_targetClearAll(void)
Clears all player targets: hyperspace, spob, asteroid, etc...
Definition: player.c:2219
void player_nolandMsg(const char *str)
Sets the no land message.
Definition: player.c:1733
void player_targetPrev(int mode)
Cycles to previous target.
Definition: player.c:2190
const PlayerOutfit_t * player_getOutfits(void)
Gets an array (array.h) of the player's outfits.
Definition: player.c:2757
void player_soundPlayGUI(int sound, int once)
Plays a GUI sound (unaffected by time accel).
Definition: player.c:847
void player_targetClear(void)
Clears the player's ship, spob or hyperspace target, in that order.
Definition: player.c:2198
void player_targetHostile(void)
Targets the nearest hostile enemy to the player.
Definition: player.c:2141
void player_eventFinished(int id)
Marks a event as completed.
Definition: player.c:2951
void player_screenshot(void)
Takes a screenshot.
Definition: player.c:2299
void player_destroyed(void)
Player blew up in a fireball.
Definition: player.c:2528
void player_targetSpob(void)
Cycle through spob targets.
Definition: player.c:1516
int player_init(void)
Initializes player stuff.
Definition: player.c:184
int * player_missionsDoneList(void)
Gets a list of all the missions the player has done.
Definition: player.c:2941
Pilot * player_getShip(const char *shipname)
Gets a specific ship.
Definition: player.c:2663
void player_targetNext(int mode)
Cycles to next target.
Definition: player.c:2180
void player_hail(void)
Opens communication with the player's target.
Definition: player.c:2358
A ship outfit, depends radically on the type.
Definition: outfit.h:304
A weapon set represents a set of weapons that have an action.
Definition: pilot.h:158
The representation of an in-game pilot.
Definition: pilot.h:210
Wrapper for outfits.
Definition: player.h:65
const Outfit * o
Definition: player.h:66
Player ship.
Definition: player.h:73
time_t acquired_date
Definition: player.h:85
double time_played
Definition: player.h:83
double dmg_done_armour
Definition: player.h:87
unsigned int death_counter
Definition: player.h:93
double dmg_taken_armour
Definition: player.h:89
int deployed
Definition: player.h:80
double dmg_taken_shield
Definition: player.h:88
unsigned int landed_times
Definition: player.h:92
Pilot * p
Definition: player.h:74
int autoweap
Definition: player.h:76
char * acquired
Definition: player.h:84
unsigned int jumped_times
Definition: player.h:91
double dmg_done_shield
Definition: player.h:86
int favourite
Definition: player.h:77
Pilot * p
Definition: player.h:101
double radar_res
Definition: player.h:125
double dmg_done_shield
Definition: player.h:137
double mousex
Definition: player.h:113
int autonav
Definition: player.h:107
unsigned int jumped_times
Definition: player.h:142
PlayerShip_t ps
Definition: player.h:102
char * name
Definition: player.h:103
char * loaded_version
Definition: player.h:121
double dmg_done_armour
Definition: player.h:138
double autonav_timer
Definition: player.h:112
int fleet_used
Definition: player.h:130
time_t last_played
Definition: player.h:134
double dmg_taken_armour
Definition: player.h:140
char * gui
Definition: player.h:124
double tc_max
Definition: player.h:111
time_t time_since_save
Definition: player.h:147
int map_minimal
Definition: player.h:127
double time_played
Definition: player.h:135
char autonavcol
Definition: player.h:110
char * chapter
Definition: player.h:116
char * autonavmsg
Definition: player.h:109
time_t date_created
Definition: player.h:136
int fleet_capacity
Definition: player.h:131
double dmg_taken_shield
Definition: player.h:139
vec2 autonav_pos
Definition: player.h:108
double speed
Definition: player.h:115
char * difficulty
Definition: player.h:117
double mousey
Definition: player.h:114
unsigned int death_counter
Definition: player.h:144
PlayerFlags flags
Definition: player.h:106
int discover_off
Definition: player.h:118
unsigned int landed_times
Definition: player.h:143
int eq_outfitMode
Definition: player.h:126
Represents a space ship.
Definition: ship.h:94
Abstraction for rendering sprite sheets.
Definition: opengl_tex.h:34
Represents a 2d vector.
Definition: vec2.h:32