r/howdidtheycodeit • u/Dragon20C • Jun 07 '21
How did Pokemon code its actions in the turn phase, e.g status effects, stat changes, change party member
I have been trying to code a pokemon inspired game, but I have reached a stand point where I don't know how to implement the actions that pokemon do, I have a simple turn base system that goes through the enemy and player and checks the speed but I am not sure how to make the actions play in a order and have it check for things like fainted etc.
Edit: engine of choice is godot.
Edit 2#: how do I make the sorting and play actions at a specific time?
51
Upvotes
18
u/theotherdoomguy Jun 07 '21
Giving a engine agnostic answer
Queue - what you want is a queue. Have an if to queue up priority actions, then queue regular actions and another if afterwards for status effects.
You now have an order of actions you want to occur in the right order, start plucking them from your queue and do them until the queue is empty, that's one round done
11
u/jimmyMFwise Jun 07 '21
Not sure what you're making it in, but this might be helpful.
pokemon YouTube series
5
u/SickMoonDoe Jun 07 '21
Pokemon Go or the Gameboy games?
PoGo is more complicated because it's turns are time based not input based ( if you don't choose an action your "turn" is skipped and 120 turns occur per second, while in the Gameboy games your opponent has to wait until you make a decision ).
3
u/ACheca7 Jun 07 '21
Can’t you add this with simple ifs? Genuine question, haven’t done this myself but I’d firstly add some bools and change the stats if those bools are true/false. And change party member would also just be change the object of the Pokemon with another object, if you’ve done it in an object oriented language.
16
u/Dragotic-PS Jun 07 '21
Pokemon-Showdown's source code is open-source. I'd recommend checking that out and working your way through. (All JS though)
2
u/Thundernerd Jun 07 '21
I could think of some ideas on how I would do it but no idea if that’s how they did it.
You could always take a look at these decompilation projects on GitHub by Pret (it’s pretty interesting IMO!)
The older ones are in assembly so they’re harder to understand but the one I linked is in C. The battle_main file would be my personal starting point to check out :)