Merge branch 'localisation' into localisation-turkish
This commit is contained in:
commit
ff4b529cda
34 changed files with 1248 additions and 137 deletions
|
|
@ -301,7 +301,11 @@ namespace RacesOfValheim
|
|||
else if (Time.time >= m_nextFightScan)
|
||||
{
|
||||
m_nextFightScan = Time.time + FightScanInterval;
|
||||
if (BaseAI.FindClosestEnemy(m_character, transform.position, FightRange) != null)
|
||||
// FindClosestEnemy takes its first match at ANY distance (it only compares against
|
||||
// maxDistance once it holds one), so with a deer anywhere in the loaded zones it never
|
||||
// returned null and vanilla kept the tick: the drone idled about instead of working.
|
||||
Character enemy = BaseAI.FindClosestEnemy(m_character, transform.position, FightRange);
|
||||
if (enemy != null && Vector3.Distance(enemy.transform.position, transform.position) <= FightRange)
|
||||
{
|
||||
m_fightUntil = Time.time + FightLinger;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,9 +273,13 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
if (target == null || !target.gameObject.activeInHierarchy) target = FindDeposit();
|
||||
if (target == null) { ai.StopMoving(); return true; }
|
||||
Vector3 point = Vector3.zero;
|
||||
Collider area = target != null ? NearestArea(target, out point) : null;
|
||||
if (area == null) { target = null; ai.StopMoving(); return true; }
|
||||
|
||||
Vector3 point = target.transform.position;
|
||||
// Measured to the closest point of the rock, not to its root: a copper deposit's root
|
||||
// sits at its base inside the mesh, so a drone aiming there stopped on top of the rock
|
||||
// and never came within reach.
|
||||
float distance = Vector3.Distance(transform.position, point);
|
||||
|
||||
if (distance > 3.5f)
|
||||
|
|
@ -287,7 +291,7 @@ namespace RacesOfValheim
|
|||
ai.StopMoving();
|
||||
if (Time.time < nextStrike) return true;
|
||||
nextStrike = Time.time + 1f;
|
||||
Strike(target);
|
||||
Strike(target, area, point);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +328,31 @@ namespace RacesOfValheim
|
|||
return best;
|
||||
}
|
||||
|
||||
private void Strike(Component deposit)
|
||||
/// <summary>
|
||||
/// The live hit area of the deposit closest to the drone, and the closest point on it.
|
||||
/// MineRock and MineRock5 only take a hit on one of their own areas; a MineRock with an area
|
||||
/// root (tin) keeps its base model collider apart, and a hit on that one is thrown away.
|
||||
/// Broken areas are switched off, so only active colliders count.
|
||||
/// </summary>
|
||||
private Collider NearestArea(Component deposit, out Vector3 point)
|
||||
{
|
||||
point = Vector3.zero;
|
||||
MineRock rock = deposit as MineRock;
|
||||
GameObject root = rock != null && rock.m_areaRoot != null ? rock.m_areaRoot : deposit.gameObject;
|
||||
|
||||
Collider best = null;
|
||||
float bestDistance = float.MaxValue;
|
||||
foreach (Collider collider in root.GetComponentsInChildren<Collider>())
|
||||
{
|
||||
if (collider == null || !collider.enabled) continue;
|
||||
Vector3 closest = collider.bounds.ClosestPoint(transform.position);
|
||||
float distance = Vector3.Distance(transform.position, closest);
|
||||
if (distance < bestDistance) { best = collider; bestDistance = distance; point = closest; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
private void Strike(Component deposit, Collider area, Vector3 point)
|
||||
{
|
||||
IDestructible destructible = deposit as IDestructible;
|
||||
if (destructible == null) return;
|
||||
|
|
@ -334,16 +362,12 @@ namespace RacesOfValheim
|
|||
hit.m_toolTier = 100;
|
||||
hit.m_dodgeable = false;
|
||||
hit.m_blockable = false;
|
||||
hit.m_point = deposit.transform.position;
|
||||
hit.m_dir = (deposit.transform.position - transform.position).normalized;
|
||||
|
||||
// MineRock5 picks the piece of the rock to hurt from the collider that was hit.
|
||||
Collider collider = deposit.GetComponentInChildren<Collider>();
|
||||
if (collider != null)
|
||||
{
|
||||
hit.m_hitCollider = collider;
|
||||
hit.m_point = collider.bounds.center;
|
||||
}
|
||||
hit.m_hitCollider = area;
|
||||
hit.m_point = point;
|
||||
hit.m_dir = (area.bounds.center - transform.position).normalized;
|
||||
// Vanilla MineRock (tin) reads the attacker's ZDOID for its hit effects without a null
|
||||
// check: a hit with no attacker throws before the area can break.
|
||||
hit.SetAttacker(GetComponent<Character>());
|
||||
|
||||
destructible.Damage(hit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,8 +89,13 @@ namespace RacesOfValheim
|
|||
DroneZapDamage = config.Bind(drone, "Zap Damage", 1f, new ConfigDescription("Lightning damage of a drone's defensive zap.", new AcceptableValueRange<float>(0f, 100f)));
|
||||
DroneZapInterval = config.Bind(drone, "Zap Interval", 2f, new ConfigDescription("Seconds between a drone's zaps.", new AcceptableValueRange<float>(0.2f, 30f)));
|
||||
|
||||
MinerDeposits = config.Bind(drone, "Mining Targets", "MineRock_Copper,MineRock_Tin,MineRock_Iron,silvervein,rock3_silver,giant_brain",
|
||||
// Copper deposits are rock4_copper (and rock4_copper_frac once hit), crypt scrap is mudpile;
|
||||
// the first default missed both, so a config still holding it is moved to the new one.
|
||||
const string oldTargets = "MineRock_Copper,MineRock_Tin,MineRock_Iron,silvervein,rock3_silver,giant_brain";
|
||||
const string targets = "rock4_copper,MineRock_Copper,MineRock_Tin,MineRock_Iron,mudpile,silvervein,rock3_silver,giant_brain";
|
||||
MinerDeposits = config.Bind(drone, "Mining Targets", targets,
|
||||
new ConfigDescription("Comma separated parts of prefab names the mining drones dig (case does not matter). Soft tissue comes from giant_brain."));
|
||||
if (MinerDeposits.Value == oldTargets) MinerDeposits.Value = targets;
|
||||
MinerDamage = config.Bind(drone, "Mining Damage", 40f, new ConfigDescription("Pickaxe damage each mining drone does per second to a deposit.", new AcceptableValueRange<float>(1f, 1000f)));
|
||||
|
||||
WildPickables = config.Bind(drone, "Wild Plants Harvested", "Pickable_Mushroom,Pickable_Dandelion,Pickable_Thistle,RaspberryBush,BlueberryBush,CloudberryBush",
|
||||
|
|
|
|||
|
|
@ -270,7 +270,11 @@ namespace RacesOfValheim
|
|||
else if (Time.time >= m_nextFightScan)
|
||||
{
|
||||
m_nextFightScan = Time.time + FightScanInterval;
|
||||
if (BaseAI.FindClosestEnemy(m_character, transform.position, FightRange) != null)
|
||||
// FindClosestEnemy takes its first match at ANY distance (it only compares against
|
||||
// maxDistance once it holds one), so with a deer anywhere in the loaded zones it never
|
||||
// returned null and vanilla kept the tick: the worker idled about instead of working.
|
||||
Character enemy = BaseAI.FindClosestEnemy(m_character, transform.position, FightRange);
|
||||
if (enemy != null && Vector3.Distance(enemy.transform.position, transform.position) <= FightRange)
|
||||
{
|
||||
m_fightUntil = Time.time + FightLinger;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,17 +323,72 @@ namespace RacesOfValheim
|
|||
GameObject fireVfx = ZNetScene.instance.GetPrefab("fx_fenring_flames");
|
||||
if (fireVfx == null) return null;
|
||||
|
||||
GameObject instance = Object.Instantiate(fireVfx, player.transform.position + Vector3.up * 1.5f + player.transform.forward, player.transform.rotation, player.transform);
|
||||
GameObject instance = Object.Instantiate(fireVfx, MouthPoint(player), player.transform.rotation, player.transform);
|
||||
instance.AddComponent<CultistFlameFollow>().Player = player;
|
||||
|
||||
// The vanilla effect is one throw, not a held breath: its emitters do not loop (2 s) and
|
||||
// a TimedDestruction removes it after 5 s, so a long hold went on draining eitr with no
|
||||
// fire. It loops here and lives until StopFire takes it down.
|
||||
TimedDestruction timer = instance.GetComponent<TimedDestruction>();
|
||||
if (timer != null)
|
||||
{
|
||||
timer.CancelInvoke();
|
||||
Object.Destroy(timer);
|
||||
}
|
||||
|
||||
// Aumentiamo la durata delle particelle del 20%
|
||||
foreach (ParticleSystem ps in instance.GetComponentsInChildren<ParticleSystem>())
|
||||
{
|
||||
var main = ps.main;
|
||||
main.startLifetimeMultiplier *= 1.2f;
|
||||
main.loop = true;
|
||||
}
|
||||
|
||||
// The roar of the fire, the same one-throw story: set before its ZSFX first plays.
|
||||
foreach (ZSFX sfx in instance.GetComponentsInChildren<ZSFX>())
|
||||
{
|
||||
sfx.m_fadeOutOnAwake = false;
|
||||
AudioSource source = sfx.GetComponent<AudioSource>();
|
||||
if (source != null) source.loop = true;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Bone names the breath leaves from, mouth first. Matched by name anywhere under the form.
|
||||
private static readonly string[] MouthBones = { "Jaw", "Head" };
|
||||
|
||||
/// <summary>
|
||||
/// Where the Cultist's breath starts: just ahead of the form's jaw (or head), so it leaves the
|
||||
/// mouth at whatever size the form stands. It used to be a fixed 1.5 m above the player's
|
||||
/// feet, chest height on a Cultist, which is the "fire starts too low" report. Falls back on
|
||||
/// that fixed point if the form has neither bone.
|
||||
/// </summary>
|
||||
public static Vector3 MouthPoint(Player player) => MouthPoint(player, FindMouth(player));
|
||||
|
||||
public static Vector3 MouthPoint(Player player, Transform bone)
|
||||
{
|
||||
Transform body = player.transform;
|
||||
return bone != null
|
||||
? bone.position + body.forward * 0.3f
|
||||
: body.position + Vector3.up * 1.5f + body.forward;
|
||||
}
|
||||
|
||||
public static Transform FindMouth(Player player)
|
||||
{
|
||||
foreach (string wanted in MouthBones)
|
||||
{
|
||||
foreach (Transform child in player.transform)
|
||||
{
|
||||
if (child.name == "Visual" || !child.gameObject.activeInHierarchy) continue;
|
||||
foreach (Transform t in child.GetComponentsInChildren<Transform>())
|
||||
{
|
||||
if (string.Equals(t.name, wanted, System.StringComparison.OrdinalIgnoreCase)) return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void PublishFire(bool on)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
|
|
@ -393,6 +448,8 @@ namespace RacesOfValheim
|
|||
private ZNetView nview;
|
||||
private string lastAttack;
|
||||
private GameObject flames;
|
||||
private bool breathing;
|
||||
private float breathStarted;
|
||||
private readonly FormLocomotion locomotion = new FormLocomotion();
|
||||
|
||||
// The flames hang off the player, not this model, so they outlive it unless taken down.
|
||||
|
|
@ -433,18 +490,31 @@ namespace RacesOfValheim
|
|||
|
||||
bool fire = nview.GetZDO().GetBool(FenrirAttackSync.FireKey, false);
|
||||
|
||||
// The breath itself: up while the flag is, gone when it drops. Only the cultist ever
|
||||
// sets the flag, so no other form can grow flames here.
|
||||
if (fire && flames == null)
|
||||
// The flag is up for the whole hold, wind-up included, as on the owner's side; the
|
||||
// flames come at the same point of the same clip (CultistBreathClip). Only the cultist
|
||||
// ever sets the flag, so no other form can grow flames here.
|
||||
if (fire && !breathing)
|
||||
{
|
||||
flames = FenrirAttackSync.SpawnFlames(player);
|
||||
breathing = true;
|
||||
breathStarted = Time.time;
|
||||
|
||||
// The roar that opens the breath, once per start, the same cue the owner hears.
|
||||
// "sfx_cultist_attack_fire_start" was asked for here and there is no sfx_cultist_*
|
||||
// prefab in the game at all; the fenring's own fire-claw snarl is the real one.
|
||||
FenrirCreatureSound.PlayFireRoar(player.transform.position);
|
||||
}
|
||||
else if (!fire && flames != null) { Destroy(flames); flames = null; }
|
||||
if (fire)
|
||||
{
|
||||
CultistBreathClip.Hold(formAnim);
|
||||
if (flames == null && CultistBreathClip.FlamesDue(formAnim, breathStarted))
|
||||
flames = FenrirAttackSync.SpawnFlames(player);
|
||||
}
|
||||
else if (breathing)
|
||||
{
|
||||
breathing = false;
|
||||
CultistBreathClip.Release(formAnim, player);
|
||||
if (flames != null) { Destroy(flames); flames = null; }
|
||||
}
|
||||
|
||||
foreach (AnimatorControllerParameter p in formAnim.parameters)
|
||||
{
|
||||
|
|
@ -550,15 +620,15 @@ namespace RacesOfValheim
|
|||
{
|
||||
StartCoroutine(HowlRoutine());
|
||||
}
|
||||
else if (RaceInput.AttackDown(1)) // Tasto destro (Heavy Claw)
|
||||
else if (RaceInput.AttackDown(1) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.FenringHeavyClawStamina.Value, Skills.SkillType.Unarmed)) // Tasto destro (Heavy Claw)
|
||||
{
|
||||
StartCoroutine(ClawRoutine("attack_claw1", FenrirConfig.FenringHeavyClawDamage.Value, 1.2f, 0.5f));
|
||||
}
|
||||
else if (RaceInput.AttackDown(0)) // Tasto sinistro
|
||||
else if (RaceInput.AttackDown(0) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.FenringLightClawStamina.Value, Skills.SkillType.Unarmed)) // Tasto sinistro
|
||||
{
|
||||
StartCoroutine(ClawRoutine("attack_claw0", FenrirConfig.FenringLightClawDamage.Value, 1.0f, 0.4f));
|
||||
}
|
||||
else if (RaceInput.AttackDown(2)) // Tasto centrale
|
||||
else if (RaceInput.AttackDown(2) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.FenringJumpAttackStamina.Value, Skills.SkillType.Unarmed)) // Tasto centrale
|
||||
{
|
||||
StartCoroutine(JumpAttackRoutine());
|
||||
}
|
||||
|
|
@ -690,7 +760,7 @@ namespace RacesOfValheim
|
|||
|
||||
private void ExecuteClawDamage(float baseDamage)
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
if (Player.m_localPlayer == null || FormStagger.AttackInterrupted) return;
|
||||
|
||||
Vector3 playerPos = Player.m_localPlayer.transform.position;
|
||||
Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 1f;
|
||||
|
|
@ -805,47 +875,40 @@ namespace RacesOfValheim
|
|||
// still falls through to StopFire() instead of leaving the flames running.
|
||||
bool canAct = RaceInput.Allowed;
|
||||
|
||||
// Fire attack on Right Click
|
||||
if (canAct && RaceInput.AttackHeld(1))
|
||||
// Fire attack on Right Click, held.
|
||||
bool wantFire = canAct && RaceInput.AttackHeld(1) && !Player.m_localPlayer.IsStaggering();
|
||||
if (wantFire && Player.m_localPlayer.GetEitr() <= 0f)
|
||||
{
|
||||
if (Player.m_localPlayer.GetEitr() > 0)
|
||||
{
|
||||
if (!isShootingFire)
|
||||
{
|
||||
StartFire();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateFire();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Held with an empty pool. Until now this did nothing whatsoever: no
|
||||
// flames, no sound, no reason given - and the form's own tier is Yagluth
|
||||
// while eitr is a Mistlands thing, so a Cultist meets this before it ever
|
||||
// meets the fire.
|
||||
SayNoEitr();
|
||||
if (isShootingFire) StopFire();
|
||||
}
|
||||
// Held with an empty pool. Until now this did nothing whatsoever: no
|
||||
// flames, no sound, no reason given - and the form's own tier is Yagluth
|
||||
// while eitr is a Mistlands thing, so a Cultist meets this before it ever
|
||||
// meets the fire.
|
||||
SayNoEitr();
|
||||
wantFire = false;
|
||||
}
|
||||
|
||||
if (wantFire)
|
||||
{
|
||||
if (!isShootingFire) StartFire();
|
||||
else UpdateFire();
|
||||
}
|
||||
else if (isShootingFire)
|
||||
{
|
||||
StopFire();
|
||||
}
|
||||
|
||||
if (canAct && FenrirConfig.HowlKey.Value.IsDownIgnoringHeldKeys())
|
||||
if (canAct && !isShootingFire && FenrirConfig.HowlKey.Value.IsDownIgnoringHeldKeys())
|
||||
{
|
||||
StartCoroutine(HowlRoutine());
|
||||
}
|
||||
|
||||
// Attacks on Left Click
|
||||
if (canAct && RaceInput.AttackDown(0) && !isShootingFire)
|
||||
if (canAct && RaceInput.AttackDown(0) && !isShootingFire && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.CultistClawStamina.Value, Skills.SkillType.Unarmed))
|
||||
{
|
||||
StartCoroutine(ClawRoutine()); // Single claw
|
||||
}
|
||||
// Double claw on Middle Click
|
||||
else if (canAct && RaceInput.AttackDown(2) && !isShootingFire)
|
||||
else if (canAct && RaceInput.AttackDown(2) && !isShootingFire && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.CultistDoubleClawStamina.Value, Skills.SkillType.Unarmed))
|
||||
{
|
||||
StartCoroutine(DoubleClawRoutine());
|
||||
}
|
||||
|
|
@ -907,31 +970,54 @@ namespace RacesOfValheim
|
|||
ModText.Get("rov_msg_fenrir_only_breath_comes_out_fire"));
|
||||
}
|
||||
|
||||
// The breath runs on the flame clip (CultistBreathClip): pressed, the clip starts; the flames,
|
||||
// the eitr drain and the damage begin at its own Hit point; released, the clip is cut.
|
||||
private bool flaming;
|
||||
private float fireStarted;
|
||||
|
||||
/// <summary>True while the local Cultist holds its breath attack, wind-up included. Read by
|
||||
/// Cultist_BreathFacesCamera_Patch.</summary>
|
||||
public static bool LocalBreathing { get; private set; }
|
||||
|
||||
private void StartFire()
|
||||
{
|
||||
if (Player.m_localPlayer == null || isShootingFire) return;
|
||||
|
||||
isShootingFire = true;
|
||||
LocalBreathing = true;
|
||||
// Planted while it breathes, as the vanilla Cultist is: its controller has no walking
|
||||
// version of the cast, so a moving Cultist slid along in the casting pose.
|
||||
// Fenrir_FormHoldStill_Patch holds the player; turning to the camera still works.
|
||||
FenrirForms.LocalAttacking = true;
|
||||
flaming = false;
|
||||
fireStarted = Time.time;
|
||||
fireTimer = 0f;
|
||||
FormAnimGuard.LeaveHowl(cultistAnim);
|
||||
cultistAnim.SetFloat("forward_speed", 0f);
|
||||
cultistAnim.SetFloat("sideway_speed", 0f);
|
||||
cultistAnim.SetBool("attack_fire", true);
|
||||
FenrirAttackSync.PublishFire(true);
|
||||
|
||||
|
||||
// Same cue the remote mirror plays - see the fire branch in the sync behaviour above.
|
||||
FenrirCreatureSound.PlayFireRoar(Player.m_localPlayer.transform.position);
|
||||
cultistAnim.SetTrigger("attack_flames");
|
||||
FenrirAttackSync.Publish("attack_flames");
|
||||
|
||||
if (fireEffectInstance == null) fireEffectInstance = FenrirAttackSync.SpawnFlames(Player.m_localPlayer);
|
||||
}
|
||||
|
||||
private void UpdateFire()
|
||||
{
|
||||
Player.m_localPlayer.UseEitr(FenrirConfig.CultistFireEitrDrainPerSecond.Value * Time.deltaTime);
|
||||
cultistAnim.SetFloat("forward_speed", 0f);
|
||||
cultistAnim.SetFloat("sideway_speed", 0f);
|
||||
|
||||
CultistBreathClip.Hold(cultistAnim);
|
||||
|
||||
if (!flaming)
|
||||
{
|
||||
if (!CultistBreathClip.FlamesDue(cultistAnim, fireStarted)) return;
|
||||
flaming = true;
|
||||
if (fireEffectInstance == null) fireEffectInstance = FenrirAttackSync.SpawnFlames(Player.m_localPlayer);
|
||||
}
|
||||
|
||||
Player.m_localPlayer.UseEitr(FenrirConfig.CultistFireEitrDrainPerSecond.Value * Time.deltaTime);
|
||||
|
||||
fireTimer += Time.deltaTime;
|
||||
if (fireTimer >= 0.2f) // Damage tick every 0.2s
|
||||
{
|
||||
|
|
@ -944,14 +1030,20 @@ namespace RacesOfValheim
|
|||
private void OnDestroy()
|
||||
{
|
||||
if (isShootingFire) FenrirAttackSync.PublishFire(false);
|
||||
if (isShootingFire) FenrirForms.LocalAttacking = false;
|
||||
LocalBreathing = false;
|
||||
}
|
||||
|
||||
private void StopFire()
|
||||
{
|
||||
isShootingFire = false;
|
||||
LocalBreathing = false;
|
||||
FenrirForms.LocalAttacking = false;
|
||||
flaming = false;
|
||||
cultistAnim.ResetTrigger("attack_flames");
|
||||
FenrirAttackSync.PublishFire(false);
|
||||
|
||||
CultistBreathClip.Release(cultistAnim, Player.m_localPlayer);
|
||||
|
||||
if (fireEffectInstance != null)
|
||||
{
|
||||
Destroy(fireEffectInstance);
|
||||
|
|
@ -1034,25 +1126,30 @@ namespace RacesOfValheim
|
|||
cultistAnim.SetFloat("sideway_speed", 0f);
|
||||
|
||||
// Per il Cultista usiamo esplicitamente il trigger dell'artigliata
|
||||
int baseline = FenrirForms.AttackEvents;
|
||||
float started = Time.time;
|
||||
cultistAnim.SetTrigger("attack_claw");
|
||||
FenrirAttackSync.Publish("attack_claw", "sfx_fenring_claw_start");
|
||||
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
// The blow lands on the clip's own Hit event (ClawAttackCultist: 0.64 s of 1.33 s), and
|
||||
// the lock holds until the clip is over. A fixed 0.4 s hit and a 0.5 s lock used to land
|
||||
// the damage before the claw swung and let the next click start a new one mid-swing.
|
||||
yield return null;
|
||||
float length = ClipLength(1.33f);
|
||||
|
||||
yield return WaitForHit(baseline, started);
|
||||
PlaySFX("sfx_fenring_claw_start");
|
||||
|
||||
ExecuteClawDamage(FenrirConfig.CultistClawDamage.Value);
|
||||
|
||||
float remainingTimeToIdle = 0.5f - 0.4f;
|
||||
if (remainingTimeToIdle > 0)
|
||||
{
|
||||
yield return new WaitForSeconds(remainingTimeToIdle);
|
||||
}
|
||||
|
||||
yield return WaitUntilClipEnds(length, started);
|
||||
cultistAnim.ResetTrigger("attack_claw");
|
||||
isAttacking = false;
|
||||
}
|
||||
|
||||
// Each swipe of the double claw deals this share of Double Claw Damage. Two swipes give
|
||||
// 120% of what the old single hit dealt: a little more, for a slower swing that can be cut short.
|
||||
private const float DoubleClawHitShare = 0.6f;
|
||||
|
||||
private IEnumerator DoubleClawRoutine()
|
||||
{
|
||||
isAttacking = true;
|
||||
|
|
@ -1061,27 +1158,66 @@ namespace RacesOfValheim
|
|||
cultistAnim.SetFloat("forward_speed", 0f);
|
||||
cultistAnim.SetFloat("sideway_speed", 0f);
|
||||
|
||||
int baseline = FenrirForms.AttackEvents;
|
||||
float started = Time.time;
|
||||
cultistAnim.SetTrigger("attack_claw_double");
|
||||
FenrirAttackSync.Publish("attack_claw_double", "sfx_fenring_claw_start");
|
||||
|
||||
// L'animazione double claw è più lunga, facciamo il danno un po' dopo
|
||||
yield return new WaitForSeconds(0.6f);
|
||||
// DoubleClawAttackCultist carries two Hit events (0.64 s and 1.21 s of 1.83 s), one per
|
||||
// swipe. It used to deal one hit at a fixed 0.6 s, so the second swipe did nothing.
|
||||
yield return null;
|
||||
float length = ClipLength(1.83f);
|
||||
float damage = FenrirConfig.CultistDoubleClawDamage.Value * DoubleClawHitShare;
|
||||
|
||||
yield return WaitForHit(baseline, started);
|
||||
PlaySFX("sfx_fenring_claw_start");
|
||||
ExecuteClawDamage(damage);
|
||||
|
||||
ExecuteClawDamage(FenrirConfig.CultistDoubleClawDamage.Value);
|
||||
|
||||
// Attendiamo che l'animazione finisca (locking del giocatore)
|
||||
// L'animazione doppia del cultista dura circa 1.5 - 2 secondi
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
yield return WaitForHit(baseline + 1, started, HitEventTimeout + 0.6f);
|
||||
PlaySFX("sfx_fenring_claw_start");
|
||||
ExecuteClawDamage(damage);
|
||||
|
||||
yield return WaitUntilClipEnds(length, started);
|
||||
cultistAnim.ResetTrigger("attack_claw_double");
|
||||
isAttacking = false;
|
||||
}
|
||||
|
||||
// Longest a swipe waits for its Hit event before landing anyway, measured from the trigger:
|
||||
// a clip that never sends one must not leave the Cultist swinging at nothing.
|
||||
private const float HitEventTimeout = 1.5f;
|
||||
|
||||
/// <summary>Waits until the clip has sent more than <paramref name="seen"/> hit events since
|
||||
/// the trigger, or until the timeout.</summary>
|
||||
private IEnumerator WaitForHit(int seen, float started, float timeout = HitEventTimeout)
|
||||
{
|
||||
while (FenrirForms.AttackEvents <= seen && Time.time - started < timeout)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The attack clip's length, read a frame after its trigger, when the transition
|
||||
/// into it has begun. <paramref name="fallback"/> is the clip's length in the game files.</summary>
|
||||
private float ClipLength(float fallback)
|
||||
{
|
||||
AnimatorClipInfo[] clips = cultistAnim.IsInTransition(0)
|
||||
? cultistAnim.GetNextAnimatorClipInfo(0)
|
||||
: cultistAnim.GetCurrentAnimatorClipInfo(0);
|
||||
if (clips != null && clips.Length > 0 && clips[0].clip != null) return clips[0].clip.length;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/// <summary>Holds the lock until the clip has played out, clamped so a wrong reading can
|
||||
/// neither cut a swing short nor freeze the form.</summary>
|
||||
private IEnumerator WaitUntilClipEnds(float length, float started)
|
||||
{
|
||||
float remaining = Mathf.Clamp(length, 0.6f, 3f) - (Time.time - started);
|
||||
if (remaining > 0f) yield return new WaitForSeconds(remaining);
|
||||
}
|
||||
|
||||
private void ExecuteClawDamage(float baseDamage)
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
if (Player.m_localPlayer == null || FormStagger.AttackInterrupted) return;
|
||||
|
||||
Vector3 playerPos = Player.m_localPlayer.transform.position;
|
||||
Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 1f;
|
||||
|
|
@ -1194,15 +1330,15 @@ namespace RacesOfValheim
|
|||
{
|
||||
StartCoroutine(WolfHowlRoutine());
|
||||
}
|
||||
else if (RaceInput.AttackDown(0)) // Left Click
|
||||
else if (RaceInput.AttackDown(0) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.WolfAttack1Stamina.Value, Skills.SkillType.Unarmed)) // Left Click
|
||||
{
|
||||
StartCoroutine(WolfAttackRoutine("attack1", FenrirConfig.WolfAttack1Damage.Value, 0.6f, 0.2f));
|
||||
}
|
||||
else if (RaceInput.AttackDown(1)) // Right Click
|
||||
else if (RaceInput.AttackDown(1) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.WolfAttack2Stamina.Value, Skills.SkillType.Unarmed)) // Right Click
|
||||
{
|
||||
StartCoroutine(WolfAttackRoutine("attack2", FenrirConfig.WolfAttack2Damage.Value, 0.8f, 0.3f));
|
||||
}
|
||||
else if (RaceInput.AttackDown(2)) // Middle Click
|
||||
else if (RaceInput.AttackDown(2) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.WolfAttack3Stamina.Value, Skills.SkillType.Unarmed)) // Middle Click
|
||||
{
|
||||
StartCoroutine(WolfAttackRoutine("attack3", FenrirConfig.WolfAttack3Damage.Value, 1.0f, 0.4f));
|
||||
}
|
||||
|
|
@ -1295,7 +1431,7 @@ namespace RacesOfValheim
|
|||
|
||||
private void ExecuteBiteDamage(float baseDamage)
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
if (Player.m_localPlayer == null || FormStagger.AttackInterrupted) return;
|
||||
|
||||
Vector3 playerPos = Player.m_localPlayer.transform.position;
|
||||
// Il lupo è basso, abbassiamo l'altezza dell'attacco
|
||||
|
|
@ -1410,16 +1546,16 @@ namespace RacesOfValheim
|
|||
{
|
||||
StartCoroutine(UlvHowlRoutine());
|
||||
}
|
||||
else if (RaceInput.AttackDown(0)) // Left Click
|
||||
else if (RaceInput.AttackDown(0) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.UlvBiteStamina.Value, Skills.SkillType.Unarmed)) // Left Click
|
||||
{
|
||||
StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvBiteDamage.Value, 0.6f, 0.2f));
|
||||
}
|
||||
else if (RaceInput.AttackDown(1)) // Right Click
|
||||
else if (RaceInput.AttackDown(1) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.UlvHeavyBiteStamina.Value, Skills.SkillType.Unarmed)) // Right Click
|
||||
{
|
||||
// Right click uses bite but as a heavier attack since slash is moved to jump
|
||||
StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvHeavyBiteDamage.Value, 0.8f, 0.3f));
|
||||
}
|
||||
else if (RaceInput.AttackDown(2)) // Middle Click
|
||||
else if (RaceInput.AttackDown(2) && FormMelee.TrySpendStamina(Player.m_localPlayer, FenrirConfig.UlvJumpAttackStamina.Value, Skills.SkillType.Unarmed)) // Middle Click
|
||||
{
|
||||
StartCoroutine(UlvJumpAttackRoutine());
|
||||
}
|
||||
|
|
@ -1504,7 +1640,7 @@ namespace RacesOfValheim
|
|||
|
||||
private void ExecuteBiteDamage(float baseDamage)
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
if (Player.m_localPlayer == null || FormStagger.AttackInterrupted) return;
|
||||
|
||||
Vector3 playerPos = Player.m_localPlayer.transform.position;
|
||||
Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 0.5f;
|
||||
|
|
@ -1621,4 +1757,160 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Cultist's breath, timed by its own clip. fenring_cultist_animator's attack_flames state
|
||||
/// plays "Flame Spell Attack" (read offline with UnityPy, bundle c4210710): 3.5 s, the hands
|
||||
/// light at 1.094 s (TrailOn), the vanilla flames come at 1.245 s (Hit) and are taken down at
|
||||
/// 3.193 s. The state leaves for Movement only when the clip ends, so a short click used to
|
||||
/// leave the Cultist standing with its arms up for the rest of the 3.5 s, breathing nothing.
|
||||
///
|
||||
/// Now the flames wait for the clip's Hit point, the arms are held in the casting pose for as
|
||||
/// long as the button is, and letting go blends straight back to Movement. Shared by the
|
||||
/// owner's Cultist and every onlooker's copy, so both play the same breath.
|
||||
/// </summary>
|
||||
internal static class CultistBreathClip
|
||||
{
|
||||
private static readonly int State = Animator.StringToHash("Base Layer.attack_flames");
|
||||
private const string MovementState = "Base Layer.Movement";
|
||||
|
||||
// The clip's Hit event, where the vanilla Cultist's flames come out.
|
||||
private const float FlamesAt = 1.245f;
|
||||
|
||||
// The throw itself: the Animator stops here while held. After it the vanilla Cultist lowers
|
||||
// its arms while its fire flies on alone, so a pin at 2.6 s held an idle-looking pose.
|
||||
private const float PinAt = 1.3f;
|
||||
|
||||
private const float Fade = 0.25f;
|
||||
|
||||
/// <summary>Seconds into the flame clip, or -1 while the Animator is in another state.</summary>
|
||||
private static float ClipTime(Animator anim)
|
||||
{
|
||||
AnimatorStateInfo info = anim.IsInTransition(0) ? anim.GetNextAnimatorStateInfo(0) : anim.GetCurrentAnimatorStateInfo(0);
|
||||
return info.fullPathHash == State ? info.normalizedTime * info.length : -1f;
|
||||
}
|
||||
|
||||
/// <summary>True once the clip has reached its Hit point. If the clip never started (another
|
||||
/// state took the Animator), the same delay counted from the press stands in for it.</summary>
|
||||
public static bool FlamesDue(Animator anim, float started)
|
||||
{
|
||||
float t = ClipTime(anim);
|
||||
return t >= FlamesAt || (t < 0f && Time.time - started >= FlamesAt + 0.2f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds the arms in the casting pose: once the clip reaches PinAt it is put back there every
|
||||
/// frame. Not with Animator.speed = 0, which is what the troll's pin uses: the creature's own
|
||||
/// CharacterAnimEvent sits on this model and sets speed back to 1 on every physics step while
|
||||
/// the player is not in a vanilla attack, so the clip ran on to its end and the Cultist went
|
||||
/// back to idle with the fire still pouring out.
|
||||
/// </summary>
|
||||
public static void Hold(Animator anim)
|
||||
{
|
||||
if (anim.IsInTransition(0)) return;
|
||||
AnimatorStateInfo info = anim.GetCurrentAnimatorStateInfo(0);
|
||||
if (info.fullPathHash != State || info.length <= 0f) return;
|
||||
if (info.normalizedTime * info.length >= PinAt) anim.Play(State, 0, PinAt / info.length);
|
||||
}
|
||||
|
||||
/// <summary>Blends out of the clip, unless a stagger has taken over (FormStagger has fired
|
||||
/// the form's own).</summary>
|
||||
public static void Release(Animator anim, Player player)
|
||||
{
|
||||
if (anim == null) return;
|
||||
if (ClipTime(anim) >= 0f && (player == null || !player.IsStaggering()))
|
||||
anim.CrossFadeInFixedTime(MovementState, Fade, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keeps the Cultist's breath in its hands, where the vanilla Cultist casts it from. fx_fenring_flames
|
||||
/// has two emitters, "flames_world left" and "flames_world right", set 1.2 to 1.6 m ahead of
|
||||
/// its own origin; spawned at the creature, the fire began that far in front of it. Each
|
||||
/// emitter goes on its hand bone (fenring_cultist rig: .../LeftForeArm/LeftHand and the right
|
||||
/// one), pointing where the player faces, so the two streams leave the palms and run forward.
|
||||
/// The embers and the light sit between the hands. Placed every LateUpdate, after the form's
|
||||
/// Animator has moved the arms. The same on every client's copy.
|
||||
///
|
||||
/// A form without hand bones keeps the whole effect at its mouth, as before.
|
||||
/// </summary>
|
||||
internal class CultistFlameFollow : MonoBehaviour
|
||||
{
|
||||
// Ahead of the palm, so the stream does not start inside the hand.
|
||||
private const float AheadOfHand = 0.15f;
|
||||
|
||||
// The light, further ahead along the stream.
|
||||
private const float LightAhead = 1.5f;
|
||||
|
||||
public Player Player;
|
||||
private Transform mouth, leftHand, rightHand;
|
||||
private Transform leftFlames, rightFlames, embers, light;
|
||||
private bool partsFound;
|
||||
private float nextLook;
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (Player == null) return;
|
||||
|
||||
if (!partsFound)
|
||||
{
|
||||
partsFound = true;
|
||||
leftFlames = transform.Find("flames_world left");
|
||||
rightFlames = transform.Find("flames_world right");
|
||||
embers = transform.Find("FireEmbers");
|
||||
light = transform.Find("Point light");
|
||||
}
|
||||
|
||||
// The form can be rebuilt under the same flames; look again now and then if lost.
|
||||
if ((leftHand == null || rightHand == null || mouth == null) && Time.time >= nextLook)
|
||||
{
|
||||
nextLook = Time.time + 0.5f;
|
||||
leftHand = FindBone(Player, "LeftHand");
|
||||
rightHand = FindBone(Player, "RightHand");
|
||||
mouth = FenrirAttackSync.FindMouth(Player);
|
||||
}
|
||||
|
||||
Quaternion facing = Player.transform.rotation;
|
||||
transform.SetPositionAndRotation(FenrirAttackSync.MouthPoint(Player, mouth), facing);
|
||||
if (leftHand == null || rightHand == null || leftFlames == null || rightFlames == null) return;
|
||||
|
||||
Vector3 forward = Player.transform.forward;
|
||||
Vector3 left = leftHand.position + forward * AheadOfHand;
|
||||
Vector3 right = rightHand.position + forward * AheadOfHand;
|
||||
leftFlames.SetPositionAndRotation(left, facing);
|
||||
rightFlames.SetPositionAndRotation(right, facing);
|
||||
|
||||
Vector3 between = (left + right) * 0.5f;
|
||||
if (embers != null) embers.SetPositionAndRotation(between, facing);
|
||||
if (light != null) light.position = between + forward * LightAhead;
|
||||
}
|
||||
|
||||
private static Transform FindBone(Player player, string name)
|
||||
{
|
||||
foreach (Transform child in player.transform)
|
||||
{
|
||||
if (child.name == "Visual" || !child.gameObject.activeInHierarchy) continue;
|
||||
foreach (Transform t in child.GetComponentsInChildren<Transform>())
|
||||
{
|
||||
if (t.name == name) return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the Cultist toward the camera while it breathes fire, as vanilla turns a player who
|
||||
/// blocks or draws a bow: Player.AlwaysRotateCamera answers true for those, and Character then
|
||||
/// turns the body to the look direction at its own turn speed. The breath is not a vanilla
|
||||
/// attack, so the body stayed facing wherever the movement keys had left it.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "AlwaysRotateCamera")]
|
||||
public static class Cultist_BreathFacesCamera_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance, ref bool __result)
|
||||
{
|
||||
if (!__result && __instance == Player.m_localPlayer && CultistFormBehavior.LocalBreathing) __result = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,20 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> WolfFormFallDamageReduction;
|
||||
public static ConfigEntry<float> FormStaminaRegenMultiplier;
|
||||
public static ConfigEntry<float> FormStaminaDrainReduction;
|
||||
public static ConfigEntry<float> FormAdrenalineMultiplier;
|
||||
|
||||
// ─── Form attack stamina (base cost, before the Unarmed skill discount) ─
|
||||
public static ConfigEntry<float> FenringLightClawStamina;
|
||||
public static ConfigEntry<float> FenringHeavyClawStamina;
|
||||
public static ConfigEntry<float> FenringJumpAttackStamina;
|
||||
public static ConfigEntry<float> CultistClawStamina;
|
||||
public static ConfigEntry<float> CultistDoubleClawStamina;
|
||||
public static ConfigEntry<float> WolfAttack1Stamina;
|
||||
public static ConfigEntry<float> WolfAttack2Stamina;
|
||||
public static ConfigEntry<float> WolfAttack3Stamina;
|
||||
public static ConfigEntry<float> UlvBiteStamina;
|
||||
public static ConfigEntry<float> UlvHeavyBiteStamina;
|
||||
public static ConfigEntry<float> UlvJumpAttackStamina;
|
||||
|
||||
// ─── Fenring form attacks ─────────────────────────────────────────────
|
||||
public static ConfigEntry<float> FenringHeavyClawDamage;
|
||||
|
|
@ -154,7 +168,7 @@ namespace RacesOfValheim
|
|||
CultistClawDamage = config.Bind(cultist, "Claw Damage", 85f,
|
||||
new ConfigDescription("Base damage of the single claw (Left Mouse), before the Unarmed skill bonus.", new AcceptableValueRange<float>(0f, 500f)));
|
||||
CultistDoubleClawDamage = config.Bind(cultist, "Double Claw Damage", 140f,
|
||||
new ConfigDescription("Base damage of the double claw (Middle Mouse), before the Unarmed skill bonus.", new AcceptableValueRange<float>(0f, 500f)));
|
||||
new ConfigDescription("Base damage of the double claw (Middle Mouse), before the Unarmed skill bonus. Each of its two swipes deals 60% of it.", new AcceptableValueRange<float>(0f, 500f)));
|
||||
CultistAttackRadius = config.Bind(cultist, "Claw Attack Radius", 2.5f,
|
||||
new ConfigDescription("Hit-sweep radius for both claw attacks.", new AcceptableValueRange<float>(1f, 10f)));
|
||||
CultistPushForce = config.Bind(cultist, "Claw Push Force", 30f,
|
||||
|
|
@ -194,6 +208,35 @@ namespace RacesOfValheim
|
|||
UlvPushForce = config.Bind(ulv, "Push Force", 25f,
|
||||
new ConfigDescription("Knockback applied on a hit.", new AcceptableValueRange<float>(0f, 100f)));
|
||||
|
||||
// Form attack stamina, beside each form's damage. Lower than a weapon's on purpose: the
|
||||
// forms pay less per swing and fill the adrenaline bar faster instead (Form Adrenaline
|
||||
// Multiplier). For scale, vanilla fists cost 4, Bjorn claws 6, Fenris claws 10.
|
||||
const string staminaNote = " Base stamina, cut by up to a third with the Unarmed skill as a weapon's is. 0 makes it free.";
|
||||
FormAdrenalineMultiplier = config.Bind(buffs, "Form Adrenaline Multiplier", 1.5f,
|
||||
new ConfigDescription("Adrenaline per form hit, times the bare-handed amount, in any Fenrir form.", new AcceptableValueRange<float>(0f, 5f)));
|
||||
FenringLightClawStamina = config.Bind(fenring, "Light Claw Stamina", 6f,
|
||||
new ConfigDescription("Stamina for the light claw (Left Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
FenringHeavyClawStamina = config.Bind(fenring, "Heavy Claw Stamina", 10f,
|
||||
new ConfigDescription("Stamina for the heavy claw (Right Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
FenringJumpAttackStamina = config.Bind(fenring, "Jump Attack Stamina", 16f,
|
||||
new ConfigDescription("Stamina for the leaping attack (Middle Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
CultistClawStamina = config.Bind(cultist, "Claw Stamina", 6f,
|
||||
new ConfigDescription("Stamina for the single claw (Left Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
CultistDoubleClawStamina = config.Bind(cultist, "Double Claw Stamina", 12f,
|
||||
new ConfigDescription("Stamina for the double claw (Middle Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
WolfAttack1Stamina = config.Bind(wolf, "Attack 1 Stamina", 4f,
|
||||
new ConfigDescription("Stamina for the Left Mouse attack." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
WolfAttack2Stamina = config.Bind(wolf, "Attack 2 Stamina", 6f,
|
||||
new ConfigDescription("Stamina for the Right Mouse attack." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
WolfAttack3Stamina = config.Bind(wolf, "Attack 3 Stamina", 10f,
|
||||
new ConfigDescription("Stamina for the Middle Mouse attack." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
UlvBiteStamina = config.Bind(ulv, "Bite Stamina", 5f,
|
||||
new ConfigDescription("Stamina for the Left Mouse bite." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
UlvHeavyBiteStamina = config.Bind(ulv, "Heavy Bite Stamina", 8f,
|
||||
new ConfigDescription("Stamina for the Right Mouse bite." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
UlvJumpAttackStamina = config.Bind(ulv, "Jump Attack Stamina", 14f,
|
||||
new ConfigDescription("Stamina for the leaping Middle Mouse attack." + staminaNote, new AcceptableValueRange<float>(0f, 50f)));
|
||||
|
||||
// The whole section stays local - see ConfigSync.LocalSections.
|
||||
const string appearance = "Fenrir - Appearance";
|
||||
ReadyMessage = config.Bind(appearance, "Ready Message", true,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@ namespace RacesOfValheim
|
|||
/// form's own routines, and on every revert.</summary>
|
||||
public static bool LocalAttacking { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How many hit events the local form's clips have fired: the creature's own "Hit" event,
|
||||
/// which CharacterAnimEvent hands to the player's OnAttackTrigger, and BlockPlayerAttackTriggerPatch
|
||||
/// counts here instead of letting it through. A swing waits for this to move, so its damage
|
||||
/// lands on the clip's own blow (TrolTrueFormModel.AttackEvents, the same idea).
|
||||
/// </summary>
|
||||
public static int AttackEvents { get; private set; }
|
||||
|
||||
public static void NotifyAttackTrigger() => AttackEvents++;
|
||||
|
||||
public static bool LocalInForm(Character character)
|
||||
{
|
||||
if (character == null || character != Player.m_localPlayer) return false;
|
||||
|
|
@ -353,9 +363,41 @@ namespace RacesOfValheim
|
|||
|
||||
ItemDrop unarmed = player.m_unarmedWeapon;
|
||||
float perHit = unarmed != null ? unarmed.m_itemData.m_shared.m_attack.m_attackAdrenaline : 1f;
|
||||
// The Fenrir forms trade cheaper swings for a faster bar; the other races' forms do not.
|
||||
if (FenrirForms.LocalInForm(player)) perHit *= FenrirConfig.FormAdrenalineMultiplier.Value;
|
||||
player.AddAdrenaline(perHit * character.m_enemyAdrenalineMultiplier * scale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Charges a form attack's stamina the way vanilla charges a weapon's (Attack.GetAttackStamina):
|
||||
/// the equipment modifier, status effects (meads, race passives), then up to a third off with
|
||||
/// the attack's skill. Without enough, the attack does not start and the stamina bar flashes,
|
||||
/// as it does for a weapon. A cost of 0 is free and always goes through.
|
||||
/// A staggered player cannot attack at all, and an attack that may start is marked for
|
||||
/// FormStagger, so a stagger before its hit cancels it.
|
||||
/// </summary>
|
||||
/// <returns>True if the attack may start; the stamina is already spent.</returns>
|
||||
public static bool TrySpendStamina(Player player, float baseCost, Skills.SkillType skill)
|
||||
{
|
||||
if (player != null && player.IsStaggering()) return false;
|
||||
FormStagger.MarkAttack();
|
||||
if (player == null || baseCost <= 0f) return true;
|
||||
|
||||
float cost = baseCost * (1f + player.GetEquipmentAttackStaminaModifier());
|
||||
player.GetSEMan().ModifyAttackStaminaUsage(cost, ref cost);
|
||||
cost -= cost * 0.33f * player.GetSkillFactor(skill);
|
||||
if (cost <= 0f) return true;
|
||||
|
||||
if (!player.HaveStamina(cost + 0.1f))
|
||||
{
|
||||
if (player == Player.m_localPlayer && Hud.instance != null) Hud.instance.StaminaBarEmptyFlash();
|
||||
return false;
|
||||
}
|
||||
|
||||
player.UseStamina(cost);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void LogHit(string form, IDestructible target, float damage)
|
||||
{
|
||||
if (!FenrirConfig.DebugFormHits.Value) return;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ namespace RacesOfValheim
|
|||
{
|
||||
public static bool Prefix(Humanoid __instance)
|
||||
{
|
||||
return !FenrirForms.LocalInForm(__instance);
|
||||
if (!FenrirForms.LocalInForm(__instance)) return true;
|
||||
FenrirForms.NotifyAttackTrigger();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
167
JotunnModStub/FormLightFollow.cs
Normal file
167
JotunnModStub/FormLightFollow.cs
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The lights a player wears - the Dvergr circlet's headlamp, a torch in hand - follow the form
|
||||
/// the player has taken.
|
||||
///
|
||||
/// A form hides the human body and leaves it standing where it was: PlayerVisualHider turns its
|
||||
/// renderers off, the Muspell shrinks the Visual to nothing. Either way the gear stays on the
|
||||
/// body's bones, and a Light is not a renderer, so the headlamp kept shining from the hidden
|
||||
/// human's head: at a person's height inside a troll's chest, from the feet of a Muspell. A
|
||||
/// tester saw it stuck where the head had been before the transformation.
|
||||
///
|
||||
/// While the body is hidden, every Light under it is put at the form's head bone, a little in
|
||||
/// front of it. A form with no bone called "head" gets the top front of its own model instead,
|
||||
/// and with no form model at all the light sits centre-forward at a person's head height. The
|
||||
/// lights go back to their own places the moment the body shows again.
|
||||
///
|
||||
/// Run for every player, not only the local one: the headlamp lights the world for onlookers too.
|
||||
/// </summary>
|
||||
public class FormLightFollow : MonoBehaviour
|
||||
{
|
||||
// Lights and the form's head are looked up again this often: VisEquipment rebuilds gear,
|
||||
// and a form can be built a frame after the body is hidden.
|
||||
private const float RescanInterval = 0.25f;
|
||||
|
||||
// RaceEyeHeight's reading of a Visual this small: hidden, not small.
|
||||
private const float HiddenScale = 0.05f;
|
||||
|
||||
// Ahead of the head bone, so the lamp does not light the skull from inside.
|
||||
private const float AheadOfHead = 0.3f;
|
||||
|
||||
// No form model at all: centre-forward, where a person's headlamp would be.
|
||||
private static readonly Vector3 FallbackOffset = new Vector3(0f, 1.6f, 0.4f);
|
||||
|
||||
private static readonly AccessTools.FieldRef<Character, GameObject> VisualRef =
|
||||
AccessTools.FieldRefAccess<Character, GameObject>("m_visual");
|
||||
|
||||
// Each light moved, with the local position it goes back to.
|
||||
private readonly Dictionary<Light, Vector3> moved = new Dictionary<Light, Vector3>();
|
||||
private readonly List<Light> dead = new List<Light>();
|
||||
private float nextScan;
|
||||
private Transform head;
|
||||
private Vector3 anchorOffset = FallbackOffset; // player-local, used when there is no head
|
||||
|
||||
public static void Tick(Player player)
|
||||
{
|
||||
GameObject visual = VisualRef(player);
|
||||
if (visual == null) return;
|
||||
|
||||
bool hidden = PlayerVisualHider.IsHidden(visual.transform) || visual.transform.localScale.y < HiddenScale;
|
||||
FormLightFollow follow = visual.GetComponent<FormLightFollow>();
|
||||
|
||||
if (!hidden)
|
||||
{
|
||||
if (follow != null && follow.moved.Count > 0) follow.Restore();
|
||||
return;
|
||||
}
|
||||
|
||||
if (follow == null) follow = visual.AddComponent<FormLightFollow>();
|
||||
follow.Follow(player);
|
||||
}
|
||||
|
||||
private void Follow(Player player)
|
||||
{
|
||||
if (Time.time >= nextScan)
|
||||
{
|
||||
nextScan = Time.time + RescanInterval;
|
||||
Scan(player);
|
||||
}
|
||||
|
||||
Transform body = player.transform;
|
||||
Vector3 anchor = head != null
|
||||
? head.position + body.forward * AheadOfHead
|
||||
: body.TransformPoint(anchorOffset);
|
||||
|
||||
foreach (Light light in moved.Keys)
|
||||
{
|
||||
if (light != null) light.transform.position = anchor;
|
||||
}
|
||||
}
|
||||
|
||||
private void Scan(Player player)
|
||||
{
|
||||
dead.Clear();
|
||||
foreach (Light light in moved.Keys)
|
||||
{
|
||||
if (light == null) dead.Add(light);
|
||||
}
|
||||
foreach (Light light in dead) moved.Remove(light);
|
||||
|
||||
foreach (Light light in GetComponentsInChildren<Light>(true))
|
||||
{
|
||||
if (!moved.ContainsKey(light)) moved.Add(light, light.transform.localPosition);
|
||||
}
|
||||
|
||||
if (moved.Count == 0) return;
|
||||
if (head == null || !head.gameObject.activeInHierarchy) FindForm(player);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The form's model is a child of the player beside the Visual (every form builds it that
|
||||
/// way). Its head bone, if it has one; otherwise the top front of its renderers.
|
||||
/// </summary>
|
||||
private void FindForm(Player player)
|
||||
{
|
||||
head = null;
|
||||
anchorOffset = FallbackOffset;
|
||||
|
||||
Transform body = player.transform;
|
||||
foreach (Transform child in body)
|
||||
{
|
||||
if (child == transform || !child.gameObject.activeInHierarchy) continue;
|
||||
if (child.GetComponentInChildren<Animator>() == null) continue;
|
||||
|
||||
head = FindHead(child);
|
||||
if (head != null) return;
|
||||
|
||||
Bounds bounds = default;
|
||||
bool any = false;
|
||||
foreach (Renderer r in child.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
if (!(r is SkinnedMeshRenderer) && !(r is MeshRenderer)) continue;
|
||||
if (any) bounds.Encapsulate(r.bounds); else { bounds = r.bounds; any = true; }
|
||||
}
|
||||
if (!any) continue;
|
||||
|
||||
Vector3 local = body.InverseTransformPoint(bounds.center);
|
||||
Vector3 size = body.InverseTransformVector(bounds.extents);
|
||||
anchorOffset = new Vector3(local.x, local.y + Mathf.Abs(size.y) * 0.6f, local.z + Mathf.Abs(size.z) * 0.6f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static Transform FindHead(Transform root)
|
||||
{
|
||||
foreach (Transform t in root.GetComponentsInChildren<Transform>())
|
||||
{
|
||||
if (string.Equals(t.name, "head", System.StringComparison.OrdinalIgnoreCase)) return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Restore()
|
||||
{
|
||||
foreach (KeyValuePair<Light, Vector3> entry in moved)
|
||||
{
|
||||
if (entry.Key != null) entry.Key.transform.localPosition = entry.Value;
|
||||
}
|
||||
moved.Clear();
|
||||
head = null;
|
||||
}
|
||||
|
||||
/// <summary>LateUpdate, so the form's Animator has already posed the head this frame.</summary>
|
||||
[HarmonyPatch(typeof(Player), "LateUpdate")]
|
||||
public static class Player_LateUpdate_FormLightFollow_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
Tick(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
95
JotunnModStub/FormStagger.cs
Normal file
95
JotunnModStub/FormStagger.cs
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// A staggered player in a form plays the form's own stagger.
|
||||
///
|
||||
/// Vanilla staggers a character with SetTrigger("stagger") on its own Animator (Character.RPC_Stagger),
|
||||
/// and that Animator belongs to the hidden human. The form's Animator never heard of it, so the
|
||||
/// True Form troll stood idle while the player could not move. A tester saw it.
|
||||
///
|
||||
/// Every creature worn as a form has the vanilla stagger ready to play (read offline with
|
||||
/// scripts/dump_controller.py, bundle c4210710): a "stagger" trigger and an AnyState -> Stagger
|
||||
/// transition in troll_animator, fenring_animator, fenring_cultist_animator, wolf_animator,
|
||||
/// ulv_animator, SeekerBrute_animator (the Sverm Ravager) and bat_animator (the Aswid bat).
|
||||
/// gd_king_animator (the Muspell) and hatchling_animator (the Skadi drake) have none, and are
|
||||
/// left alone by the parameter check.
|
||||
///
|
||||
/// The cue is Character.IsStaggering(), which reads the player's Animator state. The player's
|
||||
/// triggers are replicated, so this holds for onlookers' copies of the form too, with nothing
|
||||
/// published of its own. Fired once, as the stagger starts.
|
||||
///
|
||||
/// A stagger also cancels the local form's attack, as it cancels a weapon's in vanilla. The
|
||||
/// form's swing waits for its clip's hit event and lands on a timeout if none comes, so a
|
||||
/// stagger that cut the clip short still dealt the blow 1.5 s later. MarkAttack is called as an
|
||||
/// attack starts, and AttackInterrupted tells the hit whether a stagger began since.
|
||||
/// </summary>
|
||||
internal static class FormStagger
|
||||
{
|
||||
private const string Trigger = "stagger";
|
||||
|
||||
private static readonly AccessTools.FieldRef<Character, Animator> AnimatorRef =
|
||||
AccessTools.FieldRefAccess<Character, Animator>("m_animator");
|
||||
|
||||
private static readonly HashSet<int> staggering = new HashSet<int>();
|
||||
private static readonly List<Animator> animators = new List<Animator>();
|
||||
|
||||
// Staggers of the local player so far, and the count when the current attack started.
|
||||
private static int localStaggers;
|
||||
private static int attackMark;
|
||||
|
||||
public static void MarkAttack() => attackMark = localStaggers;
|
||||
|
||||
/// <summary>True if the local player has been staggered since the last MarkAttack.</summary>
|
||||
public static bool AttackInterrupted => localStaggers != attackMark;
|
||||
|
||||
public static void Tick(Player player)
|
||||
{
|
||||
int id = player.GetInstanceID();
|
||||
if (!player.IsStaggering())
|
||||
{
|
||||
staggering.Remove(id);
|
||||
return;
|
||||
}
|
||||
if (!staggering.Add(id)) return;
|
||||
if (player == Player.m_localPlayer) localStaggers++;
|
||||
|
||||
Animator own = AnimatorRef(player);
|
||||
RuntimeAnimatorController ownController = own != null ? own.runtimeAnimatorController : null;
|
||||
|
||||
player.GetComponentsInChildren(false, animators);
|
||||
foreach (Animator anim in animators)
|
||||
{
|
||||
// The human's own Animator staggers already, and so does anything driven by a copy of
|
||||
// its controller (a VRM model).
|
||||
if (anim == own || anim.runtimeAnimatorController == null) continue;
|
||||
if (anim.runtimeAnimatorController == ownController) continue;
|
||||
if (!anim.isActiveAndEnabled || !HasTrigger(anim)) continue;
|
||||
|
||||
anim.SetTrigger(Trigger);
|
||||
}
|
||||
animators.Clear();
|
||||
}
|
||||
|
||||
private static bool HasTrigger(Animator anim)
|
||||
{
|
||||
foreach (AnimatorControllerParameter p in anim.parameters)
|
||||
{
|
||||
if (p.type == AnimatorControllerParameterType.Trigger && p.name == Trigger) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "LateUpdate")]
|
||||
public static class Player_LateUpdate_FormStagger_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
FormStagger.Tick(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds eleven custom playable races (Alfar, Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
|
||||
"version_number": "1.6.3",
|
||||
"version_number": "1.6.4",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public const string PluginGUID = "com.nandor.racesofvalheim";
|
||||
public const string PluginName = "Races Of Valheim";
|
||||
public const string PluginVersion = "1.6.3";
|
||||
public const string PluginVersion = "1.6.4";
|
||||
|
||||
private readonly Harmony harmony = new Harmony(PluginGUID);
|
||||
|
||||
|
|
|
|||
|
|
@ -620,6 +620,7 @@ namespace RacesOfValheim
|
|||
hitData.SetAttacker(Player.m_localPlayer);
|
||||
|
||||
target.Damage(hitData);
|
||||
FormMelee.GrantAdrenaline(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<bool> HeadFireVFXEnabled;
|
||||
public static ConfigEntry<bool> BodyModelEnabled;
|
||||
public static ConfigEntry<bool> RaiseDeadIcon;
|
||||
public static ConfigEntry<bool> ShowHelmet;
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
|
|
@ -86,6 +87,7 @@ namespace RacesOfValheim
|
|||
new ConfigDescription("Whether Skeleton players wear the skeleton body. Turn it off if you use a player model mod (EnhancedValheimVRM and the like): Skeletons then keep the vanilla viking body, so the replacement model shows without bones clipping through it. Abilities are unchanged. Client-side, like the option above: it applies to every Skeleton you see, yourself included, and changes nothing for other players."));
|
||||
RaiseDeadIcon = config.Bind(visuals, "Raise the Dead Icon", true,
|
||||
new ConfigDescription("Shows the Raise the Dead status icon while your Summon on Kill is on."));
|
||||
}
|
||||
ShowHelmet = config.Bind(visuals, "Show Helmet", false,
|
||||
new ConfigDescription("Off: your helmet stays hidden over the skull. On: the helmet you wear shows. Helmets and hoods are moved and enlarged to fit the skull. Your own choice: other players see you the way you picked. A viking body (Body Model Enabled off) always shows its helmet.")); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ namespace RacesOfValheim
|
|||
|
||||
HideItemInstances(__instance, "m_hairItemInstance");
|
||||
HideItemInstances(__instance, "m_beardItemInstance");
|
||||
SetHelmetVisible(__instance, false);
|
||||
SkeletonVisuals.FitHelmet(p, __instance, SkeletonVisuals.ShowsHelmet(p));
|
||||
|
||||
// Poses the mandible, once per frame, after the animation. Attached from
|
||||
// here rather than from SkeletonRace because this postfix is the one path
|
||||
|
|
@ -396,7 +396,7 @@ namespace RacesOfValheim
|
|||
|
||||
ShowItemInstances(__instance, "m_hairItemInstance");
|
||||
ShowItemInstances(__instance, "m_beardItemInstance");
|
||||
SetHelmetVisible(__instance, true);
|
||||
SkeletonVisuals.UnfitHelmet(__instance);
|
||||
|
||||
// Parented to rig bones, not to the body container that was just switched
|
||||
// off above - so without this a human keeps the skeleton's lit sockets.
|
||||
|
|
@ -405,26 +405,6 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A helmet on a skull looks like a helmet floating in a skull, so the race hides it.
|
||||
///
|
||||
/// SkeletonRace does this every frame in a world, but it only ever runs for the local
|
||||
/// player - which is why the helmet came back on the main-menu preview once the body
|
||||
/// swap started working there. Doing it here covers the menu, remote players and the
|
||||
/// first frame after a race change, all of which reach this postfix and none of which
|
||||
/// reach SkeletonRace.
|
||||
///
|
||||
/// Delegates to SkeletonVisuals.SetEquipmentPieceHidden, which scales the wrapper to
|
||||
/// zero and disables its renderers - scale alone leaves a skinned piece (bound to the
|
||||
/// player's own bones rather than its own transform) still drawing, which is what a
|
||||
/// helmet with a skinned cloth or chain part looked like.
|
||||
/// </summary>
|
||||
private static void SetHelmetVisible(VisEquipment visEq, bool visible)
|
||||
{
|
||||
GameObject helmet = Traverse.Create(visEq).Field<GameObject>("m_helmetItemInstance").Value;
|
||||
SkeletonVisuals.SetEquipmentPieceHidden(helmet, !visible);
|
||||
}
|
||||
|
||||
private static void HideItemInstances(VisEquipment visEq, string fieldName)
|
||||
{
|
||||
SetItemInstanceActive(visEq, fieldName, false);
|
||||
|
|
|
|||
|
|
@ -396,10 +396,11 @@ namespace RacesOfValheim
|
|||
{
|
||||
// Hide Helmets (Valheim uses singular GameObject for helmet). Only over a skull:
|
||||
// a viking body wears its helmet, and the VisEquipment postfix puts it back.
|
||||
// "Show Helmet" keeps it on the skull too, and is published for other clients.
|
||||
SkeletonVisuals.PublishShowHelmet(Player.m_localPlayer);
|
||||
if (SkeletonConfig.BodyModelEnabled.Value)
|
||||
{
|
||||
var helmetObj = HarmonyLib.Traverse.Create(currentVis).Field<GameObject>("m_helmetItemInstance").Value;
|
||||
SkeletonVisuals.SetEquipmentPieceHidden(helmetObj, true);
|
||||
SkeletonVisuals.FitHelmet(Player.m_localPlayer, currentVis, SkeletonConfig.ShowHelmet.Value);
|
||||
}
|
||||
|
||||
// Scale Body Armor (Chest, Legs, Shoulder) by 5%
|
||||
|
|
|
|||
|
|
@ -59,6 +59,41 @@ namespace RacesOfValheim
|
|||
public static bool ShowsSkeletonBody(Player player) =>
|
||||
SkeletonConfig.BodyModelEnabled.Value && IsSkeletonPlayer(player);
|
||||
|
||||
// The owner's "Show Helmet" choice, so every other client draws this skeleton's helmet the
|
||||
// way its owner picked rather than the way the onlooker's own setting says.
|
||||
public const string ShowHelmetZdoKey = "RacesOfValheim_SkeletonShowHelmet";
|
||||
|
||||
/// <summary>
|
||||
/// Whether this skeleton wears its helmet visibly over the skull. The local player and the
|
||||
/// menu preview (which has no ZDO and is always this client's own character) go by this
|
||||
/// client's setting; anyone else by what their owner published.
|
||||
/// </summary>
|
||||
public static bool ShowsHelmet(Player player)
|
||||
{
|
||||
if (player == null) return false;
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (player == Player.m_localPlayer || nview == null || !nview.IsValid())
|
||||
{
|
||||
return SkeletonConfig.ShowHelmet.Value;
|
||||
}
|
||||
|
||||
return nview.GetZDO().GetBool(ShowHelmetZdoKey, false);
|
||||
}
|
||||
|
||||
/// <summary>Writes the local player's choice to its ZDO when it differs. Owner only.</summary>
|
||||
public static void PublishShowHelmet(Player player)
|
||||
{
|
||||
ZNetView nview = player != null ? player.GetComponent<ZNetView>() : null;
|
||||
if (nview == null || !nview.IsValid() || !nview.IsOwner()) return;
|
||||
|
||||
bool show = SkeletonConfig.ShowHelmet.Value;
|
||||
if (nview.GetZDO().GetBool(ShowHelmetZdoKey, false) != show)
|
||||
{
|
||||
nview.GetZDO().Set(ShowHelmetZdoKey, show);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fully hides (or restores) one equipped item instance - a helmet, typically.
|
||||
///
|
||||
|
|
@ -71,11 +106,11 @@ namespace RacesOfValheim
|
|||
/// is reasserted the same way (Valheim's own visual refresh re-enables the instance and
|
||||
/// resets its scale, so both must be redone every time visuals rebuild).
|
||||
/// </summary>
|
||||
public static void SetEquipmentPieceHidden(GameObject instance, bool hidden)
|
||||
public static void SetEquipmentPieceHidden(GameObject instance, bool hidden, float shownSize = 1f)
|
||||
{
|
||||
if (instance == null) return;
|
||||
|
||||
Vector3 wantedScale = hidden ? Vector3.zero : Vector3.one;
|
||||
Vector3 wantedScale = hidden ? Vector3.zero : Vector3.one * shownSize;
|
||||
if (instance.transform.localScale != wantedScale)
|
||||
{
|
||||
instance.transform.localScale = wantedScale;
|
||||
|
|
@ -90,6 +125,218 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where VisEquipment.AttachItem put the helmet: zero, or the prefab's own "equipoffset".
|
||||
/// Kept on the instance so the fit is always a delta on it, and so taking the fit off
|
||||
/// puts the helmet back exactly. A re-equip makes a new instance without one.
|
||||
/// </summary>
|
||||
private class HelmetBasePose : MonoBehaviour
|
||||
{
|
||||
public Vector3 Position;
|
||||
|
||||
// Skinned parts whose Head bone was swapped for the fit bone, with the bone list
|
||||
// AttachItem gave them, so a viking body gets its own head back.
|
||||
public readonly List<SkinnedMeshRenderer> Fitted = new List<SkinnedMeshRenderer>();
|
||||
public readonly List<Transform[]> OriginalBones = new List<Transform[]>();
|
||||
}
|
||||
|
||||
private const string FitBoneName = "SkeletonHelmetFitBone";
|
||||
|
||||
// The helmet on a skull: metres up and forward, and size. Dialled in on screen with
|
||||
// Configuration Manager sliders (playtest, 2026-10-29) on the bronze, drake and flametal
|
||||
// helmets, then written down here; the sliders are gone. One set fits all three bodies.
|
||||
private const float HelmetFitUp = 0.068f;
|
||||
private const float HelmetFitForward = -0.053f;
|
||||
private const float HelmetFitSize = 1.298f;
|
||||
|
||||
// The same for the fit bone of skinned helmets (the 16 vanilla prefabs with an
|
||||
// "attach_skin" child: hoods, but also Padded, Carapace, Sweatband and others). Tuned on
|
||||
// the Fenring hood, then checked on nearly all the rest (2026-10-29). It scales from the
|
||||
// Head bone's pivot rather than the helmet joint's, hence the different numbers.
|
||||
private const float HoodFitUp = 0.041f;
|
||||
private const float HoodFitForward = -0.071f;
|
||||
private const float HoodFitSize = 1.246f;
|
||||
|
||||
// Which of the helmet joint's own axes are the skull's up and forward. Every player wears
|
||||
// the same rig, so this is found once and kept. Re-picking it every frame made the
|
||||
// offset jump sideways whenever the head turned far enough for another axis to win.
|
||||
private static bool fitAxesFound;
|
||||
private static Vector3 fitUpAxis, fitForwardAxis;
|
||||
|
||||
/// <summary>
|
||||
/// Picks the axes only while the head faces straight ahead, so a turned head on the
|
||||
/// first frame cannot lock in the wrong ones. False until then.
|
||||
/// </summary>
|
||||
private static bool FindFitAxes(Transform joint, Player player)
|
||||
{
|
||||
Vector3 up = ClosestLocalAxis(joint, player.transform.up);
|
||||
Vector3 forward = ClosestLocalAxis(joint, player.transform.forward);
|
||||
if (Vector3.Dot(joint.TransformDirection(up), player.transform.up) < 0.8f ||
|
||||
Vector3.Dot(joint.TransformDirection(forward), player.transform.forward) < 0.8f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
fitUpAxis = up;
|
||||
fitForwardAxis = forward;
|
||||
fitAxesFound = true;
|
||||
Jotunn.Logger.LogInfo($"[Skeleton] Helmet fit on '{joint.name}': up = local {up}, forward = local {forward}, joint scale {joint.lossyScale}.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The helmet on a skull: hidden, or shown and moved to fit the skull, which is bigger
|
||||
/// and sits higher and further back than the viking head the helmet hangs for. Hidden
|
||||
/// unless the owner turned on "Show Helmet" (ShowsHelmet).
|
||||
///
|
||||
/// Called from the VisEquipment postfix as well as SkeletonRace and ZdoVisualSync:
|
||||
/// SkeletonRace only ever runs for the local player, which is why the helmet once came
|
||||
/// back on the main-menu preview. The postfix covers the menu, remote players and the
|
||||
/// first frame after a race change.
|
||||
///
|
||||
/// Up and forward are the player's, carried over to whichever of the helmet joint's own
|
||||
/// axes points closest to them. The joint turns with the head, so the helmet keeps its
|
||||
/// place on the skull when the player looks up or down.
|
||||
///
|
||||
/// A hood ("attach_skin") is skinned to the player's own bones, so moving its transform
|
||||
/// does nothing. Its parts weighted to the Head bone get a fit bone instead: a child of
|
||||
/// the real Head carrying the same kind of move and size. The parts weighted to the neck
|
||||
/// and shoulders stay put, so the hood stretches between the two like it would over a
|
||||
/// bigger head. Rigid helmets with a skinned chain or cloth piece get the same treatment
|
||||
/// for that piece.
|
||||
/// </summary>
|
||||
public static void FitHelmet(Player player, VisEquipment vis, bool show)
|
||||
{
|
||||
GameObject helmet = vis != null ? HarmonyLib.Traverse.Create(vis).Field<GameObject>("m_helmetItemInstance").Value : null;
|
||||
if (helmet == null) return;
|
||||
|
||||
if (!show)
|
||||
{
|
||||
SetEquipmentPieceHidden(helmet, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Always the helmet joint, never the instance's parent: a hood hangs off the body
|
||||
// container, whose axes are not the head's.
|
||||
Transform joint = HarmonyLib.Traverse.Create(vis).Field<Transform>("m_helmet").Value;
|
||||
bool rigid = joint != null && helmet.transform.parent == joint;
|
||||
|
||||
SetEquipmentPieceHidden(helmet, false, rigid ? HelmetFitSize : 1f);
|
||||
|
||||
HelmetBasePose pose = helmet.GetComponent<HelmetBasePose>();
|
||||
if (pose == null)
|
||||
{
|
||||
pose = helmet.AddComponent<HelmetBasePose>();
|
||||
pose.Position = helmet.transform.localPosition;
|
||||
}
|
||||
|
||||
if (joint == null) return;
|
||||
if (!fitAxesFound && !FindFitAxes(joint, player)) return;
|
||||
|
||||
if (rigid)
|
||||
{
|
||||
Vector3 worldOffset = FitOffset(joint, HelmetFitUp, HelmetFitForward);
|
||||
Vector3 wanted = pose.Position + joint.InverseTransformVector(worldOffset);
|
||||
if (helmet.transform.localPosition != wanted)
|
||||
{
|
||||
helmet.transform.localPosition = wanted;
|
||||
}
|
||||
}
|
||||
|
||||
FitSkinnedParts(player, helmet, pose, joint);
|
||||
}
|
||||
|
||||
private static Vector3 FitOffset(Transform joint, float up, float forward) =>
|
||||
joint.TransformDirection(fitUpAxis) * up + joint.TransformDirection(fitForwardAxis) * forward;
|
||||
|
||||
private static readonly HashSet<string> loggedCloth = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Points every skinned part of the helmet that uses the Head bone at this player's fit
|
||||
/// bone, and keeps the fit bone posed. The bone list is the part's own copy (Unity
|
||||
/// copies on get and on set), so the body and the other armour keep the real Head.
|
||||
/// </summary>
|
||||
private static void FitSkinnedParts(Player player, GameObject helmet, HelmetBasePose pose, Transform joint)
|
||||
{
|
||||
Animator anim = player.GetComponentInChildren<Animator>();
|
||||
Transform head = anim != null ? anim.GetBoneTransform(HumanBodyBones.Head) : null;
|
||||
if (head == null) return;
|
||||
|
||||
Transform fitBone = null;
|
||||
foreach (SkinnedMeshRenderer smr in helmet.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
||||
{
|
||||
if (pose.Fitted.Contains(smr)) continue;
|
||||
|
||||
Transform[] bones = smr.bones;
|
||||
int index = System.Array.IndexOf(bones, head);
|
||||
if (index < 0) continue;
|
||||
|
||||
if (fitBone == null) fitBone = GetFitBone(head);
|
||||
pose.Fitted.Add(smr);
|
||||
pose.OriginalBones.Add((Transform[])bones.Clone());
|
||||
bones[index] = fitBone;
|
||||
smr.bones = bones;
|
||||
|
||||
if (smr.GetComponent<Cloth>() != null && loggedCloth.Add(helmet.name))
|
||||
{
|
||||
Jotunn.Logger.LogInfo($"[Skeleton] Helmet '{helmet.name}': skinned part '{smr.name}' carries Cloth; its Head bone was swapped for the fit bone.");
|
||||
}
|
||||
}
|
||||
|
||||
if (pose.Fitted.Count == 0) return;
|
||||
if (fitBone == null) fitBone = GetFitBone(head);
|
||||
|
||||
Vector3 wantedPos = head.InverseTransformVector(FitOffset(joint, HoodFitUp, HoodFitForward));
|
||||
Vector3 wantedScale = Vector3.one * HoodFitSize;
|
||||
if (fitBone.localPosition != wantedPos) fitBone.localPosition = wantedPos;
|
||||
if (fitBone.localScale != wantedScale) fitBone.localScale = wantedScale;
|
||||
}
|
||||
|
||||
/// <summary>This head's fit bone, made the first time a skinned helmet part needs it.</summary>
|
||||
private static Transform GetFitBone(Transform head)
|
||||
{
|
||||
Transform fitBone = head.Find(FitBoneName);
|
||||
if (fitBone != null) return fitBone;
|
||||
|
||||
fitBone = new GameObject(FitBoneName).transform;
|
||||
fitBone.SetParent(head, false);
|
||||
fitBone.localRotation = Quaternion.identity;
|
||||
return fitBone;
|
||||
}
|
||||
|
||||
/// <summary>Shows the helmet where vanilla put it, undoing any fit. For a viking body.</summary>
|
||||
public static void UnfitHelmet(VisEquipment vis)
|
||||
{
|
||||
GameObject helmet = vis != null ? HarmonyLib.Traverse.Create(vis).Field<GameObject>("m_helmetItemInstance").Value : null;
|
||||
if (helmet == null) return;
|
||||
|
||||
SetEquipmentPieceHidden(helmet, false);
|
||||
|
||||
HelmetBasePose pose = helmet.GetComponent<HelmetBasePose>();
|
||||
if (pose == null) return;
|
||||
|
||||
if (helmet.transform.localPosition != pose.Position)
|
||||
{
|
||||
helmet.transform.localPosition = pose.Position;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pose.Fitted.Count; i++)
|
||||
{
|
||||
if (pose.Fitted[i] != null) pose.Fitted[i].bones = pose.OriginalBones[i];
|
||||
}
|
||||
pose.Fitted.Clear();
|
||||
pose.OriginalBones.Clear();
|
||||
}
|
||||
|
||||
private static Vector3 ClosestLocalAxis(Transform joint, Vector3 worldDir)
|
||||
{
|
||||
Vector3 local = joint.InverseTransformDirection(worldDir);
|
||||
Vector3 abs = new Vector3(Mathf.Abs(local.x), Mathf.Abs(local.y), Mathf.Abs(local.z));
|
||||
if (abs.x >= abs.y && abs.x >= abs.z) return new Vector3(Mathf.Sign(local.x), 0f, 0f);
|
||||
if (abs.y >= abs.z) return new Vector3(0f, Mathf.Sign(local.y), 0f);
|
||||
return new Vector3(0f, 0f, Mathf.Sign(local.z));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The tier a given player's body should be built for. The ZDO carries it so remote
|
||||
/// players render at their own standing; without one - the menu preview - fall back to
|
||||
|
|
|
|||
|
|
@ -744,7 +744,7 @@ namespace RacesOfValheim
|
|||
|
||||
wasGrounded = grounded;
|
||||
|
||||
if (!RaceInput.Allowed || !grounded) return;
|
||||
if (!RaceInput.Allowed || !grounded || player.IsStaggering()) return;
|
||||
|
||||
// Right click rams, left click bites, middle click slams. All three read the device
|
||||
// directly (mouse, or its gamepad counterpart - see RaceInput.AttackDown) rather than
|
||||
|
|
@ -782,6 +782,7 @@ namespace RacesOfValheim
|
|||
float radius, bool slam, bool lunge)
|
||||
{
|
||||
isAttacking = true;
|
||||
FormStagger.MarkAttack();
|
||||
bool played = StartAttackState(profile);
|
||||
if (rootMotion != null) rootMotion.Active = lunge;
|
||||
|
||||
|
|
@ -791,6 +792,7 @@ namespace RacesOfValheim
|
|||
|
||||
yield return FollowAttackState(stateName, played, 0f, () =>
|
||||
{
|
||||
if (FormStagger.AttackInterrupted) return;
|
||||
if (slam) Slam(profile, radius, leftY, rightY, dropSamples);
|
||||
else ExecuteDamage(profile, radius);
|
||||
}, () =>
|
||||
|
|
@ -1067,6 +1069,7 @@ namespace RacesOfValheim
|
|||
hitData.SetAttacker(player);
|
||||
|
||||
target.Damage(hitData);
|
||||
FormMelee.GrantAdrenaline(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,9 +216,9 @@
|
|||
"rov_compendium_trenta_purple_rain_g_key": "[The Elder Unlock] Purple Rain ('G' Key):",
|
||||
"rov_compendium_trenta_sap_heartwood_conduct_lightning_turn": "Sap and heartwood conduct lightning and turn away the dead: you take half damage from Lightning and Spirit. But kindling burns and the woodsman's axe still bites - you take half again as much from Fire and Slash. Meat, fish, eggs and honey are nothing you can stomach; only what grows from the ground sustains you, and it does so for $1x as long as it would a normal body.\n",
|
||||
"rov_compendium_trenta_secrets_heartwood": "The Secrets of the Heartwood\n",
|
||||
"rov_compendium_trenta_spray_toxic_pollen_bursts_out": "A spray of toxic pollen bursts out to $1 meters: every ally caught in it is healed $2, every foe is poisoned for $3. $4-second cooldown, shortened to $5 seconds while transformed into Muspell.\n",
|
||||
"rov_compendium_trenta_spray_toxic_pollen_bursts_out": "A spray of toxic pollen bursts out to $1 meters: you and every ally caught in it are healed $2, every foe is poisoned for $3. $4-second cooldown, shortened to $5 seconds while transformed into Muspell.\n",
|
||||
"rov_compendium_trenta_stand_still_daylight_roof_over": "Stand still in daylight, roof over nothing but sky, for $1 unbroken seconds, and roots take hold: $2 ticks of healing follow, $3% of your maximum health apiece, along with a Rested buff lasting $4 minutes - longer with every boss you have felled.\n",
|
||||
"rov_compendium_trenta_swamp_has_nothing_left_spoil": "The swamp has nothing left to spoil in you. Poison cannot touch you, the Wet effect cannot land on you, and swimming costs no stamina at all.\n",
|
||||
"rov_compendium_trenta_swamp_has_nothing_left_spoil": "The swamp has nothing left to spoil in you. Poison cannot touch you, the Wet effect cannot land on you, and swimming costs no stamina at all. In the water your stamina even comes back, slowly.\n",
|
||||
"rov_compendium_trenta_swarm_hornets_has_made_its": "A swarm of hornets has made its home in your branches and never leaves. Any foe that comes within $1 meters is stung for $2 poison and pierce damage every $3 seconds until it breaks off or falls.\n",
|
||||
"rov_compendium_trenta_take_shape_young_elder_root": "Take the shape of a young Elder, root and bramble given fury. Left Mouse stomps the ground for $1 damage in a ring around you, Right Mouse looses a root-spike that pierces for $2 - both rising with your Unarmed skill. Purple Rain still answers your call while transformed, on its shorter cooldown.\n",
|
||||
"rov_compendium_trenta_thorns_passive": "[Moder Unlock] Thorns (Passive):",
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
"rov_hover_trenta_ready_empty": "ready: $1 $2\n[<color=yellow><b>$KEY_Use</b></color>] Empty it",
|
||||
"rov_hover_trenta_rotting_minutes_left": "rotting, $1 minutes left",
|
||||
"rov_hover_trol_call_warbands": "\n[<color=yellow><b>$KEY_Use</b></color>] Call the warbands",
|
||||
"rov_hover_trol_grab_log": "\n[<color=yellow><b>$1</b></color>] Grab Log",
|
||||
"rov_hover_trol_grab_log": "\n[<color=yellow><b>$KEY_Use</b></color>] Grab Log",
|
||||
"rov_hover_trol_warbands": "warbands $1/$2",
|
||||
"rov_hover_trol_yagluth_drop_hand_buys_king": "\n(a Yagluth drop in hand buys a king's head, and two more bands)",
|
||||
"rov_hover_ward_personal": "Personal",
|
||||
|
|
|
|||
|
|
@ -216,9 +216,9 @@
|
|||
"rov_compendium_trenta_purple_rain_g_key": "[Sblocco Antico] Purple Rain (tasto 'G'):",
|
||||
"rov_compendium_trenta_sap_heartwood_conduct_lightning_turn": "Linfa e durame conducono il fulmine e respingono i morti: subisci metà dei danni da fulmine e da spirito. Ma la legna da ardere brucia e l'ascia del boscaiolo morde ancora: subisci una volta e mezza i danni da fuoco e da taglio. Carne, pesce, uova e miele non riesci a mandarli giù; ti sostiene solo ciò che cresce dalla terra, e lo fa $1 volte più a lungo che per un corpo normale.\n",
|
||||
"rov_compendium_trenta_secrets_heartwood": "I segreti del durame\n",
|
||||
"rov_compendium_trenta_spray_toxic_pollen_bursts_out": "Uno spruzzo di polline tossico esplode fino a $1 metri: ogni alleato colpito viene curato di $2, ogni nemico viene avvelenato per $3. Ricarica di $4 secondi, ridotta a $5 secondi da trasformato in Muspell.\n",
|
||||
"rov_compendium_trenta_spray_toxic_pollen_bursts_out": "Uno spruzzo di polline tossico esplode fino a $1 metri: tu e ogni alleato colpito venite curati di $2, ogni nemico viene avvelenato per $3. Ricarica di $4 secondi, ridotta a $5 secondi da trasformato in Muspell.\n",
|
||||
"rov_compendium_trenta_stand_still_daylight_roof_over": "Resta fermo alla luce del giorno, con sopra la testa nient'altro che cielo, per $1 secondi di fila, e le radici attecchiscono: seguono $2 impulsi di cura, ciascuno del $3% della salute massima, insieme a un bonus Riposato di $4 minuti, più lungo per ogni boss che hai abbattuto.\n",
|
||||
"rov_compendium_trenta_swamp_has_nothing_left_spoil": "La palude non ha più niente da guastare in te. Il veleno non può toccarti, l'effetto Bagnato non può colpirti, e nuotare non costa stamina.\n",
|
||||
"rov_compendium_trenta_swamp_has_nothing_left_spoil": "La palude non ha più niente da guastare in te. Il veleno non può toccarti, l'effetto Bagnato non può colpirti, e nuotare non costa stamina. In acqua la stamina torna persino, piano piano.\n",
|
||||
"rov_compendium_trenta_swarm_hornets_has_made_its": "Uno sciame di calabroni ha fatto casa tra i tuoi rami e non se ne va più. Ogni nemico che arriva entro $1 metri viene punto per $2 danni da veleno e perforanti ogni $3 secondi, finché non si allontana o cade.\n",
|
||||
"rov_compendium_trenta_take_shape_young_elder_root": "Prendi la forma di un giovane Antico, radici e rovi fatti furia. Il tasto sinistro pesta il terreno per $1 danni in un anello intorno a te, il destro scaglia una punta di radice che perfora per $2, ed entrambi crescono con la tua abilità a mani nude. Purple Rain risponde ancora al tuo richiamo mentre sei trasformato, con la sua ricarica più breve.\n",
|
||||
"rov_compendium_trenta_thorns_passive": "[Sblocco Moder] Spine (passiva):",
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
"rov_hover_trenta_ready_empty": "pronto: $1 $2\n[<color=yellow><b>$KEY_Use</b></color>] Svuotala",
|
||||
"rov_hover_trenta_rotting_minutes_left": "sta marcendo, mancano $1 minuti",
|
||||
"rov_hover_trol_call_warbands": "\n[<color=yellow><b>$KEY_Use</b></color>] Chiama le bande da guerra",
|
||||
"rov_hover_trol_grab_log": "\n[<color=yellow><b>$1</b></color>] Afferra il tronco",
|
||||
"rov_hover_trol_grab_log": "\n[<color=yellow><b>$KEY_Use</b></color>] Afferra il tronco",
|
||||
"rov_hover_trol_warbands": "bande da guerra $1/$2",
|
||||
"rov_hover_trol_yagluth_drop_hand_buys_king": "\n(un bottino di Yagluth in mano compra la testa di un re, e altre due bande)",
|
||||
"rov_hover_ward_personal": "Personale",
|
||||
|
|
|
|||
|
|
@ -216,9 +216,9 @@
|
|||
"rov_compendium_trenta_purple_rain_g_key": "[Награда: Древний] Purple Rain (клавиша «G»):",
|
||||
"rov_compendium_trenta_sap_heartwood_conduct_lightning_turn": "Смола и сердцевина древесины проводят молнию и отваживают нежить: вы получаете половинный урон от молнии и духа. Но сухие ветви быстро разгораются, а топор дровосека безжалостен — урон от огня и рубящих атак увеличен в полтора раза. Мясо, рыба, яйца и мед противны вашей натуре; лишь то, что произрастает из земли, дает вам силы, и действует в $1 раз дольше, чем на обычного человека.\n",
|
||||
"rov_compendium_trenta_secrets_heartwood": "Тайны Сердцевины\n",
|
||||
"rov_compendium_trenta_spray_toxic_pollen_bursts_out": "Выброс токсичной пыльцы в радиусе $1 м: каждый союзник внутри исцеляется на $2 ед., а каждый враг отравляется на $3 ед. урона. Перезарядка: $4 с (сокращается до $5 с в облике Муспелля).\n",
|
||||
"rov_compendium_trenta_spray_toxic_pollen_bursts_out": "Выброс токсичной пыльцы в радиусе $1 м: вы и каждый союзник внутри исцеляетесь на $2 ед., а каждый враг отравляется на $3 ед. урона. Перезарядка: $4 с (сокращается до $5 с в облике Муспелля).\n",
|
||||
"rov_compendium_trenta_stand_still_daylight_roof_over": "Постойте неподвижно под чистым небом при дневном свете в течение $1 с, и корни войдут в почву: последуют $2 тактов исцеления по $3% от макс. здоровья каждый, а также эффект «Бодрость» на $4 минут — время действия растет с каждым павшим боссом.\n",
|
||||
"rov_compendium_trenta_swamp_has_nothing_left_spoil": "Болотам нечего осквернять в вашем теле. Яд не может навредить вам, эффект сырости не накладывается, а плавание вовсе не расходует выносливость.\n",
|
||||
"rov_compendium_trenta_swamp_has_nothing_left_spoil": "Болотам нечего осквернять в вашем теле. Яд не может навредить вам, эффект сырости не накладывается, а плавание вовсе не расходует выносливость. В воде выносливость даже понемногу восстанавливается.\n",
|
||||
"rov_compendium_trenta_swarm_hornets_has_made_its": "Рой шершней свил гнездо в вашей кроне. Любой враг, приблизившийся на расстояние ближе $1 м, получает $2 ед. урона ядом и колющими ударами каждые $3 с, пока не отступит или не погибнет.\n",
|
||||
"rov_compendium_trenta_take_shape_young_elder_root": "Примите облик юного Древнего, воплотив ярость корней и терновника. ЛКМ сотрясает землю, нанося $1 ед. урона в круге вокруг вас, а ПКМ выпускает пронзающий корень на $2 ед. урона — мощь обоих приемов зависит от навыка «Без оружия». В этой форме вы по-прежнему можете призывать Purple Rain с уменьшенным временем перезарядки.\n",
|
||||
"rov_compendium_trenta_thorns_passive": "[Награда: Матерь] Шипы (Пассивное):",
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
"rov_hover_trenta_ready_empty": "готово: $1 $2\n[<color=yellow><b>$KEY_Use</b></color>] Опустошить",
|
||||
"rov_hover_trenta_rotting_minutes_left": "гниет, осталось $1 мин",
|
||||
"rov_hover_trol_call_warbands": "\n[<color=yellow><b>$KEY_Use</b></color>] Созвать боевые дружины",
|
||||
"rov_hover_trol_grab_log": "\n[<color=yellow><b>$1</b></color>] Взять бревно",
|
||||
"rov_hover_trol_grab_log": "\n[<color=yellow><b>$KEY_Use</b></color>] Взять бревно",
|
||||
"rov_hover_trol_warbands": "дружины $1/$2",
|
||||
"rov_hover_trol_yagluth_drop_hand_buys_king": "\n(трофей Яглута в руке позволит насадить голову конунга и нанять еще две дружины)",
|
||||
"rov_hover_ward_personal": "Личный",
|
||||
|
|
|
|||
|
|
@ -194,6 +194,10 @@ namespace RacesOfValheim
|
|||
|
||||
SpawnPurpleRainVfx(player);
|
||||
|
||||
// The Trenta stands in its own rain and is healed by it too. It used to be left out, so
|
||||
// a lone Trenta cast a heal that never touched anyone.
|
||||
player.Heal(TrentaConfig.PurpleRainHealAmount, true);
|
||||
|
||||
HashSet<Character> hit = new HashSet<Character>();
|
||||
foreach (Collider collider in Physics.OverlapSphere(player.transform.position, TrentaConfig.PurpleRainRadius))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> PurpleRainHealAmount;
|
||||
public static ConfigEntry<float> PurpleRainPoisonDamage;
|
||||
|
||||
// ─── Bonemass (tier 4+, passive) ──────────────────────────────────────
|
||||
public static ConfigEntry<float> SwimStaminaRegen;
|
||||
|
||||
// ─── Last Stand & Thorns (tier 5+) ────────────────────────────────────
|
||||
public static ConfigEntry<float> LastStandMaxArmorBonus;
|
||||
public static ConfigEntry<float> ThornsReflectPercent;
|
||||
|
|
@ -110,10 +113,14 @@ namespace RacesOfValheim
|
|||
PurpleRainRadius = config.Bind(purpleRain, "Radius", 8f,
|
||||
new ConfigDescription("Meters from the player the spray reaches.", new AcceptableValueRange<float>(1f, 30f)));
|
||||
PurpleRainHealAmount = config.Bind(purpleRain, "Ally Heal Amount", 40f,
|
||||
new ConfigDescription("Flat heal applied to every ally hit.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
new ConfigDescription("Flat heal applied to you and to every ally hit.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
PurpleRainPoisonDamage = config.Bind(purpleRain, "Enemy Poison Damage", 40f,
|
||||
new ConfigDescription("Flat poison damage applied to every enemy hit.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
|
||||
const string bonemass = "Trenta - Bonemass";
|
||||
SwimStaminaRegen = config.Bind(bonemass, "Swim Stamina Regen", 0.1f,
|
||||
new ConfigDescription("Share of the normal stamina regen kept while swimming, from Bonemass on. The game stops regen in water entirely, so an empty Trenta used to drown even though swimming is free. 0 is the game's behaviour.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
|
||||
const string lastStand = "Trenta - Last Stand & Thorns";
|
||||
LastStandMaxArmorBonus = config.Bind(lastStand, "Last Stand Max Armor Bonus", 0.5f,
|
||||
new ConfigDescription("Armor multiplier bonus at near-zero health, tier 5+ (0.5 = +50%). Scales down to 0 at full health.", new AcceptableValueRange<float>(0f, 3f)));
|
||||
|
|
|
|||
|
|
@ -496,6 +496,51 @@ namespace RacesOfValheim
|
|||
hitData.SetAttacker(attacker);
|
||||
|
||||
target.Damage(hitData);
|
||||
FormMelee.GrantAdrenaline(target);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The hidden human does not fight under the Muspell. Every other form already had these
|
||||
/// (see Fenrir's BlockPlayerLogicAttackPatch); the Muspell had none, so each stomp and spike
|
||||
/// also swung the weapon in hand, and the Elder clone's own CharacterAnimEvent fired the held
|
||||
/// bow or crossbow through OnAttackTrigger on top of that: a tester's bow shot several times a
|
||||
/// swing. Right Mouse is the spike and the Block button at once, so the guard is cleared too,
|
||||
/// as BlockPlayerGuardPatch does it.
|
||||
/// </summary>
|
||||
internal static class TrentaMuspellAttackBlock
|
||||
{
|
||||
private static bool LocalInForm(Character character) =>
|
||||
TrentaMuspell.IsTransformed && character != null && character == Player.m_localPlayer;
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), nameof(Humanoid.StartAttack))]
|
||||
public static class Trenta_MuspellBlockNativeAttack_Patch
|
||||
{
|
||||
public static bool Prefix(Humanoid __instance) => !LocalInForm(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "PlayerAttackInput")]
|
||||
public static class Trenta_MuspellBlockAttackInput_Patch
|
||||
{
|
||||
public static bool Prefix(Player __instance) => !LocalInForm(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), nameof(Humanoid.OnAttackTrigger))]
|
||||
public static class Trenta_MuspellBlockAttackTrigger_Patch
|
||||
{
|
||||
public static bool Prefix(Humanoid __instance) => !LocalInForm(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.SetControls))]
|
||||
public static class Trenta_MuspellBlockGuard_Patch
|
||||
{
|
||||
private static readonly AccessTools.FieldRef<Character, bool> Blocking =
|
||||
AccessTools.FieldRefAccess<Character, bool>("m_blocking");
|
||||
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
if (LocalInForm(__instance)) Blocking(__instance) = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,44 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A trickle of stamina regen while swimming, for a Bonemass-tier Trenta. Vanilla's
|
||||
/// Player.UpdateStats stops regen outright while swimming off the ground, and drowning starts
|
||||
/// at 0 stamina, so the free stroke above was not enough: a Trenta who went in empty never
|
||||
/// got a point back and drowned in water it swims for free. The same formula vanilla uses on
|
||||
/// land, times Swim Stamina Regen (slow on purpose).
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "UpdateStats", new[] { typeof(float) })]
|
||||
public static class Trenta_Player_SwimStaminaRegen_Patch
|
||||
{
|
||||
private static readonly AccessTools.FieldRef<Player, float> RegenTimer =
|
||||
AccessTools.FieldRefAccess<Player, float>("m_staminaRegenTimer");
|
||||
|
||||
public static void Postfix(Player __instance, float dt)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer || !TrentaRace.IsTrenta()) return;
|
||||
if (BossProgressionManager.GetCurrentProgressionState() < TrentaConfig.BonemassDefeatedState) return;
|
||||
|
||||
// Only where vanilla held regen at zero for the water alone.
|
||||
if (!__instance.IsSwimming() || __instance.IsOnGround()) return;
|
||||
if (__instance.InAttack() || __instance.InDodge() || __instance.IsEncumbered()) return;
|
||||
|
||||
float share = TrentaConfigManagement.SwimStaminaRegen.Value;
|
||||
if (share <= 0f || RegenTimer(__instance) > 0f) return;
|
||||
|
||||
float max = __instance.GetMaxStamina();
|
||||
float stamina = __instance.GetStamina();
|
||||
if (max <= 0f || stamina >= max) return;
|
||||
|
||||
float regen = __instance.m_staminaRegen +
|
||||
(1f - stamina / max) * __instance.m_staminaRegen * __instance.m_staminaRegenTimeMultiplier;
|
||||
float multiplier = 1f;
|
||||
__instance.GetSEMan().ModifyStaminaRegen(ref multiplier);
|
||||
|
||||
__instance.AddStamina(regen * multiplier * share * dt * Game.m_staminaRegenRate);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Blocks the Wet status effect from ever landing on a Bonemass-tier Trenta.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> TrueFormTrollDamageShare;
|
||||
public static ConfigEntry<float> TrueFormAttackReach;
|
||||
public static ConfigEntry<bool> TrueFormSlamCrater;
|
||||
public static ConfigEntry<float> TrueFormPunchStamina;
|
||||
public static ConfigEntry<float> TrueFormSlamStamina;
|
||||
public static ConfigEntry<float> TrueFormLogSwingStamina;
|
||||
public static ConfigEntry<float> TrueFormLogOverheadStamina;
|
||||
|
||||
// ─── Log Weapon (tier 7+) ──────────────────────────────────────────────
|
||||
public static ConfigEntry<float> LogWeaponMaxDurability;
|
||||
|
|
@ -87,7 +91,7 @@ namespace RacesOfValheim
|
|||
TrueFormKey = config.Bind(keybinds, "True Form", new KeyboardShortcut(KeyCode.H),
|
||||
new ConfigDescription("Transform into (or revert from) True Form, tier 5+."));
|
||||
GrabLogKey = config.Bind(keybinds, "Grab Log", new KeyboardShortcut(KeyCode.E),
|
||||
new ConfigDescription("Grabs a felled log as a weapon while looking at one, tier 7+ and already in True Form. Matches vanilla's own interact key rather than reusing the True Form key a second time."));
|
||||
new ConfigDescription("Grabs a felled log as a weapon while looking at one, tier 7+ and already in True Form. The game's own Use key (gamepad included) always grabs too; this is an extra key on top of it."));
|
||||
|
||||
const string combat = "Trol - Passive Combat";
|
||||
FireWeaknessMultiplier = config.Bind(combat, "Fire Weakness Multiplier", 1.5f,
|
||||
|
|
@ -149,6 +153,19 @@ namespace RacesOfValheim
|
|||
TrueFormSlamCrater = config.Bind(trueForm, "Ground Slam Crater", true,
|
||||
new ConfigDescription("The ground slam digs into the ground where it lands, like a pickaxe blow. Never inside a ward you have no access to."));
|
||||
|
||||
// Priced by the troll's own damage (punch and side log swing 60 blunt, slam and overhead
|
||||
// log 70), with the slam dearer because it hits all around: vanilla charges a sledge about
|
||||
// twice a mace for similar damage. An iron mace swing costs 10, an iron sledge 20.
|
||||
const string staminaNote = " Base stamina, cut by up to a third with the Clubs skill as a club's is. 0 makes it free.";
|
||||
TrueFormPunchStamina = config.Bind(trueForm, "Punch Stamina", 10f,
|
||||
new ConfigDescription("Stamina for the punch (Left Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
|
||||
TrueFormSlamStamina = config.Bind(trueForm, "Ground Slam Stamina", 18f,
|
||||
new ConfigDescription("Stamina for the ground slam (Middle Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
|
||||
TrueFormLogSwingStamina = config.Bind(trueForm, "Log Swing Stamina", 10f,
|
||||
new ConfigDescription("Stamina for the side swing with a log in hand (Left Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
|
||||
TrueFormLogOverheadStamina = config.Bind(trueForm, "Log Overhead Stamina", 12f,
|
||||
new ConfigDescription("Stamina for the overhead swing with a log in hand (Middle Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
|
||||
|
||||
const string logWeapon = "Trol - Log Weapon";
|
||||
LogWeaponMaxDurability = config.Bind(logWeapon, "Max Durability", 6f,
|
||||
new ConfigDescription("Hits a grabbed log weapon survives before breaking, tier 7+.", new AcceptableValueRange<float>(1f, 50f)));
|
||||
|
|
|
|||
|
|
@ -8,11 +8,18 @@ namespace RacesOfValheim
|
|||
{
|
||||
public static class TrolLogWeapon
|
||||
{
|
||||
// Two readers can ask for the same press: the game's own Use (Trol_LogGrabInteract_Patch)
|
||||
// and the Grab Log key, which is E by default like Use. The second one in the same press
|
||||
// would only say the troll already holds a log.
|
||||
private const float GrabDebounce = 0.5f;
|
||||
private static float lastGrabTime = -100f;
|
||||
|
||||
public static void GrabLog(Humanoid user, TreeLog logTarget)
|
||||
{
|
||||
if (user == null || logTarget == null) return;
|
||||
if (!TrolRace.IsTrol()) return;
|
||||
if (BossProgressionManager.GetCurrentProgressionState() < 7) return;
|
||||
if (Time.time - lastGrabTime < GrabDebounce) return;
|
||||
|
||||
var seman = user.GetSEMan();
|
||||
if (seman == null) return;
|
||||
|
|
@ -107,6 +114,8 @@ namespace RacesOfValheim
|
|||
{
|
||||
UnityEngine.Object.Destroy(logTarget.gameObject);
|
||||
}
|
||||
|
||||
lastGrabTime = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,8 +145,37 @@ namespace RacesOfValheim
|
|||
ItemDrop.ItemData rightItem = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field<ItemDrop.ItemData>("m_rightItem").Value;
|
||||
if (rightItem != null && rightItem.m_dropPrefab != null && rightItem.m_dropPrefab.name.StartsWith("TrolWeapon_")) return;
|
||||
|
||||
string key = TrolConfig.GrabLogKey.Value.MainKey.ToString();
|
||||
__result += ModText.Get("rov_hover_trol_grab_log", key);
|
||||
// The game's Use key, which ModText resolves to the pad's own button on a gamepad. The
|
||||
// Grab Log key still works, but only Use reaches every device.
|
||||
__result += ModText.Get("rov_hover_trol_grab_log");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grab Log on the game's own Use, keyboard and gamepad alike, the way the Aswid's Dominate
|
||||
/// works. Dominate is an Interactable, so vanilla's Player.Interact finds it; a log carries
|
||||
/// only HoverText, which is not one, so Use on a log did nothing and the Grab Log key (read
|
||||
/// off the keyboard) was the only way in. A pad had none.
|
||||
///
|
||||
/// Taken over only for a True Form Trol at tier 7+, who is the one shown the prompt; anyone
|
||||
/// else's Use on a log goes on to vanilla, which does nothing with it.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "Interact")]
|
||||
public static class Trol_LogGrabInteract_Patch
|
||||
{
|
||||
public static bool Prefix(Player __instance, GameObject go, bool hold)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer || go == null || !TrolRace.IsTrol()) return true;
|
||||
if (BossProgressionManager.GetCurrentProgressionState() < 7) return true;
|
||||
if (!__instance.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) return true;
|
||||
if (__instance.InAttack() || __instance.InDodge()) return true;
|
||||
|
||||
TreeLog log = go.GetComponentInParent<TreeLog>();
|
||||
if (log == null) return true;
|
||||
|
||||
// Holding Use repeats the call every frame: one press, one grab.
|
||||
if (!hold) TrolLogWeapon.GrabLog(__instance, log);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,20 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>What a swing costs, by the button pressed. Until these existed every troll
|
||||
/// blow was free.</summary>
|
||||
private static float StaminaFor(TrolTrueFormModel.AttackKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case TrolTrueFormModel.AttackKind.Punch: return TrolConfig.TrueFormPunchStamina.Value;
|
||||
case TrolTrueFormModel.AttackKind.Slam: return TrolConfig.TrueFormSlamStamina.Value;
|
||||
case TrolTrueFormModel.AttackKind.LogSwingH: return TrolConfig.TrueFormLogSwingStamina.Value;
|
||||
case TrolTrueFormModel.AttackKind.LogSwingV: return TrolConfig.TrueFormLogOverheadStamina.Value;
|
||||
default: return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void Play(TrolTrueFormModel.AttackKind kind)
|
||||
{
|
||||
TrolTrueFormModel.Profile profile = TrolTrueFormModel.Get(kind);
|
||||
|
|
@ -150,6 +164,7 @@ namespace RacesOfValheim
|
|||
if (profile == null && kind == TrolTrueFormModel.AttackKind.LogSwingH) profile = TrolTrueFormModel.Get(TrolTrueFormModel.AttackKind.Punch);
|
||||
if (profile == null && kind == TrolTrueFormModel.AttackKind.LogSwingV) profile = TrolTrueFormModel.Get(TrolTrueFormModel.AttackKind.Slam);
|
||||
if (profile == null) return;
|
||||
if (!FormMelee.TrySpendStamina(Player.m_localPlayer, StaminaFor(kind), Skills.SkillType.Clubs)) return;
|
||||
|
||||
bool log = kind == TrolTrueFormModel.AttackKind.LogSwingH || kind == TrolTrueFormModel.AttackKind.LogSwingV;
|
||||
// The slam goes by what the key means, not by the troll's attack type: troll_groundslam
|
||||
|
|
@ -196,7 +211,7 @@ namespace RacesOfValheim
|
|||
yield return null;
|
||||
}
|
||||
|
||||
if (player != null && !player.IsDead())
|
||||
if (player != null && !player.IsDead() && !FormStagger.AttackInterrupted)
|
||||
{
|
||||
float scale = transform.localScale.x;
|
||||
int landed;
|
||||
|
|
@ -337,6 +352,7 @@ namespace RacesOfValheim
|
|||
aoe.m_hitOwner = false;
|
||||
aoe.m_hitProps = true;
|
||||
aoe.m_radius = Mathf.Max(aoe.m_radius, range * 0.6f);
|
||||
instance.AddComponent<TrolSlamAoe>();
|
||||
aoe.Setup(player, player.transform.forward, -1f, hitData, null, null);
|
||||
spawned = true;
|
||||
}
|
||||
|
|
@ -429,6 +445,7 @@ namespace RacesOfValheim
|
|||
if (targetObj != null) done.Add(targetObj);
|
||||
FormMelee.LogHit(FormLabel, target, damage.GetTotalDamage());
|
||||
target.Damage(hitData);
|
||||
FormMelee.GrantAdrenaline(target);
|
||||
profile.Shared.m_hitEffect.Create(targetCenter, Quaternion.identity);
|
||||
landed++;
|
||||
}
|
||||
|
|
@ -437,6 +454,25 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Marks the Aoe a True Form slam spawned, so its hits can be told apart from a
|
||||
/// real troll's.</summary>
|
||||
internal class TrolSlamAoe : MonoBehaviour { }
|
||||
|
||||
/// <summary>
|
||||
/// Adrenaline for each creature the slam's Aoe lands on. Vanilla gives it inside Attack, and
|
||||
/// an Aoe set up by hand never goes through one (FormMelee.GrantAdrenaline says why the sweeps
|
||||
/// needed the same).
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Aoe), "OnHit")]
|
||||
public static class Trol_SlamAoeAdrenaline_Patch
|
||||
{
|
||||
public static void Postfix(Aoe __instance, Collider collider, bool __result)
|
||||
{
|
||||
if (!__result || collider == null || __instance.GetComponent<TrolSlamAoe>() == null) return;
|
||||
FormMelee.GrantAdrenaline(collider.GetComponentInParent<Character>());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The troll every other client sees. RemoteFenrirAnimator in shape: legs from the remote
|
||||
/// player's own Animator, which ZSyncAnimation keeps fed over the network, and attacks replayed
|
||||
|
|
|
|||
|
|
@ -127,11 +127,10 @@ namespace RacesOfValheim
|
|||
vis.SetHairItem(0);
|
||||
vis.SetBeardItem(0);
|
||||
|
||||
// Hide Helmet
|
||||
// Hide Helmet, unless its owner chose to show it
|
||||
if (SkeletonConfig.BodyModelEnabled.Value)
|
||||
{
|
||||
var helmetObj = HarmonyLib.Traverse.Create(vis).Field<GameObject>("m_helmetItemInstance").Value;
|
||||
SkeletonVisuals.SetEquipmentPieceHidden(helmetObj, true);
|
||||
SkeletonVisuals.FitHelmet(m_player, vis, SkeletonVisuals.ShowsHelmet(m_player));
|
||||
}
|
||||
|
||||
// Scale Body Armor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue