The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: shintashi on October 28, 2010, 05:57:03 AM

Title: [Resolved] Melee vs. Ranged Weapons
Post by: shintashi on October 28, 2010, 05:57:03 AM
I put it in about 20 minutes ago but I'm not sure I got my order correct. I might have misplaced my 'end'. I was trying to set all ranged weapons (id 17+) to do flat damage while melee weapons (id 1-16) get bonuses from strength.

Quoteif hit_result == true
      # Calculate basic damage
      if self.weapon_id == nil || self.weapon_id >= 17
      atk = [(attacker.atk) - self.pdef, 0].max
    else
        atk = [(attacker.atk + attacker.str) - self.pdef, 0].max # read else
      end #might have to move end down edited by shintashi
        self.damage = atk * (atk + 2)   
      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) < 10 * attacker.dex / self.agi # was 4%
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end

PS: this works fine in games with attributes of about 5-15 and hit points in the 250-1000 range.
Title: Re: combat script? did I parse this right?
Post by: shintashi on October 29, 2010, 12:53:53 AM
Quote from: shintashi on October 28, 2010, 05:57:03 AM
I put it in about 20 minutes ago but I'm not sure I got my order correct. I might have misplaced my 'end'. I was trying to set all ranged weapons (id 17+) to do flat damage while melee weapons (id 1-16) get bonuses from strength.

Quoteif hit_result == true
      # Calculate basic damage
if attacker.weapon_id == nil || attacker.weapon_id >= 17
      atk = [(attacker.atk) - self.pdef, 0].max
    else
        atk = [(attacker.atk + attacker.str) - self.pdef, 0].max # read else
      end #might have to move end down edited by shintashi
        self.damage = atk * (atk + 2)   
      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) < 10 * attacker.dex / self.agi # was 4%
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end

PS: this works fine in games with attributes of about 5-15 and hit points in the 250-1000 range.

Fixed... but I can't figure out why enemies are doing so much damage. It's like their damage coefficient is on a completely different scale.
Title: [Resolved] Melee vs. Ranged Weapons
Post by: shintashi on October 29, 2010, 01:41:43 AM
    if hit_result == true
      # Calculate basic damage
      if attacker.weapon_id == nil || attacker.weapon_id >= 17
      atk = [(attacker.atk + rand(Integer(attacker.dex/2))) - self.pdef, 0].max
    else
atk = [(attacker.atk + attacker.str + rand(Integer(attacker.agi/2))) - self.pdef, 0].max
# used to read completely differently
      end #might have to move end down edited by shintashi
        self.damage = atk * (atk + 2)   
      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) < 10 * attacker.dex / self.agi # was 4%
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end


This is my refined script. It does different damage for melee weapons than ranged weapons. Ranged weapons do damage based on the weapon, slightly modified by dexterity. Melee weapons, like swords and knives, do damage based on the weapon, plus strength, modified slightly by agility. Note that you will want to either greatly reduce melee damage or greatly increase ranged damage of weapons to compensate the difference.