示例#1
0
/*
 * Open the drawbridge located at x,y
 */
void open_drawbridge(int x, int y)
{
	struct rm *loc1, *loc2;
	struct trap *t;
	int x2, y2;

	loc1 = &level->locations[x][y];
	if (loc1->typ != DRAWBRIDGE_UP) return;
	x2 = x; y2 = y;
	get_wall_for_db(&x2,&y2);
	if (cansee(x,y) || cansee(x2,y2))
		pline("You see a drawbridge %s down!",
		    (distu(x2,y2) < distu(x,y)) ? "going" : "coming");
	loc1->typ = DRAWBRIDGE_DOWN;
	loc2 = &level->locations[x2][y2];
	loc2->typ = DOOR;
	loc2->doormask = D_NODOOR;
	set_entity(x, y, &(occupants[0]));
	set_entity(x2, y2, &(occupants[1]));
	do_entity(&(occupants[0]));		/* do set_entity after first */
	set_entity(x2, y2, &(occupants[1]));	/* do_entity for worm tails */
	do_entity(&(occupants[1]));
	revive_nasty(x,y,NULL);
	delallobj(x, y);
	if ((t = t_at(level, x, y)) != 0) deltrap(level, t);
	if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t);
	newsym(x, y);
	newsym(x2, y2);
	unblock_point(x2,y2);	/* vision */
	if (Is_stronghold(&u.uz)) u.uevent.uopened_dbridge = TRUE;
}
示例#2
0
/* release the objects the killed animal has stolen */
void
relobj(struct monst *mtmp, int show)
{
	struct obj *otmp, *otmp2;

	for(otmp = mtmp->minvent; otmp; otmp = otmp2){
		otmp->ox = mtmp->mx;
		otmp->oy = mtmp->my;
		otmp2 = otmp->nobj;
		otmp->nobj = fobj;
		fobj = otmp;
		stackobj(fobj);
		if(show & cansee(mtmp->mx,mtmp->my))
			atl(otmp->ox,otmp->oy,otmp->olet);
	}
	mtmp->minvent = (struct obj *) 0;
	if(mtmp->mgold || mtmp->data->mlet == 'L') {
		long tmp;

		tmp = (mtmp->mgold > 10000) ? 10000 : mtmp->mgold;
		mkgold((long)(tmp + d(dlevel,30)), mtmp->mx, mtmp->my);
		if(show & cansee(mtmp->mx,mtmp->my))
			atl(mtmp->mx,mtmp->my,'$');
	}
}
示例#3
0
/*
 * Close the drawbridge located at x,y.
 * Returns TRUE if the drawbridge was closed, FALSE otherwise.
 */
boolean close_drawbridge(int x, int y)
{
	struct rm *loc1, *loc2;
	struct monst *m;
	struct trap *t;
	int x2, y2;

	loc1 = &level->locations[x][y];
	if (loc1->typ != DRAWBRIDGE_DOWN) return FALSE;
	/* A huge monster will block the drawbridge. */
	if ((m = m_at(level, x, y)) && hugemonst(m->data)) {
	    pline("%s blocks the drawbridge with %s weight!",
		  canseemon(level, m) ? Amonnam(m) : "Something",
		  canseemon(level, m) ? mhis(level, m) : "its");
	    return FALSE;
	}
	if (rn2(5) == 0) {
	    pline("The mechanism seems to have something stuck in it and won't close.");
	    return FALSE;
	}
	x2 = x; y2 = y;
	get_wall_for_db(&x2,&y2);
	if (cansee(x,y) || cansee(x2,y2))
		pline("You see a drawbridge %s up!",
		    (((u.ux == x || u.uy == y) && !Underwater) ||
		     distu(x2,y2) < distu(x,y)) ? "coming" : "going");
	loc1->typ = DRAWBRIDGE_UP;
	loc2 = &level->locations[x2][y2];
	loc2->typ = DBWALL;
	switch (loc1->drawbridgemask & DB_DIR) {
		case DB_NORTH:
		case DB_SOUTH:
			loc2->horizontal = TRUE;
			break;
		case DB_WEST:
		case DB_EAST:
			loc2->horizontal = FALSE;
			break;
	}
	loc2->wall_info = W_NONDIGGABLE;
	set_entity(x, y, &(occupants[0]));
	set_entity(x2, y2, &(occupants[1]));
	do_entity(&(occupants[0]));		/* Do set_entity after first */
	set_entity(x2, y2, &(occupants[1]));	/* do_entity for worm tail */
	do_entity(&(occupants[1]));
	if (OBJ_AT(x, y) && flags.soundok)
	    You_hear("smashing and crushing.");
	revive_nasty(x,y,NULL);
	revive_nasty(x2,y2,NULL);
	delallobj(x, y);
	delallobj(x2, y2);
	if ((t = t_at(level, x, y)) != 0) deltrap(level, t);
	if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t);
	newsym(x, y);
	newsym(x2, y2);
	block_point(x2,y2);	/* vision */
	return TRUE;
}
示例#4
0
文件: dbridge.c 项目: FredrIQ/nhfourk
/*
 * Close the drawbridge located at x,y
 */
void
close_drawbridge(int x, int y)
{
    struct rm *loc1, *loc2;
    struct trap *t;
    int x2, y2;

    loc1 = &level->locations[x][y];
    if (loc1->typ != DRAWBRIDGE_DOWN)
        return;
    x2 = x;
    y2 = y;
    get_wall_for_db(&x2, &y2);
    if (cansee(x, y) || cansee(x2, y2))
        pline("You see a drawbridge %s up!",
              (((u.ux == x || u.uy == y) && !Underwater) ||
               distu(x2, y2) < distu(x, y)) ? "coming" : "going");
    else if (canhear())
        pline("You hear chains rattling and gears turning.");
    loc1->typ = DRAWBRIDGE_UP;
    loc2 = &level->locations[x2][y2];
    loc2->typ = DBWALL;
    switch (loc1->drawbridgemask & DB_DIR) {
    case DB_NORTH:
    case DB_SOUTH:
        loc2->horizontal = TRUE;
        break;
    case DB_WEST:
    case DB_EAST:
        loc2->horizontal = FALSE;
        break;
    }
    loc2->wall_info = W_NONDIGGABLE;
    set_entity(x, y, &(occupants[0]));
    set_entity(x2, y2, &(occupants[1]));
    do_entity(&(occupants[0])); /* Do set_entity after first */
    set_entity(x2, y2, &(occupants[1]));        /* do_entity for worm tail */
    do_entity(&(occupants[1]));
    if (OBJ_AT(x, y))
        You_hear("smashing and crushing.");
    revive_nasty(x, y, NULL);
    revive_nasty(x2, y2, NULL);
    delallobj(x, y);
    delallobj(x2, y2);
    if ((t = t_at(level, x, y)) != 0)
        deltrap(level, t);
    if ((t = t_at(level, x2, y2)) != 0)
        deltrap(level, t);
    del_engr_at(level, x, y);
    del_engr_at(level, x2, y2);
    newsym(x, y);
    newsym(x2, y2);
    block_point(x2, y2);        /* vision */
}
示例#5
0
static boolean artifact_hit_drainlife(struct monst *magr, struct monst *mdef,
				      struct obj *otmp, int *dmgptr)
{
    boolean youattack = (magr == &youmonst);
    boolean youdefend = (mdef == &youmonst);
    boolean vis = (!youattack && magr && cansee(magr->mx, magr->my))
	|| (!youdefend && cansee(mdef->mx, mdef->my))
	|| (youattack && u.uswallow && mdef == u.ustuck && !Blind);
	
    if (!youdefend) {
	    if (vis) {
		if (otmp->oartifact == ART_STORMBRINGER)
		    pline("The %s blade draws the life from %s!",
			    hcolor("black"),
			    mon_nam(mdef));
		else
		    pline("%s draws the life from %s!",
			    The(distant_name(otmp, xname)),
			    mon_nam(mdef));
	    }
	    if (mdef->m_lev == 0) {
		*dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER;
	    } else {
		int drain = rnd(8);
		*dmgptr += drain;
		mdef->mhpmax -= drain;
		mdef->m_lev--;
		drain /= 2;
		if (drain) healup(drain, 0, FALSE, FALSE);
	    }
	    return vis;
    } else { /* youdefend */
	    int oldhpmax = u.uhpmax;

	    if (Blind)
		    pline("You feel an %s drain your life!",
			otmp->oartifact == ART_STORMBRINGER ?
			"unholy blade" : "object");
	    else if (otmp->oartifact == ART_STORMBRINGER)
		    pline("The %s blade drains your life!",
			    hcolor("black"));
	    else
		    pline("%s drains your life!",
			    The(distant_name(otmp, xname)));
	    losexp("life drainage");
	    if (magr && magr->mhp < magr->mhpmax) {
		magr->mhp += (oldhpmax - u.uhpmax)/2;
		if (magr->mhp > magr->mhpmax) magr->mhp = magr->mhpmax;
	    }
	    return TRUE;
    }
    return FALSE;
}
示例#6
0
/* release the objects the creature is carrying */
// bool is_pet         /* If true, pet should keep wielded/worn items */
void relobj ( struct monst *mtmp, int show, bool is_pet) {
    struct obj *otmp;
    int omx = mtmp->mx, omy = mtmp->my;
    struct obj *keepobj = 0;
    struct obj *wep = MON_WEP(mtmp);
    bool item1 = false, item2 = false;

    if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data))
        item1 = item2 = true;
    if (!tunnels(mtmp->data) || !needspick(mtmp->data))
        item1 = true;

    while ((otmp = mtmp->minvent) != 0) {
        obj_extract_self(otmp);
        /* special case: pick-axe and unicorn horn are non-worn */
        /* items that we also want pets to keep 1 of */
        /* (It is a coincidence that these can also be wielded.) */
        if (otmp->owornmask || otmp == wep ||
                ((!item1 && otmp->otyp == PICK_AXE) ||
                 (!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) {
            if (is_pet) { /* dont drop worn/wielded item */
                if (otmp->otyp == PICK_AXE)
                    item1 = true;
                if (otmp->otyp == UNICORN_HORN && !otmp->cursed)
                    item2 = true;
                otmp->nobj = keepobj;
                keepobj = otmp;
                continue;
            }
        }
        mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
    }

    /* put kept objects back */
    while ((otmp = keepobj) != (struct obj *)0) {
        keepobj = otmp->nobj;
        (void) add_to_minv(mtmp, otmp);
    }
    if (mtmp->mgold) {
        long g = mtmp->mgold;
        (void) mkgold(g, omx, omy);
        if (is_pet && cansee(omx, omy) && flags.verbose) {
            message_monster_int(MSG_M_DROPS_X_GOLD_PIECES, mtmp, g);
        }
        mtmp->mgold = 0L;
    }

    if (show & cansee(omx, omy))
        newsym(omx, omy);
}
示例#7
0
spaceShip* yarrAI :: getclosest()
{
	/// Look around and find the ship closest to this one in its vision
	///
	/// Returns a ship pointer on success,
	/// returns a NULL POINTER on failure

	SPfloat closest_dist = view_dist + 1; // higher than vision to ensure we see things
	spaceShip* closest_ship = NULL;

	vector<spaceShip*>::iterator ships_i;
	for (ships_i = puppet->sector->ships.begin() ;
		ships_i != puppet->sector->ships.end() ;
		ships_i++)
	{
			if( (*ships_i)->team_id != puppet->team_id )
				if( cansee((*ships_i)->pos))
				{
					SPfloat this_dist = puppet->pos.dist( (*ships_i)->pos );
					
					if( this_dist < closest_dist)
						closest_ship = (*ships_i);
				}
	}

	return closest_ship;
}
示例#8
0
/* drop one object taken from a (possibly dead) monster's inventory */
static void mdrop_obj (struct monst *mon, struct obj *obj, bool verbosely) {
    int omx = mon->mx, omy = mon->my;

    if (obj->owornmask) {
        /* perform worn item handling if the monster is still alive */
        if (mon->mhp > 0) {
            mon->misc_worn_check &= ~obj->owornmask;
            update_mon_intrinsics(mon, obj, false, true);
            /* obj_no_longer_held(obj); -- done by place_object */
            if (obj->owornmask & W_WEP) setmnotwielded(mon, obj);
            /* don't charge for an owned saddle on dead steed */
        } else if (mon->mtame && (obj->owornmask & W_SADDLE) &&
                !obj->unpaid && costly_spot(omx, omy)) {
            obj->no_charge = 1;
        }
        obj->owornmask = 0L;
    }
    if (verbosely && cansee(omx, omy)) {
        message_monster_object(MSG_M_DROPS_O, mon, obj);
    }
    if (!flooreffects(obj, omx, omy, "fall")) {
        place_object(obj, omx, omy);
        stackobj(obj);
    }
}
示例#9
0
/* release the objects the creature is carrying */
void
relobj(struct monst *mtmp, int show, boolean is_pet)
{       /* If true, pet should keep wielded/worn items */
    struct obj *otmp;
    int omx = mtmp->mx, omy = mtmp->my;
    struct obj *keepobj = 0;
    struct pet_weapons p;
    initialize_pet_weapons(mtmp, &p);

    while ((otmp = mtmp->minvent) != 0) {
        obj_extract_self(otmp);

        if (is_pet && pet_wants_object(&p, otmp)) {
            otmp->nobj = keepobj;
            keepobj = otmp;
            continue;
        }

        if (otmp->owornmask & W_MASK(os_wep))
            setmnotwielded(mtmp, otmp);
        mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
    }

    /* put kept objects back */
    while ((otmp = keepobj) != NULL) {
        keepobj = otmp->nobj;
        add_to_minv(mtmp, otmp);
    }

    if (show & cansee(omx, omy) && mtmp->dlevel == level)
        newsym(omx, omy);
}
示例#10
0
void
worm_move(struct monst *mtmp)
{
	struct wseg *wtmp, *whd;
	int tmp = mtmp->wormno;

	wtmp = newseg();
	wtmp->wx = mtmp->mx;
	wtmp->wy = mtmp->my;
	wtmp->nseg = 0;
	(whd = wheads[tmp])->nseg = wtmp;
	wheads[tmp] = wtmp;
	if (cansee(whd->wx, whd->wy)) {
		unpmon(mtmp);
		atl(whd->wx, whd->wy, '~');
		whd->wdispl = 1;
	} else
		whd->wdispl = 0;
	if (wgrowtime[tmp] <= moves) {
		if (!wgrowtime[tmp])
			wgrowtime[tmp] = moves + rnd(5);
		else
			wgrowtime[tmp] += 2 + rnd(15);
		mtmp->mhpmax += 3;
		mtmp->mhp += 3;
		return;
	}
	whd = wsegs[tmp];
	wsegs[tmp] = whd->nseg;
	remseg(whd);
}
示例#11
0
int
tamedog(struct monst *mtmp, struct obj *obj)
{
	struct monst *mtmp2;

	if(flags.moonphase == FULL_MOON && night() && rn2(6))
		return(0);

	/* If we cannot tame him, at least he's no longer afraid. */
	mtmp->mflee = 0;
	mtmp->mfleetim = 0;
	if(mtmp->mtame || mtmp->mfroz ||
#ifndef NOWORM
		mtmp->wormno ||
#endif /* NOWORM */
		mtmp->isshk || mtmp->isgd || strchr(" &@12", mtmp->data->mlet))
		return(0); /* no tame long worms? */
	if(obj) {
		if(dogfood(obj) >= MANFOOD) return(0);
		if(cansee(mtmp->mx,mtmp->my)){
			pline("%s devours the %s.", Monnam(mtmp),
				objects[obj->otyp].oc_name);
		}
		obfree(obj, (struct obj *) 0);
	}
	mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth);
	*mtmp2 = *mtmp;
	mtmp2->mxlth = sizeof(struct edog);
	if(mtmp->mnamelth)
		(void) strlcpy(NAME(mtmp2), NAME(mtmp), mtmp2->mnamelth);
	initedog(mtmp2);
	replmon(mtmp,mtmp2);
	return(1);
}
示例#12
0
/* drop one object taken from a (possibly dead) monster's inventory */
static void mdrop_obj(struct monst *mon, struct obj *obj, boolean verbosely)
{
    int omx = mon->mx, omy = mon->my;

    if (obj->owornmask) {
	/* perform worn item handling if the monster is still alive */
	if (mon->mhp > 0) {
	    mon->misc_worn_check &= ~obj->owornmask;
	    update_mon_intrinsics(level, mon, obj, FALSE, TRUE);
	 /* obj_no_longer_held(obj); -- done by place_object */
	    if (obj->owornmask & W_WEP) setmnotwielded(mon, obj);
	/* don't charge for an owned saddle on dead steed */
	} else if (mon->mtame && (obj->owornmask & W_SADDLE) && 
		!obj->unpaid && costly_spot(omx, omy)) {
	    obj->no_charge = 1;
	}
	obj->owornmask = 0L;
    }
    if (verbosely && cansee(omx, omy))
	pline("%s drops %s.", Monnam(mon), distant_name(obj, doname));
    if (!flooreffects(obj, omx, omy, "fall")) {
	place_object(obj, level, omx, omy);
	stackobj(obj);
    }
}
void
fall(THING *obj, int pr)
{
    PLACE *pp;
    coord fpos;

    if (fallpos(&obj->o_pos, &fpos))
    {
	pp = INDEX(fpos.y, fpos.x);
	pp->p_ch = obj->o_type;
	obj->o_pos = fpos;
	if (cansee(fpos.y, fpos.x))
	{
	    if (pp->p_monst != NULL)
		pp->p_monst->t_oldch = obj->o_type;
	    else
		mvaddch(fpos.y, fpos.x, obj->o_type);
	}
	attach(lvl_obj, obj);
	return;
    }
    if (pr)
    {
	if (has_hit)
	{
	    endmsg();
	    has_hit = FALSE;
	}
	msg("the %s vanishes as it hits the ground",
	    weap_info[obj->o_which].oi_name);
    }
    discard(obj);
}
示例#14
0
文件: hack.zap.c 项目: blakeney/slack
void
hit(const char *str, struct monst *mtmp, const char *force)
	/* force: usually either "." or "!" */
{
	if(!cansee(mtmp->mx,mtmp->my)) pline("The %s hits it.", str);
	else pline("The %s hits %s%s", str, monnam(mtmp), force);
}
示例#15
0
int dochugw(struct monst *mtmp)
{
    int x = mtmp->mx;
    int y = mtmp->my;
    int d = dochug(mtmp);
    int dd;

    /* Monster still alive */
    if(d == 0) {
        if(Warning != 0) {
            if(mtmp->mpeaceful == 0) {
                dd = dist(mtmp->mx, mtmp->my);
                if(dd < dist(x,y)) {
                    if(dd < 100) {
                        if((cansee(mtmp->mx, mtmp->my) == 0)
                           || ((mtmp->minvis != 0) && (See_invisible == 0))) {
                            if(mtmp->data->mlevel > warnlevel) {
                                warnlevel = mtmp->data->mlevel;
                            }
                        }
                    }
                }
            }
        }
    }

    return d;
}
/*
 * do the actual motion on the screen done by an object traveling
 * across the room
 */
void
do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp)
{

	/*
	* Come fly with us ...
	*/
	obj->o_pos = tp->t_pos ;
	for ( ; ;) {
		register int ch ;
		/*
		* Erase the old one
		*/
		if (!ce(obj->o_pos, tp->t_pos) &&
		    cansee(unc(obj->o_pos)) &&
		    mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') {
			mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, show(obj->o_pos.y, obj->o_pos.x)) ;
		}
		/*
		* Get the new position
		*/
		obj->o_pos.y += ydelta ;
		obj->o_pos.x += xdelta ;
		if (shoot_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR && !ce(obj->o_pos, hero)) {
			/*
			* It hasn't hit anything yet, so display it
			* If it alright.
			*/
			if (cansee(unc(obj->o_pos)) &&
			    mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') {
				mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, obj->o_type) ;
				draw(cw) ;
			}
			continue ;
		}
		/* don't want objects to end up in wall, or fall through
		 * so back it up.
		 */
		if (ch == '|' || ch == '-' || ch == SECRETDOOR || ch == ' ')
			{
			obj->o_pos.y -= ydelta ;
			obj->o_pos.x -= xdelta ;
			}
			
		break ;
	}
}
void
runners(void)
{
    register struct linked_list *item;
    register struct thing *tp = NULL;

	for(item = mlist; item != NULL; item = next(item)) {
		tp = THINGPTR(item);
		turn_on(*tp, ISREADY);
	}

	for (;;) {
		
	for (item = mlist; item != NULL; item = next(item)) {
		tp = THINGPTR(item);

		if (on(*tp, ISREADY))
			break;
	}

	if (item == NULL)
		break;

	turn_off(*tp, ISREADY);

	if (on(*tp, ISHELD) && rnd(tp->t_stats.s_lvl) > 11) {
	    turn_off(*tp, ISHELD);
	    turn_on(*tp, ISRUN);
	    turn_off(*tp, ISDISGUISE);
	    tp->t_dest = &hero;
	    if (tp->t_stats.s_hpt < tp->maxstats.s_hpt)
		turn_on(*tp, ISFLEE);
	    if (cansee(tp->t_pos.y, tp->t_pos.x))
		msg("The %s breaks free from the hold spell!!!", 
			monsters[tp->t_index].m_name);
	}
	if (off(*tp, ISHELD) && on(*tp, ISRUN)) {
	    register int flee;

	    /* Should monster run away? */
	    flee = (on(*tp, ISFLEE) ||
		((tp->t_dest == &hero) && on(player, ISINWALL) &&
		 off(*tp, CANINWALL)));

	    if (off(*tp, ISSLOW) || tp->t_turn) {
		doctor(tp);
		do_chase(tp, flee);
	    }
	    if (off(*tp, ISDEAD) && on(*tp, ISHASTE)) {
		doctor(tp);
		do_chase(tp, flee);
	    }
	    if (off(*tp, ISDEAD)) {
		tp->t_turn ^= TRUE;
		tp->t_wasshot = FALSE;	/* Not shot anymore */
	    }
	}
    }
}
coord
do_motion(int ob, int ydelta, int xdelta, struct thing *tp)
{
    coord pos;
    /* Come fly with us ... */

    pos = tp->t_pos;

    for (;;)
    {
        int ch;

        /* Erase the old one */

        if (!ce(pos, tp->t_pos) &&
            cansee(pos.y, pos.x) &&
            mvwinch(cw, pos.y, pos.x) != ' ')
        {
            mvwaddch(cw, pos.y, pos.x, show(pos.y, pos.x));
        }

        /* Get the new position */

        pos.y += ydelta;
        pos.x += xdelta;

        if (shoot_ok(ch = winat(pos.y, pos.x)) &&
            ch != DOOR && !ce(pos, hero))
        {
            /* It hasn't hit anything yet, so display it if it alright. */

            if (cansee(pos.y, pos.x) &&
                mvwinch(cw, pos.y, pos.x) != ' ')
            {
                mvwaddch(cw, pos.y, pos.x, ob);
                wrefresh(cw);
            }
			
            continue;

        }
        break;
    }

    return(pos);
}
示例#19
0
/*
 * visuals:
 *	change the characters for the player
 */
visuals()
{
    register THING *tp;
    register bool seemonst;

    if (!after)
	return;
    /*
     * change the things
     */
    for (tp = lvl_obj; tp != NULL; tp = next(tp))
	if (cansee(tp->o_pos.y, tp->o_pos.x)) {
        PC_GFX_PASSGE_COLOR(tp->o_pos.y, tp->o_pos.x, 0, 0x70);
	    mvaddrawch(tp->o_pos.y, tp->o_pos.x, rnd_thing());
        PC_GFX_NOCOLOR(0x70);
    }

    /*
     * change the stairs
     */
    if (!seenstairs && cansee(stairs.y, stairs.x)) {
        PC_GFX_PASSGE_COLOR(stairs.y, stairs.x, 0, 0x70);
        mvaddrawch(stairs.y, stairs.x, rnd_thing());
        PC_GFX_NOCOLOR(0x70);
    }

    /*
     * change the monsters
     */
    seemonst = on(player, SEEMONST);
    for (tp = mlist; tp != NULL; tp = next(tp))
	if (see_monst(tp)){
        PC_GFX_PASSGE_COLOR(tp->t_pos.y, tp->t_pos.x, 0, 0x70);
	    if (tp->t_type == 'M' && tp->t_disguise != 'M')
		mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd_thing());
	    else
		mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd(26) + 'A');
        PC_GFX_NOCOLOR(0x70);
	}
	else if (seemonst)
	{
	    standout();
	    mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd(26) + 'A');
	    standend();
	}
}
示例#20
0
void
miss(const char *str, struct monst *mtmp)
{
	if (!cansee(mtmp->mx, mtmp->my))
		pline("The %s misses it.", str);
	else
		pline("The %s misses %s.", str, monnam(mtmp));
}
示例#21
0
/* release the objects the creature is carrying */
void
relobj(struct monst *mtmp, int show, boolean is_pet)
{       /* If true, pet should keep wielded/worn items */
    struct obj *otmp;
    int omx = mtmp->mx, omy = mtmp->my;
    struct obj *keepobj = 0;
    struct obj *wep = MON_WEP(mtmp), *hwep = attacktype(mtmp->data, AT_WEAP)
        ? select_hwep(mtmp) : (struct obj *)0, *proj =
        attacktype(mtmp->data, AT_WEAP)
        ? select_rwep(mtmp) : (struct obj *)0, *rwep;
    boolean item1 = FALSE, item2 = FALSE;

    rwep = attacktype(mtmp->data, AT_WEAP) ? propellor : &zeroobj;


    if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data))
        item1 = item2 = TRUE;
    if (!tunnels(mtmp->data) || !needspick(mtmp->data))
        item1 = TRUE;

    while ((otmp = mtmp->minvent) != 0) {
        obj_extract_self(otmp);
        /* special case: pick-axe and unicorn horn are non-worn */
        /* items that we also want pets to keep 1 of */
        /* (It is a coincidence that these can also be wielded.) */
        if (otmp->owornmask || otmp == wep || otmp == hwep || otmp == rwep ||
            otmp == proj ||
            would_prefer_hwep(mtmp, otmp) ||  /* cursed item in hand? */
            would_prefer_rwep(mtmp, otmp) || could_use_item(mtmp, otmp) ||
            ((!rwep || rwep == &zeroobj) &&
             (is_ammo(otmp) || is_launcher(otmp))) ||
            (rwep && rwep != &zeroobj && ammo_and_launcher(otmp, rwep)) ||
            ((!item1 && otmp->otyp == PICK_AXE) ||
             (!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) {
            if (is_pet) {       /* dont drop worn/wielded item */
                if (otmp->otyp == PICK_AXE)
                    item1 = TRUE;
                if (otmp->otyp == UNICORN_HORN && !otmp->cursed)
                    item2 = TRUE;
                otmp->nobj = keepobj;
                keepobj = otmp;
                continue;
            }
        }
        if (otmp == wep)
            setmnotwielded(mtmp, otmp);
        mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
    }

    /* put kept objects back */
    while ((otmp = keepobj) != NULL) {
        keepobj = otmp->nobj;
        add_to_minv(mtmp, otmp);
    }

    if (show & cansee(omx, omy))
        newsym(omx, omy);
}
示例#22
0
/*
 * come_down:
 *	Take the hero down off her acid trip.
 */
come_down()
{
    register THING *tp;
    register bool seemonst;

    if (!on(player, ISTrip))
	return;

    kill_daemon(visuals);

    if (on(player, ISBLIND))
	return;

    /*
     * undo the things
     */
    for (tp = lvl_obj; tp != NULL; tp = next(tp))
	if (cansee(tp->o_pos.y, tp->o_pos.x))
	    mvaddrawch(tp->o_pos.y, tp->o_pos.x, tp->o_type);

    /*
     * undo the stairs
     */
    if (seenstairs)
	mvaddrawch(stairs.y, stairs.x, STAIRS);

    /*
     * undo the monsters
     */
    seemonst = on(player, SEEMONST);
    for (tp = mlist; tp != NULL; tp = next(tp))
	if (cansee(tp->t_pos.y, tp->t_pos.x))
	    if (!on(*tp, ISINVIS) || on(player, CANSEE))
		mvaddrawch(tp->t_pos.y, tp->t_pos.x, tp->t_disguise);
	    else
		mvaddrawch(tp->t_pos.y, tp->t_pos.x, chat(tp->t_pos.y, tp->t_pos.x));
	else if (seemonst)
	{
	    standout();
	    mvaddrawch(tp->t_pos.y, tp->t_pos.x, tp->t_type);
	    standend();
	}
    player.t_flags &= ~ISTrip;
    msg("Everything looks SO boring now.");
}
示例#23
0
int do_mname(void)
{
	char buf[BUFSZ];
	coord cc;
	int cx,cy;
	struct monst *mtmp;
	char qbuf[QBUFSZ];

	if (Hallucination) {
		pline("You would never recognize it anyway.");
		return 0;
	}
	cc.x = u.ux;
	cc.y = u.uy;
	if (getpos(&cc, FALSE, "the monster you want to name") < 0 ||
			(cx = cc.x) < 0)
		return 0;
	cy = cc.y;

	if (cx == u.ux && cy == u.uy) {
	    if (u.usteed && canspotmon(u.usteed))
		mtmp = u.usteed;
	    else {
		pline("This %s creature is called %s and cannot be renamed.",
		ACURR(A_CHA) > 14 ?
		(flags.female ? "beautiful" : "handsome") :
		"ugly",
		plname);
		return 0;
	    }
	} else
	    mtmp = m_at(level, cx, cy);

	if (!mtmp || (!sensemon(mtmp) &&
			(!(cansee(cx,cy) || see_with_infrared(mtmp)) || mtmp->mundetected
			|| mtmp->m_ap_type == M_AP_FURNITURE
			|| mtmp->m_ap_type == M_AP_OBJECT
			|| (mtmp->minvis && !See_invisible)))) {
		pline("I see no monster there.");
		return 0;
	}
	/* special case similar to the one in lookat() */
	distant_monnam(mtmp, ARTICLE_THE, buf);
	sprintf(qbuf, "What do you want to call %s?", buf);
	getlin(qbuf,buf);
	if (!*buf || *buf == '\033') return 0;
	/* strip leading and trailing spaces; unnames monster if all spaces */
	mungspaces(buf);

	if (mtmp->data->geno & G_UNIQ) {
	    distant_monnam(mtmp, ARTICLE_THE, buf);
	    *buf = highc(*buf);
	    pline("%s doesn't like being called names!", buf);
	} else
	    christen_monst(mtmp, buf);
	return 0;
}
示例#24
0
boolean
inside_gas_cloud(void *p1, void *p2)
{
    struct region *reg;
    struct monst *mtmp;
    long dam;

    reg = (struct region *)p1;
    dam = (long)reg->arg;
    if (p2 == NULL) {   /* This means *YOU* Bozo! */
        if (nonliving(youmonst.data) || u.uinvulnerable)
            return FALSE;
        /* If you will unblind next turn, extend the blindness so that you do
         * not get a "You can see again!" message immediately before being
         * blinded again. */
        if (!Blind || Blinded == 1)
            make_blinded(2L, FALSE);
        if (Breathless)
            return FALSE;
        if (!Poison_resistance) {
            pline("Something is burning your %s!", makeplural(body_part(LUNG)));
            pline("You cough and spit blood!");
            losehp(rnd(dam) + 5, killer_msg(DIED, "a gas cloud"));
            return FALSE;
        } else {
            pline("You cough!");
            return FALSE;
        }
    } else {    /* A monster is inside the cloud */
        mtmp = (struct monst *)p2;

        /* Non living and non breathing monsters are not concerned */
        if (!nonliving(mtmp->data) && !breathless(mtmp->data)) {
            if (cansee(mtmp->mx, mtmp->my))
                pline("%s coughs!", Monnam(mtmp));
            setmangry(mtmp);
            if (haseyes(mtmp->data) && mtmp->mcansee) {
                mtmp->mblinded = 1;
                mtmp->mcansee = 0;
            }
            if (resists_poison(mtmp))
                return FALSE;
            mtmp->mhp -= rnd(dam) + 5;
            if (mtmp->mhp <= 0) {
                if (heros_fault(reg))
                    killed(mtmp);
                else
                    monkilled(mtmp, "gas cloud", AD_DRST);
                if (DEADMONSTER(mtmp)) {   /* not lifesaved */
                    return TRUE;
                }
            }
        }
    }
    return FALSE;       /* Monster is still alive */
}
示例#25
0
文件: worm.c 项目: DanielT/NitroHack
/*  worm_known()
 *
 *  Is any segment of this worm in viewing range?  Note: caller must check
 *  invisibility and telepathy (which should only show the head anyway).
 *  Mostly used in the canseemon() macro.
 */
boolean worm_known(const struct monst *worm)
{
    struct wseg *curr = level->wtails[worm->wormno];

    while (curr) {
	if (cansee(curr->wx,curr->wy)) return TRUE;
	curr = curr->nseg;
    }
    return FALSE;
}
示例#26
0
/* no texts here! */
void
fracture_rock(struct obj *obj)
{
	obj->otyp = ROCK;
	obj->quan = 7 + rn2(60);
	obj->owt = weight(obj);
	obj->olet = WEAPON_SYM;
	if (cansee(obj->ox, obj->oy))
		prl(obj->ox, obj->oy);
}
void
do_motion(THING *obj, int ydelta, int xdelta)
{
    int ch;

    /*
     * Come fly with us ...
     */
    obj->o_pos = hero;
    for (;;)
    {
	/*
	 * Erase the old one
	 */
	if (!ce(obj->o_pos, hero) && cansee(unc(obj->o_pos)) && !terse)
	{
	    ch = chat(obj->o_pos.y, obj->o_pos.x);
	    if (ch == FLOOR && !show_floor())
		ch = ' ';
	    mvaddch(obj->o_pos.y, obj->o_pos.x, ch);
	}
	/*
	 * Get the new position
	 */
	obj->o_pos.y += ydelta;
	obj->o_pos.x += xdelta;
	if (step_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR)
	{
	    /*
	     * It hasn't hit anything yet, so display it
	     * If it alright.
	     */
	    if (cansee(unc(obj->o_pos)) && !terse)
	    {
		mvaddch(obj->o_pos.y, obj->o_pos.x, obj->o_type);
		refresh();
	    }
	    continue;
	}
	break;
    }
}
示例#28
0
文件: hack.zap.c 项目: blakeney/slack
void
fracture_rock(struct obj *obj)	/* fractured by pick-axe or wand of striking */
				   /* no texts here! */
{
	obj->otyp = ROCK;
	obj->quan = 7 + rn2(60);
	obj->owt = weight(obj);
	obj->olet = WEAPON_SYM;
	if(cansee(obj->ox,obj->oy))
		prl(obj->ox,obj->oy);
}
示例#29
0
/*
 * This routine has the enemy ship turn its strongest shield towards
 * the enemy and then accelerate to 2/3 maximum speed.  (Always
 * returns 1)
 */
int
e_runaway(struct ship *sp, struct ship *fed)
{
	double bear;
	int strong;
	double strength;
	double temp;
	int sign = 1;
	float course = 0.0;
	int i;

	bear = bearing(sp->x, fed->x, sp->y, fed->y);
	/*
	 * Find the strongest shield
	 */
	strong = 0;
	strength = 0.;
	for (i=0; i< SHIELDS; i++) {
		temp = sp->shields[i].eff * sp->shields[i].drain *
		    (i == 0 ? SHIELD1 : 1.);
		if (temp > strength) {
			strong = i;
			strength = temp;
		}
	}
	switch (strong) {
		case 0:	course = bear;
			sign = -1;
			break;
		case 1:	course = rectify(bear - 90);
			sign = 1;
			break;
		case 2:	course = rectify(bear + 180);
			sign = 1;
			break;
		case 3:	course = rectify(bear + 90);
			sign = 1;
			break;
	}
	sp->target = NULL;
	sp->newcourse = course;
	sp->newwarp = 2 / 3 * sp->max_speed * sign;
	if (sp->newwarp > 1.0 && is_dead(sp, S_WARP))
		sp->newwarp = 0.99;
	if (cansee(sp) && syswork(fed, S_SENSOR))
		printf("%s: The %s is retreating.\n", helmsman, sp->name);
#ifdef TRACE
	if (trace) {
		printf("*** Runaway: Newcourse = %.2f\n", sp->newcourse);
		printf("*** Runaway: Newwarp = %.2f\n", sp->newwarp);
	}
#endif
	return 1;
}
示例#30
0
static order *monster_attack(unit * u, const unit * target)
{
    assert(u->region == target->region);
    assert(u->faction != target->faction);
    if (!cansee(u->faction, u->region, target, 0))
        return NULL;
    if (monster_is_waiting(u))
        return NULL;

    return create_order(K_ATTACK, u->faction->locale, "%i", target->no);
}