View Full Version : Turn Based Battle System How To.
Originally Posted on Doans.
I decided, as this is a better Idea to just explain how it works. Instead of releasing a file, and people not understanding what does what, trust me im a huge culprit for this. I use to just use engines and not understand how it worked, but now with help from Nathan, and Vespuleth, I managed to create my own Turn Based battle system, now please remember, this is just the basis, once you get the basis down, your pretty much set. So starting out.
Turn Based Battle System Structure
Scripts:
OrderCheck
Master Battle Script
P1 Turn
P2 Turn
P3 Turn
E1 Turn
E2 Turn
E3 Turn
P1 Attack E1 (repeat till E3)
P2 Attack E1 (repeat till E3)
P3 Attack E1 (repeat till E3)
E1 Attack P1 (repeat till P3)
E2 Attack P1 (repeat till P3)
E3 Attack P1 (repeat till P3)
Victory/Loss (checks to see whos dead, and if to show victory or loss)
Target Check (see who and can be attacked at the time)
Slime AI
Treant AI
Fairy AI (These are just graphics I used to represent E1-E3)
Events:
P1
P2
P3
E1
E2
E3
MASTERBATTLE
Vars:
P1 HP
P1 MAX HP
P1 MP
P1 STR
P1 AGI
P1 TURN
P2 HP
P2 MAX HP
P2 MP
P2 MAX MP
P2 STR
P2 AGI
P2 TURN
P3 HP
P3 MAX HP
P3 MP
P3 MAX MP
P3 STR
P3 AGI
P3 TURN
E1 HP
E1 MP
E1 AGI
E1 STR
E1 TURN
E2 HP
E2 MP
E2 AGI
E2 STR
E2 TURN
E3 HP
E3 MP
E3 AGI
E3 STR
E3 TURN
Attack type?
Party Turn Var
Phew what a mouthful eh? Lets get started shall we?
Order
To start your gonna need to make a new file, make it on hard, so that way you have more resources, if you would prefer to have it on easy for all the presets, thats fine, just make sure to change it to hard afterwards.
Make a new script called:
Order, it should look like as follows:
DATA:VAR:P1 TURN=P1 TURN+ P1 AGI
DATA:VAR:P2 TURN=P2 TURN+ P2 AGI
DATA:VAR:P3 TURN=P3 TURN+ P3 AGI
DATA:VAR:E1 TURN=E1 TURN+ E1 AGI
DATA:VAR:E2 TURN=E2 TURN+ E2 AGI
DATA:VAR:E3 TURN=E3 TURN+ E3 AGI
(
This will basically add agi to each participants 'turn' variable. Whoever hits 100 (or any number you choose) first will then act! Once acted, the turn variable will be deducted 100 (or any number.)
(start with enemies conditions first, as they are the ones attacking in the first place.)
SCRIPT BRANCH CONDITION: E1 TURN >= +100
SCRIPT CALL: [E1 TURN]
WAIT FOR SCRIPT END
E1 TURN= E1 TURN-100
SCRIPT CALL: [VICTORY/LOSS]
SBE
Repeat for E2 and E3
.
.
.
SCRIPT BRANCH CONDITION P1 TURN >= +100
SCRIPT CALL: [P1 TURN]
WAIT FOR SCRIPT END
SCRIPT CALL: [VICTORY/LOSS]
P1 TURN=0+0
SBE
Repeat for P2 and P3
This is how we check to see who goes when. Its all time based, all rights to this method belong to Nathan.
Master Battle Script/Turn Scripts
Now that we have the order its time to start our Master Battle Script as well as our Turn scripts since thats pretty much the very core of the system. So starting out, our Master Battle Script would look something like this.
Sound BGM[Whatever you would like]
Screen Camera: Rotate: N, or you can change it to whatever you would like. I prefer either NE or NW.
script: call [Load Party Stats]
script call [Load Enemy Stats]
(This is where the battle DOES NOT end untill some sort of goal is reached, whether it be success or failure.)
Script Branch Repeat: Flag Fixed (0ff)=off
Script Call: [Order]
Script Branch End.
Now save that script, and make it a System event, and enter that event into your battle field Enter Map slot. This is gonna make the battle not end untill you've either died or won. Next we explain what the [Load Party Stats] and [Load Enemy Stats] means. Its really simple actually, here is how your script(s) should look like.
[Load Party Stats]
P1 HP=130
P1 AGI=8
P1 MAX HP=130
P1 MP= 13
P1 MAX MP= 13
P1 STR= 6
.
.
.
Repeat up for P2 and P3 adjust to whatever you see fit.
Now that we have loaded the Party Stats in the battle, we need to load the stats for our enemies. Its the exact same process so pretty much copy and paste the [Load Party Stats] script and edit accordingly. Now that we have our stats, and we have our Order to see who goes when. Its time for actual turns.
Now use this guide for idea of how it should look, please remember you can customize this fully once you get the basis of it.
E1 E2 E3
P1 P2 P3
This is how these scripts will function for the example. The Players and Enemies are exactly 4 spaces away from each other, and one space in between each combatant. Ok continuing right along.
a basic P1 Turn will consist of Setting the HP, and other core stats. Checking to see what enemy can be hit ( also know this is only designed with one attack).
So Our Script will look similar to this.
[P1 TURN]
Party Turn Var=1
Screen Content: Var[P1 HP]
Screen Message : "/" uncheck close message window
Screen Content: Var[P1 Max HP]
Screen Message: "press enter then uncheck the window again."
Screen Content: Var[P1 MP]
Screen Message: "/" uncheck close message window.
Screen Content: Var[P1 MAX MP]
Input Multiple Choice 20, 21 "Attack"
Script Branch Condition: User Choice =+1
Script Call [Target Check]
Script Branch End.
Party Turn Var=0
Ill explain what the Target Check contains, tomorrow, right now I need to give this guide a rest.
Now comes the fun part. Target checking. Let me type the script and then I shall explain it a little better.
Target Check
I have made a sample video as to how this actually works, the VFX should be simple for you to add so I will not include it.
NRRgm8n3u8g
Now we need to check all possible combos for the three enemies that we have to choose from.
So basically it should look like so.
E1 HP >= 0 (If E1 HP is greater than 1)
E2 HP >= 0 (If E2 HP is greater than 1)
E3 HP >= 0 (If E3 HP is greater than 1)
Input Multiple Choice: "1,2,3" (E1=1,E2=2,E3=3)
User Choice=1
[Sort Attack E1]
Wait for script end
SBE
User Choice = 2
[Sort Attack E2]
Wait for script end
SBE
User Choice= 3
[Sort Attack E3]
Wait for Script End
Script Branch End
Script Branch End
Script Branch End
Script Branch End
For an example of
[Sort Attack E1]
Sort: Player Turn Var
Apply if 1
Script call: [P1 Attack E1]
Wait for script end
To End
Apply if 2
Script call: [P2 Attack E1]
wait for script end
To End
Apply if 3
Script call: [P3 Attack E1]
Wait for script end
To End
Script Branch End
Edit accordingly for [Sort Attack E2] and [Sort Attack E3]
Now the next few combinations (1,2) (1) (2) (3) (1,3) (2,3) should be the same process as above.
Since there is only one attack this target system will need additional checks for additional type attacks, for example, only e1 and e2 are alive at the time being, your selection would only be (1,2) since E3 is not alive, or not visible at the time.
Next its time to explain Attacks on certain enemies as well as AI for our enemies.
Enemy Ai/How to Attack
Here comes one of funnest things to do in my complete and honest opinion, first we will start with the AI. Basically we need to figure out how each graphic would behave in battle, For example, a Slime is more likely to expand since it is somewhat gelatinous, so a "Goo expand" type attack would work. Now lets say we use the Treant, realistically it wouldn't attack with say a sword or whatnot, Since it is made from wood, it more than likely do a pound, or some sort of throwing dirt, as well as some sort of earthy type move. And then comes our fairy, since she is floating, her main attacks shall and will be aerial, so she will either have some sort of wing attack, an attack where she grabs you and drops you from X height and junk. Ok back to the ai, to start lets work with Slime AI.
Make a new variable name it [Random]
[Slime AI]
If E1 HP>=10 (if slimes HP is 10 or greater, we are gonna call the regular attack)
Random=1?3(This is gonna randomize how the enemy decides to attack, which player, 1 being P1, 2 being P2, and 3 being P3.)
Sort [Random]
Apply if 1
[E1 Attack P1]
Wait for script end
To End
Apply if 2
[E1 Attack P2]
Wait for Script end
To End
Apply if 3
[E1 Attack P3]
Wait for script end
To End
Sbe
Sbe
If E1 HP<=9 (If Slimes HP is less than 10, we change the attack to something more aggressive.)
Sort [Random]
Apply if 1
[E1 Aggro P1]
Wait for script end
To End
Apply if 2
[E1 AggroP2]
Wait for Script end
To End
Apply if 3
[E1 Aggro P3]
Wait for script end
To End
SBE
SBE
Aggro meaning, Aggressive, the enemy shall attack with a whole lot more damage, since its using its very last ounce of energy to kill you and your party. Now you may say, "What happens if P1 is dead, and the Random is on 1?" Well at the very top of the P1 Turn script, Make the following variables, P1 State, P2 State, P3 State. then we insert,
If P1 State=1 (1=death, 2= paralysis, 3= poison, 4= numb, 5= confusion. Please note, the states don't have to necessarily be all that, its just what im using for the example.)
Force Script End
SBE
Repeat the same for P2 and P3.
That should say, if P1 is dead, it will skip 1, and should go straight to to and 3, and so on and so forth.
Now that we know when to attack, lets find out how we are gonna actually attack our Players. Now please note, the attack scripts are by far the easiest of the scripts so far to use, so im only gonna use one example, if you can't figure out how to make more from this example, then your not ready for a CBS, and you need to familiarize yourself with the system again.
Continuing, this example show here:
E1 E2 E3
P1 P2 P3
This is saying each combatant opposing each other is 4 spaces exactly. This is a great way to do find out what movement needs to done. Lets say for example P1 needs to get to E1, P1 will go straight N (4) steps forward, initiate the attack effect, take away enemy damage, display enemy damage. Now lets say I would want to attack E2, I have many routes to choose from. You can go NE 3 then N 2 spaces, or N 2, and NE 3, either way its the same combo, just reverse the order, So SE 3, S 2, would reset our position. This concept is the exact same for Enemies as well.
Next we will go into attacking detail.
Hipparchus
07-12-2009, 10:50 PM
Hooray for RealityBites! This is very helpful, and its very nice you didn't keep this system to yourself. Thank you very much, I will be experimenting with this system tonight and see how it goes. :happy If my game has this system I will credit you for sure!
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.