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.78 by root, Sun Feb 7 04:22:33 2010 UTC vs.
Revision 1.79 by root, Fri Mar 26 00:53:26 2010 UTC

277static int 277static int
278move_randomly (object *op) 278move_randomly (object *op)
279{ 279{
280 /* Give up to 15 chances for a monster to move randomly */ 280 /* Give up to 15 chances for a monster to move randomly */
281 for (int i = 0; i < 15; i++) 281 for (int i = 0; i < 15; i++)
282 if (move_object (op, rndm (8) + 1)) 282 if (op->move (rndm (8) + 1))
283 return 1; 283 return 1;
284 284
285 return 0; 285 return 0;
286} 286}
287 287
786 static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 }; 786 static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 };
787 787
788 if (++ob->move_status > 11) 788 if (++ob->move_status > 11)
789 ob->move_status = 0; 789 ob->move_status = 0;
790 790
791 if (!(move_object (ob, circle[ob->move_status]))) 791 if (!(ob->move (circle[ob->move_status])))
792 move_object (ob, rndm (8) + 1); 792 ob->move (rndm (8) + 1);
793} 793}
794 794
795static void 795static void
796circ2_move (object *ob) 796circ2_move (object *ob)
797{ 797{
798 static int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 }; 798 static int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 };
799 799
800 if (++ob->move_status > 19) 800 if (++ob->move_status > 19)
801 ob->move_status = 0; 801 ob->move_status = 0;
802 802
803 if (!(move_object (ob, circle[ob->move_status]))) 803 if (!(ob->move (circle[ob->move_status])))
804 move_object (ob, rndm (8) + 1); 804 ob->move (rndm (8) + 1);
805} 805}
806 806
807static void 807static void
808pace_movev (object *ob) 808pace_movev (object *ob)
809{ 809{
810 if (ob->move_status++ > 6) 810 if (ob->move_status++ > 6)
811 ob->move_status = 0; 811 ob->move_status = 0;
812 812
813 if (ob->move_status < 4) 813 if (ob->move_status < 4)
814 move_object (ob, 5); 814 ob->move (5);
815 else 815 else
816 move_object (ob, 1); 816 ob->move (1);
817} 817}
818 818
819static void 819static void
820pace_moveh (object *ob) 820pace_moveh (object *ob)
821{ 821{
822 if (ob->move_status++ > 6) 822 if (ob->move_status++ > 6)
823 ob->move_status = 0; 823 ob->move_status = 0;
824 824
825 if (ob->move_status < 4) 825 if (ob->move_status < 4)
826 move_object (ob, 3); 826 ob->move (3);
827 else 827 else
828 move_object (ob, 7); 828 ob->move (7);
829} 829}
830 830
831static void 831static void
832pace2_movev (object *ob) 832pace2_movev (object *ob)
833{ 833{
834 if (ob->move_status++ > 16) 834 if (ob->move_status++ > 16)
835 ob->move_status = 0; 835 ob->move_status = 0;
836 836
837 if (ob->move_status < 6) 837 if (ob->move_status < 6)
838 move_object (ob, 5); 838 ob->move (5);
839 else if (ob->move_status < 8) 839 else if (ob->move_status < 8)
840 return; 840 return;
841 else if (ob->move_status < 13) 841 else if (ob->move_status < 13)
842 move_object (ob, 1); 842 ob->move (1);
843 else 843 else
844 return; 844 return;
845} 845}
846 846
847static void 847static void
849{ 849{
850 if (ob->move_status++ > 16) 850 if (ob->move_status++ > 16)
851 ob->move_status = 0; 851 ob->move_status = 0;
852 852
853 if (ob->move_status < 6) 853 if (ob->move_status < 6)
854 move_object (ob, 3); 854 ob->move (3);
855 else if (ob->move_status < 8) 855 else if (ob->move_status < 8)
856 return; 856 return;
857 else if (ob->move_status < 13) 857 else if (ob->move_status < 13)
858 move_object (ob, 7); 858 ob->move (7);
859 else 859 else
860 return; 860 return;
861} 861}
862 862
863static void 863static void
864rand_move (object *ob) 864rand_move (object *ob)
865{ 865{
866 if (ob->move_status < 1 || ob->move_status > 8 || !(move_object (ob, ob->move_status || !(rndm (9))))) 866 if (ob->move_status < 1 || ob->move_status > 8 || !(ob->move (ob->move_status || !(rndm (9)))))
867 for (int i = 0; i < 5; i++) 867 for (int i = 0; i < 5; i++)
868 if (move_object (ob, ob->move_status = rndm (8) + 1)) 868 if (ob->move (ob->move_status = rndm (8) + 1))
869 return; 869 return;
870} 870}
871 871
872#define MAX_KNOWN_SPELLS 20 872#define MAX_KNOWN_SPELLS 20
873 873
1580 if (!dir) 1580 if (!dir)
1581 return 0; 1581 return 0;
1582 1582
1583 if (!QUERY_FLAG (op, FLAG_STAND_STILL)) 1583 if (!QUERY_FLAG (op, FLAG_STAND_STILL))
1584 { 1584 {
1585 if (move_object (op, dir)) /* Can the monster move directly toward player? */ 1585 if (op->move (dir)) /* Can the monster move directly toward player? */
1586 { 1586 {
1587 /* elmex: Turn our monster after it moved if it has DISTATT attack */ 1587 /* elmex: Turn our monster after it moved if it has DISTATT attack */
1588 if ((op->attack_movement & LO4) == DISTATT) 1588 if ((op->attack_movement & LO4) == DISTATT)
1589 op->direction = pre_att_dir; 1589 op->direction = pre_att_dir;
1590 1590
1599 for (diff = 1; diff <= maxdiff; diff++) 1599 for (diff = 1; diff <= maxdiff; diff++)
1600 { 1600 {
1601 /* try different detours */ 1601 /* try different detours */
1602 int m = 1 - rndm (2) * 2; /* Try left or right first? */ 1602 int m = 1 - rndm (2) * 2; /* Try left or right first? */
1603 1603
1604 if (move_object (op, absdir (dir + diff * m)) || move_object (op, absdir (dir - diff * m))) 1604 if (op->move (absdir (dir + diff * m)) || op->move (absdir (dir - diff * m)))
1605 return 0; 1605 return 0;
1606 } 1606 }
1607 } 1607 }
1608 } /* if monster is not standing still */ 1608 } /* if monster is not standing still */
1609 1609

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines