Mercurial > hg > early-roguelike
diff arogue5/scrolls.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
| author | elwin |
|---|---|
| date | Thu, 09 Aug 2012 22:58:48 +0000 |
| parents | |
| children | c49f7927b0fa |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arogue5/scrolls.c Thu Aug 09 22:58:48 2012 +0000 @@ -0,0 +1,709 @@ +/* + * Read a scroll and let it happen + * + * Advanced Rogue + * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T + * All rights reserved. + * + * Based on "Rogue: Exploring the Dungeons of Doom" + * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman + * All rights reserved. + * + * See the file LICENSE.TXT for full copyright and licensing information. + */ + +#include "curses.h" +#include <ctype.h> +#include "rogue.h" + + + +/* + * let the hero get rid of some type of monster (but not a UNIQUE!) + */ +genocide() +{ + register struct linked_list *ip; + register struct thing *mp; + register int i; + register struct linked_list *nip; + register int num_monst = NUMMONST-NUMUNIQUE-1, /* cannot genocide uniques */ + pres_monst=1, + num_lines=2*(LINES-3); + register int which_monst; + char monst_name[40]; + + /* Print out the monsters */ + while (num_monst > 0) { + register left_limit; + + if (num_monst < num_lines) left_limit = (num_monst+1)/2; + else left_limit = num_lines/2; + + wclear(hw); + touchwin(hw); + + /* Print left column */ + wmove(hw, 2, 0); + for (i=0; i<left_limit; i++) { + sprintf(monst_name, + "[%d] %c%s\n", + pres_monst, + monsters[pres_monst].m_normal ? ' ' : '*', + monsters[pres_monst].m_name); + waddstr(hw, monst_name); + pres_monst++; + } + + /* Print right column */ + for (i=0; i<left_limit && pres_monst<=NUMMONST-NUMUNIQUE-1; i++) { + sprintf(monst_name, + "[%d] %c%s\n", + pres_monst, + monsters[pres_monst].m_normal ? ' ' : '*', + monsters[pres_monst].m_name); + wmove(hw, i+2, COLS/2); + waddstr(hw, monst_name); + pres_monst++; + } + + if ((num_monst -= num_lines) > 0) { + mvwaddstr(hw, LINES-1, 0, morestr); + draw(hw); + wait_for(hw,' '); + } + + else { + mvwaddstr(hw, 0, 0, "Which monster"); + if (!terse) waddstr(hw, " do you wish to wipe out"); + waddstr(hw, "? "); + draw(hw); + } + } + +get_monst: + get_str(monst_name, hw); + which_monst = atoi(monst_name); + if ((which_monst < 1 || which_monst > NUMMONST-NUMUNIQUE-1)) { + mvwaddstr(hw, 0, 0, "Please enter a number in the displayed range -- "); + draw(hw); + goto get_monst; + } + + /* Set up for redraw */ + clearok(cw, TRUE); + touchwin(cw); + + /* 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) { + killed(ip, FALSE, FALSE); + } + } + + /* 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); +} + +read_scroll(which, flag, is_scroll) +register int which; +int flag; +bool is_scroll; +{ + register struct object *obj = NULL, *nobj; + register struct linked_list *item, *nitem; + register int i,j; + register char ch, nch; + bool cursed, blessed; + char buf[LINELEN]; + + blessed = FALSE; + cursed = FALSE; + item = NULL; + + if (which < 0) { + if (on(player, ISBLIND)) { + msg("You can't see to read anything"); + return; + } + item = get_item(pack, "read", SCROLL); + if (item == NULL) + return; + + obj = OBJPTR(item); + /* remove it from the pack */ + inpack--; + detach(pack, item); + + msg("As you read the scroll, it vanishes."); + cursed = (obj->o_flags & ISCURSED) != 0; + blessed = (obj->o_flags & ISBLESSED) != 0; + + which = obj->o_which; + } + else { + cursed = flag & ISCURSED; + blessed = flag & ISBLESSED; + } + + + switch (which) { + case S_CONFUSE: + /* + * Scroll of monster confusion. Give him that power. + */ + msg("Your hands begin to glow red"); + turn_on(player, CANHUH); + when S_CURING: + /* + * A cure disease spell + */ + if (on(player, HASINFEST) || + on(player, HASDISEASE)|| + on(player, DOROT)) { + if (on(player, HASDISEASE)) { + extinguish(cure_disease); + cure_disease(); + } + if (on(player, HASINFEST)) { + msg(terse ? "You feel yourself improving." + : "You begin to feel yourself improving again."); + turn_off(player, HASINFEST); + infest_dam = 0; + } + if (on(player, DOROT)) { + msg("You feel your skin returning to normal."); + turn_off(player, DOROT); + } + } + else { + msg(nothing); + break; + } + if (is_scroll) s_know[S_CURING] = TRUE; + when S_LIGHT: + if (blue_light(blessed, cursed) && is_scroll) + s_know[S_LIGHT] = TRUE; + when S_HOLD: + if (cursed) { + /* + * 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."); + } + else if (blessed) { /* Hold all monsters on level */ + if (mlist == NULL) msg(nothing); + else { + register struct linked_list *mon; + register struct thing *th; + + for (mon = mlist; mon != NULL; mon = next(mon)) { + th = THINGPTR(mon); + turn_off(*th, ISRUN); + turn_on(*th, ISHELD); + } + msg("A sudden peace comes over the dungeon."); + } + } + else { + /* + * Hold monster scroll. Stop all monsters within two spaces + * from chasing after the hero. + */ + register int x,y; + register struct linked_list *mon; + bool gotone=FALSE; + + for (x = hero.x-2; x <= hero.x+2; x++) { + for (y = hero.y-2; y <= hero.y+2; y++) { + if (y < 1 || x < 0 || y > LINES - 3 || x > COLS - 1) + continue; + if (isalpha(mvwinch(mw, y, x))) { + if ((mon = find_mons(y, x)) != NULL) { + register struct thing *th; + + gotone = TRUE; + th = THINGPTR(mon); + turn_off(*th, ISRUN); + turn_on(*th, ISHELD); + } + } + } + } + if (gotone) msg("A sudden peace surrounds you."); + else msg(nothing); + } + when S_SLEEP: + /* + * if cursed, you fall asleep + */ + if (is_scroll) s_know[S_SLEEP] = TRUE; + if (cursed) { + if (ISWEARING(R_ALERT)) + msg("You feel drowsy for a moment."); + else { + msg("You fall asleep."); + no_command += 4 + rnd(SLEEPTIME); + } + } + else { + /* + * sleep monster scroll. + * puts all monsters within 2 spaces asleep + */ + register int x,y; + register struct linked_list *mon; + bool gotone=FALSE; + + for (x = hero.x-2; x <= hero.x+2; x++) { + for (y = hero.y-2; y <= hero.y+2; y++) { + if (y < 1 || x < 0 || y > LINES - 3 || x > COLS - 1) + continue; + if (isalpha(mvwinch(mw, y, x))) { + if ((mon = find_mons(y, x)) != NULL) { + register struct thing *th; + + th = THINGPTR(mon); + if (on(*th, ISUNDEAD)) + continue; + th->t_no_move += SLEEPTIME; + gotone = TRUE; + } + } + } + } + if (gotone) + msg("The monster(s) around you seem to have fallen asleep"); + else + msg(nothing); + } + when S_CREATE: + /* + * Create a monster + * First look in a circle around him, next try his room + * otherwise give up + */ + creat_mons(&player, (short) 0, TRUE); + light(&hero); + when S_IDENT: + /* + * if its blessed then identify everything in the pack + */ + if (blessed) { + msg("You feel more Knowledgeable!"); + idenpack(); + } + else { + /* + * Identify, let the rogue figure something out + */ + if (is_scroll && s_know[S_IDENT] != TRUE) { + msg("This scroll is an identify scroll"); + } + whatis(NULL); + } + if (is_scroll) s_know[S_IDENT] = TRUE; + when S_MAP: + /* + * Scroll of magic mapping. + */ + if (is_scroll && s_know[S_MAP] != TRUE) {
