How is ammo from grenades handled in Deus Ex?
How is ammo from grenades handled in Deus Ex?
I'm trying to increase the number of grenades a player gets upon increasing his/her demolition skill. However, neither did editing DeusExWeapon or the respective ammo classes worked. From what I see, it seems grenade "ammo" is handled differently from other weapons since while they have an ammo class it's not put directly in game but only referenced through some run time functions. Can someone experienced with Deus Ex coding here help me with this?
-
- Illuminati
- Posts: 2284
- Joined: Thu Mar 08, 2012 3:21 am
Re: How is ammo from grenades handled in Deus Ex?
Grenades are considered weapons, and in reality you only ever have one, even if you actually have count: ten. Additional carried grenades are considered ammo. When you run out of ammo, the grenade weapon is destroyed.
Relevant snippets:
DeusExCarcass (when frobbing a corpse):
DeusExProjectile (deactivated proximity mine or thrown grenade):
DeusExWeapon (dropped by NPCs):
As well as the default PickupAmmoCount value in the WeaponXGrenade classes themselves. Beware there could be other instances, its a convoluted system.
Relevant snippets:
DeusExCarcass (when frobbing a corpse):
Code: Select all
// Grenades and LAMs always pickup 1
if (W.IsA('WeaponNanoVirusGrenade') ||
W.IsA('WeaponGasGrenade') ||
W.IsA('WeaponEMPGrenade') ||
W.IsA('WeaponLAM') ||
W.IsA('WeaponHideAGun') && player.FindInventorySlot(item, True)) //CyberP: there we go. Now need to stop 1-4 rand for nades
W.PickupAmmoCount = 1;
Code: Select all
if (spawnWeaponClass != None) // spawn the weapon
{
item = Spawn(spawnWeaponClass);
if (item != None)
{
if ( (Level.NetMode != NM_Standalone ) && Self.IsA('Shuriken'))
DeusExWeapon(item).PickupAmmoCount = DeusExWeapon(item).PickupAmmoCount * 3;
else
DeusExWeapon(item).PickupAmmoCount = 1;
}
}
else if (spawnAmmoClass != None) // or spawn the ammo
{
item = Spawn(spawnAmmoClass);
if (item != None)
{
if ( (Level.NetMode != NM_Standalone ) && Self.IsA('Dart'))
Ammo(item).AmmoAmount = Ammo(item).AmmoAmount * 3;
else
Ammo(item).AmmoAmount = 1;
}
}
Code: Select all
function float SetDroppedAmmoCount()
{
// Any weapons have their ammo set to a random number of rounds (1-4)
// unless it's a grenade, in which case we only want to dole out one.
// DEUS_EX AMSD In multiplayer, give everything away.
// Grenades and LAMs always pickup 1
if (IsA('WeaponNanoVirusGrenade') || IsA('WeaponGasGrenade') || IsA('WeaponEMPGrenade') || IsA('WeaponLAM') || IsA('WeaponHideAGun'))
PickupAmmoCount = 1;
else if (Level.NetMode == NM_Standalone)
PickupAmmoCount = Rand(4) + 1;
}
Re: How is ammo from grenades handled in Deus Ex?
I so much hate the Inventory pickup code in DeusExCarcass.
-
- Illuminati
- Posts: 2284
- Joined: Thu Mar 08, 2012 3:21 am
Re: How is ammo from grenades handled in Deus Ex?
Yeah, it's a right mess. It works for the player which is ultimately what matters, but it's sub-optimal coding. It's a lot like my code, although I'm improving every day.
Re: How is ammo from grenades handled in Deus Ex?
I tried to use this code (and other pickup related code) to get the players in HX to pick up full inventory of player corpses while keeping the old pickup behaviour for ScriptedPawns...Cybernetic pig wrote:Yeah, it's a right mess. It works for the player which is ultimately what matters, but it's sub-optimal coding. It's a lot like my code, although I'm improving every day.