RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Resolved] Melee vs. Ranged Weapons

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
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.

Quote
    if 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.
« Last Edit: October 29, 2010, 01:43:25 AM by shintashi »

***
Rep:
Level 82
We learn by living...
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.

Quote
    if 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.

***
Rep:
Level 82
We learn by living...
Code: [Select]
    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.