Best viewed in Firefox

Awesty Productions

Turn Based Combat

January 14th, 2007 by awesty

In this tutorial you will learn how to make a turn based combat system. I am using Flash 8, but Flash MX 2004 will work aswell.

Click here to see an example of what we will be making.

You need to have some knowledge of flash before you take this tutorial (MovieClips, Variables, All the tools etc.)

First of all, you need to make your character. Make one MC (MovieClip) with the character standing still, and the other with it attacking. Now, most people have trouble understanding this, but you have to make a blank MC (Ctrl+F8). On the first frame of that MC, drag the standing still MC from the library (Ctrl+L) onto the stage. On the second frame drag the attacking MC from the library onto the stage. Make sure they are in the same spot. Put the action ’stop();’ on each of the frames. Now return back the the main timeline and give that MC an instance name of man. (It is case sensitive)


Now do the same thing, but for the enemy. Give this an instance name of enemy.

Now make a new MC (Ctrl+F8). Leave the first frame blank. On the second frame, have something like this:

Give the dynamic text an variable name of healthPotion.

And on the third frame have something like this:

Give this an instance name of attack.

Now make one more MC. This will be the HP bar. Put one underneath the man MC and one underneath the enemy MC.
Above those HP bars put some dynamic text.

Give the one above the man MC HP bar a variable name of hP. Give the one above the enemies HP bar a variable name of ehP.

Now for the code. ;D (Make sure you read all the comments).

Put this code on the man MC.

//When this MC loads
onClipEvent(load){
    //The _global variable ‘turn’ is true
    _global.turn = true;
    //The _global variable ‘waiting’ is false
    _global.waiting = false;
}
//When this frame is entered
onClipEvent(enterFrame){
    //If turn is true and waiting is false…
    if(turn == true && !waiting){
        //the text goes to the 2nd frame (Choosing your attack)…
        _root.attack.gotoAndStop(2);
    //unless waiting is true…
    }else if(waiting == true){
        //the text goes to the 1st frame (blank)…
        _root.attack.gotoAndStop(1);
    //otherwise…
    }else{
        //the text goes to the 3rd frame (enemies turn).
        _root.attack.gotoAndStop(3);
    }
}

Put this code on the enemy MC:

//When the MC loads
onClipEvent(load){
    //Declares a new variable called waitTime which has the value of 10
    var waitTime:Number = -10;
}
//When this frame is entered
onClipEvent(enterFrame){
    //if the variables ‘turn’ and ‘waiting’ are both false…
    if(!_global.turn && !_global.waiting){
        //This MC goes and stops on the 2nd frame…
        this.gotoAndStop(2);
        //and waiting is true
        waiting = true;    
    }   
}

Put this code on the man MCs health bar.

//When this frame is entered…
onClipEvent(enterFrame){
    /*The _xscale of this MC is equal to hP, the max is
    0 (it won’t go and lower), and the min is 100 (it
    won’t go any higher)*/
                         
    this._xscale = Math.max(_root.hP,0);   
    this._xscale = Math.min(_root.hP,100);
    //If hP is greater than 100…
    if(_root.hP > 100){
        //It equals 100
        _root.hP = 100;
    }
    //If it is less than 0…
    if(_root.hP < 0){
        //It equals 0
        _root.hP = 0;
    }
}

Put this on the enemies HP bar.

onClipEvent(enterFrame){   
    this._xscale = Math.max(_root.ehP,0);      
    if(_root.ehP > 100){       
        _root.ehP = 100;
    }   
    if(_root.ehP < 0){     
        _root.ehP = 0;
    }
}

That is exactly the same as the other one, except for a few variables.

Put this on the attack button in the attack MC.

//When the mouse is release on this button…
on(release){
    //the man MC goes the the 2nd frame…
    _root.man.gotoAndStop(2);
    //And waiting is true.
    _global.waiting = true;
}

And put this on the Health potion button in the attack MC.

//When the mouse is released on this button…
on(release){
    //If there are some potions left…
    if(_root.attack.healthPotion > 0){
        //Turn is false…
        _global.turn = false;
        //Waiting is false…
        _global.waiting = false;
        /*Hp increasing by a random number
        between 0 and 29 with an additional
        20 added on. So the lowest is 20,
        the highest is 49.*/

        _root.hP += random(30)+20;
        //The man MC goes and stops on the 1st frame.
        _root.man.gotoAndStop(1);
        //The No. of potions decrease by 1.
        _root.attack.healthPotion -= 1;
    }
}

Put this on the last frame on the man MCs attacking MC.

//Turn equals false
_global.turn = false;
//Waiting equals false
_global.waiting = false;
//The enemies hP decreasing by a number
//between 3 and 9
_root.ehP -= random(7)+3;
//This MC goes to the first frame
_root.man.gotoAndStop(1);

Put this on the last frame of the enemies attacking MC.

//turn is true
_global.turn = true;
//waiting is false
_global.waiting = false;
//the man MC’s HP decreases by a number
//between 5 and 16
_root.hP -= random(12)+5;
//This MC goes and stops on the 1st frame
_root.enemy.gotoAndStop(1);

And finally, put this code on the first frame of the main timeline.

_root.hP = 100; //The characters HP = 100
_root.ehP = 100; //The enemies " "
_root.attack.healthPotion = 2; //Change this to however many potions you want.

Now you should have a fully functioning turn based combat system.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • Furl
  • MyShare
  • NewsVine
  • Netscape
  • Reddit
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

RSS feed

354 Comments »

Comment by flamingmonkeyz
2007-01-14 20:31:24

great tutorial! I’m going to use this ing my rpg game for battles!

Comment by Dude Subscribed to comments via email
2007-05-16 08:35:25

Can you posibly make a tutorial like this where you can play two play? Because that would be really awsome!

 
 
Comment by Bob
2007-01-15 00:23:38

This is by far your best tutorial ever. I can impliment it into any game! You’re the best!

 
Comment by Bob
2007-01-15 01:17:22

Actually I went back to make it, and when I did, the enemy won’t stop attacking, and I can’t use potions.

 
Comment by awesty
2007-01-15 14:38:22

Make sure you follow the tutorial closely. Make sure you haven’t missed anything.

 
Comment by Bobbkins
2007-01-16 02:26:36

Hi awesty. That tutorial was amazing. Probably one of the most useful youv’e done so far. But i think there is a slightly easier way to do it just using if statments and MCs, anyway i’m not critizing you. I have another question to ask
Is your next tutorial going to be one about a GTA type game? because that would be the best one yet.

 
Comment by asdf
2007-01-16 05:40:50

When are you going to start posting the fla files?

 
Comment by awesty
2007-01-16 10:18:30

@Bobkins: Ah… Im not sure what it will be.

@asdf: When I feel like it :P

 
Comment by abhilash
2007-01-16 19:27:13

This tutorial was coool!!!!

 
Comment by Pamela
2007-01-17 18:07:56

I have the same prob as Bob. But I went through everything and read it (you’d b suprized if you know me, i don’t read notes)

 
Comment by dragonguy
2007-01-18 03:52:24

hi thats a good tutorial. I was wondering - how can you tell if your game is going to take time to load and needs a pre loader? My games are roughly 3mb, and they load for me. Im not sure if they’ll load on the net fast, so i think i need pre loaders. Any help? thanks.

 
Comment by dragonguy
2007-01-18 06:11:18

i forgot to ask another question i had errors coming up with some variables on another project. It keeps telling me to add ( somewhere but i dont know where. The errors are like this:

**Error** Symbol=turn, layer=Layer 1, frame=2:Line 6: ‘(’ expected
if _root.wait = 5; {

**Error** Symbol=turn, layer=Layer 1, frame=2:Line 11: ‘(’ expected
if _root.wait = 10; {

**Error** Symbol=turn, layer=Layer 1, frame=2:Line 7: ‘(’ expected
if _root.wait = 10; {

**Error** Symbol=turn, layer=Layer 1, frame=2:Line 12: ‘(’ expected
if _root.wait = 5; {

Total ActionScript Errors: 4 Reported Errors: 4

I tried putting it like this
(_root.wait
and
((_root.wait)

etc but it wants it somewhere else. Can you tell me where to add it?

 
Comment by KatyS
2007-01-18 06:14:48

hello awesty that was a fab tutorial and very very useful. I need to ask a simple question, when you add variables you can make it add a random ammount. Can you please tell me the code to put on a frame that would make another mc play a random frame no. on its own timeline? Ta again awesty.

 
Comment by awesty
2007-01-18 11:04:49

@Pamela: I cant really help you anymore than that. Unless you send it to me.

@Dragonguy: 3mb is alot, so add a preloader. If it is the .fla that is 3mb, that .swf wont be as much. Also, with your problems, change them all to this:

if(_root.wait == 5){
and
if(_root.wait == 10){

@KatyS: _root.MC.gotoAndPlay(random(NUMBER) 1)

Replace NUMBER with the number of frames there are. It has 1 because if you have random(10), it is from 0-9. Replace MC with the instance name of the MC.

 
Comment by KatyS
2007-01-18 17:29:48

hello again. I tried adding to the random frame code, so that it would etheir play at 1,20,or 40. But i couldnt find a way and there is an error with the normal code you sent me :S

**Error** Symbol=man, layer=mantween, frame=35:Line 2: ‘)’ or ‘,’ expected
_root.enemy.gotoAndPlay(random(84) 1)

i would be grateful if you could help. Thanks.

 
Comment by KIM
2007-01-18 17:53:51

woohoo! this is the best tute yet!!

but i have a question…you see, i made another type of atk called man_magic_atk, and it is in the third frame of the man mc, and each time i use it, the MagicBar(a dynamic text use to cast magic spells) will go down, i completed that part but if the magic bar hits zero, i can still use my magic, how can i not use it when the MagicBar hits Zero?

thnx awesty

 
Comment by awesty
2007-01-18 20:45:10

@KatyS:
randomFrame:Array = [\”1\”,\”20\”,\”40\”];
i = random(3);
_root.enemy.gotoAndPlay(randomFrame[i]);

That should work, but it is untested.

@KIM: You will have to make it the same as the health potions.

if(MAGICTXT > 0){
//ATTACK
}

So if it is below, it wont attack.

 
Comment by KIM
2007-01-18 20:55:22

ahh!… once again you have helped me from my request!

thank you almighty awesty

 
Comment by jake
2007-01-19 12:36:14

In the demo the healthbar on enemy doesnt work and it goes into negative numbers…

 
Comment by awesty
2007-01-19 14:26:02

oops… >_<’.

But it should still work in the tutorial.

 
Comment by KatyS
2007-01-19 17:50:36

it just says syntax error

 
Comment by KIM
2007-01-19 21:33:18

hey, how can i make my “man” defend?
(like it can’t be hit when i picked the button “defend” and it stays in that frame and after the enemy moves, the “man” will go back to frame 1(standing frame)?

 
Comment by KIM
2007-01-19 21:35:07

how can the enemy not hit me when i click the defend button?

 
Comment by awesty
2007-01-20 11:37:56

@KatyS: You need to remove the backslashes and retype the qoutation marks.

@KIM: Well, make a variable that is true when the man is defending. And on the code where it takes off HP, put this around it:
if(myVariable != true){
}

So if it is true, it wont decrease in health.

 
Comment by KatyS
2007-01-21 04:55:46

hmm…. i tried it but it won’t work. I also tried rearraging the brackets etc but no luck :(

 
Comment by zionaise
2007-01-21 11:49:23

hey there!
gr8 tutorial but i have one question,
how do i make it so that once all of either sides HP are gone it will stop the game mabye with a win/lose message?

 
Comment by awesty
2007-01-21 20:10:34

@KatyS:
randomFrame:Array = [’1′,’20′,’40′];
i = random(3);
_root.enemy.gotoAndPlay(randomFrame[i]);

Dont copy and paste it, write it straight in.

@zionaise:
if(_root.hP < 0){
_root.gotoAndStop(FRAME);
}else if(_root.ehP < 0){
_root.gotoAndStop(FRAME);
}

 
Comment by Bryce K.
2007-01-22 08:28:31

Hey Awesty, best 1 yet, maybe you could make a second one and when we hit the enemy it flinches that whould be a lot better :P other than that its kool

 
Comment by zionaise
2007-01-22 12:16:25

err.. i trust that ur code will work but i cant find what to put it on =( plz help!

 
Comment by Bryce K.
2007-01-22 12:46:24

Hey Awesty,
Please o please check out my (mini) game its really kool, and i think you whould be pleased, the only thing i need help on is making an Xp bar, so when you kill an enemy it gives you xp then when you get a certain amount of xp you level up :P

check my game out!!
http://www.swfup.com/swf-view.php?id=4871

 
Comment by RDB2006
2007-01-23 02:43:53

@Bryce
For the xp thing, if your guy has a health bar then this would be the code..

onClipEvent(enterFrame){
this._xscale = _root.VAR;
if(_root.VAR

 
Comment by no1jock
2007-01-23 02:47:58

nice try with the game bryce, i say the only thing would maybe make it more spaced out and improve the dodgey animation :P

i have a problem and was wondering if anyone could help. I want it so that when you click a button that is inside an MC, the button disapears and an MC appears inside an MC (the inventory) which can be displayed by clicking a button.

But it doesn’t work. It makes the button disapear, but the item doesnt appear in the inventory when i click the button to open up the inventory mc. Iv’e got alpha and all that in, but i don’t no y its doing nothing.

 
Comment by KatyS
2007-01-23 03:01:26

hey can someone tell me the code for when you click a button it removes the button? just like you would remove an MC and it doesn’t respawn or u dont see it again throughout the movie

 
Comment by dragonguy
2007-01-23 22:49:53

i have a big problem and its seriously frustrating me. I want it so that if you click a button, and a variable equals something, then it will subtract variables and add some, and then make an MC called unlocked play at frame 2. I used this code but its not working

on (release) {
if(_root.task1 = 5 )){
_root.money =20;
_root.energy -=20;
_root.d = 5;
_root.slot1 = (”")
_root.text.gotoAndStop(3);
_root.unlocked.gotoAndStop(2)
_root.mana =5;
_root.task1 = 1000
}else _root.money = 0;
_root.energy -=0;
_root.mana =0;
_root.text.gotoAndStop(2)
_root.unlocked.gotoAndStop(1)

}

slot1 is a variable. Thanks if you can help

 
Comment by Mike
2007-01-24 06:42:15

it didn’t work for me, couldn’t u put ur “.fla” file? so we can download it from somewhere..

 
Comment by Aspherin
2007-01-24 15:49:34

I dont understand why you declare the waitTime variable..?

otherwise, this is a great tutorial!

 
Comment by Seerex
2007-01-24 23:56:17

great tutorial. some questions tho, how can i make it so u jump to “X” frame when health reachs 0, (gameover frame) and a “continue playing” frame if u win?

and any chance u can make an “XP” system and “buying items” system, since it shouldnt be that long.. i would love u to mail em to me on Seerex11@hotmail.com.. thank you

 
Comment by Bryce K
2007-01-25 09:55:58

and any chance u can make an “XP” system and “buying items” system, since it shouldnt be that long.. i would love u to mail em to me on robinweaver@san.rr.com.. thank you

LOL :P

 
Comment by Mike
2007-01-25 16:24:08

plz some1 gimme link so i can download it, cuz i cant get it working..

 
Comment by KIM
2007-01-25 16:56:49

and how can i do that? whats the code?

 
Comment by Mike
2007-01-26 00:46:52

ok then if u dont wanna put the file on internet

Plz tape when u make the tut from start to end so i understand exacly.. and write in middle of the movies and tell what u do, set it on Youtube or Video.google or something

i really want this game.. plz help! ^^

 
Comment by Mike
2007-01-26 05:51:58

gimme the .fla file plz.. i cant get it working..

i get 8 errors =S

and it stays when i attack.. nothing happends..

 
Comment by Mike
2007-01-26 05:53:57

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 2: Statement must appear within on/onClipEvent handler
_global.turn = false;

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 4: Statement must appear within on/onClipEvent handler
_global.waiting = false;

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 7: Statement must appear within on/onClipEvent handler
_root.ehP -= random(7) 3;

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 9: Statement must appear within on/onClipEvent handler
_root.man.gotoAndStop(1);

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 2: Statement must appear within on/onClipEvent handler
_global.turn = true;

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 4: Statement must appear within on/onClipEvent handler
_global.waiting = false;

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 7: Statement must appear within on/onClipEvent handler
_root.hP -= random(12) 5;

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 9: Statement must appear within on/onClipEvent handler
_root.enemy.gotoAndStop(1);

Total ActionScript Errors: 8 Reported Errors: 8

 
Comment by awesty
2007-01-26 11:36:41

@Zionaise: It tells you in the tutorial.

@Bryce K: Nice work. For an XP bar, try making a variable that increases when you win. Then when you use the XP for upgrades or something, it decreases.

@no1jock: Maybe try making the button take the MC to a dif frame, where the button isnt there but the item is.

@KatyS: Use an MC instead of a button. Give it and instance name of \”remove\”. On the frame, put this code:

remove.onRelease = function(){
this.swapDepths(9999);
this.removeMovieClip();
}

That should work.

@dragonguy: Try this:

on (release) {
if(_root.task1 == 5 ){
//I am not sure if that is meant to be += below
_root.money =20;
_root.energy -=20;
_root.d = 5;
_root.slot1 = (”\”)
_root.text.gotoAndStop(3);
_root.unlocked.gotoAndStop(2);
_root.mana =5;
_root.task1 = 1000;
}else if(_root.money == 0){
_root.energy -=0;
_root.mana =0;
_root.text.gotoAndStop(2);
_root.unlocked.gotoAndStop(1);
}
}

@Aspherin: Whoops, I was supposed to take that out. Origanally the enemy waited a bit before it attacked, but it screwed up so I left it out.

@seerex:

if(_root.hP <= 0){
_root.gotoAndStop(FRAMENUMBER);
}
if(_root.ehP <= 0){
_root.gotoAndStop(FRAMENUMBER);
}

@Mike: Why dont you follow the tutorial like everyone else? If you have trouble doing it, it is probably to hard so you should try easier things first. I am not going to record it since alot of the tutorial is coding, and it is easier just to copy and paste it then read the explanations then trying to read the text out of the recording (which would be hard because it would be bad quality).

Also most of the errors you posted are because you put the code on an MC when it should be on a frame.

 
Comment by KIM
2007-01-26 12:10:36

it dosen’t work!

i cant get my man defend!

 
Comment by awesty
2007-01-26 12:14:50

Just keep experimenting with it.

 
Comment by Bryce K
2007-01-26 12:42:44

Thanks man

 
Comment by Bryce K
2007-01-26 14:12:03

MUAHAHAHHA! Im kinda polished my game a bit tell me wut u guys think :P (Campain is not even close to done :P) Tell me wut ur guy’s highest score is
http://www.swfup.com/swf-view.php?id=4989

Comment by kensuke Subscribed to comments via email
2007-10-23 07:14:36

14 or so but i was healing from then on so i stopped i was a worrior. good game so far mine need alot of work.

 
 
Comment by Mike
2007-01-26 16:16:18

Bryce K, ultra nice game ^^ =)

i still want a .fla file plz =(

 
Comment by awesty
2007-01-26 16:24:32

I got 6.

When you beat the pac-bird in campaign and upgrade your stats, it goes back to survival mode.

 
Comment by Mike
2007-01-26 16:35:59

guys, i got away from the errors, but still not working =(!

plz some1 make one with ugly characters so u dont think i’ll steal your game, and send me the .fla file.. i cant make this but i really want!

 
Comment by Mike
2007-01-26 16:45:49

when i attack nothing happends and when i use health potion nothing hapends, so, no1 attack, so i cant play my own game =/

 
Comment by Seerex
2007-01-26 23:20:56

well, this just sound noobish, but at the XP thing, u said make a variable that incraese and decrease so on.. and how do i make a variable? sry i sound like a noob, i get ur tutorial here working fine, but how do i make an EXP system?

secondly, when i need to jump to desired frame (or SWF file) when my man touchs target? also, how do i make a button change movie, so the whole game doesnt have to be in one big SWF file?

thanks alot for helping

 
Comment by Seerex
2007-01-26 23:56:13

uh sry forget a question.. very sry for all the questions there mate, but well, ehm yeah… im making my own RPG game and i want it to be extremely good… with help from you ofc, u will also be in the credits..! for sure!

but well, about getting quest’s from an NPC, any way to make it give u XP when completing that Q, or maybe even a reward? how u increase damage done when equipping sword? all i think of is to change movieclip to another one and give higher ATK.. and finally, how to throw out a weapon? =) thank you

 
Comment by Seerex
2007-01-27 00:10:27

sry to bother u AGAIN, but i always forget to input the last questions.. FINAL question for now.. how do i make an event accour (when man touches wall it jumps to fram “X” and plays, like he enters a new zone)?

plz help me awesty!

 
Comment by Bryce K
2007-01-27 01:16:04

Thanks for telling me that awesty :P

 
Comment by Bryce K
2007-01-27 01:22:41

@Seerex Hey i can answer your last question, (with the help of awesty’s hit test TUT) First do the TUT so you understand hit tests. Second make a BUTTON wall, (oh lets say to the right) Now put this code on it (IT HAS TO BE A BUTTON!!)

on (keyPress “x”) {
if(this.hitTest(_root.SOMETHING)){
_root.gotoAndPlay(FRAME);
}
}

NOTE: Fill in SOMETHING and FRAME with a Movieclip and a Keyframe :P

 
Comment by Bryce K
2007-01-27 01:24:19

Oh yah also Seerex you might want to put a wall behind/ on top of the button because this wont stop the MC, it will go right through it :)

 
Comment by RDB2006
2007-01-27 02:43:47

hey give awesty a break and try to work things out yourself, and that way you’ll learn better.

 
Comment by guy
2007-01-27 02:49:28

ya i agree with rdb. awesty works hard and thats when he’s not at school! :p

 
Comment by Phil
2007-01-27 04:16:18

how can you make when enemys health is 0 you win &
when your hp is 0 you lose?

 
Comment by Seerex
2007-01-27 06:48:56

thanks alot bryce.. and yeah i know, i didnt think much myself there, sry awesty man, and btw, phil, awesty already answered that question, look up…

 
Comment by Seerex
2007-01-27 06:53:16

ehm bryce, it gives this error when i add the code to the button/wall thing

Clipboard Actions: Line 1: Key code identifier expected
on (keyPress “x”) {

any ideas?

 
Comment by Seerex
2007-01-27 07:13:20

and bryce, are u sure u get my question right? i mean, i would like a wall, ill make its alpha 0, but when u hit that wall it will transfer you to target frame… what i dont understand bout ur code is the on (keyPress “x”) {

dont need a keypress, but when he touches wall it transfers him.. please help me mate.. and awesty, if u have the time i would love answers on the other questions… thank you.. sry for being a pain in the ass, very good work for someone ur age, ur far better than me =).. good work mate!

 
Comment by Bryce K
2007-01-27 08:44:48

Yah, okay as i said you make it a button, one with that action and the make a movieclip with the hit test action, wut my action does is when you press X it will jump to another frame

 
Comment by Bryce K
2007-01-27 08:48:53

@Phil try to learn it for urself but if you must know at the end of your hp bar actionscript before the } put this code

gotoAndPlay(FRAME);

do the same with the enemy code

 
Comment by Seerex
2007-01-27 09:18:03

understandable bryce, but can i get ur e-mail please? would be very nice, since i think i can learn alot from u if u dont mind…

thank you

 
Comment by KIM
2007-01-27 10:00:58

ok… i’ll try

 
Comment by awesty
2007-01-27 12:21:38

@Mike: If you cant do it, it is probably to hard for you. Just do something easier until you understand this one.

@Seerex:

Variables: http://www.awestyproductions.c.....ables-101/

@Phil: Read previous comments. I feel like I have answered that question 100 times! (Thats including all the tutorials).

About making a game a bunch of different .swfs, I wouldnt recommend that.

About increasing stats… You could have a damage variable, say its called damage and it is equal to 5. So when you attack, you can just put:

_root.hp -= damage; //Which is 5

When you upgrade or something, the damage variable increases. So then the code would still be:

_root.hp -= damage;

But damage would be a higher number.

When you complete a quest, say your gold or XP was a dynamic text box. So at the end of the quest you could have something like:

if(questComplete){
_root.xP = 50;
_root.gold = 250;
}

Or something like that.

Also, no offence Bryce, but I wouldnt use that code. I would do something like:

onEnterFrame = function(){
if(man.hitTest(wall)){
_root.gotoAndStop(X);
}
}

Put that on the main frame, with the character the moves having an instance name of man, and the wall an instance name of wall. Change X to the frame you want it to go to.

 
Comment by KIM
2007-01-27 14:05:06

ok ok, i give up about this defend thingy!

anyway….

 
Comment by Seerex
2007-01-27 20:07:01

thanks alot matie, ill get started reading about the variables right away!

 
Comment by Seerex
2007-01-27 22:22:30

ehm awesty, not sure if i understand fully.. u mean add _root.hp -= damage; //5 and add another _root.hp -= damage; on the weapon when he picks it up? to increase damage or?

and ur quest complete thing, where do i put it, and how does it know its a quest complete thingy?

maybe send an FLA file to Seerex11@hotmail.com, would be nice

 
Comment by test
2007-01-28 07:29:29

ehm, this is driving me nuts, saw u told Seerex the thing with the onEnterFrame = function(){
if(man.hitTest(wall)){
_root.gotoAndStop(X);
}
}

well, i used this code as onEnterFrame = function(){
if(man.hitTest(village)){
_root.gotoAndStop(396);
}
}

so when it hitted the wall village, it should take me to fram 396, but instead take me to a frame about 190-200? ive used 30 min to figure it out but i just cant..?

 
Comment by test
2007-01-28 08:48:56

can it have something to do with the fact im using scene 5 for the game? if so, whats the code used for another scene?

 
Comment by test
2007-01-28 08:57:38

oh, silly me, got it now hehe…

 
Comment by test
2007-01-28 09:13:23

hey again awesty, i promise this is the last time ill bother you, but its a major problem for me. u see, using RPG tut 1, for item picking up thingy, i made on frame 1 a quest giver that says u need to pick up wood.. so, the char travels to frame 2, picks up the wood and goes back to frame 1, (i made a copy of the MC on frame 1, but player cant see it, so it will reach alpha 0 when the one on frame 2 does it, which should cause the MSG box to change to frame 3 in the MSG MC) but it doesnt, i dont even need to pick up the wood then it says im done with the Q… any advice?

 
Comment by Bryce K
2007-01-28 10:39:14

Non taken but the other code i don’t understand so i usually do a lot of loop holes :P

 
Comment by awesty
2007-01-28 12:15:32

@Seerex: You need to increase the damage variable.

About the quest thing, say the quest is to defeat a dragon or something. You could have something like:

if(dragonHp < 0){
questComplete = true;
}
if(questComplete){
//do stuff
}

@test: ah… I dont really know what you are saying.

 
Comment by seerex
2007-01-28 18:49:09

ah i c awesty thanks, but well, what if u need to kill the dragon, but u need to travel to, lets say fram 2, then kill it and go back to frame 1 to complete it. that wouldnt be possible would it, since if u do that the dragons HP would reset to 100? any advice?

 
Comment by awesty
2007-01-28 19:08:50

No, it would be possible.

if(dragonHp < 0 && _root._currentframe == 1){
questComplete = true;
}
if(questComplete){
//do stuff
}

That would work.

 
Comment by KatyS
2007-01-28 20:56:23

test and seerex stop flooding the comments fgs

 
Comment by seerex
2007-01-28 22:31:38

katy’s, mind ur own bussines please…

 
Comment by seerex
2007-01-28 22:36:09

katy’s, im just trying to figure this out, its the last i need for my game!…

so awesty,

if(wood_Alpha

 
Comment by seerex
2007-01-28 22:37:03

if(wood_Alpha

 
Comment by seerex
2007-01-28 22:41:25

so
if(wood_Alpha

 
Comment by seerex
2007-01-28 22:43:40

okay awesty, some bugs with the comments atm? :S. cant post the whole code ive ben using, anyways it doesnt work.. can u plz post a code doing “if wood alpha is 0 - quest complete = true; if Qcomplete _root Gold = 10;” this.. and when i pick up wood, enter frame 2 (new are) and goes back to frame 1, the wood is there again and all repeatable. how can he keep the gold, and how can the wood disappear for real? =S

sry to bother u this much, but im trying to get the game done at the release date

 
Comment by KatyS
2007-01-29 02:22:35

seerex. You are basically flooding it asking loads of long questions about RPGs. Your’e not going to learn anything posting 10 comments every day asking for mass ammounts of code so you can copy and paste. If you want information like that, then go somewhere else or figure it out yourself.

 
Comment by no1jock
2007-01-29 02:26:07

ya i agree with katy youv’e posted 16 comments in the last few days.

 
Comment by Bryce K
2007-01-29 02:40:10

Guys give Seerex a break okay, and it doesn’t matter how much he posts the comments don’t have a limit. And also if you don’t like all his posts then stop posting your posts then there will be less posts

 
Comment by bobbkins
2007-01-29 06:12:28

hi i really need to know - how can you tell how long you need to make your pre loader?

 
Comment by dragonguy
2007-01-29 06:19:58

hello i was wondering about “Flash Lite” apparently it is used to make small flash games that can be put on your mobile phone. I’m not sure if its a program or if its free or not, or where i get it or if its different from flash. Can somebody help? I really need to start making mobile games to boost my buisness. Thanks.

 
Comment by awesty
2007-01-29 08:47:34

@KatyS & no1jock: I seriously couldnt care how many comments he posts. Its not like this is a forum and you get banned for double posting.

@seerex: Well, first of all declare your variables like this:
_root.Variable or _global.Variable

Then they are accessable on other frames. Then they shouldnt reset.

@Bobkins: You dont animate preloaders. They are done with actionscript and only take 1-3 frames.

@Dragonguy: You can make those programs start from flash 8 with actionscript Lite. I have no experience with it so I cant help you anymore.

 
Comment by Hatz
2007-01-29 17:00:38

I did the whole thing and it works nifty!
(Surprising because I am completely new to this so you must be an awesome teacher)
Only thing is, the Dynamic text doesn’t display the numbers of how much health the two have left.
I’m not sure why…Do you have any suggestions?

 
Comment by Hatz
2007-01-29 17:32:07

So sorry for bothering you, I worked it all out myself.
I was writing the variable name in the instance name box.
(I have to read more closely!)

One question that remains though, (So sorry if this has already been answered) but what would the code be for saying once the enemy or man’s hP was down to zero they’d play a dying animation?
Thankyou so much.

 
Comment by bobbkins
2007-01-29 18:08:19

oops. Ive been animating them lol. Can you tell me how i can make one properly?

 
Comment by awesty
2007-01-29 20:31:18

@Hatz:

if(this.hP <= 0){
this.gotoAndStop(NUMBER);
}

Just change NUMBER to the frame number of the dying frame.

@bobbkins: Try going to newgrounds and downloading there preloader.

 
Comment by Bryce K
2007-01-30 12:57:17

Awesty, (didn’t no were to put this)
i just found out that when you add sound to a MC it doesn’t play the sound when you start the .swf do you know how to make it play?

 
Comment by seerex
2007-01-30 23:31:33

So awesty, sorry for bothering u again, but this code should work then?

_root.Variable
if(wood_Alpha

 
Comment by seerex
2007-01-30 23:31:50

So awesty, sorry for bothering u again, but this code should work then?
and BTW, where i put it? on MC man or main frame?
_root.Variable
if(wood_Alpha

 
Comment by seerex
2007-01-30 23:33:38

hm a bug accoured…
this is the code

_root. Variable
if(wood_Alpha

 
Comment by Grifo
2007-01-31 01:56:27

You can’t use LessThan brackets, because of hacking problems.

 
Comment by Trys Everything
2007-01-31 09:52:49

Ill try to help with questions. Make sure you post the errors AND the code that made the errors

 
Comment by awesty
2007-01-31 15:46:32

@Bryce: Is the sound on a timeline or done through actionscript?

@seerex: It isnt a bug, read grifos comment.

 
Comment by RDB2006
2007-01-31 17:56:50

Hi peepz. I’m going to start a big game project soon and want the graphics, sound fx, and everything to be prfect :P i was wondering if anybody that is advanced in creating sound or 3d images in flash or photo shop etc, i could hire you for my project? Your name would be displayed in the credits and you would get a free copy of the game. Just message me if you would like to help. Thanks!

 
Comment by RDB2006
2007-02-01 06:11:26

yay got a nintendo wii with zelda and wii sports, :D but need to wait fifteen days before my birthday to play it lol! arghhhhh

 
Comment by Bryce K
2007-02-01 13:39:22

ha ha lucky

 
Comment by Bryce K
2007-02-01 13:41:07

yah my sound is on a timeline no actionscript though i made the grass move in my MC but when i play the .swf it there isn’t any sound…

 
Comment by awesty
2007-02-01 20:55:45

@RDB2006: I got a wii a few weeks ago, but only have wii sports… >_< .

My brother is going to get Ultimate alliance tomorrow or something though (only because he has a voucher to get it for $30 >_<) and I should be able to get zelda in a week or two. Since we have a bunch of vouchers, so it is only $50 instead of $100.

 
Comment by awesty
2007-02-01 20:56:21

@RDB2006: I got a wii a few weeks ago, but only have wii sports… >_< .

My brother is going to get Ultimate alliance tomorrow or something though (only because he has a voucher to get it for $30 >_<) and I should be able to get zelda in a week or two. Since we have a bunch of vouchers, so it is only $50 instead of $100.

@Bryce: Click on one of the frames that the sound is on, make sure there are enough frames to play the sound and that it is set to stream.

 
Comment by RDB2006
2007-02-02 02:06:00

klkl. Lucky u, here in the UK games cost £49.99. I thinks thats around $100 in your money, and thats just for one game

 
Comment by Bryce K
2007-02-02 11:48:36

roger

 
Comment by Bryce K
2007-02-02 12:31:32

didn’t work

 
Comment by awesty
2007-02-02 15:07:58

>_<… dont get offended by this, but is your volume up?

 
Comment by Bryce K
2007-02-03 01:38:39

ha ha, yah it’s on :P ill try it again :P

 
Comment by leddyeddy
2007-02-03 04:02:22

hi awesty i think your site is amazing! the tutorials are wonderful and actully explain everything (unlike normal tutorials on the net) as you’ll know everyone is mad about the wii and i discovered flash games might be used for it! that would be great, but a bit ambitious and too hard for people like us to even make a simple game. Thought it might intrest some of you though, here are a few sites about it:

http://jayisgames.com/archives/2006/09/wii_to_support_flash.php

http://forum.explosm.net/archi.....14622.html
(there is some information on the top link apart from a few rude messages :P)

 
Comment by awesty
2007-02-03 11:00:03

Yes, I have heard about this. But I have also heard that the browser the wii uses only has flash player 5… I am not sure if this is true or not, but if it is you will have to export as flash 5.

 
Comment by RDB2006
2007-02-03 21:29:26

sounds cool. Iv’e always wanted to put my flash games on some form of console apart from a computer as it looks professnial :P the fact that i can’t open my wii for another 13 days doesn’t help lolz :P

 
Comment by leddyeddy
2007-02-03 21:31:46

im making a game and i need to know a few things.
Perhaps you could do a short tutorial or tell us how to have a customizable character. For instance,
A screen comes up saying dress your character. You would then press buttons to change the colour of his top, change his shoes, add hats etc, then when you click the play button the character you customized is there and you can move him around. Ty

 
Comment by dragonguy
2007-02-03 21:37:09

thats really good news about the wii flash games. But i have a few questions Would you have to program it especially in some different code or change the format? Would it just be a mouse game with the cursor and clicking or could you have the arrow keys? etc, etc.

 
Comment by awesty
2007-02-04 12:21:29

@leddyeddy: How about instead of getting me to make the game for you, why dont you try and do it for yourself? That way you will learn more.

@Dragonguy: Mouse = Wii controller. Im not sure about the keys though. :\

 
Comment by RDB2006
2007-02-04 21:37:45

Well iv’e already started making a basic first person shooter with enemies and sound for the wii :P

 
Comment by awesty
2007-02-05 20:13:16

Cool. Cant wait to see it ;D

 
Comment by heya
2007-02-05 21:29:35

hello awesty, im making a flash game, and its so u can change area, like u enter a wall with alpha = 0, and it transfers u to target frame, but lets say someone ask’s u to go and pick up a stone on another frame, u go, pick it up, and go back to him. but then it all reset’s coz u go 1 frame BACK in ur timeline, so the quest is repeatable.. any advise on that one?.. thank you…

 
Comment by seerex
2007-02-06 03:48:00

hey awesty, its just the thing with my game i cant get working.. well, 2 things..

like, when an enemy is defeated, how do i make him “disappear” for real? so its not possible for him to come back?

and again, i made the game so u can transfer to different zones.. 1 zone on fram 1, another on fram 2 and 3 so on. but when u get a so called “quest” on frame 1, that lets say ask’s u to pick up a stone on frame 2, u go to frame 2, pick up the stone, kill an enemy thats guarding it, then back to frame 1 to complete Quest. but when u go back to frame 1, it all reset’s.. starts over. help please, its driving me mad

 
Comment by RDB2006
2007-02-06 06:19:18

@seerex
i know how you feel, RPGs can be frustrating to make cuz all the code nd stuff. To get rid of the enemy guarding it you would have to have a remove movie clip statment i think once youv’e defeated it.

 
Comment by seerex
2007-02-06 06:39:44

but if i do that, wouldnt that just make it all reset when i travel back to frame 1?. then i could do it all over again

 
Comment by awesty
2007-02-06 15:43:53

You need to declare your variabels with either _root. or _global..

 
Comment by seerex
2007-02-06 23:50:45

okay, any chance u can make like a test code doing something. like ehm, pick up grass, quest complete, 10 G, and the declare variable thing, coz i really dont know what u mean with declare?

 
Comment by RDB2006
2007-02-07 02:25:02

all he means is.. say you have a money variable.
you would make it etheir
_root.money
or
_global

I don’t think when you remove a movie clip it will reset again, i think it removes it from the whole swf file. Another thing is, once you defeat the enemey you could put this code on it:

EnemyDead = True
_root.monster.gotoAndStop(”2″)

And on frame two you would have a blank keyframe and a
stop()
action with no enemy. Then all you need to do is, when you go to frame one, then hit the mc to get back to frame 2, you would have something like this on the mc

if _root.enemydead = true {
_root.monster.gotoAndStop(”2″)
}

a bit complicated and a few xtra things u’ll need to add but thats how i would do it..

 
Comment by no1jock
2007-02-07 02:26:58

hey RDB can’t wait for your first person shooter coming out you really inspire me lol :D :D

i was wondering if there was a trailer or anything for it because i would really like to see at least a couple of decent flash games for the wii.

 
Comment by seerex
2007-02-07 05:13:13

okay i think i got that, if not ill just spam you =)

talkin about variables RDB, if i would make like a weapon in-game, that changes damage done and even the look of the character (add desired weapon).. would i then need to add something like
if_root.daggeron = tru {
_root.man and something i dont know? any suggestions?

 
Comment by seerex
2007-02-07 05:46:57

okay RDB, im so sorry to bother u this much, but im getting nuts of this. ive read the variable tutorial 10 times, RPG tutorial 10 times, and all other’s 10 times…

but its like it cant deal with multiple targets. like i have this code on my frame

onEnterFrame = function () { if (man.hitTest(enemy)) {gotoAndStop(”Scene 6″, 1);}};

that works as it should, but if i copy and paste the “enemy” it only jumps to another frame when i touch the first one, even if all others got same instance name. same problem if i add this code, togheter with the enemy code

onEnterFrame = function () { if (man.hitTest(teleport)) {gotoAndStop(”Scene 6″, 4);}};

it doesnt jump to that frame, since there is also such a code on the same frame, why do they “stack” instead of being seperate codes?

ill try to pull myself toghter from now on instead of spamming, but just please help me man!

 
Comment by RDB2006
2007-02-08 02:25:30

hi awesty, i ran into a slight problem with my game. Iv’e taken a tutorial on making a simple preloader, and ive added it to my fla doc. First ill explain the problem. My fla file is 3mb so needs a preloader. Ive got text saying loading, and on the second frame theres two dots beside, and third theres three. on the third frame (with three dots) i put a code in to restart at frame 1 (1 dot) and on frame one i have this code.

ifFrameLoaded (”end”) {
gotoAndStop (”start”);
}

i’m not sure if im meant to name the very last frame of the whole doc end, and the start of the game start. So i experimented a bit and named the start of the game start and end end. When preview my swf file it skips the preloader, obvisouly because the end frame must be loaded. I’m not sure about this as my document is 3mb and should take time to load, and the tutorial didn’t explain very well. Any help?

 
Comment by Bryce K
2007-02-08 08:07:54

Awesty,
its still not working :P

 
Comment by seerex
2007-02-09 01:23:51

im getting nuts of this. ive read the variable tutorial 10 times, RPG tutorial 10 times, and all other’s 10 times…

but its like it cant deal with multiple targets. like i have this code on my frame

onEnterFrame = function () { if (man.hitTest(enemy)) {gotoAndStop(”Scene 6″, 1);}};

that works as it should, but if i copy and paste the “enemy” it only jumps to another frame when i touch the first one, even if all others got same instance name. same problem if i add this code, togheter with the enemy code

onEnterFrame = function () { if (man.hitTest(teleport)) {gotoAndStop(”Scene 6″, 4);}};

it doesnt jump to that frame, since there is also such a code on the same frame, why do they “stack” instead of being seperate codes?

ill try to pull myself toghter from now on instead of spamming, but just please help me man!

 
Comment by RDB2006
2007-02-09 03:13:05

@seerex - if you send me the fla file, i might be able to help.

 
Comment by seerex
2007-02-09 03:47:02

sure thing, whats ur e-mail?

 
Comment by awesty
2007-02-09 16:41:57

You cant have the same instance name on more than one MC.

 
Comment by RDB2006
2007-02-09 17:21:27

oh yeah, its gona have to be like enemy1, enemy2, enemy3, etc. my email is richard@funhut.co.uk so if you have any probz send it.

 
Comment by awesty
2007-02-10 10:45:51

you could fix that with a simple for loop. So say you have 5 enemies, called enemy0, enemy1, enemy 2 etc.. Then you could put something like:
for(i=0;i<5;i++){
if(this.hitTest(_root[”enemy”+i])){
//do something
}
}

Then that would run 5 times every frame making sure if it is hitting one of the enemeis.

 
Comment by Bryce K
2007-02-10 11:29:11

Ummm… awesty you didn’t help me with my problem
so i will restate it :)

i just found out that when you add sound to a MC it doesn’t play the sound when you start the .swf do you know how to make it play? I tried running it Stream and all that stuff but nothings working :P could you suggest actionscript maybe?

Also i got my Wii two days ago :) im so happy, i got Zelda and i just suck at finding puzzles and treasure and all that crap, im suberb at fighting tho :) This is how bad i suck i played for 5 hours and im not even past the forest temple i think i have 6 monkeys :P

 
Comment by awesty
2007-02-10 20:27:40

umm… well make sure there are enough frames to play the song. ANd set it to stream.

 
Comment by Grifo
2007-02-11 05:24:56

Sorry if this makes no sense, I never tried putting sound on a game yet, but are you sure you aren’t putting that sound inside a movie clip with a stop action at the beginning?
I’m not sure if that makes any sense, I just read what you wrote and thought of it. Just trying to help.

 
Comment by awesty
2007-02-11 12:26:41

Yea, that makes sense and could be a problem.

 
Comment by Bryce K
2007-02-12 11:10:48

Umm… i did that

 
Comment by Bryce K
2007-02-12 11:18:42

wow holy crapm there must be a glitch or something i did a New flash document and sound worked but it doesn’t wor on the flash documnet ive been working on -_-

 
Comment by Bryce K
2007-02-12 11:25:32

yes yes yes!!! I figured it out it was on flash 5 settings :P whoops

 
Comment by awesty
2007-02-12 19:21:48

haha lol.

 
Comment by RDB2006
2007-02-12 23:28:23

hey any help on my preloader problem? it’s driving me mad :S

 
Comment by awesty
2007-02-13 16:11:48

When you just preview it in flash, the preloader wont work since it loads it when it publishes it. You should name the last frame end and the first (other than the preloader) start. Make sure you dont have scenes. To see if the preloader works you will have to upload it to the net, or test it out of flash (which im not sure if that will work.)

 
Comment by Jacob Daniels
2007-02-13 23:43:36

Hey, sorry I’m pretty much a noob at Flash, I can work all the coding but i’m just dumbfounded at this bit.
“First of all, you need to make your character. Make one MC (MovieClip) with the character standing still, and the other with it attacking. Now, most people have trouble understanding this, but you have to make a blank MC (Ctrl+F8). On the first frame of that MC, drag the standing still MC from the library (Ctrl+L) onto the stage. On the second frame drag the attacking MC from the library onto the stage. Make sure they are in the same spot. Put the action ’stop();’ on each of the frames. Now return back the the main timeline and give that MC an instance name of man. (It is case sensitive)”
Can you please make a tutorial of this? Seeing as you have made tutorials of things as simple as that like the cursor tutorial and also you yourself have said how many people can’t do this first part.

 
Comment by RDB2006
2007-02-14 03:14:10

wooo finally got to open my wii a few days earlier :P the zelda game is fab but kinda hard

 
Comment by Jacob Daniels
2007-02-14 04:12:41

Hehe, I heard its great but very long!

 
Comment by And Mar
2007-02-14 06:05:08

@seerex

sorry to be the bringer of bad news, but you in the gotoAnd…. functions, you can only use the scene parameter in frames on the root timeline.

sorry : (

 
Comment by Karan K
2007-02-14 06:30:51

I’m with Jacob, I can do the code but not the simple start bit (>.>)!
Can you please make a tutorial on that, seeing as it will be easy to make because it’s not that long.

 
Comment by bone
2007-02-14 09:12:54

When I test the game a scripting error comes up and says Symbol=attack, Layer=Layer 1, Frame=2: Line 3: on handlers may not nest within other on handlers
on (release) {

 
Comment by Kurt
2007-02-14 09:59:22

Lol once you get to 0 it doesn’t say you died or something and the enemy’s bar doesn’t go down only the numbers and it goes to -’s well that’s what it dose on the example, I don’t know about the tutorial though because i didn’t try it yet.

 
Comment by Bryce K
2007-02-14 10:49:09

Hey guys, my GAME IS AWESOME!!! I whould put the .swf up here but for some reason swfup.com wont except it, i’m almost done with the first part of it (i think theres going to be as much parts as i can make) then you guys can play it on flashportal.com (if it lets me i have .swf problems :P) Catch ya guys l8er

 
Comment by awesty
2007-02-14 16:28:32

@Jacob: Sorry but I am not going to do a tutorial on that, it isnt worth it.
What you have to do is make 3 MCs, and then put each one a different frame in another MC. So that MC has one of the other MCs on each frame.
If you dont understand that read through the comments since I have answered that question a heap of times before.

@RDB2006: Ja i have only played it a little bit. The start (in the village) makes you think alot, but after that it is a bit easier.

@Karan: Well of course you can do the code since it is just copying an pasting. Read above what I said to Daniel.

@Bone: It looks like you have done something like:
on(Something){
//Code
on(Something){
//code
}
}
Which wont work.

@Kurt: I am pretty sure I just screwed up the example.

@Bryce K: You have a dA account dont you? Why dont you just upload it there and post a link?

 
Comment by bone
2007-02-15 01:22:51

ya i put in

onClipEvent (load) {
// When the mouse is released on this button…
on (release) {

then the rest of the code.

 
Comment by RDB2006
2007-02-15 06:17:14

lookin forward to seein other ppl’s work bryce, like yours but wait til u see one of my games :P

 
Comment by awesty
2007-02-15 16:13:31

@Bone: You dont need the onClipEvent(load) outside of the on(release), you need to close the load first.

 
Comment by Grifo
2007-02-16 08:46:39

@RDB2006 Awesty’s right, except in one thing: you can test your preloader without uploading it, just press ctrl+enter once more after you’re already testing it.

@bone you cant use “on” functions inside another one of them.
Hope this helps.

Awesty I’m still waitin for the AI part 3 =)

 
Comment by awesty
2007-02-16 16:03:07

Seriously?

I never knew you could do that testing preloader thing.

Btw what did you have in mind for AI part 3? Maybe top down movement, with the enemy rotating towards you?

 
Comment by Bryce K
2007-02-18 05:18:38

wuts dA? I don’t have an account…

Oh and RDB2006 if you want some cool music for ur Flash go to Newgrounds audio i got tons of good music there just incase you didn’t now :P

 
Comment by Bryce K
2007-02-18 06:16:20

Oh yeah RBD2006 do you have other people working on ur Flash cause im a loner :( oh well mine will probably be a bit shorter but thats okay Short and sweet :)

 
Comment by Extazz
2007-02-18 10:39:08

Hey awesty i got a problem with my fla file. its like this when i attack the other player attacks. and i can choose wich player i whant to attack with. and there is no wait. plzz add my email or email me jonathan_bodling4@hotmail.com

 
Comment by seerex
2007-02-18 23:37:10

hello awesty.. i have a problem, again.. i have this code added to a frame -

onEnterFrame = function () { if (man.hitTest(enemy)) {gotoAndStop(”Scene 6″, 1);}};

so when “man” touches “enemy” it jumps to fram 1 in scene 6, which is a turn based combat.. and i have

onEnterFrame = function () { if (man.hitTest(springvale)) {gotoAndStop(”Scene 5″, 1);}};

when he touches the gate, the movie jumps to frame 1 in scene 5, making him go to a village, the problem is, it doesnt work.. any ideas?

 
Comment by Bryce K
2007-02-19 04:03:00

Seerex you could try this

onClipEvent(enterFrame){
if(this.hitTest(_root.WHATEVER)){
_root.gotoAndPlay(nextScene);
}
}

 
Comment by RDB2006
2007-02-20 03:04:36

hi awesty i have another problem. Iv’e noticed most first person shooters on the net only take about 1-3mb and they have up to 40 enemies. Iv’e only made around 8, but it takes up 3mb. I made the enemies buttons and when you click them movie of a gunshot and blood plays, is there any other way i could do it that would take up less space, like the other first person shooters? thanks.

 
Comment by awesty
2007-02-20 18:30:35

@Bryce K: dA = http://www.deviantart.com/

@Extazz: I have no idea what you just said.

@Seerex: Scenes and actionscript go together like George Bush and World peace… in other worlds, it will never happen :P
Try to avoid using scenes whenever you can when using actionscript.

@RDB2006: First of all if you have heaps of music/sound effects and bitmaps that will increase the file size.

Also make sure you arent looking at the .fla file size, since the .swf is only about half the size.

 
Comment by RDB2006
2007-02-21 04:15:09

ive got little sound fx and i draw all my buttons, art etc, i was looking at the fla file anyway. Thanks.

 
Comment by Bryce K
2007-02-21 11:33:21
 
 
Comment by Bryce K
2007-02-21 11:34:18

?? umm sorry if i posted twice my computer is running slow :P

 
Comment by Grifo
2007-02-21 12:08:32

Hey Awesty how you’re doing?

Right now I’m not working in that archer project, it is stuck. I found some old friends and we’re gonna make an mmo 2d flash game(it surely will be better than Tibia…at least…anyway I’ll let you know when it’s finished). Well then I think a birds eye view trigonometric AI system may come in handy…even knowing the programmers are by far better than me(I’m a designer).

I’m looking forward to it and to anything else you may upload here at the best flash tutorial website.

 
Comment by awesty
2007-02-21 15:28:11

A MMO made in flash?

Sounds interesting.

 
Comment by seerex
2007-02-22 05:14:22

well okay awesty… but still cant get a function gold and XP system working… like u said the thing with the dragons hp for example.. i tryied to make it with alpha.. so when alpha reach’s 0 on the wood it should give gold and XP.. but how u make a “level up” system? thats kinda hard..

 
Comment by seerex
2007-02-22 19:39:34

and the thing with wood alpha doesnt work either?.. weird and im lost.. and are u SURE that u cant have a “onclipevent if this root test man gotoandplay “scene5″ 4;” (short versoin).. dont understand why that wouldnt work? why cant they change scene

 
Comment by jeppe
2007-02-22 19:46:13

hey awesty, ive got a problem, it all works fully, i press attack, attack, enemy attacks, but then enemy just keeps on attacking.. doesnt stop on my turn again.. any clues?

thanks chap..

 
Comment by jeppe
2007-02-22 23:25:38

oh, works now.. sry

 
Comment by Seerex
2007-02-22 23:27:23

hey awesty, just writing again to make sure my last question were clear.. u said that actionscripts and scene’s dont mix.. well, i have this code on my main frame

onEnterFrame = function () { if (man.hitTest(bandit)) {gotoAndStop(”Scene 6″, 2);}};

and that WORKS… but if i add

onEnterFrame = function () { if (man.hitTest(teleport)) {gotoAndStop(”Scene 5″, 1);}};

it wont work? how come? its the same code? thats what i wanted to ask…

 
Comment by Mike
2007-02-24 02:20:26

Hey, i know i seem noobish, still cant get this working =S, and i really want, plz? i got some cool models, plz some1 gimme link for .fla file..

I BEG U!

and if u allrdy made mostly of the game, i can write “GREATLY THANKS TO ****”..

 
Comment by mysteriousguy
2007-02-24 02:37:23

hi bryce. I checked out your game its rather good. only a few things though…

the person you play as is just a grey dot.

since its birdseye view the sign post saying town looks weird like that

Once you try and get into the town it takes you to the menu.

Other than that, it’s pretty good.

btw, i liked the way you made things pop up on the menu when you rollover them. If you hover over the bit were the text appears, it all appears and is bit messy :S no offence but i wouldn’t say your flash master yet, it takes a long while. I’m not critisizing you or anything, just tryna give a little bit of helpful feedback.

 
Comment by Seerex
2007-02-24 05:16:39

okay this is odd… am i right if i say that if u edit in something and then change it back to normal, it wont work? coz i had a code working fine - onEnterFrame = function(){
if(man.hitTest(bandit)){
_root.gotoAndStop(”Scene 6″, 2);
}
}

worked perfectly, but then i just tryied to change a bit in the code, didnt work, so i changed back to normal.. but now it wont work at all? have the same problem with the item system…? how come? im sry for posting this much, but well…. there aint really a limit so…

 
Comment by awesty
2007-02-24 10:18:03

@Seerex: DONT USE SCENES IF YOU ARE USING ACTIONSCRIPT! It will stuff everything up. But if you are, make sure you have a _root. infront of gotoAndStop/Play.

@Mike: Just follow the tutorial.

@Bryce: Nice game ;)

 
Comment by Mike
2007-02-24 18:55:14

@Awesty: how hard is it to put a file on internet?

ive followed the guide, started over, 10times or something. .still not working! =/

 
Comment by Kurt
2007-02-27 09:32:29

Well one thing i followed all the code and when my guy attacks he loops just like on Making a fight game but i tried and already knew it wouldn’t work
_parent.gotoAndStop(1); Well if you have any other way than

_root.attack.gotoAndStop(2);
_root.attack.gotoAndStop(1);
and

_root.attack.gotoAndStop(3);

please tell me…

P.S. i thought this would be the first tutorial i wouldn’t ask you of something.

 
Comment by Kurt
2007-02-27 09:32:45

Well one thing i followed all the code and when my guy attacks he loops just like on Making a fight game but i tried and already knew it wouldn’t work
_parent.gotoAndStop(1); Well if you have any other way than

_root.attack.gotoAndStop(2);
_root.attack.gotoAndStop(1);
and

_root.attack.gotoAndStop(3);

please tell me…

P.S. i thought this would be the first tutorial i wouldn’t ask you of something. that is hard.

 
Comment by Kurt
2007-02-27 09:35:01

Ah double comment cause i pressed stop because i wasn’t finished typing…

 
Comment by Bryce K
2007-02-27 11:17:02

Thanks guys, yeah there is a glitch, it works fine on my computer but on the internet the file is corrupt maybe its devaintart i doubt it tho, awesty could you reccommend something :P

 
Comment by Bryce K
2007-02-27 11:20:24

oh also just wanted to say in my game ur supposed to be a stickfigure at the end of Chapter One you get sucked into a vortex and in Chapter Two you become Animae ^_^\/ (yes that is rather awesome)

 
Comment by jesse
2007-02-27 12:39:21

well i am kinda new to flash iv only had it for like 2 months now and i was folling you rpg game TUT and then i saw this my reaction was OMFG YAY IMA GONNA MAKE ME A RPG GAME WITH TURN BASE FIGHTING…but then i tryed to make it so that you see an enemy and then if you go near him it will go to a turn based fighing thing but has a noob lol i cant figure out how to do that if you could do a TUT or anything to help me that would be awsome ^_^ Awesty Rulz ^_^

 
Comment by Kurt
2007-02-28 07:48:55

Lol jesse im making a game like that the runescape half part i said would be RPG though and turn based combat is just like adventure quest Well it would probably be better than adventure quest. but maybe not runescape that would be hard.

 
Comment by Kurt
2007-02-28 07:50:16

And Awesty i saw you skip people’s comments before please don’t skip mine like 6 or 7 comments above

 
Comment by Kurt
2007-02-28 09:30:19

OK i just give up ill send you the fla… just tell me your email i seen you say it to people but i can’t seem to find it.

 
Comment by Kurt
2007-03-02 08:34:28

OK i found your email = awestyproductions[@]hotmail[.]com

 
Comment by Kurt
2007-03-03 01:51:45

… i can’t email you… ill try figuring out my self…

 
Comment by Kurt
2007-03-03 01:54:06

And Awesty you know how i submitted a tutorial for clicking on something xp stuff like that if you ask i can tell you part 1 ( the code, the code comes with what it means ) and the items you need.

 
Comment by Kurt
2007-03-03 02:45:05

Lol Awesty i didn’t make the enemy have a instance name of enemy and attack movie clip an instance name of attack

Hey whoever is stuck on this read it all again you might of missed something ( you would have )

 
Comment by RDB2006
2007-03-04 03:40:41

@Kurt

hi, if you have any problems with your game ask me, im quite experinced and awesty seems a bit busy. If you need help making your game, i could be a programmer on your project. Just feel free to ask

 
Comment by Shadowdragon
2007-03-04 06:18:04

How do you add an “attack roll” to turn-based combat? Something so that it checks to see if the attack hits. If the attack does hit then it deals damage, if it doesn’t then it skips to the enemy’s attack.

 
Comment by Grifo
2007-03-05 04:31:27

@Shadowdragon If you’re talking about that stupid thing in rpgs where you strike the enemy and it simply shows a message telling you you missed even though you just hit the enemy, use Awesty’s tutorial, but when attacking you should use a set a random value that should start an if statement to lead you to a different frame(something like a “miss” message)instead of the damage calculating code. Something like that.
Hope this helps.

 
Comment by awesty
2007-03-05 16:40:09

@Mike: Just get a file on DA or NG.

@Jesse: If you arent very comfortable with flash yet I think you should focus on simpler things.

@Kurt: Its awestyproductions[@]gmail[.]com.

Also try not to rip off my tutorials on your own site. >_>
Just because you changed the color of the square doesnt mean it is different, you even have the same icon. >_>

 
Comment by Shadowdragon
2007-03-06 11:15:16

Here’s another question. How do you change the number of starting hit points without having it adjust the size of the health bars? Say I want to make the man’s hit points 200 but have it keep the health bar the same size as when it’s 100. Can you make the size of the health bars a % of the total hit points?

 
Comment by awesty
2007-03-06 15:43:21

Um…

Say the max health is 200, you could do something like:

var maxHealth:Numer = 200;
var perHealth:Number = (_root.eHp/maxHealth)*100;
this._xscale = perHealth

You could put that on the health bar, the perHealth variable is the percent of the health.

 
Comment by Shadowdragon
2007-03-06 17:31:38

It works, thanks so much.

 
Comment by Kurt
2007-03-08 04:23:35

Lol sorry about that

i will change it alot it is just i cant change it because i made it on my 30 day trial flash 8 and it expired my mom might get studio 8 though so i can fixer later I’m sorry about that.

actually ill take it off until i get flash 8.

 
Comment by Kurt
2007-03-08 04:27:13

There now i delete all remote info.

 
Comment by Kurt
2007-03-08 04:27:31

and the entire page.

 
Comment by Uzi
2007-03-11 02:40:40

Hey awesty (yes it’s me again :P).I’ve done a turn based combat in my game. I’ve done 4 attacks for the hero and 4 attacks for the enemy. Is there a code so that the enemy could “randomise” the attack? (I mean, the computer chooses the attack for the enemy). If it is, please type the whole code. :)

 
Comment by uh
2007-03-11 11:46:55

Just use a
thevar = Math.random(4);
if(thevar == 1){
gotoAndStop(attack1frame);
}
and so on…

 
Comment by Kurt
2007-03-13 04:48:34

Um Awesty i discovered something when you click on health potion and you have full health it dose the same thing as the health potion would normally do but the hp doesn’t go up what would be the code so nothing happens if your hp = 100

And i got studio 8 yaaaa! i will change the tutorial up as much as i possibly can ( i made the tutorial when i was not thinking right)

 
Comment by Kurt
2007-03-13 07:32:35

Ok i fixed it just tell me if i need to change stuff to make it less like yours and tell me what I’m doing that is like yours once you see it.

 
Comment by Kurt
2007-03-13 07:37:59

Well just click here i don’t want to post it again until you see it.

http://kfb-zone.com/Gaming%20tutorials.htm

 
Comment by Kurt
2007-03-17 04:25:50

Awesty is it OK?? or do i need to change it? i also have a kfb-flash I’m making a flash version of my website it is having some graphic problems on the side menu bar and the contact me doesn’t work any more but i will try to fix them.

 
Comment by Kurt
2007-03-17 04:30:01

Ok the graphics are fixed it is just the contact me doesn’t work it will work on the test movie thing but not on the internet I’m having the same problem as Bryce K like on his game i won’t give up that is though.

 
Comment by Eibwen
2007-03-18 00:19:05

Help, the enemy won’t stop attacking or cast magic. Here’s code.

onClipEvent (enterFrame) {
//if the variables ‘turn’ and ‘waiting’ are both false…
if (!_global.turn && !_global.waiting) {
//This MC goes and stops on the 2nd frame…
this.gotoAndStop(2);
//and waiting is true
waiting = true;
} else {
//This MC goes and stops on the 3rd frame…
this.gotoAndStop(3);
//and waiting is true
waiting = true;
}
}

is there something wrong?

 
Comment by i will Subscribed to comments via email
2007-03-21 00:38:26

i’m also having the problem that my enemy won’t stop attacking and my potions don’t work, if any one could help me pleassse!!! it is driving me crazy!

 
Comment by awesty
2007-03-21 18:47:58

@Uzi: Well where it tells the enemy to go to the attack frame, instead of having:

this.gotoAndStop(x);

You could put:

this.gotoAndStop(random(x)+1);

If the attacks are from frame 2-6, put:

this.gotoAndStop(random(5)+2);

If the attacks are from frame 145-147 put:

this.gotoAndStop(random(3)+145);

@Kurt: Yea that is fine. I think I wasnt in a very good mood when I posted that, so I probably shouldnt have said that since there are only so many ways to do this and there are hundreds of tutorials for it ;)

@Eibwen & i will: Sorry but I cant give you any more advice than going through the tutorial and making sure you didnt miss anything.

 
Comment by i will Subscribed to comments via email
2007-03-22 02:30:47

thanx, i got it to work, and i too would like to know how to make ti jump to a win screen when enemies health is 0 and lose frame when yours is zero, i tried some others up there, but they don’t work, and where would i put it

 
Comment by Uzi
2007-03-23 19:02:35

another problem :| I made a Freeze spell. When the spell hits the enemy he will lose a turn or two.What’s the code? can anybody help me?

 
Comment by i will Subscribed to comments via email
2007-04-05 08:00:01

hello? awesty? are you still there?

 
Comment by awesty
2007-04-05 12:59:23

@i will: It would be like:

if(hp == 0){
_root.gotoAndStop(loseFrame);
}

@Uzi: Um… It is basically like the rest of it but obviously you will have to change stuff like the frames.

 
Comment by i will Subscribed to comments via email
2007-04-06 05:09:20

i really hate to say this but that doesn’t work either, is there something i’m doin wrong?
I’m putting that code on the main timeline, is that right?

 
Comment by Pamela
2007-04-06 14:28:33

Hello again. I have not missed anything out. I am looking for the problem now, but it’s very hard to find it. What frames do I put “stop” onto in the attack MC?

 
Comment by awesty
2007-04-06 21:16:11

@i will: Oops, I think I gave you the wrong code. If the enemy doesnt stop attacking you, you must of missed something out in the tutorial. You can email me the .fla if you want.

@Pamela: I dont think it tells you to put it anywhere in the tutorial.

 
Comment by Shinigamy Subscribed to comments via email
2007-04-11 17:18:42

Hi I’m kind of new to actionscript, and I dont know how to have something (like an attack) activated with a button on the keyboard (besides arrowkeys) =)

 
Comment by Trunk Monkey
2007-04-14 08:09:04

I done everything i think but it doesn’t work at all none of the buttons work and they dont attack

 
Comment by awesty
2007-04-14 15:33:43

@Shinigamy: Here is a list of key codes.
http://www.awestyproductions.c.....eycode.txt

@Trunk Monkey: Then im guessing that you didnt do everything right. >_>

 
Comment by Shinigamy Subscribed to comments via email
2007-04-15 22:39:11

Thanks. =) Also, love the tutorial
I will put a link to my game when it’s finished

 
Comment by Sae
2007-04-19 00:44:30

Trunk Monkey, your problem might be the stupid mistake I did which was making the text in the Attack and Health Potion buttons dynamic. They’ll work if the text is static just fine.

Awesome tutorial, by the way, Awesty. I’m having a little trouble keeping the enemy waiting for its turn to attack, but I figure I messed up the code somewhere. I just can’t find it as of yet.

 
Comment by Boltazo Subscribed to comments via email
2007-04-19 13:34:30

um how do i get to instance names?

Comment by awesty
2007-04-20 17:59:36

It is in the properties panel down the bottom to the left.

 
 
Comment by Zamarickz Subscribed to comments via email
2007-04-22 03:32:46

Yhis tutorial sucks!!!! The enemy is stronger and after you die you dont die!!! You need to fix this tutorial

Comment by awesty
2007-04-22 13:24:24

Well if you understood what the tutorial was teaching you could do that stuff. If it showed you how to do everything you wouldnt learn anything would you

 
 
Comment by i will Subscribed to comments via email
2007-05-04 11:50:38

i would like a tested and proven code that makes it so when ethier of you get to 0 it goes to a win lose screen. Mine works fine but when we get to zero, nothing happens, the game just continues.

Comment by awesty
2007-05-04 13:34:13

onEnterFrame = function(){
_root.hP==0?gotoAndStop(2):0
_root.ehP==0?gotoAndStop(3):0
}

Put that on the first frame under the rest of the code on it. Make a blank keyframe (F7) on the second frame and write something like You Lose. Do the same for the third frame but write You win.

 
 
Comment by Johnpinkertin Subscribed to comments via email
2007-05-05 11:03:59

great tutorial, but how can i make it so that when you hit a enemy in the first frame it goes to the second fram and plays the turn based combat?

Comment by SaroVati Subscribed to comments via email
2007-06-24 11:12:31

Hehe, I’m a bit inexperienced but I think I might be able to help awesty a little =)
If I’m wrong, just correct me lol
try typing on ur main character:

onClipEvent(enterFrame) {
if(this.hitTest(_root.”A”)) {
gotoAndStop(2);
}
}

“A” - instance name of enemy guy.

 
 
Comment by i will Subscribed to comments via email
2007-05-14 07:09:48

thank you thank you sooo much, you are the best

YOU ROCK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 
Comment by ZZ prod. Subscribed to comments via email
2007-05-28 20:25:47

Hey awesty great tutorial…just wondering if you could answer a couple questions.
How could I make the enemy flinch when the man hits it?
Also this has probably been asked but how can I get my guy not to do a spell when his magic points runs out?

thanks

Comment by SaroVati Subscribed to comments via email
2007-06-24 10:53:17

Um… i’m 12 years old so this answer might not help ya, but couldn’t you try:

on (release) {
if (_root.”A”

Comment by SaroVati Subscribed to comments via email
2007-06-24 10:56:13

Lmao… didnt come out right… so ill type it out again since the LessThan command is blocked out =/

on (release) {
if (_root.”A” LessThan “B”) {
stop();
} else gotoAndPlay(”C”);
}

“A” - whatever ur spell/skill takes to cast/use.

“B” - however much mana/mp ur skill/spell costs.

“C” - frame at which it plays a small scene of ur guy using the spell.

 
 
 
Comment by krest Subscribed to comments via email
2007-05-31 08:41:22

your tutorial is awesome.
my dying animation won’t work.i already looked at everyone else’s questions but still wouldn’t work.

Comment by SaroVati Subscribed to comments via email
2007-06-24 11:34:48

Well… if the scripts above didn’t work…. you might wanna try:

if(_root.hp

 
 
Comment by Michael Subscribed to comments via email
2007-06-05 05:44:56

Hopefully someone will see this…

Can someone tell me where to put:

if (_root.hP

 
Comment by Michael Subscribed to comments via email
2007-06-05 06:13:45

if (this.hP

 
Comment by Trunk Monkey
2007-06-12 07:58:45

I don’t understand about the blank frame becausewhen I done it all then the preview is just blank I don’t understand what I did wrong

Comment by awesty
2007-06-15 14:16:36

You may have to put stop(); on one of the frames or something, I cant really remember. Just read that part again and see if you have done it right.

 
 
Comment by Trunk Monkey
2007-06-16 08:42:31

I just don’t understand about making the blank frames because when I view the game it just shows nothing

 
Comment by Trunk Monkeey
2007-06-22 20:35:03

I got the game working but I tried to make them die and I use this code on the main frame

if(_root.hP

 
Comment by Trunk Monkeey
2007-06-22 20:35:33

if(_root.hP

 
Comment by Trunk Monkeey
2007-06-22 20:36:12

well its the code you used

Comment by awesty
2007-07-02 18:40:24

You cannot use the < or > sign.

 
 
Comment by SaroVati Subscribed to comments via email
2007-06-24 11:02:12

Ah btw, I’m trying to make a RPG type game…. it’s turning out ok tnx to some of ur tutorials. I got the hitTest and alpha stuff down. I also got the custom cursor down too $$$, and I got sound on/off. I got some problems tho……

1. For my shop thingy, when my guy hits the shop, the shop window pops up… which is good. Everything is working, but when im not touching the shop and the window closes, all i did was turn the alpha to 0. Soooo… if I put my cursor above where an item should be, the description still pops up…. how can I change this!!?!??!?!
I’ve tried to put this code in so they can’t see their cursor inside a certain area. It’s put on the ground so basically most of the map except the sound buttons:

onClipEvent(enterFrame) {
if(this.hitTest(_root.customcursor)){
_root.customcursor._alpha = 0;
} else {
_root.customcursor._alpha = 100;
}
}

Comment by awesty
2007-07-02 18:42:57

Well you should make it so the description only pops up if the shops window is equal to 100.

 
 
Comment by SaroVati Subscribed to comments via email
2007-06-24 11:06:29

Ew forgot to put 2nd problem in previous comment, oh well =(

2. I’m trying to have the character’s health and mp increase depending on the amount of str and int they have. On my main frame, I have:

hp = maxHP;
mp = maxMP;
maxHP = (5*str)+100;
maxMP = (5*intelligence)+80;
str=5;
intelligence = 5;

btw, all of these are dynamic txtboxes so they all appear ok except for the “maxHP” and “maxMP”….. I’ve been trying to find tutorials and change code around for 3-4 hours and I still am not improving a thing lol..
If anyone could help it would be great =)

Comment by awesty
2007-07-02 18:44:06

try:

str=5;
intelligence = 5;
maxHP = (5*str)+100;
maxMP = (5*intelligence)+80;
hp = maxHP;
mp = maxMP;

You didn’t have them in a proper order.

 
 
Comment by SaroVati Subscribed to comments via email
2007-06-24 14:16:00

Ew sry to bother you again =) Last question for awhile. For this tutorial, your code:

onClipEvent(enterFrame) {
this._xscale = Math.max(_root.hP,0);
this._xscale = Math.min(_root.hP,100);
if(_root.hP > 100){
_root.hP = 100;
}
if(_root.hP

 
Comment by SaroVati Subscribed to comments via email
2007-06-24 14:19:12

OMG IM SOO DUMB, I PUT LESS THAN AGAIN! sry sry sry =(

onClipEvent(enterFrame) {
this._xscale = Math.max(_root.hP,0);
this._xscale = Math.min(_root.hP,100);
if(_root.hP > 100) {
_root.hP = 100;
}
if(_root.hP LessThan 0){
_root.hP = 0;
}

it works, but is there any way to make the “xscale” or whatever equal to my variable called “maxHP”? Also, I added this code to my mP and tweaked it a little bit. It works, but when u start game, the blue mP bar shrinks since my set mana was 80. Does this code only work for things that equal 100? Tnx =)

 
Comment by SaroVati Subscribed to comments via email
2007-06-25 06:44:55

Lol if I’m posting too much, just tell me =) but I’m having serious problems with my game atm lol. For the battle thing, I’m trying to put in something new….. it’s like turn based, but not. LOL ok when u fight the enemy, ur guy goes to different screen where its 2d and u fight, but u can move at will and stuff. The enemy has AI on him and if he touches u it does dmg.(thanks 2 ur AI tut xD)Only problem is, how do i make something in my inventory get “equipped” onto my character? And when it does, how do I make it show in battle that he has the weapon equipped. Ty much =)

 
Comment by ConcorX Subscribed to comments via email
2007-06-30 04:39:19

When i win i made it so it could go to town but whenever you click the button it just flashes the first frame of the town!
What do i do?
you can try my game at www.sitekreator.com/concorx
and going to the games section and clicking ConcorX RPG

Comment by SaroVati Subscribed to comments via email
2007-07-01 01:24:29

Well, either there is no ’stop();’ command on the frame, or the frame has ’stop();’ but also has something like ‘gotoAndStop(2);’

Hope this helps =)

Comment by ConcorX Subscribed to comments via email
2007-07-01 09:56:24

Sorry didn’t help…
but thanks anyways.
Bryce can you help?

 
 
 
Comment by ConcorX Subscribed to comments via email
2007-07-02 06:19:40

Oh and sorry it dosent flash it just sticks on one frame so i can’t really do anything after the battle

 
Comment by ConcorX Subscribed to comments via email
2007-07-02 06:23:43

I REALLY NEED HELP

Comment by awesty
2007-07-02 19:23:16

Could you show me your code please?

 
 
Comment by ConcorX Subscribed to comments via email
2007-07-02 20:26:25

well the old script was:
On the first frame:
stop()

if(_root.hP

 
Comment by ConcorX Subscribed to comments via email
2007-07-02 20:28:59

????
It didn’t post the whole code!
anyways on the first frame its:
stop()

if(_root.hP

 
Comment by ConcorX Subscribed to comments via email
2007-07-02 20:29:45

WTF!!!!
Awstey i’ll just email you it. or the flash file.

 
Comment by Trunk Monkeey
2007-07-08 04:23:27

i want to make a game like final fantasy and i want to have two team mates but how would i make it so the enemy could attack any one of your team mates randomly so how could i do that?

Comment by awesty
2007-09-10 17:12:24

Try using the random(x) function.

 
 
Comment by gartman
2007-07-20 02:12:37

onClipEvent (enterFrame) {
if (_root.turn=1) {
this.gotoAndStop(1);
} else if (_root.turn=2) {
this.gotoAndStop(2);
} else if (_root.turn=3) {
this.gotoAndStop(3);
}
}
why dosent this work
ON ATTACK THINGY
im trin to have 2 teammates

Comment by awesty
2007-09-10 17:13:44

You need 2 equal signs.

if (_root.turn==1) {
this.gotoAndStop(1);
} else if (_root.turn==2) {

etc..

 
 
Comment by krest Subscribed to comments via email
2007-07-22 18:23:32

Please. does anyone have the code for magic. whenever my mp reaches zero i’m still able to attack.PLEASE!!!!

 
Comment by gartman
2007-07-23 03:56:07

umm ya know turns b eing a varible after guy 1 attacks the varible changes to 2 which means its guy 2s turn he attacks and it makes turn change to 3 which makes it guy 3s turn?????? which makes the attack movieclip change to the number of the varible??????????
:”(

 
Comment by cmc Subscribed to comments via email
2007-08-13 06:24:01

This tutorial is rubbish! I followed everything that’s exactly written in this and when I try it out it doesn’t work! The buttons and who’s turn keeps flashing beyond control and when I try to click the attack button it doesn’t do anything! Also, you didn’t tell us how to make an hp bar!

I’m sorry but you need to make a better and more detailed tutorial than this.

Comment by awesty
2007-09-10 17:14:48

What version of flash are you using?

Comment by cmc Subscribed to comments via email
2007-09-10 19:30:37

Flash Professional 8

Comment by awesty
2007-09-10 19:33:50

Are the buttons button symbols or MovieClip/Graphic symbols?

 
 
 
 
Comment by Po_Sc3 Subscribed to comments via email
2007-08-16 11:40:19

cmc did you put a stop action on the second frame for the attack MC????

also in mine my enemy keeps attacking and i was wondering if there was a solution for this yet cause its seems to happen frequently???

 
Comment by Po_Sc3 Subscribed to comments via email
2007-08-16 18:59:16

k got it fixed but now i don’t know where to put the code so when my enemy dies it goes to a win screen

 
Comment by kiji Subscribed to comments via email
2007-09-03 17:57:07

wtf im so confused ive tryed everything twice and yet wen i click attack my man just freezez

Comment by awesty
2007-09-10 17:15:30

That is strange.

 
 
Comment by Johnpinkertin Subscribed to comments via email
2007-09-26 07:51:43

hey awesty, you make great tutorials, but do you have a script, so that if i made a bids eye rpg like your tutorial, and i run into a enemy, it goes to another frame, wich has the turn combat in it?

Comment by awesty
2007-09-26 12:03:47

Try learning about hitTest() and gotoAndStop().

Comment by Johnpinkertin Subscribed to comments via email
2007-09-26 12:10:57

ok, i think i understand the basics of those, and i tried putting togather a script, but it keeps coming up with error, expecting to see se a ” ) “. this is the code im using

if(_root.man.hitTest(gotoAndStop(2));

Comment by awesty
2007-09-26 12:20:33

Try:

if(_root.man.hitTest(_root.enemy)){
gotoAndStop(2);
}

Comment by Johnpinkertin Subscribed to comments via email
2007-09-26 12:28:14

ok, so i put that in the timeline, [i think thats what im suposed to do, isnt it?] and now it has a error. this is it:

**Error** Scene=Scene 1, layer=Charactors, frame=1:Line 1: Statement must appear within on/onClipEvent handler
if(_root.man.hitTest(_root.enemy)){

Total ActionScript Errors: 1 Reported Errors: 1

(Comments wont nest below this level)
Comment by awesty
2007-09-26 12:37:00

That error is coming up because you put it on an MC without putting it in an onClipEvent Handler.

You need to put that code inside the:

onClipEvent(enterFrame){
//code here
}

 
 
 
 
 
 
Comment by please help Subscribed to comments via email
2007-10-14 22:47:08

Great tut:)
I’ve been looking for a tutorial like this for ages and I only understand basic actionscripting. Ive followed the instructions three times and I’ve tried playing around with the actionscripting but then nothing happens or there are errors and the same problem occurs.
In my game the main character and the enemy never stop attacking. I never get the chance to click
‘attack’ or health potion because they flick past and dont do anything. Only the enemies health goes down.
I was hoping to send it to you.
I only have flash professional 2004 but I will send it in fla and swf.
Please post your email address.
If you fix it or send it back with some suggestions that would be great:)

 
Comment by please help Subscribed to comments via email
2007-10-14 23:06:57

I’ve fixed it up so that I can attack but the enemy still does no damage and the potions dont work (count down) and the enemy doesent stop attacking.
I’d still like to send it to ya :)
Great tut.
(The problem was I was using the same movieclip for the standing/idle as for the attack and so they did the same thing).

Comment by awesty
2007-10-16 16:56:21

Okay I have replied to your email.

 
 
Comment by please help Subscribed to comments via email
2007-10-27 13:28:32

Theres just one more problem.
I’ve used a gotoAndStop code so that when I die or the enemy dies it goes to a win lose screen. However if I win I cannot go forward to the rest of the game. If I just press forward before i win then the buttons do work.
heres the code I’m using on my frame
stop();
_root.hP = 150; //The characters HP = 100
_root.ehP = 150; //The enemies ” ”
_root.attack.healthPotion = 2; //Change this to however many potions you want.
_root.attack.superAttack = 2;
onEnterFrame = function(){
_root.hP==0?gotoAndPlay(69):0
_root.ehP==0?gotoAndPlay(41):0
}

It flashes to the next frame along but then goes straight back to frame 41.
I’ve tried to fix the scripting but I’ve had no luck.
there are no errors.

Comment by awesty
2007-10-31 15:20:58

Did you put a stop action on frame 69?

Comment by please help Subscribed to comments via email
2007-11-01 18:49:32

yeah, is it that the script doesent go and so it will not allow me to leave frame 69 because it thinks ehP is always zero because even if I right click and press forward, back or play it still skips straight back to 69. However if I put an ehP bar in with full health it still doesent work, so I guess its not that. (sorry about double post).
Did anyone else have this problem?

Comment by awesty
2007-11-01 19:23:42

Which version of flash are you using?

Comment by please help Subscribed to comments via email
2007-11-02 18:41:24

flash mx 2004.
If i download a recent fla it say’s unexpected file format, but sometimes it wont. So i think its pretty old. (?)
:)

(Comments wont nest below this level)
Comment by awesty
2007-11-02 22:25:24

Well it came out in 2004 obviously :D

Since MX 2004 there has been Flash 8 (which has no big changes) and this year Flash CS3 came out (which has AS 3.0).

 
Comment by please help Subscribed to comments via email
2007-11-04 13:19:15

Do you think my old version of flash is the problem or do you think ive stuffed the actionscripting(above). Like I said there are no errors. Quite a conumdrem. Its a shame cuss I really wanted to make this game (:-(). Also whats with this hashcash message about spam thatv was stopping me from posting??
Do you think I should send it to you because if you send it back it wont work in my version. It will say unexpected format. I suppose you could hust tell me what the problem was and I could do it myself.
Hasent anyone else had this problem? Any help or suggestions wanted :)

 
Comment by awesty
2007-11-04 19:13:32

Hashcash is to stop spam. It thought you message was spam i guess. I have it on because at one point I was getting 200+ spam comments a day.

It isn’t your version of flash that is the problem so it must be the actionscript.

You can send it to me if you want and I will take a look.

 
 
 
 
 
 
Comment by please help Subscribed to comments via email
2007-10-27 13:32:17

I’ve only got one more problem.
I have used the
_root.hP==0?gotoAndPlay(69):0
_root.ehP==0?gotoAndPlay(41):0
coding and when i win it goes to the next frame but then nothing else will happen. When I press the buttons it will flash the next frame but then return.
Should I use a removeMovieclip or something.
There are no error warnings.
Does anyone else have this problem.

 
Comment by INDODE Subscribed to comments via email
2007-11-06 03:14:16

awesty! I have a problem!
I followed the whole tutorial, I read all the comments, I turned and I turned the code but I don’t manage to do with that enemy stops attacking! please help me

Here: http://www.swfup.com/uploads/swf-48456.swf

Comment by awesty
2007-11-06 09:34:10

Did you put a gotoAndStop(1) action on the enemies last attacking frame?

Comment by INDODE Subscribed to comments via email
2007-11-07 00:18:14

yes! i follow all the tutorial!

do you want the fla. file?

Comment by awesty
2007-11-07 16:38:33

Okay, if you send it to me I will try and see what the problem is.

Comment by INDODE Subscribed to comments via email
2007-11-07 18:12:01
(Comments wont nest below this level)
Comment by INDODE Subscribed to comments via email
2007-11-09 07:50:21

sorry awesty! i figerit out!!
i forgot to give an instance name to the enemy! sorry for bothering you!

 
 
 
 
 
 
Comment by please help Subscribed to comments via email
2007-11-09 18:40:02

okay, I’ll send you the fla, its a little dodgy but everything works alright except the gotoAndStop?function
:(
sorry to keep bothering you.

 
Comment by Dalez
2007-11-17 21:03:05

Hey, i’ve made a SP sytem for when you use a spell its goes down. But i’ve ran into a little trouble.. firsty, the bar goes into negitives, and secondly, i want to make it so that when the SP bar = 0 then you can’t use any spells anymore. How would i do this? Thanks :) And great tut!

 
Comment by werny Subscribed to comments via email
2007-12-02 14:21:28

do you think you could post you fla, because I am having some troubles with clicking the attack button and have my guy actually attack

 
Comment by werny Subscribed to comments via email
2007-12-03 11:25:21

mine is really screwed up and I dont know why, can somebody tell me
http://rapidshare.com/files/73.....1.fla.html

 
Comment by ConcorX Subscribed to comments via email
2007-12-03 11:35:08

http://www.newgrounds.com/portal/view/413205

Awstey i realesed one of my best flashes yet so go and vote 5! Also check out a carnival of halloween (by me) it is a really good collection of halloween games that i made!

 
Comment by Homicidal Subscribed to comments via email
2007-12-27 07:27:15

Awesty I found a better way to use health bars

This is for frames, and the health bar has to have an Instance name of health_bar

NOTE:
health_bar: is your health bar
health: is your health
total_health: is your maximum number of health

health_bar.onEnterFrame = function():Void {
this._xscale = (_root.health/_root.total_health)*100;
if (_root.health LESS THAN =0) {
_root.health = 0;
}
if (_root.health GREATER THAN _root.total_health) {
_root.health = _root.total_health;
}

this code makes it so when the total number of health increase so does the bar. (Someone on the Internet showed me)

Comment by SaroVati Subscribed to comments via email
2008-04-04 10:28:43

Lol it would work, but you would need the health_bar to be ON the stage, if it was in the man movie clip, it wouldn’t work in the version of Flash I’m using. Maybe it’s just me, but if you just had the simpler version because we are talking about AS 2.0, just have:

onClipEvent(enterFrame) {
this._xscale = (_root.health/_root.total_health)*100;
}

on your health_bar MC… Obviously, for more advanced stuff, your code would be more organized, but lots of people here are starting Flash and probably won’t understand :P

 
 
Comment by MKA Subscribed to comments via email
2008-01-27 15:49:29

want to make it so the enemy enters a third frame when he’s out of health; one in which he dies.

How do I go about doing this?

 
Comment by darklink Subscribed to comments via email
2008-02-22 07:51:16

hey, i didnt really understand most of that… so could u please make a video tutorial.. or something easy 2 folo on… oh and y’know like dragonfable type games.. could u do a tutorial on that if u know how 2?

 
Comment by dragondude Subscribed to comments via email
2008-02-24 13:23:35

help

**Error** Symbol=hero, layer=Layer 1, frame=1:Line 1: Unexpected ‘)’ encountered
stop;()

**Error** Symbol=hero, layer=Layer 1, frame=2:Line 1: Unexpected ‘)’ encountered
stop;()

**Error** Symbol=hero, layer=Layer 1, frame=2:Line 2: ‘)’ expected
_global.turn = false;

Total ActionScript Errors: 3 Reported Errors: 3

 
Comment by hendrix13 Subscribed to comments via email
2008-04-02 12:08:32

I was wondering how I could make another attack that would do more damage. i have to animation, the fram in the man MC, and the gotoandstop code on a second attack button, but i cant find the code that takes away the enemy’s health after an attack.

 
Comment by stinkychops Subscribed to comments via email
2008-04-02 20:25:51

_global.turn = false;
_global.waiting = false;
_root.ehP -= random(12)+7;
_root.man.gotoAndStop(2);

that should be what you need.

 
Comment by hendrix13 Subscribed to comments via email
2008-04-03 11:23:34

but where is that code (the enemy health bar, you, a button… etc.)

Comment by stinkychops Subscribed to comments via email
2008-04-03 18:50:56

you need to place this in the last frame of your second attack mc. So inside the mc, inside the mc. on the last frame.

 
 
Comment by trigger Subscribed to comments via email
2008-04-04 08:39:26

I did everything correctly. I just want to know how I can make it so that when the hero’s hp goes to 0, it’ll take you to a “You died” screen, or a “You win” screen if you kill the enemy.

 
Comment by SaroVati Subscribed to comments via email
2008-04-04 10:10:59

You could check my tutorials from my website (click my name), or read the comments b4. I’m pretty sure someone already asked that question and Awesty answered it lol. If not, it was on a different tutorial. I’m feeling generous since it is Spring Break so I’ll tell you the code. It should more or less look like this:

if (_root.hp == 0) {
_root.gotoAndStop(”losingFrame”);
}

Have losingFrame the frame name of your losing frame, or have it as a number.

 
Comment by Liam Subscribed to comments via email
2008-04-13 18:26:33

Great, really helped but I’m still looking for a more advanced one, having 2 enemies, more attacks, killing them and dying etc.

Can you help?

 
Comment by SaroVati Subscribed to comments via email
2008-04-14 02:19:36

Lol if you fully understood all of Awesty’s tutorials, that wouldn’t be too hard… Obviously, you didn’t read the comment right above you that I made, because that tells you how to die. Sigh, this is what bugs me lol, they just ask for code and stuff, and don’t bother to do it themselves or even read other people’s questions….

Comment by Liam Subscribed to comments via email
2008-04-14 02:22:47

They?

I read his tutorial and made it my self in Flash, I’m also not going to bother reading 100 comments to him either, jeeze; get over it.

 
 
Comment by SamCollen Subscribed to comments via email
2008-04-14 02:50:48

is there anyway of making it so you can have two people on your side, like you choose an attack for character one, then character one attacks, then choose an attack for character two, then character two attacks, then the enemy attacks. If you could help me that would be awesome, Thank Awesty, your the best

 
Comment by SamCollen Subscribed to comments via email
2008-04-15 09:47:22

well, i tried to figure it out, and i just mess things up and boggles my mind, so if anyone can help, that would be great

Comment by stinkychops Subscribed to comments via email
2008-04-15 17:47:15

just use the global waiting and turn functions.
the hard bit would be allowing him to select the different eneminies. The easiest way would be to u

Comment by stinkychops Subscribed to comments via email
2008-04-15 17:48:04

why did it cut down my comment?

Comment by SamCollen Subscribed to comments via email
2008-04-18 10:03:23

i don’t want more than one enemy, just more than one character. And i did mess around with the global waithing, i have no idea how they work or how to do it.

 
 
 
 
Comment by SamCollen Subscribed to comments via email
2008-04-18 11:39:58

never mind, i just looked over the script and i noticed that waithing and turn are variables, i think i can figure it out now

 
Comment by Beppe Subscribed to comments via email
2008-11-16 09:50:17

this is okay. is there a way to make 2 players fight one guy, for a Mario-Brothers-esque sort of thing and they can fight together/heal each other and stuff?

and is there a way to gain MP so you can use special more powerful attacks? thanks bro.

 
Comment by Beppe Subscribed to comments via email
2008-11-16 14:01:21

i’m sorry man, but this tutorial isn’t working at all.

Comment by stinkychops Subscribed to comments via email
2008-11-17 18:45:32

What seems to be the problem Beppe?

Comment by Beppe Subscribed to comments via email
2008-11-19 06:23:53

i’m doing everything it says, it’s just not working. and if i try copying or pasting a movie clip it does the

“ONE OF MORE ITEMS ALREADY EXISTS IN THE DOCUMENT”

and if i hit DONT REPLACE it does this crazy stuff with my files. it’s weird. and the tutorial just isn’t working.

Comment by stinkychops Subscribed to comments via email
2008-11-22 19:30:06

you need to re-make the fla. Be very careful with the names of the movieclips and the instance names, do not import any mc’s into the document after you have made the mc’s.

 
 
 
 
Comment by nathan Subscribed to comments via email
2008-11-22 15:09:54

I’m having some problem
(1)My potions won’t work
(2)it won’t say enemies turn
(3)it lets me attack when the enemy attacks

Comment by stinkychops Subscribed to comments via email
2008-11-22 19:36:02

FOr, number 1, i cant help without seeing the swf.
For number 2, under the global
Turn functions ( believe its that, it could be the enemies turn or something)
put something similar to
_root.enemiesturn.gotoAndStop(2);
and make an mc, named enemiesturn with 3 frames, first1 blank with a stop(); in it, second 1 with the text enemies trun in it and then in the 3rd frame put this.gotoAndStop(1);
then inside the enemy mc place on the last frame underb the random damage
_root.enemiesturn.gotoAndStop(3);

For the 3rd one, place the buttons inside the mc, add script so that while the enemy attacks it goes to a frame that doesent show the buttons. And then on the last frame of the enemies attack put _root.[buttonthngieinstancename].gotoAndStop(1);. HHopefully this makes sense, goodluck.

 
 
Comment by Jonny{T} Subscribed to comments via email
2009-01-28 09:51:45

Great tutorial but i have a problem: Everything is working except for the battling animation. I can attack and use health potions but you don’t see them attack (if this queston has already been asked i can find it soz)

Comment by Rahhi Subscribed to comments via email
2009-09-10 22:00:10

Hey can you send me a copy of your fla so can, see it work or swf @ worlds-away@hotmail.co.uk

Having loads of problems with it so just need to see one work

Thanks

 
 
Comment by Scuds
2009-10-22 10:32:47

hi, great tutorial i just had a slight problem. i dont think you explained the attack, potion and enemies turn part well enough because i cant figure out what to do. every time i play the menu just flashes on the screen? what did i do wrong?

Comment by stinkychops Subscribed to comments via email
2009-10-22 19:00:30

Yeah mate, you need to put this piece of script in the timeline frame for the menu.
_root.stop();

That way it will stop on the frame. If there are anymore issues go through the tutorial slowly before asking.

 
 
Comment by Scuds
2009-10-23 07:03:58

thanx, i can select the attack button now but when i click on the potion button it does nothing and the number of potions doesnt show. i went over the tutorial several times and im positive i didnt miss anything. is it possible theres something wrong with the action script?

 
Comment by fletch Subscribed to comments via email
2010-01-23 07:14:28

YO, gr8 tutorial but PLEASE can you tell me how i make it go to a win or lose screen when the battle is over? anyone, just tell me what ActionScript to go where in a comment and i’ll be SO grateful ^^

Comment by stinky Subscribed to comments via email
2010-01-23 20:33:57

on the mainframe
if(hP=<0){
hP=0
}
if(hP==0){
_root.gotoAndStop(3)
}
if(ehP=<0){
ehP=0
}
if(ehP==0){
_root.gotoAndStop(2)
}

put the win frame on frame 2and lose on frame 3

 
 
Comment by Dude77 Subscribed to comments via email
2010-05-15 08:18:53

Hey awesty ty for the tutorial im using it for my rpg im working on. I have just one question though. i am making it so u can walk around in my rpg and stuff, then when u run into an enemy it takes u to the turn based battle i made with this tutorial. i made the guy start with 5 potions, and if u use one it goes down to 4 of course. but when u defeat the enemy and start traveling around again and meet another enemy, the potions are back to 5 cause they reset. how do i make it stay at how many potions i have left and not reset? Ty!

Comment by Stinkychops Subscribed to comments via email
2010-05-16 19:50:06

Create a new layer.

Fill the whole thing with one keyframe.

Inside this keyframe put

potionCount=5

inside your frame, wherever you have the _root.potion= _root.potion - 1 (or whatever your method of reduction is)
make sure the variable names are correct, test it, return here if there are problems.

 
 
Comment by Bob Subscribed to comments via email
2010-05-19 09:04:52

How do you make it so it shows a win or lose screen? Please say where to put the actionscript.

 
Comment by AW Subscribed to comments via email
2010-05-19 23:28:22

i liek smelly peehnus

 
Comment by MrPigilay Subscribed to comments via email
2010-06-21 04:39:58

I’m making a Llama RPG game where it’s like stick rpg but more of a storyline and skill structure. Well I found out how to make a turn based battle for the games fighting but in the game you have variables “str for example” I want it so the higher strength you have the higher you hit. I use this code
“_root.ehP -= random(10)+5;” But the strength doesn’t change what you hit so I need a code that makes it so the strength increases what you hit. Help me forum.

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.