bigstorm-3d.ac
100.0)
{var distance = math.sqrt(sdistance);}
else
{var distance = 0.0;}
if ((distance < 3000) and (distance > 2000.0) and (altitude<38000))
{
if (flag==1) # store the original settings when entering cloud
{
store();
flag=2; # set flag to prevent further action
}
if (transition_flag==1)
{
transition();
}
else
{
setprop("environment/metar/rain-norm",getprop("tmp/metar/rain-norm"));
setprop("environment/metar/snow-norm",getprop("tmp/metar/snow-norm"));
var econfig_aloftNode = props.globals.getNode("environment/config/aloft", 1);
var entries_aloft = econfig_aloftNode.getChildren("entry");
foreach (var e; entries_aloft) {
var v = e.getNode("visibility-m");
v.setValue(1000);
}
var econfig_boundaryNode = props.globals.getNode("environment/config/boundary", 1);
var entries_boundary = econfig_boundaryNode.getChildren("entry");
foreach (var e; entries_boundary) {
var v = e.getNode("visibility-m");
v.setValue(1000);
}
fgcommand("reinit", props.Node.new({subsystem:"environment"}));
}
}
else if ((distance < 2000) and (distance > 0.0) and (altitude<38000))
{
setprop("environment/clouds/layer[0]/elevation-ft",20000);
if (altitude < 10000)
{
setprop("environment/metar/rain-norm",0.8);
setprop("environment/metar/snow-norm",0);
}
else if ((altitude < 20000) and (altitude > 10000))
{
setprop("environment/metar/rain-norm",0);
setprop("environment/metar/snow-norm",0.8);
}
else
{
setprop("environment/metar/rain-norm",0);
setprop("environment/metar/snow-norm",0);
}
if (altitude<5000)
{
var econfig_aloftNode = props.globals.getNode("environment/config/aloft", 1);
var entries_aloft = econfig_aloftNode.getChildren("entry");
foreach (var e; entries_aloft) {
var v = e.getNode("visibility-m");
v.setValue(1000);
}
var econfig_boundaryNode = props.globals.getNode("environment/config/boundary", 1);
var entries_boundary = econfig_boundaryNode.getChildren("entry");
foreach (var e; entries_boundary) {
var v = e.getNode("visibility-m");
v.setValue(1000);
}
fgcommand("reinit", props.Node.new({subsystem:"environment"}));
}
else
{
var econfig_aloftNode = props.globals.getNode("environment/config/aloft", 1);
var entries_aloft = econfig_aloftNode.getChildren("entry");
foreach (var e; entries_aloft) {
var v = e.getNode("visibility-m");
v.setValue(100);
}
var econfig_boundaryNode = props.globals.getNode("environment/config/boundary", 1);
var entries_boundary = econfig_boundaryNode.getChildren("entry");
foreach (var e; entries_boundary) {
var v = e.getNode("visibility-m");
v.setValue(1000);
}
fgcommand("reinit", props.Node.new({subsystem:"environment"}));
}
}
else # we're not in the cloud
{
if ((flag==2) and (transition_flag==2)) # and we just left the cloud
{
# restore cloud layer altitude before initializing transition
setprop("environment/clouds/layer[0]/elevation-ft",getprop("tmp/clouds/layer[0]/elevation-ft"));
transition();
}
else if (flag==2) # we have left the cloud, restore the original settings
{
reset();
flag = 1;
}
}
settimer(thunderstorm_loop, 1);
}
var thunderstorm_turning_loop = func {
var clat = getprop("position/latitude-deg");
var clong = getprop("position/longitude-deg");
var slat = getprop("ai/models/thunderstorm[0]/position/latitude-deg");
var slong = getprop("ai/models/thunderstorm[0]/position/longitude-deg");
var angle = math.mod(math.atan2(math.sin(slong-clong) * math.cos(slat), math.cos(clat) * math.sin(slat)- math.sin(clat) * math.cos(slat) * math.cos(slong-clong)), 2 * math.pi) * R2D;
setprop("ai/models/thunderstorm[0]/orientation/rotation-deg",90-angle-heading);
settimer(thunderstorm_turning_loop, 0.05);
}
var count_nodes = func {
var econfig_aloftNode = props.globals.getNode("environment/config/aloft", 1);
var entries_aloft = econfig_aloftNode.getChildren("entry");
foreach (var e; entries_aloft) {
naloft=naloft+1;
}
var econfig_boundaryNode = props.globals.getNode("environment/config/boundary", 1);
var entries_boundary = econfig_boundaryNode.getChildren("entry");
foreach (var e; entries_boundary) {
nboundary=nboundary+1;
}
setsize(aloft_vis,naloft);
setsize(boundary_vis,nboundary);
}
print("Starting thunderstorm routines...");
var flag = 1;
var transition_flag = 1;
var transition_counter = 0;
var aloft_vis=[];
var naloft=0;
var boundary_vis=[];
var nboundary=0;
var heading = getprop("ai/models/thunderstorm[0]/orientation/true-heading-deg");
setprop("ai/models/thunderstorm[0]/in-cloud",'false');
settimer(count_nodes,1);
settimer(thunderstorm_loop,1.5); # start loop
settimer(thunderstorm_turning_loop,1.5); # start alignment transformation
print("Done.");
]]>
rotate
orientation/rotation-deg
1.0
0
0
1
select
lightning
/environment/lightning/flash
false
select
rain
main cloud layer
background cloud layer
foreground cloud layer
in-cloud
noshadow