Files
NGECore2/scripts/conversation/missions/deliver.py
T
Waverunner ac9d0e41bf Refactored delivery missions to use pre-spawned commoners
Scripters should change any commoners being spawned to use
core.staticService.spawnCommoner instead of spawnObject (see
mos_eisley.py in static_spawns\tatooine for an example). The
spawnCommoner method will add required attachments and set the proper
options bitmask in order for the missions to function properly.

Note that delivery missions won't work unless you have spawned buildouts
on the planet you are requesting the missions on due to this change.
2014-06-18 14:00:24 -04:00

89 lines
3.0 KiB
Python

from resources.common import OutOfBand
from resources.common import ProsePackage
from resources.objectives import DeliveryMissionObjective
import sys
def startConversation(core, actor, npc):
player = actor.getPlayerObject()
if player is None:
return
activeMissions = player.getActiveMissions()
missionId = checkMissions(core, actor, npc, activeMissions)
if missionId == 0:
core.conversationService.sendStopConversation(actor, npc, 'mission/mission_generic', 'npc_job_request_no_job')
return
mission = core.objectService.getObject(missionId)
if mission is None:
return
objective = mission.getObjective()
if objective is None:
core.conversationService.sendStopConversation(actor, npc, 'mission/mission_generic', 'npc_job_request_no_job')
return
if objective.getObjectivePhase() == 0:
handlePickupStage(core, actor, npc, objective, mission)
return
elif objective.getObjectivePhase() == 1:
handleDeliveryStage(core, actor, npc, objective, mission)
return
elif objective.getObjectivePhase() == 2:
handleCompletionStage(core, actor, npc, objective, mission)
return
return
def endConversation(core, actor, npc):
core.conversationService.sendStopConversation(actor, npc, 'mission/mission_generic', 'npc_job_request_no_job')
return
def handlePickupStage(core, actor, npc, objective, mission):
if objective.getMissionGiver() != npc.getObjectId():
endConversation(core, actor, npc)
return
core.conversationService.sendStopConversation(actor, npc, mission.getTitle().getStfFilename(), 'm' + str(mission.getMissionId()) + 'p')
objective.createDeliveryItem(core, actor)
objective.update(core, actor)
return
def handleDeliveryStage(core, actor, npc, objective, mission):
if objective.getDropOffNpc() != npc.getObjectId():
endConversation(core, actor, npc)
return
core.conversationService.sendStopConversation(actor, npc, mission.getTitle().getStfFilename(), 'm' + str(mission.getMissionId()) + 'r')
core.objectService.destroyObject(objective.getDeliveryObject())
objective.update(core, actor)
return
def handleCompletionStage(core, actor, npc, objective, mission):
if objective.getMissionGiver() != npc.getObjectId():
endConversation(core, actor, npc)
return
core.conversationService.sendStopConversation(actor, npc, mission.getTitle().getStfFilename(), 'm' + str(mission.getMissionId()) + 's')
core.missionService.handleMissionComplete(actor, mission)
return
def checkMissions(core, actor, npc, activeMissions):
for objId in activeMissions:
missionObj = core.objectService.getObject(objId)
if (missionObj != None):
if (missionObj.getStartLocation() is not None and missionObj.getStartLocation().getObjectId() == npc.getObjectID()):
return missionObj.getObjectID()
elif (missionObj.getDestinationLocation() is not None and missionObj.getDestinationLocation().getObjectId() == npc.getObjectID()):
return missionObj.getObjectID()
return 0