As I explored firsthand, however, if you change one of the values in the array $game_variables[x] *during* the attack rather than afterward, then the mdr for the damaged party will remain the same as it was before the attack until the attack is executed. Say, for example, you wanted to make $game_variables[1] equal to the difference between Actor Bob’s current Magic Points (mp) and the enemy’s Magic Attack (mat). If you wanted to do that, you would need access to the target *before* Bob actually executes the attack. If Bob is being controlled by the player, this is obviously something you don’t want.

Obviously, if you aren’t planning to use the foe’s stats, this won’t be a problem. I have found a workaround, however, if you are interested.

First, disable Yanfly’s mdr_formula by making it equal to base_mdr. If you use both that script and this technique I am suggesting, it will run the formula you have planned twice.

Second, go into RPG Maker VX Ace’s default scripts (the ones that control the logic of a base RPG Maker VX Ace game) and find the class of objects called “Game_Battler” under the header “▼ Game Objects”. Go to line 355. mdr is used once in the Game_Battler class, under the class method “make_damage_value” which includes line 355. Line 355 should look like this to start:

355 value *= mdr if item.magical?

Now, all we need to do is add your formula, substituting any instance of “n” with, for example, (mp-user.mat). Since this method is calculating the damage that a battler will suffer, mp or any other stat is the same as saying “x stat of the battler being attacked”. user.[stat] is instead the same as saying “x stat of the battler who is attacking”. Thus, your formula would convert to:

355 value *= mdr – ((mp-user.mat) / (256.0 + (mp-user.mat))) * 0.500 – 0.000 if item.magical?

Now what if you want to record this value? Say, for example, in testing, you want to be able to see what the value actually calculated to in order to make sure it is balanced like you want it to be. Easily done. Just hit enter after line 355 to add another line, and then set a value in the array $game_variables[x] equivalent to the value of “value”:

355 value *= mdr – ((mp-user.mat) / (256.0 + (mp-user.mat))) * 0.500 – 0.000 if item.magical?

356 $game_variables[1] = value

357 value *= rec if item.damage.recover?

…etc

As you can see, the line that was line 356 is now line 357. In case you’re totally unfamiliar with coding, you needn’t worry about this. Their line number has no bearing on how they work. As long as the lines themselves, their order, and their syntax are not changed, the code will still work.

I did a lot of extra typing for something you might not even use, but I hope you found this informative regardless of whether or not you will use the latter half of my explanation. Happy making!

]]>When I added that * 0.01 back to line 475 to show you all what the original script looks like, I meant to add it to line 474. I made the mistake of thinking it was from line 475 at first, and then I failed to correct myself when I proofread. Sorry for any confusion.

]]>In the scripts, there is a section that comes prepackaged with all RPG Maker VX Ace games. Normally, line 475 in this section’s class, Game_Battlers, there are two lines of code that multiply the success rate of a skill by the user’s hit rate if the skill is physical:

rate = item.success_rate # Get success rate

rate *= user.hit * 0.01 if item.physical? # Physical attack: Multiply hit rate

If you want to implement a comparison of AGI in your hit rates, you need only add a few lines of code and snip a small part out of line 474:

474 rate = item.success_rate # Get success rate

475 rate *= user.hit if item.physical? # Physical attack: Multiply hit rate

476 rate -= self.agi-user.agi if item.physical? #ADDED

477 $game_variables[50] = rate if item.physical? #ADDED

478 rate *= 0.01 #ADDED

479 return rate

Let’s break this down. Line 474, the start, has the multiplication by 1% removed, as I encountered some issues with recording “rate” as a variable unless I change “rate” to a decimal after converting it into a variable. I think it has something to do with the default formatting for strings–I might be able to tidy this code up with more research, but I’m just happy with a working product. After that change, line 476 (you will want to create a new line after 475 so you don’t write over the original line 476, which will now become line 479) will subtract the difference between the target’s agi (referred to as the object instance variable “self.agi” by the game’s code) and the user’s agi (referred to as the object instance variable “user.agi” by this method and several others). If you’re like me, and you want to check this hit rate with a spreadsheet to see if it lines up with the data you had planned for your game, you can optionally add in line 477 to commit the hit rate as a percentage to game variable 50. In my previous post, game variable 50 was used to record the AGI difference in Yanfly’s Extra Param Formulas script–I took that part out of his config and my phys moves to account for this new code, so don’t leave it in if you were inspired by me! Finally, to account for the snippet of code we removed from line 474, line 478 should multiply rate by 1% (0.01 in decimal form).

If anybody reading this uses the information herein to add more variety to how hit rates are calculated in their RPG, I would appreciate a credit in your project! You can just call me “Demonboy75.” If you don’t credit me, of course, it’s not like I can start a manhunt or anything. Still, I’d even just be glad to get a “thank you” in this comments section. This was bloody difficult, and the pompous side of me wants a head pat from someone besides myself.

Happy holidays,

Demonboy75

:eva_n_value => “if state?(x);2;else;1;end”,

:eva_formula => “base_eva * n”,

Using the comparative format “if [statement];value ‘a’;else;value ‘b’;end” is very useful for creating conditions for higher stats like the situation you have described here. Now, let’s say your Double Evasion status effect is status effect 35 in the database. Then you will just replace the x I put in the template with 35:

:eva_n_value => “if state?(35);2;else;1;end”,

:eva_formula => “base_eva * n”,

If this is the case, then all actors with state 35 (Double Evasion) inflicted upon them will have an “n” value of 2. If they do not have such a state, they will only have an “n” value of 1. Thus, eva_formula will calculate twice the value of base_eva for all actors and enemies that are inflicted with state 35, as the formula to calculate the final evasion (eva_formula) is simply your “n” value (2 if inflicted with Double Evasion; otherwise 1, meaning it’s a pointless value) multiplied by the actor or enemy’s base_eva.

If you want to learn more about just how versatile the formula bar can be in RPG Maker VX Ace, I highly recommend Fomar0153’s post about the many possibilities of the formula bar and conditional branches within the formula bar–this language works both in this script and in the database’s formula bar for skills and items.

http://cobbtocs.co.uk/wp/?p=271

:cri_n_value => “luk/100”,

:cri_formula => “base_cri+(n/100)”,

With this formula, the value “n” becomes the value of Luck divided by 100. Therefore, for every 100 Luck, “n” increases by 1.

Say, for example, Bob has 500 Luck. The value “n” becomes 5, because 500/100 = 5. That value will replace “n” in the formula cri_formula, and that will ultimately determine the critical hit rate. Since we want Bob’s crit rate to increase by 1% for every 100 Luck, that means we want to multiply Bob’s value “n” (the number of times 100 that equals Bob’s crit rate) and 1% (0.01, or 1/100). Since we can express 0.01 as a fraction, 1/100, and we still want to incorporate Bob’s base crit rate, the formula becomes

base_cri + (n)(1/100)

Through multiplication (which occurs before addition because of order of operations), we can simplify this formula into

base_crit + (n/100)

the formula stated above.

Following this formula, let’s calculate Bob’s crit rate as an example of what will happen.

Bob’s base_crit is 5%, so that’s 0.05 as a decimal value.

Bob has 500 Luck, so n will equal 500/100, or 5.

5 divided by 100 is 0.05, the decimal equivalent to 5%.

.05 + 5/100

.05 + .05

=.1

The calculation ends with 0.1, so Bob will have a 10% crit rate for all of his attacks.

I would still need to create an *activator skill* for all player-issued special attacks, but using several variables, I was able to convert enemy AI to a common event using two states that identify the user and the target. Since I can then use that state to understand who is attacking (a) and who is attacked (b) via conditional branches, I can execute a makeshift approximation of the formula b.agi – a.agi before the foe actually uses their attack.

This allows one unified activator skill, as LUK does nothing but act as an identifier for a Stat Reader common event that gives the foe’s stats to the player, so I was able to use it as an ID for dividing enemy AI between conditional branches as well.

Using a script from user Tsukihime on RPGMakerCentral (https://www.rpgmakercentral.com/topic/15367-remove-user-name-casts-message-when-using-skills/) and your Battle Engine’s ability to hide status popups, I was successfully able to hide the activator skill almost entirely–the enemy flashes twice instead of once when they attack, but I can easily pass that off as a “feature.”

My problem still remains for the player characters (actors), however, as they have to select their skill *before it has a target.* Please, if you have any solution through common event knowledge or some line of code I could add, I implore you to provide it at your nearest convenience.

All the same holiday wishes and my preemptive gratitude,

Demonboy75

Using the Input Combo Skills system, normal attacks give the player a choice between:

Attack (100% base_accuracy, 4% crit rate, ATK x1)

•••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, no attacks left, cancels)

••••••Add defense (reduce all damage by 20%)

••••••Add evasion (increase evasion to 50%)

•••Add power (change to 97% base_accuracy, 6% crit rate, ATK x1.2)

••••••Attack again (97% base_accuracy, 6% crit rate, ATK x1.2)

••••••Add power (erroneous, no attacks left, cancels)

••••••Add defense (reduce all damage by 20%)

••••••Add evasion (increase evasion to 50%)

•••Add defense (reduce all damage by 20%)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, defense already added, cancels)

••••••Add defense (reduce all damage by 40%)

••••••Add evasion (erroneous, defense already added, cancels)

•••Add evasion (increase evasion to 50%)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, evasion already added, cancels)

••••••Add defense (erroneous, evasion already added, cancels)

••••••Add evasion (increase evasion to 80%)

Add power (change to 97% base_accuracy, 6% crit rate, ATK x1.2)

•••Attack (97% base_accuracy, 6% crit rate, ATK x1.2)

••••••Attack again (97% base_accuracy, 6% crit rate, ATK x1.2)

••••••Add power (erroneous, no attacks left, cancels)

••••••Add defense (reduce all damage by 20%)

••••••Add evasion (increase evasion to 50%)

•••Add power (change to 90% base_accuracy, 10% crit rate, ATK x1.65)

••••••Attack (97% base_accuracy, 6% crit rate)

••••••Add power (activates Power Attack, 50% base_accuracy, 20% crit rate, ATK x2)

••••••Add defense (reduce all damage by 20%)

••••••Add evasion (increase evasion to 50%)

•••Add defense (erroneous, power already added, cancels)

•••Add evasion (erroneous, power already added, cancels)

Add defense (reduce all damage by 20%)

•••Attack (100% base_accuracy, 4% crit rate, ATK x1)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, defense already added, cancels)

••••••Add defense (reduce all damage by 40%)

••••••Add evasion (erroneous, defense already added, cancels)

•••Add power (erroneous, defense already added, cancels)

•••Add defense (reduce all damage by 40%)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, defense already added, cancels)

••••••Add defense (activates Full Guard, reduce all damage by 80%)

••••••Add evasion (erroneous, defense already added, cancels)

•••Add evasion (erroneous, defense already added, cancels)

Add evasion (increase evasion to 50%)

•••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, evasion already added, cancels)

••••••Add defense (erroneous, evasion already added, cancels)

••••••Add evasion (increase evasion to 80%)

•••Add power (erroneous, evasion already added, cancels)

•••Add defense (erroneous, evasion already added, cancels)

•••Add evasion (increase evasion to 80%)

••••••Attack again (100% base_accuracy, 4% crit rate, ATK x1)

••••••Add power (erroneous, evasion already added, cancels)

••••••Add defense (erroneous, evasion already added, cancels)

••••••Add evasion (activates Hit & Run, increase evasion to 90%, 4 attacks at 100% base_accuracy on one foe that deal 1/4 of regular damage)

In addition to base accuracy, however, I want to account for the difference between AGI in opponents.

I used this script, Extra Battle Params, to do so. I used the following formula for calculating

:hit_n_value => “if state?(2);$game_variables[50]+3;elsif state?(3);

$game_variables[50]+10;elsif state?(4);$game_variables[50]+50;else;

$game_variables[50];end”,

:hit_formula => “((base_hit*100) – n)/100”

Where states 2, 3, and 4 are different levels of power and game variable 50 is the

difference in AGI between a foe and the user (b.agi – a.agi) for each individual

action.

This only works for your Combos script because there is a combo skill used prior

which recalculates the hit rate before Attack is actually used.

For enemies and player special attacks that do not use the combo system, it does not

recalculate this hit rate. What I am wondering is if there is some way to add

a line to RPG Maker VX Ace’s code to calculate game variable 50 as the difference in

AGI between opposing parties for every skill used in the game before the success

of the attack is calculated (essentially, I want the hit rate to include

game variable 50 after it has been calculated rather than before).

As it stands now, I tried using the formula bar to calculate game variable 50,

but it saves game variable 50 for the next attack’s accuracy

rather than considering its effects on the hit rate of that attack.

This is incredibly problematic; that means that the hit rate isn’t determined

by the AGI comparison of the target and user, but instead the hit rate is

determined by the prior user of physical skills and their target. If I made every single skill have an *activator skill,* filling the same preliminary role as your Input Combo Skills, I could actually resolve this, but that would require two skills in the database for every single physical attack skill in the game; it is doable in the worst case scenario, but, as previously stated, problematic.

Please, anyone with relative knowledge of RPG Maker’s awful programming

language (I have taken two semesters of Java-based classes in college and it makes me cringe to see all the poor decisions in syntax), help me out with this at your nearest convenience. Incorporating the AGI of the user and opponent adds so much more complexity as to when it is appropriate to add power, making experimentation with the Attack Flavor system much more rewarding than “if they have high defense, you’re going to need to give up some accuracy, otherwise just do regular attacks.”

Happy Thanksgiving, and have a nice holiday once it rolls around.

-Demonboy75