feat: Trol True Form can block and roll
Right click blocks in True Form with a raised-arms guard, rooted in place. Block + jump rolls at half distance with the troll's jump animation at double speed. The slam moves to middle click (secondary attack on a pad). trolpose is a debug command for trying guard and roll states live.
This commit is contained in:
parent
cb29f54a28
commit
3cc1bee2c0
4 changed files with 382 additions and 1 deletions
112
JotunnModStub/Trol/TrolPoseCommand.cs
Normal file
112
JotunnModStub/Trol/TrolPoseCommand.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
using System.Globalization;
|
||||
using Jotunn.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// [DEBUG] Tries troll states as the True Form guard and roll, live, until the right frame is
|
||||
/// found and baked into TrolTrueFormModel. Nothing is saved: a restart goes back to the defaults.
|
||||
/// </summary>
|
||||
public class TrolPoseCommand : ConsoleCommand
|
||||
{
|
||||
// Off troll_animator with scripts/dump_controller.py. Wakeup? and the AnyState entries left
|
||||
// out: an entry check and transitions, not poses.
|
||||
private static readonly string[] States =
|
||||
{
|
||||
"Movement", "attack", "jump", "punch", "throw", "swing log V", "swing log H",
|
||||
"Stagger", "Summon", "Sleeping", "Wakeup", "In Water",
|
||||
};
|
||||
|
||||
public override string Name => "trolpose";
|
||||
|
||||
public override string Help =>
|
||||
"[DEBUG] trolpose guard <state> [0-1] - the frame True Form holds while blocking. " +
|
||||
"trolpose play <state> - plays a state whole on your troll. " +
|
||||
"trolpose dodge <state|off> [speed] - the state played when you roll, and how fast. trolpose - lists states and current values.";
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Print($"guard: '{TrolTrueFormModel.GuardState}' at {TrolTrueFormModel.GuardTime:0.00}, " +
|
||||
$"dodge: '{TrolTrueFormModel.DodgeState ?? "off"}' at speed {TrolTrueFormModel.DodgeSpeed:0.00}");
|
||||
Print("states: " + string.Join(", ", States));
|
||||
return;
|
||||
}
|
||||
|
||||
string verb = args[0].ToLowerInvariant();
|
||||
float time = -1f;
|
||||
int nameEnd = args.Length;
|
||||
// The trailing number: the frame for guard, the speed for dodge.
|
||||
if ((verb == "guard" || verb == "dodge") && args.Length > 2 &&
|
||||
float.TryParse(args[args.Length - 1], NumberStyles.Float, CultureInfo.InvariantCulture, out float number))
|
||||
{
|
||||
time = number;
|
||||
nameEnd--;
|
||||
}
|
||||
|
||||
string typed = string.Join(" ", args, 1, Mathf.Max(0, nameEnd - 1));
|
||||
|
||||
if (verb == "dodge" && typed.ToLowerInvariant() == "off")
|
||||
{
|
||||
TrolTrueFormModel.DodgeState = null;
|
||||
Print("dodge: off");
|
||||
return;
|
||||
}
|
||||
|
||||
string state = Match(typed);
|
||||
if (state == null)
|
||||
{
|
||||
Print($"unknown state '{typed}'. states: " + string.Join(", ", States));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (verb)
|
||||
{
|
||||
case "guard":
|
||||
TrolTrueFormModel.GuardState = state;
|
||||
if (time >= 0f) TrolTrueFormModel.GuardTime = Mathf.Clamp01(time);
|
||||
Print($"guard: '{state}' at {TrolTrueFormModel.GuardTime:0.00}. Hold right click in True Form to see it.");
|
||||
break;
|
||||
|
||||
case "dodge":
|
||||
TrolTrueFormModel.DodgeState = state;
|
||||
if (time > 0f) TrolTrueFormModel.DodgeSpeed = Mathf.Clamp(time, 0.25f, 5f);
|
||||
Print($"dodge: '{state}' at speed {TrolTrueFormModel.DodgeSpeed:0.00}. Block and jump in True Form to roll.");
|
||||
break;
|
||||
|
||||
case "play":
|
||||
Animator anim = TrolTrueFormModel.LocalAnimator;
|
||||
if (anim == null)
|
||||
{
|
||||
Print("play needs True Form on (not Legacy).");
|
||||
return;
|
||||
}
|
||||
anim.speed = 1f;
|
||||
anim.CrossFadeInFixedTime("Base Layer." + state, 0.1f, 0, 0f);
|
||||
Print($"playing '{state}'.");
|
||||
break;
|
||||
|
||||
default:
|
||||
Print(Help);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Match(string typed)
|
||||
{
|
||||
foreach (string s in States)
|
||||
{
|
||||
if (string.Equals(s, typed, System.StringComparison.OrdinalIgnoreCase)) return s;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void Print(string line)
|
||||
{
|
||||
Jotunn.Logger.LogInfo("[Trol] trolpose " + line);
|
||||
if (Console.instance != null) Console.instance.Print(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue