ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.97 by root, Tue May 15 19:07:15 2007 UTC vs.
Revision 1.107 by root, Mon May 28 21:28:35 2007 UTC

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}
1868 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1868 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1869 identify (tmp); 1869 identify (tmp);
1870 1870
1871 new_draw_info_format (NDI_BLACK, 0, op, "The scroll of %s turns to dust.", &tmp->inv->name); 1871 new_draw_info_format (NDI_BLACK, 0, op, "The scroll of %s turns to dust.", &tmp->inv->name);
1872 1872
1873
1874 cast_spell (op, tmp, dir, tmp->inv, NULL); 1873 cast_spell (op, tmp, dir, tmp->inv, NULL);
1875 decrease_ob (tmp); 1874 decrease_ob (tmp);
1876} 1875}
1877 1876
1878/** 1877/**
1881 * chest. 1880 * chest.
1882 */ 1881 */
1883static void 1882static void
1884apply_treasure (object *op, object *tmp) 1883apply_treasure (object *op, object *tmp)
1885{ 1884{
1886 object *treas;
1887
1888
1889 /* 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
1890 * 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
1891 * 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
1892 * 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
1893 * treasure 1889 * treasure
1894 */ 1890 */
1895
1896 treas = tmp->inv; 1891 object *treas = tmp->inv;
1897 if (treas == NULL) 1892
1893 if (!treas)
1898 { 1894 {
1899 new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); 1895 new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty.");
1900 decrease_ob (tmp); 1896 decrease_ob (tmp);
1901 return; 1897 return;
1902 } 1898 }
1899
1903 while (tmp->inv) 1900 while (tmp->inv)
1904 { 1901 {
1905 treas = tmp->inv; 1902 treas = tmp->inv;
1906 1903
1907 treas->remove (); 1904 treas->remove ();
2550 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!");
2551 return 0; 2548 return 0;
2552 } 2549 }
2553 } 2550 }
2554 2551
2555 /* Check for PLAYER to avoid a DM to disappear in a puff of smoke if
2556 * applied.
2557 */
2558 if (op->type != PLAYER && QUERY_FLAG (op, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ))
2559 {
2560 play_sound_map (pl->map, pl->x, pl->y, SOUND_OB_EVAPORATE);
2561 new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff " "of smoke!");
2562 new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion.");
2563 op->destroy ();
2564 return 1;
2565 }
2566
2567 pl->contr->last_used = op; 2552 pl->contr->last_used = op;
2568 2553
2569 tmp = manual_apply (pl, op, aflag); 2554 tmp = manual_apply (pl, op, aflag);
2570 if (!quiet) 2555 if (!quiet)
2571 { 2556 {
2630{ 2615{
2631 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))
2632 || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) 2617 || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags)))
2633 return RESULT_INT (0); 2618 return RESULT_INT (0);
2634 2619
2635 object *tmp2;
2636
2637 CLEAR_FLAG (op, FLAG_APPLIED); 2620 CLEAR_FLAG (op, FLAG_APPLIED);
2638
2639 if (player *pl = who->contr)
2640 {
2641 if (op == pl->ranged_ob) pl->ranged_ob = 0;
2642 if (op == pl->combat_ob) pl->combat_ob = 0;
2643 }
2644 2621
2645 switch (op->type) 2622 switch (op->type)
2646 { 2623 {
2647 case SKILL_TOOL: 2624 case SKILL_TOOL:
2648 // unapplying a skill tool should also unapply the skill it governs 2625 // unapplying a skill tool should also unapply the skill it governs
2657 2634
2658 change_abil (who, op); 2635 change_abil (who, op);
2659 break; 2636 break;
2660 2637
2661 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
2662 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));
2663 2647
2664 change_abil (who, op); 2648 change_abil (who, op);
2665 CLEAR_FLAG (who, FLAG_READY_WEAPON); 2649 CLEAR_FLAG (who, FLAG_READY_WEAPON);
2666 clear_skill (who);
2667 break; 2650 break;
2668 2651
2669 case SKILL: 2652 case SKILL:
2670 if (op != who->chosen_skill)
2671 LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n");
2672
2673 if (who->contr) 2653 if (who->contr)
2674 { 2654 {
2675 if (!op->invisible) 2655 if (!op->invisible)
2676 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));
2677 else 2657 else
2678 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);
2679 } 2659 }
2680 2660
2681 change_abil (who, op); 2661 change_abil (who, op);
2682 who->chosen_skill = 0;
2683 CLEAR_FLAG (who, FLAG_READY_SKILL); 2662 CLEAR_FLAG (who, FLAG_READY_SKILL);
2684 break; 2663 break;
2685 2664
2686 case ARMOUR: 2665 case ARMOUR:
2687 case HELMET: 2666 case HELMET:
2696 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));
2697 change_abil (who, op); 2676 change_abil (who, op);
2698 break; 2677 break;
2699 2678
2700 case LAMP: 2679 case LAMP:
2680 {
2701 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
2702 tmp2 = arch_to_object (op->other_arch); 2683 object *tmp2 = arch_to_object (op->other_arch);
2703 tmp2->x = op->x; 2684 tmp2->x = op->x;
2704 tmp2->y = op->y; 2685 tmp2->y = op->y;
2705 tmp2->map = op->map; 2686 tmp2->map = op->map;
2706 tmp2->below = op->below; 2687 tmp2->below = op->below;
2707 tmp2->above = op->above; 2688 tmp2->above = op->above;
2708 tmp2->stats.food = op->stats.food; 2689 tmp2->stats.food = op->stats.food;
2709 CLEAR_FLAG (tmp2, FLAG_APPLIED); 2690 CLEAR_FLAG (tmp2, FLAG_APPLIED);
2710 2691
2711 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 2692 if (QUERY_FLAG (op, FLAG_INV_LOCKED))
2712 SET_FLAG (tmp2, FLAG_INV_LOCKED); 2693 SET_FLAG (tmp2, FLAG_INV_LOCKED);
2713 2694
2714 if (who->contr) 2695 if (who->contr)
2715 esrv_del_item (who->contr, op->count); 2696 esrv_del_item (who->contr, op->count);
2716 2697
2717 op->destroy (); 2698 op->destroy ();
2718 insert_ob_in_ob (tmp2, who); 2699 insert_ob_in_ob (tmp2, who);
2719 who->update_stats (); 2700 who->update_stats ();
2720 2701
2721 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 2702 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
2722 { 2703 {
2723 if (who->contr) 2704 if (who->contr)
2724 { 2705 {
2725 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!");
2726 SET_FLAG (tmp2, FLAG_KNOWN_CURSED); 2707 SET_FLAG (tmp2, FLAG_KNOWN_CURSED);
2727 } 2708 }
2728 } 2709 }
2729 2710
2730 if (who->contr) 2711 if (who->contr)
2731 esrv_send_item (who, tmp2); 2712 esrv_send_item (who, tmp2);
2713 }
2732 2714
2733 return 1; /* otherwise, an attempt to drop causes problems */ 2715 return 1; /* otherwise, an attempt to drop causes problems */
2734 2716
2735 case BOW: 2717 case BOW:
2736 case WAND: 2718 case WAND:
2737 case ROD: 2719 case ROD:
2738 case HORN: 2720 case HORN:
2739 clear_skill (who);
2740
2741 if (who->contr) 2721 if (player *pl = who->contr)
2742 { 2722 {
2723 if (op == pl->ranged_ob)
2724 {
2725 pl->ranged_ob = 0;
2726 who->change_weapon (pl->combat_ob);
2727 }
2728
2743 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));
2744
2745 if (who->contr->ranged_ob == op)
2746 who->contr->ranged_ob = 0;
2747
2748 if (who->current_weapon == op)
2749 who->current_weapon = 0;
2750 } 2730 }
2751 else 2731 else
2752 { 2732 {
2733 who->change_skill (0);
2734
2753 if (op->type == BOW) 2735 if (op->type == BOW)
2754 CLEAR_FLAG (who, FLAG_READY_BOW); 2736 CLEAR_FLAG (who, FLAG_READY_BOW);
2755 else 2737 else
2756 CLEAR_FLAG (who, FLAG_READY_RANGE); 2738 CLEAR_FLAG (who, FLAG_READY_RANGE);
2757 } 2739 }
2758 2740
2759 break; 2741 break;
2760 2742
2761 case BUILDER: 2743 case BUILDER:
2762 if (who->contr) 2744 if (who->contr)
2763 {
2764 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));
2765
2766 if (who->contr->ranged_ob == op)
2767 who->contr->ranged_ob = 0;
2768 }
2769 break; 2746 break;
2770 2747
2771 default: 2748 default:
2772 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));
2773 break; 2750 break;
2968 /* 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
2969 * join in with more stuff equipped than they are now allowed. 2946 * join in with more stuff equipped than they are now allowed.
2970 */ 2947 */
2971 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);
2972#endif 2949#endif
2973 fprintf (stderr, "can apply never due to %d but %d - %d + %d\n",//D
2974 i, who->slot[i].used,ws ? ws->slot[i].info :-77,op->slot[i].info);//D
2975 retval |= CAN_APPLY_NEVER; 2950 retval |= CAN_APPLY_NEVER;
2976 } 2951 }
2977 else 2952 else
2978 { 2953 {
2979 /* need to unapply something. However, if this something 2954 /* need to unapply something. However, if this something
3051 * AP_UNAPPLY=always unapply). 3026 * AP_UNAPPLY=always unapply).
3052 * 3027 *
3053 * Optional flags: 3028 * Optional flags:
3054 * 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
3055 * 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
3056 * 3032 *
3057 * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) 3033 * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE)
3058 * 3034 *
3059 * apply_special() doesn't check for unpaid items. 3035 * apply_special() doesn't check for unpaid items.
3060 */ 3036 */
3098 switch (op->slottype ()) 3074 switch (op->slottype ())
3099 { 3075 {
3100 case slot_combat: who->change_weapon (pl->combat_ob); break; 3076 case slot_combat: who->change_weapon (pl->combat_ob); break;
3101 case slot_ranged: who->change_weapon (pl->ranged_ob); break; 3077 case slot_ranged: who->change_weapon (pl->ranged_ob); break;
3102 } 3078 }
3079
3080 splay (op);
3103 3081
3104 /* 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 */
3105 if (int i = can_apply_object (who, op)) 3083 if (int i = can_apply_object (who, op))
3106 { 3084 {
3107 if (i & CAN_APPLY_NEVER) 3085 if (i & CAN_APPLY_NEVER)
3146 } 3124 }
3147 else 3125 else
3148 /* While experience will be credited properly, we want to change the 3126 /* While experience will be credited properly, we want to change the
3149 * skill so that the dam and wc get updated 3127 * skill so that the dam and wc get updated
3150 */ 3128 */
3151 change_skill (who, skop, 0); 3129 who->change_skill (skop);
3152 } 3130 }
3153 3131
3154 if (who->type == PLAYER 3132 if (who->type == PLAYER
3155 && op->item_power 3133 && op->item_power
3156 && 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)
3176 switch (op->type) 3154 switch (op->type)
3177 { 3155 {
3178 case WEAPON: 3156 case WEAPON:
3179 if (!check_weapon_power (who, op->last_eat)) 3157 if (!check_weapon_power (who, op->last_eat))
3180 { 3158 {
3181 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. "
3182 "It would consume your soul!."); 3160 "It would consume your soul!.");
3183 3161
3184 if (tmp) 3162 if (tmp)
3185 insert_ob_in_ob (tmp, who); 3163 insert_ob_in_ob (tmp, who);
3186 3164
3206 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
3207 return 1; 3185 return 1;
3208 } 3186 }
3209 3187
3210 SET_FLAG (op, FLAG_APPLIED); 3188 SET_FLAG (op, FLAG_APPLIED);
3211 change_skill (who, skop, 1); 3189 who->change_skill (skop);
3212 3190
3213 if (who->contr) 3191 if (who->contr)
3214 who->change_weapon (who->contr->combat_ob = op); 3192 who->change_weapon (who->contr->combat_ob = op);
3215 3193
3216 if (!QUERY_FLAG (who, FLAG_READY_WEAPON))
3217 SET_FLAG (who, FLAG_READY_WEAPON);
3218
3219 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));
3220 3195
3196 SET_FLAG (who, FLAG_READY_WEAPON);
3221 change_abil (who, op); 3197 change_abil (who, op);
3222 break; 3198 break;
3223 3199
3224 case ARMOUR: 3200 case ARMOUR:
3225 case HELMET: 3201 case HELMET:
3282 return 0; 3258 return 0;
3283 3259
3284 case SKILL_TOOL: 3260 case SKILL_TOOL:
3285 // applying a skill tool also readies the skill 3261 // applying a skill tool also readies the skill
3286 SET_FLAG (op, FLAG_APPLIED); 3262 SET_FLAG (op, FLAG_APPLIED);
3263
3264 if (!(aflags & AP_NO_READY))
3265 {
3287 skop = find_skill_by_name (who, op->skill); 3266 skop = find_skill_by_name (who, op->skill);
3288 if (!skop->flag [FLAG_APPLIED]) 3267 if (!skop->flag [FLAG_APPLIED])
3289 apply_special (who, skop, AP_APPLY); 3268 apply_special (who, skop, AP_APPLY);
3269 }
3290 break; 3270 break;
3291 3271
3292 case SKILL: 3272 case SKILL:
3293 if (who->chosen_skill)
3294 {
3295 LOG (llevError, "BUG: apply_special(): can't apply two skills\n");
3296 return 1;
3297 }
3298
3299 if (player *pl = who->contr) 3273 if (player *pl = who->contr)
3300 { 3274 {
3301 if (IS_COMBAT_SKILL (op->subtype)) 3275 if (IS_COMBAT_SKILL (op->subtype))
3302 { 3276 {
3303 if (skill_flags [op->subtype] & SF_NEED_WEAPON) 3277 if (skill_flags [op->subtype] & SF_NEED_WEAPON)
3304 { 3278 {
3305 for (object *item = who->inv; item; item = item->below) 3279 for (object *item = who->inv; item; item = item->below)
3306 if (item->type == WEAPON && item->flag [FLAG_APPLIED]) 3280 if (item->type == WEAPON && item->flag [FLAG_APPLIED])
3307 { 3281 {
3282 if (item->skill == op->skill)
3283 {
3308 who->change_weapon (pl->combat_ob = item); 3284 who->change_weapon (pl->combat_ob = item);
3309 goto found_weapon; 3285 goto found_weapon;
3286 }
3310 } 3287 }
3311 3288
3312 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);
3313 return 1; 3290 return 1;
3314 3291
3315 found_weapon:; 3292 found_weapon:;
3316 } 3293 }
3317 else 3294 else
3322 if (skill_flags [op->subtype] & SF_NEED_BOW) 3299 if (skill_flags [op->subtype] & SF_NEED_BOW)
3323 { 3300 {
3324 for (object *item = who->inv; item; item = item->below) 3301 for (object *item = who->inv; item; item = item->below)
3325 if (item->type == BOW && item->flag [FLAG_APPLIED]) 3302 if (item->type == BOW && item->flag [FLAG_APPLIED])
3326 { 3303 {
3304 //TODO: bows should/must all have skill missile weapon right now
3327 who->change_weapon (pl->ranged_ob = item); 3305 who->change_weapon (pl->ranged_ob = item);
3328 goto found_bow; 3306 goto found_bow;
3329 } 3307 }
3330 3308
3331 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");
3332 return 1; 3310 return 1;
3333 3311
3334 found_bow:; 3312 found_bow:;
3335 }
3336 else if (skill_flags [op->subtype] & SF_NEED_ITEM)
3337 {
3338 for (object *item = who->inv; item; item = item->below)
3339 if (item->flag [FLAG_APPLIED]
3340 && (item->type == WAND || item->type == ROD || item->type == HORN))
3341 {
3342 who->change_weapon (pl->ranged_ob = item);
3343 goto found_item;
3344 }
3345
3346 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill");
3347 return 1;
3348
3349 found_item:;
3350 } 3313 }
3351 else 3314 else
3352 who->change_weapon (pl->ranged_ob = op); 3315 who->change_weapon (pl->ranged_ob = op);
3353 } 3316 }
3354 3317
3358 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);
3359 } 3322 }
3360 else 3323 else
3361 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);
3362 } 3325 }
3363 3326 else
3327 {
3364 SET_FLAG (op, FLAG_APPLIED); 3328 SET_FLAG (op, FLAG_APPLIED);
3365 change_abil (who, op); 3329 change_abil (who, op);
3366 who->chosen_skill = op; 3330 who->chosen_skill = op;
3367 SET_FLAG (who, FLAG_READY_SKILL); 3331 SET_FLAG (who, FLAG_READY_SKILL);
3332 }
3333
3368 break; 3334 break;
3369 3335
3370 case BOW: 3336 case BOW:
3371 if (!check_weapon_power (who, op->last_eat)) 3337 if (!check_weapon_power (who, op->last_eat))
3372 { 3338 {
3399 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
3400 return 1; 3366 return 1;
3401 } 3367 }
3402 3368
3403 SET_FLAG (op, FLAG_APPLIED); 3369 SET_FLAG (op, FLAG_APPLIED);
3404 change_skill (who, skop, 0); 3370 who->change_skill (skop);
3405 3371
3406 if (who->contr) 3372 if (who->contr)
3407 { 3373 {
3408 who->contr->ranged_ob = op; 3374 who->contr->ranged_ob = op;
3409 3375
3428 break; 3394 break;
3429 3395
3430 case BUILDER: 3396 case BUILDER:
3431 if (who->type == PLAYER) 3397 if (who->type == PLAYER)
3432 { 3398 {
3399 //TODO: wtf does this do? shouldn't this be managed automatically (slots?)
3433 if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) 3400 if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER)
3434 unapply_special (who, who->contr->ranged_ob, 0); 3401 unapply_special (who, who->contr->ranged_ob, 0);
3435 3402
3436 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));
3437 3404

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines