float W_AmmoItemCode(float wpn)
{
- return (get_weaponinfo(wpn)).items;
+ return (get_weaponinfo(wpn)).items & IT_AMMO;
}
+.float savenextthink;
void thrown_wep_think()
{
- self.solid = SOLID_TRIGGER;
self.owner = world;
- SUB_SetFade(self, time + 20, 1);
+ float timeleft = self.savenextthink - time;
+ if(timeleft > 1)
+ SUB_SetFade(self, self.savenextthink - 1, 1);
+ else if(timeleft > 0)
+ SUB_SetFade(self, time, timeleft);
+ else
+ SUB_VanishOrRemove(self);
+}
+
+void thrown_wep_ode_think()
+{
+ self.nextthink = time;
+ self.alpha = self.owner.alpha; // apply fading of the original weapon
+ if(!self.owner.modelindex)
+ remove(self); // the real weapon is gone, remove this
}
// returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
wep.flags |= FL_TOSSED;
wep.colormap = own.colormap;
+ if(W_WeaponBit(wpn) & WEPBIT_SUPERWEAPONS)
+ {
+ if(own.items & IT_UNLIMITED_SUPERWEAPONS)
+ {
+ wep.superweapons_finished = time + autocvar_g_balance_superweapons_time;
+ }
+ else
+ {
+ float superweapons = 1;
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+ if(own.weapons & WEPBIT_SUPERWEAPONS & W_WeaponBit(i))
+ ++superweapons;
+ if(superweapons <= 1)
+ {
+ wep.superweapons_finished = own.superweapons_finished;
+ own.superweapons_finished = 0;
+ }
+ else
+ {
+ float timeleft = own.superweapons_finished - time;
+ float weptimeleft = timeleft / superweapons;
+ wep.superweapons_finished = time + weptimeleft;
+ own.superweapons_finished -= weptimeleft;
+ }
+ }
+ }
+
wa = W_AmmoItemCode(wpn);
- if(wa == IT_SUPERWEAPON || wa == 0)
+ if(wa == 0)
{
oldself = self;
self = wep;
return string_null;
wep.glowmod = own.weaponentity_glowmod;
wep.think = thrown_wep_think;
- wep.nextthink = time + 0.5;
+ wep.savenextthink = wep.nextthink;
+ wep.nextthink = min(wep.nextthink, time + 0.5);
+ wep.pickup_anyway = TRUE; // these are ALWAYS pickable
return "";
}
else
self = oldself;
if(startitem_failed)
return string_null;
- if(doreduce)
+ if(doreduce && g_weapon_stay == 2)
{
for(i = 0, j = 1; i < 24; ++i, j *= 2)
{
if(wa & j)
{
ammofield = Item_CounterField(j);
- thisammo = min(own.ammofield, wep.ammofield);
- wep.ammofield = thisammo;
- own.ammofield -= thisammo;
- s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j));
// if our weapon is loaded, give its load back to the player
if(self.(weapon_load[self.weapon]) > 0)
own.ammofield += self.(weapon_load[self.weapon]);
self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
}
+
+ wep.ammofield = 0;
+ }
+ }
+ }
+ else if(doreduce)
+ {
+ for(i = 0, j = 1; i < 24; ++i, j *= 2)
+ {
+ if(wa & j)
+ {
+ ammofield = Item_CounterField(j);
+
+ // if our weapon is loaded, give its load back to the player
+ if(self.(weapon_load[self.weapon]) > 0)
+ {
+ own.ammofield += self.(weapon_load[self.weapon]);
+ self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
+ }
+
+ thisammo = min(own.ammofield, wep.ammofield);
+ wep.ammofield = thisammo;
+ own.ammofield -= thisammo;
+ s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j));
}
}
s = substring(s, 5, -1);
}
wep.glowmod = own.weaponentity_glowmod;
wep.think = thrown_wep_think;
- wep.nextthink = time + 0.5;
+ wep.savenextthink = wep.nextthink;
+ wep.nextthink = min(wep.nextthink, time + 0.5);
+ wep.pickup_anyway = TRUE; // these are ALWAYS pickable
+
+ // make the dropped weapon physical
+ if(autocvar_physics_ode && autocvar_sv_physics_ode_droppedweapon)
+ {
+ entity wep2;
+ wep2 = spawn();
+ setorigin(wep2, wep.origin);
+ setmodel(wep2, wep.model);
+ wep2.angles = wep.angles;
+ wep2.velocity = velo;
+ wep2.avelocity_x = random() * autocvar_sv_physics_ode_droppedweapon_avelocity;
+ wep2.avelocity_y = random() * autocvar_sv_physics_ode_droppedweapon_avelocity;
+ wep2.avelocity_z = random() * autocvar_sv_physics_ode_droppedweapon_avelocity;
+
+ wep2.classname = "droppedweapon2";
+ wep2.owner = wep;
+ wep2.solid = SOLID_BBOX;
+ wep2.movetype = MOVETYPE_PHYSICS;
+ wep2.takedamage = DAMAGE_AIM;
+ wep2.colormap = wep.colormap;
+ wep2.glowmod = wep.glowmod;
+ wep2.damageforcescale = autocvar_sv_physics_ode_droppedweapon_damageforcescale;
+
+ wep2.think = thrown_wep_ode_think;
+ wep2.nextthink = time;
+
+ wep.model = "null"; // don't use setmodel, we want to keep the size
+ wep.movetype = MOVETYPE_FOLLOW;
+ wep.aiment = wep2;
+ }
+
return s;
}
}
wa = W_AmmoItemCode(w);
if(start_weapons & wb)
{
- if(wa == IT_SUPERWEAPON && start_items & IT_UNLIMITED_SUPERWEAPONS)
- return 0;
- if(wa != IT_SUPERWEAPON && start_items & IT_UNLIMITED_WEAPON_AMMO)
- return 0;
// start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
+ if(start_items & IT_UNLIMITED_WEAPON_AMMO)
+ return 0;
if(wa == 0)
return 0;
}
return;
if(!autocvar_g_weapon_throwable)
return;
- if(autocvar_g_weapon_stay == 1)
- return;
if(self.weaponentity.state != WS_READY)
return;
if(!W_IsWeaponThrowable(w))