Initial commit
This commit is contained in:
commit
c4a24c9fdf
142 changed files with 15491 additions and 0 deletions
144
JotunnModStub/Skadi/SkadiPatches.cs
Normal file
144
JotunnModStub/Skadi/SkadiPatches.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
||||
public static class SkadiSkinColorPatch
|
||||
{
|
||||
public static void Postfix(VisEquipment __instance)
|
||||
{
|
||||
if (!__instance.m_isPlayer) return;
|
||||
Player player = __instance.GetComponent<Player>();
|
||||
if (player == null) return;
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Skadi")
|
||||
{
|
||||
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
|
||||
{
|
||||
// Azzurro molto chiaro
|
||||
Color skadiColor = new Color(0.6f, 0.8f, 1f, 1f);
|
||||
__instance.m_bodyModel.material.SetColor("_SkinColor", skadiColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
|
||||
public static class Skadi_MultiplayerVisuals_Patch
|
||||
{
|
||||
public static void Postfix(VisEquipment __instance)
|
||||
{
|
||||
if (!__instance.m_isPlayer) return;
|
||||
Player player = __instance.GetComponent<Player>();
|
||||
if (player == null || player.IsOwner()) return; // Only process remote players
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Skadi")
|
||||
{
|
||||
string formName = nview.GetZDO().GetString("RacesOfValheim_SkadiForm", "");
|
||||
|
||||
Transform playerVisual = player.transform.Find("Visual");
|
||||
Transform formBody = player.transform.Find("SkadiBody_Form");
|
||||
|
||||
if (!string.IsNullOrEmpty(formName)) {
|
||||
if (formBody != null && formBody.gameObject.name != formName + "_multiplayer") {
|
||||
UnityEngine.Object.Destroy(formBody.gameObject);
|
||||
formBody = null;
|
||||
}
|
||||
|
||||
if (formBody == null) {
|
||||
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(formName);
|
||||
if (prefab != null) {
|
||||
Transform visual = prefab.transform.Find("Visual");
|
||||
if (visual != null) {
|
||||
GameObject formInstance = UnityEngine.Object.Instantiate(visual.gameObject, player.transform);
|
||||
formInstance.name = formName + "_multiplayer";
|
||||
if (formName == "Hatchling") formInstance.transform.localPosition = new Vector3(0f, -1.0f, 0f);
|
||||
else formInstance.transform.localPosition = Vector3.zero;
|
||||
formInstance.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (playerVisual != null) playerVisual.gameObject.SetActive(false);
|
||||
} else {
|
||||
if (formBody != null) UnityEngine.Object.Destroy(formBody.gameObject);
|
||||
|
||||
// Fader form has a different name? "SkadiBody_Form" was used earlier, we just find all children and destroy them if they have "_multiplayer"
|
||||
foreach (Transform child in player.transform) {
|
||||
if (child.name.EndsWith("_multiplayer")) {
|
||||
UnityEngine.Object.Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
if (playerVisual != null) playerVisual.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
|
||||
public static class SkadiSEManPatch
|
||||
{
|
||||
public static bool Prefix(SEMan __instance, ref int nameHash)
|
||||
{
|
||||
Character character = Traverse.Create(__instance).Field<Character>("m_character").Value;
|
||||
if (character == Player.m_localPlayer && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
|
||||
{
|
||||
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||
|
||||
if (nameHash == "Cold".GetStableHashCode() && rules.ImmuneToCold)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nameHash == "Freezing".GetStableHashCode())
|
||||
{
|
||||
if (rules.ImmuneToFreezing) return false;
|
||||
|
||||
if (rules.FreezingToCold)
|
||||
{
|
||||
nameHash = "Cold".GetStableHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage")]
|
||||
public static class SkadiDamagePatch
|
||||
{
|
||||
public static void Prefix(Character __instance, ref HitData hit)
|
||||
{
|
||||
if (hit.GetAttacker() != null && hit.GetAttacker() == Player.m_localPlayer)
|
||||
{
|
||||
if (SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
|
||||
{
|
||||
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||
if (rules.BonusFrostDamage)
|
||||
{
|
||||
hit.m_damage.m_frost += 2f * BossProgressionManager.GetCurrentProgressionState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), "StartAttack")]
|
||||
public static class SkadiAttackPatch
|
||||
{
|
||||
public static bool Prefix(Humanoid __instance)
|
||||
{
|
||||
if (__instance == Player.m_localPlayer && __instance.GetComponentInChildren<DrakeFormBehavior>() != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue