2 #include "calculations.qh"
5 const float BOT_PICKUP_RATING_LOW = 2500;
6 const float BOT_PICKUP_RATING_MID = 5000;
7 const float BOT_PICKUP_RATING_HIGH = 10000;
9 const float WEP_TYPE_OTHER = 0x00; // not for damaging people
10 const float WEP_TYPE_SPLASH = 0x01; // splash damage
11 const float WEP_TYPE_HITSCAN = 0x02; // hitscan
12 const float WEP_TYPEMASK = 0x0F;
13 const float WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
14 const float WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
15 const float WEP_FLAG_HIDDEN = 0x40; // hides from menu
16 const float WEP_FLAG_RELOADABLE = 0x80; // can has reload
17 const float WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
18 const float WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
20 const float MAX_SHOT_DISTANCE = 32768;
22 // weapon requests // WEAPONTODO
23 #define WR_SETUP 1 // (SERVER) setup weapon data
24 #define WR_THINK 2 // (SERVER) logic to run every frame
25 #define WR_CHECKAMMO1 3 // (SERVER) checks ammo for weapon
26 #define WR_CHECKAMMO2 4 // (SERVER) checks ammo for weapon
27 #define WR_AIM 5 // (SERVER) runs bot aiming code for this weapon
28 #define WR_INIT 6 // (BOTH) precaches models/sounds used by this weapon
29 #define WR_SUICIDEMESSAGE 7 // (SERVER) notification number for suicide message (may inspect w_deathtype for details)
30 #define WR_KILLMESSAGE 8 // (SERVER) notification number for kill message (may inspect w_deathtype for details)
31 #define WR_RELOAD 9 // (SERVER) does not need to do anything
32 #define WR_RESETPLAYER 10 // (SERVER) does not need to do anything
33 #define WR_IMPACTEFFECT 11 // (CLIENT) impact effect
34 #define WR_SWITCHABLE 12 // (CLIENT) impact effect
35 #define WR_PLAYERDEATH 13 // (SERVER) does not need to do anything
36 #define WR_GONETHINK 14 // (SERVER) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
37 #define WR_CONFIG 15 // (ALL)
40 const float IT_UNLIMITED_WEAPON_AMMO = 1;
41 // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
42 const float IT_UNLIMITED_SUPERWEAPONS = 2;
43 // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
44 const float IT_CTF_SHIELDED = 4; // set for the flag shield
45 const float IT_USING_JETPACK = 8; // confirmation that button is pressed
46 const float IT_JETPACK = 16; // actual item
47 const float IT_FUEL_REGEN = 32; // fuel regeneration trigger
48 WANT_CONST float IT_SHELLS = 256;
49 WANT_CONST float IT_NAILS = 512;
50 WANT_CONST float IT_ROCKETS = 1024;
51 WANT_CONST float IT_CELLS = 2048;
52 const float IT_SUPERWEAPON = 4096;
53 const float IT_FUEL = 128;
54 const float IT_STRENGTH = 8192;
55 const float IT_INVINCIBLE = 16384;
56 const float IT_HEALTH = 32768;
59 WANT_CONST float IT_KEY1 = 131072;
60 WANT_CONST float IT_KEY2 = 262144;
62 const float IT_RED_FLAG_TAKEN = 32768;
63 const float IT_RED_FLAG_LOST = 65536;
64 const float IT_RED_FLAG_CARRYING = 98304;
65 const float IT_BLUE_FLAG_TAKEN = 131072;
66 const float IT_BLUE_FLAG_LOST = 262144;
67 const float IT_BLUE_FLAG_CARRYING = 393216;
69 const float IT_5HP = 524288;
70 const float IT_25HP = 1048576;
71 const float IT_ARMOR_SHARD = 2097152;
72 const float IT_ARMOR = 4194304;
74 const float IT_AMMO = 3968; // IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS | IT_FUEL;
75 const float IT_PICKUPMASK = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately
76 const float IT_UNLIMITED_AMMO = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
78 const float AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
81 string weaponorder_byid;
84 typedef vector WepSet;
85 WepSet WepSet_FromWeapon(float a);
87 void WepSet_AddStat();
88 void WriteWepSet(float dest, WepSet w);
91 WepSet WepSet_GetFromStat();
97 #define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much.
101 WepSet WEPSET_SUPERWEAPONS;
104 entity get_weaponinfo(float id);
105 string W_FixWeaponOrder(string order, float complete);
106 string W_NameWeaponOrder(string order);
107 string W_NumberWeaponOrder(string order);
115 .float ammo_batteries; // dummy
117 // entity properties of weaponinfo:
118 .float weapon; // WEP_...
119 .WepSet weapons; // WEPSET_...
120 .string netname; // short name
121 .string message; // human readable name
122 .float items; // IT_...
123 .float(float) weapon_func; // w_...
124 .string mdl; // modelname without g_, v_, w_
125 .string model; // full name of g_ model
126 .float spawnflags; // WEPSPAWNFLAG_... combined
127 .float impulse; // weapon impulse
128 .float bot_pickupbasevalue; // bot weapon priority
129 .string model2; // wpn- sprite name
130 ..float ammo_field; // main ammo field
132 // other useful macros
133 #define WEP_ACTION(wpn,wrequest) (get_weaponinfo(wpn)).weapon_func(wrequest)
135 // =====================
136 // Weapon Registration
137 // =====================
139 float w_null(float dummy);
140 void register_weapon(float id, WepSet bit, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
141 void register_weapons_done();
143 // note: the fabs call is just there to hide "if result is constant" warning
144 #define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
148 void RegisterWeapons_##id() \
150 WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
151 bit = WepSet_FromWeapon(id); \
153 if((weapontype) & WEP_FLAG_SUPERWEAPON) \
154 WEPSET_SUPERWEAPONS |= bit; \
156 register_weapon(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
158 ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
160 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
161 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
163 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
164 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
172 #define WEP_DUPECHECK(dupecheck,cvar) \
177 #error DUPLICATE WEAPON CVAR: cvar \
181 #define WEP_CLEAN_DUPECHECK(dupecheck) \
182 #ifdef WEP_CVAR_##weapon##_##name \
183 #undef WEP_CVAR_##weapon##_##name \
187 #define WEP_ADD_CVAR(weapon,mode,name) \
189 WEP_DUPECHECK(WEP_CVAR_P_##weapon##_##name, autocvar_g_balance_##weapon##_primary_##name) \
192 WEP_DUPECHECK(WEP_CVAR_S_##weapon##_##name, autocvar_g_balance_##weapon##_secondary_##name) \
194 #if mode == MO_BOTH \
195 WEP_DUPECHECK(WEP_CVAR_P_##weapon##_##name, autocvar_g_balance_##weapon##_primary_##name) \
196 WEP_DUPECHECK(WEP_CVAR_S_##weapon##_##name, autocvar_g_balance_##weapon##_secondary_##name) \
198 #if mode == MO_NONE \
199 WEP_DUPECHECK(WEP_CVAR_##weapon##_##name, autocvar_g_balance_##weapon##_##name) \
202 #define WEP_CVAR(weapon,name) autocvar_g_balance_##weapon##_##name
203 #define WEP_CVAR_PRI(weapon,name) WEP_CVAR(weapon, primary_##name)
204 #define WEP_CVAR_SEC(weapon,name) WEP_CVAR(weapon, secondary_##name)
205 #define WEP_CVAR_BOTH(weapon,mode,name) ((mode == MO_PRI) ? WEP_CVAR_PRI(weapon, name) : WEP_CVAR_SEC(weapon, name))
207 #define WEP_ADD_PROP(weapon,prop,name) \
209 WEP_DUPECHECK(WEP_CVAR_##weapon##_##name, autocvar_g_balance_##weapon##_##name)
211 #define WEP_SET_PROP(wepid,weapon,prop,name) get_weaponinfo(##wepid).##prop = autocvar_g_balance_##weapon##_##name;
213 #define WEP_SET_PROPS(wepsettings,wepid) \
214 #define WEP_ADD_CVAR(weapon,mode,name) \
215 #define WEP_ADD_PROP(weapon,prop,name) WEP_SET_PROP(wepid,weapon,prop,name) \
217 #undef WEP_ADD_CVAR \
224 #undef REGISTER_WEAPON
225 ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done)
227 string W_FixWeaponOrder(string order, float complete);
228 string W_NumberWeaponOrder(string order);
229 string W_NameWeaponOrder(string order);
230 string W_FixWeaponOrder_BuildImpulseList(string o);
231 string W_FixWeaponOrder_AllowIncomplete(string order);
232 string W_FixWeaponOrder_ForceComplete(string order);
234 void W_RandomWeapons(entity e, float n);
236 string W_Name(float weaponid);
238 float W_AmmoItemCode(float wpn);