void respawnself()
 {
     if(ispaused()) return;
     if(m_mp(gamemode))
     {
         int seq = (player1->lifesequence<<16)|((lastmillis/1000)&0xFFFF);
         if(player1->respawned!=seq) { addmsg(N_TRYSPAWN, "rc", player1); player1->respawned = seq; }
     }
     else
     {
         spawnplayer(player1);
         showscores(false);
         lasthit = 0;
         if(cmode) cmode->respawned(player1);
     }
 }
Ejemplo n.º 2
0
 void respawnself()
 {
     if(paused || ispaused()) return;
     if(m_mp(gamemode))
     {
         if(player1->respawned!=player1->lifesequence)
         {
             addmsg(N_TRYSPAWN, "rc", player1);
             player1->respawned = player1->lifesequence;
         }
     }
     else
     {
         spawnplayer(player1);
         showscores(false);
         lasthit = 0;
         if(cmode) cmode->respawned(player1);
     }
 }
Ejemplo n.º 3
0
void
died(int x)
{
	int    f, win;
	char            ch;
	const char     *mod;
	time_t          zzz;
	if (c[LIFEPROT] > 0) {	/* if life protection */
		switch ((x > 0) ? x : -x) {
		case 256:
		case 257:
		case 262:
		case 263:
		case 265:
		case 266:
		case 267:
		case 268:
		case 269:
		case 271:
		case 282:
		case 284:
		case 285:
		case 300:
			goto invalid;	/* can't be saved */
		};
		--c[LIFEPROT];
		c[HP] = 1;
		--c[CONSTITUTION];
		cursors();
		lprcat("\nYou feel wiiieeeeerrrrrd all over! ");
		emit_beep();
		lflush();
		sleep(4);
		return;		/* only case where died() returns */
	}
invalid:
	clearvt100();
	lflush();
	f = 0;
	if (ckpflag)
		unlink(ckpfile);/* remove checkpoint file if used */
	if (x < 0) {
		f++;
		x = -x;
	}			/* if we are not to display the scores */
	if ((x == 300) || (x == 257))
		exit(0);		/* for quick exit or saved game */
	if (x == 263)
		win = 1;
	else
		win = 0;
	c[GOLD] += c[BANKACCOUNT];
	c[BANKACCOUNT] = 0;
	/* now enter the player at the end of the scoreboard */
	newscore(c[GOLD], logname, x, win);
	diedsub(x);		/* print out the score line */
	lflush();

	set_score_output();
	if ((wizard == 0) && (c[GOLD] > 0)) {	/* wizards can't score		 */
#ifndef NOLOG
		if (gid != egid)
			setegid(egid);
		if (lappend(logfile) < 0) {	/* append to file */
			if (lcreat(logfile) < 0) {	/* and can't create new
							 * log file */
				lcreat((char *) 0);
				lprcat("\nCan't open record file:  I can't post your score.\n");
				sncbr();
				resetscroll();
				lflush();
				exit(0);
			}
			if (gid != egid)
				setegid(egid);
			chmod(logfile, 0660);
			if (gid != egid)
				setegid(gid);
		}
		if (gid != egid)
			setegid(gid);
		strcpy(logg.who, loginname);
		logg.score = c[GOLD];
		logg.diff = c[HARDGAME];
		if (x < 256) {
			ch = *monster[x].name;
			if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
				mod = "an";
			else
				mod = "a";
			snprintf(logg.what, sizeof(logg.what),
			    "killed by %s %s", mod, monster[x].name);
		} else
			snprintf(logg.what, sizeof(logg.what),
			    "%s", whydead[x - 256]);
		logg.cavelev = level;
		time(&zzz);	/* get CPU time -- write out score info */
		logg.diedtime = zzz;
#ifdef EXTRA
		times(&cputime);/* get CPU time -- write out score info */
		logg.cputime = i = (cputime.tms_utime + cputime.tms_stime) / 60 + c[CPUTIME];
		logg.lev = c[LEVEL];
		logg.ac = c[AC];
		logg.hpmax = c[HPMAX];
		logg.hp = c[HP];
		logg.elapsedtime = (zzz - initialtime + 59) / 60;
		logg.usage = (10000 * i) / (zzz - initialtime);
		logg.bytin = c[BYTESIN];
		logg.bytout = c[BYTESOUT];
		logg.moves = c[MOVESMADE];
		logg.spused = c[SPELLSCAST];
		logg.killed = c[MONSTKILLED];
#endif
		lwrite((char *) &logg, sizeof(struct log_fmt));
		lwclose();
#endif	/* NOLOG */

		/*
		 * now for the scoreboard maintenance -- not for a suspended
		 * game
		 */
		if (x != 257) {
			if (sortboard()) {
				set_score_output();
				scorerror = writeboard();
			}
		}
	}
	if ((x == 256) || (x == 257) || (f != 0))
		exit(0);
	if (scorerror == 0)
		showscores();	/* if we updated the scoreboard */
	if (x == 263)
		mailbill();
	exit(0);
}
Ejemplo n.º 4
0
static void respawnself() {
  spawnplayer(player1);
  showscores(false);
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
  int continuing = 0;
  int count;
  int scores_only = 0;
  int i;

#ifndef NOGETOPT
  while(( i= getopt( argc, argv, "dsh")) != -1)
  {
     switch (i)
     {
       case 'd':
#ifdef DEBUG
         DG_debug_flag++;
#endif
         break;
       case 's':
         scores_only = 1;
         break;
       case 'h':
#ifdef DEBUG
         printf("Usage: omega [-shd] [savefile]\n");
#else
         printf("Usage: omega [-sh] [savefile]\n");
#endif
         printf("Options:\n");
         printf("  -s  Display high score list\n");
         printf("  -h  Display this message\n");
#ifdef DEBUG
         printf("  -d  Enable debug mode\n");
#endif
         exit(0);
         break;
       case '?':
         /* error parsing args... ignore? */
         printf("'%c' is an invalid option, ignoring\n", optopt );
         break;
     }
  }

  if (optind >= argc ) {
    /* no save file given */
#if defined( BSD ) || defined( SYSV )
    sprintf( SaveFileName, "Omega%d", getuid() );
#else
    strcpy( SaveFileName,"Omega");
#endif
  } else {
    /* savefile given */
    continuing = 1;
    strcpy(SaveFileName,argv[optind]);
  }

#else 
  /* alternate code for people who don't support getopt() -- no enhancement */
  if (argc ==2) {
    strcpy( SaveFileName, argv[1]);
    continuing = 1;
  } else {
    strcpy( SaveFileName,"Omega");
  }
#endif

  /* always catch ^c and hang-up signals */

#ifdef SIGINT
  signal(SIGINT,signalquit);
#endif
#ifdef SIGHUP
  signal(SIGHUP,signalsave);
#endif

#ifndef MSDOS
  if (CATCH_SIGNALS) {
    signal(SIGQUIT,signalexit);
    signal(SIGILL,signalexit);
#ifdef DEBUG
    if( DG_debug_flag ) {
#endif
    signal(SIGTRAP,signalexit);
    signal(SIGFPE,signalexit);
    signal(SIGSEGV,signalexit);
#ifdef DEBUG
    }
#endif
#ifdef SIGIOT
    signal(SIGIOT,signalexit);
#endif
#ifdef SIGABRT
    signal(SIGABRT,signalexit);
#endif
#ifdef SIGEMT
    signal(SIGEMT,signalexit);
#endif
#ifdef SIGBUS
    signal(SIGBUS,signalexit);
#endif
#ifdef SIGSYS
    signal(SIGSYS,signalexit);
#endif
    }
#endif

#ifndef FIXED_OMEGALIB
  if (!(Omegalib = getenv("OMEGALIB")))
#endif
    Omegalib = OMEGALIB;

  /* if filecheck is 0, some necessary data files are missing */
  if (filecheck() == 0) exit(0);

  /* all kinds of initialization */
  init_perms();
  initgraf();
#ifndef MSDOS_SUPPORTED_ANTIQUE
  initdirs();
#endif
  initrand(E_RANDOM, 0);
  initspells();

#ifdef DEBUG
  /* initialize debug log file */
  DG_debug_log = fopen( "/tmp/omega_dbg_log", "a" );
  assert( DG_debug_log ); /* WDT :) */
  setvbuf( DG_debug_log, NULL, _IOLBF, 0);
  fprintf(DG_debug_log, "##############  new game started ##############\n");
#endif

  for (count = 0; count < STRING_BUFFER_SIZE; count++)
    strcpy(Stringbuffer[count],"<nothing>");

#ifdef SAVE_LEVELS
  msdos_init();
#endif

  omega_title();
  showscores();

  if (scores_only ) {
    endgraf();
    exit(0);
  }

  /* game restore attempts to restore game if there is an argument */
  if (continuing) 
  {
     game_restore(SaveFileName);
     mprint("Your adventure continues....");
  }
  else
  {
    /* monsters initialized in game_restore if game is being restored */  
    /* items initialized in game_restore if game is being restored */
    inititem(TRUE);
    Date = random_range(360);
    Phase = random_range(24);
#ifdef NEW_BANK
    bank_init();
#else
    strcpy(Password,"");
#endif
    continuing = initplayer(); /* RM: 04-19-2000 loading patch */
  }
  if (!continuing)
  {
    init_world();  /* RM: 04-19-2000 loading patch */
    mprint("'?' for help or commandlist, 'Q' to quit.");
  }

  timeprint();
  calc_melee();
  if (Current_Environment != E_COUNTRYSIDE)
    showroom(Level->site[Player.x][Player.y].roomnumber);
  else
    terrain_check(FALSE);
  
  if (optionp(SHOW_COLOUR))
    colour_on();
  else
    colour_off();

  screencheck(Player.x,Player.y);

 /* game cycle */
  if (!continuing)
    time_clock(TRUE);
  while (TRUE) {
    if (Current_Environment == E_COUNTRYSIDE)
      p_country_process();
    else time_clock(FALSE);
  }
}
Ejemplo n.º 6
0
void
died (int x)
{
  int f, win;
  /*char ch, *mod;
     time_t zzz; */

  if (cdesc[LIFEPROT] > 0)	/* if life protection */
    {
      switch ((x > 0) ? x : -x)
	{
	case 256:
	case 257:
	case 262:
	case 263:
	case 265:
	case 266:
	case 267:
	case 268:
	case 269:
	case 271:
	case 282:
	case 284:
	case 285:
	case 300:
	  goto invalid;		/* can't be saved */
	};
      --cdesc[LIFEPROT];
      cdesc[HP] = 1;
      --cdesc[CONSTITUTION];
      cursors ();
      lprcat ("\nYou feel wiiieeeeerrrrrd all over! ");
      lflush ();
      nap (NAPTIME);
      return;			/* only case where died() returns */
    }

  cursors ();
  lprcat ("\nPress any key to continue. ");
  ttgetch ();

invalid:
  /*clearvt100(); */
  lflush ();
  f = 0;

  /* if we are not to display the scores */
  if (x < 0)
    {
      f++;
      x = -x;
    }

  /* for quick exit or saved game */
  if ((x == 300) || (x == 257))
    {
      clearvt100 ();
      exit (EXIT_SUCCESS);
    }

  if (x == 263)
    win = 1;
  else
    win = 0;

  cdesc[GOLD] += cdesc[BANKACCOUNT];
  cdesc[BANKACCOUNT] = 0;

  /*  now enter the player at the end of the scoreboard */
  newscore (cdesc[GOLD], logname, x, win);
  diedsub (x);			/* print out the score line */
  lflush ();

  set_score_output ();
  if ((wizard == 0) && (cdesc[GOLD] > 0))	/*  wizards can't score     */
    {
      /*if (lappend(logfile)<0)
         {
         if (lcreat(logfile)<0) {
         lcreat((char*)0);
         lprcat("\nCan't open record file:  I can't post your score.\n");
         sncbr();
         resetscroll();
         lflush();
         clearvt100();
         exit(EXIT_SUCCESS);
         }
         _chmod(logfile,0666);
         }
         strcpy(logg.who,logname);
         logg.score = cdesc[GOLD];  
         logg.diff = cdesc[HARDGAME];
         if (x < 256) {
         ch = *monster[x].name;
         if (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
         mod="an";
         else
         mod="a";
         sprintf(logg.what,"killed by %s %s",mod,monster[x].name);
         }
         else sprintf(logg.what,"%s",whydead[x - 256]);
         logg.cavelev=level;
         time(&zzz);
         logg.diedtime=zzz;
         #ifdef EXTRA
         logg.lev=cdesc[LEVEL];          logg.ac=cdesc[AC];
         logg.hpmax=cdesc[HPMAX];        logg.hp=cdesc[HP];
         logg.elapsedtime=(zzz-initialtime+59)/60;
         logg.usage=(10000*i)/(zzz-initialtime);
         logg.bytin=cdesc[BYTESIN];      logg.bytout=cdesc[BYTESOUT];
         logg.moves=cdesc[MOVESMADE];    logg.spused=cdesc[SPELLSCAST];
         logg.killed=cdesc[MONSTKILLED];
         #endif
         lwrite((char*)&logg,sizeof(struct log_fmt));
         lwclose(); */

      /*  now for the scoreboard maintenance -- not for a suspended game  */
      if (x != 257)
	{
	  if (sortboard ())
	    scorerror = writeboard ();
	}
    }
  if ((x == 256) || (x == 257) || (f != 0))
    {
      clearvt100 ();
      exit (EXIT_SUCCESS);
    }
  if (scorerror == 0)
    {
      lflush ();
      clear ();
      resetscroll ();
      showscores ();		/* if we updated the scoreboard */
      cursors ();
      lprcat ("\nPress any key to exit. ");
      scbr ();
      ttgetch ();
    }
  clearvt100 ();
  exit (EXIT_SUCCESS);
}
Ejemplo n.º 7
0
bool level4()
{
    char bname[25];
    coor player, enemy[3], pshot[25], enshot[3];
    int plife=3, enlife[3]={7,7, 7};
    int fb =0, input, bo=0;
    player.xl= 20, player.yt=200, player.xr=100, player.yb=300;
    enemy[0].xl=550, enemy[0].yt=50, enemy[0].xr=630, enemy[0].yb=150;
    enemy[1].xl=550, enemy[1].yt=400, enemy[1].xr=630, enemy[1].yb=500;
    enemy[2].xl=650, enemy[2].yt=200, enemy[2].xr=730, enemy[2].yb=300;
    readimagefile("background.jpg", 0, 0, 800, 600);
    readimagefile("player.jpg", player.xl, player.yt, player.xr, player.yb);
    readimagefile("enemy3.jpg", enemy[0].xl, enemy[0].yt, enemy[0].xr, enemy[0].yb);
    readimagefile("enemy4.jpg", enemy[1].xl, enemy[1].yt, enemy[1].xr, enemy[1].yb);
    while(1)
    {
       scoring(0);
     //  p_life(plife);
        for(int i=0; i<3; i++)
        {
            char name[30];
           if(enshot[i].xl<=0 || fb==i)
            {
                fb++;
                enshot[i].xl = enemy[i].xl - 30;
                enshot[i].xr = enemy[i].xl;
                enshot[i].yb = enemy[i].yb - 45;
                enshot[i].yt = enemy[i].yt + 45;
                readimagefile("background.jpg", 0, 0, 800, 600);
                sprintf(name, "enbullet%d.jpg", i);
                readimagefile(name, enshot[i].xl, enshot[i].yt, enshot[i].xr, enshot[i].yb);
            }
            enemy[i].yb += 4, enemy[i].yt += 4 ;
            if(enshot[i].xl > 0)
            {
                enshot[i].xl-= 5, enshot[i].xr -=5;
                sprintf(name, "enbullet%d.jpg", i);
                readimagefile(name, enshot[i].xl, enshot[i].yt, enshot[i].xr, enshot[i].yb);
            }
            if(enemy[i].yb> 600)
            {
                enemy[i].yt =0, enemy[i].yb = 100;
                readimagefile("background.jpg", 0, 0, 800, 600);
            }
            sprintf(name, "enemy%d.jpg", i+2);
            readimagefile(name, enemy[i].xl, enemy[i].yt, enemy[i].xr, enemy[i].yb);
        }
        if(kbhit())
        {
            input = getch();
            if(input == 32)
            {
                scoring(-5);
                readimagefile("background.jpg", 0, 0, 800, 600);
                PlaySound(TEXT("shoot.wav"), NULL, SND_ASYNC);
                for(int k=0; k<2; k++)
            {
                pshot[bo].xl = player.xr;
                pshot[bo].xr = player.xr + 30;
                if(k==0)
                {
                    pshot[bo].yb = player.yb - 40;
                    pshot[bo].yt = player.yt + 50;
                    sprintf(bname, "pbullet%d.jpg", bo);
                readimagefile(bname, pshot[bo].xl, pshot[bo].yt, pshot[bo].xr, pshot[bo].yb);
                bo++;
                }
               /* if(k==1)
               {
                    pshot[bo].yb = player.yb - 50;
                    pshot[bo].yt = player.yt + 40;
                    sprintf(bname, "pbullet%d.jpg", bo);
                readimagefile(bname, pshot[bo].xl, pshot[bo].yt, pshot[bo].xr, pshot[bo].yb);
                bo++;
                }*/

            }
            input =0;
            }
            else if(input == 72)
            {
            if(player.yt>= 0) player.yb-=5, player.yt-=5;
            input =0;
            }
            else if(input == 80)
            {
            if(player.yb <= 600) player.yb+=5, player.yt+=5;
            input =0;
            }
            else if(input == 75)
            {
            if(player.xl >=0) player.xl-=5, player.xr-=5;
            input =0;
            }
            else if(input == 77)
            {
            if(player.xr<=800) player.xl+=5, player.xr+=5;
            input =0;
            }
  /*           else if(input == 13)
            {
                system("pause");
                setcolor(5);
                settextstyle(8, HORIZ_DIR, 3);
                outtextxy(300, 350, "Game Paused");
                outtextxy(270, 380, "Press Any Key To Continue");
                getch();
            }*/
        }
        readimagefile("player.jpg", player.xl, player.yt, player.xr, player.yb);
        for(int i=0; i<bo; i++)
        {
            if(pshot[i].xr>0 && pshot[i].xr<800)
            {
                pshot[i].xl +=6, pshot[i].xr +=6;
                sprintf(bname, "pbullet%d.jpg", i);
                readimagefile(bname, pshot[i].xl, pshot[i].yt, pshot[i].xr, pshot[i].yb);
            }
            if(pshot[i].xr >= 800)
            {
                pshot[i].xl =-1, pshot[i].xr = -1, pshot[i].yb =-1, pshot[i].yt =-1;
                readimagefile("background.jpg", 0, 0, 800, 600);
            }
        }
        for(int j=0; j<3; j++)
        {
            if((enshot[j].yt>= player.yt && enshot[j].yb <= player.yb) && (enshot[j].xl>=player.xl && enshot[j].xl <player.xr))
            {
                PlaySound(TEXT("explosion.wav"), NULL, SND_ASYNC);
                readimagefile("Explosion.jpg" , player.xl, player.yt, player.xr , player.yb );
                delay(200);
                readimagefile("background.jpg", 0, 0, 800, 600);
                readimagefile("player.jpg", player.xl, player.yt, player.xr, player.yb);
                enshot[j].xl = 0, plife--;
            }
            if(((player.xl>=enemy[j].xl && player.xl<=enemy[j].xr) || (player.xr>=enemy[j].xl && player.xr<=enemy[j].xr)) &&
                 ((player.yt>=enemy[j].yt && player.yb<=enemy[j].yt) || (player.yb>=enemy[j].yb && player.yt<=enemy[j].yb))) plife=0, enlife[j] =0;
             for(int i=0; i<bo; i++) if((pshot[i].yt>= enemy[j].yt && pshot[i].yb<= enemy[j].yb) && (pshot[i].xl>= enemy[j].xl && pshot[i].xr<= enemy[j].xr))
            {
                PlaySound(TEXT("explosion.wav"), NULL, SND_ASYNC);
                readimagefile("Explosion.jpg" , enemy[j].xl , enemy[j].yt , enemy[j].xr , enemy[j].yb );
                delay(200);
                pshot[i].xl =-1, pshot[i].xr = -1, pshot[i].yb =-1, pshot[i].yt =-1, enlife[j]--;
                if(enlife[j]>0)
                {
                    char name[30];
                    sprintf(name, "enemy%d.jpg", j+2);
                    readimagefile(name, enemy[j].xl, enemy[j].yt, enemy[j].xr, enemy[j].yb);
                }
                scoring(20);
                readimagefile("background.jpg", 0, 0, 800, 600);
            }
        }

        if(plife ==0 || ptszero())

        {
            PlaySound(TEXT("over.wav"), NULL, SND_ASYNC);
            readimagefile("Game over.jpg", 0, 0, 800, 600);
            delay(2000);
            sethighscores();
            showscores();
            cleardevice();
            return 0;
        }
         if(enlife[0] ==0 && enlife[1] == 0)
        {
            PlaySound(TEXT("win.wav"), NULL, SND_ASYNC);
            readimagefile("win.jpg", 0, 0, 800, 600);
            cleardevice();
            return 1;
        }
    }
}