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
|
/* 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.
*
*/
#include "hdb/hdb.h"
namespace HDB {
AIEntity *AI::locateEntity(const char *luaName) {
for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
if (Common::matchString((*it)->entityName, luaName)) {
return *it;
}
}
return NULL;
}
void AI::removeEntity(AIEntity *e) {
_ents->erase(&e);
}
// Initializes each entity after map is loaded
void AI::initAllEnts() {
for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
(*it)->aiInit((*it));
if ((*it)->luaFuncInit[0]) {
if (g_hdb->_lua->callFunction((*it)->luaFuncInit, 2)) {
strcpy((*it)->entityName, g_hdb->_lua->getStringOffStack());
strcpy((*it)->printedName, g_hdb->_lua->getStringOffStack());
} else {
warning("'%s' doesn't exists", (*it)->luaFuncInit);
}
}
}
warning("STUB: initAllEnts: Cache graphics for Inventory and Deliveries");
warning("STUB: initAllEnts: LaserScan required");
}
// Check to see if we can get this entity
bool AI::getTableEnt(AIType type) {
switch (type) {
case ITEM_CELL:
case ITEM_ENV_WHITE:
case ITEM_ENV_RED:
case ITEM_ENV_BLUE:
case ITEM_ENV_GREEN:
case ITEM_TRANSCEIVER:
case ITEM_CLUB:
case ITEM_ROBOSTUNNER:
case ITEM_SLUGSLINGER:
case ITEM_MONKEYSTONE:
case ITEM_GOO_CUP:
case ITEM_TEACUP:
case ITEM_BURGER:
case ITEM_PDA:
case ITEM_BOOK:
case ITEM_CLIPBOARD:
case ITEM_NOTE:
case ITEM_KEYCARD_WHITE:
case ITEM_KEYCARD_BLUE:
case ITEM_KEYCARD_RED:
case ITEM_KEYCARD_GREEN:
case ITEM_KEYCARD_PURPLE:
case ITEM_KEYCARD_BLACK:
case ITEM_SEED:
case ITEM_SODA:
case ITEM_SLICER:
case ITEM_DOLLYTOOL1:
case ITEM_DOLLYTOOL2:
case ITEM_DOLLYTOOL3:
case ITEM_DOLLYTOOL4:
return true;
default:
return false;
}
}
// Check to see if it's okay to move through this entity
bool AI::walkThroughEnt(AIType type) {
switch (type) {
case AI_VORTEXIAN:
case AI_MEERKAT:
case AI_GOODFAIRY:
case AI_BADFAIRY:
case AI_GATEPUDDLE:
case AI_BUZZFLY:
case AI_OMNIBOT:
case AI_PUSHBOT:
case AI_TURNBOT:
case AI_RIGHTBOT:
case ITEM_GEM_WHITE:
case ITEM_GEM_BLUE:
case ITEM_GEM_RED:
case ITEM_GEM_GREEN:
return true;
default:
return getTableEnt(type);
}
}
// Play special sound for every item you get
void AI::getItemSound(AIType type) {
warning("STUB: AI: getItemSound required");
}
void AI::lookAtEntity(AIEntity *e) {
lookAtXY(e->tileX, e->tileY);
}
// Change player direction to XY
void AI::lookAtXY(int x, int y) {
int distX, distY;
distX = abs(_player->tileX - x);
distY = abs(_player->tileY - y);
if (distX > distY) {
// X takes precedence
if (x < _player->tileX) {
_player->dir = DIR_LEFT;
} else if (x > _player->tileX) {
_player->dir = DIR_RIGHT;
} else if (y < _player->tileY) {
_player->dir = DIR_UP;
} else {
_player->dir = DIR_DOWN;
}
} else {
// Y takes precedence
if (y < _player->tileY) {
_player->dir = DIR_UP;
} else if (y > _player->tileY) {
_player->dir = DIR_DOWN;
} else if (x < _player->tileX) {
_player->dir = DIR_LEFT;
} else {
_player->dir = DIR_RIGHT;
}
}
switch (_player->dir) {
case DIR_UP:
_player->state = STATE_STANDUP;
warning("STUB: Set _player->draw to Player standup_gfx");
break;
case DIR_DOWN:
_player->state = STATE_STANDDOWN;
warning("STUB: Set _player->draw to Player standdown_gfx");
break;
case DIR_LEFT:
_player->state = STATE_STANDLEFT;
warning("STUB: Set _player->draw to Player standleft_gfx");
break;
case DIR_RIGHT:
_player->state = STATE_STANDRIGHT;
warning("STUB: Set _player->draw to Player standright_gfx");
break;
}
}
} // End of Namespace
|