RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 60 of 77 View original ↗
  1. I would note that Math.randomInt(x) will return a number between 0 and (x-1), so to achieve damage of between 10-20 using this you would have to use Math.randomInt(11) + 10.
  2. Silva said:
    I would note that Math.randomInt(x) will return a number between 0 and (x-1), so to achieve damage of between 10-20 using this you would have to use Math.randomInt(11) + 10.
    Thanks for the correction, I knew I was missing something...
  3. Looking to make a capture skill (like a poke-ball). I've already got the formula
    $gameParty.gainItem($dataItems[b.enemyId()], 1)
    which will give the party a corresponding item whenever they get a successful capture.

    But what I need is an addition to the formula which is going to a) make success dependent on the target having low HP, and b) will then remove the target (for, by example, applying the knockout state)

    Also, is it possible for a skill to only hit if the target has a certain state applied to it?
  4. yoluko said:
    Looking to make a capture skill (like a poke-ball). I've already got the formula
    $gameParty.gainItem($dataItems[b.enemyId()], 1)
    which will give the party a corresponding item whenever they get a successful capture.

    But what I need is an addition to the formula which is going to a) make success dependent on the target having low HP, and b) will then remove the target (for, by example, applying the knockout state)

    Also, is it possible for a skill to only hit if the target has a certain state applied to it?

    For a) and b) try:
    Code:
    if (b.hp < (b.mhp / 10)) { $gameParty.gainItem($dataItems[b.enemyId()], 1); b.addState(1) } else { $gameParty.gainItem($dataItems[pokeball item ID here]), -1) } // removes 1 pokeball from the party inventory


    For the last part try:

    Code:
    if (b.isStateAffected(stateId) { damage formula here } else { 0 } // State ID is a number
  5. So I'm trying to add a chance to add a state to the target if the actor has a state. I've got:

    a.isStateAffected(100) ? b.addState(25); regular damage here

    And

    if (Math.randomInt(100) < 50) b.addState(25); regular damage here

    However, I'm not sure how to combine them. Would it just be:

    If (Math.randomInt(100) < 50) && a.isStateAffected(100) b.addState(25); regular damage here
  6. The format for using if statements are like so:

    JavaScript:
    if (condition) code;

    So you need all of your conditions to be within the first set of brackets after the word if. Eg

    JavaScript:
    if (Math.randomInt(100) < 50 && a.isStateAffected(100)) b.addState(25); //remaining damage formula
  7. Thanks! I appreciate it!
  8. Really new to this but trying to make a damage formula that basically says;

    a.atk *1.4 - b.def
    If enemy has state (89)
    35% chance to apply state (90)
    else
    35% chance to apply state (4)


    I'm using this but it ALWAYS applies the rates 100% of the time after taking account of state A being present or not

    <Damage Formula>

    value = Math.max((a.atk * 1.4 - b.def), 1);

    if (b.isStateAffected(89)) {

    var chance = 0.35; (b.addState(90));

    } else {

    var chance = 0.35; (b.addState(4));

    }

    </Damage Formula>

    I found a little help to get this far elsewhere but they couldn't quite grasp what I was wanting to accomplish...

    Any help would be greatly appreciated!
  9. Zakarijah said:
    var chance = 0.35; (b.addState(90));
    Zakarijah said:
    var chance = 0.35; (b.addState(4));

    These are the problems. They're basically saying "assign 0.35 to the variable chance, then add state 90 (or 4) to b. There's no random calculation going on there. Try this instead:

    Code:
    <Damage Formula>
    value = Math.max((a.atk * 1.4 - b.def), 1);
    if (Math.random() < 0.35)
    {
      if (b.isStateAffected(89)) b.addState(90);
      else b.addState(4);
    }
    </Damage Formula>
  10. Aesica said:
    These are the problems. They're basically saying "assign 0.35 to the variable chance, then add state 90 (or 4) to b. There's no random calculation going on there. Try this instead:

    Code:
    <Damage Formula>
    value = Math.max((a.atk * 1.4 - b.def), 1);
    if (Math.random() < 0.35)
    {
      if (b.isStateAffected(89)) b.addState(90);
      else b.addState(4);
    }
    </Damage Formula>
    It worked, thank you! <3
  11. Is it possible to use Attack and M.Attack as a sort of percentage, where 100 in Attack is 100%?
  12. Something like a.atk/100 will be sufficient. What do you want to do more precisely ?
  13. yeah, damage formula, to get a percentage is just the current value divided by the max, then you multiply for what you want the percentage of. to get the percentage of hp you go hp/mhp for example.
  14. Hello all, this is my first post on this site.
    I am trying to recreate the damage formula from Final Fantasy 4 on the SNES.
    I will explain for it is really complex.
    And, english is not my first language, so pardon me if its unclear...

    Each characters/monsters has the following stats that are needed for the formula:
    Attack Multiplier (atm): Number of hits for each attack
    Attack (atk): The damage done by each hits (Attack to Attack * 1.5) ex. (10-15, 20-30, 100-150)
    Hit% (hit)
    Defense Multiplier (dfm):
    Number of hits that can be blocked with target's evade%
    Defense (def): The number of points substracted from attacks.
    Evade% (eva)

    Damage for an attack: Attack Multiplier x ((Attack ... Attack x 1.5) - target defense)

    I know the formula for damage(the part above in italic) : ((a.atk + Math.randomInt(1 + a.atk / 2)) - b.def)
    But I don't know how to make that this damage will be multiplied by each
    hits that will hit the target.

    Here's an exemple:
    Character's Attack : 10x100
    This means the character has an atk multiplier of 10 and attack damage of 100.
    So when he attacks, he may do up to 10 hits. The damage will be 100-150 minus the target's defense multiplied by the number of successful hits.
    What's more, each of these 10 hits may miss, so the character may finally only attack with 6 hits. (4 attacks would have missed)
    So if the target has 20 defense, the damage : 100-150 damage minus 20 (80-130 damage),
    then that number will be multiplied by the number of effective hits.

    This is how each hits have a chance to hit:
    First it calculates it it hits with attacker's Hit% (a.hit)
    Then, the target's Defense multiplier(dfm) determines the number
    of hits that it can block. So if the target has 2 def. multiplier it can only block
    2 of the 10 hits with the target's evade% (b.eva)

    Then only the final damage will be shown as a popup.
    Or, if each of the 10 attacks misses, then "Miss!" will appear as a popup.

    I hope it is understandable. I know it is really complicated
    but if someone could help with this, it would be really appreciated!
  15. Ill just share it here, maybe someone would like to use it.
    This is basically Fallout 4 damage formula, the essence is:
    low armor value defend you always, but the less damage dealt, the more effect of it
    and higher armor values more effective against very high damage values, without negating lower damage nubmers completely

    Math.min((Math.pow((a.atk*0.15/b.def), 0.365), 0.99)))*a.atk
  16. Since this has to do with damage i suppose this may be the place to post this.
    So i'm trying to make a state Icespikes,it gives 1 ally in your team 10 icespikes that deal dmg to the enemy when the actor with the state takes dmg and also takes away 1 icespike,the icespikes variable is also used for counting the state's turns but they go down even if the actor doesn't take dmg.
    I messed so much with this that it doesn't even deal dmg back anymore...sigh..
    State formula
    <Custom Apply Effect>

    var icespikes = 10;

    user.setStateTurns(24, icespikes);

    </Custom Apply Effect>



    <Custom Respond Effect>

    if (icespikes > 0) {

    var min = Math.round(a.atk * 1.2);

    var max = Math.round(a.atk * 1.8);

    var value = Math.floor(Math.random()*(max-min+1))+min;

    user.gainHp(-value);

    icespikes -= 1;

    } else if (icespikes === 0) {

    target.removeState(24);

    }

    </Custom Respond Effect>
  17. @xarxesxarxes you can't do this with just damage formula, you'll need a plugin to affect more the whole damage giving proccess for this.
    yanfly's damage core may be able to do it, I think it allows you to set every part of the damage calculation by hand, but not sure.

    on default, both the hit or miss and the damage value is calculated through the action's effect. then after the effect is done the battle log adds the popup. for every one
    you want to separate the strikes' hit calculation, but put the damage as only one popup. while also showing the misses separately.

    you'll kinda need to code it all for the skill to do that. get the supposed number of strikes, and make a loop in the damage calculation. in the loop, calculate the miss and evade, if it hits you call to make the damage value and add the value to a variable, if it misses you make it show the miss popup.
    problem here is... since it will all be one big calculation, how will you show all the needed animations, or the misses exactly when you need to?

    @Johnny_Ray just a suggestion, since the spikes go down even if the battler doesn't take damage why not make it use the turns counter and just take away one turn when it is hit? your apply effect sets iceSpikes to 10 and the turns to icespikes, and later when icespikes are 0 the state is removed, you just need to set turns to 10. "b._stateTurns[24]--;" should do it
    Also, it seems to me the attacker does take damage, but is just not showing in the screen, just losing the hp behind the scenes. add a line of "a.startDamagePopup();" and it should appear again.
  18. @YoraeRasante Thank you for replying to my request.

    I looked at Yanfly's damage core and I don't think I could make something out of it.
    I'd rather do a slightly different damage formula instead...
    I'd make a hit% formula myself, but for the damage I still need some help.
    As for attack animation, I would do the same as Final Fantasy 1, the actor would do
    always do 2 weapon strikes(disregard this for the formula), whether it misses or not.

    So the damage formula would be:
    ( A ) * Math.round(Math.max( B ),1))

    A : ((a.atk + Math.randomInt(1 + a.atk / 2)) - b.def)
    -------------------------------------------------------------------------------
    B : This is where I'd need some help. Again, this part is quite complicated...
    The minimum value would be 1 and a rounded number.
    atm: Attack multiplier (number of hits of attacker)
    dfm: Defense multiplier (number of hits that can be blocked by the target)

    Basically it would be : (a.atm calculation - b.dfm calculation)
    Exemple:
    Attacker has 10 atm and 80% hit.
    Target has 2 dfm and 20% evade.

    a.atm calculation
    First it calculates how many atm(attacker) on the 10 would hit based on the hit% stat(80).
    Like each of the 10 atm has a 80% to be used for the calculation.

    b.dfm calculation
    Then it calculates how many dfm(target) on the 2 would be subtracted, based on
    the target's eva stat (20). So each of the 2 dfm has a 20% to be subtracted from
    the a.atm calculation.

    So the a.atm calculation for this exemple would give 0 to 10
    and the b.dfm calculation would give 0 to 2. By subtracting the b.dfm calc.
    from the a.atm calc. we get the B Part of the damage formula.
    And contrary to my previous post, it won't involve missing as the minimum possible
    value of the B Part will by 1.

    It is quite complex, so if this formula is possible,
    I guess it would only fit in a <Damage Formula> section in the note box of the skill...

    Thank you for taking the time
  19. Johnny_Ray said:
    Since this has to do with damage i suppose this may be the place to post this.
    So i'm trying to make a state Icespikes,it gives 1 ally in your team 10 icespikes that deal dmg to the enemy when the actor with the state takes dmg and also takes away 1 icespike,the icespikes variable is also used for counting the state's turns but they go down even if the actor doesn't take dmg.
    I messed so much with this that it doesn't even deal dmg back anymore...sigh..
    State formula
    <Custom Apply Effect>

    var icespikes = 10;

    user.setStateTurns(24, icespikes);

    </Custom Apply Effect>



    <Custom Respond Effect>

    if (icespikes > 0) {

    var min = Math.round(a.atk * 1.2);

    var max = Math.round(a.atk * 1.8);

    var value = Math.floor(Math.random()*(max-min+1))+min;

    user.gainHp(-value);

    icespikes -= 1;

    } else if (icespikes === 0) {

    target.removeState(24);

    }

    </Custom Respond Effect>

    Hi Johnny, let me help you with that real quick, I believe you're looking for something like this c:

    Code:
    <Custom Apply Effect>
    target.setStateCounter(stateId, iceSpikes);
    </Custom Apply Effect>
    
    <Custom React Effect>
    if (value > 0 && this.isPhysical()) {
      var min = Math.round(a.atk * 1.2);
      var max = Math.round(a.atk * 1.8);
      var value = Math.floor(Math.random()*(max-min+1))+min;
      user.gainHp(-value);
      if (user.isDead()) {
        user.performCollapse();
      }
      target.addStateCounter(stateId, -1);
      if(target.getStateCounter(stateId) <= 0){
        target.removeState(stateId);
      }
    }
    </Custom React Effect>

    You just need to change stateId(4 of them) with the ID of your ice spikes state and iceSpikes with the number of uses you desire.

    And that's it, happy game making!
  20. For the custom react, you could also just add this at the start:

    var stateId = value;

    and modify value to your IceSpike ID.
    So you will only need to put the value once, minimizing chances of mismatch.