Guard falling through a wall

Open-source port of PoP that runs natively on Windows, Linux, etc.
Post Reply
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Guard falling through a wall

Post by dmitrys »

While working on changes where guard can follow kid down through rooms I encountered the following glitch. It can be seen in the video below around 2:16. When guard is in fight mode at a specific distance from a wall while getting hit by prince, he falls through the wall.

https://www.youtube.com/watch?v=3wrQ0hYgLFw&t=2m12s

I hope David or someone can give me some pointers how to fix it in SDLPoP. It seems to happen with all the existing fixes (including FIX_JUMP_THROUGH_WALL_ABOVE_GATE) enabled.
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Guard falling through a wall

Post by dmitrys »

It seems to happen in a fight when the of the characters (kid or guard) is between a wall and the opponent. At a very specific distance character starts to fall into the wall. The "in_wall()" function tries to push him out but the "delta_x" is too small so the character falls through to the floor below or into nothing. When that happens, the distance between character and opponent significantly increases most likely because the character starts to fall.

This code fixed my use case. But I am not sure if this is the best way to go about it.

Code: Select all

void __pascal far in_wall() {
	short delta_x;
	delta_x = distance_to_edge_weight();
	if (delta_x >= 8 || get_tile_infrontof_char() == tiles_20_wall) {
		delta_x = 6 - delta_x;
	} else {
		delta_x += 4;
	}
	// Increase delta_x when char and opp are 1 col apart
	if (Opp.alive < 0 &&
			Char.curr_row == Opp.curr_row &&
			ABS(Char.curr_col - Opp.curr_col) <= 1) {
		if (delta_x > 0) {
			delta_x += 2;
		} else if (delta_x < 0) {
			delta_x -= 2;
		}
	}
	Char.x = char_dx_forward(delta_x);
	load_fram_det_col();
	get_tile_at_char();
}
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Guard falling through a wall

Post by dmitrys »

And as I expected, my fix is too simplistic. It does not work in the scenario where kid bumps the wall while jumping on top of the guard.

I know that in this scenario guard ends up on column 10 (fallout). But even if I adjust the "ABS(Char.curr_col - Opp.curr_col)" condition the fix does not always work unless even with a large "delta_x".



The logic I have where guard follows kid down is pretty solid. But this type of bug, where guard (or kid) falls through walls when jumping into a guard's tile makes the gameplay unacceptable.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Guard falling through a wall

Post by atrueprincefanfrom18 »

dmitrys wrote: November 29th, 2020, 9:22 pm While working on changes where guard can follow kid down through rooms I encountered the following glitch. It can be seen in the video below around 2:16. When guard is in fight mode at a specific distance from a wall while getting hit by prince, he falls through the wall.

https://www.youtube.com/watch?v=3wrQ0hYgLFw&t=2m12s

I hope David or someone can give me some pointers how to fix it in SDLPoP. It seems to happen with all the existing fixes (including FIX_JUMP_THROUGH_WALL_ABOVE_GATE) enabled.
Yes, even I had encountered this, there's this bug even with the fix enabled.
Love to create new MODS :)

My complete list of mods until now!

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