ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/monster.C
(Generate patch)

Comparing deliantra/server/server/monster.C (file contents):
Revision 1.56 by root, Sat Dec 27 08:41:44 2008 UTC vs.
Revision 1.57 by root, Sun Dec 28 06:59:27 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines