Jump to content

Change Head part with script


Recommended Posts

Spoiler

HeadPart Property ZZZ_headp1 Auto const mandatory;
HeadPart Property ZZZ_eyes Auto const mandatory;
HeadPart Property ZZZ_lashes Auto const mandatory;
HeadPart Property ZZZ_jaw Auto const mandatory;
HeadPart Property ZZZ_blankhair Auto const mandatory;
HeadPart Property ZZZ_blankeye Auto const mandatory;

HeadPart[] tHeadParts;
int nCount;

Event OnEquipped(Actor akActor)
	;Debug.MessageBox("ZZZ ARM equipped")
	tHeadParts = akActor.GetActorBase().GetHeadParts();
	nCount = tHeadParts.Length;
	
	int i = 0;
	while (i < nCount) 
		HeadPart tPart = tHeadParts[i];
		;Debug.MessageBox("Part " + i + " [" + tPart.GetName() + "]" + " is " + tPart.GetType());
		akActor.ChangeHeadPart(tHeadParts[i], true);
		i = i + 1;                      
	endwhile
	
	
	
	akActor.ChangeHeadPart(ZZZ_headp1);
	akActor.ChangeHeadPart(ZZZ_eyes);
	akActor.ChangeHeadPart(ZZZ_lashes);
	akActor.ChangeHeadPart(ZZZ_jaw);
	akActor.ChangeHeadPart(ZZZ_blankhair);
	akActor.ChangeHeadPart(ZZZ_blankeye);
	
endEvent

Event OnUnequipped(Actor akActor)
	;Debug.MessageBox("ZZZ arm unequipped")

	akActor.ChangeHeadPart(ZZZ_headp1, true, true);
	akActor.ChangeHeadPart(ZZZ_eyes, true, true);
	akActor.ChangeHeadPart(ZZZ_lashes, true, true);
	akActor.ChangeHeadPart(ZZZ_jaw, true, true);
	akActor.ChangeHeadPart(ZZZ_blankhair, true, true);
	akActor.ChangeHeadPart(ZZZ_blankeye, true, true);
	
	int i = 0;
	while (i < nCount) 
		HeadPart tPart = tHeadParts[i];
		;Debug.MessageBox("Part " + i + " [" + tPart.GetName() + "]" + " is " + tPart.GetType());
		akActor.ChangeHeadPart(tHeadParts[i]);
		i = i + 1;
	endwhile
endEvent

 

 

Was trying to apply another face to actor who equiping armor, with support for face expressions, mostly work, but have some small problems:

1)

akActor.ChangeHeadPart(tHeadParts, true);

 

don't work for hair, script can find hair but cant remove it

only when I apply blank (no mesh) head part with hair slot result in hair disappears, but I also cant return hair back

 

2)

How I can store head part for different actors in variable to return their headpart back when armor is unequipped


HeadPart[] tHeadParts = akActor.GetActorBase().GetHeadParts();

 

3)

When I equip, then unequip, then again equip I can see eye lashes from base face, and their will appear again each time armor equipping

Why they dont appear first time, I dont know how to remove them, blank eyes and lashes cant remove them

 

4)

When I select "facegen texture" for face slot model - face appearing with previous face texture (equipped before armor equip) and it is required to use looksmenu to apply proper textures

When I select non facegen - model in face slot dont appear first time when equipping armor

 

 

I saw example with facechange with "preset" option in looksmenu, but it ruin all bodygen morphs

Link to comment

4)Solution

BodyGen.SetSkinOverride(akActor, "Your id of textures in F4SE\Plugins\F4EE\Skin\youresp.esp\skin.json")

 

when remove outfit:

BodyGen.RemoveSkinOverride(akActor);

 

warning:RemoveSkinOverride before returning headparts, otherwise script may crash game

 

For other 3 I decided to dont return face parts and leave the return of the previous preset to the user

Link to comment

@Indarello my experiments with head part swapping and race changes seem to have ended with the same results as yours. I eventually manage to replace all head parts except for the hair, and the old hair gets stuck with no way to change or remove it.

 

If you do happen to find a way to fix that and change/remove the hair as well, please do post how it's done, it would really come in handy for something I'd like to work on.

Link to comment
4 hours ago, Blaze69 said:

@Indarello my experiments with head part swapping and race changes seem to have ended with the same results as yours. I eventually manage to replace all head parts except for the hair, and the old hair gets stuck with no way to change or remove it.

 

If you do happen to find a way to fix that and change/remove the hair as well, please do post how it's done, it would really come in handy for something I'd like to work on.

As I said, you can replace hair only with another headpart with "hair" slot, this another headpart can be without mesh or with your custom mesh, dont know if replace by base fallout 4 list of hair will work

 

Link to comment
6 hours ago, Indarello said:

As I said, you can replace hair only with another headpart with "hair" slot, this another headpart can be without mesh or with your custom mesh, dont know if replace by base fallout 4 list of hair will work

From my testing, you can load any hair you want indeed. The problem is it looks like whatever hair you load will be stuck and you won't be able to change it using LooksMenu.

 

This is a problem because my plan was to set a default/empty hair record and then let the player pick the actual hair they want to use by "normal" means like using the barber chair or getting a mod like the LooksMenu Mirror. That's why I hoped there was a way to not screw up the hair after changing head parts and/or race via script.

Link to comment
3 hours ago, Carabosse said:

Would QueueUpdate help with applying changes to hair?

 

I've only ever used it for making body triangle changes, with the body only flag as per the wiki.

Worth a try at least, I guess. The main issue here is not getting the hair you force to load, but rather the fact that once you do it you cannot change the hair style using looksmenu and are stuck with the one you chose in the script, though, so I'm not sure it will actually help.

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use