fix(forms): Skadi melee hits the training dummy on the clip's hit frame, Ravager attacks get Brute sounds and scale with Unarmed
This commit is contained in:
parent
2d865f5bb0
commit
caaa233392
6 changed files with 223 additions and 41 deletions
|
|
@ -794,7 +794,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (FormStagger.AttackInterrupted) return;
|
||||
if (slam) Slam(profile, radius, leftY, rightY, dropSamples);
|
||||
else ExecuteDamage(profile, radius);
|
||||
else ExecuteDamage(profile, radius, false);
|
||||
}, () =>
|
||||
{
|
||||
if (leftClaw == null || rightClaw == null) return;
|
||||
|
|
@ -828,7 +828,11 @@ namespace RacesOfValheim
|
|||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player != null)
|
||||
ApplyDamageInSphere(player.transform.position + Vector3.up, SvermConfig.RavagerTauntRadius, profile.Damage);
|
||||
{
|
||||
// No Strike: the roar above is the taunt's sound, the weapon's would double it.
|
||||
if (ApplyDamageInSphere(player.transform.position + Vector3.up, SvermConfig.RavagerTauntRadius, profile, true))
|
||||
FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
|
||||
}
|
||||
}, null);
|
||||
|
||||
isAttacking = false;
|
||||
|
|
@ -844,6 +848,11 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (hasForwardSpeed) anim.SetFloat("forward_speed", 0f);
|
||||
|
||||
// The Brute weapon's swing sound, which vanilla plays in Attack.Start (the bite's
|
||||
// snap, the ram's charge, the slam's wind-up). The taunt's weapon has none.
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player != null) profile.Shared?.m_startEffect.Create(player.transform.position, player.transform.rotation, player.transform);
|
||||
|
||||
if (string.IsNullOrEmpty(profile.Trigger) || !knownTriggers.Contains(profile.Trigger)) return false;
|
||||
|
||||
anim.SetTrigger(profile.Trigger);
|
||||
|
|
@ -944,14 +953,14 @@ namespace RacesOfValheim
|
|||
Transform claw = StrikingClaw(leftY, rightY, samples);
|
||||
if (claw == null)
|
||||
{
|
||||
ExecuteDamage(profile, radius);
|
||||
ExecuteDamage(profile, radius, true);
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player != null)
|
||||
DigCrater(player.transform.position + player.transform.forward * SvermConfigManagement.RavagerAttackOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyDamageInSphere(claw.position + Vector3.up * 0.5f, radius, profile.Damage);
|
||||
Strike(claw.position + Vector3.up * 0.5f, radius, profile, true);
|
||||
DigCrater(claw.position);
|
||||
}
|
||||
|
||||
|
|
@ -985,14 +994,14 @@ namespace RacesOfValheim
|
|||
/// FenrirBehaviors.ExecuteClawDamage, unchanged in shape: a sphere swept against the same
|
||||
/// broad layer mask every melee form in this mod already uses.
|
||||
/// </summary>
|
||||
private void ExecuteDamage(SvermRavagerAttacks.Profile profile, float radius)
|
||||
private void ExecuteDamage(SvermRavagerAttacks.Profile profile, float radius, bool slam)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) return;
|
||||
|
||||
float reach = SvermConfigManagement.RavagerAttackOffset;
|
||||
Vector3 attackPoint = player.transform.position + player.transform.forward * reach + Vector3.up;
|
||||
ApplyDamageInSphere(attackPoint, radius, profile.Damage);
|
||||
Strike(attackPoint, radius, profile, slam);
|
||||
}
|
||||
|
||||
private const string CraterPrefab = "digg_v3";
|
||||
|
|
@ -1015,26 +1024,40 @@ namespace RacesOfValheim
|
|||
if (crater != null) Object.Instantiate(crater, ground.point, Quaternion.identity);
|
||||
}
|
||||
|
||||
private const string FormLabel = "Ravager";
|
||||
|
||||
private static readonly int HitMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece",
|
||||
"piece_nonsolid", "terrain", "character", "character_net", "character_ghost",
|
||||
"hitbox", "character_noenv", "vehicle");
|
||||
|
||||
/// <summary>
|
||||
/// The actual sweep, shared by every attack this form has (the three forward swings and
|
||||
/// the taunt's own AoE) - only the sphere's centre and radius differ between them.
|
||||
/// The actual sweep, shared by every attack this form has. TrolTrueFormHit.SphereHit in
|
||||
/// shape: a forward swing stays inside its arc (the Brute's own, widened to 75 degrees each
|
||||
/// side the way the troll's is), the slam's claws and the taunt reach all around, and
|
||||
/// FormMelee.CanReach keeps a blow from landing through a wall. Each target that takes the
|
||||
/// blow plays the Brute weapon's own impact effect, which vanilla plays inside Attack.
|
||||
///
|
||||
/// m_skill is Swords, deliberately NOT Unarmed: Sverm_Damage_Patch rewrites any Unarmed
|
||||
/// hit from a Sverm into the Chitin Claws' own tier damage, and that patch fires for THIS
|
||||
/// call too, since it hooks Character.Damage itself rather than caring who dealt the hit.
|
||||
/// Swords keeps that rewrite from overwriting the Brute's real numbers with the claws'.
|
||||
/// Swords keeps that rewrite from overwriting the Brute's numbers with the claws'. It is
|
||||
/// the Brute weapons' own skill too. The damage still scales with Unarmed (DamageFor).
|
||||
/// </summary>
|
||||
private static void ApplyDamageInSphere(Vector3 center, float radius, HitData.DamageTypes damage)
|
||||
/// <returns>True if the blow landed on a creature, so the caller raises the skill.</returns>
|
||||
private static bool ApplyDamageInSphere(Vector3 center, float radius, SvermRavagerAttacks.Profile profile, bool allAround)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) return;
|
||||
if (player == null) return false;
|
||||
|
||||
int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece",
|
||||
"piece_nonsolid", "terrain", "character", "character_net", "character_ghost",
|
||||
"hitbox", "character_noenv", "vehicle");
|
||||
Vector3 pos = player.transform.position;
|
||||
Vector3 forward = player.transform.forward;
|
||||
float halfAngle = allAround ? 180f : Mathf.Max(75f, profile.Angle * 0.5f);
|
||||
HitData.DamageTypes damage = SvermRavagerAttacks.DamageFor(player, profile);
|
||||
|
||||
Collider[] hits = Physics.OverlapSphere(center, radius, layerMask);
|
||||
Collider[] hits = Physics.OverlapSphere(center, radius, HitMask);
|
||||
FormMelee.LogSwing(FormLabel, hits.Length);
|
||||
var hitObjects = new System.Collections.Generic.HashSet<GameObject>();
|
||||
bool hitCreature = false;
|
||||
|
||||
foreach (Collider hit in hits)
|
||||
{
|
||||
|
|
@ -1042,35 +1065,65 @@ namespace RacesOfValheim
|
|||
if (hit.attachedRigidbody != null && hit.attachedRigidbody.gameObject == player.gameObject) continue;
|
||||
|
||||
IDestructible target = hit.GetComponentInParent<IDestructible>();
|
||||
if (target == null) continue;
|
||||
|
||||
if (target is Character characterTarget && characterTarget == player) continue;
|
||||
if (target == null || (target is Character self && self == player)) continue;
|
||||
|
||||
// Marked only once it is hit, further down, so a limb outside the arc does not rule
|
||||
// out a body squarely in the swing.
|
||||
GameObject targetObj = (target as MonoBehaviour)?.gameObject;
|
||||
if (targetObj != null)
|
||||
{
|
||||
if (hitObjects.Contains(targetObj)) continue;
|
||||
hitObjects.Add(targetObj);
|
||||
}
|
||||
if (targetObj != null && hitObjects.Contains(targetObj)) continue;
|
||||
|
||||
Vector3 targetCenter = hit.bounds.center;
|
||||
Vector3 dirToTarget = (targetCenter - player.transform.position).normalized;
|
||||
Vector3 flat = targetCenter - pos;
|
||||
flat.y = 0f;
|
||||
float angle = flat.sqrMagnitude > 0.0001f ? Vector3.Angle(forward, flat) : 0f;
|
||||
if (angle > halfAngle)
|
||||
{
|
||||
FormMelee.LogMiss(FormLabel, hit, $"outside the swing arc ({angle:0} deg)");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!FormMelee.CanReach(player.GetEyePoint(), center, hit, target, out string cover))
|
||||
{
|
||||
FormMelee.LogMiss(FormLabel, hit, "no clear line, blocked by '" + cover + "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
HitData hitData = new HitData();
|
||||
hitData.m_damage = damage;
|
||||
hitData.m_point = targetCenter;
|
||||
hitData.m_dir = dirToTarget;
|
||||
hitData.m_pushForce = 40f;
|
||||
hitData.m_dir = (targetCenter - pos).normalized;
|
||||
hitData.m_pushForce = profile.PushForce;
|
||||
hitData.m_skill = Skills.SkillType.Swords;
|
||||
hitData.m_dodgeable = true;
|
||||
hitData.m_blockable = true;
|
||||
hitData.m_hitType = HitData.HitType.PlayerHit;
|
||||
hitData.m_toolTier = 100;
|
||||
hitData.m_toolTier = (short)profile.ToolTier;
|
||||
hitData.SetAttacker(player);
|
||||
|
||||
if (targetObj != null) hitObjects.Add(targetObj);
|
||||
FormMelee.LogHit(FormLabel, target, damage.GetTotalDamage());
|
||||
target.Damage(hitData);
|
||||
FormMelee.GrantAdrenaline(target);
|
||||
profile.Shared?.m_hitEffect.Create(targetCenter, Quaternion.identity);
|
||||
if (target is Character) hitCreature = true;
|
||||
}
|
||||
|
||||
return hitCreature;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One blow of a Ravager attack: the Brute weapon's trigger effect (the slam's landing
|
||||
/// thud; the bite and the ram have none), the sweep, and the Unarmed experience vanilla
|
||||
/// pays inside Attack for a swing that reached a creature. The Ravager fights unarmed like
|
||||
/// the rest of the Sverm, so that is the skill it trains.
|
||||
/// </summary>
|
||||
private static void Strike(Vector3 center, float radius, SvermRavagerAttacks.Profile profile, bool allAround)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) return;
|
||||
|
||||
profile.Shared?.m_triggerEffect.Create(center, player.transform.rotation);
|
||||
if (ApplyDamageInSphere(center, radius, profile, allAround)) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue