1 ! Z-Tornado - Two player weather action game
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)
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.
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.
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/>.
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;
28 for (i = 0: i < 13: i++) {
30 weather_array->i = ch;
32 weather_array->i = ' ';
35 while (num_moved > 0) {
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) {
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) {
52 print (char) weather_array->i;
55 ! we have hit something
57 if (weather_array->i == ' ' or ch)
61 ! if ch == hail and we've hit snow, don't delete
62 if ((ch == ':') && (CountDestroyed('*', xx, yy, 1, 1) == 1))
64 weather_array->i = strength;
69 ChangeSnowWorld(' ', xx, yy);
76 xx = x + shift*(yy - 5);
77 @set_cursor screen_height 1;
80 @set_cursor screen_height 1;
82 ! delete the rain/hail/whatever (whatever ?)
85 while (num_moved > 0) {
87 for (i = 0: i < 13: i++) {
88 if (starty >= yy || starty >= house1_y + 10)
90 if (xx + 13 < 1 || xx > screen_width)
92 tmp = GetLoc(xx, starty);
93 if (tmp < fields && snow_world->tmp == ' ') {
94 @set_cursor starty xx;
101 xx = x + shift*(starty - 5);
102 @set_cursor screen_height 1;
105 return num_destroyed;
108 ! Kianga's Next Generation Snow Machine
109 ! Includes Special SnowLogic(tm)
112 Array snow_startx -> 13;
113 Array snow_starty -> 13;
114 [ DrawSnow x shift xx yy i num_moved tmp;
117 for (i = 0: i < 13: i++) {
119 weather_array->i = '*';
121 weather_array->i = ' ';
123 snow_startx->i = x + i;
128 while (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)
140 ! did we hit something?
142 if (CountDestroyed(' ', snow_x->i, snow_y->i, 1, 1) == 1) {
143 if (weather_array->i == ' ' or '*') {
147 print (char) weather_array->i;
150 ! we've hit something
152 weather_array->i = 1;
154 xx = snow_x->i - shift;
158 ChangeSnowWorld('*', xx, yy);
162 if (snow_y->i == screen_height - 1) {
163 weather_array->i = 1;
166 if (CountDestroyed(' ', xx, yy, 1, 1) == 1) {
169 ChangeSnowWorld('*', xx, yy);
174 snow_x->i = snow_x->i + shift;
176 @set_cursor screen_height 1;
179 @set_cursor screen_height 1;
183 while (num_moved > 0) {
185 for (i = 0: i < 13: i++) {
186 if (snow_starty->i >= snow_y->i)
190 tmp = GetLoc(xx, yy);
191 if ((tmp < fields) && (snow_world->tmp == ' ')) {
197 snow_startx->i = snow_startx->i + shift;
199 @set_cursor screen_height 1;
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
211 num_destroyed = CountDestroyed(' ', house2_x, house2_y, 17, 10);
213 num_destroyed = CountDestroyed(' ', house1_x, house1_y, 17, 10);
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;
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;
269 ! ...and delete it again
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;
298 return CountDestroyed(' ', house2_x, house2_y, 17, 10) - num_destroyed;
299 return CountDestroyed(' ', house1_x, house1_y, 17, 10) - num_destroyed;
302 [ DrawTornado x shift xx y shift_right tmp_x tmp_y width width_tmp
306 tmp_x = x; tmp_y = y;
309 num_destroyed = CountDestroyed(' ', house2_x, house2_y, 17, 10);
311 num_destroyed = CountDestroyed(' ', house1_x, house1_y, 17, 10);
317 if (tmp_y == 18) width = 2;
318 if (tmp_y == 21) width = 1;
321 shift_right = shift_right - 3;
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 "#";
332 tmp_x = tmp_x + shift;
333 if (xx > 0 && xx <= screen_width) {
334 @set_cursor screen_height 1;
338 @set_cursor screen_height 1;
340 tmp_x = x; tmp_y = y;
348 if (tmp_y == 18) width = 2;
349 if (tmp_y == 21) width = 1;
352 shift_right = shift_right - 3;
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;
362 tmp_x = tmp_x + shift;
363 if (xx > 0 && xx <= screen_width)
364 @set_cursor screen_height 1;
368 return CountDestroyed(' ', house2_x, house2_y, 17, 10) - num_destroyed;
369 return CountDestroyed(' ', house1_x, house1_y, 17, 10) - num_destroyed;
372 ! This *does* look like a cloud in real life ;)
373 ! @{B0} is a degree character on decent interpreters
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;
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("+", "*");