mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 18:05:10 +00:00
Added 9 more slots for quest kill objectives, and an option for kill quests to progress only if a player kills an NPC with that name.
Added quest interface support to get and modify data from specific quest types.
This commit is contained in:
1 parent
989effb5c5
commit
f876f13d77
15 files changed
+155
-32
No files matched your search
@@ -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))
|
||||
|
||||
@@ -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<String> list = new ArrayList<String>();
|
||||
@@ -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<String,Integer> map = new HashMap<String,Integer>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<Integer,Integer> dialogs = new HashMap<Integer,Integer>();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<String,Integer> targets = new HashMap<String,Integer>();
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -44,4 +44,6 @@ public interface IQuest {
|
||||
void save();
|
||||
|
||||
boolean getIsRepeatable();
|
||||
|
||||
IQuestInterface getQuestInterface();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
public interface IQuestDialog extends IQuestInterface {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
public interface IQuestInterface {
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
public interface IQuestKill extends IQuestInterface {
|
||||
void setTargetType(int type);
|
||||
int getTargetType();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user