… | |
… | |
321 | * exp - no caller needed that info, but it also prevented the callers |
321 | * exp - no caller needed that info, but it also prevented the callers |
322 | * from know if a skill was actually used, as many skills don't |
322 | * from know if a skill was actually used, as many skills don't |
323 | * give any exp for their direct use (eg, throwing). |
323 | * give any exp for their direct use (eg, throwing). |
324 | * It returns 0 if no skill was used. |
324 | * It returns 0 if no skill was used. |
325 | */ |
325 | */ |
326 | |
|
|
327 | int |
326 | int |
328 | do_skill (object *op, object *part, object *skill, int dir, const char *string) |
327 | do_skill (object *op, object *part, object *skill, int dir, const char *string) |
329 | { |
328 | { |
330 | int success = 0, exp = 0; |
329 | int success = 0, exp = 0; |
331 | int did_alc = 0; |
330 | int did_alc = 0; |
… | |
… | |
907 | * the damage. |
906 | * the damage. |
908 | */ |
907 | */ |
909 | static int |
908 | static int |
910 | do_skill_attack (object *tmp, object *op, const char *string, object *skill) |
909 | do_skill_attack (object *tmp, object *op, const char *string, object *skill) |
911 | { |
910 | { |
912 | int success; |
|
|
913 | |
|
|
914 | if (INVOKE_OBJECT (SKILL_ATTACK, op, ARG_OBJECT (tmp), ARG_STRING (string), ARG_OBJECT (skill))) |
911 | if (INVOKE_OBJECT (SKILL_ATTACK, op, ARG_OBJECT (tmp), ARG_STRING (string), ARG_OBJECT (skill))) |
915 | return RESULT_INT (0); |
912 | return RESULT_INT (0); |
916 | |
913 | |
917 | /* For Players only: if there is no ready weapon, and no "attack" skill |
914 | /* For Players only: if there is no ready weapon, and no "attack" skill |
918 | * is readied either then try to find a skill for the player to use. |
915 | * is readied either then try to find a skill for the player to use. |
… | |
… | |
970 | LOG (llevError, "Could not find applied weapon on %s\n", &op->name); |
967 | LOG (llevError, "Could not find applied weapon on %s\n", &op->name); |
971 | op->current_weapon = NULL; |
968 | op->current_weapon = NULL; |
972 | return 0; |
969 | return 0; |
973 | } |
970 | } |
974 | else |
971 | else |
975 | { |
|
|
976 | op->current_weapon = tmp; |
972 | op->current_weapon = tmp; |
977 | } |
|
|
978 | } |
973 | } |
979 | |
974 | |
980 | change_skill (op, find_skill_by_name (op, op->current_weapon->skill), 1); |
975 | change_skill (op, find_skill_by_name (op, op->current_weapon->skill), 1); |
981 | } |
976 | } |
982 | } |
977 | } |
… | |
… | |
989 | op->invisible = 0; |
984 | op->invisible = 0; |
990 | op->hide = 0; |
985 | op->hide = 0; |
991 | update_object (op, UP_OBJ_CHANGE); |
986 | update_object (op, UP_OBJ_CHANGE); |
992 | } |
987 | } |
993 | |
988 | |
994 | success = attack_ob (tmp, op); |
989 | int success = attack_ob (tmp, op); |
995 | |
990 | |
996 | /* print appropriate messages to the player */ |
991 | /* print appropriate messages to the player */ |
997 | |
992 | |
998 | if (success && string != NULL && tmp && !QUERY_FLAG (tmp, FLAG_FREED)) |
993 | if (success && string && tmp && !QUERY_FLAG (tmp, FLAG_FREED)) |
999 | { |
994 | { |
1000 | if (op->type == PLAYER) |
995 | if (op->type == PLAYER) |
1001 | new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp)); |
996 | new_draw_info_format (NDI_UNIQUE, 0, op, "You %s %s!", string, query_name (tmp)); |
1002 | else if (tmp->type == PLAYER) |
997 | else if (tmp->type == PLAYER) |
1003 | new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string); |
998 | new_draw_info_format (NDI_UNIQUE, 0, tmp, "%s %s you!", query_name (op), string); |
… | |
… | |
1031 | ty = freearr_y[dir]; |
1026 | ty = freearr_y[dir]; |
1032 | |
1027 | |
1033 | /* If we don't yet have an opponent, find if one exists, and attack. |
1028 | /* If we don't yet have an opponent, find if one exists, and attack. |
1034 | * Legal opponents are the same as outlined in move_player_attack() |
1029 | * Legal opponents are the same as outlined in move_player_attack() |
1035 | */ |
1030 | */ |
1036 | |
1031 | if (!tmp) |
1037 | if (tmp == NULL) |
|
|
1038 | { |
1032 | { |
1039 | m = pl->map; |
1033 | m = pl->map; |
1040 | tx = pl->x + freearr_x[dir]; |
1034 | tx = pl->x + freearr_x[dir]; |
1041 | ty = pl->y + freearr_y[dir]; |
1035 | ty = pl->y + freearr_y[dir]; |
1042 | |
1036 | |
… | |
… | |
1052 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR) |
1046 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->stats.hp >= 0) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || tmp->type == LOCKED_DOOR) |
1053 | { |
1047 | { |
1054 | /* Don't attack party members */ |
1048 | /* Don't attack party members */ |
1055 | if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party)) |
1049 | if ((pl->type == PLAYER && tmp->type == PLAYER) && (pl->contr->party != NULL && pl->contr->party == tmp->contr->party)) |
1056 | return 0; |
1050 | return 0; |
|
|
1051 | |
1057 | break; |
1052 | break; |
1058 | } |
1053 | } |
1059 | } |
1054 | } |
|
|
1055 | |
1060 | if (!tmp) |
1056 | if (!tmp) |
1061 | { |
1057 | { |
1062 | if (pl->type == PLAYER) |
1058 | if (pl->type == PLAYER) |
1063 | new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to attack!"); |
1059 | new_draw_info (NDI_UNIQUE, 0, pl, "There is nothing to attack!"); |
|
|
1060 | |
1064 | return 0; |
1061 | return 0; |
1065 | } |
1062 | } |
1066 | |
1063 | |
1067 | return do_skill_attack (tmp, pl, string, skill); |
1064 | return do_skill_attack (tmp, pl, string, skill); |
1068 | } |
1065 | } |