Jump to content

Need help with a custom character's stats.


Recommended Posts

So I want to make a character who gets benefits from being wet such as:
-Get a small boost in attack when wet
-No Sanity loss
-very slight passive healing

I have no idea how to code and would appreciate some tips or examples.

unrelated but, If there's any tutorials on how to make a helmet item that'd be nice too.

Edited by Pinyaps
Link to comment
Share on other sites

Take a look at my newcomer post. It has a lot of good information to help ease your way into DST modding. It also has an example mod of a Cactus Armor with all the graphics working, so you can study it to see how it's done. Changing it to be a helmet instead should be pretty easy, especially if you look at the existing hats in the game in the hats.lua (information about where to find game files is in the newcomer post).

Learn how to use ListenForEvent (search the forum; there are also tips on how to search the forum for modding-specific topics in the newcomer post), so you can listen to the "moisturedelta" event, which triggers whenever there is a change in moisture on your character, and relays information about the current moisture level to the listener. Listening to this change, you can apply any effects you want (e.g. your passing healing and attack boost), perhaps even weighted by how wet the character is.

Getting no sanity loss from wetness is difficult in DST, because that calculation is placed in the middle of a very elaborate sanity-delta calculation. In DS it's abstracted away into a separate function, but not in DST. We solved it in this thread, though.

Link to comment
Share on other sites

I took a look at your newcomer post and it's actually helped me understand a bit of Lua coding but not quite.

I'm nearly done with my mod all I need to do is make a custom helmet for the character but I still can't seem to find any tutorials for creating a custom helmet or item for a mod character.

Edited by Pinyaps
Link to comment
Share on other sites

Look at the Cactus Armor example. Combine that with a little studying of the hats.lua file from the game-code, and it should be easy enough for you to change it into a helmet and make new graphics for it. You don't have to make it as a stand-alone mod. Just make sure that the things in the Cactus Armor modmain.lua are in your character mod's modmain.lua, and use the exact same file structure. Basically, you can create the helmet as a stand-alone mod first, and easily merge it into the character mod later, if you think that will be easier for you. Otherwise, you can just start by merging the Cactus Armor into your project, and start working on changing it into a helmet from there.

Here's one tutorial (found via the tutorials links in the newcomer post) on how to make equippable items. There may be some things missing there about Spriter and animations, where this post will help you.

Link to comment
Share on other sites

My issue is that a lot of the tutorials I found were either outdated or difficult to follow due to being unclear in the instructions like this one. I feel lost when looking through the code because I don't know what I'm supposed to be looking for.

I've already made the graphics for the helmet but I don't know how to change the graphics of the armor items.

Link to comment
Share on other sites

Yeah, that one has code in one line instead of in a nice multi-line setup. It's annoying that most of the older posts are like this.

For graphics of the item on the ground and when held "in the mouse", you're looking at animations. They reside in the anim folder, and are packaged into so-called "builds". When Wolfgang changes size, the anim build is the one being changed at runtime. You use Spriter to set up animations, even ones with just 1 image which is the norm for items. You set which animation build to use in the beginning of your item or character prefab.

Here's an example from the fn() function in the prefab LUA file from the Cactus Armor mod:

inst.AnimState:SetBank("armor_cactus")
inst.AnimState:SetBuild("armor_cactus")
inst.AnimState:PlayAnimation("anim")

The bank and build name are AFAIK the filename.
You import the anim file using the following code, usually placed at the very top of your prefab file:

local assets =
{
	Asset("ANIM", "anim/armor_cactus.zip"),
}

 

For inventory images you're looking at...inventory images. Those are placed in the images\inventoryimages\ folder.

I'm not sure if it HAS to be this way, but what I've seen done the most, is to import these images in your modmain.lua, and then reference them in your prefab file.

modmain.lua code from Cactus Armor mod, usually placed at the very top of your modmain.lua file:

Assets = 
{
	Asset("ATLAS", "images/inventoryimages/armor_cactus.xml"),
}

and then in your prefab file you put the following in the fn() function AFTER adding the "inventoryitem" component. Example from the Cactus Armor mod:

inst.components.inventoryitem.atlasname = "images/inventoryimages/armor_cactus.xml"

You can clearly see which files are being used, where they are referenced and how they are imported. Just use the information in this post to help you generate the animations and textures, and use my overview above to change the filenames used in the code to match your own files. For the animations, I can't really help. I've never opened Spriter. But I'm told it's not much more than creating a new animation, placing your image in the middle of the thing, and creating a build or saving the scml or something. Then the game can build it for you with the information in the post I just linked.

Link to comment
Share on other sites

Sorry if I'm difficult to teach.

So can I replace the armor_cactus filenames in the code with my own file's names like I did with the extended character sample mod? How does putting the armor's modmain code into the character's modmain file work?

Link to comment
Share on other sites

4 minutes ago, Pinyaps said:

So can I replace the armor_cactus filenames in the code with my own file's names like I did with the extended character sample mod?

Yes.

4 minutes ago, Pinyaps said:

How does putting the armor's modmain code into the character's modmain file work?

What do you mean? You just "merge" them. Copy/paste everything from the armor/helmet's modmain into the character's modmain. Lists like "assets" and "prefabs" etc. need to be "merged" instead of just copy/pasted.

Link to comment
Share on other sites

3 minutes ago, Ultroman said:

What do you mean? You just "merge" them. Copy/paste everything from the armor/helmet's modmain into the character's modmain. Lists like "assets" and "prefabs" etc. need to be "merged" instead of just copy/pasted.

so where would the image files for the mod go in the character's files?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...