… | |
… | |
2834 | * another function that does just that. |
2834 | * another function that does just that. |
2835 | */ |
2835 | */ |
2836 | int |
2836 | int |
2837 | unapply_for_ob (object *who, object *op, int aflags) |
2837 | unapply_for_ob (object *who, object *op, int aflags) |
2838 | { |
2838 | { |
2839 | /* If we are applying a shield or weapon, unapply any equipped shield |
|
|
2840 | * or weapons first - only allowed to use one weapon/shield at a time. |
|
|
2841 | */ |
|
|
2842 | if (op->type == WEAPON || op->type == SHIELD) |
|
|
2843 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
|
|
2844 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == op->type) |
|
|
2845 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
|
|
2846 | { |
|
|
2847 | if (aflags & AP_PRINT) |
|
|
2848 | new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); |
|
|
2849 | else |
|
|
2850 | unapply_special (who, tmp, aflags); |
|
|
2851 | } |
|
|
2852 | else |
|
|
2853 | { |
|
|
2854 | /* In this case, we want to try and remove a cursed item. |
|
|
2855 | * While we know it won't work, we want unapply_special to |
|
|
2856 | * at least generate the message. |
|
|
2857 | */ |
|
|
2858 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove the %s.", query_name (tmp)); |
|
|
2859 | return 1; |
|
|
2860 | } |
|
|
2861 | |
|
|
2862 | if (op->is_range ()) |
2839 | if (op->is_range ()) |
2863 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2840 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2864 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
2841 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
2865 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
2842 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
2866 | { |
2843 | { |
… | |
… | |
2950 | if (INVOKE_OBJECT (CAN_BE_APPLIED, op, ARG_OBJECT (who)) || INVOKE_OBJECT (CAN_APPLY, who, ARG_OBJECT (op))) |
2927 | if (INVOKE_OBJECT (CAN_BE_APPLIED, op, ARG_OBJECT (who)) || INVOKE_OBJECT (CAN_APPLY, who, ARG_OBJECT (op))) |
2951 | return RESULT_INT (0); |
2928 | return RESULT_INT (0); |
2952 | |
2929 | |
2953 | int retval = 0; |
2930 | int retval = 0; |
2954 | object *tmp = 0, *ws = 0; |
2931 | object *tmp = 0, *ws = 0; |
2955 | |
|
|
2956 | /* Players have 2 'arm's, so they could in theory equip 2 shields or |
|
|
2957 | * 2 weapons, but we don't want to let them do that. So if they are |
|
|
2958 | * trying to equip a weapon or shield, see if they already have one |
|
|
2959 | * in place and store that way. |
|
|
2960 | */ |
|
|
2961 | if (op->type == WEAPON || op->type == SHIELD) |
|
|
2962 | for (tmp = who->inv; tmp && !ws; tmp = tmp->below) |
|
|
2963 | if (tmp->flag [FLAG_APPLIED] && tmp->type == op->type) |
|
|
2964 | { |
|
|
2965 | retval = CAN_APPLY_UNAPPLY; |
|
|
2966 | ws = tmp; |
|
|
2967 | } |
|
|
2968 | |
|
|
2969 | if (op->is_range ()) |
|
|
2970 | for (tmp = who->inv; tmp && !ws; tmp = tmp->below) |
|
|
2971 | if (tmp->flag [FLAG_APPLIED] && tmp->is_range ()) |
|
|
2972 | { |
|
|
2973 | retval = CAN_APPLY_UNAPPLY; |
|
|
2974 | ws = tmp; |
|
|
2975 | } |
|
|
2976 | |
2932 | |
2977 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2933 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2978 | { |
2934 | { |
2979 | if (op->slot[i].info) |
2935 | if (op->slot[i].info) |
2980 | { |
2936 | { |