From 596f14303dba038633414bb579c0e2e14a9b6eb3 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Mon, 3 Mar 2014 18:54:54 -0500 Subject: [PATCH] Added PlayerMoneyResponse/Request, started work on CommPlayerMessage --- scripts/commands/setgodmode.py | 9 +- .../combat_brawler_trandoshan_female.py | 4 +- src/protocol/swg/CommPlayerMessage.java | 89 +++++++++++++++++++ src/protocol/swg/PlayerMoneyResponse.java | 57 ++++++++++++ src/resources/common/Opcodes.java | 3 +- src/services/CharacterService.java | 9 ++ src/services/PlayerService.java | 27 ++++++ 7 files changed, 193 insertions(+), 5 deletions(-) create mode 100644 src/protocol/swg/CommPlayerMessage.java create mode 100644 src/protocol/swg/PlayerMoneyResponse.java diff --git a/scripts/commands/setgodmode.py b/scripts/commands/setgodmode.py index f6dc2f4e..3ecf3ea2 100644 --- a/scripts/commands/setgodmode.py +++ b/scripts/commands/setgodmode.py @@ -1,6 +1,6 @@ import sys from engine.resources.scene import Point3D - +from protocol.swg import CommPlayerMessage def setup(): return @@ -46,9 +46,14 @@ def run(core, actor, target, commandString): actor.sendSystemMessage('You have learned ' + arg1 + '') elif command == 'anim' and arg1: - actor.setCurrentAnimation(arg1) + actor.doSkillAnimation(arg1) actor.sendSystemMessage('Performed ' + arg1 ,0) elif command == 'changeBio' and arg1: actor.getSlottedObject('ghost').setBiography(arg1) + + elif command == 'testComm': + comm = CommPlayerMessage() + actor.getClient().getSession().write(comm.serialize()) + print ('sent comm message') return diff --git a/scripts/starter_clothing/combat_brawler_trandoshan_female.py b/scripts/starter_clothing/combat_brawler_trandoshan_female.py index 1f755bfe..6f71399c 100644 --- a/scripts/starter_clothing/combat_brawler_trandoshan_female.py +++ b/scripts/starter_clothing/combat_brawler_trandoshan_female.py @@ -1,6 +1,6 @@ import sys -def CombatBrawlerTrandoshanFemale(core, object): +def CombatBrawlerOutdoorScoutTrandoshanFemale(core, object): shirt = core.objectService.createObject('object/tangible/wearables/shirt/shared_shirt_s24.iff', object.getPlanet()) jacket = core.objectService.createObject('object/tangible/wearables/jacket/shared_jacket_s24.iff', object.getPlanet()) pants = core.objectService.createObject('object/tangible/wearables/pants/shared_pants_s25.iff', object.getPlanet()) @@ -8,4 +8,4 @@ def CombatBrawlerTrandoshanFemale(core, object): object._add(shirt) object._add(jacket) object._add(pants) - object._add(necklace) \ No newline at end of file + object._add(necklace) diff --git a/src/protocol/swg/CommPlayerMessage.java b/src/protocol/swg/CommPlayerMessage.java new file mode 100644 index 00000000..8f1e392b --- /dev/null +++ b/src/protocol/swg/CommPlayerMessage.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * 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 protocol.swg; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.common.Console; +import resources.common.StringUtilities; +import engine.resources.common.CRC; + +public class CommPlayerMessage extends SWGMessage { + + public CommPlayerMessage() { + + } + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(200).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 2); + buffer.putInt(0x594AD258); + + buffer.put((byte) 0); // aurebesh borders on comm, space version? Can cause crashes + + //buffer.putInt(0x3E46EED5); + buffer.putInt(0); // some random number, can be 0, doesn't seem to affect anything + + buffer.putInt(51); // unknown, seems to always be 51 + buffer.putInt(54); // unknown, changes for each comm message (counter?) + + buffer.putShort((short) 0); // unknonw flag, seems to do nothing + buffer.put((byte) 1); // unknown, always 0 + + buffer.putInt(0xFFFFFFFF); + + buffer.put(getAsciiString("npe_hangar_1")); // StfFile + buffer.putInt(0); // stf spacer + buffer.put(getAsciiString("droid_xp_bar")); // StfName + + buffer.putInt(0); // stf spacer + buffer.putLong(0); + buffer.putLong(0); + buffer.putLong(0); + buffer.putLong(0); // 70 bytes + buffer.putLong(0); + buffer.putLong(0); + buffer.putLong(0); + buffer.putLong(0); + buffer.put((byte) 0); + + // Officer Supply Drop: 0x3E894347 + buffer.putInt(0xF19429F0); // model crc + + buffer.put(getAsciiString("sound/vo_c3po_9a.snd")); // does not cause crash when changing to anything + + buffer.putShort((short) 0); // unk + buffer.putShort((short) 16544); // comm display time, unsure on how it's calculated + buffer.flip(); + Console.println("CPM: " + StringUtilities.bytesToHex(buffer.array())); + return buffer; + } + +} diff --git a/src/protocol/swg/PlayerMoneyResponse.java b/src/protocol/swg/PlayerMoneyResponse.java new file mode 100644 index 00000000..0438dd02 --- /dev/null +++ b/src/protocol/swg/PlayerMoneyResponse.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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 protocol.swg; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +public class PlayerMoneyResponse extends SWGMessage { + + int cash; + int bank; + + public PlayerMoneyResponse(int cash, int bank) { + this.cash = cash; + this.bank = bank; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 3); + buffer.putInt(0x367E737E); + + buffer.putInt(bank); + buffer.putInt(cash); + + buffer.flip(); + return buffer; + } + +} diff --git a/src/resources/common/Opcodes.java b/src/resources/common/Opcodes.java index 72399c5e..df9eb958 100644 --- a/src/resources/common/Opcodes.java +++ b/src/resources/common/Opcodes.java @@ -60,5 +60,6 @@ public class Opcodes { public static int FactionResponseMessage = CRC.StringtoCRC("FactionResponseMessage"); public static int SetWaypointColor = CRC.StringtoCRC("SetWaypointColor"); public static int GuildRequestMessage = CRC.StringtoCRC("GuildRequestMessage"); - + public static int PlayerMoneyRequest = CRC.StringtoCRC("PlayerMoneyRequest"); + public static int LagReport = CRC.StringtoCRC("LagReport"); } diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 57318516..ee2140cc 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -191,7 +191,16 @@ public class CharacterService implements INetworkDispatch { }); + + swgOpcodes.put(Opcodes.LagReport, new INetworkRemoteEvent() { + @Override + public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { + + } + + }); + swgOpcodes.put(Opcodes.ClientCreateCharacter, new INetworkRemoteEvent() { @Override diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 791e2056..8bb86fcd 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -42,6 +42,7 @@ import protocol.swg.ClientMfdStatusUpdateMessage; import protocol.swg.ExpertiseRequestMessage; import protocol.swg.GuildRequestMessage; import protocol.swg.GuildResponseMessage; +import protocol.swg.PlayerMoneyResponse; import protocol.swg.ServerTimeMessage; import protocol.swg.SetWaypointColor; import protocol.swg.objectControllerObjects.ChangeRoleIconChoice; @@ -274,6 +275,32 @@ public class PlayerService implements INetworkDispatch { }); + swgOpcodes.put(Opcodes.PlayerMoneyRequest, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + CreatureObject creature = (CreatureObject) player; + + if (creature == null) + return; + + PlayerMoneyResponse response = new PlayerMoneyResponse(creature.getCashCredits(), creature.getBankCredits()); + session.write(response.serialize()); + } + + }); + swgOpcodes.put(Opcodes.CmdSceneReady, new INetworkRemoteEvent() { @Override