fix(aswid): make the Vampiric Aura land, and run it passively in every form #9
1 changed files with 31 additions and 63 deletions
|
|
@ -170,9 +170,6 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsChanneling { get; private set; } = false;
|
|
||||||
private float channelDamageTimer = 0f;
|
|
||||||
|
|
||||||
private float m_tintCheckTimer = 0f;
|
private float m_tintCheckTimer = 0f;
|
||||||
private float sensesCheckTimer = 0f;
|
private float sensesCheckTimer = 0f;
|
||||||
|
|
||||||
|
|
@ -306,7 +303,7 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead() || !IsAswid())
|
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead() || !IsAswid())
|
||||||
{
|
{
|
||||||
if (IsChanneling) StopChanneling();
|
damageTickTimer = 0f;
|
||||||
wasNight = null; // reset so it triggers correctly on spawn/respawn
|
wasNight = null; // reset so it triggers correctly on spawn/respawn
|
||||||
if (Player.m_localPlayer != null) AswidSpectralClaw.PurgeAll(Player.m_localPlayer); // feature disabled for now, see AswidSpectralClaw.cs
|
if (Player.m_localPlayer != null) AswidSpectralClaw.PurgeAll(Player.m_localPlayer); // feature disabled for now, see AswidSpectralClaw.cs
|
||||||
return;
|
return;
|
||||||
|
|
@ -357,11 +354,11 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HandleChanneling();
|
HandleVampiricAura();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Jotunn.Logger.LogError($"[Aswid] Error in HandleChanneling: {ex}");
|
Jotunn.Logger.LogError($"[Aswid] Error in HandleVampiricAura: {ex}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTransformingSequence) return;
|
if (isTransformingSequence) return;
|
||||||
|
|
@ -396,8 +393,11 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto revert mist form at sunrise
|
// Auto revert mist form at sunrise. The isTransformingSequence guard matters: without it
|
||||||
if (EnvMan.instance != null && EnvMan.IsDay() && Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
// this fires again on every frame of the one-second revert, stacking a new coroutine each
|
||||||
|
// time, and they all fight over the same visuals and status effect.
|
||||||
|
if (EnvMan.instance != null && EnvMan.IsDay() && !isTransformingSequence &&
|
||||||
|
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertMistFormRoutine());
|
StartCoroutine(RevertMistFormRoutine());
|
||||||
}
|
}
|
||||||
|
|
@ -816,57 +816,27 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
private float damageTickTimer = 0f;
|
private float damageTickTimer = 0f;
|
||||||
|
|
||||||
private void StopChanneling()
|
/// <summary>
|
||||||
|
/// The Vampiric Aura is passive: it drains on its own, in every form, with no key to hold and
|
||||||
|
/// no icon or message of its own. The form only decides how hard it bites.
|
||||||
|
/// </summary>
|
||||||
|
private void HandleVampiricAura()
|
||||||
{
|
{
|
||||||
if (!IsChanneling) return;
|
damageTickTimer += Time.deltaTime;
|
||||||
IsChanneling = false;
|
if (damageTickTimer < 0.25f) return;
|
||||||
channelDamageTimer = 0f;
|
|
||||||
damageTickTimer = 0f;
|
damageTickTimer = 0f;
|
||||||
|
PerformLifeDrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleChanneling()
|
/// <summary>Half damage as a human, full as a bat, double as mist.</summary>
|
||||||
|
private float GetAuraFormMultiplier()
|
||||||
{
|
{
|
||||||
bool hasMistForm = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode());
|
SEMan seman = Player.m_localPlayer.GetSEMan();
|
||||||
bool hasBatForm = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_BatForm".GetStableHashCode());
|
|
||||||
|
|
||||||
if (Player.m_localPlayer.IsBlocking() && (hasMistForm || hasBatForm))
|
if (seman.HaveStatusEffect("SE_MistForm".GetStableHashCode())) return 2f;
|
||||||
{
|
if (seman.HaveStatusEffect("SE_BatForm".GetStableHashCode())) return 1f;
|
||||||
if (!IsChanneling)
|
return 0.5f;
|
||||||
{
|
|
||||||
IsChanneling = true;
|
|
||||||
if (mistTransformation != null)
|
|
||||||
{
|
|
||||||
var anim = mistTransformation.GetComponentInChildren<Animator>();
|
|
||||||
if (anim != null) anim.SetBool("alert", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
channelDamageTimer += Time.deltaTime;
|
|
||||||
damageTickTimer += Time.deltaTime;
|
|
||||||
|
|
||||||
if (channelDamageTimer >= 0.25f)
|
|
||||||
{
|
|
||||||
channelDamageTimer = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (damageTickTimer >= 0.25f)
|
|
||||||
{
|
|
||||||
damageTickTimer = 0f;
|
|
||||||
PerformLifeDrain();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (IsChanneling)
|
|
||||||
{
|
|
||||||
StopChanneling();
|
|
||||||
if (mistTransformation != null)
|
|
||||||
{
|
|
||||||
var anim = mistTransformation.GetComponentInChildren<Animator>();
|
|
||||||
if (anim != null) anim.SetBool("alert", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PerformLifeDrain()
|
private void PerformLifeDrain()
|
||||||
|
|
@ -882,8 +852,6 @@ namespace RacesOfValheim
|
||||||
int layerMask = LayerMask.GetMask("character", "character_net", "character_ghost");
|
int layerMask = LayerMask.GetMask("character", "character_net", "character_ghost");
|
||||||
var colliders = Physics.OverlapSphere(center, radius, layerMask);
|
var colliders = Physics.OverlapSphere(center, radius, layerMask);
|
||||||
|
|
||||||
bool hitAnything = false;
|
|
||||||
|
|
||||||
foreach (var col in colliders)
|
foreach (var col in colliders)
|
||||||
{
|
{
|
||||||
Character c = col.GetComponentInParent<Character>();
|
Character c = col.GetComponentInParent<Character>();
|
||||||
|
|
@ -894,19 +862,13 @@ namespace RacesOfValheim
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hitAnything = true;
|
|
||||||
float maxHp = c.GetMaxHealth();
|
float maxHp = c.GetMaxHealth();
|
||||||
float currentHp = c.GetHealth();
|
float currentHp = c.GetHealth();
|
||||||
|
|
||||||
float baseDamage = 1.0f;
|
float baseDamage = 1.0f;
|
||||||
float bloodMagicFactor = Player.m_localPlayer.GetSkillFactor(Skills.SkillType.BloodMagic);
|
float bloodMagicFactor = Player.m_localPlayer.GetSkillFactor(Skills.SkillType.BloodMagic);
|
||||||
// Lo scaling aggiunge un massimo di +5.0 danni (al livello 100), indipendentemente dal danno base
|
// Lo scaling aggiunge un massimo di +5.0 danni (al livello 100), indipendentemente dal danno base
|
||||||
float totalDamage = baseDamage + bloodMagicFactor * 5f;
|
float totalDamage = (baseDamage + bloodMagicFactor * 5f) * GetAuraFormMultiplier();
|
||||||
|
|
||||||
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
|
||||||
{
|
|
||||||
totalDamage *= 2.0f; // Damage doubled in Mist Form
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss())
|
if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss())
|
||||||
{
|
{
|
||||||
|
|
@ -917,8 +879,14 @@ namespace RacesOfValheim
|
||||||
HitData hd = new HitData();
|
HitData hd = new HitData();
|
||||||
hd.m_damage.m_damage = totalDamage;
|
hd.m_damage.m_damage = totalDamage;
|
||||||
hd.m_point = c.GetCenterPoint();
|
hd.m_point = c.GetCenterPoint();
|
||||||
|
hd.m_dir = (c.GetCenterPoint() - center).normalized;
|
||||||
hd.m_attacker = Player.m_localPlayer.GetZDOID();
|
hd.m_attacker = Player.m_localPlayer.GetZDOID();
|
||||||
c.ApplyDamage(hd, true, false);
|
|
||||||
|
// Damage() sends RPC_Damage to whoever owns the target, so the hit lands for
|
||||||
|
// everyone and still runs our Character.Damage patches (lifesteal, devour on
|
||||||
|
// kill). ApplyDamage() skipped all of that: it edited the local copy of a
|
||||||
|
// character we usually do not own, and the owner overwrote it on the next sync.
|
||||||
|
c.Damage(hd);
|
||||||
|
|
||||||
SpawnBloodVFX(c);
|
SpawnBloodVFX(c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue