Formula Help

I am a little confused on a.mat * 17 / (b.mdf + 10). Where would you use this? Going by your max values from earlier of "his has worked well with MDF numbers around 5-20, MAT numbers around 20-50, and HP numbers around 50-300." Then the end result would be 50 * 17 / (20+10) = 28.3. I am not denying you have a use for it, I am simply asking in what way it is useful to you so that I may see if it will be useful to me as well. Thanks!
The "usefulness" is in the balanced way that it scales as either stat becomes larger.

Let's use the default attack formula of "a.atk * 4 - b.def * 2" as an example of something that doesn't scale as well.  It works fairly well while the numbers are small and similar - 50 attack and 40 defense would result in a reasonable-sounding 120 damage.  But what if def grows large?  At 50 attack and 110 defense, you're dealing literally zero damage.  And what if both numbers grow large?  At 500 attack and 400 defense you're dealing 1200 damage, meaning that you have to scale HP at the same speed as other stats (not usually done in games) to keep the balance anywhere close.

This gets even worse when you also use the default magic formulae, many of which add a fixed value to the equation like "150 + a.mat * 4 - b.mdf * 2".  This gives you NO flexibility in balancing stats - very small numbers like 10 magic and 8 magic resist are meaningless against the 150 base damage (and the amount of HP you'd need to justify 150 base damage), whereas large numbers dwarf the base damage and would make Fire 1 (with 150 base damage) a better choice than Fire 2 (with 400 base damage but otherwise the same formula) almost every time.

On the other hand, multiplicative formulae like "a.mat * X / (Y + b.mdf)" are going to be much more flexible and balanced in the way that stats and HP can scale.  Depending on what X is (and assuming Y is generally constant across skills), a skill that does twice as much damage with low stats will also do twice as much damage with high stats.  As attack/magic grows large, the amount of damage will scale in ratio with the stat, or as defense/magic resist grows large, it will decrease in ratio with the stat, but will never really approach zero.  Doubling your defense means that it takes twice as many physical attacks to kill you, instead of meaning that damage will be reduced by an arbitrary amount (Y * 4).

So in short, this is a better formula to use for the purposes of late-game battle balance, especially in long games or games where you can build your characters how you like.
Thanks Engr. Adiktuzmiko, small mistake but the oversight would have been dire in actual play, is there a way to formula in that it drains a bit of HP from the user first or do I have to learn script for that? (can't solve RUBY for the life of me yet.)
Thanks Engr. Adiktuzmiko, small mistake but the oversight would have been dire in actual play, is there a way to formula in that it drains a bit of HP from the user first or do I have to learn script for that? (can't solve RUBY for the life of me yet.)
a.hp -= (formula for drain); formula for damage

Examples of formula for drain:

  • 50
  • (a.hp * 0.15).to_i
  • a.mat * 2
basically, if you add something like

a.hp -= 10; regular damagein front of the damage formula, it should reduce the user's HP by 10.Haven't tested it, and it might cause problems if that reduction would kill the user, but something like that is usually the way to go...
Got that to work, it can't use a defense stat though or the damage nearly quadruples. Got it currently as a.hp -= 10; a.mhp - a.hp and it removes the 10HP before the damage is dealt (I believe) and scales well. In the event the cost of HP isn't high enough it will kill the user, but still deals the damage that it would have dealt. Not recommended for a party of 1.
Thanks for the explanation!  🙂
Welcome, I did a little testing while I was at work (bonus of a lazy job) and got it shaped out to my liking. Its a shame it deals damage even if it kills the user, but its fine, minor thing IMO. I'm slowly working on the skills/spells for my RPG, been really focusing on the animations and dungeon designs currently. But the advice here has helped me tons! I'm so grateful for it all and figured others could make use of it too.

I'm going to use b.hp on one of my healing skills, works well and heals the target by its current HP, or from my tests roughly (heals slightly less/more, but its around that number) I'd like to know though is there a formula code to remove all states from the target or will I have to do the 'added effects' tab on all the states?
@Aaurael - Yanfly has a script that also lets you set an HP cost on skills, and it does not let you cast them if you don't have the required HP. Maybe that will do what you want instead?
@bgillisp - I tried using Yanfly's 'Elemental Absorb' script, couldn't get it to work for the life of me. I ended up going with Hime's instead. The issue was Yanfly's had all the location id numbers to the side when you tried copy and paste, and that messed it up especially when trying to remove them to make it look like it should. Honestly haven't gotten any of Yanfly's stuff to work for me, so I look else where. As for the being able to use the skill without the required HP cost, its not an issue. The skill is called 'Dark Oath' and is using the elements of Darkness and Metal. I wanted the life drain from the user not really as a 'cost' but as a tribute in exchange for damage that ignored defense and got more powerful the weaker the user got, the fact that it CAN kill the user only adds forethought to it's use. Sure you could use a character with 5HP to attack with it, but it would KO them, now if that person is hard to heal or has the only heal skill, it adds needed planning in the use of the skill.
Is it possible to formula in a pause like for the Dragoon's 'Jump' skill or will that require a script? And yes I'm trying to avoid scripts where I can incase I decide to go commercial with my project.
anything in the formula box is instant. Even most of a skill processing is instant and cannot be paused, the only way to make a delay is by having the script call a common event and process data in that event. And if the delay should be to another turn, you need to mix common event, troop event and variables in a complex way if you want to avoid scripts - it'll work a lot better and easier with a custom script.
If pause means freeze the screen, you can try Graphics.wait(frame)

Replace the 'frame' with any number. Remember 60 is same as one second
@Andar - I honestly haven't been doing this long enough to understand a good deal of that; though with time I could probably figure it out (wish I could write my own scripts)

@TheoAllen - So if I put graphic.wait(60) it'll wait 1 second before doing the attack? Then I'd need to time out how long a turn is and figure out how to remove them from battle for that turn. I'll try thing before seeing about a script as lots of people seem to go straight for a script when the formula text gives lots of potential.

Edited: I may try and find a script for Jump (if formula can't run it.) I'm using a couple of scripts which is currently running me $3 usd for if I decide to actually try and make a profit from my work, which I'd like to avoid going any higher at the time, at least until I get better pay at work.
Thought I had a grasp on this formula deal and seems I was mistaken. I have a character who's focus is his speed and blade style to dispatch foes with minimal effort, One of his attacks hits a foe if he has at least twice the speed/agility stat then the foe its a one hit kill, otherwise it deals his atk+agi x 9 divided by the foe's def+agi. I thought the formula would look like this

a.agi * 2 > b.agi; add_state(1); else; a.atk + a.agi * 9/ b.def + b.agi; end;

But it crashes the game when its used (one way of doing a one hit kill I guess?)

So altered it to a.agi*2>b.agi;add_state(1);else;a.atk+agi*9/b.def+b.agi;end

and same result so I changed it to

a.agi * 2 > b.agi; add_state(1); else; a.atk + a.agi * 9/ b.def + b.agi

And again it crashed

Changed it to a.agi*2>b.agi;add_state(1);else;a.atk+a.agi*9/b.def+b.agi

and same result once again, is my checking the stat wrong or what? I know the problem is in the formula but not sure exactly how.

It has something to do with game_battlers line 352. I don't fully understand RUBY or RGSS so it makes little sense to me.

Original thread: https://forums.rpgmakerweb.com/threads/formula-help.32625/