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