0 votes

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!

in Engine by (12 points)

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

1 Answer

+2 votes

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:

Signals - https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html

GUI - https://docs.godotengine.org/en/stable/tutorials/gui/index.html

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

func _ready():
    var monsterdata_file = File.new()
    monsterdata_file.open("res://your/path/to/json", File.READ)

    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!

by (39 points)

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.

Glad to help!

You seem to be pretty knowledgable with making a game similar to old-school Final Fantasy titles or pokemon. Is there a good resource or book (yes I know it also counts as a resource) that can teach me states, incorporating JSON data, and anything else involved with creating an RPG?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.