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: give these better descriptions
23 const float WR_SETUP = 1; // (SERVER) setup weapon data
24 const float WR_THINK = 2; // (SERVER) logic to run every frame
25 const float WR_CHECKAMMO1 = 3; // (SERVER) checks ammo for weapon
26 const float WR_CHECKAMMO2 = 4; // (SERVER) checks ammo for weapon
27 const float WR_AIM = 5; // (SERVER) runs bot aiming code for this weapon
28 const float WR_INIT = 6; // (BOTH) precaches models/sounds used by this weapon
29 const float WR_SUICIDEMESSAGE = 7; // (SERVER) notification number for suicide message (may inspect w_deathtype for details)
30 const float WR_KILLMESSAGE = 8; // (SERVER) notification number for kill message (may inspect w_deathtype for details)
31 const float WR_RELOAD = 9; // (SERVER) does not need to do anything
32 const float WR_RESETPLAYER = 10; // (SERVER) does not need to do anything
33 const float WR_IMPACTEFFECT = 11; // (CLIENT) impact effect
34 const float WR_SWITCHABLE = 12; // (CLIENT) impact effect
35 const float WR_PLAYERDEATH = 13; // (SERVER) does not need to do anything
36 const float 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 const float WR_CONFIG = 15; // (ALL)
38 const float WR_ZOOMRETICLE = 16; // (CLIENT) weapon specific zoom reticle
40 #define WANT_CONST /* we WANT these to be constant, but it conflicts with the declaration in dpdefs/progsdefs.qc */
41 const float IT_UNLIMITED_WEAPON_AMMO = 1; // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
42 const float IT_UNLIMITED_SUPERWEAPONS = 2; // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
43 const float IT_CTF_SHIELDED = 4; // set for the flag shield
44 const float IT_USING_JETPACK = 8; // confirmation that button is pressed
45 const float IT_JETPACK = 16; // actual item
46 const float IT_FUEL_REGEN = 32; // fuel regeneration trigger
48 const float IT_FUEL = 128;
49 WANT_CONST float IT_SHELLS = 256;
50 WANT_CONST float IT_NAILS = 512;
51 WANT_CONST float IT_ROCKETS = 1024;
52 WANT_CONST float IT_CELLS = 2048;
53 const float IT_SUPERWEAPON = 4096;
54 const float IT_STRENGTH = 8192;
55 const float IT_INVINCIBLE = 16384;
56 const float IT_HEALTH = 32768;
58 // shared value space (union):
60 WANT_CONST float IT_KEY1 = 131072;
61 WANT_CONST float IT_KEY2 = 262144;
63 const float IT_RED_FLAG_TAKEN = 32768;
64 const float IT_RED_FLAG_LOST = 65536;
65 const float IT_RED_FLAG_CARRYING = 98304;
66 const float IT_BLUE_FLAG_TAKEN = 131072;
67 const float IT_BLUE_FLAG_LOST = 262144;
68 const float IT_BLUE_FLAG_CARRYIN = 393216;
71 const float IT_5HP = 524288;
72 const float IT_25HP = 1048576;
73 const float IT_ARMOR_SHARD = 2097152;
74 const float IT_ARMOR = 4194304;
77 const float IT_AMMO = 3968; // IT_FUEL | IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS;
78 const float IT_PICKUPMASK = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately
79 const float IT_UNLIMITED_AMMO = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
81 const float AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
84 string weaponorder_byid;
87 typedef vector WepSet;
88 WepSet WepSet_FromWeapon(float a);
90 void WepSet_AddStat();
91 void WriteWepSet(float dest, WepSet w);
94 WepSet WepSet_GetFromStat();
100 #define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much.
104 WepSet WEPSET_SUPERWEAPONS;
107 entity get_weaponinfo(float id);
108 string W_FixWeaponOrder(string order, float complete);
109 string W_NameWeaponOrder(string order);
110 string W_NumberWeaponOrder(string order);
111 string W_FixWeaponOrder_BuildImpulseList(string o);
112 string W_FixWeaponOrder_AllowIncomplete(string order);
113 string W_FixWeaponOrder_ForceComplete(string order);
115 void W_RandomWeapons(entity e, float n);
117 string W_Name(float weaponid);
120 .float GetAmmoFieldFromNum(float i);
121 string GetAmmoPicture(.float ammotype);
122 float GetAmmoStat(.float ammotype);
133 // other useful macros
134 #define WEP_ACTION(wpn,wrequest) (get_weaponinfo(wpn)).weapon_func(wrequest)
135 #define AMMO_VAL(wpn) ((get_weaponinfo(wpn)).ammo_field)
137 // =====================
138 // Weapon Registration
139 // =====================
141 // create cvars for weapon settings
142 #define WEP_ADD_CVAR_NONE(wepname,name) final float autocvar_g_balance_##wepname##_##name;
144 #define WEP_ADD_CVAR_PRI(wepname,name) WEP_ADD_CVAR_NONE(wepname, primary_##name)
145 #define WEP_ADD_CVAR_SEC(wepname,name) WEP_ADD_CVAR_NONE(wepname, secondary_##name)
146 #define WEP_ADD_CVAR_BOTH(wepname,name) \
147 WEP_ADD_CVAR_PRI(wepname, name) \
148 WEP_ADD_CVAR_SEC(wepname, name)
150 #define WEP_ADD_CVAR(wepid,wepname,mode,name) WEP_ADD_CVAR_##mode(wepname, name)
152 // create properties for weapon settings
153 #define WEP_ADD_PROP(wepid,wepname,type,prop,name) \
155 final type autocvar_g_balance_##wepname##_##name;
157 // read cvars from weapon settings
158 #define WEP_CVAR(wepname,name) autocvar_g_balance_##wepname##_##name
159 #define WEP_CVAR_PRI(wepname,name) WEP_CVAR(wepname, primary_##name)
160 #define WEP_CVAR_SEC(wepname,name) WEP_CVAR(wepname, secondary_##name)
161 #define WEP_CVAR_BOTH(wepname,isprimary,name) ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name))
163 // set initialization values for weapon settings
164 #define WEP_SKIPCVAR(unuseda,unusedb,unusedc,unusedd) /* skip cvars */
165 #define WEP_SET_PROP(wepid,wepname,type,prop,name) get_weaponinfo(WEP_##wepid).##prop = autocvar_g_balance_##wepname##_##name;
167 float w_null(float dummy);
168 void register_weapon(float id, WepSet bit, float(float) func, .float ammotype, float i, float weapontype, float pickupbasevalue, vector clr, string modelname, string shortname, string wname);
169 void register_weapons_done();
171 // entity properties of weaponinfo:
172 .float weapon; // WEP_...
173 .WepSet weapons; // WEPSET_...
174 .string netname; // short name
175 .string message; // human readable name
176 .float items; // IT_... // WEAPONTODO: I thought I removed items from weapons... ?
177 .float(float) weapon_func; // w_...
178 .vector wpcolor; // waypointsprite color
179 .string mdl; // modelname without g_, v_, w_
180 .string model; // full name of g_ model
181 .float spawnflags; // WEPSPAWNFLAG_... combined
182 .float impulse; // weapon impulse
183 .float bot_pickupbasevalue; // bot weapon priority
184 .string model2; // wpn- sprite name
185 ..float ammo_field; // main ammo field
187 // note: the fabs call is just there to hide "if result is constant" warning
188 #define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,clr,modelname,shortname,wname) \
192 void RegisterWeapons_##id() \
194 WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \
195 bit = WepSet_FromWeapon(id); \
197 if((weapontype) & WEP_FLAG_SUPERWEAPON) \
198 WEPSET_SUPERWEAPONS |= bit; \
200 register_weapon(id,bit,func,ammotype,i,weapontype,pickupbasevalue,clr,modelname,shortname,wname); \
202 ACCUMULATE_FUNCTION(RegisterWeapons, RegisterWeapons_##id)
204 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,clr,modelname,shortname,wname) \
205 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,w_null,ammotype,i,weapontype,pickupbasevalue,clr,modelname,shortname,wname)
207 #define REGISTER_WEAPON(id,func,ammotype,i,weapontype,pickupbasevalue,clr,modelname,shortname,wname) \
208 REGISTER_WEAPON_2(WEP_##id,WEPSET_##id,func,ammotype,i,weapontype,pickupbasevalue,clr,modelname,shortname,wname)
213 #undef WEP_ADD_CVAR_MO_PRI
214 #undef WEP_ADD_CVAR_MO_SEC
215 #undef WEP_ADD_CVAR_MO_BOTH
216 #undef WEP_ADD_CVAR_MO_NONE
219 #undef REGISTER_WEAPON
221 ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done);