ResetInventory

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
Jimmy
 
 
Posts: 4720
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

ResetInventory

Post by Jimmy »

An ACS command to set the player's inventory as though they'd just started a new game.

For when ClearInventory, plus a bunch of GiveInventorys for stuff like the fist and pistol, is not preferable, in cases like wanting maximum weapon mod compatibility.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: ResetInventory

Post by Matt »

Can we get this for ZScript too?
User avatar
AFADoomer
Posts: 1325
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: ResetInventory

Post by AFADoomer »

Vaecrius wrote:Can we get this for ZScript too?
Ed the Bat implemented a ZScript equivalent of this in Blade of Agony. It's set up as an event handler to run on level entry for BoA, but could easily be tweaked. See the BoAEventHandler file here. Line 8-58 essentially do what you're asking, using the player's StartItem list as reference for what to set the inventory as...
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: ResetInventory

Post by Ed the Bat »

I realized a little while after implementing it that it could be made slightly more efficient. I didn't get around to putting it in BoA, though; felt a little awkward anymore about getting my hands in that pot...

Instead of checking AllActorClasses as I did there, checking the player's inventory alone would suffice for finding items to strip away, and should be marginally less work for the engine. I think (if my memory serves; it's getting fuzzy lately...) I implemented the revision for this script in the Git edition of Stronghold, if you need a reference.
User avatar
Rachael
Posts: 13561
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: ResetInventory

Post by Rachael »

Despite the fact that it exists in ZScript, having a native function would be much faster by a factor of 10's if not 100's. Though you really should not be calling a function like this very often to start with. :twisted:

At any rate, I want to see how Graf feels about this. If I had to guess, it might be as simple as exposing a simple C++ function to ZScript since it's already done internally by the engine, anyhow. But this opens a can of worms - inevitably everything that gets exposed to ZScript will eventually require parameters because someone wants additional functionality, and then the function will have to be extended, and then, and then, and then.....

So I will wait to see what Graf thinks before I attempt something like this.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: ResetInventory

Post by Matt »

Ed the Bat wrote:Instead of checking AllActorClasses as I did there, checking the player's inventory alone would suffice for finding items to strip away, and should be marginally less work for the engine.
How would you do that? All I can work out is a ThinkerIterator that checks for inventory and owner and destroying whatever meets those criteria.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: ResetInventory

Post by Ed the Bat »

An example taken from the Backpack, gzdoom.pk3/zscript/inventory/ammo.txt

Code: Select all

// Since you already have a backpack, that means you already have every
// kind of ammo in your inventory, so we don't need to look at the
// entire PClass list to discover what kinds of ammo exist...
...
for (let probe = Owner.Inv; probe != NULL; probe = probe.Inv)
...
Post Reply

Return to “Feature Suggestions [GZDoom]”