diff --git a/scripts/commands/requestcoresample.py b/scripts/commands/requestcoresample.py new file mode 100644 index 00000000..2931588a --- /dev/null +++ b/scripts/commands/requestcoresample.py @@ -0,0 +1,8 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.surveyService.requestSampling(actor, target, commandString); + return \ No newline at end of file diff --git a/scripts/commands/requestsurvey.py b/scripts/commands/requestsurvey.py new file mode 100644 index 00000000..ccff8b8a --- /dev/null +++ b/scripts/commands/requestsurvey.py @@ -0,0 +1,8 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.surveyService.requestSurvey(actor, target, commandString); + return \ No newline at end of file diff --git a/scripts/object/intangible/vehicle/speederbike_swoop_pcd.py b/scripts/object/intangible/vehicle/speederbike_swoop_pcd.py index 9340871b..94a561f7 100644 --- a/scripts/object/intangible/vehicle/speederbike_swoop_pcd.py +++ b/scripts/object/intangible/vehicle/speederbike_swoop_pcd.py @@ -1,25 +1,23 @@ import sys def setup(core, object): - #object.setAttachment('vehicleId', core.objectService.generateObjectID()) + object.setAttachment('vehicleId', core.objectService.generateObjectID()) object.setAttachment('radial_filename', 'item') return def use(core, actor, object): - actor.sendSystemMessage('use', 0) if object: - vehicleId = object.getObjectID() - actor.sendSystemMessage('vehicleId %s' % vehicleId, 0) + vehicleId = object.getAttachment('vehicleId') + if not vehicleId: return vehicle = core.objectService.getObject(vehicleId) - - #if vehicle: - #core.objectService.destroyObject(vehicle) - #else: - swoop = core.objectService.createObject('object/mobile/vehicle/shared_speederbike_swoop.iff', vehicleId, actor.getPlanet(), actor.getPosition(), actor.getOrientation()) - #core.simulationService.add(vehicle, vehicle.getPosition().x, vehicle.getPosition().z, True) - core.simulationService.add(swoop, swoop.getPosition().x, swoop.getPosition().z, True) + + if vehicle: + core.objectService.destroyObject(vehicle) + else: + core.objectService.createObject('object/mobile/vehicles/shared_speederbike_swoop.iff', vehicleId, actor.getPlanet(), actor.getPosition(), actor.getOrientation()) + core.simulationService.add(vehicle, vehicle.getPosition().x, vehicle.getPosition().z, True) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/vehicle_deed/speederbike_swoop_deed.py b/scripts/object/tangible/deed/vehicle_deed/speederbike_swoop_deed.py index fff73f2c..eb077d1f 100644 --- a/scripts/object/tangible/deed/vehicle_deed/speederbike_swoop_deed.py +++ b/scripts/object/tangible/deed/vehicle_deed/speederbike_swoop_deed.py @@ -7,13 +7,13 @@ def setup(core, object): def use(core, actor, object): datapad = actor.getSlottedObject('datapad') - pcd = core.objectService.createObject('object/intangible/vehicle/shared_speederbike_swoop_pcd.iff', actor.getPlanet(), actor.getPosition().x, actor.getPosition().z,actor.getPosition().y) + pcd = core.objectService.createObject('object/intangible/vehicle/shared_speederbike_swoop_pcd.iff', actor.getPlanet(), actor.getPosition()) if datapad and pcd: datapad.add(pcd) core.objectService.destroyObject(object) - vehicle = core.objectService.createObject('object/mobile/vehicle/shared_speederbike_swoop.iff', actor.getPlanet(), actor.getPosition().x, actor.getPosition().z,actor.getPosition().y) + vehicle = createObject('object/mobile/vehicle/shared_speederbike_swoop.iff', pcd.getAttachment('vehicleId'), actor.getPlanet(), actor.getPosition(), actor.getOrientation()) vehicle.setOwnerId(actor.getObjectID()) core.simulationService.add(vehicle, vehicle.getPosition().x, vehicle.getPosition().z, True) - + return \ No newline at end of file diff --git a/scripts/radial/survey_tool.py b/scripts/radial/survey_tool.py index fc569b64..33e36367 100644 --- a/scripts/radial/survey_tool.py +++ b/scripts/radial/survey_tool.py @@ -9,6 +9,8 @@ import sys def createRadial(core, owner, target, radials): radials.clear() radials.add(RadialOptions(0, 21, 1, 'Use')) + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 15, 0, 'Destroy')) radials.add(RadialOptions(0, 132, 1, 'Tool Options')) return diff --git a/src/main/NGECore.java b/src/main/NGECore.java index af8e09d3..64815dfa 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -118,7 +118,7 @@ import engine.servers.PingServer; public class NGECore { public static boolean didServerCrash = false; - + private static NGECore instance; private Config config = null; @@ -198,6 +198,8 @@ public class NGECore { private ObjectDatabase resourceRootsODB; private ObjectDatabase resourceHistoryODB; + public static boolean PACKET_DEBUG = false; + public NGECore() { } diff --git a/src/protocol/swg/ResourceListForSurveyMessage.java b/src/protocol/swg/ResourceListForSurveyMessage.java index 937bb00e..5263255c 100644 --- a/src/protocol/swg/ResourceListForSurveyMessage.java +++ b/src/protocol/swg/ResourceListForSurveyMessage.java @@ -41,7 +41,6 @@ public class ResourceListForSurveyMessage extends SWGMessage { private TangibleObject tool; private List resourceList; - private NGECore core; public ResourceListForSurveyMessage(TangibleObject tool, List resourceList) { this.tool = tool; @@ -51,13 +50,7 @@ public class ResourceListForSurveyMessage extends SWGMessage { public ResourceListForSurveyMessage(NGECore core, TangibleObject tool, CreatureObject surveyor) { this.tool = tool; this.resourceList = new ArrayList(); - GalacticResource sample1 = new GalacticResource("Zyogiskian","ore_siliclastic_robindun","mineral"); - GalacticResource sample2 = new GalacticResource("Odoajfaadf","steel_thoranium","mineral"); - //Vector planetVector = core.resourceService.getSpawnedResourcesByPlanet(surveyor.getPlanetId()); - - //byte generalType = ((SurveyTool)tool).getToolType(); byte generalType = 0; - System.out.println("tool.getDetailName() " + tool.getDetailName()); String toolName = tool.getDetailName(); if (toolName.equals("survey_tool_mineral")) generalType = (byte) 0; @@ -76,12 +69,10 @@ public class ResourceListForSurveyMessage extends SWGMessage { if (toolName.equals("survey_tool_liquid")) generalType = (byte) 7; - //generalType = (byte) 0; // Here the surveytool type gets set Vector planetVector = core.resourceService.getSpawnedResourcesByPlanetAndType(surveyor.getPlanetId(),generalType); resourceList = new ArrayList(planetVector); -// resourceList.add(sample1); -// resourceList.add(sample2); + } public void deserialize(IoBuffer data) { @@ -124,7 +115,7 @@ public class ResourceListForSurveyMessage extends SWGMessage { int size = result.position(); result.flip(); - services.resources.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip()); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip()); return IoBuffer.allocate(size).put(result.array(), 0, size).flip(); } } diff --git a/src/protocol/swg/ResourceMessenger.java b/src/protocol/swg/ResourceMessenger.java deleted file mode 100644 index e45be198..00000000 --- a/src/protocol/swg/ResourceMessenger.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * 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 engine.resources.objects.SWGObject; -import protocol.swg.SWGMessage; -import resources.objects.resource.GalacticResource; -import resources.objects.resource.ResourceContainerObject; - -/** - * @author Charon - */ -public class ResourceMessenger extends SWGMessage { - - private IoBuffer buffer; - - public ResourceMessenger(IoBuffer buffer) { - this.buffer = buffer; - } - - public void deserialize(IoBuffer data) { - - } - - public IoBuffer serialize() { - return IoBuffer.allocate(1); //satisfy Interface - } - - public IoBuffer serialize_buildUpdateContainmentMessage(ResourceContainerObject contentObject, SWGObject containerObject) { - IoBuffer result = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); - result.setAutoExpand(true); - result.putShort((short)4); - result.putInt(0x56CBDE9E); - result.putLong(contentObject.getObjectID()); - if (containerObject != null) { - result.putLong(containerObject.getObjectID()); - } else { - System.out.println("buildUpdateContainmentMessage -> containerObject is Null"); - result.putLong(0); - } - result.putInt(-1); // unequipped - int size = result.position(); - result.flip(); - services.resources.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip()); - return IoBuffer.allocate(size).put(result.array(), 0, size).flip(); - } - - - public IoBuffer serialize_buildRCNO3Baseline(ResourceContainerObject resourceContainer) { - IoBuffer result = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); - result.setAutoExpand(true); - int sizeP = 80; - sizeP += "resource/resource_names".length(); // "@resource/resource_names:" + R.getResourceType())); - sizeP += 1*(resourceContainer.getResourceFileName().length()); - result.putShort((short)5); - result.putInt(0x68A75F0C); - result.putLong(resourceContainer.getObjectID()); - result.putInt(0x52434E4F); - result.put((byte)3); - result.putInt(sizeP); - result.putShort((short)0x0F); - result.putFloat(1.0f); - result.put(getAsciiString("resource/resource_names")); - result.putInt(0); - result.put(getAsciiString(resourceContainer.getResourceFileName())); - result.putInt(0); - result.putInt(1); - result.putInt(0); - result.putInt(0); - result.putInt(0); - result.putInt(0); - result.putInt(0); - result.putShort((short)0); - result.putInt(0); - result.putInt(0); - result.putInt(100); //MaxCondition - result.put((byte)1); - result.putInt(resourceContainer.getStackCount()); - //result.putInt(30000); - result.putLong(resourceContainer.getReferenceID()); - int size = result.position(); - result.flip(); - services.resources.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip()); - return IoBuffer.allocate(size).put(result.array(), 0, size).flip(); - } - -// Pre-CU Packet -// 0000: 05 00 53 21 86 12 3C 65 41 16 00 00 01 00 4F 4E ..S!.. 0.10f){ diff --git a/src/resources/objects/resource/ResourceContainerMessageBuilder.java b/src/resources/objects/resource/ResourceContainerMessageBuilder.java index ad3748b4..92192c3f 100644 --- a/src/resources/objects/resource/ResourceContainerMessageBuilder.java +++ b/src/resources/objects/resource/ResourceContainerMessageBuilder.java @@ -267,7 +267,7 @@ public class ResourceContainerMessageBuilder extends ObjectMessageBuilder { result.putInt(10); int size = result.position(); result.flip(); - services.resources.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip()); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip()); return IoBuffer.allocate(size).put(result.array(), 0, size).flip(); } diff --git a/src/resources/objects/resource/ResourceContainerObject.java b/src/resources/objects/resource/ResourceContainerObject.java index b2f4a47b..20ef9dfd 100644 --- a/src/resources/objects/resource/ResourceContainerObject.java +++ b/src/resources/objects/resource/ResourceContainerObject.java @@ -333,6 +333,13 @@ public class ResourceContainerObject extends TangibleObject { if (isNewContainer) this.stackCount = stackCount; } + + public void setStackCount(int stackCount,CreatureObject owner) { + this.stackCount = stackCount; + this.getAttributes().put("@obj_attr_n:resource_contents", this.getStackCount()+"/"+maximalStackCapacity); + if (stackCount>0) + this.sendDelta3(owner.getClient()); + } public short getColdResistance() { return coldResistance; diff --git a/src/resources/objects/tool/SurveyTool.java b/src/resources/objects/tool/SurveyTool.java index fbbae469..a695a078 100644 --- a/src/resources/objects/tool/SurveyTool.java +++ b/src/resources/objects/tool/SurveyTool.java @@ -132,7 +132,6 @@ public class SurveyTool extends TangibleObject{ break; default: toolType = -1; } - System.out.println("TOOLTYPE " + toolType); } public SurveyTool(String template, Long tanoID) { @@ -184,7 +183,7 @@ public class SurveyTool extends TangibleObject{ break; default: toolType = -1; } - System.out.println("TOOLTYPE " + toolType); + } public void setToolType(byte toolType) { @@ -328,6 +327,6 @@ public class SurveyTool extends TangibleObject{ GalacticResource resourceToSurvey = this.getSurveyResource(); Vector concentrationMap = resourceToSurvey.buildConcentrationsCollection(this.getUser().getPosition(),resourceToSurvey, surveyRadius, differential, this.getUser().getPlanetId()); this.getSurveyResource().constructSurveyMapMessage(this.getUser(), concentrationMap, surveyRadius); - this.getUser().sendSystemMessage("Distance to nearest Deposit : " + this.getSurveyResource().getHelperMinDist(), (byte) 0); + //this.getUser().sendSystemMessage("Distance to nearest Deposit : " + this.getSurveyResource().getHelperMinDist(), (byte) 0); } } \ No newline at end of file diff --git a/src/services/SurveyService.java b/src/services/SurveyService.java index 8b6b353b..949c5d39 100644 --- a/src/services/SurveyService.java +++ b/src/services/SurveyService.java @@ -66,8 +66,8 @@ public class SurveyService implements INetworkDispatch { public SurveyService(NGECore core) { this.core = core; scheduleSurveyService(); - core.commandService.registerSurveyCommand("RequestSurvey"); - core.commandService.registerSurveyCommand("RequestCoreSample"); + core.commandService.registerCommand("requestsurvey"); + core.commandService.registerCommand("requestcoreSample"); } @@ -156,7 +156,7 @@ public class SurveyService implements INetworkDispatch { int stackCountToUpdate = container.getStackCount(); if (stackCountToUpdate concentrationMap = resourceToSurvey.buildConcentrationsCollection(crafter.getPosition(),resourceToSurvey, surveyRadius, differential, crafter.getPlanetId()); -// resourceToSurvey.constructSurveyMapMessage(crafter, concentrationMap, surveyRadius); -// crafter.sendSystemMessage("Distance to nearest Deposit : " + resourceToSurvey.getHelperMinDist(), (byte) 0); } - public void requestSampling(CreatureObject crafter, SWGObject target, SurveyCommand command, int actionCounter, String commandArgs){ + public void requestSampling(CreatureObject crafter, SWGObject target, String commandArgs){ PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); SurveyTool surveyTool = player.getLastUsedSurveyTool(); @@ -403,8 +374,9 @@ public class SurveyService implements INetworkDispatch { } } else { crafter.sendSystemMessage("There are only trace amounts of " + commandArgs + " here. Find a higher concentration of the resource, and try sampling again.", (byte) 0); // "@survey:trace_amount:" - surveyTool.setCurrentlySampling(true); - surveyTool.setLastSampleTime(System.currentTimeMillis()); + surveyTool.setCurrentlySampling(false); + surveyTool.setCurrentlySurveying(false); + //surveyTool.setLastSampleTime(System.currentTimeMillis()); } } else { crafter.sendSystemMessage("You must survey for " + commandArgs + " before you can sample for it.", (byte) 0); @@ -437,7 +409,7 @@ public class SurveyService implements INetworkDispatch { GalacticResource sampleResource = surveyTool.getSurveyResource(); float localConcentration = sampleResource.deliverConcentrationForSurvey(crafter.getPlanetId(), crafter.getPosition().x, crafter.getPosition().z); //float localConcentration = 1.0F; - if (localConcentration > 0.3) { + if (localConcentration > 0.1) { crafter.setPosture((byte) 1); // ToDo: overfilling resource container with continuesampling @@ -553,8 +525,8 @@ public class SurveyService implements INetworkDispatch { } else { crafter.sendSystemMessage("There are only trace amounts of " + sampleResource.getName() + " here. Find a higher concentration of the resource, and try sampling again.", (byte) 0); // "@survey:trace_amount:" - surveyTool.setCurrentlySampling(true); - surveyTool.setLastSampleTime(System.currentTimeMillis()); + surveyTool.setCurrentlySampling(false); + surveyTool.setCurrentlySurveying(false); } } @@ -594,15 +566,6 @@ public class SurveyService implements INetworkDispatch { public SUICallback handleExceptionalInput(SWGObject crafter,SUIWindow suiWindow){ SUICallback callback = suiWindow.getCallbackByEventId(1); -// if (callback!=null) -// System.out.println("handleExceptionalInput " + callback.toString()); -// if (callback.toString().equals("1")){ -// System.out.println("1"); -// PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); -// SurveyTool surveyTool = player.getLastUsedSurveyTool(); -// surveyTool.setExceptionalState(false); -// core.suiService.closeSUIWindow(crafter, 0); -// } return callback; } @@ -689,8 +652,6 @@ public class SurveyService implements INetworkDispatch { public SUICallback handleSurveyRangeInput(SWGObject crafter,SUIWindow suiWindow){ SUICallback callback = suiWindow.getCallbackByEventId(1); -// if (callback!=null) -// System.out.println("handleExceptionalInput " + callback.toString()); core.suiService.closeSUIWindow(crafter, 0); return callback; } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index b0be29bc..20564197 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -106,14 +106,6 @@ public class CommandService implements INetworkDispatch { return; } - // survey command filter - if(command instanceof SurveyCommand) { - System.out.println("SurveyCommand Instance: " + command.getCommandName()); - SurveyCommand command2 = (SurveyCommand) command.clone(); - processSurveyCommand(actor, target, command2, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments()); - return; - } - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandEnqueue.getCommandArguments()); } @@ -148,14 +140,6 @@ public class CommandService implements INetworkDispatch { } - public SurveyCommand registerSurveyCommand(String name) { - - SurveyCommand command = new SurveyCommand(name.toLowerCase()); - commandLookup.add(command); - return command; - - } - public BaseSWGCommand registerGmCommand(String name) { BaseSWGCommand command = new BaseSWGCommand(name.toLowerCase()); @@ -320,17 +304,6 @@ public class CommandService implements INetworkDispatch { } - public void processSurveyCommand(CreatureObject crafter, SWGObject target, SurveyCommand command, int actionCounter, String commandArgs) { - - if(command.getCommandName().equalsIgnoreCase("requestsurvey")){ - core.surveyService.requestSurvey(crafter, target, command, actionCounter, commandArgs); - } - - if(command.getCommandName().equalsIgnoreCase("requestcoresample")){ - core.surveyService.requestSampling(crafter, target, command, actionCounter, commandArgs); - } - } - public void callCommand(SWGObject actor, String commandName, SWGObject target, String commandArgs) { if (actor == null) return; diff --git a/src/services/resources/ResourceService.java b/src/services/resources/ResourceService.java index 1b598115..fa546a01 100644 --- a/src/services/resources/ResourceService.java +++ b/src/services/resources/ResourceService.java @@ -29,19 +29,10 @@ import java.util.Vector; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; - -import org.apache.mina.core.buffer.IoBuffer; - import com.sleepycat.persist.EntityCursor; - -import protocol.swg.ResourceMessenger; -import protocol.swg.SceneCreateObjectByCrc; -import protocol.swg.SceneEndBaselines; -import protocol.swg.UpdateContainmentMessage; import main.NGECore; import engine.resources.common.CRC; import engine.resources.objects.SWGObject; -import engine.resources.scene.Planet; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.creature.CreatureObject; @@ -10772,10 +10763,8 @@ public class ResourceService implements INetworkDispatch { return 0; } int skillMod=crafter.getSkillModBase("surveying"); - System.out.println("skillModBase " + skillMod); crafter.addSkillMod("surveying",100); skillMod=(int)(Math.round(crafter.getSkillMod("surveying").getModifier())); - System.out.println("skillMod modifier" + skillMod); skillMod=35; // TEST! float concentration=sampleResource.deliverConcentrationForSurvey(crafter.getPlanetId(), crafter.getPosition().x, crafter.getPosition().z); float concentrationPercentage=0.01F*concentration; @@ -11348,16 +11337,7 @@ public class ResourceService implements INetworkDispatch { containerObject.setIffFileName(resourceContainerIFF); long objectId = containerObject.getObjectID(); SWGObject crafterInventory = crafter.getSlottedObject("inventory"); - SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId, crafter.getOrientation().x, crafter.getOrientation().y, crafter.getOrientation().z, crafter.getOrientation().w, crafter.getPosition().x, crafter.getPosition().y, crafter.getPosition().z, resCRC, (byte) 0); - crafter.getClient().getSession().write(createObjectMsg.serialize()); - services.resources.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); - UpdateContainmentMessage updateContainmentMessage= new UpdateContainmentMessage(containerObject.getObjectID(), crafterInventory.getObjectID(), -1); - crafter.getClient().getSession().write(updateContainmentMessage.serialize()); - containerObject.sendBaselines(crafter.getClient()); - SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(containerObject.getObjectID()); - crafter.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); - services.resources.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); - //containerObject.buildAttributeListMessage(crafter.getClient()); + crafterInventory.add(containerObject); return containerObject; } } diff --git a/src/services/resources/CharonPacketUtils.java b/src/tools/CharonPacketUtils.java similarity index 95% rename from src/services/resources/CharonPacketUtils.java rename to src/tools/CharonPacketUtils.java index 65dd03e6..b7eb10a1 100644 --- a/src/services/resources/CharonPacketUtils.java +++ b/src/tools/CharonPacketUtils.java @@ -1,8 +1,14 @@ -package services.resources; +package tools; import java.io.UnsupportedEncodingException; + +import main.NGECore; + import org.apache.mina.core.buffer.IoBuffer; +/** + * @author Charon + */ public class CharonPacketUtils { @@ -49,6 +55,10 @@ public class CharonPacketUtils { } public static void printAnalysis(IoBuffer pack){ + + if (!NGECore.getInstance().PACKET_DEBUG) + return; + byte[] packArray = pack.array(); int lineCount = packArray.length/16; int actualIndex = 0;