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>
|
/// <summary>
|
||||||
/// Sleepers. UpdateSleep picks the closest player itself, possibly a remote bat, so the counter
|
/// 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
|
/// goes up for the whole call and the bat test happens in the IsDebugFlying postfix, which only
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ namespace RacesOfValheim
|
||||||
public static ConfigEntry<float> BatMaxDuration;
|
public static ConfigEntry<float> BatMaxDuration;
|
||||||
public static ConfigEntry<float> BatDurationPerState;
|
public static ConfigEntry<float> BatDurationPerState;
|
||||||
public static ConfigEntry<float> BatCooldown;
|
public static ConfigEntry<float> BatCooldown;
|
||||||
|
public static ConfigEntry<float> BatCombatLock;
|
||||||
|
|
||||||
// ─── Vampiric Aura (passive, always active) ──────────────────────────────
|
// ─── Vampiric Aura (passive, always active) ──────────────────────────────
|
||||||
public static ConfigEntry<float> AuraTickInterval;
|
public static ConfigEntry<float> AuraTickInterval;
|
||||||
|
|
@ -292,6 +293,8 @@ namespace RacesOfValheim
|
||||||
new ConfigDescription("Seconds added to the max duration per progression state. Does nothing while the max duration is 0.", new AcceptableValueRange<float>(0f, 600f)));
|
new ConfigDescription("Seconds added to the max duration per progression state. Does nothing while the max duration is 0.", new AcceptableValueRange<float>(0f, 600f)));
|
||||||
BatCooldown = config.Bind(batform, "Cooldown", 0f,
|
BatCooldown = config.Bind(batform, "Cooldown", 0f,
|
||||||
new ConfigDescription("Seconds after leaving bat form before you can take it again. 0 means none.", new AcceptableValueRange<float>(0f, 3600f)));
|
new ConfigDescription("Seconds after leaving bat form before you can take it again. 0 means none.", new AcceptableValueRange<float>(0f, 3600f)));
|
||||||
|
BatCombatLock = config.Bind(batform, "Combat Lock", 2.5f,
|
||||||
|
new ConfigDescription("Seconds after you last lost health (a hit, or a tick of fire, poison or bleeding) before you can take bat form. Turning back from bat form is never blocked. 0 means none.", new AcceptableValueRange<float>(0f, 30f)));
|
||||||
|
|
||||||
const string aura = "Aswid - Vampiric Aura";
|
const string aura = "Aswid - Vampiric Aura";
|
||||||
AuraTickInterval = config.Bind(aura, "Tick Interval", 0.25f,
|
AuraTickInterval = config.Bind(aura, "Tick Interval", 0.25f,
|
||||||
|
|
|
||||||
|
|
@ -615,6 +615,14 @@ namespace RacesOfValheim
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No escaping a fight by taking wing mid-blow: the form waits until the hits stop.
|
||||||
|
float hurtLeft = AswidConfig.BatCombatLock.Value - (Time.time - LastHurtTime);
|
||||||
|
if (hurtLeft > 0f)
|
||||||
|
{
|
||||||
|
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_bat_combat_lock", Mathf.CeilToInt(hurtLeft)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float cooldownLeft = AswidConfig.BatCooldown.Value - (Time.time - lastBatEndTime);
|
float cooldownLeft = AswidConfig.BatCooldown.Value - (Time.time - lastBatEndTime);
|
||||||
if (cooldownLeft > 0f)
|
if (cooldownLeft > 0f)
|
||||||
{
|
{
|
||||||
|
|
@ -629,6 +637,10 @@ namespace RacesOfValheim
|
||||||
// fresh session never begins on cooldown.
|
// fresh session never begins on cooldown.
|
||||||
private float lastBatEndTime = -100000f;
|
private float lastBatEndTime = -100000f;
|
||||||
|
|
||||||
|
// When the local player last lost health, for the bat's combat lock. Written by
|
||||||
|
// Aswid_BatCombatLock_Patch for every race; only the Aswid reads it.
|
||||||
|
public static float LastHurtTime = -100000f;
|
||||||
|
|
||||||
// The one bat or mist routine in flight, if any. Kept so ResetRace can stop it: a
|
// The one bat or mist routine in flight, if any. Kept so ResetRace can stop it: a
|
||||||
// TransformIntoBatRoutine left running through a reset finishes its 1.1s gesture and
|
// TransformIntoBatRoutine left running through a reset finishes its 1.1s gesture and
|
||||||
// turns a freshly reset Human into a bat.
|
// turns a freshly reset Human into a bat.
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
"rov_msg_aswid_vae_victis": "Vae Victis",
|
"rov_msg_aswid_vae_victis": "Vae Victis",
|
||||||
"rov_msg_aswid_what_horrible_night_have_curse": "what a horrible night to have a curse",
|
"rov_msg_aswid_what_horrible_night_have_curse": "what a horrible night to have a curse",
|
||||||
"rov_msg_aswid_bat_cooldown": "Your blood is not ready to take wing again ($1s)",
|
"rov_msg_aswid_bat_cooldown": "Your blood is not ready to take wing again ($1s)",
|
||||||
|
"rov_msg_aswid_bat_combat_lock": "Your blood runs too hot from the fight to take wing ($1s)",
|
||||||
"rov_msg_aswid_bat_form_fades": "The bat form fades",
|
"rov_msg_aswid_bat_form_fades": "The bat form fades",
|
||||||
"rov_msg_aswid_bat_too_heavy_to_beat": "Too heavy to beat your wings. You can only glide",
|
"rov_msg_aswid_bat_too_heavy_to_beat": "Too heavy to beat your wings. You can only glide",
|
||||||
"rov_msg_aswid_too_heavy_for_bat": "You carry too much to take bat form",
|
"rov_msg_aswid_too_heavy_for_bat": "You carry too much to take bat form",
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
"rov_msg_aswid_vae_victis": "Vae Victis",
|
"rov_msg_aswid_vae_victis": "Vae Victis",
|
||||||
"rov_msg_aswid_what_horrible_night_have_curse": "what a horrible night to have a curse",
|
"rov_msg_aswid_what_horrible_night_have_curse": "what a horrible night to have a curse",
|
||||||
"rov_msg_aswid_bat_cooldown": "Il tuo sangue non è pronto a spiccare il volo di nuovo ($1s)",
|
"rov_msg_aswid_bat_cooldown": "Il tuo sangue non è pronto a spiccare il volo di nuovo ($1s)",
|
||||||
|
"rov_msg_aswid_bat_combat_lock": "Il sangue ti ribolle per lo scontro, non puoi spiccare il volo ($1s)",
|
||||||
"rov_msg_aswid_bat_form_fades": "La forma di pipistrello svanisce",
|
"rov_msg_aswid_bat_form_fades": "La forma di pipistrello svanisce",
|
||||||
"rov_msg_aswid_bat_too_heavy_to_beat": "Troppo pesante per battere le ali. Puoi solo planare",
|
"rov_msg_aswid_bat_too_heavy_to_beat": "Troppo pesante per battere le ali. Puoi solo planare",
|
||||||
"rov_msg_aswid_too_heavy_for_bat": "Porti troppo peso per prendere la forma di pipistrello",
|
"rov_msg_aswid_too_heavy_for_bat": "Porti troppo peso per prendere la forma di pipistrello",
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
"rov_msg_aswid_vae_victis": "Vae Victis",
|
"rov_msg_aswid_vae_victis": "Vae Victis",
|
||||||
"rov_msg_aswid_what_horrible_night_have_curse": "Какая ужасная ночь для носителя проклятия...",
|
"rov_msg_aswid_what_horrible_night_have_curse": "Какая ужасная ночь для носителя проклятия...",
|
||||||
"rov_msg_aswid_bat_cooldown": "Ваша кровь еще не готова снова подняться в небо ($1 с)",
|
"rov_msg_aswid_bat_cooldown": "Ваша кровь еще не готова снова подняться в небо ($1 с)",
|
||||||
|
"rov_msg_aswid_bat_combat_lock": "Кровь слишком горяча после схватки, чтобы подняться в небо ($1 с)",
|
||||||
"rov_msg_aswid_bat_form_fades": "Облик летучей мыши рассеивается",
|
"rov_msg_aswid_bat_form_fades": "Облик летучей мыши рассеивается",
|
||||||
"rov_msg_aswid_bat_too_heavy_to_beat": "Слишком тяжело, чтобы махать крыльями. Вы можете только планировать",
|
"rov_msg_aswid_bat_too_heavy_to_beat": "Слишком тяжело, чтобы махать крыльями. Вы можете только планировать",
|
||||||
"rov_msg_aswid_too_heavy_for_bat": "Вы несете слишком много, чтобы принять облик летучей мыши",
|
"rov_msg_aswid_too_heavy_for_bat": "Вы несете слишком много, чтобы принять облик летучей мыши",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue