Skwizzy / SPT-LootingBots

AI Looting mod for Singleplayer Tarkov
https://hub.sp-tarkov.com/files/file/1096-looting-bots/#overview
29 stars 11 forks source link

Bots sometimes run extremely large distances to loot an item that is detected nearby #90

Closed Skwizzy closed 7 months ago

Skwizzy commented 9 months ago

Summary from DanW:

It looks like the bots search for loot by checking if it's within a certain radius to them. However, there are cases where the distance to the loot might be within your threshold, but the path the bot must take is super long. For example, if the bot finds loot on the first floor of the mall in Interchange but it's in the parking garage, it will run very far to get it.

What are your thoughts about "validating" the loot identified by the bot by ensuring the length of the path to it doesn't exceed some threshold (i.e. 2-3X the search distance)? You should be able to check it by doing something like this after telling the bot to start moving:

Vector3? lastPathPoint = BotOwner.Mover?.CurPathLastPoint;
float? pathLength = BotOwner.Mover?.ComputePathLengthToPoint(lastPathPoint.Value);
Skwizzy commented 8 months ago

With the suggestion from Dan W I have changed the logic for how the distance of loot is calculated. Previously, the actual destination the bot would move to was calculated in a separate logic layer than the FindLootLogic. I have moved this logic to the FindLootLogic layer so than now when a collider has been detected within the scanning range, we calculate the position the bot will move to and save it in the LootingBrain. Using this position, we can calculate the distance of the path the bot will take to reach the item. This length must be less than the detection radius for the item to be considered lootable

Changes found here: 473ed41