Setting a variable to match a party member's parameter?

Status
Not open for further replies.

shieldings

Veteran
Veteran
Joined
Apr 22, 2016
Messages
33
Reaction score
1
First Language
English
Primarily Uses
Okay, so I'm setting up a little gambling minigame. Basically, it randomizes a variable and, depending on how high that variable is, the player gets prizes of varying values. I want to make it so that after the variable is randomized, the combined luck of all the party members is added in (basically, "lucky people are better at gambling").
How can I access the parameters of party members without specifying actors? I have a set of variables that set to the Actor ID's of the different party members. Is there any way to do this without using conditional branches for every available playable character?
Here's a cap of the event, without the prizes or anything included.
 

Attachments

Rhaeami

The Sleepy-Eyed One
Veteran
Joined
Jun 2, 2014
Messages
250
Reaction score
177
First Language
English
Primarily Uses
RMVXA
Whew, took some experimentation but I finally found it. This is the script call:

$game_party.members[X].luk

Where X is the party position, 0 for leader, 1 for next, etc. You could set or add this to a variable to get the value of X party member's Luck stat. You can set up a loop to run it for each member depending on how many members you have. :kaopride:


Alternatively, you can use this format if you already have the actor IDs:

$game_actors[Y].luk

Where Y is the ID of the actor. If it's in a variable, you can do something like:

$game_actors[$game_variables[Z]].luk

Where Z is the number of the variable it's stored in. :kaohi:
 

shieldings

Veteran
Veteran
Joined
Apr 22, 2016
Messages
33
Reaction score
1
First Language
English
Primarily Uses
Whew, took some experimentation but I finally found it. This is the script call:

$game_party.members[X].luk

Where X is the party position, 0 for leader, 1 for next, etc. You could set or add this to a variable to get the value of X party member's Luck stat. You can set up a loop to run it for each member depending on how many members you have. :kaopride:


Alternatively, you can use this format if you already have the actor IDs:

$game_actors[Y].luk

Where Y is the ID of the actor. If it's in a variable, you can do something like:

$game_actors[$game_variables[Z]].luk

Where Z is the number of the variable it's stored in. :kaohi:
Works like a charm! Thank you so much! :kaoluv:
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
1,483
Reaction score
986
First Language
English
Primarily Uses
Code:
$game_party.members.inject(0) { |total, member| total + member.luk }
That'll get the combined total luk of all party members without the need for a loop or a game variable.
 
Last edited:

Ayoni

Villager
Member
Joined
Aug 15, 2017
Messages
10
Reaction score
1
First Language
English
Primarily Uses
RMMV
Code:
$game_party.members.inject(0) { |total, member| total + member.luk }
That'll get the combined total luk of all party members without the need for a loop or a game variable.
Thanks, man!

Is it possible to collect only the ".luk" of party members who are alive?
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,599
Reaction score
10,919
First Language
English
Primarily Uses
RMVXA

Ayoni, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


It is also hijacking a thread by asking a question which is different from that of the OP.

At this point I usually advise people to start their own thread - but you already have a thread on this topic. Please do not multi post your query. One query, one thread.

Closing this

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

As for the Coronavirus? Well: "People that spend their life avoiding death are already dead (they're also rich, and I like to spend my life with their money.)"
- R. Sanchez, "Edge of Tomorty: Rick, Die, Repeat"
making pierogi and corrupting my game files wbu
Trying to regain my will to work on maps T_T
I miss working in rpgmaker but I can only do one thing at a time. Maybe after drawing lessons I can come back.
Ever have a day like... you play minesweeper and your very first click is always a mine?

Forum statistics

Threads
94,340
Messages
920,073
Members
124,100
Latest member
Vulgourso
Top