aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-funcs.cpp65
-rw-r--r--engines/hdb/ai.h5
2 files changed, 69 insertions, 1 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index f3686ef2bb..ff336bc6bf 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -596,6 +596,71 @@ void AI::getEntityXY(const char *entName, int *x, int *y) {
}
}
+bool AI::useLuaEntity(const char *initName) {
+ AIEntity *e;
+
+ for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+ e = *it;
+ if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+ e->aiUse(e);
+ checkActionList(e, e->tileX, e->tileY, true);
+ if (e->luaFuncUse)
+ g_hdb->_lua->callFunction(e->luaFuncUse, 0);
+ return true;
+ }
+ }
+
+ // Check _actions list for activation as well
+ for (int i = 0; i < kMaxActions; i++) {
+ if (_actions[i].entityName && !scumm_stricmp(initName, _actions[i].entityName)) {
+ checkActionList(&_dummyPlayer, _actions[i].x1, _actions[i].y1, false);
+ checkActionList(&_dummyPlayer, _actions[i].x2, _actions[i].y2, false);
+ }
+ }
+
+ return false;
+}
+
+void AI::removeLuaEntity(const char *initName) {
+ AIEntity *e;
+
+ for (uint i = 0; i < _ents->size(); i++) {
+ e = *(_ents->begin() + i);
+ if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+ removeEntity(*(_ents->begin() + i));
+ i--;
+ }
+ }
+}
+
+void AI::animLuaEntity(const char *initName, AIState st) {
+ AIEntity *e;
+
+ for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+ e = *it;
+ if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+ e->state = st;
+ e->animFrame = 0;
+ e->animDelay = e->animCycle;
+ }
+ }
+}
+
+void AI::setLuaAnimFrame(const char *initName, AIState st, int frame) {
+ AIEntity *e;
+
+ for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) {
+ e = *it;
+ if (e->entityName && !scumm_stricmp(initName, e->entityName)) {
+ e->state = st;
+ e->animFrame = frame;
+ e->animDelay = e->animCycle;
+ animEntFrames(e);
+ e->state = STATE_NONE;
+ }
+ }
+}
+
void AI::removeEntity(AIEntity *e) {
_ents->erase(&e);
}
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index 27fcddfe50..ccd9aed42d 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -742,6 +742,10 @@ public:
AIEntity *findEntityIgnore(int x, int y, AIEntity *ignore);
AIEntity *findEntityType(AIType type, int x, int y);
void getEntityXY(const char *entName, int *x, int *y);
+ bool useLuaEntity(const char *initName);
+ void removeLuaEntity(const char *initName);
+ void animLuaEntity(const char *initName, AIState st);
+ void setLuaAnimFrame(const char *initName, AIState st, int frame);
void removeEntity(AIEntity *e);
void setEntityGoal(AIEntity *e, int x, int y);
void initAllEnts();
@@ -753,7 +757,6 @@ public:
void animateEntity(AIEntity *e);
void animEntFrames(AIEntity *e);
- void animLuaEntity(const char *initName, AIState st);
void drawEnts(int x, int y, int w, int h);
void drawLevel2Ents();
void animGrabbing();