Skip to content

Commit

Permalink
Merge pull request #73 from luponix/master
Browse files Browse the repository at this point in the history
Fix for charge eating Thunderbolt swaps
  • Loading branch information
roncli committed Jan 28, 2021
2 parents 503ffb1 + 14c2dac commit 35beada
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions GameMod/MPAutoSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,7 @@ public static bool Prefix(Player __instance)
{
if (!__instance.CanFireMissileAmmo(MissileType.NUM))
{

DelayedSwitchTimer re = new DelayedSwitchTimer();
re.Awake();
new DelayedSwitchTimer().Awake();
return false;
}
}
Expand All @@ -894,6 +892,8 @@ public static bool Prefix(Player __instance)
}


static float ThunderboltSwapDelay = 0.025f;

// checks wether there was a swap that didnt get completed due to the player firing
[HarmonyPatch(typeof(GameManager), "Update")]
internal class ProcessDelayedSwap
Expand All @@ -905,6 +905,18 @@ public static void Postfix()
{
if (!Controls.IsPressed(CCInput.FIRE_WEAPON) && !waitingSwapWeaponType.Equals(""))
{
// Thunderbolt needs atleast a 4ms delay after releasing the fire button to actually release the shot.
// so swapping on release would swallow an already charged shot if the client picked up a weapon
if( GameManager.m_local_player.m_weapon_type.Equals(WeaponType.THUNDERBOLT))
{
if(ThunderboltSwapDelay > 0f)
{
ThunderboltSwapDelay -= Time.deltaTime;
return;
}
ThunderboltSwapDelay = 0.025f; // 25ms to ensure that it is fully reliable
}

swapToWeapon(waitingSwapWeaponType);
GameManager.m_local_player.UpdateCurrentWeaponName();
waitingSwapWeaponType = "";
Expand Down

0 comments on commit 35beada

Please sign in to comment.