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