NikoPalad

Veteran
Veteran
Joined
Nov 29, 2020
Messages
101
Reaction score
49
First Language
English
Primarily Uses
RMMZ
Hey guys!
I thought about adding a guard that doesn't let the player through as long as they don't have a weapon and some armor. How can I do this, given the fact that I would need a script for this?
 

rpgLord69

Veteran
Veteran
Joined
Oct 23, 2021
Messages
310
Reaction score
267
First Language
Finnish
Primarily Uses
RMMZ
I was bored, so I googled it for you :D


$gameActors.actor(1).weapons().length

$gameActors.actor(1).armors().length

Those are true if 'actor ID 1' has a weapon / armor, otherwise false. You can put them in a conditional script.
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
375
Reaction score
208
First Language
English
Primarily Uses
N/A
You can make a conditional branch with this script line
JavaScript:
$gameParty._actors.some((element) =>$gameActors._data[element]._equips[0]._itemId == 0 )

The statement is checking True or False - someone in the party has a empty weapon slot
I don't know if you plan to have a duel weapon class and need to check the other weapon slots. But you'd just change _equips[0] to a different slot index.
 

NikoPalad

Veteran
Veteran
Joined
Nov 29, 2020
Messages
101
Reaction score
49
First Language
English
Primarily Uses
RMMZ
I was bored, so I googled it for you :D


$gameActors.actor(1).weapons().length

$gameActors.actor(1).armors().length

Those are true if 'actor ID 1' has a weapon / armor, otherwise false. You can put them in a conditional script.
I did that, but I replaced Actors.actor with Party and it worked. Problem is, I can't use those together. Is there a way to do that anyway?
 

rpgLord69

Veteran
Veteran
Joined
Oct 23, 2021
Messages
310
Reaction score
267
First Language
Finnish
Primarily Uses
RMMZ
You can write && between them on the script-line or you can just put another conditional branch inside the first one.
 

NikoPalad

Veteran
Veteran
Joined
Nov 29, 2020
Messages
101
Reaction score
49
First Language
English
Primarily Uses
RMMZ
You can write && between them on the script-line or you can just put another conditional branch inside the first one.
That doesn't work. Even if I have everything, the game will still think it isn't the case.
 

myenemy

Veteran
Veteran
Joined
Jan 17, 2014
Messages
131
Reaction score
63
First Language
Spanish
Primarily Uses
RMMZ
Did you try both
Code:
if($gameParty.weapons().length>1 && $gameParty.armors().length>1)
    //do stuff
and
Code:
if($gameParty.weapons().length>1)
    if($gameParty.armors().length>1)
        //do stuff
?
(Replacing the 1 with the number of weapons or armor pieces you want)
Maybe try different conditional cases?

Regardless, we think this is about having the pieces.
If you want to figure if the actor has something equiped instead, you'll have to check the $gameActors.actor(X).equips()[Y]. null when nothing equiped on that slot.
By default, slot 0 is weapon, 1 is shield or second weapon, and 3 is body.
Code:
if($gameActors.actor(1).equips()[0]) // Has actor 1 a weapon equiped?
if($gameActors.actor(1).equips()[1]) // Has actor 1 a shield/subweapon equiped?
if($gameActors.actor(1).equips()[3]) // Has actor 1 a chest armor equiped?
You can of course, remove the comment and just set the contents of each if, into a conditional branch of script call type.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

DamageEvil_2.png added!
index.php

Important update for Leafko!

Forum statistics

Threads
125,671
Messages
1,172,701
Members
164,802
Latest member
thesailing
Top