Checking item cost and other things

Psyche Radio

PsyRad
Member
Joined
Apr 21, 2019
Messages
8
Reaction score
1
First Language
Hungarian
Primarily Uses
RMMV
Hi, semi-lurker here.
For a while I've been struggling to make a small bargain system where in battle you could use a "tribute" skill to trade any item and depending on it's value, the enemy would abort battle and leave you alone. However, for that I'd need to check the price of the items, as well as if the party has any (regular) items in the first place and so far I've found no way to actually check those values.
:kaoswt2:

Are there any script calls or the likes to check those two values? Don't really want to abandon this game mechanic.
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
165
First Language
English
Primarily Uses
RMMV
The data of items are stored in three arrays, these are:
$dataItems
$dataWeapons
$dataArmors

The price of let's say, item 5, is stored in $dataItems[5].price

The [5] is the item ID, so if it is armor 11 it would be $dataArmors[11].price

So if you want to do a conditional branch you can do it with that variable with the regular checks. Like $dataItems[5].price < 100

You can also set a game variable to an items price by using Control Variables, the operand Script and simply entering $dataItems[5].price

I'm guessing you're asking how to check if the party has any regular items at all, correct me if I'm wrong.
Then this returns true if the party has items in the inventory: Object.keys($gameParty._items).length > 0

Maybe this helps :rock-right:
 
Last edited:

Psyche Radio

PsyRad
Member
Joined
Apr 21, 2019
Messages
8
Reaction score
1
First Language
Hungarian
Primarily Uses
RMMV
Ah! Thanks, $dataItems[var].price did work. :kaophew:

Also yeh, that's what I mean. But the code didn't work. :v
I need it specifically to be regular items, and regular items only because the skill still shows up when I have any other item with me. (though I am also using Yanfly's Skillcore so its most likely me just not understanding how to use the plugin)
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
165
First Language
English
Primarily Uses
RMMV
That's odd, Object.keys($gameParty._items).length > 0 works for me, and it's for regular items. Are you using it in a conditional branch?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
394
Reaction score
212
First Language
English
Primarily Uses
RMMV
I'm assuming you mean regular items as in the selection between regular item/hidden item/key item etc. If so you could use something like this:

Code:
$gameParty.items().filter(function(item) {return item.itypeId === 1}).length > 0
 

Psyche Radio

PsyRad
Member
Joined
Apr 21, 2019
Messages
8
Reaction score
1
First Language
Hungarian
Primarily Uses
RMMV
@ozubon I am using scripts inside a notetag.

@Silva Thanks, that worked! And yeah I did mean that.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Playtesting for Battle Castle is done, demo time for me was roughly 6 hours and 20 minutes. I'm going to pass it on to a few friends first, and after getting some feedback will be posting an official topic.
There's another Humble Bundle available now for RPG developer assets, this time focused somewhat more towards pixel art style games.
Ive got a long lost half uncle. Thats real cool.
I forget what is bumping rule in this forum. Is anyone know? Thank you.
BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?

Forum statistics

Threads
97,909
Messages
947,782
Members
129,148
Latest member
lemminace
Top