I am making a turn-based RPG game in UE5 with C++ (with 2D sprites). Think of something like Darkest Dungeon but with memes and no procedural generation. For the most part my combat system works, but sometimes the turn triggers for an allied character that isn’t even in the party (another ally performs their attack) and sometimes the turn triggers for two allies at once - when one attacks, the other does too, same with using an items.
For my allies I have two arrays - AlvailableAllies that stores all allies regardless of whether they’re in the party or not and AlliedParty - the actual party.
For fight encounters I have an actor class - AFightEncounter that spawns enemies and deals with what happens after the fight and a regular object UFight that is created when the fight is started and handles the fight itself.
I’ve tried debugging - looks like StartTurn() (and Use Item() as well when we choose to use an item) is called twice for different allies, I suspect it might be ralated to my timers - one that introduces a bit of delay between turns, the other that prevents the enemy from being stuck on their turn when they can’t use any skill. I honestly don’t have any idea what to do about it.
Here’s the code on pastebin, because I don’t know if there’s a character limit here:
If it’s not very readible lket me know if i should split each source file into separate link. Thank you in advance.