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.76 by root, Sun Nov 29 09:41:28 2009 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
403 next = tmp->below; 403 next = tmp->below;
404 if (monster_can_pick (monster, tmp)) 404 if (monster_can_pick (monster, tmp))
405 { 405 {
406 tmp->remove (); 406 tmp->remove ();
407 tmp = insert_ob_in_ob (tmp, monster); 407 tmp = insert_ob_in_ob (tmp, monster);
408 (void) monster_check_apply (monster, tmp); 408 monster_check_apply (monster, tmp);
409 } 409 }
410
410 /* We could try to re-establish the cycling, of the space, but probably 411 /* We could try to re-establish the cycling, of the space, but probably
411 * not a big deal to just bail out. 412 * not a big deal to just bail out.
412 */ 413 */
413 if (next && next->destroyed ()) 414 if (next && next->destroyed ())
414 return; 415 return;
785 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 };
786 787
787 if (++ob->move_status > 11) 788 if (++ob->move_status > 11)
788 ob->move_status = 0; 789 ob->move_status = 0;
789 790
790 if (!(move_object (ob, circle[ob->move_status]))) 791 if (!(ob->move (circle[ob->move_status])))
791 move_object (ob, rndm (8) + 1); 792 ob->move (rndm (8) + 1);
792} 793}
793 794
794static void 795static void
795circ2_move (object *ob) 796circ2_move (object *ob)
796{ 797{
797 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 };
798 799
799 if (++ob->move_status > 19) 800 if (++ob->move_status > 19)
800 ob->move_status = 0; 801 ob->move_status = 0;
801 802
802 if (!(move_object (ob, circle[ob->move_status]))) 803 if (!(ob->move (circle[ob->move_status])))
803 move_object (ob, rndm (8) + 1); 804 ob->move (rndm (8) + 1);
804} 805}
805 806
806static void 807static void
807pace_movev (object *ob) 808pace_movev (object *ob)
808{ 809{
809 if (ob->move_status++ > 6) 810 if (ob->move_status++ > 6)
810 ob->move_status = 0; 811 ob->move_status = 0;
811 812
812 if (ob->move_status < 4) 813 if (ob->move_status < 4)
813 move_object (ob, 5); 814 ob->move (5);
814 else 815 else
815 move_object (ob, 1); 816 ob->move (1);
816} 817}
817 818
818static void 819static void
819pace_moveh (object *ob) 820pace_moveh (object *ob)
820{ 821{
821 if (ob->move_status++ > 6) 822 if (ob->move_status++ > 6)
822 ob->move_status = 0; 823 ob->move_status = 0;
823 824
824 if (ob->move_status < 4) 825 if (ob->move_status < 4)
825 move_object (ob, 3); 826 ob->move (3);
826 else 827 else
827 move_object (ob, 7); 828 ob->move (7);
828} 829}
829 830
830static void 831static void
831pace2_movev (object *ob) 832pace2_movev (object *ob)
832{ 833{
833 if (ob->move_status++ > 16) 834 if (ob->move_status++ > 16)
834 ob->move_status = 0; 835 ob->move_status = 0;
835 836
836 if (ob->move_status < 6) 837 if (ob->move_status < 6)
837 move_object (ob, 5); 838 ob->move (5);
838 else if (ob->move_status < 8) 839 else if (ob->move_status < 8)
839 return; 840 return;
840 else if (ob->move_status < 13) 841 else if (ob->move_status < 13)
841 move_object (ob, 1); 842 ob->move (1);
842 else 843 else
843 return; 844 return;
844} 845}
845 846
846static void 847static void
848{ 849{
849 if (ob->move_status++ > 16) 850 if (ob->move_status++ > 16)
850 ob->move_status = 0; 851 ob->move_status = 0;
851 852
852 if (ob->move_status < 6) 853 if (ob->move_status < 6)
853 move_object (ob, 3); 854 ob->move (3);
854 else if (ob->move_status < 8) 855 else if (ob->move_status < 8)
855 return; 856 return;
856 else if (ob->move_status < 13) 857 else if (ob->move_status < 13)
857 move_object (ob, 7); 858 ob->move (7);
858 else 859 else
859 return; 860 return;
860} 861}
861 862
862static void 863static void
863rand_move (object *ob) 864rand_move (object *ob)
864{ 865{
865 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)))))
866 for (int i = 0; i < 5; i++) 867 for (int i = 0; i < 5; i++)
867 if (move_object (ob, ob->move_status = rndm (8) + 1)) 868 if (ob->move (ob->move_status = rndm (8) + 1))
868 return; 869 return;
869} 870}
870 871
871#define MAX_KNOWN_SPELLS 20 872#define MAX_KNOWN_SPELLS 20
872 873
1180} 1181}
1181 1182
1182void 1183void
1183npc_call_help (object *op) 1184npc_call_help (object *op)
1184{ 1185{
1185 unordered_mapwalk (op, -7, -7, 7, 7) 1186 unordered_mapwalk (mapwalk_buf, op, -7, -7, 7, 7)
1186 { 1187 {
1187 mapspace &ms = m->at (nx, ny); 1188 mapspace &ms = m->at (nx, ny);
1188 1189
1189 /* If nothing alive on this space, no need to search the space. */ 1190 /* If nothing alive on this space, no need to search the space. */
1190 if (!(ms.flags () & P_IS_ALIVE)) 1191 if (!(ms.flags () & P_IS_ALIVE))
1522 dir = sdir; 1523 dir = sdir;
1523 else if (smell) 1524 else if (smell)
1524 { 1525 {
1525 // no better smell found, so assume the player jumped, and erase this smell 1526 // no better smell found, so assume the player jumped, and erase this smell
1526 //printf ("erasing smell %d\n", op->ms ().smell);//D 1527 //printf ("erasing smell %d\n", op->ms ().smell);//D
1527 unordered_mapwalk (op, -1, -1, 1, 1) 1528 unordered_mapwalk (mapwalk_buf, op, -1, -1, 1, 1)
1528 m->at (nx, ny).smell = 0; 1529 m->at (nx, ny).smell = 0;
1529 } 1530 }
1530 } 1531 }
1531 1532
1532//+GPL 1533//+GPL
1579 if (!dir) 1580 if (!dir)
1580 return 0; 1581 return 0;
1581 1582
1582 if (!QUERY_FLAG (op, FLAG_STAND_STILL)) 1583 if (!QUERY_FLAG (op, FLAG_STAND_STILL))
1583 { 1584 {
1584 if (move_object (op, dir)) /* Can the monster move directly toward player? */ 1585 if (op->move (dir)) /* Can the monster move directly toward player? */
1585 { 1586 {
1586 /* 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 */
1587 if ((op->attack_movement & LO4) == DISTATT) 1588 if ((op->attack_movement & LO4) == DISTATT)
1588 op->direction = pre_att_dir; 1589 op->direction = pre_att_dir;
1589 1590
1598 for (diff = 1; diff <= maxdiff; diff++) 1599 for (diff = 1; diff <= maxdiff; diff++)
1599 { 1600 {
1600 /* try different detours */ 1601 /* try different detours */
1601 int m = 1 - rndm (2) * 2; /* Try left or right first? */ 1602 int m = 1 - rndm (2) * 2; /* Try left or right first? */
1602 1603
1603 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)))
1604 return 0; 1605 return 0;
1605 } 1606 }
1606 } 1607 }
1607 } /* if monster is not standing still */ 1608 } /* if monster is not standing still */
1608 1609
1839 1840
1840 if (op->glow_radius > 0) 1841 if (op->glow_radius > 0)
1841 return 1; 1842 return 1;
1842 1843
1843 if (op->map) 1844 if (op->map)
1844 unordered_mapwalk (op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) 1845 unordered_mapwalk (mapwalk_buf, op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS)
1845 { 1846 {
1846 /* Check the spaces with the max light radius to see if any of them 1847 /* Check the spaces with the max light radius to see if any of them
1847 * have lights, and if any of them light the player enough, then return 1. 1848 * have lights, and if any of them light the player enough, then return 1.
1848 */ 1849 */
1849 int light = m->at (nx, ny).light; 1850 int light = m->at (nx, ny).light;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines