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.

BDR Damage

BDR Damage Version: 1.0 for RMVX
By: Fustel

Introduction
This script is just a technical one, but will be required by future BDR scripts.
Basicallyn it splits the Game_Battler::make_attack_damage_value and Game_Battler::make_obj_damage_value methods, which compute damage, into sub-methods which could be easily overloaded without modifying the main ones.

Features
None

Screenshots

Demo

Script
Code:
#==============================================================================

# ** BDR Damage

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

#  © Fustel, 2010

#  02/04/10

#  Version 1.0

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

#  VERSION HISTORY:

#   - 1.0 (02/04/10), Initial release

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

#  INSTRUCTIONS:

#   - Place this script at the top of the 'Materials' section

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

# NOTES

# This script splits the Game_Battler.make_attack_damage_value and

#   Game_Battler.make_obj_damage_value into sub-method which can be

#   easily overwritten to modify damage calculation

# Each of these sun-method accepts the 'attacker' or 'user'/'obj'

#   parameter to finely tune the calculation

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

 

class Game_Battler

 

  # physical attack

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

 

  def bdr_attack_damage_atk( attacker)

    result = attacker.atk * 4

    return result

  end

 

  def bdr_attack_damage_def( attacker)

    result = self.def * 2

    return result

  end

 

  def bdr_attack_damage_element_rate( attacker)

    result = elements_max_rate( attacker.element_set)

    return result

  end

 

  def bdr_attack_damage_minimum( attacker)

    result = rand( 2)

    return result

  end

 

  def bdr_attack_damage_critical_done( attacker)

    result = prevent_critical ? false : ( rand( 100) < attacker.cri)        # critical hit?)

    return result

  end

 

  def bdr_attack_damage_critical_multiplier( attacker)

    result = @critical ? 3 : 1

    return result

  end

 

  def bdr_attack_damage_apply_variance( attacker, damage)

    result = apply_variance( damage, 20)

    return result

  end

 

  def bdr_attack_damage_apply_guard( attacker, damage)

    result = apply_guard( damage)

    return result

  end

 

  def bdr_attack_damage( attacker)

    damage = 0

    damage += bdr_attack_damage_atk( attacker)

    damage -= bdr_attack_damage_def( attacker)

    damage = [ damage, 0].max

    damage *= bdr_attack_damage_element_rate( attacker)

    damage /= 100

 

    if damage == 0

      damage = bdr_attack_damage_minimum( attacker)

    elsif damage > 0

      @critical = bdr_attack_damage_critical_done( attacker)

      damage *= bdr_attack_damage_critical_multiplier( attacker)

    end

 

    damage = bdr_attack_damage_apply_variance( attacker, damage)

    damage = bdr_attack_damage_apply_guard( attacker, damage)

 

    return damage

  end

 

  def make_attack_damage_value(attacker)

    @hp_damage = bdr_attack_damage( attacker)

  end

 

  # Skill / Item

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

 

  def bdr_obj_damage_base( user, obj)

    result = obj.base_damage

    return result

  end

 

  def bdr_obj_damage_attacker_atk( user, obj)

    result = user.atk * 4 * obj.atk_f / 100

    return result

  end

 

  def bdr_obj_damage_attacker_spi( user, obj)

    result = user.spi * 2 * obj.spi_f / 100

    return result

  end

 

  def bdr_obj_damage_defender_def( user, obj)

    result = self.def * 2 * obj.atk_f / 100

    return result

  end

 

  def bdr_obj_damage_defender_spi( user, obj)

    result = self.spi * 1 * obj.spi_f / 100

    return result

  end

 

  def bdr_obj_damage_ignore_defense( user, obj)

    result = obj.ignore_defense

    return result

  end

 

  def bdr_obj_damage_element_rate( user, obj)

    result = elements_max_rate( obj.element_set)

    return result

  end

 

  def bdr_obj_damage_apply_variance( user, obj, damage)

    result = apply_variance( damage, obj.variance)

    return result

  end

 

  def bdr_obj_damage_apply_guard( user, obj, damage)

    result = apply_guard( damage)

    return result

  end

 

  def bdr_obj_damage_to_mp( user, obj)

    result = obj.damage_to_mp

    return result

  end

 

  def bdr_obj_damage( user, obj)

    damage = 0

    damage += bdr_obj_damage_base( user, obj)

 

    if damage > 0

      damage += bdr_obj_damage_attacker_atk( user, obj)

      damage += bdr_obj_damage_attacker_spi( user, obj)

      unless bdr_obj_damage_ignore_defense( user, obj)

        damage -= bdr_obj_damage_defender_def( user, obj)

        damage -= bdr_obj_damage_defender_spi( user, obj)

      end

      damage = 0 if damage < 0

    elsif damage < 0

      damage -= bdr_obj_damage_attacker_atk( user, obj)

      damage -= bdr_obj_damage_attacker_spi( user, obj)

    end

 

    damage *= bdr_obj_damage_element_rate( user, obj)

    damage /= 100

 

    damage = bdr_obj_damage_apply_variance( user, obj, damage)

    damage = bdr_obj_damage_apply_guard( user, obj, damage)

 

    return damage

  end

 

  def make_obj_damage_value( user, obj)

    if bdr_obj_damage_to_mp( user, obj)

      @mp_damage = bdr_obj_damage( user, obj)

    else

      @hp_damage = bdr_obj_damage( user, obj)

    end

  end

end

Instructions
  • Copy the script at the start of the 'Materials' section, as it fully overwrite the main methods

FAQ

Compatibility
May interfere with scripts that fully overwrite the damage computing methods

Credits and Thanks
All done by myself

Author's Notes

Terms and Conditions
You may NOT use this in a commercial game without my explicit permission.
You may NOT post this script anywhere without my explict permission.
You *MUST* give me credit.
 

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