Home | History | Annotate | Line # | Download | only in hack
hack.do.c revision 1.1
      1  1.1  cgd /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
      2  1.1  cgd /* hack.do.c - version 1.0.3 */
      3  1.1  cgd 
      4  1.1  cgd /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */
      5  1.1  cgd 
      6  1.1  cgd #include "hack.h"
      7  1.1  cgd 
      8  1.1  cgd extern struct obj *splitobj(), *addinv();
      9  1.1  cgd extern boolean hmon();
     10  1.1  cgd extern boolean level_exists[];
     11  1.1  cgd extern struct monst youmonst;
     12  1.1  cgd extern char *Doname();
     13  1.1  cgd extern char *nomovemsg;
     14  1.1  cgd 
     15  1.1  cgd static int drop();
     16  1.1  cgd 
     17  1.1  cgd dodrop() {
     18  1.1  cgd 	return(drop(getobj("0$#", "drop")));
     19  1.1  cgd }
     20  1.1  cgd 
     21  1.1  cgd static int
     22  1.1  cgd drop(obj) register struct obj *obj; {
     23  1.1  cgd 	if(!obj) return(0);
     24  1.1  cgd 	if(obj->olet == '$') {		/* pseudo object */
     25  1.1  cgd 		register long amount = OGOLD(obj);
     26  1.1  cgd 
     27  1.1  cgd 		if(amount == 0)
     28  1.1  cgd 			pline("You didn't drop any gold pieces.");
     29  1.1  cgd 		else {
     30  1.1  cgd 			mkgold(amount, u.ux, u.uy);
     31  1.1  cgd 			pline("You dropped %ld gold piece%s.",
     32  1.1  cgd 				amount, plur(amount));
     33  1.1  cgd 			if(Invisible) newsym(u.ux, u.uy);
     34  1.1  cgd 		}
     35  1.1  cgd 		free((char *) obj);
     36  1.1  cgd 		return(1);
     37  1.1  cgd 	}
     38  1.1  cgd 	if(obj->owornmask & (W_ARMOR | W_RING)){
     39  1.1  cgd 		pline("You cannot drop something you are wearing.");
     40  1.1  cgd 		return(0);
     41  1.1  cgd 	}
     42  1.1  cgd 	if(obj == uwep) {
     43  1.1  cgd 		if(uwep->cursed) {
     44  1.1  cgd 			pline("Your weapon is welded to your hand!");
     45  1.1  cgd 			return(0);
     46  1.1  cgd 		}
     47  1.1  cgd 		setuwep((struct obj *) 0);
     48  1.1  cgd 	}
     49  1.1  cgd 	pline("You dropped %s.", doname(obj));
     50  1.1  cgd 	dropx(obj);
     51  1.1  cgd 	return(1);
     52  1.1  cgd }
     53  1.1  cgd 
     54  1.1  cgd /* Called in several places - should not produce texts */
     55  1.1  cgd dropx(obj)
     56  1.1  cgd register struct obj *obj;
     57  1.1  cgd {
     58  1.1  cgd 	freeinv(obj);
     59  1.1  cgd 	dropy(obj);
     60  1.1  cgd }
     61  1.1  cgd 
     62  1.1  cgd dropy(obj)
     63  1.1  cgd register struct obj *obj;
     64  1.1  cgd {
     65  1.1  cgd 	if(obj->otyp == CRYSKNIFE)
     66  1.1  cgd 		obj->otyp = WORM_TOOTH;
     67  1.1  cgd 	obj->ox = u.ux;
     68  1.1  cgd 	obj->oy = u.uy;
     69  1.1  cgd 	obj->nobj = fobj;
     70  1.1  cgd 	fobj = obj;
     71  1.1  cgd 	if(Invisible) newsym(u.ux,u.uy);
     72  1.1  cgd 	subfrombill(obj);
     73  1.1  cgd 	stackobj(obj);
     74  1.1  cgd }
     75  1.1  cgd 
     76  1.1  cgd /* drop several things */
     77  1.1  cgd doddrop() {
     78  1.1  cgd 	return(ggetobj("drop", drop, 0));
     79  1.1  cgd }
     80  1.1  cgd 
     81  1.1  cgd dodown()
     82  1.1  cgd {
     83  1.1  cgd 	if(u.ux != xdnstair || u.uy != ydnstair) {
     84  1.1  cgd 		pline("You can't go down here.");
     85  1.1  cgd 		return(0);
     86  1.1  cgd 	}
     87  1.1  cgd 	if(u.ustuck) {
     88  1.1  cgd 		pline("You are being held, and cannot go down.");
     89  1.1  cgd 		return(1);
     90  1.1  cgd 	}
     91  1.1  cgd 	if(Levitation) {
     92  1.1  cgd 		pline("You're floating high above the stairs.");
     93  1.1  cgd 		return(0);
     94  1.1  cgd 	}
     95  1.1  cgd 
     96  1.1  cgd 	goto_level(dlevel+1, TRUE);
     97  1.1  cgd 	return(1);
     98  1.1  cgd }
     99  1.1  cgd 
    100  1.1  cgd doup()
    101  1.1  cgd {
    102  1.1  cgd 	if(u.ux != xupstair || u.uy != yupstair) {
    103  1.1  cgd 		pline("You can't go up here.");
    104  1.1  cgd 		return(0);
    105  1.1  cgd 	}
    106  1.1  cgd 	if(u.ustuck) {
    107  1.1  cgd 		pline("You are being held, and cannot go up.");
    108  1.1  cgd 		return(1);
    109  1.1  cgd 	}
    110  1.1  cgd 	if(!Levitation && inv_weight() + 5 > 0) {
    111  1.1  cgd 		pline("Your load is too heavy to climb the stairs.");
    112  1.1  cgd 		return(1);
    113  1.1  cgd 	}
    114  1.1  cgd 
    115  1.1  cgd 	goto_level(dlevel-1, TRUE);
    116  1.1  cgd 	return(1);
    117  1.1  cgd }
    118  1.1  cgd 
    119  1.1  cgd goto_level(newlevel, at_stairs)
    120  1.1  cgd register int newlevel;
    121  1.1  cgd register boolean at_stairs;
    122  1.1  cgd {
    123  1.1  cgd 	register fd;
    124  1.1  cgd 	register boolean up = (newlevel < dlevel);
    125  1.1  cgd 
    126  1.1  cgd 	if(newlevel <= 0) done("escaped");    /* in fact < 0 is impossible */
    127  1.1  cgd 	if(newlevel > MAXLEVEL) newlevel = MAXLEVEL;	/* strange ... */
    128  1.1  cgd 	if(newlevel == dlevel) return;	      /* this can happen */
    129  1.1  cgd 
    130  1.1  cgd 	glo(dlevel);
    131  1.1  cgd 	fd = creat(lock, FMASK);
    132  1.1  cgd 	if(fd < 0) {
    133  1.1  cgd 		/*
    134  1.1  cgd 		 * This is not quite impossible: e.g., we may have
    135  1.1  cgd 		 * exceeded our quota. If that is the case then we
    136  1.1  cgd 		 * cannot leave this level, and cannot save either.
    137  1.1  cgd 		 * Another possibility is that the directory was not
    138  1.1  cgd 		 * writable.
    139  1.1  cgd 		 */
    140  1.1  cgd 		pline("A mysterious force prevents you from going %s.",
    141  1.1  cgd 			up ? "up" : "down");
    142  1.1  cgd 		return;
    143  1.1  cgd 	}
    144  1.1  cgd 
    145  1.1  cgd 	if(Punished) unplacebc();
    146  1.1  cgd 	u.utrap = 0;				/* needed in level_tele */
    147  1.1  cgd 	u.ustuck = 0;				/* idem */
    148  1.1  cgd 	keepdogs();
    149  1.1  cgd 	seeoff(1);
    150  1.1  cgd 	if(u.uswallow)				/* idem */
    151  1.1  cgd 		u.uswldtim = u.uswallow = 0;
    152  1.1  cgd 	flags.nscrinh = 1;
    153  1.1  cgd 	u.ux = FAR;				/* hack */
    154  1.1  cgd 	(void) inshop();			/* probably was a trapdoor */
    155  1.1  cgd 
    156  1.1  cgd 	savelev(fd,dlevel);
    157  1.1  cgd 	(void) close(fd);
    158  1.1  cgd 
    159  1.1  cgd 	dlevel = newlevel;
    160  1.1  cgd 	if(maxdlevel < dlevel)
    161  1.1  cgd 		maxdlevel = dlevel;
    162  1.1  cgd 	glo(dlevel);
    163  1.1  cgd 
    164  1.1  cgd 	if(!level_exists[dlevel])
    165  1.1  cgd 		mklev();
    166  1.1  cgd 	else {
    167  1.1  cgd 		extern int hackpid;
    168  1.1  cgd 
    169  1.1  cgd 		if((fd = open(lock,0)) < 0) {
    170  1.1  cgd 			pline("Cannot open %s .", lock);
    171  1.1  cgd 			pline("Probably someone removed it.");
    172  1.1  cgd 			done("tricked");
    173  1.1  cgd 		}
    174  1.1  cgd 		getlev(fd, hackpid, dlevel);
    175  1.1  cgd 		(void) close(fd);
    176  1.1  cgd 	}
    177  1.1  cgd 
    178  1.1  cgd 	if(at_stairs) {
    179  1.1  cgd 	    if(up) {
    180  1.1  cgd 		u.ux = xdnstair;
    181  1.1  cgd 		u.uy = ydnstair;
    182  1.1  cgd 		if(!u.ux) {		/* entering a maze from below? */
    183  1.1  cgd 		    u.ux = xupstair;	/* this will confuse the player! */
    184  1.1  cgd 		    u.uy = yupstair;
    185  1.1  cgd 		}
    186  1.1  cgd 		if(Punished && !Levitation){
    187  1.1  cgd 			pline("With great effort you climb the stairs.");
    188  1.1  cgd 			placebc(1);
    189  1.1  cgd 		}
    190  1.1  cgd 	    } else {
    191  1.1  cgd 		u.ux = xupstair;
    192  1.1  cgd 		u.uy = yupstair;
    193  1.1  cgd 		if(inv_weight() + 5 > 0 || Punished){
    194  1.1  cgd 			pline("You fall down the stairs.");	/* %% */
    195  1.1  cgd 			losehp(rnd(3), "fall");
    196  1.1  cgd 			if(Punished) {
    197  1.1  cgd 			    if(uwep != uball && rn2(3)){
    198  1.1  cgd 				pline("... and are hit by the iron ball.");
    199  1.1  cgd 				losehp(rnd(20), "iron ball");
    200  1.1  cgd 			    }
    201  1.1  cgd 			    placebc(1);
    202  1.1  cgd 			}
    203  1.1  cgd 			selftouch("Falling, you");
    204  1.1  cgd 		}
    205  1.1  cgd 	    }
    206  1.1  cgd 	    { register struct monst *mtmp = m_at(u.ux, u.uy);
    207  1.1  cgd 	      if(mtmp)
    208  1.1  cgd 		mnexto(mtmp);
    209  1.1  cgd 	    }
    210  1.1  cgd 	} else {	/* trapdoor or level_tele */
    211  1.1  cgd 	    do {
    212  1.1  cgd 		u.ux = rnd(COLNO-1);
    213  1.1  cgd 		u.uy = rn2(ROWNO);
    214  1.1  cgd 	    } while(levl[u.ux][u.uy].typ != ROOM ||
    215  1.1  cgd 			m_at(u.ux,u.uy));
    216  1.1  cgd 	    if(Punished){
    217  1.1  cgd 		if(uwep != uball && !up /* %% */ && rn2(5)){
    218  1.1  cgd 			pline("The iron ball falls on your head.");
    219  1.1  cgd 			losehp(rnd(25), "iron ball");
    220  1.1  cgd 		}
    221  1.1  cgd 		placebc(1);
    222  1.1  cgd 	    }
    223  1.1  cgd 	    selftouch("Falling, you");
    224  1.1  cgd 	}
    225  1.1  cgd 	(void) inshop();
    226  1.1  cgd 	initrack();
    227  1.1  cgd 
    228  1.1  cgd 	losedogs();
    229  1.1  cgd 	{ register struct monst *mtmp;
    230  1.1  cgd 	  if(mtmp = m_at(u.ux, u.uy)) mnexto(mtmp);	/* riv05!a3 */
    231  1.1  cgd 	}
    232  1.1  cgd 	flags.nscrinh = 0;
    233  1.1  cgd 	setsee();
    234  1.1  cgd 	seeobjs();	/* make old cadavers disappear - riv05!a3 */
    235  1.1  cgd 	docrt();
    236  1.1  cgd 	pickup(1);
    237  1.1  cgd 	read_engr_at(u.ux,u.uy);
    238  1.1  cgd }
    239  1.1  cgd 
    240  1.1  cgd donull() {
    241  1.1  cgd 	return(1);	/* Do nothing, but let other things happen */
    242  1.1  cgd }
    243  1.1  cgd 
    244  1.1  cgd dopray() {
    245  1.1  cgd 	nomovemsg = "You finished your prayer.";
    246  1.1  cgd 	nomul(-3);
    247  1.1  cgd 	return(1);
    248  1.1  cgd }
    249  1.1  cgd 
    250  1.1  cgd struct monst *bhit(), *boomhit();
    251  1.1  cgd dothrow()
    252  1.1  cgd {
    253  1.1  cgd 	register struct obj *obj;
    254  1.1  cgd 	register struct monst *mon;
    255  1.1  cgd 	register tmp;
    256  1.1  cgd 
    257  1.1  cgd 	obj = getobj("#)", "throw");   /* it is also possible to throw food */
    258  1.1  cgd 				       /* (or jewels, or iron balls ... ) */
    259  1.1  cgd 	if(!obj || !getdir(1))	       /* ask "in what direction?" */
    260  1.1  cgd 		return(0);
    261  1.1  cgd 	if(obj->owornmask & (W_ARMOR | W_RING)){
    262  1.1  cgd 		pline("You can't throw something you are wearing.");
    263  1.1  cgd 		return(0);
    264  1.1  cgd 	}
    265  1.1  cgd 
    266  1.1  cgd 	u_wipe_engr(2);
    267  1.1  cgd 
    268  1.1  cgd 	if(obj == uwep){
    269  1.1  cgd 		if(obj->cursed){
    270  1.1  cgd 			pline("Your weapon is welded to your hand.");
    271  1.1  cgd 			return(1);
    272  1.1  cgd 		}
    273  1.1  cgd 		if(obj->quan > 1)
    274  1.1  cgd 			setuwep(splitobj(obj, 1));
    275  1.1  cgd 		else
    276  1.1  cgd 			setuwep((struct obj *) 0);
    277  1.1  cgd 	}
    278  1.1  cgd 	else if(obj->quan > 1)
    279  1.1  cgd 		(void) splitobj(obj, 1);
    280  1.1  cgd 	freeinv(obj);
    281  1.1  cgd 	if(u.uswallow) {
    282  1.1  cgd 		mon = u.ustuck;
    283  1.1  cgd 		bhitpos.x = mon->mx;
    284  1.1  cgd 		bhitpos.y = mon->my;
    285  1.1  cgd 	} else if(u.dz) {
    286  1.1  cgd 	  if(u.dz < 0) {
    287  1.1  cgd 	    pline("%s hits the ceiling, then falls back on top of your head.",
    288  1.1  cgd 		Doname(obj));		/* note: obj->quan == 1 */
    289  1.1  cgd 	    if(obj->olet == POTION_SYM)
    290  1.1  cgd 		potionhit(&youmonst, obj);
    291  1.1  cgd 	    else {
    292  1.1  cgd 		if(uarmh) pline("Fortunately, you are wearing a helmet!");
    293  1.1  cgd 		losehp(uarmh ? 1 : rnd((int)(obj->owt)), "falling object");
    294  1.1  cgd 		dropy(obj);
    295  1.1  cgd 	    }
    296  1.1  cgd 	  } else {
    297  1.1  cgd 	    pline("%s hits the floor.", Doname(obj));
    298  1.1  cgd 	    if(obj->otyp == EXPENSIVE_CAMERA) {
    299  1.1  cgd 		pline("It is shattered in a thousand pieces!");
    300  1.1  cgd 		obfree(obj, Null(obj));
    301  1.1  cgd 	    } else if(obj->otyp == EGG) {
    302  1.1  cgd 		pline("\"Splash!\"");
    303  1.1  cgd 		obfree(obj, Null(obj));
    304  1.1  cgd 	    } else if(obj->olet == POTION_SYM) {
    305  1.1  cgd 		pline("The flask breaks, and you smell a peculiar odor ...");
    306  1.1  cgd 		potionbreathe(obj);
    307  1.1  cgd 		obfree(obj, Null(obj));
    308  1.1  cgd 	    } else {
    309  1.1  cgd 		dropy(obj);
    310  1.1  cgd 	    }
    311  1.1  cgd 	  }
    312  1.1  cgd 	  return(1);
    313  1.1  cgd 	} else if(obj->otyp == BOOMERANG) {
    314  1.1  cgd 		mon = boomhit(u.dx, u.dy);
    315  1.1  cgd 		if(mon == &youmonst) {		/* the thing was caught */
    316  1.1  cgd 			(void) addinv(obj);
    317  1.1  cgd 			return(1);
    318  1.1  cgd 		}
    319  1.1  cgd 	} else {
    320  1.1  cgd 		if(obj->otyp == PICK_AXE && shkcatch(obj))
    321  1.1  cgd 		    return(1);
    322  1.1  cgd 
    323  1.1  cgd 		mon = bhit(u.dx, u.dy, (obj->otyp == ICE_BOX) ? 1 :
    324  1.1  cgd 			(!Punished || obj != uball) ? 8 : !u.ustuck ? 5 : 1,
    325  1.1  cgd 			obj->olet,
    326  1.1  cgd 			(int (*)()) 0, (int (*)()) 0, obj);
    327  1.1  cgd 	}
    328  1.1  cgd 	if(mon) {
    329  1.1  cgd 		/* awake monster if sleeping */
    330  1.1  cgd 		wakeup(mon);
    331  1.1  cgd 
    332  1.1  cgd 		if(obj->olet == WEAPON_SYM) {
    333  1.1  cgd 			tmp = -1+u.ulevel+mon->data->ac+abon();
    334  1.1  cgd 			if(obj->otyp < ROCK) {
    335  1.1  cgd 				if(!uwep ||
    336  1.1  cgd 				    uwep->otyp != obj->otyp+(BOW-ARROW))
    337  1.1  cgd 					tmp -= 4;
    338  1.1  cgd 				else {
    339  1.1  cgd 					tmp += uwep->spe;
    340  1.1  cgd 				}
    341  1.1  cgd 			} else
    342  1.1  cgd 			if(obj->otyp == BOOMERANG) tmp += 4;
    343  1.1  cgd 			tmp += obj->spe;
    344  1.1  cgd 			if(u.uswallow || tmp >= rnd(20)) {
    345  1.1  cgd 				if(hmon(mon,obj,1) == TRUE){
    346  1.1  cgd 				  /* mon still alive */
    347  1.1  cgd #ifndef NOWORM
    348  1.1  cgd 				  cutworm(mon,bhitpos.x,bhitpos.y,obj->otyp);
    349  1.1  cgd #endif NOWORM
    350  1.1  cgd 				} else mon = 0;
    351  1.1  cgd 				/* weapons thrown disappear sometimes */
    352  1.1  cgd 				if(obj->otyp < BOOMERANG && rn2(3)) {
    353  1.1  cgd 					/* check bill; free */
    354  1.1  cgd 					obfree(obj, (struct obj *) 0);
    355  1.1  cgd 					return(1);
    356  1.1  cgd 				}
    357  1.1  cgd 			} else miss(objects[obj->otyp].oc_name, mon);
    358  1.1  cgd 		} else if(obj->otyp == HEAVY_IRON_BALL) {
    359  1.1  cgd 			tmp = -1+u.ulevel+mon->data->ac+abon();
    360  1.1  cgd 			if(!Punished || obj != uball) tmp += 2;
    361  1.1  cgd 			if(u.utrap) tmp -= 2;
    362  1.1  cgd 			if(u.uswallow || tmp >= rnd(20)) {
    363  1.1  cgd 				if(hmon(mon,obj,1) == FALSE)
    364  1.1  cgd 					mon = 0;	/* he died */
    365  1.1  cgd 			} else miss("iron ball", mon);
    366  1.1  cgd 		} else if(obj->olet == POTION_SYM && u.ulevel > rn2(15)) {
    367  1.1  cgd 			potionhit(mon, obj);
    368  1.1  cgd 			return(1);
    369  1.1  cgd 		} else {
    370  1.1  cgd 			if(cansee(bhitpos.x,bhitpos.y))
    371  1.1  cgd 				pline("You miss %s.",monnam(mon));
    372  1.1  cgd 			else pline("You miss it.");
    373  1.1  cgd 			if(obj->olet == FOOD_SYM && mon->data->mlet == 'd')
    374  1.1  cgd 				if(tamedog(mon,obj)) return(1);
    375  1.1  cgd 			if(obj->olet == GEM_SYM && mon->data->mlet == 'u' &&
    376  1.1  cgd 				!mon->mtame){
    377  1.1  cgd 			 if(obj->dknown && objects[obj->otyp].oc_name_known){
    378  1.1  cgd 			  if(objects[obj->otyp].g_val > 0){
    379  1.1  cgd 			    u.uluck += 5;
    380  1.1  cgd 			    goto valuable;
    381  1.1  cgd 			  } else {
    382  1.1  cgd 			    pline("%s is not interested in your junk.",
    383  1.1  cgd 				Monnam(mon));
    384  1.1  cgd 			  }
    385  1.1  cgd 			 } else { /* value unknown to @ */
    386  1.1  cgd 			    u.uluck++;
    387  1.1  cgd 			valuable:
    388  1.1  cgd 			    if(u.uluck > LUCKMAX)	/* dan@ut-ngp */
    389  1.1  cgd 				u.uluck = LUCKMAX;
    390  1.1  cgd 			    pline("%s graciously accepts your gift.",
    391  1.1  cgd 				Monnam(mon));
    392  1.1  cgd 			    mpickobj(mon, obj);
    393  1.1  cgd 			    rloc(mon);
    394  1.1  cgd 			    return(1);
    395  1.1  cgd 			 }
    396  1.1  cgd 			}
    397  1.1  cgd 		}
    398  1.1  cgd 	}
    399  1.1  cgd 		/* the code following might become part of dropy() */
    400  1.1  cgd 	if(obj->otyp == CRYSKNIFE)
    401  1.1  cgd 		obj->otyp = WORM_TOOTH;
    402  1.1  cgd 	obj->ox = bhitpos.x;
    403  1.1  cgd 	obj->oy = bhitpos.y;
    404  1.1  cgd 	obj->nobj = fobj;
    405  1.1  cgd 	fobj = obj;
    406  1.1  cgd 	/* prevent him from throwing articles to the exit and escaping */
    407  1.1  cgd 	/* subfrombill(obj); */
    408  1.1  cgd 	stackobj(obj);
    409  1.1  cgd 	if(Punished && obj == uball &&
    410  1.1  cgd 		(bhitpos.x != u.ux || bhitpos.y != u.uy)){
    411  1.1  cgd 		freeobj(uchain);
    412  1.1  cgd 		unpobj(uchain);
    413  1.1  cgd 		if(u.utrap){
    414  1.1  cgd 			if(u.utraptype == TT_PIT)
    415  1.1  cgd 				pline("The ball pulls you out of the pit!");
    416  1.1  cgd 			else {
    417  1.1  cgd 			    register long side =
    418  1.1  cgd 				rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
    419  1.1  cgd 			    pline("The ball pulls you out of the bear trap.");
    420  1.1  cgd 			    pline("Your %s leg is severely damaged.",
    421  1.1  cgd 				(side == LEFT_SIDE) ? "left" : "right");
    422  1.1  cgd 			    set_wounded_legs(side, 500+rn2(1000));
    423  1.1  cgd 			    losehp(2, "thrown ball");
    424  1.1  cgd 			}
    425  1.1  cgd 			u.utrap = 0;
    426  1.1  cgd 		}
    427  1.1  cgd 		unsee();
    428  1.1  cgd 		uchain->nobj = fobj;
    429  1.1  cgd 		fobj = uchain;
    430  1.1  cgd 		u.ux = uchain->ox = bhitpos.x - u.dx;
    431  1.1  cgd 		u.uy = uchain->oy = bhitpos.y - u.dy;
    432  1.1  cgd 		setsee();
    433  1.1  cgd 		(void) inshop();
    434  1.1  cgd 	}
    435  1.1  cgd 	if(cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x,bhitpos.y);
    436  1.1  cgd 	return(1);
    437  1.1  cgd }
    438  1.1  cgd 
    439  1.1  cgd /* split obj so that it gets size num */
    440  1.1  cgd /* remainder is put in the object structure delivered by this call */
    441  1.1  cgd struct obj *
    442  1.1  cgd splitobj(obj, num) register struct obj *obj; register int num; {
    443  1.1  cgd register struct obj *otmp;
    444  1.1  cgd 	otmp = newobj(0);
    445  1.1  cgd 	*otmp = *obj;		/* copies whole structure */
    446  1.1  cgd 	otmp->o_id = flags.ident++;
    447  1.1  cgd 	otmp->onamelth = 0;
    448  1.1  cgd 	obj->quan = num;
    449  1.1  cgd 	obj->owt = weight(obj);
    450  1.1  cgd 	otmp->quan -= num;
    451  1.1  cgd 	otmp->owt = weight(otmp);	/* -= obj->owt ? */
    452  1.1  cgd 	obj->nobj = otmp;
    453  1.1  cgd 	if(obj->unpaid) splitbill(obj,otmp);
    454  1.1  cgd 	return(otmp);
    455  1.1  cgd }
    456  1.1  cgd 
    457  1.1  cgd more_experienced(exp,rexp)
    458  1.1  cgd register int exp, rexp;
    459  1.1  cgd {
    460  1.1  cgd 	extern char pl_character[];
    461  1.1  cgd 
    462  1.1  cgd 	u.uexp += exp;
    463  1.1  cgd 	u.urexp += 4*exp + rexp;
    464  1.1  cgd 	if(exp) flags.botl = 1;
    465  1.1  cgd 	if(u.urexp >= ((pl_character[0] == 'W') ? 1000 : 2000))
    466  1.1  cgd 		flags.beginner = 0;
    467  1.1  cgd }
    468  1.1  cgd 
    469  1.1  cgd set_wounded_legs(side, timex)
    470  1.1  cgd register long side;
    471  1.1  cgd register int timex;
    472  1.1  cgd {
    473  1.1  cgd 	if(!Wounded_legs || (Wounded_legs & TIMEOUT))
    474  1.1  cgd 		Wounded_legs |= side + timex;
    475  1.1  cgd 	else
    476  1.1  cgd 		Wounded_legs |= side;
    477  1.1  cgd }
    478  1.1  cgd 
    479  1.1  cgd heal_legs()
    480  1.1  cgd {
    481  1.1  cgd 	if(Wounded_legs) {
    482  1.1  cgd 		if((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)
    483  1.1  cgd 			pline("Your legs feel somewhat better.");
    484  1.1  cgd 		else
    485  1.1  cgd 			pline("Your leg feels somewhat better.");
    486  1.1  cgd 		Wounded_legs = 0;
    487  1.1  cgd 	}
    488  1.1  cgd }
    489