How do I set up HP based on formulas instead of values?

Discussion in 'RPG Maker VX Ace' started by ElOtario, Feb 23, 2019.

  1. ElOtario

    ElOtario Villager Member

    Messages:
    25
    Likes Received:
    1
    First Language:
    Pretuguês
    Primarily Uses:
    RMVXA
    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.
     
    #1
  2. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,544
    Likes Received:
    2,900
    Location:
    Philippines
    First Language:
    Tagalog
    Well 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
     
    #2
  3. ElOtario

    ElOtario Villager Member

    Messages:
    25
    Likes Received:
    1
    First Language:
    Pretuguês
    Primarily Uses:
    RMVXA
    Hmm. I understand. Do you know any good script?
     
    #3
  4. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,544
    Likes Received:
    2,900
    Location:
    Philippines
    First Language:
    Tagalog
    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.
     
    #4
  5. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,376
    Likes Received:
    4,948
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    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
    
     
    #5
  6. ElOtario

    ElOtario Villager Member

    Messages:
    25
    Likes Received:
    1
    First Language:
    Pretuguês
    Primarily Uses:
    RMVXA
    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.
     
    Last edited: Feb 23, 2019
    #6
  7. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,544
    Likes Received:
    2,900
    Location:
    Philippines
    First Language:
    Tagalog
    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

    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
    
    part of Theo's code
     
    Last edited: Feb 23, 2019
    #7
  8. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,376
    Likes Received:
    4,948
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    it is correct.
     
    #8
    Engr. Adiktuzmiko likes this.
  9. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,544
    Likes Received:
    2,900
    Location:
    Philippines
    First Language:
    Tagalog
    If you want to set each level individually then I suggest an array

    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]
    
     
    #9
  10. ElOtario

    ElOtario Villager Member

    Messages:
    25
    Likes Received:
    1
    First Language:
    Pretuguês
    Primarily Uses:
    RMVXA
    Thank you very much for the scripts
     
    #10
  11. ElOtario

    ElOtario Villager Member

    Messages:
    25
    Likes Received:
    1
    First Language:
    Pretuguês
    Primarily Uses:
    RMVXA
    Code:
    Script line 1: NoMethodError occured.
    Undefined Method `id' for Object:Class
     
    #11

Share This Page