Play Sound Options for Ranged Attacks

This commit is contained in:
Kam committed 2025-03-19 18:07:21 -04:00
1 parent 353d90a00a
commit bcf329c0ae
5 files changed
+20 -1

No files matched your search

+5
View File
@@ -49,9 +49,12 @@ public class DataStats {
public ScriptParticle pCustom = new ScriptParticle("");
public int pEffAmp = 0;
public String fireSound = "random.bow";
public boolean onSoundBegin = false;
public boolean playBurstSound = true; // Internal Only
public byte aimType = 0;
public boolean projectilesKeepTerrain = false;
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
private EntityNPCInterface npc;
@@ -110,6 +113,7 @@ public class DataStats {
compound.setInteger("pTrail", pTrail.ordinal());
compound.setInteger("pEffAmp", pEffAmp);
compound.setString("FiringSound", fireSound);
compound.setBoolean("FiringSoundBegin", onSoundBegin);
compound.setByte("AimType", aimType);
compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain);
if(pTrail == EnumParticleType.Custom)
@@ -178,6 +182,7 @@ public class DataStats {
pTrail = EnumParticleType.values()[compound.getInteger("pTrail") % EnumParticleType.values().length];
pEffAmp = compound.getInteger("pEffAmp");
fireSound = compound.getString("FiringSound");
onSoundBegin = compound.getBoolean("FiringSoundBegin");
aimType = compound.getByte("AimType");
projectilesKeepTerrain = compound.getBoolean("ProjectilesKeepTerrain");
if(pTrail == EnumParticleType.Custom)
@@ -112,6 +112,9 @@ public class EntityAIRangedAttack extends EntityAIBase {
if (this.rangedAttackTime <= 0) {
if (var1 <= (double) field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) {
if (this.field_70846_g == 0) {
this.entityHost.stats.playBurstSound = true;
}
if (this.field_70846_g++ <= this.entityHost.stats.burstCount) {
this.rangedAttackTime = this.entityHost.stats.fireRate;
this.isShooting = true;
@@ -61,6 +61,9 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "gui.select"));
addButton(new GuiNpcButton(10, guiLeft + 100, y += 22, 70, 20, new String[]{"stats.onShot", "stats.onStart"}, stats.onSoundBegin ? 1 : 0));
addLabel(new GuiNpcLabel(10, "stats.firesound:", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(9, guiLeft + 100, y += 22, 70, 20, new String[]{"gui.no", "gui.yes", "stats.onShot"}, stats.aimType));
addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5));
@@ -104,6 +107,9 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
soundSelected = getTextField(7);
setSubGui(new GuiSoundSelection(soundSelected.getText()));
}
if(id == 10){
stats.onSoundBegin = ((GuiNpcButton) guibutton).getValue() == 1;
}
if (id == 66) {
close();
} else if (id == 9) {
@@ -682,7 +682,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
EntityProjectile projectile = shoot(entity, stats.accuracy, proj, f == 1);
projectile.damage = event.getDamage();
}
this.playSound(this.stats.fireSound, 2.0F, 1.0f);
if (this.stats.playBurstSound || !this.stats.onSoundBegin) {
this.playSound(this.stats.fireSound, 1.5F, 1.0f);
this.stats.playBurstSound = false;
}
}
}