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
56
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

I THINK I have a slightly better grasp on drawing my maps now... sorta. I still need to figure out how to draw a city of sorts. I've only got the abstract going so far.
One day, I'll not have this lingering cough and we'll have another make a game stream.
A music I create while practicing E Major scale. :D
Too bad the Boss Battle Build Bout isn't also for VXAce.

Forum statistics

Threads
115,180
Messages
1,087,898
Members
149,746
Latest member
Nesutokung
Top