… | |
… | |
3076 | } |
3076 | } |
3077 | |
3077 | |
3078 | if (basic_flag == AP_UNAPPLY) |
3078 | if (basic_flag == AP_UNAPPLY) |
3079 | return 0; |
3079 | return 0; |
3080 | |
3080 | |
|
|
3081 | // if the item is combat/ranged, wield the relevant slot first |
|
|
3082 | // to resolve conflicts. |
|
|
3083 | if (player *pl = who->contr) |
|
|
3084 | switch (op->type) |
|
|
3085 | { |
|
|
3086 | case WEAPON: |
|
|
3087 | who->change_weapon (pl->combat_ob); |
|
|
3088 | break; |
|
|
3089 | |
|
|
3090 | case BOW: |
|
|
3091 | case ROD: |
|
|
3092 | case WAND: |
|
|
3093 | case HORN: |
|
|
3094 | case SKILL_TOOL: |
|
|
3095 | who->change_weapon (pl->ranged_ob); |
|
|
3096 | break; |
|
|
3097 | |
|
|
3098 | case SKILL: |
|
|
3099 | if (IS_COMBAT_SKILL (op->subtype)) |
|
|
3100 | who->change_weapon (pl->combat_ob); |
|
|
3101 | else if (IS_RANGED_SKILL (op->subtype)) |
|
|
3102 | who->change_weapon (pl->ranged_ob); |
|
|
3103 | break; |
|
|
3104 | } |
|
|
3105 | |
3081 | /* Can't just apply this object. Lets see what not and what to do */ |
3106 | /* Can't just apply this object. Lets see what not and what to do */ |
3082 | if (int i = can_apply_object (who, op)) |
3107 | if (int i = can_apply_object (who, op)) |
3083 | { |
3108 | { |
3084 | if (i & CAN_APPLY_NEVER) |
3109 | if (i & CAN_APPLY_NEVER) |
3085 | { |
3110 | { |
… | |
… | |
3186 | |
3211 | |
3187 | SET_FLAG (op, FLAG_APPLIED); |
3212 | SET_FLAG (op, FLAG_APPLIED); |
3188 | change_skill (who, skop, 1); |
3213 | change_skill (who, skop, 1); |
3189 | |
3214 | |
3190 | if (who->contr) |
3215 | if (who->contr) |
3191 | who->set_weapon (who->contr->combat_ob = op); |
3216 | who->change_weapon (who->contr->combat_ob = op); |
3192 | |
3217 | |
3193 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
3218 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
3194 | SET_FLAG (who, FLAG_READY_WEAPON); |
3219 | SET_FLAG (who, FLAG_READY_WEAPON); |
3195 | |
3220 | |
3196 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3221 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
… | |
… | |
3274 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3299 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3275 | { |
3300 | { |
3276 | for (object *item = who->inv; item; item = item->below) |
3301 | for (object *item = who->inv; item; item = item->below) |
3277 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3302 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3278 | { |
3303 | { |
3279 | who->set_weapon (pl->combat_ob = item); |
3304 | who->change_weapon (pl->combat_ob = item); |
3280 | goto found_weapon; |
3305 | goto found_weapon; |
3281 | } |
3306 | } |
3282 | |
3307 | |
3283 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); |
3308 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); |
3284 | return 1; |
3309 | return 1; |
3285 | |
3310 | |
3286 | found_weapon:; |
3311 | found_weapon:; |
3287 | } |
3312 | } |
3288 | else |
3313 | else |
3289 | who->set_weapon (pl->combat_ob = op); |
3314 | who->change_weapon (pl->combat_ob = op); |
3290 | } |
3315 | } |
3291 | else if (IS_RANGED_SKILL (op->subtype)) |
3316 | else if (IS_RANGED_SKILL (op->subtype)) |
3292 | { |
3317 | { |
3293 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3318 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3294 | { |
3319 | { |
3295 | for (object *item = who->inv; item; item = item->below) |
3320 | for (object *item = who->inv; item; item = item->below) |
3296 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3321 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3297 | { |
3322 | { |
3298 | who->set_weapon (pl->ranged_ob = item); |
3323 | who->change_weapon (pl->ranged_ob = item); |
3299 | goto found_bow; |
3324 | goto found_bow; |
3300 | } |
3325 | } |
3301 | |
3326 | |
3302 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3327 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3303 | return 1; |
3328 | return 1; |
… | |
… | |
3308 | { |
3333 | { |
3309 | for (object *item = who->inv; item; item = item->below) |
3334 | for (object *item = who->inv; item; item = item->below) |
3310 | if (item->flag [FLAG_APPLIED] |
3335 | if (item->flag [FLAG_APPLIED] |
3311 | && (item->type == WAND || item->type == ROD || item->type == HORN)) |
3336 | && (item->type == WAND || item->type == ROD || item->type == HORN)) |
3312 | { |
3337 | { |
3313 | who->set_weapon (pl->ranged_ob = item); |
3338 | who->change_weapon (pl->ranged_ob = item); |
3314 | goto found_item; |
3339 | goto found_item; |
3315 | } |
3340 | } |
3316 | |
3341 | |
3317 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); |
3342 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); |
3318 | return 1; |
3343 | return 1; |
3319 | |
3344 | |
3320 | found_item:; |
3345 | found_item:; |
3321 | } |
3346 | } |
3322 | else |
3347 | else |
3323 | who->set_weapon (pl->ranged_ob = op); |
3348 | who->change_weapon (pl->ranged_ob = op); |
3324 | } |
3349 | } |
3325 | |
3350 | |
3326 | if (!op->invisible) |
3351 | if (!op->invisible) |
3327 | { |
3352 | { |
3328 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |
3353 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |