Annotation of early-roguelike/srogue/potions.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * Functions for dealing with potions
! 3: *
! 4: * @(#)potions.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 <stdlib.h>
! 18: #include <string.h>
! 19: #include "rogue.h"
! 20: #include "rogue.ext"
! 21:
! 22: /*
! 23: * quaff:
! 24: * Let the hero drink a potion
! 25: */
! 26: void
! 27: quaff(void)
! 28: {
! 29: reg struct object *obj;
! 30: reg struct linked_list *item, *titem;
! 31: reg struct thing *th;
! 32: reg int wh;
! 33: char buf[LINLEN];
! 34: bool bless, curse;
! 35:
! 36: /*
! 37: * Make certain that it is somethings that we want to drink
! 38: */
! 39: if ((item = get_item("quaff", POTION)) == NULL)
! 40: return;
! 41: obj = OBJPTR(item);
! 42: if (obj->o_type != POTION) {
! 43: msg("That's undrinkable!");
! 44: after = FALSE;
! 45: return;
! 46: }
! 47: wh = obj->o_which;
! 48: bless = o_on(obj, ISBLESS);
! 49: curse = o_on(obj, ISCURSED);
! 50: del_pack(item); /* get rid of it */
! 51:
! 52: /*
! 53: * Calculate the effect it has on the poor guy.
! 54: */
! 55: switch(wh) {
! 56: case P_CONFUSE:
! 57: if (!bless) {
! 58: if (pl_on(ISINVINC))
! 59: msg("You remain level-headed.");
! 60: else {
! 61: chg_abil(WIS,-1,TRUE); /* confuse his mind */
! 62: if (pl_off(ISHUH)) {
! 63: msg("Wait, what's going on here. Huh? What? Who?");
! 64: if (pl_on(ISHUH))
! 65: lengthen(unconfuse,rnd(8)+HUHDURATION);
! 66: else
! 67: fuse(unconfuse,TRUE,rnd(8)+HUHDURATION);
! 68: player.t_flags |= ISHUH;
! 69: }
! 70: }
! 71: p_know[P_CONFUSE] = TRUE;
! 72: }
! 73: when P_POISON:
! 74: if (!bless) {
! 75: if (pl_off(ISINVINC) && !iswearing(R_SUSTSTR) &&
! 76: !iswearing(R_SUSAB)) {
! 77: chg_abil(CON,-1,TRUE);
! 78: chg_abil(STR,-(rnd(3)+1),TRUE);
! 79: msg("You feel very sick now.");
! 80: }
! 81: else
! 82: msg("You feel momentarily sick.");
! 83: p_know[P_POISON] = TRUE;
! 84: }
! 85: when P_HEALING:
! 86: if (!curse) {
! 87: heal_self(4, TRUE);
! 88: msg("You begin to feel better.");
! 89: if (!iswearing(R_SLOW))
! 90: notslow(FALSE);
! 91: sight(FALSE);
! 92: p_know[P_HEALING] = TRUE;
! 93: }
! 94: when P_STRENGTH:
! 95: if (!curse) {
! 96: msg("You feel stronger, now. What bulging muscles!");
! 97: chg_abil(STR,1,TRUE);
! 98: p_know[P_STRENGTH] = TRUE;
! 99: }
! 100: when P_MFIND:
! 101: /*
! 102: * Potion of monster detection - find all monsters
! 103: */
! 104: if (mlist != NULL && !curse) {
! 105: dispmons();
! 106: mpos = 0;
! 107: msg("You begin to sense the presence of monsters--More--");
! 108: p_know[P_MFIND] = TRUE;
! 109: wait_for(cw,' ');
! 110: msg(""); /* clear line */
! 111: }
! 112: else
! 113: msg("You have a strange feeling for a moment, then it passes.");
! 114: when P_TFIND:
! 115: /*
! 116: * Potion of magic detection. Show the potions and scrolls
! 117: */
! 118: if (lvl_obj != NULL && !curse) {
! 119: struct linked_list *mobj;
! 120: struct object *tp;
! 121: bool show;
! 122:
! 123: show = FALSE;
! 124: wclear(hw);
! 125: for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj)) {
! 126: tp = OBJPTR(mobj);
! 127: if (is_magic(tp)) {
! 128: show = TRUE;
! 129: mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
! 130: }
! 131: }
! 132: for(titem = mlist; titem != NULL; titem = next(titem)) {
! 133: reg struct linked_list *pitem;
! 134:
! 135: th = THINGPTR(titem);
! 136: for(pitem=th->t_pack;pitem!=NULL;pitem=next(pitem)) {
! 137: if (is_magic(ldata(pitem))) {
! 138: show = TRUE;
! 139: mvwaddch(hw,th->t_pos.y, th->t_pos.x, MAGIC);
! 140: }
! 141: }
! 142: }
! 143: if (show) {
! 144: msg("You begin to sense the presence of magic.");
! 145: overlay(hw,cw);
! 146: p_know[P_TFIND] = TRUE;
! 147: break;
! 148: }
! 149: }
! 150: msg("You have a strange feeling for a moment, then it passes.");
! 151: when P_PARALYZE:
! 152: if (!bless) {
! 153: if (pl_on(ISINVINC))
! 154: msg("You feel numb for a moment.");
! 155: else {
! 156: msg("You can't move.");
! 157: player.t_nocmd = HOLDTIME;
! 158: }
! 159: p_know[P_PARALYZE] = TRUE;
! 160: }
! 161: when P_SEEINVIS:
! 162: if (!curse) {
! 163: int invlen = roll(40,20);
! 164:
! 165: msg("This potion tastes like %s juice.", fruit);
! 166: if (pl_off(CANSEE)) {
! 167: player.t_flags |= CANSEE;
! 168: fuse(unsee, TRUE, invlen);
! 169: light(&hero);
! 170: }
! 171: else
! 172: lengthen(unsee, invlen);
! 173: sight(FALSE);
! 174: }
! 175: when P_RAISE:
! 176: if (!curse) {
! 177: msg("You suddenly feel much more skillful.");
! 178: p_know[P_RAISE] = TRUE;
! 179: chg_abil(DEX,1,TRUE);
! 180: chg_abil(WIS,1,TRUE);
! 181: chg_abil(CON,1,TRUE);
! 182: raise_level();
! 183: }
! 184: when P_XHEAL:
! 185: if (!curse) {
! 186: heal_self(8, TRUE);
! 187: if (rnd(100) < 50)
! 188: chg_abil(CON,1,TRUE);
! 189: msg("You begin to feel much better.");
! 190: p_know[P_XHEAL] = TRUE;
! 191: if (!iswearing(R_SLOW))
! 192: notslow(FALSE);
! 193: unconfuse(FALSE);
! 194: extinguish(unconfuse);
! 195: sight(FALSE);
! 196: }
! 197: when P_HASTE:
! 198: if (!curse) {
! 199: add_haste(TRUE);
! 200: p_know[P_HASTE] = TRUE;
! 201: }
! 202: when P_INVINC:
! 203: if (!curse) {
! 204: int time = rnd(400) + 350;
! 205:
! 206: msg("You feel invincible.");
! 207: if (player.t_flags & ISINVINC)
! 208: lengthen(notinvinc,time);
! 209: else
! 210: fuse(notinvinc,TRUE,time);
! 211: player.t_flags |= ISINVINC;
! 212: p_know[P_INVINC] = TRUE;
! 213: }
! 214: when P_SMART:
! 215: if (!curse) {
! 216: msg("You feel more perceptive.");
! 217: p_know[P_SMART] = TRUE;
! 218: chg_abil(WIS,1,TRUE);
! 219: }
! 220: when P_RESTORE:
! 221: if (!curse) {
! 222: msg("Hey, this tastes great. You feel warm all over.");
! 223: him->s_re = max_stats.s_re;
! 224: him->s_ef = max_stats.s_re;
! 225: ringabil(); /* add in rings */
! 226: updpack(); /* update weight */
! 227: p_know[P_RESTORE] = TRUE;
! 228: extinguish(rchg_str); /* kill restore in from ulodyte */
! 229: }
! 230: when P_BLIND:
! 231: if (!bless) {
! 232: if (pl_on(ISINVINC))
! 233: msg("The light dims for a moment.");
! 234: else {
! 235: chg_abil(WIS,-1,TRUE);
! 236: msg("A cloak of darkness falls around you.");
! 237: if (pl_off(ISBLIND)) {
! 238: player.t_flags |= ISBLIND;
! 239: fuse(sight, TRUE, rnd(400) + 450);
! 240: light(&hero);
! 241: }
! 242: }
! 243: p_know[P_BLIND] = TRUE;
! 244: }
! 245: when P_ETH:
! 246: if (!curse) {
! 247: int ethlen = roll(40,20);
! 248:
! 249: msg("You feel more vaporous.");
! 250: if (pl_on(ISETHER))
! 251: lengthen(noteth,ethlen);
! 252: else
! 253: fuse(noteth,TRUE,ethlen);
! 254: player.t_flags |= ISETHER;
! 255: p_know[P_ETH] = TRUE;
! 256: }
! 257: when P_NOP:
! 258: msg("This potion tastes extremely dull.");
! 259: when P_DEX:
! 260: if (!curse) {
! 261: chg_abil(DEX,1,TRUE); /* increase dexterity */
! 262: p_know[P_DEX] = TRUE;
! 263: msg("You feel much more agile.");
! 264: }
! 265: when P_REGEN:
! 266: if (!curse) {
! 267: int reglen = rnd(450) + 450;
! 268:
! 269: if (pl_on(ISREGEN))
! 270: lengthen(notregen, reglen);
! 271: else
! 272: fuse(notregen, TRUE, reglen);
! 273: player.t_flags |= ISREGEN;
! 274: msg("You feel yourself improved.");
! 275: p_know[P_REGEN] = TRUE;
! 276: }
! 277: when P_DECREP:
! 278: case P_SUPHERO: {
! 279: int howmuch = rnd(3) + 1;
! 280:
! 281: if (wh == P_DECREP) {
! 282: if (!bless) {
! 283: if (iswearing(R_SUSAB) || pl_on(ISINVINC)) {
! 284: msg("You feel momentarily woozy.");
! 285: howmuch = 0;
! 286: }
! 287: else {
! 288: msg("You feel crippled.");
! 289: howmuch = -howmuch;
! 290: if (!iswearing(R_SUSTSTR))
! 291: chg_abil(STR,howmuch,TRUE);
! 292: }
! 293: }
! 294: else
! 295: howmuch = 0;
! 296: }
! 297: else { /* potion of superhero */
! 298: if (curse)
! 299: howmuch = 0;
! 300: msg("You feel invigorated.");
! 301: chg_abil(STR,howmuch,TRUE);
! 302: }
! 303: chg_abil(CON,howmuch,TRUE);
! 304: chg_abil(DEX,howmuch,TRUE);
! 305: chg_abil(WIS,howmuch,TRUE); /* change abilities */
! 306: p_know[wh] = TRUE;
! 307: }
! 308: otherwise:
! 309: msg("What an odd tasting potion!");
! 310: return;
! 311: }
! 312: nochange = FALSE;
! 313: if (p_know[wh] && p_guess[wh]) {
! 314: free(p_guess[wh]);
! 315: p_guess[wh] = NULL;
! 316: }
! 317: else if(!p_know[wh] && p_guess[wh] == NULL) {
! 318: strcpy(buf, p_colors[wh]);
! 319: msg(callit);
! 320: if (get_str(buf, cw) == NORM) {
! 321: p_guess[wh] = new(strlen(buf) + 1);
! 322: strcpy(p_guess[wh], buf);
! 323: }
! 324: }
! 325: }
CVSweb