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