void rpgent::update(float playerdist) { updateprojectile(); if(state==CS_DEAD) { stopmoving(); return; }; if(blocked && npcstate!=R_BLOCKED && npcstate!=R_SEEK) { blocked = false; conoutf("DEBUG: yaw=%i targetyaw=%i", yaw, targetyaw); gotoyaw(targetyaw+90+rnd(180), R_BLOCKED, 1, 1000); } if(ro->s_hp<ro->eff_maxhp() && npcstate!=R_SEEK) gotopos(enemy->o, R_SEEK, 1, 200); #define ifnextstate if(trigger<lastmillis) #define ifplayerclose if(playerdist<64) switch(npcstate) { case R_BLOCKED: case R_BACKHOME: ifnextstate goroam(); break; case R_STARE: ifplayerclose { if(ro->s_ai==2) { gotopos(player1->o, R_SEEK, 1, 200); enemy = player1; } else { gotopos(player1->o, R_STARE, 0, 500); } } else ifnextstate stareorroam(); break; case R_ROAM: ifplayerclose transition(R_STARE, 0, 500); else ifnextstate stareorroam();
void reset() { physent::reset(); stopmoving(); loopi(MAXANIMPARTS) animinterp[i].reset(); }