$gameParty.luk() don´t work

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Hello guys, I´m trying to put $gameParty.luk() on a formula to take luck as parameter.

But I coudn´t make this work. I tried $gameParty.agility() and it worked perfectly.

I need help on this, maybe is something that I have missed.

Thank you in advance!!
Thales
 

Attachments

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
It can't work because the party has no luck, only actors have luck. And to determine the luck of a specific actor, it's better to use control variable - game data than script.

Agility is an exception that only works because the battleengine needs to calculate the agility of the entire party for the success of the escape option - but I can't even tell you if that agility is calculated as the sum or the average or in a different way.
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
873
Reaction score
562
First Language
English
Primarily Uses
RMMV
That's because $gameParty.agility() is specifically defined, and gets the average agi of all party members (or enemies, if you call it on the troop) and is used in the default escape chances, among other places. The default game never needs to check their collecting luck, so there's not function to get the whole party's luck built in.

.agility() looks like this:
Code:
Game_Unit.prototype.agility = function() {
    var members = this.members();
    if (members.length === 0) {
        return 1;
    }
    var sum = members.reduce(function(r, member) {
        return r + member.agi;
    }, 0);
    return sum / members.length;
};
So, a hypothetical party luck check, if you wanted to add it to the code yourself, would look like this:
Code:
Game_Unit.prototype.luck= function() {
    var members = this.members();
    if (members.length === 0) {
        return 1;
    }
    var sum = members.reduce(function(r, member) {
        return r + member.luk;
    }, 0);
    return sum / members.length;
};
And then you could just call $gameParty.luck() and get their average luck value.
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Thank you guys for helping me.

That's because $gameParty.agility() is specifically defined, and gets the average agi of all party members (or enemies, if you call it on the troop) and is used in the default escape chances, among other places. The default game never needs to check their collecting luck, so there's not function to get the whole party's luck built in.

.agility() looks like this:
Code:
Game_Unit.prototype.agility = function() {
    var members = this.members();
    if (members.length === 0) {
        return 1;
    }
    var sum = members.reduce(function(r, member) {
        return r + member.agi;
    }, 0);
    return sum / members.length;
};
So, a hypothetical party luck check, if you wanted to add it to the code yourself, would look like this:
Code:
Game_Unit.prototype.luk = function() {
    var members = this.members();
    if (members.length === 0) {
        return 1;
    }
    var sum = members.reduce(function(r, member) {
        return r + member.luk;
    }, 0);
    return sum / members.length;
};
And then you could just call $gameParty.luk() and get their average luck value.


@Doktor_Q it worked perfectly!! Thank you so much!

Please, I would like to ask what formula do I have to put to get a single actor luk. Or a single actor agility.
Because $gameParty.luk() does get the sum of average. I have tried gameParty.luk(0) or (1) but didn´t work.
 
Last edited:

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
873
Reaction score
562
First Language
English
Primarily Uses
RMMV
You're doing this in the formula window for a skill, right? They already give you access to the user and target directly- "a.atk - b.def" is accessing the attack of the user and the defense of the target. You don't need to change anything to have access to all of the base stats for those battlers.
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Hello! Thank you guys for replying!!

I can´t use "a.luk" because I´m using this on Items. And there I just can do it with formulas.

But $gameActors.actor(x).luk works perfectly!!!
Thank you @Silva for the code!!!
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
873
Reaction score
562
First Language
English
Primarily Uses
RMMV
Hello! Thank you guys for replying!!

I can´t use "a.luk" because I´m using this on Items. And there I just can do it with formulas.

But $gameActors.actor(x).luk works perfectly!!!
Thank you @Silva for the code!!!
Items support "a.luk" just the same as skills. In fact, an item can do just about anything a skill can do- the only real difference is the requirements to use. They use the same code to process their effects.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
With items, you would use b.luk as you use an item ON an actor, so the actor is the target. Items don't have a user, if you're using them from the menu. There's only a user if you're in battle.
 

thalesgal

Veteran
Veteran
Joined
Dec 23, 2016
Messages
195
Reaction score
45
First Language
Portuguese
Primarily Uses
RMMV
Ok! Got it! Thank you!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top