/* 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); }
/* 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); }
/* 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); boolean 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) != NULL) { keepobj = otmp->nobj; add_to_minv(mtmp, otmp); } if (show & cansee(omx, omy)) newsym(omx, omy); }
static struct obj * DROPPABLES(struct monst *mon) { struct obj *obj; struct obj *wep = MON_WEP(mon), *hwep = attacktype(mon->data, AT_WEAP) ? select_hwep(mon) : (struct obj *)0, *proj = attacktype(mon->data, AT_WEAP) ? select_rwep(mon) : (struct obj *)0, *rwep; boolean item1 = FALSE, item2 = FALSE; rwep = attacktype(mon->data, AT_WEAP) ? propellor : &zeroobj; if (is_animal(mon->data) || mindless(mon->data)) item1 = item2 = TRUE; if (!tunnels(mon->data) || !needspick(mon->data)) item1 = TRUE; for (obj = mon->minvent; obj; obj = obj->nobj) { if (!item1 && is_pick(obj) && (obj->otyp != DWARVISH_MATTOCK || !which_armor(mon, W_ARMS))) { item1 = TRUE; continue; } if (!item2 && obj->otyp == UNICORN_HORN && !obj->cursed) { item2 = TRUE; continue; } if (!obj->owornmask && obj != wep && obj != rwep && obj != proj && obj != hwep && !would_prefer_hwep(mon, obj) /* cursed item in hand? */ && !would_prefer_rwep(mon, obj) && ((rwep != &zeroobj) || (!is_ammo(obj) && !is_launcher(obj))) && (rwep == &zeroobj || !ammo_and_launcher(obj, rwep)) && !could_use_item(mon, obj)) return obj; } return NULL; }
/* * Move for priests and shopkeepers. Called from shk_move() and pri_move(). * Valid returns are 1: moved 0: didn't -1: let m_move do it -2: died. */ int move_special(struct monst *mtmp, boolean in_his_shop, schar appr, boolean uondoor, boolean avoid, xchar omx, xchar omy, xchar gx, xchar gy) { xchar nx, ny, nix, niy; schar i; schar chcnt, cnt; coord poss[9]; long info[9]; long allowflags; struct obj *ib = NULL; if (omx == gx && omy == gy) return 0; if (mtmp->mconf) { avoid = FALSE; appr = 0; } nix = omx; niy = omy; if (mtmp->isshk) allowflags = ALLOW_SSM; else allowflags = ALLOW_SSM | ALLOW_SANCT; if (passes_walls(mtmp->data)) allowflags |= (ALLOW_ROCK | ALLOW_WALL); if (throws_rocks(mtmp->data)) allowflags |= ALLOW_ROCK; if (tunnels(mtmp->data)) allowflags |= ALLOW_DIG; if (!nohands(mtmp->data) && !verysmall(mtmp->data)) { allowflags |= OPENDOOR; if (m_carrying(mtmp, SKELETON_KEY)) allowflags |= BUSTDOOR; } if (is_giant(mtmp->data)) allowflags |= BUSTDOOR; cnt = mfndpos(mtmp, poss, info, allowflags); if (mtmp->isshk && avoid && uondoor) { /* perhaps we cannot avoid him */ for (i = 0; i < cnt; i++) if (!(info[i] & NOTONL)) goto pick_move; avoid = FALSE; } #define GDIST(x,y) (dist2(x,y,gx,gy)) pick_move: chcnt = 0; for (i = 0; i < cnt; i++) { nx = poss[i].x; ny = poss[i].y; if (IS_ROOM(level->locations[nx][ny].typ) || (mtmp->isshk && (!in_his_shop || ESHK(mtmp)->following))) { if (avoid && (info[i] & NOTONL)) continue; if ((!appr && !rn2(++chcnt)) || (appr && GDIST(nx, ny) < GDIST(nix, niy))) { nix = nx; niy = ny; } } } if (mtmp->ispriest && avoid && nix == omx && niy == omy && onlineu(omx, omy)) { /* might as well move closer as long it's going to stay lined up */ avoid = FALSE; goto pick_move; } if (nix != omx || niy != omy) { remove_monster(level, omx, omy); place_monster(mtmp, nix, niy); newsym(nix, niy); if (mtmp->isshk && !in_his_shop && inhishop(mtmp)) check_special_room(FALSE); if (ib) { if (cansee(mtmp->mx, mtmp->my)) pline("%s picks up %s.", Monnam(mtmp), distant_name(ib, doname)); obj_extract_self(ib); mpickobj(mtmp, ib); } return 1; } return 0; }