RMMV Damage Formula - ideas and help

Discussion in 'RPG Maker MV' started by Shaz, Oct 25, 2015.

  1. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    And if you change b with target
    Code:
    <After Eval>
    if(target.result().isHit() ){target.addState(state);}
    </After Eval>
    Seems I had it working in the after eval brackets this worked on my end
     
  2. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Sorry, to clarify:

    Do the Eval Brackets go in the Formula line or the Notes of the Skill?
     
  3. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    The notes.
     
  4. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    And is my formula meant to look like this now after changing the b to target? Or am I misunderstanding something, because it doesn't seem to be working?

    (Thank you for your help so far, by the way)
     
  5. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Yes but the damage formula should be in the formula box or in between the <damage formula></damage formula> tags above the <after eval> tag In this case.
     
  6. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, so with the eval in the notebox, and the formula in the formula box, it doesn't seem to change much, as it just does damage with no added state.

    Having the formula in both the formula brackets and the notebox as well as the eval in notes causes it to come up as 0, which I assume means it's cancelling itself out.

    Having just the formula in the brackets and the eval brackets, both in the notes results in nothing, not even damage popup. :/
     
  7. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    After eval means after the damage evaluation thus it has no meaning putting a damage formula there and might lead to problems.
    Created a skill based of of my example and this works on my end.
    Code:
    <damage formula>
    value=10;
    </damage formula>
    <After Eval>
    var state = 16 ;
    var basechance = 100;
    var roll = Math.randomInt(100) + 1;
    var chance = basechance * target.stateRate(state) ;
    if(target.isStateAffected(15) && target.result().isHit() ){target.addState(state);
    }
    </After Eval>
    
    
    value is the variable used to store the damage formula so by saying value 10 the skill does 10 damage.
    Btw I just scraped some of an existing skill in my project put it down as standalone skill and tested it after changing some stuff this should work just as fine

    Code:
    <damage formula>
    value=10;
    </damage formula>
    <After Eval>
    if(target.isStateAffected(15) && target.result().isHit() ){target.addState(16);
    }
    </After Eval>
    
    
     
    Last edited: Apr 27, 2019
    Catog likes this.
  8. Catog

    Catog Professional Internal Screamer Veteran

    Messages:
    50
    Likes Received:
    12
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    THERE WE GO!!

    So the one that you just put through, I changed the target.addState(16) to a target.setHp(0), and that worked exactly how I wanted!
    Thank you so much!
     
  9. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Well what works that works, but you couldn't give them the state death?
    You're welcome.
     
  10. deus69xxx

    deus69xxx Warper Member

    Messages:
    3
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    So... this seems to be a thread discussing some of what I need a little help with. Hopefully popping this in here will net an answer, and isn't the wrong thing to do. (In fact, this may be an answer in itself for some people, since it's the kind of scaling some want, keeping all skills relevant for the whole game).

    I have a working damage formula for physical attacks and magic/skills/whatever. Physical attacks are the base formula, using base atk, base mat, weapon atk, and weapon mat, and everything else works off that base with an added modifier. Now, everything works for the main character, who is rather complicated in his skills, since all his stuff works off his bonuses from weapons to atk and mat, will work fine for the physical fighter since his will just be atk (after moding the formula a little on his skills). My mages, however (rather, mage and priest), will be a different story. Their magic will work just fine like that, except for one thing I will get to in a moment.

    The Formula that works fine:
    (Edit: bloody hell, i was wondering why the numbers were flaring recently on this particular attack. change reflected (e+d)*(e+d) should be (e+d)*2. error apparently from not saving once in game Dx)
    c=(a.atk-a.paramBase(2))+(a.mat-a.paramBase(4));d=a.paramBase(2)/2;e=a.paramBase(4)/2;(((((c+(a.level*a.level*(c+((e+d)*2))))/256)*3/4)*(255-(b.def/2)+(b.mdf/2)))/256)+1

    This is the main character's basic attack. It uses his weapon's atk and mat as c, and adds half his base atk and mat to make a basic attack power. Exponential level multiplied by these params, and multiplication of the damage by a fraction of half mdf and def to come out with nice numbers throughout the leveling system. Magic adds an extra set of parenthesis and a modifier, such as 2, 3, 5, 8, .3, etc, to make them something special depending on a cumulative buff, etc. Now, for the problem.

    The formula that needs help:
    c=???;(#((((c+(a.level*a.level*(c+(a.mat*2)))/256)*3/4)*(255-b.mdf))/256))+1

    This is going to be 'spell' damage from mage or priest. Essentially works the same way, except those two things which don't fit. # is easy, it would be a modifier, like earlier, based on the spell. What I need is a number (rather, an equation) for ??? that would scale like weapons do. A kind of starting lower curve, into a higher curve later, to match the weapon curve. Weapons will generally be something like 12-15 atk at the start of game, all the way to the biggest meanest weapons at ~250, and I guess an average would be something in the 140's around level 30 (mid game). I've tried various things such as c=: level*2, level+(level/2), level*(level*1.1). I can't seem to find a way to make a nice slow(ish) curve like what the stat generator can create in the options. These only make it steadily increase to make it unbalancedly weak or strong in the early game, and the opposite in end game. The only other option I have it to essentially use it like a physical attack and use weapon mat, or re-think it entirely, since I'm NOT (likely) re-teaching skills at higher levels, though that could be an answer. But I don't wanna. :barf:

    Does anyone happen to know a good formula to mathematically make a curve like that off level? This could be slightly modified to make # part of the base, and I could always add another step or two.
     
    Last edited: May 31, 2019
    jetboost likes this.
  11. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Then i'll try to assist.

    It seems to first be a question on what you will use to create the formula?

    I can give you a couple ideas:
    For magic I myself track 2 extra things affinity and attunement.
    Affinity - one's inborn talent.
    Attunement - The ellement one choses to attune him/herself to(something which increases gradually through the game).
    (On a sidenote the novel "Warlock of the Mages World" inspired me to do it like this. If you like reading xianxia and DnD kinda stories i'd recommend reading it. Wuxiaworld is where I have read it.)

    Secondly there is still elemental rate build-in.

    And there is also skill lvl.

    So what do you use? What will you use?
    Are there more things that have to be taken into consideration with the formula?

    And that's quite an impresive formula, only I can't imagine how you came up with it.
    Will have to recreate it in an excell sheet to understand it better.
     
  12. deus69xxx

    deus69xxx Warper Member

    Messages:
    3
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    welp, through a little experimentation (thank you for the spreadsheet idea, much easier than notepad++ and a calculator) I have cobbled together an equation that reasonably approximates weapon scaling at levels. (level+level)*7/3+15. that's my c for magic :D

    Now I'll just have to play around with some # values, see if I even need them.
     
  13. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMMV
    Hello everybody!

    I have a simple question, I think.

    My base damage formula currently is:

    damage * (1+(a.atk-b.def)/200)

    The idea behind this is that the attackers atk will be substracted by the defenders def by a 1 to 1 ratio and the result is then added or substracted as a % value to the base damage.

    Example:

    Attackers ATK is 62, the Skill does 100 base damage and Defenders DEF is 47. That would yield to a 7.5% bonus damage, so 107,5 damage dealt.

    Example 2:

    Attackers ATK is 118 and Defenders DEF is 189. That would be -35,5% damage, so 64,5 damage dealt.


    I kinda like this idea a lot more than just the default Attack_Value_Is_Always_Higher_Than_Def_Lol*4 - Poor_Def*2 .

    But the problem is, that if the defense is more than 200 more than the attackers ATK, it will result in a negative damage value. So basicly healing. And on the other side on some point, if the attack value is much higher than the defense value, the attacks will get devastating. I need a cap for this on both ends.

    How do I implement, let's say, a 75% maximum damage bonus or a -75% maximum damage reduction into the calculation?

    Thank you very much in advance for any answers! :LZSsmile:


    Edit:
    Never mind. I found the solution. What I was looking for is the .clamp() method.

    damage * (1+(a.atk-b.def)/200).clamp(0.25, 1.75)
     
    Last edited: Jun 13, 2019
  14. Kryss

    Kryss Villager Member

    Messages:
    16
    Likes Received:
    1
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    Hi, I am new to rpgmaker and was using wrong formulas all the time because I didn' t notice old ones don't work in MV. Can you help me with one?

    I want a weapon (stun bombs) to have a 25% of apllying stun to enemies when hit? which I can do in the weapon page, but also want that if the enemy is confused or blinded the stun is always applied. I thought I needed to do this in the attack formula, but I don't know how to check for 2 things (actor is using stun bombs AND objective is confused or blinded), can someone help me?

    Thanks!
     
  15. jetboost

    jetboost Veteran Veteran

    Messages:
    84
    Likes Received:
    26
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    Good to hear.
    I myself haven’t seen the clamp() method before as i used if statements to make sure of a minimum and a maximum amount of an value.

    But does clamp() work the way you use it now?
    It doesn’t need to be like this:
    Modifier = 1+(a.atk-b.def)/200;
    Modifier.clamp(0.25, 1.75);
    Damage* modifier;
     
  16. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMMV
    I didn't test it extensively yet. Just changed the standard formula to this one and started some test battles. It immediately gave a lot more natural numbers than the default formula. Now that I think about it I could simply test this. I will set the defense of one of the battlers to 999 and check if the damage will become at least 25% of the base damage.

    And... it worked! The damage will at least be 25% of the base value, no matter how low the a.atk or high the b.def is.

    So (formula).clamp(min, max) can be used without the need to use a variable for formula. That's very handy because it is an ultra short one-liner that way.



    @Kryss
    I think you need to insert this behind your regular damage formula:

    ; if (b.isStateAffected(confused_ID) || b.isStateAffected(blinded_ID)) {b.addState(stun_ID);}

    You have to replace confused_ID, blinded_ID and stun_ID with the ID numbers in your states database.

    Let me know if that worked. :LZSsmile:

    Edit: Woops, forgot that if.
     
    Last edited: Jun 13, 2019
    jetboost likes this.
  17. Silva

    Silva Scoobityboo Veteran

    Messages:
    292
    Likes Received:
    142
    First Language:
    English
    Primarily Uses:
    RMMV
    I think you've forgotten to close your first opening bracket as well. ie (blinded_ID))

    Expanding on what @XZINED has written so as to include both elements of what you're looking to do. Your options here are to continue adding conditions to the if statement using || to function as the word 'or' like so:

    Code:
    if (b.isStateAffected(confusedId) || b.isStateAffected(blindId) || Math.randomInt(100) < 25) {b.addState(stunId)}; damageFormula
    Your other option is to add an 'else if' section onto the formula, this might make the formula easier to understand if you look at it again in the future but is lengthier - in this instance its personal preference which method you use. If you wanted to have a different result based on a different condition if the first one wasn't true this would be the way forward. Using if else the formula would look like this:

    Code:
    if (b.isStateAffected(confusedId) || b.isStateAffected(blindId)) {b.addState(stunId} else if (Math.randomInt(100) < 25) {b.addState(stunId)}; damageFormula;
    You don't need to check that the actor is using the stun bombs, so long as you put the formula into the item/skills damage formula the effects will execute only when an actor uses the item/skill.
     
    Nilom likes this.
  18. Nilom

    Nilom Veteran Veteran

    Messages:
    178
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMMV
    Oh yeah, I've corrected that. :LZScheeze:

    I didn't include the regular % chances of states to occur because I assumed that Kryss would have them on the skills anyway, the classic way.

    But that's also a great way to do it!

    I personally find the first method to be better readable. You have all conditions and ors next to each other and not "nested". But as you said, everyone has his own preference. :LZSsmile:

    One more thing to consider:
    I think it should be dependent on the skill if the regular damage formula will happen before or after. When thinking about an attack which will cause a state to happen after the attack took place I would put the formula before the state checks. Otherwise the targets would be stunned before they receive damage. I don't know if this would make any difference or if the effects take place at the same time anyway.

    For example if you have a skill "Crippling Strike" that makes the target more vulnerable to physical attacks, after being hit. Would the attack itself already do more damage if the state is applied before, or not?
     
    Last edited: Jun 13, 2019
    Silva likes this.
  19. Kryss

    Kryss Villager Member

    Messages:
    16
    Likes Received:
    1
    First Language:
    Spanish
    Primarily Uses:
    RMMV

    Maybe I am not understanding it, but the stun bombs are a weapon, and in the weapon page there is no damage formula, am I missing something? Where should I put the formula?
     
  20. Silva

    Silva Scoobityboo Veteran

    Messages:
    292
    Likes Received:
    142
    First Language:
    English
    Primarily Uses:
    RMMV
    Ah, that's a total goof on my part. If you want to use the damage formula to add this effect from the weapons you will need to check the actor has it equipped. The best check to use for this would be

    Code:
    a.hasWeapon($dataWeapons[id])
    
    //where id = weapons database id
    Now to get that into damage formulas with the above would look something like this:

    Code:
    if (a.hasWeapon($dataWeapons[weaponId]) && (b.isStateAffected(confusedId) || b.isStateAffected(blindId) || Math.randomInt(100) < 25)) {b.addState(stunId)}; damageFormula
    
    It's messy, but it should work in your skills damage formula.
     

Share This Page