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 | } |
… | |
… | |
2615 | { |
2615 | { |
2616 | 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)) |
2617 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2617 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2618 | return RESULT_INT (0); |
2618 | return RESULT_INT (0); |
2619 | |
2619 | |
2620 | object *tmp2; |
|
|
2621 | |
|
|
2622 | CLEAR_FLAG (op, FLAG_APPLIED); |
2620 | CLEAR_FLAG (op, FLAG_APPLIED); |
2623 | |
|
|
2624 | if (player *pl = who->contr) |
|
|
2625 | { |
|
|
2626 | if (op == pl->ranged_ob) pl->ranged_ob = 0; |
|
|
2627 | if (op == pl->combat_ob) pl->combat_ob = 0; |
|
|
2628 | } |
|
|
2629 | |
2621 | |
2630 | switch (op->type) |
2622 | switch (op->type) |
2631 | { |
2623 | { |
2632 | case SKILL_TOOL: |
2624 | case SKILL_TOOL: |
2633 | // unapplying a skill tool should also unapply the skill it governs |
2625 | // unapplying a skill tool should also unapply the skill it governs |
… | |
… | |
2642 | |
2634 | |
2643 | change_abil (who, op); |
2635 | change_abil (who, op); |
2644 | break; |
2636 | break; |
2645 | |
2637 | |
2646 | 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 | |
2647 | 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)); |
2648 | |
2647 | |
2649 | change_abil (who, op); |
2648 | change_abil (who, op); |
2650 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2649 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2651 | clear_skill (who); |
|
|
2652 | break; |
2650 | break; |
2653 | |
2651 | |
2654 | case SKILL: |
2652 | case SKILL: |
2655 | if (op != who->chosen_skill) |
|
|
2656 | LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); |
|
|
2657 | |
|
|
2658 | if (who->contr) |
2653 | if (who->contr) |
2659 | { |
2654 | { |
2660 | if (!op->invisible) |
2655 | if (!op->invisible) |
2661 | 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)); |
2662 | else |
2657 | else |
2663 | 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); |
2664 | } |
2659 | } |
2665 | |
2660 | |
2666 | change_abil (who, op); |
2661 | change_abil (who, op); |
2667 | who->chosen_skill = 0; |
|
|
2668 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2662 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2669 | break; |
2663 | break; |
2670 | |
2664 | |
2671 | case ARMOUR: |
2665 | case ARMOUR: |
2672 | case HELMET: |
2666 | case HELMET: |
… | |
… | |
2681 | 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)); |
2682 | change_abil (who, op); |
2676 | change_abil (who, op); |
2683 | break; |
2677 | break; |
2684 | |
2678 | |
2685 | case LAMP: |
2679 | case LAMP: |
|
|
2680 | { |
2686 | 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 | |
2687 | tmp2 = arch_to_object (op->other_arch); |
2683 | object *tmp2 = arch_to_object (op->other_arch); |
2688 | tmp2->x = op->x; |
2684 | tmp2->x = op->x; |
2689 | tmp2->y = op->y; |
2685 | tmp2->y = op->y; |
2690 | tmp2->map = op->map; |
2686 | tmp2->map = op->map; |
2691 | tmp2->below = op->below; |
2687 | tmp2->below = op->below; |
2692 | tmp2->above = op->above; |
2688 | tmp2->above = op->above; |
2693 | tmp2->stats.food = op->stats.food; |
2689 | tmp2->stats.food = op->stats.food; |
2694 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2690 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2695 | |
2691 | |
2696 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2692 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2697 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2693 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2698 | |
2694 | |
2699 | if (who->contr) |
2695 | if (who->contr) |
2700 | esrv_del_item (who->contr, op->count); |
2696 | esrv_del_item (who->contr, op->count); |
2701 | |
2697 | |
2702 | op->destroy (); |
2698 | op->destroy (); |
2703 | insert_ob_in_ob (tmp2, who); |
2699 | insert_ob_in_ob (tmp2, who); |
2704 | who->update_stats (); |
2700 | who->update_stats (); |
2705 | |
2701 | |
2706 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2702 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2707 | { |
2703 | { |
2708 | if (who->contr) |
2704 | if (who->contr) |
2709 | { |
2705 | { |
2710 | 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!"); |
2711 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2707 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2712 | } |
2708 | } |
2713 | } |
2709 | } |
2714 | |
2710 | |
2715 | if (who->contr) |
2711 | if (who->contr) |
2716 | esrv_send_item (who, tmp2); |
2712 | esrv_send_item (who, tmp2); |
|
|
2713 | } |
2717 | |
2714 | |
2718 | return 1; /* otherwise, an attempt to drop causes problems */ |
2715 | return 1; /* otherwise, an attempt to drop causes problems */ |
2719 | |
2716 | |
2720 | case BOW: |
2717 | case BOW: |
2721 | case WAND: |
2718 | case WAND: |
2722 | case ROD: |
2719 | case ROD: |
2723 | case HORN: |
2720 | case HORN: |
2724 | clear_skill (who); |
|
|
2725 | |
|
|
2726 | if (who->contr) |
2721 | if (player *pl = who->contr) |
2727 | { |
2722 | { |
|
|
2723 | if (op == pl->ranged_ob) |
|
|
2724 | { |
|
|
2725 | pl->ranged_ob = 0; |
|
|
2726 | who->change_weapon (pl->combat_ob); |
|
|
2727 | } |
|
|
2728 | |
2728 | 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)); |
2729 | |
|
|
2730 | if (who->contr->ranged_ob == op) |
|
|
2731 | who->contr->ranged_ob = 0; |
|
|
2732 | |
|
|
2733 | if (who->current_weapon == op) |
|
|
2734 | who->current_weapon = 0; |
|
|
2735 | } |
2730 | } |
2736 | else |
2731 | else |
2737 | { |
2732 | { |
|
|
2733 | who->change_skill (0); |
|
|
2734 | |
2738 | if (op->type == BOW) |
2735 | if (op->type == BOW) |
2739 | CLEAR_FLAG (who, FLAG_READY_BOW); |
2736 | CLEAR_FLAG (who, FLAG_READY_BOW); |
2740 | else |
2737 | else |
2741 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
2738 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
2742 | } |
2739 | } |
2743 | |
2740 | |
2744 | break; |
2741 | break; |
2745 | |
2742 | |
2746 | case BUILDER: |
2743 | case BUILDER: |
2747 | if (who->contr) |
2744 | if (who->contr) |
2748 | { |
|
|
2749 | 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)); |
2750 | |
|
|
2751 | if (who->contr->ranged_ob == op) |
|
|
2752 | who->contr->ranged_ob = 0; |
|
|
2753 | } |
|
|
2754 | break; |
2746 | break; |
2755 | |
2747 | |
2756 | default: |
2748 | default: |
2757 | 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)); |
2758 | break; |
2750 | break; |
… | |
… | |
3034 | * AP_UNAPPLY=always unapply). |
3026 | * AP_UNAPPLY=always unapply). |
3035 | * |
3027 | * |
3036 | * Optional flags: |
3028 | * Optional flags: |
3037 | * 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 |
3038 | * 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 |
3039 | * |
3032 | * |
3040 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3033 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3041 | * |
3034 | * |
3042 | * apply_special() doesn't check for unpaid items. |
3035 | * apply_special() doesn't check for unpaid items. |
3043 | */ |
3036 | */ |
… | |
… | |
3081 | switch (op->slottype ()) |
3074 | switch (op->slottype ()) |
3082 | { |
3075 | { |
3083 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3076 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3084 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3077 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3085 | } |
3078 | } |
|
|
3079 | |
|
|
3080 | splay (op); |
3086 | |
3081 | |
3087 | /* 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 */ |
3088 | if (int i = can_apply_object (who, op)) |
3083 | if (int i = can_apply_object (who, op)) |
3089 | { |
3084 | { |
3090 | if (i & CAN_APPLY_NEVER) |
3085 | if (i & CAN_APPLY_NEVER) |
… | |
… | |
3159 | switch (op->type) |
3154 | switch (op->type) |
3160 | { |
3155 | { |
3161 | case WEAPON: |
3156 | case WEAPON: |
3162 | if (!check_weapon_power (who, op->last_eat)) |
3157 | if (!check_weapon_power (who, op->last_eat)) |
3163 | { |
3158 | { |
3164 | 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. " |
3165 | "It would consume your soul!."); |
3160 | "It would consume your soul!."); |
3166 | |
3161 | |
3167 | if (tmp) |
3162 | if (tmp) |
3168 | insert_ob_in_ob (tmp, who); |
3163 | insert_ob_in_ob (tmp, who); |
3169 | |
3164 | |
… | |
… | |
3194 | who->change_skill (skop); |
3189 | who->change_skill (skop); |
3195 | |
3190 | |
3196 | if (who->contr) |
3191 | if (who->contr) |
3197 | who->change_weapon (who->contr->combat_ob = op); |
3192 | who->change_weapon (who->contr->combat_ob = op); |
3198 | |
3193 | |
3199 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
|
|
3200 | SET_FLAG (who, FLAG_READY_WEAPON); |
|
|
3201 | |
|
|
3202 | 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)); |
3203 | |
3195 | |
|
|
3196 | SET_FLAG (who, FLAG_READY_WEAPON); |
3204 | change_abil (who, op); |
3197 | change_abil (who, op); |
3205 | break; |
3198 | break; |
3206 | |
3199 | |
3207 | case ARMOUR: |
3200 | case ARMOUR: |
3208 | case HELMET: |
3201 | case HELMET: |