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 |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License 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 |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | #include <cmath> |
24 | #include <cmath> |
26 | |
25 | |
… | |
… | |
69 | |
68 | |
70 | /* If the director has race set, only affect objects with a arch, |
69 | /* If the director has race set, only affect objects with a arch, |
71 | * name or race that matches. |
70 | * name or race that matches. |
72 | */ |
71 | */ |
73 | if ((op->race) && |
72 | if ((op->race) && |
74 | ((!(victim->arch && arch_flag && victim->arch->name) || op->race != victim->arch->name)) && |
73 | ((!(victim->arch && arch_flag && victim->arch->archname) || op->race != victim->arch->archname)) && |
75 | ((!(victim->name && name_flag) || op->race != victim->name)) && |
74 | ((!(victim->name && name_flag) || op->race != victim->name)) && |
76 | ((!(victim->race && race_flag) || op->race != victim->race))) |
75 | ((!(victim->race && race_flag) || op->race != victim->race))) |
77 | return 1; |
76 | return 1; |
78 | |
77 | |
79 | /* If the director has slaying set, only affect objects where none |
78 | /* If the director has slaying set, only affect objects where none |
80 | * of arch, name, or race match. |
79 | * of arch, name, or race match. |
81 | */ |
80 | */ |
82 | if ((op->slaying) && (((victim->arch && arch_flag && victim->arch->name && op->slaying == victim->arch->name))) || |
81 | if ((op->slaying) && (((victim->arch && arch_flag && victim->arch->archname && op->slaying == victim->arch->archname))) || |
83 | ((victim->name && name_flag && op->slaying == victim->name)) || |
82 | ((victim->name && name_flag && op->slaying == victim->name)) || |
84 | ((victim->race && race_flag && op->slaying == victim->race))) |
83 | ((victim->race && race_flag && op->slaying == victim->race))) |
85 | return 1; |
84 | return 1; |
86 | |
85 | |
87 | return 0; |
86 | return 0; |
… | |
… | |
158 | |
157 | |
159 | /** |
158 | /** |
160 | * This checks whether the object has a "on_use_yield" field, and if so generated and drops |
159 | * This checks whether the object has a "on_use_yield" field, and if so generated and drops |
161 | * matching item. |
160 | * matching item. |
162 | **/ |
161 | **/ |
163 | static void |
162 | void |
164 | handle_apply_yield (object *tmp) |
163 | handle_apply_yield (object *tmp) |
165 | { |
164 | { |
166 | const char *yield; |
165 | const char *yield; |
167 | |
166 | |
168 | yield = get_ob_key_value (tmp, "on_use_yield"); |
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
… | |
… | |
425 | return 0; |
424 | return 0; |
426 | |
425 | |
427 | op = op->below; |
426 | op = op->below; |
428 | while (op != NULL) |
427 | while (op != NULL) |
429 | { |
428 | { |
430 | if (strcmp (op->arch->name, item) == 0) |
429 | if (strcmp (op->arch->archname, item) == 0) |
431 | { |
430 | { |
432 | if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) |
431 | if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) |
433 | /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID)) |
432 | /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID)) |
434 | { |
433 | { |
435 | if (op->nrof == 0) /* this is necessary for artifact sacrifices --FD-- */ |
434 | if (op->nrof == 0) /* this is necessary for artifact sacrifices --FD-- */ |
… | |
… | |
459 | prev = op; |
458 | prev = op; |
460 | op = op->below; |
459 | op = op->below; |
461 | |
460 | |
462 | while (op != NULL) |
461 | while (op != NULL) |
463 | { |
462 | { |
464 | if (strcmp (op->arch->name, item) == 0) |
463 | if (strcmp (op->arch->archname, item) == 0) |
465 | { |
464 | { |
466 | if (op->nrof >= nrof) |
465 | if (op->nrof >= nrof) |
467 | { |
466 | { |
468 | decrease_ob_nr (op, nrof); |
467 | decrease_ob_nr (op, nrof); |
469 | return; |
468 | return; |
… | |
… | |
576 | op->update_stats (); |
575 | op->update_stats (); |
577 | return 1; |
576 | return 1; |
578 | } |
577 | } |
579 | |
578 | |
580 | /* Types of improvements, hidden in the sp field. */ |
579 | /* Types of improvements, hidden in the sp field. */ |
581 | #define IMPROVE_PREPARE 1 |
580 | #define IMPROVE_PREPARE 1 |
582 | #define IMPROVE_DAMAGE 2 |
581 | #define IMPROVE_DAMAGE 2 |
583 | #define IMPROVE_WEIGHT 3 |
582 | #define IMPROVE_WEIGHT 3 |
584 | #define IMPROVE_ENCHANT 4 |
583 | #define IMPROVE_ENCHANT 4 |
585 | #define IMPROVE_STR 5 |
584 | #define IMPROVE_STR 5 |
586 | #define IMPROVE_DEX 6 |
585 | #define IMPROVE_DEX 6 |
587 | #define IMPROVE_CON 7 |
586 | #define IMPROVE_CON 7 |
588 | #define IMPROVE_WIS 8 |
587 | #define IMPROVE_WIS 8 |
589 | #define IMPROVE_CHA 9 |
588 | #define IMPROVE_CHA 9 |
590 | #define IMPROVE_INT 10 |
589 | #define IMPROVE_INT 10 |
591 | #define IMPROVE_POW 11 |
590 | #define IMPROVE_POW 11 |
592 | |
|
|
593 | |
591 | |
594 | /** |
592 | /** |
595 | * This does the prepare weapon scroll. |
593 | * This does the prepare weapon scroll. |
596 | * Checks for sacrifice, and so on. |
594 | * Checks for sacrifice, and so on. |
597 | */ |
595 | */ |
598 | |
|
|
599 | int |
596 | int |
600 | prepare_weapon (object *op, object *improver, object *weapon) |
597 | prepare_weapon (object *op, object *improver, object *weapon) |
601 | { |
598 | { |
602 | int sacrifice_count, i; |
599 | int sacrifice_count, i; |
603 | char buf[MAX_BUF]; |
600 | char buf[MAX_BUF]; |
… | |
… | |
605 | if (weapon->level != 0) |
602 | if (weapon->level != 0) |
606 | { |
603 | { |
607 | new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared."); |
604 | new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared."); |
608 | return 0; |
605 | return 0; |
609 | } |
606 | } |
|
|
607 | |
610 | for (i = 0; i < NROFATTACKS; i++) |
608 | for (i = 0; i < NROFATTACKS; i++) |
611 | if (weapon->resist[i]) |
609 | if (weapon->resist[i]) |
612 | break; |
610 | break; |
613 | |
611 | |
614 | /* If we break out, i will be less than nrofattacks, preventing |
612 | /* If we break out, i will be less than nrofattacks, preventing |
… | |
… | |
620 | weapon->stats.ac) /* AC - only taifu's I think */ |
618 | weapon->stats.ac) /* AC - only taifu's I think */ |
621 | { |
619 | { |
622 | new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons."); |
620 | new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons."); |
623 | return 0; |
621 | return 0; |
624 | } |
622 | } |
|
|
623 | |
625 | sacrifice_count = check_sacrifice (op, improver); |
624 | sacrifice_count = check_sacrifice (op, improver); |
626 | if (sacrifice_count <= 0) |
625 | if (sacrifice_count <= 0) |
627 | return 0; |
626 | return 0; |
|
|
627 | |
628 | weapon->level = isqrt (sacrifice_count); |
628 | weapon->level = isqrt (sacrifice_count); |
629 | new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted."); |
629 | new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted."); |
630 | eat_item (op, improver->slaying, sacrifice_count); |
630 | eat_item (op, improver->slaying, sacrifice_count); |
631 | |
631 | |
632 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your *%s may be improved %d times.", &weapon->name, weapon->level); |
632 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your *%s may be improved %d times.", &weapon->name, weapon->level); |
… | |
… | |
855 | { |
855 | { |
856 | base = base - (base * settings.armor_speed_improvement) / 100; |
856 | base = base - (base * settings.armor_speed_improvement) / 100; |
857 | pow++; |
857 | pow++; |
858 | } |
858 | } |
859 | |
859 | |
860 | ARMOUR_SPEED (armour) = (ARMOUR_SPEED (&armour->arch->clone) * base) / 100; |
860 | ARMOUR_SPEED (armour) = (ARMOUR_SPEED (armour->arch) * base) / 100; |
861 | } |
861 | } |
862 | else |
862 | else |
863 | ARMOUR_SPEED (armour) = (ARMOUR_SPEED (&armour->arch->clone) * (100 + armour->magic * settings.armor_speed_improvement)) / 100; |
863 | ARMOUR_SPEED (armour) = (ARMOUR_SPEED (armour->arch) * (100 + armour->magic * settings.armor_speed_improvement)) / 100; |
864 | |
864 | |
865 | if (!settings.armor_weight_linear) |
865 | if (!settings.armor_weight_linear) |
866 | { |
866 | { |
867 | int base = 100; |
867 | int base = 100; |
868 | int pow = 0; |
868 | int pow = 0; |
… | |
… | |
871 | { |
871 | { |
872 | base = base - (base * settings.armor_weight_reduction) / 100; |
872 | base = base - (base * settings.armor_weight_reduction) / 100; |
873 | pow++; |
873 | pow++; |
874 | } |
874 | } |
875 | |
875 | |
876 | armour->weight = (armour->arch->clone.weight * base) / 100; |
876 | armour->weight = (armour->arch->weight * base) / 100; |
877 | } |
877 | } |
878 | else |
878 | else |
879 | armour->weight = (armour->arch->clone.weight * (100 - armour->magic * settings.armor_weight_reduction)) / 100; |
879 | armour->weight = (armour->arch->weight * (100 - armour->magic * settings.armor_weight_reduction)) / 100; |
880 | |
880 | |
881 | if (armour->weight <= 0) |
881 | if (armour->weight <= 0) |
882 | { |
882 | { |
883 | LOG (llevInfo, "Warning: enchanted armours can have negative weight\n."); |
883 | LOG (llevInfo, "Warning: enchanted armours can have negative weight\n."); |
884 | armour->weight = 1; |
884 | armour->weight = 1; |
885 | } |
885 | } |
886 | |
886 | |
887 | armour->item_power = get_power_from_ench (armour->arch->clone.item_power + armour->magic); |
887 | armour->item_power = get_power_from_ench (armour->arch->item_power + armour->magic); |
888 | |
888 | |
889 | if (op->type == PLAYER) |
889 | if (op->type == PLAYER) |
890 | { |
890 | { |
891 | esrv_send_item (op, armour); |
891 | esrv_send_item (op, armour); |
892 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
892 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
… | |
… | |
898 | insert_ob_in_ob (tmp, op); |
898 | insert_ob_in_ob (tmp, op); |
899 | esrv_send_item (op, tmp); |
899 | esrv_send_item (op, tmp); |
900 | } |
900 | } |
901 | return 1; |
901 | return 1; |
902 | } |
902 | } |
903 | |
|
|
904 | |
903 | |
905 | /* |
904 | /* |
906 | * convert_item() returns 1 if anything was converted, 0 if the item was not |
905 | * convert_item() returns 1 if anything was converted, 0 if the item was not |
907 | * what the converter wants, -1 if the converter is broken. |
906 | * what the converter wants, -1 if the converter is broken. |
908 | */ |
907 | */ |
… | |
… | |
924 | |
923 | |
925 | /* We make some assumptions - we assume if it takes money as it type, |
924 | /* We make some assumptions - we assume if it takes money as it type, |
926 | * it wants some amount. We don't make change (ie, if something costs |
925 | * it wants some amount. We don't make change (ie, if something costs |
927 | * 3 gp and player drops a platinum, tough luck) |
926 | * 3 gp and player drops a platinum, tough luck) |
928 | */ |
927 | */ |
929 | if (!strcmp (CONV_FROM (converter), "money")) |
928 | if (CONV_FROM (converter) == shstr_money) |
930 | { |
929 | { |
931 | int cost; |
|
|
932 | |
|
|
933 | if (item->type != MONEY) |
930 | if (item->type != MONEY) |
934 | return 0; |
931 | return 0; |
935 | |
932 | |
936 | nr = (item->nrof * item->value) / CONV_NEED (converter); |
933 | nr = (item->nrof * item->value) / CONV_NEED (converter); |
937 | if (!nr) |
934 | if (!nr) |
938 | return 0; |
935 | return 0; |
|
|
936 | |
|
|
937 | converter->play_sound (sound_find ("shop_buy")); |
|
|
938 | |
939 | cost = nr * CONV_NEED (converter) / item->value; |
939 | int cost = nr * CONV_NEED (converter) / item->value; |
940 | /* take into account rounding errors */ |
940 | /* take into account rounding errors */ |
941 | if (nr * CONV_NEED (converter) % item->value) |
941 | if (nr * CONV_NEED (converter) % item->value) |
942 | cost++; |
942 | cost++; |
|
|
943 | |
943 | decrease_ob_nr (item, cost); |
944 | decrease_ob_nr (item, cost); |
944 | |
945 | |
945 | price_in = cost * item->value; |
946 | price_in = cost * item->value; |
946 | } |
947 | } |
947 | else |
948 | else |
948 | { |
949 | { |
949 | if (item->type == PLAYER || CONV_FROM (converter) != item->arch->name || |
950 | if (item->type == PLAYER || CONV_FROM (converter) != item->arch->archname || |
950 | (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) |
951 | (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) |
951 | return 0; |
952 | return 0; |
|
|
953 | |
|
|
954 | converter->play_sound (sound_find ("convert_item")); |
952 | |
955 | |
953 | if (CONV_NEED (converter)) |
956 | if (CONV_NEED (converter)) |
954 | { |
957 | { |
955 | nr = item->nrof / CONV_NEED (converter); |
958 | nr = item->nrof / CONV_NEED (converter); |
956 | decrease_ob_nr (item, nr * CONV_NEED (converter)); |
959 | decrease_ob_nr (item, nr * CONV_NEED (converter)); |
… | |
… | |
961 | price_in = item->value; |
964 | price_in = item->value; |
962 | item->destroy (); |
965 | item->destroy (); |
963 | } |
966 | } |
964 | } |
967 | } |
965 | |
968 | |
966 | if (converter->inv != NULL) |
969 | if (converter->inv) |
967 | { |
970 | { |
968 | object *ob; |
971 | object *ob; |
969 | int i; |
972 | int i; |
970 | object *ob_to_copy; |
973 | object *ob_to_copy; |
971 | |
974 | |
972 | /* select random object from inventory to copy */ |
975 | /* select random object from inventory to copy */ |
973 | ob_to_copy = converter->inv; |
976 | ob_to_copy = converter->inv; |
974 | for (ob = converter->inv->below, i = 1; ob != NULL; ob = ob->below, i++) |
977 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
975 | { |
|
|
976 | if (rndm (0, i) == 0) |
978 | if (rndm (0, i) == 0) |
977 | { |
|
|
978 | ob_to_copy = ob; |
979 | ob_to_copy = ob; |
979 | } |
980 | |
980 | } |
|
|
981 | item = object_create_clone (ob_to_copy); |
981 | item = object_create_clone (ob_to_copy); |
982 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
982 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
983 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
983 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
984 | } |
984 | } |
985 | else |
985 | else |
… | |
… | |
995 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
995 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
996 | } |
996 | } |
997 | |
997 | |
998 | if (CONV_NR (converter)) |
998 | if (CONV_NR (converter)) |
999 | item->nrof = CONV_NR (converter); |
999 | item->nrof = CONV_NR (converter); |
|
|
1000 | |
1000 | if (nr) |
1001 | if (nr) |
1001 | item->nrof *= nr; |
1002 | item->nrof *= nr; |
|
|
1003 | |
1002 | if (is_in_shop (converter)) |
1004 | if (is_in_shop (converter)) |
1003 | SET_FLAG (item, FLAG_UNPAID); |
1005 | SET_FLAG (item, FLAG_UNPAID); |
1004 | else if (price_in < item->nrof * item->value) |
1006 | else if (price_in < item->nrof * item->value) |
1005 | { |
1007 | { |
1006 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1008 | 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); |
1009 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1008 | |
|
|
1009 | /** |
1010 | /** |
1010 | * elmex: we are going to let the game continue, as the mapcreator |
1011 | * elmex: we are going to let the game continue, as the mapcreator |
1011 | * propably had something in mind when doing this |
1012 | * hopefully had something in mind when doing this. |
1012 | */ |
1013 | */ |
1013 | } |
1014 | } |
|
|
1015 | |
|
|
1016 | SET_FLAG (item, FLAG_IDENTIFIED); |
1014 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1017 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1015 | return 1; |
1018 | return 1; |
1016 | } |
1019 | } |
1017 | |
1020 | |
1018 | /** |
1021 | /** |
… | |
… | |
1139 | double opinion; |
1142 | double opinion; |
1140 | object *tmp, *next; |
1143 | object *tmp, *next; |
1141 | |
1144 | |
1142 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
1145 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
1143 | |
1146 | |
|
|
1147 | bool has_unpaid = false; |
|
|
1148 | |
|
|
1149 | // quite inefficient to do this here twice, but the api doesn'T lend itself to |
|
|
1150 | // a quick and small change :( |
|
|
1151 | for (object::depth_iterator item = op->begin (); item != op->end (); ++item) |
|
|
1152 | if (item->flag [FLAG_UNPAID]) |
|
|
1153 | { |
|
|
1154 | has_unpaid = true; |
|
|
1155 | break; |
|
|
1156 | } |
|
|
1157 | |
1144 | if (op->type != PLAYER) |
1158 | if (op->type != PLAYER) |
1145 | { |
1159 | { |
1146 | /* Remove all the unpaid objects that may be carried here. |
1160 | /* Remove all the unpaid objects that may be carried here. |
1147 | * This could be pets or monsters that are somehow in |
1161 | * This could be pets or monsters that are somehow in |
1148 | * the shop. |
1162 | * the shop. |
… | |
… | |
1174 | /* unpaid objects, or non living objects, can't transfer by |
1188 | /* unpaid objects, or non living objects, can't transfer by |
1175 | * shop mats. Instead, put it on a nearby space. |
1189 | * shop mats. Instead, put it on a nearby space. |
1176 | */ |
1190 | */ |
1177 | if (QUERY_FLAG (op, FLAG_UNPAID) || !QUERY_FLAG (op, FLAG_ALIVE)) |
1191 | if (QUERY_FLAG (op, FLAG_UNPAID) || !QUERY_FLAG (op, FLAG_ALIVE)) |
1178 | { |
1192 | { |
1179 | |
|
|
1180 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
1193 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
1181 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
1194 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
1182 | |
1195 | |
1183 | if (i != -1) |
1196 | if (i != -1) |
1184 | rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, shop_mat); |
1197 | rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, shop_mat); |
… | |
… | |
1192 | } |
1205 | } |
1193 | else if (can_pay (op) && get_payment (op)) |
1206 | else if (can_pay (op) && get_payment (op)) |
1194 | { |
1207 | { |
1195 | /* this is only used for players */ |
1208 | /* this is only used for players */ |
1196 | rv = teleport (shop_mat, SHOP_MAT, op); |
1209 | rv = teleport (shop_mat, SHOP_MAT, op); |
|
|
1210 | |
|
|
1211 | if (has_unpaid) |
|
|
1212 | op->contr->play_sound (sound_find ("shop_buy")); |
|
|
1213 | else if (is_in_shop (op)) |
|
|
1214 | op->contr->play_sound (sound_find ("shop_enter")); |
|
|
1215 | else |
|
|
1216 | op->contr->play_sound (sound_find ("shop_leave")); |
1197 | |
1217 | |
1198 | if (shop_mat->msg) |
1218 | if (shop_mat->msg) |
1199 | new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); |
1219 | new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); |
1200 | /* This check below is a bit simplistic - generally it should be correct, |
1220 | /* This check below is a bit simplistic - generally it should be correct, |
1201 | * but there is never a guarantee that the bottom space on the map is |
1221 | * but there is never a guarantee that the bottom space on the map is |
… | |
… | |
1216 | } |
1236 | } |
1217 | } |
1237 | } |
1218 | else |
1238 | else |
1219 | { |
1239 | { |
1220 | /* if we get here, a player tried to leave a shop but was not able |
1240 | /* if we get here, a player tried to leave a shop but was not able |
1221 | * to afford the items he has. We try to move the player so that |
1241 | * to afford the items he has. We try to move the player so that |
1222 | * they are not on the mat anymore |
1242 | * they are not on the mat anymore |
1223 | */ |
1243 | */ |
1224 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
1244 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
1225 | |
1245 | |
1226 | if (i == -1) |
1246 | if (i == -1) |
1227 | { |
|
|
1228 | LOG (llevError, "Internal shop-mat problem.\n"); |
1247 | LOG (llevError, "Internal shop-mat problem.\n"); |
1229 | } |
|
|
1230 | else |
1248 | else |
1231 | { |
1249 | { |
1232 | op->remove (); |
1250 | op->remove (); |
1233 | op->x += freearr_x[i]; |
1251 | op->x += freearr_x[i]; |
1234 | op->y += freearr_y[i]; |
1252 | op->y += freearr_y[i]; |
… | |
… | |
1245 | */ |
1263 | */ |
1246 | static void |
1264 | static void |
1247 | apply_sign (object *op, object *sign, int autoapply) |
1265 | apply_sign (object *op, object *sign, int autoapply) |
1248 | { |
1266 | { |
1249 | readable_message_type *msgType; |
1267 | readable_message_type *msgType; |
1250 | char newbuf[HUGE_BUF]; |
|
|
1251 | |
1268 | |
1252 | if (sign->msg == NULL) |
1269 | if (sign->msg == NULL) |
1253 | { |
1270 | { |
1254 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is written on it."); |
1271 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is written on it."); |
1255 | return; |
1272 | return; |
… | |
… | |
1259 | { |
1276 | { |
1260 | if (sign->last_eat >= sign->stats.food) |
1277 | if (sign->last_eat >= sign->stats.food) |
1261 | { |
1278 | { |
1262 | if (!sign->move_on) |
1279 | if (!sign->move_on) |
1263 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot read it anymore."); |
1280 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot read it anymore."); |
|
|
1281 | |
1264 | return; |
1282 | return; |
1265 | } |
1283 | } |
1266 | |
1284 | |
1267 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1285 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1268 | sign->last_eat++; |
1286 | sign->last_eat++; |
… | |
… | |
1276 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
1294 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
1277 | { |
1295 | { |
1278 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1296 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1279 | return; |
1297 | return; |
1280 | } |
1298 | } |
|
|
1299 | |
|
|
1300 | if (op->contr) |
|
|
1301 | if (client *ns = op->contr->ns) |
|
|
1302 | { |
|
|
1303 | ns->play_sound (sign->sound); |
1281 | msgType = get_readable_message_type (sign); |
1304 | msgType = get_readable_message_type (sign); |
|
|
1305 | |
|
|
1306 | if (ns->can_msg) |
|
|
1307 | ns->send_msg (NDI_NAVY, msgType->msgtype, &sign->msg); |
|
|
1308 | else |
|
|
1309 | { |
|
|
1310 | char newbuf[HUGE_BUF]; |
1282 | snprintf (newbuf, sizeof (newbuf), "%hhu %s", autoapply ? 1 : 0, &sign->msg); |
1311 | snprintf (newbuf, sizeof (newbuf), "%u %s", autoapply ? 1 : 0, &sign->msg); |
1283 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, newbuf, &sign->msg); |
1312 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, newbuf, &sign->msg); |
|
|
1313 | } |
|
|
1314 | } |
1284 | } |
1315 | } |
1285 | |
1316 | |
1286 | /** |
1317 | /** |
1287 | * 'victim' moves onto 'trap' |
1318 | * 'victim' moves onto 'trap' |
1288 | * 'victim' leaves 'trap' |
1319 | * 'victim' leaves 'trap' |
… | |
… | |
1311 | * proper. This code was causing needless crashes. |
1342 | * proper. This code was causing needless crashes. |
1312 | */ |
1343 | */ |
1313 | if (recursion_depth >= 500) |
1344 | if (recursion_depth >= 500) |
1314 | { |
1345 | { |
1315 | LOG (llevDebug, "WARNING: move_apply(): aborting recursion " |
1346 | LOG (llevDebug, "WARNING: move_apply(): aborting recursion " |
1316 | "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->name, &trap->name, &victim->arch->name, &victim->name); |
1347 | "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->archname, &trap->name, &victim->arch->archname, &victim->name); |
1317 | return; |
1348 | return; |
1318 | } |
1349 | } |
|
|
1350 | |
1319 | recursion_depth++; |
1351 | recursion_depth++; |
1320 | if (trap->head) |
1352 | if (trap->head) |
1321 | trap = trap->head; |
1353 | trap = trap->head; |
1322 | |
1354 | |
1323 | if (INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
1355 | if (INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
… | |
… | |
1338 | |
1370 | |
1339 | /* Just put in some sanity check. I think there is a bug in the |
1371 | /* Just put in some sanity check. I think there is a bug in the |
1340 | * above with some objects have zero speed, and thus the player |
1372 | * above with some objects have zero speed, and thus the player |
1341 | * getting permanently paralyzed. |
1373 | * getting permanently paralyzed. |
1342 | */ |
1374 | */ |
1343 | if (victim->speed_left < -50.0) |
1375 | if (victim->speed_left < -50.f) |
1344 | victim->speed_left = -50.0; |
1376 | victim->speed_left = -50.f; |
1345 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
1377 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
1346 | } |
1378 | } |
1347 | goto leave; |
1379 | goto leave; |
1348 | |
1380 | |
1349 | case SPINNER: |
1381 | case SPINNER: |
… | |
… | |
1421 | |
1453 | |
1422 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1454 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1423 | { |
1455 | { |
1424 | if (!sound_was_played) |
1456 | if (!sound_was_played) |
1425 | { |
1457 | { |
1426 | play_sound_map (trap->map, trap->x, trap->y, SOUND_FALL_HOLE); |
1458 | trap->play_sound (sound_find ("fall_hole")); |
1427 | sound_was_played = 1; |
1459 | sound_was_played = 1; |
1428 | } |
1460 | } |
|
|
1461 | |
1429 | new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!"); |
1462 | new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!"); |
1430 | transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab); |
1463 | transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab); |
1431 | } |
1464 | } |
1432 | } |
1465 | } |
1433 | goto leave; |
1466 | goto leave; |
1434 | } |
1467 | } |
1435 | |
1468 | |
1436 | |
|
|
1437 | case CONVERTER: |
1469 | case CONVERTER: |
1438 | if (convert_item (victim, trap) < 0) |
1470 | if (convert_item (victim, trap) < 0) |
1439 | { |
1471 | { |
1440 | new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap)); |
1472 | new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap)); |
1441 | get_archetype ("burnout")->insert_at (trap, trap); |
1473 | get_archetype ("burnout")->insert_at (trap, trap); |
… | |
… | |
1466 | * Processing will happen if the head runs into the pit |
1498 | * Processing will happen if the head runs into the pit |
1467 | */ |
1499 | */ |
1468 | if (victim->head) |
1500 | if (victim->head) |
1469 | goto leave; |
1501 | goto leave; |
1470 | |
1502 | |
1471 | play_sound_map (victim->map, victim->x, victim->y, SOUND_FALL_HOLE); |
1503 | victim->play_sound (sound_find ("fall_hole")); |
1472 | new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n"); |
1504 | new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n"); |
1473 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1505 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1474 | goto leave; |
1506 | goto leave; |
1475 | |
1507 | |
1476 | case EXIT: |
1508 | case EXIT: |
… | |
… | |
1518 | } |
1550 | } |
1519 | goto leave; |
1551 | goto leave; |
1520 | |
1552 | |
1521 | default: |
1553 | default: |
1522 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1554 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1523 | "handled in move_apply()\n", &trap->name, &trap->arch->name, trap->type); |
1555 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
1524 | goto leave; |
1556 | goto leave; |
1525 | } |
1557 | } |
1526 | |
1558 | |
1527 | leave: |
1559 | leave: |
1528 | recursion_depth--; |
1560 | recursion_depth--; |
… | |
… | |
1540 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1572 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1541 | { |
1573 | { |
1542 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1574 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1543 | return; |
1575 | return; |
1544 | } |
1576 | } |
|
|
1577 | |
1545 | if (tmp->msg == NULL) |
1578 | if (!tmp->msg) |
1546 | { |
1579 | { |
1547 | new_draw_info_format (NDI_UNIQUE, 0, op, "You open the %s and find it empty.", &tmp->name); |
1580 | new_draw_info_format (NDI_UNIQUE, 0, op, "You open the %s and find it empty.", &tmp->name); |
1548 | return; |
1581 | return; |
1549 | } |
1582 | } |
1550 | |
1583 | |
1551 | /* need a literacy skill to read stuff! */ |
1584 | /* need a literacy skill to read stuff! */ |
1552 | skill_ob = find_skill_by_name (op, tmp->skill); |
1585 | skill_ob = find_skill_by_name (op, tmp->skill); |
1553 | if (!skill_ob) |
1586 | if (!skill_ob) |
1554 | { |
1587 | { |
1555 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1588 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the skill to read this>"); |
1556 | return; |
1589 | return; |
1557 | } |
1590 | } |
|
|
1591 | |
1558 | lev_diff = tmp->level - (skill_ob->level + 5); |
1592 | lev_diff = tmp->level - (skill_ob->level + 5); |
1559 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1593 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1560 | { |
1594 | { |
1561 | if (lev_diff < 2) |
1595 | if (lev_diff < 2) |
1562 | new_draw_info (NDI_UNIQUE, 0, op, "This book is just barely beyond your comprehension."); |
1596 | new_draw_info (NDI_UNIQUE, 0, op, "This book is just barely beyond your comprehension."); |
… | |
… | |
1573 | return; |
1607 | return; |
1574 | } |
1608 | } |
1575 | |
1609 | |
1576 | readable_message_type *msgType = get_readable_message_type (tmp); |
1610 | readable_message_type *msgType = get_readable_message_type (tmp); |
1577 | |
1611 | |
|
|
1612 | if (player *pl = op->contr) |
|
|
1613 | if (client *ns = pl->ns) |
|
|
1614 | if (ns->can_msg) |
|
|
1615 | { |
|
|
1616 | dynbuf_text buf; |
|
|
1617 | buf << long_desc (tmp, op) |
|
|
1618 | << "\n\n" |
|
|
1619 | << tmp->msg |
|
|
1620 | << '\0'; |
|
|
1621 | ns->send_msg (NDI_NAVY, msgType->msgtype, buf.linearise ()); |
|
|
1622 | } |
|
|
1623 | else |
1578 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
1624 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
1579 | msgType->message_type, msgType->message_subtype, |
1625 | msgType->message_type, msgType->message_subtype, |
1580 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
1626 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
1581 | long_desc (tmp, op), &tmp->msg); |
1627 | long_desc (tmp, op), &tmp->msg); |
1582 | |
1628 | |
1583 | /* gain xp from reading */ |
1629 | /* gain xp from reading */ |
1584 | if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) |
1630 | if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) |
1585 | { /* only if not read before */ |
1631 | { /* only if not read before */ |
1586 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
1632 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
… | |
… | |
1652 | return; |
1698 | return; |
1653 | } |
1699 | } |
1654 | return; |
1700 | return; |
1655 | } |
1701 | } |
1656 | |
1702 | |
1657 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1703 | op->contr->play_sound (sound_find ("learn_spell")); |
|
|
1704 | |
1658 | tmp = spell->clone (); |
1705 | tmp = spell->clone (); |
1659 | insert_ob_in_ob (tmp, op); |
1706 | insert_ob_in_ob (tmp, op); |
1660 | |
1707 | |
1661 | if (special_prayer) |
1708 | if (special_prayer) |
1662 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1709 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
… | |
… | |
1707 | |
1754 | |
1708 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1755 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1709 | * instead of having their spell stored in stats.sp. These are |
1756 | * instead of having their spell stored in stats.sp. These are |
1710 | * legacy spellbooks |
1757 | * legacy spellbooks |
1711 | */ |
1758 | */ |
1712 | |
|
|
1713 | if (tmp->slaying != NULL) |
1759 | if (tmp->slaying) |
1714 | { |
1760 | { |
1715 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1761 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1716 | if (!spell) |
1762 | if (!spell) |
1717 | { |
1763 | { |
1718 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1764 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1719 | return; |
1765 | return; |
1720 | } |
1766 | } |
1721 | else |
1767 | else |
1722 | insert_ob_in_ob (spell, tmp); |
1768 | insert_ob_in_ob (spell, tmp); |
|
|
1769 | |
1723 | tmp->slaying = NULL; |
1770 | tmp->slaying = 0; |
1724 | } |
1771 | } |
1725 | |
1772 | |
1726 | skop = find_skill_by_name (op, tmp->skill); |
1773 | skop = find_skill_by_name (op, tmp->skill); |
1727 | |
1774 | |
1728 | /* need a literacy skill to learn spells. Also, having a literacy level |
1775 | /* need a literacy skill to learn spells. Also, having a literacy level |
1729 | * lower than the spell will make learning the spell more difficult */ |
1776 | * lower than the spell will make learning the spell more difficult */ |
1730 | if (!skop) |
1777 | if (!skop) |
1731 | { |
1778 | { |
1732 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1779 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H<You lack the literacy skill.>"); |
1733 | return; |
1780 | return; |
1734 | } |
1781 | } |
1735 | |
1782 | |
1736 | spell = tmp->inv; |
1783 | spell = tmp->inv; |
1737 | |
1784 | |
1738 | if (!spell) |
1785 | if (!spell) |
1739 | { |
1786 | { |
1740 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1787 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1741 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); |
1788 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense. This is a bug, please report!"); |
1742 | return; |
1789 | return; |
1743 | } |
1790 | } |
1744 | |
1791 | |
1745 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1792 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1746 | { |
1793 | { |
1747 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. [Your literacy level is too low]"); |
1794 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<Your literacy level is too low.>"); |
1748 | return; |
1795 | return; |
1749 | } |
1796 | } |
1750 | |
1797 | |
1751 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1798 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1752 | |
1799 | |
… | |
… | |
1765 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1812 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1766 | * they would have a special prayer mark. |
1813 | * they would have a special prayer mark. |
1767 | */ |
1814 | */ |
1768 | if (check_spell_known (op, spell->name)) |
1815 | if (check_spell_known (op, spell->name)) |
1769 | { |
1816 | { |
1770 | new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell.\n"); |
1817 | new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell. H<It makes no sense to learn spells twice, and would only waste the spellbook.>\n"); |
1771 | return; |
1818 | return; |
1772 | } |
1819 | } |
1773 | |
1820 | |
1774 | if (spell->skill) |
1821 | if (spell->skill) |
1775 | { |
1822 | { |
… | |
… | |
1816 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1863 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1817 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1864 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1818 | } |
1865 | } |
1819 | else |
1866 | else |
1820 | { |
1867 | { |
1821 | play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); |
1868 | op->contr->play_sound (sound_find ("fumble_spell")); |
1822 | new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell.\n"); |
1869 | new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); |
1823 | } |
1870 | } |
1824 | |
1871 | |
1825 | decrease_ob (tmp); |
1872 | decrease_ob (tmp); |
1826 | } |
1873 | } |
1827 | |
1874 | |
… | |
… | |
1839 | return; |
1886 | return; |
1840 | } |
1887 | } |
1841 | |
1888 | |
1842 | if (!tmp->inv || tmp->inv->type != SPELL) |
1889 | if (!tmp->inv || tmp->inv->type != SPELL) |
1843 | { |
1890 | { |
1844 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense!"); |
1891 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>"); |
1845 | return; |
1892 | return; |
1846 | } |
1893 | } |
1847 | |
1894 | |
1848 | if (op->type == PLAYER) |
1895 | if (op->type == PLAYER) |
1849 | { |
1896 | { |
… | |
… | |
1855 | */ |
1902 | */ |
1856 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1903 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1857 | |
1904 | |
1858 | if (!skop) |
1905 | if (!skop) |
1859 | { |
1906 | { |
1860 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1907 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
1861 | return; |
1908 | return; |
1862 | } |
1909 | } |
1863 | |
1910 | |
1864 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1911 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1865 | change_exp (op, exp_gain, skop->skill, 0); |
1912 | change_exp (op, exp_gain, skop->skill, 0); |
… | |
… | |
1867 | |
1914 | |
1868 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1915 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1869 | identify (tmp); |
1916 | identify (tmp); |
1870 | |
1917 | |
1871 | new_draw_info_format (NDI_BLACK, 0, op, "The scroll of %s turns to dust.", &tmp->inv->name); |
1918 | new_draw_info_format (NDI_BLACK, 0, op, "The scroll of %s turns to dust.", &tmp->inv->name); |
1872 | |
|
|
1873 | |
1919 | |
1874 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1920 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1875 | decrease_ob (tmp); |
1921 | decrease_ob (tmp); |
1876 | } |
1922 | } |
1877 | |
1923 | |
… | |
… | |
1881 | * chest. |
1927 | * chest. |
1882 | */ |
1928 | */ |
1883 | static void |
1929 | static void |
1884 | apply_treasure (object *op, object *tmp) |
1930 | apply_treasure (object *op, object *tmp) |
1885 | { |
1931 | { |
1886 | object *treas; |
|
|
1887 | |
|
|
1888 | |
|
|
1889 | /* Nice side effect of new treasure creation method is that the treasure |
1932 | /* 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 |
1933 | * 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 |
1934 | * 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 |
1935 | * prevents people fromt moving chests to more difficult maps to get better |
1893 | * treasure |
1936 | * treasure |
1894 | */ |
1937 | */ |
1895 | |
|
|
1896 | treas = tmp->inv; |
1938 | object *treas = tmp->inv; |
1897 | if (treas == NULL) |
1939 | |
|
|
1940 | if (!treas) |
1898 | { |
1941 | { |
1899 | new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); |
1942 | new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); |
1900 | decrease_ob (tmp); |
1943 | decrease_ob (tmp); |
1901 | return; |
1944 | return; |
1902 | } |
1945 | } |
|
|
1946 | |
1903 | while (tmp->inv) |
1947 | while (tmp->inv) |
1904 | { |
1948 | { |
1905 | treas = tmp->inv; |
1949 | treas = tmp->inv; |
1906 | |
1950 | |
1907 | treas->remove (); |
1951 | treas->remove (); |
… | |
… | |
1989 | /* special food hack -b.t. */ |
2033 | /* special food hack -b.t. */ |
1990 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2034 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
1991 | eat_special_food (op, tmp); |
2035 | eat_special_food (op, tmp); |
1992 | } |
2036 | } |
1993 | } |
2037 | } |
|
|
2038 | |
1994 | handle_apply_yield (tmp); |
2039 | handle_apply_yield (tmp); |
1995 | decrease_ob (tmp); |
2040 | decrease_ob (tmp); |
1996 | } |
2041 | } |
1997 | |
2042 | |
1998 | /** |
2043 | /** |
… | |
… | |
2025 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2070 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2026 | return 0; |
2071 | return 0; |
2027 | |
2072 | |
2028 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2073 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2029 | from the player's inventory */ |
2074 | from the player's inventory */ |
2030 | shstr_cmp dragon_ability_force ("dragon_ability_force"); |
|
|
2031 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
|
|
2032 | |
|
|
2033 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2075 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2034 | if (tmp->type == FORCE) |
2076 | if (tmp->type == FORCE) |
2035 | if (tmp->arch->name == dragon_skin_force) |
2077 | if (tmp->arch->archname == shstr_dragon_skin_force) |
2036 | skin = tmp; |
2078 | skin = tmp; |
2037 | else if (tmp->arch->name == dragon_ability_force) |
2079 | else if (tmp->arch->archname == shstr_dragon_ability_force) |
2038 | abil = tmp; |
2080 | abil = tmp; |
2039 | |
2081 | |
2040 | /* if either skin or ability are missing, this is an old player |
2082 | /* if either skin or ability are missing, this is an old player |
2041 | which is not to be considered a dragon -> bail out */ |
2083 | which is not to be considered a dragon -> bail out */ |
2042 | if (skin == NULL || abil == NULL) |
2084 | if (skin == NULL || abil == NULL) |
… | |
… | |
2163 | static void |
2205 | static void |
2164 | apply_armour_improver (object *op, object *tmp) |
2206 | apply_armour_improver (object *op, object *tmp) |
2165 | { |
2207 | { |
2166 | object *armor; |
2208 | object *armor; |
2167 | |
2209 | |
2168 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
2210 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2169 | { |
2211 | { |
2170 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); |
2212 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H<The area prevents magic effects.>"); |
2171 | return; |
2213 | return; |
2172 | } |
2214 | } |
2173 | |
2215 | |
2174 | armor = find_marked_object (op); |
2216 | armor = find_marked_object (op); |
2175 | |
2217 | |
2176 | if (!armor) |
2218 | if (!armor) |
2177 | { |
2219 | { |
2178 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); |
2220 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2179 | return; |
2221 | return; |
2180 | } |
2222 | } |
2181 | |
2223 | |
2182 | if (armor->type != ARMOUR |
2224 | if (armor->type != ARMOUR |
2183 | && armor->type != CLOAK |
2225 | && armor->type != CLOAK |
… | |
… | |
2194 | extern void |
2236 | extern void |
2195 | apply_poison (object *op, object *tmp) |
2237 | apply_poison (object *op, object *tmp) |
2196 | { |
2238 | { |
2197 | if (op->type == PLAYER) |
2239 | if (op->type == PLAYER) |
2198 | { |
2240 | { |
2199 | play_sound_player_only (op->contr, SOUND_DRINK_POISON, 0, 0); |
2241 | op->contr->play_sound (sound_find ("drink_poison")); |
2200 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2242 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2201 | strcpy (op->contr->killer, "poisonous booze"); |
2243 | strcpy (op->contr->killer, "poisonous booze"); |
2202 | } |
2244 | } |
|
|
2245 | |
2203 | if (tmp->stats.hp > 0) |
2246 | if (tmp->stats.hp > 0) |
2204 | { |
2247 | { |
2205 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2248 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2206 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2249 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2207 | } |
2250 | } |
|
|
2251 | |
2208 | op->stats.food -= op->stats.food / 4; |
2252 | op->stats.food -= op->stats.food / 4; |
2209 | handle_apply_yield (tmp); |
2253 | handle_apply_yield (tmp); |
2210 | decrease_ob (tmp); |
2254 | decrease_ob (tmp); |
2211 | } |
2255 | } |
2212 | |
2256 | |
… | |
… | |
2322 | |
2366 | |
2323 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2367 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2324 | { |
2368 | { |
2325 | if (op->type == PLAYER) |
2369 | if (op->type == PLAYER) |
2326 | { |
2370 | { |
2327 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); |
2371 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H<You cannot use items marked as unpaid.>"); |
2328 | return 1; |
2372 | return 1; |
2329 | } |
2373 | } |
2330 | else |
2374 | else |
2331 | return 0; /* monsters just skip unpaid items */ |
2375 | return 0; /* monsters just skip unpaid items */ |
2332 | } |
2376 | } |
… | |
… | |
2336 | |
2380 | |
2337 | switch (tmp->type) |
2381 | switch (tmp->type) |
2338 | { |
2382 | { |
2339 | case CF_HANDLE: |
2383 | case CF_HANDLE: |
2340 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2384 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2341 | play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); |
2385 | op->play_sound (sound_find ("turn_handle")); |
2342 | tmp->value = tmp->value ? 0 : 1; |
2386 | tmp->value = tmp->value ? 0 : 1; |
2343 | SET_ANIMATION (tmp, tmp->value); |
2387 | SET_ANIMATION (tmp, tmp->value); |
2344 | update_object (tmp, UP_OBJ_FACE); |
2388 | update_object (tmp, UP_OBJ_FACE); |
2345 | push_button (tmp); |
2389 | push_button (tmp); |
2346 | return 1; |
2390 | return 1; |
2347 | |
2391 | |
2348 | case TRIGGER: |
2392 | case TRIGGER: |
2349 | if (check_trigger (tmp, op)) |
2393 | if (check_trigger (tmp, op)) |
2350 | { |
2394 | { |
2351 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2395 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2352 | play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); |
2396 | op->play_sound (sound_find ("turn_handle")); |
2353 | } |
2397 | } |
2354 | else |
2398 | else |
2355 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2399 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2356 | |
2400 | |
2357 | return 1; |
2401 | return 1; |
… | |
… | |
2369 | new_draw_info (NDI_NAVY, 0, op, tmp->msg); |
2413 | new_draw_info (NDI_NAVY, 0, op, tmp->msg); |
2370 | |
2414 | |
2371 | op->enter_exit (tmp); |
2415 | op->enter_exit (tmp); |
2372 | } |
2416 | } |
2373 | |
2417 | |
|
|
2418 | return 1; |
|
|
2419 | |
|
|
2420 | case INSCRIBABLE: |
|
|
2421 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
|
|
2422 | // maybe show a spell menu to chose from or something like that |
2374 | return 1; |
2423 | return 1; |
2375 | |
2424 | |
2376 | case SIGN: |
2425 | case SIGN: |
2377 | apply_sign (op, tmp, 0); |
2426 | apply_sign (op, tmp, 0); |
2378 | return 1; |
2427 | return 1; |
… | |
… | |
2490 | |
2539 | |
2491 | get_tod (&tod); |
2540 | get_tod (&tod); |
2492 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
2541 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
2493 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2542 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2494 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
2543 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
2495 | play_sound_player_only (op->contr, SOUND_CLOCK, 0, 0); |
2544 | op->play_sound (sound_find ("sound_clock")); |
2496 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2545 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2497 | return 1; |
2546 | return 1; |
2498 | } |
2547 | } |
2499 | else |
2548 | else |
2500 | return 0; |
2549 | return 0; |
… | |
… | |
2540 | int |
2589 | int |
2541 | player_apply (object *pl, object *op, int aflag, int quiet) |
2590 | player_apply (object *pl, object *op, int aflag, int quiet) |
2542 | { |
2591 | { |
2543 | int tmp; |
2592 | int tmp; |
2544 | |
2593 | |
2545 | if (op->env == NULL && (pl->move_type & MOVE_FLYING)) |
2594 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2546 | { |
2595 | { |
2547 | /* player is flying and applying object not in inventory */ |
2596 | /* player is flying and applying object not in inventory */ |
2548 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2597 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2549 | { |
2598 | { |
2550 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); |
2599 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2551 | return 0; |
2600 | return 0; |
2552 | } |
2601 | } |
2553 | } |
|
|
2554 | |
|
|
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 | } |
2602 | } |
2566 | |
2603 | |
2567 | pl->contr->last_used = op; |
2604 | pl->contr->last_used = op; |
2568 | |
2605 | |
2569 | tmp = manual_apply (pl, op, aflag); |
2606 | tmp = manual_apply (pl, op, aflag); |
… | |
… | |
2572 | if (tmp == 0) |
2609 | if (tmp == 0) |
2573 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2610 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2574 | else if (tmp == 2) |
2611 | else if (tmp == 2) |
2575 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2612 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2576 | } |
2613 | } |
|
|
2614 | |
2577 | return tmp; |
2615 | return tmp; |
2578 | } |
2616 | } |
2579 | |
2617 | |
2580 | /** |
2618 | /** |
2581 | * player_apply_below attempts to apply the object 'below' the player. |
2619 | * player_apply_below attempts to apply the object 'below' the player. |
… | |
… | |
2630 | { |
2668 | { |
2631 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
2669 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
2632 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2670 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2633 | return RESULT_INT (0); |
2671 | return RESULT_INT (0); |
2634 | |
2672 | |
2635 | object *tmp2; |
|
|
2636 | |
|
|
2637 | CLEAR_FLAG (op, FLAG_APPLIED); |
2673 | CLEAR_FLAG (op, FLAG_APPLIED); |
2638 | |
2674 | |
2639 | switch (op->type) |
2675 | switch (op->type) |
2640 | { |
2676 | { |
|
|
2677 | case SKILL_TOOL: |
|
|
2678 | // unapplying a skill tool should also unapply the skill it governs |
|
|
2679 | // but this is hard, as it shouldn't do so when the skill can |
|
|
2680 | // be used for other reasons |
|
|
2681 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
|
|
2682 | if (tmp->skill == op->skill |
|
|
2683 | && tmp->type == SKILL |
|
|
2684 | && tmp->flag [FLAG_APPLIED] |
|
|
2685 | && !tmp->flag [FLAG_CAN_USE_SKILL]) |
|
|
2686 | unapply_special (who, tmp, 0); |
|
|
2687 | |
|
|
2688 | change_abil (who, op); |
|
|
2689 | break; |
|
|
2690 | |
2641 | case WEAPON: |
2691 | case WEAPON: |
|
|
2692 | if (player *pl = who->contr) |
|
|
2693 | if (op == pl->combat_ob) |
|
|
2694 | { |
|
|
2695 | pl->combat_ob = 0; |
|
|
2696 | who->change_weapon (pl->ranged_ob); |
|
|
2697 | } |
|
|
2698 | |
2642 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2699 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2643 | |
2700 | |
2644 | change_abil (who, op); |
2701 | change_abil (who, op); |
2645 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2702 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2646 | |
|
|
2647 | if (who->contr) |
|
|
2648 | { |
|
|
2649 | if (who->contr->combat_ob == op) |
|
|
2650 | who->contr->combat_ob = 0; |
|
|
2651 | |
|
|
2652 | if (who->current_weapon == op) |
|
|
2653 | who->current_weapon = 0; |
|
|
2654 | } |
|
|
2655 | |
|
|
2656 | clear_skill (who); |
|
|
2657 | break; |
2703 | break; |
2658 | |
2704 | |
2659 | case SKILL: /* allows objects to impart skills */ |
|
|
2660 | case SKILL_TOOL: |
2705 | case SKILL: |
2661 | if (op != who->chosen_skill) |
|
|
2662 | LOG (llevError, "BUG: apply_special(): applied skill is not a chosen skill\n"); |
|
|
2663 | |
|
|
2664 | if (who->contr) |
2706 | if (who->contr) |
2665 | { |
2707 | { |
2666 | if (!op->invisible) |
2708 | if (!op->invisible) |
2667 | new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); |
2709 | new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); |
2668 | else |
2710 | else |
2669 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); |
2711 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); |
2670 | } |
2712 | } |
2671 | |
2713 | |
2672 | change_abil (who, op); |
2714 | change_abil (who, op); |
2673 | who->chosen_skill = 0; |
|
|
2674 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2715 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2675 | break; |
2716 | break; |
2676 | |
2717 | |
2677 | case ARMOUR: |
2718 | case ARMOUR: |
2678 | case HELMET: |
2719 | case HELMET: |
… | |
… | |
2687 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); |
2728 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); |
2688 | change_abil (who, op); |
2729 | change_abil (who, op); |
2689 | break; |
2730 | break; |
2690 | |
2731 | |
2691 | case LAMP: |
2732 | case LAMP: |
|
|
2733 | { |
2692 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); |
2734 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); |
|
|
2735 | |
2693 | tmp2 = arch_to_object (op->other_arch); |
2736 | object *tmp2 = arch_to_object (op->other_arch); |
2694 | tmp2->x = op->x; |
2737 | tmp2->x = op->x; |
2695 | tmp2->y = op->y; |
2738 | tmp2->y = op->y; |
2696 | tmp2->map = op->map; |
2739 | tmp2->map = op->map; |
2697 | tmp2->below = op->below; |
2740 | tmp2->below = op->below; |
2698 | tmp2->above = op->above; |
2741 | tmp2->above = op->above; |
2699 | tmp2->stats.food = op->stats.food; |
2742 | tmp2->stats.food = op->stats.food; |
2700 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2743 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2701 | |
2744 | |
2702 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2745 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2703 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2746 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2704 | |
2747 | |
2705 | if (who->contr) |
2748 | if (who->contr) |
2706 | esrv_del_item (who->contr, op->count); |
2749 | esrv_del_item (who->contr, op->count); |
2707 | |
2750 | |
2708 | op->destroy (); |
2751 | op->destroy (); |
2709 | insert_ob_in_ob (tmp2, who); |
2752 | insert_ob_in_ob (tmp2, who); |
2710 | who->update_stats (); |
2753 | who->update_stats (); |
2711 | |
2754 | |
2712 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2755 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2713 | { |
2756 | { |
2714 | if (who->contr) |
2757 | if (who->contr) |
2715 | { |
2758 | { |
2716 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
2759 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
2717 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2760 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2718 | } |
2761 | } |
2719 | } |
2762 | } |
2720 | |
2763 | |
2721 | if (who->contr) |
2764 | if (who->contr) |
2722 | esrv_send_item (who, tmp2); |
2765 | esrv_send_item (who, tmp2); |
|
|
2766 | } |
2723 | |
2767 | |
2724 | return 1; /* otherwise, an attempt to drop causes problems */ |
2768 | return 1; /* otherwise, an attempt to drop causes problems */ |
2725 | |
2769 | |
2726 | case BOW: |
2770 | case BOW: |
2727 | case WAND: |
2771 | case WAND: |
2728 | case ROD: |
2772 | case ROD: |
2729 | case HORN: |
2773 | case HORN: |
2730 | clear_skill (who); |
|
|
2731 | |
|
|
2732 | if (who->contr) |
2774 | if (player *pl = who->contr) |
|
|
2775 | { |
|
|
2776 | if (op == pl->ranged_ob) |
2733 | { |
2777 | { |
|
|
2778 | pl->ranged_ob = 0; |
|
|
2779 | who->change_weapon (pl->combat_ob); |
|
|
2780 | } |
|
|
2781 | |
2734 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2782 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2735 | |
|
|
2736 | if (who->contr->ranged_ob == op) |
|
|
2737 | who->contr->ranged_ob = 0; |
|
|
2738 | |
|
|
2739 | if (who->current_weapon == op) |
|
|
2740 | who->current_weapon = 0; |
|
|
2741 | } |
2783 | } |
2742 | else |
2784 | else |
2743 | { |
2785 | { |
|
|
2786 | who->change_skill (0); |
|
|
2787 | |
2744 | if (op->type == BOW) |
2788 | if (op->type == BOW) |
2745 | CLEAR_FLAG (who, FLAG_READY_BOW); |
2789 | CLEAR_FLAG (who, FLAG_READY_BOW); |
2746 | else |
2790 | else |
2747 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
2791 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
2748 | } |
2792 | } |
2749 | |
2793 | |
2750 | break; |
2794 | break; |
2751 | |
2795 | |
2752 | case BUILDER: |
2796 | case BUILDER: |
2753 | if (who->contr) |
2797 | if (who->contr) |
2754 | { |
|
|
2755 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2798 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2756 | |
|
|
2757 | if (who->contr->ranged_ob == op) |
|
|
2758 | who->contr->ranged_ob = 0; |
|
|
2759 | } |
|
|
2760 | break; |
2799 | break; |
2761 | |
2800 | |
2762 | default: |
2801 | default: |
2763 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2802 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2764 | break; |
2803 | break; |
… | |
… | |
2788 | /** |
2827 | /** |
2789 | * Returns the object that is using location 'loc'. |
2828 | * Returns the object that is using location 'loc'. |
2790 | * Note that 'start' is the first object to start examing - we |
2829 | * Note that 'start' is the first object to start examing - we |
2791 | * then go through the below of this. In this way, you can do |
2830 | * then go through the below of this. In this way, you can do |
2792 | * something like: |
2831 | * something like: |
2793 | * tmp = get_item_from_body_location(who->inv, 1); |
2832 | * tmp = get_next_item_from_body_location(who->inv, 1); |
2794 | * if (tmp) tmp1 = get_item_from_body_location(tmp->below, 1); |
2833 | * if (tmp) tmp1 = get_next_item_from_body_location(tmp->below, 1); |
2795 | * to find the second object that may use this location, etc. |
2834 | * to find the second object that may use this location, etc. |
2796 | * Returns NULL if no match is found. |
2835 | * Returns NULL if no match is found. |
2797 | * loc is the index into the array we are looking for a match. |
2836 | * loc is the index into the array we are looking for a match. |
2798 | * don't return invisible objects unless they are skill objects |
2837 | * don't return invisible objects unless they are skill objects |
2799 | * invisible other objects that use |
2838 | * invisible other objects that use |
2800 | * up body locations can be used as restrictions. |
2839 | * up body locations can be used as restrictions. |
2801 | */ |
2840 | */ |
2802 | static object * |
2841 | static object * |
2803 | get_item_from_body_location (int loc, object *start) |
2842 | get_next_item_from_body_location (int loc, object *start) |
2804 | { |
2843 | { |
2805 | if (start) |
|
|
2806 | for (object *tmp = start; tmp; tmp = tmp->below) |
2844 | for (object *tmp = start; tmp; tmp = tmp->below) |
2807 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->slot[loc].info && (!tmp->invisible || tmp->type == SKILL)) |
2845 | if (tmp->flag [FLAG_APPLIED] |
|
|
2846 | && tmp->slot[loc].info |
|
|
2847 | && (!tmp->invisible || tmp->type == SKILL)) |
2808 | return tmp; |
2848 | return tmp; |
2809 | |
2849 | |
2810 | return 0; |
2850 | return 0; |
2811 | } |
2851 | } |
2812 | |
2852 | |
2813 | /** |
2853 | /** |
… | |
… | |
2819 | * Returns 0 on success, returns 1 if there is some problem. |
2859 | * Returns 0 on success, returns 1 if there is some problem. |
2820 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2860 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2821 | * instead of doing it. This is a lot less code than having |
2861 | * instead of doing it. This is a lot less code than having |
2822 | * another function that does just that. |
2862 | * another function that does just that. |
2823 | */ |
2863 | */ |
|
|
2864 | |
|
|
2865 | #define CANNOT_REMOVE_CURSED \ |
|
|
2866 | "H<You cannot remove cursed or damned items, you first have to remove the curse. " \ |
|
|
2867 | "Praying over an altar, scrolls of remove curse/damnation, " \ |
|
|
2868 | "priests or even other players might help.>" |
|
|
2869 | |
2824 | int |
2870 | int |
2825 | unapply_for_ob (object *who, object *op, int aflags) |
2871 | unapply_for_ob (object *who, object *op, int aflags) |
2826 | { |
2872 | { |
2827 | if (op->is_range ()) |
2873 | if (op->is_range ()) |
2828 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2874 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
… | |
… | |
2838 | { |
2884 | { |
2839 | /* In this case, we want to try and remove a cursed item. |
2885 | /* In this case, we want to try and remove a cursed item. |
2840 | * While we know it won't work, we want unapply_special to |
2886 | * While we know it won't work, we want unapply_special to |
2841 | * at least generate the message. |
2887 | * at least generate the message. |
2842 | */ |
2888 | */ |
2843 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove the %s.", query_name (tmp)); |
2889 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
2890 | "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, |
|
|
2891 | query_name (tmp)); |
2844 | return 1; |
2892 | return 1; |
2845 | } |
2893 | } |
2846 | |
2894 | |
2847 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2895 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2848 | { |
2896 | { |
… | |
… | |
2854 | /* We do a while loop - may need to remove several items in order |
2902 | /* We do a while loop - may need to remove several items in order |
2855 | * to free up enough slots. |
2903 | * to free up enough slots. |
2856 | */ |
2904 | */ |
2857 | while ((who->slot[i].used + op->slot[i].info) < 0) |
2905 | while ((who->slot[i].used + op->slot[i].info) < 0) |
2858 | { |
2906 | { |
2859 | object *tmp = get_item_from_body_location (i, last); |
2907 | object *tmp = get_next_item_from_body_location (i, last); |
2860 | |
2908 | |
2861 | if (!tmp) |
2909 | if (!tmp) |
2862 | { |
2910 | { |
2863 | #if 0 |
2911 | #if 0 |
2864 | /* Not a bug - we'll get this if the player has cursed items |
2912 | /* Not a bug - we'll get this if the player has cursed items |
… | |
… | |
2882 | /* Cursed item that we can't unequip - tell the player. |
2930 | /* Cursed item that we can't unequip - tell the player. |
2883 | * Note this could be annoying if this is just one of a few, |
2931 | * Note this could be annoying if this is just one of a few, |
2884 | * so it may not be critical (eg, putting on a ring and you have |
2932 | * so it may not be critical (eg, putting on a ring and you have |
2885 | * one cursed ring.) |
2933 | * one cursed ring.) |
2886 | */ |
2934 | */ |
2887 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off", query_name (tmp)); |
2935 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
2888 | } |
2936 | } |
2889 | |
2937 | |
2890 | last = tmp->below; |
2938 | last = tmp->below; |
2891 | } |
2939 | } |
2892 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
2940 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
2902 | * Checks to see if 'who' can apply object 'op'. |
2950 | * Checks to see if 'who' can apply object 'op'. |
2903 | * Returns 0 if apply can be done without anything special. |
2951 | * Returns 0 if apply can be done without anything special. |
2904 | * Otherwise returns a bitmask - potentially several of these may be |
2952 | * Otherwise returns a bitmask - potentially several of these may be |
2905 | * set, but largely depends on circumstance - in the future, processing |
2953 | * set, but largely depends on circumstance - in the future, processing |
2906 | * may be pruned once we know some status (eg, once CAN_APPLY_NEVER |
2954 | * may be pruned once we know some status (eg, once CAN_APPLY_NEVER |
2907 | * is set, do we really are what the other flags may be?) |
2955 | * is set, do we really care what the other flags may be?) |
2908 | * |
2956 | * |
2909 | * See include/define.h for detailed description of the meaning of |
2957 | * See include/define.h for detailed description of the meaning of |
2910 | * these return values. |
2958 | * these return values. |
2911 | */ |
2959 | */ |
2912 | int |
2960 | int |
… | |
… | |
2921 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2969 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2922 | { |
2970 | { |
2923 | if (op->slot[i].info) |
2971 | if (op->slot[i].info) |
2924 | { |
2972 | { |
2925 | /* Item uses more slots than we have */ |
2973 | /* Item uses more slots than we have */ |
2926 | if (abs (op->slot[i].info) > who->slot[i].info) |
2974 | if (who->slot[i].info + op->slot [i].info < 0) |
2927 | { |
2975 | { |
2928 | /* Could return now for efficiency - rest of info below isn't |
2976 | /* Could return now for efficiency - rest of info below isn't |
2929 | * really needed. |
2977 | * really needed. |
2930 | */ |
2978 | */ |
2931 | retval |= CAN_APPLY_NEVER; |
2979 | retval |= CAN_APPLY_NEVER; |
2932 | } |
2980 | } |
2933 | else if ((who->slot[i].used + op->slot[i].info) < 0) |
2981 | else if (who->slot[i].used + op->slot[i].info < 0) |
2934 | { |
2982 | { |
2935 | /* in this case, equipping this would use more free spots than |
2983 | /* in this case, equipping this would use more free spots than |
2936 | * we have. |
2984 | * we have. |
2937 | */ |
2985 | */ |
2938 | |
2986 | |
… | |
… | |
2949 | { |
2997 | { |
2950 | retval |= CAN_APPLY_UNAPPLY; |
2998 | retval |= CAN_APPLY_UNAPPLY; |
2951 | continue; |
2999 | continue; |
2952 | } |
3000 | } |
2953 | |
3001 | |
2954 | object *tmp1 = get_item_from_body_location (i, who->inv); |
3002 | object *tmp1 = get_next_item_from_body_location (i, who->inv); |
2955 | if (!tmp1) |
3003 | if (!tmp1) |
2956 | { |
3004 | { |
2957 | #if 0 |
3005 | #if 0 |
2958 | /* This is sort of an error, but happens a lot when old players |
3006 | /* This is sort of an error, but happens a lot when old players |
2959 | * join in with more stuff equipped than they are now allowed. |
3007 | * join in with more stuff equipped than they are now allowed. |
… | |
… | |
2967 | /* need to unapply something. However, if this something |
3015 | /* need to unapply something. However, if this something |
2968 | * is different than we had found before, it means they need |
3016 | * is different than we had found before, it means they need |
2969 | * to apply multiple objects |
3017 | * to apply multiple objects |
2970 | */ |
3018 | */ |
2971 | retval |= CAN_APPLY_UNAPPLY; |
3019 | retval |= CAN_APPLY_UNAPPLY; |
|
|
3020 | |
2972 | if (!tmp) |
3021 | if (!tmp) |
2973 | tmp = tmp1; |
3022 | tmp = tmp1; |
2974 | else if (tmp != tmp1) |
3023 | else if (tmp != tmp1) |
2975 | retval |= CAN_APPLY_UNAPPLY_MULT; |
3024 | retval |= CAN_APPLY_UNAPPLY_MULT; |
2976 | |
3025 | |
… | |
… | |
3038 | * AP_UNAPPLY=always unapply). |
3087 | * AP_UNAPPLY=always unapply). |
3039 | * |
3088 | * |
3040 | * Optional flags: |
3089 | * Optional flags: |
3041 | * AP_NO_MERGE: don't merge an unapplied object with other objects |
3090 | * AP_NO_MERGE: don't merge an unapplied object with other objects |
3042 | * AP_IGNORE_CURSE: unapply cursed items |
3091 | * AP_IGNORE_CURSE: unapply cursed items |
|
|
3092 | * AP_NO_READY: do not ready skills when applying skill tools |
3043 | * |
3093 | * |
3044 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3094 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3045 | * |
3095 | * |
3046 | * apply_special() doesn't check for unpaid items. |
3096 | * apply_special() doesn't check for unpaid items. |
3047 | */ |
3097 | */ |
|
|
3098 | |
|
|
3099 | #define LACK_ITEM_POWER \ |
|
|
3100 | " H<You lack enough unused item power to use this weapon, see the skills command.>" |
|
|
3101 | |
3048 | int |
3102 | int |
3049 | apply_special (object *who, object *op, int aflags) |
3103 | apply_special (object *who, object *op, int aflags) |
3050 | { |
3104 | { |
3051 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3105 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3052 | object *tmp, *tmp2, *skop = NULL; |
3106 | object *tmp, *tmp2, *skop = NULL; |
… | |
… | |
3067 | if (basic_flag == AP_APPLY) |
3121 | if (basic_flag == AP_APPLY) |
3068 | return 0; |
3122 | return 0; |
3069 | |
3123 | |
3070 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3124 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3071 | { |
3125 | { |
3072 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op)); |
3126 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3127 | "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, |
|
|
3128 | query_name (op)); |
3073 | return 1; |
3129 | return 1; |
3074 | } |
3130 | } |
3075 | |
3131 | |
3076 | return unapply_special (who, op, aflags); |
3132 | return unapply_special (who, op, aflags); |
3077 | } |
3133 | } |
… | |
… | |
3080 | return 0; |
3136 | return 0; |
3081 | |
3137 | |
3082 | // if the item is combat/ranged, wield the relevant slot first |
3138 | // if the item is combat/ranged, wield the relevant slot first |
3083 | // to resolve conflicts. |
3139 | // to resolve conflicts. |
3084 | if (player *pl = who->contr) |
3140 | if (player *pl = who->contr) |
3085 | switch (op->type) |
3141 | switch (op->slottype ()) |
3086 | { |
3142 | { |
3087 | case WEAPON: |
|
|
3088 | who->change_weapon (pl->combat_ob); |
3143 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
3089 | break; |
|
|
3090 | |
|
|
3091 | case BOW: |
|
|
3092 | case ROD: |
|
|
3093 | case WAND: |
|
|
3094 | case HORN: |
|
|
3095 | case SKILL_TOOL: |
|
|
3096 | who->change_weapon (pl->ranged_ob); |
3144 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
3097 | break; |
|
|
3098 | |
|
|
3099 | case SKILL: |
|
|
3100 | if (IS_COMBAT_SKILL (op->subtype)) |
|
|
3101 | who->change_weapon (pl->combat_ob); |
|
|
3102 | else if (IS_RANGED_SKILL (op->subtype)) |
|
|
3103 | who->change_weapon (pl->ranged_ob); |
|
|
3104 | break; |
|
|
3105 | } |
3145 | } |
|
|
3146 | |
|
|
3147 | splay (op); |
3106 | |
3148 | |
3107 | /* Can't just apply this object. Lets see what not and what to do */ |
3149 | /* Can't just apply this object. Lets see what not and what to do */ |
3108 | if (int i = can_apply_object (who, op)) |
3150 | if (int i = can_apply_object (who, op)) |
3109 | { |
3151 | { |
3110 | if (i & CAN_APPLY_NEVER) |
3152 | if (i & CAN_APPLY_NEVER) |
3111 | { |
3153 | { |
3112 | new_draw_info_format (NDI_UNIQUE, 0, who, "You don't have the body to use a %s\n", query_name (op)); |
3154 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3155 | "You don't have the body to use a %s. H<You can never apply this item.>", |
|
|
3156 | query_name (op)); |
3113 | return 1; |
3157 | return 1; |
3114 | } |
3158 | } |
3115 | else if (i & CAN_APPLY_RESTRICTION) |
3159 | else if (i & CAN_APPLY_RESTRICTION) |
3116 | { |
3160 | { |
3117 | new_draw_info_format (NDI_UNIQUE, 0, who, "You have a prohibition against using a %s\n", query_name (op)); |
3161 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3162 | "You have a prohibition against using a %s. " |
|
|
3163 | "H<Your belief, profession or class prevents you from applying this item.>", |
|
|
3164 | query_name (op)); |
3118 | return 1; |
3165 | return 1; |
3119 | } |
3166 | } |
3120 | |
3167 | |
3121 | if (who->type != PLAYER) |
3168 | if (who->type != PLAYER) |
3122 | { |
3169 | { |
… | |
… | |
3149 | } |
3196 | } |
3150 | else |
3197 | else |
3151 | /* While experience will be credited properly, we want to change the |
3198 | /* While experience will be credited properly, we want to change the |
3152 | * skill so that the dam and wc get updated |
3199 | * skill so that the dam and wc get updated |
3153 | */ |
3200 | */ |
3154 | change_skill (who, skop, 0); |
3201 | who->change_skill (skop); |
3155 | } |
3202 | } |
3156 | |
3203 | |
3157 | if (who->type == PLAYER |
3204 | if (who->type == PLAYER |
3158 | && op->item_power |
3205 | && op->item_power |
3159 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3206 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3160 | { |
3207 | { |
3161 | new_draw_info (NDI_UNIQUE, 0, who, |
3208 | new_draw_info (NDI_UNIQUE, 0, who, |
3162 | "Equipping that combined with other items would consume your soul! " |
3209 | "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3163 | "[use the skills command to check your available item power]"); |
|
|
3164 | return 1; |
3210 | return 1; |
3165 | } |
3211 | } |
3166 | |
3212 | |
3167 | /* Ok. We are now at the state where we can apply the new object. |
3213 | /* Ok. We are now at the state where we can apply the new object. |
3168 | * Note that we don't have the checks for can_use_... |
3214 | * Note that we don't have the checks for can_use_... |
… | |
… | |
3179 | switch (op->type) |
3225 | switch (op->type) |
3180 | { |
3226 | { |
3181 | case WEAPON: |
3227 | case WEAPON: |
3182 | if (!check_weapon_power (who, op->last_eat)) |
3228 | if (!check_weapon_power (who, op->last_eat)) |
3183 | { |
3229 | { |
3184 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use.\n" |
3230 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3185 | "It would consume your soul!."); |
3231 | "It would consume your soul!." LACK_ITEM_POWER); |
3186 | |
3232 | |
3187 | if (tmp) |
3233 | if (tmp) |
3188 | insert_ob_in_ob (tmp, who); |
3234 | insert_ob_in_ob (tmp, who); |
3189 | |
3235 | |
3190 | return 1; |
3236 | return 1; |
… | |
… | |
3194 | // i.e. "R" can use Ragnarok's sword. |
3240 | // i.e. "R" can use Ragnarok's sword. |
3195 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3241 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3196 | { |
3242 | { |
3197 | /* if the weapon does not have the name as the character, can't use it. */ |
3243 | /* if the weapon does not have the name as the character, can't use it. */ |
3198 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3244 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3199 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3245 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3246 | "The weapon does not recognize you as its owner. " |
|
|
3247 | "H<Its name indicates that it belongs to somebody else.>"); |
3200 | |
3248 | |
3201 | if (tmp) |
3249 | if (tmp) |
3202 | insert_ob_in_ob (tmp, who); |
3250 | insert_ob_in_ob (tmp, who); |
3203 | |
3251 | |
3204 | return 1; |
3252 | return 1; |
… | |
… | |
3209 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3257 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3210 | return 1; |
3258 | return 1; |
3211 | } |
3259 | } |
3212 | |
3260 | |
3213 | SET_FLAG (op, FLAG_APPLIED); |
3261 | SET_FLAG (op, FLAG_APPLIED); |
3214 | change_skill (who, skop, 1); |
3262 | who->change_skill (skop); |
3215 | |
3263 | |
3216 | if (who->contr) |
3264 | if (who->contr) |
3217 | who->change_weapon (who->contr->combat_ob = op); |
3265 | who->change_weapon (who->contr->combat_ob = op); |
3218 | |
3266 | |
3219 | if (!QUERY_FLAG (who, FLAG_READY_WEAPON)) |
|
|
3220 | SET_FLAG (who, FLAG_READY_WEAPON); |
|
|
3221 | |
|
|
3222 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3267 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3223 | |
3268 | |
|
|
3269 | SET_FLAG (who, FLAG_READY_WEAPON); |
3224 | change_abil (who, op); |
3270 | change_abil (who, op); |
3225 | break; |
3271 | break; |
3226 | |
3272 | |
3227 | case ARMOUR: |
3273 | case ARMOUR: |
3228 | case HELMET: |
3274 | case HELMET: |
… | |
… | |
3240 | break; |
3286 | break; |
3241 | |
3287 | |
3242 | case LAMP: |
3288 | case LAMP: |
3243 | if (op->stats.food < 1) |
3289 | if (op->stats.food < 1) |
3244 | { |
3290 | { |
3245 | new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of fuel!", &op->name); |
3291 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3292 | "Your %s is out of fuel! " |
|
|
3293 | "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); |
3246 | return 1; |
3294 | return 1; |
3247 | } |
3295 | } |
3248 | |
3296 | |
3249 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3297 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3250 | tmp2 = arch_to_object (op->other_arch); |
3298 | tmp2 = arch_to_object (op->other_arch); |
… | |
… | |
3273 | who->update_stats (); |
3321 | who->update_stats (); |
3274 | |
3322 | |
3275 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3323 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3276 | if (who->type == PLAYER) |
3324 | if (who->type == PLAYER) |
3277 | { |
3325 | { |
3278 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3326 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3327 | "Oops, it feels deadly cold! " |
|
|
3328 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3279 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3329 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3280 | } |
3330 | } |
3281 | |
3331 | |
3282 | if (who->type == PLAYER) |
3332 | if (who->type == PLAYER) |
3283 | esrv_send_item (who, tmp2); |
3333 | esrv_send_item (who, tmp2); |
3284 | |
3334 | |
3285 | return 0; |
3335 | return 0; |
3286 | |
3336 | |
3287 | /* this part is needed for skill-tools */ |
3337 | case SKILL_TOOL: |
|
|
3338 | // applying a skill tool also readies the skill |
|
|
3339 | SET_FLAG (op, FLAG_APPLIED); |
|
|
3340 | |
|
|
3341 | if (!(aflags & AP_NO_READY)) |
|
|
3342 | { |
|
|
3343 | skop = find_skill_by_name (who, op->skill); |
|
|
3344 | if (!skop->flag [FLAG_APPLIED]) |
|
|
3345 | apply_special (who, skop, AP_APPLY); |
|
|
3346 | } |
|
|
3347 | break; |
|
|
3348 | |
3288 | case SKILL: |
3349 | case SKILL: |
3289 | case SKILL_TOOL: |
|
|
3290 | if (who->chosen_skill) |
|
|
3291 | { |
|
|
3292 | LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); |
|
|
3293 | return 1; |
|
|
3294 | } |
|
|
3295 | |
|
|
3296 | if (player *pl = who->contr) |
3350 | if (player *pl = who->contr) |
3297 | { |
3351 | { |
3298 | if (IS_COMBAT_SKILL (op->subtype)) |
3352 | if (IS_COMBAT_SKILL (op->subtype)) |
3299 | { |
3353 | { |
3300 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3354 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3301 | { |
3355 | { |
3302 | for (object *item = who->inv; item; item = item->below) |
3356 | for (object *item = who->inv; item; item = item->below) |
3303 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3357 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3304 | { |
3358 | { |
|
|
3359 | if (item->skill == op->skill) |
|
|
3360 | { |
3305 | who->change_weapon (pl->combat_ob = item); |
3361 | who->change_weapon (pl->combat_ob = item); |
3306 | goto found_weapon; |
3362 | goto found_weapon; |
|
|
3363 | } |
3307 | } |
3364 | } |
3308 | |
3365 | |
3309 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a melee weapon before readying this skill"); |
3366 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3367 | "You need to apply a '%s' melee weapon before readying this skill. " |
|
|
3368 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
|
|
3369 | &op->skill); |
3310 | return 1; |
3370 | return 1; |
3311 | |
3371 | |
3312 | found_weapon:; |
3372 | found_weapon:; |
3313 | } |
3373 | } |
3314 | else |
3374 | else |
… | |
… | |
3319 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3379 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3320 | { |
3380 | { |
3321 | for (object *item = who->inv; item; item = item->below) |
3381 | for (object *item = who->inv; item; item = item->below) |
3322 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3382 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3323 | { |
3383 | { |
|
|
3384 | //TODO: bows should/must all have skill missile weapon right now |
3324 | who->change_weapon (pl->ranged_ob = item); |
3385 | who->change_weapon (pl->ranged_ob = item); |
3325 | goto found_bow; |
3386 | goto found_bow; |
3326 | } |
3387 | } |
3327 | |
3388 | |
|
|
3389 | new_draw_info (NDI_UNIQUE, 0, who, |
3328 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3390 | "You need to apply a missile weapon before readying this skill. " |
|
|
3391 | "H<Some skills need an item, in this case a missile weapon, to function.>"); |
3329 | return 1; |
3392 | return 1; |
3330 | |
3393 | |
3331 | found_bow:; |
3394 | found_bow:; |
3332 | } |
|
|
3333 | else if (skill_flags [op->subtype] & SF_NEED_ITEM) |
|
|
3334 | { |
|
|
3335 | for (object *item = who->inv; item; item = item->below) |
|
|
3336 | if (item->flag [FLAG_APPLIED] |
|
|
3337 | && (item->type == WAND || item->type == ROD || item->type == HORN)) |
|
|
3338 | { |
|
|
3339 | who->change_weapon (pl->ranged_ob = item); |
|
|
3340 | goto found_item; |
|
|
3341 | } |
|
|
3342 | |
|
|
3343 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a magic item before readying this skill"); |
|
|
3344 | return 1; |
|
|
3345 | |
|
|
3346 | found_item:; |
|
|
3347 | } |
3395 | } |
3348 | else |
3396 | else |
3349 | who->change_weapon (pl->ranged_ob = op); |
3397 | who->change_weapon (pl->ranged_ob = op); |
3350 | } |
3398 | } |
3351 | |
3399 | |
… | |
… | |
3355 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); |
3403 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); |
3356 | } |
3404 | } |
3357 | else |
3405 | else |
3358 | new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); |
3406 | new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); |
3359 | } |
3407 | } |
3360 | |
3408 | else |
|
|
3409 | { |
3361 | SET_FLAG (op, FLAG_APPLIED); |
3410 | SET_FLAG (op, FLAG_APPLIED); |
3362 | change_abil (who, op); |
3411 | change_abil (who, op); |
3363 | who->chosen_skill = op; |
3412 | who->chosen_skill = op; |
3364 | SET_FLAG (who, FLAG_READY_SKILL); |
3413 | SET_FLAG (who, FLAG_READY_SKILL); |
|
|
3414 | } |
|
|
3415 | |
3365 | break; |
3416 | break; |
3366 | |
3417 | |
3367 | case BOW: |
3418 | case BOW: |
3368 | if (!check_weapon_power (who, op->last_eat)) |
3419 | if (!check_weapon_power (who, op->last_eat)) |
3369 | { |
3420 | { |
3370 | new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); |
3421 | new_draw_info (NDI_UNIQUE, 0, who, |
3371 | new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); |
3422 | "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3372 | |
3423 | |
3373 | if (tmp) |
3424 | if (tmp) |
3374 | insert_ob_in_ob (tmp, who); |
3425 | insert_ob_in_ob (tmp, who); |
3375 | |
3426 | |
3376 | return 1; |
3427 | return 1; |
3377 | } |
3428 | } |
3378 | |
3429 | |
3379 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3430 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3380 | { |
3431 | { |
3381 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3432 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3433 | "The weapon does not recognize you as its owner. " |
|
|
3434 | "H<Its name indicates that it belongs to somebody else.>"); |
3382 | if (tmp) |
3435 | if (tmp) |
3383 | insert_ob_in_ob (tmp, who); |
3436 | insert_ob_in_ob (tmp, who); |
3384 | |
3437 | |
3385 | return 1; |
3438 | return 1; |
3386 | } |
3439 | } |
… | |
… | |
3396 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3449 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3397 | return 1; |
3450 | return 1; |
3398 | } |
3451 | } |
3399 | |
3452 | |
3400 | SET_FLAG (op, FLAG_APPLIED); |
3453 | SET_FLAG (op, FLAG_APPLIED); |
3401 | change_skill (who, skop, 0); |
3454 | who->change_skill (skop); |
3402 | |
3455 | |
3403 | if (who->contr) |
3456 | if (who->contr) |
3404 | { |
3457 | { |
3405 | who->contr->ranged_ob = op; |
3458 | who->contr->ranged_ob = op; |
3406 | |
3459 | |
… | |
… | |
3425 | break; |
3478 | break; |
3426 | |
3479 | |
3427 | case BUILDER: |
3480 | case BUILDER: |
3428 | if (who->type == PLAYER) |
3481 | if (who->type == PLAYER) |
3429 | { |
3482 | { |
|
|
3483 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3430 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3484 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3431 | unapply_special (who, who->contr->ranged_ob, 0); |
3485 | unapply_special (who, who->contr->ranged_ob, 0); |
3432 | |
3486 | |
3433 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); |
3487 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); |
3434 | |
3488 | |
… | |
… | |
3453 | */ |
3507 | */ |
3454 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3508 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3455 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3509 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3456 | |
3510 | |
3457 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3511 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3458 | { |
|
|
3459 | if (who->type == PLAYER) |
3512 | if (who->type == PLAYER) |
3460 | { |
3513 | { |
3461 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3514 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3515 | "Oops, it feels deadly cold! " |
|
|
3516 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3462 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3517 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3463 | } |
3518 | } |
3464 | } |
|
|
3465 | |
3519 | |
3466 | if (who->type == PLAYER) |
3520 | if (who->type == PLAYER) |
3467 | { |
3521 | { |
3468 | /* if multiple objects were applied, update both slots */ |
3522 | /* if multiple objects were applied, update both slots */ |
3469 | if (tmp) |
3523 | if (tmp) |
… | |
… | |
3478 | int |
3532 | int |
3479 | monster_apply_special (object *who, object *op, int aflags) |
3533 | monster_apply_special (object *who, object *op, int aflags) |
3480 | { |
3534 | { |
3481 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3535 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3482 | return 1; |
3536 | return 1; |
|
|
3537 | |
3483 | return apply_special (who, op, aflags); |
3538 | return apply_special (who, op, aflags); |
3484 | } |
3539 | } |
3485 | |
3540 | |
3486 | /** |
3541 | /** |
3487 | * Map was just loaded, handle op's initialisation. |
3542 | * Map was just loaded, handle op's initialisation. |
… | |
… | |
3813 | |
3868 | |
3814 | if (failure <= -1 && failure > -15) |
3869 | if (failure <= -1 && failure > -15) |
3815 | { /* wonder */ |
3870 | { /* wonder */ |
3816 | object *tmp; |
3871 | object *tmp; |
3817 | |
3872 | |
3818 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3873 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); |
3819 | tmp = get_archetype (SPELL_WONDER); |
3874 | tmp = get_archetype (SPELL_WONDER); |
3820 | cast_wonder (op, op, 0, tmp); |
3875 | cast_wonder (op, op, 0, tmp); |
3821 | tmp->destroy (); |
3876 | tmp->destroy (); |
3822 | } |
3877 | } |
3823 | else if (failure <= -15 && failure > -35) |
3878 | else if (failure <= -15 && failure > -35) |
… | |
… | |
3876 | */ |
3931 | */ |
3877 | int i, j; |
3932 | int i, j; |
3878 | |
3933 | |
3879 | for (i = 0; i < NUM_STATS; i++) |
3934 | for (i = 0; i < NUM_STATS; i++) |
3880 | { |
3935 | { |
3881 | int race_bonus = pl->arch->clone.stats.stat (i); |
3936 | int race_bonus = pl->arch->stats.stat (i); |
3882 | sint8 stat = stats->stat (i) + ns->stat (i); |
3937 | sint8 stat = stats->stat (i) + ns->stat (i); |
3883 | |
3938 | |
3884 | if (stat > 20 + race_bonus) |
3939 | if (stat > 20 + race_bonus) |
3885 | { |
3940 | { |
3886 | excess_stat++; |
3941 | excess_stat++; |
… | |
… | |
3896 | |
3951 | |
3897 | if (i == CHA) |
3952 | if (i == CHA) |
3898 | continue; /* exclude cha from this */ |
3953 | continue; /* exclude cha from this */ |
3899 | |
3954 | |
3900 | int stat = stats->stat (i); |
3955 | int stat = stats->stat (i); |
3901 | int race_bonus = pl->arch->clone.stats.stat (i); |
3956 | int race_bonus = pl->arch->stats.stat (i); |
3902 | if (stat < 20 + race_bonus) |
3957 | if (stat < 20 + race_bonus) |
3903 | { |
3958 | { |
3904 | change_attr_value (stats, i, 1); |
3959 | change_attr_value (stats, i, 1); |
3905 | excess_stat--; |
3960 | excess_stat--; |
3906 | } |
3961 | } |
… | |
… | |
3963 | char got[MAX_BUF]; |
4018 | char got[MAX_BUF]; |
3964 | int len; |
4019 | int len; |
3965 | |
4020 | |
3966 | if (!pl || !transformer) |
4021 | if (!pl || !transformer) |
3967 | return; |
4022 | return; |
|
|
4023 | |
3968 | marked = find_marked_object (pl); |
4024 | marked = find_marked_object (pl); |
|
|
4025 | |
3969 | if (!marked) |
4026 | if (!marked) |
3970 | { |
4027 | { |
3971 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
4028 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
3972 | return; |
4029 | return; |
3973 | } |
4030 | } |
|
|
4031 | |
3974 | if (!marked->slaying) |
4032 | if (!marked->slaying) |
3975 | { |
4033 | { |
3976 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4034 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3977 | return; |
4035 | return; |
3978 | } |
4036 | } |
|
|
4037 | |
3979 | /* check whether they are compatible or not */ |
4038 | /* check whether they are compatible or not */ |
3980 | find = strstr (marked->slaying, transformer->arch->name); |
4039 | find = strstr (marked->slaying, transformer->arch->archname); |
3981 | if (!find || (*(find + strlen (transformer->arch->name)) != ':')) |
4040 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3982 | { |
4041 | { |
3983 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4042 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3984 | return; |
4043 | return; |
3985 | } |
4044 | } |
|
|
4045 | |
3986 | find += strlen (transformer->arch->name) + 1; |
4046 | find += strlen (transformer->arch->archname) + 1; |
3987 | /* Item can be used, now find how many and what it yields */ |
4047 | /* Item can be used, now find how many and what it yields */ |
3988 | if (isdigit (*(find))) |
4048 | if (isdigit (*(find))) |
3989 | { |
4049 | { |
3990 | yield = atoi (find); |
4050 | yield = atoi (find); |
3991 | if (yield < 1) |
4051 | if (yield < 1) |
… | |
… | |
3999 | |
4059 | |
4000 | while (isdigit (*find)) |
4060 | while (isdigit (*find)) |
4001 | find++; |
4061 | find++; |
4002 | while (*find == ' ') |
4062 | while (*find == ' ') |
4003 | find++; |
4063 | find++; |
|
|
4064 | |
4004 | memset (got, 0, MAX_BUF); |
4065 | memset (got, 0, MAX_BUF); |
|
|
4066 | |
4005 | if ((separator = strchr (find, ';')) != NULL) |
4067 | if ((separator = strchr (find, ';')) != NULL) |
4006 | { |
|
|
4007 | len = separator - find; |
4068 | len = separator - find; |
4008 | } |
|
|
4009 | else |
4069 | else |
4010 | { |
|
|
4011 | len = strlen (find); |
4070 | len = strlen (find); |
4012 | } |
4071 | |
4013 | if (len > MAX_BUF - 1) |
4072 | if (len > MAX_BUF - 1) |
4014 | len = MAX_BUF - 1; |
4073 | len = MAX_BUF - 1; |
|
|
4074 | |
4015 | strcpy (got, find); |
4075 | strcpy (got, find); |
4016 | got[len] = '\0'; |
4076 | got[len] = '\0'; |
4017 | |
4077 | |
4018 | /* Now create new item, remove used ones when required. */ |
4078 | /* Now create new item, remove used ones when required. */ |
4019 | new_item = get_archetype (got); |
4079 | new_item = get_archetype (got); |
… | |
… | |
4027 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4087 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4028 | insert_ob_in_ob (new_item, pl); |
4088 | insert_ob_in_ob (new_item, pl); |
4029 | esrv_send_inventory (pl, pl); |
4089 | esrv_send_inventory (pl, pl); |
4030 | /* Eat up one item */ |
4090 | /* Eat up one item */ |
4031 | decrease_ob_nr (marked, 1); |
4091 | decrease_ob_nr (marked, 1); |
|
|
4092 | |
4032 | /* Eat one transformer if needed */ |
4093 | /* Eat one transformer if needed */ |
4033 | if (transformer->stats.food) |
4094 | if (transformer->stats.food) |
4034 | if (--transformer->stats.food == 0) |
4095 | if (--transformer->stats.food == 0) |
4035 | decrease_ob_nr (transformer, 1); |
4096 | decrease_ob_nr (transformer, 1); |
4036 | } |
4097 | } |