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.

Small change for the damage formula. [RMVX]

I'm needing something that is, in theory, very small, though I could be completely wrong. I want to change the battle formula using MP as a percentage, and specifically I need the following to happen:

1. I want actors/enemies alike to deal that percentage of their MP as their damage.
2. Actors and enemies spend 25 MP every time they perform a normal attack. This needs to happen after said damage is calculated.

For example:
Player A has 90/100 MP. Player A attacks and goes down to 65/100 MP. They will only inflict 90% of their expected damage because they had 90 MP.


I want to say that there should be a default damage formula around, and you would basically plug in a (current battler's SP/100) on top of it. It's really the second thing I need that I have absolutely no clue how to do.

Any help at all would be much appreciated. Thanks in advance.
 
Here, I think I've come up with something.

Go to Game_Battler 3 and find line 49. It should say # Calculate basic damage. Replace the two lines beneath it with this code:

Code:
 

atk = [attacker.atk - self.pdef, 0].max

self.damage = ((atk + attacker.str) / 2)*attacker.sp

attacker.sp-=25

 

What I've done here is make it so that normal attacks do damage equal to the average of your attack and strength multiplied by your SP. Each attack takes 25 SP.

Now all you need to do is fix everyone's SP to 100 and change their atk and strength appropriately. Right now, normal attacks do pretty outrageous damage at 100% SP.

Hope that helps.
 
Thank you very much, though not quite what I was aiming for. That particular edit would make a character with 100% SP do 100 times their expected damage, no? Still, I think we're on the right track.

In my game, I'm utilizing a stamina system with 100 MP acting like a percentage. I've already worked out all characters recovering X amount of MP at the beginning of every round, but as far as attacking is concerned, I want it to scale with the character's MP. Essentially, if you take the damage formula, multiply it by the attacker's MP, then divide by 100, that achieves exactly what I'm trying to do.

I really hate to be a pain, but I'll be needing that in RMVX form rather than RMXP. Sorry about that. :cry:
 
hey xionteikiatsu

I think this should work...atleast it seemed to when i was testing it

Goes in Game_Battler under the Calculation of Damage From Normal Attack section
Code:
 

 def make_attack_damage_value(attacker)

    # replace damage formula using here to....

    base_damage = attacker.atk * 4 - self.def * 2        # base calculation

    if attacker.maxmp ==0                                             # incase actor/enemy has no maxmp

      damage = base_damage

    elsif attacker.mp > 0                

      damage = base_damage * attacker.mp/attacker.maxmp

    end

    # here

    damage = 0 if damage < 0                        # if negative, make 0

    damage *= elements_max_rate(attacker.element_set)   # elemental adjustment

    damage /= 100

    if damage == 0                                  # if damage is 0,

      damage = rand(2)                              # half of the time, 1 dmg

    elsif damage > 0                                # a positive number?

      @critical = (rand(100) < attacker.cri)        # critical hit?

      @critical = false if prevent_critical         # criticals prevented?

      damage *= 3 if @critical                      # critical adjustment

    end 

    attacker.mp-= 25                                 # loose 25mp per normal attack

    damage = apply_variance(damage, 20)             # variance

    damage = apply_guard(damage)                    # guard adjustment   

    @hp_damage = damage                             # damage HP

  end

 

As you probably know, you only need to replace the damage formula and add in the attack.mp-= 25
(or you can replace the whole thing)

In the above def is applied before the reduction caused by mp. It can be change by moving it to after the two damage lines though.

I also used maxmp instead of 100 incase you wanted to use different mps and still do damage based on a % of the max.

hope its what you were looking for =D
 
oops i noticed a small mistake I made
the line...
if attacker.mp == 0
damage = base_damage

should be

if attacker.maxmp == 0
damage = base_damage

otherwords you'll probably notice attacking with 0mp causes you're characters to take off max damage

note: error has been fixed in the previous post
 

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