RPG Maker MV / MZ Script Call List

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
715
Reaction score
307
First Language
English
Primarily Uses
RMMV
Something like this should work:

$gameParty.allMembers().some(who => who.isStateAffected(4))

That includes members not participating in battle. If you only want the fighting members, I believe it's battleMembers, and if I recall correctly, just members will also work (and include only battle members when in battle, but all members otherwise).

Obviously replace 4 with the ID of the state you're checking.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
I have the code for all followers to turn in one particular direction. It is:
Code:
for (const follower of $gamePlayer.followers().data()) { follower.setDirection(4); }

I now want just one particular follower to turn, so thought that substituting the follower for data() would work, like this:
Code:
for (const follower of $gamePlayer.followers().follower(1)) { follower.setDirection(6); }

Sadly, but unsurprisingly, given my level of incompetence, this didn't work. The follower continued to face the original direction.

I then tried:
Code:
$gamePlayer.followers().followers(1).setDirection(6)
That didn't work either, including trying to put the whole code in brackets. I then ran out of ideas.

Could someone please correct the code.

Thank you.
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
I then tried:
Code:
$gamePlayer.followers().followers(1).setDirection(6)
Nearly: it should be follower(1) (no s). Try this instead:
JavaScript:
$gamePlayer.followers().follower(1).setDirection(6);
Note that follower index 1 will be the second follower, i.e. the third party member. If you want to affect the first follower, replace 1 with 0.
 
  • Like
Reactions: Kes

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,788
Reaction score
2,224
First Language
English
Primarily Uses
RMMV
So I check the spreadsheet, and couldn't find a script call to directly reference the state of an event's self-switch. There are functions like:
$gameSelfSwitches.setValue([mapId, eventId, switchId], value);
...that let me set a value, but that's not what I'm trying to do. I just want to use the self-switch in an if conditional.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
@Frostorm - Get Self Switch is in the "Switches & Variables" section, currently row 551. Here's the example:

// Is self-switch B for event 1 on map 2 on? $gameSelfSwitches.value([2, 1, 'B']);
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
I see in the spreadsheet that it is possible to change a param by script call

// Give actor ID 5 a permanent -20 LUK malus
$gameActors.actor(5).addParam(7, -20);

Is it possible to use this formula as a basis to change an exparam or sparam?

EDIT
Before posting I tried:
Code:
$gameActors.actor(1).addXparam(2, 2);
and the console said that addXparam is not a function.
But of course I don't know if I got that because I used the code incorrectly or if it's because it's simply not possible.
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
@Kes - no, you'll need a plugin. By default:
  • Ex-params are the sum of all relevant traits, starting at 0.
  • Sp-params are the product of all relevant traits, starting at 1.
Looks like VisuStella Core Engine has some relevant notetags:
There are probably other options as well~
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
@caethyril Sadly, as far as I can see, Core Engine doesn't have any note tags for Items. Note tags for armour or weapons are no good because as soon as they are unequipped the bonus is lost and I want these increases to be permanent.

Though I admit I might be missing something because I can't see the need to use note tags on gear as ex-parameter and sp-parameter bonuses can be allocated in the Traits box. It's Items which doesn't have that facility.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
@Kes - ah, yea, you want a permanent addition. The tags are just to allow for more flexibility in Ex-/Sp-param formulae, e.g. a rate for an Ex-param (normally they only add). You could start a thread in Plugin Requests if need be~
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
I have seen the script calls in the spreadsheet to find out if the party leader or a specific actor has a particular item of gear equipped.

However, what is the script call to find out if any actor has an item of gear equipped?
I've been playing around with variations based on this code:
Code:
$gameParty.allMembers.any?{hasArmor($data_armors[71])}
but it throws one error after another, usually around 'unexpected token', and I've now run out of ideas.

Thank you.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,342
Reaction score
1,548
First Language
English
Primarily Uses
Other
Your lambda function looks odd.
Try comparing with the post Solar_Flare made the 1st of July.
Does that give you some ideas on what to try out?
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
@Kes - try this:

$gameParty.allMembers().some(who => who.hasArmor($dataArmors[71]))
  1. $gameParty.members, or allMembers if you want to be sure to check reserves as well, are functions, so they should be followed by (brackets). Without (), you're just pointing at the function rather than evaluating it. These particular functions don't expect any arguments, so the brackets are empty. You might find this article helpful:

  2. JavaScript uses some, not any. Technical details:
    Also, (brackets) and {braces} are different...I imagine that was the main cause of the "unexpected token" errors you saw. {Braces} are used to define scopes in JS; if in doubt, try (brackets) first.

  3. The who => code part is an arrow function, with one argument that is named who in this case. Technical details:
    Array#some evaluates this function once per array value until it either returns true for one of them or has checked all values. Each time, who is set equal to the value being checked.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
@caethyril I was just beginning to post when you replied.
I did what @Zeriab suggested and came up with the same code that you have just posted.

The only problem with it is that it gave me the wrong result. I interacted with the event that had that code in the conditional. It should have said 'yes' because actor 3 is wearing that item. However, it said 'no'.

Needless to say, I now have no clue what to do next.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,342
Reaction score
1,548
First Language
English
Primarily Uses
Other
Find the 'hasArmor' method and post it here for inspection
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
@Zeriab I don't even know where to look. I have virtually zero knowledge of JS.

EDIT
Found it. Lines 4250, 4251 and 5252 of rmmz_object.js

Code:
Game_Actor.prototype.hasArmor = function(armor) {
    return this.armors().includes(armor);
};
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
Game_Actor#hasArmor checks the actor's equipped armors (rmmz_objects.js):
JavaScript:
Game_Actor.prototype.hasArmor = function(armor) {
    return this.armors().includes(armor);
};
The script call I posted earlier works for me, without plugins, in Conditional Branch -> Script. You could try copy+pasting that just in case you made a typo (remember that JS is case-sensitive).

For diagnostic purposes you could run a couple of tests via the console (F8 during playtest):
  • List actor IDs for each actor in the party:

    console.log('IDs of party members:', $gameParty.allMembers().map(a => a.actorId()));

  • List equip IDs for actor ID 3:

    console.log('IDs of actor 3 equipped armors:', $gameActors.actor(3).armors().map(a => a.id));
If you want to check ALL actors regardless of who is in the party then try this instead:

let found = false; for (let n = $dataActors.length; --n;) if ($gameActors.actor(n).hasArmor($dataArmors[71])) { found = true; break; }; found
Again, this works for me.

Otherwise I suggest starting a new thread, e.g. in MZ Support or Plugin Support, since this sounds like it's probably a design or implementation problem. For example, maybe you're mistaking the actor or armor ID, or using an "independent/instanced items" plugin.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,375
First Language
English
Primarily Uses
RMMZ
@caethyril (hangs head in shame) It was indeed a typo. I'm sorry to have put you to all this extra work unnecessarily.
As always, your help is much appreciated. And I'm trying to get my head around all the explanations in your earlier post. With luck this will reduce the number of my errors.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,802
Reaction score
2,864
First Language
EN
Primarily Uses
RMMZ
No worries! Everyone makes typos now and then, and code is particularly nitpicky about grammar. Good to hear you've got it working now~ :kaohi:
 

Latest Threads

Latest Profile Posts

1660090657213.png
Mistakes will be made.
After three years, it was awesome to be back at Gen Con!
Words of Wisdom: You can be honest and alone. Or dishonest and together.
Working on mapping using RPGTools to create parallax maps using PVgames tiles/assets. It's super cool... but mapping is still something I drag my feet on getting done. I hate this but love the math parts of design, which is the opposite of a lot of dev's around, I think. It really do be different strokes for different folks.
Spend $5,000 on a new gaming PC. Didn't expect it to be like 1 foot wide, 2 feet tall, and weigh like 100+ pounds. The heck did I get myself into?

Forum statistics

Threads
124,379
Messages
1,163,210
Members
163,179
Latest member
LeuzyGamer
Top