… | |
… | |
272 | } |
272 | } |
273 | |
273 | |
274 | return 0; |
274 | return 0; |
275 | } |
275 | } |
276 | |
276 | |
277 | int |
277 | static int |
278 | move_randomly (object *op) |
278 | move_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 (move_object (op, rndm (8) + 1)) |
… | |
… | |
873 | /* Returns a randomly selected spell. This logic is still |
873 | /* Returns a randomly selected spell. This logic is still |
874 | * less than ideal. This code also only seems to deal with |
874 | * less than ideal. This code also only seems to deal with |
875 | * wizard spells, as the check is against sp, and not grace. |
875 | * wizard spells, as the check is against sp, and not grace. |
876 | * can mosnters know cleric spells? |
876 | * can mosnters know cleric spells? |
877 | */ |
877 | */ |
878 | object * |
878 | static object * |
879 | monster_choose_random_spell (object *monster) |
879 | monster_choose_random_spell (object *monster) |
880 | { |
880 | { |
881 | object *altern[MAX_KNOWN_SPELLS]; |
881 | object *altern[MAX_KNOWN_SPELLS]; |
882 | int i = 0; |
882 | int i = 0; |
883 | |
883 | |
… | |
… | |
906 | * part is the part of the monster we are checking against. |
906 | * part is the part of the monster we are checking against. |
907 | * pl is the target. |
907 | * pl is the target. |
908 | * dir is the direction to case. |
908 | * dir is the direction to case. |
909 | * rv is the vector which describes where the enemy is. |
909 | * rv is the vector which describes where the enemy is. |
910 | */ |
910 | */ |
911 | int |
911 | static int |
912 | monster_cast_spell (object *head, object *part, object *pl, int dir, rv_vector * rv) |
912 | monster_cast_spell (object *head, object *part, object *pl, int dir, rv_vector * rv) |
913 | { |
913 | { |
914 | object *spell_item; |
914 | object *spell_item; |
915 | object *owner; |
915 | object *owner; |
916 | rv_vector rv1; |
916 | rv_vector rv1; |
… | |
… | |
982 | head->spellitem = NULL; |
982 | head->spellitem = NULL; |
983 | |
983 | |
984 | return cast_spell (part, part, dir, spell_item, NULL); |
984 | return cast_spell (part, part, dir, spell_item, NULL); |
985 | } |
985 | } |
986 | |
986 | |
987 | int |
987 | static int |
988 | monster_use_scroll (object *head, object *part, object *pl, int dir, rv_vector * rv) |
988 | monster_use_scroll (object *head, object *part, object *pl, int dir, rv_vector * rv) |
989 | { |
989 | { |
990 | object *scroll; |
990 | object *scroll; |
991 | object *owner; |
991 | object *owner; |
992 | rv_vector rv1; |
992 | rv_vector rv1; |
… | |
… | |
1040 | * The skills we are treating here are all but those. -b.t. |
1040 | * The skills we are treating here are all but those. -b.t. |
1041 | * |
1041 | * |
1042 | * At the moment this is only useful for throwing, perhaps for |
1042 | * At the moment this is only useful for throwing, perhaps for |
1043 | * stealing. TODO: This should be more integrated in the game. -MT, 25.11.01 |
1043 | * stealing. TODO: This should be more integrated in the game. -MT, 25.11.01 |
1044 | */ |
1044 | */ |
1045 | int |
1045 | static int |
1046 | monster_use_skill (object *head, object *part, object *pl, int dir) |
1046 | monster_use_skill (object *head, object *part, object *pl, int dir) |
1047 | { |
1047 | { |
1048 | object *skill, *owner; |
1048 | object *skill, *owner; |
1049 | |
1049 | |
1050 | if (!(dir = path_to_player (part, pl, 0))) |
1050 | if (!(dir = path_to_player (part, pl, 0))) |
… | |
… | |
1083 | /* use skill */ |
1083 | /* use skill */ |
1084 | return do_skill (head, part, head->chosen_skill, dir, NULL); |
1084 | return do_skill (head, part, head->chosen_skill, dir, NULL); |
1085 | } |
1085 | } |
1086 | |
1086 | |
1087 | /* Monster will use a ranged spell attack. */ |
1087 | /* Monster will use a ranged spell attack. */ |
1088 | int |
1088 | static int |
1089 | monster_use_range (object *head, object *part, object *pl, int dir) |
1089 | monster_use_range (object *head, object *part, object *pl, int dir) |
1090 | { |
1090 | { |
1091 | object *wand, *owner; |
1091 | object *wand, *owner; |
1092 | int at_least_one = 0; |
1092 | int at_least_one = 0; |
1093 | |
1093 | |
… | |
… | |
1153 | LOG (llevError, "Error: Monster %s (%d) HAS_READY_RANGE() without wand/horn/rod.\n", &head->name, head->count); |
1153 | LOG (llevError, "Error: Monster %s (%d) HAS_READY_RANGE() without wand/horn/rod.\n", &head->name, head->count); |
1154 | CLEAR_FLAG (head, FLAG_READY_RANGE); |
1154 | CLEAR_FLAG (head, FLAG_READY_RANGE); |
1155 | return 0; |
1155 | return 0; |
1156 | } |
1156 | } |
1157 | |
1157 | |
1158 | int |
1158 | static int |
1159 | monster_use_bow (object *head, object *part, object *pl, int dir) |
1159 | monster_use_bow (object *head, object *part, object *pl, int dir) |
1160 | { |
1160 | { |
1161 | object *owner; |
1161 | object *owner; |
1162 | |
1162 | |
1163 | if (!(dir = path_to_player (part, pl, 0))) |
1163 | if (!(dir = path_to_player (part, pl, 0))) |