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