Merge branch 'localisation' into localisation-turkish
This commit is contained in:
commit
240a4356b4
18 changed files with 377 additions and 107 deletions
|
|
@ -105,6 +105,10 @@ namespace RacesOfValheim
|
|||
|
||||
BaseAI ai = prefab.GetComponent<BaseAI>();
|
||||
if (ai != null) ai.m_randomMoveRange = 5f;
|
||||
// A flyer's MoveTo lifts its goal to m_flyAltitudeMin above whatever solid is under it,
|
||||
// the rock top included: at the vanilla height the miners hovered over a deposit out of
|
||||
// reach and never struck.
|
||||
if (ai != null && miner) { ai.m_flyAltitudeMin = 0.5f; ai.m_flyAltitudeMax = 2f; }
|
||||
|
||||
foreach (CharacterDrop drops in prefab.GetComponentsInChildren<CharacterDrop>(true))
|
||||
{
|
||||
|
|
@ -251,9 +255,18 @@ namespace RacesOfValheim
|
|||
public float Radius = 12f;
|
||||
public float LiveSeconds = 120f;
|
||||
|
||||
private const float Reach = 4f;
|
||||
|
||||
private float born;
|
||||
private float nextStrike;
|
||||
private Component target;
|
||||
private float lastDistance = -1f;
|
||||
private int strikes;
|
||||
|
||||
public static readonly List<AlfarMiner> All = new List<AlfarMiner>();
|
||||
|
||||
private void OnEnable() { All.Add(this); }
|
||||
private void OnDisable() { All.Remove(this); }
|
||||
|
||||
private static readonly System.Reflection.MethodInfo MoveToMethod =
|
||||
AccessTools.Method(typeof(BaseAI), "MoveTo", new[] { typeof(float), typeof(Vector3), typeof(float), typeof(bool) });
|
||||
|
|
@ -281,8 +294,9 @@ namespace RacesOfValheim
|
|||
// sits at its base inside the mesh, so a drone aiming there stopped on top of the rock
|
||||
// and never came within reach.
|
||||
float distance = Vector3.Distance(transform.position, point);
|
||||
lastDistance = distance;
|
||||
|
||||
if (distance > 3.5f)
|
||||
if (distance > Reach)
|
||||
{
|
||||
if (MoveToMethod != null) MoveToMethod.Invoke(ai, new object[] { dt, point + Vector3.up * 1.5f, 2f, true });
|
||||
return true;
|
||||
|
|
@ -292,14 +306,29 @@ namespace RacesOfValheim
|
|||
if (Time.time < nextStrike) return true;
|
||||
nextStrike = Time.time + 1f;
|
||||
Strike(target, area, point);
|
||||
strikes++;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string[] names;
|
||||
private static string[] Deposits => names ?? (names = AlfarNexusConfig.MinerDeposits.Value.Split(
|
||||
new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries));
|
||||
private static string namesSource;
|
||||
|
||||
private bool IsPrecious(string prefabName)
|
||||
// Read again when the config line changes, so an edit in game counts without a restart.
|
||||
private static string[] Deposits
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = AlfarNexusConfig.MinerDeposits.Value;
|
||||
if (names == null || namesSource != value)
|
||||
{
|
||||
namesSource = value;
|
||||
names = value.Split(new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsPrecious(string prefabName)
|
||||
{
|
||||
foreach (string wanted in Deposits)
|
||||
{
|
||||
|
|
@ -314,9 +343,7 @@ namespace RacesOfValheim
|
|||
float bestDistance = float.MaxValue;
|
||||
foreach (Collider collider in Physics.OverlapSphere(Centre, Radius, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
Component deposit = collider.GetComponentInParent<MineRock5>();
|
||||
if (deposit == null) deposit = collider.GetComponentInParent<MineRock>();
|
||||
if (deposit == null) deposit = collider.GetComponentInParent<Destructible>();
|
||||
Component deposit = DepositOf(collider);
|
||||
if (deposit == null) continue;
|
||||
|
||||
string prefabName = Utils.GetPrefabName(deposit.gameObject);
|
||||
|
|
@ -372,6 +399,47 @@ namespace RacesOfValheim
|
|||
destructible.Damage(hit);
|
||||
}
|
||||
|
||||
private static Component DepositOf(Collider collider)
|
||||
{
|
||||
Component deposit = collider.GetComponentInParent<MineRock5>();
|
||||
if (deposit == null) deposit = collider.GetComponentInParent<MineRock>();
|
||||
if (deposit == null) deposit = collider.GetComponentInParent<Destructible>();
|
||||
return deposit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// F8 readout: what the camera looks at (is it a deposit, of which kind, on the list?) and
|
||||
/// what each live miner is doing (its target, how far, how many strikes).
|
||||
/// </summary>
|
||||
public static void DebugReport(Player player)
|
||||
{
|
||||
var lines = new List<string>();
|
||||
Transform aim = GameCamera.instance != null ? GameCamera.instance.transform : player.transform;
|
||||
if (Physics.Raycast(aim.position, aim.forward, out RaycastHit hit, 50f, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
Component deposit = DepositOf(hit.collider);
|
||||
string prefabName = deposit != null ? Utils.GetPrefabName(deposit.gameObject) : Utils.GetPrefabName(hit.collider.transform.root.gameObject);
|
||||
lines.Add($"[RoV graf] look: {hit.collider.name} on {prefabName} " +
|
||||
(deposit != null ? $"{deposit.GetType().Name} listed={IsPrecious(prefabName)}" : "not a deposit"));
|
||||
}
|
||||
else lines.Add("[RoV graf] look: nothing within 50m");
|
||||
|
||||
foreach (AlfarMiner miner in All)
|
||||
{
|
||||
if (miner == null) continue;
|
||||
string targetName = miner.target != null ? Utils.GetPrefabName(miner.target.gameObject) : "none";
|
||||
lines.Add($"[RoV graf] miner {Vector3.Distance(miner.transform.position, player.transform.position):0}m away: " +
|
||||
$"target {targetName} dist {miner.lastDistance:0.0} strikes {miner.strikes} " +
|
||||
$"age {Time.time - miner.born:0}s centre {miner.Centre} r {miner.Radius:0}");
|
||||
}
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
Debug.Log(line);
|
||||
player.Message(MessageHud.MessageType.TopLeft, line);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MonsterAI), "UpdateAI")]
|
||||
public static class Alfar_Miner_UpdateAI_Patch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,11 +6,22 @@ namespace RacesOfValheim
|
|||
/// <summary>
|
||||
/// Whether a player is a bat, on any client.
|
||||
///
|
||||
/// This file used to be AswidBatAggro: while the bat flew on vanilla's debug-fly flag, vanilla
|
||||
/// read that flag as "this player is not really here" - no monster could see, hear or wake for
|
||||
/// it, and every hit on it was dropped - and six patches here lied about the flag in exactly
|
||||
/// those places. The bat now flies on m_flying (DirectedFlight.cs), which vanilla's AI and
|
||||
/// damage never look at, so monsters notice and hurt it with no help, and the lie went.
|
||||
/// Stamina Flight flies on m_flying (DirectedFlight.cs), which vanilla's AI and damage never
|
||||
/// look at, so monsters notice and hurt that bat with no help.
|
||||
///
|
||||
/// Free Flight flies on vanilla's debug-fly flag, and vanilla reads that flag as "this player
|
||||
/// is not really here". Six places, read out of assembly_valheim:
|
||||
///
|
||||
/// BaseAI.CanHearTarget, BaseAI.CanSeeTarget and BaseAI's HuntPlayer fallback ask
|
||||
/// Player.InDebugFlyMode() and drop the player.
|
||||
/// MonsterAI.UpdateSleep asks IsDebugFlying() and will not wake, twice over.
|
||||
/// Character.ApplyDamage and Character.RPC_Damage ask IsDebugFlying() and drop the hit.
|
||||
///
|
||||
/// The patches below keep the flag (it IS the flight) and lie about it in exactly those
|
||||
/// places, for bats only. InDebugFlyMode() is forced false flat: those three AI paths are its
|
||||
/// only callers. IsDebugFlying() cannot be: Character.UpdateMotion reads it to hold the bat in
|
||||
/// the air, so it reads false only while the call stack is inside one of the methods that push
|
||||
/// the counter. The patches were removed with the old flight in v1.6.1 and came back with it.
|
||||
/// </summary>
|
||||
public static class AswidBatForm
|
||||
{
|
||||
|
|
@ -22,6 +33,14 @@ namespace RacesOfValheim
|
|||
|
||||
private static readonly int BatFormHash = "SE_BatForm".GetStableHashCode();
|
||||
|
||||
// How deep we are inside vanilla calls that must not see the debug-fly flag. A counter,
|
||||
// not a bool: ApplyDamage runs inside RPC_Damage, so the frames nest.
|
||||
private static int unmaskDepth;
|
||||
|
||||
public static bool Unmasked => unmaskDepth > 0;
|
||||
public static void PushUnmask() { unmaskDepth++; }
|
||||
public static void PopUnmask() { if (unmaskDepth > 0) unmaskDepth--; }
|
||||
|
||||
/// <summary>
|
||||
/// The ZDO first and the status effect only as a fallback: the ZDO is the one that is true
|
||||
/// on every client, and the status effect covers the local player during the frames of the
|
||||
|
|
@ -40,6 +59,77 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Free Flight: monsters see and hear a bat. See AswidBatForm for why this one is safe flat.</summary>
|
||||
[HarmonyPatch(typeof(Player), "InDebugFlyMode")]
|
||||
public static class Aswid_BatIsVisibleToAI_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance, ref bool __result)
|
||||
{
|
||||
if (__result && AswidBatForm.IsBat(__instance)) __result = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The scoped half: false only inside the methods that push the counter, so flight, motion,
|
||||
/// the camera and UpdateStats still read the flag as true.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "IsDebugFlying")]
|
||||
public static class Aswid_BatIsDebugFlying_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance, ref bool __result)
|
||||
{
|
||||
if (!__result || !AswidBatForm.Unmasked) return;
|
||||
if (AswidBatForm.IsBat(__instance)) __result = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A hit landing on a free-flying bat. Finalizer rather than Postfix: the counter has to come
|
||||
/// down even when the method throws, and a void Finalizer leaves the exception alone.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage")]
|
||||
public static class Aswid_BatTakesDamage_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, ref bool __state)
|
||||
{
|
||||
__state = __instance is Player player && AswidBatForm.IsBat(player);
|
||||
if (__state) AswidBatForm.PushUnmask();
|
||||
}
|
||||
|
||||
public static void Finalizer(bool __state)
|
||||
{
|
||||
if (__state) AswidBatForm.PopUnmask();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The networked half of the same thing: a hit sent by another machine.</summary>
|
||||
[HarmonyPatch(typeof(Character), "RPC_Damage")]
|
||||
public static class Aswid_BatTakesRemoteDamage_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, ref bool __state)
|
||||
{
|
||||
__state = __instance is Player player && AswidBatForm.IsBat(player);
|
||||
if (__state) AswidBatForm.PushUnmask();
|
||||
}
|
||||
|
||||
public static void Finalizer(bool __state)
|
||||
{
|
||||
if (__state) AswidBatForm.PopUnmask();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// runs its test for a player already debug flying.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(MonsterAI), "UpdateSleep")]
|
||||
public static class Aswid_BatWakesSleepers_Patch
|
||||
{
|
||||
public static void Prefix() { AswidBatForm.PushUnmask(); }
|
||||
public static void Finalizer() { AswidBatForm.PopUnmask(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The revert path cannot handle a bat that dies: AswidRace.Update() returns early on IsDead(),
|
||||
/// so the coroutine that takes the form down never starts. The flight flag would stay on and
|
||||
|
|
|
|||
|
|
@ -74,8 +74,24 @@ namespace RacesOfValheim
|
|||
// The bat flies on the same directed flight as the Skadi's drakes (DirectedFlight.cs),
|
||||
// with its own numbers. It used to fly on vanilla's debug-fly flag: 50 m/s, free, blind
|
||||
// to carry weight, and ignored by every monster until AswidBatAggro lied to six vanilla
|
||||
// methods about it. None of that is left.
|
||||
// methods about it. The old flight came back as Free Flight, for players who want it
|
||||
// (building tall); AswidBatForm holds the aggro patches it needs.
|
||||
public enum EncumberedMode { Allowed, Blocked }
|
||||
public enum BatFlightRuleMode { PlayerChoice, AlwaysStaminaFlight, AlwaysFreeFlight }
|
||||
|
||||
public static ConfigEntry<bool> FreeBatFlight;
|
||||
public static ConfigEntry<BatFlightRuleMode> BatFlightRule;
|
||||
|
||||
/// <summary>Which flight a bat taken now gets: the server's rule first, then the player's own pick.</summary>
|
||||
public static bool UsesFreeBatFlight()
|
||||
{
|
||||
switch (BatFlightRule.Value)
|
||||
{
|
||||
case BatFlightRuleMode.AlwaysStaminaFlight: return false;
|
||||
case BatFlightRuleMode.AlwaysFreeFlight: return true;
|
||||
default: return FreeBatFlight.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigEntry<float> BatTurnSpeed;
|
||||
public static ConfigEntry<float> BatGlideSpeed;
|
||||
|
|
@ -240,6 +256,10 @@ namespace RacesOfValheim
|
|||
new ConfigDescription("How far the camera rolls. 1 is about 4 degrees. Local.", new AcceptableValueRange<float>(0f, 3f)));
|
||||
|
||||
const string batform = "Aswid - Bat Form";
|
||||
FreeBatFlight = config.Bind(batform, "Free Bat Flight", false,
|
||||
new ConfigDescription("Off: Stamina Flight, the settings below. On: the old Free Flight, up to 50 m/s with no stamina cost and no weight limit; Jump rises, Left Ctrl sinks. Your own choice, unless the server's Bat Flight Rule forces one. Takes effect the next time you become a bat."));
|
||||
BatFlightRule = config.Bind(batform, "Bat Flight Rule", BatFlightRuleMode.PlayerChoice,
|
||||
new ConfigDescription("Server rule. PlayerChoice: each player's Free Bat Flight setting decides. AlwaysStaminaFlight / AlwaysFreeFlight: every bat flies that way. On a server only the host's or the server's value counts."));
|
||||
// Same controls as the Skadi's drake: aim with the camera, W beats forward, Shift
|
||||
// sprints, S beats backwards, and letting go hovers briefly before gliding down.
|
||||
BatTurnSpeed = config.Bind(batform, "Turn Speed", 180f,
|
||||
|
|
|
|||
|
|
@ -329,9 +329,6 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
private float m_tintCheckTimer = 0f;
|
||||
private float sensesCheckTimer = 0f;
|
||||
|
||||
private Dictionary<Character, GameObject> activeSensesLight = new Dictionary<Character, GameObject>();
|
||||
|
||||
public static float GetEnslaveCooldown()
|
||||
{
|
||||
|
|
@ -373,6 +370,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
seman.RemoveStatusEffect(myHash);
|
||||
}
|
||||
HunterSenses.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -381,64 +379,8 @@ namespace RacesOfValheim
|
|||
seman.AddStatusEffect(myHash, true);
|
||||
}
|
||||
|
||||
sensesCheckTimer -= Time.deltaTime;
|
||||
if (sensesCheckTimer <= 0f)
|
||||
{
|
||||
sensesCheckTimer = AswidConfig.SensesRefreshInterval.Value; // TTL is 2s
|
||||
|
||||
List<Character> allChars = Character.GetAllCharacters();
|
||||
Vector3 myPos = Player.m_localPlayer.transform.position;
|
||||
|
||||
int markHash = "SE_AswidSensesMark".GetStableHashCode();
|
||||
HashSet<Character> inRangeChars = new HashSet<Character>();
|
||||
|
||||
foreach (var c in allChars)
|
||||
{
|
||||
if (c == null || c == Player.m_localPlayer || c.IsDead() || c.IsTamed()) continue;
|
||||
|
||||
float dist = Vector3.Distance(c.transform.position, myPos);
|
||||
if (dist <= AswidConfig.SensesRadius.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
inRangeChars.Add(c);
|
||||
c.GetSEMan().AddStatusEffect(markHash, true); // Keep the malus as requested
|
||||
|
||||
// Locally generate the visual
|
||||
if (!activeSensesLight.ContainsKey(c))
|
||||
{
|
||||
GameObject lightObj = new GameObject("AswidSensesLight");
|
||||
lightObj.transform.SetParent(c.transform);
|
||||
lightObj.transform.position = c.GetCenterPoint();
|
||||
|
||||
Light pLight = lightObj.AddComponent<Light>();
|
||||
pLight.type = LightType.Point;
|
||||
pLight.color = Color.green;
|
||||
pLight.range = AswidConfig.SensesLightRange.Value;
|
||||
pLight.intensity = AswidConfig.SensesLightIntensity.Value;
|
||||
pLight.shadows = LightShadows.None;
|
||||
|
||||
activeSensesLight[c] = lightObj;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Jotunn.Logger.LogError($"[Aswid] Error processing mob {c.name}: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Character> keysToRemove = new List<Character>();
|
||||
foreach (var kvp in activeSensesLight)
|
||||
{
|
||||
if (kvp.Key == null || kvp.Key.IsDead() || !inRangeChars.Contains(kvp.Key))
|
||||
{
|
||||
if (kvp.Value != null) Destroy(kvp.Value);
|
||||
keysToRemove.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
foreach (var k in keysToRemove) activeSensesLight.Remove(k);
|
||||
}
|
||||
int markHash = "SE_AswidSensesMark".GetStableHashCode();
|
||||
HunterSenses.Tick(AswidConfig.SensesRadius.Value, c => c.GetSEMan().AddStatusEffect(markHash, true));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -446,15 +388,6 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
private void ClearSuperhumanSenses()
|
||||
{
|
||||
foreach (var kvp in activeSensesLight)
|
||||
{
|
||||
if (kvp.Value != null) Destroy(kvp.Value);
|
||||
}
|
||||
activeSensesLight.Clear();
|
||||
}
|
||||
|
||||
private bool? wasNight = null;
|
||||
|
||||
private void Update()
|
||||
|
|
|
|||
|
|
@ -14,17 +14,25 @@ namespace RacesOfValheim
|
|||
///
|
||||
/// Other clients learn the bat is airborne from Aswid_IsBatForm in the ZDO, which
|
||||
/// Aswid_MultiplayerVisuals_Patch mirrors into their copy's m_flying.
|
||||
///
|
||||
/// FREE FLIGHT. A player who picks it (or a server that forces it, AswidConfig.UsesFreeBatFlight)
|
||||
/// gets the old flight back: vanilla's debug fly, both halves (the field for the local physics,
|
||||
/// s_debugFly in the ZDO for everyone else), and no DirectedFlight. The mode is read once, when
|
||||
/// the form goes up. AswidBatForm keeps monsters seeing and hurting a free-flying bat.
|
||||
/// </summary>
|
||||
public class BatFormBehavior : MonoBehaviour, IDirectedFlyer
|
||||
{
|
||||
private static readonly System.Reflection.FieldInfo FlyingField =
|
||||
AccessTools.Field(typeof(Character), "m_flying");
|
||||
private static readonly System.Reflection.FieldInfo DebugFlyField =
|
||||
AccessTools.Field(typeof(Player), "m_debugFly");
|
||||
|
||||
private Animator anim;
|
||||
private AswidProgression.FormRules formRules;
|
||||
private float startTime;
|
||||
private bool warnedTooHeavy;
|
||||
private bool expired;
|
||||
private bool free;
|
||||
|
||||
public void Initialize(AswidProgression.FormRules rules)
|
||||
{
|
||||
|
|
@ -73,8 +81,9 @@ namespace RacesOfValheim
|
|||
anim = GetComponentInChildren<Animator>();
|
||||
startTime = Time.time;
|
||||
LastPoweredTime = Time.time;
|
||||
DirectedFlight.Register(this);
|
||||
SetFlying(true);
|
||||
free = AswidConfig.UsesFreeBatFlight();
|
||||
if (!free) DirectedFlight.Register(this);
|
||||
Hold();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
|
@ -85,16 +94,20 @@ namespace RacesOfValheim
|
|||
// Held every frame rather than set once, for the same reason the debug-fly flag was:
|
||||
// anything that clears it mid-form (a vanilla reset, another mod) would drop the bat
|
||||
// into walking with the model still on.
|
||||
SetFlying(true);
|
||||
Hold();
|
||||
|
||||
if (!CanPower && !warnedTooHeavy)
|
||||
// Free Flight ignores weight, so only Stamina Flight warns about it.
|
||||
if (!free)
|
||||
{
|
||||
warnedTooHeavy = true;
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_bat_too_heavy_to_beat"));
|
||||
}
|
||||
else if (CanPower)
|
||||
{
|
||||
warnedTooHeavy = false;
|
||||
if (!CanPower && !warnedTooHeavy)
|
||||
{
|
||||
warnedTooHeavy = true;
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_bat_too_heavy_to_beat"));
|
||||
}
|
||||
else if (CanPower)
|
||||
{
|
||||
warnedTooHeavy = false;
|
||||
}
|
||||
}
|
||||
|
||||
float max = MaxDuration();
|
||||
|
|
@ -120,15 +133,37 @@ namespace RacesOfValheim
|
|||
SetFlying(false);
|
||||
}
|
||||
|
||||
private void Hold()
|
||||
{
|
||||
if (free) SetDebugFly(true);
|
||||
else SetFlying(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The local half of flight. The remote half is the Aswid_IsBatForm ZDO flag AswidRace
|
||||
/// already writes, so there is nothing to replicate here.
|
||||
/// The local half of Stamina Flight. The remote half is the Aswid_IsBatForm ZDO flag
|
||||
/// AswidRace already writes, so there is nothing to replicate here. Turning it off also
|
||||
/// turns debug fly off, so every exit path ends both flights whichever one was up.
|
||||
/// </summary>
|
||||
public static void SetFlying(bool flying)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null || FlyingField == null) return;
|
||||
FlyingField.SetValue(player, flying);
|
||||
if (player == null) return;
|
||||
if (FlyingField != null) FlyingField.SetValue(player, flying);
|
||||
if (!flying) SetDebugFly(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Both halves of debug fly, for Free Flight. The ZDO write every frame is not network
|
||||
/// spam: ZDO.Set returns early when the value is unchanged.
|
||||
/// </summary>
|
||||
private static void SetDebugFly(bool flying)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) return;
|
||||
if (DebugFlyField != null) DebugFlyField.SetValue(player, flying);
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid() && nview.IsOwner()) nview.GetZDO().Set(ZDOVars.s_debugFly, flying);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace RacesOfValheim
|
|||
// Each player picks their own True Form: a player model mod (VRM and the like) breaks
|
||||
// under the troll costume, so a server cannot be allowed to force the costume on.
|
||||
"legacy true form",
|
||||
// The player's own pick of bat flight; the synced Bat Flight Rule can override it.
|
||||
"free bat flight",
|
||||
};
|
||||
|
||||
public static void Apply(ConfigFile config)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> SpeedBonusPerState;
|
||||
public static ConfigEntry<float> JumpBonusPerState;
|
||||
public static ConfigEntry<float> SunSicknessDuration;
|
||||
public static ConfigEntry<float> SensesRadius;
|
||||
|
||||
// ─── Form buffs (applied while transformed) ───────────────────────────
|
||||
public static ConfigEntry<float> FullFormSpeedBonus;
|
||||
|
|
@ -131,6 +132,10 @@ namespace RacesOfValheim
|
|||
SunSicknessDuration = config.Bind(combat, "Sun Sickness Duration", 60f,
|
||||
new ConfigDescription("Seconds of forced human form after being reverted by sunrise.", new AcceptableValueRange<float>(0f, 300f)));
|
||||
|
||||
const string senses = "Fenrir - Superhuman Senses";
|
||||
SensesRadius = config.Bind(senses, "Detection Radius", 100f,
|
||||
new ConfigDescription("Meters within which nearby creatures glow green while you are in any form. The light itself follows the Aswid's Marker Light settings.", new AcceptableValueRange<float>(10f, 300f)));
|
||||
|
||||
const string buffs = "Fenrir - Form Buffs";
|
||||
BindNote(config, buffs, "Note: these values need a relog to take effect.");
|
||||
FullFormSpeedBonus = config.Bind(buffs, "Full Form Speed Bonus", 1.0f,
|
||||
|
|
|
|||
|
|
@ -164,6 +164,10 @@ namespace RacesOfValheim {
|
|||
}
|
||||
}
|
||||
|
||||
// The hunter's senses, shared with the Aswid: every form has them, the human does not.
|
||||
if (isTransformed) HunterSenses.Tick(FenrirConfig.SensesRadius.Value);
|
||||
else HunterSenses.Clear();
|
||||
|
||||
if (!RaceInput.Allowed) return;
|
||||
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
|
|
@ -412,6 +416,7 @@ namespace RacesOfValheim {
|
|||
private IEnumerator RevertToHumanRoutine()
|
||||
{
|
||||
isTransformingSequence = true;
|
||||
HunterSenses.Clear();
|
||||
|
||||
if (currentTransformation != null)
|
||||
{
|
||||
|
|
|
|||
92
JotunnModStub/HunterSenses.cs
Normal file
92
JotunnModStub/HunterSenses.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The hunter's senses the Aswid and the Fenrir share: every untamed creature within a radius
|
||||
/// gets a green light, seen only by the local player. The Aswid has it as a passive from Moder,
|
||||
/// the Fenrir in any of its four forms.
|
||||
///
|
||||
/// The lights are local GameObjects parented to the creature, so nothing goes on the network.
|
||||
/// The light's range and strength are the Aswid's settings; each race brings its own radius.
|
||||
/// </summary>
|
||||
public static class HunterSenses
|
||||
{
|
||||
private static readonly Dictionary<Character, GameObject> lights = new Dictionary<Character, GameObject>();
|
||||
private static float timer;
|
||||
|
||||
/// <summary>
|
||||
/// Called every frame while the senses are on. Sweeps once per refresh interval;
|
||||
/// onSensed runs for each creature in range (the Aswid marks them with its status effect).
|
||||
/// </summary>
|
||||
public static void Tick(float radius, Action<Character> onSensed = null)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) return;
|
||||
|
||||
timer -= Time.deltaTime;
|
||||
if (timer > 0f) return;
|
||||
timer = AswidConfig.SensesRefreshInterval.Value;
|
||||
|
||||
Vector3 myPos = player.transform.position;
|
||||
HashSet<Character> inRange = new HashSet<Character>();
|
||||
|
||||
foreach (Character c in Character.GetAllCharacters())
|
||||
{
|
||||
if (c == null || c == player || c.IsDead() || c.IsTamed()) continue;
|
||||
if (Vector3.Distance(c.transform.position, myPos) > radius) continue;
|
||||
|
||||
try
|
||||
{
|
||||
inRange.Add(c);
|
||||
onSensed?.Invoke(c);
|
||||
|
||||
if (!lights.ContainsKey(c))
|
||||
{
|
||||
GameObject lightObj = new GameObject("AswidSensesLight");
|
||||
lightObj.transform.SetParent(c.transform);
|
||||
lightObj.transform.position = c.GetCenterPoint();
|
||||
|
||||
Light pLight = lightObj.AddComponent<Light>();
|
||||
pLight.type = LightType.Point;
|
||||
pLight.color = Color.green;
|
||||
pLight.range = AswidConfig.SensesLightRange.Value;
|
||||
pLight.intensity = AswidConfig.SensesLightIntensity.Value;
|
||||
pLight.shadows = LightShadows.None;
|
||||
|
||||
lights[c] = lightObj;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Jotunn.Logger.LogError($"[Senses] Error processing mob {c.name}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
List<Character> keysToRemove = new List<Character>();
|
||||
foreach (var kvp in lights)
|
||||
{
|
||||
if (kvp.Key == null || kvp.Key.IsDead() || !inRange.Contains(kvp.Key))
|
||||
{
|
||||
if (kvp.Value != null) UnityEngine.Object.Destroy(kvp.Value);
|
||||
keysToRemove.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
foreach (var k in keysToRemove) lights.Remove(k);
|
||||
}
|
||||
|
||||
/// <summary>Puts every light out, for when the senses end (a form reverts, a tier is lost).</summary>
|
||||
public static void Clear()
|
||||
{
|
||||
if (lights.Count == 0) return;
|
||||
foreach (var kvp in lights)
|
||||
{
|
||||
if (kvp.Value != null) UnityEngine.Object.Destroy(kvp.Value);
|
||||
}
|
||||
lights.Clear();
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds eleven custom playable races (Alfar, 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.6.4",
|
||||
"version_number": "1.6.5",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
|
|
@ -516,9 +516,12 @@ namespace RacesOfValheim
|
|||
if (state >= 2)
|
||||
{
|
||||
sb.AppendLine(ModText.Get("rov_compendium_aswid_bat_form_g_key_night"));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_aswid_bat_flight",
|
||||
AswidConfig.BatPoweredStaminaPerSecond.Value.ToString("0.#"),
|
||||
AswidConfig.BatSprintStaminaPerSecond.Value.ToString("0.#")));
|
||||
if (AswidConfig.UsesFreeBatFlight())
|
||||
sb.AppendLine(ModText.Get("rov_compendium_aswid_bat_free_flight"));
|
||||
else
|
||||
sb.AppendLine(ModText.Get("rov_compendium_aswid_bat_flight",
|
||||
AswidConfig.BatPoweredStaminaPerSecond.Value.ToString("0.#"),
|
||||
AswidConfig.BatSprintStaminaPerSecond.Value.ToString("0.#")));
|
||||
}
|
||||
|
||||
if (state >= 2)
|
||||
|
|
@ -586,7 +589,10 @@ namespace RacesOfValheim
|
|||
sb.AppendLine(ModText.Get("rov_compendium_fenrir_cursed_claws_s_wolf_s", (RaceClawsConfig.DurationSeconds.Value).ToString("0"), (SvermClaws.GetDamagePercent(state) * 100f).ToString("0")));
|
||||
|
||||
if (state >= 3)
|
||||
{
|
||||
sb.AppendLine(ModText.Get("rov_compendium_fenrir_wolf_form_g_key_night"));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_fenrir_senses_in_form", Mathf.RoundToInt(FenrirConfig.SensesRadius.Value)));
|
||||
}
|
||||
|
||||
if (state >= 4)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ namespace RacesOfValheim
|
|||
if (__instance != Player.m_localPlayer || !Input.GetKeyDown(KeyCode.F8)) return;
|
||||
RaceMeleeReach.DebugOn = !RaceMeleeReach.DebugOn;
|
||||
__instance.Message(MessageHud.MessageType.TopLeft, $"[RoV reach] debug {(RaceMeleeReach.DebugOn ? "on" : "off")}");
|
||||
AlfarMiner.DebugReport(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public const string PluginGUID = "com.nandor.racesofvalheim";
|
||||
public const string PluginName = "Races Of Valheim";
|
||||
public const string PluginVersion = "1.6.4";
|
||||
public const string PluginVersion = "1.6.5";
|
||||
|
||||
private readonly Harmony harmony = new Harmony(PluginGUID);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"rov_compendium_aswid_aswid_s_curse": "The Aswid's Curse\n",
|
||||
"rov_compendium_aswid_bat_form_g_key_night": "[Eikthyr Unlock] Bat Form ('G' Key, night only): Take the shape of a bat.\n",
|
||||
"rov_compendium_aswid_bat_flight": "The bat flies where you look: W beats forward for $1 stamina a second, Shift sprints for $2 more, S beats backwards, and letting go holds you still for a moment before you glide down. Out of stamina, you can only glide.\n",
|
||||
"rov_compendium_aswid_bat_free_flight": "Free Flight: the bat flies fast and free, with no stamina cost and no weight limit. Jump rises, Left Ctrl sinks, Shift goes faster.\n",
|
||||
"rov_compendium_aswid_bat_form_now_answers_by": "[The Elder Unlock] Bat Form now answers by day as well as night.\n",
|
||||
"rov_compendium_aswid_benedictus_et_afflictus": "[Base Passive] Benedictus et Afflictus:",
|
||||
"rov_compendium_aswid_claws_beast_s_grows_blackened": "[Base Passive] Claws of the Beast ([K], $1s): Grows blackened claws for a limited time instead of a weapon. Bare-handed blows land at $2% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait, sheathe it and they are back, until the timer runs out and they retract on their own - no slot wasted between casts. They cannot be dropped, traded or stolen while grown - and in bat or mist form you have no hands to hold them with.\n",
|
||||
|
|
@ -93,6 +94,7 @@
|
|||
"rov_compendium_fenrir_fenring_form_h_key_night": "[Moder Unlock] Fenring Form ('H' Key, night only): Stand as a true Fenring - heavy claws and a leaping strike, and the strongest of the four shapes so far.\n",
|
||||
"rov_compendium_fenrir_fenring_form_now_answers_by": "[The Queen Unlock] Fenring Form now answers by day as well as night.\n",
|
||||
"rov_compendium_fenrir_g_now_calls_ulv_form": "[Moder Unlock] 'G' now calls Ulv Form instead of Wolf, and answers by day as well as night.\n",
|
||||
"rov_compendium_fenrir_senses_in_form": "In any form you sense every untamed creature within $1m, marking it with a telltale glow, as the Aswid do.\n",
|
||||
"rov_compendium_fenrir_sunrise_breaks_any_night_bound": "Sunrise breaks any night-bound form early and leaves the beast too tired to change shape again for a short while after.\n",
|
||||
"rov_compendium_fenrir_title": "Fenrir Secrets",
|
||||
"rov_compendium_fenrir_ulv_form_h_key_night": "[Bonemass Unlock] Ulv Form ('H' Key, night only): A heavier wolf shape - stronger bite attacks, still bound to the dark.\n",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"rov_compendium_aswid_aswid_s_curse": "La maledizione degli Aswid\n",
|
||||
"rov_compendium_aswid_bat_form_g_key_night": "[Sblocco Eikthyr] Forma di pipistrello (tasto 'G', solo di notte): prendi la forma di un pipistrello.\n",
|
||||
"rov_compendium_aswid_bat_flight": "Il pipistrello vola dove guardi: W batte le ali in avanti per $1 stamina al secondo, Shift scatta per altri $2, S batte all'indietro, e se lasci tutto resti fermo un attimo prima di planare giù. Senza stamina puoi solo planare.\n",
|
||||
"rov_compendium_aswid_bat_free_flight": "Volo libero: il pipistrello vola veloce e libero, senza costo di stamina e senza limite di peso. Salto sale, Ctrl sinistro scende, Shift va più veloce.\n",
|
||||
"rov_compendium_aswid_bat_form_now_answers_by": "[Sblocco Antico] La forma di pipistrello ora risponde di giorno come di notte.\n",
|
||||
"rov_compendium_aswid_benedictus_et_afflictus": "[Passiva base] Benedictus et Afflictus:",
|
||||
"rov_compendium_aswid_claws_beast_s_grows_blackened": "[Passiva base] Artigli della Bestia ([K], $1s): per un tempo limitato fai crescere artigli anneriti al posto di un'arma. I colpi a mani nude valgono il $2% del peso di un paio adulto, tutto come danno da taglio, e crescono con ogni boss che cade. Sfodera una spada e aspettano, rinfoderala e tornano, finché il tempo non scade e si ritraggono da soli, senza sprecare uno slot tra un uso e l'altro. Mentre sono fuori non possono essere lasciati cadere, scambiati o rubati, e in forma di pipistrello o di nebbia non hai mani per tenerli.\n",
|
||||
|
|
@ -93,6 +94,7 @@
|
|||
"rov_compendium_fenrir_fenring_form_h_key_night": "[Sblocco Moder] Forma di Fenring (tasto 'H', solo di notte): ergiti come un vero Fenring, con artigli pesanti e un attacco in salto, la più forte delle quattro forme finora.\n",
|
||||
"rov_compendium_fenrir_fenring_form_now_answers_by": "[Sblocco Regina] La forma di Fenring ora risponde di giorno come di notte.\n",
|
||||
"rov_compendium_fenrir_g_now_calls_ulv_form": "[Sblocco Moder] 'G' ora richiama la forma di Ulv invece del Lupo, e risponde di giorno come di notte.\n",
|
||||
"rov_compendium_fenrir_senses_in_form": "In qualsiasi forma percepisci ogni creatura non addomesticata entro $1m, e la segni con un bagliore rivelatore, come fanno gli Aswid.\n",
|
||||
"rov_compendium_fenrir_sunrise_breaks_any_night_bound": "L'alba spezza in anticipo ogni forma legata alla notte, e lascia la bestia troppo stanca per cambiare di nuovo forma per un po'.\n",
|
||||
"rov_compendium_fenrir_title": "Segreti dei Fenrir",
|
||||
"rov_compendium_fenrir_ulv_form_h_key_night": "[Sblocco Massa d'ossa] Forma di Ulv (tasto 'H', solo di notte): una forma di lupo più pesante, con morsi più forti, ancora legata al buio.\n",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
"rov_compendium_aswid_aswid_s_curse": "Проклятие Асвида\n",
|
||||
"rov_compendium_aswid_bat_form_g_key_night": "[Награда: Эйктюр] Облик летучей мыши (клавиша «G», только ночью): Примите облик летучей мыши.\n",
|
||||
"rov_compendium_aswid_bat_flight": "Летучая мышь летит туда, куда вы смотрите: W — полет вперед за $1 выносливости в секунду, Shift — рывок еще за $2, S — полет назад, а если отпустить клавиши, вы ненадолго зависаете, а затем планируете вниз. Без выносливости можно только планировать.\n",
|
||||
"rov_compendium_aswid_bat_free_flight": "Свободный полет: летучая мышь летает быстро и свободно, без затрат выносливости и без ограничения веса. Прыжок — вверх, левый Ctrl — вниз, Shift — быстрее.\n",
|
||||
"rov_compendium_aswid_bat_form_now_answers_by": "[Награда: Древний] Облик летучей мыши теперь доступен как ночью, так и днем.\n",
|
||||
"rov_compendium_aswid_benedictus_et_afflictus": "[Базовое пассивное] Benedictus et Afflictus:",
|
||||
"rov_compendium_aswid_claws_beast_s_grows_blackened": "[Базовое пассивное] Когти зверя ([K], $1 с): На ограниченное время отращивает черные когти вместо оружия. Удары кулаками наносят $2% от урона зрелых когтей (полностью рубящий урон), и их сила растет с каждым поверженным боссом. Если достать меч — когти спрячутся, убрать его — вернутся, пока не истечет таймер. Не занимают ячейку экипировки. Их нельзя выбросить, передать или украсть, пока они активны. В облике летучей мыши или тумана когти недоступны, так как у вас нет рук.\n",
|
||||
|
|
@ -93,6 +94,7 @@
|
|||
"rov_compendium_fenrir_fenring_form_h_key_night": "[Награда: Матерь] Облик фенринга (клавиша «H», только ночью): Станьте истинным Фенрингом — тяжелые когти, сокрушительный удар в прыжке и мощнейшая из четырех форм на данный момент.\n",
|
||||
"rov_compendium_fenrir_fenring_form_now_answers_by": "[Награда: Королева] Облик фенринга теперь доступен как днем, так и ночью.\n",
|
||||
"rov_compendium_fenrir_g_now_calls_ulv_form": "[Награда: Матерь] Клавиша «G» теперь призывает облик Ульва вместо Волка и доступна и днем, и ночью.\n",
|
||||
"rov_compendium_fenrir_senses_in_form": "В любой форме вы чувствуете любое неприрученное существо в радиусе $1 м, подсвечивая его характерным свечением, как Асвиды.\n",
|
||||
"rov_compendium_fenrir_sunrise_breaks_any_night_bound": "Восход солнца прерывает любую ночную форму раньше срока и оставляет зверя истощенным, не позволяя перевоплощаться еще некоторое время.\n",
|
||||
"rov_compendium_fenrir_title": "Тайны Фенрира",
|
||||
"rov_compendium_fenrir_ulv_form_h_key_night": "[Награда: Масса костей] Облик ульва (клавиша «H», только ночью): Более тяжелая волчья форма — смертоносные укусы, по-прежнему скованные тьмой.\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue