hi guys, just wondering if u could take a look at my simple AI. I know the problem is sumthing simple but i cant find out whats wrong with it. Any help would be great, thanx.
action = Math.ceil(Math.random()*100);
aTimer = 0;
eattack = false;
//
function enemyAttack() {
aTimer++;
if (aTimer == 180) {
aTimer = 0;
if (action>=0 && action<45) {
_root.dino.gotoAndStop("walk");
eattack = true;
//
} else if (action>=45 && action<70) {
_root.dino.gotoAndStop("chomp");
eattack = true;
//
} else if (action>=70 && action<100) {
_root.dino.gotoAndStop("tailslap");
eattack = true;
//
} else {
_root.dino.gotoAndStop("stand");
eattack = true;
}
}
}
if (eattack=false) {
enemyAttack();
}
i traced the aTimer and it duznt count up so for sum reason the timer isnt being initiated. hope that helps.
system
July 26, 2004, 12:56pm
3
action = Math.ceil(Math.random()*100);
aTimer = 0;
eattack = false;
//
function enemyAttack() {
aTimer++;
eattack = true;
if (aTimer == 180) {
aTimer = 0;
if (action>=0 && action<45) {
_root.dino.gotoAndStop("walk");
//
} else if (action>=45 && action<70) {
_root.dino.gotoAndStop("chomp");
//
} else if (action>=70 && action<100) {
_root.dino.gotoAndStop("tailslap");
//
} else {
_root.dino.gotoAndStop("stand");
}
}
}
if (eattack == false) {
enemyAttack();
}
ok i fixed that, but now it just counts to 1. any help?
system
July 26, 2004, 4:46pm
4
Change the first line to this:
action = random(100)+1;
system
July 27, 2004, 2:01am
5
hhmm. its still not working. i attached the FLA with sum quickly drawn graphics.
system
July 27, 2004, 1:49pm
6
I don’t think I can help. I don’t have flash on this computer and the internet isn’t working on mine. Someone else will know.
Nevermind. It’s working now. I don’t know why, but this works: