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);
108 string W_FixWeaponOrder_BuildImpulseList(string o);
109 string W_FixWeaponOrder_AllowIncomplete(string order);
110 string W_FixWeaponOrder_ForceComplete(string order);
112 void W_RandomWeapons(entity e, float n);
114 string W_Name(float weaponid);
116 float W_AmmoItemCode(float wpn);
125 .float ammo_batteries; // dummy
127 // entity properties of weaponinfo:
128 .float weapon; // WEP_...
129 .WepSet weapons; // WEPSET_...
130 .string netname; // short name
131 .string message; // human readable name
132 .float items; // IT_...
133 .float(float) weapon_func; // w_...
134 .string mdl; // modelname without g_, v_, w_
135 .string model; // full name of g_ model
136 .float spawnflags; // WEPSPAWNFLAG_... combined
137 .float impulse; // weapon impulse
138 .float bot_pickupbasevalue; // bot weapon priority
139 .string model2; // wpn- sprite name
140 ..float ammo_field; // main ammo field
142 // other useful macros
143 #define WEP_ACTION(wpn,wrequest) (get_weaponinfo(wpn)).weapon_func(wrequest)
146 // =====================
147 // Weapon Registration
148 // =====================
155 // create cvars for weapon settings
156 #define WEP_ADD_CVAR_MO_PRI(wepname,name) final float autocvar_g_balance_##wepname##_primary_##name;
157 #define WEP_ADD_CVAR_MO_SEC(wepname,name) final float autocvar_g_balance_##wepname##_secondary_##name;
158 #define WEP_ADD_CVAR_MO_BOTH(wepname,name) \
159 final float autocvar_g_balance_##wepname##_primary_##name; \
160 final float autocvar_g_balance_##wepname##_secondary_##name;
161 #define WEP_ADD_CVAR_MO_NONE(wepname,name) final float autocvar_g_balance_##wepname##_##name;
162 #define WEP_ADD_CVAR(wepid,wepname,mode,name) WEP_ADD_CVAR_##mode(wepname, name)
164 // create properties for weapon settings
165 #define WEP_ADD_PROP(wepid,wepname,prop,name) \
167 final float autocvar_g_balance_##wepname##_##name;
169 // read cvars from weapon settings
170 #define WEP_CVAR(wepname,name) autocvar_g_balance_##wepname##_##name
171 #define WEP_CVAR_PRI(wepname,name) WEP_CVAR(wepname, primary_##name)
172 #define WEP_CVAR_SEC(wepname,name) WEP_CVAR(wepname, secondary_##name)
173 #define WEP_CVAR_BOTH(wepname,mode,name) ((mode == MO_PRI) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))
175 // set initialization values for weapon settings
176 #define WEP_SKIPCVAR(unuseda,unusedb,unusedc,unusedd) /* skip cvars */
177 #define WEP_SET_PROP(wepid,wepname,prop,name) get_weaponinfo(##wepid).##prop = autocvar_g_balance_##wepname##_##name;
179 float w_null(float dummy);
180 void register_weapon(float id, WepSet bit, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname);
181 void register_weapons_done();
183 // note: the fabs call is just there to hide "if result is constant" warning
184 #define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
188 void RegisterWeapons_##id() \
190 WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
191 bit = WepSet_FromWeapon(id); \
193 if((weapontype) & WEP_FLAG_SUPERWEAPON) \
194 WEPSET_SUPERWEAPONS |= bit; \
196 register_weapon(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \
198 ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
200 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
201 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
203 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \
204 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname)
209 #undef WEP_ADD_CVAR_MO_PRI
210 #undef WEP_ADD_CVAR_MO_SEC
211 #undef WEP_ADD_CVAR_MO_BOTH
212 #undef WEP_ADD_CVAR_MO_NONE
215 #undef REGISTER_WEAPON
217 ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done);