1 void thrown_wep_think()
4 float timeleft = self.savenextthink - time;
6 SUB_SetFade(self, self.savenextthink - 1, 1);
8 SUB_SetFade(self, time, timeleft);
10 SUB_VanishOrRemove(self);
13 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
14 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
17 float wa, thisammo, i, j;
24 wep.classname = "droppedweapon";
26 wep.owner = wep.enemy = own;
27 wep.flags |= FL_TOSSED;
28 wep.colormap = own.colormap;
30 if(WepSet_FromWeapon(wpn) & WEPSET_SUPERWEAPONS)
32 if(own.items & IT_UNLIMITED_SUPERWEAPONS)
34 wep.superweapons_finished = time + autocvar_g_balance_superweapons_time;
38 float superweapons = 1;
39 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
40 if(WepSet_FromWeapon(i) & WEPSET_SUPERWEAPONS)
41 if(own.weapons & WepSet_FromWeapon(i))
45 wep.superweapons_finished = own.superweapons_finished;
46 own.superweapons_finished = 0;
50 float timeleft = own.superweapons_finished - time;
51 float weptimeleft = timeleft / superweapons;
52 wep.superweapons_finished = time + weptimeleft;
53 own.superweapons_finished -= weptimeleft;
58 wa = W_AmmoItemCode(wpn);
63 weapon_defaultspawnfunc(wpn);
67 wep.glowmod = own.weaponentity_glowmod;
68 wep.think = thrown_wep_think;
69 wep.savenextthink = wep.nextthink;
70 wep.nextthink = min(wep.nextthink, time + 0.5);
71 wep.pickup_anyway = TRUE; // these are ALWAYS pickable
79 weapon_defaultspawnfunc(wpn);
83 if(doreduce && g_weapon_stay == 2)
85 for(i = 0, j = 1; i < 24; ++i, j *= 2)
89 ammofield = Item_CounterField(j);
91 // if our weapon is loaded, give its load back to the player
92 if(self.(weapon_load[self.weapon]) > 0)
94 own.ammofield += self.(weapon_load[self.weapon]);
95 self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
104 for(i = 0, j = 1; i < 24; ++i, j *= 2)
108 ammofield = Item_CounterField(j);
110 // if our weapon is loaded, give its load back to the player
111 if(self.(weapon_load[self.weapon]) > 0)
113 own.ammofield += self.(weapon_load[self.weapon]);
114 self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
117 thisammo = min(own.ammofield, wep.ammofield);
118 wep.ammofield = thisammo;
119 own.ammofield -= thisammo;
120 s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j));
123 s = substring(s, 5, -1);
125 wep.glowmod = own.weaponentity_glowmod;
126 wep.think = thrown_wep_think;
127 wep.savenextthink = wep.nextthink;
128 wep.nextthink = min(wep.nextthink, time + 0.5);
129 wep.pickup_anyway = TRUE; // these are ALWAYS pickable
135 float W_IsWeaponThrowable(float w)
139 if (!autocvar_g_pickup_items)
145 if (g_nexball && w == WEP_GRENADE_LAUNCHER)
150 wa = W_AmmoItemCode(w);
151 if(start_weapons & WepSet_FromWeapon(w))
153 // start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
154 if(start_items & IT_UNLIMITED_WEAPON_AMMO)
163 // toss current weapon
164 void W_ThrowWeapon(vector velo, vector delta, float doreduce)
171 return; // just in case
172 if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon))
174 if(!autocvar_g_weapon_throwable)
176 if(self.weaponentity.state != WS_READY)
178 if(!W_IsWeaponThrowable(w))
181 if(!(self.weapons & WepSet_FromWeapon(w)))
183 self.weapons &= ~WepSet_FromWeapon(w);
185 W_SwitchWeapon_Force(self, w_getbestweapon(self));
186 a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);
189 Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_WEAPON_DROP, a, w);