Bind Taming ability to K key instead of E
This commit is contained in:
parent
225b7115bc
commit
ff9fc4db2d
2 changed files with 36 additions and 32 deletions
|
|
@ -459,42 +459,11 @@ namespace RacesOfValheim
|
|||
|
||||
if (canTame)
|
||||
{
|
||||
__result += "\n[<color=yellow><b></b></color>] Tame";
|
||||
__result += "\n[<color=yellow><b>K</b></color>] Tame";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Tameable), "Interact")]
|
||||
public static class Aswid_TameInteract_Patch
|
||||
{
|
||||
public static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt)
|
||||
{
|
||||
if (hold || alt) return true;
|
||||
if (user != Player.m_localPlayer || !AswidRace.IsAswid()) return true;
|
||||
if (__instance.GetComponent<Character>()?.IsTamed() == true) return true;
|
||||
|
||||
string prefabName = __instance.gameObject.name.ToLower();
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
|
||||
bool canTame = false;
|
||||
if (state >= 2 && prefabName.Contains("boar")) canTame = true;
|
||||
if (state >= 5 && prefabName.Contains("wolf")) canTame = true;
|
||||
if (state >= 6 && prefabName.Contains("lox")) canTame = true;
|
||||
if (state >= 8 && prefabName.Contains("asksvin")) canTame = true;
|
||||
|
||||
if (canTame)
|
||||
{
|
||||
__instance.GetComponent<Character>()?.SetTamed(true);
|
||||
HarmonyLib.Traverse.Create(__instance).Method("Tame").GetValue(); // attempt to call Tame for VFX if it exists
|
||||
__instance.Command(user);
|
||||
user.Message(MessageHud.MessageType.Center, "Tamed!");
|
||||
return false; // Skip original interact
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Hud), "UpdateStamina")]
|
||||
public static class Aswid_HideStamina_Patch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -512,6 +512,11 @@ namespace RacesOfValheim
|
|||
TryCastEclipse(state);
|
||||
return;
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
TryTameHoverObject(state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Auto revert mist form at sunrise
|
||||
|
|
@ -848,6 +853,36 @@ namespace RacesOfValheim
|
|||
yield return null;
|
||||
}
|
||||
|
||||
private void TryTameHoverObject(int state)
|
||||
{
|
||||
GameObject hoverObject = Player.m_localPlayer.GetHoverObject();
|
||||
if (hoverObject != null)
|
||||
{
|
||||
Tameable tameable = hoverObject.GetComponentInParent<Tameable>();
|
||||
if (tameable != null)
|
||||
{
|
||||
Character c = tameable.GetComponent<Character>();
|
||||
if (c != null && !c.IsTamed())
|
||||
{
|
||||
string prefabName = c.gameObject.name.ToLower();
|
||||
bool canTame = false;
|
||||
if (state >= 2 && prefabName.Contains("boar")) canTame = true;
|
||||
if (state >= 5 && prefabName.Contains("wolf")) canTame = true;
|
||||
if (state >= 6 && prefabName.Contains("lox")) canTame = true;
|
||||
if (state >= 8 && prefabName.Contains("asksvin")) canTame = true;
|
||||
|
||||
if (canTame)
|
||||
{
|
||||
c.SetTamed(true);
|
||||
HarmonyLib.Traverse.Create(tameable).Method("Tame").GetValue(); // attempt to call Tame for VFX if it exists
|
||||
tameable.Command(Player.m_localPlayer);
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Tamed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TryCastEclipse(int state)
|
||||
{
|
||||
if (state < 6) return; // Requires Yagluth
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue