mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-12 22:45:31 -04:00
Added accepting for missions, added first phase for delivery missions
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from resources.common import OutOfBand
|
||||
from resources.common import ProsePackage
|
||||
from resources.objectives import DeliveryMissionObjective
|
||||
import sys
|
||||
|
||||
def startConversation(core, actor, npc):
|
||||
mission = npc.getAttachment('assignedMission')
|
||||
|
||||
if mission is None:
|
||||
return
|
||||
|
||||
objective = mission.getObjective()
|
||||
|
||||
if mission.getGrandparent().getObjectId() != actor.getObjectId() or objective is None:
|
||||
core.conversationService.sendStopConversation(actor, npc, 'conversation/respecseller', 's_38')
|
||||
return
|
||||
|
||||
if objective.getObjectivePhase() == 0:
|
||||
handleFirstDeliveryStage(core, actor, npc, objective, mission)
|
||||
return
|
||||
|
||||
#convSvc.sendConversationMessage(actor, npc, OutOfBand(ProsePackage(mission.getMissionDescription(), 'm' + str(mission.getMissionId()) + 'p')))
|
||||
return
|
||||
|
||||
def endConversation(core, actor, npc):
|
||||
return
|
||||
|
||||
def handleFirstDeliveryStage(core, actor, npc, objective, mission):
|
||||
core.conversationService.sendStopConversation(actor, npc, mission.getMissionDescription(), 'm' + str(mission.getMissionId()) + 'p')
|
||||
objective.createDeliveryItem()
|
||||
objective.setObjectivePhase(1)
|
||||
return
|
||||
@@ -9,7 +9,6 @@ def createRadial(core, owner, target, radials):
|
||||
|
||||
def handleSelection(core, owner, target, option):
|
||||
if option == 26 and target:
|
||||
print 'test'
|
||||
core.conversationService.handleStartConversation(owner, target)
|
||||
return
|
||||
|
||||
@@ -74,6 +74,7 @@ public class ObjControllerMessage extends SWGMessage {
|
||||
public static final int NEXT_CRAFTING_STAGE_RESULT = 0x01BE;
|
||||
public static final int DRAFT_SLOTS_QUERY_RESPONSE = 0x01BF;
|
||||
public static final int RESOURCE_WEIGHTS = 0x0207;
|
||||
public static final int MISSION_ACCEPT_RESPONSE = 0x00FA;
|
||||
|
||||
public ObjControllerMessage() {
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ public class MissionAcceptRequest extends ObjControllerObject {
|
||||
|
||||
private long missionObjId;
|
||||
private long terminalObjId;
|
||||
|
||||
private byte terminalType;
|
||||
|
||||
public MissionAcceptRequest() { }
|
||||
|
||||
@Override
|
||||
@@ -36,6 +37,7 @@ public class MissionAcceptRequest extends ObjControllerObject {
|
||||
data.getInt();
|
||||
setMissionObjId(data.getLong());
|
||||
setTerminalObjId(data.getLong());
|
||||
setTerminalType(data.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,5 +60,12 @@ public class MissionAcceptRequest extends ObjControllerObject {
|
||||
public void setTerminalObjId(long terminalObjId) {
|
||||
this.terminalObjId = terminalObjId;
|
||||
}
|
||||
|
||||
|
||||
public void setTerminalType(byte terminalType) {
|
||||
this.terminalType = terminalType;
|
||||
}
|
||||
|
||||
public byte getTerminalType() {
|
||||
return terminalType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,20 +21,43 @@
|
||||
******************************************************************************/
|
||||
package protocol.swg.objectControllerObjects;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
|
||||
public class MissionAcceptResponse extends ObjControllerObject {
|
||||
|
||||
private long objectId;
|
||||
private long missionObjId;
|
||||
private byte terminalType;
|
||||
private byte flag;
|
||||
|
||||
public MissionAcceptResponse(long objectId, long missionObjId, byte terminalType, byte flag) {
|
||||
this.objectId = objectId;
|
||||
this.missionObjId = missionObjId;
|
||||
this.terminalType = terminalType;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(IoBuffer data) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IoBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
IoBuffer buffer = IoBuffer.allocate(27).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(ObjControllerMessage.MISSION_ACCEPT_RESPONSE);
|
||||
buffer.putLong(objectId);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putLong(missionObjId);
|
||||
buffer.put(flag);
|
||||
buffer.put(terminalType);
|
||||
|
||||
return buffer.flip();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,25 +21,55 @@
|
||||
******************************************************************************/
|
||||
package resources.objectives;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
import main.NGECore;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.mission.MissionObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
import services.mission.MissionObjective;
|
||||
|
||||
public class DeliveryMissionObjective extends MissionObjective {
|
||||
|
||||
private TangibleObject deliveryObject;
|
||||
private int objectivePhase;
|
||||
|
||||
private NGECore core = NGECore.getInstance();
|
||||
|
||||
public DeliveryMissionObjective(MissionObject parent) {
|
||||
super(parent);
|
||||
this.objectivePhase = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
|
||||
if (isActivated())
|
||||
return;
|
||||
|
||||
String template = "object/mobile/shared_dressed_commoner_tatooine_sullustan_male_06.iff";
|
||||
Point3D startLoc = parent.getStartLocation();
|
||||
|
||||
CreatureObject missionGiver = (CreatureObject) core.staticService.spawnObject(template, parent.getPlanet().name, 0, startLoc.x, startLoc.y, startLoc.z, 0, 1);
|
||||
missionGiver.setAttachment("conversationFile", "missions/deliver");
|
||||
missionGiver.setAttachment("radial_filename", "object/conversation");
|
||||
missionGiver.setAttachment("assignedMission", getMissionObject());
|
||||
missionGiver.setOptionsBitmask(264);
|
||||
|
||||
if (getObjectivePhase() == 0) {
|
||||
WaypointObject waypoint = (WaypointObject) core.objectService.createObject("object/waypoint/shared_waypoint.iff", parent.getPlanet());
|
||||
waypoint.setPosition(startLoc);
|
||||
waypoint.setName("@mission/" + parent.getMissionTitle() + ":" + parent.getMissionId());
|
||||
waypoint.setColor(WaypointObject.ORANGE);
|
||||
waypoint.setActive(true);
|
||||
getMissionObject().setAttachedWaypoint(waypoint);
|
||||
}
|
||||
|
||||
setActive(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete() {
|
||||
}
|
||||
@@ -47,8 +77,30 @@ public class DeliveryMissionObjective extends MissionObjective {
|
||||
@Override
|
||||
public void drop() {
|
||||
}
|
||||
|
||||
public boolean createDeliveryItem() {
|
||||
|
||||
SWGObject player = getMissionObject().getGrandparent();
|
||||
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
TangibleObject inventory = (TangibleObject) player.getSlottedObject("inventory");
|
||||
|
||||
if (inventory == null)
|
||||
return false;
|
||||
|
||||
TangibleObject deliveryObject = (TangibleObject) core.objectService.createObject("object/tangible/mission/shared_mission_datadisk.iff", getMissionObject().getGrandparent().getPlanet());
|
||||
|
||||
if (deliveryObject != null && inventory.add(deliveryObject)) {
|
||||
setDeliveryObject(deliveryObject);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public TangibleObject getDeliveryObject() { return deliveryObject; }
|
||||
|
||||
public int getObjectivePhase() { return objectivePhase; }
|
||||
|
||||
public void setDeliveryObject(TangibleObject object) { this.deliveryObject = object; }
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.nio.ByteOrder;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.scene.Point3D;
|
||||
import resources.common.Console;
|
||||
import resources.common.StringUtilities;
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
@@ -100,11 +101,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
buffer.put(getAsciiString(mission.getMissionDescription()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(mission.getMissionDescId()));
|
||||
buffer.put(getAsciiString("m" + mission.getMissionId() + "d"));
|
||||
|
||||
buffer.put(getAsciiString(mission.getMissionTitle()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(mission.getMissionTitleId()));
|
||||
buffer.put(getAsciiString("m" + mission.getMissionId() + "t"));
|
||||
|
||||
buffer.putInt(0); // refresh counter
|
||||
|
||||
@@ -131,14 +132,14 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
} else {
|
||||
buffer.putInt(wp.getCellId());
|
||||
buffer.putFloat(wp.getPosition().x);
|
||||
buffer.putFloat(wp.getPosition().z);
|
||||
buffer.putFloat(wp.getPosition().y);
|
||||
buffer.putFloat(wp.getPosition().z);
|
||||
buffer.putLong(0);
|
||||
buffer.putInt(CRC.StringtoCRC(wp.getPlanet().name));
|
||||
buffer.put(getUnicodeString(wp.getName()));
|
||||
buffer.putLong(mission.getObjectId() + 1);
|
||||
buffer.putLong(wp.getObjectId());
|
||||
buffer.put(wp.getColor());
|
||||
buffer.put((byte) 0x01);
|
||||
buffer.put((byte) (wp.isActive() ? 1 : 0));
|
||||
}
|
||||
|
||||
int size = buffer.position();
|
||||
@@ -219,13 +220,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildStartLocationDelta(float x, float z, String planet) {
|
||||
public IoBuffer buildStartLocationDelta(Point3D startLocation, String planet) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putFloat(x);
|
||||
buffer.putFloat(startLocation.x);
|
||||
buffer.putFloat(0);
|
||||
buffer.putFloat(z);
|
||||
buffer.putFloat(startLocation.z);
|
||||
|
||||
buffer.putLong(0);
|
||||
|
||||
@@ -236,7 +237,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;
|
||||
}
|
||||
@@ -267,13 +268,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDestinationDelta(float x, float z, String planet) {
|
||||
public IoBuffer buildDestinationDelta(Point3D destination, String planet) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putFloat(x);
|
||||
buffer.putFloat(destination.x);
|
||||
buffer.putFloat(0);
|
||||
buffer.putFloat(z);
|
||||
buffer.putFloat(destination.z);
|
||||
|
||||
buffer.putLong(0); // Destination Object ID
|
||||
|
||||
@@ -285,7 +286,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;
|
||||
}
|
||||
@@ -303,13 +304,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildMissionDescriptionDelta(String desc, String id) {
|
||||
public IoBuffer buildMissionDescriptionDelta(String desc, int id) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(8 + desc.length() + id.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer buffer = IoBuffer.allocate(12 + desc.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(desc));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(id));
|
||||
buffer.put(getAsciiString("m" + id + "d"));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
@@ -318,13 +319,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildMissionTitleDelta(String title, String id) {
|
||||
public IoBuffer buildMissionTitleDelta(String title, int id) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(8 + title.length() + id.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer buffer = IoBuffer.allocate(12 + title.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(title));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(id));
|
||||
buffer.put(getAsciiString("m" + id + "t"));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
@@ -371,6 +372,28 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildWaypointDelta(WaypointObject wp) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(44 + (2 * wp.getName().length()), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(wp.getCellId());
|
||||
buffer.putFloat(wp.getPosition().x);
|
||||
buffer.putFloat(wp.getPosition().y);
|
||||
buffer.putFloat(wp.getPosition().z);
|
||||
buffer.putLong(0);
|
||||
buffer.putInt(CRC.StringtoCRC(wp.getPlanet().name));
|
||||
buffer.put(getUnicodeString(wp.getName()));
|
||||
buffer.putLong(wp.getObjectId());
|
||||
buffer.put(wp.getColor());
|
||||
buffer.put((byte) (wp.isActive() ? 1 : 0));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x10, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
@Persistent(version=1)
|
||||
public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
|
||||
private Point3D destination;
|
||||
@@ -49,8 +49,7 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
private String description = "";
|
||||
private String title = "";
|
||||
private String missionTargetName = ""; // Target object I guess?
|
||||
private String descId = "";
|
||||
private String titleId = "";
|
||||
private int missionId = 0;
|
||||
private String type = "";
|
||||
private int missionTemplateObject = 0;
|
||||
private WaypointObject attachedWaypoint;
|
||||
@@ -148,13 +147,12 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public void setMissionDescription(String missionDescription, String id) {
|
||||
public void setMissionDescription(String missionDescription) {
|
||||
synchronized(objectMutex) {
|
||||
this.description = missionDescription;
|
||||
this.descId = id;
|
||||
}
|
||||
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionDescriptionDelta(missionDescription, id));
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionDescriptionDelta(missionDescription, missionId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,13 +162,12 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public void setMissionTitle(String missionTitle, String id) {
|
||||
public void setMissionTitle(String missionTitle) {
|
||||
synchronized(objectMutex) {
|
||||
this.title = missionTitle;
|
||||
this.titleId = id;
|
||||
}
|
||||
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionTitleDelta(missionTitle, id));
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionTitleDelta(missionTitle, missionId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,9 +192,13 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttachedWaypoint(WaypointObject missionAttachedWaypoint) {
|
||||
public void setAttachedWaypoint(WaypointObject waypoint) {
|
||||
synchronized(objectMutex) {
|
||||
this.attachedWaypoint = missionAttachedWaypoint;
|
||||
this.attachedWaypoint = waypoint;
|
||||
}
|
||||
|
||||
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildWaypointDelta(waypoint));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,18 +217,6 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public String getMissionDescId() {
|
||||
synchronized(objectMutex) {
|
||||
return descId;
|
||||
}
|
||||
}
|
||||
|
||||
public String getMissionTitleId() {
|
||||
synchronized(objectMutex) {
|
||||
return titleId;
|
||||
}
|
||||
}
|
||||
|
||||
public String getMissionType() {
|
||||
synchronized(objectMutex) {
|
||||
return type;
|
||||
@@ -274,7 +263,7 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
}
|
||||
|
||||
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildStartLocationDelta(startLocation.x, startLocation.z, planet));
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildStartLocationDelta(startLocation, planet));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,10 +274,18 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
}
|
||||
|
||||
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildDestinationDelta(destination.x, destination.z, planet));
|
||||
getGrandparent().getClient().getSession().write(messageBuilder.buildDestinationDelta(destination, planet));
|
||||
}
|
||||
}
|
||||
|
||||
public int getMissionId() {
|
||||
return missionId;
|
||||
}
|
||||
|
||||
public void setMissionId(int missionId) {
|
||||
this.missionId = missionId;
|
||||
}
|
||||
|
||||
public Transaction getTransaction() {
|
||||
return txn;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,13 @@ import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.mission.MissionObject;
|
||||
|
||||
@Persistent
|
||||
@Persistent(version=0)
|
||||
public abstract class MissionObjective {
|
||||
|
||||
protected long startTime;
|
||||
protected boolean activated;
|
||||
protected MissionObject parent;
|
||||
private int objectivePhase;
|
||||
|
||||
public MissionObjective() { }
|
||||
|
||||
@@ -38,14 +39,21 @@ public abstract class MissionObjective {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.activated = false;
|
||||
this.parent = parent;
|
||||
this.objectivePhase = 0;
|
||||
}
|
||||
|
||||
public abstract void activate();
|
||||
public abstract void complete();
|
||||
public abstract void drop();
|
||||
public abstract void update();
|
||||
|
||||
public long getStartTime() { return startTime; }
|
||||
|
||||
public boolean isActivated() { return activated; }
|
||||
public void setActive(boolean isActive) { this.activated = isActive; }
|
||||
public MissionObject getParent() { return parent; }
|
||||
|
||||
public MissionObject getMissionObject() { return parent; }
|
||||
|
||||
public int getObjectivePhase() { return objectivePhase; }
|
||||
public void setObjectivePhase(int phase) { this.objectivePhase = phase; }
|
||||
}
|
||||
|
||||
@@ -35,9 +35,11 @@ import main.NGECore;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.objectControllerObjects.MissionAcceptRequest;
|
||||
import protocol.swg.objectControllerObjects.MissionAcceptResponse;
|
||||
import protocol.swg.objectControllerObjects.MissionListRequest;
|
||||
import protocol.swg.objectControllerObjects.ObjControllerObject;
|
||||
import resources.common.Console;
|
||||
import resources.common.SpawnPoint;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
@@ -45,6 +47,7 @@ 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.StfTable;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.common.CRC;
|
||||
@@ -142,11 +145,13 @@ public class MissionService implements INetworkDispatch {
|
||||
return;
|
||||
|
||||
if (handleMissionAccept(creature, mission)) {
|
||||
//MissionAcceptResponse response = new MissionAcceptResponse();
|
||||
//session.write(response.serialize());
|
||||
MissionAcceptResponse response = new MissionAcceptResponse(object.getObjectId(), mission.getObjectId(), request.getTerminalType(), (byte) 1);
|
||||
object.getClient().getSession().write(new ObjControllerMessage(0x0B, response).serialize());
|
||||
} else {
|
||||
MissionAcceptResponse response = new MissionAcceptResponse(object.getObjectId(), mission.getObjectId(), request.getTerminalType(), (byte) 0);
|
||||
object.getClient().getSession().write(new ObjControllerMessage(0x0B, response).serialize());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -283,21 +288,18 @@ public class MissionService implements INetworkDispatch {
|
||||
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; }
|
||||
missionBag.transferTo(creature, datapad, mission);
|
||||
createMissionObjective(creature, mission);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createMissionObjective(CreatureObject creature, MissionObject mission) {
|
||||
String type = mission.getMissionType();
|
||||
|
||||
System.out.println("Type: " + type);
|
||||
switch(type) {
|
||||
|
||||
case "deliver":
|
||||
@@ -306,6 +308,7 @@ public class MissionService implements INetworkDispatch {
|
||||
mission.setObjective(objective);
|
||||
|
||||
objective.activate();
|
||||
System.out.println("Went here!");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -319,10 +322,10 @@ public class MissionService implements INetworkDispatch {
|
||||
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.setMissionId(getRandomStringEntry(missionStf));
|
||||
mission.setMissionDescription(missionStf);
|
||||
mission.setMissionTitle(missionStf);
|
||||
|
||||
mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3));
|
||||
|
||||
@@ -334,10 +337,17 @@ public class MissionService implements INetworkDispatch {
|
||||
mission.setStartLocation(startLocation, player.getPlanet().name);
|
||||
mission.setDestination(destination, player.getPlanet().name);
|
||||
|
||||
mission.setCreditReward((int) (50 * ((player.getWorldPosition().getDistance2D(destination) / 10))));
|
||||
mission.setCreditReward((int) (50 * ((startLocation.getDistance2D(destination) / 10))));
|
||||
|
||||
mission.setMissionTemplateObject(CRC.StringtoCRC("object/tangible/mission/shared_mission_datadisk.iff"));
|
||||
mission.setMissionTargetName("Datadisk");
|
||||
|
||||
WaypointObject waypoint = (WaypointObject) core.objectService.createObject("object/waypoint/shared_waypoint.iff", player.getPlanet());
|
||||
if (waypoint == null)
|
||||
return;
|
||||
|
||||
waypoint.setColor(WaypointObject.ORANGE);
|
||||
|
||||
}
|
||||
|
||||
private void randomDestroyMission(SWGObject player, MissionObject mission) {
|
||||
|
||||
Reference in New Issue
Block a user