Annotation of early-roguelike/arogue7/rings.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * rings.c - routines dealing specifically with rings
! 3: * Advanced Rogue
! 4: * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
! 5: * All rights reserved.
! 6: *
! 7: * Based on "Rogue: Exploring the Dungeons of Doom"
! 8: * Copyright (C) 1980, 1981 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 <string.h>
! 16: #include "curses.h"
! 17: #include "rogue.h"
! 18:
! 19: /*
! 20: * routines dealing specifically with rings
! 21: */
! 22:
! 23:
! 24: /*
! 25: * how much food does this ring use up?
! 26: */
! 27: int
! 28: ring_eat(int hand)
! 29: {
! 30: if (cur_ring[hand] == NULL)
! 31: return 0;
! 32: switch (cur_ring[hand]->o_which) {
! 33: case R_VAMPREGEN:
! 34: return 3;
! 35: case R_REGEN:
! 36: return 2;
! 37: case R_HEALTH:
! 38: case R_SUSABILITY:
! 39: return 1;
! 40: case R_SEARCH:
! 41: case R_SEEINVIS:
! 42: return (rnd(100) < 33);
! 43: case R_DIGEST:
! 44: if (cur_ring[hand]->o_ac >= 0)
! 45: return (-(cur_ring[hand]->o_ac)-1);
! 46: else
! 47: return (-(cur_ring[hand]->o_ac));
! 48: }
! 49: return 0;
! 50: }
! 51:
! 52: void
! 53: ring_on(struct linked_list *item)
! 54: {
! 55: register struct object *obj;
! 56: register int save_max;
! 57:
! 58: obj = OBJPTR(item);
! 59:
! 60: /*
! 61: * Calculate the effect it has on the poor guy.
! 62: */
! 63: switch (obj->o_which)
! 64: {
! 65: case R_ADDSTR:
! 66: save_max = max_stats.s_str;
! 67: chg_str(obj->o_ac);
! 68: max_stats.s_str = save_max;
! 69: when R_ADDHIT:
! 70: pstats.s_dext += obj->o_ac;
! 71: when R_ADDINTEL:
! 72: pstats.s_intel += obj->o_ac;
! 73: when R_ADDWISDOM:
! 74: pstats.s_wisdom += obj->o_ac;
! 75: when R_SEEINVIS:
! 76: turn_on(player, CANSEE);
! 77: msg("Your eyes begin to tingle");
! 78: light(&hero);
! 79: mvwaddch(cw, hero.y, hero.x, PLAYER);
! 80: when R_AGGR:
! 81: aggravate(TRUE, TRUE);
! 82: when R_WARMTH:
! 83: turn_on(player, NOCOLD);
! 84: when R_FIRE:
! 85: turn_on(player, NOFIRE);
! 86: when R_LIGHT: {
! 87: if(roomin(&hero) != NULL) {
! 88: light(&hero);
! 89: mvwaddch(cw, hero.y, hero.x, PLAYER);
! 90: }
! 91: }
! 92: when R_SEARCH:
! 93: start_daemon(ring_search, NULL, AFTER);
! 94: when R_TELEPORT:
! 95: start_daemon(ring_teleport, NULL, AFTER);
! 96: }
! 97: status(FALSE);
! 98: if (r_know[obj->o_which] && r_guess[obj->o_which])
! 99: {
! 100: free(r_guess[obj->o_which]);
! 101: r_guess[obj->o_which] = NULL;
! 102: }
! 103: else if (!r_know[obj->o_which] &&
! 104: askme &&
! 105: (obj->o_flags & ISKNOW) == 0 &&
! 106: r_guess[obj->o_which] == NULL) {
! 107: nameitem(item, FALSE);
! 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_CARRY:
! 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