# How to make a turn based, monster-catching game like Pokemon or Miscrits?

Attention Topic was automatically imported from the old Question2Answer platform.

I want to make a game using godot like the monster-catching game Miscrits or Pokemon, Can anyone help give me an idea of how to code random encounter to random monsters (for example you look under a rock, you have a chance to encounter a water monster, and the next you get a fire monster), how to code the turn based fighting by picking the move you want to use on your opponent, how to see the unlocked monsters (like pokedex to see which monster you have caught and havent yet) and the chance to catch the monster to be higher when the hp is lower, I hope you guys can help me out!

Hey! i’ve been wanting to “Revive” miscrits for a while now, if you are interested in that too maybe we could try working together! Hmu

Anc | 2020-10-07 04:49

I’m currently learning and building a turn-based RPG like FINAL FANTASY but it still follows similar ideas.

There’s a lot you have to learn, I’m not familiar with how much programming / coding knowledge you have, so I’ll try to explain the logic simply.

For the turn-based system, you’d probably do something as follows.

This would be all the possible states in the battle. You could have more, or less, if you wanted.

``````enum STATES = {
PLAYER,    # Player's turn
ENEMY,    # Enemy's turn
WIN,    # If player wins
LOSE,    # If enemy wins
RUN    # If they RUN from the battle
}
``````
``````var current_state = null
``````

This allows you to change or reference state like this

``````current_state = STATES.PLAYER
``````

Then you may want a function that handles state change and changes the game

``````func _handle_state(new_state):
current_state = new_state

match current_state:
STATES.PLAYER:
pass    # What will happen on player's state?
STATES.ENEMY:
pass    # What will happen on enemy's state?
STATES.WIN
pass    # What will happen on player win?
STATES.LOSE
pass    # What will happen on player lose?
STATES.RUN
pass    # What will happen on player run?
``````

Then you can change the state whenever you want like this

``````_handle_state(STATES.PLAYER)
``````

and the function will handle the change in the game

For a logical point of view, you can think of the game as always the player’s turn unless otherwise stated. So you’d have to create a GUI, learn about signals and building GUIs using the godot docs:

What I do in my game is hide the GUI when it’s not the player’s turn, and show the GUI when it is. The GUI will have buttons that call functions. So you’d probably have buttons like “Move, Item, Run” or something.

As for characters, and a pokedex, you’d probably benefit from storing all possible catchable characters as JSON like this

``````[
{
"id": 1,
"name": "Fire Monster",
"attack": 32,
"defense": 18
},
...
]
``````

You can easily load all your JSON files by making an autoload singleton and structuring it like this

``````var monster_data

var monsterdata_file = File.new()

var monsterdata_json = JSON.parse(monsterdata_file.get_as_text())
monsterdata_file.close()
monster_data = monsterdata_json.result
``````

YourSingleton.monster_data becomes a json array with all the information of your monsters

Since this is structured by monster ID, you can have an array of all IDs of monster that a player has. Then when showing a pokedex you can generate all the monsters and only light up or only show as visible the monsters that are in the player’s “owned” array.

I hope this helped you at least get started. I suggest messing around and building the turn-based battle system first, before worrying about other aspects of your game. Build the game “system by system” and eventually it’ll come together

Good luck!

I remember doing this in python once, python and GDscript are pretty similar so should be easy to port the workflow of a pygame easily. Your answer is a great nudge in right direction.

Wakatta | 2020-08-31 02:35