diff options
author | Nipun Garg | 2019-06-27 07:10:57 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:02 +0200 |
commit | 0f313f3eda614b828574e62fbca66a1eb3b9fb71 (patch) | |
tree | 4c81407e03d3bc2fd2bc48742c8729919248fcce /engines/hdb | |
parent | 368e80c75f157da79747d2166502d97215b7b5bc (diff) | |
download | scummvm-rg350-0f313f3eda614b828574e62fbca66a1eb3b9fb71.tar.gz scummvm-rg350-0f313f3eda614b828574e62fbca66a1eb3b9fb71.tar.bz2 scummvm-rg350-0f313f3eda614b828574e62fbca66a1eb3b9fb71.zip |
HDB: Add functions related to _triggerList
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/ai-lists.cpp | 55 | ||||
-rw-r--r-- | engines/hdb/ai.h | 3 |
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); |