Keeping items between episodes?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Keeping items between episodes?

Postby Doominer441 » Tue Apr 06, 2021 7:34 pm

I'm honestly not expecting there to be a real way to do this, but is there any way to make inventory items persist between episodes, or at least track them to be given at the start of the next episode?
User avatar
Doominer441
 
Joined: 24 Oct 2013

Re: Keeping items between episodes?

Postby Cherno » Tue Apr 06, 2021 8:02 pm

You should be able to make the playerpawn class have an array of a custom class which in turn represents an inventory by name and amount, and you could fill this array based on the carried items before exiting a map, and then ading them to the playerpawn in the new episode.
User avatar
Cherno
 
Joined: 06 Dec 2016

Re: Keeping items between episodes?

Postby Doominer441 » Tue Apr 06, 2021 9:40 pm

How exactly would I go about doing that?
User avatar
Doominer441
 
Joined: 24 Oct 2013

Re: Keeping items between episodes?

Postby Graf Zahl » Thu Apr 08, 2021 7:05 am

Starting a new episode means starting a new game - so obviously everything gets reset. The only really feasible way to carry over the items is to change the exit destinations of each episode's final map to the next episode's first map so that you turn it into one continuous game.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Keeping items between episodes?

Postby Doominer441 » Thu Apr 08, 2021 7:11 am

Even through the array method? Because Ive managed to create a script which should theoretically add the certain items I want to persist to an array, and then be able to dump it back into the player’s inventory. With this being part of a library, starting a new episode would reset this array too?

Code: Select allExpand view
#library "KEYKPR"
#include "zcommon.acs"
//str keyarray[3] = { "UnmakerRune1", "UnmakerRune2", "UnmakerRune3" };
//int playerkeys[3];

#define TOTAL_ITEMS 3

str items[TOTAL_ITEMS] = { "UnmakerRune1", "UnmakerRune2", "UnmakerRune3" };

int playerstock[8][TOTAL_ITEMS];

Script "STORE_INVENTORY" (VOID)
{
   for (int i=0; i<TOTAL_ITEMS; i++)
   {
      if (CheckInventory(items[i]))
      {
         playerstock[PlayerNumber()][i] = Checkinventory(items[i]);
      }
      else
      {
         playerstock[PlayerNumber()][i] = FALSE;
      }
   }
}

Script "REMOVE_INVENTORY" (VOID)
{
   for (int i=0; i<TOTAL_ITEMS; i++)
   {
      if (CheckInventory(items[i]))
      {
         TakeInventory(items[i], playerstock[PlayerNumber()][i]);
      }
   }
}

Script "REPLACE_INVENTORY" (VOID)
{
   for (int i=0; i<TOTAL_ITEMS; i++)
   {
      if (playerstock[PlayerNumber()][i])
      {
         GiveInventory(items[i], playerstock[PlayerNumber()][i]);
      }
   }
}


This is what I made (read: Cobbled together from other scripts). This wouldn't keep items between episodes?
User avatar
Doominer441
 
Joined: 24 Oct 2013


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest