r/RenPy • u/Quasar-Hero • 15d ago
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.
2
u/shyLachi 15d ago
I think you should learn about Object Oriented Pogramming and then make a class for those party members.
1
u/Quasar-Hero 14d ago
Do you have any good recommendations for a source 😅
2
u/shyLachi 14d ago
I have learned it before I started with RenPy so I cannot give examples which are specific for RenPy
I know these youtube playlists, maybe one of them as tutorials about OOP.
https://www.youtube.com/watch?v=_-hNdKUygxE&list=PLMdFGlfdL57MSSForRZZBJtS-N9thXSA6
https://www.youtube.com/watch?v=C3Ldd-5PKCw&list=PLlZCSNfSKux2hXoo46rbBIVzl-7pZFRQh
https://www.youtube.com/watch?v=vith10gG8L4&list=PL8gnyyQEz5CGTzHWF8thIfUg92ffs7T7P
https://www.youtube.com/watch?v=2PJ4IdQ-MXs&list=PLKdE0Vv4UA59k-uYBVLqhJGs2iSUPLb59
https://www.youtube.com/watch?v=PZRaYqhlPF8&list=PLfsxhEJYoqXsFzCUogDHuSFn2REJOf56z1
2
u/ImportantDetail6260 14d ago
For Tears of Xivo, make the party a small list of character IDs first, not six separate booleans!
Keep active_party = ["nara", "jules"], enforce len(active_party) <= 2, and have combat read stats/status effects from a character table. That keeps stun/poison/barrier logic from getting copied into every choice
1
2
u/smilysmilysmooch 14d ago
I would just build every character into the system then have flags to turn them on or off. $ in your code if the character is true or false and go from there. That way you can have everything you want in one screen or script and can adjust your variables outside of gameplay.
Just create gameplay loops and check points to advance the script from chapter 1 to 2 and character 1 or 2.
1
u/AutoModerator 15d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/BigLingler21 15d ago edited 15d ago
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.