PDA

View Full Version : RPG Moving character with NPC's



zipperdeaf
May 1st, 2006, 09:33 PM
Im using the RPG game tutorials code for moving my character:
//////////////////////////////////////////////
onClipEvent (load) {
s = 3;
b = this.getBounds(this);
function move(x, y) {
if (_root.stopwalk == false) {
if (!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)) {
if (!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)) {
if (!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)) {
if (!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)) {
_x += x;
_y += y;
}
}
}
}
}
}
}
onClipEvent (enterFrame) {
keydown = false;
if (_root.stopwalk == false) {
if (Key.isDown(Key.UP)) {
keydown = true;
_root.hero.gotoAndStop(1);
move(0, -s);
}
if (Key.isDown(Key.DOWN)) {
keydown = true;
_root.hero.gotoAndStop(5);
move(0, s);
}
if (Key.isDown(Key.LEFT)) {
keydown = true;
_root.hero.gotoAndStop(2);
move(-s, 0);
}
if (Key.isDown(Key.RIGHT)) {
keydown = true;
_root.hero.gotoAndStop(4);
move(s, 0);
}
}
if (!keydown) {
_root.hero.char.stop();
}
}

/////////////////////////////////////

I need to figure out how to add an npc. Also if there is a better way I can have this character walk according to the art based walls its from what i see not supported with anything above flash 5.
35650

zipperdeaf
May 2nd, 2006, 09:57 AM
Any help would be rad:-/

KIERIOSHIMOTO
May 2nd, 2006, 10:12 AM
Whats an NPC?

Lord Rahl
May 2nd, 2006, 11:38 AM
Whats an NPC?
None Playable Character

Joppe
May 2nd, 2006, 02:49 PM
What kind of an npc? Like one following you? one being talked to ? etc..

zipperdeaf
May 3rd, 2006, 06:33 AM
I fixed it using Marz's method of the artbased RPG, would anyone know a good way to make them (the NPC's - people with blue hair) be able to walk and not hit the walks randomly. I guess the same script im using for the hero and just have it not be detected by the keys and a random number?

InfestedDemon
May 3rd, 2006, 03:24 PM
reminds me abit like pokEmon, great job!

zipperdeaf
May 3rd, 2006, 04:30 PM
Thanks, there are cool backgrounds in there making it look more gameboy/nintendo ish, but anyone have a good idea on how to move the ai characters around, such as in pokemon or any rpg game?

Nich
May 3rd, 2006, 04:45 PM
It's much easier to do tiles in this sort of game because then you could just tell the ai to move thet character 1 tile up instead of 100 (or so) pixels. What you could do is use the same move function, and then just use Math.random to create timers, and randomise the direction (dir[0] = "right", dir[1] = left, etc.). Keep count of how far you've moved, and then stop moving when you have walked far enough. (either randomly, or fixed depending on if you want a tile based feel even though it's art based)

zipperdeaf
May 3rd, 2006, 09:42 PM
Yeah thats how i think its going to work im just working on the code to do it. thanks

Ravmaster
May 5th, 2006, 02:00 PM
hey uhh how did u get the talking bit to work?