class milkacow : public creature { public: milkacow() {} milkacow(milkacow *parent); creature* newcreature() {return new milkacow(this);} void choosejob(); char shortkey() {return 'c';} }; milkacow::milkacow(milkacow *parent) : creature(parent) { species=MILKACOW; hitpoints=410; power=10; health=100; speed=300; diet=atdiet[GRASS]; terrain=atterrain[VOID]; preparecreature(parent); } void milkacow::choosejob() { job=TAKE; if (load!=VOID) { if (load==GRASS) job=EAT; else if (!random(2)) {dir=random(4);job=RUN;} } else if (p[xcoor-1][ycoor]==GRASS) dir=WEST; else if (p[xcoor+1][ycoor]==GRASS) dir=EAST; else if (p[xcoor][ycoor-1]==GRASS) dir=NORTH; else if (p[xcoor][ycoor+1]==GRASS) dir=SOUTH; else { if (!random(100)||!(terrain&atterrain[p[xcoor+dx[dir]][ycoor+dy[dir]]])) { dir=random(4); for (int prut=1;prut<4;prut++) if (terrain&atterrain[p[xcoor+dx[(prut+dir)%4]][ycoor+dy[(prut+dir)%4]]]) {dir=(dir+prut)%4;} } job=RUN; } if (job==RUN&&food>weight*2.5&&random(10)) job=MULTIPLY; if (!random(50)) {dir=random(4);job=RUN;} }