14#include "difficulty.h"
19#include "nlua_outfit.h"
20#include "nlua_pilot.h"
21#include "nlua_pilotoutfit.h"
36static const char *outfitkeytostr( OutfitKey key );
51 double *a,
double dt )
57 if ( wt->type == TARGET_NONE )
72 if ( wt->type == TARGET_PILOT ) {
75 }
else if ( wt->type == TARGET_ASTEROID ) {
77 .asteroids[wt->u.ast.asteroid];
78 x = ast->
sol.
pos.
x - p->solid.pos.x;
79 y = ast->
sol.
pos.
y - p->solid.pos.y;
84 *a =
FABS( angle_diff( ang, p->solid.dir ) );
120 if ( p->stats.launch_lockon <= 0. )
142 for (
int i = 0; i <
array_size( p->outfits ); i++ ) {
172 if ( ship_isFlag( p->ship, SHIP_3DMOUNTS ) ) {
180 cm = cos( p->solid.dir );
181 sm = sin( p->solid.dir );
182 x = m->
pos.v[0] * cm - m->
pos.v[1] * sm;
183 y = m->
pos.v[0] * sm + m->
pos.v[1] * cm + m->
pos.v[2];
188 vec2_cset( v, x, y );
205 if ( p->dockpilot != target->
id )
210 if ( dockslot == NULL )
214 if ( vec2_dist( &p->solid.pos, &target->
solid.
pos ) >
215 target->
ship->
size * PILOT_SIZE_APPROX )
219 if ( vec2_dist2( &p->solid.vel, &target->
solid.
vel ) >
220 pow2( MAX_HYPERSPACE_VEL ) )
233 WARN( _(
"Unable to add ammo to '%s' from docking pilot '%s'!" ),
234 target->
name, p->name );
238 if ( ( target->
escorts[i].
type == ESCORT_TYPE_BAY ) &&
244 WARN( _(
"Docking pilot '%s' not found in pilot '%s's escort list!" ),
245 target->
name, p->name );
263 for (
int i = 0; i <
array_size( p->outfits ); i++ ) {
264 if ( p->outfits[i]->outfit == NULL )
267 if ( p->outfits[i]->u.ammo.deployed > 0 )
287 s->
state = PILOT_OUTFIT_OFF;
316 s->
flags |= PILOTOUTFIT_ACTIVE;
318 s->
flags &= ~PILOTOUTFIT_ACTIVE;
322 s->
flags |= PILOTOUTFIT_TOGGLEABLE;
324 s->
flags &= ~PILOTOUTFIT_TOGGLEABLE;
355 if ( s->
outfit != NULL ) {
357 WARN( _(
"Pilot '%s': trying to add outfit '%s' to slot that already "
364 WARN( _(
"Pilot '%s': Not enough CPU to add outfit '%s'" ),
367 }
else if ( ( str =
pilot_canEquip( pilot, s, outfit ) ) != NULL ) {
369 WARN( _(
"Pilot '%s': Trying to add outfit but %s" ), pilot->
name,
408 WARN( _(
"Instrinsic outfits must be modifiers!" ) );
429 WARN( _(
"Instrinsic outfits must be modifiers!" ) );
453 if ( s->
outfit != outfit )
473 if ( s->
outfit != outfit )
494 if ( s->
state == PILOT_OUTFIT_ON )
501 if ( s->
outfit != NULL ) {
515 ret = ( s->
outfit == NULL );
525 if ( s->
lua_mem != LUA_NOREF ) {
549 WARN( _(
"Pilot '%s': Trying to remove outfit but %s" ), pilot->
name,
570 for (
int i = 0; i <
array_size( p->outfits ); i++ )
571 if ( ( p->outfits[i]->outfit != NULL ) &&
573 &p->outfits[i]->sslot->slot ) )
586 for (
int i = 0; i <
array_size( p->outfits ); i++ )
587 if ( p->outfits[i]->sslot->required && p->outfits[i]->outfit == NULL )
613#define SPACEWORTHY_CHECK( cond, msg ) \
616 if ( buf != NULL ) { \
618 pos += scnprintf( &buf[pos], bufSize - pos, "\n" ); \
619 pos += scnprintf( &buf[pos], bufSize - pos, ( msg ) ); \
627 _(
"!! Not All Core Slots are equipped" ) );
629 SPACEWORTHY_CHECK( p->cpu < 0, _(
"!! Insufficient CPU" ) );
632 SPACEWORTHY_CHECK( p->accel < 0, _(
"!! Insufficient Accel" ) );
633 SPACEWORTHY_CHECK( p->speed < 0, _(
"!! Insufficient Speed" ) );
634 SPACEWORTHY_CHECK( p->turn < 0, _(
"!! Insufficient Turn" ) );
637 SPACEWORTHY_CHECK( p->armour < 0., _(
"!! Insufficient Armour" ) );
638 SPACEWORTHY_CHECK( p->armour_regen < 0.,
639 _(
"!! Insufficient Armour Regeneration" ) );
640 SPACEWORTHY_CHECK( p->shield < 0., _(
"!! Insufficient Shield" ) );
641 SPACEWORTHY_CHECK( p->shield_regen < 0.,
642 _(
"!! Insufficient Shield Regeneration" ) );
643 SPACEWORTHY_CHECK( p->energy_max < 0., _(
"!! Insufficient Energy" ) );
644 SPACEWORTHY_CHECK( ( p->energy_regen <= 0. ) && ( p->energy_max > 0. ),
645 _(
"!! Insufficient Energy Regeneration" ) );
648 SPACEWORTHY_CHECK( p->fuel_max < 0, _(
"!! Insufficient Fuel Maximum" ) );
649 SPACEWORTHY_CHECK( p->fuel_consumption < 0,
650 _(
"!! Insufficient Fuel Consumption" ) );
651 SPACEWORTHY_CHECK( p->cargo_free < 0,
652 _(
"!! Insufficient Free Cargo Space" ) );
653 SPACEWORTHY_CHECK( p->crew < 0, _(
"!! Insufficient Crew" ) );
661 if ( pos > bufSize - 1 ) {
662 buf[bufSize - 4] =
'.';
663 buf[bufSize - 3] =
'.';
664 buf[bufSize - 2] =
'.';
666 }
else if ( pos == 0 ) {
668 pos +=
scnprintf( buf, bufSize, _(
"Spaceworthy" ) );
669 if ( ship_isFlag( p->ship, SHIP_NOPLAYER ) )
670 pos +=
scnprintf( &buf[pos], bufSize - pos,
"\n#o%s#0",
671 _(
"Escort only" ) );
672 if ( ship_isFlag( p->ship, SHIP_NOESCORT ) )
673 scnprintf( &buf[pos], bufSize - pos,
"\n#o%s#0",
674 _(
"Lead ship only" ) );
679#undef SPACEWORTHY_CHECK
692 for (
int i = 0; i <
array_size( p->outfits ); i++ ) {
693 const Outfit *o = p->outfits[i]->outfit;
696 if ( ( o->
limit != NULL ) && ( strcmp( o->
limit, limit ) == 0 ) )
699 for (
int i = 0; i <
array_size( p->outfit_intrinsic ); i++ ) {
700 const Outfit *o = p->outfit_intrinsic[i].outfit;
701 if ( ( o->
limit != NULL ) && ( strcmp( o->
limit, limit ) == 0 ) )
719 if ( ( p == NULL ) || ( s == NULL ) )
720 return _(
"Nothing selected." );
725 return _(
"Does not fit slot." );
728 return _(
"Already have an outfit of this type installed" );
730 if ( outfit_isProp( o, OUTFIT_PROP_UNIQUE ) &&
732 return _(
"Can only install unique outfit once." );
751 if ( s->
outfit == NULL ) {
752 WARN( _(
"Pilot '%s': Trying to add ammo to unequipped slot." ),
786 else if ( s->
outfit == NULL ) {
787 WARN( _(
"Pilot '%s': Trying to remove ammo from unequipped slot." ),
817 if ( outfit == NULL )
841 if ( outfit == NULL )
860 max =
MAX( 0, round( (
double)o->
u.
lau.
amount * p->stats.ammo_capacity ) );
862 max =
MAX( 0, round( (
double)o->
u.
bay.
amount * p->stats.fbay_capacity ) );
896double pilot_outfitRange(
const Pilot *p,
const Outfit *o )
903 range *= p->stats.tur_range * p->stats.weapon_range;
905 range *= p->stats.fwd_range * p->stats.weapon_range;
912 range *= p->stats.tur_range * p->stats.weapon_range;
914 range *= p->stats.fwd_range * p->stats.weapon_range;
923 duration *= p->stats.launch_range * p->stats.weapon_range;
924 speed *= p->stats.launch_speed;
925 accel *= p->stats.launch_accel;
926 speed_max *= p->stats.launch_speed;
934 speedinc = speed_max - speed;
935 double at = speedinc / accel;
937 return speedinc * ( duration - at / 2. ) + speed * duration;
940 return pow2( duration ) * accel / 2. + duration * speed;
942 return speed * duration;
980 if ( slot->
lua_mem != LUA_NOREF )
990 if ( ( slot->
flags & PILOTOUTFIT_ACTIVE ) &&
991 !( slot->
state == PILOT_OUTFIT_ON ) )
998 if ( ( slot->
flags & PILOTOUTFIT_ACTIVE ) &&
999 !( slot->
state == PILOT_OUTFIT_ON ) )
1005 PILOT_AFTERBURNER );
1021 double ac, sc, ec, tm;
1064 if ( pilot_isWithPlayer( pilot ) )
1065 difficulty_apply( s );
1085 if ( pilot_isFlag( pilot, PILOT_STEALTH ) ) {
1157 if ( pilot_isFlag( pilot, PILOT_CARRIER_DIED ) ) {
1159 if ( parent == NULL ) {
1181 if ( pilot_isPlayer( pilot ) && ( tm != s->
time_mod ) )
1217 ( strcmp( s->
sslot->
name, name ) == 0 ) )
1233 return 1. / ( 1. + f + f + 4. * pow( f, 3. ) );
1260 if ( pilot_isFlag( pilot, PILOT_HASSPEEDLIMIT ) ) {
1263 if ( pilot->
speed < 0. ) {
1273 if ( pilot_isPlayer( pilot ) )
1285 return ( o->
flags & PILOTOUTFIT_TOGGLEABLE );
1292 void ( *
const func )(
const Pilot *p,
1297 pilotoutfit_modified = 0;
1298 for (
int i = 0; i <
array_size( p->outfits ); i++ ) {
1300 if ( po->
outfit == NULL )
1302 func( p, po, data );
1304 for (
int i = 0; i <
array_size( p->outfit_intrinsic ); i++ ) {
1306 if ( po->
outfit == NULL )
1308 func( p, po, data );
1311 if ( pilotoutfit_modified ) {
1317static void outfitLRunWarning(
const Pilot *p,
const Outfit *o,
1318 const char *name,
const char *error )
1320 WARN( _(
"Pilot '%s''s outfit '%s' -> '%s':\n%s" ), p->name, o->
name, name,
1331 if ( po->
lua_mem == LUA_NOREF ) {
1332 lua_newtable(
naevL );
1336 nlua_getenv(
naevL, env,
"mem" );
1337 oldmem = luaL_ref(
naevL, LUA_REGISTRYINDEX );
1340 nlua_setenv(
naevL, env,
"mem" );
1349 lua_rawgeti(
naevL, LUA_REGISTRYINDEX, oldmem );
1350 nlua_setenv(
naevL, env,
"mem" );
1351 luaL_unref(
naevL, LUA_REGISTRYINDEX, oldmem );
1354static const char *pilot_outfitLDescExtra(
const Pilot *p,
const Outfit *o )
1356 static char descextra[STRMAX];
1363 if ( ( p != NULL ) && ( p->id > 0 ) )
1366 lua_pushnil(
naevL );
1368 if ( nlua_pcall( o->
lua_env, 2, 1 ) ) {
1369 outfitLRunWarning( p, o,
"descextra", lua_tostring(
naevL, -1 ) );
1370 lua_pop(
naevL, 1 );
1371 descextra[0] =
'\0';
1375 if ( lua_isnoneornil(
naevL, -1 ) ) {
1376 lua_pop(
naevL, 1 );
1379 de = luaL_checkstring(
naevL, -1 );
1380 strncpy( descextra, de,
sizeof( descextra ) - 1 );
1381 lua_pop(
naevL, 1 );
1396 static char o_description[STRMAX];
1397 const char *de = pilot_outfitLDescExtra( p, o );
1400 snprintf( o_description,
sizeof( o_description ),
"%s\n%s", _( o->
desc_raw ),
1402 return o_description;
1417 static char o_summary[STRMAX];
1418 const char *de = pilot_outfitLDescExtra( p, o );
1421 snprintf( o_summary,
sizeof( o_summary ),
"%s\n%s", _( o->
name ),
1424 snprintf( o_summary,
sizeof( o_summary ),
"%s", o->
summary_raw );
1427 snprintf( o_summary,
sizeof( o_summary ),
"%s\n%s\n%s", _( o->
name ),
1430 snprintf( o_summary,
sizeof( o_summary ),
"%s\n%s", o->
summary_raw,
1450 speed *= p->stats.launch_speed;
1451 accel *= p->stats.launch_accel;
1452 speed_max *= p->stats.launch_speed;
1453 duration *= p->stats.launch_range * p->stats.weapon_range;
1463 t = ( speed_max - speed ) / accel;
1467 return ( accel * t * t / 2. +
1468 ( speed_max - speed ) * ( duration - t ) ) /
1473 return accel * duration / 2. + speed;
1485 pilotoutfit_modified = 0;
1491 if ( pilotoutfit_modified ) {
1505 if ( po->
outfit == NULL )
1518 outfitLRunWarning( pilot, po->
outfit,
"onadd",
1519 lua_tostring(
naevL, -1 ) );
1520 lua_pop(
naevL, 1 );
1535 if ( po->
outfit == NULL )
1548 outfitLRunWarning( pilot, po->
outfit,
"onremove",
1549 lua_tostring(
naevL, -1 ) );
1550 lua_pop(
naevL, 1 );
1567 int lua_oinit, oldmem;
1570 if ( po->
outfit == NULL )
1582 if ( lua_oinit == LUA_NOREF ) {
1588 lua_rawgeti(
naevL, LUA_REGISTRYINDEX, lua_oinit );
1591 if ( nlua_pcall( lua_env, 2, 0 ) ) {
1592 outfitLRunWarning( pilot, po->
outfit,
"init", lua_tostring(
naevL, -1 ) );
1593 lua_pop(
naevL, 1 );
1612 dt = *(
double *)data;
1621 lua_pushnumber(
naevL, dt );
1622 if ( nlua_pcall( env, 3, 0 ) ) {
1623 outfitLRunWarning( pilot, po->
outfit,
"update",
1624 lua_tostring(
naevL, -1 ) );
1625 lua_pop(
naevL, 1 );
1640 NTracingZone( _ctx, 1 );
1642 NTracingZoneEnd( _ctx );
1663 if ( nlua_pcall( env, 2, 0 ) ) {
1664 outfitLRunWarning( pilot, po->
outfit,
"outofenergy",
1665 lua_tostring(
naevL, -1 ) );
1666 lua_pop(
naevL, 1 );
1683 unsigned int attacker;
1688 double armour, shield;
1689 unsigned int attacker;
1700 armour = odat->armour;
1701 shield = odat->shield;
1702 attacker = odat->attacker;
1711 lua_pushnumber(
naevL, armour );
1712 lua_pushnumber(
naevL, shield );
1714 if ( nlua_pcall( env, 5, 0 ) ) {
1715 outfitLRunWarning( pilot, po->
outfit,
"onhit",
1716 lua_tostring(
naevL, -1 ) );
1717 lua_pop(
naevL, 1 );
1730 unsigned int attacker )
1733 .armour = armour, .shield = shield, .attacker = attacker };
1752 pilotoutfit_modified = 0;
1761 lua_pushboolean(
naevL, on );
1762 lua_pushboolean(
naevL, natural );
1763 if ( nlua_pcall( env, 4, 1 ) ) {
1764 outfitLRunWarning( pilot, po->
outfit,
"ontoggle",
1765 lua_tostring(
naevL, -1 ) );
1766 lua_pop(
naevL, 1 );
1772 ret = lua_toboolean(
naevL, -1 );
1773 lua_pop(
naevL, 1 );
1789 pilotoutfit_modified = 0;
1798 if ( nlua_pcall( env, 2, 1 ) ) {
1799 outfitLRunWarning( pilot, po->
outfit,
"onshoot",
1800 lua_tostring(
naevL, -1 ) );
1801 lua_pop(
naevL, 1 );
1807 ret = lua_toboolean(
naevL, -1 );
1808 lua_pop(
naevL, 1 );
1810 return ret || pilotoutfit_modified;
1822 int done, success, oldmem;
1833 success = cdat->success;
1834 timer = cdat->timer;
1843 lua_pushboolean(
naevL, done );
1845 lua_pushboolean(
naevL, success );
1847 lua_pushnumber(
naevL, timer );
1848 if ( nlua_pcall( env, 4, 0 ) ) {
1849 outfitLRunWarning( pilot, po->
outfit,
"cooldown",
1850 lua_tostring(
naevL, -1 ) );
1851 lua_pop(
naevL, 1 );
1867 .done = done, .success = success, .timer = timer };
1888 if ( nlua_pcall( env, 2, 0 ) ) {
1889 outfitLRunWarning( pilot, po->
outfit,
"onshootany",
1890 lua_tostring(
naevL, -1 ) );
1891 lua_pop(
naevL, 1 );
1923 naevL, pilot_isFlag( pilot, PILOT_STEALTH ) );
1924 if ( nlua_pcall( env, 3, 0 ) ) {
1925 outfitLRunWarning( pilot, po->
outfit,
"onstealth",
1926 lua_tostring(
naevL, -1 ) );
1927 lua_pop(
naevL, 1 );
1940 return pilotoutfit_modified;
1961 if ( nlua_pcall( env, 3, 0 ) ) {
1962 outfitLRunWarning( pilot, po->
outfit,
"onscan",
1963 lua_tostring(
naevL, -1 ) );
1964 lua_pop(
naevL, 1 );
1981 const Pilot *scanner;
1987 scanner = (
const Pilot *)data;
1997 if ( nlua_pcall( env, 3, 0 ) ) {
1998 outfitLRunWarning( pilot, po->
outfit,
"onscanned",
1999 lua_tostring(
naevL, -1 ) );
2000 lua_pop(
naevL, 1 );
2032 if ( nlua_pcall( env, 2, 0 ) ) {
2033 outfitLRunWarning( pilot, po->
outfit,
"land", lua_tostring(
naevL, -1 ) );
2034 lua_pop(
naevL, 1 );
2065 if ( nlua_pcall( env, 2, 0 ) ) {
2066 outfitLRunWarning( pilot, po->
outfit,
"takeoff",
2067 lua_tostring(
naevL, -1 ) );
2068 lua_pop(
naevL, 1 );
2099 if ( nlua_pcall( env, 2, 0 ) ) {
2100 outfitLRunWarning( pilot, po->
outfit,
"jumpin",
2101 lua_tostring(
naevL, -1 ) );
2102 lua_pop(
naevL, 1 );
2119 const Pilot *target;
2125 target = (
const Pilot *)data;
2135 if ( nlua_pcall( env, 3, 0 ) ) {
2136 outfitLRunWarning( pilot, po->
outfit,
"board",
2137 lua_tostring(
naevL, -1 ) );
2138 lua_pop(
naevL, 1 );
2153static const char *outfitkeytostr( OutfitKey key )
2156 case OUTFIT_KEY_ACCEL:
2158 case OUTFIT_KEY_LEFT:
2160 case OUTFIT_KEY_RIGHT:
2173 key = *( (
const OutfitKey *)data );
2181 lua_rawgeti(
naevL, LUA_REGISTRYINDEX,
2185 lua_pushstring(
naevL, outfitkeytostr( key ) );
2186 if ( nlua_pcall( env, 3, 1 ) ) {
2187 outfitLRunWarning( pilot, po->
outfit,
"keydoubletap",
2188 lua_tostring(
naevL, -1 ) );
2189 lua_pop(
naevL, 1 );
2194 if ( ( po->
state == PILOT_OUTFIT_ON ) || lua_toboolean(
naevL, -1 ) )
2196 lua_pop(
naevL, 1 );
2198void pilot_outfitLOnkeydoubletap(
Pilot *pilot, OutfitKey key )
2200 if ( pilot_isDisabled( pilot ) )
2204 if (
stealth_break && pilot_isFlag( pilot, PILOT_STEALTH ) )
2215 key = *( (
const OutfitKey *)data );
2226 lua_pushstring(
naevL, outfitkeytostr( key ) );
2227 if ( nlua_pcall( env, 3, 0 ) ) {
2228 outfitLRunWarning( pilot, po->
outfit,
"keyrelease",
2229 lua_tostring(
naevL, -1 ) );
2230 lua_pop(
naevL, 1 );
2234void pilot_outfitLOnkeyrelease(
Pilot *pilot, OutfitKey key )
2247 pilotoutfit_modified = 0;
2251 if ( po->
outfit == NULL )
2257 if ( po->
lua_mem == LUA_NOREF )
2269 if ( nlua_pcall( env, 2, 0 ) ) {
2270 outfitLRunWarning( pilot, po->
outfit,
"cleanup",
2271 lua_tostring(
naevL, -1 ) );
2272 lua_pop(
naevL, 1 );
Provides macros to work with dynamic arrays.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void effect_compute(ShipStats *s, const Effect *efxlist)
Updates shipstats from effect list.
void escort_rmListIndex(Pilot *p, int i)
Remove from escorts list.
void gui_setShip(void)
Player just upgraded their ship or modified it.
void gui_setGeneric(const Pilot *pilot)
Calls trigger functions depending on who the pilot is.
void mat4_mul_vec(vec3 *out, const mat4 *m, const vec3 *v)
Multiplies a matrix with a vector (out = m * v);.
Header file with generic functions and naev-specifics.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
PilotOutfitSlot ** lua_pushpilotoutfit(lua_State *L, PilotOutfitSlot *po)
Pushes a pilot outfit on the stack.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
int outfit_isBeam(const Outfit *o)
Checks if outfit is a beam type weapon.
double outfit_cpu(const Outfit *o)
Gets the outfit's cpu usage.
int outfit_isActive(const Outfit *o)
Checks if outfit is an active outfit.
int outfit_isLauncher(const Outfit *o)
Checks if outfit is a weapon launcher.
int outfit_isSeeker(const Outfit *o)
Checks if outfit is a seeking weapon.
int outfit_isToggleable(const Outfit *o)
Checks if outfit can be toggled.
int outfit_fitsSlot(const Outfit *o, const OutfitSlot *s)
Checks to see if an outfit fits a slot.
int outfit_isFighterBay(const Outfit *o)
Checks if outfit is a fighter bay.
int outfit_isAfterburner(const Outfit *o)
Checks if outfit is an afterburner.
int outfit_isTurret(const Outfit *o)
Checks if outfit is a turret class weapon.
double outfit_ammoMass(const Outfit *o)
Gets the outfit's ammunition mass.
int outfit_isForward(const Outfit *o)
Checks if outfit is a fixed mounted weapon.
int outfit_isMod(const Outfit *o)
Checks if outfit is a ship modification.
int outfit_isBolt(const Outfit *o)
Checks if outfit is bolt type weapon.
mat4 pilot_local_transform(const Pilot *p)
Gets the local transformation matrix of a pilot.
PilotOutfitSlot * pilot_getDockSlot(Pilot *p)
Gets the dock slot of the pilot.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
void pilot_delete(Pilot *p)
Deletes a pilot.
int pilot_numOutfit(const Pilot *p, const Outfit *o)
Checks to see how many of an outfit a pilot has.
void pilot_cargoCalc(Pilot *pilot)
Calculates how much cargo ship has left and such.
void pilot_destealth(Pilot *p)
Destealths a pilot.
double pilot_ewWeaponTrack(const Pilot *p, const Pilot *t, double trackmin, double trackmax)
Calculates the weapon lead (1. is 100%, 0. is 0%)..
void pilot_ewUpdateStatic(Pilot *p)
Updates the pilot's static electronic warfare properties.
void pilot_heatCalcSlot(PilotOutfitSlot *o)
Calculates the heat parameters for a pilot's slot.
void pilot_heatCalc(Pilot *p)
Calculates the heat parameters for a pilot.
int pilot_runHook(Pilot *p, int hook_type)
Tries to run a pilot hook if he has it.
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_hasDeployed(const Pilot *p)
Checks to see if the pilot has deployed ships.
static void pilot_outfitLunmem(nlua_env env, int oldmem)
Cleans up the outfit memory for a slot.
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.
static void pilot_calcStatsSlot(Pilot *pilot, PilotOutfitSlot *slot)
Computes the stats for a pilot's slot.
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.
static int pilot_outfitLmem(PilotOutfitSlot *po, nlua_env env)
Sets up the outfit memory for a slot.
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.
int pilot_dock(Pilot *p, Pilot *target)
Docks the pilot on its target pilot.
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.
static void pilot_outfitLRun(Pilot *p, void(*const func)(const Pilot *p, PilotOutfitSlot *po, const void *data), const void *data)
Wrapper that does all the work for us.
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.
int pilot_outfitOff(Pilot *p, PilotOutfitSlot *o, int natural)
Disables a given active outfit.
void pilot_weapSetUpdateOutfitState(Pilot *p)
Updates the local state of all the pilot's outfits based on the weapon sets.
void pilot_weapSetUpdateStats(Pilot *p)
Update the weapon sets given pilot stat changes.
void player_resetSpeed(void)
Resets the player speed stuff.
void ss_free(ShipStatList *ll)
Frees a list of ship stats.
int ss_statsMergeFromList(ShipStats *stats, const ShipStatList *list)
Updates a stat structure from a stat list.
int sp_required(unsigned int spid)
Gets whether or not a slot property is required.
Represents a single asteroid.
A ship outfit, depends radically on the type.
union Outfit::@264277167364127137334024361374356236341374052147 u
OutfitAfterburnerData afb
Stores an outfit the pilot has.
The representation of an in-game pilot.
ShipStatList * ship_stats
PilotOutfitSlot ** outfits
PilotOutfitSlot * outfit_intrinsic
ShipStatList * intrinsic_stats
PilotOutfitSlot * afterburner
Represents a ship weapon mount point.
Represents ship statistics, properties ship can use.
double shield_regen_malus
double energy_regen_malus
double armour_regen_malus
Represents a weapon target.