Yeah, you can't base a bonus on the same parameter that way, that will result in a loop, like you already noticed.
You can base any bonus on other parameters safely thou using that method.
But why would you have a custom param for maximum damage separately from the damage parameter?
You have the value of the damage parameter. That parameter got an editable maximum allowed value, and an editable minimum value. You can add bonuses for the minimum and maximum values the same way, so there should be no reason to make a separate parameter for maximum damage, unless you use that for an entirely different purpose.
Anyway, here is how you can make a base percentage bonus value based on the same parameter:
Spoiler
def base_percent(user,cprm,percent="0.1",round_it="true")
if user.is_a?(Game_Actor)
val = user.actor.cparam(cprm,user) # Base cparam value (Actor object)
val += user.class.cparam(cprm,user) # Class cparam value (Class object)
else
val = user.enemy.cparam(cprm,user) # Base cparam value (Enemy object)
end
val *= percent.to_f
val = val.to_i if round_it == "true"
return val
end
In this method, I just get the base value of the parameters directly from the objects instead of getting the whole value.
This negates the loop problem, since it gets the values from another method, so it won't be a recursive loop, and it gets you the values you requested, only the base value.
Additionally, you can add the parameter gain from the script calls as well (those are permanent changes, so they can be considered as part of the base value, right?) if you want.
That would look like:
Spoiler
def base_percent(user,cprm,percent="0.1",round_it="true")
if user.is_a?(Game_Actor)
val = user.actor.cparam(cprm,user) # Base cparam value (Actor object)
val += user.class.cparam(cprm,user) # Class cparam value (Class object)
else
val = user.enemy.cparam(cprm,user) # Base cparam value (Enemy object)
end
val += user.cparam_bonus(cprm) # The cparam value gained from script calls
val *= percent.to_f
val = val.to_i if round_it == "true"
return val
end
The above method would add the values gained from these script calls as well.
It is highly unlikely that your enemies will gain parameters from the script call (unless you actually do that in your game), so if you want, you can put it in the
Game_Actor part only. I note this, because, by default, each enemy you encounter will be a new Game_Enemy instance, so all these parameter gains from the script call would be reset for each enemy. Although it can be good in some evented battles, I guess.
To use this method, you must place it into the module for your custom methods in this script (named
CustomParamMethods, found right below the parameter setting part).
After this, you can simply note-tag your equipment and states (only these, otherwise, you will get into a loop again!) with the following:
Spoiler
<dex method: base_percent, dex, 0.15>
<dex value update>
This note-tag example would make the equipment/state have 15% DEX bonus based on the base value of the actor's/enemy's DEX (without equipment and state bonuses).
I think this is what you wanted, right?
You can use what you suggested, another custom parameter to handle the percentage values. I wouldn't do this if it is not necessary, and I think it is not.
As for performance, if possible, use custom methods instead of string evals (formulas). Their usage is actually the same (you need to write the logic in code in both cases), but the method usage is quicker than the eval one. The only minor difference is the note-tag used for them, but I think, it is still easy to use (even easier, considering the fact that you only need to put in the method name and the arguments you want versus the whole code).
Overall, you won't notice much difference unless you call the custom parameter in every frame (in some rare cases, that is inevitable), that might be noticeable, but I never really tested. It is proven that running an eval formula (strings evaluated during runtime) is slower than running a method which is already defined on start-up (mostly noticeable with longer/more complex strings/methods), that's why I always note that using your own custom methods is the best thing to do if you can choose between eval and normal method usage.