[BACK]Return to potions.c CVS log [TXT][DIR] Up to [contributed] / early-roguelike / rogue4

Annotation of early-roguelike/rogue4/potions.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:  * Function(s) for dealing with potions
                      3:  *
                      4:  * @(#)potions.c       4.24 (Berkeley) 4/6/82
                      5:  *
                      6:  * Rogue: Exploring the Dungeons of Doom
                      7:  * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
                      8:  * All rights reserved.
                      9:  *
                     10:  * See the file LICENSE.TXT for full copyright and licensing information.
                     11:  */
                     12:
                     13: #include <curses.h>
                     14: #include "rogue.h"
                     15:
                     16: /*
                     17:  * quaff:
                     18:  *     Quaff a potion from the pack
                     19:  */
                     20: void
                     21: quaff(void)
                     22: {
                     23:     register THING *obj, *th;
                     24:     register bool discardit = FALSE;
                     25:
                     26:     obj = get_item("quaff", POTION);
                     27:     /*
                     28:      * Make certain that it is somethings that we want to drink
                     29:      */
                     30:     if (obj == NULL)
                     31:        return;
                     32:     if (obj->o_type != POTION)
                     33:     {
                     34:        if (!terse)
                     35:            msg("yuk! Why would you want to drink that?");
                     36:        else
                     37:            msg("that's undrinkable");
                     38:        return;
                     39:     }
                     40:     if (obj == cur_weapon)
                     41:        cur_weapon = NULL;
                     42:
                     43:     /*
                     44:      * Calculate the effect it has on the poor guy.
                     45:      */
                     46:     switch (obj->o_which)
                     47:     {
                     48:        case P_CONFUSE:
                     49:            p_know[P_CONFUSE] = TRUE;
                     50:            if (!on(player, ISHUH))
                     51:            {
                     52:                if (on(player, ISHUH))
                     53:                    lengthen(unconfuse, rnd(8)+HUHDURATION);
                     54:                else
                     55:                    fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
                     56:                player.t_flags |= ISHUH;
                     57:                msg("wait, what's going on here. Huh? What? Who?");
                     58:            }
                     59:        when P_POISON:
                     60:            p_know[P_POISON] = TRUE;
                     61:            if (!ISWEARING(R_SUSTSTR))
                     62:            {
                     63:                chg_str(-(rnd(3)+1));
                     64:                msg("you feel very sick now");
                     65:            }
                     66:            else
                     67:                msg("you feel momentarily sick");
                     68:        when P_HEALING:
                     69:            p_know[P_HEALING] = TRUE;
                     70:            if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
                     71:                pstats.s_hpt = ++max_hp;
                     72:            sight();
                     73:            msg("you begin to feel better");
                     74:        when P_STRENGTH:
                     75:            p_know[P_STRENGTH] = TRUE;
                     76:            chg_str(1);
                     77:            msg("you feel stronger, now.  What bulging muscles!");
                     78:        when P_MFIND:
                     79:            player.t_flags |= SEEMONST;
                     80:            fuse(turn_see_off, TRUE, HUHDURATION, AFTER);
                     81:            if (mlist == NULL)
                     82:                msg("you have a strange feeling for a moment");
                     83:            else
                     84:                p_know[P_MFIND] |= turn_see(FALSE);
                     85:        when P_TFIND:
                     86:            /*
                     87:             * Potion of magic detection.  Show the potions and scrolls
                     88:             */
                     89:            if (lvl_obj != NULL)
                     90:            {
                     91:                register THING *tp;
                     92:                register bool show;
                     93:
                     94:                show = FALSE;
                     95:                wclear(hw);
                     96:                for (tp = lvl_obj; tp != NULL; tp = next(tp))
                     97:                {
                     98:                    if (is_magic(tp))
                     99:                    {
                    100:                        show = TRUE;
                    101:                        mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
                    102:                        p_know[P_TFIND] = TRUE;
                    103:                    }
                    104:                }
                    105:                for (th = mlist; th != NULL; th = next(th))
                    106:                {
                    107:                    for (tp = th->t_pack; tp != NULL; tp = next(tp))
                    108:                    {
                    109:                        if (is_magic(tp))
                    110:                        {
                    111:                            show = TRUE;
                    112:                            mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
                    113:                            p_know[P_TFIND] = TRUE;
                    114:                        }
                    115:                    }
                    116:                }
                    117:                if (show)
                    118:                {
                    119:                    show_win(hw,
                    120:                        "You sense the presence of magic on this level.--More--");
                    121:                    break;
                    122:                }
                    123:            }
                    124:            msg("you have a strange feeling for a moment, then it passes");
                    125:        when P_PARALYZE:
                    126:            p_know[P_PARALYZE] = TRUE;
                    127:            no_command = HOLDTIME;
                    128:            player.t_flags &= ~ISRUN;
                    129:            msg("you can't move");
                    130:        when P_SEEINVIS:
                    131:            if (!on(player, CANSEE))
                    132:            {
                    133:                fuse(unsee, 0, SEEDURATION, AFTER);
                    134:                look(FALSE);
                    135:                invis_on();
                    136:            }
                    137:            sight();
                    138:            msg("this potion tastes like %s juice", fruit);
                    139:        when P_RAISE:
                    140:            p_know[P_RAISE] = TRUE;
                    141:            msg("you suddenly feel much more skillful");
                    142:            raise_level();
                    143:        when P_XHEAL:
                    144:            p_know[P_XHEAL] = TRUE;
                    145:            if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
                    146:            {
                    147:                if (pstats.s_hpt > max_hp + pstats.s_lvl + 1)
                    148:                    ++max_hp;
                    149:                pstats.s_hpt = ++max_hp;
                    150:            }
                    151:            sight();
                    152:            msg("you begin to feel much better");
                    153:        when P_HASTE:
                    154:            p_know[P_HASTE] = TRUE;
                    155:            if (add_haste(TRUE))
                    156:                msg("you feel yourself moving much faster");
                    157:        when P_RESTORE:
                    158:            if (ISRING(LEFT, R_ADDSTR))
                    159:                add_str(&pstats.s_str, -cur_ring[LEFT]->o_ac);
                    160:            if (ISRING(RIGHT, R_ADDSTR))
                    161:                add_str(&pstats.s_str, -cur_ring[RIGHT]->o_ac);
                    162:            if (pstats.s_str < max_stats.s_str)
                    163:                pstats.s_str = max_stats.s_str;
                    164:            if (ISRING(LEFT, R_ADDSTR))
                    165:                add_str(&pstats.s_str, cur_ring[LEFT]->o_ac);
                    166:            if (ISRING(RIGHT, R_ADDSTR))
                    167:                add_str(&pstats.s_str, cur_ring[RIGHT]->o_ac);
                    168:            msg("hey, this tastes great.  It make you feel warm all over");
                    169:        when P_BLIND:
                    170:            p_know[P_BLIND] = TRUE;
                    171:            if (!on(player, ISBLIND))
                    172:            {
                    173:                player.t_flags |= ISBLIND;
                    174:                fuse(sight, 0, SEEDURATION, AFTER);
                    175:                look(FALSE);
                    176:            }
                    177:            msg("a cloak of darkness falls around you");
                    178:        when P_NOP:
                    179:            msg("this potion tastes extremely dull");
                    180:        otherwise:
                    181:            msg("what an odd tasting potion!");
                    182:            return;
                    183:     }
                    184:     status();
                    185:     /*
                    186:      * Throw the item away
                    187:      */
                    188:     inpack--;
                    189:     if (obj->o_count > 1)
                    190:        obj->o_count--;
                    191:     else
                    192:     {
                    193:        detach(pack, obj);
                    194:         discardit = TRUE;
                    195:     }
                    196:
                    197:     call_it(p_know[obj->o_which], &p_guess[obj->o_which]);
                    198:
                    199:     if (discardit)
                    200:        discard(obj);
                    201: }
                    202:
                    203: /*
                    204:  * invis_on:
                    205:  *     Turn on the ability to see invisible
                    206:  */
                    207: void
                    208: invis_on(void)
                    209: {
                    210:     register THING *th;
                    211:
                    212:     player.t_flags |= CANSEE;
                    213:     for (th = mlist; th != NULL; th = next(th))
                    214:        if (on(*th, ISINVIS) && see_monst(th))
                    215:        {
                    216:            move(th->t_pos.y, th->t_pos.x);
                    217:            addch(th->t_disguise);
                    218:        }
                    219: }
                    220:
                    221: /*
                    222:  * see_monst:
                    223:  *     Put on or off seeing monsters on this level
                    224:  */
                    225: bool
                    226: turn_see(bool turn_off)
                    227: {
                    228:     register THING *mp;
                    229:     register bool can_see, add_new;
                    230:
                    231:     add_new = FALSE;
                    232:     for (mp = mlist; mp != NULL; mp = next(mp))
                    233:     {
                    234:        move(mp->t_pos.y, mp->t_pos.x);
                    235:        can_see = (see_monst(mp) || inch() == (unsigned char)mp->t_type);
                    236:        if (turn_off)
                    237:        {
                    238:            if (!can_see)
                    239:                addch(mp->t_oldch);
                    240:        }
                    241:        else
                    242:        {
                    243:            if (!can_see)
                    244:                standout();
                    245:            addch(mp->t_type);
                    246:            if (!can_see)
                    247:            {
                    248:                standend();
                    249:                add_new++;
                    250:            }
                    251:        }
                    252:     }
                    253:     if (turn_off)
                    254:        player.t_flags &= ~SEEMONST;
                    255:     else
                    256:        player.t_flags |= SEEMONST;
                    257:     return add_new;
                    258: }
                    259:
                    260: /*
                    261:  * A wrapper for turn_see(TRUE), to be used as a fuse.
                    262:  */
                    263: void
                    264: turn_see_off(void)
                    265: {
                    266:     turn_see(TRUE);
                    267: }

CVSweb