aswig and multiplayer fixes
This commit is contained in:
parent
d25800eca4
commit
1bdf77e8d6
6 changed files with 102 additions and 49 deletions
|
|
@ -804,4 +804,24 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "ClearFood")]
|
||||
public static class Aswid_Player_ClearFood_Patch
|
||||
{
|
||||
public static bool Prefix(Player __instance)
|
||||
{
|
||||
if (__instance == Player.m_localPlayer && AswidRace.IsAswid())
|
||||
{
|
||||
// Retain food if the player is dead/dying.
|
||||
// Allows Bukeperries to still clear food normally.
|
||||
if (__instance.IsDead() || __instance.GetHealth() <= 0f)
|
||||
{
|
||||
Jotunn.Logger.LogInfo("[AswidRace] Preserving food buffs through death (Aswid racial trait).");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ namespace RacesOfValheim
|
|||
{ "Ulv", "BloodPudding" },
|
||||
{ "Seeker", "CookedBugMeat" },
|
||||
{ "SeekerBrute", "CookedBugMeat" },
|
||||
{ "SeekerBrood", "CookedBugMeat" }
|
||||
{ "SeekerBrood", "CookedBugMeat" },
|
||||
{ "Surtling", "BloodPudding" },
|
||||
{ "Bear", "CookedBearMeat" }
|
||||
};
|
||||
|
||||
public static bool BypassAswidFoodCheck = false;
|
||||
|
|
@ -139,11 +141,16 @@ namespace RacesOfValheim
|
|||
{
|
||||
burnTime = 1200f; // 20 minutes
|
||||
}
|
||||
else if (mobName == "Greyling") { foodHp = 20f; burnTime = 1200f; }
|
||||
else if (mobName == "Greydwarf") { foodHp = 25f; burnTime = 1200f; }
|
||||
else if (mobName == "Greydwarf_Shaman") { foodHp = 30f; burnTime = 1200f; }
|
||||
else if (mobName == "Greydwarf_Elite") { foodHp = 60f; burnTime = 1800f; }
|
||||
|
||||
customItem.ItemDrop.m_itemData.m_shared.m_food = foodHp;
|
||||
customItem.ItemDrop.m_itemData.m_shared.m_foodStamina = 0f;
|
||||
customItem.ItemDrop.m_itemData.m_shared.m_foodEitr = 0f;
|
||||
customItem.ItemDrop.m_itemData.m_shared.m_foodBurnTime = burnTime;
|
||||
customItem.ItemDrop.m_itemData.m_shared.m_foodRegen = 1f;
|
||||
customItem.ItemDrop.m_itemData.m_shared.m_foodRegen = Mathf.Max(1f, foodHp / 15f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -579,6 +586,11 @@ namespace RacesOfValheim
|
|||
if (playerVisual != null)
|
||||
{
|
||||
playerVisual.gameObject.SetActive(true);
|
||||
|
||||
ZSyncAnimation zanim = Player.m_localPlayer.GetComponent<ZSyncAnimation>();
|
||||
if (zanim != null) zanim.SetBool("sit", false);
|
||||
Animator anim = playerVisual.GetComponent<Animator>();
|
||||
if (anim != null) anim.SetBool("sit", false);
|
||||
}
|
||||
|
||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_BatForm".GetStableHashCode(), true);
|
||||
|
|
@ -690,6 +702,11 @@ namespace RacesOfValheim
|
|||
if (playerVisual != null)
|
||||
{
|
||||
playerVisual.gameObject.SetActive(true);
|
||||
|
||||
ZSyncAnimation zanim = Player.m_localPlayer.GetComponent<ZSyncAnimation>();
|
||||
if (zanim != null) zanim.SetBool("sit", false);
|
||||
Animator anim = playerVisual.GetComponent<Animator>();
|
||||
if (anim != null) anim.SetBool("sit", false);
|
||||
}
|
||||
|
||||
float elapsed = 0f;
|
||||
|
|
@ -1092,3 +1109,5 @@ namespace RacesOfValheim
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ namespace RacesOfValheim
|
|||
formInstance.name = wanted;
|
||||
formInstance.transform.localPosition = formName == "Hatchling" ? new Vector3(0f, -1.0f, 0f) : Vector3.zero;
|
||||
formInstance.transform.localRotation = Quaternion.identity;
|
||||
|
||||
if (formInstance.GetComponent<RemoteSkadiAnimator>() == null)
|
||||
{
|
||||
formInstance.AddComponent<RemoteSkadiAnimator>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +88,34 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
public class RemoteSkadiAnimator : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
private Player player;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
if (anim == null) anim = GetComponentInChildren<Animator>();
|
||||
player = GetComponentInParent<Player>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (anim == null || player == null) return;
|
||||
|
||||
bool flying = HarmonyLib.Traverse.Create(player).Field<bool>("m_flying").Value;
|
||||
bool grounded = !flying && player.IsOnGround();
|
||||
|
||||
anim.SetBool("onGround", grounded);
|
||||
anim.SetBool("flying", flying);
|
||||
|
||||
Vector3 vel = player.GetVelocity();
|
||||
vel.y = 0f;
|
||||
anim.SetFloat("forward_speed", vel.magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
|
||||
public static class SkadiSEManPatch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ namespace RacesOfValheim
|
|||
|
||||
if (prefab != null && playerVisual != null)
|
||||
{
|
||||
playerVisual.localScale = Vector3.one * 0.001f;
|
||||
playerVisual.gameObject.SetActive(false);
|
||||
|
||||
Transform visual = prefab.transform.Find("Visual");
|
||||
if (visual != null)
|
||||
|
|
@ -726,6 +726,11 @@ namespace RacesOfValheim
|
|||
{
|
||||
playerVisual.localScale = Vector3.one;
|
||||
playerVisual.gameObject.SetActive(true);
|
||||
|
||||
ZSyncAnimation zanim = Player.m_localPlayer.GetComponent<ZSyncAnimation>();
|
||||
if (zanim != null) zanim.SetBool("sit", false);
|
||||
Animator anim = playerVisual.GetComponent<Animator>();
|
||||
if (anim != null) anim.SetBool("sit", false);
|
||||
}
|
||||
|
||||
isTransformed = false;
|
||||
|
|
|
|||
|
|
@ -142,9 +142,11 @@ namespace RacesOfValheim
|
|||
if (visual == null) return;
|
||||
|
||||
float targetScale = ScaleForState(state);
|
||||
if (isTrueFormActive)
|
||||
{
|
||||
targetScale = state >= 7 ? 2.5f : 2.0f;
|
||||
}
|
||||
|
||||
// TEMPORARY: remote Trol sizing still is not showing up for observers and static
|
||||
// reading has not explained why, so report what each observer actually computes.
|
||||
if (!isLocal && Time.time - lastRemoteLog > 2f)
|
||||
{
|
||||
lastRemoteLog = Time.time;
|
||||
|
|
@ -156,18 +158,26 @@ namespace RacesOfValheim
|
|||
|
||||
if (race == "Trol")
|
||||
{
|
||||
// Prevent overriding scale while transforming or in True Form
|
||||
// Local player has a coroutine that smooth-scales during the active transformation,
|
||||
// so don't fight it here. Otherwise, lerp the scale (for remote players, or to
|
||||
// maintain base size).
|
||||
bool isTransforming = isLocal && TrolRace.Instance != null && TrolRace.Instance.isTransforming;
|
||||
|
||||
if (!isTrueFormActive && !isTransforming &&
|
||||
visual.transform.localScale != new Vector3(targetScale, targetScale, targetScale))
|
||||
if (!isTransforming)
|
||||
{
|
||||
visual.transform.localScale = new Vector3(targetScale, targetScale, targetScale);
|
||||
if (Mathf.Abs(visual.transform.localScale.x - targetScale) > 0.005f)
|
||||
{
|
||||
float newScale = Mathf.Lerp(visual.transform.localScale.x, targetScale, Time.deltaTime * 5f);
|
||||
visual.transform.localScale = new Vector3(newScale, newScale, newScale);
|
||||
}
|
||||
else if (visual.transform.localScale.x != targetScale)
|
||||
{
|
||||
visual.transform.localScale = new Vector3(targetScale, targetScale, targetScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (visual.transform.localScale == new Vector3(targetScale, targetScale, targetScale))
|
||||
else if (Mathf.Abs(visual.transform.localScale.x - 1f) > 0.001f)
|
||||
{
|
||||
// Reset scale if not Trol
|
||||
visual.transform.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ namespace RacesOfValheim
|
|||
{
|
||||
UpdateAswidVisuals();
|
||||
}
|
||||
else if (race == "Trol")
|
||||
{
|
||||
// Managed externally in TrolPatches.cs
|
||||
}
|
||||
else
|
||||
{
|
||||
RevertAllVisuals();
|
||||
|
|
@ -230,44 +234,6 @@ namespace RacesOfValheim
|
|||
$"[SkadiSync] remote '{m_player.GetPlayerName()}' form='{currentForm}' flying={flying} " +
|
||||
$"y={m_player.transform.position.y:F1} gravity={(body != null ? body.useGravity.ToString() : "no-body")}");
|
||||
}
|
||||
|
||||
if (currentForm != m_lastSkadiForm)
|
||||
{
|
||||
// Form changed
|
||||
if (m_currentFormInstance != null) Destroy(m_currentFormInstance);
|
||||
|
||||
Transform playerVisual = m_player.transform.Find("Visual");
|
||||
if (playerVisual != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(currentForm))
|
||||
{
|
||||
playerVisual.localScale = Vector3.one;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerVisual.localScale = Vector3.one * 0.001f;
|
||||
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(currentForm);
|
||||
if (prefab != null)
|
||||
{
|
||||
Transform visual = prefab.transform.Find("Visual");
|
||||
if (visual != null)
|
||||
{
|
||||
m_currentFormInstance = Instantiate(visual.gameObject, m_player.transform);
|
||||
m_currentFormInstance.transform.localPosition = Vector3.zero;
|
||||
m_currentFormInstance.transform.localRotation = Quaternion.identity;
|
||||
Component animEvent = m_currentFormInstance.GetComponent("AnimEvent");
|
||||
if (animEvent != null) Destroy(animEvent);
|
||||
|
||||
foreach (var col in m_currentFormInstance.GetComponentsInChildren<Collider>())
|
||||
{
|
||||
Destroy(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lastSkadiForm = currentForm;
|
||||
}
|
||||
}
|
||||
|
||||
private void RevertAllVisuals()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue