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

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

1.1       rubenllo    1: /*
                      2:  *     @(#)potions.c   3.1     3.1     5/7/81
                      3:  * Function(s) for dealing with potions
                      4:  *
                      5:  * Rogue: Exploring the Dungeons of Doom
                      6:  * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
                      7:  * All rights reserved.
                      8:  *
                      9:  * See the file LICENSE.TXT for full copyright and licensing information.
                     10:  */
                     11:
                     12: #include "curses.h"
                     13: #include <stdlib.h>
                     14: #include <string.h>
                     15: #include "rogue.h"
                     16:
                     17: void
                     18: quaff()
                     19: {
                     20:     struct object *obj;
                     21:     struct linked_list *item, *titem;
                     22:     struct thing *th;
                     23:     char buf[80];
                     24:
                     25:     item = get_item("quaff", POTION);
                     26:     /*
                     27:      * Make certain that it is somethings that we want to drink
                     28:      */
                     29:     if (item == NULL)
                     30:        return;
                     31:     obj = (struct object *) ldata(item);
                     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:            if (off(player, ISHUH))
                     50:                msg("Wait, what's going on here. Huh? What? Who?");
                     51:
                     52:            if (on(player, ISHUH))
                     53:                lengthen(unconfuse, rnd(8)+HUHDURATION);
                     54:            else
                     55:                fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
                     56:
                     57:            player.t_flags |= ISHUH;
                     58:            p_know[P_CONFUSE] = TRUE;
                     59:        when P_POISON:
                     60:            if (!ISWEARING(R_SUSTSTR))
                     61:            {
                     62:                chg_str(-(rnd(3)+1));
                     63:                msg("You feel very sick now.");
                     64:            }
                     65:            else
                     66:                msg("You feel momentarily sick");
                     67:            p_know[P_POISON] = TRUE;
                     68:        when P_HEALING:
                     69:            if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
                     70:                pstats.s_hpt = ++max_hp;
                     71:            msg("You begin to feel better.");
                     72:            sight();
                     73:            p_know[P_HEALING] = TRUE;
                     74:        when P_STRENGTH:
                     75:            msg("You feel stronger, now.  What bulging muscles!");
                     76:            chg_str(1);
                     77:            p_know[P_STRENGTH] = TRUE;
                     78:        when P_MFIND:
                     79:            /*
                     80:             * Potion of monster detection, if there are monters, detect them
                     81:             */
                     82:            if (mlist != NULL)
                     83:            {
                     84:                wclear(hw);
                     85:                overwrite(mw, hw);
                     86:                show_win(hw,
                     87:                    "You begin to sense the presence of monsters.--More--");
                     88:                p_know[P_MFIND] = TRUE;
                     89:            }
                     90:            else
                     91:                msg("You have a strange feeling for a moment, then it passes.");
                     92:        when P_TFIND:
                     93:            /*
                     94:             * Potion of magic detection.  Show the potions and scrolls
                     95:             */
                     96:            if (lvl_obj != NULL)
                     97:            {
                     98:                struct linked_list *mobj;
                     99:                struct object *tp;
                    100:                int show;
                    101:
                    102:                show = FALSE;
                    103:                wclear(hw);
                    104:                for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj))
                    105:                {
                    106:                    tp = (struct object *) ldata(mobj);
                    107:                    if (is_magic(tp))
                    108:                    {
                    109:                        show = TRUE;
                    110:                        mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
                    111:                    }
                    112:                    p_know[P_TFIND] = TRUE;
                    113:                }
                    114:                for (titem = mlist; titem != NULL; titem = next(titem))
                    115:                {
                    116:                    struct linked_list *pitem;
                    117:
                    118:                    th = (struct thing *) ldata(titem);
                    119:                    for (pitem = th->t_pack; pitem != NULL; pitem = next(pitem))
                    120:                    {
                    121:                        if (is_magic(OBJPTR(pitem)))
                    122:                        {
                    123:                            show = TRUE;
                    124:                            mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
                    125:                        }
                    126:                        p_know[P_TFIND] = TRUE;
                    127:                    }
                    128:                }
                    129:                if (show)
                    130:                {
                    131:                    show_win(hw,
                    132:                        "You sense the presence of magic on this level.--More--");
                    133:                    break;
                    134:                }
                    135:            }
                    136:            msg("You have a strange feeling for a moment, then it passes.");
                    137:        when P_PARALYZE:
                    138:            msg("You can't move.");
                    139:            no_command = HOLDTIME;
                    140:            p_know[P_PARALYZE] = TRUE;
                    141:        when P_SEEINVIS:
                    142:            msg("This potion tastes like %s juice.", fruit);
                    143:            if (off(player, CANSEE))
                    144:            {
                    145:                player.t_flags |= CANSEE;
                    146:                fuse(unsee, 0, SEEDURATION, AFTER);
                    147:                light(&hero);
                    148:            }
                    149:            sight();
                    150:        when P_RAISE:
                    151:            msg("You suddenly feel much more skillful");
                    152:            p_know[P_RAISE] = TRUE;
                    153:            raise_level();
                    154:        when P_XHEAL:
                    155:            if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
                    156:                pstats.s_hpt = ++max_hp;
                    157:            msg("You begin to feel much better.");
                    158:            p_know[P_XHEAL] = TRUE;
                    159:            sight();
                    160:        when P_HASTE:
                    161:            if (add_haste(TRUE))
                    162:                msg("You feel yourself moving much faster.");
                    163:            p_know[P_HASTE] = TRUE;
                    164:        when P_RESTORE:
                    165:            msg("Hey, this tastes great.  It make you feel warm all over.");
                    166:            if (pstats.s_str.st_str < max_stats.s_str.st_str ||
                    167:                (pstats.s_str.st_str == 18 &&
                    168:                 pstats.s_str.st_add < max_stats.s_str.st_add))
                    169:            pstats.s_str = max_stats.s_str;
                    170:        when P_BLIND:
                    171:            msg("A cloak of darkness falls around you.");
                    172:            if (off(player, ISBLIND))
                    173:            {
                    174:                player.t_flags |= ISBLIND;
                    175:                fuse(sight, 0, SEEDURATION, AFTER);
                    176:                look(FALSE);
                    177:            }
                    178:            p_know[P_BLIND] = TRUE;
                    179:        when P_NOP:
                    180:            msg("This potion tastes extremely dull.");
                    181:        otherwise:
                    182:            msg("What an odd tasting potion!");
                    183:            return;
                    184:     }
                    185:     status();
                    186:     if (p_know[obj->o_which] && p_guess[obj->o_which])
                    187:     {
                    188:        free(p_guess[obj->o_which]);
                    189:        p_guess[obj->o_which] = NULL;
                    190:     }
                    191:     else if (!p_know[obj->o_which] && askme && p_guess[obj->o_which] == NULL)
                    192:     {
                    193:        msg(terse ? "Call it: " : "What do you want to call it? ");
                    194:        if (get_str(buf, cw) == NORM)
                    195:        {
                    196:            p_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1);
                    197:            if (p_guess[obj->o_which] != NULL)
                    198:                strcpy(p_guess[obj->o_which], buf);
                    199:        }
                    200:     }
                    201:     /*
                    202:      * Throw the item away
                    203:      */
                    204:     inpack--;
                    205:     if (obj->o_count > 1)
                    206:        obj->o_count--;
                    207:     else
                    208:     {
                    209:        detach(pack, item);
                    210:         discard(item);
                    211:     }
                    212: }

CVSweb