Jump to content

Need help to understand how to add a custom attack animation to a custom weapon


Recommended Posts

Hello guys,

 

I am trying to implement a custom attack animation for a custom weapon I made.

I created my animation using Spriter using as a base the sample provided by Cheerio (http://forums.kleientertainment.com/topic/37151-tutorial-adding-a-custom-idle-animation/)

 

But now I am quite stuck. I don't really know what to do with this scml project. I tried to see how blowdart and boomerang are handled to understand the difference. I found out that in the SGWilson.lua we can find different "events" (one for "throw", one for "blowdart") so I guess that's how it is handles. But even if I add a stategraph using AddStategraphPostInit, how do I really use it?

 

Is there a mod I could use as an example?

 

Thanks in advance.

Link to comment
Share on other sites

So I managed to attach my custom animation using AddStategraphState and AddStategraphActionHandler.

 

What I did basically is putting in my modmain.lua a copy of the state "blowdart" from SGWilson.lua and replacing the entries "blowdart" by the name of my weapon (and the proper animation name of course).

 

Then I did the same with the event handler.

 

The issue now is that the character is displaying the action but the weapon disappear. I don't think that the weapon is supposed to be included in the animation or is it?

Also it is not dealing damages anymore. It is also not spawning the projectile but I guess it's linked.

I attached the files if anyone can enlighten me on what I should correct.

 

Thanks

modmain.lua

arrow.lua

bow.lua

Link to comment
Share on other sites

Come on, nobody can help me on this one?

There is also another stuff that I find quite strange. I decompiled the blowdart animation for example and applied it to my custom weapon. I was expecting that it will at least solve the issue of the hat, backpack/armor and equipped item disappearing while the animation is played but it doesn't.

Adding a folder "swap_hat" enables me to display the hat again (even if in a funny place) but I cannot figure out how to display the armor/backpack and quipped item while the animation plays. And actually I don't understand why it doesn't display at the first place while it is the original aniamtion for the blowdart, which doesn't make everything disappear.

Edited by ZupaleX
Link to comment
Share on other sites

You need to add a couple of dummy objects to your custom animation so that the game has something to replace when you call OverrideSymbol.

For handheld items, you need a dummy called swap_object. Add the bow with that name and animate it

 

You already have the line

owner.AnimState:OverrideSymbol("swap_object", "swap_bow", "swap_bow")

on your bow's prefab lua so it should work once you add it.

 

You should also add dummies for the hat (swap_hat) and backpack (swap_body). There's also swap_body_tall and swap_face, but I haven't checked what those do yet.

Link to comment
Share on other sites

Thanks for the answere, but I finally figured it out meanwhile ;-)

There is actually also dummy symbols for the beard, skirts and ponytails ("beard", "hairpigtails" and "skirt").

 

Spriter is a pain is the ass to do this because this stupid software is constantly messing up the order of the images in the folder and randomly build a ID table which result in a big mess. I had to process through the scml file several times with notepad++ to fix the ID, so swap_body-0.png is indeed the ID 0 and not some crap randomly fixed by spriter.

Also it ignores the folders sometimes and he was refusing to create a new "folder ID" for the "hairpigtails" but was putting it with the "hairs" in the scml file.

 

But well, all in all spriter is free (but it still has HUGE flaws) :-)

Link to comment
Share on other sites

Spriter is a pain is the ass to do this because this stupid software is constantly messing up the order of the images in the folder and randomly build a ID table which result in a big mess.

Yeah, Spriter is very buggy. Really pain. :(

I hold the project separately from the autocompiler. When it is necessary to start a compilation, I copy whole project to the exported folder. I do so every time when something changes in the spriters' project.

Link to comment
Share on other sites

There really should be a tutorial on custom animations. The one regarding idle animations is too limited in scope to be useful for other animations. I'm going through your archery mod files trying to figure out how to do my own, but mods themselves don't contain the .scml files, which is a huge pain. I will say, though, that your struggles haven't been in vain, since they've been very helpful to me :D

Edited by StarmanUltra
Link to comment
Share on other sites

Here it is.

It is probably not perfect, my animation is a bit ugly and everything, but there is all the symbols I found up until now including the swap stuffs.

There is probably a need to tweak a bit the positions of some stuffs but in general, it's functionnal.

Ah, the folder for the hands is a bit messed up in my .scml but since i did not encounter issues because of that yet i did not fix it. It should not be too hard though to do it yourself if needed.

If you need any help tell me.

wilson.zip

Edited by ZupaleX
Link to comment
Share on other sites

You're awesome :grin: This answers a lot of questions, including but not limited to:

  • what to name entities/animations (looks like specific names aren't required),
  • what it is your lua scripts call,
  • yes you are able (but not required) to use bones,
  • each animation requires a different facing of the character,
  • animations are not all side-by-side like the .scml file in the mod character template,
  • swap_hat, swap_body, swap_object examples!
  • etc. etc.

 

So, for the benefit and convenience of others, I'll attach your archery mod as it exists now. I think this serves as an excellent example of how to customize a weapon and give it an attack animation. 

workshop-488009136.zip

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...