Mercurial > hg > early-roguelike
comparison urogue/artifact.c @ 256:c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
author | John "Elwin" Edwards |
---|---|
date | Tue, 31 Jan 2017 19:56:04 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
253:d9badb9c0179 | 256:c495a4f288c6 |
---|---|
1 /* | |
2 artifact.c - functions for dealing with artifacts | |
3 | |
4 UltraRogue: The Ultimate Adventure in the Dungeons of Doom | |
5 Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong | |
6 All rights reserved. | |
7 | |
8 See the file LICENSE.TXT for full copyright and licensing information. | |
9 */ | |
10 | |
11 #include <stdlib.h> | |
12 #include <ctype.h> | |
13 #include "rogue.h" | |
14 | |
15 /* | |
16 apply() | |
17 apply an artifact | |
18 */ | |
19 | |
20 void | |
21 apply(void) | |
22 { | |
23 struct linked_list *item; | |
24 struct object *obj; | |
25 int which; | |
26 int chance; | |
27 | |
28 if ((item = get_item("activate", ARTIFACT)) == NULL) | |
29 return; | |
30 | |
31 obj = OBJPTR(item); | |
32 which = obj->o_which; | |
33 | |
34 if (!(obj->ar_flags & ISACTIVE)) | |
35 { | |
36 chance = rnd(100) - 10 * rnd(luck); | |
37 debug("Rolled %d.", chance); | |
38 if (chance < 5) | |
39 do_major(); | |
40 else if (chance < 50) | |
41 do_minor(obj); | |
42 else | |
43 obj->ar_flags |= ISACTIVE; | |
44 } | |
45 | |
46 if (obj->ar_flags & ISACTIVE) | |
47 { | |
48 switch (which) | |
49 { | |
50 case TR_PURSE: do_bag(obj); | |
51 break; | |
52 case TR_PHIAL: do_phial(); | |
53 break; | |
54 case TR_AMULET: do_amulet(); | |
55 break; | |
56 case TR_PALANTIR: do_palantir(); | |
57 break; | |
58 case TR_CROWN: do_crown(); | |
59 break; | |
60 case TR_SCEPTRE: do_sceptre(); | |
61 break; | |
62 case TR_SILMARIL: do_silmaril(); | |
63 break; | |
64 case TR_WAND: do_wand(); | |
65 break; | |
66 default: nothing_message(ISCURSED); | |
67 return; | |
68 } | |
69 } | |
70 | |
71 if (rnd(pstats.s_lvl) < 6) | |
72 do_minor(obj); | |
73 | |
74 turn_on(player, POWEREAT); | |
75 } | |
76 | |
77 /* | |
78 possessed(int artifact) | |
79 was the hero carrying a particular artifact | |
80 */ | |
81 | |
82 int | |
83 possessed(int artifact) | |
84 { | |
85 return (picked_artifact >> artifact) & 1; | |
86 } | |
87 | |
88 /* | |
89 is_carrying(int artifact) | |
90 is the hero carrying a particular artifact | |
91 */ | |
92 | |
93 int | |
94 is_carrying(int artifact) | |
95 { | |
96 return (has_artifact >> artifact) & 1; | |
97 } | |
98 | |
99 /* | |
100 make_artifact() | |
101 is it time to make a new artifact? | |
102 */ | |
103 | |
104 int | |
105 make_artifact(void) | |
106 { | |
107 int i; | |
108 | |
109 mpos = 0; | |
110 | |
111 debug("Artifact possession and picked flags : %x %x.", | |
112 has_artifact, picked_artifact); | |
113 | |
114 for(i = 0; i < maxartifact; i++) | |
115 { | |
116 if (!is_carrying(i) && arts[i].ar_level <= level) | |
117 return TRUE; | |
118 } | |
119 | |
120 return FALSE; | |
121 } | |
122 | |
123 /* | |
124 new_artifact(int which, struct object *cur) | |
125 make a specified artifact | |
126 */ | |
127 | |
128 struct object * | |
129 new_artifact(int which, struct object *cur) | |
130 { | |
131 if (which >= maxartifact) | |
132 { | |
133 debug("Bad artifact %d. Random one created.", which); | |
134 which = rnd(maxartifact); | |
135 } | |
136 | |
137 if (which < 0) | |
138 { | |
139 for (which = 0; which < maxartifact; which++) | |
140 if (!is_carrying(which) && arts[which].ar_level <= level) | |
141 break; | |
142 } | |
143 | |
144 debug("Artifact number: %d.", which); | |
145 | |
146 cur->o_hplus = cur->o_dplus = 0; | |
147 cur->o_damage = cur->o_hurldmg = "0d0"; | |
148 cur->o_ac = 11; | |
149 cur->o_mark[0] = '\0'; | |
150 cur->o_type = ARTIFACT; | |
151 cur->o_which = which; | |
152 cur->o_weight = arts[which].ar_weight; | |
153 cur->o_flags = 0; | |
154 cur->o_group = 0; | |
155 cur->o_count = 1; | |
156 cur->o_bag = NULL; | |
157 cur->ar_flags = 0; | |
158 | |
159 return(cur); | |
160 } | |
161 | |
162 /* | |
163 do_minor(struct object *tr) | |
164 side effects and minor malevolent effects of artifacts | |
165 */ | |
166 | |
167 void | |
168 do_minor(struct object *tr) | |
169 { | |
170 int which; | |
171 long loss; | |
172 | |
173 which = rnd(110); | |
174 | |
175 debug("Rolled %d.", which); | |
176 | |
177 switch (which) | |
178 { | |
179 case 0: | |
180 seemsg("You develop some acne on your face."); | |
181 break; | |
182 | |
183 case 1: | |
184 if (on(player, CANSCENT)) | |
185 { | |
186 msg("A sudden whiff of BO causes you to faint."); | |
187 no_command = STONETIME; | |
188 } | |
189 else if (off(player, ISUNSMELL)) | |
190 msg("You begin to smell funny."); | |
191 break; | |
192 | |
193 case 2: | |
194 seemsg("A wart grows on the end of your nose."); | |
195 break; | |
196 | |
197 case 3: | |
198 hearmsg("Your hear strange noises in the distance."); | |
199 break; | |
200 | |
201 case 4: | |
202 hearmsg("You hear shuffling in the distance."); | |
203 break; | |
204 | |
205 case 5: | |
206 hearmsg("You hear clanking in the distance."); | |
207 break; | |
208 | |
209 case 6: | |
210 hearmsg("You hear water dripping onto the floor."); | |
211 break; | |
212 | |
213 case 7: | |
214 hearmsg("The dungeon goes strangely silent."); | |
215 break; | |
216 | |
217 case 8: | |
218 msg("You suddenly feel very warm."); | |
219 break; | |
220 | |
221 case 9: | |
222 msg("You feel very hot."); | |
223 break; | |
224 | |
225 case 10: | |
226 msg("A blast of heat hits you."); | |
227 break; | |
228 | |
229 case 11: | |
230 { | |
231 struct room *rp; | |
232 | |
233 if (off(player, ISBLIND)) | |
234 msg("A pillar of flame leaps up beside you."); | |
235 else | |
236 msg("You feel something very hot nearby."); | |
237 | |
238 if (ntraps + 1 < 2 * MAXTRAPS && | |
239 fallpos(hero, &traps[ntraps].tr_pos)) | |
240 { | |
241 mvaddch(traps[ntraps].tr_pos.y, traps[ntraps].tr_pos.x, | |
242 FIRETRAP); | |
243 traps[ntraps].tr_type = FIRETRAP; | |
244 traps[ntraps].tr_flags = ISFOUND; | |
245 traps[ntraps].tr_show = FIRETRAP; | |
246 ntraps++; | |
247 | |
248 if ((rp = roomin(hero)) != NULL) | |
249 { | |
250 rp->r_flags &= ~ISDARK; | |
251 light(&hero); | |
252 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
253 } | |
254 } | |
255 } | |
256 break; | |
257 | |
258 case 12: | |
259 msg("You feel a blast of hot air."); | |
260 break; | |
261 | |
262 case 13: | |
263 msg("You feel very cold."); | |
264 break; | |
265 | |
266 case 14: | |
267 msg("You break out in a cold sweat."); | |
268 break; | |
269 | |
270 case 15: | |
271 if (off(player, ISBLIND) && cur_armor == NULL) | |
272 msg("You are covered with frost."); | |
273 else if (off(player, ISBLIND)) | |
274 msg("Your armor is covered with frost."); | |
275 else if (cur_armor == NULL) | |
276 msg("Your body feels very cold and you begin to shiver."); | |
277 else | |
278 msg("Your armor feels very cold. You hear cracking ice."); | |
279 break; | |
280 | |
281 case 16: | |
282 msg("A cold wind whistles through the dungeon."); | |
283 break; | |
284 | |
285 case 17: | |
286 { | |
287 int change; | |
288 | |
289 change = 18 - pstats.s_str; | |
290 chg_str(change, TRUE, FALSE); | |
291 chg_dext(-change, TRUE, FALSE); | |
292 | |
293 if (change > 0) | |
294 msg("You feel stronger and clumsier now."); | |
295 else if (change < 0) | |
296 msg("You feel weaker and more dextrous now."); | |
297 else | |
298 nothing_message(ISCURSED); | |
299 } | |
300 break; | |
301 | |
302 case 18: | |
303 msg("You begin to itch all over."); | |
304 break; | |
305 | |
306 case 19: | |
307 msg("You begin to feel hot and itchy."); | |
308 break; | |
309 | |
310 case 20: | |
311 msg("You feel a burning itch."); | |
312 chg_dext(-1, FALSE, TRUE); | |
313 | |
314 if (off(player, HASITCH)) | |
315 { | |
316 turn_on(player, HASITCH); | |
317 light_fuse(FUSE_UNITCH, 0, roll(4,6), AFTER); | |
318 } | |
319 else | |
320 lengthen_fuse(FUSE_UNITCH, roll(4,6)); | |
321 break; | |
322 | |
323 case 21: | |
324 if (off(player, ISBLIND)) | |
325 msg("Your skin begins to flake and peel."); | |
326 else | |
327 msg("You feel an urge to scratch an itch."); | |
328 break; | |
329 | |
330 | |
331 case 22: | |
332 seemsg("Your hair begins to turn grey."); | |
333 break; | |
334 | |
335 case 23: | |
336 seemsg("Your hair begins to turn white."); | |
337 break; | |
338 | |
339 case 24: | |
340 seemsg("Some of your hair instantly turns white."); | |
341 break; | |
342 | |
343 case 25: | |
344 seemsg("You are covered with long white hair."); | |
345 break; | |
346 | |
347 case 26: | |
348 seemsg("You are covered with long red hair."); | |
349 break; | |
350 | |
351 case 27: | |
352 msg("You grow a beard."); | |
353 break; | |
354 | |
355 case 28: | |
356 msg("Your hair falls out."); | |
357 break; | |
358 | |
359 case 29: | |
360 msg("You feel a burning down below."); | |
361 break; | |
362 | |
363 case 30: | |
364 msg("Your toes fall off."); | |
365 break; | |
366 | |
367 case 31: | |
368 msg("You grow some extra toes."); | |
369 break; | |
370 | |
371 case 32: | |
372 msg("You grow some extra fingers."); | |
373 break; | |
374 | |
375 case 33: | |
376 msg("You grow an extra thumb."); | |
377 break; | |