The only way I know how to set HP is to go to Classes and type in the specific HP value for each level. Is there a way to use a formula for each level (or even better a global formula that depends on level) instead? Can I do it without scripts? If not, are there any scripts available? (I'd rather do it without scripts). Thank you.
How do I set up HP based on formulas instead of values?
RPG Maker VXAce SupportWell you can make an event that modifies max HP based on level (via the change parameters command) but depending on the formula that you want, you might still need to use script calls at least.
Other than that, scripting would be the way to go
Other than that, scripting would be the way to go
Hmm. I understand. Do you know any good script?
I believe yanfly has a script for using formulas for parameters (named Param Formulas iirc) but I'm not sure if it handles the base parameters.
Just throw this ...
Code:
class Game_Actor
def param_base(param_id)
if param_id == 0 # max HP
return @level * 100 # <-- edit here
end
self.class.params[param_id, @level]
end
end
Sweet. And if I want to do it for different classes? Or if I want to set each level individually? Sorry if I'm asking for too much, I am really grateful for the script.
You could do any of these:
- check the class ID using an if/then or a case clause and return a different formula per ID
- save each formula in an array using the corresponding class ID as the index
- make a notetag that you will use to set the formula on the class notebox in the database and load it
an example of checking the ID an returning a different formula depending on it
Note: not sure if self.class.id is the right way of checking the class ID
Note 2: You would use the above format as replacement to the
part of Theo's code
- check the class ID using an if/then or a case clause and return a different formula per ID
- save each formula in an array using the corresponding class ID as the index
- make a notetag that you will use to set the formula on the class notebox in the database and load it
an example of checking the ID an returning a different formula depending on it
Code:
case self.class.id
when 1
return formula_for_class1
when 2
return formula_for_class2
and so on per class that you want
else
return default_formula
#this will be the formula for any class not defined above
end #dont forget this line
Note: not sure if self.class.id is the right way of checking the class ID
Note 2: You would use the above format as replacement to the
Code:
return @level * 100
it is correct.
If you want to set each level individually then I suggest an array
the replace the edit line at Theo's code with
Code:
LEVEL_ARRAY = []
LEVEL_ARRAY[1] = formula/value at level1
LEVEL_ARRAY[2] = formula/value at level 2
#and so on for all levels
#if you're gonna use formulas, put them as strings
#like "@level * 100"
the replace the edit line at Theo's code with
Code:
#if using formulas
return eval(LEVEL_ARRAY[@level])
#or if using just values
return LEVEL_ARRAY[@level]
Thank you very much for the scripts
Code:
Script line 1: NoMethodError occured.
Undefined Method `id' for Object:Class
Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-set-up-hp-based-on-formulas-instead-of-values.105971/