How can I calculate average party level for events?

Snarkyfork

Veteran
Veteran
Joined
Oct 29, 2015
Messages
410
Reaction score
59
First Language
English
Primarily Uses
How would it be possible to calculate or create a variable that records the average level of all party members? Basically adding up the levels of party members 1-4 (their current class levels) then dividing it by 4.
 

lianderson

Veteran
Veteran
Joined
Dec 27, 2012
Messages
763
Reaction score
1,002
First Language
English
Primarily Uses
N/A
Yes, but I am not good at explaining things! A game dev human shall arrive shortly to aid you. Variables are your friend!
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,548
Reaction score
3,310
First Language
Binary
Primarily Uses
RMMZ
Code:
$gameParty.members().reduce((r, a) => r += a.level || 1, 0) / $gameParty.members().length;
should work for all party members.

Code:
$gameParty.battleMembers().reduce((r, a) => r += a.level || 1, 0) / $gameParty.battleMembers().length;
should work for only the active battle party members :)

have fun :*
 

Latest Threads

Latest Posts

Latest Profile Posts

Only 3 more days to get your copy of Move That Box! with -15% discount!
1660090657213.png
Mistakes will be made.
After three years, it was awesome to be back at Gen Con!
Words of Wisdom: You can be honest and alone. Or dishonest and together.
Working on mapping using RPGTools to create parallax maps using PVgames tiles/assets. It's super cool... but mapping is still something I drag my feet on getting done. I hate this but love the math parts of design, which is the opposite of a lot of dev's around, I think. It really do be different strokes for different folks.

Forum statistics

Threads
124,380
Messages
1,163,220
Members
163,179
Latest member
LeuzyGamer
Top