void stealamulet(struct monst *mtmp) { struct obj *otmp = NULL; int real = 0, fake = 0; /* select the artifact to steal */ if (u.uhave.amulet) { real = AMULET_OF_YENDOR; fake = FAKE_AMULET_OF_YENDOR; } else if (u.uhave.questart) { for (otmp = invent; otmp; otmp = otmp->nobj) if (is_quest_artifact(otmp)) break; if (!otmp) return; /* should we panic instead? */ } else if (u.uhave.bell) { real = BELL_OF_OPENING; fake = BELL; } else if (u.uhave.book) { real = SPE_BOOK_OF_THE_DEAD; } else if (u.uhave.menorah) { real = CANDELABRUM_OF_INVOCATION; } else return; /* you have nothing of special interest */ if (!otmp) { /* If we get here, real and fake have been set up. */ for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->otyp == real || (otmp->otyp == fake && !mtmp->iswiz)) break; } if (otmp) { /* we have something to snatch */ if (otmp->owornmask) remove_worn_item(otmp, TRUE); freeinv(otmp); /* mpickobj wont merge otmp because none of the above things to steal are mergable */ mpickobj(mtmp, otmp); /* may merge and free otmp */ pline("%s stole %s!", Monnam(mtmp), doname(otmp)); if (can_teleport(mtmp->data) && !tele_restrict(mtmp)) rloc(mtmp, FALSE); } }
static void chat_with_leader(void) { /* Rule 0: Cheater checks. */ if (Uhave_questart && !Qstat(met_nemesis)) Qstat(cheater) = TRUE; /* It is possible for you to get the amulet without completing * the quest. If so, try to induce the player to quest. */ if (Qstat(got_thanks)) { /* Rule 1: You've gone back with/without the amulet. */ if (Uhave_amulet) finish_quest(NULL); /* Rule 2: You've gone back before going for the amulet. */ else qt_pager(QT_POSTHANKS); } /* Rule 3: You've got the artifact and are back to return it. */ else if (Uhave_questart) { struct obj *otmp; for (otmp = invent; otmp; otmp = otmp->nobj) if (is_quest_artifact(otmp)) break; finish_quest(otmp); /* Rule 4: You haven't got the artifact yet. */ } else if (Qstat(got_quest)) { qt_pager(rn1(10, QT_ENCOURAGE)); /* Rule 5: You aren't yet acceptable - or are you? */ } else { if (!Qstat(met_leader)) { qt_pager(QT_FIRSTLEADER); Qstat(met_leader) = TRUE; Qstat(not_ready) = 0; } else qt_pager(QT_NEXTLEADER); /* the quest leader might have passed through the portal into the regular dungeon; none of the remaining make sense there */ if (!on_level(&u.uz, &qstart_level)) return; if ((is_pure(FALSE) > 0) && (u.ulevelmax < 2) && ((!challengemode) || !(u.uconduct[conduct_killer]))) { qt_pager(QT_LOWLEVEL); if (yn_function("Confirm your readiness and start the quest?", "yn", 'n') == 'y') { pline("\"Go on then.\""); Qstat(got_quest) = TRUE; /* TODO: levelport the player straight to Quest 2? */ historic_event(FALSE, FALSE, "embarked upon an epic quest."); } else { qt_pager(QT_BADLEVEL); expulsion(FALSE); } return; } if (not_capable()) { qt_pager(QT_BADLEVEL); expulsion(FALSE); } else if (is_pure(TRUE) < 0) { com_pager(QT_BANISHED); expulsion(TRUE); } else if (is_pure(FALSE) == 0) { qt_pager(QT_BADALIGN); if (Qstat(not_ready) == MAX_QUEST_TRIES) { qt_pager(QT_LASTLEADER); expulsion(TRUE); } else { Qstat(not_ready)++; expulsion(FALSE); } } else { /* You are worthy! */ qt_pager(QT_ASSIGNQUEST); Qstat(got_quest) = TRUE; historic_event(FALSE, FALSE, "embarked upon an epic quest."); } } }
/* fungi will eat even tainted food */ int dogfood(const struct monst *mon, struct obj *obj) { boolean carni = carnivorous(mon->data); boolean herbi = herbivorous(mon->data); const struct permonst *fptr = &mons[obj->corpsenm]; boolean starving; if (is_quest_artifact(obj) || obj_resists(obj, 0, 95)) return obj->cursed ? TABU : APPORT; switch (obj->oclass) { case FOOD_CLASS: if (obj->otyp == CORPSE && ((touch_petrifies(&mons[obj->corpsenm]) && !resists_ston(mon)) || is_rider(fptr))) return TABU; /* Ghouls only eat old corpses... yum! */ if (mon->data == &mons[PM_GHOUL]) return (obj->otyp == CORPSE && peek_at_iced_corpse_age(obj) + 50L <= moves) ? DOGFOOD : TABU; if (!carni && !herbi) return obj->cursed ? UNDEF : APPORT; /* a starving pet will eat almost anything */ starving = (mon->mtame && !mon->isminion && CONST_EDOG(mon)->mhpmax_penalty); switch (obj->otyp) { case TRIPE_RATION: case MEATBALL: case MEAT_RING: case MEAT_STICK: case HUGE_CHUNK_OF_MEAT: return carni ? DOGFOOD : MANFOOD; case EGG: if (touch_petrifies(&mons[obj->corpsenm]) && !resists_ston(mon)) return POISON; return carni ? CADAVER : MANFOOD; case CORPSE: if ((peek_at_iced_corpse_age(obj) + 50L <= moves && obj->corpsenm != PM_LIZARD && obj->corpsenm != PM_LICHEN && mon->data->mlet != S_FUNGUS) || (acidic(&mons[obj->corpsenm]) && !resists_acid(mon)) || (poisonous(&mons[obj->corpsenm]) && !resists_poison(mon))) return POISON; else if (vegan(fptr)) return herbi ? CADAVER : MANFOOD; else return carni ? CADAVER : MANFOOD; case CLOVE_OF_GARLIC: return (is_undead(mon->data) ? TABU : ((herbi || starving) ? ACCFOOD : MANFOOD)); case TIN: return metallivorous(mon->data) ? ACCFOOD : MANFOOD; case APPLE: case CARROT: return herbi ? DOGFOOD : starving ? ACCFOOD : MANFOOD; case BANANA: return ((mon->data->mlet == S_YETI) ? DOGFOOD : ((herbi || starving) ? ACCFOOD : MANFOOD)); case K_RATION: case C_RATION: case CRAM_RATION: case LEMBAS_WAFER: case FOOD_RATION: if (is_human(mon->data) || is_elf(mon->data) || is_dwarf(mon->data) || is_gnome(mon->data) || is_orc(mon->data)) return ACCFOOD; default: if (starving) return ACCFOOD; return (obj->otyp > SLIME_MOLD ? (carni ? ACCFOOD : MANFOOD) : (herbi ? ACCFOOD : MANFOOD)); } default: if (obj->otyp == AMULET_OF_STRANGULATION || obj->otyp == RIN_SLOW_DIGESTION) return TABU; if (hates_silver(mon->data) && objects[obj->otyp].oc_material == SILVER) return TABU; if (mon->data == &mons[PM_GELATINOUS_CUBE] && is_organic(obj)) return ACCFOOD; if (metallivorous(mon->data) && is_metallic(obj) && (is_rustprone(obj) || mon->data != &mons[PM_RUST_MONSTER])) { /* Non-rustproofed ferrous based metals are preferred. */ return (is_rustprone(obj) && !obj->oerodeproof) ? DOGFOOD : ACCFOOD; } if (!obj->cursed && obj->oclass != BALL_CLASS && obj->oclass != CHAIN_CLASS) return APPORT; /* fall into next case */ case ROCK_CLASS: return UNDEF; } }
static void chat_with_leader(void) { /* Rule 0: Cheater checks. */ if (u.uhave.questart && !Qstat(met_nemesis)) Qstat(cheater) = TRUE; /* It is possible for you to get the amulet without completing * the quest. If so, try to induce the player to quest. */ if (Qstat(got_thanks)) { /* Rule 1: You've gone back with/without the amulet. */ if (u.uhave.amulet) finish_quest(NULL); /* Rule 2: You've gone back before going for the amulet. */ else qt_pager(QT_POSTHANKS); } /* Rule 3: You've got the artifact and are back to return it. */ else if (u.uhave.questart) { struct obj *otmp; for (otmp = invent; otmp; otmp = otmp->nobj) if (is_quest_artifact(otmp)) break; finish_quest(otmp); /* Rule 4: You haven't got the artifact yet. */ } else if (Qstat(got_quest)) { qt_pager(rn1(10, QT_ENCOURAGE)); /* Rule 5: You aren't yet acceptable - or are you? */ } else { if (!Qstat(met_leader)) { qt_pager(QT_FIRSTLEADER); Qstat(met_leader) = TRUE; Qstat(not_ready) = 0; } else qt_pager(QT_NEXTLEADER); /* the quest leader might have passed through the portal into the regular dungeon; none of the remaining make sense there */ if (!on_level(&u.uz, &qstart_level)) return; if (not_capable()) { qt_pager(QT_BADLEVEL); exercise(A_WIS, TRUE); expulsion(FALSE); } else if (is_pure(TRUE) < 0) { com_pager(QT_BANISHED); expulsion(TRUE); } else if (is_pure(TRUE) == 0) { qt_pager(QT_BADALIGN); if (Qstat(not_ready) == MAX_QUEST_TRIES) { qt_pager(QT_LASTLEADER); expulsion(TRUE); } else { Qstat(not_ready)++; exercise(A_WIS, TRUE); expulsion(FALSE); } } else { /* You are worthy! */ qt_pager(QT_ASSIGNQUEST); exercise(A_WIS, TRUE); Qstat(got_quest) = TRUE; historic_event(FALSE, "embarked upon an epic quest."); } } }