Re: New Mod Doubts
Posted: September 26th, 2021, 5:34 pm
Done both: https://github.com/NagyD/SDLPoP/commit/ ... 4e1cb5de47
Done both: https://github.com/NagyD/SDLPoP/commit/ ... 4e1cb5de47
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.Akruzen wrote: ↑September 26th, 2021, 12:41 pm Any idea how to set prince to a particular frame? I tried settingin 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.Code: Select all
Kid.frame = frame_106_fall;
The kid's current frame is overridden by play_seq() in every frame.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?
Thank You David, that helped me to achieve the feature I wanted to add.
Code: Select all
if((current_level == 7) && (curr_room == 8))
"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.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: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"?Code: Select all
if((current_level == 7) && (curr_room == 8))
Here is the code that restarts the level. The nested "else" statement on line 390 is executed when the next level starts.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?
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:
Code: Select all
curr_room_tiles[curr_tilepos] = tiles_0_empty;
Here is how you can copy a tile.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 usebut 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.Code: Select all
curr_room_tiles[curr_tilepos] = tiles_0_empty;
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);
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.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.
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;
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();
Existing variables are reset here: https://github.com/NagyD/SDLPoP/blob/80 ... c#L81-L105dmitry_s wrote: ↑October 7th, 2021, 4:09 pmHere is the code that restarts the level. The nested "else" statement on line 390 is executed when the next level starts.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?
https://github.com/NagyD/SDLPoP/blob/80 ... 003.c#L381
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.dmitry_s wrote: ↑October 9th, 2021, 12:12 amEach tile is 14 pixels wide. If you know the exact column number, do this:
Or to move prince back 14 pixels you can doCode: 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;
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();
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.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.
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);
It would be very similar.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 usedto make Jaffar do a hand rise, he just continues without executing anything. Any idea how to do that too?Code: Select all
seqtbl_offset_opp(102);
Code: Select all
loadshad();
Char.x = x_bump[5 + col_number] + 7;
Char.curr_col = col_number;
seqtbl_offset_char(102);
saveshad();
play_seq();
Could you please help me fix it? I have posted the GitHub link in the previous post.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.