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.

Equipment Alters HP and SP

I'd like to be able to have armor and weapons that increase/decrease HP or SP. I've searched all over and can't find anything. I would also like to be able to see the changes in EquipLeft.

Any help would be great. Thanks!
 

Wazabi

Member

Hello !

You can do like this:

steps.png

Of course, you can modify the percentage of HP.


(Sorry for the French version !)
 
Yeah, I thought of that. The only issue is that that method only allows for percentage-based HP alteration, and I need to specify exactly how much the weapon/armor changes a character's HP/SP. Thanks though! :D
 

Atoa

Member

Another 10 minutes simple code .-.\

Maxhp[type][ID] = value
Maxsp[type][ID] = value

type = Equip type, 'Weapon' or 'Armor'
ID = equip ID
value = changed value
Code:
#==============================================================================

# 

#==============================================================================

 

module Atoa

 

  Maxhp = {'Weapon' => {}, 'Armor' => {}}

  Maxsp = {'Weapon' => {}, 'Armor' => {}}

  

  

  Maxhp['Weapon'][1] = 50

  

  Maxhp['Armor'][1] = 50

  

  

  Maxsp['Weapon'][1] = -50

  

  Maxsp['Armor'][1] = -50

  

end

 

#==============================================================================

# RPG::Weapon

#==============================================================================

 

class RPG::Weapon

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def maxhp

    return (Atoa::Maxhp['Weapon'][@id].nil? ? 0 : Atoa::Maxhp['Weapon'][@id])

  end

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def maxsp

    return (Atoa::Maxsp['Weapon'][@id].nil? ? 0 : Atoa::Maxsp['Weapon'][@id])

  end

end

 

#==============================================================================

# RPG::Armor

#==============================================================================

 

class RPG::Armor

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def maxhp

    return (Atoa::Maxhp['Armor'][@id].nil? ? 0 : Atoa::Maxhp['Armor'][@id])

  end

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def maxsp

    return (Atoa::Maxsp['Armor'][@id].nil? ? 0 : Atoa::Maxsp['Armor'][@id])

  end

end

 

#==============================================================================

# Game_Actor

#==============================================================================

 

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def weapons

    result = [$data_weapons[@weapon_id]]

    result.delete_if {|x| x == nil }

    return result

  end

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def armors

    result = []

    result << $data_armors[@armor1_id]

    result << $data_armors[@armor2_id]

    result << $data_armors[@armor3_id]

    result << $data_armors[@armor4_id]

    result.delete_if {|x| x == nil }

    return result

  end

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  def equips

    return weapons + armors

  end  

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  alias base_maxhp_hpspequip base_maxhp

  def base_maxhp

    value = base_maxhp_hpspequip

    equips.each {|equip| value += equip.maxhp}

    return value

  end

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  alias base_maxsp_hpspequip base_maxsp

  def base_maxsp

    value = base_maxsp_hpspequip

    equips.each {|equip| value += equip.maxsp}

    return value

  end

  #--------------------------------------------------------------------------

  # 

  #--------------------------------------------------------------------------

  alias equip_hpspequip equip

  def equip(equip_type, id)

    equip_hpspequip(equip_type, id)

    @hp = [@hp, self.maxhp].min

    @sp = [@sp, self.maxsp].min

  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