mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
actual burst fire logic
also adds burst fire to josh
This commit is contained in:
parent
96c1986ae9
commit
16f710450c
@ -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 = "";
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user