… | |
… | |
157 | |
157 | |
158 | /** |
158 | /** |
159 | * 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 |
160 | * matching item. |
160 | * matching item. |
161 | **/ |
161 | **/ |
162 | static void |
162 | void |
163 | handle_apply_yield (object *tmp) |
163 | handle_apply_yield (object *tmp) |
164 | { |
164 | { |
165 | const char *yield; |
165 | const char *yield; |
166 | |
166 | |
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
… | |
… | |
575 | op->update_stats (); |
575 | op->update_stats (); |
576 | return 1; |
576 | return 1; |
577 | } |
577 | } |
578 | |
578 | |
579 | /* Types of improvements, hidden in the sp field. */ |
579 | /* Types of improvements, hidden in the sp field. */ |
580 | #define IMPROVE_PREPARE 1 |
580 | #define IMPROVE_PREPARE 1 |
581 | #define IMPROVE_DAMAGE 2 |
581 | #define IMPROVE_DAMAGE 2 |
582 | #define IMPROVE_WEIGHT 3 |
582 | #define IMPROVE_WEIGHT 3 |
583 | #define IMPROVE_ENCHANT 4 |
583 | #define IMPROVE_ENCHANT 4 |
584 | #define IMPROVE_STR 5 |
584 | #define IMPROVE_STR 5 |
585 | #define IMPROVE_DEX 6 |
585 | #define IMPROVE_DEX 6 |
586 | #define IMPROVE_CON 7 |
586 | #define IMPROVE_CON 7 |
587 | #define IMPROVE_WIS 8 |
587 | #define IMPROVE_WIS 8 |
588 | #define IMPROVE_CHA 9 |
588 | #define IMPROVE_CHA 9 |
589 | #define IMPROVE_INT 10 |
589 | #define IMPROVE_INT 10 |
590 | #define IMPROVE_POW 11 |
590 | #define IMPROVE_POW 11 |
591 | |
|
|
592 | |
591 | |
593 | /** |
592 | /** |
594 | * This does the prepare weapon scroll. |
593 | * This does the prepare weapon scroll. |
595 | * Checks for sacrifice, and so on. |
594 | * Checks for sacrifice, and so on. |
596 | */ |
595 | */ |
597 | |
|
|
598 | int |
596 | int |
599 | prepare_weapon (object *op, object *improver, object *weapon) |
597 | prepare_weapon (object *op, object *improver, object *weapon) |
600 | { |
598 | { |
601 | int sacrifice_count, i; |
599 | int sacrifice_count, i; |
602 | char buf[MAX_BUF]; |
600 | char buf[MAX_BUF]; |
… | |
… | |
604 | if (weapon->level != 0) |
602 | if (weapon->level != 0) |
605 | { |
603 | { |
606 | new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared."); |
604 | new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared."); |
607 | return 0; |
605 | return 0; |
608 | } |
606 | } |
|
|
607 | |
609 | for (i = 0; i < NROFATTACKS; i++) |
608 | for (i = 0; i < NROFATTACKS; i++) |
610 | if (weapon->resist[i]) |
609 | if (weapon->resist[i]) |
611 | break; |
610 | break; |
612 | |
611 | |
613 | /* If we break out, i will be less than nrofattacks, preventing |
612 | /* If we break out, i will be less than nrofattacks, preventing |
… | |
… | |
619 | weapon->stats.ac) /* AC - only taifu's I think */ |
618 | weapon->stats.ac) /* AC - only taifu's I think */ |
620 | { |
619 | { |
621 | new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons."); |
620 | new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons."); |
622 | return 0; |
621 | return 0; |
623 | } |
622 | } |
|
|
623 | |
624 | sacrifice_count = check_sacrifice (op, improver); |
624 | sacrifice_count = check_sacrifice (op, improver); |
625 | if (sacrifice_count <= 0) |
625 | if (sacrifice_count <= 0) |
626 | return 0; |
626 | return 0; |
|
|
627 | |
627 | weapon->level = isqrt (sacrifice_count); |
628 | weapon->level = isqrt (sacrifice_count); |
628 | new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted."); |
629 | new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted."); |
629 | eat_item (op, improver->slaying, sacrifice_count); |
630 | eat_item (op, improver->slaying, sacrifice_count); |
630 | |
631 | |
631 | 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); |
… | |
… | |
898 | esrv_send_item (op, tmp); |
899 | esrv_send_item (op, tmp); |
899 | } |
900 | } |
900 | return 1; |
901 | return 1; |
901 | } |
902 | } |
902 | |
903 | |
903 | |
|
|
904 | /* |
904 | /* |
905 | * 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 |
906 | * what the converter wants, -1 if the converter is broken. |
906 | * what the converter wants, -1 if the converter is broken. |
907 | */ |
907 | */ |
908 | #define CONV_FROM(xyz) xyz->slaying |
908 | #define CONV_FROM(xyz) xyz->slaying |
… | |
… | |
923 | |
923 | |
924 | /* 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, |
925 | * 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 |
926 | * 3 gp and player drops a platinum, tough luck) |
926 | * 3 gp and player drops a platinum, tough luck) |
927 | */ |
927 | */ |
928 | if (!strcmp (CONV_FROM (converter), "money")) |
928 | if (CONV_FROM (converter) == shstr_money) |
929 | { |
929 | { |
930 | int cost; |
|
|
931 | |
|
|
932 | if (item->type != MONEY) |
930 | if (item->type != MONEY) |
933 | return 0; |
931 | return 0; |
934 | |
932 | |
935 | nr = (item->nrof * item->value) / CONV_NEED (converter); |
933 | nr = (item->nrof * item->value) / CONV_NEED (converter); |
936 | if (!nr) |
934 | if (!nr) |
937 | return 0; |
935 | return 0; |
|
|
936 | |
|
|
937 | converter->play_sound (sound_find ("shop_buy")); |
|
|
938 | |
938 | cost = nr * CONV_NEED (converter) / item->value; |
939 | int cost = nr * CONV_NEED (converter) / item->value; |
939 | /* take into account rounding errors */ |
940 | /* take into account rounding errors */ |
940 | if (nr * CONV_NEED (converter) % item->value) |
941 | if (nr * CONV_NEED (converter) % item->value) |
941 | cost++; |
942 | cost++; |
|
|
943 | |
942 | decrease_ob_nr (item, cost); |
944 | decrease_ob_nr (item, cost); |
943 | |
945 | |
944 | price_in = cost * item->value; |
946 | price_in = cost * item->value; |
945 | } |
947 | } |
946 | else |
948 | else |
947 | { |
949 | { |
948 | if (item->type == PLAYER || CONV_FROM (converter) != item->arch->archname || |
950 | if (item->type == PLAYER || CONV_FROM (converter) != item->arch->archname || |
949 | (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) |
951 | (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) |
950 | return 0; |
952 | return 0; |
951 | |
953 | |
|
|
954 | converter->play_sound (sound_find ("convert_item")); |
|
|
955 | |
952 | if (CONV_NEED (converter)) |
956 | if (CONV_NEED (converter)) |
953 | { |
957 | { |
954 | nr = item->nrof / CONV_NEED (converter); |
958 | nr = item->nrof / CONV_NEED (converter); |
955 | decrease_ob_nr (item, nr * CONV_NEED (converter)); |
959 | decrease_ob_nr (item, nr * CONV_NEED (converter)); |
956 | price_in = nr * CONV_NEED (converter) * item->value; |
960 | price_in = nr * CONV_NEED (converter) * item->value; |
… | |
… | |
960 | price_in = item->value; |
964 | price_in = item->value; |
961 | item->destroy (); |
965 | item->destroy (); |
962 | } |
966 | } |
963 | } |
967 | } |
964 | |
968 | |
965 | if (converter->inv != NULL) |
969 | if (converter->inv) |
966 | { |
970 | { |
967 | object *ob; |
971 | object *ob; |
968 | int i; |
972 | int i; |
969 | object *ob_to_copy; |
973 | object *ob_to_copy; |
970 | |
974 | |
971 | /* select random object from inventory to copy */ |
975 | /* select random object from inventory to copy */ |
972 | ob_to_copy = converter->inv; |
976 | ob_to_copy = converter->inv; |
973 | 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++) |
974 | { |
|
|
975 | if (rndm (0, i) == 0) |
978 | if (rndm (0, i) == 0) |
976 | { |
|
|
977 | ob_to_copy = ob; |
979 | ob_to_copy = ob; |
978 | } |
980 | |
979 | } |
|
|
980 | item = object_create_clone (ob_to_copy); |
981 | item = object_create_clone (ob_to_copy); |
981 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
982 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
982 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
983 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
983 | } |
984 | } |
984 | else |
985 | else |
… | |
… | |
994 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
995 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
995 | } |
996 | } |
996 | |
997 | |
997 | if (CONV_NR (converter)) |
998 | if (CONV_NR (converter)) |
998 | item->nrof = CONV_NR (converter); |
999 | item->nrof = CONV_NR (converter); |
|
|
1000 | |
999 | if (nr) |
1001 | if (nr) |
1000 | item->nrof *= nr; |
1002 | item->nrof *= nr; |
|
|
1003 | |
1001 | if (is_in_shop (converter)) |
1004 | if (is_in_shop (converter)) |
1002 | SET_FLAG (item, FLAG_UNPAID); |
1005 | SET_FLAG (item, FLAG_UNPAID); |
1003 | else if (price_in < item->nrof * item->value) |
1006 | else if (price_in < item->nrof * item->value) |
1004 | { |
1007 | { |
1005 | 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", |
1006 | &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); |
1007 | |
|
|
1008 | /** |
1010 | /** |
1009 | * 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 |
1010 | * probably had something in mind when doing this |
1012 | * hopefully had something in mind when doing this. |
1011 | */ |
1013 | */ |
1012 | } |
1014 | } |
|
|
1015 | |
|
|
1016 | SET_FLAG (item, FLAG_IDENTIFIED); |
1013 | 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); |
1014 | return 1; |
1018 | return 1; |
1015 | } |
1019 | } |
1016 | |
1020 | |
1017 | /** |
1021 | /** |
… | |
… | |
1138 | double opinion; |
1142 | double opinion; |
1139 | object *tmp, *next; |
1143 | object *tmp, *next; |
1140 | |
1144 | |
1141 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
1145 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
1142 | |
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 | |
1143 | if (op->type != PLAYER) |
1158 | if (op->type != PLAYER) |
1144 | { |
1159 | { |
1145 | /* Remove all the unpaid objects that may be carried here. |
1160 | /* Remove all the unpaid objects that may be carried here. |
1146 | * This could be pets or monsters that are somehow in |
1161 | * This could be pets or monsters that are somehow in |
1147 | * the shop. |
1162 | * the shop. |
… | |
… | |
1173 | /* unpaid objects, or non living objects, can't transfer by |
1188 | /* unpaid objects, or non living objects, can't transfer by |
1174 | * shop mats. Instead, put it on a nearby space. |
1189 | * shop mats. Instead, put it on a nearby space. |
1175 | */ |
1190 | */ |
1176 | if (QUERY_FLAG (op, FLAG_UNPAID) || !QUERY_FLAG (op, FLAG_ALIVE)) |
1191 | if (QUERY_FLAG (op, FLAG_UNPAID) || !QUERY_FLAG (op, FLAG_ALIVE)) |
1177 | { |
1192 | { |
1178 | |
|
|
1179 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
1193 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
1180 | 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); |
1181 | |
1195 | |
1182 | if (i != -1) |
1196 | if (i != -1) |
1183 | 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); |
… | |
… | |
1191 | } |
1205 | } |
1192 | else if (can_pay (op) && get_payment (op)) |
1206 | else if (can_pay (op) && get_payment (op)) |
1193 | { |
1207 | { |
1194 | /* this is only used for players */ |
1208 | /* this is only used for players */ |
1195 | 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")); |
1196 | |
1217 | |
1197 | if (shop_mat->msg) |
1218 | if (shop_mat->msg) |
1198 | new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); |
1219 | new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); |
1199 | /* 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, |
1200 | * 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 |
… | |
… | |
1215 | } |
1236 | } |
1216 | } |
1237 | } |
1217 | else |
1238 | else |
1218 | { |
1239 | { |
1219 | /* 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 |
1220 | * 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 |
1221 | * they are not on the mat anymore |
1242 | * they are not on the mat anymore |
1222 | */ |
1243 | */ |
1223 | 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); |
1224 | |
1245 | |
1225 | if (i == -1) |
1246 | if (i == -1) |
1226 | { |
|
|
1227 | LOG (llevError, "Internal shop-mat problem.\n"); |
1247 | LOG (llevError, "Internal shop-mat problem.\n"); |
1228 | } |
|
|
1229 | else |
1248 | else |
1230 | { |
1249 | { |
1231 | op->remove (); |
1250 | op->remove (); |
1232 | op->x += freearr_x[i]; |
1251 | op->x += freearr_x[i]; |
1233 | op->y += freearr_y[i]; |
1252 | op->y += freearr_y[i]; |
… | |
… | |
1257 | { |
1276 | { |
1258 | if (sign->last_eat >= sign->stats.food) |
1277 | if (sign->last_eat >= sign->stats.food) |
1259 | { |
1278 | { |
1260 | if (!sign->move_on) |
1279 | if (!sign->move_on) |
1261 | 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 | |
1262 | return; |
1282 | return; |
1263 | } |
1283 | } |
1264 | |
1284 | |
1265 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1285 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1266 | sign->last_eat++; |
1286 | sign->last_eat++; |
… | |
… | |
1278 | } |
1298 | } |
1279 | |
1299 | |
1280 | if (op->contr) |
1300 | if (op->contr) |
1281 | if (client *ns = op->contr->ns) |
1301 | if (client *ns = op->contr->ns) |
1282 | { |
1302 | { |
|
|
1303 | ns->play_sound (sign->sound); |
1283 | msgType = get_readable_message_type (sign); |
1304 | msgType = get_readable_message_type (sign); |
1284 | |
1305 | |
1285 | if (ns->can_msg) |
1306 | if (ns->can_msg) |
1286 | ns->send_msg (NDI_NAVY, msgType->msgtype, &sign->msg); |
1307 | ns->send_msg (NDI_NAVY, msgType->msgtype, &sign->msg); |
1287 | else |
1308 | else |
… | |
… | |
1432 | |
1453 | |
1433 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1454 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1434 | { |
1455 | { |
1435 | if (!sound_was_played) |
1456 | if (!sound_was_played) |
1436 | { |
1457 | { |
1437 | play_sound_map (trap->map, trap->x, trap->y, SOUND_FALL_HOLE); |
1458 | trap->play_sound (sound_find ("fall_hole")); |
1438 | sound_was_played = 1; |
1459 | sound_was_played = 1; |
1439 | } |
1460 | } |
|
|
1461 | |
1440 | 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!"); |
1441 | 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); |
1442 | } |
1464 | } |
1443 | } |
1465 | } |
1444 | goto leave; |
1466 | goto leave; |
1445 | } |
1467 | } |
1446 | |
1468 | |
1447 | |
|
|
1448 | case CONVERTER: |
1469 | case CONVERTER: |
1449 | if (convert_item (victim, trap) < 0) |
1470 | if (convert_item (victim, trap) < 0) |
1450 | { |
1471 | { |
1451 | 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)); |
1452 | get_archetype ("burnout")->insert_at (trap, trap); |
1473 | get_archetype ("burnout")->insert_at (trap, trap); |
… | |
… | |
1477 | * Processing will happen if the head runs into the pit |
1498 | * Processing will happen if the head runs into the pit |
1478 | */ |
1499 | */ |
1479 | if (victim->head) |
1500 | if (victim->head) |
1480 | goto leave; |
1501 | goto leave; |
1481 | |
1502 | |
1482 | play_sound_map (victim->map, victim->x, victim->y, SOUND_FALL_HOLE); |
1503 | victim->play_sound (sound_find ("fall_hole")); |
1483 | 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"); |
1484 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1505 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1485 | goto leave; |
1506 | goto leave; |
1486 | |
1507 | |
1487 | case EXIT: |
1508 | case EXIT: |
… | |
… | |
1562 | |
1583 | |
1563 | /* need a literacy skill to read stuff! */ |
1584 | /* need a literacy skill to read stuff! */ |
1564 | skill_ob = find_skill_by_name (op, tmp->skill); |
1585 | skill_ob = find_skill_by_name (op, tmp->skill); |
1565 | if (!skill_ob) |
1586 | if (!skill_ob) |
1566 | { |
1587 | { |
1567 | 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>"); |
1568 | return; |
1589 | return; |
1569 | } |
1590 | } |
1570 | |
1591 | |
1571 | lev_diff = tmp->level - (skill_ob->level + 5); |
1592 | lev_diff = tmp->level - (skill_ob->level + 5); |
1572 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1593 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
… | |
… | |
1677 | return; |
1698 | return; |
1678 | } |
1699 | } |
1679 | return; |
1700 | return; |
1680 | } |
1701 | } |
1681 | |
1702 | |
1682 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1703 | op->contr->play_sound (sound_find ("learn_spell")); |
|
|
1704 | |
1683 | tmp = spell->clone (); |
1705 | tmp = spell->clone (); |
1684 | insert_ob_in_ob (tmp, op); |
1706 | insert_ob_in_ob (tmp, op); |
1685 | |
1707 | |
1686 | if (special_prayer) |
1708 | if (special_prayer) |
1687 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1709 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
… | |
… | |
1732 | |
1754 | |
1733 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1755 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1734 | * instead of having their spell stored in stats.sp. These are |
1756 | * instead of having their spell stored in stats.sp. These are |
1735 | * legacy spellbooks |
1757 | * legacy spellbooks |
1736 | */ |
1758 | */ |
1737 | |
|
|
1738 | if (tmp->slaying != NULL) |
1759 | if (tmp->slaying) |
1739 | { |
1760 | { |
1740 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1761 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1741 | if (!spell) |
1762 | if (!spell) |
1742 | { |
1763 | { |
1743 | 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); |
1744 | return; |
1765 | return; |
1745 | } |
1766 | } |
1746 | else |
1767 | else |
1747 | insert_ob_in_ob (spell, tmp); |
1768 | insert_ob_in_ob (spell, tmp); |
|
|
1769 | |
1748 | tmp->slaying = NULL; |
1770 | tmp->slaying = 0; |
1749 | } |
1771 | } |
1750 | |
1772 | |
1751 | skop = find_skill_by_name (op, tmp->skill); |
1773 | skop = find_skill_by_name (op, tmp->skill); |
1752 | |
1774 | |
1753 | /* 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 |
1754 | * lower than the spell will make learning the spell more difficult */ |
1776 | * lower than the spell will make learning the spell more difficult */ |
1755 | if (!skop) |
1777 | if (!skop) |
1756 | { |
1778 | { |
1757 | 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.>"); |
1758 | return; |
1780 | return; |
1759 | } |
1781 | } |
1760 | |
1782 | |
1761 | spell = tmp->inv; |
1783 | spell = tmp->inv; |
1762 | |
1784 | |
1763 | if (!spell) |
1785 | if (!spell) |
1764 | { |
1786 | { |
1765 | 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); |
1766 | 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!"); |
1767 | return; |
1789 | return; |
1768 | } |
1790 | } |
1769 | |
1791 | |
1770 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1792 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1771 | { |
1793 | { |
1772 | 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.>"); |
1773 | return; |
1795 | return; |
1774 | } |
1796 | } |
1775 | |
1797 | |
1776 | 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); |
1777 | |
1799 | |
… | |
… | |
1790 | * 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 |
1791 | * they would have a special prayer mark. |
1813 | * they would have a special prayer mark. |
1792 | */ |
1814 | */ |
1793 | if (check_spell_known (op, spell->name)) |
1815 | if (check_spell_known (op, spell->name)) |
1794 | { |
1816 | { |
1795 | 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"); |
1796 | return; |
1818 | return; |
1797 | } |
1819 | } |
1798 | |
1820 | |
1799 | if (spell->skill) |
1821 | if (spell->skill) |
1800 | { |
1822 | { |
… | |
… | |
1841 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1863 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1842 | 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); |
1843 | } |
1865 | } |
1844 | else |
1866 | else |
1845 | { |
1867 | { |
1846 | play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); |
1868 | op->contr->play_sound (sound_find ("fumble_spell")); |
1847 | 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"); |
1848 | } |
1870 | } |
1849 | |
1871 | |
1850 | decrease_ob (tmp); |
1872 | decrease_ob (tmp); |
1851 | } |
1873 | } |
1852 | |
1874 | |
… | |
… | |
1864 | return; |
1886 | return; |
1865 | } |
1887 | } |
1866 | |
1888 | |
1867 | if (!tmp->inv || tmp->inv->type != SPELL) |
1889 | if (!tmp->inv || tmp->inv->type != SPELL) |
1868 | { |
1890 | { |
1869 | 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.>"); |
1870 | return; |
1892 | return; |
1871 | } |
1893 | } |
1872 | |
1894 | |
1873 | if (op->type == PLAYER) |
1895 | if (op->type == PLAYER) |
1874 | { |
1896 | { |
… | |
… | |
1880 | */ |
1902 | */ |
1881 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1903 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1882 | |
1904 | |
1883 | if (!skop) |
1905 | if (!skop) |
1884 | { |
1906 | { |
1885 | 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.>"); |
1886 | return; |
1908 | return; |
1887 | } |
1909 | } |
1888 | |
1910 | |
1889 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1911 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1890 | change_exp (op, exp_gain, skop->skill, 0); |
1912 | change_exp (op, exp_gain, skop->skill, 0); |
… | |
… | |
2011 | /* special food hack -b.t. */ |
2033 | /* special food hack -b.t. */ |
2012 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2034 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2013 | eat_special_food (op, tmp); |
2035 | eat_special_food (op, tmp); |
2014 | } |
2036 | } |
2015 | } |
2037 | } |
|
|
2038 | |
2016 | handle_apply_yield (tmp); |
2039 | handle_apply_yield (tmp); |
2017 | decrease_ob (tmp); |
2040 | decrease_ob (tmp); |
2018 | } |
2041 | } |
2019 | |
2042 | |
2020 | /** |
2043 | /** |
… | |
… | |
2182 | static void |
2205 | static void |
2183 | apply_armour_improver (object *op, object *tmp) |
2206 | apply_armour_improver (object *op, object *tmp) |
2184 | { |
2207 | { |
2185 | object *armor; |
2208 | object *armor; |
2186 | |
2209 | |
2187 | 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)) |
2188 | { |
2211 | { |
2189 | 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.>"); |
2190 | return; |
2213 | return; |
2191 | } |
2214 | } |
2192 | |
2215 | |
2193 | armor = find_marked_object (op); |
2216 | armor = find_marked_object (op); |
2194 | |
2217 | |
2195 | if (!armor) |
2218 | if (!armor) |
2196 | { |
2219 | { |
2197 | 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."); |
2198 | return; |
2221 | return; |
2199 | } |
2222 | } |
2200 | |
2223 | |
2201 | if (armor->type != ARMOUR |
2224 | if (armor->type != ARMOUR |
2202 | && armor->type != CLOAK |
2225 | && armor->type != CLOAK |
… | |
… | |
2213 | extern void |
2236 | extern void |
2214 | apply_poison (object *op, object *tmp) |
2237 | apply_poison (object *op, object *tmp) |
2215 | { |
2238 | { |
2216 | if (op->type == PLAYER) |
2239 | if (op->type == PLAYER) |
2217 | { |
2240 | { |
2218 | play_sound_player_only (op->contr, SOUND_DRINK_POISON, 0, 0); |
2241 | op->contr->play_sound (sound_find ("drink_poison")); |
2219 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2242 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2220 | strcpy (op->contr->killer, "poisonous booze"); |
2243 | strcpy (op->contr->killer, "poisonous booze"); |
2221 | } |
2244 | } |
|
|
2245 | |
2222 | if (tmp->stats.hp > 0) |
2246 | if (tmp->stats.hp > 0) |
2223 | { |
2247 | { |
2224 | 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); |
2225 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2249 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2226 | } |
2250 | } |
|
|
2251 | |
2227 | op->stats.food -= op->stats.food / 4; |
2252 | op->stats.food -= op->stats.food / 4; |
2228 | handle_apply_yield (tmp); |
2253 | handle_apply_yield (tmp); |
2229 | decrease_ob (tmp); |
2254 | decrease_ob (tmp); |
2230 | } |
2255 | } |
2231 | |
2256 | |
… | |
… | |
2341 | |
2366 | |
2342 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2367 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2343 | { |
2368 | { |
2344 | if (op->type == PLAYER) |
2369 | if (op->type == PLAYER) |
2345 | { |
2370 | { |
2346 | 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.>"); |
2347 | return 1; |
2372 | return 1; |
2348 | } |
2373 | } |
2349 | else |
2374 | else |
2350 | return 0; /* monsters just skip unpaid items */ |
2375 | return 0; /* monsters just skip unpaid items */ |
2351 | } |
2376 | } |
… | |
… | |
2355 | |
2380 | |
2356 | switch (tmp->type) |
2381 | switch (tmp->type) |
2357 | { |
2382 | { |
2358 | case CF_HANDLE: |
2383 | case CF_HANDLE: |
2359 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2384 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2360 | play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); |
2385 | op->play_sound (sound_find ("turn_handle")); |
2361 | tmp->value = tmp->value ? 0 : 1; |
2386 | tmp->value = tmp->value ? 0 : 1; |
2362 | SET_ANIMATION (tmp, tmp->value); |
2387 | SET_ANIMATION (tmp, tmp->value); |
2363 | update_object (tmp, UP_OBJ_FACE); |
2388 | update_object (tmp, UP_OBJ_FACE); |
2364 | push_button (tmp); |
2389 | push_button (tmp); |
2365 | return 1; |
2390 | return 1; |
2366 | |
2391 | |
2367 | case TRIGGER: |
2392 | case TRIGGER: |
2368 | if (check_trigger (tmp, op)) |
2393 | if (check_trigger (tmp, op)) |
2369 | { |
2394 | { |
2370 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2395 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2371 | play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); |
2396 | op->play_sound (sound_find ("turn_handle")); |
2372 | } |
2397 | } |
2373 | else |
2398 | else |
2374 | 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."); |
2375 | |
2400 | |
2376 | return 1; |
2401 | return 1; |
… | |
… | |
2509 | |
2534 | |
2510 | get_tod (&tod); |
2535 | get_tod (&tod); |
2511 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
2536 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
2512 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2537 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2513 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
2538 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
2514 | play_sound_player_only (op->contr, SOUND_CLOCK, 0, 0); |
2539 | op->play_sound (sound_find ("sound_clock")); |
2515 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2540 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2516 | return 1; |
2541 | return 1; |
2517 | } |
2542 | } |
2518 | else |
2543 | else |
2519 | return 0; |
2544 | return 0; |
… | |
… | |
2559 | int |
2584 | int |
2560 | player_apply (object *pl, object *op, int aflag, int quiet) |
2585 | player_apply (object *pl, object *op, int aflag, int quiet) |
2561 | { |
2586 | { |
2562 | int tmp; |
2587 | int tmp; |
2563 | |
2588 | |
2564 | if (op->env == NULL && (pl->move_type & MOVE_FLYING)) |
2589 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2565 | { |
2590 | { |
2566 | /* player is flying and applying object not in inventory */ |
2591 | /* player is flying and applying object not in inventory */ |
2567 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2592 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2568 | { |
2593 | { |
2569 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); |
2594 | 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.>"); |
2570 | return 0; |
2595 | return 0; |
2571 | } |
2596 | } |
2572 | } |
2597 | } |
2573 | |
2598 | |
2574 | pl->contr->last_used = op; |
2599 | pl->contr->last_used = op; |
… | |
… | |
2579 | if (tmp == 0) |
2604 | if (tmp == 0) |
2580 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2605 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2581 | else if (tmp == 2) |
2606 | else if (tmp == 2) |
2582 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2607 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2583 | } |
2608 | } |
|
|
2609 | |
2584 | return tmp; |
2610 | return tmp; |
2585 | } |
2611 | } |
2586 | |
2612 | |
2587 | /** |
2613 | /** |
2588 | * player_apply_below attempts to apply the object 'below' the player. |
2614 | * player_apply_below attempts to apply the object 'below' the player. |
… | |
… | |
2828 | * Returns 0 on success, returns 1 if there is some problem. |
2854 | * Returns 0 on success, returns 1 if there is some problem. |
2829 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2855 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2830 | * instead of doing it. This is a lot less code than having |
2856 | * instead of doing it. This is a lot less code than having |
2831 | * another function that does just that. |
2857 | * another function that does just that. |
2832 | */ |
2858 | */ |
|
|
2859 | |
|
|
2860 | #define CANNOT_REMOVE_CURSED \ |
|
|
2861 | "H<You cannot remove cursed or damned items, you first have to remove the curse. " \ |
|
|
2862 | "Praying over an altar, scrolls of remove curse/damnation, " \ |
|
|
2863 | "priests or even other players might help.>" |
|
|
2864 | |
2833 | int |
2865 | int |
2834 | unapply_for_ob (object *who, object *op, int aflags) |
2866 | unapply_for_ob (object *who, object *op, int aflags) |
2835 | { |
2867 | { |
2836 | if (op->is_range ()) |
2868 | if (op->is_range ()) |
2837 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2869 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
… | |
… | |
2847 | { |
2879 | { |
2848 | /* In this case, we want to try and remove a cursed item. |
2880 | /* In this case, we want to try and remove a cursed item. |
2849 | * While we know it won't work, we want unapply_special to |
2881 | * While we know it won't work, we want unapply_special to |
2850 | * at least generate the message. |
2882 | * at least generate the message. |
2851 | */ |
2883 | */ |
2852 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove the %s.", query_name (tmp)); |
2884 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
2885 | "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, |
|
|
2886 | query_name (tmp)); |
2853 | return 1; |
2887 | return 1; |
2854 | } |
2888 | } |
2855 | |
2889 | |
2856 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2890 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2857 | { |
2891 | { |
… | |
… | |
2891 | /* Cursed item that we can't unequip - tell the player. |
2925 | /* Cursed item that we can't unequip - tell the player. |
2892 | * Note this could be annoying if this is just one of a few, |
2926 | * Note this could be annoying if this is just one of a few, |
2893 | * so it may not be critical (eg, putting on a ring and you have |
2927 | * so it may not be critical (eg, putting on a ring and you have |
2894 | * one cursed ring.) |
2928 | * one cursed ring.) |
2895 | */ |
2929 | */ |
2896 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off", query_name (tmp)); |
2930 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
2897 | } |
2931 | } |
2898 | |
2932 | |
2899 | last = tmp->below; |
2933 | last = tmp->below; |
2900 | } |
2934 | } |
2901 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
2935 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
3054 | * |
3088 | * |
3055 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3089 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3056 | * |
3090 | * |
3057 | * apply_special() doesn't check for unpaid items. |
3091 | * apply_special() doesn't check for unpaid items. |
3058 | */ |
3092 | */ |
|
|
3093 | |
|
|
3094 | #define LACK_ITEM_POWER \ |
|
|
3095 | " H<You lack enough unused item power to use this weapon, see the skills command.>" |
|
|
3096 | |
3059 | int |
3097 | int |
3060 | apply_special (object *who, object *op, int aflags) |
3098 | apply_special (object *who, object *op, int aflags) |
3061 | { |
3099 | { |
3062 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3100 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3063 | object *tmp, *tmp2, *skop = NULL; |
3101 | object *tmp, *tmp2, *skop = NULL; |
… | |
… | |
3078 | if (basic_flag == AP_APPLY) |
3116 | if (basic_flag == AP_APPLY) |
3079 | return 0; |
3117 | return 0; |
3080 | |
3118 | |
3081 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3119 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3082 | { |
3120 | { |
3083 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op)); |
3121 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3122 | "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, |
|
|
3123 | query_name (op)); |
3084 | return 1; |
3124 | return 1; |
3085 | } |
3125 | } |
3086 | |
3126 | |
3087 | return unapply_special (who, op, aflags); |
3127 | return unapply_special (who, op, aflags); |
3088 | } |
3128 | } |
… | |
… | |
3104 | /* Can't just apply this object. Lets see what not and what to do */ |
3144 | /* Can't just apply this object. Lets see what not and what to do */ |
3105 | if (int i = can_apply_object (who, op)) |
3145 | if (int i = can_apply_object (who, op)) |
3106 | { |
3146 | { |
3107 | if (i & CAN_APPLY_NEVER) |
3147 | if (i & CAN_APPLY_NEVER) |
3108 | { |
3148 | { |
3109 | new_draw_info_format (NDI_UNIQUE, 0, who, "You don't have the body to use a %s\n", query_name (op)); |
3149 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3150 | "You don't have the body to use a %s. H<You can never apply this item.>", |
|
|
3151 | query_name (op)); |
3110 | return 1; |
3152 | return 1; |
3111 | } |
3153 | } |
3112 | else if (i & CAN_APPLY_RESTRICTION) |
3154 | else if (i & CAN_APPLY_RESTRICTION) |
3113 | { |
3155 | { |
3114 | new_draw_info_format (NDI_UNIQUE, 0, who, "You have a prohibition against using a %s\n", query_name (op)); |
3156 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3157 | "You have a prohibition against using a %s. " |
|
|
3158 | "H<Your belief, profession or class prevents you from applying this item.>", |
|
|
3159 | query_name (op)); |
3115 | return 1; |
3160 | return 1; |
3116 | } |
3161 | } |
3117 | |
3162 | |
3118 | if (who->type != PLAYER) |
3163 | if (who->type != PLAYER) |
3119 | { |
3164 | { |
… | |
… | |
3154 | if (who->type == PLAYER |
3199 | if (who->type == PLAYER |
3155 | && op->item_power |
3200 | && op->item_power |
3156 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3201 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3157 | { |
3202 | { |
3158 | new_draw_info (NDI_UNIQUE, 0, who, |
3203 | new_draw_info (NDI_UNIQUE, 0, who, |
3159 | "Equipping that combined with other items would consume your soul! " |
3204 | "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3160 | "[use the skills command to check your available item power]"); |
|
|
3161 | return 1; |
3205 | return 1; |
3162 | } |
3206 | } |
3163 | |
3207 | |
3164 | /* Ok. We are now at the state where we can apply the new object. |
3208 | /* Ok. We are now at the state where we can apply the new object. |
3165 | * Note that we don't have the checks for can_use_... |
3209 | * Note that we don't have the checks for can_use_... |
… | |
… | |
3177 | { |
3221 | { |
3178 | case WEAPON: |
3222 | case WEAPON: |
3179 | if (!check_weapon_power (who, op->last_eat)) |
3223 | if (!check_weapon_power (who, op->last_eat)) |
3180 | { |
3224 | { |
3181 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3225 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3182 | "It would consume your soul!."); |
3226 | "It would consume your soul!." LACK_ITEM_POWER); |
3183 | |
3227 | |
3184 | if (tmp) |
3228 | if (tmp) |
3185 | insert_ob_in_ob (tmp, who); |
3229 | insert_ob_in_ob (tmp, who); |
3186 | |
3230 | |
3187 | return 1; |
3231 | return 1; |
… | |
… | |
3191 | // i.e. "R" can use Ragnarok's sword. |
3235 | // i.e. "R" can use Ragnarok's sword. |
3192 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3236 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3193 | { |
3237 | { |
3194 | /* if the weapon does not have the name as the character, can't use it. */ |
3238 | /* if the weapon does not have the name as the character, can't use it. */ |
3195 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3239 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3196 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3240 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3241 | "The weapon does not recognize you as its owner. " |
|
|
3242 | "H<Its name indicates that it belongs to somebody else.>"); |
3197 | |
3243 | |
3198 | if (tmp) |
3244 | if (tmp) |
3199 | insert_ob_in_ob (tmp, who); |
3245 | insert_ob_in_ob (tmp, who); |
3200 | |
3246 | |
3201 | return 1; |
3247 | return 1; |
… | |
… | |
3235 | break; |
3281 | break; |
3236 | |
3282 | |
3237 | case LAMP: |
3283 | case LAMP: |
3238 | if (op->stats.food < 1) |
3284 | if (op->stats.food < 1) |
3239 | { |
3285 | { |
3240 | new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of fuel!", &op->name); |
3286 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3287 | "Your %s is out of fuel! " |
|
|
3288 | "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); |
3241 | return 1; |
3289 | return 1; |
3242 | } |
3290 | } |
3243 | |
3291 | |
3244 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3292 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3245 | tmp2 = arch_to_object (op->other_arch); |
3293 | tmp2 = arch_to_object (op->other_arch); |
… | |
… | |
3268 | who->update_stats (); |
3316 | who->update_stats (); |
3269 | |
3317 | |
3270 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3318 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3271 | if (who->type == PLAYER) |
3319 | if (who->type == PLAYER) |
3272 | { |
3320 | { |
3273 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3321 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3322 | "Oops, it feels deadly cold! " |
|
|
3323 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3274 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3324 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3275 | } |
3325 | } |
3276 | |
3326 | |
3277 | if (who->type == PLAYER) |
3327 | if (who->type == PLAYER) |
3278 | esrv_send_item (who, tmp2); |
3328 | esrv_send_item (who, tmp2); |
… | |
… | |
3306 | who->change_weapon (pl->combat_ob = item); |
3356 | who->change_weapon (pl->combat_ob = item); |
3307 | goto found_weapon; |
3357 | goto found_weapon; |
3308 | } |
3358 | } |
3309 | } |
3359 | } |
3310 | |
3360 | |
3311 | new_draw_info_format (NDI_UNIQUE, 0, who, "You need to apply a '%s' melee weapon before readying this skill", &op->skill); |
3361 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3362 | "You need to apply a '%s' melee weapon before readying this skill. " |
|
|
3363 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
|
|
3364 | &op->skill); |
3312 | return 1; |
3365 | return 1; |
3313 | |
3366 | |
3314 | found_weapon:; |
3367 | found_weapon:; |
3315 | } |
3368 | } |
3316 | else |
3369 | else |
… | |
… | |
3326 | //TODO: bows should/must all have skill missile weapon right now |
3379 | //TODO: bows should/must all have skill missile weapon right now |
3327 | who->change_weapon (pl->ranged_ob = item); |
3380 | who->change_weapon (pl->ranged_ob = item); |
3328 | goto found_bow; |
3381 | goto found_bow; |
3329 | } |
3382 | } |
3330 | |
3383 | |
|
|
3384 | new_draw_info (NDI_UNIQUE, 0, who, |
3331 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3385 | "You need to apply a missile weapon before readying this skill. " |
|
|
3386 | "H<Some skills need an item, in this case a missile weapon, to function.>"); |
3332 | return 1; |
3387 | return 1; |
3333 | |
3388 | |
3334 | found_bow:; |
3389 | found_bow:; |
3335 | } |
3390 | } |
3336 | else |
3391 | else |
… | |
… | |
3356 | break; |
3411 | break; |
3357 | |
3412 | |
3358 | case BOW: |
3413 | case BOW: |
3359 | if (!check_weapon_power (who, op->last_eat)) |
3414 | if (!check_weapon_power (who, op->last_eat)) |
3360 | { |
3415 | { |
3361 | new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); |
3416 | new_draw_info (NDI_UNIQUE, 0, who, |
3362 | new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); |
3417 | "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3363 | |
3418 | |
3364 | if (tmp) |
3419 | if (tmp) |
3365 | insert_ob_in_ob (tmp, who); |
3420 | insert_ob_in_ob (tmp, who); |
3366 | |
3421 | |
3367 | return 1; |
3422 | return 1; |
3368 | } |
3423 | } |
3369 | |
3424 | |
3370 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3425 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3371 | { |
3426 | { |
3372 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3427 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3428 | "The weapon does not recognize you as its owner. " |
|
|
3429 | "H<Its name indicates that it belongs to somebody else.>"); |
3373 | if (tmp) |
3430 | if (tmp) |
3374 | insert_ob_in_ob (tmp, who); |
3431 | insert_ob_in_ob (tmp, who); |
3375 | |
3432 | |
3376 | return 1; |
3433 | return 1; |
3377 | } |
3434 | } |
… | |
… | |
3445 | */ |
3502 | */ |
3446 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3503 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3447 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3504 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3448 | |
3505 | |
3449 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3506 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3450 | { |
|
|
3451 | if (who->type == PLAYER) |
3507 | if (who->type == PLAYER) |
3452 | { |
3508 | { |
3453 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3509 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3510 | "Oops, it feels deadly cold! " |
|
|
3511 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3454 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3512 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3455 | } |
3513 | } |
3456 | } |
|
|
3457 | |
3514 | |
3458 | if (who->type == PLAYER) |
3515 | if (who->type == PLAYER) |
3459 | { |
3516 | { |
3460 | /* if multiple objects were applied, update both slots */ |
3517 | /* if multiple objects were applied, update both slots */ |
3461 | if (tmp) |
3518 | if (tmp) |
… | |
… | |
3470 | int |
3527 | int |
3471 | monster_apply_special (object *who, object *op, int aflags) |
3528 | monster_apply_special (object *who, object *op, int aflags) |
3472 | { |
3529 | { |
3473 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3530 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3474 | return 1; |
3531 | return 1; |
|
|
3532 | |
3475 | return apply_special (who, op, aflags); |
3533 | return apply_special (who, op, aflags); |
3476 | } |
3534 | } |
3477 | |
3535 | |
3478 | /** |
3536 | /** |
3479 | * Map was just loaded, handle op's initialisation. |
3537 | * Map was just loaded, handle op's initialisation. |
… | |
… | |
3805 | |
3863 | |
3806 | if (failure <= -1 && failure > -15) |
3864 | if (failure <= -1 && failure > -15) |
3807 | { /* wonder */ |
3865 | { /* wonder */ |
3808 | object *tmp; |
3866 | object *tmp; |
3809 | |
3867 | |
3810 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3868 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); |
3811 | tmp = get_archetype (SPELL_WONDER); |
3869 | tmp = get_archetype (SPELL_WONDER); |
3812 | cast_wonder (op, op, 0, tmp); |
3870 | cast_wonder (op, op, 0, tmp); |
3813 | tmp->destroy (); |
3871 | tmp->destroy (); |
3814 | } |
3872 | } |
3815 | else if (failure <= -15 && failure > -35) |
3873 | else if (failure <= -15 && failure > -35) |
… | |
… | |
3955 | char got[MAX_BUF]; |
4013 | char got[MAX_BUF]; |
3956 | int len; |
4014 | int len; |
3957 | |
4015 | |
3958 | if (!pl || !transformer) |
4016 | if (!pl || !transformer) |
3959 | return; |
4017 | return; |
|
|
4018 | |
3960 | marked = find_marked_object (pl); |
4019 | marked = find_marked_object (pl); |
|
|
4020 | |
3961 | if (!marked) |
4021 | if (!marked) |
3962 | { |
4022 | { |
3963 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
4023 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
3964 | return; |
4024 | return; |
3965 | } |
4025 | } |
|
|
4026 | |
3966 | if (!marked->slaying) |
4027 | if (!marked->slaying) |
3967 | { |
4028 | { |
3968 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4029 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3969 | return; |
4030 | return; |
3970 | } |
4031 | } |
|
|
4032 | |
3971 | /* check whether they are compatible or not */ |
4033 | /* check whether they are compatible or not */ |
3972 | find = strstr (marked->slaying, transformer->arch->archname); |
4034 | find = strstr (marked->slaying, transformer->arch->archname); |
3973 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4035 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3974 | { |
4036 | { |
3975 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4037 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3976 | return; |
4038 | return; |
3977 | } |
4039 | } |
|
|
4040 | |
3978 | find += strlen (transformer->arch->archname) + 1; |
4041 | find += strlen (transformer->arch->archname) + 1; |
3979 | /* Item can be used, now find how many and what it yields */ |
4042 | /* Item can be used, now find how many and what it yields */ |
3980 | if (isdigit (*(find))) |
4043 | if (isdigit (*(find))) |
3981 | { |
4044 | { |
3982 | yield = atoi (find); |
4045 | yield = atoi (find); |
… | |
… | |
3991 | |
4054 | |
3992 | while (isdigit (*find)) |
4055 | while (isdigit (*find)) |
3993 | find++; |
4056 | find++; |
3994 | while (*find == ' ') |
4057 | while (*find == ' ') |
3995 | find++; |
4058 | find++; |
|
|
4059 | |
3996 | memset (got, 0, MAX_BUF); |
4060 | memset (got, 0, MAX_BUF); |
|
|
4061 | |
3997 | if ((separator = strchr (find, ';')) != NULL) |
4062 | if ((separator = strchr (find, ';')) != NULL) |
3998 | { |
|
|
3999 | len = separator - find; |
4063 | len = separator - find; |
4000 | } |
|
|
4001 | else |
4064 | else |
4002 | { |
|
|
4003 | len = strlen (find); |
4065 | len = strlen (find); |
4004 | } |
4066 | |
4005 | if (len > MAX_BUF - 1) |
4067 | if (len > MAX_BUF - 1) |
4006 | len = MAX_BUF - 1; |
4068 | len = MAX_BUF - 1; |
|
|
4069 | |
4007 | strcpy (got, find); |
4070 | strcpy (got, find); |
4008 | got[len] = '\0'; |
4071 | got[len] = '\0'; |
4009 | |
4072 | |
4010 | /* Now create new item, remove used ones when required. */ |
4073 | /* Now create new item, remove used ones when required. */ |
4011 | new_item = get_archetype (got); |
4074 | new_item = get_archetype (got); |
… | |
… | |
4019 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4082 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4020 | insert_ob_in_ob (new_item, pl); |
4083 | insert_ob_in_ob (new_item, pl); |
4021 | esrv_send_inventory (pl, pl); |
4084 | esrv_send_inventory (pl, pl); |
4022 | /* Eat up one item */ |
4085 | /* Eat up one item */ |
4023 | decrease_ob_nr (marked, 1); |
4086 | decrease_ob_nr (marked, 1); |
|
|
4087 | |
4024 | /* Eat one transformer if needed */ |
4088 | /* Eat one transformer if needed */ |
4025 | if (transformer->stats.food) |
4089 | if (transformer->stats.food) |
4026 | if (--transformer->stats.food == 0) |
4090 | if (--transformer->stats.food == 0) |
4027 | decrease_ob_nr (transformer, 1); |
4091 | decrease_ob_nr (transformer, 1); |
4028 | } |
4092 | } |