1 void thrown_wep_think()
4 if(self.oldorigin != self.origin)
6 self.SendFlags |= ISF_LOCATION;
7 self.oldorigin = self.origin;
10 float timeleft = self.savenextthink - time;
12 SUB_SetFade(self, self.savenextthink - 1, 1);
14 SUB_SetFade(self, time, timeleft);
16 SUB_VanishOrRemove(self);
19 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
20 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
25 var .float ammotype = (get_weaponinfo(wpn)).ammo_field;
30 wep.classname = "droppedweapon";
32 wep.owner = wep.enemy = own;
33 wep.flags |= FL_TOSSED;
34 wep.colormap = own.colormap;
36 W_DropEvent(WR_DROP,own,wpn,wep);
38 if(WepSet_FromWeapon(wpn) & WEPSET_SUPERWEAPONS)
40 if(own.items & IT_UNLIMITED_SUPERWEAPONS)
42 wep.superweapons_finished = time + autocvar_g_balance_superweapons_time;
46 float superweapons = 1;
47 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
48 if(WepSet_FromWeapon(i) & WEPSET_SUPERWEAPONS)
49 if(own.weapons & WepSet_FromWeapon(i))
53 wep.superweapons_finished = own.superweapons_finished;
54 own.superweapons_finished = 0;
58 float timeleft = own.superweapons_finished - time;
59 float weptimeleft = timeleft / superweapons;
60 wep.superweapons_finished = time + weptimeleft;
61 own.superweapons_finished -= weptimeleft;
68 weapon_defaultspawnfunc(wpn);
72 wep.glowmod = own.weaponentity_glowmod;
73 wep.think = thrown_wep_think;
74 wep.savenextthink = wep.nextthink;
75 wep.nextthink = min(wep.nextthink, time + 0.5);
76 wep.pickup_anyway = TRUE; // these are ALWAYS pickable
78 //wa = W_AmmoItemCode(wpn);
79 if(ammotype == ammo_none)
87 if(doreduce && g_weapon_stay == 2)
89 // if our weapon is loaded, give its load back to the player
90 if(self.(weapon_load[self.weapon]) > 0)
92 own.ammotype += self.(weapon_load[self.weapon]);
93 self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
100 // if our weapon is loaded, give its load back to the player
101 if(self.(weapon_load[self.weapon]) > 0)
103 own.ammotype += self.(weapon_load[self.weapon]);
104 self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
107 thisammo = min(own.ammotype, wep.ammotype);
108 wep.ammotype = thisammo;
109 own.ammotype -= thisammo;
113 case ammo_shells: s = sprintf("%s and %d shells", s, thisammo); break;
114 case ammo_nails: s = sprintf("%s and %d nails", s, thisammo); break;
115 case ammo_rockets: s = sprintf("%s and %d rockets", s, thisammo); break;
116 case ammo_cells: s = sprintf("%s and %d cells", s, thisammo); break;
117 case ammo_plasma: s = sprintf("%s and %d plasma", s, thisammo); break;
118 case ammo_fuel: s = sprintf("%s and %d fuel", s, thisammo); break;
121 s = substring(s, 5, -1);
127 float W_IsWeaponThrowable(float w)
129 if (!autocvar_g_pickup_items)
135 if (g_nexball && w == WEP_MORTAR)
141 if(start_weapons & WepSet_FromWeapon(w))
143 // start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
144 if(start_items & IT_UNLIMITED_WEAPON_AMMO)
146 if((get_weaponinfo(w)).ammo_field == ammo_none)
151 return (get_weaponinfo(w)).weaponthrowable;
155 // toss current weapon
156 void W_ThrowWeapon(vector velo, vector delta, float doreduce)
163 return; // just in case
164 if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon))
166 if(!autocvar_g_weapon_throwable)
168 if(self.weaponentity.state != WS_READY)
170 if(!W_IsWeaponThrowable(w))
173 if(!(self.weapons & WepSet_FromWeapon(w)))
175 self.weapons &= ~WepSet_FromWeapon(w);
177 W_SwitchWeapon_Force(self, w_getbestweapon(self));
178 a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);
181 Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_WEAPON_DROP, a, w);
184 void SpawnThrownWeapon(vector org, float w)
186 if(self.weapons & WepSet_FromWeapon(self.weapon))
187 if(W_IsWeaponThrowable(self.weapon))
188 W_ThrowNewWeapon(self, self.weapon, FALSE, org, randomvec() * 125 + '0 0 200');