… | |
… | |
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); |
… | |
… | |
1432 | |
1433 | |
1433 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1434 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1434 | { |
1435 | { |
1435 | if (!sound_was_played) |
1436 | if (!sound_was_played) |
1436 | { |
1437 | { |
1437 | play_sound_map (trap->map, trap->x, trap->y, SOUND_FALL_HOLE); |
1438 | trap->play_sound (sound_find ("fall_hole")); |
1438 | sound_was_played = 1; |
1439 | sound_was_played = 1; |
1439 | } |
1440 | } |
|
|
1441 | |
1440 | new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!"); |
1442 | 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); |
1443 | transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab); |
1442 | } |
1444 | } |
1443 | } |
1445 | } |
1444 | goto leave; |
1446 | goto leave; |
… | |
… | |
1477 | * Processing will happen if the head runs into the pit |
1479 | * Processing will happen if the head runs into the pit |
1478 | */ |
1480 | */ |
1479 | if (victim->head) |
1481 | if (victim->head) |
1480 | goto leave; |
1482 | goto leave; |
1481 | |
1483 | |
1482 | play_sound_map (victim->map, victim->x, victim->y, SOUND_FALL_HOLE); |
1484 | victim->play_sound (sound_find ("fall_hole")); |
1483 | new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n"); |
1485 | 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); |
1486 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1485 | goto leave; |
1487 | goto leave; |
1486 | |
1488 | |
1487 | case EXIT: |
1489 | case EXIT: |
… | |
… | |
1562 | |
1564 | |
1563 | /* need a literacy skill to read stuff! */ |
1565 | /* need a literacy skill to read stuff! */ |
1564 | skill_ob = find_skill_by_name (op, tmp->skill); |
1566 | skill_ob = find_skill_by_name (op, tmp->skill); |
1565 | if (!skill_ob) |
1567 | if (!skill_ob) |
1566 | { |
1568 | { |
1567 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1569 | 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; |
1570 | return; |
1569 | } |
1571 | } |
1570 | |
1572 | |
1571 | lev_diff = tmp->level - (skill_ob->level + 5); |
1573 | lev_diff = tmp->level - (skill_ob->level + 5); |
1572 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1574 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
… | |
… | |
1677 | return; |
1679 | return; |
1678 | } |
1680 | } |
1679 | return; |
1681 | return; |
1680 | } |
1682 | } |
1681 | |
1683 | |
1682 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1684 | op->contr->play_sound (sound_find ("learn_spell")); |
|
|
1685 | |
1683 | tmp = spell->clone (); |
1686 | tmp = spell->clone (); |
1684 | insert_ob_in_ob (tmp, op); |
1687 | insert_ob_in_ob (tmp, op); |
1685 | |
1688 | |
1686 | if (special_prayer) |
1689 | if (special_prayer) |
1687 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1690 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
… | |
… | |
1732 | |
1735 | |
1733 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1736 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1734 | * instead of having their spell stored in stats.sp. These are |
1737 | * instead of having their spell stored in stats.sp. These are |
1735 | * legacy spellbooks |
1738 | * legacy spellbooks |
1736 | */ |
1739 | */ |
1737 | |
|
|
1738 | if (tmp->slaying != NULL) |
1740 | if (tmp->slaying) |
1739 | { |
1741 | { |
1740 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1742 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1741 | if (!spell) |
1743 | if (!spell) |
1742 | { |
1744 | { |
1743 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1745 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1744 | return; |
1746 | return; |
1745 | } |
1747 | } |
1746 | else |
1748 | else |
1747 | insert_ob_in_ob (spell, tmp); |
1749 | insert_ob_in_ob (spell, tmp); |
|
|
1750 | |
1748 | tmp->slaying = NULL; |
1751 | tmp->slaying = 0; |
1749 | } |
1752 | } |
1750 | |
1753 | |
1751 | skop = find_skill_by_name (op, tmp->skill); |
1754 | skop = find_skill_by_name (op, tmp->skill); |
1752 | |
1755 | |
1753 | /* need a literacy skill to learn spells. Also, having a literacy level |
1756 | /* need a literacy skill to learn spells. Also, having a literacy level |
1754 | * lower than the spell will make learning the spell more difficult */ |
1757 | * lower than the spell will make learning the spell more difficult */ |
1755 | if (!skop) |
1758 | if (!skop) |
1756 | { |
1759 | { |
1757 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1760 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H<You lack the literacy skill.>"); |
1758 | return; |
1761 | return; |
1759 | } |
1762 | } |
1760 | |
1763 | |
1761 | spell = tmp->inv; |
1764 | spell = tmp->inv; |
1762 | |
1765 | |
1763 | if (!spell) |
1766 | if (!spell) |
1764 | { |
1767 | { |
1765 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1768 | 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."); |
1769 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense. This is a bug, please report!"); |
1767 | return; |
1770 | return; |
1768 | } |
1771 | } |
1769 | |
1772 | |
1770 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1773 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1771 | { |
1774 | { |
1772 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. [Your literacy level is too low]"); |
1775 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<Your literacy level is too low.>"); |
1773 | return; |
1776 | return; |
1774 | } |
1777 | } |
1775 | |
1778 | |
1776 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1779 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1777 | |
1780 | |
… | |
… | |
1790 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1793 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1791 | * they would have a special prayer mark. |
1794 | * they would have a special prayer mark. |
1792 | */ |
1795 | */ |
1793 | if (check_spell_known (op, spell->name)) |
1796 | if (check_spell_known (op, spell->name)) |
1794 | { |
1797 | { |
1795 | new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell.\n"); |
1798 | 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; |
1799 | return; |
1797 | } |
1800 | } |
1798 | |
1801 | |
1799 | if (spell->skill) |
1802 | if (spell->skill) |
1800 | { |
1803 | { |
… | |
… | |
1841 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1844 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1842 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1845 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1843 | } |
1846 | } |
1844 | else |
1847 | else |
1845 | { |
1848 | { |
1846 | play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); |
1849 | op->contr->play_sound (sound_find ("fumble_spell")); |
1847 | new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell.\n"); |
1850 | 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 | } |
1851 | } |
1849 | |
1852 | |
1850 | decrease_ob (tmp); |
1853 | decrease_ob (tmp); |
1851 | } |
1854 | } |
1852 | |
1855 | |
… | |
… | |
1864 | return; |
1867 | return; |
1865 | } |
1868 | } |
1866 | |
1869 | |
1867 | if (!tmp->inv || tmp->inv->type != SPELL) |
1870 | if (!tmp->inv || tmp->inv->type != SPELL) |
1868 | { |
1871 | { |
1869 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense!"); |
1872 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>"); |
1870 | return; |
1873 | return; |
1871 | } |
1874 | } |
1872 | |
1875 | |
1873 | if (op->type == PLAYER) |
1876 | if (op->type == PLAYER) |
1874 | { |
1877 | { |
… | |
… | |
1880 | */ |
1883 | */ |
1881 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1884 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1882 | |
1885 | |
1883 | if (!skop) |
1886 | if (!skop) |
1884 | { |
1887 | { |
1885 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1888 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
1886 | return; |
1889 | return; |
1887 | } |
1890 | } |
1888 | |
1891 | |
1889 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1892 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1890 | change_exp (op, exp_gain, skop->skill, 0); |
1893 | change_exp (op, exp_gain, skop->skill, 0); |
… | |
… | |
2011 | /* special food hack -b.t. */ |
2014 | /* special food hack -b.t. */ |
2012 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2015 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2013 | eat_special_food (op, tmp); |
2016 | eat_special_food (op, tmp); |
2014 | } |
2017 | } |
2015 | } |
2018 | } |
|
|
2019 | |
2016 | handle_apply_yield (tmp); |
2020 | handle_apply_yield (tmp); |
2017 | decrease_ob (tmp); |
2021 | decrease_ob (tmp); |
2018 | } |
2022 | } |
2019 | |
2023 | |
2020 | /** |
2024 | /** |
… | |
… | |
2182 | static void |
2186 | static void |
2183 | apply_armour_improver (object *op, object *tmp) |
2187 | apply_armour_improver (object *op, object *tmp) |
2184 | { |
2188 | { |
2185 | object *armor; |
2189 | object *armor; |
2186 | |
2190 | |
2187 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
2191 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2188 | { |
2192 | { |
2189 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); |
2193 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H<The area prevents magic effects.>"); |
2190 | return; |
2194 | return; |
2191 | } |
2195 | } |
2192 | |
2196 | |
2193 | armor = find_marked_object (op); |
2197 | armor = find_marked_object (op); |
2194 | |
2198 | |
2195 | if (!armor) |
2199 | if (!armor) |
2196 | { |
2200 | { |
2197 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); |
2201 | 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; |
2202 | return; |
2199 | } |
2203 | } |
2200 | |
2204 | |
2201 | if (armor->type != ARMOUR |
2205 | if (armor->type != ARMOUR |
2202 | && armor->type != CLOAK |
2206 | && armor->type != CLOAK |
… | |
… | |
2213 | extern void |
2217 | extern void |
2214 | apply_poison (object *op, object *tmp) |
2218 | apply_poison (object *op, object *tmp) |
2215 | { |
2219 | { |
2216 | if (op->type == PLAYER) |
2220 | if (op->type == PLAYER) |
2217 | { |
2221 | { |
2218 | play_sound_player_only (op->contr, SOUND_DRINK_POISON, 0, 0); |
2222 | op->contr->play_sound (sound_find ("drink_poison")); |
2219 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2223 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2220 | strcpy (op->contr->killer, "poisonous booze"); |
2224 | strcpy (op->contr->killer, "poisonous booze"); |
2221 | } |
2225 | } |
|
|
2226 | |
2222 | if (tmp->stats.hp > 0) |
2227 | if (tmp->stats.hp > 0) |
2223 | { |
2228 | { |
2224 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2229 | 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); |
2230 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2226 | } |
2231 | } |
|
|
2232 | |
2227 | op->stats.food -= op->stats.food / 4; |
2233 | op->stats.food -= op->stats.food / 4; |
2228 | handle_apply_yield (tmp); |
2234 | handle_apply_yield (tmp); |
2229 | decrease_ob (tmp); |
2235 | decrease_ob (tmp); |
2230 | } |
2236 | } |
2231 | |
2237 | |
… | |
… | |
2341 | |
2347 | |
2342 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2348 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2343 | { |
2349 | { |
2344 | if (op->type == PLAYER) |
2350 | if (op->type == PLAYER) |
2345 | { |
2351 | { |
2346 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); |
2352 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H<You cannot use items marked as unpaid.>"); |
2347 | return 1; |
2353 | return 1; |
2348 | } |
2354 | } |
2349 | else |
2355 | else |
2350 | return 0; /* monsters just skip unpaid items */ |
2356 | return 0; /* monsters just skip unpaid items */ |
2351 | } |
2357 | } |
… | |
… | |
2355 | |
2361 | |
2356 | switch (tmp->type) |
2362 | switch (tmp->type) |
2357 | { |
2363 | { |
2358 | case CF_HANDLE: |
2364 | case CF_HANDLE: |
2359 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2365 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2360 | play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); |
2366 | op->play_sound (sound_find ("turn_handle")); |
2361 | tmp->value = tmp->value ? 0 : 1; |
2367 | tmp->value = tmp->value ? 0 : 1; |
2362 | SET_ANIMATION (tmp, tmp->value); |
2368 | SET_ANIMATION (tmp, tmp->value); |
2363 | update_object (tmp, UP_OBJ_FACE); |
2369 | update_object (tmp, UP_OBJ_FACE); |
2364 | push_button (tmp); |
2370 | push_button (tmp); |
2365 | return 1; |
2371 | return 1; |
2366 | |
2372 | |
2367 | case TRIGGER: |
2373 | case TRIGGER: |
2368 | if (check_trigger (tmp, op)) |
2374 | if (check_trigger (tmp, op)) |
2369 | { |
2375 | { |
2370 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2376 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2371 | play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); |
2377 | op->play_sound (sound_find ("turn_handle")); |
2372 | } |
2378 | } |
2373 | else |
2379 | else |
2374 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2380 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2375 | |
2381 | |
2376 | return 1; |
2382 | return 1; |
… | |
… | |
2509 | |
2515 | |
2510 | get_tod (&tod); |
2516 | get_tod (&tod); |
2511 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
2517 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
2512 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2518 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2513 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
2519 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
2514 | play_sound_player_only (op->contr, SOUND_CLOCK, 0, 0); |
2520 | op->play_sound (sound_find ("sound_clock")); |
2515 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2521 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2516 | return 1; |
2522 | return 1; |
2517 | } |
2523 | } |
2518 | else |
2524 | else |
2519 | return 0; |
2525 | return 0; |
… | |
… | |
2559 | int |
2565 | int |
2560 | player_apply (object *pl, object *op, int aflag, int quiet) |
2566 | player_apply (object *pl, object *op, int aflag, int quiet) |
2561 | { |
2567 | { |
2562 | int tmp; |
2568 | int tmp; |
2563 | |
2569 | |
2564 | if (op->env == NULL && (pl->move_type & MOVE_FLYING)) |
2570 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2565 | { |
2571 | { |
2566 | /* player is flying and applying object not in inventory */ |
2572 | /* player is flying and applying object not in inventory */ |
2567 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2573 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2568 | { |
2574 | { |
2569 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); |
2575 | 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; |
2576 | return 0; |
2571 | } |
2577 | } |
2572 | } |
2578 | } |
2573 | |
2579 | |
2574 | pl->contr->last_used = op; |
2580 | pl->contr->last_used = op; |
… | |
… | |
2579 | if (tmp == 0) |
2585 | if (tmp == 0) |
2580 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2586 | 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) |
2587 | else if (tmp == 2) |
2582 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2588 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2583 | } |
2589 | } |
|
|
2590 | |
2584 | return tmp; |
2591 | return tmp; |
2585 | } |
2592 | } |
2586 | |
2593 | |
2587 | /** |
2594 | /** |
2588 | * player_apply_below attempts to apply the object 'below' the player. |
2595 | * player_apply_below attempts to apply the object 'below' the player. |
… | |
… | |
2828 | * Returns 0 on success, returns 1 if there is some problem. |
2835 | * Returns 0 on success, returns 1 if there is some problem. |
2829 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2836 | * 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 |
2837 | * instead of doing it. This is a lot less code than having |
2831 | * another function that does just that. |
2838 | * another function that does just that. |
2832 | */ |
2839 | */ |
|
|
2840 | |
|
|
2841 | #define CANNOT_REMOVE_CURSED \ |
|
|
2842 | "H<You cannot remove cursed or damned items, you first have to remove the curse. " \ |
|
|
2843 | "Praying over an altar, scrolls of remove curse/damnation, " \ |
|
|
2844 | "priests or even other players might help.>" |
|
|
2845 | |
2833 | int |
2846 | int |
2834 | unapply_for_ob (object *who, object *op, int aflags) |
2847 | unapply_for_ob (object *who, object *op, int aflags) |
2835 | { |
2848 | { |
2836 | if (op->is_range ()) |
2849 | if (op->is_range ()) |
2837 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2850 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
… | |
… | |
2847 | { |
2860 | { |
2848 | /* In this case, we want to try and remove a cursed item. |
2861 | /* 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 |
2862 | * While we know it won't work, we want unapply_special to |
2850 | * at least generate the message. |
2863 | * at least generate the message. |
2851 | */ |
2864 | */ |
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)); |
2865 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
2866 | "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, |
|
|
2867 | query_name (tmp)); |
2853 | return 1; |
2868 | return 1; |
2854 | } |
2869 | } |
2855 | |
2870 | |
2856 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2871 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2857 | { |
2872 | { |
… | |
… | |
2891 | /* Cursed item that we can't unequip - tell the player. |
2906 | /* Cursed item that we can't unequip - tell the player. |
2892 | * Note this could be annoying if this is just one of a few, |
2907 | * 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 |
2908 | * so it may not be critical (eg, putting on a ring and you have |
2894 | * one cursed ring.) |
2909 | * one cursed ring.) |
2895 | */ |
2910 | */ |
2896 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off", query_name (tmp)); |
2911 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
2897 | } |
2912 | } |
2898 | |
2913 | |
2899 | last = tmp->below; |
2914 | last = tmp->below; |
2900 | } |
2915 | } |
2901 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
2916 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
3054 | * |
3069 | * |
3055 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3070 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3056 | * |
3071 | * |
3057 | * apply_special() doesn't check for unpaid items. |
3072 | * apply_special() doesn't check for unpaid items. |
3058 | */ |
3073 | */ |
|
|
3074 | |
|
|
3075 | #define LACK_ITEM_POWER \ |
|
|
3076 | " H<You lack enough unused item power to use this weapon, see the skills command.>" |
|
|
3077 | |
3059 | int |
3078 | int |
3060 | apply_special (object *who, object *op, int aflags) |
3079 | apply_special (object *who, object *op, int aflags) |
3061 | { |
3080 | { |
3062 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3081 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3063 | object *tmp, *tmp2, *skop = NULL; |
3082 | object *tmp, *tmp2, *skop = NULL; |
… | |
… | |
3078 | if (basic_flag == AP_APPLY) |
3097 | if (basic_flag == AP_APPLY) |
3079 | return 0; |
3098 | return 0; |
3080 | |
3099 | |
3081 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3100 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3082 | { |
3101 | { |
3083 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op)); |
3102 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3103 | "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, |
|
|
3104 | query_name (op)); |
3084 | return 1; |
3105 | return 1; |
3085 | } |
3106 | } |
3086 | |
3107 | |
3087 | return unapply_special (who, op, aflags); |
3108 | return unapply_special (who, op, aflags); |
3088 | } |
3109 | } |
… | |
… | |
3104 | /* Can't just apply this object. Lets see what not and what to do */ |
3125 | /* Can't just apply this object. Lets see what not and what to do */ |
3105 | if (int i = can_apply_object (who, op)) |
3126 | if (int i = can_apply_object (who, op)) |
3106 | { |
3127 | { |
3107 | if (i & CAN_APPLY_NEVER) |
3128 | if (i & CAN_APPLY_NEVER) |
3108 | { |
3129 | { |
3109 | new_draw_info_format (NDI_UNIQUE, 0, who, "You don't have the body to use a %s\n", query_name (op)); |
3130 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3131 | "You don't have the body to use a %s. H<You can never apply this item.>", |
|
|
3132 | query_name (op)); |
3110 | return 1; |
3133 | return 1; |
3111 | } |
3134 | } |
3112 | else if (i & CAN_APPLY_RESTRICTION) |
3135 | else if (i & CAN_APPLY_RESTRICTION) |
3113 | { |
3136 | { |
3114 | new_draw_info_format (NDI_UNIQUE, 0, who, "You have a prohibition against using a %s\n", query_name (op)); |
3137 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3138 | "You have a prohibition against using a %s. " |
|
|
3139 | "H<Your belief, profession or class prevents you from applying this item.>", |
|
|
3140 | query_name (op)); |
3115 | return 1; |
3141 | return 1; |
3116 | } |
3142 | } |
3117 | |
3143 | |
3118 | if (who->type != PLAYER) |
3144 | if (who->type != PLAYER) |
3119 | { |
3145 | { |
… | |
… | |
3154 | if (who->type == PLAYER |
3180 | if (who->type == PLAYER |
3155 | && op->item_power |
3181 | && op->item_power |
3156 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3182 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3157 | { |
3183 | { |
3158 | new_draw_info (NDI_UNIQUE, 0, who, |
3184 | new_draw_info (NDI_UNIQUE, 0, who, |
3159 | "Equipping that combined with other items would consume your soul! " |
3185 | "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; |
3186 | return 1; |
3162 | } |
3187 | } |
3163 | |
3188 | |
3164 | /* Ok. We are now at the state where we can apply the new object. |
3189 | /* 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_... |
3190 | * Note that we don't have the checks for can_use_... |
… | |
… | |
3177 | { |
3202 | { |
3178 | case WEAPON: |
3203 | case WEAPON: |
3179 | if (!check_weapon_power (who, op->last_eat)) |
3204 | if (!check_weapon_power (who, op->last_eat)) |
3180 | { |
3205 | { |
3181 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3206 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3182 | "It would consume your soul!."); |
3207 | "It would consume your soul!." LACK_ITEM_POWER); |
3183 | |
3208 | |
3184 | if (tmp) |
3209 | if (tmp) |
3185 | insert_ob_in_ob (tmp, who); |
3210 | insert_ob_in_ob (tmp, who); |
3186 | |
3211 | |
3187 | return 1; |
3212 | return 1; |
… | |
… | |
3191 | // i.e. "R" can use Ragnarok's sword. |
3216 | // i.e. "R" can use Ragnarok's sword. |
3192 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3217 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3193 | { |
3218 | { |
3194 | /* if the weapon does not have the name as the character, can't use it. */ |
3219 | /* 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) */ |
3220 | /* (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."); |
3221 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3222 | "The weapon does not recognize you as its owner. " |
|
|
3223 | "H<Its name indicates that it belongs to somebody else.>"); |
3197 | |
3224 | |
3198 | if (tmp) |
3225 | if (tmp) |
3199 | insert_ob_in_ob (tmp, who); |
3226 | insert_ob_in_ob (tmp, who); |
3200 | |
3227 | |
3201 | return 1; |
3228 | return 1; |
… | |
… | |
3235 | break; |
3262 | break; |
3236 | |
3263 | |
3237 | case LAMP: |
3264 | case LAMP: |
3238 | if (op->stats.food < 1) |
3265 | if (op->stats.food < 1) |
3239 | { |
3266 | { |
3240 | new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of fuel!", &op->name); |
3267 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3268 | "Your %s is out of fuel! " |
|
|
3269 | "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); |
3241 | return 1; |
3270 | return 1; |
3242 | } |
3271 | } |
3243 | |
3272 | |
3244 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3273 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3245 | tmp2 = arch_to_object (op->other_arch); |
3274 | tmp2 = arch_to_object (op->other_arch); |
… | |
… | |
3268 | who->update_stats (); |
3297 | who->update_stats (); |
3269 | |
3298 | |
3270 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3299 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3271 | if (who->type == PLAYER) |
3300 | if (who->type == PLAYER) |
3272 | { |
3301 | { |
3273 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3302 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3303 | "Oops, it feels deadly cold! " |
|
|
3304 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3274 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3305 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3275 | } |
3306 | } |
3276 | |
3307 | |
3277 | if (who->type == PLAYER) |
3308 | if (who->type == PLAYER) |
3278 | esrv_send_item (who, tmp2); |
3309 | esrv_send_item (who, tmp2); |
… | |
… | |
3306 | who->change_weapon (pl->combat_ob = item); |
3337 | who->change_weapon (pl->combat_ob = item); |
3307 | goto found_weapon; |
3338 | goto found_weapon; |
3308 | } |
3339 | } |
3309 | } |
3340 | } |
3310 | |
3341 | |
3311 | new_draw_info_format (NDI_UNIQUE, 0, who, "You need to apply a '%s' melee weapon before readying this skill", &op->skill); |
3342 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3343 | "You need to apply a '%s' melee weapon before readying this skill. " |
|
|
3344 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
|
|
3345 | &op->skill); |
3312 | return 1; |
3346 | return 1; |
3313 | |
3347 | |
3314 | found_weapon:; |
3348 | found_weapon:; |
3315 | } |
3349 | } |
3316 | else |
3350 | else |
… | |
… | |
3326 | //TODO: bows should/must all have skill missile weapon right now |
3360 | //TODO: bows should/must all have skill missile weapon right now |
3327 | who->change_weapon (pl->ranged_ob = item); |
3361 | who->change_weapon (pl->ranged_ob = item); |
3328 | goto found_bow; |
3362 | goto found_bow; |
3329 | } |
3363 | } |
3330 | |
3364 | |
|
|
3365 | 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"); |
3366 | "You need to apply a missile weapon before readying this skill. " |
|
|
3367 | "H<Some skills need an item, in this case a missile weapon, to function.>"); |
3332 | return 1; |
3368 | return 1; |
3333 | |
3369 | |
3334 | found_bow:; |
3370 | found_bow:; |
3335 | } |
3371 | } |
3336 | else |
3372 | else |
… | |
… | |
3356 | break; |
3392 | break; |
3357 | |
3393 | |
3358 | case BOW: |
3394 | case BOW: |
3359 | if (!check_weapon_power (who, op->last_eat)) |
3395 | if (!check_weapon_power (who, op->last_eat)) |
3360 | { |
3396 | { |
3361 | new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); |
3397 | new_draw_info (NDI_UNIQUE, 0, who, |
3362 | new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); |
3398 | "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3363 | |
3399 | |
3364 | if (tmp) |
3400 | if (tmp) |
3365 | insert_ob_in_ob (tmp, who); |
3401 | insert_ob_in_ob (tmp, who); |
3366 | |
3402 | |
3367 | return 1; |
3403 | return 1; |
3368 | } |
3404 | } |
3369 | |
3405 | |
3370 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3406 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3371 | { |
3407 | { |
3372 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3408 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3409 | "The weapon does not recognize you as its owner. " |
|
|
3410 | "H<Its name indicates that it belongs to somebody else.>"); |
3373 | if (tmp) |
3411 | if (tmp) |
3374 | insert_ob_in_ob (tmp, who); |
3412 | insert_ob_in_ob (tmp, who); |
3375 | |
3413 | |
3376 | return 1; |
3414 | return 1; |
3377 | } |
3415 | } |
… | |
… | |
3445 | */ |
3483 | */ |
3446 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3484 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3447 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3485 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3448 | |
3486 | |
3449 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3487 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3450 | { |
|
|
3451 | if (who->type == PLAYER) |
3488 | if (who->type == PLAYER) |
3452 | { |
3489 | { |
3453 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3490 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3491 | "Oops, it feels deadly cold! " |
|
|
3492 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3454 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3493 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3455 | } |
3494 | } |
3456 | } |
|
|
3457 | |
3495 | |
3458 | if (who->type == PLAYER) |
3496 | if (who->type == PLAYER) |
3459 | { |
3497 | { |
3460 | /* if multiple objects were applied, update both slots */ |
3498 | /* if multiple objects were applied, update both slots */ |
3461 | if (tmp) |
3499 | if (tmp) |
… | |
… | |
3470 | int |
3508 | int |
3471 | monster_apply_special (object *who, object *op, int aflags) |
3509 | monster_apply_special (object *who, object *op, int aflags) |
3472 | { |
3510 | { |
3473 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3511 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3474 | return 1; |
3512 | return 1; |
|
|
3513 | |
3475 | return apply_special (who, op, aflags); |
3514 | return apply_special (who, op, aflags); |
3476 | } |
3515 | } |
3477 | |
3516 | |
3478 | /** |
3517 | /** |
3479 | * Map was just loaded, handle op's initialisation. |
3518 | * Map was just loaded, handle op's initialisation. |
… | |
… | |
3805 | |
3844 | |
3806 | if (failure <= -1 && failure > -15) |
3845 | if (failure <= -1 && failure > -15) |
3807 | { /* wonder */ |
3846 | { /* wonder */ |
3808 | object *tmp; |
3847 | object *tmp; |
3809 | |
3848 | |
3810 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3849 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); |
3811 | tmp = get_archetype (SPELL_WONDER); |
3850 | tmp = get_archetype (SPELL_WONDER); |
3812 | cast_wonder (op, op, 0, tmp); |
3851 | cast_wonder (op, op, 0, tmp); |
3813 | tmp->destroy (); |
3852 | tmp->destroy (); |
3814 | } |
3853 | } |
3815 | else if (failure <= -15 && failure > -35) |
3854 | else if (failure <= -15 && failure > -35) |
… | |
… | |
3955 | char got[MAX_BUF]; |
3994 | char got[MAX_BUF]; |
3956 | int len; |
3995 | int len; |
3957 | |
3996 | |
3958 | if (!pl || !transformer) |
3997 | if (!pl || !transformer) |
3959 | return; |
3998 | return; |
|
|
3999 | |
3960 | marked = find_marked_object (pl); |
4000 | marked = find_marked_object (pl); |
|
|
4001 | |
3961 | if (!marked) |
4002 | if (!marked) |
3962 | { |
4003 | { |
3963 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
4004 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
3964 | return; |
4005 | return; |
3965 | } |
4006 | } |
|
|
4007 | |
3966 | if (!marked->slaying) |
4008 | if (!marked->slaying) |
3967 | { |
4009 | { |
3968 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4010 | 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; |
4011 | return; |
3970 | } |
4012 | } |
|
|
4013 | |
3971 | /* check whether they are compatible or not */ |
4014 | /* check whether they are compatible or not */ |
3972 | find = strstr (marked->slaying, transformer->arch->archname); |
4015 | find = strstr (marked->slaying, transformer->arch->archname); |
3973 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4016 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3974 | { |
4017 | { |
3975 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4018 | 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; |
4019 | return; |
3977 | } |
4020 | } |
|
|
4021 | |
3978 | find += strlen (transformer->arch->archname) + 1; |
4022 | find += strlen (transformer->arch->archname) + 1; |
3979 | /* Item can be used, now find how many and what it yields */ |
4023 | /* Item can be used, now find how many and what it yields */ |
3980 | if (isdigit (*(find))) |
4024 | if (isdigit (*(find))) |
3981 | { |
4025 | { |
3982 | yield = atoi (find); |
4026 | yield = atoi (find); |
… | |
… | |
3991 | |
4035 | |
3992 | while (isdigit (*find)) |
4036 | while (isdigit (*find)) |
3993 | find++; |
4037 | find++; |
3994 | while (*find == ' ') |
4038 | while (*find == ' ') |
3995 | find++; |
4039 | find++; |
|
|
4040 | |
3996 | memset (got, 0, MAX_BUF); |
4041 | memset (got, 0, MAX_BUF); |
|
|
4042 | |
3997 | if ((separator = strchr (find, ';')) != NULL) |
4043 | if ((separator = strchr (find, ';')) != NULL) |
3998 | { |
|
|
3999 | len = separator - find; |
4044 | len = separator - find; |
4000 | } |
|
|
4001 | else |
4045 | else |
4002 | { |
|
|
4003 | len = strlen (find); |
4046 | len = strlen (find); |
4004 | } |
4047 | |
4005 | if (len > MAX_BUF - 1) |
4048 | if (len > MAX_BUF - 1) |
4006 | len = MAX_BUF - 1; |
4049 | len = MAX_BUF - 1; |
|
|
4050 | |
4007 | strcpy (got, find); |
4051 | strcpy (got, find); |
4008 | got[len] = '\0'; |
4052 | got[len] = '\0'; |
4009 | |
4053 | |
4010 | /* Now create new item, remove used ones when required. */ |
4054 | /* Now create new item, remove used ones when required. */ |
4011 | new_item = get_archetype (got); |
4055 | 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)); |
4063 | 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); |
4064 | insert_ob_in_ob (new_item, pl); |
4021 | esrv_send_inventory (pl, pl); |
4065 | esrv_send_inventory (pl, pl); |
4022 | /* Eat up one item */ |
4066 | /* Eat up one item */ |
4023 | decrease_ob_nr (marked, 1); |
4067 | decrease_ob_nr (marked, 1); |
|
|
4068 | |
4024 | /* Eat one transformer if needed */ |
4069 | /* Eat one transformer if needed */ |
4025 | if (transformer->stats.food) |
4070 | if (transformer->stats.food) |
4026 | if (--transformer->stats.food == 0) |
4071 | if (--transformer->stats.food == 0) |
4027 | decrease_ob_nr (transformer, 1); |
4072 | decrease_ob_nr (transformer, 1); |
4028 | } |
4073 | } |