边缘世界 RimWorld

边缘世界 RimWorld

Drop Loot When Destroyed Framework
 此主题已被置顶,因此可能具有重要性
Romyashi  [开发者] 2023 年 8 月 5 日 上午 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>
最后由 Romyashi 编辑于; 2024 年 5 月 3 日 上午 7:51
< >
正在显示第 1 - 15 条,共 25 条留言
tanyfilina 2023 年 8 月 12 日 上午 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  [开发者] 2023 年 8 月 12 日 上午 10:36 
@tanyfilina Do you have the error itself? Is it generated at all? Or the game just closes?
tanyfilina 2023 年 8 月 12 日 上午 11:03 
Black screen and all mods removed from mod-list after reload.
最后由 tanyfilina 编辑于; 2023 年 8 月 12 日 上午 11:10
tanyfilina 2023 年 8 月 12 日 上午 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  [开发者] 2023 年 8 月 12 日 上午 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.
最后由 Romyashi 编辑于; 2023 年 8 月 12 日 上午 11:53
Romyashi  [开发者] 2023 年 8 月 12 日 下午 11:35 
@tanyfilina Can you confirm that the framework is enabled and loaded before your patch mod?
最后由 Romyashi 编辑于; 2023 年 8 月 12 日 下午 11:47
tanyfilina 2023 年 8 月 12 日 下午 11:55 
Lol, I'm idiot ))
I'l delete error logs here to clean space )
tanyfilina 2023 年 8 月 13 日 上午 12:26 
Now there are no errors, but the tree I've patched drops no wood when cut.
Romyashi  [开发者] 2023 年 8 月 13 日 上午 12: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  [开发者] 2023 年 8 月 13 日 上午 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.
最后由 Romyashi 编辑于; 2023 年 8 月 13 日 上午 4:57
tanyfilina 2023 年 8 月 13 日 上午 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  [开发者] 2023 年 8 月 13 日 上午 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.
最后由 Romyashi 编辑于; 2023 年 8 月 13 日 上午 5:43
tanyfilina 2023 年 8 月 13 日 上午 5:43 
Yes ) Thank you!
tanyfilina 2023 年 8 月 13 日 上午 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  [开发者] 2023 年 8 月 13 日 上午 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.
< >
正在显示第 1 - 15 条,共 25 条留言
每页显示数: 1530 50