chore(release): v1.5.5 - Sverm Gjall bombs spare the player and the ticks they hatch are tame
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9a3ab78666
commit
5113225981
5 changed files with 114 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
|
||||
"version_number": "1.5.4",
|
||||
"version_number": "1.5.5",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public const string PluginGUID = "com.nandor.racesofvalheim";
|
||||
public const string PluginName = "Races Of Valheim";
|
||||
public const string PluginVersion = "1.5.4";
|
||||
public const string PluginVersion = "1.5.5";
|
||||
|
||||
private readonly Harmony harmony = new Harmony(PluginGUID);
|
||||
|
||||
|
|
|
|||
102
JotunnModStub/Sverm/SvermGjallPatches.cs
Normal file
102
JotunnModStub/Sverm/SvermGjallPatches.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// What a Sverm Gjall's bombs do once they land: no friendly fire, and the ticks they hatch are ours.
|
||||
///
|
||||
/// Two reports in one. The Gjall's bile bomb is an AOE projectile, and Projectile.DoAOE (read off
|
||||
/// the IL) only spares a victim when m_noDamageFriendly is set on the projectile - the vanilla
|
||||
/// Gjall never needed it, because nothing it fights has friends. Ours has the player, so a bomb
|
||||
/// aimed at a turtle killed the player on a boat beside it. And the ticks the bomb spawns
|
||||
/// (Projectile.SpawnOnHit) are plain wild Ticks, hostile to everyone, the Gjall that threw them
|
||||
/// included.
|
||||
///
|
||||
/// Both are keyed on the projectile's owner being a Sverm troop (a RaisedThrall that answers to the
|
||||
/// Sverm race), so a wild Gjall in the Mistlands behaves exactly as before.
|
||||
/// </summary>
|
||||
public static class SvermGjallPatches
|
||||
{
|
||||
/// <summary>How long a hatched tick lives. Wild ones never despawn, and ours would pile up.</summary>
|
||||
private const float TickLifetime = 45f;
|
||||
|
||||
private static bool IsSvermTroop(Character owner)
|
||||
{
|
||||
if (owner == null) return false;
|
||||
RaisedThrall thrall = owner.GetComponent<RaisedThrall>();
|
||||
return thrall != null && thrall.m_commandingRace == SvermConfig.RaceId;
|
||||
}
|
||||
|
||||
// ── Friendly fire ────────────────────────────────────────────────────
|
||||
|
||||
[HarmonyPatch(typeof(Projectile), nameof(Projectile.Setup))]
|
||||
public static class Sverm_Projectile_Setup_Patch
|
||||
{
|
||||
public static void Postfix(Projectile __instance, Character ___m_owner)
|
||||
{
|
||||
if (IsSvermTroop(___m_owner)) __instance.m_noDamageFriendly = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ── The ticks ────────────────────────────────────────────────────────
|
||||
|
||||
// Characters that came to life while a Sverm projectile was spawning its payload. Awake has
|
||||
// run on every component by the time SpawnOnHit returns, which is when they are tamed.
|
||||
private static bool collecting;
|
||||
private static readonly List<Character> born = new List<Character>();
|
||||
|
||||
[HarmonyPatch(typeof(Projectile), "SpawnOnHit")]
|
||||
public static class Sverm_Projectile_SpawnOnHit_Patch
|
||||
{
|
||||
public static void Prefix(Character ___m_owner)
|
||||
{
|
||||
born.Clear();
|
||||
collecting = IsSvermTroop(___m_owner);
|
||||
}
|
||||
|
||||
public static void Postfix()
|
||||
{
|
||||
collecting = false;
|
||||
|
||||
foreach (Character spawned in born)
|
||||
{
|
||||
if (spawned == null || spawned.IsPlayer() || spawned.IsDead()) continue;
|
||||
|
||||
spawned.SetTamed(true);
|
||||
spawned.gameObject.AddComponent<SvermGjallTickLife>().m_seconds = TickLifetime;
|
||||
}
|
||||
born.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Character), "Awake")]
|
||||
public static class Sverm_Character_Awake_Patch
|
||||
{
|
||||
public static void Postfix(Character __instance)
|
||||
{
|
||||
if (collecting) born.Add(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A tick born of a Sverm Gjall's bomb: tame, and gone after a short while.</summary>
|
||||
public class SvermGjallTickLife : MonoBehaviour
|
||||
{
|
||||
public float m_seconds = 45f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Invoke(nameof(Expire), m_seconds);
|
||||
}
|
||||
|
||||
private void Expire()
|
||||
{
|
||||
ZNetView nview = GetComponent<ZNetView>();
|
||||
if (nview == null || !nview.IsValid() || !nview.IsOwner()) return;
|
||||
|
||||
ZNetScene.instance.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue