Accessing Actor and Party Stas

Discussion in 'RGSS3 Script Requests' started by charlesthehurst, Oct 14, 2016.

Thread Status:
Not open for further replies.
  1. charlesthehurst

    charlesthehurst Veteran Veteran

    Messages:
    34
    Likes Received:
    14
    Location:
    New Mexico USA
    First Language:
    English
    Hello fine folks, I'm in need of help.


    Basically, I would like to be able to use script calls to access stat information for specific actors as well as the party as a whole.


    Actor stats:  I am aware I can already pull actor stats using variables without a script.  What I need is to be able to pull the stat of an actor into a variable based on their position in the party.


    For instance, let's say I have an event that check's for the Party Leader's (1st slot) ATK stat. I want to be able to use a script call to determine the 1st slot's ATK stat regardless of what actor is in that position.


    Party Stat: For this I need to be able to take every actor in the party and add their stats together into one variable.  For instance, let's say I have an event that checks for the party's combined MAG stat.  If I have 3 party members with 20 MAG each, I want to store the cumulative value of 60 to a variable.


    I have already looked around and found some scripts that do similar things but not exactly what I am looking for, particularly the Party Stat idea.


    Any help would be appreciated.
     
    #1
  2. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    788
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    To check for a party member's stat:


    $game_party.members[index].param(param_id)


    Replace the index with the member's position in the party. The party leader's index is 0, the second party member's index is 1, and so on.


    Replace the param_id with the ID of the parameter. 0 = MHP, 1 = MMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK.


    To get the sum of the specified parameter based on your party members, you can use this:


    $game_party.members.inject(0) {|r,mem| r += mem.param(param_id)}


    Again, just replace the param_id with the ID of the parameter you want to calculate.


    The above code won't fit into that tiny little script box of the "Control Variables" event command, so you will have to do it this way:


    $game_variables[id] = $game_party.members.inject(0) {|r,mem| r += mem.param(param_id)}


    Replace the id with the ID of the variable you want to store this data in.


    Use this in a regular "Script Call" event command.


    Note that $game_party.members will check for all of your party members if you are outside of battle, regardless if they are in the active battle party or not.


    If you only want to check for active battle members, you can use $game_party.battle_members instead.
     
    #2
    charlesthehurst likes this.
  3. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,578
    Likes Received:
    7,512
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
     
    #3
Thread Status:
Not open for further replies.

Share This Page