Okay, I have looked at the code a little more and have determined that object 102 is you and 104 is the enemy, while 105 is the bullet to be fired...
But there are other concerns as well here. The first is, you can't print "shoot" in the same manner as you're printing "dist" unless it too is a global, since I'm assuming you want it to say "1" is aialert() is trying to fire. That's the same problem as you had with dist, it's not global unless you've declared it as such and setting a value inside a function does not mean it gets passed to the total program for the same reason. So for that you'd need;
shoot=aialeart(dist)
print shoot
if shoot = 1 then aishoot()
And while we're on the variables here, the aishoot will only show the bullet if bulletfire equals zero, and then will decrement the value to 99 and leave it there forever! Why? Because the decrement command is inside the same if condition. Unless you have another place in your main loop where you decrement bulletfire and advance the bullet movement, then reset bulletfire back to 100, the bullet will never move. And that TOO must be declared as global, because the value will be ZERO when the aishoot() function starts if it is not.
So, assuming you've made all these values globals... let's see why your distance value isn't changing.
For that, I am assuming that the value of 1000 or even 3000 is "too close." What I mean is, the player and the enemy are "within range" of shooting at each other if you set a value of 1000 or 3000, so the enemy object tries to "follow" the player constantly. This means that dist will always be the same value as the player moves, (unless you move closer to the enemy) because the enemy is changing position with the player.
Try setting the value to like 500 or 100 -- meaning you have to get *really close* before the enemy follows you, which takes place in aialert(). Then you should see dist change as you move around, until you get close enough to have the enemy start following.
Good luck...
s.
Any truly great code should be indisguishable from magic.