aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-06-27 07:41:53 +0530
committerEugene Sandulenko2019-09-03 17:17:02 +0200
commit0f4e637e2a1710b20bb535a6dca63e125695e624 (patch)
tree463acc77e0984b4c072122c794b199d957967211 /engines
parent86f7991eba8787a4e65758edd389982efbc749b0 (diff)
downloadscummvm-rg350-0f4e637e2a1710b20bb535a6dca63e125695e624.tar.gz
scummvm-rg350-0f4e637e2a1710b20bb535a6dca63e125695e624.tar.bz2
scummvm-rg350-0f4e637e2a1710b20bb535a6dca63e125695e624.zip
HDB: Add _luaList functions
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-lists.cpp56
-rw-r--r--engines/hdb/ai.h3
2 files changed, 59 insertions, 0 deletions
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index 207e51f2be..cb66ca2592 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -434,6 +434,62 @@ bool AI::autoActive(int x, int y) {
return false;
}
+void AI::addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse) {
+ for (int i = 0; i < kMaxLuaEnts; i++) {
+ if (!_luaList[i].luaFuncInit[0] && !_luaList[i].luaFuncAction[0] && !_luaList[i].luaFuncUse[0]) {
+ _luaList[i].x = x;
+ _luaList[i].y = y;
+ _luaList[i].value1 = value1;
+ _luaList[i].value2 = value2;
+
+ strcpy(_luaList[i].luaFuncInit, luaFuncInit);
+ if (luaFuncInit[0] == '*')
+ _luaList[i].luaFuncInit[0] = 0;
+ strcpy(_luaList[i].luaFuncAction, luaFuncAction);
+ if (luaFuncAction[0] == '*')
+ _luaList[i].luaFuncAction[0] = 0;
+ strcpy(_luaList[i].luaFuncUse, luaFuncUse);
+ if (luaFuncUse[0] == '*')
+ _luaList[i].luaFuncUse[0] = 0;
+
+ _numLuaList++;
+ if (_luaList[i].luaFuncInit[0])
+ g_hdb->_lua->invokeLuaFunction(luaFuncInit, x, y, value1, value2);
+
+ spawnBlocking(x, y, 1);
+
+ return;
+ }
+ }
+}
+
+bool AI::checkLuaList(AIEntity *e, int x, int y) {
+ for (int i = 0;i < _numLuaList; i++) {
+ if (_luaList[i].x == x && _luaList[i].y == y && _luaList[i].luaFuncUse[0]) {
+ if (e == _player) {
+ lookAtXY(x, y);
+ animGrabbing();
+ }
+
+ g_hdb->_lua->invokeLuaFunction(_luaList[i].luaFuncUse, _luaList[i].x, _luaList[i].y, _luaList[i].value1, _luaList[i].value2);
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool AI::luaExistAtXY(int x, int y) {
+ for (int i = 0;i < _numLuaList; i++) {
+ if (_luaList[i].x == x && _luaList[i].y == y && _luaList[i].luaFuncUse[0]) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse) {
if (!level)
level = 1;
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index c76b6d6307..1bcf757b10 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -725,6 +725,9 @@ public:
bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
bool checkAutoList(AIEntity *e, int x, int y);
bool autoActive(int x, int y);
+ void addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse);
+ bool checkLuaList(AIEntity *e, int x, int y);
+ bool luaExistAtXY(int x, int y);
void addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse);
bool checkTeleportList(AIEntity *e, int x, int y);
bool findTeleporterDest(int tileX, int tileY, SingleTele *info);