Formula Help

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Alright I've got an issue in my game with a skill that I've been trying to play with.

Basically in my game I have states that are inflicted by certain elemental attacks, the light skills and dark skills are supposed to have a instant death effect if hitting a target under the dark/light state respectfully. So my question is what formula do I use to make a skill deal damage to an enemy unless it's in a certain state in which its a 1-hit KO?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,107
First Language
English
Primarily Uses
RMVXA
If you want to do it with damage (not the cleanest way, but the easiest), you can use the following formula:

if b.state?(38); b.add_state(1); 999999; else; a.mat * 4 - b.mdf * 2; end

"38" is whatever light or dark state would activate the instant KO.  "1" is the designated KO state (which will probably be 1 for you).  The last line before "end" can be changed to whatever damage formula you want.

What this does is check to see if the target as the light/dark state, and if so, it both deals 999999 damage and forcibly adds the KO state to the target.  In most cases either one of these two things would be enough, but in case the enemy has "Element Rate 0%" elemental resistance or a 0% state rate for KO, this will ensure that the instant KO still works.

The cleaner, more flexible, but harder way to do this would be to apply a Dummy State and use a Common Event to run the appropriate processing for each enemy/actor that has the Dummy State.
 
Last edited by a moderator:

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Duh, I didn't even think about the b.add_state(1) when reading that blog by Formar (and yes, KO is 1 for me too now.) Would this work without the 999999 also? As would it work as if b.state?(17); b.add_state(1); else; a.mat * 4 - b.mdf * 2; end ? Going to give it a try and pray that nothing goes wrong with game_battler script as it has been. Thanks a ton Wavelength!
 

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Just tested it as if b.state(17); b.add_state(1); else; a.mat * 4 - b.mdf * 2; end other then doing nearly 50% of their hp in damage when not in the dark state it works like a charm. I'm going to have to change the battle formula on the damage end, but it works without a crash, thanks!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
well, adding state 1 to a battler in VXAce = killing that battler (by default)
 

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Yeah I didn't think of it (only owned Ace for about 2 weeks now). I'm still having some issues with the formula damage wise. Its either doing no damage or its doing nearly 4k damage. But at least the 1-hit ko on state is working.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,370
Reaction score
7,678
First Language
German
Primarily Uses
RMMV
The damage done is always the last number returned from the formula - that sometimes requires indirect methods because you can't end the sequence on a non-number value in a lot of cases.


For example setting the damage number first and then adding a state will usually cause the first number to be ignored...
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
yeah, if you use the 1-hit method via just adding the death state, then it will surely deal 0 damage when the 1-hit KO succeeds. :)
 
Last edited by a moderator:

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Well I've been using Effect: -10+-10% HP for the time, with the formula if b.state?(17); add_state(1); end. Seems to work more or less, just seems to be doing too much damage still, wouldn't think on an enemy with 8k HP 4,051 is 10%+10 damage or on an enemy with 250HP 289HP would be that, so still working with balance on the damage bit, but its working...More or less.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,107
First Language
English
Primarily Uses
RMVXA
Plug in whatever formula you want in place of "a.mat * 4 - b.mdf * 2" - the only I reason I used that here was that it's the default formula for some magic in VX Ace, so it seemed like a good example.  Whatever formula you're using for most of your skills should work when inserted in that part of the formula I gave you.

The reason I added the "999999" was so it would still automatically KO an enemy that had a "State Rate: KO" feature set to under 100%.  You might or might now want this behavior, so as you've discovered, you can safely remove the 999999 if you don't want this behavior.
 

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Yeah, it just seemed redundant to me is all to have add_state?(1) and deal damage 999999 as well. But I've tried the damage on various enemies of varying mdef. Either its reflected, it deals over 50% they're HP or it just does no damage when I use any damage formula. Still playing around with it on the side, but it is more or less working. And now that I know a few formula ideas I can add some variety to the things abilities do other then basic damage.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,107
First Language
English
Primarily Uses
RMVXA
How about the other skills in your game - I assume you are also having trouble getting the balance right on those as well?

Here's the basic formula I used for spells in my last game: a.mat * 17 / (b.mdf + 10)  The 17 is replaced with different numbers based on how powerful the spell is, but the 10 is usually the same everywhere.  This has worked well with MDF numbers around 5-20, MAT numbers around 20-50, and HP numbers around 50-300.  What's I find really nice about such a formula, however, is that the division rather than subtraction means that it's easier to avoid bad balance.  No matter how high the target's MDF is, it won't do zero damage, and raising MAT to high levels will allow the damage to scale linearly, rather than exponentially.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
@Wavelength: I like that idea! I've been playing around with different spell formulas in my game, and been struggling to make it so that all late game spells don't do 9999 all the time, and also to make boosts to MDF matter more (right now I've been doing spell formula - 5.0 * b.mdf instead).
 

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
I will definitely have to try that, I hadn't seemed to have too much problems with my other skills, but this might just help give the weak ones the oomph they need and the over powered the water down without being too under powered. Still really working on animations for all the spells/skills, but I needed to branch and get started on the actual skills. I'll have to put this division formula to the test and see if it helps, might even answer my light skill issue; that one has me bogged at the time, even on an enemy with 2 mdf it still does nothing unless under the dark state, really got me for a loop that does.

Just gave it a try, works very nicely and no longer needs the Effect -10%+-10 recovery addition like I was using, the division seems to work much better then the multiplication. Thanks everyone, save to say the issue is solved and I know where to come first for any further questions.
 
Last edited by a moderator:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,107
First Language
English
Primarily Uses
RMVXA
No problem.  The formula, as I gave it to you as part of the "conditional automatic KO", should work the same as for any other skill.

Glad that (both of you!) like the "division" formula.  League of Legends does something similar with Armor and Magic Resist and I was inspired by how well it works with both small and absurdly large numbers.  Of course, if you expect your DEF or MDF numbers to reach into the hundreds, you can start with a bigger "base" in the divisor than 10. :)
 

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
What about a formula for an attack based off the user's def stat? would it be a.def instead of a.atk or a.mat? (thinking of this for one of my paladin's attacks.)
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
a.def works it base it on defense. I'm using it in my game for a skill where the character attacks with the shield.
 

Zurea

Alchemist in Training
Veteran
Joined
Sep 30, 2014
Messages
57
Reaction score
11
First Language
English
Primarily Uses
Thanks, will try that. Still on Formulas would I use a.hp-a.mhp * 1/b.mhp for an attack that deals damage based off the user's current hp - their max hp? For basically an attack that deals more damage the lower the user's HP goes example: User has 200 HP but is currently at 2HP so the attack deals 200-2=198 damage. And what's the formula code to make the skill drain a small portion of hp from the user as well. I had seen a skill formula that set a state, curious if I can make it drain some hp as well.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
It should be (a.mhp-a.hp), if you did hp before mhp, that will be negative and will result to a heal instead
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
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!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top