1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.do_wear.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.do_wear.c,v 1.3 1999/11/16 02:57:03 billf Exp $ */
4 /* $DragonFly: src/games/hack/hack.do_wear.c,v 1.3 2004/11/06 12:29:17 eirikn Exp $ */
8 extern char *nomovemsg;
9 extern char quitchars[];
10 extern char *Doname();
12 off_msg(otmp) struct obj *otmp; {
13 pline("You were wearing %s.", doname(otmp));
18 if(!uarm && !uarmh && !uarms && !uarmg) {
19 pline("Not wearing any armor.");
22 otmp = (!uarmh && !uarms && !uarmg) ? uarm :
23 (!uarms && !uarm && !uarmg) ? uarmh :
24 (!uarmh && !uarm && !uarmg) ? uarms :
25 (!uarmh && !uarm && !uarms) ? uarmg :
26 getobj("[", "take off");
28 if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
29 pline("You can't take that off.");
32 if( otmp == uarmg && uwep && uwep->cursed ) { /* myers@uwmacc */
33 pline("You seem not able to take off the gloves while holding your weapon.");
36 (void) armoroff(otmp);
41 if(!uleft && !uright){
42 pline("Not wearing any ring.");
49 if(uleft && uright) while(1) {
52 pline("What ring, Right or Left? [ rl?]");
53 if(index(quitchars, (answer = readchar())))
64 /* might look at morc here %% */
73 dorr(otmp) struct obj *otmp; {
74 if(cursed(otmp)) return(0);
80 cursed(otmp) struct obj *otmp; {
82 pline("You can't. It appears to be cursed.");
88 armoroff(otmp) struct obj *otmp; {
89 int delay = -objects[otmp->otyp].oc_delay;
90 if(cursed(otmp)) return(0);
91 setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
96 nomovemsg = "You finished taking off your helmet.";
99 nomovemsg = "You finished taking off your gloves";
102 nomovemsg = "You finished taking off your suit.";
116 otmp = getobj("[", "wear");
118 if(otmp->owornmask & W_ARMOR) {
119 pline("You are already wearing that!");
122 if(otmp->otyp == HELMET){
124 pline("You are already wearing a helmet.");
128 } else if(otmp->otyp == SHIELD){
129 if(uarms) pline("You are already wearing a shield."), err++;
130 if(uwep && uwep->otyp == TWO_HANDED_SWORD)
131 pline("You cannot wear a shield and wield a two-handed sword."), err++;
132 if(!err) mask = W_ARMS;
133 } else if(otmp->otyp == PAIR_OF_GLOVES) {
135 pline("You are already wearing gloves.");
138 if(uwep && uwep->cursed) {
139 pline("You cannot wear gloves over your weapon.");
145 if(otmp->otyp != ELVEN_CLOAK || uarm2) {
146 pline("You are already wearing some armor.");
150 if(!err) mask = W_ARM;
152 if(otmp == uwep && uwep->cursed) {
154 pline("%s is welded to your hand.", Doname(uwep));
159 setuwep((struct obj *) 0);
160 delay = -objects[otmp->otyp].oc_delay;
163 nomovemsg = "You finished your dressing manoeuvre.";
175 pline("There are no more ring-fingers to fill.");
178 otmp = getobj("=", "wear");
180 if(otmp->owornmask & W_RING) {
181 pline("You are already wearing that!");
184 if(otmp == uleft || otmp == uright) {
185 pline("You are already wearing that.");
188 if(otmp == uwep && uwep->cursed) {
189 pline("%s is welded to your hand.", Doname(uwep));
192 if(uleft) mask = RIGHT_RING;
193 else if(uright) mask = LEFT_RING;
197 pline("What ring-finger, Right or Left? ");
198 if(index(quitchars, (answer = readchar())))
213 setuwep((struct obj *) 0);
214 oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
215 u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
218 if(!oldprop) float_up();
220 case RIN_PROTECTION_FROM_SHAPE_CHANGERS:
223 case RIN_GAIN_STRENGTH:
225 u.ustrmax += otmp->spe;
226 if(u.ustr > 118) u.ustr = 118;
227 if(u.ustrmax > 118) u.ustrmax = 118;
230 case RIN_INCREASE_DAMAGE:
231 u.udaminc += otmp->spe;
242 mask = obj->owornmask & W_RING;
243 setworn((struct obj *) 0, obj->owornmask);
244 if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
245 impossible("Strange... I didnt know you had that ring.");
246 u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
248 case RIN_FIRE_RESISTANCE:
249 /* Bad luck if the player is in hell... --jgm */
250 if (!Fire_resistance && dlevel >= 30) {
251 pline("The flames of Hell burn you to a crisp.");
252 killer = "stupidity in hell";
257 if(!Levitation) { /* no longer floating */
261 case RIN_GAIN_STRENGTH:
263 u.ustrmax -= obj->spe;
264 if(u.ustr > 118) u.ustr = 118;
265 if(u.ustrmax > 118) u.ustrmax = 118;
268 case RIN_INCREASE_DAMAGE:
269 u.udaminc -= obj->spe;
276 if(uarm) uac -= ARM_BONUS(uarm);
277 if(uarm2) uac -= ARM_BONUS(uarm2);
278 if(uarmh) uac -= ARM_BONUS(uarmh);
279 if(uarms) uac -= ARM_BONUS(uarms);
280 if(uarmg) uac -= ARM_BONUS(uarmg);
281 if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
282 if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
292 if(!uarmg) if(uleft || uright) {
293 /* Note: at present also cursed rings fall off */
294 pline("Your %s off your fingers.",
295 (uleft && uright) ? "rings slip" : "ring slips");
297 if((otmp = uleft) != Null(obj)){
301 if((otmp = uright) != Null(obj)){
306 if((otmp = uwep) != Null(obj)){
307 /* Note: at present also cursed weapons fall */
308 setuwep((struct obj *) 0);
310 pline("Your weapon %sslips from your hands.",
317 struct obj *otmph = uarm;
318 if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
319 if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
320 if(uarms && (!otmph || !rn2(4))) otmph = uarms;
325 struct obj *otmph = some_armor();
327 if(otmph->rustfree ||
328 otmph->otyp == ELVEN_CLOAK ||
329 otmph->otyp == LEATHER_ARMOR ||
330 otmph->otyp == STUDDED_LEATHER_ARMOR) {
331 pline("Your %s not affected!",
332 aobjnam(otmph, "are"));
335 pline("Your %s!", aobjnam(otmph, "corrode"));