… | |
… | |
424 | * then calls improve_weapon to do the dirty work. |
424 | * then calls improve_weapon to do the dirty work. |
425 | */ |
425 | */ |
426 | static int |
426 | static int |
427 | check_improve_weapon (object *op, object *tmp) |
427 | check_improve_weapon (object *op, object *tmp) |
428 | { |
428 | { |
429 | object *otmp; |
|
|
430 | |
|
|
431 | if (op->type != PLAYER) |
429 | if (op->type != PLAYER) |
432 | return 0; |
430 | return 0; |
433 | |
431 | |
434 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
432 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
435 | { |
433 | { |
436 | op->failmsg ("Something blocks the magic of the scroll!"); |
434 | op->failmsg ("Something blocks the magic of the scroll!"); |
437 | return 0; |
435 | return 0; |
438 | } |
436 | } |
439 | |
437 | |
440 | otmp = find_marked_object (op); |
438 | object *otmp = op->mark (); |
441 | |
439 | |
442 | if (!otmp) |
440 | if (!otmp) |
443 | { |
441 | { |
444 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
442 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
445 | return 0; |
443 | return 0; |
446 | } |
444 | } |
447 | |
445 | |
448 | if (otmp->type != WEAPON && otmp->type != BOW) |
446 | if (otmp->type != WEAPON && otmp->type != BOW) |
449 | { |
447 | { |
450 | op->failmsg ("Marked item is not a weapon or bow!"); |
448 | op->failmsg ("Marked item is not a weapon or bow!"); |
|
|
449 | return 0; |
|
|
450 | } |
|
|
451 | |
|
|
452 | if (!op->apply (otmp, AP_UNAPPLY)) |
|
|
453 | { |
|
|
454 | op->failmsg ("You are unable to take off your weapon to improve it!"); |
451 | return 0; |
455 | return 0; |
452 | } |
456 | } |
453 | |
457 | |
454 | op->statusmsg ("Applied weapon builder."); |
458 | op->statusmsg ("Applied weapon builder."); |
455 | |
459 | |
… | |
… | |
481 | * changing of physical area right now. |
485 | * changing of physical area right now. |
482 | */ |
486 | */ |
483 | static int |
487 | static int |
484 | improve_armour (object *op, object *improver, object *armour) |
488 | improve_armour (object *op, object *improver, object *armour) |
485 | { |
489 | { |
486 | object *tmp; |
|
|
487 | |
|
|
488 | if (armour->magic >= settings.armor_max_enchant) |
490 | if (armour->magic >= settings.armor_max_enchant) |
489 | { |
491 | { |
490 | op->failmsg ("This armour can not be enchanted any further!"); |
492 | op->failmsg ("This armour can not be enchanted any further!"); |
491 | return 0; |
493 | return 0; |
492 | } |
494 | } |
… | |
… | |
503 | } |
505 | } |
504 | |
506 | |
505 | /* Split objects if needed. Can't insert tmp until the |
507 | /* Split objects if needed. Can't insert tmp until the |
506 | * end of this function - otherwise it will just re-merge. |
508 | * end of this function - otherwise it will just re-merge. |
507 | */ |
509 | */ |
508 | tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
510 | object *tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
509 | |
511 | |
510 | armour->magic++; |
512 | armour->magic++; |
511 | |
513 | |
512 | if (!settings.armor_speed_linear) |
514 | if (!settings.armor_speed_linear) |
513 | { |
515 | { |
… | |
… | |
1759 | return 0; |
1761 | return 0; |
1760 | |
1762 | |
1761 | /* if the player has a marked item, identify that if it needs to be |
1763 | /* if the player has a marked item, identify that if it needs to be |
1762 | * identified. If it doesn't, then go through the player inventory. |
1764 | * identified. If it doesn't, then go through the player inventory. |
1763 | */ |
1765 | */ |
1764 | if (object *marked = find_marked_object (pl)) |
1766 | if (object *marked = pl->mark ()) |
1765 | if (!marked->flag [FLAG_IDENTIFIED] && need_identify (marked)) |
1767 | if (!marked->flag [FLAG_IDENTIFIED] && need_identify (marked)) |
1766 | { |
1768 | { |
1767 | if (operate_altar (altar, &money, pl)) |
1769 | if (operate_altar (altar, &money, pl)) |
1768 | { |
1770 | { |
1769 | identify (marked); |
1771 | identify (marked); |
… | |
… | |
2646 | int exp_gain = 0; |
2648 | int exp_gain = 0; |
2647 | |
2649 | |
2648 | /* hard code literacy - tmp->skill points to where the exp |
2650 | /* hard code literacy - tmp->skill points to where the exp |
2649 | * should go for anything killed by the spell. |
2651 | * should go for anything killed by the spell. |
2650 | */ |
2652 | */ |
2651 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
2653 | skop = find_skill_by_name (op, shstr_literacy); |
2652 | |
2654 | |
2653 | if (!skop) |
2655 | if (!skop) |
2654 | { |
2656 | { |
2655 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY]); |
2657 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
2656 | return; |
2658 | return; |
2657 | } |
2659 | } |
2658 | |
2660 | |
2659 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
2661 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
2660 | change_exp (op, exp_gain, skop->skill, 0); |
2662 | change_exp (op, exp_gain, skop->skill, 0); |
… | |
… | |
2954 | * Does some sanity checks, then calls improve_armour. |
2956 | * Does some sanity checks, then calls improve_armour. |
2955 | */ |
2957 | */ |
2956 | static void |
2958 | static void |
2957 | apply_armour_improver (object *op, object *tmp) |
2959 | apply_armour_improver (object *op, object *tmp) |
2958 | { |
2960 | { |
2959 | object *armor; |
|
|
2960 | |
|
|
2961 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2961 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2962 | { |
2962 | { |
2963 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2963 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2964 | return; |
2964 | return; |
2965 | } |
2965 | } |
2966 | |
2966 | |
2967 | armor = find_marked_object (op); |
2967 | object *armor = op->mark (); |
2968 | |
2968 | |
2969 | if (!armor) |
2969 | if (!armor) |
2970 | { |
2970 | { |
2971 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2971 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2972 | return; |
2972 | return; |
… | |
… | |
2975 | if (armor->type != ARMOUR |
2975 | if (armor->type != ARMOUR |
2976 | && armor->type != CLOAK |
2976 | && armor->type != CLOAK |
2977 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2977 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2978 | { |
2978 | { |
2979 | op->failmsg ("Your marked item is not armour!\n"); |
2979 | op->failmsg ("Your marked item is not armour!\n"); |
|
|
2980 | return; |
|
|
2981 | } |
|
|
2982 | |
|
|
2983 | if (!op->apply (armor, AP_UNAPPLY)) |
|
|
2984 | { |
|
|
2985 | op->failmsg ("You are unable to take off your armour to improve it!"); |
2980 | return; |
2986 | return; |
2981 | } |
2987 | } |
2982 | |
2988 | |
2983 | op->statusmsg ("Applying armour enchantment."); |
2989 | op->statusmsg ("Applying armour enchantment."); |
2984 | improve_armour (op, tmp, armor); |
2990 | improve_armour (op, tmp, armor); |
… | |
… | |
3070 | * the selected object to "burn". -b.t. |
3076 | * the selected object to "burn". -b.t. |
3071 | */ |
3077 | */ |
3072 | static void |
3078 | static void |
3073 | apply_lighter (object *who, object *lighter) |
3079 | apply_lighter (object *who, object *lighter) |
3074 | { |
3080 | { |
3075 | object *item; |
|
|
3076 | int is_player_env = 0; |
3081 | int is_player_env = 0; |
3077 | |
3082 | |
3078 | item = find_marked_object (who); |
3083 | if (object *item = who->mark ()) |
3079 | if (item) |
|
|
3080 | { |
3084 | { |
3081 | if (!auto_apply_lighter (who, item, lighter)) |
3085 | if (!auto_apply_lighter (who, item, lighter)) |
3082 | return; |
3086 | return; |
3083 | |
3087 | |
3084 | /* Perhaps we should split what we are trying to light on fire? |
3088 | /* Perhaps we should split what we are trying to light on fire? |
… | |
… | |
3275 | * The 'slaying' field for transformer is used as verb for the action. |
3279 | * The 'slaying' field for transformer is used as verb for the action. |
3276 | */ |
3280 | */ |
3277 | static void |
3281 | static void |
3278 | apply_item_transformer (object *pl, object *transformer) |
3282 | apply_item_transformer (object *pl, object *transformer) |
3279 | { |
3283 | { |
3280 | object *marked; |
|
|
3281 | object *new_item; |
3284 | object *new_item; |
3282 | const char *find; |
3285 | const char *find; |
3283 | char *separator; |
3286 | char *separator; |
3284 | int yield; |
3287 | int yield; |
3285 | char got[MAX_BUF]; |
3288 | char got[MAX_BUF]; |
3286 | int len; |
3289 | int len; |
3287 | |
3290 | |
3288 | if (!pl || !transformer) |
3291 | if (!pl || !transformer) |
3289 | return; |
3292 | return; |
3290 | |
3293 | |
3291 | marked = find_marked_object (pl); |
3294 | object *marked = pl->mark (); |
3292 | |
3295 | |
3293 | if (!marked) |
3296 | if (!marked) |
3294 | { |
3297 | { |
3295 | pl->failmsgf ("Use the %s with what item?", query_name (transformer)); |
3298 | pl->failmsgf ("Use the %s with what item?", query_name (transformer)); |
3296 | return; |
3299 | return; |