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