6 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
7 if(self.move_flags & FL_ONGROUND)
8 { // For some reason move_avelocity gets set to '0 0 0' here ...
9 self.oldorigin = self.origin;
12 if(autocvar_cl_animate_items)
13 { // ... so reset it if animations are requested.
14 if(self.ItemStatus & ITS_ANIMATE1)
15 self.move_avelocity = '0 180 0';
17 if(self.ItemStatus & ITS_ANIMATE2)
18 self.move_avelocity = '0 -90 0';
22 else if (autocvar_cl_animate_items)
24 if(self.ItemStatus & ITS_ANIMATE1)
26 self.angles += self.move_avelocity * frametime;
27 setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2));
30 if(self.ItemStatus & ITS_ANIMATE2)
32 self.angles += self.move_avelocity * frametime;
33 setorigin(self, '0 0 8' + self.oldorigin + '0 0 4' * sin(time * 3));
42 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
44 if(self.move_flags & FL_ONGROUND)
49 void ItemRead(float _IsNew)
51 float sf = ReadByte();
55 self.origin_x = ReadCoord();
56 self.origin_y = ReadCoord();
57 self.origin_z = ReadCoord();
58 setorigin(self, self.origin);
59 self.oldorigin = self.origin;
64 self.angles_x = ReadCoord();
65 self.angles_y = ReadCoord();
66 self.angles_z = ReadCoord();
67 self.move_angles = self.angles;
72 self.mins_x = ReadCoord();
73 self.mins_y = ReadCoord();
74 self.mins_z = ReadCoord();
75 self.maxs_x = ReadCoord();
76 self.maxs_y = ReadCoord();
77 self.maxs_z = ReadCoord();
78 setsize(self, self.mins, self.maxs);
81 if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
83 self.ItemStatus = ReadByte();
85 if(self.ItemStatus & ITS_AVAILABLE)
88 self.colormod = self.glowmod = '1 1 1';
92 if (autocvar_cl_ghost_items_color)
94 self.alpha = autocvar_cl_ghost_items;
95 self.colormod = self.glowmod = autocvar_cl_ghost_items_color;
101 if(autocvar_cl_fullbright_items)
102 if(self.ItemStatus & ITS_ALLOWFB)
103 self.effects |= EF_FULLBRIGHT;
105 if(self.ItemStatus & ITS_STAYWEP)
107 self.colormod = self.glowmod = autocvar_cl_weapon_stay_color;
108 self.alpha = autocvar_cl_weapon_stay_alpha;
112 if(self.ItemStatus & ITS_POWERUP)
114 if(self.ItemStatus & ITS_AVAILABLE)
115 self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
117 self.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
123 self.drawmask = MASK_NORMAL;
124 self.movetype = MOVETYPE_TOSS;
125 self.draw = ItemDraw;
131 string _fn = ReadString();
133 if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
135 string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
136 self.draw = ItemDrawSimple;
140 if(fexists(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix)))
141 self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
142 else if(fexists(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix)))
143 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
144 else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
145 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
146 else if(fexists(sprintf("%s%s.obj", _fn2, autocvar_cl_simpleitems_postfix)))
147 self.mdl = strzone(sprintf("%s%s.obj", _fn2, autocvar_cl_simpleitems_postfix));
150 self.draw = ItemDraw;
151 dprint("Simple item requested for ", _fn, " but no model exsist for it\n");
155 if(self.draw != ItemDrawSimple)
156 self.mdl = strzone(_fn);
160 dprint("^1WARNING!^7 self.mdl is unset for item ", self.classname, " tell tZork aboute this!\n");
162 precache_model(self.mdl);
163 setmodel(self, self.mdl);
166 if(sf & ISF_COLORMAP)
167 self.colormap = ReadShort();
172 //self.move_angles = '0 0 0';
173 self.move_movetype = MOVETYPE_TOSS;
174 self.move_velocity_x = ReadCoord();
175 self.move_velocity_y = ReadCoord();
176 self.move_velocity_z = ReadCoord();
177 self.velocity = self.move_velocity;
178 self.move_origin = self.oldorigin;
182 self.move_time = time;
183 self.spawntime = time;
186 self.move_time = max(self.move_time, time);
189 if(autocvar_cl_animate_items)
191 if(self.ItemStatus & ITS_ANIMATE1)
192 self.move_avelocity = '0 180 0';
194 if(self.ItemStatus & ITS_ANIMATE2)
195 self.move_avelocity = '0 -90 0';
202 float ItemSend(entity to, float sf)
209 WriteByte(MSG_ENTITY, ENT_CLIENT_ITEM);
210 WriteByte(MSG_ENTITY, sf);
212 //WriteByte(MSG_ENTITY, self.cnt);
213 if(sf & ISF_LOCATION)
215 WriteCoord(MSG_ENTITY, self.origin_x);
216 WriteCoord(MSG_ENTITY, self.origin_y);
217 WriteCoord(MSG_ENTITY, self.origin_z);
222 WriteCoord(MSG_ENTITY, self.angles_x);
223 WriteCoord(MSG_ENTITY, self.angles_y);
224 WriteCoord(MSG_ENTITY, self.angles_z);
229 WriteCoord(MSG_ENTITY, self.mins_x);
230 WriteCoord(MSG_ENTITY, self.mins_y);
231 WriteCoord(MSG_ENTITY, self.mins_z);
232 WriteCoord(MSG_ENTITY, self.maxs_x);
233 WriteCoord(MSG_ENTITY, self.maxs_y);
234 WriteCoord(MSG_ENTITY, self.maxs_z);
238 WriteByte(MSG_ENTITY, self.ItemStatus);
244 dprint("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
246 WriteString(MSG_ENTITY, self.mdl);
250 if(sf & ISF_COLORMAP)
251 WriteShort(MSG_ENTITY, self.colormap);
255 WriteCoord(MSG_ENTITY, self.velocity_x);
256 WriteCoord(MSG_ENTITY, self.velocity_y);
257 WriteCoord(MSG_ENTITY, self.velocity_z);
263 void ItemUpdate(entity item)
265 item.SendFlags |= ISF_LOCATION;
268 float have_pickup_item(void)
270 if(self.flags & FL_POWERUP)
272 if(autocvar_g_powerups > 0)
274 if(autocvar_g_powerups == 0)
279 if(autocvar_g_pickup_items > 0)
281 if(autocvar_g_pickup_items == 0)
284 if(self.weapons || (self.items & IT_AMMO)) // no item or ammo pickups in weaponarena
291 float Item_Customize()
293 if(self.spawnshieldtime)
295 if(self.weapons & ~other.weapons)
297 self.colormod = '0 0 0';
298 self.glowmod = self.colormod;
299 self.alpha = 0.5 + 0.5 * g_ghost_items; // halfway more alpha
306 self.colormod = stov(autocvar_g_ghost_items_color);
307 self.glowmod = self.colormod;
308 self.alpha = g_ghost_items;
317 void Item_Show (entity e, float mode)
319 e.effects &= ~(EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST);
320 e.ItemStatus &= ~ITS_STAYWEP;
323 // make the item look normal, and be touchable
325 e.solid = SOLID_TRIGGER;
326 e.spawnshieldtime = 1;
327 e.ItemStatus |= ITS_AVAILABLE;
331 // hide the item completely
332 e.model = string_null;
334 e.spawnshieldtime = 1;
335 e.ItemStatus &= ~ITS_AVAILABLE;
337 else if((e.flags & FL_WEAPON) && !(e.flags & FL_NO_WEAPON_STAY) && g_weapon_stay)
339 // make the item translucent and not touchable
341 e.solid = SOLID_TRIGGER; // can STILL be picked up!
342 e.effects |= EF_STARDUST;
343 e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
344 e.ItemStatus |= (ITS_AVAILABLE | ITS_STAYWEP);
348 //setmodel(e, "null");
350 e.colormod = '0 0 0';
351 e.glowmod = e.colormod;
352 e.spawnshieldtime = 1;
353 e.ItemStatus &= ~ITS_AVAILABLE;
356 if (e.items & IT_STRENGTH || e.items & IT_INVINCIBLE)
357 e.ItemStatus |= ITS_POWERUP;
359 if (autocvar_g_nodepthtestitems)
360 e.effects |= EF_NODEPTHTEST;
363 if (autocvar_g_fullbrightitems)
364 e.ItemStatus |= ITS_ALLOWFB;
366 if (autocvar_sv_simple_items)
367 e.ItemStatus |= ITS_ALLOWSI;
369 // relink entity (because solid may have changed)
370 setorigin(e, e.origin);
371 e.SendFlags |= ISF_STATUS;
376 self.nextthink = time;
377 if(self.origin != self.oldorigin)
379 self.oldorigin = self.origin;
384 void Item_Respawn (void)
388 if(self.items == IT_STRENGTH)
389 sound (self, CH_TRIGGER, "misc/strength_respawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound
390 else if(self.items == IT_INVINCIBLE)
391 sound (self, CH_TRIGGER, "misc/shield_respawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound
393 sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound
394 setorigin (self, self.origin);
396 self.think = Item_Think;
397 self.nextthink = time;
399 //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
400 pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);
403 void Item_RespawnCountdown (void)
405 if(self.count >= ITEM_RESPAWN_TICKS)
407 if(self.waypointsprite_attached)
408 WaypointSprite_Kill(self.waypointsprite_attached);
413 self.nextthink = time + 1;
418 vector rgb = '1 0 1';
422 case IT_FUEL_REGEN: name = "item-fuelregen"; rgb = '1 0.5 0'; break;
423 case IT_JETPACK: name = "item-jetpack"; rgb = '0.5 0.5 0.5'; break;
424 case IT_STRENGTH: name = "item-strength"; rgb = '0 0 1'; break;
425 case IT_INVINCIBLE: name = "item-shield"; rgb = '1 0 1'; break;
429 MUTATOR_CALLHOOK(Item_RespawnCountdown);
432 if(self.flags & FL_WEAPON)
434 entity wi = get_weaponinfo(self.weapon);
443 WaypointSprite_Spawn(name, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
444 if(self.waypointsprite_attached)
445 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
449 print("Unknown powerup-marked item is wanting to respawn\n");
450 localcmd(sprintf("prvm_edict server %d\n", num_for_edict(self)));
453 sound (self, CH_TRIGGER, "misc/itemrespawncountdown.wav", VOL_BASE, ATTEN_NORM); // play respawn sound
454 if(self.waypointsprite_attached)
456 WaypointSprite_Ping(self.waypointsprite_attached);
457 //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
462 void Item_RespawnThink()
464 self.nextthink = time;
465 if(self.origin != self.oldorigin)
467 self.oldorigin = self.origin;
471 if(time >= self.wait)
475 void Item_ScheduleRespawnIn(entity e, float t)
477 if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS))
479 e.think = Item_RespawnCountdown;
480 e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
485 e.think = Item_RespawnThink;
491 void Item_ScheduleRespawn(entity e)
493 if(e.respawntime > 0)
496 Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e));
498 else // if respawntime is -1, this item does not respawn
502 void Item_ScheduleInitialRespawn(entity e)
505 Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
508 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
513 if (item.spawnshieldtime)
515 if ((player.ammotype < ammomax) || item.pickup_anyway)
517 player.ammotype = bound(player.ammotype, ammomax, player.ammotype + item.ammotype);
521 else if(g_weapon_stay == 2)
523 float mi = min(item.ammotype, ammomax);
524 if (player.ammotype < mi)
526 player.ammotype = mi;
537 player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
539 case ITEM_MODE_HEALTH:
540 player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
542 case ITEM_MODE_ARMOR:
543 player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
551 float Item_GiveTo(entity item, entity player)
558 // if nothing happens to player, just return without taking the item
560 _switchweapon = FALSE;
561 // in case the player has autoswitch enabled do the following:
562 // if the player is using their best weapon before items are given, they
563 // probably want to switch to an even better weapon after items are given
564 if (player.autoswitch)
565 if (player.switchweapon == w_getbestweapon(player))
566 _switchweapon = TRUE;
568 if (!(player.weapons & WepSet_FromWeapon(player.switchweapon)))
569 _switchweapon = TRUE;
571 pickedup |= Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max, ITEM_MODE_FUEL);
572 pickedup |= Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max, ITEM_MODE_NONE);
573 pickedup |= Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max, ITEM_MODE_NONE);
574 pickedup |= Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max, ITEM_MODE_NONE);
575 pickedup |= Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max, ITEM_MODE_NONE);
576 pickedup |= Item_GiveAmmoTo(item, player, ammo_plasma, g_pickup_plasma_max, ITEM_MODE_NONE);
577 pickedup |= Item_GiveAmmoTo(item, player, health, item.max_health, ITEM_MODE_HEALTH);
578 pickedup |= Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue, ITEM_MODE_ARMOR);
580 if (item.flags & FL_WEAPON)
584 it &= ~player.weapons;
586 if (it || (item.spawnshieldtime && item.pickup_anyway))
589 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
590 if(it & WepSet_FromWeapon(i))
592 W_DropEvent(WR_PICKUP, player, i, item);
593 W_GiveWeapon(player, i);
598 if((it = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
602 sprint (player, strcat("You got the ^2", item.netname, "\n"));
605 if (item.strength_finished)
608 player.strength_finished = max(player.strength_finished, time) + item.strength_finished;
610 if (item.invincible_finished)
613 player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished;
615 if (item.superweapons_finished)
618 player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished;
623 // always eat teamed entities
631 if (player.switchweapon != w_getbestweapon(player))
632 W_SwitchWeapon_Force(player, w_getbestweapon(player));
637 void Item_Touch (void)
641 // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
642 if(self.classname == "droppedweapon")
644 if (ITEM_TOUCH_NEEDKILL())
651 if (!IS_PLAYER(other))
657 if (self.solid != SOLID_TRIGGER)
659 if (self.owner == other)
661 if (time < self.item_spawnshieldtime)
664 switch(MUTATOR_CALLHOOK(ItemTouch))
666 case MUT_ITEMTOUCH_RETURN: { return; }
667 case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
670 if (self.classname == "droppedweapon")
672 self.strength_finished = max(0, self.strength_finished - time);
673 self.invincible_finished = max(0, self.invincible_finished - time);
674 self.superweapons_finished = max(0, self.superweapons_finished - time);
677 if(!Item_GiveTo(self, other))
679 if (self.classname == "droppedweapon")
681 // undo what we did above
682 self.strength_finished += time;
683 self.invincible_finished += time;
684 self.superweapons_finished += time;
691 other.last_pickup = time;
693 pointparticles(particleeffectnum("item_pickup"), self.origin, '0 0 0', 1);
694 sound (other, CH_TRIGGER, self.item_pickupsound, VOL_BASE, ATTEN_NORM);
696 if (self.classname == "droppedweapon")
698 else if (!self.spawnshieldtime)
704 RandomSelection_Init();
705 for(head = world; (head = findfloat(head, team, self.team)); )
707 if(head.flags & FL_ITEM)
710 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
713 e = RandomSelection_chosen_ent;
718 Item_ScheduleRespawn(e);
724 Item_Show(self, !self.state);
725 setorigin (self, self.origin);
727 if(self.classname != "droppedweapon")
729 self.think = Item_Think;
730 self.nextthink = time;
732 if(self.waypointsprite_attached)
733 WaypointSprite_Kill(self.waypointsprite_attached);
735 if((self.flags & FL_POWERUP) || (self.weapons & WEPSET_SUPERWEAPONS)) // do not spawn powerups initially!
736 Item_ScheduleInitialRespawn(self);
744 if(self.effects & EF_NODRAW)
746 // marker for item team search
747 dprint("Initializing item team ", ftos(self.team), "\n");
748 RandomSelection_Init();
749 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
750 RandomSelection_Add(head, 0, string_null, head.cnt, 0);
751 e = RandomSelection_chosen_ent;
755 for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
759 // make it a non-spawned item
761 head.state = 1; // state 1 = initially hidden item
763 head.effects &= ~EF_NODRAW;
770 // Savage: used for item garbage-collection
771 // TODO: perhaps nice special effect?
772 void RemoveItem(void)
777 // pickup evaluation functions
778 // these functions decide how desirable an item is to the bots
780 float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickupbasevalue;}
782 float weapon_pickupevalfunc(entity player, entity item)
784 float c, j, position;
786 // See if I have it already
787 if(item.weapons & ~player.weapons)
789 // If I can pick it up
790 if(!item.spawnshieldtime)
792 else if(player.ammo_cells || player.ammo_shells || player.ammo_plasma || player.ammo_nails || player.ammo_rockets)
794 // Skilled bots will grab more
795 c = bound(0, skill / 10, 1) * 0.5;
803 // If custom weapon priorities for bots is enabled rate most wanted weapons higher
804 if( bot_custom_weapon && c )
806 // Find the highest position on any range
808 for(j = 0; j < WEP_LAST ; ++j){
810 bot_weapons_far[j] == item.weapon ||
811 bot_weapons_mid[j] == item.weapon ||
812 bot_weapons_close[j] == item.weapon
823 position = WEP_LAST - position;
824 // item.bot_pickupbasevalue is overwritten here
825 return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
829 return item.bot_pickupbasevalue * c;
832 float commodity_pickupevalfunc(entity player, entity item)
835 float need_shells = FALSE, need_nails = FALSE, need_rockets = FALSE, need_cells = FALSE, need_plasma = FALSE, need_fuel = FALSE;
839 // Detect needed ammo
840 for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
842 wi = get_weaponinfo(i);
844 if (!(player.weapons & WepSet_FromWeapon(i)))
847 if(wi.items & IT_SHELLS)
849 else if(wi.items & IT_NAILS)
851 else if(wi.items & IT_ROCKETS)
853 else if(wi.items & IT_CELLS)
855 else if(wi.items & IT_PLASMA)
857 else if(wi.items & IT_FUEL)
861 // TODO: figure out if the player even has the weapon this ammo is for?
862 // may not affect strategy much though...
863 // find out how much more ammo/armor/health the player can hold
865 if (item.ammo_shells)
866 if (player.ammo_shells < g_pickup_shells_max)
867 c = c + max(0, 1 - player.ammo_shells / g_pickup_shells_max);
870 if (player.ammo_nails < g_pickup_nails_max)
871 c = c + max(0, 1 - player.ammo_nails / g_pickup_nails_max);
873 if (item.ammo_rockets)
874 if (player.ammo_rockets < g_pickup_rockets_max)
875 c = c + max(0, 1 - player.ammo_rockets / g_pickup_rockets_max);
878 if (player.ammo_cells < g_pickup_cells_max)
879 c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
881 if (item.ammo_plasma)
882 if (player.ammo_plasma < g_pickup_plasma_max)
883 c = c + max(0, 1 - player.ammo_plasma / g_pickup_plasma_max);
886 if (player.ammo_fuel < g_pickup_fuel_max)
887 c = c + max(0, 1 - player.ammo_fuel / g_pickup_fuel_max);
889 if (player.armorvalue < item.max_armorvalue)
890 c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
892 if (player.health < item.max_health)
893 c = c + max(0, 1 - player.health / item.max_health);
895 return item.bot_pickupbasevalue * c;
898 void Item_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
900 if(ITEM_DAMAGE_NEEDKILL(deathtype))
904 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
906 startitem_failed = FALSE;
909 self.model = itemmodel;
913 error(strcat("^1Tried to spawn ", itemname, " with no model!\n"));
917 if(self.item_pickupsound == "")
918 self.item_pickupsound = pickupsound;
920 if(!self.respawntime) // both need to be set
922 self.respawntime = defaultrespawntime;
923 self.respawntimejitter = defaultrespawntimejitter;
927 self.weapon = weaponid;
930 self.weapons = WepSet_FromWeapon(weaponid);
932 self.flags = FL_ITEM | itemflags;
934 if(MUTATOR_CALLHOOK(FilterItem)) // error means we do not want the item
936 startitem_failed = TRUE;
941 // is it a dropped weapon?
942 if (self.classname == "droppedweapon")
944 self.reset = SUB_Remove;
945 // it's a dropped weapon
946 self.movetype = MOVETYPE_TOSS;
948 // Savage: remove thrown items after a certain period of time ("garbage collection")
949 self.think = RemoveItem;
950 self.nextthink = time + 20;
952 self.takedamage = DAMAGE_YES;
953 self.event_damage = Item_Damage;
955 if(self.strength_finished || self.invincible_finished || self.superweapons_finished)
958 if(!(self.weapons & ~WEPSET_SUPERWEAPONS)) // only superweapons
959 if(self.ammo_nails == 0)
960 if(self.ammo_cells == 0)
961 if(self.ammo_rockets == 0)
962 if(self.ammo_shells == 0)
963 if(self.ammo_fuel == 0)
965 if(self.armorvalue == 0)
968 // if item is worthless after a timer, have it expire then
969 self.nextthink = max(self.strength_finished, self.invincible_finished, self.superweapons_finished);
972 // don't drop if in a NODROP zone (such as lava)
973 traceline(self.origin, self.origin, MOVE_NORMAL, self);
974 if (trace_dpstartcontents & DPCONTENTS_NODROP)
976 startitem_failed = TRUE;
983 if(!have_pickup_item())
985 startitem_failed = TRUE;
990 self.reset = Item_Reset;
992 if(self.spawnflags & 1)
995 self.movetype = MOVETYPE_NONE;
997 self.movetype = MOVETYPE_TOSS;
998 // do item filtering according to game mode and other things
1001 // first nudge it off the floor a little bit to avoid math errors
1002 setorigin(self, self.origin + '0 0 1');
1003 // set item size before we spawn a spawnfunc_waypoint
1004 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
1005 setsize (self, '-16 -16 0', '16 16 48');
1007 setsize (self, '-16 -16 0', '16 16 32');
1009 // note droptofloor returns FALSE if stuck/or would fall too far
1011 waypoint_spawnforitem(self);
1015 * can't do it that way, as it would break maps
1016 * TODO make a target_give like entity another way, that perhaps has
1017 * the weapon name in a key
1020 // target_give not yet supported; maybe later
1021 print("removed targeted ", self.classname, "\n");
1022 startitem_failed = TRUE;
1028 if(autocvar_spawn_debug >= 2)
1031 for(otheritem = findradius(self.origin, 3); otheritem; otheritem = otheritem.chain)
1033 // why not flags & fl_item?
1034 if(otheritem.is_item)
1036 dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
1037 dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
1038 error("Mapper sucks.");
1041 self.is_item = TRUE;
1044 weaponsInMap |= WepSet_FromWeapon(weaponid);
1046 precache_model (self.model);
1047 precache_sound (self.item_pickupsound);
1049 precache_sound ("misc/itemrespawncountdown.wav");
1050 if(itemid == IT_STRENGTH)
1051 precache_sound ("misc/strength_respawn.wav");
1052 else if(itemid == IT_INVINCIBLE)
1053 precache_sound ("misc/shield_respawn.wav");
1055 precache_sound ("misc/itemrespawn.wav");
1057 if((itemflags & (FL_POWERUP | FL_WEAPON)) || (itemid & (IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)))
1058 self.target = "###item###"; // for finding the nearest item using find()
1061 self.bot_pickup = TRUE;
1062 self.bot_pickupevalfunc = pickupevalfunc;
1063 self.bot_pickupbasevalue = pickupbasevalue;
1064 self.mdl = self.model;
1065 self.netname = itemname;
1066 self.touch = Item_Touch;
1067 setmodel(self, "null"); // precision set below
1068 //self.effects |= EF_LOWPRECISION;
1070 if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
1072 self.pos1 = '-16 -16 0';
1073 self.pos2 = '16 16 48';
1077 self.pos1 = '-16 -16 0';
1078 self.pos2 = '16 16 32';
1080 setsize (self, self.pos1, self.pos2);
1082 if(itemflags & FL_POWERUP)
1083 self.ItemStatus |= ITS_ANIMATE1;
1085 if(self.armorvalue || self.health)
1086 self.ItemStatus |= ITS_ANIMATE2;
1088 if(itemflags & FL_WEAPON)
1090 if (self.classname != "droppedweapon") // if dropped, colormap is already set up nicely
1091 self.colormap = 1024; // color shirt=0 pants=0 grey
1095 self.ItemStatus |= ITS_ANIMATE1;
1096 self.ItemStatus |= ISF_COLORMAP;
1100 if(self.team) // broken, no idea why.
1103 self.cnt = 1; // item probability weight
1105 self.effects |= EF_NODRAW; // marker for item team search
1106 InitializeEntity(self, Item_FindTeam, INITPRIO_FINDTARGET);
1111 Net_LinkEntity(self, FALSE, 0, ItemSend);
1113 self.SendFlags |= ISF_SIZE;
1115 self.SendFlags |= ISF_ANGLES;
1117 // call this hook after everything else has been done
1118 if(MUTATOR_CALLHOOK(Item_Spawn))
1120 startitem_failed = TRUE;
1125 void spawnfunc_item_rockets (void) {
1126 if(!self.ammo_rockets)
1127 self.ammo_rockets = g_pickup_rockets;
1128 if(!self.pickup_anyway)
1129 self.pickup_anyway = g_pickup_ammo_anyway;
1130 StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
1133 void spawnfunc_item_shells (void);
1134 void spawnfunc_item_bullets (void) {
1136 if(autocvar_sv_q3acompat_machineshotgunswap)
1137 if(self.classname != "droppedweapon")
1139 weaponswapping = TRUE;
1140 spawnfunc_item_shells();
1141 weaponswapping = FALSE;
1145 if(!self.ammo_nails)
1146 self.ammo_nails = g_pickup_nails;
1147 if(!self.pickup_anyway)
1148 self.pickup_anyway = g_pickup_ammo_anyway;
1149 StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
1152 void spawnfunc_item_cells (void) {
1153 if(!self.ammo_cells)
1154 self.ammo_cells = g_pickup_cells;
1155 if(!self.pickup_anyway)
1156 self.pickup_anyway = g_pickup_ammo_anyway;
1157 StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
1160 void spawnfunc_item_plasma()
1162 if(!self.ammo_plasma)
1163 self.ammo_plasma = g_pickup_plasma;
1164 if(!self.pickup_anyway)
1165 self.pickup_anyway = g_pickup_ammo_anyway;
1166 StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "plasma", IT_PLASMA, 0, 0, commodity_pickupevalfunc, 2000);
1169 void spawnfunc_item_shells (void) {
1171 if(autocvar_sv_q3acompat_machineshotgunswap)
1172 if(self.classname != "droppedweapon")
1174 weaponswapping = TRUE;
1175 spawnfunc_item_bullets();
1176 weaponswapping = FALSE;
1180 if(!self.ammo_shells)
1181 self.ammo_shells = g_pickup_shells;
1182 if(!self.pickup_anyway)
1183 self.pickup_anyway = g_pickup_ammo_anyway;
1184 StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
1187 void spawnfunc_item_armor_small (void) {
1188 if(!self.armorvalue)
1189 self.armorvalue = g_pickup_armorsmall;
1190 if(!self.max_armorvalue)
1191 self.max_armorvalue = g_pickup_armorsmall_max;
1192 if(!self.pickup_anyway)
1193 self.pickup_anyway = g_pickup_armorsmall_anyway;
1194 StartItem ("models/items/item_armor_small.md3", "misc/armor1.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1197 void spawnfunc_item_armor_medium (void) {
1198 if(!self.armorvalue)
1199 self.armorvalue = g_pickup_armormedium;
1200 if(!self.max_armorvalue)
1201 self.max_armorvalue = g_pickup_armormedium_max;
1202 if(!self.pickup_anyway)
1203 self.pickup_anyway = g_pickup_armormedium_anyway;
1204 StartItem ("models/items/item_armor_medium.md3", "misc/armor10.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
1207 void spawnfunc_item_armor_big (void) {
1208 if(!self.armorvalue)
1209 self.armorvalue = g_pickup_armorbig;
1210 if(!self.max_armorvalue)
1211 self.max_armorvalue = g_pickup_armorbig_max;
1212 if(!self.pickup_anyway)
1213 self.pickup_anyway = g_pickup_armorbig_anyway;
1214 StartItem ("models/items/item_armor_big.md3", "misc/armor17_5.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "50 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
1217 void spawnfunc_item_armor_large (void) {
1218 if(!self.armorvalue)
1219 self.armorvalue = g_pickup_armorlarge;
1220 if(!self.max_armorvalue)
1221 self.max_armorvalue = g_pickup_armorlarge_max;
1222 if(!self.pickup_anyway)
1223 self.pickup_anyway = g_pickup_armorlarge_anyway;
1224 StartItem ("models/items/item_armor_large.md3", "misc/armor25.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
1227 void spawnfunc_item_health_small (void) {
1228 if(!self.max_health)
1229 self.max_health = g_pickup_healthsmall_max;
1231 self.health = g_pickup_healthsmall;
1232 if(!self.pickup_anyway)
1233 self.pickup_anyway = g_pickup_healthsmall_anyway;
1234 StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1237 void spawnfunc_item_health_medium (void) {
1238 if(!self.max_health)
1239 self.max_health = g_pickup_healthmedium_max;
1241 self.health = g_pickup_healthmedium;
1242 if(!self.pickup_anyway)
1243 self.pickup_anyway = g_pickup_healthmedium_anyway;
1244 StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
1247 void spawnfunc_item_health_large (void) {
1248 if(!self.max_health)
1249 self.max_health = g_pickup_healthlarge_max;
1251 self.health = g_pickup_healthlarge;
1252 if(!self.pickup_anyway)
1253 self.pickup_anyway = g_pickup_healthlarge_anyway;
1254 StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
1257 void spawnfunc_item_health_mega (void) {
1258 if(!self.max_health)
1259 self.max_health = g_pickup_healthmega_max;
1261 self.health = g_pickup_healthmega;
1262 if(!self.pickup_anyway)
1263 self.pickup_anyway = g_pickup_healthmega_anyway;
1264 StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
1267 // support old misnamed entities
1268 void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); } // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
1269 void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
1270 void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
1271 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
1272 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
1274 void spawnfunc_item_strength (void) {
1275 precache_sound("weapons/strength_fire.wav");
1276 if(!self.strength_finished)
1277 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1278 StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
1281 void spawnfunc_item_invincible (void) {
1282 if(!self.invincible_finished)
1283 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1284 StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Shield", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
1288 void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
1290 void target_items_use (void)
1292 if(activator.classname == "droppedweapon")
1299 if (!IS_PLAYER(activator))
1301 if(activator.deadflag != DEAD_NO)
1306 for(e = world; (e = find(e, classname, "droppedweapon")); )
1307 if(e.enemy == activator)
1310 if(GiveItems(activator, 0, tokenize_console(self.netname)))
1311 centerprint(activator, self.message);
1314 void spawnfunc_target_items (void)
1319 self.use = target_items_use;
1320 if(!self.strength_finished)
1321 self.strength_finished = autocvar_g_balance_powerup_strength_time;
1322 if(!self.invincible_finished)
1323 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
1324 if(!self.superweapons_finished)
1325 self.superweapons_finished = autocvar_g_balance_superweapons_time;
1327 precache_sound("misc/itempickup.wav");
1328 precache_sound("misc/megahealth.wav");
1329 precache_sound("misc/armor25.wav");
1330 precache_sound("misc/powerup.wav");
1331 precache_sound("misc/poweroff.wav");
1332 precache_sound("weapons/weaponpickup.wav");
1334 n = tokenize_console(self.netname);
1335 if(argv(0) == "give")
1337 self.netname = substring(self.netname, argv_start_index(1), argv_end_index(-1) - argv_start_index(1));
1341 for(i = 0; i < n; ++i)
1343 if (argv(i) == "unlimited_ammo") self.items |= IT_UNLIMITED_AMMO;
1344 else if(argv(i) == "unlimited_weapon_ammo") self.items |= IT_UNLIMITED_WEAPON_AMMO;
1345 else if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
1346 else if(argv(i) == "strength") self.items |= IT_STRENGTH;
1347 else if(argv(i) == "invincible") self.items |= IT_INVINCIBLE;
1348 else if(argv(i) == "superweapons") self.items |= IT_SUPERWEAPON;
1349 else if(argv(i) == "jetpack") self.items |= IT_JETPACK;
1350 else if(argv(i) == "fuel_regen") self.items |= IT_FUEL_REGEN;
1353 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1355 e = get_weaponinfo(j);
1356 if(argv(i) == e.netname)
1358 self.weapons |= WepSet_FromWeapon(j);
1359 if(self.spawnflags == 0 || self.spawnflags == 2)
1360 WEP_ACTION(e.weapon, WR_INIT);
1365 print("target_items: invalid item ", argv(i), "\n");
1369 string itemprefix, valueprefix;
1370 if(self.spawnflags == 0)
1375 else if(self.spawnflags == 1)
1377 itemprefix = "max ";
1378 valueprefix = "max ";
1380 else if(self.spawnflags == 2)
1382 itemprefix = "min ";
1383 valueprefix = "min ";
1385 else if(self.spawnflags == 4)
1387 itemprefix = "minus ";
1388 valueprefix = "max ";
1392 error("invalid spawnflags");
1394 itemprefix = string_null;
1395 valueprefix = string_null;
1400 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
1401 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
1402 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * !!(self.items & IT_STRENGTH), "strength");
1403 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * !!(self.items & IT_INVINCIBLE), "invincible");
1404 self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * !!(self.items & IT_SUPERWEAPON), "superweapons");
1405 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_JETPACK), "jetpack");
1406 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_FUEL_REGEN), "fuel_regen");
1407 if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
1408 if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
1409 if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
1410 if(self.ammo_cells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_cells), "cells");
1411 if(self.ammo_plasma != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_plasma), "plasma");
1412 if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
1413 if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
1414 if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
1415 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1417 e = get_weaponinfo(j);
1419 self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & WepSet_FromWeapon(j)), e.netname);
1422 self.netname = strzone(self.netname);
1423 //print(self.netname, "\n");
1425 n = tokenize_console(self.netname);
1426 for(i = 0; i < n; ++i)
1428 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1430 e = get_weaponinfo(j);
1431 if(argv(i) == e.netname)
1433 WEP_ACTION(e.weapon, WR_INIT);
1440 void spawnfunc_item_fuel(void)
1443 self.ammo_fuel = g_pickup_fuel;
1444 if(!self.pickup_anyway)
1445 self.pickup_anyway = g_pickup_ammo_anyway;
1446 StartItem ("models/items/g_fuel.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "Fuel", IT_FUEL, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1449 void spawnfunc_item_fuel_regen(void)
1451 if(start_items & IT_FUEL_REGEN)
1453 spawnfunc_item_fuel();
1456 StartItem ("models/items/g_fuelregen.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Fuel regenerator", IT_FUEL_REGEN, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1459 void spawnfunc_item_jetpack(void)
1461 if(g_grappling_hook)
1462 return; // sorry, but these two can't coexist (same button); spawn fuel instead
1464 self.ammo_fuel = g_pickup_fuel_jetpack;
1465 if(start_items & IT_JETPACK)
1467 spawnfunc_item_fuel();
1470 StartItem ("models/items/g_jetpack.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Jet pack", IT_JETPACK, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
1473 float GiveWeapon(entity e, float wpn, float op, float val)
1476 v0 = (e.weapons & WepSet_FromWeapon(wpn));
1481 e.weapons |= WepSet_FromWeapon(wpn);
1483 e.weapons &= ~WepSet_FromWeapon(wpn);
1488 e.weapons |= WepSet_FromWeapon(wpn);
1492 e.weapons &= ~WepSet_FromWeapon(wpn);
1496 e.weapons &= ~WepSet_FromWeapon(wpn);
1499 v1 = (e.weapons & WepSet_FromWeapon(wpn));
1503 float GiveBit(entity e, .float fld, float bit, float op, float val)
1533 float GiveValue(entity e, .float fld, float op, float val)
1543 e.fld = max(e.fld, val); // min 100 cells = at least 100 cells
1546 e.fld = min(e.fld, val);
1559 void GiveSound(entity e, float v0, float v1, float t, string snd_incr, string snd_decr)
1566 sound (e, CH_TRIGGER, snd_decr, VOL_BASE, ATTEN_NORM);
1568 else if(v0 >= v0 + t)
1571 sound (e, CH_TRIGGER, snd_incr, VOL_BASE, ATTEN_NORM);
1575 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime)
1578 e.rotfield = max(e.rotfield, time + rottime);
1580 e.regenfield = max(e.regenfield, time + regentime);
1582 float GiveItems(entity e, float beginarg, float endarg)
1584 float got, i, j, val, op;
1585 float _switchweapon;
1594 _switchweapon = FALSE;
1596 if (e.switchweapon == w_getbestweapon(e))
1597 _switchweapon = TRUE;
1599 e.strength_finished = max(0, e.strength_finished - time);
1600 e.invincible_finished = max(0, e.invincible_finished - time);
1601 e.superweapons_finished = max(0, e.superweapons_finished - time);
1605 PREGIVE(e, strength_finished);
1606 PREGIVE(e, invincible_finished);
1607 PREGIVE(e, superweapons_finished);
1608 PREGIVE(e, ammo_nails);
1609 PREGIVE(e, ammo_cells);
1610 PREGIVE(e, ammo_plasma);
1611 PREGIVE(e, ammo_shells);
1612 PREGIVE(e, ammo_rockets);
1613 PREGIVE(e, ammo_fuel);
1614 PREGIVE(e, armorvalue);
1617 for(i = beginarg; i < endarg; ++i)
1621 if(cmd == "0" || stof(cmd))
1645 got += GiveBit(e, items, IT_FUEL_REGEN, op, val);
1646 got += GiveValue(e, strength_finished, op, val);
1647 got += GiveValue(e, invincible_finished, op, val);
1648 got += GiveValue(e, superweapons_finished, op, val);
1649 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1651 got += GiveBit(e, items, IT_JETPACK, op, val);
1652 got += GiveValue(e, health, op, val);
1653 got += GiveValue(e, armorvalue, op, val);
1655 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1657 wi = get_weaponinfo(j);
1659 if (!(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED))
1660 got += GiveWeapon(e, j, op, val);
1663 got += GiveValue(e, ammo_cells, op, val);
1664 got += GiveValue(e, ammo_plasma, op, val);
1665 got += GiveValue(e, ammo_shells, op, val);
1666 got += GiveValue(e, ammo_nails, op, val);
1667 got += GiveValue(e, ammo_rockets, op, val);
1668 got += GiveValue(e, ammo_fuel, op, val);
1670 case "unlimited_ammo":
1671 got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
1673 case "unlimited_weapon_ammo":
1674 got += GiveBit(e, items, IT_UNLIMITED_WEAPON_AMMO, op, val);
1676 case "unlimited_superweapons":
1677 got += GiveBit(e, items, IT_UNLIMITED_SUPERWEAPONS, op, val);
1680 got += GiveBit(e, items, IT_JETPACK, op, val);
1683 got += GiveBit(e, items, IT_FUEL_REGEN, op, val);
1686 got += GiveValue(e, strength_finished, op, val);
1689 got += GiveValue(e, invincible_finished, op, val);
1691 case "superweapons":
1692 got += GiveValue(e, superweapons_finished, op, val);
1695 got += GiveValue(e, ammo_cells, op, val);
1698 got += GiveValue(e, ammo_plasma, op, val);
1701 got += GiveValue(e, ammo_shells, op, val);
1705 got += GiveValue(e, ammo_nails, op, val);
1708 got += GiveValue(e, ammo_rockets, op, val);
1711 got += GiveValue(e, health, op, val);
1714 got += GiveValue(e, armorvalue, op, val);
1717 got += GiveValue(e, ammo_fuel, op, val);
1720 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1722 wi = get_weaponinfo(j);
1723 if(cmd == wi.netname)
1725 got += GiveWeapon(e, j, op, val);
1730 print("give: invalid item ", cmd, "\n");
1737 POSTGIVE_BIT(e, items, IT_FUEL_REGEN, "misc/itempickup.wav", string_null);
1738 POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, "misc/powerup.wav", "misc/poweroff.wav");
1739 POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, "misc/powerup.wav", "misc/poweroff.wav");
1740 POSTGIVE_BIT(e, items, IT_JETPACK, "misc/itempickup.wav", string_null);
1741 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
1743 wi = get_weaponinfo(j);
1746 POSTGIVE_WEAPON(e, j, "weapons/weaponpickup.wav", string_null);
1747 if (!(save_weapons & WepSet_FromWeapon(j)))
1748 if(e.weapons & WepSet_FromWeapon(j))
1749 WEP_ACTION(wi.weapon, WR_INIT);
1752 POSTGIVE_VALUE(e, strength_finished, 1, "misc/powerup.wav", "misc/poweroff.wav");
1753 POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", "misc/poweroff.wav");
1754 POSTGIVE_VALUE(e, ammo_nails, 0, "misc/itempickup.wav", string_null);
1755 POSTGIVE_VALUE(e, ammo_cells, 0, "misc/itempickup.wav", string_null);
1756 POSTGIVE_VALUE(e, ammo_plasma, 0, "misc/itempickup.wav", string_null);
1757 POSTGIVE_VALUE(e, ammo_shells, 0, "misc/itempickup.wav", string_null);
1758 POSTGIVE_VALUE(e, ammo_rockets, 0, "misc/itempickup.wav", string_null);
1759 POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, autocvar_g_balance_pause_fuel_rot, pauseregen_finished, autocvar_g_balance_pause_fuel_regen, "misc/itempickup.wav", string_null);
1760 POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, autocvar_g_balance_pause_armor_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, "misc/armor25.wav", string_null);
1761 POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, "misc/megahealth.wav", string_null);
1763 if(e.superweapons_finished <= 0)
1764 if(self.weapons & WEPSET_SUPERWEAPONS)
1765 e.superweapons_finished = autocvar_g_balance_superweapons_time;
1767 if(e.strength_finished <= 0)
1768 e.strength_finished = 0;
1770 e.strength_finished += time;
1771 if(e.invincible_finished <= 0)
1772 e.invincible_finished = 0;
1774 e.invincible_finished += time;
1775 if(e.superweapons_finished <= 0)
1776 e.superweapons_finished = 0;
1778 e.superweapons_finished += time;
1780 if (!(e.weapons & WepSet_FromWeapon(e.switchweapon)))
1781 _switchweapon = TRUE;
1783 W_SwitchWeapon_Force(e, w_getbestweapon(e));