Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Kagutsuchi on January 04, 2009, 01:59:56 pm

Title: Alter how battle damage is calculated
Post by: Kagutsuchi on January 04, 2009, 01:59:56 pm
How do I alter how battle damage is calculated for a basic attack?
I know that your STR somehow affects your battle damage, I want to remove that and basically I want the way battle damage is calculated to be ATK - PDEF. And of course the outcome to become 0 if it is below 0.
Title: Re: Alter how battle damage is calculated
Post by: Aqua on January 04, 2009, 02:09:14 pm
Game Battler 3
def attack_effect

Line 51 is the part with the strength.
Title: Re: Alter how battle damage is calculated
Post by: winkio on January 04, 2009, 02:44:56 pm
If you need help ill do it.  I've already done a full damage calculation edit.
Title: Re: Alter how battle damage is calculated
Post by: Kagutsuchi on January 04, 2009, 05:25:59 pm
Yeah that would be nice winkio, cause no matter what I try to do with line 51 the strenght always seems to remain a part of the calculation ^^;;
Title: Re: Alter how battle damage is calculated
Post by: winkio on January 04, 2009, 06:02:09 pm
either comment out or delete line 51 from Game_Battler 3.  Or, if you want a script you can stick below the defaults, use this:

Spoiler: ShowHide
#==============================================================================
# Custom damage script
#------------------------------------------------------------------------------
# does not factor STR into attack damage
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # attack_effect
  #
  # this method calculates the damage done by an attack
  # modified so that damage is ATK - PDEF
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Miss"
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
end

Title: Re: Alter how battle damage is calculated
Post by: Kagutsuchi on January 04, 2009, 06:49:53 pm
EDIT: (Yes I deleted the entire shit for an edit :P)
Turns out that another script I am using also overwrites the damage calculations, so I had to mess around with it as well ^^ thanks for the help