Jump to content

Please load SandboxVars before firing OnPreDistributionMerge or OnInitWorld


Xyberviri

Recommended Posts

Hello,

 

I noticed in IsoWorld.java we are loading the Sandbox options after firing off the Distribution events, a lot of mods that deal with loot (including my self) are loading things into the loot tables around these events, would it be possible to load the sandbox options before these events so we can have access to sandbox variables before Distribution tables are messed with?

 

      LuaEventManager.triggerEvent("OnPreDistributionMerge");
      LuaEventManager.triggerEvent("OnDistributionMerge");
      LuaEventManager.triggerEvent("OnPostDistributionMerge");
      ItemPickerJava.Parse();
      VehiclesDB2.instance.init();
      LuaEventManager.triggerEvent("OnInitWorld");
      if (!GameClient.bClient) {
         SandboxOptions.instance.load();
      }

The big issue with this is if a mod implements their own sandbox options we cant really do anything with loot until OnInitGlobalModData or OnLoadMapZones fires off, if we want to change loot we have to go back and remove stuff which takes a boat load of time.

 

Sure if i want to hard code things no problem, but if I want a end user to be able to change any settings, again im sort of just out of luck unless im willing to go back though the tables with lua and slow down loading for a user. 

 

 

The alternative requires end users have to create a server mod to their settings via lua files which still have to be distributed, this is why we have a billion  Arsenal26ServerSettings mods clogging up the workshop.

Edited by Xyberviri
Link to comment
Share on other sites

Yes please!

 

I had a lot of trouble with my mod before I found out that sandbox settings variables cannot reliably be used to fill loot tables. It works the first time - but not after that. It always reuses the original variables. If you check those variables in game - they will be updated - but they get updated after distribution happens - so it is too late.

 

table.insert(ProceduralDistributions.list["BathroomCounter"].items, "module.someitem");
table.insert(ProceduralDistributions.list["BathroomCounter"].items, *SANDBOX REFERENCE ONLY WORKS THE FIRST TIME HERE*);

Link to comment
Share on other sites

I don't understand what it is what you want to do exactly, would you mind elaborating for me?

 

When adding items to the distribution tables you do not need to account for the loot rarity sandbox settings; item spawning should automatically adjust spawn values for loot rarity settings when populating containers during gameplay, I thought. I don't see a reason for mods to use the sandbox values in order to set loot values.
Not all sandbox values can be changed on the fly and it's not feasible to, either.

Or you're trying to do something else, in which case it'd help me if I knew what you were trying to do/achieve :)

Mind you, this would not be something we could provide for Build 41 since we're kissing it goodbye with one last patch, pretty much, so this'd have to wait until B42, but it'd help if I knew what you were going for.

Link to comment
Share on other sites

4 hours ago, nasKo said:

I don't understand what it is what you want to do exactly, would you mind elaborating for me?

 

When adding items to the distribution tables you do not need to account for the loot rarity sandbox settings; item spawning should automatically adjust spawn values for loot rarity settings when populating containers during gameplay, I thought. I don't see a reason for mods to use the sandbox values in order to set loot values.
Not all sandbox values can be changed on the fly and it's not feasible to, either.

Or you're trying to do something else, in which case it'd help me if I knew what you were trying to do/achieve :)

Mind you, this would not be something we could provide for Build 41 since we're kissing it goodbye with one last patch, pretty much, so this'd have to wait until B42, but it'd help if I knew what you were going for.


I assume it's something similar to a problem I had in Hydrocraft.  I added a sandbox value to let players turn off the guns/silencers in Hydrocraft - but when you load a save SandboxVars.Hydrocraft.SpawnHydrocraftGuns would return the default value, and not the value set by the player (as the save hasn't loaded, so the game doesn't know what the modified value is).

To get around it, I had to add a check using the OnLoad event to control whether or not the guns should be added to loot tables.

The problem doesn't arise when starting a new game - as the SandboxVars value seems to be set already in that situation.

I can't think of a situation where the OnLoad work around wouldn't work, but there might be one (and I never tested it in MP).

Link to comment
Share on other sites

Hi,

 

sorry for the late reply, the main reason is when i want to add my own sand box variables to allow the end users to adjust the rarity of the items I'm adding to the game itself, whatever weight i end up choosing to add my items a server owner / end user will inevitably ask for the ability to adjust my items to spawn more or less than whatever i choose.

 

Alternatively i would like the ability to turn off the spawning of some of my items depending on the sandbox options a user sets.

 

Also the reason this appears to be a bug, or at least not intentional is when you start a new game or host the sandbox variables are accessible in these events. If you restart the server/reload the game these is no longer accessible until later, so the behavior is inconsistent depending on how the game world is started.

 

 

Edited by Xyberviri
Link to comment
Share on other sites

Yeah, but modifying the distro directly with sandbox options doesn't seem to be a great solution and we'd probably break any mod that relied on the order in which these calls are made, if we were to change the order of events.

 

If you were using the default Sandbox settings, then all you'd need to do is call ItemPickerJava's InitSandboxLootSettings() after you've made your changes, but that doesn't really help with a custom setting.

 

If it's more about removing an item entirely from the distribution then it'd probably be best just to restart the server vs. trying to hook into events here. Distribution tables are very delicate and trying to recreate them in an active game seems like could break an awful lot. 

 

 

Link to comment
Share on other sites

 

Sorry i diverged there for a sec, this was about allowing end users to customize if a object is going to get added to the loot tables entirely by using a sandbox option. I would rather not resort to having a "EnableSettingA,EnableSettingB,EnableSettingC, etc, etc, etc" mod just to enable a setting.

 

I guess i could break up the items and assets into sub mods and just tell people to load the options they want and build my settings based off that if i really had to.

 

It appears the game has a copy of the loot tables in the java side and the "real" loot tables get built when ItemPickerJava.Parse() is called, If we wait until OnInitGlobalModData we have access to the sandbox variables but we cant add anything to SuburbsDistributions or ProceduralDistributions.

 

Well correction, anything we insert appears to be in the loot tables when you inspect a container with lootzed but its never going to actually drop, i tried turning up the weight to 100 and had loot showing 97% against everything else and nothing ever dropped.

 

but if you just deal with loot in OnPostDistributionMerge, your added items actually drop in game.
 

 

 

All good i figured out i can just call ItemPickerJava.Parse() and it loads my changes.

 

Edited by Xyberviri
Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...