]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items.qh
SVQC finished
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items.qh
1 float BOT_PICKUP_RATING_LOW     = 2500;
2 float BOT_PICKUP_RATING_MID     = 5000;
3 float BOT_PICKUP_RATING_HIGH    = 10000;
4
5 float WEP_TYPE_OTHER        =  0x00;    // e.g: Hook, Port-o-launch, etc
6 float WEP_TYPE_SPLASH       =  0x01;
7 float WEP_TYPE_HITSCAN      =  0x02;
8 float WEP_TYPEMASK          =  0x0F;
9 float WEP_FLAG_CANCLIMB     =  0x10;
10 float WEP_FLAG_NORMAL       =  0x20;
11 float WEP_FLAG_HIDDEN       =  0x40;
12 float WEP_FLAG_RELOADABLE   =  0x80;
13 float WEP_FLAG_SUPERWEAPON  = 0x100;
14
15 float   IT_UNLIMITED_WEAPON_AMMO     = 1;
16 // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
17 float   IT_UNLIMITED_SUPERWEAPONS    = 2;
18 // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
19 float   IT_CTF_SHIELDED              = 4; // set for the flag shield
20 float   IT_USING_JETPACK             = 8; // confirmation that button is pressed
21 float   IT_JETPACK                   = 16; // actual item
22 float   IT_FUEL_REGEN                = 32; // fuel regeneration trigger
23 float   IT_SHELLS                    = 256;
24 float   IT_NAILS                     = 512;
25 float   IT_ROCKETS                   = 1024;
26 float   IT_CELLS                     = 2048;
27 float   IT_SUPERWEAPON               = 4096;
28 float   IT_FUEL                      = 128;
29 float   IT_STRENGTH                  = 8192;
30 float   IT_INVINCIBLE                = 16384;
31 float   IT_HEALTH                    = 32768;
32 // union:
33         // for items:
34         float   IT_KEY1              = 131072;
35         float   IT_KEY2              = 262144;
36         // for players:
37         float   IT_RED_FLAG_TAKEN    = 32768;
38         float   IT_RED_FLAG_LOST     = 65536;
39         float   IT_RED_FLAG_CARRING  = 98304;
40         float   IT_BLUE_FLAG_TAKEN   = 131072;
41         float   IT_BLUE_FLAG_LOST    = 262144;
42         float   IT_BLUE_FLAG_CARRING = 393216;
43 // end
44 float   IT_5HP                       = 524288;
45 float   IT_25HP                      = 1048576;
46 float   IT_ARMOR_SHARD               = 2097152;
47 float   IT_ARMOR                     = 4194304;
48
49 float   IT_AMMO                      = 3968; // IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS | IT_FUEL;
50 float   IT_PICKUPMASK                = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately
51 float   IT_UNLIMITED_AMMO            = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
52
53 float AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
54
55 // variables:
56 string weaponorder_byid;
57
58 // functions:
59 entity get_weaponinfo(float id);
60 string W_FixWeaponOrder(string order, float complete);
61 string W_NameWeaponOrder(string order);
62 string W_NumberWeaponOrder(string order);
63
64 // ammo types
65 .float ammo_shells;
66 .float ammo_nails;
67 .float ammo_rockets;
68 .float ammo_cells;
69 .float ammo_fuel;
70 .float ammo_batteries; // dummy
71
72 // entity properties of weaponinfo:
73 .float weapon; // WEP_...
74 .string netname; // short name
75 .string message; // human readable name
76 .float items; // IT_...
77 .float(float) weapon_func; // w_...
78 .string mdl; // modelname without g_, v_, w_
79 .string model; // full name of g_ model
80 .float spawnflags; // WEPSPAWNFLAG_... combined
81 .float impulse; // weapon impulse
82 .float bot_pickupbasevalue; // bot weapon priority
83 .string model2; // wpn- sprite name
84 ..float ammo_field; // main ammo field
85 // also, weaponinfo ents can act as a WEPSET
86
87 // dynamic weapon adding
88 float w_null(float dummy);
89 void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
90 void register_weapons_done();
91
92 #if 1
93 .float _WS_weapons;
94 # define WEPSET_DECLARE_A(a) float _WS_##a
95
96 # define WEPSET_CLEAR_E(e) ((e)._WS_weapons = 0)
97 # define WEPSET_CLEAR_A(a) ((_WS_##a) = 0)
98
99 # define WEPSET_EMPTY_E(e) ((e)._WS_weapons == 0)
100 # define WEPSET_EMPTY_A(a) ((_WS_##a) == 0)
101
102 # define WEPSET_COPY_EE(e,o) ((e)._WS_weapons = (o)._WS_weapons)
103 # define WEPSET_EQ_EE(e,o) ((e)._WS_weapons == (o)._WS_weapons)
104 # define WEPSET_OR_EE(e,o) ((e)._WS_weapons |= (o)._WS_weapons)
105 # define WEPSET_AND_EE(e,o) ((e)._WS_weapons &= (o)._WS_weapons)
106 # define WEPSET_ANDNOT_EE(e,o) ((e)._WS_weapons &~= (o)._WS_weapons)
107 # define WEPSET_CONTAINS_ANY_EE(e,o) !!((e)._WS_weapons & (o)._WS_weapons)
108 # define WEPSET_CONTAINS_ALL_EE(e,o) !!(((e)._WS_weapons & (o)._WS_weapons) == (e)._WS_weapons)
109
110 # define WEPSET_COPY_EA(e,a) ((e)._WS_weapons = (_WS_##a))
111 # define WEPSET_EQ_EA(e,a) ((e)._WS_weapons == (_WS_##a))
112 # define WEPSET_OR_EA(e,a) ((e)._WS_weapons |= (_WS_##a))
113 # define WEPSET_AND_EA(e,a) ((e)._WS_weapons &= (_WS_##a))
114 # define WEPSET_ANDNOT_EA(e,a) ((e)._WS_weapons &~= (_WS_##a))
115 # define WEPSET_CONTAINS_ANY_EA(e,a) !!((e)._WS_weapons & (_WS_##a))
116 # define WEPSET_CONTAINS_ALL_EA(e,a) !!(((e)._WS_weapons & (_WS_##a)) == (_WS_##a))
117
118 # define WEPSET_COPY_EW(e,w) ((e)._WS_weapons = power2of((w) - WEP_FIRST))
119 # define WEPSET_EQ_EW(e,w) ((e)._WS_weapons == power2of((w) - WEP_FIRST))
120 # define WEPSET_OR_EW(e,w) ((e)._WS_weapons |= power2of((w) - WEP_FIRST))
121 # define WEPSET_AND_EW(e,w) ((e)._WS_weapons &= power2of((w) - WEP_FIRST))
122 # define WEPSET_ANDNOT_EW(e,w) ((e)._WS_weapons &~= power2of((w) - WEP_FIRST))
123 # define WEPSET_CONTAINS_EW(e,w) !!((e)._WS_weapons & power2of((w) - WEP_FIRST))
124
125 # define WEPSET_COPY_AE(a,e) ((_WS_##a) = (e)._WS_weapons)
126 # define WEPSET_EQ_AE(a,e) ((_WS_##a) == (e)._WS_weapons)
127 # define WEPSET_OR_AE(a,e) ((_WS_##a) |= (e)._WS_weapons)
128 # define WEPSET_AND_AE(a,e) ((_WS_##a) &= (e)._WS_weapons)
129 # define WEPSET_ANDNOT_AE(a,e) ((_WS_##a) &~= (e)._WS_weapons)
130 # define WEPSET_CONTAINS_ANY_AE(a,e) !!((_WS_##a) & (e)._WS_weapons)
131 # define WEPSET_CONTAINS_ALL_AE(a,e) !!(((_WS_##a) & (e)._WS_weapons) == (e))
132
133 # define WEPSET_COPY_AA(a,b) ((_WS_##a) = (_WS_##b))
134 # define WEPSET_EQ_AA(a,b) ((_WS_##a) == (_WS_##b))
135 # define WEPSET_OR_AA(a,b) ((_WS_##a) |= (_WS_##b))
136 # define WEPSET_AND_AA(a,b) ((_WS_##a) &= (_WS_##b))
137 # define WEPSET_ANDNOT_AA(a,b) ((_WS_##a) &~= (_WS_##b))
138 # define WEPSET_CONTAINS_ANY_AA(a,b) !!((_WS_##a) & (_WS_##b))
139 # define WEPSET_CONTAINS_ALL_AA(a,b) !!(((_WS_##a) & (_WS_##b)) == (_WS_##b))
140
141 # define WEPSET_COPY_AW(a,w) ((_WS_##a) = power2of((w) - WEP_FIRST))
142 # define WEPSET_EQ_AW(a,w) ((_WS_##a) == power2of((w) - WEP_FIRST))
143 # define WEPSET_OR_AW(a,w) ((_WS_##a) |= power2of((w) - WEP_FIRST))
144 # define WEPSET_AND_AW(a,w) ((_WS_##a) &= power2of((w) - WEP_FIRST))
145 # define WEPSET_ANDNOT_AW(a,w) ((_WS_##a) &~= power2of((w) - WEP_FIRST))
146 # define WEPSET_CONTAINS_AW(a,w) !((_WS_##a) & power2of((w) - WEP_FIRST))
147
148 # ifdef CSQC
149 #  define WEPSET_COPY_AS(a) ((_WS_##a) = getstatf(STAT_WEAPONS))
150 # endif
151
152 # ifdef SVQC
153 #  define WEPSET_ADDSTAT() addstat(STAT_WEAPONS, AS_INT, _WS_weapons)
154 # endif
155
156 #endif
157
158 float WEP_COUNT;
159 float WEP_FIRST = 1;
160 float WEP_LAST;
161 #define WEP_MAXCOUNT 24
162 WEPSET_DECLARE_A(WEPBIT_ALL);
163 WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
164 // note: the fabs call is just there to hide "if result is constant" warning
165 #define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
166         float id; \
167         float func(float); \
168         void RegisterWeapons_##id() \
169         { \
170                 WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
171                 WEPSET_OR_AW(WEPBIT_ALL, id); \
172                 if(fabs(weapontype & WEP_FLAG_SUPERWEAPON)) \
173                         WEPSET_OR_AW(WEPBIT_SUPERWEAPONS, id); \
174                 ++WEP_COUNT; \
175                 register_weapon(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
176         } \
177         ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
178 #ifdef MENUQC
179 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
180         REGISTER_WEAPON_2(WEP_##id,WEPBIT_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
181 #else
182 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
183         REGISTER_WEAPON_2(WEP_##id,WEPBIT_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
184 #endif
185
186 #include "../server/w_all.qc"
187
188 #undef REGISTER_WEAPON
189 ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done)
190
191
192 string W_FixWeaponOrder(string order, float complete);
193 string W_NumberWeaponOrder(string order);
194 string W_NameWeaponOrder(string order);
195 string W_FixWeaponOrder_BuildImpulseList(string o);
196 string W_FixWeaponOrder_AllowIncomplete(string order);
197 string W_FixWeaponOrder_ForceComplete(string order);
198
199 void W_RandomWeapons(entity e, float n);