15#include "nlua_pilot.h"
20#include "damagetype.h"
24#include "land_outfits.h"
27#include "nlua_asteroid.h"
28#include "nlua_canvas.h"
29#include "nlua_colour.h"
31#include "nlua_commodity.h"
32#include "nlua_faction.h"
34#include "nlua_pilotoutfit.h"
35#include "nlua_outfit.h"
38#include "nlua_system.h"
43#include "pilot_heat.h"
57static int pilotL_getFriendOrFoe( lua_State *L,
int friend );
422 state = lua_toboolean(L, 2);
426 pilot_setFlag( p, flag );
428 pilot_rmFlag( p, flag );
455 return *((LuaPilot*) lua_touserdata(L,ind));
468 luaL_typerror(L, ind, PILOT_METATABLE);
482 NLUA_ERROR(L,_(
"Pilot is invalid."));
497 LuaPilot *p = (LuaPilot*) lua_newuserdata(L,
sizeof(LuaPilot));
499 luaL_getmetatable(L, PILOT_METATABLE);
500 lua_setmetatable(L, -2);
514 if (lua_getmetatable(L,ind)==0)
516 lua_getfield(L, LUA_REGISTRYINDEX, PILOT_METATABLE);
519 if (lua_rawequal(L, -1, -2))
539 int ignore_rules, guerilla;
541 JumpPoint *jump = NULL;
546 ignore_rules = lua_toboolean(L,2);
547 guerilla = lua_toboolean(L,3);
553 else if (jump != NULL)
592 const char *pilotname, *ai;
605 pilot_clearFlagsRaw( flags );
617 pilotname = luaL_optstring( L, 4, _(ship->
name) );
622 a = RNGF() * 2.*M_PI;
631 pilot_setFlagRaw( flags, PILOT_TAKEOFF );
632 a = RNGF() * 2. * M_PI;
633 r = RNGF() * spob->
radius;
635 spob->
pos.
x + r * cos(a),
636 spob->
pos.
y + r * sin(a) );
637 a = RNGF() * 2.*M_PI;
641 else if (lua_isnoneornil(L,3)) {
644 if (lua_isboolean(L,3) && lua_toboolean(L,3))
651 pilot_setFlagRaw( flags, PILOT_TAKEOFF );
652 a = RNGF() * 2. * M_PI;
653 r = RNGF() * spob->
radius;
655 spob->
pos.
x + r * cos(a),
656 spob->
pos.
y + r * sin(a) );
657 a = RNGF() * 2.*M_PI;
661 a = RNGF() * 2.*M_PI;
666 NLUA_INVALID_PARAMETER(L);
672 && !jp_isFlag(
cur_system->jumps[i].returnJump, JP_EXITONLY )) {
679 WARN(_(
"Ship '%s' jumping in from non-adjacent system '%s' to '%s'."),
684 WARN(_(
"Ship '%s' attempting to jump in from '%s', but '%s' has no jump points."),
691 if (lua_gettop( L ) >= 5 && !lua_isnil( L, 5 )) {
692 if (!lua_istable( L, 5 )) {
693 NLUA_ERROR( L, _(
"'parameters' should be a table of options or omitted!") );
696 lua_getfield( L, 5,
"ai" );
697 ai = luaL_optstring( L, -1, NULL );
700 lua_getfield( L, 5,
"naked" );
701 if (lua_toboolean(L, -1))
702 pilot_setFlagRaw( flags, PILOT_NO_OUTFITS );
705 lua_getfield( L, 5,
"stealth" );
706 if (lua_toboolean(L, -1))
707 pilot_setFlagRaw( flags, PILOT_STEALTH );
714 pilot_setFlagRaw( flags, PILOT_HYP_END );
718 a = fmod( a, 2.*M_PI );
723 p =
pilot_create( ship, pilotname, lf, ai, a, &vp, &vv, flags, 0, 0 );
728 if ((jump != NULL) && pilot_isFlagRaw( flags, PILOT_STEALTH )) {
763 NLUA_ERROR( L, _(
"Trying to remove the bloody player!") );
845 if (!lua_isnoneornil(L,1)) {
848 int b = !lua_toboolean(L,2);
859 else if (lua_isboolean(L,1))
862 NLUA_INVALID_PARAMETER(L);
886 int d = lua_toboolean(L,2);
901 while (lua_next(L, 1) != 0) {
917 lua_rawseti(L,-2, k++);
925 else if ((lua_isnil(L,1)) || (lua_gettop(L) == 0)) {
933 lua_rawseti(L,-2,k++);
938 NLUA_INVALID_PARAMETER(L);
947static int pilotL_getFriendOrFoe( lua_State *L,
int friend )
953 int inrange, dis, fighters;
962 else if (lua_isstring(L,1))
966 dist = luaL_optnumber(L,2,-1.);
969 dis = lua_toboolean(L,5);
970 fighters = lua_toboolean(L,6);
976 dist = luaL_optnumber(L,2,-1.);
977 v = luaL_optvector(L,3,&p->solid->pos);
978 inrange = !lua_toboolean(L,4);
979 dis = lua_toboolean(L,5);
980 fighters = lua_toboolean(L,6);
994 if (pilot_isFlag(plt, PILOT_DELETE))
998 if (!fighters && pilot_isFlag(plt, PILOT_CARRIED))
1003 vec2_dist2(&plt->
solid->
pos, v) > dd)
1007 if (dis && pilot_isDisabled(plt))
1039 if ((p!=NULL) && inrange &&
friend) {
1045 lua_rawseti(L,-2, k++);
1067 return pilotL_getFriendOrFoe( L, 1 );
1087 return pilotL_getFriendOrFoe( L, 0 );
1102 int dis = lua_toboolean(L,2);
1121 lua_rawseti(L,-2,k++);
1140 double d = luaL_checknumber(L,2);
1141 int dis = lua_toboolean(L,3);
1154 if (pilot_isFlag(p, PILOT_DELETE))
1157 if (pilot_isFlag(p, PILOT_HIDE))
1160 if (dis && pilot_isDisabled(p))
1164 if (vec2_dist2( v, &p->solid->pos ) >
d )
1168 lua_rawseti(L,-2,k++);
1188 lua_pushboolean(L, p1 == p2);
1204 lua_pushstring(L, p->name);
1220 lua_pushnumber(L, p->id);
1243 else if (pilot_isFlag( p, PILOT_DEAD ) || pilot_isFlag( p, PILOT_HIDE ))
1249 lua_pushboolean(L, exists);
1286 if (lua_isnoneornil(L,2))
1290 if (pilot_isPlayer(p))
1311 if (p->nav_asteroid < 0)
1314 la.parent = p->nav_anchor;
1315 la.id = p->nav_asteroid;
1333 p->nav_anchor = la->parent;
1334 p->nav_asteroid = la->id;
1363 lua_pushboolean(L,1);
1364 lua_pushboolean(L,1);
1366 else if (ret == 0) {
1367 lua_pushboolean(L,0);
1368 lua_pushboolean(L,0);
1371 lua_pushboolean(L,1);
1372 lua_pushboolean(L,0);
1419 lua_pushboolean(L, pilot_isWithPlayer(p));
1446 if (p->nav_spob < 0)
1452 if (p->nav_hyperspace < 0)
1455 ls =
cur_system->jumps[ p->nav_hyperspace ].targetid;
1475 lua_pushnumber( L, p->active_set + 1 );
1527 double delay, firemod, enermod, t;
1536 if (lua_gettop(L) > 1) {
1537 if (lua_isnumber(L,2))
1538 id = luaL_checkinteger(L,2) - 1;
1539 else if (lua_isboolean(L,2)) {
1540 all = lua_toboolean(L,2);
1544 NLUA_INVALID_PARAMETER(L);
1548 id =
CLAMP( 0, PILOT_WEAPON_SETS,
id );
1551 if (p->target != p->id)
1565 for (
int j=0; j<=PILOT_WEAPSET_MAX_LEVELS; j++) {
1567 int level_match = (j==PILOT_WEAPSET_MAX_LEVELS) ? -1 : j;
1570 for (
int i=0; i<n; i++) {
1572 slot = all ? p->outfits[i] : p->outfits[ po_list[i].
slotid ];
1581 || is_lau || is_fb))
1584 level = slot->
level;
1587 if (level != level_match)
1596 lua_pushnumber(L,++k);
1600 lua_pushstring(L,
"name");
1611 lua_pushstring(L,
"cooldown");
1612 has_beamid = (slot->u.
beamid > 0);
1614 lua_pushnumber(L, 0.);
1617 lua_pushnumber( L,
CLAMP( 0., 1., 1. -delay ) );
1622 lua_pushstring(L,
"charge");
1626 lua_pushnumber( L,
CLAMP( 0., 1., 1. -delay ) );
1631 lua_pushstring(L,
"cooldown");
1635 lua_pushnumber( L,
CLAMP( 0., 1., 1. - slot->
timer / delay ) );
1637 lua_pushnumber( L, 1. );
1642 if (is_lau || is_fb) {
1643 lua_pushstring(L,
"left");
1648 lua_pushstring(L,
"left_p");
1656 lua_pushstring(L,
"lockon");
1658 lua_pushnumber(L, 1.);
1664 lua_pushstring(L,
"in_arc");
1670 lua_pushstring(L,
"level");
1671 lua_pushnumber(L, level+1);
1675 lua_pushstring(L,
"temp");
1680 lua_pushstring(L,
"type");
1687 lua_pushstring(L,
"dtype");
1693 if (slot->
outfit->
type == OUTFIT_TYPE_TURRET_BOLT) {
1694 lua_pushstring(L,
"track");
1698 lua_pushnumber(L, -1);
1735 double heat, heat_mean, heat_peak, nweapons;
1745 if (lua_gettop(L) > 1) {
1746 if (lua_isnumber(L,2))
1747 id = luaL_checkinteger(L,2) - 1;
1748 else if (lua_isboolean(L,2)) {
1749 all = lua_toboolean(L,2);
1753 NLUA_INVALID_PARAMETER(L);
1757 id =
CLAMP( 0, PILOT_WEAPON_SETS,
id );
1763 for (
int j=0; j<=PILOT_WEAPSET_MAX_LEVELS; j++) {
1765 int level_match = (j==PILOT_WEAPSET_MAX_LEVELS) ? -1 : j;
1768 for (
int i=0; i<n; i++) {
1776 level = all ? slot->
level : po_list[i].
level;
1779 if (level != level_match)
1790 if (heat > heat_peak)
1797 heat_mean /= nweapons;
1799 lua_pushnumber( L, heat_mean );
1800 lua_pushnumber( L, heat_peak );
1846 sort = lua_toboolean(L,2);
1856 outfits = p->outfits;
1870 lua_pushnumber(L,++k);
1874 lua_pushstring(L,
"name");
1879 lua_pushstring(L,
"type");
1884 lua_pushstring(L,
"temp");
1891 if (outfits[i]->weapset != -1) {
1892 lua_pushstring(L,
"weapset");
1893 lua_pushnumber(L, outfits[i]->weapset + 1);
1899 case PILOT_OUTFIT_OFF:
1902 case PILOT_OUTFIT_WARMUP:
1908 lua_pushstring(L,
"warmup");
1909 lua_pushnumber(L,
d );
1912 case PILOT_OUTFIT_ON:
1918 else if (!isinf(o->
stimer))
1923 lua_pushstring(L,
"duration");
1924 lua_pushnumber(L,
d );
1927 case PILOT_OUTFIT_COOLDOWN:
1933 else if (!isinf(o->
stimer))
1938 lua_pushstring(L,
"cooldown");
1939 lua_pushnumber(L,
d );
1946 lua_pushstring(L,
"state");
1947 lua_pushstring(L,str);
1978 if (s1->
id < s2->
id)
1980 else if (s1->
id > s2->
id)
2000 const char *type = luaL_optstring(L,2,NULL);
2001 int skip_locked = lua_toboolean(L,3);
2002 OutfitSlotType ost = OUTFIT_SLOT_NULL;
2006 if (strcmp(type,
"all")==0)
2008 else if (strcmp(type,
"structure")==0)
2009 ost = OUTFIT_SLOT_STRUCTURE;
2010 else if (strcmp(type,
"utility")==0)
2011 ost = OUTFIT_SLOT_UTILITY;
2012 else if (strcmp(type,
"weapon")==0)
2013 ost = OUTFIT_SLOT_WEAPON;
2014 else if (strcmp(type,
"intrinsic")==0) {
2019 NLUA_ERROR(L,_(
"Unknown slot type '%s'"), type);
2025 for (
int i=0; i<
array_size(p->outfits); i++) {
2027 if (p->outfits[i]->outfit == NULL)
2031 if ((ost!=OUTFIT_SLOT_NULL) && (p->outfits[i]->outfit->slot.type!=ost))
2035 if (skip_locked && p->outfits[i]->sslot->locked)
2040 lua_rawseti( L, -2, j++ );
2044 for (
int i=0; i<
array_size(p->outfit_intrinsic); i++) {
2046 lua_rawseti( L, -2, i+1 );
2064 for (
int i=0; i<
array_size(p->outfits); i++) {
2065 if (p->outfits[i]->outfit == NULL)
2066 lua_pushboolean( L, 0 );
2069 lua_rawseti( L, -2, i+1 );
2086 int id = luaL_checkinteger(L,2)-1;
2088 NLUA_ERROR(L, _(
"Pilot '%s' outfit ID '%d' is out of range!"), p->name,
id);
2090 if (p->outfits[
id]->outfit != NULL)
2107 int isstealth, n = 0;
2109 int id = luaL_checkinteger(L,2)-1;
2110 int activate = lua_toboolean(L,3);
2112 NLUA_ERROR(L, _(
"Pilot '%s' outfit ID '%d' is out of range!"), p->name,
id);
2121 if ((pilot_isDisabled(p)) || (pilot_isFlag(p, PILOT_COOLDOWN)))
2124 if ((activate && (po->
state != PILOT_OUTFIT_OFF)) ||
2125 (!activate && (po->
state != PILOT_OUTFIT_ON)))
2133 isstealth = pilot_isFlag( p, PILOT_STEALTH );
2134 if (n>0 && isstealth)
2136 else if (n>0 || pilotoutfit_modified)
2139 lua_pushboolean(L,n);
2155 int id = luaL_checkinteger(L,2)-1;
2157 NLUA_ERROR(L, _(
"Pilot '%s' outfit ID '%d' is out of range!"), p->name,
id);
2159 if (p->outfits[
id]->outfit != NULL)
2160 lua_pushboolean( L, p->outfits[
id]->state==PILOT_OUTFIT_OFF );
2162 lua_pushboolean( L, 0 );
2179 const char *name = luaL_checkstring(L,2);
2183 p->name = strdup(name);
2232 lua_pushboolean(L,(VMOD(p->solid->vel) < MIN_VEL_ERR));
2248 lua_pushnumber( L, p->ew_evasion );
2264 lua_pushnumber( L, p->solid->dir );
2280 lua_pushnumber( L, p->heat_T );
2296 lua_pushnumber( L, p->solid->mass );
2330 char message[STRMAX_SHORT];
2333 lua_pushboolean( L, worthy );
2334 lua_pushstring( L, message );
2357 p->solid->pos = *vec;
2360 if (pilot_isPlayer(p))
2382 p->solid->vel = *vec;
2401 double d = luaL_checknumber(L,2);
2404 p->solid->dir = fmodf(
d, 2*M_PI );
2405 if (p->solid->dir < 0.)
2406 p->solid->dir += 2*M_PI;
2426 if (lua_isstring(L,1)) {
2427 const char *s = luaL_checkstring(L,1);
2428 const char *msg = luaL_checkstring(L,2);
2429 const char *col = luaL_optstring(L,3,NULL);
2431 player_message( _(
"#%cBroadcast %s>#0 \"%s\""), ((col==NULL)?
'N':col[0]), s, msg );
2437 const char *msg = luaL_checkstring(L,2);
2438 int ignore_int = lua_toboolean(L,3);
2465 if (lua_isstring(L,1)) {
2468 const char *msg, *col;
2475 s = luaL_checkstring(L,1);
2476 if (lua_isstring(L,2)) {
2477 msg = luaL_checkstring(L,2);
2478 col = luaL_optstring(L,3,NULL);
2479 raw = lua_toboolean(L,4);
2485 msg = luaL_checkstring(L,3);
2486 col = luaL_optstring(L,4,NULL);
2487 raw = lua_toboolean(L,5);
2492 player_message( _(
"#%c%s>#0 %s"), ((col==NULL)?
'N':col[0]), s, msg );
2494 player_message( _(
"#%cComm %s>#0 \"%s\""), ((col==NULL)?
'N':col[0]), s, msg );
2502 int ignore_int, raw;
2506 if (lua_isstring(L,2)) {
2508 msg = luaL_checkstring(L,2);
2509 ignore_int = lua_toboolean(L,3);
2510 raw = lua_toboolean(L,4);
2514 msg = luaL_checkstring(L,3);
2515 ignore_int = lua_toboolean(L,4);
2516 raw = lua_toboolean(L,5);
2526 if (target == 0 || target == PLAYER_ID) {
2581 if (lua_isnone(L,2))
2584 state = lua_toboolean(L, 2);
2614 if (lua_isnone(L,2))
2617 state = lua_toboolean(L, 2);
2813 int permanent = !lua_toboolean(L,2);
2817 p->stress = p->armour;
2821 pilot_setFlag(p, PILOT_DISABLED_PERM);
2823 pilot_rmFlag(p, PILOT_DISABLED_PERM);
2841 lua_pushboolean( L, pilot_isFlag(p, PILOT_COOLDOWN) );
2842 lua_pushboolean( L, pilot_isFlag(p, PILOT_COOLDOWN_BRAKE) );
2864 if (lua_isnone(L,2))
2867 state = lua_toboolean(L, 2);
2889 pilot_rmFlag(p, PILOT_COOLDOWN_BRAKE);
2944 if ((s->
outfit != NULL) &&
2953 else if (bypass_cpu) {
2999 int q, added, bypass_cpu, bypass_slot;
3004 q = luaL_optinteger(L,3,1);
3005 bypass_cpu = lua_toboolean(L,4);
3006 bypass_slot = lua_toboolean(L,5);
3010 for (
int i=0; i<
array_size(p->outfits); i++) {
3035 if ((added > 0) && p->autoweap)
3042 lua_pushnumber(L,added);
3057 const char *slotname = luaL_checkstring(L,2);
3060 WARN(_(
"Pilot '%s' with ship '%s' does not have named slot '%s'!"), p->name, _(p->ship->name), slotname );
3085 int ret, added, bypass_cpu, bypass_slot;
3086 const char *slotname;
3091 slotname = luaL_checkstring(L,3);
3092 bypass_cpu = lua_toboolean(L,4);
3093 bypass_slot = lua_toboolean(L,5);
3098 WARN(_(
"Pilot '%s' with ship '%s' does not have named slot '%s'!"), p->name, _(p->ship->name), slotname );
3111 if ((added > 0) && p->autoweap)
3118 lua_pushboolean(L,added);
3142 int q, removed, matched = 0;
3147 q = luaL_optinteger(L,3,1);
3149 if (lua_isstring(L,2)) {
3150 const char *outfit = luaL_checkstring(L,2);
3153 if (strcmp(outfit,
"all")==0) {
3154 for (
int i=0; i<
array_size(p->outfits); i++) {
3155 if (p->outfits[i]->sslot->required)
3157 if (p->outfits[i]->sslot->locked)
3166 else if (strcmp(outfit,
"cores")==0) {
3167 for (
int i=0; i<
array_size(p->outfits); i++) {
3168 if (!p->outfits[i]->sslot->required)
3183 for (
int i=0; i<
array_size(p->outfits); i++) {
3189 if (p->outfits[i]->outfit != o)
3203 lua_pushnumber( L, removed );
3221 int ret, removed = 0;
3223 const char *slotname = luaL_checkstring(L,2);
3226 WARN(_(
"Pilot '%s' with ship '%s' does not have named slot '%s'!"), p->name, _(p->ship->name), slotname );
3238 lua_pushboolean( L, ret );
3259 lua_pushboolean(L,ret);
3277 for (
int i=0; i<
array_size(p->outfit_intrinsic); i++) {
3285 lua_pushboolean(L,ret);
3288 lua_pushboolean(L,0);
3308 if (lua_isboolean(L,2)) {
3309 if (lua_toboolean(L,2))
3310 p->fuel = p->fuel_max;
3314 else if (lua_isnumber(L,2)) {
3315 p->fuel =
CLAMP( 0, p->fuel_max, lua_tonumber(L,2) );
3318 NLUA_INVALID_PARAMETER(L);
3321 lua_pushnumber(L, p->fuel);
3356 if (!lua_istable(L,2)) {
3357 name = luaL_checkstring(L,2);
3358 value = luaL_checknumber(L,3);
3359 replace = lua_toboolean(L,4);
3360 ss_statsSet( &p->intrinsic_stats, name, value, replace );
3364 replace = lua_toboolean(L,4);
3367 while (lua_next(L,2) != 0) {
3368 name = luaL_checkstring(L,-2);
3369 value = luaL_checknumber(L,-1);
3370 ss_statsSet( &p->intrinsic_stats, name, value, replace );
3390 const char *name = luaL_optstring(L,2,NULL);
3391 int internal = lua_toboolean(L,3);
3423 const char *effectname = luaL_checkstring(L,2);
3424 double duration = luaL_optnumber(L,3,-1.);
3425 double scale = luaL_optnumber(L,4,1.);
3428 if (!
effect_add( &p->effects, efx, duration, scale, p->id ))
3430 lua_pushboolean(L,1);
3433 lua_pushboolean(L,0);
3448 const char *effectname = luaL_checkstring(L,2);
3449 int all = lua_toboolean(L,3);
3469 for (
int i=0; i<
array_size(p->effects); i++) {
3470 Effect *e = &p->effects[i];
3474 lua_setfield(L,-2,
"name");
3476 lua_pushnumber(L,e->
timer);
3477 lua_setfield(L,-2,
"timer");
3480 lua_setfield(L,-2,
"duration");
3483 lua_setfield(L,-2,
"icon");
3485 lua_rawseti(L,-2,i+1);
3503 lua_pushstring( L, p->ai->name );
3521 const char *str = luaL_checkstring(L,2);
3528 lua_pushboolean(L, ret);
3554 kelvins = luaL_checknumber(L, 2);
3555 setOutfits = !lua_toboolean(L,3);
3558 kelvins =
MAX(kelvins, CONST_SPACE_STAR_TEMP);
3561 p->heat_T = kelvins;
3565 for (
int i=0; i <
array_size(p->outfits); i++)
3566 p->outfits[i]->heat_T = kelvins;
3593 a = luaL_optnumber(L, 2, 100.*p->armour / p->armour_max);
3594 s = luaL_optnumber(L, 3, 100.*p->shield / p->shield_max);
3595 st = luaL_optnumber(L,4,0.);
3602 p->armour = a * p->armour_max;
3603 p->shield = s * p->shield_max;
3604 p->stress =
st * p->armour;
3607 if (p->armour > 0.) {
3608 pilot_rmFlag( p, PILOT_DISABLED );
3609 pilot_rmFlag( p, PILOT_DEAD );
3610 pilot_rmFlag( p, PILOT_DEATH_SOUND );
3611 pilot_rmFlag( p, PILOT_EXPLODED );
3612 pilot_rmFlag( p, PILOT_DELETE );
3613 if (pilot_isPlayer(p))
3614 player_rmFlag( PLAYER_DESTROYED );
3616 pilot_rmFlag( p, PILOT_DISABLED_PERM );
3641 a = luaL_optnumber(L, 2, 0.);
3642 s = luaL_optnumber(L, 3, 0.);
3645 p->armour =
CLAMP( 0., p->armour_max, p->armour + a );
3646 p->shield =
CLAMP( 0., p->shield_max, p->shield + s );
3669 double e = luaL_checknumber(L,2);
3670 int absolute = lua_toboolean(L,3);
3673 p->energy =
CLAMP( 0, p->energy_max, e );
3675 p->energy = (e/100.) * p->energy_max;
3712 if (lua_isnone(L,2))
3715 disable = lua_toboolean(L, 2);
3719 pilot_setFlag(p, PILOT_NOBOARD);
3721 pilot_rmFlag(p, PILOT_NOBOARD);
3745 if (lua_isnone(L,2))
3748 disable = lua_toboolean(L, 2);
3752 pilot_setFlag(p, PILOT_NODISABLE);
3754 pilot_rmFlag(p, PILOT_NODISABLE);
3775 double s = luaL_checknumber(L, 2);
3780 pilot_setFlag( p, PILOT_HASSPEEDLIMIT );
3782 pilot_rmFlag( p, PILOT_HASSPEEDLIMIT );
3804 int absolute = lua_toboolean(L,2);
3808 lua_pushnumber(L, p->armour );
3809 lua_pushnumber(L, p->shield );
3812 lua_pushnumber(L,(p->armour_max > 0.) ? p->armour / p->armour_max * 100. : 0. );
3813 lua_pushnumber(L,(p->shield_max > 0.) ? p->shield / p->shield_max * 100. : 0. );
3815 lua_pushnumber(L,
MIN( 1., p->stress / p->armour ) * 100. );
3816 lua_pushboolean(L, pilot_isDisabled(p));
3834 int absolute = lua_toboolean(L,2);
3837 lua_pushnumber(L, p->energy );
3839 lua_pushnumber(L, (p->energy_max > 0.) ? p->energy / p->energy_max * 100. : 0. );
3856 lua_pushnumber(L, p->lockons );
3860#define PUSH_DOUBLE( L, name, value ) \
3861lua_pushstring( L, name ); \
3862lua_pushnumber( L, value ); \
3864#define PUSH_INT( L, name, value ) \
3865lua_pushstring( L, name ); \
3866lua_pushinteger( L, value ); \
3908 PUSH_DOUBLE( L,
"cpu", p->cpu );
3909 PUSH_INT( L,
"cpu_max", p->cpu_max );
3910 PUSH_INT( L,
"crew", (
int)round( p->crew ) );
3911 PUSH_INT( L,
"fuel", p->fuel );
3912 PUSH_INT( L,
"fuel_max", p->fuel_max );
3913 PUSH_INT( L,
"fuel_consumption", p->fuel_consumption );
3914 PUSH_DOUBLE( L,
"mass", p->solid->mass );
3916 PUSH_DOUBLE( L,
"thrust", p->thrust / p->solid->mass );
3917 PUSH_DOUBLE( L,
"speed", p->speed );
3918 PUSH_DOUBLE( L,
"turn", p->turn * 180. / M_PI );
3919 PUSH_DOUBLE( L,
"speed_max", solid_maxspeed(p->solid, p->speed, p->thrust) );
3921 PUSH_DOUBLE( L,
"absorb", p->dmg_absorb );
3922 PUSH_DOUBLE( L,
"armour", p->armour_max );
3923 PUSH_DOUBLE( L,
"shield", p->shield_max );
3924 PUSH_DOUBLE( L,
"energy", p->energy_max );
3925 PUSH_DOUBLE( L,
"armour_regen", p->armour_regen );
3926 PUSH_DOUBLE( L,
"shield_regen", p->shield_regen );
3927 PUSH_DOUBLE( L,
"energy_regen", p->energy_regen );
3929 PUSH_DOUBLE( L,
"ew_detection", p->ew_detection );
3930 PUSH_DOUBLE( L,
"ew_evasion", p->ew_evasion );
3931 PUSH_DOUBLE( L,
"ew_stealth", p->ew_stealth );
3952 const char *str = luaL_optstring(L,2,NULL);
3953 int internal = lua_toboolean(L,3);
3967 if (pilot_isFlag(p,PILOT_STEALTH))
3968 lua_pushnumber( L, p->ew_stealth );
3970 lua_pushnumber( L, p->ew_detection );
4003 lua_pushnumber(L, quantity);
4025 int quantity = luaL_checknumber(L, 3);
4028 NLUA_ERROR( L, _(
"Quantity must be positive for pilot.cargoAdd (if removing, use pilot.cargoRm)") );
4034 lua_pushnumber( L, quantity );
4038static int pilotL_cargoRmHelper( lua_State *L,
int jet )
4047 if (lua_isstring(L, 2)) {
4048 const char *str = lua_tostring(L, 2);
4051 if (strcmp(str,
"all") == 0) {
4053 lua_pushnumber(L, quantity);
4060 quantity = luaL_checknumber(L, 3);
4064 _(
"Quantity must be positive for pilot.cargoRm (if adding, use"
4065 " pilot.cargoAdd)"));
4075 lua_pushnumber(L, quantity);
4096 return pilotL_cargoRmHelper( L, 0 );
4113 return pilotL_cargoRmHelper( L, 1 );
4137 for (
int i=0; i<
array_size(p->commodities); i++) {
4143 lua_pushstring(L,
"name");
4147 lua_pushstring(L,
"c");
4151 lua_pushstring(L,
"q");
4155 lua_pushstring(L,
"m");
4156 lua_pushboolean(L, pc->
id);
4159 lua_rawseti(L,-2,i+1);
4177 lua_pushnumber( L, p->credits );
4222 { .
name =
"stealth", .id = PILOT_STEALTH },
4223 { .name =
"refueling", .id = PILOT_REFUELING },
4224 { .name =
"invisible", .id = PILOT_INVISIBLE },
4225 { .name =
"disabled", .id = PILOT_DISABLED },
4226 { .name =
"takingoff", .id = PILOT_TAKEOFF },
4227 { .name =
"jumpingin", .id = PILOT_HYP_END },
4228 { .name =
"jumpingout", .id = PILOT_HYPERSPACE },
4229 { .name =
"manualcontrol", .id = PILOT_MANUAL_CONTROL },
4230 { .name =
"carried", .id = PILOT_CARRIED },
4231 { .name =
"hailing", .id = PILOT_HAILING },
4232 { .name =
"bribed", .id = PILOT_BRIBED },
4233 { .name =
"boardable", .id = PILOT_BOARDABLE },
4234 { .name =
"nojump", .id = PILOT_NOJUMP },
4235 { .name =
"noland", .id = PILOT_NOLAND },
4236 { .name =
"nodeath", .id = PILOT_NODEATH },
4237 { .name =
"nodisable", .id = PILOT_NODISABLE },
4238 { .name =
"visible", .id = PILOT_VISIBLE },
4239 { .name =
"visplayer", .id = PILOT_VISPLAYER },
4240 { .name =
"hilight", .id = PILOT_HILIGHT },
4241 { .name =
"norender", .id = PILOT_NORENDER },
4242 { .name =
"hide", .id = PILOT_HIDE },
4243 { .name =
"invincible", .id = PILOT_INVINCIBLE },
4244 { .name =
"invinc_player", .id = PILOT_INVINC_PLAYER },
4245 { .name =
"friendly", .id = PILOT_FRIENDLY },
4246 { .name =
"hostile", .id = PILOT_HOSTILE },
4247 { .name =
"combat", .id = PILOT_COMBAT },
4286 const char *name = luaL_optstring( L, 2, NULL );
4290 if (strcmp(
pL_flags[i].name,name)==0) {
4291 lua_pushboolean( L, pilot_isFlag( p,
pL_flags[i].
id ) );
4295 WARN(_(
"Tried to access unknown flag '%s' for pilot '%s'!"), name, p->name);
4303 lua_pushboolean( L, pilot_isFlag( p,
pL_flags[i].
id ) );
4304 lua_setfield(L, -2,
pL_flags[i].name);
4352 lua_pushinteger(L, p->ship->points);
4368 lua_pushboolean(L, p->task==0);
4396 int enable, cleartasks;
4400 if (lua_isnone(L,2))
4403 enable = lua_toboolean(L, 2);
4404 if (lua_isnone(L,3))
4405 cleartasks = enable ^ pilot_isFlag(p, PILOT_MANUAL_CONTROL);
4407 cleartasks = lua_toboolean(L, 3);
4410 int isp = pilot_isPlayer(p);
4413 pilot_setFlag(p, PILOT_MANUAL_CONTROL);
4418 pilot_rmFlag(p, PILOT_MANUAL_CONTROL);
4419 if (pilot_isPlayer(p))
4451 if (p->ai == NULL) {
4452 NLUA_ERROR(L,_(
"Pilot '%s' does not have an AI!"),p->name);
4456 lua_rawgeti( L, LUA_REGISTRYINDEX, p->lua_mem );
4472 lua_pushstring(L, p->ai->name);
4489 lua_pushstring(L, t->
name);
4490 if (t->
dat != LUA_NOREF) {
4491 lua_rawgeti(L, LUA_REGISTRYINDEX, t->
dat);
4512 lua_pushstring(L, t->
name);
4514 lua_pushstring(L, t->
subtask->name);
4535 for (
Task *t=p->task; t!=NULL; t=t->next) {
4538 lua_pushstring(L,t->name);
4539 lua_rawseti(L,-2,n++);
4556 if (t && (t->
dat != LUA_NOREF)) {
4557 lua_rawgeti(L, LUA_REGISTRYINDEX, t->
dat);
4591 const char *task = luaL_checkstring(L,2);
4593 if (pilot_isPlayer(p) && !pilot_isFlag(p,PILOT_MANUAL_CONTROL))
4597 if (!lua_isnoneornil(L,3)) {
4598 lua_pushvalue( L, 3 );
4599 t->
dat = luaL_ref( L, LUA_REGISTRYINDEX );
4618 NLUA_ERROR(L, _(
"Trying to pop task when there are no tasks on the stack."));
4637 double amount = luaL_optinteger(L,3,100);
4638 pilot_rmFlag( p, PILOT_HYP_PREP);
4639 pilot_rmFlag( p, PILOT_HYP_BRAKE );
4640 pilot_rmFlag( p, PILOT_HYP_BEGIN);
4641 pilot_setFlag( p, PILOT_REFUELING);
4643 p->refuel_amount = amount;
4655 if (!pilot_isFlag( p, PILOT_MANUAL_CONTROL)) {
4656 NLUA_ERROR( L, _(
"Pilot is not on manual control.") );
4690 int brake, compensate;
4696 if (lua_isnone(L,3))
4699 brake = lua_toboolean(L,3);
4700 if (lua_isnone(L,4))
4703 compensate = lua_toboolean(L,4);
4711 tsk =
"moveto_nobrake";
4713 tsk =
"moveto_nobrake_raw";
4717 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4749 towards = lua_toboolean(L,3);
4762 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4805 accurate = lua_toboolean(L,3);
4814 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4840 if (!lua_isnoneornil(L,2)) {
4853 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4882 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4911 if (lua_isnoneornil(L,3)) {
4914 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4917 if (lua_isboolean(L,3)) {
4918 int nojump = lua_toboolean(L,3);
4921 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4928 lua_rawseti( L, -2, 1 );
4930 lua_rawseti( L, -2, 2 );
4931 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4938 lua_rawseti( L, -2, 1 );
4940 lua_rawseti( L, -2, 2 );
4941 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4944 NLUA_INVALID_PARAMETER(L);
4967 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
4998 noshoot = lua_toboolean(L,3);
5011 if (jp->target != ss)
5015 if (jp_isFlag( jp, JP_EXITONLY )) {
5016 NLUA_ERROR( L, _(
"Pilot '%s' can't jump out exit only jump '%s'"), p->name, ss->name );
5022 lj.
destid = jp->targetid;
5024 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
5028 NLUA_ERROR( L, _(
"System '%s' is not adjacent to current system '%s'"), ss->name,
cur_system->name );
5048 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
5087 if (lua_isnoneornil(L,2))
5091 noshoot = lua_toboolean(L,3);
5108 NLUA_ERROR( L, _(
"Spob '%s' not found in system '%s'"), pnt->
name,
cur_system->name );
5113 if (p->id == PLAYER_ID)
5117 t->
dat = luaL_ref(L, LUA_REGISTRYINDEX);
5140 if (lua_isnone(L,2))
5143 enable = lua_toboolean(L,2);
5152 pilot_setFlag( p, PILOT_HAILING );
5156 pilot_rmFlag( p, PILOT_HAILING );
5174 Pilot *p, *receiver=NULL;
5178 if (lua_isnoneornil(L,1))
5182 type = luaL_checkstring(L,3);
5183 data = lua_gettop(L) > 3 ? 4 : 0;
5185 if (!lua_istable(L,2)) {
5191 while (lua_next(L, 2) != 0) {
5212 if (p->dockpilot != 0) {
5214 if ((l == NULL) || pilot_isFlag( l, PILOT_DEAD )) {
5235 if (p->parent != 0) {
5237 if ((l == NULL) || pilot_isFlag( l, PILOT_DEAD )) {
5266 if (prev_leader != NULL) {
5272 if (e->
type != ESCORT_TYPE_MERCENARY) {
5273 NLUA_ERROR(L,_(
"Trying to change the leader of pilot '%s' that is a deployed fighter or part of the player fleet!"), p->name);
5281 WARN(_(
"Pilot '%s' not found in followers of '%s'"), p->name, prev_leader->
name );
5285 if (lua_isnoneornil(L, 2)) {
5293 if (p->id == leader->
id)
5294 NLUA_ERROR(L,_(
"Trying to set pilot '%s' to be their own leader!"),p->name);
5296 if ((leader->
parent != 0) && (leader->
parent != p->id)) {
5298 if (leader_leader != NULL)
5299 leader = leader_leader;
5302 p->parent = leader->
id;
5306 if (dockslot != NULL) {
5313 escort_addList( leader, p->ship->name, ESCORT_TYPE_MERCENARY, p->id, 0 );
5316 for (
int i=
array_size(p->escorts)-1; i>=0; i--) {
5319 if (e->
type != ESCORT_TYPE_MERCENARY)
5328 if (pe->
id == p->parent) {
5358 for (
int i=0; i <
array_size(p->escorts); i++) {
5361 if ((pe==NULL) || pilot_isFlag( pe, PILOT_DEAD ) || pilot_isFlag( pe, PILOT_HIDE ))
5364 lua_rawseti(L, -2, idx++);
5388 int k = p->ship->gfx_space->sx * p->tsy + p->tsx;
5389 return &p->ship->polygon[k];
5410 &rpoly, &a->pos, &crash );
5422 if (pilot_isFlag( t, PILOT_INVINCIBLE ))
5426 if (pilot_isFlag( t, PILOT_LANDING) ||
5427 pilot_isFlag( t, PILOT_TAKEOFF ) ||
5428 pilot_isFlag( t, PILOT_NONTARGETABLE))
5462 dmg.
damage = luaL_checknumber(L,2);
5463 dmg.
disable = luaL_optnumber(L,3,0.);
5468 damage =
pilot_hit( p, NULL, parent, &dmg, NULL, LUA_NOREF, 1 );
5472 lua_pushnumber(L, damage);
5521 e = luaL_optnumber(L,3,1.);
5525 m2 = luaL_checknumber(L,2);
5527 x2 = luaL_optvector(L,4,x1);
5528 e = luaL_optnumber(L,5,1.);
5533 double vx = (m1*v1->x + m2*v2->x) / (m1+m2);
5534 double vy = (m1*v1->y + m2*v2->y) / (m1+m2);
5535 vec2_cset( &p1->
solid->
vel, vx, vy );
5537 vec2_cset( &p2->
solid->
vel, vx, vy );
5543 double a1 = -e * (2.*m2)/(m1+m2);
5545 a1 *= ((v1->x-v2->x)*(x1->
x-x2->
x) + (v1->y-v2->y)*(x1->
y-x2->
y)) / norm;
5547 vec2_cadd( &p1->
solid->
vel, a1*(x1->
x-x2->
x), a1*(x1->
y-x2->
y) );
5549 double a2 = -e * (2.*m1)/(m2+m1);
5551 a2 *= ((v2->x-v1->x)*(x2->
x-x1->
x) + (v2->y-v1->y)*(x2->
y-x1->
y)) / norm;
5552 vec2_cadd( &p2->
solid->
vel, a2*(x2->
x-x1->
x), a2*(x2->
y-x1->
y) );
5557 double vx = (m1*v1->x + m2*v2->x) / (m1+m2);
5558 double vy = (m1*v1->y + m2*v2->y) / (m1+m2);
5559 vec2_cset( &p1->
solid->
vel, e*v1->
x + (1.-e)*vx, e*v1->y + (1.-e)*vy );
5561 vec2_cset( &p2->
solid->
vel, e*v2->
x + (1.-e)*vx, e*v2->y + (1.-e)*vy );
5594 if (lua_gettop(L) > 0)
5595 state = lua_toboolean(L, 1);
5602 debug_setFlag(DEBUG_MARK_EMITTER);
5604 debug_rmFlag(DEBUG_MARK_EMITTER);
5607 NLUA_ERROR(L, _(
"Requires a debug build."));
5626 const char *str = luaL_checkstring(L,2);
5644 const char *str = luaL_checkstring(L,2);
5646 if (p->shipvar==NULL)
5662 const char *str = luaL_checkstring(L,2);
5683 w = p->ship->gfx_space->sw;
5684 h = p->ship->gfx_space->sh;
5685 if (canvas_new( &lc, w, h ))
5686 NLUA_ERROR( L, _(
"Error setting up framebuffer!"));
5691 lua_pushcanvas( L, lc );
5710 if ((lc->
tex->
w < p->ship->gfx_space->sw) || (lc->
tex->
h < p->ship->gfx_space->sh))
5711 WARN(_(
"Canvas is too small to fully render '%s': %.0f x %.0f < %.0f x %.0f"),
5713 p->ship->gfx_space->sw, p->ship->gfx_space->sh );
5718 lua_pushnumber( L, p->ship->gfx_space->sw );
5719 lua_pushnumber( L, p->ship->gfx_space->sh );
Task * ai_newtask(lua_State *L, Pilot *p, const char *func, int subtask, int pos)
Creates a new AI task.
Task * ai_curTask(Pilot *pilot)
Gets the current running task.
void ai_refuel(Pilot *refueler, unsigned int target)
Has a pilot attempt to refuel the other.
void ai_cleartasks(Pilot *p)
Clears the pilot's tasks.
void ai_destroy(Pilot *p)
Destroys the ai part of the pilot.
int ai_pinit(Pilot *p, const char *ai)
Initializes the pilot in the ai.
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_copy(basic_type, ptr_array)
Returns a shallow copy of the input array.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void cam_update(double dt)
Updates the camera.
void RotatePolygon(CollPoly *rpolygon, CollPoly *ipolygon, float theta)
Rotates a polygon.
int CollidePolygon(const CollPoly *at, const vec2 *ap, const CollPoly *bt, const vec2 *bp, vec2 *crash)
Checks whether or not two polygons collide. /!\ The function is not symmetric: the points of polygon ...
int dtype_get(const char *name)
Gets the id of a dtype based on name.
const char * dtype_damageTypeToStr(int type)
Gets the human readable string from damage type.
int effect_rm(Effect **efxlist, const EffectData *efx, int all)
Removes an effect from an effect list.
const EffectData * effect_get(const char *name)
Gets an effect by name.
void effect_clear(Effect **efxlist)
Clears an effect list, removing all active effects.
int effect_add(Effect **efxlist, const EffectData *efx, double duration, double scale, unsigned int parent)
Adds an effect to an effect list.
void escort_rmListIndex(Pilot *p, int i)
Remove from escorts list.
int escort_addList(Pilot *p, const char *ship, EscortType_t type, unsigned int id, int persist)
Adds an escort to the escort list of a pilot.
int areEnemies(int a, int b)
Checks whether two factions are enemies.
int areAllies(int a, int b)
Checks whether two factions are allies or not.
void gui_setNav(void)
Player just changed their nav computer target.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
int lvar_addArray(lvar **arr, lvar *new_var, int sort)
Adds a var to a var array.
void lvar_rmArray(lvar **arr, lvar *rm_var)
Removes a var from a var array.
lvar * lvar_get(lvar *arr, const char *str)
Gets a lua var by name.
lvar lvar_tovar(lua_State *L, const char *name, int idx)
Gets a lua variable from an index from a lua state.
int lvar_push(lua_State *L, const lvar *v)
Pushes a lua var to a lua state.
Header file with generic functions and naev-specifics.
int nlua_loadAsteroid(nlua_env env)
Loads the asteroid library.
int lua_isasteroid(lua_State *L, int ind)
Checks to see if ind is a asteroid.
LuaAsteroid_t * luaL_checkasteroid(lua_State *L, int ind)
Gets asteroid at index or raises error if there is no asteroid at index.
LuaAsteroid_t * lua_pushasteroid(lua_State *L, LuaAsteroid_t asteroid)
Pushes a asteroid on the stack.
Asteroid * luaL_validasteroid(lua_State *L, int ind)
Gets asteroid at index raising an error if type doesn't match.
glColour * lua_pushcolour(lua_State *L, glColour colour)
Pushes a colour on the stack.
Commodity ** lua_pushcommodity(lua_State *L, Commodity *commodity)
Pushes a commodity on the stack.
Commodity * luaL_validcommodity(lua_State *L, int ind)
Makes sure the commodity is valid or raises a Lua error.
LuaFaction * lua_pushfaction(lua_State *L, LuaFaction faction)
Pushes a faction on the stack.
LuaFaction luaL_validfaction(lua_State *L, int ind)
Gets faction (or faction name) at index, raising an error if type isn't a valid faction.
int lua_isfaction(lua_State *L, int ind)
Checks to see if ind is a faction.
LuaFaction lua_tofaction(lua_State *L, int ind)
Gets faction at index.
LuaJump * lua_pushjump(lua_State *L, LuaJump jump)
Pushes a jump on the stack.
int lua_isjump(lua_State *L, int ind)
Checks to see if ind is a jump.
LuaJump * lua_tojump(lua_State *L, int ind)
This module allows you to handle the jumps from Lua.
const Outfit * luaL_validoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
static int pilotL_setVisible(lua_State *L)
Marks the pilot as always visible for other pilots.
static int pilotL_intrinsicGet(lua_State *L)
Allows getting an intrinsic stats of a pilot, or gets all of them if name is not specified.
static int pilotL_getVisible(lua_State *L)
Gets visible pilots to a pilot within a certain distance.
static int pilotL_isStopped(lua_State *L)
Checks to see if a pilot is stopped.
static int pilotL_clone(lua_State *L)
Clones a pilot. It will share nearly all properties including outfits.
static int pilotL_setHide(lua_State *L)
Sets the pilot's hide status.
static int pilotL_calcStats(lua_State *L)
Forces a recomputation of the pilots' stats.
static int pilotL_refuel(lua_State *L)
Tries to refuel a pilot.
static int pilotL_eq(lua_State *L)
Checks to see if pilot and p are the same.
static int pilotL_moveto(lua_State *L)
Makes the pilot move to a position.
static int pilotL_hailPlayer(lua_State *L)
Marks the pilot as hailing the player.
static int pilotL_setEnergy(lua_State *L)
Sets the energy of a pilot.
static int pilotL_setFriendly(lua_State *L)
Controls the pilot's friendliness towards the player.
static int pilotL_cargoJet(lua_State *L)
Tries to remove a cargo from a pilot's ship and jet it into space.
static int pilotL_activeWeapset(lua_State *L)
Gets the ID (number from 1 to 10) of the current active weapset.
static int pilotL_outfitRm(lua_State *L)
Removes an outfit from a pilot.
static int pilotL_outfitRmIntrinsic(lua_State *L)
Removes an intrinsic outfit from the pilot.
static int pilotL_actives(lua_State *L)
Gets the active outfits and their states of the pilot.
static int pilotL_cargoFree(lua_State *L)
Gets the free cargo space the pilot has.
static int pilotL_setNoLand(lua_State *L)
Enables or disables landing for a pilot.
static int pilotL_targetAsteroid(lua_State *L)
Gets the asteroid target of the pilot.
static int pilotL_setActiveBoard(lua_State *L)
Allows the pilot to be boarded when not disabled.
static int pilotL_brake(lua_State *L)
Makes the pilot brake.
static int pilotL_withPlayer(lua_State *L)
Checks to see if pilot is with player.
static int pilotL_spaceworthy(lua_State *L)
Checks the pilot's spaceworthiness.
static int pilotL_render(lua_State *L)
Renders the pilot to a canvas.
static int pilotL_runaway(lua_State *L)
Makes the pilot runaway from another pilot.
static int pilotL_land(lua_State *L)
Tells the pilot to land.
LuaPilot lua_topilot(lua_State *L, int ind)
Lua bindings to interact with pilots.
static int pilotL_memory(lua_State *L)
Gets a pilots memory table.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
static int pilotL_choosePoint(lua_State *L)
Returns a suitable jumpin spot for a given pilot. Lua usage parameter: point = pilot....
static int pilotL_setNoClear(lua_State *L)
Enables or disables making the the pilot exempt from pilot.clear().
static int pilotL_canSpawn(lua_State *L)
Returns if pilots can can spawn naturally in the current system.
static int pilotL_setNoJump(lua_State *L)
Enables or disables a pilot's hyperspace engine.
static int pilotL_setLeader(lua_State *L)
Set a pilots leader.
static int pilotL_taskclear(lua_State *L)
Clears all the tasks of the pilot.
static int pilotL_nav(lua_State *L)
Gets the nav target of the pilot.
static int pilotL_credits(lua_State *L)
Handles the pilots credits.
static int pilotL_taskdata(lua_State *L)
Gets the data of the task the pilot is currently doing.
static int pilotL_setInvisible(lua_State *L)
Sets the pilot's invisibility status.
static int pilotL_exists(lua_State *L)
Checks to see if pilot is still in the system and alive.
static int pilotL_hasIllegal(lua_State *L)
Checks to see if the pilot has illegal stuff to a faction.
static int pilotL_setTemp(lua_State *L)
Sets the temperature of a pilot.
static int pilotL_clearSelect(lua_State *L)
Removes all pilots belonging to a faction from the system.
static int pilotL_outfitRmSlot(lua_State *L)
Removes an outfit from a pilot's named slot.
Pilot * luaL_validpilot(lua_State *L, int ind)
Makes sure the pilot is valid or raises a Lua error.
static int pilotL_toggleSpawn(lua_State *L)
Disables or enables pilot spawning in the current system.
static int pilotL_getEnergy(lua_State *L)
Gets the pilot's energy.
static int pilotL_points(lua_State *L)
Gets the points the pilot costs.
static int pilotL_showEmitters(lua_State *L)
Toggles the emitter marker.
static int pilotL_msg(lua_State *L)
Sends a message to another pilot.
static int pilotL_setBribed(lua_State *L)
Makes pilot act as if bribed by the player.
static int pilotL_cargoRm(lua_State *L)
Tries to remove cargo from the pilot's ship.
static int pilotL_knockback(lua_State *L)
Knocks back a pilot. It can either accept two pilots, or a pilot and an element represented by mass,...
static int pilotL_hookClear(lua_State *L)
Clears the pilot's hooks.
static int pilotL_setNoRender(lua_State *L)
Sets the pilot's norender status.
static int pilotL_taskname(lua_State *L)
Gets the name of the task the pilot is currently doing.
static int pilotL_intrinsicReset(lua_State *L)
Resets the intrinsic stats of a pilot.
static int pilotL_pushtask(lua_State *L)
Pushes a new task to the pilot's AI.
static int pilotL_mothership(lua_State *L)
Gets a pilots mothership (only exists for deployed pilots). Guaranteed to exist or will be nil.
static int pilotL_getHealth(lua_State *L)
Gets the pilot's health.
static int pilotL_cargoAdd(lua_State *L)
Tries to add cargo to the pilot's ship.
static int pilot_outfitAddSlot(Pilot *p, const Outfit *o, PilotOutfitSlot *s, int bypass_slot, int bypass_cpu)
Adds an outfit to a specific slot.
static int pilotL_damage(lua_State *L)
Damages a pilot.
static int pilotL_ai(lua_State *L)
Gets the pilot's AI.
static int pilotL_cooldownCycle(lua_State *L)
Makes the pilot do an instant full cooldown cycle.
static int pilotL_velocity(lua_State *L)
Gets the pilot's velocity.
static int pilotL_disable(lua_State *L)
Disables a pilot.
static int pilotL_comm(lua_State *L)
Sends a message to the target or player if no target is passed.
static int pilotL_tryStealth(lua_State *L)
Tries to make the pilot stealth.
static int pilotL_setNoboard(lua_State *L)
Sets the ability to board the pilot.
static int pilotL_fillAmmo(lua_State *L)
Fills up the pilot's ammo.
static const luaL_Reg pilotL_methods[]
static int pilotL_setHealth(lua_State *L)
Sets the health of a pilot.
static int pilotL_getInrange(lua_State *L)
Gets visible pilots to a pilot within a certain distance.
static int pilotL_changeAI(lua_State *L)
Changes the pilot's AI.
static int pilotL_setTarget(lua_State *L)
Sets the pilot target of the pilot.
static int pilotL_getEnemies(lua_State *L)
Gets hostile pilots to a pilot (or faction) within a certain distance.
static int pilotL_name(lua_State *L)
Gets the pilot's current (translated) name.
static int pilotL_getColour(lua_State *L)
Gets the pilot's colour based on hostility or friendliness to the player.
static int pilotL_scandone(lua_State *L)
Checks to see if a pilot is done scanning its target.
static Task * pilotL_newtask(lua_State *L, Pilot *p, const char *task)
Does a new task.
static int pilotL_shipvarPeek(lua_State *L)
Peeks at a ship variable.
static int pilotL_getShipStat(lua_State *L)
Gets a shipstat from a Pilot by name, or a table containing all the ship stats if not specified.
static int pilotL_setNoDisable(lua_State *L)
Sets the ability of the pilot to be disabled.
static int pilotL_cargoHas(lua_State *L)
Checks to see how many tonnes of a specific type of cargo the pilot has.
static int pilotL_setFuel(lua_State *L)
Sets the fuel of a pilot.
static int pilotL_stealth(lua_State *L)
Tells the pilot to try to stealth.
static int pilotL_outfits(lua_State *L)
Gets a mapping of outfit slot IDs and outfits of a pilot.
static int pilotL_outfitSlot(lua_State *L)
Checks to see outfit a pilot has in a slot.
static int pilotL_outfitsList(lua_State *L)
Gets the outfits of a pilot.
static int pilotL_ainame(lua_State *L)
Gets the name of the task the pilot is currently doing.
static int outfit_compareActive(const void *slot1, const void *slot2)
qsort compare function for active outfits.
static int pilotL_shipvarPop(lua_State *L)
Pops a ship variable.
static int pilotL_setCooldown(lua_State *L)
Starts or stops a pilot's cooldown mode.
static int pilotL_face(lua_State *L)
Makes the pilot face a target.
static int pilotL_clear(lua_State *L)
Clears the current system of pilots. Used for epic battles and such.
static int pilotL_rename(lua_State *L)
Changes the pilot's name.
static int pilotL_mass(lua_State *L)
Gets the mass of a pilot.
static const struct pL_flag pL_flags[]
static int pilotL_collisionTest(lua_State *L)
Tests to see if two ships collide.
static int pilotL_setHostile(lua_State *L)
Controls the pilot's hostility towards the player.
static int pilotL_getAllies(lua_State *L)
Gets friendly pilots to a pilot (or faction) within a certain distance.
static int pilotL_dir(lua_State *L)
Gets the pilot's direction.
static int pilotL_setPosition(lua_State *L)
Sets the pilot's position.
static int pilotL_attack(lua_State *L)
Makes the pilot attack another pilot.
static int pilotL_setFlagWrapper(lua_State *L, int flag)
Wrapper to simplify flag setting stuff.
int nlua_loadPilot(nlua_env env)
Loads the pilot library.
static int pilotL_setSpeedLimit(lua_State *L)
Limits the speed of a pilot.
static int pilotL_control(lua_State *L)
Sets manual control of the pilot.
static int pilotL_followers(lua_State *L)
Get all of a pilots followers.
static int pilotL_outfitToggle(lua_State *L)
Toggles an outfit.
static int pilotL_leader(lua_State *L)
Gets a pilots leader. Guaranteed to exist or will be nil.
static int pilotL_outfitGet(lua_State *L)
Gets a pilot's outfit by ID.
static int pilotL_temp(lua_State *L)
Gets the temperature of a pilot.
static int pilotL_weapsetHeat(lua_State *L)
Gets heat information for a weapon set.
static int pilotL_setHilight(lua_State *L)
Makes pilot stand out on radar and the likes.
static int pilotL_shipvarPush(lua_State *L)
Pushes a ship variable.
static int pilotL_outfitAddIntrinsic(lua_State *L)
Adds an intrinsic outfit to the pilot.
static int pilotL_addHealth(lua_State *L)
Adds health to a pilot.
static int pilotL_getLockon(lua_State *L)
Gets the lockons on the pilot.
static int pilotL_getDetectedDistance(lua_State *L)
Gets the distance that a pilot can be currently detect at.
static int pilotL_effectRm(lua_State *L)
Removes an effect from the pilot.
static int pilotL_remove(lua_State *L)
Removes a pilot without explosions or anything.
static int pilotL_intrinsicSet(lua_State *L)
Allows setting intrinsic stats of a pilot.
static int pilotL_kill(lua_State *L)
Kills a pilot.
static int pilotL_setFaction(lua_State *L)
Sets the pilot's faction.
int lua_ispilot(lua_State *L, int ind)
Checks to see if ind is a pilot.
static int pilotL_outfitReady(lua_State *L)
Sees if an outfit is ready to use.
static int pilotL_position(lua_State *L)
Gets the pilot's position.
static int pilotL_getStats(lua_State *L)
Gets stats of the pilot.
static int pilotL_poptask(lua_State *L)
Pops the current task from the pilot's AI.
static int pilotL_gather(lua_State *L)
Makes the pilot gather stuff.
static int pilotL_setInvincPlayer(lua_State *L)
Sets the pilot's invincibility status towards the player.
static int pilotL_cargoList(lua_State *L)
Lists the cargo the pilot has.
static int pilotL_setNoDeath(lua_State *L)
Makes it so the pilot never dies, stays at 1. armour.
static int pilotL_id(lua_State *L)
Gets the ID of the pilot.
static int pilotL_getHostile(lua_State *L)
Returns whether the pilot is hostile to the player.
static int pilotL_board(lua_State *L)
Makes the pilot board another pilot.
static int pilotL_broadcast(lua_State *L)
Makes the pilot broadcast a message.
static int pilotL_cooldown(lua_State *L)
Gets a pilot's cooldown state.
static int pilotL_setDir(lua_State *L)
Sets the pilot's direction.
static int pilotL_task(lua_State *L)
Gets the name and data of a pilot's current task.
static int pilotL_inrangeAsteroid(lua_State *L)
Checks to see if an asteroid is in range of a pilot.
static int pilotL_setVelocity(lua_State *L)
Sets the pilot's velocity.
static int pilotL_taskstack(lua_State *L)
Gets the name of all the pilot's current tasks (not subtasks).
static int pilotL_inrange(lua_State *L)
Checks to see if a target pilot is in range of a pilot.
static int pilotL_evasion(lua_State *L)
Gets the pilot's evasion.
static int pilotL_setInvincible(lua_State *L)
Sets the pilot's invincibility status.
LuaPilot luaL_checkpilot(lua_State *L, int ind)
Gets pilot at index or raises error if there is no pilot at index.
static int pilotL_outfitAdd(lua_State *L)
Adds an outfit to a pilot.
static int pilotL_follow(lua_State *L)
Makes the pilot follow another pilot.
static int pilotL_effectAdd(lua_State *L)
Adds an effect to a pilot.
static int pilotL_outfitAddSlot(lua_State *L)
Adds an outfit to a pilot by slot name.
static int pilotL_ship(lua_State *L)
Gets the pilot's ship.
static int pilotL_flags(lua_State *L)
Gets the pilot's flags.
static int pilotL_hyperspace(lua_State *L)
Tells the pilot to hyperspace.
static int pilotL_getPilots(lua_State *L)
Gets the pilots available in the system by a certain criteria.
static int pilotL_setVisplayer(lua_State *L)
Marks the pilot as always visible for the player.
static int pilotL_effectGet(lua_State *L)
Gets the effects on a pilot.
static int pilotL_faction(lua_State *L)
Gets the pilot's faction.
static int pilotL_setTargetAsteroid(lua_State *L)
Sets the pilot's asteroid target.
static int pilotL_renderTo(lua_State *L)
Renders the pilot to a canvas.
static int pilotL_target(lua_State *L)
Gets the pilot target of the pilot.
static int pilotL_weapset(lua_State *L)
Gets the weapset weapon of the pilot.
static int pilotL_idle(lua_State *L)
Checks to see if the pilot is idle.
static int pilotL_effectClear(lua_State *L)
Clears the effect on a pilot.
static int pilotL_add(lua_State *L)
Adds a ship with an AI and faction to the system (instead of a predefined fleet).
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
int nlua_loadShip(nlua_env env)
Loads the ship library.
const Ship * luaL_validship(lua_State *L, int ind)
Makes sure the ship is valid or raises a Lua error.
LuaSpob lua_tospob(lua_State *L, int ind)
This module allows you to handle the spobs from Lua.
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
Spob * luaL_validspob(lua_State *L, int ind)
Gets a spob directly.
int lua_isspob(lua_State *L, int ind)
Checks to see if ind is a spob.
LuaSystem * lua_pushsystem(lua_State *L, LuaSystem sys)
Pushes a system on the stack.
StarSystem * luaL_validsystem(lua_State *L, int ind)
Gets system (or system name) at index raising an error if type doesn't match.
LuaSystem lua_tosystem(lua_State *L, int ind)
Lua system module.
int lua_issystem(lua_State *L, int ind)
Checks to see if ind is a system.
glTexture ** lua_pushtex(lua_State *L, glTexture *texture)
Pushes a texture on the stack.
int lua_isvector(lua_State *L, int ind)
Checks to see if ind is a vector.
vec2 * luaL_checkvector(lua_State *L, int ind)
Gets vector at index making sure type is valid.
vec2 * lua_tovector(lua_State *L, int ind)
Represents a 2D vector in Lua.
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
double ntime_convertSeconds(ntime_t t)
Converts the time to seconds.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
int outfit_isBeam(const Outfit *o)
Checks if outfit is a beam type weapon.
int outfit_isLauncher(const Outfit *o)
Checks if outfit is a weapon launcher.
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.
const char * outfit_getType(const Outfit *o)
Gets the outfit's specific type.
int outfit_isMod(const Outfit *o)
Checks if outfit is a ship modification.
const Damage * outfit_damage(const Outfit *o)
Gets the outfit's damage.
double outfit_duration(const Outfit *o)
Gets the outfit's duration.
double outfit_cooldown(const Outfit *o)
Gets the outfit's cooldown.
int outfit_isBolt(const Outfit *o)
Checks if outfit is bolt type weapon.
double outfit_delay(const Outfit *o)
Gets the outfit's delay.
int outfit_fitsSlotType(const Outfit *o, const OutfitSlot *s)
Checks to see if an outfit fits a slot type (ignoring size).
char pilot_getFactionColourChar(const Pilot *p)
Gets the faction colour char, works like faction_getColourChar but for a pilot.
void pilot_choosePoint(vec2 *vp, Spob **spob, JumpPoint **jump, int lf, int ignore_rules, int guerilla)
Finds a spawn point for a pilot.
int pilot_isHostile(const Pilot *p)
Checks to see if pilot is hostile to the player.
void pilot_updateDisable(Pilot *p, unsigned int shooter)
Handles pilot disabling. Set or unset the disable status depending on health and stress values.
void pilot_cooldown(Pilot *p, int dochecks)
Begins active cooldown, reducing hull and outfit temperatures.
unsigned int pilot_create(const Ship *ship, const char *name, int faction, const char *ai, const double dir, const vec2 *pos, const vec2 *vel, const PilotFlags flags, unsigned int dockpilot, int dockslot)
Creates a new pilot.
void pilot_rmHostile(Pilot *p)
Unmarks a pilot as hostile to player.
void pilot_msg(Pilot *p, Pilot *receiver, const char *type, unsigned int idx)
Sends a message.
int pilot_validEnemy(const Pilot *p, const Pilot *target)
Checks to see if a pilot is a valid enemy for another pilot.
int pilot_areEnemies(const Pilot *p, const Pilot *target)
Like areEnemies but for pilots.
void pilots_clear(void)
Clears all the pilots except the player and clear-exempt pilots.
Pilot * pilot_getTarget(Pilot *p)
Gets the target of a pilot using a fancy caching system.
ntime_t pilot_hyperspaceDelay(Pilot *p)
Calculates the hyperspace delay for a pilot.
void pilot_dead(Pilot *p, unsigned int killer)
Pilot is dead, now will slowly explode.
void pilot_cooldownEnd(Pilot *p, const char *reason)
Terminates active cooldown.
credits_t pilot_modCredits(Pilot *p, credits_t amount)
Modifies the amount of credits the pilot has.
unsigned int pilot_getNearestEnemy(const Pilot *p)
Gets the nearest enemy to the pilot.
void pilot_setFriendly(Pilot *p)
Marks pilot as friendly to player.
int pilot_validTarget(const Pilot *p, const Pilot *target)
Checks to see if a pilot is a valid target for another pilot.
PilotOutfitSlot * pilot_getDockSlot(Pilot *p)
Gets the dock slot of the pilot.
int pilot_hasIllegal(const Pilot *p, int faction)
Checks to see if the pilot has illegal stuf to a faction.
void pilot_setCommMsg(Pilot *p, const char *s)
Sets the overhead communication message of the pilot.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
void pilot_broadcast(Pilot *p, const char *msg, int ignore_int)
Has the pilot broadcast a message.
void pilot_setHostile(Pilot *p)
Marks pilot as hostile to player.
const glColour * pilot_getColour(const Pilot *p)
Gets a pilot's colour.
static Pilot ** pilot_stack
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
int pilot_canTarget(const Pilot *p)
Same as pilot_validTarget but without the range check.
void pilot_rmFriendly(Pilot *p)
Unmarks a pilot as friendly to player.
int pilot_areAllies(const Pilot *p, const Pilot *target)
Like areAllies but for pilots.
int pilot_getJumps(const Pilot *p)
Gets the amount of jumps the pilot has left.
void pilot_delete(Pilot *p)
Deletes a pilot.
double pilot_hit(Pilot *p, const Solid *w, const Pilot *pshooter, const Damage *dmg, const Outfit *outfit, int lua_mem, int reset)
Damages the pilot.
void pilot_renderFramebuffer(Pilot *p, GLuint fbo, double fw, double fh)
Renders a pilot to a framebuffer.
void pilot_sample_trails(Pilot *p, int none)
Updates the given pilot's trail emissions.
void pilot_setTarget(Pilot *p, unsigned int id)
Sets the target of the pilot.
unsigned int pilot_clone(const Pilot *ref)
Clones an existing pilot.
int pilot_cargoRmAll(Pilot *pilot, int cleanup)
Gets rid of all cargo from pilot. Can remove mission cargo.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoRm(Pilot *pilot, const Commodity *cargo, int quantity)
Tries to get rid of quantity cargo from pilot.
int pilot_cargoOwned(const Pilot *pilot, const Commodity *cargo)
Gets how many of the commodity a pilot has.
int pilot_cargoJet(Pilot *p, const Commodity *cargo, int quantity, int simulate)
Tries to get rid of quantity cargo from pilot, jetting it into space.
int pilot_cargoAdd(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Tries to add quantity of cargo to pilot.
int pilot_inRangePilot(const Pilot *p, const Pilot *target, double *dist2)
Check to see if a pilot is in sensor range of another.
int pilot_ewScanCheck(const Pilot *p)
Checks to see if a scan is done.
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%)..
int pilot_inRangeAsteroid(const Pilot *p, int ast, int fie)
Check to see if an asteroid is in sensor range of the pilot.
int pilot_stealth(Pilot *p)
Stealths a pilot.
double pilot_heatEfficiencyMod(double T, double Tb, double Tc)
Returns a 0:1 modifier representing efficiency (1. being normal).
double pilot_heatFirePercent(double T)
Returns a 0:2 level of fire, 0:1 is the accuracy point, 1:2 is fire rate point.
void pilot_clearHooks(Pilot *p)
Clears the pilots hooks.
int pilot_rmOutfit(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot.
int pilot_outfitLInit(Pilot *pilot, PilotOutfitSlot *po)
Runs the pilot's Lua outfits init script for an outfit.
void pilot_updateMass(Pilot *pilot)
Updates the pilot stats after mass change.
int pilot_maxAmmoO(const Pilot *p, const Outfit *o)
Gets the maximum available ammo for a pilot for a specific outfit.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
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_rmOutfitRaw(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot without doing any checks.
PilotOutfitSlot * pilot_getSlotByName(Pilot *pilot, const char *name)
Gets the outfit slot by name.
int pilot_reportSpaceworthy(const Pilot *p, char *buf, int bufSize)
Pilot safety report - makes sure stats are safe.
int pilot_addOutfitTest(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s, int warn)
Tests to see if an outfit can be added.
int pilot_rmOutfitIntrinsic(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from an intrinsic slot.
int pilot_addOutfitRaw(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
Adds an outfit to the pilot, ignoring CPU or other limits.
int pilot_addOutfitIntrinsic(Pilot *pilot, const Outfit *outfit)
Adds an outfit as an intrinsic slot.
void pilot_getRateMod(double *rate_mod, double *energy_mod, const Pilot *p, const Outfit *o)
Gets applicable fire rate and energy modifications for a pilot's weapon.
PilotWeaponSetOutfit * pilot_weapSetList(Pilot *p, int id)
Lists the items in a pilot weapon set.
int pilot_outfitOn(Pilot *p, PilotOutfitSlot *o)
Enable a given active outfit.
void pilot_weaponAuto(Pilot *p)
Tries to automatically set and create the pilot's weapon set.
const char * pilot_weapSetName(Pilot *p, int id)
Gets the name of a weapon set.
int pilot_outfitOff(Pilot *p, PilotOutfitSlot *o)
Disables a given active outfit.
void player_hailStart(void)
Starts the hail sounds and aborts autoNav.
void player_targetSet(unsigned int id)
Sets the player's target.
void player_autonavAbort(const char *reason)
Aborts autonav.
int ss_statsGetLua(lua_State *L, const ShipStats *s, const char *name, int internal)
Gets a ship stat value by name and pushes it to Lua.
int ss_statsInit(ShipStats *stats)
Initializes a stat structure.
int ss_statsSet(ShipStats *s, const char *name, double value, int overwrite)
Sets a ship stat by name.
StarSystem * system_getIndex(int id)
Get the system by its index.
int space_calcJumpInPos(const StarSystem *in, const StarSystem *out, vec2 *pos, vec2 *vel, double *dir, const Pilot *p)
Calculates the jump in pos for a pilot.
Represents a single asteroid.
Represents a polygon used for collision detection.
Core damage that an outfit does.
A ship outfit, depends radically on the type.
OutfitAfterburnerData afb
Stores a pilot commodity.
const Commodity * commodity
Stores an outfit the pilot has.
A pilot Weapon Set Outfit.
The representation of an in-game pilot.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Contains a mission variable.
Small struct to handle flags.
void weapon_clear(void)
Clears all the weapons, does NOT free the layers.
void weapon_hitAI(Pilot *p, const Pilot *shooter, double dmg)
Informs the AI if needed that it's been hit.