Marcy’s Mark: Challenge Solutions

A few weeks ago we discussed the power of the damage formula bar in a skill, and two challenges were issued.

Beginner Challenge

Marcy Mage has a slightly different mark she applies. Any damage the enemy takes by any of Marcy’s friends (or Marcy herself) will be measured against that enemy’s magic defense – even physical damage. How do we do that in the formula bar?

Advanced Challenge

Marcy Mage just leveled up her mark. Now, any damage the enemy takes is does fire damage, such that it considers the target’s fire resistance or weakness (great against those stupid ice imps). How do we do that in the formula bar?

So let’s dig in!

Beginner Challenge

You can probably guess based on the last post that our damage formula is going to be a ternary operator. And you might even guess that the first part, the question, is the exact same as before. That’s right:

b.state?(25) ? x :y

And in fact, “Y” should just be the normal damage done by the skill. It’s what happens when the state isn’t on. All we need to do is fill in for x.

The answer is to just change the stat examined. So, if we look at our damage formula, we’ll say that we replace the enemy’s defense with magic defense. Something like:

b.state?(25) ? (a.atk*4 - b.mdf*2) : (a.atk*4 - b.def*2)
Check the comments section for dozens of different stats you can reference in your formula bar!

Check the comments section for dozens of different stats you can reference in your formula bar!

And that’s it!

Advanced Challenge

A bit more involved this time; first, we’ll need the number for your fire element. Remember, those little index numbers in the database are always the key! We ask what an enemy’s resistance is to an element with:

b.element_rate(n)
The index is listed in this tab in your database.

The index is listed in this tab in your database.

This returns a decimal corresponding to the percentage you might set in your enemy page. For example, the default “Slime” takes 200% ice damage, so b.element_rate(id number for ice) would be the same as saying “2.”

See where this is going? The following answer will give you the upgraded mark which takes into account the target’s fire resistance:

b.state?(25) ? (a.atk*4 - b.mdf*2)*.b.element_rate(3) : (a.atk*4 - b.def*2)
This works...kind of.

This works…kind of.

 

And that’s it! Follow instructions – Marcy’s mark doesn’t have this upgraded ability until later in the game! Let’s say she gets access to it at level 10. Uh oh, now we have three possible options:

  • The enemy hasn’t been marked
  • The enemy has been marked, and Marcy is level 10 or higher
  • The enemy has been marked, and Marcy is not yet level 10

We need three possible damage formulas, not two. Let’s follow the logic.

Does the enemy have mark? If no, do regular damage. If yes, is Marcy level 10 or above? If no, do magic defense damage; if yes, also do fire damage. To avoid repeating myself so many times in a line, I might actually want multiple lines of code. To do that, use “;”. Something like:

mult= $game_actors[9].level >= 10 ? b.element_rate(3) : 1; b.state?(25) ? (a.atk*4 - b.mdf*2) * mult : (a.atk*4 - b.def*2)

So that’s actually two lines of code. First, assign the variable “mult” based on whether Marcy (who, in my example is Actor 9) has reached level 10 or not. If she has, mult is our enemy’s fire resistance rate, otherwise it’s just 1. Then, if the mark is applied, attack using magic defense and apply the mult (meaning just multiply by 1 if Marcy isn’t level 10 yet); if the mark isn’t applied, do normal damage.

Remember, we need to use Marcy's level, and that means we need Marcy's id. Here it's 9.

Remember, we need to use Marcy’s level, and that means we need Marcy’s id. Here it’s 9.

Check to make sure your final product fits in the bar!

Check to make sure your final product fits in the bar!

One final problem. This line is too long for the bar! So, we’d likely need to add it into our script section, and then call the function from our formula bar.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s