]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/t_items.qc
weapon_setup no longer needed its second argument, so kill it
[divverent/nexuiz.git] / data / qcsrc / server / t_items.qc
1 floatfield Item_CounterField(float it)
2 {
3         switch(it)
4         {
5                 case IT_SHELLS:      return ammo_shells;
6                 case IT_NAILS:       return ammo_nails;
7                 case IT_ROCKETS:     return ammo_rockets;
8                 case IT_CELLS:       return ammo_cells;
9                 case IT_5HP:         return health;
10                 case IT_25HP:        return health;
11                 case IT_HEALTH:      return health;
12                 case IT_ARMOR_SHARD: return armorvalue;
13                 case IT_ARMOR:       return armorvalue;
14                 // add more things here (health, armor)
15                 default:             error("requested item has no counter field");
16         }
17 }
18
19 string Item_CounterFieldName(float it)
20 {
21         switch(it)
22         {
23                 case IT_SHELLS:      return "shells";
24                 case IT_NAILS:       return "nails";
25                 case IT_ROCKETS:     return "rockets";
26                 case IT_CELLS:       return "cells";
27                 // add more things here (health, armor)
28                 default:             error("requested item has no counter field name");
29         }
30 }
31
32 void Item_SpawnByWeaponCode(float it)
33 {
34         weapon_action(it, WR_SPAWNFUNC);
35 }
36
37 .float max_armorvalue;
38
39 void Item_Respawn (void)
40 {
41         self.model = self.mdl;          // restore original model
42         self.solid = SOLID_TRIGGER;     // allow it to be touched again
43         sound (self, CHAN_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTN_NORM);        // play respawn sound
44         setorigin (self, self.origin);
45
46         //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
47         pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);
48 }
49
50 void Item_Touch (void)
51 {
52         entity oldself;
53         float _switchweapon;
54         float pickedup;
55         float it;
56         float i;
57         entity e;
58
59         // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
60         if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
61         {
62                 remove(self);
63                 return;
64         }
65         if (other.classname != "player")
66                 return;
67         if (other.deadflag)
68                 return;
69         if (self.solid != SOLID_TRIGGER)
70                 return;
71         if (self.owner == other)
72                 return;
73
74         // if nothing happens to other, just return without taking the item
75         pickedup = FALSE;
76         _switchweapon = FALSE;
77
78         if (g_minstagib)
79         {
80                 _switchweapon = TRUE;
81                 if (self.ammo_cells)
82                 {
83                         pickedup = TRUE;
84                         // play some cool sounds ;)
85                         centerprint(other, "\n");
86                         if(other.health <= 5)
87                                 announce(other, "announcer/robotic/lastsecond.ogg");
88                         else if(other.health < 50)
89                                 announce(other, "announcer/robotic/narrowly.ogg");
90                         // sound not available
91                         // else if(self.items == IT_CELLS)
92                         //      play2(other, "announce/robotic/ammo.ogg");
93
94                         if (self.weapons & WEPBIT_NEX)
95                                 W_GiveWeapon (other, WEP_NEX, "Nex");
96                         if (self.ammo_cells)
97                                 other.ammo_cells = min (other.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
98                         other.health = 100;
99                 }
100
101                 // extralife powerup
102                 if (self.max_health)
103                 {
104                         pickedup = TRUE;
105                         // sound not available
106                         // play2(other, "announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.ogg");
107                         other.armorvalue = other.armorvalue + cvar("g_minstagib_extralives");
108                         sprint(other, "^3You picked up some extra lives\n");
109                 }
110
111                 // invis powerup
112                 if (self.strength_finished)
113                 {
114                         pickedup = TRUE;
115                         // sound not available
116                         // play2(other, "announce/robotic/invisible.ogg");
117                         other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
118                 }
119
120                 // speed powerup
121                 if (self.invincible_finished)
122                 {
123                         pickedup = TRUE;
124                         // sound not available
125                         // play2(other, "announce/robotic/speed.ogg");
126                         other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
127                 }
128         }
129         else
130         {
131                 if (cvar("deathmatch") == 2 || cvar("g_weapon_stay"))
132                 {
133                         if (self.flags & FL_WEAPON && other.weapons & self.weapons && self.classname != "droppedweapon")
134                                 return;
135                         if (other.weapons & self.weapons && self.flags & FL_TOSSED)     // don't let players stack ammo by tossing weapons
136                                 return;
137                 }
138
139                 // in case the player has autoswitch enabled do the following:
140                 // if the player is using their best weapon before items are given, they
141                 // probably want to switch to an even better weapon after items are given
142                 if (other.autoswitch)
143                 if (other.switchweapon == w_getbestweapon(other))
144                         _switchweapon = TRUE;
145
146                 if (self.ammo_shells)
147                 if (other.ammo_shells < g_pickup_shells_max)
148                 {
149                         pickedup = TRUE;
150                         other.ammo_shells = min (other.ammo_shells + self.ammo_shells, g_pickup_shells_max);
151                 }
152                 if (self.ammo_nails)
153                 if (other.ammo_nails < g_pickup_nails_max)
154                 {
155                         pickedup = TRUE;
156                         other.ammo_nails = min (other.ammo_nails + self.ammo_nails, g_pickup_nails_max);
157                 }
158                 if (self.ammo_rockets)
159                 if (other.ammo_rockets < g_pickup_rockets_max)
160                 {
161                         pickedup = TRUE;
162                         other.ammo_rockets = min (other.ammo_rockets + self.ammo_rockets, g_pickup_rockets_max);
163                 }
164                 if (self.ammo_cells)
165                 if (other.ammo_cells < g_pickup_cells_max)
166                 {
167                         pickedup = TRUE;
168                         other.ammo_cells = min (other.ammo_cells + self.ammo_cells, g_pickup_cells_max);
169                 }
170
171                 if (self.flags & FL_WEAPON)
172                 if ((it = self.weapons - (self.weapons & other.weapons)))
173                 {
174                         pickedup = TRUE;
175                         for(i = WEP_FIRST; i <= WEP_LAST; ++i)
176                         {
177                                 e = get_weaponinfo(i);
178                                 if(it & e.weapons)
179                                         W_GiveWeapon (other, e.weapon, self.netname);
180                         }
181                 }
182
183                 if (self.strength_finished)
184                 {
185                         pickedup = TRUE;
186                         other.strength_finished = max(other.strength_finished, time) + cvar("g_balance_powerup_strength_time");
187                 }
188                 if (self.invincible_finished)
189                 {
190                         pickedup = TRUE;
191                         other.invincible_finished = max(other.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
192                 }
193                 //if (self.speed_finished)
194                 //{
195                 //      pickedup = TRUE;
196                 //      other.speed_finished = max(other.speed_finished, time) + cvar("g_balance_powerup_speed_time");
197                 //}
198                 //if (self.slowmo_finished)
199                 //{
200                 //      pickedup = TRUE;
201                 //      other.slowmo_finished = max(other.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
202                 //}
203
204                 if (self.health)
205                 if (other.health < self.max_health)
206                 {
207                         pickedup = TRUE;
208                         other.health = min(other.health + self.health, self.max_health);
209                         other.pauserothealth_finished = max(other.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
210                 }
211                 if (self.armorvalue)
212                 if (other.armorvalue < self.max_armorvalue)
213                 {
214                         pickedup = TRUE;
215                         other.armorvalue = min(other.armorvalue + self.armorvalue, self.max_armorvalue);
216                         other.pauserotarmor_finished = max(other.pauserotarmor_finished, time + cvar("g_balance_pause_armor_rot"));
217                 }
218         }
219
220         if (!pickedup)
221                 return;
222
223         sound (other, CHAN_AUTO, self.item_pickupsound, VOL_BASE, ATTN_NORM);
224
225         oldself = self;
226         self = other;
227
228         if (_switchweapon)
229                 self.switchweapon = w_getbestweapon(self);
230         if (self.switchweapon != self.weapon)
231                 self.cnt = self.weapon;
232
233         self = oldself;
234
235         if (self.classname == "droppedweapon")
236                 remove (self);
237         else if(self.flags & FL_WEAPON && (cvar("deathmatch") == 2 || cvar("g_weapon_stay")))
238                 return;
239         else
240         {
241                 self.solid = SOLID_NOT;
242                 self.model = string_null;
243                 self.nextthink = time + self.respawntime;
244                 self.think = Item_Respawn;
245                 setorigin (self, self.origin);
246         }
247 }
248
249 // Savage: used for item garbage-collection
250 // TODO: perhaps nice special effect?
251 void RemoveItem(void) /*FIXDECL*/
252 {
253         remove(self);
254 }
255
256 // pickup evaluation functions
257 // these functions decide how desirable an item is to the bots
258
259 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;};
260
261 float weapon_pickupevalfunc(entity player, entity item)
262 {
263         // if we already have the weapon, rate it 1/5th normal value
264         if ((player.weapons & item.weapons) == item.weapons)
265                 return item.bot_pickupbasevalue * 0.2;
266         return item.bot_pickupbasevalue;
267 };
268
269 float commodity_pickupevalfunc(entity player, entity item)
270 {
271         float c;
272         c = 0;
273         // TODO: figure out if the player even has the weapon this ammo is for?
274         // may not affect strategy much though...
275         // find out how much more ammo/armor/health the player can hold
276         if (item.ammo_shells)
277         if (player.ammo_shells < g_pickup_shells_max)
278                 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
279         if (item.ammo_nails)
280         if (player.ammo_nails < g_pickup_nails_max)
281                 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
282         if (item.ammo_rockets)
283         if (player.ammo_rockets < g_pickup_rockets_max)
284                 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
285         if (item.ammo_cells)
286         if (player.ammo_cells < g_pickup_cells_max)
287                 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
288         if (item.armorvalue)
289         if (player.armorvalue < item.max_armorvalue)
290                 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
291         if (item.health)
292         if (player.health < item.max_health)
293                 c = c + max(0, 1 - player.health / item.max_health);
294
295         return item.bot_pickupbasevalue * c;
296 };
297
298
299 .float is_item;
300 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
301 {
302         startitem_failed = FALSE;
303
304         // is it a dropped weapon?
305         if (self.classname == "droppedweapon")
306         {
307                 // it's a dropped weapon
308                 self.movetype = MOVETYPE_TOSS;
309                 self.solid = SOLID_TRIGGER;
310                 // Savage: remove thrown items after a certain period of time ("garbage collection")
311                 self.think = RemoveItem;
312                 self.nextthink = time + 60;
313                 // don't drop if in a NODROP zone (such as lava)
314                 traceline(self.origin, self.origin, MOVE_NORMAL, self);
315                 if (trace_dpstartcontents & DPCONTENTS_NODROP)
316                 {
317                         startitem_failed = TRUE;
318                         remove(self);
319                         return;
320                 }
321         }
322         else
323         {
324                 // it's a level item
325                 if(self.spawnflags & 1)
326                         self.noalign = 1;
327                 if (self.noalign)
328                         self.movetype = MOVETYPE_NONE;
329                 else
330                         self.movetype = MOVETYPE_TOSS;
331                 self.solid = SOLID_TRIGGER;
332                 // do item filtering according to game mode and other things
333                 if (!self.noalign)
334                 {
335                         // first nudge it off the floor a little bit to avoid math errors
336                         setorigin(self, self.origin + '0 0 1');
337                         // set item size before we spawn a spawnfunc_waypoint
338                         if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
339                                 setsize (self, '-16 -16 0', '16 16 48');
340                         else
341                                 setsize (self, '-16 -16 0', '16 16 32');
342                         // note droptofloor returns FALSE if stuck/or would fall too far
343                         droptofloor();
344                         waypoint_spawnforitem(self);
345                 }
346
347                 if(teams_matter)
348                 {
349                         if(self.notteam)
350                         {
351                                 print("removed non-teamplay ", self.classname, "\n");
352                                 startitem_failed = TRUE;
353                                 remove (self);
354                                 return;
355                         }
356                 }
357                 else
358                 {
359                         if(self.notfree)
360                         {
361                                 print("removed non-FFA ", self.classname, "\n");
362                                 startitem_failed = TRUE;
363                                 remove (self);
364                                 return;
365                         }
366                 }
367
368                 if(self.notq3a)
369                 {
370                         // We aren't TA or something like that, so we keep the Q3A entities
371                         print("removed non-Q3A ", self.classname, "\n");
372                         startitem_failed = TRUE;
373                         remove (self);
374                         return;
375                 }
376
377                 /*
378                  * can't do it that way, as it would break maps
379                  * TODO make a target_give like entity another way, that perhaps has
380                  * the weapon name in a key
381                 if(self.targetname)
382                 {
383                         // target_give not yet supported; maybe later
384                         print("removed targeted ", self.classname, "\n");
385                         startitem_failed = TRUE;
386                         remove (self);
387                         return;
388                 }
389                 */
390
391                 if(cvar("spawn_debug") >= 2)
392                 {
393                         entity otheritem;
394                         for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
395                         {
396                                 if(otheritem.is_item)
397                                 {
398                                         dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
399                                         dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
400                                         error("Mapper sucks.");
401                                 }
402                         }
403                         self.is_item = TRUE;
404                 }
405
406                 weaponsInMap |= weaponid;
407
408                 if(g_lms || g_instagib || g_rocketarena)
409                 {
410                         startitem_failed = TRUE;
411                         remove(self);
412                         return;
413                 }
414                 else if (g_minstagib)
415                 {
416                         // don't remove dropped items and powerups
417                         if (self.classname != "minstagib")
418                         {
419                                 startitem_failed = TRUE;
420                                 remove (self);
421                                 return;
422                         }
423                 }
424                 else if ((!cvar("g_pickup_items") || g_nixnex) && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
425                 {
426                         startitem_failed = TRUE;
427                         remove (self);
428                         return;
429                 }
430
431                 precache_model (itemmodel);
432                 precache_sound (pickupsound);
433                 precache_sound ("misc/itemrespawn.wav");
434
435                 if((itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)) || (weaponid & WEPBIT_ALL))
436                         self.target = "###item###"; // for finding the nearest item using find()
437         }
438
439         self.bot_pickup = TRUE;
440         self.bot_pickupevalfunc = pickupevalfunc;
441         self.bot_pickupbasevalue = pickupbasevalue;
442         self.mdl = itemmodel;
443         self.item_pickupsound = pickupsound;
444         // let mappers override respawntime
445         if (!self.respawntime)
446                 self.respawntime = defaultrespawntime;
447         self.netname = itemname;
448         self.items = itemid;
449         self.weapons = weaponid;
450         self.flags = FL_ITEM | itemflags;
451         self.touch = Item_Touch;
452         setmodel (self, self.mdl); // precision set below
453         self.effects |= EF_LOWPRECISION;
454         if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
455                 setsize (self, '-16 -16 0', '16 16 48');
456         else
457                 setsize (self, '-16 -16 0', '16 16 32');
458         if (itemflags & FL_WEAPON)
459         {
460                 // neutral team color for pickup weapons
461                 self.colormap = 160 * 1024 + 160;
462         }
463
464         if (cvar("g_fullbrightitems"))
465                 self.effects = self.effects | EF_FULLBRIGHT;
466 }
467
468 /* replace items in minstagib
469  * IT_STRENGTH   = invisibility
470  * IT_NAILS      = extra lives
471  * IT_INVINCIBLE = speed
472  */
473 void minstagib_items (float itemid)
474 {
475         // we don't want to replace dropped weapons ;)
476         if (self.classname == "droppedweapon")
477         {
478                 self.ammo_cells = 25;
479                 StartItem ("models/weapons/g_nex.md3",
480                         "weapons/weaponpickup.wav", 15,
481                         "Nex Gun", 0, WEPBIT_NEX, FL_WEAPON, generic_pickupevalfunc, 1000);
482                 return;
483         }
484
485         local float rnd;
486         self.classname = "minstagib";
487
488         // replace rocket launchers and nex guns with ammo cells
489         if (itemid == IT_CELLS)
490         {
491                 self.ammo_cells = 1;
492                 StartItem ("models/items/a_cells.md3",
493                         "misc/itempickup.wav", 45,
494                         "Nex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
495                 return;
496         }
497
498         // randomize
499         rnd = random() * 3;
500         if (rnd <= 1)
501                 itemid = IT_STRENGTH;
502         else if (rnd <= 2)
503                 itemid = IT_NAILS;
504         else
505                 itemid = IT_INVINCIBLE;
506
507         // replace with invis
508         if (itemid == IT_STRENGTH)
509         {
510                 self.effects = EF_ADDITIVE;
511                 self.strength_finished = 30;
512                 StartItem ("models/items/g_strength.md3",
513                         "misc/powerup.wav", 120,
514                         "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
515         }
516         // replace with extra lives
517         if (itemid == IT_NAILS)
518         {
519                 self.max_health = 1;
520                 StartItem ("models/items/g_h100.md3",
521                         "misc/megahealth.wav", 120,
522                         "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
523
524         }
525         // replace with speed
526         if (itemid == IT_INVINCIBLE)
527         {
528                 self.effects = EF_ADDITIVE;
529                 self.invincible_finished = 30;
530                 StartItem ("models/items/g_invincible.md3",
531                         "misc/powerup_shield.wav", 120,
532                         "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
533         }
534
535 }
536
537 float minst_no_auto_cells;
538 void minst_remove_item (void) {
539         if(minst_no_auto_cells)
540                 remove(self);
541 }
542
543 float weaponswapping;
544
545 void weapon_defaultspawnfunc(float wpn, float weight)
546 {
547         entity e;
548         var .float ammofield;
549         e = get_weaponinfo(wpn);
550
551         if(e.items)
552         {
553                 ammofield = Item_CounterField(e.items);
554                 if(!self.ammofield)
555                         self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(e.items)));
556         }
557
558         StartItem (e.model, "weapons/weaponpickup.wav", 15, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, weight);
559         if (self.modelindex) // don't precache if self was removed
560                 weapon_action(e.weapon, WR_PRECACHE);
561 }
562
563 void spawnfunc_weapon_shotgun (void);
564 void spawnfunc_weapon_uzi (void) {
565         if(!weaponswapping)
566         if(q3acompat_machineshotgunswap)
567         if(self.classname != "droppedweapon")
568         {
569                 weapon_defaultspawnfunc(WEP_SHOTGUN, 2500);
570                 return;
571         }
572         weapon_defaultspawnfunc(WEP_UZI, 5000);
573 }
574
575 void spawnfunc_weapon_shotgun (void) {
576         if(!weaponswapping)
577         if(q3acompat_machineshotgunswap)
578         if(self.classname != "droppedweapon")
579         {
580                 weapon_defaultspawnfunc(WEP_UZI, 5000);
581                 return;
582         }
583         weapon_defaultspawnfunc(WEP_SHOTGUN, 2500);
584 }
585
586 void spawnfunc_weapon_nex (void)
587 {
588         if (g_minstagib)
589         {
590                 minstagib_items(IT_CELLS);
591                 self.think = minst_remove_item;
592                 self.nextthink = time + cvar("sys_ticrate");
593                 return;
594         }
595         weapon_defaultspawnfunc(WEP_NEX, 10000);
596 }
597
598 void spawnfunc_weapon_rocketlauncher (void)
599 {
600         if (g_minstagib)
601         {
602                 minstagib_items(IT_CELLS);
603                 self.think = minst_remove_item;
604                 self.nextthink = time + cvar("sys_ticrate");
605                 return;
606         }
607         weapon_defaultspawnfunc(WEP_ROCKET_LAUNCHER, 10000);
608 }
609
610 void spawnfunc_item_rockets (void) {
611         if(!self.ammo_rockets)
612                 self.ammo_rockets = g_pickup_rockets;
613         StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", 15, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
614 }
615
616 void spawnfunc_item_shells (void);
617 void spawnfunc_item_bullets (void) {
618         if(!weaponswapping)
619         if(q3acompat_machineshotgunswap)
620         if(self.classname != "droppedweapon")
621         {
622                 weaponswapping = TRUE;
623                 spawnfunc_item_shells();
624                 weaponswapping = FALSE;
625                 return;
626         }
627
628         if(!self.ammo_nails)
629                 self.ammo_nails = g_pickup_nails;
630         StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", 15, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
631 }
632
633 void spawnfunc_item_cells (void) {
634         if(!self.ammo_cells)
635                 self.ammo_cells = g_pickup_cells;
636         StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", 15, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
637 }
638
639 void spawnfunc_item_shells (void) {
640         if(!weaponswapping)
641         if(q3acompat_machineshotgunswap)
642         if(self.classname != "droppedweapon")
643         {
644                 weaponswapping = TRUE;
645                 spawnfunc_item_bullets();
646                 weaponswapping = FALSE;
647                 return;
648         }
649
650         if(!self.ammo_shells)
651                 self.ammo_shells = g_pickup_shells;
652         StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", 15, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
653 }
654
655 void spawnfunc_item_armor_small (void) {
656         if(!self.armorvalue)
657                 self.armorvalue = g_pickup_armorsmall;
658         if(!self.max_armorvalue)
659                 self.max_armorvalue = g_pickup_armorsmall_max;
660         StartItem ("models/items/g_a1.md3", "misc/armor1.wav", 15, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, 1000);
661 }
662
663 void spawnfunc_item_armor_medium (void) {
664         if(!self.armorvalue)
665                 self.armorvalue = g_pickup_armormedium;
666         if(!self.max_armorvalue)
667                 self.max_armorvalue = g_pickup_armormedium_max;
668         StartItem ("models/items/g_armormedium.md3", "misc/armor1.wav", 20, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
669 }
670
671 void spawnfunc_item_armor_large (void) {
672         if(!self.armorvalue)
673                 self.armorvalue = g_pickup_armorlarge;
674         if(!self.max_armorvalue)
675                 self.max_armorvalue = g_pickup_armorlarge_max;
676         StartItem ("models/items/g_a25.md3", "misc/armor25.wav", 30, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
677 }
678
679 void spawnfunc_item_health_small (void) {
680         if(!self.max_health)
681                 self.max_health = g_pickup_healthsmall_max;
682         if(!self.health)
683                 self.health = g_pickup_healthsmall;
684         StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", 15, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, 20000);
685 }
686
687 void spawnfunc_item_health_medium (void) {
688         if(!self.max_health)
689                 self.max_health = g_pickup_healthmedium_max;
690         if(!self.health)
691                 self.health = g_pickup_healthmedium;
692         StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", 15, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
693 }
694
695 void spawnfunc_item_health_large (void) {
696         if(!self.max_health)
697                 self.max_health = g_pickup_healthlarge_max;
698         if(!self.health)
699                 self.health = g_pickup_healthlarge;
700         StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", 20, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
701 }
702
703 void spawnfunc_item_health_mega (void) {
704         if(!cvar("g_powerup_superhealth"))
705                 return;
706
707         if(g_arena && !cvar("g_arena_powerups"))
708                 return;
709
710         if(g_minstagib) {
711                 minstagib_items(IT_NAILS);
712         } else {
713                 if(!self.max_health)
714                         self.max_health = g_pickup_healthmega_max;
715                 if(!self.health)
716                         self.health = g_pickup_healthmega;
717                 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", 30, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, 20000);
718         }
719 }
720
721 // support old misnamed entities
722 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); }  // FIXME: in Quake this is green armor, in Nexuiz maps it is an armor shard
723 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
724 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
725 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
726 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
727
728 void spawnfunc_item_strength (void) {
729         if(!cvar("g_powerup_strength"))
730                 return;
731
732         if(g_arena && !cvar("g_arena_powerups"))
733                 return;
734
735         if(g_minstagib) {
736                 minstagib_items(IT_STRENGTH);
737         } else {
738                 precache_sound("weapons/strength_fire.wav");
739                 self.strength_finished = 30;
740                 self.effects = EF_ADDITIVE;
741                 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", 120, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
742         }
743 }
744
745 void spawnfunc_item_invincible (void) {
746         if(!cvar("g_powerup_shield"))
747                 return;
748
749         if(g_arena && !cvar("g_arena_powerups"))
750                 return;
751
752         if(g_minstagib) {
753                 minstagib_items(IT_INVINCIBLE);
754         } else {
755                 self.invincible_finished = 30;
756                 self.effects = EF_ADDITIVE;
757                 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", 120, "Invulnerability", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
758         }
759 }
760 //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);}
761 //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);}
762
763 void spawnfunc_item_minst_cells (void) {
764         if (g_minstagib)
765         {
766                 minst_no_auto_cells = 1;
767                 minstagib_items(IT_CELLS);
768         }
769         else
770                 remove(self);
771 }
772
773 // compatibility:
774 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
775
776 void spawnfunc_misc_models (void)
777 {
778         SetBrushEntityModel();
779 }
780
781 void func_wall_use (void)
782 {
783         if(teams_matter)
784         {
785                 if(activator.team)
786                         self.colormap = (activator.team - 1) * 0x11;
787                 else
788                         self.colormap = 0x00;
789         }
790         else
791                 self.colormap = ceil(random() * 256) - 1;
792         self.colormap |= 1024; // RENDER_COLORMAPPED
793 }
794
795 void spawnfunc_func_wall (void)
796 {
797         SetBrushEntityModel();
798         self.solid = SOLID_BSP;
799         self.use = func_wall_use;
800 }
801