From cc24adeea699a04a11cc68bfd75db5ece8774e70 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sun, 10 Nov 2013 16:33:41 -0500 Subject: [PATCH] Added BuildABuff Packet --- scripts/commands/inspire.py | 13 ++ src/main/NGECore.java | 1 + src/protocol/swg/ObjControllerMessage.java | 4 +- .../BuffBuilderChange.java | 147 ++++++++++++++++++ .../BuffBuilderStartMessage.java | 57 +++++++ .../common/ObjControllerOpcodes.java | 2 +- src/services/BuffService.java | 48 +++++- src/services/SimulationService.java | 1 + 8 files changed, 267 insertions(+), 6 deletions(-) create mode 100644 scripts/commands/inspire.py create mode 100644 src/protocol/swg/objectControllerObjects/BuffBuilderChange.java create mode 100644 src/protocol/swg/objectControllerObjects/BuffBuilderStartMessage.java diff --git a/scripts/commands/inspire.py b/scripts/commands/inspire.py new file mode 100644 index 00000000..99a03877 --- /dev/null +++ b/scripts/commands/inspire.py @@ -0,0 +1,13 @@ +from protocol.swg.objectControllerObjects import BuffBuilderStartMessage +from protocol.swg import ObjControllerMessage +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + print ('Buffing Player: ' + str(target.getObjectId())) + openBuffWindow = BuffBuilderStartMessage(actor.getObjectId(), target.getObjectId()) + objController = ObjControllerMessage(11, openBuffWindow) + actor.getClient().getSession().write(objController.serialize()) + return \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 77a22c65..7f3ceb47 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -226,6 +226,7 @@ public class NGECore { zoneDispatch.addService(mapService); zoneDispatch.addService(travelService); zoneDispatch.addService(playerService); + zoneDispatch.addService(buffService); zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT")); zoneServer.start(); diff --git a/src/protocol/swg/ObjControllerMessage.java b/src/protocol/swg/ObjControllerMessage.java index 7eda7054..2aa76b4e 100644 --- a/src/protocol/swg/ObjControllerMessage.java +++ b/src/protocol/swg/ObjControllerMessage.java @@ -53,6 +53,8 @@ public class ObjControllerMessage extends SWGMessage { public static final int SHOW_FLY_TEXT = 0x01BD; public static final int START_TASK = 0x448; public static final int ANIMATION = 0x00F2; + public static final int BUFF_BUILDER_START = 0x025C; + public static final int BUFF_BUILDER_CHANGE = 0x025A; public ObjControllerMessage() { @@ -76,7 +78,7 @@ public class ObjControllerMessage extends SWGMessage { buffer.putInt(0x80CE5E46); buffer.putInt(update); buffer.put(objControllerObject.serialize()); - + //System.out.println("OBJMSG: " + buffer.flip().getHexDump()); int size = buffer.position(); return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); } diff --git a/src/protocol/swg/objectControllerObjects/BuffBuilderChange.java b/src/protocol/swg/objectControllerObjects/BuffBuilderChange.java new file mode 100644 index 00000000..31dea901 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/BuffBuilderChange.java @@ -0,0 +1,147 @@ +package protocol.swg.objectControllerObjects; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.ObjControllerMessage; + +public class BuffBuilderChange extends ObjControllerObject { + + private long bufferId; + private long recipientId; + private int buffCost; + private int accepted; + + private long unk1; + private long unk2; + private long unk3; + + private int unkI1; + private int unkI2; + + private byte unkByte; + + public BuffBuilderChange() { + + } + + public BuffBuilderChange(long bufferId, long recipientId, int accepted, int cost) { + this.bufferId = bufferId; + this.recipientId = recipientId; + this.accepted = accepted; + this.buffCost = cost; + } + + @Override + public void deserialize(IoBuffer data) { + unk1 = data.getLong(); + unkI1 = data.getInt(); + unk2 = data.getLong(); + unk3 = data.getLong(); + unkI2 = data.getInt(); + buffCost = data.getInt(); + accepted = data.getInt(); + unkByte = data.get(); + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + + result.putInt(ObjControllerMessage.BUFF_BUILDER_CHANGE); + result.putLong(unk1); + + result.putInt(unkI1); // tickCount + result.putLong(unk2); + result.putLong(unk3); + result.putInt(unkI2); // starting time + result.putInt(buffCost); + result.putInt(accepted); + result.put(unkByte); // unk + + //return result.flip(); + return result.flip(); + } + + public long getBufferId() { + return bufferId; + } + + public void setBufferId(long bufferId) { + this.bufferId = bufferId; + } + + public long getRecipientId() { + return recipientId; + } + + public void setRecipientId(long recipientId) { + this.recipientId = recipientId; + } + + public int getBuffCost() { + return buffCost; + } + + public void setBuffCost(int buffCost) { + this.buffCost = buffCost; + } + + public int getAccepted() { + return accepted; + } + + public void setAccepted(int accepted) { + this.accepted = accepted; + } + + public long getUnk1() { + return unk1; + } + + public void setUnk1(long unk1) { + this.unk1 = unk1; + } + + public long getUnk2() { + return unk2; + } + + public void setUnk2(long unk2) { + this.unk2 = unk2; + } + + public long getUnk3() { + return unk3; + } + + public void setUnk3(long unk3) { + this.unk3 = unk3; + } + + public int getUnkI1() { + return unkI1; + } + + public void setUnkI1(int unkI1) { + this.unkI1 = unkI1; + } + + public int getUnkI2() { + return unkI2; + } + + public void setUnkI2(int unkI2) { + this.unkI2 = unkI2; + } + + public byte getUnkByte() { + return this.unkByte; + } + + public void setUnkByte(byte unkByte) { + this.unkByte = unkByte; + } + +} diff --git a/src/protocol/swg/objectControllerObjects/BuffBuilderStartMessage.java b/src/protocol/swg/objectControllerObjects/BuffBuilderStartMessage.java new file mode 100644 index 00000000..622b3b70 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/BuffBuilderStartMessage.java @@ -0,0 +1,57 @@ +package protocol.swg.objectControllerObjects; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.ObjControllerMessage; + +public class BuffBuilderStartMessage extends ObjControllerObject { + + private long objectId; + private long recieverId; + + public BuffBuilderStartMessage(long objectId, long recieverId) { + this.objectId = objectId; + this.recieverId = recieverId; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(37).order(ByteOrder.LITTLE_ENDIAN); + + //0B 00 00-00 # flag (11) + result.putInt(ObjControllerMessage.BUFF_BUILDER_START); + + result.putLong(objectId); + result.putInt(0); // tick count + result.putLong(objectId); + result.putLong(recieverId); + + + //System.out.println("BBMSG: " + result.flip().getHexDump()); + return result.flip(); + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public long getRecieverId() { + return recieverId; + } + + public void setRecieverId(long recieverId) { + this.recieverId = recieverId; + } + +} diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index beef7d8c..4b67af61 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -30,5 +30,5 @@ public class ObjControllerOpcodes { public static final int OBJECT_MENU_REQUEST = 0x46010000; public static final int SECURE_TRADE = 0x15010000; public static final int USE_STATIC_OBJECT = 0x26010000; - + public static final int BUFF_BUILDER_CHANGE = 0x5A020000; } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 0b4dbf57..9187fe37 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -21,6 +21,7 @@ ******************************************************************************/ package services; +import java.nio.ByteOrder; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -28,14 +29,25 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; + + + + + + +import org.apache.mina.core.buffer.IoBuffer; +import org.apache.mina.core.session.IoSession; + +import protocol.swg.objectControllerObjects.BuffBuilderChange; +import protocol.swg.objectControllerObjects.BuffBuilderStartMessage; +import resources.common.Console; import resources.common.FileUtilities; +import resources.common.ObjControllerOpcodes; import resources.objects.Buff; import resources.objects.DamageOverTime; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; - import main.NGECore; - import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -49,8 +61,36 @@ public class BuffService implements INetworkDispatch { } @Override - public void insertOpcodes(Map arg0, Map arg1) { - + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + // BUFF_BUILDER_CHANGE sent every time something is clicked on in the Buff Builder. It's also sent when the buff session is started. + objControllerOpcodes.put(ObjControllerOpcodes.BUFF_BUILDER_CHANGE, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + Console.println("BUFF_BUILDER_CHANGE RECIEVED"); + data.order(ByteOrder.LITTLE_ENDIAN); + + BuffBuilderChange changeMessage = new BuffBuilderChange(); + changeMessage.deserialize(data); + + //Console.println("Unknown Long 1 (objId?): " + changeMessage.getUnk1()); + //Console.println("Unknown Int 1 (tickCount?): " + changeMessage.getUnkI1()); + //Console.println("Unknown Long 2 (objId?): " + changeMessage.getUnk2()); + //Console.println("Unknown Long 3 (buff or buffer?): " + changeMessage.getUnk3()); + //Console.println("Unknown Int 2 (???): " + changeMessage.getUnkI2()); + //Console.println("Unknown Int 3 (buffCost?): " + changeMessage.getBuffCost()); + //Console.println("Unknown Int 4 (accepted?): " + changeMessage.getAccepted()); + //Console.println("Unknown Byte: " + changeMessage.getUnkByte()); + //CreatureObject player = (CreatureObject) core.objectService.getObject(changeMessage.getUnk1()); + + //if (player == null) + //return; + + //BuffBuilderStartMessage startMsg = new BuffBuilderStartMessage(changeMessage.getBufferId(), changeMessage.getUnknown()); + //player.getClient().getSession().write(startMsg.serialize()); + + } + }); } @Override diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 0ad5d5d1..5f8b3ae7 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -141,6 +141,7 @@ public class SimulationService implements INetworkDispatch { core.commandService.registerCommand("purchaseticket"); core.commandService.registerCommand("boardshuttle"); core.commandService.registerCommand("getplayerid"); + core.commandService.registerCommand("inspire"); }