… | |
… | |
403 | next = tmp->below; |
403 | next = tmp->below; |
404 | if (monster_can_pick (monster, tmp)) |
404 | if (monster_can_pick (monster, tmp)) |
405 | { |
405 | { |
406 | tmp->remove (); |
406 | tmp->remove (); |
407 | tmp = insert_ob_in_ob (tmp, monster); |
407 | tmp = insert_ob_in_ob (tmp, monster); |
408 | (void) monster_check_apply (monster, tmp); |
408 | monster_check_apply (monster, tmp); |
409 | } |
409 | } |
|
|
410 | |
410 | /* We could try to re-establish the cycling, of the space, but probably |
411 | /* We could try to re-establish the cycling, of the space, but probably |
411 | * not a big deal to just bail out. |
412 | * not a big deal to just bail out. |
412 | */ |
413 | */ |
413 | if (next && next->destroyed ()) |
414 | if (next && next->destroyed ()) |
414 | return; |
415 | return; |
… | |
… | |
1130 | } |
1131 | } |
1131 | else if (wand->type == ROD || wand->type == HORN) |
1132 | else if (wand->type == ROD || wand->type == HORN) |
1132 | { |
1133 | { |
1133 | /* Found rod/horn, let's use it if possible */ |
1134 | /* Found rod/horn, let's use it if possible */ |
1134 | at_least_one = 1; |
1135 | at_least_one = 1; |
1135 | if (wand->stats.hp < MAX (wand->inv->stats.sp, wand->inv->stats.grace)) |
1136 | if (wand->stats.hp < max (wand->inv->stats.sp, wand->inv->stats.grace)) |
1136 | continue; |
1137 | continue; |
1137 | |
1138 | |
1138 | /* drain charge before casting spell - can be a case where the |
1139 | /* drain charge before casting spell - can be a case where the |
1139 | * spell destroys the monster, and rod, so if done after, results |
1140 | * spell destroys the monster, and rod, so if done after, results |
1140 | * in crash. |
1141 | * in crash. |
… | |
… | |
1180 | } |
1181 | } |
1181 | |
1182 | |
1182 | void |
1183 | void |
1183 | npc_call_help (object *op) |
1184 | npc_call_help (object *op) |
1184 | { |
1185 | { |
1185 | unordered_mapwalk (op, -7, -7, 7, 7) |
1186 | unordered_mapwalk (mapwalk_buf, op, -7, -7, 7, 7) |
1186 | { |
1187 | { |
1187 | mapspace &ms = m->at (nx, ny); |
1188 | mapspace &ms = m->at (nx, ny); |
1188 | |
1189 | |
1189 | /* If nothing alive on this space, no need to search the space. */ |
1190 | /* If nothing alive on this space, no need to search the space. */ |
1190 | if (!(ms.flags () & P_IS_ALIVE)) |
1191 | if (!(ms.flags () & P_IS_ALIVE)) |
… | |
… | |
1292 | * |
1293 | * |
1293 | * Cast to sint32 before comparing to maxhp since otherwise an (sint16) |
1294 | * Cast to sint32 before comparing to maxhp since otherwise an (sint16) |
1294 | * overflow might produce monsters with negative hp. |
1295 | * overflow might produce monsters with negative hp. |
1295 | */ |
1296 | */ |
1296 | |
1297 | |
1297 | op->last_heal += (int) ((float) (8 * op->stats.Con) / FABS (op->speed)); |
1298 | op->last_heal += (int) ((float) (8 * op->stats.Con) / op->speed); |
1298 | op->stats.hp = MIN ((sint32) op->stats.hp + op->last_heal / 32, op->stats.maxhp); /* causes Con/4 hp/tick */ |
1299 | op->stats.hp = min ((sint32) op->stats.hp + op->last_heal / 32, op->stats.maxhp); /* causes Con/4 hp/tick */ |
1299 | op->last_heal %= 32; |
1300 | op->last_heal %= 32; |
1300 | |
1301 | |
1301 | /* So if the monster has gained enough HP that they are no longer afraid */ |
1302 | /* So if the monster has gained enough HP that they are no longer afraid */ |
1302 | if (QUERY_FLAG (op, FLAG_RUN_AWAY) && op->stats.hp >= (signed short)(((float)op->run_away / 100.f) * (float)op->stats.maxhp)) |
1303 | if (QUERY_FLAG (op, FLAG_RUN_AWAY) && op->stats.hp >= (signed short)(((float)op->run_away / 100.f) * (float)op->stats.maxhp)) |
1303 | CLEAR_FLAG (op, FLAG_RUN_AWAY); |
1304 | CLEAR_FLAG (op, FLAG_RUN_AWAY); |
… | |
… | |
1316 | * |
1317 | * |
1317 | * Cast to sint32 before comparing to maxhp since otherwise an (sint16) |
1318 | * Cast to sint32 before comparing to maxhp since otherwise an (sint16) |
1318 | * overflow might produce monsters with negative sp. |
1319 | * overflow might produce monsters with negative sp. |
1319 | */ |
1320 | */ |
1320 | |
1321 | |
1321 | op->last_sp += (int) ((float) (8 * op->stats.Pow) / fabsf (op->speed)); |
1322 | op->last_sp += (int) ((float) (8 * op->stats.Pow) / op->speed); |
1322 | op->stats.sp = min (op->stats.sp + op->last_sp / 128, op->stats.maxsp); /* causes Pow/16 sp/tick */ |
1323 | op->stats.sp = min (op->stats.sp + op->last_sp / 128, op->stats.maxsp); /* causes Pow/16 sp/tick */ |
1323 | op->last_sp %= 128; |
1324 | op->last_sp %= 128; |
1324 | } |
1325 | } |
1325 | |
1326 | |
1326 | /* this should probably get modified by many more values. |
1327 | /* this should probably get modified by many more values. |
… | |
… | |
1522 | dir = sdir; |
1523 | dir = sdir; |
1523 | else if (smell) |
1524 | else if (smell) |
1524 | { |
1525 | { |
1525 | // no better smell found, so assume the player jumped, and erase this smell |
1526 | // no better smell found, so assume the player jumped, and erase this smell |
1526 | //printf ("erasing smell %d\n", op->ms ().smell);//D |
1527 | //printf ("erasing smell %d\n", op->ms ().smell);//D |
1527 | unordered_mapwalk (op, -1, -1, 1, 1) |
1528 | unordered_mapwalk (mapwalk_buf, op, -1, -1, 1, 1) |
1528 | m->at (nx, ny).smell = 0; |
1529 | m->at (nx, ny).smell = 0; |
1529 | } |
1530 | } |
1530 | } |
1531 | } |
1531 | |
1532 | |
1532 | //+GPL |
1533 | //+GPL |
… | |
… | |
1839 | |
1840 | |
1840 | if (op->glow_radius > 0) |
1841 | if (op->glow_radius > 0) |
1841 | return 1; |
1842 | return 1; |
1842 | |
1843 | |
1843 | if (op->map) |
1844 | if (op->map) |
1844 | unordered_mapwalk (op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) |
1845 | unordered_mapwalk (mapwalk_buf, op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) |
1845 | { |
1846 | { |
1846 | /* Check the spaces with the max light radius to see if any of them |
1847 | /* Check the spaces with the max light radius to see if any of them |
1847 | * have lights, and if any of them light the player enough, then return 1. |
1848 | * have lights, and if any of them light the player enough, then return 1. |
1848 | */ |
1849 | */ |
1849 | int light = m->at (nx, ny).light; |
1850 | int light = m->at (nx, ny).light; |