Mercurial > mm7
changeset 1321:cc8d58f2bf0c
clickable_distance
author | Ritor1 |
---|---|
date | Fri, 28 Jun 2013 16:51:01 +0600 |
parents | 2e3deb510de3 |
children | 65d301bce717 e70fe5d77928 |
files | Viewport.cpp |
diffstat | 1 files changed, 366 insertions(+), 184 deletions(-) [+] |
line wrap: on
line diff
--- a/Viewport.cpp Fri Jun 28 11:34:15 2013 +0600 +++ b/Viewport.cpp Fri Jun 28 16:51:01 2013 +0600 @@ -255,39 +255,25 @@ { signed int v0; // ebx@2 POINT *v1; // esi@3 - signed int v2; // eax@9 - BLVFace *v3; // eax@10 - unsigned int v4; // eax@11 - unsigned __int16 v5; // dx@14 signed int v6; // eax@14 char *v7; // esi@15 - //int *v8; // eax@19 int v9; // eax@19 - unsigned int v10; // eax@19 - int v11; // ecx@21 - ODMFace *v12; // eax@22 - LevelDecoration *v13; // esi@24 - __int16 v14; // ax@25 + unsigned int pTextureID; // eax@19 + int pEventID; // ecx@21 int v15; // ecx@29 signed int v16; // edx@30 - Actor *v17; // esi@30 int v18; // ebx@47 - unsigned __int16 v19; // ax@50 - const char *v20; // eax@51 signed int v21; // eax@58 - ItemGen *v22; // esi@62 - unsigned int v23; // eax@62 SpriteObject a1; // [sp+Ch] [bp-80h]@1 - //POINT v25; // [sp+7Ch] [bp-10h]@3 POINT a2; // [sp+84h] [bp-8h]@3 + int clickable_distance = 512; + v1 = pMouse->GetCursorPos(&a2); if ( pRenderer->pRenderD3D ) v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); else - { v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; - } if ( PID_TYPE(v0) == OBJECT_Item) { @@ -296,221 +282,417 @@ if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID && (unsigned int)v0 < 0x2000000 ) { - v22 = &pSpriteObjects[v21].stru_24; - v23 = pSpriteObjects[v21].stru_24.uItemID; - if ( pItemsTable->pItems[v23].uEquipType == 18 ) + if ( pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].uEquipType == 18 ) { - party_finds_gold(v22->uSpecEnchantmentType, 0); + party_finds_gold(pSpriteObjects[v21].stru_24.uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else { - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].pUnidentifiedName); ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( v22->uItemID == 506 ) - _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); - if ( v22->uItemID == 455 ) - _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); - if ( !pParty->AddItem(v22) ) - pParty->SetHoldingItem(v22); + if ( pSpriteObjects[v21].stru_24.uItemID == 506 ) + _449B7E_toggle_bit(pParty->_quest_bits, 184, 1); + if ( pSpriteObjects[v21].stru_24.uItemID == 455 ) + _449B7E_toggle_bit(pParty->_quest_bits, 185, 1); + if ( !pParty->AddItem(&pSpriteObjects[v21].stru_24) ) + pParty->SetHoldingItem(&pSpriteObjects[v21].stru_24); } SpriteObject::OnInteraction(a2.y); return; } - v4 = pParty->pPickedItem.uItemID; if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; + return; + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; } - if ( PID_TYPE(v0) != OBJECT_Actor) + if ( PID_TYPE(v0) == OBJECT_Actor) { - if ( PID_TYPE(v0) == OBJECT_Decoration) + v16 = (signed int)(unsigned __int16)v0 >> 3; + a2.y = v16; + if ( pActors[v16].uAIState == 5 ) { - v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; - if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) - { - v4 = pParty->pPickedItem.uItemID; + if ( (unsigned int)v0 < 0x2000000 ) + { + stru_50C198.LootActor(&pActors[v16]); + return; + } + if ( !pParty->pPickedItem.uItemID ) + return; + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) + { + if ( !pActors[v16].GetActorsRelation(0) && !(BYTE2(pActors[v16].uAttributes) & 8) ) + { + if ( HIWORD(v0) >= clickable_distance) + { if ( !pParty->pPickedItem.uItemID ) return; - goto LABEL_14; - } - v14 = v13->field_16_event_id; - if ( !v14 ) - { - if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + if ( !pActors[v16].CanAct() ) + return; + v18 = a2.y; + Actor::AI_FaceObject(a2.y, 4, 0, 0); + if ( !pActors[v16].sNPC_ID ) { - v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; - activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; - EventProcessor(v15, 0, 1); - activeLevelDecoration = NULL; + if ( pNPCStats->pGroups_copy[pActors[v16].uGroup] ) + { + if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]] ) + { + pParty->uFlags |= 2u; + strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]]); + sub_4451A8_press_any_key(0, 0, 0); + } + } + return; } + pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); return; } - v11 = v14; + if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) + { + pTurnEngine->field_18 |= 8; + return; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); } else { - if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 ) - { - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - v2 = PID_ID(v0); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) { - v3 = &pIndoor->pFaces[v2]; - if ( !(v3->uAttributes & 0x2000000) ) - { -LABEL_11: - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - { - ShowNothingHereStatus(); - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - } -LABEL_14: - v5 = pItemsTable->pItems[v4].uSpriteID; - v6 = 0; - a1.uType = v5; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - LOWORD(v6) = 0; - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - { - LOWORD(v6) = 0; - break; - } - } - } - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.spell_caster_pid = OBJECT_Player; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); - - extern int UnprojectX(int); - v9 = UnprojectX(v1->x); - a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); - if (v10 != -1) - pIcons_LOD->pTextures[v10].Release(); - pMouse->RemoveHoldingItem(); - pIcons_LOD->SyncLoadedFilesCount(); - return; - } - v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; + pParty->uFlags |= PARTY_FLAGS_1_FALLING; + return; } - else - { - v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F]; - if ( !v12->Clickable()) - goto LABEL_11; - v11 = v12->sCogTriggeredID; - } + if ( uActiveCharacter && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) + pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); } - EventProcessor(v11, (unsigned __int16)v0, 1); return; } - v16 = (signed int)(unsigned __int16)v0 >> 3; - a2.y = v16; - v17 = &pActors[v16]; - if ( v17->uAIState == 5 ) + if ( PID_TYPE(v0) == OBJECT_Decoration) { - if ( (unsigned int)v0 < 0x2000000 ) + if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uDecorationDescID].uRadius) >= clickable_distance ) { - stru_50C198.LootActor(&pActors[v16]); + if ( !pParty->pPickedItem.uItemID ) + return; + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); return; } - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; + if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id ) + { + if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) + { + v15 = stru_5E4C90._decor_events[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]._idx_in_stru123 - 75] + 380; + activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; + EventProcessor(v15, 0, 1); + activeLevelDecoration = NULL; + } + return; + } + pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id; } - if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) + if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance) { - if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { - if ( HIWORD(v0) >= 512) - { - v4 = pParty->pPickedItem.uItemID; + if ( !(pIndoor->pFaces[PID_ID(v0)].uAttributes & 0x2000000) ) + { + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); if ( !pParty->pPickedItem.uItemID ) return; - goto LABEL_14; - } - if ( !v17->CanAct() ) - return; - v18 = a2.y; - Actor::AI_FaceObject(a2.y, 4u, 0, 0); - if ( !v17->sNPC_ID ) - { - v19 = pNPCStats->pGroups_copy[v17->uGroup]; - if ( v19 ) + } + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else { - v20 = pNPCStats->pCatchPhrases[v19]; - if ( v20 ) + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) { - pParty->uFlags |= 2u; - strcpy(byte_5B0938.data(), v20); - sub_4451A8_press_any_key(0, 0, 0); + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } } } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); return; } - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) - return; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; -LABEL_42: - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - return;*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); - return; + pEventID = pIndoor->pFaceExtras[pIndoor->pFaces[PID_ID(v0)].uFaceExtraID].uEventID; } - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) - { - pTurnEngine->field_18 |= 8u; - return; - } - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; - goto LABEL_41; - }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); + if ( !pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].Clickable()) + { + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); + if ( !pParty->pPickedItem.uItemID ) + return; + } + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + pEventID = pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].sCogTriggeredID; + } + EventProcessor(pEventID, (unsigned __int16)v0, 1); + return; } - else + if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= clickable_distance ) { - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) - { - pParty->uFlags |= PARTY_FLAGS_1_FALLING; + if ( !pParty->pPickedItem.uItemID ) return; - } - if ( uActiveCharacter - && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else { - pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); - /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell; -LABEL_41: - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - goto LABEL_42;*/ + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; } }