Stackable Weapon Mods in Inventory?
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Stackable Weapon Mods in Inventory?
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
Batman: o_0 O_0 o.0 O.0
Re: Stackable Weapon Mods in Inventory?
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.
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
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.
-- 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
Batman: o_0 O_0 o.0 O.0
Re: Stackable Weapon Mods in Inventory?
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.
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
And it doesn't.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.
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
-- 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'
-- 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
Batman: o_0 O_0 o.0 O.0
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
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.
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.
Code: Select all
Critical Error: WeaponModScope01_NYC_UNATCOIsland.WeaponModScope0 (Function DeusEx.WeaponMod.DestroyMod:0000) Infinite script recursion (250 calls) detected
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
Batman: o_0 O_0 o.0 O.0
Re: Stackable Weapon Mods in Inventory?
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.
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
At last, my little experiment finally works.
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......
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......
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
Batman: o_0 O_0 o.0 O.0
-
- Illuminati
- Posts: 2284
- Joined: Thu Mar 08, 2012 3:21 am
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
Go right ahead.Cybernetic pig wrote:Cool. Mind if I use this for my mod?
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Batman: o_0 O_0 o.0 O.0
-
- Illuminati
- Posts: 2284
- Joined: Thu Mar 08, 2012 3:21 am
Re: Stackable Weapon Mods in Inventory?
For PS20...
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.
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));
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.
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
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.Hanfling wrote:For PS20...
PersonaInventoryItemButton.DrawWindow()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));
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.
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Batman: o_0 O_0 o.0 O.0
Re: Stackable Weapon Mods in Inventory?
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.
- CorinthMaxwell
- NSF
- Posts: 79
- Joined: Sat Oct 04, 2008 1:28 am
Re: Stackable Weapon Mods in Inventory?
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.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.
Robin: "Holy flying snotburgers, Batman!"
Batman: o_0 O_0 o.0 O.0
Batman: o_0 O_0 o.0 O.0