… | |
… | |
931 | LOG (llevDebug, "Fleeing player is dead.\n"); |
931 | LOG (llevDebug, "Fleeing player is dead.\n"); |
932 | CLEAR_FLAG (op, FLAG_SCARED); |
932 | CLEAR_FLAG (op, FLAG_SCARED); |
933 | return; |
933 | return; |
934 | } |
934 | } |
935 | |
935 | |
936 | if (op->enemy == NULL) |
936 | if (!op->enemy) |
937 | { |
937 | { |
938 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
938 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
939 | CLEAR_FLAG (op, FLAG_SCARED); |
939 | CLEAR_FLAG (op, FLAG_SCARED); |
940 | return; |
|
|
941 | } |
|
|
942 | |
|
|
943 | /* Seen some crashes here. Since we don't store an |
|
|
944 | * op->enemy_count, it is possible that something destroys the |
|
|
945 | * actual enemy, and the object is recycled. |
|
|
946 | */ |
|
|
947 | if (op->enemy->map == NULL) |
|
|
948 | { |
|
|
949 | CLEAR_FLAG (op, FLAG_SCARED); |
|
|
950 | op->enemy = NULL; |
|
|
951 | return; |
940 | return; |
952 | } |
941 | } |
953 | |
942 | |
954 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
943 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
955 | { |
944 | { |
… | |
… | |
1016 | |
1005 | |
1017 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1006 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1018 | { |
1007 | { |
1019 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1008 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1020 | CHK_PICK_PICKUP; |
1009 | CHK_PICK_PICKUP; |
|
|
1010 | |
1021 | continue; |
1011 | continue; |
1022 | } |
1012 | } |
1023 | |
1013 | |
1024 | /* high not bit set? We're using the old autopickup model */ |
1014 | /* high not bit set? We're using the old autopickup model */ |
1025 | if (!(op->contr->mode & PU_NEWMODE)) |
1015 | if (!(op->contr->mode & PU_NEWMODE)) |
… | |
… | |
1462 | for (i = 0, found = 0; i < 20; i++) |
1452 | for (i = 0, found = 0; i < 20; i++) |
1463 | { |
1453 | { |
1464 | x += freearr_x[dir]; |
1454 | x += freearr_x[dir]; |
1465 | y += freearr_y[dir]; |
1455 | y += freearr_y[dir]; |
1466 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1456 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
|
|
1457 | |
1467 | if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) |
1458 | if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) |
1468 | { |
1459 | { |
1469 | tmp = NULL; |
1460 | tmp = 0; |
1470 | break; |
1461 | break; |
1471 | } |
1462 | } |
1472 | else if (GET_MAP_MOVE_BLOCK (m, x, y) == MOVE_FLY_LOW) |
1463 | else if (GET_MAP_MOVE_BLOCK (m, x, y) == MOVE_FLY_LOW) |
1473 | { |
1464 | { |
1474 | /* This block presumes arrows and the like are MOVE_FLY_SLOW - |
1465 | /* This block presumes arrows and the like are MOVE_FLY_SLOW - |
1475 | * perhaps a bad assumption. |
1466 | * perhaps a bad assumption. |
1476 | */ |
1467 | */ |
1477 | tmp = NULL; |
1468 | tmp = 0; |
1478 | break; |
1469 | break; |
1479 | } |
1470 | } |
|
|
1471 | |
1480 | if (mflags & P_IS_ALIVE) |
1472 | if (mflags & P_IS_ALIVE) |
1481 | { |
|
|
1482 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1473 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1483 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
1474 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
1484 | { |
|
|
1485 | found++; |
|
|
1486 | break; |
|
|
1487 | } |
|
|
1488 | if (found) |
|
|
1489 | break; |
1475 | break; |
1490 | } |
|
|
1491 | } |
1476 | } |
1492 | if (tmp == NULL) |
1477 | |
|
|
1478 | if (!tmp) |
1493 | return find_arrow (op, type); |
1479 | return find_arrow (op, type); |
1494 | |
1480 | |
1495 | if (tmp->head) |
1481 | if (tmp->head) |
1496 | tmp = tmp->head; |
1482 | tmp = tmp->head; |
1497 | |
1483 | |
… | |
… | |
1542 | if (bow->below) |
1528 | if (bow->below) |
1543 | { |
1529 | { |
1544 | bow->remove (); |
1530 | bow->remove (); |
1545 | op->insert (bow); |
1531 | op->insert (bow); |
1546 | } |
1532 | } |
1547 | |
|
|
1548 | } |
1533 | } |
1549 | |
1534 | |
1550 | if (!bow->race || !bow->skill) |
1535 | if (!bow->race || !bow->skill) |
1551 | { |
1536 | { |
1552 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1537 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
… | |
… | |
1675 | * hence the function name. |
1660 | * hence the function name. |
1676 | */ |
1661 | */ |
1677 | int |
1662 | int |
1678 | player_fire_bow (object *op, int dir) |
1663 | player_fire_bow (object *op, int dir) |
1679 | { |
1664 | { |
1680 | int ret = 0, wcmod = 0; |
1665 | int ret; |
1681 | |
1666 | |
1682 | if (op->contr->bowtype == bow_bestarrow) |
1667 | if (op->contr->bowtype == bow_bestarrow) |
1683 | { |
1668 | { |
1684 | ret = fire_bow (op, op, pick_arrow_target (op, op->contr->ranged_ob->race, dir), dir, 0, op->x, op->y); |
1669 | ret = fire_bow (op, op, pick_arrow_target (op, op->contr->ranged_ob->race, dir), dir, 0, op->x, op->y); |
1685 | } |
1670 | } |
1686 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1671 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1687 | { |
1672 | { |
1688 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1673 | int wcmod = similar_direction (dir, op->contr->bowtype - bow_n + 1) ? 0 : -1; |
1689 | wcmod = -1; |
|
|
1690 | |
|
|
1691 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1674 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1692 | } |
1675 | } |
1693 | else if (op->contr->bowtype == bow_threewide) |
1676 | else if (op->contr->bowtype == bow_threewide) |
1694 | { |
1677 | { |
1695 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1678 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1696 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir + 2)], op->y + freearr_y[absdir (dir + 2)]); |
1679 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir + 2)], op->y + freearr_y[absdir (dir + 2)]); |
1697 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir - 2)], op->y + freearr_y[absdir (dir - 2)]); |
1680 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir - 2)], op->y + freearr_y[absdir (dir - 2)]); |
1698 | } |
1681 | } |
1699 | else if (op->contr->bowtype == bow_spreadshot) |
1682 | else if (op->contr->bowtype == bow_spreadshot) |
1700 | { |
1683 | { |
1701 | ret |= fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1684 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1702 | ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); |
1685 | ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); |
1703 | ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); |
1686 | ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); |
1704 | } |
1687 | } |
1705 | else |
1688 | else |
1706 | { |
1689 | { |
… | |
… | |
1763 | } |
1746 | } |
1764 | } |
1747 | } |
1765 | |
1748 | |
1766 | if (cast_spell (op, item, dir, item->inv, NULL)) |
1749 | if (cast_spell (op, item, dir, item->inv, NULL)) |
1767 | { |
1750 | { |
1768 | SET_FLAG (op, FLAG_BEEN_APPLIED); /* You now know something about it */ |
1751 | item->flag [FLAG_BEEN_APPLIED] = true; /* You now know something about it */ |
|
|
1752 | |
1769 | if (item->type == WAND) |
1753 | if (item->type == WAND) |
1770 | { |
1754 | { |
1771 | if (!(--item->stats.food)) |
1755 | if (!(--item->stats.food)) |
1772 | { |
1756 | { |
1773 | object *tmp; |
1757 | object *tmp; |
… | |
… | |
2071 | --op->speed_left; |
2055 | --op->speed_left; |
2072 | |
2056 | |
2073 | op->play_sound (sound_find ("push_player")); |
2057 | op->play_sound (sound_find ("push_player")); |
2074 | push_ob (mon, dir, op); |
2058 | push_ob (mon, dir, op); |
2075 | |
2059 | |
2076 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2060 | if (action_makes_visible (op)) |
2077 | make_visible (op); |
2061 | make_visible (op); |
2078 | |
2062 | |
2079 | return true; |
2063 | return true; |
2080 | } |
2064 | } |
2081 | else |
2065 | else |
… | |
… | |
3214 | return 0; |
3198 | return 0; |
3215 | } |
3199 | } |
3216 | |
3200 | |
3217 | /* routine for both players and monsters. We call this when |
3201 | /* routine for both players and monsters. We call this when |
3218 | * there is a possibility for our action distrubing our hiding |
3202 | * there is a possibility for our action distrubing our hiding |
3219 | * place or invisiblity spell. Artefact invisiblity is not |
3203 | * place or invisiblity spell. Artefact invisiblity causes |
3220 | * effected by this. If we arent invisible to begin with, we |
3204 | * "noise" instead. If we arent invisible to begin with, we |
3221 | * return 0. |
3205 | * return 0. |
3222 | */ |
3206 | */ |
3223 | int |
3207 | int |
3224 | action_makes_visible (object *op) |
3208 | action_makes_visible (object *op) |
3225 | { |
3209 | { |
3226 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
3210 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
3227 | { |
3211 | { |
3228 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
3212 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
|
|
3213 | { |
|
|
3214 | // artefact invisibility is permanent, but we still make noise |
|
|
3215 | // this is important for game-balance. |
|
|
3216 | if (op->contr) |
|
|
3217 | op->make_noise (); |
|
|
3218 | |
3229 | return 0; |
3219 | return 0; |
|
|
3220 | } |
3230 | |
3221 | |
3231 | if (op->contr && op->contr->tmp_invis == 0) |
3222 | if (op->contr && op->contr->tmp_invis == 0) |
3232 | return 0; |
3223 | return 0; |
3233 | |
3224 | |
3234 | /* If monsters, they should become visible */ |
3225 | /* If monsters, they should become visible */ |