Debian Codegraph @

Models/Volcanoes/Etna/etna.nas

raw
1 var etna_ash_loop_flag = 0;
2 var etna_fountain_loop_flag = 0;
3
4 var etna_se_factor = 1.0;
5 var etna_ne_factor = 1.0;
6
7 var etna_se_probability = 0.985;
8 var etna_ne_probability = 0.985;
9
10
11 var etna_ash_loop = func (timer) {
12
13 if (etna_ash_loop_flag == 0)
14 {
15 print("Ending Etna ash eruption simulation.");
16 return;
17 }
18
19 if (timer < 0.0)
20 {
21
22 if (rand() > 0.6)
23 {
24 setprop("/environment/volcanoes/etna/ash-se-alpha", (rand() - 0.5) * 60.0);
25 setprop("/environment/volcanoes/etna/ash-se-beta", (rand() - 0.5) * 60.0);
26 setprop("/environment/volcanoes/etna/ash-ne-alpha", (rand() - 0.5) * 60.0);
27 setprop("/environment/volcanoes/etna/ash-ne-beta", (rand() - 0.5) * 60.0);
28 }
29 else
30 {
31 setprop("/environment/volcanoes/etna/ash-se-alpha", 0.0);
32 setprop("/environment/volcanoes/etna/ash-se-beta", 0.0);
33 setprop("/environment/volcanoes/etna/ash-ne-alpha", 0.0);
34 setprop("/environment/volcanoes/etna/ash-ne-beta", 0.0);
35 }
36 timer = 2.0 + 3.0 * rand();
37 }
38
39 timer = timer - 0.1;
40
41 settimer(func {etna_ash_loop(timer);}, 0.1);
42 }
43
44
45 var etna_fountain_loop = func (timer, strength, timer_sec, strength_sec) {
46
47 if (etna_fountain_loop_flag == 0)
48 {
49 print("Ending Etna lava fountain simulation.");
50 return;
51 }
52
53
54 if ((timer <= 0.0) and (rand() > etna_se_probability))
55 {
56 strength = 180.0 + 70.0 * rand();
57 strength *= etna_se_factor;
58 timer = 0.4 + 0.4 * rand();
59 setprop("/environment/volcanoes/etna/ash-se-alpha", (rand() - 0.5) * 40.0);
60 setprop("/environment/volcanoes/etna/ash-se-beta", (rand() - 0.5) * 40.0);
61 }
62 else if (timer <= 0.0)
63 {
64 strength = strength - 3.0;
65 }
66 else
67 {
68 strength = strength - 0.5;
69 }
70
71 if (strength < 10.0) {strength = 10.0;}
72
73
74 setprop("/environment/volcanoes/etna/se-strength", strength );
75 setprop("/environment/volcanoes/etna/se-strength-inner", 0.95 * strength );
76 setprop("/environment/volcanoes/etna/se-quantity", int(5.0*strength + rand()));
77 setprop("/environment/volcanoes/etna/se-quantity-inner", int(1.0*strength + 0.2 * rand()));
78
79 timer = timer - 0.1;
80
81
82 if ((timer_sec <= 0.0) and (rand() > etna_ne_probability))
83 {
84 strength_sec = 140.0 + 60.0 * rand();
85 strength_sec *= etna_ne_factor;
86 timer_sec = 0.2 + 0.2 * rand();
87 setprop("/environment/volcanoes/etna/ash-ne-alpha", (rand() - 0.5) * 40.0);
88 setprop("/environment/volcanoes/etna/ash-ne-beta", (rand() - 0.5) * 40.0);
89 }
90 else if (timer_sec <= 0.0)
91 {
92 strength_sec = strength_sec - 3.0;
93 }
94 else
95 {
96 strength_sec = strength_sec - 0.5;
97 }
98
99 if (strength_sec < 10.0) {strength_sec = 10.0;}
100
101
102 setprop("/environment/volcanoes/etna/ne-strength", 0.95 * ((0.9 + 0.1 * rand()) * strength_sec) );
103 setprop("/environment/volcanoes/etna/ne-strength-inner", ((0.9 + 0.1 * rand()) * strength_sec) );
104 setprop("/environment/volcanoes/etna/ne-quantity", int(5.0*strength_sec + rand()));
105 setprop("/environment/volcanoes/etna/ne-quantity-inner", int(1.0*strength_sec + 0.2 * rand()));
106
107 timer_sec = timer_sec - 0.1;
108
109 settimer(func {etna_fountain_loop(timer, strength, timer_sec, strength_sec);}, 0.1);
110 }
111
112
113
114 etna_state_manager = func {
115
116 var state_se = getprop("/environment/volcanoes/etna/southeast-activity");
117 var state_ne = getprop("/environment/volcanoes/etna/northeast-activity");
118 var state_flank = getprop("/environment/volcanoes/etna/flank-activity");
119
120 if (((state_se > 2) or (state_ne > 2)) and (etna_ash_loop_flag == 0))
121 {
122 print ("Starting Etna ash eruption simulation.");
123 etna_ash_loop_flag = 1;
124 etna_ash_loop(0.0);
125 }
126 else if ((state_se < 3) and (state_ne < 3) and (etna_ash_loop_flag == 1))
127 {
128 etna_ash_loop_flag = 0;
129 }
130
131
132
133 if (((state_se == 2) or (state_ne == 2)) and (etna_fountain_loop_flag == 0))
134 {
135 print ("Starting Etna lava fountain simulation.");
136 etna_fountain_loop_flag = 1;
137 etna_fountain_loop(0.0, 0.0, 0.0, 0.0);
138 }
139 else if ((state_se < 2) and (state_ne < 2) and (etna_fountain_loop_flag == 1))
140 {
141 etna_fountain_loop_flag = 0;
142 }
143 }
144
145 # call state manager once to get correct autosaved behavior, otherwise use listener
146
147 etna_state_manager();
148
149 setlistener("/environment/volcanoes/etna/southeast-activity", etna_state_manager);
150 setlistener("/environment/volcanoes/etna/northeast-activity", etna_state_manager);