5 #include "../util-pre.qh"
6 #include "../../client/sys-pre.qh"
7 #include "../../dpdefs/csprogsdefs.qc"
8 #include "../../client/sys-post.qh"
9 #include "../../client/Defs.qc"
10 #include "../../dpdefs/keycodes.qc"
11 #include "../constants.qh"
12 #include "../stats.qh"
13 #include "../../warpzonelib/anglestransform.qh"
14 #include "../../warpzonelib/mathlib.qh"
15 #include "../../warpzonelib/common.qh"
16 #include "../../warpzonelib/client.qh"
17 #include "../playerstats.qh"
18 #include "../teams.qh"
20 #include "../nades.qh"
21 #include "../buffs.qh"
23 #include "../counting.qh"
25 #include "../util-pre.qh"
26 #include "../../menu/sys-pre.qh"
27 #include "../../dpdefs/menudefs.qc"
28 #include "../../dpdefs/keycodes.qc"
29 #include "../../menu/sys-post.qh"
30 #include "../../menu/config.qh"
31 #include "../../warpzonelib/mathlib.qh"
34 #include "../../menu/oo/base.qh"
35 #include "../playerstats.qh"
36 #include "../teams.qh"
37 #include "../constants.qh"
38 #include "../mapinfo.qh"
39 #include "../campaign_common.qh"
41 #include "../util-pre.qh"
42 #include "../../server/sys-pre.qh"
43 #include "../../dpdefs/progsdefs.qc"
44 #include "../../dpdefs/dpextensions.qc"
45 #include "../../server/sys-post.qh"
46 #include "../../warpzonelib/anglestransform.qh"
47 #include "../../warpzonelib/mathlib.qh"
48 #include "../../warpzonelib/common.qh"
49 #include "../../warpzonelib/util_server.qh"
50 #include "../../warpzonelib/server.qh"
51 #include "../constants.qh"
52 #include "../stats.qh"
53 #include "../teams.qh"
55 #include "../nades.qh"
56 #include "../buffs.qh"
58 #include "../counting.qh"
59 #include "../urllib.qh"
60 #include "../command/markup.qh"
61 #include "../command/rpn.qh"
62 #include "../command/generic.qh"
63 #include "../command/shared_defs.qh"
64 #include "../net_notice.qh"
65 #include "../animdecide.qh"
66 #include "../monsters/monsters.qh"
67 #include "../monsters/sv_monsters.qh"
68 #include "../monsters/spawn.qh"
73 #include "calculations.qh"
76 const int MAX_SHOT_DISTANCE = 32768;
78 // weapon pickup ratings for bot logic
79 const int BOT_PICKUP_RATING_LOW = 2500;
80 const int BOT_PICKUP_RATING_MID = 5000;
81 const int BOT_PICKUP_RATING_HIGH = 10000;
84 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
85 const int WEP_TYPE_SPLASH = 0x01; // splash damage
86 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
87 const int WEP_TYPEMASK = 0x0F;
88 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
89 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
90 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
91 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
92 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
93 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
96 const int WR_SETUP = 1; // (SERVER) setup weapon data
97 const int WR_THINK = 2; // (SERVER) logic to run every frame
98 const int WR_CHECKAMMO1 = 3; // (SERVER) checks ammo for weapon primary
99 const int WR_CHECKAMMO2 = 4; // (SERVER) checks ammo for weapon second
100 const int WR_AIM = 5; // (SERVER) runs bot aiming code for this weapon
101 const int WR_INIT = 6; // (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties
102 const int WR_SUICIDEMESSAGE = 7; // (SERVER) notification number for suicide message (may inspect w_deathtype for details)
103 const int WR_KILLMESSAGE = 8; // (SERVER) notification number for kill message (may inspect w_deathtype for details)
104 const int WR_RELOAD = 9; // (SERVER) handles reloading for weapon
105 const int WR_RESETPLAYER = 10; // (SERVER) clears fields that the weapon may use
106 const int WR_IMPACTEFFECT = 11; // (CLIENT) impact effect for weapon explosion
107 const int WR_PLAYERDEATH = 12; // (SERVER) called whenever a player dies
108 const int WR_GONETHINK = 13; // (SERVER) logic to run when weapon is lost
109 const int WR_CONFIG = 14; // (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons)
110 const int WR_ZOOMRETICLE = 15; // (CLIENT) weapon specific zoom reticle
111 const int WR_DROP = 16; // (SERVER) the weapon is dropped
112 const int WR_PICKUP = 17; // (SERVER) a weapon is picked up
115 string weaponorder_byid;
118 typedef vector WepSet;
119 WepSet WepSet_FromWeapon(float a);
121 void WepSet_AddStat();
122 void WriteWepSet(float dest, WepSet w);
125 WepSet WepSet_GetFromStat();
129 // weapon name macros
131 #define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much.
135 WepSet WEPSET_SUPERWEAPONS;
138 entity get_weaponinfo(float id);
139 string W_FixWeaponOrder(string order, float complete);
140 string W_NameWeaponOrder(string order);
141 string W_NumberWeaponOrder(string order);
142 string W_FixWeaponOrder_BuildImpulseList(string o);
143 string W_FixWeaponOrder_AllowIncomplete(string order);
144 string W_FixWeaponOrder_ForceComplete(string order);
145 void W_RandomWeapons(entity e, float n);
147 string GetAmmoPicture(.float ammotype);
150 .float GetAmmoFieldFromNum(float i);
151 float GetAmmoStat(.float ammotype);
163 // other useful macros
164 #define WEP_ACTION(wpn,wrequest) (get_weaponinfo(wpn)).weapon_func(wrequest)
165 #define WEP_AMMO(wpn) ((get_weaponinfo(WEP_##wpn)).ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
166 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).message)
169 // ======================
170 // Configuration Macros
171 // ======================
173 // create cvars for weapon settings
174 #define WEP_ADD_CVAR_NONE(wepname,name) [[last]] float autocvar_g_balance_##wepname##_##name;
176 #define WEP_ADD_CVAR_PRI(wepname,name) WEP_ADD_CVAR_NONE(wepname, primary_##name)
177 #define WEP_ADD_CVAR_SEC(wepname,name) WEP_ADD_CVAR_NONE(wepname, secondary_##name)
178 #define WEP_ADD_CVAR_BOTH(wepname,name) \
179 WEP_ADD_CVAR_PRI(wepname, name) \
180 WEP_ADD_CVAR_SEC(wepname, name)
182 #define WEP_ADD_CVAR(wepid,wepname,mode,name) WEP_ADD_CVAR_##mode(wepname, name)
184 // create properties for weapon settings
185 #define WEP_ADD_PROP(wepid,wepname,type,prop,name) \
187 [[last]] type autocvar_g_balance_##wepname##_##name;
189 // read cvars from weapon settings
190 #define WEP_CVAR(wepname,name) autocvar_g_balance_##wepname##_##name
191 #define WEP_CVAR_PRI(wepname,name) WEP_CVAR(wepname, primary_##name)
192 #define WEP_CVAR_SEC(wepname,name) WEP_CVAR(wepname, secondary_##name)
193 #define WEP_CVAR_BOTH(wepname,isprimary,name) ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))
195 // set initialization values for weapon settings
196 #define WEP_SKIP_CVAR(unuseda,unusedb,unusedc,unusedd) /* skip cvars */
197 #define WEP_SET_PROP(wepid,wepname,type,prop,name) get_weaponinfo(WEP_##wepid).##prop = autocvar_g_balance_##wepname##_##name;
200 // =====================
201 // Weapon Registration
202 // =====================
204 float w_null(float dummy);
206 void register_weapon(
213 float pickupbasevalue,
222 void register_weapons_done();
224 // entity properties of weaponinfo:
225 // fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A"
226 .float weapon; // M: WEP_id // WEP_...
227 .WepSet weapons; // A: WEPSET_id // WEPSET_...
228 .float(float) weapon_func; // M: function // w_...
229 ..float ammo_field; // M: ammotype // main ammo field
230 .int impulse; // M: impulse // weapon impulse
231 .float spawnflags; // M: flags // WEPSPAWNFLAG_... combined
232 .float bot_pickupbasevalue; // M: rating // bot weapon priority
233 .vector wpcolor; // M: color // waypointsprite color
234 .string wpmodel; // A: wpn-id // wpn- sprite name
235 .string mdl; // M: modelname // name of model (without g_ v_ or h_ prefixes)
236 .string model; // A: modelname // full path to g_ model
237 .string w_simplemdl; // M: simplemdl // simpleitems weapon model/image
238 .string w_crosshair; // M: crosshair // per-weapon crosshair: "CrosshairImage Size"
239 .float w_crosshair_size; // A: crosshair // per-weapon crosshair size (argument two of "crosshair" field)
240 .string model2; // M: wepimg // "weaponfoobar" side view image file of weapon // WEAPONTODO: Move out of skin files, move to common files
241 .string netname; // M: refname // reference name name
242 .string message; // M: wepname // human readable name
245 // note: the fabs call is just there to hide "if result is constant" warning
246 #define REGISTER_WEAPON_2(id,bit,function,ammotype,impulse,flags,rating,color,modelname,simplemdl,crosshair,wepimg,refname,wepname) \
249 float function(float); \
250 void RegisterWeapons_##id() \
252 WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
253 bit = WepSet_FromWeapon(id); \
255 if((flags) & WEP_FLAG_SUPERWEAPON) \
256 WEPSET_SUPERWEAPONS |= bit; \
258 register_weapon(id,bit,function,ammotype,impulse,flags,rating,color,modelname,simplemdl,crosshair,wepimg,refname,wepname); \
260 ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
262 #define REGISTER_WEAPON(id,function,ammotype,impulse,flags,rating,color,modelname,simplemdl,crosshair,wepimg,refname,wepname) \
263 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,impulse,flags,rating,color,modelname,simplemdl,crosshair,wepimg,refname,wepname)
265 #define REGISTER_WEAPON(id,function,ammotype,impulse,flags,rating,color,modelname,simplemdl,crosshair,wepimg,refname,wepname) \
266 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,function,ammotype,impulse,flags,rating,color,modelname,simplemdl,crosshair,wepimg,refname,wepname)
271 #undef WEP_ADD_CVAR_MO_PRI
272 #undef WEP_ADD_CVAR_MO_SEC
273 #undef WEP_ADD_CVAR_MO_BOTH
274 #undef WEP_ADD_CVAR_MO_NONE
277 #undef REGISTER_WEAPON
279 ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done);