Making recipes do more (Increase ExtractMetalFromSlag metel output)

Started by Daman453, April 26, 2015, 01:23:12 PM

Previous topic - Next topic

Daman453

How would i do that? I am in the RecipeDef folder. If the title confused you, I mean when you get a smelter, you can get slag chunks and put that into metal, i wish to increase the amount i get from doing it.
Quote from: StorymasterQ on February 02, 2016, 08:19:52 PM
For flu, try a cock. If that doesn't work, try boobmilk. Nice.


1000101

Some recipes are defined in code.   This includes smelting, butchery, tailoring, etc.

You can however influence them through xml although some things are constants.

RaceProperties:variable:
   float meatAmountMultiplier = 1.0
   bool hasLeather
constants:
   const float BaseButcherMeatAmount = 90.0
   const float BaseButcherLeatherAmount = 20.0


ThingDef:variables:
   RecipeMakerProperties recipeMaker
   List<ThingCount> smeltProducts


Where ThingCount:variables:
    ThingDef thingDef
    int count


RecipeMakerProperties starts getting more complex and is used for apparel and weapons.  I won't get into that here but if you decompile Assembly-CSharp you can find everything you need on everything in the game.

Just keep in mind that the more you change, the less compatible your mod will be.  If it's for your own use, no problem as you can resolve all that on your own.  But, if you plan on releasing a mod for general use, you need to prepare for "does not work with X."  This is why most mods add new things and change little of the core game.  Those that do change the core game usually state, "will conflict with anything that modifies x, y and z."
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

Daman453

Quote from: StorymasterQ on February 02, 2016, 08:19:52 PM
For flu, try a cock. If that doesn't work, try boobmilk. Nice.


Daman453

<RecipeDef>
    <defName>ExtractMetalFromSlag</defName>
    <label>smelt metal from slag</label>
    <description>Use heat and strong electromagnets to separate useful metal from slag chunks.</description>
    <jobString>Smelting metal from slag.</jobString>
    <workAmount>1600</workAmount>
    <workSpeedStat>SmeltingSpeed</workSpeedStat>
    <effectWorking>Smelt</effectWorking>
    <soundWorking>Recipe_Smelt</soundWorking>
    <ingredients>
      <li>
        <filter>
          <thingDefs>
            <li>ChunkSlagSteel</li>
          </thingDefs>
        </filter>
        <count>1</count>
      </li>
    </ingredients>
    <specialProducts>
      <li>Smelted</li>
    </specialProducts>
    <fixedIngredientFilter>
      <thingDefs>
        <li>ChunkSlagSteel</li>
      </thingDefs>
    </fixedIngredientFilter>
  </RecipeDef>

That's the code for ExtractMetalFromSlag in the RecipeDef, so what do i do here? I got some of your post, but not all of it.
Quote from: StorymasterQ on February 02, 2016, 08:19:52 PM
For flu, try a cock. If that doesn't work, try boobmilk. Nice.


1000101

That's in the RecipeDefs, you want to be in ThingDefs.

Defs/ThingDefs/Various_Stone.xml  <ThingDef ParentName="ChunkBase">
    <defName>ChunkSlagSteel</defName>
    <label>steel slag chunk</label>
    <graphicPath>Things/Item/Chunk/ChunkSlag</graphicPath>
    <graphicClass>Graphic_Random</graphicClass>
    <soundDrop>ChunkSlag_Drop</soundDrop>
    <thingCategories>
      <li>Chunks</li>
    </thingCategories>
    <smeltProducts>
      <Steel>10</Steel>
    </smeltProducts>
  </ThingDef>


Quote from: 1000101 on April 26, 2015, 02:22:32 PMThingDef:variables:
   RecipeMakerProperties recipeMaker
   List<ThingCount> smeltProducts


Where ThingCount:variables:
    ThingDef thingDef
    int count

Not every property is required and some have defaults if they are.  "recipeMaker" and "smeltProducts" are optional and have no defaults.  "defName" is required and the game will throw an error and assign one.  "useHitPoints" is optional and the default is true.

"ChunkSteelSlag" is inheriting all the properties of "ChunkBase".  It does so by declaring ParentName="ChunkBase".  Some properties must be defined on an as-per basis such as "defName" and this particular value must be unique in it's class (ThingDef, RecipeDef, SomeOtherClassDef).

A handy tool to use when looking for strings when mod making is grep (example finding all instances of "ChunkSteelSlag").  I use wingrep.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

Daman453

Quote from: StorymasterQ on February 02, 2016, 08:19:52 PM
For flu, try a cock. If that doesn't work, try boobmilk. Nice.