[RESOLVED] Elemental Modifier (RPGXP)

Started by MeVII, January 08, 2009, 01:17:00 am

Previous topic - Next topic

MeVII

January 08, 2009, 01:17:00 am Last Edit: January 11, 2009, 12:08:17 pm by MeVII
I requested help understanding how Elemental modifiers get applied in combat.
After some testing I clearly observed that elemental damage was not being calculated correctly,
according to what RGPXP says in its help file.

Damage Formula: ShowHide
Quote"Damage = force × multiplier ÷ 20 × elemental modifier × critical modifier × defense modifier (± variance %)
Elemental modifier: The weakest of B's effective elements corresponding to the action's element(s).
A: 200%, B: 150%, C: 100%, D: 50%, E: 0%, F: -100%
Reduced by half if B's armor or state has a defending (opposing) element.
When there are more than one of the same defending elements, the damage may be halved multiple times. "


Blizzard verified that the game system has a fault in it, and provided a miniscript fix.
Telling me to add it placed below the entire set of Blizzards tons of add ons.

Miniscript: ShowHide
class Game_Battler
  $DUMMY_ELEMENTS = [] if $DUMMY_ELEMENTS == nil
  def elements_correct(elements)
    return 100 if elements.size == 0
    multiplier = 0
    size = 0
    elements.each {|i|
        if !$DUMMY_ELEMENTS.include?(i) && self.element_rate(i) != 100
          multiplier += self.element_rate(i)
          size += 1
        end}
    return 100 if size == 0
    return multiplier/size
  end
end


I added the script and retested the game, but still was not getting the correct results.
After no success with more troubleshooting I replied here, and blizzard provided extra
details regarding the faulty calculation system.

Blizzards Explanation: ShowHide
QuoteI'll explain the error:

Weapon with elements 1 and 2.
Enemy very weak against 1 (200% damage).
The damage will be 150%.
Why?
Simple, it takes the average between element 1 and 2 (even though 2 should be completely neutral),
resulting in average of 100% and 200% which is 150% damage.
The correct would be 200% damage since element 2 should be ignored, it doesn't alter anything.
That's the error and that's what the code I gave above fixes.


So going back I tested a 3rd time, armed with the exact information I noticed something
in the averages that caused me to recall something.
In the Blizzard TOAO, there is a setting in section 1, near or on lines 657 and 658 for setting
dummy elements and dummy states.

It was my fault.

I had been using dummy elements for something and had them listed there.
I stopped using them, and although I removed them from the list in the
systems settings, I LEFT their IDs in the scripts configuration.

Naturally this caused the legitimate elements I had recreated in those ID slots
to be ignored.
I removed the IDs, added the miniscript Blizzard provided,
and wouldn't you know it ... everything works fine now.

*Rolls Eyes and Shakes Head at Self*

Thanks for all the help Bliz.

                                                                                   Me VII

P.S. My final corrected testing stats are below, for anyone who would just like to see
how things look/came out when all was said and done.

Final Test Data: ShowHide



Battle Test Character Stat Totals
Str    1
Dex   2
Atk    100

Battle Test Monster Stat Totals
Str     1
Dex    1
PDEF  0




Miniscript = Active

Weapon
Element 1 = Inactive, Element 2 = Inactive

Enemy
Element 1 = A - 200%, Element 2 = C - 100%

Attacks
109,108,110,107,100,113,109,100,102,106 - Average = 106.4




Miniscript = Active

Weapon
Element 1 = Active, Element 2 = Inactive

Enemy
Element 1 = A - 200%, Element 2 = C - 100%

Attacks
195,183.220,202,208,231,220,210,204,207 - Average = 208




Miniscript = Active

Weapon
Element 1 = Active, Element 2 = Active

Enemy
Element 1 = A - 200%, Element 2 = C - 100%

Attacks
221,221,208,228,191,212,210,214,205,194- Average = 210.4




Miniscript = Active

Weapon
Element 1 = Active, Element 2 = Active

Enemy
Element 1 = A - 200%, Element 2 = B - 150%

Attacks
184,191,194,166,186,177,157,182,181,178 - Average = 179.6




Miniscript = Active

Weapon
Element 1 = Active, Element 2 = Active

Enemy
Element 1 = A - 200%, Element 2 = D - 50%

Attacks
116,134,147,133,126,143,196,143,123,133  - Average = 139


Blizzard

It's actually faulty. More-than-one-element weapon/items/skills aren't calculated right. This is the one I use in my game (without the absorbing element parts).

class Game_Battler
  $DUMMY_ELEMENTS = [] if $DUMMY_ELEMENTS == nil
  def elements_correct(elements)
    return 100 if elements.size == 0
    multiplier = 0
    size = 0
    elements.each {|i|
        if !$DUMMY_ELEMENTS.include?(i) && self.element_rate(i) != 100
          multiplier += self.element_rate(i)
          size += 1
        end}
    return 100 if size == 0
    return multiplier/size
  end
end


$DUMMY_ELEMENTS is an array of elements that is being ignored. You should put it below Tons of Add-ons if you use it (and I know you do xD).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Blizzard

It's actually not that complicated. Yes, there is an edit of the elements_correct method in several places simply adding the override for dummy elements. If you don't set them up, they will not appear.
As I said, the default RMXP elemental calculation is wrong, but all those (identical) overrides work like the normal system does. You need to put that miniscript I gave you right below Tons of Add-ons as I said.

The way it normally behaves is like usually correct, but I'll explain the error:

Weapon with elements 1 and 2.
Enemy very weak against 1 (200% damage).
The damage will be 150%.
Why?
Simple, it takes the average between element 1 and 2 (even though 2 should be completely neutral) resulting in average of 100% and 200% which is 150% damage. The correct would be 200% damage since element 2 should be ignored, it doesn't alter anything. That's the error and that's what the code I gave above fixes.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.