… | |
… | |
1029 | if (sack == NULL || sack->type != CONTAINER) |
1029 | if (sack == NULL || sack->type != CONTAINER) |
1030 | { |
1030 | { |
1031 | LOG (llevError, "apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1031 | LOG (llevError, "apply_container: %s is not container!\n", sack ? &sack->name : "[nullobject]"); |
1032 | return 0; |
1032 | return 0; |
1033 | } |
1033 | } |
1034 | op->contr->last_used = NULL; |
1034 | |
1035 | op->contr->last_used_id = 0; |
1035 | op->contr->last_used = 0; |
1036 | |
1036 | |
1037 | if (sack->env != op) |
1037 | if (sack->env != op) |
1038 | { |
1038 | { |
1039 | if (sack->other_arch == NULL || sack->env != NULL) |
1039 | if (sack->other_arch == NULL || sack->env != NULL) |
1040 | { |
1040 | { |
1041 | new_draw_info (NDI_UNIQUE, 0, op, "You must get it first."); |
1041 | new_draw_info (NDI_UNIQUE, 0, op, "You must get it first."); |
1042 | return 1; |
1042 | return 1; |
1043 | } |
1043 | } |
|
|
1044 | |
1044 | /* It's on the ground, the problems begin */ |
1045 | /* It's on the ground, the problems begin */ |
1045 | if (op->container != sack) |
1046 | if (op->container != sack) |
1046 | { |
1047 | { |
1047 | /* it's closed OR some player has opened it */ |
1048 | /* it's closed OR some player has opened it */ |
1048 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
1049 | if (QUERY_FLAG (sack, FLAG_APPLIED)) |
… | |
… | |
1143 | apply_container (op, sack); |
1144 | apply_container (op, sack); |
1144 | return 1; |
1145 | return 1; |
1145 | } |
1146 | } |
1146 | } |
1147 | } |
1147 | } |
1148 | } |
|
|
1149 | |
1148 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1150 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1151 | |
1149 | if (op->contr) |
1152 | if (op->contr) |
1150 | op->contr->socket.update_look = 1; |
1153 | op->contr->socket->update_look = 1; |
|
|
1154 | |
1151 | return 1; |
1155 | return 1; |
1152 | } |
1156 | } |
1153 | |
1157 | |
1154 | /** |
1158 | /** |
1155 | * Eneq(@csd.uu.se): Handle apply on containers. This is for containers |
1159 | * Eneq(@csd.uu.se): Handle apply on containers. This is for containers |
… | |
… | |
1786 | |
1790 | |
1787 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1791 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1788 | { |
1792 | { |
1789 | /*exp_gain *= 2; because they just identified it too */ |
1793 | /*exp_gain *= 2; because they just identified it too */ |
1790 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1794 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
|
|
1795 | |
1791 | /* If in a container, update how it looks */ |
1796 | /* If in a container, update how it looks */ |
1792 | if (tmp->env) |
1797 | if (tmp->env) |
1793 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1798 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1794 | else |
1799 | else |
1795 | op->contr->socket.update_look = 1; |
1800 | op->contr->socket->update_look = 1; |
1796 | } |
1801 | } |
|
|
1802 | |
1797 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1803 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1798 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1804 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1799 | } |
1805 | } |
1800 | } |
1806 | } |
1801 | |
1807 | |
… | |
… | |
1850 | } |
1856 | } |
1851 | return; |
1857 | return; |
1852 | } |
1858 | } |
1853 | |
1859 | |
1854 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1860 | play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); |
1855 | tmp = object::create (); |
1861 | tmp = spell->clone (); |
1856 | spell->copy_to (tmp); |
|
|
1857 | insert_ob_in_ob (tmp, op); |
1862 | insert_ob_in_ob (tmp, op); |
1858 | |
1863 | |
1859 | if (special_prayer) |
1864 | if (special_prayer) |
1860 | { |
|
|
1861 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1865 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
1862 | } |
|
|
1863 | |
1866 | |
1864 | esrv_add_spells (op->contr, tmp); |
1867 | esrv_add_spells (op->contr, tmp); |
1865 | } |
1868 | } |
1866 | |
1869 | |
1867 | /** |
1870 | /** |
… | |
… | |
1951 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1954 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1952 | |
1955 | |
1953 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1956 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1954 | { |
1957 | { |
1955 | identify (tmp); |
1958 | identify (tmp); |
|
|
1959 | |
1956 | if (tmp->env) |
1960 | if (tmp->env) |
1957 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1961 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1958 | else |
1962 | else |
1959 | op->contr->socket.update_look = 1; |
1963 | op->contr->socket->update_look = 1; |
1960 | } |
1964 | } |
1961 | |
1965 | |
1962 | /* I removed the check for special_prayer_mark here - it didn't make |
1966 | /* I removed the check for special_prayer_mark here - it didn't make |
1963 | * a lot of sense - special prayers are not found in spellbooks, and |
1967 | * a lot of sense - special prayers are not found in spellbooks, and |
1964 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1968 | * if the player doesn't know the spell, doesn't make a lot of sense that |
… | |
… | |
2811 | op->destroy (); |
2815 | op->destroy (); |
2812 | return 1; |
2816 | return 1; |
2813 | } |
2817 | } |
2814 | |
2818 | |
2815 | pl->contr->last_used = op; |
2819 | pl->contr->last_used = op; |
2816 | pl->contr->last_used_id = op->count; |
|
|
2817 | |
2820 | |
2818 | tmp = manual_apply (pl, op, aflag); |
2821 | tmp = manual_apply (pl, op, aflag); |
2819 | if (!quiet) |
2822 | if (!quiet) |
2820 | { |
2823 | { |
2821 | if (tmp == 0) |
2824 | if (tmp == 0) |
… | |
… | |
3651 | int i; |
3654 | int i; |
3652 | |
3655 | |
3653 | switch (op->type) |
3656 | switch (op->type) |
3654 | { |
3657 | { |
3655 | case SHOP_FLOOR: |
3658 | case SHOP_FLOOR: |
3656 | if (!HAS_RANDOM_ITEMS (op)) |
3659 | if (!op->has_random_items ()) |
3657 | return 0; |
3660 | return 0; |
3658 | |
3661 | |
3659 | do |
3662 | do |
3660 | { |
3663 | { |
3661 | i = 10; /* let's give it 10 tries */ |
3664 | i = 10; /* let's give it 10 tries */ |
… | |
… | |
3738 | { |
3741 | { |
3739 | invnext = invtmp->below; |
3742 | invnext = invtmp->below; |
3740 | |
3743 | |
3741 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3744 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3742 | auto_apply (invtmp); |
3745 | auto_apply (invtmp); |
3743 | else if (invtmp->type == TREASURE && HAS_RANDOM_ITEMS (invtmp)) |
3746 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3744 | { |
3747 | { |
3745 | while ((invtmp->stats.hp--) > 0) |
3748 | while ((invtmp->stats.hp--) > 0) |
3746 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3749 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3747 | |
3750 | |
3748 | invtmp->randomitems = NULL; |
3751 | invtmp->randomitems = NULL; |
3749 | } |
3752 | } |
3750 | else if (invtmp && invtmp->arch |
3753 | else if (invtmp && invtmp->arch |
3751 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && HAS_RANDOM_ITEMS (invtmp)) |
3754 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) |
3752 | { |
3755 | { |
3753 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3756 | create_treasure (invtmp->randomitems, invtmp, 0, m->difficulty, 0); |
3754 | /* Need to clear this so that we never try to create |
3757 | /* Need to clear this so that we never try to create |
3755 | * treasure again for this object |
3758 | * treasure again for this object |
3756 | */ |
3759 | */ |
… | |
… | |
3773 | |
3776 | |
3774 | } |
3777 | } |
3775 | |
3778 | |
3776 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3779 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3777 | auto_apply (tmp); |
3780 | auto_apply (tmp); |
3778 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && HAS_RANDOM_ITEMS (tmp)) |
3781 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3779 | { |
3782 | { |
3780 | while ((tmp->stats.hp--) > 0) |
3783 | while ((tmp->stats.hp--) > 0) |
3781 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
3784 | create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
3782 | tmp->randomitems = NULL; |
3785 | tmp->randomitems = NULL; |
3783 | } |
3786 | } |
… | |
… | |
3798 | * This is a problem for the above objects, because they have counters |
3801 | * This is a problem for the above objects, because they have counters |
3799 | * which say how many times to make the treasure. |
3802 | * which say how many times to make the treasure. |
3800 | */ |
3803 | */ |
3801 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3804 | else if (tmp && tmp->arch && tmp->type != PLAYER |
3802 | && tmp->type != TREASURE && tmp->type != SPELL |
3805 | && tmp->type != TREASURE && tmp->type != SPELL |
3803 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && HAS_RANDOM_ITEMS (tmp)) |
3806 | && tmp->type != PLAYER_CHANGER && tmp->type != CLASS && tmp->has_random_items ()) |
3804 | { |
3807 | { |
3805 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3808 | create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
3806 | tmp->randomitems = NULL; |
3809 | tmp->randomitems = NULL; |
3807 | } |
3810 | } |
3808 | } |
3811 | } |
… | |
… | |
3921 | { /* lighter gets used up */ |
3924 | { /* lighter gets used up */ |
3922 | /* Split multiple lighters if they're being used up. Otherwise * |
3925 | /* Split multiple lighters if they're being used up. Otherwise * |
3923 | * one charge from each would be used up. --DAMN */ |
3926 | * one charge from each would be used up. --DAMN */ |
3924 | if (lighter->nrof > 1) |
3927 | if (lighter->nrof > 1) |
3925 | { |
3928 | { |
3926 | object *oneLighter = object::create (); |
3929 | object *oneLighter = lighter->clone (); |
3927 | |
3930 | |
3928 | lighter->copy_to (oneLighter); |
|
|
3929 | lighter->nrof -= 1; |
3931 | lighter->nrof -= 1; |
3930 | oneLighter->nrof = 1; |
3932 | oneLighter->nrof = 1; |
3931 | oneLighter->stats.food--; |
3933 | oneLighter->stats.food--; |
3932 | esrv_send_item (who, lighter); |
3934 | esrv_send_item (who, lighter); |
3933 | oneLighter = insert_ob_in_ob (oneLighter, who); |
3935 | oneLighter = insert_ob_in_ob (oneLighter, who); |