Morizel

Veteran
Veteran
Joined
Sep 28, 2018
Messages
112
Reaction score
8
First Language
Russian
Primarily Uses
RMMV
I have some questions about equipment checks via events and scripts. Like, how to check the equipment slot of all active party members? I mean, how to check that all party members are "naked" (wears no equipment)?

Because I know how to check the equipment slot of a specific actor.
$gameActors.actor(actor ID).equips()[armor type ID]
But how to do that to all actors in the party, without no need to name them?

And how to autofill equipment slot of one specific actor via scripts in the event? And how to do that with all party members?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,788
Reaction score
2,935
First Language
English
Primarily Uses
RMMZ
Code:
$gameParty.members().map(member => member.equips()).filter(equipList => !equipList.every(equipSlot => equipSlot === null)).length === 0

That will return true if all party members are unequipped and false otherwise.

Code:
$gameParty.members()[0].forceChangeEquip(1, $dataArmors[3])

That will force armour 3 to be equipped on the first party member's shield slot (you need to own the item for this to work, and the member needs to be able to equip it)

Code:
$gameParty.members().forEach(member => member.forceChangeEquip(1, $dataArmors[3]))

This will do the same thing on all party members.
 

Morizel

Veteran
Veteran
Joined
Sep 28, 2018
Messages
112
Reaction score
8
First Language
Russian
Primarily Uses
RMMV
Code:
$gameParty.members().map(member => member.equips()).filter(equipList => !equipList.every(equipSlot => equipSlot === null)).length === 0

That will return true if all party members are unequipped and false otherwise.
Okay, thank you.
What if I want to check only one slot, not all of them? Like, "body" one?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,788
Reaction score
2,935
First Language
English
Primarily Uses
RMMZ
In the every function call add equipSlot.id === 2 before the null check, would be my first thing to try.
 

Morizel

Veteran
Veteran
Joined
Sep 28, 2018
Messages
112
Reaction score
8
First Language
Russian
Primarily Uses
RMMV
I guess it supposed to look like this?
Code:
$gameParty.members().map(member => member.equips()).filter(equipList => !equipList.every(equipSlot.id === 2 => equipSlot === null)).length === 0
And if I want to just autofill equip slot by any armor (a not specific one), I just need to remove the number within square brackets?
Code:
$gameParty.members()[0].forceChangeEquip(1, $dataArmors[])
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,788
Reaction score
2,935
First Language
English
Primarily Uses
RMMZ
every(equipSlot => equipSlot.id === 2 && equipSlot === null)

If you want to autofill the slot with any armour you'll need to do a bit more work to grab what armours the party actually has, just blank square brackets won't do anything.
 

Morizel

Veteran
Veteran
Joined
Sep 28, 2018
Messages
112
Reaction score
8
First Language
Russian
Primarily Uses
RMMV
Alright, I understand.
Then how to check "nudity" (I mean, that one specific equipment slot is empty) of any in party? Nor specific actor, neither all actors in party.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
655
Reaction score
267
First Language
English
Primarily Uses
RMMV
To check if equip slot 4 is empty on actor 3:

JavaScript:
$gameActors.actor(3).equipSlots().map((val, i) => val == 4 ? i : 0).filter(i => i != 0).every(slot => $gameActor.actor(3)._equips[slot].isNull())

Or if you don't need to account for dual-wielding or plugins adding multiple of the same slot, you can simplify it to:

JavaScript:
$gameActors.actor(3)._equips[4].isNull()
 

Morizel

Veteran
Veteran
Joined
Sep 28, 2018
Messages
112
Reaction score
8
First Language
Russian
Primarily Uses
RMMV
Okay. But how I can check if slot is empty on any of the actors at the party?
I want to make next situation in the game: the player enters the temple. A priest can heal his characters if they are dressed up. Otherwise, if one of these actors is undressed ("Body" equipment slot is empty), he won't help anymore. If all party members undressed, then the priest kicks them out from the temple.
Because mostly I am checking equipment only in one main character. Although sometimes player has more than 1 actor in the party.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,788
Reaction score
2,935
First Language
English
Primarily Uses
RMMZ
Assuming you're using the default set of equipment slots, you can do

Code:
$gameParty.members().some(member => member._equips[3].isNull())
 

Latest Threads

Latest Profile Posts

I'm gonna put my project on pause for a tiny bit so I can explore the engine outside of it... Winging it can only get you so far LMFAO
Have seen some of my favorite people here posting and helping others with questions today -- love to see it!
Haven't been on here actively in awhile, project is going strong my biggest issue is the STORY, i'm refining the plot and learning so much i decided to take a writers class to improve even more but the programming and functionality of the game is stepping up nicely!
Hi everyone! Here's what I'm working on today! It's one of the dorms on campus. I know I said I wouldn't use assets but I reused a few things from the cafeteria hehe.
FCuxBOMXMAICK5e
I added a little squish effect when characters change direction to try and make things a bit more lively. Though it's a bit hard to see on the fast moving guys.
2f4fiuy.gif

Forum statistics

Threads
116,126
Messages
1,095,978
Members
151,537
Latest member
Anrirck
Top