… | |
… | |
194 | return; |
194 | return; |
195 | |
195 | |
196 | terminate_all_pets (ob); |
196 | terminate_all_pets (ob); |
197 | remove_friendly_object (ob); |
197 | remove_friendly_object (ob); |
198 | ob->deactivate_recursive (); |
198 | ob->deactivate_recursive (); |
|
|
199 | maplevel = ob->map->path; |
199 | ob->remove (); |
200 | ob->remove (); |
200 | ob->map = 0; |
201 | ob->map = 0; |
201 | |
202 | |
202 | // for weird reasons, this is often "ob", keeping a circular reference |
203 | // for weird reasons, this is often "ob", keeping a circular reference |
203 | ranges [range_skill] = 0; |
204 | ranges [range_skill] = 0; |
… | |
… | |
526 | x = mon->x; |
527 | x = mon->x; |
527 | y = mon->y; |
528 | y = mon->y; |
528 | m = mon->map; |
529 | m = mon->map; |
529 | dir = rv.direction; |
530 | dir = rv.direction; |
530 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
531 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
531 | diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); |
532 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
|
|
533 | |
532 | /* If we can't solve it within the search distance, return now. */ |
534 | /* If we can't solve it within the search distance, return now. */ |
533 | if (diff > max) |
535 | if (diff > max) |
534 | return 0; |
536 | return 0; |
|
|
537 | |
535 | while (diff > 1 && max > 0) |
538 | while (diff > 1 && max > 0) |
536 | { |
539 | { |
537 | lastx = x; |
540 | lastx = x; |
538 | lasty = y; |
541 | lasty = y; |
539 | lastmap = m; |
542 | lastmap = m; |
… | |
… | |
621 | max--; |
624 | max--; |
622 | lastdir = dir; |
625 | lastdir = dir; |
623 | if (!firstdir) |
626 | if (!firstdir) |
624 | firstdir = dir; |
627 | firstdir = dir; |
625 | } |
628 | } |
|
|
629 | |
626 | if (diff <= 1) |
630 | if (diff <= 1) |
627 | { |
631 | { |
628 | /* Recalculate diff (distance) because we may not have actually |
632 | /* Recalculate diff (distance) because we may not have actually |
629 | * headed toward player for entire distance. |
633 | * headed toward player for entire distance. |
630 | */ |
634 | */ |
631 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
635 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
632 | diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); |
636 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
633 | } |
637 | } |
|
|
638 | |
634 | if (diff > max) |
639 | if (diff > max) |
635 | return 0; |
640 | return 0; |
636 | } |
641 | } |
|
|
642 | |
637 | /* If we reached the max, didn't find a direction in time */ |
643 | /* If we reached the max, didn't find a direction in time */ |
638 | if (!max) |
644 | if (!max) |
639 | return 0; |
645 | return 0; |
640 | |
646 | |
641 | return firstdir; |
647 | return firstdir; |
… | |
… | |
755 | roll_stat (void) |
761 | roll_stat (void) |
756 | { |
762 | { |
757 | int a[4], i, j, k; |
763 | int a[4], i, j, k; |
758 | |
764 | |
759 | for (i = 0; i < 4; i++) |
765 | for (i = 0; i < 4; i++) |
760 | a[i] = (int) RANDOM () % 6 + 1; |
766 | a[i] = (int) rndm (6) + 1; |
761 | |
767 | |
762 | for (i = 0, j = 0, k = 7; i < 4; i++) |
768 | for (i = 0, j = 0, k = 7; i < 4; i++) |
763 | if (a[i] < k) |
769 | if (a[i] < k) |
764 | k = a[i], j = i; |
770 | k = a[i], j = i; |
765 | |
771 | |
… | |
… | |
2210 | return 0; |
2216 | return 0; |
2211 | } |
2217 | } |
2212 | |
2218 | |
2213 | /* peterm: added following line */ |
2219 | /* peterm: added following line */ |
2214 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2220 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2215 | dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); |
2221 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2216 | |
2222 | |
2217 | op->facing = dir; |
2223 | op->facing = dir; |
2218 | |
2224 | |
2219 | if (op->hide) |
2225 | if (op->hide) |
2220 | do_hidden_move (op); |
2226 | do_hidden_move (op); |
… | |
… | |
2981 | tmp->x = op->x, tmp->y = op->y; |
2987 | tmp->x = op->x, tmp->y = op->y; |
2982 | if (tmp->type == CONTAINER) |
2988 | if (tmp->type == CONTAINER) |
2983 | { /* empty container to ground */ |
2989 | { /* empty container to ground */ |
2984 | loot_object (tmp); |
2990 | loot_object (tmp); |
2985 | } |
2991 | } |
2986 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
2992 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2987 | { |
2993 | { |
2988 | if (tmp->nrof > 1) |
2994 | if (tmp->nrof > 1) |
2989 | { |
2995 | { |
2990 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2996 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2991 | tmp2->destroy (); |
2997 | tmp2->destroy (); |
… | |
… | |
3533 | pl->ranges[i] = 0; |
3539 | pl->ranges[i] = 0; |
3534 | if (pl->shoottype == i) |
3540 | if (pl->shoottype == i) |
3535 | pl->shoottype = range_none; |
3541 | pl->shoottype = range_none; |
3536 | } |
3542 | } |
3537 | } |
3543 | } |
|
|
3544 | |
|
|
3545 | sint8 |
|
|
3546 | player::visibility_at (maptile *map, int x, int y) const |
|
|
3547 | { |
|
|
3548 | if (!ns) |
|
|
3549 | return 0; |
|
|
3550 | |
|
|
3551 | int dx, dy; |
|
|
3552 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
|
|
3553 | return 0; |
|
|
3554 | |
|
|
3555 | x += dx - ns->current_x + ns->mapx / 2; |
|
|
3556 | y += dy - ns->current_y + ns->mapy / 2; |
|
|
3557 | |
|
|
3558 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
|
|
3559 | return 0; |
|
|
3560 | |
|
|
3561 | return 100 - blocked_los [x][y]; |
|
|
3562 | } |