I think the issue is with the sword table values but I am not exactly sure how to fix it correctly to avoid side effects. This is a workaround that I put with a few coordinates I identified. It puts the sword 1 pixel to the left of where it should be but it still looks much better than the gap (see the second attachment).
Code: Select all
void fix_disappearing_sword_obj_x() {
// custom logic - prevent sword from disappearing at specific positions
// when the character is facing left near the edge of the room
if (Char.charid == charid_0_kid && Char.direction == dir_FF_left && obj_x == 19) {
--obj_x;
} else if (Char.charid == charid_0_kid && Char.direction == dir_FF_left && obj_x == 3) {
--obj_x;
// need to test it with skeletons
} else if (Char.charid == charid_2_guard && Char.direction == dir_FF_left && ABS(obj_x) == 4) {
--obj_x;
}
}
// seg006:1798
void __pascal far add_sword_to_objtable() {
short frame;
short sword_frame;
frame = Char.frame;
if ((frame >= frame_229_found_sword && frame < 238) || // found sword + put sword away
Char.sword != sword_0_sheathed ||
(Char.charid == charid_2_guard && Char.alive < 0)
) {
sword_frame = cur_frame.sword & 0x3F;
if (sword_frame) {
obj_id = sword_tbl[sword_frame].id;
if (obj_id != 0xFF) {
obj_x = calc_screen_x_coord(obj_x);
fix_disappearing_sword_obj_x(); // the fix function
obj_dx_forward(sword_tbl[sword_frame].x);
obj_y += sword_tbl[sword_frame].y;
obj_chtab = id_chtab_0_sword;
add_objtable(3); // sword
}
}
}
}