Help with spawning Minerals

Started by AlmostLuckyDucky, June 04, 2017, 01:38:29 PM

Previous topic - Next topic

AlmostLuckyDucky

A few days ago i started playing around with making a mod for rimworld which included some new metals. i added the relevant defs and sure enough it spawned them as a minable resource as required.. however it also made most of the ruins out of them too.. i have tried several attempts to find out how NOT to make them do that and just spawn as just minable or deep minerals but i am assuming it is just that way as vanilla minerals work that was and adding new metals to the resource base also leads to this.

The other problem i had is i also added some alloys made out of a mixture of these metals as i wanted weapons to be made out of these alloys but it also added them to the ruins. is it possible to have a metal as a base to give bonuses to weapons without it spawning in rocks/deep or ruins?

jamaicancastle

Mineable rocks are easy. You've no doubt noticed if you've been playing around with the defs that each mineable resource is defined twice - once in Items_Resource_Stuff to define the item itself, and once in Buildings_Natural to define the ore. If you simply have an item def without a corresponding natural building (stone) def, you won't see any mineable form of that item, but it will still show up in the other normal ways (traders, starting spawn options, etc.) and you can add a recipe that yields it.

Deep drilling resources are controlled by a single line in the resource def which looks like this:
    <deepCommonality>1</deepCommonality>
Remove that line, and it should not place your resource in the deep drilling layer (although this will not affect any maps that are already created).

For metals, this is a little tricky. Your two options are to either modify the C# code that creates ruins, or make an end run around it entirely. If you're willing to deal in C# coding and can find the ruins code (which unfortunately I can't help you with, but I'm sure plenty of people here can point you to it), it should be easy to create exceptions for whatever resources you don't want. (You'll note, for instance, that in vanilla you never get ruins made of gold.)

The alternative is to avoid using the Metallic stuff category altogether. In Misc/StuffCategoryDefs you can find a list of these categories; if you add another one for your new items, you should be able to specifically add it to recipes that use Stuffs without that category being eligible for ruins. (This would be a lot more work, however, it's achievable completely in XML with no coding.)

AlmostLuckyDucky

Thanks... yeah i think its the c# i need to look at to add exceptions for anything i want to add to make it harder as they way it is now almost all the ruins are made from the metals i added and obviously that is not what i wanted however i have no idea what i am doing when it comes to c# so i am guessing my time tonight will be to look through every file to find the ruins part and work out how to overwrite this to get it right.

hopefully someone will point me in the right direction as i am sure there are quite a few people out there that know exactly what i am trying to do and know exactly how to do it :)

Thanks again

Bowen

So, similar question I guess.  What does  the number assigned to <deepCommonality> represent?  Also, how if at all does it correspond to the number assigned to <commonality>?  When googling Rimworld and deepCommonality this was the only useful hit I got.  Everything else was a log or an ad >:( .
I don't mind learning life's lessons from "The School of Hard Knocks"...

but the refresher courses there kill me

Ekarus

I ran into this problem myself recently, rather ruins being made out of stuff I didn't want them to be.

Someone else explained to me that ruins are made out of non-expensive stuff. If you don't want something to be used as a ruins material setting it to use "small" values, like silver (can't remember the exact tag but it's a true/false if I remember right) or make it more expensive (Don't know the tipping point.)

skullywag

Here is how all walls in "shrines" and "ruins" are created:

// RimWorld.BaseGen.BaseGenUtility
public static ThingDef RandomCheapWallStuff(Faction faction, bool notVeryFlammable = false)
{
if (faction != null && faction.def.techLevel.IsNeolithicOrWorse())
{
return ThingDefOf.WoodLog;
}
return (from d in DefDatabase<ThingDef>.AllDefsListForReading
where d.IsStuff && d.stuffProps.CanMake(ThingDefOf.Wall) && (!notVeryFlammable || d.BaseFlammability < 0.5f) && d.BaseMarketValue / d.VolumePerUnit < 5f
select d).RandomElement<ThingDef>();
}


If you can make your stuff not meet some of the criteria in the "where" bit you might be able to make it work but looking at those, it might be difficult without breaking stuff.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

jamaicancastle

Quote from: Bowen on July 18, 2017, 02:52:39 PM
So, similar question I guess.  What does  the number assigned to <deepCommonality> represent?  Also, how if at all does it correspond to the number assigned to <commonality>?  When googling Rimworld and deepCommonality this was the only useful hit I got.  Everything else was a log or an ad >:( .
When the game spawns minerals in the deep layer for a map, each time it adds a new deposit, it randomly chooses a thing to put in that deposit by making a weighted selection. Think of it like a lottery draw where each resource has a number of balls equal to its deepCommonality.

The stuff property "Commonality" works similarly, but is invoked when an item is generated (for a trader's inventory, a pawn's apparel or weapons, or a quest reward, primarily) and used to determine what material that item is made of. The two numbers have no direct interaction, so you could have something that's quite common as a raw material but rarely used to make objects with, for instance.

Bowen

Quote from: jamaicancastle on July 20, 2017, 09:55:05 AM

When the game spawns minerals in the deep layer for a map, each time it adds a new deposit, it randomly chooses a thing to put in that deposit by making a weighted selection. Think of it like a lottery draw where each resource has a number of balls equal to its deepCommonality.

The stuff property "Commonality" works similarly, but is invoked when an item is generated (for a trader's inventory, a pawn's apparel or weapons, or a quest reward, primarily) and used to determine what material that item is made of. The two numbers have no direct interaction, so you could have something that's quite common as a raw material but rarely used to make objects with, for instance.

Thanks for the reply.
So... smaller number = less lottery tickets?

Sincerely Grateful,

Bowen
I don't mind learning life's lessons from "The School of Hard Knocks"...

but the refresher courses there kill me

jamaicancastle

Quote from: Bowen on July 24, 2017, 08:56:18 AM
So... smaller number = less lottery tickets?
Exactly. If one item has twice the commonality of another, it has twice the odds of getting picked; if it has half the commonality, it's picked half as often.