Disease Code - location? [Biogenic mod]

Started by Cat123, November 10, 2014, 05:01:51 PM

Previous topic - Next topic

Cat123

I'm looking for the specific disease code parameters - most importantly % chance of catching etc.

I'm thinking of a biological modification mod that works as an opposite to the bionics mods - grafting alien tissue into people, infecting them with mutagens etc. The major difference from bionics being it's 100% permanent and removes any future changes to that body part. While tying a few directly to events is ok, I'd prefer it if there was a code based framework so that I can hang a lot of variables off. e.g. "Eat X alien item > % chance mutation".

So, while I'll be ripping open the bionics mod code, I'd love to use the current disease code as a basis for random mutations, random alien infections > mutations and so on.


Thanks in advance!

Rikiki


  • Open ILSpy
  • Go into the Verse namespace.
  • You will find the disease classes: Disease, DiseaseImmunity, DiseaseProps, ...

Good luck, this mod seems really interresting! :)

Igabod

Quote from: Cat123 on November 10, 2014, 05:01:51 PM
I'm looking for the specific disease code parameters - most importantly % chance of catching etc.
Chance of catching diseases is in the biomes defs. specifically, Core/Defs/BiomeDefs/BiomesBase.xml

The particular part that effects chance per day of getting the disease looks like this:

     <diseases>
      <li>
        <diseaseInc>Flu</diseaseInc>
        <chancePerDay>0.01</chancePerDay>
      </li>
      <li>
        <diseaseInc>Plague</diseaseInc>
        <chancePerDay>0.005</chancePerDay>
      </li>
    </diseases>


And is defined for each biome individually.

Cat123

Quote from: Igabod on November 17, 2014, 02:25:06 AM

Chance of catching diseases is in the biomes defs. specifically, Core/Defs/BiomeDefs/BiomesBase.xml

The particular part that effects chance per day of getting the disease looks like this:


And is defined for each biome individually.


Yep, I've found that - wasn't quite what I was looking for, however. At the moment, all the diseases do roughly the same thing, I was hoping there was more I could do with it. i.e. make diseases that did specific things.

skullywag

Got any examples of these specific things?

Im sure you could do this in DLL form. Xml i doubt it.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Cat123

#5
Quote from: skullywag on November 17, 2014, 04:24:13 AM
Got any examples of these specific things?

Im sure you could do this in DLL form. Xml i doubt it.

This thread: https://ludeon.com/forums/index.php?topic=7461.0


At the moment, the loop I'm stuck in is this:

Organs = <items>; Operation = <item X> <-> <item Y> (e.g. leg for bionic leg). It's neither permanent nor logical for what I'm trying to do.

So, I've got:

1) A huge list of <items> (biogenic_bodyparts_mutations.xml, biogenic_bodyparts_weapons.xml, healthdiffs_mutatedparts.xml, healthdiffs_mutatedparts_weapons.xml) that I don't want to be available as <items>, but I have to generate / make them somehow.

2) A permanence issue: i.e. making each mutation permanent and exclusive, and disallowing surgery in some cases. e.g. you could cut a tentacle off (arm), but not remove a spined spine or an armored carapace (torso / sternum).  You can change the XML so that when a mutation is removed it generates something other than the original item (human meat is what I'm using atm), but you can't turn off the categories.

3) Given they are mutations, see the linked thread to specific desires. i.e. weighted tables that determine which is given.

I was hoping to use the disease code to do the following: each mutation = a disease, then effects the pawn, over time > <item> (mutation) is added. e.g. (this is for skull replacement):

<diseases>
      <li>
        <diseaseInc>Bony Ridges</diseaseInc>
        <chancePerDay>0.25</chancePerDay>
      </li>
      <li>
        <diseaseInc>Enlarged Cranium</diseaseInc>
        <chancePerDay>0.2</chancePerDay>
      </li>     
<li>
        <diseaseInc>Spongy Holes</diseaseInc>
        <chancePerDay>0.05</chancePerDay>
      </li>     
<li>
        <diseaseInc>Tumorous Growths</diseaseInc>
        <chancePerDay>0.1</chancePerDay>
      </li>
<li>
        <diseaseInc>Horned</diseaseInc>
        <chancePerDay>0.2</chancePerDay>
      </li>
<li>
        <diseaseInc>Bull Horned</diseaseInc>
        <chancePerDay>0.15</chancePerDay>
      </li>
<li>
        <diseaseInc>Predator </diseaseInc>
        <chancePerDay>0.05</chancePerDay>
      </li>
    </diseases>


So - 100% chance that one happens in a day; in the list above, 7 are positive, 2 are negative and 1 is amazing. Each has it's own HP / stats / bonuses or penalties attached to it - a couple have melee attacks, which I'm working on (porting across the animal attacks so that headbutts are a thing). They each also have a weighting to the degree of mutation, but that's a system not in place atm (i.e. Most are minor, a couple are medium, one is monstrous).

The problem being I need to limit the duration to a single day, and roll only once - after that, the colonist comes down with the "disease" (mutating!), after 1-4 days > mutation is installed.

TL;DR

At the moment I'm trying to hack together a system that doesn't require coding I'm not capable of. Rimworld has no weighted table rolls I can find. In other games, I'd simply generate a weighted table and have the mutation selected off a subtable (e.g. Mutations > skull > roll on table > item selected + installed, no need to craft it)

Cat123

#6
Reference to myself: I might have been a muppet. If you replace a base bodypart with one that hasn't got an operation assigned to it, you'll make it permanent.


<RecipeDef>
<defName>MutateNaturalSkull</defName>
<label>mutate skull</label>
<description>Mutates Skull.</description>
<workerClass>Recipe_InstallNaturalBodyPart</workerClass>
<jobString>Adding foreign DNA to skull.</jobString>
<workAmount>2000</workAmount>
<workEffect>ButcherFlesh</workEffect>
<workSpeedStat>MedicalOperationSpeed</workSpeedStat>
<sustainerSoundDef>Recipe_ButcherCorpseFlesh</sustainerSoundDef>
<ingredients>
<li>
<filter>
<thingDefs>
<li>Mutagen</li>
</thingDefs>
</filter>
<count>1</count>
</li>
<li>
<filter>
<thingDefs>
<li>Skull</li>
</thingDefs>
</filter>
<count>1</count>
</li>
</ingredients>
<fixedIngredientFilter>
<thingDefs>
<li>Mutagen</li>
<li>Skull</li>
</thingDefs>
</fixedIngredientFilter>
<appliedOnFixedBodyParts>
<li>Skull</li>
</appliedOnFixedBodyParts>
<subOptionsChooseOne>
<addsHealthDiff>Bony Ridges</addsHealthDiff>
<addsHealthDiff>Enlarged Cranium</addsHealthDiff>
<addsHealthDiff>Spongy Holes</addsHealthDiff>
<addsHealthDiff>Tumorous Growths</addsHealthDiff>
<addsHealthDiff>Horned</addsHealthDiff>
<addsHealthDiff>Bull Horned</addsHealthDiff>
<addsHealthDiff>Predator</addsHealthDiff>
</subOptionsChooseOne>
</RecipeDef>


Pawnkind has <subOptionsChooseOne> tag - so all that's needed is to choose the outcome healthdiff, with odds! Obviously this tag won't work, but the precedent is in the code.

WTB something like this:

<subOptionsChooseOne>
<li>
<addsHealthDiff>Bony Ridges</addsHealthDiff>
<Weight>0.2</weight>
</li>
<li>
<addsHealthDiff>Enlarged Cranium</addsHealthDiff>
<Weight>0.2</weight>
</li>
<li>
<addsHealthDiff>Spongy Holes</addsHealthDiff>
<Weight>0.2</weight>
</li>
(etc)
</subOptionsChooseOne>
.

Can't be too hard.

Cat123

#7
Tum te tum.

Next question (no-one's answering, but meh)

Can you add <statBases> to bodyparts? Like so:

  <BodyPartDef>
    <defName>BonyRidges</defName>
    <label>bony ridges</label>
<health>40</health>
<oldInjuryBaseChance>0</oldInjuryBaseChance>
<skinCovered>false</skinCovered>
<isSolid>true</isSolid>
<dontSuggestAmputation>true</dontSuggestAmputation>
  </BodyPartDef>

<HealthDiffDef ParentName="MutatedBodyPartBase">
    <defName>BonyRidges</defName>
    <label>bony ridges</label>
    <addedBodyPart>
      <isSolid>true</isSolid>
      <partEfficiency>1</partEfficiency>
    </addedBodyPart>
<modifiers>
    <statBases>
      <DamageDeflection_Blunt>0.1</DamageDeflection_Blunt>
      <DamageDeflection_Piercing>0.1</DamageDeflection_Piercing>
    </statBases>
    </modifiers>
  </HealthDiffDef>



And yeah, <HealthDiffDef ParentName="MutatedBodyPartBase"> might just change into the normal version; atm nothing that's added regenerates, which is bad. Thinking about it, <partEfficiency>1</partEfficiency> probably requires the <isbionic> tag, so can be pruned.

Quesion - why did 'SurgeryExtended & Bionics' mod by Minus+CrazehMeow+GottJammern use novel code and why didn't they alter the races_humanoid.xml to add the recipes to the base pawn?

Rikiki

QuoteQuesion - why did 'SurgeryExtended & Bionics' mod by Minus+CrazehMeow+GottJammern use novel code and why didn't they alter the races_humanoid.xml to add the recipes to the base pawn?

For compatibility reasons between mods, you should NOT alter core files like races_humanoid.xml.
You should better add a new module.

Cat123

#9
Quote from: Rikiki on November 18, 2014, 03:16:00 AM

For compatibility reasons between mods, you should NOT alter core files like races_humanoid.xml.
You should better add a new module.

If they mod a core file & bundle it in their mod, I can't see an issue as long as theirs is loaded first. You also didn't answer the question: I cannot see any place in their mod where a <list> is added to, nor can I see the point of the <list> in the core file apart from generation of non-Player pawns.

In which case, I obviously want to add to it so that non-Player pawns can spawn with mutations. e.g. In this code, what's the point of having this recipe list, if adding to the InstallBodyPart tree doesn't require modding it at all?

<thinkTree>Humanoid</thinkTree>
      <humanoid>true</humanoid>
      <isFlesh>true</isFlesh>
      <hasLeather>true</hasLeather>
      <leatherColor>(211,194,143)</leatherColor>
      <nameCategory>HumanStandard</nameCategory>
      <hasStory>true</hasStory>
      <minFoodQuality>Raw</minFoodQuality>
      <body>Human</body>
      <bodySize>1</bodySize>
      <healthScale>1</healthScale>
      <diet>Omnivorous</diet>
      <soundWounded>Pawn_Human_Wounded</soundWounded>
      <soundDeath>Pawn_Human_Death</soundDeath>
      <soundMeleeHitPawn>Pawn_Melee_Punch_HitPawn</soundMeleeHitPawn>
      <soundMeleeHitBuilding>Pawn_Melee_Punch_HitBuilding</soundMeleeHitBuilding>
      <soundMeleeMiss>Pawn_Melee_Punch_Miss</soundMeleeMiss>
    </race>
    <recipes>
      <li>InstallPowerClaw</li>
  <li>InstallScytherKnifeProtrusion</li>
      <li>InstallBionicEye</li>
      <li>InstallBionicArm</li>
      <li>InstallBionicLeg</li>
      <li>InstallSimpleProstheticArm</li>
      <li>InstallSimpleProstheticLeg</li>
      <li>InstallPegLeg</li>
      <li>InstallDenture</li>
      <li>InstallNaturalHeart</li>
      <li>InstallNaturalLung</li>
      <li>InstallNaturalKidney</li>
      <li>InstallNaturalLiver</li>
      <li>RemoveBodyPart</li>
  <li>Euthanize</li>
    </recipes>



Anyhow, last try: so far I've asked about 10 times whether or not various <tags> are transferrable and whether they'd work, and got zero response.

<RecipeDef>
<defName>MutateNaturalSkull</defName>
<label>mutate skull</label>
<description>Mutates Skull.</description>
<workerClass>Recipe_InstallNaturalBodyPart</workerClass>
<jobString>Adding foreign DNA to skull.</jobString>
<workAmount>2000</workAmount>
<workEffect>ButcherFlesh</workEffect>
<workSpeedStat>MedicalOperationSpeed</workSpeedStat>
<sustainerSoundDef>Recipe_ButcherCorpseFlesh</sustainerSoundDef>
<ingredients>
<li>
<filter>
<thingDefs>
<li>Mutagen</li>
</thingDefs>
</filter>
<count>1</count>
</li>
<li>
<filter>
<thingDefs>
<li>Skull</li>
</thingDefs>
</filter>
<count>1</count>
</li>
</ingredients>
<fixedIngredientFilter>
<thingDefs>
<li>Mutagen</li>
<li>Skull</li>
</thingDefs>
</fixedIngredientFilter>
<appliedOnFixedBodyParts>
<li>Skull</li>
</appliedOnFixedBodyParts>
<subOptionsChooseOne>
<li>
<addsHealthDiff>BonyRidges</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
<li>
<addsHealthDiff>EnlargedCranium</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
<li>
<addsHealthDiff>SpongyHoles</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
<li>
<addsHealthDiff>TumorousGrowths</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
<li>
<addsHealthDiff>Horned</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
<li>
<addsHealthDiff>BullHorned</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
<li>
<addsHealthDiff>Predator</addsHealthDiff>
<selectionWeight>20</selectionWeight>
</li>
</subOptionsChooseOne>
</RecipeDef>



It's obvious what I'm attempting to do - I don't understand the confusion / inability for anyone to offer answers and/or fixed XML.

Cat123

Injector code from their mod:

public static class humanRecipeResolver
{
public static System.Collections.Generic.List<RecipeDef> collectedRecipes = new System.Collections.Generic.List<RecipeDef>();
public static void collect()
{
foreach (RecipeDef current in DefDatabase<RecipeDef>.get_AllDefs())
{
if (current.workSpeedStat != null)
{
if (current.workSpeedStat.defName.Equals("MedicalOperationSpeed") && !current.defName.Equals("Euthanize"))
{
humanRecipeResolver.collectedRecipes.Add(current);
}
}
}
}
public static void injectToHuman()
{
ThingDef named = DefDatabase<ThingDef>.GetNamed("Human", true);
named.recipes.Clear();
foreach (RecipeDef current in humanRecipeResolver.collectedRecipes)
{
named.recipes.Add(current);
}
}
public static void debug()
{
foreach (RecipeDef current in DefDatabase<ThingDef>.GetNamed("Human", true).recipes)
{
Log.Error(current.defName);
}
}
public static void execute()
{
humanRecipeResolver.collect();
humanRecipeResolver.injectToHuman();
humanRecipeResolver.debug();

and

{
public class Loader : ITab
{
protected GameObject gameObject = null;
public Loader()
{
this.gameObject = new GameObject("Injector");
this.gameObject.AddComponent<NewRecipeNurseObject>();
UnityEngine.Object.DontDestroyOnLoad(this.gameObject);
}
protected override void FillTab()
{
}
}



Unless I'm gravely mistaken, this is a lot of work in order to avoid just adding to that recipelist in the XML. Not sure why it's used?!!?

Rikiki

I have not played with the prosthesis part of the game for now.
My guess is they use the recipe nurse dll to avoid conflicts between mods adding prosthesis parts because
QuoteI recently saw some mods overwriting Core Definitions to add Recipes. This can be "dangerous" for other mods and break them if they use Core data and should be avoided.

You should have a look at this thread.

skullywag

The reason you havent got an answer on the tags question is the answer is yes/no some are some arent. The ones that arent can be made to via dll modding. I know you like to know whats available via xml before diving into the c# but i think you could answer a lot of these questions yourself with a quick look over the code in ILSpy or something.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Cat123

#13
Quote from: skullywag on November 18, 2014, 12:33:50 PM
The reason you havent got an answer on the tags question is the answer is yes/no some are some arent. The ones that arent can be made to via dll modding. I know you like to know whats available via xml before diving into the c# but i think you could answer a lot of these questions yourself with a quick look over the code in ILSpy or something.

I have ILSpy open atm, and am running into a vicious circle.

e.g.

{
public class AddedBodyPartProps
{
public bool isBionic;
public bool isSolid = true;
public float partEfficiency = 1f;
public ThingDef spawnThingOnRemoved;
}
}


This is a core element to the .dll --- all I want to do is add another tag, thus:

{
public class AddedBodyPartProps
{
public bool isBionic;
public bool isMutation;
public bool isSolid = true;
public float partEfficiency = 1f;
public ThingDef spawnThingOnRemoved;
}
}


Then link that extra tag into a new check:

// RimWorld.ThoughtPredicates
public static bool HasMutatedBodyPart(Pawn p)
{
foreach (HealthDiff current in p.healthTracker.bodyModel.healthDiffs)
{
AddedBodyPartProps addedBodyPart = current.def.addedBodyPart;
if (addedBodyPart != null && addedBodyPart.isMutation)
{
return true;
}
}
return false;
}


Dead easy, done in 15 seconds. Add <IsMutation>true / false</isMutation> to all your bodyparts, we're good to go.


Problem: I have to alter the main .dll to do this. What's the best prog to alter it in and how to export just that single element as a new .dll please?

skullywag

there's a thread on these forums regarding defining xml for dll use. It involves setting the class to use on the xml next to where you put the "Parent=blah" search "define xml" I'm sure it'll pop up.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?