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.22 by pippijn, Mon Jan 15 21:06:20 2007 UTC vs.
Revision 1.23 by root, Thu Jan 18 19:42:10 2007 UTC

278 int i; 278 int i;
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 (i = 0; i < 15; i++) 281 for (i = 0; i < 15; i++)
282 { 282 {
283 if (move_object (op, RANDOM () % 8 + 1)) 283 if (move_object (op, rndm (8) + 1))
284 return 1; 284 return 1;
285 } 285 }
286 return 0; 286 return 0;
287} 287}
288 288
357 } 357 }
358 358
359 /* this should probably get modified by many more values. 359 /* this should probably get modified by many more values.
360 * (eg, creatures resistance to fear, level, etc. ) 360 * (eg, creatures resistance to fear, level, etc. )
361 */ 361 */
362 if (QUERY_FLAG (op, FLAG_SCARED) && !(RANDOM () % 20)) 362 if (QUERY_FLAG (op, FLAG_SCARED) && !(rndm (20)))
363 { 363 {
364 CLEAR_FLAG (op, FLAG_SCARED); /* Time to regain some "guts"... */ 364 CLEAR_FLAG (op, FLAG_SCARED); /* Time to regain some "guts"... */
365 } 365 }
366 366
367 if (INVOKE_OBJECT (MONSTER_MOVE, op, ARG_OBJECT (op->enemy))) 367 if (INVOKE_OBJECT (MONSTER_MOVE, op, ARG_OBJECT (op->enemy)))
486 * but that we test above... so can be old code here 486 * but that we test above... so can be old code here
487 */ 487 */
488 if (QUERY_FLAG (op, FLAG_RUN_AWAY)) 488 if (QUERY_FLAG (op, FLAG_RUN_AWAY))
489 dir = absdir (dir + 4); 489 dir = absdir (dir + 4);
490 if (QUERY_FLAG (op, FLAG_CONFUSED)) 490 if (QUERY_FLAG (op, FLAG_CONFUSED))
491 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 491 dir = absdir (dir + rndm (3) + rndm (3) - 2);
492 492
493 if (QUERY_FLAG (op, FLAG_CAST_SPELL) && !(RANDOM () % 3)) 493 if (QUERY_FLAG (op, FLAG_CAST_SPELL) && !(rndm (3)))
494 { 494 {
495 if (monster_cast_spell (op, part, enemy, dir, &rv1)) 495 if (monster_cast_spell (op, part, enemy, dir, &rv1))
496 return 0; 496 return 0;
497 } 497 }
498 498
499 if (QUERY_FLAG (op, FLAG_READY_SCROLL) && !(RANDOM () % 3)) 499 if (QUERY_FLAG (op, FLAG_READY_SCROLL) && !(rndm (3)))
500 { 500 {
501 if (monster_use_scroll (op, part, enemy, dir, &rv1)) 501 if (monster_use_scroll (op, part, enemy, dir, &rv1))
502 return 0; 502 return 0;
503 } 503 }
504 504
505 if (QUERY_FLAG (op, FLAG_READY_RANGE) && !(RANDOM () % 3)) 505 if (QUERY_FLAG (op, FLAG_READY_RANGE) && !(rndm (3)))
506 { 506 {
507 if (monster_use_range (op, part, enemy, dir)) 507 if (monster_use_range (op, part, enemy, dir))
508 return 0; 508 return 0;
509 } 509 }
510 if (QUERY_FLAG (op, FLAG_READY_SKILL) && !(RANDOM () % 3)) 510 if (QUERY_FLAG (op, FLAG_READY_SKILL) && !(rndm (3)))
511 { 511 {
512 if (monster_use_skill (op, rv.part, enemy, rv.direction)) 512 if (monster_use_skill (op, rv.part, enemy, rv.direction))
513 return 0; 513 return 0;
514 } 514 }
515 if (QUERY_FLAG (op, FLAG_READY_BOW) && !(RANDOM () % 2)) 515 if (QUERY_FLAG (op, FLAG_READY_BOW) && !(rndm (2)))
516 { 516 {
517 if (monster_use_bow (op, part, enemy, dir)) 517 if (monster_use_bow (op, part, enemy, dir))
518 return 0; 518 return 0;
519 } 519 }
520 } /* for processing of all parts */ 520 } /* for processing of all parts */
526 526
527 if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) 527 if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY))
528 dir = absdir (dir + 4); 528 dir = absdir (dir + 4);
529 529
530 if (QUERY_FLAG (op, FLAG_CONFUSED)) 530 if (QUERY_FLAG (op, FLAG_CONFUSED))
531 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 531 dir = absdir (dir + rndm (3) + rndm (3) - 2);
532 532
533 pre_att_dir = dir; /* remember the original direction */ 533 pre_att_dir = dir; /* remember the original direction */
534 534
535 if ((op->attack_movement & LO4) && !QUERY_FLAG (op, FLAG_SCARED)) 535 if ((op->attack_movement & LO4) && !QUERY_FLAG (op, FLAG_SCARED))
536 { 536 {
668can_hit (object *ob1, object *ob2, rv_vector * rv) 668can_hit (object *ob1, object *ob2, rv_vector * rv)
669{ 669{
670 object *more; 670 object *more;
671 rv_vector rv1; 671 rv_vector rv1;
672 672
673 if (QUERY_FLAG (ob1, FLAG_CONFUSED) && !(RANDOM () % 3)) 673 if (QUERY_FLAG (ob1, FLAG_CONFUSED) && !(rndm (3)))
674 return 0; 674 return 0;
675 675
676 if (abs (rv->distance_x) < 2 && abs (rv->distance_y) < 2) 676 if (abs (rv->distance_x) < 2 && abs (rv->distance_y) < 2)
677 return 1; 677 return 1;
678 678
787 return 0; /* Might hit owner with spell */ 787 return 0; /* Might hit owner with spell */
788 } 788 }
789 } 789 }
790 790
791 if (QUERY_FLAG (head, FLAG_CONFUSED)) 791 if (QUERY_FLAG (head, FLAG_CONFUSED))
792 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 792 dir = absdir (dir + rndm (3) + rndm (3) - 2);
793 793
794 /* If the monster hasn't already chosen a spell, choose one 794 /* If the monster hasn't already chosen a spell, choose one
795 * I'm not sure if it really make sense to pre-select spells (events 795 * I'm not sure if it really make sense to pre-select spells (events
796 * could be different by the time the monster goes again). 796 * could be different by the time the monster goes again).
797 */ 797 */
864 return 0; /* Might hit owner with spell */ 864 return 0; /* Might hit owner with spell */
865 } 865 }
866 } 866 }
867 867
868 if (QUERY_FLAG (head, FLAG_CONFUSED)) 868 if (QUERY_FLAG (head, FLAG_CONFUSED))
869 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 869 dir = absdir (dir + rndm (3) + rndm (3) - 2);
870 870
871 for (scroll = head->inv; scroll; scroll = scroll->below) 871 for (scroll = head->inv; scroll; scroll = scroll->below)
872 if (scroll->type == SCROLL && monster_should_cast_spell (head, scroll->inv)) 872 if (scroll->type == SCROLL && monster_should_cast_spell (head, scroll->inv))
873 break; 873 break;
874 874
913 913
914 if (dirdiff (dir, dir2) < 1) 914 if (dirdiff (dir, dir2) < 1)
915 return 0; /* Might hit owner with skill -thrown rocks for example ? */ 915 return 0; /* Might hit owner with skill -thrown rocks for example ? */
916 } 916 }
917 if (QUERY_FLAG (head, FLAG_CONFUSED)) 917 if (QUERY_FLAG (head, FLAG_CONFUSED))
918 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 918 dir = absdir (dir + rndm (3) + rndm (3) - 2);
919 919
920 /* skill selection - monster will use the next unused skill. 920 /* skill selection - monster will use the next unused skill.
921 * well...the following scenario will allow the monster to 921 * well...the following scenario will allow the monster to
922 * toggle between 2 skills. One day it would be nice to make 922 * toggle between 2 skills. One day it would be nice to make
923 * more skills available to monsters. 923 * more skills available to monsters.
957 957
958 if (dirdiff (dir, dir2) < 2) 958 if (dirdiff (dir, dir2) < 2)
959 return 0; /* Might hit owner with spell */ 959 return 0; /* Might hit owner with spell */
960 } 960 }
961 if (QUERY_FLAG (head, FLAG_CONFUSED)) 961 if (QUERY_FLAG (head, FLAG_CONFUSED))
962 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 962 dir = absdir (dir + rndm (3) + rndm (3) - 2);
963 963
964 for (wand = head->inv; wand != NULL; wand = wand->below) 964 for (wand = head->inv; wand != NULL; wand = wand->below)
965 { 965 {
966 if (wand->type == WAND) 966 if (wand->type == WAND)
967 { 967 {
1017 object *owner; 1017 object *owner;
1018 1018
1019 if (!(dir = path_to_player (part, pl, 0))) 1019 if (!(dir = path_to_player (part, pl, 0)))
1020 return 0; 1020 return 0;
1021 if (QUERY_FLAG (head, FLAG_CONFUSED)) 1021 if (QUERY_FLAG (head, FLAG_CONFUSED))
1022 dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); 1022 dir = absdir (dir + rndm (3) + rndm (3) - 2);
1023 1023
1024 if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) 1024 if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL)
1025 { 1025 {
1026 int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); 1026 int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y);
1027 1027
1517{ 1517{
1518 static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 }; 1518 static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 };
1519 if (++ob->move_status > 11) 1519 if (++ob->move_status > 11)
1520 ob->move_status = 0; 1520 ob->move_status = 0;
1521 if (!(move_object (ob, circle[ob->move_status]))) 1521 if (!(move_object (ob, circle[ob->move_status])))
1522 (void) move_object (ob, RANDOM () % 8 + 1); 1522 (void) move_object (ob, rndm (8) + 1);
1523} 1523}
1524 1524
1525void 1525void
1526circ2_move (object *ob) 1526circ2_move (object *ob)
1527{ 1527{
1528 static int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 }; 1528 static int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 };
1529 if (++ob->move_status > 19) 1529 if (++ob->move_status > 19)
1530 ob->move_status = 0; 1530 ob->move_status = 0;
1531 if (!(move_object (ob, circle[ob->move_status]))) 1531 if (!(move_object (ob, circle[ob->move_status])))
1532 (void) move_object (ob, RANDOM () % 8 + 1); 1532 (void) move_object (ob, rndm (8) + 1);
1533} 1533}
1534 1534
1535void 1535void
1536pace_movev (object *ob) 1536pace_movev (object *ob)
1537{ 1537{
1587void 1587void
1588rand_move (object *ob) 1588rand_move (object *ob)
1589{ 1589{
1590 int i; 1590 int i;
1591 1591
1592 if (ob->move_status < 1 || ob->move_status > 8 || !(move_object (ob, ob->move_status || !(RANDOM () % 9)))) 1592 if (ob->move_status < 1 || ob->move_status > 8 || !(move_object (ob, ob->move_status || !(rndm (9)))))
1593 for (i = 0; i < 5; i++) 1593 for (i = 0; i < 5; i++)
1594 if (move_object (ob, ob->move_status = RANDOM () % 8 + 1)) 1594 if (move_object (ob, ob->move_status = rndm (8) + 1))
1595 return; 1595 return;
1596} 1596}
1597 1597
1598void 1598void
1599check_earthwalls (object *op, maptile *m, int x, int y) 1599check_earthwalls (object *op, maptile *m, int x, int y)
1780 /* ah, we are within range, detected? take cases */ 1780 /* ah, we are within range, detected? take cases */
1781 if (!enemy->invisible) /* enemy in dark squares... are seen! */ 1781 if (!enemy->invisible) /* enemy in dark squares... are seen! */
1782 return 1; 1782 return 1;
1783 1783
1784 /* hidden or low-quality invisible */ 1784 /* hidden or low-quality invisible */
1785 if (enemy->hide && (rv->distance <= 1) && (RANDOM () % 100 <= hide_discovery)) 1785 if (enemy->hide && (rv->distance <= 1) && (rndm (100) <= hide_discovery))
1786 { 1786 {
1787 make_visible (enemy); 1787 make_visible (enemy);
1788 /* inform players of new status */ 1788 /* inform players of new status */
1789 if (enemy->type == PLAYER && player_can_view (enemy, op)) 1789 if (enemy->type == PLAYER && player_can_view (enemy, op))
1790 new_draw_info_format (NDI_UNIQUE, 0, enemy, "You are discovered by %s!", &op->name); 1790 new_draw_info_format (NDI_UNIQUE, 0, enemy, "You are discovered by %s!", &op->name);
1797 * do something to you. Decreasing the duration of invisible 1797 * do something to you. Decreasing the duration of invisible
1798 * doesn't make a lot of sense IMO, as a bunch of stupid creatures 1798 * doesn't make a lot of sense IMO, as a bunch of stupid creatures
1799 * can then basically negate the spell. The spell isn't negated - 1799 * can then basically negate the spell. The spell isn't negated -
1800 * they just know where you are! 1800 * they just know where you are!
1801 */ 1801 */
1802 if ((RANDOM () % 50) <= hide_discovery) 1802 if ((rndm (50)) <= hide_discovery)
1803 { 1803 {
1804 if (enemy->type == PLAYER) 1804 if (enemy->type == PLAYER)
1805 { 1805 {
1806 new_draw_info_format (NDI_UNIQUE, 0, enemy, "You see %s noticing your position.", query_name (op)); 1806 new_draw_info_format (NDI_UNIQUE, 0, enemy, "You see %s noticing your position.", query_name (op));
1807 } 1807 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines