Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

TheDanaAddams

[Tutorial] The Artist's Guide To Character/item Modding

Recommended Posts

TheDanaAddams    573

It seems people have a lot of difficulty following the existing guides... which also happen to be somewhat out of date... so with this, I'm aiming to present an up-to-date guide that is easy to follow for artists, who really don't have the first clue about coding, and all that technical nonsense. Custom characters with custom items are definitely what the majority of folks want to create, so hopefully this guide will walk you through it in a manner that anybody can follow, regardless of technical skill.
 
What you'll need

  • An image editor: Photoshop, GIMP... doesn't matter - as long as it has a layer system, and can output PNG files with alpha, it'll work.
  • The sample mods/templates: You can download them here. You probably want to make a character, so be sure to get the character and portrait templates.
  • Tex conversion software: The Windows tool can be found here; a Unix (Mac/Linux) tool can be found here.
  • Build renaming software: You will need to be able to change buildnames - you can use the Build Renamer tool here on Windows, or do it "the hard way" and use a Hex Editor on Mac/Linux. I personally use Hex Fiend.
  • Zip editing software: You need to be able to edit the contents of a zip without decompressing it. (I've found that the files don't work if you decompress, change the files, and recompress.) I believe WinRar can do this, on Windows. On Mac, I use BetterZip.
  • Code editor: Any text editor can be used, but something with Lua syntax highlighting is beneficial. You can use Notepad++ on Windows. On Mac, I use TextWrangler.
  • Patience

First things first
I'll walk you through the creation of a character, starting with making the art.
Take the template sheet into your image editor.
(I want to stress that this is not the only way to do it, but it is the way that I personally feel works best.)
 
Once it's loaded in, you should blow the image up to 200% or 400% - this will ensure better quality in the final assets. As the character sheet is fairly large, I find 400% gets a bit data-heavy, so 200% should be enough. Small things like items, we can easily go to 400% with no problems.
 
Now that we've blown the template up to our 'working' resolution, make a layer above the template, and drop the template image's opacity - this will make it easier to focus on your new art.
n49smr.png
Using the template as your guide, draw everything you need - keeping things in line with the template is the best way for it all to be properly aligned in-game, but you may need to adjust things later, depending how far you deviate from the template.
110dhyb.png
The facial expressions, by my observations, are:
A - part of speech animation
B - transition in front blink
C - default front
D - rubbing eyes - also used in blink transition
E - side blink
F - Alternate side blink
G - default side
H - transition to side blink
I - Eating
J - death
K - frontal blink
L - shocked/scared
M - part of speech animation & used when picking food/swapping equip
N - startup - laying unconscious
 
Once that's all done, you're going to want to do the portrait, big portrait, and save slot art.
Again, follow the template.
 
Now that you have all your textures finished, shrink them back down to the original size - then you need to convert them to the .tex format.
A guide explaining how to do this with Matt's TexTools can be found here. On a Unix system, follow the usage guide by Simplex on his tool's download page.
 
Now that we have our .tex files
We're ready to start getting things into the game.
So, duplicate the Sample Character Mod folder, and let's get to work!
 
You will see several files and folders. Let's start with bigportraits.
Inside, we will find wod.tex and wod.xml. Rename the .xml from 'wod' to a unique name for your character.
You should limit it to three letters, and avoid starting with a number.
Now delete wod.tex, and replace the file with your converted bigportrait .tex - which you must name in the same way as the .xml.
 
Following this, we need to edit the .xml - open it with your text editor, and replace both instances of "wod.tex" with your filename.
 
Now open the 'images' folder, and you will see two more folders. One for the select screen portrait, and one for the save slot portrait.
The process for the save slot and select screen portrait is identical to the bigportrait. Rename the files, replace the tex with your new one, and edit the xml.
 
To be on the safe side, I do rename and update the wod_silho files, but I don't believe they are necessary.
 
Replacing the in-game character art is a little trickier, but not that hard.
First, rename the wod.zip to your filename.
Now open it with your zip program.
You will see two files - "atlas-0.tex" and "build.bin" - first, you will need to extract the build.bin file.
 
We need to edit this.
 
Most of you will just need to use the build renamer tool. But for those using a hex editor, like me:
zybitk.png
Just edit the highlighted section, changing it to the name you've been working with, and save.
 
With that done, we need to put our new files in the .zip.
 
Rename your new character art to atlas-0.tex.
Now, using the zip software, replace the files in what used to be wod.zip with your new build.bin and atlas-0.tex, and save the changes.
 
And that's all the art taken care of!
So let's get down to the code.
 
Since it won't take long, let's edit modinfo.lua - everything inside is pretty straightforward.
Most importantly, make sure your api_version is set to 6.
 
Now, let's move on to modmain.lua - here you will see a bunch of assets and things. All we need to do in here, is change every instance of 'wod' to our working name.
 
Almost there, now!
Let's go into scripts/prefabs, and get to work on the last lua file!
 
Rename it, of course, just as we've done with the previous files.
The first thing we need to change, is this:



        -- Don't forget to include your character's custom assets!        Asset( "ANIM", "anim/wod.zip" ),}

Change wod, again, just as we have done every other time.
 
The next thing we will want to change is this:

    -- choose which sounds this character will play    inst.soundsname = "wolfgang"

Replace "wolfgang" with the character whose sound you want to use. Your options are:

  • "wendy"
  • "wes"
  • "wickerbottom"
  • "willow"
  • "wilson"
  • "wolfgang"
  • "woodie"
  • "wx78"
  • "maxwell"

Replace "wolfgang" with the name of your choice shown above.
 
Here comes the trickier stuff:
Look for:

    -- todo: Add an example special power here.end

 
At this point, we need to do some detective work.
Open Don't Starve's "data" folder - found in the same directory as the "mods" folder.
Then go to scripts/prefabs/ and scroll down to the "w"s.
Here we can see the prefab files for the different characters.
 
Let's have a look at Wendy - she deals less damage than other characters, so let's find out how.
In the equivalent section of the wendy.lua file, you will see:

    inst.components.sanity.night_drain_mult = TUNING.WENDY_SANITY_MULT    inst.components.sanity.neg_aura_mult = TUNING.WENDY_SANITY_MULT    inst.components.combat.damagemultiplier = TUNING.WENDY_DAMAGE_MULT

These are the little things that overwrite the "default" stats. They represent different aspects of different components.
These files reference the "tuning" file. What is usually helpful, is to use Wilson as your reference point. So let's take this line:

    inst.components.combat.damagemultiplier = TUNING.WENDY_DAMAGE_MULT

Then change Wendy to Wilson and add it to our character's prefab .lua file, so we have something like this:

    -- todo: Add an example special power here.    inst.components.combat.damagemultiplier = TUNING.WILSON_DAMAGE_MULTend

 
Which means that our character will have the damage multiplier of Wilson.
Awful boring, isn't it?
So, let's spice it up, and make our character deal twice the damage that Wilson does! We can change the line to:

    inst.components.combat.damagemultiplier = (TUNING.WILSON_DAMAGE_MULT * 2)

Which tells the game to take Wilson's damage multiplier, and multiply it by 2.
Alternatively, we can just give it a set value that doesn't refer to the tuning file at all:

    inst.components.combat.damagemultiplier = 4

This multiplies the damage by 4, as opposed to multiplying it by double whatever Wilson's multiplier happens to be. (It's 1, but this is an example.)
 
We can look at other character prefabs, and see how they're doing their stat perks... or we could get a little deeper, and start examining the components.
You will find these in data/scripts/components/ - but keep in mind that you're not going to want all of them for your character.
 
Let's see if we can find out how to give our new character a health boost, and open the health.lua component.
Right at the top, we can see this:

local Health = Class(function(self, inst)    self.inst = inst    self.maxhealth = 100    self.minhealth = 0    self.currenthealth = self.maxhealth    self.invincible = false        self.vulnerabletoheatdamage = true    self.takingfiredamage = false    self.takingfiredamagetime = 0    self.fire_damage_scale = 1    self.nofadeout = false    self.penalty = 0    self.absorb = 0

"self.maxhealth = 100" looks like what we want! So let's go back to our character prefab, and add to our perks list:

    inst.components.health.maxhealth = 100

But we don't want 100 max health - we want to boost it!
So we have two options again. You can change that 100 to whatever number value you want... or you can reference the tuning files. You can find tuning.lua in the data/scripts folder.
Inside tuning.lua, we can find:

        WILSON_HEALTH = wilson_health,

Wilson_health having been earlier specified through:

    local wilson_health = 150

So we know Wilson's health value is 150. Now let's update our character's perk. We can use:

    inst.components.health.maxhealth = (TUNING.WILSON_HEALTH * 2)

And this will give us double Wilson's health - which amounts to 300.
 
So, now you can pick and choose which components and values you want to buff or debuff for your character, and add them all to the list, there.
Once you've finished, we can move on to the strings:

-- First up, the character select screen lines-- note: these are lower-case character nameSTRINGS.CHARACTER_TITLES.wod = "The Template"STRINGS.CHARACTER_NAMES.wod = "Wod"STRINGS.CHARACTER_DESCRIPTIONS.wod = "* An example of how to create a mod character."STRINGS.CHARACTER_QUOTES.wod = "\"I am a blank slate.\""

As before, change 'wod' to your file's name, and then edit the information as you would like.
It is worth noting that you can add multiple lines to the CHARACTER_DESCRIPTIONS line by adding "\n" (without quotes) - this will cause a line break.
 
I'm quite sure the instruction included above the next few lines speaks for itself:

-- You can also add any kind of custom dialogue that you would like. Don't forget to make-- categories that don't exist yet using = {}-- note: these are UPPER-CASE charcacter name

Just change the name as always from WOD to whatever you're using.
If you don't want to add any custom quotes, you can just comment out the Evergreen description, like so:

--STRINGS.CHARACTERS.WOD.DESCRIBE.EVERGREEN = "A template description of a tree."

 
Change the last remaining instance of wod, here:

return MakePlayerCharacter("wod", prefabs, assets, fn)

 
And we've finished our character!
Put your mod into the mods folder, and let's take it for a spin. Enable it through the mod menu, and start a new game.
At this stage, you'll want to check that all the textures are lining up right, and that you haven't gotten any floating pixels, or anything.
 
 
But what about items?
We want to give our character a custom item! Make ourselves feel all special.
This is a bit more involved.
 
First, you'll want to choose the item you're basing it on - equippable items will generally require two anim .zip files: prefab.zip, and swap_prefab.zip.
For this demonstration, I will be using a specific example, and base it on the Bunny Hood from my Link mod, to make a custom hat.
So, take the .zip from the anim folder, and decompress it.
Use the .tex converter software to convert the atlas-0.tex file found within to png - this will give us a template to work against.
 
Just as you did with the character art, create the art for your new item, convert it to tex, and rename it to atlas-0.
Rename the build, just as you did before - I should note that anyone using the hex edit method should be sure to replace any extra characters with hex value 00.
In my example, I have taken "bunnyhood" and changed it to "cutehat" - but at first, I was left with "cutehatod" and had to replace the extra 'o' and 'd' with hex values of 00.
Replace the files in your duplicated-and-renamed base prefab anim .zip with your new stuff, and add the new .zip to the 'anim' folder of your mod.
 
The item also needs an inventory image, so let's make one - it just needs to be a 64x64 image. This also needs an xml, so we must create a matching xml file. The contents of which should look like this:

<Atlas><Texture filename="YOUR_PREFAB_HERE.tex" />    <Elements><Element name="YOUR_PREFAB_HERE.tex" u1="0" u2="1" v1="0" v2="1" /></Elements></Atlas> 

 
Put your YOUR_PREFAB_HERE.tex and YOUR_PREFAB_HERE.xml into a new folder called "inventoryimages" and place that folder inside your mod's "images" directory.
 
We're almost there, now, so let's copy the contents of your base prefab's .lua file that you found in scripts/prefabs into a new document.
 
The first thing to change is the assets list. You want to have something like so:

local assets={    Asset("ANIM", "anim/YOUR_PREFAB_HERE.zip"),    Asset("ATLAS", "images/inventoryimages/YOUR_PREFAB_HERE.xml")}

 
Everything else gets a bit more dependent on your item, but things you want to keep an eye out for are, as a few examples...
 
Override Symbols:

local function onequip(inst, owner)        owner.AnimState:OverrideSymbol("swap_hat", "YOUR_PREFAB_HERE", "swap_hat")

 
Set Build:

    anim:SetBank("featherhat")    anim:SetBuild("YOUR_PREFAB_HERE")    anim:PlayAnimation("anim")

 
The final line:

return Prefab( "common/inventory/YOUR_PREFAB_HERE", fn, assets)

 
And, of course, the inventory image must be specified like so:

    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/inventoryimages/YOUR_PREFAB_HERE.xml"

 
But we've only copied an item verbatim, right now - in the same way we added perks to the character, by looking at components, and looking at other items, we can add custom attributes and effects to our new item.
To my hat, I want to add a dapperness component, so I have added to the constructor (the "function fn(Sim)" part):

    inst:AddComponent("dapperness")    inst.components.dapperness.dapperness = (TUNING.DAPPERNESS_MED * 2)

 
You can get more advanced than this, but that's all I want to do with this particular item, so let's save it, and drop it in our mod's scripts/prefabs folder.
 
But we're not done yet!
We need to add it to our character!
 
Open the modmain.lua file, and look for the part right at the top:

PrefabFiles = {    "YOU",}

 
We need to add our item to this list, so we end up with:

PrefabFiles = {    "YOU",    "YOUR_ITEM",}

 
We also mustn't forget to give our item a name and description, which we can do by adding this to the very top, above the prefab list:

GLOBAL.STRINGS.NAMES.YOUR_PREFAB_HERE = "NAME"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.YOUR_PREFAB_HERE = "DESCRIPTION"

 
We should now be able to debug spawn it. But we want our character to start with it! So let's add a little bit of code to our character's prefab .lua file.
 
Just above the line "local fn = function(inst)" we need to add a new section, like so:

local start_inv ={    "YOUR_ITEM",}local fn = function(inst)

 
So it's now added to our start inventory. (We found out how to do this with some detective work, looking at how other characters add start inventories.)
 
We must also change the last line, so the game knows to check the start inventory:

return MakePlayerCharacter("YOU", prefabs, assets, fn)

Becomes:

return MakePlayerCharacter("YOU", prefabs, assets, fn, start_inv)

 
And finally, we are done!
 
Go make yourself some nice tea to celebrate, and then sit down and enjoy your very own character!
 
These same methods and principles can be applied to just about anything, and by looking at the existing files, and other mods, you can work out how to do more and more complex things. It's all about detective work.
Good luck, everyone!

 

Here is a link to the character I created while writing this.

Share this post


Link to post
Share on other sites
leprucio    12

Epic i study all nigth but when i can i make all and say you =) really ty for new info of modding for starter =) like me ^^

Share this post


Link to post
Share on other sites
Tesability    88

This is making me wonder how one can make something similar to hand claws  and make it so that it creates another hand slot above that to allow you to hold second item as well, maybe even a second hand claw. I have a monk character I'm trying to create and being able to have it so that she can make and use at least one of their weapons would be awesome. :3 (And no, I'm not planning on crossing Diablo with Don't Starve. The character would still be a crossover, but she'd be from a different game entirely. >.>)

Share this post


Link to post
Share on other sites
TheDanaAddams    573

This is making me wonder how one can make something similar to hand claws  and make it so that it creates another hand slot above that to allow you to hold second item as well, maybe even a second hand claw. I have a monk character I'm trying to create and being able to have it so that she can make and use at least one of their weapons would be awesome. :3 (And no, I'm not planning on crossing Diablo with Don't Starve. The character would still be a crossover, but she'd be from a different game entirely. >.>)

You will probably have to wait until we have the ability to expand existing animation sets before you could do something like that.

I can't think of anything off-hand that would suit a glove-weapon.

(No pun intended, but I'll take it. ;P)

Share this post


Link to post
Share on other sites
Tesability    88

Ah, well. I'm just going to have to figure out another character then. I know slamming a shapeshifter into the game's definitely impossible right now. (I'm talking Ditto-styled shapeshifting, not Woodie-styled shapeshifting.)

Share this post


Link to post
Share on other sites
simplex    2,595

Very well written and detailed guide! Not just for artists, but for everyone starting out (at least!).

I don't know why you're having to edit the zips in place, though. I always decompress it, mess with the files and then recompress.

Just one note about hex-editing build names: you can change the name's length, both increasing it and decreasing it (without having to add zero bytes).

Taking you "wod" example:

fDdRtJo.png?1

That number 3 is the length of the build name, "wod". If you want to change the name's length, all you have to do is update that number as well. It's easy to spot it, because it's the last number before the name, always followed by 3 zero bytes. Buuut, many hex editors don't have support for adding bytes, only editing existing ones. Personally, I found it easier to use a hex editor to edit that number and a text editor to edit the name.

Share this post


Link to post
Share on other sites
Tesability    88

Unfortunately, I'm one of those that still need a side-by-side example of an already made custom character next to the sprite template to make heads or tails of it. x.x I'm more of a visual learner than anything else. >_>;

Share this post


Link to post
Share on other sites
leprucio    12

=) yep all work now need more work in art =3 epic ty  dana =P (i have a lot isues i solve it puting all whit bloq mayus off)k53b.jpg

Share this post


Link to post
Share on other sites
TheDanaAddams    573

Unfortunately, I'm one of those that still need a side-by-side example of an already made custom character next to the sprite template to make heads or tails of it. x.x I'm more of a visual learner than anything else. >_>;

At the very end of the post, I link to the character I created while writing this, if taking a look at that will help. =)

 

 

=) yep all work now need more work in art =3 epic ty  dana =P (i have a lot isues i solve it puting all whit bloq mayus off)

I'm glad to see you were able to follow it!

You've got some pretty nasty-looking aliasing around the edge of the hair, though. Something I'm sure you've noticed. =)

Share this post


Link to post
Share on other sites
leprucio    12

I'm glad to see you were able to follow it!

You've got some pretty nasty-looking aliasing around the edge of the hair, though. Something I'm sure you've noticed. =)

 

Yep =) i fix it now i trying to fix problem of body conection to head in the screenshot can see (left rigth) the body is under hair in the second is the best but i can see a little hair in neck zone and in the last img  the hair is under body =) and i fixising nose problems =) when all finis i go to make portraits and powers ect ect but the first needed is a cool char =)

am7f.jpg

Share this post


Link to post
Share on other sites
leprucio    12
    inst.components.sanity.night_drain_mult = TUNING.WENDY_SANITY_MULT    inst.components.sanity.neg_aura_mult = TUNING.WENDY_SANITY_MULT

is posible make the inverse of the wendy pasive? this make less drain of sanity i want make the oposite  more drain of sanity (in all situations monster day  cicle ect..) i put yet a pasive drain  sanity perk but a want too more sanity drain influence =P srry for mi english and mi noob quest i think put

    inst.components.sanity.night_drain_mult = ( TUNING.WENDY_SANITY_MULT * -2 )    inst.components.sanity.neg_aura_mult = ( TUNING.WENDY_SANITY_MULT * -2  )

but i dont think if i can make like that

 

I KNOW yet i rember wolfang have scare to nigth and monsters i see the lua and i found the path =3

	inst.components.sanity.night_drain_mult = 1.1	inst.components.sanity.neg_aura_mult = 1.1

Share this post


Link to post
Share on other sites
TheDanaAddams    573
    inst.components.sanity.night_drain_mult = TUNING.WENDY_SANITY_MULT    inst.components.sanity.neg_aura_mult = TUNING.WENDY_SANITY_MULT

is posible make the inverse of the wendy pasive? this make less drain of sanity i want make the oposite  more drain of sanity (in all situations monster day  cicle ect..) i put yet a pasive drain  sanity perk but a want too more sanity drain influence =P srry for mi english and mi noob quest i think put

    inst.components.sanity.night_drain_mult = ( TUNING.WENDY_SANITY_MULT * -2 )    inst.components.sanity.neg_aura_mult = ( TUNING.WENDY_SANITY_MULT * -2  )

but i dont think if i can make like that

 

I KNOW yet i rember wolfang have scare to nigth and monsters i see the lua and i found the path =3

	inst.components.sanity.night_drain_mult = 1.1	inst.components.sanity.neg_aura_mult = 1.1

Since it's a multiplier, it's pretty straightforward. Wilson is 1x, and that's your point of reference.

A value of 1.1 would be 110% of Wilson's sanity draining, and thus faster.

A value of 0.75 would be 75% of Wilson's sanity draining, and thus slower.

 

Think about it like that, and it should be pretty easy to work out. =)

 

 

I need the mod don't work. It says: steamapps/common/dont_starve/data/scripts/util.lua:244: Could not find an asset matching anim/E79.zip (The name i choose) in any of the search paths.

LUA ERROR stack traceback:

=[C] in function 'assert'

steamapps/common/dont_starve/data/scripts/util.lua(244,1) in function 'resolvefilepath'

steamapps/common/dont_starve/data/scripts/mainfunction.lua(18,1) in function 'RegisterPrefabs'

steamapps/common/dont_starve/data/scripts/mainfunctions.lua(42,1 in function 'LoadPrefabFile'

scripts/main.lua(202,1) in function 'ModSafeStartup'

scripts/main.lua(241,1)

=[C] in function 'SetPersistentString'

steamapps/common/dont_starve/data/scripts/modindex.lua(55,1)

 

This error may have occured due to a mod you have enabled!

You have the following mods enabled:

"Mymod"

The problem is explained pretty well in that error!

steamapps/common/dont_starve/data/scripts/util.lua:244: Could not find an asset matching anim/E79.zip in any of the search paths.

The code is telling it to look in your mod's "anim" folder for a file called "E79.zip" - and it's crashing because it can't find it.

Check that the file is in there, and named correctly - also double check that you've got the correct case, since I believe the file paths are case sensitive. You may be telling it to look for "E79"when the file is called "e79".

 

 

Night vision while Charlie is still able to hurt you in darkness, is that somehow still considered OP?

Don't worry about that stuff - just make your character how you want to make it. It's your project, after all!

Share this post


Link to post
Share on other sites
TheDanaAddams    573

Okay thanks you i fixed the error. But when i launch the game it immediately crashes?

Check your log.txt in Documents/Klei/DoNotStarve/

 

It'll be in your "My Documents" sort of folder - not with the rest of the Don't Starve files.

Share this post


Link to post
Share on other sites
TheDanaAddams    573

Looks like your portrait tex files are bad. Download the sample character templates and make sure you keep to the power-of-2 sizes. (128, 256, 1024, things like that. I'm pretty sure the template images you're getting errors on, there, don't have those dimensions in the templates.

Share this post


Link to post
Share on other sites
Georjen    0

how we do the "draw" of a animation: Ex: i want do a hand and how I draw it, i dont know how to create a animation file.

Share this post


Link to post
Share on other sites
TheDanaAddams    573

how we do the "draw" of a animation: Ex: i want do a hand and how I draw it, i dont know how to create a animation file.

Download the templates from the Sample Mods, bring it into your image editor, and draw over the top on a new layer.

Share this post


Link to post
Share on other sites
Tesability    88

Some character designs have physical traits that are going to be a pain in the ass to translate into a viable sprite...such as my attempt's twin-tails. x.x Figuring out how to make it so that my character is wearing her custom tophat when not actually wearing a hat and not showing it when she's is wearing something was easy. >_>

Share this post


Link to post
Share on other sites