dry fire animations, clicky stuff

This commit is contained in:
Bob 2024-09-22 22:52:47 +02:00
parent 51839e8abb
commit 42b7d1f657
4 changed files with 38 additions and 15 deletions

View File

@ -22,6 +22,7 @@ public class Receiver {
public static final String I_ROUNDSPERCYCLE = "I_ROUNDSPERCYCLE";
public static final String F_SPREADMOD = "F_SPREADMOD";
public static final String B_REFIREONHOLD = "B_REFIREONHOLD";
public static final String B_DOESDRYFIRE = "B_DOESDRYFIRE";
public static final String O_EJECTOR = "O_EJECTOR";
public static final String I_RELOADDURATION = "I_RELOADDURATION";
public static final String S_FIRESOUND = "S_FIRESOUND";
@ -41,6 +42,7 @@ public class Receiver {
protected int roundsPerCycle_DNA = 1;
protected float spreadModExtra_DNA = 0F;
protected boolean refireOnHold_DNA = false;
protected boolean doesDryFire_DNA = true;
protected CasingEjector ejector_DNA = null;
protected int reloadDuration_DNA;
protected String fireSound_DNA;
@ -56,6 +58,7 @@ public class Receiver {
public int getRoundsPerCycle(ItemStack stack) { return WeaponUpgradeManager.eval(this.roundsPerCycle_DNA, stack, I_ROUNDSPERCYCLE, this); }
public float getSpreadMod(ItemStack stack) { return WeaponUpgradeManager.eval(this.spreadModExtra_DNA, stack, F_SPREADMOD, this); }
public boolean getRefireOnHold(ItemStack stack) { return WeaponUpgradeManager.eval(this.refireOnHold_DNA, stack, B_REFIREONHOLD, this); }
public boolean getDoesDryFire(ItemStack stack) { return WeaponUpgradeManager.eval(this.doesDryFire_DNA, stack, B_DOESDRYFIRE, this); }
public CasingEjector getEjector(ItemStack stack) { return WeaponUpgradeManager.eval(this.ejector_DNA, stack, O_EJECTOR, this); }
public int getReloadDuration(ItemStack stack) { return WeaponUpgradeManager.eval(this.reloadDuration_DNA, stack, I_RELOADDURATION, this); }
public String getFireSound(ItemStack stack) { return WeaponUpgradeManager.eval(this.fireSound_DNA, stack, S_FIRESOUND, this); }
@ -70,8 +73,9 @@ public class Receiver {
public Receiver dmg(float dmg) { this.baseDamage_DNA = dmg; return this; }
public Receiver delay(int delay) { this.delayAfterFire_DNA = delay; return this; }
public Receiver rounds(int rounds) { this.roundsPerCycle_DNA = rounds; return this; }
public Receiver spread(int spread) { this.spreadModExtra_DNA = spread; return this; }
public Receiver spread(int spread) { this.spreadModExtra_DNA = spread; return this; }
public Receiver auto(boolean auto) { this.refireOnHold_DNA = auto; return this; }
public Receiver dryfire(boolean dryfire) { this.doesDryFire_DNA = dryfire; return this; }
public Receiver burst(CasingEjector ejector) { this.ejector_DNA = ejector; return this; }
public Receiver reload(int delay) { this.reloadDuration_DNA = delay; return this; }
public Receiver mag(IMagazine magazine) { this.magazine_DNA = magazine; return this; }

View File

@ -36,7 +36,7 @@ public class GunFactory {
ModItems.gun_debug = new ItemGunBaseNT(new GunConfig()
.dura(600F).draw(15).inspect(23).crosshair(Crosshair.L_CLASSIC).hud(Lego.HUD_COMPONENT_DURABILITY, Lego.HUD_COMPONENT_AMMO).smoke(true).orchestra(DEBUG_ORCHESTRA)
.rec(new Receiver(0)
.dmg(10F).delay(12).reload(46).sound("hbm:weapon.44Shoot", 1.0F, 1.0F)
.dmg(10F).delay(14).reload(46).sound("hbm:weapon.44Shoot", 1.0F, 1.0F)
.mag(new MagazineFullReload(0, 12).addConfigs(ammo_debug, ammo_debug_buckshot))
.canFire(Lego.LAMBDA_STANDARD_CAN_FIRE).fire(Lego.LAMBDA_STANDARD_FIRE))
.pp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY) .pr(Lego.LAMBDA_STANDARD_RELOAD) .pt(Lego.LAMBDA_TOGGLE_AIM)
@ -54,7 +54,7 @@ public class GunFactory {
int timer = ItemGunBaseNT.getAnimTimer(stack);
if(type == AnimType.RELOAD) {
if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F);
if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F);
if(timer == 10) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F);
if(timer == 34) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F);
if(timer == 40) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F);
@ -62,8 +62,12 @@ public class GunFactory {
if(type == AnimType.CYCLE) {
if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F);
}
if(type == AnimType.INSPECT) {
if(type == AnimType.CYCLE_DRY) {
if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F);
if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F);
}
if(type == AnimType.INSPECT) {
if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F);
if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F);
}
};

View File

@ -62,15 +62,26 @@ public class Lego {
Receiver rec = ctx.config.getReceivers(stack)[0];
GunState state = ItemGunBaseNT.getState(stack);
if(state == GunState.IDLE && rec.getCanFire(stack).apply(stack, ctx)) {
ItemGunBaseNT.setState(stack, GunState.COOLDOWN);
ItemGunBaseNT.setTimer(stack, rec.getDelayAfterFire(stack));
rec.getOnFire(stack).accept(stack, ctx);
if(state == GunState.IDLE) {
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack));
int remaining = rec.getRoundsPerCycle(stack) - 1;
for(int i = 0; i < remaining; i++) if(rec.getCanFire(stack).apply(stack, ctx)) rec.getOnFire(stack).accept(stack, ctx);
if(rec.getCanFire(stack).apply(stack, ctx)) {
rec.getOnFire(stack).accept(stack, ctx);
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack));
int remaining = rec.getRoundsPerCycle(stack) - 1;
for(int i = 0; i < remaining; i++) if(rec.getCanFire(stack).apply(stack, ctx)) rec.getOnFire(stack).accept(stack, ctx);
ItemGunBaseNT.setState(stack, GunState.COOLDOWN);
ItemGunBaseNT.setTimer(stack, rec.getDelayAfterFire(stack));
} else {
ItemGunBaseNT.playAnimation(player, stack, AnimType.CYCLE_DRY);
if(rec.getDoesDryFire(stack)) {
ItemGunBaseNT.setState(stack, GunState.COOLDOWN);
ItemGunBaseNT.setTimer(stack, rec.getDelayAfterFire(stack));
}
}
}
};
@ -113,9 +124,12 @@ public class Lego {
@SuppressWarnings("incomplete-switch") public static BiFunction<ItemStack, AnimType, BusAnimation> LAMBDA_DEBUG_ANIMS = (stack, type) -> {
switch(type) {
case CYCLE: return new BusAnimation()
.addBus("RECOIL", new BusAnimationSequence().addPos(0, 0, 0, 50).addPos(0, 0, -3, 50).addPos(0, 0, 0, 250))
.addBus("HAMMER", new BusAnimationSequence().addPos(0, 0, 1, 50).addPos(0, 0, 1, 300 + 100).addPos(0, 0, 0, 200))
.addBus("DRUM", new BusAnimationSequence().addPos(0, 0, 0, 350 + 100).addPos(0, 0, 1, 200));
.addBus("RECOIL", new BusAnimationSequence().addPos(0, 0, 0, 50).addPos(0, 0, -3, 50).addPos(0, 0, 0, 250))
.addBus("HAMMER", new BusAnimationSequence().addPos(0, 0, 1, 50).addPos(0, 0, 1, 400).addPos(0, 0, 0, 200))
.addBus("DRUM", new BusAnimationSequence().addPos(0, 0, 0, 450).addPos(0, 0, 1, 200));
case CYCLE_DRY: return new BusAnimation()
.addBus("HAMMER", new BusAnimationSequence().addPos(0, 0, 1, 50).addPos(0, 0, 1, 300 + 100).addPos(0, 0, 0, 200))
.addBus("DRUM", new BusAnimationSequence().addPos(0, 0, 0, 450).addPos(0, 0, 1, 200));
case EQUIP: return new BusAnimation().addBus("ROTATE", new BusAnimationSequence().addPos(-360, 0, 0, 350));
case RELOAD: return new BusAnimation()
.addBus("RELAOD_TILT", new BusAnimationSequence().addPos(-15, 0, 0, 100).addPos(65, 0, 0, 100).addPos(45, 0, 0, 50).addPos(0, 0, 0, 200).addPos(0, 0, 0, 1450).addPos(-80, 0, 0, 100).addPos(-80, 0, 0, 100).addPos(0, 0, 0, 200))

View File

@ -24,6 +24,7 @@ public class HbmAnimations {
RELOAD_END, //animation for transitioning from our RELOAD_CYCLE to idle
CYCLE, //animation for every firing cycle
CYCLE_EMPTY, //animation for the final shot in the magazine
CYCLE_DRY, //animation for trying to fire, but no round is available
ALT_CYCLE, //animation for alt fire cycles
SPINUP, //animation for actionstart
SPINDOWN, //animation for actionend