The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Shadow Phoenix on November 23, 2007, 02:04:29 AM

Title: [RESOLVED] A script to change the attack power stat?
Post by: Shadow Phoenix on November 23, 2007, 02:04:29 AM
Yeah, the weapons you can make in RMXP have attack power. Thing is, it causes some... problems...

You see, in my game, you start out with stats that are, at most, in the fifties. So, your first weapon is a weak sword with an attack power of 12. The first boss has defence that is too high FOR THE WEAPON!

Could I have a script that will make it so that the weapons attack power is not so important? As in, it makes it so your char does base damage based on their strength, and the attack power  of a weapon will add damage equal to the strength of the char (weapons and armour included) multiplied by the attack power (turned into a percentage)?

Something like this, for example: (Some sort of formula involving strength and defence to calculate base power of attack) + (strength x (attack power / 100)),

So, an example, lets say the base power (damage without a weapon, if you will) is 12.

12 + (23 x (7 / 100) = 12 + (23 x 0.07) = 12 + 1.61 = 13.61 = 14 (rounded up)?

And yes, I looked MANUALLY to ensure there was no such thing already
Title: Re: [AVAILABLE] A script to change the attack power stat?
Post by: modern algebra on November 23, 2007, 06:56:23 AM
Well, I'll point you to the damage calculation in RGSS. Though, you can always lower the defense of the boss <(''<)

Anyway, go into Game_Battler 3 and find this method:

Code: [Select]
#--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  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
      self.damage = atk * (20 + attacker.str) / 20
      # 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

As you can see, damage calculations are in there. Everything that modifies self.damage is part of the calculation.
Title: Re: [AVAILABLE] A script to change the attack power stat?
Post by: Shadow Phoenix on November 24, 2007, 01:12:25 AM
Thanks!
Title: Re: [RESOLVED] A script to change the attack power stat?
Post by: wasup274 on November 28, 2007, 09:17:27 PM
maybe im just not getting it but why not just lower the bosses def (suggustivly not higher attack because then other monsters will be owned)