[Ace] Custom Stats Overhaul (scripting)

● ARCHIVED · READ-ONLY
Started by TheoAllen 2 posts View original ↗
  1. Background:
    Stats are the element of a game that has a big role. Everything on gameplay are driven by stats and their number. The default engine provides a wonderful tools to tweak it. However, when you want to extend the usability, you can't help but to search what people offers to you and dependent on any script that had been released. While you can easily tweak it if you know how the stats works on default script.

    For example, you want to make a weapon increase the stat by 10 ONLY when an actor has a certain state, and 5 when it's not. It is not possible within the default editor that you have to resort to request a custom script for that. This tutorial exist to help you with that so (I hope) you can help yourself.

    I'm not native English speaker, so I'll try my best to explain.

    Disclaimer!
    This tutorial means to be used as guide to make your game. It does not mean to be used to write a proper script to be released for other people to use. As it requires a careful written script that can ensure compatibility, bugs, and many things. Even if you do, you take all the responsibility of the script you're releasing.

    Requirements:
    • Know most if not all the basic functions of RM (if you don't, please watch / read other's tutorial)
    • A basic sense of math
    • A basic sense of true/false logic
    • A basic Ruby/RGSS3 scripting knowledge would be a plus
    How stat is calculated?
    First, let's take a peek on the default script, Game_BattlerBase > Line 267
    069b78ff99e9370558b7dc8b23d0bcb1.png

    These chunks of codes tell you the formula of how the stat is calculated. To make it more understandable in human language, I'm gonna tell you in simpler version.
    • First, the game fetch the stats from Database > Class. Say the ATK is 20 in database.
    • Then 20 is added by permanent modifier. Something like, when you make an item or event that can permanently add stats. e.g, You eat a power pill, your attack increased by +5 permanently. It also comes from flat stat boost from equipment that is equipped to your actor.
    • Once addition it's done, it's multiplied by many modifiers. For example, a state that boost ATK by 200%, now you have ATK value = 50
    • Then the game caps the stat to a certain value. For ATK, it has the ceiling cap equal to 999 and the bottom cap equal to 1.
    Thus the formula can be written like this:
    Code:
    final_stat = (base + plus) * rate_modifier

    Knowing this is important. Because, where you change the formula could affect the final outcome. Like, would you like to modify the final value? or rather the base value? Both will result a different outcome.

    Say, Base value is 20. You changed that and it becomes 25. Multiplied by 200%, it becomes 50. If you modify the final value, then it will be 20 * 200% + 5 = 45

    The fun part!
    Let's get straight to the point of how you gonna modify these formula. But before we proceed, I need you to know the param id. This is important to know which stat you're going to modify.
    • 0 = MaxHP
    • 1 = MaxMP
    • 2 = ATK
    • 3 = DEF
    • 4 = MAT
    • 5 = MDF
    • 6 = AGI
    • 7 = LUK
    I'm going to use the example I wrote on the background section. We're making the weapon ID 1 increase stat by 10 when an actor has state id 10. We're going to change the base.

    First, you create a slot on your editor that I expect you already know how to do it if you know how to install script. Write this.
    Code:
    class Game_Actor
      def param_base(param_id)
        value = self.class.params[param_id, @level]
        # We're going to insert the codes here
        return value
      end
    end

    Next, we need to check the state. Check if equipment is equipped, and we use param ID 2 (Attack).
    To check if state ID 10 is present, we can use this.
    Code:
    state?(10)
    To check equipment, we can use this.
    Code:
    equips.include?($data_weapons[1])
    To filter the parameter so that it only affect atk, we need this
    Code:
    param_id == 2
    Ignoring the filter and it will be applied to all stats.

    We're going to increase the stat by 10 while the actor is equipping the weapon and has the state. If the state is not present, it will only increase it by 5
    Code:
    class Game_Actor
      def param_base(param_id)
        value = self.class.params[param_id, @level]
        #-----------------------------------------------------------
        if param_id == 2 # <-- Modify only attack stat
          if equips.include?($data_weapons[1]) # <-- Check equip first
            if state?(10) # <-- after equip, check state
              value += 10
            else
              value += 5
            end
          end
        end
        #-----------------------------------------------------------
        return value
      end
    end

    What if you want to change into a multiplicative one instead of additive? Say, increase the ATK stat by +20%, and +10% otherwise?
    You can change the code like this.
    Code:
    class Game_Actor
      def param_base(param_id)
        value = self.class.params[param_id, @level]
        #-----------------------------------------------------------
        if param_id == 2 # <-- Modify only attack stat
          if equips.include?($data_weapons[1]) # <-- Check equip first
            if state?(10) # <-- after equip, check state
              value *= 1.2
            else
              value *= 1.1
            end
          end
        end
        #-----------------------------------------------------------
        return value
      end
    end

    That is if we want to change the base. If we're changing from the final stat, use this instead
    Code:
    class Game_Actor
      def param(param_id)
        value = super(param_id)
        # Insert the code here
        return value
      end
    end

    Be creative!
    This custom stat overhaul has limitless possibilities. Don't let my example limits your creativity. You can make the stat affected by weather if you managed to get weather check. Or stat affected by game variables, or even it only affect a certain actor.

    Some handy symbols to use if you want to some conditions
    Spoiler
    True/False check
    • == Equal as
    • < Lesser than
    • > Bigger than
    • >= Bigger or equal than
    • <= Lesser or equal than
    • != Is not the same as
    Basic operations
    • += add
    • -= substract
    • *= multiply
    • /= division
    • %= modulo (remainder of a division)

    Limitation
    There're too many possibilities can be made using this method that I have no time writing them all. Besides it will be too long to write them all here. I might want to update this tutorial for more tips and trick of overhauling the stats system later time. But as for now, I will leave it like this.

    If you have question of how to make custom stat overhaul or more suggestions, feel free to post!
  2. Wow thank you so much. I was searching for scripts to make states that changed the params by flat numbs and couldn't find anything. Who would guess you could do it yourself so easily!