From 159b42b61542a291b8098ee7bb744682fea2502c Mon Sep 17 00:00:00 2001 From: throwaway180185 Date: Mon, 13 Dec 2021 23:49:08 -0500 Subject: [PATCH 1/3] hacky initial implementation 3 round burst for all guns shots are noticeably much slower for high rate of fire weapons, which should be addressed --- src/main/java/com/flansmod/common/PlayerData.java | 7 +++++++ .../java/com/flansmod/common/guns/ItemGun.java | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/flansmod/common/PlayerData.java b/src/main/java/com/flansmod/common/PlayerData.java index b0c391828..b2bd40c69 100644 --- a/src/main/java/com/flansmod/common/PlayerData.java +++ b/src/main/java/com/flansmod/common/PlayerData.java @@ -109,6 +109,13 @@ public void SetBurstRoundsRemaining(EnumHand hand, int set) if(hand == EnumHand.OFF_HAND) burstRoundsRemainingLeft = set; else burstRoundsRemainingRight = set; } + + public boolean IsBursting(EnumHand hand) + { + if(GetBurstRoundsRemaining(hand) > 0) + return true; + else return false; + } public Vector3f[] lastMeleePositions; diff --git a/src/main/java/com/flansmod/common/guns/ItemGun.java b/src/main/java/com/flansmod/common/guns/ItemGun.java index 99e252138..c6aba79cb 100644 --- a/src/main/java/com/flansmod/common/guns/ItemGun.java +++ b/src/main/java/com/flansmod/common/guns/ItemGun.java @@ -349,11 +349,20 @@ public void onUpdateClient(ItemStack gunstack, int gunSlot, World world, Entity case BURST: { //PlayerData burst rounds handled on client - if(data.GetBurstRoundsRemaining(hand) > 0) + if(hold && !held) { - shouldShootThisTick = true; + data.SetBurstRoundsRemaining(hand, 9); + } + else if(held) + { + if(data.IsBursting(hand)) + { + shouldShootThisTick = true; + data.SetBurstRoundsRemaining(hand, data.GetBurstRoundsRemaining(hand) - 1); + } } - // Fallthrough to semi auto + else needsToReload = false; + break; } case SEMIAUTO: { From 436859fcc12c60e99d065f49696b5571037e0842 Mon Sep 17 00:00:00 2001 From: throwaway180185 Date: Tue, 14 Dec 2021 00:49:37 -0500 Subject: [PATCH 2/3] change counting to tick clean up burst fire by counting ticks instead of rounds rounds come from setting the amount of ticks to be in a burst fire state equal to each gun's shootDelay multiplied by 3 (number of rounds) --- .../flansmod/client/handlers/KeyInputHandler.java | 2 +- src/main/java/com/flansmod/common/PlayerData.java | 14 +++++++------- .../java/com/flansmod/common/guns/GunType.java | 2 +- .../java/com/flansmod/common/guns/ItemGun.java | 5 +++-- .../common/network/PacketGunAnimation.java | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java b/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java index 5eb8ded57..e73d65b4b 100644 --- a/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java +++ b/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java @@ -218,7 +218,7 @@ void checkEventKeys() animations.doReload(type.reloadTime, pumpDelay, pumpTime); data.reloadingRight = true; - data.burstRoundsRemainingRight = 0; + data.burstTicksRemainingRight = 0; } } } diff --git a/src/main/java/com/flansmod/common/PlayerData.java b/src/main/java/com/flansmod/common/PlayerData.java index b2bd40c69..4dcf005bc 100644 --- a/src/main/java/com/flansmod/common/PlayerData.java +++ b/src/main/java/com/flansmod/common/PlayerData.java @@ -85,7 +85,7 @@ public class PlayerData /** * When the player shoots a burst fire weapon, one shot is fired immediately and this counter keeps track of how many more should be fired */ - public int burstRoundsRemainingLeft = 0, burstRoundsRemainingRight = 0; + public int burstTicksRemainingLeft = 0, burstTicksRemainingRight = 0; // Handed getters and setters public float GetShootTime(EnumHand hand) @@ -99,20 +99,20 @@ public void SetShootTime(EnumHand hand, float set) else shootTimeRight = set; } - public int GetBurstRoundsRemaining(EnumHand hand) + public int GetBurstTicksRemaining(EnumHand hand) { - return hand == EnumHand.OFF_HAND ? burstRoundsRemainingLeft : burstRoundsRemainingRight; + return hand == EnumHand.OFF_HAND ? burstTicksRemainingLeft : burstTicksRemainingRight; } - public void SetBurstRoundsRemaining(EnumHand hand, int set) + public void SetBurstTicksRemaining(EnumHand hand, int set) { - if(hand == EnumHand.OFF_HAND) burstRoundsRemainingLeft = set; - else burstRoundsRemainingRight = set; + if(hand == EnumHand.OFF_HAND) burstTicksRemainingLeft = set; + else burstTicksRemainingRight = set; } public boolean IsBursting(EnumHand hand) { - if(GetBurstRoundsRemaining(hand) > 0) + if(GetBurstTicksRemaining(hand) > 0) return true; else return false; } diff --git a/src/main/java/com/flansmod/common/guns/GunType.java b/src/main/java/com/flansmod/common/guns/GunType.java index f6c3e95fe..6dbd2d3d6 100644 --- a/src/main/java/com/flansmod/common/guns/GunType.java +++ b/src/main/java/com/flansmod/common/guns/GunType.java @@ -833,7 +833,7 @@ public float GetShootDelay(ItemStack stack) for(AttachmentType attachment : getCurrentAttachments(stack)) { if(attachment.modeOverride == EnumFireMode.BURST) - return Math.max(shootDelay, 3); + return Math.max(shootDelay, 1.5F); } float stackShootDelay = shootDelay; diff --git a/src/main/java/com/flansmod/common/guns/ItemGun.java b/src/main/java/com/flansmod/common/guns/ItemGun.java index c6aba79cb..9e4a878c1 100644 --- a/src/main/java/com/flansmod/common/guns/ItemGun.java +++ b/src/main/java/com/flansmod/common/guns/ItemGun.java @@ -57,6 +57,7 @@ import com.flansmod.common.enchantments.EnchantmentModule; import com.flansmod.common.enchantments.ItemGlove; import com.flansmod.common.guns.raytracing.FlansModRaytracer; +import com.flansmod.common.guns.GunType; import com.flansmod.common.network.PacketGunFire; import com.flansmod.common.network.PacketPlaySound; import com.flansmod.common.network.PacketReload; @@ -351,14 +352,14 @@ public void onUpdateClient(ItemStack gunstack, int gunSlot, World world, Entity //PlayerData burst rounds handled on client if(hold && !held) { - data.SetBurstRoundsRemaining(hand, 9); + data.SetBurstTicksRemaining(hand, (int) (Math.max(type.shootDelay, 1.5F) * 3)); } else if(held) { if(data.IsBursting(hand)) { shouldShootThisTick = true; - data.SetBurstRoundsRemaining(hand, data.GetBurstRoundsRemaining(hand) - 1); + data.SetBurstTicksRemaining(hand, data.GetBurstTicksRemaining(hand) - 1); } } else needsToReload = false; diff --git a/src/main/java/com/flansmod/common/network/PacketGunAnimation.java b/src/main/java/com/flansmod/common/network/PacketGunAnimation.java index beb0958df..3eff7fa68 100644 --- a/src/main/java/com/flansmod/common/network/PacketGunAnimation.java +++ b/src/main/java/com/flansmod/common/network/PacketGunAnimation.java @@ -159,7 +159,7 @@ private void handleAnimation(GunAnimations animations, AnimationType type, Entit animations.doReload(reloadtime, pumpdelay, pumptime); PlayerData data = PlayerHandler.getPlayerData(player); data.shootTimeRight = data.shootTimeLeft = reloadtime; - data.SetBurstRoundsRemaining(hand, 0); + data.SetBurstTicksRemaining(hand, 0); data.reloadingLeft = data.reloadingRight = true; break; From 009144c312a81998b1aa99bc08c3a9d245237e85 Mon Sep 17 00:00:00 2001 From: throwaway180185 Date: Tue, 14 Dec 2021 01:13:56 -0500 Subject: [PATCH 3/3] Update ItemGun.java fixed so that guns set to burst by default can shoot faster than the 1.5 tick limit that should only be imposed on the guns with the modification --- src/main/java/com/flansmod/common/guns/ItemGun.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/flansmod/common/guns/ItemGun.java b/src/main/java/com/flansmod/common/guns/ItemGun.java index 9e4a878c1..defc30a62 100644 --- a/src/main/java/com/flansmod/common/guns/ItemGun.java +++ b/src/main/java/com/flansmod/common/guns/ItemGun.java @@ -352,7 +352,10 @@ public void onUpdateClient(ItemStack gunstack, int gunSlot, World world, Entity //PlayerData burst rounds handled on client if(hold && !held) { - data.SetBurstTicksRemaining(hand, (int) (Math.max(type.shootDelay, 1.5F) * 3)); + if(type.mode != EnumFireMode.BURST) + data.SetBurstTicksRemaining(hand, (int) (Math.max(type.shootDelay, 1.5F) * 3)); + else + data.SetBurstTicksRemaining(hand, (int) type.shootDelay * 3); } else if(held) {