Jump to content

how to se wig color?


pxd2050

Recommended Posts

I am doing a mod to change hair color and encounter a challenge: how to set a color for a wig.

I know that the bEnable TintHairSlot of Racemenu's skee64 can do it, but it has a bug with the wrong color.

Skee64 source code does not have the version for 1.597, and its hook code is difficult to understand.



I make a code:

After equip wig,over actor to get model of wig to set color.(This will first display the default color for the wig, and then refresh to the color I set)

I don't know how to set wig color before equip ,because There is no way to get model.

I try <SKSE::NiNodeUpdateEvent> but it don't work .



f*#@, I try many times can't post code.

Edited by pxd2050
Link to comment
Share on other sites

class NiNodeUpdateEventHandler : public RE::BSTEventSink<SKSE::NiNodeUpdateEvent>

{

public:

static NiNodeUpdateEventHandler* GetSingleton()

{

static NiNodeUpdateEventHandler singleton;

return &singleton;

}


virtual EventResult ProcessEvent(const SKSE::NiNodeUpdateEvent* a_event, RE::BSTEventSource<SKSE::NiNodeUpdateEvent>*)

{

auto actor = a_event->reference->As<RE::Actor>();

auto wig = actor->GetWornArmor(RE::BIPED_MODEL::BipedObjectSlot::kHair);

if (!a_event || !actor || !wig)

return EventResult::kContinue;


auto a_arma = wig->GetArmorAddonByMask(actor->GetRace(), RE::BIPED_MODEL::BipedObjectSlot::kHair);

if (a_arma) {

auto npc = actor->GetActorBase();

RE::NiColor color;


if (npc && npc->headRelatedData) {

const auto hairColor = npc->headRelatedData->hairColor;

if (hairColor) {

color.red = static_cast<float>(hairColor->color.red) / static_cast<float>(128.0);

color.green = static_cast<float>(hairColor->color.green) / static_cast<float>(128.0);

color.blue = static_cast<float>(hairColor->color.blue) / static_cast<float>(128.0);


auto ref = actor->As<RE::TESObjectREFR>();

if (ref) {

char addonString[MAX_PATH]{ '\0' };

a_arma->GetNodeName(addonString, ref, wig, -1);

auto skeletonRoot = ref->Get3D();

if (skeletonRoot) {

const auto obj = skeletonRoot->GetObjectByName(addonString);

if (obj) {

obj->UpdateHairColor(color);

}

}

}

}

}

}


return EventResult::kContinue;

}

Edited by pxd2050
Link to comment
Share on other sites

  • Recently Browsing   0 members

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