VXAce Adding extra stats (e.g., HCR, TCR_Y, CDR, WUR) to Yanfly's Extra Param Formulas

Self-explanatory. My project uses multiple Yanfly scripts, including Extra Param Formulas, Skill Cost Manager, Skill Restrictions, and I want to add formulas to custom stats, namely:
  1. HCR and TCR_Y from Skill Cost Manager; and
  2. CDR and WUR from Skill Restrictions.
Problem is, I have no idea how to add these stats to what is a small script, as I tried to add them to the "xparam" pool, but failed.
class Game_BattlerBase

#--------------------------------------------------------------------------
# mass alias methods
#--------------------------------------------------------------------------
alias_xparam = ["hit", "eva", "cri", "cev", "mev", "mrf", "cnt", "hrg", "mrg",
"trg", "tgr", "grd", "rec", "pha", "mcr", "tcr", "pdr", "mdr", "fdr", "exr"]
alias_xparam.each { |xparam|
aStr = %Q(
alias game_battlerbase_#{xparam}_epf #{xparam}
def #{xparam}
base_#{xparam} = game_battlerbase_#{xparam}_epf
n = eval(YEA::XPARAM::FORMULA[:#{xparam}_n_value])
return eval(YEA::XPARAM::FORMULA[:#{xparam}_formula])
end
)
module_eval(aStr)
} # Do not remove this.

end # Game_BattlerBase

How do I add the extra stats to Extra Param Formulas?
Hey,

Probably the easiest option would be to manually do what the Parameter Formulas script does in bulk here and alias these parameter methods to include your adjustments:
Ruby:
class Game_BattlerBase
 
  # Snapshot the current versions of the parameter methods:
  alias_method(:hcr_without_extra_formula, :hcr)
  alias_method(:tcr_y_without_extra_formula, :tcr_y)
  # ...
  
  # Overwrite the parameter methods with new ones that include the extra formulas:
  def hcr
    old_value = hcr_without_extra_formula
    return old_value * ($game_switches[1] ? this.element_rate(17) : 1)
  end
  # ...

end

If you do want to change the Extra Parameter Formulas script instead, then it probably should work if you add parameters like "hcr" to the alias_xparam list shown in your snippet and create the respective
:hcr_n_value and :hcr_formula entries in the FORMULA section above it.
(But I have not tried that part yet)
If you do want to change the Extra Parameter Formulas script instead, then it probably should work if you add parameters like "hcr" to the alias_xparam list shown in your snippet and create the respective
:hcr_n_value and :hcr_formula entries in the FORMULA section above it.
(But I have not tried that part yet)
I tried this method, it doesn't work, instead the game gives me an error message at the start:
Script 'Extra Param Formulas' line 219: NameError occurred.
undefined method 'hcr' for class 'Game_BattlerBase'
I then tried the other method and got the same error as the code above.
Ah.

In this case try to move the "Extra Param Formulas" script below the other two in the script list (but still above Main).
Scripts are executed in order from top to bottom, and this should allow the new parameter methods to get defined first before getting modified.
In this case try to move the "Extra Param Formulas" script below the other two in the script list (but still above Main).
Scripts are executed in order from top to bottom, and this should allow the new parameter methods to get defined first before getting modified.
I moved Extra Param Formulas below and tried the ""hcr" to the alias_xparam list" method, and... it worked!
I then added TCR_Y, CDR, and WUR, it didn't work at first, but then I realized I made a silly error by copy-pasting "base_hcr" in multiple formulas.

Thank you, stranger on the Internet! :kiss::kiss::kiss:
1758237411065.png

(I used the same formula as MCR (MP Cost Rate) in my test.)

Original thread: https://forums.rpgmakerweb.com/threads/adding-extra-stats-e-g-hcr-tcr_y-cdr-wur-to-yanflys-extra-param-formulas.180132/