//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Automated Weather Script "Natural Weather" - Made by Blnukem.
//------------------------------------------------------------------------------
// NOTICE:
// • This script is public for others to learn.
// • If this script is used in any way, please give credit to it's creator.
// • Enjoy randomized weather! Other information will be at the bottom.
//------------------------------------------------------------------------------

function WeatherCycle(%args, %weather) {


   if(%args $= "Cancel") { // Kill the script.
      Warn("Natrual Weather has been cancelled");
      Cancel($WeatherCycle);
      return;
   }

   if(($CurrentMission !$= "Affliction") || (Game.class !$= "InfectionGame")) { // If the requirements are not met, don't start the script.
      Error("The Natural Weather script attempted to initiate with invalid activation requirements.");
      return;
   } else if(!isFile("Scripts/ModScripts/WeatherTypes.cs") && ($CurrentMission $= "Affliction")) { // Missing the WeatherTypes file? If so, change the mission.
      cycleMissions();
      messageAll("", "\c2The mission was changed because the Weather Types file is missing. ~wvoice/Announcer/ANN.gameover.wav");
      Error("Major Error: The weather types file is missing.");
   } else if(%args $= "Initiate" && Game.class $= "InfectionGame") { // Just a precaution.
      Warn("The Natural Weather script has been inititated properly. Random weather will now begin.");
      $WeatherCycle = schedule(60000*6, 0, "WeatherCycle", "NaturalWeather");
      return;
   }

   if(%args $= "NaturalWeather" && $CurrentMission $= "Affliction") {
      $WeatherCycle = schedule(60000*6, 0, "WeatherCycle", "NaturalWeather");
      %cycle = getRandom(1, 9);
   if(%cycle == 2)
      LightAfflictionSandStorm();
   else if(%cycle == 3)
      MediumAfflictionSandStorm();
   else if(%cycle == 4)
      HeavyAfflictionSandStorm();
   else if(%cycle == 5)
      AfflictionMeteorStorm();
   else
      AfflictionClear();
      return;
   }
}
