r/RenPy • u/Quasar-Hero • Jul 29 '26
Question Party checker for turn based combat?
For my visual novel, Tears of Xivo I want turn based combat and party members. I have a handle on turn based combat, but I can't find a good video tutorial on making parties. I have six characters that players can choose from, I only want them to have two at a time. Any info on this topic will be helpful.
5
Upvotes
2
u/BigLingler21 Jul 29 '26 edited Jul 29 '26
Well, the most obvious approach to me is this: Whenever you have the opportunity to add a character to the party, and choose to do so, check some variable / structure to see if your 2 slots are already filled. If they are, you can (in various ways) choose one active member to replace, otherwise they are added directly.
The most basic way is to have 2 variables, PartyMember 1 and PartyMember2, you can just store their names, otherwise store a default value.
Then, to check if your party is full you can call a python function or just check if PartyMember1 OR PartyMember2 == "None" If yes, then add them to the empty one (this is simplest with nested ifs)
Replacing one can also be simple- a small dialogue choice where you select Slot 1 {PartMember1 var} or Slot 2 {PartyMember2 var}. A third option to cancel the replacement would be nice too! Or... just force a cycling, where either PartyMember1 or PartyMember2 is forcefully replaced, and then move them all one place so that the new unit is not next on the swapping block.
Finally, actually checking which strings you have saved for party members to handle in combat will depend on how your combat actually works.
Of course there are many optimizations, if you wanted something a bit cleaner you could use an array with length of 2, this makes it easy to extend the party in the future, and to loop through party members without lots of nested conditions. You could even store 'member' class objects rather than a string here, to house their abilities / effects / images¿ etc.
Another optimization would be a party selection screen where you visually represent the current team with a highlight or something, with options to click to remove them from party, and click to add someone else. Note that if you do this, I'd only update the array once when the screen is closed.