Making an RPG type game 2
In this tutorial, we will be continuing the last RPG game tutorial. If you haven’t already taken it, you can find it HERE.
In this tutorial, we will be learning how to communicate with people. So when you are close to them, you can talk to them.
You can see an example here. LINK
First of all, open up the file from last time and draw the person you want to communicate with. This is what mine looks like:
Make it a MC (Movie Clip) by hitting F8, and use the following settings:
Now make another MC, the same width as your other guy, but about 2.5 times longer than him. Select it, open the properties panel and make its alpha 0.
Now, you need to make another MC. This one is going to contain the text. Make the first frame of the MC blank, the 2nd have a message like “Go and pick up the sword” and the 2rd have a message like “Good job!”. Give this and instance name of msg.
Now place this code on the invisible box.
if(_root.man.hitTest(this)){
if(_root.smallItem._alpha > 0){
_root.msg.gotoAndStop(3);
}else{
_root.msg.gotoAndStop(2);
}
}else{
_root.msg.gotoAndStop(1);
}
}
Okay, the first line you should know. It basically means ‘When this frame is entered, do the following code. Line 2 is a if statement. It checks to see if the code in the brackets (’(’ & ‘)’) is true, which is if the ‘man’ MC is touching it. If it is true it does the following code, if its false it does the else statement if there is one.
Line 3 is checking if the ’smallItem’ (the sword in the inventory) has an alpha over 0. If it does it makes the text go to the 3rd frame, otherwise it goes to the second.
If line 2 is false, line 9 runs, which makes the text go to frame 1.
Now put this code on the guy you just made.
if (_root.man.hitTest(this._x+(this._width/2), this._y, false)) {
_root.man._x += 3;
}
if (_root.man.hitTest(_x-(_width/2), _y, true)) {
_root.man._x -= 3;
}
if (_root.man.hitTest(_x, _y+(_height/2), true)) {
_root.man._y += 3;
}
if (_root.man.hitTest(_x, _y-(_height/2), true)) {
_root.man._y -= 3;
}
}
That is so ‘man’ can’t walk over the other guy. For an explanation on that code take this tutorial:
http://www.awestyproductions.com/tutorials/flash-tutorials/using-hittests-part-2/
Thanks for taking this tutorial!















Hi! This tutorial is great. I have been looking for this and was getting frustrated. Then I saw this. Thankyou!
(Check out kmy deviantart page, I made a game called RatAttack using this tutorial and made a link to this website!)
Wow, thanks this is just what I wanted. Now to go test it out!
hi, yet another great tutorial! Very useful indeed for all these RPGs every1 wants to make.
Ty!
these tutorial are getting better every day! :D:D
thanks for posting this tutorial, ive almost complete my RPG but have one question that i need to know before i can complete it.
I am looking for the code that you would put on an MC, and if a man hits it, and he has a certain number in a variable, say reputation 6 then it would take you to a different frame.
thankz.
oops, sorry to double post but i remember another question i had. Could you maybe explain, or create a tutorial on how to make it so that when you click a button, like if you have a certain ammount of money you can buy clothes, and they would be added to your mc? I tried doing what i thought would work with alpha but im not sure how many MCs i should have and where to put them. Aby help? thanks awesty
@rrr444: the code would be something like:
onClipEvent(enterFrame){
if(_root.man.hitTest(this)){
if(_root.reputation == 6){
_root.gotoAndStop(2);
}else{
_root.gotoAndStop(1);
}
}
}
@rrr444 & eb264: But if it is just a variable, you might not need the _root in front of the reputation.
onClipEvent(enterFrame){
if(_root.man.hitTest(this)){
if(reputation == 6){
_root.gotoAndStop(2);
}else{
_root.gotoAndStop(1);
}
}
}
my birthday is January 8th, 2007
heh..my birthday is Janurary 7th
Well I have a question..ive started on an RPG not to long ago..and have tryed to do just this!
finaly I have something to read and learn from.
Ok I have tryed it out and it works like a charm!! thank you for that, but I have a little problem tho.. when the text msg comes up and I walk away..the text msg stays up?? it does not dissappear?? once I pick the sword up and return to the guy..the text msg changes and then also stays there..even if I walk away?
How do I sort this weirdness out??
your tutorials are helping me greatly..its people like you that inspires me to make games.
Make sure you have this:
}else{
_root.msg.gotoAndStop(1);
}
That should work if it is there. Btw happy brithday you two
*sings* haaaapppyy birthday to youtwo haaaaapppyy - Screw this I got to go to school.
Btw awesty, I have an awesome game comming out soon that will knock the socks off you! It’s like a destruction derby. But that’s all I’ll say
hello once again, thanks for the happy birthday

Do you know how to work this?? if so..could ya give meh a hint or 2 
ok..This is the code iam using:
onClipEvent (enterFrame) {
if (_root.man.hitTest(this)) {
if (_root.smallItem._alpha>0) {
_root.msg.gotoAndStop(3);
} else {
_root.msg.gotoAndStop(2);
}
} else {
_root.msg.gotoAndStop(1);
}
}
Its what you told meh to do..but it dont work for me..iam wondering if ive done something wrong there..ive checked it myself and looks fine so I dont know why it fails to work right.
Its anoying me
Also..another thing I cant master either..is if I pick the sword up..it ends up in an inventory slot..now in your last tutorial a guy came along and gave the code to work it out..but I dont get it and cant get it working
Bob, I made a crappy destruction derby, 4 cars driving around and you have to bash them
ya another good tut. thanks.
@Irish_PXzyan:
Just send the .fla to
awestyproductions[@]gmail[.]com
And i will check it out.
OK awesty, its another cool tutorial, but i wonder, will there be a part three?
cuz if there is, ill be looking at it
There might be if there is something I can add. Any suggestions?
you need to make it so you can use the sword
I have one maybe,you could make it so when u push say…spacebar,and your near the sword,it picks it up,and have him only able to talk if he pushes spacebar….make SB a action button.
I know this sounds simple but weilding the sword if clicked, and cutting something with it to move on to next lvl.
Yea, i might do a tutorial like that.
Ok thanks, I sent you an email of the file..In the file I had to add a button so that when you click the button then the message dissappears..but I dont like it that way
This looks very like the tutorials you did..same graphics and stuff! so you will know your way around 
I have a problem. When i walk into the guy the message says well done you have the sword, when i don’t. And when i go over and pick up the sword, it doesn’t appear in the inventory, but it disapears and the man says well done. It might be because i have flash MX educational, im not sure. Can anybody help me? Thanks.
@Irish_PXzyan: Okay, I will have a look at it.
@RDB2006: Is it Flash MX or Flash MX 2004?
It’s flash mx 2004
hey next tut do movie clips in movie clips
iam haveing truble with puting the ht invisble platform and words inside the random guys movie clip
help
Gay!
hey awesty
another great tutorial
im only 12 but i am gettin the hang of it
i took ur two tutorials and tried to add
my touch
i added a bow
a more storylinish play
ability to equip wepons
and best of all
the feature to move around the map
i made it so u could roam around
anyways
if u want my version
i could email it to u
and feel free to use my scipting and such
in other tutorials
thanks for this tutorial
Hi awesty thnx 4 tut. but i want t ask how we can make a feature like when the guy meets a creatue a dueling screen should open up
@RDB2004: Just email the .fla to awestyproductions[@]gmail[.]com
@Hugama: Yea sure. Feel free to email it to me.
@tuty: Have the battle screen on a different frame, and then have:
if(this.hitTest(something)){
gotoAndPlay(FRAME);
}
This was a good tutorial. I am learning flash from 2 yrs but still a beginner(I’am only a kid of 13 yrs.).Can you tell me how to make a pet game, in which we should feed him,play with him etc.
hey, hi again awesty,(im just asking not requesting) but will there be an “making-an-rpg-type-game-3″?
nice tutorial but ive got big problem ive followed your tutorial and it works fine but
i have it so when you go up to the guy you and
you have the item he gives u another item but when i made another person to trade it with( the new item) it just does nothing
@abhilash: No, I can’t just tell you. You will have to try and figure that out yourself.
@KIM: Possibly.
@andrew: Just send the .fla to
awestyproductions[@]gmail[.]com
I’m 14 and i’ve been doing flash for
about 2 years now.
I stumbled across your tute and think it’s
really cool.
I’m going to school the day after tommorow
and thought i’d post…=)
I would like to see a more advanced look to this
eg:
More boundries
Money
Enemies
Quests
Spells …etc
And i may help on some of these.
If you post back which i doubt than i will
try to get back to you asap.
For those newbies =)… good luck for the future
of your programing.
Anyway it’s getting late and im gonna go to
sleep…so goodnight for me =(
Signing Off
Master MX’er
PS: Lol for my name
=)
This is just copy/paste with no explinations! It’s also really short. You could just make a full tutorial instead of making people wait and come back later…
hi awesty, ehm, i have a problem.. when im done and test it, the text doesnt appear.. i cant walk through him, but the text doesnt appear.. also i dont understand what “the invisible box” is.. which one?
thank you for a great turotial, im learning much
Is it possible to make a battle system? like dragon fable and adventure quest (yes i know they are way past most of our league) but a simpler one. if so how. i’m new at this so bear with me, im used to coding text based games but the code in flaash looks similar. So how do you do it?
@Master MX’er: Uh… If you have been doing flash for 2 years you should be able to figure some of that out for yourself. I have had flash for a year, but haven’t been using AS the whole time.
@Flash Sandbox: The reason this is part two is because people requested it, I wasn’t planning on doing this tutorial. Also, there ARE explanations, but on the last one there isn’t since I have already explained it in a different tutorial so I just linked there.
@Seerex: You need the invisible box so the text will appear. Have a look at the third picture and you will see a box on the guy you talk to. Give that 0 alpha. Then put the first block of code on it.
thanks alot, all works now, well i hope u are gonna give another tutorial with the RPG thing..
also, isnt there another way of making the “inventory system” so u dont need to just take the alpha down and stuff, and is there a way to make “inventory full” and stuff? also, last question, how do i make it jump to the “game over” frame when the HP bar reachs “0″
I dont know what you mean by Inventory full, but there are otherways to make an inventory system.
To go to the game over frame, try:
if(_root.hp <= 0){
_root.gotoAndStop(GAMEOVERFRAME);
}
Just put the frame number between the brackets where it says GAMEOVERFRAME.
nice tutorial but please put as soon as you can a tute with attack. You know, how to attack a thug for example and win rewards, a scrolling map, buy armor, weapons. Please don’t think I’m a critic but your tutes are awesome! thanks
Uh… you should be able to figure all off that out from my other tutorials. You will just have to edit the code a bit.
the inventory thing does not work for me, i have Flash Mx 2004, can u send me a different way to do it
@Rober F. I do not use MX 2004, but I believe it should be the same code, once both of them (MX 2004 and
use Action Script 2.0. There might be something diferent on your code.
Awesty, I think you could make some tutorials on advanced AI programming, I know you use AS2(and I don’t) but there are no big diferences. In fact, almost all your tutorials can work for people that use AS1.What I’m asking for is just a usual tutorial, not getting into the game itself, as we already know you won’t, but actually giving us a generic code so we can work it out and find what we need by ourselves.
Thanks in advance.
The only problem is that the caracter can walk out of the frame
ya thats right
@Robert F.: If you follow the tutorial it will work. You need to take part 1 for the inventory system.
@Grifo: Sure. I am going to do one on trig soon, so I could do an AI one involving trig.
DUDES… PLZ HELP!! i would be vey happy if someone of u guys could send me ur .fla rpg-game.. cause mine doesnt work….
Just figure it out for yourself. It seriously isnt that hard.
What about this:
The W key should get the bow ready, and if it already is, it will “disarm” it(it’s late at night here and I can think in english properly).
I fire arrows with the A key,(of course, only when the bow is on hands).
I need the character to have a different animation when he is with the bow on hand and when he isn’t.However, I want two other animations:when getting the bow and when disarming it, both activated when pressing W(like on/off).
Can you please show me an example on that?
I’m looking forward to your reply, and sorry if it doesn’t make any sense.
It makes sense, but I dont really feel like coding it atm. :\
It could easily be done with a bunch of if/else statements.
Okay thanks. I’ll see what I can do. See ya.
when is the next tutorial gonna be out
Well since school is back, maybe not for a few days.
Hi awesty! I looked at your tutorials and they are awesome! All kinds o’ game tutorials that a website needs. I wanna say that I’ve got a problem ; I looked in the whole Internet but nothing ; maybe u could help me :-). I wanna add to my game a character design stage, and when u press SAVE you could play with that character you’ve created. Could u figure out how to do? Thanks
There would be easier ways to do this, put this is the fastest thing I can think of.
Make all the clothes and everything a MC (which they should be) and on each frame put the different style. The when it comes to choosing, make flash remember which one they chose by putting it into a variable (easiest would be an array) and the on each new frame tell flash to do something like:
_root.man.shirt.gotoAndStop(array[0]);
_root.man.hair.gotoAndStop(array[1]);
_root.man.shoes.gotoAndStop(array[2]);
OK, but all of the clothing should be MCs and give them the Instance name of for example “hair1″, “eyes1″ etc.?
how to prevent the character from walking away from the monitor?
http://www.awestyproductions.com/tutorials/
Awesty, could you please make for me a character design in flash? If you do, I could figure out how to do it. Please send it to me at uzi_032000@Yahoo.com.
Im not going to design a character for you in flash. >_>
OK. Sorry for being so selfish.
but will u please ask my previous question? so I can understand it; I know you’re a lil’ mad at me
but….you’re flash experience is high and u know a lot
oops, sorry i didnt see it up there
Um… *tries to remember what he was on about*.
I think you have each shirt an MC, but they dont have to be, and put each one on a different frame in an MC with an instance name shirt for example. That would have all the shirts in it.
ok thanks, will the next tutorial show how to make such a thing?
I hope so….
iv been doing flash for 2 days and i got this WOOOO great tutorial
I’ve gone through all your tut so far, step by step. Great! Simple and easy, and very usefull
thanks for the good work!
Abhilash and Master MX’er, I can beat your age. I’m 12 and have been studying for Flash for almost a half year. >_>
know what Jay? I’m 15 and i work in Flash since I was 10!!
So that means you got no live Uzi? No friends to play with, only you and your flash….
@Uzi: Are you serious?
@wesley: Just because he has been using flash for 5 years doesnt mean he has no life. He might only use it once every few days.
yeah he’s right. And yes it’s true; I do work on flash for 5 years but i’m not very good at actionscripting.
could you plz give me the actionscript
so that i can move with arrow keys instered of the w a s d plz thank you plz email me at sirmadboy@gmail.com
@Charlie: http://www.awestyproductions.com/tutorials/
First tutorial listed I think.
Awesome tutorial, Awesty. It was very easy to do and extremely helpful for the animation project I’m working on.
My one question is,say instead of just collecting a sword, you want the playable character to collect four objects and THEN go to the other character in order to complete the job? I can use your first RPG tutorial easily to make it so the four different items go into the inventory correctly, but I’m not sure how to make them all part of the quest.
You could make a bunch of variables to check whether or not those things are true or not, and if they are then the quest is complete.
CAN YOU MAKE A TUTORIAL
WHEN YOU STEP ON A ALPHA 0 SYMBOLS OR SOMETHING YOU WILL TRANSFER TO THE NEXT FRAME
LIKE WHAT HAPPEN ON THE RPG’S
Lol you don’t really need a tutorial for that…
Type this on your main character guy….:
onClipEvent(enterFrame) {
if (this.hitTest(_root.”A”)) {
gotoAndPlay(”B”);
}
}
“A” - the instance name of the object with “alpha = 0;”
“B” - number of the frame you wanna go to.
Hope it helps =)
yeah i already guess about it before you
reply..BTW.
how could i use those QWERTYUIOPASDFGHJKLZXCVBNM keys on my game??
wow…. i’ve posted 2 comments for RAY and yet I don’t think that they are showing up xD…. oh well =/
Ok that one did apparently, so i’ll type it out a third time lol… Each letter has a number to represent it. For example:
W - 87
S - 83
A - 65
D - 68
and so on…
If you want to tell the user that if he presses “w” then the man will attack, the code on the man would be:
onClipEvent(enterFrame) {
if(Key.isDown(87)) {
_root.gotoAndStop(”A”);
}
}
“A” - the frame of which your little skit or scene of the man attacking.
Hope this helps =)
can you give me a pattern how it works??
btw do you know how to scroll a background without letting the hp or the inventory from scrolling too?
Pattern? You mean the pattern of the number on the key letter? If so, you can search it up on this site. It gives you all the numbers for them. As for your second question, you can search up awesty’s tutorial.
Its here: http://www.awestyproductions.c.....ackground/
If you have, then just make sure the hp and inventory are NOT part of the background.
Hope this helps =)
LOL I think that the first part of my answer makes no sense at all. I meant if your asking about all the numbers QWERTYUIOPASDFGHJKLZXCVBNM, what I found out is that if you hold ALT, and on your keypad on the right side of the keyboard type 65, A will come up. If you type 66, B will come up, so I’m assuming that 65 is A, 66 is B, 67 is C, etc.