pull request #1024 - keep hero movement points
Pull request from saltwaterterrapin: record current move's pending movement points in save file. They were being thrown away during save and hero given 12 at time of restore. Hero had to have had at least 12 in order for player to issue the S command, but might have had more than that if able to move faster than normal speed. This implements it differently from the suggested commit. Add new field umovement to 'struct u' instead of using youmonst.movement and needing to save and restore that separately. Invalidates existing save and bones files. Closes #1024
This commit is contained in:
@@ -10,14 +10,15 @@
|
||||
|
||||
/* set up an individual monster's base type (initial creation, shapechange) */
|
||||
void
|
||||
set_mon_data(struct monst* mon, struct permonst* ptr)
|
||||
set_mon_data(struct monst *mon, struct permonst *ptr)
|
||||
{
|
||||
int new_speed, old_speed = mon->data ? mon->data->mmove : 0;
|
||||
short *movement_p = (mon == &gy.youmonst) ? &u.umovement : &mon->movement;
|
||||
|
||||
mon->data = ptr;
|
||||
mon->mnum = (short) monsndx(ptr);
|
||||
|
||||
if (mon->movement) { /* used to adjust poly'd hero as well as monsters */
|
||||
if (*movement_p) { /* used to adjust poly'd hero as well as monsters */
|
||||
new_speed = ptr->mmove;
|
||||
/* prorate unused movement if new form is slower so that
|
||||
it doesn't get extra moves leftover from previous form;
|
||||
@@ -28,9 +29,9 @@ set_mon_data(struct monst* mon, struct permonst* ptr)
|
||||
mon->movement = new_speed * mon->movement / old_speed;
|
||||
* so add a redundant test to suppress that.
|
||||
*/
|
||||
mon->movement *= new_speed;
|
||||
*movement_p *= new_speed;
|
||||
if (old_speed > 0) /* old > new and new >= 0, so always True */
|
||||
mon->movement /= old_speed;
|
||||
*movement_p /= old_speed;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user