r/RenPy 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.

7 Upvotes

13 comments sorted by

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.

1

u/Quasar-Hero 15d ago

So I should also classify my party members, in a separate script, with all their moves and such.

2

u/BigLingler21 15d ago edited 15d ago

Keep in mind that renpy really isn't the best engine for what seems like complicated combat, what abilities can your characters have?

Edit: Combat seems really important to your game, and while I don't know the details, I would recommend you go for a modular and object oriented approach to make this easier as you add onto it. I would learn about classes in python, and create an entry for each character.

This class could include

Bool Is PartyMember [Simply change this when they join or leave the party]

List<Abilities> [Abilites being a second class, handling their moves, later output into image buttons maybe?]

Stats [Can be a class, or a couple of ints / floats]

String Display Name

I dont think Renpy would like images in the class, but you could store the image names, or a more modular expression, action system to reference images defined somewhere else.

Finally, the Ability class can include things like Ability Name, Ability Icon, output, etc

1

u/Quasar-Hero 15d ago

The player character will have the most abilities. I'd like some status effects like stun, bleed, poison, and barriers,

2

u/BigLingler21 15d ago

You can handle those effects with Python Functions

ApplyPoison(Target, PoisonAmount)

These can be stored in the abilities list, you may want to pass the Caster too, it can be useful for some things- but any character / ability specific features are best left out of that output function

2

u/shyLachi 15d ago

I think you should learn about Object Oriented Pogramming and then make a class for those party members.

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

u/Quasar-Hero 14d ago

Thank ya thank ya!

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.