… | |
… | |
508 | |
508 | |
509 | part = rv.part; |
509 | part = rv.part; |
510 | dir = rv.direction; |
510 | dir = rv.direction; |
511 | |
511 | |
512 | #if DEVEL |
512 | #if DEVEL |
|
|
513 | // if the enemy is a player, we have los. if los says we |
|
|
514 | // can directly reach the player, we do not deviate. |
|
|
515 | // for non-players, we never deviate |
|
|
516 | if (enemy->contr && enemy->contr->darkness_at (op->map, op->x, op->y) == LOS_BLOCKED) |
|
|
517 | { |
|
|
518 | int sdir = 0; |
|
|
519 | |
513 | for (int sdir = 1; sdir <= 8; ++sdir) |
520 | for (int dir = 1; dir <= 8; ++dir) |
514 | { |
521 | { |
515 | mapxy pos (op); pos.move (sdir); |
522 | mapxy pos (op); pos.move (dir); |
516 | if (pos.normalise ()) |
523 | if (pos.normalise ()) |
517 | { |
|
|
518 | mapspace &ms = pos.ms (); |
|
|
519 | |
|
|
520 | if (ms.smell > op->ms ().smell) |
|
|
521 | { |
524 | { |
|
|
525 | mapspace &ms = pos.ms (); |
|
|
526 | |
|
|
527 | if (ms.smell > op->ms ().smell) |
|
|
528 | { |
522 | printf ("%s: found smell, following it, apparently (%d, %d)\n",& op->name,op->ms().smell,ms.smell);//D |
529 | printf ("%s: found smell, following it, apparently (%d, %d)\n",& op->name,op->ms().smell,ms.smell);//D |
523 | op->ms ().smell = ms.smell - 1; |
530 | op->ms ().smell = ms.smell - 1; |
524 | dir = sdir; |
531 | sdir = dir; |
|
|
532 | |
|
|
533 | // perturbing the path might let the monster lose track, |
|
|
534 | // but it will also wide the actual path, spreading information |
|
|
535 | if (!rndm (20)) |
|
|
536 | sdir += absdir (1 - rndm (2) * 2); |
|
|
537 | } |
525 | } |
538 | } |
526 | } |
539 | } |
|
|
540 | |
|
|
541 | if (sdir) |
|
|
542 | dir = sdir; |
|
|
543 | else |
|
|
544 | // no better smell found, so assume the player jumped, and erase this smell |
|
|
545 | {if (op->ms ().smell) printf ("erasing smell %d\n", op->ms ().smell);//D |
|
|
546 | ordered_mapwalk_begin (op, -1, -1, 1, 1) |
|
|
547 | if (m) |
|
|
548 | m->at (nx, ny).smell = 0; |
|
|
549 | ordered_mapwalk_end |
|
|
550 | }//D |
527 | } |
551 | } |
|
|
552 | |
528 | #endif |
553 | #endif |
529 | |
554 | |
530 | if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) |
555 | if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) |
531 | dir = absdir (dir + 4); |
556 | dir = absdir (dir + 4); |
532 | |
557 | |