Buttons get stuck if you merge the shadow on them

Discuss PoP1 for DOS here.
Post Reply
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Buttons get stuck if you merge the shadow on them

Post by atrueprincefanfrom18 »

Ok, so I experiment with the shadow a lot and found out a trick...

If you merge on a tile, wait there for the flashing to finish and (strangely!) the music to finish, the tile (uh, well, sometimes) behaves the same way as if the guard is killed on it. Didn't understand or want to know more? Check this out:



It is I think easy to do when there are no loose tiles in between when reaching towards the shadow... But there is somehow problem when there are loose tiles in between... Now check this one... I just succeeded only once in doing mentioned above...



I don't know how sometimes it works, sometimes it doesn't...

Norbert, David, Falcury, SuavePrince, prince777, YURA anyone expert here want to help?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: Magic Of Persia - New MOD

Post by Norbert »

atrueprincefanfrom18 wrote: February 28th, 2020, 7:24 pmIf you merge on a tile, wait there for the flashing to finish and (strangely!) the music to finish, the tile (uh, well, sometimes) behaves the same way as if the guard is killed on it.
Interesting, thanks.
I'll add a note about this under trick 31 torromow.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Magic Of Persia - New MOD

Post by atrueprincefanfrom18 »

Norbert wrote: February 28th, 2020, 9:25 pm Interesting, thanks.
I'll add a note about this under trick 31 torromow.
Maybe another trick would be good? I don't really know why, but I feel that there are more tricks to be found with shadow and other elements and even other special events of the game (like shadow drinking a health potion on Level 5, something related with that, etc.)... So even a seperate page is best, I suppose... Because as of now, no special event tricks, (like the shadow merging) are discovered a lot...

But anyway, what feels best to you, put it up there! :)

Thanks!
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Magic Of Persia - New MOD

Post by atrueprincefanfrom18 »

prince777 wrote: February 28th, 2020, 9:36 pm An interesting trick. Can be used on mod :idea: ;)
Yes, but I don't really know, it sometime works, sometimes doesn't...

If someone can get a document ready stating why it works and a complete, proper way how to do it, it would be awesome.

I'll experiment more today...
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: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Magic Of Persia - New MOD

Post by David »

atrueprincefanfrom18 wrote: February 28th, 2020, 7:24 pm If you merge on a tile, wait there for the flashing to finish and (strangely!) the music to finish, the tile (uh, well, sometimes) behaves the same way as if the guard is killed on it.
Try this: In the shadow's room, fill the top row with buttons. Make sure you use a different event number for each button.
Then play the level and merge with the shadow on this button-"carpet". One button will always be stuck. So you don't even have to wait for anything to finish.

If you merge the shadow using a standing jump, the shadow won't move at all.
If you try this, you'll see that the stuck tile is the same which the shadow was holding down right before the merge. (see attached shadow_stuck_tile.p1r)
If he was standing on the edge between two tiles then, for some reason, the tile on the left will get stuck. (see attached shadow_stuck_tile_edge.p1r)
shadow_stuck_tile.p1r
(3.12 KiB) Downloaded 128 times
shadow_stuck_tile_edge.p1r
(3.12 KiB) Downloaded 135 times

Now, why does this happen?
Luckily the bug occurs in SDLPoP as well, so we can look for the answer in its source.

When a button is pressed, the game checks whether the character who pressed the button is alive or not.
Here: https://github.com/NagyD/SDLPoP/blob/ma ... 06.c#L1526
If the character is alive (Char.alive < 0) then the button will be triggered regularly.
But if the character is dead then the button will be triggered permanently. (died_on_button())
So the game thinks that the shadow is dead, but why?

When the prince and the shadow merge, the game puts the prince into the shadow's place, and clears the shadow.
Here: https://github.com/NagyD/SDLPoP/blob/ma ... 02.c#L1187
Clearing a character will mark them as dead (Char.alive = 0).
Here: https://github.com/NagyD/SDLPoP/blob/ma ... 06.c#L1764

Clearing also marks the character as not present (Char.direction = dir_56_none).
Normally, non-present opponents would be ignored: https://github.com/NagyD/SDLPoP/blob/ma ... 00.c#L1158
However, the shadow is cleared *after* the game checked whether there is an opponent.
And the pressed tile is checked after clearing the character, but before re-checking the character's presence, within the same invocation of play_guard_frame().
Namely:
Merging: play_guard_frame -> play_guard -> autocontrol_opponent -> autocontrol_shadow -> autocontrol_shadow_level12 -> clear_char
Pressed: play_guard_frame -> check_press -> died_on_button

There is a further condition between the calls to play_guard() and check_press(): if (Char.room == drawn_room).
But it stays true in this case, because clear_char() doesn't clear Char.room.
However, if I add the line "Char.room = 0;" to clear_char() then no tiles will get stuck when merging the shadow.


So to summarize: When you merge the shadow, the shadow disappears, and the game thinks for a moment that the shadow died where he was last seen.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: Magic Of Persia - New MOD

Post by Norbert »

David wrote: February 29th, 2020, 8:52 pmWhen a button is pressed, the game checks whether the character who pressed the button is alive or not. [...If] the character is dead then the button will be triggered permanently. (died_on_button())
I'm curious why this feature is even in the original game...
Unless I'm mistaken, I don't think it's ever a requirement to kill an enemy on a button.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Magic Of Persia - New MOD

Post by atrueprincefanfrom18 »

David wrote: February 29th, 2020, 8:52 pm So to summarize: When you merge the shadow, the shadow disappears, and the game thinks for a moment that the shadow died where he was last seen.
Thanks David for your reply to this.

Yes, I got the summary well before I uploaded the test videos, but the main question is this:
How should we perfectly merge with the shadow in order to make the system think that the shadow died on the button and it would keep it pressed throughout the level?

If you can check the videos I posted here then you can see that in the first video, it's quite easy to merge because you have no tiles falling. In the second video, I could succeed only once and other times I failed a lot (not all failed plays are in the video) (Let's ignore that there is a "button carpet" on which the kid is merging. I am talking only in cases where there is just a single or maybe two button tiles and we have to keep one pressed continuously to complete the level, if that's the case how can we complete it?).

So, even if the summary looks what we think, why in the videos I posted the tile was not pressed? Is there something I did the wrong way? Also, if there is a single button tile in a row and you merge you have to wait till the music is finished as well... (I didn't studied the source code a lot, but I am thinking that there might a boolean which decides whether or not the tile should be held continuously, changes it's value if you move while the flashing and music is playing).

Just play yourself in DOSBox. Because if there is a bug in original game, it's a lot likely to be in SDLPoP. Am I right?

I'll try experimenting more today...

It doesn't seem much easy to figure out what's going on.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Magic Of Persia - New MOD

Post by atrueprincefanfrom18 »

Norbert wrote: February 29th, 2020, 10:53 pm
David wrote: February 29th, 2020, 8:52 pmWhen a button is pressed, the game checks whether the character who pressed the button is alive or not. [...If] the character is dead then the button will be triggered permanently. (died_on_button())
I'm curious why this feature is even in the original game...
Unless I'm mistaken, I don't think it's ever a requirement to kill an enemy on a button.
Well, I think Mechner is a person of perfectising things... I can see and learn from his videos that he likes to keep it simple and very real-world logic. Meaning, the gravity, properties of real world, like spikes hurt you, you can't go through the gates unless they are opened, you can't run with sword in hand, you can't keep clinging on for ages unless you are still (otherwise after 4 seconds you would fall down), etc. are very neatly implemented in the game, so this one also got included with that.

Or, maybe you needed the guard to interact with tiles on Level 8? (After all mouse is treated as a guard technically and helps you open the gate, with just a special event that it would go back). Another is on Level 6, where the shadow forces you to drop down into dungeons.

That's what I think...

David what do you think about this?
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: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Magic Of Persia - New MOD

Post by David »

atrueprincefanfrom18 wrote: March 1st, 2020, 8:15 am If you can check the videos I posted here then you can see that in the first video, it's quite easy to merge because you have no tiles falling. In the second video, I could succeed only once and other times I failed a lot (not all failed plays are in the video) (Let's ignore that there is a "button carpet" on which the kid is merging. I am talking only in cases where there is just a single or maybe two button tiles and we have to keep one pressed continuously to complete the level, if that's the case how can we complete it?).
In the second video, the shadow is turned left.
In this case, for some reason, the tile which gets stuck is sometimes not where the shadow is standing, but the tile on its left.
But not always.

So you should try the same thing with the button moved one tile to the left.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Magic Of Persia - New MOD

Post by atrueprincefanfrom18 »

David wrote: March 7th, 2020, 8:46 pm So you should try the same thing with the button moved one tile to the left.
Excellent! I now have got how it works. David, You were right. The tile on the left gets stuck. And yes, no need to wait for the music to finish!

I analysed the two videos I created and also tried new things and came to this conclusion. It's always possible to do the trick. There are two conditions you have to meet when you merge:

1. A tile has three parts: Left, Center and Right. What you should do is merge on the right-most side of the tile which you want to keep held (pressed).
2. Keep approximate two tiles distance between the Kid and the Shadow (you may need to try again with different distance).

Just check the p1r files (SDLPoP, of course!):

gotit2.p1r
(3.4 KiB) Downloaded 162 times
gotit1.p1r
(3.4 KiB) Downloaded 134 times

Also the YouTube videos (DOSBox):




Anything else, anyone want to mention?

Also, please check this...

Norbert, Falcury, can the shadow discussion from this topic be moved to a different topic?

Thanks!
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: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Magic Of Persia - New MOD

Post by David »

atrueprincefanfrom18 wrote: March 12th, 2020, 3:49 pm Norbert, Falcury, can the shadow discussion from this topic be moved to a different topic?
Done.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Magic Of Persia - New MOD

Post by atrueprincefanfrom18 »

David wrote: March 14th, 2020, 9:58 am
atrueprincefanfrom18 wrote: March 12th, 2020, 3:49 pm Norbert, Falcury, can the shadow discussion from this topic be moved to a different topic?
Done.
Thanks! :)
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
Post Reply