Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,965
Reaction score
1,670
First Language
English
Primarily Uses
RMMV
So I currently have my monsters' move routes set up so that they will chase the player upon sight and then return back to their original position if they stray too far. I want to add an alternate move route where the monsters run away from the player if the player's avg party lv is +x levels higher than the monster. I currently have it so it checks the party leader's level, but I want it to check the entire party's average level. This is what I got so far:
$gameParty.leader().level > 5 ? this.detector(0) : this.detector(2);
My issue is that I need it to be compatible w/ situations where there are different party sizes. For example, 1 party member, 2 party members, or 3 party members.
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
58
Reaction score
38
First Language
English
Primarily Uses
RMMV
Hi,

I have been working with my own stuff trying to grab actor data, and researching lots on this forum.
I think I might have found something helpful for you.

You can grab the party member size with this expression:
JavaScript:
var partysize = $gameParty.members().length; //If you have 3 members it will return the number 3.

Now, all you have to do is loop through the party and then perform your trinary.
EDIT: Whoops, let me fix this snippet. There, now it should work.

JavaScript:
var combinedLevel = 0;
for (let i = 0; i < partysize; partysize++) {
combinedLevel += $gameActors.actor(partysize)._level
}
combinedLevel > 5 ? this.detector(0) : this.detector(2);


Caution, I always make mistakes since arrays start with 0, meaning you only want i <= 2, if you have 3 members in your party.
If my for statement is wrong, please try adjusting for that.

I hope it helps!
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,965
Reaction score
1,670
First Language
English
Primarily Uses
RMMV
Awesomesauce, thx a bunch!
 

Latest Threads

Latest Posts

Latest Profile Posts

Lately I have been taking a break from game and resource making so I won't get burnt out. But I am also interested in the Game Jams this site periodically holds. It'd be great if I knew when the next one, if any, is planned.
elexy 1.2.pngSome bust art to be cropped and cleaned. May use in special decision moments. Depending on how it looks in game I may cut it.
Tiamat-86 wrote on ATT_Turan's profile.
apparently since its turning 15 years old this year the ps3 is considered "retro". now how old do you feel?
guess that means im an "antique" gamer since ill still play games as old as i am.
"you know your getting old when your childhood console changes ethnicity" lol it turned yellow
I'm making Toilet in Wonderland 2. and tell vinny about it lol

Forum statistics

Threads
115,343
Messages
1,089,170
Members
150,020
Latest member
eungi
Top