RPGs have a lot of stats that make battles more interesting: Attack lets us hit enemies harder, Defense keeps our heroes from fainting after one hit, and Agility speeds the battle up. But what about the often-ignored stat, Luck? Let’s take some time to find a few ways to use Luck, both in and out of battles.
By default, the parameter Luck affects the chance of getting a state like poison, but often people overlook that it could be used in other ways. In fact, quite a few games don’t consider that the parameters can be used for more than just battles, such as changing a reward or offering the player with a high parameter new information.
Keep in mind that we could use any of the parameters in similar ways to how we’ll be using Luck, so if you wanted to use Attack or Agility instead you can with just a few minor tweaks.
First up is a way to have Luck affect battle skills. Of course we could just add a.luk to a damage formula so that our actor’s Luck is used instead of (or with) their Attack, but that’s not the only option.
What about a skill that has the chance to double or even triple the skill’s default damage when the user’s Luck is high?
To start, we’ll need to add our skill to the database. The details like animation and message will depend on the game and who will be using the skill, so choose something that will fit your battles. We’ll be focusing on the damage section, since that’s where we’ll be using Luck.
Our skill’s description of “An attack that has the chance to do more damage if the user's Luck is higher than 50”, should give our players an idea of how the skill will work: it’ll check the attacker’s Luck and adjust the possible damage done depending on that Luck parameter. Which means our damage formula is going to need to include a conditional branch to check Luck as well as the actual damage formula. Luckily there is a built-in way to do that, so our damage formula will look like this:
Condition ? Effect if condition is true : Effect if condition is false ; Actual Damage formula
We already know that our Condition is if the user’s Luck is higher than 50, so we’ll write it as a.luk >= 50. Before we fill in the effects, we need to decide how we’ll be affecting our damage formula. There are a few ways we could do this, but for this skill let’s set a variable that we can use to multiply the damage done. Variable 1 isn’t being used to keep track of anything in this project, so let’s set it to 1 if the Luck is under 50 and 3 if it’s over. The damage formula lets us shorten variables to v[N], so our Effect if condition is true will be v[1] = 3 and our Effect if condition is false will be v[1] = 1. Last thing we need is the part that will actually be the damage done to the enemy, and to keep it simple we can make it a simple formula of the attacker’s Attack times the variable we just set.
So all together, our damage formula is: a.luk >= 50 ? v[1] = 3 : v[1] = 1 ; a.atk * v[1]
To make sure everything is working properly, we can set the variance to 0 and critical hits to ‘No’ so that when we playtest the skill in battle we’ll be able to easily tell if it’s working.
But what if we want some real luck into the damage formula, by having the variable randomly be 1, 2, or 3 if the attacker’s Luck is more than 50? Then we’ll need to do some Math! To get a random number, we’ll be using Math.floor(Math.random()*N) + bonus , where the N will affect the range of possible numbers (starting from 0) and the bonus affects where the range starts numerically. So if we used Math.floor(Math.random()*4) + 0 the the possibilities would be 0, 1, 2, and 3, while Math.floor(Math.random()*2) + 2 would give us 2 and 3. Since we want our variable set to something between 1 and 3, our code will be Math.floor(Math.random()*3) + 1 .
Which makes our new formula: a.luk >= 50 ? v[1] = Math.floor(Math.random()*3) + 1 : v[1] = 1 ; a.atk * v[1]
And again, we’ll want to test it in battle to make sure it’s working right. Of course, with the added randomness it may take some extra testing to see if it’s working (I had the variable set to 1 five times in a row even though the attacker’s Luck was 75) so setting up the variable’s code to something more obvious like Math.floor(Math.random()*3) + 5 could be useful.
But that’s enough with battle skills. What about using Luck to give our players new NPC dialogue?
Creating a few events that require high Luck gives our players a reason to revisit places after leveling up as well as a reason to care about Luck outside of battles. So let’s make a few events that will reward a player if their Luck is high enough.
The events themselves will be pretty straightforward, we just need to set a variable to the actor’s Luck and check that variable with a conditional branch to change how the event responds.
The control variable command gives us the option to set our variable to any of our actor’s parameters, so we can easily put our main character’s (Priscilla in this case) Luck as the variable.
With our Luck safely tucked into our variable, we can set up a conditional branch to see if the variable is more than 50, and reward our players if it is. If it’s less than 50, then the event lets our players know their Luck isn’t high enough.
While that works great for a game with a single main character, what about games that let you change the team’s leader? Luckily there’s some javascript that will let us check the leader’s Luck! $gameParty.leader().param(N) can give us the selected parameter for the actor that is leading the team, with N replaced with a number from 0 to 7, each number being tied to a different parameter (0:Max HP, 1:Max MP, 2:Attack, 3:Defense, 4:Magic Attack, 5:Magic Defense, 6:Agility, 7:Luck). So to set our variable to the leader’s Luck, we'll use $gameParty.leader().param(7) .
The rest of our event can be the same as our previous one:
Now when we playtest and talk to this event, it will respond to the leader’s Luck no matter who is leading the party!
The last way we’ll look at using Luck is having it adjust the randomness of rewards. It can be nice to have treasure chests give a random reward, like giving more gold or a rare weapon, and it’s easy to create a random drop by setting up a random variable and using conditional branches to give different rewards depending on the variable amount.
In this case, we can set a variable to a random number between 1 and 10 and have the amount of gold given increase if the variable is higher than 7.
There is a problem with a setup like this though: our player’s Luck doesn’t have any effect! So even if our player has been dutifully raising all of their actor’s parameters, they could still end up getting one of the lesser rewards. Instead, why don’t we adjust the variable depending on the leader’s Luck? As long as we set up our rewards so that the better ones require a high variable, we can add to the random variable to up the chances of the event giving one of the better rewards.
We already know the code to check our party leader’s Luck, so we can use it in a conditional branch to see if the Luck is high enough to warrant adjusting the randomness. So if we want to give the chance to increase the variable if the leader’s Luck is equal to or more than 25, we could use $gameParty.leader().param(7) >= 25 in the conditional branch and possibly add a 1 to our random variable.
With our Luck adjustments ready to go, we can just slip them in between setting the variable and giving the reward. Our treasure chest should now be more likely to give lots of gold if the party leader’s Luck is high.
Now we’re ready to make Luck (and the rest of our actor’s stats!) really matter in our games! Where would you use Luck in your game to make it more fun?