ResetInventory

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

Moderator: GZDoom Developers

ResetInventory

Postby Jimmy » Wed Jul 19, 2017 6:58 am

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.
Jimmy
I picked a fine day to be lactose intolerant
 
 
 
Joined: 10 Apr 2006
Location: Perth, WA
Discord: Jimmy#4100
Twitch ID: JimmySquared

Re: ResetInventory

Postby Matt » Sun Jul 23, 2017 3:42 pm

Can we get this for ZScript too?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: ResetInventory

Postby AFADoomer » Sun Jul 23, 2017 3:57 pm

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
AFADoomer
 
Joined: 15 Jul 2003

Re: ResetInventory

Postby Ed the Bat » Sun Jul 23, 2017 4:24 pm

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
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Re: ResetInventory

Postby Rachael » Sun Jul 23, 2017 5:10 pm

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
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: ResetInventory

Postby Matt » Sun Jul 30, 2017 3:00 pm

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
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: ResetInventory

Postby Ed the Bat » Sun Jul 30, 2017 3:16 pm

An example taken from the Backpack, gzdoom.pk3/zscript/inventory/ammo.txt
Code: Select allExpand view
// 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)
...
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest