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.

[FILLED] Dexterity for DMG instead of Strength

My game takes place in modern times, and I was wondering if someone could make a script that would affect certain weapons or classes so your dexterity stat determines your damage instead of strength (right now it's setup so that the harder your pull the trigger the more damage you do, which makes no damn sense at all.)

If you could, it'd be cool if you could also do support for other stats like Agi or Int based damage instead of Str.

Thanks
 
Because then Dex would determine strength damage for melee weapons. What I'm talking about is the kind of system you see in Ragnarok Online and Dungeons and Dragons where an archer's damage is tied to his dexterity (skill of hitting the target) instead of how hard he pulls on the bow or how hard he pulls the trigger of a gun, and at the same time you can still have a guy with a lead pipe who's very strong and can hit hard with the pipe because of his Str stat.
 

Shiro

Member

How do you want the damage calculated? Do you want it to use the same formula as the normal damage formula, but with DEX instead of STR? Or a different formula?

STR-based damage:
Code:
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20

would you like it to be...
Code:
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.dex) / 20
???
 
Myonosken;123367 said:
Ohhh...Hang on, do you want Str to be like normal and determine damage for Melee, and then DEX for guns and the sort?

Yes. You see this kind of system in DnD and RO as I said. Right now RMXP is setup so that Str and Atk determines the damage you do with a weapon. This doesn't make sense for things like corssbows and guns. I want it to be so that the characters Dexterity score is used to determine the damage you do with a ranged weapon (like Shiro said.) That way the better you are at aiming determines how much damage you do with guns.

And if it was the same formula as strength that would be cool.

Also, if you could make it so that certain weapons (staffs, rods or magic book types) do more melee damage with Int.

EDIT: If possible, something like an element tag (Str based, Int based, Dex based, etc.)
 

Shiro

Member

Go to scripts

Select Game_Battler 3

Find this line of code:
Code:
self.damage = atk * (20 + attacker.str) / 20
Right under that, insert this line of code:
Code:
if atk.element_set.include?(1) # THE NUMBER IS THE ELEMENT
       atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.dex) / 20 
    end

Change the 1 to whatever number element you want. You can also make another one under that which uses user.int as well.

Then in weapons, use select that element.

Any questions? (I didn't test this but it should work... but then again, I'm a n00b at scripting :()

EDIT:
In D&D you don't use DEX for damage (then again, I've only played 3.0E rules and up). Damage is based on the 'mighty' attribute which is based on STR. Why? The more you can pull back the bow, the stronger the arrow will be. By saying damage is DEX based, you're saying just because you have godly grace and dexterity, your aim (20DEX) does the same damage as a giant (20STR) smacking you with an axe?

For example, you're shooting an arrow at a blank wall. No matter how agile and dexterious you are, that arrow is not going to do any more damage. But if you're able to pull the arrow back with more force (without breaking the bow), then you could do more damage to a wall.

For guns, neither STR nor DEX should really be used for damage, there should be a set damage for it regardless cause there's not much you can do to raise the total damage. But this is just my two cents and I'm semi-off topic rant :P
 
Thanks a lot for the script! I'm about to test it out in a second.

The reason why I'm doing things this way is because in my game the dexterity stat is used for how well you aim. It's true a gun technically will do the same amount of damage every time you pull the trigger, but, a character with sharp eyes has a greater change to hit certain places on a target like someone's eyes, heart or brain. Thus, a character with higher dexterity would have a greater chance to hit places that do more damage on the body.

In DnD I was kinda referring to certain classes like the Paladin and Swashbuckler that can add their ability modifiers to their melee damage.

Also, there are no bow and arrows in my game, but crossbows, which count as "guns" as well.

EDIT: And I just tried out the code and it doesn't seem to work... Sorry :(
 
Shiro had the right idea, just got one object wrong. I just put it into a format I like better (no sense calculating something then overwriting it a couple of lines after :P).
Replace your attack_effect method in Game_Battler 3 with this:
Code:
  #--------------------------------------------------------------------------
  # * 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
      # ***Begin Modification***
      if attacker.element_set.include?(1) # Change this number to the element ID you want to use for ranged weapons
        self.damage = atk * (20 + attacker.dex) / 20
      else
        self.damage = atk * (20 + attacker.str) / 20
      end                                            
      # ***End modification***
      # 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 it says in the comment, change the number in the brackets to the element ID you want to use, then set all your ranged weapons to use that element in the database. (I'd name the element "Ranged" or something similar ;))
Since dexterity is already used to determine critical hits, I can also make it so strength is used instead when using a ranged weapon - if you feel so inclined.

I tested it, so it should work fine :P
 
kyonides":39h0rfkx said:
How weird! If the enemies (Game_Enemy) are also Game_Battler 's then they should be able to take advantage of that script mod, especially if the enemies call that method...

They can't because the part the script is referencing is based on the equipment of the actor, I think I need to know how to write an if statement using the attacker's resistance to a status effect or element.
For example I need:
if attacker resists element (element)

With that bit of code all enemies that resist that element (probably a dummy element) will be able to do damage differently than normal.

Problem is, I don't know how to write that statement.
 
On the actor's equipment? Mmm, maybe I'm completely asleep and miss that part you read because I didn't find any direct method call to anything regarding the equipment. I found several things concerning the element state though.

Anyway, it's for defenders not for attackers since self should be a reference to an enemy getting hit in your hypothetical case. IDK why you'd need to know if the attacker resists an element at all. Maybe I'd need some more explanation or / and get some sleep he he he.
 
kyonides":2hgw9jj2 said:
On the actor's equipment? Mmm, maybe I'm completely asleep and miss that part you read because I didn't find any direct method call to anything regarding the equipment. I found several things concerning the element state though.

Anyway, it's for defenders not for attackers since self should be a reference to an enemy getting hit in your hypothetical case. IDK why you'd need to know if the attacker resists an element at all. Maybe I'd need some more explanation or / and get some sleep he he he.

The element state is only located on the equipment though, you can't set an enemy's basic attack to have elements associated with them.
However, enemies can have elemental resistances.

I'm trying to get the game to check a dummy elemental resistance.
For Example: If attacker A resists the element "Turtles", then A's attack will be calculated: atk = 9000
But if attacker A does not resist the element "Turtles" then A's attack will be calculated normally.

The fact that the attacker resists "Turtles" will never actually matter except for this purpose.
Also I'm only using atk = 9000 for example purposes.
 
Mmm, I'm sorry but your explanation got me more confused than I was before. Maybe the thing is that you practically need a new method to do that and I missed your point. If so, that script post wouldn't help you at all since it's based on what will happen to the defender.

(Going to edit this post later...)
 

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