Changing the Prices of Items¶
Here, the price of multiple several items will be changed to demonstrate an example structure for the mod.
The files used are available separately or zipped. You can see the output here.
First, we’ll need to build the folder for the Mod Generator to use as input. Make new files and folders until you have the following:
ItemPriceMod
├── filelist.xml
└── Content
└── Items
├── Misc
| └── misc.xml
└── Weapons
└── weapons.xml
Here, filelist.xml will be copied over and misc.xml and weapons.xml will be diff files instructing the Generator to change certain files.
The same structure as vanilla’s Content directory is used, but this is down to preference.
Keeping the same vanilla structure makes it easier to tell what each file modifies.
Now, edit filelist.xml to contain the relevant information.
<?xml version="1.0" encoding="utf-8"?>
<contentpackage name="Item Price Mod" path="Mods/ItemPriceMod/filelist.xml" corepackage="false" gameversion="0.10.4.0">
<Items file="Mods/ItemPriceMod/Content/Items/Weapons/weapons.xml"/>
<Items file="Mods/ItemPriceMod/Content/Items/Misc/misc.xml"/>
</contentpackage>
With filelist.xml in place, we can now edit the diff files.
Starting with misc.xml, define a basic diff element:
<?xml version="1.0" encoding="utf-8"?>
<Diff file="Content/Items/Misc/misc.xml" override="root" cleanup="true">
</Diff>
Now add elements that change the properties of that file. Reading the vanilla file, we see:
<?xml version="1.0" encoding="utf-8"?>
<Items>
<Item name="" identifier="guitar" category="Misc" Tags="bigitem" scale="0.5" description="" price="300" isshootable="true">
<Upgrade gameversion="0.9.2.0" scale="0.5"/>
<PreferredContainer primary="crewcab" spawnprobability="0.01"/>
<Price baseprice="50" soldeverywhere="false">
<Price locationtype="outpost" multiplier="1" minavailable="1" />
<Price locationtype="city" multiplier="1" sold="false"/>
<Price locationtype="research" multiplier="1" sold="false"/>
<Price locationtype="military" multiplier="1" sold="false"/>
<Price locationtype="mine" multiplier="1" sold="false"/>
</Price>
<InventoryIcon texture="Content/Items/InventoryIconAtlas.png" sourcerect="512,256,64,64" origin="0.5,0.5" />
<Sprite texture="Misc.png" sourcerect="0,0,97,254" depth="0.5" origin="0.5,0.5" />
<Body radius="40" height="160" density="12" />
<Holdable slots="RightHand+LeftHand" controlpose="true" aimpos="50,0" handle1="-2,0" handle2="10,50" swingamount="10,20" swingspeed="1" swingwhenusing="true" msg="ItemMsgPickUpSelect">
<StatusEffect type="OnUse" target="Character">
<Conditional HasStatusTag="!equals clown" />
<sound file="Content/Items/Misc/Guitar1.ogg" type="OnUse" selectionmode="CharacterSpecific" range="600" loop="true" />
<sound file="Content/Items/Misc/Guitar2.ogg" type="OnUse" selectionmode="CharacterSpecific" range="600" loop="true" />
<sound file="Content/Items/Misc/Guitar3.ogg" type="OnUse" selectionmode="CharacterSpecific" range="600" loop="true" />
</StatusEffect>
<StatusEffect type="OnUse" target="Character">
<Conditional HasStatusTag="clown" />
<sound file="Content/Items/Misc/GuitarClown.ogg" type="OnUse" range="600" loop="true" />
</StatusEffect>
</Holdable>
</Item>
</Items>
The rest of the file has been left out for clarity.
To change the price of an item, we need to edit the baseprice attribute of the Price element, and the multiplier on each of the locationtypes.
Since we’re changing values that are already present, we use the replace element.
Let’s increase the guitar’s baseprice, and make it cheaper at cities.
Update our misc.xml diff to be:
<?xml version="1.0" encoding="utf-8"?>
<Diff file="Content/Items/Misc/misc.xml" override="root" cleanup="true">
<replace sel="/Items/Item[@identifier='guitar']/Price/@baseprice">100</replace>
<replace sel="/Items/Item[@identifier='guitar']/Price/Price[@locationtype='city']/@multiplier">0.5</replace>
</Diff>
Now we can run the Mod Generator to check the output.
<?xml version="1.0" encoding="utf-8"?>
<Override>
<Items>
<Item name="" identifier="guitar" category="Misc" Tags="bigitem" scale="0.5" description="" price="300" isshootable="true">
<Upgrade gameversion="0.9.2.0" scale="0.5" />
<PreferredContainer primary="crewcab" spawnprobability="0.01" />
<Price baseprice="100" soldeverywhere="false">
<Price locationtype="outpost" multiplier="1" minavailable="1" />
<Price locationtype="city" multiplier="0.5" sold="false" />
<Price locationtype="research" multiplier="1" sold="false" />
<Price locationtype="military" multiplier="1" sold="false" />
<Price locationtype="mine" multiplier="1" sold="false" />
</Price>
<InventoryIcon texture="Content/Items/InventoryIconAtlas.png" sourcerect="512,256,64,64" origin="0.5,0.5" />
<Sprite texture="Misc.png" sourcerect="0,0,97,254" depth="0.5" origin="0.5,0.5" />
<Body radius="40" height="160" density="12" />
<Holdable slots="RightHand+LeftHand" controlpose="true" aimpos="50,0" handle1="-2,0" handle2="10,50" swingamount="10,20" swingspeed="1" swingwhenusing="true" msg="ItemMsgPickUpSelect">
<StatusEffect type="OnUse" target="Character">
<Conditional HasStatusTag="!equals clown" />
<sound file="Content/Items/Misc/Guitar1.ogg" type="OnUse" selectionmode="CharacterSpecific" range="600" loop="true" />
<sound file="Content/Items/Misc/Guitar2.ogg" type="OnUse" selectionmode="CharacterSpecific" range="600" loop="true" />
<sound file="Content/Items/Misc/Guitar3.ogg" type="OnUse" selectionmode="CharacterSpecific" range="600" loop="true" />
</StatusEffect>
<StatusEffect type="OnUse" target="Character">
<Conditional HasStatusTag="clown" />
<sound file="Content/Items/Misc/GuitarClown.ogg" type="OnUse" range="600" loop="true" />
</StatusEffect>
</Holdable>
</Item>
</Items>
</Override>
This method will work for any number of items in the same file. One diff per file is required, but one file could also have multiple diffs to make some things clearer (such as editing multiple items in it in complex ways).
Here’s our weapons.xml diff:
<?xml version="1.0" encoding="utf-8"?>
<Diff file="Content/Items/Weapons/weapons.xml" override="root" cleanup="true">
<!--Harpoon-->
<replace sel="/Items/Item[@identifier='spear']/Price/@baseprice">60</replace>
<!--Explosive Harpoon-->
<replace sel="/Items/Item[@identifier='explosivespear']/Price/@baseprice">500</replace>
<!--Harpoon Gun-->
<replace sel="/Items/Item[@identifier='harpoongun']/Price/Price[@locationtype='outpost']/@multiplier">2.0</replace>
<replace sel="/Items/Item[@identifier='harpoongun']/Price/Price[@locationtype='city']/@multiplier">1.5</replace>
<replace sel="/Items/Item[@identifier='harpoongun']/Price/Price[@locationtype='research']/@multiplier">1.5</replace>
<replace sel="/Items/Item[@identifier='harpoongun']/Price/Price[@locationtype='military']/@multiplier">0.5</replace>
<replace sel="/Items/Item[@identifier='harpoongun']/Price/Price[@locationtype='mine']/@multiplier">1.5</replace>
</Diff>
Running the Mod Generator on the input directory will produce the same result as the pre-generated version.
This concludes the Item Price tutorial.