Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Variable for player inventory.

Selvalanch

Villager
Xy$
0.00
I want to save the player inventory in variable. the goal is to make a system when player failed the quest map or decide to retire. player inventory will reset back to where before they start a quest and lost all item they gather in a map. keep only exps and levels.

Is it possible to do this?
 

Zarsla

Villager
Xy$
0.00
This can be done with eventing. You need 2 variables for every item you want.
For this example I'll uses variables 7-12, with items Potion, Ether & bombs.

These are the variables

Variable 7 = Potion Before
Variable 8 = Potion After
Variable 9 = Ether Before
Variable 10 = Ether After
Variable 11 = Bombs Before
Variable 12 = Bombs After.

On the event that gives the quest. After the quest is given and accepted (ie the player says yes)
Go to control variable and set Variables 7,9, & 11. To game data number of items in inventory.
ie variable 7 is set to the number of potions the party has, and variable 9 is set to the number of ethers the party has.

On the event where you check if the quest is completed or not.
Under where the quest failed check is run and returns true.
Set variables 8,10 & 12 to game data number of items in inventory.
ie variable 8 is set to the number of potions the party has, and variable 10 is set to the number of ethers the party has.

Now then set up variables 8,10 & 12 to do some math.
Variable 8 is going to be set to subtract varable 7.
Variable 10 is going to be set to subtract varable 9.
Variable 12 is going to be set to subtract varable 11.
Basically make it where the after variables subtract the before varables.
Now open up the change item command.
In the change item command pick each item, ie pick the potion and set it to decrease by the after varable.
Ie potion should be the item you pick, select decrease by variable, and the variable you pick is varisble 8.
Now do this for all the items you have and done.

For more info on how to use variables try this video.
 

Zarsla

Villager
Xy$
0.00
That depends.
You could do this as a pair of common events.
Event 1 would do the first part ie the stuff that happens when you give the quest.
While Common Event 2 would do the other stuff.
Then you call common event 1 when you give a quest and common event 2 when you fail it.

Thus items that change would be altered and those thst didn't wouldn't.
Also I forgot to mention when you do the part that runs when you fail, you need to place a conditional branch after you set the second set of variables. The branch is going to check if the variable after is greater than variable before, if it is then it'll change the item, if not it won't.

This is so you don't end up taking away negative items (which gives items to the player).
 
Top