/* checks current food status of player, every hour, and when food is eaten */ void foodcheck(void) { if (Player.food > 48) { print3("You vomit up your huge meal."); Player.food = 12; } else if (Player.food == 30) print3("Time for a smackerel of something."); else if (Player.food == 20) print3("You feel hungry."); else if (Player.food == 12) print3("You are ravenously hungry."); else if (Player.food == 3) { print3("You feel weak."); if (State.getFastMove()) { drawvision(Player.x,Player.y); State.setFastMove(false); } } else if (Player.food < 0) { if (State.getFastMove()) { drawvision(Player.x,Player.y); State.setFastMove(false); } print3("You're starving!"); p_damage(-5*Player.food,UNSTOPPABLE,"starvation"); } showflags(); }
/* search once particular spot */ void searchat(int x, int y) { int i; if (inbounds(x,y) && (random_range(3) || Player.status[ALERT])) { if (loc_statusp(x,y,SECRET)) { lreset(x,y,SECRET); lset(x, y, CHANGED); if ((Level->site[x][y].locchar==OPEN_DOOR) || (Level->site[x][y].locchar==CLOSED_DOOR)) { mprint("You find a secret door!"); for(i=0; i<=8; i++) { /* FIXED! 12/25/98 */ lset(x+Dirs[0][i],y+Dirs[1][i],STOPS); lset(x+Dirs[0][i], y+Dirs[1][i], CHANGED); } } else mprint("You find a secret passage!"); drawvision(Player.x,Player.y); } if ((Level->site[x][y].p_locf >= TRAP_BASE) && (Level->site[x][y].locchar != TRAP) && (Level->site[x][y].p_locf <= TRAP_BASE+NUMTRAPS)) { Level->site[x][y].locchar = TRAP; lset(x, y, CHANGED); mprint("You find a trap!"); drawvision(Player.x,Player.y); State.setFastMove(false); } } }
/* do dmg points of damage of type dtype, from source fromstring */ void p_damage(int dmg, int dtype, char *fromstring) { if (State.getFastMove()) { drawvision(Player.x,Player.y); State.setFastMove(false); } if (! p_immune(dtype)) { if (dtype == NORMAL_DAMAGE) Player.hp -= max(1,(dmg-Player.absorption)); else Player.hp -= dmg; if (Player.hp < 1) p_death(fromstring); } else mprint("You resist the effects!"); dataprint(); }
void l_balancestone(void) { print1("This is a massive granite slab teetering dangerously on a corner."); print2("You feel a sense of balance as you regard it."); morewait(); clearmsg(); if (cinema_confirm("Your hand naturally drifts forward to touch it.")=='y') { print1("A vortex of mana spins about you!"); if (abs(Player.alignment) > random_range(50)) { print2("The cyclone whirls you off to a strange place!"); morewait(); change_environment(E_COUNTRYSIDE); do { setPlayerXY( random_range(COUNTRY_WIDTH), random_range(COUNTRY_LENGTH)); } while (Country[Player.x][Player.y].current_terrain_type == CHAOS_SEA); screencheck(Player.x,Player.y); drawvision(Player.x,Player.y); } else { print2("You are being drained of experience! Step back? [yn] "); if (ynq2()=='y') { clearmsg(); print1("The vortex calms down, dimishes, and then disappears."); } else { Player.xp -= Player.xp/4; dataprint(); print2("The vortex vanishes. Suddenly, there is a clap of thunder!"); morewait(); Player.alignment = 0; strategic_teleport(1); } } } else print1("You step back from the unlikely boulder."); }
/* deal with a new player command in countryside mode */ void p_country_process(void) { int no_op; drawvision(Player.x,Player.y); do { no_op = FALSE; Cmd = mgetc(); clear_if_necessary(); switch (Cmd) { case ' ': case 13: no_op = TRUE; break; case 7: wizard(); break; /* ^g */ case 12: xredraw(); no_op = TRUE; break; /* ^l */ #if !defined(WIN32) case 16: bufferprint(); no_op = TRUE; break; /* ^p */ #else case 15: bufferprint(); no_op = TRUE; break; /* ^o */ #endif case 18: redraw(); no_op = TRUE; break; /* ^r */ case 23: if (gamestatusp(CHEATED)) drawscreen(); break; /* ^w */ case 24: if (gamestatusp(CHEATED) || Player.rank[ADEPT]) wish(1); break; /* ^x */ case 'd': drop(); break; case 'e': eat(); break; case 'i': do_inventory_control(); break; case 's': countrysearch(); break; case 'x': examine(); break; case 'E': dismount_steed(); break; case 'H': hunt(Country[Player.x][Player.y].current_terrain_type); break; case 'I': if (! optionp(TOPINV)) top_inventory_control(); else { menuclear(); display_possessions(); inventory_control(); } break; case 'O': setoptions(); 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 'V': version(); break; case '>': enter_site(Country[Player.x][Player.y].base_terrain_type); break; case '#': if (gamestatusp(CHEATED)) editstats(); break; /* RAC - char editor */ case '/': charid(); no_op = TRUE; break; case '?': help(); no_op = TRUE; break; case '4': case 'h': movepincountry(-1,0); break; case '2': case 'j': movepincountry(0,1); break; case '8': case 'k': movepincountry(0,-1); break; case '6': case 'l': movepincountry(1,0); break; case '1': case 'b': movepincountry(-1,1); break; case '3': case 'n': movepincountry(1,1); break; case '7': case 'y': movepincountry(-1,-1); break; case '9': case 'u': movepincountry(1,-1); break; default: commanderror(); no_op = TRUE; break; } } while (no_op); screencheck(Player.x,Player.y); }
/* 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); }
void p_movefunction(int movef) { /* loc functs above traps should be activated whether levitating or not */ drawvision(Player.x,Player.y); sign_print(Player.x,Player.y,false); if (Player.status[SHADOWFORM]) switch(movef) { /* player in shadow form is unable to do most things */ case L_CHAOS: l_chaos(); break; case L_ABYSS: l_abyss(); break; case L_ARENA_EXIT: l_arena_exit(); break; case L_ENTER_COURT: l_enter_court(); break; case L_ESCALATOR: l_escalator(); break; case L_COLLEGE: l_college(); break; case L_SORCERORS: l_sorcerors(); break; case L_ALTAR: l_altar(); break; case L_TACTICAL_EXIT: l_tactical_exit(); break; case L_HOUSE_EXIT: l_house_exit(); break; case L_HOUSE: l_house(); break; case L_HOVEL: l_hovel(); break; case L_MANSION: l_mansion(); break; case L_COUNTRYSIDE: l_countryside(); break; case L_ORACLE: l_oracle(); break; case L_TEMPLE_WARNING: l_temple_warning(); break; case L_ENTER_CIRCLE: l_enter_circle(); break; case L_CIRCLE_LIBRARY: l_circle_library(); break; case L_TOME1: l_tome1(); break; case L_TOME2: l_tome2(); break; case L_ADEPT: l_adept(); break; case L_VOICE1: l_voice1(); break; case L_VOICE2: l_voice2(); break; case L_VOICE3: l_voice3(); break; case L_VOID: l_void(); break; case L_FIRE_STATION: l_fire_station(); break; case L_EARTH_STATION: l_earth_station(); break; case L_WATER_STATION: l_water_station(); break; case L_AIR_STATION: l_air_station(); break; case L_VOID_STATION: l_void_station(); break; } else if ((! Player.status[LEVITATING]) || State.getMounted() || (Cmd == '@') || /* @ command activates all effects under player */ (movef < LEVITATION_AVOIDANCE)) { if (movef != L_NO_OP) { State.setFastMove(false); dataprint(); } switch(movef) { /* miscellaneous */ case L_NO_OP: l_no_op(); break; case L_HEDGE: l_hedge(); break; case L_WATER: l_water(); break; case L_LIFT: l_lift(); break; case L_LAVA: l_lava(); break; case L_FIRE: l_fire(); break; case L_WHIRLWIND: l_whirlwind(); break; case L_RUBBLE: l_rubble(); break; case L_MAGIC_POOL: l_magic_pool(); break; case L_CHAOS: l_chaos(); break; case L_ABYSS: l_abyss(); break; case L_PORTCULLIS_TRAP: l_portcullis_trap(); break; case L_RAISE_PORTCULLIS: l_raise_portcullis(); break; case L_DROP_EVERY_PORTCULLIS: l_drop_every_portcullis(); break; case L_ARENA_EXIT: l_arena_exit(); break; case L_TRIFID: l_trifid(); break; case L_ENTER_COURT: l_enter_court(); break; case L_ESCALATOR: l_escalator(); break; case L_THRONE: l_throne(); break; case L_TRAP_DART: l_trap_dart(); break; case L_TRAP_SIREN: l_trap_siren(); break; case L_TRAP_PIT: l_trap_pit(); break; case L_TRAP_DOOR: l_trap_door(); break; case L_TRAP_SNARE: l_trap_snare(); break; case L_TRAP_BLADE: l_trap_blade(); break; case L_TRAP_FIRE: l_trap_fire(); break; case L_TRAP_TELEPORT: l_trap_teleport(); break; case L_TRAP_DISINTEGRATE: l_trap_disintegrate(); break; case L_TRAP_SLEEP_GAS: l_trap_sleepgas(); break; case L_TRAP_MANADRAIN: l_trap_manadrain(); break; case L_TRAP_ACID: l_trap_acid(); break; case L_TRAP_ABYSS: l_trap_abyss(); break; /*door functions */ case L_BANK: l_bank(); break; case L_ARMORER: l_armorer(); break; case L_CLUB: l_club(); break; case L_GYM: l_gym(); break; case L_BROTHEL: l_brothel(); break; case L_THIEVES_GUILD: l_thieves_guild(); break; case L_COLLEGE: l_college(); break; case L_HEALER: l_healer(); break; case L_STATUE_WAKE: l_statue_wake(); break; case L_CASINO: l_casino(); break; case L_COMMANDANT: l_commandant(); break; case L_DINER: l_diner(); break; case L_CRAP: l_crap(); break; case L_TAVERN: l_tavern(); break; case L_MERC_GUILD: l_merc_guild(); break; case L_MONASTERY: l_monastery(); break; case L_ALCHEMIST: l_alchemist(); break; case L_SORCERORS: l_sorcerors(); break; case L_CASTLE: l_castle(); break; case L_ARENA: l_arena(); break; case L_VAULT: l_vault(); break; case L_DPW: l_dpw(); break; case L_LIBRARY: l_library(); break; case L_PAWN_SHOP: l_pawn_shop(); break; case L_CONDO: l_condo(); break; case L_TOURIST: l_tourist(); break; case L_ALTAR: l_altar(); break; case L_TACTICAL_EXIT: l_tactical_exit(); break; case L_HOUSE_EXIT: l_house_exit(); break; case L_SAFE: l_safe(); break; case L_HOUSE: l_house(); break; case L_HOVEL: l_hovel(); break; case L_MANSION: l_mansion(); break; case L_COUNTRYSIDE: l_countryside(); break; case L_ORACLE: l_oracle(); break; case L_ORDER: l_order(); break; case L_CARTOGRAPHER: l_cartographer(); break; case L_TEMPLE_WARNING: l_temple_warning(); break; case L_ENTER_CIRCLE: l_enter_circle(); break; case L_CIRCLE_LIBRARY: l_circle_library(); break; case L_TOME1: l_tome1(); break; case L_TOME2: l_tome2(); break; case L_CHARITY: l_charity(); break; case L_CHAOSTONE: l_chaostone(); break; case L_VOIDSTONE: l_voidstone(); break; case L_BALANCESTONE: l_balancestone(); break; case L_LAWSTONE: l_lawstone(); break; case L_SACRIFICESTONE: l_sacrificestone(); break; case L_MINDSTONE: l_mindstone(); break; /* challenge functions */ case L_ADEPT: l_adept(); break; case L_VOICE1: l_voice1(); break; case L_VOICE2: l_voice2(); break; case L_VOICE3: l_voice3(); break; case L_VOID: l_void(); break; case L_FIRE_STATION: l_fire_station(); break; case L_EARTH_STATION: l_earth_station(); break; case L_WATER_STATION: l_water_station(); break; case L_AIR_STATION: l_air_station(); break; case L_VOID_STATION: l_void_station(); break; } } }
void change_level (char fromlevel, char tolevel, char rewrite_level) { struct level * thislevel = NULL; Player.sx = -1; Player.sy = -1; /* sanctuary effect dispelled */ thislevel = findlevel(Dungeon, tolevel); deepest[Current_Environment] = max(deepest[Current_Environment], tolevel); if (!thislevel) { thislevel = (level*) checkmalloc(sizeof(levtype)); clear_level(thislevel); Level = thislevel; Level->next = Dungeon; Dungeon = Level; } Level = thislevel; if ((!Level->generated) || rewrite_level) { initrand(Current_Environment, tolevel); Level->environment = Current_Environment; Level->depth = tolevel; Level->generated = true; switch (Current_Environment) { case E_CAVES: Level->level_width = CAVES_WIDTH; Level->level_length = CAVES_LENGTH; if ((0 == random_range(4)) && (tolevel < MaxDungeonLevels)) room_level(); else cavern_level(); break; case E_SEWERS: Level->level_width = SEWERS_WIDTH; Level->level_length = SEWERS_LENGTH; if ((0 == random_range(4)) && (tolevel < MaxDungeonLevels)) room_level(); else sewer_level(); break; case E_CASTLE: Level->level_width = CASTLE_WIDTH; Level->level_length = CASTLE_LENGTH; room_level(); break; case E_PALACE: /* PGM TODO */ Level->level_width = PALACE_WIDTH; Level->level_length = PALACE_LENGTH; room_level(); break; case E_ASTRAL: Level->level_width = ASTRAL_WIDTH; Level->level_length = ASTRAL_LENGTH; maze_level(); break; case E_VOLCANO: Level->level_width = VOLCANO_WIDTH; Level->level_length = VOLCANO_LENGTH; switch (random_range(3)) { case 0: cavern_level(); break; case 1: room_level(); break; case 2: maze_level(); break; } break; default: print3("This dungeon not implemented!"); assert(false); break; } install_traps(); install_specials(); make_stairs(fromlevel); make_stairs(fromlevel); initrand(E_RESTORE, 0); populate_level(Current_Environment); stock_level(); } find_stairs(fromlevel, tolevel); ScreenOffset = Player.y - (ScreenLength/2); show_screen(); screencheck(Player.x,Player.y); drawvision(Player.x,Player.y); /* synchronize with player on level change */ Player.click = (Tick+1)%60; roomcheck(); }