アイテムを拾うモンスターの持つアイテムが整理されるように(from Angband)。金を盗んだモンスターを倒すと、盗んだお金をドロップするようにした。(thanks to paulblayさん)
@@ -3344,23 +3344,11 @@ | ||
3344 | 3344 | #endif |
3345 | 3345 | } |
3346 | 3346 | |
3347 | - /* Excise the object */ | |
3347 | + /* Excise the object from floor */ | |
3348 | 3348 | excise_object_idx(this_o_idx); |
3349 | 3349 | |
3350 | - /* Forget mark */ | |
3351 | - o_ptr->marked &= OM_TOUCHED; | |
3352 | - | |
3353 | - /* Forget location */ | |
3354 | - o_ptr->iy = o_ptr->ix = 0; | |
3355 | - | |
3356 | - /* Memorize monster */ | |
3357 | - o_ptr->held_m_idx = m_idx; | |
3358 | - | |
3359 | - /* Build a stack */ | |
3360 | - o_ptr->next_o_idx = m_ptr->hold_o_idx; | |
3361 | - | |
3362 | - /* Carry object */ | |
3363 | - m_ptr->hold_o_idx = this_o_idx; | |
3350 | + /* Carry the object */ | |
3351 | + (void)monster_carry(m_idx, o_ptr); | |
3364 | 3352 | } |
3365 | 3353 | |
3366 | 3354 | /* Destroy the item if not a pet */ |
@@ -862,31 +862,49 @@ | ||
862 | 862 | if (gold <= 0) |
863 | 863 | { |
864 | 864 | #ifdef JP |
865 | - msg_print("しかし何も盗まれなかった。"); | |
865 | + msg_print("しかし何も盗まれなかった。"); | |
866 | 866 | #else |
867 | 867 | msg_print("Nothing was stolen."); |
868 | 868 | #endif |
869 | - | |
870 | 869 | } |
871 | - else if (p_ptr->au) | |
870 | + else | |
872 | 871 | { |
872 | + object_type *i_ptr; | |
873 | + object_type object_type_body; | |
874 | + | |
875 | + /* Get local object */ | |
876 | + i_ptr = &object_type_body; | |
877 | + | |
878 | + /* Wipe the object */ | |
879 | + object_wipe(i_ptr); | |
880 | + | |
881 | + /* Prepare a gold object */ | |
882 | + object_prep(i_ptr, OBJ_GOLD_LIST + 3); | |
883 | + i_ptr->pval = gold; | |
884 | + | |
885 | + /* Carry the object */ | |
886 | + (void)monster_carry(m_idx, i_ptr); | |
887 | + | |
888 | + if (p_ptr->au) | |
889 | + { | |
873 | 890 | #ifdef JP |
874 | - msg_print("財布が軽くなった気がする。"); | |
875 | - msg_format("$%ld のお金が盗まれた!", (long)gold); | |
891 | + msg_print("財布が軽くなった気がする。"); | |
892 | + msg_format("$%ld のお金が盗まれた!", (long)gold); | |
876 | 893 | #else |
877 | - msg_print("Your purse feels lighter."); | |
878 | - msg_format("%ld coins were stolen!", (long)gold); | |
894 | + msg_print("Your purse feels lighter."); | |
895 | + msg_format("%ld coins were stolen!", (long)gold); | |
879 | 896 | #endif |
880 | - } | |
881 | - else | |
882 | - { | |
897 | + } | |
898 | + else | |
899 | + { | |
883 | 900 | #ifdef JP |
884 | - msg_print("財布が軽くなった気がする。"); | |
885 | - msg_print("お金が全部盗まれた!"); | |
901 | + msg_print("財布が軽くなった気がする。"); | |
902 | + msg_print("お金が全部盗まれた!"); | |
886 | 903 | #else |
887 | - msg_print("Your purse feels lighter."); | |
888 | - msg_print("All of your coins were stolen!"); | |
904 | + msg_print("Your purse feels lighter."); | |
905 | + msg_print("All of your coins were stolen!"); | |
889 | 906 | #endif |
907 | + } | |
890 | 908 | } |
891 | 909 | |
892 | 910 | /* Redraw gold */ |
@@ -3755,3 +3755,74 @@ | ||
3755 | 3755 | /* Forget objects */ |
3756 | 3756 | m_ptr->hold_o_idx = 0; |
3757 | 3757 | } |
3758 | + | |
3759 | + | |
3760 | +/* | |
3761 | + * Make a monster carry an object | |
3762 | + * Taken from Angband 3.1.0 under the Angband license | |
3763 | + */ | |
3764 | +s16b monster_carry(int m_idx, object_type *j_ptr) | |
3765 | +{ | |
3766 | + s16b o_idx; | |
3767 | + | |
3768 | + s16b this_o_idx, next_o_idx = 0; | |
3769 | + | |
3770 | + monster_type *m_ptr = &m_list[m_idx]; | |
3771 | + | |
3772 | + | |
3773 | + /* Scan objects already being held for combination */ | |
3774 | + for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) | |
3775 | + { | |
3776 | + object_type *o_ptr; | |
3777 | + | |
3778 | + /* Get the object */ | |
3779 | + o_ptr = &o_list[this_o_idx]; | |
3780 | + | |
3781 | + /* Get the next object */ | |
3782 | + next_o_idx = o_ptr->next_o_idx; | |
3783 | + | |
3784 | + /* Check for combination */ | |
3785 | + if (object_similar(o_ptr, j_ptr)) | |
3786 | + { | |
3787 | + /* Combine the items */ | |
3788 | + object_absorb(o_ptr, j_ptr); | |
3789 | + | |
3790 | + /* Result */ | |
3791 | + return (this_o_idx); | |
3792 | + } | |
3793 | + } | |
3794 | + | |
3795 | + | |
3796 | + /* Make an object */ | |
3797 | + o_idx = o_pop(); | |
3798 | + | |
3799 | + /* Success */ | |
3800 | + if (o_idx) | |
3801 | + { | |
3802 | + object_type *o_ptr; | |
3803 | + | |
3804 | + /* Get new object */ | |
3805 | + o_ptr = &o_list[o_idx]; | |
3806 | + | |
3807 | + /* Copy object */ | |
3808 | + object_copy(o_ptr, j_ptr); | |
3809 | + | |
3810 | + /* Forget mark */ | |
3811 | + o_ptr->marked = OM_TOUCHED; | |
3812 | + | |
3813 | + /* Forget location */ | |
3814 | + o_ptr->iy = o_ptr->ix = 0; | |
3815 | + | |
3816 | + /* Link the object to the monster */ | |
3817 | + o_ptr->held_m_idx = m_idx; | |
3818 | + | |
3819 | + /* Link the object to the pile */ | |
3820 | + o_ptr->next_o_idx = m_ptr->hold_o_idx; | |
3821 | + | |
3822 | + /* Link the monster to the object */ | |
3823 | + m_ptr->hold_o_idx = o_idx; | |
3824 | + } | |
3825 | + | |
3826 | + /* Result */ | |
3827 | + return (o_idx); | |
3828 | +} |
@@ -796,6 +796,7 @@ | ||
796 | 796 | extern bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet); |
797 | 797 | extern bool player_place(int y, int x); |
798 | 798 | extern void monster_drop_carried_objects(monster_type *m_ptr); |
799 | +extern s16b monster_carry(int m_idx, object_type *j_ptr); | |
799 | 800 | |
800 | 801 | /* object1.c */ |
801 | 802 | extern void reset_visuals(void); |