Barotrauma Wiki
Advertisement



  • This guide is designed for use with Windows operating systems. Information on other operating systems will vary.

Creating a Content Package from scratch may seem like a difficult task, but once you understand the basics it becomes easy. This tutorial is here to help new users create their first Content Package.

In this example, we will be creating a melee weapon.

Beginning[]

Before we can start creating content, we need to define the Content Package. Find a folder called Content Packages in the Data folder in your Barotrauma directory (it should look like this: \Barotrauma Go To The Official Barotrauma Wiki\Data\ContentPackages) and copy & paste the file called "Vanilla 0.9". Once you have your new copy, name it "Unarmed", then right click on it and click "Edit".

Immediately, you'll see a lot of lines of code, all defining file paths. This is how the game knows where to find content. For now, we'll just be looking at the second line. It should look like this:

<contentpackage name="Vanilla 0.8" path="Data/ContentPackages/Vanilla 0.8">

Now let's change it to look like this:

<contentpackage name="Unarmed" path="Data/ContentPackages/Unarmed">

Once you're done, save the file, but don't close out of it - we'll need to change it later.

Content[]

Setting up the Folder[]

After we've defined the Content Package, we need to create a content folder for it. This is actually rather easy - navigate to \Barotrauma Go To The Official Barotrauma Wiki\Mods and create a new folder there, named "Unarmed". This will henceforth be referred to as the Mod Folder.

Creating our Weapon[]

In order to create our weapon, we'll be learning from existing code. Navigate to \Barotrauma Go To The Official Barotrauma Wiki\Content\Items\Weapons and find two files: weapons.xml and weapons.png. Copy and paste them both into the Mod Folder.

Once they're in place, right-click on weapons.xml and click "Edit". Much like our Content Package definition, you'll be met with many lines of code - scroll down until get to the bottom. Once there, copy and paste the following code just above the line that says </Items>:

<Item
    name="Unarmed"
    category="Equipment"
    Tags="smallitem,weapon"
    pickdistance="150"
    price="5"
    description="Pow! If you don't have a Harpoon Gun on you, why not just use your fists?">

    <Deconstruct time="0">
    </Deconstruct>

    <Sprite texture="weapons.png" sourcerect="21,0,77,22" depth="0.55"/>
    
    <Body width="30" height="30" density="30"/>

    <MeleeWeapon slots="Any,RightHand,LeftHand"
              aimpos="50,0" handle1="-5,0" holdangle="10" reload="0.3">
      <Attack damage="20" stun="1" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/> 
    </MeleeWeapon>
  </Item>

Then save the file and exit.

Defining our Weapon[]

Before it can be found in-game, you need to define the weapon. Head on over to the Content Package definition we created in the beginning of the tutorial. You'll need to find a line just over halfway through the code that looks like this:

<Item file="Content/Items/Weapons/weapons.xml" />

Change it to look like this:

<Item file="Mods/Unarmed/weapons.xml" />

Then save the file one last time.

Playing[]

After you've completed the previous steps, open up the Barotrauma Launcher and press the "Content package" button. Select "Unarmed" from the dropdown menu that opens up. Then, press the big grey 'START' button. If all goes well, the game feels like playing nice and you followed the guide, it should launch with no problems.

FAQ[]


  • Q: Barotrauma crashed while playing the Content Package!
  • A: This happens regularly. Barotrauma is an unpolished game, and is very prone to bugs - crashes with Content Packages are to be expected.


  • Q: Where can I find the content I implemented?
  • A: Items can be found in the pre-level Shop (if you gave them a Price value) or can be placed in the Submarine Editor.


  • Q: What about creatures?
  • A: Creatures are, obviously, a different matter entirely. You'll have to create a new Random Events file and some other things. The guide will likely be updated in the future to reflect creatures.


  • Q: The unarmed weapon is invisible!
  • A: That is indeed the nature of unarmed weaponry. If you want to give it a sprite, you are free to do so yourself. This guide does not currently cover spriting, but will likely be updated to do so in the future.


  • Q: How do I use the unarmed weapon?
  • A: Once it is in either of your hand slots, right click to ready it and then left click to throw a punch.

References[]

https://steamcommunity.com/sharedfiles/filedetails/?id=1896847566

Advertisement