From a00f637f13e789881e059bea56f42ab9de31112e Mon Sep 17 00:00:00 2001 From: Waverunner Date: Tue, 22 Apr 2014 17:54:05 -0400 Subject: [PATCH] More randomization's for delivery missions, more work on objectives --- .../MissionAcceptRequest.java | 62 ++++ .../MissionAcceptResponse.java} | 70 +++-- .../common/ObjControllerOpcodes.java | 1 + .../objectives/DeliveryMissionObjective.java | 1 + .../mission/MissionMessageBuilder.java | 36 ++- .../objects/mission/MissionObject.java | 103 +++---- src/services/mission/MissionObjective.java | 6 + src/services/mission/MissionService.java | 283 +++++++++++++----- 8 files changed, 374 insertions(+), 188 deletions(-) create mode 100644 src/protocol/swg/objectControllerObjects/MissionAcceptRequest.java rename src/{resources/common/TerminalType.java => protocol/swg/objectControllerObjects/MissionAcceptResponse.java} (73%) diff --git a/src/protocol/swg/objectControllerObjects/MissionAcceptRequest.java b/src/protocol/swg/objectControllerObjects/MissionAcceptRequest.java new file mode 100644 index 00000000..62a37694 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/MissionAcceptRequest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 org.apache.mina.core.buffer.IoBuffer; + +public class MissionAcceptRequest extends ObjControllerObject { + + private long missionObjId; + private long terminalObjId; + + public MissionAcceptRequest() { } + + @Override + public void deserialize(IoBuffer data) { + data.getLong(); + data.getInt(); + setMissionObjId(data.getLong()); + setTerminalObjId(data.getLong()); + } + + @Override + public IoBuffer serialize() { + return null; + } + + public long getMissionObjId() { + return missionObjId; + } + + public void setMissionObjId(long misssionObjId) { + this.missionObjId = misssionObjId; + } + + public long getTerminalObjId() { + return terminalObjId; + } + + public void setTerminalObjId(long terminalObjId) { + this.terminalObjId = terminalObjId; + } + +} diff --git a/src/resources/common/TerminalType.java b/src/protocol/swg/objectControllerObjects/MissionAcceptResponse.java similarity index 73% rename from src/resources/common/TerminalType.java rename to src/protocol/swg/objectControllerObjects/MissionAcceptResponse.java index 375d1e61..50e862e9 100644 --- a/src/resources/common/TerminalType.java +++ b/src/protocol/swg/objectControllerObjects/MissionAcceptResponse.java @@ -1,30 +1,40 @@ -/******************************************************************************* - * 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 TerminalType { - public static int MISSION_GENERIC = 1; - public static int MISSION_BOUNTYHUNTER = 2; - public static int MISSION_ENTERTAINER = 3; - public static int MISSION_ARTISAN = 4; - public static int MISSION_EXPLORER = 5; -} +/******************************************************************************* + * 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 org.apache.mina.core.buffer.IoBuffer; + +public class MissionAcceptResponse extends ObjControllerObject { + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index 8cc142fd..41db9dbd 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -34,6 +34,7 @@ public class ObjControllerOpcodes { public static final int BUFF_BUILDER_CHANGE = 0x5A020000; public static final int BUFF_BUILDER_END = 0x5B020000; public static final int MISSION_LIST_REQUEST = 0xF5000000; + public static final int MISSION_GENERIC_REQUEST = 0xF9000000; public static final int ChangeRoleIconChoice = 0x4D040000; public static final int IMAGE_DESIGN_CHANGE = 0x38020000; public static final int IMAGE_DESIGN_END = 0x39020000; diff --git a/src/resources/objectives/DeliveryMissionObjective.java b/src/resources/objectives/DeliveryMissionObjective.java index 31b1ed78..aa4d7a00 100644 --- a/src/resources/objectives/DeliveryMissionObjective.java +++ b/src/resources/objectives/DeliveryMissionObjective.java @@ -37,6 +37,7 @@ public class DeliveryMissionObjective extends MissionObjective { @Override public void activate() { + setActive(true); } @Override diff --git a/src/resources/objects/mission/MissionMessageBuilder.java b/src/resources/objects/mission/MissionMessageBuilder.java index c97226cd..236afe65 100644 --- a/src/resources/objects/mission/MissionMessageBuilder.java +++ b/src/resources/objects/mission/MissionMessageBuilder.java @@ -59,9 +59,15 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putInt(mission.getMissionLevel()); - buffer.putFloat(mission.getMissionStartX()); - buffer.putFloat(mission.getMissionStartZ()); // missionStartZ - buffer.putFloat(mission.getMissionStartY()); + if (mission.getStartLocation() != null) { + buffer.putFloat(mission.getStartLocation().x); + buffer.putFloat(0); + buffer.putFloat(mission.getStartLocation().z); + } else { + buffer.putFloat(0); + buffer.putFloat(0); + buffer.putFloat(0); + } buffer.putLong(0); // Start Object ID if (mission.getMissionStartPlanet() == null) buffer.putInt(0); @@ -75,9 +81,15 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putInt(mission.getCreditReward()); - buffer.putFloat(mission.getMissionDestinationX()); - buffer.putFloat(mission.getMissionDestinationZ()); - buffer.putFloat(mission.getMissionDestinationY()); + if (mission.getDestination() != null) { + buffer.putFloat(mission.getDestination().x); + buffer.putFloat(0); + buffer.putFloat(mission.getDestination().z); + } else { + buffer.putFloat(0); + buffer.putFloat(0); + buffer.putFloat(0); + } buffer.putLong(0); // Destination Object ID if (mission.getMissionDestinationPlanet() == null) buffer.putInt(0); @@ -207,13 +219,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildStartLocationDelta(float x, float z, float y, String planet) { + public IoBuffer buildStartLocationDelta(float x, float z, String planet) { IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN); buffer.putFloat(x); + buffer.putFloat(0); buffer.putFloat(z); - buffer.putFloat(y); buffer.putLong(0); @@ -224,7 +236,7 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { } int size = buffer.position(); buffer.flip(); - buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x06, buffer, size + 4); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x09, buffer, size + 4); return buffer; } @@ -255,13 +267,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildDestinationDelta(float x, float z, float y, String planet) { + public IoBuffer buildDestinationDelta(float x, float z, String planet) { IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN); buffer.putFloat(x); + buffer.putFloat(0); buffer.putFloat(z); - buffer.putFloat(y); buffer.putLong(0); // Destination Object ID @@ -273,7 +285,7 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { int size = buffer.position(); buffer.flip(); - buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x09, buffer, size + 4); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x06, buffer, size + 4); return buffer; } diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index 249d8869..4c6d1cd4 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -38,12 +38,8 @@ import engine.resources.scene.Quaternion; @Persistent(version=0) public class MissionObject extends IntangibleObject implements IPersistent { - private float destX = 0; - private float destY = 0; - private float destZ = 0; - private float startX = 0; - private float startY = 0; - private float startZ = 0; + private Point3D destination; + private Point3D startLocation; private String startPlanet = ""; private int difficultyLevel = 0; // Difficulty level displayed in details private String destinationPlanet = ""; @@ -74,66 +70,6 @@ public class MissionObject extends IntangibleObject implements IPersistent { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), template); } - public float getMissionStartX() { - synchronized(objectMutex) { - return startX; - } - } - - public float getMissionStartY() { - synchronized(objectMutex) { - return startY; - } - } - - public float getMissionStartZ() { - synchronized(objectMutex) { - return startZ; - } - } - - public void setMissionStart(float x, float y, float z, String planet) { - synchronized(objectMutex) { - this.startZ = z; - this.startX = x; - this.startY = y; - this.startPlanet = planet; - } - if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) { - getGrandparent().getClient().getSession().write(messageBuilder.buildStartLocationDelta(x, z, y, planet)); - } - } - - public float getMissionDestinationX() { - synchronized(objectMutex) { - return destX; - } - } - - public float getMissionDestinationY() { - synchronized(objectMutex) { - return destY; - } - } - - public float getMissionDestinationZ() { - synchronized(objectMutex) { - return destZ; - } - } - - public void setMissionDestination(float x, float y, float z, String planet) { - synchronized(objectMutex) { - this.destZ = z; - this.destY = y; - this.destZ = z; - this.destinationPlanet = planet; - } - if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) { - getGrandparent().getClient().getSession().write(messageBuilder.buildDestinationDelta(x, z, y, planet)); - } - } - public String getMissionDestinationPlanet() { synchronized(objectMutex) { return destinationPlanet; @@ -304,7 +240,6 @@ public class MissionObject extends IntangibleObject implements IPersistent { } if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) { getGrandparent().getClient().getSession().write(messageBuilder.buildMissionTypeDelta(missionType)); - } } @@ -320,6 +255,40 @@ public class MissionObject extends IntangibleObject implements IPersistent { } } + public Point3D getStartLocation() { + synchronized(objectMutex) { + return startLocation; + } + } + + public Point3D getDestination() { + synchronized(objectMutex) { + return destination; + } + } + + public void setStartLocation(Point3D startLocation, String planet) { + synchronized(objectMutex) { + this.startLocation = startLocation; + this.startPlanet = planet; + } + + if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) { + getGrandparent().getClient().getSession().write(messageBuilder.buildStartLocationDelta(startLocation.x, startLocation.z, planet)); + } + } + + public void setDestination(Point3D destination, String planet) { + synchronized(objectMutex) { + this.destination = destination; + this.destinationPlanet = planet; + } + + if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) { + getGrandparent().getClient().getSession().write(messageBuilder.buildDestinationDelta(destination.x, destination.z, planet)); + } + } + public Transaction getTransaction() { return txn; } diff --git a/src/services/mission/MissionObjective.java b/src/services/mission/MissionObjective.java index aa69ed08..37b7de49 100644 --- a/src/services/mission/MissionObjective.java +++ b/src/services/mission/MissionObjective.java @@ -21,14 +21,19 @@ ******************************************************************************/ package services.mission; +import com.sleepycat.persist.model.Persistent; + import resources.objects.mission.MissionObject; +@Persistent public abstract class MissionObjective { protected long startTime; protected boolean activated; protected MissionObject parent; + public MissionObjective() { } + public MissionObjective(MissionObject parent) { this.startTime = System.currentTimeMillis(); this.activated = false; @@ -41,5 +46,6 @@ public abstract class MissionObjective { public long getStartTime() { return startTime; } public boolean isActivated() { return activated; } + public void setActive(boolean isActive) { this.activated = isActive; } public MissionObject getParent() { return parent; } } diff --git a/src/services/mission/MissionService.java b/src/services/mission/MissionService.java index 488f7d52..0ed0dddd 100644 --- a/src/services/mission/MissionService.java +++ b/src/services/mission/MissionService.java @@ -27,6 +27,7 @@ import java.nio.ByteOrder; import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import main.NGECore; @@ -34,24 +35,22 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; +import protocol.swg.objectControllerObjects.MissionAcceptRequest; +import protocol.swg.objectControllerObjects.MissionAcceptResponse; import protocol.swg.objectControllerObjects.MissionListRequest; import resources.common.Console; -import resources.common.TerminalType; +import resources.common.SpawnPoint; import resources.common.ObjControllerOpcodes; import resources.objectives.DeliveryMissionObjective; import resources.objects.creature.CreatureObject; import resources.objects.mission.MissionObject; import resources.objects.tangible.TangibleObject; -import resources.objects.waypoint.WaypointObject; -import engine.clientdata.ClientFileManager; import engine.clientdata.StfTable; -import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.common.CRC; import engine.resources.common.NameGen; import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; -import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -70,7 +69,7 @@ public class MissionService implements INetworkDispatch { try { nameGenerator = new NameGen("names.txt"); } catch (IOException e) { e.printStackTrace(); } - populateMissionEntryCount(); + loadMissionEntryCounts(); } @Override @@ -79,11 +78,6 @@ public class MissionService implements INetworkDispatch { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { - data.order(ByteOrder.LITTLE_ENDIAN); - - MissionListRequest request = new MissionListRequest(); - request.deserialize(data); - Client client = core.getClient(session); if(client == null || client.getSession() == null) @@ -94,17 +88,25 @@ public class MissionService implements INetworkDispatch { if(object == null) return; + data.order(ByteOrder.LITTLE_ENDIAN); + + MissionListRequest request = new MissionListRequest(); + request.deserialize(data); + SWGObject terminal = core.objectService.getObject(request.getTerminalId()); + if (terminal.getAttachment("terminalType") == null) + return; + int terminalType = (int) terminal.getAttachment("terminalType"); - if (terminalType == TerminalType.MISSION_GENERIC) { - populateMissions(core.objectService.getObject(request.getObjectId()), TerminalType.MISSION_GENERIC); - } else if (terminalType == TerminalType.MISSION_BOUNTYHUNTER) { + if (terminalType == TerminalType.GENERIC) { + handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.GENERIC); + } else if (terminalType == TerminalType.BOUNTYHUNTER) { - } else if (terminalType == TerminalType.MISSION_ENTERTAINER) { + } else if (terminalType == TerminalType.ENTERTAINER) { - } else if (terminalType == TerminalType.MISSION_ARTISAN) { + } else if (terminalType == TerminalType.ARTISAN) { } else { Console.println("ERROR: Unsupported terminal " + terminal.getObjectId()); @@ -112,15 +114,43 @@ public class MissionService implements INetworkDispatch { } }); - } - - private void populateMissions(final SWGObject player, int type) { - CreatureObject creature = (CreatureObject) player; - debugMissionDelta(creature); + objControllerOpcodes.put(ObjControllerOpcodes.MISSION_GENERIC_REQUEST, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + Client client = core.getClient(session); + + if(client == null || client.getSession() == null) + return; + + SWGObject object = client.getParent(); + + if(object == null) + return; + + CreatureObject creature = (CreatureObject) object; + + data.order(ByteOrder.LITTLE_ENDIAN); + + MissionAcceptRequest request = new MissionAcceptRequest(); + request.deserialize(data); + + MissionObject mission = (MissionObject) core.objectService.getObject(request.getMissionObjId()); + + if (mission == null) + return; + + if (handleMissionAccept(creature, mission)) { + //MissionAcceptResponse response = new MissionAcceptResponse(); + //session.write(response.serialize()); + } + } + + }); } - - private void populateMissionEntryCount() { + + private void loadMissionEntryCounts() { File missionFolder = new File("./clientdata/string/en/mission"); File[] missionFiles = missionFolder.listFiles(); @@ -152,58 +182,6 @@ public class MissionService implements INetworkDispatch { System.out.println("Loaded " + missionStrings + " mission entry counts."); } - public void debugMissionDelta(CreatureObject creature) { - TangibleObject missionBag = (TangibleObject) creature.getSlottedObject("mission_bag"); - - final AtomicInteger destroyCount = new AtomicInteger(); - final AtomicInteger deliverCount = new AtomicInteger(); - - missionBag.viewChildren(creature, true, false, new Traverser() { - - @Override - public void process(SWGObject child) { - - if (child instanceof MissionObject == false) - return; - - MissionObject mission = (MissionObject) child; - if (destroyCount.get() < 5) { - mission.setMissionType("destroy"); - - String missionStf = "mission/mission_destroy_neutral_easy_creature"; - int strId = getRandomStringEntry(missionStf); - - mission.setMissionDescription(missionStf, "m" + String.valueOf(strId) + "d"); - mission.setMissionTitle(missionStf, "m" + String.valueOf(strId) + "t"); - - destroyCount.getAndIncrement(); - } - else if (deliverCount.get() < 5) { - mission.setMissionType("deliver"); - - String missionStf = "mission/mission_deliver_neutral_easy"; - int strId = getRandomStringEntry(missionStf); - - mission.setMissionDescription(missionStf, "m" + String.valueOf(strId) + "d"); - mission.setMissionTitle(missionStf, "m" + String.valueOf(strId) + "t"); - - deliverCount.getAndIncrement(); - } - else { return; } - - mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3)); - - mission.setMissionLevel(1); - mission.setMissionStart((float) 3377.148, (float) -4753.221, (float) 0, "tatooine"); - mission.setCreditReward(69); - mission.setMissionDestination((float) 3447.129, (float) -5070.057, (float) 0, "tatooine"); - mission.setMissionTemplateObject(CRC.StringtoCRC("object/tangible/mission/shared_mission_datadisk.iff")); - mission.setRepeatCount(1); - - } - - }); - } private int getRandomStringEntry(String missionStf) { int ranEntryNum = 1; @@ -216,22 +194,169 @@ public class MissionService implements INetworkDispatch { else return ranEntryNum; } + + private void handleMissionListRequest(final SWGObject player, int requestCounter, int type) { + CreatureObject creature = (CreatureObject) player; + + TangibleObject missionBag = (TangibleObject) creature.getSlottedObject("mission_bag"); + + if (missionBag == null || creature == null) + return; + + final AtomicInteger typeOneCount = new AtomicInteger(); + final AtomicInteger typeTwoCount = new AtomicInteger(); + + missionBag.viewChildren(creature, true, false, new Traverser() { + + @Override + public void process(SWGObject obj) { + + if (obj instanceof MissionObject == false) + return; + + MissionObject mission = (MissionObject) obj; + + if (typeOneCount.get() < 4) { + + if (type == TerminalType.GENERIC) + randomDeliveryMission(player, mission); + + else if (type == TerminalType.BOUNTYHUNTER) + randomBountyMission(player, mission); + + else if (type == TerminalType.ARTISAN) + return; + + else + return; + + mission.setRepeatCount(requestCounter); + typeOneCount.incrementAndGet(); + + } else if (typeTwoCount.get() < 4) { + + if (type == TerminalType.GENERIC) + randomDestroyMission(player, mission); + + else if (type == TerminalType.BOUNTYHUNTER) + return; + + else if (type == TerminalType.ARTISAN) + return; + + else + return; + + mission.setRepeatCount(requestCounter); + typeTwoCount.incrementAndGet(); + } + } + }); + } - private void randomDeliveryMission(MissionObject mission) { + private boolean handleMissionAccept(CreatureObject creature, MissionObject mission) { + SWGObject missionBag = creature.getSlottedObject("mission_bag"); + + if (mission.getContainer() != missionBag) + return false; + + TangibleObject datapad = (TangibleObject) creature.getSlottedObject("datapad"); + + if (datapad == null) + return false; + + AtomicInteger missionCount = new AtomicInteger(); + AtomicBoolean hasBountyMission = new AtomicBoolean(false); + datapad.viewChildren(creature, true, false, new Traverser() { + + @Override + public void process(SWGObject obj) { + if (obj instanceof MissionObject) { + missionCount.incrementAndGet(); + + if (((MissionObject) obj).getMissionType().equals("bounty")) + hasBountyMission.set(true); + } + } + }); + + if (hasBountyMission.get() && mission.getMissionType().equals("bounty")) // Can only have 1 bounty mission + return false; + + System.out.println("Player has " + missionCount.get() + " missions."); + + if (missionCount.get() == 2) { + creature.sendSystemMessage("@mission/mission_generic:too_many_missions", (byte) 0); + return false; + } + if (missionBag.transferTo(creature, datapad, mission)) { + createMissionObjective(creature, mission); + return true; + } else { return false; } + } + + private void createMissionObjective(CreatureObject creature, MissionObject mission) { + String type = mission.getMissionType(); + + switch(type) { + + case "deliver": + DeliveryMissionObjective objective = new DeliveryMissionObjective(mission); + + mission.setObjective(objective); + + objective.activate(); + break; + + default: + break; + } + } + + private void randomDeliveryMission(SWGObject player, MissionObject mission) { mission.setMissionType("deliver"); - String missionStf = "mission/mission_deliver_neutral_easy"; + String[] difficulties = { "easy", "medium", "hard" }; + + String missionStf = "mission/mission_deliver_neutral_" + difficulties[ran.nextInt(difficulties.length)]; int strId = getRandomStringEntry(missionStf); mission.setMissionDescription(missionStf, "m" + String.valueOf(strId) + "d"); mission.setMissionTitle(missionStf, "m" + String.valueOf(strId) + "t"); - //mission.setObjective(new DeliveryMissionObjective(mission)); + mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3)); + + mission.setMissionLevel(5); + + Point3D startLocation = SpawnPoint.getRandomPosition(player.getPosition(), (float) 50, (float) 300, player.getPlanetId()); + Point3D destination = SpawnPoint.getRandomPosition(startLocation, (float) 50, (float) 500, player.getPlanetId()); + + mission.setStartLocation(startLocation, player.getPlanet().name); + mission.setDestination(destination, player.getPlanet().name); + + mission.setCreditReward((int) (50 * ((player.getWorldPosition().getDistance2D(destination) / 10)))); + + mission.setMissionTemplateObject(CRC.StringtoCRC("object/tangible/mission/shared_mission_datadisk.iff")); + mission.setMissionTargetName("Datadisk"); + } + + private void randomDestroyMission(SWGObject player, MissionObject mission) { + + } + + private void randomBountyMission(SWGObject player, MissionObject mission) { + + } + public enum TerminalType {; + public static final int GENERIC = 1; + public static final int BOUNTYHUNTER = 2; + public static final int ENTERTAINER = 3; + public static final int ARTISAN = 4; + public static final int EXPLORER = 5; } @Override public void shutdown() { } - }