fix(skeleton): Auto-Resurrect on the real deathblow; Summon on Kill toggle

Auto-Resurrect was decided in the Character.Damage prefix on the raw
hit: before armour, blocking and resistances, with poison and fire
counted in full. With good armour it fired on almost any hit. Damage
also runs on the attacker's owner, so on a dedicated server a mob
owned by the server or another player skipped the check entirely. It
now runs in an ApplyDamage prefix, on the victim's own client, against
the damage that is about to land. The rising-from-the-ground immunity
is checked there too.

Summon on Kill gets a toggle key (G, Skeleton - Keybinds) and a
gamepad radial entry. The choice is saved on the character, on by
default. A "Raise the Dead" status icon with the Dead Raiser's
picture shows while it is on. Texts in English, Italian and Russian.
This commit is contained in:
kanym 2026-10-24 15:28:04 +02:00
commit 53f6fb71a2
10 changed files with 158 additions and 35 deletions

View file

@ -48,6 +48,73 @@ namespace RacesOfValheim
resurrectSE.name = "SE_SkeletonResurrectCooldown";
CustomStatusEffect customResurrectSE = new CustomStatusEffect(resurrectSE, fixReference: false);
ItemManager.Instance.AddStatusEffect(customResurrectSE);
// The "Summon on Kill is on" icon. The Dead Raiser's, since the Skeleton trophy is
// already Undead Fortitude's and this is the staff that raises skeletons in vanilla.
var raiseSE = ScriptableObject.CreateInstance<StatusEffect>();
raiseSE.name = RaiseDeadEffectName;
raiseSE.m_name = "$rov_se_skeleton_raisedead_name";
raiseSE.m_tooltip = "$rov_se_skeleton_raisedead_tooltip";
raiseSE.m_icon = PrefabManager.Cache.GetPrefab<ItemDrop>("StaffSkeleton")?.m_itemData.GetIcon()
?? PrefabManager.Cache.GetPrefab<ItemDrop>("TrophySkeleton")?.m_itemData.GetIcon();
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(raiseSE, fixReference: false));
}
// ─── Summon on Kill switch ──────────────────────────────────────────
private const string RaiseDeadEffectName = "SE_SkeletonRaiseDead";
private static readonly int RaiseDeadEffectHash = RaiseDeadEffectName.GetStableHashCode();
// Stored as "off" on the character, so a character that never pressed the key - every
// existing one - keeps the perk on.
private const string SummonOffKey = "RacesOfValheim_SkeletonSummonOff";
/// <summary>Whether this character wants a skeleton raised from each kill. Per character, saved with it.</summary>
public static bool SummonOnKillEnabled
{
get
{
Player player = Player.m_localPlayer;
return player == null || player.m_customData == null || !player.m_customData.ContainsKey(SummonOffKey);
}
set
{
Player player = Player.m_localPlayer;
if (player == null || player.m_customData == null) return;
if (value) player.m_customData.Remove(SummonOffKey);
else player.m_customData[SummonOffKey] = "1";
}
}
/// <summary>
/// The toggle key, and the icon that says the perk is on. The icon is put back whenever it
/// is missing, because status effects do not survive death or a relog.
/// </summary>
private static void TickSummonToggle(Player player, SkeletonProgression.SkeletonRules rules)
{
if (RaceInput.Allowed && SkeletonConfig.SummonToggleKey.Value.IsDownIgnoringHeldKeys())
{
if (!rules.SummonOnKill)
{
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_summon_locked"));
}
else
{
SummonOnKillEnabled = !SummonOnKillEnabled;
player.Message(MessageHud.MessageType.Center,
ModText.Get(SummonOnKillEnabled ? "rov_msg_skeleton_summon_on" : "rov_msg_skeleton_summon_off"));
}
}
SetRaiseDeadIcon(player, rules.SummonOnKill && SummonOnKillEnabled);
}
private static void SetRaiseDeadIcon(Player player, bool on)
{
SEMan seman = player.GetSEMan();
bool has = seman.HaveStatusEffect(RaiseDeadEffectHash);
if (on && !has) seman.AddStatusEffect(RaiseDeadEffectHash, true);
else if (!on && has) seman.RemoveStatusEffect(RaiseDeadEffectHash, true);
}
public static bool IsSkeleton()
@ -272,6 +339,7 @@ namespace RacesOfValheim
SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, false, ref fireAuraVFX);
headFlame.Apply(Player.m_localPlayer, false);
RestoreJawBone();
SetRaiseDeadIcon(Player.m_localPlayer, false);
if (Player.m_localPlayer.transform.localScale != Vector3.one)
{
@ -319,6 +387,8 @@ namespace RacesOfValheim
int state = BossProgressionManager.GetCurrentProgressionState();
var rules = SkeletonProgression.GetRules(state);
TickSummonToggle(Player.m_localPlayer, rules);
// Continuously adjust equipment
VisEquipment currentVis = Player.m_localPlayer.GetComponent<VisEquipment>();
if (currentVis != null)