Stackable Weapon Mods in Inventory?

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

Quick question: would adding the properties "maxCopies=xx" and "bCanHaveMultipleCopies=True" to weapon mods allow them to be stackable (like multitools, medkits, or Zyme vials) in the user's inventory?
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Stackable Weapon Mods in Inventory?

Post by Hanfling »

It should, but you will also need to override DestroyMod() to deduce copies of the mod, else after applying one mod, all mods gets destroyed in that inventory slot. But it should work this way.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

This is the script in "WeaponMod.uc" that handles removing mods from the player's inventory once they've been used.

-- redacted --

Is it safe to assume that I could replace the above script with this edited script (from "DeusExPickup.uc") to allow me to have any number of mods of the same type in a single stack, and then be able to use them all one-by-one until they're gone?

-- redacted --

EDIT: Completed script available in most recent reply.
Last edited by CorinthMaxwell on Fri Aug 29, 2014 10:16 pm, edited 1 time in total.
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Stackable Weapon Mods in Inventory?

Post by Hanfling »

Yup, thats the way i thought about doing it, well but you could just call UseOnce() there and not put the whole function in. But just try it. You will see if it works.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

Hanfling wrote:Yup, thats the way i thought about doing it, well but you could just call UseOnce() there and not put the whole function in. But just try it. You will see if it works.
And it doesn't. #-o

Error message from UCC.log:

Code: Select all

Error: C:\DeusEx (Shifter)\DeusEx\Classes\WeaponMod.uc(17) : Error, Unrecognized variable 'DestroyMod' name in replication definition
Here's the altered portions of the script I'm using......can you help me figure out what went wrong? :/

-- redacted --

UPDATE 01: Replacing "DestroyMod" in Line 17 with "UseOnce" gave me a different error. <_<

Code: Select all

Error: C:\DeusEx (Shifter)\DeusEx\Classes\WeaponMod.uc(17) : Error, Function 'UseOnce' is defined in base class 'DeusExPickup'
UPDATE 02: I combined the script functions in "UseOnce()" with the original section "DestroyMod()", and the DeusEx.u file compiled without errors. I'm currently testing whether or not the weapon mods will be stacked in the player's inventory & used properly (i.e., one-by-one). Will edit post (or reply) with another update soon.

-- redacted --

EDIT: Completed script available in most recent reply.
Last edited by CorinthMaxwell on Fri Aug 29, 2014 10:17 pm, edited 1 time in total.
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

Ok, then........When I tested the new "DeusEx.u" file with the previous changes, I attempted to apply a Scope mod to the Mini-Crossbow, and this message popped up.

Code: Select all

Critical Error: WeaponModScope01_NYC_UNATCOIsland.WeaponModScope0 (Function DeusEx.WeaponMod.DestroyMod:0000) Infinite script recursion (250 calls) detected
I then made other changes to "WeaponMod.uc", causing something rather interesting & unusual. By removing a portion of the script I'd implanted (i.e., "if (!IsA('WeaponMod')), GotoState('DeActivated');") and changing "if (NumCopies <= 0)" to "if (NumCopies == 1)", I wound up causing the unexpected benefit of making every weapon mod have infinite uses -- i.e., I could drag any mod onto any weapon in my inventory as many times as I wished, without having the mod removed from my inventory.

While this is particularly useful (and definitely game-breaking), I would much rather achieve the original desired effect, if I can actually get it to work. <_<
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Stackable Weapon Mods in Inventory?

Post by Hanfling »

I discourage the change of base game packages, but you call DestroyMod() in your DestroyMod() method. No wonder it causes infinite recursion, you should stick with the old Destroy() inside the function.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

At last, my little experiment finally works.

Image

Also, in each individual weapon mod's code, I added the properties "bCanHaveMultipleCopies=True" and "maxCopies=5", just to ensure that even though I can carry them in stacks, I'd have to use up quite a few of them eventually. Now, I just have to figure out how to make those damned PS20s stackable......8)

Code: Select all

//=============================================================================
// WeaponMod
//=============================================================================
class WeaponMod extends DeusExPickup
	abstract;

var() Float WeaponModifier;
var localized String DragToUpgrade;

// ----------------------------------------------------------------------
// Network Replication
// ----------------------------------------------------------------------
replication
{
   // client to server function call
   reliable if (Role < ROLE_Authority)
      ApplyMod, DestroyMod;
}


function PostBeginPlay()
{
	Super.PostBeginPlay();

	LoopAnim('Cycle');
}

// ----------------------------------------------------------------------
// ApplyMod()
//
// Applies the modification to the weapon.  Unique for each different 
// type of weapon mod class
// ----------------------------------------------------------------------

function ApplyMod(DeusExWeapon weapon)
{
}

// ----------------------------------------------------------------------
// CanUpgradeWeapon()
// ----------------------------------------------------------------------

function bool CanUpgradeWeapon(DeusExWeapon weapon)
{
}

// ----------------------------------------------------------------------
// DestroyMod()
//
// Subtract a use, then destroy if out of uses
// ----------------------------------------------------------------------

function DestroyMod()
{
	local DeusExPlayer player;

	player = DeusExPlayer(Owner);
	NumCopies--;

	if (NumCopies <= 0)
	{
		if (player.inHand == Self)
			player.PutInHand(None);
		Destroy();
	}
	else
	{
		UpdateBeltText();
	}
}

// ----------------------------------------------------------------------
// UpdateInfo()
//
// Describes the capabilities of this weapon mod,
// for instance, "Increases base accuracy by 20%"
// ----------------------------------------------------------------------

simulated function bool UpdateInfo(Object winObject)
{
	local PersonaInfoWindow winInfo;

	winInfo = PersonaInfoWindow(winObject);
	if (winInfo == None)
		return False;

	winInfo.Clear();
	winInfo.SetTitle(itemName);
	winInfo.SetText(Description $ winInfo.CR() $ winInfo.CR());

	winInfo.AppendText(DragToUpgrade);

	return True;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
     DragToUpgrade="Drag over weapon to upgrade.  Weapons highlighted in GREEN can be upgraded with this mod."
     PlayerViewOffset=(X=30.000000,Z=-12.000000)
     PlayerViewMesh=LodMesh'DeusExItems.WeaponMod'
     PickupViewMesh=LodMesh'DeusExItems.WeaponMod'
     ThirdPersonMesh=LodMesh'DeusExItems.WeaponMod'
     LandSound=Sound'DeusExSounds.Generic.PlasticHit1'
     largeIconWidth=34
     largeIconHeight=49
     Mesh=LodMesh'DeusExItems.WeaponMod'
     CollisionRadius=3.500000
     CollisionHeight=4.420000
     Mass=1.000000
}
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Stackable Weapon Mods in Inventory?

Post by Cybernetic pig »

Cool. Mind if I use this for my mod?
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

Cybernetic pig wrote:Cool. Mind if I use this for my mod?
Go right ahead. 8)
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: Stackable Weapon Mods in Inventory?

Post by Cybernetic pig »

Thanks.
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Stackable Weapon Mods in Inventory?

Post by Hanfling »

For PS20...

Code: Select all

// DeusExPlayer.HandleItemPickup()
				// If these fields are set as checked, then this is a 
				// single use weapon, and if we already have one in our 
				// inventory another cannot be picked up (puke). 

				bCanPickup = ! ( (Weapon(foundItem).ReloadCount == 0) && 
				                 (Weapon(foundItem).PickupAmmoCount == 0) && 
				                 (Weapon(foundItem).AmmoName != None) );

				if (!bCanPickup)
					ClientMessage(Sprintf(CanCarryOnlyOne, foundItem.itemName));
PersonaInventoryItemButton.DrawWindow()
Make the AmmoAmount displayed as item count.

See how it works out, and maybe you need to show the throw away animation as a reload animation.

Done.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

Hanfling wrote:For PS20...

Code: Select all

// DeusExPlayer.HandleItemPickup()
				// If these fields are set as checked, then this is a 
				// single use weapon, and if we already have one in our 
				// inventory another cannot be picked up (puke). 

				bCanPickup = ! ( (Weapon(foundItem).ReloadCount == 0) && 
				                 (Weapon(foundItem).PickupAmmoCount == 0) && 
				                 (Weapon(foundItem).AmmoName != None) );

				if (!bCanPickup)
					ClientMessage(Sprintf(CanCarryOnlyOne, foundItem.itemName));
PersonaInventoryItemButton.DrawWindow()
Make the AmmoAmount displayed as item count.

See how it works out, and maybe you need to show the throw away animation as a reload animation.

Done.
Slight question......where, specifically, does this bit of code need to go? I'm assuming it should be added to "WeaponHideAGun", but I'd like to be certain.
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Hanfling
MJ12
Posts: 406
Joined: Sun Oct 04, 2009 6:54 pm

Re: Stackable Weapon Mods in Inventory?

Post by Hanfling »

It should go nowhere. It was just to show for what is checked when you want to pick up single use weapons. So you should propbably set ReloadCount and/or PickupAmmoCount to 1 in defprops.
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.
User avatar
CorinthMaxwell
NSF
Posts: 79
Joined: Sat Oct 04, 2008 1:28 am

Re: Stackable Weapon Mods in Inventory?

Post by CorinthMaxwell »

Hanfling wrote:It should go nowhere. It was just to show for what is checked when you want to pick up single use weapons. So you should propbably set ReloadCount and/or PickupAmmoCount to 1 in defprops.
Bit of a delayed update......Editing those properties not only didn't work, but it turned the PS20 into a one-shot weapon that wasn't automatically discarded from the player's inventory or his hand. Even worse, I wasn't able to stack multiple PS20s in my inventory as I expected to be able to. As far as my little "improving the inventory" side project goes, this portion of it might be a lost cause. :?
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Post Reply