-
Senior Member
Originally posted by jorosdaman
oh well.....
the thing is, i dont want it to be just a random response. all i want to know how to do, is to check if what the player types contains a certain word. is that possible? i know that you can check for a whole string, ive done that before, but what about one particular section of that string?
here you go.
http://www.hot.ee/tonypa/flash/flas/talking.html
write something in the top text box and click the talk button.
Thats how it works:
declare arrays:
Code:
random_answer = [["My head hurts"],["I cant talk right now"],["Hello there, I am answering machine"]];
good_answer = [["Sword is good to kill enemies"],["Town is east from here"],["I cant help you"]];
keywords = [["sword"],["town"],["help"]];
so, we have 3 arrays. First for random answers, when no keyword is found. Second for answers at correct keyword and then the keywords.
keyword[0] goes with good_answer[0]
On the button:
Code:
on (release) {
answer = "";
answer_temp = question.split(" ");
for (i=0; i<answer_temp.length; i++) {
for (j=0; j<keywords.length; j++) {
if (answer_temp[i] eq keywords[j]) {
answer = good_answer[j];
break;
}
}
}
if (answer eq "") {
answer = random_answer[random(3)];
}
}
and the fla
http://www.hot.ee/tonypa/flash/flas/talking.fla
-
godly++;
tonypa, your a ledgend. I will try and understand tha code, and incorperate it into the game - thanks heaps.
[Edited by jorosdaman on 04-06-2002 at 03:52 AM]
-
thats freaking amazing! i never thought that that was possible.
-
ok. i have another problem. this one is reguarding events. I have this little scene where you get a reward for something that you did. once you get the reward I want you to be able to go and buy something with the rupees you received.
i was thinking about using the talking and random response code when you want to buy it. but i need to set it up so that the shop keeper will only say a certain response if you have gotten the rupees. i know i've seen this problem somewhat encountered before but i can't find where.
so basically it would need to work like
if event is done { say: here's your product; }
if event is not done { say: you do not have enough rupees to buy that; }
and if they say i would like to buy the product or something, then i need to shop keeper to drop an item, but this could be set up in events too!
if shop keeper says : here's your product { drop item; }
anyone know how to do this
on the same subject of the shops, i need to place a warp in the middle of the screen. so in the changing background mc (walkbale) i made a line with this code on it
Code:
onClipEvent (enterFrame) {
if (hitTest(_root.hero)) {
_root.hero._x =150;
_root.hero._y =290;
tellTarget(_root.floor) { gotoAndStop(17); }
}
}
this tells the non-walkable mc to go to room 17 where the shop is located. the problem is that the hittest with the non-walkable items won't work any longer...
anyone have any suggestions on this to??
[Edited by ZGOteddy on 04-06-2002 at 04:28 PM]
-
AI
I am having huge problems coding my enemies. has anyone successfully created enemies with AI?? I am wondering if the rpg makers of this board could see an fla to help us know how to do it or maybe MAD-SCI can continue a tutorial but this time on AI involved with RPGs...
-
Gross Pecululatarian
Well, I don't really know how to incorporate it with your code, but for an enemy to move around, he has ot be able to get feedback from his environment, so make a function where he can pass a movment, like (5,0) and it will return wheter that is valid or not. Have a variable that stores the current direction of movment, and have them always check what is ahead acoordin to it. Then, if it isn't valid chose a direction perpendicular to it. For enemies that want to attack the player, a simple test of if(enemy._x > player._x){enemy._x += 5; (only with some sort of delay to stop him from vibrating around the player when across from him.
For talking to the shop keeper, it really isn't that much different from tony's script, you just need to de a quick money check before the deal is confirmed. Make a variable with the shope keepers welcome text (maybe a few phrases) and chose one at random when the player isn't carrying any goods ( I take it this is a zelda style shop ) and if they are and are close, ask if they want to buy it if they have rupies (or do the check once they try to buy it, looks less smart though).
-
thanks for the help. but how would i set it up in any case:
where if an event happens such as someone gives you rupees, then something new can happen such as you can buy stuff with them. or for example you find a key, you can only go through a door with that key....
-
incredibulus-actionscriptum
well i am not very good with arrays but in this case i believe its a must
first of all you creating a game on the fly i mean you have to think about max number of iems,weapons and stuff
before you actually start the game not after nor in the midle of it , that's bad programming
now when you are infront of a door
have the door mc check using a for loop
the inventory array for a specific item
suppose you call it "key1"
if "key1" is inside the inventory array then set door_open=true;
then if door_open==true gotoAndPlay whatever you want
just an idea
cia
-
i think i get what you mean. but before i do that, i need to get something else to work. i have a village and in each 'room' or part of the village there are 2-3 shops that you can enter. you enter them by going over a line situated in the walkable screen. i need it to change the non-walkable frame to the shop room so i tried using this code:
Code:
onClipEvent (enterFrame) {
if (hitTest(_root.hero)) {
_root.hero._x =150;
_root.hero._y =290;
tellTarget(_root.floor) { gotoAndStop(17); }
}
}
this tells the non-walkable mc to go to room 17 where the shop is located. the problem is that the hittest with the non-walkable items won't work any longer...and even tho the frame that you were in disappeared dialogue messages pop-up when you walk around where the people once were...
anyone have any suggestions on this to??
-
lol. never mind i fixed my own problem...
-
incredibulus-actionscriptum
glad to hear it
what was it anyway?
are you planning to put this game on the web?
bcause its already over 90kb you know
i am sure it can be optimezed though !!
cia
-
im braking it down into levels. i dont really have very much to ad now except for some graphical tune ups and some enemies for the first level.
-
i have an rpg been working on it for like 2 months and it is coming along really good and all i used was simple codes and they are running good i dont know what the need is for all this code for a messenger all that mine would be like is
if yourmsg =="sword"
_root.msgtoyou="sword is good for stabbing things"
that is simple you should start simple before you try all these hard codes that are long and take a long time. but for people who are good you can keep doing that but for newbies and people who arent very experienced should try simpler codes.
-
personally, i dont think that the way tonypa set it up was hard at all. it is not complicated and works well as there is a random response and if there is a keyword in the phrase then there is a certain response. this makes the game seem like the NPCs have artificial intelligence... although the way u suggested would work also, it is much easier to expand tonypa's suggestion into a more in depth talking code....
-
ok new topic. this one is about ladders and hills and stuff. when you go up a ladder and hill your speed slows down... so we have to change the speed of the character. I was thinking of using a hit test to detect if the character is in the vicinity of the ladder, then change the speed to something slower and change the movie animation of the running character from running to climbing a ladder.
so
if (this.hitTest(_root.hero)) {
speed = 3; //speed was 5
tellTarget (_root.hero) {
if (Key.isDown(Key.UP)) {Ystep=-3;Xstep=0;
if (moving==false) {
moving = true;
this.ladder.gotoAndPlay(1); //ladder is the going up a ladder instance name
}
}
}
obviously this doesnt work. i was just fooling around with code and tried this. how would i set it up so that if key up is pressed then the hero moves up the ladder with the ladder animation slower then he would walk??
-
Gross Pecululatarian
Well, in your bit that makes the character normally move, do you have a speed variable? IF not, it would be usful to impliment it now, and for any other things, you could just say _root.zelda.speed = 3; (assuming it's called zelda ). As for walking, you could always make the walking animation about 30 frames long, (say you have three sprites, spread them out) and then, in your walking, move forward by the speed, so say this.animation.gotoAndStop(this.animation._current Frame + speed); And then, it will adjust to how fast he moves.
-
ok cool. that works for the speed. on top of that how could i adjust the character so that if you hit the ladder, then it plays the ladder climbing animation rather than the running animation. generally i just create a new layer in the hero walking script with all the animations in MCs inside it and each different animation type has an instance name such as sword, walk etc. i need to adjust the change the up animation for this hitTest. i just dont know how...do you understand what im trying to do??
-
I feel like an idiot because u guys talk about a this stuff I dont understand.
Anyways i would be really happy if someone told me the simplest way to have a wall and make your character stop using hit test
-
ok you need to have the hero in the _root directory and then in a new layer (the 3rd layer) make a walkable MC screen such as your background. so this will always appear as the background. then on the 2nd layer make a MC called back. then put in your background stuff that you dont want the hero to be able to walk over top of. then in the hero mc ad this action:
// collision with any non-walkable thing whithing the MC back
if (_root.back.hitTest( this._x+10,this._y,true)){this._x=old_x;}
if (_root.back.hitTest( this._x-10,this._y,true)){this._x=old_x;}
if (_root.back.hitTest( this._x,this._y+10,true)){this._y=old_y;}
if (_root.back.hitTest( this._x,this._y-10,true)){this._y=old_y;}
here's the fla:
http://zeldago.com/zeldawalk2.fla
(i think that this is a bit ilaborated version)
-
thank you that really helped
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|