Mercurial > hg > early-roguelike
comparison arogue7/wear.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 * wear.c - functions for dealing with armor | |
3 * | |
4 * Advanced Rogue | |
5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T | |
6 * All rights reserved. | |
7 * | |
8 * Based on "Rogue: Exploring the Dungeons of Doom" | |
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
10 * All rights reserved. | |
11 * | |
12 * See the file LICENSE.TXT for full copyright and licensing information. | |
13 */ | |
14 | |
15 /* | |
16 * This file contains misc functions for dealing with armor | |
17 */ | |
18 | |
19 #include "curses.h" | |
20 #include "rogue.h" | |
21 | |
22 | |
23 /* | |
24 * take_off: | |
25 * Get the armor off of the players back | |
26 */ | |
27 | |
28 take_off() | |
29 { | |
30 register struct object *obj; | |
31 register struct linked_list *item; | |
32 | |
33 /* It takes time to take things off */ | |
34 if (player.t_action != C_TAKEOFF) { | |
35 /* What does player want to take off? */ | |
36 if ((item = get_item(pack, "take off", REMOVABLE, FALSE, FALSE))==NULL) | |
37 return; | |
38 | |
39 obj = OBJPTR(item); | |
40 if (!is_current(obj)) { | |
41 msg("Not wearing %c) %s", pack_char(pack, obj),inv_name(obj, TRUE)); | |
42 return; | |
43 } | |
44 | |
45 player.t_using = item; /* Remember what it is */ | |
46 player.t_action = C_TAKEOFF; /* We are taking something off */ | |
47 | |
48 /* Cursed items take almost no time */ | |
49 if (obj->o_flags & ISCURSED) player.t_no_move = movement(&player); | |
50 else player.t_no_move = dress_units(item) * movement(&player); | |
51 return; | |
52 } | |
53 | |
54 /* We have waited our time, let's take off our item */ | |
55 item = player.t_using; | |
56 player.t_using = NULL; | |
57 player.t_action = A_NIL; | |
58 | |
59 obj = OBJPTR(item); | |
60 if (!is_current(obj)) { /* Just to be on the safe side */ | |
61 msg("Not wearing %c) %s", pack_char(pack, obj),inv_name(obj, TRUE)); | |
62 return; | |
63 } | |
64 | |
65 /* Can the player remove the item? */ | |
66 if (!dropcheck(obj)) return; | |
67 updpack(TRUE, &player); | |
68 | |
69 msg("Was wearing %c) %s", pack_char(pack, obj),inv_name(obj,TRUE)); | |
70 } | |
71 | |
72 /* | |
73 * wear: | |
74 * The player wants to wear something, so let him/her put it on. | |
75 */ | |
76 | |
77 wear() | |
78 { | |
79 register struct linked_list *item; | |
80 register struct object *obj; | |
81 register int i; | |
82 | |
83 /* It takes time to put things on */ | |
84 if (player.t_action != C_WEAR) { | |
85 /* What does player want to wear? */ | |
86 if ((item = get_item(pack, "wear", WEARABLE, FALSE, FALSE)) == NULL) | |
87 return; | |
88 | |
89 obj = OBJPTR(item); | |
90 | |
91 switch (obj->o_type) { | |
92 case ARMOR: | |
93 if (cur_armor != NULL) { | |
94 addmsg("You are already wearing armor"); | |
95 if (!terse) addmsg(". You'll have to take it off first."); | |
96 endmsg(); | |
97 after = FALSE; | |
98 return; | |
99 } | |
100 if (player.t_ctype == C_MONK) { | |
101 msg("Monks can't wear armor!"); | |
102 return; | |
103 } | |
104 if (cur_misc[WEAR_BRACERS] != NULL) { | |
105 msg("You can't wear armor with bracers of defense."); | |
106 return; | |
107 } | |
108 if (cur_misc[WEAR_CLOAK] != NULL || cur_relic[EMORI_CLOAK]) { | |
109 msg("You can't wear armor with a cloak."); | |
110 return; | |
111 } | |
112 if (player.t_ctype == C_THIEF && | |
113 (obj->o_which != LEATHER && | |
114 obj->o_which != STUDDED_LEATHER)) { | |
115 if (terse) msg("Thieves can't wear that type of armor"); | |
116 else | |
117 msg("Thieves can only wear leather or studded leather armor"); | |
118 return; | |
119 } | |
120 if (player.t_ctype == C_ASSASIN && | |
121 (obj->o_which != LEATHER && | |
122 obj->o_which != STUDDED_LEATHER)) { | |
123 if (terse) msg("Assassins can't wear that type of armor"); | |
124 else | |
125 msg("Assassins can only wear leather or studded leather armor"); | |
126 return; | |
127 } | |
128 | |
129 when MM: | |
130 switch (obj->o_which) { | |
131 /* | |
132 * when wearing the boots of elvenkind the player will not | |
133 * set off any traps | |
134 */ | |
135 case MM_ELF_BOOTS: | |
136 if (cur_misc[WEAR_BOOTS] != NULL) { | |
137 msg("Already wearing a pair of boots"); | |
138 return; | |
139 } | |
140 /* | |
141 * when wearing the boots of dancing the player will dance | |
142 * uncontrollably | |
143 */ | |
144 when MM_DANCE: | |
145 if (cur_misc[WEAR_BOOTS] != NULL) { | |
146 msg("Already wearing a pair of boots"); | |
147 return; | |
148 } | |
149 /* | |
150 * bracers give the hero protection in he same way armor does. | |
151 * they cannot be used with armor but can be used with cloaks | |
152 */ | |
153 when MM_BRACERS: | |
154 if (cur_misc[WEAR_BRACERS] != NULL) { | |
155 msg("Already wearing bracers"); | |
156 return; | |
157 } | |
158 else { | |
159 if (cur_armor != NULL) { | |
160 msg("You can't wear bracers of defense with armor."); | |
161 return; | |
162 } | |
163 } | |
164 | |
165 /* | |
166 * The robe (cloak) of powerlessness disallows any spell casting | |
167 */ | |
168 when MM_R_POWERLESS: | |
169 /* | |
170 * the cloak of displacement gives the hero an extra +2 on AC | |
171 * and saving throws. Cloaks cannot be used with armor. | |
172 */ | |
173 case MM_DISP: | |
174 /* | |
175 * the cloak of protection gives the hero +n on AC and saving | |
176 * throws with a max of +3 on saves | |
177 */ | |
178 case MM_PROTECT: | |
179 if (cur_misc[WEAR_CLOAK] != NULL || | |
180 cur_relic[EMORI_CLOAK]) { | |
181 msg("%slready wearing a cloak.", terse ? "A" | |
182 : "You are a"); | |
183 return; | |
184 } | |
185 else { | |
186 if (cur_armor != NULL) { | |
187 msg("You can't wear a cloak with armor."); | |
188 return; | |
189 } | |
190 } | |
191 /* | |
192 * the gauntlets of dexterity give the hero a dexterity of 18 | |
193 * the gauntlets of ogre power give the hero a strength of 18 | |
194 * the gauntlets of fumbling cause the hero to drop his weapon | |
195 */ | |
196 when MM_G_DEXTERITY: | |
197 case MM_G_OGRE: | |
198 case MM_FUMBLE: | |
199 if (cur_misc[WEAR_GAUNTLET] != NULL) { | |
200 msg("Already wearing a pair of gauntlets."); | |
201 return; | |
202 } | |
203 /* | |
204 * the jewel of attacks does an aggavate monster | |
205 */ | |
206 when MM_JEWEL: | |
207 if (cur_misc[WEAR_JEWEL] != NULL || | |
208 cur_relic[YENDOR_AMULET] || | |
209 cur_relic[STONEBONES_AMULET]) { | |
210 msg("Already wearing an amulet."); | |
211 return; | |
212 } | |
213 /* | |
214 * the necklace of adaption makes the hero immune to | |
215 * chlorine gas | |
216 */ | |
217 when MM_ADAPTION: | |
218 if (cur_misc[WEAR_NECKLACE] != NULL) { | |
219 msg("Already wearing a necklace"); | |
220 return; | |
221 } | |
222 /* | |
223 * the necklace of stragulation will try to strangle the | |
224 * hero to death | |
225 */ | |
226 when MM_STRANGLE: | |
227 if (cur_misc[WEAR_NECKLACE] != NULL) { | |
228 msg("Already wearing a necklace"); | |
229 return; | |
230 } | |
231 otherwise: | |
232 msg("what a strange item you have!"); | |
233 return; | |
234 } | |
235 | |
236 when RING: | |
237 if (cur_misc[WEAR_GAUNTLET] != NULL) { | |
238 msg ("You have to remove your gauntlets first!"); | |
239 return; | |
240 } | |
241 | |
242 /* Is there room to put the ring on */ | |
243 for (i=0; i<NUM_FINGERS; i++) | |
244 if (cur_ring[i] == NULL) { | |
245 break; | |
246 } | |
247 if (i == NUM_FINGERS) { /* No room */ | |
248 if (terse) msg("Wearing enough rings"); | |
249 else msg("You already have on eight rings"); | |
250 return; | |
251 } | |
252 } | |
253 | |
254 player.t_using = item; /* Remember what it is */ | |
255 player.t_action = C_WEAR; /* We are taking something off */ | |
256 player.t_no_move = dress_units(item) * movement(&player); | |
257 return; | |
258 } | |
259 | |
260 /* We have waited our time, let's put on our item */ | |
261 item = player.t_using; | |
262 player.t_using = NULL; | |
263 player.t_action = A_NIL; | |
264 | |
265 obj = OBJPTR(item); | |
266 | |
267 switch (obj->o_type) { | |
268 case ARMOR: | |
269 obj->o_flags |= ISKNOW; | |
270 cur_armor = obj; | |
271 addmsg(terse ? "W" : "You are now w"); | |
272 msg("earing %s.", armors[obj->o_which].a_name); | |
273 | |
274 when MM: | |
275 switch (obj->o_which) { | |
276 /* | |
277 * when wearing the boots of elvenkind the player will not | |
278 * set off any traps | |
279 */ | |
280 case MM_ELF_BOOTS: | |
281 msg("Wearing %s",inv_name(obj,TRUE)); | |
282 cur_misc[WEAR_BOOTS] = obj; | |
283 /* | |
284 * when wearing the boots of dancing the player will dance | |
285 * uncontrollably | |
286 */ | |
287 when MM_DANCE: | |
288 msg("Wearing %s",inv_name(obj,TRUE)); | |
289 cur_misc[WEAR_BOOTS] = obj; | |
290 msg("You begin to dance uncontrollably!"); | |
291 turn_on(player, ISDANCE); | |
292 /* | |
293 * bracers give the hero protection in he same way armor does. | |
294 * they cannot be used with armor but can be used with cloaks | |
295 */ | |
296 when MM_BRACERS: | |
297 msg("wearing %s",inv_name(obj,TRUE)); | |
298 cur_misc[WEAR_BRACERS] = obj; | |
299 | |
300 /* | |
301 * The robe (cloak) of powerlessness disallows any spell casting | |
302 */ | |
303 when MM_R_POWERLESS: | |
304 /* | |
305 * the cloak of displacement gives the hero an extra +2 on AC | |
306 * and saving throws. Cloaks cannot be used with armor. | |
307 */ | |
308 case MM_DISP: | |
309 /* | |
310 * the cloak of protection gives the hero +n on AC and saving | |
311 * throws with a max of +3 on saves | |
312 */ | |
313 case MM_PROTECT: | |
314 msg("wearing %s",inv_name(obj,TRUE)); | |
315 cur_misc[WEAR_CLOAK] = obj; | |
316 /* | |
317 * the gauntlets of dexterity give the hero a dexterity of 18 | |
318 * the gauntlets of ogre power give the hero a strength of 18 | |
319 * the gauntlets of fumbling cause the hero to drop his weapon | |
320 */ | |
321 when MM_G_DEXTERITY: | |
322 case MM_G_OGRE: | |
323 case MM_FUMBLE: | |
324 msg("Wearing %s", inv_name(obj,TRUE)); | |
325 cur_misc[WEAR_GAUNTLET] = obj; | |
326 if (obj->o_which == MM_FUMBLE) | |
327 daemon(fumble, 0, AFTER); | |
328 /* | |
329 * the jewel of attacks does an aggavate monster | |
330 */ | |
331 when MM_JEWEL: | |
332 msg("Wearing %s",inv_name(obj,TRUE)); | |
333 cur_misc[WEAR_JEWEL] = obj; | |
334 aggravate(TRUE, TRUE); | |
335 /* | |
336 * the necklace of adaption makes the hero immune to | |
337 * chlorine gas | |
338 */ | |
339 when MM_ADAPTION: | |
340 msg("Wearing %s",inv_name(obj,TRUE)); | |
341 cur_misc[WEAR_NECKLACE] = obj; | |
342 turn_on(player, NOGAS); | |
343 /* | |
344 * the necklace of stragulation will try to strangle the | |
345 * hero to death | |
346 */ | |
347 when MM_STRANGLE: | |
348 msg("Wearing %s",inv_name(obj,TRUE)); | |
349 cur_misc[WEAR_NECKLACE] = obj; | |
350 msg("The necklace is beginning to strangle you!"); | |
351 daemon(strangle, 0, AFTER); | |
352 otherwise: | |
353 msg("What a strange item you have!"); | |
354 } | |
355 status(FALSE); | |
356 if (m_know[obj->o_which] && m_guess[obj->o_which]) { | |
357 free(m_guess[obj->o_which]); | |
358 m_guess[obj->o_which] = NULL; | |
359 } | |
360 else if (!m_know[obj->o_which] && | |
361 askme && | |
362 (obj->o_flags & ISKNOW) == 0 && | |
363 m_guess[obj->o_which] == NULL) { | |
364 nameitem(item, FALSE); | |
365 } | |
366 | |
367 when RING: | |
368 /* If there is room, put on the ring */ | |
369 for (i=0; i<NUM_FINGERS; i++) | |
370 if (cur_ring[i] == NULL) { | |
371 cur_ring[i] = obj; | |