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

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

1.1       rubenllo    1:
                      2: /*
                      3:  * Special wizard commands (some of which are also non-wizard commands
                      4:  * under strange circumstances)
                      5:  *
                      6:  * @(#)wizard.c        4.14 (Berkeley) 1/26/82
                      7:  */
                      8:
                      9: #include <curses.h>
                     10: #include <ctype.h>
                     11: #include <stdlib.h>
                     12: #include <string.h>
                     13: #include "rogue.h"
                     14:
                     15: /*
                     16:  * whatis:
                     17:  *     What a certin object is
                     18:  */
                     19: void
                     20: whatis(bool insist)
                     21: {
                     22:     register THING *obj;
                     23:
                     24:     if (pack == NULL)
                     25:     {
                     26:        msg("You don't have anything in your pack to identify");
                     27:        return;
                     28:     }
                     29:
                     30:     for (;;)
                     31:        if ((obj = get_item("identify", 0)) == NULL && insist)
                     32:            msg("You must identify something");
                     33:        else
                     34:            break;
                     35:
                     36:     if (!insist && obj == NULL)
                     37:        return;
                     38:
                     39:     switch (obj->o_type)
                     40:     {
                     41:         case SCROLL:
                     42:            s_know[obj->o_which] = TRUE;
                     43:            if (s_guess[obj->o_which])
                     44:            {
                     45:                free(s_guess[obj->o_which]);
                     46:                s_guess[obj->o_which] = NULL;
                     47:            }
                     48:         when POTION:
                     49:            p_know[obj->o_which] = TRUE;
                     50:            if (p_guess[obj->o_which])
                     51:            {
                     52:                free(p_guess[obj->o_which]);
                     53:                p_guess[obj->o_which] = NULL;
                     54:            }
                     55:        when STICK:
                     56:            ws_know[obj->o_which] = TRUE;
                     57:            obj->o_flags |= ISKNOW;
                     58:            if (ws_guess[obj->o_which])
                     59:            {
                     60:                free(ws_guess[obj->o_which]);
                     61:                ws_guess[obj->o_which] = NULL;
                     62:            }
                     63:         when WEAPON:
                     64:         case ARMOR:
                     65:            obj->o_flags |= ISKNOW;
                     66:         when RING:
                     67:            r_know[obj->o_which] = TRUE;
                     68:            obj->o_flags |= ISKNOW;
                     69:            if (r_guess[obj->o_which])
                     70:            {
                     71:                free(r_guess[obj->o_which]);
                     72:                r_guess[obj->o_which] = NULL;
                     73:            }
                     74:     }
                     75:     msg(inv_name(obj, FALSE));
                     76: }
                     77:
                     78: #ifdef WIZARD
                     79: /*
                     80:  * create_obj:
                     81:  *     Wizard command for getting anything he wants
                     82:  */
                     83: void
                     84: create_obj(void)
                     85: {
                     86:     register THING *obj;
                     87:     register char ch, bless;
                     88:
                     89:     obj = new_item();
                     90:     msg("type of item: ");
                     91:     obj->o_type = readchar();
                     92:     mpos = 0;
                     93:     msg("which %c do you want? (0-f)", obj->o_type);
                     94:     obj->o_which = (isdigit((ch = readchar())) ? ch - '0' : ch - 'a' + 10);
                     95:     obj->o_group = 0;
                     96:     obj->o_count = 1;
                     97:     mpos = 0;
                     98:     if (obj->o_type == WEAPON || obj->o_type == ARMOR)
                     99:     {
                    100:        msg("blessing? (+,-,n)");
                    101:        bless = readchar();
                    102:        mpos = 0;
                    103:        if (bless == '-')
                    104:            obj->o_flags |= ISCURSED;
                    105:        if (obj->o_type == WEAPON)
                    106:        {
                    107:            init_weapon(obj, obj->o_which);
                    108:            if (bless == '-')
                    109:                obj->o_hplus -= rnd(3)+1;
                    110:            if (bless == '+')
                    111:                obj->o_hplus += rnd(3)+1;
                    112:        }
                    113:        else
                    114:        {
                    115:            obj->o_ac = a_class[obj->o_which];
                    116:            if (bless == '-')
                    117:                obj->o_ac += rnd(3)+1;
                    118:            if (bless == '+')
                    119:                obj->o_ac -= rnd(3)+1;
                    120:        }
                    121:     }
                    122:     else if (obj->o_type == RING)
                    123:        switch (obj->o_which)
                    124:        {
                    125:            case R_PROTECT:
                    126:            case R_ADDSTR:
                    127:            case R_ADDHIT:
                    128:            case R_ADDDAM:
                    129:                msg("blessing? (+,-,n)");
                    130:                bless = readchar();
                    131:                mpos = 0;
                    132:                if (bless == '-')
                    133:                    obj->o_flags |= ISCURSED;
                    134:                obj->o_ac = (bless == '-' ? -1 : rnd(2) + 1);
                    135:            when R_AGGR:
                    136:            case R_TELEPORT:
                    137:                obj->o_flags |= ISCURSED;
                    138:        }
                    139:     else if (obj->o_type == STICK)
                    140:        fix_stick(obj);
                    141:     else if (obj->o_type == GOLD)
                    142:     {
                    143:        msg("how much?");
                    144:        get_num(&obj->o_goldval, stdscr);
                    145:     }
                    146:     add_pack(obj, FALSE);
                    147: }
                    148: #endif
                    149:
                    150: /*
                    151:  * telport:
                    152:  *     Bamf the hero someplace else
                    153:  */
                    154: int
                    155: teleport(void)
                    156: {
                    157:     register int rm;
                    158:     coord c;
                    159:
                    160:     mvaddch(hero.y, hero.x, chat(hero.y, hero.x));
                    161:     do
                    162:     {
                    163:        rm = rnd_room();
                    164:        rnd_pos(&rooms[rm], &c);
                    165:     } until (step_ok(winat(c.y, c.x)));
                    166:     if (&rooms[rm] != proom)
                    167:     {
                    168:        leave_room(&hero);
                    169:        hero = c;
                    170:        enter_room(&hero);
                    171:     }
                    172:     else
                    173:     {
                    174:        hero = c;
                    175:        look(TRUE);
                    176:     }
                    177:     mvaddch(hero.y, hero.x, PLAYER);
                    178:     /*
                    179:      * turn off ISHELD in case teleportation was done while fighting
                    180:      * a Fungi
                    181:      */
                    182:     if (on(player, ISHELD)) {
                    183:        THING *mon;
                    184:
                    185:        player.t_flags &= ~ISHELD;
                    186:        fung_hit = 0;
                    187:        for (mon = mlist; mon != NULL; mon = next(mon)) {
                    188:            if (mon->t_type == 'F')
                    189:                strcpy(mon->t_stats.s_dmg, "0d0");
                    190:        }
                    191:     }
                    192:     no_move = 0;
                    193:     count = 0;
                    194:     running = FALSE;
                    195:     flush_type();
                    196:     return rm;
                    197: }
                    198:
                    199: #ifdef WIZARD
                    200: /*
                    201:  * passwd:
                    202:  *     See if user knows password
                    203:  */
                    204: bool
                    205: passwd(void)
                    206: {
                    207:     register char *sp, c;
                    208:     char buf[MAXSTR], *xcrypt();
                    209:
                    210:     msg("wizard's Password:");
                    211:     mpos = 0;
                    212:     sp = buf;
                    213:     while ((c = readchar()) != '\n' && c != '\r' && c != ESCAPE)
                    214:        if (c == md_killchar())
                    215:            sp = buf;
                    216:        else if (c == md_erasechar() && sp > buf)
                    217:            sp--;
                    218:        else
                    219:            *sp++ = c;
                    220:     if (sp == buf)
                    221:        return FALSE;
                    222:     *sp = '\0';
                    223:     return (strcmp(PASSWD, xcrypt(buf, "mT")) == 0);
                    224: }
                    225:
                    226: /*
                    227:  * show_map:
                    228:  *     Print out the map for the wizard
                    229:  */
                    230: void
                    231: show_map(void)
                    232: {
                    233:     register int y, x, real;
                    234:
                    235:     wclear(hw);
                    236:     for (y = 1; y < LINES - 1; y++)
                    237:        for (x = 0; x < COLS; x++)
                    238:        {
                    239:            if (!(real = flat(y, x) & F_REAL))
                    240:                wstandout(hw);
                    241:            wmove(hw, y, x);
                    242:            waddch(hw, chat(y, x));
                    243:            if (!real)
                    244:                wstandend(hw);
                    245:        }
                    246:     show_win(hw, "---More (level map)---");
                    247: }
                    248: #endif

CVSweb