diff --git a/JotunnModStub/Translations/English/hover.json b/JotunnModStub/Translations/English/hover.json
index 968461e..d4f85c5 100644
--- a/JotunnModStub/Translations/English/hover.json
+++ b/JotunnModStub/Translations/English/hover.json
@@ -45,7 +45,7 @@
"rov_hover_trenta_ready_empty": "ready: $1 $2\n[$KEY_Use] Empty it",
"rov_hover_trenta_rotting_minutes_left": "rotting, $1 minutes left",
"rov_hover_trol_call_warbands": "\n[$KEY_Use] Call the warbands",
- "rov_hover_trol_grab_log": "\n[$1] Grab Log",
+ "rov_hover_trol_grab_log": "\n[$KEY_Use] Grab Log",
"rov_hover_trol_warbands": "warbands $1/$2",
"rov_hover_trol_yagluth_drop_hand_buys_king": "\n(a Yagluth drop in hand buys a king's head, and two more bands)",
"rov_hover_ward_personal": "Personal",
diff --git a/JotunnModStub/Translations/Italian/hover.json b/JotunnModStub/Translations/Italian/hover.json
index 5739dc0..49145ea 100644
--- a/JotunnModStub/Translations/Italian/hover.json
+++ b/JotunnModStub/Translations/Italian/hover.json
@@ -45,7 +45,7 @@
"rov_hover_trenta_ready_empty": "pronto: $1 $2\n[$KEY_Use] Svuotala",
"rov_hover_trenta_rotting_minutes_left": "sta marcendo, mancano $1 minuti",
"rov_hover_trol_call_warbands": "\n[$KEY_Use] Chiama le bande da guerra",
- "rov_hover_trol_grab_log": "\n[$1] Afferra il tronco",
+ "rov_hover_trol_grab_log": "\n[$KEY_Use] Afferra il tronco",
"rov_hover_trol_warbands": "bande da guerra $1/$2",
"rov_hover_trol_yagluth_drop_hand_buys_king": "\n(un bottino di Yagluth in mano compra la testa di un re, e altre due bande)",
"rov_hover_ward_personal": "Personale",
diff --git a/JotunnModStub/Translations/Russian/hover.json b/JotunnModStub/Translations/Russian/hover.json
index 3ebe66d..85965d3 100644
--- a/JotunnModStub/Translations/Russian/hover.json
+++ b/JotunnModStub/Translations/Russian/hover.json
@@ -45,7 +45,7 @@
"rov_hover_trenta_ready_empty": "готово: $1 $2\n[$KEY_Use] Опустошить",
"rov_hover_trenta_rotting_minutes_left": "гниет, осталось $1 мин",
"rov_hover_trol_call_warbands": "\n[$KEY_Use] Созвать боевые дружины",
- "rov_hover_trol_grab_log": "\n[$1] Взять бревно",
+ "rov_hover_trol_grab_log": "\n[$KEY_Use] Взять бревно",
"rov_hover_trol_warbands": "дружины $1/$2",
"rov_hover_trol_yagluth_drop_hand_buys_king": "\n(трофей Яглута в руке позволит насадить голову конунга и нанять еще две дружины)",
"rov_hover_ward_personal": "Личный",
diff --git a/JotunnModStub/Trol/TrolConfig.cs b/JotunnModStub/Trol/TrolConfig.cs
index 5521be7..707f54c 100644
--- a/JotunnModStub/Trol/TrolConfig.cs
+++ b/JotunnModStub/Trol/TrolConfig.cs
@@ -87,7 +87,7 @@ namespace RacesOfValheim
TrueFormKey = config.Bind(keybinds, "True Form", new KeyboardShortcut(KeyCode.H),
new ConfigDescription("Transform into (or revert from) True Form, tier 5+."));
GrabLogKey = config.Bind(keybinds, "Grab Log", new KeyboardShortcut(KeyCode.E),
- new ConfigDescription("Grabs a felled log as a weapon while looking at one, tier 7+ and already in True Form. Matches vanilla's own interact key rather than reusing the True Form key a second time."));
+ new ConfigDescription("Grabs a felled log as a weapon while looking at one, tier 7+ and already in True Form. The game's own Use key (gamepad included) always grabs too; this is an extra key on top of it."));
const string combat = "Trol - Passive Combat";
FireWeaknessMultiplier = config.Bind(combat, "Fire Weakness Multiplier", 1.5f,
diff --git a/JotunnModStub/Trol/TrolLogWeapon.cs b/JotunnModStub/Trol/TrolLogWeapon.cs
index 5480273..46ed511 100644
--- a/JotunnModStub/Trol/TrolLogWeapon.cs
+++ b/JotunnModStub/Trol/TrolLogWeapon.cs
@@ -8,11 +8,18 @@ namespace RacesOfValheim
{
public static class TrolLogWeapon
{
+ // Two readers can ask for the same press: the game's own Use (Trol_LogGrabInteract_Patch)
+ // and the Grab Log key, which is E by default like Use. The second one in the same press
+ // would only say the troll already holds a log.
+ private const float GrabDebounce = 0.5f;
+ private static float lastGrabTime = -100f;
+
public static void GrabLog(Humanoid user, TreeLog logTarget)
{
if (user == null || logTarget == null) return;
if (!TrolRace.IsTrol()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 7) return;
+ if (Time.time - lastGrabTime < GrabDebounce) return;
var seman = user.GetSEMan();
if (seman == null) return;
@@ -107,6 +114,8 @@ namespace RacesOfValheim
{
UnityEngine.Object.Destroy(logTarget.gameObject);
}
+
+ lastGrabTime = Time.time;
}
}
@@ -136,8 +145,37 @@ namespace RacesOfValheim
ItemDrop.ItemData rightItem = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_rightItem").Value;
if (rightItem != null && rightItem.m_dropPrefab != null && rightItem.m_dropPrefab.name.StartsWith("TrolWeapon_")) return;
- string key = TrolConfig.GrabLogKey.Value.MainKey.ToString();
- __result += ModText.Get("rov_hover_trol_grab_log", key);
+ // The game's Use key, which ModText resolves to the pad's own button on a gamepad. The
+ // Grab Log key still works, but only Use reaches every device.
+ __result += ModText.Get("rov_hover_trol_grab_log");
+ }
+ }
+
+ ///
+ /// Grab Log on the game's own Use, keyboard and gamepad alike, the way the Aswid's Dominate
+ /// works. Dominate is an Interactable, so vanilla's Player.Interact finds it; a log carries
+ /// only HoverText, which is not one, so Use on a log did nothing and the Grab Log key (read
+ /// off the keyboard) was the only way in. A pad had none.
+ ///
+ /// Taken over only for a True Form Trol at tier 7+, who is the one shown the prompt; anyone
+ /// else's Use on a log goes on to vanilla, which does nothing with it.
+ ///
+ [HarmonyPatch(typeof(Player), "Interact")]
+ public static class Trol_LogGrabInteract_Patch
+ {
+ public static bool Prefix(Player __instance, GameObject go, bool hold)
+ {
+ if (__instance != Player.m_localPlayer || go == null || !TrolRace.IsTrol()) return true;
+ if (BossProgressionManager.GetCurrentProgressionState() < 7) return true;
+ if (!__instance.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) return true;
+ if (__instance.InAttack() || __instance.InDodge()) return true;
+
+ TreeLog log = go.GetComponentInParent();
+ if (log == null) return true;
+
+ // Holding Use repeats the call every frame: one press, one grab.
+ if (!hold) TrolLogWeapon.GrabLog(__instance, log);
+ return false;
}
}
}