Merge branch 'localisation' into localisation-russian

This commit is contained in:
kanym 2026-10-17 15:51:54 +02:00
commit 7f0133f64b
9 changed files with 141 additions and 7 deletions

View file

@ -1258,7 +1258,8 @@ namespace RacesOfValheim
{
// Show the Vae Victis message in the center of the screen
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_vae_victis"));
Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "$msg_ate " + addedItem.m_shared.m_name);
// "$msg_ate" exists in no vanilla table and players saw [msg_ate]; vanilla's "Consumed" reads the same.
Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "$msg_consumed " + addedItem.m_shared.m_name);
// Vae Victis XP logic - similar to Dead Raiser
Player.m_localPlayer.RaiseSkill(Skills.SkillType.BloodMagic, 1f);

View file

@ -157,7 +157,7 @@ namespace RacesOfValheim
if (CountCoins(inventory) < price)
{
player.Message(MessageHud.MessageType.Center, "$msg_notenoughmoney");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_not_enough_coins"));
return;
}

View file

@ -212,6 +212,14 @@ namespace RacesOfValheim
Character monster = Traverse.Create(__instance).Field<Character>("m_character").Value;
if (monster == null) return;
// A piece an allied race built is never a target, with or without anyone around.
// See FactionPieceTruce.
if (targetStatic.GetValue() is Component target && FactionPieceTruce.Protects(target.gameObject, monster))
{
targetStatic.SetValue(null);
return;
}
foreach (Player player in Player.GetAllPlayers())
{
if (Vector3.Distance(player.transform.position, monster.transform.position) > FactionCheckRange) continue;

View file

@ -0,0 +1,120 @@
using HarmonyLib;
using UnityEngine;
namespace RacesOfValheim
{
/// <summary>
/// Allied mobs leave a race's buildings alone whether or not anyone is home.
///
/// FactionStaticTargetPatch only spares a base while an allied player stands within 100 m of
/// the mob. That left the troll cave bug: a Trol builds a cooking station inside a troll cave,
/// walks out, and the cave's resident Troll - m_attackPlayerObjects is true on its prefab - finds
/// nobody to stop it and smashes the station. The player came back to the materials on the floor.
///
/// So every piece remembers the race of whoever built it (BuilderRaceKey on its ZDO), and an
/// allied mob of that race can neither pick it as a target nor damage it. The damage veto is
/// for the blows meant for something else: a Troll swinging at a Dvergar's wall must not take
/// the Trol's workbench next to it down too. The target veto is what keeps the Troll from
/// standing there forever: it never picks an allied piece, so once the foreign one is gone it
/// has nothing to swing at.
///
/// A piece built before this existed carries no race. It gets one the next time its builder
/// loads it, from Piece.Awake, which runs anyway for every piece in a zone as it loads - so
/// there is no timer and no scan. Until then it is protected only the old way.
/// </summary>
public static class FactionPieceTruce
{
public const string BuilderRaceKey = "RacesOfValheim_BuilderRace";
/// <summary>True if this piece was built by a race whose ally <paramref name="monster"/> is,
/// and the monster holds no grudge against the builder.</summary>
public static bool Protects(GameObject pieceObject, Character monster)
{
if (!FactionsConfig.Hostility || pieceObject == null || monster == null) return false;
if (monster.IsPlayer() || monster.IsTamed()) return false;
ZNetView nview = pieceObject.GetComponentInParent<ZNetView>();
if (nview == null || !nview.IsValid()) return false;
string race = nview.GetZDO().GetString(BuilderRaceKey, "");
if (string.IsNullOrEmpty(race)) return false;
if (!FactionHostilityPatch.IsAlliedMob(race, monster.gameObject.name)) return false;
// A mob fighting the builder right now is no ally of the builder's house either.
long creator = nview.GetZDO().GetLong(ZDOVars.s_creator, 0L);
if (creator != 0L)
{
foreach (Player player in Player.GetAllPlayers())
{
if (player.GetPlayerID() == creator && RaceGrudge.Holds(monster, player)) return false;
}
}
return true;
}
private static void Stamp(ZNetView nview)
{
Player local = Player.m_localPlayer;
if (local == null) return;
string race = FactionHostilityPatch.GetPlayerRace(local);
if (string.IsNullOrEmpty(race)) return;
nview.GetZDO().Set(BuilderRaceKey, race);
}
/// <summary>A new piece: stamped by its builder the moment it is placed.</summary>
[HarmonyPatch(typeof(Piece), nameof(Piece.SetCreator))]
public static class Faction_PieceSetCreator_Patch
{
public static void Postfix(Piece __instance, long uid)
{
if (__instance == null || Player.m_localPlayer == null) return;
if (uid != Player.m_localPlayer.GetPlayerID()) return;
ZNetView nview = __instance.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid() || !nview.IsOwner()) return;
Stamp(nview);
}
}
/// <summary>
/// An old piece: stamped by its builder the first time it loads for them. Only the ZDO's
/// owner writes, as everywhere else in the mod; a piece some other player owns right now
/// gets its race on a later load.
/// </summary>
[HarmonyPatch(typeof(Piece), "Awake")]
public static class Faction_PieceAwake_Patch
{
public static void Postfix(Piece __instance)
{
Player local = Player.m_localPlayer;
if (__instance == null || local == null) return;
ZNetView nview = __instance.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid() || !nview.IsOwner()) return;
ZDO zdo = nview.GetZDO();
if (zdo.GetLong(ZDOVars.s_creator, 0L) != local.GetPlayerID()) return;
if (!string.IsNullOrEmpty(zdo.GetString(BuilderRaceKey, ""))) return;
Stamp(nview);
}
}
/// <summary>
/// Blows from an allied mob land on nothing. Patched on Damage, the attacker's side, where
/// the mob is a live object; RPC_Damage runs on the piece's owner, who may not have it.
/// </summary>
[HarmonyPatch(typeof(WearNTear), nameof(WearNTear.Damage))]
public static class Faction_PieceDamage_Patch
{
public static bool Prefix(WearNTear __instance, HitData hit)
{
if (hit == null) return true;
Character attacker = hit.GetAttacker();
return !Protects(__instance.gameObject, attacker);
}
}
}
}

View file

@ -106,6 +106,7 @@
"rov_msg_fenrir_trough_takes_line_runs_deeper": "The trough takes it. The line runs deeper now.",
"rov_msg_fenrir_wants_meat_any_meat": "It wants meat. Any meat.",
"rov_msg_fenrir_wants_what_yagluth_left_behind": "It wants what Yagluth left behind.",
"rov_msg_not_enough_coins": "Not enough coins",
"rov_msg_skadi_are_drake": "You are a Drake!",
"rov_msg_skadi_are_fader": "You are Fader!",
"rov_msg_skadi_are_moder": "You are Moder!",

View file

@ -106,6 +106,7 @@
"rov_msg_fenrir_trough_takes_line_runs_deeper": "La mangiatoia lo accetta. Ora la discendenza va più a fondo.",
"rov_msg_fenrir_wants_meat_any_meat": "Vuole carne. Qualsiasi carne.",
"rov_msg_fenrir_wants_what_yagluth_left_behind": "Vuole ciò che Yagluth ha lasciato.",
"rov_msg_not_enough_coins": "Monete insufficienti",
"rov_msg_skadi_are_drake": "Sei un Drake!",
"rov_msg_skadi_are_fader": "Sei Fader!",
"rov_msg_skadi_are_moder": "Sei Moder!",

View file

@ -106,6 +106,7 @@
"rov_msg_fenrir_trough_takes_line_runs_deeper": "Кормушка принимает жертву. Родословная стаи крепнет.",
"rov_msg_fenrir_wants_meat_any_meat": "Требуется мясо. Любое мясо.",
"rov_msg_fenrir_wants_what_yagluth_left_behind": "Требуется то, что осталось после падения Яглута.",
"rov_msg_not_enough_coins": "Недостаточно монет",
"rov_msg_skadi_are_drake": "Вы — Дрейк!",
"rov_msg_skadi_are_fader": "Вы — Прародитель!",
"rov_msg_skadi_are_moder": "Вы — Матерь!",

View file

@ -90,7 +90,7 @@ namespace RacesOfValheim
if (f.m_item.m_shared.m_name != item.m_shared.m_name) continue;
if (f.CanEatAgain()) return true;
__instance.Message(MessageHud.MessageType.Center, "$msg_eatanother");
__instance.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_nomore", item.m_shared.m_name));
__result = false;
return false;
}
@ -110,12 +110,12 @@ namespace RacesOfValheim
if (has4 && food4.m_item.m_shared.m_name == item.m_shared.m_name)
{
if (canEat4) { TrolFoodManager.SetExtraFood(__instance, item); ConsumeItemEffect(__instance, item); __result = true; return false; }
else { __instance.Message(MessageHud.MessageType.Center, "$msg_eatanother"); __result = false; return false; }
else { __instance.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_nomore", item.m_shared.m_name)); __result = false; return false; }
}
if (has5 && food5.m_item.m_shared.m_name == item.m_shared.m_name)
{
if (state5 && canEat5) { TrolFoodManager.SetExtraFood5(__instance, item); ConsumeItemEffect(__instance, item); __result = true; return false; }
else { __instance.Message(MessageHud.MessageType.Center, "$msg_eatanother"); __result = false; return false; }
else { __instance.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_nomore", item.m_shared.m_name)); __result = false; return false; }
}
// 3. A free vanilla slot takes it the vanilla way.
@ -137,7 +137,9 @@ namespace RacesOfValheim
return false;
}
__instance.Message(MessageHud.MessageType.Center, "$msg_canteatanymore");
// Vanilla's own "You are full already", the line Player.CanEat shows for a full stomach.
// "$msg_canteatanymore" was never a vanilla token, so players saw [msg_canteatanymore].
__instance.Message(MessageHud.MessageType.Center, "$msg_isfull");
__result = false;
return false;
}

View file

@ -157,7 +157,7 @@ namespace RacesOfValheim
if (CountCoins(inventory) < troop.Price)
{
player.Message(MessageHud.MessageType.Center, "$msg_notenoughmoney");
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_not_enough_coins"));
return;
}