Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: bx83 on Wed 12/05/2021 01:13:16

Title: How do you know, in script, if an inventory item is marked PlayerStartsWithItem?
Post by: bx83 on Wed 12/05/2021 01:13:16
I'm trying to add/remove ONLY items that a player starts with, however InvWindow, Inventory, Game, player.Inventory* etc. doesn't contain a function to check for this, or a property.
How do I do the following (pseudocode):

//add all 'starts game with' items back to empty inventory
for (int x=1; x<=Game.InventoryItemCount; x++) {
  if (player.InventoryItemStartsWith[x])
    player.InventoryQuantity=1;   
}
Title: Re: How do you know, in script, if an inventory item is marked PlayerStartsWithItem?
Post by: Crimson Wizard on Wed 12/05/2021 01:39:14
There's no way to do this as far as I know, but you may remember which items are in inventory at startup.

Code (ags) Select

int startingItems[MAX_INV];

function game_start()
{
    for (int i = 0; i < Game.InventoryItemCount; i++) {
        startingItems[i] = player.InventoryQuantity[i];
    }
}


Then you simply copy startingItems to player.InventoryQuantity backwards.