]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/t_items.qc
Nex is too strong... so allow server admins to change the default respawn time of...
[divverent/nexuiz.git] / data / qcsrc / server / t_items.qc
1 //void Item_ClearRespawnEffect (void) {
2 //      self.effects = self.effects - (self.effects & EF_STARDUST);
3 //}
4
5 void Item_Respawn (void)
6 {
7         self.model = self.mdl;          // restore original model
8         self.solid = SOLID_TRIGGER;     // allow it to be touched again
9         sound (self, CHAN_VOICE, "misc/itemrespawn.ogg", 1, ATTN_NORM); // play respawn sound
10         setorigin (self, self.origin);
11
12         // LordHavoc: replaced respawn stardust effect with a custom te_wizspike
13         te_wizspike(self.origin + self.mins_z * '0 0 1' + '0 0 48');
14         //// Savage: Add simple Respawn effect and make sure it gets removed
15         //self.effects = self.effects | EF_STARDUST;
16         //self.think = Item_ClearRespawnEffect;
17         //self.nextthink = time + 0.1;
18 }
19
20 void Item_Touch (void)
21 {
22         local entity oldself;
23         local float _switchweapon;
24
25         // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
26         if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
27         {
28                 remove(self);
29                 return;
30         }
31         if (other.classname != "player")
32                 return;
33         if (other.deadflag)
34                 return;
35         if (self.solid != SOLID_TRIGGER)
36                 return;
37         if (self.health && other.health >= other.max_health)
38                 return;
39         if (self.owner == other)
40                 return;
41         // Savage: Remove the respawn effect if still present
42         self.effects = self.effects - (self.effects & EF_STARDUST);
43
44         sound (self, CHAN_BODY, self.noise, 1, ATTN_NORM);
45
46         // in case the player has autoswitch enabled do the following:
47         // if the player is using their best weapon before items are given, they
48         // probably want to switch to an even better weapon after items are given
49         _switchweapon = (other.autoswitch && (other.switchweapon == w_getbestweapon(other)) || cvar("g_minstagib"));
50
51         if (cvar("g_minstagib"))
52         {
53                 if (self.ammo_cells)
54                 {
55                         // play some cool sounds ;)
56                         centermsg_freefor(other, CENTERMSG_MINSTAGIB);
57                         centermsg_freefor(other, CENTERMSG_MINSTAGIB2);
58                         if(other.health <= 5)
59                                 stuffcmd(other, "play2 announcer/robotic/lastsecond.ogg\n");
60                         else if(other.health < 50)
61                                 stuffcmd(other, "play2 announcer/robotic/narrowly.ogg\n");
62                         // sound not available
63                         // else if(self.items == IT_CELLS)
64                         //      stuffcmd(other, "play2 announce/robotic/ammo.ogg\n");
65
66                         if (self.items & IT_NEX)
67                                 W_GiveWeapon (other, IT_NEX, "Nex");
68                         if (self.ammo_cells)
69                                 other.ammo_cells = min (other.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
70                         other.health = 100;
71                 }
72
73                 // extralife powerup
74                 if (self.max_health)
75                 {
76                         // sound not available
77                         // stuffcmd(other, "play2 announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.ogg\n");
78                         other.extralives = other.extralives + cvar("g_minstagib_extralives");
79                         other.armorvalue = other.extralives;
80                         sprint(other, "^3You picked up some extra lives\n");
81                 }
82
83                 // invis powerup
84                 if (self.strength_finished)
85                 {
86                         // sound not available
87                         // stuffcmd(other, "play2 announce/robotic/invisible.ogg\n");
88                         other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
89                 }
90
91                 // speed powerup
92                 if (self.invincible_finished)
93                 {
94                         // sound not available
95                         // stuffcmd(other, "play2 announce/robotic/speed.ogg\n");
96                         other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
97                 }
98         }
99         else
100         {
101                 if (cvar("deathmatch") == 2 || cvar("g_weapon_stay"))
102                 {
103                         if (self.flags & FL_WEAPON && other.items & self.items && self.classname != "droppedweapon")
104                                 return;
105                         if (other.items & self.items && self.flags & FL_TOSSED) // don't let players stack ammo by tossing weapons
106                                 return;
107                 }
108
109                 if (self.ammo_shells)
110                         other.ammo_shells = min (other.ammo_shells + self.ammo_shells, 999);
111                 if (self.ammo_nails)
112                         other.ammo_nails = min (other.ammo_nails + self.ammo_nails, 999);
113                 if (self.ammo_rockets)
114                         other.ammo_rockets = min (other.ammo_rockets + self.ammo_rockets, 999);
115                 if (self.ammo_cells)
116                         other.ammo_cells = min (other.ammo_cells + self.ammo_cells, 999);
117
118                 if (self.items & IT_UZI)                W_GiveWeapon (other, IT_UZI, self.netname);
119                 if (self.items & IT_SHOTGUN)            W_GiveWeapon (other, IT_SHOTGUN, self.netname);
120                 if (self.items & IT_GRENADE_LAUNCHER)   W_GiveWeapon (other, IT_GRENADE_LAUNCHER, self.netname);
121                 if (self.items & IT_ELECTRO)            W_GiveWeapon (other, IT_ELECTRO, self.netname);
122                 if (self.items & IT_NEX)                W_GiveWeapon (other, IT_NEX, self.netname);
123                 if (self.items & IT_HAGAR)              W_GiveWeapon (other, IT_HAGAR, self.netname);
124                 if (self.items & IT_ROCKET_LAUNCHER)    W_GiveWeapon (other, IT_ROCKET_LAUNCHER, self.netname);
125                 if (self.items & IT_CRYLINK)            W_GiveWeapon (other, IT_CRYLINK, self.netname);
126
127                 if (self.strength_finished)
128                         other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
129                 if (self.invincible_finished)
130                         other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
131                 //if (self.speed_finished)
132                 //      other.speed_finished = max(other.speed_finished, time) + cvar("g_balance_powerup_speed_time");
133                 //if (self.slowmo_finished)
134                 //      other.slowmo_finished = max(other.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
135
136                 if (self.max_health)
137                 {
138                         other.health = other.health + self.max_health;
139                         other.pauserothealth_finished = max(other.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
140                 }
141                 if (self.health && other.health < other.max_health)
142                         other.health = min(other.health + self.health, other.max_health);
143                 if (self.armorvalue)
144                 {
145                         other.armorvalue = other.armorvalue + self.armorvalue;
146                         other.pauserotarmor_finished = max(other.pauserotarmor_finished, time + cvar("g_balance_pause_armor_rot"));
147                 }
148         }
149
150         sound (other, CHAN_AUTO, self.item_pickupsound, 1, ATTN_NORM);
151
152         oldself = self;
153         self = other;
154
155         if (_switchweapon)
156                 self.switchweapon = w_getbestweapon(self);
157         if (self.switchweapon != self.weapon)
158                 self.cnt = self.weapon;
159
160         self = oldself;
161
162         if (self.classname == "droppedweapon")
163                 remove (self);
164         else if(self.flags & FL_WEAPON && (cvar("deathmatch") == 2 || cvar("g_weapon_stay")))
165                 return;
166         else
167         {
168                 self.solid = SOLID_NOT;
169                 self.model = string_null;
170                 self.nextthink = time + self.respawntime;
171                 self.think = Item_Respawn;
172                 setorigin (self, self.origin);
173         }
174 }
175
176 // Savage: used for item garbage-collection
177 // TODO: perhaps nice special effect?
178 void RemoveItem(void) = {
179         remove(self);
180 }
181
182 // pickup evaluation functions
183 // these functions decide how desirable an item is to the bots
184
185 float(entity player, entity item) generic_pickupevalfunc = {return item.bot_pickupbasevalue;};
186
187 float(entity player, entity item) weapon_pickupevalfunc =
188 {
189         // if we already have the weapon, rate it 1/5th normal value
190         if ((player.items & item.items) == item.items)
191                 return item.bot_pickupbasevalue * 0.2;
192         return item.bot_pickupbasevalue;
193 };
194
195 float(entity player, entity item) commodity_pickupevalfunc =
196 {
197         float c;
198         c = 0;
199         // TODO: figure out if the player even has the weapon this ammo is for?
200         // may not affect strategy much though...
201         // find out how much ammo the player has, in terms of this ammo pickup
202         // (how many of these ammo pickups it would take to total the player's
203         // current ammo)
204         if (item.ammo_shells)
205                 c = c + player.ammo_shells / item.ammo_shells;
206         if (item.ammo_nails)
207                 c = c + player.ammo_nails / item.ammo_nails;
208         if (item.ammo_rockets)
209                 c = c + player.ammo_rockets / item.ammo_rockets;
210         if (item.ammo_cells)
211                 c = c + player.ammo_cells / item.ammo_cells;
212         if (item.armorvalue)
213                 c = c + player.armorvalue / item.armorvalue;
214         if (item.health)
215                 c = c + player.health / item.health / 10;
216         // the more ammo the player has, the less desirable this pickup becomes
217         c = 1 / (1 + c);
218
219         if (cvar("deathmatch") == 2) // weapon stay is on, so weapons the player already has are of no interest
220         if (item.flags & FL_WEAPON)
221         if (self.items & item.items)
222         if (item.classname != "droppedweapon")
223                 c = 0;
224
225         return item.bot_pickupbasevalue * c;
226 };
227
228
229 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
230 {
231         vector org;
232         org = self.origin;
233
234         startitem_failed = FALSE;
235
236         if (self.classname != "droppedweapon" && !self.noalign)
237         {
238                 vector z_offset;
239
240                 z_offset = '0 0 1';
241
242                 if (itemid == IT_SHELLS)
243                         z_offset = '0 0 4';
244                 else if (itemid == IT_ROCKETS)
245                         z_offset = '0 0 4';
246                 else if (itemid == IT_NAILS)
247                         z_offset = '0 0 0';
248                 else if (itemid == IT_25HP)
249                         z_offset = '0 0 5';
250                 else if (itemid == IT_ARMOR)
251                         z_offset = '0 0 3';
252
253                 org = find_floor(org) + z_offset;
254                 setorigin(self, org);
255         }
256
257         if (self.classname != "droppedweapon")
258                 waypoint_spawnforitem(self);
259
260         if (!(cvar("g_pickup_items") && !cvar("g_nixnex")) && !cvar("g_minstagib") &&
261                         itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
262         {
263                 startitem_failed = TRUE;
264                 remove (self);
265                 return;
266         }
267
268         if (cvar("g_minstagib"))
269         {
270                 // don't remove dropped items and powerups
271                 if (self.classname != "droppedweapon" &&
272                     self.classname != "minstagib")
273                 {
274                         startitem_failed = TRUE;
275                         remove (self);
276                         return;
277                 }
278         }
279
280         if(cvar("g_lms") && (self.classname != "droppedweapon"))
281         {
282                 startitem_failed = TRUE;
283                 remove(self);
284                 return;
285         }
286
287         if(cvar("g_instagib") || cvar("g_rocketarena"))
288         {
289                 startitem_failed = TRUE;
290                 remove(self);
291                 return;
292         }
293
294         if (self.classname == "droppedweapon")
295         {
296                 // don't drop if in a NODROP zone (such as lava)
297                 traceline(self.origin, self.origin, MOVE_NORMAL, self);
298                 if (trace_dpstartcontents & DPCONTENTS_NODROP)
299                 {
300                         startitem_failed = TRUE;
301                         remove(self);
302                         return;
303                 }
304         }
305
306         if(itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2 |
307                                 IT_ROCKET_LAUNCHER | IT_HAGAR | IT_NEX | IT_CRYLINK | IT_ELECTRO |
308                                 IT_GRENADE_LAUNCHER | IT_UZI | IT_SHOTGUN | IT_LASER) && self.classname != "droppedweapon")
309         {
310                 self.target = "###item###"; // for finding the nearest item using find()
311         }
312         self.bot_pickup = TRUE;
313         self.bot_pickupevalfunc = pickupevalfunc;
314         self.bot_pickupbasevalue = pickupbasevalue;
315         self.mdl = itemmodel;
316         //self.noise = pickupsound;
317         self.item_pickupsound = pickupsound;
318         // let mappers override respawntime
319         if (!self.respawntime)
320                 self.respawntime = defaultrespawntime;
321         self.netname = itemname;
322         self.items = itemid;
323         self.flags = FL_ITEM | itemflags;
324         setmodel (self, self.mdl);
325         if (itemflags & FL_WEAPON)
326         {
327                 setorigin (self, self.origin + '0 0 23');
328                 setsize (self, '-12 -12 -12', '12 12 12');
329
330                 // neutral team color for pickup weapons
331                 self.colormap = 160 * 1024 + 160;
332         }
333         else
334         {
335                 setorigin (self, self.origin + '0 0 25');
336         //      setsize (self, '-8 -8 -5', '8 8 8');
337         }
338         self.movetype = MOVETYPE_TOSS;
339         self.solid = SOLID_TRIGGER;
340         self.touch = Item_Touch;
341
342         // Savage: remove thrown items after a certain period of time ("garbage collection")
343         if (self.classname == "droppedweapon")
344         {
345                 self.think = RemoveItem;
346                 self.nextthink = time + 60;
347         }
348         else
349         {
350                 self.movetype = MOVETYPE_NONE;
351                 setorigin(self, org);
352         }
353
354         if (cvar("g_fullbrightitems"))
355                 self.effects = self.effects | EF_FULLBRIGHT;
356 }
357
358 /* replace items in minstagib
359  * IT_STRENGTH   = invisibility
360  * IT_NAILS      = extra lives
361  * IT_INVINCIBLE = speed
362  */
363 void minstagib_items (float itemid)
364 {
365         // we don't want to replace dropped weapons ;)
366         if (self.classname == "droppedweapon")
367         {
368                 self.ammo_cells = 25;
369                 StartItem ("models/weapons/g_nex.md3",
370                         "weapons/weaponpickup.ogg", 15,
371                         "Nex Gun", IT_NEX, FL_WEAPON, generic_pickupevalfunc, 1000);
372                 return;
373         }
374
375         local float rnd;
376         self.classname = "minstagib";
377
378         // replace rocket launchers and nex guns with ammo cells
379         if (itemid == IT_CELLS)
380         {
381                 self.ammo_cells = 1;
382                 StartItem ("models/items/a_cells.md3",
383                         "misc/itempickup.ogg", 45,
384                         "Nex Ammo", IT_CELLS, 0, generic_pickupevalfunc, 100);
385                 return;
386         }
387
388         // randomize
389         rnd = random() * 3;
390         if (rnd <= 1)
391                 itemid = IT_STRENGTH;
392         else if (rnd <= 2)
393                 itemid = IT_NAILS;
394         else
395                 itemid = IT_INVINCIBLE;
396
397         // replace with invis
398         if (itemid == IT_STRENGTH)
399         {
400                 self.effects = EF_ADDITIVE;
401                 self.strength_finished = 30;
402                 StartItem ("models/items/g_strength.md3",
403                         "misc/powerup.ogg", 120,
404                         "Invisibility", IT_STRENGTH, FL_POWERUP, generic_pickupevalfunc, 1000);
405         }
406         // replace with extra lives
407         if (itemid == IT_NAILS)
408         {
409                 self.max_health = 1;
410                 StartItem ("models/items/g_h100.md3",
411                         "misc/megahealth.ogg", 120,
412                         "Extralife", IT_NAILS, FL_POWERUP, generic_pickupevalfunc, 1000);
413
414         }
415         // replace with ammo
416         if (itemid == IT_INVINCIBLE)
417         {
418                 self.effects = EF_ADDITIVE;
419                 self.invincible_finished = 30;
420                 StartItem ("models/items/g_invincible.md3",
421                         "misc/powerup_shield.ogg", 120,
422                         "Speed", IT_INVINCIBLE, FL_POWERUP, generic_pickupevalfunc, 1000);
423         }
424
425 }
426
427 void weapon_uzi (void) {
428         self.ammo_nails = 120;
429         StartItem ("models/weapons/g_uzi.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_UZI), IT_UZI, FL_WEAPON, weapon_pickupevalfunc, 1000);
430 }
431
432 void weapon_shotgun (void) {
433         self.ammo_shells = 15;
434         StartItem ("models/weapons/g_shotgun.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_SHOTGUN), IT_SHOTGUN, FL_WEAPON, weapon_pickupevalfunc, 1000);
435 }
436
437 void weapon_grenadelauncher (void) {
438         self.ammo_rockets = 15;
439         StartItem ("models/weapons/g_gl.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_GRENADE_LAUNCHER), IT_GRENADE_LAUNCHER, FL_WEAPON, weapon_pickupevalfunc, 1000);
440 }
441
442 void weapon_electro (void) {
443         self.ammo_cells = 25;
444         StartItem ("models/weapons/g_electro.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_ELECTRO), IT_ELECTRO, FL_WEAPON, weapon_pickupevalfunc, 1000);
445 }
446
447 void weapon_crylink (void) {
448         self.ammo_cells = 25;
449         StartItem ("models/weapons/g_crylink.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_CRYLINK), IT_CRYLINK, FL_WEAPON, weapon_pickupevalfunc, 1000);
450 }
451
452 void weapon_nex (void) {
453         if (cvar("g_minstagib")) {
454                 minstagib_items(IT_CELLS);
455         } else {
456                 float nextime;
457                 self.ammo_cells = 25;
458                 nextime = cvar("g_balance_nex_respawntime_modifier");
459                 if(nextime)
460                         nextime = 15 * nextime;
461                 else
462                         nextime = 15;
463                 StartItem ("models/weapons/g_nex.md3", "weapons/weaponpickup.ogg", nextime, W_Name(WEP_NEX), IT_NEX, FL_WEAPON, weapon_pickupevalfunc, 1000);
464         }
465 }
466
467 void weapon_hagar (void) {
468         self.ammo_rockets = 15;
469         StartItem ("models/weapons/g_hagar.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_HAGAR), IT_HAGAR, FL_WEAPON, weapon_pickupevalfunc, 1000);
470 }
471
472 void weapon_rocketlauncher (void) {
473         if (cvar("g_minstagib")) {
474                 minstagib_items(IT_CELLS);
475         } else {
476                 self.ammo_rockets = 15;
477                 StartItem ("models/weapons/g_rl.md3", "weapons/weaponpickup.ogg", 15, W_Name(WEP_ROCKET_LAUNCHER), IT_ROCKET_LAUNCHER, FL_WEAPON, weapon_pickupevalfunc, 1000);
478         }
479 }
480
481 void item_rockets (void) {
482         self.ammo_rockets = 15;
483         StartItem ("models/items/a_rockets.md3", "misc/itempickup.ogg", 15, "rockets", IT_ROCKETS, 0, commodity_pickupevalfunc, 100);
484 }
485
486 void item_bullets (void) {
487         self.ammo_nails = 120;
488         StartItem ("models/items/a_bullets.mdl", "misc/itempickup.ogg", 15, "bullets", IT_NAILS, 0, commodity_pickupevalfunc, 100);
489 }
490
491 void item_cells (void) {
492         self.ammo_cells = 25;
493         StartItem ("models/items/a_cells.md3", "misc/itempickup.ogg", 15, "cells", IT_CELLS, 0, commodity_pickupevalfunc, 100);
494 }
495
496 void item_shells (void) {
497         self.ammo_shells = 15;
498         StartItem ("models/items/a_shells.md3", "misc/itempickup.ogg", 15, "shells", IT_SHELLS, 0, commodity_pickupevalfunc, 100);
499 }
500
501 void item_armor1 (void) {
502         self.armorvalue = 5;
503         StartItem ("models/items/g_a1.md3", "misc/armor1.wav", 15, "Armor Shard", IT_ARMOR_SHARD, 0, commodity_pickupevalfunc, 100);
504 }
505
506 void item_armor25 (void) {
507         self.armorvalue = 100;
508         StartItem ("models/items/g_a25.md3", "misc/armor25.wav", 30, "Armor", IT_ARMOR, 0, commodity_pickupevalfunc, 2000);
509 }
510
511 void item_health1 (void) {
512         self.max_health = 5;
513         StartItem ("models/items/g_h1.md3", "misc/minihealth.ogg", 15, "5 Health", IT_5HP, 0, commodity_pickupevalfunc, 100);
514 }
515
516 void item_health25 (void) {
517         self.max_health = 25;
518         StartItem ("models/items/g_h25.md3", "misc/mediumhealth.ogg", 15, "25 Health", IT_25HP, 0, commodity_pickupevalfunc, 500);
519 }
520
521 void item_health100 (void) {
522         if(!cvar("g_powerup_superhealth"))
523                 return;
524
525         if(cvar("g_arena") && !cvar("g_arena_powerups"))
526                 return;
527
528         if(cvar("g_minstagib")) {
529                 minstagib_items(IT_NAILS);
530         } else {
531                 self.max_health = 100;
532                 StartItem ("models/items/g_h100.md3", "misc/megahealth.ogg", 30, "100 Health", IT_HEALTH, 0, commodity_pickupevalfunc, 2000);
533         }
534 }
535
536 void item_strength (void) {
537         if(!cvar("g_powerup_strength"))
538                 return;
539
540         if(cvar("g_arena") && !cvar("g_arena_powerups"))
541                 return;
542
543         if(cvar("g_minstagib")) {
544                 minstagib_items(IT_STRENGTH);
545         } else {
546                 self.strength_finished = 30;
547                 self.effects = EF_ADDITIVE;StartItem ("models/items/g_strength.md3", "misc/powerup.ogg", 120, "Strength Powerup", IT_STRENGTH, FL_POWERUP, generic_pickupevalfunc, 10000);
548         }
549 }
550
551 void item_invincible (void) {
552         if(!cvar("g_powerup_shield"))
553                 return;
554
555         if(cvar("g_arena") && !cvar("g_arena_powerups"))
556                 return;
557
558         if(cvar("g_minstagib")) {
559                 minstagib_items(IT_INVINCIBLE);
560         } else {
561                 self.invincible_finished = 30;
562                 self.effects = EF_ADDITIVE;
563                 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.ogg", 120, "Invulnerability", IT_INVINCIBLE, FL_POWERUP, generic_pickupevalfunc, 10000);
564         }
565 }
566 //void item_speed (void) {self.speed_finished = 30;StartItem ("models/items/g_speed.md3", "misc/powerup.wav", 120, "Speed Powerup", IT_SPEED, FL_POWERUP, generic_pickupevalfunc, 10000);}
567 //void item_slowmo (void) {self.slowmo_finished = 30;StartItem ("models/items/g_slowmo.md3", "misc/powerup.wav", 120, "Slow Motion", IT_SLOWMO, FL_POWERUP, generic_pickupevalfunc, 10000);}
568
569 // compatibility:
570 void item_quad (void) {self.classname = "item_strength";item_strength();}
571
572 void misc_models (void)
573 {
574         precache_model (self.model);
575         setmodel (self, self.model);
576         setsize (self, self.mins, self.maxs);
577 }
578
579
580
581
582
583 floatfield Item_CounterField(float it)
584 {
585         switch(it)
586         {
587                 case IT_SHELLS:      return ammo_shells;
588                 case IT_NAILS:       return ammo_nails;
589                 case IT_ROCKETS:     return ammo_rockets;
590                 case IT_CELLS:       return ammo_cells;
591                 case IT_5HP:         return health;
592                 case IT_25HP:        return health;
593                 case IT_HEALTH:      return health;
594                 case IT_ARMOR_SHARD: return armorvalue;
595                 case IT_ARMOR:       return armorvalue;
596                 // add more things here (health, armor)
597                 default:             error("requested item has no counter field");
598         }
599 }
600
601 float Item_WeaponCode(float it)
602 {
603         switch(it)
604         {
605                 case IT_LASER:            return WEP_LASER;
606                 case IT_SHOTGUN:          return WEP_SHOTGUN;
607                 case IT_UZI:              return WEP_UZI;
608                 case IT_GRENADE_LAUNCHER: return WEP_GRENADE_LAUNCHER;
609                 case IT_ELECTRO:          return WEP_ELECTRO;
610                 case IT_CRYLINK:          return WEP_CRYLINK;
611                 case IT_NEX:              return WEP_NEX;
612                 case IT_HAGAR:            return WEP_HAGAR;
613                 case IT_ROCKET_LAUNCHER:  return WEP_ROCKET_LAUNCHER;
614                 default:                  return 0;
615         }
616 }
617
618 spawnfunc Item_SpawnFunc(float it)
619 {
620         switch(it)
621         {
622                 case IT_SHOTGUN:          return weapon_shotgun;
623                 case IT_UZI:              return weapon_uzi;
624                 case IT_GRENADE_LAUNCHER: return weapon_grenadelauncher;
625                 case IT_ELECTRO:          return weapon_electro;
626                 case IT_CRYLINK:          return weapon_crylink;
627                 case IT_NEX:              return weapon_nex;
628                 case IT_HAGAR:            return weapon_hagar;
629                 case IT_ROCKET_LAUNCHER:  return weapon_rocketlauncher;
630                 // add all other item spawn functions here
631                 default:                  error("requested item can't be spawned");
632         }
633 }