[A17] Experience gain

Started by corruptsoul, October 30, 2017, 03:36:19 PM

Previous topic - Next topic

corruptsoul

I am making a mod that brings a the allowed crafting skill to rolling smokeleaf joints. I brought it back by adding "Crafting" to the <workSkill> in the defs, but this also makes rolling joints give crafting xp. I want to either reduce it or bring it all the way to zero. Where is experience gain handled? I have looked at a lot of different defs but I can't seem to find anything regarding xp gain. I also can't find anything in the jobs or bill parts of the C# code. Any help is appreciated.

Spar10Tech

Right after your workSkill def try adding something like below.  This is the stats from making stone blocks in the 'Recipes_Production.xml'


<workSkill>Crafting</workSkill>
<workSkillLearnFactor>0.3</workSkillLearnFactor>

corruptsoul

I tried adding it, but unfortunately  that tag doesn't correspond to any field in type RecipeMakerProperties. Im starting to think that the drugs are made differently than other craftable objects, and that I might just need to find the C# file that does experience, or builds the drugs, and modify things there.

Spar10Tech

you could try adding a new recipe def that can be used at the crafting spot.  It wouldn't replace the existing one but might accomplish what you want.  Below is a code snip-it from another mod that adds the ability to craft several joints at once.

<?xml version="1.0" encoding="utf-8" ?>
<RecipeDefs>
<RecipeDef>
<defName>FiveSmokeleafJoint</defName>
<label>make (5) smokeleafjoint</label>
<description>Make five smokeleafjoint.</description>
<jobString>Crafting smokeleafjoint.</jobString>
<workAmount>2000</workAmount>
<workSpeedStat>DrugProductionSpeed</workSpeedStat>
<workSkill>Crafting</workSkill>
<workSkillLearnFactor>0.3</workSkillLearnFactor>
<ingredients>
<li>
<filter>
<thingDefs>
<li>SmokeleafLeaves</li>
</thingDefs>
</filter>
<count>20</count>
</li>
</ingredients>
<fixedIngredientFilter>
<thingDefs>
<li>SmokeleafLeaves</li>
</thingDefs>
</fixedIngredientFilter>
<products>
<SmokeleafJoint>5</SmokeleafJoint>
</products>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>6</minLevel>
</li>
</skillRequirements>
<recipeUsers>
<li>CraftingSpot</li>
<li>DrugLab</li>
</recipeUsers>
</RecipeDef>
</RecipeDefs>

corruptsoul

#4
That worked when I make a new RecipeDef, however the old recipe is still there like you said. Im now trying to get rid of that. Also I need help understanding what to name the xml file. Its named Smokeleaf.xml right now and thats working because its overriding the old one (I think). What do I have to do to make it its own name? That might help in taking the old recipe off of the crafting spot. I'm trying to just get rid of the <recipeMaker> and see if that will take it off the crafting spot.

Edit: That did remove the old recipe from the crafting spot.

Spar10Tech

So did you just do a new xml to overwrite the original smokeleaf drug properties to not include <recipeMaker> section?  You might want to try an xpath patch to remove the section.

It doesn't really matter what you name the XML file but it is good practice to give it a prefix for your mod or author.  I tend to make all my custom xml files like ST_smokeleaf.xml.

Out of curiosity what is your mod? and what all is it going to do?  I might know of some other mods to use for examples that might help you. 


corruptsoul

Its called Quality Joints. I made it mostly because I was annoyed that my constructor would make joints instead of stone blocks, so I wanted to give the allowed crafting skill to the make joints work order. Yes I just made a copy of the smokeleaf xml to not include <recipeMaker>. It worked on its own, but when I tried to include it with the new recipe, it didnt work. I'll look into the xpath patch and see what it does. I'm completely new so I'm just learning the tools I can use. The reason I asked about xml names is cause it doesn't work when I have the new recipe in a file named QualityJoints.xml, just it worked when it was called smokeleaf.xml.

Spar10Tech

If you had both of the edits in one xml it probably wouldn't work in A17.  The smokeleaf thingdef is in a root def <Smokeleaf> while the new recipe def should be inside a root def <RecipeDefs>.

If you want help with the XPath stuff just ask.  I just finished converting some of my personal mods to use xpath patches.  Here is a link that was helpful for me to learn the patch operations.
https://gist.github.com/MatchSG/13c82aae25262bcb70554fbec16973d7
You'll probably need to use the <Operation Class="PatchOperationRemove"> to delete the <recipeMaker> node.