コード例 #1
0
ファイル: command1.c プロジェクト: albert-wang/OmegaRPG
/* deal with a new player command in dungeon or city mode*/
void p_process(void)
{
    static int searchval=0;

    if (Player.status[BERSERK])
        if (goberserk()) {
            setgamestatus(SKIP_PLAYER);
            drawvision(Player.x,Player.y);
        }
    if (! gamestatusp(SKIP_PLAYER)) {
        if (searchval > 0) {
            searchval--;
            if (searchval == 0) resetgamestatus(FAST_MOVE);
        }
        drawvision(Player.x,Player.y);
        if (! gamestatusp(FAST_MOVE)) {
            searchval = 0;
            Cmd = mgetc();
            clear_if_necessary();
        }
        Command_Duration = 0;
        switch (Cmd) {
        case ' ':
        case 13:
            setgamestatus(SKIP_MONSTERS);
            break; /*no op on space or return*/
        case 6:
            abortshadowform();
            break; /* ^f */
        case 7:
            wizard();
            break; /* ^g */
        case 4:
            player_dump();
            break; /* ^d */
        case 9:
            display_pack();
            morewait();
            xredraw();
            break; /* ^i */
        case 11:
            if (gamestatusp(CHEATED)) frobgamestatus();
            break;
        case 12:
            xredraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^l */
#if !defined(WIN32)
        case 16:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^p */
#else
        case 15:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^o */
#endif
        case 18:
            redraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^r */
        case 23:
            if (gamestatusp(CHEATED)) drawscreen();
            break; /* ^w */
        case 24: /* ^x */
            if (gamestatusp(CHEATED) ||
                    Player.rank[ADEPT])
                wish(1);
            Command_Duration = 5;
            break;
        case 'a':
            zapwand();
            Command_Duration = Player.speed*8/5;
            break;
        case 'c':
            closedoor();
            Command_Duration = Player.speed*2/5;
            break;
        case 'd':
            drop();
            Command_Duration = Player.speed*5/5;
            break;
        case 'e':
            eat();
            Command_Duration = 30;
            break;
        case 'f':
            fire();
            Command_Duration = Player.speed*5/5;
            break;
        case 'g':
            pickup();
            Command_Duration = Player.speed*10/5;
            break;
        case 'i':
            do_inventory_control();
            break;
        case 'm':
            magic();
            Command_Duration = 12;
            break;
        case 'o':
            opendoor();
            Command_Duration = Player.speed*5/5;
            break;
        case 'p':
            pickpocket();
            Command_Duration = Player.speed*20/5;
            break;
        case 'q':
            quaff();
            Command_Duration = 10;
            break;
        case 'r':
            peruse();
            Command_Duration = 20;
            break;
        case 's':
            search(&searchval);
            Command_Duration = 20;
            break;
        case 't':
            talk();
            Command_Duration = 10;
            break;
        case 'v':
            vault();
            Command_Duration = Player.speed*10/5;
            break;
        case 'x':
            examine();
            Command_Duration = 1;
            break;
        case 'z':
            bash_location();
            Command_Duration = Player.speed*10/5;
            break;
        case 'A':
            activate();
            Command_Duration = 10;
            break;
        case 'C':
            callitem();
            break;
        case 'D':
            disarm();
            Command_Duration = 30;
            break;
        case 'E':
            dismount_steed();
            Command_Duration = Player.speed*10/5;
            break;
        case 'F':
            tacoptions();
            break;
        case 'G':
            give();
            Command_Duration = 10;
            break;
        case 'I':
            if (! optionp(TOPINV)) top_inventory_control();
            else {
                display_possessions();
                inventory_control();
            }
            break;
        case 'M':
            city_move();
            Command_Duration = 10;
            break;
        case 'O':
            setoptions();
#if defined(WIN32)
            show_screen();
            xredraw();
#endif
            break;
        case 'P':
            show_license();
            break; /* actually show_license is in file.c */
        case 'Q':
            quit();
            break;
        case 'R':
            rename_player();
            break;
        case 'S':
            save(FALSE);
            break;
        case 'T':
            tunnel();
            Command_Duration =  Player.speed*30/5;
            break;
        case 'V':
            version();
            break;
        case 'Z':
            bash_item();
            Command_Duration = Player.speed*10/5;
            break;
        case '.':
            rest();
            Command_Duration = 10;
            break;
        case ',':
            Command_Duration = 10;
            nap();
            break;
        case '>':
            downstairs();
            break;
        case '<':
            upstairs();
            break;
        case '@':
            p_movefunction(Level->site[Player.x][Player.y].p_locf);
            Command_Duration = 5;
            break;
        case '#':
            if (gamestatusp(CHEATED)) editstats();
            break; /* RAC - char editor */
        case '/':
            charid();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '?':
            help();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '4':
        case 'h':
            moveplayer(-1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '2':
        case 'j':
            moveplayer(0,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '8':
        case 'k':
            moveplayer(0,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '6':
        case 'l':
            moveplayer(1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '1':
        case 'b':
            moveplayer(-1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '3':
        case 'n':
            moveplayer(1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '7':
        case 'y':
            moveplayer(-1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '9':
        case 'u':
            moveplayer(1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '5':
            setgamestatus(SKIP_MONSTERS); /* don't do anything; a dummy turn */
            Cmd = mgetc();
            while ((Cmd != ESCAPE) &&
                    ((Cmd < '1') || (Cmd > '9') || (Cmd=='5'))) {
                print3("Run in keypad direction [ESCAPE to abort]: ");
                Cmd = mgetc();
            }
            if (Cmd != ESCAPE) 
                setgamestatus(FAST_MOVE);
            else
                clearmsg3();
            break;
        case 'H':
            setgamestatus(FAST_MOVE);
            Cmd = 'h';
            moveplayer(-1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'J':
            setgamestatus(FAST_MOVE);
            Cmd = 'j';
            moveplayer(0,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'K':
            setgamestatus(FAST_MOVE);
            Cmd = 'k';
            moveplayer(0,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'L':
            setgamestatus(FAST_MOVE);
            Cmd = 'l';
            moveplayer(1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'B':
            setgamestatus(FAST_MOVE);
            Cmd = 'b';
            moveplayer(-1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'N':
            setgamestatus(FAST_MOVE);
            Cmd = 'n';
            moveplayer(1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'Y':
            setgamestatus(FAST_MOVE);
            Cmd = 'y';
            moveplayer(-1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'U':
            setgamestatus(FAST_MOVE);
            Cmd = 'u';
            moveplayer(1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        default:
            commanderror();
            setgamestatus(SKIP_MONSTERS);
            break;
        }
    }
    if (Current_Environment != E_COUNTRYSIDE) roomcheck();
    screencheck(Player.x,Player.y);
}
コード例 #2
0
void
eat(void)
{
    struct object   *obj;
    int amount;
    float scale = (float) (LINES * COLS) / (25.0F * 80.0F);

    if ((obj = get_object(pack, "eat", FOOD, NULL)) == NULL)
        return;

    switch (obj->o_which)
    {
    case FD_RATION:
        amount = (int)(scale * (HUNGERTIME + rnd(400) - 200));

        if (rnd(100) > 70)
        {
            msg("Yuk, this food tastes awful.");
            pstats.s_exp++;
            check_level();
        }
        else
            msg("Yum, that tasted good.");
        break;

    case FD_FRUIT:
        amount = (int)(scale * (200 + rnd(HUNGERTIME)));
        msg("My, that was a yummy %s.", fruit);
        break;

    case FD_CRAM:
        amount = (int)(scale * (rnd(HUNGERTIME / 2) + 600));
        msg("The cram tastes dry in your mouth.");
        break;

    case FD_CAKES:
        amount = (int)(scale * ((HUNGERTIME / 3) + rnd(600)));
        msg("Yum, the honey cakes tasted good.");
        break;

    case FD_LEMBA:
        amount = (int)(scale * ((HUNGERTIME / 2) + rnd(900)));
        quaff(&player, P_HEALING, ISNORMAL);
        break;

    case FD_MIRUVOR:
        amount = (int)(scale * ((HUNGERTIME / 3) + rnd(500)));
        quaff(&player, P_HEALING, ISNORMAL);
        quaff(&player, P_RESTORE, ISNORMAL);
        break;

    default:
        msg("What a strange thing to eat!");
        amount = (int)(scale * HUNGERTIME);
    }

    food_left += amount;

    if (obj->o_flags & ISBLESSED)
    {
        food_left += 2 * amount;
        msg("You have a tingling feeling in your mouth.");
    }
    else if (food_left > scale * STOMACHSIZE)
    {
        food_left = (int)(scale * STOMACHSIZE);
        msg("You feel satiated and too full to move.");
        no_command = HOLDTIME;
    }

    hungry_state = F_OK;
    updpack();

    if (obj == cur_weapon)
        cur_weapon = NULL;

    if (--obj->o_count <= 0) /* Remove this pack entry if last of food */
        discard_pack(obj);
}
コード例 #3
0
ファイル: main.c プロジェクト: ajinkya93/netbsd-src
/*
	parse()

	get and execute a command
 */
static void
parse(void)
{
	int    i, j, k, flag;
	while (1) {
		k = yylex();
		switch (k) {	/* get the token from the input and switch on
				 * it	 */
		case 'h':
			moveplayer(4);
			return;	/* west		 */
		case 'H':
			run(4);
			return;	/* west		 */
		case 'l':
			moveplayer(2);
			return;	/* east		 */
		case 'L':
			run(2);
			return;	/* east		 */
		case 'j':
			moveplayer(1);
			return;	/* south		 */
		case 'J':
			run(1);
			return;	/* south		 */
		case 'k':
			moveplayer(3);
			return;	/* north		 */
		case 'K':
			run(3);
			return;	/* north		 */
		case 'u':
			moveplayer(5);
			return;	/* northeast	 */
		case 'U':
			run(5);
			return;	/* northeast	 */
		case 'y':
			moveplayer(6);
			return;	/* northwest	 */
		case 'Y':
			run(6);
			return;	/* northwest	 */
		case 'n':
			moveplayer(7);
			return;	/* southeast	 */
		case 'N':
			run(7);
			return;	/* southeast	 */
		case 'b':
			moveplayer(8);
			return;	/* southwest	 */
		case 'B':
			run(8);
			return;	/* southwest	 */

		case '.':
			if (yrepcount)
				viewflag = 1;
			return;	/* stay here		 */

		case 'w':
			yrepcount = 0;
			wield();
			return;	/* wield a weapon */

		case 'W':
			yrepcount = 0;
			wear();
			return;	/* wear armor	 */

		case 'r':
			yrepcount = 0;
			if (c[BLINDCOUNT]) {
				cursors();
				lprcat("\nYou can't read anything when you're blind!");
			} else if (c[TIMESTOP] == 0)
				readscr();
			return;	/* to read a scroll	 */

		case 'q':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				quaff();
			return;	/* quaff a potion		 */

		case 'd':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				dropobj();
			return;	/* to drop an object	 */

		case 'c':
			yrepcount = 0;
			cast();
			return;	/* cast a spell	 */

		case 'i':
			yrepcount = 0;
			nomove = 1;
			showstr();
			return;	/* status		 */

		case 'e':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				eatcookie();
			return;	/* to eat a fortune cookie */

		case 'D':
			yrepcount = 0;
			seemagic(0);
			nomove = 1;
			return;	/* list spells and scrolls */

		case '?':
			yrepcount = 0;
			help();
			nomove = 1;
			return;	/* give the help screen */

		case 'S':
			clear();
			lprcat("Saving . . .");
			lflush();
			savegame(savefilename);
			wizard = 1;
			died(-257);	/* save the game - doesn't return	 */

		case 'Z':
			yrepcount = 0;
			if (c[LEVEL] > 9) {
				oteleport(1);
				return;
			}
			cursors();
			lprcat("\nAs yet, you don't have enough experience to use teleportation");
			return;	/* teleport yourself	 */

		case '^':	/* identify traps */
			flag = yrepcount = 0;
			cursors();
			lprc('\n');
			for (j = playery - 1; j < playery + 2; j++) {
				if (j < 0)
					j = 0;
				if (j >= MAXY)
					break;
				for (i = playerx - 1; i < playerx + 2; i++) {
					if (i < 0)
						i = 0;
					if (i >= MAXX)
						break;
					switch (item[i][j]) {
					case OTRAPDOOR:
					case ODARTRAP:
					case OTRAPARROW:
					case OTELEPORTER:
						lprcat("\nIt's ");
						lprcat(objectname[item[i][j]]);
						flag++;
					};
				}
			}
			if (flag == 0)
				lprcat("\nNo traps are visible");
			return;

#if WIZID
		case '_':	/* this is the fudge player password for
				 * wizard mode */
			yrepcount = 0;
			cursors();
			nomove = 1;
			if (userid != wisid) {
				lprcat("Sorry, you are not empowered to be a wizard.\n");
				scbr();	/* system("stty -echo cbreak"); */
				lflush();
				return;
			}
			if (getpassword() == 0) {
				scbr();	/* system("stty -echo cbreak"); */
				return;
			}
			wizard = 1;
			scbr();	/* system("stty -echo cbreak"); */
			for (i = 0; i < 6; i++)
				c[i] = 70;
			iven[0] = iven[1] = 0;
			take(OPROTRING, 50);
			take(OLANCE, 25);
			c[WIELD] = 1;
			c[LANCEDEATH] = 1;
			c[WEAR] = c[SHIELD] = -1;
			raiseexperience(6000000L);
			c[AWARENESS] += 25000;
			{
				int    i, j;
				for (i = 0; i < MAXY; i++)
					for (j = 0; j < MAXX; j++)
						know[j][i] = 1;
				for (i = 0; i < SPNUM; i++)
					spelknow[i] = 1;
				for (i = 0; i < MAXSCROLL; i++)
					scrollname[i] = scrollhide[i];
				for (i = 0; i < MAXPOTION; i++)
					potionname[i] = potionhide[i];
			}
			for (i = 0; i < MAXSCROLL; i++)
				if (strlen(scrollname[i]) > 2) {	/* no null items */
					item[i][0] = OSCROLL;
					iarg[i][0] = i;
				}
			for (i = MAXX - 1; i > MAXX - 1 - MAXPOTION; i--)
				if (strlen(potionname[i - MAXX + MAXPOTION]) > 2) {	/* no null items */
					item[i][0] = OPOTION;
					iarg[i][0] = i - MAXX + MAXPOTION;
				}
			for (i = 1; i < MAXY; i++) {
				item[0][i] = i;
				iarg[0][i] = 0;
			}
			for (i = MAXY; i < MAXY + MAXX; i++) {
				item[i - MAXY][MAXY - 1] = i;
				iarg[i - MAXY][MAXY - 1] = 0;
			}
			for (i = MAXX + MAXY; i < MAXX + MAXY + MAXY; i++) {
				item[MAXX - 1][i - MAXX - MAXY] = i;
				iarg[MAXX - 1][i - MAXX - MAXY] = 0;
			}
			c[GOLD] += 25000;
			drawscreen();
			return;
#endif

		case 'T':
			yrepcount = 0;
			cursors();
			if (c[SHIELD] != -1) {
				c[SHIELD] = -1;
				lprcat("\nYour shield is off");
				bottomline();
			} else if (c[WEAR] != -1) {
				c[WEAR] = -1;
				lprcat("\nYour armor is off");
				bottomline();
			} else
				lprcat("\nYou aren't wearing anything");
			return;

		case 'g':
			cursors();
			lprintf("\nThe stuff you are carrying presently weighs %ld pounds", (long) packweight());
		case ' ':
			yrepcount = 0;
			nomove = 1;
			return;

		case 'v':
			yrepcount = 0;
			cursors();
			lprintf("\nCaverns of Larn, Version %ld.%ld, Diff=%ld",
				(long) VERSION, (long) SUBVERSION,
				(long) c[HARDGAME]);
			if (wizard)
				lprcat(" Wizard");
			nomove = 1;
			if (cheat)
				lprcat(" Cheater");
			lprcat(copyright);
			return;

		case 'Q':
			yrepcount = 0;
			quit();
			nomove = 1;
			return;	/* quit		 */

		case 'L' - 64:
			yrepcount = 0;
			drawscreen();
			nomove = 1;
			return;	/* look		 */

#if WIZID
#ifdef EXTRA
		case 'A':
			yrepcount = 0;
			nomove = 1;
			if (wizard) {
				diag();
				return;
			}	/* create diagnostic file */
			return;
#endif
#endif
		case 'P':
			cursors();
			if (outstanding_taxes > 0)
				lprintf("\nYou presently owe %ld gp in taxes.",
					(long) outstanding_taxes);
			else
				lprcat("\nYou do not owe any taxes.");
			return;
		};
	}
}