comparison xrogue/wear.c @ 142:6b5fbd7c3ece

Merge arogue7 and xrogue trees.
author John "Elwin" Edwards
date Tue, 12 May 2015 21:39:39 -0400
parents ce0cf824c192
children cadff8f047a1
comparison
equal deleted inserted replaced
132:66b0263af424 142:6b5fbd7c3ece
1 /*
2 wear.c - functions for dealing with armor
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 <stdlib.h>
20 #include <curses.h>
21 #include "rogue.h"
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 wear leather and studded leather armor.");
118 return;
119 }
120 if (player.t_ctype == C_ASSASSIN &&
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 wear leather and 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 and ogre power give the hero
193 * a dexterity of 21, the gauntlets of fumbling cause the
194 * 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 and acid breath.
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) { /* Not enough fingers */
248 if (terse) msg("Wearing enough rings.");
249 else msg("You are already wearing 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 and ogre power give the hero
318 * a dexterity of 21, the gauntlets of fumbling cause the
319 * 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, (VOID *)NULL, 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); /* affect all charactors */
335 if (player.t_ctype == C_PALADIN ||
336 player.t_ctype == C_RANGER || player.t_ctype == C_MONK)
337 msg("A chill runs down your spine! ");
338
339 /*
340 * the necklace of adaption makes the hero immune to
341 * chlorine gas and acid
342 */
343 when MM_ADAPTION:
344 msg("Wearing %s",inv_name(obj,TRUE));
345 cur_misc[WEAR_NECKLACE] = obj;
346 turn_on(player, NOGAS);
347 turn_on(player, NOACID);
348
349 /*
350 * the necklace of stragulation will try to strangle the
351 * hero to death