From 6d28ac9cd509e05a3f35e81a53fd94d86066bc39 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Mon, 26 May 2014 18:58:16 -0400 Subject: [PATCH] Fixed mission strings, fixed multiple bounty hunting bugs, added stacks for tracking droids from CBT Fixed bugs for BHing include: Bounty not being removed from bountyMap (they were still removed from the db though) Bounty success/defeat messages were wrong Seeker not being destroyed from world Completing bounty mission would not remove it from log (Allowing you to keep on killing the player and potentially collecting the reward) Fixed conversation messages on Arakyd Droid to use new ProsePackage format --- scripts/commands/setgodmode.py | 3 ++ .../missions/bounty_droid_probot.py | 26 ++--------- scripts/radial/npc/bounty_probot.py | 5 ++ scripts/radial/npc/bounty_seeker.py | 7 ++- .../objectives/BountyMissionObjective.java | 4 ++ .../mission/MissionMessageBuilder.java | 24 +++++----- .../objects/mission/MissionObject.java | 21 +++++---- src/services/DevService.java | 6 ++- src/services/SimulationService.java | 4 +- src/services/combat/CombatService.java | 2 +- src/services/mission/MissionService.java | 46 ++++++++++--------- 11 files changed, 78 insertions(+), 70 deletions(-) diff --git a/scripts/commands/setgodmode.py b/scripts/commands/setgodmode.py index 680ba082..ec5c6133 100644 --- a/scripts/commands/setgodmode.py +++ b/scripts/commands/setgodmode.py @@ -114,6 +114,9 @@ def run(core, actor, target, commandString): playerObject.setGodLevel(0) elif command == 'setBounty': + if actor.getFaction() == "": + actor.sendSystemMessage('You must be aligned in order to place a bounty on yourself.', 0) + return core.playerService.sendSetBountyWindow(actor, actor) return diff --git a/scripts/conversation/missions/bounty_droid_probot.py b/scripts/conversation/missions/bounty_droid_probot.py index ea327232..78fd806b 100644 --- a/scripts/conversation/missions/bounty_droid_probot.py +++ b/scripts/conversation/missions/bounty_droid_probot.py @@ -15,42 +15,26 @@ def startConversation(core, actor, npc): return if probotRequester.getObjectId() != actor.getObjectId(): - prose = ProsePackage('conversation/bounty_probot', 's_6') - outOfBand = OutOfBand() - outOfBand.addProsePackage(prose) - convSvc.sendConversationMessage(actor, npc, outOfBand) + convSvc.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/bounty_probot:s_6')) return mission = core.objectService.getObject(long(npc.getAttachment('attachedMission'))) if mission is None: - prose = ProsePackage('conversation/bounty_probot', 's_4') - outOfBand = OutOfBand() - outOfBand.addProsePackage(prose) - convSvc.sendConversationMessage(actor, npc, prose) + convSvc.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/bounty_probot:s_4')) return objective = mission.getObjective() if objective is None: - prose = ProsePackage('conversation/bounty_probot', 's_4') - outOfBand = OutOfBand() - outOfBand.addProsePackage(prose) - convSvc.sendConversationMessage(actor, npc, prose) + convSvc.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/bounty_probot:s_4')) return - prose = ProsePackage('conversation/bounty_probot', 's_5') - outOfBand = OutOfBand() - outOfBand.addProsePackage(prose) - convSvc.sendConversationMessage(actor, npc, outOfBand) + convSvc.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/bounty_probot:s_5')) options = Vector() - optionProse = ProsePackage('conversation/bounty_probot', 's_8') - optionOOB = OutOfBand() - optionOOB.addProsePackage(optionProse) - options.add(ConversationOption(optionOOB, 0)) + options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/bounty_probot:s_8'), 0)) convSvc.sendConversationOptions(actor, npc, options, handleBioTransmit) - return def handleBioTransmit(core, actor, npc, selection): diff --git a/scripts/radial/npc/bounty_probot.py b/scripts/radial/npc/bounty_probot.py index 1301c027..83cdb93a 100644 --- a/scripts/radial/npc/bounty_probot.py +++ b/scripts/radial/npc/bounty_probot.py @@ -25,6 +25,11 @@ def handleSelection(core, owner, target, option): if not core.terrainService.canBuildAtPosition(owner, owner.getPosition().x, owner.getPosition().z): owner.sendSystemMessage('@mission/mission_generic:probe_droid_bad_location', 0) return + + if target.getUses() == 0: + core.objectService.destroyObject(target) + else: + target.setUses(target.getUses() - 1) mission.getObjective().handleProbeDroidSummon(core, owner) return \ No newline at end of file diff --git a/scripts/radial/npc/bounty_seeker.py b/scripts/radial/npc/bounty_seeker.py index d7e829fe..f619a5bb 100644 --- a/scripts/radial/npc/bounty_seeker.py +++ b/scripts/radial/npc/bounty_seeker.py @@ -26,13 +26,18 @@ def handleSelection(core, owner, target, option): if mission.getObjective().isSeekerActive(): owner.sendSystemMessage('@mission/mission_generic:bounty_already_tracking', 0) return + if target.getUses() == 0: + core.objectService.destroyObject(target) + else: + target.setUses(target.getUses() - 1) pos = SpawnPoint.getRandomPosition(owner.getPosition(), 1, 3, owner.getPlanetId()) ori = owner.getOrientation() seeker = core.staticService.spawnObject('object/creature/npc/droid/crafted/shared_probe_droid_advanced.iff', owner.getPlanet().getName(), 0, pos.x, pos.y, pos.z, ori.y, ori.w) time.sleep(3) owner.sendSystemMessage('@mission/mission_generic:seeker_droid_standby', 0) seeker.setPosture(8) - time.sleep(7.5) + time.sleep(6.5) + core.objectService.destroyObject(seeker) mission.getObjective().beginSeekerUpdates(core, owner) return diff --git a/src/resources/objectives/BountyMissionObjective.java b/src/resources/objectives/BountyMissionObjective.java index fa102f8f..a2d81812 100644 --- a/src/resources/objectives/BountyMissionObjective.java +++ b/src/resources/objectives/BountyMissionObjective.java @@ -134,8 +134,12 @@ public class BountyMissionObjective extends MissionObjective { clearActiveMissions(core, bounty); core.missionService.removeBounty(markObjId); + player.getPlayerObject().setBountyMissionId(0); player.updatePvpStatus(); + + cancelLocationUpdates(); + core.missionService.handleMissionAbort(player, getMissionObject(), true); // Do not call abort method } @Override diff --git a/src/resources/objects/mission/MissionMessageBuilder.java b/src/resources/objects/mission/MissionMessageBuilder.java index c7b61268..22431c85 100644 --- a/src/resources/objects/mission/MissionMessageBuilder.java +++ b/src/resources/objects/mission/MissionMessageBuilder.java @@ -103,13 +103,13 @@ public class MissionMessageBuilder extends IntangibleMessageBuilder { buffer.putInt(mission.getMissionTemplateObject()); + buffer.put(getAsciiString(mission.getMissionStf())); + buffer.putInt(0); buffer.put(getAsciiString(mission.getMissionDescription())); - buffer.putInt(0); - buffer.put(getAsciiString("m" + mission.getMissionId() + "d")); - buffer.put(getAsciiString(mission.getMissionTitle())); + buffer.put(getAsciiString(mission.getMissionStf())); buffer.putInt(0); - buffer.put(getAsciiString("m" + mission.getMissionId() + "t")); + buffer.put(getAsciiString(mission.getMissionTitle())); buffer.putInt(0); // refresh counter @@ -308,13 +308,13 @@ public class MissionMessageBuilder extends IntangibleMessageBuilder { return buffer; } - public IoBuffer buildMissionDescriptionDelta(String desc, int id, String additionalParam) { + public IoBuffer buildMissionDescriptionDelta(String stfFile, String descId) { - IoBuffer buffer = IoBuffer.allocate(13 + desc.length() + additionalParam.length(), false).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(13 + stfFile.length() + descId.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(desc)); + buffer.put(getAsciiString(stfFile)); buffer.putInt(0); - buffer.put(getAsciiString("m" + id + "d" + additionalParam)); + buffer.put(getAsciiString(descId)); int size = buffer.position(); buffer.flip(); @@ -323,13 +323,13 @@ public class MissionMessageBuilder extends IntangibleMessageBuilder { return buffer; } - public IoBuffer buildMissionTitleDelta(String title, int id, String additionalParam) { + public IoBuffer buildMissionTitleDelta(String stfFile, String titleId) { - IoBuffer buffer = IoBuffer.allocate(12 + title.length() + additionalParam.length(), false).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(12 + stfFile.length() + titleId.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(title)); + buffer.put(getAsciiString(stfFile)); buffer.putInt(0); - buffer.put(getAsciiString("m" + id + "t" + additionalParam)); + buffer.put(getAsciiString(titleId)); int size = buffer.position(); buffer.flip(); diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index aa3f4ba2..e6640a05 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -51,6 +51,7 @@ public class MissionObject extends IntangibleObject implements Serializable { private String title = ""; private String missionTargetName = ""; // Target object I guess? private int missionId = 0; + private String missionStf = ""; private String type = ""; private int missionTemplateObject = 0; private WaypointObject attachedWaypoint; @@ -157,15 +158,11 @@ public class MissionObject extends IntangibleObject implements Serializable { } 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, additionalParam)); + getGrandparent().getClient().getSession().write(messageBuilder.buildMissionDescriptionDelta(missionStf, missionDescription)); } } @@ -176,15 +173,11 @@ public class MissionObject extends IntangibleObject implements Serializable { } 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, additionalParam)); + getGrandparent().getClient().getSession().write(messageBuilder.buildMissionTitleDelta(missionStf, missionTitle)); } } @@ -311,6 +304,14 @@ public class MissionObject extends IntangibleObject implements Serializable { this.bountyObjId = bountyObjId; } + public String getMissionStf() { + return missionStf; + } + + public void setMissionStf(String missionStf) { + this.missionStf = missionStf; + } + @Override public void sendBaselines(Client destination) { diff --git a/src/services/DevService.java b/src/services/DevService.java index 452b7321..18a090fa 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -1277,11 +1277,13 @@ public class DevService implements INetworkDispatch { case 123: TangibleObject arakydDroids = (TangibleObject) core.objectService.createObject("object/tangible/mission/shared_mission_bounty_droid_probot.iff", planet); - //arakydDroids.setStackable(true); - //arakydDroids.setStackCount(10); + arakydDroids.setStackable(true); + arakydDroids.setUses(20); inventory.add(arakydDroids); TangibleObject seekerDroids = (TangibleObject) core.objectService.createObject("object/tangible/mission/shared_mission_bounty_droid_seeker.iff", planet); + seekerDroids.setStackable(true); + seekerDroids.setUses(20); inventory.add(seekerDroids); return; diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index fd824cc7..2abb6d75 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -811,13 +811,13 @@ public class SimulationService implements INetworkDispatch { core.mountService.storeAll(object); - for (Integer roomId : ghost.getJoinedChatChannels()) { + /*for (Integer roomId : ghost.getJoinedChatChannels()) { // TODO: Fix Concurrency error ChatRoom room = core.chatService.getChatRoom(roomId.intValue()); if (room != null) { core.chatService.leaveChatRoom(object, roomId.intValue()); } // work-around for any channels that may have been deleted, or only spawn on server startup, that were added to the joined channels else { ghost.removeChannel(roomId); } - } + }*/ /* object.createTransaction(core.getCreatureODB().getEnvironment()); core.getCreatureODB().put(object, Long.class, CreatureObject.class, object.getTransaction()); diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 713152b7..8385c765 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -1027,7 +1027,7 @@ public class CombatService implements INetworkDispatch { attacker.sendSystemMessage(OutOfBand.ProsePackage("@bounty_hunter:bounty_success_hunter", mission.getCreditReward(), "TT", target.getCustomName(), "TO", target.getObjectID()), DisplayType.Broadcast); - target.sendSystemMessage(OutOfBand.ProsePackage("@bounty_hunter:bounty_success_hunter", mission.getCreditReward(), "TT", attacker.getCustomName()), DisplayType.Broadcast); + target.sendSystemMessage(OutOfBand.ProsePackage("@bounty_hunter:bounty_success_target", mission.getCreditReward(), "TT", attacker.getCustomName()), DisplayType.Broadcast); core.missionService.handleMissionComplete(attacker, mission); } diff --git a/src/services/mission/MissionService.java b/src/services/mission/MissionService.java index 967b01f3..60af71ec 100644 --- a/src/services/mission/MissionService.java +++ b/src/services/mission/MissionService.java @@ -216,6 +216,12 @@ public class MissionService implements INetworkDispatch { handleMissionAbort(creature, mission, false); } + /** + * Aborts the target mission for the specified player. If silent is true then MissionObjective.abort is not called. + * @param creature Target player used in MissionObjective.abort + * @param mission Mission to abort + * @param silent If true, called the MissionObjective.abort() method, otherwise it simply destroys the mission (false) + */ public void handleMissionAbort(CreatureObject creature, MissionObject mission, boolean silent) { MissionObjective objective = mission.getObjective(); @@ -263,7 +269,8 @@ public class MissionService implements INetworkDispatch { if (entryCounts.get(missionStf) != null) { ranEntryNum = ran.nextInt(entryCounts.get(missionStf)); } //else { System.out.println(missionStf + " was not found in entryCount and is using entry #1"); } - + if (missionStf.equals("mission/mission_deliver_neutral_hard") && ranEntryNum == 1) // m1s value is "mission_success_mail", so dont even use the mission + return 2; if (ranEntryNum == 0) return 1; else @@ -468,10 +475,10 @@ public class MissionService implements INetworkDispatch { mission.setMissionType("survey"); String missionStf = "mission/mission_npc_survey_neutral_easy"; - + mission.setMissionStf(missionStf); mission.setMissionId(getRandomStringEntry(missionStf)); - mission.setMissionDescription(missionStf); - mission.setMissionTitle(missionStf); + mission.setMissionDescription("m" + mission.getMissionId() + "d"); + mission.setMissionTitle("m" + mission.getMissionId() + "t"); mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3)); @@ -492,10 +499,10 @@ public class MissionService implements INetworkDispatch { String[] difficulties = { "easy", "medium", "hard" }; String missionStf = "mission/mission_deliver_neutral_" + difficulties[ran.nextInt(difficulties.length)]; - + mission.setMissionStf(missionStf); mission.setMissionId(getRandomStringEntry(missionStf)); - mission.setMissionDescription(missionStf, "o"); - mission.setMissionTitle(missionStf); + mission.setMissionDescription("m" + mission.getMissionId() + "d"); + mission.setMissionTitle("m" + mission.getMissionId() + "t"); mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3)); @@ -533,29 +540,26 @@ public class MissionService implements INetworkDispatch { if (attempts >= 5 && !gotBounty) return; } - + if (bountyTarget == null) + return; + mission.setMissionType("bounty"); String missionStf = "mission/mission_bounty_jedi"; + mission.setMissionStf(missionStf); if (!bountyTarget.getProfession().equals("")) { // TODO: Smuggler mission checks. - if (bountyTarget.getFaction().equals("neutral")) { // There were no neutral bounty missions. Remove this when done testing. - mission.setMissionTargetName("@mission/mission_bounty_jedi:neutral_jedi"); - mission.setMissionId(3); - mission.setCreator("Corporate Sector Authority"); - } - else if (bountyTarget.getFaction().equals("rebel")) { + if (bountyTarget.getFaction().equals("rebel")) { mission.setMissionTargetName("Rebel Bounty"); mission.setMissionId(2); mission.setCreator("The Galactic Empire"); - } - else if (bountyTarget.getFaction().equals("imperial")) { + } else if (bountyTarget.getFaction().equals("imperial")) { mission.setMissionTargetName("Imperial Bounty"); mission.setMissionId(1); mission.setCreator("The Alliance"); } - mission.setMissionTitle(missionStf); - mission.setMissionDescription(missionStf); + mission.setMissionTitle("m" + mission.getMissionId() + "t"); + mission.setMissionDescription("m" + mission.getMissionId() + "d"); } else { // TODO: Dead code, but place-holder for implementation of smuggler missions. if (bountyTarget.getFaction().equals("neutral")) { @@ -567,8 +571,8 @@ public class MissionService implements INetworkDispatch { else if (bountyTarget.getFaction().equals("imperial")) { mission.setMissionId(1); } - mission.setMissionTitle(missionStf, "s"); - mission.setMissionDescription(missionStf, "s"); + mission.setMissionTitle("m" + mission.getMissionId() + "ts"); + mission.setMissionDescription("m" + mission.getMissionId() + "ds"); } mission.setMissionLevel(95 + bountyTarget.getFailedAttempts()); @@ -646,7 +650,7 @@ public class MissionService implements INetworkDispatch { public boolean removeBounty(long bountyTarget, boolean listRemove) { if (listRemove) - bountyMap.remove(bountiesODB.get(bountyTarget)); + bountyMap.remove(bountyTarget); bountiesODB.remove(bountyTarget); return true; }