3 #include <common/command/_mod.qh>
8 REGISTRY(Turrets, BITS(5))
9 #define get_turretinfo(i) REGISTRY_GET(Turrets, i)
10 REGISTER_REGISTRY(Turrets)
11 REGISTRY_CHECK(Turrets)
13 #define TR_PROPS_COMMON(P, class, prefix) \
14 P(class, prefix, aim_firetolerance_dist, float) \
15 P(class, prefix, aim_maxpitch, float) \
16 P(class, prefix, aim_maxrot, float) \
17 P(class, prefix, aim_speed, float) \
18 P(class, prefix, ammo_max, float) \
19 P(class, prefix, ammo_recharge, float) \
20 P(class, prefix, health, float) \
21 P(class, prefix, respawntime, float) \
22 P(class, prefix, shot_dmg, float) \
23 P(class, prefix, shot_force, float) \
24 P(class, prefix, shot_radius, float) \
25 P(class, prefix, shot_refire, float) \
26 P(class, prefix, shot_speed, float) \
27 P(class, prefix, shot_spread, float) \
28 P(class, prefix, shot_volly, float) \
29 P(class, prefix, shot_volly_refire, float) \
30 P(class, prefix, target_range, float) \
31 P(class, prefix, target_range_min, float) \
32 P(class, prefix, target_range_optimal, float) \
33 P(class, prefix, target_select_anglebias, float) \
34 P(class, prefix, target_select_missilebias, float) \
35 P(class, prefix, target_select_playerbias, float) \
36 P(class, prefix, target_select_rangebias, float) \
37 P(class, prefix, target_select_samebias, float) \
38 P(class, prefix, track_accel_pitch, float) \
39 P(class, prefix, track_accel_rot, float) \
40 P(class, prefix, track_blendrate, float) \
41 P(class, prefix, track_type, float) \
44 #define TR_PROPS(L, class, prefix) \
45 L(TR_CONFIG_BEGIN, TR_CONFIG, TR_CONFIG_END, class, prefix) \
48 #define TR_CONFIG(class, turname, fld, T) _TR_CONFIG(class, fld, T, turname)
50 #define TR_CONFIG_BEGIN(class) METHOD(class, tr_config, void(class this)) {
51 #define _TR_CONFIG(class, fld, T, turname) if (#turname == this.netname) TUR_CONFIG_WRITE_CVARS(turname, fld, T);
52 #define TR_CONFIG_END() }
54 #define TR_CONFIG_BEGIN(class)
55 #define _TR_CONFIG(class, fld, T, turname)
56 #define TR_CONFIG_END()
59 #define DEFAULT_FILENAME "turrets_dump.cfg"
60 // NOTE: dumpeffectinfo, dumpnotifs, dumpturrets and dumpweapons use similar code
61 GENERIC_COMMAND(dumpturrets, "Dump all turrets into " DEFAULT_FILENAME, false)
65 case CMD_REQUEST_COMMAND:
69 tur_config_alsoprint = -1;
70 string filename = argv(1);
74 filename = DEFAULT_FILENAME;
75 tur_config_alsoprint = false;
77 else if(filename == "-")
79 filename = DEFAULT_FILENAME;
80 tur_config_alsoprint = true;
82 tur_config_file = fopen(filename, FILE_WRITE);
84 if(tur_config_file >= 0)
86 Dump_Turret_Settings();
87 LOG_INFOF("Dumping turrets... File located in ^2data/data/%s^7.", filename);
88 fclose(tur_config_file);
90 tur_config_alsoprint = -1;
94 LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
97 LOG_INFO("Turrets dump command only works with sv_cmd.");
103 case CMD_REQUEST_USAGE:
105 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpturrets [<filename>]");
106 LOG_HELPF(" Where <filename> is the file to write (default is %s),", DEFAULT_FILENAME);
107 LOG_HELP(" if supplied with '-' output to console as well as default,");
108 LOG_HELP(" if left blank, it will only write to default.");
113 #undef DEFAULT_FILENAME
116 const int TUR_FIRST = 1;
117 #define TUR_LAST (REGISTRY_COUNT(Turrets) - 1)
119 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
121 REGISTER_TURRET(Null, NEW(Turret));
122 REGISTRY_DEFINE_GET(Turrets, TUR_Null)
124 #include "turret/_mod.qh"