• R/O
  • SSH
  • HTTPS

xangband: Commit


Commit MetaInfo

Révision1788 (tree)
l'heure2009-03-16 13:22:00
Auteuriks

Message de Log

アイテムを拾うモンスターの持つアイテムが整理されるように(from Angband)。金を盗んだモンスターを倒すと、盗んだお金をドロップするようにした。(thanks to paulblayさん)

Change Summary

Modification

--- XAngband/trunk/src/melee2.c (revision 1787)
+++ XAngband/trunk/src/melee2.c (revision 1788)
@@ -3344,23 +3344,11 @@
33443344 #endif
33453345 }
33463346
3347- /* Excise the object */
3347+ /* Excise the object from floor */
33483348 excise_object_idx(this_o_idx);
33493349
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);
33643352 }
33653353
33663354 /* Destroy the item if not a pet */
--- XAngband/trunk/src/melee1.c (revision 1787)
+++ XAngband/trunk/src/melee1.c (revision 1788)
@@ -862,31 +862,49 @@
862862 if (gold <= 0)
863863 {
864864 #ifdef JP
865- msg_print("しかし何も盗まれなかった。");
865+ msg_print("しかし何も盗まれなかった。");
866866 #else
867867 msg_print("Nothing was stolen.");
868868 #endif
869-
870869 }
871- else if (p_ptr->au)
870+ else
872871 {
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+ {
873890 #ifdef JP
874- msg_print("財布が軽くなった気がする。");
875- msg_format("$%ld のお金が盗まれた!", (long)gold);
891+ msg_print("財布が軽くなった気がする。");
892+ msg_format("$%ld のお金が盗まれた!", (long)gold);
876893 #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);
879896 #endif
880- }
881- else
882- {
897+ }
898+ else
899+ {
883900 #ifdef JP
884- msg_print("財布が軽くなった気がする。");
885- msg_print("お金が全部盗まれた!");
901+ msg_print("財布が軽くなった気がする。");
902+ msg_print("お金が全部盗まれた!");
886903 #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!");
889906 #endif
907+ }
890908 }
891909
892910 /* Redraw gold */
--- XAngband/trunk/src/monster2.c (revision 1787)
+++ XAngband/trunk/src/monster2.c (revision 1788)
@@ -3755,3 +3755,74 @@
37553755 /* Forget objects */
37563756 m_ptr->hold_o_idx = 0;
37573757 }
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+}
--- XAngband/trunk/src/externs.h (revision 1787)
+++ XAngband/trunk/src/externs.h (revision 1788)
@@ -796,6 +796,7 @@
796796 extern bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet);
797797 extern bool player_place(int y, int x);
798798 extern void monster_drop_carried_objects(monster_type *m_ptr);
799+extern s16b monster_carry(int m_idx, object_type *j_ptr);
799800
800801 /* object1.c */
801802 extern void reset_visuals(void);
Afficher sur ancien navigateur de dépôt.