]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/all.qh
Rename t_items.qc to items.qc
[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 get_turretinfo(i) REGISTRY_GET(Turrets, i)
10 REGISTER_REGISTRY(Turrets)
11 REGISTRY_CHECK(Turrets)
12
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) \
42         /**/
43
44 #define TR_PROPS(L, class, prefix) \
45         L(TR_CONFIG_BEGIN, TR_CONFIG, TR_CONFIG_END, class, prefix) \
46         /**/
47
48 #define TR_CONFIG(class, turname, fld, T)     _TR_CONFIG(class, fld, T, turname)
49 #ifdef SVQC
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() }
53 #else
54         #define TR_CONFIG_BEGIN(class)
55                 #define _TR_CONFIG(class, fld, T, turname)
56         #define TR_CONFIG_END()
57 #endif
58
59 GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt", false)
60 {
61     switch(request)
62     {
63         case CMD_REQUEST_COMMAND:
64         {
65             #ifdef SVQC
66             tur_config_file = -1;
67             tur_config_alsoprint = -1;
68             string filename = argv(1);
69
70             if(filename == "")
71             {
72                 filename = "turrets_dump.cfg";
73                 tur_config_alsoprint = false;
74             }
75             else if(filename == "-")
76             {
77                 filename = "turrets_dump.cfg";
78                 tur_config_alsoprint = true;
79             }
80             tur_config_file = fopen(filename, FILE_WRITE);
81
82             if(tur_config_file >= 0)
83             {
84                 Dump_Turret_Settings();
85                 LOG_INFOF("Dumping turrets... File located in ^2data/data/%s^7.", filename);
86                 fclose(tur_config_file);
87                 tur_config_file = -1;
88                 tur_config_alsoprint = -1;
89             }
90             else
91             {
92                 LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename);
93             }
94             #else
95             LOG_INFO(_("Turrets dump command only works with sv_cmd."));
96             #endif
97             return;
98         }
99
100         default:
101         case CMD_REQUEST_USAGE:
102         {
103             LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]");
104             LOG_HELP("  Where 'filename' is the file to write (default is turrets_dump.cfg),");
105             LOG_HELP("  if supplied with '-' output to console as well as default,");
106             LOG_HELP("  if left blank, it will only write to default.");
107             return;
108         }
109     }
110 }
111
112
113 const int TUR_FIRST = 1;
114 #define TUR_LAST (REGISTRY_COUNT(Turrets) - 1)
115
116 #define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
117
118 REGISTER_TURRET(Null, NEW(Turret));
119 REGISTRY_DEFINE_GET(Turrets, TUR_Null)
120
121 #include "turret/_mod.qh"