Initial commit
This commit is contained in:
commit
c4a24c9fdf
142 changed files with 15491 additions and 0 deletions
1030
JotunnModStub/Fenrir/FenrirBehaviors.cs
Normal file
1030
JotunnModStub/Fenrir/FenrirBehaviors.cs
Normal file
File diff suppressed because it is too large
Load diff
97
JotunnModStub/Fenrir/FenrirPatches.cs
Normal file
97
JotunnModStub/Fenrir/FenrirPatches.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using System.Collections;
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI; // Added for UI
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
[HarmonyPatch(typeof(Character), nameof(Character.StartAttack))]
|
||||
public static class BlockPlayerLogicAttackPatch
|
||||
{
|
||||
public static bool Prefix(Character __instance)
|
||||
{
|
||||
if (__instance != null && __instance == Player.m_localPlayer)
|
||||
{
|
||||
if (__instance.GetSEMan().HaveStatusEffect("SE_FenrirForm".GetStableHashCode()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// --- PATCH 2: BLOCCO ANIMAZIONI ED EFFETTI SONORI NATIVI ---
|
||||
[HarmonyPatch(typeof(ZSyncAnimation), nameof(ZSyncAnimation.SetTrigger))]
|
||||
public static class BlockPlayerAnimationsPatch
|
||||
{
|
||||
public static bool Prefix(ZSyncAnimation __instance, string name)
|
||||
{
|
||||
if (Player.m_localPlayer != null && __instance.gameObject == Player.m_localPlayer.gameObject)
|
||||
{
|
||||
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_FenrirForm".GetStableHashCode()))
|
||||
{
|
||||
string triggerName = name.ToLower();
|
||||
if (triggerName.Contains("attack") || triggerName.Contains("swing") || triggerName.Contains("punch"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class FenrirDamagePatch
|
||||
{
|
||||
[HarmonyTargetMethod]
|
||||
public static System.Reflection.MethodBase TargetMethod()
|
||||
{
|
||||
return System.Linq.Enumerable.FirstOrDefault(
|
||||
HarmonyLib.AccessTools.GetDeclaredMethods(typeof(ItemDrop.ItemData)),
|
||||
m => m.Name == "GetDamage" && m.ReturnType == typeof(HitData.DamageTypes)
|
||||
);
|
||||
}
|
||||
public static void Postfix(ItemDrop.ItemData __instance, ref HitData.DamageTypes __result)
|
||||
{
|
||||
if (Player.m_localPlayer != null &&
|
||||
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_FenrirCurse".GetStableHashCode()) &&
|
||||
Player.m_localPlayer.GetInventory().ContainsItem(__instance))
|
||||
{
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
if (state > 0)
|
||||
{
|
||||
float bonus = FenrirProgression.GetDamageBonus(state);
|
||||
|
||||
if (__result.m_slash > 0) __result.m_slash += bonus;
|
||||
if (__result.m_blunt > 0) __result.m_blunt += bonus;
|
||||
if (__result.m_pierce > 0) __result.m_pierce += bonus;
|
||||
if (__result.m_chop > 0) __result.m_chop += bonus;
|
||||
if (__result.m_pickaxe > 0) __result.m_pickaxe += bonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.GetBodyArmor))]
|
||||
public static class FenrirArmorPatch
|
||||
{
|
||||
public static void Postfix(Player __instance, ref float __result)
|
||||
{
|
||||
if (__instance != null && __instance == Player.m_localPlayer)
|
||||
{
|
||||
if (__instance.GetSEMan().HaveStatusEffect("SE_FenrirCurse".GetStableHashCode()))
|
||||
{
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
__result += FenrirProgression.GetArmorBonus(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
84
JotunnModStub/Fenrir/FenrirProgression.cs
Normal file
84
JotunnModStub/Fenrir/FenrirProgression.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
public static class FenrirProgression
|
||||
{
|
||||
public enum FormType
|
||||
{
|
||||
None,
|
||||
Wolf,
|
||||
Ulv,
|
||||
Fenring,
|
||||
Cultist
|
||||
}
|
||||
|
||||
public class FormRules
|
||||
{
|
||||
public FormType Form;
|
||||
public bool NeedsNight;
|
||||
public float DurationMinutes;
|
||||
public float CooldownMinutes;
|
||||
|
||||
public FormRules(FormType form, bool needsNight, float duration, float cooldown)
|
||||
{
|
||||
Form = form;
|
||||
NeedsNight = needsNight;
|
||||
DurationMinutes = duration;
|
||||
CooldownMinutes = cooldown;
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetArmorBonus(int state)
|
||||
{
|
||||
return 3f * state;
|
||||
}
|
||||
|
||||
public static float GetDamageBonus(int state)
|
||||
{
|
||||
return 5f * state;
|
||||
}
|
||||
|
||||
public static float GetFallDamageModifier(int state)
|
||||
{
|
||||
return Mathf.Clamp(-0.1f * state, -1f, 0f);
|
||||
}
|
||||
|
||||
public static float GetSpeedModifier(int state)
|
||||
{
|
||||
return 0.03f * state;
|
||||
}
|
||||
|
||||
public static float GetJumpModifier(int state)
|
||||
{
|
||||
return 0.03f * state;
|
||||
}
|
||||
|
||||
// --- Transformation Rules for Keys ---
|
||||
|
||||
public static FormRules GetGKeyRules(int state)
|
||||
{
|
||||
if (state >= 5) return new FormRules(FormType.Ulv, false, 0f, 0f); // Moder: Ulv (Day/Night)
|
||||
if (state >= 4) return new FormRules(FormType.Wolf, false, 0f, 0f); // Bonemass: Wolf (Day/Night)
|
||||
if (state >= 3) return new FormRules(FormType.Wolf, true, 0f, 0f); // Elder: Wolf (Night)
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FormRules GetHKeyRules(int state)
|
||||
{
|
||||
if (state >= 7) return new FormRules(FormType.Fenring, false, 0f, 0f); // Queen: Fenrir (Day/Night)
|
||||
if (state >= 5) return new FormRules(FormType.Fenring, true, 0f, 0f); // Moder: Fenrir (Night)
|
||||
if (state >= 4) return new FormRules(FormType.Ulv, true, 0f, 0f); // Bonemass: Ulv (Night)
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FormRules GetJKeyRules(int state)
|
||||
{
|
||||
if (state >= 8) return new FormRules(FormType.Cultist, false, 0f, 0f); // Fader: Cultist (Day/Night)
|
||||
if (state >= 7) return new FormRules(FormType.Cultist, true, 1f, 5f); // Queen: Cultist (Night, 1m dur, 5m cd)
|
||||
if (state >= 6) return new FormRules(FormType.Cultist, true, 1f, 10f); // Yagluth: Cultist (Night, 1m dur, 10m cd)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
429
JotunnModStub/Fenrir/FenrirRace.cs
Normal file
429
JotunnModStub/Fenrir/FenrirRace.cs
Normal file
|
|
@ -0,0 +1,429 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim {
|
||||
public class FenrirRace : MonoBehaviour {
|
||||
public static FenrirRace Instance;
|
||||
public static SE_FenrirCurse curseSE;
|
||||
public static SE_Stats formBuffSE;
|
||||
public static SE_Stats wolfFormBuffSE;
|
||||
public static SE_Stats cultistFormBuffSE;
|
||||
public static SE_FormCooldown fenrirCdSE;
|
||||
public static SE_FormCooldown cultistCdSE;
|
||||
|
||||
private GameObject currentTransformation;
|
||||
private bool isTransformed = false;
|
||||
private bool isTransformingSequence = false;
|
||||
|
||||
private FenrirProgression.FormRules activeRules = null;
|
||||
private bool wasNight = false;
|
||||
private float sunSicknessTimer = 0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void CreateModAssets()
|
||||
{
|
||||
curseSE = ScriptableObject.CreateInstance<SE_FenrirCurse>();
|
||||
curseSE.name = "SE_FenrirCurse";
|
||||
curseSE.m_name = "Fenrir's Blood";
|
||||
curseSE.m_tooltip = "You are of the Fenrir race.";
|
||||
curseSE.m_mods = new System.Collections.Generic.List<HitData.DamageModPair>()
|
||||
{
|
||||
new HitData.DamageModPair() { m_type = HitData.DamageType.Spirit, m_modifier = HitData.DamageModifier.Weak }
|
||||
};
|
||||
|
||||
GameObject fenringTrophy = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophyFenring")?.gameObject;
|
||||
Sprite fenringTrophyIcon = null;
|
||||
if (fenringTrophy != null)
|
||||
{
|
||||
ItemDrop trophyDrop = fenringTrophy.GetComponent<ItemDrop>();
|
||||
if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
fenringTrophyIcon = trophyDrop.m_itemData.m_shared.m_icons[0];
|
||||
curseSE.m_icon = fenringTrophyIcon;
|
||||
}
|
||||
}
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(curseSE, fixReference: false));
|
||||
|
||||
fenrirCdSE = ScriptableObject.CreateInstance<SE_FormCooldown>();
|
||||
fenrirCdSE.name = "SE_FenrirCooldown";
|
||||
fenrirCdSE.m_name = "Fenrir Form Cooldown";
|
||||
fenrirCdSE.m_icon = fenringTrophyIcon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(fenrirCdSE, fixReference: false));
|
||||
|
||||
cultistCdSE = ScriptableObject.CreateInstance<SE_FormCooldown>();
|
||||
cultistCdSE.name = "SE_CultistCooldown";
|
||||
cultistCdSE.m_name = "Cultist Form Cooldown";
|
||||
cultistCdSE.m_icon = fenringTrophyIcon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cultistCdSE, fixReference: false));
|
||||
|
||||
formBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
|
||||
formBuffSE.name = "SE_FenrirForm";
|
||||
formBuffSE.m_name = "Bestial Fury";
|
||||
formBuffSE.m_speedModifier = 1.0f;
|
||||
formBuffSE.m_jumpModifier = new Vector3(0, 1.0f, 0);
|
||||
formBuffSE.m_fallDamageModifier = -1f;
|
||||
formBuffSE.m_staminaRegenMultiplier = 1.3f;
|
||||
formBuffSE.m_runStaminaDrainModifier = -0.2f;
|
||||
formBuffSE.m_icon = fenringTrophyIcon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(formBuffSE, fixReference: false));
|
||||
|
||||
cultistFormBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
|
||||
cultistFormBuffSE.name = "SE_CultistForm";
|
||||
cultistFormBuffSE.m_name = "Cultist Fury";
|
||||
cultistFormBuffSE.m_speedModifier = 1.0f;
|
||||
cultistFormBuffSE.m_jumpModifier = new Vector3(0, 1.0f, 0);
|
||||
cultistFormBuffSE.m_fallDamageModifier = -1f;
|
||||
cultistFormBuffSE.m_staminaRegenMultiplier = 1.3f;
|
||||
cultistFormBuffSE.m_runStaminaDrainModifier = -0.2f;
|
||||
cultistFormBuffSE.m_icon = fenringTrophyIcon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cultistFormBuffSE, fixReference: false));
|
||||
|
||||
wolfFormBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
|
||||
wolfFormBuffSE.name = "SE_WolfForm";
|
||||
wolfFormBuffSE.m_name = "Wolf Senses";
|
||||
wolfFormBuffSE.m_speedModifier = 0.5f;
|
||||
wolfFormBuffSE.m_fallDamageModifier = -0.5f;
|
||||
wolfFormBuffSE.m_staminaRegenMultiplier = 1.3f;
|
||||
wolfFormBuffSE.m_runStaminaDrainModifier = -0.2f;
|
||||
wolfFormBuffSE.m_icon = fenringTrophyIcon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(wolfFormBuffSE, fixReference: false));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Player.m_localPlayer == null || EnvMan.instance == null) return;
|
||||
if (isTransformingSequence) return;
|
||||
if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_FenrirCurse".GetStableHashCode())) return;
|
||||
|
||||
if (sunSicknessTimer > 0f)
|
||||
{
|
||||
sunSicknessTimer -= Time.deltaTime;
|
||||
}
|
||||
|
||||
bool isNight = EnvMan.IsNight();
|
||||
if (isNight && !wasNight)
|
||||
{
|
||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_FenrirCooldown".GetStableHashCode());
|
||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_CultistCooldown".GetStableHashCode());
|
||||
|
||||
var fenrirSE = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_FenrirForm".GetStableHashCode());
|
||||
if (fenrirSE != null) fenrirSE.m_ttl = 0f;
|
||||
|
||||
var cultistSE = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_CultistForm".GetStableHashCode());
|
||||
if (cultistSE != null) cultistSE.m_ttl = 0f;
|
||||
|
||||
var wolfSE = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_WolfForm".GetStableHashCode());
|
||||
if (wolfSE != null) wolfSE.m_ttl = 0f;
|
||||
}
|
||||
else if (!isNight && wasNight)
|
||||
{
|
||||
// Sunrise: force revert and block for 60 seconds
|
||||
sunSicknessTimer = 60f;
|
||||
ForceRevert();
|
||||
}
|
||||
wasNight = isNight;
|
||||
|
||||
if (isTransformed)
|
||||
{
|
||||
bool hasAnyForm = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_FenrirForm".GetStableHashCode()) ||
|
||||
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_CultistForm".GetStableHashCode()) ||
|
||||
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_WolfForm".GetStableHashCode());
|
||||
if (!hasAnyForm)
|
||||
{
|
||||
ForceRevert();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(FenrirProgression.GetGKeyRules(state)); return; }
|
||||
if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(FenrirProgression.GetHKeyRules(state)); return; }
|
||||
if (Input.GetKeyDown(KeyCode.J)) { TryTransformWithRules(FenrirProgression.GetJKeyRules(state)); return; }
|
||||
}
|
||||
|
||||
private void TryTransformWithRules(FenrirProgression.FormRules rules)
|
||||
{
|
||||
if (rules == null || rules.Form == FenrirProgression.FormType.None) return;
|
||||
|
||||
if (sunSicknessTimer > 0f)
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The beast is tired");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTransformed)
|
||||
{
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
return;
|
||||
}
|
||||
|
||||
if (rules.NeedsNight && !EnvMan.IsNight())
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The beast rests. You can only transform at night.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rules.CooldownMinutes > 0)
|
||||
{
|
||||
string cdName = rules.Form == FenrirProgression.FormType.Cultist ? "SE_CultistCooldown" : "SE_FenrirCooldown";
|
||||
var cdSE = Player.m_localPlayer.GetSEMan().GetStatusEffect(cdName.GetStableHashCode());
|
||||
if (cdSE != null)
|
||||
{
|
||||
float m_time = HarmonyLib.Traverse.Create(cdSE).Field<float>("m_time").Value;
|
||||
float remaining = cdSE.m_ttl - m_time;
|
||||
if (remaining < 0) remaining = 0;
|
||||
int rMin = Mathf.FloorToInt(remaining / 60f);
|
||||
int rSec = Mathf.FloorToInt(remaining % 60f);
|
||||
string formName = rules.Form == FenrirProgression.FormType.Cultist ? "Cultist" : "Fenrir";
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"{formName} form is on cooldown ({rMin}:{rSec:00}).");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(TransformIntoWolfRoutine(rules));
|
||||
}
|
||||
|
||||
public void ForceRevert()
|
||||
{
|
||||
if (isTransformed && !isTransformingSequence)
|
||||
{
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator TransformIntoWolfRoutine(FenrirProgression.FormRules rules)
|
||||
{
|
||||
isTransformingSequence = true;
|
||||
activeRules = rules;
|
||||
|
||||
ZSyncAnimation zAnim = Player.m_localPlayer.GetComponent<ZSyncAnimation>();
|
||||
if (zAnim != null) zAnim.SetTrigger("gpower");
|
||||
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
|
||||
SpawnPoofEffect();
|
||||
|
||||
if (ZNetScene.instance != null)
|
||||
{
|
||||
GameObject howlPrefab = ZNetScene.instance.GetPrefab("sfx_wolf_howl") ?? ZNetScene.instance.GetPrefab("sfx_fenring_idle");
|
||||
if (howlPrefab != null) Instantiate(howlPrefab, Player.m_localPlayer.transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
|
||||
ExecuteTransformation(rules);
|
||||
|
||||
if (currentTransformation != null && currentTransformation.GetComponent<WolfFormBehavior>() == null && currentTransformation.GetComponent<UlvFormBehavior>() == null)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
float duration = 0.5f;
|
||||
float startMultiplier = 0.5f;
|
||||
Vector3 startScale = Vector3.one * startMultiplier;
|
||||
Vector3 endScale = Vector3.one;
|
||||
|
||||
currentTransformation.transform.localScale = startScale;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
if (currentTransformation == null) break;
|
||||
currentTransformation.transform.localScale = Vector3.Lerp(startScale, endScale, elapsed / duration);
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
if (currentTransformation != null) currentTransformation.transform.localScale = endScale;
|
||||
}
|
||||
|
||||
isTransformingSequence = false;
|
||||
}
|
||||
|
||||
private IEnumerator RevertToHumanRoutine()
|
||||
{
|
||||
isTransformingSequence = true;
|
||||
|
||||
if (currentTransformation != null)
|
||||
{
|
||||
FenrirFormBehavior fenrirBehavior = currentTransformation.GetComponent<FenrirFormBehavior>();
|
||||
if (fenrirBehavior != null) fenrirBehavior.enabled = false;
|
||||
|
||||
CultistFormBehavior cultistBehavior = currentTransformation.GetComponent<CultistFormBehavior>();
|
||||
if (cultistBehavior != null) cultistBehavior.enabled = false;
|
||||
|
||||
WolfFormBehavior wolfBehavior = currentTransformation.GetComponent<WolfFormBehavior>();
|
||||
if (wolfBehavior != null) wolfBehavior.enabled = false;
|
||||
|
||||
UlvFormBehavior ulvBehavior = currentTransformation.GetComponent<UlvFormBehavior>();
|
||||
if (ulvBehavior != null) ulvBehavior.enabled = false;
|
||||
|
||||
if (wolfBehavior == null && ulvBehavior == null)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
float duration = 0.5f;
|
||||
Vector3 startScale = currentTransformation.transform.localScale;
|
||||
float endMultiplier = 0.5f;
|
||||
Vector3 endScale = startScale * endMultiplier;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
if (currentTransformation == null) break;
|
||||
currentTransformation.transform.localScale = Vector3.Lerp(startScale, endScale, elapsed / duration);
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpawnPoofEffect();
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
ExecuteReversion();
|
||||
isTransformingSequence = false;
|
||||
}
|
||||
|
||||
private void SpawnPoofEffect()
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
Vector3 pos = Player.m_localPlayer.transform.position + Vector3.up;
|
||||
|
||||
GameObject smoke = PrefabManager.Cache.GetPrefab<GameObject>("vfx_corpse_destruction");
|
||||
if (smoke != null) Instantiate(smoke, pos, Quaternion.identity);
|
||||
|
||||
GameObject sparks = PrefabManager.Cache.GetPrefab<GameObject>("vfx_HitSparks");
|
||||
if (sparks != null) Instantiate(sparks, pos, Quaternion.identity);
|
||||
}
|
||||
|
||||
private void ExecuteTransformation(FenrirProgression.FormRules rules)
|
||||
{
|
||||
Transform playerVisual = Player.m_localPlayer.transform.Find("Visual");
|
||||
string prefabName = "";
|
||||
|
||||
switch (rules.Form)
|
||||
{
|
||||
case FenrirProgression.FormType.Wolf: prefabName = "Wolf"; break;
|
||||
case FenrirProgression.FormType.Ulv: prefabName = "Ulv"; break;
|
||||
case FenrirProgression.FormType.Fenring: prefabName = "Fenring"; break;
|
||||
case FenrirProgression.FormType.Cultist: prefabName = "Fenring_Cultist"; break;
|
||||
}
|
||||
|
||||
GameObject prefab = PrefabManager.Cache.GetPrefab<GameObject>(prefabName);
|
||||
|
||||
// Sync to ZDO
|
||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
nview.GetZDO().Set("RacesOfValheim_FenrirForm", prefabName);
|
||||
}
|
||||
|
||||
if (prefab != null && playerVisual != null)
|
||||
{
|
||||
playerVisual.localScale = Vector3.one * 0.001f;
|
||||
|
||||
Transform visual = prefab.transform.Find("Visual");
|
||||
if (visual != null)
|
||||
{
|
||||
currentTransformation = Instantiate(visual.gameObject, Player.m_localPlayer.transform);
|
||||
currentTransformation.transform.localPosition = Vector3.zero;
|
||||
currentTransformation.transform.localRotation = Quaternion.identity;
|
||||
Component animEvent = currentTransformation.GetComponent("AnimEvent");
|
||||
if (animEvent != null) Destroy(animEvent);
|
||||
|
||||
float ttl = rules.DurationMinutes > 0 ? (rules.DurationMinutes * 60f) : 0f;
|
||||
|
||||
if (prefabName == "Ulv")
|
||||
{
|
||||
currentTransformation.AddComponent<UlvFormBehavior>();
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_WolfForm".GetStableHashCode(), true);
|
||||
var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_WolfForm".GetStableHashCode());
|
||||
if (se != null) se.m_ttl = ttl;
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are an Ulv!");
|
||||
}
|
||||
else if (prefabName == "Wolf")
|
||||
{
|
||||
currentTransformation.AddComponent<WolfFormBehavior>();
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_WolfForm".GetStableHashCode(), true);
|
||||
var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_WolfForm".GetStableHashCode());
|
||||
if (se != null) se.m_ttl = ttl;
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Wolf!");
|
||||
}
|
||||
else if (prefabName == "Fenring_Cultist")
|
||||
{
|
||||
currentTransformation.AddComponent<CultistFormBehavior>();
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_CultistForm".GetStableHashCode(), true);
|
||||
var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_CultistForm".GetStableHashCode());
|
||||
if (se != null) se.m_ttl = ttl;
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Cultist!");
|
||||
}
|
||||
else
|
||||
{
|
||||
currentTransformation.AddComponent<FenrirFormBehavior>();
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_FenrirForm".GetStableHashCode(), true);
|
||||
var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_FenrirForm".GetStableHashCode());
|
||||
if (se != null) se.m_ttl = ttl;
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Fenring!");
|
||||
}
|
||||
|
||||
isTransformed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DestroyAllForms()
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
var forms1 = Player.m_localPlayer.GetComponentsInChildren<FenrirFormBehavior>(true);
|
||||
foreach (var f in forms1) Destroy(f.gameObject);
|
||||
|
||||
var forms2 = Player.m_localPlayer.GetComponentsInChildren<CultistFormBehavior>(true);
|
||||
foreach (var f in forms2) Destroy(f.gameObject);
|
||||
|
||||
var forms3 = Player.m_localPlayer.GetComponentsInChildren<WolfFormBehavior>(true);
|
||||
foreach (var f in forms3) Destroy(f.gameObject);
|
||||
|
||||
var forms4 = Player.m_localPlayer.GetComponentsInChildren<UlvFormBehavior>(true);
|
||||
foreach (var f in forms4) Destroy(f.gameObject);
|
||||
}
|
||||
|
||||
private void ExecuteReversion()
|
||||
{
|
||||
Transform playerVisual = Player.m_localPlayer.transform.Find("Visual");
|
||||
if (currentTransformation != null) Destroy(currentTransformation);
|
||||
DestroyAllForms(); // Safety check to remove any leaked forms
|
||||
|
||||
// Sync to ZDO
|
||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
nview.GetZDO().Set("RacesOfValheim_FenrirForm", "");
|
||||
}
|
||||
|
||||
if (playerVisual != null)
|
||||
{
|
||||
playerVisual.localScale = Vector3.one;
|
||||
playerVisual.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_FenrirForm".GetStableHashCode());
|
||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_CultistForm".GetStableHashCode());
|
||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode());
|
||||
|
||||
isTransformed = false;
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You returned to human form.");
|
||||
|
||||
if (activeRules != null && activeRules.CooldownMinutes > 0)
|
||||
{
|
||||
string cdName = activeRules.Form == FenrirProgression.FormType.Cultist ? "SE_CultistCooldown" : "SE_FenrirCooldown";
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect(cdName.GetStableHashCode(), true);
|
||||
var cdSE = Player.m_localPlayer.GetSEMan().GetStatusEffect(cdName.GetStableHashCode());
|
||||
if (cdSE != null) cdSE.m_ttl = activeRules.CooldownMinutes * 60f;
|
||||
}
|
||||
activeRules = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
JotunnModStub/Fenrir/FenrirStatusEffects.cs
Normal file
46
JotunnModStub/Fenrir/FenrirStatusEffects.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections;
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI; // Added for UI
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
|
||||
public class SE_FormCooldown : StatusEffect
|
||||
{
|
||||
public override void Stop()
|
||||
{
|
||||
base.Stop();
|
||||
if (Player.m_localPlayer != null)
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"{m_name} is Ready!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SE_FenrirCurse : SE_Stats
|
||||
{
|
||||
public override void Setup(Character character)
|
||||
{
|
||||
base.Setup(character);
|
||||
if (character == Player.m_localPlayer)
|
||||
{
|
||||
Player.m_localPlayer.m_customData["FenrirCurse_Active"] = "true";
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateStatusEffect(float dt)
|
||||
{
|
||||
base.UpdateStatusEffect(dt);
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
|
||||
m_fallDamageModifier = FenrirProgression.GetFallDamageModifier(state);
|
||||
m_speedModifier = 1.0f + FenrirProgression.GetSpeedModifier(state);
|
||||
m_jumpModifier = new Vector3(0, FenrirProgression.GetJumpModifier(state), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue