Home » MODDING HQ 1.13 » v1.13 Coding Talk » Roof climbing problem in 1.13
Roof climbing problem in 1.13[message #344502] Sun, 13 March 2016 10:44 Go to previous message
Deleted.

 
Messages:2656
Registered:December 2012
Location: Russian Federation
1. In 1.13, roof climbing used ASTAR.
2. At some moment, ASTAR was disabled.
3. As a result, roof climbing is partially broken now.
4. As solution, all functions that use ASTAR should be reverted to vanilla state.

For example, FindClosestClimbPoint in FindLocations.cpp:
// 0verhaul:  This function is optimized to take advantage of the new climb point info.

if (gpWorldLevelData[ sGridNo].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT)


MAPELEMENT_EXT_CLIMBPOINT is set in void AStarPathfinder::ExecuteAStarLogic(), which is disabled.

So, all functions that use MAPELEMENT_EXT_CLIMBPOINT should be reverted to vanilla state:
FindClosestClimbPoint, FindDirectionForClimbing

Another problem:
in GenerateBuilding (Buildings.cpp), the following code is used:
if ( !(gpWorldLevelData[ sCurrGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) )
		{
			gpWorldLevelData[ sCurrGridNo ].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED;

			gubBuildingInfo[ sCurrGridNo ] = ubBuildingID;

			// consider this location as possible climb gridno
			// there must be a regular wall adjacent to this for us to consider it a
			// climb gridno

What is interesting is
gubBuildingInfo[ sCurrGridNo ] = ubBuildingID;

which sets building information for the tile that is outside of the building. As a result, all tiles adjacent to building are set as they belong to that building, as a result, SameBuilding returns TRUE when first gridno is inside building and second gridno is outside of the building.
There's no such code in vanilla source, this looks like some old 1.13 bug.

Another problem:
when AI tries to find a path to a disturbance on different level, it first searches for a closest climb point.
Then, if the climbing point is found, it tries to estimate path cost to climb point, at which moment it fails if the soldier is already standing at the climb point, because EstimatePathCostToLocation returns 0.
This means that if AI was moving to climb and reached the climb point, next turn instead of climbing he moves to another climb point or simply decides taking cover or something else, because his seacrh for closest disturbance call fails.

--------------------------------------------------------------------------------------------------------------

My solution to some probems, implemented and tested in ja2+ai:

in Buildings.cpp/FindClosestClimbPoint:
allow climbing from the spot where soldier stands:
Toggle Spoiler


In AIUtils.cpp/EstimatePathCostToLocation:
don't return 0 if soldier is standing at climb point:
Toggle Spoiler


FindLocations.cpp/FindClosestClimbPoint: new calculation using FindHeigherLevel
Toggle Spoiler


FindLocations.cpp/FindDirectionForClimbing: new calculation using FindHeigherLevel/FindLowerLevel
Toggle Spoiler


Hope that helps.

[Updated on: Sun, 13 March 2016 10:47]




Left this community.

Report message to a moderator

Lieutenant

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Path finding problems in 1.13
Next Topic: Item choices
Goto Forum:
  


Current Time: Wed Feb 19 01:41:05 GMT+2 2025

Total time taken to generate the page: 0.00665 seconds