diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 04901d78fa6..44e2ec9639b 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -1731,18 +1731,32 @@ void PrinceEngine::leftMouseButton() { return; } else if (_selectedMode != 0) { //give_item - - } else { - if (_room->_itemUse == 0) { - //standard_useitem - //_script->_scriptInfo.stdUse; - } else { - debug("selectedMob: %d", _selectedMob); - int mobEvent = _script->scanMobEventsWithItem(_mobList[_selectedMob - 1]._mask, _room->_itemUse, _selectedItem); - if (mobEvent == -1) { - - } + int optionEvent = -1; + if (_room->_itemGive != 0) { + optionEvent = _script->scanMobEventsWithItem(_optionsMob, _room->_itemGive, _selectedItem); } + if (optionEvent == -1) { + //standard_giveitem + optionEvent = _script->_scriptInfo.stdGiveItem; + } + // eax <- return (int)READ_UINT16(&_data[optionEvent]); + // store_new_pc: + // storeNewPC(); + return; + } else { + int optionEvent = -1; + if (_room->_itemUse != 0) { + optionEvent = _script->scanMobEventsWithItem(_optionsMob, _room->_itemUse, _selectedItem); + _flags->setFlagValue(Flags::SELITEM, _selectedItem); + } + if (optionEvent == -1) { + //standard_useitem + optionEvent = _script->_scriptInfo.stdUseItem; + } + // eax <- return (int)READ_UINT16(&_data[optionEvent]); + // store_new_pc: + // storeNewPC(); + return; } } @@ -2043,6 +2057,8 @@ void PrinceEngine::displayInventory() { _mainHero->_inventory.push_back(44); _mainHero->_inventory.push_back(67); + _mainHero->_inventory.push_back(8); + prepareInventoryToView(); while (!shouldQuit()) { diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 4122b3898e9..461dbb12df0 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -218,7 +218,6 @@ int Script::scanMobEvents(int mobMask, int dataEventOffset) { mob = (int)READ_UINT16(&_data[dataEventOffset + i * 6]); if (mob == mobMask) { code = (int)READ_UINT32(&_data[dataEventOffset + i * 6 + 2]); - debug("mob: %d", mob); debug("code: %d", code); return code; } @@ -227,7 +226,7 @@ int Script::scanMobEvents(int mobMask, int dataEventOffset) { return -1; } -int Script::scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemNr) { +int Script::scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemMask) { debug("mobMask: %d", mobMask); int i = 0; int16 mob; @@ -237,10 +236,9 @@ int Script::scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemNr) mob = (int)READ_UINT16(&_data[dataEventOffset + i * 8]); if (mob == mobMask) { item = (int)READ_UINT16(&_data[dataEventOffset + i * 8 + 2]); - if (item == itemNr) { + if (item == itemMask) { code = (int)READ_UINT32(&_data[dataEventOffset + i * 8 + 4]); - debug("mob: %d", mob); - debug("item: %d", item); + debug("itemMask: %d", item); debug("code: %d", code); return code; } diff --git a/engines/prince/script.h b/engines/prince/script.h index 5cdf9c64baa..28e3be4ebc7 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -141,7 +141,7 @@ public: bool loadAllMasks(Common::Array &maskList, int offset); int scanMobEvents(int mobMask, int dataEventOffset); - int scanMobEventsWithItem(int mobMask, int dataEventOffset, int item); + int scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemMask); const char *getString(uint32 offset) { return (const char *)(&_data[offset]);