From: PatR Date: Tue, 26 Jan 2016 02:18:35 +0000 (-0800) Subject: fix part of #H2343 - youmonst.movement vs poly X-Git-Tag: NetHack-3.6.1_RC01~983 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=489445da02909f8d950f0406a57c37c2fa2c6744;p=nethack fix part of #H2343 - youmonst.movement vs poly From a July 2011 report listing multiple movement anomalies, fix one of the easier ones. If you polymorph from a fast from into a slow one, pending movement points can let the slow form get in some moves it shouldn't. I've deliberately avoided adjusting pending movement when you change into a faster form, which will get it's own movement boost on the next turn. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 1fe963394..d7ce1b127 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -125,6 +125,7 @@ if a chameleon took vampire form, it would stop periodically changing shape corpses obtained from tipping an ice box wouldn't rot away suppress "you climb up the stairs" message if verbose option is off physical damage from mind flayer attack was being inflicted twice +adjust pending movement points when polymorphing into a slower creature Platform- and/or Interface-Specific Fixes diff --git a/src/mondata.c b/src/mondata.c index 9fb2491d5..97bee8ae1 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -13,6 +13,8 @@ struct monst *mon; struct permonst *ptr; int flag; { + int new_speed, old_speed = mon->data ? mon->data->mmove : 0; + mon->data = ptr; if (flag == -1) return; /* "don't care" */ @@ -21,6 +23,15 @@ int flag; mon->mintrinsics |= (ptr->mresists & 0x00FF); else mon->mintrinsics = (ptr->mresists & 0x00FF); + + if (mon->movement) { /* same adjustment as poly'd hero undergoes */ + new_speed = ptr->mmove; + /* prorate unused movement if new form is slower so that + it doesn't get extra moves leftover from previous form; + if new form is faster, leave unused movement as is */ + if (new_speed < old_speed) + mon->movement = new_speed * mon->movement / old_speed; + } return; } diff --git a/src/polyself.c b/src/polyself.c index 68936af8d..9c03e5b8d 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -42,6 +42,7 @@ void set_uasmon() { struct permonst *mdat = &mons[u.umonnum]; + int new_speed, old_speed = youmonst.data ? youmonst.data->mmove : 0; set_mon_data(&youmonst, mdat, 0); @@ -92,16 +93,23 @@ set_uasmon() PROPSET(PASSES_WALLS, passes_walls(mdat)); PROPSET(REGENERATION, regenerates(mdat)); PROPSET(REFLECTING, (mdat == &mons[PM_SILVER_DRAGON])); +#undef PROPSET float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ + polysense(); -#undef PROPSET + if (youmonst.movement) { + new_speed = mdat->mmove; + /* prorate unused movement if new form is slower so that + it doesn't get extra moves leftover from previous form; + if new form is faster, leave unused movement as is */ + if (new_speed < old_speed) + youmonst.movement = new_speed * youmonst.movement / old_speed; + } #ifdef STATUS_VIA_WINDOWPORT status_initialize(REASSESS_ONLY); #endif - - polysense(); } /* Levitation overrides Flying; set or clear BFlying|I_SPECIAL */