diff options
author | Nipun Garg | 2019-07-03 21:39:05 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:09 +0200 |
commit | c2c639cfc4de7860cf014f91edbc376513b86443 (patch) | |
tree | c668bb04a6a3021c8e28032e3d2ca41497ca9d79 /engines/hdb/ai-use.cpp | |
parent | e3ceb4dfbde8ccf9d0b5b9a584892d6b202f63f3 (diff) | |
download | scummvm-rg350-c2c639cfc4de7860cf014f91edbc376513b86443.tar.gz scummvm-rg350-c2c639cfc4de7860cf014f91edbc376513b86443.tar.bz2 scummvm-rg350-c2c639cfc4de7860cf014f91edbc376513b86443.zip |
HDB: Add Cell Holder function
Diffstat (limited to 'engines/hdb/ai-use.cpp')
-rw-r--r-- | engines/hdb/ai-use.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp index fdbaaaf0fd..e2b3f9ae11 100644 --- a/engines/hdb/ai-use.cpp +++ b/engines/hdb/ai-use.cpp @@ -198,7 +198,29 @@ bool AI::useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, // Purple Cell Holder Switch bool AI::useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY) { - warning("STUB: Define useCellHolder"); + // is the PLAYER next to this thing? No other entities are allowed to unlock anything! + if (abs(x - _player->tileX) > 1 || abs(y - _player->tileY) > 1) + return false; + + int amount = queryInventoryType(ITEM_CELL); + int worked; + bool rtn; + + if (amount) { + rtn = useTarget(x, y, targetX, targetY, _useHolderFull, &worked); + if (worked) { + removeInvItemType(ITEM_CELL, 1); + if (g_hdb->_map->onScreen(x, y)) + g_hdb->_sound->playSound(SND_SWITCH_USE); + } + return rtn; + } else { + if (g_hdb->_map->onScreen(x, y)) + g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT); + } + + g_hdb->_window->openDialog("Locked!", -1, "I can't use that unless I have an Energy Cell.", 0, NULL); + g_hdb->_sound->playVoice(GUY_ENERGY_CELL, 0); return false; } |