Real-Time Battle System Part 1
Article
A real-time battle system with no scripting!
Heh... it feels odd being the first to write an RMXP tutorial, but here it goes....
This is going to go into how to make a real-time battle system, where your character encounters enemies that move and fight, while you move around, avoiding attacks and fighting back. There are four parts I will cover, and this tutorial covers part one.
Part 1: Melee attack:
This is the coding for the basic attack. A swing of the sword, a flying fist, whatever! This will take two different events.
The first is a common event. Set it to a parallel process to a switch. Call this event "Melee attack", and the switch "Sword1". Also make a variable called "attackON", and a second switch called "swordON".
@>Button Input Processing:
@>Conditional Branch: Variable ==16
@>Control Switches:=ON
@>Set move route: Player (Ignore if can't move)
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>SE:'064-Swing03', 80, 130
: :$>1 Step Forward
: :$>Change Speed: 4
: :$>Change Freq.: 4
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:=0
@>
:Branch End
What this does is make it so that when you press D, your player moves forward one space quickly, making the sound of a sword swing. To add more detail, make an animation of a sword swinging. To do that, import the picture of a sword into the animations folder. Make it fit in a 192X192 pixel block. Then go to the animation editor and make each animation of the swinging sword. I am not good at explaining this part, but basically, make 4 animation files. On each one, make three frames. The first frame has the sword at a positive 45 degree angle from where the player is facing, the secon frame has the sword facing where the player is facind, and the third is a negatice 45 degree angle. Then set the above code under conditional branches for each direction the player is facing, adding the animation code just before the move event. I'll show a sample using the same switches and variables. The animations will be called "attackUP", "attackLEFT", "attackRIGHT", and "attackDOWN".
@>Button Input Processing:
@>Conditional Branch: Variable ==16
@>Control Switches:=ON
@>Conditional Branch: Player is facing Down
@>Show animation: Player,
@>Set move route: Player (Ignore if can't move)
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>SE:'064-Swing03', 80, 130
: :$>1 Step Forward
: :$>Change Speed: 4
: :$>Change Freq.: 4
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:=0
@>
:Else
@>Conditional Branch: Player is facing Left
@>Show animation: Player,
@>Set move route: Player (Ignore if can't move)
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>SE:'064-Swing03', 80, 130
: :$>1 Step Forward
: :$>Change Speed: 4
: :$>Change Freq.: 4
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:=0
@>
: Else.....
You get it.
Next, make sure that the switch "Sword1" is activated from the start, or this code will not work. Finally, the enemy. The enemy will consist of three event pages. Page one sets the enemy's HP. It is a non-conditional parallel process. Make a new variable. Call it "EnemyHP1".
Page 1:
@>Control Variables:=10
@>Control Self Switch: A=ON
@>
This sets the enemy's HP to 10.
Now for the most complicated part of the code. I actually got help from Melch on this part, so I'll be sure to add in what I originally did wrong. If anybody want to try and edit this code, then heed this warning. DO NOT MAKE THIS A LOOP OR IT WILL FREEZE THE GAME!!!!!!
Anyway, this code works fine. It is an event touch trigger that activates when self switch A is on.
Page 2:
@>Conditional Branch: Switch ==ON
@>Show Animation: This event,
@>Set Move Route: This event (ignore if can't move)
: :$>Move Animation OFF
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>1 Step Back
: :$>Change Speed: 4
: :$>Change Freq.: 4
: :$>Move Animation ON
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:-=1
@>
:Else
@>Show Animation: Player,
@>Set Move Route: Player (ignore if can't move)
: :$>Move Animation OFF
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>1 Step Back
: :$>Change Speed: 4
: :$>Change Freq.: 4
: :$>Move Animation ON
@>Wait for move's completion
@>Change HP: Party, -1
@>
:Branch End
@>Conditional Branch: Variable ==0
@>Control Self Switche: B=ON
@>
:Branch End
@>
This sets the fact that if your character is swinging his sword when touching the enemy, then the enemy takes damage. Otherwise, your character takes damage. The movement is set to look like the target is being knocked back. The end links to the final page, for when the enemy is dead. Make some kind of animation for this, and call it "dead". This can be anything. This page is a parallel process, conditional to self switch B.
Page 3:
@>Show animation: This event,
@>Erase Event
@>
On this last page, set the event graphic to nothing. If you want the enemy to stay dead, activate a switch on page 3, then make a page 4 with no coding or graphic that is conditional to that switch.
Long, I know.
Next up, Part 2: Ranged weaponry
This is going to go into how to make a real-time battle system, where your character encounters enemies that move and fight, while you move around, avoiding attacks and fighting back. There are four parts I will cover, and this tutorial covers part one.
Part 1: Melee attack:
This is the coding for the basic attack. A swing of the sword, a flying fist, whatever! This will take two different events.
The first is a common event. Set it to a parallel process to a switch. Call this event "Melee attack", and the switch "Sword1". Also make a variable called "attackON", and a second switch called "swordON".
@>Button Input Processing:
@>Conditional Branch: Variable ==16
@>Control Switches:=ON
@>Set move route: Player (Ignore if can't move)
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>SE:'064-Swing03', 80, 130
: :$>1 Step Forward
: :$>Change Speed: 4
: :$>Change Freq.: 4
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:=0
@>
:Branch End
What this does is make it so that when you press D, your player moves forward one space quickly, making the sound of a sword swing. To add more detail, make an animation of a sword swinging. To do that, import the picture of a sword into the animations folder. Make it fit in a 192X192 pixel block. Then go to the animation editor and make each animation of the swinging sword. I am not good at explaining this part, but basically, make 4 animation files. On each one, make three frames. The first frame has the sword at a positive 45 degree angle from where the player is facing, the secon frame has the sword facing where the player is facind, and the third is a negatice 45 degree angle. Then set the above code under conditional branches for each direction the player is facing, adding the animation code just before the move event. I'll show a sample using the same switches and variables. The animations will be called "attackUP", "attackLEFT", "attackRIGHT", and "attackDOWN".
@>Button Input Processing:
@>Conditional Branch: Variable ==16
@>Control Switches:=ON
@>Conditional Branch: Player is facing Down
@>Show animation: Player,
@>Set move route: Player (Ignore if can't move)
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>SE:'064-Swing03', 80, 130
: :$>1 Step Forward
: :$>Change Speed: 4
: :$>Change Freq.: 4
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:=0
@>
:Else
@>Conditional Branch: Player is facing Left
@>Show animation: Player,
@>Set move route: Player (Ignore if can't move)
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>SE:'064-Swing03', 80, 130
: :$>1 Step Forward
: :$>Change Speed: 4
: :$>Change Freq.: 4
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:=0
@>
: Else.....
You get it.
Next, make sure that the switch "Sword1" is activated from the start, or this code will not work. Finally, the enemy. The enemy will consist of three event pages. Page one sets the enemy's HP. It is a non-conditional parallel process. Make a new variable. Call it "EnemyHP1".
Page 1:
@>Control Variables:=10
@>Control Self Switch: A=ON
@>
This sets the enemy's HP to 10.
Now for the most complicated part of the code. I actually got help from Melch on this part, so I'll be sure to add in what I originally did wrong. If anybody want to try and edit this code, then heed this warning. DO NOT MAKE THIS A LOOP OR IT WILL FREEZE THE GAME!!!!!!
Anyway, this code works fine. It is an event touch trigger that activates when self switch A is on.
Page 2:
@>Conditional Branch: Switch ==ON
@>Show Animation: This event,
@>Set Move Route: This event (ignore if can't move)
: :$>Move Animation OFF
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>1 Step Back
: :$>Change Speed: 4
: :$>Change Freq.: 4
: :$>Move Animation ON
@>Wait for move's completion
@>Control Switches:=OFF
@>Control Variables:-=1
@>
:Else
@>Show Animation: Player,
@>Set Move Route: Player (ignore if can't move)
: :$>Move Animation OFF
: :$>Change Speed: 6
: :$>Change Freq.: 6
: :$>1 Step Back
: :$>Change Speed: 4
: :$>Change Freq.: 4
: :$>Move Animation ON
@>Wait for move's completion
@>Change HP: Party, -1
@>
:Branch End
@>Conditional Branch: Variable ==0
@>Control Self Switche: B=ON
@>
:Branch End
@>
This sets the fact that if your character is swinging his sword when touching the enemy, then the enemy takes damage. Otherwise, your character takes damage. The movement is set to look like the target is being knocked back. The end links to the final page, for when the enemy is dead. Make some kind of animation for this, and call it "dead". This can be anything. This page is a parallel process, conditional to self switch B.
Page 3:
@>Show animation: This event,
@>Erase Event
@>
On this last page, set the event graphic to nothing. If you want the enemy to stay dead, activate a switch on page 3, then make a page 4 with no coding or graphic that is conditional to that switch.
Long, I know.
Next up, Part 2: Ranged weaponry
Comments
InfiniteSeraph 10/17/08 10:21 AM
Double-Post:
I'm gonna teach everyone how to innovate CBS's soon! Easy-to-understand tutorial coming soon from moi!!
I'm gonna teach everyone how to innovate CBS's soon! Easy-to-understand tutorial coming soon from moi!!
InfiniteSeraph 10/17/08 10:20 AM
This is a nice ABS.
As a side note, I don't think you need to have an else parameter when making a parallel process common event like this. It would basically move on to the next condition if the first one isnt met, and if nothing is met, then nothing happens.
Having else parameters confuses the game into executing the else if the first isnt true, and it can cause unnecessary nested forks.
As a side note, I don't think you need to have an else parameter when making a parallel process common event like this. It would basically move on to the next condition if the first one isnt met, and if nothing is met, then nothing happens.
Having else parameters confuses the game into executing the else if the first isnt true, and it can cause unnecessary nested forks.
Seribr0 06/25/08 10:44 PM
Hi,I'm a very lousy programer but still want to use this in my RPG project.
Could anyone send me a RPGproject without any imported files to me?
I cant seem to figure out where to set the@button input prossecing thing.
Could anyone send me a RPGproject without any imported files to me?
I cant seem to figure out where to set the@button input prossecing thing.
Zeldafan9577 06/25/08 03:59 AM
Took me a while but i finnally understood it except i didn't use a sword just punching
Quiversee 02/03/08 02:04 AM
Actually, around Feb. 13, I will have a demo of a better version of this. A little after, I'll submit another tutorial and will "update" this one with it.
But I do have a ready to play demo of this version, if you're interested.
But I do have a ready to play demo of this version, if you're interested.
Quiversee 02/03/08 02:03 AM
Actually, around Feb. 13, I will have a demo of a better version of this. A little after, I'll submit another tutorial and will "update" this one with it.
Infinite Games 01/28/08 09:29 AM
Do you have a demo of this? If not that would be a good idea.
Quiversee 11/09/07 07:56 PM
ok, action battle. Whatever you call it. I call it real time because it isn't turn based like the standard RMXP battle system. Still, it works.
Tsuichi Rin 11/09/07 07:25 PM
this isn't real time ;o... its action battle...
Add Comment
You must be logged in to comment.
Home
