Sign in to follow this  
Wurmhole

Set Vein Quantity - minnig change

Recommended Posts

Just saw a post here from Wulfrock on a custom mod to fix sandstone vein counts: 

What I would like to see is a mod like this, but that expands on the idea to include all vein types, allowing you to set an ore range for each type.  So if you want Glimmer and Addy veins to be higher than 50, but not as high as iron, presto.  I agree with Wulfrock that sandstone is too plentiful for full 10k veins, so setting a lower count is going to be preferable for most server hosts.  If there was a mod like this before I'd created my server, I would have created more veins, but with smaller quantities in each, to provide greater access to all the different ore types, without making it too impossible to mine in a straight line.

Share this post


Link to post
Share on other sites

just for reference, I don't want to make this, here is some useful information.

  • Vein quality is determined by a seeded RNG. It would be difficult to change this. I'd think you need state data for all tiles in the game to remember custom quality. With that quality use expression editor changes on the mining action to replace Wurm's RNG generated values with your custom quality state data.
  • Vein ore counts are in the Server.resourceMesh integer array. Each mesh entry integer is encoded per (hexadecimal): MMMM????, where M is how many ores are in the vein. I'm not sure what the ? are being used for. There is a public getter and setter for cave resources so you don't actualy need to mess with decoding/encoding. I think it's good to know anyway.
  • Vein/wall type (Type), the ceiling offset (data), and cave floor elevation (Height) are in the Server.caveMesh integer array. Each mesh entry integer is encoded per(hexadecimal): TTCCHHHH where T tile type, C is ceiling offset and H is floor elevation, . I ended up making my own getters and setters for these three values as I got tired of messing with Wurm code regarding this. Most (maybe all) the setters and getters are in the Server class.
  • regarding the mesh files there is an integer for every tile in the game. A program could iterate through all tiles in the game while testing for type equality. For matches change the resource counts. Also, one could iterate through the Server.caveMesh.getData() array but WU code requires x,y data for its set/get methods. This means the array ordinal needs to be converted to a x,y value in order to use Wurm's getters and setters. This might help with that
int meshArraySize = Server.caveMesh.getData().length;
int columns = (int) Math.pow(Server.caveMesh.getSizeLevel(), 2.0d); // Bitwise, WU usually does this: 1 << getSizeLevel()
for(int meshArrayOrdinal=0; meshArrayOrdinal < meshArraySize; meshArrayOrdinal++) {
  int y = meshArrayOrdinal / columns; // Bitwise: ordinal >> getSizeLevel()
  int x = meshArrayOrdinal % columns; // Bitwise: ordinal & (~(1 << getSizeLevel()))
}

Although, you're not really using the mesh array there anyway so maybe it's not so helpful. eh, there it is anyway.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for that info Joedobo!

 

Would it be easier to specify the specific ore count, rather than trying to set a range?  Say all moon metal veins are 500, sandstone 1000, iron 5000, etc?  I know when we populate the veins at server creation, we choose the number of each type of vein, so in a way, I suppose we can control the total ore that way, but it could get annoying if every 3rd tile was moon metal, to achieve the quantity desired. 

 

I wonder, can ore redistribution be run easily?  Would it be as simple as recreating the resources and copying it over to the main Creative directory, to replace the existing resources map?  Is that what they did for Xanadu, back when they did that redistribution?

Share this post


Link to post
Share on other sites

I don't think it's that different between a specific set quantity or a random quantity bound by ranges. In one case we'd set the resource mesh with a specific number. In the other case we'd do something this : setCount = minimumCount + Server.rand.nextInt(maxCount - minimumCount)

 

It shouldn't be to difficult to change vein types or the quantity in a vein. The only really hard one to deal with is vein quality as that is decided with a seed random algorithm. If we just want to do a  simple flat RNG per a tile, it should be easy that is.

Now, if the goal is to add ore zones, maybe stop ore from spawning under water, maybe increase the chance of certain ores given the elevation of the surface mesh (moon metal only occurs for the group of tiles where the surface elevation is in the top 1% based on its elevation). All that kinds of stuff is harder to do. Although, we could probably look at Budda's WU server map generator to see how he did RNG zones.

 

One of my reluctances to dealing with mesh files is the changes are permanent. And given that it's used with a bunch of bitwise encode/decode methods to cram it all into an integer, I feel it's too easy to make a little mistake that could drastically mess up a server's terrain data. If you got a backup it should be okay, but people don't always do that. It isn't that hard to iterate through an array of integers, make decisions based on decoded values from those integers, and potentially replace them with new integers whose values are encoded representation of the new desired tile data. It's just that simple mistakes could lead to being forced to reroll the server's terrain.

 

Share this post


Link to post
Share on other sites

You should look at the code for moonmetal veins, they are generated like normal veins but on each mining action it checks if the vein has more than 50 actions remaining and then if it does it sets the actions remaining to 50, maybe with some rng either side I can't remember off the top of my head. You could replicate this by doing a check and if it has more than sandstoneCapAverage + sandstoneCapVariance then set it to sandstoneCapAverage + (RandomInteger(2*sandstoneCapVariance) - sandstoneCapVariance) on each mining action and it would mean you could set a range of quantity in the vein for a cap if it spawns wight 10k.

Share this post


Link to post
Share on other sites

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
Sign in to follow this