Browse  Forum  Clubs  Chat  News 

ActionScripters Club -> AS: Tutorials -> RPG Battle Tutorial

AS: Tutorials Forum: RPG Battle Tutorial

Stick Man Animator: RPG Battle Tutorial - Aug 8th 2008, 11:44AM Link | Report
Ok, I might not be able to teach you much, but I'll try.

---------

First of all, make two layers. Then label on the top "health", and on the bottom "fight" without the quotes. In the health layer, make one frame, and in the fight layer, add a keyframe, making the frames in the health layer with 1 frame, and in the fight layer with 2 frames.

Next, add two dynamic text in the first frame of the health layer. Then label one of the text var. "good", and the other one "bad" without the quotes. You can add static text to know which one you're playing as and the other one the enemy.

In the first frame of the fight layer, add these actions.

good = 100;
bad = 100;

That shows that their lives are each 100. You can change that to any number you want.

In the second frame of the fight layer, add these actions. And name the frame "home" without the quotes.

stop();
if (_root.good<=0) {
gotoAndPlay("lose");
}
if (_root.bad<=0) {
gotoAndPlay("win");
}

I cannot really teach you what it is for, but I'll show you later.

Now in the frame where you added the last action I showed you, draw yourself, or use sprites. And add 2 buttons, name them "Attack" and "Heal" without the quotes. In the Attack button, add these actions.

on (release) {
gotoAndPlay("goodattack");
}

And in the Heal Button, add these actions.

on (release) {
_root.good += 20;
}
on (release) {
gotoAndPlay("goodheal");
}

I set the for you to heal only 20, you can change it later.

Now all in all, you have your health in the health layer, and in the battle layer, in the first frame, you have actions, and in the second frame, you have 2 buttons, and your characters. By the way, you can add a Super Special Attack if you want.

Ok, add a keyframe in the fight layer, and name the frame "goodattack" without the quotes. Then animate yourself attacking, no movieclips. In the frame where you hit the enemy, add these actions.

_root.bad = _root.bad-random(10);

I set the attack point to 10 randomly. If you remove the random, you'll hit the exact number you placed. You can change it later.

After you attack, make sure you're on the same spot where you started. At the last frame where you attacked, add these actions.

gotoAndPlay("badattack");

Next, add a new keyframe, animate yourself healing, again no movieclips. After you heal, add these actions.

gotoAndPlay("badatttack");

Ok, now make a new keyframe with your enemy attacking. And name it "badattack" without the quotes again. On the frame where your enemy hits you, add these actions.

_root.good = _root.good-random(10);

That action means the enemy will hit you randomly from 10 to 0. Now at the last frame where your enemy is attacking, add thses actions.

gotoAndStop("home");

Now, back to the health layer, add a frame to where your enemy attacked.

Next add two blank keyframes in the fight layer. Name one of the frames "win", and the other one "lose" without the quotes.

In the "win", show that you win like you're standing and the enemy dead, or just on the ground. And in the "lose" frame show that you lost like add a text like "You Lose." And add a stop action to both frames.

---------------

Ok, that's pretty much it, if you have any questions, ask me. This is just a simple tutorial, you can look on Newgrounds for better tutorials.
Page: