Why QuickSave Not Available in Float State?

Open-source port of PoP that runs natively on Windows, Linux, etc.
Post Reply
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Why QuickSave Not Available in Float State?

Post by atrueprincefanfrom18 »

Hello, just curious to know why QuickSave is not available in Float State? When you drink a potion (which allows you to feather fall), you cannot quicksave. You get a message "NO QUICKSAVE". Is the development in progress or we cannot see quicksave option to work during feather fall?
Thank you!
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Why QuickSave Not Available in Float State?

Post by David »

atrueprincefanfrom18 wrote: February 10th, 2020, 2:10 pm Hello, just curious to know why QuickSave is not available in Float State? When you drink a potion (which allows you to feather fall), you cannot quicksave. You get a message "NO QUICKSAVE". Is the development in progress or we cannot see quicksave option to work during feather fall?
Thank you!
This was added here by Falcury.
Deny quicksave during the feather fall effect
The description does not say why, but I have a guess:
The feather fall effect lasts as long as its music.
When the user saves a state while feather fall is active, and then loads it back, the game would need to continue the music from the point where it was when the state was saved.
Falcury probably found that impossible or too hard.

@Falcury, is my guess correct?
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Why QuickSave Not Available in Float State?

Post by atrueprincefanfrom18 »

Oh, Hmm... Interesting!
Thank you! :)
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Why QuickSave Not Available in Float State?

Post by Falcury »

David wrote: February 15th, 2020, 5:08 pm @Falcury, is my guess correct?
Yes, that's correct!
I didn't see an easy solution to the problem you described, back when I wrote that code...
Thinking about it now, I guess the way to do it is to store two additional variables in the game state, one for which sound is currently playing, and another for the current play position. Then, when restoring the game state, the same sound could be played again and fastforwarded to the correct position.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Why QuickSave Not Available in Float State?

Post by atrueprincefanfrom18 »

Falcury wrote: February 17th, 2020, 9:50 pm Yes, that's correct!
I didn't see an easy solution to the problem you described, back when I wrote that code...
Thinking about it now, I guess the way to do it is to store two additional variables in the game state, one for which sound is currently playing, and another for the current play position. Then, when restoring the game state, the same sound could be played again and fastforwarded to the correct position.
Another improvement suggestion I can think, is to add a feature to show how many seconds the feather fall is going to last from now... You can maybe display it the same way you display when 't' is pressed, so maybe 'f' letter in this case.

Can we see this feature some day?

Thanks!
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Why QuickSave Not Available in Float State?

Post by dmitrys »

I came up with a solution to this problem. I changed the boolean feather fall variable into a timer. The sound lasts about 18.7 seconds before it starts repeating if you loop it so I set to to 19 seconds (with a slight padding). Maybe it was meant to be 20 seconds but I wanted the feather mode to stop right after the music stops.

This allowed me to solve 2 problems. The quicksave/quickload now works well in the feather fall mode. Also, the timer can be paused if you pause the game. The music stops when the menu opens. Once the menu is closed the sound is restarted in the position of the total music length minus the timer value. In the PC speaker mode the sound starts over and stops when the timer is up. So no more cheating with the feather fall mode using the pause functionality. :)

Another benefit is when the OGG file is used to play the music (I am using Roland digital sounds), you can hear other game sounds while the feather fall music is playing.

There is one (small imo and solvable) problem. The game plays at different speeds between in combat vs non-combat mode. In combat mode the game timer length (this is a different type of timer than the feather fall one) is 6 with the base frequency of 60, which means 10 FPS or 10 ticks per second. In non-combat mode the game timer length is 5 which is 12 ticks per second. That means if you switch between combat and non-combat modes after the music starts playing the timer can take more or less time compared to the actual music length.

If the remaining timer is shorter than the music length, the sound just stops earlier. I do not see that being a problem as you should not be able to activate feather mode while fighting unless you are cheating. If the remaining timer is longer than the music length (because you started to fight a guard after drinking the potion) the sound either starts playing over (PC speaker) or starts from the remaining timer position (digital) until the timer is up. The later is barely noticeable because music kind of repeats itself already but the feather mode can last a few seconds longer.

In my mod kid also slows down by 1 timer length when he has 1 hit point left. But I do not see it much of a problem as you cannot really take advantage of a longer feather mode time while fighting a guard. And it should be possible to recalculate feather fall remaining timer value when switching the game timer length. But that is a task for another day.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Why QuickSave Not Available in Float State?

Post by atrueprincefanfrom18 »

Nice! You might want to send a pull request to SDLPoP?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Why QuickSave Not Available in Float State?

Post by dmitrys »

Recalculation of ticks after changing the timer length works well.

I am not sure if it is a good idea to change SDLPoP behavior as it tries to be fully DOS compatible.

It should be possible to add simplified logic behind a flag that would change the `is_feather_full` variable into a timer when enabled. It would not allow pausing the feather fall (without making significant changes to the digi sound code) but quicksave/quickload should still work. If you turn off sound during the feather flight then turn it back, on the feather fall music would not restart. Also, replacing the feather fall music file would not change the feather fall length. If there is an interest in this change, I can create a PR.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Why QuickSave Not Available in Float State?

Post by atrueprincefanfrom18 »

No, I think there should be an option saying ALLOW_QUICKSAVE_IN_FLOAT_STATE or something, and if it's enabled, then that new code will apply?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Why QuickSave Not Available in Float State?

Post by dmitrys »

Then there could be a scenario where you load a quick save the middle of float state without having that option enabled. I guess the feather fall flag can be disabled in that case in the `restore_room_after_quick_load` method and kid would fall to his death.

I am going to try to do this weekend or next week.
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Why QuickSave Not Available in Float State?

Post by dmitrys »

Post Reply