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:
parent
c64cb393c7
commit
db29f868ea
4 changed files with 190 additions and 33 deletions
|
|
@ -55,6 +55,10 @@ namespace RacesOfValheim
|
|||
public float PushForce;
|
||||
public int ToolTier;
|
||||
public ItemDrop.ItemData.SharedData Shared;
|
||||
|
||||
// The weapon's own model, as VisEquipment would hang it in the troll's hand. Only the
|
||||
// log swings have one worth showing.
|
||||
public GameObject Attach;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<AttackKind, Profile> profiles = new Dictionary<AttackKind, Profile>();
|
||||
|
|
@ -69,6 +73,10 @@ namespace RacesOfValheim
|
|||
|
||||
public static bool LocalActive => localModel != null;
|
||||
|
||||
/// <summary>True while the local troll is in the middle of a swing, a slam or a throw.
|
||||
/// Trol_TrueFormHoldStill_Patch holds the player still for exactly that long.</summary>
|
||||
public static bool LocalAttacking { get; set; }
|
||||
|
||||
/// <summary>How many OnAttackTrigger events the local troll has fired. Attack routines
|
||||
/// remember the count and wait for it to move.</summary>
|
||||
public static int AttackEvents => attackEvents;
|
||||
|
|
@ -101,7 +109,7 @@ namespace RacesOfValheim
|
|||
if (localModel == null) return;
|
||||
|
||||
localModel.AddComponent<TrolTrueFormBehavior>();
|
||||
PlayerVisualHider.Hide(player.transform.Find("Visual"), "trol-trueform-local");
|
||||
PlayerVisualHider.Hide(player.transform.Find("Visual"), "trol-trueform-local", keepScale: true);
|
||||
|
||||
GameObject smoke = PrefabManager.Cache.GetPrefab<GameObject>("vfx_corpse_destruction_medium");
|
||||
if (smoke != null) Object.Instantiate(smoke, player.transform.position + Vector3.up, Quaternion.identity);
|
||||
|
|
@ -118,8 +126,9 @@ namespace RacesOfValheim
|
|||
localModel.SetActive(false);
|
||||
Object.Destroy(localModel);
|
||||
localModel = null;
|
||||
LocalAttacking = false;
|
||||
|
||||
if (player != null) PlayerVisualHider.Show(player.transform.Find("Visual"), "trol-trueform-revert");
|
||||
if (player != null) PlayerVisualHider.Show(player.transform.Find("Visual"), "trol-trueform-revert", keepScale: true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -253,17 +262,23 @@ namespace RacesOfValheim
|
|||
if (wanted == null || rightHandPath == null) return;
|
||||
|
||||
Transform hand = model.transform.Find(rightHandPath);
|
||||
Transform attach = itemPrefab.transform.Find("attach");
|
||||
if (hand == null || attach == null) return;
|
||||
if (hand == null) return;
|
||||
|
||||
current = Object.Instantiate(attach.gameObject, hand);
|
||||
// The troll's OWN log, not the Trol's. The Trol's was built for a person's hand - turned
|
||||
// 90 degrees, pushed 1.5 m along it, scaled to 0.4 - and in the troll's fist that came
|
||||
// out huge and pointing the wrong way. The troll's log weapon carries a model made for
|
||||
// exactly this bone, and hanging it the way VisEquipment.AttachItem does (zero offset,
|
||||
// no rotation, its own scale) puts it where vanilla puts it.
|
||||
Profile log = Get(AttackKind.LogSwingH) ?? Get(AttackKind.LogSwingV);
|
||||
GameObject source = log?.Attach;
|
||||
if (source == null) return;
|
||||
|
||||
current = Object.Instantiate(source, hand);
|
||||
current.name = "TrolTrueFormLog";
|
||||
current.transform.localPosition = Vector3.zero;
|
||||
current.transform.localRotation = Quaternion.identity;
|
||||
// Left at the attach's own scale: the hand bone already carries the costume's, so the
|
||||
// log grows and shrinks with the troll. Whether it looks right in the fist is a thing
|
||||
// only an eye can settle - this is the line to change if it does not.
|
||||
current.transform.localScale = Vector3.one;
|
||||
current.transform.localScale = source.transform.localScale;
|
||||
foreach (Collider c in current.GetComponentsInChildren<Collider>(true)) Object.Destroy(c);
|
||||
}
|
||||
|
||||
// ─── Attacks ─────────────────────────────────────────────────────────
|
||||
|
|
@ -316,6 +331,7 @@ namespace RacesOfValheim
|
|||
PushForce = shared.m_attackForce,
|
||||
ToolTier = shared.m_toolTier,
|
||||
Shared = shared,
|
||||
Attach = weapon.transform.Find("attach")?.gameObject,
|
||||
};
|
||||
profiles[kind.Value] = p;
|
||||
|
||||
|
|
@ -369,6 +385,25 @@ namespace RacesOfValheim
|
|||
|
||||
// ─── Native attack loop, shut while the costume is on ────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Holds the troll still through its own attack clips, the way vanilla roots a creature in
|
||||
/// mid-swing. SkeletonRiseControlsPatch's arrangement: the move direction is the first
|
||||
/// argument of SetControls, bound by position.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "SetControls")]
|
||||
public static class Trol_TrueFormHoldStill_Patch
|
||||
{
|
||||
public static void Prefix(Player __instance, ref Vector3 __0, ref bool jump, ref bool crouch, ref bool dodge)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer || !LocalActive || !LocalAttacking) return;
|
||||
|
||||
__0 = Vector3.zero;
|
||||
jump = false;
|
||||
crouch = false;
|
||||
dodge = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), "StartAttack")]
|
||||
public static class Trol_TrueFormBlockNativeAttack_Patch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue