Super Basic Battlin'

13
Official Construct Team Post
Laura_D's avatar
Laura_D
  • 6 Nov, 2020
  • 404 words
  • ~2-3 mins
  • 1,432 visits
  • 2 favourites

Last week I talked about my current project – building a turn-based, Pokemon-inspired battle system. Step One for this inevitably long process has been a success: stripping back the mechanics to build the turn-based system in its simplest form. Understanding how a turn-based system might work is rather vital when your end goal is to build a complex collection of mechanics funnily enough.

As an aside, I hope you are prepared for some excellent programmer art.

The test is made up of an attack button, two participants that both have an HP, Attack and Speed stats and a couple of text objects to display some of the data. It's controlled using the mouse (in the sense that all that needs to happen is a button click) and simulates an incredibly basic battle.

A Boolean variable keeps track of if it's the player's turn, enabling the events for the attack button. When the attack button is clicked, a speed check determines which of the participants should attack first and if the speed stats are the same, a choose expression picks which of the attack functions should be called.

Each attack function checks if the attacker has an HP value greater than zero, and if so subtracts the attack value from the target's HP. The attack causes the target to flash and as long as only one participant has made their attack, then once the flash has ended, the other attack function is triggered. If both participants have moved, then the EndTurn function is triggered and sets things up for the next turn. Whoever loses their HP first loses the battle and triggers the Game Over screen.

It's probably not the best foundation in the world, but it's a great starting place for me. My next step is to try and introduce an accuracy check for the attack. The way Pokemon does this is by calculating an A value made up of a move's accuracy and several modifiers. This is then compared to a random number between 1 and 100 (R) and if R is less than or equal to A then the move hits. For the next test, I think I'll ignore the modifiers, a simple random number check should be sufficient to start with.

How hard can that be?

Subscribe

Get emailed when there are new posts!

  • 6 Comments

  • Order by
Want to leave a comment? Login or Register an account!