Actor Specific Extra Parameters that include Variables

Oops, forgot the class part. XD

Incidentally, @A-Moonless-Night, is there a particular reason you reopen classes instead of using class_eval?
Incidentally, @A-Moonless-Night, is there a particular reason you reopen classes instead of using class_eval?
Not really, just a 'RPG Maker' style thing I guess! Is class_eval faster/better?
Not as much as it used to be in earlier Ruby versions, I don't think. But it does have one major advantage: you don't have to bother remembering what class the one you're extending inherited from, so it's less prone to mistakes.
Okay, I think I've got something that'll work for you. It'll take a bit of set up since you have lots of characters, but see how you go with this:
Spoiler: Script
Ruby:
module YEAExtraFormulas
  
  ACTOR_FORMULAS = {
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
#  Change the values in the area below to suit your needs.
#==============================================================================

=begin

Set up your actors below here, like so:

  ACTOR_ID => {
    :hit_n_value => "n_value_formula_goes_here",
    :hit_formula => "formula_goes_here",
  },

You can overwrite any of the xparam n_value or formulas set in the original
Yanfly script. Just include the ones you want to change.

=end
  
  # ACTOR_ID => {
    1 => { # Martial artist (change the number to the correct actor ID)
      :hit_n_value => "(atk + agi) * (2 + $game_variables[1])",
      :eva_n_value => "(agi + luk) * (2 + $game_variables[2])",
      :cri_n_value => "luk + $game_variables[3]",
      :cev_n_value => "agi + luk + $game_variables[4]",
      :mev_n_value => "(mdf + luk) * (2 + $game_variables[5])",
      :cnt_formula => "base_cnt + $game_variables[6]",
      :tgr_formula => "base_tgr - $game_variables[7]",
      :grd_formula => "base_grd + $game_variables[5]",
      :pha_formula => "base_pha + $game_variables[8]",
      :tcr_formula => "base_tcr + $game_variables[9]",
      :pdr_formula => "base_pdr - $game_variables[10] - (n / (256.0 + n)) * 0.500 - 0.000",
      :mdr_formula => "base_mdr - $game_variables[11] - (n / (256.0 + n)) * 0.500 - 0.000",
      :fdr_formula => "base_fdr - $game_variables[12]",
      :exr_formula => "base_exr + $game_variables[13]",
    },
    
  # ACTOR_ID => {
    2 => { # Kid 1 (change the number to the correct actor ID)
      :hit_n_value => "(atk + agi) / (2 + $game_variables[14])",
      :eva_n_value => "(agi + luk) / (2 + $game_variables[15])",
      :cri_n_value => "luk - $game_variables[16]",
      :cev_n_value => "agi * 0.75 + luk * 0.25 - $game_variables[17]",
      :mev_n_value => "(mdf + luk) / (2 + $game_variables[18])",
      :mrf_formula => "base_mrf + $game_variables[19]",
      :tgr_formula => "base_tgr + $game_variables[20]",
      :grd_formula => "base_grd - $game_variables[21]",
      :rec_formula => "base_rec - $game_variables[22]",
      :mcr_formula => "base_mcr - $game_variables[23]",
      :pdr_formula => "base_pdr + $game_variables[24] - (n / (256.0 + n)) * 0.500 - 0.000",
      :mdr_formula => "base_mdr - $game_variables[25] - (n / (256.0 + n)) * 0.500 - 0.000",
      :fdr_formula => "base_fdr + $game_variables[26]",
    },
    

    # PASTE EXTRA CHARACTERS ABOVE HERE ^ ^ ^
    
=begin


  COPY AND PASTE THIS AS NEEDED:
  
  # ACTOR_ID => {
    3 => { # < change the number to the ID of the correct actor
      :hit_n_value => "(atk + agi) / (2 + $game_variables[14])",
    },
  
  
=end

#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
#  Please do not edit below this point unless you know what you are doing.
#==============================================================================

  }
  
end

class Game_BattlerBase
  include YEAExtraFormulas

  def has_custom_formula?(xparam)
    return false unless actor? && ACTOR_FORMULAS.key?(@actor_id)
    return ACTOR_FORMULAS[@actor_id].key?(:"#{xparam}_formula")
  end

  def has_custom_n_value?(xparam)
    return false unless actor? && ACTOR_FORMULAS.key?(@actor_id)
    return ACTOR_FORMULAS[@actor_id].key?(:"#{xparam}_n_value")
  end

end

class Game_BattlerBase

  xprms = ["hit", "eva", "cri", "cev", "mev", "mrf", "cnt", "hrg", "mrg", "trg", "tgr", 
  "grd", "rec", "pha", "mcr", "tcr", "pdr", "mdr", "fdr", "exr"]
  xprms.each { |xprm|
  module_eval(%Q(
  alias amn_yea_gamebatbase_#{xprm} #{xprm}
  def #{xprm}
    base_#{xprm} = game_battlerbase_#{xprm}_epf
    return amn_yea_gamebatbase_#{xprm} unless actor? && ACTOR_FORMULAS.key?(@actor_id)
    n = eval((ACTOR_FORMULAS[@actor_id].key?(:#{xprm}_n_value) ? ACTOR_FORMULAS[@actor_id] : YEA::XPARAM::FORMULA)[:#{xprm}_n_value])
    return eval((ACTOR_FORMULAS[@actor_id].key?(:#{xprm}_formula) ? ACTOR_FORMULAS[@actor_id] : YEA::XPARAM::FORMULA)[:#{xprm}_formula])
  end
  ))
  }
  
end

Basically, you can overwrite any of the n_value and formulas in Yanfly's original script with custom ones for each character. These are set up in what's called a hash (inside the curly braces) to make it easy to reference. Just include the ones you want to overwrite, otherwise they'll use the default ones in the original script.

I've set up the martial artist and kid 1 based on your original post with the formulas and things. You will need to change the numbers next to $game_variable with the ID of the variables you're using and the ID for each hash should be the ID of the actor. Hopefully this should give you what you need to set up the other actors.

For example, if you wanted to set up formulas for the teenage girl character, you would copy the section that looks like this:
Ruby:
  # ACTOR_ID => {
    3 => { # < change the number to the ID of the correct actor
      :hit_n_value => "(atk + agi) / (2 + $game_variables[14])",
    },

and paste it just above the section that says # PASTE EXTRA CHARACTERS ABOVE HERE ^ ^ ^. Then you would just add the formulas you want for that character. For the teenage girl, you would probably have:
Ruby:
    3 => { # < change the number to the ID of the correct actor
      :eva_n_value => "(agi + luk + $game_variables[20]) / 2", #using the ID of the fleeing variable
      :cev_n_value => "agi * 0.75 + luk * 0.25 + $game_variables[20]", #using the ID of the fleeing variable
      :mev_n_value => "(mdf + luk + $game_variables[20]) / 2", #using the ID of the fleeing variable
    },

I know you're not too familiar with scripting, so let me know if you need any other explanations.
Well it's loading now, but there are still issues.
Using the old code on the previous page, the game worked, but when I went to the status menu and tried to look at the properties tab, the game crashed with a very informative error message.

Extra Parameter Script 2.png


When I looked at the scripts to see where the error was, it came up with this.

Extra Parameter Script 3.png


I think it's an issue with the display on the properties tab of the status menu.
But I don't know what's up with line 686.

I tried the script on this page, and decided to test it with just the two characters you used as examples first (since the game loads, I assume there isn't an issue, but just in case here's a screenshot.

Extra Parameter Script 4.png


When I go on the status menu and try and view the properties tab, this appears.

Extra Parameter Script 5.png


When I check the scripts, this comes up.

Extra Parameter Script 6.png


I don't know what's wrong.
Stack level too deep means you have the same script twice.
Okay, but is there another meaning.
As all my scripts are different.
Still, you have something in there that's in there twice.
When I remove the script A-Moonless-Night did the properties tab works fine.
So I'm not sure what's going on.

EDIT: I had a look at the script and noticed this.
Extra Parameter Script 7.png


The end of line 112 isn't blue.
I'm not sure exactly what it means though.
That's fine, it's not supposed to be blue. The way Yanfly created the methods for getting xparam values is dynamic so the syntax colouring doesn't recognise it the same way, but it works.
Pop it below the Extra Params script and see if that works.
Ah, I did that, it started to work, then I decided to check all the formulas and make sure they were all working just in case something came up, but then some serious IRL stuff came up and I had to deal with that.

I'm just going to see if all the formulas fit first, but so far it's working fine.
Thanks for what you've done.

Original thread: https://forums.rpgmakerweb.com/threads/actor-specific-extra-parameters-that-include-variables.121524/