void PlayerInventoryHud::dropEntity() { if(!(player.Interface & INTER_INVENTORY) && !(player.Interface & INTER_INVENTORYALL)) return; if(InventoryY != 0) return; if(!g_playerInventoryHud.containsPos(DANAEMouse)) return; Vec2s s = DRAGINTER->m_inventorySize; int bag = 0; Vec2f anchorPos = g_playerInventoryHud.anchorPosition(); float fCenterX = anchorPos.x; float fSizY = anchorPos.y; short iPosX = checked_range_cast<short>(fCenterX); short iPosY = checked_range_cast<short>(fSizY); Vec2s t = Vec2s_ZERO; if(player.Interface & INTER_INVENTORY) { t.x = DANAEMouse.x - iPosX; t.y = DANAEMouse.y - iPosY; t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); if((t.x >= 0) && (t.x <= 16 - s.x) && (t.y >= 0) && (t.y <= 3 - s.y)) { bag = g_currentInventoryBag; } else { return; } } else { bool bOk = false; float fBag = (player.bag - 1) * (-121 * m_scale); short iY = checked_range_cast<short>(fBag); //We must enter the for-loop to initialyze tx/ty arx_assert(0 < player.bag); for(int i = 0; i < player.bag; i++) { t.x = DANAEMouse.x - iPosX; t.y = DANAEMouse.y - iPosY - iY; if((t.x >= 0) && (t.y >= 0)) { t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); if((t.x >= 0) && (t.x <= 16 - s.x) && (t.y >= 0) && (t.y <= 3 - s.y)) { bOk = true; bag = i; break; } } float fRatio = (121 * m_scale); iY += checked_range_cast<short>(fRatio); } if(!bOk) return; } if(DRAGINTER->ioflags & IO_GOLD) { ARX_PLAYER_AddGold(DRAGINTER); Set_DragInter(NULL); return; } for(long j = 0; j < s.y; j++) for(long i = 0; i < s.x; i++) { Entity * ioo = inventory[bag][t.x+i][t.y+j].io; if(!ioo) continue; ARX_INVENTORY_IdentifyIO(ioo); if( ioo->_itemdata->playerstacksize > 1 && IsSameObject(DRAGINTER, ioo) && ioo->_itemdata->count < ioo->_itemdata->playerstacksize ) { ioo->_itemdata->count += DRAGINTER->_itemdata->count; if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) { DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize; ioo->_itemdata->count = ioo->_itemdata->playerstacksize; } else { DRAGINTER->_itemdata->count = 0; } ioo->scale = 1.f; ARX_INVENTORY_Declare_InventoryIn(DRAGINTER); if(!DRAGINTER->_itemdata->count) { DRAGINTER->destroy(); } ARX_SOUND_PlayInterface(SND_INVSTD); return; } return; } for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { inventory[bag][t.x+i][t.y+j].io = DRAGINTER; inventory[bag][t.x+i][t.y+j].show = false; } } inventory[bag][t.x][t.y].show = true; ARX_INVENTORY_Declare_InventoryIn(DRAGINTER); ARX_SOUND_PlayInterface(SND_INVSTD); DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; Set_DragInter(NULL); }
void SecondaryInventoryHud::dropEntity() { // First Look for Identical Item... if(SecondaryInventory && g_secondaryInventoryHud.containsPos(DANAEMouse)) { Entity * io = SecondaryInventory->io; float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; //>>1; long price = checked_range_cast<long>(fprice); price *= DRAGINTER->_itemdata->count; fprice = price + price * player.m_skillFull.intuition * 0.005f; price = checked_range_cast<long>(fprice); // SHOP if(io->ioflags & IO_SHOP) { if(!io->shop_category.empty() && DRAGINTER->groups.find(io->shop_category) == DRAGINTER->groups.end()) return; if(price <= 0) return; // Check shop group for(long j = 0; j < SecondaryInventory->m_size.y; j++) { for(long i = 0; i < SecondaryInventory->m_size.x; i++) { Entity * ioo = SecondaryInventory->slot[i][j].io; if(!ioo || !IsSameObject(DRAGINTER, ioo)) continue; ioo->_itemdata->count += DRAGINTER->_itemdata->count; ioo->scale = 1.f; DRAGINTER->destroy(); ARX_PLAYER_AddGold(price); ARX_SOUND_PlayInterface(SND_GOLD); ARX_SOUND_PlayInterface(SND_INVSTD); return; } } } Vec2s t = Vec2s_ZERO; t.x = DANAEMouse.x + static_cast<short>(m_fadePosition) - (2 * m_scale); t.y = DANAEMouse.y - (13 * m_scale); t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); Vec2s s = DRAGINTER->m_inventorySize; if(t.x <= SecondaryInventory->m_size.x - s.x && t.y <= SecondaryInventory->m_size.y - s.y) { float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; long price = checked_range_cast<long>(fprice); price *= DRAGINTER->_itemdata->count; fprice = price + price * player.m_skillFull.intuition * 0.005f; price = checked_range_cast<long>(fprice); for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { Entity * ioo = SecondaryInventory->slot[t.x+i][t.y+j].io; if(!ioo) continue; DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; if( ioo->_itemdata->playerstacksize > 1 && IsSameObject(DRAGINTER, ioo) && ioo->_itemdata->count < ioo->_itemdata->playerstacksize ) { ioo->_itemdata->count += DRAGINTER->_itemdata->count; if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) { DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize; ioo->_itemdata->count = ioo->_itemdata->playerstacksize; } else { DRAGINTER->_itemdata->count = 0; } } if(DRAGINTER->_itemdata->count) { if(CanBePutInSecondaryInventory(SecondaryInventory, DRAGINTER)) { // SHOP if(io->ioflags & IO_SHOP) { ARX_PLAYER_AddGold(price); ARX_SOUND_PlayInterface(SND_GOLD); } } else { return; } } ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(NULL); return; } } if(DRAGINTER->ioflags & IO_GOLD) { ARX_PLAYER_AddGold(DRAGINTER); Set_DragInter(NULL); return; } for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { SecondaryInventory->slot[t.x+i][t.y+j].io = DRAGINTER; SecondaryInventory->slot[t.x+i][t.y+j].show = false; } } // SHOP if(io->ioflags & IO_SHOP) { player.gold += price; ARX_SOUND_PlayInterface(SND_GOLD); } SecondaryInventory->slot[t.x][t.y].show = true; DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(NULL); return; } } }