FF6 Hacking
Checking inventory for an item - Printable Version

+- FF6 Hacking (https://www.ff6hacking.com/forums)
+-- Forum: Discussion Forums (https://www.ff6hacking.com/forums/forum-5.html)
+--- Forum: Magitek Research Facility (https://www.ff6hacking.com/forums/forum-9.html)
+--- Thread: Checking inventory for an item (/thread-3920.html)



Checking inventory for an item - Morendo - 12-30-2019

Hi everyone! I have another question, this time regarding Event programming. I had the idea to incorporate a sort of Synthesis Shop that turns items into other items. Here's what I have so far! 

In this example, by giving 200gp and a Hi-Ether to a merchant, the player will receive an Elixir. The simplest way I could figure to do this was to create an NPC who performed only this single function. The code looks as follows:
Code:
4B 01 00 [display text box with a "No/Yes to continue" choice]
B6 78 98 02 83 98 02 [if no, then return. If yes, then proceed]
85 C8 00 [take 200 GP from party]
C0 BE 81 [check event bit 1BE to see if party has enough GP. If not...]
FF 69 01 [display text box "not enough GP..." and return]
81 ED [take Hi-Ether from inventory]
????
80 EE [Give Elixir to inventory]
FE [return]
As you can see, I'm hoping there is something we can place in the spot of the question marks that checks whether or not the Hi-Ether is in the player's inventory, and if not will display a text box saying "not enough items" and return. As it stands now, the game will take the Hi-Ether if it sees it, but if you don't have one it just continues on with the code giving you an Elixir anyway. 
I'd say a way to do it is to set an event bit when you receive a Hi-Ether in your inventory, but how would you even turn it off if you drink it in battle, sell it, etc, so that doesn't seem like a realistic option. Is there a way to do this that I'm missing? 
Thank you in advance for any assistance. I appreciate it!


RE: Checking inventory for an item - Everything - 12-31-2019

I don't think there is a quick way to do that using only the vanilla event script commands. You could try creating a new command if you are up for the challenge of writing a little bit of assembly code.


RE: Checking inventory for an item - madsiur - 12-31-2019

Yeah I would go with Everything's idea. There's a few unused event commands, it's not really hard to make a command that would check an item quantity and branch in the event code based on the fact that it's zero quantity or one or more. You can take the dialogue branching command and item commands a bit as ways to understand how to do this.