REAL-TIME BATTLE SYSTEM PART 1

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

Posts

Pages: 1
this isn't real time ;o... its action battle...
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.
Do you have a demo of this? If not that would be a good idea.
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.
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.
*Sorry about double post. Computer lag*
Took me a while but i finnally understood it except i didn't use a sword just punching
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.
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.
Double-Post:

I'm gonna teach everyone how to innovate CBS's soon! Easy-to-understand tutorial coming soon from moi!!
umm please hurry on the ranged weaponry and dont forget skills!
Double-Post

What does the number 16 have to do with anything?
Isn't a switch enough?
Also, if you reduce HP by 1 it would take years to die in this battle system.
You could just give the player 5 HP points and there you go super easy.

I did this the same exact way almost, except I incorporated a second player and also a difficulty setting.

Yay me.
Does this script work on RPG maker VX? (Sorry Noob here)
@artas_frost it is not a script, it is an event system. And yes, it works with VX.
I tried doing this with a ghost, and the attacking for me worked, but didn't do any damage, just did a little animation and then the ghost kind of just did a lot of animations while running into the wall and disintegrating leaving me shocked like wtf just happened. Can you care to make a demo, since I obviously don't know what I'm doing.
I made a (heavily) modified version of this, and it seems to be working really well so far. If anyone is interested, I'd be glad to show you exactly what I did. The only drawbacks that I have found in the method I'm using are:

1) You still move forward when you attack, provided there isn't anything in the area where you would be.

2) I still haven't found an efficient method for making a system like this for ranged combat. Does anyone know any tutorials that explain it?
author=Quiversee
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.


download link :<
Pages: 1