1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include "milkacow.h"
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;}
}
|