Пример #1
0
void addscore(int n,Sint4 score)
{
  scdat[n].score+=score;
  if (scdat[n].score>999999L)
    scdat[n].score=0;
  if (n==0)
    writenum(scdat[n].score,0,0,6,1);
  else
    if (scdat[n].score<100000L)
      writenum(scdat[n].score,236,0,6,1);
    else
      writenum(scdat[n].score,248,0,6,1);
  if (scdat[n].score>=scdat[n].nextbs+n &&   /* +n to reproduce original bug */
      scdat[n].score<1000000L) {
    if (getlives(n)<5 || unlimlives) {
      if (gauntlet)
        cgtime+=17897715L; /* 15 second time bonus instead of the life */
      else
        addlife(n);
      drawlives();
    }
    scdat[n].nextbs+=bonusscore;
  }
  incpenalty();
  incpenalty();
  incpenalty();
}
Пример #2
0
bool hitemerald(int16_t x,int16_t y,int16_t rx,int16_t ry,int16_t dir)
{
  bool hit=false;
  int16_t r;
  if (dir!=DIR_RIGHT && dir!=DIR_UP && dir!=DIR_LEFT && dir!=DIR_DOWN)
    return hit;
  if (dir==DIR_RIGHT && rx!=0)
    x++;
  if (dir==DIR_DOWN && ry!=0)
    y++;
  if (dir==DIR_RIGHT || dir==DIR_LEFT)
    r=rx;
  else
    r=ry;
  if (emfield[y*MWIDTH+x]&emmask) {
    if (r==embox[dir]) {
      drawemerald(x*20+12,y*18+21);
      incpenalty();
    }
    if (r==embox[dir+1]) {
      eraseemerald(x*20+12,y*18+21);
      incpenalty();
      hit=true;
      emfield[y*MWIDTH+x]&=~emmask;
    }
  }
  return hit;
}
Пример #3
0
bool hitemerald(Sint4 x,Sint4 y,Sint4 rx,Sint4 ry,Sint4 dir)
{
  bool hit=FALSE;
  Sint4 r;
  if (dir!=DIR_RIGHT && dir!=DIR_UP && dir!=DIR_LEFT && dir!=DIR_DOWN)
    return hit;
  if (dir==DIR_RIGHT && rx!=0)
    x++;
  if (dir==DIR_DOWN && ry!=0)
    y++;
  if (dir==DIR_RIGHT || dir==DIR_LEFT)
    r=rx;
  else
    r=ry;
  if (emfield[y*MWIDTH+x]&emmask) {
    if (r==embox[dir]) {
      drawemerald(x*20+12,y*18+21);
      incpenalty();
    }
    if (r==embox[dir+1]) {
      eraseemerald(x*20+12,y*18+21);
      incpenalty();
      hit=TRUE;
      emfield[y*MWIDTH+x]&=~emmask;
    }
  }
  return hit;
}
Пример #4
0
void dobags(void)
{
    int16_t bag;
    bool soundfalloffflag = true, soundwobbleoffflag = true;
    for (bag = 0; bag < BAGS; bag++)
        if (bagdat[bag].exist)
        {
            if (bagdat[bag].gt != 0)
            {
                if (bagdat[bag].gt == 1)
                {
                    soundbreak();
                    drawgold(bag, 4, bagdat[bag].x, bagdat[bag].y);
                    incpenalty();
                }
                if (bagdat[bag].gt == 3)
                {
                    drawgold(bag, 5, bagdat[bag].x, bagdat[bag].y);
                    incpenalty();
                }
                if (bagdat[bag].gt == 5)
                {
                    drawgold(bag, 6, bagdat[bag].x, bagdat[bag].y);
                    incpenalty();
                }
                bagdat[bag].gt++;
                if (bagdat[bag].gt == goldtime)
                    removebag(bag);
                else if (bagdat[bag].v < MHEIGHT - 1 &&
                         bagdat[bag].gt < goldtime - 10)
                    if ((getfield(bagdat[bag].h, bagdat[bag].v + 1) & 0x2000) ==
                            0)
                        bagdat[bag].gt = goldtime - 10;
            }
            else
                updatebag(bag);
        }
    for (bag = 0; bag < BAGS; bag++)
    {
        if (bagdat[bag].dir == DIR_DOWN && bagdat[bag].exist)
            soundfalloffflag = false;
        if (bagdat[bag].dir != DIR_DOWN && bagdat[bag].wobbling &&
                bagdat[bag].exist)
            soundwobbleoffflag = false;
    }
    if (soundfalloffflag)
        soundfalloff();
    if (soundwobbleoffflag)
        soundwobbleoff();
}
Пример #5
0
void updatebag(Sint4 bag)
{
  Sint4 x,h,xr,y,v,yr,wbl;
  x=bagdat[bag].x;
  h=bagdat[bag].h;
  xr=bagdat[bag].xr;
  y=bagdat[bag].y;
  v=bagdat[bag].v;
  yr=bagdat[bag].yr;
  switch (bagdat[bag].dir) {
    case DIR_NONE:
      if (y<180 && xr==0) {
        if (bagdat[bag].wobbling) {
          if (bagdat[bag].wt==0) {
            bagdat[bag].dir=DIR_DOWN;
            soundfall();
            break;
          }
          bagdat[bag].wt--;
          wbl=bagdat[bag].wt%8;
          if (!(wbl&1)) {
            drawgold(bag,wblanim[wbl>>1],x,y);
            incpenalty();
            soundwobble();
          }
        }
        else
          if ((getfield(h,v+1)&0xfdf)!=0xfdf)
            if (!checkdiggerunderbag(h,v+1))
              bagdat[bag].wobbling=TRUE;
      }
Пример #6
0
void mondie(Sint4 mon)
{
  switch (mondat[mon].death) {
    case 1:
      if (bagy(mondat[mon].bag)+6>mondat[mon].y)
        mondat[mon].y=bagy(mondat[mon].bag);
      drawmondie(mon,mondat[mon].nob,mondat[mon].hdir,mondat[mon].x,
                 mondat[mon].y);
      incpenalty();
      if (getbagdir(mondat[mon].bag)==-1) {
        mondat[mon].dtime=1;
        mondat[mon].death=4;
      }
      break;
    case 4:
      if (mondat[mon].dtime!=0)
        mondat[mon].dtime--;
      else {
        killmon(mon);
        if (diggers==2)
          scorekill2();
        else
          scorekill(curplayer);
      }
  }
}
Пример #7
0
void drawexplosion(int n)
{

  if (digdat[n].bob.expsn < 4) {
    CALL_METHOD(&digdat[n].bob, animate);
    incpenalty();
  } else {
    killfire(n);
  }
}
Пример #8
0
void drawexplosion(int n)
{
  switch (digdat[n].expsn) {
    case 1:
      soundexplode(n);
    case 2:
    case 3:
      drawfire(n-curplayer,digdat[n].fx,digdat[n].fy,digdat[n].expsn);
      incpenalty();
      digdat[n].expsn++;
      break;
    default:
      killfire(n);
      digdat[n].expsn=0;
  }
}
Пример #9
0
void eatfield(int16_t x,int16_t y,int16_t dir)
{
  int16_t h=(x-12)/20,xr=((x-12)%20)/4,v=(y-18)/18,yr=((y-18)%18)/3;
  incpenalty();
  switch (dir) {
    case DIR_RIGHT:
      h++;
      field[v*MWIDTH+h]&=bitmasks[xr];
      if (field[v*MWIDTH+h]&0x1f)
        break;
      field[v*MWIDTH+h]&=0xdfff;
      break;
    case DIR_UP:
      yr--;
      if (yr<0) {
        yr+=6;
        v--;
      }
      field[v*MWIDTH+h]&=bitmasks[6+yr];
      if (field[v*MWIDTH+h]&0xfc0)
        break;
      field[v*MWIDTH+h]&=0xdfff;
      break;
    case DIR_LEFT:
      xr--;
      if (xr<0) {
        xr+=5;
        h--;
      }
      field[v*MWIDTH+h]&=bitmasks[xr];
      if (field[v*MWIDTH+h]&0x1f)
        break;
      field[v*MWIDTH+h]&=0xdfff;
      break;
    case DIR_DOWN:
      v++;
      field[v*MWIDTH+h]&=bitmasks[6+yr];
      if (field[v*MWIDTH+h]&0xfc0)
        break;
      field[v*MWIDTH+h]&=0xdfff;
  }
}
Пример #10
0
void digger_readdir(int n)
{
    Sint4 j;
    bool u=false,d=false,l=false,r=false;
    bool u2=false,d2=false,l2=false,r2=false;

    if (n==0) {
        if (auppressed || uppressed) {
            u=true;
            auppressed=false;
        }
        if (adownpressed || downpressed) {
            d=true;
            adownpressed=false;
        }
        if (aleftpressed || leftpressed) {
            l=true;
            aleftpressed=false;
        }
        if (arightpressed || rightpressed) {
            r=true;
            arightpressed=false;
        }
        if (f1pressed || af1pressed) {
            firepflag=true;
            af1pressed=false;
        }
        else
            firepflag=false;
        if (u && !oupressed)
            staticdir=dynamicdir=DIR_UP;
        if (d && !odpressed)
            staticdir=dynamicdir=DIR_DOWN;
        if (l && !olpressed)
            staticdir=dynamicdir=DIR_LEFT;
        if (r && !orpressed)
            staticdir=dynamicdir=DIR_RIGHT;
        if ((oupressed && !u && dynamicdir==DIR_UP) ||
                (odpressed && !d && dynamicdir==DIR_DOWN) ||
                (olpressed && !l && dynamicdir==DIR_LEFT) ||
                (orpressed && !r && dynamicdir==DIR_RIGHT)) {
            dynamicdir=DIR_NONE;
            if (u) dynamicdir=staticdir=2;
            if (d) dynamicdir=staticdir=6;
            if (l) dynamicdir=staticdir=4;
            if (r) dynamicdir=staticdir=0;
        }
        oupressed=u;
        odpressed=d;
        olpressed=l;
        orpressed=r;
        keydir=staticdir;
        if (dynamicdir!=DIR_NONE)
            keydir=dynamicdir;
        staticdir=DIR_NONE;
    }
    else {
        if (aup2pressed || up2pressed) {
            u2=true;
            aup2pressed=false;
        }
        if (adown2pressed || down2pressed) {
            d2=true;
            adown2pressed=false;
        }
        if (aleft2pressed || left2pressed) {
            l2=true;
            aleft2pressed=false;
        }
        if (aright2pressed || right2pressed) {
            r2=true;
            aright2pressed=false;
        }
        if (f12pressed || af12pressed) {
            fire2pflag=true;
            af12pressed=false;
        }
        else
            fire2pflag=false;
        if (u2 && !ou2pressed)
            staticdir2=dynamicdir2=DIR_UP;
        if (d2 && !od2pressed)
            staticdir2=dynamicdir2=DIR_DOWN;
        if (l2 && !ol2pressed)
            staticdir2=dynamicdir2=DIR_LEFT;
        if (r2 && !or2pressed)
            staticdir2=dynamicdir2=DIR_RIGHT;
        if ((ou2pressed && !u2 && dynamicdir2==DIR_UP) ||
                (od2pressed && !d2 && dynamicdir2==DIR_DOWN) ||
                (ol2pressed && !l2 && dynamicdir2==DIR_LEFT) ||
                (or2pressed && !r2 && dynamicdir2==DIR_RIGHT)) {
            dynamicdir2=DIR_NONE;
            if (u2) dynamicdir2=staticdir2=2;
            if (d2) dynamicdir2=staticdir2=6;
            if (l2) dynamicdir2=staticdir2=4;
            if (r2) dynamicdir2=staticdir2=0;
        }
        ou2pressed=u2;
        od2pressed=d2;
        ol2pressed=l2;
        or2pressed=r2;
        keydir2=staticdir2;
        if (dynamicdir2!=DIR_NONE)
            keydir2=dynamicdir2;
        staticdir2=DIR_NONE;
    }

    if (joyflag) {
        incpenalty();
        incpenalty();
        joyanay=0;
        joyanax=0;
        for (j=0; j<4; j++) {
            readjoy();
            joyanax+=joyx;
            joyanay+=joyy;
        }
        joyx=joyanax>>2;
        joyy=joyanay>>2;
        if (joybut1)
            firepflag=true;
        else
            firepflag=false;
    }
}
Пример #11
0
void monai(Sint4 mon)
{
  Sint4 monox,monoy,dir,mdirp1,mdirp2,mdirp3,mdirp4,t;
  int clcoll[SPRITES],clfirst[TYPES],i,m,dig;
  bool push,bagf;
  monox=mondat[mon].x;
  monoy=mondat[mon].y;
  if (mondat[mon].xr==0 && mondat[mon].yr==0) {

    /* If we are here the monster needs to know which way to turn next. */

    /* Turn hobbin back into nobbin if it's had its time */

    if (mondat[mon].hnt>30+(levof10()<<1))
      if (!mondat[mon].nob) {
        mondat[mon].hnt=0;
        mondat[mon].nob=true;
      }

    /* Set up monster direction properties to chase Digger */

    dig=mondat[mon].chase;
    if (!digalive(dig))
      dig=(diggers-1)-dig;

    if (abs(diggery(dig)-mondat[mon].y)>abs(diggerx(dig)-mondat[mon].x)) {
      if (diggery(dig)<mondat[mon].y) { mdirp1=DIR_UP;    mdirp4=DIR_DOWN; }
                                 else { mdirp1=DIR_DOWN;  mdirp4=DIR_UP; }
      if (diggerx(dig)<mondat[mon].x) { mdirp2=DIR_LEFT;  mdirp3=DIR_RIGHT; }
                                 else { mdirp2=DIR_RIGHT; mdirp3=DIR_LEFT; }
    }
    else {
      if (diggerx(dig)<mondat[mon].x) { mdirp1=DIR_LEFT;  mdirp4=DIR_RIGHT; }
                                 else { mdirp1=DIR_RIGHT; mdirp4=DIR_LEFT; }
      if (diggery(dig)<mondat[mon].y) { mdirp2=DIR_UP;    mdirp3=DIR_DOWN; }
                                 else { mdirp2=DIR_DOWN;  mdirp3=DIR_UP; }
    }

    /* In bonus mode, run away from Digger */

    if (bonusmode) {
      t=mdirp1; mdirp1=mdirp4; mdirp4=t;
      t=mdirp2; mdirp2=mdirp3; mdirp3=t;
    }

    /* Adjust priorities so that monsters don't reverse direction unless they
       really have to */

    dir=reversedir(mondat[mon].dir);
    if (dir==mdirp1) {
      mdirp1=mdirp2;
      mdirp2=mdirp3;
      mdirp3=mdirp4;
      mdirp4=dir;
    }
    if (dir==mdirp2) {
      mdirp2=mdirp3;
      mdirp3=mdirp4;
      mdirp4=dir;
    }
    if (dir==mdirp3) {
      mdirp3=mdirp4;
      mdirp4=dir;
    }

    /* Introduce a random element on levels <6 : occasionally swap p1 and p3 */

    if (randno(levof10()+5)==1) /* Need to split for determinism */
      if (levof10()<6) {
        t=mdirp1;
        mdirp1=mdirp3;
        mdirp3=t;
      }

    /* Check field and find direction */

    if (fieldclear(mdirp1,mondat[mon].h,mondat[mon].v))
      dir=mdirp1;
    else
      if (fieldclear(mdirp2,mondat[mon].h,mondat[mon].v))
        dir=mdirp2;
      else
        if (fieldclear(mdirp3,mondat[mon].h,mondat[mon].v))
          dir=mdirp3;
        else
          if (fieldclear(mdirp4,mondat[mon].h,mondat[mon].v))
            dir=mdirp4;

    /* Hobbins don't care about the field: they go where they want. */

    if (!mondat[mon].nob)
      dir=mdirp1;

    /* Monsters take a time penalty for changing direction */

    if (mondat[mon].dir!=dir)
      mondat[mon].t++;

    /* Save the new direction */

    mondat[mon].dir=dir;
  }

  /* If monster is about to go off edge of screen, stop it. */

  if ((mondat[mon].x==292 && mondat[mon].dir==DIR_RIGHT) ||
      (mondat[mon].x==12 && mondat[mon].dir==DIR_LEFT) ||
      (mondat[mon].y==180 && mondat[mon].dir==DIR_DOWN) ||
      (mondat[mon].y==18 && mondat[mon].dir==DIR_UP))
    mondat[mon].dir=DIR_NONE;

  /* Change hdir for hobbin */

  if (mondat[mon].dir==DIR_LEFT || mondat[mon].dir==DIR_RIGHT)
    mondat[mon].hdir=mondat[mon].dir;

  /* Hobbins dig */

  if (!mondat[mon].nob)
    eatfield(mondat[mon].x,mondat[mon].y,mondat[mon].dir);

  /* (Draw new tunnels) and move monster */

  switch (mondat[mon].dir) {
    case DIR_RIGHT:
      if (!mondat[mon].nob)
        drawrightblob(mondat[mon].x,mondat[mon].y);
      mondat[mon].x+=4;
      break;
    case DIR_UP:
      if (!mondat[mon].nob)
        drawtopblob(mondat[mon].x,mondat[mon].y);
      mondat[mon].y-=3;
      break;
    case DIR_LEFT:
      if (!mondat[mon].nob)
        drawleftblob(mondat[mon].x,mondat[mon].y);
      mondat[mon].x-=4;
      break;
    case DIR_DOWN:
      if (!mondat[mon].nob)
        drawbottomblob(mondat[mon].x,mondat[mon].y);
      mondat[mon].y+=3;
      break;
  }

  /* Hobbins can eat emeralds */

  if (!mondat[mon].nob)
    hitemerald((mondat[mon].x-12)/20,(mondat[mon].y-18)/18,
               (mondat[mon].x-12)%20,(mondat[mon].y-18)%18,
               mondat[mon].dir);

  /* If Digger's gone, don't bother */

  if (!isalive()) {
    mondat[mon].x=monox;
    mondat[mon].y=monoy;
  }

  /* If monster's just started, don't move yet */

  if (mondat[mon].stime!=0) {
    mondat[mon].stime--;
    mondat[mon].x=monox;
    mondat[mon].y=monoy;
  }

  /* Increase time counter for hobbin */

  if (!mondat[mon].nob && mondat[mon].hnt<100)
    mondat[mon].hnt++;

  /* Draw monster */

  push=true;
  drawmon(mon,mondat[mon].nob,mondat[mon].hdir,mondat[mon].x,mondat[mon].y);
  for (i=0;i<TYPES;i++)
    clfirst[i]=first[i];
  for (i=0;i<SPRITES;i++)
    clcoll[i]=coll[i];
  incpenalty();

  /* Collision with another monster */

  if (clfirst[2]!=-1) {
    mondat[mon].t++; /* Time penalty */
    /* Ensure both aren't moving in the same dir. */
    i=clfirst[2];
    do {
      m=i-FIRSTMONSTER;
      if (mondat[mon].dir==mondat[m].dir && mondat[m].stime==0 &&
          mondat[mon].stime==0)
        mondat[m].dir=reversedir(mondat[m].dir);
      /* The kludge here is to preserve playback for a bug in previous
         versions. */
      if (!kludge)
        incpenalty();
      else
        if (!(m&1))
          incpenalty();
      i=clcoll[i];
    } while (i!=-1);
    if (kludge)
      if (clfirst[0]!=-1)
        incpenalty();
  }

  /* Check for collision with bag */

  i=clfirst[1];
  bagf=false;
  while (i!=-1) {
    if (bagexist(i-FIRSTBAG)) {
      bagf=true;
      break;
    }
    i=clcoll[i];
  }

  if (bagf) {
    mondat[mon].t++; /* Time penalty */
    mongotgold=false;
    if (mondat[mon].dir==DIR_RIGHT || mondat[mon].dir==DIR_LEFT) {
      push=pushbags(mondat[mon].dir,clfirst,clcoll);      /* Horizontal push */
      mondat[mon].t++; /* Time penalty */
    }
    else
      if (!pushudbags(clfirst,clcoll)) /* Vertical push */
        push=false;
    if (mongotgold) /* No time penalty if monster eats gold */
      mondat[mon].t=0;
    if (!mondat[mon].nob && mondat[mon].hnt>1)
      removebags(clfirst,clcoll); /* Hobbins eat bags */
  }

  /* Increase hobbin cross counter */

  if (mondat[mon].nob && clfirst[2]!=-1 && isalive())
    mondat[mon].hnt++;

  /* See if bags push monster back */

  if (!push) {
    mondat[mon].x=monox;
    mondat[mon].y=monoy;
    drawmon(mon,mondat[mon].nob,mondat[mon].hdir,mondat[mon].x,mondat[mon].y);
    incpenalty();
    if (mondat[mon].nob) /* The other way to create hobbin: stuck on h-bag */
      mondat[mon].hnt++;
    if ((mondat[mon].dir==DIR_UP || mondat[mon].dir==DIR_DOWN) &&
        mondat[mon].nob)
      mondat[mon].dir=reversedir(mondat[mon].dir); /* If vertical, give up */
  }

  /* Collision with Digger */

  if (clfirst[4]!=-1 && isalive())
    if (bonusmode) {
      killmon(mon);
      i=clfirst[4];
      while (i!=-1) {
        if (digalive(i-FIRSTDIGGER+curplayer))
          sceatm(i-FIRSTDIGGER+curplayer);
        i=clcoll[i];
      }
      soundeatm(); /* Collision in bonus mode */
    }
    else {
      i=clfirst[4];
      while (i!=-1) {
        if (digalive(i-FIRSTDIGGER+curplayer))
          killdigger(i-FIRSTDIGGER+curplayer,3,0); /* Kill Digger */
        i=clcoll[i];
      }
    }

  /* Update co-ordinates */

  mondat[mon].h=(mondat[mon].x-12)/20;
  mondat[mon].v=(mondat[mon].y-18)/18;
  mondat[mon].xr=(mondat[mon].x-12)%20;
  mondat[mon].yr=(mondat[mon].y-18)%18;
}
Пример #12
0
void dodigger(void)
{
  int n;
  newframe();
  if (gauntlet) {
    drawlives();
    if (cgtime<ftime)
      timeout=TRUE;
    cgtime-=ftime;
  }
  for (n=curplayer;n<diggers+curplayer;n++) {
    if (digdat[n].expsn!=0)
      drawexplosion(n);
    else
      updatefire(n);
    if (digvisible)
      if (digdat[n].alive)
        if (digdat[n].bagtime!=0) {
          drawdig(n,digdat[n].mdir,digdat[n].x,digdat[n].y,
                  digdat[n].notfiring && digdat[n].rechargetime==0);
          incpenalty();
          digdat[n].bagtime--;
        }
        else
          updatedigger(n);
      else
        diggerdie(n);
    if (digdat[n].emocttime>0)
      digdat[n].emocttime--;
  }
  if (bonusmode && isalive()) {
    if (bonustimeleft!=0) {
      bonustimeleft--;
      if (startbonustimeleft!=0 || bonustimeleft<20) {
        startbonustimeleft--;
        if (bonustimeleft&1) {
          ginten(0);
          soundbonus();
        }
        else {
          ginten(1);
          soundbonus();
        }
        if (startbonustimeleft==0) {
          music(0);
          soundbonusoff();
          ginten(1);
        }
      }
    }
    else {
      endbonusmode();
      soundbonusoff();
      music(1);
    }
  }
  if (bonusmode && !isalive()) {
    endbonusmode();
    soundbonusoff();
    music(1);
  }
}
Пример #13
0
static void
diggerdie(struct digger_draw_api *ddap, int n)
{
  int clfirst[TYPES],clcoll[SPRITES],i;
  bool alldead;
  switch (digdat[n].deathstage) {
    case 1:
      if (bagy(digdat[n].deathbag)+6>digdat[n].dob.y)
        digdat[n].dob.y=bagy(digdat[n].deathbag)+6;
      drawdigger(n-curplayer,15,digdat[n].dob.x,digdat[n].dob.y,false);
      incpenalty();
      if (getbagdir(digdat[n].deathbag)+1==0) {
        soundddie();
        digdat[n].deathtime=5;
        digdat[n].deathstage=2;
        digdat[n].deathani=0;
        digdat[n].dob.y-=6;
      }
      break;
    case 2:
      if (digdat[n].deathtime!=0) {
        digdat[n].deathtime--;
        break;
      }
      if (digdat[n].deathani==0)
        music(2);
      drawdigger(n-curplayer,14-digdat[n].deathani,digdat[n].dob.x,digdat[n].dob.y,
                 false);
      for (i=0;i<TYPES;i++)
        clfirst[i]=first[i];
      for (i=0;i<SPRITES;i++)
        clcoll[i]=coll[i];
      incpenalty();
      if (digdat[n].deathani==0 && clfirst[2]!=-1)
        killmonsters(clfirst,clcoll);
      if (digdat[n].deathani<4) {
        digdat[n].deathani++;
        digdat[n].deathtime=2;
      }
      else {
        digdat[n].deathstage=4;
        if (musicflag || diggers>1)
          digdat[n].deathtime=60;
        else
          digdat[n].deathtime=10;
      }
      break;
    case 3:
      digdat[n].deathstage=5;
      digdat[n].deathani=0;
      digdat[n].deathtime=0;
      break;
    case 5:
      if (digdat[n].deathani>=0 && digdat[n].deathani<=6) {
        drawdigger(n-curplayer,15,digdat[n].dob.x,
                   digdat[n].dob.y-deatharc[digdat[n].deathani],false);
        if (digdat[n].deathani==6 && !isalive())
          musicoff();
        incpenalty();
        digdat[n].deathani++;
        if (digdat[n].deathani==1)
          soundddie();
        if (digdat[n].deathani==7) {
          digdat[n].deathtime=5;
          digdat[n].deathani=0;
          digdat[n].deathstage=2;
        }
      }
      break;
    case 4:
      if (digdat[n].deathtime!=0)
        digdat[n].deathtime--;
      else {
        digdat[n].dead=true;
        alldead=true;
        for (i=0;i<diggers;i++)
          if (!digdat[i].dead) {
            alldead=false;
            break;
          }
        if (alldead)
          setdead(true);
        else
          if (isalive() && digdat[n].lives>0) {
            if (!gauntlet)
              digdat[n].lives--;
            drawlives(ddap);
            if (digdat[n].lives>0) {
              digdat[n].v=9;
              digdat[n].mdir=4;
              digdat[n].h=(diggers==1) ? 7 : (8-n*2);
              digdat[n].dob.x=digdat[n].h*20+12;
              digdat[n].dob.dir=(n==0) ? DIR_RIGHT : DIR_LEFT;
              digdat[n].rx=0;
              digdat[n].ry=0;
              digdat[n].bagtime=0;
              digdat[n].dob.alive=true;
              digdat[n].dead=false;
              digdat[n].invin=true;
              digdat[n].ivt=50;
              digdat[n].deathstage=1;
              digdat[n].dob.y=digdat[n].v*18+18;
              erasespr(n+FIRSTDIGGER-curplayer);
              CALL_METHOD(&digdat[n].dob, put);
              digdat[n].notfiring=true;
              digdat[n].emocttime=0;
              digdat[n].firepressed=false;
              digdat[n].bob.expsn=0;
              digdat[n].rechargetime=0;
              digdat[n].emn=0;
              digdat[n].msc=1;
            }
            clearfire(n);
            if (bonusmode)
              music(0);
            else
              music(1);
          }
      }
  }
}
Пример #14
0
static void
updatedigger(struct digger_draw_api *ddap, int n)
{
  int16_t dir,ddir,diggerox,diggeroy,nmon;
  bool push=true,bagf;
  int clfirst[TYPES],clcoll[SPRITES],i;
  readdirect(n-curplayer);
  dir=getdirect(n-curplayer);
  if (dir==DIR_RIGHT || dir==DIR_UP || dir==DIR_LEFT || dir==DIR_DOWN)
    ddir=dir;
  else
    ddir=DIR_NONE;
  if (digdat[n].rx==0 && (ddir==DIR_UP || ddir==DIR_DOWN))
    digdat[n].dob.dir=digdat[n].mdir=ddir;
  if (digdat[n].ry==0 && (ddir==DIR_RIGHT || ddir==DIR_LEFT))
    digdat[n].dob.dir=digdat[n].mdir=ddir;
  if (dir==DIR_NONE)
    digdat[n].mdir=DIR_NONE;
  else
    digdat[n].mdir=digdat[n].dob.dir;
  if ((digdat[n].dob.x==292 && digdat[n].mdir==DIR_RIGHT) ||
      (digdat[n].dob.x==12 && digdat[n].mdir==DIR_LEFT) ||
      (digdat[n].dob.y==180 && digdat[n].mdir==DIR_DOWN) ||
      (digdat[n].dob.y==18 && digdat[n].mdir==DIR_UP))
    digdat[n].mdir=DIR_NONE;
  diggerox=digdat[n].dob.x;
  diggeroy=digdat[n].dob.y;
  if (digdat[n].mdir!=DIR_NONE)
    eatfield(diggerox,diggeroy,digdat[n].mdir);
  switch (digdat[n].mdir) {
    case DIR_RIGHT:
      drawrightblob(digdat[n].dob.x,digdat[n].dob.y);
      digdat[n].dob.x+=4;
      break;
    case DIR_UP:
      drawtopblob(digdat[n].dob.x,digdat[n].dob.y);
      digdat[n].dob.y-=3;
      break;
    case DIR_LEFT:
      drawleftblob(digdat[n].dob.x,digdat[n].dob.y);
      digdat[n].dob.x-=4;
      break;
    case DIR_DOWN:
      drawbottomblob(digdat[n].dob.x,digdat[n].dob.y);
      digdat[n].dob.y+=3;
      break;
  }
  if (hitemerald((digdat[n].dob.x-12)/20,(digdat[n].dob.y-18)/18,
                 (digdat[n].dob.x-12)%20,(digdat[n].dob.y-18)%18,
                 digdat[n].mdir)) {
    if (digdat[n].emocttime==0)
      digdat[n].emn=0;
    scoreemerald(ddap, n);
    soundem();
    soundemerald(digdat[n].emn);

    digdat[n].emn++;
    if (digdat[n].emn==8) {
      digdat[n].emn=0;
      scoreoctave(ddap, n);
    }
    digdat[n].emocttime=9;
  }
  drawdig(n);
  for (i=0;i<TYPES;i++)
    clfirst[i]=first[i];
  for (i=0;i<SPRITES;i++)
    clcoll[i]=coll[i];
  incpenalty();

  i=clfirst[1];
  bagf=false;
  while (i!=-1) {
    if (bagexist(i-FIRSTBAG)) {
      bagf=true;
      break;
    }
    i=clcoll[i];
  }

  if (bagf) {
    if (digdat[n].mdir==DIR_RIGHT || digdat[n].mdir==DIR_LEFT) {
      push=pushbags(ddap, digdat[n].mdir,clfirst,clcoll);
      digdat[n].bagtime++;
    }
    else
      if (!pushudbags(ddap, clfirst,clcoll))
        push=false;
    if (!push) { /* Strange, push not completely defined */
      digdat[n].dob.x=diggerox;
      digdat[n].dob.y=diggeroy;
      digdat[n].dob.dir = digdat[n].mdir;
      drawdig(n);
      incpenalty();
      digdat[n].dob.dir=reversedir(digdat[n].mdir);
    }
  }
  if (clfirst[2]!=-1 && bonusmode && digdat[n].dob.alive)
    for (nmon=killmonsters(clfirst,clcoll);nmon!=0;nmon--) {
      soundeatm();
      sceatm(ddap, n);
    }
  if (clfirst[0]!=-1) {
    scorebonus(ddap, n);
    initbonusmode(ddap);
  }
  digdat[n].h=(digdat[n].dob.x-12)/20;
  digdat[n].rx=(digdat[n].dob.x-12)%20;
  digdat[n].v=(digdat[n].dob.y-18)/18;
  digdat[n].ry=(digdat[n].dob.y-18)%18;
}
Пример #15
0
static void
updatefire(struct digger_draw_api *ddap, int n)
{
  int16_t pix=0, fx, fy;
  int clfirst[TYPES],clcoll[SPRITES],i;
  bool clflag;
  if (digdat[n].notfiring) {
    if (digdat[n].rechargetime!=0) {
      digdat[n].rechargetime--;
      if (digdat[n].rechargetime == 0) {
        CALL_METHOD(&digdat[n].dob, recharge);
      }
    } else {
      if (getfirepflag(n-curplayer)) {
        if (digdat[n].dob.alive) {
          CALL_METHOD(&digdat[n].dob, discharge);
          digdat[n].rechargetime=levof10()*3+60;
          digdat[n].notfiring=false;
          switch (digdat[n].dob.dir) {
            case DIR_RIGHT:
              fx = digdat[n].dob.x + 8;
              fy = digdat[n].dob.y + 4;
              break;
            case DIR_UP:
              fx = digdat[n].dob.x + 4;
              fy = digdat[n].dob.y;
              break;
            case DIR_LEFT:
              fx = digdat[n].dob.x;
              fy = digdat[n].dob.y + 4;
              break;
            case DIR_DOWN:
              fx = digdat[n].dob.x + 4;
              fy = digdat[n].dob.y + 8;
              break;
            default:
              abort();
          }
          bullet_obj_init(&digdat[n].bob, n - curplayer, digdat[n].dob.dir, fx, fy);
          CALL_METHOD(&digdat[n].bob, put);
          soundfire(n);
        }
      }
    }
  }
  else {
    switch (digdat[n].bob.dir) {
      case DIR_RIGHT:
        digdat[n].bob.x+=8;
        pix=ddap->ggetpix(digdat[n].bob.x,digdat[n].bob.y+4)|
            ddap->ggetpix(digdat[n].bob.x+4,digdat[n].bob.y+4);
        break;
      case DIR_UP:
        digdat[n].bob.y-=7;
        pix=0;
        for (i=0;i<7;i++)
          pix|=ddap->ggetpix(digdat[n].bob.x+4,digdat[n].bob.y+i);
        pix&=0xc0;
        break;
      case DIR_LEFT:
        digdat[n].bob.x-=8;
        pix=ddap->ggetpix(digdat[n].bob.x,digdat[n].bob.y+4)|
            ddap->ggetpix(digdat[n].bob.x+4,digdat[n].bob.y+4);
        break;
      case DIR_DOWN:
        digdat[n].bob.y+=7;
        pix=0;
        for (i=0;i<7;i++)
          pix|=ddap->ggetpix(digdat[n].bob.x,digdat[n].bob.y+i);
        pix&=0x3;
        break;       
    }
    CALL_METHOD(&digdat[n].bob, animate);
    for (i=0;i<TYPES;i++)
      clfirst[i]=first[i];
    for (i=0;i<SPRITES;i++)
      clcoll[i]=coll[i];
    incpenalty();
    i=clfirst[2];
    while (i!=-1) {
      killmon(i-FIRSTMONSTER);
      scorekill(ddap, n);
      CALL_METHOD(&digdat[n].bob, explode);
      i=clcoll[i];
    }
    i=clfirst[4];
    while (i!=-1) {
      if (i-FIRSTDIGGER+curplayer!=n && !digdat[i-FIRSTDIGGER+curplayer].invin
          && digdat[i-FIRSTDIGGER+curplayer].dob.alive) {
        killdigger(i-FIRSTDIGGER+curplayer,3,0);
        CALL_METHOD(&digdat[n].bob, explode);
      }
      i=clcoll[i];
    }
    if (clfirst[0]!=-1 || clfirst[1]!=-1 || clfirst[2]!=-1 || clfirst[3]!=-1 ||
        clfirst[4]!=-1)
      clflag=true;
    else
      clflag=false;
    if (clfirst[0]!=-1 || clfirst[1]!=-1 || clfirst[3]!=-1) {
      CALL_METHOD(&digdat[n].bob, explode);
      i=clfirst[3];
      while (i!=-1) {
        if (digdat[i-FIRSTFIREBALL+curplayer].bob.expsn==0) {
          CALL_METHOD(&digdat[i-FIRSTFIREBALL+curplayer].bob, explode);
        }
        i=clcoll[i];
      }
    }
    switch (digdat[n].bob.dir) {
      case DIR_RIGHT:
        if (digdat[n].bob.x>296) {
          CALL_METHOD(&digdat[n].bob, explode);
        } else {
          if (pix!=0 && !clflag) {
            digdat[n].bob.x-=8;
            CALL_METHOD(&digdat[n].bob, animate);
            CALL_METHOD(&digdat[n].bob, explode);
          }
        }
        break;
      case DIR_UP:
        if (digdat[n].bob.y<15) {
          CALL_METHOD(&digdat[n].bob, explode);
        } else {
          if (pix!=0 && !clflag) {
            digdat[n].bob.y+=7;
            CALL_METHOD(&digdat[n].bob, animate);
            CALL_METHOD(&digdat[n].bob, explode);
          }
        }
        break;
      case DIR_LEFT:
        if (digdat[n].bob.x<16) {
          CALL_METHOD(&digdat[n].bob, explode);
        } else {
          if (pix!=0 && !clflag) {
            digdat[n].bob.x+=8;
            CALL_METHOD(&digdat[n].bob, animate);
            CALL_METHOD(&digdat[n].bob, explode);
          }
        }
        break;
      case DIR_DOWN:
        if (digdat[n].bob.y>183) {
          CALL_METHOD(&digdat[n].bob, explode);
        } else {
          if (pix!=0 && !clflag) {
            digdat[n].bob.y-=7;
            CALL_METHOD(&digdat[n].bob, animate);
            CALL_METHOD(&digdat[n].bob, explode);
          }
        }
    }
  }
}
Пример #16
0
void
dodigger(struct digger_draw_api *ddap)
{
  int n;
  int16_t tdir;

  newframe();
  if (gauntlet) {
    drawlives(ddap);
    if (cgtime<ftime)
      timeout=true;
    cgtime-=ftime;
  }
  for (n=curplayer;n<diggers+curplayer;n++) {
    if (digdat[n].bob.expsn!=0)
      drawexplosion(n);
    else
      updatefire(ddap, n);
    if (digvisible) {
      if (digdat[n].dob.alive)
        if (digdat[n].bagtime!=0) {
          tdir = digdat[n].dob.dir;
          digdat[n].dob.dir = digdat[n].mdir;
          drawdig(n);
          digdat[n].dob.dir = tdir;
          incpenalty();
          digdat[n].bagtime--;
        }
        else
          updatedigger(ddap, n);
      else
        diggerdie(ddap, n);
    }
    if (digdat[n].emocttime>0)
      digdat[n].emocttime--;
  }
  if (bonusmode && isalive()) {
    if (bonustimeleft!=0) {
      bonustimeleft--;
      if (startbonustimeleft!=0 || bonustimeleft<20) {
        startbonustimeleft--;
        if (bonustimeleft&1) {
          ddap->ginten(0);
          soundbonus();
        }
        else {
          ddap->ginten(1);
          soundbonus();
        }
        if (startbonustimeleft==0) {
          music(0);
          soundbonusoff();
          ddap->ginten(1);
        }
      }
    }
    else {
      endbonusmode(ddap);
      soundbonusoff();
      music(1);
    }
  }
  if (bonusmode && !isalive()) {
    endbonusmode(ddap);
    soundbonusoff();
    music(1);
  }
}
Пример #17
0
void updatefire(int n)
{
  Sint4 pix;
  int clfirst[TYPES],clcoll[SPRITES],i;
  bool clflag;
  if (digdat[n].notfiring) {
    if (digdat[n].rechargetime!=0)
      digdat[n].rechargetime--;
    else
      if (getfirepflag(n-curplayer))
        if (digdat[n].alive) {
          digdat[n].rechargetime=levof10()*3+60;
          digdat[n].notfiring=FALSE;
          switch (digdat[n].dir) {
            case DIR_RIGHT:
              digdat[n].fx=digdat[n].x+8;
              digdat[n].fy=digdat[n].y+4;
              break;
            case DIR_UP:
              digdat[n].fx=digdat[n].x+4;
              digdat[n].fy=digdat[n].y;
              break;
            case DIR_LEFT:
              digdat[n].fx=digdat[n].x;
              digdat[n].fy=digdat[n].y+4;
              break;
            case DIR_DOWN:
              digdat[n].fx=digdat[n].x+4;
              digdat[n].fy=digdat[n].y+8;
          }
          digdat[n].fdir=digdat[n].dir;
          movedrawspr(FIRSTFIREBALL+n-curplayer,digdat[n].fx,digdat[n].fy);
          soundfire(n);
        }
  }
  else {
    switch (digdat[n].fdir) {
      case DIR_RIGHT:
        digdat[n].fx+=8;
        pix=ggetpix(digdat[n].fx,digdat[n].fy+4)|
            ggetpix(digdat[n].fx+4,digdat[n].fy+4);
        break;
      case DIR_UP:
        digdat[n].fy-=7;
        pix=0;
        for (i=0;i<7;i++)
          pix|=ggetpix(digdat[n].fx+4,digdat[n].fy+i);
        pix&=0xc0;
        break;
      case DIR_LEFT:
        digdat[n].fx-=8;
        pix=ggetpix(digdat[n].fx,digdat[n].fy+4)|
            ggetpix(digdat[n].fx+4,digdat[n].fy+4);
        break;
      case DIR_DOWN:
        digdat[n].fy+=7;
        pix=0;
        for (i=0;i<7;i++)
          pix|=ggetpix(digdat[n].fx,digdat[n].fy+i);
        pix&=0x3;
        break;       
    }
    drawfire(n-curplayer,digdat[n].fx,digdat[n].fy,0);
    for (i=0;i<TYPES;i++)
      clfirst[i]=first[i];
    for (i=0;i<SPRITES;i++)
      clcoll[i]=coll[i];
    incpenalty();
    i=clfirst[2];
    while (i!=-1) {
      killmon(i-FIRSTMONSTER);
      scorekill(n);
      digdat[n].expsn=1;
      i=clcoll[i];
    }
    i=clfirst[4];
    while (i!=-1) {
      if (i-FIRSTDIGGER+curplayer!=n && !digdat[i-FIRSTDIGGER+curplayer].invin
          && digdat[i-FIRSTDIGGER+curplayer].alive) {
        killdigger(i-FIRSTDIGGER+curplayer,3,0);
        digdat[n].expsn=1;
      }
      i=clcoll[i];
    }
    if (clfirst[0]!=-1 || clfirst[1]!=-1 || clfirst[2]!=-1 || clfirst[3]!=-1 ||
        clfirst[4]!=-1)
      clflag=TRUE;
    else
      clflag=FALSE;
    if (clfirst[0]!=-1 || clfirst[1]!=-1 || clfirst[3]!=-1) {
      digdat[n].expsn=1;
      i=clfirst[3];
      while (i!=-1) {
        if (digdat[i-FIRSTFIREBALL+curplayer].expsn==0)
          digdat[i-FIRSTFIREBALL+curplayer].expsn=1;
        i=clcoll[i];
      }
    }
    switch (digdat[n].fdir) {
      case DIR_RIGHT:
        if (digdat[n].fx>296)
          digdat[n].expsn=1;
        else
          if (pix!=0 && !clflag) {
            digdat[n].expsn=1;
            digdat[n].fx-=8;
            drawfire(n-curplayer,digdat[n].fx,digdat[n].fy,0);
          }
        break;
      case DIR_UP:
        if (digdat[n].fy<15)
          digdat[n].expsn=1;
        else
          if (pix!=0 && !clflag) {
            digdat[n].expsn=1;
            digdat[n].fy+=7;
            drawfire(n-curplayer,digdat[n].fx,digdat[n].fy,0);
          }
        break;
      case DIR_LEFT:
        if (digdat[n].fx<16)
          digdat[n].expsn=1;
        else
          if (pix!=0 && !clflag) {
            digdat[n].expsn=1;
            digdat[n].fx+=8;
            drawfire(n-curplayer,digdat[n].fx,digdat[n].fy,0);
          }
        break;
      case DIR_DOWN:
        if (digdat[n].fy>183)
          digdat[n].expsn=1;
        else
          if (pix!=0 && !clflag) {
            digdat[n].expsn=1;
            digdat[n].fy-=7;
            drawfire(n-curplayer,digdat[n].fx,digdat[n].fy,0);
          }
    }
  }
}