Changes to MissionObjective, started working on player bounties

This commit is contained in:
Waverunner
2014-04-28 17:37:23 -04:00
parent 251ce17612
commit b0e2a490f6
19 changed files with 461 additions and 80 deletions
+2 -1
View File
@@ -60,7 +60,8 @@ odb/chatRooms/je.info.*
odb/resourcehistory/je.info.*
odb/resourceroots/je.info.*
odb/resources/je.info.*
odb/auction/je.info.*
odb/auction/je.info.*
odb/bounties/je.info.*
# External tool builders
.externalToolBuilders/
View File
+5 -3
View File
@@ -99,11 +99,9 @@ def run(core, actor, target, commandString):
if (actor.isInStealth()):
actor.setInStealth(False)
actor.setRadarVisible(True)
actor.sendSystemMessage('You are now visible to other players.', 0)
else:
actor.setInStealth(True)
actor.setRadarVisible(False)
actor.sendSystemMessage('You are now hidden from players. "Stealth Effect" is not implemented, however players still won\'t be able to see you. Type /setgodmode stealth again to be visible.', 0)
elif command == 'holoEmote' and arg1:
playerObject.setHoloEmote('holoemote_' + arg1)
@@ -114,5 +112,9 @@ def run(core, actor, target, commandString):
if playerObject.getGodLevel > 0:
actor.removeAbility("admin")
playerObject.setGodLevel(0)
elif command == 'setBounty' and arg1:
core.missionService.createNewBounty(actor, int(arg1))
return
return
+4 -4
View File
@@ -44,8 +44,8 @@ def handlePickupStage(core, actor, npc, objective, mission):
return
core.conversationService.sendStopConversation(actor, npc, mission.getMissionDescription(), 'm' + str(mission.getMissionId()) + 'p')
objective.createDeliveryItem()
objective.update()
objective.createDeliveryItem(core, actor)
objective.update(core, actor)
return
def handleDeliveryStage(core, actor, npc, objective, mission):
@@ -56,7 +56,7 @@ def handleDeliveryStage(core, actor, npc, objective, mission):
core.conversationService.sendStopConversation(actor, npc, mission.getMissionDescription(), 'm' + str(mission.getMissionId()) + 'r')
core.objectService.destroyObject(objective.getDeliveryObject())
objective.update()
objective.update(core, actor)
return
def handleCompletionStage(core, actor, npc, objective, mission):
@@ -66,5 +66,5 @@ def handleCompletionStage(core, actor, npc, objective, mission):
return
core.conversationService.sendStopConversation(actor, npc, mission.getMissionDescription(), 'm' + str(mission.getMissionId()) + 's')
objective.complete()
objective.complete(core, actor)
return
@@ -1,9 +1,7 @@
from resources.common import TerminalType
import sys
def setup(core, object):
core.mapService.addLocation(object.getPlanet(), 'Mission Terminal', object.getPosition().x, object.getPosition().z, 41, 44, 0)
object.setAttachment("terminalType", TerminalType.MISSION_GENERIC)
object.setAttachment("terminalType", 1)
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment("terminalType", 2)
return
+6
View File
@@ -213,6 +213,7 @@ public class NGECore {
private ObjectDatabase resourcesODB;
private ObjectDatabase resourceRootsODB;
private ObjectDatabase resourceHistoryODB;
private ObjectDatabase bountiesODB;
public static boolean PACKET_DEBUG = false;
@@ -274,6 +275,7 @@ public class NGECore {
resourceRootsODB = new ObjectDatabase("resourceroots", true, false, true);
resourceHistoryODB = new ObjectDatabase("resourcehistory", true, false, true);
auctionODB = new ObjectDatabase("auction", true, false, true);
bountiesODB = new ObjectDatabase("bounties", true, false, true);
// Services
loginService = new LoginService(this);
@@ -626,6 +628,10 @@ public class NGECore {
return chatRoomODB;
}
public ObjectDatabase getBountiesODB() {
return bountiesODB;
}
public ObjectDatabase getResourcesODB() {
return resourcesODB;
}
+105
View File
@@ -0,0 +1,105 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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;
import java.util.ArrayList;
import java.util.List;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;
@Entity
public class BountyListItem {
@PrimaryKey
private long objectId;
private int creditReward;
private String profession;
private String faction;
private String name;
private List<Long> assignedHunters;
public BountyListItem() { }
public BountyListItem(long objectId, int creditReward, String profession, String faction, String name) {
this.objectId = objectId;
this.creditReward = creditReward;
this.profession = profession;
this.faction = faction;
this.setName(name);
this.setAssignedHunters(new ArrayList<Long>(3));
}
public long getObjectId() {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public int getCreditReward() {
return creditReward;
}
public void setCreditReward(int creditReward) {
this.creditReward = creditReward;
}
public String getProfession() {
return profession;
}
public void setProfession(String profession) {
this.profession = profession;
}
public String getFaction() {
return faction;
}
public void setFaction(String faction) {
this.faction = faction;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void addBounty(int amountToAdd) {
this.creditReward =+ amountToAdd;
}
public List<Long> getAssignedHunters() {
return assignedHunters;
}
public void setAssignedHunters(List<Long> assignedHunters) {
this.assignedHunters = assignedHunters;
}
public boolean addBountyHunter(long objectId) {
return assignedHunters.add(objectId);
}
public boolean removeBountyHunter(long objectId) {
return assignedHunters.remove(objectId);
}
}
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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.objectives;
import java.util.Random;
import engine.resources.scene.Point3D;
import main.NGECore;
import resources.common.BountyListItem;
import resources.objects.creature.CreatureObject;
import resources.objects.mission.MissionObject;
import services.mission.MissionObjective;
public class BountyMissionObjective extends MissionObjective {
private Point3D lastKnownLocation;
private long markObjId;
public BountyMissionObjective(MissionObject parent) {
super(parent);
}
@Override
public void activate(NGECore core, CreatureObject player) {
if (isActivated())
return;
BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyObjId());
setMarkObjId(bountyTarget.getObjectId());
// TODO: Change this to a comm message.
player.sendSystemMessage("@mission/mission_bounty_informant:target_hard_" + Integer.toString(new Random().nextInt(5)), (byte) 0);
}
@Override
public void complete(NGECore core, CreatureObject player) {
}
@Override
public void abort(NGECore core, CreatureObject player) {
}
@Override
public void update(NGECore core, CreatureObject player) {
}
public Point3D getLastKnownLocation() { return lastKnownLocation; }
public void setLastKnownLocation(Point3D lastKnownLocation) { this.lastKnownLocation = lastKnownLocation; }
public long getMarkObjId() { return markObjId; }
public void setMarkObjId(long markObjId) { this.markObjId = markObjId; }
}
@@ -21,7 +21,6 @@
******************************************************************************/
package resources.objectives;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Point3D;
import main.NGECore;
import resources.common.OutOfBand;
@@ -37,14 +36,13 @@ public class DeliveryMissionObjective extends MissionObjective {
private TangibleObject deliveryObject;
private CreatureObject missionGiver;
private CreatureObject dropOffNpc;
private NGECore core = NGECore.getInstance();
public DeliveryMissionObjective(MissionObject parent) {
super(parent);
}
@Override
public void activate() {
public void activate(NGECore core, CreatureObject player) {
if (isActivated())
return;
@@ -97,25 +95,21 @@ public class DeliveryMissionObjective extends MissionObjective {
}
@Override
public void complete() {
CreatureObject completer = (CreatureObject) getMissionObject().getGrandparent();
if (completer == null)
return;
public void complete(NGECore core, CreatureObject player) {
int reward = getMissionObject().getCreditReward();
completer.addBankCredits(reward);
player.addBankCredits(reward);
completer.sendSystemMessage(new OutOfBand(new ProsePackage("@mission/mission_generic:success_w_amount", reward)), (byte) 0);
player.sendSystemMessage(new OutOfBand(new ProsePackage("@mission/mission_generic:success_w_amount", reward)), (byte) 0);
abort();
abort(core, player);
core.objectService.destroyObject(getMissionObject());
}
@Override
public void abort() {
public void abort(NGECore core, CreatureObject player) {
if (deliveryObject != null)
core.objectService.destroyObject(deliveryObject.getObjectId());
@@ -127,7 +121,7 @@ public class DeliveryMissionObjective extends MissionObjective {
}
@Override
public void update() {
public void update(NGECore core, CreatureObject player) {
setObjectivePhase(getObjectivePhase() + 1);
@@ -154,10 +148,8 @@ public class DeliveryMissionObjective extends MissionObjective {
}
}
public boolean createDeliveryItem() {
public boolean createDeliveryItem(NGECore core, CreatureObject player) {
SWGObject player = getMissionObject().getGrandparent();
if (player == null)
return false;
@@ -21,6 +21,8 @@
******************************************************************************/
package resources.objectives;
import main.NGECore;
import resources.objects.creature.CreatureObject;
import resources.objects.mission.MissionObject;
import services.mission.MissionObjective;
@@ -31,27 +33,28 @@ public class DestroyMissionObjective extends MissionObjective {
}
@Override
public void activate() {
public void activate(NGECore core, CreatureObject player) {
// TODO Auto-generated method stub
}
@Override
public void complete() {
public void complete(NGECore core, CreatureObject player) {
// TODO Auto-generated method stub
}
@Override
public void abort() {
public void abort(NGECore core, CreatureObject player) {
// TODO Auto-generated method stub
}
@Override
public void update() {
public void update(NGECore core, CreatureObject player) {
// TODO Auto-generated method stub
}
}
@@ -304,13 +304,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
return buffer;
}
public IoBuffer buildMissionDescriptionDelta(String desc, int id) {
public IoBuffer buildMissionDescriptionDelta(String desc, int id, String additionalParam) {
IoBuffer buffer = IoBuffer.allocate(12 + desc.length(), false).order(ByteOrder.LITTLE_ENDIAN);
IoBuffer buffer = IoBuffer.allocate(13 + desc.length() + additionalParam.length(), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(getAsciiString(desc));
buffer.putInt(0);
buffer.put(getAsciiString("m" + id + "d"));
buffer.put(getAsciiString("m" + id + "d" + additionalParam));
int size = buffer.position();
buffer.flip();
@@ -318,14 +318,14 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
return buffer;
}
public IoBuffer buildMissionTitleDelta(String title, int id) {
IoBuffer buffer = IoBuffer.allocate(12 + title.length(), false).order(ByteOrder.LITTLE_ENDIAN);
public IoBuffer buildMissionTitleDelta(String title, int id, String additionalParam) {
IoBuffer buffer = IoBuffer.allocate(12 + title.length() + additionalParam.length(), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(getAsciiString(title));
buffer.putInt(0);
buffer.put(getAsciiString("m" + id + "t"));
buffer.put(getAsciiString("m" + id + "t" + additionalParam));
int size = buffer.position();
buffer.flip();
@@ -26,6 +26,7 @@ import com.sleepycat.je.Transaction;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import resources.common.BountyListItem;
import resources.objects.intangible.IntangibleObject;
import resources.objects.waypoint.WaypointObject;
import services.mission.MissionObjective;
@@ -53,8 +54,11 @@ public class MissionObject extends IntangibleObject implements IPersistent {
private String type = "";
private int missionTemplateObject = 0;
private WaypointObject attachedWaypoint;
// Server variables
private MissionObjective objective;
private long bountyObjId;
@NotPersistent
MissionMessageBuilder messageBuilder = new MissionMessageBuilder(this);
@@ -148,11 +152,15 @@ public class MissionObject extends IntangibleObject implements IPersistent {
}
public void setMissionDescription(String missionDescription) {
setMissionDescription(missionDescription, "");
}
public void setMissionDescription(String missionDescription, String additionalParam) {
synchronized(objectMutex) {
this.description = missionDescription;
}
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionDescriptionDelta(missionDescription, missionId));
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionDescriptionDelta(missionDescription, missionId, additionalParam));
}
}
@@ -163,11 +171,15 @@ public class MissionObject extends IntangibleObject implements IPersistent {
}
public void setMissionTitle(String missionTitle) {
setMissionTitle(missionTitle, "");
}
public void setMissionTitle(String missionTitle, String additionalParam) {
synchronized(objectMutex) {
this.title = missionTitle;
}
if (getGrandparent() != null && getGrandparent().getClient() != null && getGrandparent().getClient().getSession() != null) {
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionTitleDelta(missionTitle, missionId));
getGrandparent().getClient().getSession().write(messageBuilder.buildMissionTitleDelta(missionTitle, missionId, additionalParam));
}
}
@@ -286,6 +298,14 @@ public class MissionObject extends IntangibleObject implements IPersistent {
this.missionId = missionId;
}
public long getBountyObjId() {
return bountyObjId;
}
public void setBountyObjId(long bountyObjId) {
this.bountyObjId = bountyObjId;
}
public Transaction getTransaction() {
return txn;
}
+2
View File
@@ -323,6 +323,8 @@ public class CharacterService implements INetworkDispatch {
object.addAbility("startDance");
object.addAbility("startDance+Basic");
object.setFaction("neutral");
object.addObjectToEquipList(datapad);
object.addObjectToEquipList(inventory);
object.addObjectToEquipList(bank);
+10
View File
@@ -146,6 +146,12 @@ public class GroupService implements INetworkDispatch {
group.setGroupLeader(leader);
group.getMemberList().add(leader);
group.getMemberList().add(invited);
if (invited.getLevel() > leader.getLevel())
group.setGroupLevel(invited.getLevel());
else
group.setGroupLevel(leader.getLevel());
leader.makeAware(group);
leader.setGroupId(group.getObjectID());
invited.makeAware(group);
@@ -170,6 +176,10 @@ public class GroupService implements INetworkDispatch {
invited.makeAware(group);
invited.setGroupId(group.getObjectID());
invited.sendSystemMessage("@group:joined_self", (byte) 0);
if (group.getGroupLevel() < invited.getLevel())
group.setGroupLevel(invited.getLevel());
addGroupBuffsToMember(group, invited);
core.chatService.joinChatRoom(invited.getCustomName(), group.getChatRoomId(), true);
+22
View File
@@ -58,6 +58,7 @@ import protocol.swg.ShowHelmet;
import protocol.swg.objectControllerObjects.ChangeRoleIconChoice;
import protocol.swg.objectControllerObjects.ShowFlyText;
import protocol.swg.objectControllerObjects.ShowLootBox;
import resources.common.BountyListItem;
import resources.common.FileUtilities;
import resources.common.ObjControllerOpcodes;
import resources.common.Opcodes;
@@ -78,6 +79,7 @@ import resources.objects.player.PlayerMessageBuilder;
import resources.objects.player.PlayerObject;
import resources.objects.tangible.TangibleObject;
import resources.objects.waypoint.WaypointObject;
import services.sui.SUIService.InputBoxType;
import services.sui.SUIService.ListBoxType;
import services.sui.SUIWindow;
import services.sui.SUIWindow.Trigger;
@@ -1252,6 +1254,26 @@ public class PlayerService implements INetworkDispatch {
core.suiService.openSUIWindow(ringWindow);
}
public void sendSetBountyWindow(final CreatureObject victim, final CreatureObject attacker) {
final SUIWindow bountyWindow = core.suiService.createInputBox(InputBoxType.INPUT_BOX_OK_CANCEL, "@bounty_hunter:setbounty_title", "@bounty_hunter:setbounty_prompt1 " + attacker.getCustomName() + "?" + "\n@bounty_hunter:setbounty_prompt2 " + victim.getBankCredits() + victim.getCashCredits(),
victim, null, (float) 10, new SUICallback() {
@Override
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
if (eventType == 0 && returnList.get(0) != null) {
if (core.missionService.getBountyListItem(attacker.getObjectId()) != null) {
BountyListItem currentBounty = core.missionService.getBountyListItem(attacker.getObjectId());
currentBounty.addBounty(Integer.parseInt(returnList.get(0)));
} else {
core.missionService.createNewBounty(attacker, Integer.parseInt(returnList.get(0)));
}
}
}
});
core.suiService.openSUIWindow(bountyWindow);
}
public String getFormalProfessionName(String template) {
String formalName = "";
+2
View File
@@ -991,6 +991,8 @@ public class CombatService implements INetworkDispatch {
if(target.getDuelList().contains(attacker)) handleEndDuel(target, attacker, false);
core.playerService.sendCloningWindow(target, attacker.getSlottedObject("ghost") != null);
//if (attacker.getSlottedObject("ghost") != null)
//core.playerService.sendSetBountyWindow(target, attacker);
}
public boolean areInDuel(CreatureObject creature1, CreatureObject creature2) {
+7 -4
View File
@@ -21,8 +21,11 @@
******************************************************************************/
package services.mission;
import main.NGECore;
import com.sleepycat.persist.model.Persistent;
import resources.objects.creature.CreatureObject;
import resources.objects.mission.MissionObject;
@Persistent(version=0)
@@ -42,10 +45,10 @@ public abstract class MissionObjective {
this.objectivePhase = 0;
}
public abstract void activate();
public abstract void complete();
public abstract void abort();
public abstract void update();
public abstract void activate(NGECore core, CreatureObject player);
public abstract void complete(NGECore core, CreatureObject player);
public abstract void abort(NGECore core, CreatureObject player);
public abstract void update(NGECore core, CreatureObject player);
public long getStartTime() { return startTime; }
+164 -30
View File
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.nio.ByteOrder;
import java.util.Map;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -35,24 +36,29 @@ import main.NGECore;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import com.sleepycat.je.Transaction;
import protocol.swg.ObjControllerMessage;
import protocol.swg.objectControllerObjects.MissionAbort;
import protocol.swg.objectControllerObjects.MissionAcceptRequest;
import protocol.swg.objectControllerObjects.MissionAcceptResponse;
import protocol.swg.objectControllerObjects.MissionListRequest;
import resources.common.BountyListItem;
import resources.common.SpawnPoint;
import resources.common.ObjControllerOpcodes;
import resources.objectives.BountyMissionObjective;
import resources.objectives.DeliveryMissionObjective;
import resources.objectives.DestroyMissionObjective;
import resources.objects.creature.CreatureObject;
import resources.objects.mission.MissionObject;
import resources.objects.player.PlayerObject;
import resources.objects.tangible.TangibleObject;
import resources.objects.waypoint.WaypointObject;
import engine.clientdata.StfTable;
import engine.clients.Client;
import engine.resources.common.CRC;
import engine.resources.common.NameGen;
import engine.resources.container.Traverser;
import engine.resources.database.ObjectDatabase;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Point3D;
import engine.resources.service.INetworkDispatch;
@@ -63,7 +69,9 @@ public class MissionService implements INetworkDispatch {
private NGECore core;
private NameGen nameGenerator;
// Use a HashMap for obtaining number of entries so we aren't using a visitor all the time.
private ConcurrentHashMap<String, Integer> entryCounts = new ConcurrentHashMap<String, Integer>();
private Map<String, Integer> entryCounts = new ConcurrentHashMap<String, Integer>();
private Vector<BountyListItem> bountyList = new Vector<BountyListItem>();
private ObjectDatabase bountiesODB;
private Random ran = new Random();
public MissionService(NGECore core) {
@@ -73,6 +81,8 @@ public class MissionService implements INetworkDispatch {
catch (IOException e) { e.printStackTrace(); }
loadMissionEntryCounts();
bountiesODB = core.getBountiesODB();
}
@Override
@@ -118,7 +128,7 @@ public class MissionService implements INetworkDispatch {
if(client == null || client.getSession() == null)
return;
SWGObject object = client.getParent();
CreatureObject object = (CreatureObject) client.getParent();
if(object == null)
return;
@@ -137,8 +147,12 @@ public class MissionService implements INetworkDispatch {
if (terminalType == TerminalType.GENERIC) {
handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.GENERIC);
} else if (terminalType == TerminalType.BOUNTYHUNTER) {
} else if (terminalType == TerminalType.BOUNTY) {
if (!object.hasSkill("class_bountyhunter_phase1_novice")) {
object.sendSystemMessage("@mission/mission_generic:not_bounty_hunter_terminal", (byte) 0);
} else {
handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.BOUNTY);
}
} else if (terminalType == TerminalType.ENTERTAINER) {
} else if (terminalType == TerminalType.ARTISAN) {
@@ -191,7 +205,7 @@ public class MissionService implements INetworkDispatch {
MissionObjective objective = mission.getObjective();
if (objective != null)
objective.abort();
objective.abort(core, creature);
core.objectService.destroyObject(mission.getObjectId());
}
@@ -267,7 +281,7 @@ public class MissionService implements INetworkDispatch {
if (type == TerminalType.GENERIC)
randomDeliveryMission(player, mission);
else if (type == TerminalType.BOUNTYHUNTER)
else if (type == TerminalType.BOUNTY)
randomBountyMission(player, mission);
else if (type == TerminalType.ARTISAN)
@@ -282,9 +296,9 @@ public class MissionService implements INetworkDispatch {
} else if (typeTwoCount.get() < 4) {
if (type == TerminalType.GENERIC)
randomDestroyMission(player, mission);
return;
else if (type == TerminalType.BOUNTYHUNTER)
else if (type == TerminalType.BOUNTY)
return;
else if (type == TerminalType.ARTISAN)
@@ -293,8 +307,8 @@ public class MissionService implements INetworkDispatch {
else
return;
mission.setRepeatCount(requestCounter);
typeTwoCount.incrementAndGet();
//mission.setRepeatCount(requestCounter);
//typeTwoCount.incrementAndGet();
}
}
});
@@ -338,7 +352,11 @@ public class MissionService implements INetworkDispatch {
return true;
}
private void createMissionObjective(CreatureObject creature, MissionObject mission) {
private MissionObjective createMissionObjective(CreatureObject creature, MissionObject mission) {
return createMissionObjective(creature, mission, false);
}
private MissionObjective createMissionObjective(CreatureObject creature, MissionObject mission, boolean silent) {
switch(mission.getMissionType()) {
case "deliver":
@@ -346,18 +364,32 @@ public class MissionService implements INetworkDispatch {
mission.setObjective(deliveryObjective);
deliveryObjective.activate();
break;
if (!silent)
deliveryObjective.activate(core, creature);
return deliveryObjective;
case "destroy":
DestroyMissionObjective destroyObjective = new DestroyMissionObjective(mission);
mission.setObjective(destroyObjective);
destroyObjective.activate();
break;
if (!silent)
destroyObjective.activate(core, creature);
return destroyObjective;
case "bounty":
BountyMissionObjective bountyObjective = new BountyMissionObjective(mission);
mission.setObjective(bountyObjective);
if (!silent)
bountyObjective.activate(core, creature);
return bountyObjective;
default:
break;
return null;
}
}
@@ -387,33 +419,135 @@ public class MissionService implements INetworkDispatch {
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) {
}
private void randomBountyMission(SWGObject player, MissionObject mission) {
BountyListItem bountyTarget = null;
if (bountyList.size() > 0) {
boolean gotBounty = false;
while (!gotBounty) {
bountyTarget = getRandomBounty();
if (bountyTarget == null || bountyTarget.getAssignedHunters().size() >= 3 || bountyTarget.getCreditReward() < 20000)
continue;
else
gotBounty = true;
}
}
if (bountyTarget == null)
return;
mission.setMissionType("bounty");
String missionStf = "mission/mission_bounty_jedi";
if (!bountyTarget.getProfession().equals("")) { // TODO: Smuggler mission checks.
if (bountyTarget.getFaction().equals("neutral")) {
mission.setMissionTargetName("@mission/mission_bounty_jedi:neutral_jedi");
mission.setMissionId(3);
}
else if (bountyTarget.getFaction().equals("rebel")) {
mission.setMissionTargetName("@mission/mission_bounty_jedi:rebel_jedi");
mission.setMissionId(2);
}
else if (bountyTarget.getFaction().equals("imperial")) {
mission.setMissionTargetName("@mission/mission_bounty_jedi:imperial_jedi");
mission.setMissionId(1);
}
mission.setMissionTitle(missionStf);
mission.setMissionDescription(missionStf);
} else {
// TODO: Dead code, but place-holder for implementation of smuggler missions.
if (bountyTarget.getFaction().equals("neutral")) {
mission.setMissionId(3);
}
else if (bountyTarget.getFaction().equals("rebel")) {
mission.setMissionId(2);
}
else if (bountyTarget.getFaction().equals("imperial")) {
mission.setMissionId(1);
}
mission.setMissionTitle(missionStf, "s");
mission.setMissionDescription(missionStf, "s");
}
mission.setMissionLevel(90);
mission.setCreditReward(bountyTarget.getCreditReward());
mission.setMissionTemplateObject(CRC.StringtoCRC("object/tangible/mission/shared_mission_bounty_jedi_target.iff"));
mission.setBountyObjId(bountyTarget.getObjectId());
}
public enum TerminalType {;
public static final int GENERIC = 1;
public static final int BOUNTYHUNTER = 2;
public static final int BOUNTY = 2;
public static final int ENTERTAINER = 3;
public static final int ARTISAN = 4;
public static final int EXPLORER = 5;
}
public Vector<BountyListItem> getBountyList() {
return this.bountyList;
}
public BountyListItem getRandomBounty() {
int bountyListId = ran.nextInt(bountyList.size());
return bountyList.get(bountyListId);
}
public BountyListItem getBountyListItem(long objectId) {
Vector<BountyListItem> bounties = bountyList;
for (BountyListItem bounty : bounties) {
if (bounty.getObjectId() == objectId)
return bounty;
}
return null;
}
public BountyListItem createNewBounty(CreatureObject bountyTarget, int reward) {
PlayerObject player = (PlayerObject) bountyTarget.getSlottedObject("ghost");
if (player == null)
return null;
if (getBountyListItem(bountyTarget.getObjectId()) != null)
return null;
BountyListItem bounty = new BountyListItem(bountyTarget.getObjectId(), reward, core.playerService.getFormalProfessionName(player.getProfession()), bountyTarget.getFaction(), bountyTarget.getCustomName());
bountyList.add(bounty);
//Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
//bountiesODB.put(bounty, Long.class, BountyListItem.class, txn);
//txn.commitSync();
//System.out.println("Put in bounty for " + bounty.getName() + " with amount " + reward);
return bounty;
}
public boolean addToExistingBounty(CreatureObject bountyTarget, int amountToAdd) {
PlayerObject player = (PlayerObject) bountyTarget.getSlottedObject("ghost");
if (player == null)
return false;
BountyListItem bounty = getBountyListItem(bountyTarget.getObjectId());
if (bounty == null)
return false;
//Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
//bountiesODB.get(bounty, Long.class, BountyListItem.class);
//txn.commitSync();
return true;
}
@Override
public void shutdown() {
}
}