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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include "lion.h"
lion::lion(lion *parent) : creature(parent)
{
species=LION;
hitpoints=410;
power=500;
health=100;
speed=500;
diet=atdiet[MEAT];
terrain=atterrain[VOID]|atterrain[GRASS];
preparecreature(parent);
}
void lion::choosejob()
{
int x,y;
x=xcoor;y=ycoor;
if (load!=VOID)
{
if (load==MEAT)
job=EAT;
else
if (!random(2))
{dir=random(4);job=RUN;}
}
else if (r[x-1][y]&&(r[x-1][y]->species!=LION||r[x-1][y]->status==DEAD))
{
dir=WEST;
if (r[x-1][y]->status==DEAD) job=TAKE;
else job=ATTACK;
}
else if (r[x+1][y]&&(r[x+1][y]->species!=LION||r[x+1][y]->status==DEAD))
{
dir=EAST;
if (r[x+1][y]->status==DEAD) job=TAKE;
else job=ATTACK;
}
else if (r[x][y-1]&&(r[x][y-1]->species!=LION||r[x][y-1]->status==DEAD))
{
dir=NORTH;
if (r[x][y-1]->status==DEAD) job=TAKE;
else job=ATTACK;
}
else if (r[x][y+1]&&(r[x][y+1]->species!=LION||r[x][y+1]->status==DEAD))
{
dir=SOUTH;
if (r[x][y+1]->status==DEAD) job=TAKE;
else job=ATTACK;
}
else
{
if (!random(10))
dir=random(4);
job=RUN;
}
if (food>weight*5&&!random(10))
job=MULTIPLY;
if (!random(20)) {dir=random(4);job=RUN;}
}
|