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.

A simple question

I'm trying to make the damage calculation for my game to use Str Factor for melee weapons while Dex for ranged weapon.
This question I'm asking involved in Game_Battler 3 where the damaged in battles are calculated.

What should I add into the "Applying Normal Attack Effects" script to have the damage cause by an actor using melee weapon to be calculated using this formula

Code:
self.damage = ((atk * 2) + attacker.str) - (self.pdef * 2)

While a ranged weapon (Bows, guns, etc.) to be calculated with Dex factors instead

Code:
self.damage = ((atk * 2) + attacker.dex) - (self.pdef * 2)

I'm kinda sucks when it comes to explaining things, but I hope someone could help me with this.
 
In the default system (new game) bows & guns are weapons 17..24

You want to replace line 51 in Game_Battler 3

Code:
      self.damage = atk * (20 + attacker.str) / 20

with

Code:
# if ranged
if (attacker.weapon_id >= 17) and (attacker.weapon_id <= 24)
   self.damage = ((atk * 2) + attacker.dex) - (self.pdef * 2)
else
   self.damage = ((atk * 2) + attacker.str) - (self.pdef * 2)
end

If you've customized your weapons, you'll have to make an adjustment.
the "attacker.weapon_id"  property is the key.
(unless you have additional systems that identify weapons as 'ranged')

If your ranged weapons are scattered through the weapons database, you could
add a 'ranged' element, then check attacker.weapon_id to see if it has that element.

Be Well
 

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