diff --git a/README.md b/README.md index 783721b1..c138cb9e 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Then export the following folders to your clientdata folder(should be located in - snapshot - terrain +Export the same folders from sku1_client.toc, sku2_client.toc and sku3_client.toc to avoid errors with kashyyyk. + Now you're ready to run the core! Contributing and Submitting patches diff --git a/scripts/buffs/proc_old_light_jedi_gift.py b/scripts/buffs/proc_old_light_jedi_gift.py new file mode 100644 index 00000000..e09c02e5 --- /dev/null +++ b/scripts/buffs/proc_old_light_jedi_gift.py @@ -0,0 +1,8 @@ +import sys + +def setup(core, actor, buff): + return + +def removeBuff(core, actor, buff): + return + \ No newline at end of file diff --git a/scripts/commands/requestwaypointatposition.py b/scripts/commands/requestwaypointatposition.py new file mode 100644 index 00000000..98c3fd2d --- /dev/null +++ b/scripts/commands/requestwaypointatposition.py @@ -0,0 +1,14 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + commandArgs = commandString.split("(^-,=+_)color_13548(,+-=_^)=1") + + newString = commandArgs[1] + print (newString) + cmdService = core.commandService + cmdService.callCommand(actor, 'waypoint', None, newString) # No need to re-create a script + return \ No newline at end of file diff --git a/scripts/commands/waypoint.py b/scripts/commands/waypoint.py index ab3b56a1..5e2802c4 100644 --- a/scripts/commands/waypoint.py +++ b/scripts/commands/waypoint.py @@ -67,6 +67,24 @@ def run(core, actor, target, commandString): actorPlayer.waypointAdd(waypoint) actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0) return + + #/wp planet x z y name + elif len(commandArgs) >= 3 and isFloat(commandArgs[2]) and isFloat(commandArgs[3]) and isFloat(commandArgs[4]): + waypoint = core.objectService.createObject('object/waypoint/shared_waypoint.iff', core.terrainService.getPlanetByName(commandArgs[1]), float(commandArgs[2]), float(commandArgs[4]), float(commandArgs[3])) + waypoint.setActive(True) + waypoint.setColor(WaypointObject.BLUE) + name = commandString.split(" ", 5) + print (name) + if name == "": + name = "Waypoint" + + waypoint.setName(name[5]) + waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName())) + actorPlayer.getWaypoints().add(waypoint) + actorPlayer.waypointAdd(waypoint) + actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0) + return + #/wp NAME else: waypoint = core.objectService.createObject('object/waypoint/shared_waypoint.iff', actor.getPlanet(), actor.getWorldPosition().x, actor.getWorldPosition().z, actor.getWorldPosition().y) diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s01.py b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s01.py index ccad8904..1d64fa57 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s01.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s01.py @@ -1,4 +1,18 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 100) + core.skillModService.addSkillMod(actor, 'precision_modified', 100) + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 100) + core.skillModService.deductSkillMod(actor, 'precision_modified', 100) + + + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s02.py b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s02.py index ccad8904..0a02012a 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s02.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s02.py @@ -1,4 +1,18 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 145) + core.skillModService.addSkillMod(actor, 'precision_modified', 145) + + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 145) + core.skillModService.deductSkillMod(actor, 'precision_modified', 145) + + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s03.py b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s03.py index ccad8904..9a627b3b 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s03.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s03.py @@ -1,4 +1,19 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 185) + core.skillModService.addSkillMod(actor, 'precision_modified', 185) + core.skillModService.addSkillMod(actor, 'luck_modified', 185) + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 185) + core.skillModService.deductSkillMod(actor, 'precision_modified', 185) + core.skillModService.deductSkillMod(actor, 'luck_modified', 185) + + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s04.py b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s04.py index ccad8904..8c145ab4 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s04.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s04.py @@ -1,4 +1,31 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 250) + core.skillModService.addSkillMod(actor, 'precision_modified', 250) + core.skillModService.addSkillMod(actor, 'luck_modified', 250) + + Buff = actor.getBuffByName('proc_old_dark_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + + if actor: + core.buffService.addBuffToCreature(actor, 'proc_old_dark_jedi_gift') + return + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 250) + core.skillModService.deductSkillMod(actor, 'precision_modified', 250) + core.skillModService.deductSkillMod(actor, 'luck_modified', 250) + + Buff = actor.getBuffByName('proc_old_dark_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_light_s01.py b/scripts/object/tangible/wearables/robe/robe_jedi_light_s01.py index ccad8904..639eac05 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_light_s01.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_light_s01.py @@ -1,4 +1,18 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 100) + core.skillModService.addSkillMod(actor, 'strength_modified', 100) + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 100) + core.skillModService.deductSkillMod(actor, 'strength_modified', 100) + + + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_light_s02.py b/scripts/object/tangible/wearables/robe/robe_jedi_light_s02.py index ccad8904..9db15ef9 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_light_s02.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_light_s02.py @@ -1,4 +1,18 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 145) + core.skillModService.addSkillMod(actor, 'strength_modified', 145) + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 145) + core.skillModService.deductSkillMod(actor, 'strength_modified', 145) + + + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_light_s03.py b/scripts/object/tangible/wearables/robe/robe_jedi_light_s03.py index ccad8904..6a546a09 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_light_s03.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_light_s03.py @@ -1,4 +1,19 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'agility_modified', 185) + core.skillModService.addSkillMod(actor, 'constitution_modified', 185) + core.skillModService.addSkillMod(actor, 'strength_modified', 185) + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'agility_modified', 185) + core.skillModService.deductSkillMod(actor, 'constitution_modified', 185) + core.skillModService.deductSkillMod(actor, 'strength_modified', 185) + + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_light_s04.py b/scripts/object/tangible/wearables/robe/robe_jedi_light_s04.py index ccad8904..be022790 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_light_s04.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_light_s04.py @@ -1,4 +1,31 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'agility_modified', 250) + core.skillModService.addSkillMod(actor, 'constitution_modified', 250) + core.skillModService.addSkillMod(actor, 'strength_modified', 250) + + Buff = actor.getBuffByName('proc_old_light_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + + if actor: + core.buffService.addBuffToCreature(actor, 'proc_old_light_jedi_gift') + return + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'agility_modified', 250) + core.skillModService.deductSkillMod(actor, 'constitution_modified', 250) + core.skillModService.deductSkillMod(actor, 'strength_modified', 250) + + Buff = actor.getBuffByName('proc_old_light_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + return + \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_light_s05.py b/scripts/object/tangible/wearables/robe/robe_jedi_light_s05.py index ccad8904..9c60f170 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_light_s05.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_light_s05.py @@ -1,4 +1,34 @@ import sys +def setup(core, object): + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'agility_modified', 250) + core.skillModService.addSkillMod(actor, 'constitution_modified', 250) + core.skillModService.addSkillMod(actor, 'strength_modified', 250) + + Buff = actor.getBuffByName('proc_old_light_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + + if actor: + core.buffService.addBuffToCreature(actor, 'proc_old_light_jedi_gift') + return + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'agility_modified', 250) + core.skillModService.deductSkillMod(actor, 'constitution_modified', 250) + core.skillModService.deductSkillMod(actor, 'strength_modified', 250) + + Buff = actor.getBuffByName('proc_old_light_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + return + import sys + def setup(core, object): return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_padawan.py b/scripts/object/tangible/wearables/robe/robe_jedi_padawan.py index ccad8904..6a0ba95d 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_padawan.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_padawan.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'agility_modified', 21) + + return + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'agility_modified', 21) + + return + \ No newline at end of file diff --git a/scripts/radial/default.py b/scripts/radial/default.py index 572f253b..94d4e810 100644 --- a/scripts/radial/default.py +++ b/scripts/radial/default.py @@ -2,8 +2,12 @@ from resources.common import RadialOptions import sys def createRadial(core, owner, target, radials): + radials.add(RadialOptions(0, 21, 1, '')) + radials.add(RadialOptions(0, 7, 1, '')) return def handleSelection(core, owner, target, option): + if option == 21 and target: + core.objectService.useObject(owner, target) return \ No newline at end of file diff --git a/scripts/static_map_locations.py b/scripts/static_map_locations.py index 62070749..c0d85263 100644 --- a/scripts/static_map_locations.py +++ b/scripts/static_map_locations.py @@ -74,7 +74,7 @@ def nabooLocations(core, planet): mapService.addLocation(planet, 'Theed', -5488, 4380, 17, 0, 0) mapService.addLocation(planet, 'Keren', 1888, 2700, 17, 0, 0) mapService.addLocation(planet, 'Moenia', 4836, -4830.5, 17, 0, 0) - mapService.addLocation(planet, 'Deeja Peek', 4686, -1375, 17, 0, 0) + mapService.addLocation(planet, 'Deeja Peak', 4686, -1375, 17, 0, 0) mapService.addLocation(planet, 'Kaadara', 5288, 6687, 17, 0, 0) def roriLocations(core, planet): diff --git a/src/protocol/swg/objectControllerObjects/MissionListRequest.java b/src/protocol/swg/objectControllerObjects/MissionListRequest.java new file mode 100644 index 00000000..1cafd618 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/MissionListRequest.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * 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.objectControllerObjects; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.ObjControllerMessage; +import resources.common.Console; +import resources.common.StringUtilities; + +public class MissionListRequest extends ObjControllerObject { + + private long objectId; + private long terminalId; + private int tickCount; + + @Override + public void deserialize(IoBuffer data) { + Console.println("MissionListRequest: " + StringUtilities.bytesToHex(data.array())); + setObjectId(data.getLong()); + data.get(); // unk byte + setTickCount(data.get()); + setTerminalId(data.getLong()); + } + + @Override + public IoBuffer serialize() { + return null; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public long getTerminalId() { + return terminalId; + } + + public void setTerminalId(long terminalId) { + this.terminalId = terminalId; + } + + public int getTickCount() { + return tickCount; + } + + public void setTickCount(int tickCount) { + this.tickCount = tickCount; + } + +} diff --git a/src/resources/common/Difficulty.java b/src/resources/common/Difficulty.java new file mode 100644 index 00000000..e1229723 --- /dev/null +++ b/src/resources/common/Difficulty.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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 Difficulty { + + public static byte NORMAL = 0; // Normal + public static byte ELITE = 1; // Elite + public static byte BOSS = 2; // Gold elite + +} diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index 9e66c155..17c9784c 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -26,10 +26,11 @@ public class ObjControllerOpcodes { public static final int DATA_TRANSFORM = 0x71000000; public static final int DATA_TRANSFORM_WITH_PARENT = 0xF1000000; public static final int COMMAND_QUEUE_ENQUEUE = 0x16010000; - public static final int TARGET_UPDATE = 0x26010000; + public static final int HOVER_TARGET = 0x26010000; + public static final int TARGET_UPDATE = 0xC5040000; public static final int OBJECT_MENU_REQUEST = 0x46010000; public static final int SECURE_TRADE = 0x15010000; - public static final int USE_OBJECT = 0xC5040000; public static final int BUFF_BUILDER_CHANGE = 0x5A020000; + public static final int MISSION_LIST_REQUEST = 0x5F000000; } diff --git a/src/resources/common/Options.java b/src/resources/common/Options.java index 136c7462..5b8faa0e 100644 --- a/src/resources/common/Options.java +++ b/src/resources/common/Options.java @@ -25,7 +25,7 @@ public class Options { // Any uncommented ones are confirmed correct for NGE with detailed analysis - public static int NONE = 0; + public static int NONE = 0; // HAM is visible, but health is grey without the Attackable flag public static int SPACE_ATTACKABLE = 1; // Ships that are attackable in space. Includes everything except stations and asteroids so far public static int USABLE = 2; // Vendors, collections (hand icon) public static int INSURED = 4; // Unused in NGE diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index ac7ceac5..90ed5851 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -366,8 +366,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(1); } - - buffer.putShort((short) 0); + + buffer.put((byte) 0); + buffer.put(creature.getDifficulty()); buffer.putInt(0xFFFFFFFF); buffer.put((byte) 1); buffer.putShort((short) 0); @@ -982,6 +983,15 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } + public IoBuffer buildDifficultyDelta(byte difficulty) { + IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.put(difficulty); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1C, buffer, size + 4); + return buffer; + } + @Override public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { // TODO Auto-generated method stub diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 1e964681..ea367d8f 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -45,7 +45,6 @@ import engine.clients.Client; import resources.objects.Buff; import resources.objects.DamageOverTime; import resources.objects.SWGList; -import engine.resources.common.CRC; import engine.resources.objects.IPersistent; import engine.resources.objects.MissionCriticalObject; import engine.resources.objects.SWGObject; @@ -56,7 +55,7 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=2) +@Entity(version=3) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -131,6 +130,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { private SWGList buffList = new SWGList(); @NotPersistent private int buffListUpdateCounter = 0; + private byte difficulty = 0; private SWGList appearanceEquipmentList; @NotPersistent private int appearanceEquipmentListUpdateCounter = 0; @@ -278,12 +278,24 @@ public class CreatureObject extends TangibleObject implements IPersistent { } + public void setOptions(int options, boolean add) { + synchronized(objectMutex) { + if (options != 0) { + if (add) { + addOption(options); + } else { + removeOption(options); + } + } + } + } + public void addOption(int option) { - setOptionsBitmask(getOptionsBitmask() & option); + setOptionsBitmask(getOptionsBitmask() | option); } public void removeOption(int option) { - setOptionsBitmask(getOptionsBitmask() |~ option); + setOptionsBitmask(getOptionsBitmask() & ~option); } public byte getPosture() { @@ -1309,4 +1321,18 @@ public class CreatureObject extends TangibleObject implements IPersistent { notifyObservers(new UpdatePVPStatusMessage(getObjectID(), getPvPBitmask(), getFaction()), false); } + public byte getDifficulty() { + synchronized(objectMutex) { + return difficulty; + } + } + + public void setDifficulty(byte difficulty) { + synchronized(objectMutex) { + this.difficulty = difficulty; + } + + notifyObservers(messageBuilder.buildDifficultyDelta(difficulty), true); + } + } diff --git a/src/resources/objects/mission/MissionMessageBuilder.java b/src/resources/objects/mission/MissionMessageBuilder.java index 90c78dfe..8e206c01 100644 --- a/src/resources/objects/mission/MissionMessageBuilder.java +++ b/src/resources/objects/mission/MissionMessageBuilder.java @@ -21,6 +21,126 @@ ******************************************************************************/ package resources.objects.mission; -public class MissionMessageBuilder { +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.common.CRC; +import resources.objects.ObjectMessageBuilder; +import resources.objects.waypoint.WaypointObject; + +public class MissionMessageBuilder extends ObjectMessageBuilder { + + public MissionMessageBuilder(MissionObject missionObject) { + setObject(missionObject); + } + + public IoBuffer buildBaseline3() { + MissionObject mission = (MissionObject) object; + IoBuffer buffer = IoBuffer.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 11); + + buffer.putFloat(mission.getMissionComplexity()); + buffer.put(getAsciiString("mission/mission_object")); + buffer.putInt(0); + buffer.put(getAsciiString(mission.getStfName())); + + if (mission.getCustomName() == null) { buffer.put(getUnicodeString("")); } + else { buffer.put(getUnicodeString(mission.getCustomName())); } + + buffer.putInt(mission.getVolume()); + buffer.putInt(0); // unused + buffer.putInt(mission.getMissionLevel()); + + buffer.putFloat(mission.getMissionStartX()); + buffer.putFloat(0); // missionStartZ + buffer.putFloat(mission.getMissionStartY()); + + buffer.putLong(0); // ?? + + buffer.putInt(CRC.StringtoCRC(mission.getMissionStartPlanet())); + + buffer.put(getUnicodeString(mission.getMissionCreator())); + buffer.putInt(mission.getMissionCredits()); + + buffer.putFloat(mission.getMissionDestinationX()); + buffer.putFloat(0); // missionDestinationZ + buffer.putFloat(mission.getMissionDestinationY()); + + buffer.putLong(0); // ?? + + buffer.putInt(CRC.StringtoCRC(mission.getMissionDestinationPlanet())); + + buffer.putInt(CRC.StringtoCRC(mission.getMissionTemplateObject())); + + buffer.put(getAsciiString(mission.getMissionDescription())); + buffer.putInt(0); + buffer.put(getAsciiString(mission.getMissionDescId())); + + buffer.put(getAsciiString(mission.getMissionTitle())); + buffer.putInt(0); + buffer.put(getAsciiString(mission.getMissionTitleId())); + + buffer.putInt(0); // refresh counter + + buffer.putInt(CRC.StringtoCRC(mission.getMissionType())); + + buffer.put(getAsciiString(mission.getMissionTargetName())); + + WaypointObject wp = mission.getMissionAttachedWaypoint(); + + if (wp == null) { + buffer.putInt(0); + buffer.putFloat(0); // x + buffer.putFloat(0); // z + buffer.putFloat(0); // y + buffer.putLong(0); // target id + buffer.putInt(0); // planet crc + buffer.put(getUnicodeString("")); + buffer.putLong(0); // waypoint id + buffer.put((byte) 0); // color + buffer.put((byte) 0x01); //active + } else { + buffer.putInt(wp.getCellId()); + buffer.putFloat(wp.getPosition().x); + buffer.putFloat(wp.getPosition().z); + buffer.putFloat(wp.getPosition().y); + buffer.putLong(0); + buffer.putInt(CRC.StringtoCRC(wp.getPlanet().name)); + } + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("MISO", (byte) 3, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline6() { + + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(121); // unk + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("MISO", (byte) 6, buffer, size); + + return buffer; + } + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + + } + + @Override + public void sendBaselines() { + + } } diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index 57c7540e..3cbde103 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -21,6 +21,269 @@ ******************************************************************************/ package resources.objects.mission; -public class MissionObject { +import com.sleepycat.je.Environment; +import com.sleepycat.je.Transaction; +import com.sleepycat.persist.model.NotPersistent; + +import resources.objects.tangible.TangibleObject; +import resources.objects.waypoint.WaypointObject; +import engine.clients.Client; +import engine.resources.objects.IPersistent; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + +public class MissionObject extends SWGObject implements IPersistent { + + private String stfName; + private String customName; + private int volume; + + private float missionComplexity; + private float missionDestinationX; + private float missionDestinationY; + private float missionDestinationZ; + private float missionStartX; + private float missionStartY; + private float missionStartZ; + private String missionStartPlanet; + private int missionLevel; // Difficulty level displayed in details + private String missionDestinationPlanet; + private int missionRepeatCounter; // increases for each player using the mission; used for redisplaying on mission term too + private int missionCredits; + private String missionCreator; + private String missionDescription; + private String missionTitle; + private String missionTargetName; // target/destination + private String missionDescId; + private String missionTitleId; + private String missionType; + private WaypointObject missionAttachedWaypoint; + + private String missionTemplateObject; + + @NotPersistent + MissionMessageBuilder messageBuilder = new MissionMessageBuilder(this); + + @NotPersistent + private Transaction txn; + + + public MissionObject(long objectID, Planet planet, String template) { + super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), template); + } + + public String getStfName() { + return stfName; + } + + public void setStfName(String stfName) { + this.stfName = stfName; + } + + public String getCustomName() { + return customName; + } + + public void setCustomName(String customName) { + this.customName = customName; + } + + public int getVolume() { + return volume; + } + + public void setVolume(int volume) { + this.volume = volume; + } + + public float getMissionComplexity() { + return missionComplexity; + } + + public void setMissionComplexity(float missionComplexity) { + this.missionComplexity = missionComplexity; + } + + public float getMissionStartX() { + return missionStartX; + } + + public void setMissionStartX(float missionStartX) { + this.missionStartX = missionStartX; + } + + public float getMissionStartY() { + return missionStartY; + } + + public void setMissionStartY(float missionStartY) { + this.missionStartY = missionStartY; + } + + public float getMissionStartZ() { + return missionStartZ; + } + + public void setMissionStartZ(float missionStartZ) { + this.missionStartZ = missionStartZ; + } + + public float getMissionDestinationX() { + return missionDestinationX; + } + + public void setMissionDestinationX(float missionDestinationX) { + this.missionDestinationX = missionDestinationX; + } + + public float getMissionDestinationY() { + return missionDestinationY; + } + + public void setMissionDestinationY(float missionDestinationY) { + this.missionDestinationY = missionDestinationY; + } + + public float getMissionDestinationZ() { + return missionDestinationZ; + } + + public void setMissionDestinationZ(float missionDestinationZ) { + this.missionDestinationZ = missionDestinationZ; + } + + public String getMissionDestinationPlanet() { + return missionDestinationPlanet; + } + + public void setMissionDestinationPlanet(String missionDestinationPlanet) { + this.missionDestinationPlanet = missionDestinationPlanet; + } + + public int getMissionLevel() { + return missionLevel; + } + + public void setMissionLevel(int missionLevel) { + this.missionLevel = missionLevel; + } + + public String getMissionStartPlanet() { + return missionStartPlanet; + } + + public void setMissionStartPlanet(String missionStartPlanetCRC) { + this.missionStartPlanet = missionStartPlanetCRC; + } + + public int getMissionRepeatCounter() { + return missionRepeatCounter; + } + + public void setMissionRepeatCounter(int missionRepeatCounter) { + this.missionRepeatCounter = missionRepeatCounter; + } + + public int getMissionCredits() { + return missionCredits; + } + + public void setMissionCredits(int missionCredits) { + this.missionCredits = missionCredits; + } + + public String getMissionCreator() { + return missionCreator; + } + + public void setMissionCreator(String missionCreator) { + this.missionCreator = missionCreator; + } + + public String getMissionDescription() { + return missionDescription; + } + + public void setMissionDescription(String missionDescription) { + this.missionDescription = missionDescription; + } + + public String getMissionTitle() { + return missionTitle; + } + + public void setMissionTitle(String missionTitle) { + this.missionTitle = missionTitle; + } + + public String getMissionTargetName() { + return missionTargetName; + } + + public void setMissionTargetName(String missionTargetName) { + this.missionTargetName = missionTargetName; + } + + public WaypointObject getMissionAttachedWaypoint() { + return missionAttachedWaypoint; + } + + public void setMissionAttachedWaypoint(WaypointObject missionAttachedWaypoint) { + this.missionAttachedWaypoint = missionAttachedWaypoint; + } + + public String getMissionTemplateObject() { + return missionTemplateObject; + } + + public void setMissionTemplateObject(String missionTemplateObject) { + this.missionTemplateObject = missionTemplateObject; + } + + public String getMissionDescId() { + return missionDescId; + } + + public void setMissionDescId(String missionDescId) { + this.missionDescId = missionDescId; + } + + public String getMissionTitleId() { + return missionTitleId; + } + + public void setMissionTitleId(String missionTitleId) { + this.missionTitleId = missionTitleId; + } + + public String getMissionType() { + return missionType; + } + + public void setMissionType(String missionType) { + this.missionType = missionType; + } + + public Transaction getTransaction() { + return txn; + } + + public void createTransaction(Environment env) { + txn = env.beginTransaction(null, null); + } + + @Override + public void sendBaselines(Client destination) { + + if(destination == null || destination.getSession() == null) { + System.out.println("NULL session"); + return; + } + + destination.getSession().write(messageBuilder.buildBaseline3()); + destination.getSession().write(messageBuilder.buildBaseline6()); + } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 7a1ae89d..5a9a56f6 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -137,6 +137,26 @@ public class TangibleObject extends SWGObject { this.optionsBitmask = optionsBitmask; } + public void setOptions(int options, boolean add) { + synchronized(objectMutex) { + if (options != 0) { + if (add) { + addOption(options); + } else { + removeOption(options); + } + } + } + } + + public void addOption(int option) { + setOptionsBitmask(getOptionsBitmask() | option); + } + + public void removeOption(int option) { + setOptionsBitmask(getOptionsBitmask() & ~option); + } + public int getMaxDamage() { return maxDamage; } diff --git a/src/services/MissionService.java b/src/services/MissionService.java new file mode 100644 index 00000000..d376f698 --- /dev/null +++ b/src/services/MissionService.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * 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; + +import java.util.Map; + +import org.apache.mina.core.buffer.IoBuffer; +import org.apache.mina.core.session.IoSession; + +import resources.common.ObjControllerOpcodes; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class MissionService implements INetworkDispatch { + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + objControllerOpcodes.put(ObjControllerOpcodes.MISSION_LIST_REQUEST, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + + } + + }); + } + + @Override + public void shutdown() { + + } + +} diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 0c441fe6..31ee4181 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -145,6 +145,7 @@ public class SimulationService implements INetworkDispatch { core.commandService.registerCommand("getplayerid"); core.commandService.registerCommand("inspire"); core.commandService.registerCommand("setgodmode"); + core.commandService.registerCommand("requestwaypointatposition"); } diff --git a/src/services/SkillService.java b/src/services/SkillService.java index a6cd92c4..da016e3a 100644 --- a/src/services/SkillService.java +++ b/src/services/SkillService.java @@ -178,7 +178,7 @@ public class SkillService implements INetworkDispatch { PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); DatatableVisitor skillTable; - if (creature.getClient() == null) { + if (player == null) { return; } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 27d19d93..b08ad2f9 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -76,6 +76,7 @@ import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.guild.GuildObject; +import resources.objects.mission.MissionObject; import resources.objects.player.PlayerObject; import resources.objects.staticobject.StaticObject; import resources.objects.tangible.TangibleObject; @@ -203,7 +204,11 @@ public class ObjectService implements INetworkDispatch { object = new WaypointObject(objectID, planet, position); - } else { + } else if(Template.startsWith("object/mission")) { + + object = new MissionObject(objectID, planet, Template); + + } else { return null; @@ -214,7 +219,7 @@ public class ObjectService implements INetworkDispatch { object.setAttachment("serverTemplate", ((customServerTemplate != null) ? customServerTemplate : object.getTemplate())); object.setisInSnapshot(isSnapshot); - //loadServerTemplate(object); + loadServerTemplate(object); objectList.put(objectID, object); @@ -567,32 +572,6 @@ public class ObjectService implements INetworkDispatch { }); - /* - objControllerOpcodes.put(ObjControllerOpcodes.USE_OBJECT, new INetworkRemoteEvent() { - - @Override - public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { - buffer.order(ByteOrder.LITTLE_ENDIAN); - - CreatureObject creature = (CreatureObject) getObject(buffer.getLong()); - - if (creature == null || creature.getClient() == null) { - return; - } - - buffer.skip(4); - - SWGObject object = getObject(buffer.getLong()); - - if (object == null) { - return; - } - useObject(creature, object); - } - - }); - */ - } public void shutdown() { diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index 457c90e7..928fb404 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -83,8 +83,6 @@ public class SUIService implements INetworkDispatch { return; core.scriptService.callScript("scripts/radial/", getRadialFilename(target), "createRadial", core, owner, target, request.getRadialOptions()); - if(getRadialFilename(target).equals("default")) - return; sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount());