aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he/moonbase/ai_main.h
blob: 8952cb5c0d0993a91b573eaf4f52160ddf0e3dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef SCUMM_HE_MOONBASE_AI_MAIN_H
#define SCUMM_HE_MOONBASE_AI_MAIN_H

#include "scumm/he/moonbase/ai_tree.h"

namespace Scumm {

class ScummEngine_v90he;

extern ScummEngine_v90he *_vm;

typedef Common::Array<int>::iterator intVecItr;

enum {
	TERRAIN_TYPE_GOOD = 0,
	TERRAIN_TYPE_SLOPE = 1,
	TERRAIN_TYPE_WATER = 2,
	MAX_MEMORY = 3
};

enum {
	ITEM_BOMB = 0,
	ITEM_CLUSTER = 1,
	ITEM_REPAIR = 2,
	ITEM_ANTIAIR = 3,
	ITEM_BRIDGE = 4,
	ITEM_TOWER = 5,
	ITEM_GUIDED = 6,
	ITEM_EMP = 7,
	ITEM_SPIKE = 8,
	ITEM_RECLAIMER = 9,
	ITEM_BALLOON = 10,
	ITEM_MINE = 11,
	ITEM_CRAWLER = 12,
	ITEM_VIRUS = 13,
	ITEM_ENERGY = 14,
	ITEM_SHIELD = 15,
	ITEM_OFFENSE = 16,
	ITEM_HUB = 17,
	ITEM_TIME_EXPIRED = 18,
	SKIP_TURN = -999
};

enum BuildingTypes {
	BUILDING_ENERGY_COLLECTOR = 3,
	BUILDING_MAIN_BASE = 4,
	BUILDING_BRIDGE = 5,
	BUILDING_TOWER = 6,
	BUILDING_EXPLOSIVE_MINE = 7,
	BUILDING_SHIELD = 8,
	BUILDING_ANTI_AIR = 9,
	BUILDING_OFFENSIVE_LAUNCHER = 10,
	BUILDING_BALLOON   = 11,
	BUILDING_CRAWLER   = 12
};

enum {
	ENERGY_POOL_X = 45,
	ENERGY_POOL_Y = 46,
	ENERGY_POOL_UNITS_ON = 47,

	MIN_DIST = 108
};

static int energyHogType = 0;

void resetAI(ScummEngine_v90he *vm);
void cleanUpAI();
void setAIType(const int paramCount, const int32 *params);
int masterControlProgram(const int paramCount, const int32 *params);

int chooseBehavior();
int chooseTarget(int behavior);

Tree *initApproachTarget(int targetX, int targetY, Node **retNode);
int *approachTarget(Tree *myTree, int &x, int &y, Node **currentNode);
Tree *initAcquireTarget(int targetX, int targetY, Node **retNode);
int *acquireTarget(int targetX, int targetY);
int *acquireTarget(int targetX, int targetY, Tree *myTree, int &errorCode);
int *offendTarget(int &targetX, int &targetY, int index);
int *defendTarget(int &targetX, int &targetY, int index);
int *energizeTarget(int &targetX, int &targetY, int index);

int getClosestUnit(int x, int y, int radius, int player, int alignment, int unitType, int checkUnitEnabled);
int getClosestUnit(int x, int y, int radius, int player, int alignment, int unitType, int checkUnitEnabled, int minDist);

int getDistance(int originX, int originY, int endX, int endY);
int calcAngle(int originX, int originY, int endX, int endY);
int calcAngle(int originX, int originY, int endX, int endY, int noWrapFlag);
int getTerrain(int x, int y);
int getHubX(int hub);
int getHubY(int hub);
int getMaxX();
int getMaxY();
int getCurrentPlayer();
int getMaxPower();
int getMinPower();
int getTerrainSquareSize();
int getBuildingOwner(int building);
int getBuildingState(int building);
int getBuildingType(int building);
int getBuildingArmor(int building);
int getBuildingWorth(int building);
int getEnergyPoolsArray();
int getCoordinateVisibility(int x, int y, int playerNum);
int getUnitVisibility(int unit, int playerNum);
int getEnergyPoolVisibility(int pool, int playerNum);
int getNumberOfPools();
int getNumberOfPlayers();
int getPlayerEnergy();
int getPlayerMaxTime();
int getWindXSpeed();
int getWindYSpeed();
int getTotalWindSpeed();
int getWindXSpeedMax();
int getWindYSpeedMax();
int getBigXSize();
int getBigYSize();
int getEnergyPoolWidth(int pool);
int getBuildingMaxArmor(int building);
int getTimerValue(int timerNum);
int getLastAttacked(int &x, int &y);
int getPlayerTeam(int player);
int getBuildingTeam(int building);
int getFOW();
int getAnimSpeed();
int getBuildingStackPtr();
int getTurnCounter();

int getGroundAltitude(int x, int y);
int checkForCordOverlap(int xStart, int yStart, int affectRadius, int simulateFlag);
int checkForAngleOverlap(int unit, int angle);
int estimateNextRoundEnergy(int player);
int checkForUnitOverlap(int x, int y, int radius, int ignoredUnit);
int checkForEnergySquare(int x, int y);
int aiChat();

int simulateBuildingLaunch(int x, int y, int power, int angle, int numSteps, int isEnergy);
int simulateWeaponLaunch(int x, int y, int power, int angle, int numSteps);
int fakeSimulateWeaponLaunch(int x, int y, int power, int angle);

int getPowerAngleFromPoint(int originX, int originY, int endX, int endY, int threshold, int olFlag);
int getPowerAngleFromPoint(int originX, int originY, int endX, int endY, int threshold);
int checkIfWaterState(int x, int y);
int checkIfWaterSquare(int x, int y);
int getUnitsWithinRadius(int x, int y, int radius);
int getLandingPoint(int x, int y, int power, int angle);
int getEnemyUnitsVisible(int playerNum);

float degToRad(float degrees);
void limitLocation(int &a, int &b, int c, int d);
int energyPoolSize(int pool);
int getMaxCollectors(int pool);

int getEnergyHogType();

extern Common::Array<int> lastXCoord[];
extern Common::Array<int> lastYCoord[];

} // End of namespace Scumm

#endif