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