Godot Version
4.3
Question
Hello there (: so I’m learning GDScript and making something like a rpg dungeon crawler and I have to make the ‘Turn System’ for combat.
So first I thinked of having a turn handler and while combat is on depending on who should play (player or npc) call their respective player_turn or npc_turn functions but this will lead in calling multiple times the player_turn since waiting for the player input on what actions take would take longer than running the npc script.
So I want to avoid this behavior since it doesn’t feel right, maybe it is (if that’s the case it would be awesome to know)
Then I had the idea of using some custom signals, and should be something like this:
- Combat starts
- First turn is decided (let’s assume player go first)
- Player takes his time to decide what to do
- When player is out of actions to do in his turn or skips the turn emit a signal to npc turn
- Npc turn is scripted so it will be linear in execution
- emit a signal to player turn
So far this looks great but I’m not sure about the next thing, when I emit a signal the function where this signal comes from keeps hanging until the reception function ends their execution?
I know I made a long post to make a simple cuestion but anybody have a different approach to solve this system is also appreciated, thanks and a have a nice day