aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-funcs.cpp15
-rw-r--r--engines/hdb/ai.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 3a425beb76..d0888d3473 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -37,6 +37,21 @@ 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);
+ }
+ }
+ }
+}
+
// Check to see if we can get this entity
bool AI::getTableEnt(AIType type) {
switch (type) {
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index aaa8385fd5..8dcb34797f 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -413,6 +413,7 @@ public:
// Entity Functions
AIEntity *locateEntity(const char *luaName);
void removeEntity(AIEntity *e);
+ void initAllEnts();
bool getTableEnt(AIType type);
bool walkThroughEnt(AIType type);
void getItemSound(AIType type);