Hello everyone!
I want to know is there a way to give the player all inventory items they don't have? I'm making my own debug system because I will be using it as a cheats mechanic later on after the game is finished.
Any help would be greatly appreciated!
Whenever you want to process all entities of category at once, you need two things: find an array these entities are stored in, and use the loop operator.
For example, character has InventoryQuantity array that stores how many of each item does he has:
for (int i = 0; i < Game.InventoryItemCount; i++)
{
if (player.InventoryQuantity[i] == 0)
player.InventoryQuantity[i] = 1;
}
UpdateInventory();
Alternate variant, but I think it may be slower. I am posting it for the sake of mentioning "inventory" array only. "inventory" array holds all inventory item references existing in game.
for (int i = 0; i < Game.InventoryItemCount; i++)
{
InventoryItem *inv = inventory[i];
if (!player.HasInventory(inv))
player.AddInventory(inv);
}
Thanks CW! The alternative worked for me.
I actually asked this exact question on Discord a few weeks ago. I ended up making a pigs ear of my attempt. I'll try this method, CW.
My plan is to have a separate ‘debug' inventory filled with all items in it which I can bring up anywhere in the game and give the player character only specific items he needs rather than everything.