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

Steam page is now live!
1632768058957.png
just discovered thig game called Willowbrooke Post... beautiful artstyle if I do say so myself... does anyone know what this kind of style is called??
In one of my game projects, I am working on an arena where you can fight combatants or bet on monsters, and, man, it is taking so long, lmao. I do not think that it helps that I am using an evented combat system with a lot of things that I have to edit.
Time to take a little break from the project to work on another for Skyrim. Shouldn't take too long, as it's just fulfilling an easy to do request(more than likely I'll get beaten to the punch but...) this also gives me an excuse to play Skyrim again LOL.
Dawg.gifKhat.gif
I made two new friends today. I'm not sure which style I like the best..?

Forum statistics

Threads
115,413
Messages
1,089,681
Members
150,157
Latest member
riesco
Top