aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hdb')
-rw-r--r--engines/hdb/ai-lists.cpp55
-rw-r--r--engines/hdb/ai.h3
2 files changed, 58 insertions, 0 deletions
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 3d1e235740..207e51f2be 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -623,4 +623,59 @@ ArrowPath *AI::findArrowPath(int x, int y) {
return NULL;
}
+void AI::addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id) {
+ Trigger *t = new Trigger;
+
+ strcpy(t->id, id);
+ t->x = x;
+ t->y = y;
+ t->value1 = value1;
+ t->value2 = value2;
+ if (luaFuncInit[0] != '*')
+ strcpy(t->luaFuncInit, luaFuncInit);
+ if (luaFuncUse[0] != '*')
+ strcpy(t->luaFuncUse, luaFuncUse);
+
+ if (!t->luaFuncUse[0])
+ warning("STUB: addToTriggerList: Open MessageBar");
+
+ if (t->luaFuncInit[0]) {
+ g_hdb->_lua->pushFunction(t->luaFuncInit);
+ g_hdb->_lua->pushInt(x);
+ g_hdb->_lua->pushInt(y);
+ g_hdb->_lua->pushInt(value1);
+ g_hdb->_lua->pushInt(value2);
+ g_hdb->_lua->call(4, 0);
+ }
+}
+
+bool AI::checkTriggerList(char *entName, int x, int y) {
+ Trigger *t;
+
+ for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
+ if (t->x == x && t->y == y) {
+ if (!t->luaFuncUse[0])
+ return false;
+
+ g_hdb->_lua->pushFunction(t->luaFuncUse);
+ g_hdb->_lua->pushString(entName);
+ g_hdb->_lua->pushInt(t->x);
+ g_hdb->_lua->pushInt(t->y);
+ g_hdb->_lua->pushInt(t->value1);
+ g_hdb->_lua->pushInt(t->value2);
+ g_hdb->_lua->call(5, 0);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void AI::killTrigger(char *id) {
+ for (Common::Array<Trigger *>::iterator it = _triggerList->begin(); it != _triggerList->end(); it++) {
+ if (!scumm_stricmp(id, (*it)->id))
+ _triggerList->erase(it);
+ }
+}
+
} // End of Namespace
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 7a33e42547..bf0a9bc3a7 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -718,6 +718,9 @@ public:
bool findTeleporterDest(int tileX, int tileY, SingleTele *info);
void addToPathList(int x, int y, int type, AIDir dir);
ArrowPath *findArrowPath(int x, int y);
+ void addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id);
+ bool checkTriggerList(char *entName, int x, int y);
+ void killTrigger(char *id);
void floatEntity(AIEntity *e, AIState state);
bool checkFloating(int x, int y);