DrakiaXYZ / SPT-LootRadius

Loot loose items in a radius, instead of needing to pinpoint every little item
MIT License
1 stars 2 forks source link

[ Bug, not sure is fixable ] Distance is ignored sometimes if items is outside surface #2

Closed 6562680 closed 2 hours ago

6562680 commented 10 hours ago

I have a 3.5m loot radius in my SPT build and it's usually enough to loot corpses (drop their weapons/gear on the ground to examine/disassemble parts with a delay or no backpack space).

Also the plugin is very useful for finding quest items, like a "search radar".

There is a problem... if an item is on a table for example, sometimes it happens that opening the backpack doesn't give any items on the outside, but I actually see the item right in front of me.

Maybe the height of the surfaces can be manually rescanned, or if that's not possible, maybe the GUI can be updated with a simple update of the numbers that change at runtime to see how many items are near me at the moment, this will help debug why some items on the table are showing up and some are missing...

If you use "grenade scanning logic" to scan objects in a radius, maybe the sphere should spawn at the player's face instead of under their feet?

DrakiaXYZ commented 10 hours ago

The radius is from 0.5m above your feet, but there is a raycast check from your head to verify that you can physically see the object. There's not much I can do to improve this while not also enabling people to loot things through physical objects. This isn't something I plan to put time into trying to fix, as the mod works well enough even though sometimes it misses an item here or there

6562680 commented 10 hours ago

Maybe create two radiuses... one is above the feet, and one at the viewpoint (the "laser dot")... but it can't really scan anything that way, only two surfaces...

Do the objects have coordinates? Maybe just walk the array of coordinates, then calculate the distance to the objects using, maybe... an idea!

  1. At the beginning of the raid, ONCE, calculate the distance from the player (or, better, from map center) and the angle to each item for all items (into an array)
  2. Sort items by distance, rounding the distance to 10 (divide by 10, round, multiply by 10: 133 -> 130, 147 -> 140)
  3. Every 10 meters, sort items by degree, rounding to 5 (divide by 5, then mathematically round)
  4. Then, every 10 meters and, at same time, every 5 degrees (thats why we sort items before), randomly (or just pick the first) select one or more items to get their coordinates, save these coordinates (primary coordinates)
  5. As soon as the player presses the "inventory" key, we iterate over primary items to find the closest primary coordinates. And now we have access to related items of this "primary" item ("this siblings" or "this group")
  6. Run a distance check only for related items and the primary item. If the primary item is picked up - the dot is still saved in array. It could work enough optimized because of splitting by small groups.

Also this behavior only helps with initially spawned items, "items that the player drops manually" stuff now works fine

6562680 commented 9 hours ago

Finished editing the answer above.

Also, raycast (not sure about Tarkov, expect that because of tech magic and coding experience) is expensive feature that also could cause bugs, just because of item is slightly under the surface, for 0.1 or something. So raycast will say that item is invisible, but actually it isnt.

DrakiaXYZ commented 2 hours ago

I'm well aware how raycasts work and their potential to cause performance issues if not utilized correctly. This mod is not and never will be a loot vacuum mod, the raycast is a requirement to stop loot vacuum behaviour

As I said, the mod works well enough, due to BSGs placement of some items, the mod may not detect them, that's not worth the time to fix in my opinion.

6562680 commented 2 hours ago

Well, ok, thanks for the explanation