Upgrade to GPLv3
[ztornado.git] / erwin.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, write to the Free Software
19 ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ! (The AI is called Erwin for unknown reasons.)
22
23 ! The new improved AI (for the old, non-improved version, have a look at
24 ! the C source :)
25 [ ErwinChoice;
26   ! Choose snow randomly from time to time.
27   if (random(5) == 1) return 'S';
28   ! If the cloud is right above the enemy house and it has >75%
29   ! then we strike with lightning to do most damage.
30   ! If the cloud is close to the enemy house and it has >75%
31   ! then we strike with tornado.
32   ! If the cloud is far away from the enemy house
33   ! then we strike with hail.
34   ! If the place where we would like to hit is covered with snow
35   ! then we use rain to get rid of it.
36   if (player1) {
37     if (((CountDestroyed(' ', house2_x, house2_y, 17, 10) - SPACES) < 25)
38     && (cloud_x >= 40))
39       return 'L';
40     else if (((CountDestroyed(' ', house2_x, house2_y, 17, 10) - SPACES) < 25)
41     && (cloud_x >= 30))
42       return 'T';
43     else if (CountSnow(house2_x, house2_y, 17, 10) > 5)
44       return 'R';
45     else
46       return 'H';
47   } else {
48     if (((CountDestroyed(' ', house1_x, house1_y, 17, 10) - SPACES) < 25)
49     && (cloud_x <= 15))
50       return 'L';
51     if (((CountDestroyed(' ', house1_x, house1_y, 17, 10) - SPACES) < 25)
52     && (cloud_x <= 25))
53       return 'T';
54     else if (CountSnow(house1_x, house1_y, 17, 10) > 5)
55       return 'R';
56     else
57       return 'H';
58   }
59 ];
60
61 [ ErwinAim input;
62   ! For lightning, we don't need to aim and can return immediately
63   if (input == 'L')     return 0;
64   ! In case of snow, we aim at our own house
65   if (input == 'S') {
66     if (player1) {
67       if (windspeed <= 0)
68         return (Abs(windspeed * 20) + (-3 - cloud_x)) / 20;
69       else
70         return (-Abs(windspeed * 20) + (-3 - cloud_x)) / 20;
71     } else {
72       if (windspeed <= 0)
73         return (Abs(windspeed * 20) + (69 - cloud_x)) / 20;
74       else
75         return (-Abs(windspeed * 20) + (60 - cloud_x)) / 20;
76     }
77   }
78   ! Otherwise, we aim at the opponent's house
79   else if (player1) {
80     if (windspeed <= 0)
81       return (Abs(windspeed * 20) + (69 - cloud_x)) / 20;
82     else
83       return (-Abs(windspeed * 20) + (60 - cloud_x)) / 20;
84   } else {
85     if (windspeed <= 0)
86       return (Abs(windspeed * 20) + (-3 - cloud_x)) / 20;
87     else
88       return (-Abs(windspeed * 20) + (-3 - cloud_x)) / 20;
89   }
90 ];
91
92 [ Abs num;
93   if (num < 0)
94     return -num;
95   return num;
96 ];