I want to make a quest that the player needs to get VARIABLE number of items but in the events commands the only condition about items is "If: party has item". How do I set it to check if the party has X amount of certain item?
How do I set # of items as a condition?
RPG Maker MZ SupportYou could set a variable to the number of items, then check the variable.
The simplest way would be to have a variable add 1 (or whatever number) each time they collect one, then check that variable. There is probably also a script call you could use, I just don't know it off the top of my head. Here's the script call reference:
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mz-script-call-reference.122501/
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mz-script-call-reference.122501/
I though a simple condition for quests would be native from the system. Since I have no idea how to use variables I'll add a Control Variable for when the player collects the item. IT's gonna be messy in the variables table, but who cares hehe.
EDIT: I meant to say that i don't know how to use scripts.
No need - that means you'd need one variable for every item that you need to collect multiples of (and what if the player can buy or sell them)? Just because you haven't used variables before doesn't mean you have to avoid them.
Control Variables > Game Data > Item [X]
Conditional Branch > Variable >= required number
This will let you have a single variable that you can use for all sorts of things, because you're setting it then using it in a condition immediately in the same event. It doesn't matter if something else changes its value later because you have no need for it anymore.
It's easy. Be brave 😀
Control Variables > Game Data > Item [X]
Conditional Branch > Variable >= required number
This will let you have a single variable that you can use for all sorts of things, because you're setting it then using it in a condition immediately in the same event. It doesn't matter if something else changes its value later because you have no need for it anymore.
It's easy. Be brave 😀
Variables and switches are the foundation of making a game in an RPG Maker engine. If you really don't understand them, you need to spend some time with some tutorials and get a grasp on these basics.
It's expected you will use a lot of variables, so name them well so you know their purpose.
edit: Nevermind, I thought the Game Data only told you if the item was in inventory, not how many. I need to brush up on my game making, it seems.
It's expected you will use a lot of variables, so name them well so you know their purpose.
edit: Nevermind, I thought the Game Data only told you if the item was in inventory, not how many. I need to brush up on my game making, it seems.
Or run this script in Condition Branch, script tab:
$gameParty.numItems($dataItems[1]) >= 10
//that will check if party has at least 10 of item 1
$gameParty.numItems($dataItems[1]) >= 10
//that will check if party has at least 10 of item 1
Oops, I meant to say Scripts, hehe. I know how to use variables and switches. I already have set the quest but I encountered another problem but I can figure it later!
I just don't like to have too much switches and variables because i will start with 1, 2, 3 ,4 and then I'll have to use 71,72,73 because I was using the other for something else. I hate that you can't really automatically reorganize the variables.
I just don't like to have too much switches and variables because i will start with 1, 2, 3 ,4 and then I'll have to use 71,72,73 because I was using the other for something else. I hate that you can't really automatically reorganize the variables.
Since the variable is only used temporarly to store data for a conditional branch and is not needed afterwards, you can reuse it again and again without needing to assign new ones.
Only if the Variable is supposed to remember a Value for later usage, than you cant reuse the Variable.
In your case it looks like you can just reuse them.
Only if the Variable is supposed to remember a Value for later usage, than you cant reuse the Variable.
In your case it looks like you can just reuse them.
Oh I'm using one for the Quest, but I had to create one for each item and one switch for each item because the quest is random. I don't really like having a lot of variables and switches because I can't "easily" reorganize them.
If I need/want to rearrange them to make it more Tidy and clean I would need to check every single event and change it.
Based on these requirements. There is one solution.
Use two variables (or one might be enough). One for the item ID, one is to store the value of how many the item is.
For example, your quest gives you a task to collect a random item, say, that the item is randomized and you get to collect slime gel. The slime gel item id is 5, then you store the id (which is 5) in a variable. Then to check how much slime gel you have by using script call.
For example, you store the ID in variable 70
Code:
$gameParty.numItem($dataItems[$gameVariables.value(70)])
With reuse of Variable i mean something like in this dirty example:
◆Control Variables:#0001 Var1 I know amount of 999 Items = The number of Potion
◆If:Var1 I know amount of 999 Items ≥ 1
◆Text:None, Window, Bottom
: :1 Potion thank you
◆Change Items:Potion - 1
◆
:Else
◆Text:None, Window, Bottom
: :1 Potion is missing.
◆
:End
◆Control Variables:#0001 Var1 I know amount of 999 Items = The number of Magic Water
◆If:Var1 I know amount of 999 Items ≥ 1
◆Text:None, Window, Bottom
: :1 Magic Water thank you
◆Change Items:Magic Water - 1
◆
:Else
◆Text:None, Window, Bottom
: :1 Magic Water is missing.
◆
:End
◆Control Variables:#0001 Var1 I know amount of 999 Items = The number of Potion
◆If:Var1 I know amount of 999 Items ≥ 1
◆Text:None, Window, Bottom
: :1 Potion thank you
◆Change Items:Potion - 1
◆
:Else
◆Text:None, Window, Bottom
: :1 Potion is missing.
◆
:End
◆Control Variables:#0001 Var1 I know amount of 999 Items = The number of Magic Water
◆If:Var1 I know amount of 999 Items ≥ 1
◆Text:None, Window, Bottom
: :1 Magic Water thank you
◆Change Items:Magic Water - 1
◆
:Else
◆Text:None, Window, Bottom
: :1 Magic Water is missing.
◆
:End
Got ya, but There's a problem, first the NPC event (NPC) checks which day is it (var DAY), after that it rolls on the SUPply var (SUP) to decide which item he needs. So I have to have one page for each demand he has, which means one var per item and one switch per item.
You mentioned two variables.
Why one page each demand? can you just use multiple conditional branches?
I don't know why my solution is not solving your problem
I don't remember if it's at all possible, directly.
one time I had to do something similar, and I solved it by adding 1 to a variable every time an item was obtained.
since it's for quests, and you control the narrative, it's easier that way.... for checking it, you just check the variable >= X, since the variable can only increase by getting the items, which can't be reacquired, because the narrative only goes forward.
one time I had to do something similar, and I solved it by adding 1 to a variable every time an item was obtained.
since it's for quests, and you control the narrative, it's easier that way.... for checking it, you just check the variable >= X, since the variable can only increase by getting the items, which can't be reacquired, because the narrative only goes forward.
You could make use of a Plugin that creates Self Variables for Events.
With Event Scriptcommand you can even change the Self Variables of other Events even on other Maps. Self Variables are like Self Switches, the Events will be able to store all Data you now got in Global Variables.
hakuenstudio.itch.io
For example:
You turn 1 Global Variable into a Self Variable for Events.
That can than be used for hundrets if not thousands of Events through the whole Game to keep track how Friendly the NPC is towards the Hero. Normaly you would need 1 Global Variable for each NPC,
this Scripts adds something that is so awesome that it should be by default in rpg Maker =).
Edit:
Yanfly had a same looking one in the past for MV, not sure if there are alternative plugins for MZ.
Not sure, but maybe this helps?
With Event Scriptcommand you can even change the Self Variables of other Events even on other Maps. Self Variables are like Self Switches, the Events will be able to store all Data you now got in Global Variables.
Hakuen Studio Self Variables for RPG Maker MZ by Hakuen Studio
Fully integrated Self Variables with the default event commands!
hakuenstudio.itch.io
For example:
You turn 1 Global Variable into a Self Variable for Events.
That can than be used for hundrets if not thousands of Events through the whole Game to keep track how Friendly the NPC is towards the Hero. Normaly you would need 1 Global Variable for each NPC,
this Scripts adds something that is so awesome that it should be by default in rpg Maker =).
Edit:
Yanfly had a same looking one in the past for MV, not sure if there are alternative plugins for MZ.
Not sure, but maybe this helps?
only if you need to store a value for many uses it would need a dedicated variable.
for simple checks you can designate a few variables and switches for TEMP use (just name them TEMP1 to TEMP5 or whatever). Then you can use them for whatever you want and just have to remember that they should not store data, just get it from game data before the conditional branch command checks that data.
that way even a single variable can check multiple game data values, just by a sequence of control variable (for setting the temp value) and then conditional branch for checking it.
Well I use a script that let me set more conditions, which helps keeping it organized. The plan is not having 3 or 4 different types of quests, but, up to 75 and I really like to keep things organized and streamlined.
Well the variables for the quest is just two, but I need to have variables for each item so I can compare that to the quest one since I can't compare the variable to the number of items.
why not? that sentence doesn't really make sense, so I assume you go at it in a complicated roundabout way instead of doing this directly.
Show us a screenshot how you plan to use the variables and we can check it for problems.
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Of course this is not the whole thing completed, just me testing the thing. It works. I don't see how I can make it more organized, tho.
I also need to implement the "one quest per day" part, but that's not what is concerning me.
Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-set-of-items-as-a-condition.133080/