MCPcopy Create free account
hub / github.com/NetHack/NetHack / steal_it

Function steal_it

src/uhitm.c:2173–2278  ·  view source on GitHub ↗

* Player uses theft attack against monster. * * If the target is wearing body armor, take all of its possessions; * otherwise, take one object. [Is this really the behavior we want?] */

Source from the content-addressed store, hash-verified

2171 * otherwise, take one object. [Is this really the behavior we want?]
2172 */
2173staticfn void
2174steal_it(struct monst *mdef, struct attack *mattk)
2175{
2176 struct obj *otmp, *gold = 0, *ustealo, **minvent_ptr;
2177 long unwornmask;
2178
2179 otmp = mdef->minvent;
2180 if (!otmp || (otmp->oclass == COIN_CLASS && !otmp->nobj))
2181 return; /* nothing to take */
2182
2183 /* look for worn body armor */
2184 ustealo = (struct obj *) 0;
2185 if (could_seduce(&gy.youmonst, mdef, mattk) && mdef->mcanmove) {
2186 /* find armor, and move it to end of inventory in the process */
2187 minvent_ptr = &mdef->minvent;
2188 while ((otmp = *minvent_ptr) != 0)
2189 if (otmp->owornmask & W_ARM) {
2190 if (ustealo)
2191 panic("steal_it: multiple worn suits");
2192 *minvent_ptr = otmp->nobj; /* take armor out of minvent */
2193 ustealo = otmp;
2194 ustealo->nobj = (struct obj *) 0;
2195 } else {
2196 minvent_ptr = &otmp->nobj;
2197 }
2198 *minvent_ptr = ustealo; /* put armor back into minvent */
2199 }
2200 gold = findgold(mdef->minvent);
2201
2202 if (ustealo) { /* we will be taking everything */
2203 char heshe[20];
2204
2205 /* 5.0: this uses hero's base gender rather than nymph femininity
2206 but was using hardcoded pronouns She/her for target monster;
2207 switch to dynamic pronoun */
2208 if (gender(mdef) == (int) u.mfemale
2209 && gy.youmonst.data->mlet == S_NYMPH)
2210 You("charm %s. %s gladly hands over %s%s possessions.",
2211 mon_nam(mdef), upstart(strcpy(heshe, mhe(mdef))),
2212 !gold ? "" : "most of ", mhis(mdef));
2213 else
2214 You("seduce %s and %s starts to take off %s clothes.",
2215 mon_nam(mdef), mhe(mdef), mhis(mdef));
2216 }
2217
2218 /* prevent gold from being stolen so that steal-item isn't a superset
2219 of steal-gold; shuffling it out of minvent before selecting next
2220 item, and then back in case hero or monster dies (hero touching
2221 stolen c'trice corpse or monster wielding one and having gloves
2222 stolen) is less bookkeeping than skipping it within the loop or
2223 taking it out once and then trying to figure out how to put it back */
2224 if (gold)
2225 obj_extract_self(gold);
2226
2227 while ((otmp = mdef->minvent) != 0) {
2228 if (gold) /* put 'mdef's gold back after remembering mdef->minvent */
2229 mpickobj(mdef, gold), gold = 0;
2230 if (!Upolyd)

Callers 1

mhitm_ad_seduFunction · 0.85

Calls 15

could_seduceFunction · 0.85
findgoldFunction · 0.85
genderFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
upstartFunction · 0.85
obj_extract_selfFunction · 0.85
mpickobjFunction · 0.85
find_artifactFunction · 0.85
extract_from_minventFunction · 0.85
MonnamFunction · 0.85
hold_another_objectFunction · 0.85

Tested by

no test coverage detected