Mod:Nebula's Mission Board/ Reward cutscenes
When players leave a dungeon successfully after completing at least one job, they will be brought to the map defined inside the end_dungeon_day_destination setting. The library will then expect your code to use the reward handler here.
Do note that the end_dungeon_day_destination can also be a place where you assigned one or more job boards. It doesn't need to be a completely separate place.
Go to your end_dungeon_day_destination's Enter function and paste this code in it, before any kind of fade-in occurs:
if MissionGen:HasCompletedMissions() then MissionGen:PlayJobsCompletedCutscene() end
If the map has no job board assigned to it, this is already everything you need to do. PlayJobsCompletedCutscene will move the flow of execution to the maps where the completed jobs' board is set and then simply return, letting those maps handle the rest.
If that is not the case, however, you will also need to write the reward cutscene, and then pass it to the function like so:
MissionGen:PlayJobsCompletedCutscene(<callback>)
This should be done in any map where there's a job board.
Writing a Reward Cutscene
When PlayJobsCompletedCutscene is called, it looks for the first completed job in the taken list. If the board that job has been taken from is not assigned to the current map, the player is transported to the correct map, where another instance of the function is then expected to run. If the map is correct, however, a list of GroundChars is created and then passed to the callback you provided the function with, alongside the job table itself. In other words, the callback needs to be a function with the following signature:
function(job, npcs)
where:
jobis the Job Table. See the Job Table Documentation page for more detailsnpcsis the list of GroundChars, already added to the map at the coordinates 0, 0. It contains 4 characters for law enforcement jobs, 2 for jobs with a friendly target, and 1 for jobs with no targets
This function is what needs to implement the reward cutscene. You can use the job data and the number of npcs created to move the characters to the correct positions, differentiate between multiple boardss in the same map, if you have to, and then display a different introductory dialogue depending on the job type. Then, whenever you need to actually give the rewards to your players, call the following function
MissionGen:RewardPlayer(job, speaker, line1, line2)
where:
jobis the Job Table, needed to read what the rewards arespeakeris the character that will say the lines given in the next parameters. If omitted, the lines will be displayed with no speaker.line1is the line thatspeakerwill say before giving the first reward to the player, unless the client itself is the rewardline2is the line thatspeakerwill say before giving the second reward to the player, if it exists
This function will handle everything in regards to rewards, without moving the characters around. You will then be able to add more actions after it returns.
When the cutscene is done, simply add a fade-out, and you'll be good to go. PlayJobsCompletedCutscene will dispose of the characters and move to the next completed job, or return control to the player if there are no more completed jobs.
