An audit of all 59 prefab names the mod resolves, against the game's own
asset manifests, found nine that are not in Valheim at all. A name vanilla
does not use has no vanilla candidate to beat in Jotunn's name cache, so it
is a free slot for whoever ships one - which is how another mod's weapon
trail became the Skeleton's fire aura in 00d4fd6.
Eight of the nine failed in silence, which is why none of them was ever
reported:
vfx_corpse_destruction -> _medium, _large for the Muspell. The puff that
covers a transformation. Fenrir and Skadi at least had their sparks;
the Muspell swapped bodies in plain view with nothing at all.
vfx_surtling_death -> vfx_wraith_death for the Aswid's Mist Form,
which reads as mist by construction and is the same creature the form
already borrows its Visual from; vfx_corpse_destruction_medium for the
thrall, where nothing is misty. Vanilla has no surtling death effect
under any spelling.
TrophyTroll -> TrophyForestTroll.
TrophyBat -> TrophyDeathsquito. Vanilla ships no bat trophy,
so the Aswid's two status effects and its radial entry had no icon.
vfx_smoke -> gone. It was the Trenta's fallback for Purple
Rain's particle material behind Greydwarf_Shaman, and the day the
Shaman failed to resolve it would have worn whatever a mod supplies.
Purple Rain is purple by design, so nobody would ever have reported it.
The ninth did not fail in silence. vfx_OozeHit was passed to Instantiate
unguarded, so every successful Draugh parry threw ArgumentException and took
the North Wind nova below it down as well. It is vfx_blob_hit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
166 lines
6.3 KiB
C#
166 lines
6.3 KiB
C#
using UnityEngine;
|
|
using System;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
public class AswidThrall : MonoBehaviour, Interactable, Hoverable
|
|
{
|
|
private Character m_character;
|
|
private MonsterAI m_ai;
|
|
private ZNetView m_nview;
|
|
private bool m_wasEnslaved = false;
|
|
private bool m_wasConsumed = false;
|
|
|
|
private void Awake()
|
|
{
|
|
m_character = GetComponent<Character>();
|
|
m_ai = GetComponent<MonsterAI>();
|
|
m_nview = GetComponent<ZNetView>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (m_nview == null || !m_nview.IsValid()) return;
|
|
|
|
bool isEnslaved = m_nview.GetZDO().GetBool("AswidEnslaved", false);
|
|
if (isEnslaved)
|
|
{
|
|
if (!m_wasEnslaved)
|
|
{
|
|
m_wasEnslaved = true;
|
|
m_character.SetTamed(true); // Ensure tamed is true on client side if it missed the RPC
|
|
|
|
if (m_ai != null)
|
|
{
|
|
// Custom AI behaviors can be set here if needed
|
|
}
|
|
}
|
|
|
|
// If it dies, the local player who owns it tries to consume it
|
|
if (m_character.IsDead() && !m_wasConsumed)
|
|
{
|
|
m_wasConsumed = true;
|
|
if (m_nview.IsOwner() && AswidRace.IsAswid())
|
|
{
|
|
AswidRace.TryConsumeMob(m_character, m_character.GetMaxHealth());
|
|
}
|
|
}
|
|
|
|
// Only the ZDO owner should track lifetime to kill it
|
|
if (m_nview.IsOwner())
|
|
{
|
|
long enslaveTime = m_nview.GetZDO().GetLong("AswidEnslaveTime", 0);
|
|
if (enslaveTime > 0)
|
|
{
|
|
DateTime time = new DateTime(enslaveTime);
|
|
if ((DateTime.Now - time).TotalSeconds >= AswidConfig.ThrallLifetime.Value)
|
|
{
|
|
// Time's up! Kill the thrall.
|
|
HitData hit = new HitData();
|
|
hit.m_damage.m_damage = 99999f;
|
|
hit.m_hitType = HitData.HitType.Undefined;
|
|
m_character.ApplyDamage(hit, true, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool Interact(Humanoid user, bool hold, bool alt)
|
|
{
|
|
if (hold || alt) return false;
|
|
if (m_nview == null || !m_nview.IsValid()) return false;
|
|
if (user != Player.m_localPlayer || !AswidRace.IsAswid()) return false;
|
|
|
|
bool isEnslaved = m_nview.GetZDO().GetBool("AswidEnslaved", false);
|
|
if (isEnslaved)
|
|
{
|
|
// Toggle follow/stay
|
|
if (m_ai != null)
|
|
{
|
|
if (m_ai.GetFollowTarget() == user.gameObject)
|
|
{
|
|
m_ai.SetFollowTarget(null);
|
|
user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} is staying.");
|
|
}
|
|
else
|
|
{
|
|
m_ai.SetFollowTarget(user.gameObject);
|
|
user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} is following.");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Enslave action
|
|
if (BossProgressionManager.GetCurrentProgressionState() < 6) return false;
|
|
|
|
float cooldown = AswidRace.GetEnslaveCooldown();
|
|
if (cooldown > 0)
|
|
{
|
|
user.Message(MessageHud.MessageType.Center, $"Dominate on cooldown ({Mathf.CeilToInt(cooldown / 60f)}m {Mathf.CeilToInt(cooldown % 60f)}s)");
|
|
return false;
|
|
}
|
|
|
|
// Enslave it!
|
|
AswidRace.StartEnslaveCooldown();
|
|
|
|
// Take ownership to set ZDO vars reliably
|
|
m_nview.ClaimOwnership();
|
|
|
|
m_nview.GetZDO().Set("AswidEnslaved", true);
|
|
m_nview.GetZDO().Set("AswidEnslaveTime", DateTime.Now.Ticks);
|
|
m_character.SetTamed(true);
|
|
|
|
if (m_ai != null)
|
|
{
|
|
m_ai.SetFollowTarget(user.gameObject);
|
|
}
|
|
|
|
// "vfx_surtling_death" was asked for here and is not a prefab in this game, so dominating
|
|
// a creature happened with no effect at all. The generic body-sized puff, rather than the
|
|
// Wraith's mist the Mist Form wears: nothing about domination is misty.
|
|
GameObject vfx = ZNetScene.instance.GetPrefab("vfx_corpse_destruction_medium");
|
|
if (vfx) Instantiate(vfx, m_character.transform.position, Quaternion.identity);
|
|
|
|
user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} dominated!");
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool UseItem(Humanoid user, ItemDrop.ItemData item)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public string GetHoverText()
|
|
{
|
|
if (m_nview == null || !m_nview.IsValid()) return "";
|
|
if (Player.m_localPlayer == null || !AswidRace.IsAswid()) return "";
|
|
|
|
bool isEnslaved = m_nview.GetZDO().GetBool("AswidEnslaved", false);
|
|
if (isEnslaved)
|
|
{
|
|
bool following = m_ai != null && m_ai.GetFollowTarget() != null;
|
|
return following ? "[<color=yellow><b>E</b></color>] Stay" : "[<color=yellow><b>E</b></color>] Follow";
|
|
}
|
|
else
|
|
{
|
|
if (BossProgressionManager.GetCurrentProgressionState() < 6) return "";
|
|
|
|
float cd = AswidRace.GetEnslaveCooldown();
|
|
if (cd > 0) return $"[<color=red>E</color>] Dominate (Cooldown: {Mathf.CeilToInt(cd / 60f)}m)";
|
|
return "[<color=yellow><b>E</b></color>] Dominate";
|
|
}
|
|
}
|
|
|
|
// New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
|
|
// serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
|
|
public float GetHoverOffset() => 0f;
|
|
|
|
public string GetHoverName()
|
|
{
|
|
return ""; // Character component already provides the name
|
|
}
|
|
}
|
|
}
|