Advertisement
Guest User

Iban

a guest
Sep 10th, 2010
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 15.46 KB | None | 0 0
  1. // In the archive I found this in, my file was dated for 3/14/2009.
  2. // This is well over a year before the publish date of "RP Weather."
  3.  
  4. // I have no problems with people using my code. Even if they copy and paste it almost verbatim.
  5. // In fact, I'm glad my work is being used and appreciated a full year past its prime.
  6. // I'm even glad people are learning from it.
  7. // I learned TS the same way: by ripping up existing add-ons.
  8. // But to take what I have, copy and paste it, change some file paths
  9. // and then to claim 100% credit is what is known as 'plagarism' and is totally unacceptable.
  10.  
  11. // JJstorm, you have a lot of growing up to do.
  12.  
  13. // Source: scriptobjects.cs
  14. // File Created: 3/14/2009
  15. // ============================================================
  16. // Section 5 : WeatherSO
  17. // ============================================================
  18. function WeatherSO::loadForecast(%so)
  19. {
  20.     // Rain Probability
  21.     %so.rainProb[0] = 5; //"Ibanuary";
  22.     %so.rainProb[1] = 10; //"February";
  23.     %so.rainProb[2] = 15; //"March";
  24.     %so.rainProb[3] = 20; //"April";
  25.     %so.rainProb[4] = 30; //"May";
  26.     %so.rainProb[5] = 40; //"June";
  27.     %so.rainProb[6] = 50; //"July";
  28.     %so.rainProb[7] = 40; //"August";
  29.     %so.rainProb[8] = 30; //"September";
  30.     %so.rainProb[9] = 20; //"October";
  31.     %so.rainProb[10] = 15; //"November";
  32.     %so.rainProb[11] = 10; //"December";
  33.     %so.rainProb[12] = 0; //"Undecimber";
  34.    
  35.     // Snow Probability
  36.     %so.snowProb[0] = 30; //"Ibanuary";
  37.     %so.snowProb[1] = 15; //"February";
  38.     %so.snowProb[2] = 5; //"March";
  39.     %so.snowProb[3] = 0; //"April";
  40.     %so.snowProb[4] = 0; //"May";
  41.     %so.snowProb[5] = 0; //"June";
  42.     %so.snowProb[6] = 0; //"July";
  43.     %so.snowProb[7] = 0; //"August";
  44.     %so.snowProb[8] = 0; //"September";
  45.     %so.snowProb[9] = 5; //"October";
  46.     %so.snowProb[10] = 15; //"November";
  47.     %so.snowProb[11] = 30; //"December";
  48.     %so.snowProb[12] = 100; //"Undecimber";
  49. }
  50.  
  51. function WeatherSO::todaysForecast(%so)
  52. {
  53.     %month = CalendarSO.getMonth();
  54.    
  55.     %snowProb = %so.snowProb[%month];
  56.     %rainProb = %so.rainProb[%month];
  57.     %clearProb = 100 - (%so.snowProb[%month] + %so.rainProb[%month]);
  58.    
  59.     %snowPow = getRandom(0, %snowProb);
  60.     %rainPow = getRandom(0, %rainProb);
  61.     if(%clearProb > 0)
  62.         %clearPow = getRandom(0, %clearProb);
  63.    
  64.     if(%snowPow > %rainPow && %snowPow > %clearPow)
  65.         %forecast = "snow";
  66.     else if(%rainPow > %snowPow && %rainPow > %clearPow)
  67.         %forecast = "rain";
  68.     else
  69.         %forecast = "";
  70.    
  71.     if(%forecast !$= "")
  72.     {
  73.         %intensity = getRandom(0, 15);
  74.        
  75.         if(%forecast $= %so.currWeather)
  76.             %verb = "remains";
  77.         else
  78.         {
  79.             %so.currWeather = %forecast;
  80.             %verb = "is";
  81.         }
  82.        
  83.         %intensity = getRandom(5, 15);
  84.        
  85.         switch$(%forecast)
  86.         {
  87.             case "snow":
  88.                 %so.generateWeather("snow", %intensity);
  89.                 messageAll('', '\c6 - Today\'s forecast %1 Snowy.', %verb);
  90.             case "rain":
  91.                 %so.generateWeather("rain", %intensity);
  92.                 messageAll('', '\c6 - Today\'s forecast %1 Rainy.', %verb);
  93.             default:
  94.                 %so.generateWeather("", 0);
  95.                 messageAll('', '\c6 - Today\'s forecast %1 \c0INVALID\c6.', %verb);
  96.         }
  97.     }
  98.     else
  99.     {
  100.         messageAll('', "\c6 - Today's forecast is Clear.");
  101.         %so.generateWeather("", 0);
  102.     }
  103. }
  104.  
  105. function WeatherSO::generateWeather(%so, %weather, %intensity)
  106. {
  107.     warn("WEATHER ADJUSTING TO:" SPC "[" @ %weather @ "] WITH INTENSITY OF [" @ %intensity @ "]");
  108.    
  109.     if(isObject(Precipitation))
  110.         Precipitation.delete();
  111.    
  112.     $CityRPG_Temp::CurrWeather = %weather;
  113.    
  114.     if(%weather !$= "" && (%intensity = mFloor(%intensity)) > 0)
  115.     {      
  116.         switch$(%weather)
  117.         {
  118.             case "snow":
  119.                 %db = "SnowA";
  120.                 %mutliplier = 0.15;
  121.             case "rain":
  122.                 %db = "CityRPG_Rain";
  123.                 %mutliplier = 0.5;
  124.             default:
  125.                 %db = "SnowA";
  126.                 %mutliplier = 0.15;
  127.         }
  128.        
  129.         %intensity = %intensity * %mutliplier;
  130.         // Default Properties
  131.         %numDrops = 500 * %intensity;
  132.         %minSpeed = 0.5 * %intensity;
  133.         %maxSpeed = 1 * %intensity;
  134.         %minMass = 0.75 * %intensity;
  135.         %maxMass = 0.85 * %intensity;
  136.         %maxTurbulence = 0.1 * %intensity;
  137.         %turbulenceSpeed = 0.5 * %intensity;
  138.        
  139.         new Precipitation(Precipitation)
  140.         {
  141.             dataBlock = %db;
  142.             numDrops = %numDrops;
  143.            
  144.             position = "191.844 621.068 566.484";
  145.             rotation = "1 0 0 0";
  146.             scale = "1 1 1";
  147.             doCollision = "1";
  148.            
  149.             boxWidth = "100";
  150.             boxHeight = "100";
  151.            
  152.             minSpeed = %minSpeed;
  153.             maxSpeed = %maxSpeed;
  154.            
  155.             minMass = %minMass;
  156.             maxMass = %maxMass;
  157.            
  158.             useTurbulence = "false";
  159.             maxTurbulence = %maxTurbulence;
  160.             turbulenceSpeed = %turbulenceSpeed;
  161.             rotateWithCamVel = "false";
  162.         };
  163.        
  164.         Sky.setName("Sky_Old");
  165.         switch$(%weather)
  166.         {
  167.             case "rain":
  168.                 new Sky(Sky)
  169.                 {
  170.                     materialList = "Add-Ons/GameMode_CityRPG/shapes/Skies/Rain/resource.dml";
  171.                     position = "336 136 0";
  172.                     rotation = "1 0 0 0";
  173.                     scale = "1 1 1";
  174.                     cloudHeightPer[0] = "0.6";
  175.                     cloudHeightPer[1] = "0.3";
  176.                     cloudHeightPer[2] = "0.4";
  177.                     cloudSpeed1 = "0.003";
  178.                     cloudSpeed2 = "0.001";
  179.                     cloudSpeed3 = "0.0001";
  180.                     visibleDistance = "140";
  181.                     fogDistance = "40";
  182.                     fogColor = "0.250000 0.250000 0.300000 1.000000";
  183.                     fogStorm1 = "0";
  184.                     fogStorm2 = "0";
  185.                     fogStorm3 = "0";
  186.                     fogVolume1 = "0 0 0";
  187.                     fogVolume2 = "0 0 0";
  188.                     fogVolume3 = "0 0 0";
  189.                     fogVolumeColor1 = "128.000000 128.000000 128.000000 -222768174765569860000000000000000000000.000000";
  190.                     fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
  191.                     fogVolumeColor3 = "128.000000 128.000000 128.000000 -170698929442160050000000000000000000000.000000";
  192.                     windVelocity = "0.5 0 0";
  193.                     windEffectPrecipitation = "1";
  194.                     SkySolidColor = "0.000000 0.000000 0.100000 1.000000";
  195.                     useSkyTextures = "1";
  196.                     renderBottomTexture = "0";
  197.                     noRenderBans = "0";
  198.                     locked = "true";
  199.                 };
  200.             case "snow":
  201.                 new Sky(Sky)
  202.                 {
  203.                     position = "312 96 0";
  204.                     rotation = "1 0 0 0";
  205.                     scale = "1 1 1";
  206.                     materialList = "base/data/skies/Sky_Spooky3/resource.dml";
  207.                     cloudHeightPer[0] = "0.349971";
  208.                     cloudHeightPer[1] = "0.3";
  209.                     cloudHeightPer[2] = "0.199973";
  210.                     cloudSpeed1 = "0.0005";
  211.                     cloudSpeed2 = "0.001";
  212.                     cloudSpeed3 = "0.0003";
  213.                     visibleDistance = "1500";
  214.                     fogDistance = "1000";
  215.                     fogColor = "0.900000 0.900000 0.900000 1.000000";
  216.                     fogStorm1 = "0";
  217.                     fogStorm2 = "0";
  218.                     fogStorm3 = "0";
  219.                     fogVolume1 = "0 0 0";
  220.                     fogVolume2 = "0 0 0";
  221.                     fogVolume3 = "0 0 0";
  222.                     fogVolumeColor1 = "0.000000 0.000000 0.000000 1.000000";
  223.                     fogVolumeColor2 = "0.000000 0.000000 0.000000 1.000000";
  224.                     fogVolumeColor3 = "0.000000 0.000000 0.000000 1.000000";
  225.                     windVelocity = "0.25 0.25 0";
  226.                     windEffectPrecipitation = "1";
  227.                     SkySolidColor = "0.600000 0.600000 0.600000 1.000000";
  228.                     useSkyTextures = "1";
  229.                     renderBottomTexture = "0";
  230.                     noRenderBans = "0";
  231.                 };
  232.            
  233.         }
  234.         Sky_Old.delete();
  235.     }
  236.     else
  237.     {
  238.         Sky.setName("Sky_Old");
  239.         new Sky(Sky)
  240.         {
  241.             position = "336 136 0";
  242.             rotation = "1 0 0 0";
  243.             scale = "1 1 1";
  244.             materialList = "Add-Ons/GameMode_CityRPG/shapes/Skies/Clear/resource.dml";
  245.             cloudHeightPer[0] = "0.349971";
  246.             cloudHeightPer[1] = "0.3";
  247.             cloudHeightPer[2] = "0.199973";
  248.             cloudSpeed1 = "0.0005";
  249.             cloudSpeed2 = "0.001";
  250.             cloudSpeed3 = "0.0003";
  251.             visibleDistance = "5000";
  252.             fogDistance = "800";
  253.             fogColor = "0.900000 0.900000 1.000000 1.000000";
  254.             fogStorm1 = "0";
  255.             fogStorm2 = "0";
  256.             fogStorm3 = "0";
  257.             fogVolume1 = "0 0 0";
  258.             fogVolume2 = "0 0 0";
  259.             fogVolume3 = "0 0 0";
  260.             fogVolumeColor1 = "128.000000 128.000000 128.000000 -222768174765569860000000000000000000000.000000";
  261.             fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
  262.             fogVolumeColor3 = "128.000000 128.000000 128.000000 -170698929442160050000000000000000000000.000000";
  263.             windVelocity = "0 0 0";
  264.             windEffectPrecipitation = "0";
  265.             SkySolidColor = "0.000000 0.000000 0.100000 1.000000";
  266.             useSkyTextures = "1";
  267.             renderBottomTexture = "0";
  268.             noRenderBans = "0";
  269.             locked = "true";
  270.         }; 
  271.         Sky_Old.delete();      
  272.     }
  273. }
  274.  
  275. if(!isObject(WeatherSO))
  276. {
  277.     //new scriptObject(WeatherSO) { };
  278.     //WeatherSO.loadForecast();
  279. }
  280.  
  281. // Source: RP_Weather/game.cs
  282. // File Created: 9/6/2010
  283. // -=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  284. // 2. Manual Commands To Set Weather
  285. // -=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  286. function getweather() {
  287.    
  288.     // Get The Chances Of Rain/Snow
  289.    
  290.     // Make Rain/Snow?
  291.     if(RPModExist("RP_Radio")) {
  292.     %radioname = $RP::pref::radioname;
  293.     %radiofreq = $RP::pref::radiofreq;
  294.     }
  295.     else
  296.     {
  297.     %radioname = "City Radio";
  298.     %radiofreq = "103.5";
  299.     }
  300.     %month = $RP::pref::timeMonth;
  301.     %snowchance = $RP::pref::SnowMonth[%month];
  302.     %rainchance = $RP::pref::RainMonth[%month];
  303.     %clearchance = 100 - (%snowchance + %rainchance);
  304.    
  305.     %snowPow = getRandom(0, %snowchance);
  306.     %rainPow = getRandom(0, %rainchance);
  307.     if(%clearchance > 0)
  308.         %clearPow = getRandom(0, %clearchance);
  309.    
  310.     if(%snowPow > %rainPow && %snowPow > %clearPow)
  311.         %forecast = "snow";
  312.     else if(%rainPow > %snowPow && %rainPow > %clearPow)
  313.         %forecast = "rain";
  314.     else
  315.         %forecast = "";
  316.    
  317.     if(%forecast !$= "")
  318.     {
  319.         %currweather = $RP::pref::CurrWeather;
  320.         if(%forecast $= %currweather)
  321.         {
  322.             %verb = "remains";
  323.         }
  324.         else
  325.         {
  326.             %verb = "is";
  327.         }
  328.    
  329.         %intensity = getRandom(5, 50);
  330.  
  331.         switch$(%forecast)
  332.         {
  333.             case "snow":
  334.                 generateWeather("snow", %intensity);
  335.                 messageAll('', '\c6<color:ffff00>[<color:ffffff>%1 %2<color:ffff00>]:Today\'s forecast %3 <color:ffffff>Snowy.', %radioname, %radiofreq, %verb);
  336.             case "rain":
  337.                 generateWeather("rain", %intensity);
  338.                 messageAll('', '\c6<color:ffff00>[<color:ffffff>%1 %2<color:ffff00>]:Today\'s forecast %3 <color:ffffff>Rainy.', %radioname, %radiofreq, %verb);
  339.             default:
  340.                 generateWeather("", 0);
  341.                 messageAll('', '\c6<color:ffff00>[<color:ffffff>%1 %2<color:ffff00>]: Today\'s forecast %1 \c0INVALID\c6.', %radioname, %radiofreq);
  342.         }
  343.     }
  344.     else
  345.     {
  346.         messageAll('', '\c6<color:ffff00>[<color:ffffff>%1 %2<color:ffff00>]: Today\'s forecast is <color:ffffff>Clear.', %radioname, %radiofreq);
  347.         generateWeather("", 0);
  348.     }
  349. }
  350.  
  351. function generateWeather(%weather, %intensity)
  352. {
  353.     if(%weather $= "rain" || %weather $= "snow") {
  354.         warn("WEATHER ADJUSTING TO:" SPC "[" @ %weather @ "] WITH INTENSITY OF [" @ %intensity @ "]");
  355.        
  356.         if(isObject(Precipitation))
  357.             Precipitation.delete();
  358.  
  359.         // Set Prefs Currectly
  360.         if(%weather $= rain) { %weathercurr = "Rain"; } else
  361.         if(%weather $= snow) { %weathercurr = "Snow"; } else
  362.         if(%weather $= clear) { %weathercurr = "Clear"; }
  363.        
  364.         $RP::pref::CurrWeather = %weathercurr;
  365.            
  366.             if(%weather !$= "" && (%intensity = mFloor(%intensity)) >= 0)
  367.             {
  368.                 switch$(%weather)
  369.                 {
  370.                     case "snow":
  371.                         %db = "SnowA";
  372.                         %mutliplier = 0.15;
  373.                     case "rain":
  374.                         %db = "RP_Weather_Rain";
  375.                         %mutliplier = 0.5;
  376.                     default:
  377.                         %db = "SnowA";
  378.                         %mutliplier = 0.15;
  379.                 }
  380.                
  381.                 %intensity = %intensity * %mutliplier;
  382.                 // Default Properties
  383.                 %numDrops = 400 * %intensity;
  384.                 %minSpeed = 0.5 * %intensity;
  385.                 %maxSpeed = 1 * %intensity;
  386.                 %minMass = 0.75 * %intensity;
  387.                 %maxMass = 0.85 * %intensity;
  388.                 %maxTurbulence = 0.1 * %intensity;
  389.                 %turbulenceSpeed = 0.5 * %intensity;
  390.                
  391.                 new Precipitation(Precipitation)
  392.                 {
  393.                     dataBlock = %db;
  394.                     numDrops = %numDrops;
  395.                    
  396.                     position = "191.844 621.068 566.484";
  397.                     rotation = "1 0 0 0";
  398.                     scale = "1 1 1";
  399.                     doCollision = "1";
  400.                    
  401.                     boxWidth = "100";
  402.                     boxHeight = "100";
  403.                    
  404.                     minSpeed = %minSpeed;
  405.                     maxSpeed = %maxSpeed;
  406.                    
  407.                     minMass = %minMass;
  408.                     maxMass = %maxMass;
  409.                    
  410.                     useTurbulence = "false";
  411.                     maxTurbulence = %maxTurbulence;
  412.                     turbulenceSpeed = %turbulenceSpeed;
  413.                     rotateWithCamVel = "false";
  414.                 };
  415.            
  416.                 Sky.setName("Sky_Old");
  417.                 switch$(%weather)
  418.                 {
  419.                     case "rain":
  420.                         new Sky(Sky)
  421.                         {
  422.                             materialList = "Add-Ons/RP_Weather/Skies/Rain/resource.dml";
  423.                             position = "336 136 0";
  424.                             rotation = "1 0 0 0";
  425.                             scale = "1 1 1";
  426.                             cloudHeightPer[0] = "0.6";
  427.                             cloudHeightPer[1] = "0.3";
  428.                             cloudHeightPer[2] = "0.4";
  429.                             cloudSpeed1 = "0.003";
  430.                             cloudSpeed2 = "0.001";
  431.                             cloudSpeed3 = "0.0001";
  432.                             visibleDistance = "140";
  433.                             fogDistance = "40";
  434.                             fogColor = "0.250000 0.250000 0.300000 1.000000";
  435.                             fogStorm1 = "0";
  436.                             fogStorm2 = "0";
  437.                             fogStorm3 = "0";
  438.                             fogVolume1 = "0 0 0";
  439.                             fogVolume2 = "0 0 0";
  440.                             fogVolume3 = "0 0 0";
  441.                             fogVolumeColor1 = "128.000000 128.000000 128.000000 -222768174765569860000000000000000000000.000000";
  442.                             fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
  443.                             fogVolumeColor3 = "128.000000 128.000000 128.000000 -170698929442160050000000000000000000000.000000";
  444.                             windVelocity = "0.5 0 0";
  445.                             windEffectPrecipitation = "1";
  446.                             SkySolidColor = "0.000000 0.000000 0.100000 1.000000";
  447.                             useSkyTextures = "1";
  448.                             renderBottomTexture = "0";
  449.                             noRenderBans = "0";
  450.                             locked = "true";
  451.                         };
  452.                     case "snow":
  453.                         new Sky(Sky)
  454.                         {
  455.                             position = "312 96 0";
  456.                             rotation = "1 0 0 0";
  457.                             scale = "1 1 1";
  458.                             materialList = "base/data/skies/Sky_Spooky3/resource.dml";
  459.                             cloudHeightPer[0] = "0.349971";
  460.                             cloudHeightPer[1] = "0.3";
  461.                             cloudHeightPer[2] = "0.199973";
  462.                             cloudSpeed1 = "0.0005";
  463.                             cloudSpeed2 = "0.001";
  464.                             cloudSpeed3 = "0.0003";
  465.                             visibleDistance = "1500";
  466.                             fogDistance = "1000";
  467.                             fogColor = "0.900000 0.900000 0.900000 1.000000";
  468.                             fogStorm1 = "0";
  469.                             fogStorm2 = "0";
  470.                             fogStorm3 = "0";
  471.                             fogVolume1 = "0 0 0";
  472.                             fogVolume2 = "0 0 0";
  473.                             fogVolume3 = "0 0 0";
  474.                             fogVolumeColor1 = "0.000000 0.000000 0.000000 1.000000";
  475.                             fogVolumeColor2 = "0.000000 0.000000 0.000000 1.000000";
  476.                             fogVolumeColor3 = "0.000000 0.000000 0.000000 1.000000";
  477.                             windVelocity = "0.25 0.25 0";
  478.                             windEffectPrecipitation = "1";
  479.                             SkySolidColor = "0.600000 0.600000 0.600000 1.000000";
  480.                             useSkyTextures = "1";
  481.                             renderBottomTexture = "0";
  482.                             noRenderBans = "0";
  483.                         };
  484.                        
  485.                     }
  486.             Sky_Old.delete();
  487.         }
  488.         else
  489.         {
  490.             Sky.setName("Sky_Old");
  491.             new Sky(Sky)
  492.             {
  493.                 position = "336 136 0";
  494.                 rotation = "1 0 0 0";
  495.                 scale = "1 1 1";
  496.                 materialList = "Add-Ons/RP_Weather/Skies/Clear/resource.dml";
  497.                 cloudHeightPer[0] = "0";
  498.                 cloudHeightPer[1] = "0";
  499.                 cloudHeightPer[2] = "0";
  500.                 cloudSpeed1 = "0.0";
  501.                 cloudSpeed2 = "0.0";
  502.                 cloudSpeed3 = "0.0";
  503.                 visibleDistance = "5000";
  504.                 fogDistance = "2500";
  505.                 fogColor = "0.900000 0.900000 1.000000 1.000000";
  506.                 fogStorm1 = "0";
  507.                 fogStorm2 = "0";
  508.                 fogStorm3 = "0";
  509.                 fogVolume1 = "0 0 0";
  510.                 fogVolume2 = "0 0 0";
  511.                 fogVolume3 = "0 0 0";
  512.                 fogVolumeColor1 = "128.000000 128.000000 128.000000 -222768174765569860000000000000000000000.000000";
  513.                 fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
  514.                 fogVolumeColor3 = "128.000000 128.000000 128.000000 -170698929442160050000000000000000000000.000000";
  515.                 windVelocity = "0 0 0";
  516.                 windEffectPrecipitation = "0";
  517.                 SkySolidColor = "0.000000 0.000000 0.100000 1.000000";
  518.                 useSkyTextures = "1";
  519.                 renderBottomTexture = "0";
  520.                 noRenderBans = "0";
  521.                 locked = "true";
  522.             }; 
  523.             Sky_Old.delete();
  524.         }
  525.     }
  526.     else
  527.     {
  528.     if(isObject(Precipitation))
  529.         Precipitation.delete();
  530.  
  531.     getday();
  532.  
  533.     $RP::pref::CurrWeather = Clear;
  534.  
  535.     warn("WEATHER ADJUSTING TO: [Clear]");
  536.     }
  537.  
  538. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement