Annotation of researchv10no/games/rogue/potions.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.