RMMV Damage Formula - ideas and help

● ARCHIVED · READ-ONLY
Started by Shaz 1539 posts Page 72 of 77 View original ↗
  1. YoraeRasante said:
    IS making two separate randomInts any better than putting them combined in a single one?
    It skews the random distribution from uniform to binomial: extreme variance is less likely. E.g.
    • 1 roll of 2~4 gives results: 2, 3, 4.
    • 2 rolls of 1~2 gives results: 1 + 1 = 2, 1 + 2 = 3, 2 + 1 = 3, 2 + 2 = 4.
    As you can see, 3 is twice as likely as 2 or 4 in the "2-rolls" case.
  2. I see. Like how in tabletop more dices are more reliable than less dices but a small plus.
  3. Hello. I'm trying to figure out a way to have a skill deal damage to only a certain enemy type, so the logic would be as follows:

    If Enemy Type == Bee
    {
    Deal Damage
    }
    Else
    {
    Deal No Damage
    }

    I know in the damage formula you can pull the enemy's ID which is essentially its enemy type, but is there a way to compare it to a list of enemy IDs?Perhaps by doing the following?
    1. If enemyId() == $data_enemies[beeID] { Do Damage } else { Do no damage }
  4. CastorClamwhistler said:
    Hello. I'm trying to figure out a way to have a skill deal damage to only a certain enemy type, so the logic would be as follows:

    If Enemy Type == Bee
    {
    Deal Damage
    }
    Else
    {
    Deal No Damage
    }

    I know in the damage formula you can pull the enemy's ID which is essentially its enemy type, but is there a way to compare it to a list of enemy IDs?Perhaps by doing the following?
    1. If enemyId() == $data_enemies[beeID] { Do Damage } else { Do no damage }
    well, as far as I know you would need to use ternaries when dealing with the damage formula directly.
    ternaries are like if else: (formula to check) ? (if true) : (if false)

    About bees,
    you have two options. You can either:

    give your bee enemies a meta, putting in their noteblock something like <enemyType:bee>, then on the skill make it check for $dataEnemies[target._enemyId].meta.enemyType === "bee"

    use [1, 2, 3].contains(target._enemyId)

    Oh, and either way don't forget to check if the target IS an enemy through target.isEnemy(), unless you are certain it will be a player's only skill.
  5. YoraeRasante said:
    well, as far as I know you would need to use ternaries when dealing with the damage formula directly.
    No, any valid JavaScript code works, including regular if statements. In fact, you need to use if statements when there's going to be more than one command as a result. However:
    CastorClamwhistler said:
    If Enemy Type == Bee
    That's invalid syntax. Your condition needs to be inside parentheses.

    YoraeRasante said:
    About bees,
    you have two options. You can either:
    These are both good.
  6. ATT_Turan said:
    No, any valid JavaScript code works, including regular if statements. In fact, you need to use if statements when there's going to be more than one command as a result.
    Really?
    I remember that some time ago people were having problems using ifs in the damage formula and thus there was a common belief they were restricted to ternaries.
  7. @YoraeRasante - ATT_Turan is correct. Here's a quick example you can test for yourself:

    if (b.isActor()) { alert('actor target'); 50 } else { alert('enemy target'); 100 }
  8. YoraeRasante said:
    Really?
    I remember that some time ago people were having problems using ifs in the damage formula and thus there was a common belief they were restricted to ternaries.
    It could be that you're remembering someone commenting about how if-else constructs behave a little strangely in an eval context. An eval returns the result of the last expression. If there is an if-else construct and no additional expression after it, then the expression returned is the last part of the branch that was taken. That also means that if there is no else branch, it returns null if the branch is not taken.

    In general, I would say it's perfectly safe to use if-else statements as long as one of the following is true:

    * They only set variables and the final expression is afterwards (eg var x = 1; if(b.isActor()) { x = 2 }; x * a.atk doubles the damage if the enemy is an actor)
    * Both branches end with an expression (as Caethyril's example)

    I prefer ternaries most of the time, but that's just my preference.
  9. (stat^2 / maxStat) * mult + base

    Parabola. Starts off super duper slow and then increases rapidly as the main stat approaches the maximum for that character. Base is the starting base damage(the position of the vertex on the X axis), and mult affects the entire range of values(widens or closes the parabola). Factoring in defense was a pain and lead to a gigantic cumbersome formula that gave me numbers I didn't want. I don't know what to do about that.

    On the earlier subject of eval.. why is this used when it's warned against?
  10. Neptuna said:
    On the earlier subject of eval.. why is this used when it's warned against?
    I'm trying to find the earlier subject you're referencing and I'm not sure what your context of "this" is.

    If you're talking about the eval() function itself, and that JavaScript documentation warns against it, it's used in RPG Maker code because that's the only way to allow the user to provide JavaScript that will be interpreted by the engine (e.g. in the damage formula, notetags from plugins...).

    And it's primarily warned against in documentation because it provides a way for users to break your Web sites, but in this case it's intended for the user to alter the game engine.
  11. Technically you can construct functions from strings, bypassing the need for eval entirely. That's also better for most cases: it only has to compile the code once, and doesn't expose values from the enclosing scope (evals can have their local vars rewritten as function arguments).

    The core scripts use eval, though, so we work with what we've got.

    [Edit: expanded a bit on the benefits of new Function vs eval.]
  12. ATT_Turan said:
    I'm trying to find the earlier subject you're referencing and I'm not sure what your context of "this" is.
    "This" being the post right that was above my previous post. I'm sorry you missed it.

    Edit: Fixed tense so you don't get lost in an event horizon whilst trying to find what I was talking about.
  13. Neptuna said:
    "This" being the post right that was above my previous post. I'm sorry you missed it.

    Edit: Fixed tense so you don't get lost in an event horizon whilst trying to find what I was talking about.
    You can be snarky if you like, but the post above yours didn't talk about anything being warned against, so your question is still unclear.

    If you're asking about the use of if conditionals versus ternaries, no one has "warned against" using them.

    As both myself and caethyril (i.e. the three posts immediately above that :stickytongue:) pointed out, they function perfectly well so long as the user pays attention to the fact that the damage formula requires an actual numeric value to be stated at the end in order to function properly.

    That has nothing to do with using if statements or ternaries, you can produce unexpected results with any code if you do it wrong.

    If you're asking why anyone would use if statements at all, ignoring the warned-against thing, the ternary operator can only take one code statement in each section. If you want to do more than one thing as the result of a condition, you have to use an if statement with braces to create a code block.
  14. ATT_Turan said:
    You can be snarky if you like,
    You were snarky first sir, I only responded in kind.

    Now Im asking you, not telling you, to please back off and do not reply to me on these forums. Straight up.


    Edit. .had I known that asking an honest question would've drawn such an encounter, I would'nt have said anything at all. But with the unfortunate benefit of hindsight, I dont feel safe to post here...*and I just got here..*. I really didnt need that to happen....

    Oh well.
  15. Neptuna said:
    You were snarky first sir, I only responded in kind.
    Asking for clarification is not snark. If it were an honest question, you should've had no problem simply saying "I meant this."

    Good luck with your life endeavors.
  16. I'm trying to add a variable into the mix that changes value during gameplay as a sort of weapon affinity. So what I need to do is:

    IF Actor1 is using this skill, do this:
    ( variable21 / 5 ) + a.atk + a.agi - b.def * 2
    ELSE
    a.atk + a.agi - b.def * 2

    Thus, when variable 21 is increased over the course of the game that skill will slowly do more and more damage. So far I got this:

    isActor(1) ? v[21] / 5 + a.atk + a.agi - b.def * 2 : a.atk + a.agi - b.def * 2

    I want only the Player's Actor to have skills that effect battling, whereas other party members/actors deal the normal skill's damage via the ELSE clause in that line of code. But I keep getting 0 damage which is telling me something is going horribly wrong ;_;

    EDIT: forgot to mention I'm using MV, and Actor1 will always be the player as the Formation is never changed during the whole game if that helps!
  17. fladdles said:
    I'm trying to add a variable into the mix that changes value during gameplay as a sort of weapon affinity. So what I need to do is:

    IF Actor1 is using this skill, do this:
    ( variable21 / 5 ) + a.atk + a.agi - b.def * 2
    ELSE
    a.atk + a.agi - b.def * 2

    Thus, when variable 21 is increased over the course of the game that skill will slowly do more and more damage. So far I got this:

    isActor(1) ? v[21] / 5 + a.atk + a.agi - b.def * 2 : a.atk + a.agi - b.def * 2

    I want only the Player's Actor to have skills that effect battling, whereas other party members/actors deal the normal skill's damage via the ELSE clause in that line of code. But I keep getting 0 damage which is telling me something is going horribly wrong ;_;

    EDIT: forgot to mention I'm using MV, and Actor1 will always be the player as the Formation is never changed during the whole game if that helps!
    You're getting 0 because isActor() is not a standalone function, and the one that exists on battlers doesn't take an argument. What you want is

    JavaScript:
    a.isActor() && a.actorId() === 1 ? v[21] / 5 + a.atk + a.agi - b.def * 2 : a.atk + a.agi - b.def * 2
  18. I always thought the default formula's were a little weird. Why is ATK twice as important as DEF? And when DEF is too high, you do 0 damage...

    So, I like to use ATK, DEF, MAT and MDF a little differently:

    Each skill has a base value, which we call X in this case. This value will by multiplied by the casters ATK, and divided by the targets DEF. Like this:

    Code:
    X * a.atk / b.def
    Code:
    X * a.mat / b.mdf

    This way you always do damage. When you ATK is higher than the targets DEF, you do more damage than X, and if their DEF is higher than your ATK, you do less damage. And if your ATK and their DEF are the same, you do exactly X damage.

    Lets say a punch does 20 damages, your ATK is 50 and their DEF is 25, then you do 40 damage.
    (20*50=1000, 1000/25=40)
    Your ATK is twice as large as their DEF, so you do twice the base damage.

    Lets turn it around: a punch does 20 damages, your ATK is 25 and their DEF is 50, then you do 10 damage.
    (20*25=500, 500/50=10)
    Your ATK is half as large as their DEF, so you do half the base damage.

    It is super easy to balance skills like this too. Just higher the base damage for stronger skills, or lower it for weaker skills.

    Of course special skills can have longer formula's, based on the same principles. Lets say you want to deal a quick jab, based on ATK and AGI.

    Code:
    X * a.atk * a.agi / b.def / b.agi

    It's so simple and super effective. Balancing your game was never easier.
  19. JohnDoeNews said:
    I always thought the default formula's were a little weird. Why is ATK twice as important as DEF? And when DEF is too high, you do 0 damage...

    So, I like to use ATK, DEF, MAT and MDF a little differently:

    Each skill has a base value, which we call X in this case. This value will by multiplied by the casters ATK, and divided by the targets DEF. Like this:

    Code:
    X * a.atk / b.def
    Code:
    X * a.mat / b.mdf

    This way you always do damage. When you ATK is higher than the targets DEF, you do more damage than X, and if their DEF is higher than your ATK, you do less damage. And if your ATK and their DEF are the same, you do exactly X damage.

    Lets say a punch does 20 damages, your ATK is 50 and their DEF is 25, then you do 40 damage.
    (20*50=1000, 1000/25=40)
    Your ATK is twice as large as their DEF, so you do twice the base damage.

    Lets turn it around: a punch does 20 damages, your ATK is 25 and their DEF is 50, then you do 10 damage.
    (20*25=500, 500/50=10)
    Your ATK is half as large as their DEF, so you do half the base damage.

    It is super easy to balance skills like this too. Just higher the base damage for stronger skills, or lower it for weaker skills.

    Of course special skills can have longer formula's, based on the same principles. Lets say you want to deal a quick jab, based on ATK and AGI.

    Code:
    X * a.atk * a.agi / b.def / b.agi

    It's so simple and super effective. Balancing your game was never easier.
    So basically what you're doing is applying the percentage of difference between the relevant stats as a bonus/penalty to the damage. I know a few people who do this kind of thing, it's definitely a lot more interesting than dealing with flat values.
  20. Trihan said:
    So basically what you're doing is applying the percentage of difference between the relevant stats as a bonus/penalty to the damage. I know a few people who do this kind of thing, it's definitely a lot more interesting than dealing with flat values.
    That is exactly what I am doing. :) I see those stats as percentages.

    But, if you would make skills this way, you should make your whole game this way. You can't really mix things up with default formula's, where you suddenly do 20 + 4*ATK - 2*DEF damage, because your stats will be off.

    Also the stats of your actors, enemies, weapons and armor will work slightly different then they do by default. The ATK of weapons should go up and the DEF of armor should go down, since ALL armors slots of a certain level should give as much DEF as 1 single weapon of the same level give ATK.