comparison xrogue/rings.c @ 133:e6179860cb76

Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
author John "Elwin" Edwards
date Tue, 21 Apr 2015 08:55:20 -0400
parents
children ce0cf824c192
comparison
equal deleted inserted replaced
124:d10fc4a065ac 133:e6179860cb76
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 <curses.h>
20 #include "rogue.h"
21
22 /*
23 * routines dealing specifically with rings
24 */
25
26 /*
27 * how much food does this ring use up?
28 */
29
30 ring_eat(hand)
31 register int hand;
32 {
33 if (cur_ring[hand] == NULL)
34 return 0;
35 switch (cur_ring[hand]->o_which) {
36 case R_VAMPREGEN:
37 return 3;
38 case R_REGEN:
39 case R_SUSABILITY:
40 return 2;
41 case R_HEALTH:
42 return 1;
43 case R_SEARCH:
44 case R_SEEINVIS:
45 return (rnd(100) < 50); /* 0 or 1 */
46 case R_DIGEST:
47 if (cur_ring[hand]->o_ac >= 0)
48 return (-(cur_ring[hand]->o_ac)-1);
49 else
50 return (-(cur_ring[hand]->o_ac));
51 }
52 return 0;
53 }
54
55 ring_on(item)
56 register struct linked_list *item;
57 {
58 register struct object *obj;
59 register int save_max;
60
61 obj = OBJPTR(item);
62
63 /*
64 * Calculate the effect it has on the poor guy.
65 */
66 switch (obj->o_which)
67 {
68 case R_ADDSTR:
69 save_max = max_stats.s_str;
70 chg_str(obj->o_ac);
71 max_stats.s_str = save_max;
72 when R_ADDHIT:
73 pstats.s_dext += obj->o_ac;
74 when R_ADDINTEL:
75 pstats.s_intel += obj->o_ac;
76 when R_ADDWISDOM:
77 pstats.s_wisdom += obj->o_ac;
78 when R_SEEINVIS:
79 if (on(player, CANSEE)) msg("Your eyes sparkle.");
80 else msg("Your eyes begin to tingle.");
81 turn_on(player, CANSEE);
82 light(&hero);
83 mvwaddch(cw, hero.y, hero.x, PLAYER);
84 when R_AGGR:
85 aggravate(TRUE, TRUE); /* all charactors are affected*/
86 when R_WARMTH:
87 if (on(player, NOCOLD)) msg("You feel warm all over.");
88 else msg("You begin to feel warm.");
89 turn_on(player, NOCOLD);
90 when R_FIRE:
91 if (on(player, NOFIRE)) msg("You feel quite fire proof now.");
92 else msg("You begin to feel fire proof.");
93 turn_on(player, NOFIRE);
94 when R_LIGHT: {
95 if(roomin(&hero) != NULL) {
96 light(&hero);
97 mvwaddch(cw, hero.y, hero.x, PLAYER);
98 }
99 }
100 when R_SEARCH:
101 daemon(ring_search, (VOID *)NULL, AFTER);
102 when R_TELEPORT:
103 daemon(ring_teleport, (VOID *)NULL, AFTER);
104 }
105 status(FALSE);
106 if (r_know[obj->o_which] && r_guess[obj->o_which]) {
107 free(r_guess[obj->o_which]);
108 r_guess[obj->o_which] = NULL;
109 }
110 else if (!r_know[obj->o_which] &&
111 askme &&
112 (obj->o_flags & ISKNOW) == 0 &&
113 r_guess[obj->o_which] == NULL) {
114 nameitem(item, FALSE);
115 }
116 }
117
118 /*
119 * print ring bonuses
120 */
121
122 char *
123 ring_num(obj)
124 register struct object *obj;
125 {
126 static char buf[5];
127
128 if (!(obj->o_flags & ISKNOW))
129 return "";
130 switch (obj->o_which)
131 {
132 case R_PROTECT:
133 case R_ADDSTR:
134 case R_ADDDAM:
135 case R_ADDHIT:
136 case R_ADDINTEL:
137 case R_ADDWISDOM:
138 case R_DIGEST:
139 buf[0] = ' ';
140 strcpy(&buf[1], num(obj->o_ac, 0));
141 when R_AGGR:
142 case R_LIGHT:
143 case R_CARRY:
144 case R_TELEPORT:
145 if (obj->o_flags & ISCURSED)
146 return " cursed";
147 else
148 return "";
149 otherwise:
150 return "";
151 }
152 return buf;
153 }
154
155 /*
156 * Return the effect of the specified ring
157 */
158
159 ring_value(type)
160 {
161 int result = 0;
162
163 if (ISRING(LEFT_1, type)) result += cur_ring[LEFT_1]->o_ac;
164 if (ISRING(LEFT_2, type)) result += cur_ring[LEFT_2]->o_ac;
165 if (ISRING(LEFT_3, type)) result += cur_ring[LEFT_3]->o_ac;
166 if (ISRING(LEFT_4, type)) result += cur_ring[LEFT_4]->o_ac;
167 if (ISRING(RIGHT_1, type)) result += cur_ring[RIGHT_1]->o_ac;
168 if (ISRING(RIGHT_2, type)) result += cur_ring[RIGHT_2]->o_ac;
169 if (ISRING(RIGHT_3, type)) result += cur_ring[RIGHT_3]->o_ac;
170 if (ISRING(RIGHT_4, type)) result += cur_ring[RIGHT_4]->o_ac;
171 return(result);
172 }
173