Decane / SRP

Sky Reclamation Project for S.T.A.L.K.E.R.: Clear Sky
http://www.moddb.com/mods/srp
131 stars 21 forks source link

Too long NPC path going from Freedom Base to Swamp antennas #73

Closed SurDno closed 5 years ago

SurDno commented 6 years ago

Red line is how every squad going from Freedom base to Swamp antennas walk. Green is the shortest path, but Freedom squads always choose to go this way.

image

Decane commented 5 years ago

Not a bug, despite how unintuitive it might seem. Smart terrains in CS are linked to other, adjacent smart terrains in all.spawn via the targets field. And squads in CS can, by design, only travel through a path that cuts through so-linked adjacent smart terrains. The path you are witnessing squads travel is:

Gulp of Freedom Bar   -> Small old wagon       -> Stop                  -> Swamp camp
val_smart_terrain_7_5 -> val_smart_terrain_9_6 -> val_smart_terrain_8_7 -> val_smart_terrain_7_8

The path you think they should take instead:

Gulp of Freedom Bar   -> Stop                  -> Swamp camp
val_smart_terrain_7_5 -> val_smart_terrain_8_7 -> val_smart_terrain_7_8

Now let's inspect the targets for the Gulp of Freedom Bar in all.spawn: "val_smart_terrain_7_4, val_smart_terrain_7_3, val_smart_terrain_9_4, val_smart_terrain_9_2, val_smart_terrain_8_6".

As you can see, the "Stop" (val_smart_terrain_8_7) is missing from the list. That means the game doesn't consider it adjacent to the Gulp of Freedom Bar. Hence squads must travel to it via some other camp that is adjacent to the Gulp of Freedom Bar.

You're probably thinking we should add the "Stop" to the list of targets for the Gulp of Freedom Bar. The trouble is, if we do that, squads will sometimes move from the Gulp of Freedom Bar to the Factory Lobby like this:

Gulp of Freedom Bar   -> Stop                  -> Small old wagon       -> Factory lobby
val_smart_terrain_7_5 -> val_smart_terrain_8_7 -> val_smart_terrain_9_6 -> val_smart_terrain_1_2

... which would involve an even more awkward detour.

There's probably an optimization problem in here somewhere, but the bottom line is that CS's squad path-finding is necessarily somewhat crude due to the design of the faction wars combined with the limited number of smart terrains in the game. And adding more smart terrains is beyond the scope of the SRP.

SurDno commented 5 years ago

Interesting, thanks.