コード例 #1
0
ファイル: hack.unix.c プロジェクト: lattera/openbsd
static void
newmail()
{
	/* produce a scroll of mail */
	struct obj *obj;
	struct monst *md;
	extern char plname[];
	extern struct obj *mksobj();
	extern struct monst *makemon();
	extern struct permonst pm_mail_daemon;

	obj = mksobj(SCR_MAIL);
	if(md = makemon(&pm_mail_daemon, u.ux, u.uy)) /* always succeeds */
		mdrush(md,0);

	pline("\"Hello, %s! I have some mail for you.\"", plname);
	if(md) {
		if(dist(md->mx,md->my) > 2)
			pline("\"Catch!\"");
		more();

		/* let him disappear again */
		mdrush(md,1);
		mondead(md);
	}

	obj = addinv(obj);
	(void) identify(obj);		/* set known and do prinv() */
}
コード例 #2
0
ファイル: hack.apply.c プロジェクト: jyin0813/OpenBSD-src
int
out_ice_box(struct obj *obj)
{
	struct obj *otmp;

	if (obj == fcobj)
		fcobj = fcobj->nobj;
	else {
		for(otmp = fcobj; otmp->nobj != obj; otmp = otmp->nobj)
			if(!otmp->nobj) panic("out_ice_box");
		otmp->nobj = obj->nobj;
	}
	current_ice_box->owt -= obj->owt;
	obj->age = moves - obj->age;	/* simulated point of time */
	(void) addinv(obj);
	return(0);
}
コード例 #3
0
ファイル: unix.c プロジェクト: kleopatra999/bsd-games-3
void newmail(void)
{
    // produce a scroll of mail
    struct obj *obj;
    struct monst *md;

    obj = mksobj(SCR_MAIL);
    if (md = makemon(&pm_mail_daemon, u.ux, u.uy))	// always succeeds
	mdrush(md, 0);

    pline("\"Hello, %s! I have some mail for you.\"", plname);
    if (md) {
	if (dist(md->mx, md->my) > 2)
	    pline("\"Catch!\"");
	more();

	// let him disappear again
	mdrush(md, 1);
	mondead(md);
    }
    obj = addinv(obj);
    (void) identify(obj);      // set known and do prinv()
}
コード例 #4
0
void
level_tele_impl(boolean wizard_tele)
{
    int newlev;
    d_level newlevel;
    const char *escape_by_flying = 0;   /* when surviving dest of -N */
    boolean force_dest = FALSE;
    const char *buf, *killer = NULL;

    if ((Uhave_amulet || In_endgame(&u.uz) || In_sokoban(&u.uz))
        && !wizard_tele) {
        pline("You feel very disoriented for a moment.");
        return;
    }
    if ((Teleport_control && !Stunned) || wizard_tele) {
        int trycnt = 0;
        const char *qbuf = "To what level do you want to teleport?";
        do {
            if (++trycnt == 2) {
                if (wizard_tele)
                    qbuf = msgcat(qbuf, " [type a number or ? for a menu]");
                else
                    qbuf = msgcat(qbuf, " [type a number]");
            }
            buf = getlin(qbuf, FALSE);
            if (!strcmp(buf, "\033")) { /* cancelled */
                if (Confusion && rnl(5)) {
                    pline("Oops...");
                    goto random_levtport;
                }
                return;
            } else if (!strcmp(buf, "*")) {
                goto random_levtport;
            } else if (Confusion && rnl(5)) {
                pline("Oops...");
                goto random_levtport;
            }

            if (wizard_tele && !strcmp(buf, "?")) {
                schar destlev = 0;
                xchar destdnum = 0;

                if ((newlev = (int)print_dungeon(TRUE, &destlev, &destdnum))) {
                    newlevel.dnum = destdnum;
                    newlevel.dlevel = destlev;
                    if (In_endgame(&newlevel) && !In_endgame(&u.uz)) {
                        const char *dest = "Destination is earth level";
                        if (!Uhave_amulet) {
                            struct obj *obj;

                            obj = mksobj(level, AMULET_OF_YENDOR, TRUE, FALSE,
                                         rng_main);
                            if (obj) {
                                addinv(obj);
                                dest = msgcat(dest, " with the amulet");
                            }
                        }
                        assign_level(&newlevel, &earth_level);
                        pline("%s.", dest);
                    }
                    force_dest = TRUE;
                } else
                    return;
            } else if ((newlev = lev_by_name(buf)) == 0)
                newlev = atoi(buf);
        } while (!newlev && !digit(buf[0]) && (buf[0] != '-' || !digit(buf[1]))
                 && trycnt < 10);

        /* no dungeon escape via this route */
        if (newlev == 0) {
            if (trycnt >= 10)
                goto random_levtport;
            if (ynq("Go to Nowhere.  Are you sure?") != 'y')
                return;
            pline("You %s in agony as your body begins to warp...",
                  is_silent(youmonst.data) ? "writhe" : "scream");
            win_pause_output(P_MESSAGE);
            pline("You cease to exist.");
            if (invent)
                pline("Your possessions land on the %s with a thud.",
                      surface(u.ux, u.uy));
            done(DIED, "committed suicide");
            pline("An energized cloud of dust begins to coalesce.");
            pline("Your body rematerializes%s.",
                  invent ? ", and you gather up all your possessions" : "");
            return;
        }

        /* if in Knox and the requested level > 0, stay put. we let negative
           values requests fall into the "heaven" loop. */
        if (Is_knox(&u.uz) && newlev > 0) {
            pline("You shudder for a moment.");
            return;
        }
        /* if in Quest, the player sees "Home 1", etc., on the status line,
           instead of the logical depth of the level.  controlled level
           teleport request is likely to be relativized to the status line, and
           consequently it should be incremented to the value of the logical
           depth of the target level. we let negative values requests fall into
           the "heaven" loop. */
        if (In_quest(&u.uz) && newlev > 0)
            newlev = newlev + find_dungeon(&u.uz).depth_start - 1;
    } else {    /* involuntary level tele */
    random_levtport:
        newlev = random_teleport_level();
        if (newlev == depth(&u.uz)) {
            pline("You shudder for a moment.");
            return;
        }
    }

    if (!next_to_u()) {
        pline("You shudder for a moment.");
        return;
    }

    if (In_endgame(&u.uz)) {    /* must already be wizard */
        int llimit = dunlevs_in_dungeon(&u.uz);

        if (newlev >= 0 || newlev <= -llimit) {
            pline("You can't get there from here.");
            return;
        }
        newlevel.dnum = u.uz.dnum;
        newlevel.dlevel = llimit + newlev;
        schedule_goto(&newlevel, FALSE, FALSE, 0, NULL, NULL);
        return;
    }

    if (newlev < 0 && !force_dest) {
        if (*u.ushops0) {
            /* take unpaid inventory items off of shop bills */
            in_mklev = TRUE;    /* suppress map update */
            u_left_shop(u.ushops0, TRUE);
            /* you're now effectively out of the shop */
            *u.ushops0 = *u.ushops = '\0';
            in_mklev = FALSE;
        }
        if (newlev <= -10) {
            pline("You arrive in heaven.");
            verbalize("Thou art early, but we'll admit thee.");
            killer = "went to heaven prematurely";
        } else if (newlev == -9) {
            pline("You feel deliriously happy. ");
            pline("(In fact, you're on Cloud 9!) ");
            win_pause_output(P_MESSAGE);
        } else
            pline("You are now high above the clouds...");

        if (killer) {
            ;   /* arrival in heaven is pending */
        } else if (Levitation) {
            escape_by_flying = "float gently down to earth";
        } else if (Flying) {
            escape_by_flying = "fly down to the ground";
        } else {
            pline("Unfortunately, you don't know how to fly.");
            pline("You plummet a few thousand feet to your death.");
            killer = msgcat_many("teleported out of the dungeon and fell to ",
                                 uhis(), " death", NULL);
        }
    }

    if (killer) {       /* the chosen destination was not survivable */
        d_level lsav;

        /* set specific death location; this also suppresses bones */
        lsav = u.uz;    /* save current level, see below */
        u.uz.dnum = 0;  /* main dungeon */
        u.uz.dlevel = (newlev <= -10) ? -10 : 0;        /* heaven or surface */
        done(DIED, killer);
        /* can only get here via life-saving (or declining to die in
           explore|debug mode); the hero has now left the dungeon... */
        escape_by_flying = "find yourself back on the surface";
        u.uz = lsav;    /* restore u.uz so escape code works */
    }

    /* calls done(ESCAPED) if newlevel==0 */
    if (escape_by_flying) {
        pline("You %s.", escape_by_flying);
        done(ESCAPED, "teleported to safety");
    } else if (u.uz.dnum == medusa_level.dnum &&
               newlev >= (find_dungeon(&u.uz).depth_start +
                          dunlevs_in_dungeon(&u.uz))) {
        if (!(wizard_tele && force_dest))
            find_hell(&newlevel);
    } else {
        /* if invocation did not yet occur, teleporting into the last level of
           Gehennom is forbidden. */
        if (!wizard_tele)
            if (Inhell && !u.uevent.invoked &&
                newlev >= (find_dungeon(&u.uz).depth_start +
                           dunlevs_in_dungeon(&u.uz) - 1)) {
                newlev = (find_dungeon(&u.uz).depth_start +
                          dunlevs_in_dungeon(&u.uz) - 2);
                pline("Sorry...");
            }
        /* no teleporting out of quest dungeon */
        if (In_quest(&u.uz) && newlev < depth(&qstart_level))
            newlev = depth(&qstart_level);
        /* the player thinks of levels purely in logical terms, so we must
           translate newlev to a number relative to the current dungeon. */
        if (!(wizard_tele && force_dest))
            get_level(&newlevel, newlev);
    }
    schedule_goto(&newlevel, FALSE, FALSE, 0, NULL, NULL);
    /* in case player just read a scroll and is about to be asked to call it
       something, we can't defer until the end of the turn */
    if (!flags.mon_moving)
        deferred_goto();
}
コード例 #5
0
ファイル: hack.zap.c プロジェクト: blakeney/slack
int
dozap(void)
{
	struct obj *obj;
	xchar zx,zy;

	obj = getobj("/", "zap");
	if(!obj) return(0);
	if(obj->spe < 0 || (obj->spe == 0 && rn2(121))) {
		pline("Nothing Happens.");
		return(1);
	}
	if(obj->spe == 0)
		pline("You wrest one more spell from the worn-out wand.");
	if(!(objects[obj->otyp].bits & NODIR) && !getdir(1))
		return(1);	/* make him pay for knowing !NODIR */
	obj->spe--;
	if(objects[obj->otyp].bits & IMMEDIATE) {
		if(u.uswallow)
			bhitm(u.ustuck, obj);
		else if(u.dz) {
			if(u.dz > 0) {
				struct obj *otmp = o_at(u.ux, u.uy);
				if(otmp)
					bhito(otmp, obj);
			}
		} else
			bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj);
	} else {
	    switch(obj->otyp){
		case WAN_LIGHT:
			litroom(TRUE);
			break;
		case WAN_SECRET_DOOR_DETECTION:
			if(!findit()) return(1);
			break;
		case WAN_CREATE_MONSTER:
			{ int cnt = 1;
			if(!rn2(23)) cnt += rn2(7) + 1;
			while(cnt--)
			    makemon(NULL, u.ux, u.uy);
			}
			break;
		case WAN_WISHING:
			{ char buf[BUFSZ];
			  struct obj *otmp;
		      if(u.uluck + rn2(5) < 0) {
			pline("Unfortunately, nothing happens.");
			break;
		      }
		      pline("You may wish for an object. What do you want? ");
		      getlin(buf);
		      if(buf[0] == '\033') buf[0] = 0;
		      otmp = readobjnam(buf);
		      otmp = addinv(otmp);
		      prinv(otmp);
		      break;
			}
		case WAN_DIGGING:
			/* Original effect (approximately):
			 * from CORR: dig until we pierce a wall
			 * from ROOM: piece wall and dig until we reach
			 * an ACCESSIBLE place.
			 * Currently: dig for digdepth positions;
			 * also down on request of Lennart Augustsson.
			 */
			{ struct rm *room;
			  int digdepth;
			if(u.uswallow) {
				struct monst *mtmp = u.ustuck;

				pline("You pierce %s's stomach wall!",
					monnam(mtmp));
				mtmp->mhp = 1;	/* almost dead */
				unstuck(mtmp);
				mnexto(mtmp);
				break;
			}
			if(u.dz) {
			    if(u.dz < 0) {
				pline("You loosen a rock from the ceiling.");
				pline("It falls on your head!");
				losehp(1, "falling rock");
				mksobj_at(ROCK, u.ux, u.uy);
				fobj->quan = 1;
				stackobj(fobj);
				if(Invisible) newsym(u.ux, u.uy);
			    } else {
				dighole();
			    }
			    break;
			}
			zx = u.ux+u.dx;
			zy = u.uy+u.dy;
			digdepth = 8 + rn2(18);
			Tmp_at(-1, '*');	/* open call */
			while(--digdepth >= 0) {
				if(!isok(zx,zy)) break;
				room = &levl[zx][zy];
				Tmp_at(zx,zy);
				if(!xdnstair){
					if(zx < 3 || zx > COLNO-3 ||
					    zy < 3 || zy > ROWNO-3)
						break;
					if(room->typ == HWALL ||
					    room->typ == VWALL){
						room->typ = ROOM;
						break;
					}
				} else
				if(room->typ == HWALL || room->typ == VWALL ||
				   room->typ == SDOOR || room->typ == LDOOR){
					room->typ = DOOR;
					digdepth -= 2;
				} else
				if(room->typ == SCORR || !room->typ) {
					room->typ = CORR;
					digdepth--;
				}
				mnewsym(zx,zy);
				zx += u.dx;
				zy += u.dy;
			}
			mnewsym(zx,zy);	/* not always necessary */
			Tmp_at(-1,-1);	/* closing call */
			break;
			}
		default:
			buzz((int) obj->otyp - WAN_MAGIC_MISSILE,
				u.ux, u.uy, u.dx, u.dy);
			break;
		}
	}
	return(1);
}
コード例 #6
0
ファイル: eat.c プロジェクト: msharov/bsd-games
int doeat(void)
{
    struct obj *otmp;
    int tmp;

    // Is there some food (probably a heavy corpse) here on the ground?
    if (!Levitation)
	for (otmp = _level->objects; otmp; otmp = otmp->nobj) {
	    if (otmp->ox == _u.ux && otmp->oy == _u.uy && otmp->olet == FOOD_SYM) {
		pline("There %s %s here; eat %s? [ny] ", (otmp->quan == 1) ? "is" : "are", doname(otmp), (otmp->quan == 1) ? "it" : "one");
		if (readchar() == 'y') {
		    if (otmp->quan != 1)
			(void) splitobj(otmp, 1);
		    freeobj(otmp);
		    otmp = addinv(otmp);
		    addtobill(otmp);
		    goto gotit;
		}
	    }
	}
    otmp = getobj("%", "eat");
    if (!otmp)
	return 0;
  gotit:
    if (otmp->otyp == TIN) {
	if (uwep) {
	    switch (uwep->otyp) {
		case CAN_OPENER:
		    tmp = 1;
		    break;
		case DAGGER:
		    tmp = 3;
		    break;
		case PICK_AXE:
		case AXE:
		    tmp = 6;
		    break;
		default:
		    goto no_opener;
	    }
	    pline("Using your %s you try to open the tin.", aobjnam(uwep, NULL));
	} else {
	  no_opener:
	    pline("It is not so easy to open this tin.");
	    if (Glib) {
		pline("The tin slips out of your hands.");
		if (otmp->quan > 1) {
		    struct obj *obj;

		    obj = splitobj(otmp, 1);
		    if (otmp == uwep)
			setuwep(obj);
		}
		dropx(otmp);
		return 1;
	    }
	    tmp = 10 + rn2(1 + 500 / ((int) (_u.ulevel + _u.ustr)));
	}
	tin.reqtime = tmp;
	tin.usedtime = 0;
	tin.tin = otmp;
	occupation = opentin;
	occtxt = "opening the tin";
	return 1;
    }
    const struct objclass* ftmp = &c_Objects[otmp->otyp];
    multi = -ftmp->oc_delay;
    if (otmp->otyp >= CORPSE && eatcorpse(otmp))
	goto eatx;
    if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
	pline("Blecch!  Rotten food!");
	if (!rn2(4)) {
	    pline("You feel rather light headed.");
	    Confusion += d(2, 4);
	} else if (!rn2(4) && !Blind) {
	    pline("Everything suddenly goes dark.");
	    Blind = d(2, 10);
	    seeoff(0);
	} else if (!rn2(3)) {
	    if (Blind)
		pline("The world spins and you slap against the floor.");
	    else
		pline("The world spins and goes dark.");
	    nomul(-rnd(10));
	    nomovemsg = "You are conscious again.";
	}
	lesshungry(ftmp->nutrition / 4);
    } else {
	if (_u.uhunger >= 1500) {
	    pline("You choke over your food.");
	    pline("You die...");
	    killer = ftmp->oc_name;
	    done("choked");
	}
	switch (otmp->otyp) {
	    case FOOD_RATION:
		if (_u.uhunger <= 200)
		    pline("That food really hit the spot!");
		else if (_u.uhunger <= 700)
		    pline("That satiated your stomach!");
		else {
		    pline("You're having a hard time getting all that food down.");
		    multi -= 2;
		}
		lesshungry(ftmp->nutrition);
		if (multi < 0)
		    nomovemsg = "You finished your meal.";
		break;
	    case TRIPE_RATION:
		pline("Yak - dog food!");
		more_experienced(1, 0);
		_wflags.botl = 1;
		if (rn2(2)) {
		    pline("You vomit.");
		    morehungry(20);
		    if (Sick) {
			Sick = 0;	// David Neves
			pline("What a relief!");
		    }
		} else
		    lesshungry(ftmp->nutrition);
		break;
	    default:
		if (otmp->otyp >= CORPSE)
		    pline("That %s tasted terrible!", ftmp->oc_name);
		else
		    pline("That %s was delicious!", ftmp->oc_name);
		lesshungry(ftmp->nutrition);
		if (otmp->otyp == DEAD_LIZARD && (Confusion > 2))
		    Confusion = 2;
		else if (otmp->otyp == FORTUNE_COOKIE) {
		    if (Blind) {
			pline("This cookie has a scrap of paper inside!");
			pline("What a pity, that you cannot read it!");
		    } else
			print_rumor();
		} else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) {
		    // This stuff seems to be VERY healthy!
		    if (_u.ustrmax < 118)
			++_u.ustrmax;
		    if (_u.ustr < _u.ustrmax)
			++_u.ustr;
		    _u.uhp += rnd(20);
		    if (_u.uhp > _u.uhpmax) {
			if (!rn2(17))
			    ++_u.uhpmax;
			_u.uhp = _u.uhpmax;
		    }
		    heal_legs();
		}
		break;
	}
    }
  eatx:
    if (multi < 0 && !nomovemsg) {
	static char msgbuf[BUFSZ];
	sprintf(msgbuf, "You finished eating the %s.", ftmp->oc_name);
	nomovemsg = msgbuf;
    }
    useup(otmp);
    return 1;
}
コード例 #7
0
ファイル: hack.do.c プロジェクト: lattera/openbsd
int
dothrow()
{
	struct obj *obj;
	struct monst *mon;
	int tmp;

	obj = getobj("#)", "throw");   /* it is also possible to throw food */
				       /* (or jewels, or iron balls ... ) */
	if(!obj || !getdir(1))	       /* ask "in what direction?" */
		return(0);
	if(obj->owornmask & (W_ARMOR | W_RING)){
		pline("You can't throw something you are wearing.");
		return(0);
	}

	u_wipe_engr(2);

	if(obj == uwep){
		if(obj->cursed){
			pline("Your weapon is welded to your hand.");
			return(1);
		}
		if(obj->quan > 1)
			setuwep(splitobj(obj, 1));
		else
			setuwep((struct obj *) 0);
	}
	else if(obj->quan > 1)
		(void) splitobj(obj, 1);
	freeinv(obj);
	if(u.uswallow) {
		mon = u.ustuck;
		bhitpos.x = mon->mx;
		bhitpos.y = mon->my;
	} else if(u.dz) {
	  if(u.dz < 0) {
	    pline("%s hits the ceiling, then falls back on top of your head.",
		Doname(obj));		/* note: obj->quan == 1 */
	    if(obj->olet == POTION_SYM)
		potionhit(&youmonst, obj);
	    else {
		if(uarmh) pline("Fortunately, you are wearing a helmet!");
		losehp(uarmh ? 1 : rnd((int)(obj->owt)), "falling object");
		dropy(obj);
	    }
	  } else {
	    pline("%s hits the floor.", Doname(obj));
	    if(obj->otyp == EXPENSIVE_CAMERA) {
		pline("It is shattered in a thousand pieces!");
		obfree(obj, Null(obj));
	    } else if(obj->otyp == EGG) {
		pline("\"Splash!\"");
		obfree(obj, Null(obj));
	    } else if(obj->olet == POTION_SYM) {
		pline("The flask breaks, and you smell a peculiar odor ...");
		potionbreathe(obj);
		obfree(obj, Null(obj));
	    } else {
		dropy(obj);
	    }
	  }
	  return(1);
	} else if(obj->otyp == BOOMERANG) {
		mon = boomhit(u.dx, u.dy);
		if(mon == &youmonst) {		/* the thing was caught */
			(void) addinv(obj);
			return(1);
		}
	} else {
		if(obj->otyp == PICK_AXE && shkcatch(obj))
		    return(1);

		mon = bhit(u.dx, u.dy, (obj->otyp == ICE_BOX) ? 1 :
			(!Punished || obj != uball) ? 8 : !u.ustuck ? 5 : 1,
			obj->olet, NULL, NULL, obj);
	}
	if(mon) {
		/* awake monster if sleeping */
		wakeup(mon);

		if(obj->olet == WEAPON_SYM) {
			tmp = -1+u.ulevel+mon->data->ac+abon();
			if(obj->otyp < ROCK) {
				if(!uwep ||
				    uwep->otyp != obj->otyp+(BOW-ARROW))
					tmp -= 4;
				else {
					tmp += uwep->spe;
				}
			} else
			if(obj->otyp == BOOMERANG) tmp += 4;
			tmp += obj->spe;
			if(u.uswallow || tmp >= rnd(20)) {
				if(hmon(mon,obj,1) == TRUE){
				  /* mon still alive */
#ifndef NOWORM
				  cutworm(mon,bhitpos.x,bhitpos.y,obj->otyp);
#endif /* NOWORM */
				} else mon = 0;
				/* weapons thrown disappear sometimes */
				if(obj->otyp < BOOMERANG && rn2(3)) {
					/* check bill; free */
					obfree(obj, (struct obj *) 0);
					return(1);
				}
			} else miss(objects[obj->otyp].oc_name, mon);
		} else if(obj->otyp == HEAVY_IRON_BALL) {
			tmp = -1+u.ulevel+mon->data->ac+abon();
			if(!Punished || obj != uball) tmp += 2;
			if(u.utrap) tmp -= 2;
			if(u.uswallow || tmp >= rnd(20)) {
				if(hmon(mon,obj,1) == FALSE)
					mon = 0;	/* he died */
			} else miss("iron ball", mon);
		} else if(obj->olet == POTION_SYM && u.ulevel > rn2(15)) {
			potionhit(mon, obj);
			return(1);
		} else {
			if(cansee(bhitpos.x,bhitpos.y))
				pline("You miss %s.",monnam(mon));
			else pline("You miss it.");
			if(obj->olet == FOOD_SYM && mon->data->mlet == 'd')
				if(tamedog(mon,obj)) return(1);
			if(obj->olet == GEM_SYM && mon->data->mlet == 'u' &&
				!mon->mtame){
			 if(obj->dknown && objects[obj->otyp].oc_name_known){
			  if(objects[obj->otyp].g_val > 0){
			    u.uluck += 5;
			    goto valuable;
			  } else {
			    pline("%s is not interested in your junk.",
				Monnam(mon));
			  }
			 } else { /* value unknown to @ */
			    u.uluck++;
			valuable:
			    if(u.uluck > LUCKMAX)	/* dan@ut-ngp */
				u.uluck = LUCKMAX;
			    pline("%s graciously accepts your gift.",
				Monnam(mon));
			    mpickobj(mon, obj);
			    rloc(mon);
			    return(1);
			 }
			}
		}
	}
		/* the code following might become part of dropy() */
	if(obj->otyp == CRYSKNIFE)
		obj->otyp = WORM_TOOTH;
	obj->ox = bhitpos.x;
	obj->oy = bhitpos.y;
	obj->nobj = fobj;
	fobj = obj;
	/* prevent him from throwing articles to the exit and escaping */
	/* subfrombill(obj); */
	stackobj(obj);
	if(Punished && obj == uball &&
		(bhitpos.x != u.ux || bhitpos.y != u.uy)){
		freeobj(uchain);
		unpobj(uchain);
		if(u.utrap){
			if(u.utraptype == TT_PIT)
				pline("The ball pulls you out of the pit!");
			else {
			    long side =
				rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
			    pline("The ball pulls you out of the bear trap.");
			    pline("Your %s leg is severely damaged.",
				(side == LEFT_SIDE) ? "left" : "right");
			    set_wounded_legs(side, 500+rn2(1000));
			    losehp(2, "thrown ball");
			}
			u.utrap = 0;
		}
		unsee();
		uchain->nobj = fobj;
		fobj = uchain;
		u.ux = uchain->ox = bhitpos.x - u.dx;
		u.uy = uchain->oy = bhitpos.y - u.dy;
		setsee();
		(void) inshop();
	}
	if(cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x,bhitpos.y);
	return(1);
}
コード例 #8
0
ファイル: x_editor.cpp プロジェクト: Jaguar83/xargon
void design (void) {
	int updflag=0;
	int dx,dy,tempx,n;
	int lastcell=1;
	int tempint;
	int drawmode=0;
	char tempstr[32];
	char tempfname[32];
	char tempstr2[12];
	char tempstr3[32];
	int new_col=0;
	int bc_x=0,bc_y=0,bc_w=0,bc_h=0;		// Block copy x,y and width,height
	int tx,ty;

	disy=0;
	designflag=1;
	gamecount=0;
	tempstr[0]='\0';
	tempfname[0]='\0';
	setorigin();
	dx=objs[0].x/16;
	dy=objs[0].y/16;
	drawboard();
	fontcolor (&statvp,1,0);
	clearvp (&statvp);

	do {
		if (drawmode) {
			setboard (dx,dy,lastcell);
			drawcell (dx,dy);
			updflag=1;
			}
		fontcolor (&statvp,3,0);						// memory usage
		wprint (&statvp,248,1,2,"       ");
		ultoa (coreleft(),tempstr3,10);
		wprint (&statvp,290-(1+strlen(tempstr3)*6),1,2,tempstr3);
		tempstr3[0]='\0';

		fontcolor (&statvp,1,0);
		wprint (&statvp,248,21,2, "# objs: ");
		fontcolor (&statvp,3,0);
		wprint (&statvp,296,21,2,itoa(numobjs,tempstr2,10));

		drawshape (&gamevp,0x0100,dx*16+4,dy*16+4);
		do {
			checkctrl(0);
			} while ((dx1==0)&&(dy1==0)&&(key==0)&&(updflag==0));
		updflag=0;
		modboard(dx,dy);
		upd_objs(0);
		refresh(0);
		purgeobjs();
		if ((dx1!=0)||(dy1!=0)) {
			dx+=dx1*(1+fire1*(scrnxs/2-1));
			dy+=dy1*(1+fire1*(scrnys/2-1));
			if (dx<0) dx=0;
			if (dx>=boardxs) dx=boardxs-1;
			if (dy<0) dy=0;
			if (dy>=boardys) dy=boardys-1;
			if ((dx*16)<gamevp.vpox) {
				gamevp.vpox-=scrnxs*8;
				if (gamevp.vpox<0) gamevp.vpox=0;
				drawboard();
				};
			if ((dx*16)>=(gamevp.vpox+16*scrnxs-16)) {
				gamevp.vpox+=scrnxs*8;
				if (gamevp.vpox>=(16*(boardxs-scrnxs)+8))
					gamevp.vpox=16*(boardxs-scrnxs)+8;
				drawboard();
				};
			if ((16*dy)<gamevp.vpoy) {
				gamevp.vpoy-=scrnys*8;
				if (gamevp.vpoy<0) gamevp.vpoy=0;
				drawboard();
				};
			if ((16*dy)>=(gamevp.vpoy+16*(scrnys-1))) {
				gamevp.vpoy+=scrnys*8;
				if (gamevp.vpoy>=(16*(boardys-scrnys+1)))
					gamevp.vpoy=(boardys-scrnys+1)*16;
				drawboard();
				};
			};

		switch (toupper(key)) {
			case k_f1:					// Mark top left corner of block
				bc_x=dx; bc_y=dy; break;
			case k_f2:
				// Mark bottom right corner of block and copy
				//	block of tile numbers into temp array bc_array
				if(dx<bc_x) break;
					// 0-width or negative width rectangle	(can't do that)
				if(dy<bc_y) break;
					// 0-height or negative height rectangle (can't do that)
				bc_w=(dx-bc_x)+1; bc_h=(dy-bc_y)+1;
				if((bc_w>normxs)||(bc_h>normys)) {			// Too big!!
					bc_w=0; bc_h=0; break;
					};
				for(ty=0; ty<bc_h; ty++) {
					for(tx=0; tx<bc_w; tx++) {
						bc_array[(ty*bc_w)+tx]=board(bc_x+tx,bc_y+ty);
						};
					};	break;
			case k_f3:
				for(ty=0; ty<bc_h; ty++) {
					for(tx=0; tx<bc_w; tx++) {
						setboard(dx+tx, dy+ty, bc_array[(ty*bc_w)+tx]);
						};
					};	updflag=1; break;
			case k_f4:
				do {
					upd_colors (); gamecount++; checkctrl0(0);
					} while (key==0); break;
			case enter:
				clearvp (&statvp);
				wprint (&statvp,2,1,1,"Put:");
				fontcolor (&statvp,6,0);
				winput (&statvp,2,11,1,tempstr,16);
				strupr (tempstr);
				for (tempint=0; tempint<numinfotypes; tempint++) {
					if (strcmp (tempstr,info[tempint].na)==0) {
						lastcell=tempint;
						setboard(dx,dy,tempint);
						shm_want[(info[tempint].sh>>8)&0x3f]=1;
						shm_do(); break;
						};
					};
				updflag=1; break;
			case 9: drawmode=!drawmode; break;				// tab
			case 'K': lastcell=board(dx,dy); break;
			case ' ':
				setboard(dx,dy,lastcell);
				updflag=1; break;
			case 'I':
				pl.score=1000;
				printhi (1);
				pl.score=0; break;
			case 'V':
				if (pl.numinv==0) addinv (inv_hero);
				else {
					pl.numinv=0;
					init_inv();
					};
				pl.score=0;
				pl.level=0; break;
			case 'H':
				tempint=board(dx,dy);
				tempx=dx;
				while (board(tempx,dy)==tempint) {
					setboard(tempx,dy,lastcell);
					drawcell (tempx,dy);
					tempx--;
					};
				tempx=dx+1;
				while (board(tempx,dy)==tempint) {
					setboard(tempx,dy,lastcell);
					drawcell (tempx,dy);
					tempx++;
					}; break;
			case 'O': updflag=objdesign(dx,dy); break;	// Object Mgmt
			case 'U':
				for (n=0; n<numobjs; n++) {
//					if (((kindflags[objs[n].objkind]&f_inside)==0)&&
//						(objs[n].inside!=NULL)) {
//						objs[n].inside=NULL;
//						sound(240);
//						delay(500);
//						nosound();
//						};
					setobjsize (n);
					}; break;
			case 'Z':
				infname ("Clear?",tempfname);
				if (toupper(tempfname[0])=='Y') {
					init_brd();
					init_objs();
					drawboard();
					}; break;
			case 'L':
				infname ("Load:",tempfname);
				if (tempfname[0]!='\0') {
					loadboard (tempfname);
					setorigin();
					dx=objs[0].x/16; dy=objs[0].y/16;
					drawboard();
					}; break;
			case 'Y':												// Disalign Y
				clearvp (&statvp);
				wprint (&statvp,2,1,1,"Dis Y:");
				itoa (disy,tempstr,10);
				winput (&statvp,2,11,1,tempstr,16);
				disy=atoi (tempstr);
				strupr (tempstr); break;
			case 'N':
				infname ("New board?",tempfname);
				if (toupper (tempfname[0])=='Y') {
					zapobjs();
					init_brd();
					}; break;
			case 'S':
				infname ("Save:",tempfname);
				if (tempfname[0]!='\0') saveboard (tempfname); break;
			case 'C':
				clearvp (&statvp);
				wprint (&statvp,2,1,1,"New Color:");
				fontcolor (&statvp,6,0);
				itoa (new_col,tempstr,10);
				winput (&statvp,2,11,1,tempstr,16);
				new_col=atoi (tempstr);

				switch (new_col) {
					case 0: setcolor (250,0,0,0);
						setcolor (251,0,0,0); break;				// reset all
					case 1: setcolor (251,0,0,0); break;		// reset #251
					case 2: setcolor (250,0,0,32);		 		// dk. blue sky
						setcolor (251,0,0,32); break;
					case 3:												// lt. blue sky
						setcolor (176,8,16,25); setcolor (177,8,20,29);
						setcolor (178,12,24,33); setcolor (179,16,28,41);
						setcolor (180,20,32,45); setcolor (181,24,40,49);
						setcolor (182,28,44,57); setcolor (183,36,48,60);
						setcolor (250,36,48,60); setcolor (251,36,48,60); break;
					case 4:												// yellow sky
						setcolor (176,32,0,0); setcolor (177,40,0,0);
						setcolor (178,52,0,0); setcolor (179,60,0,0);
						setcolor (180,60,28,0); setcolor (181,60,40,0);
						setcolor (182,60,52,0); setcolor (183,60,60,0);
						setcolor (250,60,60,0);	setcolor (251,60,60,0); break;
					case 5:												// emerald sky
						setcolor (176,0,12,12); setcolor (177,0,18,17);
						setcolor (178,0,25,23); setcolor (179,0,32,27);
						setcolor (180,0,39,32); setcolor (181,0,46,35);
						setcolor (182,0,53,38); setcolor (183,0,60,40);
						setcolor (250,0,60,40); setcolor (251,0,60,40); break;
					case 6: setcolor (250,32,32,24);				// olive green
						setcolor (251,32,32,24); break;
					case 7:												// violet sky
						setcolor (176,13,5,22); setcolor (177,18,8,27);
						setcolor (178,23,13,33); setcolor (179,29,19,39);
						setcolor (180,35,25,45); setcolor (181,42,32,51);
						setcolor (182,49,40,57); setcolor (183,57,50,63);
						setcolor (250,57,50,63); setcolor (251,57,50,63); break;
					case 8: setcolor (250,23,23,23);				// factory grey
						setcolor (251,23,23,23); break;
					case 9: setcolor (250,12,23,63);		 		// royal blue
						setcolor (251,12,23,63); break;
					case 10: setcolor (250,20,20,23);			// factory grey v3
						setcolor (251,20,20,23); break;
					};
			};
		} while (key!=escape);
コード例 #9
0
ファイル: hack.u_init.c プロジェクト: AhmadTux/DragonFlyBSD
static void
ini_inv(struct trobj *trop)
{
	struct obj *obj;

	while (trop->trolet) {
		obj = mkobj(trop->trolet);
		obj->known = trop->trknown;
		/* not obj->dknown = 1; - let him look at it at least once */
		obj->cursed = 0;
		if (obj->olet == WEAPON_SYM) {
			obj->quan = trop->trquan;
			trop->trquan = 1;
		}
		if (trop->trspe != UNDEF_SPE)
			obj->spe = trop->trspe;
		if (trop->trotyp != UNDEF_TYP)
			obj->otyp = trop->trotyp;
		else if (obj->otyp == WAN_WISHING)	/* gitpyr!robert */
			obj->otyp = WAN_DEATH;
		obj->owt = weight(obj);	/* defined after setting otyp+quan */
		obj = addinv(obj);
		if (obj->olet == ARMOR_SYM) {
			switch (obj->otyp) {
			case SHIELD:
				if (!uarms)
					setworn(obj, W_ARMS);
				break;
			case HELMET:
				if (!uarmh)
					setworn(obj, W_ARMH);
				break;
			case PAIR_OF_GLOVES:
				if (!uarmg)
					setworn(obj, W_ARMG);
				break;
			case ELVEN_CLOAK:
				if (!uarm2)
					setworn(obj, W_ARM);
				break;
			default:
				if (!uarm)
					setworn(obj, W_ARM);
			}
		}
		if (obj->olet == WEAPON_SYM)
			if (!uwep)
				setuwep(obj);
#ifndef PYRAMID_BUG
		if (--trop->trquan)	/* make a similar object */
			continue;
#else
		if (trop->trquan) {	/* check if zero first */
			--trop->trquan;
			if (trop->trquan)
				continue;	/* make a similar object */
		}
#endif /* PYRAMID_BUG */
		trop++;
	}
}