3 #include "../common/items/all.qc"
8 #include "bot/waypoints.qh"
10 #include "mutators/all.qh"
12 #include "weapons/common.qh"
13 #include "weapons/selection.qh"
14 #include "weapons/weaponsystem.qh"
16 #include "../common/constants.qh"
17 #include "../common/deathtypes/all.qh"
18 #include "../common/notifications.qh"
19 #include "../common/triggers/subs.qh"
20 #include "../common/util.qh"
22 #include "../common/monsters/all.qh"
24 #include "../common/weapons/all.qh"
26 #include "../lib/warpzone/util_server.qh"
29 REGISTER_NET_LINKED(ENT_CLIENT_ITEM)
32 void ItemDraw(entity this)
36 Movetype_Physics_MatchServer(this, false);
37 if(this.move_flags & FL_ONGROUND)
38 { // For some reason move_avelocity gets set to '0 0 0' here ...
39 this.oldorigin = this.origin;
42 if(autocvar_cl_animate_items)
43 { // ... so reset it if animations are requested.
44 if(this.ItemStatus & ITS_ANIMATE1)
45 this.move_avelocity = '0 180 0';
47 if(this.ItemStatus & ITS_ANIMATE2)
48 this.move_avelocity = '0 -90 0';
52 else if (autocvar_cl_animate_items)
54 if(this.ItemStatus & ITS_ANIMATE1)
56 this.angles += this.move_avelocity * frametime;
57 setorigin(this, '0 0 10' + this.oldorigin + '0 0 8' * sin(time * 2));
60 if(this.ItemStatus & ITS_ANIMATE2)
62 this.angles += this.move_avelocity * frametime;
63 setorigin(this, '0 0 8' + this.oldorigin + '0 0 4' * sin(time * 3));
68 void ItemDrawSimple(entity this)
72 Movetype_Physics_MatchServer(this, false);
74 if(this.move_flags & FL_ONGROUND)
83 org = getpropertyvec(VF_ORIGIN);
84 if(!checkpvs(org, self)) // this makes sense as long as we don't support recursive warpzones
86 else if(self.fade_start)
87 alph = bound(0, (self.fade_end - vlen(org - self.origin - 0.5 * (self.mins + self.maxs))) / (self.fade_end - self.fade_start), 1);
90 //printf("%v <-> %v\n", view_origin, self.origin + 0.5 * (self.mins + self.maxs));
91 if(self.ItemStatus & ITS_AVAILABLE)
96 self.drawmask = MASK_NORMAL;
105 NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
109 if(sf & ISF_LOCATION)
111 self.origin_x = ReadCoord();
112 self.origin_y = ReadCoord();
113 self.origin_z = ReadCoord();
114 setorigin(self, self.origin);
115 self.oldorigin = self.origin;
120 self.angles_x = ReadAngle();
121 self.angles_y = ReadAngle();
122 self.angles_z = ReadAngle();
123 self.move_angles = self.angles;
128 float use_bigsize = ReadByte();
129 setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
132 if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
134 self.ItemStatus = ReadByte();
136 if(self.ItemStatus & ITS_AVAILABLE)
139 self.colormod = self.glowmod = '1 1 1';
143 if (autocvar_cl_ghost_items_color)
145 self.alpha = autocvar_cl_ghost_items;
146 self.colormod = self.glowmod = autocvar_cl_ghost_items_color;
152 if(autocvar_cl_fullbright_items)
153 if(self.ItemStatus & ITS_ALLOWFB)
154 self.effects |= EF_FULLBRIGHT;
156 if(self.ItemStatus & ITS_STAYWEP)
158 self.colormod = self.glowmod = autocvar_cl_weapon_stay_color;
159 self.alpha = autocvar_cl_weapon_stay_alpha;
163 if(self.ItemStatus & ITS_POWERUP)
165 if(self.ItemStatus & ITS_AVAILABLE)
166 self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
168 self.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
174 self.drawmask = MASK_NORMAL;
175 self.move_movetype = MOVETYPE_TOSS;
176 self.draw = ItemDraw;
177 self.solid = SOLID_TRIGGER;
178 //self.move_flags |= FL_ITEM;
180 bool use_bigsize = ReadByte();
182 self.fade_end = ReadShort();
183 self.fade_start = ReadShort();
184 if(self.fade_start && !autocvar_cl_items_nofade)
185 self.predraw = Item_PreDraw;
191 string _fn = ReadString();
193 if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
195 string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
196 self.draw = ItemDrawSimple;
198 if(fexists(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix)))
199 self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
200 else if(fexists(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix)))
201 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
202 else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
203 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
204 else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
205 self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
208 self.draw = ItemDraw;
209 LOG_TRACE("Simple item requested for ", _fn, " but no model exists for it\n");
213 if(self.draw != ItemDrawSimple)
214 self.mdl = strzone(_fn);
218 LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, ", tell tZork about this!\n");
220 precache_model(self.mdl);
221 _setmodel(self, self.mdl);
223 setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
226 if(sf & ISF_COLORMAP)
227 self.colormap = ReadShort();
232 self.pushable = true;
233 //self.move_angles = '0 0 0';
234 self.move_movetype = MOVETYPE_TOSS;
235 self.move_velocity_x = ReadCoord();
236 self.move_velocity_y = ReadCoord();
237 self.move_velocity_z = ReadCoord();
238 self.velocity = self.move_velocity;
239 self.move_origin = self.oldorigin;
243 self.move_time = time;
244 self.spawntime = time;
247 self.move_time = max(self.move_time, time);
250 if(autocvar_cl_animate_items)
252 if(self.ItemStatus & ITS_ANIMATE1)
253 self.move_avelocity = '0 180 0';
255 if(self.ItemStatus & ITS_ANIMATE2)
256 self.move_avelocity = '0 -90 0';
259 self.entremove = ItemRemove;
267 bool ItemSend(entity this, entity to, int sf)
274 WriteHeader(MSG_ENTITY, ENT_CLIENT_ITEM);
275 WriteByte(MSG_ENTITY, sf);
277 //WriteByte(MSG_ENTITY, self.cnt);
278 if(sf & ISF_LOCATION)
280 WriteCoord(MSG_ENTITY, self.origin.x);
281 WriteCoord(MSG_ENTITY, self.origin.y);
282 WriteCoord(MSG_ENTITY, self.origin.z);
287 WriteAngle(MSG_ENTITY, self.angles_x);
288 WriteAngle(MSG_ENTITY, self.angles_y);
289 WriteAngle(MSG_ENTITY, self.angles_z);
294 Pickup p = this.itemdef;
295 WriteByte(MSG_ENTITY, p.instanceOfPowerup || p.instanceOfHealth || p.instanceOfArmor);
299 WriteByte(MSG_ENTITY, self.ItemStatus);
303 Pickup p = this.itemdef;
304 WriteByte(MSG_ENTITY, p.instanceOfPowerup || p.instanceOfHealth || p.instanceOfArmor);
305 WriteShort(MSG_ENTITY, self.fade_end);
306 WriteShort(MSG_ENTITY, self.fade_start);
309 LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
311 WriteString(MSG_ENTITY, self.mdl);
315 if(sf & ISF_COLORMAP)
316 WriteShort(MSG_ENTITY, self.colormap);
320 WriteCoord(MSG_ENTITY, self.velocity.x);
321 WriteCoord(MSG_ENTITY, self.velocity.y);
322 WriteCoord(MSG_ENTITY, self.velocity.z);
328 void ItemUpdate(entity this)
330 this.oldorigin = this.origin;
331 this.SendFlags |= ISF_LOCATION;
334 void UpdateItemAfterTeleport(entity this)
336 if(this.SendEntity3 == ItemSend)
340 bool have_pickup_item(entity this)
342 if(this.itemdef.instanceOfPowerup)
344 if(autocvar_g_powerups > 0)
346 if(autocvar_g_powerups == 0)
351 if(autocvar_g_pickup_items > 0)
353 if(autocvar_g_pickup_items == 0)
356 if(this.weapons || (this.items & IT_AMMO)) // no item or ammo pickups in weaponarena
363 float Item_Customize()
365 if(self.spawnshieldtime)
367 if(self.weapons & ~other.weapons)
369 self.colormod = '0 0 0';
370 self.glowmod = self.colormod;
371 self.alpha = 0.5 + 0.5 * g_ghost_items; // halfway more alpha
378 self.colormod = stov(autocvar_g_ghost_items_color);
379 self.glowmod = self.colormod;
380 self.alpha = g_ghost_items;
389 void Item_Show (entity e, float mode)
391 e.effects &= ~(EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST);
392 e.ItemStatus &= ~ITS_STAYWEP;
395 // make the item look normal, and be touchable
397 e.solid = SOLID_TRIGGER;
398 e.spawnshieldtime = 1;
399 e.ItemStatus |= ITS_AVAILABLE;
403 // hide the item completely
404 e.model = string_null;
406 e.spawnshieldtime = 1;
407 e.ItemStatus &= ~ITS_AVAILABLE;
410 entity def = e.itemdef;
411 bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.weapons & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
412 || e.team // weapon stay isn't supported for teamed weapons
414 if(def.instanceOfWeaponPickup && !nostay && g_weapon_stay)
416 // make the item translucent and not touchable
418 e.solid = SOLID_TRIGGER; // can STILL be picked up!
419 e.effects |= EF_STARDUST;
420 e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
421 e.ItemStatus |= (ITS_AVAILABLE | ITS_STAYWEP);
425 //setmodel(e, "null");
427 e.colormod = '0 0 0';
428 e.glowmod = e.colormod;
429 e.spawnshieldtime = 1;
430 e.ItemStatus &= ~ITS_AVAILABLE;
433 if (e.items & ITEM_Strength.m_itemid || e.items & ITEM_Shield.m_itemid)
434 e.ItemStatus |= ITS_POWERUP;
436 if (autocvar_g_nodepthtestitems)
437 e.effects |= EF_NODEPTHTEST;
440 if (autocvar_g_fullbrightitems)
441 e.ItemStatus |= ITS_ALLOWFB;
443 if (autocvar_sv_simple_items)
444 e.ItemStatus |= ITS_ALLOWSI;
446 // relink entity (because solid may have changed)
447 setorigin(e, e.origin);
448 e.SendFlags |= ISF_STATUS;
453 self.nextthink = time;
454 if(self.origin != self.oldorigin)
458 bool Item_ItemsTime_SpectatorOnly(GameItem it);
459 bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons);
460 float Item_ItemsTime_UpdateTime(entity e, float t);
461 void Item_ItemsTime_SetTime(entity e, float t);
462 void Item_ItemsTime_SetTimesForAllPlayers();
468 if(self.items == ITEM_Strength.m_itemid)
469 sound (self, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
470 else if(self.items == ITEM_Shield.m_itemid)
471 sound (self, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
473 sound (self, CH_TRIGGER, SND_ITEMRESPAWN, VOL_BASE, ATTEN_NORM); // play respawn sound
474 setorigin (self, self.origin);
476 if (Item_ItemsTime_Allow(self.itemdef, self.weapons))
478 float t = Item_ItemsTime_UpdateTime(self, 0);
479 Item_ItemsTime_SetTime(self, t);
480 Item_ItemsTime_SetTimesForAllPlayers();
483 self.think = Item_Think;
484 self.nextthink = time;
486 //Send_Effect(EFFECT_ITEM_RESPAWN, self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
487 Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
490 void Item_RespawnCountdown ()
492 if(self.count >= ITEM_RESPAWN_TICKS)
494 if(self.waypointsprite_attached)
495 WaypointSprite_Kill(self.waypointsprite_attached);
500 self.nextthink = time + 1;
504 MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
507 entity wi = Weapons_from(self.weapon);
508 if (wi != WEP_Null) {
509 entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
510 wp.wp_extra = wi.m_id;
515 entity ii = self.itemdef;
517 entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Item);
518 wp.wp_extra = ii.m_id;
523 if(self.waypointsprite_attached)
525 GameItem def = self.itemdef;
526 if (Item_ItemsTime_SpectatorOnly(def))
527 WaypointSprite_UpdateRule(self.waypointsprite_attached, 0, SPRITERULE_SPECTATOR);
528 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
532 if(self.waypointsprite_attached)
534 setself(self.waypointsprite_attached);
536 FOR_EACH_REALCLIENT(e)
537 if(self.waypointsprite_visible_for_player(e))
540 soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM); // play respawn sound
544 WaypointSprite_Ping(self.waypointsprite_attached);
545 //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
550 void Item_RespawnThink()
552 self.nextthink = time;
553 if(self.origin != self.oldorigin)
556 if(time >= self.wait)
560 void Item_ScheduleRespawnIn(entity e, float t)
562 if (Item_ItemsTime_Allow(e.itemdef, e.weapons))
564 e.think = Item_RespawnCountdown;
565 e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
566 e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
568 t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime);
569 Item_ItemsTime_SetTime(e, t);
570 Item_ItemsTime_SetTimesForAllPlayers();
574 e.think = Item_RespawnThink;
576 e.scheduledrespawntime = time + t;
581 void Item_ScheduleRespawn(entity e)
583 if(e.respawntime > 0)
586 Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e));
588 else // if respawntime is -1, this item does not respawn
592 void Item_ScheduleInitialRespawn(entity e)
595 Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
598 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
600 if (!item.(ammotype))
603 if (item.spawnshieldtime)
605 if ((player.(ammotype) < ammomax) || item.pickup_anyway > 0)
607 player.(ammotype) = bound(player.(ammotype), ammomax, player.(ammotype) + item.(ammotype));
611 else if(g_weapon_stay == 2)
613 float mi = min(item.(ammotype), ammomax);
614 if (player.(ammotype) < mi)
616 player.(ammotype) = mi;
627 player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
629 case ITEM_MODE_HEALTH:
630 player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
632 case ITEM_MODE_ARMOR:
633 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
641 float Item_GiveTo(entity item, entity player)
648 // if nothing happens to player, just return without taking the item
650 _switchweapon = false;
651 // in case the player has autoswitch enabled do the following:
652 // if the player is using their best weapon before items are given, they
653 // probably want to switch to an even better weapon after items are given
654 if (player.autoswitch)
655 if (PS(player).m_switchweapon == w_getbestweapon(player))
656 _switchweapon = true;
658 if (!(player.weapons & WepSet_FromWeapon(PS(player).m_switchweapon)))
659 _switchweapon = true;
661 pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
662 pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
663 pickedup |= Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max, ITEM_MODE_NONE);
664 pickedup |= Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max, ITEM_MODE_NONE);
665 pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max, ITEM_MODE_NONE);
666 pickedup |= Item_GiveAmmoTo(item, player, ammo_plasma, g_pickup_plasma_max, ITEM_MODE_NONE);
667 pickedup |= Item_GiveAmmoTo(item, player, health, item.max_health, ITEM_MODE_HEALTH);
668 pickedup |= Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue, ITEM_MODE_ARMOR);
670 if (item.itemdef.instanceOfWeaponPickup)
674 it &= ~player.weapons;
676 if (it || (item.spawnshieldtime && item.pickup_anyway > 0))
679 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
680 if(it & WepSet_FromWeapon(Weapons_from(i)))
682 W_DropEvent(wr_pickup, player, i, item);
683 W_GiveWeapon(player, i);
688 if((it = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
692 Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_ITEM_WEAPON_GOT, item.netname);
695 if (item.strength_finished)
698 player.strength_finished = max(player.strength_finished, time) + item.strength_finished;
700 if (item.invincible_finished)
703 player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished;
705 if (item.superweapons_finished)
708 player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished;
713 // always eat teamed entities
720 // crude hack to enforce switching weapons
721 if(g_cts && item.itemdef.instanceOfWeaponPickup)
723 W_SwitchWeapon_Force(player, Weapons_from(item.weapon));
728 if (PS(player).m_switchweapon != w_getbestweapon(player))
729 W_SwitchWeapon_Force(player, w_getbestweapon(player));
738 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
739 if (this.classname == "droppedweapon")
741 if (ITEM_TOUCH_NEEDKILL())
748 if(!(other.flags & FL_PICKUPITEMS)
751 || (this.solid != SOLID_TRIGGER)
752 || (this.owner == other)
753 || (time < this.item_spawnshieldtime)
756 switch (MUTATOR_CALLHOOK(ItemTouch, this, other))
758 case MUT_ITEMTOUCH_RETURN: { return; }
759 case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
762 if (this.classname == "droppedweapon")
764 this.strength_finished = max(0, this.strength_finished - time);
765 this.invincible_finished = max(0, this.invincible_finished - time);
766 this.superweapons_finished = max(0, this.superweapons_finished - time);
768 entity it = this.itemdef;
769 bool gave = ITEM_HANDLE(Pickup, it, this, other);
772 if (this.classname == "droppedweapon")
774 // undo what we did above
775 this.strength_finished += time;
776 this.invincible_finished += time;
777 this.superweapons_finished += time;
784 other.last_pickup = time;
786 Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
787 _sound (other, CH_TRIGGER, (this.item_pickupsound ? this.item_pickupsound : Sound_fixpath(this.item_pickupsound_ent)), VOL_BASE, ATTEN_NORM);
789 if (this.classname == "droppedweapon")
791 else if (this.spawnshieldtime)
796 RandomSelection_Init();
797 for(entity head = world; (head = findfloat(head, team, this.team)); )
799 if(head.flags & FL_ITEM)
800 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
803 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
806 e = RandomSelection_chosen_ent;
811 Item_ScheduleRespawn(e);
815 void Item_Reset(entity this)
817 Item_Show(this, !this.state);
818 setorigin(this, this.origin);
820 if (this.classname != "droppedweapon")
822 this.think = Item_Think;
823 this.nextthink = time;
825 if (this.waypointsprite_attached)
826 WaypointSprite_Kill(this.waypointsprite_attached);
828 if (this.itemdef.instanceOfPowerup || (this.weapons & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
829 Item_ScheduleInitialRespawn(this);
832 void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
838 if(self.effects & EF_NODRAW)
840 // marker for item team search
841 LOG_TRACE("Initializing item team ", ftos(self.team), "\n");
842 RandomSelection_Init();
843 for(head = world; (head = findfloat(head, team, self.team)); )
844 if(head.flags & FL_ITEM)
845 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
846 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
847 e = RandomSelection_chosen_ent;
851 for(head = world; (head = findfloat(head, team, self.team)); )
852 if(head.flags & FL_ITEM)
853 if(head.classname != "item_flag_team" && head.classname != "item_key_team")
857 // make it a non-spawned item
859 head.state = 1; // state 1 = initially hidden item
861 head.effects &= ~EF_NODRAW;
868 // Savage: used for item garbage-collection
869 // TODO: perhaps nice special effect?
872 if(wasfreed(self) || !self) { return; }
873 Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
877 // pickup evaluation functions
878 // these functions decide how desirable an item is to the bots
880 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;}
882 float weapon_pickupevalfunc(entity player, entity item)
886 // See if I have it already
887 if(item.weapons & ~player.weapons)
889 // If I can pick it up
890 if(!item.spawnshieldtime)
892 else if(player.ammo_cells || player.ammo_shells || player.ammo_plasma || player.ammo_nails || player.ammo_rockets)
894 // Skilled bots will grab more
895 c = bound(0, skill / 10, 1) * 0.5;
903 // If custom weapon priorities for bots is enabled rate most wanted weapons higher
904 if( bot_custom_weapon && c )
906 // Find the highest position on any range
908 for (int j = 0; j < WEP_LAST ; ++j){
910 bot_weapons_far[j] == item.weapon ||
911 bot_weapons_mid[j] == item.weapon ||
912 bot_weapons_close[j] == item.weapon
923 position = WEP_LAST - position;
924 // item.bot_pickupbasevalue is overwritten here
925 return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
929 return item.bot_pickupbasevalue * c;
932 float commodity_pickupevalfunc(entity player, entity item)
935 float need_shells = false, need_nails = false, need_rockets = false, need_cells = false, need_plasma = false, need_fuel = false;
939 // Detect needed ammo
940 for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
942 wi = Weapons_from(i);
944 if (!(player.weapons & (wi.m_wepset)))
947 if(wi.items & ITEM_Shells.m_itemid)
949 else if(wi.items & ITEM_Bullets.m_itemid)
951 else if(wi.items & ITEM_Rockets.m_itemid)
953 else if(wi.items & ITEM_Cells.m_itemid)
955 else if(wi.items & ITEM_Plasma.m_itemid)
957 else if(wi.items & ITEM_JetpackFuel.m_itemid)
961 // TODO: figure out if the player even has the weapon this ammo is for?
962 // may not affect strategy much though...
963 // find out how much more ammo/armor/health the player can hold
965 if (item.ammo_shells)
966 if (player.ammo_shells < g_pickup_shells_max)
967 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
970 if (player.ammo_nails < g_pickup_nails_max)
971 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
973 if (item.ammo_rockets)
974 if (player.ammo_rockets < g_pickup_rockets_max)
975 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
978 if (player.ammo_cells < g_pickup_cells_max)
979 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
981 if (item.ammo_plasma)
982 if (player.ammo_plasma < g_pickup_plasma_max)
983 c = c + max(0, 1 - player.ammo_plasma / g_pickup_plasma_max);
986 if (player.ammo_fuel < g_pickup_fuel_max)
987 c = c + max(0, 1 - player.ammo_fuel / g_pickup_fuel_max);
989 if (player.armorvalue < item.max_armorvalue)
990 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
992 if (player.health < item.max_health)
993 c = c + max(0, 1 - player.health / item.max_health);
995 return item.bot_pickupbasevalue * c;
998 void Item_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
1000 if(ITEM_DAMAGE_NEEDKILL(deathtype))
1004 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter)
1006 string itemname = def.m_name;
1007 Model itemmodel = def.m_model;
1008 Sound pickupsound = def.m_sound;
1009 float(entity player, entity item) pickupevalfunc = def.m_pickupevalfunc;
1010 float pickupbasevalue = def.m_botvalue;
1011 int itemflags = def.m_itemflags;
1013 startitem_failed = false;
1015 this.item_model_ent = itemmodel;
1016 this.item_pickupsound_ent = pickupsound;
1018 if(!this.respawntime) // both need to be set
1020 this.respawntime = defaultrespawntime;
1021 this.respawntimejitter = defaultrespawntimejitter;
1024 int itemid = def.m_itemid;
1025 this.items = itemid;
1026 int weaponid = def.instanceOfWeaponPickup ? def.m_weapon.m_id : 0;
1027 this.weapon = weaponid;
1031 this.fade_start = autocvar_g_items_mindist;
1032 this.fade_end = autocvar_g_items_maxdist;
1036 this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
1038 this.flags = FL_ITEM | itemflags;
1040 if(MUTATOR_CALLHOOK(FilterItem, this)) // error means we do not want the item
1042 startitem_failed = true;
1047 // is it a dropped weapon?
1048 if (this.classname == "droppedweapon")
1050 this.reset = SUB_Remove;
1051 // it's a dropped weapon
1052 this.movetype = MOVETYPE_TOSS;
1054 // Savage: remove thrown items after a certain period of time ("garbage collection")
1055 this.think = RemoveItem;
1056 this.nextthink = time + 20;
1058 this.takedamage = DAMAGE_YES;
1059 this.event_damage = Item_Damage;
1061 if(this.strength_finished || this.invincible_finished || this.superweapons_finished)
1063 // if item is worthless after a timer, have it expire then
1064 this.nextthink = max(this.strength_finished, this.invincible_finished, this.superweapons_finished);
1067 // don't drop if in a NODROP zone (such as lava)
1068 traceline(this.origin, this.origin, MOVE_NORMAL, this);
1069 if (trace_dpstartcontents & DPCONTENTS_NODROP)
1071 startitem_failed = true;
1078 if(!have_pickup_item(this))
1080 startitem_failed = true;
1085 if(this.angles != '0 0 0')
1086 this.SendFlags |= ISF_ANGLES;
1088 this.reset = Item_Reset;
1089 // it's a level item
1090 if(this.spawnflags & 1)
1092 if (this.noalign > 0)
1093 this.movetype = MOVETYPE_NONE;
1095 this.movetype = MOVETYPE_TOSS;
1096 // do item filtering according to game mode and other things
1097 if (this.noalign <= 0)
1099 // first nudge it off the floor a little bit to avoid math errors
1100 setorigin(this, this.origin + '0 0 1');
1101 // set item size before we spawn a spawnfunc_waypoint
1102 setsize(this, def.m_mins, def.m_maxs);
1103 this.SendFlags |= ISF_SIZE;
1104 // note droptofloor returns false if stuck/or would fall too far
1106 WITH(entity, self, this, droptofloor());
1107 waypoint_spawnforitem(this);
1111 * can't do it that way, as it would break maps
1112 * TODO make a target_give like entity another way, that perhaps has
1113 * the weapon name in a key
1116 // target_give not yet supported; maybe later
1117 print("removed targeted ", this.classname, "\n");
1118 startitem_failed = true;
1124 if(autocvar_spawn_debug >= 2)
1126 for(entity otheritem = findradius(this.origin, 3); otheritem; otheritem = otheritem.chain)
1128 // why not flags & fl_item?
1129 if(otheritem.is_item)
1131 LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(this.origin));
1132 LOG_TRACE(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
1133 error("Mapper sucks.");
1136 this.is_item = true;
1139 weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
1141 precache_model(this.model);
1142 precache_sound(this.item_pickupsound);
1144 if ( def.instanceOfPowerup
1145 || def.instanceOfWeaponPickup
1146 || (def.instanceOfHealth && def != ITEM_HealthSmall)
1147 || (def.instanceOfArmor && def != ITEM_ArmorSmall)
1148 || (itemid & (IT_KEY1 | IT_KEY2))
1149 ) this.target = "###item###"; // for finding the nearest item using find()
1151 Item_ItemsTime_SetTime(this, 0);
1154 this.bot_pickup = true;
1155 this.bot_pickupevalfunc = pickupevalfunc;
1156 this.bot_pickupbasevalue = pickupbasevalue;
1157 this.mdl = this.model ? this.model : strzone(this.item_model_ent.model_str());
1158 this.netname = itemname;
1159 this.touch = Item_Touch;
1160 setmodel(this, MDL_Null); // precision set below
1161 //this.effects |= EF_LOWPRECISION;
1163 setsize (this, this.pos1 = def.m_mins, this.pos2 = def.m_maxs);
1165 this.SendFlags |= ISF_SIZE;
1167 if (!(this.spawnflags & 1024)) {
1168 if(def.instanceOfPowerup)
1169 this.ItemStatus |= ITS_ANIMATE1;
1171 if(this.armorvalue || this.health)
1172 this.ItemStatus |= ITS_ANIMATE2;
1175 if(def.instanceOfWeaponPickup)
1177 if (this.classname != "droppedweapon") // if dropped, colormap is already set up nicely
1178 this.colormap = 1024; // color shirt=0 pants=0 grey
1181 if (!(this.spawnflags & 1024))
1182 this.ItemStatus |= ITS_ANIMATE1;
1183 this.ItemStatus |= ISF_COLORMAP;
1187 if(this.team) // broken, no idea why.
1190 this.cnt = 1; // item probability weight
1192 this.effects |= EF_NODRAW; // marker for item team search
1193 InitializeEntity(this, Item_FindTeam, INITPRIO_FINDTARGET);
1198 Net_LinkEntity(this, !(def.instanceOfPowerup || def.instanceOfHealth || def.instanceOfArmor), 0, ItemSend);
1200 // call this hook after everything else has been done
1201 if (MUTATOR_CALLHOOK(Item_Spawn, this))
1203 startitem_failed = true;
1209 void StartItem(entity this, GameItem def)
1214 def.m_respawntime(), // defaultrespawntime
1215 def.m_respawntimejitter() // defaultrespawntimejitter
1219 spawnfunc(item_rockets)
1221 if(!this.ammo_rockets)
1222 this.ammo_rockets = g_pickup_rockets;
1223 if(!this.pickup_anyway)
1224 this.pickup_anyway = g_pickup_ammo_anyway;
1225 StartItem(this, ITEM_Rockets);
1228 spawnfunc(item_bullets)
1231 if(autocvar_sv_q3acompat_machineshotgunswap)
1232 if(this.classname != "droppedweapon")
1234 weaponswapping = true;
1235 spawnfunc_item_shells(this);
1236 weaponswapping = false;
1240 if(!this.ammo_nails)
1241 this.ammo_nails = g_pickup_nails;
1242 if(!this.pickup_anyway)
1243 this.pickup_anyway = g_pickup_ammo_anyway;
1244 StartItem(this, ITEM_Bullets);
1247 spawnfunc(item_cells)
1249 if(!this.ammo_cells)
1250 this.ammo_cells = g_pickup_cells;
1251 if(!this.pickup_anyway)
1252 this.pickup_anyway = g_pickup_ammo_anyway;
1253 StartItem(this, ITEM_Cells);
1256 spawnfunc(item_plasma)
1258 if(!this.ammo_plasma)
1259 this.ammo_plasma = g_pickup_plasma;
1260 if(!this.pickup_anyway)
1261 this.pickup_anyway = g_pickup_ammo_anyway;
1262 StartItem(this, ITEM_Plasma);
1265 spawnfunc(item_shells)
1268 if(autocvar_sv_q3acompat_machineshotgunswap)
1269 if(this.classname != "droppedweapon")
1271 weaponswapping = true;
1272 spawnfunc_item_bullets(this);
1273 weaponswapping = false;
1277 if(!this.ammo_shells)
1278 this.ammo_shells = g_pickup_shells;
1279 if(!this.pickup_anyway)
1280 this.pickup_anyway = g_pickup_ammo_anyway;
1281 StartItem(this, ITEM_Shells);
1284 spawnfunc(item_armor_small)
1286 if(!this.armorvalue)
1287 this.armorvalue = g_pickup_armorsmall;
1288 if(!this.max_armorvalue)
1289 this.max_armorvalue = g_pickup_armorsmall_max;
1290 if(!this.pickup_anyway)
1291 this.pickup_anyway = g_pickup_armorsmall_anyway;
1292 StartItem(this, ITEM_ArmorSmall);
1295 spawnfunc(item_armor_medium)
1297 if(!this.armorvalue)
1298 this.armorvalue = g_pickup_armormedium;
1299 if(!this.max_armorvalue)
1300 this.max_armorvalue = g_pickup_armormedium_max;
1301 if(!this.pickup_anyway)
1302 this.pickup_anyway = g_pickup_armormedium_anyway;
1303 StartItem(this, ITEM_ArmorMedium);
1306 spawnfunc(item_armor_big)
1308 if(!this.armorvalue)
1309 this.armorvalue = g_pickup_armorbig;
1310 if(!this.max_armorvalue)
1311 this.max_armorvalue = g_pickup_armorbig_max;
1312 if(!this.pickup_anyway)
1313 this.pickup_anyway = g_pickup_armorbig_anyway;
1314 StartItem(this, ITEM_ArmorLarge);
1317 spawnfunc(item_armor_large)
1319 if(!this.armorvalue)
1320 this.armorvalue = g_pickup_armorlarge;
1321 if(!this.max_armorvalue)
1322 this.max_armorvalue = g_pickup_armorlarge_max;
1323 if(!this.pickup_anyway)
1324 this.pickup_anyway = g_pickup_armorlarge_anyway;
1325 StartItem(this, ITEM_ArmorMega);
1328 spawnfunc(item_health_small)
1330 if(!this.max_health)
1331 this.max_health = g_pickup_healthsmall_max;
1333 this.health = g_pickup_healthsmall;
1334 if(!this.pickup_anyway)
1335 this.pickup_anyway = g_pickup_healthsmall_anyway;
1336 StartItem(this, ITEM_HealthSmall);
1339 spawnfunc(item_health_medium)
1341 if(!this.max_health)
1342 this.max_health = g_pickup_healthmedium_max;
1344 this.health = g_pickup_healthmedium;
1345 if(!this.pickup_anyway)
1346 this.pickup_anyway = g_pickup_healthmedium_anyway;
1347 StartItem(this, ITEM_HealthMedium);
1350 spawnfunc(item_health_large)
1352 if(!this.max_health)
1353 this.max_health = g_pickup_healthlarge_max;
1355 this.health = g_pickup_healthlarge;
1356 if(!this.pickup_anyway)
1357 this.pickup_anyway = g_pickup_healthlarge_anyway;
1358 StartItem(this, ITEM_HealthLarge);
1361 spawnfunc(item_health_mega)
1363 if(!this.max_health)
1364 this.max_health = g_pickup_healthmega_max;
1366 this.health = g_pickup_healthmega;
1367 if(!this.pickup_anyway)
1368 this.pickup_anyway = g_pickup_healthmega_anyway;
1369 StartItem(this, ITEM_HealthMega);
1372 // support old misnamed entities
1373 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
1374 spawnfunc(item_armor25) { spawnfunc_item_armor_large(this); }
1375 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
1376 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
1377 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
1379 spawnfunc(item_strength)
1381 if(!this.strength_finished)
1382 this.strength_finished = autocvar_g_balance_powerup_strength_time;
1383 StartItem(this, ITEM_Strength);
1386 spawnfunc(item_invincible)
1388 if(!this.invincible_finished)
1389 this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1390 StartItem(this, ITEM_Shield);
1394 spawnfunc(item_quad) { this.classname = "item_strength";spawnfunc_item_strength(this);}
1396 void target_items_use()
1398 if(activator.classname == "droppedweapon")
1405 if (!IS_PLAYER(activator))
1407 if(activator.deadflag != DEAD_NO)
1412 for(e = world; (e = find(e, classname, "droppedweapon")); )
1413 if(e.enemy == activator)
1416 if(GiveItems(activator, 0, tokenize_console(self.netname)))
1417 centerprint(activator, self.message);
1420 spawnfunc(target_items)
1426 self.use = target_items_use;
1427 if(!self.strength_finished)
1428 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1429 if(!self.invincible_finished)
1430 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1431 if(!self.superweapons_finished)
1432 self.superweapons_finished = autocvar_g_balance_superweapons_time;
1434 n = tokenize_console(self.netname);
1435 if(argv(0) == "give")
1437 self.netname = substring(self.netname, argv_start_index(1), argv_end_index(-1) - argv_start_index(1));
1441 for(i = 0; i < n; ++i)
1443 if (argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1444 else if(argv(i) == "unlimited_weapon_ammo") self.items |= IT_UNLIMITED_WEAPON_AMMO;
1445 else if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
1446 else if(argv(i) == "strength") self.items |= ITEM_Strength.m_itemid;
1447 else if(argv(i) == "invincible") self.items |= ITEM_Shield.m_itemid;
1448 else if(argv(i) == "superweapons") self.items |= IT_SUPERWEAPON;
1449 else if(argv(i) == "jetpack") self.items |= ITEM_Jetpack.m_itemid;
1450 else if(argv(i) == "fuel_regen") self.items |= ITEM_JetpackRegen.m_itemid;
1453 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1455 e = Weapons_from(j);
1456 s = W_UndeprecateName(argv(i));
1459 self.weapons |= (e.m_wepset);
1460 if(self.spawnflags == 0 || self.spawnflags == 2) {
1467 LOG_INFO("target_items: invalid item ", argv(i), "\n");
1471 string itemprefix, valueprefix;
1472 if(self.spawnflags == 0)
1477 else if(self.spawnflags == 1)
1479 itemprefix = "max ";
1480 valueprefix = "max ";
1482 else if(self.spawnflags == 2)
1484 itemprefix = "min ";
1485 valueprefix = "min ";
1487 else if(self.spawnflags == 4)
1489 itemprefix = "minus ";
1490 valueprefix = "max ";
1494 error("invalid spawnflags");
1495 itemprefix = valueprefix = string_null;
1499 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
1500 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
1501 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * boolean(self.items & ITEM_Strength.m_itemid), "strength");
1502 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * boolean(self.items & ITEM_Shield.m_itemid), "invincible");
1503 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * boolean(self.items & IT_SUPERWEAPON), "superweapons");
1504 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_Jetpack.m_itemid), "jetpack");
1505 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, boolean(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
1506 if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
1507 if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
1508 if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
1509 if(self.ammo_cells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_cells), "cells");
1510 if(self.ammo_plasma != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_plasma), "plasma");
1511 if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
1512 if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
1513 if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
1514 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1516 e = Weapons_from(j);
1517 if(e == WEP_Null) continue;
1518 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (e.m_wepset)), e.netname);
1521 self.netname = strzone(self.netname);
1522 //print(self.netname, "\n");
1524 n = tokenize_console(self.netname);
1525 for(i = 0; i < n; ++i)
1527 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1529 e = Weapons_from(j);
1530 if(argv(i) == e.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, j, val, op;
1627 float _switchweapon;
1636 _switchweapon = false;
1638 if (PS(e).m_switchweapon == w_getbestweapon(e))
1639 _switchweapon = true;
1641 e.strength_finished = max(0, e.strength_finished - time);
1642 e.invincible_finished = max(0, e.invincible_finished - time);
1643 e.superweapons_finished = max(0, e.superweapons_finished - time);
1647 PREGIVE(e, strength_finished);
1648 PREGIVE(e, invincible_finished);
1649 PREGIVE(e, superweapons_finished);
1650 PREGIVE(e, ammo_nails);
1651 PREGIVE(e, ammo_cells);
1652 PREGIVE(e, ammo_plasma);
1653 PREGIVE(e, ammo_shells);
1654 PREGIVE(e, ammo_rockets);
1655 PREGIVE(e, ammo_fuel);
1656 PREGIVE(e, armorvalue);
1659 for(i = beginarg; i < endarg; ++i)
1663 if(cmd == "0" || stof(cmd))
1687 got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
1688 got += GiveValue(e, strength_finished, op, val);
1689 got += GiveValue(e, invincible_finished, op, val);
1690 got += GiveValue(e, superweapons_finished, op, val);
1691 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1693 got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
1694 got += GiveValue(e, health, op, val);
1695 got += GiveValue(e, armorvalue, op, val);
1697 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1699 wi = Weapons_from(j);
1700 if(wi == WEP_Null) continue;
1701 if (!(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED))
1702 got += GiveWeapon(e, j, op, val);
1705 got += GiveValue(e, ammo_cells, op, val);
1706 got += GiveValue(e, ammo_plasma, op, val);
1707 got += GiveValue(e, ammo_shells, op, val);
1708 got += GiveValue(e, ammo_nails, op, val);
1709 got += GiveValue(e, ammo_rockets, op, val);
1710 got += GiveValue(e, ammo_fuel, op, val);
1712 case "unlimited_ammo":
1713 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1715 case "unlimited_weapon_ammo":
1716 got += GiveBit(e, items, IT_UNLIMITED_WEAPON_AMMO, op, val);
1718 case "unlimited_superweapons":
1719 got += GiveBit(e, items, IT_UNLIMITED_SUPERWEAPONS, op, val);
1722 got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
1725 got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
1728 got += GiveValue(e, strength_finished, op, val);
1731 got += GiveValue(e, invincible_finished, op, val);
1733 case "superweapons":
1734 got += GiveValue(e, superweapons_finished, op, val);
1737 got += GiveValue(e, ammo_cells, op, val);
1740 got += GiveValue(e, ammo_plasma, op, val);
1743 got += GiveValue(e, ammo_shells, op, val);
1747 got += GiveValue(e, ammo_nails, op, val);
1750 got += GiveValue(e, ammo_rockets, op, val);
1753 got += GiveValue(e, health, op, val);
1756 got += GiveValue(e, armorvalue, op, val);
1759 got += GiveValue(e, ammo_fuel, op, val);
1762 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1764 wi = Weapons_from(j);
1765 if(cmd == wi.netname)
1767 got += GiveWeapon(e, j, op, val);
1772 LOG_INFO("give: invalid item ", cmd, "\n");
1779 POSTGIVE_BIT(e, items, ITEM_JetpackRegen.m_itemid, SND(ITEMPICKUP), string_null);
1780 POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, SND(POWERUP), SND(POWEROFF));
1781 POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, SND(POWERUP), SND(POWEROFF));
1782 POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, SND(ITEMPICKUP), string_null);
1783 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1785 wi = Weapons_from(j);
1786 if (wi == WEP_Null) continue;
1787 POSTGIVE_WEAPON(e, Weapons_from(j), SND(WEAPONPICKUP), string_null);
1788 if (!(save_weapons & (wi.m_wepset)))
1789 if(e.weapons & (wi.m_wepset)) {
1793 POSTGIVE_VALUE(e, strength_finished, 1, SND(POWERUP), SND(POWEROFF));
1794 POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", SND(POWEROFF));
1795 POSTGIVE_VALUE(e, ammo_nails, 0, SND(ITEMPICKUP), string_null);
1796 POSTGIVE_VALUE(e, ammo_cells, 0, SND(ITEMPICKUP), string_null);
1797 POSTGIVE_VALUE(e, ammo_plasma, 0, SND(ITEMPICKUP), string_null);
1798 POSTGIVE_VALUE(e, ammo_shells, 0, SND(ITEMPICKUP), string_null);
1799 POSTGIVE_VALUE(e, ammo_rockets, 0, SND(ITEMPICKUP), string_null);
1800 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);
1801 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);
1802 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);
1804 if(e.superweapons_finished <= 0)
1805 if(self.weapons & WEPSET_SUPERWEAPONS)
1806 e.superweapons_finished = autocvar_g_balance_superweapons_time;
1808 if(e.strength_finished <= 0)
1809 e.strength_finished = 0;
1811 e.strength_finished += time;
1812 if(e.invincible_finished <= 0)
1813 e.invincible_finished = 0;
1815 e.invincible_finished += time;
1816 if(e.superweapons_finished <= 0)
1817 e.superweapons_finished = 0;
1819 e.superweapons_finished += time;
1821 if (!(e.weapons & WepSet_FromWeapon(PS(e).m_switchweapon)))
1822 _switchweapon = true;
1824 W_SwitchWeapon_Force(e, w_getbestweapon(e));