avoid spawnpoints with duplicate location
- duplicates were created because the rotation is noisy, we round it to get rid of the noise - add location_id to loose loot which can be used to check after generation if a duplicate was created when there are items with significantly differing rotation on the same location
This commit is contained in:
parent
30a4888bfb
commit
997fb537f3
@ -18,13 +18,15 @@ def preprocess_looseloot(looseloot):
|
||||
unique_ids = {}
|
||||
for li in looseloot:
|
||||
|
||||
# sometimes the rotatio changes very slightly in the dumps for the same location / rotation spawnpoint
|
||||
# use rounding to make sure it is not generated to two spawnpoint
|
||||
group_fun = lambda x: (
|
||||
x["Position"]["x"],
|
||||
x["Position"]["y"],
|
||||
x["Position"]["z"],
|
||||
x["Rotation"]["x"],
|
||||
x["Rotation"]["y"],
|
||||
x["Rotation"]["z"],
|
||||
round(x["Rotation"]["x"],3),
|
||||
round(x["Rotation"]["y"],3),
|
||||
round(x["Rotation"]["z"],3),
|
||||
x["useGravity"],
|
||||
x["IsGroupPosition"],
|
||||
)
|
||||
@ -85,9 +87,9 @@ class LooseLootProcessor:
|
||||
x["Position"]["x"],
|
||||
x["Position"]["y"],
|
||||
x["Position"]["z"],
|
||||
x["Rotation"]["x"],
|
||||
x["Rotation"]["y"],
|
||||
x["Rotation"]["z"],
|
||||
round(x["Rotation"]["x"], 3),
|
||||
round(x["Rotation"]["y"], 3),
|
||||
round(x["Rotation"]["z"], 3),
|
||||
x["useGravity"],
|
||||
x["GroupPositions"],
|
||||
x["IsGroupPosition"],
|
||||
@ -105,6 +107,9 @@ class LooseLootProcessor:
|
||||
print(json.dumps(gl, indent=4))
|
||||
raise ValueError("Attributes for distinct SpawnPointId differ")
|
||||
|
||||
location_id_fun = lambda x: str((x["Position"]["x"], x["Position"]["y"], x["Position"]["z"]))
|
||||
location_id = location_id_fun(gl[0])
|
||||
|
||||
template = copy.deepcopy(gl[0])
|
||||
template["Root"] = None
|
||||
|
||||
@ -118,12 +123,14 @@ class LooseLootProcessor:
|
||||
|
||||
if any((self._tarkov_items.is_questitem(item['tpl']) for item in item_distribution)):
|
||||
spawnpoint = {
|
||||
"locationId": location_id,
|
||||
"probability": probabilities[mi][spawnpoint],
|
||||
"template": template
|
||||
}
|
||||
loose_loot_distribution[mi]["spawnpointsForced"].append(spawnpoint)
|
||||
elif probabilities[mi][spawnpoint] > 0.99:
|
||||
spawnpoint = {
|
||||
"locationId": location_id,
|
||||
"probability": probabilities[mi][spawnpoint],
|
||||
"template": template
|
||||
}
|
||||
@ -133,12 +140,32 @@ class LooseLootProcessor:
|
||||
template["Items"] = []
|
||||
|
||||
spawnpoint = {
|
||||
"locationId": location_id,
|
||||
"probability": probabilities[mi][spawnpoint],
|
||||
"template": template,
|
||||
"itemDistribution": sorted(item_distribution, key=lambda x: x["tpl"])
|
||||
}
|
||||
loose_loot_distribution[mi]["spawnpoints"].append(spawnpoint)
|
||||
|
||||
# # Test for duplicate position
|
||||
# # we removed most of them by "rounding away" the jitter in rotation,
|
||||
# # there are still a few duplicate locations with distinct difference in rotation left though
|
||||
# group_fun = lambda x: (
|
||||
# x["template"]["Position"]["x"],
|
||||
# x["template"]["Position"]["y"],
|
||||
# x["template"]["Position"]["z"],
|
||||
# )
|
||||
# test = sorted(loose_loot_distribution[mi]["spawnpoints"], key=group_fun)
|
||||
# test_grouped = groupby(test, group_fun)
|
||||
# test_len = []
|
||||
# for k, g in test_grouped:
|
||||
# gl = list(g)
|
||||
# test_len.append(len(gl))
|
||||
# if len(gl) > 1:
|
||||
# print(gl)
|
||||
#
|
||||
# print(mi, np.unique(test_len, return_counts=True))
|
||||
|
||||
loose_loot_distribution[mi]["spawnpoints"] = sorted(loose_loot_distribution[mi]["spawnpoints"], key=lambda x: x["template"]["Id"])
|
||||
|
||||
# Cross check with forced loot in dumps vs items defined in forced_loose.yaml
|
||||
|
Loading…
x
Reference in New Issue
Block a user