Bulletin Board System

From Elite Wiki
Revision as of 02:06, 7 February 2017 by Phkb (talk | contribs)

Overview

This OXP adds a bulletin board to most stations in Oolite, from which missions (added by other OXP's) can be viewed and accepted. This OXP doesn't include any missions itself - it is a framework that other OXP's can utilise to make the process of adding missions easier.

Player Usage

The Bulletin Board is accessed through the Interfaces screen (F4), and it's normally found under "Station Interfaces". If there are no missions available, and you don't have any active missions, the interface won't be listed. When there are missions available, or you have active missions, the number of these will be displayed on the interface entry. eg "Station bulletin board (4 available, 2 active)".

When the interface is opened, any active missions will be grouped at the top of the list. Active missions are marked with a "•" and also have a value in the "%" (percentage completed) column. All other entries in the list are available missions.

When a mission is selected from the list, details of the mission will be displayed. These details include:

DescriptionThe short description of this mission.
DetailsFull details of the mission parameters.
Destination systemWhere the mission needs to be completed at.
Mission expires inHow much time you have to complete the mission.
Payment on completionHow much you will be paid when the mission is completed.
PenaltyHow much you will be charged if you fail to complete the mission. This value will be scaled by how much of the mission you completed.

If you have accepted a mission you will also see:

Percent completeHow much of the mission has been completed so far.

At the bottom of the screen will be the following options:

Accept missionThis will signal that you are starting this mission.
Show destinationThis will display a chart (either a short range or long range, depending on the distance to the destination), allowing the player to see where the destination is.

Once you have accepted a mission, you will see the following options:

Terminate missionThis will signal that you are giving up on this mission. If the mission has a penalty, it will be applied now. The mission will be removed from the list.
Complete missionThis will only be available once the percent complete reaches 100%. This option will give you your payment and remove the mission from the list.

Active missions are shown on the F5F5 Manifest screen, under the "Bulletin Board Missions" heading. Depending on the mission, you will likely see how much of the mission you have yet to complete, and how much time is remaining before the mission expires.

Some missions will automatically complete as soon as you reach 100%, some will complete the next time you dock. It's important to check back on the Bulletin Board to see if you need to "Complete" the mission yourself.

Moving contracts onto the Bulletin Board

If you want to move all the cargo, passenger and parcel contracts onto the Bulletin Board, see the Bulletin Board Contracts OXP.

Technical Details

The purpose of the Bulletin Board system is to create a simple yet flexible interface which OXP authors can use to offer custom missions to the player. Missions added to the list are intended to be only available in the current system. Active missions are stored by the system and saved in the save game file, but the list of available missions will be cleared out with each hyperspace jump.

To add a new mission to the Bulletin Board, you need to run the "$addBBMission" function and pass an object with the following parameters:

 var bb = worldScripts.BulletinBoardSystem;
 if (bb) {
   var myID = bb.$addBBMission({
     description:"My first mission",
     source:7,
     destination:129,
     stationKey:"galcop",
     details:"This is my first sample mission available on the Bulletin board.",
     manifestText:"My mission is active!",
     statusText:"A special text description to include on the briefing screen.",
     expiry:clock.seconds + 86400,
     payment:1000,
     penalty:100,
     deposit:0,
     allowPartialComplete:false,
     allowTerminate:true,
     accepted:false,
     percentComplete:0,
     completionType:"AT_SOURCE",
     stopTimeAtComplete:false,
     markerShape:"MARKER_PLUS",
     markerColor:"cyanColor",
     markerScale:1.0,
     model:"police",
     spinModel:true,
     disablePercentDisplay:true,
     customDisplayItems:"",
     initiateCallback:"$myMissionInitiate",
     completedCallback:"$myMissionComplete",
     confirmCompleteCallback:"$myMissionConfirmComplete",
     terminateCallback:"$myMissionTerminate",
     failedCallback:"$myMissionFailed",
     manifestCallback:"$myMissionUpdateManifest",
     availableCallback:"$myMissionAvailableCheck",
     worldScript:"MyFirstMission"
   });
 }

In detail these parameters are:

description(required) This is the description of the mission shown in the Bulletin board list
source(optional) The system ID of the source of this mission. If not included it will default to the current system's ID.
destination(required) This is the system ID of the destination system where the mission will be carried out. This can be the current system, if the mission is local.
stationKey(optional) The stationKey helps to limit which stations the mission will be offered in. See the section below title "Station Keys" for more details.
If omitted this will default to "" (blank), meaning this mission will be available from all stations in this system
detailsThis is the full details of the mission parameters.
manifestText(optional) This is the text to display on the F5F5 manifest screen when the mission has been accepted. See also "manifestCallback" below.
statusText(optional) This is the text to display on the mission briefing screen when the mission is active. If not set, the "manifestText" property will be used instead.
expiry(required) The time is clock seconds when the mission must be completed by.
payment(required) The number of credits the player will be given when they complete the mission.
penalty(optional) The number of credits the player will be charged if they fail to complete the mission, scaled by the percentage completed.
deposit(optional) The number of credits the player will need to pay up-front to accept the mission. This amount will be refunded when the mission is completed.
allowPartialComplete(optional) True/false value that indicates whether the player can complete the mission with less than the full percentage. Payment and deposit will be scaled by the percentage completed. Penalties will also apply, again scaled by the percentage completed.
For example, if the payment is 100 cr and the penalty 10 cr, and the player completes 70% of the mission, if they hand it in they would receive 70 cr (70% of 100), and the penalty would be 3 cr (30% of 10), meaning their total payment would be 73 cr.
Default is false.
allowTerminate(optional) True/false value indicating whether the "Terminate mission" will be available to the player after accepting the mission. The default is true.
accepted(optional) True/false value indicating whether this mission will be added to the list as already accepted by the player. Under normal circumstances this item can be left out. However, if you want to link missions together, so completing one mission automatically starts a second mission, you may want to add the mission to the list as "accepted:true" so the player doesn't have to go to the Bulletin Board and manually accept the second mission.
The default is false.
percentComplete(optional) A decimal value between 0 and 1. Allows you to create missions that already have some part completed.
completionType(optional) A text value indicating what should happen when the player completes the mission (ie the percentComplete value reached 1, or 100%). Can be one of these:
AT_SOURCEPlayer must return to the source system/station, open the mission and select "Complete mission".
AT_STATIONKEYPlayer can return to any system, dock at any station with the same stationKey, open the mission and select "Complete mission".
ANYWHEREPlayer can return to any system, dock at any station, open the mission and select "Complete mission".
IMMEDIATEPlayer is rewarded immediately when the mission is flagged as 100% complete - player won't need to dock anywhere.
WHEN_DOCKED_SOURCEPlayer is automatically rewarded as soon as they next dock at the source system/station. Notice will appear in arrival report.
WHEN_DOCKED_STATIONKEYPlayer is automatically rewarded as soon as they next dock at any station, any system, but with the same station key. Notice will appear in arrival report.
WHEN_DOCKED_ANYWHEREPlayer is automatically rewarded as soon as they next dock at any station, any system. Notice will appear in arrival report.
The default is "AT_SOURCE".
stopTimeAtComplete(optional) True/value flag to indicate that the clock will stop when the mission is flagged 100% complete.
Default false. This means that, for a completionType of "AT_SOURCE" the player has to return to the original station within the allowed time in order to complete the mission. If this flag is set to true, once the player completes the mission at the destination, they are free to take as much time as they like to return to the original station and hand in their mission.
This flag will be ignored if the completionType is set to "IMMEDIATE".
arrivalReportText(optional) When the completionType is set to "WHEN_DOCKED_*" this text will be displayed on the arrival report when the player completes the mission. If omitted, will default to "'<description>' mission complete. You have been awarded <payment>."
model(optional) Role of a ship to use as the background on the mission details screen.
modelPersonality(optional) The entityPersonality assigned to the ship model.
spinModel(optional) True/false value indicating whether the ship model will rotate or not. The default to true.
background(optional) guiTextureSpecifier (name of a picture used as background)
overlay(optional) guiTextureSpecifier (name of a picture used as overlay). Will default to the bulletin board graphic when not set.
markerShape(optional) Allows the shape of the galactic chart marker to be overridden. Default is "MARKER_PLUS". Possible values are:
NONENo galactic chart marker will be added.
MARKER_XUses an "X" to mark the system.
MARKER_PLUSUses a "+" to mark the system.
MARKER_SQUAREUses a square shape to mark the system.
MARKER_DIAMONDUses a diamond shape to mark the system.
markerColor(optional) Allows the color of the galactic chart marker to be overridden. Default is "redColor".
markerScale(optional) Allows the scale setting of the galactic chart marker to be overridden. Value between 0.5 and 2.0. Default is 1.0.
disablePercentDisplay(optional) Controls the display of the "Percent complete" value on this mission details page. Default false.
When set to true, only the mission manifest text will be shown on the mission details page.
customDisplayItems(optional) Allows a mission to specify additional, non-standard items on the details page.

When used, should be set to an array of dictionary items, having "heading" and "value" properties in each dictionary object.

eg [{heading:"Special Instructions:", value:"Be very, very qwiet..."}]
initiateCallback(required) The function name to call back when the mission is accepted by the player.
completedCallback(required) The function name to call back when the mission is completed by the player, based on the completionType setting.
confirmCompleteCallback(optional) A function name to call to confirm the mission has been completed. Useful if there are secondary steps that must have been completed by the player.

For instance, you might want to check that the player has a particular amount of a certain commodity in their hold.

Expects a string return value of blank (meaning mission is completed) or [string explaining why mission cannot be completed] (meaning the mission is not complete).
terminateCallback(required) The function name to call back when the mission is terminated/cancelled by the player.
failedCallback(optional) The function name to call back when the player fails to complete the mission in the alloted time. Called during the "shipWillDockWithStation" event.
manifestCallback(optional) The function name to call back when the manifest entry for the mission requires updating.
availableCallback(optional) The function to call to check if the mission is actually available. The mission ID will be passed as a parameter. Function should return a string value of either a blank (""), to indicate the mission is available, or a short description of the reason why the mission is unavailable (eg "Insufficient cargo space").
worldScript(required) The name of the worldScript where these functions reside.

This call will return a unique ID (integer) value that can be stored and used to reference this mission in other bulletin board functions.

Once a mission has been added, it is up to the calling script to work out and track the criteria required to complete a mission. The BB system will handle the display of information, and will pay or charge the player if they complete or fail the mission. But the rules which govern the mission criteria are controlled solely by the calling routine. It is up to the calling routine to track the mission and tell the BB system when updates are required.

With that in mind, the following functions will be of use to the calling party:

 $updateBBMissionPercentage(bbID, percentage);

This function will update the percentage completed value for a given mission ID (as provided by the $addBBMission function).

When this function is called, it will also initiate the "manifestCallback" routine, giving the OXP an opportunity to update the manifest entry.

If the percentage is 1 (ie. 100%), and the completionType is "IMMEDIATE", the "completedCallback" routine will be called and the mission will be removed from the list. Otherwise, the mission will be completed at another event (eg when docking, or when the player selects "Complete Mission" on the mission details screen.)

 $updateBBStatusText(bbID, newtext);

This function will update the status text on the mission briefing screen for a given mission ID. This function should generally be called from the "manifestCallback" routine. If no status text is supplied, the "manifestText" property will be used instead.

 $updateBBManifestText(bbID, newtext);

This function will update the manifest text entry for a given mission ID. This function should generally be called from the "manifestCallback" routine.

Some other functions that may be useful:

$shuffleBBListA function to randomise the order of bulletin board items. This can be handy if you add missions to the list in a sequence, but you don't want that sequence to be visible to the player by having all the same types of missions grouped together.
$percentCompleted(bbID)Returns the current percentage complete value for a particular mission ID
$removeBBMission(bbID)Removes a particular mission ID from the list. This method skips any mission constraints and completed/failed events and just removed the record. This can be useful when chaining missions together, if the previous mission needs to be removed completely, without performing any of the callbacks.
$getItem(bbID)Returns a bulletin board mission object for the given mission ID.
$getIndex(bbID)Returns the index value of the given mission ID in the internal data array. This can be useful if you would like to update mission parameters directly (eg. changing the "stopTimeAtComplete" flag).
Note: Because index values are subject to change without notices (particularly between saves) the value returned from this function should be used and then discarded. Do not try to save the index value in some method and use it later - you may be updating a completely different mission!
$registerBBEvent(wsName, fnName, eventName)Registers a worldScript/function to be called when a particular BB system event takes place. At the moment, the possible events are:
missionAddedOccurs when a mission is added to the BB.
preListDisplayOccurs just before the BB mission list is displayed
postListDisplayOccurs just after the BB mission list is displayed
preItemDisplayOccurs just before a mission detail page is displayed. The mission ID will be passed as a parameter.
postItemDisplayOccurs just after a mission detail page is displayed. The mission ID will be passed as a parameter.
preItemChartDisplayOccurs just before the chart view of a mission is displayed. The mission ID will be passed as a parameter.
postItemChartDisplayOccurs just after the chart view of a mission is displayed. The mission ID will be passed as a parameter.

Station Keys

To limit the stations at which a mission will be available from, a station key is required. When the "stationKey" is not provided to the "$addBBMission" function, the mission will be available at all stations in the source system.

Each station can have multiple station keys, depending on the worldScript, but if no specific station key is added, the default station key will be the stations "allegiance" property. So, a station with an allegiance of "galcop" will have a default station key of "galcop". Therefore, if you want to limit your mission to only be available at GalCop-aligned stations, you would include "galcop" in the "stationKey" when adding the mission to the bulletin board. If you want to include your mission at both "galcop" and "chaotic" stations, you would use a comma separator and make your mission stationKey "galcop,chaotic".

But what if allegiance is insufficient to identify the specific station you want to add your mission to? In these cases, you need to give your target station a special stationKey of its own. At some point after the system has been populated, (for instance, during the systemWillPopulate or startUpComplete events), find the station you want to give your special key to and perform the following function:

 var bb = worldScripts.BulletinBoardSystem;
 var stns = system.stations;
 // loop through all the available stations
 for (var i = 0; i < stns.length; i++) {
   // if this station is the one I'm looking for....you'll need to provide some logic for identifying your station
   if (stns[i].<< something >>) {
     // add the station key for this worldScript
     bb.$addStationKey(this.name, stns[i], "myStationKey");
     // first parameter is "worldScriptName". Normally this would be "this.name".
     // second parameter is "station". This is a reference to the station.
     // third parameter is "stationKey". This is the station key that will be added to the list of keys for this worldScript and station combination.
   }
 }

Once the station has been given this custom key for your worldScript, you can use that key when adding missions. The custom key will override whatever default key the station may have had previously. A station can have multiple keys for your worldScript.

For example, let's say I wanted to create a mission that was only available at the main station of the system. However, with OXP's like "Stations For Extra Planets" installed, I can't just rely on the station.allegiance. What I need to do is this:

 this.startUpComplete = function() {
   var bb = worldScript.BulletinBoardSystem;
   bb.$addStationKey(this.name, system.mainStation, "mainStation");
 }

Now I can apply the "mainStation" station key to any bulletin board missions I add, and they will now only be visible at the main station in the system.

Removing the Bulletin Board from a Station

You may decide that you don't want to have the bulletin board at a particular station. This can be achieved in one of two ways:

1. In the shipdata.plist file for the station, include the following item in the "script_info" section:

 "script_info" = {
   "bb_hide" = 1;
 };
 

2. At some point after the system has been populated, find the station you want to hide the bulletin board on and add "bb_hide" value to the "script" property by doing the following:

 var stns = system.stations;
 for (var i = 0; i < stns.length; i++) {
   // if this station is the one I'm looking for....you'll need to provide some logic for identifying your station
   if (stns[i].<< something >>) {
     stns[i].script.bb_hide = 1;
   }
 }

Example Mission Script

In the download package, in the "Resources" sub folder, is a mini-OXP that adds a simple "Asteroid Hunt" mission to the Bulletin Board. This OXP contains examples of most of the functions of the Bulletin Board, and should be used as a reference for OXP developers who want to make use of it.

Download

Download BulletinBoardSystem.oxz v0.17 BulletinBoardSystem.oxz (downloaded 3813 times).
Download BulletinBoardSystem.zip (OXP to extract to AddOns) v0.17 BulletinBoardSystem.zip

License

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

Version History

0.17

  • Added number of jumps to destination to the various mission screens.
  • Origination system and destination system details will now wrap inside the column correctly.
  • Cleanup of chart route mode handling.

0.16

  • Attempt to fix the event callback function generating error when calling functions.

0.15

  • Added "remoteDepositProcess" property, to control whether deduction of the deposit amount should be handled by the BB or by some external process.
  • Changed colour of unavailable items in the main list to be a slightly darker shade of gray.
  • Added a "Net payment" line to missions that have a deposit.
  • Unavailable items will now be put at the bottom of the mission list.
  • Removed the backgroundHeight and overlayHeight properties. The background and overlay properties are now defined as guiTextureSpecifier, which can include these other elements as part of a dictionary.

0.14

  • The "availableCallback" function was not being called on the short or long range chart screens.
  • Added an event registration and execution system, so OXP's can know when various interface events have taken place.
  • Days now included in mission time remaining on the mission detail screen.
  • Fixed issue where "Set course for" options were not being displayed on map screens.
  • Fixed issue where numeric custom display item values were causing an error.
  • Fixed issue where an error would occur if a mission does not have a manifestText entry as well as no manifestCallback.
  • Fixed issue where adding multiple station keys to the same station were not adding data correctly.
  • The stationKeys array was not being reset after a jump.
  • Corrected errors in documentation.
  • Bug fixes.
  • Code refactoring.

0.13

  • Added an "availableCallback" function, to allow for cases where a mission can be added to the BB, but conditions prevent the player from being able to accept it (eg insufficient cargo space).
  • If a mission has a deposit amount as part of the terms of acceptance, this value will be deducted from the payment amount on the first page of the bulletin board display. Brings it into line with the cargo contracts screen.
  • Fixed bug with displaying custom items on a mission detail page.

0.12

  • Moved restoring data process to startUp function.

0.11

  • Added custom menu items that can be used with callbacks to allow custom functions to be called on each mission.
  • Changed methodology for creating mission ID's to eliminate the possibility of ever having two missions with the same ID.
  • Changed short range chart selection range to 7.5ly, rather than 15ly.
  • Fixed another minor bug with the players destination getting reset unexpectedly when viewing mission destinations.
  • Missions added with "autoAccept" turned on will now get their destination marker put on the system map, and (if the Email System is installed) will have confirmation emails sent.
  • Fixed Javascript reference error when terminating a mission.
  • Better handling of interstellar space conditions.
  • Added the "noEmails" option, to stop a mission from sending confirmation emails.
  • Added ability for calling routines to specify their own ID for reference, overriding the default.
  • Changed the console message that is displayed when a mission is manually terminated by the player.
  • Chart markers were not being removed from the chart after missions were completed.
  • Fixed issue with HUD not becoming visible again when launching while viewing the Bulletin Board.
  • Setting a blank value ("") for a mission station key should have allowed the mission to be found and completed at any station in the source system.
  • Swapped "Expiry" and "Payment" columns in the main list to align better with other contract screens (parcels, cargo, passengers).

0.10

  • "terminateCallback" was not being called when a mission was terminated by the player. "failedCallback" was being called instead.
  • Fixed Javascript bug in "failedCallback" routine.

0.9

  • Added optional "deposit" property to mission items, which will be deducted from the player's account when accepting the mission.
  • Added travel time (in hours) to the destination system info and source system info.
  • "Set course" option now takes player's full course into consideration when working out whether the option should be displayed, rather than just the final destination.
  • Fixed issue where player destination was getting reset when BB is exited by pressing a function key, rather than via the "Exit" command.

0.8

  • Fixed issue with AT_SOURCE missions that allow for partial completion, where they could be partially completed at non-source stations.
  • Active but expired missions that are shown on the main BB list will now just show as "Expired".
  • Added "customDisplayItems", so missions can add their own heading/value information items to the mission details page.
  • "Set course for" menu items won't be shown if player already has that system set as their destination.
  • Changed "==" comparisons to "===" for performance improvements.

0.7

  • Accepting a mission now doesn't close the mission briefing screen.
  • Added a "stopTimeAtComplete" boolean value to enable missions to be setup so that, as soon as the mission is flagged 100% complete, the expiry time countdown will stop. This means that the player can take as much time as they want to return to the system and hand in their completed mission. The default for this value is false.
  • Added a "allowPartialComplete" boolean value so that a mission can be handed in early, with a reduction in the payment based on the percentage completed. If penalties also apply it will reduced by the percentage completed.
  • Added a "statusText" text value that will be displayed on the mission briefing screen as the "Current status" instead of the manifestText value.
  • Added the "$updateBBStatusText" function to enable the status text to be updated.
  • Fixed issue with "allowTerminate" not defaulting correctly.
  • Added the originating system to the mission details page.
  • Added the destination system to the main mission list.
  • Changed the "Expires" column to only show hours (or minutes if the time remaining is less than 100 minutes) on the main mission list screen.
  • Moved "Percentage Complete" column to be the last column on the main mission list screen.
  • Changed how stationKeys are added, making it possible for a station to have multiple keys, as well as allowing for multiple worldScripts to have different station keys for the same station.
  • Fixed issue where exiting a multi-page mission briefing and re-opening it was not reseting the current page back to 1.
  • Fixed issue where boolean values of true or false (that is not a text string with "true" or "false" in it) were not being recognised correctly when adding a mission.
  • Changed the way the number of active missions is counted. Now any active mission is listed, not just the non-expired missions.
  • When viewing a completed Bulletin Board mission and the player is not in the originating system, the option to "Set course for [originating system]" will now be available.
  • Corrected logic for determining when a property has been passed in an object when adding new missions.
  • Changed completion types "AT_STATION" and "WHEN_DOCKED_STATION" to be "AT_STATIONKEY" and "WHEN_DOCKED_STATIONKEY" to better describe their purpose.
  • Added a debug flag to turn on/off log messages.
  • If the Email System is installed, accepting, terminating, completing and failing missions will now generate a confirmation email.
  • Added a comma between "# available" and "# active" on the interface screen.

0.6

  • Added an additional check when creating a new mission. Expiry time must be in the future.
  • Fixed bug with "markerShape" setting not being correctly set up.
  • Active missions that have expired are now coloured red in the bulletin board list.
  • Included manifest text on mission briefing page when mission is completed but not yet handed in. Also included expiry time, which is still relevant for completed-yet-not-handed-in missions.
  • Forced manifest entries to be updated each time the manifest screen is viewed in order to keep "Expires in" field up to date.
  • Added "%" to percentage completed text on mission screen.
  • Added a "disablePercentDisplay" boolean value to enable a mission to turn off the display of the "Percent complete" value. This would leave just the manifest text as the method of showing mission status.
  • Completed missions that are about to be handed in will no longer show as being close to expiry.
  • Better handling missions complete when docking where the confirmCompleteCallback function returns a value.
  • Fixed bug when attempting to show the long range chart.
  • Code refactoring.

0.5

  • Fixed remainder of missing "clock" references.

0.4

  • Turned off some debug messages.
  • Fixed missing "clock" reference when updating mission percentage.

0.3

  • Fixed Javascript reference error when displaying mission details.
  • Fixed issue where setting course for the destination system wasn't actually setting the course.
  • Bulletin Board was not reseting itself correctly between views.
  • Fixed issue where the space between accepted and available missions was not appearing if there were only 1 of each type in the list.
  • Added a confirmation screen to the terminate mission process.
  • Added a "Set course for" option to the mission briefing page.
  • Added the "confirmCompleteCallback" callback function, so that secondary steps can be confirmed before a mission can be accepted as complete. This would be useful if there is a possibility that something might have changed between completing the required steps of a mission, and getting to a dock to enter the "Complete Mission" response (eg loosing or selling cargo).

0.2

  • Missions whose expiry time has already passed are now excluded from the list of available missions.
  • Missions whose expiry time is extremely tight are now highlighted on the list of available missions and in the mission details as well.
  • clock.adjustedSeconds now used to calculate remaining time to complete mission.
  • Spelling corrections.

0.1

  • Initial release


Version Released License Features Category Author(s) Feedback
0.17 2017-02-06 CC BY-NC-SA 3.0 Mission framework Misc OXPs phkb Oolite BB

Gameplay and Balance indicator

Tag-colour-green.png