Very VERY simple AI problems AND another thing

So basically I had AI problems yesterday and I have it today. The Goblin is supposed to attack when the Hero gets to close.

Enemy.onEnterFrame = function()
{
if (Enemy._x - Hero._x >= 30)
{
trace(“ATTACK THE INNOCENT HOMES AND VILLAGES!”);
_root.Enemy.gotoAndPlay(Attack);
}
else
{
trace(“Peace”);
}
}

I think it’s jsut a problem with the goblin animation sequence, but I’m not entirely sure.

My other problem is in a different project of mine. It just doens’t shoot more than one bullet, I shoot once, and if I shoot again my first dissapears and my second one appears at my gun.

i = i+1;
var depth = 1;
onMouseDown = function () {
var b = attachMovie(“bullet”, “bullet”+depth, depth);
depth++;
b._x=MainHero._x, b._y=MainHero._y;
b._t = Math.atan2(this._ymouse-b._y, this._xmouse-b._x);
b.onEnterFrame = function() {
this._x += Math.cos(this._t)*9;
this._y += Math.sin(this._t)*9;


Enemy.onEnterFrame = function()
{
if (Math.abs(this._x - Hero._x)>= 30)
{
trace("ATTACK THE INNOCENT HOMES AND VILLAGES!");
_root.Enemy.gotoAndPlay(Attack);
}
else
{
trace("Peace");
}
}

the way you had it would make it so the enemy would have to have a greater _x, while the code i posted can be eather or

Oh I see. Thx Bomb. But do you know what’s wrong with the bullets?

is this your whole code?



onMouseDown = function () {
   var b = attachMovie("bullet", "bullet"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
   b._x=MainHero._x, b._y=MainHero._y;
   b._t = Math.atan2(this._ymouse-b._y, this._xmouse-b._x);
   b.onEnterFrame = function() {
      this._x += Math.cos(this._t)*9;
      this._y += Math.sin(this._t)*9;
   }
}

now you don’t have to worry about depths

No it’s not my whole code, it’s just my duplicating code which seemed to be the source of the problem…

MAN BomBsledder! Your a life saver, thx for the help with the bullets!

:hugegrin: :hugegrin: :hugegrin: :hugegrin:

glad to be of help