From 16f710450c83f00417885c58896f85562304d3c1 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Fri, 1 Sep 2023 11:43:59 -0400 Subject: [PATCH 1/4] actual burst fire logic also adds burst fire to josh --- .../com/hbm/handler/GunConfiguration.java | 4 +- .../hbm/handler/guncfg/Gun50BMGFactory.java | 13 +++++- .../com/hbm/items/weapon/ItemGunBase.java | 45 +++++++++++++++---- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/hbm/handler/GunConfiguration.java b/src/main/java/com/hbm/handler/GunConfiguration.java index 1763ad83a..dd8e20796 100644 --- a/src/main/java/com/hbm/handler/GunConfiguration.java +++ b/src/main/java/com/hbm/handler/GunConfiguration.java @@ -25,6 +25,8 @@ public class GunConfiguration implements Cloneable { public int rateOfFire; //amount of bullets fired per delay passed public int roundsPerCycle; + /** Amount of rounds per burst, irrelevant if not a burst fire weapon**/ + public int roundsPerBurst; //0 = normal, 1 = release, 2 = both public int gunMode; //0 = manual, 1 = automatic @@ -46,7 +48,7 @@ public class GunConfiguration implements Cloneable { //how long the reload animation will play //MUST BE GREATER THAN ZERO ! ! ! public int reloadDuration; - //duration of every animation cycle + //duration of every animation cycle, used also for how quickly a burst fire rifle can fire public int firingDuration; //sound path to the reload sound public String reloadSound = ""; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java index 5da9631d2..189ad105e 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java @@ -157,7 +157,18 @@ public class Gun50BMGFactory { return config; } - + + public static GunConfiguration getAR15BurstConfig(){ + GunConfiguration config = getAR15Config(); + config.rateOfFire = 4; + config.roundsPerBurst = 3; + config.firingDuration = 2; + config.gunMode = GunConfiguration.MODE_NORMAL; + config.firingMode = GunConfiguration.FIRE_BURST; + + return config; + } + public static GunConfiguration getM2Config() { GunConfiguration config = getAR15Config(); diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index e2b428c7e..0bd0611f8 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -55,7 +55,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu public boolean m1;// = false; @SideOnly(Side.CLIENT) public boolean m2;// = false; - + + public int burstDuration = 0; public ItemGunBase(GunConfiguration config) { mainConfig = config; this.setMaxStackSize(1); @@ -131,13 +132,26 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if(getIsMouseDown(stack) && !(player.getHeldItem() == stack)) { setIsMouseDown(stack, false); } - + + if(burstDuration > 0) { + if(altConfig == null) { + if (world.getWorldTime() % mainConfig.firingDuration == 0 && tryShoot(stack, world, player, true)) { + fire(stack, world, player); + } + } else { + boolean canFire = altConfig.firingDuration == 1 || world.getWorldTime() % altConfig.firingDuration == 0; + if (canFire && tryShoot(stack, world, player, false)) { + altFire(stack, world, player); + } + } + + if(--burstDuration == 0) setDelay(stack, mainConfig.rateOfFire); + } if(getIsAltDown(stack) && !isCurrentItem) { setIsAltDown(stack, false); } if(GeneralConfig.enableGuns && mainConfig.firingMode == 1 && getIsMouseDown(stack) && tryShoot(stack, world, player, isCurrentItem)) { - fire(stack, world, player); setDelay(stack, mainConfig.rateOfFire); } @@ -284,17 +298,32 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu //called on click (server side, called by mouse packet) for semi-automatics and specific events public void startAction(ItemStack stack, World world, EntityPlayer player, boolean main) { - if(mainConfig.firingMode == mainConfig.FIRE_MANUAL && main && tryShoot(stack, world, player, main)) { - fire(stack, world, player); - setDelay(stack, mainConfig.rateOfFire); + boolean validConfig = mainConfig.firingMode == GunConfiguration.FIRE_MANUAL || mainConfig.firingMode == GunConfiguration.FIRE_BURST; + + if(validConfig && main && tryShoot(stack, world, player, main)) { + + if(mainConfig.firingMode == GunConfiguration.FIRE_BURST){ + if(burstDuration <= 0) + burstDuration = mainConfig.firingDuration * mainConfig.roundsPerBurst; + } else { + fire(stack, world, player); + setDelay(stack, mainConfig.rateOfFire); + } + //setMag(stack, getMag(stack) - 1); //useUpAmmo(player, stack, main); //player.inventoryContainer.detectAndSendChanges(); } if(!main && altConfig != null && tryShoot(stack, world, player, main)) { - altFire(stack, world, player); - setDelay(stack, altConfig.rateOfFire); + + if(altConfig.firingMode == GunConfiguration.FIRE_BURST && burstDuration <= 0){ + burstDuration = altConfig.firingDuration * altConfig.roundsPerBurst; + } else { + altFire(stack, world, player); + setDelay(stack, altConfig.rateOfFire); + } + //useUpAmmo(player, stack, main); //player.inventoryContainer.detectAndSendChanges(); } From 9e2d2dba01d104d7d6953bfc28128b195c767972 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Fri, 1 Sep 2023 13:22:20 -0400 Subject: [PATCH 2/4] burst fire for the UAC pistol --- .../hbm/handler/guncfg/Gun45ACPFactory.java | 23 ++++++++++++++++++- src/main/java/com/hbm/items/ModItems.java | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java index b4f25aa06..55f42911b 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java @@ -62,7 +62,7 @@ public class Gun45ACPFactory { config.firingMode = GunConfiguration.FIRE_MANUAL; config.reloadDuration = 10; config.firingDuration = 8; - config.ammoCap = 16; + config.ammoCap = 21; config.durability = 10000; config.reloadType = 1; config.allowsInfinity = true; @@ -88,6 +88,27 @@ public class Gun45ACPFactory { .addKeyframe(new BusAnimationKeyframe(15, 0, 0, 10)) .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 40)))); + //faster version of the main one, so it doesn't cut out much on the bursts + config.animations.put(AnimType.ALT_CYCLE, new BusAnimation() + .addBus("SLIDE", new BusAnimationSequence() + .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 5))// Wait for hammer + .addKeyframe(new BusAnimationKeyframe(0, 0, -3.5, 20))// Slide back + .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 20)))// Return + .addBus("HAMMER", new BusAnimationSequence() + .addKeyframe(new BusAnimationKeyframe(15, 0, 0, 5)) + .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 20)))); + + return config; + } + + public static GunConfiguration getUACPistolBurstConfig() { + GunConfiguration config = getUACPistolConfig(); + config.rateOfFire = 5; + config.roundsPerBurst = 3; + config.firingDuration = 2; + config.gunMode = GunConfiguration.MODE_NORMAL; + config.firingMode = GunConfiguration.FIRE_BURST; + return config; } diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 119a33d3b..8ee6a7e1e 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -4229,8 +4229,8 @@ public class ModItems { gun_glass_cannon = new ItemEnergyGunBase(GunPoweredFactory.getGlassCannonConfig()).setFull3D().setUnlocalizedName("gun_glass_cannon").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter"); gun_m2 = new ItemGunBase(Gun50BMGFactory.getM2Config()).setFull3D().setUnlocalizedName("gun_m2").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter"); gun_lunatic_marksman = new ItemGunBase(Gun50BMGFactory.getLunaticMarksman()).setFull3D().setUnlocalizedName("gun_lunatic_marksman").setCreativeTab(MainRegistry.weaponTab); - gun_uac_pistol = new ItemGunBase(Gun45ACPFactory.getUACPistolConfig()).setFull3D().setUnlocalizedName("gun_uac_pistol").setCreativeTab(MainRegistry.weaponTab); - + gun_uac_pistol = new ItemGunBase(Gun45ACPFactory.getUACPistolConfig(), Gun45ACPFactory.getUACPistolBurstConfig()).setFull3D().setUnlocalizedName("gun_uac_pistol").setCreativeTab(MainRegistry.weaponTab); + ToolMaterial matCrucible = EnumHelper.addToolMaterial("CRUCIBLE", 10, 3, 50.0F, 100.0F, 0); crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible"); From ad826215eeeebbbe8b4595f01f15605c7d716c4b Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:17:20 -0400 Subject: [PATCH 3/4] i forogr --- src/main/java/com/hbm/handler/GunConfiguration.java | 1 + .../java/com/hbm/handler/guncfg/Gun45ACPFactory.java | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/com/hbm/handler/GunConfiguration.java b/src/main/java/com/hbm/handler/GunConfiguration.java index dd8e20796..97cb7b3a5 100644 --- a/src/main/java/com/hbm/handler/GunConfiguration.java +++ b/src/main/java/com/hbm/handler/GunConfiguration.java @@ -96,6 +96,7 @@ public class GunConfiguration implements Cloneable { public static final int FIRE_MANUAL = 0; public static final int FIRE_AUTO = 1; + public static final int FIRE_BURST = 2; public static final int RELOAD_NONE = 0; public static final int RELOAD_FULL = 1; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java index 55f42911b..644d37457 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java @@ -88,16 +88,6 @@ public class Gun45ACPFactory { .addKeyframe(new BusAnimationKeyframe(15, 0, 0, 10)) .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 40)))); - //faster version of the main one, so it doesn't cut out much on the bursts - config.animations.put(AnimType.ALT_CYCLE, new BusAnimation() - .addBus("SLIDE", new BusAnimationSequence() - .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 5))// Wait for hammer - .addKeyframe(new BusAnimationKeyframe(0, 0, -3.5, 20))// Slide back - .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 20)))// Return - .addBus("HAMMER", new BusAnimationSequence() - .addKeyframe(new BusAnimationKeyframe(15, 0, 0, 5)) - .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 20)))); - return config; } From 523d76133bc26ee06fca2a37fd1820721bd07ba5 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Mon, 4 Sep 2023 16:59:45 -0400 Subject: [PATCH 4/4] Converted burst fire gun system to use NBT --- .../com/hbm/items/weapon/ItemGunBase.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index 0bd0611f8..385801c3a 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -56,7 +56,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu @SideOnly(Side.CLIENT) public boolean m2;// = false; - public int burstDuration = 0; public ItemGunBase(GunConfiguration config) { mainConfig = config; this.setMaxStackSize(1); @@ -133,7 +132,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu setIsMouseDown(stack, false); } - if(burstDuration > 0) { + if(getBurstDuration(stack) > 0) { if(altConfig == null) { if (world.getWorldTime() % mainConfig.firingDuration == 0 && tryShoot(stack, world, player, true)) { fire(stack, world, player); @@ -145,7 +144,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu } } - if(--burstDuration == 0) setDelay(stack, mainConfig.rateOfFire); + setBurstDuration(stack, getBurstDuration(stack) - 1); + if(getBurstDuration(stack) == 0) setDelay(stack, mainConfig.rateOfFire); } if(getIsAltDown(stack) && !isCurrentItem) { setIsAltDown(stack, false); @@ -303,8 +303,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if(validConfig && main && tryShoot(stack, world, player, main)) { if(mainConfig.firingMode == GunConfiguration.FIRE_BURST){ - if(burstDuration <= 0) - burstDuration = mainConfig.firingDuration * mainConfig.roundsPerBurst; + if(getBurstDuration(stack) <= 0) + setBurstDuration(stack,mainConfig.firingDuration * mainConfig.roundsPerBurst); } else { fire(stack, world, player); setDelay(stack, mainConfig.rateOfFire); @@ -317,8 +317,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if(!main && altConfig != null && tryShoot(stack, world, player, main)) { - if(altConfig.firingMode == GunConfiguration.FIRE_BURST && burstDuration <= 0){ - burstDuration = altConfig.firingDuration * altConfig.roundsPerBurst; + if(altConfig.firingMode == GunConfiguration.FIRE_BURST && getBurstDuration(stack) <= 0){ + setBurstDuration(stack,altConfig.firingDuration * altConfig.roundsPerBurst); } else { altFire(stack, world, player); setDelay(stack, altConfig.rateOfFire); @@ -673,6 +673,14 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu public static int getMagType(ItemStack stack) { return readNBT(stack, "magazineType"); } + /// Sets how long a burst fires for, only useful for burst fire weapons /// + public static void setBurstDuration(ItemStack stack, int i) { + writeNBT(stack, "bduration", i); + } + + public static int getBurstDuration(ItemStack stack) { + return readNBT(stack, "bduration"); + } /// queued casing for ejection /// public static void setCasing(ItemStack stack, BulletConfiguration bullet) {