Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion In-System Cargo Delivery

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Open In-System Cargo Delivery mission interface on F4 screen, select mission, pick up cargo and deliver it onto port of destination. Time is not limited, but it is obligatory to perform mission without docking with any outside port. Open In-System Cargo Delivery mission interface on F4 screen, select mission, pick up cargo and deliver it onto port of destination. Time is not limited, but it is obligatory to perform mission without docking with any outside port.
Identifier oolite.oxp.stranger.InSystemCargoDelivery oolite.oxp.stranger.InSystemCargoDelivery
Title In-System Cargo Delivery In-System Cargo Delivery
Category Activities Activities
Author stranger stranger
Version 0.6.0 0.6.0
Tags cargo, system cargo, system
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.Thargoid.PlanetaryCompass:1.02
  • oolite.oxp.Thargoid.PlanetaryCompass:1.02
  • Optional Expansions
    Conflict Expansions
    Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=19668 n/a
    Download URL https://wiki.alioth.net/img_auth.php/6/61/InSystemCargoDelivery.oxz n/a
    License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
    File Size n/a
    Upload date 1610873315

    Documentation

    Also read http://wiki.alioth.net/index.php/In-System%20Cargo%20Delivery

    ReadMe & License.txt

    In-System Cargo Delivery OXP by Stranger
    
    This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license.
    You are free to use and distribute this OXP on non-commercial basis. 
    Rebundling of this OXP within another distribution is permitted as long as it is unchanged.
    Any mods/derivatives of this OXP must be distributed under another names.
    The license information (either as this file or merged into a larger one) must be included in the OXP.
    
    --------------------------------------------------------------
    
    This OXP implements new type of in-system activity: in-system cargo delivery :-)
    
    There are two types of cargo delivery missions:
    Special cargo delivery - extra equipment for research stations beyond the limits of pre-planned regular supply.
    Urgent cargo delivery - equipment for recovery from malfunctions and accidents (first-aid kits, auxiliary/backup systems etc).
    
    Both types of cargo is not cargo in common sense - it is 5 ton container installed in cargo bay as equipment unit. It installs after mission selection and removes after arrival to destination port.
    
    Mission selection interface on F4 page (Ship, System & Status Controls) is hidden after start-up. It reveals only after docking with main station!
    
    In-system cargo delivery missions generates for extra planet ports only - not for main planet ports, not for moon ports, not for space stations!
    
    You need ship with Planet Landing Capability installed and at least 5 tons of free cargo space to accept mission. Mission will not be offered without satisfying these condition.
    You need also at least 250 Cr as insurance fee to pick mission.
    Advanced Space Compass will be very useful too for navigation to destination port, but it is your problem if you think to be able to navigate by visual rules without ASC.
    
    Select mission after arrival onto main station and save to continue later as you wish - mission status will be written to oolite-save file.
    250 Cr will be removed from your cash - this insurance fee will be returned only in case of successful delivery.
    You can load extra cargo for destination port, if you have free cargo space after installing special/urgent cargo unit. Pick mission, load extra cargo, save and run!
    Start from main station, lock ASC onto destination port an go to destination. Destination port is displayed on manifest screen F5-F5.
    It is obligatory to perform mission without docking with any outside port. It is not time limited mission, but in case of docking with any outside port cargo container will be removed and mission will be failed. In case of hyperjump to other system mission will be failed too!
    Mission will be rated as successful in case of cargo delivery onto any port in planet of destination. Land and receive payment and congrats!
    
    ***
    
    Features and dependences:
    
    This package minimum requirement is Oolite 1.82.
    
    Planetary Compass OXZ (author - Thargoid) is mandatory to generate missions correctly.
    PlanetLand (author - stranger) is recommended, but this OXP compatible with PlanetFall (author Thargoid) too.
    Planetary Systems (author - stranger) is also recommended, but you can use Additional Planets SR (authors Redspear, spara, phkb) instead as you wish. In any case no planets - no missions :-)
    
    Credits
    
    Thargoid - Planetary Compass.
    commander vasig - discussion and testing.
    phkn - code refining and fixing some grammar errors.
    Background image for mission screens taken from BGS (authors P.A.Groove, Phantor Gorth, Thargoid, Svengali and Tricky).
    
    --------------------------------------------------------------
    
    Version history:
    
    30.01.2019 - Version 0.6.0	Fixed error in handling of repeated mission query.
    				Premium cash displayed in integer numbers.
    30.01.2019 - Version 0.5.2	Fixed error in manifest.plist
    30.01.2019 - Version 0.5.1	Converted to OXZ
    08.08.2018 - Version 0.5.0	Fixed flawed code generating too many urgent missions.
    				Probability of accidents generating urgent missions tweaked.
    14.05.2018 - Version 0.4.1	Improvements made by phkb:
    				Condition script for special/urgent cargo unit equipment added.
    				Some grammar errors fixed.
    				Missing “use strict” statement added to CargoDelivery.js
    20.04.2018 - Version 0.4	Bug in mission offering condition check fixed.
    				Advanced calculation of payment based on system danger index.
    				Code edited to satisfy OXP Standards recommendations.
    				manifest.plist added.
    10.04.2016 - Version 0.3	Obsolete code lines (used on pre-release testing) removed.
    07.04.2016 - Version 0.2	Mission generator readjusted.
    06.04.2016 - Version 0.1	Initial release - internal testing.

    Equipment

    Name Visible Cost [deci-credits] Tech-Level
    Special Cargo Unit yes 0 1+
    Urgent Cargo Unit yes 0 1+

    Ships

    This expansion declares no ships.

    Models

    This expansion declares no models.

    Scripts

    Path
    Scripts/cargoDelivery.js
    "use strict";
    this.name = "In-System Cargo Delivery";
    this.author = "Stranger";
    this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
    this.description = "In-System cargo delivery";
    this.version = "0.6.0";
    
    this.$planetInfo = new Array();
    this.$planetFlag = new Array();
    
    // No active mission
    
    this.$missionRefuse = "It would seem that you are taking this mission just as outing.\n Really, you'd better prepare for this sort of activity. Ship with planet landing capability and 5 tons of available cargo space at least. And free 250 credits for insurance fee of course.\n Return then you'll be ready.";
    this.$missionEmpty = "Thanks for your willingness, commander.\n Nothing to do in open task list now.";
    this.$missionOffered = "Mission was already offered, commander, and cargo is in your cargo bay. Just deliver it to destination!";
    
    // Special missions
    
    this.$specialCargoList = [
        "Atmospheric Probes",
        "Datapads",
        "Scientific Equipment Toolkit",
        "Long Range Scanners",
        "Scout Spiders",
        "Mining Bots",
        "Mobile Shelter",
        "Meteostation",
        "Seismic Station",
        "Relay Station",
        "Biomaterials",
        "Biosensors"
        ];
    
    this.$specialCargoLegend = [
        "Airborne data gathering is very important for atmospheric research and air survey.\n Special delivery of radiosondes, solar powered sail-planes and multicopters to support field research is needed.",
        "Increased volume of scientific data collected in field explorations demands huge data processing power.\n Data storage and processing devices must be delivered to research field outpost by special flight to prevent loss of valuable information.",
        "We have shortage of functional scientific equipment due to unplanned lag in regular supply.\n Replacement units, spare parts and consumables must be delivered to provide uninterrupted supply for research field outpost.",
        "Long range scanners extremely needed to provide safe remote monitoring of hazardous environment.\n This is dual-purpose technology too risky for regular delivery!",
        "Autonomous bots are extremely valuable tools to increase efficiency and decrease personnel risk for remote field explorations in hazardous environment.\n Special delivery to support field research is needed.",
        "Research group on remote survey camp has a pressing need to replace old mining bots for new ones.",
        "Long-range field expedition needs fully equipped mobile shelter to provide temporary base camp.\n Construction kit must be delivered to remote field observation post to overcome constrains of limited local logistics.",
        "More data needed for understanding perfectly unusual seasonal weather patterns.\n Set of automatic meteo equipment must be deployed in remote field location to support field research.",
        "Sporadic seismic activity poses a threat to planned construction area.\n Seismic detectors must be deployed in remote field location to expand coverage of seismic early warning network.",
        "Ionospheric storms induced by solar activity sometimes interrupts signal transmissions between main colony base and remote sites.\n Relay transceiver must be deployed in remote field location to expand coverage of communication network.",
        "Our terraforming project switched over from modelling studies to field test.\n Biological samples must be delivered intact to testing ground in strictly controlled conditions. Regular delivery of biomaterial is prohibited due to biohazard regulations.",
        "Some new data indicates possibility of alien life on testing ground planned for terraforming.\n Biochips for xenobiota detection must be delivered intact in sterilized container to prevent contamination of alien ecosystem in question."
        ];
    
    // Accident missions
    
    this.$accidentCargoSheet = [
        // life support system failure
        [1,1,2,2,3,3,9,10,11,12],
        // lost in field
        [6,8,8,8,8,8,8,8,8,15],
        // life threatening accident
        [0,0,0,1,1,1,3,4,8,17],
        // fire
        [0,0,1,1,2,2,3,4,6,7],
        // power failure
        [1,2,2,5,5,7,13,13,13,13],
        // seismic collapse
        [0,1,2,3,4,6,7,8,8,8],
        // atmosphere loss
        [1,1,1,2,2,3,3,3,6,7],
        // solar flare
        [2,5,5,5,5,6,7,14,15,16]
        ];
    
    this.$accidentEventLegend = [
        // life support system failure
        "Partial failure of life supporting systems is reported.",
        // lost in field
        "Contact with field survey team was abruptly lost.",
        // life threatening accident
        "A serious life threatened accident with number of badly injured personnel is reported.",
        // fire
        "Installation caught heavy fire. Zone of ignition is isolated, but situation remains critical.",
        // power failure
        "Partial shutdown of installation power grid is reported.",
        // seismic collapse
        "Installation was severely damaged due to seismic shock.",
        // atmosphere loss
        "Part of living area was depressurized.",
        // solar flare
        "Overload and multiple short circuits of electrical network was caused by particularly intense solar storm."
        ];
    
    this.$accidentCargoList = [
        "First-aid Kit",
        "Emergency Toolkit",
        "Repair Toolkit",
        "Spacesuits",
        "Exoskeletons",
        "Radiation Protective Suits",
        "Emergency Shelter",
        "Repair Bots",
        "SAR Drones",
        "Atmosphere Processing Unit",
        "Water Processing Unit",
        "Climate Control Unit",
        "Waste Processing Unit",
        "Auxiliary Power Unit",
        "Auxiliary Navigation Beacon",
        "Communication Transceiver",
        "LAN Mainframes",
        "Biomedical equipment"
        ];
    
    this.$accidentCargoLegend = [
        "Urgent delivery of first-aid medkit is a first priority task to support recovery of accident victims.",
        "Urgent delivery of emergency toolkit is a first priority task to provide personnel survival.",
        "Urgent delivery of repair toolkit is a first priority task to support system recovery.",
        "External repair of installation without spacesuits is ruled out due to lack of breathable atmosphere.\n Urgent delivery of spacesuits is a first priority task to perform external activity.",
        "It is extremely important to provide safe access onto zone of accident. Using of heavy bots is not option.\n Urgent delivery of exoskeletons is a first priority task to clear way for special task team.",
        "High level of background radiation poses a threat to health of unshielded personnel.\n Urgent delivery of radiation protective suits is a first priority task to support safe work of repair team.",
        "Urgent delivery of emergency shelter is a first priority task to provide personnel survival.",
        "Environment too hazardous for personnel prevents manned activity.\n Urgent delivery of repair bots is a first priority task to perform crucial part of repair mission.",
        "It is absolutely essential to begin search and rescue mission as soon as possible.\n Urgent delivery of SAR drones is a first priority task to support salvage operations.",
        "Urgent delivery of atmospheric processing unit is a first priority task to support breathable atmosphere.",
        "Urgent delivery of water processing unit is a first priority task to recover from water deficiency.",
        "Urgent delivery of climate control unit is a first priority task to provide acceptable living conditions.",
        "Urgent delivery of waste processing unit is a first priority task to recycle waste.",
        "Urgent delivery of auxiliary power unit is a first priority task to support power for repair mission.",
        "Shutdown of navigation system makes regular supply too risky.\n Urgent delivery of auxiliary navigation beacon is a first priority task to support safe port operations.",
        "Shutdown of communication network makes external activity too risky.\n Urgent delivery of communication transceiver is a first priority task to support safe external operations.",
        "Partial shutdown of computing network led to serious degradation of port functionality.\n Urgent delivery of new LAN mainframes is a first priority task to recover installation functions.",
        "Physical state of some victims is too bad to cope with regular first-aid kit.\n Urgent delivery of special biomedical equipment is a first priority task to support recovery of accident victims."
        ];
    
    this.startUp = function()
        {
        if (missionVariables.cargoDelivery_missionFlag == "ON")                    // activate saved mission
            {
            this.$planetFlagSelected = missionVariables.cargoDelivery_planetFlag;
            this.$deliveryItem = missionVariables.cargoDelivery_deliveryItem;
            this.$destinationPort = missionVariables.cargoDelivery_destinationPort;
            this.$urgentMissionFlag = missionVariables.cargoDelivery_urgentFlag;
            this.$specialMissionFlag = missionVariables.cargoDelivery_specialFlag;
            this.$dangerStatus();
            this.$insuranceFee = 250;                  
            if (this.$urgentMissionFlag >= 0)
                {            
                this.$urgentPremium = 500 + 500 * this.$dangerIndex;
                this.$urgentPremiumTotal = this.$insuranceFee + this.$urgentPremium;
                }
            else
                {
                this.$specialPremium = 250 + 250 * this.$dangerIndex;
                this.$specialPremiumTotal = this.$insuranceFee + this.$specialPremium;
                }
            }
        }
    
    this.shipWillExitWitchspace = function()
        {
        // reset mission flags
        this.$awardMissionFlag = -1;      // set mission offer block OFF
        this.$planetInfoSelected = 0;
        this.$planetFlagSelected = 0;
        missionVariables.cargoDelivery_missionFlag = "OFF";
        missionVariables.cargoDelivery_planetFlag = 0;
        missionVariables.cargoDelivery_destinationPort = "";
        missionVariables.cargoDelivery_deliveryCash = 0;
        mission.setInstructions(null);
        }
    
    this.shipDockedWithStation = function(station)
        {
        // main station - contract offer
        if (player.ship.dockedStation.isMainStation == true)
            {
            this.$initInterface(station);    
            }
        // cargo delivered
        if ((player.ship.equipmentStatus ("EQ_SCU") == "EQUIPMENT_OK") || (player.ship.equipmentStatus ("EQ_UCU") == "EQUIPMENT_OK"))
            {
            this.$cargoRemove(station);
            }
        }
    
    this.$initInterface = function(station)
        {
    	station.setInterface(this.name,{
    		title:"In-System Cargo Delivery",
    		category:"Deliveries",
    		summary:"Pick up special cargo and transfer it to appointed port",
    		callback:this.$setupMissionPage.bind(this)
            });
        }
    
    this.$setupMissionPage = function()
        {
    	this.$showMissionPage();
        }
    
    this.$showMissionPage = function()
        {
        // scan all system planets
        this.$scanSystem();
        if(this.$awardMissionFlag == -1)
            {
            this.$setMissionGenerator();
            this.$missionActualInfo();        
            }
        else
            {
            this.$missionObsoleteInfo();
            }
        }
    
    this.shipApproachingPlanetSurface = function(planet) 
        {
        if (planet.radius == this.$planetFlagSelected)
            {
            this.$deliveryFlag = 1;
            }
        else
            {
            this.$deliveryFlag = 0;
            }
        }
    
    this.$scanSystem = function()
        {
        this.$planetNameList = worldScripts["planetaryCompass_worldScript.js"].planetNames;
        this.$planetList = worldScripts["planetaryCompass_worldScript.js"].stellarArray;
        }
    
    this.$setMissionGenerator = function()
        {    
        var k = 0;
        for (let i=0; i<this.$planetList.length; i++)
            {
    		if(this.$planetList[i].hasAtmosphere)
                {
                this.$planetInfo[k] = this.$planetNameList[k];
                this.$planetFlag[k] = this.$planetList[i].radius;
                k += 1;            
                }
            }
        var p = Math.floor(Math.random()*k);
        this.$planetInfoSelected = this.$planetInfo[p];
        this.$planetFlagSelected = this.$planetFlag[p];
        this.$awardMissionFlag = 1;                                             // set mission flag ON
        this.$dangerStatus();
        this.$insuranceFee = 250;
    
        // set emergency mission - high priority!
        this.$urgentlMissionFlag = -1;
        this.$LSSRate = 0.975;                                                  // life support systems durability
        this.$LSSRateTotal = Math.pow(this.$LSSRate,k);                         // cumulative life support systems durability
        this.$flareRate = 1 - system.info.corona_flare / 100;                   // equipment durability for solar flares
        this.$flareRateTotal = Math.pow(this.$flareRate,k);                     // cumulative durability for solar flares
        this.$genericUrgentRate = 0.990;                                        // generic accident durability
        this.$genericUrgentRateTotal = Math.pow(this.$genericUrgentRate,k);     // cumulative accident durability
        this.$urgentPremium = 500 + 500 * this.$dangerIndex;
        this.$urgentPremiumTotal = this.$insuranceFee + this.$urgentPremium;
        this.$generateUrgentMission();
    
        // set special mission
        this.$specialMissionFlag = -1;
        this.$specialLogisticRate = 0.75 - 0.5 * this.$dangerIndex;             // more logistic lags in more dangerous systems
        this.$specialLogisticTotal = Math.pow(this.$specialLogisticRate,k);     // cumulative logistic rate
        this.$specialPremium = 250 + 250 * this.$dangerIndex;
        this.$specialPremiumTotal = this.$insuranceFee + this.$specialPremium;
        if (this.$specialLogisticTotal < Math.random())
            {
            this.$generateSpecialMission();
            }    
        }
    
    this.$generateSpecialMission = function()
        {
        this.$specialMissionIndex = Math.floor(Math.random()*12);    
        this.$specialMissionFlag = this.$specialMissionIndex;
        if((this.$planetFlagSelected < 40000) && ((this.$specialMissionIndex == 0) || (this.$specialMissionIndex > 6)))
            {
            this.$specialMissionFlag = -1;                                      // exclude some equipment for small planets without dense atmosphere
            }
        if((this.$planetFlagSelected >= 100000) && (this.$specialMissionIndex > 3))
            {
            this.$specialMissionFlag = -1;                                      // exclude surface based equipment for gas giant stations
            }
        if(this.$planetFlagSelected == system.mainPlanet.radius)
            {
            this.$specialMissionFlag = -1;   // exclude main planet
            }
        }
    
    this.$generateUrgentMission = function()
        {
        if(this.$LSSRateTotal < Math.random())
            {
            this.$urgentMissionFlag = 0; // life support system failure
            }
        if(this.$flareRateTotal < Math.random())
            {
            this.$urgentMissionFlag = 1; // lost in field
            }
        if(this.$flareRateTotal < Math.random())
            {
            this.$urgentMissionFlag = 7; // solar storm
            }
        if(this.$genericUrgentRateTotal < Math.random())
            {
            this.$urgentMissionIndex = Math.floor(Math.random()*7);        
            this.$urgentMissionFlag = this.$urgentMissionIndex;                 // generic accidents
            }
        if((this.$planetFlagSelected >= 100000) && ((this.$urgentMissionIndex == 1) || (this.$urgentMissionIndex == 5)))
            {
            this.$urgentMissionFlag = -1;                                       // exclude ground based accidents on gas giants        
            }
        if(this.$planetFlagSelected == system.mainPlanet.radius)
            {
            this.$urgentMissionFlag = -1;                                       // exclude main planet
            }
        }
    
    this.$cargoLoad = function()
        {
        // set mission state for save
        missionVariables.cargoDelivery_missionFlag = "ON";
        missionVariables.cargoDelivery_planetFlag = this.$planetFlagSelected;
        missionVariables.cargoDelivery_deliveryItem = this.$deliveryItem;
        missionVariables.cargoDelivery_destinationPort = this.$destinationPort;
        missionVariables.cargoDelivery_urgentFlag = this.$urgentMissionFlag;
        missionVariables.cargoDelivery_specialFlag = this.$specialMissionFlag;    
        // load cargo
        if(this.$urgentMissionFlag >= 0)
            {
            player.ship.awardEquipment("EQ_UCU");        
            missionVariables.cargoDelivery_deliveryCash = this.$urgentPremium;
            }
        else
            {
            player.ship.awardEquipment("EQ_SCU");         
            missionVariables.cargoDelivery_deliveryCash = this.$specialPremium;
            }
        player.credits -= this.$insuranceFee;
        }
    
    this.$cargoRemove = function(station)
        {
        // unload cargo & reset mission state
        var arrivalInfo = "";
        player.ship.removeEquipment("EQ_SCU");
        player.ship.removeEquipment("EQ_UCU");    
        missionVariables.cargoDelivery_missionFlag = "OFF";
        missionVariables.cargoDelivery_planetFlag = 0;
        missionVariables.cargoDelivery_deliveryItem = "";    
        missionVariables.cargoDelivery_destinationPort = "";
        missionVariables.cargoDelivery_deliveryCash = 0;
        missionVariables.cargoDelivery_urgentFlag = -1;
        missionVariables.cargoDelivery_specialFlag = -1; 
        // pay cash & generate mission info
        if(station.hasRole("planetFall_surface") && this.$deliveryFlag == 1)     // delivery successfull - emergency OR special mission check
            {
            if(this.$urgentMissionFlag >= 0)
                {
                player.credits += this.$urgentPremiumTotal;
                arrivalInfo = "Thank you for help commander!" + "\n\n"
                + this.$urgentPremium.toFixed(0) + " Cr already transferred to you cash with " + this.$insuranceFee + " Cr of insurance fee, " + this.$urgentPremiumTotal.toFixed(0) + " Cr total." + "\n\n"
                + "Good luck!";
                }
            else
                {
                player.credits += this.$specialPremiumTotal;
                arrivalInfo = "Thank you for help commander!" + "\n\n"
                + this.$specialPremium.toFixed(0) + " Cr already transferred to you cash with " + this.$insuranceFee + " Cr of insurance fee, " + this.$specialPremiumTotal.toFixed(0) + " Cr total." + "\n\n"
                + "Good luck!";
                }
            }
        else        // delivery failed
            {
            arrivalInfo = "You failed to delivery cargo commander!" + "\n\n"
            + "More responsible pilot will be selected for this job next time." + "\n\n"
            + "Good-bye!";        
            }
        mission.runScreen({
        title: "Cargo Arrival Info",
        background: {name: "specialCargoLoad.png", height: 480 },
        message: arrivalInfo,}
            );
        }
    
    this.$missionActualInfo = function()
        {
        var u = -1;
        var s = -1;
        this.$destinationPort = system.info.name + " " + this.$planetInfoSelected;
        var deliveryInfo = "";
        // emergency missions
        // *** item selection
        if(this.$urgentMissionFlag >= 0)
            {
            u = this.$urgentMissionFlag;        
            this.$urgentBreef = this.$accidentEventLegend[u];
            this.$urgentMissionList  = this.$accidentCargoSheet[u];
            var l = Math.floor(Math.random()*10);
            this.$urgentCargoTag = this.$urgentMissionList[l];
            var t = this.$urgentCargoTag;
            this.$urgentCargoItem = this.$accidentCargoList[t];
            this.$urgentCargoLegend = this.$accidentCargoLegend[t];
            this.$deliveryItem = this.$urgentCargoItem;
            }
        if(u >= 0)
            {
            deliveryInfo = "Urgent cargo delivery - "
                            + this.$urgentCargoItem + "\n\n"
                            + this.$urgentBreef + "\n\n"
                            + this.$urgentCargoLegend + "\n\n"
                            + "Destination port: " + this.$destinationPort + "\n\n"
                            + "Insurance fee " + this.$insuranceFee + " Cr will be removed from your cash if you will assign this contract." + "\n"
                            + "This fee will be returned with " + this.$urgentPremium.toFixed(0) + " Cr premium only in case of successful cargo delivery.";
            // *** case 1 - ship is not equipped for mission
            if((player.ship.equipmentStatus ("EQ_PLANETFALL") != "EQUIPMENT_OK") || (player.ship.cargoSpaceAvailable < 5) || (player.credits < this.$insuranceFee))
                {
                deliveryInfo = this.$missionRefuse;
                mission.runScreen({
                title: "Cargo Delivery Info",
                background: {name: "specialCargoLoad.png", height: 480 },
                message: deliveryInfo,}
                );
                }
            // *** case 2 - mission available
            else
                {
                mission.runScreen({
                title: "Cargo Delivery Info",
                background: {name: "specialCargoLoad.png", height: 480 },
                message: deliveryInfo,
                choicesKey: "cargo_contract"},
                function (choice)
                    {
                    if (choice === "1_Accept_Contract")  this.$cargoLoad();
                    }
                );
                }
            }
    
        // special missions
        if(u >= 0) return;                                                      // check for emergency missions priority!
        s = this.$specialMissionFlag;
        this.$deliveryItem = this.$specialCargoList[s];
        if(s >= 0)
            {
            deliveryInfo = "Special cargo delivery - "
                            + this.$specialCargoList[s] + "\n\n"
                            + this.$specialCargoLegend[s] + "\n\n"
                            + "Destination port: " + this.$destinationPort + "\n\n"
                            + "Insurance fee " + this.$insuranceFee + " Cr will be removed from your cash if you will assign this contract." + "\n"
                            + "This fee will be returned with " + this.$specialPremium.toFixed(0) + " Cr premium only in case of successful cargo delivery.";
            }
    
                        // *** case 1 - ship is not equipped for mission
        if((player.ship.equipmentStatus ("EQ_PLANETFALL") != "EQUIPMENT_OK") || (player.ship.cargoSpaceAvailable < 5) || (player.credits < this.$insuranceFee))
            {
            deliveryInfo = this.$missionRefuse;
            mission.runScreen({
            title: "Cargo Delivery Info",
            background: {name: "specialCargoLoad.png", height: 480 },
            message: deliveryInfo,}
            );
            }
        else
            {
            if (s >= 0) // *** case 2 - mission available
                {
                mission.runScreen({
                title: "Cargo Delivery Info",
                background: {name: "specialCargoLoad.png", height: 480 },
                message: deliveryInfo,
                choicesKey: "cargo_contract"},
                function (choice)
                    {
                    if (choice === "1_Accept_Contract")  this.$cargoLoad();
                    }
                );
                }
            else        // *** case 3 - no mission
                {
                deliveryInfo = this.$missionEmpty;
                mission.runScreen({
                title: "Cargo Delivery Info",
                background: {name: "specialCargoLoad.png", height: 480 },
                message: deliveryInfo,}
                );            
                }
            }
        
        }
    
    this.$missionObsoleteInfo = function()
        {
        var deliveryInfo = "";
        if (missionVariables.cargoDelivery_missionFlag == "ON")
            {
            deliveryInfo = this.$missionOffered;
            mission.runScreen({
            title: "Cargo Delivery Info",
            background: {name: "specialCargoLoad.png", height: 480 },
            message: deliveryInfo,}
                );        
            }    
        else
            {
            deliveryInfo = this.$missionEmpty;
            mission.runScreen({
            title: "Cargo Delivery Info",
            background: {name: "specialCargoLoad.png", height: 480 },
            message: deliveryInfo,}
                );        
            }
        }
    
    this.guiScreenWillChange = function (to, from)
        {
        if (to === "GUI_SCREEN_MANIFEST")
            {
            if (missionVariables.cargoDelivery_missionFlag == "ON")
                {
                this.portInfo = "In-System Cargo Delivery: " + this.$deliveryItem + " to " + this.$destinationPort + ".";
                mission.setInstructions(this.portInfo);
                }
            else
                {
                mission.setInstructions(null);
                }
            
            }
        }
    
    this.$dangerStatus = function()
        {
    	if(system.isInterstellarSpace || !system.sun || system.sun.isGoingNova || system.sun.hasGoneNova) return;
        var g = system.info.galaxyID;
        this.$dangerLevelTotal = 25 - 5 * system.government;                    // system danger level per se
        var dangerLevel = 0;
        var l = System.infoForSystem(g, system.ID).systemsInRange();
        for (var i = 0; i < l.length; i++)
            {
            var m = l[i].systemID;
            dangerLevel = 5 - System.infoForSystem(g, m).government;            // 7 LY zone of influence added
            this.$dangerLevelTotal += dangerLevel;        
            }
        this.$dangerLevelMax = 25 + 5 * l.length;                               // max possible danger level
        this.$dangerRate = this.$dangerLevelTotal / this.$dangerLevelMax;       // final danger level
        this.$dangerIndex = this.$dangerRate.toFixed(3);
        }
    Scripts/cargoDeliveryConditions.js
    "use strict";
    this.name = "InSystemCargoDelivery_Conditions";
    this.author = "stranger";
    this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
    this.description = "Condition script for equipment.";
    this.licence = "CC BY-NC-SA 4.0";
    
    //-------------------------------------------------------------------------------------------------------------
    this.allowAwardEquipment = function (equipment, ship, context) {
        if (context === "scripted") return true;
        return false;
    }