xref: /dragonfly/games/hack/hack.wield.c (revision 2cd2d2b5)
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.wield.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.wield.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.wield.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */
5 
6 #include	"hack.h"
7 extern struct obj zeroobj;
8 
9 setuwep(obj) struct obj *obj; {
10 	setworn(obj, W_WEP);
11 }
12 
13 dowield()
14 {
15 	struct obj *wep;
16 	int res = 0;
17 
18 	multi = 0;
19 	if(!(wep = getobj("#-)", "wield"))) /* nothing */;
20 	else if(uwep == wep)
21 		pline("You are already wielding that!");
22 	else if(uwep && uwep->cursed)
23 		pline("The %s welded to your hand!",
24 			aobjnam(uwep, "are"));
25 	else if(wep == &zeroobj) {
26 		if(uwep == 0){
27 			pline("You are already empty handed.");
28 		} else {
29 			setuwep((struct obj *) 0);
30 			res++;
31 			pline("You are empty handed.");
32 		}
33 	} else if(uarms && wep->otyp == TWO_HANDED_SWORD)
34 	pline("You cannot wield a two-handed sword and wear a shield.");
35 	else if(wep->owornmask & (W_ARMOR | W_RING))
36 		pline("You cannot wield that!");
37 	else {
38 		setuwep(wep);
39 		res++;
40 		if(uwep->cursed)
41 		    pline("The %s %s to your hand!",
42 			aobjnam(uwep, "weld"),
43 			(uwep->quan == 1) ? "itself" : "themselves"); /* a3 */
44 		else prinv(uwep);
45 	}
46 	return(res);
47 }
48 
49 corrode_weapon(){
50 	if(!uwep || uwep->olet != WEAPON_SYM) return;	/* %% */
51 	if(uwep->rustfree)
52 		pline("Your %s not affected.", aobjnam(uwep, "are"));
53 	else {
54 		pline("Your %s!", aobjnam(uwep, "corrode"));
55 		uwep->spe--;
56 	}
57 }
58 
59 chwepon(otmp,amount)
60 struct obj *otmp;
61 int amount;
62 {
63 char *color = (amount < 0) ? "black" : "green";
64 char *time;
65 	if(!uwep || uwep->olet != WEAPON_SYM) {
66 		strange_feeling(otmp,
67 			(amount > 0) ? "Your hands twitch."
68 				     : "Your hands itch.");
69 		return(0);
70 	}
71 
72 	if(uwep->otyp == WORM_TOOTH && amount > 0) {
73 		uwep->otyp = CRYSKNIFE;
74 		pline("Your weapon seems sharper now.");
75 		uwep->cursed = 0;
76 		return(1);
77 	}
78 
79 	if(uwep->otyp == CRYSKNIFE && amount < 0) {
80 		uwep->otyp = WORM_TOOTH;
81 		pline("Your weapon looks duller now.");
82 		return(1);
83 	}
84 
85 	/* there is a (soft) upper limit to uwep->spe */
86 	if(amount > 0 && uwep->spe > 5 && rn2(3)) {
87 	    pline("Your %s violently green for a while and then evaporate%s.",
88 		aobjnam(uwep, "glow"), plur(uwep->quan));
89 	    while(uwep)		/* let all of them disappear */
90 				/* note: uwep->quan = 1 is nogood if unpaid */
91 	        useup(uwep);
92 	    return(1);
93 	}
94 	if(!rn2(6)) amount *= 2;
95 	time = (amount*amount == 1) ? "moment" : "while";
96 	pline("Your %s %s for a %s.",
97 		aobjnam(uwep, "glow"), color, time);
98 	uwep->spe += amount;
99 	if(amount > 0) uwep->cursed = 0;
100 	return(1);
101 }
102