PRINCE: LMB outside inventory - give / use item

This commit is contained in:
lukaslw 2014-06-24 05:03:36 +02:00
parent a319f473f6
commit 9a13423829
3 changed files with 31 additions and 17 deletions

View File

@ -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()) {

View File

@ -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;
}

View File

@ -141,7 +141,7 @@ public:
bool loadAllMasks(Common::Array<Mask> &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]);