Jump to content

Changing a Character's Build


Recommended Posts

I'm trying to create a character that uses a build that doesn't share its prefab name.  Normally, a character called "example" would default to using the anim file called "example.zip", unless instructed otherwise.  I can't seem to convince it to use any build other than its own, however.  I've read that the proper way to do this is to assign a new build using:

inst.AnimState:SetBuild("differentbuild")

however, it doesn't seem to work.  The character defaults to the anim file with the same name, or simply becomes invisible if the anim with the same name is not provided.  Here's the full prefab:

local MakePlayerCharacter = require "prefabs/player_common"

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

local common_postinit = function(inst) 

end

local master_postinit = function(inst)
	inst.AnimState:SetBuild("chanti")
end

return MakePlayerCharacter("domo", prefabs, assets, common_postinit, master_postinit)

Both build files are standard character builds, compatible with the standard player stategraph.  Can anyone fill me in on what I'm doing wrong, or anything I'm missing?  Thank you so much!

Link to comment
Share on other sites

So i'm totally not sure but when i look at wolfgang, it seems, if i understand it well, that the change of appearance is managed by "skin" instead of "build", for example :

    inst.components.skinner:SetSkinMode("wimpy_skin", "wolfgang_skinny")

Seems the same for woodie and the special mode.

I don't know if you can use this method for custom character, or if you can use the build one, but maybe it's why it's not working ? Maybe you should look for another mod with custom build ? I think @SuperDavid made a mod like this if i remember well.

Link to comment
Share on other sites

8 minutes ago, Lumina said:

I don't know if you can use this method for custom character, or if you can use the build one, but maybe it's why it's not working ? Maybe you should look for another mod with custom build ? I think @SuperDavid made a mod like this if i remember well.

Thanks @Lumina.  I actually did reference a mod that uses my example, on top of also having skins for the characters.  I'm afraid if I cheat and use a skin to change the character, I'm limiting myself to not also being able to add skins to my character.

The mod I referenced was Leonardo Coxington's Playable Pets mod.  As an example, the playable Bearger character's prefab is called "bearplayer", and then sets its build as follows:

inst.AnimState:SetBank("bearger")
inst.AnimState:SetBuild("bearger_build")
inst:SetStateGraph("SGbearplayer")

The build name is different from the prefab name, and it still functions. (The mod then goes on to offer several skins for the Bearger character, as well as others), so I'd still  like to try to get it to work this way.

Link to comment
Share on other sites

What are you trying to do? Get your character to swap it's texture or add like different skins you select from the wardrobe? If it's the wardrobe thing then I can't help since I don't know anything about skins, sorry :)!

Link to comment
Share on other sites

3 hours ago, SuperDavid said:

Get your character to swap it's texture

I don't know if he want swap, but he want to use another build, so it look like something you did if i'm not wrong. No skin (at least not for this part)

Link to comment
Share on other sites

27 minutes ago, Lumina said:

but he want to use another build

Okay! :)

 

So, all you need to do is copy paste one of your character's current texture builds that work then you rename the folder, scml & zip folder to the new name of your texture.

Then you change the textures with something like gimp or any paint editing software that supports transparency, compile them with auto-compiler & add the newly picked name into your "local assets" inside YOURCHARACTER.lua

for example this is how mine looks

Spoiler

local assets = {
Asset( "ANIM", "anim/adam.zip"),
Asset( "ANIM", "anim/insane_adam.zip"),

Asset( "ANIM", "anim/wathgrithr_adam.zip"),
Asset( "ANIM", "anim/gelid_wathgrithr_adam.zip"),
Asset( "ANIM", "anim/wathgrithr_insane_adam.zip"),
Asset( "ANIM", "anim/gelid_wathgrithr_insane_adam.zip"),

Asset( "ANIM", "anim/gelid_adam.zip"),
Asset( "ANIM", "anim/gelid_insane_adam.zip"),

Asset( "ANIM", "anim/vampire_adam.zip"),
Asset( "ANIM", "anim/gelid_vampire_adam.zip"),
Asset( "ANIM", "anim/wathgrithr_vampire_adam.zip"),

Asset( "ANIM", "anim/dawn_adam.zip"),
--Asset( "ANIM", "anim/gelid_dawn_adam.zip"),

Asset( "ANIM", "anim/ghost_adam_build.zip" ),

Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
}

 

after all that you just simply use " inst.AnimState:SetBuild("Texture Build Name Here") " on a event or something & your character's texture should change, at least that's how it works for me!

If that doesn't work for you then maybe the scml is glitched or something & you could just replace it with the scml from the esctemplate mod by dleowolf, after renaming it of course :)! If that still doesn't work then you can link your textures/mod here if you want to see if I can get them to work or what's wrong!

 

EDIT: If your problem is with skins then I would ask someone from here 

more specifically Fidooop since he seems to be the one that made the entire API for mod character skins & stuff, but if it's just changing your texture then I'm sure I can be of some help :D!

Edited by SuperDavid
Link to comment
Share on other sites

@Lumina @SuperDavid Thanks guys.  The problem isn't with the anim files themselves, they both work fine on their own.  I simply can't seem to reassign a prefab's build to anything other than the anim that shares its name.  Perhaps, since I'm doing it in master_postinit, the game overwrites my change before it starts?  I can change the character's build with no issue if I use SetBuild in the console, so it may just be a matter of when I'm calling it.  I'll link the latest version of the mod, where I try to get the "testchar" prefab to use Wendy's build.

TESTMOD.rar

Link to comment
Share on other sites

@ViewtifulDom Hey, so I think I fixed your problem TestChar DST Mod.zip, have fun :D~!

So, I will now tell you what your problem was...

  1. Your character didn't have a "YOURCHARACTER_none.lua" that's something very important all characters need!
  2. Your character didn't have a texture for becoming a ghost, so you'd probably become invisible when you die, so I added a ghost build.

That's all :)! So, I added a code that when your character equips a handslot item his texture changes to Wendy & when he unequips the handslot item he changes back to Testchar then you can see if it works for yourself, so have a great time & happy modding :D~!

 

Edited by SuperDavid
Link to comment
Share on other sites

Thanks for all your effort @SuperDavid, but it doesn't solve my problem.  Like I said, I can change the character's build without issue in the console, so changing it in on the "equip" event doesn't help me.  I need the character's build to be changed on its initialization, like the Playable Pets mod does.  As for testchar_none.lua and the ghost build, I'm aware they're missing, but they're unnecessary for this particular test.

Link to comment
Share on other sites

I'm sorry to hear I couldn't help fix your problem & I don't really understand what "character's build to be changed on its initialization" means, & I've never used the Playable Pets mod.. So, I probably can't be of any help :(... Though, I wish you good luck for what you're trying to do :D!! 

Edited by SuperDavid
Link to comment
Share on other sites

So are you trying to do this via the Skin Mod API?

Spoiler

 

If you are wanting to use the Skin mod to change the your build on initialization you will need a prefab file named after the skin name. So for example: 


AddModCharacterSkin("bearplayer", "formal", {normal_skin = "bearger_shiny_build_01", ghost_skin = "ghost_monster_build"}, {"bearger_shiny_build_01", "ghost_monster_build"}, {"BEARPLAYER", "FORMAL"})
 

Then you will need to make a bearplayer_formal.lua. You can look into Playable Pets files to see how the prefab file is setup.

Also if you want to use a specific build under specific conditions, use the inst.CurrentModdedSkin = "formal_or_whatever" for your statements. Note that CurrentModdedSkin is not loaded on initialzation so you can't use it in masterpostinit, you might have to do a DoTaskInTime function.

 

If not via Skin mod then why not have the character use the build you want in masterpostinit (which I am assuming since you want it changed on  initialization, unless I'm not understanding something?).

 

 

Link to comment
Share on other sites

@DarkKingBoo After closer inspection, it looks like that's what I was trying to do after all.  Although I don't understand your final suggestion; changing the build in masterpostinit is exactly what I tried, and it didn't work, which is the problem.  Should this work?:

local master_postinit = function(inst)
	inst.AnimState:SetBuild("build_with_different_name_than_the_prefab")
end

 

Link to comment
Share on other sites

It should, the only reason why it wouldn't work if it wasn't compatible with anim. I've never created a custom character outside of mobs, so I'm just assuming that the anim is just copy/paste of wilson. If the build is not working with the current anim, then it might need a custom anim/bank for it. Which means you'll need to change the bank as well.

Although if you said you were able to change the build just fine via console commands, I'm not sure why it wouldn't work when in masterpostinit. Does your character becomes invisible when you try to set this build, or does he just use his default build?

Link to comment
Share on other sites

@DarkKingBoo I tried it once with two custom character anims.  When both character anims were present, and testchar1's build was set to testchar2 in masterpostinit, it would simply default to testchar1's build.  When I removed testchar1's anim, and again set its build to testchar2 in masterpostinit, it would turn invisible.  Both character anims had been tested elsewhere and worked fine.  Like you, whenever I create a custom mob, I can set the build, bank, and stategraph in masterpostinit with no problem.  For some reason, any character I create always seems to default to the anim that share's its prefab name despite changing it's build in masterpostinit.  It must get overridden even after masterpostinit?

Link to comment
Share on other sites

Its very possible it is getting overridden after mastpost_init. I had a similar problem with trying to make custom skins work on bearplayer (which was fixed by having bearplayer_none.lua and bearplayer_formal.lua). A temporary solution would be to make a inst:DoTaskInTime(3, function(inst) inst.SetBuild("thebuildyouwant") end) in the masterpostinit. You might be able to go below 3 (and maybe make it to where its not noticeable) but be noted that if you make it too low, it will work fine for you but not other players. Especially players with bad ping.

I'll take a look at your mod later tonight and see if I can a way to fix it.

Edit: It seems like master_postinit isn't even running, I'm trying to figure out why.

Edited by DarkKingBoo
Link to comment
Share on other sites

So a couple questions, with the character you're making are you wanting them to change builds after something occurs like on a Full Moon or are you wanting the character to start the game looking like a different model? I think what might be occurring is the order in which the game builds your character model. The Build you're trying to push through Master Postinit may occur before the original character model is made and then gets overridden. 

Link to comment
Share on other sites

@DarkKingBoo @RedHairedHero Thanks for taking the time, guys.  I figured it was probably being overridden after masterpostinit, and I don't know where else to call it without using a messy DoTaskInTime.  To clarify, RedHairedHero, my goal is for the character to start the game looking like a different model.  Is there perhaps some sort of "OnSpawn" event or function I could use?  That would actually solve several other problems I'm having as well.

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