Different fabric temperature multiplier?

Started by Kubouch, January 09, 2015, 03:08:44 PM

Previous topic - Next topic

Kubouch

Hi,
is it possible to have different temperature multipliers for different fabric materials (devilstrand/hyperweave/cloth/synthread)? Kinda the same thing as different leather types have:


Races_Animals.xml

<leatherEquippedStatFactors>
        <ComfyTemperatureMin>2.0</ComfyTemperatureMin>
        <ComfyTemperatureMax>1.0</ComfyTemperatureMax>
</leatherEquippedStatFactors>


I'd like to add the multiplier to different cloth materials but no xml trickery I performed worked.
I found no such modifier in Items_Resources.xml.

Thanks,
Kubouch

Kubouch

Allright, I did some science by digging through assemblies with ILSpy.

In RimWorld.StatDefOf I found this:

public static StatDef ComfyTemperatureMin;
public static StatDef ComfyTemperatureMax;


In Verse.RaceProperties I found this:
public List<StatModifier> leatherEquippedStatFactors;
which should store those ComfyTemperatureMin/Max as factors.

Then there must be somewhere a method to multiply these with a base temperature of an apparel.

What I need is to create some kind of fabricEquippedStatFactors inside of RimWorld.ApparelProperties (maybe?) which reads ComfyTemperatureMin/Max from a particular material in Items_Resources.xml. Then I need somewhere a method which multiplies these numbers with an actual apparel values. Or maybe not... It's just what I came up with.

Also in Rimworld.StuffCategoryDefOf I found
public static StuffCategoryDef Fabric;
which might be useful but I don't know what for.

Yes, very scientific, I know :-D. All I can do in C# is only little more than "Hello world" so it's quite confusing to me. But I like to write this down since it helps me to organize it and somebody else can actually help me, too.



skullywag

Tynan changed all this as leather doesnt have a def you can mess with as its created on the fly depending on the animal butchered. Cloth and fabrics do have defs you can mess with have you tried adding the stats to the item (stuff) defs. Im not near a pc so cant see the code unfortunately.

Apparel itself has the temp comfy stats on it if i remember right. Does the type of leather affect those stats? I thought it only changed armour stats. I havent messed in this area when modding all that much. Shinzy would probably be your best bet if anyones looked into this itll be him.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Kubouch

Thanks for reply skullywag.

Apparel itself adds constant min/max comfortable temperature offsets. For example parka has ComfyTemperatureMin -45 which adds to the colonist min comfortable temp. Leather has another multiplier which multiplies the ComfyTemperatureMin/Max value. For example muffalo leather has ComfyTemperatureMin factor 2.0 so a parka made of muffalo leather has min comfy temp offset -45*2.0 = -90. Squirrel has the factor 1.7 so parka made of squirrel leather has min comfy temp offset -45*1.7 = -76.5 making it less effective in cold. All this can be found in Apparel_Various.xml and Races_Animal.xml.

I tried to mess with xml files by adding

<equippedStatOffsets/Factors>
<ComfyTemperatureMin>xxx</ComfyTemperatureMin>
</equippedStatOffsets/Factors>

inside <statOffsets/Factors> in synthread/cloth/... defs which resulted in an error that
no Rimworld.DtatDef named equippedStatOffsets/Factors found to give to RimWorld.StatModifier

When I added directly

<ComfyTemperatureMin>xxx</ComfyTemperatureMin>

inside <statOffsets/Factors> no error appeared but nothing changed either.

It is probably needed to look at leather and see how it's done and then try to replicate the <leatherEquippedStatFactors> stuff for fabric. However it seems there is nothing relevant to be found in the code.


Shinzy

I already told Kubouch this in a pm but thought I'd post here too just incase someone caan shed some moar light on this!

cause I did fiddle about with the xmls aswell good while ago much like how Kubby did but didn't see any visible effect on anything

so that is all! I'd love to know too if someone can heeeeeeeeelp!
Hilfe! Hulp! Apua! Hjälp! Helpooo! iEl toro Hobla hobla! Hojohojo shinpaiii~

StorymasterQ

Quote from: Shinzy on January 13, 2015, 08:17:18 AM
I already told Kubouch this in a pm but thought I'd post here too just incase someone caan shed some moar light on this!

cause I did fiddle about with the xmls aswell good while ago much like how Kubby did but didn't see any visible effect on anything

so that is all! I'd love to know too if someone can heeeeeeeeelp!
Hilfe! Hulp! Apua! Hjälp! Helpooo! iEl toro Hobla hobla! Hojohojo shinpaiii~

That last bit sounds like a (somewhat misspelled) chant to summon Haplo. Maybe I'm wrong, but I don't think you should chant it while dancing on a pentagram of candles.
I like how this game can result in quotes that would be quite unnerving when said in public, out of context. - Myself

The dubious quotes list is now public. See it here

Shinzy

but it's the only way to summon modder demon haplo
but it looks like he wasn't none too impressed with my "dancing"
I need to knock it up a notch! *dancing intensifies*

Haplo

#7
Sorry, but summoning me doesn't help here either.
I've extracted the offsets and factors of the squirrel leather, but there isn't anything other than the heat factor that comes even remotely to the resulting values.
Here are my results:

Jacket base value: min value -15�C

Pawn w some clothes:
+32�C / +6�C

Squirrel Leather Jacket:
+32�C / -19,5�C

Devilstrand, Cloth, Hyperweave:
+32�C / -9�C

Squirrel_Leather:
IsStuff: True
StatFactor: MarketValue 1.3
StatFactor: ArmorRating_Blunt 1.5
StatFactor: ArmorRating_Sharp 1.5
StatFactor: ArmorRating_Heat 1.7
StatFactor: ArmorRating_Electric 4
volumePerUnit:1 stuffCommonality:1
StatOffset: null



To be honest, I'm also at a loss here...
I m slowly thinking the changing value isn't found in the stuff definition but somewhere else..
Maybe we should summon Tynan to help us understand why the offset doesn't work with clothes :)

Today I'm out of time.
Maybe tomorrow I'll continue my search for wisdom ;)

Edit: Value correction

unifex

I looked into this a bit when I noticed my new apparel recipes' products weren't affected by the materials they used. Tried to work around it (I think by doing something in SpawnSetup which calculated what I thought should be the resulting value, but the values lay on the Defs, not the items themselves) but this ones a core one.

Igabod

I just started messing around with creating a new wild animal for a mod and have decided that the best way to create new fabrics with the temperature multiplier offsets is to make new animals. If anybody wants to contribute new animal textures to the cause and specify what temperature offsets and armor offsets the leather provides then please do.

unifex

Quote from: Igabod on January 15, 2015, 05:41:26 PM
I just started messing around with creating a new wild animal for a mod and have decided that the best way to create new fabrics with the temperature multiplier offsets is to make new animals. If anybody wants to contribute new animal textures to the cause and specify what temperature offsets and armor offsets the leather provides then please do.

I'm fairly sure I played with different leather types for making apparel, and none of those values transferred across to the final garment. Or did I get that wrong? Its only the recipe values that end up being used.

Kubouch

I did my personal summoning of JuliaEllie with no good solution either. Since it's becoming quite a public topic I'll share her PM (hope she won't get mad):
Quote from: JuliaEllie
I looked into the code and the game takes the information for the comfy temperatures directly from the ThingDefs and not from the Things themselves. You would have to rewrite a big part of the game to implement different values for different stuff. I would suggest to make different ThingDefs for Apparel which uses the different materials and put the different StatModifiers there. This is just a work around and not a very good solution.

Quote from: Igabod on January 15, 2015, 05:41:26 PM
I just started messing around with creating a new wild animal for a mod and have decided that the best way to create new fabrics with the temperature multiplier offsets is to make new animals. If anybody wants to contribute new animal textures to the cause and specify what temperature offsets and armor offsets the leather provides then please do.

For leather temperatures you can look into Races_Animals.xml and look up for <leatherEquippedStatFactors>. These numbers multiply comfy temp offsets set in Apparel_Various.xml. I explained it more here. AFAIK leather should not provide any temperature offsets.

Quote from: Haplo on January 15, 2015, 05:02:11 PM

Jacket base value: min value -15�C

Pawn w some clothes:
+32�C / +6�C

Squirrel Leather Jacket:
+32�C / -13,5�C

Devilstrand, Cloth, Hyperweave:
+32�C / -9�C

Squirrel_Leather:
IsStuff: True
StatFactor: MarketValue 1.3
StatFactor: ArmorRating_Blunt 1.5
StatFactor: ArmorRating_Sharp 1.5
StatFactor: ArmorRating_Heat 1.7
StatFactor: ArmorRating_Electric 4
volumePerUnit:1 stuffCommonality:1
StatOffset: null

Strange, jacket has -15 C, squirrel leather x1.7 so the resulting offset should be -15*1.7 = -25.5 C. Pawn with min comfy temp +6 then should have -19.5 C.

Also the
StatFactor: ArmorRating_Heat 1.7
corresponds with the leather temperature factor (both are 1.7). Not sure whether it's useful for anything but maybe the heat armor rating is derived from the leather temp factors.

Gaesatae

I took a long look into it, and I may have found an answer. This is where I started.
From StatUtility:
    public static float StatOffsetFromGear(Thing gear, StatDef stat)
    {
      float statOffsetFromList = StatUtility.GetStatOffsetFromList(gear.def.equippedStatOffsets, stat);
      if (gear.Stuff != null)
        statOffsetFromList *= StatUtility.GetStatFactorFromList(gear.Stuff.stuffProps.equippedStatFactors, stat);
      return statOffsetFromList;
    }


So, I think the only thing you need is to modify the StuffProperties of your Def and set the StatsDefs directly. In theory, It should work. If you look at the ThingDefGenereator_Leather long enough you'll see it.
Do not mistake the StatDefOf.ArmorRating_Heat for the StatDefOf.ComfyTemperatureMin/Max. The first is used for protection against fire.

I'm not really sure, but I'm confident that I understand how the statfactors works. Lets see if I'm able to translate it to words after looking at the code for two hours.

stuffprops.equippedStatFactors is a List<StatModifier>
a StatModifier is a class with two fields: StatDef stat;  float value;
Take a simplified example for leather:

Looking only at temperature, each kind of Leather Def.stuffprops.equippedStatFactors is composed from:
a "StatModifier1" = StatDefOf.ComfyTemperatureMin, 1.2f (Shared for all the leathers)
a "StatModifier2" = StatDefOf.ComfyTemperatureMin, (defoftheanimal.race.leatherEquippedStatFactors[index of ComfyTemperatureMin].value)
and a "StatModifier3" = StatDefOf.ComfyTemperatureMax, (defoftheanimal.race.leatherEquippedStatFactors[index of ComfyTemperatureMax].value


Maybe I'm wrong about the way the StatModifier works, but I believe that, in theory, you should be able to do what you asked. Easier said than done.

Haplo

I've seen that also. But strangely if you add the comfy variables to the Def, it doesn't change the resulting temperature. It looks good in the code but will not work and I have no idea why..

Gaesatae

Well, now this is infuriating.
I've been trying for a couple of hours to make this work and now I'm blind.
The equipped multiplier works fine when equipped, but I couldn't manage to find an easy way to use the stuff's multipliers to show up in the info of the cloth offset.

The worst part is that, after going through the code of the leatherdefgen a couple of times, I don't think that its code does anything that could not be done using the xml.

Other thing that's bugging me is that I don't understand why there is a Stuff.equippedStatOffsets and how may be related to the stuffprops statmodifiers.

In any case, I believe you can use the statFactors in the xml to store the statmods with the value of your multiplier and at spawnsetup apply the value of the multiplier directly to the def.equippedStatOffsets of the cloth.

Tell me if you want me to write the code, and I'll do it tomorrow. Can't today, I think I broke my brain.