Sami-Fire64

Veteran
Veteran
Joined
Sep 18, 2014
Messages
58
Reaction score
127
First Language
English
Primarily Uses
In my game there is a situation where I want the game to check and see if there are multiple items in the player's inventory. However, more than checking for all the items, there's also something like an or branch in there. Diagrammed, it would go something like this:

Check for: Item 1 and check for Weapon 1 OR Weapon 2 OR Weapon 3 and check for Armor 1 OR Armor 2.

I could have sworn I'd seen an option to check for multiple switches/variables/items in one go, but I can't remember where it is and the event tutorials I've checked don't seem to mention anything about it. Furthermore, the presence of those ors/alternate items makes it a bit trickier than just a straightforward "check everything." What should I do?

EDIT: On a related note, I want the game to check for the items and, if the player is missing an item and has lower than a certain amount of gold, give the player the missing item(s). How would I do that?
 
Last edited by a moderator:

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
118
Primarily Uses
I don't recall there's an option to check multiple things in one go via event command, or I wrong?

And what do you mean with item 1, what to do with it? I mean, does it should exist in inventory, than if yes go check the rest things and if not then just skip?

I believe you need a nested conditional branch to do this, you need to make a priority too. Then check it one by one from the top priority until the lowest, yes to achive this you need more work I'm afraid because you check three different things, also you need to give a handler for every false output(if it's necessary).

But, let'see if someone can help us  =')
 

Sami-Fire64

Veteran
Veteran
Joined
Sep 18, 2014
Messages
58
Reaction score
127
First Language
English
Primarily Uses
It's possible that I misremembered the multiple check option. Yes, that's just about right- I was going to have the game check for each item and skip to a message if one was missing. I did consider using a nested conditional branch for all of it, but that "or" segment up there makes things a bit tricky.
 

PencilCase27

So, I can write anything I want here... right?
Veteran
Joined
Jun 5, 2014
Messages
33
Reaction score
14
First Language
German
Primarily Uses
I'd recommend to learn a tiny little bit scripting:

We're going to create a script call you can insert to your conditional branch. First we need a module so the new method doesn't interfere with other stuff. This is optional but recomended:

module Sami_FireendThen we set up the method:

module Sami_Fire def self.checkmystuff endendNow you can call this method with Sami_Fire.checkmystuff. It won't do anything, but we'll change that.

The method to check the party inventory is called $game_party.has_item?(item, include_equipment). So we need to fill in the arguments "item" and "include_equipment".

item is the item, weapon or armor you're checking:

$data_items[x], $data_weapons[x], $data_armors[x] where x is the ID of that item/weapon/armor.

include_equipment is either true or false and determines if we want to check the plaers equipment or not. Obviously makes only sense for armor and weapons.

Now we have a way to check if the party has a single item. To link them we need the operators && (and) and || (or). Example:

$game_party.has_item?($data_items[1]) && $game_party.has_item?($data_items[2])

This will return true if yoou have both item 1 and item 2.

So how to implement it into the method?

Like this:

module Sami_Fire def self.checkmystuff return true if has_item_1 && has_item_2 return true if has_weapon_1 && has_weapon_2 && has_weapon_3 ... return true if has_armor_1 && has_item_1 return false endend(you have to replace the conditions with the $game_party.has_item?(item) method)

So what does it do? It will check if you have item 1 and 2. If yes, the method is happy and retuns true. If not, it will check if you have weapon 1 and weapon 2 and weapon 3. If yes, it returns true, else it continues checking. And at the end, when all the conditions are not met, it returns false, meaning that none of the above was true.

This is probably a little bit cryptic, but making stuff like this only with events is a pain, and minor scripting knowledge is always good to have :)

Feel free to ask any questions.

Edit: maybe I should give an example. Lets say you want to check if the party has item 1 and weapon 1 OR item 2 and weapon 2 OR armor 4:

Code:
module Sami_Fire    def self.checkmystuff    return true if $game_party.has_item?($data_items[1]) && $game_party.has_item?($data_weapons[1], true)    return true if $game_party.has_item?($data_items[2]) && $game_party.has_item?($data_weapons[2], true)    return true if $game_party.has_item?($data_armors[4], true)    return false  endend
 
Last edited by a moderator:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,870
First Language
English
Primarily Uses
RMVXA
Yeah, the best way to do this is with scripting, like PencilCase said.

If you don't want to use scripting but need to check several different conditions, you can do so with smart use of switches and/or variables.  For example, if you needed to check whether the player has Weapon (A OR B OR C OR D) and Armor (A OR B OR C) and Item (A OR B OR C):

Turn Switch 1 OFF

Turn Switch 2 OFF

Turn Switch 3 OFF

Turn Switch 4 OFF

Conditional Branch: If weapon A is in inventory:

    Turn Switch 1 ON

End

Conditional Branch: If weapon B is in inventory:

    Turn Switch 1 ON

End

Conditional Branch: If weapon C is in inventory:

    Turn Switch 1 ON

End

Conditional Branch: If weapon D is in inventory:

    Turn Switch 1 ON

End

Conditional Branch: If armor A is in inventory:

    Turn Switch 2 ON

End

Conditional Branch: If armor B is in inventory:

    Turn Switch 2 ON

End

Conditional Branch: If armor C is in inventory:

    Turn Switch 2 ON

End

Conditional Branch: If item A is in inventory:

    Turn Switch 3 ON

End

Conditional Branch: If item B is in inventory:

    Turn Switch 3 ON

End

Conditional Branch: If item C is in inventory:

    Turn Switch 3 ON

End

Conditional Branch: If Switch 1 is ON:

    Conditional Branch: If Switch 2 is ON:

        Conditional Branch: If Switch 3 is ON:

            Turn Switch 4 ON

        End

    End

End

If Switch 4 is ON:

    (Do whatever eventing should be done if all conditions are satisfied)

Else:

    (Do whatever eventing for if any conditions are NOT satisfied)

End

This will save you from the literal hundreds of nested branches you'd need to create if you tried to do it without "tracking switches".

With that being said, once again, if you can get used to the syntax that the game uses to check whether the player has a given item/weapon/armor, you can write the whole thing up in just a couple of lines.
 

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
118
Primarily Uses
Well, it looks like everybody suggest that scripting is the best idea. And yeah I agree with it. I can see that Pencilcase27 give a good solution for you =)

You need to place that script in new slot below Materials but above Main Process.

I recommend to modify the method so it takes arguments, so you don't need to create so many checking, this will also escaping you from the nested check, creating one by one speficic item weapon or amor to be checked is the same like nested conditional branch check itself, and it just relocate the place in where you do the nested check into the script itself. I mean it still you need to create one by one what specific item is what specific armor and what specific weapon to be checked, and that's totally not esacping you from nested check.

I modify the script a bit. So you don't need to mess with script editor again.

Put this script in a new slot below Material above Main Process.

module SamiFire def self.checkmystuff(item = nil, weapon = nil, armor = nil) if item && weapon && armor return true if $game_party.has_item?(item) && $game_party.has_item?(weapon, true) && $game_party.has_item?(armor, true) elsif item && weapon return true if $game_party.has_item?(item) && $game_party.has_item?(weapon, true) elsif item && armor return true if $game_party.has_item?(item) && $game_party.has_item?(armor, true) elsif weapon && armor return true if $game_party.has_item?(weapon, true) && $game_party.has_item?(armor, true) else return false end endend # End of module SamiFirenow example call :

1.checking player inventory has potion and sword(or whatever weapon that id is 1)

SamiFire.checkmystuff($data_items[1], $data_weapons[1])

NOTE : Armor in third argument is not mandatory.

2. checking player inventory has potion and casual clothes(casual clothes id is 1 in armor database)

SamiFire.checkmystuff($data_items[1], nil, $data_armors[1])

NOTE : Because the armor is third argument, means we need to pass argument for weapon because it's the second argument, just past it with nil.

3. checking player inventory has sword and casual clothes

SamiFire.checkmystuff(nil, $data_weapons[1], $data_armors[1])

NOTE : first argument must be set to nil, because we want to pass the second argument(weapon) and third argument(armor).

4 cheking player inventory has potion and casual clothes and sword (all stuffs  is index 1 in their database)

SamiFire.checkmystuff($data_items[1], $data_weapons[1], $data_armors[1])

NOTE : Pass all arguments item, weapon and armor

SPECIAL NOTE : you notice that the fourth script call is a very long line huh, and the damn script box is really suck in size, it might not fit(I can't check it because when I write this post I'm not in situation where I can open VXAce, sorry) So you may want to rename your method or module into short name.

That's all. Hope this helps, sorry if I did something wrong, I'm not checking the script above.
 
Last edited by a moderator:

Sami-Fire64

Veteran
Veteran
Joined
Sep 18, 2014
Messages
58
Reaction score
127
First Language
English
Primarily Uses
Thanks, guys! I figured I'd have to encounter scripting with this... I'll test it out later and let you know if anything comes up that shouldn't.
 

PencilCase27

So, I can write anything I want here... right?
Veteran
Joined
Jun 5, 2014
Messages
33
Reaction score
14
First Language
German
Primarily Uses
@BoluBolu: What about this

def self.check_all(items, weapons, armors) p = $game_party items.each { |id| return false if !p.has_item?($data_items[id]) } weapons.each { |id| return false if !p.has_item?($data_weapons[id], true) } armors.each { |id| return false if !p.has_item?($data_armors[id], true) } return true endExample: Check for item 1 and 2 and for armor 3, 4 and 7.

Code:
Sami_Fire.check_all([1,2], [], [3,4,7])
 

Ralpf

Veteran
Veteran
Joined
Jun 5, 2014
Messages
590
Reaction score
153
First Language
English
Thanks, guys! I figured I'd have to encounter scripting with this... I'll test it out later and let you know if anything comes up that shouldn't.
You don't have to use scripting, I just did something similar with my game. Scripting would just be easier if you have to do this multiple times and especially if you have more then 3 switches/variables to consider (the more you have to consider the more work and more chance of screwing it up using conditional branches. {look in spoiler}).

IF A

  IF B

     IF C

     DO ABC

     ELSE DO AB

  ELSE IF C

  DO AC

  ELSE DO A

ELSE IF B

  IF C

  DO BC

  ELSE DO B

ELSE IF C

DO C

And just imagine that with a 4th variable. It may be be incorrect, just an illustration to show how complicated it could get with more then a few variables
Scripting is probably the best way to do it. Doubly so since they have given you so stuff to use.
 
Last edited by a moderator:

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
118
Primarily Uses
@PencilCase27

That's very good =). One thing is, Sami need to understand about passing an array, but that's not really a problem, we hope he knows, aside from that, it's pretty much looks nice.
 

Sami-Fire64

Veteran
Veteran
Joined
Sep 18, 2014
Messages
58
Reaction score
127
First Language
English
Primarily Uses
Now that I actually have time to sit down and take a close look at the scripts... I'm not 100% sure what I'm doing. PencilCase27, in your most recent script, do I have to fill in those ids, or will filling them in in the script call you have listed in your example work? (I'm going to test it right now so I'll probably be editing this post shortly.) If not, what do I put in the id spaces in the script?

EDIT: Not quite sure what I did wrong here... when the player doesn't have the items on hand, it works just fine. However, when the player has bought all three items (a potion, a weapon, and armor) the game acts like there's still missing items. I don't know if I used the wrong version of the script or botched the script call to make the game think all the listed items are needed. The script call I used is this:

MultiItemCheck.check_all([1], [1,7,19], [1,2])I used the most recent script from PencilCase27 posted up there. I'm thinking I may have to use one of the other versions.
 
Last edited by a moderator:

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
118
Primarily Uses
yes, you need to fill the item id, weapon id, and armor id in a bracket.

example : want to check have potion and hi potion, the id in item databas is 1 and 2,

 so

Sami_Fire.check_all([1,2], [ ],[ ])

what you need to understand is, you must passing the argument(which is the item id) inside a square bracket [ ],

the first argument is for item, the second is for weapon, and the last(third) is for armor. If you didn't want to check specific item, i.e you only want to check item and weapon, so armor does not need check, just pass empty bracket at the armor argument(third argument, like this [ ].

 example check potion and sword which id is 1 for potion and sword(or whatever weapon it is, i think it's Hand Ax) which id also 1 then :

Sami_Fire.check_all([1], [1 ],[ ]) 

Remember to name your module into Sami_Fire.
 

Sami-Fire64

Veteran
Veteran
Joined
Sep 18, 2014
Messages
58
Reaction score
127
First Language
English
Primarily Uses
I think that's what I did in the script call. What might have happened is that the game isn't looking for potion AND Weapon 1 or 2 or 3 AND Armor 1 or 2 but for all of the items to be present. How do I put an or condition back in there so that the player only needs one potion, one of any of the weapons, and one of any of the armors to advance?
 

PencilCase27

So, I can write anything I want here... right?
Veteran
Joined
Jun 5, 2014
Messages
33
Reaction score
14
First Language
German
Primarily Uses
I almost thought that this was a little bit confusing, sorry about that. Here's what happend

In your op you asked for a way to check for multiple items with multiple branches, eg. player has item 1 and either weapon 1 or armor 1.

Then, in my first post, I described a way to do this with one conditional branch in your event, and this event has one script call that checks for everything. The script would look like this:

module Sami_Fire def self.check_stuff_1 return true if $game_party.has_item?($data_items[1]) && $game_party.has_item?($data_weapons[1], true) return true if $game_party.has_item?($data_items[1]) && $game_party.has_item?($data_armors[1], true) return false endendAnd the event would look like this (notice how this script call doesn't has any arguments, it will always check for the same items):

Conditional Branch: Script: Sami_Fire::check_stuff_1

  # do what happens if the conditions are met

else

  # do something else

Now BoluBolu suggested annother solution: Instead of one script call for each check, we create one script call that takes arguments and then checks if you have all of the given items, and then we make the different branches inside of the event. The script would be the same I posted in my last post, and the event would be like this:

Conditional Branch: Script: Sami_Fire::check_all( [1], [1], [] )

  # do what happens if the conditions are met

else 

  Conditional Branch: Script: Sami_Fire::Check_all( [1], [], [1] )

    # do what happens if the conditions are met

  else

    # do something else

This means my first post is all about solution 1, while my previous post is for solution 2. Now you have to choose which one of those methods you like more.
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Two more portraits and I'll be done with the Ace cast. Any requests for the next batch?
jeetje, you are told to read forums and learn about them before you post, cmon ppl, it is impossible?
plugin for this, plugin for that, i should probs just buy all the visustella plugins lol
Hey you know that problem I had with my old project file? I figured out what went wrong, so I fixed it there! Now I don't need this new file! *deletes*

......

*remembers I made good changes on it and did not write those changes down elsewhere*

.....Well ****.

Forum statistics

Threads
121,524
Messages
1,142,276
Members
159,686
Latest member
zDreemss
Top