feat(aswid): bat form waits until 2.5 s after the last hit
An Aswid could take wing in the middle of a fight. Taking bat form is now refused until Combat Lock seconds (default 2.5, 0 turns it off) after the local player last lost health. Health is compared around Character.ApplyDamage, so direct hits and fire, poison and bleeding ticks all count, and a fully blocked or absorbed hit does not. Turning back from bat form is never blocked.
This commit is contained in:
parent
4c7e0ec16d
commit
71721caa8d
6 changed files with 39 additions and 0 deletions
|
|
@ -118,6 +118,27 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notes when the local player last lost health, for the bat's combat lock. ApplyDamage is the
|
||||
/// one final stage for direct hits, burning, poison and bleeding, so comparing health around it
|
||||
/// catches them all, and a hit fully blocked or absorbed (Alfar shield, Heimkall) is no hurt.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage",
|
||||
new[] { typeof(HitData), typeof(bool), typeof(bool), typeof(HitData.DamageModifier) })]
|
||||
public static class Aswid_BatCombatLock_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, ref float __state)
|
||||
{
|
||||
__state = __instance == Player.m_localPlayer ? __instance.GetHealth() : -1f;
|
||||
}
|
||||
|
||||
public static void Postfix(Character __instance, float __state)
|
||||
{
|
||||
if (__state < 0f) return;
|
||||
if (__instance.GetHealth() < __state) AswidRace.LastHurtTime = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sleepers. UpdateSleep picks the closest player itself, possibly a remote bat, so the counter
|
||||
/// goes up for the whole call and the bat test happens in the IsDebugFlying postfix, which only
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue