Gw Temp


Tutorial - 'ABS Tutorial Part 1 - Basic Sword Attacks' by AzureFenrir

An item about RPGMaker 2000 posted on


Part one of AzureFenrir's ABS chain tutorial, this tutorial shows you the basic sword attack algorithms of an RM2K ABS.


ABS Tutorial Part 1 - Basic Sword Attacks and Damage

The Lunatic AzureFenrir, at your service. I bring to you Part One of a (hopeful) series of ABS tutorials, each covering a good "feature" of ABSes. I'll try to keep my jokes to a bare minimum in this series so I can spend more time teaching the actual stuff.

ABS stands for Active Battle System. It's basically a system where everything occurs continuously (as opposed to turn-based) and you can move characters/use weapons in real-time. To make an ABS in R2K, you'll need a lot of parallel common events, as well as a solid knowledge of RM2K functions.

So, here's what you need to know before you read this tutorial:


Experience With and Knowledge of RM2K Commands
Using and Manipulating Switches
Using and Manipulating Variables
Fork Statements
Comparing Hero/Event Coordinates
Input Password

You probably already know what an ABS is, but for those of you who do not, it stands for "Active Battle System." It's basically a custom battle system where you fight enemies in real time instead of a turn-based structure.

Before you start, here are the switches and variables that you need:


2 Switches - "Blocked", "Enemy1Die"
6 Temporary Variables - "HeroX", "HeroY", "WatchX", "WatchY", "Temp", "Enemy1HP"

We'll start with a simple 20x15 map, like this:

Now, add two events to the map. Give one event a evil-looking graphic: this will be our enemy. Move the other event outside of the map, and make it a parallel process event. Your map should now look something like this:

So...if our hero touches the enemy, then he gets hurt, right? So let's make the villain's event begin "On Touch (Event, Hero)", and add code for damaging the hero, such as:

<>Flash Screen: (R31,G00,B00,V31),0.5sec(W)
<>Take Damage: AlexAttack 5 Damage

So, if the enemy attacks Alex, he takes 5 damage. That's easy enough. But what if the hero attacks the enemy? this case, let us add some code to the Parallel Process event. Start by using the Enter Password script to ask the player for the Decision Key (5) (and store the result in "Temp"). Make sure you check the "Wait Until Key Hit" option!

Now, store the Hero's X and Y coordinates in the HeroX and HeroY parameters, and the enemy's coordinates in the WatchX and WatchY parameters. Your code should look like this:

<>Enter Password: [0005:Temp]
<>Variable: Ch[0001:HeroX] Set, Hero XPos
<>Variable: Ch[0002:HeroY] Set, Hero YPos
<>Variable: Ch[0003:WatchX] Set, EvilVillainguy XPos
<>Variable: Ch[0004:WatchY] Set, EvilVillainguy YPos

Now we can use the coordinates to our advantage. First, make a fork condition that executes when the hero is FACING UPWARD. In this FORK statement, start off by showing a uber-1337 "Hero swinging sword" animation or something, so the hero will look like he/she's attacking.

Now, if the hero is facing up and attacking, then the enemy must be directly north of the hero, right? Right. That means the hero's X coordinate should be the same as the enemy's X coordinate. which means:

<>FORK Optn:Varbl[0001:HeroX]-V[0003]Equivl

Remember to change 0001 and 0003 to whatever variable numbers that you used!

Also, the hero must be one block below the enemy, so HeroY should be one greater than WatchY (remember that the Y coordinate INCREASES as you go down). Therefore, let's use the Temp variable again:

Variable Ch:[0005:Temp] Set, Var.[0002]val.
Variable Ch:[0005:Temp] -, Var.[0004]val.
<>FORK Optn:Varbl[0005:Temp]-1

OK, you first set the Temp variable to the Hero's X Coordinate. Now, you subtract the enemy's Y coordinate from temp, which will give you the difference between the hero and the enemy's Y coordinates. If the difference equals one, then BINGO! The enemy is only one block above from the hero! Remember that if the enemy is one block BELOW the hero, you would get negative one (-1) as the difference instead of positive one, so you don't have to check for that.

Now, inside the final FORK statement, add the damage code and whatnot, like:

<>Flash Character...: EvilVillainguy, 1.0s.(W)
<>Move Event...: EvilVillainguy, Fix Dir., Escape from Hero, Escape from Hero, CancelFixDir
<>Variable Ch:[0006:Enemy1HP] -, 1
<>FORK Optn:Varbl[0006:Enemy1HP]-0less
    <>Change Switch: [0015:Enemy1Die]-ON Set
 :END Case

This will flash the villain red and knock him/her back 2 spaces. It will also reduce a variable called Enemy1HP by one, and when it reaches or is less than 0, the enemy DIES!!! You should initialize Enemy1HP to 1 when the player enters the map.

Don't forget to add another page to the villain event and set it's start conditions to "Enemy1Die-ON" to get rid of the enemy!

Remember to add three more FORK statements for when the hero is facing DOWN, LEFT, and RIGHT:

DOWN: HeroX = WatchX, HeroY - WatchY = -1
LEFT: HeroY = WatchY, HeroX - WatchX = 1
RIGHT: HeroY = WatchY, HeroX - WatchX = -1

Here's the full code for the other three directions:

I didn't include the death handlers/damage code because this was quickly written during testing. You'll have to add them to the appropriate place inside each fork (I R TEH LAZY).


Setting an enemy's HP seems like a very easy process. You could simply add an AUTOSTART event to the map and add scripts to make it set the Enemy1HP variable and turn on a switch that will disable the event. However, what if you want to make enemies that reappear every time you enter the map, or even reuse the Enemy1HP variable so you don't have to create millions of variables for millions of enemies?

Well, you could make TWO such switches. The Auto Start event that sets the HP for one map could use one switch, and the event for an adjacent map could use the other switch. The two maps could then turn on the adjacent map's switch.

There is an easier way, though. You could insert the resetting code in the events that teleport the main character to other maps. Therefore, you can reset the enemys' HPs whenever the user leaves the map, thus eliminating the need for separate events and switches.