bugfix 21/09/26
This commit is contained in:
parent
834d6647fd
commit
64d8869f98
3 changed files with 70 additions and 3 deletions
|
|
@ -199,4 +199,46 @@ namespace RacesOfValheim
|
||||||
return PieceDensityLimit.Allow(__instance, Utils.GetPrefabName(__0.gameObject), __1);
|
return PieceDensityLimit.Allow(__instance, Utils.GetPrefabName(__0.gameObject), __1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What makes "a prefix returning false spends nothing" TRUE, which on its own it is not.
|
||||||
|
///
|
||||||
|
/// Read off the 1.0 IL: nothing is paid inside PlacePiece. TryPlacePiece calls it and then does an
|
||||||
|
/// unconditional `ldc.i4.1; ret`, and it is UpdatePlacement that, on that true, runs
|
||||||
|
/// ConsumeResources and UseStamina. So every race lock in the mod - this class's gates, the Trol
|
||||||
|
/// totem, the Dvergar bank and barrel, the Trenta Root - stopped the building and still took the
|
||||||
|
/// wood: "Only the Sverm can raise a hive", and 40 wood and 20 resin gone.
|
||||||
|
///
|
||||||
|
/// Fixed here once rather than in each lock: a last-priority prefix on the same PlacePiece
|
||||||
|
/// overload sees __runOriginal after every other prefix has had its say, and if any of them said
|
||||||
|
/// no, TryPlacePiece reports false - the path vanilla already takes for a blocked placement, which
|
||||||
|
/// charges nothing. Any lock added later is covered without knowing this exists.
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(Player), "PlacePiece",
|
||||||
|
new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
|
||||||
|
public static class PlacementRefusalWatch
|
||||||
|
{
|
||||||
|
internal static bool Refused;
|
||||||
|
|
||||||
|
[HarmonyPriority(Priority.Last)]
|
||||||
|
public static void Prefix(bool __runOriginal)
|
||||||
|
{
|
||||||
|
if (!__runOriginal) Refused = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(Player), "TryPlacePiece")]
|
||||||
|
public static class PlacementRefusalCharge
|
||||||
|
{
|
||||||
|
public static void Prefix()
|
||||||
|
{
|
||||||
|
PlacementRefusalWatch.Refused = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Postfix(ref bool __result)
|
||||||
|
{
|
||||||
|
if (PlacementRefusalWatch.Refused) __result = false;
|
||||||
|
PlacementRefusalWatch.Refused = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,10 @@ namespace RacesOfValheim
|
||||||
// the live button state (via the configured shortcut, so a rebind stays in sync)
|
// the live button state (via the configured shortcut, so a rebind stays in sync)
|
||||||
// rather than a flag set during our Update, so it does not depend on whether
|
// rather than a flag set during our Update, so it does not depend on whether
|
||||||
// PlayerController's FixedUpdate happens to run first.
|
// PlayerController's FixedUpdate happens to run first.
|
||||||
if (secondaryAttack && SkadiConfig.ColdSpellKey.Value.IsPressedIgnoringHeldKeys() &&
|
// The pad's secondary attack casts only bare-handed (SkadiRace.PadCastsColdSpell), so it
|
||||||
|
// swallows the kick only then; with a weapon in hand the weapon's secondary goes through.
|
||||||
|
bool padCast = RaceInput.PadAttackHeld(2) && SkadiRace.PadCastsColdSpell(Player.m_localPlayer);
|
||||||
|
if (secondaryAttack && (SkadiConfig.ColdSpellKey.Value.IsPressedIgnoringHeldKeys() || padCast) &&
|
||||||
SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
|
SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
|
||||||
{
|
{
|
||||||
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());
|
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||||
|
|
|
||||||
|
|
@ -339,9 +339,18 @@ namespace RacesOfValheim
|
||||||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
||||||
if (isTransformed) return; // Do not cast human spell while in dragon form
|
if (isTransformed) return; // Do not cast human spell while in dragon form
|
||||||
|
|
||||||
|
// Hammer, hoe or cultivator in hand: every build button is vanilla's. Middle mouse is
|
||||||
|
// Remove on the keyboard, and on the pad JoySecondaryAttack shares its physical button
|
||||||
|
// with JoyRemove (Classic) or JoyPlace (Alt2) - read off ZInput.AddGamepad*Buttons - so
|
||||||
|
// each piece built or removed also cast the spell and drained the stamina for it.
|
||||||
|
if (Player.m_localPlayer.InPlaceMode()) return;
|
||||||
|
|
||||||
// Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey.
|
// Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey.
|
||||||
// On a gamepad, the secondary attack button (the pad's own middle-mouse equivalent).
|
// On a gamepad, the secondary attack button (the pad's own middle-mouse equivalent) -
|
||||||
if (SkadiConfig.ColdSpellKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(2))
|
// but only bare-handed: the pad has no separate spell key, so with a weapon or a tool
|
||||||
|
// that button belongs to the item's own secondary attack, as it does in vanilla.
|
||||||
|
if (SkadiConfig.ColdSpellKey.Value.IsDownIgnoringHeldKeys() ||
|
||||||
|
(RaceInput.PadAttackDown(2) && PadCastsColdSpell(Player.m_localPlayer)))
|
||||||
{
|
{
|
||||||
// The improved cast is a burst rather than a rapid-fire, so it waits longer.
|
// The improved cast is a burst rather than a rapid-fire, so it waits longer.
|
||||||
float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN;
|
float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN;
|
||||||
|
|
@ -373,6 +382,19 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the pad's secondary attack button casts the Cold Spell right now: out of build
|
||||||
|
/// mode and with nothing in either hand. Shared with SkadiAttackPatch, which swallows the
|
||||||
|
/// unarmed kick under exactly the same condition.
|
||||||
|
/// </summary>
|
||||||
|
public static bool PadCastsColdSpell(Player player)
|
||||||
|
{
|
||||||
|
if (player == null || player.InPlaceMode()) return false;
|
||||||
|
var hands = HarmonyLib.Traverse.Create(player);
|
||||||
|
return hands.Field<ItemDrop.ItemData>("m_rightItem").Value == null &&
|
||||||
|
hands.Field<ItemDrop.ItemData>("m_leftItem").Value == null;
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerator ColdSpellKickCoroutine(SkadiProgression.FormRules rules)
|
private IEnumerator ColdSpellKickCoroutine(SkadiProgression.FormRules rules)
|
||||||
{
|
{
|
||||||
// Wait for the cast animation to reach the release point
|
// Wait for the cast animation to reach the release point
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue