Debian Codegraph @

Models/Volcanoes/Katla/katla.nas

raw
1 var katla_ash_loop_flag = 0;
2
3 var katla_main_factor = 1.0;
4 var katla_main_probability = 0.985;
5
6 var katla_pos = geo.Coord.new().set_latlon(63.65750, -19.182871);
7
8
9 var katla_ash_loop = func (timer) {
10
11 if (katla_ash_loop_flag == 0)
12 {
13 print("Ending Katla ash eruption simulation.");
14 return;
15 }
16
17 if (timer < 0.0)
18 {
19
20 if (rand() > 0.6)
21 {
22 setprop("/environment/volcanoes/katla/ash-main-alpha", (rand() - 0.5) * 60.0);
23 setprop("/environment/volcanoes/katla/ash-main-beta", (rand() - 0.5) * 60.0);
24 }
25 else
26 {
27 setprop("/environment/volcanoes/katla/ash-main-alpha", 0.0);
28 setprop("/environment/volcanoes/katla/ash-main-beta", 0.0);
29 }
30 timer = 2.0 + 3.0 * rand();
31 }
32
33 var aircraft_pos = geo.aircraft_position();
34 var dist = aircraft_pos.distance_to(katla_pos);
35 var turbulence = 25000000.0/(dist * dist);
36 if (turbulence > 1.0) {turbulence = 1.0;}
37
38 setprop("/environment/volcanoes/turbulence", turbulence);
39
40 timer = timer - 0.1;
41
42 settimer(func {katla_ash_loop(timer);}, 0.1);
43 }
44
45
46 katla_state_manager = func {
47
48 var state_main = getprop("/environment/volcanoes/katla/main-activity");
49
50 if ( (state_main > 0) and (katla_ash_loop_flag == 0))
51 {
52 print ("Starting Katla ash eruption simulation.");
53 katla_ash_loop_flag = 1;
54 katla_ash_loop(0.0);
55 }
56 else if ((state_main < 1) and (katla_ash_loop_flag == 1))
57 {
58 katla_ash_loop_flag = 0;
59 setprop("/environment/volcanoes/turbulence", 0);
60
61 }
62
63
64
65
66 }
67
68 # call state manager once to get correct autosaved behavior, otherwise use listener
69
70 katla_state_manager();
71 setlistener("/environment/volcanoes/katla/main-activity", katla_state_manager);