Jump to content

[TEMPLATE] Custom Player Animation


PanAzej
 Share

Recommended Posts

@Yakuzashi

Silly Yakuzashi from the past. Just paste this into your modmain.lua

local function spearjab(sg) 
 local _onenter = sg.states["attack"].onenter 

	sg.states["attack"].onenter = function(inst) 
		_onenter(inst) 
	
		local equip = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)		
		if equip ~= nil and equip:HasTag("weapon") then		
				inst.AnimState:PlayAnimation("spearjab")
		end	
	end
end

AddStategraphPostInit("wilson", spearjab)

and don't forget about:

Quote

local EQUIPSLOTS = GLOBAL.EQUIPSLOTS

Cheers, you dummy

Link to comment
Share on other sites

Hi everyone,

I had a bit of free time today and I decided to dedicate it to updating Custom Animation Template.

New changes include:

- Added "hairfront" symbol.

- Added "customanim_mount" - animation of player riding on beefalo.

I will update the .zip in the main post shortly.

 

You can download this template on the Steam Workshop:

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

...or you can just click on the attached file.

 

Enjoy.

custom_player_animation_11112020.zip

  • Like 4
  • Thanks 1
  • Health 1
Link to comment
Share on other sites

Hello! I was just wondering if there was any way to add something to an idle animation with this? I know it sounds dumb, but for example, wendy, her idle animation has a flower. I'd like to know if it is at all possible to add something like that, or even some other kind of special effects? If it's not possible, that is cool too, this is an awesome template!

Link to comment
Share on other sites

23 minutes ago, Arimo said:

Hello! I was just wondering if there was any way to add something to an idle animation with this? I know it sounds dumb, but for example, wendy, her idle animation has a flower. I'd like to know if it is at all possible to add something like that, or even some other kind of special effects? If it's not possible, that is cool too, this is an awesome template!

You can create a new animation using this template, and for the special idle animation you don't even have to create a new state, just simply load in the *.zip with anim.bin in your character's prefab and add the line below in your character's master_postinit:

inst.customidleanim = "idle_animationname"

Stategraph reads animation name from this variable and tries playing it during "funnyidle" state.

If it doesn't find a variable with this anim or this variable is empty, it plays the default "funnyidle" animation.

 

And if you're asking how to add a new symbol, then yes, that's possible too.

You would need to add an "override build" with inst.AnimState:AddOverrideBuild("build_name") or simply just add new symbol to animation, and compile it. That would mean leaving files other than anim.bin (a ton of unneeded graphics), so I would recommend compiling and loading that symbol as a separate build.

I may create some more extended tutorial about animations and stategraphs in DST at some point, but currently I'm leaving it as is.

Edited by PanAzej
more info
  • Thanks 1
Link to comment
Share on other sites

57 minutes ago, PanAzej said:

You can create a new animation using this template, and for the special idle animation you don't even have to create a new state, just simply load in the *.zip with anim.bin in your character's prefab and add the line below in your character's master_postinit:

inst.customidleanim = "idle_animationname"

Stategraph reads animation name from this variable and tries playing it during "funnyidle" state.

If it doesn't find a variable with this anim or this variable is empty, it plays the default "funnyidle" animation.

 

And if you're asking how to add a new symbol, then yes, that's possible too.

You would need to add an "override build" with inst.AnimState:AddOverrideBuild("build_name") or simply just add new symbol to animation, and compile it. That would mean leaving files other than anim.bin (a ton of unneeded graphics), so I would recommend compiling and loading that symbol as a separate build.

I may create some more extended tutorial about animations and stategraphs in DST at some point, but currently I'm leaving it as is.

I am very new to this, so a tutorial would be stellar some time for newbies like me, haha. I will do my best! Thank you so much for the reply and for making this!

Link to comment
Share on other sites

@PanAzej

On 3/6/2017 at 3:18 AM, PanAzej said:

Yes, you need all of those symbols at once for animation to work properly.

Hello, ^_^

This template has been recommended to me numerous times, and I'm trying to figure out how to hide/remove some of the symbols.

To be more specific, I want a mostly normal character, while being able to use swap_face.  What I don't need are BEARD, hairfront, hairpigtails, lantern_overlay, swap_body, swap_hat, or swap_object.

The anim file will not generate if these files are removed, and deleting them from the Spriter file does not appear to change anything.  I am attempting to use " self.animstate:Hide("______") " to hide the symbols, but so far have only had mixed results.  The symbols still appear on the character select screen, and swap_hat and hairpigtails fail to disappear in general.

self.animstate:Hide("BEARD")
self.animstate:Hide("hairfront")
self.animstate:Hide("hairpigtails")
self.animstate:Hide("lantern_overlay")
self.animstate:Hide("swap_body")
self.animstate:Hide("swap_hat")
self.animstate:Hide("swap_object")

Am I overlooking something obvious?
I've read and re-read this forum thread and am not sure how to make these symbols not appear on the character.

Edited by FurryEskimo
Link to comment
Share on other sites

On 5/12/2021 at 1:30 AM, FurryEskimo said:

@PanAzej

Hello, ^_^

This template has been recommended to me numerous times, and I'm trying to figure out how to hide/remove some of the symbols.

To be more specific, I want a mostly normal character, while being able to use swap_face.  What I don't need are BEARD, hairfront, hairpigtails, lantern_overlay, swap_body, swap_hat, or swap_object.

The anim file will not generate if these files are removed, and deleting them from the Spriter file does not appear to change anything.  I am attempting to use " self.animstate:Hide("______") " to hide the symbols, but so far have only had mixed results.  The symbols still appear on the character select screen, and swap_hat and hairpigtails fail to disappear in general.


self.animstate:Hide("BEARD")
self.animstate:Hide("hairfront")
self.animstate:Hide("hairpigtails")
self.animstate:Hide("lantern_overlay")
self.animstate:Hide("swap_body")
self.animstate:Hide("swap_hat")
self.animstate:Hide("swap_object")

Am I overlooking something obvious?
I've read and re-read this forum thread and am not sure how to make these symbols not appear on the character.

Hi.

Sorry that I'm replying just now, I wasn't present on the forums for quite a long time.

 

All you need to do is open the compiled *.zip of your animation and delete all contents except anim.bin.

That is all.

 

EDIT:

Nevermind, I've read your thread.

You want to make a custom character BUILD with this template, not an animation?

In this case just replace the character parts you don't want with blank textures.

(There is a better way of doing this stuff, by removing symbols from the project, but that's a lot of manual work not worth anybody's time.)

Edited by PanAzej
stuff
Link to comment
Share on other sites

@PanAzej
Thanks, but I actually figured it out!  :D

I opened the original Spriter file in Notepad, copied the part info I needed, and posted it into my own Spriter file.  I then added the sprite images I needed, (maybe renumbered the sprites, I forget) and it worked!  The character now has a scarf option and cuffs.  I update some code that hides/reveals the items based on the clothes being worn, but now it works!  ^-^

Link to comment
Share on other sites

Thought I'd add this as a helpful tip to those who come after me.

I downloaded the Spriter file, ran DST's scml.exe to make a build, copied an anim.bin for in-game animations (player_basic and player_idles, in turn), and used krane to decompile the build with the selected in-game animation.

The resultant Spriter file wasn't quite right. The tail and FACE_SWAP images had been, seemingly, cropped to remove transparent blank space, and then stretched back to fill the entire space of the original file. There was a vertically stretched giant Clops eye floating in front of the character.

This was easily resolved by copying the png's from the original Spriter project into the new one, though. (Also it wouldn't affect the compiling of any new animations anyway, as far as I understand; but it would make it a tad more difficult to design them.)

Link to comment
Share on other sites

Can I still ask here?

No matter what I do to the animation files Z-order in spriter. The game doesn't render it?

How this frame looks in Spriter:
image.thumb.png.0507170d2b08e57a3b910356cd92d93e.png

And here's how it renders in game:
image.thumb.png.a58bfa9fea0b2344eca4bd21e9ce7974.png

 

Does anyone know WHY the z-order is wrong in game?

Link to comment
Share on other sites

On 2/10/2022 at 7:28 AM, Scrumch said:

Can I still ask here?

No matter what I do to the animation files Z-order in spriter. The game doesn't render it?

How this frame looks in Spriter:
image.thumb.png.0507170d2b08e57a3b910356cd92d93e.png

And here's how it renders in game:
image.thumb.png.a58bfa9fea0b2344eca4bd21e9ce7974.png

 

Does anyone know WHY the z-order is wrong in game?

I know I'm replying super late to your post, but this issue happens most likely because the arm is at some point in the animation in the Z-order shown in the game.

 

Look closely at the timeline in your animation. There must be a node (frame) where the Z-order of this symbol is in this specific order.

Z-order of a symbol cannot be changed during an animation (as far as I'm aware). If you need to do that, then I recommend splitting the animation into 2 parts - 1st, where the arm is behind the torso/pelvis, and 2nd, where the arm is before torso/pelvis.

And then playing them one after another in the stategraph -> first part of the animation triggered with inst.AnimState:PlayAnimation("animation1_name", false), second part with inst.AnimState:PushAnimation("animation2_name", false)

Edited by PanAzej
fixed "AnimState" command, I've done too much C# coding lately...
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

On 3/7/2017 at 6:40 PM, PanAzej said:

For example, to get hand slot item's positions I had to find how the default symbol is named in animation files, then make my own item symbol with that name, then use its graphics with player animations to decompile them and then get position values, so that I could copy-paste them to the template

Can you explain to me how exactly you got the position of the symbols and "copy and paste" them into the template? Here is me problem:

When decompiling and compiling assets from SW items, I noticed that the ripple and shadow symbols of floating items are no longer shown (cause it's a blank symbol that ktools didn't extract). When using GetSymbolPosition there is a return, which made me think that the symbol still exists...

Thank You <3

Link to comment
Share on other sites

On 4/13/2022 at 6:11 AM, Leonidas IV said:

Can you explain to me how exactly you got the position of the symbols and "copy and paste" them into the template? Here is me problem:

When decompiling and compiling assets from SW items, I noticed that the ripple and shadow symbols of floating items are no longer shown (cause it's a blank symbol that ktools didn't extract). When using GetSymbolPosition there is a return, which made me think that the symbol still exists...

Thank You <3

The symbol exists in the animation itself, but when you decompile the animation with Krane, you need to supply the anim.bin file with a build.bin file which contains all of the symbols used by the animation to properly decompile the entire thing.

So for example, to decompile the entire default player build with all symbols (as shown in my template here), I had to find all symbols in various character/item builds (some symbols are never used in character's build.bin/atlas files, so I also had to unpack swap_hat (used in headgear item's builds) and other symbols).

Then, I had to combine all symbols I collected into a single SCML file and compile it (using Klei's autocompiler from Don't Starve Modding Tools package on Steam). Then, I used the compiled build.bin/atlas files (from my compiled ZIP file) to decompile an anim.bin file I was interested in.

So, my guess is that the floating effect symbol must be located in a separate file. You would have to grab some item's anim.bin file, decompile it, then decompile that floating symbol, and combine their SCML symbol declarations (symbols are declared at the top of SCML file, before animations) both in a single SCML file (of course you need to copy folders with symbols to the location of merged SCML file too). Then, compile all that stuff to create a new build.bin + atlas, which you can use to decompile the anim.bin of a floating item, getting a properly unpacked animation without missing stuff in the process.

EDIT: By the way, you can unpack any build.bin/atlas combination with any anim.bin file - the animations just won't be there. But, the symbol declarations should be intact. So regardless of anything, you can use those declarations + unpacked symbols to create and compile a new, more complete build.

Edited by PanAzej
additional stuff
  • Thanks 1
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...