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

Annotation of early-roguelike/arogue5/rings.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:  * routines dealing specifically with rings
                      3:  *
                      4:  * Advanced Rogue
                      5:  * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
                      6:  * All rights reserved.
                      7:  *
                      8:  * Based on "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 "rogue.h"
                     17: #include <stdlib.h>
                     18: #include <string.h>
                     19:
                     20: /*
                     21:  * how much food does this ring use up?
                     22:  */
                     23: int
                     24: ring_eat(int hand)
                     25: {
                     26:     if (cur_ring[hand] == NULL)
                     27:        return 0;
                     28:     switch (cur_ring[hand]->o_which) {
                     29:        case R_VAMPREGEN:
                     30:            return 3;
                     31:        case R_REGEN:
                     32:            return 2;
                     33:        case R_HEALTH:
                     34:        case R_SUSABILITY:
                     35:            return 1;
                     36:        case R_SEARCH:
                     37:        case R_SEEINVIS:
                     38:            return (rnd(100) < 33);
                     39:        case R_DIGEST:
                     40:            if (cur_ring[hand]->o_ac >= 0)
                     41:                return (-(cur_ring[hand]->o_ac)-1);
                     42:            else
                     43:                return (-(cur_ring[hand]->o_ac));
                     44:     }
                     45:     return 0;
                     46: }
                     47: 
                     48: void
                     49: ring_on(struct object *obj)
                     50: {
                     51:     register int save_max;
                     52:     char buf[LINELEN];
                     53:
                     54:     /*
                     55:      * Calculate the effect it has on the poor guy.
                     56:      */
                     57:     switch (obj->o_which)
                     58:     {
                     59:        case R_ADDSTR:
                     60:            save_max = max_stats.s_str;
                     61:            chg_str(obj->o_ac);
                     62:            max_stats.s_str = save_max;
                     63:        when R_ADDHIT:
                     64:            pstats.s_dext += obj->o_ac;
                     65:        when R_ADDINTEL:
                     66:            pstats.s_intel += obj->o_ac;
                     67:        when R_ADDWISDOM:
                     68:            pstats.s_wisdom += obj->o_ac;
                     69:        when R_SEEINVIS:
                     70:            turn_on(player, CANSEE);
                     71:            msg("Your eyes begin to tingle");
                     72:            light(&hero);
                     73:            mvwaddch(cw, hero.y, hero.x, PLAYER);
                     74:        when R_AGGR:
                     75:            aggravate();
                     76:        when R_WARMTH:
                     77:            turn_on(player, NOCOLD);
                     78:        when R_FIRE:
                     79:            turn_on(player, NOFIRE);
                     80:        when R_LIGHT: {
                     81:                if(roomin(&hero) != NULL) {
                     82:                        light(&hero);
                     83:                        mvwaddch(cw, hero.y, hero.x, PLAYER);
                     84:                }
                     85:            }
                     86:        when R_SEARCH:
                     87:                start_daemon(ring_search, 0, AFTER);
                     88:        when R_TELEPORT:
                     89:                start_daemon(ring_teleport, 0, AFTER);
                     90:     }
                     91:     status(FALSE);
                     92:     if (r_know[obj->o_which] && r_guess[obj->o_which])
                     93:     {
                     94:        free(r_guess[obj->o_which]);
                     95:        r_guess[obj->o_which] = NULL;
                     96:     }
                     97:     else if (!r_know[obj->o_which] &&
                     98:             askme &&
                     99:             (obj->o_flags & ISKNOW) == 0 &&
                    100:             r_guess[obj->o_which] == NULL) {
                    101:        msg(terse ? "Call it: " : "What do you want to call it? ");
                    102:        if (get_str(buf, msgw) == NORM)
                    103:        {
                    104:            r_guess[obj->o_which] = new((unsigned int) strlen(buf) + 1);
                    105:            strcpy(r_guess[obj->o_which], buf);
                    106:        }
                    107:        msg("");
                    108:     }
                    109: }
                    110: 
                    111: /*
                    112:  * print ring bonuses
                    113:  */
                    114: char *
                    115: ring_num(struct object *obj)
                    116: {
                    117:     static char buf[5];
                    118:
                    119:     if (!(obj->o_flags & ISKNOW))
                    120:        return "";
                    121:     switch (obj->o_which)
                    122:     {
                    123:        case R_PROTECT:
                    124:        case R_ADDSTR:
                    125:        case R_ADDDAM:
                    126:        case R_ADDHIT:
                    127:        case R_ADDINTEL:
                    128:        case R_ADDWISDOM:
                    129:        case R_DIGEST:
                    130:            buf[0] = ' ';
                    131:            strcpy(&buf[1], num(obj->o_ac, 0));
                    132:        when R_AGGR:
                    133:        case R_LIGHT:
                    134:        case R_HEAVY:
                    135:        case R_TELEPORT:
                    136:            if (obj->o_flags & ISCURSED)
                    137:                return " cursed";
                    138:            else
                    139:                return "";
                    140:        otherwise:
                    141:            return "";
                    142:     }
                    143:     return buf;
                    144: }
                    145: 
                    146: /*
                    147:  * Return the effect of the specified ring
                    148:  */
                    149: int
                    150: ring_value(int type)
                    151: {
                    152:     int result = 0;
                    153:
                    154:     if (ISRING(LEFT_1, type))  result += cur_ring[LEFT_1]->o_ac;
                    155:     if (ISRING(LEFT_2, type)) result += cur_ring[LEFT_2]->o_ac;
                    156:     if (ISRING(LEFT_3, type)) result += cur_ring[LEFT_3]->o_ac;
                    157:     if (ISRING(LEFT_4, type)) result += cur_ring[LEFT_4]->o_ac;
                    158:     if (ISRING(RIGHT_1, type)) result += cur_ring[RIGHT_1]->o_ac;
                    159:     if (ISRING(RIGHT_2, type))  result += cur_ring[RIGHT_2]->o_ac;
                    160:     if (ISRING(RIGHT_3, type)) result += cur_ring[RIGHT_3]->o_ac;
                    161:     if (ISRING(RIGHT_4, type))  result += cur_ring[RIGHT_4]->o_ac;
                    162:     return(result);
                    163: }

CVSweb