Merge branch 'main' into race-chains-and-stations
# Conflicts: # JotunnModStub/Aswid/AswidRace.cs # JotunnModStub/Factions/FactionHostilityPatch.cs # JotunnModStub/Factions/FactionMerchantCatalog.cs # JotunnModStub/Furling/FurlingPatches.cs
This commit is contained in:
commit
f60b8d8f7d
48 changed files with 1865 additions and 380 deletions
|
|
@ -335,8 +335,8 @@ namespace RacesOfValheim
|
|||
anim.cullingMode = AnimatorCullingMode.AlwaysAnimate;
|
||||
}
|
||||
|
||||
HideItemInstances(__instance, "m_hairItemInstances");
|
||||
HideItemInstances(__instance, "m_beardItemInstances");
|
||||
HideItemInstances(__instance, "m_hairItemInstance");
|
||||
HideItemInstances(__instance, "m_beardItemInstance");
|
||||
SetHelmetVisible(__instance, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -359,8 +359,8 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
ShowItemInstances(__instance, "m_hairItemInstances");
|
||||
ShowItemInstances(__instance, "m_beardItemInstances");
|
||||
ShowItemInstances(__instance, "m_hairItemInstance");
|
||||
ShowItemInstances(__instance, "m_beardItemInstance");
|
||||
SetHelmetVisible(__instance, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -375,70 +375,61 @@ namespace RacesOfValheim
|
|||
/// first frame after a race change, all of which reach this postfix and none of which
|
||||
/// reach SkeletonRace.
|
||||
///
|
||||
/// Scaled rather than deactivated, because Valheim re-enables the instance whenever it
|
||||
/// refreshes visuals - the approach the Dvergar's hood already proved out.
|
||||
/// Delegates to SkeletonVisuals.SetEquipmentPieceHidden, which scales the wrapper to
|
||||
/// zero and disables its renderers - scale alone leaves a skinned piece (bound to the
|
||||
/// player's own bones rather than its own transform) still drawing, which is what a
|
||||
/// helmet with a skinned cloth or chain part looked like.
|
||||
/// </summary>
|
||||
private static void SetHelmetVisible(VisEquipment visEq, bool visible)
|
||||
{
|
||||
GameObject helmet = Traverse.Create(visEq).Field<GameObject>("m_helmetItemInstance").Value;
|
||||
if (helmet == null) return;
|
||||
|
||||
Vector3 wanted = visible ? Vector3.one : Vector3.zero;
|
||||
|
||||
// Only ever undo our own hiding: another race may legitimately be scaling this.
|
||||
if (!visible && helmet.transform.localScale != Vector3.zero)
|
||||
{
|
||||
helmet.transform.localScale = wanted;
|
||||
}
|
||||
else if (visible && helmet.transform.localScale == Vector3.zero)
|
||||
{
|
||||
helmet.transform.localScale = wanted;
|
||||
}
|
||||
SkeletonVisuals.SetEquipmentPieceHidden(helmet, !visible);
|
||||
}
|
||||
|
||||
private static void HideItemInstances(VisEquipment visEq, string fieldName)
|
||||
{
|
||||
SetItemInstanceActive(visEq, fieldName, false);
|
||||
}
|
||||
|
||||
private static void ShowItemInstances(VisEquipment visEq, string fieldName)
|
||||
{
|
||||
SetItemInstanceActive(visEq, fieldName, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hair and beard live in VisEquipment as a single GameObject (m_hairItemInstance /
|
||||
/// m_beardItemInstance), the same as the helmet - not a list. A previous version of
|
||||
/// this looked for "m_hairItemInstances" / "m_beardItemInstances" (plural), which do
|
||||
/// not exist on VisEquipment, so the reflection lookup silently found nothing and the
|
||||
/// beard never got the SetActive(false) this was supposed to give it. Handling both
|
||||
/// shapes here matches the defensive pattern the Furling race already uses.
|
||||
/// </summary>
|
||||
private static void SetItemInstanceActive(VisEquipment visEq, string fieldName, bool active)
|
||||
{
|
||||
try
|
||||
{
|
||||
var field = typeof(VisEquipment).GetField(fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
if (field != null)
|
||||
if (field == null) return;
|
||||
|
||||
object value = field.GetValue(visEq);
|
||||
if (value is GameObject go)
|
||||
{
|
||||
var list = field.GetValue(visEq) as System.Collections.Generic.List<GameObject>;
|
||||
if (list != null)
|
||||
if (go != null) go.SetActive(active);
|
||||
}
|
||||
else if (value is System.Collections.Generic.List<GameObject> list)
|
||||
{
|
||||
foreach (GameObject item in list)
|
||||
{
|
||||
foreach (GameObject go in list)
|
||||
{
|
||||
if (go != null) go.SetActive(false);
|
||||
}
|
||||
if (item != null) item.SetActive(active);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"Failed to hide {fieldName}: {e.Message}");
|
||||
Jotunn.Logger.LogWarning($"Failed to set {fieldName} active={active}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ShowItemInstances(VisEquipment visEq, string fieldName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var field = typeof(VisEquipment).GetField(fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
if (field != null)
|
||||
{
|
||||
var list = field.GetValue(visEq) as System.Collections.Generic.List<GameObject>;
|
||||
if (list != null)
|
||||
{
|
||||
foreach (GameObject go in list)
|
||||
{
|
||||
if (go != null) go.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e) { }
|
||||
}
|
||||
|
||||
// Bones worth reporting on. Not remapped - the player rig has a real 'Jaw' bone and the
|
||||
// name match lands on it correctly, which is exactly why the plain and poison skeletons
|
||||
// always looked right. An earlier attempt pinned this group to the head instead and
|
||||
|
|
@ -605,16 +596,16 @@ namespace RacesOfValheim
|
|||
if (attacker != null && attacker == Player.m_localPlayer && SkeletonRace.IsSkeleton())
|
||||
{
|
||||
// Auto Stun
|
||||
if (rules.AutoStunFirstHit && Time.time - lastStunTime > 5f)
|
||||
if (rules.AutoStunFirstHit && Time.time - lastStunTime > SkeletonConfig.AutoStunCooldown.Value)
|
||||
{
|
||||
hit.m_staggerMultiplier = 100f; // Force stagger
|
||||
hit.m_staggerMultiplier = SkeletonConfig.AutoStunStaggerMultiplier.Value; // Force stagger
|
||||
lastStunTime = Time.time;
|
||||
}
|
||||
|
||||
// Poison Attacks
|
||||
if (rules.PoisonAttacks)
|
||||
{
|
||||
hit.m_damage.m_poison += 20f; // Add flat 20 poison damage
|
||||
hit.m_damage.m_poison += SkeletonConfig.PoisonAttackBonus.Value;
|
||||
}
|
||||
|
||||
// Lifesteal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue