Making A Turn Based Combat System


#1

So this is a topic on how to make a turn based RPG game. If you don’t know what a turn based RPG is, think Pokémon.

How To Make The Turn Based Parts:
Variables are helpful in turn based because you can set variables to all the different characteristics of your battle(for example a specific move you can use). If you want to make the core turn based part though it is pretty simple. Use a check Once Block and the check if Turn(a variable)=1 (Turn 1 is your turn and Turn 2 is your opponent’s) you can put this inside a when tapped block. For complete reference to Pokémon, When Ember(a move) is tapped Check once if turn=1. Then put whatever you want inside the check Once block. If it was an attack that took away the enemies HP it could be something like this:
When Ember Is Tapped
Check Once If Turn=1
[Increase Boss HP by -2].
You can do this both ways with the enemy and with yourself.

How To Make A Move That Acts Like Defense System:
This is where it takes a little bit of thought to figure out how to do this because think normally you can’t do this with variables. Or at least 100% accurate. You can make it 99.99% accurate, but using variables it won’t always work. I will show you why. Let’s say whenever you use the move “Defend” a shield pops up. And you want the shield to stay through to the enemies Turn and back to yours. With variables you have to keep repeating to check when your opponent’s turn ends. You have to use repeat and wait Blocks, which means that if under a certain period of time “X”(x would be how much time you put I the wait Block" and it would just keep repeating. Of course, you can’t use repeat forever because hen that conditional can’t do anything else which is bad. Using one conditional makes this easier because setting a variable and then checking for it won’t work properly because it is in the same conditional. So, you have to use a combination of check Once If that check when the variable switches:
Check Once If Turn=1
[Check Once If Turn=2
[Check Once If Turn=1
[Set Invisibility 100%]]]
Since it can’t repeat forever, it has to keep switching between turns. And it has to get through Turn 2 again before it can get back to turn 1, when it disappears.


I know this was me kind of talking about how to make this but a I hope somebody read all of it and now understands how to make one of these games.
https://c.gethopscotch.com/p/z3uep4c30
@POMTL


#2

I have gotten ten likes on this yet no replit’s. Does anyone have any questions?


#3

Good tutorial.
You could show how to code a random damage amount based on the distance of the player to the enemy.


#4

Well that wouldn’t be in an RPG


#5

Hi @HopscotchRemixer

Thank you for sharing :grinning:

The project link doesn’t work for me. Could you give the username & title to search for?


#6

There’s one part you might think a bit more about though. Regarding the defense shield & using variables, you said:

it won’t always work. I will show you why. Let’s say whenever you use the move “Defend” a shield pops up. And you want the shield to stay through to the enemies Turn and back to yours. With variables you have to keep repeating to check when your opponent’s turn ends.

This can be done elegantly and 100% accurately using variables (without continually checking & without waits). Give it some thought how you might do this by using conditional When rules…


#7

Oh sorry…you must have misunderstood me…I only wanted to use 1 conditional. I don’t know why the link doesn’t work for you…it worked for me…


#8

I might be over thinking it. Either way I still think it is easier my way…I don’t know you are way better than me.


#9

The popular RPG “Final fantasy 7” on PlayStation 1 had a combat system that had the player choose to move their units to the front or back row as well as a lot of other RPG’s.


#10

I see both of your points. Final fantasy is what came to mind for me as well when you mentioned “distance” before. However, strictly speaking, the damage isn’t based on distance but rather it’s likely a simple multiplier dependent on the row of the attacker.

Either way, a turned based combat game would be cool on Hoscotch.


@HopscotchRemixer What username & title is your project (linked above) published under? I’d like to check it out. After one of the recent Hopscotch updates, forum links to projects quit working.


#11

Oh sorry I have never played Final Fantasy…


#12

OfficialHopscotchRemixer
Beta Testers Only!
I will repost it…


#13


@ThinBuffalo I reposted it.


#14

Looks great so far! I’m looking forward to seeing how it develops :+1:


#15

@BlastFusion he here is some of my more advanced experience with variables! Even ThinBuffalo complimented me about it!


#16

The code I have done is super complex. I can’t even explain it. I can send you a copy of the project when I complete the battling.

Thanks for sharing.


#17

Ok I can check it over then.