SOLVED: Trying to get maximum Luck stat of party

BishoujoHelper

Veteran
Veteran
Joined
May 6, 2017
Messages
54
Reaction score
46
First Language
English
Primarily Uses
RMMV
I'm sure there's a relatively quick way to use a script call to get the maximum value of the Luck ($gameActors.actor(actorID).param(7)) statistic of all party members. But I keep getting a crash ("TypeError: Cannot read property 'param' of null") when doing this:

Code:
◆Script:for(var i=0,actor=0,maxLK=0; i<$gameParty.size(); i++) {
:      : actor=$gameParty.members();
:      : maxLK=Math.max(maxLK,$gameActors.actor(actor).param(7));
:      :}
:      :$gameVariables.setValue(2,maxLK);

to put it into variable 2. I've already discovered that you have to use gameParty.size() as .length returns 0 even with 6 in the party, and .size() is correct.
And tried commenting out the "maxLK=" line and getting last actor value with .setValue(2,actor) but that's showing "[object Object]"!
 

King Gerar

White Wolf
Veteran
Joined
May 15, 2012
Messages
165
Reaction score
213
First Language
Portuguese
Primarily Uses
RMMV
Try this:
Code:
var maxLK = 0;
for (a = 0; a < $gameParty.size(); a++) {
maxLK += $gameParty.members()[a].param(7);
};
$gameVariables.setValue(2, maxLK);
 

BishoujoHelper

Veteran
Veteran
Joined
May 6, 2017
Messages
54
Reaction score
46
First Language
English
Primarily Uses
RMMV
The "$gameParty.members()[a].param(7)" (it's [ i ] in my script but that triggers italics here in the forum) gets me what I wanted, thanks! Annoying that I couldn't access the actor value and use the methods that I'm used to from other scripts, but I'll leave it for now.

SOLVED
Code:
  ◆Control Variables:#0001 RandomPercent = Random 1..100
  ◆Script:for(var i=0, maxLK=0; i < $gameParty.size(); i++) {
  :      : maxLK = Math.max(maxLK, $gameParty.members()[i].param(7) );
  :      :}
  :      :$gameVariables.setValue(2, maxLK);
  ◆If:RandomPercent ≤ temp
    ◆Control Switches:#0019 thisTrapDisarmed = ON
    ◆Exit Event Processing
    ◆
  :End
where my variable 2 is named "temp", and param(7) is Luck
 
Last edited:

Latest Threads

Latest Profile Posts

When you don't find any time to work... :kaocry:
First Ten Minutes of my Caretaker inspired game

Finally, I got a good Gmail message [from smg5urded]
"This game does look a bit plain, but, I'm sure this does not destroy the experience as a whole. Monsters fit your style of game-play, mapping looks crude but I'm sure you can make it better if you do a remake of Forgotten Eclipse"
Going to start a new project today. OMG, it will be on RPGMaker MV. :D
Paid material WIP~
EysZO9cVEAEWy9W

This is Alchemy pack.
I decided to add more witch elements.

Now we have wooden props, candles, pots, and potion bottles.
We also want to add herbs, kettles, fireplaces, etc.

Forum statistics

Threads
110,397
Messages
1,052,940
Members
143,450
Latest member
Magnus-barvock
Top