… | |
… | |
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 | { |
513 | int sdir = 0; |
518 | int sdir = 0; |
514 | |
519 | |
515 | for (int dir = 1; dir <= 8; ++dir) |
520 | for (int dir = 1; dir <= 8; ++dir) |
516 | { |
521 | { |
517 | mapxy pos (op); pos.move (dir); |
522 | mapxy pos (op); pos.move (dir); |
518 | if (pos.normalise ()) |
523 | if (pos.normalise ()) |
519 | { |
|
|
520 | mapspace &ms = pos.ms (); |
|
|
521 | |
|
|
522 | if (ms.smell > op->ms ().smell) |
|
|
523 | { |
524 | { |
|
|
525 | mapspace &ms = pos.ms (); |
|
|
526 | |
|
|
527 | if (ms.smell > op->ms ().smell) |
|
|
528 | { |
524 | 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 |
525 | op->ms ().smell = ms.smell - 1; |
530 | op->ms ().smell = ms.smell - 1; |
526 | sdir = dir; |
531 | sdir = dir; |
527 | |
532 | |
528 | // perturbing the path might let the monster lose track, |
533 | // perturbing the path might let the monster lose track, |
529 | // but it will also wide the actual path, spreading information |
534 | // but it will also wide the actual path, spreading information |
530 | if (!rndm (20)) |
535 | if (!rndm (20)) |
531 | sdir += absdir (1 - rndm (2) * 2); |
536 | sdir += absdir (1 - rndm (2) * 2); |
|
|
537 | } |
532 | } |
538 | } |
533 | } |
539 | } |
534 | } |
|
|
535 | |
540 | |
536 | if (sdir) |
541 | if (sdir) |
537 | dir = sdir; |
542 | dir = sdir; |
538 | else |
543 | else |
539 | // no better smell found, so assume the player jumped, and erase this smell |
544 | // no better smell found, so assume the player jumped, and erase this smell |
540 | {if (op->ms ().smell) printf ("erasing smell %d\n", op->ms ().smell);//D |
545 | {if (op->ms ().smell) printf ("erasing smell %d\n", op->ms ().smell);//D |
541 | ordered_mapwalk_begin (op, -1, -1, 1, 1) |
546 | ordered_mapwalk_begin (op, -1, -1, 1, 1) |
542 | if (m) |
547 | if (m) |
543 | m->at (nx, ny).smell = 0; |
548 | m->at (nx, ny).smell = 0; |
544 | ordered_mapwalk_end |
549 | ordered_mapwalk_end |
545 | }//D |
550 | }//D |
|
|
551 | } |
546 | |
552 | |
547 | #endif |
553 | #endif |
548 | |
554 | |
549 | 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)) |
550 | dir = absdir (dir + 4); |
556 | dir = absdir (dir + 4); |