From 56d92cdb7bca9a842b46ae7b0a7ba3264d50db97 Mon Sep 17 00:00:00 2001 From: nothere Date: Thu, 5 Aug 2004 23:59:39 +0000 Subject: [PATCH] =?utf8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=82=92?= =?utf8?q?=E6=8B=BE=E3=81=A3=E3=81=9F=E3=83=A2=E3=83=B3=E3=82=B9=E3=82=BF?= =?utf8?q?=E3=83=BC=E3=81=8C=E3=82=AB=E3=82=AA=E3=82=B9=E7=9A=84=E5=8A=B9?= =?utf8?q?=E6=9E=9C=E3=82=84=E3=82=AB=E3=82=AA=E3=82=B9=E5=B1=9E=E6=80=A7?= =?utf8?q?=E7=AD=89=E3=81=A7=E5=A4=89=E8=BA=AB=E3=81=97,=20=E5=A4=89?= =?utf8?q?=E8=BA=AB=20=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=97=E3=81=9F?= =?utf8?q?=E5=A0=B4=E5=90=88,=20=E5=80=92=E3=81=99=E3=81=A8(=E3=81=AA?= =?utf8?q?=E3=81=97)=E3=82=92=E8=90=BD=E3=81=A8=E3=81=99=E3=83=90=E3=82=B0?= =?utf8?q?=E3=82=92=E4=BF=AE=E6=AD=A3.=20=E3=81=BE=E3=81=9F,=20=E3=81=93?= =?utf8?q?=E3=82=8C=E3=82=89=E3=81=AE=E5=A4=89=E8=BA=AB=E3=81=A7=20?= =?utf8?q?=E3=81=AF=E3=83=A2=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=BC=E3=81=AF?= =?utf8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=82=92=E5=A4=B1=E3=82=8F?= =?utf8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/spells3.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/spells3.c b/src/spells3.c index 7a2c935b4..68264b969 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -5492,12 +5492,17 @@ bool polymorph_monster(int y, int x) if (new_r_idx != old_r_idx) { u32b mode = 0L; + bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE; + s16b this_o_idx, next_o_idx = 0; /* Get the monsters attitude */ if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY; if (is_pet(m_ptr)) mode |= PM_FORCE_PET; if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET; + /* Mega-hack -- ignore held objects */ + m_ptr->hold_o_idx = 0; + /* "Kill" the "old" monster */ delete_monster_idx(c_ptr->m_idx); @@ -5506,6 +5511,7 @@ bool polymorph_monster(int y, int x) { m_list[hack_m_idx_ii].nickname = back_m.nickname; m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx; + m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx; /* Success */ polymorphed = TRUE; @@ -5520,6 +5526,35 @@ bool polymorph_monster(int y, int x) /* Re-initialize monster process */ mproc_init(); } + else preserve_hold_objects = FALSE; + } + + /* Mega-hack -- preserve held objects */ + if (preserve_hold_objects) + { + for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) + { + /* Acquire object */ + object_type *o_ptr = &o_list[this_o_idx]; + + /* Acquire next object */ + next_o_idx = o_ptr->next_o_idx; + + /* Held by new monster */ + o_ptr->held_m_idx = hack_m_idx_ii; + } + } + else if (back_m.hold_o_idx) /* Failed (paranoia) */ + { + /* Delete objects */ + for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) + { + /* Acquire next object */ + next_o_idx = o_list[this_o_idx].next_o_idx; + + /* Delete the object */ + delete_object_idx(this_o_idx); + } } if (targeted) target_who = hack_m_idx_ii; -- 2.11.0