Jump to content

Recommended Posts

I want my character to have a different headbase sprite for when they wear specific hats, is it possible? 

I've tried to find something about it but it seems there's not much people who have the same idea... For context, it's supposed to be like this: when there's no hat, their ears are up, and when there is a hat the ears go down.

I don't really know how hard it might be, but I'll be glad if someone helps me find out how to do that. ^^

Edited by majuck

Most hats already feature a system to hide/show different headbases/hair already.

If you make your ears similar to how wilson's hair works. You could simply just have the ears up as your default headbase and the ears down as your headbase_hat textures.

But seeing as you want it for very specific hats? You'll need to do listenforevents for equip/unequip and update your symbols using AnimState:OverrideSymbol

Like how specific do you need them to be?

By default most hats will automatically hide the default headbase and show the headbase_hat texture for example. Except for some hats such as the ear muffs which will show the default headbase and hair.

Edited by IronHunter
  • Like 1

Oh, thank you! I saw those hat textures but for some reason it never clicked to me that's what they're for lol. 

I wanted to make it specifically for the hats that cover the upper half of the head, just to be sure there won't be any weird occurances, but now that I think about it I guess I'll just test how it works normally when I get it done first. 

Btw, sorry for the late reply, I don't get many answers here so I didn't expect much. Thanks again.

  • Like 1
On 5/15/2022 at 1:43 PM, IronHunter said:

 

Hey IronHunter, sorry for asking again but I have another question, it's different but still related to hats...

Do you know how to make it so one part of a custom hat appears behind the character instead of Infront/on them? I'm planning to make it so one part of it is layered like a normal hat, but the other is behind the character wearing it. 

What I'm making is pretty specific, so I guess it isn't being asked a lot.. My bad if it's a bit hard to accomplish. Feel free to ask any questions if you'll need to, but just a heads up I'm not good at making codes so If you do decide to help then an example or something as such will be nice. 

Again, sorry for asking. I hope it's not a problem for you. 

9 hours ago, majuck said:

Hey IronHunter, sorry for asking again but I have another question, it's different but still related to hats...

Do you know how to make it so one part of a custom hat appears behind the character instead of Infront/on them? I'm planning to make it so one part of it is layered like a normal hat, but the other is behind the character wearing it. 

What I'm making is pretty specific, so I guess it isn't being asked a lot.. My bad if it's a bit hard to accomplish. Feel free to ask any questions if you'll need to, but just a heads up I'm not good at making codes so If you do decide to help then an example or something as such will be nice. 

Again, sorry for asking. I hope it's not a problem for you. 

So the problem arises that there is only one Offical Hat symbol that always renders in  the front. However there are other symbols in the player bank. You can use a bit of trickery with how the symbols are layered by overriding one of the unused hair symbols for your back symbol. You may need to experiment with which hair symbol to use as those ones render behind the headbase.

This will take trial and error.

  • Like 1
On 5/26/2022 at 10:00 PM, IronHunter said:

However there are other symbols in the player bank. You can use a bit of trickery with how the symbols are layered by overriding one of the unused hair symbols for your back symbol.

First of all, thanks for the reply.

I've finally gotten to this part, but I realised that adding a new part like I wanted to and changing the player bank isn't as easy as I thought to figure out. 

My bad for being so clueless, but could you go into more detail about both of the things? I can't seem to find where exactly I can change the bank, and since there's no templates including that, I also can't figure out how do I tie one sprite to another and do it from multiple angles as well. 

1 hour ago, majuck said:

First of all, thanks for the reply.

I've finally gotten to this part, but I realised that adding a new part like I wanted to and changing the player bank isn't as easy as I thought to figure out. 

My bad for being so clueless, but could you go into more detail about both of the things? I can't seem to find where exactly I can change the bank, and since there's no templates including that, I also can't figure out how do I tie one sprite to another and do it from multiple angles as well. 

It is feasibly impossible to add new symbols to the existing animations. What you are doing is recycling some of the symbols that exist in the animation that you may not need at all times.

If you noticed with custom hats there is a bunch of code like AnimState:OverrideSymbol or AnimState:HideSymbol

You can use these to show/hide both parts of the hair symbol and override the non hat version of the symbol for the back part of your hat.

While still overriding the normal hat symbol for the front part of your hat.

I suggest checking the tutorials sub forum as I recall there is a equippable item tutorial. As vanilla hats are all bundled together and likely confusing for newer coders.

5 hours ago, IronHunter said:

You can use these to show/hide both parts of the hair symbol and override the non hat version of the symbol for the back part of your hat.

I did as you said, but it didn't work. Both of the hair symbols show up now, but it doesn't get overriden with the back of the hat. What did I do wrong?

IMG-dd5dd1cda7c5a7fdbdaca4d139501ed0-V.jpg

You need to make sure your back hat symbols use a similar folder structure to the hair symbol.

You can copy your character's template hair symbol and use that as reference for adding your hat symbols.

If you want more help you are going to have to attach your hat files.

 

On 5/28/2022 at 11:19 PM, IronHunter said:

You need to make sure your back hat symbols use a similar folder structure to the hair symbol.

You can copy your character's template hair symbol and use that as reference for adding your hat symbols.

If you want more help you are going to have to attach your hat files.

If what you meant is that I have to give it as many pngs as the hair folder does, then I just tried that and it didn't work as well.
Either way, here's the zip, I included all of the hat files just in case, but if you don't mind it I'll delete it from the post later since It's a private mod.

 

Edited by majuck
13 hours ago, majuck said:

If what you meant is that I have to give it as many pngs as the hair folder does, then I just tried that and it didn't work as well.
Either way, here's the zip, I included all of the hat files just in case, but if you don't mind it I'll delete it from the post later since It's a private mod.

witchhat.zip 191.92 kB · 0 downloads

You can always send stuff via a private message if you don't want to upload it to the forums.

So looking at your code you are trying to override a symbol swap_hat_behind which doesn't exist. You are supposed to override one of the hair symbols like "hair"

Edited by IronHunter
10 hours ago, IronHunter said:

You can always send stuff via a private message if you don't want to upload it to the forums.

So looking at your code you are trying to override a symbol swap_hat_behind which doesn't exist. You are supposed to override one of the hair symbols like "hair"

Oh, I see.
Just did that, and thankfully now it kinda works and overrides the hair with (I suppose) nothing, but how do I make it so it's the back of the hat that's overriding it? 
Forgot to include, here's the edited line just incase:

owner.AnimState:OverrideSymbol("hair", "witchhat", "hair")

Edited by majuck

owner.AnimState:OverrideSymbol("symbolname", "buildname", "symbolinbuildname")

Symbolname has to be a name of a symbol from klei's animation bank. In this case hair.

Buildname is the .zip file name, it is the name of the spriter file.

Symbolinbuildname is the folder name for the .pngs.

Make sure your spelling is correct for the respective stuff and also make sure your spriter file has the correct paths to the folders and .pngs.

7 hours ago, IronHunter said:

owner.AnimState:OverrideSymbol("symbolname", "buildname", "symbolinbuildname")

Symbolname has to be a name of a symbol from klei's animation bank. In this case hair.

Buildname is the .zip file name, it is the name of the spriter file.

Symbolinbuildname is the folder name for the .pngs.

Make sure your spelling is correct for the respective stuff and also make sure your spriter file has the correct paths to the folders and .pngs.

Ah, I see what I was missing then.
But, it still just doesn't want to acknowledge the back of the hat even after I added the paths in the spriter file.. So, if possible, could you look into what I might be writing wrong? I'm pretty sure I didn't do any spelling mistakes, rather I guess I'm just unaware if I added the right stuff or messed up somewhere.
I'll continue to try to change and test it according to your comment after that, but for now I'll leave the file here.
Thanks in advance. 

 

witchhat.scml

Edited by majuck
On 5/30/2022 at 3:58 PM, IronHunter said:

owner.AnimState:OverrideSymbol("symbolname", "buildname", "symbolinbuildname")

Symbolname has to be a name of a symbol from klei's animation bank. In this case hair.

Buildname is the .zip file name, it is the name of the spriter file.

Symbolinbuildname is the folder name for the .pngs.

Make sure your spelling is correct for the respective stuff and also make sure your spriter file has the correct paths to the folders and .pngs.

Alright, I got the file working in spriter, but not in-game... I don't know what else I'm missing, so I kindly ask for your help again.
Just a heads up, I tried it with both linking the hair folder and without, but neither worked, still.

witchhat.zip

Edited by majuck
8 hours ago, majuck said:

Alright, I got the file working in spriter, but not in-game... I don't know what else I'm missing, so I kindly ask for your help again.
Just a heads up, I tried it with both linking the hair folder and without, but neither worked, still.

witchhat.zip 1.77 kB · 0 downloads

It seems you are hiding the hair symbol in your code, maybe commenting it out and testing that?

Sorry I have been inactive, still recovering from covid.

local function OnEquip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_hat", "witchhat_swap", "swap_hat")
	owner.AnimState:OverrideSymbol("hair", "witchhat", "swap_hat_behind")

	owner.AnimState:Show("HAT")
	owner.AnimState:Show("HAIR_HAT")
	--owner.AnimState:Hide("HAIR_NOHAT")
	--owner.AnimState:Hide("HAIR")
        
	if owner:HasTag("player") then
		owner.AnimState:Show("HEAD")
		owner.AnimState:Hide("HEAD_HAT")
	end
		
	owner.AnimState:Hide("HEAD")
	owner.AnimState:Show("HEAD_HAT")
	
	owner.components.combat:AddDamageModifier("witchhatbonus",1.2) -- multiplies the damage with 1.2
	
	if inst.components.fueled ~= nil then
		inst.components.fueled:StartConsuming()
	end
	
end

 

witchhat.lua

6 hours ago, IronHunter said:

It seems you are hiding the hair symbol in your code, maybe commenting it out and testing that?

Sorry I have been inactive, still recovering from covid.


local function OnEquip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_hat", "witchhat_swap", "swap_hat")
	owner.AnimState:OverrideSymbol("hair", "witchhat", "swap_hat_behind")

	owner.AnimState:Show("HAT")
	owner.AnimState:Show("HAIR_HAT")
	--owner.AnimState:Hide("HAIR_NOHAT")
	--owner.AnimState:Hide("HAIR")
        
	if owner:HasTag("player") then
		owner.AnimState:Show("HEAD")
		owner.AnimState:Hide("HEAD_HAT")
	end
		
	owner.AnimState:Hide("HEAD")
	owner.AnimState:Show("HEAD_HAT")
	
	owner.components.combat:AddDamageModifier("witchhatbonus",1.2) -- multiplies the damage with 1.2
	
	if inst.components.fueled ~= nil then
		inst.components.fueled:StartConsuming()
	end
	
end

 

witchhat.lua 2.95 kB · 0 downloads

It worked!! Thank you so much for all the help through this time!

I hardly noticed it at first since it was higher than needed and hid behind the hat itself, but I'll edit it later.

Also aw man, really? Hope you get better, stay safe. 

Thank you again! 

Update for anyone else having trouble:
When a vanilla character wears it, the custom character's hair sprite stays on them after unequipping so add those lines:
 

--In OnEquip
	if not owner:HasTag("witch") then
		owner.AnimState:Show("HAIR")
		owner.AnimState:Show("HAIR_NOHAT")
	end	

--In OnUnequip
	if not owner:HasTag("witch") then
			owner.AnimState:Hide("HAIR")
			owner.AnimState:Hide("HAIR_NOHAT")
	end	

Replace the "witch" with the tag of your custom character.

Edited by majuck
4 hours ago, majuck said:

It worked!! Thank you so much for all the help through this time!

I hardly noticed it at first since it was higher than needed and hid behind the hat itself, but I'll edit it later.

Also aw man, really? Hope you get better, stay safe. 

Thank you again! 

Update for anyone else having trouble:
When a vanilla character wears it, the custom character's hair sprite stays on them after unequipping so add those lines:
 


--In OnEquip
	if not owner:HasTag("witch") then
		owner.AnimState:Show("HAIR")
		owner.AnimState:Show("HAIR_NOHAT")
	end	

--In OnUnequip
	if not owner:HasTag("witch") then
			owner.AnimState:Hide("HAIR")
			owner.AnimState:Hide("HAIR_NOHAT")
	end	

Replace the "witch" with the tag of your custom character.

Make sure you just clear the overridesymbol then for the hair

owner.AnimState:ClearOverrideSymbol("hair")

 

Edited by IronHunter

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
×
  • Create New...