naev 0.11.5
nlua_outfit.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
11
12#include "naev.h"
15#include "nlua_outfit.h"
16
17#include "array.h"
18#include "log.h"
19#include "damagetype.h"
20#include "nlua_faction.h"
21#include "nlua_pilot.h"
22#include "nlua_ship.h"
23#include "nlua_tex.h"
24#include "nluadef.h"
25#include "player.h"
26#include "rng.h"
27#include "slots.h"
28
29/* Outfit metatable methods. */
30static int outfitL_eq( lua_State *L );
31static int outfitL_get( lua_State *L );
32static int outfitL_getAll( lua_State *L );
33static int outfitL_name( lua_State *L );
34static int outfitL_nameRaw( lua_State *L );
35static int outfitL_shortname( lua_State *L );
36static int outfitL_type( lua_State *L );
37static int outfitL_typeBroad( lua_State *L );
38static int outfitL_cpu( lua_State *L );
39static int outfitL_mass( lua_State *L );
40static int outfitL_heatFor( lua_State *L );
41static int outfitL_slot( lua_State *L );
42static int outfitL_limit( lua_State *L );
43static int outfitL_icon( lua_State *L );
44static int outfitL_price( lua_State *L );
45static int outfitL_description( lua_State *L );
46static int outfitL_summary( lua_State *L );
47static int outfitL_unique( lua_State *L );
48static int outfitL_friendlyfire( lua_State *L );
49static int outfitL_pointdefense( lua_State *L );
50static int outfitL_miss_ships( lua_State *L );
51static int outfitL_miss_asteroids( lua_State *L );
52static int outfitL_toggleable( lua_State *L );
53static int outfitL_getShipStat( lua_State *L );
54static int outfitL_weapStats( lua_State *L );
55static int outfitL_specificStats( lua_State *L );
56static int outfitL_illegality( lua_State *L );
57static int outfitL_tags( lua_State *L );
58static const luaL_Reg outfitL_methods[] = {
59 { "__tostring", outfitL_name },
60 { "__eq", outfitL_eq },
61 { "get", outfitL_get },
62 { "getAll", outfitL_getAll },
63 { "name", outfitL_name },
64 { "nameRaw", outfitL_nameRaw },
65 { "shortname", outfitL_shortname },
66 { "type", outfitL_type },
67 { "typeBroad", outfitL_typeBroad },
68 { "cpu", outfitL_cpu },
69 { "mass", outfitL_mass },
70 { "heatFor", outfitL_heatFor },
71 { "slot", outfitL_slot },
72 { "limit", outfitL_limit },
73 { "icon", outfitL_icon },
74 { "price", outfitL_price },
75 { "description", outfitL_description },
76 { "summary", outfitL_summary },
77 { "unique", outfitL_unique },
78 { "friendlyfire", outfitL_friendlyfire },
79 { "pointdefense", outfitL_pointdefense },
80 { "missShips", outfitL_miss_ships },
81 { "missAsteroids", outfitL_miss_asteroids },
82 { "toggleable", outfitL_toggleable },
83 { "shipstat", outfitL_getShipStat },
84 { "weapstats", outfitL_weapStats },
85 { "specificstats", outfitL_specificStats },
86 { "illegality", outfitL_illegality },
87 { "tags", outfitL_tags },
88 {0,0}
89};
97int nlua_loadOutfit( nlua_env env )
98{
99 nlua_register(env, OUTFIT_METATABLE, outfitL_methods, 1);
100 return 0;
101}
102
124const Outfit* lua_tooutfit( lua_State *L, int ind )
125{
126 return *((const Outfit**) lua_touserdata(L,ind));
127}
135const Outfit* luaL_checkoutfit( lua_State *L, int ind )
136{
137 if (lua_isoutfit(L,ind))
138 return lua_tooutfit(L,ind);
139 luaL_typerror(L, ind, OUTFIT_METATABLE);
140 return NULL;
141}
149const Outfit* luaL_validoutfit( lua_State *L, int ind )
150{
151 const Outfit *o;
152
153 if (lua_isoutfit(L, ind))
154 o = luaL_checkoutfit(L,ind);
155 else if (lua_isstring(L, ind))
156 o = outfit_get( lua_tostring(L, ind) );
157 else {
158 luaL_typerror(L, ind, OUTFIT_METATABLE);
159 return NULL;
160 }
161
162 if (o == NULL)
163 NLUA_ERROR(L, _("Outfit is invalid."));
164
165 return o;
166}
174const Outfit** lua_pushoutfit( lua_State *L, const Outfit *outfit )
175{
176 const Outfit **o = (const Outfit**) lua_newuserdata(L, sizeof(Outfit*));
177 *o = outfit;
178 luaL_getmetatable(L, OUTFIT_METATABLE);
179 lua_setmetatable(L, -2);
180 return o;
181}
189int lua_isoutfit( lua_State *L, int ind )
190{
191 int ret;
192
193 if (lua_getmetatable(L,ind)==0)
194 return 0;
195 lua_getfield(L, LUA_REGISTRYINDEX, OUTFIT_METATABLE);
196
197 ret = 0;
198 if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
199 ret = 1;
200
201 lua_pop(L, 2); /* remove both metatables */
202 return ret;
203}
204
215static int outfitL_eq( lua_State *L )
216{
217 const Outfit *a, *b;
218 a = luaL_checkoutfit(L,1);
219 b = luaL_checkoutfit(L,2);
220 if (a == b)
221 lua_pushboolean(L,1);
222 else
223 lua_pushboolean(L,0);
224 return 1;
225}
226
236static int outfitL_get( lua_State *L )
237{
238 const Outfit *o = luaL_validoutfit(L,1);
239 lua_pushoutfit(L, o);
240 return 1;
241}
242
249static int outfitL_getAll( lua_State *L )
250{
251 const Outfit *outfits = outfit_getAll();
252 lua_newtable(L); /* t */
253 for (int i=0; i<array_size(outfits); i++) {
254 lua_pushoutfit( L, (Outfit*) &outfits[i] );
255 lua_rawseti( L, -2, i+1 );
256 }
257 return 1;
258}
259
273static int outfitL_name( lua_State *L )
274{
275 const Outfit *o = luaL_validoutfit(L,1);
276 lua_pushstring(L, _(o->name));
277 return 1;
278}
279
293static int outfitL_nameRaw( lua_State *L )
294{
295 const Outfit *o = luaL_validoutfit(L,1);
296 lua_pushstring(L, o->name);
297 return 1;
298}
299
311static int outfitL_shortname( lua_State *L )
312{
313 const Outfit *o = luaL_validoutfit(L,1);
314 lua_pushstring(L, (o->shortname!=NULL) ? _(o->shortname) : _(o->name));
315 return 1;
316}
317
327static int outfitL_type( lua_State *L )
328{
329 const Outfit *o = luaL_validoutfit(L,1);
330 lua_pushstring(L, outfit_getType(o));
331 return 1;
332}
333
345static int outfitL_typeBroad( lua_State *L )
346{
347 const Outfit *o = luaL_validoutfit(L,1);
348 lua_pushstring(L, outfit_getTypeBroad(o));
349 return 1;
350}
351
361static int outfitL_cpu( lua_State *L )
362{
363 const Outfit *o = luaL_validoutfit(L,1);
364 lua_pushnumber(L, outfit_cpu(o));
365 return 1;
366}
367
377static int outfitL_mass( lua_State *L )
378{
379 const Outfit *o = luaL_validoutfit(L,1);
380 lua_pushnumber(L, o->mass);
381 return 1;
382}
383
393static int outfitL_heatFor( lua_State *L )
394{
395 const Outfit *o = luaL_validoutfit( L, 1 );
396 double heatup = luaL_checknumber( L, 2 );
397 double C = pilot_heatCalcOutfitC( o );
398 double area = pilot_heatCalcOutfitArea( o );
399 double heat = ((800.-CONST_SPACE_STAR_TEMP)*C +
400 STEEL_HEAT_CONDUCTIVITY * ((800.-CONST_SPACE_STAR_TEMP) * area)) /
401 heatup;
402 lua_pushnumber( L, heat );
403 return 1;
404}
405
419static int outfitL_slot( lua_State *L )
420{
421 const Outfit *o = luaL_validoutfit(L,1);
422 lua_pushstring(L, outfit_slotName(o));
423 lua_pushstring(L, outfit_slotSize(o));
424 lua_pushstring(L, sp_display( o->slot.spid ));
425 lua_pushboolean(L, sp_required( o->slot.spid ));
426 lua_pushboolean(L, sp_exclusive( o->slot.spid ));
427 return 5;
428}
429
437static int outfitL_limit( lua_State *L )
438{
439 const Outfit *o = luaL_validoutfit(L,1);
440 if (o->limit) {
441 lua_pushstring(L,o->limit);
442 return 1;
443 }
444 return 0;
445}
446
456static int outfitL_icon( lua_State *L )
457{
458 const Outfit *o = luaL_validoutfit(L,1);
460 return 1;
461}
462
472static int outfitL_price( lua_State *L )
473{
474 const Outfit *o = luaL_validoutfit(L,1);
475 lua_pushnumber(L, o->price);
476 return 1;
477}
478
489static int outfitL_description( lua_State *L )
490{
491 const Outfit *o = luaL_validoutfit(L,1);
492 if (lua_ispilot(L,2))
493 lua_pushstring(L, pilot_outfitDescription( luaL_validpilot(L,2), o ) );
494 else
495 lua_pushstring(L, pilot_outfitDescription( player.p, o ) );
496 return 1;
497}
498
510static int outfitL_summary( lua_State *L )
511{
512 const Outfit *o = luaL_validoutfit(L,1);
513 int noname = lua_toboolean(L,3);
514 if (lua_ispilot(L,2))
515 lua_pushstring(L, pilot_outfitSummary( luaL_validpilot(L,2), o, !noname ) );
516 else
517 lua_pushstring(L, pilot_outfitSummary( player.p, o, !noname ) );
518 return 1;
519}
520
521static int getprop( lua_State *L, int prop )
522{
523 const Outfit *o = luaL_validoutfit(L,1);
524 lua_pushboolean(L, outfit_isProp(o, prop));
525 return 1;
526}
527
537static int outfitL_unique( lua_State *L )
538{
539 return getprop( L, OUTFIT_PROP_UNIQUE );
540}
541
549static int outfitL_friendlyfire( lua_State *L )
550{
551 return getprop( L, OUTFIT_PROP_WEAP_FRIENDLYFIRE );
552}
553
561static int outfitL_pointdefense( lua_State *L )
562{
563 return getprop( L, OUTFIT_PROP_WEAP_POINTDEFENSE );
564}
565
573static int outfitL_miss_ships( lua_State *L )
574{
575 return getprop( L, OUTFIT_PROP_WEAP_MISS_SHIPS );
576}
577
585static int outfitL_miss_asteroids( lua_State *L )
586{
587 return getprop( L, OUTFIT_PROP_WEAP_MISS_ASTEROIDS );
588}
589
597static int outfitL_toggleable( lua_State *L )
598{
599 const Outfit *o = luaL_validoutfit(L,1);
600 lua_pushboolean( L, outfit_isToggleable(o) );
601 return 1;
602}
603
613static int outfitL_getShipStat( lua_State *L )
614{
615 ShipStats ss;
616 const Outfit *o = luaL_validoutfit(L,1);
617 ss_statsInit( &ss );
618 ss_statsMergeFromList( &ss, o->stats );
619 const char *str = luaL_optstring(L,2,NULL);
620 int internal = lua_toboolean(L,3);
621 ss_statsGetLua( L, &ss, str, internal );
622 return 1;
623}
624
639static int outfitL_weapStats( lua_State *L )
640{
641 double eps, dps, disable, shots;
642 double mod_energy, mod_damage, mod_shots;
643 double sdmg, admg;
644 const Damage *dmg;
645 const Outfit *o = luaL_validoutfit( L, 1 );
646 Pilot *p = (lua_ispilot(L,2)) ? luaL_validpilot(L,2) : NULL;
647
648 /* Just return 0 for non-wapons. */
649 if (o->slot.type != OUTFIT_SLOT_WEAPON)
650 return 0;
651
652 /* Special case beam weapons .*/
653 if (outfit_isBeam(o)) {
654 if (p) {
655 /* Special case due to continuous fire. */
656 if (o->type == OUTFIT_TYPE_BEAM) {
657 mod_energy = p->stats.fwd_energy;
658 mod_damage = p->stats.fwd_damage;
659 mod_shots = 1. / p->stats.fwd_firerate;
660 }
661 else {
662 mod_energy = p->stats.tur_energy;
663 mod_damage = p->stats.tur_damage;
664 mod_shots = 1. / p->stats.tur_firerate;
665 }
666 }
667 else {
668 mod_energy = 1.;
669 mod_damage = 1.;
670 mod_shots = 1.;
671 }
672 shots = outfit_duration(o);
673 mod_shots = shots / (shots + mod_shots * outfit_delay(o));
674 dmg = outfit_damage(o);
675 /* Modulate the damage by average of damage types. */
676 if (dtype_raw( dmg->type, &sdmg, &admg, NULL ) != 0)
677 return NLUA_ERROR(L, _("Outfit has invalid damage type."));
678 mod_damage *= 0.5*(sdmg+admg);
679 /* Calculate good damage estimates. */
680 dps = mod_shots * mod_damage * dmg->damage;
681 disable = mod_shots * mod_damage * dmg->disable;
682 eps = mod_shots * mod_energy * outfit_energy(o);
683 lua_pushnumber( L, dps );
684 lua_pushnumber( L, disable );
685 lua_pushnumber( L, eps );
686 lua_pushnumber( L, outfit_range(o) );
687 return 4;
688 }
689
690 if (p) {
691 switch (o->type) {
692 case OUTFIT_TYPE_BOLT:
693 mod_energy = p->stats.fwd_energy;
694 mod_damage = p->stats.fwd_damage;
695 mod_shots = 1. / p->stats.fwd_firerate;
696 break;
697 case OUTFIT_TYPE_TURRET_BOLT:
698 mod_energy = p->stats.tur_energy;
699 mod_damage = p->stats.tur_damage;
700 mod_shots = 1. / p->stats.tur_firerate;
701 break;
702 case OUTFIT_TYPE_LAUNCHER:
703 case OUTFIT_TYPE_TURRET_LAUNCHER:
704 mod_energy = 1.;
705 mod_damage = p->stats.launch_damage;
706 mod_shots = 1. / p->stats.launch_rate;
707 break;
708 case OUTFIT_TYPE_BEAM:
709 case OUTFIT_TYPE_TURRET_BEAM:
710 default:
711 return 0;
712 }
713 }
714 else {
715 mod_energy = 1.;
716 mod_damage = 1.;
717 mod_shots = 1.;
718 }
719
720 shots = 1. / (mod_shots * outfit_delay(o));
721 /* Special case: Ammo-based weapons. */
722 dmg = outfit_damage(o);
723 if (dmg==NULL)
724 return 0;
725 /* Modulate the damage by average of damage types. */
726 dtype_raw( dmg->type, &sdmg, &admg, NULL );
727 mod_damage *= 0.5*(sdmg+admg);
728 /* Calculate good damage estimates. */
729 dps = shots * mod_damage * dmg->damage;
730 disable = shots * mod_damage * dmg->disable;
731 eps = shots * mod_energy * MAX( outfit_energy(o), 0. );
732
733 lua_pushnumber( L, dps );
734 lua_pushnumber( L, disable );
735 lua_pushnumber( L, eps );
736 lua_pushnumber( L, outfit_range(o) );
737 lua_pushnumber( L, outfit_trackmin(o) );
738 lua_pushnumber( L, outfit_trackmax(o) );
739 if (outfit_isLauncher(o)) {
740 lua_pushnumber( L, o->u.lau.lockon );
741 lua_pushnumber( L, o->u.lau.iflockon );
742 lua_pushboolean( L, o->u.lau.ai!=AMMO_AI_UNGUIDED );
743 return 9;
744 }
745 return 6;
746}
747
748#define SETFIELD( name, value ) \
749 lua_pushnumber( L, value ); \
750 lua_setfield( L, -2, name )
751#define SETFIELDI( name, value ) \
752 lua_pushinteger( L, value ); \
753 lua_setfield( L, -2, name )
754#define SETFIELDB( name, value ) \
755 lua_pushboolean( L, value ); \
756 lua_setfield( L, -2, name )
763static int outfitL_specificStats( lua_State *L )
764{
765 const Outfit *o = luaL_validoutfit( L, 1 );
766 lua_newtable(L);
767 switch (o->type) {
768 case OUTFIT_TYPE_AFTERBURNER:
769 SETFIELD( "accel", o->u.afb.accel );
770 SETFIELD( "speed", o->u.afb.speed );
771 SETFIELD( "energy", o->u.afb.energy );
772 SETFIELD( "mass_limit", o->u.afb.mass_limit );
773 SETFIELD( "heatup", o->u.afb.heatup );
774 SETFIELD( "heat", o->u.afb.heat );
775 SETFIELD( "overheat_min",o->overheat_min );
776 SETFIELD( "overheat_max",o->overheat_max );
777 break;
778
779 case OUTFIT_TYPE_FIGHTER_BAY:
780 lua_pushship( L, o->u.bay.ship );
781 lua_setfield( L, -2, "ship" );
782 SETFIELD( "delay", o->u.bay.delay );
783 SETFIELDI("amount", o->u.bay.amount );
784 SETFIELD( "reload_time",o->u.bay.reload_time );
785 break;
786
787 case OUTFIT_TYPE_TURRET_BOLT:
788 SETFIELDB("isturret", 1 );
789 FALLTHROUGH;
790 case OUTFIT_TYPE_BOLT:
791 SETFIELD( "delay", o->u.blt.delay );
792 SETFIELD( "speed", o->u.blt.speed );
793 SETFIELD( "range", o->u.blt.range );
794 SETFIELD( "falloff", o->u.blt.falloff );
795 SETFIELD( "energy", o->u.blt.energy );
796 SETFIELD( "heatup", o->u.blt.heatup );
797 SETFIELD( "heat", o->u.blt.heat );
798 SETFIELD( "trackmin", o->u.blt.trackmin );
799 SETFIELD( "trackmax", o->u.blt.trackmax );
800 SETFIELD( "swivel", o->u.blt.swivel );
801 /* Damage stuff. */
802 SETFIELD( "penetration",o->u.blt.dmg.penetration );
803 SETFIELD( "damage", o->u.blt.dmg.damage );
804 SETFIELD( "disable", o->u.blt.dmg.disable );
805 break;
806
807 case OUTFIT_TYPE_TURRET_BEAM:
808 SETFIELDB("isturret", 1 );
809 FALLTHROUGH;
810 case OUTFIT_TYPE_BEAM:
811 SETFIELD( "delay", o->u.bem.delay );
812 SETFIELD( "warmup", o->u.bem.warmup );
813 SETFIELD( "duration", o->u.bem.duration );
814 SETFIELD( "min_duration",o->u.bem.min_duration );
815 SETFIELD( "range", o->u.bem.range );
816 SETFIELD( "turn", o->u.bem.turn );
817 SETFIELD( "energy", o->u.bem.energy );
818 SETFIELD( "heatup", o->u.bem.heatup );
819 SETFIELD( "heat", o->u.bem.heat );
820 /* Damage stuff. */
821 SETFIELD( "penetration",o->u.bem.dmg.penetration );
822 SETFIELD( "damage", o->u.bem.dmg.damage );
823 SETFIELD( "disable", o->u.bem.dmg.disable );
824 break;
825
826 case OUTFIT_TYPE_TURRET_LAUNCHER:
827 SETFIELDB("isturret", 1 );
828 FALLTHROUGH;
829 case OUTFIT_TYPE_LAUNCHER:
830 SETFIELD( "delay", o->u.lau.delay );
831 SETFIELDI("amount", o->u.lau.amount );
832 SETFIELD( "reload_time",o->u.lau.reload_time );
833 SETFIELD( "lockon", o->u.lau.lockon );
834 SETFIELD( "iflockon", o->u.lau.iflockon );
835 SETFIELD( "trackmin", o->u.lau.trackmin );
836 SETFIELD( "trackmax", o->u.lau.trackmax );
837 SETFIELD( "arc", o->u.lau.arc );
838 SETFIELD( "swivel", o->u.lau.swivel );
839 /* Ammo stuff. */
840 SETFIELD( "duration", o->u.lau.duration );
841 SETFIELD( "speed", o->u.lau.speed );
842 SETFIELD( "speed_max", o->u.lau.speed_max );
843 SETFIELD( "turn", o->u.lau.turn );
844 SETFIELD( "accel", o->u.lau.accel );
845 SETFIELD( "energy", o->u.lau.energy );
846 SETFIELDB("seek", o->u.lau.ai!=AMMO_AI_UNGUIDED );
847 SETFIELDB("smart", o->u.lau.ai==AMMO_AI_SMART );
848 /* Damage stuff. */
849 SETFIELD( "penetration",o->u.lau.dmg.penetration );
850 SETFIELD( "damage", o->u.lau.dmg.damage );
851 SETFIELD( "disable", o->u.lau.dmg.disable );
852 break;
853
854 default:
855 break;
856 }
857 return 1;
858}
859#undef SETFIELD
860#undef SETFIELDI
861#undef SETFIELDB
862
870static int outfitL_illegality( lua_State *L )
871{
872 const Outfit *o = luaL_validoutfit(L,1);
873 lua_newtable(L);
874 for (int i=0; i<array_size(o->illegalto); i++) {
875 lua_pushfaction( L, o->illegalto[i] );
876 lua_rawseti( L, -2, i+1 );
877 }
878 return 1;
879}
880
890static int outfitL_tags( lua_State *L )
891{
892 const Outfit *o = luaL_validoutfit(L,1);
893 lua_newtable(L);
894 for (int i=0; i<array_size(o->tags); i++) {
895 lua_pushstring(L,o->tags[i]);
896 lua_pushboolean(L,1);
897 lua_rawset(L,-3);
898 }
899 return 1;
900}
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:168
int dtype_raw(int type, double *shield, double *armour, double *knockback)
Gets the raw modulation stats of a damage type.
Definition damagetype.c:252
Header file with generic functions and naev-specifics.
#define MAX(x, y)
Definition naev.h:39
LuaFaction * lua_pushfaction(lua_State *L, LuaFaction faction)
Pushes a faction on the stack.
static int outfitL_limit(lua_State *L)
Gets the limit string of the outfit. Only one outfit can be equipped at the same time for each limit ...
static int outfitL_mass(lua_State *L)
Gets the mass of an outfit.
static int outfitL_illegality(lua_State *L)
Gets the factions to which the outfit is illegal to.
const Outfit * luaL_validoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
static int outfitL_cpu(lua_State *L)
Gets the cpu usage of an outfit.
static int outfitL_slot(lua_State *L)
Gets the slot name, size and property of an outfit.
int nlua_loadOutfit(nlua_env env)
Loads the outfit library.
Definition nlua_outfit.c:97
static int outfitL_tags(lua_State *L)
Gets the outfit tags.
static int outfitL_typeBroad(lua_State *L)
Gets the broad type of an outfit.
static int outfitL_specificStats(lua_State *L)
Returns raw data specific to each outfit type.
static int outfitL_summary(lua_State *L)
Gets the summary of an outfit (translated).
static int outfitL_miss_ships(lua_State *L)
Gets whether or not a weapon outfit misses ships.
static int outfitL_toggleable(lua_State *L)
Gets whether or not an outfit is toggleable.
static int outfitL_type(lua_State *L)
Gets the type of an outfit.
static int outfitL_icon(lua_State *L)
Gets the store icon for an outfit.
static int outfitL_getShipStat(lua_State *L)
Gets a shipstat from an Outfit by name, or a table containing all the ship stats if not specified.
static int outfitL_getAll(lua_State *L)
Gets all the outfits.
static int outfitL_nameRaw(lua_State *L)
Gets the raw (untranslated) name of the outfit.
static int outfitL_miss_asteroids(lua_State *L)
Gets whether or not a weapon outfit misses asteroids.
static int outfitL_get(lua_State *L)
Gets a outfit.
static int outfitL_description(lua_State *L)
Gets the description of an outfit (translated).
static int outfitL_friendlyfire(lua_State *L)
Gets whether or not a weapon outfit can do friendly fire.
static int outfitL_shortname(lua_State *L)
Gets the translated short name of the outfit.
static int outfitL_name(lua_State *L)
Gets the translated name of the outfit.
const Outfit * luaL_checkoutfit(lua_State *L, int ind)
Gets outfit at index or raises error if there is no outfit at index.
static int outfitL_weapStats(lua_State *L)
Computes statistics for weapons.
static int outfitL_price(lua_State *L)
Gets the price of an outfit.
static int outfitL_pointdefense(lua_State *L)
Gets whether or not a weapon outfit is point defense.
static int outfitL_heatFor(lua_State *L)
Calculates a heat value to be used with heat up.
static const luaL_Reg outfitL_methods[]
Definition nlua_outfit.c:58
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
static int outfitL_eq(lua_State *L)
Checks to see if two outfits are the same.
int lua_isoutfit(lua_State *L, int ind)
Checks to see if ind is a outfit.
static int outfitL_unique(lua_State *L)
Gets whether or not an outfit is unique.
const Outfit * lua_tooutfit(lua_State *L, int ind)
Lua bindings to interact with outfits.
Pilot * luaL_validpilot(lua_State *L, int ind)
Makes sure the pilot is valid or raises a Lua error.
Definition nlua_pilot.c:547
int lua_ispilot(lua_State *L, int ind)
Checks to see if ind is a pilot.
Definition nlua_pilot.c:578
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
Definition nlua_ship.c:166
glTexture ** lua_pushtex(lua_State *L, glTexture *texture)
Pushes a texture on the stack.
Definition nlua_tex.c:130
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
Definition opengl_tex.c:917
double outfit_trackmin(const Outfit *o)
Gets the outfit's minimal tracking.
Definition outfit.c:848
int outfit_isBeam(const Outfit *o)
Checks if outfit is a beam type weapon.
Definition outfit.c:554
const Outfit * outfit_getAll(void)
Gets the array (array.h) of all outfits.
Definition outfit.c:189
double outfit_cpu(const Outfit *o)
Gets the outfit's cpu usage.
Definition outfit.c:779
const Outfit * outfit_get(const char *name)
Gets an outfit by name.
Definition outfit.c:166
int outfit_isLauncher(const Outfit *o)
Checks if outfit is a weapon launcher.
Definition outfit.c:564
int outfit_isToggleable(const Outfit *o)
Checks if outfit can be toggled.
Definition outfit.c:500
const char * outfit_getTypeBroad(const Outfit *o)
Gets the outfit's broad type.
Definition outfit.c:976
double outfit_range(const Outfit *o)
Gets the outfit's range.
Definition outfit.c:787
const char * outfit_getType(const Outfit *o)
Gets the outfit's specific type.
Definition outfit.c:945
double outfit_trackmax(const Outfit *o)
Gets the outfit's minimal tracking.
Definition outfit.c:860
const Damage * outfit_damage(const Outfit *o)
Gets the outfit's damage.
Definition outfit.c:713
double outfit_duration(const Outfit *o)
Gets the outfit's duration.
Definition outfit.c:917
const char * outfit_slotName(const Outfit *o)
Gets the name of the slot type of an outfit.
Definition outfit.c:327
const char * outfit_slotSize(const Outfit *o)
Gets the name of the slot size of an outfit.
Definition outfit.c:380
double outfit_energy(const Outfit *o)
Gets the outfit's energy usage.
Definition outfit.c:757
double outfit_delay(const Outfit *o)
Gets the outfit's delay.
Definition outfit.c:734
double pilot_heatCalcOutfitC(const Outfit *o)
Calculates the thermal mass of an outfit.
Definition pilot_heat.c:62
double pilot_heatCalcOutfitArea(const Outfit *o)
Calculates the effective transfer area of an outfit.
Definition pilot_heat.c:73
const char * pilot_outfitDescription(const Pilot *p, const Outfit *o)
Gets the description of an outfit for a given pilot.
const char * pilot_outfitSummary(const Pilot *p, const Outfit *o, int withname)
Gets the summary of an outfit for a give pilot.
Player_t player
Definition player.c:74
static cholmod_common C
Definition safelanes.c:95
int ss_statsMergeFromList(ShipStats *stats, const ShipStatList *list)
Updates a stat structure from a stat list.
Definition shipstats.c:627
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.
Definition shipstats.c:1054
int ss_statsInit(ShipStats *stats)
Initializes a stat structure.
Definition shipstats.c:430
const char * sp_display(unsigned int spid)
Gets the display name of a slot property (in English).
Definition slots.c:159
int sp_required(unsigned int spid)
Gets whether or not a slot property is required.
Definition slots.c:179
int sp_exclusive(unsigned int spid)
Gets whether or not a slot property is exclusive.
Definition slots.c:189
Core damage that an outfit does.
Definition outfit.h:138
int type
Definition outfit.h:139
double disable
Definition outfit.h:142
double penetration
Definition outfit.h:140
double damage
Definition outfit.h:141
double energy
Definition outfit.h:188
double heatup
Definition outfit.h:190
double duration
Definition outfit.h:182
double warmup
Definition outfit.h:181
Damage dmg
Definition outfit.h:189
double min_duration
Definition outfit.h:183
double turn
Definition outfit.h:187
double heat
Definition outfit.h:191
double range
Definition outfit.h:186
double delay
Definition outfit.h:180
double heat
Definition outfit.h:158
double trackmin
Definition outfit.h:159
double falloff
Definition outfit.h:152
double range
Definition outfit.h:151
double delay
Definition outfit.h:149
double swivel
Definition outfit.h:161
double heatup
Definition outfit.h:157
Damage dmg
Definition outfit.h:154
double trackmax
Definition outfit.h:160
double speed
Definition outfit.h:150
double energy
Definition outfit.h:153
const struct Ship_ * ship
Definition outfit.h:291
double reload_time
Definition outfit.h:214
OutfitAmmoAI ai
Definition outfit.h:231
unsigned int spid
Definition outfit.h:110
OutfitSlotType type
Definition outfit.h:112
A ship outfit, depends radically on the type.
Definition outfit.h:328
char ** tags
Definition outfit.h:367
credits_t price
Definition outfit.h:347
char * limit
Definition outfit.h:342
OutfitLauncherData lau
Definition outfit.h:406
OutfitBeamData bem
Definition outfit.h:405
OutfitBoltData blt
Definition outfit.h:404
double overheat_max
Definition outfit.h:358
OutfitType type
Definition outfit.h:402
glTexture * gfx_store
Definition outfit.h:353
char * shortname
Definition outfit.h:331
union Outfit::@12 u
OutfitSlot slot
Definition outfit.h:336
OutfitAfterburnerData afb
Definition outfit.h:408
int * illegalto
Definition outfit.h:343
OutfitFighterBayData bay
Definition outfit.h:409
ShipStatList * stats
Definition outfit.h:364
double overheat_min
Definition outfit.h:357
double mass
Definition outfit.h:340
char * name
Definition outfit.h:329
The representation of an in-game pilot.
Definition pilot.h:217
Pilot * p
Definition player.h:101
Represents ship statistics, properties ship can use.
Definition shipstats.h:198