How do I make Army vs Army?

Is there a relatively easy way to do an army vs an army?


By this I mean, you can recruit men, ogres, skeletons, etc. Into your 'army' then a group fight them and there is a % chance of you winning/losing obviously depending on the strengths of each army.


So lets say it's 300 vs 500, is there a quick way for me to generate a % chance of winning/losing? It's for a project where you amass an army to defend your castle with momentary battles happening while you're gone, I.E you come back and its like "You were attacked while you were gone by 100 whatever." and it then works out whether you won or lost based on the differences of power.
Are you talking about a single battle that happened, where there is one outcome?  Or multiple battles, where there could be a different outcome for each battle?  



How will you determine the strength of each army?


Something like this would work (I'm making a few assumptions here):

Code:
# Setting up party strength (size?)
Control Variables: 1 (Ally Strength) = 300
Control Variables: 2 (Enemy Strength) = 500

# Determine combined strength
Control Variables: 3 (Total Strength) = Variable 1 (Ally Strength)
Control Variables: 3 (Total Strength) += Variable 2 (Enemy Strength)

# Who won?
Control Variables: 4 (Random Number) = Random (1 .. Variable 3 (Total Strength))
If Variable 4 (Random Number) <= Variable 1 (Ally Strength)
  Control Switches: 1 (Winner) = ON
Else
  Control Switches: 1 (Winner) = OFF
End

So you're just getting a random number based on the strength of both sides combined, and compare it with your team's strength.  It favours the stronger team, but still gives the weaker team a chance to win.  The greater the difference between team strengths, the more likely it is that the stronger team will win.


The above assumes a single battle.  How you set up the first two variables might be different - variable 1 (ally strength) will be adjusted as you recruit fighters.  Variable 2 (enemy strength) could be a random number, or you could have a different method of setting that value.
Are you talking about a single battle that happened, where there is one outcome?  Or multiple battles, where there could be a different outcome for each battle?  



How will you determine the strength of each army?


Something like this would work (I'm making a few assumptions here):

Code:
# Setting up party strength (size?)
Control Variables: 1 (Ally Strength) = 300
Control Variables: 2 (Enemy Strength) = 500

# Determine combined strength
Control Variables: 3 (Total Strength) = Variable 1 (Ally Strength)
Control Variables: 3 (Total Strength) += Variable 2 (Enemy Strength)

# Who won?
Control Variables: 4 (Random Number) = Random (1 .. Variable 3 (Total Strength))
If Variable 4 (Random Number) <= Variable 1 (Ally Strength)
  Control Switches: 1 (Winner) = ON
Else
  Control Switches: 1 (Winner) = OFF
End

So you're just getting a random number based on the strength of both sides combined, and compare it with your team's strength.  It favours the stronger team, but still gives the weaker team a chance to win.  The greater the difference between team strengths, the more likely it is that the stronger team will win.


The above assumes a single battle.  How you set up the first two variables might be different - variable 1 (ally strength) will be adjusted as you recruit fighters.  Variable 2 (enemy strength) could be a random number, or you could have a different method of setting that value.



I understood what to do up until Control Variables: 4 (Random Number) = Random (1 .. Variable 3 (Total Strength))  there isn't a = random for a batch of variables. Could you please elaborate, because looking at the rest i'm sure it will work for what I need.
No, you're not doing a batch change - you're changing the variable that you'll call Random Number TO a random number between 1 and variable 3.  Look down below the operators - one of the options there will be Random and you'll be able to enter a start and end value.


Ah, what a pain - it doesn't allow you to use variables as the range.  In that case, do Control Variables and select your Random Number variable.  Then put this in the Script box:


rand($game_variables[3])


but change 3 to whatever variable you're using for Total Strength.
It works. Thank you very much for your help. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-army-vs-army.72739/