if (!stbandit[i].Char.Moving) stbandit[i].Char.Walk(...);
I should have known this bit by now. Crimson advice was the same when he told me about checking if a character was animating and so on.
Enemies not following the player is not really a problem as long as they meet him and collide. The problem I'm facing now is that when the fight occurs it gets engaged super fast. I tried to counter this with a function that "pushed" character away a few pixels if they are hit:
function bpushed() {
int i=closestenemy;
stbandit[i].Char.FollowCharacter(null);
if (stbandit[i].name=="Bandit") {
if (stbandit[i].Char.x > stHero.Char.x) {
if (!stbandit[i].Char.Moving) {
stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);
AudioChannel* bhurt = abandit_hurt.Play();
}
}
if (stbandit[i].Char.x < stHero.Char.x) {
if (!stbandit[i].Char.Moving) {
stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);
AudioChannel* bhurt = abandit_hurt.Play();
}
}
}
if (stbandit[i].name=="Rat") {
if (stbandit[i].Char.x > stHero.Char.x) {
if (!stbandit[i].Char.Moving) {
stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);
AudioChannel* rpain = arat_pain.Play();
}
}
if (stbandit[i].Char.x < stHero.Char.x) {
if (!stbandit[i].Char.Moving) {
stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);
AudioChannel* rpain = arat_pain.Play();
}
}
}
mood=death;
}
My goal was to prevent characters from always colliding and it worked fine (not 100%) when I was using followcharacter; now the fights run super fast even if the "push" functions are being called.
Is the answer adding more checks to slow things down?