Damage Formulas 101

● ARCHIVED · READ-ONLY
Started by Skunk 281 posts Page 14 of 15 View original ↗
  1. I used this formula for actor 2 "b.actorId() == 2 ? -10 : 50" but instead of causing damage it just doesn't heal but it does heal everyone else which is good but it should cause damage for actor 2. Maybe I didn't input the formula right.
  2. @Sunlo Why didn't you post this in the thread you made where you asked about this and I suggested that formula? It always makes more sense to keep a topic in one place.

    I missed that evalDamageFormula() prevents healing from going into negative just like damage.

    So to do what you want, you'd need to use a plugin like VisuStella Battle Core and change the damage value after it's calculated.
  3. this was a very useful tutorial.
  4. I totally understood all that, *sweats as he tries to be convincing.* Heh I read all those formula's though, very in depth. I imagine it was aimed at MZ but I'm currently on VX Ace, I have MZ but have not started working on that yet. I was just ghosting about here to see if someone was having the same issue, but this is much more advanced then what I'm trying to figure out.

    I was just trying to see if there was a means within the RPG Maker VX itself to make it to where no matter how weak an enemy is, they always do 1 damage at the least. If that was covered in all that....*shudders* math, up there then It clearly went over my head, not hard considering I'm a rodent...ha!
  5. H-and-R-Writers-Block said:
    I imagine it was aimed at MZ
    1705347784914.png
    H-and-R-Writers-Block said:
    I was just trying to see if there was a means within the RPG Maker VX itself to make it to where no matter how weak an enemy is, they always do 1 damage at the least.
    From the first post, "Math.max(numbers) - returns a maximum number from provided numbers."

    Googling the Ruby version of that:
    Code:
    [your formula, 1].max
  6. Where would I put the Math.round(number) in this formula so it stops showing decimals?

    a.gainHp(- a.hp / 4); a.hp / 5

    The skill sacrifices the user's HP to restore a smaller amount to the target.
  7. around any bit of math that can produce a decimal, but isnt a part of the final damage/heal as that is already rounded
    a.gainHp(-Math.round(a.hp / 4)); a.hp / 5
  8. Robro33 said:
    around any bit of math that can produce a decimal, but isnt a part of the final damage/heal as that is already rounded
    a.gainHp(-Math.round(a.hp / 4)); a.hp / 5
    I think you need to encase everything within math.round unless you using Visustella
  9. Dark_Ansem said:
    I think you need to encase everything within math.round unless you using Visustella
    Thank you, it seems to work fine as is, though :D (I'm not yet using visustella)
  10. Dark_Ansem said:
    I think you need to encase everything within math.round unless you using Visustella
    by default, the last step the engine takes before completing damage a calc is to round the result. its why you can feed a decimal directly into the formula box, and if its a part of the final damage calc, it doesnt give a decimal ingame, but if you put any code before it that to do anything else, you have to round it manually

    Default Damage Steps
    Code:
    Game_Action.prototype.makeDamageValue = function(target, critical) {
        var item = this.item();
        var baseValue = this.evalDamageFormula(target);
        var value = baseValue * this.calcElementRate(target);
        if (this.isPhysical()) {
            value *= target.pdr;
        }
        if (this.isMagical()) {
            value *= target.mdr;
        }
        if (baseValue < 0) {
            value *= target.rec;
        }
        if (critical) {
            value = this.applyCritical(value);
        }
        value = this.applyVariance(value, item.damage.variance);
        value = this.applyGuard(value, target);
        value = Math.round(value);
        return value;
    };
  11. My other question is how could I take this

    a.gainHp(-Math.round(a.hp)); a.hp

    and make it damage the enemy?

    It's a self-sacrifice skill but the current formula accounts for damage after the user loses their HP, resulting in '0' damage to the enemy.

    Sorry, trying to do as much as I can skill-wise w/o using plugins.
  12. Zakarijazh said:
    My other question is how could I take this

    a.gainHp(-Math.round(a.hp)); a.hp

    and make it damage the enemy?

    It's a self-sacrifice skill but the current formula accounts for damage after the user loses their HP, resulting in '0' damage to the enemy.

    Sorry, trying to do as much as I can skill-wise w/o using plugins.
    Try storing a.hp into a temporary variable
    var dmg = a.hp; a.gainHp(-Math.round(a.hp)); dmg
  13. Zakarijazh said:
    Gensun said:
    Try storing a.hp into a temporary variable
    var dmg = a.hp; a.gainHp(-Math.round(a.hp)); dmg
    Yes! perfect! Thanks so much! :D

    Gensun said:
    Try storing a.hp into a temporary variable
    var dmg = a.hp; a.gainHp(-Math.round(a.hp)); dmg
    When I use this in battle, the user is not able to be revived using items or skills, despite it showing the normal Death state after user?

    I also created an MP-sacrifice skill that seems to work fine?
  14. Zakarijazh said:
    When I use this in battle, the user is not able to be revived using items or skills, despite it showing the normal Death state after user?

    I also created an MP-sacrifice skill that seems to work fine?
    I tested it on my blank project. I cannot replicate this bug.
  15. Gensun said:
    I tested it on my blank project. I cannot replicate this bug.
    I just figured it out. I had the healing skills/items set to 'ally' and not 'Ally (dead)'
  16. Is there a way to make an attack use Damage HP when against a certain actor but use Damage MP against another one?
  17. JorgeBonito said:
    Is there a way to make an attack use Damage HP when against a certain actor but use Damage MP against another one?
    The problem with that is the damage type is determined by what you select in the database.

    So you could set it to HP Damage and use script calls in the formula to take MP instead, but there are two issues:
    1 - You'd see a 0 damage popup for the HP
    2 - You should not put script calls that change anything into the damage formula, because they'll be executed when the game evaluates that skill during enemy turns or Auto Battling.

    I think you'd be better off giving it no damage type in the database, then using Yanfly's Action Sequence to program out the skill and figure out how to code damage execution inside of that.

    And yes, that is as complicated as it sounds.

    You could also try putting a Yanfly Auto Passive State on the target that uses Buffs and States Core notetags to convert the HP damage into MP damage and try to deactivate the HP popup.
  18. ATT_Turan said:
    The problem with that is the damage type is determined by what you select in the database.

    So you could set it to HP Damage and use script calls in the formula to take MP instead, but there are two issues:
    1 - You'd see a 0 damage popup for the HP
    2 - You should not put script calls that change anything into the damage formula, because they'll be executed when the game evaluates that skill during enemy turns or Auto Battling.

    I think you'd be better off giving it no damage type in the database, then using Yanfly's Action Sequence to program out the skill and figure out how to code damage execution inside of that.

    And yes, that is as complicated as it sounds.

    You could also try putting a Yanfly Auto Passive State on the target that uses Buffs and States Core notetags to convert the HP damage into MP damage and try to deactivate the HP popup.
    Since the character I want to use this on is a character that has 0 HP but receives damage on MP, the Buffs and States Core made the trick. Just added a Invisible Status with a Respond Effect that gains the negative value of the damage.
  19. Is V[10] the variable for the damage calculated?
  20. Jaykov said:
    Is V[10] the variable for the damage calculated?
    Sorry, what are you talking about?

    There is no V in the damage formula, only v. And v[10] is game variable ID 10.