]> granicus.if.org Git - nethack/commitdiff
fix part of #H2343 - youmonst.movement vs poly
authorPatR <rankin@nethack.org>
Tue, 26 Jan 2016 02:18:35 +0000 (18:18 -0800)
committerPatR <rankin@nethack.org>
Tue, 26 Jan 2016 02:18:35 +0000 (18:18 -0800)
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.

doc/fixes36.1
src/mondata.c
src/polyself.c

index 1fe9633945eea6af7fcb6c8ec3f0f0a2fab2e874..d7ce1b127789b4bb45345c3f2311f41986e84196 100644 (file)
@@ -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
index 9fb2491d5348a9a74f885f095b87c5d82ea9702d..97bee8ae19e9cb3235d63ccc6540f1d0d1b49e17 100644 (file)
@@ -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;
 }
 
index 68936af8d0aea0a36cfd721b267b86aa3863347c..9c03e5b8ddd1cf898d4e49d623ae62dab02d854c 100644 (file)
@@ -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 */