Annotation of early-roguelike/xrogue/rings.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: rings.c - Routines dealing specificaly with rings
! 3:
! 4: XRogue: Expeditions into the Dungeons of Doom
! 5: Copyright (C) 1991 Robert Pietkivitch
! 6: All rights reserved.
! 7:
! 8: Based on "Advanced Rogue"
! 9: Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
! 10: All rights reserved.
! 11:
! 12: Based on "Rogue: Exploring the Dungeons of Doom"
! 13: Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
! 14: All rights reserved.
! 15:
! 16: See the file LICENSE.TXT for full copyright and licensing information.
! 17: */
! 18:
! 19: #include <stdlib.h>
! 20: #include <string.h>
! 21: #include <curses.h>
! 22: #include "rogue.h"
! 23:
! 24: /*
! 25: * routines dealing specifically with rings
! 26: */
! 27:
! 28: /*
! 29: * how much food does this ring use up?
! 30: */
! 31:
! 32: int
! 33: ring_eat(int hand)
! 34: {
! 35: if (cur_ring[hand] == NULL)
! 36: return 0;
! 37: switch (cur_ring[hand]->o_which) {
! 38: case R_VAMPREGEN:
! 39: return 3;
! 40: case R_REGEN:
! 41: case R_SUSABILITY:
! 42: return 2;
! 43: case R_HEALTH:
! 44: return 1;
! 45: case R_SEARCH:
! 46: case R_SEEINVIS:
! 47: return (rnd(100) < 50); /* 0 or 1 */
! 48: case R_DIGEST:
! 49: if (cur_ring[hand]->o_ac >= 0)
! 50: return (-(cur_ring[hand]->o_ac)-1);
! 51: else
! 52: return (-(cur_ring[hand]->o_ac));
! 53: }
! 54: return 0;
! 55: }
! 56:
! 57: void
! 58: ring_on(struct linked_list *item)
! 59: {
! 60: register struct object *obj;
! 61: register int save_max;
! 62:
! 63: obj = OBJPTR(item);
! 64:
! 65: /*
! 66: * Calculate the effect it has on the poor guy.
! 67: */
! 68: switch (obj->o_which)
! 69: {
! 70: case R_ADDSTR:
! 71: save_max = max_stats.s_str;
! 72: chg_str(obj->o_ac);
! 73: max_stats.s_str = save_max;
! 74: when R_ADDHIT:
! 75: pstats.s_dext += obj->o_ac;
! 76: when R_ADDINTEL:
! 77: pstats.s_intel += obj->o_ac;
! 78: when R_ADDWISDOM:
! 79: pstats.s_wisdom += obj->o_ac;
! 80: when R_SEEINVIS:
! 81: if (on(player, CANSEE)) msg("Your eyes sparkle.");
! 82: else msg("Your eyes begin to tingle.");
! 83: turn_on(player, CANSEE);
! 84: light(&hero);
! 85: mvwaddch(cw, hero.y, hero.x, PLAYER);
! 86: when R_AGGR:
! 87: aggravate(TRUE, TRUE); /* all charactors are affected*/
! 88: when R_WARMTH:
! 89: if (on(player, NOCOLD)) msg("You feel warm all over.");
! 90: else msg("You begin to feel warm.");
! 91: turn_on(player, NOCOLD);
! 92: when R_FIRE:
! 93: if (on(player, NOFIRE)) msg("You feel quite fire proof now.");
! 94: else msg("You begin to feel fire proof.");
! 95: turn_on(player, NOFIRE);
! 96: when R_LIGHT: {
! 97: if(roomin(&hero) != NULL) {
! 98: light(&hero);
! 99: mvwaddch(cw, hero.y, hero.x, PLAYER);
! 100: }
! 101: }
! 102: when R_SEARCH:
! 103: start_daemon(ring_search, NULL, AFTER);
! 104: when R_TELEPORT:
! 105: start_daemon(ring_teleport, NULL, AFTER);
! 106: }
! 107: status(FALSE);
! 108: if (r_know[obj->o_which] && r_guess[obj->o_which]) {
! 109: free(r_guess[obj->o_which]);
! 110: r_guess[obj->o_which] = NULL;
! 111: }
! 112: else if (!r_know[obj->o_which] &&
! 113: askme &&
! 114: (obj->o_flags & ISKNOW) == 0 &&
! 115: r_guess[obj->o_which] == NULL) {
! 116: nameitem(item, FALSE);
! 117: }
! 118: }
! 119:
! 120: /*
! 121: * print ring bonuses
! 122: */
! 123:
! 124: char *
! 125: ring_num(struct object *obj)
! 126: {
! 127: static char buf[5];
! 128:
! 129: if (!(obj->o_flags & ISKNOW))
! 130: return "";
! 131: switch (obj->o_which)
! 132: {
! 133: case R_PROTECT:
! 134: case R_ADDSTR:
! 135: case R_ADDDAM:
! 136: case R_ADDHIT:
! 137: case R_ADDINTEL:
! 138: case R_ADDWISDOM:
! 139: case R_DIGEST:
! 140: buf[0] = ' ';
! 141: strcpy(&buf[1], num(obj->o_ac, 0));
! 142: when R_AGGR:
! 143: case R_LIGHT:
! 144: case R_CARRY:
! 145: case R_TELEPORT:
! 146: if (obj->o_flags & ISCURSED)
! 147: return " cursed";
! 148: else
! 149: return "";
! 150: otherwise:
! 151: return "";
! 152: }
! 153: return buf;
! 154: }
! 155:
! 156: /*
! 157: * Return the effect of the specified ring
! 158: */
! 159:
! 160: int
! 161: ring_value(int type)
! 162: {
! 163: int result = 0;
! 164:
! 165: if (ISRING(LEFT_1, type)) result += cur_ring[LEFT_1]->o_ac;
! 166: if (ISRING(LEFT_2, type)) result += cur_ring[LEFT_2]->o_ac;
! 167: if (ISRING(LEFT_3, type)) result += cur_ring[LEFT_3]->o_ac;
! 168: if (ISRING(LEFT_4, type)) result += cur_ring[LEFT_4]->o_ac;
! 169: if (ISRING(RIGHT_1, type)) result += cur_ring[RIGHT_1]->o_ac;
! 170: if (ISRING(RIGHT_2, type)) result += cur_ring[RIGHT_2]->o_ac;
! 171: if (ISRING(RIGHT_3, type)) result += cur_ring[RIGHT_3]->o_ac;
! 172: if (ISRING(RIGHT_4, type)) result += cur_ring[RIGHT_4]->o_ac;
! 173: return(result);
! 174: }
! 175:
CVSweb