PDA

View Full Version : ai problems



mordormaster
May 12th, 2008, 02:46 PM
hiyar, well its been two months and my game has come along in leaps and bounds until now, i had a basic ai system ready but i seem to have alot of faults with it.

1.)The enemies can go through walls

The enemies can walk straight through walls and basicly i have no idea how to stop them doing that

2.)The enemies dont attack

I tried adding a hittest inside it to play an arm symbol and it will not attack the character

3.)For it to work things must be a certain way

The code means that the character must be in the exact center of the map

i was wondering if anyone could fix any of these problems for me
thank you in advance

mordormaster
May 18th, 2008, 12:47 PM
Could anybody help me please?

therobot
May 18th, 2008, 05:48 PM
i don't actually understand what your problem is, mordormaster. You have a laundry list of things you have no idea how to do, and you keep making a new thread every month or so to see if someone can fix your fla and send it back to you.

You have got to start putting your code in one place instead of on movieclips if you want people to begin to sort through it for you. It's kind of a mess right now.

bpalermo
May 18th, 2008, 07:41 PM
BY the way, I got an unexpected file format error here...

mordormaster
May 19th, 2008, 09:06 AM
The file format is flash cs3. i only need one or two of thouse problems fixed, i created alot of other things for the game im making but so far only ai is not working for me, now i have got the enemies walking but they still wont attack, i cant creat a hittest that works for it.

bpalermo
May 19th, 2008, 10:50 AM
I still use Flash 8...

bluemagica
May 19th, 2008, 10:53 AM
i also use flash8, and i dont plan on using cs3 anytime soon, instead i will move on to something like flashdevelop which is meant for coding alone...

Anyway, mordormaster, if the code is in as2, then convert the file to fl8 and show, else put your code right here.

mordormaster
May 19th, 2008, 04:38 PM
i have converted it to flash 8 format now, but incase that dont work here is the code for the ai itself :)




onClipEvent (enterFrame) {
var herox=(_root.map._width/2)-_root.map._x;
var heroy=(_root.map._height/2)-_root.map._y;
// determine the distance using pythag's theorem
dist = Math.sqrt( Math.pow( this._x - herox, 2) + Math.pow( this._y - heroy, 2) );
// only chase if within 200px, and stop if touching
if(dist < 200 && dist > this._width){
// determine the angle between the hero and the enemy
angle = Math.atan2( heroy - this._y, herox - this._x );
// rotate enemy to face the hero
this._rotation = angle * (180 / Math.PI);
// move the enemy along the vector that leads to the hero
// adjust the value of 5 to change the speed
this._x += Math.cos(angle) * 5;
this._y += Math.sin(angle) * 5;
}else{
// normal enemy movement when not chasing goes here
} //if
}

mordormaster
May 23rd, 2008, 11:59 AM
right i have fixed the walking through walls and made it attack but i need to be able to make it go for the center of the screen, so far if i make my map any bigger than 700 pixels by 700 pixels it just wont work, can anyone help me?