naev 0.12.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"
14
15#include "nlua_outfit.h"
16
17#include "array.h"
18#include "damagetype.h"
19#include "nlua_faction.h"
20#include "nlua_pilot.h"
21#include "nlua_ship.h"
22#include "nlua_tex.h"
23#include "nluadef.h"
24#include "player.h"
25#include "slots.h"
26
27/* Outfit metatable methods. */
28static int outfitL_eq( lua_State *L );
29static int outfitL_get( lua_State *L );
30static int outfitL_exists( lua_State *L );
31static int outfitL_getAll( lua_State *L );
32static int outfitL_name( lua_State *L );
33static int outfitL_nameRaw( lua_State *L );
34static int outfitL_shortname( lua_State *L );
35static int outfitL_type( lua_State *L );
36static int outfitL_typeBroad( lua_State *L );
37static int outfitL_cpu( lua_State *L );
38static int outfitL_mass( lua_State *L );
39static int outfitL_heatFor( lua_State *L );
40static int outfitL_slot( lua_State *L );
41static int outfitL_limit( lua_State *L );
42static int outfitL_icon( lua_State *L );
43static int outfitL_price( lua_State *L );
44static int outfitL_description( lua_State *L );
45static int outfitL_summary( lua_State *L );
46static int outfitL_unique( lua_State *L );
47static int outfitL_friendlyfire( lua_State *L );
48static int outfitL_pointdefense( lua_State *L );
49static int outfitL_miss_ships( lua_State *L );
50static int outfitL_miss_asteroids( lua_State *L );
51static int outfitL_toggleable( lua_State *L );
52static int outfitL_getShipStat( lua_State *L );
53static int outfitL_weapStats( lua_State *L );
54static int outfitL_specificStats( lua_State *L );
55static int outfitL_illegality( lua_State *L );
56static int outfitL_known( lua_State *L );
57static int outfitL_tags( lua_State *L );
58
59static const luaL_Reg outfitL_methods[] = {
60 { "__tostring", outfitL_name },
61 { "__eq", outfitL_eq },
62 { "get", outfitL_get },
63 { "exists", outfitL_exists },
64 { "getAll", outfitL_getAll },
65 { "name", outfitL_name },
66 { "nameRaw", outfitL_nameRaw },
67 { "shortname", outfitL_shortname },
68 { "type", outfitL_type },
69 { "typeBroad", outfitL_typeBroad },
70 { "cpu", outfitL_cpu },
71 { "mass", outfitL_mass },
72 { "heatFor", outfitL_heatFor },
73 { "slot", outfitL_slot },
74 { "limit", outfitL_limit },
75 { "icon", outfitL_icon },
76 { "price", outfitL_price },
77 { "description", outfitL_description },
78 { "summary", outfitL_summary },
79 { "unique", outfitL_unique },
80 { "friendlyfire", outfitL_friendlyfire },
81 { "pointdefense", outfitL_pointdefense },
82 { "missShips", outfitL_miss_ships },
83 { "missAsteroids", outfitL_miss_asteroids },
84 { "toggleable", outfitL_toggleable },
85 { "shipstat", outfitL_getShipStat },
86 { "weapstats", outfitL_weapStats },
87 { "specificstats", outfitL_specificStats },
88 { "illegality", outfitL_illegality },
89 { "known", outfitL_known },
90 { "tags", outfitL_tags },
91 { 0, 0 } };
92
99int nlua_loadOutfit( nlua_env env )
100{
101 nlua_register( env, OUTFIT_METATABLE, outfitL_methods, 1 );
102 return 0;
103}
104
126const Outfit *lua_tooutfit( lua_State *L, int ind )
127{
128 return *( (const Outfit **)lua_touserdata( L, ind ) );
129}
130
137const Outfit *luaL_checkoutfit( lua_State *L, int ind )
138{
139 if ( lua_isoutfit( L, ind ) )
140 return lua_tooutfit( L, ind );
141 luaL_typerror( L, ind, OUTFIT_METATABLE );
142 return NULL;
143}
144
151const Outfit *luaL_validoutfit( lua_State *L, int ind )
152{
153 const Outfit *o;
154
155 if ( lua_isoutfit( L, ind ) )
156 o = luaL_checkoutfit( L, ind );
157 else if ( lua_isstring( L, ind ) )
158 o = outfit_get( lua_tostring( L, ind ) );
159 else {
160 luaL_typerror( L, ind, OUTFIT_METATABLE );
161 return NULL;
162 }
163
164 if ( o == NULL )
165 NLUA_ERROR( L, _( "Outfit is invalid." ) );
166
167 return o;
168}
169
176const Outfit **lua_pushoutfit( lua_State *L, const Outfit *outfit )
177{
178 const Outfit **o = (const Outfit **)lua_newuserdata( L, sizeof( Outfit * ) );
179 *o = outfit;
180 luaL_getmetatable( L, OUTFIT_METATABLE );
181 lua_setmetatable( L, -2 );
182 return o;
183}
184
191int lua_isoutfit( lua_State *L, int ind )
192{
193 int ret;
194
195 if ( lua_getmetatable( L, ind ) == 0 )
196 return 0;
197 lua_getfield( L, LUA_REGISTRYINDEX, OUTFIT_METATABLE );
198
199 ret = 0;
200 if ( lua_rawequal( L, -1, -2 ) ) /* does it have the correct mt? */
201 ret = 1;
202
203 lua_pop( L, 2 ); /* remove both metatables */
204 return ret;
205}
206
217static int outfitL_eq( lua_State *L )
218{
219 const Outfit *a, *b;
220 a = luaL_checkoutfit( L, 1 );
221 b = luaL_checkoutfit( L, 2 );
222 if ( a == b )
223 lua_pushboolean( L, 1 );
224 else
225 lua_pushboolean( L, 0 );
226 return 1;
227}
228
240static int outfitL_get( lua_State *L )
241{
242 const Outfit *o = luaL_validoutfit( L, 1 );
243 lua_pushoutfit( L, o );
244 return 1;
245}
246
259static int outfitL_exists( lua_State *L )
260{
261 const Outfit *o = NULL;
262 if ( lua_isoutfit( L, 1 ) )
263 o = luaL_checkoutfit( L, 1 );
264 else if ( lua_isstring( L, 1 ) ) {
265 const char *str = lua_tostring( L, 1 );
266 o = outfit_getW( str );
267 } else {
268 luaL_typerror( L, 1, OUTFIT_METATABLE );
269 return 0;
270 }
271 if ( o != NULL ) {
272 lua_pushoutfit( L, o );
273 return 1;
274 }
275 return 0;
276}
277
284static int outfitL_getAll( lua_State *L )
285{
286 const Outfit *outfits = outfit_getAll();
287 lua_newtable( L ); /* t */
288 for ( int i = 0; i < array_size( outfits ); i++ ) {
289 lua_pushoutfit( L, (Outfit *)&outfits[i] );
290 lua_rawseti( L, -2, i + 1 );
291 }
292 return 1;
293}
294
308static int outfitL_name( lua_State *L )
309{
310 const Outfit *o = luaL_validoutfit( L, 1 );
311 lua_pushstring( L, _( o->name ) );
312 return 1;
313}
314
328static int outfitL_nameRaw( lua_State *L )
329{
330 const Outfit *o = luaL_validoutfit( L, 1 );
331 lua_pushstring( L, o->name );
332 return 1;
333}
334
346static int outfitL_shortname( lua_State *L )
347{
348 const Outfit *o = luaL_validoutfit( L, 1 );
349 lua_pushstring( L, outfit_shortname( o ) );
350 return 1;
351}
352
362static int outfitL_type( lua_State *L )
363{
364 const Outfit *o = luaL_validoutfit( L, 1 );
365 lua_pushstring( L, outfit_getType( o ) );
366 return 1;
367}
368
380static int outfitL_typeBroad( lua_State *L )
381{
382 const Outfit *o = luaL_validoutfit( L, 1 );
383 lua_pushstring( L, outfit_getTypeBroad( o ) );
384 return 1;
385}
386
396static int outfitL_cpu( lua_State *L )
397{
398 const Outfit *o = luaL_validoutfit( L, 1 );
399 lua_pushnumber( L, outfit_cpu( o ) );
400 return 1;
401}
402
412static int outfitL_mass( lua_State *L )
413{
414 const Outfit *o = luaL_validoutfit( L, 1 );
415 lua_pushnumber( L, o->mass );
416 return 1;
417}
418
431static int outfitL_heatFor( lua_State *L )
432{
433 const Outfit *o = luaL_validoutfit( L, 1 );
434 double heatup = luaL_checknumber( L, 2 );
435 double C = pilot_heatCalcOutfitC( o );
436 double area = pilot_heatCalcOutfitArea( o );
437 double heat = ( ( 800. - CONST_SPACE_STAR_TEMP ) * C +
438 STEEL_HEAT_CONDUCTIVITY *
439 ( ( 800. - CONST_SPACE_STAR_TEMP ) * area ) ) /
440 heatup;
441 lua_pushnumber( L, heat );
442 return 1;
443}
444
459static int outfitL_slot( lua_State *L )
460{
461 const Outfit *o = luaL_validoutfit( L, 1 );
462 lua_pushstring( L, outfit_slotName( o ) );
463 lua_pushstring( L, outfit_slotSize( o ) );
464 lua_pushstring( L, sp_display( o->slot.spid ) );
465 lua_pushboolean( L, sp_required( o->slot.spid ) );
466 lua_pushboolean( L, sp_exclusive( o->slot.spid ) );
467 return 5;
468}
469
478static int outfitL_limit( lua_State *L )
479{
480 const Outfit *o = luaL_validoutfit( L, 1 );
481 if ( o->limit ) {
482 lua_pushstring( L, o->limit );
483 return 1;
484 }
485 return 0;
486}
487
497static int outfitL_icon( lua_State *L )
498{
499 const Outfit *o = luaL_validoutfit( L, 1 );
502 return 1;
503}
504
514static int outfitL_price( lua_State *L )
515{
516 const Outfit *o = luaL_validoutfit( L, 1 );
517 lua_pushnumber( L, o->price );
518 return 1;
519}
520
531static int outfitL_description( lua_State *L )
532{
533 const Outfit *o = luaL_validoutfit( L, 1 );
534 if ( lua_ispilot( L, 2 ) )
535 lua_pushstring( L,
537 else
538 lua_pushstring( L, pilot_outfitDescription( player.p, o ) );
539 return 1;
540}
541
554static int outfitL_summary( lua_State *L )
555{
556 const Outfit *o = luaL_validoutfit( L, 1 );
557 int noname = lua_toboolean( L, 3 );
558 if ( lua_ispilot( L, 2 ) )
559 lua_pushstring(
560 L, pilot_outfitSummary( luaL_validpilot( L, 2 ), o, !noname ) );
561 else
562 lua_pushstring( L, pilot_outfitSummary( player.p, o, !noname ) );
563 return 1;
564}
565
566static int getprop( lua_State *L, int prop )
567{
568 const Outfit *o = luaL_validoutfit( L, 1 );
569 lua_pushboolean( L, outfit_isProp( o, prop ) );
570 return 1;
571}
572
582static int outfitL_unique( lua_State *L )
583{
584 return getprop( L, OUTFIT_PROP_UNIQUE );
585}
586
594static int outfitL_friendlyfire( lua_State *L )
595{
596 return getprop( L, OUTFIT_PROP_WEAP_FRIENDLYFIRE );
597}
598
606static int outfitL_pointdefense( lua_State *L )
607{
608 return getprop( L, OUTFIT_PROP_WEAP_POINTDEFENSE );
609}
610
618static int outfitL_miss_ships( lua_State *L )
619{
620 return getprop( L, OUTFIT_PROP_WEAP_MISS_SHIPS );
621}
622
630static int outfitL_miss_asteroids( lua_State *L )
631{
632 return getprop( L, OUTFIT_PROP_WEAP_MISS_ASTEROIDS );
633}
634
642static int outfitL_toggleable( lua_State *L )
643{
644 const Outfit *o = luaL_validoutfit( L, 1 );
645 lua_pushboolean( L, outfit_isToggleable( o ) );
646 return 1;
647}
648
661static int outfitL_getShipStat( lua_State *L )
662{
663 ShipStats ss;
664 const Outfit *o = luaL_validoutfit( L, 1 );
665 ss_statsInit( &ss );
666 ss_statsMergeFromList( &ss, o->stats );
667 const char *str = luaL_optstring( L, 2, NULL );
668 int internal = lua_toboolean( L, 3 );
669 ss_statsGetLua( L, &ss, str, internal );
670 return 1;
671}
672
687static int outfitL_weapStats( lua_State *L )
688{
689 double eps, dps, disable, shots;
690 double mod_energy, mod_damage, mod_shots;
691 double sdmg, admg;
692 const Damage *dmg;
693 const Outfit *o = luaL_validoutfit( L, 1 );
694 Pilot *p = ( lua_ispilot( L, 2 ) ) ? luaL_validpilot( L, 2 ) : NULL;
695
696 /* Just return 0 for non-wapons. */
697 if ( !outfit_isWeapon( o ) )
698 return 0;
699
700 /* Special case beam weapons .*/
701 if ( outfit_isBeam( o ) ) {
702 if ( p ) {
703 /* Special case due to continuous fire. */
704 if ( o->type == OUTFIT_TYPE_BEAM ) {
705 mod_energy = p->stats.fwd_energy;
706 mod_damage = p->stats.fwd_damage;
707 mod_shots = 1. / p->stats.fwd_firerate;
708 } else {
709 mod_energy = p->stats.tur_energy;
710 mod_damage = p->stats.tur_damage;
711 mod_shots = 1. / p->stats.tur_firerate;
712 }
713 } else {
714 mod_energy = 1.;
715 mod_damage = 1.;
716 mod_shots = 1.;
717 }
718 shots = outfit_duration( o );
719 mod_shots = shots / ( shots + mod_shots * outfit_delay( o ) );
720 dmg = outfit_damage( o );
721 /* Modulate the damage by average of damage types. */
722 if ( dtype_raw( dmg->type, &sdmg, &admg, NULL ) != 0 )
723 return NLUA_ERROR( L, _( "Outfit has invalid damage type." ) );
724 mod_damage *= 0.5 * ( sdmg + admg );
725 /* Calculate good damage estimates. */
726 dps = mod_shots * mod_damage * dmg->damage;
727 disable = mod_shots * mod_damage * dmg->disable;
728 /* Bolts have energy per hit, while beams are sustained energy, so flip.
729 */
730 eps = mod_shots * mod_energy * -outfit_energy( o );
731 lua_pushnumber( L, dps );
732 lua_pushnumber( L, disable );
733 lua_pushnumber( L, eps );
734 lua_pushnumber( L, outfit_range( o ) );
735 return 4;
736 }
737
738 if ( p ) {
739 switch ( o->type ) {
740 case OUTFIT_TYPE_BOLT:
741 mod_energy = p->stats.fwd_energy;
742 mod_damage = p->stats.fwd_damage;
743 mod_shots = 1. / p->stats.fwd_firerate;
744 break;
745 case OUTFIT_TYPE_TURRET_BOLT:
746 mod_energy = p->stats.tur_energy;
747 mod_damage = p->stats.tur_damage;
748 mod_shots = 1. / p->stats.tur_firerate;
749 break;
750 case OUTFIT_TYPE_LAUNCHER:
751 case OUTFIT_TYPE_TURRET_LAUNCHER:
752 mod_energy = 1.;
753 mod_damage = p->stats.launch_damage;
754 mod_shots = 1. / p->stats.launch_rate;
755 break;
756 case OUTFIT_TYPE_BEAM:
757 case OUTFIT_TYPE_TURRET_BEAM:
758 default:
759 return 0;
760 }
761 } else {
762 mod_energy = 1.;
763 mod_damage = 1.;
764 mod_shots = 1.;
765 }
766
767 shots = 1. / ( mod_shots * outfit_delay( o ) );
768 /* Special case: Ammo-based weapons. */
769 dmg = outfit_damage( o );
770 if ( dmg == NULL ) {
771 dps = 0.;
772 disable = 0.;
773 } else {
774 /* Modulate the damage by average of damage types. */
775 dtype_raw( dmg->type, &sdmg, &admg, NULL );
776 mod_damage *= 0.5 * ( sdmg + admg );
777 /* Calculate good damage estimates. */
778 dps = shots * mod_damage * dmg->damage;
779 disable = shots * mod_damage * dmg->disable;
780 }
781 eps = shots * mod_energy * MAX( outfit_energy( o ), 0. );
782
783 lua_pushnumber( L, dps );
784 lua_pushnumber( L, disable );
785 lua_pushnumber( L, eps );
786 lua_pushnumber( L, outfit_range( o ) );
787 lua_pushnumber( L, outfit_trackmin( o ) );
788 lua_pushnumber( L, outfit_trackmax( o ) );
789 if ( outfit_isLauncher( o ) ) {
790 lua_pushnumber( L, o->u.lau.lockon );
791 lua_pushnumber( L, o->u.lau.iflockon );
792 lua_pushboolean( L, o->u.lau.ai != AMMO_AI_UNGUIDED );
793 return 9;
794 }
795 return 6;
796}
797
798#define SETFIELD( name, value ) \
799 lua_pushnumber( L, value ); \
800 lua_setfield( L, -2, name )
801#define SETFIELDI( name, value ) \
802 lua_pushinteger( L, value ); \
803 lua_setfield( L, -2, name )
804#define SETFIELDB( name, value ) \
805 lua_pushboolean( L, value ); \
806 lua_setfield( L, -2, name )
813static int outfitL_specificStats( lua_State *L )
814{
815 const Outfit *o = luaL_validoutfit( L, 1 );
816 lua_newtable( L );
817 switch ( o->type ) {
818 case OUTFIT_TYPE_AFTERBURNER:
819 SETFIELD( "accel", o->u.afb.accel );
820 SETFIELD( "speed", o->u.afb.speed );
821 SETFIELD( "energy", o->u.afb.energy );
822 SETFIELD( "mass_limit", o->u.afb.mass_limit );
823 SETFIELD( "heatup", o->u.afb.heatup );
824 SETFIELD( "heat", o->u.afb.heat );
825 SETFIELD( "overheat_min", o->overheat_min );
826 SETFIELD( "overheat_max", o->overheat_max );
827 break;
828
829 case OUTFIT_TYPE_FIGHTER_BAY:
830 lua_pushship( L, o->u.bay.ship );
831 lua_setfield( L, -2, "ship" );
832 SETFIELD( "delay", o->u.bay.delay );
833 SETFIELDI( "amount", o->u.bay.amount );
834 SETFIELD( "reload_time", o->u.bay.reload_time );
835 break;
836
837 case OUTFIT_TYPE_TURRET_BOLT:
838 SETFIELDB( "isturret", 1 );
839 FALLTHROUGH;
840 case OUTFIT_TYPE_BOLT:
841 SETFIELD( "delay", o->u.blt.delay );
842 SETFIELD( "speed", o->u.blt.speed );
843 SETFIELD( "range", o->u.blt.range );
844 SETFIELD( "falloff", o->u.blt.falloff );
845 SETFIELD( "energy", o->u.blt.energy );
846 SETFIELD( "heatup", o->u.blt.heatup );
847 SETFIELD( "heat", o->u.blt.heat );
848 SETFIELD( "trackmin", o->u.blt.trackmin );
849 SETFIELD( "trackmax", o->u.blt.trackmax );
850 SETFIELD( "swivel", o->u.blt.swivel );
851 /* Damage stuff. */
852 SETFIELD( "penetration", o->u.blt.dmg.penetration );
853 SETFIELD( "damage", o->u.blt.dmg.damage );
854 SETFIELD( "disable", o->u.blt.dmg.disable );
855 break;
856
857 case OUTFIT_TYPE_TURRET_BEAM:
858 SETFIELDB( "isturret", 1 );
859 FALLTHROUGH;
860 case OUTFIT_TYPE_BEAM:
861 SETFIELD( "delay", o->u.bem.delay );
862 SETFIELD( "min_delay", o->u.bem.min_delay );
863 SETFIELD( "warmup", o->u.bem.warmup );
864 SETFIELD( "duration", o->u.bem.duration );
865 SETFIELD( "range", o->u.bem.range );
866 SETFIELD( "turn", o->u.bem.turn );
867 SETFIELD( "energy", o->u.bem.energy );
868 SETFIELD( "heatup", o->u.bem.heatup );
869 SETFIELD( "heat", o->u.bem.heat );
870 /* Damage stuff. */
871 SETFIELD( "penetration", o->u.bem.dmg.penetration );
872 SETFIELD( "damage", o->u.bem.dmg.damage );
873 SETFIELD( "disable", o->u.bem.dmg.disable );
874 break;
875
876 case OUTFIT_TYPE_TURRET_LAUNCHER:
877 SETFIELDB( "isturret", 1 );
878 FALLTHROUGH;
879 case OUTFIT_TYPE_LAUNCHER:
880 SETFIELD( "delay", o->u.lau.delay );
881 SETFIELDI( "amount", o->u.lau.amount );
882 SETFIELD( "reload_time", o->u.lau.reload_time );
883 SETFIELD( "lockon", o->u.lau.lockon );
884 SETFIELD( "iflockon", o->u.lau.iflockon );
885 SETFIELD( "trackmin", o->u.lau.trackmin );
886 SETFIELD( "trackmax", o->u.lau.trackmax );
887 SETFIELD( "arc", o->u.lau.arc );
888 SETFIELD( "swivel", o->u.lau.swivel );
889 /* Ammo stuff. */
890 SETFIELD( "duration", o->u.lau.duration );
891 SETFIELD( "speed", o->u.lau.speed );
892 SETFIELD( "speed_max", o->u.lau.speed_max );
893 SETFIELD( "turn", o->u.lau.turn );
894 SETFIELD( "accel", o->u.lau.accel );
895 SETFIELD( "energy", o->u.lau.energy );
896 SETFIELDB( "seek", o->u.lau.ai != AMMO_AI_UNGUIDED );
897 SETFIELDB( "smart", o->u.lau.ai == AMMO_AI_SMART );
898 /* Damage stuff. */
899 SETFIELD( "penetration", o->u.lau.dmg.penetration );
900 SETFIELD( "damage", o->u.lau.dmg.damage );
901 SETFIELD( "disable", o->u.lau.dmg.disable );
902 break;
903
904 default:
905 break;
906 }
907 return 1;
908}
909#undef SETFIELD
910#undef SETFIELDI
911#undef SETFIELDB
912
920static int outfitL_illegality( lua_State *L )
921{
922 const Outfit *o = luaL_validoutfit( L, 1 );
923 lua_newtable( L );
924 for ( int i = 0; i < array_size( o->illegalto ); i++ ) {
925 lua_pushfaction( L, o->illegalto[i] );
926 lua_rawseti( L, -2, i + 1 );
927 }
928 return 1;
929}
930
935static int outfitL_known( lua_State *L )
936{
937 /* TODO cache this and mark as dirty instead of recomputing for each outfit.
938 */
939 const Outfit *o = luaL_validoutfit( L, 1 );
940 const PlayerOutfit_t *po = player_getOutfits();
941 for ( int i = 0; i < array_size( po ); i++ ) {
942 if ( po[i].o == o ) {
943 lua_pushboolean( L, 1 );
944 return 1;
945 }
946 }
947 const PlayerShip_t *ps = player_getShipStack();
948 for ( int i = 0; i < array_size( ps ); i++ ) {
949 for ( int j = 0; j < array_size( ps[i].p->outfits ); j++ ) {
950 if ( ps[i].p->outfits[j]->outfit == o ) {
951 lua_pushboolean( L, 1 );
952 return 1;
953 }
954 }
955 }
956 const Spob *ss = spob_getAll();
957 for ( int i = 0; i < array_size( ss ); i++ ) {
958 const Spob *spb = &ss[i];
959 if ( !spob_hasService( spb, SPOB_SERVICE_SHIPYARD ) )
960 continue;
961 if ( !spob_isKnown( spb ) )
962 continue;
963 if ( tech_hasOutfit( spb->tech, o ) ) {
964 lua_pushboolean( L, 1 );
965 return 1;
966 }
967 }
968 lua_pushboolean( L, 0 );
969 return 1;
970}
971
984static int outfitL_tags( lua_State *L )
985{
986 const Outfit *o = luaL_validoutfit( L, 1 );
987 return nlua_helperTags( L, 2, o->tags );
988}
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:179
int dtype_raw(int type, double *shield, double *armour, double *knockback)
Gets the raw modulation stats of a damage type.
Definition damagetype.c:251
Header file with generic functions and naev-specifics.
#define MAX(x, y)
Definition naev.h:37
int nlua_helperTags(lua_State *L, int idx, char *const *tags)
Helper function to deal with tags.
Definition nlua.c:1118
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:99
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_exists(lua_State *L)
Gets a outfit if it exists, nil otherwise.
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:59
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.
static int outfitL_known(lua_State *L)
Gets whether or not the outfit is known to the player, as in they know a spob that sells it or own it...
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:560
int lua_ispilot(lua_State *L, int ind)
Checks to see if ind is a pilot.
Definition nlua_pilot.c:591
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
Definition nlua_ship.c:193
glTexture ** lua_pushtex(lua_State *L, glTexture *texture)
Pushes a texture on the stack.
Definition nlua_tex.c:129
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
Definition opengl_tex.c:891
const char * outfit_shortname(const Outfit *o)
Gets the short name (translated) of an outfit.
Definition outfit.c:1168
double outfit_trackmin(const Outfit *o)
Gets the outfit's minimal tracking.
Definition outfit.c:946
int outfit_isBeam(const Outfit *o)
Checks if outfit is a beam type weapon.
Definition outfit.c:639
const Outfit * outfit_getAll(void)
Gets the array (array.h) of all outfits.
Definition outfit.c:247
double outfit_cpu(const Outfit *o)
Gets the outfit's cpu usage.
Definition outfit.c:891
const Outfit * outfit_get(const char *name)
Gets an outfit by name.
Definition outfit.c:223
int outfit_isLauncher(const Outfit *o)
Checks if outfit is a weapon launcher.
Definition outfit.c:649
int outfit_isWeapon(const Outfit *o)
Checks to see if an outfit is a weapon.
Definition outfit.c:603
int outfit_isToggleable(const Outfit *o)
Checks if outfit can be toggled.
Definition outfit.c:584
const Outfit * outfit_getW(const char *name)
Gets an outfit by name without warning on no-find.
Definition outfit.c:237
const char * outfit_getTypeBroad(const Outfit *o)
Gets the outfit's broad type.
Definition outfit.c:1091
double outfit_range(const Outfit *o)
Gets the outfit's range.
Definition outfit.c:899
const char * outfit_getType(const Outfit *o)
Gets the outfit's specific type.
Definition outfit.c:1060
double outfit_trackmax(const Outfit *o)
Gets the outfit's minimal tracking.
Definition outfit.c:961
int outfit_gfxStoreLoad(Outfit *o)
Loads the store graphics for the outfit.
Definition outfit.c:198
const Damage * outfit_damage(const Outfit *o)
Gets the outfit's damage.
Definition outfit.c:808
double outfit_duration(const Outfit *o)
Gets the outfit's duration.
Definition outfit.c:1030
const char * outfit_slotName(const Outfit *o)
Gets the name of the slot type of an outfit.
Definition outfit.c:405
const char * outfit_slotSize(const Outfit *o)
Gets the name of the slot size of an outfit.
Definition outfit.c:458
double outfit_energy(const Outfit *o)
Gets the outfit's energy usage.
Definition outfit.c:863
double outfit_delay(const Outfit *o)
Gets the outfit's delay.
Definition outfit.c:834
double pilot_heatCalcOutfitC(const Outfit *o)
Calculates the thermal mass of an outfit.
Definition pilot_heat.c:63
double pilot_heatCalcOutfitArea(const Outfit *o)
Calculates the effective transfer area of an outfit.
Definition pilot_heat.c:75
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.
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
Definition player.c:2804
Player_t player
Definition player.c:77
const PlayerOutfit_t * player_getOutfits(void)
Gets an array (array.h) of the player's outfits.
Definition player.c:2940
static cholmod_common C
Definition safelanes.c:106
int ss_statsMergeFromList(ShipStats *stats, const ShipStatList *list)
Updates a stat structure from a stat list.
Definition shipstats.c:666
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:1116
int ss_statsInit(ShipStats *stats)
Initializes a stat structure.
Definition shipstats.c:490
const char * sp_display(unsigned int spid)
Gets the display name of a slot property (in English).
Definition slots.c:165
int sp_required(unsigned int spid)
Gets whether or not a slot property is required.
Definition slots.c:185
int sp_exclusive(unsigned int spid)
Gets whether or not a slot property is exclusive.
Definition slots.c:195
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
Definition space.c:1166
Core damage that an outfit does.
Definition outfit.h:168
int type
Definition outfit.h:169
double disable
Definition outfit.h:174
double penetration
Definition outfit.h:171
double damage
Definition outfit.h:173
double energy
Definition outfit.h:224
double heatup
Definition outfit.h:226
double duration
Definition outfit.h:218
double warmup
Definition outfit.h:217
Damage dmg
Definition outfit.h:225
double turn
Definition outfit.h:223
double heat
Definition outfit.h:228
double min_delay
Definition outfit.h:219
double range
Definition outfit.h:222
double delay
Definition outfit.h:216
double heat
Definition outfit.h:192
double trackmin
Definition outfit.h:193
double falloff
Definition outfit.h:185
double range
Definition outfit.h:184
double delay
Definition outfit.h:182
double swivel
Definition outfit.h:195
double heatup
Definition outfit.h:190
Damage dmg
Definition outfit.h:187
double trackmax
Definition outfit.h:194
double speed
Definition outfit.h:183
double energy
Definition outfit.h:186
const struct Ship_ * ship
Definition outfit.h:334
double reload_time
Definition outfit.h:252
OutfitAmmoAI ai
Definition outfit.h:271
unsigned int spid
Definition outfit.h:140
A ship outfit, depends radically on the type.
Definition outfit.h:372
char ** tags
Definition outfit.h:413
credits_t price
Definition outfit.h:391
char * limit
Definition outfit.h:386
union Outfit::@264277167364127137334024361374356236341374052147 u
OutfitLauncherData lau
Definition outfit.h:456
OutfitBeamData bem
Definition outfit.h:455
OutfitBoltData blt
Definition outfit.h:454
double overheat_max
Definition outfit.h:404
OutfitType type
Definition outfit.h:452
glTexture * gfx_store
Definition outfit.h:398
OutfitSlot slot
Definition outfit.h:380
OutfitAfterburnerData afb
Definition outfit.h:458
int * illegalto
Definition outfit.h:387
OutfitFighterBayData bay
Definition outfit.h:459
ShipStatList * stats
Definition outfit.h:410
double overheat_min
Definition outfit.h:402
double mass
Definition outfit.h:384
char * name
Definition outfit.h:373
The representation of an in-game pilot.
Definition pilot.h:263
Wrapper for outfits.
Definition player.h:64
Player ship.
Definition player.h:72
Represents ship statistics, properties ship can use.
Definition shipstats.h:229
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Definition space.h:102
tech_group_t * tech
Definition space.h:137
int tech_hasOutfit(const tech_group_t *tech, const Outfit *outfit)
Checks to see whether a tech group contains a outfit.
Definition tech.c:755