Template for battles

Is it possible to make a full template event for battles?
What I mean is - I have many battles to set on the map. They all need some dialogue at the beginning, some text after win or after lose and turn a selfswitch. Before the battle processing, I ask the player which one member of his party will fight (he can use only one at a time). The max size of a party is 4. So with that, I have to set the same battle processing 4 times. After loosing, he still has 3 members, so that leads to the fight again and again. You can imagine how big tree that makes.

I'm now working on a 16th battle in my game and I thought... what if I could have one event for all of the battles and just use some variables before that common event to set actual enemies, members , dialogues etc.?
That would speed up my work amazingly. I would have a template to paste every time.
I've thought about the "Designation with a variable" option in battle processing. But I have no idea how to connect a variable with an actual troop.
I feel like I don't see something obvious. That's why I ask.

Maybe there is also a solution to dialogues? Since I have to copy them many times and paste in many places for just one battle.

As always, I'd rather not use any plugins. I believe it can be achieved with logic and basic functions of RM.

Something like this ?
Use Common Events for this. You make the event once, and it can be accessed from anywhere at anytime with the Common Event command.
Use Common Events for this. You make the event once, and it can be accessed from anywhere at anytime with the Common Event command.
I've already said that I want to use it as common event. The main problem is, I don't know how to make a battle processing with a different troop for every battle. That's why I was thinking about a variable, but I don't understand determine a troop with it.

Something like this ?
Not exactly, because the dialogue is different for every battle. It's just used few times in the same event.
So I'm guessing they're touch encounters. You put a common event call before each battle process that goes through the party selection process.

In-battle (turn 0, span: battle), you call another common event that does the battle dialogues.
For in-battle end-battle events before the victory or game over scene, the only way would be to set up a system so enemies are immortal and inflicted death upon reaching 0 HP via an event, and then active the end-battle event when the last enemy dies. Because no new events can be triggered once all enemies are defeated, so it must be within the same event chain, but it can still be within a common event.
I guess this will be your saving grace:

Base Troop Events

Specify which troop will have the eventing you want to copy everywhere else, and it'll read its pages no matter which troop you're fighting in game.
As I've said - I really don't want to use plugins if it's not necessary.

So I'm guessing they're touch encounters. You put a common event call before each battle process that goes through the party selection process.
(...)
That's an interesting idea, but maybe I should show you where was I going with mine :
When you set the battle processing, you can either choose a direct troop or choose a variable (pic 1). A variable here would be the easiest option for me. But I can't see how can I set the variable to the troop ID (pic 2). Is it even possible? If not, why would they make such option?

var1.png


var2.png
No, what it does is use the Troop ID equal to the value of the designated variable. So if the variable is set at 5, it'll battle process Troop 5 in your database. It'd be mostly useful for getting a large selection of random encounters for a battle.
As I've said - I really don't want to use plugins if it's not necessary.
Plugins are not your enemy.
But I can't see how can I set the variable to the troop ID (pic 2). Is it even possible? If not, why would they make such option?
$gameTroop._troopId will return the ID of the troop you're currently fighting against. You can set variables to script values, right under "Game Data". It's visible in the 2nd screenshot.
No, what it does is use the Troop ID equal to the value of the designated variable. So if the variable is set at 5, it'll battle process Troop 5 in your database. It'd be mostly useful for getting a large selection of random encounters for a battle.
Damn! You're right! I think that I have subconsciously rejected that idea, thinking it's too easy to be true. So I was trying other ways...
Thank you!


Plugins are not your enemy.

$gameTroop._troopId will return the ID of the troop you're currently fighting against. You can set variables to script values, right under "Game Data". It's visible in the 2nd screenshot.
I thought about that, but apparently I've found some wrong script (or maybe for older RM version) like this : $gameTroop.members()[id]
Your script works, so thank you also!

When it comes to plugins - I've had some problems at the beginning of working with my game, when I knew nothing about RM and was trying to execute all of my ideas with plugins that were later crushing the game. Now I have only SRD's HUDMaker and I'm not using any beside this one.
And second thing : I have this irrational feeling that somebody might sue me for selling my game with their scripts even if they claim their plugin is completely free to use. (irrational is the key word here).

So we're left with dialogues. If I make common events with the starting dialogue, then another one after winning the battle and after loosing. So let's say dialogue A, B, C. Assuming that they are different for every battle how could I change them every time in a common event? I'd need different face images and texts but I don't think it's achievable with variables.
So we're left with dialogues. If I make common events with the starting dialogue, then another one after winning the battle and after loosing. So let's say dialogue A, B, C. Assuming that they are different for every battle how could I change them every time in a common event? I'd need different face images and texts but I don't think it's achievable with variables.
If you're calling for an encounter against a troop designated by a variable, you'd just have to make sure that variable doesn't change during the battle. At the end, the "win" branch and the "lose" branch each have a variable condition.
Basically, how this would go:
Code:
Set Variable N to X (the troop ID)
Battle processing: variable N
Victory:
    If Variable N = Y:
        Dialogue A
    If Variable N = Z:
        Dialogue B
    etc
Defeat:
    If Variable N = Y:
        Dialogue C
    If Variable N = Z:
        Dialogue D
    etc
You'll probably want the Set Variable command to be right before the line that calls the common event, so you're actually able to start fights with different troops with this common event.
Great! Another two names for "Thank you" section in the credits of my game. If you don't mind of course.

Original thread: https://forums.rpgmakerweb.com/threads/template-for-battles.132034/