From 9a18eb1eaaf6420537966aa6b78cdcec6a836acd Mon Sep 17 00:00:00 2001 From: Treeku Date: Tue, 8 Apr 2014 05:06:03 +0100 Subject: [PATCH 01/13] Few command improvements --- src/services/command/CommandService.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 8e9bcf44..98116332 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -114,7 +114,7 @@ public class CommandService implements INetworkDispatch { break; case 1: // Other Only - if (target == null || target == actor) { + if (target == actor) { return false; } @@ -272,7 +272,7 @@ public class CommandService implements INetworkDispatch { boolean hasCharacterAbility = (((String) visitor.getObject(i, 7-sub)).length() > 0); - if (tableArray[n].startsWith("client_") && tableArray[n].startsWith("command_table_")) { + if (tableArray[n].startsWith("client_") || tableArray[n].startsWith("command_table_")) { sub += 7; } @@ -333,7 +333,7 @@ public class CommandService implements INetworkDispatch { boolean hasCharacterAbility = (((String) visitor.getObject(i, 7-sub)).length() > 0); - if (tableArray[n].startsWith("client_") && tableArray[n].startsWith("command_table_")) { + if (tableArray[n].startsWith("client_") || tableArray[n].startsWith("command_table_")) { sub += 7; } @@ -367,9 +367,7 @@ public class CommandService implements INetworkDispatch { } public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - if (command.getCooldown() > (float) 1) { - actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); - } + actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); From 74af0d5244da4ae7bd970d0cfb55fb94a8c26668 Mon Sep 17 00:00:00 2001 From: Treeku Date: Tue, 8 Apr 2014 05:09:18 +0100 Subject: [PATCH 02/13] Forgot safety check --- src/services/command/CommandService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 98116332..ff33d682 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -114,7 +114,7 @@ public class CommandService implements INetworkDispatch { break; case 1: // Other Only - if (target == actor) { + if (target != null && target == actor) { return false; } From caca57b9b0ab6f80e55071ec1d5fc633ace8f9fb Mon Sep 17 00:00:00 2001 From: Treeku Date: Tue, 8 Apr 2014 05:42:19 +0100 Subject: [PATCH 03/13] checkLineOfSight now checks if obj is in inventory --- src/services/SimulationService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index bf7cc26e..1b106d62 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -909,6 +909,11 @@ public class SimulationService implements INetworkDispatch { if(obj1.getPlanet() != obj2.getPlanet()) return false; + // If obj1 is an item in inventory and vice versa + if (obj1 == obj2.getGrandparent() || obj2 == obj1.getGrandparent()) { + return true; + } + if(obj1.getGrandparent() != null || obj2.getGrandparent() != null) { if(obj1.getGrandparent() == obj2.getGrandparent()) From 10e8c4050791b37a2de4c28408a4a1e203b72a61 Mon Sep 17 00:00:00 2001 From: Treeku Date: Tue, 8 Apr 2014 05:53:01 +0100 Subject: [PATCH 04/13] checkLOS checks if obj1 is container of obj2 --- src/services/SimulationService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 1b106d62..d7c05496 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -909,8 +909,8 @@ public class SimulationService implements INetworkDispatch { if(obj1.getPlanet() != obj2.getPlanet()) return false; - // If obj1 is an item in inventory and vice versa - if (obj1 == obj2.getGrandparent() || obj2 == obj1.getGrandparent()) { + // If obj1 is container of obj2 vice versa + if (obj1 == obj2.getContainer() || obj2 == obj1.getContainer() || obj1 == obj2.getGrandparent() || obj2 == obj1.getGrandparent()) { return true; } From c7ea2536208f03e816560c8bfc9ebe5d4cc82748 Mon Sep 17 00:00:00 2001 From: Treeku Date: Tue, 8 Apr 2014 05:58:04 +0100 Subject: [PATCH 05/13] Equipment cmd checks --- src/services/command/CommandService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index ff33d682..650bef26 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -114,11 +114,15 @@ public class CommandService implements INetworkDispatch { break; case 1: // Other Only - if (target != null && target == actor) { + if (target == null || target == actor) { return false; } - if (target != null && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { + if (target.getContainer() == actor || target.getGrandparent() == actor) { + break; + } + + if (actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { return false; } From 7eaed057c704ac3df53e83393059f48f69792afd Mon Sep 17 00:00:00 2001 From: Treeku Date: Tue, 8 Apr 2014 06:16:33 +0100 Subject: [PATCH 06/13] Fixed null exception --- src/services/command/CommandService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 650bef26..c6a62435 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -478,7 +478,7 @@ public class CommandService implements INetworkDispatch { return; } - if(command.getHitType() == 0 && command.getBuffNameSelf().length() > 0) { + if(command.getHitType() == 0 && command.getBuffNameSelf() != null && command.getBuffNameSelf().length() > 0) { core.combatService.doSelfBuff(attacker, weapon, command, actionCounter); return; } From f60583dff2c9acba2f62b08a9cf2fb6edd4297e9 Mon Sep 17 00:00:00 2001 From: Seefo Date: Tue, 8 Apr 2014 10:30:16 -0400 Subject: [PATCH 07/13] Temporary fix for certain commands being registered as combat commands even though the are not combat commands --- src/services/command/CommandService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index c6a62435..5470f7cb 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -350,6 +350,7 @@ public class CommandService implements INetworkDispatch { if(visitor.getObject(i, 82-sub) instanceof Boolean) isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + // "isCombatCommand" needs to be changed so that non-combat commands that are flagged to added to a combat queue are not considered combat commands if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); @@ -393,7 +394,15 @@ public class CommandService implements INetworkDispatch { //} if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) + { core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); + } + // Temporary fix for certain non-combat commands being registered as combat commands + else if(FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) + { + core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, attacker, target, commandArgs); + return; + } boolean success = true; From 2c4356188a5fefbb949b0955729872c87c3a01f1 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Tue, 8 Apr 2014 16:30:19 -0400 Subject: [PATCH 08/13] Fixed #396: Environmental Purge not granting. --- scripts/expertise/expertise_of_purge_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/expertise/expertise_of_purge_1.py b/scripts/expertise/expertise_of_purge_1.py index 36e8c855..3598d236 100644 --- a/scripts/expertise/expertise_of_purge_1.py +++ b/scripts/expertise/expertise_of_purge_1.py @@ -1,9 +1,9 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("expertise_of_purge_1") + actor.addAbility("of_purge_1") return def removeAbilities(core, actor, player): - actor.removeAbility("expertise_of_purge_1") + actor.removeAbility("of_purge_1") return From 6e84d1334102f3dc0e9741e82e853c3a96b6c28c Mon Sep 17 00:00:00 2001 From: Waverunner Date: Tue, 8 Apr 2014 19:42:38 -0400 Subject: [PATCH 09/13] Able to create a chat room now Work still needs to be done on joining the rooms. However, you can create custom rooms. --- src/protocol/swg/ChatCreateRoom.java | 29 ++++++++++++++ src/protocol/swg/ChatEnterRoomById.java | 19 ++++++--- src/protocol/swg/ChatOnCreateRoom.java | 52 +++++++++++++++++++++++-- src/protocol/swg/ChatOnEnteredRoom.java | 1 + src/services/chat/ChatService.java | 46 ++++++++++++++++++---- 5 files changed, 131 insertions(+), 16 deletions(-) diff --git a/src/protocol/swg/ChatCreateRoom.java b/src/protocol/swg/ChatCreateRoom.java index 5f63614a..640cba0e 100644 --- a/src/protocol/swg/ChatCreateRoom.java +++ b/src/protocol/swg/ChatCreateRoom.java @@ -23,11 +23,23 @@ package protocol.swg; import org.apache.mina.core.buffer.IoBuffer; + public class ChatCreateRoom extends SWGMessage { + private String address, title; + private boolean privacy, moderatorOnly; + private int request; + + public ChatCreateRoom() { } @Override public void deserialize(IoBuffer data) { + this.privacy = (boolean) ((data.get() == 1) ? false : true); + this.moderatorOnly = (boolean) ((data.get() == 1) ? true : false); + data.getShort(); // unk + this.address = getAsciiString(data); + this.title = getAsciiString(data); + this.request = data.getInt(); } @Override @@ -35,4 +47,21 @@ public class ChatCreateRoom extends SWGMessage { return null; } + public String getAddress() { + return address; + } + public String getTitle() { + return title; + } + public boolean isPrivacy() { + return privacy; + } + public boolean isModeratorOnly() { + return moderatorOnly; + } + + public int getRequest() { + return request; + } + } diff --git a/src/protocol/swg/ChatEnterRoomById.java b/src/protocol/swg/ChatEnterRoomById.java index 29fd69cd..a5b2d4c3 100644 --- a/src/protocol/swg/ChatEnterRoomById.java +++ b/src/protocol/swg/ChatEnterRoomById.java @@ -23,15 +23,24 @@ package protocol.swg; import org.apache.mina.core.buffer.IoBuffer; +import resources.common.StringUtilities; + public class ChatEnterRoomById extends SWGMessage { private int roomId; + private int requestId; public ChatEnterRoomById() { } @Override public void deserialize(IoBuffer data) { - setRoomId(data.getInt()); + StringUtilities.printBytes(data.array()); + data.getShort(); + data.getInt(); + + this.requestId = data.getInt(); + this.roomId = data.getInt(); + // getAsciiString(data); // name of the room but don't need it since we have id. } @Override @@ -39,12 +48,12 @@ public class ChatEnterRoomById extends SWGMessage { return null; } + public int getRequestId() { + return requestId; + } + public int getRoomId() { return roomId; } - public void setRoomId(int roomId) { - this.roomId = roomId; - } - } diff --git a/src/protocol/swg/ChatOnCreateRoom.java b/src/protocol/swg/ChatOnCreateRoom.java index be54a71d..0492800c 100644 --- a/src/protocol/swg/ChatOnCreateRoom.java +++ b/src/protocol/swg/ChatOnCreateRoom.java @@ -21,6 +21,10 @@ ******************************************************************************/ package protocol.swg; +import java.nio.ByteOrder; + +import main.NGECore; + import org.apache.mina.core.buffer.IoBuffer; import services.chat.ChatRoom; @@ -28,9 +32,13 @@ import services.chat.ChatRoom; public class ChatOnCreateRoom extends SWGMessage { private ChatRoom room; + private int error; + private int requestId; - public ChatOnCreateRoom(ChatRoom room) { + public ChatOnCreateRoom(ChatRoom room, int error, int requestId) { this.room = room; + this.error = error; + this.requestId = requestId; } @Override @@ -40,8 +48,46 @@ public class ChatOnCreateRoom extends SWGMessage { @Override public IoBuffer serialize() { - // TODO Auto-generated method stub - return null; + String server = NGECore.getInstance().getGalaxyName(); + IoBuffer data = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + data.setAutoExpand(true); + + data.putShort((short) 4); + data.putInt(0x35D7CC9F); + + data.putInt(error); + data.putInt(room.getRoomId()); + data.putInt(room.isPrivateRoom() ? 0 : 1); + data.put((byte) (room.isModeratorsOnly() ? 1 : 0)); + data.put(getAsciiString(room.getRoomAddress())); + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(room.getCreator())); + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(room.getOwner())); + data.put(getUnicodeString(room.getDescription())); + + data.putInt(0); + /*if (room.getModeratorList().size() > 0) { + for (CreatureObject creo : room.getModeratorList()) { + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(creo.getCustomName())); + } + }*/ + + data.putInt(0); + /*if (room.getUserList().size() > 0) { + for (CreatureObject creo : room.getUserList()) { + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(creo.getCustomName())); + } + }*/ + + data.putInt(requestId); + return data.flip(); } } diff --git a/src/protocol/swg/ChatOnEnteredRoom.java b/src/protocol/swg/ChatOnEnteredRoom.java index b040c1bf..179f981a 100644 --- a/src/protocol/swg/ChatOnEnteredRoom.java +++ b/src/protocol/swg/ChatOnEnteredRoom.java @@ -62,6 +62,7 @@ public class ChatOnEnteredRoom extends SWGMessage { buffer.put(getAsciiString(characterName)); buffer.putInt(success); buffer.putInt(roomId); + buffer.putInt(0); return buffer.flip(); } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 562686dc..8d4a159f 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -49,6 +49,7 @@ import resources.common.*; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; +import protocol.swg.ChatCreateRoom; import protocol.swg.ChatEnterRoomById; import protocol.swg.ChatOnChangeFriendStatus; import protocol.swg.ChatDeletePersistentMessage; @@ -56,6 +57,7 @@ import protocol.swg.ChatFriendsListUpdate; import protocol.swg.ChatInstantMessageToCharacter; import protocol.swg.ChatInstantMessagetoClient; import protocol.swg.ChatOnAddFriend; +import protocol.swg.ChatOnCreateRoom; import protocol.swg.ChatOnEnteredRoom; import protocol.swg.ChatOnSendInstantMessage; import protocol.swg.ChatOnSendPersistentMessage; @@ -369,13 +371,37 @@ public class ChatService implements INetworkDispatch { }); swgOpcodes.put(Opcodes.ChatCreateRoom, (session, data) -> { - //System.out.println("CREATE:"); - //StringUtilities.printBytes(data.array()); + data.order(ByteOrder.LITTLE_ENDIAN); + + Client client = core.getClient(session); + + if(client == null) + return; + + SWGObject obj = client.getParent(); + + if (obj == null) + return; + + CreatureObject creo = (CreatureObject) obj; + + ChatCreateRoom sentPacket = new ChatCreateRoom(); + sentPacket.deserialize(data); + + ChatRoom room = createChatRoom(sentPacket.getTitle(), sentPacket.getAddress(), creo.getCustomName().toLowerCase(), true, false); + room.setPrivateRoom(sentPacket.isPrivacy()); + room.setModeratorsOnly(sentPacket.isModeratorOnly()); + + if (room != null) { + room.getUserList().add(creo); + room.getModeratorList().add(creo); + ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest()); + session.write(response.serialize()); + } + }); swgOpcodes.put(Opcodes.ChatQueryRoom, (session, data) -> { - //System.out.println("QUERY: "); - //StringUtilities.printBytes(data.array()); }); swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> { @@ -408,13 +434,14 @@ public class ChatService implements INetworkDispatch { if (obj == null) return; - + data.order(ByteOrder.LITTLE_ENDIAN); + data.position(0); ChatEnterRoomById sentPacket = new ChatEnterRoomById(); sentPacket.deserialize(data); joinChatRoom((CreatureObject) obj, sentPacket.getRoomId()); - //System.out.println("Entering room..."); + System.out.println("Entering room... " + sentPacket.getRoomId()); }); } @@ -684,7 +711,7 @@ public class ChatService implements INetworkDispatch { } private void loadChatRooms() { - ChatRoom system = createChatRoom("Waves Dungeon", "ProjectSWGTest.Dungeon", "Waverunner", true); + ChatRoom system = createChatRoom("", "Chat", "system", true); chatRooms.put(system.getRoomId(), system); EntityCursor cursor = chatRoomsODB.getCursor(Integer.class, ChatRoom.class); @@ -704,7 +731,10 @@ public class ChatService implements INetworkDispatch { ChatRoom room = new ChatRoom(); room.setDescription(roomName); - room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); + if (!address.startsWith("SWG.")) + room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); + else + room.setRoomAddress(address); room.setCreator(creator); room.setOwner(creator); room.setVisible(showInList); From 46c2c1bf2c73111b09fff86e414ab4457c894127 Mon Sep 17 00:00:00 2001 From: Seefo Date: Tue, 8 Apr 2014 23:47:59 -0400 Subject: [PATCH 10/13] Preliminary housing --- scripts/commands/placestructure.py | 26 +++ .../player_house_generic_small_style_01.py | 14 ++ .../player_house_generic_small_style_01.py | 5 + .../generic_house_small_deed.py | 4 + scripts/radial/structureDeed.py | 11 ++ src/main/NGECore.java | 5 + .../EnterStructurePlacementModeMessage.java | 64 +++++++ src/services/DevService.java | 7 +- src/services/housing/HouseTemplate.java | 55 ++++++ src/services/housing/HousingService.java | 166 ++++++++++++++++++ src/services/object/ObjectService.java | 12 +- 11 files changed, 362 insertions(+), 7 deletions(-) create mode 100644 scripts/commands/placestructure.py create mode 100644 scripts/houses/player_house_generic_small_style_01.py create mode 100644 scripts/radial/structureDeed.py create mode 100644 src/protocol/swg/EnterStructurePlacementModeMessage.java create mode 100644 src/services/housing/HouseTemplate.java create mode 100644 src/services/housing/HousingService.java diff --git a/scripts/commands/placestructure.py b/scripts/commands/placestructure.py new file mode 100644 index 00000000..edddb24e --- /dev/null +++ b/scripts/commands/placestructure.py @@ -0,0 +1,26 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + cmdArgs = commandString.split(" ") + + deedId = long(cmdArgs[0]) + deed = core.objectService.getObject(deedId) + + positionX = float(cmdArgs[1]) + positionZ = float(cmdArgs[2]) + #positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2 + + rotation = float(cmdArgs[3]) + + + #structureTemplate = deed.getAttachment("structureTemplate") + + core.housingService.placeStructure(actor, deed, positionX, positionZ, rotation) + + #building = core.objectService.createObject(structureTemplate, actor.getPlanet(), positionX, positionZ, positionY); + #core.simulationService.add(building, building.getPosition().x, building.getPosition().z); + + return \ No newline at end of file diff --git a/scripts/houses/player_house_generic_small_style_01.py b/scripts/houses/player_house_generic_small_style_01.py new file mode 100644 index 00000000..95d9f2b4 --- /dev/null +++ b/scripts/houses/player_house_generic_small_style_01.py @@ -0,0 +1,14 @@ +import sys +from services.housing import HouseTemplate +from engine.resources.scene import Point3D + +def setup(core): + houseTemplate = HouseTemplate("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", "object/building/player/shared_player_house_generic_small_style_01.iff", 2) + + houseTemplate.addBuildingSign("object/tangible/sign/player/shared_house_address.iff", Point3D(1, 2, 3)) + houseTemplate.addPlaceablePlanet("tatooine") + houseTemplate.addPlaceablePlanet("corellia") + houseTemplate.addPlaceablePlanet("naboo") + + core.housingService.addHousingTemplate(houseTemplate) + return \ No newline at end of file diff --git a/scripts/object/building/player/player_house_generic_small_style_01.py b/scripts/object/building/player/player_house_generic_small_style_01.py index ccad8904..17c11b52 100644 --- a/scripts/object/building/player/player_house_generic_small_style_01.py +++ b/scripts/object/building/player/player_house_generic_small_style_01.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + sign = core.objectService.createChildObject(object, 'object/tangible/sign/player/shared_house_address.iff', -7.39, 2.36, 2, -1, 0, -1) + print(sign) + object.setAttachment("structureSign", sign) + + core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -5, 0.74, -1.81, 0.707107, -0.707107, 1) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py index ccad8904..e100519a 100644 --- a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py +++ b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structureDeed'); + return + +def use(core, actor, object): return \ No newline at end of file diff --git a/scripts/radial/structureDeed.py b/scripts/radial/structureDeed.py new file mode 100644 index 00000000..0ddee9f3 --- /dev/null +++ b/scripts/radial/structureDeed.py @@ -0,0 +1,11 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + return + +def handleSelection(core, owner, target, option): + if option == 21 and target: + core.housingService.enterStructureMode(owner, target) + return + \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 0762507f..050e213b 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -57,6 +57,7 @@ import services.DevService; import services.EntertainmentService; import services.EquipmentService; import services.GroupService; +import services.housing.HousingService; import services.InstanceService; import services.LoginService; import services.MissionService; @@ -175,6 +176,8 @@ public class NGECore { public ResourceService resourceService; public ConversationService conversationService; + + public HousingService housingService; // Login Server @@ -286,6 +289,7 @@ public class NGECore { entertainmentService = new EntertainmentService(this); devService = new DevService(this); conversationService = new ConversationService(this); + housingService = new HousingService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); @@ -449,6 +453,7 @@ public class NGECore { spawnService.loadLairGroups(); spawnService.loadSpawnAreas(); + housingService.loadHousingTemplates(); equipmentService.loadBonusSets(); retroService.run(); diff --git a/src/protocol/swg/EnterStructurePlacementModeMessage.java b/src/protocol/swg/EnterStructurePlacementModeMessage.java new file mode 100644 index 00000000..3f12cf0a --- /dev/null +++ b/src/protocol/swg/EnterStructurePlacementModeMessage.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * 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 main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import services.travel.TravelPoint; +import engine.resources.objects.SWGObject; + +@SuppressWarnings("unused") +public class EnterStructurePlacementModeMessage extends SWGMessage { + + private SWGObject deed; + private String structureTemplate; + + public EnterStructurePlacementModeMessage(SWGObject deed, String structureTemplate) { + this.deed = deed; + this.structureTemplate = structureTemplate; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(16 + structureTemplate.length()).order(ByteOrder.LITTLE_ENDIAN); + + result.putShort((short) 3); + result.putInt(0xE8A54DC1); + + result.putLong(deed.getObjectID()); + + deed.setAttachment("structureTemplate", structureTemplate); + result.put(getAsciiString(structureTemplate)); + + return result.flip(); + } + +} \ No newline at end of file diff --git a/src/services/DevService.java b/src/services/DevService.java index 0cde2b83..fe8c6e21 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -84,6 +84,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 21, "Weapons"); suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); + //suiOptions.put((long) 120, "House Deeds"); suiOptions.put((long) 110, "Survey Devices"); break; case 3: // [Items] Weapons @@ -990,8 +991,12 @@ public class DevService implements INetworkDispatch { SurveyTool solarSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_solar.iff", planet); solarSurveyTool.setCustomName("Solar Survey Device"); inventory.add(solarSurveyTool); + return; - break; + case 120: + SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); + inventory.add(houseDeed); + return; } } }); diff --git a/src/services/housing/HouseTemplate.java b/src/services/housing/HouseTemplate.java new file mode 100644 index 00000000..aaba8d7e --- /dev/null +++ b/src/services/housing/HouseTemplate.java @@ -0,0 +1,55 @@ +package services.housing; + +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import engine.resources.scene.Point3D; + +public class HouseTemplate +{ + private String deedTemplate; + private String buildingTemplate; + private int lotCost; + private Vector placeablePlanets; + private Map buildingSigns; + + public HouseTemplate(String deedTemplate, String buildingTemplate, int lotCost) + { + this.deedTemplate = deedTemplate; + this.buildingTemplate = buildingTemplate; + this.lotCost = lotCost; + this.placeablePlanets = new Vector(); + this.buildingSigns = new HashMap(); + } + + public void addBuildingSign(String signTemplate, Point3D signPosition) + { + buildingSigns.put(signTemplate, signPosition); + } + public void addPlaceablePlanet(String planetName) + { + this.placeablePlanets.add(planetName); + } + + public String getDeedTemplate() + { + return this.deedTemplate; + } + public String getBuildingTemplate() + { + return this.buildingTemplate; + } + public Map getBuildingSigns() + { + return this.buildingSigns; + } + public Vector getPlaceablePlanets() + { + return this.placeablePlanets; + } + public int getLotCost() + { + return this.lotCost; + } +} diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java new file mode 100644 index 00000000..bbeab9f9 --- /dev/null +++ b/src/services/housing/HousingService.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * 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 services.housing; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.FileVisitor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Map; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import com.sleepycat.persist.EntityCursor; + +import main.NGECore; +import protocol.swg.EnterStructurePlacementModeMessage; +import resources.objects.building.BuildingObject; +import resources.objects.creature.CreatureObject; +import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; +import services.chat.Mail; +import services.equipment.BonusSetTemplate; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class HousingService implements INetworkDispatch { + + private NGECore core; + private Map housingTemplates = new ConcurrentHashMap(); + + public HousingService(NGECore core) { + this.core = core; + core.commandService.registerCommand("placestructure"); + core.commandService.registerCommand("movefurniture"); + core.commandService.registerCommand("rotatefurniture"); + } + + public void enterStructureMode(CreatureObject player, TangibleObject deed) + { + if(housingTemplates.containsKey(deed.getTemplate())) + { + HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); + EnterStructurePlacementModeMessage packet = new EnterStructurePlacementModeMessage(deed, houseTemplate.getBuildingTemplate()); + player.getClient().getSession().write(packet.serialize()); + } + } + + public void placeStructure(final CreatureObject actor, TangibleObject deed, float positionX, float positionZ, float rotation) + { + HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); + + int structureLotCost = houseTemplate.getLotCost(); + String structureTemplate = houseTemplate.getBuildingTemplate(); + + // Lot stuff + if(actor.getAttachment("structureLots") == null) actor.setAttachment("structureLots", 10); // Temporary until better + + int playerLots = (int) actor.getAttachment("structureLots"); + if(playerLots - structureLotCost < 0) + { + actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf + return; + } + actor.setAttachment("structureLots", playerLots - structureLotCost); + + // Calculate our orientation and height + Quaternion quaternion = new Quaternion(1, 0, 0, 0); + quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * rotation), new Point3D(0, 1, 0)); + + float positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2f; + + // Create the building + BuildingObject building = (BuildingObject) core.objectService.createObject(structureTemplate, 0, actor.getPlanet(), new Point3D(positionX, positionY, positionZ), quaternion); + core.simulationService.add(building, building.getPosition().x, building.getPosition().z, true); + + // Name the sign + TangibleObject sign = (TangibleObject) building.getAttachment("structureSign"); + sign.setCustomName2(actor.getCustomName() + "'s House"); + //building.add(sign); + + core.objectService.destroyObject(deed); + + // Structure management + Vector admins = new Vector<>(); + admins.add(actor.getObjectID()); + + building.setAttachment("structureOwner", actor.getObjectID()); + building.setAttachment("structureAdmins", admins); + + // Save structure to DB + //building.createTransaction(core.getBuildingODB().getEnvironment()); + //core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction()); + //building.getTransaction().commitSync(); + } + + @SuppressWarnings("unchecked") + public boolean getPermissions(SWGObject player, SWGObject container) + { + if(((Vector) container.getContainer().getAttachment("structureAdmins")).contains(player.getObjectID())) return true; + return false; + } + + public void addHousingTemplate(HouseTemplate houseTemplate) + { + housingTemplates.put(houseTemplate.getDeedTemplate(), houseTemplate); + } + + public void loadHousingTemplates() { + Path p = Paths.get("scripts/houses/"); + FileVisitor fv = new SimpleFileVisitor() + { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException + { + System.out.println("Loading housing template " + file.getFileName()); + core.scriptService.callScript("scripts/houses/", file.getFileName().toString().replace(".py", ""), "setup", core); + return FileVisitResult.CONTINUE; + } + }; + try + { + Files.walkFileTree(p, fv); + } + catch (IOException e) { e.printStackTrace(); } + } + + + + @Override + public void insertOpcodes(Map arg0, + Map arg1) { + // TODO Auto-generated method stub + + } + + @Override + public void shutdown() { + + } +} \ No newline at end of file diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index cb85e06d..6c5a44a4 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -877,7 +877,7 @@ public class ObjectService implements INetworkDispatch { * @param position The position as an offset to the parent object. * @param orientation The orientation as an offset to the parent object. */ - public void createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) { + public SWGObject createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) { if(cellNumber == -1) { @@ -907,15 +907,15 @@ public class ObjectService implements INetworkDispatch { child.setAttachment("cellNumber", cellNumber); //core.simulationService.add(child, x, z); - + return child; } - public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) { - createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1); + public SWGObject createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) { + return createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1); } - public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) { - createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber); + public SWGObject createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) { + return createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber); } public void loadBuildoutObjects(Planet planet) throws InstantiationException, IllegalAccessException { From 8025bc7ad09d971010dd7a60cdde96c841e99a25 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 11:56:56 -0400 Subject: [PATCH 11/13] Changes to housing, added real player lot count to character sheet --- .../player_house_generic_small_style_01.py | 5 ++++ .../swg/CharacterSheetResponseMessage.java | 2 +- .../objects/creature/CreatureObject.java | 7 ++++- .../objects/player/PlayerObject.java | 30 ++++++++++++++++++- src/services/housing/HouseTemplate.java | 15 ++++++++++ src/services/housing/HousingService.java | 16 ++++++---- 6 files changed, 66 insertions(+), 9 deletions(-) diff --git a/scripts/houses/player_house_generic_small_style_01.py b/scripts/houses/player_house_generic_small_style_01.py index 95d9f2b4..3b1f0a4c 100644 --- a/scripts/houses/player_house_generic_small_style_01.py +++ b/scripts/houses/player_house_generic_small_style_01.py @@ -9,6 +9,11 @@ def setup(core): houseTemplate.addPlaceablePlanet("tatooine") houseTemplate.addPlaceablePlanet("corellia") houseTemplate.addPlaceablePlanet("naboo") + houseTemplate.addPlaceablePlanet("talus") + houseTemplate.addPlaceablePlanet("rori") + houseTemplate.addPlaceablePlanet("dantooine") + houseTemplate.addPlaceablePlanet("lok") + houseTemplate.setDefaultItemLimit(200) core.housingService.addHousingTemplate(houseTemplate) return \ No newline at end of file diff --git a/src/protocol/swg/CharacterSheetResponseMessage.java b/src/protocol/swg/CharacterSheetResponseMessage.java index 28de844d..70e14124 100644 --- a/src/protocol/swg/CharacterSheetResponseMessage.java +++ b/src/protocol/swg/CharacterSheetResponseMessage.java @@ -99,7 +99,7 @@ public class CharacterSheetResponseMessage extends SWGMessage { buffer.put(getUnicodeString(spouse)); - buffer.putInt(10); // lots remaining + buffer.putInt(creature.getPlayerObject().getLotsRemaining()); // lots remaining return buffer.flip(); } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 74b2d7f3..da90caec 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -22,7 +22,6 @@ package resources.objects.creature; import java.lang.System; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -63,6 +62,7 @@ import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; +import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -1777,6 +1777,11 @@ public class CreatureObject extends TangibleObject implements IPersistent { return 0L; } + public PlayerObject getPlayerObject() + { + return (PlayerObject) this.getSlottedObject("ghost"); + } + //public float getCooldown(String cooldownGroup) { //return ((float) getCooldown(cooldownGroup) / (float) 1000); //} diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 9448144d..1a50837d 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -45,7 +45,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=9) +@Persistent(version=10) public class PlayerObject extends IntangibleObject { // PLAY 3 @@ -127,6 +127,8 @@ public class PlayerObject extends IntangibleObject { private String holoEmote; private int holoEmoteUses; + private int lotsRemaining = 10; + @NotPersistent private PlayerMessageBuilder messageBuilder; @@ -822,4 +824,30 @@ public class PlayerObject extends IntangibleObject { public void setRecentContainer(ResourceContainerObject recentContainer) { this.recentContainer = recentContainer; } + + public void setLotsRemaining(int amount) + { + this.lotsRemaining = amount; + } + + public boolean addLots(int amount) + { + this.lotsRemaining += amount; + return true; + } + + public boolean deductLots(int amount) + { + if(this.lotsRemaining - amount > 0) + { + this.lotsRemaining -= amount; + return true; + } + return false; + } + + public int getLotsRemaining() + { + return this.lotsRemaining; + } } diff --git a/src/services/housing/HouseTemplate.java b/src/services/housing/HouseTemplate.java index aaba8d7e..fc2861df 100644 --- a/src/services/housing/HouseTemplate.java +++ b/src/services/housing/HouseTemplate.java @@ -11,6 +11,7 @@ public class HouseTemplate private String deedTemplate; private String buildingTemplate; private int lotCost; + private int defaultItemLimit; private Vector placeablePlanets; private Map buildingSigns; @@ -19,6 +20,7 @@ public class HouseTemplate this.deedTemplate = deedTemplate; this.buildingTemplate = buildingTemplate; this.lotCost = lotCost; + this.defaultItemLimit = 50; this.placeablePlanets = new Vector(); this.buildingSigns = new HashMap(); } @@ -31,6 +33,10 @@ public class HouseTemplate { this.placeablePlanets.add(planetName); } + public void setDefaultItemLimit(int itemLimit) + { + this.defaultItemLimit = itemLimit; + } public String getDeedTemplate() { @@ -48,8 +54,17 @@ public class HouseTemplate { return this.placeablePlanets; } + public boolean canBePlacedOn(String planetName) + { + if(placeablePlanets.contains(planetName)) return true; + else return false; + } public int getLotCost() { return this.lotCost; } + public int getDefaultItemLimit() + { + return this.defaultItemLimit; + } } diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index bbeab9f9..a8f2034b 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -78,16 +78,19 @@ public class HousingService implements INetworkDispatch { int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); - // Lot stuff - if(actor.getAttachment("structureLots") == null) actor.setAttachment("structureLots", 10); // Temporary until better + if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) + { + actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf + return; + } - int playerLots = (int) actor.getAttachment("structureLots"); - if(playerLots - structureLotCost < 0) + // Lot stuff + if(actor.getPlayerObject().getLotsRemaining() - structureLotCost < 0) { actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf return; } - actor.setAttachment("structureLots", playerLots - structureLotCost); + actor.getPlayerObject().deductLots(structureLotCost); // Calculate our orientation and height Quaternion quaternion = new Quaternion(1, 0, 0, 0); @@ -101,7 +104,8 @@ public class HousingService implements INetworkDispatch { // Name the sign TangibleObject sign = (TangibleObject) building.getAttachment("structureSign"); - sign.setCustomName2(actor.getCustomName() + "'s House"); + String playerFirstName = actor.getCustomName().split(" ")[0]; + sign.setCustomName2(playerFirstName + "'s House"); //building.add(sign); core.objectService.destroyObject(deed); From bf2422923597c71754f5b2a083ab5fb6827a37c9 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 13:05:36 -0400 Subject: [PATCH 12/13] Added no-build checks when placing structures --- src/services/DevService.java | 2 +- src/services/housing/HousingService.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/services/DevService.java b/src/services/DevService.java index fe8c6e21..30ee710c 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -84,8 +84,8 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 21, "Weapons"); suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); - //suiOptions.put((long) 120, "House Deeds"); suiOptions.put((long) 110, "Survey Devices"); + //suiOptions.put((long) 120, "House Deeds"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index a8f2034b..3bcc9188 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -61,13 +61,19 @@ public class HousingService implements INetworkDispatch { core.commandService.registerCommand("rotatefurniture"); } - public void enterStructureMode(CreatureObject player, TangibleObject deed) + public void enterStructureMode(CreatureObject actor, TangibleObject deed) { + if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z)) + { + actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf + return; + } + if(housingTemplates.containsKey(deed.getTemplate())) { HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); EnterStructurePlacementModeMessage packet = new EnterStructurePlacementModeMessage(deed, houseTemplate.getBuildingTemplate()); - player.getClient().getSession().write(packet.serialize()); + actor.getClient().getSession().write(packet.serialize()); } } @@ -84,6 +90,12 @@ public class HousingService implements INetworkDispatch { return; } + if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ)) + { + actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf + return; + } + // Lot stuff if(actor.getPlayerObject().getLotsRemaining() - structureLotCost < 0) { From 399cf7a5352c093d96caee3f5defa7779b4e02d3 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 16:32:15 -0400 Subject: [PATCH 13/13] Fixed combat commands and added a better check for combat commands --- src/services/command/CommandService.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 5470f7cb..efb0fd84 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -122,7 +122,7 @@ public class CommandService implements INetworkDispatch { break; } - if (actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { + if (command.getMaxRangeToTarget() != 0 && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { return false; } @@ -286,8 +286,11 @@ public class CommandService implements INetworkDispatch { boolean isCombatCommand = false; - if(visitor.getObject(i, 82-sub) instanceof Boolean) - isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + System.out.println(((String) visitor.getObject(i, 85-sub))); + + if(((String) visitor.getObject(i, 3)).equals("failSpecialAttack") || ((String) visitor.getObject(i, 85-sub)).equals("defaultattack")) + isCombatCommand = true; + if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(name.toLowerCase()); @@ -347,8 +350,8 @@ public class CommandService implements INetworkDispatch { boolean isCombatCommand = false; - if(visitor.getObject(i, 82-sub) instanceof Boolean) - isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + if(((String) visitor.getObject(i, 3)).equals("failSpecialAttack") || ((String) visitor.getObject(i, 85-sub)).equals("defaultattack")) + isCombatCommand = true; // "isCombatCommand" needs to be changed so that non-combat commands that are flagged to added to a combat queue are not considered combat commands if (hasCharacterAbility || isCombatCommand) { @@ -373,7 +376,6 @@ public class CommandService implements INetworkDispatch { public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); - if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { @@ -397,12 +399,6 @@ public class CommandService implements INetworkDispatch { { core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); } - // Temporary fix for certain non-combat commands being registered as combat commands - else if(FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) - { - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, attacker, target, commandArgs); - return; - } boolean success = true;