1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
9 | * it under the terms of the GNU General Public License as published by |
9 | * under the terms of the GNU General Public License as published by the Free |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
11 | * (at your option) any later version. |
11 | * any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, but |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16 | * GNU General Public License for more details. |
16 | * for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License along |
19 | * along with this program; if not, write to the Free Software |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <cmath> |
25 | #include <cmath> |
26 | |
26 | |
… | |
… | |
1006 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1006 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1007 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1007 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1008 | |
1008 | |
1009 | /** |
1009 | /** |
1010 | * elmex: we are going to let the game continue, as the mapcreator |
1010 | * elmex: we are going to let the game continue, as the mapcreator |
1011 | * propably had something in mind when doing this |
1011 | * probably had something in mind when doing this |
1012 | */ |
1012 | */ |
1013 | } |
1013 | } |
1014 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1014 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1015 | return 1; |
1015 | return 1; |
1016 | } |
1016 | } |
… | |
… | |
1880 | * chest. |
1880 | * chest. |
1881 | */ |
1881 | */ |
1882 | static void |
1882 | static void |
1883 | apply_treasure (object *op, object *tmp) |
1883 | apply_treasure (object *op, object *tmp) |
1884 | { |
1884 | { |
1885 | object *treas; |
|
|
1886 | |
|
|
1887 | /* Nice side effect of new treasure creation method is that the treasure |
1885 | /* Nice side effect of new treasure creation method is that the treasure |
1888 | * for the chest is done when the chest is created, and put into the chest |
1886 | * for the chest is done when the chest is created, and put into the chest |
1889 | * inventory. So that when the chest burns up, the items still exist. Also |
1887 | * inventory. So that when the chest burns up, the items still exist. Also |
1890 | * prevents people fromt moving chests to more difficult maps to get better |
1888 | * prevents people fromt moving chests to more difficult maps to get better |
1891 | * treasure |
1889 | * treasure |
1892 | */ |
1890 | */ |
1893 | |
|
|
1894 | treas = tmp->inv; |
1891 | object *treas = tmp->inv; |
1895 | if (treas == NULL) |
1892 | |
|
|
1893 | if (!treas) |
1896 | { |
1894 | { |
1897 | new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); |
1895 | new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); |
1898 | decrease_ob (tmp); |
1896 | decrease_ob (tmp); |
1899 | return; |
1897 | return; |
1900 | } |
1898 | } |
|
|
1899 | |
1901 | while (tmp->inv) |
1900 | while (tmp->inv) |
1902 | { |
1901 | { |
1903 | treas = tmp->inv; |
1902 | treas = tmp->inv; |
1904 | |
1903 | |
1905 | treas->remove (); |
1904 | treas->remove (); |
… | |
… | |
2548 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); |
2547 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); |
2549 | return 0; |
2548 | return 0; |
2550 | } |
2549 | } |
2551 | } |
2550 | } |
2552 | |
2551 | |
2553 | /* Check for PLAYER to avoid a DM to disappear in a puff of smoke if |
|
|
2554 | * applied. |
|
|
2555 | */ |
|
|
2556 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
|
|
2557 | { |
|
|
2558 | play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE); |
|
|
2559 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff " "of smoke!"); |
|
|
2560 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
|
|
2561 | op->destroy (); |
|
|
2562 | return 1; |
|
|
2563 | } |
|
|
2564 | |
|
|
2565 | pl->contr->last_used = op; |
2552 | pl->contr->last_used = op; |
2566 | |
2553 | |
2567 | tmp = manual_apply (pl, op, aflag); |
2554 | tmp = manual_apply (pl, op, aflag); |
2568 | if (!quiet) |
2555 | if (!quiet) |
2569 | { |
2556 | { |
… | |
… | |
2628 | { |
2615 | { |
2629 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
2616 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
2630 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2617 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2631 | return RESULT_INT (0); |
2618 | return RESULT_INT (0); |
2632 | |
2619 | |
2633 | object *tmp2; |
|
|
2634 | |
|
|
2635 | CLEAR_FLAG (op, FLAG_APPLIED); |
2620 | CLEAR_FLAG (op, FLAG_APPLIED); |
2636 | |
|
|
2637 | if (player *pl = who->contr) |
|
|
2638 | { |
|
|
2639 | if (op == pl->ranged_ob) pl->ranged_ob = 0; |
|
|
2640 | if (op == pl->combat_ob) pl->combat_ob = 0; |
|
|
2641 | } |
|
|
2642 | |
2621 | |
2643 | switch (op->type) |
2622 | switch (op->type) |
2644 | { |
2623 | { |
2645 | case SKILL_TOOL: |
2624 | case SKILL_TOOL: |
2646 | // unapplying a skill tool should also unapply the skill it governs |
2625 | // unapplying a skill tool should also unapply the skill it governs |
… | |
… | |
2655 | |
2634 | |
2656 | change_abil (who, op); |
2635 | change_abil (who, op); |
2657 | break; |
2636 | break; |
2658 | |
2637 | |
2659 | case WEAPON: |
2638 | case WEAPON: |
|
|
2639 | if (player *pl = who->contr) |
|
|
2640 | if (op == pl->combat_ob) |
|
|
2641 | { |
|
|
2642 | pl->combat_ob = 0; |
|
|
2643 | who->change_weapon (pl->ranged_ob); |
|
|
2644 | } |
|
|
2645 | |
2660 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2646 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2661 | |
2647 | |
2662 | change_abil (who, op); |
2648 | change_abil (who, op); |
2663 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2649 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2664 | clear_skill (who); |
|
|
2665 | break; |
2650 | break; |
2666 | |
2651 | |
2667 | case SKILL: |
2652 | case SKILL: |
2668 | if (op != who->chosen_skill) |
|
|
2669 | LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); |
|
|
2670 | |
|
|
2671 | if (who->contr) |
2653 | if (who->contr) |
2672 | { |
2654 | { |
2673 | if (!op->invisible) |
2655 | if (!op->invisible) |
2674 | new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); |
2656 | new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); |
2675 | else |
2657 | else |
2676 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); |
2658 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); |
2677 | } |
2659 | } |
2678 | |
2660 | |
2679 | change_abil (who, op); |
2661 | change_abil (who, op); |
2680 | who->chosen_skill = 0; |
|
|
2681 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2662 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2682 | break; |
2663 | break; |
2683 | |
2664 | |
2684 | case ARMOUR: |
2665 | case ARMOUR: |
2685 | case HELMET: |
2666 | case HELMET: |
… | |
… | |
2694 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); |
2675 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); |
2695 | change_abil (who, op); |
2676 | change_abil (who, op); |
2696 | break; |
2677 | break; |
2697 | |
2678 | |
2698 | case LAMP: |
2679 | case LAMP: |
|
|
2680 | { |
2699 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); |
2681 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); |
|
|
2682 | |
2700 | tmp2 = arch_to_object (op->other_arch); |
2683 | object *tmp2 = arch_to_object (op->other_arch); |
2701 | tmp2->x = op->x; |
2684 | tmp2->x = op->x; |
2702 | tmp2->y = op->y; |
2685 | tmp2->y = op->y; |
2703 | tmp2->map = op->map; |
2686 | tmp2->map = op->map; |
2704 | tmp2->below = op->below; |
2687 | tmp2->below = op->below; |
2705 | tmp2->above = op->above; |
2688 | tmp2->above = op->above; |
2706 | tmp2->stats.food = op->stats.food; |
2689 | tmp2->stats.food = op->stats.food; |
2707 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2690 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2708 | |
2691 | |
2709 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2692 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2710 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2693 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2711 | |
2694 | |
2712 | if (who->contr) |
2695 | if (who->contr) |
2713 | esrv_del_item (who->contr, op->count); |
2696 | esrv_del_item (who->contr, op->count); |
2714 | |
2697 | |
2715 | op->destroy (); |
2698 | op->destroy (); |
2716 | insert_ob_in_ob (tmp2, who); |
2699 | insert_ob_in_ob (tmp2, who); |
2717 | who->update_stats (); |
2700 | who->update_stats (); |
2718 | |
2701 | |
2719 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2702 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2720 | { |
2703 | { |
2721 | if (who->contr) |
2704 | if (who->contr) |
2722 | { |
2705 | { |
2723 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
2706 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
2724 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2707 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2725 | } |
2708 | } |
2726 | } |
2709 | } |
2727 | |
2710 | |
2728 | if (who->contr) |
2711 | if (who->contr) |
2729 | esrv_send_item (who, tmp2); |
2712 | esrv_send_item (who, tmp2); |
|
|
2713 | } |
2730 | |
2714 | |
2731 | return 1; /* otherwise, an attempt to drop causes problems */ |
2715 | return 1; /* otherwise, an attempt to drop causes problems */ |
2732 | |
2716 | |
2733 | case BOW: |
2717 | case BOW: |
2734 | case WAND: |
2718 | case WAND: |
2735 | case ROD: |
2719 | case ROD: |
2736 | case HORN: |
2720 | case HORN: |
2737 | clear_skill (who); |
|
|
2738 | |
|
|
2739 | if (who->contr) |
2721 | if (player *pl = who->contr) |
2740 | { |
2722 | { |
|
|
2723 | if (op == pl->ranged_ob) |
|
|
2724 | { |
|
|
2725 | pl->ranged_ob = 0; |
|
|
2726 | who->change_weapon (pl->combat_ob); |
|
|
2727 | } |
|
|
2728 | |
2741 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2729 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2742 | |
|
|
2743 | if (who->contr->ranged_ob == op) |
|
|
2744 | who->contr->ranged_ob = 0; |
|
|
2745 | |
|
|
2746 | if (who->current_weapon == op) |
|
|
2747 | who->current_weapon = 0; |
|
|
2748 | } |
2730 | } |
2749 | else |
2731 | else |
2750 | { |
2732 | { |
|
|
2733 | who->change_skill (0); |
|
|
2734 | |
2751 | if (op->type == BOW) |
2735 | if (op->type == BOW) |
2752 | CLEAR_FLAG (who, FLAG_READY_BOW); |
2736 | CLEAR_FLAG (who, FLAG_READY_BOW); |
2753 | else |
2737 | else |
2754 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
2738 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
2755 | } |
2739 | } |
2756 | |
2740 | |
2757 | break; |
2741 | break; |
2758 | |
2742 | |
2759 | case BUILDER: |
2743 | case BUILDER: |
2760 | if (who->contr) |
2744 | if (who->contr) |
2761 | { |
|
|
2762 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2745 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2763 | |
|
|
2764 | if (who->contr->ranged_ob == op) |
|
|
2765 | who->contr->ranged_ob = 0; |
|
|
2766 | } |
|
|
2767 | break; |
2746 | break; |
2768 | |
2747 | |
2769 | default: |
2748 | default: |
2770 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2749 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2771 | break; |
2750 | break; |
… | |
… | |
2966 | /* This is sort of an error, but happens a lot when old players |
2945 | /* This is sort of an error, but happens a lot when old players |
2967 | * join in with more stuff equipped than they are now allowed. |
2946 | * join in with more stuff equipped than they are now allowed. |
2968 | */ |
2947 | */ |
2969 | LOG (llevError, "Can't find object using location %d on %s\n", i, who->name); |
2948 | LOG (llevError, "Can't find object using location %d on %s\n", i, who->name); |
2970 | #endif |
2949 | #endif |
2971 | fprintf (stderr, "can apply never due to %d but %d - %d + %d\n",//D |
|
|
2972 | i, who->slot[i].used,ws ? ws->slot[i].info :-77,op->slot[i].info);//D |
|
|
2973 | retval |= CAN_APPLY_NEVER; |
2950 | retval |= CAN_APPLY_NEVER; |
2974 | } |
2951 | } |
2975 | else |
2952 | else |
2976 | { |
2953 | { |
2977 | /* need to unapply something. However, if this something |
2954 | /* need to unapply something. However, if this something |
… | |
… | |
3049 | * AP_UNAPPLY=always unapply). |
3026 | * AP_UNAPPLY=always unapply). |
3050 | * |
3027 | * |
3051 | * Optional flags: |
3028 | * Optional flags: |
3052 | * AP_NO_MERGE: don't merge an unapplied object with other objects |
3029 | * AP_NO_MERGE: don't merge an unapplied object with other objects |
3053 | * AP_IGNORE_CURSE: unapply cursed items |
3030 | * AP_IGNORE_CURSE: unapply cursed items |
|
|
3031 | * AP_NO_READY: do not ready skills when applying skill tools |
3054 | * |
3032 | * |
3055 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3033 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3056 | * |
3034 | * |
3057 | * apply_special() doesn't check for unpaid items. |
3035 | * apply_special() doesn't check for unpaid items. |
3058 | */ |
3036 | */ |
… | |
… | |
3096 | switch (op->slottype ()) |
3074 | switch (op->slottype ()) |
3097 | { |
3075 | { |
3098 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3076 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3099 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3077 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3100 | } |
3078 | } |
|
|
3079 | |
|
|
3080 | splay (op); |
3101 | |
3081 | |
3102 | /* Can't just apply this object. Lets see what not and what to do */ |
3082 | /* Can't just apply this object. Lets see what not and what to do */ |
3103 | if (int i = can_apply_object (who, op)) |
3083 | if (int i = can_apply_object (who, op)) |
3104 | { |
3084 | { |
3105 | if (i & CAN_APPLY_NEVER) |
3085 | if (i & CAN_APPLY_NEVER) |
… | |
… | |
3144 | } |
3124 | } |
3145 | else |
3125 | else |
3146 | /* While experience will be credited properly, we want to change the |
3126 | /* While experience will be credited properly, we want to change the |
3147 | * skill so that the dam and wc get updated |
3127 | * skill so that the dam and wc get updated |
3148 | */ |
3128 | */ |
3149 | change_skill (who, skop, 0); |
3129 | who->change_skill (skop); |
3150 | } |
3130 | } |
3151 | |
3131 | |
3152 | if (who->type == PLAYER |
3132 | if (who->type == PLAYER |
3153 | && op->item_power |
3133 | && op->item_power |
3154 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3134 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
… | |
… | |
3174 | switch (op->type) |
3154 | switch (op->type) |
3175 | { |
3155 | { |
3176 | case WEAPON: |
3156 | case WEAPON: |
3177 | if (!check_weapon_power (who, op->last_eat)) |
3157 | if (!check_weapon_power (who, op->last_eat)) |
3178 | { |
3158 | { |
3179 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use.\n" |
3159 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3180 | "It would consume your soul!."); |
3160 | "It would consume your soul!."); |
3181 | |
3161 | |
3182 | if (tmp) |
3162 | if (tmp) |
3183 | insert_ob_in_ob (tmp, who); |
3163 | insert_ob_in_ob (tmp, who); |
3184 | |
3164 | |
… | |
… | |
3204 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3184 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3205 | return 1; |
3185 | return 1; |
3206 | } |
3186 | } |
3207 | |
3187 | |
3208 | SET_FLAG (op, FLAG_APPLIED); |
3188 | SET_FLAG (op, FLAG_APPLIED); |
3209 | change_skill (who, skop, 1); |
3189 | who->change_skill (skop); |
3210 | |
3190 | |
3211 | if (who->contr) |
3191 | if (who->contr) |
3212 | who->change_weapon (who->contr->combat_ob = op); |
3192 | who->change_weapon (who->contr->combat_ob = op); |
3213 | |
3193 | |
3214 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
|
|
3215 | SET_FLAG (who, FLAG_READY_WEAPON); |
|
|
3216 | |
|
|
3217 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3194 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3218 | |
3195 | |
|
|
3196 | SET_FLAG (who, FLAG_READY_WEAPON); |
3219 | change_abil (who, op); |
3197 | change_abil (who, op); |
3220 | break; |
3198 | break; |
3221 | |
3199 | |
3222 | case ARMOUR: |
3200 | case ARMOUR: |
3223 | case HELMET: |
3201 | case HELMET: |
… | |
… | |
3280 | return 0; |
3258 | return 0; |
3281 | |
3259 | |
3282 | case SKILL_TOOL: |
3260 | case SKILL_TOOL: |
3283 | // applying a skill tool also readies the skill |
3261 | // applying a skill tool also readies the skill |
3284 | SET_FLAG (op, FLAG_APPLIED); |
3262 | SET_FLAG (op, FLAG_APPLIED); |
|
|
3263 | |
|
|
3264 | if (!(aflags & AP_NO_READY)) |
|
|
3265 | { |
3285 | skop = find_skill_by_name (who, op->skill); |
3266 | skop = find_skill_by_name (who, op->skill); |
3286 | if (!skop->flag [FLAG_APPLIED]) |
3267 | if (!skop->flag [FLAG_APPLIED]) |
3287 | apply_special (who, skop, AP_APPLY); |
3268 | apply_special (who, skop, AP_APPLY); |
|
|
3269 | } |
3288 | break; |
3270 | break; |
3289 | |
3271 | |
3290 | case SKILL: |
3272 | case SKILL: |
3291 | if (who->chosen_skill) |
|
|
3292 | { |
|
|
3293 | LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); |
|
|
3294 | return 1; |
|
|
3295 | } |
|
|
3296 | |
|
|
3297 | if (player *pl = who->contr) |
3273 | if (player *pl = who->contr) |
3298 | { |
3274 | { |
3299 | if (IS_COMBAT_SKILL (op->subtype)) |
3275 | if (IS_COMBAT_SKILL (op->subtype)) |
3300 | { |
3276 | { |
3301 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3277 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3302 | { |
3278 | { |
3303 | for (object *item = who->inv; item; item = item->below) |
3279 | for (object *item = who->inv; item; item = item->below) |
3304 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3280 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3305 | { |
3281 | { |
|
|
3282 | if (item->skill == op->skill) |
|
|
3283 | { |
3306 | who->change_weapon (pl->combat_ob = item); |
3284 | who->change_weapon (pl->combat_ob = item); |
3307 | goto found_weapon; |
3285 | goto found_weapon; |
|
|
3286 | } |
3308 | } |
3287 | } |
3309 | |
3288 | |
3310 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); |
3289 | new_draw_info_format (NDI_UNIQUE, 0, who, "You need to apply a '%s' melee weapon before readying this skill", &op->skill); |
3311 | return 1; |
3290 | return 1; |
3312 | |
3291 | |
3313 | found_weapon:; |
3292 | found_weapon:; |
3314 | } |
3293 | } |
3315 | else |
3294 | else |
… | |
… | |
3320 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3299 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3321 | { |
3300 | { |
3322 | for (object *item = who->inv; item; item = item->below) |
3301 | for (object *item = who->inv; item; item = item->below) |
3323 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3302 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3324 | { |
3303 | { |
|
|
3304 | //TODO: bows should/must all have skill missile weapon right now |
3325 | who->change_weapon (pl->ranged_ob = item); |
3305 | who->change_weapon (pl->ranged_ob = item); |
3326 | goto found_bow; |
3306 | goto found_bow; |
3327 | } |
3307 | } |
3328 | |
3308 | |
3329 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3309 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3330 | return 1; |
3310 | return 1; |
3331 | |
3311 | |
3332 | found_bow:; |
3312 | found_bow:; |
3333 | } |
|
|
3334 | else if (skill_flags [op->subtype] & SF_NEED_ITEM) |
|
|
3335 | { |
|
|
3336 | for (object *item = who->inv; item; item = item->below) |
|
|
3337 | if (item->flag [FLAG_APPLIED] |
|
|
3338 | && (item->type == WAND || item->type == ROD || item->type == HORN)) |
|
|
3339 | { |
|
|
3340 | who->change_weapon (pl->ranged_ob = item); |
|
|
3341 | goto found_item; |
|
|
3342 | } |
|
|
3343 | |
|
|
3344 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); |
|
|
3345 | return 1; |
|
|
3346 | |
|
|
3347 | found_item:; |
|
|
3348 | } |
3313 | } |
3349 | else |
3314 | else |
3350 | who->change_weapon (pl->ranged_ob = op); |
3315 | who->change_weapon (pl->ranged_ob = op); |
3351 | } |
3316 | } |
3352 | |
3317 | |
… | |
… | |
3356 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); |
3321 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); |
3357 | } |
3322 | } |
3358 | else |
3323 | else |
3359 | new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); |
3324 | new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); |
3360 | } |
3325 | } |
3361 | |
3326 | else |
|
|
3327 | { |
3362 | SET_FLAG (op, FLAG_APPLIED); |
3328 | SET_FLAG (op, FLAG_APPLIED); |
3363 | change_abil (who, op); |
3329 | change_abil (who, op); |
3364 | who->chosen_skill = op; |
3330 | who->chosen_skill = op; |
3365 | SET_FLAG (who, FLAG_READY_SKILL); |
3331 | SET_FLAG (who, FLAG_READY_SKILL); |
|
|
3332 | } |
|
|
3333 | |
3366 | break; |
3334 | break; |
3367 | |
3335 | |
3368 | case BOW: |
3336 | case BOW: |
3369 | if (!check_weapon_power (who, op->last_eat)) |
3337 | if (!check_weapon_power (who, op->last_eat)) |
3370 | { |
3338 | { |
… | |
… | |
3397 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3365 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3398 | return 1; |
3366 | return 1; |
3399 | } |
3367 | } |
3400 | |
3368 | |
3401 | SET_FLAG (op, FLAG_APPLIED); |
3369 | SET_FLAG (op, FLAG_APPLIED); |
3402 | change_skill (who, skop, 0); |
3370 | who->change_skill (skop); |
3403 | |
3371 | |
3404 | if (who->contr) |
3372 | if (who->contr) |
3405 | { |
3373 | { |
3406 | who->contr->ranged_ob = op; |
3374 | who->contr->ranged_ob = op; |
3407 | |
3375 | |
… | |
… | |
3426 | break; |
3394 | break; |
3427 | |
3395 | |
3428 | case BUILDER: |
3396 | case BUILDER: |
3429 | if (who->type == PLAYER) |
3397 | if (who->type == PLAYER) |
3430 | { |
3398 | { |
|
|
3399 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3431 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3400 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3432 | unapply_special (who, who->contr->ranged_ob, 0); |
3401 | unapply_special (who, who->contr->ranged_ob, 0); |
3433 | |
3402 | |
3434 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); |
3403 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); |
3435 | |
3404 | |