Turn Based Combat
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.
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:
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.
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.
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.
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.
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.
_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.
_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.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.















great tutorial! I’m going to use this ing my rpg game for battles!
Can you posibly make a tutorial like this where you can play two play? Because that would be really awsome!
This is by far your best tutorial ever. I can impliment it into any game! You’re the best!
Actually I went back to make it, and when I did, the enemy won’t stop attacking, and I can’t use potions.
Make sure you follow the tutorial closely. Make sure you haven’t missed anything.
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.
When are you going to start posting the fla files?
@Bobkins: Ah… Im not sure what it will be.
@asdf: When I feel like it
This tutorial was coool!!!!
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)
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.
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?
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.
@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.
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.
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
@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.
ahh!… once again you have helped me from my request!
thank you almighty awesty
In the demo the healthbar on enemy doesnt work and it goes into negative numbers…
oops… >_<’.
But it should still work in the tutorial.
it just says syntax error
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)?
how can the enemy not hit me when i click the defend button?
@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.
hmm…. i tried it but it won’t work. I also tried rearraging the brackets etc but no luck
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?
@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);
}
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
other than that its kool
err.. i trust that ur code will work but i cant find what to put it on =( plz help!
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
check my game out!!
http://www.swfup.com/swf-view.php?id=4871
@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
nice try with the game bryce, i say the only thing would maybe make it more spaced out and improve the dodgey animation
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.
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
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
it didn’t work for me, couldn’t u put ur “.fla” file? so we can download it from somewhere..
I dont understand why you declare the waitTime variable..?
otherwise, this is a great tutorial!
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
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
plz some1 gimme link so i can download it, cuz i cant get it working..
and how can i do that? whats the code?
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! ^^
gimme the .fla file plz.. i cant get it working..
i get 8 errors =S
and it stays when i attack.. nothing happends..
**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
@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.
it dosen’t work!
i cant get my man defend!
Just keep experimenting with it.
Thanks man
MUAHAHAHHA! Im kinda polished my game a bit tell me wut u guys think
(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
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.
Bryce K, ultra nice game ^^ =)
i still want a .fla file plz =(
I got 6.
When you beat the pac-bird in campaign and upgrade your stats, it goes back to survival mode.
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!
when i attack nothing happends and when i use health potion nothing hapends, so, no1 attack, so i cant play my own game =/
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
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
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!
Thanks for telling me that awesty
@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
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
hey give awesty a break and try to work things out yourself, and that way you’ll learn better.
ya i agree with rdb. awesty works hard and thats when he’s not at school! :p
how can you make when enemys health is 0 you win &
when your hp is 0 you lose?
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…
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?
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!
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
@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
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
ok… i’ll try
@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.
ok ok, i give up about this defend thingy!
anyway….
thanks alot matie, ill get started reading about the variables right away!
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
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..?
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?
oh, silly me, got it now hehe…
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?
Non taken but the other code i don’t understand so i usually do a lot of loop holes
@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.
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?
No, it would be possible.
if(dragonHp < 0 && _root._currentframe == 1){
questComplete = true;
}
if(questComplete){
//do stuff
}
That would work.
test and seerex stop flooding the comments fgs
katy’s, mind ur own bussines please…
katy’s, im just trying to figure this out, its the last i need for my game!…
so awesty,
if(wood_Alpha
if(wood_Alpha
so
if(wood_Alpha
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
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.
ya i agree with katy youv’e posted 16 comments in the last few days.
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
hi i really need to know - how can you tell how long you need to make your pre loader?
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.
@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.
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?
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.
oops. Ive been animating them lol. Can you tell me how i can make one properly?
@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.
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?
So awesty, sorry for bothering u again, but this code should work then?
_root.Variable
if(wood_Alpha
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
hm a bug accoured…
this is the code
_root. Variable
if(wood_Alpha
You can’t use LessThan brackets, because of hacking problems.
Ill try to help with questions. Make sure you post the errors AND the code that made the errors
@Bryce: Is the sound on a timeline or done through actionscript?
@seerex: It isnt a bug, read grifos comment.
Hi peepz. I’m going to start a big game project soon and want the graphics, sound fx, and everything to be prfect
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!
yay got a nintendo wii with zelda and wii sports,
but need to wait fifteen days before my birthday to play it lol! arghhhhh
ha ha lucky
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…
@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.
@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.
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
roger
didn’t work
>_<… dont get offended by this, but is your volume up?
ha ha, yah it’s on
ill try it again 
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)
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.
sounds cool. Iv’e always wanted to put my flash games on some form of console apart from a computer as it looks professnial
the fact that i can’t open my wii for another 13 days doesn’t help lolz 
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
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.
@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. :\
Well iv’e already started making a basic first person shooter with enemies and sound for the wii
Cool. Cant wait to see it ;D
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…
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
@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.
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
You need to declare your variabels with either _root. or _global..
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?
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..
hey RDB can’t wait for your first person shooter coming out you really inspire me lol
: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.
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?
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!
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?
Awesty,
its still not working
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!
@seerex - if you send me the fla file, i might be able to help.
sure thing, whats ur e-mail?
You cant have the same instance name on more than one MC.
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.
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.
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
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 
umm… well make sure there are enough frames to play the song. ANd set it to stream.
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.
Yea, that makes sense and could be a problem.
Umm… i did that
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 -_-
yes yes yes!!! I figured it out it was on flash 5 settings
whoops
haha lol.
hey any help on my preloader problem? it’s driving me mad :S
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.)
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.
wooo finally got to open my wii a few days earlier
the zelda game is fab but kinda hard
Hehe, I heard its great but very long!
@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 : (
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.
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) {
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.
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
@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?
ya i put in
onClipEvent (load) {
// When the mouse is released on this button…
on (release) {
then the rest of the code.
lookin forward to seein other ppl’s work bryce, like yours but wait til u see one of my games
@Bone: You dont need the onClipEvent(load) outside of the on(release), you need to close the load first.
@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 =)
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?
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
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 
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
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?
Seerex you could try this
onClipEvent(enterFrame){
if(this.hitTest(_root.WHATEVER)){
_root.gotoAndPlay(nextScene);
}
}
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.
@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
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.
ive got little sound fx and i draw all my buttons, art etc, i was looking at the fla file anyway. Thanks.
Okay dokey here u go
http://www.deviantart.com/devi.....n%3Ascraps
http://www.deviantart.com/devi.....n%3Ascraps
Here u go
?? umm sorry if i posted twice my computer is running slow
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.
A MMO made in flash?
Sounds interesting.
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..
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
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..
oh, works now.. sry
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…
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 ****”..
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.
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…
@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
@Awesty: how hard is it to put a file on internet?
ive followed the guide, started over, 10times or something. .still not working! =/
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.
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.
Ah double comment cause i pressed stop because i wasn’t finished typing…
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
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)
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 ^_^
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.
And Awesty i saw you skip people’s comments before please don’t skip mine like 6 or 7 comments above
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.
OK i found your email = awestyproductions[@]hotmail[.]com
… i can’t email you… ill try figuring out my self…
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.
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 )
@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
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.
@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.
@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. >_>
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?
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.
It works, thanks so much.
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.
There now i delete all remote info.
and the entire page.
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.
Just use a
thevar = Math.random(4);
if(thevar == 1){
gotoAndStop(attack1frame);
}
and so on…
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)
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.
Well just click here i don’t want to post it again until you see it.
http://kfb-zone.com/Gaming%20tutorials.htm
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.
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.
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?
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!
@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.
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
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?
hello? awesty? are you still there?
@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.
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?
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?
@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.
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) =)
I done everything i think but it doesn’t work at all none of the buttons work and they dont attack
@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. >_>
Thanks. =) Also, love the tutorial
I will put a link to my game when it’s finished
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.
um how do i get to instance names?
It is in the properties panel down the bottom to the left.
Yhis tutorial sucks!!!! The enemy is stronger and after you die you dont die!!! You need to fix this tutorial
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
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.
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.
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?
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.
thank you thank you sooo much, you are the best
YOU ROCK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
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
Um… i’m 12 years old so this answer might not help ya, but couldn’t you try:
on (release) {
if (_root.”A”
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.
your tutorial is awesome.
my dying animation won’t work.i already looked at everyone else’s questions but still wouldn’t work.
Well… if the scripts above didn’t work…. you might wanna try:
if(_root.hp
Hopefully someone will see this…
Can someone tell me where to put:
if (_root.hP
if (this.hP
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
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.
I just don’t understand about making the blank frames because when I view the game it just shows nothing
I got the game working but I tried to make them die and I use this code on the main frame
if(_root.hP
if(_root.hP
well its the code you used
You cannot use the < or > sign.
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;
}
}
Well you should make it so the description only pops up if the shops window is equal to 100.
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 =)
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.
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
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 =)
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 =)
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
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 =)
Sorry didn’t help…
but thanks anyways.
Bryce can you help?
Oh and sorry it dosent flash it just sticks on one frame so i can’t really do anything after the battle
I REALLY NEED HELP
Could you show me your code please?
well the old script was:
On the first frame:
stop()
if(_root.hP
????
It didn’t post the whole code!
anyways on the first frame its:
stop()
if(_root.hP
WTF!!!!
Awstey i’ll just email you it. or the flash file.
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?
Try using the random(x) function.
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
You need 2 equal signs.
if (_root.turn==1) {
this.gotoAndStop(1);
} else if (_root.turn==2) {
etc..
Please. does anyone have the code for magic. whenever my mp reaches zero i’m still able to attack.PLEASE!!!!
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??????????
:”(
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.
What version of flash are you using?
Flash Professional 8
Are the buttons button symbols or MovieClip/Graphic symbols?
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???
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
wtf im so confused ive tryed everything twice and yet wen i click attack my man just freezez
That is strange.
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?
Try learning about hitTest() and gotoAndStop().
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));
Try:
if(_root.man.hitTest(_root.enemy)){
gotoAndStop(2);
}
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
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
}
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:)
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).
Okay I have replied to your email.
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.
Did you put a stop action on frame 69?
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?
Which version of flash are you using?
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. (?)
Well it came out in 2004 obviously
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).
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
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.
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.
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
Did you put a gotoAndStop(1) action on the enemies last attacking frame?
yes! i follow all the tutorial!
do you want the fla. file?
Okay, if you send it to me I will try and see what the problem is.
here it is:
http://rapidshare.com/files/68007341/fight.fla
sorry awesty! i figerit out!!
i forgot to give an instance name to the enemy! sorry for bothering you!
okay, I’ll send you the fla, its a little dodgy but everything works alright except the gotoAndStop?function

sorry to keep bothering you.
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!
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
mine is really screwed up and I dont know why, can somebody tell me
http://rapidshare.com/files/73.....1.fla.html
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!
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)
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
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?
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?
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
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.
_global.turn = false;
_global.waiting = false;
_root.ehP -= random(12)+7;
_root.man.gotoAndStop(2);
that should be what you need.
but where is that code (the enemy health bar, you, a button… etc.)
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.
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.
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.
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?
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….
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.
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
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
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
why did it cut down my comment?
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.
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
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.
i’m sorry man, but this tutorial isn’t working at all.
What seems to be the problem Beppe?
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.
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.
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
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.
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)
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
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?
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.
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?
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 ^^
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
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!
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.
How do you make it so it shows a win or lose screen? Please say where to put the actionscript.
i liek smelly peehnus
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.
everytime i play it the it keeps looping the enemys attack animation
http://rapidshare.com/files/422794020/game.fla
what am i doing wrong
nvm i figured it out