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