OpenXcom Forum

OpenXcom => Open Feedback => Topic started by: NKF on September 12, 2017, 02:26:09 pm

Title: Pathing down the Skyranger ramp
Post by: NKF on September 12, 2017, 02:26:09 pm
More an observation than anything else, but when walking my troops straight down the Skyranger ramp, I'm finding they're jumping off the side before getting back on the path. In the vanilla game they would just walk down in a straight line.

To see what I mean, select a soldier inside the Skyranger and pick the first ground tile past the ramp. In fact you can be on the ramp and select the ground tile past the ramp to see this happen.

Is OpenXcom just following good old Dijkstra's shortest path and selecting the most optimal path to get to the destination? It looks awkward, but does seem to give you a 4 ~ 5 TU saving.
Title: Re: Pathing down the Skyranger ramp
Post by: Meridian on September 12, 2017, 03:41:08 pm
Dijkstra's algorithm is used to calculate all accessible/reachable tiles in OpenXcom.

For shortest path, OpenXcom tries to follow Bresenham's line first and if it fails it falls back to A* algorithm.

https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
https://en.wikipedia.org/wiki/A*_search_algorithm
Title: Re: Pathing down the Skyranger ramp
Post by: The Reaver of Darkness on September 13, 2017, 09:19:50 am
It's because of the time unit cost of walking down the tiles being set to 8. It's cheaper to take the 4 it costs to jump off the side, then spend 4 every further tile on the ground. It's literally cheaper to walk off the side and go around to get to the base of the ramp than it is to take a straight line path, and it's not even a small margin.


There's a similar bug in TFTD in which some corals cost as much as 16 time units to step on. Fortunately your soldiers will merely path around them if you don't command them to step on the corals.
Title: Re: Pathing down the Skyranger ramp
Post by: bulletdesigner on September 13, 2017, 03:12:00 pm
I never look into it as a bug, but than in real life it cost more to walk up and down a ramp , i even thougt it was pretty cleaver ! But i see all people complain and even release mod to nulify it
Title: Re: Pathing down the Skyranger ramp
Post by: Stoddard on September 13, 2017, 08:53:55 pm
It's in fact possible to mitigate that by modifying the tile TU cost with a value that depends on some combination of offset 0x30 values of both the floor and object MCDs of both the 'origin' and 'destination' tiles, so for example if origin's max(floor+0x30, object+0x30) is greater than destination's max(floor+0x30, object+0x30) TUs are subtracted from the movement cost and vice versa.

Basically, take height difference into account.

This effectively redefines the movement graph's edge costs making them differ depending on the direction of traversal.
This has no effect on the pathfinding algorithm used. Only the Pathfinding::getTUCost() in Pathfinding.cpp changes.