Damage Formula Question

Discussion in 'RPG Maker MV' started by Jenova, Jun 20, 2019.

  1. Jenova

    Jenova Because you are...a puppet! Veteran

    Messages:
    174
    Likes Received:
    112
    Location:
    Hawaii
    First Language:
    English
    Primarily Uses:
    RMMV
    Ok, so I have an issue where I want my character to heal themselves by a percentage of the damage caused if the enemy is under a certain state.

    Example: If the enemy is under the state Bleed [#0043], then do regular damage and heal your life by 50% of the damage caused, otherwise do regular damage.

    I looked at the Damage Formula Thread, but I don't know how to put it together to get my intended outcome.

    Thanks!

    EDIT:

    Wait, does YEP_LifeSteal do that? If it does, I don't need help then, because while playing my game, I have the notetag on one of my characters and he is set to do 10% lifesteal.

    Did 1700 damage
    Healed 170 HP

    Is this right?


    Nevermind, going back on what I was asking for since I am looking for the state causing the effects and not just the effects itself.
     
    Last edited: Jun 20, 2019
    #1
  2. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,768
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    always do regular damage, and send the battlers to a post-damage common event.

    in the common event, check for state, and THEN, do the calculations.
    in order to grab the battlers in question you need to grab the scene, so:
    Code:
    scene = SceneManager._scene
    battler = scene._subject
    target = $gameTroop.members[battler._lastTargetIndex]
    
    there is no way to calculate "heal by a percentage of the damage dealt", without first dealing the damage.
     
    #2
  3. Jenova

    Jenova Because you are...a puppet! Veteran

    Messages:
    174
    Likes Received:
    112
    Location:
    Hawaii
    First Language:
    English
    Primarily Uses:
    RMMV

    Probably should have revisited my old threads first but...

    Take damage from skill

    This seems to be what I am looking for, but the opposite.

    And I only want it to heal IF the enemy is under that status effect "Bleed"
     
    #3
  4. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,768
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    well, that's one way, but if you do that you're regenerating BEFORE applying the damage, so if there's another code dealing with any of those aspects it'll likely fail to run correctly.

    the damage formula should only be used to deliver the damage (and, if you want to use it correctly 100%, only be used to deliver the attack value, not the damage dealt, and not involve the defense of the target.... the damage calculation should be handled by the battle system)

    for that particular case, your code should look like this:

    Code:
    var dmg = (formula), regen = Math.round(dmg * percentage); if (b.isStateAffected(ID)) {a.gainHp(regen)}; dmg
    
     
    #4
    Jenova likes this.
  5. Jenova

    Jenova Because you are...a puppet! Veteran

    Messages:
    174
    Likes Received:
    112
    Location:
    Hawaii
    First Language:
    English
    Primarily Uses:
    RMMV
    So something like this:
    Code:
    var dmg = (a.atk * 4), regen = Math.round(dmg * 0.50); if (b.isStateAffected(43)) {a.gainHp(regen)}; dmg
    Whereas a.atk * 4 is the formula, 50% of the damage is converted to HP Regen if the enemy is under State 43 (Bleed)?
     
    #5
  6. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,768
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    yes, but you have to include the target's defense in the formula.
     
    #6
  7. Jenova

    Jenova Because you are...a puppet! Veteran

    Messages:
    174
    Likes Received:
    112
    Location:
    Hawaii
    First Language:
    English
    Primarily Uses:
    RMMV
    Well, my intention was to have skills take hp away. To compensate, I made attacks ignore defense. Unless, that's not how it works.
     
    #7
  8. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,768
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    there is no *how it works* when it comes to damage formulas, which is one of the things I dislike about the whole system.
     
    #8
  9. Jenova

    Jenova Because you are...a puppet! Veteran

    Messages:
    174
    Likes Received:
    112
    Location:
    Hawaii
    First Language:
    English
    Primarily Uses:
    RMMV
    Yikes. So is ignoring defense not explicitly defined or what I did was one way to do it out of thousands of others?

    Because I'm mildly confused at this point.
     
    #9
  10. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,768
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    if you don't add in the defense *because you don't need it*, that's fine.
    I mean, that with the default damage formula you always have to add in the target's defense and make each skill calculate the damage on it's own, as opposed to having the battle system do it (which should be the correct way, IMO)
     
    #10

Share This Page