void PlayerInventoryHud::dragEntity(Entity * io, const Vec2s &pos) { Vec2f anchorPos = g_playerInventoryHud.anchorPosition(); Vec2i iPos = Vec2i(anchorPos); if(g_playerInventoryHud.containsPos(pos)) { if(!GInput->actionPressed(CONTROLS_CUST_STEALTHMODE)) { if((io->ioflags & IO_ITEM) && io->_itemdata->count > 1) { if(io->_itemdata->count - 1 > 0) { Entity * ioo = AddItem(io->classPath()); ioo->show = SHOW_FLAG_NOT_DRAWN; ioo->_itemdata->count = 1; io->_itemdata->count--; ioo->scriptload = 1; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(ioo); RemoveFromAllInventories(ioo); sInventory = 1; float fX = (pos.x - iPos.x) / (32 * m_scale); float fY = (pos.y - iPos.y) / (32 * m_scale); sInventoryPos.x = checked_range_cast<short>(fX); sInventoryPos.y = checked_range_cast<short>(fY); SendInitScriptEvent(ioo); ARX_INVENTORY_IdentifyIO(ioo); return; } } } } arx_assert(player.bag >= 0); arx_assert(player.bag <= 3); for(size_t bag = 0; bag < size_t(player.bag); bag++) for(size_t y = 0; y < INVENTORY_Y; y++) for(size_t x = 0; x < INVENTORY_X; x++) { INVENTORY_SLOT & slot = inventory[bag][x][y]; if(slot.io == io) { slot.io = NULL; slot.show = true; sInventory = 1; float fX = (pos.x - iPos.x) / (32 * m_scale); float fY = (pos.y - iPos.y) / (32 * m_scale); sInventoryPos.x = checked_range_cast<short>(fX); sInventoryPos.y = checked_range_cast<short>(fY); } } Set_DragInter(io); RemoveFromAllInventories(io); ARX_INVENTORY_IdentifyIO(io); }
void ARX_EQUIPMENT_IdentifyAll() { arx_assert(entities.player()); for(size_t i = 0; i < MAX_EQUIPED; i++) { if(ValidIONum(player.equiped[i])) { Entity * toequip = entities[player.equiped[i]]; ARX_INVENTORY_IdentifyIO(toequip); } } }
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); }
bool SecondaryInventoryHud::dragEntity(Entity * io, const Vec2s & pos) { if(SecondaryInventory != NULL) { if(g_secondaryInventoryHud.containsPos(pos) && (io->ioflags & IO_ITEM)) { Entity * ioo = SecondaryInventory->io; if(ioo->ioflags & IO_SHOP) { long cos = ARX_INTERACTIVE_GetPrice(io, ioo); float fcos = cos - cos * player.m_skillFull.intuition * 0.005f; cos = checked_range_cast<long>(fcos); if(player.gold < cos) { return false; } ARX_SOUND_PlayInterface(SND_GOLD); player.gold -= cos; if(io->_itemdata->count > 1) { Entity * ioo = CloneIOItem(io); ioo->show = SHOW_FLAG_NOT_DRAWN; ioo->scriptload = 1; ioo->_itemdata->count = 1; io->_itemdata->count--; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(ioo); return true; } } else if(io->_itemdata->count > 1) { if(!GInput->actionPressed(CONTROLS_CUST_STEALTHMODE)) { Entity * ioo = CloneIOItem(io); ioo->show = SHOW_FLAG_NOT_DRAWN; ioo->scriptload = 1; ioo->_itemdata->count = 1; io->_itemdata->count--; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(ioo); sInventory = 2; Vec2f calc; calc.x = (pos.x + m_fadePosition - (2 * m_scale)) / (32 * m_scale); calc.y = (pos.y - (13 * m_scale)) / (32 * m_scale); sInventoryPos.x = checked_range_cast<short>(calc.x); sInventoryPos.y = checked_range_cast<short>(calc.y); //ARX_INVENTORY_Object_Out(SecondaryInventory->io, ioo); ARX_INVENTORY_IdentifyIO(ioo); return true; } } } for(long j = 0; j < SecondaryInventory->m_size.y; j++) for(long i = 0; i < SecondaryInventory->m_size.x; i++) { INVENTORY_SLOT & slot = SecondaryInventory->slot[i][j]; if(slot.io != io) continue; slot.io = NULL; slot.show = true; sInventory = 2; float fCalcX = (pos.x + m_fadePosition - (2 * m_scale)) / (32 * m_scale); float fCalcY = (pos.y - (13 * m_scale)) / (32 * m_scale); sInventoryPos.x = checked_range_cast<short>(fCalcX); sInventoryPos.y = checked_range_cast<short>(fCalcY); } } Set_DragInter(io); RemoveFromAllInventories(io); ARX_INVENTORY_IdentifyIO(io); return true; }