]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/t_items.qc
some weapon system fixes; allow infinite portals to work by anticipating the collision
[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                 W_SwitchWeapon_Force(self, w_getbestweapon(self));
230
231         self = oldself;
232
233         if (self.classname == "droppedweapon")
234                 remove (self);
235         else if(self.flags & FL_WEAPON && (cvar("deathmatch") == 2 || cvar("g_weapon_stay")))
236                 return;
237         else
238         {
239                 self.solid = SOLID_NOT;
240                 self.model = string_null;
241                 self.nextthink = time + self.respawntime;
242                 self.think = Item_Respawn;
243                 setorigin (self, self.origin);
244         }
245 }
246
247 // Savage: used for item garbage-collection
248 // TODO: perhaps nice special effect?
249 void RemoveItem(void) /*FIXDECL*/
250 {
251         remove(self);
252 }
253
254 // pickup evaluation functions
255 // these functions decide how desirable an item is to the bots
256
257 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;};
258
259 float weapon_pickupevalfunc(entity player, entity item)
260 {
261         // if we already have the weapon, rate it 1/5th normal value
262         if ((player.weapons & item.weapons) == item.weapons)
263                 return item.bot_pickupbasevalue * 0.2;
264         return item.bot_pickupbasevalue;
265 };
266
267 float commodity_pickupevalfunc(entity player, entity item)
268 {
269         float c;
270         c = 0;
271         // TODO: figure out if the player even has the weapon this ammo is for?
272         // may not affect strategy much though...
273         // find out how much more ammo/armor/health the player can hold
274         if (item.ammo_shells)
275         if (player.ammo_shells < g_pickup_shells_max)
276                 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
277         if (item.ammo_nails)
278         if (player.ammo_nails < g_pickup_nails_max)
279                 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
280         if (item.ammo_rockets)
281         if (player.ammo_rockets < g_pickup_rockets_max)
282                 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
283         if (item.ammo_cells)
284         if (player.ammo_cells < g_pickup_cells_max)
285                 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
286         if (item.armorvalue)
287         if (player.armorvalue < item.max_armorvalue)
288                 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
289         if (item.health)
290         if (player.health < item.max_health)
291                 c = c + max(0, 1 - player.health / item.max_health);
292
293         return item.bot_pickupbasevalue * c;
294 };
295
296
297 .float is_item;
298 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
299 {
300         startitem_failed = FALSE;
301
302         // is it a dropped weapon?
303         if (self.classname == "droppedweapon")
304         {
305                 // it's a dropped weapon
306                 self.movetype = MOVETYPE_TOSS;
307                 self.solid = SOLID_TRIGGER;
308                 // Savage: remove thrown items after a certain period of time ("garbage collection")
309                 self.think = RemoveItem;
310                 self.nextthink = time + 60;
311                 // don't drop if in a NODROP zone (such as lava)
312                 traceline(self.origin, self.origin, MOVE_NORMAL, self);
313                 if (trace_dpstartcontents & DPCONTENTS_NODROP)
314                 {
315                         startitem_failed = TRUE;
316                         remove(self);
317                         return;
318                 }
319         }
320         else
321         {
322                 // it's a level item
323                 if(self.spawnflags & 1)
324                         self.noalign = 1;
325                 if (self.noalign)
326                         self.movetype = MOVETYPE_NONE;
327                 else
328                         self.movetype = MOVETYPE_TOSS;
329                 self.solid = SOLID_TRIGGER;
330                 // do item filtering according to game mode and other things
331                 if (!self.noalign)
332                 {
333                         // first nudge it off the floor a little bit to avoid math errors
334                         setorigin(self, self.origin + '0 0 1');
335                         // set item size before we spawn a spawnfunc_waypoint
336                         if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
337                                 setsize (self, '-16 -16 0', '16 16 48');
338                         else
339                                 setsize (self, '-16 -16 0', '16 16 32');
340                         // note droptofloor returns FALSE if stuck/or would fall too far
341                         droptofloor();
342                         waypoint_spawnforitem(self);
343                 }
344
345                 if(teams_matter)
346                 {
347                         if(self.notteam)
348                         {
349                                 print("removed non-teamplay ", self.classname, "\n");
350                                 startitem_failed = TRUE;
351                                 remove (self);
352                                 return;
353                         }
354                 }
355                 else
356                 {
357                         if(self.notfree)
358                         {
359                                 print("removed non-FFA ", self.classname, "\n");
360                                 startitem_failed = TRUE;
361                                 remove (self);
362                                 return;
363                         }
364                 }
365
366                 if(self.notq3a)
367                 {
368                         // We aren't TA or something like that, so we keep the Q3A entities
369                         print("removed non-Q3A ", self.classname, "\n");
370                         startitem_failed = TRUE;
371                         remove (self);
372                         return;
373                 }
374
375                 /*
376                  * can't do it that way, as it would break maps
377                  * TODO make a target_give like entity another way, that perhaps has
378                  * the weapon name in a key
379                 if(self.targetname)
380                 {
381                         // target_give not yet supported; maybe later
382                         print("removed targeted ", self.classname, "\n");
383                         startitem_failed = TRUE;
384                         remove (self);
385                         return;
386                 }
387                 */
388
389                 if(cvar("spawn_debug") >= 2)
390                 {
391                         entity otheritem;
392                         for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
393                         {
394                                 if(otheritem.is_item)
395                                 {
396                                         dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
397                                         dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
398                                         error("Mapper sucks.");
399                                 }
400                         }
401                         self.is_item = TRUE;
402                 }
403
404                 weaponsInMap |= weaponid;
405
406                 if(g_lms || g_instagib || g_rocketarena)
407                 {
408                         startitem_failed = TRUE;
409                         remove(self);
410                         return;
411                 }
412                 else if (g_minstagib)
413                 {
414                         // don't remove dropped items and powerups
415                         if (self.classname != "minstagib")
416                         {
417                                 startitem_failed = TRUE;
418                                 remove (self);
419                                 return;
420                         }
421                 }
422                 else if ((!cvar("g_pickup_items") || g_nixnex) && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
423                 {
424                         startitem_failed = TRUE;
425                         remove (self);
426                         return;
427                 }
428
429                 precache_model (itemmodel);
430                 precache_sound (pickupsound);
431                 precache_sound ("misc/itemrespawn.wav");
432
433                 if((itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)) || (weaponid & WEPBIT_ALL))
434                         self.target = "###item###"; // for finding the nearest item using find()
435         }
436
437         self.bot_pickup = TRUE;
438         self.bot_pickupevalfunc = pickupevalfunc;
439         self.bot_pickupbasevalue = pickupbasevalue;
440         self.mdl = itemmodel;
441         self.item_pickupsound = pickupsound;
442         // let mappers override respawntime
443         if (!self.respawntime)
444                 self.respawntime = defaultrespawntime;
445         self.netname = itemname;
446         self.items = itemid;
447         self.weapons = weaponid;
448         self.flags = FL_ITEM | itemflags;
449         self.touch = Item_Touch;
450         setmodel (self, self.mdl); // precision set below
451         self.effects |= EF_LOWPRECISION;
452         if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
453                 setsize (self, '-16 -16 0', '16 16 48');
454         else
455                 setsize (self, '-16 -16 0', '16 16 32');
456         if (itemflags & FL_WEAPON)
457         {
458                 // neutral team color for pickup weapons
459                 self.colormap = 160 * 1024 + 160;
460         }
461
462         if (cvar("g_fullbrightitems"))
463                 self.effects = self.effects | EF_FULLBRIGHT;
464 }
465
466 /* replace items in minstagib
467  * IT_STRENGTH   = invisibility
468  * IT_NAILS      = extra lives
469  * IT_INVINCIBLE = speed
470  */
471 void minstagib_items (float itemid)
472 {
473         // we don't want to replace dropped weapons ;)
474         if (self.classname == "droppedweapon")
475         {
476                 self.ammo_cells = 25;
477                 StartItem ("models/weapons/g_nex.md3",
478                         "weapons/weaponpickup.wav", 15,
479                         "Nex Gun", 0, WEPBIT_NEX, FL_WEAPON, generic_pickupevalfunc, 1000);
480                 return;
481         }
482
483         local float rnd;
484         self.classname = "minstagib";
485
486         // replace rocket launchers and nex guns with ammo cells
487         if (itemid == IT_CELLS)
488         {
489                 self.ammo_cells = 1;
490                 StartItem ("models/items/a_cells.md3",
491                         "misc/itempickup.wav", 45,
492                         "Nex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
493                 return;
494         }
495
496         // randomize
497         rnd = random() * 3;
498         if (rnd <= 1)
499                 itemid = IT_STRENGTH;
500         else if (rnd <= 2)
501                 itemid = IT_NAILS;
502         else
503                 itemid = IT_INVINCIBLE;
504
505         // replace with invis
506         if (itemid == IT_STRENGTH)
507         {
508                 self.effects = EF_ADDITIVE;
509                 self.strength_finished = 30;
510                 StartItem ("models/items/g_strength.md3",
511                         "misc/powerup.wav", 120,
512                         "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
513         }
514         // replace with extra lives
515         if (itemid == IT_NAILS)
516         {
517                 self.max_health = 1;
518                 StartItem ("models/items/g_h100.md3",
519                         "misc/megahealth.wav", 120,
520                         "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
521
522         }
523         // replace with speed
524         if (itemid == IT_INVINCIBLE)
525         {
526                 self.effects = EF_ADDITIVE;
527                 self.invincible_finished = 30;
528                 StartItem ("models/items/g_invincible.md3",
529                         "misc/powerup_shield.wav", 120,
530                         "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
531         }
532
533 }
534
535 float minst_no_auto_cells;
536 void minst_remove_item (void) {
537         if(minst_no_auto_cells)
538                 remove(self);
539 }
540
541 float weaponswapping;
542
543 void weapon_defaultspawnfunc(float wpn, float weight)
544 {
545         entity e;
546         var .float ammofield;
547         e = get_weaponinfo(wpn);
548
549         if(e.items && e.items != IT_SUPERWEAPON)
550         {
551                 ammofield = Item_CounterField(e.items);
552                 if(!self.ammofield)
553                         self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(e.items)));
554         }
555
556         StartItem (e.model, "weapons/weaponpickup.wav", 15, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, weight);
557         if (self.modelindex) // don't precache if self was removed
558                 weapon_action(e.weapon, WR_PRECACHE);
559 }
560
561 void spawnfunc_weapon_shotgun (void);
562 void spawnfunc_weapon_uzi (void) {
563         if(!weaponswapping)
564         if(q3acompat_machineshotgunswap)
565         if(self.classname != "droppedweapon")
566         {
567                 weapon_defaultspawnfunc(WEP_SHOTGUN, 2500);
568                 return;
569         }
570         weapon_defaultspawnfunc(WEP_UZI, 5000);
571 }
572
573 void spawnfunc_weapon_shotgun (void) {
574         if(!weaponswapping)
575         if(q3acompat_machineshotgunswap)
576         if(self.classname != "droppedweapon")
577         {
578                 weapon_defaultspawnfunc(WEP_UZI, 5000);
579                 return;
580         }
581         weapon_defaultspawnfunc(WEP_SHOTGUN, 2500);
582 }
583
584 void spawnfunc_weapon_nex (void)
585 {
586         if (g_minstagib)
587         {
588                 minstagib_items(IT_CELLS);
589                 self.think = minst_remove_item;
590                 self.nextthink = time + cvar("sys_ticrate");
591                 return;
592         }
593         weapon_defaultspawnfunc(WEP_NEX, 10000);
594 }
595
596 void spawnfunc_weapon_rocketlauncher (void)
597 {
598         if (g_minstagib)
599         {
600                 minstagib_items(IT_CELLS);
601                 self.think = minst_remove_item;
602                 self.nextthink = time + cvar("sys_ticrate");
603                 return;
604         }
605         weapon_defaultspawnfunc(WEP_ROCKET_LAUNCHER, 10000);
606 }
607
608 void spawnfunc_item_rockets (void) {
609         if(!self.ammo_rockets)
610                 self.ammo_rockets = g_pickup_rockets;
611         StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", 15, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
612 }
613
614 void spawnfunc_item_shells (void);
615 void spawnfunc_item_bullets (void) {
616         if(!weaponswapping)
617         if(q3acompat_machineshotgunswap)
618         if(self.classname != "droppedweapon")
619         {
620                 weaponswapping = TRUE;
621                 spawnfunc_item_shells();
622                 weaponswapping = FALSE;
623                 return;
624         }
625
626         if(!self.ammo_nails)
627                 self.ammo_nails = g_pickup_nails;
628         StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", 15, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
629 }
630
631 void spawnfunc_item_cells (void) {
632         if(!self.ammo_cells)
633                 self.ammo_cells = g_pickup_cells;
634         StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", 15, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
635 }
636
637 void spawnfunc_item_shells (void) {
638         if(!weaponswapping)
639         if(q3acompat_machineshotgunswap)
640         if(self.classname != "droppedweapon")
641         {
642                 weaponswapping = TRUE;
643                 spawnfunc_item_bullets();
644                 weaponswapping = FALSE;
645                 return;
646         }
647
648         if(!self.ammo_shells)
649                 self.ammo_shells = g_pickup_shells;
650         StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", 15, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
651 }
652
653 void spawnfunc_item_armor_small (void) {
654         if(!self.armorvalue)
655                 self.armorvalue = g_pickup_armorsmall;
656         if(!self.max_armorvalue)
657                 self.max_armorvalue = g_pickup_armorsmall_max;
658         StartItem ("models/items/g_a1.md3", "misc/armor1.wav", 15, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, 1000);
659 }
660
661 void spawnfunc_item_armor_medium (void) {
662         if(!self.armorvalue)
663                 self.armorvalue = g_pickup_armormedium;
664         if(!self.max_armorvalue)
665                 self.max_armorvalue = g_pickup_armormedium_max;
666         StartItem ("models/items/g_armormedium.md3", "misc/armor1.wav", 20, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
667 }
668
669 void spawnfunc_item_armor_large (void) {
670         if(!self.armorvalue)
671                 self.armorvalue = g_pickup_armorlarge;
672         if(!self.max_armorvalue)
673                 self.max_armorvalue = g_pickup_armorlarge_max;
674         StartItem ("models/items/g_a25.md3", "misc/armor25.wav", 30, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
675 }
676
677 void spawnfunc_item_health_small (void) {
678         if(!self.max_health)
679                 self.max_health = g_pickup_healthsmall_max;
680         if(!self.health)
681                 self.health = g_pickup_healthsmall;
682         StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", 15, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, 20000);
683 }
684
685 void spawnfunc_item_health_medium (void) {
686         if(!self.max_health)
687                 self.max_health = g_pickup_healthmedium_max;
688         if(!self.health)
689                 self.health = g_pickup_healthmedium;
690         StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", 15, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
691 }
692
693 void spawnfunc_item_health_large (void) {
694         if(!self.max_health)
695                 self.max_health = g_pickup_healthlarge_max;
696         if(!self.health)
697                 self.health = g_pickup_healthlarge;
698         StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", 20, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
699 }
700
701 void spawnfunc_item_health_mega (void) {
702         if(!cvar("g_powerup_superhealth"))
703                 return;
704
705         if(g_arena && !cvar("g_arena_powerups"))
706                 return;
707
708         if(g_minstagib) {
709                 minstagib_items(IT_NAILS);
710         } else {
711                 if(!self.max_health)
712                         self.max_health = g_pickup_healthmega_max;
713                 if(!self.health)
714                         self.health = g_pickup_healthmega;
715                 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", 30, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, 20000);
716         }
717 }
718
719 // support old misnamed entities
720 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); }  // FIXME: in Quake this is green armor, in Nexuiz maps it is an armor shard
721 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
722 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
723 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
724 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
725
726 void spawnfunc_item_strength (void) {
727         if(!cvar("g_powerup_strength"))
728                 return;
729
730         if(g_arena && !cvar("g_arena_powerups"))
731                 return;
732
733         if(g_minstagib) {
734                 minstagib_items(IT_STRENGTH);
735         } else {
736                 precache_sound("weapons/strength_fire.wav");
737                 self.strength_finished = 30;
738                 self.effects = EF_ADDITIVE;
739                 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", 120, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
740         }
741 }
742
743 void spawnfunc_item_invincible (void) {
744         if(!cvar("g_powerup_shield"))
745                 return;
746
747         if(g_arena && !cvar("g_arena_powerups"))
748                 return;
749
750         if(g_minstagib) {
751                 minstagib_items(IT_INVINCIBLE);
752         } else {
753                 self.invincible_finished = 30;
754                 self.effects = EF_ADDITIVE;
755                 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", 120, "Invulnerability", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
756         }
757 }
758 //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);}
759 //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);}
760
761 void spawnfunc_item_minst_cells (void) {
762         if (g_minstagib)
763         {
764                 minst_no_auto_cells = 1;
765                 minstagib_items(IT_CELLS);
766         }
767         else
768                 remove(self);
769 }
770
771 // compatibility:
772 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
773
774 void spawnfunc_misc_models (void)
775 {
776         SetBrushEntityModel();
777 }
778
779 void func_wall_use (void)
780 {
781         if(teams_matter)
782         {
783                 if(activator.team)
784                         self.colormap = (activator.team - 1) * 0x11;
785                 else
786                         self.colormap = 0x00;
787         }
788         else
789                 self.colormap = ceil(random() * 256) - 1;
790         self.colormap |= 1024; // RENDER_COLORMAPPED
791 }
792
793 void spawnfunc_func_wall (void)
794 {
795         SetBrushEntityModel();
796         self.solid = SOLID_BSP;
797         self.use = func_wall_use;
798 }
799