示例#1
0
/* Returns 1 if otmp is free'd, 0 otherwise. */
int mpickobj(struct monst *mtmp, struct obj *otmp)
{
    int freed_otmp;

    boolean snuff_otmp = FALSE;
    /* don't want hidden light source inside the monster; assumes that
       engulfers won't have external inventories; whirly monsters cause
       the light to be extinguished rather than letting it shine thru */
    if (otmp->lamplit &&  /* hack to avoid function calls for most objs */
      	obj_sheds_light(otmp) &&
	attacktype(mtmp->data, AT_ENGL)) {
	/* this is probably a burning object that you dropped or threw */
	if (u.uswallow && mtmp == u.ustuck && !Blind)
	    pline("%s out.", Tobjnam(otmp, "go"));
	snuff_otmp = TRUE;
    }
    /* Must do carrying effects on object prior to add_to_minv() */
    carry_obj_effects(otmp);
    /* add_to_minv() might free otmp [if merged with something else],
       so we have to call it after doing the object checks */
    freed_otmp = add_to_minv(mtmp, otmp);
    /* and we had to defer this until object is in mtmp's inventory */
    if (snuff_otmp) snuff_light_source(mtmp->mx, mtmp->my);

    return freed_otmp;
}
示例#2
0
/* Returns 1 if otmp is free'd, 0 otherwise. */
int mpickobj (struct monst *mtmp, struct obj *otmp) {
    int freed_otmp;

    if (otmp->oclass == COIN_CLASS) {
        mtmp->mgold += otmp->quan;
        obfree(otmp, (struct obj *)0);
        freed_otmp = 1;
    } else {
        bool snuff_otmp = false;
        /* don't want hidden light source inside the monster; assumes that
           engulfers won't have external inventories; whirly monsters cause
           the light to be extinguished rather than letting it shine thru */
        if (otmp->lamplit &&  /* hack to avoid function calls for most objs */
                obj_sheds_light(otmp) &&
                attacktype(mtmp->data, AT_ENGL)) {
            /* this is probably a burning object that you dropped or threw */
            if (u.uswallow && mtmp == u.ustuck && !Blind()) {
                message_object(MSG_O_GO_OUT, otmp);
            }
            snuff_otmp = true;
        }
        /* Must do carrying effects on object prior to add_to_minv() */
        carry_obj_effects(otmp);
        /* add_to_minv() might free otmp [if merged with something else],
           so we have to call it after doing the object checks */
        freed_otmp = add_to_minv(mtmp, otmp);
        /* and we had to defer this until object is in mtmp's inventory */
        if (snuff_otmp) snuff_light_source(mtmp->mx, mtmp->my);
    }
    return freed_otmp;
}