Barotrauma

Barotrauma

38 betyg
How to add an Item to your Mod
Av [bk]schorote
Description how I work from a raw Image to the finished Item in Barotrauma.

1. Get Images
2. Edit them in Gimp
3. Add it to Barotraumas XML

This does NOT explain how to create a mod or upload it.
   
Utmärkelse
Favorit
Favoritmarkerad
Avfavoritmarkerad
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.
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=1848030345

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:
http://www.peakpx.com/603931/brown-duffel-bag
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:
https://pixabay.com/photos/homeless-man-person-tramp-55492/
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: https://pixabay.com/users/arttower-5337/
5 kommentarer
Sergeant 18 jan, 2023 @ 14:29 
depth -- defines the Z axis offset of item's sprite in-game, where 0.001 is foreground and 0.999 is background.
InventoryIconSprite -- representation of item in inventory bar. Takes same parameters as Sprite tag. Item will be present with main sprite as inventory icon once this tag is omitted.
Upgrade -- usually defines the game version item is defined to be used in with respective parameter gameversion=... as it's required for proper operation of game's equipment upgrade system.
Body -- definition of item hitbox and behavior once put in water. Takes three parameters: width, height and density, where density=10 makes item neutrally buoyant (staying still in water while idle). Not needed for stationary items such as machinery.
scale -- float number that indicates the size of item in-game compared to source sprite size. For example, scale=0.5 will make item two times smaller than sprite's initial size.
Sergeant 18 jan, 2023 @ 14:28 
Majority of items includes the following components:

file -- used to define location of sprite. Without directory given, this parameter will refer to file with entered name in same directory as item file.
sourcerect -- array of four numbers used to define the section of image used as item's sprite. Source rect selection syntax is defined like this: [selection_start_left],[selection_start_top],[width_from_left],[height_from_top]. For example, sourcerect=0,64,64,64 will select area of 64x64 on left edge and 64 pixels down from top edge.
origin -- offset of sprite's central point. Consists of two float numbers: [origin_x],[origin_y], where value of 0 is left or top edge and value of 1 is right or bottom edge. Majority of sprites are considered to be displayed with sprites located in the middle, which is origin=0.5,0.5. Pay attention that float numbers are defined with dot as divider rather than comma, as comma plays role of value separation in array.
Jarlsh Rels 3 jan, 2022 @ 18:06 
Maybe I'll try to make usable coffee cup and maker. the for the guide
Gãs 2 jan, 2022 @ 17:44 
This is exactly what I needed, thank you very much!:captainclown:
PrideGroupIsEvil 18 jun, 2021 @ 20:51 
This typo's and errors in this guide make it hard to read.