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