]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/all.qh
ee0e1918e4b9194c3d5f75b510d864095476b81e
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / all.qh
1 #pragma once
2
3 #include <common/command/_mod.qh>
4 #include "config.qh"
5
6 #include "turret.qh"
7
8 REGISTRY(Turrets, BITS(5))
9 #define Turrets_from(i) _Turrets_from(i, TUR_Null)
10 #define get_turretinfo(i) Turrets_from(i)
11 REGISTER_REGISTRY(Turrets)
12 REGISTRY_CHECK(Turrets)
13
14 #define TR_PROPS_COMMON(P, class, prefix) \
15         P(class, prefix, aim_firetolerance_dist, float) \
16         P(class, prefix, aim_maxpitch, float) \
17         P(class, prefix, aim_maxrot, float) \
18         P(class, prefix, aim_speed, float) \
19         P(class, prefix, ammo_max, float) \
20         P(class, prefix, ammo_recharge, float) \
21         P(class, prefix, health, float) \
22         P(class, prefix, respawntime, float) \
23         P(class, prefix, shot_dmg, float) \
24         P(class, prefix, shot_force, float) \
25         P(class, prefix, shot_radius, float) \
26         P(class, prefix, shot_refire, float) \
27         P(class, prefix, shot_speed, float) \
28         P(class, prefix, shot_spread, float) \
29         P(class, prefix, shot_volly, float) \
30         P(class, prefix, shot_volly_refire, float) \
31         P(class, prefix, target_range, float) \
32         P(class, prefix, target_range_min, float) \
33         P(class, prefix, target_range_optimal, float) \
34         P(class, prefix, target_select_anglebias, float) \
35         P(class, prefix, target_select_missilebias, float) \
36         P(class, prefix, target_select_playerbias, float) \
37         P(class, prefix, target_select_rangebias, float) \
38         P(class, prefix, target_select_samebias, float) \
39         P(class, prefix, track_accel_pitch, float) \
40         P(class, prefix, track_accel_rot, float) \
41         P(class, prefix, track_blendrate, float) \
42         P(class, prefix, track_type, float) \
43         /**/
44
45 #define TR_PROPS(L, class, prefix) \
46         L(TR_CONFIG_BEGIN, TR_CONFIG, TR_CONFIG_END, class, prefix) \
47         /**/
48
49 #define TR_CONFIG(class, turname, fld, T)     _TR_CONFIG(class, fld, T, turname)
50 #ifdef SVQC
51         #define TR_CONFIG_BEGIN(class) METHOD(class, tr_config, void(class this)) {
52                 #define _TR_CONFIG(class, fld, T, turname) if (#turname == this.netname) TUR_CONFIG_WRITE_CVARS(turname, fld, T);
53         #define TR_CONFIG_END() }
54 #else
55         #define TR_CONFIG_BEGIN(class)
56                 #define _TR_CONFIG(class, fld, T, turname)
57         #define TR_CONFIG_END()
58 #endif
59
60 GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt", false)
61 {
62     switch(request)
63     {
64         case CMD_REQUEST_COMMAND:
65         {
66             #ifdef SVQC
67             tur_config_file = -1;
68             tur_config_alsoprint = -1;
69             string filename = argv(1);
70
71             if(filename == "")
72             {
73                 filename = "turrets_dump.cfg";
74                 tur_config_alsoprint = false;
75             }
76             else if(filename == "-")
77             {
78                 filename = "turrets_dump.cfg";
79                 tur_config_alsoprint = true;
80             }
81             tur_config_file = fopen(filename, FILE_WRITE);
82
83             if(tur_config_file >= 0)
84             {
85                 Dump_Turret_Settings();
86                 LOG_INFOF("Dumping turrets... File located in ^2data/data/%s^7.", filename);
87                 fclose(tur_config_file);
88                 tur_config_file = -1;
89                 tur_config_alsoprint = -1;
90             }
91             else
92             {
93                 LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
94             }
95             #else
96             LOG_INFO(_("Turrets dump command only works with sv_cmd."));
97             #endif
98             return;
99         }
100
101         default:
102         case CMD_REQUEST_USAGE:
103         {
104             LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]");
105             LOG_INFO("  Where 'filename' is the file to write (default is turrets_dump.cfg),");
106             LOG_INFO("  if supplied with '-' output to console as well as default,");
107             LOG_INFO("  if left blank, it will only write to default.");
108             return;
109         }
110     }
111 }
112
113
114 const int TUR_FIRST = 1;
115 #define TUR_LAST (REGISTRY_COUNT(Turrets) - 1)
116
117 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
118
119 REGISTER_TURRET(Null, NEW(Turret));
120
121 #include "turret/_mod.qh"