6 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
7 if(self.move_flags & FL_ONGROUND)
8 { // For some reason move_avelocity gets set to '0 0 0' here ...
9 self.oldorigin = self.origin;
12 if(autocvar_cl_animate_items)
13 { // ... so reset it if animations are requested.
14 if(self.ItemStatus & ITS_ANIMATE1)
15 self.move_avelocity = '0 180 0';
17 if(self.ItemStatus & ITS_ANIMATE2)
18 self.move_avelocity = '0 -90 0';
22 else if (autocvar_cl_animate_items)
24 if(self.ItemStatus & ITS_ANIMATE1)
26 self.angles += self.move_avelocity * frametime;
27 setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2));
30 if(self.ItemStatus & ITS_ANIMATE2)
32 self.angles += self.move_avelocity * frametime;
33 setorigin(self, '0 0 8' + self.oldorigin + '0 0 4' * sin(time * 3));
42 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
44 if(self.move_flags & FL_ONGROUND)
49 void ItemRead(float _IsNew)
51 float sf = ReadByte();
55 self.origin_x = ReadCoord();
56 self.origin_y = ReadCoord();
57 self.origin_z = ReadCoord();
58 setorigin(self, self.origin);
59 self.oldorigin = self.origin;
64 self.angles_x = ReadCoord();
65 self.angles_y = ReadCoord();
66 self.angles_z = ReadCoord();
67 self.move_angles = self.angles;
70 if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
72 self.ItemStatus = ReadByte();
74 if(self.ItemStatus & ITS_AVAILABLE)
77 self.colormod = self.glowmod = '1 1 1';
81 if (autocvar_cl_ghost_items_color)
83 self.alpha = autocvar_cl_ghost_items;
84 self.colormod = self.glowmod = autocvar_cl_ghost_items_color;
90 if(autocvar_cl_fullbright_items)
91 if(self.ItemStatus & ITS_ALLOWFB)
92 self.effects |= EF_FULLBRIGHT;
94 if(self.ItemStatus & ITS_STAYWEP)
96 self.colormod = self.glowmod = autocvar_cl_weapon_stay_color;
97 self.alpha = autocvar_cl_weapon_stay_alpha;
101 if(self.ItemStatus & ITS_POWERUP)
103 if(self.ItemStatus & ITS_AVAILABLE)
104 self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
106 self.effects &~= (EF_ADDITIVE | EF_FULLBRIGHT);
112 self.drawmask = MASK_NORMAL;
113 self.movetype = MOVETYPE_NOCLIP;
114 self.draw = ItemDraw;
120 string _fn = ReadString();
122 if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
124 string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
125 self.draw = ItemDrawSimple;
129 if(fexists(sprintf("%s%s.md3", _fn2, autocvr_cl_simpleitems_postfix)))
130 self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvr_cl_simpleitems_postfix));
131 else if(fexists(sprintf("%s%s.dpm", _fn2, autocvr_cl_simpleitems_postfix)))
132 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvr_cl_simpleitems_postfix));
133 else if(fexists(sprintf("%s%s.iqm", _fn2, autocvr_cl_simpleitems_postfix)))
134 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvr_cl_simpleitems_postfix));
135 else if(fexists(sprintf("%s%s.obj", _fn2, autocvr_cl_simpleitems_postfix)))
136 self.mdl = strzone(sprintf("%s%s.obj", _fn2, autocvr_cl_simpleitems_postfix));
139 self.draw = ItemDraw;
140 dprint("Simple item requested for ", _fn, " but no model exsist for it\n");
144 if(self.draw != ItemDrawSimple)
145 self.mdl = strzone(_fn);
149 dprint("^1WARNING!^7 self.mdl is unset for item ", self.classname, " tell tZork aboute this!\n");
151 precache_model(self.mdl);
152 setmodel(self, self.mdl);
155 if(sf & ISF_COLORMAP)
156 self.colormap = ReadShort();
161 self.move_angles = '0 0 0';
162 self.move_movetype = MOVETYPE_TOSS;
163 self.move_velocity_x = ReadCoord();
164 self.move_velocity_y = ReadCoord();
165 self.move_velocity_z = ReadCoord();
166 self.velocity = self.move_velocity;
167 self.move_origin = self.oldorigin;
171 self.move_time = time;
172 self.spawntime = time;
175 self.move_time = max(self.move_time, time);
178 if(autocvar_cl_animate_items)
180 if(self.ItemStatus & ITS_ANIMATE1)
181 self.move_avelocity = '0 180 0';
183 if(self.ItemStatus & ITS_ANIMATE2)
184 self.move_avelocity = '0 -90 0';
191 float ItemSend(entity to, float sf)
198 WriteByte(MSG_ENTITY, ENT_CLIENT_ITEM);
199 WriteByte(MSG_ENTITY, sf);
201 //WriteByte(MSG_ENTITY, self.cnt);
202 if(sf & ISF_LOCATION)
204 WriteCoord(MSG_ENTITY, self.origin_x);
205 WriteCoord(MSG_ENTITY, self.origin_y);
206 WriteCoord(MSG_ENTITY, self.origin_z);
211 WriteCoord(MSG_ENTITY, self.angles_x);
212 WriteCoord(MSG_ENTITY, self.angles_y);
213 WriteCoord(MSG_ENTITY, self.angles_z);
217 WriteByte(MSG_ENTITY, self.ItemStatus);
223 dprint("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
225 WriteString(MSG_ENTITY, self.mdl);
229 if(sf & ISF_COLORMAP)
230 WriteShort(MSG_ENTITY, self.colormap);
234 WriteCoord(MSG_ENTITY, self.velocity_x);
235 WriteCoord(MSG_ENTITY, self.velocity_y);
236 WriteCoord(MSG_ENTITY, self.velocity_z);
243 float have_pickup_item(void)
245 if(self.flags & FL_POWERUP)
247 if(autocvar_g_powerups > 0)
249 if(autocvar_g_powerups == 0)
258 if(autocvar_g_pickup_items > 0)
260 if(autocvar_g_pickup_items == 0)
265 if(!WEPSET_EMPTY_E(self) || (self.items & IT_AMMO))
271 floatfield Item_CounterField(float it)
275 case IT_SHELLS: return ammo_shells;
276 case IT_NAILS: return ammo_nails;
277 case IT_ROCKETS: return ammo_rockets;
278 case IT_CELLS: return ammo_cells;
279 case IT_FUEL: return ammo_fuel;
280 case IT_5HP: return health;
281 case IT_25HP: return health;
282 case IT_HEALTH: return health;
283 case IT_ARMOR_SHARD: return armorvalue;
284 case IT_ARMOR: return armorvalue;
285 // add more things here (health, armor)
286 default: error("requested item has no counter field");
289 // should never happen
294 string Item_CounterFieldName(float it)
298 case IT_SHELLS: return "shells";
299 case IT_NAILS: return "nails";
300 case IT_ROCKETS: return "rockets";
301 case IT_CELLS: return "cells";
302 case IT_FUEL: return "fuel";
304 // add more things here (health, armor)
305 default: error("requested item has no counter field name");
308 // should never happen
314 float Item_Customize()
316 if(self.spawnshieldtime)
318 if(!WEPSET_CONTAINS_ALL_EE(other, self))
320 self.colormod = '0 0 0';
321 self.glowmod = self.colormod;
322 self.alpha = 0.5 + 0.5 * g_ghost_items; // halfway more alpha
329 self.colormod = stov(autocvar_g_ghost_items_color);
330 self.glowmod = self.colormod;
331 self.alpha = g_ghost_items;
340 void Item_Show (entity e, float mode)
342 e.effects &~= EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST;
343 e.ItemStatus &~= ITS_STAYWEP;
346 // make the item look normal, and be touchable
348 e.solid = SOLID_TRIGGER;
349 e.spawnshieldtime = 1;
350 e.ItemStatus |= ITS_AVAILABLE;
354 // hide the item completely
355 e.model = string_null;
357 e.spawnshieldtime = 1;
358 e.ItemStatus &~= ITS_AVAILABLE;
360 else if((e.flags & FL_WEAPON) && !(e.flags & FL_NO_WEAPON_STAY) && g_weapon_stay)
362 // make the item translucent and not touchable
364 e.solid = SOLID_TRIGGER; // can STILL be picked up!
365 e.effects |= EF_STARDUST;
366 e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
367 e.ItemStatus |= (ITS_AVAILABLE | ITS_STAYWEP);
371 //setmodel(e, "null");
373 e.colormod = '0 0 0';
374 e.glowmod = e.colormod;
375 e.spawnshieldtime = 1;
376 e.ItemStatus &~= ITS_AVAILABLE;
379 if (e.items & IT_STRENGTH || e.items & IT_INVINCIBLE)
380 e.ItemStatus |= ITS_POWERUP;
382 if (autocvar_g_nodepthtestitems)
383 e.effects |= EF_NODEPTHTEST;
386 if (autocvar_g_fullbrightitems)
387 e.ItemStatus |= ITS_ALLOWFB;
389 if (autocvar_sv_simple_items)
390 e.ItemStatus |= ITS_ALLOWSI;
392 // relink entity (because solid may have changed)
393 setorigin(e, e.origin);
394 e.SendFlags |= ISF_STATUS;
397 void Item_Respawn (void)
401 if(self.items == IT_STRENGTH)
402 sound (self, CH_TRIGGER, "misc/strength_respawn.wav", VOL_BASE, ATTN_NORM); // play respawn sound
403 else if(self.items == IT_INVINCIBLE)
404 sound (self, CH_TRIGGER, "misc/shield_respawn.wav", VOL_BASE, ATTN_NORM); // play respawn sound
406 sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTN_NORM); // play respawn sound
407 setorigin (self, self.origin);
409 //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
410 pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);
413 void Item_RespawnCountdown (void)
415 if(self.count >= ITEM_RESPAWN_TICKS)
417 if(self.waypointsprite_attached)
418 WaypointSprite_Kill(self.waypointsprite_attached);
423 self.nextthink = time + 1;
428 vector rgb = '1 0 1';
432 case IT_FUEL_REGEN: name = "item-fuelregen"; rgb = '1 0.5 0'; break;
433 case IT_JETPACK: name = "item-jetpack"; rgb = '0.5 0.5 0.5'; break;
434 case IT_STRENGTH: name = "item-strength"; rgb = '0 0 1'; break;
435 case IT_INVINCIBLE: name = "item-shield"; rgb = '1 0 1'; break;
439 MUTATOR_CALLHOOK(Item_RespawnCountdown);
442 if(self.flags & FL_WEAPON)
444 entity wi = get_weaponinfo(self.weapon);
453 WaypointSprite_Spawn(name, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
454 if(self.waypointsprite_attached)
455 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
459 print("Unknown powerup-marked item is wanting to respawn\n");
460 localcmd(sprintf("prvm_edict server %d\n", num_for_edict(self)));
463 sound (self, CH_TRIGGER, "misc/itemrespawncountdown.wav", VOL_BASE, ATTN_NORM); // play respawn sound
464 if(self.waypointsprite_attached)
466 WaypointSprite_Ping(self.waypointsprite_attached);
467 //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
472 void Item_ScheduleRespawnIn(entity e, float t)
474 if((e.flags & FL_POWERUP) || WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
476 e.think = Item_RespawnCountdown;
477 e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
482 e.think = Item_Respawn;
483 e.nextthink = time + t;
487 void Item_ScheduleRespawn(entity e)
489 if(e.respawntime > 0)
492 Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e));
494 else // if respawntime is -1, this item does not respawn
498 void Item_ScheduleInitialRespawn(entity e)
501 Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
504 float Item_GiveAmmoTo(entity item, entity player, .float ammofield, float ammomax, float mode)
509 if (item.spawnshieldtime)
511 if ((player.ammofield < ammomax) || item.pickup_anyway)
513 player.ammofield = bound(player.ammofield, ammomax, player.ammofield + item.ammofield);
517 else if(g_weapon_stay == 2)
519 float mi = min(item.ammofield, ammomax);
520 if (player.ammofield < mi)
522 player.ammofield = mi;
533 player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
535 case ITEM_MODE_HEALTH:
536 player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
538 case ITEM_MODE_ARMOR:
539 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
547 float Item_GiveTo(entity item, entity player)
554 // if nothing happens to player, just return without taking the item
556 _switchweapon = FALSE;
557 // in case the player has autoswitch enabled do the following:
558 // if the player is using their best weapon before items are given, they
559 // probably want to switch to an even better weapon after items are given
560 if (player.autoswitch)
561 if (player.switchweapon == w_getbestweapon(player))
562 _switchweapon = TRUE;
564 if not(WEPSET_CONTAINS_EW(player, player.switchweapon))
565 _switchweapon = TRUE;
567 pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
568 pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
569 pickedup |= Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max, ITEM_MODE_NONE);
570 pickedup |= Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max, ITEM_MODE_NONE);
571 pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max, ITEM_MODE_NONE);
572 pickedup |= Item_GiveAmmoTo(item, player, health, item.max_health, ITEM_MODE_HEALTH);
573 pickedup |= Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue, ITEM_MODE_ARMOR);
575 if (item.flags & FL_WEAPON)
577 WEPSET_DECLARE_A(it);
578 WEPSET_COPY_AE(it, item);
579 WEPSET_ANDNOT_AE(it, player);
581 if (!WEPSET_EMPTY_A(it) || (item.spawnshieldtime && item.pickup_anyway))
584 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
585 if(WEPSET_CONTAINS_AW(it, i))
586 W_GiveWeapon(player, i);
590 if((it = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
594 sprint (player, strcat("You got the ^2", item.netname, "\n"));
597 if (item.strength_finished)
600 player.strength_finished = max(player.strength_finished, time) + item.strength_finished;
602 if (item.invincible_finished)
605 player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished;
607 if (item.superweapons_finished)
610 player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished;
615 // always eat teamed entities
623 if (player.switchweapon != w_getbestweapon(player))
624 W_SwitchWeapon_Force(player, w_getbestweapon(player));
629 void Item_Touch (void)
633 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
634 if(self.classname == "droppedweapon")
636 if (ITEM_TOUCH_NEEDKILL())
643 if not(IS_PLAYER(other))
647 if (self.solid != SOLID_TRIGGER)
649 if (self.owner == other)
652 switch(MUTATOR_CALLHOOK(ItemTouch))
654 case MUT_ITEMTOUCH_RETURN: { return; }
655 case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
658 if (self.classname == "droppedweapon")
660 self.strength_finished = max(0, self.strength_finished - time);
661 self.invincible_finished = max(0, self.invincible_finished - time);
662 self.superweapons_finished = max(0, self.superweapons_finished - time);
665 if(!Item_GiveTo(self, other))
667 if (self.classname == "droppedweapon")
669 // undo what we did above
670 self.strength_finished += time;
671 self.invincible_finished += time;
672 self.superweapons_finished += time;
679 other.last_pickup = time;
681 pointparticles(particleeffectnum("item_pickup"), self.origin, '0 0 0', 1);
682 sound (other, CH_TRIGGER, self.item_pickupsound, VOL_BASE, ATTN_NORM);
684 if (self.classname == "droppedweapon")
686 else if not(self.spawnshieldtime)
692 RandomSelection_Init();
693 for(head = world; (head = findfloat(head, team, self.team)); )
695 if(head.flags & FL_ITEM)
698 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
701 e = RandomSelection_chosen_ent;
706 Item_ScheduleRespawn(e);
712 Item_Show(self, !self.state);
713 setorigin (self, self.origin);
715 if(self.classname != "droppedweapon")
717 self.think = func_null;
720 if(self.waypointsprite_attached)
721 WaypointSprite_Kill(self.waypointsprite_attached);
723 if((self.flags & FL_POWERUP) | WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS)) // do not spawn powerups initially!
724 Item_ScheduleInitialRespawn(self);
732 if(self.effects & EF_NODRAW)
734 // marker for item team search
735 dprint("Initializing item team ", ftos(self.team), "\n");
736 RandomSelection_Init();
737 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
738 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
739 e = RandomSelection_chosen_ent;
743 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
747 // make it a non-spawned item
749 head.state = 1; // state 1 = initially hidden item
751 head.effects &~= EF_NODRAW;
758 // Savage: used for item garbage-collection
759 // TODO: perhaps nice special effect?
760 void RemoveItem(void)
765 // pickup evaluation functions
766 // these functions decide how desirable an item is to the bots
768 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;}
770 float weapon_pickupevalfunc(entity player, entity item)
772 float c, j, position;
774 // See if I have it already
775 if(!WEPSET_CONTAINS_ALL_EE(player, item))
777 // If I can pick it up
778 if(!item.spawnshieldtime)
780 else if(player.ammo_cells || player.ammo_shells || player.ammo_nails || player.ammo_rockets)
782 // Skilled bots will grab more
783 c = bound(0, skill / 10, 1) * 0.5;
791 // If custom weapon priorities for bots is enabled rate most wanted weapons higher
792 if( bot_custom_weapon && c )
794 // Find the highest position on any range
796 for(j = 0; j < WEP_LAST ; ++j){
798 bot_weapons_far[j] == item.weapon ||
799 bot_weapons_mid[j] == item.weapon ||
800 bot_weapons_close[j] == item.weapon
811 position = WEP_LAST - position;
812 // item.bot_pickupbasevalue is overwritten here
813 return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
817 return item.bot_pickupbasevalue * c;
820 float commodity_pickupevalfunc(entity player, entity item)
823 float need_shells = FALSE, need_nails = FALSE, need_rockets = FALSE, need_cells = FALSE, need_fuel = FALSE;
827 // Detect needed ammo
828 for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
830 wi = get_weaponinfo(i);
832 if not(WEPSET_CONTAINS_EW(player, i))
835 if(wi.items & IT_SHELLS)
837 else if(wi.items & IT_NAILS)
839 else if(wi.items & IT_ROCKETS)
841 else if(wi.items & IT_CELLS)
843 else if(wi.items & IT_FUEL)
847 // TODO: figure out if the player even has the weapon this ammo is for?
848 // may not affect strategy much though...
849 // find out how much more ammo/armor/health the player can hold
851 if (item.ammo_shells)
852 if (player.ammo_shells < g_pickup_shells_max)
853 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
856 if (player.ammo_nails < g_pickup_nails_max)
857 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
859 if (item.ammo_rockets)
860 if (player.ammo_rockets < g_pickup_rockets_max)
861 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
864 if (player.ammo_cells < g_pickup_cells_max)
865 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
868 if (player.ammo_fuel < g_pickup_fuel_max)
869 c = c + max(0, 1 - player.ammo_fuel / g_pickup_fuel_max);
871 if (player.armorvalue < item.max_armorvalue)
872 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
874 if (player.health < item.max_health)
875 c = c + max(0, 1 - player.health / item.max_health);
877 return item.bot_pickupbasevalue * c;
880 void Item_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
882 if(ITEM_DAMAGE_NEEDKILL(deathtype))
886 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
888 startitem_failed = FALSE;
891 self.model = itemmodel;
895 error(strcat("^1Tried to spawn ", itemname, " with no model!\n"));
899 if(self.item_pickupsound == "")
900 self.item_pickupsound = pickupsound;
902 if(!self.respawntime) // both need to be set
904 self.respawntime = defaultrespawntime;
905 self.respawntimejitter = defaultrespawntimejitter;
909 self.weapon = weaponid;
912 WEPSET_COPY_EW(self, weaponid);
914 self.flags = FL_ITEM | itemflags;
916 if(MUTATOR_CALLHOOK(FilterItem)) // error means we do not want the item
918 startitem_failed = TRUE;
923 // is it a dropped weapon?
924 if (self.classname == "droppedweapon")
926 self.reset = SUB_Remove;
927 // it's a dropped weapon
928 self.movetype = MOVETYPE_TOSS;
930 // Savage: remove thrown items after a certain period of time ("garbage collection")
931 self.think = RemoveItem;
932 self.nextthink = time + 20;
934 self.takedamage = DAMAGE_YES;
935 self.event_damage = Item_Damage;
937 if(self.strength_finished || self.invincible_finished || self.superweapons_finished)
940 if(WEPSET_CONTAINS_ALL_AE(WEPBIT_SUPERWEAPONS, self)) // only superweapons
941 if(self.ammo_nails == 0)
942 if(self.ammo_cells == 0)
943 if(self.ammo_rockets == 0)
944 if(self.ammo_shells == 0)
945 if(self.ammo_fuel == 0)
947 if(self.armorvalue == 0)
950 // if item is worthless after a timer, have it expire then
951 self.nextthink = max(self.strength_finished, self.invincible_finished, self.superweapons_finished);
954 // don't drop if in a NODROP zone (such as lava)
955 traceline(self.origin, self.origin, MOVE_NORMAL, self);
956 if (trace_dpstartcontents & DPCONTENTS_NODROP)
958 startitem_failed = TRUE;
965 if(!have_pickup_item())
967 startitem_failed = TRUE;
972 if(self.angles != '0 0 0')
973 self.SendFlags |= ISF_ANGLES;
975 self.reset = Item_Reset;
977 if(self.spawnflags & 1)
980 self.movetype = MOVETYPE_NONE;
982 self.movetype = MOVETYPE_TOSS;
983 // do item filtering according to game mode and other things
986 // first nudge it off the floor a little bit to avoid math errors
987 setorigin(self, self.origin + '0 0 1');
988 // set item size before we spawn a spawnfunc_waypoint
989 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
990 setsize (self, '-16 -16 0', '16 16 48');
992 setsize (self, '-16 -16 0', '16 16 32');
993 // note droptofloor returns FALSE if stuck/or would fall too far
995 waypoint_spawnforitem(self);
999 * can't do it that way, as it would break maps
1000 * TODO make a target_give like entity another way, that perhaps has
1001 * the weapon name in a key
1004 // target_give not yet supported; maybe later
1005 print("removed targeted ", self.classname, "\n");
1006 startitem_failed = TRUE;
1012 if(autocvar_spawn_debug >= 2)
1015 for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
1017 // why not flags & fl_item?
1018 if(otheritem.is_item)
1020 dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
1021 dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
1022 error("Mapper sucks.");
1025 self.is_item = TRUE;
1028 WEPSET_OR_AW(weaponsInMap, weaponid);
1030 precache_model (self.model);
1031 precache_sound (self.item_pickupsound);
1033 precache_sound ("misc/itemrespawncountdown.wav");
1034 if(itemid == IT_STRENGTH)
1035 precache_sound ("misc/strength_respawn.wav");
1036 else if(itemid == IT_INVINCIBLE)
1037 precache_sound ("misc/shield_respawn.wav");
1039 precache_sound ("misc/itemrespawn.wav");
1041 if((itemflags & (FL_POWERUP | FL_WEAPON)) || (itemid & (IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)))
1042 self.target = "###item###"; // for finding the nearest item using find()
1045 self.bot_pickup = TRUE;
1046 self.bot_pickupevalfunc = pickupevalfunc;
1047 self.bot_pickupbasevalue = pickupbasevalue;
1048 self.mdl = self.model;
1049 self.netname = itemname;
1050 self.touch = Item_Touch;
1051 setmodel(self, "null"); // precision set below
1052 //self.effects |= EF_LOWPRECISION;
1054 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
1056 self.pos1 = '-16 -16 0';
1057 self.pos2 = '16 16 48';
1061 self.pos1 = '-16 -16 0';
1062 self.pos2 = '16 16 32';
1064 setsize (self, self.pos1, self.pos2);
1066 if(itemflags & FL_POWERUP)
1067 self.ItemStatus |= ITS_ANIMATE1;
1069 if(self.armorvalue || self.health)
1070 self.ItemStatus |= ITS_ANIMATE2;
1072 if(itemflags & FL_WEAPON)
1074 if (self.classname != "droppedweapon") // if dropped, colormap is already set up nicely
1075 self.colormap = 1024; // color shirt=0 pants=0 grey
1079 self.ItemStatus |= ITS_ANIMATE1;
1080 self.ItemStatus |= ISF_COLORMAP;
1084 if(self.team) // broken, no idea why.
1087 self.cnt = 1; // item probability weight
1089 self.effects |= EF_NODRAW; // marker for item team search
1090 InitializeEntity(self, Item_FindTeam, INITPRIO_FINDTARGET);
1095 Net_LinkEntity(self, FALSE, 0, ItemSend);
1097 // call this hook after everything else has been done
1098 if(MUTATOR_CALLHOOK(Item_Spawn))
1100 startitem_failed = TRUE;
1106 void spawnfunc_item_rockets (void) {
1107 if(!self.ammo_rockets)
1108 self.ammo_rockets = g_pickup_rockets;
1109 if(!self.pickup_anyway)
1110 self.pickup_anyway = g_pickup_ammo_anyway;
1111 StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
1114 void spawnfunc_item_shells (void);
1115 void spawnfunc_item_bullets (void) {
1117 if(autocvar_sv_q3acompat_machineshotgunswap)
1118 if(self.classname != "droppedweapon")
1120 weaponswapping = TRUE;
1121 spawnfunc_item_shells();
1122 weaponswapping = FALSE;
1126 if(!self.ammo_nails)
1127 self.ammo_nails = g_pickup_nails;
1128 if(!self.pickup_anyway)
1129 self.pickup_anyway = g_pickup_ammo_anyway;
1130 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
1133 void spawnfunc_item_cells (void) {
1134 if(!self.ammo_cells)
1135 self.ammo_cells = g_pickup_cells;
1136 if(!self.pickup_anyway)
1137 self.pickup_anyway = g_pickup_ammo_anyway;
1138 StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
1141 void spawnfunc_item_shells (void) {
1143 if(autocvar_sv_q3acompat_machineshotgunswap)
1144 if(self.classname != "droppedweapon")
1146 weaponswapping = TRUE;
1147 spawnfunc_item_bullets();
1148 weaponswapping = FALSE;
1152 if(!self.ammo_shells)
1153 self.ammo_shells = g_pickup_shells;
1154 if(!self.pickup_anyway)
1155 self.pickup_anyway = g_pickup_ammo_anyway;
1156 StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
1159 void spawnfunc_item_armor_small (void) {
1160 if(!self.armorvalue)
1161 self.armorvalue = g_pickup_armorsmall;
1162 if(!self.max_armorvalue)
1163 self.max_armorvalue = g_pickup_armorsmall_max;
1164 if(!self.pickup_anyway)
1165 self.pickup_anyway = g_pickup_armorsmall_anyway;
1166 StartItem ("models/items/item_armor_small.md3", "misc/armor1.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1169 void spawnfunc_item_armor_medium (void) {
1170 if(!self.armorvalue)
1171 self.armorvalue = g_pickup_armormedium;
1172 if(!self.max_armorvalue)
1173 self.max_armorvalue = g_pickup_armormedium_max;
1174 if(!self.pickup_anyway)
1175 self.pickup_anyway = g_pickup_armormedium_anyway;
1176 StartItem ("models/items/item_armor_medium.md3", "misc/armor10.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
1179 void spawnfunc_item_armor_big (void) {
1180 if(!self.armorvalue)
1181 self.armorvalue = g_pickup_armorbig;
1182 if(!self.max_armorvalue)
1183 self.max_armorvalue = g_pickup_armorbig_max;
1184 if(!self.pickup_anyway)
1185 self.pickup_anyway = g_pickup_armorbig_anyway;
1186 StartItem ("models/items/item_armor_big.md3", "misc/armor17_5.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "50 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
1189 void spawnfunc_item_armor_large (void) {
1190 if(!self.armorvalue)
1191 self.armorvalue = g_pickup_armorlarge;
1192 if(!self.max_armorvalue)
1193 self.max_armorvalue = g_pickup_armorlarge_max;
1194 if(!self.pickup_anyway)
1195 self.pickup_anyway = g_pickup_armorlarge_anyway;
1196 StartItem ("models/items/item_armor_large.md3", "misc/armor25.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
1199 void spawnfunc_item_health_small (void) {
1200 if(!self.max_health)
1201 self.max_health = g_pickup_healthsmall_max;
1203 self.health = g_pickup_healthsmall;
1204 if(!self.pickup_anyway)
1205 self.pickup_anyway = g_pickup_healthsmall_anyway;
1206 StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1209 void spawnfunc_item_health_medium (void) {
1210 if(!self.max_health)
1211 self.max_health = g_pickup_healthmedium_max;
1213 self.health = g_pickup_healthmedium;
1214 if(!self.pickup_anyway)
1215 self.pickup_anyway = g_pickup_healthmedium_anyway;
1216 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
1219 void spawnfunc_item_health_large (void) {
1220 if(!self.max_health)
1221 self.max_health = g_pickup_healthlarge_max;
1223 self.health = g_pickup_healthlarge;
1224 if(!self.pickup_anyway)
1225 self.pickup_anyway = g_pickup_healthlarge_anyway;
1226 StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
1229 void spawnfunc_item_health_mega (void) {
1230 if(!self.max_health)
1231 self.max_health = g_pickup_healthmega_max;
1233 self.health = g_pickup_healthmega;
1234 if(!self.pickup_anyway)
1235 self.pickup_anyway = g_pickup_healthmega_anyway;
1236 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
1239 // support old misnamed entities
1240 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
1241 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
1242 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
1243 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
1244 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
1246 void spawnfunc_item_strength (void) {
1247 precache_sound("weapons/strength_fire.wav");
1248 if(!self.strength_finished)
1249 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1250 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
1253 void spawnfunc_item_invincible (void) {
1254 if(!self.invincible_finished)
1255 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1256 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Shield", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
1260 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
1262 void target_items_use (void)
1264 if(activator.classname == "droppedweapon")
1271 if not(IS_PLAYER(activator))
1273 if(activator.deadflag != DEAD_NO)
1278 for(e = world; (e = find(e, classname, "droppedweapon")); )
1279 if(e.enemy == activator)
1282 if(GiveItems(activator, 0, tokenize_console(self.netname)))
1283 centerprint(activator, self.message);
1286 void spawnfunc_target_items (void)
1291 self.use = target_items_use;
1292 if(!self.strength_finished)
1293 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1294 if(!self.invincible_finished)
1295 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1296 if(!self.superweapons_finished)
1297 self.superweapons_finished = autocvar_g_balance_superweapons_time;
1299 precache_sound("misc/itempickup.wav");
1300 precache_sound("misc/megahealth.wav");
1301 precache_sound("misc/armor25.wav");
1302 precache_sound("misc/powerup.wav");
1303 precache_sound("misc/poweroff.wav");
1304 precache_sound("weapons/weaponpickup.wav");
1306 n = tokenize_console(self.netname);
1307 if(argv(0) == "give")
1309 self.netname = substring(self.netname, argv_start_index(1), argv_end_index(-1) - argv_start_index(1));
1313 for(i = 0; i < n; ++i)
1315 if (argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1316 else if(argv(i) == "unlimited_weapon_ammo") self.items |= IT_UNLIMITED_WEAPON_AMMO;
1317 else if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
1318 else if(argv(i) == "strength") self.items |= IT_STRENGTH;
1319 else if(argv(i) == "invincible") self.items |= IT_INVINCIBLE;
1320 else if(argv(i) == "superweapons") self.items |= IT_SUPERWEAPON;
1321 else if(argv(i) == "jetpack") self.items |= IT_JETPACK;
1322 else if(argv(i) == "fuel_regen") self.items |= IT_FUEL_REGEN;
1325 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1327 e = get_weaponinfo(j);
1328 if(argv(i) == e.netname)
1330 WEPSET_OR_EW(self, j);
1331 if(self.spawnflags == 0 || self.spawnflags == 2)
1332 WEP_ACTION(e.weapon, WR_INIT);
1337 print("target_items: invalid item ", argv(i), "\n");
1341 string itemprefix, valueprefix;
1342 if(self.spawnflags == 0)
1347 else if(self.spawnflags == 1)
1349 itemprefix = "max ";
1350 valueprefix = "max ";
1352 else if(self.spawnflags == 2)
1354 itemprefix = "min ";
1355 valueprefix = "min ";
1357 else if(self.spawnflags == 4)
1359 itemprefix = "minus ";
1360 valueprefix = "max ";
1364 error("invalid spawnflags");
1366 itemprefix = string_null;
1367 valueprefix = string_null;
1372 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
1373 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
1374 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * !!(self.items & IT_STRENGTH), "strength");
1375 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * !!(self.items & IT_INVINCIBLE), "invincible");
1376 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * !!(self.items & IT_SUPERWEAPON), "superweapons");
1377 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_JETPACK), "jetpack");
1378 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_FUEL_REGEN), "fuel_regen");
1379 if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
1380 if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
1381 if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
1382 if(self.ammo_cells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_cells), "cells");
1383 if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
1384 if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
1385 if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
1386 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1388 e = get_weaponinfo(j);
1390 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, WEPSET_CONTAINS_EW(self, j), e.netname);
1393 self.netname = strzone(self.netname);
1394 //print(self.netname, "\n");
1396 n = tokenize_console(self.netname);
1397 for(i = 0; i < n; ++i)
1399 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1401 e = get_weaponinfo(j);
1402 if(argv(i) == e.netname)
1404 WEP_ACTION(e.weapon, WR_INIT);
1411 void spawnfunc_item_fuel(void)
1414 self.ammo_fuel = g_pickup_fuel;
1415 if(!self.pickup_anyway)
1416 self.pickup_anyway = g_pickup_ammo_anyway;
1417 StartItem ("models/items/g_fuel.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "Fuel", IT_FUEL, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1420 void spawnfunc_item_fuel_regen(void)
1422 if(start_items & IT_FUEL_REGEN)
1424 spawnfunc_item_fuel();
1427 StartItem ("models/items/g_fuelregen.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Fuel regenerator", IT_FUEL_REGEN, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1430 void spawnfunc_item_jetpack(void)
1432 if(g_grappling_hook)
1433 return; // sorry, but these two can't coexist (same button); spawn fuel instead
1435 self.ammo_fuel = g_pickup_fuel_jetpack;
1436 if(start_items & IT_JETPACK)
1438 spawnfunc_item_fuel();
1441 StartItem ("models/items/g_jetpack.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Jet pack", IT_JETPACK, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1444 float GiveWeapon(entity e, float wpn, float op, float val)
1447 v0 = WEPSET_CONTAINS_EW(e, wpn);
1452 WEPSET_OR_EW(e, wpn);
1454 WEPSET_ANDNOT_EW(e, wpn);
1459 WEPSET_OR_EW(e, wpn);
1463 WEPSET_ANDNOT_EW(e, wpn);
1467 WEPSET_ANDNOT_EW(e, wpn);
1470 v1 = WEPSET_CONTAINS_EW(e, wpn);
1474 float GiveBit(entity e, .float fld, float bit, float op, float val)
1504 float GiveValue(entity e, .float fld, float op, float val)
1514 e.fld = max(e.fld, val); // min 100 cells = at least 100 cells
1517 e.fld = min(e.fld, val);
1530 void GiveSound(entity e, float v0, float v1, float t, string snd_incr, string snd_decr)
1537 sound (e, CH_TRIGGER, snd_decr, VOL_BASE, ATTN_NORM);
1539 else if(v0 >= v0 + t)
1542 sound (e, CH_TRIGGER, snd_incr, VOL_BASE, ATTN_NORM);
1546 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime)
1549 e.rotfield = max(e.rotfield, time + rottime);
1551 e.regenfield = max(e.regenfield, time + regentime);
1554 float GiveItems(entity e, float beginarg, float endarg)
1556 float got, i, j, val, op;
1557 float _switchweapon;
1566 _switchweapon = FALSE;
1568 if (e.switchweapon == w_getbestweapon(e))
1569 _switchweapon = TRUE;
1571 e.strength_finished = max(0, e.strength_finished - time);
1572 e.invincible_finished = max(0, e.invincible_finished - time);
1573 e.superweapons_finished = max(0, e.superweapons_finished - time);
1577 PREGIVE(e, strength_finished);
1578 PREGIVE(e, invincible_finished);
1579 PREGIVE(e, superweapons_finished);
1580 PREGIVE(e, ammo_nails);
1581 PREGIVE(e, ammo_cells);
1582 PREGIVE(e, ammo_shells);
1583 PREGIVE(e, ammo_rockets);
1584 PREGIVE(e, ammo_fuel);
1585 PREGIVE(e, armorvalue);
1588 for(i = beginarg; i < endarg; ++i)
1592 if(cmd == "0" || stof(cmd))
1616 got += GiveBit(e, items, IT_FUEL_REGEN, op, val);
1617 got += GiveValue(e, strength_finished, op, val);
1618 got += GiveValue(e, invincible_finished, op, val);
1619 got += GiveValue(e, superweapons_finished, op, val);
1620 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1622 got += GiveBit(e, items, IT_JETPACK, op, val);
1623 got += GiveValue(e, health, op, val);
1624 got += GiveValue(e, armorvalue, op, val);
1626 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1628 wi = get_weaponinfo(j);
1630 if not(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED)
1631 got += GiveWeapon(e, j, op, val);
1634 got += GiveValue(e, ammo_cells, op, val);
1635 got += GiveValue(e, ammo_shells, op, val);
1636 got += GiveValue(e, ammo_nails, op, val);
1637 got += GiveValue(e, ammo_rockets, op, val);
1638 got += GiveValue(e, ammo_fuel, op, val);
1640 case "unlimited_ammo":
1641 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1643 case "unlimited_weapon_ammo":
1644 got += GiveBit(e, items, IT_UNLIMITED_WEAPON_AMMO, op, val);
1646 case "unlimited_superweapons":
1647 got += GiveBit(e, items, IT_UNLIMITED_SUPERWEAPONS, op, val);
1650 got += GiveBit(e, items, IT_JETPACK, op, val);
1653 got += GiveBit(e, items, IT_FUEL_REGEN, op, val);
1656 got += GiveValue(e, strength_finished, op, val);
1659 got += GiveValue(e, invincible_finished, op, val);
1661 case "superweapons":
1662 got += GiveValue(e, superweapons_finished, op, val);
1665 got += GiveValue(e, ammo_cells, op, val);
1668 got += GiveValue(e, ammo_shells, op, val);
1672 got += GiveValue(e, ammo_nails, op, val);
1675 got += GiveValue(e, ammo_rockets, op, val);
1678 got += GiveValue(e, health, op, val);
1681 got += GiveValue(e, armorvalue, op, val);
1684 got += GiveValue(e, ammo_fuel, op, val);
1687 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1689 wi = get_weaponinfo(j);
1690 if(cmd == wi.netname)
1692 got += GiveWeapon(e, j, op, val);
1697 print("give: invalid item ", cmd, "\n");
1704 POSTGIVE_BIT(e, items, IT_FUEL_REGEN, "misc/itempickup.wav", string_null);
1705 POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, "misc/powerup.wav", "misc/poweroff.wav");
1706 POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, "misc/powerup.wav", "misc/poweroff.wav");
1707 POSTGIVE_BIT(e, items, IT_JETPACK, "misc/itempickup.wav", string_null);
1708 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1710 wi = get_weaponinfo(j);
1713 POSTGIVE_WEAPON(e, j, "weapons/weaponpickup.wav", string_null);
1714 if not(WEPSET_CONTAINS_AW(save_weapons, j))
1715 if(WEPSET_CONTAINS_EW(e, j))
1716 WEP_ACTION(wi.weapon, WR_INIT);
1719 POSTGIVE_VALUE(e, strength_finished, 1, "misc/powerup.wav", "misc/poweroff.wav");
1720 POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", "misc/poweroff.wav");
1721 POSTGIVE_VALUE(e, ammo_nails, 0, "misc/itempickup.wav", string_null);
1722 POSTGIVE_VALUE(e, ammo_cells, 0, "misc/itempickup.wav", string_null);
1723 POSTGIVE_VALUE(e, ammo_shells, 0, "misc/itempickup.wav", string_null);
1724 POSTGIVE_VALUE(e, ammo_rockets, 0, "misc/itempickup.wav", string_null);
1725 POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, autocvar_g_balance_pause_fuel_rot, pauseregen_finished, autocvar_g_balance_pause_fuel_regen, "misc/itempickup.wav", string_null);
1726 POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, autocvar_g_balance_pause_armor_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, "misc/armor25.wav", string_null);
1727 POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, "misc/megahealth.wav", string_null);
1729 if(e.superweapons_finished <= 0)
1730 if(WEPSET_CONTAINS_ANY_EA(self, WEPBIT_SUPERWEAPONS))
1731 e.superweapons_finished = autocvar_g_balance_superweapons_time;
1733 if(e.strength_finished <= 0)
1734 e.strength_finished = 0;
1736 e.strength_finished += time;
1737 if(e.invincible_finished <= 0)
1738 e.invincible_finished = 0;
1740 e.invincible_finished += time;
1741 if(e.superweapons_finished <= 0)
1742 e.superweapons_finished = 0;
1744 e.superweapons_finished += time;
1746 if not(WEPSET_CONTAINS_EW(e, e.switchweapon))
1747 _switchweapon = TRUE;
1749 W_SwitchWeapon_Force(e, w_getbestweapon(e));