feat(trol): skin and hair colour pickers in Trol - Appearance
Two Color entries, Skin Color and Hair Color (hair and beard), defaulting to the old peacock blue and golden blonde so no Trol changes on update. Each Trol publishes its choice on its own ZDO and every client paints that player with it; a Trol on an older build publishes nothing and shows the defaults. The menu preview, with no ZDO, reads the local config. The section is kept local by ConfigSync. README: New in block, Trol features line and a 1.5.10 changelog entry.
This commit is contained in:
parent
bb1ca57924
commit
65b488b5dc
4 changed files with 56 additions and 9 deletions
|
|
@ -31,6 +31,7 @@ namespace RacesOfValheim
|
||||||
"Skeleton - Visuals",
|
"Skeleton - Visuals",
|
||||||
"Sverm - Dorsal Spines",
|
"Sverm - Dorsal Spines",
|
||||||
"Sverm - Emberform",
|
"Sverm - Emberform",
|
||||||
|
"Trol - Appearance",
|
||||||
"War Vulture - Model",
|
"War Vulture - Model",
|
||||||
"War Vulture - Interface",
|
"War Vulture - Interface",
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,23 @@ namespace RacesOfValheim
|
||||||
// ─── Farming ───────────────────────────────────────────────────────────
|
// ─── Farming ───────────────────────────────────────────────────────────
|
||||||
public static ConfigEntry<float> UnarmedFarmingDamageBonusPerState;
|
public static ConfigEntry<float> UnarmedFarmingDamageBonusPerState;
|
||||||
|
|
||||||
|
// ─── Appearance ────────────────────────────────────────────────────────
|
||||||
|
public static ConfigEntry<Color> SkinColor;
|
||||||
|
public static ConfigEntry<Color> HairColor;
|
||||||
|
|
||||||
|
// The colours every Trol wore before these became settings. Also what a Trol on an older
|
||||||
|
// build of the mod shows as, since that build publishes no colour of its own.
|
||||||
|
public static readonly Color DefaultSkinColor = new Color(0.1f, 0.6f, 0.7f, 1f);
|
||||||
|
public static readonly Color DefaultHairColor = new Color(0.9f, 0.8f, 0.4f, 1f);
|
||||||
|
|
||||||
public static void Bind(ConfigFile config)
|
public static void Bind(ConfigFile config)
|
||||||
{
|
{
|
||||||
|
const string appearance = "Trol - Appearance";
|
||||||
|
SkinColor = config.Bind(appearance, "Skin Color", DefaultSkinColor,
|
||||||
|
new ConfigDescription("Your Trol's skin. Other players see it too. The game multiplies it with the skin texture, so it comes out a little darker than the swatch. For the look of Valheim's own trolls try 7FA8C9."));
|
||||||
|
HairColor = config.Bind(appearance, "Hair Color", DefaultHairColor,
|
||||||
|
new ConfigDescription("Your Trol's hair and beard. Other players see it too."));
|
||||||
|
|
||||||
const string keybinds = "Trol - Keybinds";
|
const string keybinds = "Trol - Keybinds";
|
||||||
ThrowRockKey = config.Bind(keybinds, "Throw Rock", new KeyboardShortcut(KeyCode.G),
|
ThrowRockKey = config.Bind(keybinds, "Throw Rock", new KeyboardShortcut(KeyCode.G),
|
||||||
new ConfigDescription("Throws a rock (or the log you're holding), tier 3+."));
|
new ConfigDescription("Throws a rock (or the log you're holding), tier 3+."));
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,23 @@ namespace RacesOfValheim
|
||||||
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
||||||
public static class TrolSkinColorPatch
|
public static class TrolSkinColorPatch
|
||||||
{
|
{
|
||||||
// Golden blonde hair
|
// Each Trol picks their own colours in Trol - Appearance and publishes them here (see
|
||||||
private static readonly Color HairColor = new Color(0.9f, 0.8f, 0.4f, 1f);
|
// Trol_PlayerUpdate_Patch), so everyone sees the colours that player chose. Stored without
|
||||||
|
// alpha: _SkinColor ignores it.
|
||||||
|
public const string SkinColorKey = "RacesOfValheim_TrolSkinColor";
|
||||||
|
public const string HairColorKey = "RacesOfValheim_TrolHairColor";
|
||||||
|
|
||||||
|
private static Vector3 ToVec3(Color c) => new Vector3(c.r, c.g, c.b);
|
||||||
|
private static Color ToColor(Vector3 v) => new Color(v.x, v.y, v.z, 1f);
|
||||||
|
|
||||||
|
/// <summary>Puts the local player's chosen colours on their ZDO. Only the owner writes.</summary>
|
||||||
|
public static void Publish(ZDO zdo)
|
||||||
|
{
|
||||||
|
Vector3 skin = ToVec3(TrolConfig.SkinColor.Value);
|
||||||
|
Vector3 hair = ToVec3(TrolConfig.HairColor.Value);
|
||||||
|
if (zdo.GetVec3(SkinColorKey, Vector3.negativeInfinity) != skin) zdo.Set(SkinColorKey, skin);
|
||||||
|
if (zdo.GetVec3(HairColorKey, Vector3.negativeInfinity) != hair) zdo.Set(HairColorKey, hair);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Postfix(VisEquipment __instance)
|
public static void Postfix(VisEquipment __instance)
|
||||||
{
|
{
|
||||||
|
|
@ -28,25 +43,38 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (race != "Trol") return;
|
if (race != "Trol") return;
|
||||||
|
|
||||||
// Apply skin, hair, beard colors here...
|
// The colours this Trol published. A Trol on an older build publishes none and keeps the
|
||||||
|
// defaults; with no ZDO at all (the main-menu preview) it is the local player's own
|
||||||
|
// character, so the local settings are the right answer.
|
||||||
|
Color skinColor, hairColor;
|
||||||
|
if (nview != null && nview.IsValid())
|
||||||
|
{
|
||||||
|
ZDO zdo = nview.GetZDO();
|
||||||
|
skinColor = ToColor(zdo.GetVec3(SkinColorKey, ToVec3(TrolConfig.DefaultSkinColor)));
|
||||||
|
hairColor = ToColor(zdo.GetVec3(HairColorKey, ToVec3(TrolConfig.DefaultHairColor)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skinColor = TrolConfig.SkinColor.Value;
|
||||||
|
hairColor = TrolConfig.HairColor.Value;
|
||||||
|
}
|
||||||
|
|
||||||
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
|
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
|
||||||
{
|
{
|
||||||
// Peacock blue (deep greenish-blue)
|
__instance.m_bodyModel.material.SetColor("_SkinColor", skinColor);
|
||||||
Color trolColor = new Color(0.1f, 0.6f, 0.7f, 1f);
|
|
||||||
__instance.m_bodyModel.material.SetColor("_SkinColor", trolColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hair
|
// Hair
|
||||||
var hairInst = Traverse.Create(__instance).Field("m_hairItemInstance").GetValue<GameObject>();
|
var hairInst = Traverse.Create(__instance).Field("m_hairItemInstance").GetValue<GameObject>();
|
||||||
if (hairInst != null)
|
if (hairInst != null)
|
||||||
foreach (var r in hairInst.GetComponentsInChildren<Renderer>())
|
foreach (var r in hairInst.GetComponentsInChildren<Renderer>())
|
||||||
if (r.material != null) r.material.SetColor("_SkinColor", HairColor);
|
if (r.material != null) r.material.SetColor("_SkinColor", hairColor);
|
||||||
|
|
||||||
// Beard
|
// Beard
|
||||||
var beardInst = Traverse.Create(__instance).Field("m_beardItemInstance").GetValue<GameObject>();
|
var beardInst = Traverse.Create(__instance).Field("m_beardItemInstance").GetValue<GameObject>();
|
||||||
if (beardInst != null)
|
if (beardInst != null)
|
||||||
foreach (var r in beardInst.GetComponentsInChildren<Renderer>())
|
foreach (var r in beardInst.GetComponentsInChildren<Renderer>())
|
||||||
if (r.material != null) r.material.SetColor("_SkinColor", HairColor);
|
if (r.material != null) r.material.SetColor("_SkinColor", hairColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,6 +156,7 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
nview.GetZDO().Set(StateKey, state);
|
nview.GetZDO().Set(StateKey, state);
|
||||||
nview.GetZDO().Set(TrueFormKey, isTrueFormActive);
|
nview.GetZDO().Set(TrueFormKey, isTrueFormActive);
|
||||||
|
if (race == "Trol") TrolSkinColorPatch.Publish(nview.GetZDO());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorT
|
||||||
|
|
||||||
## New in v1.5.10
|
## New in v1.5.10
|
||||||
|
|
||||||
Using a player model mod such as EnhancedValheimVRM? Turn off `Skeleton - Visuals` → `Body Model Enabled` and Skeletons keep the vanilla body, so no bones clip through your model. Full details in the [changelog](#v1510).
|
Using a player model mod such as EnhancedValheimVRM? Turn off `Skeleton - Visuals` → `Body Model Enabled` and Skeletons keep the vanilla body, so no bones clip through your model. Trols can pick their own skin and hair colour under `Trol - Appearance`. Full details in the [changelog](#v1510).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -72,6 +72,7 @@ Using a player model mod such as EnhancedValheimVRM? Turn off `Skeleton - Visual
|
||||||
- **Immense Strength:** Increased carry weight; armor scales up as you defeat bosses.
|
- **Immense Strength:** Increased carry weight; armor scales up as you defeat bosses.
|
||||||
- **Rock Throwing:** Hurl huge boulders at enemies.
|
- **Rock Throwing:** Hurl huge boulders at enemies.
|
||||||
- **Tree Weaponry:** At higher tiers, True Form lets you rip logs and wield them as weapons or throw them.
|
- **Tree Weaponry:** At higher tiers, True Form lets you rip logs and wield them as weapons or throw them.
|
||||||
|
- **Your Own Colours:** pick your skin and hair colour under `Trol - Appearance`. Other players see them too.
|
||||||
|
|
||||||
### 7. Draugh
|
### 7. Draugh
|
||||||
- **Born Dead, Buried Alive:** Undead warrior: resistant to physical/poison, weak to fire/spirit.
|
- **Born Dead, Buried Alive:** Undead warrior: resistant to physical/poison, weak to fire/spirit.
|
||||||
|
|
@ -450,6 +451,7 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact
|
||||||
|
|
||||||
### v1.5.10
|
### v1.5.10
|
||||||
- **New - Skeleton body switch for player model mods:** with EnhancedValheimVRM or another model replacer, the skeleton's bones stayed on screen and floated around the new model. Set `Skeleton - Visuals` → `Body Model Enabled` to off and Skeletons keep the vanilla body: no bones, eye lights or skull flames, and the helmet shows. Abilities don't change. The setting is client-side, so it applies to every Skeleton you see and changes nothing for other players. The race strips hair and beard, so the vanilla body is bald, and the auto-resurrection still shows the skeleton for the few seconds it climbs out of the ground. Thanks to the players who reported it and tested the fix.
|
- **New - Skeleton body switch for player model mods:** with EnhancedValheimVRM or another model replacer, the skeleton's bones stayed on screen and floated around the new model. Set `Skeleton - Visuals` → `Body Model Enabled` to off and Skeletons keep the vanilla body: no bones, eye lights or skull flames, and the helmet shows. Abilities don't change. The setting is client-side, so it applies to every Skeleton you see and changes nothing for other players. The race strips hair and beard, so the vanilla body is bald, and the auto-resurrection still shows the skeleton for the few seconds it climbs out of the ground. Thanks to the players who reported it and tested the fix.
|
||||||
|
- **New - Trol skin and hair colour:** `Trol - Appearance` has a colour picker for the skin and one for the hair and beard. Each Trol picks their own and every player sees them. The defaults are the old peacock blue and golden blonde, so nobody's Trol changes after the update. For the blue-grey of Valheim's own trolls, try `7FA8C9`. A Trol on an older version of the mod shows the defaults to everyone else. Thanks to the player who suggested it.
|
||||||
- **Fix - Russian translation:** corrections to several Russian texts, by Axibed.
|
- **Fix - Russian translation:** corrections to several Russian texts, by Axibed.
|
||||||
|
|
||||||
### v1.5.9
|
### v1.5.9
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue