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.
ResetInventory
Moderator: GZDoom Developers
- 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
Can we get this for ZScript too?
Re: ResetInventory
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...Vaecrius wrote:Can we get this for ZScript too?
- 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
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.
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.
Re: ResetInventory
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.
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.
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.
- 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
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.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.
- 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
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)
...