Disease Code - location? [Biogenic mod]

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

Previous topic - Next topic

Cat123

#15
This is the thread:

https://ludeon.com/forums/index.php?topic=3046.0


Not so useful, given that I'll still be modding the core bodypart stuff, and I'd already gone one stage better than that thread, aka - direct c coding.

Haplo

What you try to do is change the core code from Tynan, correct?
As long as you don't have access to Tynans sourcecode it is nearly impossible to do this. You can't just overwrite/change main code that is not specified to be virtual or overridable.
If it were easily changable like that, we (modders) wouldn't have so much problems implementing specific codes and maintaining the compatibility with our different mods. That is the reason why we do some things in an overly complicated way when it would be rather easy if we had access to the source itself ;)

Oh and you aren't correct when you say you've done one better with pure c# coding. If you do pure c# coding and want to change a small value, you always have to compile a new dll. The better variant is, when you code in c# and define specific variables in the xml. This way you can do small changes for testings in between a restart of RimWorld :)

Cat123

#17
Quote from: Haplo on November 18, 2014, 03:42:08 PM
What you try to do is change the core code from Tynan, correct?
As long as you don't have access to Tynans sourcecode it is nearly impossible to do this. You can't just overwrite/change main code that is not specified to be virtual or overridable.
If it were easily changable like that, we (modders) wouldn't have so much problems implementing specific codes and maintaining the compatibility with our different mods. That is the reason why we do some things in an overly complicated way when it would be rather easy if we had access to the source itself ;)

Oh and you aren't correct when you say you've done one better with pure c# coding. If you do pure c# coding and want to change a small value, you always have to compile a new dll. The better variant is, when you code in c# and define specific variables in the xml. This way you can do small changes for testings in between a restart of RimWorld :)

Ok, yes, I understand that - which is why I've asked twice for help.

>>Problem: I have to alter the main .dll to do this. <<

I even typed the code out directly:

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

and

// 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;
}


How's about running me through exactly how to enact those changes, please? The <isBionic> tag is a single check that's used no-where else, so duplicating it shouldn't exactly be difficult.

Downloading Visual Studio 2013 as I type this - but, tbh, this is hitting the line between "modding" and "coding". 9gig download to add a single fucking tag. >.>

skullywag

ummm 9gig, visual studio express will do. Takes minutes.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Cat123

Quote from: skullywag on November 18, 2014, 04:32:37 PM
ummm 9gig, visual studio express will do. Takes minutes.

Cancelled the full studio, signed up for express.

It's still 6 gigs.

skullywag

My installed folder is just over 1 GB, have they changed the free version recently?
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Haplo

For your problem:
This is how it would normally be done, you make a new class that's based on the old class.
As it's based on the old class, you don't need to repeat their variables. They are already there.
What's a bit of a problem in this case is, that you need to tell the program to use your definition instead of the core definition of the class. Normally Tynan did it nicely that you can define the new class in the xml and the game runs with it. As far as I can see it, that isn't really possible with this case, as it is only defined and used inside the code, without any possibility to change it..
Maybe someone else has an idea how to do that, but from my point of view it's not doable, sorry..
This is one of the cases that look really easy and are really hard to do.


public class MyAddedBodyPartProps : AddedBodyPartProps
{
public bool isMutation;
}

Cat123

#22
Quote from: skullywag on November 18, 2014, 04:46:14 PM
My installed folder is just over 1 GB, have they changed the free version recently?

Express 2013 for win desktop - MS just made a lot of VS open source etc, so that might have changed things.

I'm going to finish off all the XML I can do & bundle it into an alpha release (which 100% won't work). Getting <statbase> and armor defs onto bodyparts and so on is going to be fun. (JuliaEllie's code is going to get ravaged).

<artificialBodyPartsMoney>
<min>1000</min>
<max>1500</max>
</artificialBodyPartsMoney>
<artificialBodyPartsTags>
<li>Advanced</li>
</artificialBodyPartsTags>
<artificialBodyPartsChance>0.003</artificialBodyPartsChance>


Modding this for pawnkinds_mutants.xml is also uggh. I cannot see in ILSpy where <advanced> is actually defined in relation to the bionic bodyparts that are currently in vanilla.

For some basic cyborgs as an event, obviously something like:

<artificialBodyPartsMoney>
<min>5000</min>
<max>15000</max>
</artificialBodyPartsMoney>
<artificialBodyPartsTags>
<li>Advanced</li>
</artificialBodyPartsTags>
<artificialBodyPartsChance>0.5</artificialBodyPartsChance>


Would work. But... no tags, nothing I can spot that defines which bodyparts are advanced. Logically, it'd be the <isbionic> tag, but nooooo.

Quote from: Haplo on November 18, 2014, 05:05:34 PM
As far as I can see it, that isn't really possible with this case, as it is only defined and used inside the code, without any possibility to change it..
Maybe someone else has an idea how to do that, but from my point of view it's not doable, sorry..
This is one of the cases that look really easy and are really hard to do.

What about just cloning it & using the tag MutatedBodyParts instead?

<HealthDiffDef Name="MutatedBodyPartBase" Abstract="True">
    <naturallyHealed>true</naturallyHealed>
  </HealthDiffDef>


Then the new items would use the cloned class, which would function exactly the same (apart from "<isbionic>" > "isMutation").

p.s.

Tynan is a beast with this code base. Makes content modders depressed though.

Haplo

Most likely it would be like this:
<HealthDiffDef Class="MutationMod.MutatedBodyPartBase"...>
Then you can read it with your code.
The base code won't access it, but that's really not needed, so yes, it can maybe work.