feat(trenta): add the Trenta race
A vegan, tree-born race unlocking new perks per boss defeated: skin/hair tint, blocked non-vegan food, awakened seed foods after Eikthyr, a mob hostility list, Photosynthesis, elemental resistances, Purple Rain after the Elder, swim/poison/wet immunity after Bonemass, Last Stand and Thorns after Moder, a Homecoming Portal after Yagluth, Hornet's Nest after the Queen, and Muspell (a half-size Elder transformation with Stomp/Spike attacks) after Fader. Also fixes RaceScale never listing Trenta as self-sizing, which let a shared Player.Update postfix fight Muspell's own scale changes every frame.
This commit is contained in:
parent
d164579e00
commit
d0ed92c553
14 changed files with 2430 additions and 2 deletions
|
|
@ -33,12 +33,14 @@ namespace RacesOfValheim
|
|||
gameObject.AddComponent<TrolRace>();
|
||||
gameObject.AddComponent<DraughRace>();
|
||||
gameObject.AddComponent<DvergarRace>();
|
||||
gameObject.AddComponent<TrentaRace>();
|
||||
PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
|
||||
CommandManager.Instance.AddConsoleCommand(new ResetRaceCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new CheckProgressionCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new IncreaseProgressionCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new ResetProgressionCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new DumpDvergerCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new DumpElderCommand());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -76,6 +78,7 @@ namespace RacesOfValheim
|
|||
player.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.StatsSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.StatsSE.GetStableHashCode());
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
|
||||
|
|
@ -98,6 +101,7 @@ namespace RacesOfValheim
|
|||
TrolRace.Instance.CreateModAssets();
|
||||
DraughRace.Instance.CreateModAssets();
|
||||
DvergarRace.Instance.CreateModAssets();
|
||||
TrentaRace.Instance.CreateModAssets();
|
||||
}
|
||||
// --- RACE SELECTION UI ---
|
||||
public void ShowRaceSelectionMenu()
|
||||
|
|
@ -240,6 +244,7 @@ namespace RacesOfValheim
|
|||
|
||||
// Row 3 (y = -140)
|
||||
CreateRaceButtonWithConfirm("Dvergar", new Vector2(-450, -140), GetDvergarIcon(), "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", SelectDvergar);
|
||||
CreateRaceButtonWithConfirm("Trenta", new Vector2(-150, -140), GetTrentaIcon(), "Tree-born folk, kin to root and leaf. Patient and hard to fell.", SelectTrenta);
|
||||
|
||||
GUIManager.BlockInput(true);
|
||||
}
|
||||
|
|
@ -622,6 +627,44 @@ namespace RacesOfValheim
|
|||
return null;
|
||||
}
|
||||
|
||||
private void SelectTrenta()
|
||||
{
|
||||
if (Player.m_localPlayer != null)
|
||||
{
|
||||
Player.m_localPlayer.m_customData["Race"] = TrentaConfig.RaceId;
|
||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", TrentaConfig.RaceId);
|
||||
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect(TrentaConfig.StatsSE.GetStableHashCode(), true);
|
||||
|
||||
// No SetSkinColor here: the tint is written onto the material by the UpdateColors
|
||||
// postfix in TrentaPatches, which keys off the race and so needs nothing saved.
|
||||
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
|
||||
if (visEq != null)
|
||||
{
|
||||
visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
||||
}
|
||||
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Trenta.");
|
||||
CloseRaceSelectionMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private Sprite GetTrentaIcon()
|
||||
{
|
||||
GameObject prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophyGreydwarfBrute")?.gameObject;
|
||||
if (prefab == null) prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("Wood")?.gameObject;
|
||||
if (prefab != null)
|
||||
{
|
||||
ItemDrop drop = prefab.GetComponent<ItemDrop>();
|
||||
if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
return drop.m_itemData.m_shared.m_icons[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void CloseRaceSelectionMenu()
|
||||
{
|
||||
if (raceSelectionMenu != null)
|
||||
|
|
@ -872,6 +915,152 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [DEBUG] Built for Muspell (Trenta/Fader): dumps everything about "gd_king" (The Elder) that
|
||||
/// Mono.Cecil cannot see, since that only reveals field/method *names*, never the actual
|
||||
/// values baked into the prefab asset. Three things a transformation ability needs and can
|
||||
/// only get from a live prefab reference:
|
||||
/// - the full hierarchy (same as DumpDvergerCommand), to see whether "Visual" actually
|
||||
/// carries the Animator our clone needs, or whether it lives somewhere else;
|
||||
/// - every Animator's real parameter list, since a wrong trigger name passed to
|
||||
/// Animator.SetTrigger doesn't throw or warn, it just silently does nothing;
|
||||
/// - the real attack animation trigger names, read directly off Humanoid.m_defaultItems'
|
||||
/// weapon SharedData (confirmed via IL that Attack.Start feeds m_attackAnimation straight
|
||||
/// into ZSyncAnimation.SetTrigger, so this is the actual string The Elder itself uses,
|
||||
/// not a guess).
|
||||
/// None of this instantiates the prefab, so nothing here can trigger its AI/Awake logic.
|
||||
/// </summary>
|
||||
public class DumpElderCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "dumpelder";
|
||||
public override string Help => "[DEBUG] Logs The Elder's hierarchy, Animator parameters and real attack animation names";
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
string prefabName = args.Length > 0 ? args[0] : TrentaConfig.MuspellFormPrefab;
|
||||
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(prefabName);
|
||||
if (prefab == null)
|
||||
{
|
||||
Console.instance.Print($"Prefab '{prefabName}' not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
Jotunn.Logger.LogInfo($"=== {prefabName} HIERARCHY ===");
|
||||
DumpTransform(prefab.transform, "");
|
||||
|
||||
Jotunn.Logger.LogInfo($"=== {prefabName} ANIMATORS ===");
|
||||
bool anyAnimator = false;
|
||||
foreach (Animator animator in prefab.GetComponentsInChildren<Animator>(true))
|
||||
{
|
||||
anyAnimator = true;
|
||||
Jotunn.Logger.LogInfo($" Animator on '{GetPath(animator.transform)}' controller='{(animator.runtimeAnimatorController != null ? animator.runtimeAnimatorController.name : "null")}'");
|
||||
if (animator.runtimeAnimatorController == null) continue;
|
||||
|
||||
foreach (AnimatorControllerParameter param in animator.parameters)
|
||||
{
|
||||
Jotunn.Logger.LogInfo($" param: {param.name} ({param.type})");
|
||||
}
|
||||
}
|
||||
if (!anyAnimator) Jotunn.Logger.LogInfo(" (no Animator found anywhere in the hierarchy)");
|
||||
|
||||
Jotunn.Logger.LogInfo($"=== {prefabName} ATTACKS (from Humanoid.m_defaultItems) ===");
|
||||
Humanoid humanoid = prefab.GetComponent<Humanoid>();
|
||||
if (humanoid == null)
|
||||
{
|
||||
Jotunn.Logger.LogInfo(" (no Humanoid component on the prefab root)");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject[] defaultItems = Traverse.Create(humanoid).Field<GameObject[]>("m_defaultItems").Value;
|
||||
if (defaultItems == null || defaultItems.Length == 0)
|
||||
{
|
||||
Jotunn.Logger.LogInfo(" (m_defaultItems is empty)");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (GameObject itemPrefab in defaultItems)
|
||||
{
|
||||
if (itemPrefab == null) continue;
|
||||
DumpWeaponAttacks(itemPrefab);
|
||||
}
|
||||
}
|
||||
|
||||
ItemDrop unarmed = Traverse.Create(humanoid).Field<ItemDrop>("m_unarmedWeapon").Value;
|
||||
if (unarmed != null) DumpWeaponAttacks(unarmed.gameObject);
|
||||
}
|
||||
|
||||
Console.instance.Print($"Dumped '{prefabName}' to the BepInEx log.");
|
||||
}
|
||||
|
||||
private static void DumpWeaponAttacks(GameObject itemPrefab)
|
||||
{
|
||||
ItemDrop drop = itemPrefab.GetComponent<ItemDrop>();
|
||||
if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) return;
|
||||
|
||||
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
|
||||
Jotunn.Logger.LogInfo($" weapon '{itemPrefab.name}' ({shared.m_name}): damages={DumpDamageTypes(shared.m_damages)}");
|
||||
DumpAttack("primary", shared.m_attack);
|
||||
DumpAttack("secondary", shared.m_secondaryAttack);
|
||||
}
|
||||
|
||||
private static void DumpAttack(string label, Attack attack)
|
||||
{
|
||||
if (attack == null) return;
|
||||
Jotunn.Logger.LogInfo(
|
||||
$" {label}: animation='{attack.m_attackAnimation}' randomAnimations={attack.m_attackRandomAnimations} " +
|
||||
$"chainLevels={attack.m_attackChainLevels} damageMultiplier={attack.m_damageMultiplier} " +
|
||||
$"type={attack.m_attackType} range={attack.m_attackRange} angle={attack.m_attackAngle} " +
|
||||
$"spawnOnTrigger='{(attack.m_spawnOnTrigger != null ? attack.m_spawnOnTrigger.name : "none")}' " +
|
||||
$"projectile='{(attack.m_attackProjectile != null ? attack.m_attackProjectile.name : "none")}'");
|
||||
|
||||
if (attack.m_attackProjectile != null)
|
||||
{
|
||||
Projectile proj = attack.m_attackProjectile.GetComponent<Projectile>();
|
||||
if (proj == null) proj = attack.m_attackProjectile.GetComponentInChildren<Projectile>(true);
|
||||
if (proj != null)
|
||||
{
|
||||
Jotunn.Logger.LogInfo($" projectile '{attack.m_attackProjectile.name}' damage={DumpDamageTypes(proj.m_damage)} aoe={proj.m_aoe}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Jotunn.Logger.LogInfo($" projectile '{attack.m_attackProjectile.name}' has no Projectile component");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string DumpDamageTypes(HitData.DamageTypes d)
|
||||
{
|
||||
if (d == null) return "none";
|
||||
return $"blunt={d.m_blunt} slash={d.m_slash} pierce={d.m_pierce} chop={d.m_chop} pickaxe={d.m_pickaxe} " +
|
||||
$"fire={d.m_fire} frost={d.m_frost} lightning={d.m_lightning} poison={d.m_poison} spirit={d.m_spirit}";
|
||||
}
|
||||
|
||||
private static void DumpTransform(Transform t, string indent)
|
||||
{
|
||||
if (t == null) return;
|
||||
|
||||
System.Text.StringBuilder components = new System.Text.StringBuilder();
|
||||
foreach (Component c in t.GetComponents<Component>())
|
||||
{
|
||||
if (c != null) components.Append(c.GetType().Name).Append(" ");
|
||||
}
|
||||
|
||||
Jotunn.Logger.LogInfo($"{indent}{t.name} [{components}]");
|
||||
for (int i = 0; i < t.childCount; i++) DumpTransform(t.GetChild(i), indent + " ");
|
||||
}
|
||||
|
||||
private static string GetPath(Transform t)
|
||||
{
|
||||
string path = t.name;
|
||||
while (t.parent != null)
|
||||
{
|
||||
t = t.parent;
|
||||
path = t.name + "/" + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public class ResetProgressionCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "resetprogression";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue