| Scripts/smivs_space_pizza_script.js | "use strict";
// Standard attributes 
this.name           = "smivs_space_pizza_script"; 
this.author         = "Smivs"; 
this.licence        = "Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License";
this.copyright      = "Smivs"; 
this.version        = "3.1"; 
this.description    = "Main script to add Giant Space Pizzas and related objects to selected systems, and control the 'mission' elements of the OXP" 
this.startUp = function()
{
// This section writes modified planet descriptions to the save file
    System.infoForSystem(0, 152).description = "The world Isatre is a boring planet, but has a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(0, 238).description = "This world is a tedious place. There is a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(1, 192).description = "The world Sosole is fabled for its weird rock formations and the Sosoleian deadly goat. There is a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(2, 56).description = "This planet is notable for the Atistisoian edible poet and Atistisoian evil brandy. It also has a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(3, 134).description = "Usgeat is cursed by dreadful civil war and has a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(3, 189).description = "This planet is very notable for its inhabitants' ingrained shyness and its fabulous cuisine. A Giant Space Pizza can be found in orbit around its Sun";
    System.infoForSystem(4, 50).description = "The planet Raleor is scourged by killer edible Leilcearoids. It has a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(5, 193).description = "The planet Biteen is reasonably noted for mud tennis and its unusual sit coms. A Giant Space Pizza is in orbit around its Sun";
    System.infoForSystem(6, 150).description = "This world is reasonably well known for its great dense forests but scourged by frequent civil war. A Giant Space Pizza is in orbit around its Sun";
    System.infoForSystem(6, 158).description = "This world is very notable for the Xerasoian edible moth. A Giant Space Pizza is in orbit around its Sun";
    System.infoForSystem(6, 205).description = "This planet is a dull world. It has a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(7, 13).description = "This planet is a dull world. It has a Giant Space Pizza in orbit around its Sun";
    System.infoForSystem(7, 168).description = "The planet Xetila is famous for Xetilaian wolf cutlets but plagued by a lethal disease. It has a Giant Space Pizza in orbit around its Sun"; 
// set status
  if(!missionVariables.GiantSpacePizza_status)
    {
      missionVariables.GiantSpacePizza_status = "DEFAULT";
    }
// set mission flag
  this.missionFlag = "NO";
// Mark pizzas on charts at startup
  this.$markPizzas()
//close startUp function
  this.startUpComplete;
  delete this.startUp;
}
this.playerEnteredNewGalaxy = function()
{
// Mark pizzas on charts after gal-jump
  this.$markPizzas()
// Allow for GalJump from Pizza system to or within 3 jumps of a Pizza System
  missionVariables.GiantSpacePizza_jumpCount = "JUMPS_0";
  missionVariables.GiantSpacePizza_status = "DEFAULT";
}
// Marks pizzas on charts
this.$markPizzas = function()
{
  if (galaxyNumber == 0)
    {
    mission.markSystem({
      system: 152,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      },
                      {
      system: 238,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 1)
    {
    mission.markSystem({
      system: 192,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 2)
    {
    mission.markSystem({
      system: 56,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 3)
    {
    mission.markSystem({
      system: 134,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      },
                      {
      system: 189,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 4)
    {
    mission.markSystem({
      system: 50,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 5)
    {
    mission.markSystem({
      system: 193,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 6)
    {
    mission.markSystem({
      system: 150,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      },
                      {
      system: 158,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      },
                      {
      system: 205,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
  else if (galaxyNumber == 7)
    {
    mission.markSystem({
      system: 13,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      },
                      {
      system: 168,
      name: "Giant Space Pizza",
      markerColor: "yellowColor",
      markerScale: 1.0,
      markerShape: "MARKER_DIAMOND"
                      });
    }
}
// Populates Pizzas, Stewards and Visitor centres
this.systemWillPopulate = function() 
{
  if 
  (
  !system.isInterstellarSpace && galaxyNumber == 0 && system.ID == 152 ||
  !system.isInterstellarSpace && galaxyNumber == 0 && system.ID == 238 ||
  !system.isInterstellarSpace && galaxyNumber == 1 && system.ID == 192 ||
  !system.isInterstellarSpace && galaxyNumber == 2 && system.ID == 56 ||
  !system.isInterstellarSpace && galaxyNumber == 3 && system.ID == 134 ||
  !system.isInterstellarSpace && galaxyNumber == 3 && system.ID == 189 ||
  !system.isInterstellarSpace && galaxyNumber == 4 && system.ID == 50 ||
  !system.isInterstellarSpace && galaxyNumber == 5 && system.ID == 193 ||
  !system.isInterstellarSpace && galaxyNumber == 6 && system.ID == 150 ||
  !system.isInterstellarSpace && galaxyNumber == 6 && system.ID == 158 ||
  !system.isInterstellarSpace && galaxyNumber == 6 && system.ID == 205 ||
  !system.isInterstellarSpace && galaxyNumber == 7 && system.ID == 13 ||
  !system.isInterstellarSpace && galaxyNumber == 7 && system.ID == 168 
  )
  {
  system.setPopulator("space_pizza_system",
          {
            callback: function(pos) 
              {
// Add the pizza
                var GSP = system.addShipsToRoute("smivs_space_pizza", 1, 0.96, "ws")[0];
// Add a safety steward
		var GSPSteward = system.addShips("Pizza-safety-steward", 1, GSP.position, 15000)[0];
// Add the visitor centre
                var SPVC = system.addShipsToRoute("smivs_pizza_giftshop", 1, 0.5, "ps")[0];
// next line sets up a vector SPVC --> planet
                var targetVector = system.mainPlanet.position.subtract(SPVC.position).direction();
// next line aligns the station relative to the targetVector by rotating
                SPVC.orientation = targetVector.rotationTo(new Vector3D(1,0,1));
              },
            deterministic: false
          });
  }
}
this.missionScreenOpportunity = function ()
// next section runs missionscreens at relevent main Stations
{
  if (player.ship.docked && player.ship.dockedStation.isMainStation && missionVariables.GiantSpacePizza_status == "DEFAULT"  && this.missionFlag && this.missionFlag === "NO") 
    {
      if 
        (
        galaxyNumber == 0 && system.ID == 152 ||
        galaxyNumber == 0 && system.ID == 238 ||
        galaxyNumber == 1 && system.ID == 192 ||
        galaxyNumber == 2 && system.ID == 56 ||
        galaxyNumber == 3 && system.ID == 134 ||
        galaxyNumber == 3 && system.ID == 189 ||
        galaxyNumber == 4 && system.ID == 50 ||
        galaxyNumber == 5 && system.ID == 193 ||
        galaxyNumber == 6 && system.ID == 150 ||
        galaxyNumber == 6 && system.ID == 158 ||
        galaxyNumber == 6 && system.ID == 205 ||
        galaxyNumber == 7 && system.ID == 13 ||
        galaxyNumber == 7 && system.ID == 168 
        )
    mission.runScreen({title: "!!! Major Visitor Attraction !!!", messageKey: "SPMainStnGreeting1", model:"smivs_pizza_giftshop"});
    this.missionFlag = "DONE";
    }
//  next section runs mission screens at visitor centres
  else if(player.ship.docked && player.ship.dockedStation.hasRole("smivs_pizza_giftshop") && missionVariables.GiantSpacePizza_status == "DEFAULT" && this.missionFlag && this.missionFlag === "NO")
    {
      if 
       (
       missionVariables.GiantSpacePizza_stage === "STAGE_1" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_2" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_3" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_4" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_5" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_6" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_7" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_8" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_9" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_10" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_11" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_12"
       )
// next lines run the standard visitor centre mission screen
       {
       mission.runScreen({title: "Giant Space Pizza Visitor Centre", messageKey: "SPVC_greeting1", choicesKey: "space_pizza_history_choice", background: { name: "SPVC.png", height: 512 }}, this.choices);
       this.missionFlag = "DONE";
       }
// If player docks at stage_13...
    else if (missionVariables.GiantSpacePizza_stage === "STAGE_13")
// next lines run the special 'Elite PizzaMan' mission screen
       {
       mission.runScreen({title: "Giant Space Pizza Visitor Centre", messageKey: "SPVC_greeting3", choicesKey: "space_pizza_history_choice", background: { name: "elitePizzaman.png", height: 512 }}, this.choices);
// then we give the reward!
       player.credits += 35;
       player.ship.fuel = 7.0;
       mission.setInstructionsKey ("elitePizzaman");
       missionVariables.GiantSpacePizza_stage = "STAGE_14";
       this.missionFlag = "DONE";
       }
// If player docks at stage_14...
    else if (missionVariables.GiantSpacePizza_stage === "STAGE_14") 
// next lines run the standard 'Elite PizzaMan' mission screen
       {
      mission.runScreen({title: "Giant Space Pizza Visitor Centre", messageKey: "SPVC_greeting4", choicesKey: "space_pizza_history_choice", background: { name: "elitePizzaman.png", height: 512 }}, this.choices);
       player.credits += 35;
       player.ship.fuel = 7.0;
       this.missionFlag = "DONE";
       }
    }
//  next section runs re-visit mission screen at visitor centres
  else if(player.ship.docked && player.ship.dockedStation.hasRole("smivs_pizza_giftshop") && this.missionFlag && this.missionFlag === "NO" && missionVariables.GiantSpacePizza_status == "VISITED_GIFTSHOP")
    {
      if 
       (
       missionVariables.GiantSpacePizza_stage === "STAGE_1" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_2" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_3" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_4" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_5" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_6" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_7" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_8" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_9" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_10" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_11" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_12" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_13" ||
       missionVariables.GiantSpacePizza_stage === "STAGE_14" 
       )
// next lines run the special mission screen for immediate re-visits to the Visitor Centre
       {
       mission.runScreen({title: "Giant Space Pizza Visitor Centre", messageKey: "SPVC_greeting5",background: { name: "SPVC.png", height: 512 }});
       this.missionFlag = "DONE";
       }
    }
}
this.choices = function(choice)
{
  switch(choice)
    {
      case "1_Yes":
        {
  mission.runScreen({title: "History of the Giant Space Pizza", messageKey: "space_pizza_history1", choicesKey: "space_pizza_history_continue", background: { name: "history1.png", height: 512 }}, this.choices);
  break;
        }
      case "2_No":
        {
  mission.runScreen({title: "Giant Space Pizza Visitor Centre", messageKey: "SPVC_greeting2", background: { name: "pizzaBG.png", height: 512 }}, this.choices);
  break;
        }
      case "1_Continue":
        {
  mission.runScreen({title: "History of the Giant Space Pizza", messageKey: "space_pizza_history2", choicesKey: "space_pizza_history_finish", background: { name: "history2.png", height: 512 }}, this.choices);
  break;
        }
      case "1_Continue1":
        {
  mission.runScreen({title: "Giant Space Pizza Visitor Centre", messageKey: "SPVC_greeting2", background: { name: "pizzaBG.png", height: 512 }}, this.choices);	
  break;
        }	
    }
}
this.shipWillDockWithStation = function(station)
// prevents stage count from increasing on re-visit to same giftshop
{
 if(station.primaryRole == "smivs_pizza_giftshop" && missionVariables.GiantSpacePizza_status == "VISITED_GIFTSHOP")
   {
     return;
   }
// count active visits
 else if(station.primaryRole == "smivs_pizza_giftshop" && missionVariables.GiantSpacePizza_status == "DEFAULT")
   {
// Set up stages for count
   if (!missionVariables.GiantSpacePizza_stage)
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_1";
     }
// then increase count on each visit
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_1")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_2";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_2")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_3";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_3")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_4";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_4")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_5";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_5")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_6";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_6")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_7";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_7")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_8";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_8")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_9";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_9")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_10";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_10")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_11";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_11")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_12";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_12")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_13";
     }
   else if (missionVariables.GiantSpacePizza_stage === "STAGE_13")
     {
       missionVariables.GiantSpacePizza_stage = "STAGE_14";
     }
   }
}
this.shipDockedWithStation = function(station)
{
 if(station.primaryRole == "smivs_pizza_giftshop")
   {
// next line deducts visitor fees from player
   player.credits -= 35;
// next lines starts 'musak' for giftshop
   this.pizza_musak = new SoundSource; 
   this.pizza_musak.sound = "pizza-musak.ogg";
   this.pizza_musak.loop = true;
   this.pizza_musak.play();
   }
}
this.shipWillLaunchFromStation = function(station) 
{
 if(station.primaryRole == "smivs_pizza_giftshop")
   {
// stops giftshop 'musak' and re-sets status and mission flag 
   this.pizza_musak.stop();
   missionVariables.GiantSpacePizza_status = "VISITED_GIFTSHOP";
   this.missionFlag = "NO";
   }
 if(station.isMainStation)
   {
// reset mission flag
   this.missionFlag = "NO";
   }
}
this.playerWillEnterWitchspace = function()
// three-jump count after each visit to deter re-visits
{
  if (missionVariables.GiantSpacePizza_status === "VISITED_GIFTSHOP" && !missionVariables.GiantSpacePizza_jumpCount)
     {
       missionVariables.GiantSpacePizza_jumpCount = "JUMPS_1";
     }
// then increase count on each jump
  else if (missionVariables.GiantSpacePizza_status === "VISITED_GIFTSHOP" && missionVariables.GiantSpacePizza_jumpCount === "JUMPS_0")
    {
       missionVariables.GiantSpacePizza_jumpCount = "JUMPS_1";
    }
  else if (missionVariables.GiantSpacePizza_status === "VISITED_GIFTSHOP" && missionVariables.GiantSpacePizza_jumpCount === "JUMPS_1")
    {
       missionVariables.GiantSpacePizza_jumpCount = "JUMPS_2";
    }
  else if (missionVariables.GiantSpacePizza_status === "VISITED_GIFTSHOP" && missionVariables.GiantSpacePizza_jumpCount === "JUMPS_2")
    {
       missionVariables.GiantSpacePizza_jumpCount = "JUMPS_3";
    }
  else if (missionVariables.GiantSpacePizza_status === "VISITED_GIFTSHOP" && missionVariables.GiantSpacePizza_jumpCount === "JUMPS_3")
    {
       missionVariables.GiantSpacePizza_jumpCount = "JUMPS_0";
       missionVariables.GiantSpacePizza_status = "DEFAULT";
    }
// Prevent pizza system going nova
// Code by cim
  if (galaxyNumber != 3) { return; }
  if (missionVariables.novacount >= 2 &&
        !missionVariables.nova &&
        (player.ship.targetSystem == 134 || player.ship.targetSystem == 189))
  {
    missionVariables.novacount = 1; //delay the nova mission
  }
}
 |