naev 0.12.5
pilot_outfit.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "pilot.h"
7
8#include "target.h"
9
10#define PILOT_OUTFIT_LUA_UPDATE_DT \
11 ( 1.0 / 10.0 ) /* How often the Lua outfits run their update script (in \
12 seconds). */
13
14typedef enum OutfitKey_ {
15 OUTFIT_KEY_ACCEL,
16 OUTFIT_KEY_LEFT,
17 OUTFIT_KEY_RIGHT,
18} OutfitKey;
19
20/* Augmentations of normal pilot API. */
21const char *pilot_outfitDescription( const Pilot *pilot, const Outfit *o );
22const char *pilot_outfitSummary( const Pilot *p, const Outfit *o,
23 int withname );
24double pilot_outfitSpeed( const Pilot *p, const Outfit *o );
25double pilot_outfitRange( const Pilot *p, const Outfit *o );
26
27/* Raw changes. */
28int pilot_addOutfitRaw( Pilot *pilot, const Outfit *outfit,
29 PilotOutfitSlot *s );
30int pilot_addOutfitTest( Pilot *pilot, const Outfit *outfit,
31 const PilotOutfitSlot *s, int warn );
33
34/* Changes with checks. */
35int pilot_addOutfit( Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s );
36int pilot_rmOutfit( Pilot *pilot, PilotOutfitSlot *s );
37
38/* Intrinsic outfits. */
39int pilot_addOutfitIntrinsicRaw( Pilot *pilot, const Outfit *outfit );
40int pilot_addOutfitIntrinsic( Pilot *pilot, const Outfit *outfit );
41int pilot_rmOutfitIntrinsic( Pilot *pilot, const Outfit *outfit );
42int pilot_hasIntrinsic( const Pilot *pilot, const Outfit *outfit );
43
44/* Ammo. */
45int pilot_addAmmo( Pilot *pilot, PilotOutfitSlot *s, int quantity );
46int pilot_rmAmmo( Pilot *pilot, PilotOutfitSlot *s, int quantity );
47int pilot_countAmmo( const Pilot *pilot );
48int pilot_maxAmmo( const Pilot *pilot );
49int pilot_maxAmmoO( const Pilot *p, const Outfit *o );
50void pilot_fillAmmo( Pilot *pilot );
51
52/* Checks. */
53int pilot_hasOutfitLimit( const Pilot *p, const char *limit );
54int pilot_slotsCheckSafety( const Pilot *p );
55int pilot_slotsCheckRequired( const Pilot *p );
56int pilot_isSpaceworthy( const Pilot *p );
57int pilot_reportSpaceworthy( const Pilot *p, char *buf, int buffSize );
58const char *pilot_canEquip( const Pilot *p, const PilotOutfitSlot *s,
59 const Outfit *o );
60
61/* Lock-ons. */
63 double *a, double dt );
64void pilot_lockClear( Pilot *p );
65
66/* Other. */
67void pilot_calcStats( Pilot *pilot );
68double pilot_massFactor( const Pilot *pilot );
69void pilot_updateMass( Pilot *pilot );
70void pilot_healLanded( Pilot *pilot );
71PilotOutfitSlot *pilot_getSlotByName( Pilot *pilot, const char *name );
72
73/* Special outfit stuff. */
74int pilot_getMount( const Pilot *p, const PilotOutfitSlot *w, vec2 *v );
75
76/* Lua outfit stuff. */
78int pilot_outfitLAdd( const Pilot *pilot, PilotOutfitSlot *po );
79int pilot_outfitLRemove( const Pilot *pilot, PilotOutfitSlot *po );
80void pilot_outfitLInitAll( Pilot *pilot );
81int pilot_outfitLInit( const Pilot *pilot, PilotOutfitSlot *po );
82void pilot_outfitLUpdate( Pilot *pilot, double dt );
83void pilot_outfitLOutfofenergy( Pilot *pilot );
84void pilot_outfitLOnhit( Pilot *pilot, double armour, double shield,
85 unsigned int attacker );
86int pilot_outfitLOntoggle( const Pilot *pilot, PilotOutfitSlot *po, int on,
87 int natural );
88int pilot_outfitLOnshoot( const Pilot *pilot, PilotOutfitSlot *po );
89void pilot_outfitLCooldown( Pilot *pilot, int done, int success, double timer );
90void pilot_outfitLOnshootany( Pilot *pilot );
91int pilot_outfitLOnstealth( Pilot *pilot );
92void pilot_outfitLOnscan( Pilot *pilot );
93void pilot_outfitLOnscanned( Pilot *pilot, const Pilot *scanner );
94void pilot_outfitLOnland( Pilot *pilot );
95void pilot_outfitLOntakeoff( Pilot *pilot );
96void pilot_outfitLOnjumpin( Pilot *pilot );
97void pilot_outfitLOnboard( Pilot *pilot, const Pilot *target );
98void pilot_outfitLOnkeydoubletap( Pilot *pilot, OutfitKey key );
99void pilot_outfitLOnkeyrelease( Pilot *pilot, OutfitKey key );
100void pilot_outfitLCleanup( Pilot *pilot );
int pilot_getMount(const Pilot *p, const PilotOutfitSlot *w, vec2 *v)
Gets the mount position of a pilot.
void pilot_lockUpdateSlot(Pilot *p, PilotOutfitSlot *o, Pilot *t, Target *wt, double *a, double dt)
Updates the lockons on the pilot's launchers.
int pilot_rmOutfit(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot.
void pilot_updateMass(Pilot *pilot)
Updates the pilot stats after mass change.
int pilot_addOutfitIntrinsicRaw(Pilot *pilot, const Outfit *outfit)
Adds an outfit as an intrinsic slot.
void pilot_outfitLCooldown(Pilot *pilot, int done, int success, double timer)
Handle cooldown hooks for outfits.
int pilot_hasOutfitLimit(const Pilot *p, const char *limit)
Checks to see if a pilot has an outfit with a specific outfit type.
void pilot_outfitLOutfofenergy(Pilot *pilot)
Handles when the pilot runs out of energy.
const char * pilot_outfitDescription(const Pilot *p, const Outfit *o)
Gets the description of an outfit for a given pilot.
void pilot_healLanded(Pilot *pilot)
Cures the pilot as if he was landed.
int pilot_slotsCheckRequired(const Pilot *p)
Pilot required (core) slot filled check - makes sure they are filled.
int pilot_slotsCheckSafety(const Pilot *p)
Pilot slot safety check - makes sure stats are safe.
int pilot_outfitLAdd(const Pilot *pilot, PilotOutfitSlot *po)
Outfit is added to a ship.
int pilot_maxAmmoO(const Pilot *p, const Outfit *o)
Gets the maximum available ammo for a pilot for a specific outfit.
int pilot_addOutfit(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
Adds an outfit to the pilot.
void pilot_outfitLOnjumpin(Pilot *pilot)
Runs Lua outfits when pilot jumps into a system.
int pilot_slotIsToggleable(const PilotOutfitSlot *o)
Checks to see if a slot has an active outfit that can be toggleable.
void pilot_outfitLOntakeoff(Pilot *pilot)
Runs Lua outfits when pilot takes off from a spob.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
double pilot_massFactor(const Pilot *pilot)
Gets the factor at which speed gets worse.
void pilot_fillAmmo(Pilot *pilot)
Fills pilot's ammo completely.
int pilot_addAmmo(Pilot *pilot, PilotOutfitSlot *s, int quantity)
Adds some ammo to the pilot stock.
int pilot_hasIntrinsic(const Pilot *pilot, const Outfit *outfit)
Gets how many copies of an intrinsic a pilot has.
const char * pilot_outfitSummary(const Pilot *p, const Outfit *o, int withname)
Gets the summary of an outfit for a give pilot.
int pilot_rmOutfitRaw(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot without doing any checks.
int pilot_outfitLInit(const Pilot *pilot, PilotOutfitSlot *po)
Runs the pilot's Lua outfits init script for an outfit.
int pilot_countAmmo(const Pilot *pilot)
Gets the number of ammo units on the ship.
void pilot_lockClear(Pilot *p)
Clears pilot's missile lockon timers.
int pilot_outfitLOnstealth(Pilot *pilot)
Runs the pilot's Lua outfits onhit script.
void pilot_outfitLCleanup(Pilot *pilot)
Handle cleanup hooks for outfits.
PilotOutfitSlot * pilot_getSlotByName(Pilot *pilot, const char *name)
Gets the outfit slot by name.
int pilot_maxAmmo(const Pilot *pilot)
The maximum amount of ammo the pilot's current ship can hold.
void pilot_outfitLOnscan(Pilot *pilot)
Runs Lua outfits when pilot scanned their target.
int pilot_reportSpaceworthy(const Pilot *p, char *buf, int bufSize)
Pilot safety report - makes sure stats are safe.
int pilot_outfitLOntoggle(const Pilot *pilot, PilotOutfitSlot *po, int on, int natural)
Handle the manual toggle of an outfit.
int pilot_addOutfitTest(Pilot *pilot, const Outfit *outfit, const PilotOutfitSlot *s, int warn)
Tests to see if an outfit can be added.
int pilot_outfitLOnshoot(const Pilot *pilot, PilotOutfitSlot *po)
Handle the manual shoot of an outfit.
void pilot_outfitLOnboard(Pilot *pilot, const Pilot *target)
Runs Lua outfits when pilot boards a target.
int pilot_outfitLRemove(const Pilot *pilot, PilotOutfitSlot *po)
Outfit is removed froma ship.
int pilot_rmAmmo(Pilot *pilot, PilotOutfitSlot *s, int quantity)
Removes some ammo from the pilot stock.
void pilot_outfitLOnland(Pilot *pilot)
Runs Lua outfits when pilot lands on a spob.
void pilot_outfitLOnscanned(Pilot *pilot, const Pilot *scanner)
Runs Lua outfits when pilot was scanned by scanner.
const char * pilot_canEquip(const Pilot *p, const PilotOutfitSlot *s, const Outfit *o)
Checks to see if can equip/remove an outfit from a slot.
void pilot_outfitLOnshootany(Pilot *pilot)
Runs the pilot's Lua outfits onshootany script.
void pilot_outfitLUpdate(Pilot *pilot, double dt)
Runs the pilot's Lua outfits update script.
int pilot_addOutfitRaw(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
Adds an outfit to the pilot, ignoring CPU or other limits.
int pilot_rmOutfitIntrinsic(Pilot *pilot, const Outfit *outfit)
Removes an outfit from an intrinsic slot.
int pilot_isSpaceworthy(const Pilot *p)
Pilot safety check - makes sure stats are safe.
int pilot_addOutfitIntrinsic(Pilot *pilot, const Outfit *outfit)
Adds an outfit as an intrinsic slot.
void pilot_outfitLOnhit(Pilot *pilot, double armour, double shield, unsigned int attacker)
Runs the pilot's Lua outfits onhit script.
double pilot_outfitSpeed(const Pilot *p, const Outfit *o)
Gets the speed of an outfit given a pilot.
void pilot_outfitLInitAll(Pilot *pilot)
Runs the pilot's Lua outfits init script.
A ship outfit, depends radically on the type.
Definition outfit.h:372
Stores an outfit the pilot has.
Definition pilot.h:145
The representation of an in-game pilot.
Definition pilot.h:263
Represents a weapon target.
Definition target.h:19
Represents a 2d vector.
Definition vec2.h:45