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

Annotation of early-roguelike/rogue3/wizard.c, Revision 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        3.8 (Berkeley) 6/3/81
        !             7:  *
        !             8:  * Rogue: Exploring the Dungeons of Doom
        !             9:  * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
        !            10:  * All rights reserved.
        !            11:  *
        !            12:  * See the file LICENSE.TXT for full copyright and licensing information.
        !            13:  */
        !            14:
        !            15: #include "curses.h"
        !            16: #include <ctype.h>
        !            17: #include <string.h>
        !            18: #include <stdlib.h>
        !            19: #include "machdep.h"
        !            20: #include "rogue.h"
        !            21:
        !            22: /*
        !            23:  * whatis:
        !            24:  *     What a certin object is
        !            25:  */
        !            26:
        !            27: void
        !            28: whatis()
        !            29: {
        !            30:     struct object *obj;
        !            31:     struct linked_list *item;
        !            32:
        !            33:     if ((item = get_item("identify", 0)) == NULL)
        !            34:        return;
        !            35:     obj = (struct object *) ldata(item);
        !            36:     switch (obj->o_type)
        !            37:     {
        !            38:         case SCROLL:
        !            39:            s_know[obj->o_which] = TRUE;
        !            40:            if (s_guess[obj->o_which])
        !            41:            {
        !            42:                free(s_guess[obj->o_which]);
        !            43:                s_guess[obj->o_which] = NULL;
        !            44:            }
        !            45:         when POTION:
        !            46:            p_know[obj->o_which] = TRUE;
        !            47:            if (p_guess[obj->o_which])
        !            48:            {
        !            49:                free(p_guess[obj->o_which]);
        !            50:                p_guess[obj->o_which] = NULL;
        !            51:            }
        !            52:        when STICK:
        !            53:            ws_know[obj->o_which] = TRUE;
        !            54:            obj->o_flags |= ISKNOW;
        !            55:            if (ws_guess[obj->o_which])
        !            56:            {
        !            57:                free(ws_guess[obj->o_which]);
        !            58:                ws_guess[obj->o_which] = NULL;
        !            59:            }
        !            60:         when WEAPON:
        !            61:         case ARMOR:
        !            62:            obj->o_flags |= ISKNOW;
        !            63:         when RING:
        !            64:            r_know[obj->o_which] = TRUE;
        !            65:            obj->o_flags |= ISKNOW;
        !            66:            if (r_guess[obj->o_which])
        !            67:            {
        !            68:                free(r_guess[obj->o_which]);
        !            69:                r_guess[obj->o_which] = NULL;
        !            70:            }
        !            71:     }
        !            72:     msg(inv_name(obj, FALSE));
        !            73: }
        !            74:
        !            75: /*
        !            76:  * create_obj:
        !            77:  *     Wizard command for getting anything he wants
        !            78:  */
        !            79:
        !            80: void
        !            81: create_obj()
        !            82: {
        !            83:     struct linked_list *item;
        !            84:     struct object *obj;
        !            85:     int bless;
        !            86:     int ch;
        !            87:
        !            88:     item = new_item(sizeof *obj);
        !            89:     obj = (struct object *) ldata(item);
        !            90:     msg("Type of item: ");
        !            91:     obj->o_type = readchar(cw);
        !            92:     mpos = 0;
        !            93:     msg("Which %c do you want? (0-f)", obj->o_type);
        !            94:     obj->o_which = (isdigit((ch = readchar(cw))) ? 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(cw);
        !           102:        mpos = 0;
        !           103:        if (obj->o_type == WEAPON)
        !           104:        {
        !           105:            init_weapon(obj, obj->o_which);
        !           106:            if (bless == '-') {
        !           107:                obj->o_hplus -= rnd(3)+1;
        !           108:                obj->o_flags |= ISCURSED;
        !           109:            }
        !           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:                obj->o_flags |= ISCURSED;
        !           119:            }
        !           120:            if (bless == '+')
        !           121:                obj->o_ac -= rnd(3)+1;
        !           122:        }
        !           123:     }
        !           124:     else if (obj->o_type == RING)
        !           125:        switch (obj->o_which)
        !           126:        {
        !           127:            case R_PROTECT:
        !           128:            case R_ADDSTR:
        !           129:            case R_ADDHIT:
        !           130:            case R_ADDDAM:
        !           131:                msg("Blessing? (+,-,n)");
        !           132:                bless = readchar(cw);
        !           133:                mpos = 0;
        !           134:                if (bless == '-')
        !           135:                    obj->o_flags |= ISCURSED;
        !           136:                obj->o_ac = (bless == '-' ? -1 : rnd(2) + 1);
        !           137:        }
        !           138:     else if (obj->o_type == STICK)
        !           139:        fix_stick(obj);
        !           140:     add_pack(item, FALSE);
        !           141: }
        !           142:
        !           143: /*
        !           144:  * telport:
        !           145:  *     Bamf the hero someplace else
        !           146:  */
        !           147:
        !           148: int
        !           149: teleport()
        !           150: {
        !           151:     int rm;
        !           152:     coord c;
        !           153:
        !           154:     c = hero;
        !           155:     mvwaddch(cw, hero.y, hero.x, mvwinch(stdscr, hero.y, hero.x));
        !           156:     do
        !           157:     {
        !           158:        rm = rnd_room();
        !           159:        rnd_pos(&rooms[rm], &hero);
        !           160:     } until(winat(hero.y, hero.x) == FLOOR);
        !           161:     light(&c);
        !           162:     light(&hero);
        !           163:     mvwaddch(cw, hero.y, hero.x, PLAYER);
        !           164:     /*
        !           165:      * turn off ISHELD in case teleportation was done while fighting
        !           166:      * a Fungi
        !           167:      */
        !           168:     if (on(player, ISHELD)) {
        !           169:        struct linked_list *item;
        !           170:        struct thing *mon;
        !           171:
        !           172:        player.t_flags &= ~ISHELD;
        !           173:        fung_hit = 0;
        !           174:        for (item = mlist; item != NULL; item = next(item)) {
        !           175:            mon = (struct thing *) ldata(item);
        !           176:            if (mon->t_type == 'F')
        !           177:                strcpy(mon->t_stats.s_dmg, "000d0");
        !           178:        }
        !           179:     }
        !           180:     count = 0;
        !           181:     running = FALSE;
        !           182:     flush_type();              /* flush typeahead */
        !           183:     return rm;
        !           184: }
        !           185:
        !           186: /*
        !           187:  * passwd:
        !           188:  *     see if user knows password
        !           189:  */
        !           190:
        !           191: int
        !           192: passwd()
        !           193: {
        !           194:     char *sp, c;
        !           195:     char buf[80];
        !           196:
        !           197:     msg("Wizard's Password:");
        !           198:     mpos = 0;
        !           199:     sp = buf;
        !           200:     while ((c = readchar(cw)) != '\n' && c != '\r' && c != '\033')
        !           201:        if (c == md_killchar())
        !           202:            sp = buf;
        !           203:        else if (c == md_erasechar() && sp > buf)
        !           204:            sp--;
        !           205:        else
        !           206:            *sp++ = c;
        !           207:     if (sp == buf)
        !           208:        return FALSE;
        !           209:     *sp = '\0';
        !           210:     return (strcmp(PASSWD, crypt(buf, "mT")) == 0);
        !           211: }

CVSweb