1 floatfield Item_CounterField(float it)
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");
19 string Item_CounterFieldName(float it)
23 case IT_SHELLS: return "shells";
24 case IT_NAILS: return "nails";
25 case IT_ROCKETS: return "rockets";
26 case IT_CELLS: return "cells";
28 // add more things here (health, armor)
29 default: error("requested item has no counter field name");
33 .float max_armorvalue;
35 void Item_Respawn (void)
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);
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);
46 float Item_GiveTo(entity item, entity player)
54 // if nothing happens to player, just return without taking the item
56 _switchweapon = FALSE;
64 // play some cool sounds ;)
65 centerprint(player, "\n");
66 if(player.health <= 5)
67 announce(player, "announcer/robotic/lastsecond.ogg");
68 else if(player.health < 50)
69 announce(player, "announcer/robotic/narrowly.ogg");
70 // sound not available
71 // else if(item.items == IT_CELLS)
72 // play2(player, "announce/robotic/ammo.ogg");
74 if (item.weapons & WEPBIT_MINSTANEX)
75 W_GiveWeapon (player, WEP_MINSTANEX, "Nex");
77 player.ammo_cells = min (player.ammo_cells + cvar("g_minstagib_ammo_drop"), 999);
85 // sound not available
86 // play2(player, "announce/robotic/extra.ogg\nplay2 announce/robotic/_lives.ogg");
87 player.armorvalue = player.armorvalue + cvar("g_minstagib_extralives");
88 sprint(player, "^3You picked up some extra lives\n");
92 if (item.strength_finished)
95 // sound not available
96 // play2(player, "announce/robotic/invisible.ogg");
97 player.strength_finished = max(player.strength_finished, time) + cvar("g_balance_powerup_strength_time");
101 if (item.invincible_finished)
104 // sound not available
105 // play2(player, "announce/robotic/speed.ogg");
106 player.invincible_finished = max(player.invincible_finished, time) + cvar("g_balance_powerup_strength_time");
111 if (cvar("deathmatch") == 2 || cvar("g_weapon_stay"))
113 if (item.flags & FL_WEAPON && player.weapons & item.weapons && item.classname != "droppedweapon")
115 if (player.weapons & item.weapons && item.flags & FL_TOSSED) // don't let players stack ammo by tossing weapons
119 // in case the player has autoswitch enabled do the following:
120 // if the player is using their best weapon before items are given, they
121 // probably want to switch to an even better weapon after items are given
122 if (player.autoswitch)
123 if (player.switchweapon == w_getbestweapon(player))
124 _switchweapon = TRUE;
126 if (item.ammo_shells)
127 if (player.ammo_shells < g_pickup_shells_max)
130 player.ammo_shells = min (player.ammo_shells + item.ammo_shells, g_pickup_shells_max);
133 if (player.ammo_nails < g_pickup_nails_max)
136 player.ammo_nails = min (player.ammo_nails + item.ammo_nails, g_pickup_nails_max);
138 if (item.ammo_rockets)
139 if (player.ammo_rockets < g_pickup_rockets_max)
142 player.ammo_rockets = min (player.ammo_rockets + item.ammo_rockets, g_pickup_rockets_max);
145 if (player.ammo_cells < g_pickup_cells_max)
148 player.ammo_cells = min (player.ammo_cells + item.ammo_cells, g_pickup_cells_max);
151 if (item.flags & FL_WEAPON)
152 if ((it = item.weapons - (item.weapons & player.weapons)))
155 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
157 e = get_weaponinfo(i);
159 W_GiveWeapon (player, e.weapon, item.netname);
163 if (item.strength_finished)
166 player.strength_finished = max(player.strength_finished, time) + cvar("g_balance_powerup_strength_time");
168 if (item.invincible_finished)
171 player.invincible_finished = max(player.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
173 //if (item.speed_finished)
176 // player.speed_finished = max(player.speed_finished, time) + cvar("g_balance_powerup_speed_time");
178 //if (item.slowmo_finished)
181 // player.slowmo_finished = max(player.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
185 if (player.health < item.max_health)
188 player.health = min(player.health + item.health, item.max_health);
189 player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
192 if (player.armorvalue < item.max_armorvalue)
195 player.armorvalue = min(player.armorvalue + item.armorvalue, item.max_armorvalue);
196 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + cvar("g_balance_pause_armor_rot"));
200 // always eat teamed entities
207 sound (player, CHAN_AUTO, item.item_pickupsound, VOL_BASE, ATTN_NORM);
209 W_SwitchWeapon_Force(player, w_getbestweapon(player));
214 void Item_Touch (void)
219 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
220 if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
225 if (other.classname != "player")
229 if (self.solid != SOLID_TRIGGER)
231 if (self.owner == other)
234 if(!Item_GiveTo(self, other))
237 if (self.classname == "droppedweapon")
239 else if((self.flags & FL_WEAPON) && !self.team && (cvar("deathmatch") == 2 || cvar("g_weapon_stay")))
243 self.solid = SOLID_NOT;
244 self.model = string_null;
247 RandomSelection_Init();
248 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
249 RandomSelection_Add(head, 0, 1, 0);
250 e = RandomSelection_chosen_ent;
254 e.nextthink = time + self.respawntime;
255 e.think = Item_Respawn;
263 if(self.effects & EF_NODRAW)
265 // marker for item team search
266 dprint("Initializing item team ", ftos(self.team), "\n");
267 RandomSelection_Init();
268 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
269 RandomSelection_Add(head, 0, 1, 0);
270 e = RandomSelection_chosen_ent;
272 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
276 // make it a non-spawned item
277 head.solid = SOLID_NOT;
278 head.model = string_null;
280 head.effects = head.effects - (head.effects & EF_NODRAW);
285 // Savage: used for item garbage-collection
286 // TODO: perhaps nice special effect?
287 void RemoveItem(void) /*FIXDECL*/
292 // pickup evaluation functions
293 // these functions decide how desirable an item is to the bots
295 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;};
297 float weapon_pickupevalfunc(entity player, entity item)
299 // if we already have the weapon, rate it 1/5th normal value
300 if ((player.weapons & item.weapons) == item.weapons)
301 return item.bot_pickupbasevalue * 0.2;
302 return item.bot_pickupbasevalue;
305 float commodity_pickupevalfunc(entity player, entity item)
309 // TODO: figure out if the player even has the weapon this ammo is for?
310 // may not affect strategy much though...
311 // find out how much more ammo/armor/health the player can hold
312 if (item.ammo_shells)
313 if (player.ammo_shells < g_pickup_shells_max)
314 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
316 if (player.ammo_nails < g_pickup_nails_max)
317 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
318 if (item.ammo_rockets)
319 if (player.ammo_rockets < g_pickup_rockets_max)
320 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
322 if (player.ammo_cells < g_pickup_cells_max)
323 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
325 if (player.armorvalue < item.max_armorvalue)
326 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
328 if (player.health < item.max_health)
329 c = c + max(0, 1 - player.health / item.max_health);
331 return item.bot_pickupbasevalue * c;
336 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
338 startitem_failed = FALSE;
340 // is it a dropped weapon?
341 if (self.classname == "droppedweapon")
343 // it's a dropped weapon
344 self.movetype = MOVETYPE_TOSS;
345 self.solid = SOLID_TRIGGER;
346 // Savage: remove thrown items after a certain period of time ("garbage collection")
347 self.think = RemoveItem;
348 self.nextthink = time + 60;
349 // don't drop if in a NODROP zone (such as lava)
350 traceline(self.origin, self.origin, MOVE_NORMAL, self);
351 if (trace_dpstartcontents & DPCONTENTS_NODROP)
353 startitem_failed = TRUE;
361 if(self.spawnflags & 1)
364 self.movetype = MOVETYPE_NONE;
366 self.movetype = MOVETYPE_TOSS;
367 self.solid = SOLID_TRIGGER;
368 // do item filtering according to game mode and other things
371 // first nudge it off the floor a little bit to avoid math errors
372 setorigin(self, self.origin + '0 0 1');
373 // set item size before we spawn a spawnfunc_waypoint
374 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
375 setsize (self, '-16 -16 0', '16 16 48');
377 setsize (self, '-16 -16 0', '16 16 32');
378 // note droptofloor returns FALSE if stuck/or would fall too far
380 waypoint_spawnforitem(self);
387 print("removed non-teamplay ", self.classname, "\n");
388 startitem_failed = TRUE;
397 print("removed non-FFA ", self.classname, "\n");
398 startitem_failed = TRUE;
406 // We aren't TA or something like that, so we keep the Q3A entities
407 print("removed non-Q3A ", self.classname, "\n");
408 startitem_failed = TRUE;
414 * can't do it that way, as it would break maps
415 * TODO make a target_give like entity another way, that perhaps has
416 * the weapon name in a key
419 // target_give not yet supported; maybe later
420 print("removed targeted ", self.classname, "\n");
421 startitem_failed = TRUE;
427 if(cvar("spawn_debug") >= 2)
430 for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
432 if(otheritem.is_item)
434 dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
435 dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
436 error("Mapper sucks.");
442 weaponsInMap |= weaponid;
444 if(g_lms || g_rocketarena)
446 startitem_failed = TRUE;
450 else if (g_minstagib)
452 // don't remove dropped items and powerups
453 if (self.classname != "minstagib")
455 startitem_failed = TRUE;
460 else if ((!cvar("g_pickup_items") || g_nixnex) && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
462 startitem_failed = TRUE;
467 precache_model (itemmodel);
468 precache_sound (pickupsound);
469 precache_sound ("misc/itemrespawn.wav");
471 if((itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)) || (weaponid & WEPBIT_ALL))
472 self.target = "###item###"; // for finding the nearest item using find()
475 self.bot_pickup = TRUE;
476 self.bot_pickupevalfunc = pickupevalfunc;
477 self.bot_pickupbasevalue = pickupbasevalue;
478 self.mdl = itemmodel;
479 self.item_pickupsound = pickupsound;
480 // let mappers override respawntime
481 if (!self.respawntime)
482 self.respawntime = defaultrespawntime;
483 self.netname = itemname;
485 self.weapons = weaponid;
486 self.flags = FL_ITEM | itemflags;
487 self.touch = Item_Touch;
488 setmodel (self, self.mdl); // precision set below
489 self.effects |= EF_LOWPRECISION;
490 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
491 setsize (self, '-16 -16 0', '16 16 48');
493 setsize (self, '-16 -16 0', '16 16 32');
494 if (itemflags & FL_WEAPON)
496 // neutral team color for pickup weapons
497 self.colormap = 160 * 1024 + 160;
500 if (cvar("g_fullbrightitems"))
501 self.effects = self.effects | EF_FULLBRIGHT;
505 self.effects = self.effects | EF_NODRAW; // marker for item team search
506 InitializeEntity(self, Item_FindTeam, INITPRIO_FINDTARGET);
510 /* replace items in minstagib
511 * IT_STRENGTH = invisibility
512 * IT_NAILS = extra lives
513 * IT_INVINCIBLE = speed
515 void minstagib_items (float itemid)
517 // we don't want to replace dropped weapons ;)
518 if (self.classname == "droppedweapon")
520 self.ammo_cells = 25;
521 StartItem ("models/weapons/g_nex.md3",
522 "weapons/weaponpickup.wav", 15,
523 "MinstaNex", 0, WEPBIT_MINSTANEX, FL_WEAPON, generic_pickupevalfunc, 1000);
528 self.classname = "minstagib";
530 // replace rocket launchers and nex guns with ammo cells
531 if (itemid == IT_CELLS)
534 StartItem ("models/items/a_cells.md3",
535 "misc/itempickup.wav", 45,
536 "Nex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
543 itemid = IT_STRENGTH;
547 itemid = IT_INVINCIBLE;
549 // replace with invis
550 if (itemid == IT_STRENGTH)
552 self.effects = EF_ADDITIVE;
553 self.strength_finished = 30;
554 StartItem ("models/items/g_strength.md3",
555 "misc/powerup.wav", g_pickup_respawntime_powerup,
556 "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
558 // replace with extra lives
559 if (itemid == IT_NAILS)
562 StartItem ("models/items/g_h100.md3",
563 "misc/megahealth.wav", g_pickup_respawntime_powerup,
564 "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
567 // replace with speed
568 if (itemid == IT_INVINCIBLE)
570 self.effects = EF_ADDITIVE;
571 self.invincible_finished = 30;
572 StartItem ("models/items/g_invincible.md3",
573 "misc/powerup_shield.wav", g_pickup_respawntime_powerup,
574 "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
579 float minst_no_auto_cells;
580 void minst_remove_item (void) {
581 if(minst_no_auto_cells)
585 float weaponswapping;
588 void weapon_defaultspawnfunc(float wpn)
592 var .float ammofield;
597 if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
599 s = cvar_string(strcat("g_weaponreplace_", ftos(wpn)));
603 self.team = --internalteam;
604 for(i = 1; i < t; ++i)
608 copyentity(oldself, self);
609 self.classname = "replacedweapon";
610 weapon_defaultspawnfunc(stof(argv(i)));
612 print("replaced by ", argv(i), "\n");
619 e = get_weaponinfo(wpn);
621 t = g_pickup_respawntime_short;
623 if(e.items && e.items != IT_SUPERWEAPON)
625 ammofield = Item_CounterField(e.items);
627 self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(e.items)));
630 if(e.items == IT_SUPERWEAPON)
631 t = g_pickup_respawntime_powerup;
633 StartItem(e.model, "weapons/weaponpickup.wav", t, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, e.bot_pickupbasevalue);
634 if (self.modelindex) // don't precache if self was removed
635 weapon_action(e.weapon, WR_PRECACHE);
638 void spawnfunc_weapon_shotgun (void);
639 void spawnfunc_weapon_uzi (void) {
640 if(q3acompat_machineshotgunswap)
641 if(self.classname != "droppedweapon")
643 weapon_defaultspawnfunc(WEP_SHOTGUN);
646 weapon_defaultspawnfunc(WEP_UZI);
649 void spawnfunc_weapon_shotgun (void) {
650 if(q3acompat_machineshotgunswap)
651 if(self.classname != "droppedweapon")
653 weapon_defaultspawnfunc(WEP_UZI);
656 weapon_defaultspawnfunc(WEP_SHOTGUN);
659 void spawnfunc_weapon_nex (void)
663 minstagib_items(IT_CELLS);
664 self.think = minst_remove_item;
665 self.nextthink = time + cvar("sys_ticrate");
668 weapon_defaultspawnfunc(WEP_NEX);
671 void spawnfunc_weapon_minstanex (void)
675 minstagib_items(IT_CELLS);
676 self.think = minst_remove_item;
677 self.nextthink = time + cvar("sys_ticrate");
680 weapon_defaultspawnfunc(WEP_MINSTANEX);
683 void spawnfunc_weapon_rocketlauncher (void)
687 minstagib_items(IT_CELLS);
688 self.think = minst_remove_item;
689 self.nextthink = time + cvar("sys_ticrate");
692 weapon_defaultspawnfunc(WEP_ROCKET_LAUNCHER);
695 void spawnfunc_item_rockets (void) {
696 if(!self.ammo_rockets)
697 self.ammo_rockets = g_pickup_rockets;
698 StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_short, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
701 void spawnfunc_item_shells (void);
702 void spawnfunc_item_bullets (void) {
704 if(q3acompat_machineshotgunswap)
705 if(self.classname != "droppedweapon")
707 weaponswapping = TRUE;
708 spawnfunc_item_shells();
709 weaponswapping = FALSE;
714 self.ammo_nails = g_pickup_nails;
715 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_short, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
718 void spawnfunc_item_cells (void) {
720 self.ammo_cells = g_pickup_cells;
721 StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_short, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
724 void spawnfunc_item_shells (void) {
726 if(q3acompat_machineshotgunswap)
727 if(self.classname != "droppedweapon")
729 weaponswapping = TRUE;
730 spawnfunc_item_bullets();
731 weaponswapping = FALSE;
735 if(!self.ammo_shells)
736 self.ammo_shells = g_pickup_shells;
737 StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_short, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
740 void spawnfunc_item_armor_small (void) {
742 self.armorvalue = g_pickup_armorsmall;
743 if(!self.max_armorvalue)
744 self.max_armorvalue = g_pickup_armorsmall_max;
745 StartItem ("models/items/g_a1.md3", "misc/armor1.wav", g_pickup_respawntime_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, 1000);
748 void spawnfunc_item_armor_medium (void) {
750 self.armorvalue = g_pickup_armormedium;
751 if(!self.max_armorvalue)
752 self.max_armorvalue = g_pickup_armormedium_max;
753 StartItem ("models/items/g_armormedium.md3", "misc/armor1.wav", g_pickup_respawntime_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
756 void spawnfunc_item_armor_large (void) {
758 self.armorvalue = g_pickup_armorlarge;
759 if(!self.max_armorvalue)
760 self.max_armorvalue = g_pickup_armorlarge_max;
761 StartItem ("models/items/g_a25.md3", "misc/armor25.wav", g_pickup_respawntime_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
764 void spawnfunc_item_health_small (void) {
766 self.max_health = g_pickup_healthsmall_max;
768 self.health = g_pickup_healthsmall;
769 StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, 20000);
772 void spawnfunc_item_health_medium (void) {
774 self.max_health = g_pickup_healthmedium_max;
776 self.health = g_pickup_healthmedium;
777 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
780 void spawnfunc_item_health_large (void) {
782 self.max_health = g_pickup_healthlarge_max;
784 self.health = g_pickup_healthlarge;
785 StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
788 void spawnfunc_item_health_mega (void) {
789 if(!cvar("g_powerup_superhealth"))
792 if(g_arena && !cvar("g_arena_powerups"))
796 minstagib_items(IT_NAILS);
799 self.max_health = g_pickup_healthmega_max;
801 self.health = g_pickup_healthmega;
802 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, 20000);
806 // support old misnamed entities
807 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); } // FIXME: in Quake this is green armor, in Nexuiz maps it is an armor shard
808 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
809 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
810 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
811 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
813 void spawnfunc_item_strength (void) {
814 if(!cvar("g_powerup_strength"))
817 if(g_arena && !cvar("g_arena_powerups"))
821 minstagib_items(IT_STRENGTH);
823 precache_sound("weapons/strength_fire.wav");
824 self.strength_finished = 30;
825 self.effects = EF_ADDITIVE;
826 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
830 void spawnfunc_item_invincible (void) {
831 if(!cvar("g_powerup_shield"))
834 if(g_arena && !cvar("g_arena_powerups"))
838 minstagib_items(IT_INVINCIBLE);
840 self.invincible_finished = 30;
841 self.effects = EF_ADDITIVE;
842 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, "Invulnerability", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
846 void spawnfunc_item_minst_cells (void) {
849 minst_no_auto_cells = 1;
850 minstagib_items(IT_CELLS);
857 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
859 void spawnfunc_misc_models (void)
861 SetBrushEntityModel();
864 void func_wall_use (void)
869 self.colormap = (activator.team - 1) * 0x11;
871 self.colormap = 0x00;
874 self.colormap = ceil(random() * 256) - 1;
875 self.colormap |= 1024; // RENDER_COLORMAPPED
878 void spawnfunc_func_wall (void)
880 SetBrushEntityModel();
881 self.solid = SOLID_BSP;
882 self.use = func_wall_use;
885 void trigger_items_use (void)
887 if(activator.classname != "player")
889 if(activator.deadflag != DEAD_NO)
894 _switchweapon = FALSE;
895 if (activator.autoswitch)
896 if (activator.switchweapon == w_getbestweapon(activator))
897 _switchweapon = TRUE;
899 if(self.spawnflags == 0) // SET
901 activator.ammo_shells = self.ammo_shells;
902 activator.ammo_nails = self.ammo_nails;
903 activator.ammo_rockets = self.ammo_rockets;
904 activator.ammo_cells = self.ammo_cells;
905 activator.health = self.health;
906 activator.armorvalue = self.armorvalue;
907 activator.weapons = self.weapons;
908 activator.items = self.items;
911 sound (activator, CHAN_AUTO, "weapons/weaponpickup.wav", VOL_BASE, ATTN_NORM);
913 sound (activator, CHAN_AUTO, "misc/itempickup.wav", VOL_BASE, ATTN_NORM);
915 sound (activator, CHAN_AUTO, "misc/megahealth.wav", VOL_BASE, ATTN_NORM);
917 sound (activator, CHAN_AUTO, "misc/armor25.wav", VOL_BASE, ATTN_NORM);
918 if(self.items & IT_STRENGTH)
920 sound (activator, CHAN_AUTO, "misc/powerup.wav", VOL_BASE, ATTN_NORM);
921 activator.strength_finished = max(activator.strength_finished, time + self.strength_finished);
923 if(self.items & IT_INVINCIBLE)
925 sound (activator, CHAN_AUTO, "misc/powerup_shield.wav", VOL_BASE, ATTN_NORM);
926 activator.invincible_finished = max(activator.invincible_finished, time + self.invincible_finished);
929 else if(self.spawnflags == 1) // AND/MIN
931 activator.ammo_shells = min(activator.ammo_shells, self.ammo_shells);
932 activator.ammo_nails = min(activator.ammo_nails, self.ammo_nails);
933 activator.ammo_rockets = min(activator.ammo_rockets, self.ammo_rockets);
934 activator.ammo_cells = min(activator.ammo_cells, self.ammo_cells);
935 activator.health = min(activator.health, self.health);
936 activator.armorvalue = min(activator.armorvalue, self.armorvalue);
937 activator.weapons = activator.weapons & self.weapons;
938 activator.items = activator.items & self.items;
940 if not(self.items & IT_STRENGTH)
941 activator.strength_finished = 0;
942 if not(self.items & IT_INVINCIBLE)
943 activator.invincible_finished = 0;
945 else if(self.spawnflags == 2) // OR/MAX
947 activator.ammo_shells = max(activator.ammo_shells, self.ammo_shells);
948 activator.ammo_nails = max(activator.ammo_nails, self.ammo_nails);
949 activator.ammo_rockets = max(activator.ammo_rockets, self.ammo_rockets);
950 activator.ammo_cells = max(activator.ammo_cells, self.ammo_cells);
951 activator.health = max(activator.health, self.health);
952 activator.armorvalue = max(activator.armorvalue, self.armorvalue);
953 activator.weapons |= self.weapons;
954 activator.items |= self.items;
957 sound (activator, CHAN_AUTO, "weapons/weaponpickup.wav", VOL_BASE, ATTN_NORM);
959 sound (activator, CHAN_AUTO, "misc/itempickup.wav", VOL_BASE, ATTN_NORM);
961 sound (activator, CHAN_AUTO, "misc/megahealth.wav", VOL_BASE, ATTN_NORM);
963 sound (activator, CHAN_AUTO, "misc/armor25.wav", VOL_BASE, ATTN_NORM);
964 if(self.items & IT_STRENGTH)
966 sound (activator, CHAN_AUTO, "misc/powerup.wav", VOL_BASE, ATTN_NORM);
967 activator.strength_finished = max(activator.strength_finished, time + self.strength_finished);
969 if(self.items & IT_INVINCIBLE)
971 sound (activator, CHAN_AUTO, "misc/powerup_shield.wav", VOL_BASE, ATTN_NORM);
972 activator.invincible_finished = max(activator.invincible_finished, time + self.invincible_finished);
975 else if(self.spawnflags == 4) // ANDNOT/MIN
977 activator.ammo_shells = min(activator.ammo_shells, self.ammo_shells);
978 activator.ammo_nails = min(activator.ammo_nails, self.ammo_nails);
979 activator.ammo_rockets = min(activator.ammo_rockets, self.ammo_rockets);
980 activator.ammo_cells = min(activator.ammo_cells, self.ammo_cells);
981 activator.health = min(activator.health, self.health);
982 activator.armorvalue = min(activator.armorvalue, self.armorvalue);
983 activator.weapons -= activator.weapons & self.weapons;
984 activator.items -= activator.items & self.items;
986 if(self.items & IT_STRENGTH)
987 activator.strength_finished = 0;
988 if(self.items & IT_INVINCIBLE)
989 activator.invincible_finished = 0;
992 if not(activator.weapons & W_WeaponBit(activator.switchweapon))
993 _switchweapon = TRUE;
995 W_SwitchWeapon_Force(activator, w_getbestweapon(activator));
998 void spawnfunc_trigger_items (void)
1003 self.use = trigger_items_use;
1004 if(!self.strength_finished)
1005 self.strength_finished = cvar("g_balance_powerup_strength_time");
1006 if(!self.invincible_finished)
1007 self.invincible_finished = cvar("g_balance_powerup_invincible_time");
1009 n = tokenize(self.message);
1010 for(i = 0; i < n; ++i)
1012 if(argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1013 if(argv(i) == "strength") self.items |= IT_STRENGTH;
1014 if(argv(i) == "shield") self.items |= IT_INVINCIBLE;
1015 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1017 e = get_weaponinfo(j);
1018 if(argv(i) == e.netname)
1019 self.weapons |= e.weapons;