void genocide(int flags) { struct linked_list *ip; struct thing *mp; struct linked_list *nip; int which_monst; int blessed = flags & ISBLESSED; int cursed = flags & ISCURSED; while ((which_monst = get_monster_number("genocide")) == 0) ; if (cursed) /* oops... */ { new_level(THRONE, which_monst); msg("What's this I hear about you trying to wipe me out?"); fighting = running = after = FALSE; return; } /* Remove this monster from the present level */ for (ip = mlist; ip; ip = nip) { mp = THINGPTR(ip); nip = next(ip); if (mp->t_index == which_monst) { check_residue(mp); /* Check for special features before removing */ remove_monster(&mp->t_pos, ip); } } /* Remove from available monsters */ monsters[which_monst].m_normal = FALSE; monsters[which_monst].m_wander = FALSE; mpos = 0; msg("You have wiped out the %s.", monsters[which_monst].m_name); if (blessed) genocide(ISNORMAL); }
/* Use a staff. -RAK- */ void use() { int32u i; int j, k, item_val, chance, y, x; register int ident; register struct misc *m_ptr; register inven_type *i_ptr; free_turn_flag = TRUE; if (inven_ctr == 0) msg_print("But you are not carrying anything."); else if (!find_range(TV_STAFF, TV_NEVER, &j, &k)) msg_print("You are not carrying any staffs."); else if (get_item(&item_val, "Use which staff?", j, k, 0)) { i_ptr = &inventory[item_val]; free_turn_flag = FALSE; m_ptr = &py.misc; chance = m_ptr->save + stat_adj(A_INT) - (int)i_ptr->level - 5 + (class_level_adj[m_ptr->pclass][CLA_DEVICE] * m_ptr->lev / 3); if (py.flags.confused > 0) chance = chance / 2; if (chance <= 0) chance = 1; if (randint(chance) < USE_DEVICE) msg_print("You failed to use the staff properly."); else if (i_ptr->p1 > 0) { i = i_ptr->flags; ident = FALSE; (i_ptr->p1)--; switch(i) { case ST_HEALING: ident = hp_player(300); if (py.flags.stun>0) { if (py.flags.stun>50) { py.misc.ptohit+=20; py.misc.ptodam+=20; } else { py.misc.ptohit+=5; py.misc.ptodam+=5; } py.flags.stun=0; ident = TRUE; msg_print("You're head stops stinging."); } if (py.flags.cut>0) { py.flags.cut=0; ident = TRUE; msg_print("You feel better."); } break; case ST_GENOCIDE: genocide(FALSE); ident = TRUE; break; case ST_PROBE: probing(); ident = TRUE; break; case ST_IDENTIFY: ident_spell(); ident = TRUE; break; case ST_HOLYNESS: dispel_creature(EVIL,120); protect_evil(); cure_poison(); remove_fear(); hp_player(50); if (py.flags.stun>0) { if (py.flags.stun>50) { py.misc.ptohit+=20; py.misc.ptodam+=20; } else { py.misc.ptohit+=5; py.misc.ptodam+=5; } py.flags.stun=0; ident = TRUE; msg_print("You're head stops stinging."); } if (py.flags.cut>0) { py.flags.cut=0; ident = TRUE; msg_print("You feel better."); } ident = TRUE; break; case ST_MAGI: if (res_stat(A_INT)) { msg_print("You have a warm feeling."); ident = TRUE; } m_ptr = &py.misc; if (m_ptr->cmana < m_ptr->mana) { m_ptr->cmana = m_ptr->mana; ident = TRUE; msg_print("Your feel your head clear."); prt_cmana(); } break; case ST_POWER: dispel_creature(0xFFFFFFFFL,120); break; case ST_SURROUND: map_area(); ident = TRUE; break; case ST_LIGHT: ident = light_area(char_row, char_col); break; case ST_DR_LC: ident = detect_sdoor(); break; case ST_TRP_LC: ident = detect_trap(); break; case ST_TRE_LC: ident = detect_treasure(); break; case ST_OBJ_LC: ident = detect_object(); break; case ST_TELE: teleport(100); ident = TRUE; break; case ST_EARTH: ident = TRUE; earthquake(); break; case ST_SUMMON: ident = FALSE; for (k = 0; k < randint(4); k++) { y = char_row; x = char_col; ident |= summon_monster(&y, &x, FALSE); } break; case ST_DEST: ident = TRUE; destroy_area(char_row, char_col); break; case ST_STAR: ident = TRUE; starlite(char_row, char_col); break; case ST_HAST_MN: ident = speed_monsters(1); break; case ST_SLOW_MN: ident = speed_monsters(-1); break; case ST_SLEE_MN: ident = sleep_monsters2(); break; case ST_CURE_LT: ident = hp_player(randint(8)); break; case ST_DET_INV: ident = detect_invisible(); break; case ST_SPEED: if (py.flags.fast == 0) ident = TRUE; if (py.flags.fast <= 0) py.flags.fast += randint(30) + 15; else py.flags.fast += randint(5); break; case ST_SLOW: if (py.flags.slow == 0) ident = TRUE; py.flags.slow += randint(30) + 15; break; case ST_REMOVE: if (remove_curse()) { if (py.flags.blind < 1) msg_print("The staff glows blue for a moment.."); ident = TRUE; } break; case ST_DET_EVI: ident = detect_evil(); break; case ST_CURING: if ((cure_blindness()) || (cure_poison()) || (cure_confusion()) || (py.flags.stun>0) || (py.flags.cut>0)) ident = TRUE; if (py.flags.stun>0) { if (py.flags.stun>50) { py.misc.ptohit+=20; py.misc.ptodam+=20; } else { py.misc.ptohit+=5; py.misc.ptodam+=5; } py.flags.stun=0; msg_print("You're head stops stinging."); } else if (py.flags.cut>0) { py.flags.cut=0; msg_print("You feel better."); } break; case ST_DSP_EVI: ident = dispel_creature(EVIL, 60); break; case ST_DARK: ident = unlight_area(char_row, char_col); break; default: msg_print("Internal error in staffs()"); break; } if (ident) { if (!known1_p(i_ptr)) { m_ptr = &py.misc; /* round half-way case up */ m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) / m_ptr->lev; prt_experience(); identify(&item_val); i_ptr = &inventory[item_val]; } }
/* Scrolls for the reading -RAK- */ void read_scroll() { int32u i; int j, k, item_val, y, x; int tmp[6], flag, used_up; bigvtype out_val, tmp_str; register int ident, l; register inven_type *i_ptr; register struct misc *m_ptr; free_turn_flag = TRUE; if (py.flags.blind > 0) msg_print("You can't see to read the scroll."); else if (no_light()) msg_print("You have no light to read by."); else if (py.flags.confused > 0) msg_print("You are too confused to read a scroll."); else if (inven_ctr == 0) msg_print("You are not carrying anything!"); else if (!find_range(TV_SCROLL1, TV_SCROLL2, &j, &k)) msg_print ("You are not carrying any scrolls!"); else if (get_item(&item_val, "Read which scroll?", j, k, 0)) { i_ptr = &inventory[item_val]; free_turn_flag = FALSE; used_up = TRUE; i = i_ptr->flags; ident = FALSE; while (i != 0) { j = bit_pos(&i) + 1; if (i_ptr->tval == TV_SCROLL2) j += 32; /* Scrolls. */ switch(j) { case 1: i_ptr = &inventory[INVEN_WIELD]; if (i_ptr->tval != TV_NOTHING) { objdes(tmp_str, i_ptr, FALSE); (void) sprintf(out_val, "Your %s glows faintly!", tmp_str); msg_print(out_val); if (enchant(&i_ptr->tohit)) { i_ptr->flags &= ~TR_CURSED; calc_bonuses(); } else msg_print("The enchantment fails."); ident = TRUE; } break; case 2: i_ptr = &inventory[INVEN_WIELD]; if (i_ptr->tval != TV_NOTHING) { objdes(tmp_str, i_ptr, FALSE); (void) sprintf(out_val, "Your %s glows faintly!", tmp_str); msg_print(out_val); if (enchant(&i_ptr->todam)) { i_ptr->flags &= ~TR_CURSED; calc_bonuses (); } else msg_print("The enchantment fails."); ident = TRUE; } break; case 3: k = 0; l = 0; if (inventory[INVEN_BODY].tval != TV_NOTHING) tmp[k++] = INVEN_BODY; if (inventory[INVEN_ARM].tval != TV_NOTHING) tmp[k++] = INVEN_ARM; if (inventory[INVEN_OUTER].tval != TV_NOTHING) tmp[k++] = INVEN_OUTER; if (inventory[INVEN_HANDS].tval != TV_NOTHING) tmp[k++] = INVEN_HANDS; if (inventory[INVEN_HEAD].tval != TV_NOTHING) tmp[k++] = INVEN_HEAD; /* also enchant boots */ if (inventory[INVEN_FEET].tval != TV_NOTHING) tmp[k++] = INVEN_FEET; if (k > 0) l = tmp[randint(k)-1]; if (TR_CURSED & inventory[INVEN_BODY].flags) l = INVEN_BODY; else if (TR_CURSED & inventory[INVEN_ARM].flags) l = INVEN_ARM; else if (TR_CURSED & inventory[INVEN_OUTER].flags) l = INVEN_OUTER; else if (TR_CURSED & inventory[INVEN_HEAD].flags) l = INVEN_HEAD; else if (TR_CURSED & inventory[INVEN_HANDS].flags) l = INVEN_HANDS; else if (TR_CURSED & inventory[INVEN_FEET].flags) l = INVEN_FEET; if (l > 0) { i_ptr = &inventory[l]; objdes(tmp_str, i_ptr, FALSE); (void) sprintf(out_val, "Your %s glows faintly!", tmp_str); msg_print(out_val); if (enchant(&i_ptr->toac)) { i_ptr->flags &= ~TR_CURSED; calc_bonuses (); } else msg_print("The enchantment fails."); ident = TRUE; } break; case 4: msg_print("This is an identify scroll."); ident = TRUE; used_up = ident_spell(); /* the identify may merge objects, causing the identify scroll to move to a different place. Check for that here. */ if (i_ptr->tval != TV_SCROLL1 || i_ptr->flags != 0x00000008) { item_val--; i_ptr = &inventory[item_val]; if (i_ptr->tval != TV_SCROLL1 || i_ptr->flags != 0x00000008) { msg_print("internal error with identify spell."); msg_print("Please tell the wizard!"); return; } } break; case 5: if (remove_curse()) { msg_print("You feel as if someone is watching over you."); ident = TRUE; } break; case 6: ident = light_area(char_row, char_col); break; case 7: for (k = 0; k < randint(3); k++) { y = char_row; x = char_col; ident |= summon_monster(&y, &x, FALSE); } break; case 8: teleport(10); ident = TRUE; break; case 9: teleport(100); ident = TRUE; break; case 10: (void) tele_level(); ident = TRUE; break; case 11: if (py.flags.confuse_monster == 0) { msg_print("Your hands begin to glow."); py.flags.confuse_monster = TRUE; ident = TRUE; } break; case 12: ident = TRUE; map_area(); break; case 13: ident = sleep_monsters1(char_row, char_col); break; case 14: ident = TRUE; warding_glyph(); break; case 15: ident = detect_treasure(); break; case 16: ident = detect_object(); break; case 17: ident = detect_trap(); break; case 18: ident = detect_sdoor(); break; case 19: msg_print("This is a mass genocide scroll."); ident = mass_genocide(TRUE); break; case 20: ident = detect_invisible(); break; case 21: ident = aggravate_monster(20); if (ident) msg_print("There is a high pitched humming noise."); break; case 22: ident = trap_creation(); break; case 23: ident = td_destroy(); break; case 24: /* Not Used , used to be door creation */ break; case 25: msg_print("This is a Recharge-Item scroll."); ident = TRUE; used_up = recharge(60); break; case 26: msg_print("This is a genocide scroll."); ident = genocide(TRUE); break; case 27: ident = unlight_area(char_row, char_col); break; case 28: ident = protect_evil(); break; case 29: ident = TRUE; create_food(); break; case 30: ident = dispel_creature(UNDEAD, 60); break; case 31: remove_all_curse(); ident = TRUE; break; case 33: i_ptr = &inventory[INVEN_WIELD]; if (i_ptr->tval != TV_NOTHING) { objdes(tmp_str, i_ptr, FALSE); (void) sprintf(out_val, "Your %s glows brightly!", tmp_str); msg_print(out_val); flag = FALSE; for (k = 0; k < randint(2); k++) if (enchant(&i_ptr->tohit)) flag = TRUE; for (k = 0; k < randint(2); k++) if (enchant(&i_ptr->todam)) flag = TRUE; if (flag) { i_ptr->flags &= ~TR_CURSED; calc_bonuses (); } else msg_print("The enchantment fails."); ident = TRUE; } break; case 34: i_ptr = &inventory[INVEN_WIELD]; if (i_ptr->tval != TV_NOTHING) { objdes(tmp_str, i_ptr, FALSE); (void)sprintf(out_val,"Your %s glows black, fades.",tmp_str); msg_print(out_val); unmagic_name(i_ptr); i_ptr->tohit = -randint(5) - randint(5); i_ptr->todam = -randint(5) - randint(5); i_ptr->flags = TR_CURSED; py_bonuses(i_ptr, -1); calc_bonuses (); ident = TRUE; } break; case 35: k = 0; l = 0; if (inventory[INVEN_BODY].tval != TV_NOTHING) tmp[k++] = INVEN_BODY; if (inventory[INVEN_ARM].tval != TV_NOTHING) tmp[k++] = INVEN_ARM; if (inventory[INVEN_OUTER].tval != TV_NOTHING) tmp[k++] = INVEN_OUTER; if (inventory[INVEN_HANDS].tval != TV_NOTHING) tmp[k++] = INVEN_HANDS; if (inventory[INVEN_HEAD].tval != TV_NOTHING) tmp[k++] = INVEN_HEAD; /* also enchant boots */ if (inventory[INVEN_FEET].tval != TV_NOTHING) tmp[k++] = INVEN_FEET; if (k > 0) l = tmp[randint(k)-1]; if (TR_CURSED & inventory[INVEN_BODY].flags) l = INVEN_BODY; else if (TR_CURSED & inventory[INVEN_ARM].flags) l = INVEN_ARM; else if (TR_CURSED & inventory[INVEN_OUTER].flags) l = INVEN_OUTER; else if (TR_CURSED & inventory[INVEN_HEAD].flags) l = INVEN_HEAD; else if (TR_CURSED & inventory[INVEN_HANDS].flags) l = INVEN_HANDS; else if (TR_CURSED & inventory[INVEN_FEET].flags) l = INVEN_FEET; if (l > 0) { i_ptr = &inventory[l]; objdes(tmp_str, i_ptr, FALSE); (void) sprintf(out_val,"Your %s glows brightly!", tmp_str); msg_print(out_val); flag = FALSE; for (k = 0; k < randint(2) + 1; k++) if (enchant(&i_ptr->toac)) flag = TRUE; if (flag) { i_ptr->flags &= ~TR_CURSED; calc_bonuses (); } else msg_print("The enchantment fails."); ident = TRUE; } break; case 36: if ((inventory[INVEN_BODY].tval != TV_NOTHING) && (randint(4) == 1)) k = INVEN_BODY; else if ((inventory[INVEN_ARM].tval != TV_NOTHING) && (randint(3) ==1)) k = INVEN_ARM; else if ((inventory[INVEN_OUTER].tval != TV_NOTHING) && (randint(3) ==1)) k = INVEN_OUTER; else if ((inventory[INVEN_HEAD].tval != TV_NOTHING) && (randint(3) ==1)) k = INVEN_HEAD; else if ((inventory[INVEN_HANDS].tval != TV_NOTHING) && (randint(3) ==1)) k = INVEN_HANDS; else if ((inventory[INVEN_FEET].tval != TV_NOTHING) && (randint(3) ==1)) k = INVEN_FEET; else if (inventory[INVEN_BODY].tval != TV_NOTHING) k = INVEN_BODY; else if (inventory[INVEN_ARM].tval != TV_NOTHING) k = INVEN_ARM; else if (inventory[INVEN_OUTER].tval != TV_NOTHING) k = INVEN_OUTER; else if (inventory[INVEN_HEAD].tval != TV_NOTHING) k = INVEN_HEAD; else if (inventory[INVEN_HANDS].tval != TV_NOTHING) k = INVEN_HANDS; else if (inventory[INVEN_FEET].tval != TV_NOTHING) k = INVEN_FEET; else k = 0; if (k > 0) { i_ptr = &inventory[k]; objdes(tmp_str, i_ptr, FALSE); (void)sprintf(out_val,"Your %s glows black, fades.",tmp_str); msg_print(out_val); unmagic_name(i_ptr); i_ptr->flags = TR_CURSED; i_ptr->toac = -randint(5) - randint(5); calc_bonuses (); ident = TRUE; } break; case 37: ident = FALSE; for (k = 0; k < randint(3); k++) { y = char_row; x = char_col; ident |= summon_undead(&y, &x); } break; case 38: ident = TRUE; bless(randint(12)+6); break; case 39: ident = TRUE; bless(randint(24)+12); break; case 40: ident = TRUE; bless(randint(48)+24); break; case 41: ident = TRUE; if (py.flags.word_recall == 0) py.flags.word_recall = 25 + randint(30); msg_print("The air about you becomes charged."); break; case 42: destroy_area(char_row, char_col); ident = TRUE; break; case 43: place_special(char_row, char_col, SPECIAL); prt_map(); break; case 44: special_random_object(char_row, char_col, 1); prt_map(); break; default: msg_print("Internal error in scroll()"); break; } /* End of Scrolls. */ } i_ptr = &inventory[item_val]; if (ident) { if (!known1_p(i_ptr)) { m_ptr = &py.misc; /* round half-way case up */ m_ptr->exp += (i_ptr->level +(m_ptr->lev >> 1)) / m_ptr->lev; prt_experience(); identify(&item_val); i_ptr = &inventory[item_val]; } }
/* * 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); } }