diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index a5e620ce6..705dc2e75 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -21,7 +21,6 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.village.MerchantRecipeList; -import net.minecraftforge.event.CommandEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; @@ -43,7 +42,6 @@ import noppes.npcs.items.ItemShield; import noppes.npcs.items.ItemSoulstoneEmpty; import noppes.npcs.quests.QuestKill; import noppes.npcs.roles.RoleFollower; -import noppes.npcs.scripted.event.ForgeEvent; public class ServerEventsHandler { @@ -309,6 +307,8 @@ public class ServerEventsHandler { } String name = entityName; QuestKill quest = (QuestKill) data.quest.questInterface; + if(quest.targetType == 1 && !(entity instanceof EntityNPCInterface)) + continue; if(quest.targets.containsKey(entity.getCommandSenderName())) name = entity.getCommandSenderName(); else if(!quest.targets.containsKey(name)) diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java index a753c28bc..40a5cc9ae 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java @@ -37,29 +37,35 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi quest = (QuestKill) q.questInterface; - setBackground("menubg.png"); - xSize = 356; - ySize = 216; + setBackground("largebg.png"); + bgScale = 1.7F; + bgScaleX = 1.1F; + + xSize = 300; + ySize = 300; closeOnEsc = true; } public void initGui() { super.initGui(); + + guiTop -= 20; + int i = 0; - addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 50)); + addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 20)); for (String name : quest.targets.keySet()) { - this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name)); - this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.targets.get(name) + "")); - this.getTextField(i+3).integersOnly = true; - this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); + this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, name)); + this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, quest.targets.get(name) + "")); + this.getTextField(i+12).integersOnly = true; + this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1); i++; } - for(;i < 3; i++){ - this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, "")); - this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1")); - this.getTextField(i+3).integersOnly = true; - this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); + for(;i < 12; i++){ + this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, "")); + this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, "1")); + this.getTextField(i+12).integersOnly = true; + this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1); } Map data = EntityList.stringToClassMapping; ArrayList list = new ArrayList(); @@ -78,9 +84,13 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi scroll.setList(list); scroll.setSize(130, 198); scroll.guiLeft = guiLeft + 220; - scroll.guiTop = guiTop + 14; + scroll.guiTop = guiTop + 40; addScroll(scroll); - this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back")); + + guiTop += 50; + this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 300, 98, 20, "gui.back")); + this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs"}, quest.targetType)); + guiTop -= 50; scroll.visible = GuiNpcTextField.isFieldActive(); } @@ -90,6 +100,9 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi if (guibutton.id == 0) { close(); } + if (guibutton.id == 1) { + quest.targetType = guibutton.displayString.equals("NPCs") ? 1 : 0; + } } public void mouseClicked(int i, int j, int k) { @@ -101,18 +114,18 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id < 3) + if(guiNpcTextField.id < 12) lastSelected = guiNpcTextField; saveTargets(); } private void saveTargets(){ HashMap map = new HashMap(); - for(int i = 0; i< 3; i++){ + for(int i = 0; i< 12; i++){ String name = getTextField(i).getText(); if(name.isEmpty()) continue; - map.put(name, getTextField(i+3).getInteger()); + map.put(name, getTextField(i+12).getInteger()); } quest.targets = map; } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java index cb6e52ce0..1e896158f 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java @@ -45,7 +45,10 @@ public abstract class GuiNPCInterface extends GuiScreen public int mouseX, mouseY; public float bgScale = 1; - + public float bgScaleX = 1; + public float bgScaleY = 1; + public float bgScaleZ = 1; + public GuiNPCInterface(EntityNPCInterface npc) { this.player = Minecraft.getMinecraft().thePlayer; @@ -102,7 +105,7 @@ public abstract class GuiNPCInterface extends GuiScreen gui.setWorldAndResolution(mc, 350, 250); extra.put(gui.id, gui); } - + public void mouseClicked(int i, int j, int k) { if(AWTWindow != null) @@ -202,11 +205,11 @@ public abstract class GuiNPCInterface extends GuiScreen scrolls.put(scroll.id, scroll); } public GuiCustomScroll getScroll(int id){ - return scrolls.get(id); + return scrolls.get(id); } - + public abstract void save(); - + @Override public void drawScreen(int i, int j, float f){ if(AWTWindow != null){ @@ -223,12 +226,12 @@ public abstract class GuiNPCInterface extends GuiScreen mouseY = j; if(drawDefaultBackground && subgui == null) drawDefaultBackground(); - + if(background != null && mc.renderEngine != null){ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPushMatrix(); GL11.glTranslatef(guiLeft, guiTop, 0); - GL11.glScalef(bgScale, bgScale, bgScale); + GL11.glScalef(bgScale*bgScaleX, bgScale*bgScaleY, bgScale*bgScaleZ); mc.renderEngine.bindTexture(background); if(xSize > 256){ drawTexturedModalRect(0, 0, 0, 0, 250, ySize); diff --git a/src/main/java/noppes/npcs/controllers/Quest.java b/src/main/java/noppes/npcs/controllers/Quest.java index a290314c9..3205d3073 100644 --- a/src/main/java/noppes/npcs/controllers/Quest.java +++ b/src/main/java/noppes/npcs/controllers/Quest.java @@ -20,6 +20,7 @@ import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.handler.data.IQuest; import noppes.npcs.scripted.handler.data.IQuestCategory; +import noppes.npcs.scripted.handler.data.IQuestInterface; import noppes.npcs.scripted.handler.data.IQuestObjective; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.IPlayer; @@ -242,4 +243,8 @@ public class Quest implements ICompatibilty, IQuest { public IContainer getRewards() { return NpcAPI.Instance().getIContainer(this.rewardItems); } + + public IQuestInterface getQuestInterface(){ + return this.questInterface; + } } diff --git a/src/main/java/noppes/npcs/quests/QuestDialog.java b/src/main/java/noppes/npcs/quests/QuestDialog.java index b23f91742..6dd84633b 100644 --- a/src/main/java/noppes/npcs/quests/QuestDialog.java +++ b/src/main/java/noppes/npcs/quests/QuestDialog.java @@ -14,9 +14,10 @@ import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.handler.data.IQuestDialog; import noppes.npcs.scripted.handler.data.IQuestObjective; -public class QuestDialog extends QuestInterface{ +public class QuestDialog extends QuestInterface implements IQuestDialog { public HashMap dialogs = new HashMap(); diff --git a/src/main/java/noppes/npcs/quests/QuestInterface.java b/src/main/java/noppes/npcs/quests/QuestInterface.java index a2b192100..dd1ef4fa7 100644 --- a/src/main/java/noppes/npcs/quests/QuestInterface.java +++ b/src/main/java/noppes/npcs/quests/QuestInterface.java @@ -4,9 +4,10 @@ import java.util.Vector; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.scripted.handler.data.IQuestInterface; import noppes.npcs.scripted.handler.data.IQuestObjective; -public abstract class QuestInterface { +public abstract class QuestInterface implements IQuestInterface { public int questId; public abstract void writeEntityToNBT(NBTTagCompound compound); public abstract void readEntityFromNBT(NBTTagCompound compound); diff --git a/src/main/java/noppes/npcs/quests/QuestItem.java b/src/main/java/noppes/npcs/quests/QuestItem.java index c37e3cd88..fb3221a21 100644 --- a/src/main/java/noppes/npcs/quests/QuestItem.java +++ b/src/main/java/noppes/npcs/quests/QuestItem.java @@ -9,10 +9,11 @@ import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilServer; import noppes.npcs.NpcMiscInventory; import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.handler.data.IQuestItem; import noppes.npcs.scripted.handler.data.IQuestObjective; import noppes.npcs.util.ValueUtil; -public class QuestItem extends QuestInterface{ +public class QuestItem extends QuestInterface implements IQuestItem { public NpcMiscInventory items = new NpcMiscInventory(3); public boolean leaveItems = false; public boolean ignoreDamage = false; @@ -137,6 +138,27 @@ public class QuestItem extends QuestInterface{ return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); } + public void setLeaveItems(boolean leaveItems){ + this.leaveItems = leaveItems; + } + public boolean getLeaveItems(){ + return this.leaveItems; + } + + public void setIgnoreDamage(boolean ignoreDamage){ + this.ignoreDamage = ignoreDamage; + } + public boolean getIgnoreDamage(){ + return this.ignoreDamage; + } + + public void setIgnoreNbt(boolean ignoreNbt){ + this.ignoreNBT = ignoreNbt; + } + public boolean getIgnoreNbt(){ + return this.ignoreNBT; + } + class QuestItemObjective implements IQuestObjective { private final QuestItem parent; private final EntityPlayer player; diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index 89536bf2a..0f84bd422 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -14,19 +14,23 @@ import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.QuestData; import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.handler.data.IQuestKill; import noppes.npcs.scripted.handler.data.IQuestObjective; -public class QuestKill extends QuestInterface{ +public class QuestKill extends QuestInterface implements IQuestKill { public HashMap targets = new HashMap(); + public int targetType = 0; @Override public void readEntityFromNBT(NBTTagCompound compound) { targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10)); + targetType = compound.getInteger("TargetType"); } @Override public void writeEntityToNBT(NBTTagCompound compound) { compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets)); + compound.setInteger("TargetType",targetType); } @Override @@ -90,6 +94,18 @@ public class QuestKill extends QuestInterface{ return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); } + public void setTargetType(int type) { + if(type < 0) + type = 0; + if(type > 1) + type = 1; + + this.targetType = type; + } + public int getTargetType() { + return this.targetType; + } + class QuestKillObjective implements IQuestObjective { private final QuestKill parent; private final EntityPlayer player; diff --git a/src/main/java/noppes/npcs/quests/QuestLocation.java b/src/main/java/noppes/npcs/quests/QuestLocation.java index 17f1ce4a2..edefd2887 100644 --- a/src/main/java/noppes/npcs/quests/QuestLocation.java +++ b/src/main/java/noppes/npcs/quests/QuestLocation.java @@ -13,9 +13,10 @@ import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.QuestData; import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.handler.data.IQuestLocation; import noppes.npcs.scripted.handler.data.IQuestObjective; -public class QuestLocation extends QuestInterface{ +public class QuestLocation extends QuestInterface implements IQuestLocation { public String location = ""; public String location2 = ""; public String location3 = ""; @@ -118,6 +119,27 @@ public class QuestLocation extends QuestInterface{ return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); } + public void setLocation1(String loc1){ + this.location = loc1; + } + public String getLocation1(){ + return location; + } + + public void setLocation2(String loc2){ + this.location2 = loc2; + } + public String getLocation2(){ + return location2; + } + + public void setLocation3(String loc3){ + this.location3 = loc3; + } + public String getLocation3(){ + return location3; + } + class QuestLocationObjective implements IQuestObjective { private final QuestLocation parent; private final EntityPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuest.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuest.java index f16b7674f..bfd640ec1 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuest.java +++ b/src/main/java/noppes/npcs/scripted/handler/data/IQuest.java @@ -44,4 +44,6 @@ public interface IQuest { void save(); boolean getIsRepeatable(); + + IQuestInterface getQuestInterface(); } diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestDialog.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuestDialog.java new file mode 100644 index 000000000..1e285efc0 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/handler/data/IQuestDialog.java @@ -0,0 +1,4 @@ +package noppes.npcs.scripted.handler.data; + +public interface IQuestDialog extends IQuestInterface { +} diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java new file mode 100644 index 000000000..5edc4f1e0 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java @@ -0,0 +1,4 @@ +package noppes.npcs.scripted.handler.data; + +public interface IQuestInterface { +} diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestItem.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuestItem.java new file mode 100644 index 000000000..7adca2254 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/handler/data/IQuestItem.java @@ -0,0 +1,12 @@ +package noppes.npcs.scripted.handler.data; + +public interface IQuestItem extends IQuestInterface { + void setLeaveItems(boolean leaveItems); + boolean getLeaveItems(); + + void setIgnoreDamage(boolean ignoreDamage); + boolean getIgnoreDamage(); + + void setIgnoreNbt(boolean ignoreNbt); + boolean getIgnoreNbt(); +} diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestKill.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuestKill.java new file mode 100644 index 000000000..7193f1aa8 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/handler/data/IQuestKill.java @@ -0,0 +1,6 @@ +package noppes.npcs.scripted.handler.data; + +public interface IQuestKill extends IQuestInterface { + void setTargetType(int type); + int getTargetType(); +} diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestLocation.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuestLocation.java new file mode 100644 index 000000000..7496b81ba --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/handler/data/IQuestLocation.java @@ -0,0 +1,12 @@ +package noppes.npcs.scripted.handler.data; + +public interface IQuestLocation extends IQuestInterface { + void setLocation1(String loc1); + String getLocation1(); + + void setLocation2(String loc2); + String getLocation2(); + + void setLocation3(String loc3); + String getLocation3(); +}