Barotrauma Guide

How to add an Item to your Mod for Barotrauma

How to add an Item to your Mod

Overview

Description how I work from a raw Image to the finished Item in Barotrauma. 1. Get Images2. Edit them in Gimp3. Add it to Barotraumas XMLThis does NOT explain how to create a mod or upload it.

Introduction

Its a rainy day, and so I decided to add a bag Item to my Mod , and while doing so, also write all steps down.
[link]

This Guide will show you how to Add an Item, and how I prepare my Images to archive a “Baroish” look, in a quick way.

1. Acquire the files:

If you like me, your drawing skills won’t be sufficient to simply draw a new Object, so we use instead photos of an Object.
First you can make it yourself and Copy it to your PC, or use one from the Internet. If you use Google Image search, make sure to select
Tools -> marked as copyright and royalty free
if you found a Picture, make sure the page itself containing the Image explicit mark the image as use-free and check if you have to contribute any author naming like this one:
[link]
There are no Problems with the copyright, but technical the Image is not greater to use; its because the Photo was took in an angle. So if you make Images or use already made ones, try to get strait side views of Items because Barotrauma is an 2D sidescrool platformer. So we have to finde One with better Proportions, so after some search I found this one:
[link]
Keep in mind to check its copyright again.

2. Change your Raw Image to a usable Texture- (Atlas)

Open your Raw Texture into Gimp. Personly I like to work with an oversized resolution of the final Image, so Details getting a bit blurry in the process are still sharp when finished. This Image has about 1000px, and my bag will become 128px, so that’s OK.


Now select the lasso Tool, Zoom in, and start Clicking around the Bag. If you Are Around Select the Rectangle Tool, witch will change your selection with a dashed line. Now Just Copy by pressing Ctrl-C, and paste it with Ctrl-Shift-V into a new Picture.
If Any Background you like to remove is still there, repeat.

Now its time to Change the Image a bit, add missing pieces or if you like a second Zipper and so on. Just the Art part.
Use the Rectangle Selection Tool to duplicate Parts like the Belt, to extend to the right. Select, Ctrl-C, Ctrl-V to copy and past it to the file, and click on the Bottom left the Icon for New Layer. Now you can move your new Belt “behind” The Bag, so it blends nicely in. If you are done, right klick your layers and select “combine visible layers”, merging all layers together, so they become editable as one layer.


To “remove” those pink pieces in front, you have to use the Stamper and plaster: both are used the same, but the stamper has sharper edges and is someway more direct. So Select with your Ctrl Key pressed down the source, and than click or drag where you like to add the Source Parts. Than if you roughly drawn the Area, repeat with the Plaster Tool, to smoothen things up.

Next step is to change the whole Color of the Image: use the right click Context menu -> Colors, to alter Hue, Saturation, Contrast, Brightness and so on. Just play a bit with the Rulers.

Now we get Rid of the “Colorful Border of your Item. If you look closely most times the Border is just in the Bags Color, or has Color left over by the Background, witch makes Items look in game just as Papercutouts. To blend this in, I like to use a simple Trick, a Black Outline or Shadow.
Right Click your layer in the Layer Window, and Select “Selection from Alphachannel”
than right click your Image, Selection -> shrink and set it to 1px.
Now right Click again, Selection -> Invert, witch selects every around your bag plus 1 px.
In the Lower left corner Add a new Layer, Your selection should stay. With the Fill tool, Fill the whole Selection now Black. Context menu -> Selection -> nothing, to remove the selection, and now you can Blur the Black Layer by right click -> Filters -> Blur -> Gaussian Blur as much as you like.


If you are pleased by your Outline/shadow get the selection from your Bags layer Again, select the black outline Layer, Invert the selection and press the Del key to remove all Black Background and just leave the blurred black at the border of your bag.
(this is done more quickly than read, and if you read so far, you will manage that.)


One Last Step in texture preparation: Putting all together and saving:
right click your layers and select “Merge visible Layers”. Now right click your Image, select Image -> Scale Image, and now shrink it to your desired Texture file Resolution. For a Bad this Size I would choose 128px in width, depends on the size of your actually Object, and if its just Background or hold in hand. Working long times with Opengl just let me Working in powers of 2, so that’s why I like to use Textures Sizes like 64,128,256,512, but you are more free in Barotrauma.
Now save your Object just as single file, or if you have more Objects in a Textureatlas (is just a bigger file with more Objects in).
I like to use a file size like 512px x 512px witch let me put 16 Items in with 128 squered px. Save as png in your mod folder.

3. Create the XML tag

Now the fun part: Open the Barotrauma Folder, and there the /Content folder. Here you have all Vanilla Stuff, you can use as Template. Pick one that gets as close as you can.
For me, because its a bag, I use the Toolbox: Open Content/Items/Tools/Tools.xml with any Text Editor, and copy the whole File to your Mod folder, remove any Item except the Toolbox, and alter its Values:
– Name is the Displayed Name,
– Identifeyer is the Unique Name the Game uses
– and the tag properties called Texture, to the path of your Texture (iE: Mods/Your Mod/myBag.png)
– and last you have to set the sourcerect to display the bag, sourcerect=”left, top, width, height” (my values are 0,128,128,128)
(and that’s why I stick to multiples of 2, because its easy form than with those rectangle values.)
Now you can change the Items Scale by change the scale property of the items Tag itself scale=”0.4″

<Item name=”Toolbox” identifier=”smc-bag” category=”Equipment” tags=”smallitem” fireproof=”true” description=”” impactsoundtag=”impact_metal_heavy”> <Deconstruct time=”10″> <Item identifier=”fabric” /> </Deconstruct> <Fabricate suitablefabricators=”fabricator” requiredtime=”20″> <RequiredSkill identifier=”mechanical” level=”20″ /> <Item identifier=”steel” /> </Fabricate> <InventoryIcon texture=”Mods/Schorotes More Content Mod/Items/Tools/Bag.png” sourcerect=”0,128,128,128″ origin=”0.5,0.6″ /> <Sprite texture=”Mods/Schorotes More Content Mod/Items/Tools/Bag.png” sourcerect=”0,128,128,128″ origin=”0.5,0.5″ /> <!–<Sprite texture=”Content/Items/Containers/crates.png” depth=”0.54″ sourcerect=”1,0,68,39″/>–> <Body width=”45″ height=”31″ density=”20″ /> <MeleeWeapon slots=”RightHand+LeftHand,Any” controlpose=”true” aimpos=”45,10″ handle1=”0,10″ handle2=”-15,10″ holdangle=”0″ reload=”1″ range=”50″ combatpriority=”5″ msg=”ItemMsgPickUpSelect”> <Attack structuredamage=”10″ stun=”0.6″> <Affliction identifier=”internaldamage” strength=”2″ /> <Sound file=”Content/Items/Weapons/Smack2.ogg” range=”800″ /> </Attack> </MeleeWeapon> <ItemContainer capacity=”12″ keepopenwhenequipped=”true” movableframe=”true”> <Containable identifiers=”smallitem” excludedidentifiers=”toolbox” /> </ItemContainer> </Item>

And that’s all to add a new Object. There are Additional Steps, like the Localfiles, for Description and so on, but that’s a topic on its own, like general mod creation and publishing.

Sure, you can now go on further. Change the description, sound, fabricate, deconstuct and all other propeties as you like.

And maybe you like to contribute the Photos Authors name in a readme?

Regards, Schorote.

Author of the First Image: peakpx.com (didn’t found any author info)
Author of the used Image: [link]

SteamSolo.com