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 Item_SetAlpha(entity this)
39 if(!hud && (this.ItemStatus & ITS_AVAILABLE))
42 this.colormod = this.glowmod = '1 1 1';
46 if (autocvar_cl_ghost_items_color)
48 this.alpha = autocvar_cl_ghost_items;
49 this.colormod = this.glowmod = autocvar_cl_ghost_items_color;
56 if(this.ItemStatus & ITS_STAYWEP)
58 this.colormod = this.glowmod = autocvar_cl_weapon_stay_color;
59 this.alpha = autocvar_cl_weapon_stay_alpha;
62 void ItemDraw(entity this)
66 Movetype_Physics_MatchServer(this, false);
67 if(this.move_flags & FL_ONGROUND)
68 { // For some reason move_avelocity gets set to '0 0 0' here ...
69 this.oldorigin = this.origin;
72 if(autocvar_cl_animate_items)
73 { // ... so reset it if animations are requested.
74 if(this.ItemStatus & ITS_ANIMATE1)
75 this.move_avelocity = '0 180 0';
77 if(this.ItemStatus & ITS_ANIMATE2)
78 this.move_avelocity = '0 -90 0';
82 else if (autocvar_cl_animate_items)
84 if(this.ItemStatus & ITS_ANIMATE1)
86 this.angles += this.move_avelocity * frametime;
87 setorigin(this, '0 0 10' + this.oldorigin + '0 0 8' * sin(time * 2));
90 if(this.ItemStatus & ITS_ANIMATE2)
92 this.angles += this.move_avelocity * frametime;
93 setorigin(this, '0 0 8' + this.oldorigin + '0 0 4' * sin(time * 3));
100 void ItemDrawSimple(entity this)
104 Movetype_Physics_MatchServer(this, false);
106 if(this.move_flags & FL_ONGROUND)
113 if(warpzone_warpzones_exist)
115 // just incase warpzones were initialized last, reset these
117 self.drawmask = MASK_NORMAL;
121 vector org = getpropertyvec(VF_ORIGIN);
122 if(!checkpvs(org, self)) // this makes sense as long as we don't support recursive warpzones
124 else if(self.fade_start)
125 alph = bound(0, (self.fade_end - vlen(org - self.origin - 0.5 * (self.mins + self.maxs))) / (self.fade_end - self.fade_start), 1);
128 //printf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs));
129 if(!hud && (self.ItemStatus & ITS_AVAILABLE))
134 self.drawmask = MASK_NORMAL;
143 NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
147 if(sf & ISF_LOCATION)
149 self.origin_x = ReadCoord();
150 self.origin_y = ReadCoord();
151 self.origin_z = ReadCoord();
152 setorigin(self, self.origin);
153 self.oldorigin = self.origin;
158 self.angles_x = ReadAngle();
159 self.angles_y = ReadAngle();
160 self.angles_z = ReadAngle();
161 self.move_angles = self.angles;
166 float use_bigsize = ReadByte();
167 setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
170 if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
172 self.ItemStatus = ReadByte();
176 if(autocvar_cl_fullbright_items)
177 if(self.ItemStatus & ITS_ALLOWFB)
178 self.effects |= EF_FULLBRIGHT;
180 if(self.ItemStatus & ITS_POWERUP)
182 if(self.ItemStatus & ITS_AVAILABLE)
183 self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
185 self.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
191 self.drawmask = MASK_NORMAL;
192 self.move_movetype = MOVETYPE_TOSS;
193 self.draw = ItemDraw;
194 self.solid = SOLID_TRIGGER;
195 //self.move_flags |= FL_ITEM;
197 bool use_bigsize = ReadByte();
199 self.fade_end = ReadShort();
200 self.fade_start = ReadShort();
201 if(self.fade_start && !autocvar_cl_items_nofade)
202 self.predraw = Item_PreDraw;
208 string _fn = ReadString();
210 if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
212 string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
213 self.draw = ItemDrawSimple;
215 if(fexists(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix)))
216 self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
217 else if(fexists(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix)))
218 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
219 else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
220 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
221 else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
222 self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
225 self.draw = ItemDraw;
226 LOG_TRACE("Simple item requested for ", _fn, " but no model exists for it\n");
230 if(self.draw != ItemDrawSimple)
231 self.mdl = strzone(_fn);
235 LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, ", tell tZork about this!\n");
237 precache_model(self.mdl);
238 _setmodel(self, self.mdl);
240 setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
243 if(sf & ISF_COLORMAP)
244 self.colormap = ReadShort();
249 self.pushable = true;
250 //self.move_angles = '0 0 0';
251 self.move_movetype = MOVETYPE_TOSS;
252 self.move_velocity_x = ReadCoord();
253 self.move_velocity_y = ReadCoord();
254 self.move_velocity_z = ReadCoord();
255 self.velocity = self.move_velocity;
256 self.move_origin = self.oldorigin;
260 self.move_time = time;
261 self.spawntime = time;
264 self.move_time = max(self.move_time, time);
267 if(autocvar_cl_animate_items)
269 if(self.ItemStatus & ITS_ANIMATE1)
270 self.move_avelocity = '0 180 0';
272 if(self.ItemStatus & ITS_ANIMATE2)
273 self.move_avelocity = '0 -90 0';
276 self.entremove = ItemRemove;
284 bool ItemSend(entity this, entity to, int sf)
291 WriteHeader(MSG_ENTITY, ENT_CLIENT_ITEM);
292 WriteByte(MSG_ENTITY, sf);
294 //WriteByte(MSG_ENTITY, self.cnt);
295 if(sf & ISF_LOCATION)
297 WriteCoord(MSG_ENTITY, self.origin.x);
298 WriteCoord(MSG_ENTITY, self.origin.y);
299 WriteCoord(MSG_ENTITY, self.origin.z);
304 WriteAngle(MSG_ENTITY, self.angles_x);
305 WriteAngle(MSG_ENTITY, self.angles_y);
306 WriteAngle(MSG_ENTITY, self.angles_z);
311 Pickup p = this.itemdef;
312 WriteByte(MSG_ENTITY, p.instanceOfPowerup || p.instanceOfHealth || p.instanceOfArmor);
316 WriteByte(MSG_ENTITY, self.ItemStatus);
320 Pickup p = this.itemdef;
321 WriteByte(MSG_ENTITY, p.instanceOfPowerup || p.instanceOfHealth || p.instanceOfArmor);
322 WriteShort(MSG_ENTITY, self.fade_end);
323 WriteShort(MSG_ENTITY, self.fade_start);
326 LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
328 WriteString(MSG_ENTITY, self.mdl);
332 if(sf & ISF_COLORMAP)
333 WriteShort(MSG_ENTITY, self.colormap);
337 WriteCoord(MSG_ENTITY, self.velocity.x);
338 WriteCoord(MSG_ENTITY, self.velocity.y);
339 WriteCoord(MSG_ENTITY, self.velocity.z);
345 void ItemUpdate(entity this)
347 this.oldorigin = this.origin;
348 this.SendFlags |= ISF_LOCATION;
351 void UpdateItemAfterTeleport(entity this)
353 if(this.SendEntity3 == ItemSend)
357 bool have_pickup_item(entity this)
359 if(this.itemdef.instanceOfPowerup)
361 if(autocvar_g_powerups > 0)
363 if(autocvar_g_powerups == 0)
368 if(autocvar_g_pickup_items > 0)
370 if(autocvar_g_pickup_items == 0)
373 if(this.weapons || (this.items & IT_AMMO)) // no item or ammo pickups in weaponarena
380 float Item_Customize()
382 if(self.spawnshieldtime)
384 if(self.weapons & ~other.weapons)
386 self.colormod = '0 0 0';
387 self.glowmod = self.colormod;
388 self.alpha = 0.5 + 0.5 * g_ghost_items; // halfway more alpha
395 self.colormod = stov(autocvar_g_ghost_items_color);
396 self.glowmod = self.colormod;
397 self.alpha = g_ghost_items;
406 void Item_Show (entity e, float mode)
408 e.effects &= ~(EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST);
409 e.ItemStatus &= ~ITS_STAYWEP;
412 // make the item look normal, and be touchable
414 e.solid = SOLID_TRIGGER;
415 e.spawnshieldtime = 1;
416 e.ItemStatus |= ITS_AVAILABLE;
420 // hide the item completely
421 e.model = string_null;
423 e.spawnshieldtime = 1;
424 e.ItemStatus &= ~ITS_AVAILABLE;
427 entity def = e.itemdef;
428 bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.weapons & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
429 || e.team // weapon stay isn't supported for teamed weapons
431 if(def.instanceOfWeaponPickup && !nostay && g_weapon_stay)
433 // make the item translucent and not touchable
435 e.solid = SOLID_TRIGGER; // can STILL be picked up!
436 e.effects |= EF_STARDUST;
437 e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
438 e.ItemStatus |= (ITS_AVAILABLE | ITS_STAYWEP);
442 //setmodel(e, "null");
444 e.colormod = '0 0 0';
445 e.glowmod = e.colormod;
446 e.spawnshieldtime = 1;
447 e.ItemStatus &= ~ITS_AVAILABLE;
450 if (e.items & ITEM_Strength.m_itemid || e.items & ITEM_Shield.m_itemid)
451 e.ItemStatus |= ITS_POWERUP;
453 if (autocvar_g_nodepthtestitems)
454 e.effects |= EF_NODEPTHTEST;
457 if (autocvar_g_fullbrightitems)
458 e.ItemStatus |= ITS_ALLOWFB;
460 if (autocvar_sv_simple_items)
461 e.ItemStatus |= ITS_ALLOWSI;
463 // relink entity (because solid may have changed)
464 setorigin(e, e.origin);
465 e.SendFlags |= ISF_STATUS;
470 self.nextthink = time;
471 if(self.origin != self.oldorigin)
475 bool Item_ItemsTime_SpectatorOnly(GameItem it);
476 bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons);
477 float Item_ItemsTime_UpdateTime(entity e, float t);
478 void Item_ItemsTime_SetTime(entity e, float t);
479 void Item_ItemsTime_SetTimesForAllPlayers();
485 if(self.items == ITEM_Strength.m_itemid)
486 sound (self, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
487 else if(self.items == ITEM_Shield.m_itemid)
488 sound (self, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
490 sound (self, CH_TRIGGER, SND_ITEMRESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
491 setorigin (self, self.origin);
493 if (Item_ItemsTime_Allow(self.itemdef, self.weapons))
495 float t = Item_ItemsTime_UpdateTime(self, 0);
496 Item_ItemsTime_SetTime(self, t);
497 Item_ItemsTime_SetTimesForAllPlayers();
500 self.think = Item_Think;
501 self.nextthink = time;
503 //Send_Effect(EFFECT_ITEM_RESPAWN, self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
504 Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
507 void Item_RespawnCountdown ()
509 if(self.count >= ITEM_RESPAWN_TICKS)
511 if(self.waypointsprite_attached)
512 WaypointSprite_Kill(self.waypointsprite_attached);
517 self.nextthink = time + 1;
521 MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
524 entity wi = Weapons_from(self.weapon);
525 if (wi != WEP_Null) {
526 entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
527 wp.wp_extra = wi.m_id;
532 entity ii = self.itemdef;
534 entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Item);
535 wp.wp_extra = ii.m_id;
540 if(self.waypointsprite_attached)
542 GameItem def = self.itemdef;
543 if (Item_ItemsTime_SpectatorOnly(def))
544 WaypointSprite_UpdateRule(self.waypointsprite_attached, 0, SPRITERULE_SPECTATOR);
545 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
549 if(self.waypointsprite_attached)
551 setself(self.waypointsprite_attached);
552 FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
553 if(self.waypointsprite_visible_for_player(it))
556 soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM); // play respawn sound
561 WaypointSprite_Ping(self.waypointsprite_attached);
562 //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
567 void Item_RespawnThink()
569 self.nextthink = time;
570 if(self.origin != self.oldorigin)
573 if(time >= self.wait)
577 void Item_ScheduleRespawnIn(entity e, float t)
579 if (Item_ItemsTime_Allow(e.itemdef, e.weapons))
581 e.think = Item_RespawnCountdown;
582 e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
583 e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
585 t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
586 Item_ItemsTime_SetTime(e, t);
587 Item_ItemsTime_SetTimesForAllPlayers();
591 e.think = Item_RespawnThink;
593 e.scheduledrespawntime = time + t;
598 void Item_ScheduleRespawn(entity e)
600 if(e.respawntime > 0)
603 Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e));
605 else // if respawntime is -1, this item does not respawn
609 void Item_ScheduleInitialRespawn(entity e)
612 Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
615 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
617 if (!item.(ammotype))
620 if (item.spawnshieldtime)
622 if ((player.(ammotype) < ammomax) || item.pickup_anyway > 0)
624 player.(ammotype) = bound(player.(ammotype), ammomax, player.(ammotype) + item.(ammotype));
628 else if(g_weapon_stay == 2)
630 float mi = min(item.(ammotype), ammomax);
631 if (player.(ammotype) < mi)
633 player.(ammotype) = mi;
644 player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
646 case ITEM_MODE_HEALTH:
647 player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
649 case ITEM_MODE_ARMOR:
650 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
658 float Item_GiveTo(entity item, entity player)
663 // if nothing happens to player, just return without taking the item
665 _switchweapon = false;
666 // in case the player has autoswitch enabled do the following:
667 // if the player is using their best weapon before items are given, they
668 // probably want to switch to an even better weapon after items are given
669 if (player.autoswitch)
670 if (PS(player).m_switchweapon == w_getbestweapon(player))
671 _switchweapon = true;
673 if (!(player.weapons & WepSet_FromWeapon(PS(player).m_switchweapon)))
674 _switchweapon = true;
676 pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
677 pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
678 pickedup |= Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max, ITEM_MODE_NONE);
679 pickedup |= Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max, ITEM_MODE_NONE);
680 pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max, ITEM_MODE_NONE);
681 pickedup |= Item_GiveAmmoTo(item, player, ammo_plasma, g_pickup_plasma_max, ITEM_MODE_NONE);
682 pickedup |= Item_GiveAmmoTo(item, player, health, item.max_health, ITEM_MODE_HEALTH);
683 pickedup |= Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue, ITEM_MODE_ARMOR);
685 if (item.itemdef.instanceOfWeaponPickup)
689 w &= ~player.weapons;
691 if (w || (item.spawnshieldtime && item.pickup_anyway > 0))
694 FOREACH(Weapons, it != WEP_Null, LAMBDA(
695 if(w & (it.m_wepset))
697 W_DropEvent(wr_pickup, player, it.m_id, item);
698 W_GiveWeapon(player, it.m_id);
705 if((its = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
709 Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_ITEM_WEAPON_GOT, item.netname);
712 if (item.strength_finished)
715 player.strength_finished = max(player.strength_finished, time) + item.strength_finished;
717 if (item.invincible_finished)
720 player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished;
722 if (item.superweapons_finished)
725 player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished;
730 // always eat teamed entities
737 // crude hack to enforce switching weapons
738 if(g_cts && item.itemdef.instanceOfWeaponPickup)
740 W_SwitchWeapon_Force(player, Weapons_from(item.weapon));
745 if (PS(player).m_switchweapon != w_getbestweapon(player))
746 W_SwitchWeapon_Force(player, w_getbestweapon(player));
755 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
756 if (this.classname == "droppedweapon")
758 if (ITEM_TOUCH_NEEDKILL())
765 if(!(other.flags & FL_PICKUPITEMS)
768 || (this.solid != SOLID_TRIGGER)
769 || (this.owner == other)
770 || (time < this.item_spawnshieldtime)
773 switch (MUTATOR_CALLHOOK(ItemTouch, this, other))
775 case MUT_ITEMTOUCH_RETURN: { return; }
776 case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
779 if (this.classname == "droppedweapon")
781 this.strength_finished = max(0, this.strength_finished - time);
782 this.invincible_finished = max(0, this.invincible_finished - time);
783 this.superweapons_finished = max(0, this.superweapons_finished - time);
785 entity it = this.itemdef;
786 bool gave = ITEM_HANDLE(Pickup, it, this, other);
789 if (this.classname == "droppedweapon")
791 // undo what we did above
792 this.strength_finished += time;
793 this.invincible_finished += time;
794 this.superweapons_finished += time;
801 other.last_pickup = time;
803 Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
804 _sound (other, CH_TRIGGER, (this.item_pickupsound ? this.item_pickupsound : Sound_fixpath(this.item_pickupsound_ent)), VOL_BASE, ATTEN_NORM);
806 if (this.classname == "droppedweapon")
808 else if (this.spawnshieldtime)
813 RandomSelection_Init();
814 for(entity head = world; (head = findfloat(head, team, this.team)); )
816 if(head.flags & FL_ITEM)
817 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
820 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
823 e = RandomSelection_chosen_ent;
828 Item_ScheduleRespawn(e);
832 void Item_Reset(entity this)
834 Item_Show(this, !this.state);
835 setorigin(this, this.origin);
837 if (this.classname != "droppedweapon")
839 this.think = Item_Think;
840 this.nextthink = time;
842 if (this.waypointsprite_attached)
843 WaypointSprite_Kill(this.waypointsprite_attached);
845 if (this.itemdef.instanceOfPowerup || (this.weapons & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
846 Item_ScheduleInitialRespawn(this);
849 void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
855 if(self.effects & EF_NODRAW)
857 // marker for item team search
858 LOG_TRACE("Initializing item team ", ftos(self.team), "\n");
859 RandomSelection_Init();
860 for(head = world; (head = findfloat(head, team, self.team)); )
861 if(head.flags & FL_ITEM)
862 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
863 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
864 e = RandomSelection_chosen_ent;
868 for(head = world; (head = findfloat(head, team, self.team)); )
869 if(head.flags & FL_ITEM)
870 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
874 // make it a non-spawned item
876 head.state = 1; // state 1 = initially hidden item
878 head.effects &= ~EF_NODRAW;
885 // Savage: used for item garbage-collection
886 // TODO: perhaps nice special effect?
889 if(wasfreed(self) || !self) { return; }
890 Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
894 // pickup evaluation functions
895 // these functions decide how desirable an item is to the bots
897 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;}
899 float weapon_pickupevalfunc(entity player, entity item)
903 // See if I have it already
904 if(item.weapons & ~player.weapons)
906 // If I can pick it up
907 if(!item.spawnshieldtime)
909 else if(player.ammo_cells || player.ammo_shells || player.ammo_plasma || player.ammo_nails || player.ammo_rockets)
911 // Skilled bots will grab more
912 c = bound(0, skill / 10, 1) * 0.5;
920 // If custom weapon priorities for bots is enabled rate most wanted weapons higher
921 if( bot_custom_weapon && c )
923 // Find the highest position on any range
925 for (int j = 0; j < WEP_LAST ; ++j){
927 bot_weapons_far[j] == item.weapon ||
928 bot_weapons_mid[j] == item.weapon ||
929 bot_weapons_close[j] == item.weapon
940 position = WEP_LAST - position;
941 // item.bot_pickupbasevalue is overwritten here
942 return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
946 return item.bot_pickupbasevalue * c;
949 float commodity_pickupevalfunc(entity player, entity item)
952 float need_shells = false, need_nails = false, need_rockets = false, need_cells = false, need_plasma = false, need_fuel = false;
955 // Detect needed ammo
956 FOREACH(Weapons, it != WEP_Null, LAMBDA(
957 if(!(player.weapons & (it.m_wepset)))
960 if(it.items & ITEM_Shells.m_itemid)
962 else if(it.items & ITEM_Bullets.m_itemid)
964 else if(it.items & ITEM_Rockets.m_itemid)
966 else if(it.items & ITEM_Cells.m_itemid)
968 else if(it.items & ITEM_Plasma.m_itemid)
970 else if(it.items & ITEM_JetpackFuel.m_itemid)
974 // TODO: figure out if the player even has the weapon this ammo is for?
975 // may not affect strategy much though...
976 // find out how much more ammo/armor/health the player can hold
978 if (item.ammo_shells)
979 if (player.ammo_shells < g_pickup_shells_max)
980 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
983 if (player.ammo_nails < g_pickup_nails_max)
984 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
986 if (item.ammo_rockets)
987 if (player.ammo_rockets < g_pickup_rockets_max)
988 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
991 if (player.ammo_cells < g_pickup_cells_max)
992 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
994 if (item.ammo_plasma)
995 if (player.ammo_plasma < g_pickup_plasma_max)
996 c = c + max(0, 1 - player.ammo_plasma / g_pickup_plasma_max);
999 if (player.ammo_fuel < g_pickup_fuel_max)
1000 c = c + max(0, 1 - player.ammo_fuel / g_pickup_fuel_max);
1001 if (item.armorvalue)
1002 if (player.armorvalue < item.max_armorvalue)
1003 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
1005 if (player.health < item.max_health)
1006 c = c + max(0, 1 - player.health / item.max_health);
1008 return item.bot_pickupbasevalue * c;
1011 void Item_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
1013 if(ITEM_DAMAGE_NEEDKILL(deathtype))
1017 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter)
1019 string itemname = def.m_name;
1020 Model itemmodel = def.m_model;
1021 Sound pickupsound = def.m_sound;
1022 float(entity player, entity item) pickupevalfunc = def.m_pickupevalfunc;
1023 float pickupbasevalue = def.m_botvalue;
1024 int itemflags = def.m_itemflags;
1026 startitem_failed = false;
1028 this.item_model_ent = itemmodel;
1029 this.item_pickupsound_ent = pickupsound;
1031 if(!this.respawntime) // both need to be set
1033 this.respawntime = defaultrespawntime;
1034 this.respawntimejitter = defaultrespawntimejitter;
1037 int itemid = def.m_itemid;
1038 this.items = itemid;
1039 int weaponid = def.instanceOfWeaponPickup ? def.m_weapon.m_id : 0;
1040 this.weapon = weaponid;
1044 this.fade_start = autocvar_g_items_mindist;
1045 this.fade_end = autocvar_g_items_maxdist;
1049 this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
1051 this.flags = FL_ITEM | itemflags;
1053 if(MUTATOR_CALLHOOK(FilterItem, this)) // error means we do not want the item
1055 startitem_failed = true;
1060 // is it a dropped weapon?
1061 if (this.classname == "droppedweapon")
1063 this.reset = SUB_Remove;
1064 // it's a dropped weapon
1065 this.movetype = MOVETYPE_TOSS;
1067 // Savage: remove thrown items after a certain period of time ("garbage collection")
1068 this.think = RemoveItem;
1069 this.nextthink = time + 20;
1071 this.takedamage = DAMAGE_YES;
1072 this.event_damage = Item_Damage;
1074 if(this.strength_finished || this.invincible_finished || this.superweapons_finished)
1076 // if item is worthless after a timer, have it expire then
1077 this.nextthink = max(this.strength_finished, this.invincible_finished, this.superweapons_finished);
1080 // don't drop if in a NODROP zone (such as lava)
1081 traceline(this.origin, this.origin, MOVE_NORMAL, this);
1082 if (trace_dpstartcontents & DPCONTENTS_NODROP)
1084 startitem_failed = true;
1091 if(!have_pickup_item(this))
1093 startitem_failed = true;
1098 if(this.angles != '0 0 0')
1099 this.SendFlags |= ISF_ANGLES;
1101 this.reset = Item_Reset;
1102 // it's a level item
1103 if(this.spawnflags & 1)
1105 if (this.noalign > 0)
1106 this.movetype = MOVETYPE_NONE;
1108 this.movetype = MOVETYPE_TOSS;
1109 // do item filtering according to game mode and other things
1110 if (this.noalign <= 0)
1112 // first nudge it off the floor a little bit to avoid math errors
1113 setorigin(this, this.origin + '0 0 1');
1114 // set item size before we spawn a spawnfunc_waypoint
1115 setsize(this, def.m_mins, def.m_maxs);
1116 this.SendFlags |= ISF_SIZE;
1117 // note droptofloor returns false if stuck/or would fall too far
1119 WITH(entity, self, this, droptofloor());
1120 waypoint_spawnforitem(this);
1124 * can't do it that way, as it would break maps
1125 * TODO make a target_give like entity another way, that perhaps has
1126 * the weapon name in a key
1129 // target_give not yet supported; maybe later
1130 print("removed targeted ", this.classname, "\n");
1131 startitem_failed = true;
1137 if(autocvar_spawn_debug >= 2)
1139 for(entity otheritem = findradius(this.origin, 3); otheritem; otheritem = otheritem.chain)
1141 // why not flags & fl_item?
1142 if(otheritem.is_item)
1144 LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
1145 LOG_TRACE(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
1146 error("Mapper sucks.");
1149 this.is_item = true;
1152 weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
1154 precache_model(this.model);
1155 precache_sound(this.item_pickupsound);
1157 if ( def.instanceOfPowerup
1158 || def.instanceOfWeaponPickup
1159 || (def.instanceOfHealth && def != ITEM_HealthSmall)
1160 || (def.instanceOfArmor && def != ITEM_ArmorSmall)
1161 || (itemid & (IT_KEY1 | IT_KEY2))
1162 ) this.target = "###item###"; // for finding the nearest item using find()
1164 Item_ItemsTime_SetTime(this, 0);
1167 this.bot_pickup = true;
1168 this.bot_pickupevalfunc = pickupevalfunc;
1169 this.bot_pickupbasevalue = pickupbasevalue;
1170 this.mdl = this.model ? this.model : strzone(this.item_model_ent.model_str());
1171 this.netname = itemname;
1172 this.touch = Item_Touch;
1173 setmodel(this, MDL_Null); // precision set below
1174 //this.effects |= EF_LOWPRECISION;
1176 setsize (this, this.pos1 = def.m_mins, this.pos2 = def.m_maxs);
1178 this.SendFlags |= ISF_SIZE;
1180 if (!(this.spawnflags & 1024)) {
1181 if(def.instanceOfPowerup)
1182 this.ItemStatus |= ITS_ANIMATE1;
1184 if(this.armorvalue || this.health)
1185 this.ItemStatus |= ITS_ANIMATE2;
1188 if(def.instanceOfWeaponPickup)
1190 if (this.classname != "droppedweapon") // if dropped, colormap is already set up nicely
1191 this.colormap = 1024; // color shirt=0 pants=0 grey
1194 if (!(this.spawnflags & 1024))
1195 this.ItemStatus |= ITS_ANIMATE1;
1196 this.ItemStatus |= ISF_COLORMAP;
1200 if(this.team) // broken, no idea why.
1203 this.cnt = 1; // item probability weight
1205 this.effects |= EF_NODRAW; // marker for item team search
1206 InitializeEntity(this, Item_FindTeam, INITPRIO_FINDTARGET);
1211 Net_LinkEntity(this, !(def.instanceOfPowerup || def.instanceOfHealth || def.instanceOfArmor), 0, ItemSend);
1213 // call this hook after everything else has been done
1214 if (MUTATOR_CALLHOOK(Item_Spawn, this))
1216 startitem_failed = true;
1222 void StartItem(entity this, GameItem def)
1227 def.m_respawntime(), // defaultrespawntime
1228 def.m_respawntimejitter() // defaultrespawntimejitter
1232 spawnfunc(item_rockets)
1234 if(!this.ammo_rockets)
1235 this.ammo_rockets = g_pickup_rockets;
1236 if(!this.pickup_anyway)
1237 this.pickup_anyway = g_pickup_ammo_anyway;
1238 StartItem(this, ITEM_Rockets);
1241 spawnfunc(item_bullets)
1244 if(autocvar_sv_q3acompat_machineshotgunswap)
1245 if(this.classname != "droppedweapon")
1247 weaponswapping = true;
1248 spawnfunc_item_shells(this);
1249 weaponswapping = false;
1253 if(!this.ammo_nails)
1254 this.ammo_nails = g_pickup_nails;
1255 if(!this.pickup_anyway)
1256 this.pickup_anyway = g_pickup_ammo_anyway;
1257 StartItem(this, ITEM_Bullets);
1260 spawnfunc(item_cells)
1262 if(!this.ammo_cells)
1263 this.ammo_cells = g_pickup_cells;
1264 if(!this.pickup_anyway)
1265 this.pickup_anyway = g_pickup_ammo_anyway;
1266 StartItem(this, ITEM_Cells);
1269 spawnfunc(item_plasma)
1271 if(!this.ammo_plasma)
1272 this.ammo_plasma = g_pickup_plasma;
1273 if(!this.pickup_anyway)
1274 this.pickup_anyway = g_pickup_ammo_anyway;
1275 StartItem(this, ITEM_Plasma);
1278 spawnfunc(item_shells)
1281 if(autocvar_sv_q3acompat_machineshotgunswap)
1282 if(this.classname != "droppedweapon")
1284 weaponswapping = true;
1285 spawnfunc_item_bullets(this);
1286 weaponswapping = false;
1290 if(!this.ammo_shells)
1291 this.ammo_shells = g_pickup_shells;
1292 if(!this.pickup_anyway)
1293 this.pickup_anyway = g_pickup_ammo_anyway;
1294 StartItem(this, ITEM_Shells);
1297 spawnfunc(item_armor_small)
1299 if(!this.armorvalue)
1300 this.armorvalue = g_pickup_armorsmall;
1301 if(!this.max_armorvalue)
1302 this.max_armorvalue = g_pickup_armorsmall_max;
1303 if(!this.pickup_anyway)
1304 this.pickup_anyway = g_pickup_armorsmall_anyway;
1305 StartItem(this, ITEM_ArmorSmall);
1308 spawnfunc(item_armor_medium)
1310 if(!this.armorvalue)
1311 this.armorvalue = g_pickup_armormedium;
1312 if(!this.max_armorvalue)
1313 this.max_armorvalue = g_pickup_armormedium_max;
1314 if(!this.pickup_anyway)
1315 this.pickup_anyway = g_pickup_armormedium_anyway;
1316 StartItem(this, ITEM_ArmorMedium);
1319 spawnfunc(item_armor_big)
1321 if(!this.armorvalue)
1322 this.armorvalue = g_pickup_armorbig;
1323 if(!this.max_armorvalue)
1324 this.max_armorvalue = g_pickup_armorbig_max;
1325 if(!this.pickup_anyway)
1326 this.pickup_anyway = g_pickup_armorbig_anyway;
1327 StartItem(this, ITEM_ArmorLarge);
1330 spawnfunc(item_armor_large)
1332 if(!this.armorvalue)
1333 this.armorvalue = g_pickup_armorlarge;
1334 if(!this.max_armorvalue)
1335 this.max_armorvalue = g_pickup_armorlarge_max;
1336 if(!this.pickup_anyway)
1337 this.pickup_anyway = g_pickup_armorlarge_anyway;
1338 StartItem(this, ITEM_ArmorMega);
1341 spawnfunc(item_health_small)
1343 if(!this.max_health)
1344 this.max_health = g_pickup_healthsmall_max;
1346 this.health = g_pickup_healthsmall;
1347 if(!this.pickup_anyway)
1348 this.pickup_anyway = g_pickup_healthsmall_anyway;
1349 StartItem(this, ITEM_HealthSmall);
1352 spawnfunc(item_health_medium)
1354 if(!this.max_health)
1355 this.max_health = g_pickup_healthmedium_max;
1357 this.health = g_pickup_healthmedium;
1358 if(!this.pickup_anyway)
1359 this.pickup_anyway = g_pickup_healthmedium_anyway;
1360 StartItem(this, ITEM_HealthMedium);
1363 spawnfunc(item_health_large)
1365 if(!this.max_health)
1366 this.max_health = g_pickup_healthlarge_max;
1368 this.health = g_pickup_healthlarge;
1369 if(!this.pickup_anyway)
1370 this.pickup_anyway = g_pickup_healthlarge_anyway;
1371 StartItem(this, ITEM_HealthLarge);
1374 spawnfunc(item_health_mega)
1376 if(!this.max_health)
1377 this.max_health = g_pickup_healthmega_max;
1379 this.health = g_pickup_healthmega;
1380 if(!this.pickup_anyway)
1381 this.pickup_anyway = g_pickup_healthmega_anyway;
1382 StartItem(this, ITEM_HealthMega);
1385 // support old misnamed entities
1386 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
1387 spawnfunc(item_armor25) { spawnfunc_item_armor_large(this); }
1388 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
1389 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
1390 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
1392 spawnfunc(item_strength)
1394 if(!this.strength_finished)
1395 this.strength_finished = autocvar_g_balance_powerup_strength_time;
1396 StartItem(this, ITEM_Strength);
1399 spawnfunc(item_invincible)
1401 if(!this.invincible_finished)
1402 this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1403 StartItem(this, ITEM_Shield);
1407 spawnfunc(item_quad) { this.classname = "item_strength";spawnfunc_item_strength(this);}
1409 void target_items_use()
1411 if(activator.classname == "droppedweapon")
1418 if (!IS_PLAYER(activator))
1420 if(activator.deadflag != DEAD_NO)
1425 for(e = world; (e = find(e, classname, "droppedweapon")); )
1426 if(e.enemy == activator)
1429 if(GiveItems(activator, 0, tokenize_console(self.netname)))
1430 centerprint(activator, self.message);
1433 spawnfunc(target_items)
1438 self.use = target_items_use;
1439 if(!self.strength_finished)
1440 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1441 if(!self.invincible_finished)
1442 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1443 if(!self.superweapons_finished)
1444 self.superweapons_finished = autocvar_g_balance_superweapons_time;
1446 n = tokenize_console(self.netname);
1447 if(argv(0) == "give")
1449 self.netname = substring(self.netname, argv_start_index(1), argv_end_index(-1) - argv_start_index(1));
1453 for(i = 0; i < n; ++i)
1455 if (argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1456 else if(argv(i) == "unlimited_weapon_ammo") self.items |= IT_UNLIMITED_WEAPON_AMMO;
1457 else if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
1458 else if(argv(i) == "strength") self.items |= ITEM_Strength.m_itemid;
1459 else if(argv(i) == "invincible") self.items |= ITEM_Shield.m_itemid;
1460 else if(argv(i) == "superweapons") self.items |= IT_SUPERWEAPON;
1461 else if(argv(i) == "jetpack") self.items |= ITEM_Jetpack.m_itemid;
1462 else if(argv(i) == "fuel_regen") self.items |= ITEM_JetpackRegen.m_itemid;
1465 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1466 s = W_UndeprecateName(argv(i));
1469 self.weapons |= (it.m_wepset);
1470 if(self.spawnflags == 0 || self.spawnflags == 2)
1478 string itemprefix, valueprefix;
1479 if(self.spawnflags == 0)
1484 else if(self.spawnflags == 1)
1486 itemprefix = "max ";
1487 valueprefix = "max ";
1489 else if(self.spawnflags == 2)
1491 itemprefix = "min ";
1492 valueprefix = "min ";
1494 else if(self.spawnflags == 4)
1496 itemprefix = "minus ";
1497 valueprefix = "max ";
1501 error("invalid spawnflags");
1502 itemprefix = valueprefix = string_null;
1506 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
1507 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
1508 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * boolean(self.items & ITEM_Strength.m_itemid), "strength");
1509 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * boolean(self.items & ITEM_Shield.m_itemid), "invincible");
1510 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * boolean(self.items & IT_SUPERWEAPON), "superweapons");
1511 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_Jetpack.m_itemid), "jetpack");
1512 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
1513 if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
1514 if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
1515 if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
1516 if(self.ammo_cells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_cells), "cells");
1517 if(self.ammo_plasma != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_plasma), "plasma");
1518 if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
1519 if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
1520 if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
1521 FOREACH(Weapons, it != WEP_Null, LAMBDA(self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname)));
1523 self.netname = strzone(self.netname);
1524 //print(self.netname, "\n");
1526 n = tokenize_console(self.netname);
1527 for(i = 0; i < n; ++i)
1529 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1530 if(argv(i) == it.netname)
1539 spawnfunc(item_fuel)
1542 this.ammo_fuel = g_pickup_fuel;
1543 if(!this.pickup_anyway)
1544 this.pickup_anyway = g_pickup_ammo_anyway;
1545 StartItem(this, ITEM_JetpackFuel);
1548 spawnfunc(item_fuel_regen)
1550 if(start_items & ITEM_JetpackRegen.m_itemid)
1552 spawnfunc_item_fuel(this);
1555 StartItem(this, ITEM_JetpackRegen);
1558 spawnfunc(item_jetpack)
1561 this.ammo_fuel = g_pickup_fuel_jetpack;
1562 if(start_items & ITEM_Jetpack.m_itemid)
1564 spawnfunc_item_fuel(this);
1567 StartItem(this, ITEM_Jetpack);
1570 float GiveWeapon(entity e, float wpn, float op, float val)
1573 WepSet s = WepSet_FromWeapon(Weapons_from(wpn));
1574 v0 = (e.weapons & s);
1597 v1 = (e.weapons & s);
1601 void GiveSound(entity e, float v0, float v1, float t, string snd_incr, string snd_decr)
1608 _sound (e, CH_TRIGGER, snd_decr, VOL_BASE, ATTEN_NORM);
1610 else if(v0 >= v0 + t)
1613 _sound (e, CH_TRIGGER, snd_incr, VOL_BASE, ATTEN_NORM);
1617 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime)
1620 e.(rotfield) = max(e.(rotfield), time + rottime);
1622 e.(regenfield) = max(e.(regenfield), time + regentime);
1624 float GiveItems(entity e, float beginarg, float endarg)
1626 float got, i, val, op;
1627 float _switchweapon;
1635 _switchweapon = false;
1637 if (PS(e).m_switchweapon == w_getbestweapon(e))
1638 _switchweapon = true;
1640 e.strength_finished = max(0, e.strength_finished - time);
1641 e.invincible_finished = max(0, e.invincible_finished - time);
1642 e.superweapons_finished = max(0, e.superweapons_finished - time);
1646 PREGIVE(e, strength_finished);
1647 PREGIVE(e, invincible_finished);
1648 PREGIVE(e, superweapons_finished);
1649 PREGIVE(e, ammo_nails);
1650 PREGIVE(e, ammo_cells);
1651 PREGIVE(e, ammo_plasma);
1652 PREGIVE(e, ammo_shells);
1653 PREGIVE(e, ammo_rockets);
1654 PREGIVE(e, ammo_fuel);
1655 PREGIVE(e, armorvalue);
1658 for(i = beginarg; i < endarg; ++i)
1662 if(cmd == "0" || stof(cmd))
1686 got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
1687 got += GiveValue(e, strength_finished, op, val);
1688 got += GiveValue(e, invincible_finished, op, val);
1689 got += GiveValue(e, superweapons_finished, op, val);
1690 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1692 got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
1693 got += GiveValue(e, health, op, val);
1694 got += GiveValue(e, armorvalue, op, val);
1696 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1697 if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
1698 got += GiveWeapon(e, it.m_id, op, val);
1701 got += GiveValue(e, ammo_cells, op, val);
1702 got += GiveValue(e, ammo_plasma, op, val);
1703 got += GiveValue(e, ammo_shells, op, val);
1704 got += GiveValue(e, ammo_nails, op, val);
1705 got += GiveValue(e, ammo_rockets, op, val);
1706 got += GiveValue(e, ammo_fuel, op, val);
1708 case "unlimited_ammo":
1709 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1711 case "unlimited_weapon_ammo":
1712 got += GiveBit(e, items, IT_UNLIMITED_WEAPON_AMMO, op, val);
1714 case "unlimited_superweapons":
1715 got += GiveBit(e, items, IT_UNLIMITED_SUPERWEAPONS, op, val);
1718 got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
1721 got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
1724 got += GiveValue(e, strength_finished, op, val);
1727 got += GiveValue(e, invincible_finished, op, val);
1729 case "superweapons":
1730 got += GiveValue(e, superweapons_finished, op, val);
1733 got += GiveValue(e, ammo_cells, op, val);
1736 got += GiveValue(e, ammo_plasma, op, val);
1739 got += GiveValue(e, ammo_shells, op, val);
1743 got += GiveValue(e, ammo_nails, op, val);
1746 got += GiveValue(e, ammo_rockets, op, val);
1749 got += GiveValue(e, health, op, val);
1752 got += GiveValue(e, armorvalue, op, val);
1755 got += GiveValue(e, ammo_fuel, op, val);
1758 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1759 if(cmd == it.netname)
1761 got += GiveWeapon(e, it.m_id, op, val);
1771 POSTGIVE_BIT(e, items, ITEM_JetpackRegen.m_itemid, SND(ITEMPICKUP), string_null);
1772 POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, SND(POWERUP), SND(POWEROFF));
1773 POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, SND(POWERUP), SND(POWEROFF));
1774 POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND(ITEMPICKUP), string_null);
1775 FOREACH(Weapons, it != WEP_Null, LAMBDA(
1776 POSTGIVE_WEAPON(e, it, SND(WEAPONPICKUP), string_null);
1777 if(!(save_weapons & (it.m_wepset)))
1778 if(e.weapons & (it.m_wepset))
1781 POSTGIVE_VALUE(e, strength_finished, 1, SND(POWERUP), SND(POWEROFF));
1782 POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", SND(POWEROFF));
1783 POSTGIVE_VALUE(e, ammo_nails, 0, SND(ITEMPICKUP), string_null);
1784 POSTGIVE_VALUE(e, ammo_cells, 0, SND(ITEMPICKUP), string_null);
1785 POSTGIVE_VALUE(e, ammo_plasma, 0, SND(ITEMPICKUP), string_null);
1786 POSTGIVE_VALUE(e, ammo_shells, 0, SND(ITEMPICKUP), string_null);
1787 POSTGIVE_VALUE(e, ammo_rockets, 0, SND(ITEMPICKUP), string_null);
1788 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);
1789 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);
1790 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);
1792 if(e.superweapons_finished <= 0)
1793 if(self.weapons & WEPSET_SUPERWEAPONS)
1794 e.superweapons_finished = autocvar_g_balance_superweapons_time;
1796 if(e.strength_finished <= 0)
1797 e.strength_finished = 0;
1799 e.strength_finished += time;
1800 if(e.invincible_finished <= 0)
1801 e.invincible_finished = 0;
1803 e.invincible_finished += time;
1804 if(e.superweapons_finished <= 0)
1805 e.superweapons_finished = 0;
1807 e.superweapons_finished += time;
1809 if (!(e.weapons & WepSet_FromWeapon(PS(e).m_switchweapon)))
1810 _switchweapon = true;
1812 W_SwitchWeapon_Force(e, w_getbestweapon(e));