Logo Search packages:      
Sourcecode: matrem version File versions  Download package

lion.cpp

#include "lion.h"

lion::lion(lion *parent=NULL) : 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;}
}





































Generated by  Doxygen 1.6.0   Back to index