3 #include "items/all.qc"
7 #include "../server/bot/bot.qh"
8 #include "../server/bot/waypoints.qh"
10 #include "../server/mutators/all.qh"
12 #include "../server/weapons/common.qh"
13 #include "../server/weapons/selection.qh"
14 #include "../server/weapons/weaponsystem.qh"
16 #include "constants.qh"
17 #include "deathtypes/all.qh"
18 #include "notifications.qh"
19 #include "triggers/subs.qh"
22 #include "monsters/all.qh"
24 #include "weapons/all.qh"
26 #include "../lib/warpzone/util_server.qh"
28 #include "physics/movetypes/movetypes.qh"
29 #include "weapons/all.qh"
30 #include "../lib/csqcmodel/cl_model.qh"
31 #include "../lib/csqcmodel/common.qh"
34 REGISTER_NET_LINKED(ENT_CLIENT_ITEM)
37 void ItemDraw(entity this)
41 Movetype_Physics_MatchServer(this, false);
42 if(this.move_flags & FL_ONGROUND)
43 { // For some reason move_avelocity gets set to '0 0 0' here ...
44 this.oldorigin = this.origin;
47 if(autocvar_cl_animate_items)
48 { // ... so reset it if animations are requested.
49 if(this.ItemStatus & ITS_ANIMATE1)
50 this.move_avelocity = '0 180 0';
52 if(this.ItemStatus & ITS_ANIMATE2)
53 this.move_avelocity = '0 -90 0';
57 else if (autocvar_cl_animate_items)
59 if(this.ItemStatus & ITS_ANIMATE1)
61 this.angles += this.move_avelocity * frametime;
62 setorigin(this, '0 0 10' + this.oldorigin + '0 0 8' * sin(time * 2));
65 if(this.ItemStatus & ITS_ANIMATE2)
67 this.angles += this.move_avelocity * frametime;
68 setorigin(this, '0 0 8' + this.oldorigin + '0 0 4' * sin(time * 3));
73 void ItemDrawSimple(entity this)
77 Movetype_Physics_MatchServer(this, false);
79 if(this.move_flags & FL_ONGROUND)
86 if(warpzone_warpzones_exist)
88 // just incase warpzones were initialized last, reset these
90 self.drawmask = MASK_NORMAL;
94 vector org = getpropertyvec(VF_ORIGIN);
95 if(!checkpvs(org, self)) // this makes sense as long as we don't support recursive warpzones
97 else if(self.fade_start)
98 alph = bound(0, (self.fade_end - vlen(org - self.origin - 0.5 * (self.mins + self.maxs))) / (self.fade_end - self.fade_start), 1);
101 //printf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs));
102 if(self.ItemStatus & ITS_AVAILABLE)
107 self.drawmask = MASK_NORMAL;
116 NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
120 if(sf & ISF_LOCATION)
122 self.origin_x = ReadCoord();
123 self.origin_y = ReadCoord();
124 self.origin_z = ReadCoord();
125 setorigin(self, self.origin);
126 self.oldorigin = self.origin;
131 self.angles_x = ReadAngle();
132 self.angles_y = ReadAngle();
133 self.angles_z = ReadAngle();
134 self.move_angles = self.angles;
139 float use_bigsize = ReadByte();
140 setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
143 if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
145 self.ItemStatus = ReadByte();
147 if(self.ItemStatus & ITS_AVAILABLE)
150 self.colormod = self.glowmod = '1 1 1';
154 if (autocvar_cl_ghost_items_color)
156 self.alpha = autocvar_cl_ghost_items;
157 self.colormod = self.glowmod = autocvar_cl_ghost_items_color;
163 if(autocvar_cl_fullbright_items)
164 if(self.ItemStatus & ITS_ALLOWFB)
165 self.effects |= EF_FULLBRIGHT;
167 if(self.ItemStatus & ITS_STAYWEP)
169 self.colormod = self.glowmod = autocvar_cl_weapon_stay_color;
170 self.alpha = autocvar_cl_weapon_stay_alpha;
174 if(self.ItemStatus & ITS_POWERUP)
176 if(self.ItemStatus & ITS_AVAILABLE)
177 self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
179 self.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
185 self.drawmask = MASK_NORMAL;
186 self.move_movetype = MOVETYPE_TOSS;
187 self.draw = ItemDraw;
188 self.solid = SOLID_TRIGGER;
189 //self.move_flags |= FL_ITEM;
191 bool use_bigsize = ReadByte();
193 self.fade_end = ReadShort();
194 self.fade_start = ReadShort();
195 if(self.fade_start && !autocvar_cl_items_nofade)
196 self.predraw = Item_PreDraw;
202 string _fn = ReadString();
204 if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
206 string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
207 self.draw = ItemDrawSimple;
209 if(fexists(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix)))
210 self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
211 else if(fexists(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix)))
212 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
213 else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
214 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
215 else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
216 self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
219 self.draw = ItemDraw;
220 LOG_TRACE("Simple item requested for ", _fn, " but no model exists for it\n");
224 if(self.draw != ItemDrawSimple)
225 self.mdl = strzone(_fn);
229 LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, ", tell tZork about this!\n");
231 precache_model(self.mdl);
232 _setmodel(self, self.mdl);
234 setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
237 if(sf & ISF_COLORMAP)
238 self.colormap = ReadShort();
243 self.pushable = true;
244 //self.move_angles = '0 0 0';
245 self.move_movetype = MOVETYPE_TOSS;
246 self.move_velocity_x = ReadCoord();
247 self.move_velocity_y = ReadCoord();
248 self.move_velocity_z = ReadCoord();
249 self.velocity = self.move_velocity;
250 self.move_origin = self.oldorigin;
254 self.move_time = time;
255 self.spawntime = time;
258 self.move_time = max(self.move_time, time);
261 if(autocvar_cl_animate_items)
263 if(self.ItemStatus & ITS_ANIMATE1)
264 self.move_avelocity = '0 180 0';
266 if(self.ItemStatus & ITS_ANIMATE2)
267 self.move_avelocity = '0 -90 0';
270 self.entremove = ItemRemove;
278 bool ItemSend(entity this, entity to, int sf)
285 WriteHeader(MSG_ENTITY, ENT_CLIENT_ITEM);
286 WriteByte(MSG_ENTITY, sf);
288 //WriteByte(MSG_ENTITY, self.cnt);
289 if(sf & ISF_LOCATION)
291 WriteCoord(MSG_ENTITY, self.origin.x);
292 WriteCoord(MSG_ENTITY, self.origin.y);
293 WriteCoord(MSG_ENTITY, self.origin.z);
298 WriteAngle(MSG_ENTITY, self.angles_x);
299 WriteAngle(MSG_ENTITY, self.angles_y);
300 WriteAngle(MSG_ENTITY, self.angles_z);
305 Pickup p = this.itemdef;
306 WriteByte(MSG_ENTITY, p.instanceOfPowerup || p.instanceOfHealth || p.instanceOfArmor);
310 WriteByte(MSG_ENTITY, self.ItemStatus);
314 Pickup p = this.itemdef;
315 WriteByte(MSG_ENTITY, p.instanceOfPowerup || p.instanceOfHealth || p.instanceOfArmor);
316 WriteShort(MSG_ENTITY, self.fade_end);
317 WriteShort(MSG_ENTITY, self.fade_start);
320 LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
322 WriteString(MSG_ENTITY, self.mdl);
326 if(sf & ISF_COLORMAP)
327 WriteShort(MSG_ENTITY, self.colormap);
331 WriteCoord(MSG_ENTITY, self.velocity.x);
332 WriteCoord(MSG_ENTITY, self.velocity.y);
333 WriteCoord(MSG_ENTITY, self.velocity.z);
339 void ItemUpdate(entity this)
341 this.oldorigin = this.origin;
342 this.SendFlags |= ISF_LOCATION;
345 void UpdateItemAfterTeleport(entity this)
347 if(this.SendEntity3 == ItemSend)
351 bool have_pickup_item(entity this)
353 if(this.itemdef.instanceOfPowerup)
355 if(autocvar_g_powerups > 0)
357 if(autocvar_g_powerups == 0)
362 if(autocvar_g_pickup_items > 0)
364 if(autocvar_g_pickup_items == 0)
367 if(this.weapons || (this.items & IT_AMMO)) // no item or ammo pickups in weaponarena
374 float Item_Customize()
376 if(self.spawnshieldtime)
378 if(self.weapons & ~other.weapons)
380 self.colormod = '0 0 0';
381 self.glowmod = self.colormod;
382 self.alpha = 0.5 + 0.5 * g_ghost_items; // halfway more alpha
389 self.colormod = stov(autocvar_g_ghost_items_color);
390 self.glowmod = self.colormod;
391 self.alpha = g_ghost_items;
400 void Item_Show (entity e, float mode)
402 e.effects &= ~(EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST);
403 e.ItemStatus &= ~ITS_STAYWEP;
406 // make the item look normal, and be touchable
408 e.solid = SOLID_TRIGGER;
409 e.spawnshieldtime = 1;
410 e.ItemStatus |= ITS_AVAILABLE;
414 // hide the item completely
415 e.model = string_null;
417 e.spawnshieldtime = 1;
418 e.ItemStatus &= ~ITS_AVAILABLE;
421 entity def = e.itemdef;
422 bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.weapons & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
423 || e.team // weapon stay isn't supported for teamed weapons
425 if(def.instanceOfWeaponPickup && !nostay && g_weapon_stay)
427 // make the item translucent and not touchable
429 e.solid = SOLID_TRIGGER; // can STILL be picked up!
430 e.effects |= EF_STARDUST;
431 e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
432 e.ItemStatus |= (ITS_AVAILABLE | ITS_STAYWEP);
436 //setmodel(e, "null");
438 e.colormod = '0 0 0';
439 e.glowmod = e.colormod;
440 e.spawnshieldtime = 1;
441 e.ItemStatus &= ~ITS_AVAILABLE;
444 if (e.items & ITEM_Strength.m_itemid || e.items & ITEM_Shield.m_itemid)
445 e.ItemStatus |= ITS_POWERUP;
447 if (autocvar_g_nodepthtestitems)
448 e.effects |= EF_NODEPTHTEST;
451 if (autocvar_g_fullbrightitems)
452 e.ItemStatus |= ITS_ALLOWFB;
454 if (autocvar_sv_simple_items)
455 e.ItemStatus |= ITS_ALLOWSI;
457 // relink entity (because solid may have changed)
458 setorigin(e, e.origin);
459 e.SendFlags |= ISF_STATUS;
464 self.nextthink = time;
465 if(self.origin != self.oldorigin)
469 bool Item_ItemsTime_SpectatorOnly(GameItem it);
470 bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons);
471 float Item_ItemsTime_UpdateTime(entity e, float t);
472 void Item_ItemsTime_SetTime(entity e, float t);
473 void Item_ItemsTime_SetTimesForAllPlayers();
479 if(self.items == ITEM_Strength.m_itemid)
480 sound (self, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
481 else if(self.items == ITEM_Shield.m_itemid)
482 sound (self, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
484 sound (self, CH_TRIGGER, SND_ITEMRESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
485 setorigin (self, self.origin);
487 if (Item_ItemsTime_Allow(self.itemdef, self.weapons))
489 float t = Item_ItemsTime_UpdateTime(self, 0);
490 Item_ItemsTime_SetTime(self, t);
491 Item_ItemsTime_SetTimesForAllPlayers();
494 self.think = Item_Think;
495 self.nextthink = time;
497 //Send_Effect(EFFECT_ITEM_RESPAWN, self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
498 Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
501 void Item_RespawnCountdown ()
503 if(self.count >= ITEM_RESPAWN_TICKS)
505 if(self.waypointsprite_attached)
506 WaypointSprite_Kill(self.waypointsprite_attached);
511 self.nextthink = time + 1;
515 MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
518 entity wi = Weapons_from(self.weapon);
519 if (wi != WEP_Null) {
520 entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
521 wp.wp_extra = wi.m_id;
526 entity ii = self.itemdef;
528 entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Item);
529 wp.wp_extra = ii.m_id;
534 if(self.waypointsprite_attached)
536 GameItem def = self.itemdef;
537 if (Item_ItemsTime_SpectatorOnly(def))
538 WaypointSprite_UpdateRule(self.waypointsprite_attached, 0, SPRITERULE_SPECTATOR);
539 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
543 if(self.waypointsprite_attached)
545 setself(self.waypointsprite_attached);
546 FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
547 if(self.waypointsprite_visible_for_player(it))
550 soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM); // play respawn sound
555 WaypointSprite_Ping(self.waypointsprite_attached);
556 //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
561 void Item_RespawnThink()
563 self.nextthink = time;
564 if(self.origin != self.oldorigin)
567 if(time >= self.wait)
571 void Item_ScheduleRespawnIn(entity e, float t)
573 if (Item_ItemsTime_Allow(e.itemdef, e.weapons))
575 e.think = Item_RespawnCountdown;
576 e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
577 e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
579 t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
580 Item_ItemsTime_SetTime(e, t);
581 Item_ItemsTime_SetTimesForAllPlayers();
585 e.think = Item_RespawnThink;
587 e.scheduledrespawntime = time + t;
592 void Item_ScheduleRespawn(entity e)
594 if(e.respawntime > 0)
597 Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e));
599 else // if respawntime is -1, this item does not respawn
603 void Item_ScheduleInitialRespawn(entity e)
606 Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
609 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
611 if (!item.(ammotype))
614 if (item.spawnshieldtime)
616 if ((player.(ammotype) < ammomax) || item.pickup_anyway > 0)
618 player.(ammotype) = bound(player.(ammotype), ammomax, player.(ammotype) + item.(ammotype));
622 else if(g_weapon_stay == 2)
624 float mi = min(item.(ammotype), ammomax);
625 if (player.(ammotype) < mi)
627 player.(ammotype) = mi;
638 player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
640 case ITEM_MODE_HEALTH:
641 player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
643 case ITEM_MODE_ARMOR:
644 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
652 float Item_GiveTo(entity item, entity player)
657 // if nothing happens to player, just return without taking the item
659 _switchweapon = false;
660 // in case the player has autoswitch enabled do the following:
661 // if the player is using their best weapon before items are given, they
662 // probably want to switch to an even better weapon after items are given
663 if (player.autoswitch)
664 if (PS(player).m_switchweapon == w_getbestweapon(player))
665 _switchweapon = true;
667 if (!(player.weapons & WepSet_FromWeapon(PS(player).m_switchweapon)))
668 _switchweapon = true;
670 pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
671 pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
672 pickedup |= Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max, ITEM_MODE_NONE);
673 pickedup |= Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max, ITEM_MODE_NONE);
674 pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max, ITEM_MODE_NONE);
675 pickedup |= Item_GiveAmmoTo(item, player, ammo_plasma, g_pickup_plasma_max, ITEM_MODE_NONE);
676 pickedup |= Item_GiveAmmoTo(item, player, health, item.max_health, ITEM_MODE_HEALTH);
677 pickedup |= Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue, ITEM_MODE_ARMOR);
679 if (item.itemdef.instanceOfWeaponPickup)
683 w &= ~player.weapons;
685 if (w || (item.spawnshieldtime && item.pickup_anyway > 0))
688 FOREACH(Weapons, it != WEP_Null, LAMBDA(
689 if(w & (it.m_wepset))
691 W_DropEvent(wr_pickup, player, it.m_id, item);
692 W_GiveWeapon(player, it.m_id);
699 if((its = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
703 Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_ITEM_WEAPON_GOT, item.netname);
706 if (item.strength_finished)
709 player.strength_finished = max(player.strength_finished, time) + item.strength_finished;
711 if (item.invincible_finished)
714 player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished;
716 if (item.superweapons_finished)
719 player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished;
724 // always eat teamed entities
731 // crude hack to enforce switching weapons
732 if(g_cts && item.itemdef.instanceOfWeaponPickup)
734 W_SwitchWeapon_Force(player, Weapons_from(item.weapon));
739 if (PS(player).m_switchweapon != w_getbestweapon(player))
740 W_SwitchWeapon_Force(player, w_getbestweapon(player));
749 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
750 if (this.classname == "droppedweapon")
752 if (ITEM_TOUCH_NEEDKILL())
759 if(!(other.flags & FL_PICKUPITEMS)
762 || (this.solid != SOLID_TRIGGER)
763 || (this.owner == other)
764 || (time < this.item_spawnshieldtime)
767 switch (MUTATOR_CALLHOOK(ItemTouch, this, other))
769 case MUT_ITEMTOUCH_RETURN: { return; }
770 case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
773 if (this.classname == "droppedweapon")
775 this.strength_finished = max(0, this.strength_finished - time);
776 this.invincible_finished = max(0, this.invincible_finished - time);
777 this.superweapons_finished = max(0, this.superweapons_finished - time);
779 entity it = this.itemdef;
780 bool gave = ITEM_HANDLE(Pickup, it, this, other);
783 if (this.classname == "droppedweapon")
785 // undo what we did above
786 this.strength_finished += time;
787 this.invincible_finished += time;
788 this.superweapons_finished += time;
795 other.last_pickup = time;
797 Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
798 _sound (other, CH_TRIGGER, (this.item_pickupsound ? this.item_pickupsound : Sound_fixpath(this.item_pickupsound_ent)), VOL_BASE, ATTEN_NORM);
800 if (this.classname == "droppedweapon")
802 else if (this.spawnshieldtime)
807 RandomSelection_Init();
808 for(entity head = world; (head = findfloat(head, team, this.team)); )
810 if(head.flags & FL_ITEM)
811 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
814 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
817 e = RandomSelection_chosen_ent;
822 Item_ScheduleRespawn(e);
826 void Item_Reset(entity this)
828 Item_Show(this, !this.state);
829 setorigin(this, this.origin);
831 if (this.classname != "droppedweapon")
833 this.think = Item_Think;
834 this.nextthink = time;
836 if (this.waypointsprite_attached)
837 WaypointSprite_Kill(this.waypointsprite_attached);
839 if (this.itemdef.instanceOfPowerup || (this.weapons & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
840 Item_ScheduleInitialRespawn(this);
843 void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
849 if(self.effects & EF_NODRAW)
851 // marker for item team search
852 LOG_TRACE("Initializing item team ", ftos(self.team), "\n");
853 RandomSelection_Init();
854 for(head = world; (head = findfloat(head, team, self.team)); )
855 if(head.flags & FL_ITEM)
856 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
857 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
858 e = RandomSelection_chosen_ent;
862 for(head = world; (head = findfloat(head, team, self.team)); )
863 if(head.flags & FL_ITEM)
864 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
868 // make it a non-spawned item
870 head.state = 1; // state 1 = initially hidden item
872 head.effects &= ~EF_NODRAW;
879 // Savage: used for item garbage-collection
880 // TODO: perhaps nice special effect?
883 if(wasfreed(self) || !self) { return; }
884 Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
888 // pickup evaluation functions
889 // these functions decide how desirable an item is to the bots
891 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;}
893 float weapon_pickupevalfunc(entity player, entity item)
897 // See if I have it already
898 if(item.weapons & ~player.weapons)
900 // If I can pick it up
901 if(!item.spawnshieldtime)
903 else if(player.ammo_cells || player.ammo_shells || player.ammo_plasma || player.ammo_nails || player.ammo_rockets)
905 // Skilled bots will grab more
906 c = bound(0, skill / 10, 1) * 0.5;
914 // If custom weapon priorities for bots is enabled rate most wanted weapons higher
915 if( bot_custom_weapon && c )
917 // Find the highest position on any range
919 for (int j = 0; j < WEP_LAST ; ++j){
921 bot_weapons_far[j] == item.weapon ||
922 bot_weapons_mid[j] == item.weapon ||
923 bot_weapons_close[j] == item.weapon
934 position = WEP_LAST - position;
935 // item.bot_pickupbasevalue is overwritten here
936 return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
940 return item.bot_pickupbasevalue * c;
943 float commodity_pickupevalfunc(entity player, entity item)
946 float need_shells = false, need_nails = false, need_rockets = false, need_cells = false, need_plasma = false, need_fuel = false;
949 // Detect needed ammo
950 FOREACH(Weapons, it != WEP_Null, LAMBDA(
951 if(!(player.weapons & (it.m_wepset)))
954 if(it.items & ITEM_Shells.m_itemid)
956 else if(it.items & ITEM_Bullets.m_itemid)
958 else if(it.items & ITEM_Rockets.m_itemid)
960 else if(it.items & ITEM_Cells.m_itemid)
962 else if(it.items & ITEM_Plasma.m_itemid)
964 else if(it.items & ITEM_JetpackFuel.m_itemid)
968 // TODO: figure out if the player even has the weapon this ammo is for?
969 // may not affect strategy much though...
970 // find out how much more ammo/armor/health the player can hold
972 if (item.ammo_shells)
973 if (player.ammo_shells < g_pickup_shells_max)
974 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
977 if (player.ammo_nails < g_pickup_nails_max)
978 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
980 if (item.ammo_rockets)
981 if (player.ammo_rockets < g_pickup_rockets_max)
982 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
985 if (player.ammo_cells < g_pickup_cells_max)
986 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
988 if (item.ammo_plasma)
989 if (player.ammo_plasma < g_pickup_plasma_max)
990 c = c + max(0, 1 - player.ammo_plasma / g_pickup_plasma_max);
993 if (player.ammo_fuel < g_pickup_fuel_max)
994 c = c + max(0, 1 - player.ammo_fuel / g_pickup_fuel_max);
996 if (player.armorvalue < item.max_armorvalue)
997 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
999 if (player.health < item.max_health)
1000 c = c + max(0, 1 - player.health / item.max_health);
1002 return item.bot_pickupbasevalue * c;
1005 void Item_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
1007 if(ITEM_DAMAGE_NEEDKILL(deathtype))
1011 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter)
1013 string itemname = def.m_name;
1014 Model itemmodel = def.m_model;
1015 Sound pickupsound = def.m_sound;
1016 float(entity player, entity item) pickupevalfunc = def.m_pickupevalfunc;
1017 float pickupbasevalue = def.m_botvalue;
1018 int itemflags = def.m_itemflags;
1020 startitem_failed = false;
1022 this.item_model_ent = itemmodel;
1023 this.item_pickupsound_ent = pickupsound;
1025 if(!this.respawntime) // both need to be set
1027 this.respawntime = defaultrespawntime;
1028 this.respawntimejitter = defaultrespawntimejitter;
1031 int itemid = def.m_itemid;
1032 this.items = itemid;
1033 int weaponid = def.instanceOfWeaponPickup ? def.m_weapon.m_id : 0;
1034 this.weapon = weaponid;
1038 this.fade_start = autocvar_g_items_mindist;
1039 this.fade_end = autocvar_g_items_maxdist;
1043 this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
1045 this.flags = FL_ITEM | itemflags;
1047 if(MUTATOR_CALLHOOK(FilterItem, this)) // error means we do not want the item
1049 startitem_failed = true;
1054 // is it a dropped weapon?
1055 if (this.classname == "droppedweapon")
1057 this.reset = SUB_Remove;
1058 // it's a dropped weapon
1059 this.movetype = MOVETYPE_TOSS;
1061 // Savage: remove thrown items after a certain period of time ("garbage collection")
1062 this.think = RemoveItem;
1063 this.nextthink = time + 20;
1065 this.takedamage = DAMAGE_YES;
1066 this.event_damage = Item_Damage;
1068 if(this.strength_finished || this.invincible_finished || this.superweapons_finished)
1070 // if item is worthless after a timer, have it expire then
1071 this.nextthink = max(this.strength_finished, this.invincible_finished, this.superweapons_finished);
1074 // don't drop if in a NODROP zone (such as lava)
1075 traceline(this.origin, this.origin, MOVE_NORMAL, this);
1076 if (trace_dpstartcontents & DPCONTENTS_NODROP)
1078 startitem_failed = true;
1085 if(!have_pickup_item(this))
1087 startitem_failed = true;
1092 if(this.angles != '0 0 0')
1093 this.SendFlags |= ISF_ANGLES;
1095 this.reset = Item_Reset;
1096 // it's a level item
1097 if(this.spawnflags & 1)
1099 if (this.noalign > 0)
1100 this.movetype = MOVETYPE_NONE;
1102 this.movetype = MOVETYPE_TOSS;
1103 // do item filtering according to game mode and other things
1104 if (this.noalign <= 0)
1106 // first nudge it off the floor a little bit to avoid math errors
1107 setorigin(this, this.origin + '0 0 1');
1108 // set item size before we spawn a spawnfunc_waypoint
1109 setsize(this, def.m_mins, def.m_maxs);
1110 this.SendFlags |= ISF_SIZE;
1111 // note droptofloor returns false if stuck/or would fall too far
1113 WITH(entity, self, this, droptofloor());
1114 waypoint_spawnforitem(this);
1118 * can't do it that way, as it would break maps
1119 * TODO make a target_give like entity another way, that perhaps has
1120 * the weapon name in a key
1123 // target_give not yet supported; maybe later
1124 print("removed targeted ", this.classname, "\n");
1125 startitem_failed = true;
1131 if(autocvar_spawn_debug >= 2)
1133 for(entity otheritem = findradius(this.origin, 3); otheritem; otheritem = otheritem.chain)
1135 // why not flags & fl_item?
1136 if(otheritem.is_item)
1138 LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
1139 LOG_TRACE(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
1140 error("Mapper sucks.");
1143 this.is_item = true;
1146 weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
1148 precache_model(this.model);
1149 precache_sound(this.item_pickupsound);
1151 if ( def.instanceOfPowerup
1152 || def.instanceOfWeaponPickup
1153 || (def.instanceOfHealth && def != ITEM_HealthSmall)
1154 || (def.instanceOfArmor && def != ITEM_ArmorSmall)
1155 || (itemid & (IT_KEY1 | IT_KEY2))
1156 ) this.target = "###item###"; // for finding the nearest item using find()
1158 Item_ItemsTime_SetTime(this, 0);
1161 this.bot_pickup = true;
1162 this.bot_pickupevalfunc = pickupevalfunc;
1163 this.bot_pickupbasevalue = pickupbasevalue;
1164 this.mdl = this.model ? this.model : strzone(this.item_model_ent.model_str());
1165 this.netname = itemname;
1166 this.touch = Item_Touch;
1167 setmodel(this, MDL_Null); // precision set below
1168 //this.effects |= EF_LOWPRECISION;
1170 setsize (this, this.pos1 = def.m_mins, this.pos2 = def.m_maxs);
1172 this.SendFlags |= ISF_SIZE;
1174 if (!(this.spawnflags & 1024)) {
1175 if(def.instanceOfPowerup)
1176 this.ItemStatus |= ITS_ANIMATE1;
1178 if(this.armorvalue || this.health)
1179 this.ItemStatus |= ITS_ANIMATE2;
1182 if(def.instanceOfWeaponPickup)
1184 if (this.classname != "droppedweapon") // if dropped, colormap is already set up nicely
1185 this.colormap = 1024; // color shirt=0 pants=0 grey
1188 if (!(this.spawnflags & 1024))
1189 this.ItemStatus |= ITS_ANIMATE1;
1190 this.ItemStatus |= ISF_COLORMAP;
1194 if(this.team) // broken, no idea why.
1197 this.cnt = 1; // item probability weight
1199 this.effects |= EF_NODRAW; // marker for item team search
1200 InitializeEntity(this, Item_FindTeam, INITPRIO_FINDTARGET);
1205 Net_LinkEntity(this, !(def.instanceOfPowerup || def.instanceOfHealth || def.instanceOfArmor), 0, ItemSend);
1207 // call this hook after everything else has been done
1208 if (MUTATOR_CALLHOOK(Item_Spawn, this))
1210 startitem_failed = true;
1216 void StartItem(entity this, GameItem def)
1221 def.m_respawntime(), // defaultrespawntime
1222 def.m_respawntimejitter() // defaultrespawntimejitter
1226 spawnfunc(item_rockets)
1228 if(!this.ammo_rockets)
1229 this.ammo_rockets = g_pickup_rockets;
1230 if(!this.pickup_anyway)
1231 this.pickup_anyway = g_pickup_ammo_anyway;
1232 StartItem(this, ITEM_Rockets);
1235 spawnfunc(item_bullets)
1238 if(autocvar_sv_q3acompat_machineshotgunswap)
1239 if(this.classname != "droppedweapon")
1241 weaponswapping = true;
1242 spawnfunc_item_shells(this);
1243 weaponswapping = false;
1247 if(!this.ammo_nails)
1248 this.ammo_nails = g_pickup_nails;
1249 if(!this.pickup_anyway)
1250 this.pickup_anyway = g_pickup_ammo_anyway;
1251 StartItem(this, ITEM_Bullets);
1254 spawnfunc(item_cells)
1256 if(!this.ammo_cells)
1257 this.ammo_cells = g_pickup_cells;
1258 if(!this.pickup_anyway)
1259 this.pickup_anyway = g_pickup_ammo_anyway;
1260 StartItem(this, ITEM_Cells);
1263 spawnfunc(item_plasma)
1265 if(!this.ammo_plasma)
1266 this.ammo_plasma = g_pickup_plasma;
1267 if(!this.pickup_anyway)
1268 this.pickup_anyway = g_pickup_ammo_anyway;
1269 StartItem(this, ITEM_Plasma);
1272 spawnfunc(item_shells)
1275 if(autocvar_sv_q3acompat_machineshotgunswap)
1276 if(this.classname != "droppedweapon")
1278 weaponswapping = true;
1279 spawnfunc_item_bullets(this);
1280 weaponswapping = false;
1284 if(!this.ammo_shells)
1285 this.ammo_shells = g_pickup_shells;
1286 if(!this.pickup_anyway)
1287 this.pickup_anyway = g_pickup_ammo_anyway;
1288 StartItem(this, ITEM_Shells);
1291 spawnfunc(item_armor_small)
1293 if(!this.armorvalue)
1294 this.armorvalue = g_pickup_armorsmall;
1295 if(!this.max_armorvalue)
1296 this.max_armorvalue = g_pickup_armorsmall_max;
1297 if(!this.pickup_anyway)
1298 this.pickup_anyway = g_pickup_armorsmall_anyway;
1299 StartItem(this, ITEM_ArmorSmall);
1302 spawnfunc(item_armor_medium)
1304 if(!this.armorvalue)
1305 this.armorvalue = g_pickup_armormedium;
1306 if(!this.max_armorvalue)
1307 this.max_armorvalue = g_pickup_armormedium_max;
1308 if(!this.pickup_anyway)
1309 this.pickup_anyway = g_pickup_armormedium_anyway;
1310 StartItem(this, ITEM_ArmorMedium);
1313 spawnfunc(item_armor_big)
1315 if(!this.armorvalue)
1316 this.armorvalue = g_pickup_armorbig;
1317 if(!this.max_armorvalue)
1318 this.max_armorvalue = g_pickup_armorbig_max;
1319 if(!this.pickup_anyway)
1320 this.pickup_anyway = g_pickup_armorbig_anyway;
1321 StartItem(this, ITEM_ArmorLarge);
1324 spawnfunc(item_armor_large)
1326 if(!this.armorvalue)
1327 this.armorvalue = g_pickup_armorlarge;
1328 if(!this.max_armorvalue)
1329 this.max_armorvalue = g_pickup_armorlarge_max;
1330 if(!this.pickup_anyway)
1331 this.pickup_anyway = g_pickup_armorlarge_anyway;
1332 StartItem(this, ITEM_ArmorMega);
1335 spawnfunc(item_health_small)
1337 if(!this.max_health)
1338 this.max_health = g_pickup_healthsmall_max;
1340 this.health = g_pickup_healthsmall;
1341 if(!this.pickup_anyway)
1342 this.pickup_anyway = g_pickup_healthsmall_anyway;
1343 StartItem(this, ITEM_HealthSmall);
1346 spawnfunc(item_health_medium)
1348 if(!this.max_health)
1349 this.max_health = g_pickup_healthmedium_max;
1351 this.health = g_pickup_healthmedium;
1352 if(!this.pickup_anyway)
1353 this.pickup_anyway = g_pickup_healthmedium_anyway;
1354 StartItem(this, ITEM_HealthMedium);
1357 spawnfunc(item_health_large)
1359 if(!this.max_health)
1360 this.max_health = g_pickup_healthlarge_max;
1362 this.health = g_pickup_healthlarge;
1363 if(!this.pickup_anyway)
1364 this.pickup_anyway = g_pickup_healthlarge_anyway;
1365 StartItem(this, ITEM_HealthLarge);
1368 spawnfunc(item_health_mega)
1370 if(!this.max_health)
1371 this.max_health = g_pickup_healthmega_max;
1373 this.health = g_pickup_healthmega;
1374 if(!this.pickup_anyway)
1375 this.pickup_anyway = g_pickup_healthmega_anyway;
1376 StartItem(this, ITEM_HealthMega);
1379 // support old misnamed entities
1380 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
1381 spawnfunc(item_armor25) { spawnfunc_item_armor_large(this); }
1382 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
1383 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
1384 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
1386 spawnfunc(item_strength)
1388 if(!this.strength_finished)
1389 this.strength_finished = autocvar_g_balance_powerup_strength_time;
1390 StartItem(this, ITEM_Strength);
1393 spawnfunc(item_invincible)
1395 if(!this.invincible_finished)
1396 this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1397 StartItem(this, ITEM_Shield);
1401 spawnfunc(item_quad) { this.classname = "item_strength";spawnfunc_item_strength(this);}
1403 void target_items_use()
1405 if(activator.classname == "droppedweapon")
1412 if (!IS_PLAYER(activator))
1414 if(activator.deadflag != DEAD_NO)
1419 for(e = world; (e = find(e, classname, "droppedweapon")); )
1420 if(e.enemy == activator)
1423 if(GiveItems(activator, 0, tokenize_console(self.netname)))
1424 centerprint(activator, self.message);
1427 spawnfunc(target_items)
1432 self.use = target_items_use;
1433 if(!self.strength_finished)
1434 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1435 if(!self.invincible_finished)
1436 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1437 if(!self.superweapons_finished)
1438 self.superweapons_finished = autocvar_g_balance_superweapons_time;
1440 n = tokenize_console(self.netname);
1441 if(argv(0) == "give")
1443 self.netname = substring(self.netname, argv_start_index(1), argv_end_index(-1) - argv_start_index(1));
1447 for(i = 0; i < n; ++i)
1449 if (argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1450 else if(argv(i) == "unlimited_weapon_ammo") self.items |= IT_UNLIMITED_WEAPON_AMMO;
1451 else if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
1452 else if(argv(i) == "strength") self.items |= ITEM_Strength.m_itemid;
1453 else if(argv(i) == "invincible") self.items |= ITEM_Shield.m_itemid;
1454 else if(argv(i) == "superweapons") self.items |= IT_SUPERWEAPON;
1455 else if(argv(i) == "jetpack") self.items |= ITEM_Jetpack.m_itemid;
1456 else if(argv(i) == "fuel_regen") self.items |= ITEM_JetpackRegen.m_itemid;
1459 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1460 s = W_UndeprecateName(argv(i));
1463 self.weapons |= (it.m_wepset);
1464 if(self.spawnflags == 0 || self.spawnflags == 2)
1472 string itemprefix, valueprefix;
1473 if(self.spawnflags == 0)
1478 else if(self.spawnflags == 1)
1480 itemprefix = "max ";
1481 valueprefix = "max ";
1483 else if(self.spawnflags == 2)
1485 itemprefix = "min ";
1486 valueprefix = "min ";
1488 else if(self.spawnflags == 4)
1490 itemprefix = "minus ";
1491 valueprefix = "max ";
1495 error("invalid spawnflags");
1496 itemprefix = valueprefix = string_null;
1500 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
1501 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
1502 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * boolean(self.items & ITEM_Strength.m_itemid), "strength");
1503 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * boolean(self.items & ITEM_Shield.m_itemid), "invincible");
1504 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * boolean(self.items & IT_SUPERWEAPON), "superweapons");
1505 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_Jetpack.m_itemid), "jetpack");
1506 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
1507 if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
1508 if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
1509 if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
1510 if(self.ammo_cells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_cells), "cells");
1511 if(self.ammo_plasma != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_plasma), "plasma");
1512 if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
1513 if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
1514 if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
1515 FOREACH(Weapons, it != WEP_Null, LAMBDA(self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname)));
1517 self.netname = strzone(self.netname);
1518 //print(self.netname, "\n");
1520 n = tokenize_console(self.netname);
1521 for(i = 0; i < n; ++i)
1523 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1524 if(argv(i) == it.netname)
1533 spawnfunc(item_fuel)
1536 this.ammo_fuel = g_pickup_fuel;
1537 if(!this.pickup_anyway)
1538 this.pickup_anyway = g_pickup_ammo_anyway;
1539 StartItem(this, ITEM_JetpackFuel);
1542 spawnfunc(item_fuel_regen)
1544 if(start_items & ITEM_JetpackRegen.m_itemid)
1546 spawnfunc_item_fuel(this);
1549 StartItem(this, ITEM_JetpackRegen);
1552 spawnfunc(item_jetpack)
1555 this.ammo_fuel = g_pickup_fuel_jetpack;
1556 if(start_items & ITEM_Jetpack.m_itemid)
1558 spawnfunc_item_fuel(this);
1561 StartItem(this, ITEM_Jetpack);
1564 float GiveWeapon(entity e, float wpn, float op, float val)
1567 WepSet s = WepSet_FromWeapon(Weapons_from(wpn));
1568 v0 = (e.weapons & s);
1591 v1 = (e.weapons & s);
1595 void GiveSound(entity e, float v0, float v1, float t, string snd_incr, string snd_decr)
1602 _sound (e, CH_TRIGGER, snd_decr, VOL_BASE, ATTEN_NORM);
1604 else if(v0 >= v0 + t)
1607 _sound (e, CH_TRIGGER, snd_incr, VOL_BASE, ATTEN_NORM);
1611 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime)
1614 e.(rotfield) = max(e.(rotfield), time + rottime);
1616 e.(regenfield) = max(e.(regenfield), time + regentime);
1618 float GiveItems(entity e, float beginarg, float endarg)
1620 float got, i, val, op;
1621 float _switchweapon;
1629 _switchweapon = false;
1631 if (PS(e).m_switchweapon == w_getbestweapon(e))
1632 _switchweapon = true;
1634 e.strength_finished = max(0, e.strength_finished - time);
1635 e.invincible_finished = max(0, e.invincible_finished - time);
1636 e.superweapons_finished = max(0, e.superweapons_finished - time);
1640 PREGIVE(e, strength_finished);
1641 PREGIVE(e, invincible_finished);
1642 PREGIVE(e, superweapons_finished);
1643 PREGIVE(e, ammo_nails);
1644 PREGIVE(e, ammo_cells);
1645 PREGIVE(e, ammo_plasma);
1646 PREGIVE(e, ammo_shells);
1647 PREGIVE(e, ammo_rockets);
1648 PREGIVE(e, ammo_fuel);
1649 PREGIVE(e, armorvalue);
1652 for(i = beginarg; i < endarg; ++i)
1656 if(cmd == "0" || stof(cmd))
1680 got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
1681 got += GiveValue(e, strength_finished, op, val);
1682 got += GiveValue(e, invincible_finished, op, val);
1683 got += GiveValue(e, superweapons_finished, op, val);
1684 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1686 got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
1687 got += GiveValue(e, health, op, val);
1688 got += GiveValue(e, armorvalue, op, val);
1690 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1691 if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
1692 got += GiveWeapon(e, it.m_id, op, val);
1695 got += GiveValue(e, ammo_cells, op, val);
1696 got += GiveValue(e, ammo_plasma, op, val);
1697 got += GiveValue(e, ammo_shells, op, val);
1698 got += GiveValue(e, ammo_nails, op, val);
1699 got += GiveValue(e, ammo_rockets, op, val);
1700 got += GiveValue(e, ammo_fuel, op, val);
1702 case "unlimited_ammo":
1703 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1705 case "unlimited_weapon_ammo":
1706 got += GiveBit(e, items, IT_UNLIMITED_WEAPON_AMMO, op, val);
1708 case "unlimited_superweapons":
1709 got += GiveBit(e, items, IT_UNLIMITED_SUPERWEAPONS, op, val);
1712 got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
1715 got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
1718 got += GiveValue(e, strength_finished, op, val);
1721 got += GiveValue(e, invincible_finished, op, val);
1723 case "superweapons":
1724 got += GiveValue(e, superweapons_finished, op, val);
1727 got += GiveValue(e, ammo_cells, op, val);
1730 got += GiveValue(e, ammo_plasma, op, val);
1733 got += GiveValue(e, ammo_shells, op, val);
1737 got += GiveValue(e, ammo_nails, op, val);
1740 got += GiveValue(e, ammo_rockets, op, val);
1743 got += GiveValue(e, health, op, val);
1746 got += GiveValue(e, armorvalue, op, val);
1749 got += GiveValue(e, ammo_fuel, op, val);
1752 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1753 if(cmd == it.netname)
1755 got += GiveWeapon(e, it.m_id, op, val);
1765 POSTGIVE_BIT(e, items, ITEM_JetpackRegen.m_itemid, SND(ITEMPICKUP), string_null);
1766 POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, SND(POWERUP), SND(POWEROFF));
1767 POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, SND(POWERUP), SND(POWEROFF));
1768 POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND(ITEMPICKUP), string_null);
1769 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1770 POSTGIVE_WEAPON(e, it, SND(WEAPONPICKUP), string_null);
1771 if(!(save_weapons & (it.m_wepset)))
1772 if(e.weapons & (it.m_wepset))
1775 POSTGIVE_VALUE(e, strength_finished, 1, SND(POWERUP), SND(POWEROFF));
1776 POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", SND(POWEROFF));
1777 POSTGIVE_VALUE(e, ammo_nails, 0, SND(ITEMPICKUP), string_null);
1778 POSTGIVE_VALUE(e, ammo_cells, 0, SND(ITEMPICKUP), string_null);
1779 POSTGIVE_VALUE(e, ammo_plasma, 0, SND(ITEMPICKUP), string_null);
1780 POSTGIVE_VALUE(e, ammo_shells, 0, SND(ITEMPICKUP), string_null);
1781 POSTGIVE_VALUE(e, ammo_rockets, 0, SND(ITEMPICKUP), string_null);
1782 POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, autocvar_g_balance_pause_fuel_rot, pauseregen_finished, autocvar_g_balance_pause_fuel_regen, SND(ITEMPICKUP), string_null);
1783 POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, autocvar_g_balance_pause_armor_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND(ARMOR25), string_null);
1784 POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND(MEGAHEALTH), string_null);
1786 if(e.superweapons_finished <= 0)
1787 if(self.weapons & WEPSET_SUPERWEAPONS)
1788 e.superweapons_finished = autocvar_g_balance_superweapons_time;
1790 if(e.strength_finished <= 0)
1791 e.strength_finished = 0;
1793 e.strength_finished += time;
1794 if(e.invincible_finished <= 0)
1795 e.invincible_finished = 0;
1797 e.invincible_finished += time;
1798 if(e.superweapons_finished <= 0)
1799 e.superweapons_finished = 0;
1801 e.superweapons_finished += time;
1803 if (!(e.weapons & WepSet_FromWeapon(PS(e).m_switchweapon)))
1804 _switchweapon = true;
1806 W_SwitchWeapon_Force(e, w_getbestweapon(e));