How is ammo from grenades handled in Deus Ex?

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
Post Reply
User avatar
DevAnj
UNATCO
Posts: 106
Joined: Sun Aug 02, 2015 2:16 am

How is ammo from grenades handled in Deus Ex?

Post by DevAnj »

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?
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How is ammo from grenades handled in Deus Ex?

Post by Cybernetic pig »

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):

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; 
DeusExProjectile (deactivated proximity mine or thrown grenade):

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;
			}
		}
DeusExWeapon (dropped by NPCs):

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;
}
As well as the default PickupAmmoCount value in the WeaponXGrenade classes themselves. Beware there could be other instances, its a convoluted system.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: How is ammo from grenades handled in Deus Ex?

Post by Hanfling »

I so much hate the Inventory pickup code in DeusExCarcass.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How is ammo from grenades handled in Deus Ex?

Post by Cybernetic pig »

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.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: How is ammo from grenades handled in Deus Ex?

Post by Hanfling »

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.
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...
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
Post Reply