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(); }
void testpause(void) { int i; if (pausef) { soundpause(); sett2val(40); setsoundt2(); cleartopline(); outtext(ddap, "PRESS ANY KEY",80,0,1); getkey(true); cleartopline(); drawscores(ddap); for (i=0;i<diggers;i++) addscore(ddap, i,0); drawlives(ddap); if (!synchvid) curtime=gethrt(); pausef=false; } else soundpauseoff(); }
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); } } } }
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); } }
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); } }
void game(void) { int16_t t,c,i; bool flashplayer=false; if (gauntlet) { cgtime=gtime*1193181l; timeout=false; } initlives(); gamedat[0].level=startlev; if (nplayers==2) gamedat[1].level=startlev; alldead=false; ddap->gclear(); curplayer=0; initlevel(); curplayer=1; initlevel(); zeroscores(); bonusvisible=true; if (nplayers==2) flashplayer=true; curplayer=0; while (getalllives()!=0 && !escape && !timeout) { while (!alldead && !escape && !timeout) { initmbspr(); if (playing) randv=playgetrand(); else randv=getlrt(); #ifdef INTDRF fprintf(info,"%lu\n",randv); frame=0; #endif recputrand(randv); if (levnotdrawn) { levnotdrawn=false; drawscreen(ddap); if (flashplayer) { flashplayer=false; strcpy(pldispbuf,"PLAYER "); if (curplayer==0) strcat(pldispbuf,"1"); else strcat(pldispbuf,"2"); cleartopline(); for (t=0;t<15;t++) for (c=1;c<=3;c++) { outtext(ddap, pldispbuf,108,0,c); writecurscore(ddap, c); newframe(); if (escape) return; } drawscores(ddap); for (i=0;i<diggers;i++) addscore(ddap, i,0); } } else initchars(); outtext(ddap, " ",108,0,3); initscores(ddap); drawlives(ddap); music(1); flushkeybuf(); for (i=0;i<diggers;i++) readdirect(i); while (!alldead && !gamedat[curplayer].levdone && !escape && !timeout) { penalty=0; dodigger(ddap); domonsters(ddap); dobags(ddap); if (penalty>8) incmont(penalty-8); testpause(); checklevdone(); } erasediggers(); musicoff(); t=20; while ((getnmovingbags()!=0 || t!=0) && !escape && !timeout) { if (t!=0) t--; penalty=0; dobags(ddap); dodigger(ddap); domonsters(ddap); if (penalty<8) t=0; } soundstop(); for (i=0;i<diggers;i++) killfire(i); erasebonus(ddap); cleanupbags(); savefield(); erasemonsters(); recputeol(); if (playing) playskipeol(); if (escape) recputeog(); if (gamedat[curplayer].levdone) soundlevdone(); if (countem()==0 || gamedat[curplayer].levdone) { #ifdef INTDRF fprintf(info,"%i\n",frame); #endif for (i=curplayer;i<diggers+curplayer;i++) if (getlives(i)>0 && !digalive(i)) declife(i); drawlives(ddap); gamedat[curplayer].level++; if (gamedat[curplayer].level>1000) gamedat[curplayer].level=1000; initlevel(); } else if (alldead) { #ifdef INTDRF fprintf(info,"%i\n",frame); #endif for (i=curplayer;i<curplayer+diggers;i++) if (getlives(i)>0) declife(i); drawlives(ddap); } if ((alldead && getalllives()==0 && !gauntlet && !escape) || timeout) endofgame(ddap); } alldead=false; if (nplayers==2 && getlives(1-curplayer)!=0) { curplayer=1-curplayer; flashplayer=levnotdrawn=true; } } #ifdef INTDRF fprintf(info,"-1\n%lu\n%i",getscore0(),gamedat[0].level); #endif }