Author Topic: How to give player all items without debug [SOLVED]  (Read 199 times)

Stranga

  • Beer Potion!
    • I can help with making music
    •  
    • I can help with story design
    •  
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!
« Last Edit: 25 Jan 2018, 13:26 by Stranga »
Yo.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: How to give player all items without debug
« Reply #1 on: 25 Jan 2018, 13:17 »
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:
Code: Adventure Game Studio
  1. for (int i = 0; i < Game.InventoryItemCount; i++)
  2. {
  3.     if (player.InventoryQuantity[i] == 0)
  4.         player.InventoryQuantity[i] = 1;
  5. }
  6. UpdateInventory();
  7.  

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.
Code: Adventure Game Studio
  1. for (int i = 0; i < Game.InventoryItemCount; i++)
  2. {
  3.     InventoryItem *inv = inventory[i];
  4.     if (!player.HasInventory(inv))
  5.         player.AddInventory(inv);
  6. }
  7.  
« Last Edit: 25 Jan 2018, 13:20 by Crimson Wizard »

Stranga

  • Beer Potion!
    • I can help with making music
    •  
    • I can help with story design
    •  
Re: How to give player all items without debug
« Reply #2 on: 25 Jan 2018, 13:25 »
Thanks CW! The alternative worked for me.
Yo.

Stupot

    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: How to give player all items without debug [SOLVED]
« Reply #3 on: 26 Jan 2018, 00:42 »
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.