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