This tutorial builds on the last tutorial project. The basic structure is the same, but we'll be making some changes. If you've not seen the last tutorial, it's worth checking it out, as I'll only be explaining the updates to the objects and event sheet.
The project in the last tutorial was functional, but it would be a bit dull if you incorporated that into an actual game – doing the same damage every turn becomes a bit predictable. Adding an accuracy check gives another element of randomness to the battle system. With a single move, it's easier to add a single accuracy check.
There are a few changes that need to be made to the objects in this project compared to the last one. Our two combatant sprites now have an extra instance variable Acc which will be used for the accuracy checks. Again, these can be whatever numbers you choose, I'm working on a 100 scale to match up with the random number function (which will be defined later) so the two variables are set to 50 for the opponent and 95 for the player. Hopefully, this will better demonstrate the accuracy checks in action!
The BattleText text object is now called BattleEnd, and there's a new text object called HitStatus. HitStatus also carries the Timer behavior.
Talking of the Timer behavior, this is also a good opportunity to look at other methods of controlling the turn states in the battle system. In the last project, we used the Flash behavior to determine when to switch between the player and opponent turns. However, introducing the notion of an attack that can miss means this won't always work. So, in this project, the Flash behavior is purely aesthetic – the turn control is done using the Timer behavior.
Where in the last project the turn functions were called when the Flash behavior stopped flashing, this is now replaced with a Timer trigger: