Annotation of researchv10no/games/rogue/wizard.c, revision 1.1.1.1

1.1       root        1: 
                      2: /*
                      3:  * Special wizard commands (some of which are also non-wizard commands
                      4:  * under strange circumstances)
                      5:  *
                      6:  * @(#)wizard.c        3.8 (Berkeley) 6/3/81
                      7:  */
                      8: 
                      9: #include <curses.h>
                     10: #include <ctype.h>
                     11: #include "rogue.h"
                     12: 
                     13: /*
                     14:  * whatis:
                     15:  *     What a certin object is
                     16:  */
                     17: 
                     18: whatis()
                     19: {
                     20:     register struct object *obj;
                     21:     register struct linked_list *item;
                     22: 
                     23:     if ((item = get_item("identify", 0)) == NULL)
                     24:        return;
                     25:     obj = (struct object *) ldata(item);
                     26:     switch (obj->o_type)
                     27:     {
                     28:         when SCROLL:
                     29:            s_know[obj->o_which] = TRUE;
                     30:            if (s_guess[obj->o_which])
                     31:            {
                     32:                cfree(s_guess[obj->o_which]);
                     33:                s_guess[obj->o_which] = NULL;
                     34:            }
                     35:         when POTION:
                     36:            p_know[obj->o_which] = TRUE;
                     37:            if (p_guess[obj->o_which])
                     38:            {
                     39:                cfree(p_guess[obj->o_which]);
                     40:                p_guess[obj->o_which] = NULL;
                     41:            }
                     42:        when STICK:
                     43:            ws_know[obj->o_which] = TRUE;
                     44:            obj->o_flags |= ISKNOW;
                     45:            if (ws_guess[obj->o_which])
                     46:            {
                     47:                cfree(ws_guess[obj->o_which]);
                     48:                ws_guess[obj->o_which] = NULL;
                     49:            }
                     50:         when WEAPON:
                     51:         case ARMOR:
                     52:            obj->o_flags |= ISKNOW;
                     53:         when RING:
                     54:            r_know[obj->o_which] = TRUE;
                     55:            obj->o_flags |= ISKNOW;
                     56:            if (r_guess[obj->o_which])
                     57:            {
                     58:                cfree(r_guess[obj->o_which]);
                     59:                r_guess[obj->o_which] = NULL;
                     60:            }
                     61:     }
                     62:     msg(inv_name(obj, FALSE));
                     63: }
                     64: 
                     65: /*
                     66:  * create_obj:
                     67:  *     Wizard command for getting anything he wants
                     68:  */
                     69: 
                     70: create_obj()
                     71: {
                     72:     register struct linked_list *item;
                     73:     register struct object *obj;
                     74:     register char ch, bless;
                     75: 
                     76:     item = new_item(sizeof *obj);
                     77:     obj = (struct object *) ldata(item);
                     78:     msg("Type of item: ");
                     79:     obj->o_type = readchar();
                     80:     mpos = 0;
                     81:     msg("Which %c do you want? (0-f)", obj->o_type);
                     82:     obj->o_which = (isdigit((ch = readchar())) ? ch - '0' : ch - 'a' + 10);
                     83:     obj->o_group = 0;
                     84:     obj->o_count = 1;
                     85:     mpos = 0;
                     86:     if (obj->o_type == WEAPON || obj->o_type == ARMOR)
                     87:     {
                     88:        msg("Blessing? (+,-,n)");
                     89:        bless = readchar();
                     90:        mpos = 0;
                     91:        if (bless == '-')
                     92:            obj->o_flags |= ISCURSED;
                     93:        if (obj->o_type == WEAPON)
                     94:        {
                     95:            init_weapon(obj, obj->o_which);
                     96:            if (bless == '-')
                     97:                obj->o_hplus -= rnd(3)+1;
                     98:            if (bless == '+')
                     99:                obj->o_hplus += rnd(3)+1;
                    100:        }
                    101:        else
                    102:        {
                    103:            obj->o_ac = a_class[obj->o_which];
                    104:            if (bless == '-')
                    105:                obj->o_ac += rnd(3)+1;
                    106:            if (bless == '+')
                    107:                obj->o_ac -= rnd(3)+1;
                    108:        }
                    109:     }
                    110:     else if (obj->o_type == RING)
                    111:        switch (obj->o_which)
                    112:        {
                    113:            case R_PROTECT:
                    114:            case R_ADDSTR:
                    115:            case R_ADDHIT:
                    116:            case R_ADDDAM:
                    117:                msg("Blessing? (+,-,n)");
                    118:                bless = readchar();
                    119:                mpos = 0;
                    120:                if (bless == '-')
                    121:                    obj->o_flags |= ISCURSED;
                    122:                obj->o_ac = (bless == '-' ? -1 : rnd(2) + 1);
                    123:        }
                    124:     else if (obj->o_type == STICK)
                    125:        fix_stick(obj);
                    126:     add_pack(item, FALSE);
                    127: }
                    128: 
                    129: /*
                    130:  * telport:
                    131:  *     Bamf the hero someplace else
                    132:  */
                    133: 
                    134: teleport()
                    135: {
                    136:     register int rm;
                    137:     coord c;
                    138: 
                    139:     c = hero;
                    140:     mvwaddch(cw, hero.y, hero.x, mvwinch(stdscr, hero.y, hero.x));
                    141:     do
                    142:     {
                    143:        rm = rnd_room();
                    144:        rnd_pos(&rooms[rm], &hero);
                    145:     } until(winat(hero.y, hero.x) == FLOOR);
                    146:     light(&c);
                    147:     light(&hero);
                    148:     mvwaddch(cw, hero.y, hero.x, PLAYER);
                    149:     /*
                    150:      * turn off ISHELD in case teleportation was done while fighting
                    151:      * a Fungi
                    152:      */
                    153:     if (on(player, ISHELD)) {
                    154:        player.t_flags &= ~ISHELD;
                    155:        fung_hit = 0;
                    156:        strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0");
                    157:     }
                    158:     count = 0;
                    159:     running = FALSE;
                    160: #if    USG==1
                    161:     ioctl(_tty_ch, TCFLSH, 0);
                    162: #else
                    163:     raw();     /* flush typeahead */
                    164:     noraw();
                    165: #endif
                    166:     return rm;
                    167: }
                    168: 
                    169: /*
                    170:  * passwd:
                    171:  *     see if user knows password
                    172:  */
                    173: 
                    174: passwd()
                    175: {
                    176:     register char *sp, c;
                    177:     char buf[80], *crypt();
                    178: 
                    179:     msg("Wizard's Password:");
                    180:     mpos = 0;
                    181:     sp = buf;
                    182:     while ((c = getchar()) != '\n' && c != '\r' && c != '\033')
                    183: #if    USG==1
                    184:        if (c == _tty.c_cc[VKILL])
                    185: #else
                    186:        if (c == _tty.sg_kill)
                    187: #endif
                    188:            sp = buf;
                    189: #if    USG==1
                    190:        else if (c == _tty.c_cc[VERASE] && sp > buf)
                    191: #else
                    192:        else if (c == _tty.sg_erase && sp > buf)
                    193: #endif
                    194:            sp--;
                    195:        else
                    196:            *sp++ = c;
                    197:     if (sp == buf)
                    198:        return FALSE;
                    199:     *sp = '\0';
                    200:     return (strcmp(PASSWD, crypt(buf, "mT")) == 0);
                    201: }

unix.superglobalmegacorp.com

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