From 509d32bfc14545b698debc174a82d8fa95b1dcef Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 23 Jan 2024 23:32:02 -0500 Subject: [PATCH] Add two types of Leaps -- Jump and Pounce --- src/main/java/noppes/npcs/DataAI.java | 6 +++--- src/main/java/noppes/npcs/VersionCompatibility.java | 8 +++++++- .../java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java | 4 ++-- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 8 +++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/noppes/npcs/DataAI.java b/src/main/java/noppes/npcs/DataAI.java index 7e4236374..7f4a7aa9a 100644 --- a/src/main/java/noppes/npcs/DataAI.java +++ b/src/main/java/noppes/npcs/DataAI.java @@ -26,7 +26,7 @@ public class DataAI { public boolean avoidsSun = false; public boolean returnToStart = true; public boolean directLOS = true; - public boolean canLeap = false; + public int leapType = 0; public boolean canSprint = false; public boolean stopAndInteract = true; public EnumNavType tacticalVariant = EnumNavType.Default; @@ -72,7 +72,7 @@ public class DataAI { doorInteract = compound.getInteger("DoorInteract"); findShelter = compound.getInteger("FindShelter"); directLOS = compound.getBoolean("DirectLOS"); - canLeap = compound.getBoolean("CanLeap"); + leapType = compound.getInteger("LeapType"); canSprint = compound.getBoolean("CanSprint"); canFireIndirect = compound.getInteger("FireIndirect"); useRangeMelee = compound.getInteger("RangeAndMelee"); @@ -140,7 +140,7 @@ public class DataAI { compound.setInteger("DoorInteract", doorInteract); compound.setInteger("FindShelter", findShelter); compound.setBoolean("DirectLOS", directLOS); - compound.setBoolean("CanLeap", canLeap); + compound.setInteger("LeapType", leapType); compound.setBoolean("CanSprint", canSprint); compound.setInteger("FireIndirect", canFireIndirect); compound.setInteger("RangeAndMelee", useRangeMelee); diff --git a/src/main/java/noppes/npcs/VersionCompatibility.java b/src/main/java/noppes/npcs/VersionCompatibility.java index a16e48a3d..23445f625 100644 --- a/src/main/java/noppes/npcs/VersionCompatibility.java +++ b/src/main/java/noppes/npcs/VersionCompatibility.java @@ -13,11 +13,17 @@ import java.util.Collection; import java.util.List; public class VersionCompatibility { - public static int ModRev = 21; + public static int ModRev = 22; public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ if(npc.npcVersion == ModRev) return; + if(npc.npcVersion < 22) { + if (compound.hasKey("CanLeap")) { + boolean canLeap = compound.getBoolean("CanLeap"); + compound.setInteger("LeapType", !canLeap ? 0 : 1); + } + } if(npc.npcVersion < 19) { if (compound.hasKey("CanDrown")) { compound.setInteger("DrowningType", (compound.getBoolean("CanDrown") ? 1 : 0)); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index e54840f77..6e93f7d1d 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -39,7 +39,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG addLabel(new GuiNpcLabel(11,"ai.return", guiLeft + 150, guiTop + 40)); addButton(new GuiNpcButton(6, guiLeft + 230, guiTop + 35, 60, 20, new String[]{"gui.no","gui.yes"} ,npc.ai.returnToStart ? 1:0)); addLabel(new GuiNpcLabel(17,"ai.leapattarget", guiLeft + 150, guiTop + 65)); - addButton(new GuiNpcButton(15,guiLeft + 230, guiTop + 60, 60, 20, new String[]{"gui.no", "gui.yes"} ,npc.ai.canLeap ? 1:0)); + addButton(new GuiNpcButton(15,guiLeft + 230, guiTop + 60, 60, 20, new String[]{"gui.no", "ai.jump", "ai.pounce"} ,npc.ai.leapType)); addLabel(new GuiNpcLabel(15, "ai.indirect", guiLeft + 150, guiTop + 90)); addButton(new GuiNpcButton(13, guiLeft + 230, guiTop + 85, 60, 20, new String[]{"gui.no", "gui.whendistant", "gui.whenhidden"}, ai.canFireIndirect)); addLabel(new GuiNpcLabel(16, "ai.rangemelee", guiLeft + 150, guiTop + 115)); @@ -129,7 +129,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG initGui(); } else if (button.id == 15) { - ai.canLeap = (button.getValue() == 1); + ai.leapType = (byte) button.getValue(); } else if (button.id == 16) { ai.canSprint = (button.getValue() == 1); diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index eaf41ade2..01a37ac32 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -680,7 +680,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } else if (this.ai.onAttack == 0) { - this.setCanLeap(); + this.setLeapTask(); if (this.inventory.getProjectile() == null || this.ai.useRangeMelee == 2) { System.out.println("checking this stuff"); @@ -767,8 +767,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti /* * Branch task function for leaping */ - public void setCanLeap() { - if (this.ai.canLeap) + public void setLeapTask() { + if (this.ai.leapType == 1) + this.tasks.addTask(this.taskCount++, aiLeap = new EntityAILeapAtTarget(this, 0.4F)); + if (this.ai.leapType == 2) this.tasks.addTask(this.taskCount++, aiLeap = new EntityAIPounceTarget(this)); }