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.5 by root, Fri Mar 31 22:04:03 2006 UTC vs.
Revision 1.6 by elmex, Sat Apr 22 15:10:08 2006 UTC

1/* 1/*
2 * static char *rcsid_monster_c = 2 * static char *rcsid_monster_c =
3 * "$Id: monster.c,v 1.5 2006/03/31 22:04:03 root Exp $"; 3 * "$Id: monster.c,v 1.6 2006/04/22 15:10:08 elmex Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
291/* 291/*
292 * Move-monster returns 1 if the object has been freed, otherwise 0. 292 * Move-monster returns 1 if the object has been freed, otherwise 0.
293 */ 293 */
294 294
295int move_monster(object *op) { 295int move_monster(object *op) {
296 int dir, diff; 296 int dir, diff, pre_att_dir; /* elmex: pre_att_dir remembers the direction before attack movement */
297 object *owner, *enemy, *part, *oph=op; 297 object *owner, *enemy, *part, *oph=op;
298 rv_vector rv; 298 rv_vector rv;
299 299
300 /* Monsters not on maps don't do anything. These monsters are things 300 /* Monsters not on maps don't do anything. These monsters are things
301 * Like royal guards in city dwellers inventories. 301 * Like royal guards in city dwellers inventories.
530 dir=absdir(dir+4); 530 dir=absdir(dir+4);
531 531
532 if(QUERY_FLAG(op,FLAG_CONFUSED)) 532 if(QUERY_FLAG(op,FLAG_CONFUSED))
533 dir = absdir(dir + RANDOM()%3 + RANDOM()%3 - 2); 533 dir = absdir(dir + RANDOM()%3 + RANDOM()%3 - 2);
534 534
535 pre_att_dir = dir; /* remember the original direction */
536
535 if ((op->attack_movement & LO4) && !QUERY_FLAG(op, FLAG_SCARED)) 537 if ((op->attack_movement & LO4) && !QUERY_FLAG(op, FLAG_SCARED))
536 { 538 {
537 switch (op->attack_movement & LO4) { 539 switch (op->attack_movement & LO4) {
538 case DISTATT: 540 case DISTATT:
539 dir = dist_att (dir,op,enemy,part,&rv); 541 dir = dist_att (dir,op,enemy,part,&rv);
571 if (!dir) 573 if (!dir)
572 return 0; 574 return 0;
573 575
574 if (!QUERY_FLAG(op,FLAG_STAND_STILL)) { 576 if (!QUERY_FLAG(op,FLAG_STAND_STILL)) {
575 if(move_object(op,dir)) /* Can the monster move directly toward player? */ 577 if(move_object(op,dir)) /* Can the monster move directly toward player? */
578 {
579 /* elmex: Turn our monster after it moved if it has DISTATT attack */
580 if ((op->attack_movement & LO4) == DISTATT)
581 op->direction = pre_att_dir;
582
576 return 0; 583 return 0;
584 }
577 585
578 if(QUERY_FLAG(op, FLAG_SCARED) || !can_hit(part,enemy,&rv) 586 if(QUERY_FLAG(op, FLAG_SCARED) || !can_hit(part,enemy,&rv)
579 || QUERY_FLAG(op,FLAG_RUN_AWAY)) { 587 || QUERY_FLAG(op,FLAG_RUN_AWAY)) {
580 588
581 /* Try move around corners if !close */ 589 /* Try move around corners if !close */
587 move_object(op,absdir(dir - diff*m))) 595 move_object(op,absdir(dir - diff*m)))
588 return 0; 596 return 0;
589 } 597 }
590 } 598 }
591 } /* if monster is not standing still */ 599 } /* if monster is not standing still */
600
601 /* elmex: Turn our monster after it moved if it has DISTATT attack */
602 if ((op->attack_movement & LO4) == DISTATT)
603 op->direction = pre_att_dir;
592 604
593 /* 605 /*
594 * Eneq(@csd.uu.se): Patch to make RUN_AWAY or SCARED monsters move a random 606 * Eneq(@csd.uu.se): Patch to make RUN_AWAY or SCARED monsters move a random
595 * direction if they can't move away. 607 * direction if they can't move away.
596 */ 608 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines