/* * idenpack: * Identify all the items in the pack */ void idenpack() { struct linked_list *pc; for (pc = pack ; pc != NULL ; pc = next(pc)) whatis(pc); }
void owhat(Node *n, Node *res) { res->op = OCONST; /* Default return value */ res->type = TLIST; res->nstore.u0.sl = 0; whatis(n->sym); }
void showpack(char *howso) { char *iname; unsigned int worth; int cnt, ch, oldpurse; struct linked_list *item; struct object *obj; struct linked_list *bag = NULL; cnt = 1; clear(); mvprintw(0, 0, "Contents of your pack %s:\n", howso); ch = 0; oldpurse = purse; purse = 0; for (item = pack; item != NULL; item = next(item)) { obj = OBJPTR(item); worth = get_worth(obj); whatis(item); purse += worth; if (obj->o_type == ARTIFACT && obj->o_which == TR_PURSE) bag = obj->o_bag; iname = inv_name(obj, UPPERCASE); mvprintw(cnt, 0, "%d) %s\n", ch, iname); ch += 1; if (++cnt > LINES - 5 && next(item) != NULL) { cnt = 1; mvaddstr(LINES - 1, 0, morestr); refresh(); wait_for(' '); clear(); } } if (bag != NULL) { mvaddstr(LINES - 1, 0, morestr); refresh(); wait_for(' '); clear(); cnt = 1; ch = 0; mvprintw(0, 0, "Contents of the Magic Purse of Yendor %s:\n", howso); for (item = bag; item != NULL; item = next(item)) { obj = OBJPTR(item); worth = get_worth(obj); whatis(item); purse += worth; mvprintw(cnt, 0, "%d) %s\n", ch, inv_name(obj, UPPERCASE)); ch += 1; if (++cnt > LINES - 5 && next(item) != NULL) { cnt = 1; mvaddstr(LINES - 1, 0, morestr); refresh(); wait_for(' '); clear(); } } } mvprintw(cnt + 1, 0, "Carrying %d gold pieces", oldpurse); mvprintw(cnt + 2, 0, "Carrying objects worth %d gold pieces", purse); purse += oldpurse; refresh(); }
void total_winner(void) { struct linked_list *item; struct object *obj; int worth, oldpurse; char c; struct linked_list *bag = NULL; clear(); standout(); addstr(" \n"); addstr(" @ @ @ @ @ @@@ @ @ \n"); addstr(" @ @ @@ @@ @ @ @ @ \n"); addstr(" @ @ @@@ @ @ @ @ @ @@@ @@@@ @@@ @ @@@ @ \n"); addstr(" @@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ \n"); addstr(" @ @ @ @ @ @ @ @@@@ @ @ @@@@@ @ @ @ \n"); addstr(" @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ \n"); addstr(" @@@ @@@ @@ @ @ @ @@@@ @@@@ @@@ @@@ @@ @ \n"); addstr(" \n"); addstr(" Congratulations, you have made it to the light of day! \n"); standend(); addstr("\nYou have joined the elite ranks of those who have \n"); addstr("escaped the Dungeons of Doom alive. You journey home \n"); addstr("and sell all your loot at a great profit.\n"); addstr("The White Council approves the recommendation of\n"); if (player.t_ctype == C_FIGHTER) addstr("the fighters guild and appoints you Lord Protector\n"); else if (player.t_ctype == C_ASSASIN) addstr("the assassins guild and appoints you Master Murderer\n"); else if (player.t_ctype == C_NINJA) addstr("the ninja guild and appoints you Master of the Wind\n"); else if (player.t_ctype == C_ILLUSION) addstr("the illusionists guild and appoints you Master Wizard\n"); else if (player.t_ctype == C_MAGICIAN) addstr("the magicians guild and appoints you Master Wizard\n"); else if (player.t_ctype == C_CLERIC) addstr("the temple priests and appoints you Master of the Flowers\n"); else if (player.t_ctype == C_DRUID) addstr("the temple priests and appoints you Master of the Flowers\n"); else if (player.t_ctype == C_RANGER) addstr("the rangers guild and appoints you Master Ranger\n"); else if (player.t_ctype == C_PALADIN) addstr("the paladins guild and appoints you Master Paladin\n"); else if (player.t_ctype == C_THIEF) { addstr("the thieves guild under protest and appoints you\n"); addstr("Master of the Highways\n"); } addstr("of the Land Between the Mountains.\n"); mvaddstr(LINES - 1, 0, spacemsg); refresh(); wait_for(' '); clear(); idenpack(); oldpurse = purse; mvaddstr(0, 0, " Worth Item"); for (c = 'a', item = pack; item != NULL; c++, item = next(item)) { obj = OBJPTR(item); worth = get_worth(obj); purse += worth; if (obj->o_type == ARTIFACT && obj->o_which == TR_PURSE) bag = obj->o_bag; mvprintw(c - 'a' + 1, 0, "%c) %8d %s", c, worth, inv_name(obj, UPPERCASE)); } if (bag != NULL) { mvaddstr(LINES - 1, 0, morestr); refresh(); wait_for(' '); clear(); mvprintw(0, 0, "Contents of the Magic Purse of Yendor:\n"); for (c = 'a', item = bag; item != NULL; c++, item = next(item)) { obj = OBJPTR(item); worth = get_worth(obj); whatis(item); purse += worth; mvprintw(c - 'a' + 1, 0, "%c) %8d %s\n", c, worth, inv_name(obj, UPPERCASE)); } } mvprintw(c - 'a' + 1, 0, " %6d Gold Pieces ", oldpurse); refresh(); if (has_artifact == 255) score(pstats.s_exp, pstats.s_lvl, TOTAL, 0); else score(pstats.s_exp, pstats.s_lvl, WINNER, 0); byebye(); }
void read_scroll(void) { THING *obj; PLACE *pp; int y, x; int ch; int i; int discardit = FALSE; struct room *cur_room; THING *orig_obj; coord mp; obj = get_item("read", SCROLL); if (obj == NULL) return; if (obj->o_type != SCROLL) { if (!terse) msg("there is nothing on it to read"); else msg("nothing to read"); return; } /* * Calculate the effect it has on the poor guy. */ if (obj == cur_weapon) cur_weapon = NULL; /* * Get rid of the thing */ discardit = (obj->o_count == 1); leave_pack(obj, FALSE, FALSE); orig_obj = obj; switch (obj->o_which) { case S_CONFUSE: /* * Scroll of monster confusion. Give him that power. */ player.t_flags |= CANHUH; msg("your hands begin to glow %s", pick_color("red")); when S_ARMOR: if (cur_armor != NULL) { cur_armor->o_arm--; cur_armor->o_flags &= ~ISCURSED; msg("your armor glows %s for a moment", pick_color("silver")); } when S_HOLD: /* * Hold monster scroll. Stop all monsters within two spaces * from chasing after the hero. */ ch = 0; for (x = hero.x - 2; x <= hero.x + 2; x++) if (x >= 0 && x < NUMCOLS) for (y = hero.y - 2; y <= hero.y + 2; y++) if (y >= 0 && y <= NUMLINES - 1) if ((obj = moat(y, x)) != NULL && on(*obj, ISRUN)) { obj->t_flags &= ~ISRUN; obj->t_flags |= ISHELD; ch++; } if (ch) { addmsg("the monster"); if (ch > 1) addmsg("s around you"); addmsg(" freeze"); if (ch == 1) addmsg("s"); endmsg(); scr_info[S_HOLD].oi_know = TRUE; } else msg("you feel a strange sense of loss"); when S_SLEEP: /* * Scroll which makes you fall asleep */ scr_info[S_SLEEP].oi_know = TRUE; no_command += rnd(SLEEPTIME) + 4; player.t_flags &= ~ISRUN; msg("you fall asleep"); when S_CREATE: /* * Create a monster: * First look in a circle around him, next try his room * otherwise give up */ i = 0; for (y = hero.y - 1; y <= hero.y + 1; y++) for (x = hero.x - 1; x <= hero.x + 1; x++) /* * Don't put a monster in top of the player. */ if (y == hero.y && x == hero.x) continue; /* * Or anything else nasty * Also avoid a xeroc which is disguised as scroll */ else if (moat(y, x) == NULL && step_ok(ch = winat(y, x))) { if (ch == SCROLL && find_obj(y, x)->o_which == S_SCARE) continue; else if (rnd(++i) == 0) { mp.y = y; mp.x = x; } } if (i == 0) msg("you hear a faint cry of anguish in the distance"); else { obj = new_item(); new_monster(obj, randmonster(FALSE), &mp); } when S_ID_POTION: case S_ID_SCROLL: case S_ID_WEAPON: case S_ID_ARMOR: case S_ID_R_OR_S: { int id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out */ scr_info[obj->o_which].oi_know = TRUE; msg("this scroll is an %s scroll", scr_info[obj->o_which].oi_name); /* whatis(TRUE, id_type[obj->o_which]); */ if (idscr_md != TRUE) whatis(TRUE, id_type[obj->o_which]); else whatis(FALSE, 0); } when S_MAP: /* * Scroll of magic mapping. */ scr_info[S_MAP].oi_know = TRUE; msg("oh, now this scroll has a map on it"); /* * take all the things we want to keep hidden out of the window */ for (y = 1; y < NUMLINES - 1; y++) for (x = 0; x < NUMCOLS; x++) { pp = INDEX(y, x); switch (ch = pp->p_ch) { case DOOR: case STAIRS: break; case '-': case '|': if (!(pp->p_flags & F_REAL)) { ch = pp->p_ch = DOOR; pp->p_flags |= F_REAL; } break; case ' ': if (pp->p_flags & F_REAL) goto def; pp->p_flags |= F_REAL; ch = pp->p_ch = PASSAGE; /* FALLTHROUGH */ case PASSAGE: pass: if (!(pp->p_flags & F_REAL)) pp->p_ch = PASSAGE; pp->p_flags |= (F_SEEN|F_REAL); ch = PASSAGE; break; case FLOOR: if (pp->p_flags & F_REAL) ch = ' '; else { ch = TRAP; pp->p_ch = TRAP; pp->p_flags |= (F_SEEN|F_REAL); } break; default: def: if (pp->p_flags & F_PASS) goto pass; ch = ' '; break; } if (ch != ' ') { if ((obj = pp->p_monst) != NULL) obj->t_oldch = ch; if (obj == NULL || !on(player, SEEMONST)) mvaddch2(y, x, ch); } } when S_FDET: /* * Potion of gold detection */ ch = FALSE; wclear(hw); for (obj = lvl_obj; obj != NULL; obj = next(obj)) if (obj->o_type == FOOD) { ch = TRUE; wmove(hw, obj->o_pos.y, obj->o_pos.x); waddch2(hw, FOOD); } if (ch) { scr_info[S_FDET].oi_know = TRUE; show_win("Your nose tingles and you smell food.--More--"); } else msg("your nose tingles"); when S_TELEP: /* * Scroll of teleportation: * Make him dissapear and reappear */ { cur_room = proom; teleport(); if (cur_room != proom) scr_info[S_TELEP].oi_know = TRUE; } when S_ENCH: if (cur_weapon == NULL || cur_weapon->o_type != WEAPON) msg("you feel a strange sense of loss"); else { cur_weapon->o_flags &= ~ISCURSED; if (rnd(2) == 0) cur_weapon->o_hplus++; else cur_weapon->o_dplus++; msg("your %s glows %s for a moment", weap_info[cur_weapon->o_which].oi_name, pick_color("blue")); } when S_SCARE: /* * Reading it is a mistake and produces laughter at her * poor boo boo. */ msg("you hear maniacal laughter in the distance"); when S_REMOVE: uncurse(cur_armor); uncurse(cur_weapon); uncurse(cur_ring[LEFT]); uncurse(cur_ring[RIGHT]); msg(choose_str("you feel in touch with the Universal Onenes", "you feel as if somebody is watching over you")); when S_AGGR: /* * This scroll aggravates all the monsters on the current * level and sets them running towards the hero */ aggravate(); msg("you hear a high pitched humming noise"); when S_PROTECT: if (cur_armor != NULL) { cur_armor->o_flags |= ISPROT; msg("your armor is covered by a shimmering %s shield", pick_color("gold")); } else msg("you feel a strange sense of loss"); #ifdef MASTER otherwise: msg("what a puzzling scroll!"); return; #endif } obj = orig_obj; look(TRUE); /* put the result of the scroll on the screen */ status(); call_it(&scr_info[obj->o_which]); if (discardit) discard(obj); }
/* * read_scroll: * Let the hero read a scroll */ int read_scroll() { struct object *obj; struct linked_list *item; int i, j, wh; unsigned long ch, nch; struct room *rp; struct linked_list *titem; char buf[LINLEN]; bool bless, curse; if ((item = get_item("read", SCROLL)) == NULL) return 0; obj = OBJPTR(item); if (obj->o_type != SCROLL) { msg("Nothing to read."); after = FALSE; return 0; } msg("As you read the scroll, it vanishes."); wh = obj->o_which; bless = o_on(obj, ISBLESS); curse = o_on(obj, ISCURSED); del_pack(item); /* Get rid of the thing */ /* * Calculate the effect it has on the hero */ switch(wh) { case S_KNOWALL: if (!curse) { idenpack(); /* identify all the pack */ msg("You feel more knowledgable."); chg_abil(WIS,1,TRUE); s_know[S_KNOWALL] = TRUE; } when S_CONFUSE: if (!curse) { /* * Scroll of monster confusion. Give him that power. */ msg("Your hands begin to glow red."); player.t_flags |= CANHUH; s_know[S_CONFUSE] = TRUE; } when S_LIGHT: rp = player.t_room; if (!curse) { if (rp == NULL) { s_know[S_LIGHT] = TRUE; msg("The corridor glows and then fades."); } else { if (rf_on(rp,ISDARK)) { s_know[S_LIGHT] = TRUE; msg("The room is lit."); rp->r_flags &= ~ISDARK; } light(&hero); mvwaddch(cw, hero.y, hero.x, PLAYER); } } when S_ARMOR: if (!curse) { if (cur_armor != NULL && o_off(cur_armor,ISPROT)) { s_know[S_ARMOR] = TRUE; msg("Your armor glows faintly for a moment."); if (o_on(cur_armor,ISCURSED)) cur_armor->o_ac = armors[cur_armor->o_which].a_class; else cur_armor->o_ac--; resoflg(cur_armor,ISCURSED); } } when S_HOLD: if (!curse) { /* * Hold monster scroll. Stop all monsters within 3 spaces * from chasing after the hero. */ int x,y; struct linked_list *mon; for (x = hero.x - 3; x <= hero.x + 3; x++) { for (y = hero.y - 3; y <= hero.y + 3; y++) { if (y > 0 && x > 0 && isalpha(mvwinch(mw, y, x))) { if ((mon = find_mons(y, x)) != NULL) { struct thing *th; th = THINGPTR(mon); th->t_flags &= ~ISRUN; th->t_flags |= ISHELD; th->t_flags |= ISSTUCK; } } } } } when S_SLEEP: /* * Scroll which makes you fall asleep */ if (!bless) { s_know[S_SLEEP] = TRUE; msg("You fall asleep."); player.t_nocmd += 4 + rnd(SLEEPTIME); } when S_CREATE: if (!bless) { if (makemons(mtlev[rnd(levcount)]->m_show)) s_know[S_CREATE] = TRUE; else msg("You hear a faint cry of anguish in the distance."); } when S_IDENT: if (!curse) { msg("This scroll is an identify scroll"); s_know[S_IDENT] = TRUE; whatis(NULL); } when S_MAP: if (curse) break; s_know[S_MAP] = TRUE; addmsg("Oh, now this scroll has a "); if (rnd(100) < 10 || bless) { addmsg("very detailed map on it."); endmsg(); displevl(); } else { addmsg("map on it."); endmsg(); overwrite(stdscr, hw); for (i = 1; i < LINES - 2; i++) { for (j = 0; j < COLS; j++) { switch (nch = ch = mvwinch(hw, i, j)) { case SECRETDOOR: nch = DOOR; mvaddch(i, j, nch); case '-': case '|': case DOOR: case PASSAGE: case ' ': case STAIRS: if (mvwinch(mw, i, j) != ' ') { struct thing *it; struct linked_list *blah; blah = find_mons(i, j); if (blah != NULL) { it = THINGPTR(blah); if (it->t_oldch == ' ') it->t_oldch = nch; } } break; default: nch = ' '; } if (nch != ch) waddch(hw, nch); } } overlay(cw, hw); overwrite(hw, cw); } when S_GFIND: if (!curse) { int gtotal = 0; struct room *rp; wclear(hw); for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) { gtotal += rp->r_goldval; if (rp->r_goldval != 0 && mvinch(rp->r_gold.y,rp->r_gold.x) == GOLD) mvwaddch(hw,rp->r_gold.y,rp->r_gold.x,GOLD); } if (gtotal) { s_know[S_GFIND] = TRUE; msg("You begin to feel greedy and sense gold."); overlay(hw,cw); } else msg("You begin to feel a pull downward."); } when S_TELEP: if (!curse) { int rm; struct room *cur_room; cur_room = player.t_room; rm = teleport(rndspot, &player); if (cur_room != &rooms[rm]) s_know[S_TELEP] = TRUE; } when S_ENCH: if (!curse) { if (cur_weapon == NULL || (cur_weapon != NULL && (o_on(cur_weapon,ISPROT) || cur_weapon->o_type != WEAPON))) msg("You feel a strange sense of loss."); else { s_know[S_ENCH] = TRUE; if (o_on(cur_weapon,ISCURSED)) { resoflg(cur_weapon,ISCURSED); cur_weapon->o_hplus = rnd(2); cur_weapon->o_dplus = rnd(2); } else { /* weapon was not cursed here */ if (rnd(100) < 50) cur_weapon->o_hplus += 1; else cur_weapon->o_dplus += 1; } setoflg(cur_weapon, ISKNOW); msg("Your %s glows blue for a moment.", w_magic[cur_weapon->o_which].mi_name); } } when S_SCARE: /* * A monster will refuse to step on a scare monster scroll * if it is dropped. Thus reading it is a mistake and produces * laughter at the poor rogue's boo boo. */ msg("You hear maniacal laughter in the distance."); when S_REMOVE: if (!curse) { if (cur_armor != NULL && o_off(cur_armor,ISPROT)) resoflg(cur_armor,ISCURSED); if (cur_weapon != NULL && o_off(cur_weapon,ISPROT)) resoflg(cur_weapon,ISCURSED); if (cur_ring[LEFT]!=NULL && o_off(cur_ring[LEFT],ISPROT)) resoflg(cur_ring[LEFT],ISCURSED); if (cur_ring[RIGHT]!=NULL && o_off(cur_ring[RIGHT],ISPROT)) resoflg(cur_ring[RIGHT],ISCURSED); msg("You feel as if somebody is watching over you."); s_know[S_REMOVE] = TRUE; } when S_AGGR: if (!bless) { if (mlist != NULL) { aggravate(); msg("You hear a high pitched humming noise."); s_know[S_AGGR] = TRUE; } } when S_NOP: msg("This scroll seems to be blank."); when S_GENOCIDE: if (!curse) { msg("You have been granted the boon of genocide."); genocide(); s_know[S_GENOCIDE] = TRUE; } when S_DCURSE: if (!bless) { struct linked_list *ll; struct object *lb; msg("Your pack shudders."); for (ll = pack ; ll != NULL ; ll = next(ll)) { lb = OBJPTR(ll); if (o_off(lb,ISPROT)) { resoflg(lb, ISBLESS); setoflg(lb, ISCURSED); } } } when S_DLEVEL: if (!bless) { int much = rnd(9) - 4; if (much != 0) { level += much; if (level < 1) level = 1; mpos = 0; new_level(NORMLEV); /* change levels */ msg("You are whisked away to another region."); s_know[S_DLEVEL] = TRUE; } } when S_PROTECT: if (!curse) { struct linked_list *ll; struct object *lb; msg("You are granted the power of protection."); if ((ll = get_item("protect",0)) != NULL) { lb = OBJPTR(ll); setoflg(lb,ISPROT); mpos = 0; msg("Protected %s.",inv_name(lb,TRUE)); } s_know[S_PROTECT] = TRUE; } when S_ALLENCH: if (!curse) { struct linked_list *ll; struct object *lb; int howmuch, ac, good; msg("You are granted the power of enchantment."); good = TRUE; if ((ll = get_item("enchant",0)) != NULL) { lb = OBJPTR(ll); resoflg(lb,ISCURSED); resoflg(lb,ISPROT); howmuch = rnd(3) + 1; switch(lb->o_type) { case RING: if (lb->o_ac < 0) lb->o_ac = 0; lb->o_ac += howmuch; when ARMOR: ac = armors[lb->o_which].a_class; if (lb->o_ac > ac) lb->o_ac = ac; lb->o_ac -= howmuch; when STICK: lb->o_charges += howmuch + 10; when WEAPON: if (lb->o_dplus < 0) lb->o_dplus = 0; if (lb->o_hplus < 0) lb->o_hplus = 0; lb->o_hplus += howmuch; lb->o_dplus += howmuch; otherwise: msg("You are injured as the scroll flashes & bursts into flames !!!"); chg_hpt(-roll(6,6),FALSE,K_SCROLL); good = FALSE; } if (good) { mpos = 0; msg("Enchanted %s.",inv_name(lb,TRUE)); } } s_know[S_ALLENCH] = TRUE; } when S_BLESS: if (!curse) { struct linked_list *ll; struct object *lb; msg("Your pack glistens brightly."); for (ll = pack ; ll != NULL ; ll = next(ll)) { whatis(ll); lb = OBJPTR(ll); resoflg(lb,ISCURSED); setoflg(lb,ISBLESS); } } when S_MAKEIT: if (!curse) { msg("You have been endowed with the power of creation."); s_know[S_MAKEIT] = TRUE; create_obj(TRUE); } when S_BAN: { int howdeep; char *ptr; if (bless) { if (level > 6) { howdeep = 1 + rnd(5); ptr = "elevated to the upper"; } else { howdeep = -1; bless = FALSE; } } else { howdeep = level + 10 + rnd(20) + (curse * 20); ptr = "banished to the lower"; } if ((!bless && level < howdeep) || bless) { level = howdeep; new_level(NORMLEV); mpos = 0; msg("You are %s regions.", ptr); s_know[S_BAN] = TRUE; } } when S_CWAND: if (!curse) { struct linked_list *ll; struct object *lb; bool wands = FALSE; for (ll = pack ; ll != NULL ; ll = next(ll)) { lb = OBJPTR(ll); if (lb->o_type == STICK) { whatis(ll); setoflg(lb, ISKNOW); resoflg(lb, ISCURSED); lb->o_charges += rnd(11) + 5; wands = TRUE; } } if (wands) { msg("Your sticks gleam."); s_know[wh] = TRUE; } } when S_LOCTRAP: { struct trap *trp; if (ntraps > 0) { for (trp = &traps[0]; trp < &traps[ntraps]; trp++) trp->tr_flags |= ISFOUND; look(FALSE); msg("You now recognize pitfalls."); s_know[S_LOCTRAP] = TRUE; } } otherwise: msg("What a puzzling scroll!"); return 0; }
read_scroll() { register struct object *obj; register struct linked_list *item; register struct room *rp; register int i,j; register char ch, nch; register struct linked_list *titem; char buf[80]; item = get_item("run", SCROLL); if (item == NULL) return; obj = (struct object *) ldata(item); if (obj->o_type != SCROLL) { if (!terse) msg("There is no way to run it"); else msg("Nothing to run"); return; } msg("As you run the device, it self-destructs."); /* * Calculate the effect it has on the poor guy. */ if (obj == cur_weapon) cur_weapon = NULL; switch(obj->o_which) { when S_CONFUSE: /* * Scroll of monster confusion. Give him that power. */ msg("Your hands begin to glow red"); player.t_flags |= CANHUH; when S_LIGHT: s_know[S_LIGHT] = TRUE; if ((rp = roomin(&hero)) == NULL) msg("The corridor glows and then fades"); else { addmsg("The room is lit"); if (!terse) addmsg(" by a shimmering blue light."); endmsg(); rp->r_flags &= ~ISDARK; /* * Light the room and put the player back up */ light(&hero); mvwaddch(cw, hero.y, hero.x, PLAYER); } when S_ARMOR: if (cur_armor != NULL) { msg("Your armor glows faintly for a moment"); cur_armor->o_ac--; cur_armor->o_flags &= ~ISCURSED; } when S_HOLD: /* * Hold monster scroll. Stop all monsters within two spaces * from chasing after the hero. */ { register int x,y; register struct linked_list *mon; for (x = hero.x-2; x <= hero.x+2; x++) for (y = hero.y-2; y <= hero.y+2; y++) if (y > 0 && x > 0 && isupper(mvwinch(mw, y, x))) if ((mon = find_mons(y, x)) != NULL) { register struct thing *th; th = (struct thing *) ldata(mon); th->t_flags &= ~ISRUN; th->t_flags |= ISHELD; } } when S_SLEEP: /* * Scroll which makes you fall asleep */ s_know[S_SLEEP] = TRUE; msg("You fall asleep."); no_command += 4 + rnd(SLEEPTIME); when S_CREATE: /* * Create a monster * First look in a circle around him, next try his room * otherwise give up */ { register int x, y; register bool appear = 0; coord mp; /* * Search for an open place */ for (y = hero.y; y <= hero.y+1; y++) for (x = hero.x; x <= hero.x+1; x++) { /* * Don't put a monster in top of the player. */ if (y == hero.y && x == hero.x) continue; /* * Or anything else nasty */ if (step_ok(winat(y, x))) { if (rnd(++appear) == 0) { mp.y = y; mp.x = x; } } } if (appear) { titem = new_item(sizeof (struct thing)); new_monster(titem, randmonster(FALSE), &mp); } else msg("You hear a faint cry of anguish in the distance."); } when S_IDENT: /* * Identify, let the rogue figure something out */ msg("This nanodevice is an identify nanodevice"); s_know[S_IDENT] = TRUE; whatis(); when S_MAP: /* * Scroll of magic mapping. */ s_know[S_MAP] = TRUE; msg("Oh, now this nanodevice has a map on it."); overwrite(stdscr, hw); /* * Take all the things we want to keep hidden out of the window */ for (i = 0; i < lines(); i++) for (j = 0; j < cols(); j++) { switch (nch = ch = mvwinch(hw, i, j)) { case SECRETDOOR: mvaddch(i, j, nch = DOOR); case '-': case '|': case DOOR: case PASSAGE: case ' ': case STAIRS: if (mvwinch(mw, i, j) != ' ') { register struct thing *it; it = (struct thing *) ldata(find_mons(i, j)); if (it->t_oldch == ' ') it->t_oldch = nch; } break; default: nch = ' '; } if (nch != ch) waddch(hw, nch); } /* * Copy in what he has discovered */ overlay(cw, hw); /* * And set up for display */ overwrite(hw, cw); when S_GFIND: /* * Potion of gold detection */ { int gtotal = 0; wclear(hw); for (i = 0; i < MAXROOMS; i++) { gtotal += rooms[i].r_goldval; if (rooms[i].r_goldval != 0 && mvwinch(stdscr, rooms[i].r_gold.y, rooms[i].r_gold.x) == GOLD) mvwaddch(hw,rooms[i].r_gold.y,rooms[i].r_gold.x,GOLD); } if (gtotal) { s_know[S_GFIND] = TRUE; show_win(hw, "You connect to the Net and detect credits locations.--More--"); } else msg("You begin to feel a pull downward"); } when S_TELEP: /* * Scroll of teleportation: * Make him dissapear and reappear */ { int rm; struct room *cur_room; cur_room = roomin(&hero); rm = teleport(); if (cur_room != &rooms[rm]) s_know[S_TELEP] = TRUE; } when S_ENCH: if (cur_weapon == NULL) msg("You feel a strange sense of loss."); else { cur_weapon->o_flags &= ~ISCURSED; if (rnd(100) > 50) cur_weapon->o_hplus++; else cur_weapon->o_dplus++; msg("Your %s glows blue for a moment.", w_names[cur_weapon->o_which]); } when S_SCARE: /* * A monster will refuse to step on a scare monster scroll * if it is dropped. Thus reading it is a mistake and produces * laughter at the poor rogue's boo boo. */ msg("You hear maniacal laughter in the distance."); when S_REMOVE: if (cur_armor != NULL) cur_armor->o_flags &= ~ISCURSED; if (cur_weapon != NULL) cur_weapon->o_flags &= ~ISCURSED; if (cur_ring[LEFT] != NULL) cur_ring[LEFT]->o_flags &= ~ISCURSED; if (cur_ring[RIGHT] != NULL) cur_ring[RIGHT]->o_flags &= ~ISCURSED; msg("You feel as if somebody is watching over you."); when S_AGGR: /* * This scroll aggravates all the monsters on the current * level and sets them running towards the hero */ aggravate(); msg("You hear a high pitched humming noise."); when S_NOP: msg("This nanodevice seems to be empty."); when S_GENOCIDE: msg("You have been granted the boon of genocide"); genocide(); s_know[S_GENOCIDE] = TRUE; otherwise: msg("What a puzzling nanodevice!"); return; } look(TRUE); /* put the result of the scroll on the screen */ status(); if (s_know[obj->o_which] && s_guess[obj->o_which]) { cfree(s_guess[obj->o_which]); s_guess[obj->o_which] = NULL; } else if (!s_know[obj->o_which] && askme && s_guess[obj->o_which] == NULL) { msg(terse ? "Call it: " : "What do you want to call it? "); if (get_str(buf, cw) == NORM) { s_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1); strcpy(s_guess[obj->o_which], buf); } } /* * Get rid of the thing */ inpack--; if (obj->o_count > 1) obj->o_count--; else { detach(pack, item); discard(item); } }