XP Damage Formula editing gone wrong

Status
Not open for further replies.

Lord Vectra

Master Eventer
Veteran
Joined
Dec 6, 2015
Messages
211
Reaction score
336
First Language
English
Primarily Uses
RMVXA
I'm trying to do the following:
PDEF and MDEF can only max out at 85 and they decrease damage by a percentage rather the default direct subtraction.

STR partially ignores armor (is currently 20% of your Str)

Physical and Magical defense does not affect healing spells

For some reason, I keep getting 0 as final damage even if I max all stats to 999 and PDEF/MDEF at 0 while making all the "_f" at 100 (except pdef_f and mdef_f). Even when I changed "power / 25" to just "power," it still ended up being 0. Can someone help me because I've been editing the damage formula, and its been a nightmare? I'm fine with someone re-editing this or just leading me to a whole new script that makes it easier.

The default damage formula is this:

Code:
 power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # Calculate rate
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # Calculate basic damage
      self.damage = power * rate / 20
This is what I have:
Code:
power = skill.power
      #Damage spells
    if skill.power > 1
        rate = 25
        rate += user.str * skill.str_f / 100
        rate += user.dex * skill.dex_f / 100
        rate += user.agi * skill.agi_f / 100
        rate += user.int * skill.int_f / 100
        rate += user.atk * skill.atk_f / 100
        power *= rate
        if self.pdef > 85
          rate = self.pdef - 85
        else
          rate = 0
        end
        power *= (100 - (self.pdef - rate - user.str / 5)) / 100 * skill.pdef_f / 100
        if self.mdef > 85
          rate = self.mdef - 85
        else
          rate = 0
        end
        power *= (100 - (self.mdef - rate)) / 100 * skill.mdef_f / 100
        self.damage = power / 25
      end
    #For healing
    if skill.power <= 0
        rate = 25
        rate += user.str * skill.str_f / 100
        rate += user.dex * skill.dex_f / 100
        rate += user.agi * skill.agi_f / 100
        rate += user.int * skill.int_f / 100
        rate += user.atk * skill.atk_f / 100
        power *= rate
        self.damage = power / 25
    end
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,351
Reaction score
8,532
First Language
English
Primarily Uses
RMMV

I've moved this thread to RGSS Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,497
Reaction score
5,334
First Language
english
Primarily Uses
RMMZ

I've moved this thread to RGSS Support. Please be sure to post your threads in the correct forum next time. Thank you.



Edit: ninja'd
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
Here's a couple of things for you to check. These suggestions may come off as me being condescending but I can't tell you how many times I've overlooked something simple, so it pays to be thorough.

-The code you're editing only applies to skills. Are you experiencing this problem with skills or something else?
-Is the power of the skill set to 0? Zero times anything is still zero, and all you do in your code is multiply power with other things.
-Is the power of the skill 1? If it is, you'll never trigger your own code since the first check looks for it to be greater than 1 and the second looks for it to be equal to or less than zero. Since your code isn't run, damage won't be set and it defaults to 0.
-You can perform some poor man's debugging by adding "print X" statements in your code to check that the values of the variables are what you expect. For example, "print rate" will let you check that all the math you did on rate worked out how you expected. If you think the value should be 100 but it's actually 50 that can help narrow your search for what you did wrong.
 

Lord Vectra

Master Eventer
Veteran
Joined
Dec 6, 2015
Messages
211
Reaction score
336
First Language
English
Primarily Uses
RMVXA
Problem is only with skills and I'm aware it only affects skills and not your normal attack

Power is 15

I found the reason for the 0. If p.def_f or if m.def_f is 0, the damage becomes 0 since the damage deduction is multiplied rather than subtracted. Therefore, all I had to do was check to see if p.def_f and m.def_f is greater than 0 which I did here:


Code:
# Calculate power
     power = skill.power
      #Damage spells
    if skill.power > 1
        rate = 25
        rate += user.str * skill.str_f / 100
        rate += user.dex * skill.dex_f / 100
        rate += user.agi * skill.agi_f / 100
        rate += user.int * skill.int_f / 100
        rate += user.atk * 1.25 * skill.atk_f / 100
        power *= rate
       
        #Checks if Physical Defense > 85
        if self.pdef > 85
          rate = self.pdef - 85
        else
          rate = 0
        end
       
        #Checks if Physical Defense Multiplier > 0
        if skill.pdef_f > 0
          power *= (100 - (self.pdef - rate - user.str / 5)) / 100 * skill.pdef_f / 100
        end
       
        #Checks if Magical Defense > 85
        if self.mdef > 85
          rate = self.mdef - 85
        else
          rate = 0
        end
       
        #Checks if Magical Defense Multiplier is > 0
        if skill.mdef_f > 0
          power *= (100 - (self.mdef - rate)) / 100 * skill.mdef_f / 100
        end
        self.damage = power / 25
      end

    #For healing
    if skill.power < 1
        rate = 25
        rate += user.str * skill.str_f / 100
        rate += user.dex * skill.dex_f / 100
        rate += user.agi * skill.agi_f / 100
        rate += user.int * skill.int_f / 100
        rate += user.atk * skill.atk_f / 100
        power *= rate
        self.damage = power / 25
    end
And thankfully, this formula works. I just have to change the normal attack formula to be something similar which I will do later.
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,497
Reaction score
5,334
First Language
english
Primarily Uses
RMMZ

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top