Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Different Max Stats for Enemies and Players

I would like to request a script (probably just an edit to the predefined scripts) that lets me define the maximum value for stats (HP, SP, STR, DEX, AGI, INT), and that the maximums can be different for the player characters and for enemies. For example, I want, for the enemies:
HP: 999,999+ (if this is possible, I know it is 99,999 by default)
SP: 99,999 (same as above, since the max is 9999)
STR: 999
DEX: 999
AGI: 999
INT: 999

For the player characters:
HP: 9999
SP: 999
STR: 255
DEX: 255
AGI: 255
INT: 255

The point of this is that, even though in the database, no player has, for example, a natural strength of more than 255, I want to be able to equip an accessory that raises strength without going over 255.

I was able to adjust the values in Game_Battler1 to set the maximums, but it was the same for both the enemies and players. Any help with this would be greatly appreciated.
 
Err look in Game_Actor and then modify the methods:
base_maxsp
base_str
base_dex
base_int
base_agi
Eg:
Code:
  def base_int
    n = $data_actors[@actor_id].parameters[5, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.int_plus : 0
    n += armor1 != nil ? armor1.int_plus : 0
    n += armor2 != nil ? armor2.int_plus : 0
    n += armor3 != nil ? armor3.int_plus : 0
    n += armor4 != nil ? armor4.int_plus : 0
    return [[n, 1].max, 255].min
  end
And for sp:
Code:
  def base_maxsp
    return [$data_actors[@actor_id].parameters[1, @level], 999].min
  end
 
Well, I've seen the "Limit Breaks" thread before, but I thought it was just a FFVII limit break system. :*) Anyway, I don't see a way in the script to set different maximums for actors and enemies for any stats other than HP and SP. Does it support that and I'm just blind or would that need to be added on?
 
BUMP

I was also wondering what damage_limit does. I figured it was the maximum damage an attack can do, but setting it to different values didn't seem to affect that, so I don't know if it does something else or there is just something else that needs to be set up for it to work properly.
 
Well, here's the script:
Code:
module Limits
  #--------------------------------------------------------------------------
  # * Max Hp Limit (nil for no limit)
  #--------------------------------------------------------------------------
  Max_Hp_Limit_Actors = 999
  Max_Hp_Limit_Enemies = 99999
  #--------------------------------------------------------------------------
  # * Max Sp Limit (nil for no limit)
  #--------------------------------------------------------------------------
  Max_Sp_Limit_Actors = 99
  Max_Sp_Limit_Enemies = 9999
  #--------------------------------------------------------------------------
  # * Exp Limit
  #--------------------------------------------------------------------------
  Exp_Limit = 9999999
  #--------------------------------------------------------------------------
  # * Strength Limit
  #--------------------------------------------------------------------------
  Strength_Limit = 100
  #--------------------------------------------------------------------------
  # * Dexerity Limit
  #--------------------------------------------------------------------------
  Dexerity_Limit = 100
  #--------------------------------------------------------------------------
  # * Agility Limit
  #--------------------------------------------------------------------------
  Agility_Limit = 100
  #--------------------------------------------------------------------------
  # * Intelligence Limit
  #--------------------------------------------------------------------------
  Intelligence_Limit = 100
  #--------------------------------------------------------------------------
  # * Hp Plus Limit
  #--------------------------------------------------------------------------
  Hp_Plus_Limit = nil
  #--------------------------------------------------------------------------
  # * Sp Plus Limit
  #--------------------------------------------------------------------------
  Sp_Plus_Limit = nil
  #--------------------------------------------------------------------------
  # * Strength Plus Limit
  #--------------------------------------------------------------------------
  Str_Plus_Limit = nil
  #--------------------------------------------------------------------------
  # * Dex Plus Limit
  #--------------------------------------------------------------------------
  Dex_Plus_Limit = nil
  #--------------------------------------------------------------------------
  # * Agi Plus Limit
  #--------------------------------------------------------------------------
  Agi_Plus_Limit = nil
  #--------------------------------------------------------------------------
  # * Int Plus Limit
  #--------------------------------------------------------------------------
  Int_Plus_Limit = nil
  #--------------------------------------------------------------------------
  # * Damage Limit
  #--------------------------------------------------------------------------
  Damage_Limit = nil
end


class Game_Enemy
  #--------------------------------------------------------------------------
  # * Get Maximum HP
  #--------------------------------------------------------------------------
  def maxhp
    if Max_Hp_Limit_Enemies != nil
      n = [[base_maxhp + @maxhp_plus, 1].max, Max_Hp_Limit_Enemies].min
    else
      n = [base_maxhp + @maxhp_plus, 1].max
    end
    for i in @states
      n *= $data_states[i].maxhp_rate / 100.0
    end
    if Max_Hp_Limit_Enemies != nil
      n = [[n, 1].max, Max_Hp_Limit_Enemies].min
    else
      n = [n, 1].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Get Maximum SP
  #--------------------------------------------------------------------------
  def maxsp
    if Max_Sp_Limit_Enemies != nil
      n = [[base_maxsp + @maxsp_plus, 0].max, Max_Sp_Limit_Enemies].min
    else
      n = [base_maxsp + @maxsp_plus, 0].max
    end
    for i in @states
      n *= $data_states[i].maxsp_rate / 100.0
    end
    if Max_Sp_Limit_Enemies != nil
      n = [[n, 0].max, Max_Sp_Limit_Enemies].min
    else
      n = [n, 0].max
    end
    return Integer(n)
  end
end

class Game_Actor
  #--------------------------------------------------------------------------
  # * Get Maximum HP
  #--------------------------------------------------------------------------
  def maxhp
    if Max_Hp_Limit_Actors != nil
      n = [[base_maxhp + @maxhp_plus, 1].max, Max_Hp_Limit_Actors].min
    else
      n = [base_maxhp + @maxhp_plus, 1].max
    end
    for i in @states
      n *= $data_states[i].maxhp_rate / 100.0
    end
    if Max_Hp_Limit_Actors != nil
      n = [[n, 1].max, Max_Hp_Limit_Actors].min
    else
      n = [n, 1].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Get Maximum SP
  #--------------------------------------------------------------------------
  def maxsp
    if Max_Sp_Limit_Actors != nil
      n = [[base_maxsp + @maxsp_plus, 0].max, Max_Sp_Limit_Actors].min
    else
      n = [base_maxsp + @maxsp_plus, 0].max
    end
    for i in @states
      n *= $data_states[i].maxsp_rate / 100.0
    end
    if Max_Sp_Limit_Actors != nil
      n = [[n, 0].max, Max_Sp_Limit_Actors].min
    else
      n = [n, 0].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Get Basic Strength
  #--------------------------------------------------------------------------
  def base_str
    n = $data_actors[@actor_id].parameters[2, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.str_plus : 0
    n += armor1 != nil ? armor1.str_plus : 0
    n += armor2 != nil ? armor2.str_plus : 0
    n += armor3 != nil ? armor3.str_plus : 0
    n += armor4 != nil ? armor4.str_plus : 0
    n = Strength_Limit != nil ? [[n, 1].max, Strength_Limit].min : [n, 1].max
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Dexterity
  #--------------------------------------------------------------------------
  def base_dex
    n = $data_actors[@actor_id].parameters[3, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.dex_plus : 0
    n += armor1 != nil ? armor1.dex_plus : 0
    n += armor2 != nil ? armor2.dex_plus : 0
    n += armor3 != nil ? armor3.dex_plus : 0
    n += armor4 != nil ? armor4.dex_plus : 0
    n = Dexerity_Limit != nil ? [[n, 1].max, Dexerity_Limit].min : [n, 1].max
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Agility
  #--------------------------------------------------------------------------
  def base_agi
    n = $data_actors[@actor_id].parameters[4, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.agi_plus : 0
    n += armor1 != nil ? armor1.agi_plus : 0
    n += armor2 != nil ? armor2.agi_plus : 0
    n += armor3 != nil ? armor3.agi_plus : 0
    n += armor4 != nil ? armor4.agi_plus : 0
    n = Agility_Limit != nil ? [[n, 1].max, Agility_Limit].min : [n, 1].max
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Intelligence
  #--------------------------------------------------------------------------
  def base_int
    n = $data_actors[@actor_id].parameters[5, @level]
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.int_plus : 0
    n += armor1 != nil ? armor1.int_plus : 0
    n += armor2 != nil ? armor2.int_plus : 0
    n += armor3 != nil ? armor3.int_plus : 0
    n += armor4 != nil ? armor4.int_plus : 0
    n = Intelligence_Limit != nil ? [[n, 1].max, Intelligence_Limit].min : [n, 1].max
    return n
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    if Exp_Limit != nil
      @exp = [[exp, Exp_Limit].min, 0].max
    else
      @exp = [exp, 0].max
    end
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
end

class Game_Battler
  #--------------------------------------------------------------------------
  # * Include Limits - Laziness and to Avoid Typing As Much
  #--------------------------------------------------------------------------
  include Limits
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :damage_limit_enabled
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  alias damage_limit_initialize initialize
  def initialize
    damage_limit_initialize
    @damage_limit_enabled = true
  end
  #--------------------------------------------------------------------------
  # * Get Strength (STR)
  #--------------------------------------------------------------------------
  def str
    if Strength_Limit != nil
      n = [[base_str + @str_plus, 1].max, Strength_Limit].min
    else
      n = [base_str + @str_plus, 1].max
    end
    for i in @states
      n *= $data_states[i].str_rate / 100.0
    end
    if Strength_Limit != nil
      n = [[n, 1].max, Strength_Limit].min
    else
      n = [n, 1].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Get Dexterity (DEX)
  #--------------------------------------------------------------------------
  def dex
    if Dexerity_Limit != nil
      n = [[base_dex + @dex_plus, 1].max, Dexerity_Limit].min
    else
      n = [base_dex + @dex_plus, 1].max
    end
    for i in @states
      n *= $data_states[i].dex_rate / 100.0
    end
    if Dexerity_Limit != nil
      n = [[n, 1].max, Dexerity_Limit].min
    else
      n = [n, 1].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Get Agility (AGI)
  #--------------------------------------------------------------------------
  def agi
    if Agility_Limit != nil
      n = [[base_agi + @agi_plus, 1].max, Agility_Limit].min
    else
      n = [base_agi + @agi_plus, 1].max
    end
    for i in @states
      n *= $data_states[i].agi_rate / 100.0
    end
    if Agility_Limit != nil
      n = [[n, 1].max, Agility_Limit].min
    else
      n = [n,1].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Get Intelligence (INT)
  #--------------------------------------------------------------------------
  def int
    if Intelligence_Limit != nil
      n = [[base_int + @int_plus, 1].max, Intelligence_Limit].min
    else
      n = [base_int + @int_plus, 1].max
    end
    for i in @states
      n *= $data_states[i].int_rate / 100.0
    end
    if Intelligence_Limit != nil
      n = [[n, 1].max, Intelligence_Limit].min
    else
      n = [n, 1].max
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  # * Set Maximum HP
  #     maxhp : new maximum HP
  #--------------------------------------------------------------------------
  def maxhp=(maxhp)
    @maxhp_plus += maxhp - self.maxhp
    if Hp_Plus_Limit != nil
      @maxhp_plus = [[@maxhp_plus, -Hp_Plus_Limit].max, Hp_Plus_Limit].min
    end
    @hp = [@hp, self.maxhp].min
  end
  #--------------------------------------------------------------------------
  # * Set Maximum SP
  #     maxsp : new maximum SP
  #--------------------------------------------------------------------------
  def maxsp=(maxsp)
    @maxsp_plus += maxsp - self.maxsp
    if Sp_Plus_Limit != nil
      @maxsp_plus = [[@maxsp_plus, -Sp_Plus_Limit].max, Sp_Plus_Limit].min
    end
    @sp = [@sp, self.maxsp].min
  end
  #--------------------------------------------------------------------------
  # * Set Strength (STR)
  #     str : new Strength (STR)
  #--------------------------------------------------------------------------
  def str=(str)
    @str_plus += str - self.str
    if Str_Plus_Limit != nil
      @str_plus = [[@str_plus, -Str_Plus_Limit].max, Str_Plus_Limit].min
    end
  end
  #--------------------------------------------------------------------------
  # * Set Dexterity (DEX)
  #     dex : new Dexterity (DEX)
  #--------------------------------------------------------------------------
  def dex=(dex)
    @dex_plus += dex - self.dex
    if Dex_Plus_Limit != nil
      @dex_plus = [[@dex_plus, -Dex_Plus_Limit].max, Dex_Plus_Limit].min
    end
  end
  #--------------------------------------------------------------------------
  # * Set Agility (AGI)
  #     agi : new Agility (AGI)
  #--------------------------------------------------------------------------
  def agi=(agi)
    @agi_plus += agi - self.agi
    if Agi_Plus_Limit != nil
      @agi_plus = [[@agi_plus, -Agi_Plus_Limit].max, Agi_Plus_Limit].min
    end
  end
  #--------------------------------------------------------------------------
  # * Set Intelligence (INT)
  #     int : new Intelligence (INT)
  #--------------------------------------------------------------------------
  def int=(int)
    @int_plus += int - self.int
    if Int_Plus_Limit != nil
      @int_plus = [[@int_plus, -Int_Plus_Limit].max, Int_Plus_Limit].min
    end
  end
  #--------------------------------------------------------------------------
  # * Set Hp (Damage Limit)
  #--------------------------------------------------------------------------
  alias damage_limit_hp= hp=
  def hp=(hp)
    # Get old hp and
    old_hp, new_hp = self.hp, hp
    # If Damage is A Number and Difference is damage
    if self.damage.is_a?(Numeric) and old_hp - new_hp == self.damage and self.damage > 9999 and @damage_limit_enabled
      # Get Damage
      n = self.damage
      # Set New Damage
      damage_hp = Damage_Limit.nil? ? n : Damage_Limit
      # Set Hp
      self.damage_limit_hp = old_hp - damage_hp
      # Set Damage
      self.damage = damage_hp
    else
      # The usaul
      self.damage_limit_hp = hp
    end
    # Reset Damage Enabled Flag
    @damage_limit_enabled = false
  end
  #--------------------------------------------------------------------------
  # * Attack Effect
  #--------------------------------------------------------------------------
  alias damage_limit_attack_effect attack_effect
  def attack_effect(attacker)
    self.damage_limit_enabled = true
    damage_limit_attack_effect(attacker)
    return true
  end
  #--------------------------------------------------------------------------
  # * Skill Effect
  #--------------------------------------------------------------------------
  alias damage_limit_skill_effect skill_effect
  def skill_effect(user, skill)
    self.damage_limit_enabled = true
    effective = damage_limit_skill_effect(user, skill)
    return effective
  end
  #--------------------------------------------------------------------------
  # * Item Effect
  #--------------------------------------------------------------------------
  alias damage_limit_item_effect item_effect
  def item_effect(item)
    self.damage_limit_enabled = true
    effective = damage_limit_item_effect(item)
    return effective
  end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top