void Zombie::runAI(Uint16 dt) { Dai+=dt; if (state&STATE_ATTACK) Dattack+=dt; else Dattack=T_Attack_Bite-300; if (Dai>T_AI_EFFECT) { if (state&STATE_ATTACK) { if (targets.empty()) { //shouldn't happen unsetState(STATE_ATTACK); } else { Player* target=*(targets.begin()); Uint16 dir=scenario->getDirection(getCenter(),target->getCenter()); dir&=~(DIR_UP|DIR_DOWN); if (dir&DIR_LEFT) setState(STATE_LEFT); else unsetState(STATE_LEFT); if (Dattack>T_Attack_Bite) { ai_attack(target,dir); } } } else if (state&STATE_LEFT) ai_left(Dai); else ai_right(Dai); Dai=0; } }
static int cfun_ai_check_attack(lua_State *L) { return ai_attack(L, false); }
static int cfun_ai_execute_attack(lua_State *L) { return ai_attack(L, true); }