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 not(player.weapons & W_WeaponBit(player.switchweapon))
127 _switchweapon = TRUE;
129 if (item.ammo_shells)
130 if (player.ammo_shells < g_pickup_shells_max)
133 player.ammo_shells = min (player.ammo_shells + item.ammo_shells, g_pickup_shells_max);
136 if (player.ammo_nails < g_pickup_nails_max)
139 player.ammo_nails = min (player.ammo_nails + item.ammo_nails, g_pickup_nails_max);
141 if (item.ammo_rockets)
142 if (player.ammo_rockets < g_pickup_rockets_max)
145 player.ammo_rockets = min (player.ammo_rockets + item.ammo_rockets, g_pickup_rockets_max);
148 if (player.ammo_cells < g_pickup_cells_max)
151 player.ammo_cells = min (player.ammo_cells + item.ammo_cells, g_pickup_cells_max);
154 if (item.flags & FL_WEAPON)
155 if ((it = item.weapons - (item.weapons & player.weapons)))
158 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
160 e = get_weaponinfo(i);
162 W_GiveWeapon (player, e.weapon, item.netname);
166 if (item.strength_finished)
169 player.strength_finished = max(player.strength_finished, time) + cvar("g_balance_powerup_strength_time");
171 if (item.invincible_finished)
174 player.invincible_finished = max(player.invincible_finished, time) + cvar("g_balance_powerup_invincible_time");
176 //if (item.speed_finished)
179 // player.speed_finished = max(player.speed_finished, time) + cvar("g_balance_powerup_speed_time");
181 //if (item.slowmo_finished)
184 // player.slowmo_finished = max(player.slowmo_finished, time) + (cvar("g_balance_powerup_slowmo_time") * cvar("g_balance_powerup_slowmo_speed"));
188 if (player.health < item.max_health)
191 player.health = min(player.health + item.health, item.max_health);
192 player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
195 if (player.armorvalue < item.max_armorvalue)
198 player.armorvalue = min(player.armorvalue + item.armorvalue, item.max_armorvalue);
199 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + cvar("g_balance_pause_armor_rot"));
203 // always eat teamed entities
210 sound (player, CHAN_AUTO, item.item_pickupsound, VOL_BASE, ATTN_NORM);
212 W_SwitchWeapon_Force(player, w_getbestweapon(player));
217 void Item_Touch (void)
222 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
223 if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
228 if (other.classname != "player")
232 if (self.solid != SOLID_TRIGGER)
234 if (self.owner == other)
237 if(!Item_GiveTo(self, other))
240 if (self.classname == "droppedweapon")
242 else if((self.flags & FL_WEAPON) && !self.team && (cvar("deathmatch") == 2 || cvar("g_weapon_stay")))
246 self.solid = SOLID_NOT;
247 self.model = string_null;
250 RandomSelection_Init();
251 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
252 RandomSelection_Add(head, 0, 1, 0);
253 e = RandomSelection_chosen_ent;
257 e.nextthink = time + self.respawntime;
258 e.think = Item_Respawn;
266 if(self.effects & EF_NODRAW)
268 // marker for item team search
269 dprint("Initializing item team ", ftos(self.team), "\n");
270 RandomSelection_Init();
271 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
272 RandomSelection_Add(head, 0, 1, 0);
273 e = RandomSelection_chosen_ent;
275 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
279 // make it a non-spawned item
280 head.solid = SOLID_NOT;
281 head.model = string_null;
283 head.effects = head.effects - (head.effects & EF_NODRAW);
288 // Savage: used for item garbage-collection
289 // TODO: perhaps nice special effect?
290 void RemoveItem(void) /*FIXDECL*/
295 // pickup evaluation functions
296 // these functions decide how desirable an item is to the bots
298 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;};
300 float weapon_pickupevalfunc(entity player, entity item)
302 // if we already have the weapon, rate it 1/5th normal value
303 if ((player.weapons & item.weapons) == item.weapons)
304 return item.bot_pickupbasevalue * 0.2;
305 return item.bot_pickupbasevalue;
308 float commodity_pickupevalfunc(entity player, entity item)
312 // TODO: figure out if the player even has the weapon this ammo is for?
313 // may not affect strategy much though...
314 // find out how much more ammo/armor/health the player can hold
315 if (item.ammo_shells)
316 if (player.ammo_shells < g_pickup_shells_max)
317 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
319 if (player.ammo_nails < g_pickup_nails_max)
320 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
321 if (item.ammo_rockets)
322 if (player.ammo_rockets < g_pickup_rockets_max)
323 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
325 if (player.ammo_cells < g_pickup_cells_max)
326 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
328 if (player.armorvalue < item.max_armorvalue)
329 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
331 if (player.health < item.max_health)
332 c = c + max(0, 1 - player.health / item.max_health);
334 return item.bot_pickupbasevalue * c;
339 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
341 startitem_failed = FALSE;
343 // is it a dropped weapon?
344 if (self.classname == "droppedweapon")
346 // it's a dropped weapon
347 self.movetype = MOVETYPE_TOSS;
348 self.solid = SOLID_TRIGGER;
349 // Savage: remove thrown items after a certain period of time ("garbage collection")
350 self.think = RemoveItem;
351 self.nextthink = time + 60;
352 // don't drop if in a NODROP zone (such as lava)
353 traceline(self.origin, self.origin, MOVE_NORMAL, self);
354 if (trace_dpstartcontents & DPCONTENTS_NODROP)
356 startitem_failed = TRUE;
364 if(self.spawnflags & 1)
367 self.movetype = MOVETYPE_NONE;
369 self.movetype = MOVETYPE_TOSS;
370 self.solid = SOLID_TRIGGER;
371 // do item filtering according to game mode and other things
374 // first nudge it off the floor a little bit to avoid math errors
375 setorigin(self, self.origin + '0 0 1');
376 // set item size before we spawn a spawnfunc_waypoint
377 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
378 setsize (self, '-16 -16 0', '16 16 48');
380 setsize (self, '-16 -16 0', '16 16 32');
381 // note droptofloor returns FALSE if stuck/or would fall too far
383 waypoint_spawnforitem(self);
390 print("removed non-teamplay ", self.classname, "\n");
391 startitem_failed = TRUE;
400 print("removed non-FFA ", self.classname, "\n");
401 startitem_failed = TRUE;
409 // We aren't TA or something like that, so we keep the Q3A entities
410 print("removed non-Q3A ", self.classname, "\n");
411 startitem_failed = TRUE;
417 * can't do it that way, as it would break maps
418 * TODO make a target_give like entity another way, that perhaps has
419 * the weapon name in a key
422 // target_give not yet supported; maybe later
423 print("removed targeted ", self.classname, "\n");
424 startitem_failed = TRUE;
430 if(cvar("spawn_debug") >= 2)
433 for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
435 if(otheritem.is_item)
437 dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
438 dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
439 error("Mapper sucks.");
445 weaponsInMap |= weaponid;
447 if(g_lms || g_rocketarena)
449 startitem_failed = TRUE;
453 else if (g_minstagib)
455 // don't remove dropped items and powerups
456 if (self.classname != "minstagib")
458 startitem_failed = TRUE;
463 else if ((!cvar("g_pickup_items") || g_nixnex) && itemid != IT_STRENGTH && itemid != IT_INVINCIBLE && itemid != IT_HEALTH)
465 startitem_failed = TRUE;
470 precache_model (itemmodel);
471 precache_sound (pickupsound);
472 precache_sound ("misc/itemrespawn.wav");
474 if((itemid & (IT_STRENGTH | IT_INVINCIBLE | IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)) || (weaponid & WEPBIT_ALL))
475 self.target = "###item###"; // for finding the nearest item using find()
478 self.bot_pickup = TRUE;
479 self.bot_pickupevalfunc = pickupevalfunc;
480 self.bot_pickupbasevalue = pickupbasevalue;
481 self.mdl = itemmodel;
482 self.item_pickupsound = pickupsound;
483 // let mappers override respawntime
484 if (!self.respawntime)
485 self.respawntime = defaultrespawntime;
486 self.netname = itemname;
488 self.weapons = weaponid;
489 self.flags = FL_ITEM | itemflags;
490 self.touch = Item_Touch;
491 setmodel (self, self.mdl); // precision set below
492 self.effects |= EF_LOWPRECISION;
493 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
494 setsize (self, '-16 -16 0', '16 16 48');
496 setsize (self, '-16 -16 0', '16 16 32');
497 if (itemflags & FL_WEAPON)
499 // neutral team color for pickup weapons
500 self.colormap = 160 * 1024 + 160;
503 if (cvar("g_fullbrightitems"))
504 self.effects = self.effects | EF_FULLBRIGHT;
508 self.effects = self.effects | EF_NODRAW; // marker for item team search
509 InitializeEntity(self, Item_FindTeam, INITPRIO_FINDTARGET);
513 /* replace items in minstagib
514 * IT_STRENGTH = invisibility
515 * IT_NAILS = extra lives
516 * IT_INVINCIBLE = speed
518 void minstagib_items (float itemid)
520 // we don't want to replace dropped weapons ;)
521 if (self.classname == "droppedweapon")
523 self.ammo_cells = 25;
524 StartItem ("models/weapons/g_nex.md3",
525 "weapons/weaponpickup.wav", 15,
526 "MinstaNex", 0, WEPBIT_MINSTANEX, FL_WEAPON, generic_pickupevalfunc, 1000);
531 self.classname = "minstagib";
533 // replace rocket launchers and nex guns with ammo cells
534 if (itemid == IT_CELLS)
537 StartItem ("models/items/a_cells.md3",
538 "misc/itempickup.wav", 45,
539 "Nex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
546 itemid = IT_STRENGTH;
550 itemid = IT_INVINCIBLE;
552 // replace with invis
553 if (itemid == IT_STRENGTH)
555 self.effects = EF_ADDITIVE;
556 self.strength_finished = 30;
557 StartItem ("models/items/g_strength.md3",
558 "misc/powerup.wav", g_pickup_respawntime_powerup,
559 "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
561 // replace with extra lives
562 if (itemid == IT_NAILS)
565 StartItem ("models/items/g_h100.md3",
566 "misc/megahealth.wav", g_pickup_respawntime_powerup,
567 "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
570 // replace with speed
571 if (itemid == IT_INVINCIBLE)
573 self.effects = EF_ADDITIVE;
574 self.invincible_finished = 30;
575 StartItem ("models/items/g_invincible.md3",
576 "misc/powerup_shield.wav", g_pickup_respawntime_powerup,
577 "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 1000);
582 float minst_no_auto_cells;
583 void minst_remove_item (void) {
584 if(minst_no_auto_cells)
588 float weaponswapping;
591 void weapon_defaultspawnfunc(float wpn)
595 var .float ammofield;
600 if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
602 s = cvar_string(strcat("g_weaponreplace_", ftos(wpn)));
606 self.team = --internalteam;
607 for(i = 1; i < t; ++i)
611 copyentity(oldself, self);
612 self.classname = "replacedweapon";
613 weapon_defaultspawnfunc(stof(argv(i)));
615 print("replaced by ", argv(i), "\n");
622 e = get_weaponinfo(wpn);
624 t = g_pickup_respawntime_short;
626 if(e.items && e.items != IT_SUPERWEAPON)
628 ammofield = Item_CounterField(e.items);
630 self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(e.items)));
633 if(e.items == IT_SUPERWEAPON)
634 t = g_pickup_respawntime_powerup;
636 StartItem(e.model, "weapons/weaponpickup.wav", t, e.message, 0, e.weapons, FL_WEAPON, weapon_pickupevalfunc, e.bot_pickupbasevalue);
637 if (self.modelindex) // don't precache if self was removed
638 weapon_action(e.weapon, WR_PRECACHE);
641 void spawnfunc_weapon_shotgun (void);
642 void spawnfunc_weapon_uzi (void) {
643 if(q3acompat_machineshotgunswap)
644 if(self.classname != "droppedweapon")
646 weapon_defaultspawnfunc(WEP_SHOTGUN);
649 weapon_defaultspawnfunc(WEP_UZI);
652 void spawnfunc_weapon_shotgun (void) {
653 if(q3acompat_machineshotgunswap)
654 if(self.classname != "droppedweapon")
656 weapon_defaultspawnfunc(WEP_UZI);
659 weapon_defaultspawnfunc(WEP_SHOTGUN);
662 void spawnfunc_weapon_nex (void)
666 minstagib_items(IT_CELLS);
667 self.think = minst_remove_item;
668 self.nextthink = time + cvar("sys_ticrate");
671 weapon_defaultspawnfunc(WEP_NEX);
674 void spawnfunc_weapon_minstanex (void)
678 minstagib_items(IT_CELLS);
679 self.think = minst_remove_item;
680 self.nextthink = time + cvar("sys_ticrate");
683 weapon_defaultspawnfunc(WEP_MINSTANEX);
686 void spawnfunc_weapon_rocketlauncher (void)
690 minstagib_items(IT_CELLS);
691 self.think = minst_remove_item;
692 self.nextthink = time + cvar("sys_ticrate");
695 weapon_defaultspawnfunc(WEP_ROCKET_LAUNCHER);
698 void spawnfunc_item_rockets (void) {
699 if(!self.ammo_rockets)
700 self.ammo_rockets = g_pickup_rockets;
701 StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_short, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
704 void spawnfunc_item_shells (void);
705 void spawnfunc_item_bullets (void) {
707 if(q3acompat_machineshotgunswap)
708 if(self.classname != "droppedweapon")
710 weaponswapping = TRUE;
711 spawnfunc_item_shells();
712 weaponswapping = FALSE;
717 self.ammo_nails = g_pickup_nails;
718 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_short, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
721 void spawnfunc_item_cells (void) {
723 self.ammo_cells = g_pickup_cells;
724 StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_short, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
727 void spawnfunc_item_shells (void) {
729 if(q3acompat_machineshotgunswap)
730 if(self.classname != "droppedweapon")
732 weaponswapping = TRUE;
733 spawnfunc_item_bullets();
734 weaponswapping = FALSE;
738 if(!self.ammo_shells)
739 self.ammo_shells = g_pickup_shells;
740 StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_short, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
743 void spawnfunc_item_armor_small (void) {
745 self.armorvalue = g_pickup_armorsmall;
746 if(!self.max_armorvalue)
747 self.max_armorvalue = g_pickup_armorsmall_max;
748 StartItem ("models/items/g_a1.md3", "misc/armor1.wav", g_pickup_respawntime_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, 1000);
751 void spawnfunc_item_armor_medium (void) {
753 self.armorvalue = g_pickup_armormedium;
754 if(!self.max_armorvalue)
755 self.max_armorvalue = g_pickup_armormedium_max;
756 StartItem ("models/items/g_armormedium.md3", "misc/armor1.wav", g_pickup_respawntime_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
759 void spawnfunc_item_armor_large (void) {
761 self.armorvalue = g_pickup_armorlarge;
762 if(!self.max_armorvalue)
763 self.max_armorvalue = g_pickup_armorlarge_max;
764 StartItem ("models/items/g_a25.md3", "misc/armor25.wav", g_pickup_respawntime_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
767 void spawnfunc_item_health_small (void) {
769 self.max_health = g_pickup_healthsmall_max;
771 self.health = g_pickup_healthsmall;
772 StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, 20000);
775 void spawnfunc_item_health_medium (void) {
777 self.max_health = g_pickup_healthmedium_max;
779 self.health = g_pickup_healthmedium;
780 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
783 void spawnfunc_item_health_large (void) {
785 self.max_health = g_pickup_healthlarge_max;
787 self.health = g_pickup_healthlarge;
788 StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, 20000);
791 void spawnfunc_item_health_mega (void) {
792 if(!cvar("g_powerup_superhealth"))
795 if(g_arena && !cvar("g_arena_powerups"))
799 minstagib_items(IT_NAILS);
802 self.max_health = g_pickup_healthmega_max;
804 self.health = g_pickup_healthmega;
805 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, 20000);
809 // support old misnamed entities
810 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); } // FIXME: in Quake this is green armor, in Nexuiz maps it is an armor shard
811 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
812 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
813 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
814 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
816 void spawnfunc_item_strength (void) {
817 if(!cvar("g_powerup_strength"))
820 if(g_arena && !cvar("g_arena_powerups"))
824 minstagib_items(IT_STRENGTH);
826 precache_sound("weapons/strength_fire.wav");
827 self.strength_finished = 30;
828 self.effects = EF_ADDITIVE;
829 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
833 void spawnfunc_item_invincible (void) {
834 if(!cvar("g_powerup_shield"))
837 if(g_arena && !cvar("g_arena_powerups"))
841 minstagib_items(IT_INVINCIBLE);
843 self.invincible_finished = 30;
844 self.effects = EF_ADDITIVE;
845 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, "Invulnerability", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
849 void spawnfunc_item_minst_cells (void) {
852 minst_no_auto_cells = 1;
853 minstagib_items(IT_CELLS);
860 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
862 void spawnfunc_misc_models (void)
864 SetBrushEntityModel();
867 void func_wall_use (void)
872 self.colormap = (activator.team - 1) * 0x11;
874 self.colormap = 0x00;
877 self.colormap = ceil(random() * 256) - 1;
878 self.colormap |= 1024; // RENDER_COLORMAPPED
881 void spawnfunc_func_wall (void)
883 SetBrushEntityModel();
884 self.solid = SOLID_BSP;
885 self.use = func_wall_use;
888 float trigger_item_func_set(float a, float b)
898 float trigger_item_func_min(float a, float b)
908 float trigger_item_func_max(float a, float b)
913 float trigger_item_func_and(float a, float b)
918 float trigger_item_func_or(float a, float b)
923 float trigger_item_func_andnot(float a, float b)
928 float trigger_item_changed;
929 void trigger_item_change(float binary, .float field, float(float a, float b) func, string sound_increase, string sound_decrease)
932 n = func(activator.field, self.field);
936 d = n & activator.field;
937 if(d != n) // bits added?
939 else if(d != activator.field) // bits removed?
945 d = n - activator.field;
949 if(sound_decrease != "")
950 sound (activator, CHAN_AUTO, sound_decrease, VOL_BASE, ATTN_NORM);
951 trigger_item_changed = 1;
955 if(sound_increase != "")
956 sound (activator, CHAN_AUTO, sound_increase, VOL_BASE, ATTN_NORM);
957 trigger_item_changed = 1;
962 void trigger_items_use (void)
965 if(activator.classname != "player")
967 if(activator.deadflag != DEAD_NO)
972 for(e = world; (e = find(e, classname, "droppedweapon")); )
973 if(e.enemy == activator)
977 _switchweapon = FALSE;
978 if (activator.autoswitch)
979 if (activator.switchweapon == w_getbestweapon(activator))
980 _switchweapon = TRUE;
982 a0 = activator.armorvalue;
983 h0 = activator.health;
984 trigger_item_changed = 0;
986 if(self.spawnflags == 0) // SET
988 trigger_item_change(0, ammo_shells, trigger_item_func_set, "misc/itempickup.wav", "");
989 trigger_item_change(0, ammo_nails, trigger_item_func_set, "misc/itempickup.wav", "");
990 trigger_item_change(0, ammo_rockets, trigger_item_func_set, "misc/itempickup.wav", "");
991 trigger_item_change(0, ammo_cells, trigger_item_func_set, "misc/itempickup.wav", "");
992 trigger_item_change(0, health, trigger_item_func_set, "misc/megahealth.wav", "");
993 trigger_item_change(0, armorvalue, trigger_item_func_set, "misc/armor25.wav", "");
994 trigger_item_change(1, items, trigger_item_func_set, "misc/powerup.wav", "");
995 trigger_item_change(1, weapons, trigger_item_func_set, "weapons/weaponpickup.wav", "");
997 if((self.items & activator.items) & IT_STRENGTH)
998 activator.strength_finished = time + self.strength_finished;
999 if((self.items & activator.items) & IT_INVINCIBLE)
1000 activator.invincible_finished = time + self.invincible_finished;
1002 else if(self.spawnflags == 1) // AND/MIN
1004 trigger_item_change(0, ammo_shells, trigger_item_func_min, "misc/itempickup.wav", "");
1005 trigger_item_change(0, ammo_nails, trigger_item_func_min, "misc/itempickup.wav", "");
1006 trigger_item_change(0, ammo_rockets, trigger_item_func_min, "misc/itempickup.wav", "");
1007 trigger_item_change(0, ammo_cells, trigger_item_func_min, "misc/itempickup.wav", "");
1008 trigger_item_change(0, health, trigger_item_func_min, "misc/megahealth.wav", "");
1009 trigger_item_change(0, armorvalue, trigger_item_func_min, "misc/armor25.wav", "");
1010 trigger_item_change(1, items, trigger_item_func_and, "misc/powerup.wav", "");
1011 trigger_item_change(1, weapons, trigger_item_func_and, "weapons/weaponpickup.wav", "");
1013 if((self.items & activator.items) & IT_STRENGTH)
1014 activator.strength_finished = min(activator.strength_finished, time + self.strength_finished);
1015 if((self.items & activator.items) & IT_INVINCIBLE)
1016 activator.invincible_finished = min(activator.invincible_finished, time + self.invincible_finished);
1018 else if(self.spawnflags == 2) // OR/MAX
1020 trigger_item_change(0, ammo_shells, trigger_item_func_max, "misc/itempickup.wav", "");
1021 trigger_item_change(0, ammo_nails, trigger_item_func_max, "misc/itempickup.wav", "");
1022 trigger_item_change(0, ammo_rockets, trigger_item_func_max, "misc/itempickup.wav", "");
1023 trigger_item_change(0, ammo_cells, trigger_item_func_max, "misc/itempickup.wav", "");
1024 trigger_item_change(0, health, trigger_item_func_max, "misc/megahealth.wav", "");
1025 trigger_item_change(0, armorvalue, trigger_item_func_max, "misc/armor25.wav", "");
1026 trigger_item_change(1, items, trigger_item_func_or, "misc/powerup.wav", "");
1027 trigger_item_change(1, weapons, trigger_item_func_or, "weapons/weaponpickup.wav", "");
1029 if((self.items & activator.items) & IT_STRENGTH)
1030 activator.strength_finished = max(activator.strength_finished, time + self.strength_finished);
1031 if((self.items & activator.items) & IT_INVINCIBLE)
1032 activator.invincible_finished = max(activator.invincible_finished, time + self.invincible_finished);
1034 else if(self.spawnflags == 4) // ANDNOT/MIN
1036 trigger_item_change(0, ammo_shells, trigger_item_func_min, "misc/itempickup.wav", "");
1037 trigger_item_change(0, ammo_nails, trigger_item_func_min, "misc/itempickup.wav", "");
1038 trigger_item_change(0, ammo_rockets, trigger_item_func_min, "misc/itempickup.wav", "");
1039 trigger_item_change(0, ammo_cells, trigger_item_func_min, "misc/itempickup.wav", "");
1040 trigger_item_change(0, health, trigger_item_func_min, "misc/megahealth.wav", "");
1041 trigger_item_change(0, armorvalue, trigger_item_func_min, "misc/armor25.wav", "");
1042 trigger_item_change(1, items, trigger_item_func_andnot, "misc/powerup.wav", "");
1043 trigger_item_change(1, weapons, trigger_item_func_andnot, "weapons/weaponpickup.wav", "");
1045 if((self.items & activator.items) & IT_STRENGTH)
1046 activator.strength_finished = min(activator.strength_finished, time + self.strength_finished);
1047 if((self.items & activator.items) & IT_INVINCIBLE)
1048 activator.invincible_finished = min(activator.invincible_finished, time + self.invincible_finished);
1051 if not(activator.items & IT_STRENGTH)
1052 activator.strength_finished = 0;
1053 if not(activator.items & IT_INVINCIBLE)
1054 activator.invincible_finished = 0;
1056 if(activator.health > h0)
1057 activator.pauserothealth_finished = max(activator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
1058 else if(activator.health < h0)
1059 activator.pauseregen_finished = max(activator.pauseregen_finished, time + cvar("g_balance_pause_health_regen"));
1061 if(activator.armorvalue > a0)
1062 activator.pauserotarmor_finished = max(activator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));
1064 if not(activator.weapons & W_WeaponBit(activator.switchweapon))
1065 _switchweapon = TRUE;
1067 W_SwitchWeapon_Force(activator, w_getbestweapon(activator));
1069 if(trigger_item_changed)
1070 centerprint(activator, self.message);
1073 void spawnfunc_trigger_items (void)
1078 self.use = trigger_items_use;
1079 if(!self.strength_finished)
1080 self.strength_finished = cvar("g_balance_powerup_strength_time");
1081 if(!self.invincible_finished)
1082 self.invincible_finished = cvar("g_balance_powerup_invincible_time");
1084 n = tokenize(self.netname);
1085 for(i = 0; i < n; ++i)
1087 if(argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1088 if(argv(i) == "strength") self.items |= IT_STRENGTH;
1089 if(argv(i) == "invincible") self.items |= IT_INVINCIBLE;
1090 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1092 e = get_weaponinfo(j);
1093 if(argv(i) == e.netname)
1094 self.weapons |= e.weapons;