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.

Changing damage calculations in RGSS2/VX

Seems simple enough; I was easily able to do this in XP/RGSS, but I'm stumped doing this with VX/RGSS2.  I would like to modify damage to where defense is calculated not as a set value, but as a percentage.  I.E., if a foe has a defense of 100, it would mean damage is reduced by 100%- he is normally unaffected by physical attacks, whereas if the foe's defense is 50, it means physical attacks are basically cut in half.  I understand the calculations, but I don't know what variables and classes these are assigned to in VX/RGSS2.  I spent some time browsing through the built-in classes, but none of them seem to deal directly with calculating damage (I do recall in XP, it's in the Game_Battler 3 class), so I don't even have a template to work with in VX/RGSS2.  Any help would be greatly appreciated!  Thanks!

  -- David
 

Atoa

Member

you want that defense works in % right?
Be sure that the defense do go over 100

in game battler look for:
for physical damage
Code:
   damage = attacker.atk * 4 - self.def * 2 
change it to:
Code:
  atk_power = attacker.atk #you can change it any way you want like use VX "attacker.atk * 4" formula
 damage = atk_power - (atk_power * self.def/100)

since in VX theres no "Mag def" status, you will have to use defense for both.
so you can do this for mag damage

change:
Code:
    if damage > 0                                   # a positive number?
      damage += user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage += user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
      unless obj.ignore_defense                     # Except for ignore defense
        damage -= self.def * 2 * obj.atk_f / 100    # Attack F of the target
        damage -= self.spi * 1 * obj.spi_f / 100    # Spirit F of the target
      end
      damage = 0 if damage < 0                      # If negative, make 0
    elsif damage < 0                                # a negative number?
      damage -= user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage -= user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
    end

to:
Code:
    if damage > 0                                   # a positive number?
      atk_power = user.atk #you can too change the formula here
      mag_power = user.spi #you can too change the formula here
      damage += atk_power * obj.atk_f / 100      # Attack F of the user
      damage += mag_power * 2 * obj.spi_f / 100      # Spirit F of the user
      unless obj.ignore_defense                     # Except for ignore defense
        damage -= atk_power * self.def * obj.atk_f / 10000    # Attack F of the target
        damage -= mag_power * self.def * obj.spi_f / 10000   # Spirit F of the target
      end
      damage = 0 if damage < 0                      # If negative, make 0
    elsif damage < 0                                # a negative number?
      damage -= user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage -= user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
    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