Damage Formulas 101

● ARCHIVED · READ-ONLY
Started by Skunk 281 posts Page 11 of 15 View original ↗
  1. Thanks again for the detailed explanation. My only knowledge about functions comes from this thread, I've also checked out another thread about damage formulas but that one was for VX and the syntax was different so I couldn't make the examples there work in MV.

    I think I might be confusing parenthesis with these things { }

    I probably should check out some basic javascript tutorials, but that's going to have to be way down the line. I'm pretty terrible at anything coding related and the only reason I'm here trying to learn as much as I can is because I stumbled upon this thread and saw that a lot of the things that I wanted to do and assumed would require plugins was in fact possible with a few lines of code. So, I really appreciate the help!
  2. Nox_Aeternae said:
    I think I might be confusing parenthesis with these things { }
    Braces also are not necessary in either of your examples above - they're used after if statements or loops (which apply to the next single code statement) to make it apply to an entire block. They're also used to enclose the contents of a function.

    When you're just doing a series of code statements (set this switch, call this function) there's no need for any additional symbols.

    Nox_Aeternae said:
    I probably should check out some basic javascript tutorials, but that's going to have to be way down the line. I'm pretty terrible at anything coding related
    Well, it would benefit you. For example, just looking at your posts yesterday (the older posts don't have a timestamp), you waited 4 hours between posting your problem and getting the answer. It would certainly have taken you fewer than 4 hours of tutorials to have learned everything you needed to fix that formula (and then some) :wink:
  3. I'm struggling to try and get something like this to work; wearing specific armor adds status effect. Any suggestions?

    if a.hasArmor($dataArmor[10]) b.addState(4); 200 + a.mat * 2 - b.mdf * 2
  4. twosnakes said:
    I'm struggling to try and get something like this to work; wearing specific armor adds status effect. Any suggestions?

    if a.hasArmor($dataArmor[10]) b.addState(4); 200 + a.mat * 2 - b.mdf * 2
    It's $dataArmors, with an "S".
  5. Hi, thanks for the detailed information on the formula!
    I'm a noob with javascript, can somebody tell me when checking whether a state is afflicted or not, why do you type 10000:1 at the end? What does it do?
    Hope somebody would explain that to me.
  6. Zerun said:
    Hi, thanks for the detailed information on the formula!
    I'm a noob with javascript, can somebody tell me when checking whether a state is afflicted or not, why do you type 10000:1 at the end? What does it do?
    Hope somebody would explain that to me.
    I'm not sure what you're talking about, because checking whether a state is present in no way requires "10000:1" on the end. Where have you seen this?
  7. Trihan said:
    I'm not sure what you're talking about, because checking whether a state is present in no way requires "10000:1" on the end. Where have you seen this?
    isStateAffected(stateId) - checks if battler has state inflicted to them.
    E.g. b.isStateAffected(10) ? 10000 : 1;
    This is from the Main thread, under the state section.

    What about advanced stuff where you can influence formulas with states?

    We got all that!
    isStateAffected(stateId) - checks if battler has state inflicted to them.
    E.g. b.isStateAffected(10) ? 10000 : 1;

    isDeathStateAffected() - checks if battler has death state inflicted to them.
    E.g. b.isDeathStateAffected() ? 10000 : 1;

    resetStateCounts(stateId) - refreshes how long state will last for the battler
    if (b.isStateAffected(10)) b.resetStateCounts(10); 100

    updateStateTurns() - shortens all states on battler by 1 turn
    b.updateStateTurns(); 100

    addState(stateId) - adds state to the battler
    if (!b.isStateAffected(10)) b.addState(10); 100

    isStateAddable(stateId) - checks if state can be added to the battler
    c=100; if (b.isStateAddable(10)) b.addState(10); else c=4000; c

    removeState(stateId) - removes state from the battler
    if (a.isStateAffected(10)) a.removeState(10); 0
  8. Zerun said:
    isStateAffected(stateId) - checks if battler has state inflicted to them.
    E.g. b.isStateAffected(10) ? 10000 : 1;
    This is from the Main thread, under the state section.

    What about advanced stuff where you can influence formulas with states?

    We got all that!
    isStateAffected(stateId) - checks if battler has state inflicted to them.
    E.g. b.isStateAffected(10) ? 10000 : 1;

    isDeathStateAffected() - checks if battler has death state inflicted to them.
    E.g. b.isDeathStateAffected() ? 10000 : 1;

    resetStateCounts(stateId) - refreshes how long state will last for the battler
    if (b.isStateAffected(10)) b.resetStateCounts(10); 100

    updateStateTurns() - shortens all states on battler by 1 turn
    b.updateStateTurns(); 100

    addState(stateId) - adds state to the battler
    if (!b.isStateAffected(10)) b.addState(10); 100

    isStateAddable(stateId) - checks if state can be added to the battler
    c=100; if (b.isStateAddable(10)) b.addState(10); else c=4000; c

    removeState(stateId) - removes state from the battler
    if (a.isStateAffected(10)) a.removeState(10); 0
    Ah, I see where you're getting confused.

    The numbers are nothing to do with checking a state: if you want to check whether the target has a state, it's just b.isStateAffected(stateId). The 10000 is the amount of damage to deal if the state is present, and the 1 is the damage if it isn't. They aren't dependent on each other; the state check can be any valid condition, and the 10000/1 can be any number (or any formula to calculate one).

    This is what's called a ternary if statement, where the syntax is

    condition ? iftrue : iffalse

    In the damage formula box, the last value evaluated will be taken as the amount of damage you want the skill/item to deal.
  9. Trihan said:
    Ah, I see where you're getting confused.

    The numbers are nothing to do with checking a state: if you want to check whether the target has a state, it's just b.isStateAffected(stateId). The 10000 is the amount of damage to deal if the state is present, and the 1 is the damage if it isn't. They aren't dependent on each other; the state check can be any valid condition, and the 10000/1 can be any number (or any formula to calculate one).

    This is what's called a ternary if statement, where the syntax is

    condition ? iftrue : iffalse

    In the damage formula box, the last value evaluated will be taken as the amount of damage you want the skill/item to deal.
    I see now. Thank you for explaining this!
  10. Awesome, thank you so much for this info!
  11. I'm trying to do a very simple in-game battle tutorial and I wanted to use a skill that is seriously reduced when the player guards. Keeping it simple, it would be the skill does 100 damage if opponent not guarding, but only 5 damage if guarding. I tried using this formula
    Code:
    b.isStateAffected(2) ? 5 : 100;
    The player receives 100 damage whether guarding or not. I tried adding another state guardTutorial to the guard skill and then checking that skillID
    Code:
    b.isStateAffected(34) ? 5 : 100;
    Damage is still 100 even though the player is guarding.
    I tried a conditional statement in the troop event.
    Code:
    ◆If:Samster is affected by Guard (Tutorial)
      ◆Control Variables:#0147 tutorialDamage = 5
      ◆Change State:Samster, - Guard (Tutorial)
      ◆
    :Else
      ◆Control Variables:#0147 tutorialDamage = 100
      ◆
    :End
    ◆Text:None, None, Window, Bottom
    :    :Damage to be dealt is \v[147]
    ◆Force Action:#1 Mercenary, tutorialCriticalAttack, Last Target
    and changed the damage formula to
    Code:
    $gameVariables.value(147);
    Damage remains 100.

    Is there any way to check if a player is guarding?
    I have all 8 wave Visustella plugins, though I'm only using a few. I turned off the Battle Core and VisualStateEffects and that didn't make a difference.

    I really don't want to replace the default Guard with a plugin just for these couple of tutorial battles, so I'm hoping there's a way I can find out if the player is guarding when the enemy hits with that tutorialCriticalHit. Thank you for any insight and help.

    Edit: Using the variable method, this happens
    Round 1-Player guards, Enemy prepares for tutorialCriticalAttack (forced noAction/just animation in troop event page)
    Round 2-Enemy hits with tutorialCriticalAttack for 5 damage, player attacks.

    So it would seem I need to find a way to look for the state just before the enemy attacks rather than in the troop turn event?

    Edit 2 [Solved]: So in the end I reverted the formula back to a critical formula
    Code:
    a.atk * 6 - b.def * 2
    added a common event to the skill tutorialCriticalAttack which checks to see if the player is guarding, if so, increments a flag/counter variable.

    The guarding works to accept only half damage and I can check to see if the player successfully guarded against an incoming critical attack.

    Looks like I was approaching it from the wrong side.... :aswt:
  12. m trying to find a way to do a damage formula kind of like this:

    Attack is the power of the weapon, Strength is the power of the character, and both are required for attack power. The following is the formula for damage dealt:

    {\displaystyle BaseDamage=[Attack-TargetDefence]*[[Strength+Level/8]+Strength]}

    but idk how to make a rpgmaker equivalent to that, nor do i know how to get it to pull the attack 0f the weapon and the attack of the player as 2 different parameters
  13. @crackkillz
    Don't know if I can solve your problem in it's entirety, but I can atleast give you a starting point.

    The basic formula would look like this:

    JavaScript:
    (X - b.def) * ((a.atk + a.level/8) + a.atk)

    Note: X is the attack damage of the weapon. Replace "atk" and "def" with the parameters of the characters you want to use.

    Now, the important thing is *where* you store the "power" of the weapon that we use in the formula.
    Since the power of the character and power of the weapon are two different things, we cannot use the same parameter for them.

    The easiest solution for me in this case would probably be:

    1. Give every weapon a notetag, which stores it's "power".
    -> Something like <power:10>
    2. In the formula, replace the X with:
    Code:
    parseInt(a.equips()[0].meta.power)

    Note: This formula won't work with enemies since they don't carry equipment.
  14. ScorchedGround said:
    @crackkillz
    Don't know if I can solve your problem in it's entirety, but I can atleast give you a starting point.

    The basic formula would look like this:

    JavaScript:
    (X - b.def) * ((a.atk + a.level/8) + a.atk)

    Note: X is the attack damage of the weapon. Replace "atk" and "def" with the parameters of the characters you want to use.

    Now, the important thing is *where* you store the "power" of the weapon that we use in the formula.
    Since the power of the character and power of the weapon are two different things, we cannot use the same parameter for them.

    The easiest solution for me in this case would probably be:

    1. Give every weapon a notetag, which stores it's "power".
    -> Something like <power:10>
    2. In the formula, replace the X with:
    Code:
    parseInt(a.equips()[0].meta.power)

    Note: This formula won't work with enemies since they don't carry equipment.
    Thasnks a lot! thats a hell of a lot simpler than what im used to. im more familiar with c# than javascript, and i woulda had to make so many classes to achieve the same thing. so do the note tags run as javascript? and u can declare variables with note tags? if so this rpgmaker is cooler than i thought
  15. @crackkillz
    The notetags themselves don't do anything.
    It's up to the developers to use them according to their intentions.

    I'm sure you can store variables somehow, but not with my example, as notetags are initially just strings. That's why I had to use parseInt() in the formula to convert the power to an integer.

    Putting in whole variables is a little out of my scope of knowledge I'm afraid, as it is a lot more complex, but I'm sure that others can tell you more about it.

    Edit: again, depending on how your game works, my method could pose some problems, as it won't work with enemies, or dual wielding weapons, and I'm not sure how it behaves with no weapons equipped.
  16. ScorchedGround said:
    parseInt(a.equips()[0].meta.power)
    would parseInt(a.weapons()[0].meta.power) work too?is there a difference?
  17. @crackkillz
    I just tested it out and it seems to work aswell.

    The main difference is probably that weapons() gives you an array of just the weapons and equips() gives you an array of every piece of equipment, including weapons and armors.

    But functionally there shouldn't be a huge different in this specific case.
  18. ScorchedGround said:
    @crackkillz
    I just tested it out and it seems to work aswell.

    The main difference is probably that weapons() gives you an array of just the weapons and equips() gives you an array of every piece of equipment, including weapons and armors.

    But functionally there shouldn't be a huge different in this specific case.
    it appears as though parseInt(a.equips()[0].meta.power) only affects the party leader or player actor when i tried it
  19. @crackkillz

    a should refer to the object using the skill, i.e. the actor in question.

    Where did you put the formula in the first place? If you put it into a skill damage formula, it should work just fine.

    So theoretically it should look like this, right?

    JavaScript:
    (parseInt(a.equips()[0].meta.power) - b.def) * ((a.atk + a.level/8) + a.atk)
  20. ScorchedGround said:
    @crackkillz

    a should refer to the object using the skill, i.e. the actor in question.

    Where did you put the formula in the first place? If you put it into a skill damage formula, it should work just fine.

    So theoretically it should look like this, right?

    JavaScript:
    (parseInt(a.equips()[0].meta.power) - b.def) * ((a.atk + a.level/8) + a.atk)
    @ScorchedGround
    it got it working with your help, which is huge. thats the damage formula used in Final fantasy 9. if we call the boost to attack or strength that the weapon gives as "power" then the vaalue that the players strength contributes to the formula can be decl;aired as Strength, which would nee d a base scaling stat and then value. idk how to explain what im thinking so ill put it likke this:

    Strength = StrengthBase+[Level*3/10]+[StrengthBonus/32]
    in which Strength Bonus is increased by any equipment that boosts Strength , and the base was their lv 1 strength.

    damage calculation from a normal attack would be the formula that we figured out above. Well, u figured out lol.

    (parseInt(a.equips()[0].meta.power) - b.def) * ((a.atk + a.level/8) + a.atk)

    and the only other thing i would have to figure out is how to scale everyone in the party's hp values, so im gunna attempt it, let me know how bad i butcher this as im not gunna test it or look it up im just going to try to convert my notes to a format rpgmaker understands....:

    const HPBase = $gameParty.members()[n].gainHp(value);
    let HP = (Strength * HPBase * (Level)/50)

    or something like that idk javascript syntax at all lol

    my thinking was to have HPBase be const cuz it should never change wherease HP is obviously changing per level so i used. let. thats about as much JS as i know XD