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 Profile Posts

Playing Aroma Indosiar theme song.
Aroma is an Indonesian TV show about cooking. :)
Working on a characteeer! (Why is it so hard to color hair?) ;-;
Silly-Sketches.png
Just finished eventing a couple simple puzzles in RMMV, for my very first game "Sample Quest." Just messing around, throwing things together, and calling it a story XD On a non-RM note, got my hair cut today!
I feel the need to inform everyone on the forums NOT to go with Web Hosting Canada for your hosting needs. It is by far the worst customer service and just overall experience I have ever had with hosting and I am Canadian...
BCj
Got another eye surgery monday. Hope I'll recover quick and all's well. A bit tired of surgeries. On a happy note, working on the next chapter of Escalia so hope I can continue soon :)

Forum statistics

Threads
115,372
Messages
1,089,344
Members
150,065
Latest member
Ariel240gamer
Top