Mercurial > hg > early-roguelike
comparison srogue/scrolls.c @ 36:2128c7dc8a40
Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
| author | elwin |
|---|---|
| date | Thu, 25 Nov 2010 12:21:41 +0000 |
| parents | |
| children | 3aa87373c908 |
comparison
equal
deleted
inserted
replaced
| 35:05018c63a721 | 36:2128c7dc8a40 |
|---|---|
| 1 /* | |
| 2 * Read a scroll and let it happen | |
| 3 * | |
| 4 * @(#)scrolls.c 9.0 (rdk) 7/17/84 | |
| 5 * | |
| 6 * Super-Rogue | |
| 7 * Copyright (C) 1984 Robert D. Kindelberger | |
| 8 * All rights reserved. | |
| 9 * | |
| 10 * Based on "Rogue: Exploring the Dungeons of Doom" | |
| 11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 12 * All rights reserved. | |
| 13 * | |
| 14 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 15 */ | |
| 16 | |
| 17 #include <ctype.h> | |
| 18 #include "rogue.h" | |
| 19 #include "rogue.ext" | |
| 20 | |
| 21 /* | |
| 22 * read_scroll: | |
| 23 * Let the hero read a scroll | |
| 24 */ | |
| 25 read_scroll() | |
| 26 { | |
| 27 reg struct object *obj; | |
| 28 reg struct linked_list *item; | |
| 29 reg int i, j, wh; | |
| 30 reg char ch, nch; | |
| 31 struct room *rp; | |
| 32 struct linked_list *titem; | |
| 33 char buf[LINLEN]; | |
| 34 bool bless, curse; | |
| 35 | |
| 36 if ((item = get_item("read", SCROLL)) == NULL) | |
| 37 return; | |
| 38 obj = OBJPTR(item); | |
| 39 if (obj->o_type != SCROLL) { | |
| 40 msg("Nothing to read."); | |
| 41 after = FALSE; | |
| 42 return; | |
| 43 } | |
| 44 msg("As you read the scroll, it vanishes."); | |
| 45 wh = obj->o_which; | |
| 46 bless = o_on(obj, ISBLESS); | |
| 47 curse = o_on(obj, ISCURSED); | |
| 48 del_pack(item); /* Get rid of the thing */ | |
| 49 | |
| 50 /* | |
| 51 * Calculate the effect it has on the hero | |
| 52 */ | |
| 53 switch(wh) { | |
| 54 case S_KNOWALL: | |
| 55 if (!curse) { | |
| 56 idenpack(); /* identify all the pack */ | |
| 57 msg("You feel more knowledgable."); | |
| 58 chg_abil(WIS,1,TRUE); | |
| 59 s_know[S_KNOWALL] = TRUE; | |
| 60 } | |
| 61 when S_CONFUSE: | |
| 62 if (!curse) { | |
| 63 /* | |
| 64 * Scroll of monster confusion. Give him that power. | |
| 65 */ | |
| 66 msg("Your hands begin to glow red."); | |
| 67 player.t_flags |= CANHUH; | |
| 68 s_know[S_CONFUSE] = TRUE; | |
| 69 } | |
| 70 when S_LIGHT: | |
| 71 rp = player.t_room; | |
| 72 if (!curse) { | |
| 73 if (rp == NULL) { | |
| 74 s_know[S_LIGHT] = TRUE; | |
| 75 msg("The corridor glows and then fades."); | |
| 76 } | |
| 77 else { | |
| 78 if (rf_on(rp,ISDARK)) { | |
| 79 s_know[S_LIGHT] = TRUE; | |
| 80 msg("The room is lit."); | |
| 81 rp->r_flags &= ~ISDARK; | |
| 82 } | |
| 83 light(&hero); | |
| 84 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 85 } | |
| 86 } | |
| 87 when S_ARMOR: | |
| 88 if (!curse) { | |
| 89 if (cur_armor != NULL && o_off(cur_armor,ISPROT)) { | |
| 90 s_know[S_ARMOR] = TRUE; | |
| 91 msg("Your armor glows faintly for a moment."); | |
| 92 if (o_on(cur_armor,ISCURSED)) | |
| 93 cur_armor->o_ac = armors[cur_armor->o_which].a_class; | |
| 94 else | |
| 95 cur_armor->o_ac--; | |
| 96 resoflg(cur_armor,ISCURSED); | |
| 97 } | |
| 98 } | |
| 99 when S_HOLD: | |
| 100 if (!curse) { | |
| 101 /* | |
| 102 * Hold monster scroll. Stop all monsters within 3 spaces | |
| 103 * from chasing after the hero. | |
| 104 */ | |
| 105 reg int x,y; | |
| 106 reg struct linked_list *mon; | |
| 107 | |
| 108 for (x = hero.x - 3; x <= hero.x + 3; x++) { | |
| 109 for (y = hero.y - 3; y <= hero.y + 3; y++) { | |
| 110 if (y > 0 && x > 0 && isalpha(mvwinch(mw, y, x))) { | |
| 111 if ((mon = find_mons(y, x)) != NULL) { | |
| 112 reg struct thing *th; | |
| 113 | |
| 114 th = THINGPTR(mon); | |
| 115 th->t_flags &= ~ISRUN; | |
| 116 th->t_flags |= ISHELD; | |
| 117 th->t_flags |= ISSTUCK; | |
| 118 } | |
| 119 } | |
| 120 } | |
| 121 } | |
| 122 } | |
| 123 when S_SLEEP: | |
| 124 /* | |
| 125 * Scroll which makes you fall asleep | |
| 126 */ | |
| 127 if (!bless) { | |
| 128 s_know[S_SLEEP] = TRUE; | |
| 129 msg("You fall asleep."); | |
| 130 player.t_nocmd += 4 + rnd(SLEEPTIME); | |
| 131 } | |
| 132 when S_CREATE: | |
| 133 if (!bless) { | |
| 134 if (makemons(mtlev[rnd(levcount)]->m_show)) | |
| 135 s_know[S_CREATE] = TRUE; | |
| 136 else | |
| 137 msg("You hear a faint cry of anguish in the distance."); | |
| 138 } | |
| 139 when S_IDENT: | |
| 140 if (!curse) { | |
| 141 msg("This scroll is an identify scroll"); | |
| 142 s_know[S_IDENT] = TRUE; | |
| 143 whatis(NULL); | |
| 144 } | |
| 145 when S_MAP: | |
| 146 if (curse) | |
| 147 break; | |
| 148 s_know[S_MAP] = TRUE; | |
| 149 addmsg("Oh, now this scroll has a "); | |
| 150 if (rnd(100) < 10 || bless) { | |
| 151 addmsg("very detailed map on it."); | |
| 152 endmsg(); | |
| 153 displevl(); | |
| 154 } | |
| 155 else { | |
| 156 addmsg("map on it."); | |
| 157 endmsg(); | |
| 158 overwrite(stdscr, hw); | |
| 159 for (i = 1; i < LINES - 2; i++) { | |
| 160 for (j = 0; j < COLS; j++) { | |
| 161 switch (nch = ch = mvwinch(hw, i, j)) { | |
| 162 case SECRETDOOR: | |
| 163 nch = DOOR; | |
| 164 mvaddch(i, j, nch); | |
| 165 case '-': | |
| 166 case '|': | |
| 167 case DOOR: | |
| 168 case PASSAGE: | |
| 169 case ' ': | |
| 170 case STAIRS: | |
| 171 if (mvwinch(mw, i, j) != ' ') { | |
| 172 struct thing *it; | |
| 173 struct linked_list *blah; | |
| 174 | |
| 175 blah = find_mons(i, j); | |
| 176 if (blah != NULL) { | |
| 177 it = THINGPTR(blah); | |
| 178 if (it->t_oldch == ' ') | |
| 179 it->t_oldch = nch; | |
| 180 } | |
| 181 } | |
| 182 break; | |
| 183 default: | |
| 184 nch = ' '; | |
| 185 } | |
| 186 if (nch != ch) | |
| 187 waddch(hw, nch); | |
| 188 } | |
| 189 } | |
| 190 overlay(cw, hw); | |
| 191 overwrite(hw, cw); | |
| 192 } | |
| 193 when S_GFIND: | |
| 194 if (!curse) { | |
| 195 int gtotal = 0; | |
| 196 struct room *rp; | |
| 197 | |
| 198 wclear(hw); | |
| 199 for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) { | |
| 200 gtotal += rp->r_goldval; | |
| 201 if (rp->r_goldval != 0 && | |
| 202 mvinch(rp->r_gold.y,rp->r_gold.x) == GOLD) | |
| 203 mvwaddch(hw,rp->r_gold.y,rp->r_gold.x,GOLD); | |
| 204 } | |
| 205 if (gtotal) { | |
| 206 s_know[S_GFIND] = TRUE; | |
| 207 msg("You begin to feel greedy and sense gold."); | |
| 208 overlay(hw,cw); | |
| 209 } | |
| 210 else | |
| 211 msg("You begin to feel a pull downward."); | |
| 212 } | |
| 213 when S_TELEP: | |
| 214 if (!curse) { | |
| 215 int rm; | |
| 216 struct room *cur_room; | |
| 217 | |
| 218 cur_room = player.t_room; | |
| 219 rm = teleport(rndspot, &player); | |
| 220 if (cur_room != &rooms[rm]) | |
| 221 s_know[S_TELEP] = TRUE; | |
| 222 } | |
| 223 when S_ENCH: | |
| 224 if (!curse) { | |
| 225 if (cur_weapon == NULL || (cur_weapon != NULL && | |
| 226 (o_on(cur_weapon,ISPROT) || cur_weapon->o_type != WEAPON))) | |
| 227 msg("You feel a strange sense of loss."); | |
| 228 else { | |
| 229 s_know[S_ENCH] = TRUE; | |
| 230 if (o_on(cur_weapon,ISCURSED)) { | |
| 231 resoflg(cur_weapon,ISCURSED); | |
| 232 cur_weapon->o_hplus = rnd(2); | |
| 233 cur_weapon->o_dplus = rnd(2); | |
| 234 } | |
| 235 else { /* weapon was not cursed here */ | |
| 236 if (rnd(100) < 50) | |
| 237 cur_weapon->o_hplus += 1; | |
| 238 else | |
| 239 cur_weapon->o_dplus += 1; | |
| 240 } | |
| 241 setoflg(cur_weapon, ISKNOW); | |
| 242 msg("Your %s glows blue for a moment.", | |
| 243 w_magic[cur_weapon->o_which].mi_name); | |
| 244 } | |
| 245 } | |
| 246 when S_SCARE: | |
| 247 /* | |
| 248 * A monster will refuse to step on a scare monster scroll | |
| 249 * if it is dropped. Thus reading it is a mistake and produces | |
| 250 * laughter at the poor rogue's boo boo. | |
| 251 */ | |
| 252 msg("You hear maniacal laughter in the distance."); | |
| 253 when S_REMOVE: | |
| 254 if (!curse) { | |
| 255 if (cur_armor != NULL && o_off(cur_armor,ISPROT)) | |
| 256 resoflg(cur_armor,ISCURSED); | |
| 257 if (cur_weapon != NULL && o_off(cur_weapon,ISPROT)) | |
| 258 resoflg(cur_weapon,ISCURSED); | |
| 259 if (cur_ring[LEFT]!=NULL && o_off(cur_ring[LEFT],ISPROT)) | |
| 260 resoflg(cur_ring[LEFT],ISCURSED); | |
| 261 if (cur_ring[RIGHT]!=NULL && o_off(cur_ring[RIGHT],ISPROT)) | |
| 262 resoflg(cur_ring[RIGHT],ISCURSED); | |
| 263 msg("You feel as if somebody is watching over you."); | |
| 264 s_know[S_REMOVE] = TRUE; | |
| 265 } | |
| 266 when S_AGGR: | |
| 267 if (!bless) { | |
| 268 if (mlist != NULL) { | |
| 269 aggravate(); | |
| 270 msg("You hear a high pitched humming noise."); | |
| 271 s_know[S_AGGR] = TRUE; | |
| 272 } | |
| 273 } | |
| 274 when S_NOP: | |
| 275 msg("This scroll seems to be blank."); | |
| 276 when S_GENOCIDE: | |
| 277 if (!curse) { | |
| 278 msg("You have been granted the boon of genocide."); | |
| 279 genocide(); | |
| 280 s_know[S_GENOCIDE] = TRUE; | |
| 281 } | |
| 282 when S_DCURSE: | |
| 283 if (!bless) { | |
| 284 struct linked_list *ll; | |
| 285 struct object *lb; | |
| 286 | |
| 287 msg("Your pack shudders."); | |
| 288 for (ll = pack ; ll != NULL ; ll = next(ll)) { | |
| 289 lb = OBJPTR(ll); | |
| 290 if (o_off(lb,ISPROT)) { | |
| 291 resoflg(lb, ISBLESS); | |
| 292 setoflg(lb, ISCURSED); | |
| 293 } | |
| 294 } | |
| 295 } | |
| 296 when S_DLEVEL: | |
| 297 if (!bless) { | |
| 298 int much = rnd(9) - 4; | |
| 299 | |
| 300 if (much != 0) { | |
| 301 level += much; | |
| 302 if (level < 1) | |
| 303 level = 1; | |
| 304 mpos = 0; | |
| 305 new_level(NORMLEV); /* change levels */ | |
| 306 msg("You are whisked away to another region."); | |
| 307 s_know[S_DLEVEL] = TRUE; | |
| 308 } | |
| 309 } | |
| 310 when S_PROTECT: | |
| 311 if (!curse) { | |
| 312 struct linked_list *ll; | |
| 313 struct object *lb; | |
| 314 | |
| 315 msg("You are granted the power of protection."); | |
| 316 if ((ll = get_item("protect",0)) != NULL) { | |
| 317 lb = OBJPTR(ll); | |
| 318 setoflg(lb,ISPROT); | |
| 319 mpos = 0; | |
| 320 msg("Protected %s.",inv_name(lb,TRUE)); | |
| 321 } | |
| 322 s_know[S_PROTECT] = TRUE; | |
| 323 } | |
| 324 when S_ALLENCH: | |
| 325 if (!curse) { | |
| 326 struct linked_list *ll; | |
| 327 struct object *lb; | |
| 328 int howmuch, ac, good; | |
| 329 | |
| 330 msg("You are granted the power of enchantment."); | |
| 331 good = TRUE; | |
| 332 if ((ll = get_item("enchant",0)) != NULL) { | |
| 333 lb = OBJPTR(ll); | |
| 334 resoflg(lb,ISCURSED); | |
| 335 resoflg(lb,ISPROT); | |
| 336 howmuch = rnd(3) + 1; | |
| 337 switch(lb->o_type) { | |
| 338 case RING: | |
| 339 if (lb->o_ac < 0) | |
| 340 lb->o_ac = 0; | |
| 341 lb->o_ac += howmuch; | |
| 342 when ARMOR: | |
| 343 ac = armors[lb->o_which].a_class; | |
| 344 if (lb->o_ac > ac) | |
| 345 lb->o_ac = ac; | |
| 346 lb->o_ac -= howmuch; | |
| 347 when STICK: | |
| 348 lb->o_charges += howmuch + 10; | |
| 349 when WEAPON: | |
| 350 if (lb->o_dplus < 0) | |
| 351 lb->o_dplus = 0; | |
| 352 if (lb->o_hplus < 0) | |
| 353 lb->o_hplus = 0; | |
| 354 lb->o_hplus += howmuch; | |
| 355 lb->o_dplus += howmuch; | |
| 356 otherwise: | |
| 357 msg("You are injured as the scroll flashes & bursts into flames !!!"); | |
| 358 chg_hpt(-roll(6,6),FALSE,K_SCROLL); | |
| 359 good = FALSE; | |
| 360 } | |
| 361 if (good) { | |
| 362 mpos = 0; | |
| 363 msg("Enchanted %s.",inv_name(lb,TRUE)); | |
| 364 } | |
| 365 } | |
| 366 s_know[S_ALLENCH] = TRUE; | |
| 367 } | |
| 368 when S_BLESS: | |
| 369 if (!curse) { | |
| 370 struct linked_list *ll; | |
| 371 struct object *lb; | |
| 372 | |
| 373 msg("Your pack glistens brightly."); | |
| 374 for (ll = pack ; ll != NULL ; ll = next(ll)) { | |
| 375 whatis(ll); | |
| 376 lb = OBJPTR(ll); | |
| 377 resoflg(lb,ISCURSED); | |
| 378 setoflg(lb,ISBLESS); | |
