Dev build/Linux: modded loot piles all contain the same items [RESOLVED]

User avatar
pango
Posts: 3358
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Dev build/Linux: modded loot piles all contain the same items [RESOLVED]

Post by pango »

Testing AlexanderSig's recent modded lootpiles, I noticed two things:
- the mod can only change the look of newly created lootpiles. If is enable it while in a dungeon, you'll have to exit and enter the dungeon again (or another dungeon) to start seeing modded lootpiles;
- more importantly all modded lootpiles have the same content:
the pile of loot.jpg
the pile of loot.jpg (40.68 KiB) Viewed 2475 times
Gamesave near the entrance of a random dungeon. A lootpile is easily reachable by following the left hand wall.
Attachments
SAVE1.zip
(422.68 KiB) Downloaded 110 times
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Interkarma
Posts: 7245
Joined: Sun Mar 22, 2015 1:51 am

Re: Dev build/Linux: modded loot piles all contain the same items

Post by Interkarma »

Thanks for report. It's likely the random loot seed is being cleared when loot pile is replaced by asset injection. So every replacement ends up with the same seed and randomly generated loot within.

User avatar
pango
Posts: 3358
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Dev build/Linux: modded loot piles all contain the same items

Post by pango »

Yes, I suspect that much too.
By the way, I later had a different lootpiles content (not sure when/why it changed), but again all the modded lootpiles of the dungeon were identical.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Dev build/Linux: modded loot piles all contain the same items

Post by TheLacus »

pango wrote: Fri Apr 12, 2019 9:28 pm - the mod can only change the look of newly created lootpiles. If is enable it while in a dungeon, you'll have to exit and enter the dungeon again (or another dungeon) to start seeing modded lootpiles;
I can't reproduce this issue. The save you provided has a bad positioned loot, maybe this is why you don't see it.
2019.04.14-16.02.png
2019.04.14-16.02.png (287.63 KiB) Viewed 2439 times

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Dev build/Linux: modded loot piles all contain the same items

Post by TheLacus »

pango wrote: Fri Apr 12, 2019 9:28 pm Testing AlexanderSig's recent modded lootpiles, I noticed two things:
- more importantly all modded lootpiles have the same content:
I don't think loot content is affected in any way, but i might not have experienced the bug because i currently can't find many loot treasures replaced by AlexanderSig's mod in any dungeon. I noticed your save was made with Persistent Dungeon mod enabled, did you try without it?

User avatar
pango
Posts: 3358
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Dev build/Linux: modded loot piles all contain the same items

Post by pango »

TheLacus wrote: Sun Apr 14, 2019 2:19 pm I don't think loot content is affected in any way
My main hypothesis, like Interkarma, is that the mod somehow resets the random seed between each pile creation, and indirectly removes randomness. Second one would be some kind of aliasing (I click on different piles but I'm always presented with the content of the same one), but removing items from one doesn't affect the others, so this is less likely.
TheLacus wrote: Sun Apr 14, 2019 2:19 pm i might not have experienced the bug because i currently can't find many loot treasures replaced by AlexanderSig's mod in any dungeon. I noticed your save was made with Persistent Dungeon mod enabled, did you try without it?
It was installed but not enabled, does that count?
In any case, I reinstalled with only the handpainted mod, then created two saves, one with the mod enabled (212), the other with the mod disabled (211).
Each time I reloaded SAVE1 from above, entered the dungeon, and I saved in one of those treasure-trap rooms surrounded by doors that open when you loot the triggering pile.
Screenshot.jpg
Screenshot.jpg (125.69 KiB) Viewed 2427 times
Attachments
SAVE212.zip
(341 KiB) Downloaded 97 times
SAVE211.zip
(330.69 KiB) Downloaded 95 times
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Dev build/Linux: modded loot piles all contain the same items

Post by TheLacus »

pango wrote: Sun Apr 14, 2019 3:24 pm
TheLacus wrote: Sun Apr 14, 2019 2:19 pm i might not have experienced the bug because i currently can't find many loot treasures replaced by AlexanderSig's mod in any dungeon. I noticed your save was made with Persistent Dungeon mod enabled, did you try without it?
It was installed but not enabled, does that count?
In any case, I reinstalled with only the handpainted mod, then created two saves, one with the mod enabled (212), the other with the mod disabled (211).
Each time I reloaded SAVE1 from above, entered the dungeon, and I saved in one of those treasure-trap rooms surrounded by doors that open when you loot the triggering pile.
Screenshot.jpg
Thank you for the save, now i see. When a treasure is deserialized, is first assigned to a random record id. Corresponding custom model is instantiated if available and billboard is removed, otherwise billboard material is set.

Code: Select all

DaggerfallLoot customLootContainer = GameObjectHelper.CreateDroppedLootContainer(GameManager.Instance.PlayerObject, key);
Only later the actual texture archive and record are defined and applied.

Code: Select all

serializableLootContainer.RestoreSaveData(lootContainers[i]);
This means the billboard material/imported asset is set twice. This is pretty bad for performance and it causes the bug found by pango when a mod provides the asset associated to the id chosen randomically but not the one read from save. I can recreate billboard if necessary, but i think it's better to rewrite this and set real id from start.

User avatar
pango
Posts: 3358
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Dev build/Linux: modded loot piles all contain the same items

Post by pango »

I watched Jinarra stream Daggerfall Unity 0.7.146 (modded: DREAM, Convenient Clock, Enhanced Sky, Handpainted Models, Remove Spiders, Loading Screens), he's been doing quests for some temple, taking some loot off the floor each time he came back to the temple.
He temporarily disabled "Handpainted models - Treasures" since I told him in a previous stream that that was the cause for the loot issue he noticed, but it seems the problem is not gone:

6 gold pieces, 2 holy daggers and 1 holy water:
https://www.twitch.tv/videos/434766801?t=00h09m52s
https://www.twitch.tv/videos/434766801?t=00h16m05s
https://www.twitch.tv/videos/434766801?t=00h35m49s
https://www.twitch.tv/videos/435177404?t=00h05m48s

So either it's having any model replacement enabled that triggers the issue, or they're several root causes...
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Interkarma
Posts: 7245
Joined: Sun Mar 22, 2015 1:51 am

Re: Dev build/Linux: modded loot piles all contain the same items

Post by Interkarma »

I'd love to take a looks at this soon. Going through some other stuff right now that's burning a lot of time and energy. Will try to have this sorted as part of June release.

User avatar
pango
Posts: 3358
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Dev build/Linux: modded loot piles all contain the same items

Post by pango »

Any models replacement mod triggers the bug.
As you suspected, the problem is MeshReplacement.ImportCustomFlatGameobject() resetting the random seed.

Code: Select all

diff --git a/Assets/Scripts/Utility/AssetInjection/MeshReplacement.cs b/Assets/Scripts/Utility/AssetInjection/MeshReplacement.cs
index 2c43e4c6..5a2be103 100644
--- a/Assets/Scripts/Utility/AssetInjection/MeshReplacement.cs
+++ b/Assets/Scripts/Utility/AssetInjection/MeshReplacement.cs
@@ -117,8 +117,10 @@ namespace DaggerfallWorkshop.Utility.AssetInjection
             var iObjectPositioner = go.GetComponent<IObjectPositioner>();
             if (iObjectPositioner == null || iObjectPositioner.AllowFlatRotation)
             {
+                Random.State oldState = Random.state;
                 Random.InitState((int)position.x);
                 go.transform.Rotate(0, Random.Range(0f, 360f), 0);
+                Random.state = oldState;
             }
 
             // Add NPC trigger collider
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Locked