115 lines
5.3 KiB
C#
115 lines
5.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// The Seeker Brute's three real damage profiles - a trigger name and a set of real damage
|
|
/// numbers, read once from the Brute's own weapons and cached. Nothing is cloned, registered
|
|
/// or equipped.
|
|
///
|
|
/// THIS REPLACES A WHOLE FILE (SvermRavagerWeapons.cs) THAT TRIED TO EQUIP THE REAL ITEMS AND
|
|
/// LET VALHEIM'S OWN Attack.Start RUN. It fought the game at every turn: Humanoid.
|
|
/// GetCurrentBlocker routed right-click into a parry because the source items were
|
|
/// m_blockable; player.InAttack() stopped rooting the player before the visible clip on the
|
|
/// model had actually finished; wiring a working secondary attack meant cloning and mutating
|
|
/// Attack objects by hand. None of that is necessary, because this mod already has two
|
|
/// working examples of "become a creature and attack" - FenrirBehaviors.cs and
|
|
/// DrakeFormBehavior.cs - and NEITHER of them equips anything. A trigger on the model's own
|
|
/// Animator plus a timed Physics.OverlapSphere, the same two calls every other transformation
|
|
/// in this mod already uses, is the whole mechanism. See RavagerFormBehavior.AttackRoutine.
|
|
/// </summary>
|
|
public static class SvermRavagerAttacks
|
|
{
|
|
public struct Profile
|
|
{
|
|
public string Trigger;
|
|
public HitData.DamageTypes Damage;
|
|
|
|
/// <summary>The Brute weapon itself, for its swing (m_triggerEffect) and impact
|
|
/// (m_hitEffect) sounds. Vanilla plays both inside Attack, which this form never runs,
|
|
/// so without them every hit landed silent. Null if the weapon was missing.</summary>
|
|
public ItemDrop.ItemData.SharedData Shared;
|
|
|
|
/// <summary>The weapon's own push (m_attackForce), tool tier and swing arc, the way
|
|
/// TrolTrueFormModel.Profile carries the troll's.</summary>
|
|
public float PushForce;
|
|
public int ToolTier;
|
|
public float Angle;
|
|
}
|
|
|
|
/// <summary>
|
|
/// One blow's damage: the Brute's, times Ravager Attack Damage, times the Unarmed skill
|
|
/// factor the way a weapon's skill scales it (0.25-0.55 at level 0, 0.85-1 at 100).
|
|
/// TrolTrueFormModel.DamageFor does the same with Clubs for the troll.
|
|
/// </summary>
|
|
public static HitData.DamageTypes DamageFor(Player player, Profile profile)
|
|
{
|
|
HitData.DamageTypes damage = profile.Damage.Clone();
|
|
damage.Modify(SvermConfigManagement.RavagerDamageShare * player.GetRandomSkillFactor(Skills.SkillType.Unarmed));
|
|
return damage;
|
|
}
|
|
|
|
private static Profile bite;
|
|
private static Profile ram;
|
|
private static Profile slam;
|
|
private static Profile taunt;
|
|
private static bool read;
|
|
|
|
public static Profile Bite { get { EnsureRead(); return bite; } }
|
|
public static Profile Ram { get { EnsureRead(); return ram; } }
|
|
public static Profile Slam { get { EnsureRead(); return slam; } }
|
|
|
|
/// <summary>
|
|
/// type=None on the real Brute, so its Attack fields (range/angle/hitbox) were never
|
|
/// meant to land a hit - only m_attackAnimation and m_damages are trustworthy here, which
|
|
/// is why the taunt is handled by its own AoE routine rather than folded into
|
|
/// AttackRoutine's forward-swing shape.
|
|
/// </summary>
|
|
public static Profile Taunt { get { EnsureRead(); return taunt; } }
|
|
|
|
private static void EnsureRead()
|
|
{
|
|
if (read) return;
|
|
read = true;
|
|
|
|
bite = ReadOne(SvermConfig.RavagerBiteWeapon);
|
|
ram = ReadOne(SvermConfig.RavagerRamWeapon);
|
|
slam = ReadOne(SvermConfig.RavagerSlamWeapon);
|
|
taunt = ReadOne(SvermConfig.RavagerTauntWeapon);
|
|
}
|
|
|
|
private static Profile ReadOne(string sourcePrefabName)
|
|
{
|
|
GameObject source = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(sourcePrefabName);
|
|
ItemDrop drop = source != null ? source.GetComponent<ItemDrop>() : null;
|
|
ItemDrop.ItemData.SharedData shared = drop != null ? drop.m_itemData?.m_shared : null;
|
|
|
|
if (shared == null)
|
|
{
|
|
Jotunn.Logger.LogWarning($"[Sverm] No '{sourcePrefabName}' to read Ravager Strain damage " +
|
|
"from; that attack will land for nothing.");
|
|
return default;
|
|
}
|
|
|
|
Profile profile = new Profile
|
|
{
|
|
Trigger = shared.m_attack != null ? (shared.m_attack.m_attackAnimation ?? "") : "",
|
|
Damage = shared.m_damages,
|
|
Shared = shared,
|
|
PushForce = shared.m_attackForce,
|
|
ToolTier = shared.m_toolTier,
|
|
Angle = shared.m_attack != null ? shared.m_attack.m_attackAngle : 90f,
|
|
};
|
|
|
|
Jotunn.Logger.LogInfo($"[Sverm] Ravager Strain reads '{profile.Trigger}' off '{sourcePrefabName}' - " +
|
|
$"{DumpDamage(profile.Damage)}.");
|
|
return profile;
|
|
}
|
|
|
|
private static string DumpDamage(HitData.DamageTypes d)
|
|
{
|
|
return $"blunt={d.m_blunt:0.#} slash={d.m_slash:0.#} pierce={d.m_pierce:0.#} " +
|
|
$"chop={d.m_chop:0.#} pickaxe={d.m_pickaxe:0.#}";
|
|
}
|
|
}
|
|
}
|