RimWorld

RimWorld

Drop Loot When Destroyed Framework
 Denne tråd er blevet fastgjort, så den er sikkert vigtig
Romyashi  [udvikler] 5. aug. 2023 kl. 8:02
Instructions for implementing
Currently there are two ways of implementing the framework -- one with comps and one for filth.
Note: Remove the comments that start with "<=" from your XML files if you copy text from here, they are made for the instructions only and will crash your game.

Comp:
<comps> <li Class="DLWDFramework.DLWDThingCompProps"> <DropOnlyOne>true</DropOnlyOne> <= Optional. When set to true will ensure that if one loot thing has dropped no other loot from the list will drop. <GuaranteeOne>true</GuaranteeOne> <= Optional. When set to true will ensure that at least one loot thing from the list will drop. Do not use on filth that generates naturally a lot, like rock rubble, otherwise the game will not load any new map. Do not use on a plant that has both vanilla harvestAfterGrowth tag and this mod's HasToBeHarvestable tag. <LootConfigs> <li> <LootThingDef>Steel</LootThingDef> <= The defName of the desired ThingDef to be dropped. <LootChance>0.6</LootChance> <= The chance for the thing to drop, ranging from 0.00 to 1.00. <LootAmountMin>5</LootAmountMin> <= Minimum and maximum amount of loot to drop. The code will randomize the amount between these two numbers. <LootAmountMax>10</LootAmountMax> <HasToBeHarvestable>true</HasToBeHarvestable> <= Only for plants. Specifies if the plant has to be harvestable for the loot to drop. If set to false or not set at all the loot will drop at any growth stage. <ForbiddenWhenDropped>false</ForbiddenWhenDropped> <= Optional. Specifies if the loot will be forbidden when dropped outside of home area. If not set to false will default to true. <HasToBeDestroyedIntentionally>true</HasToBeDestroyedIntentionally> <= Optional. Makes it so the loot drops only when the parent is destroyed by harvesting, cutting, mining or deconstructing. Ignores ForbiddenWhenDropped flag, makes the loot not forbidden. </li> <li> <= This way you can add as many loot drops as you want. <LootThingDef>WoodLog</LootThingDef> <LootChance>0.6</LootChance> <LootAmountMin>5</LootAmountMin> <LootAmountMax>10</LootAmountMax> </li> </LootConfigs> </li> </comps>

Filth is pretty much exactly the same except that the properties are set in the mod extensions.
Filth:
<thingClass>DLWDFramework.DLWDFilth</thingClass> <= This class contains code necessary for drops to work. Filth cannot have comps, so it is done with a class and a mod extension. <modExtensions> <li Class="DLWDFramework.FilthLootExtension"> <DropOnlyOne>true</DropOnlyOne> <GuaranteeOne>true</GuaranteeOne> <LootConfigs> <li> <LootThingDef>Steel</LootThingDef> <LootChance>0.6</LootChance> <LootAmountMin>5</LootAmountMin> <LootAmountMax>10</LootAmountMax> </li> </LootConfigs> </li> </modExtensions>

There is also a comp that allows for item to self destruct when it is used. There is one in vanilla as well, but it crashes with this framework, so use this one instead:
<comps> <li Class="CompProperties_Usable"> <= Vanilla comp to allow using of items. <useJob>UseItem</useJob> <useLabel>Use {0_label}</useLabel> </li> <li Class="DLWDFramework.DLWDDestroySelfComp" /> <= Use only with CompProperties_Usable. Makes it so that when the item is used it gets destroyed. <comps>
Sidst redigeret af Romyashi; 3. maj 2024 kl. 7:51
< >
Viser 1-15 af 25 kommentarer
tanyfilina 12. aug. 2023 kl. 10:22 
Hello!
I've tried to make a patch for another mod with this instruction, but it had broken my game. The code is following:
<Patch> <Operation Class="PatchOperationSequence"> <success>Always</success> <operations> <li Class="PatchOperationTest"> <xpath>/Defs/ThingDef[defName = "RC2_PlantOrangeTree"]/comps</xpath> <success>Invert</success> </li> <li Class="PatchOperationAdd"> <xpath>/Defs/ThingDef[defName = "RC2_PlantOrangeTree"]</xpath> <value> <comps/> </value> </li> </operations> </Operation> <Operation Class="PatchOperationSequence"> <success>Always</success> <operations> <li Class="PatchOperationTest"> <xpath>/Defs/ThingDef[defName = "RC2_PlantOrangeTree"]/comps/li[@Class="DLWDFramework.DLWDThingCompProps"]</xpath> <success>Invert</success> </li> <li Class="PatchOperationAdd"> <xpath>/Defs/ThingDef[defName = "RC2_PlantOrangeTree"]/comps</xpath> <value> <li Class="DLWDFramework.DLWDThingCompProps"> <LootConfigs> <li> <LootThingDef>WoodLog</LootThingDef> <= The defName of the desired ThingDef to be dropped. <LootChance>1.0</LootChance> <= The chance for the thing to drop, ranging from 0.00 to 1.00. <LootAmountMin>15</LootAmountMin> <= Minimum and maximum amount of loot to drop. The code will randomize the amount between these two numbers. <LootAmountMax>25</LootAmountMax> <HasToBeHarvestable>true</HasToBeHarvestable> <= Only for plants. Specifies if the plant has to be harvestable for the loot to drop. If set to false or not set at all the loot will drop at any growth stage. </li> </LootConfigs> </li> </value> </li> </operations> </Operation> </Patch>
Romyashi  [udvikler] 12. aug. 2023 kl. 10:36 
@tanyfilina Do you have the error itself? Is it generated at all? Or the game just closes?
tanyfilina 12. aug. 2023 kl. 11:03 
Black screen and all mods removed from mod-list after reload.
Sidst redigeret af tanyfilina; 12. aug. 2023 kl. 11:10
tanyfilina 12. aug. 2023 kl. 11:08 
I've found this in the player.log:

Exception reading DestroyedLootPatch.xml as XML: System.Xml.XmlException: Name cannot begin with the '=' character, hexadecimal value 0x3D. Line 35, position 44.
Romyashi  [udvikler] 12. aug. 2023 kl. 11:11 
@tanyfilina Oh, right, makes sense. Remove the comments that start with "<=" from the patch, I made them for the instructions, they should not be in your XMLs. Added this info to the main post.
Sidst redigeret af Romyashi; 12. aug. 2023 kl. 11:53
Romyashi  [udvikler] 12. aug. 2023 kl. 23:35 
@tanyfilina Can you confirm that the framework is enabled and loaded before your patch mod?
Sidst redigeret af Romyashi; 12. aug. 2023 kl. 23:47
tanyfilina 12. aug. 2023 kl. 23:55 
Lol, I'm idiot ))
I'l delete error logs here to clean space )
tanyfilina 13. aug. 2023 kl. 0:26 
Now there are no errors, but the tree I've patched drops no wood when cut.
Romyashi  [udvikler] 13. aug. 2023 kl. 0:43 
@tanyfilina Seems like cutting calls for other code than regular destruction. I will take a look at what I can do to fix this.
Romyashi  [udvikler] 13. aug. 2023 kl. 4:53 
@tanyfilina Should be fixed now. The problem was in the harvestAfterGrowth tag. Now, if the plant has this tag, you have to include <tickerType>Normal</tickerType> somewhere in the def and everything should work. Make sure you have the latest version of the framework.
Sidst redigeret af Romyashi; 13. aug. 2023 kl. 4:57
tanyfilina 13. aug. 2023 kl. 5:40 
In this mod all plants are derived from the base plant that has <tickerType>Long</tickerType>. If I change it to Normal, won't it break something?
Romyashi  [udvikler] 13. aug. 2023 kl. 5:43 
@tanyfilina This is RimCuisine 2, correct? I tested it on it to make sure it's not a problem with that mod specifically and no, nothing breaks when you add a tickerType that is different from it's base. At least I did not see if anything was broken, haha.
Sidst redigeret af Romyashi; 13. aug. 2023 kl. 5:43
tanyfilina 13. aug. 2023 kl. 5:43 
Yes ) Thank you!
tanyfilina 13. aug. 2023 kl. 6:19 
Now everything works (although it works only with each tree separately, I've tried to modify the whole class - RC2_DeciduousTreeBase - didn't work). The only little problem left is that the new dropped loot is forbidden.
Romyashi  [udvikler] 13. aug. 2023 kl. 6:30 
@tanyfilina All loot outsife of home area will be forbidden. This is to avoid situations where trees, for example, die on the edges of the map and your colonists will spend half a day hauling stuff from there. I may add another flag for forbidding or unforbidding though, will notify you when I do so.
< >
Viser 1-15 af 25 kommentarer
Per side: 1530 50