2DRPG: How to have a party in combat?

I want to be able to have multiple party members during combat like chrono trigger or persona for example. I’ve been following a template series by Gamedev Experiments on making a pokemon style game. I got the combat down, I just wanna be able to use multiple party members while in combat.

I have multiple c# scripts all for the hud, player and enemy units, and the battlesystem. Any advice would be helpful. I’ve attached just a handful of files below to show my code. Apologies if this isnt the best place to put this.

9635168–1369193–BattleDialogBox.cs (2.36 KB)
9635168–1369196–BattleHud.cs (854 Bytes)
9635168–1369199–BattleSystem.cs (6.5 KB)
9635168–1369202–BattleUnit.cs (2.05 KB)

If you have a fully working 1vs1 pokemon style game, then it shouldn’t be hard to convert it to a party based combat, you just have to replace every “pokemon” with a list of party members and then every turn you have to decide which of these members should act on the current turn, for example a simple index variable which you increment every turn.

1 Like

Ahhh okay. First I do wanna thank you for taking the time to reach out and answer my question. With that I just have 1 question going about that. When you say replace “pokemon” or in my case “player” in a list like where I can store my characters? or code out separately every “pokemon” with multiple pokemon with its own code.

I tried adding a “player2” to the scripts, such as updating its HUD and adding it as a player unit, but that was under the same code. I was thinking if they were both considered “PlayerUnit” they would be able to use the same attack and turn script. Maybe its something I could continue working on if it works.

I recommend using a list for combatants.

There’s no reason to have variables called “Player1” and “Player2” and fill your scripts with all sorts of duplicate code.

With a list you can refer to players as Player[0], Player[1], Player[2], but the power comes in when you replace the number with an int variable. You can write the code once and it can apply to any player on the list.

1 Like

Adding onto the great stuff already posted by kdgalla and R1PFake above…

Be sure to answer critical questions like what “party combat” means.

If you currently have 1 attacking 1, what happens with 1 attacking 3?

Does the attack focus on only one of the three targets? Or all of them?

How does an attacker choose targets?

  • they choose and pick
  • their attack always hits the guy in front
  • something else??

What about 2 attacking 3? Can both attack at the same time? How does each one choose targets? How do you choose targets? Weakest? Strongest? Most-damaging? The player has to choose? What does that user interface look like? Does it do something special if they do? Or are there just two separate turns taken? Or are the turns simultaneous?

The answers to these questions matter greatly when you go to decide how to structure things.

And yes, get very very very comfortable using collection (such as arrays or List) types. No sense rewriting all the code twice when you have two players! Collections allow a single piece of code to be iteratively applied to many different things.