Source:Hack 1.0/hack.wield.c

Below is the full text to hack.wield.c from the source code of Hack 1.0. To link to a particular line, write [[Hack 1.0/hack.wield.c#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

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