PDA

View Full Version : Pls. Help flash game AI



cain_1st
February 4th, 2007, 08:44 AM
pls. help the code below are for my AI the only thing can do is chase the player if it's in range and attack i need them to follow path and respown after 10 sec or so just like in warcraft3 dota pls. help or any links you can give thanks.

onClipEvent(enterFrame)
{
distance=200
rx=_root.player2whole._x
ry=_root.player2whole._y
erx=_root.monster2whole._x
ery=_root.monster2whole._y

if (Math.sqrt( (rx-erx)*(rx-erx) + (ry-ery)*(ry-ery))<distance)
{
if(rx<erx-20){
this._x-=2;
gotoAndStop("monster2left");
if(_root.monster2whole.hitTest(_root.player2whole) )
{
gotoAndStop("monster2attackleft");

}
}

else if(ry<ery-20){
this._y-=2;
gotoAndStop("monster2back");
if(_root.monster2whole.hitTest(_root.player2whole) )
{
gotoAndStop("monster2attackback");

}
}
else if(rx>erx+20){
this._x+=2;
gotoAndStop("monster2right");
if(_root.monster2whole.hitTest(_root.player2whole) )
{
gotoAndStop("monster2attackright");

}
}
else if(ry>ery+20){
this._y+=2;
gotoAndStop("monster2front");
if(_root.monster2whole.hitTest(_root.player2whole) )
{
gotoAndStop("monster2attackfront");

}
}
}
_root.monster2whole.m2hpcase._alpha = 0;
_root.monster2whole.m2hp._alpha = 0;
if(_root.monster2whole.hitTest(_root.player2whole) )
{
_root.monster2whole.m2hpcase._alpha = 100;
_root.monster2whole.m2hp._alpha = 100;
}
}

cain_1st
February 4th, 2007, 09:58 PM
any idea pls post trouble making it:bored:

Templarian
February 5th, 2007, 12:24 AM
your in the wrong forum... thats why no ones answering it. This is programming not scripting... :lol: look up a few forums and you will see Flash 8 or Flash Game/AI programming.

cain_1st
February 5th, 2007, 09:40 AM
ok sorry see you in my next post