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);
}
Exemplo n.º 2
0
void
fall(struct linked_list *item, int pr)
{
    struct object *obj;
    struct room *rp;
    static coord fpos;

    obj = (struct object *) ldata(item);
    if (fallpos(&obj->o_pos, &fpos, TRUE))
    {
	mvaddrawch(fpos.y, fpos.x, obj->o_type);
	obj->o_pos = fpos;
	if ((rp = roomin(&hero)) != NULL && !(rp->r_flags & ISDARK))
	{
	    light(&hero);
	    mvwaddrawch(cw, hero.y, hero.x, PLAYER);
	}
	attach(lvl_obj, item);
	return;
    }
    if (pr)
        if (obj->o_type == WEAPON) /* BUGFUX: Identification trick */
            msg("Your %s vanishes as it hits the ground.", w_names[obj->o_which]);
        else
            msg("%s vanishes as it hits the ground.", inv_name(obj,TRUE));
    discard(item);
}
/*
 * fall:
 *	Drop an item someplace around here.
 */
int
fall(struct linked_list *item, int pr)
{
	register struct object *obj ;
	register struct room *rp ;
	static coord fpos ;
	int ret;

	obj = (struct object *) ldata(item) ;
	rp = roomin(&hero);
	if (obj->o_flags & CANRETURN) {
	    add_pack(item, TRUE);
	    return TRUE;
	}
	else if (fallpos(&obj->o_pos, &fpos, TRUE)) {
		if (obj->o_flags & CANBURN && ntraps + 1 < MAXTRAPS + MAXTRAPS) {
		    mvaddch(fpos.y, fpos.x, FIRETRAP);
		    traps[ntraps].tr_type = FIRETRAP;
		    traps[ntraps].tr_flags = ISFOUND;
		    traps[ntraps].tr_show = FIRETRAP;
		    traps[ntraps].tr_pos.y = fpos.y;
		    traps[ntraps++].tr_pos.x = fpos.x;
		    if (rp != NULL)
			rp->r_flags &= ~ISDARK;
			discard(item);
			ret = FALSE;
		}
		else {
		    mvaddch(fpos.y, fpos.x, obj->o_type) ;
		    obj->o_pos = fpos ;
		    attach(lvl_obj, item) ;
			ret = TRUE;
		}
		if (rp != NULL &&
		    (!(rp->r_flags & ISDARK) ||
		    (rp->r_flags & HASFIRE))) {
			light(&hero) ;
			mvwaddch(cw, hero.y, hero.x, PLAYER) ;
		}
		return ret;
	}
	if (pr) {
		if (obj->o_type == WEAPON)
			addmsg("The %s", weaps[obj->o_which]);
		else
			addmsg(inv_name(obj, TRUE));
		msg(" vanishes as it hits the ground.");
	}
	discard(item) ;
	return FALSE;
}
Exemplo n.º 4
0
void
missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp)
{
    struct object   *obj;
    struct linked_list  *nitem;

    if (item == NULL)   /* Get which thing we are hurling */
        return;

    obj = OBJPTR(item);

    if (!dropcheck(obj) || is_current(obj))
        return;

    /*
     * Get rid of the thing. If it is a non-multiple item object, or if
     * it is the last thing, just drop it. Otherwise, create a new item
     * with a count of one.
    */

    if (obj->o_count < 2)
    {
        if (tp->t_pack == pack)
            rem_pack(obj);
        else
            detach(tp->t_pack, item);
    }
    else
    {
        obj->o_count--;
        nitem = (struct linked_list *) new_item(sizeof *obj);
        obj = OBJPTR(nitem);
        *obj = *(OBJPTR(item));
        obj->o_count = 1;
        item = nitem;
    }

    switch (obj->o_type)
    {
        case ARTIFACT:
            has_artifact &= ~(1 << obj->o_which);
            break;

        case SCROLL:
            if (obj->o_which == S_SCARE && obj->o_flags & ISBLESSED)
                obj->o_flags &= ~ISBLESSED;
            else
                obj->o_flags |= ISCURSED;
    }

    updpack();
    obj->o_pos = do_motion(obj->o_type, ydelta, xdelta, tp);

    /*
     * AHA! Here it has hit something. If it is a wall or a door, or if
     * it misses (combat) the monster, put it on the floor
     */

    if (!hit_monster(obj->o_pos.y, obj->o_pos.x, obj, tp))
    {
        if (obj->o_type == WEAPON && obj->o_which == GRENADE)
        {
            hearmsg("BOOOM!");
            aggravate();

            if (ntraps + 1 < 2 * MAXTRAPS &&
                fallpos(obj->o_pos, &traps[ntraps].tr_pos))
            {
                mvaddch(traps[ntraps].tr_pos.y, traps[ntraps].tr_pos.x,
                    TRAPDOOR);
                traps[ntraps].tr_type = TRAPDOOR;
                traps[ntraps].tr_flags = ISFOUND;
                traps[ntraps].tr_show = TRAPDOOR;
                ntraps++;
                light(&hero);
            }
            discard(item);
        }
        else if (obj->o_flags & ISLOST)
        {
            if (obj->o_type == WEAPON)
                addmsg("The %s", weaps[obj->o_which].w_name);
            else
                addmsg(inv_name(obj, LOWERCASE));

            msg(" vanishes in a puff of greasy smoke.");
            discard(item);
        }
        else
        {
            fall(&player, item, TRUE, TRUE);

            if (obj->o_flags & CANRETURN)
                msg("You have %s.", inv_name(obj, LOWERCASE));
        }
    }
    else if (obj->o_flags & ISOWNED)
    {
        add_pack(item, NOMESSAGE);
        msg("You have %s.", inv_name(obj, LOWERCASE));
    }

    mvwaddch(cw, hero.y, hero.x, PLAYER);
}
Exemplo n.º 5
0
void
fall(struct thing *tp, struct linked_list *item, int pr, int player_owned)
{
    struct object *obj;
    struct room   *rp;
    coord   fpos;

    obj = OBJPTR(item);
    rp = roomin(tp->t_pos);

    if (player_owned && obj->o_flags & CANRETURN)
    {
        add_pack(item, NOMESSAGE);
        msg("You have %s.", inv_name(obj, LOWERCASE));
        return;
    }
    else if (fallpos(obj->o_pos, &fpos))
    {
        if (obj->o_flags & CANBURN && obj->o_type == WEAPON
            && obj->o_which == MOLOTOV
            && ntraps + 1 < 2 * MAXTRAPS)
        {
            mvaddch(fpos.y, fpos.x, FIRETRAP);
            traps[ntraps].tr_type  = FIRETRAP;
            traps[ntraps].tr_flags = ISFOUND;
            traps[ntraps].tr_show  = FIRETRAP;
            traps[ntraps].tr_pos   = fpos;
            ntraps++;

            if (rp != NULL)
                rp->r_flags &= ~ISDARK;
        }
        else
        {
            obj->o_pos = fpos;
            add_obj(item, fpos.y, fpos.x);
        }

        if (rp != NULL &&
            (!(rp->r_flags & ISDARK) ||
             (rp->r_flags & HASFIRE)))
        {
            light(&hero);
            mvwaddch(cw, hero.y, hero.x, PLAYER);
        }
        return;
    }

    /* get here only if there isn't a place to put it */
	
    if (pr)
    {
        if (cansee(obj->o_pos.y, obj->o_pos.x))
        {
            if (obj->o_type == WEAPON)
                addmsg("The %s", weaps[obj->o_which].w_name);
            else
                addmsg(inv_name(obj, LOWERCASE));

            msg(" vanishes as it hits the ground.");
        }
    }
    discard(item);
}
/*
 * missile:
 *	Fire a missile in a given direction
 */
void
missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp)
{
	register struct object *obj ;
	register struct linked_list *nitem ;

	/*
	* Get which thing we are hurling
	*/
	if (item == NULL) {
		return ;
	}
	obj = (struct object *) ldata(item) ;
	if (!dropcheck(obj) || is_current(obj)) {
		return ;
	}
	/*
	* Get rid of the thing. If it is a non-multiple item object, or
	* if it is the last thing, just drop it. Otherwise, create a new
	* item with a count of one.
	*/
	if (obj->o_count < 2) {
		detach(tp->t_pack, item) ;
		if (tp->t_pack == pack) {
			inpack-- ;
			freeletter(item);
		}
	} else {
		obj->o_count-- ;
		nitem = (struct linked_list *) new_item(sizeof *obj) ;
		obj = (struct object *) ldata(nitem) ;
		*obj = *((struct object *) ldata(item)) ;
		obj->o_count = 1 ;
		item = nitem ;
	}
	if (obj->o_type == ARTIFACT)
		has_artifact &= ~(1 << obj->o_which);
	if (obj->o_type == SCROLL && obj->o_which == S_SCARE) {
		if (obj->o_flags & ISBLESSED)
		    obj->o_flags &= ~ISBLESSED;
		else 
		    obj->o_flags |= ISCURSED;
	}
	updpack (FALSE);
	do_motion(obj, ydelta, xdelta, tp) ;
	/*
	* AHA! Here it has hit something. If it is a wall or a door,
	* or if it misses (combat) the monster, put it on the floor
	*/
	if (!hit_monster(unc(obj->o_pos), obj, tp)) {
		if (obj->o_type == WEAPON && obj->o_which == GRENADE) {
			register struct room *rp;
            static coord fpos;

            msg("BOOOM!");
            aggravate();
            rp = roomin(&obj->o_pos);
            if (ntraps + 1 < MAXTRAPS + MAXTRAPS &&
					fallpos(&obj->o_pos, &fpos, TRUE)) {
				mvaddch(fpos.y, fpos.x, TRAPDOOR);
                traps[ntraps].tr_type = TRAPDOOR;
                traps[ntraps].tr_flags = ISFOUND;
                traps[ntraps].tr_show = TRAPDOOR;
                traps[ntraps].tr_pos.y = fpos.y;
                traps[ntraps++].tr_pos.x = fpos.x;
                light(&hero);
            }
            discard(item);
        }
	    else if (obj->o_flags & ISLOST) {
		if (obj->o_type == WEAPON)
		    addmsg("The %s", weaps[obj->o_which].w_name);
		else
		    addmsg(inv_name(obj, TRUE));
		msg(" vanishes in a puff of greasy smoke.");
		discard(item);
	    }
	    else {
		if (fall(item, TRUE))
		if (obj->o_flags & CANRETURN)
		    msg("You have %s.", inv_name(obj, TRUE));
	    }
	}
	else if (obj->o_flags & ISOWNED) {
		add_pack(item, TRUE);
		msg("You have %s.", inv_name(obj, TRUE));
	}
	mvwaddch(cw, hero.y, hero.x, PLAYER) ;
}