Page 1 of 1

Keeping items between episodes?

PostPosted: Tue Apr 06, 2021 7:34 pm
by Doominer441
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?

Re: Keeping items between episodes?

PostPosted: Tue Apr 06, 2021 8:02 pm
by Cherno
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.

Re: Keeping items between episodes?

PostPosted: Tue Apr 06, 2021 9:40 pm
by Doominer441
How exactly would I go about doing that?

Re: Keeping items between episodes?

PostPosted: Thu Apr 08, 2021 7:05 am
by Graf Zahl
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.

Re: Keeping items between episodes?

PostPosted: Thu Apr 08, 2021 7:11 am
by Doominer441
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?