Add .gitignore
[ztornado.git] / weather.inf
1 ! Z-Tornado - Two player weather action game
2 !
3 ! Tornado is copyright (C) 2000-2002  Oliver Feiler
4 ! http://www.lionking.org/~kiza/linux/tornado
5 ! Inform version copyright (c) 2003  Sophie Frühling (sfruehling@aon.at)
6
7 ! This program is free software; you can redistribute it and/or modify
8 ! it under the terms of the GNU General Public License as published by
9 ! the Free Software Foundation; either version 3 of the License, or
10 ! (at your option) any later version.
11 !
12 ! This program is distributed in the hope that it will be useful,
13 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ! GNU General Public License for more details.
16 !
17 ! You should have received a copy of the GNU General Public License
18 ! along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 ! Next Generation Weather Function
21 ! rain (strength 1) and hail (strength 2)
22 Array weather_array -> 13;
23 [ DrawWeather x shift ch strength  tmp i num_moved num_destroyed xx starty yy;
24   num_destroyed = 0;
25   yy = 5; xx = x;
26   starty = 5;
27   ! Init weather_array
28   for (i = 0: i < 13: i++) {
29     if (i%3 == 0)
30       weather_array->i = ch;
31     else
32       weather_array->i = ' ';
33   }
34   num_moved = 1;
35   while (num_moved > 0) {
36     num_moved = 0;
37     ! move each character
38     for (i = 0: i < 13: i++) {
39       ! bottom, left, or right border
40       if ((yy >= house1_y + 10) || (xx >= screen_width) || (xx <= 1))
41         weather_array->i = strength;
42       ! skip if this object has disappeared (weather_array->i >= strength)
43       if ((weather_array->i ~= ' ' or ch) && weather_array->i >= strength) {
44         xx++; continue;
45       }
46       num_moved++;
47       ! did we hit something?
48       ! no hit (there is a space character at xx yy)
49       if (CountDestroyed(' ', xx, yy, 1, 1) == 1) {
50         if (weather_array->i == ' ' or ch) {
51           @set_cursor yy xx;
52           print (char) weather_array->i;
53         }
54       }
55       ! we have hit something
56       else {
57         if (weather_array->i == ' ' or ch)
58           weather_array->i = 1;
59         else
60            (weather_array->i)++;
61         ! if ch == hail and we've hit snow, don't delete
62         if ((ch == ':') && (CountDestroyed('*', xx, yy, 1, 1) == 1))
63           ! "expire" the object
64           weather_array->i = strength;
65         else {
66           ! draw the object
67           @set_cursor yy xx;
68           print (char) ch;
69           ChangeSnowWorld(' ', xx, yy);
70           num_destroyed++;
71         }
72       }
73       xx++;
74     }
75     yy++;
76     xx = x + shift*(yy - 5);
77     @set_cursor screen_height 1;
78     Pause(2);
79   }
80   @set_cursor screen_height 1;
81   Pause(10);
82   ! delete the rain/hail/whatever (whatever ?)
83   xx = x;
84   num_moved = 1;
85   while (num_moved > 0) {
86     num_moved = 0;
87     for (i = 0: i < 13: i++) {
88       if (starty >= yy || starty >= house1_y + 10)
89         break;
90       if (xx + 13 < 1 || xx > screen_width)
91         continue;
92       tmp = GetLoc(xx, starty);
93       if (tmp < fields && snow_world->tmp == ' ') {
94         @set_cursor starty xx;
95         print (char) ' ';
96       }
97       xx++;
98       num_moved++;
99     }
100     starty++;
101     xx = x + shift*(starty - 5);
102     @set_cursor screen_height 1;
103     Pause(1);
104   }
105   return num_destroyed;
106 ];
107
108 ! Kianga's Next Generation Snow Machine
109 ! Includes Special SnowLogic(tm)
110 Array snow_x -> 13;
111 Array snow_y -> 13;
112 Array snow_startx -> 13;
113 Array snow_starty -> 13;
114 [ DrawSnow x shift  xx yy i num_moved tmp;
115   yy = 5; xx = x;
116   ! Put snow in array
117   for (i = 0: i < 13: i++) {
118     if (i%3 == 0)
119       weather_array->i = '*';
120     else 
121       weather_array->i = ' ';
122     snow_x->i = x + i;
123     snow_startx->i = x + i;
124     snow_y->i = yy;
125     snow_starty->i = yy;
126   }
127   num_moved = 1;
128   while (num_moved > 0) {
129     num_moved = 0;
130     ! move each character
131     for (i = 0: i < 13: i++) {
132       ! bottom, left, or right border
133       if ((snow_y->i >= house1_y + 10)
134       || (snow_x->i >= screen_width) || (snow_x->i <= 1))
135         weather_array->i = 1;
136       ! skip if this object has disappeared (weather_array->i >= strength)
137       if ((weather_array->i ~= ' ' or '*') && weather_array->i >= 1)
138         continue;
139       num_moved++;
140       ! did we hit something?
141       ! no hit
142       if (CountDestroyed(' ', snow_x->i, snow_y->i, 1, 1) == 1) {
143         if (weather_array->i == ' ' or '*') {
144           xx = snow_x->i;
145           yy = snow_y->i;
146           @set_cursor yy xx;
147           print (char) weather_array->i;
148         }
149       }
150       ! we've hit something
151       else {
152         weather_array->i = 1;
153         if (snow_y->i > 5) {
154           xx = snow_x->i - shift;
155           yy = snow_y->i - 1;
156           @set_cursor yy xx;
157           print (char) '*';
158           ChangeSnowWorld('*', xx, yy);
159         }
160       }
161       ! bottom
162       if (snow_y->i == screen_height - 1) {
163         weather_array->i = 1;
164         xx = snow_x->i;
165         yy = snow_y->i;
166         if (CountDestroyed(' ', xx, yy, 1, 1) == 1) {
167           @set_cursor yy xx;
168           print (char) '*';
169           ChangeSnowWorld('*', xx, yy);
170         }
171       }         
172       ! move the object
173       (snow_y->i)++;
174       snow_x->i = snow_x->i + shift;
175     }
176     @set_cursor screen_height 1;
177     Pause(2);
178   }
179   @set_cursor screen_height 1;
180   Pause(10);
181   ! delete the snow
182   num_moved = 1;
183   while (num_moved > 0) {
184     num_moved = 0;
185     for (i = 0: i < 13: i++) {
186       if (snow_starty->i >= snow_y->i)
187         continue;
188       xx = snow_startx->i;
189       yy = snow_starty->i;
190       tmp = GetLoc(xx, yy);
191       if ((tmp < fields) && (snow_world->tmp == ' ')) {
192         @set_cursor yy xx;
193         print (char) ' ';
194       }
195       num_moved++;
196       (snow_starty->i)++;
197       snow_startx->i = snow_startx->i + shift;
198     }
199     @set_cursor screen_height 1;
200     Pause(1);
201   }
202 ];
203
204 ! Probably the ugliest function in the whole program.
205 [ DrawLightning x  xx y num_destroyed;
206   ! Is needed if screen_width is smaller than 80, maybe due to some
207   ! bug somewhere else
208   DrawStatusLine();
209   xx = x + 6; y = 5;
210   if (player1)
211     num_destroyed = CountDestroyed(' ', house2_x, house2_y, 17, 10);
212   else
213     num_destroyed = CountDestroyed(' ', house1_x, house1_y, 17, 10);
214   ! draw it...
215   @set_cursor  5 xx; print "||";
216   ChangeWorld(xx, 5, 2);
217   @set_cursor  6 xx; print "//";
218   ChangeWorld(xx, 6, 2); xx--;
219   @set_cursor  7 xx; print "//@@92@@92";
220   ChangeWorld(xx, 7, 4); xx--;
221   @set_cursor  8 xx; print "//";
222   ChangeWorld(xx, 8, 2); xx = x + 7;
223   @set_cursor  8 xx; print "@@92@@92";
224   ChangeWorld(xx, 8, 2); xx = x + 3;
225   @set_cursor  9 xx; print "||";
226   ChangeWorld(xx, 9, 2); xx = x + 8;
227   @set_cursor  9 xx; print "@@92@@92";
228   ChangeWorld(xx, 9, 2); xx++;
229   @set_cursor 10 xx; print "@@92@@92";
230   ChangeWorld(xx, 10, 2); xx--;
231   @set_cursor 11 xx; print "//@@92@@92";
232   ChangeWorld(xx, 11, 4); xx--;
233   @set_cursor 12 xx; print "//";
234   ChangeWorld(xx, 12, 2); xx = x + 11;
235   @set_cursor 12 xx; print "@@92@@92";
236   ChangeWorld(xx, 12, 2); xx = x + 7;
237   @set_cursor 13 xx; print "||";
238   ChangeWorld(xx, 13, 2); xx--;
239   @set_cursor screen_height 1;
240   Pause(2);
241   @set_cursor 14 xx; print "//@@92@@92";
242   ChangeWorld(xx, 14, 4); xx--;
243   @set_cursor 15 xx; print "//";
244   ChangeWorld(xx, 15, 2); xx = x + 9;
245   @set_cursor 15 xx; print "@@92@@92";
246   ChangeWorld(xx, 15, 2); xx = x + 4;
247   @set_cursor 16 xx; print "//";
248   ChangeWorld(xx, 16, 2); xx = x + 10;
249   @set_cursor 16 xx; print "@@92@@92";
250   ChangeWorld(xx, 16, 2);
251   @set_cursor 17 xx; print "||";
252   ChangeWorld(xx, 17, 2); xx--;
253   @set_cursor 18 xx; print "//@@92@@92";
254   ChangeWorld(xx, 18, 4); xx--;
255   @set_cursor 19 xx; print "//";
256   ChangeWorld(xx, 19, 2); xx = x + 12;
257   @set_cursor 19 xx; print "@@92@@92";
258   ChangeWorld(xx, 19, 2); xx = x + 7;
259   @set_cursor 20 xx; print "//";
260   ChangeWorld(xx, 20, 2);
261   @set_cursor 21 xx; print "@@92@@92";
262   ChangeWorld(xx, 21, 2); xx++;
263   @set_cursor 22 xx; print "@@92@@92";
264   ChangeWorld(xx, 22, 2); xx++;
265   @set_cursor 23 xx; print "@@92@@92";
266   ChangeWorld(xx, 23, 2);
267   @set_cursor screen_height 1;
268   Pause(10);
269   ! ...and delete it again
270   xx = x + 6;
271   @set_cursor  5 xx; print "  ";
272   @set_cursor  6 xx; print "  ";   xx--;
273   @set_cursor  7 xx; print "    "; xx--;
274   @set_cursor  8 xx; print "  ";   xx = x + 7;
275   @set_cursor  8 xx; print "  ";   xx = x + 3;
276   @set_cursor  9 xx; print "  ";   xx = x + 8;
277   @set_cursor  9 xx; print "  ";   xx++;
278   @set_cursor 10 xx; print "  ";   xx--;
279   @set_cursor 11 xx; print "    "; xx--;
280   @set_cursor 12 xx; print "  ";   xx = x + 11;
281   @set_cursor 12 xx; print "  ";   xx = x + 7;
282   @set_cursor 13 xx; print "  ";   xx--;
283   @set_cursor 14 xx; print "    "; xx--;
284   @set_cursor 15 xx; print "  ";   xx = x + 9;
285   @set_cursor 15 xx; print "  ";   xx = x + 4;
286   @set_cursor 16 xx; print "  ";   xx = x + 10;
287   @set_cursor 16 xx; print "  ";
288   @set_cursor 17 xx; print "  ";   xx--;
289   @set_cursor 18 xx; print "    ";   xx--;
290   @set_cursor 19 xx; print "  ";   xx = x + 12;
291   @set_cursor 19 xx; print "  ";   xx = x + 7;
292   @set_cursor 20 xx; print "  ";
293   @set_cursor 21 xx; print "  ";   xx++;
294   @set_cursor 22 xx; print "  ";   xx++;
295   @set_cursor 23 xx; print "  ";
296   @set_cursor screen_height 1;
297   if (player1)
298     return CountDestroyed(' ', house2_x, house2_y, 17, 10) - num_destroyed;
299   return CountDestroyed(' ', house1_x, house1_y, 17, 10) - num_destroyed;
300 ];
301
302 [ DrawTornado x shift  xx y shift_right tmp_x tmp_y width width_tmp
303   num_destroyed;
304   xx = 0; y = 4;
305   shift_right = 0;
306   tmp_x = x; tmp_y = y;
307   width = 29;
308   if (player1)
309     num_destroyed = CountDestroyed(' ', house2_x, house2_y, 17, 10);
310   else
311     num_destroyed = CountDestroyed(' ', house1_x, house1_y, 17, 10);
312   while (tmp_y < 24) {
313     if (width > 3) {
314       width = width - 2;
315       shift_right++;
316     }
317     if (tmp_y == 18) width = 2;
318     if (tmp_y == 21) width = 1;
319     if (tmp_y == 23) {
320       width = 7;
321       shift_right = shift_right - 3;
322     }
323     xx = tmp_x + shift_right;
324     ChangeWorld(xx, tmp_y, width);
325     for (width_tmp = 0: width_tmp < width: width_tmp++) {
326       xx = tmp_x + shift_right + width_tmp;
327       if (xx > 0 && xx <= screen_width) {
328         @set_cursor tmp_y xx; print "#";
329       }
330     }
331     tmp_y++;
332     tmp_x = tmp_x + shift;
333     if (xx > 0 && xx <= screen_width) {
334       @set_cursor screen_height 1;
335       Pause(2);
336     }
337   }
338   @set_cursor screen_height 1;
339   Pause(10);
340   tmp_x = x; tmp_y = y;
341   shift_right = 0;
342   width = 29;
343   while (tmp_y < 24) {
344     if (width > 3) {
345       width = width - 2;
346       shift_right++;
347     }
348     if (tmp_y == 18) width = 2;
349     if (tmp_y == 21) width = 1;
350     if (tmp_y == 23) {
351       width = 7;
352       shift_right = shift_right - 3;
353     }
354     for (width_tmp = 0: width_tmp < width: width_tmp++) {
355       xx = tmp_x + shift_right + width_tmp;
356       if (xx > 0 && xx <= screen_width) {
357         @set_cursor tmp_y xx;
358         print " ";
359       }
360     }
361     tmp_y++;
362     tmp_x = tmp_x + shift;
363     if (xx > 0 && xx <= screen_width)
364       @set_cursor screen_height 1;
365       Pause(1);
366   }
367   if (player1)
368     return CountDestroyed(' ', house2_x, house2_y, 17, 10) - num_destroyed;
369   return CountDestroyed(' ', house1_x, house1_y, 17, 10) - num_destroyed;
370 ];
371
372 ! This *does* look like a cloud in real life ;)
373 ! @{B0} is a degree character on decent interpreters
374 [ DrawCloud x;
375   if (x ~= 0) cloud_x = x;
376   else cloud_x = random(screen_width - 29);
377   @set_cursor 1 cloud_x; print ",/+++*++***+****++++++***+@@92,";
378   @set_cursor 2 cloud_x; print "(*+++*****+++++***+++****++)";
379   @set_cursor 3 cloud_x; print "`@@92++******+*++*++*****+++*/'";
380   @set_cursor 4 cloud_x; print " `@{B0}*,.,*@{B0}'`@{B0}*,.,",
381                                "*@{B0}`@{B0}*,.,*@{B0}'";
382   @set_cursor screen_height 1;
383 ];
384
385 ! Replace the normal cloud with a bigger one
386 [ DrawTornadoCloud  i;
387   for (i = 1: i <= screen_width: i++) {
388     @set_cursor 1 i; print (string) random("+", "*");
389     @set_cursor 2 i; print (string) random("+", "*");
390     @set_cursor 3 i; print (string) random("+", "*");
391   }
392 ];
393