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.

[XP]Order of Mechanics of RMXP

Nukei

Member

I am using the Enu sideview battle system and have unsuccessfully attempted to try and modify the script.

Issue: Change the order in which damage is dealt:

For example, in my tests:

Attacker attacks monster (0 PDEF, 0% Resistance) = 623 damage
Attacker attacks monster (50 PDEF, 0% Resistance) = 527 damage
Attacker attacks monster (0 PDEF, 50% Resistance) = 311 damage
Attacker attacks monster (50 PDEF, 50% Resistance) = 263 damage

The 96 damage drop from the first two test cases and the 48 damage drop from the last two test cases most likely show that the attacker goes through PDEF calculations first, then resistance calculations.

It may be supported by the order of the code as well:

Code:
  def set_attack_damage_value(attacker)

    case DAMAGE_ALOGARITHM_TYPE

    when 0

      atk = [attacker.atk - (self.pdef / 2), 0].max

      str = [20 + attacker.str, 0].max

    when 1

      atk = [attacker.atk - ((attacker.atk * self.pdef) / 1000), 0].max

      str = [20 + attacker.str, 0].max

    when 2

      atk = 20

      str = [(attacker.str * 4) - (self.dex * 2) , 0].max

    when 3

      atk = [(10 + attacker.atk) - (self.pdef / 2), 0].max

      str = [(20 + attacker.str) - (self.dex / 2), 0].max

    end

    self.damage = atk * str / 20

    self.damage = 1 if self.damage == 0 and (rand(100) > 40)

    self.damage *= elements_correct(attacker.element_set)

    self.damage /= 100

  end

In this script, when 0, 1, 2, and 3 refer to different damage formulas which can be changed at the start of the script (not shown).

I would like it if one could change the order of this formula correctly so that the resistance is calculated first and the PDEF calculations calculated afterward.

I will learn from your example and try doing mdef calculations by myself.

Thanks for your time, Nukei.
 
Changing the order will not make a difference. (remember the commutative property of multiplication?)

If by "resistance", you mean 'elements_correct()', That is just a %

Here is the entire formula, for case 0...

damage = (attacker.atk - self.pdef / 2) * (20 + attacker.str) / 20 * elements_correct(attacker.element_set) / 100

are you saying you want...

damage = (attacker.atk * elements_correct(attacker.element_set) / 100) * (20 + attacker.str) / 20 - self.pdef / 2

or

damage = (attacker.atk) * (20 + attacker.str * elements_correct(attacker.element_set) / 100) / 20 - self.pdef / 2

or something else?
 

Nukei

Member

What I meant by order was that the element calculations seem to be after the cases, and thus I believed that since there was no mention of element within the cases, I believed that static damage is used first and the resistance later.

I believe it is the first one. Thanks for your time.
 

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