Realistic yearly atmospheric cycle system v0.1 beta
by Dimitris Matsouliadis · 09/15/2008 (2:14 pm) · 28 comments
Download Code File
for better
-----------------------------------------------------------------------------------------
. Set your sky name to "Sky"
. Set your sun name to "MySun" // not necessary
. Create a sunlightObject with "MyMoon" name // not necessary
execute the SunCycle.cs
execute the TimeCycle.cs
execute the WeatherCycle.cs
Any time you like after mission load or in consol use
TimeCycle(MyTime, 80);// 80 is the time ~1 gameday in 80 min
you can use
Mysun.Elevation = ; // degree to start or set the sun, default is 0 degree "sunrise"
Mysun.reset();
Mysun.Apply();
changeTheSky();
createTheMoon();
createTheSun();
MyMoon.delete();
Mysun.delete();
If you like place in PlayGui.gui a Textcontrol with name (isMyclock) to see the time
If you like place in PlayGui.gui a Textcontrol with name (isMyDater) to see the full date like "Sunday 1 January of 380 BC"
// here is the TimeCycle.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// Time/date 09/2008 Matsouliadis Dimitris
//------------------------------------------
//seasons = "seasonNow, Name, TimeEffect, baseEffect1, baseEffect2, baseEffect3, maxEffect1, maxEffect2, maxEffect3, Nightlight, fogRain"
$season[0] = "0 Spring 20 0 10 10 10 50 50 8 30";
$season[1] = "1 Summer 10 0 10 0 0 50 10 10 50";
$season[2] = "2 Autumn 30 0 10 10 10 50 50 5 20";
$season[3] = "3 Winter 60 0 10 10 1 50 50 1 10";
//Months = "SeasonIs, MonthName, DaysHave"
$setMonths = "12";
$Month[0] = "3 January 31";
$Month[1] = "3 February 28";
$Month[2] = "0 March 31";
$Month[3] = "0 April 30";
$Month[4] = "0 May 31";
$Month[5] = "1 June 30";
$Month[6] = "1 july 31";
$Month[7] = "1 August 31";
$Month[8] = "2 September 30";
$Month[9] = "2 October 31";
$Month[10] = "2 November 30";
$Month[11] = "3 December 31";
//weekdays = "Daynumder. Dayname"
$setWeekDays = "7";
$weekDay[0] = "0 Sunday";
$weekDay[1] = "1 Monday";
$weekDay[2] = "2 Tuesday";
$weekDay[3] = "3 Wednesday";
$weekDay[4] = "4 Thursday";
$weekDay[5] = "5 Friday";
$weekDay[6] = "6 Saturday";
$MyTime = new ScriptObject(Mytime);
// Starring values for >> Sunrise, Winter, Sunday 1 January of 380 BC
$MyTime.Year = "380 0"; //0= year ++. 1= year --
$MySeason = 3;
$MyTime.Month = 0;
$MyTime.week = 0;
$MyTime.hours = 7;
$MyTime.Day = 0;
$MyTime.MonthDay =1;
$MySunElevationNow = 1;
$ElevatorStep = 0;
$setSunRissing = 7;
//---------------------- Timer -----------------
function TimeCycle(%Mytime,%duration)
{
%Mytime.TimeCycleSec = %duration;
if((%Mytime.Pulse % %Mytime.TimeCycleSec) == 0)
{
$SetTheDuration = %duration;
$MyMoonElevationTime = $SetTheDuration * 10;
serverCmdDoTime();
}
%Mytime.Pulse++;
if(%Mytime.Pulse >= 3600)
%Mytime.Pulse = 0;
schedule(%duration, 0, "TimeCycle", %Mytime, %duration);
}
//---------------------------------------------
function serverCmdDoTime(%client)
{
if(isObject(MyTime))
{
$MyTime.minutes++;
$ElevatorStep++;
if($ElevatorStep >= 4)
{
$ElevatorStep = 0;
$MySunElevationNow++;
suncycle(Mysun,$SetTheDuration);
}
if($MyTime.minutes >=60)
{
$MyTime.minutes = 0;
$MyTime.hours++;
if(MyTime.hours >= 24)
{
$MyTime.hours = 0;
$MyTime.Day++;
$MyTime.MonthDay++;
%DayOfMonth = getword($Month[$MyTime.Month] , 2) +1;
if($MyTime.MonthDay >= %DayOfMonth)
{
$MyTime.MonthDay = 1;
$MyTime.Month++;
SetDefaultSeasonSky();
if($MyTime.Day >= $setWeekDays)
{
$MyTime.Day = 0;
$MyTime.week++;
if($MyTime.week >= 53)
$MyTime.week =0;
}
if($MyTime.Month >=$setMonths)
{
$MySeason = getword($Month[$MyTime.Month], 0);
$MyTime.Month = 0;
%yearSet = getword($MyTime.Year, 1);
%yearNow = getword($MyTime.Year, 0);
if(%yearSet == "0")
{
%yearNow++;
$MyTime.Year= (%yearNow SPC %yearSet);
}
else
{
%yearNow--;
$MyTime.Year= (%yearNow SPC %yearSet);
}
}
}
}
}
}
$DayNow = getword($weekDay[$MyTime.Day], 1);
$MonthNow= getword($Month[$MyTime.Month], 1);
$YearNow = getword($MyTime.Year, 0);
//%client = $playernow;
//%MyTimeWord = ("Time is: " @ $MyTime.hours @ ":" @ $MyTime.minutes SPC $MyTime.MonthDay SPC $DayNow SPC $MonthNow @ " of year " @ $YearNow);
//messageClient(%client, 'MyTime', %MyTimeWord);
if($MyTime.minutes == $MyTime.Prev)
{
}
else
{
$MyTime.Prev = $MyTime.minutes;
%SetClock = ($MyTime.hours @ ":" @ $MyTime.minutes);
%SetDater =($DayNow SPC $MyTime.MonthDay SPC $MonthNow @ " of " @ $YearNow SPC "BC");
isMyclock.text = %SetClock;
isMyDater.text = %SetDater;
}
}
//here is the SunCycle.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// day/night 09/2008 Matsouliadis Dimitris
//------------------------------------------
// sunrise set for winter
$Skymaterial = "scriptsAndAssets/data/skies/sky_blue/sky_blue.dml";
$FogSet = 150;
$fogColor = "0.92 0.69 0.431373 0";
$checkSunPlace = 0;
$MySundrl = 1.3;
$MyMoonDate =1;
$MySkyCloud1 = "0.05";
$MySkyCloud2 = "0.2";
$MySkyCloud3 = "0";
$MySkyClSpeed1 = "0.0001";
$MySkyClSpeed2 = "0.0001";
$MySkyClSpeed3 = "0.0001";
$MyHeliosMaxBrt = 0.6;
// ------------- checking the sun elevation
function SunCycle(%MySun,%duration)
{
if(isObject(%MySun))
{
if($MySunElevationNow> 359)
{
$MySunElevationNow = 0;
}
%MySun.Elevation = $MySunElevationNow;
%Sunelv = %MySun.Elevation; //support the sun degree
weatherCheck();
if($checkSunPlace == $MySunElevationNow)
{
//support the water, non contain
}
else
{
$checkSunPlace = $MySunElevationNow;
if(%Sunelv >=160 && %Sunelv <= 230) //sunset
{
$FogSet =690 -(%Sunelv * 3);
if($FogSet <=1)
$FogSet=1;
%fogClRed = "0.92" +((159 -%Sunelv) /70);
%fogClGreen = "0.92" +((159 -%Sunelv) /60);
%fogClBlue = "0.92" +((159 -%Sunelv) /45);
%nightLight = getword($season[$MySeason], 9) / 100;
if(%fogClRed <= %nightLight)
%fogClRed = %nightLight;
if(%fogClGreen <= %nightLight)
%fogClGreen = %nightLight;
if(%fogClBlue <= %nightLight)
%fogClBlue = %nightLight;
$fogColor = (%fogClRed SPC %fogClGreen SPC %fogClBlue SPC "0");
changeTheSky();
}
if(%Sunelv >=311) //sunrise
{
$FogSet = %Sunelv -300;
if(%Sunelv >=340)
{
%fogClRed = ((%Sunelv -339) /22.2);
%fogClGreen = ((%Sunelv -339) /29);
%fogClBlue = ((%Sunelv -339) /46.5);
$fogColor = (%fogClRed SPC %fogClGreen SPC %fogClBlue SPC "0");
}
changeTheSky();
}
if(%Sunelv >=1 && %Sunelv <= 90) //step to midday
{
$FogSet = 60 + (%Sunelv * 10);
if($FogSet >= 500)
$FogSet=500;
if(%Sunelv >=1 && %Sunelv <= 60)
{
%fogClRed = "0.92";
%fogClGreen = "0.69" + (%Sunelv /261);
%fogClBlue = "0.43" + (%Sunelv /120);
$fogColor = (%fogClRed SPC %fogClGreen SPC %fogClBlue SPC "0");
if(%Sunelv >=30)
}
changeTheSky();
}
if($MySundrl <= 0.01)
{
$MySundrl = 0.01;
}
%MySun.DrlMultiplier = $MySundrl;
%MySun.apply();
if(%Sunelv == 1)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_blue/sky_blue.dml";
$MySundrl = 1.3;
changeTheSky();
if(isObject(MyMoon))
MyMoon.delete();
}
if(%Sunelv == 160)
{
$MyMoonDate++;
if($StartRainNow == 0)
CreateTheMoon();
}
if(%Sunelv == 170)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_middle/sky_middle.dml";
$MySundrl = 0.8;
changeTheSky();
}
if(%Sunelv == 210)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_night/sky_night.dml";
$MySundrl = 0.1;
changeTheSky();
}
if(%Sunelv == 350)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_middle/sky_middle.dml";
$MySundrl = 0.6;
changeTheSky();
}
}
}
}
function changeTheSky(){
if($StartRainNow == 1)
{
%fogRain = getword($season[$MySeason], 10);
$FogSet = %fogRain;
}
%VisibleSet = $FogSet +100;
if(%VisibleSet >= 600)
%VisibleSet =600;
if(%VisibleSet <= 250)
%VisibleSet =250;
Sky.canSaveDynamicFields = "1";
Sky.Enabled = "1";
Sky.position = "336 136 0";
Sky.rotation = "1 0 0 0";
Sky.scale = "1 1 1";
Sky.materialList = $Skymaterial;
Sky.cloudHeightPer[0] = $MySkyCloud1;
Sky.cloudHeightPer[1] = $MySkyCloud2;
Sky.cloudHeightPer[2] = $MySkyCloud3;
Sky.cloudSpeed1 = $MySkyClSpeed1;
Sky.cloudSpeed2 = $MySkyClSpeed2;
Sky.cloudSpeed3 = $MySkyClSpeed3;
Sky.visibleDistance = %VisibleSet;
Sky.fogDistance = $FogSet;
Sky.fogColor = $fogColor;
Sky.fogStorm1 = "0";
Sky.fogStorm2 = "0";
Sky.fogStorm3 = "0";
Sky.fogVolume1 = "0 0 0";
Sky.fogVolume2 = "0 0 0";
Sky.fogVolume3 = "0 0 0";
Sky.windVelocity = "5 1 0";
Sky.SkySolidColor = "0.6 0.6 0.6 0.1";
Sky.useSkyTextures = "1";
Sky.renderBottomTexture = "0";
Sky.noRenderBans = "0";
Sky.renderBanOffsetHeight = "50";
Sky.skyGlow = "0";
Sky.skyGlowColor = "0 0 0 0";
Sky.fogVolumeColor1 = "128 128 128 0";
Sky.fogVolumeColor2 = "128 128 128 0";
Sky.fogVolumeColor3 = "128 128 128 0";
Sky.windEffectPrecipitation = "1";
Sky.locked = "false";
Sky.applySkyChanges(); // This need some fix in engine:)
}
function CreateTheSun(){
if(isObject(MyHelios))
{
MyHelios.delete();
}
%MyHeliosMinBrt = $MyHeliosMaxBrt /2;
new fxSunLight(MyHelios) {
canSaveDynamicFields = "1";
Enabled = "0";
position = "3774.41 772.596 26.5183";
rotation = "1 0 0 0";
scale = "1 1 1";
Enable = "1";
LocalFlareBitmap = "common/lighting/corona.png";
RemoteFlareBitmap = "common/lighting/corona.png";
SunAzimuth = "50";
SunElevation = "10";
LockToRealSun = "1";
FlareTP = "1";
Colour = "1 1 1 1";
Brightness = "1";
FlareSize = "1";
LocalScale = "1";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "1";
AnimBrightness = "1";
AnimRotation = "1";
AnimSize = "0";
AnimAzimuth = "0";
AnimElevation = "0";
LerpColour = "1";
LerpBrightness = "1";
LerpRotation = "1";
LerpSize = "1";
LerpAzimuth = "1";
LerpElevation = "0";
LinkFlareSize = "0";
SingleColourKeys = "1";
MinColour = "0.45 0.25 0.03 0";
MaxColour = "0.35 0.20 0.04 0";
MinBrightness = %MyHeliosMinBrt;
MaxBrightness = $MyHeliosMaxBrt;
MinRotation = "0";
MaxRotation = "359";
minSize = "0.5";
MaxSize = "1";
MinAzimuth = "0";
MaxAzimuth = "359";
MinElevation = "0";
MaxElevation = "360";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RotationKeys = "AZA";
SizeKeys = "AZA";
AzimuthKeys = "AZ";
ElevationKeys = "AZ";
ColourTime = "5";
BrightnessTime = "5";
RotationTime = "600";
SizeTime = "5";
AzimuthTime = "5";
ElevationTime = "200";
};
MissionGroup.add(MyHelios);
}
function CreateTheMoon(){
if($MyMoonDate >=7) //7 days cycle (27 normal)
$MyMoonDate = 1;
if($MyMoonDate >=1)
%MyMoonFace ="common/lighting/MyMoon.png";
if($MyMoonDate >=2)
%MyMoonFace ="common/lighting/MyMoon1.png";
if($MyMoonDate >=3)
%MyMoonFace ="common/lighting/MyMoon2.png";
if($MyMoonDate >=4)
%MyMoonFace ="common/lighting/MyMoon3.png";
if($MyMoonDate >=5)
%MyMoonFace ="common/lighting/MyMoon4.png";
if($MyMoonDate >=6)
%MyMoonFace ="common/lighting/MyMoon5.png";
if(isObject(MyMoon))
MyMoon.delete();
new fxSunLight(MyMoon) {
canSaveDynamicFields = "1";
Enabled = "1";
position = "3774.41 772.596 26.5183";
rotation = "1 0 0 0";
scale = "1 1 1";
Enable = "1";
LocalFlareBitmap = %MyMoonFace;
RemoteFlareBitmap = %MyMoonFace;
SunAzimuth = "30";
SunElevation = "0";
LockToRealSun = "0";
FlareTP = "1";
Colour = "1 1 1 1";
Brightness = "1";
FlareSize = "1";
LocalScale = "1";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "1";
AnimBrightness = "1";
AnimRotation = "0";
AnimSize = "0";
AnimAzimuth = "0";
AnimElevation = "1";
LerpColour = "1";
LerpBrightness = "1";
LerpRotation = "1";
LerpSize = "1";
LerpAzimuth = "1";
LerpElevation = "1";
LinkFlareSize = "0";
SingleColourKeys = "1";
MinColour = "0.5 0.45 0.35 0";
MaxColour = "0.65 0.5 0.4 0";
MinBrightness = "0.6";
MaxBrightness = "0.9";
MinRotation = "0";
MaxRotation = "359";
minSize = "0.5";
MaxSize = "1";
MinAzimuth = "20";
MaxAzimuth = "160";
MinElevation = "45";
MaxElevation = "270";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RotationKeys = "AZA";
SizeKeys = "AZA";
AzimuthKeys = "AZ";
ElevationKeys = "AZ";
ColourTime = "200";
BrightnessTime = "500";
RotationTime = "600";
SizeTime = "5";
AzimuthTime = "5";
ElevationTime = $MyMoonElevationTime;
};
MissionGroup.add(MyMoon);
echo("The moon is rissing at: " @ MyMoon.SunElevation @ " with face: " @ %MyMoonFace );
}
// here is the weatherCycle.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// weather 09/2008 Matsouliadis Dimitris
//------------------------------------------
$RainTimeCounter =0;
$StartRainNow = 0;
function weatherCheck()
{
if($MySeason == 0)
%CloudLevel = 30;
if($MySeason == 1)
%CloudLevel = 50;
if($MySeason == 2)
%CloudLevel = 30;
if($MySeason == 3)
%CloudLevel = 10;
%timeStorm = getword($season[$MySeason] ,2);
$timeRain = %timeStorm;
if($RainTimeCounter == 0)
{
%GotoRain = getRandom(1, (100 -%timeStorm));
//echo("GO to Rain Random : " @ %GotoRain);
if(%GotoRain == 35)
{
$SetCloudLevel = getRandom(1 ,%CloudLevel);
$StartRainNow = 3;
}
}
if($StartRainNow == 1)
{
$IsStorm = 2;
startTheRain();
}
if($StartRainNow == 2)
{
SetDefaultSeasonSky();
}
if($StartRainNow == 3)
{
SetRainPrepare();
}
}
function startTheRain()
{
$RainTimeCounter++;
//echo("Rain counter : " @ $RainTimeCounter);
if($RainTimeCounter == getword($season[$MySeason] ,2))
{
$RainTimeCounter =0;
$StartRainNow = 2;
}
if($RainTimeCounter >= (getword($season[$MySeason] ,2) -3))
{
if(isObject(MyRain))
MyRain.delete();
if(isObject(MyLightning))
MyLightning.delete();
}
if($RainTimeCounter <= 1 && $StartRainNow == 1)
{
$MySkyCloud1 = getword($season[$MySeason], 6)/100;
$MySkyCloud2 = getword($season[$MySeason], 7)/100;
$MySkyCloud3 = getword($season[$MySeason], 8)/100;
$IsStorm = getRandom(1 ,8);
//$IsStorm = 8; //use this to snowing cycle only for snowed mountans
$MySkyClSpeed1 = ("0.0001" * $IsStorm);
$MySkyClSpeed2 = ("0.0001" * ($IsStorm /2));
$MySkyClSpeed3 = ("0.0001" * ($IsStorm /3));
//echo("Storm size : " @ $IsStorm);
%SetDropsNumber = $IsStorm * 3000;
if($IsStorm >=3)
{
if($MySeason <=2){
if($IsStorm ==8)
$IsStorm =7;
}
%setRain = "Rain";
%SetSpeedmin = $IsStorm /3;
%SetSpeedmax = $IsStorm /2;
if($IsStorm >= 5 && $IsStorm <=6 )
{
%setRain = "Rain";
StartTheLighting();
}
if($IsStorm ==7 )
{
%setRain = "HeavyRain";
StartTheLighting();
}
if($IsStorm >=8)
{
%setRain = "Snow";
%SetSpeedmin = "0.3";
%SetSpeedmax = "0.5";
}
new Precipitation(MyRain)
{
datablock = %setRain;
minSpeed = %SetSpeedmin;
maxSpeed = %SetSpeedmax;
numDrops = %SetDropsNumber;
boxWidth = "200";
boxHeight = "100";
minMass = "1.0";
maxMass = "2.0";
rotateWithCamVel = true;
doCollision = true;
useTurbulence = false;
};
MyRain.modifyStorm(0.1, getword($season[$MySeason] ,2));
}
changeTheSky();
}
if(isObject(MyMoon)){
MyMoon.delete();
}
}
function StartTheLighting()
{
%GetStrikes = $IsStorm *2;
%GetStrikesWidth = $IsStorm * 0.01;
%GetPos = "0 0 0";
%numHumans = 0;
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%client = ClientGroup.getObject(%i);
if( !%client.isAIControlled() )
{
if(isObject(%client.player))
{
%numHumans++;
%pos = VectorAdd(%pos, %client.player.position);
}
}
}
%GetPos = VectorScale(%pos, 1.0 / (%numHumans ));
if (!isObject(MyLightning))
{
new Lightning(MyLightning)
{
position = %GetPos;
scale = "250 350 450";
dataBlock = "LightningStorm";
strikesPerMinute = %GetStrikes;
strikeWidth = %GetStrikesWidth;
chanceToHitTarget = "0.02";
strikeRadius = "500";
boltStartRadius = "20";
color = "1 1 1 1";
fadeColor = "8 8 8 1";
useFog = "1";
locked = "false";
};
}
}
function SetDefaultSeasonSky()
{
%nowCloud1 = getword($season[$MySeason], 3)/10;
%nowCloud2 = getword($season[$MySeason], 4)/10;
%nowCloud3 = getword($season[$MySeason], 5)/10;
%Cloud1 = $MySkyCloud1 * 10;
%Cloud1--;
if(%Cloud1<= %nowCloud1){
%Cloud1 = %nowCloud1;
}
%Cloud2 = $MySkyCloud2 * 10;
%Cloud2--;
if(%Cloud2 <= %nowCloud2){
%Cloud2 = %nowCloud2;
}
%Cloud3 = $MySkyCloud3 * 10;
%Cloud3--;
if(%Cloud3 <= %nowCloud3){
%Cloud3 = %nowCloud3;
}
$MySkyCloud1 = %Cloud1 /10;
$MySkyCloud2 = %Cloud2 /10;
$MySkyCloud3 = %Cloud3 /10;
$MySkyClSpeed1 = getword($season[$MySeason], 2)/220000;
$MySkyClSpeed2 = getword($season[$MySeason], 2)/260000;
$MySkyClSpeed3 = getword($season[$MySeason], 2)/300000;
changeTheSky();
//echo($MySkyCloud1 SPC $MySkyCloud2 SPC $MySkyCloud3);
if(($MySkyCloud1 *10) <= %nowCloud1 && ($MySkyCloud2 *10) <= %nowCloud2 && ($MySkyCloud3 *10) <= %nowCloud3)
{
if($MySeason == 0)
$MyHeliosMaxBrt = "0.9";
if($MySeason == 1)
$MyHeliosMaxBrt = "1";
if($MySeason == 2)
$MyHeliosMaxBrt = "0.8";
if($MySeason == 4){
$MyHeliosMaxBrt = "0.6";
}
CreateTheSun();
$StartRainNow = 0;
}
}
function SetRainPrepare()
{
%nowCloud1 = getword($season[$MySeason], 6)/10;
%nowCloud2 = getword($season[$MySeason], 7)/10;
%nowCloud3 = getword($season[$MySeason], 8)/10;
%Cloud1 = $MySkyCloud1 * 10;
%Cloud1++;
if(%Cloud1>= %nowCloud1){
%Cloud1 = %nowCloud1;
}
%Cloud2 = $MySkyCloud2 * 10;
%Cloud2++;
if(%Cloud2 >= %nowCloud2){
%Cloud2 = %nowCloud2;
}
%Cloud3 = $MySkyCloud3 * 10;
%Cloud3++;
if(%Cloud3 >= %nowCloud3){
%Cloud3 = %nowCloud3;
}
$MySkyCloud1 = %Cloud1 /10;
$MySkyCloud2 = %Cloud2 /10;
$MySkyCloud3 = %Cloud3 /10;
changeTheSky();
//echo("Prapare>> " @ $MySkyCloud1 SPC $MySkyCloud2 SPC $MySkyCloud3);
if(($MySkyCloud1 *10) >= %nowCloud1 && ($MySkyCloud2 *10) >= %nowCloud2 && ($MySkyCloud3 *10) >= %nowCloud3)
$RainTimeCounter =0;
$StartRainNow = 1;
$MyHeliosMaxBrt = "0.2";
CreateTheSun();
}
//-----------------------------------------------------------------------------
datablock SFXProfile(MyHeavyRainSound)
{
fileName = "~/data/sound/environment/HeavyRain";
description = AudioLooping2d;
preload = true;
};
datablock SFXProfile(MyRainSound)
{
fileName = "~/data/sound/environment/Rain";
description = AudioLooping2d;
preload = true;
};
datablock SFXProfile(MySnowSound)
{
fileName = "~/data/sound/environment/snow";
description = AudioLooping2d;
preload = true;
};
datablock PrecipitationData(Rain)
{
soundProfile = "MyRainSound";
dropTexture = "~/data/environment/rain";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.2;
splashSize = 0.01;
useTrueBillboards = false;
splashMS = 250;
};
datablock PrecipitationData(HeavyRain)
{
soundProfile = "MyHeavyRainSound";
dropTexture = "~/data/environment/rain";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.3;
splashSize = 0.05;
useTrueBillboards = false;
splashMS = 250;
};
datablock PrecipitationData(Snow)
{
soundProfile = "MySnowSound";
dropTexture = "~/data/environment/snow";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.1;
splashSize = 0.001;
useTrueBillboards = true;
splashMS = 0.1;
};
datablock SFXProfile(ThunderCrash1Sound)
{
fileName = "~/data/sound/environment/thunder1";
description = AudioClose3d;
preload = true;
};
datablock SFXProfile(ThunderCrash2Sound)
{
fileName = "~/data/sound/environment/thunder2";
description = AudioClose3d;
preload = true;
};
datablock SFXProfile(ThunderCrash3Sound)
{
fileName = "~/data/sound/environment/thunder3";
description = AudioClose3d;
preload = true;
};
datablock SFXProfile(ThunderCrash4Sound)
{
fileName = "~/data/sound/environment/thunder4";
description = AudioClose3d;
preload = true;
};
datablock LightningData(LightningStorm)
{
strikeTextures[0] = "~/data/environment/lightning.dml";
thunderSounds[0] = ThunderCrash1Sound;
thunderSounds[1] = ThunderCrash2Sound;
thunderSounds[2] = ThunderCrash3Sound;
thunderSounds[3] = ThunderCrash4Sound;
};
Click Here for screenshots
for better
-----------------------------------------------------------------------------------------
. Set your sky name to "Sky"
. Set your sun name to "MySun" // not necessary
. Create a sunlightObject with "MyMoon" name // not necessary
execute the SunCycle.cs
execute the TimeCycle.cs
execute the WeatherCycle.cs
Any time you like after mission load or in consol use
TimeCycle(MyTime, 80);// 80 is the time ~1 gameday in 80 min
you can use
Mysun.Elevation = ; // degree to start or set the sun, default is 0 degree "sunrise"
Mysun.reset();
Mysun.Apply();
changeTheSky();
createTheMoon();
createTheSun();
MyMoon.delete();
Mysun.delete();
If you like place in PlayGui.gui a Textcontrol with name (isMyclock) to see the time
If you like place in PlayGui.gui a Textcontrol with name (isMyDater) to see the full date like "Sunday 1 January of 380 BC"
// here is the TimeCycle.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// Time/date 09/2008 Matsouliadis Dimitris
//------------------------------------------
//seasons = "seasonNow, Name, TimeEffect, baseEffect1, baseEffect2, baseEffect3, maxEffect1, maxEffect2, maxEffect3, Nightlight, fogRain"
$season[0] = "0 Spring 20 0 10 10 10 50 50 8 30";
$season[1] = "1 Summer 10 0 10 0 0 50 10 10 50";
$season[2] = "2 Autumn 30 0 10 10 10 50 50 5 20";
$season[3] = "3 Winter 60 0 10 10 1 50 50 1 10";
//Months = "SeasonIs, MonthName, DaysHave"
$setMonths = "12";
$Month[0] = "3 January 31";
$Month[1] = "3 February 28";
$Month[2] = "0 March 31";
$Month[3] = "0 April 30";
$Month[4] = "0 May 31";
$Month[5] = "1 June 30";
$Month[6] = "1 july 31";
$Month[7] = "1 August 31";
$Month[8] = "2 September 30";
$Month[9] = "2 October 31";
$Month[10] = "2 November 30";
$Month[11] = "3 December 31";
//weekdays = "Daynumder. Dayname"
$setWeekDays = "7";
$weekDay[0] = "0 Sunday";
$weekDay[1] = "1 Monday";
$weekDay[2] = "2 Tuesday";
$weekDay[3] = "3 Wednesday";
$weekDay[4] = "4 Thursday";
$weekDay[5] = "5 Friday";
$weekDay[6] = "6 Saturday";
$MyTime = new ScriptObject(Mytime);
// Starring values for >> Sunrise, Winter, Sunday 1 January of 380 BC
$MyTime.Year = "380 0"; //0= year ++. 1= year --
$MySeason = 3;
$MyTime.Month = 0;
$MyTime.week = 0;
$MyTime.hours = 7;
$MyTime.Day = 0;
$MyTime.MonthDay =1;
$MySunElevationNow = 1;
$ElevatorStep = 0;
$setSunRissing = 7;
//---------------------- Timer -----------------
function TimeCycle(%Mytime,%duration)
{
%Mytime.TimeCycleSec = %duration;
if((%Mytime.Pulse % %Mytime.TimeCycleSec) == 0)
{
$SetTheDuration = %duration;
$MyMoonElevationTime = $SetTheDuration * 10;
serverCmdDoTime();
}
%Mytime.Pulse++;
if(%Mytime.Pulse >= 3600)
%Mytime.Pulse = 0;
schedule(%duration, 0, "TimeCycle", %Mytime, %duration);
}
//---------------------------------------------
function serverCmdDoTime(%client)
{
if(isObject(MyTime))
{
$MyTime.minutes++;
$ElevatorStep++;
if($ElevatorStep >= 4)
{
$ElevatorStep = 0;
$MySunElevationNow++;
suncycle(Mysun,$SetTheDuration);
}
if($MyTime.minutes >=60)
{
$MyTime.minutes = 0;
$MyTime.hours++;
if(MyTime.hours >= 24)
{
$MyTime.hours = 0;
$MyTime.Day++;
$MyTime.MonthDay++;
%DayOfMonth = getword($Month[$MyTime.Month] , 2) +1;
if($MyTime.MonthDay >= %DayOfMonth)
{
$MyTime.MonthDay = 1;
$MyTime.Month++;
SetDefaultSeasonSky();
if($MyTime.Day >= $setWeekDays)
{
$MyTime.Day = 0;
$MyTime.week++;
if($MyTime.week >= 53)
$MyTime.week =0;
}
if($MyTime.Month >=$setMonths)
{
$MySeason = getword($Month[$MyTime.Month], 0);
$MyTime.Month = 0;
%yearSet = getword($MyTime.Year, 1);
%yearNow = getword($MyTime.Year, 0);
if(%yearSet == "0")
{
%yearNow++;
$MyTime.Year= (%yearNow SPC %yearSet);
}
else
{
%yearNow--;
$MyTime.Year= (%yearNow SPC %yearSet);
}
}
}
}
}
}
$DayNow = getword($weekDay[$MyTime.Day], 1);
$MonthNow= getword($Month[$MyTime.Month], 1);
$YearNow = getword($MyTime.Year, 0);
//%client = $playernow;
//%MyTimeWord = ("Time is: " @ $MyTime.hours @ ":" @ $MyTime.minutes SPC $MyTime.MonthDay SPC $DayNow SPC $MonthNow @ " of year " @ $YearNow);
//messageClient(%client, 'MyTime', %MyTimeWord);
if($MyTime.minutes == $MyTime.Prev)
{
}
else
{
$MyTime.Prev = $MyTime.minutes;
%SetClock = ($MyTime.hours @ ":" @ $MyTime.minutes);
%SetDater =($DayNow SPC $MyTime.MonthDay SPC $MonthNow @ " of " @ $YearNow SPC "BC");
isMyclock.text = %SetClock;
isMyDater.text = %SetDater;
}
}
//here is the SunCycle.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// day/night 09/2008 Matsouliadis Dimitris
//------------------------------------------
// sunrise set for winter
$Skymaterial = "scriptsAndAssets/data/skies/sky_blue/sky_blue.dml";
$FogSet = 150;
$fogColor = "0.92 0.69 0.431373 0";
$checkSunPlace = 0;
$MySundrl = 1.3;
$MyMoonDate =1;
$MySkyCloud1 = "0.05";
$MySkyCloud2 = "0.2";
$MySkyCloud3 = "0";
$MySkyClSpeed1 = "0.0001";
$MySkyClSpeed2 = "0.0001";
$MySkyClSpeed3 = "0.0001";
$MyHeliosMaxBrt = 0.6;
// ------------- checking the sun elevation
function SunCycle(%MySun,%duration)
{
if(isObject(%MySun))
{
if($MySunElevationNow> 359)
{
$MySunElevationNow = 0;
}
%MySun.Elevation = $MySunElevationNow;
%Sunelv = %MySun.Elevation; //support the sun degree
weatherCheck();
if($checkSunPlace == $MySunElevationNow)
{
//support the water, non contain
}
else
{
$checkSunPlace = $MySunElevationNow;
if(%Sunelv >=160 && %Sunelv <= 230) //sunset
{
$FogSet =690 -(%Sunelv * 3);
if($FogSet <=1)
$FogSet=1;
%fogClRed = "0.92" +((159 -%Sunelv) /70);
%fogClGreen = "0.92" +((159 -%Sunelv) /60);
%fogClBlue = "0.92" +((159 -%Sunelv) /45);
%nightLight = getword($season[$MySeason], 9) / 100;
if(%fogClRed <= %nightLight)
%fogClRed = %nightLight;
if(%fogClGreen <= %nightLight)
%fogClGreen = %nightLight;
if(%fogClBlue <= %nightLight)
%fogClBlue = %nightLight;
$fogColor = (%fogClRed SPC %fogClGreen SPC %fogClBlue SPC "0");
changeTheSky();
}
if(%Sunelv >=311) //sunrise
{
$FogSet = %Sunelv -300;
if(%Sunelv >=340)
{
%fogClRed = ((%Sunelv -339) /22.2);
%fogClGreen = ((%Sunelv -339) /29);
%fogClBlue = ((%Sunelv -339) /46.5);
$fogColor = (%fogClRed SPC %fogClGreen SPC %fogClBlue SPC "0");
}
changeTheSky();
}
if(%Sunelv >=1 && %Sunelv <= 90) //step to midday
{
$FogSet = 60 + (%Sunelv * 10);
if($FogSet >= 500)
$FogSet=500;
if(%Sunelv >=1 && %Sunelv <= 60)
{
%fogClRed = "0.92";
%fogClGreen = "0.69" + (%Sunelv /261);
%fogClBlue = "0.43" + (%Sunelv /120);
$fogColor = (%fogClRed SPC %fogClGreen SPC %fogClBlue SPC "0");
if(%Sunelv >=30)
}
changeTheSky();
}
if($MySundrl <= 0.01)
{
$MySundrl = 0.01;
}
%MySun.DrlMultiplier = $MySundrl;
%MySun.apply();
if(%Sunelv == 1)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_blue/sky_blue.dml";
$MySundrl = 1.3;
changeTheSky();
if(isObject(MyMoon))
MyMoon.delete();
}
if(%Sunelv == 160)
{
$MyMoonDate++;
if($StartRainNow == 0)
CreateTheMoon();
}
if(%Sunelv == 170)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_middle/sky_middle.dml";
$MySundrl = 0.8;
changeTheSky();
}
if(%Sunelv == 210)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_night/sky_night.dml";
$MySundrl = 0.1;
changeTheSky();
}
if(%Sunelv == 350)
{
$Skymaterial = "scriptsAndAssets/data/skies/sky_middle/sky_middle.dml";
$MySundrl = 0.6;
changeTheSky();
}
}
}
}
function changeTheSky(){
if($StartRainNow == 1)
{
%fogRain = getword($season[$MySeason], 10);
$FogSet = %fogRain;
}
%VisibleSet = $FogSet +100;
if(%VisibleSet >= 600)
%VisibleSet =600;
if(%VisibleSet <= 250)
%VisibleSet =250;
Sky.canSaveDynamicFields = "1";
Sky.Enabled = "1";
Sky.position = "336 136 0";
Sky.rotation = "1 0 0 0";
Sky.scale = "1 1 1";
Sky.materialList = $Skymaterial;
Sky.cloudHeightPer[0] = $MySkyCloud1;
Sky.cloudHeightPer[1] = $MySkyCloud2;
Sky.cloudHeightPer[2] = $MySkyCloud3;
Sky.cloudSpeed1 = $MySkyClSpeed1;
Sky.cloudSpeed2 = $MySkyClSpeed2;
Sky.cloudSpeed3 = $MySkyClSpeed3;
Sky.visibleDistance = %VisibleSet;
Sky.fogDistance = $FogSet;
Sky.fogColor = $fogColor;
Sky.fogStorm1 = "0";
Sky.fogStorm2 = "0";
Sky.fogStorm3 = "0";
Sky.fogVolume1 = "0 0 0";
Sky.fogVolume2 = "0 0 0";
Sky.fogVolume3 = "0 0 0";
Sky.windVelocity = "5 1 0";
Sky.SkySolidColor = "0.6 0.6 0.6 0.1";
Sky.useSkyTextures = "1";
Sky.renderBottomTexture = "0";
Sky.noRenderBans = "0";
Sky.renderBanOffsetHeight = "50";
Sky.skyGlow = "0";
Sky.skyGlowColor = "0 0 0 0";
Sky.fogVolumeColor1 = "128 128 128 0";
Sky.fogVolumeColor2 = "128 128 128 0";
Sky.fogVolumeColor3 = "128 128 128 0";
Sky.windEffectPrecipitation = "1";
Sky.locked = "false";
Sky.applySkyChanges(); // This need some fix in engine:)
}
function CreateTheSun(){
if(isObject(MyHelios))
{
MyHelios.delete();
}
%MyHeliosMinBrt = $MyHeliosMaxBrt /2;
new fxSunLight(MyHelios) {
canSaveDynamicFields = "1";
Enabled = "0";
position = "3774.41 772.596 26.5183";
rotation = "1 0 0 0";
scale = "1 1 1";
Enable = "1";
LocalFlareBitmap = "common/lighting/corona.png";
RemoteFlareBitmap = "common/lighting/corona.png";
SunAzimuth = "50";
SunElevation = "10";
LockToRealSun = "1";
FlareTP = "1";
Colour = "1 1 1 1";
Brightness = "1";
FlareSize = "1";
LocalScale = "1";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "1";
AnimBrightness = "1";
AnimRotation = "1";
AnimSize = "0";
AnimAzimuth = "0";
AnimElevation = "0";
LerpColour = "1";
LerpBrightness = "1";
LerpRotation = "1";
LerpSize = "1";
LerpAzimuth = "1";
LerpElevation = "0";
LinkFlareSize = "0";
SingleColourKeys = "1";
MinColour = "0.45 0.25 0.03 0";
MaxColour = "0.35 0.20 0.04 0";
MinBrightness = %MyHeliosMinBrt;
MaxBrightness = $MyHeliosMaxBrt;
MinRotation = "0";
MaxRotation = "359";
minSize = "0.5";
MaxSize = "1";
MinAzimuth = "0";
MaxAzimuth = "359";
MinElevation = "0";
MaxElevation = "360";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RotationKeys = "AZA";
SizeKeys = "AZA";
AzimuthKeys = "AZ";
ElevationKeys = "AZ";
ColourTime = "5";
BrightnessTime = "5";
RotationTime = "600";
SizeTime = "5";
AzimuthTime = "5";
ElevationTime = "200";
};
MissionGroup.add(MyHelios);
}
function CreateTheMoon(){
if($MyMoonDate >=7) //7 days cycle (27 normal)
$MyMoonDate = 1;
if($MyMoonDate >=1)
%MyMoonFace ="common/lighting/MyMoon.png";
if($MyMoonDate >=2)
%MyMoonFace ="common/lighting/MyMoon1.png";
if($MyMoonDate >=3)
%MyMoonFace ="common/lighting/MyMoon2.png";
if($MyMoonDate >=4)
%MyMoonFace ="common/lighting/MyMoon3.png";
if($MyMoonDate >=5)
%MyMoonFace ="common/lighting/MyMoon4.png";
if($MyMoonDate >=6)
%MyMoonFace ="common/lighting/MyMoon5.png";
if(isObject(MyMoon))
MyMoon.delete();
new fxSunLight(MyMoon) {
canSaveDynamicFields = "1";
Enabled = "1";
position = "3774.41 772.596 26.5183";
rotation = "1 0 0 0";
scale = "1 1 1";
Enable = "1";
LocalFlareBitmap = %MyMoonFace;
RemoteFlareBitmap = %MyMoonFace;
SunAzimuth = "30";
SunElevation = "0";
LockToRealSun = "0";
FlareTP = "1";
Colour = "1 1 1 1";
Brightness = "1";
FlareSize = "1";
LocalScale = "1";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "1";
AnimBrightness = "1";
AnimRotation = "0";
AnimSize = "0";
AnimAzimuth = "0";
AnimElevation = "1";
LerpColour = "1";
LerpBrightness = "1";
LerpRotation = "1";
LerpSize = "1";
LerpAzimuth = "1";
LerpElevation = "1";
LinkFlareSize = "0";
SingleColourKeys = "1";
MinColour = "0.5 0.45 0.35 0";
MaxColour = "0.65 0.5 0.4 0";
MinBrightness = "0.6";
MaxBrightness = "0.9";
MinRotation = "0";
MaxRotation = "359";
minSize = "0.5";
MaxSize = "1";
MinAzimuth = "20";
MaxAzimuth = "160";
MinElevation = "45";
MaxElevation = "270";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RotationKeys = "AZA";
SizeKeys = "AZA";
AzimuthKeys = "AZ";
ElevationKeys = "AZ";
ColourTime = "200";
BrightnessTime = "500";
RotationTime = "600";
SizeTime = "5";
AzimuthTime = "5";
ElevationTime = $MyMoonElevationTime;
};
MissionGroup.add(MyMoon);
echo("The moon is rissing at: " @ MyMoon.SunElevation @ " with face: " @ %MyMoonFace );
}
// here is the weatherCycle.cs
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// weather 09/2008 Matsouliadis Dimitris
//------------------------------------------
$RainTimeCounter =0;
$StartRainNow = 0;
function weatherCheck()
{
if($MySeason == 0)
%CloudLevel = 30;
if($MySeason == 1)
%CloudLevel = 50;
if($MySeason == 2)
%CloudLevel = 30;
if($MySeason == 3)
%CloudLevel = 10;
%timeStorm = getword($season[$MySeason] ,2);
$timeRain = %timeStorm;
if($RainTimeCounter == 0)
{
%GotoRain = getRandom(1, (100 -%timeStorm));
//echo("GO to Rain Random : " @ %GotoRain);
if(%GotoRain == 35)
{
$SetCloudLevel = getRandom(1 ,%CloudLevel);
$StartRainNow = 3;
}
}
if($StartRainNow == 1)
{
$IsStorm = 2;
startTheRain();
}
if($StartRainNow == 2)
{
SetDefaultSeasonSky();
}
if($StartRainNow == 3)
{
SetRainPrepare();
}
}
function startTheRain()
{
$RainTimeCounter++;
//echo("Rain counter : " @ $RainTimeCounter);
if($RainTimeCounter == getword($season[$MySeason] ,2))
{
$RainTimeCounter =0;
$StartRainNow = 2;
}
if($RainTimeCounter >= (getword($season[$MySeason] ,2) -3))
{
if(isObject(MyRain))
MyRain.delete();
if(isObject(MyLightning))
MyLightning.delete();
}
if($RainTimeCounter <= 1 && $StartRainNow == 1)
{
$MySkyCloud1 = getword($season[$MySeason], 6)/100;
$MySkyCloud2 = getword($season[$MySeason], 7)/100;
$MySkyCloud3 = getword($season[$MySeason], 8)/100;
$IsStorm = getRandom(1 ,8);
//$IsStorm = 8; //use this to snowing cycle only for snowed mountans
$MySkyClSpeed1 = ("0.0001" * $IsStorm);
$MySkyClSpeed2 = ("0.0001" * ($IsStorm /2));
$MySkyClSpeed3 = ("0.0001" * ($IsStorm /3));
//echo("Storm size : " @ $IsStorm);
%SetDropsNumber = $IsStorm * 3000;
if($IsStorm >=3)
{
if($MySeason <=2){
if($IsStorm ==8)
$IsStorm =7;
}
%setRain = "Rain";
%SetSpeedmin = $IsStorm /3;
%SetSpeedmax = $IsStorm /2;
if($IsStorm >= 5 && $IsStorm <=6 )
{
%setRain = "Rain";
StartTheLighting();
}
if($IsStorm ==7 )
{
%setRain = "HeavyRain";
StartTheLighting();
}
if($IsStorm >=8)
{
%setRain = "Snow";
%SetSpeedmin = "0.3";
%SetSpeedmax = "0.5";
}
new Precipitation(MyRain)
{
datablock = %setRain;
minSpeed = %SetSpeedmin;
maxSpeed = %SetSpeedmax;
numDrops = %SetDropsNumber;
boxWidth = "200";
boxHeight = "100";
minMass = "1.0";
maxMass = "2.0";
rotateWithCamVel = true;
doCollision = true;
useTurbulence = false;
};
MyRain.modifyStorm(0.1, getword($season[$MySeason] ,2));
}
changeTheSky();
}
if(isObject(MyMoon)){
MyMoon.delete();
}
}
function StartTheLighting()
{
%GetStrikes = $IsStorm *2;
%GetStrikesWidth = $IsStorm * 0.01;
%GetPos = "0 0 0";
%numHumans = 0;
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%client = ClientGroup.getObject(%i);
if( !%client.isAIControlled() )
{
if(isObject(%client.player))
{
%numHumans++;
%pos = VectorAdd(%pos, %client.player.position);
}
}
}
%GetPos = VectorScale(%pos, 1.0 / (%numHumans ));
if (!isObject(MyLightning))
{
new Lightning(MyLightning)
{
position = %GetPos;
scale = "250 350 450";
dataBlock = "LightningStorm";
strikesPerMinute = %GetStrikes;
strikeWidth = %GetStrikesWidth;
chanceToHitTarget = "0.02";
strikeRadius = "500";
boltStartRadius = "20";
color = "1 1 1 1";
fadeColor = "8 8 8 1";
useFog = "1";
locked = "false";
};
}
}
function SetDefaultSeasonSky()
{
%nowCloud1 = getword($season[$MySeason], 3)/10;
%nowCloud2 = getword($season[$MySeason], 4)/10;
%nowCloud3 = getword($season[$MySeason], 5)/10;
%Cloud1 = $MySkyCloud1 * 10;
%Cloud1--;
if(%Cloud1<= %nowCloud1){
%Cloud1 = %nowCloud1;
}
%Cloud2 = $MySkyCloud2 * 10;
%Cloud2--;
if(%Cloud2 <= %nowCloud2){
%Cloud2 = %nowCloud2;
}
%Cloud3 = $MySkyCloud3 * 10;
%Cloud3--;
if(%Cloud3 <= %nowCloud3){
%Cloud3 = %nowCloud3;
}
$MySkyCloud1 = %Cloud1 /10;
$MySkyCloud2 = %Cloud2 /10;
$MySkyCloud3 = %Cloud3 /10;
$MySkyClSpeed1 = getword($season[$MySeason], 2)/220000;
$MySkyClSpeed2 = getword($season[$MySeason], 2)/260000;
$MySkyClSpeed3 = getword($season[$MySeason], 2)/300000;
changeTheSky();
//echo($MySkyCloud1 SPC $MySkyCloud2 SPC $MySkyCloud3);
if(($MySkyCloud1 *10) <= %nowCloud1 && ($MySkyCloud2 *10) <= %nowCloud2 && ($MySkyCloud3 *10) <= %nowCloud3)
{
if($MySeason == 0)
$MyHeliosMaxBrt = "0.9";
if($MySeason == 1)
$MyHeliosMaxBrt = "1";
if($MySeason == 2)
$MyHeliosMaxBrt = "0.8";
if($MySeason == 4){
$MyHeliosMaxBrt = "0.6";
}
CreateTheSun();
$StartRainNow = 0;
}
}
function SetRainPrepare()
{
%nowCloud1 = getword($season[$MySeason], 6)/10;
%nowCloud2 = getword($season[$MySeason], 7)/10;
%nowCloud3 = getword($season[$MySeason], 8)/10;
%Cloud1 = $MySkyCloud1 * 10;
%Cloud1++;
if(%Cloud1>= %nowCloud1){
%Cloud1 = %nowCloud1;
}
%Cloud2 = $MySkyCloud2 * 10;
%Cloud2++;
if(%Cloud2 >= %nowCloud2){
%Cloud2 = %nowCloud2;
}
%Cloud3 = $MySkyCloud3 * 10;
%Cloud3++;
if(%Cloud3 >= %nowCloud3){
%Cloud3 = %nowCloud3;
}
$MySkyCloud1 = %Cloud1 /10;
$MySkyCloud2 = %Cloud2 /10;
$MySkyCloud3 = %Cloud3 /10;
changeTheSky();
//echo("Prapare>> " @ $MySkyCloud1 SPC $MySkyCloud2 SPC $MySkyCloud3);
if(($MySkyCloud1 *10) >= %nowCloud1 && ($MySkyCloud2 *10) >= %nowCloud2 && ($MySkyCloud3 *10) >= %nowCloud3)
$RainTimeCounter =0;
$StartRainNow = 1;
$MyHeliosMaxBrt = "0.2";
CreateTheSun();
}
//-----------------------------------------------------------------------------
datablock SFXProfile(MyHeavyRainSound)
{
fileName = "~/data/sound/environment/HeavyRain";
description = AudioLooping2d;
preload = true;
};
datablock SFXProfile(MyRainSound)
{
fileName = "~/data/sound/environment/Rain";
description = AudioLooping2d;
preload = true;
};
datablock SFXProfile(MySnowSound)
{
fileName = "~/data/sound/environment/snow";
description = AudioLooping2d;
preload = true;
};
datablock PrecipitationData(Rain)
{
soundProfile = "MyRainSound";
dropTexture = "~/data/environment/rain";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.2;
splashSize = 0.01;
useTrueBillboards = false;
splashMS = 250;
};
datablock PrecipitationData(HeavyRain)
{
soundProfile = "MyHeavyRainSound";
dropTexture = "~/data/environment/rain";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.3;
splashSize = 0.05;
useTrueBillboards = false;
splashMS = 250;
};
datablock PrecipitationData(Snow)
{
soundProfile = "MySnowSound";
dropTexture = "~/data/environment/snow";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.1;
splashSize = 0.001;
useTrueBillboards = true;
splashMS = 0.1;
};
datablock SFXProfile(ThunderCrash1Sound)
{
fileName = "~/data/sound/environment/thunder1";
description = AudioClose3d;
preload = true;
};
datablock SFXProfile(ThunderCrash2Sound)
{
fileName = "~/data/sound/environment/thunder2";
description = AudioClose3d;
preload = true;
};
datablock SFXProfile(ThunderCrash3Sound)
{
fileName = "~/data/sound/environment/thunder3";
description = AudioClose3d;
preload = true;
};
datablock SFXProfile(ThunderCrash4Sound)
{
fileName = "~/data/sound/environment/thunder4";
description = AudioClose3d;
preload = true;
};
datablock LightningData(LightningStorm)
{
strikeTextures[0] = "~/data/environment/lightning.dml";
thunderSounds[0] = ThunderCrash1Sound;
thunderSounds[1] = ThunderCrash2Sound;
thunderSounds[2] = ThunderCrash3Sound;
thunderSounds[3] = ThunderCrash4Sound;
};
Click Here for screenshots
About the author
entelsoft, commercial accounting software
#22
05/05/2010 (7:27 pm)
Dimitri I am running T3D and would like a chance to look over your script changes. You can reach me at thevisad (at) gmail (dot) com.
#23
Sorry I have not replied in due time but incomplete job for long periods outside.
I am now working more in td3 which is amazing.
This code needs some changes to t3d and natural additions.
Will do them soon. With a good graphics card I saw that t3d plays in real time with all the shadows and physics without problems.
for contact use if you like my email Astald.tor@gmail.com
07/26/2010 (2:07 pm)
Hi everyone ..Sorry I have not replied in due time but incomplete job for long periods outside.
I am now working more in td3 which is amazing.
This code needs some changes to t3d and natural additions.
Will do them soon. With a good graphics card I saw that t3d plays in real time with all the shadows and physics without problems.
for contact use if you like my email Astald.tor@gmail.com
#24
10/06/2010 (3:55 pm)
I would love to see you current work on this. Please update us! This would be a great resource for T3D!
#25
10/06/2010 (3:56 pm)
This currently works in T3D without too much of an issue; however, the sun is not as smooth as the ToD mod. The weather effects are awesome to play with and work very well.
#26
06/10/2011 (8:22 pm)
Working on the T3D, has great potential and many functions of the code already exists. I intend to upgrade to a more realistic annual cycle in all weather and conditions. Write a mmorpg and soon will need to add seasons.
#27
08/27/2011 (3:41 pm)
hows the progress on this been goin?
#28
03/04/2014 (3:14 pm)
hi, found a copy of the code on the web, will make it work with last 3.5. 
Torque 3D Owner Scottie Sirius