* 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. */
| 1140 | * on the original mtmp. It now returns TRUE if the taming succeeded. |
| 1141 | */ |
| 1142 | boolean |
| 1143 | tamedog( |
| 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))) { |
no test coverage detected