mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 18:29:05 +00:00
Add a new Aim While Shooting Type
This commit is contained in:
1 parent
0877aee3e6
commit
cac5a53997
9 files changed
+52
-13
No files matched your search
@@ -49,7 +49,7 @@ public class DataStats {
|
||||
public ScriptParticle pCustom = new ScriptParticle("");
|
||||
public int pEffAmp = 0;
|
||||
public String fireSound = "random.bow";
|
||||
public boolean aimWhileShooting = false;
|
||||
public byte aimType = 0;
|
||||
public boolean projectilesKeepTerrain = false;
|
||||
|
||||
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
|
||||
@@ -110,7 +110,7 @@ public class DataStats {
|
||||
compound.setInteger("pTrail", pTrail.ordinal());
|
||||
compound.setInteger("pEffAmp", pEffAmp);
|
||||
compound.setString("FiringSound", fireSound);
|
||||
compound.setBoolean("AimWhileShooting", aimWhileShooting);
|
||||
compound.setByte("AimType", aimType);
|
||||
compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain);
|
||||
if(pTrail == EnumParticleType.Custom)
|
||||
compound.setTag("pCustom", pCustom.writeToNBT());
|
||||
@@ -176,7 +176,7 @@ public class DataStats {
|
||||
pTrail = EnumParticleType.values()[compound.getInteger("pTrail") % EnumParticleType.values().length];
|
||||
pEffAmp = compound.getInteger("pEffAmp");
|
||||
fireSound = compound.getString("FiringSound");
|
||||
aimWhileShooting = compound.getBoolean("AimWhileShooting");
|
||||
aimType = compound.getByte("AimType");
|
||||
projectilesKeepTerrain = compound.getBoolean("ProjectilesKeepTerrain");
|
||||
if(pTrail == EnumParticleType.Custom){
|
||||
pCustom = ScriptParticle.fromNBT(compound.getCompoundTag("pCustom"));
|
||||
|
||||
@@ -13,11 +13,17 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class VersionCompatibility {
|
||||
public static int ModRev = 22;
|
||||
public static int ModRev = 23;
|
||||
|
||||
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound) {
|
||||
if (npc.npcVersion == ModRev)
|
||||
return;
|
||||
if (npc.npcVersion < 23) {
|
||||
if (compound.hasKey("AimWhileShooting")) {
|
||||
boolean aimShot = compound.getBoolean("AimWhileShooting");
|
||||
compound.setInteger("AimType", !aimShot ? 0 : 1);
|
||||
}
|
||||
}
|
||||
if (npc.npcVersion < 22) {
|
||||
if (compound.hasKey("CanLeap")) {
|
||||
boolean canLeap = compound.getBoolean("CanLeap");
|
||||
|
||||
@@ -24,8 +24,12 @@ public class EntityAIAnimation extends EntityAIBase {
|
||||
if (isDead)
|
||||
return npc.currentAnimation != EnumAnimation.LYING;
|
||||
|
||||
if (npc.stats.aimWhileShooting && npc.isAttacking())
|
||||
if (npc.stats.aimType == 1 && npc.isAttacking())
|
||||
return npc.currentAnimation != EnumAnimation.AIMING;
|
||||
|
||||
if(npc.stats.aimType == 2 && npc.isAttacking() && npc.getRangedTask() != null && npc.getRangedTask().isShooting())
|
||||
return npc.currentAnimation != EnumAnimation.AIMING;
|
||||
|
||||
if (npc.ais.animationType == EnumAnimation.NONE)
|
||||
return npc.currentAnimation != EnumAnimation.NONE;
|
||||
isAttacking = npc.isAttacking();
|
||||
@@ -42,10 +46,15 @@ public class EntityAIAnimation extends EntityAIBase {
|
||||
|
||||
@Override
|
||||
public void updateTask() {
|
||||
if (npc.stats.aimWhileShooting && npc.isAttacking()) {
|
||||
if (npc.stats.aimType == 1 && npc.isAttacking()) {
|
||||
setAnimation(EnumAnimation.AIMING);
|
||||
return;
|
||||
}
|
||||
if (npc.stats.aimType == 2 && npc.isAttacking() && npc.getRangedTask() != null && npc.getRangedTask().isShooting()) {
|
||||
setAnimation(EnumAnimation.AIMING);
|
||||
return;
|
||||
}
|
||||
|
||||
EnumAnimation type = npc.ais.animationType;
|
||||
if (isDead)
|
||||
type = EnumAnimation.LYING;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class EntityAIRangedAttack extends EntityAIBase {
|
||||
private int attackTick = 0;
|
||||
private boolean hasFired = false;
|
||||
private boolean navOverride = false;
|
||||
private boolean isShooting = false;
|
||||
|
||||
public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob) {
|
||||
if (!(par1IRangedAttackMob instanceof EntityLivingBase)) {
|
||||
@@ -113,10 +114,12 @@ public class EntityAIRangedAttack extends EntityAIBase {
|
||||
if (var1 <= (double) field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) {
|
||||
if (this.field_70846_g++ <= this.entityHost.stats.burstCount) {
|
||||
this.rangedAttackTime = this.entityHost.stats.fireRate;
|
||||
this.isShooting = true;
|
||||
} else {
|
||||
this.field_70846_g = 0;
|
||||
this.hasFired = true;
|
||||
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
|
||||
this.isShooting = false;
|
||||
}
|
||||
|
||||
if (this.field_70846_g > 1) {
|
||||
@@ -143,6 +146,10 @@ public class EntityAIRangedAttack extends EntityAIBase {
|
||||
return this.hasFired;
|
||||
}
|
||||
|
||||
public boolean isShooting() {
|
||||
return this.isShooting;
|
||||
}
|
||||
|
||||
public void navOverride(boolean nav) {
|
||||
this.navOverride = nav;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
|
||||
@@ -61,7 +61,7 @@ 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 GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting));
|
||||
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));
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
||||
@@ -107,7 +107,7 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
||||
if (id == 66) {
|
||||
close();
|
||||
} else if (id == 9) {
|
||||
stats.aimWhileShooting = ((GuiNpcButtonYesNo) guibutton).getBoolean();
|
||||
stats.aimType = (byte) ((GuiNpcButton) guibutton).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.scripted.ScriptParticle;
|
||||
|
||||
@@ -20,7 +21,6 @@ public class SubGuiScriptParticle extends SubGuiInterface implements ITextfieldL
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int y = guiTop + 10;
|
||||
// Directory (long textfield)
|
||||
addLabel(new GuiNpcLabel(1, "display.texture", guiLeft + 5, y));
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 70, y - 5, 260, 20, particle.directory));
|
||||
|
||||
@@ -104,4 +104,10 @@ public class SubGuiScriptParticle extends SubGuiInterface implements ITextfieldL
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(){
|
||||
GuiNpcTextField.unfocus();
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
@@ -519,11 +519,21 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
}
|
||||
|
||||
public boolean canAimWhileShooting() {
|
||||
return !npc.stats.aimWhileShooting;
|
||||
return npc.stats.aimType == 1;
|
||||
}
|
||||
|
||||
public void aimWhileShooting(boolean aimWhileShooting) {
|
||||
npc.stats.aimWhileShooting = aimWhileShooting;
|
||||
public void aimWhileShooting(boolean aimWhileShooting){
|
||||
npc.stats.aimType = (byte) (aimWhileShooting ? 1 : 0);
|
||||
}
|
||||
|
||||
public void setAimType(byte aimWhileShooting) {
|
||||
if(aimWhileShooting < 0 || aimWhileShooting > 2)
|
||||
return;
|
||||
npc.stats.aimType = aimWhileShooting;
|
||||
}
|
||||
|
||||
public byte getAimType() {
|
||||
return npc.stats.aimType;
|
||||
}
|
||||
|
||||
public void setMinProjectileDelay(int minDelay) {
|
||||
|
||||
Reference in new issue
Block a user