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 | } |
… | |
… | |
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 | CLEAR_FLAG (op, FLAG_APPLIED); |
2620 | CLEAR_FLAG (op, FLAG_APPLIED); |
2621 | |
2621 | |
2622 | if (player *pl = who->contr) |
|
|
2623 | { |
|
|
2624 | if (op == pl->ranged_ob) pl->ranged_ob = 0; |
|
|
2625 | if (op == pl->combat_ob) pl->combat_ob = 0; |
|
|
2626 | |
|
|
2627 | if (op == who->current_weapon) |
|
|
2628 | who->change_weapon (pl->combat_ob ? pl->combat_ob : pl->ranged_ob); |
|
|
2629 | } |
|
|
2630 | else if (op == who->current_weapon) |
|
|
2631 | who->change_weapon (0); |
|
|
2632 | |
|
|
2633 | switch (op->type) |
2622 | switch (op->type) |
2634 | { |
2623 | { |
2635 | case SKILL_TOOL: |
2624 | case SKILL_TOOL: |
2636 | // unapplying a skill tool should also unapply the skill it governs |
2625 | // unapplying a skill tool should also unapply the skill it governs |
2637 | // but this is hard, as it shouldn't do so when the skill can |
2626 | // but this is hard, as it shouldn't do so when the skill can |
… | |
… | |
2645 | |
2634 | |
2646 | change_abil (who, op); |
2635 | change_abil (who, op); |
2647 | break; |
2636 | break; |
2648 | |
2637 | |
2649 | 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 | |
2650 | 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)); |
2651 | |
2647 | |
2652 | change_abil (who, op); |
2648 | change_abil (who, op); |
2653 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2649 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2654 | break; |
2650 | break; |
… | |
… | |
2720 | |
2716 | |
2721 | case BOW: |
2717 | case BOW: |
2722 | case WAND: |
2718 | case WAND: |
2723 | case ROD: |
2719 | case ROD: |
2724 | case HORN: |
2720 | case HORN: |
2725 | if (who->contr) |
2721 | if (player *pl = who->contr) |
|
|
2722 | { |
|
|
2723 | if (op == pl->ranged_ob) |
|
|
2724 | { |
|
|
2725 | pl->ranged_ob = 0; |
|
|
2726 | who->change_weapon (pl->combat_ob); |
|
|
2727 | } |
|
|
2728 | |
2726 | 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)); |
|
|
2730 | } |
2727 | else |
2731 | else |
2728 | { |
2732 | { |
2729 | who->change_skill (0); |
2733 | who->change_skill (0); |
2730 | |
2734 | |
2731 | if (op->type == BOW) |
2735 | if (op->type == BOW) |
… | |
… | |
3071 | { |
3075 | { |
3072 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3076 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3073 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3077 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3074 | } |
3078 | } |
3075 | |
3079 | |
|
|
3080 | splay (op); |
|
|
3081 | |
3076 | /* 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 */ |
3077 | if (int i = can_apply_object (who, op)) |
3083 | if (int i = can_apply_object (who, op)) |
3078 | { |
3084 | { |
3079 | if (i & CAN_APPLY_NEVER) |
3085 | if (i & CAN_APPLY_NEVER) |
3080 | { |
3086 | { |
… | |
… | |
3148 | switch (op->type) |
3154 | switch (op->type) |
3149 | { |
3155 | { |
3150 | case WEAPON: |
3156 | case WEAPON: |
3151 | if (!check_weapon_power (who, op->last_eat)) |
3157 | if (!check_weapon_power (who, op->last_eat)) |
3152 | { |
3158 | { |
3153 | 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. " |
3154 | "It would consume your soul!."); |
3160 | "It would consume your soul!."); |
3155 | |
3161 | |
3156 | if (tmp) |
3162 | if (tmp) |
3157 | insert_ob_in_ob (tmp, who); |
3163 | insert_ob_in_ob (tmp, who); |
3158 | |
3164 | |