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

Annotation of early-roguelike/rogue5/wizard.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:  * Special wizard commands (some of which are also non-wizard commands
                      3:  * under strange circumstances)
                      4:  *
                      5:  * @(#)wizard.c        4.30 (Berkeley) 02/05/99
                      6:  *
                      7:  * Rogue: Exploring the Dungeons of Doom
                      8:  * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
                      9:  * All rights reserved.
                     10:  *
                     11:  * See the file LICENSE.TXT for full copyright and licensing information.
                     12:  */
                     13:
                     14: #include <stdlib.h>
                     15: #include <curses.h>
                     16: #include <string.h>
                     17: #include <ctype.h>
                     18: #include "rogue.h"
                     19:
                     20: /*
                     21:  * whatis:
                     22:  *     What a certin object is
                     23:  */
                     24:
                     25: void
                     26: whatis(int insist, int type)
                     27: {
                     28:     THING *obj;
                     29:
                     30:     if (pack == NULL)
                     31:     {
                     32:        msg("you don't have anything in your pack to identify");
                     33:        return;
                     34:     }
                     35:
                     36:     for (;;)
                     37:     {
                     38:        obj = get_item("identify", type);
                     39:        if (insist)
                     40:        {
                     41:            if (n_objs == 0)
                     42:                return;
                     43:            else if (obj == NULL)
                     44:                msg("you must identify something");
                     45:            else if (type && obj->o_type != type &&
                     46:               !(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) )
                     47:                    msg("you must identify a %s", type_name(type));
                     48:            else
                     49:                break;
                     50:        }
                     51:        else
                     52:            break;
                     53:     }
                     54:
                     55:     if (obj == NULL)
                     56:        return;
                     57:
                     58:     switch (obj->o_type)
                     59:     {
                     60:         case SCROLL:
                     61:            set_know(obj, scr_info);
                     62:         when POTION:
                     63:            set_know(obj, pot_info);
                     64:        when STICK:
                     65:            set_know(obj, ws_info);
                     66:         when WEAPON:
                     67:         case ARMOR:
                     68:            obj->o_flags |= ISKNOW;
                     69:         when RING:
                     70:            set_know(obj, ring_info);
                     71:     }
                     72:     msg(inv_name(obj, FALSE));
                     73: }
                     74:
                     75: /*
                     76:  * set_know:
                     77:  *     Set things up when we really know what a thing is
                     78:  */
                     79:
                     80: void
                     81: set_know(THING *obj, struct obj_info *info)
                     82: {
                     83:     char **guess;
                     84:
                     85:     info[obj->o_which].oi_know = TRUE;
                     86:     obj->o_flags |= ISKNOW;
                     87:     guess = &info[obj->o_which].oi_guess;
                     88:     if (*guess)
                     89:     {
                     90:        free(*guess);
                     91:        *guess = NULL;
                     92:     }
                     93: }
                     94:
                     95: /*
                     96:  * type_name:
                     97:  *     Return a pointer to the name of the type
                     98:  */
                     99: const char *
                    100: type_name(int type)
                    101: {
                    102:     struct h_list *hp;
                    103:     struct h_list tlist[] = {
                    104:        {POTION, "potion",              FALSE},
                    105:        {SCROLL, "scroll",              FALSE},
                    106:        {FOOD,   "food",                FALSE},
                    107:        {R_OR_S, "ring, wand or staff", FALSE},
                    108:        {RING,   "ring",                FALSE},
                    109:        {STICK,  "wand or staff",       FALSE},
                    110:        {WEAPON, "weapon",              FALSE},
                    111:        {ARMOR,  "suit of armor",       FALSE},
                    112:     };
                    113:
                    114:     for (hp = tlist; hp->h_ch; hp++)
                    115:        if (type == hp->h_ch)
                    116:            return hp->h_desc;
                    117:     /* NOTREACHED */
                    118:     return(0);
                    119: }
                    120:
                    121: #ifdef MASTER
                    122: /*
                    123:  * create_obj:
                    124:  *     wizard command for getting anything he wants
                    125:  */
                    126:
                    127: void
                    128: create_obj(void)
                    129: {
                    130:     THING *obj;
                    131:     int ch, bless;
                    132:
                    133:     obj = new_item();
                    134:     msg("type of item: ");
                    135:     obj->o_type = readchar();
                    136:     mpos = 0;
                    137:     msg("which %c do you want? (0-f)", obj->o_type);
                    138:     obj->o_which = (isdigit((ch = readchar())) ? ch - '0' : ch - 'a' + 10);
                    139:     obj->o_group = 0;
                    140:     obj->o_count = 1;
                    141:     mpos = 0;
                    142:     if (obj->o_type == WEAPON || obj->o_type == ARMOR)
                    143:     {
                    144:        msg("blessing? (+,-,n)");
                    145:        bless = readchar();
                    146:        mpos = 0;
                    147:        if (bless == '-')
                    148:            obj->o_flags |= ISCURSED;
                    149:        if (obj->o_type == WEAPON)
                    150:        {
                    151:            init_weapon(obj, obj->o_which);
                    152:            if (bless == '-')
                    153:                obj->o_hplus -= rnd(3)+1;
                    154:            if (bless == '+')
                    155:                obj->o_hplus += rnd(3)+1;
                    156:        }
                    157:        else
                    158:        {
                    159:            obj->o_arm = a_class[obj->o_which];
                    160:            if (bless == '-')
                    161:                obj->o_arm += rnd(3)+1;
                    162:            if (bless == '+')
                    163:                obj->o_arm -= rnd(3)+1;
                    164:        }
                    165:     }
                    166:     else if (obj->o_type == RING)
                    167:        switch (obj->o_which)
                    168:        {
                    169:            case R_PROTECT:
                    170:            case R_ADDSTR:
                    171:            case R_ADDHIT:
                    172:            case R_ADDDAM:
                    173:                msg("blessing? (+,-,n)");
                    174:                bless = readchar();
                    175:                mpos = 0;
                    176:                if (bless == '-')
                    177:                    obj->o_flags |= ISCURSED;
                    178:                obj->o_arm = (bless == '-' ? -1 : rnd(2) + 1);
                    179:            when R_AGGR:
                    180:            case R_TELEPORT:
                    181:                obj->o_flags |= ISCURSED;
                    182:        }
                    183:     else if (obj->o_type == STICK)
                    184:        fix_stick(obj);
                    185:     else if (obj->o_type == GOLD)
                    186:     {
                    187:        msg("how much?");
                    188:        get_num(&obj->o_goldval, stdscr);
                    189:     }
                    190:     add_pack(obj, FALSE);
                    191: }
                    192: #endif
                    193:
                    194: /*
                    195:  * telport:
                    196:  *     Bamf the hero someplace else
                    197:  */
                    198:
                    199: void
                    200: teleport(void)
                    201: {
                    202:     coord c;
                    203:
                    204:     mvaddch(hero.y, hero.x, floor_at());
                    205:     find_floor(NULL, &c, FALSE, TRUE);
                    206:     if (roomin(&c) != proom)
                    207:     {
                    208:        leave_room(&hero);
                    209:        hero = c;
                    210:        enter_room(&hero);
                    211:     }
                    212:     else
                    213:     {
                    214:        hero = c;
                    215:        look(TRUE);
                    216:     }
                    217:     mvaddch(hero.y, hero.x, PLAYER);
                    218:     /*
                    219:      * turn off ISHELD in case teleportation was done while fighting
                    220:      * a Flytrap
                    221:      */
                    222:     if (on(player, ISHELD)) {
                    223:        THING *mp;
                    224:
                    225:        player.t_flags &= ~ISHELD;
                    226:        vf_hit = 0;
                    227:        for (mp = mlist; mp != NULL; mp = next(mp)) {
                    228:            if (mp->t_type == 'F')
                    229:                strcpy(mp->t_stats.s_dmg, "0x0");
                    230:        }
                    231:     }
                    232:     no_move = 0;
                    233:     count = 0;
                    234:     running = FALSE;
                    235:     flush_type();
                    236: }
                    237:
                    238: #ifdef MASTER
                    239: /*
                    240:  * passwd:
                    241:  *     See if user knows password
                    242:  */
                    243: int
                    244: passwd(void)
                    245: {
                    246:     char *sp;
                    247:     int c;
                    248:     static char buf[MAXSTR];
                    249:
                    250:     msg("wizard's Password:");
                    251:     mpos = 0;
                    252:     sp = buf;
                    253:     while ((c = readchar()) != '\n' && c != '\r' && c != ESCAPE)
                    254:        if (c == md_killchar())
                    255:            sp = buf;
                    256:        else if (c == md_erasechar() && sp > buf)
                    257:            sp--;
                    258:        else
                    259:            *sp++ = (char) c;
                    260:     if (sp == buf)
                    261:        return FALSE;
                    262:     *sp = '\0';
                    263:     return (strcmp(PASSWD, md_crypt(buf, "mT")) == 0);
                    264: }
                    265:
                    266: /*
                    267:  * show_map:
                    268:  *     Print out the map for the wizard
                    269:  */
                    270:
                    271: void
                    272: show_map(void)
                    273: {
                    274:     int y, x, real;
                    275:
                    276:     wclear(hw);
                    277:     for (y = 1; y < NUMLINES - 1; y++)
                    278:        for (x = 0; x < NUMCOLS; x++)
                    279:        {
                    280:            real = flat(y, x) & F_REAL;
                    281:            if (!real)
                    282:                wstandout(hw);
                    283:            wmove(hw, y, x);
                    284:            waddch(hw, chat(y, x));
                    285:            if (!(real & F_REAL))
                    286:                wstandend(hw);
                    287:        }
                    288:     show_win("---More (level map)---");
                    289: }
                    290: #endif

CVSweb