MCPcopy Index your code
hub / github.com/NetHack/NetHack / tamedog

Function tamedog

src/dog.c:1142–1282  ·  view source on GitHub ↗

* tamedog() used to return the monster, which might have changed address * if a new one was created in order to allocate the edog extension. * With the separate mextra structure added in 3.6.x it always operates * on the original mtmp. It now returns TRUE if the taming succeeded. */

Source from the content-addressed store, hash-verified

1140 * on the original mtmp. It now returns TRUE if the taming succeeded.
1141 */
1142boolean
1143tamedog(
1144 struct monst *mtmp,
1145 struct obj *obj, /* food or scroll/spell */
1146 boolean givemsg)
1147{
1148 boolean blessed_scroll = FALSE;
1149
1150 if (obj && (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS)) {
1151 blessed_scroll = obj->blessed ? TRUE : FALSE;
1152 /* the rest of this routine assumes 'obj' represents food */
1153 obj = (struct obj *) NULL;
1154 }
1155 /* reduce timed sleep or paralysis, leaving mtmp->mcanmove as-is
1156 (note: if mtmp is donning armor, this will reduce its busy time) */
1157 if (mtmp->mfrozen)
1158 mtmp->mfrozen = (mtmp->mfrozen + 1) / 2;
1159 /* end indefinite sleep; using distance==1 limits the waking to mtmp */
1160 if (mtmp->msleeping)
1161 wake_nearto(mtmp->mx, mtmp->my, 1); /* [different from wakeup()] */
1162
1163 /* The Wiz, Medusa and the quest nemeses aren't even made peaceful. */
1164 if (mtmp->iswiz || mtmp->data == &mons[PM_MEDUSA]
1165 || (mtmp->data->mflags3 & M3_WANTSARTI))
1166 return FALSE;
1167
1168 /* worst case, at least it'll be peaceful. */
1169 if (givemsg && !mtmp->mpeaceful && canspotmon(mtmp)) {
1170 pline_mon(mtmp, "%s seems %s.", Monnam(mtmp),
1171 Hallucination ? "really chill" : "more amiable");
1172 givemsg = FALSE; /* don't give another message below */
1173 }
1174 mtmp->mpeaceful = 1;
1175 set_malign(mtmp);
1176 if (flags.moonphase == FULL_MOON && night() && rn2(6) && obj
1177 && mtmp->data->mlet == S_DOG)
1178 return FALSE;
1179
1180 /* If we cannot tame it, at least it's no longer afraid. */
1181 mtmp->mflee = 0;
1182 mtmp->mfleetim = 0;
1183
1184 /* make grabber let go now, whether it becomes tame or not */
1185 if (mtmp == u.ustuck) {
1186 if (u.uswallow)
1187 expels(mtmp, mtmp->data, TRUE);
1188 else if (!(Upolyd && sticks(gy.youmonst.data)))
1189 unstuck(mtmp);
1190 }
1191
1192 /* feeding it treats makes it tamer */
1193 if (mtmp->mtame && obj) {
1194 int tasty;
1195
1196 if (mtmp->mcanmove && !mtmp->mconf && !mtmp->meating
1197 && ((tasty = dogfood(mtmp, obj)) == DOGFOOD
1198 || (tasty <= ACCFOOD
1199 && EDOG(mtmp)->hungrytime <= svm.moves))) {

Callers 12

djinni_from_bottleFunction · 0.85
demonpetFunction · 0.85
were_summonFunction · 0.85
hatch_eggFunction · 0.85
thitmonstFunction · 0.85
charm_monstersFunction · 0.85
domagictrapFunction · 0.85
clone_monFunction · 0.85
reviveFunction · 0.85
deadbook_pacify_undeadFunction · 0.85
maybe_tameFunction · 0.85

Calls 15

wake_neartoFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
set_malignFunction · 0.85
nightFunction · 0.85
rn2Function · 0.85
expelsFunction · 0.85
sticksFunction · 0.85
unstuckFunction · 0.85
dogfoodFunction · 0.85
canseemonFunction · 0.85
theFunction · 0.85

Tested by

no test coverage detected