New Mod Doubts

Open-source port of PoP that runs natively on Windows, Linux, etc.
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: New Mod Doubts

Post by David »

Akruzen wrote: September 26th, 2021, 12:41 pm
David wrote: September 26th, 2021, 9:38 am This way all OGG files will override all music from DAT files.
(Should I add an INI option for this?)
Yes, that would be very helpful. Is there any similar way by which we can use the graphics of SDLPoP and not the custom mod's folder? That would be very helpful :)
Done both: https://github.com/NagyD/SDLPoP/commit/ ... 4e1cb5de47
dmitry_s
Developer
Developer
Posts: 148
Joined: July 27th, 2021, 7:22 am

Re: New Mod Doubts

Post by dmitry_s »

Akruzen wrote: September 26th, 2021, 12:41 pm Any idea how to set prince to a particular frame? I tried setting

Code: Select all

Kid.frame = frame_106_fall;
in a if statement but that doesn't affect prince at all. The rest of the code in that if statement works, so the statement is reachable.
The reason that does not work is because of the sequence table that drives the game. When prince is standing and no keys are pressed it keeps looping in a sequence that sets the standing frame and a corresponding action to the "Kid" variable. When you press an arrow key the pointer to the sequence table moves and now are you in the running sequence until the key is released and so on.

As David has mentioned, you can set the sequence that can last several frames. But it sounds to me like you really want to store the last few prince's moves.

Take a look at how the "do_auto_moves()" function works that is used to drive shadow on different levels as well as the initial demo at the end of credits when you start the game. The "replay.c" file does something very similar by allowing you to replay the entire level but I am not too familiar with that code.
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: New Mod Doubts

Post by David »

Akruzen wrote: September 26th, 2021, 12:56 pm Thank You for prompt reply David, however, I don't want to start any animation. I want prince to take a certain frame for 1 frame. That's why I tried putting the if statement in timers() function in seg003. Though the rest get's executed in the timer, prince doesn't change its frame for that particular moment. Any idea how to do this?
The kid's current frame is overridden by play_seq() in every frame.

In play_kid_frame(), put an if statement around the play_seq() call, with a condition that is false if your custom timer is active.
User avatar
Akruzen
Developer
Developer
Posts: 141
Joined: April 30th, 2016, 10:16 am

Re: New Mod Doubts

Post by Akruzen »

David wrote: September 26th, 2021, 5:47 pm The kid's current frame is overridden by play_seq() in every frame.
In play_kid_frame(), put an if statement around the play_seq() call, with a condition that is false if your custom timer is active.
Thank You David, that helped me to achieve the feature I wanted to add.

Is there any variable which holds the value of the room the potion is in? For example a special potion in room 8 of level 7 does a different action than default. To achieve that I added an if condition in the drinking function pickable object with conditions:

Code: Select all

if((current_level == 7) && (curr_room == 8))
However, since the potion is located at the end of the room prince can drink it other room too by crouching and pressing shift which then breaks the code. Is there any alternative for "curr_room"?

Also, where is the code that executes when a level starts? I want some values of variables to be reset when the level restarts (by dying, ctrl+a) and some other functions to be executed when the next level starts (either by ctrl+l or normally). But since there are multiple ways by which this can happen I have to write the same code at multiple locations. Any work-around for this?
What if life is a video game and Déjà Vu are just checkpoints?
dmitry_s
Developer
Developer
Posts: 148
Joined: July 27th, 2021, 7:22 am

Re: New Mod Doubts

Post by dmitry_s »

Akruzen wrote: October 6th, 2021, 6:47 pm Is there any variable which holds the value of the room the potion is in? For example a special potion in room 8 of level 7 does a different action than default. To achieve that I added an if condition in the drinking function pickable object with conditions:

Code: Select all

if((current_level == 7) && (curr_room == 8))
However, since the potion is located at the end of the room prince can drink it other room too by crouching and pressing shift which then breaks the code. Is there any alternative for "curr_room"?
"curr_room" is the correct variable but it gets changed any time the code is getting tile information. So here is what is probably happening.

1. prince picks up the potion, curr_room is valid
2. animation/sequence starts and moves prince into another room
3. tiles get drawn and the curr_room value changes
4. your code gets the wrong value

I think you need to define a new global variable and set it to "curr_room" in "proc_get_object" or "do_pickup" method.
Akruzen wrote: October 6th, 2021, 6:47 pm Also, where is the code that executes when a level starts? I want some values of variables to be reset when the level restarts (by dying, ctrl+a) and some other functions to be executed when the next level starts (either by ctrl+l or normally). But since there are multiple ways by which this can happen I have to write the same code at multiple locations. Any work-around for this?
Here is the code that restarts the level. The nested "else" statement on line 390 is executed when the next level starts.
https://github.com/NagyD/SDLPoP/blob/80 ... 003.c#L381
User avatar
Akruzen
Developer
Developer
Posts: 141
Joined: April 30th, 2016, 10:16 am

Re: New Mod Doubts

Post by Akruzen »

dmitry_s wrote: October 7th, 2021, 4:09 pm Here is the code that restarts the level. The nested "else" statement on line 390 is executed when the next level starts.
Thank You Dmitrys, that saved me a lot of lines. Could you also tell me how to copy a tile located at a particular room, column and row? I want to assign that tile elsewhere in the room. Basically I want to tell the compiler:

"See which tile is at Room 2, Column 4, Row 0 and place that tile to Room 1, Column 5 Row 0."

I tried to use

Code: Select all

curr_room_tiles[curr_tilepos] = tiles_0_empty;
but the problem with it is you always have to manually mention which tile should be placed on right hand side of the equal to sign. In my case, the RHS of the statement is to be decided dynamically (note that the room of the tile to copy is different than the room where it has to be pasted) depending on the type of tile at given room-col-row, since the tile to copy changes numerous times.

I also added your code in check_gate_push, but prince always seems to be able to pass from right to left (i.e. when he is facing right and gate is to left of prince). Your patch however solved the bug where Prince could go from left to right with drawn sword. Note that in this mod prince can draw sword anywhere and also doesn't sheathe the sword automatically.

Last but not the least, how can I shift the position of prince by one tile to the left? I don't want his animation to be interupted nor his y value. I tried Char.x -= 20; but that is not helping.
What if life is a video game and Déjà Vu are just checkpoints?
dmitry_s
Developer
Developer
Posts: 148
Joined: July 27th, 2021, 7:22 am

Re: New Mod Doubts

Post by dmitry_s »

Akruzen wrote: October 8th, 2021, 8:56 pm Thank You Dmitrys, that saved me a lot of lines. Could you also tell me how to copy a tile located at a particular room, column and row? I want to assign that tile elsewhere in the room. Basically I want to tell the compiler:

"See which tile is at Room 2, Column 4, Row 0 and place that tile to Room 1, Column 5 Row 0."

I tried to use

Code: Select all

curr_room_tiles[curr_tilepos] = tiles_0_empty;
but the problem with it is you always have to manually mention which tile should be placed on right hand side of the equal to sign. In my case, the RHS of the statement is to be decided dynamically (note that the room of the tile to copy is different than the room where it has to be pasted) depending on the type of tile at given room-col-row, since the tile to copy changes numerous times.
Here is how you can copy a tile.

Code: Select all

byte tile_1 = get_tile(/* tile_1_room, tile_1_col, tile_1_row */);
byte tile_1_modif = curr_room_modif[curr_tilepos];

get_tile(/* tile_2_room, tile_2_col, tile_2_row */);
curr_room_tiles[curr_tilepos] = tile_1;
curr_room_modif[curr_tilepos] = tile_1_modif;

// if tile2 room is the drawn_room
redraw_height = 63;
set_wipe(curr_tilepos, 1);
set_redraw_full(curr_tilepos, 1);
Akruzen wrote: October 8th, 2021, 8:56 pm I also added your code in check_gate_push, but prince always seems to be able to pass from right to left (i.e. when he is facing right and gate is to left of prince). Your patch however solved the bug where Prince could go from left to right with drawn sword. Note that in this mod prince can draw sword anywhere and also doesn't sheathe the sword automatically.
That does not seem to happen in my mod. You would have to debug what the curr_tile2/tile_col values are set to in check_gate_push. The issue here is the dx_weight() value is typically -13 in frames when the sword is drawn that puts the center of the the tile almost a full tile back from the center of the frame.

That also creates another problem where kid can fall through the floor while drawing the sword when there is an empty tile behind him even when the distance from it is pretty big (10+ pixels).
Akruzen wrote: October 8th, 2021, 8:56 pm Last but not the least, how can I shift the position of prince by one tile to the left? I don't want his animation to be interupted nor his y value. I tried Char.x -= 20; but that is not helping.
Each tile is 14 pixels wide. If you know the exact column number, do this:

Code: Select all

// there are 5 off-screen columns on each side of the room, 7 pixel offset puts prince in the middle of the tile
Kid.curr_col = /* col_number */;
Kid.x = x_bump[/* col_number */ + 5] + 7;
Or to move prince back 14 pixels you can do

Code: Select all

// assumes loadkid() was called earlier to assign Char to Kid
Char.x = char_dx_forward(-14); // a positive value would move him forward
determine_col();
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: New Mod Doubts

Post by David »

dmitry_s wrote: October 7th, 2021, 4:09 pm
Akruzen wrote: October 6th, 2021, 6:47 pm Also, where is the code that executes when a level starts? I want some values of variables to be reset when the level restarts (by dying, ctrl+a) and some other functions to be executed when the next level starts (either by ctrl+l or normally). But since there are multiple ways by which this can happen I have to write the same code at multiple locations. Any work-around for this?
Here is the code that restarts the level. The nested "else" statement on line 390 is executed when the next level starts.
https://github.com/NagyD/SDLPoP/blob/80 ... 003.c#L381
Existing variables are reset here: https://github.com/NagyD/SDLPoP/blob/80 ... c#L81-L105

You can use `if (level_number != current_level)` to see whether the player moved to the next level, or restarted the current level.
User avatar
Akruzen
Developer
Developer
Posts: 141
Joined: April 30th, 2016, 10:16 am

Re: New Mod Doubts

Post by Akruzen »

dmitry_s wrote: October 9th, 2021, 12:12 am
Akruzen wrote: October 8th, 2021, 8:56 pm Last but not the least, how can I shift the position of prince by one tile to the left? I don't want his animation to be interupted nor his y value. I tried Char.x -= 20; but that is not helping.
Each tile is 14 pixels wide. If you know the exact column number, do this:

Code: Select all

// there are 5 off-screen columns on each side of the room, 7 pixel offset puts prince in the middle of the tile
Kid.curr_col = /* col_number */;
Kid.x = x_bump[/* col_number */ + 5] + 7;
Or to move prince back 14 pixels you can do

Code: Select all

// assumes loadkid() was called earlier to assign Char to Kid
Char.x = char_dx_forward(-14); // a positive value would move him forward
determine_col();
Since I don't want Prince to be placed at a fixed column, I used the later code which moves prince to 14 pixels left. However it is not working. He stands where he is. Any idea why? I even called loadkid() in the previous line after some attempts just to be safe.
Also does copy tile copy the state of the door opened? For example, if the door is opening and it gets pasted in the room, does the door's portion of opened part also remain same? The code misbehaved when I tried to do it. Same goes with even pressure plates. I want them to retain the event they were assigned before pasting in the room.
What if life is a video game and Déjà Vu are just checkpoints?
dmitry_s
Developer
Developer
Posts: 148
Joined: July 27th, 2021, 7:22 am

Re: New Mod Doubts

Post by dmitry_s »

Try adding savekid() after the move.
dmitry_s
Developer
Developer
Posts: 148
Joined: July 27th, 2021, 7:22 am

Re: New Mod Doubts

Post by dmitry_s »

Akruzen wrote: October 9th, 2021, 8:16 pm Also does copy tile copy the state of the door opened? For example, if the door is opening and it gets pasted in the room, does the door's portion of opened part also remain same? The code misbehaved when I tried to do it. Same goes with even pressure plates. I want them to retain the event they were assigned before pasting in the room.
The modifier should copy the state of the plates. But events are trickier. So if a gate is opening/closing, you would have to trigger it.
User avatar
Akruzen
Developer
Developer
Posts: 141
Joined: April 30th, 2016, 10:16 am

Re: New Mod Doubts

Post by Akruzen »

dmitry_s wrote: October 9th, 2021, 8:41 pm Try adding savekid() after the move.
Thanks, adding that line helped. Do you know how to shift jaffar to a certain column too? Also even if I used

Code: Select all

seqtbl_offset_opp(102);
to make Jaffar do a hand rise, he just continues without executing anything. Any idea how to do that too?
What if life is a video game and Déjà Vu are just checkpoints?
dmitry_s
Developer
Developer
Posts: 148
Joined: July 27th, 2021, 7:22 am

Re: New Mod Doubts

Post by dmitry_s »

Akruzen wrote: October 12th, 2021, 5:05 pm Thanks, adding that line helped. Do you know how to shift jaffar to a certain column too? Also even if I used

Code: Select all

seqtbl_offset_opp(102);
to make Jaffar do a hand rise, he just continues without executing anything. Any idea how to do that too?
It would be very similar.

Code: Select all

loadshad();
Char.x = x_bump[5 + col_number] + 7;
Char.curr_col = col_number;
seqtbl_offset_char(102);
saveshad();
play_seq();
I am not sure about the 102 seq number. That value is only defined in the pre-game sequence and might not work in the game itself. I have not tried it.
User avatar
Akruzen
Developer
Developer
Posts: 141
Joined: April 30th, 2016, 10:16 am

Re: New Mod Doubts

Post by Akruzen »

Hello Everyone,

I have been working on this mod for quite a while now and now that it has been finally finished, I wish to release the beta version of the same. Kindly give your suggestions.

GitHub Link:
Prince of Persia - The Maharaja's Palace

Kindly compile the project and run it.

P.S. Please do not post any walkthrough videos until public version is released. Thank You!
Last edited by Akruzen on October 13th, 2021, 2:35 pm, edited 1 time in total.
What if life is a video game and Déjà Vu are just checkpoints?
User avatar
Akruzen
Developer
Developer
Posts: 141
Joined: April 30th, 2016, 10:16 am

Re: New Mod Doubts

Post by Akruzen »

dmitry_s wrote: October 9th, 2021, 12:12 am
That does not seem to happen in my mod. You would have to debug what the curr_tile2/tile_col values are set to in check_gate_push. The issue here is the dx_weight() value is typically -13 in frames when the sword is drawn that puts the center of the the tile almost a full tile back from the center of the frame.
Could you please help me fix it? I have posted the GitHub link in the previous post.
What if life is a video game and Déjà Vu are just checkpoints?
Post Reply