]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.wield.c
Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
[bsdgames-darwin.git] / hack / hack.wield.c
1 /* $NetBSD: hack.wield.c,v 1.5 2001/03/25 20:44:03 jsm Exp $ */
2
3 /*
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
5 */
6
7 #include <sys/cdefs.h>
8 #ifndef lint
9 __RCSID("$NetBSD: hack.wield.c,v 1.5 2001/03/25 20:44:03 jsm Exp $");
10 #endif /* not lint */
11
12 #include "hack.h"
13 #include "extern.h"
14
15 void
16 setuwep(obj)
17 struct obj *obj;
18 {
19 setworn(obj, W_WEP);
20 }
21
22 int
23 dowield()
24 {
25 struct obj *wep;
26 int res = 0;
27
28 multi = 0;
29 if (!(wep = getobj("#-)", "wield"))) /* nothing */
30 ;
31 else if (uwep == wep)
32 pline("You are already wielding that!");
33 else if (uwep && uwep->cursed)
34 pline("The %s welded to your hand!",
35 aobjnam(uwep, "are"));
36 else if (wep == &zeroobj) {
37 if (uwep == 0) {
38 pline("You are already empty handed.");
39 } else {
40 setuwep((struct obj *) 0);
41 res++;
42 pline("You are empty handed.");
43 }
44 } else if (uarms && wep->otyp == TWO_HANDED_SWORD)
45 pline("You cannot wield a two-handed sword and wear a shield.");
46 else if (wep->owornmask & (W_ARMOR | W_RING))
47 pline("You cannot wield that!");
48 else {
49 setuwep(wep);
50 res++;
51 if (uwep->cursed)
52 pline("The %s %s to your hand!",
53 aobjnam(uwep, "weld"),
54 (uwep->quan == 1) ? "itself" : "themselves"); /* a3 */
55 else
56 prinv(uwep);
57 }
58 return (res);
59 }
60
61 void
62 corrode_weapon()
63 {
64 if (!uwep || uwep->olet != WEAPON_SYM)
65 return; /* %% */
66 if (uwep->rustfree)
67 pline("Your %s not affected.", aobjnam(uwep, "are"));
68 else {
69 pline("Your %s!", aobjnam(uwep, "corrode"));
70 uwep->spe--;
71 }
72 }
73
74 int
75 chwepon(otmp, amount)
76 struct obj *otmp;
77 int amount;
78 {
79 const char *color = (amount < 0) ? "black" : "green";
80 const char *time;
81 if (!uwep || uwep->olet != WEAPON_SYM) {
82 strange_feeling(otmp,
83 (amount > 0) ? "Your hands twitch."
84 : "Your hands itch.");
85 return (0);
86 }
87 if (uwep->otyp == WORM_TOOTH && amount > 0) {
88 uwep->otyp = CRYSKNIFE;
89 pline("Your weapon seems sharper now.");
90 uwep->cursed = 0;
91 return (1);
92 }
93 if (uwep->otyp == CRYSKNIFE && amount < 0) {
94 uwep->otyp = WORM_TOOTH;
95 pline("Your weapon looks duller now.");
96 return (1);
97 }
98 /* there is a (soft) upper limit to uwep->spe */
99 if (amount > 0 && uwep->spe > 5 && rn2(3)) {
100 pline("Your %s violently green for a while and then evaporate%s.",
101 aobjnam(uwep, "glow"), plur(uwep->quan));
102 while (uwep) /* let all of them disappear */
103 /* note: uwep->quan = 1 is nogood if unpaid */
104 useup(uwep);
105 return (1);
106 }
107 if (!rn2(6))
108 amount *= 2;
109 time = (amount * amount == 1) ? "moment" : "while";
110 pline("Your %s %s for a %s.",
111 aobjnam(uwep, "glow"), color, time);
112 uwep->spe += amount;
113 if (amount > 0)
114 uwep->cursed = 0;
115 return (1);
116 }