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