Annotation of early-roguelike/arogue7/potions.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * potions.c - Function(s) for dealing with potions
! 3: *
! 4: * Advanced Rogue
! 5: * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
! 6: * All rights reserved.
! 7: *
! 8: * Based on "Rogue: Exploring the Dungeons of Doom"
! 9: * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
! 10: * All rights reserved.
! 11: *
! 12: * See the file LICENSE.TXT for full copyright and licensing information.
! 13: */
! 14:
! 15: /*
! 16: * Function(s) for dealing with potions
! 17: */
! 18:
! 19: #include <stdlib.h>
! 20: #include "curses.h"
! 21: #include "rogue.h"
! 22:
! 23:
! 24: /*
! 25: * add_abil is an array of functions used to change attributes. It must be
! 26: * ordered according to the attribute definitions in rogue.h.
! 27: */
! 28:
! 29: void (*add_abil[NUMABILITIES])() = {
! 30: add_intelligence, add_strength, add_wisdom, add_dexterity,
! 31: add_constitution, add_charisma
! 32: };
! 33:
! 34: /*
! 35: * res_abil is an array of functions used to change attributes. It must be
! 36: * ordered according to the attribute definitions in rogue.h.
! 37: */
! 38:
! 39: void (*res_abil[NUMABILITIES])() = {
! 40: res_intelligence, res_strength, res_wisdom, res_dexterity,
! 41: res_constitution, res_charisma
! 42: };
! 43:
! 44: /*
! 45: * Increase player's constitution
! 46: */
! 47:
! 48: void
! 49: add_constitution(int change)
! 50: {
! 51: /* Do the potion */
! 52: if (change < 0) {
! 53: msg("You feel less healthy now.");
! 54: pstats.s_const += change;
! 55: if (pstats.s_const <= 0)
! 56: death(D_CONSTITUTION);
! 57: }
! 58: else {
! 59: msg("You feel healthier now.");
! 60: pstats.s_const = min(pstats.s_const + change, 25);
! 61: }
! 62:
! 63: /* Adjust the maximum */
! 64: if (max_stats.s_const < pstats.s_const)
! 65: max_stats.s_const = pstats.s_const;
! 66: }
! 67:
! 68: /*
! 69: * Increase player's charisma
! 70: */
! 71:
! 72: void
! 73: add_charisma(int change)
! 74: {
! 75: /* Do the potion */
! 76: if (change < 0) msg("You feel less attractive now.");
! 77: else msg("You feel more attractive now.");
! 78:
! 79: pstats.s_charisma += change;
! 80: if (pstats.s_charisma > 25) pstats.s_charisma = 25;
! 81: else if (pstats.s_charisma < 3) pstats.s_charisma = 3;
! 82:
! 83: /* Adjust the maximum */
! 84: if (max_stats.s_charisma < pstats.s_charisma)
! 85: max_stats.s_charisma = pstats.s_charisma;
! 86: }
! 87:
! 88: /*
! 89: * Increase player's dexterity
! 90: */
! 91:
! 92: void
! 93: add_dexterity(int change)
! 94: {
! 95: int ring_str; /* Value of ring strengths */
! 96:
! 97: /* Undo any ring changes */
! 98: ring_str = ring_value(R_ADDHIT);
! 99: pstats.s_dext -= ring_str;
! 100:
! 101: /* Now do the potion */
! 102: if (change < 0) msg("You feel less dextrous now.");
! 103: else msg("You feel more dextrous now. Watch those hands!");
! 104:
! 105: pstats.s_dext += change;
! 106: if (pstats.s_dext > 25) pstats.s_dext = 25;
! 107: else if (pstats.s_dext < 3) pstats.s_dext = 3;
! 108:
! 109: /* Adjust the maximum */
! 110: if (max_stats.s_dext < pstats.s_dext)
! 111: max_stats.s_dext = pstats.s_dext;
! 112:
! 113: /* Now put back the ring changes */
! 114: if (ring_str)
! 115: pstats.s_dext += ring_str;
! 116: }
! 117:
! 118: /*
! 119: * add_haste:
! 120: * add a haste to the player
! 121: */
! 122:
! 123: void
! 124: add_haste(bool blessed)
! 125: {
! 126: int hasttime;
! 127:
! 128: if (player.t_ctype == C_MONK) { /* monks cannot be slowed or hasted */
! 129: msg(nothing);
! 130: return;
! 131: }
! 132:
! 133: if (blessed) hasttime = HASTETIME*2;
! 134: else hasttime = HASTETIME;
! 135:
! 136: if (on(player, ISSLOW)) { /* Is person slow? */
! 137: extinguish(noslow);
! 138: noslow();
! 139:
! 140: if (blessed) hasttime = HASTETIME/2;
! 141: else return;
! 142: }
! 143:
! 144: if (on(player, ISHASTE)) {
! 145: msg("You faint from exhaustion.");
! 146: player.t_no_move += movement(&player) * rnd(hasttime);
! 147: player.t_action = A_FREEZE;
! 148: lengthen(nohaste, roll(hasttime,hasttime));
! 149: }
! 150: else {
! 151: msg("You feel yourself moving %sfaster.", blessed ? "much " : "");
! 152: turn_on(player, ISHASTE);
! 153: fuse(nohaste, NULL, roll(hasttime, hasttime), AFTER);
! 154: }
! 155: }
! 156:
! 157: /*
! 158: * Increase player's intelligence
! 159: */
! 160: void
! 161: add_intelligence(int change)
! 162: {
! 163: int ring_str; /* Value of ring strengths */
! 164:
! 165: /* Undo any ring changes */
! 166: ring_str = ring_value(R_ADDINTEL);
! 167: pstats.s_intel -= ring_str;
! 168:
! 169: /* Now do the potion */
! 170: if (change < 0) msg("You feel slightly less intelligent now.");
! 171: else msg("You feel more intelligent now. What a mind!");
! 172:
! 173: pstats.s_intel += change;
! 174: if (pstats.s_intel > 25) pstats.s_intel = 25;
! 175: else if (pstats.s_intel < 3) pstats.s_intel = 3;
! 176:
! 177: /* Adjust the maximum */
! 178: if (max_stats.s_intel < pstats.s_intel)
! 179: max_stats.s_intel = pstats.s_intel;
! 180:
! 181: /* Now put back the ring changes */
! 182: if (ring_str)
! 183: pstats.s_intel += ring_str;
! 184: }
! 185:
! 186: /*
! 187: * this routine makes the hero move slower
! 188: */
! 189: void
! 190: add_slow(void)
! 191: {
! 192: /* monks cannot be slowed or hasted */
! 193: if (player.t_ctype == C_MONK || ISWEARING(R_FREEDOM)) {
! 194: msg(nothing);
! 195: return;
! 196: }
! 197:
! 198: if (on(player, ISHASTE)) { /* Already sped up */
! 199: extinguish(nohaste);
! 200: nohaste();
! 201: }
! 202: else {
! 203: msg("You feel yourself moving %sslower.",
! 204: on(player, ISSLOW) ? "even " : "");
! 205: if (on(player, ISSLOW))
! 206: lengthen(noslow, roll(HASTETIME,HASTETIME));
! 207: else {
! 208: turn_on(player, ISSLOW);
! 209: fuse(noslow, NULL, roll(HASTETIME,HASTETIME), AFTER);
! 210: }
! 211: }
! 212: }
! 213:
! 214: /*
! 215: * Increase player's strength
! 216: */
! 217:
! 218: void
! 219: add_strength(int change)
! 220: {
! 221:
! 222: if (change < 0) {
! 223: msg("You feel slightly weaker now.");
! 224: chg_str(change);
! 225: }
! 226: else {
! 227: msg("You feel stronger now. What bulging muscles!");
! 228: chg_str(change);
! 229: }
! 230: }
! 231:
! 232: /*
! 233: * Increase player's wisdom
! 234: */
! 235:
! 236: void
! 237: add_wisdom(int change)
! 238: {
! 239: int ring_str; /* Value of ring strengths */
! 240:
! 241: /* Undo any ring changes */
! 242: ring_str = ring_value(R_ADDWISDOM);
! 243: pstats.s_wisdom -= ring_str;
! 244:
! 245: /* Now do the potion */
! 246: if (change < 0) msg("You feel slightly less wise now.");
! 247: else msg("You feel wiser now. What a sage!");
! 248:
! 249: pstats.s_wisdom += change;
! 250: if (pstats.s_wisdom > 25) pstats.s_wisdom = 25;
! 251: else if (pstats.s_wisdom < 3) pstats.s_wisdom = 3;
! 252:
! 253: /* Adjust the maximum */
! 254: if (max_stats.s_wisdom < pstats.s_wisdom)
! 255: max_stats.s_wisdom = pstats.s_wisdom;
! 256:
! 257: /* Now put back the ring changes */
! 258: if (ring_str)
! 259: pstats.s_wisdom += ring_str;
! 260: }
! 261:
! 262: void
! 263: quaff(int which, int kind, int flags, bool is_potion)
! 264: {
! 265: register struct object *obj;
! 266: register struct linked_list *item, *titem;
! 267: register struct thing *th;
! 268: bool cursed, blessed;
! 269:
! 270: blessed = FALSE;
! 271: cursed = FALSE;
! 272: item = NULL;
! 273:
! 274: if (which < 0) { /* figure out which ourselves */
! 275: /* This is a potion. */
! 276: if (player.t_action != C_QUAFF) {
! 277: int units;
! 278:
! 279: item = get_item(pack, "quaff", QUAFFABLE, FALSE, FALSE);
! 280:
! 281: /*
! 282: * Make certain that it is somethings that we want to drink
! 283: */
! 284: if (item == NULL)
! 285: return;
! 286:
! 287: /* How long does it take to quaff? */
! 288: units = usage_time(item);
! 289: if (units < 0) return;
! 290:
! 291: player.t_using = item; /* Remember what it is */
! 292: player.t_no_move = units * movement(&player);
! 293: if ((OBJPTR(item))->o_type == POTION) player.t_action = C_QUAFF;
! 294: else player.t_action = C_USE;
! 295: return;
! 296: }
! 297:
! 298: /* We have waited our time, let's quaff the potion */
! 299: item = player.t_using;
! 300: player.t_using = NULL;
! 301: player.t_action = A_NIL;
! 302:
! 303: obj = OBJPTR(item);
! 304: /* remove it from the pack */
! 305: inpack--;
! 306: detach(pack, item);
! 307:
! 308: flags = obj->o_flags;
! 309: which = obj->o_which;
! 310: kind = obj->o_kind;
! 311: }
! 312: cursed = flags & ISCURSED;
! 313: blessed = flags & ISBLESSED;
! 314:
! 315: switch(which) {
! 316: case P_CLEAR:
! 317: if (cursed) {
! 318: confus_player();
! 319: }
! 320: else {
! 321: if (blessed) { /* Make player immune for the whole game */
! 322: extinguish(unclrhead); /* If we have a fuse, put it out */
! 323: msg("A strong blue aura surrounds your head.");
! 324: }
! 325: else { /* Just light a fuse for how long player is safe */
! 326: if (off(player, ISCLEAR)) {
! 327: fuse(unclrhead, NULL, CLRDURATION, AFTER);
! 328: msg("A faint blue aura surrounds your head.");
! 329: }
! 330: else { /* If we have a fuse lengthen it, else we
! 331: * are permanently clear.
! 332: */
! 333: if (find_slot(unclrhead) == 0)
! 334: msg("Your blue aura continues to glow strongly.");
! 335: else {
! 336: lengthen(unclrhead, CLRDURATION);
! 337: msg("Your blue aura brightens for a moment.");
! 338: }
! 339: }
! 340: }
! 341: turn_on(player, ISCLEAR);
! 342: /* If player is confused, unconfuse him */
! 343: if (on(player, ISHUH)) {
! 344: extinguish(unconfuse);
! 345: unconfuse();
! 346: }
! 347: }
! 348: when P_HEALING:
! 349: if (cursed) {
! 350: msg("You feel worse now.");
! 351: pstats.s_hpt -= roll(pstats.s_lvl, char_class[player.t_ctype].hit_pts);
! 352: if (pstats.s_hpt <= 0)
! 353: death(D_POISON);
! 354: }
! 355: else {
! 356: if (blessed) {
! 357: pstats.s_hpt += roll(pstats.s_lvl+1, char_class[player.t_ctype].hit_pts);
! 358: if (pstats.s_hpt > max_stats.s_hpt)
! 359: pstats.s_hpt = ++max_stats.s_hpt;
! 360: if (on(player, ISHUH)) {
! 361: extinguish(unconfuse);
! 362: unconfuse();
! 363: }
! 364: }
! 365: else {
! 366: pstats.s_hpt += roll(pstats.s_lvl+1, char_class[player.t_ctype].hit_pts/2);
! 367: if (pstats.s_hpt > max_stats.s_hpt)
! 368: pstats.s_hpt = ++max_stats.s_hpt;
! 369: }
! 370: msg("You begin to feel %sbetter.",
! 371: blessed ? "much " : "");
! 372: sight();
! 373: if (is_potion) p_know[P_HEALING] = TRUE;
! 374: }
! 375: when P_ABIL:
! 376: /* If it is cursed, we take a point away */
! 377: if (cursed) {
! 378: if (ISWEARING(R_SUSABILITY)) {
! 379: msg(nothing);
! 380: break;
! 381: }
! 382: else add_abil[kind](-1);
! 383: }
! 384:
! 385: /* Otherwise we add points */
! 386: else add_abil[kind](blessed ? 3 : 1);
! 387:
! 388: if (is_potion) p_know[P_ABIL] = TRUE;
! 389: when P_MFIND:
! 390: /*
! 391: * Potion of monster detection, if there are monters, detect them
! 392: */
! 393: if (mlist != NULL)
! 394: {
! 395: register struct thing *tp;
! 396: register struct linked_list *item;
! 397:
! 398: msg("You begin to sense the presence of monsters.");
! 399: wclear(hw);
! 400: for (item=mlist; item!=NULL; item=next(item)) {
! 401: tp = THINGPTR(item);
! 402: if (on(*tp, NODETECT))
! 403: continue;
! 404: if (off(*tp, ISRUN))/* turn off only on sleeping ones */
! 405: turn_off(*tp, CANSURPRISE);
! 406: mvwaddch(hw, tp->t_pos.y, tp->t_pos.x,
! 407: monsters[tp->t_index].m_appear);
! 408: }
! 409: waddstr(msgw, morestr);
! 410: clearok(msgw, FALSE);
! 411: draw(msgw);
! 412: wait_for(' ');
! 413: msg("");
! 414: overlay(hw, cw);
! 415: draw(cw);
! 416: if (is_potion) p_know[P_MFIND] = TRUE;
! 417: }
! 418: else
! 419: msg("You have a strange feeling for a moment, then it passes.");
! 420: when P_TFIND:
! 421: /*
! 422: * Potion of magic detection. Show the potions and scrolls
! 423: */
! 424: {
! 425: register struct linked_list *mobj;
! 426: register struct object *tp;
! 427: bool show;
! 428:
! 429: show = FALSE;
! 430: wclear(hw);
! 431: for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj)) {
! 432: tp = OBJPTR(mobj);
! 433: if (is_magic(tp)) {
! 434: char mag_type=MAGIC;
! 435:
! 436: /* Mark cursed items or bad weapons */
! 437: if ((tp->o_flags & ISCURSED) ||
! 438: (tp->o_type == WEAPON &&
! 439: (tp->o_hplus < 0 || tp->o_dplus < 0)))
! 440: mag_type = CMAGIC;
! 441: else if ((tp->o_flags & ISBLESSED) ||
! 442: (tp->o_type == WEAPON &&
! 443: (tp->o_hplus > 0 || tp->o_dplus > 0)))
! 444: mag_type = BMAGIC;
! 445: show = TRUE;
! 446: mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, mag_type);
! 447: }
! 448: }
! 449: for (titem = mlist; titem != NULL; titem = next(titem)) {
! 450: register struct linked_list *pitem;
! 451:
! 452: th = THINGPTR(titem);
! 453: if (on(*th, NODETECT)) continue;
! 454: for(pitem = th->t_pack; pitem != NULL; pitem = next(pitem)){
! 455: tp = OBJPTR(pitem);
! 456: if (is_magic(tp)) {
! 457: char mag_type=MAGIC;
! 458:
! 459: /* Mark cursed items or bad weapons */
! 460: if ((tp->o_flags & ISCURSED) ||
! 461: (tp->o_type == WEAPON &&
! 462: (tp->o_hplus < 0 || tp->o_dplus < 0)))
! 463: mag_type = CMAGIC;
! 464: else if ((tp->o_flags & ISBLESSED) ||
! 465: (tp->o_type == WEAPON &&
! 466: (tp->o_hplus > 0 || tp->o_dplus > 0)))
! 467: mag_type = BMAGIC;
! 468: show = TRUE;
! 469: mvwaddch(hw, th->t_pos.y, th->t_pos.x, mag_type);
! 470: }
! 471: }
! 472: }
! 473: if (show) {
! 474: if (is_potion) p_know[P_TFIND] = TRUE;
! 475: msg("You sense the presence of magic on this level.");
! 476: waddstr(msgw, morestr);
! 477: clearok(msgw, FALSE);
! 478: draw(msgw);
! 479: wait_for(' ');
! 480: msg("");
! 481: overlay(hw,cw);
! 482: draw(cw);
! 483: break;
! 484: }
! 485: else
! 486: msg("You have a strange feeling for a moment, then it passes.");
! 487: }
! 488: when P_SEEINVIS:
! 489: if (cursed) {
! 490: if (!find_slot(sight))
! 491: {
! 492: msg("A cloak of darkness falls around you.");
! 493: turn_on(player, ISBLIND);
! 494: fuse(sight, NULL, SEEDURATION, AFTER);
! 495: light(&hero);
! 496: }
! 497: else
! 498: lengthen(sight, SEEDURATION);
! 499: }
! 500: else {
! 501: if (off(player, CANSEE)) {
! 502: turn_on(player, CANSEE);
! 503: msg("Your eyes begin to tingle.");
! 504: fuse(unsee, NULL, blessed ? SEEDURATION*3 :SEEDURATION, AFTER);
! 505: light(&hero);
! 506: }
! 507: else if (find_slot(unsee) != 0)
! 508: lengthen(unsee, blessed ? SEEDURATION*3 : SEEDURATION);
! 509: sight();
! 510: }
! 511: when P_PHASE:
! 512: if (cursed) {
! 513: msg("You can't move.");
! 514: player.t_no_move = movement(&player) * FREEZETIME;
! 515: player.t_action = A_FREEZE;
! 516: }
! 517: else {
! 518: int duration;
! 519:
! 520: if (blessed) duration = 3;
! 521: else duration = 1;
! 522:
! 523: if (on(player, CANINWALL))
! 524: lengthen(unphase, duration*PHASEDURATION);
! 525: else {
! 526: fuse(unphase, NULL, duration*PHASEDURATION, AFTER);
! 527: turn_on(player, CANINWALL);
! 528: }
! 529: msg("You feel %slight-headed!",
! 530: blessed ? "very " : "");
! 531: }
! 532: when P_FLY: {
! 533: int duration;
! 534: bool say_message;
! 535:
! 536: say_message = TRUE;
! 537:
! 538: if (blessed) duration = 3;
! 539: else duration = 1;
! 540:
! 541: if (on(player, ISFLY)) {
! 542: if (find_slot(land))
! 543: lengthen(land, duration*FLYTIME);
! 544: else {
! 545: msg("Nothing happens."); /* Flying by cloak */
! 546: say_message = FALSE;
! 547: }
! 548: }
! 549: else {
! 550: fuse(land, NULL, duration*FLYTIME, AFTER);
! 551: turn_on(player, ISFLY);
! 552: }
! 553: if (say_message) {
! 554: if (is_potion) p_know[P_FLY] = TRUE;
! 555: msg("You feel %slighter than air!", blessed ? "much " : "");
! 556: }
! 557: }
! 558: when P_RAISE:
! 559: if (cursed) lower_level(D_POTION);
! 560: else {
! 561: msg("You suddenly feel %smore skillful",
! 562: blessed ? "much " : "");
! 563: p_know[P_RAISE] = TRUE;
! 564: raise_level();
! 565: if (blessed) raise_level();
! 566: }
! 567: when P_HASTE:
! 568: if (cursed) { /* Slow player down */
! 569: add_slow();
! 570: }
! 571: else {
! 572: add_haste(blessed);
! 573: if (is_potion) p_know[P_HASTE] = TRUE;
! 574: }
! 575: when P_RESTORE: {
! 576: register int i, howmuch, strength_tally;
! 577:
! 578: msg("Hey, this tastes great. It make you feel %swarm all over.",
! 579: blessed ? "really " : "");
! 580: howmuch = blessed ? 2 : 1;
! 581:
! 582: for (i=0; i<NUMABILITIES; i++) {
! 583: if (i == A_STRENGTH) {
! 584: if (lost_str) {
! 585: if (lost_str > howmuch) {
! 586: lost_str -= howmuch;
! 587:
! 588: /*
! 589: * Save the lost strength. We have to set
! 590: * temporarilty set it to 0 so that res_strength
! 591: * will not restore it.
! 592: */
! 593: strength_tally = lost_str;
! 594: lost_str = 0;
! 595: res_strength(howmuch);
! 596: lost_str = strength_tally;
! 597: }
! 598: else {
! 599: lost_str = 0;
! 600: extinguish(res_strength);
! 601: res_strength(howmuch);
! 602: }
! 603: }
! 604: else res_strength(howmuch);
! 605: }
! 606: else res_abil[i](howmuch);
! 607: }
! 608: }
! 609: when P_INVIS:
! 610: if (off(player, ISINVIS)) {
! 611: turn_on(player, ISINVIS);
! 612: msg("You have a tingling feeling all over your body");
! 613: fuse(appear, NULL, blessed ? GONETIME*3 : GONETIME, AFTER);
! 614: PLAYER = IPLAYER;
! 615: light(&hero);
! 616: }
! 617: else {
! 618: if (find_slot(appear)) {
! 619: msg("Your tingling feeling surges.");
! 620: lengthen(appear, blessed ? GONETIME*3 : GONETIME);
! 621: }
! 622: else msg("Nothing happens."); /* Using cloak */
! 623: }
! 624:
! 625: when P_FFIND:
! 626: {
! 627: register struct linked_list *nitem;
! 628: register struct object *nobj;
! 629: bool show;
! 630:
! 631: show = FALSE;
! 632: wclear(hw);
! 633: for (nitem = lvl_obj; nitem != NULL; nitem = next(nitem)) {
! 634: nobj = OBJPTR(nitem);
! 635: if (nobj->o_type == FOOD) {
! 636: show = TRUE;
! 637: mvwaddch(hw, nobj->o_pos.y, nobj->o_pos.x, FOOD);
! 638: }
! 639: }
! 640: for (nitem = mlist; nitem != NULL; nitem = next(nitem)) {
! 641: register struct linked_list *pitem;
! 642: register struct thing *th;
! 643:
! 644: th = THINGPTR(nitem);
! 645: if (on(*th, NODETECT)) continue;
! 646: for(pitem = th->t_pack; pitem != NULL; pitem = next(pitem)){
! 647: nobj = OBJPTR(pitem);
! 648: if (nobj->o_type == FOOD) {
! 649: show = TRUE;
! 650: mvwaddch(hw, th->t_pos.y, th->t_pos.x, FOOD);
! 651: }
! 652: }
! 653: }
! 654: if (show) {
! 655: if (is_potion) p_know[P_FFIND] = TRUE;
! 656: msg("Your nose tingles.");
! 657: msg("You sense the presence of food on this level.");
! 658: waddstr(msgw, morestr);
! 659: clearok(msgw, FALSE);
! 660: draw(msgw);
! 661: wait_for(' ');
! 662: msg("");
! 663: overlay(hw,cw);
! 664: draw(cw);
! 665: }
! 666: else
! 667: msg("You have a strange feeling for a moment, then it passes.");
! 668: }
! 669:
! 670: when P_SKILL:
! 671: if (cursed) {
! 672: msg("You feel less skillful.");
! 673:
! 674: /* Does he currently have an artifical skill? */
! 675: if (!find_slot(unskill)) { /* No skill */
! 676: pstats.s_lvladj = -2;
! 677: pstats.s_lvl += pstats.s_lvladj;
! 678: fuse(unskill, NULL, SKILLDURATION, AFTER);
! 679: }
! 680: else { /* Has an artifical skill */
! 681: /* Is the skill beneficial? */
! 682: if (pstats.s_lvladj > 0) {
! 683: /* Decrease the previous skill advantage */
! 684: pstats.s_lvl -= 2;
! 685: pstats.s_lvladj -= 2;
! 686:
! 687: /* If there is now a negative skill, lengthen time */
! 688: if (pstats.s_lvladj < 0)
! 689: lengthen(unskill, SKILLDURATION);
! 690:
! 691: /* If there is no skill advantage, unfuse us */
! 692: else if (pstats.s_lvladj == 0) extinguish(unskill);
! 693: }
! 694: else { /* Already bad */
! 695: /* Make it a little worse, and lengthen it */
! 696: pstats.s_lvl--;
! 697: pstats.s_lvladj--;
! 698: lengthen(unskill, SKILLDURATION);
! 699: }
! 700: }
! 701:
! 702: /* Is our level too low now? */
! 703: if (pstats.s_lvl < 1) death(D_POTION);
! 704: }
! 705: else {
! 706: int adjust;
! 707:
! 708: msg("You feel more skillful.");
! 709:
! 710: /* Get the adjustment */
! 711: adjust = blessed ? 3 : 2;
! 712:
! 713: /* Does he currently have an artifical skill? */
! 714: if (!find_slot(unskill)) {
! 715: pstats.s_lvladj = adjust;
! 716: pstats.s_lvl += pstats.s_lvladj;
! 717: fuse(unskill, NULL,
! 718: blessed ? SKILLDURATION*2 : SKILLDURATION, AFTER);
! 719: }
! 720: else { /* Has an artifical skill */
! 721: /* Is the skill detrimental? */
! 722: if (pstats.s_lvladj < 0) {
! 723: /* Decrease the previous skill advantage */
! 724: pstats.s_lvl += adjust;
! 725: pstats.s_lvladj += adjust;
! 726:
! 727: /* If there is now a positive skill, lengthen time */
! 728: if (pstats.s_lvladj < 0)
! 729: lengthen(unskill, SKILLDURATION);
! 730:
! 731: /* If there is no skill advantage, unfuse us */
! 732: else if (pstats.s_lvladj == 0) extinguish(unskill);
! 733: }
! 734: else { /* Already good */
! 735: /*
! 736: * Make the skill the maximum of the current good
! 737: * skill and what the adjust would give him.
! 738: */
! 739: pstats.s_lvl -= pstats.s_lvladj;
! 740: pstats.s_lvladj = max(pstats.s_lvladj, adjust);
! 741: pstats.s_lvl += pstats.s_lvladj;
! 742: lengthen(unskill,
! 743: blessed ? SKILLDURATION*2 : SKILLDURATION);
! 744: }
! 745: }
! 746: }
! 747:
! 748: when P_FIRE: {
! 749: int duration;
! 750: bool say_message;
! 751:
! 752: say_message = TRUE;
! 753:
! 754: if (blessed) duration = 3;
! 755: else duration = 1;
! 756:
! 757: if (on(player, NOFIRE)) {
! 758: if (find_slot(nofire))
! 759: lengthen(nofire, duration*FIRETIME);
! 760: else {
! 761: msg("Nothing happens."); /* has on a ring */
! 762: say_message = FALSE;
! 763: }
! 764: }
! 765: else {
! 766: fuse(nofire, NULL, duration*FIRETIME, AFTER);
! 767: turn_on(player, NOFIRE);
! 768: }
! 769: if (say_message) {
! 770: if (is_potion) p_know[P_FIRE] = TRUE;
! 771: msg("You feel %sfire resistant", blessed ? "very " : "");
! 772: }
! 773: }
! 774: when P_COLD: {
! 775: int duration;
! 776: bool say_message;
! 777:
! 778: say_message = TRUE;
! 779:
! 780: if (blessed) duration = 3;
! 781: else duration = 1;
! 782:
! 783: if (on(player, NOCOLD)) {
! 784: if (find_slot(nocold))
! 785: lengthen(nocold, duration*COLDTIME);
! 786: else {
! 787: msg("Nothing happens."); /* has on a ring */
! 788: say_message = FALSE;
! 789: }
! 790: }
! 791: else {
! 792: fuse(nocold, NULL, duration*COLDTIME, AFTER);
! 793: turn_on(player, NOCOLD);
! 794: }
! 795: if (say_message) {
! 796: if (is_potion) p_know[P_COLD] = TRUE;
! 797: msg("You feel %scold resistant", blessed ? "very " : "");
! 798: }
! 799: }
! 800: when P_LIGHTNING: {
! 801: int duration;
! 802: bool say_message;
! 803:
! 804: say_message = TRUE;
! 805:
! 806: if (blessed) duration = 3;
! 807: else duration = 1;
! 808:
! 809: if (on(player, NOBOLT)) {
! 810: if (find_slot(nobolt))
! 811: lengthen(nobolt, duration*BOLTTIME);
! 812: }
! 813: else {
! 814: fuse(nobolt, NULL, duration*BOLTTIME, AFTER);
! 815: turn_on(player, NOBOLT);
! 816: }
! 817: if (say_message)
! 818: msg("Your skin turns %sblue!", blessed ? "very " : "");
! 819: }
! 820: when P_POISON:
! 821: if (!save(VS_POISON, &player, -2)) {
! 822: msg("You feel very sick now.");
! 823: pstats.s_hpt /= 2;
! 824: if (!ISWEARING(R_SUSABILITY))
! 825: pstats.s_const--;
! 826: }
! 827: else {
! 828: msg("You feel sick now.");
! 829: pstats.s_hpt -= (pstats.s_hpt / 4);
! 830: }
! 831: if (pstats.s_const <= 0 || pstats.s_hpt <= 0)
! 832: death(D_POISON);
! 833: otherwise:
! 834: msg("What an odd tasting potion!");
! 835: return;
! 836: }
! 837: status(FALSE);
! 838: if (is_potion && item && p_know[which] && p_guess[which])
! 839: {
! 840: free(p_guess[which]);
! 841: p_guess[which] = NULL;
! 842: }
! 843: else if (is_potion &&
! 844: !p_know[which] &&
! 845: item &&
! 846: askme &&
! 847: (flags & ISKNOW) == 0 &&
! 848: (flags & ISPOST) == 0 &&
! 849: p_guess[which] == NULL) {
! 850: nameitem(item, FALSE);
! 851: }
! 852: if (item != NULL) o_discard(item);
! 853: updpack(TRUE, &player);
! 854: }
! 855:
! 856:
! 857: /*
! 858: * res_dexterity:
! 859: * Restore player's dexterity
! 860: * if called with zero the restore fully
! 861: */
! 862:
! 863: void
! 864: res_dexterity(int howmuch)
! 865: {
! 866: short save_max;
! 867: int ring_str;
! 868:
! 869: if (howmuch < 0) return;
! 870:
! 871: /* Discount the ring value */
! 872: ring_str = ring_value(R_ADDHIT);
! 873: pstats.s_dext -= ring_str;
! 874:
! 875: if (pstats.s_dext < max_stats.s_dext ) {
! 876: if (howmuch == 0)
! 877: pstats.s_dext = max_stats.s_dext;
! 878: else
! 879: pstats.s_dext = min(pstats.s_dext+howmuch, max_stats.s_dext);
! 880: }
! 881:
! 882: /* Redo the rings */
! 883: if (ring_str) {
! 884: save_max = max_stats.s_dext;
! 885: pstats.s_dext += ring_str;
! 886: max_stats.s_dext = save_max;
! 887: }
! 888: }
! 889:
! 890:
! 891: /*
! 892: * res_intelligence:
! 893: * Restore player's intelligence
! 894: */
! 895:
! 896: void
! 897: res_intelligence(int howmuch)
! 898: {
! 899: short save_max;
! 900: int ring_str;
! 901:
! 902: if (howmuch <= 0) return;
! 903:
! 904: /* Discount the ring value */
! 905: ring_str = ring_value(R_ADDINTEL);
! 906: pstats.s_intel -= ring_str;
! 907:
! 908: pstats.s_intel = min(pstats.s_intel + howmuch, max_stats.s_intel);
! 909:
! 910: /* Redo the rings */
! 911: if (ring_str) {
! 912: save_max = max_stats.s_intel;
! 913: pstats.s_intel += ring_str;
! 914: max_stats.s_intel = save_max;
! 915: }
! 916: }
! 917:
! 918: /*
! 919: * res_wisdom:
! 920: * Restore player's wisdom
! 921: */
! 922:
! 923: void
! 924: res_wisdom(int howmuch)
! 925: {
! 926: short save_max;
! 927: int ring_str;
! 928:
! 929: if (howmuch <= 0) return;
! 930:
! 931: /* Discount the ring value */
! 932: ring_str = ring_value(R_ADDWISDOM);
! 933: pstats.s_wisdom -= ring_str;
! 934:
! 935: pstats.s_wisdom = min(pstats.s_wisdom + howmuch, max_stats.s_wisdom);
! 936:
! 937: /* Redo the rings */
! 938: if (ring_str) {
! 939: save_max = max_stats.s_wisdom;
! 940: pstats.s_wisdom += ring_str;
! 941: max_stats.s_wisdom = save_max;
! 942: }
! 943: }
! 944:
! 945: /*
! 946: * res_constitution:
! 947: * Restore the players constitution.
! 948: */
! 949:
! 950: void
! 951: res_constitution(int howmuch)
! 952: {
! 953: if (howmuch > 0)
! 954: pstats.s_const = min(pstats.s_const + howmuch, max_stats.s_const);
! 955: }
! 956:
! 957: /*
! 958: * res_charisma:
! 959: * Restore the players charisma.
! 960: */
! 961:
! 962: void
! 963: res_charisma(int howmuch)
! 964: {
! 965: if (howmuch > 0)
! 966: pstats.s_charisma =
! 967: min(pstats.s_charisma + howmuch, max_stats.s_charisma);
! 968: }
CVSweb