]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/t_items.qc
fix the stupid alignment of the rockets pickup. MAPPER decides how it is facing.
[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
28                 // add more things here (health, armor)
29                 default:             error("requested item has no counter field name");
30         }
31 }
32
33 .float max_armorvalue;
34
35 void Item_Respawn (void)
36 {
37         self.model = self.mdl;          // restore original model
38         self.solid = SOLID_TRIGGER;     // allow it to be touched again
39         sound (self, CHAN_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTN_NORM);        // play respawn sound
40         setorigin (self, self.origin);
41
42         //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
43         pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);
44 }
45
46 float Item_GiveTo(entity item, entity player)
47 {
48         float _switchweapon;
49         float pickedup;
50         float it;
51         float i;
52         entity e;
53
54         // if nothing happens to player, just return without taking the item
55         pickedup = FALSE;
56         _switchweapon = FALSE;
57
58         if (g_minstagib)
59         {
60                 _switchweapon = TRUE;
61                 if (item.ammo_cells)
62                 {
63                         pickedup = TRUE;
64                         // play some cool sounds ;)
65                         centerprint(player, "\n");
66                         if(player.health <= 5)
67                                 announce(player, "announcer/robotic/lastsecond.wav");
68                         else if(player.health < 50)
69                                 announce(player, "announcer/robotic/narrowly.wav");
70                         // sound not available
71                         // else if(item.items == IT_CELLS)
72                         //      play2(player, "announce/robotic/ammo.wav");
73
74                         if (item.weapons & WEPBIT_MINSTANEX)
75                                 W_GiveWeapon (player, WEP_MINSTANEX, "Nex");
76                         if (item.ammo_cells)
77                                 player.ammo_cells = min (player.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
78                         player.health = 100;
79                 }
80
81                 // extralife powerup
82                 if (item.max_health)
83                 {
84                         pickedup = TRUE;
85                         // sound not available
86                         // play2(player, "announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.wav");
87                         player.armorvalue = player.armorvalue + cvar("g_minstagib_extralives");
88                         sprint(player, "^3You picked up some extra lives\n");
89                 }
90
91                 // invis powerup
92                 if (item.strength_finished)
93                 {
94                         pickedup = TRUE;
95                         // sound not available
96                         // play2(player, "announce/robotic/invisible.wav");
97                         player.strength_finished = max(player.strength_finished, time) + cvar("g_balance_powerup_strength_time");
98                 }
99
100                 // speed powerup
101                 if (item.invincible_finished)
102                 {
103                         pickedup = TRUE;
104                         // sound not available
105                         // play2(player, "announce/robotic/speed.wav");
106                         player.invincible_finished = max(player.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
107                 }
108         }
109         else
110         {
111                 if (g_weapon_stay == 1)
112                 if not(item.flags & FL_NO_WEAPON_STAY)
113                 if (item.flags & FL_WEAPON)
114                 {
115                         if(item.classname == "droppedweapon")
116                         {
117                                 if (player.weapons & item.weapons)      // don't let players stack ammo by tossing weapons
118                                         goto skip;
119                         }
120                         else
121                         {
122                                 if (player.weapons & item.weapons)
123                                         goto skip;
124                         }
125                 }
126
127                 // in case the player has autoswitch enabled do the following:
128                 // if the player is using their best weapon before items are given, they
129                 // probably want to switch to an even better weapon after items are given
130                 if (player.autoswitch)
131                 if (player.switchweapon == w_getbestweapon(player))
132                         _switchweapon = TRUE;
133
134                 if not(player.weapons & W_WeaponBit(player.switchweapon))
135                         _switchweapon = TRUE;
136
137                 if (item.ammo_shells)
138                 if (player.ammo_shells < g_pickup_shells_max)
139                 {
140                         pickedup = TRUE;
141                         player.ammo_shells = min (player.ammo_shells + item.ammo_shells, g_pickup_shells_max);
142                 }
143                 if (item.ammo_nails)
144                 if (player.ammo_nails < g_pickup_nails_max)
145                 {
146                         pickedup = TRUE;
147                         player.ammo_nails = min (player.ammo_nails + item.ammo_nails, g_pickup_nails_max);
148                 }
149                 if (item.ammo_rockets)
150                 if (player.ammo_rockets < g_pickup_rockets_max)
151                 {
152                         pickedup = TRUE;
153                         player.ammo_rockets = min (player.ammo_rockets + item.ammo_rockets, g_pickup_rockets_max);
154                 }
155                 if (item.ammo_cells)
156                 if (player.ammo_cells < g_pickup_cells_max)
157                 {
158                         pickedup = TRUE;
159                         player.ammo_cells = min (player.ammo_cells + item.ammo_cells, g_pickup_cells_max);
160                 }
161
162                 if (item.flags & FL_WEAPON)
163                 if ((it = item.weapons - (item.weapons & player.weapons)))
164                 {
165                         pickedup = TRUE;
166                         for(i = WEP_FIRST; i <= WEP_LAST; ++i)
167                         {
168                                 e = get_weaponinfo(i);
169                                 if(it & e.weapons)
170                                         W_GiveWeapon (player, e.weapon, item.netname);
171                         }
172                 }
173
174                 if (item.strength_finished)
175                 {
176                         pickedup = TRUE;
177                         player.strength_finished = max(player.strength_finished, time) + cvar("g_balance_powerup_strength_time");
178                 }
179                 if (item.invincible_finished)
180                 {
181                         pickedup = TRUE;
182                         player.invincible_finished = max(player.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
183                 }
184                 //if (item.speed_finished)
185                 //{
186                 //      pickedup = TRUE;
187                 //      player.speed_finished = max(player.speed_finished, time) + cvar("g_balance_powerup_speed_time");
188                 //}
189                 //if (item.slowmo_finished)
190                 //{
191                 //      pickedup = TRUE;
192                 //      player.slowmo_finished = max(player.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
193                 //}
194
195                 if (item.health)
196                 if (player.health < item.max_health)
197                 {
198                         pickedup = TRUE;
199                         player.health = min(player.health + item.health, item.max_health);
200                         player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
201                 }
202                 if (item.armorvalue)
203                 if (player.armorvalue < item.max_armorvalue)
204                 {
205                         pickedup = TRUE;
206                         player.armorvalue = min(player.armorvalue + item.armorvalue, item.max_armorvalue);
207                         player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + cvar("g_balance_pause_armor_rot"));
208                 }
209         }
210
211 :skip
212         // always eat teamed entities
213         if(item.team)
214                 pickedup = TRUE;
215
216         if (!pickedup)
217                 return 0;
218
219         sound (player, CHAN_AUTO, item.item_pickupsound, VOL_BASE, ATTN_NORM);
220         if (_switchweapon)
221                 W_SwitchWeapon_Force(player, w_getbestweapon(player));
222
223         return 1;
224 }
225
226 void Item_Touch (void)
227 {
228         entity e, head;
229
230         // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
231         if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
232         {
233                 remove(self);
234                 return;
235         }
236         if (other.classname != "player")
237                 return;
238         if (other.deadflag)
239                 return;
240         if (self.solid != SOLID_TRIGGER)
241                 return;
242         if (self.owner == other)
243                 return;
244
245         if(!Item_GiveTo(self, other))
246                 return;
247
248         if (self.classname == "droppedweapon")
249                 remove (self);
250         else if((self.flags & FL_WEAPON) && !(self.flags & FL_NO_WEAPON_STAY) && g_weapon_stay)
251                 return;
252         else
253         {
254                 self.solid = SOLID_NOT;
255                 self.model = string_null;
256                 if(self.team)
257                 {
258                         RandomSelection_Init();
259                         for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
260                                 RandomSelection_Add(head, 0, head.cnt, 0);
261                         e = RandomSelection_chosen_ent;
262                 }
263                 else
264                         e = self;
265                 e.nextthink = time + self.respawntime;
266                 e.think = Item_Respawn;
267         }
268 }
269
270 void Item_FindTeam()
271 {
272         entity head, e;
273
274         if(self.effects & EF_NODRAW)
275         {
276                 // marker for item team search
277                 dprint("Initializing item team ", ftos(self.team), "\n");
278                 RandomSelection_Init();
279                 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
280                         RandomSelection_Add(head, 0, head.cnt, 0);
281                 e = RandomSelection_chosen_ent;
282                 e.state = 0;
283
284                 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
285                 {
286                         if(head != e)
287                         {
288                                 // make it a non-spawned item
289                                 head.solid = SOLID_NOT;
290                                 head.model = string_null;
291                                 head.state = 1; // state 1 = initially hidden item
292                         }
293                         head.effects = head.effects - (head.effects & EF_NODRAW);
294                 }
295         }
296 }
297
298 void Item_Reset()
299 {
300         if(self.state == 1)
301         {
302                 self.model = string_null;
303                 self.solid = SOLID_NOT;
304         }
305         else
306         {
307                 self.model = self.mdl;
308                 self.solid = SOLID_TRIGGER;
309         }
310         setorigin (self, self.origin);
311         self.think = SUB_Null;
312         self.nextthink = 0;
313 }
314
315 // Savage: used for item garbage-collection
316 // TODO: perhaps nice special effect?
317 void RemoveItem(void)
318 {
319         remove(self);
320 }
321
322 // pickup evaluation functions
323 // these functions decide how desirable an item is to the bots
324
325 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;};
326
327 float weapon_pickupevalfunc(entity player, entity item)
328 {
329         // if we already have the weapon, rate it 1/5th normal value
330         if ((player.weapons & item.weapons) == item.weapons)
331                 return item.bot_pickupbasevalue * 0.2;
332         return item.bot_pickupbasevalue;
333 };
334
335 float commodity_pickupevalfunc(entity player, entity item)
336 {
337         float c;
338         c = 0;
339         // TODO: figure out if the player even has the weapon this ammo is for?
340         // may not affect strategy much though...
341         // find out how much more ammo/armor/health the player can hold
342         if (item.ammo_shells)
343         if (player.ammo_shells < g_pickup_shells_max)
344                 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
345         if (item.ammo_nails)
346         if (player.ammo_nails < g_pickup_nails_max)
347                 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
348         if (item.ammo_rockets)
349         if (player.ammo_rockets < g_pickup_rockets_max)
350                 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
351         if (item.ammo_cells)
352         if (player.ammo_cells < g_pickup_cells_max)
353                 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
354         if (item.armorvalue)
355         if (player.armorvalue < item.max_armorvalue)
356                 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
357         if (item.health)
358         if (player.health < item.max_health)
359                 c = c + max(0, 1 - player.health / item.max_health);
360
361         return item.bot_pickupbasevalue * c;
362 };
363
364
365 .float is_item;
366 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
367 {
368         startitem_failed = FALSE;
369
370         // is it a dropped weapon?
371         if (self.classname == "droppedweapon")
372         {
373                 self.reset = SUB_Remove;
374                 // it's a dropped weapon
375                 self.movetype = MOVETYPE_TOSS;
376                 self.solid = SOLID_TRIGGER;
377                 // Savage: remove thrown items after a certain period of time ("garbage collection")
378                 self.think = RemoveItem;
379                 self.nextthink = time + 60;
380                 // don't drop if in a NODROP zone (such as lava)
381                 traceline(self.origin, self.origin, MOVE_NORMAL, self);
382                 if (trace_dpstartcontents & DPCONTENTS_NODROP)
383                 {
384                         startitem_failed = TRUE;
385                         remove(self);
386                         return;
387                 }
388         }
389         else
390         {
391                 self.reset = Item_Reset;
392                 // it's a level item
393                 if(self.spawnflags & 1)
394                         self.noalign = 1;
395                 if (self.noalign)
396                         self.movetype = MOVETYPE_NONE;
397                 else
398                         self.movetype = MOVETYPE_TOSS;
399                 self.solid = SOLID_TRIGGER;
400                 // do item filtering according to game mode and other things
401                 if (!self.noalign)
402                 {
403                         // first nudge it off the floor a little bit to avoid math errors
404                         setorigin(self, self.origin + '0 0 1');
405                         // set item size before we spawn a spawnfunc_waypoint
406                         if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
407                                 setsize (self, '-16 -16 0', '16 16 48');
408                         else
409                                 setsize (self, '-16 -16 0', '16 16 32');
410                         // note droptofloor returns FALSE if stuck/or would fall too far
411                         droptofloor();
412                         waypoint_spawnforitem(self);
413                 }
414
415                 if(teams_matter)
416                 {
417                         if(self.notteam)
418                         {
419                                 print("removed non-teamplay ", self.classname, "\n");
420                                 startitem_failed = TRUE;
421                                 remove (self);
422                                 return;
423                         }
424                 }
425                 else
426                 {
427                         if(self.notfree)
428                         {
429                                 print("removed non-FFA ", self.classname, "\n");
430                                 startitem_failed = TRUE;
431                                 remove (self);
432                                 return;
433                         }
434                 }
435
436                 if(self.notq3a)
437                 {
438                         // We aren't TA or something like that, so we keep the Q3A entities
439                         print("removed non-Q3A ", self.classname, "\n");
440                         startitem_failed = TRUE;
441                         remove (self);
442                         return;
443                 }
444
445                 /*
446                  * can't do it that way, as it would break maps
447                  * TODO make a target_give like entity another way, that perhaps has
448                  * the weapon name in a key
449                 if(self.targetname)
450                 {
451                         // target_give not yet supported; maybe later
452                         print("removed targeted ", self.classname, "\n");
453                         startitem_failed = TRUE;
454                         remove (self);
455                         return;
456                 }
457                 */
458
459                 if(cvar("spawn_debug") >= 2)
460                 {
461                         entity otheritem;
462                         for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
463                         {
464                                 if(otheritem.is_item)
465                                 {
466                                         dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
467                                         dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
468                                         error("Mapper sucks.");
469                                 }
470                         }
471                         self.is_item = TRUE;
472                 }
473
474                 weaponsInMap |= weaponid;
475
476                 if(g_lms || g_weaponarena)
477                 {
478                         startitem_failed = TRUE;
479                         remove(self);
480                         return;
481                 }
482                 else if (g_minstagib)
483                 {
484                         // don't remove dropped items and powerups
485                         if (self.classname != "minstagib")
486                         {
487                                 startitem_failed = TRUE;
488                                 remove (self);
489                                 return;
490                         }
491                 }
492                 else if ((!cvar("g_pickup_items") || g_nixnex) && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
493                 {
494                         startitem_failed = TRUE;
495                         remove (self);
496                         return;
497                 }
498
499                 precache_model (itemmodel);
500                 precache_sound (pickupsound);
501                 precache_sound ("misc/itemrespawn.wav");
502
503                 if((itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)) || (weaponid & WEPBIT_ALL))
504                         self.target = "###item###"; // for finding the nearest item using find()
505         }
506
507         self.bot_pickup = TRUE;
508         self.bot_pickupevalfunc = pickupevalfunc;
509         self.bot_pickupbasevalue = pickupbasevalue;
510         self.mdl = itemmodel;
511         self.item_pickupsound = pickupsound;
512         // let mappers override respawntime
513         if (!self.respawntime)
514                 self.respawntime = defaultrespawntime;
515         self.netname = itemname;
516         self.items = itemid;
517         self.weapons = weaponid;
518         self.flags = FL_ITEM | itemflags;
519         self.touch = Item_Touch;
520         setmodel (self, self.mdl); // precision set below
521         self.effects |= EF_LOWPRECISION;
522         if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
523                 setsize (self, '-16 -16 0', '16 16 48');
524         else
525                 setsize (self, '-16 -16 0', '16 16 32');
526         if(itemflags & FL_WEAPON)
527                 self.modelflags |= MF_ROTATE;
528
529         if (self.classname != "droppedweapon") // if dropped, colormap is already set up nicely
530         if (itemflags & FL_WEAPON)
531         {
532                 // neutral team color for pickup weapons
533                 self.colormap = 1024; // color shirt=0 pants=0 grey
534         }
535
536         if (cvar("g_fullbrightitems"))
537                 self.effects = self.effects | EF_FULLBRIGHT;
538
539         self.state = 0;
540         if(self.team)
541         {
542                 if(!self.cnt)
543                         self.cnt = 1; // item probability weight
544                 self.effects = self.effects | EF_NODRAW; // marker for item team search
545                 InitializeEntity(self, Item_FindTeam, INITPRIO_FINDTARGET);
546         }
547 }
548
549 /* replace items in minstagib
550  * IT_STRENGTH   = invisibility
551  * IT_NAILS      = extra lives
552  * IT_INVINCIBLE = speed
553  */
554 void minstagib_items (float itemid)
555 {
556         // we don't want to replace dropped weapons ;)
557         if (self.classname == "droppedweapon")
558         {
559                 self.ammo_cells = 25;
560                 StartItem ("models/weapons/g_nex.md3",
561                         "weapons/weaponpickup.wav", 15,
562                         "MinstaNex", 0, WEPBIT_MINSTANEX, FL_WEAPON, generic_pickupevalfunc, 1000);
563                 return;
564         }
565
566         local float rnd;
567         self.classname = "minstagib";
568
569         // replace rocket launchers and nex guns with ammo cells
570         if (itemid == IT_CELLS)
571         {
572                 self.ammo_cells = 1;
573                 StartItem ("models/items/a_cells.md3",
574                         "misc/itempickup.wav", 45,
575                         "Nex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
576                 return;
577         }
578
579         // randomize
580         rnd = random() * 3;
581         if (rnd <= 1)
582                 itemid = IT_STRENGTH;
583         else if (rnd <= 2)
584                 itemid = IT_NAILS;
585         else
586                 itemid = IT_INVINCIBLE;
587
588         // replace with invis
589         if (itemid == IT_STRENGTH)
590         {
591                 self.effects = EF_ADDITIVE;
592                 self.strength_finished = 30;
593                 StartItem ("models/items/g_strength.md3",
594                         "misc/powerup.wav", g_pickup_respawntime_powerup,
595                         "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID);
596         }
597         // replace with extra lives
598         if (itemid == IT_NAILS)
599         {
600                 self.max_health = 1;
601                 StartItem ("models/items/g_h100.md3",
602                         "misc/megahealth.wav", g_pickup_respawntime_powerup,
603                         "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
604
605         }
606         // replace with speed
607         if (itemid == IT_INVINCIBLE)
608         {
609                 self.effects = EF_ADDITIVE;
610                 self.invincible_finished = 30;
611                 StartItem ("models/items/g_invincible.md3",
612                         "misc/powerup_shield.wav", g_pickup_respawntime_powerup,
613                         "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID);
614         }
615
616 }
617
618 float minst_no_auto_cells;
619 void minst_remove_item (void) {
620         if(minst_no_auto_cells)
621                 remove(self);
622 }
623
624 float weaponswapping;
625 float internalteam;
626
627 void weapon_defaultspawnfunc(float wpn)
628 {
629         entity e;
630         float t;
631         var .float ammofield;
632         string s;
633         entity oldself;
634         float i, j;
635
636         // set the respawntime in advance (so replaced weapons can copy it)
637         if(!self.respawntime)
638         {
639                 e = get_weaponinfo(wpn);
640                 if(e.items == IT_SUPERWEAPON)
641                         self.respawntime = g_pickup_respawntime_powerup;
642                 else
643                         self.respawntime = g_pickup_respawntime_weapon;
644         }
645
646         if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
647         {
648                 e = get_weaponinfo(wpn);
649                 s = cvar_string(strcat("g_weaponreplace_", e.netname));
650                 if(s == "0")
651                 {
652                         remove(self);
653                         startitem_failed = TRUE;
654                         return;
655                 }
656                 t = tokenize_sane(s);
657                 if(t >= 2)
658                 {
659                         self.team = --internalteam;
660                         oldself = self;
661                         for(i = 1; i < t; ++i)
662                         {
663                                 s = argv(i);
664                                 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
665                                 {
666                                         e = get_weaponinfo(j);
667                                         if(e.netname == s)
668                                         {
669                                                 self = spawn();
670                                                 copyentity(oldself, self);
671                                                 self.classname = "replacedweapon";
672                                                 weapon_defaultspawnfunc(j);
673                                                 break;
674                                         }
675                                 }
676                                 if(j > WEP_LAST)
677                                 {
678                                         print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
679                                 }
680                         }
681                         self = oldself;
682                 }
683                 if(t >= 1)
684                 {
685                         s = argv(0);
686                         wpn = 0;
687                         for(j = WEP_FIRST; j <= WEP_LAST; ++j)
688                         {
689                                 e = get_weaponinfo(j);
690                                 if(e.netname == s)
691                                 {
692                                         wpn = j;
693                                         break;
694                                 }
695                         }
696                         if(j > WEP_LAST)
697                         {
698                                 print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
699                         }
700                 }
701                 if(wpn == 0)
702                 {
703                         remove(self);
704                         startitem_failed = TRUE;
705                         return;
706                 }
707         }
708
709         e = get_weaponinfo(wpn);
710
711         if(e.items && e.items != IT_SUPERWEAPON)
712         {
713                 ammofield = Item_CounterField(e.items);
714                 if(!self.ammofield)
715                         self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(e.items)));
716         }
717         else
718         {
719                 self.flags |= FL_NO_WEAPON_STAY;
720         }
721
722         // weapon stay isn't supported for teamed weapons
723         if(self.team)
724                 self.flags |= FL_NO_WEAPON_STAY;
725
726         if(g_weapon_stay == 2)
727         {
728                 self.ammo_shells = 0;
729                 self.ammo_nails = 0;
730                 self.ammo_cells = 0;
731                 self.ammo_rockets = 0;
732                 // weapon stay 2: don't use ammo on weapon pickups; instead
733                 // initialize all ammo types to the pickup ammo unless set by g_start_ammo_*
734         }
735
736         StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, e.bot_pickupbasevalue);
737         if (self.modelindex) // don't precache if self was removed
738                 weapon_action(e.weapon, WR_PRECACHE);
739 }
740
741 void spawnfunc_weapon_shotgun (void);
742 void spawnfunc_weapon_uzi (void) {
743         if(q3acompat_machineshotgunswap)
744         if(self.classname != "droppedweapon")
745         {
746                 weapon_defaultspawnfunc(WEP_SHOTGUN);
747                 return;
748         }
749         weapon_defaultspawnfunc(WEP_UZI);
750 }
751
752 void spawnfunc_weapon_shotgun (void) {
753         if(q3acompat_machineshotgunswap)
754         if(self.classname != "droppedweapon")
755         {
756                 weapon_defaultspawnfunc(WEP_UZI);
757                 return;
758         }
759         weapon_defaultspawnfunc(WEP_SHOTGUN);
760 }
761
762 void spawnfunc_weapon_nex (void)
763 {
764         if (g_minstagib)
765         {
766                 minstagib_items(IT_CELLS);
767                 self.think = minst_remove_item;
768                 self.nextthink = time;
769                 return;
770         }
771         weapon_defaultspawnfunc(WEP_NEX);
772 }
773
774 void spawnfunc_weapon_minstanex (void)
775 {
776         if (g_minstagib)
777         {
778                 minstagib_items(IT_CELLS);
779                 self.think = minst_remove_item;
780                 self.nextthink = time;
781                 return;
782         }
783         weapon_defaultspawnfunc(WEP_MINSTANEX);
784 }
785
786 void spawnfunc_weapon_rocketlauncher (void)
787 {
788         if (g_minstagib)
789         {
790                 minstagib_items(IT_CELLS);
791                 self.think = minst_remove_item;
792                 self.nextthink = time;
793                 return;
794         }
795         weapon_defaultspawnfunc(WEP_ROCKET_LAUNCHER);
796 }
797
798 void spawnfunc_item_rockets (void) {
799         if(!self.ammo_rockets)
800                 self.ammo_rockets = g_pickup_rockets;
801         self.angles_y -= 9; // because some "artist" wasn't even able to align it right, and only saved it in non-editable-by-open-source smd format
802         StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
803 }
804
805 void spawnfunc_item_shells (void);
806 void spawnfunc_item_bullets (void) {
807         if(!weaponswapping)
808         if(q3acompat_machineshotgunswap)
809         if(self.classname != "droppedweapon")
810         {
811                 weaponswapping = TRUE;
812                 spawnfunc_item_shells();
813                 weaponswapping = FALSE;
814                 return;
815         }
816
817         if(!self.ammo_nails)
818                 self.ammo_nails = g_pickup_nails;
819         StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_ammo, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
820 }
821
822 void spawnfunc_item_cells (void) {
823         if(!self.ammo_cells)
824                 self.ammo_cells = g_pickup_cells;
825         StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
826 }
827
828 void spawnfunc_item_shells (void) {
829         if(!weaponswapping)
830         if(q3acompat_machineshotgunswap)
831         if(self.classname != "droppedweapon")
832         {
833                 weaponswapping = TRUE;
834                 spawnfunc_item_bullets();
835                 weaponswapping = FALSE;
836                 return;
837         }
838
839         if(!self.ammo_shells)
840                 self.ammo_shells = g_pickup_shells;
841         StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
842 }
843
844 void spawnfunc_item_armor_small (void) {
845         if(!self.armorvalue)
846                 self.armorvalue = g_pickup_armorsmall;
847         if(!self.max_armorvalue)
848                 self.max_armorvalue = g_pickup_armorsmall_max;
849         StartItem ("models/items/g_a1.md3", "misc/armor1.wav", g_pickup_respawntime_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
850 }
851
852 void spawnfunc_item_armor_medium (void) {
853         if(!self.armorvalue)
854                 self.armorvalue = g_pickup_armormedium;
855         if(!self.max_armorvalue)
856                 self.max_armorvalue = g_pickup_armormedium_max;
857         StartItem ("models/items/g_armormedium.md3", "misc/armor10.wav", g_pickup_respawntime_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
858 }
859
860 void spawnfunc_item_armor_big (void) {
861         if(!self.armorvalue)
862                 self.armorvalue = g_pickup_armorbig;
863         if(!self.max_armorvalue)
864                 self.max_armorvalue = g_pickup_armorbig_max;
865         StartItem ("models/items/g_a50.md3", "misc/armor17_5.wav", g_pickup_respawntime_long, "50 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
866 }
867
868 void spawnfunc_item_armor_large (void) {
869         if(!self.armorvalue)
870                 self.armorvalue = g_pickup_armorlarge;
871         if(!self.max_armorvalue)
872                 self.max_armorvalue = g_pickup_armorlarge_max;
873         StartItem ("models/items/g_a25.md3", "misc/armor25.wav", g_pickup_respawntime_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
874 }
875
876 void spawnfunc_item_health_small (void) {
877         if(!self.max_health)
878                 self.max_health = g_pickup_healthsmall_max;
879         if(!self.health)
880                 self.health = g_pickup_healthsmall;
881         StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
882 }
883
884 void spawnfunc_item_health_medium (void) {
885         if(!self.max_health)
886                 self.max_health = g_pickup_healthmedium_max;
887         if(!self.health)
888                 self.health = g_pickup_healthmedium;
889         StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
890 }
891
892 void spawnfunc_item_health_large (void) {
893         if(!self.max_health)
894                 self.max_health = g_pickup_healthlarge_max;
895         if(!self.health)
896                 self.health = g_pickup_healthlarge;
897         StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
898 }
899
900 void spawnfunc_item_health_mega (void) {
901         if(!cvar("g_powerup_superhealth"))
902                 return;
903
904         if(g_arena && !cvar("g_arena_powerups"))
905                 return;
906
907         if(g_minstagib) {
908                 minstagib_items(IT_NAILS);
909         } else {
910                 if(!self.max_health)
911                         self.max_health = g_pickup_healthmega_max;
912                 if(!self.health)
913                         self.health = g_pickup_healthmega;
914                 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
915         }
916 }
917
918 // support old misnamed entities
919 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); }  // FIXME: in Quake this is green armor, in Nexuiz maps it is an armor shard
920 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
921 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
922 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
923 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
924
925 void spawnfunc_item_strength (void) {
926         if(!cvar("g_powerup_strength"))
927                 return;
928
929         if(g_arena && !cvar("g_arena_powerups"))
930                 return;
931
932         if(g_minstagib) {
933                 minstagib_items(IT_STRENGTH);
934         } else {
935                 precache_sound("weapons/strength_fire.wav");
936                 self.strength_finished = 30;
937                 self.effects = EF_ADDITIVE;
938                 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
939         }
940 }
941
942 void spawnfunc_item_invincible (void) {
943         if(!cvar("g_powerup_shield"))
944                 return;
945
946         if(g_arena && !cvar("g_arena_powerups"))
947                 return;
948
949         if(g_minstagib) {
950                 minstagib_items(IT_INVINCIBLE);
951         } else {
952                 self.invincible_finished = 30;
953                 self.effects = EF_ADDITIVE;
954                 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, "Invulnerability", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
955         }
956 }
957
958 void spawnfunc_item_minst_cells (void) {
959         if (g_minstagib)
960         {
961                 minst_no_auto_cells = 1;
962                 minstagib_items(IT_CELLS);
963         }
964         else
965                 remove(self);
966 }
967
968 // compatibility:
969 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
970
971 void spawnfunc_misc_models (void)
972 {
973         // exists as alias name for 2.4.2 compat
974         SetBrushEntityModel();
975 }
976
977 void spawnfunc_func_static (void)
978 {
979         // exists as alias name for having it with brushes
980         SetBrushEntityModel();
981 }
982
983 void func_wall_use (void)
984 {
985         if(teams_matter)
986         {
987                 if(activator.team)
988                         self.colormap = (activator.team - 1) * 0x11;
989                 else
990                         self.colormap = 0x00;
991         }
992         else
993                 self.colormap = floor(random() * 256);
994         self.colormap |= 1024; // RENDER_COLORMAPPED
995 }
996
997 void spawnfunc_func_wall (void)
998 {
999         SetBrushEntityModel();
1000         if(!self.solid)
1001                 self.solid = SOLID_BSP;
1002         self.use = func_wall_use;
1003 }
1004
1005 void spawnfunc_func_illusionary (void)
1006 {
1007         SetBrushEntityModel();
1008         self.use = func_wall_use;
1009 }
1010
1011 void gamemodel_drop()
1012 {
1013         if(self.spawnflags & 3 == 1) // ALIGN_ORIGIN
1014         {
1015                 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
1016                 setorigin(self, trace_endpos);
1017         }
1018         else if(self.spawnflags & 3 == 2) // ALIGN_BOTTOM
1019         {
1020                 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
1021                 setorigin(self, trace_endpos);
1022         }
1023         else if(self.spawnflags & 3 == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
1024         {
1025                 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
1026                 setorigin(self, trace_endpos - '0 0 1' * self.mins_z);
1027         }
1028 }
1029
1030 .float modelscale;
1031 void spawnfunc_misc_gamemodel (void)
1032 {
1033         if(!self.scale)
1034                 self.scale = self.modelscale;
1035         SetBrushEntityModel();
1036         self.use = func_wall_use;
1037
1038         InitializeEntity(self, gamemodel_drop, INITPRIO_DROPTOFLOOR);
1039 }
1040
1041 float target_item_func_set(float a, float b)
1042 {
1043         if(b == 0)
1044                 return a;
1045         else if(b < 0)
1046                 return 0;
1047         else
1048                 return b;
1049 }
1050
1051 float target_item_func_min(float a, float b)
1052 {
1053         if(b == 0)
1054                 return a;
1055         else if(b < 0)
1056                 return 0;
1057         else
1058                 return min(a, b);
1059 }
1060
1061 float target_item_func_max(float a, float b)
1062 {
1063         return max(a, b);
1064 }
1065
1066 float target_item_func_bitset(float a, float b)
1067 {
1068         return b;
1069 }
1070
1071 float target_item_func_and(float a, float b)
1072 {
1073         return a & b;
1074 }
1075
1076 float target_item_func_itembitset(float a, float b)
1077 {
1078         return (a - (a & (IT_UNLIMITED_WEAPON_AMMO | IT_STRENGTH | IT_INVINCIBLE))) | b;
1079 }
1080
1081 float target_item_func_itemand(float a, float b)
1082 {
1083         return (a - (a & (IT_UNLIMITED_WEAPON_AMMO | IT_STRENGTH | IT_INVINCIBLE))) | (a & b);
1084 }
1085
1086 float target_item_func_or(float a, float b)
1087 {
1088         return a | b;
1089 }
1090
1091 float target_item_func_andnot(float a, float b)
1092 {
1093         return a - (a & b);
1094 }
1095
1096 float target_item_changed;
1097 void target_item_change(float binary, .float field, float(float a, float b) func, string sound_increase, string sound_decrease)
1098 {
1099         float n, d;
1100         n = func(activator.field, self.field);
1101
1102         if(binary)
1103         {
1104                 d = n & activator.field;
1105                 if(d != n) // bits added?
1106                         d = +1;
1107                 else if(d != activator.field) // bits removed?
1108                         d = -1;
1109                 else
1110                         d = 0;
1111         }
1112         else
1113                 d = n - activator.field;
1114
1115         if(d < 0)
1116         {
1117                 if(sound_decrease != "")
1118                         sound (activator, CHAN_AUTO, sound_decrease, VOL_BASE, ATTN_NORM);
1119                 target_item_changed = 1;
1120         }
1121         else if(d > 0)
1122         {
1123                 if(sound_increase != "")
1124                         sound (activator, CHAN_AUTO, sound_increase, VOL_BASE, ATTN_NORM);
1125                 target_item_changed = 1;
1126         }
1127         activator.field = n;
1128 }
1129
1130 void target_items_use (void)
1131 {
1132         float h0, a0;
1133         if(activator.classname != "player")
1134                 return;
1135         if(activator.deadflag != DEAD_NO)
1136                 return;
1137         EXACTTRIGGER_TOUCH;
1138
1139         entity e;
1140         for(e = world; (e = find(e, classname, "droppedweapon")); )
1141                 if(e.enemy == activator)
1142                         remove(e);
1143
1144         float _switchweapon;
1145         _switchweapon = FALSE;
1146         if (activator.autoswitch)
1147                 if (activator.switchweapon == w_getbestweapon(activator))
1148                         _switchweapon = TRUE;
1149
1150         a0 = activator.armorvalue;
1151         h0 = activator.health;
1152         target_item_changed = 0;
1153
1154         if(self.spawnflags == 0) // SET
1155         {
1156                 target_item_change(0, ammo_shells, target_item_func_set, "misc/itempickup.wav", "");
1157                 target_item_change(0, ammo_nails, target_item_func_set, "misc/itempickup.wav", "");
1158                 target_item_change(0, ammo_rockets, target_item_func_set, "misc/itempickup.wav", "");
1159                 target_item_change(0, ammo_cells, target_item_func_set, "misc/itempickup.wav", "");
1160                 target_item_change(0, health, target_item_func_set, "misc/megahealth.wav", "");
1161                 target_item_change(0, armorvalue, target_item_func_set, "misc/armor25.wav", "");
1162                 target_item_change(1, items, target_item_func_itembitset, "misc/powerup.wav", "");
1163                 target_item_change(1, weapons, target_item_func_bitset, "weapons/weaponpickup.wav", "");
1164
1165                 if((self.items & activator.items) & IT_STRENGTH)
1166                         activator.strength_finished = time + self.strength_finished;
1167                 if((self.items & activator.items) & IT_INVINCIBLE)
1168                         activator.invincible_finished = time + self.invincible_finished;
1169         }
1170         else if(self.spawnflags == 1) // AND/MIN
1171         {
1172                 target_item_change(0, ammo_shells, target_item_func_min, "misc/itempickup.wav", "");
1173                 target_item_change(0, ammo_nails, target_item_func_min, "misc/itempickup.wav", "");
1174                 target_item_change(0, ammo_rockets, target_item_func_min, "misc/itempickup.wav", "");
1175                 target_item_change(0, ammo_cells, target_item_func_min, "misc/itempickup.wav", "");
1176                 target_item_change(0, health, target_item_func_min, "misc/megahealth.wav", "");
1177                 target_item_change(0, armorvalue, target_item_func_min, "misc/armor25.wav", "");
1178                 target_item_change(1, items, target_item_func_itemand, "misc/powerup.wav", "");
1179                 target_item_change(1, weapons, target_item_func_and, "weapons/weaponpickup.wav", "");
1180
1181                 if((self.items & activator.items) & IT_STRENGTH)
1182                         activator.strength_finished = min(activator.strength_finished, time + self.strength_finished);
1183                 if((self.items & activator.items) & IT_INVINCIBLE)
1184                         activator.invincible_finished = min(activator.invincible_finished, time + self.invincible_finished);
1185         }
1186         else if(self.spawnflags == 2) // OR/MAX
1187         {
1188                 target_item_change(0, ammo_shells, target_item_func_max, "misc/itempickup.wav", "");
1189                 target_item_change(0, ammo_nails, target_item_func_max, "misc/itempickup.wav", "");
1190                 target_item_change(0, ammo_rockets, target_item_func_max, "misc/itempickup.wav", "");
1191                 target_item_change(0, ammo_cells, target_item_func_max, "misc/itempickup.wav", "");
1192                 target_item_change(0, health, target_item_func_max, "misc/megahealth.wav", "");
1193                 target_item_change(0, armorvalue, target_item_func_max, "misc/armor25.wav", "");
1194                 target_item_change(1, items, target_item_func_or, "misc/powerup.wav", "");
1195                 target_item_change(1, weapons, target_item_func_or, "weapons/weaponpickup.wav", "");
1196
1197                 if((self.items & activator.items) & IT_STRENGTH)
1198                         activator.strength_finished = max(activator.strength_finished, time + self.strength_finished);
1199                 if((self.items & activator.items) & IT_INVINCIBLE)
1200                         activator.invincible_finished = max(activator.invincible_finished, time + self.invincible_finished);
1201         }
1202         else if(self.spawnflags == 4) // ANDNOT/MIN
1203         {
1204                 target_item_change(0, ammo_shells, target_item_func_min, "misc/itempickup.wav", "");
1205                 target_item_change(0, ammo_nails, target_item_func_min, "misc/itempickup.wav", "");
1206                 target_item_change(0, ammo_rockets, target_item_func_min, "misc/itempickup.wav", "");
1207                 target_item_change(0, ammo_cells, target_item_func_min, "misc/itempickup.wav", "");
1208                 target_item_change(0, health, target_item_func_min, "misc/megahealth.wav", "");
1209                 target_item_change(0, armorvalue, target_item_func_min, "misc/armor25.wav", "");
1210                 target_item_change(1, items, target_item_func_andnot, "misc/powerup.wav", "");
1211                 target_item_change(1, weapons, target_item_func_andnot, "weapons/weaponpickup.wav", "");
1212
1213                 if((self.items & activator.items) & IT_STRENGTH)
1214                         activator.strength_finished = min(activator.strength_finished, time + self.strength_finished);
1215                 if((self.items & activator.items) & IT_INVINCIBLE)
1216                         activator.invincible_finished = min(activator.invincible_finished, time + self.invincible_finished);
1217         }
1218
1219         if not(activator.items & IT_STRENGTH)
1220                 activator.strength_finished = 0;
1221         if not(activator.items & IT_INVINCIBLE)
1222                 activator.invincible_finished = 0;
1223
1224         if(activator.health > h0)
1225                 activator.pauserothealth_finished = max(activator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
1226         else if(activator.health < h0)
1227                 activator.pauseregen_finished = max(activator.pauseregen_finished, time + cvar("g_balance_pause_health_regen"));
1228
1229         if(activator.armorvalue > a0)
1230                 activator.pauserotarmor_finished = max(activator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
1231
1232         if not(activator.weapons & W_WeaponBit(activator.switchweapon))
1233                 _switchweapon = TRUE;
1234         if(_switchweapon)
1235                 W_SwitchWeapon_Force(activator, w_getbestweapon(activator));
1236
1237         if(target_item_changed)
1238                 centerprint(activator, self.message);
1239 }
1240
1241 void spawnfunc_target_items (void)
1242 {
1243         float n, i, j;
1244         entity e;
1245         self.use = target_items_use;
1246         if(!self.strength_finished)
1247                 self.strength_finished = cvar("g_balance_powerup_strength_time");
1248         if(!self.invincible_finished)
1249                 self.invincible_finished = cvar("g_balance_powerup_invincible_time");
1250
1251         precache_sound("misc/itempickup.wav");
1252         precache_sound("misc/itempickup.wav");
1253         precache_sound("misc/itempickup.wav");
1254         precache_sound("misc/itempickup.wav");
1255         precache_sound("misc/megahealth.wav");
1256         precache_sound("misc/armor25.wav");
1257         precache_sound("misc/powerup.wav");
1258         precache_sound("weapons/weaponpickup.wav");
1259
1260         n = tokenize_sane(self.netname);
1261         for(i = 0; i < n; ++i)
1262         {
1263                 if(argv(i) == "unlimited_ammo")         self.items |= IT_UNLIMITED_AMMO;
1264                 if(argv(i) == "unlimited_weapon_ammo")  self.items |= IT_UNLIMITED_WEAPON_AMMO;
1265                 if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
1266                 if(argv(i) == "strength")               self.items |= IT_STRENGTH;
1267                 if(argv(i) == "invincible")             self.items |= IT_INVINCIBLE;
1268                 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1269                 {
1270                         e = get_weaponinfo(j);
1271                         if(argv(i) == e.netname)
1272                         {
1273                                 self.weapons |= e.weapons;
1274                                 if(self.spawnflags == 0 || self.spawnflags == 2)
1275                                         weapon_action(e.weapon, WR_PRECACHE);
1276                         }
1277                 }
1278         }
1279 }