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