any C# coders able to help out?

Started by Rah, August 16, 2019, 08:04:15 AM

Previous topic - Next topic

Rah

Hi, how would you go about making a mod setting button that makes you use a different file in your mod, instead of another one? Like, activate this file while simultaneously deactivating another file, so that it will not be used in the mod.

Or, if that doesn't work, make a mod setting button that deactivates a certain section of xml coding in a file. on/off

thanks !

K

Whether this is possible probably depends on the type of file that you want to enable or disable. Generally, with the way that mod loading works (at least to my knowledge) there's no easy way to get the game to load only one file or another.

The second option, turning on or off xml sections is more feasible, but almost certainly requires C# to work. The way I would think to implement that is to have every field that can be used in the xml, then select between them with the C#.

Can you describe what you're trying to do in a bit more detail? It would make it easier to determine the best solution.

Rah

QuoteThe second option, turning on or off xml sections is more feasible, but almost certainly requires C# to work. The way I would think to implement that is to have every field that can be used in the xml, then select between them with the C#.

Thanks for your answer. That sounds logical. So basically, I have a rejection system for natural organs in my mod, but I think it would be nice for users to be able to turn it off if they want. That would involve deactivating quite a bit of coding. Here's the code for the lung:

<HediffDef ParentName="addedPartPropsBase">
      <defName>Lung</defName>
      <label>lung transplant</label>
      <lethalSeverity>1</lethalSeverity>
      <minSeverity>0.001</minSeverity>
      <tendable>true</tendable>
      <spawnThingOnRemoved>Lung</spawnThingOnRemoved>
      <comps>
      <li Class="HediffCompProperties_TendDuration">
        <baseTendDurationHours>96</baseTendDurationHours>
        <severityPerDayTended>-0.8</severityPerDayTended>
      </li>
      <li Class="HediffCompProperties_Immunizable">
        <severityPerDayNotImmune>0.3</severityPerDayNotImmune>
      </li>
    </comps>
      <addedPartProps>
         <solid>true</solid>
         <partEfficiency>1.0</partEfficiency>
      </addedPartProps>
      <stages>
      <li>
        <label>mild rejection</label>
<partEfficiencyOffset>-0.05</partEfficiencyOffset>
      </li>
      <li>
        <label>moderate rejection</label>
        <minSeverity>0.3</minSeverity>
<partEfficiencyOffset>-0.3</partEfficiencyOffset>
<vomitMtbDays>1</vomitMtbDays>
<painOffset>0.15</painOffset>
<capMods>
            <li>
               <capacity>Consciousness</capacity>
               <offset>-0.2</offset>
            </li>
         </capMods>
      </li>
      <li>
        <label>serious rejection</label>
        <minSeverity>0.6</minSeverity>
<partEfficiencyOffset>-0.5</partEfficiencyOffset>
<vomitMtbDays>1</vomitMtbDays>
<painOffset>0.25</painOffset>
<capMods>
            <li>
               <capacity>Consciousness</capacity>
               <offset>-0.3</offset>
            </li>
         </capMods>
      </li>
      <li>
        <label>deadly rejection</label>
        <minSeverity>0.8</minSeverity>
<partEfficiencyOffset>-0.7</partEfficiencyOffset>
<vomitMtbDays>1</vomitMtbDays>
<painOffset>0.4</painOffset>
<capMods>
            <li>
               <capacity>Consciousness</capacity>
               <offset>-0.6</offset>
            </li>
         </capMods>
      </li>
    </stages>
   </HediffDef>

K

This should be fairly easily accomplished with a custom Hediff then. Since your rejection system is based on severity, you could override the default severity handler so that it returns the "normal" severity value when the rejection system is enabled, and zero when it isn't.