Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCI32: Fix QFG4 forest pathfinding #1473

Merged
merged 1 commit into from Jan 6, 2019
Merged

Conversation

Vhati
Copy link
Contributor

@Vhati Vhati commented Jan 4, 2019

Adds workarounds for odd detours during entry

#10857 - Script patch

// When entering forest room 557 from the east (563), hero is supposed to move
// only a short distance into the room. ScummVM's pathfinding sends hero off
// course, to the middle of the room and back.
//
// There's an unwalkable stream in the SE corner, and hero's coords were within
// its polygon. We lower the top two points to keep hero on the outside.

Side note: Hand decompiled code for the forest::init() is attached there, in case in case anyone is curious about random encounters and pre-combat setup. It's shared across all the forest rooms.

 

#10858 - AStar() workaround

ScummVM's pathfinding has a penalty that discourages travel to vertices on a screen edge.
QFG1VGA already had a boolean to exempt one room.
I reformatted it in a way that can add additional rooms.

// WORKAROUND: This check is needed in SCI1.1 games, such as LB2. Until our
// algorithm matches better what SSCI is doing, we exempt certain rooms where
// the check fails.
bool penaltyWorkaround =
	// QFG1VGA room 81 - Hero gets stuck when walking to the SE corner (bug #6140).
	(g_sci->getGameId() == GID_QFG1VGA && g_sci->getEngineState()->currentRoomNumber() == 81) ||
#ifdef ENABLE_SCI32
	// QFG4 room 563 - Hero zig-zags into the room (bug #10858).
	// Entering from the south (564) off-screen behind an obstacle, hero
	// fails to turn at a point on the screen edge, passes the poly's corner,
	// then approaches the destination from deeper in the room.
	(g_sci->getGameId() == GID_QFG4 && g_sci->getEngineState()->currentRoomNumber() == 563) ||
#endif
	false;

if (s->pointOnScreenBorder(vertex->v) && !penaltyWorkaround)
	new_dist += 10000;

 

Both tickets have images of the polygons and hero's start/end coords.

Adds workarounds for odd detours during entry, bugs #10857, #10858
@bluegr
Copy link
Member

bluegr commented Jan 6, 2019

Nice work, thanks!

Merging

@bluegr bluegr merged commit aac5ed1 into scummvm:master Jan 6, 2019
@Vhati Vhati deleted the qfg4_forest branch January 7, 2019 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants