fix(trol): True Form troll size, log, reach, root during attacks, slam

The troll pulsed several times a second and stayed small because
PlayerVisualHider.Hide put the hidden Visual back to scale 1 every
frame while Trol_PlayerUpdate_Patch grew it back, and the troll follows
that scale. Hide and Show take keepScale now, and the Trol calls pass
it. The camera height, which reads the same scale, stops jumping too.

The log in the troll's hand is the troll's own log model, hung the way
VisEquipment does it, instead of the Trol's, which was built for a
person's hand and came out huge and sideways.

Punch and slam reach further and hit wider, with a new Troll Attack
Reach option (1.3). The player is held still through every attack
clip, throw included.

The ground slam spawns the troll's own troll_groundslam_aoe with the
player's damage, kept off friends, plus its trigger and terrain
effects. It carries chop and pickaxe at least equal to its blunt, so
it breaks trees and rocks, and with Ground Slam Crater on it digs into
the terrain where it lands, never inside a ward without access.
This commit is contained in:
kanym 2026-10-14 17:08:20 +02:00
commit db29f868ea
4 changed files with 190 additions and 33 deletions

View file

@ -37,14 +37,18 @@ namespace RacesOfValheim
private float m_nextLog;
private string m_context = "";
public static void Hide(Transform playerVisual, string context)
/// <param name="keepScale">Leave the Visual's scale alone. For a body that is meant to be
/// sized while hidden: the Trol's True Form troll stands as tall as the Visual does, and
/// resetting it here every frame fought Trol_PlayerUpdate_Patch growing it back - the troll
/// pulsed several times a second and never reached full size.</param>
public static void Hide(Transform playerVisual, string context, bool keepScale = false)
{
if (playerVisual == null) return;
// Undo the two older ways this body could have been hidden, so a form entered right
// after one of those code paths still starts from a sane state.
if (!playerVisual.gameObject.activeSelf) playerVisual.gameObject.SetActive(true);
if (playerVisual.localScale != Vector3.one) playerVisual.localScale = Vector3.one;
if (!keepScale && playerVisual.localScale != Vector3.one) playerVisual.localScale = Vector3.one;
// Belt and braces: if anything else ever does deactivate the Visual, at least keep the
// animator from snapping back to its spawn state.
@ -68,12 +72,12 @@ namespace RacesOfValheim
}
}
public static void Show(Transform playerVisual, string context)
public static void Show(Transform playerVisual, string context, bool keepScale = false)
{
if (playerVisual == null) return;
if (!playerVisual.gameObject.activeSelf) playerVisual.gameObject.SetActive(true);
if (playerVisual.localScale != Vector3.one) playerVisual.localScale = Vector3.one;
if (!keepScale && playerVisual.localScale != Vector3.one) playerVisual.localScale = Vector3.one;
PlayerVisualHider hider = playerVisual.GetComponent<PlayerVisualHider>();
if (hider == null || !hider.enabled) return;