… | |
… | |
490 | /* hm, not sure about this part - in original was a scared flag here too |
490 | /* hm, not sure about this part - in original was a scared flag here too |
491 | * but that we test above... so can be old code here |
491 | * but that we test above... so can be old code here |
492 | */ |
492 | */ |
493 | if (QUERY_FLAG (op, FLAG_RUN_AWAY)) |
493 | if (QUERY_FLAG (op, FLAG_RUN_AWAY)) |
494 | dir = absdir (dir + 4); |
494 | dir = absdir (dir + 4); |
|
|
495 | |
495 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
496 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
496 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
497 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
497 | |
498 | |
498 | if (QUERY_FLAG (op, FLAG_CAST_SPELL) && !(rndm (3))) |
499 | if (QUERY_FLAG (op, FLAG_CAST_SPELL) && !(rndm (3))) |
499 | { |
|
|
500 | if (monster_cast_spell (op, part, enemy, dir, &rv1)) |
500 | if (monster_cast_spell (op, part, enemy, dir, &rv1)) |
501 | return 0; |
501 | return 0; |
502 | } |
|
|
503 | |
502 | |
504 | if (QUERY_FLAG (op, FLAG_READY_SCROLL) && !(rndm (3))) |
503 | if (QUERY_FLAG (op, FLAG_READY_SCROLL) && !(rndm (3))) |
505 | { |
|
|
506 | if (monster_use_scroll (op, part, enemy, dir, &rv1)) |
504 | if (monster_use_scroll (op, part, enemy, dir, &rv1)) |
507 | return 0; |
505 | return 0; |
508 | } |
|
|
509 | |
506 | |
510 | if (QUERY_FLAG (op, FLAG_READY_RANGE) && !(rndm (3))) |
507 | if (QUERY_FLAG (op, FLAG_READY_RANGE) && !(rndm (3))) |
511 | { |
|
|
512 | if (monster_use_range (op, part, enemy, dir)) |
508 | if (monster_use_range (op, part, enemy, dir)) |
513 | return 0; |
509 | return 0; |
514 | } |
510 | |
515 | if (QUERY_FLAG (op, FLAG_READY_SKILL) && !(rndm (3))) |
511 | if (QUERY_FLAG (op, FLAG_READY_SKILL) && !(rndm (3))) |
516 | { |
|
|
517 | if (monster_use_skill (op, rv.part, enemy, rv.direction)) |
512 | if (monster_use_skill (op, rv.part, enemy, rv.direction)) |
518 | return 0; |
513 | return 0; |
519 | } |
514 | |
520 | if (QUERY_FLAG (op, FLAG_READY_BOW) && !(rndm (2))) |
515 | if (QUERY_FLAG (op, FLAG_READY_BOW) && !(rndm (2))) |
521 | { |
|
|
522 | if (monster_use_bow (op, part, enemy, dir)) |
516 | if (monster_use_bow (op, part, enemy, dir)) |
523 | return 0; |
517 | return 0; |
524 | } |
|
|
525 | } /* for processing of all parts */ |
518 | } /* for processing of all parts */ |
526 | } /* If not scared */ |
519 | } /* If not scared */ |
527 | |
520 | |
528 | |
521 | |
529 | part = rv.part; |
522 | part = rv.part; |
… | |
… | |
960 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
953 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
961 | |
954 | |
962 | if (dirdiff (dir, dir2) < 2) |
955 | if (dirdiff (dir, dir2) < 2) |
963 | return 0; /* Might hit owner with spell */ |
956 | return 0; /* Might hit owner with spell */ |
964 | } |
957 | } |
|
|
958 | |
965 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
959 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
966 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
960 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
967 | |
961 | |
968 | for (wand = head->inv; wand; wand = wand->below) |
962 | for (wand = head->inv; wand; wand = wand->below) |
969 | { |
963 | { |
… | |
… | |
1008 | } |
1002 | } |
1009 | |
1003 | |
1010 | if (at_least_one) |
1004 | if (at_least_one) |
1011 | return 0; |
1005 | return 0; |
1012 | |
1006 | |
1013 | LOG (llevError, "Error: Monster %s (%d) HAS_READY_RANG() without wand/horn/rod.\n", &head->name, head->count); |
1007 | LOG (llevError, "Error: Monster %s (%d) HAS_READY_RANGE() without wand/horn/rod.\n", &head->name, head->count); |
1014 | CLEAR_FLAG (head, FLAG_READY_RANGE); |
1008 | CLEAR_FLAG (head, FLAG_READY_RANGE); |
1015 | return 0; |
1009 | return 0; |
1016 | } |
1010 | } |
1017 | |
1011 | |
1018 | int |
1012 | int |
… | |
… | |
1020 | { |
1014 | { |
1021 | object *owner; |
1015 | object *owner; |
1022 | |
1016 | |
1023 | if (!(dir = path_to_player (part, pl, 0))) |
1017 | if (!(dir = path_to_player (part, pl, 0))) |
1024 | return 0; |
1018 | return 0; |
|
|
1019 | |
1025 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
1020 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
1026 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
1021 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
1027 | |
1022 | |
1028 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
1023 | if (QUERY_FLAG (head, FLAG_FRIENDLY) && (owner = head->owner) != NULL) |
1029 | { |
1024 | { |
… | |
… | |
1037 | return fire_bow (head, part, NULL, dir, 0, part->x, part->y); |
1032 | return fire_bow (head, part, NULL, dir, 0, part->x, part->y); |
1038 | |
1033 | |
1039 | } |
1034 | } |
1040 | |
1035 | |
1041 | /* Checks if putting on 'item' will make 'who' do more |
1036 | /* Checks if putting on 'item' will make 'who' do more |
1042 | * damage. This is a very simplistic check - also checking things |
1037 | * damage. This is a very simplistic check - also checking things |
1043 | * like speed and ac are also relevant. |
1038 | * like speed and ac are also relevant. |
1044 | * |
1039 | * |
1045 | * return true if item is a better object. |
1040 | * return true if item is a better object. |
1046 | */ |
1041 | */ |
1047 | |
|
|
1048 | int |
1042 | int |
1049 | check_good_weapon (object *who, object *item) |
1043 | check_good_weapon (object *who, object *item) |
1050 | { |
1044 | { |
1051 | object *other_weap; |
1045 | object *other_weap; |
1052 | int val = 0, i; |
1046 | int val = 0, i; |
1053 | |
1047 | |
1054 | for (other_weap = who->inv; other_weap != NULL; other_weap = other_weap->below) |
1048 | for (other_weap = who->inv; other_weap; other_weap = other_weap->below) |
1055 | if (other_weap->type == item->type && QUERY_FLAG (other_weap, FLAG_APPLIED)) |
1049 | if (other_weap->type == item->type && QUERY_FLAG (other_weap, FLAG_APPLIED)) |
1056 | break; |
1050 | break; |
1057 | |
1051 | |
1058 | if (other_weap == NULL) /* No other weapons */ |
1052 | if (!other_weap) /* No other weapons */ |
1059 | return 1; |
1053 | return 1; |
1060 | |
1054 | |
1061 | /* Rather than go through and apply the new one, and see if it is |
1055 | /* Rather than go through and apply the new one, and see if it is |
1062 | * better, just do some simple checks |
1056 | * better, just do some simple checks |
1063 | * Put some multipliers for things that hvae several effects, |
1057 | * Put some multipliers for things that hvae several effects, |