diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java b/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java new file mode 100644 index 00000000..e55e0c98 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java @@ -0,0 +1,5 @@ +package protocol.swg.objectControllerObjects; + +public class NpcConversationMessage { + +} diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java new file mode 100644 index 00000000..fec41aa3 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java @@ -0,0 +1,5 @@ +package protocol.swg.objectControllerObjects; + +public class NpcConversationOptions { + +} diff --git a/src/protocol/swg/objectControllerObjects/StartNpcConversation.java b/src/protocol/swg/objectControllerObjects/StartNpcConversation.java new file mode 100644 index 00000000..a96adedf --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/StartNpcConversation.java @@ -0,0 +1,39 @@ +package protocol.swg.objectControllerObjects; + +import java.nio.ByteOrder; +import org.apache.mina.core.buffer.IoBuffer; +import resources.common.ObjControllerOpcodes; + +public class StartNpcConversation extends ObjControllerObject { + + private long npcId; + private long objectId; + + public StartNpcConversation(long objectId, long npcId) { + this.objectId = objectId; + this.npcId = npcId; + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(31).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(ObjControllerOpcodes.START_NPC_CONVERSATION); + buffer.putLong(objectId); + + buffer.putInt(0); + buffer.putLong(npcId); + buffer.putInt(0); + buffer.putShort((short) 0); + buffer.put((byte) 0); + + return buffer.flip(); + } + +} diff --git a/src/protocol/swg/objectControllerObjects/StopNpcConversation.java b/src/protocol/swg/objectControllerObjects/StopNpcConversation.java new file mode 100644 index 00000000..b3bc6947 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/StopNpcConversation.java @@ -0,0 +1,45 @@ +package protocol.swg.objectControllerObjects; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.common.ObjControllerOpcodes; + +public class StopNpcConversation extends ObjControllerObject { + + private long npcId; + private long objectId; + private String stfFile; + private String stfLabel; + + public StopNpcConversation(long objectId, long npcId, String stfFile, String stfLabel) { + this.objectId = objectId; + this.npcId = npcId; + this.stfFile = stfFile; + this.stfLabel = stfLabel; + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(40 + stfFile.length() + stfLabel.length()).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(ObjControllerOpcodes.STOP_NPC_CONVERSATION); + buffer.putLong(objectId); + + buffer.putInt(0); + buffer.putLong(npcId); + buffer.put(getAsciiString(stfFile)); + buffer.putInt(0); + buffer.put(getAsciiString(stfLabel)); + buffer.putLong(0); + + return buffer.flip(); + } +} diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index bf4edcb7..9bfbf542 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -37,4 +37,9 @@ public class ObjControllerOpcodes { public static final int ChangeRoleIconChoice = 0x4D040000; public static final int IMAGE_DESIGN_CHANGE = 0x38020000; public static final int IMAGE_DESIGN_END = 0x39020000; + public static final int NPC_CONVERSATION_MESSAGE = 0xDF000000; + public static final int START_NPC_CONVERSATION = 0xDD000000; + public static final int STOP_NPC_CONVERSATION = 0xDE000000; + public static final int NPC_CONVERSATION_OPTIONS = 0xE0000000; + } diff --git a/src/resources/common/OutOfBand.java b/src/resources/common/OutOfBand.java new file mode 100644 index 00000000..ace435f6 --- /dev/null +++ b/src/resources/common/OutOfBand.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.common; + +import java.nio.ByteOrder; +import java.util.Vector; +import resources.common.StringUtilities; +import org.apache.mina.core.buffer.IoBuffer; + +public class OutOfBand { + + private short count; + private Vector prosePackages = new Vector(); + + public void addProsePackage(ProsePackage prosePackage) { + prosePackages.add(prosePackage); + setCount((short) (getCount() + 1)); + } + + public IoBuffer serialize() { + + IoBuffer buffer = IoBuffer.allocate(50).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putInt(2); + buffer.putShort(getCount()); + + for(ProsePackage prosePackage : prosePackages) { + + buffer.put((byte) 1); + buffer.putInt(-1); + buffer.put(StringUtilities.getAsciiString(prosePackage.getStfFile())); + buffer.putInt(0); + buffer.put(StringUtilities.getAsciiString(prosePackage.getStfLabel())); + + buffer.putLong(prosePackage.getTuObjectId()); + buffer.put(StringUtilities.getAsciiString(prosePackage.getTuStfFile())); + buffer.putInt(0); + buffer.put(StringUtilities.getAsciiString(prosePackage.getTuStfLabel())); + buffer.put(StringUtilities.getUnicodeString(prosePackage.getTuCustomString())); + + buffer.putLong(prosePackage.getTtObjectId()); + buffer.put(StringUtilities.getAsciiString(prosePackage.getTtStfFile())); + buffer.putInt(0); + buffer.put(StringUtilities.getAsciiString(prosePackage.getTtStfLabel())); + buffer.put(StringUtilities.getUnicodeString(prosePackage.getTtCustomString())); + + buffer.putLong(prosePackage.getToObjectId()); + buffer.put(StringUtilities.getAsciiString(prosePackage.getToStfFile())); + buffer.putInt(0); + buffer.put(StringUtilities.getAsciiString(prosePackage.getToStfLabel())); + buffer.put(StringUtilities.getUnicodeString(prosePackage.getToCustomString())); + + buffer.putInt(prosePackage.getDiInteger()); + buffer.putFloat(prosePackage.getDfFloat()); + + buffer.put(prosePackage.getDisplayFlag()); + + int stfLength = prosePackage.getStfFile().length() + prosePackage.getStfLabel().length() + + prosePackage.getTuStfFile().length() + prosePackage.getTuStfLabel().length() + + prosePackage.getTtStfFile().length() + prosePackage.getTtStfLabel().length() + + prosePackage.getToStfFile().length() + prosePackage.getToStfLabel().length(); + + if(stfLength % 2 == 1) { + buffer.put((byte) 0); + } + + } + + setLength(buffer); + + return buffer.flip(); + } + + public void setLength(IoBuffer buffer) { + buffer.putInt(0, (buffer.position() - 4) / 2); + } + + public short getCount() { + return count; + } + + public void setCount(short count) { + this.count = count; + } + + public Vector getProsePackages() { + return prosePackages; + } + + public void setProsePackages(Vector prosePackages) { + this.prosePackages = prosePackages; + } + + + +} diff --git a/src/resources/common/ProsePackage.java b/src/resources/common/ProsePackage.java new file mode 100644 index 00000000..aab8d08c --- /dev/null +++ b/src/resources/common/ProsePackage.java @@ -0,0 +1,208 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.common; + +public class ProsePackage { + + /* + * TU = Text You + * TT = Text Target + * TO = Text Object + * DI/DF = Decimal Value + */ + + private byte displayFlag = 1; + + private String stfFile = ""; + private String stfLabel = ""; + + private long tuObjectId; + private String tuStfFile = ""; + private String tuStfLabel = ""; + private String tuCustomString = ""; + + private long ttObjectId; + private String ttStfFile = ""; + private String ttStfLabel = ""; + private String ttCustomString = ""; + + private long toObjectId; + private String toStfFile = ""; + private String toStfLabel = ""; + private String toCustomString = ""; + + private int diInteger; + private float dfFloat; + + // TODO: Add more constructors + + private ProsePackage(String stfFile, String stfLabel) { + this.stfFile = stfFile; + this.stfLabel = stfLabel; + } + + private ProsePackage(String stfFile, String stfLabel, long tuObjectId, String tuStfFile, String tuStfLabel, String tuCustomString) { + this.stfFile = stfFile; + this.stfLabel = stfLabel; + this.tuObjectId = tuObjectId; + this.tuStfFile = tuStfFile; + this.tuStfLabel = tuStfLabel; + this.tuCustomString = tuCustomString; + } + + public byte getDisplayFlag() { + return displayFlag; + } + + public void setDisplayFlag(byte displayFlag) { + this.displayFlag = displayFlag; + } + + public String getStfFile() { + return stfFile; + } + + public void setStfFile(String stfFile) { + this.stfFile = stfFile; + } + + public String getStfLabel() { + return stfLabel; + } + + public void setStfLabel(String stfLabel) { + this.stfLabel = stfLabel; + } + + public long getTuObjectId() { + return tuObjectId; + } + + public void setTuObjectId(long tuObjectId) { + this.tuObjectId = tuObjectId; + } + + public String getTuStfFile() { + return tuStfFile; + } + + public void setTuStfFile(String tuStfFile) { + this.tuStfFile = tuStfFile; + } + + public String getTuStfLabel() { + return tuStfLabel; + } + + public void setTuStfLabel(String tuStfLabel) { + this.tuStfLabel = tuStfLabel; + } + + public String getTuCustomString() { + return tuCustomString; + } + + public void setTuCustomString(String tuCustomString) { + this.tuCustomString = tuCustomString; + } + + public long getTtObjectId() { + return ttObjectId; + } + + public void setTtObjectId(long ttObjectId) { + this.ttObjectId = ttObjectId; + } + + public String getTtStfFile() { + return ttStfFile; + } + + public void setTtStfFile(String ttStfFile) { + this.ttStfFile = ttStfFile; + } + + public String getTtStfLabel() { + return ttStfLabel; + } + + public void setTtStfLabel(String ttStfLabel) { + this.ttStfLabel = ttStfLabel; + } + + public String getTtCustomString() { + return ttCustomString; + } + + public void setTtCustomString(String ttCustomString) { + this.ttCustomString = ttCustomString; + } + + public long getToObjectId() { + return toObjectId; + } + + public void setToObjectId(long toObjectId) { + this.toObjectId = toObjectId; + } + + public String getToStfFile() { + return toStfFile; + } + + public void setToStfFile(String toStfFile) { + this.toStfFile = toStfFile; + } + + public String getToStfLabel() { + return toStfLabel; + } + + public void setToStfLabel(String toStfLabel) { + this.toStfLabel = toStfLabel; + } + + public String getToCustomString() { + return toCustomString; + } + + public void setToCustomString(String toCustomString) { + this.toCustomString = toCustomString; + } + + public int getDiInteger() { + return diInteger; + } + + public void setDiInteger(int diInteger) { + this.diInteger = diInteger; + } + + public float getDfFloat() { + return dfFloat; + } + + public void setDfFloat(float dfFloat) { + this.dfFloat = dfFloat; + } + +}