Mercurial > mm7
view UI/UIShops.cpp @ 1327:8433de6fd7d0
Слияние
author | Ritor1 |
---|---|
date | Mon, 01 Jul 2013 09:26:35 +0600 |
parents | bedc304ab617 |
children | b51332ab228f |
line wrap: on
line source
#include "..\Items.h" #include "..\GUIWindow.h" #include "..\mm7_data.h" #include "..\texts.h" #include "UIHouses.h" #include "..\GUIFont.h" #include "..\Render.h" #include "..\Party.h" #include "..\Texture.h" #include "..\Mouse.h" #include "..\Events2D.h" #include "..\AudioPlayer.h" #include "..\MapInfo.h" #include "..\Viewport.h" //----- (004B910F) -------------------------------------------------------- void __cdecl WeaponShopDialog() { int v0; // ebx@1 int pNumActiveItem; // eax@6 signed int v2; // esi@8 ItemGen *v4; // eax@11 char *v5; // ecx@12 unsigned __int8 v6; // dl@13 char *v7; // edx@14 int v9; // ST08_4@16 int v10; // eax@16 signed int v11; // esi@18 int v12; // ST08_4@21 int v13; // eax@21 int v14; // edi@23 char **v15; // esi@23 int v16; // eax@24 //int v18; // edx@25 int v19; // edi@25 unsigned __int8 v20; // sf@25 GUIButton *pButton; // esi@27 int pNewItem; // eax@27 unsigned int v24; // ecx@27 int v25; // edx@27 unsigned int pColorText; // ax@27 signed int v27; // esi@32 int v28; // ST08_4@36 int v29; // eax@36 signed int v32; // esi@41 unsigned int v33; // esi@43 int v34; // eax@43 unsigned int v35; // eax@44 int v36; // eax@46 __int32 v37; // ecx@51 int v40; // eax@53 char *v41; // eax@55 unsigned int v43; // ecx@55 const char **v44; // edx@55 int v45; // eax@55 int v47; // eax@59 const char **v48; // eax@63 unsigned int v49; // esi@65 Texture *v50; // eax@65 int v51; // edi@65 int v52; // esi@70 Texture *v53; // ST1C_4@70 int v54; // edi@70 signed int v55; // ecx@73 SHORT v56; // di@82 bool v57; // eax@82 const char *v58; // ecx@84 POINT *v59; // esi@89 LONG v60; // ecx@90 int v61; // eax@90 int v62; // ecx@90 ItemGen *pItemInShop; // esi@90 int v64; // eax@95 int all_text_height; // esi@96 char **v66; // edi@96 int v67; // eax@97 int v69; // edx@98 int v70; // edi@98 int v71; const char **v72; // eax@100 int pTextHeight; // eax@100 unsigned int v74; // ecx@100 int v78; // [sp-14h] [bp-10Ch]@14 ItemGen *v79; // [sp-10h] [bp-108h]@12 int v80; // [sp-10h] [bp-108h]@14 void *v81; // [sp-Ch] [bp-104h]@12 unsigned __int16 v82; // [sp-Ch] [bp-104h]@14 int v83; // [sp-8h] [bp-100h]@11 char *v84; // [sp-8h] [bp-100h]@14 __int64 *v85; // [sp-4h] [bp-FCh]@11 unsigned int v86; // [sp-4h] [bp-FCh]@14 POINT v87; // [sp+Ch] [bp-ECh]@8 POINT v88; // [sp+14h] [bp-E4h]@18 POINT v89; // [sp+1Ch] [bp-DCh]@89 POINT v90; // [sp+24h] [bp-D4h]@19 POINT v91; // [sp+2Ch] [bp-CCh]@89 POINT v92; // [sp+34h] [bp-C4h]@9 POINT v93; // [sp+3Ch] [bp-BCh]@33 POINT v94; // [sp+44h] [bp-B4h]@18 POINT v95; // [sp+4Ch] [bp-ACh]@32 POINT v96; // [sp+54h] [bp-A4h]@18 POINT v97; // [sp+5Ch] [bp-9Ch]@32 POINT a2; // [sp+64h] [bp-94h]@8 POINT v99; // [sp+6Ch] [bp-8Ch]@32 POINT v100; // [sp+74h] [bp-84h]@8 GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 char *Str; // [sp+D0h] [bp-28h]@55 __int32 v103; // [sp+D4h] [bp-24h]@25 int pColorYellow; // [sp+D8h] [bp-20h]@1 int pColorWhite; // [sp+DCh] [bp-1Ch]@1 POINT v106; // [sp+E0h] [bp-18h]@8 Player *pPlayer; // [sp+E8h] [bp-10h]@1 int pItemNum; // [sp+ECh] [bp-Ch]@26 const char **v109; // [sp+F0h] [bp-8h]@26 unsigned __int8 v110; // [sp+F7h] [bp-1h]@16 int pNumString; pPlayer = pPlayers[uActiveCharacter]; memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; dialog_window.uFrameZ = 334; pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u); switch(dialog_menu_id) { case HOUSE_DIALOGUE_MAIN: { pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); if ( pNumActiveItem ) { pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; all_text_height = 0; for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 ); all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); v103 = (174 - all_text_height) / 4; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; v20 = -pDialogueWindow->pNumPresenceButton < 0; if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )) { pItemNum = 2; pNumString = 0; do { pButton = pDialogueWindow->GetControl(pItemNum); pButton->uY = v103 + v19; pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v19 = pButton->uY + pTextHeight - 1; pButton->uW = v19; pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); ++pItemNum; ++pNumString; pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } while ( pItemNum < pNumActiveItem ); } } break; } case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v48 = 0; pItemNum = 0; v109 = 0; do { // if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] ) if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID) { v49 = word_F8B158[(signed int)v48]; v50 = ItemsInShopTexture[(signed int)v48]; v49 += 30; v51 = 60 - ((signed int)v50->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v51 + pItemNum, v49, v50); sub_40F92A(&pRenderer->pActiveZBuffer[v51 + pItemNum + 640 * v49], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1)); v48 = v109; } pItemNum += 70; v48 = (const char **)((char *)v48 + 1); v109 = v48; } while ( (signed int)v48 < 6 ); pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); if ( pNumActiveItem ) { v55 = 0; v106.x = 0; v106.x = 0; do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v106.x; ++v55; } while ( v55 < 6 ); v56 = GetAsyncKeyState(17); v57 = pPlayer->CanSteal(); Str = (char *)v57; if ( v56 && v57 ) { v58 = pGlobalTXT_LocalizationStrings[185]; } else { v58 = pGlobalTXT_LocalizationStrings[195]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v58 = pGlobalTXT_LocalizationStrings[196]; } DrawTextAtStatusBar(v58, 0); if ( v106.x ) { v59 = pMouse->GetCursorPos(&v91); pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]; if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) { v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; v106.x = v60; v61 = (int)window_SpeakInHouse->ptr_1C;//maybe ptr_1C - BuildID_2Events // v62 = 9 * (v60 + 12 * v61); pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; if ( !v56 || !Str ) { v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } } } else { dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); pNumActiveItem = 0; //added } } break; } case HOUSE_DIALOGUE_SHOP_SELL: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; if((v11 = pMouse->GetCursorPos(&v96)->x - 14, v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5), pMouse->GetCursorPos(&v94)->x <= 13) || pMouse->GetCursorPos(&v90)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; v79 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); break; } case HOUSE_DIALOGUE_SHOP_IDENTIFY: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; if((v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5), pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; if (!v4->Identified()) { v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } break; } case HOUSE_DIALOGUE_SHOP_REPAIR: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) return; if( (v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5), pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) ) return; v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3); return; } break; case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];//sell pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];//identify pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];//repair all_text_height = 0; for ( int i = 0; i < 3; ++i ) all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); v103 = (174 - all_text_height) / 3; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v70 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138; v20 = -pDialogueWindow->pNumPresenceButton < 0; if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )) { pItemNum = 2; pNumString = 0; do { pButton = pDialogueWindow->GetControl(pItemNum); pButton->uY = v103 + v70; pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v70 = pButton->uY + pTextHeight - 1; pButton->uW = v70; pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); ++pItemNum; ++pNumString; pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } while ( pItemNum < pNumActiveItem ); } break; } case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v109 = 0; pItemNum = 0; do { // if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] ) if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID) { v52 = word_F8B158[(signed int)v109] + 30; v53 = ItemsInShopTexture[(signed int)v109]; v54 = 60 - ((signed int)v53->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v54 + pItemNum, word_F8B158[(signed int)v109] + 30, v53); sub_40F92A(&pRenderer->pActiveZBuffer[v54 + pItemNum + 640 * v52], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1)); } v109 = (const char **)((char *)v109 + 1); pItemNum += 70; } while ( (signed int)v109 < 6 ); pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); if ( pNumActiveItem ) { v55 = 0; v106.x = 0; do { // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID) ++v106.x; ++v55; } while ( v55 < 6 ); v56 = GetAsyncKeyState(17); v57 = pPlayer->CanSteal(); Str = (char *)v57; if ( v56 && v57 ) { v58 = pGlobalTXT_LocalizationStrings[185]; } else { v58 = pGlobalTXT_LocalizationStrings[195]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v58 = pGlobalTXT_LocalizationStrings[196]; } DrawTextAtStatusBar(v58, 0); if ( v106.x ) { v59 = pMouse->GetCursorPos(&v91); pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]; if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) { v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; v106.x = v60; v61 = (int)window_SpeakInHouse->ptr_1C; // v62 = 9 * (v60 + 12 * v61); pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } } } else { dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); pNumActiveItem = 0; //added } } break; } case HOUSE_DIALOGUE_LEARN_SKILLS: { if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) return; v0 = 0; all_text_height = 0; //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0); v32 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); pItemNum = v32 * (100 - pPlayer->GetMerchant()) / 100; if ( pItemNum < v32 / 3 ) pItemNum = v32 / 3; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); return; } do { v35 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v35] && !pPlayer->pActiveSkills[v35] ) { all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v35], &dialog_window, 0, 0); v0++; } ++pNumActiveItem; } while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); if ( !v0 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); return; } sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum); dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); v103 = (149 - all_text_height) / v0; if ( (149 - all_text_height) / v0 > 32 ) v103 = 32; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v37 = (149 - v0 * v103 - all_text_height) / 2 - v103 / 2 + 162; if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) { pItemNum = 2; do { pButton = pDialogueWindow->GetControl(pItemNum); v40 = pButton->msg_param - 36; if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v40] || pPlayer->pActiveSkills[v40] ) { pButton->uW = 0; pButton->uHeight = 0; pButton->uY = 0; } else { pButton->uY = v103 + v37; pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v40], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v37 = pButton->uY + pTextHeight - 1; pButton->uW = v37; pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v40], 3); } pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; pItemNum++; } while ( pItemNum < pNumActiveItem ); } break; } default: { if( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR) pNumActiveItem = dialog_menu_id - 96; else pNumActiveItem = dialog_menu_id - 4; break; } } } //----- (004BA928) -------------------------------------------------------- void __cdecl ArmorShopDialog() { signed int v1; // esi@8 unsigned int v2; // eax@10 ItemGen *v3; // eax@11 char *v5; // ecx@12 char *v6; // eax@13 int v8; // eax@15 signed int v9; // esi@17 unsigned int v10; // eax@19 char *v11; // edi@19 int v12; // ST08_4@20 int v13; // eax@20 char *v15; // ecx@20 char **v16; // edi@22 int all_text_height; // ebx@22 char **v18; // esi@22 int v19; // eax@23 GUIWindow *v20; // ecx@24 int v21; // eax@24 int v22; // edx@24 int v23; // ebx@24 unsigned __int8 v24; // sf@24 GUIButton *pButton; // eax@26 unsigned int v28; // ecx@26 int v29; // edx@26 signed int v31; // esi@31 unsigned int v32; // eax@33 int v33; // eax@34 int v35; // eax@35 char *v36; // edx@36 signed int v38; // esi@42 unsigned int v39; // esi@44 int v40; // eax@44 unsigned int v41; // eax@45 int v42; // eax@47 int v43; // ecx@52 int v46; // eax@54 unsigned int v49; // ecx@56 int v51; // eax@56 int v53; // eax@60 int textureH; // eax@60 signed int textureW; // ebx@65 Texture *v56; // eax@67 unsigned int pY_item; // edi@68 Texture *v58; // ST1C_4@68 int v59; // eax@68 int v60; // edi@69 signed int v61; // ebx@73 Texture *v62; // eax@75 int v63; // edi@76 Texture *v64; // ST1C_4@76 unsigned int v65; // ST18_4@76 int v66; // eax@76 int v67; // edi@77 signed int v68; // ecx@81 const char *pStatusText; // ecx@91 void *v72; // eax@95 POINT *v73; // esi@97 int v74; // ecx@97 int v75; // eax@98 int v76; // ecx@98 ItemGen *selected_item; // ecx@99 unsigned __int8 v78; // bl@104 int v80; // ebx@105 char **v81; // esi@105 int v82; // eax@106 int v86; // ebx@107 int pTextHeight; // eax@109 unsigned int v90; // ecx@109 int pNumString; // edx@109 unsigned __int16 pTextColor; // ax@109 signed int v93; // edx@114 POINT *v94; // edi@120 __int32 v95; // ecx@120 void *v96; // ST14_4@122 unsigned __int8 v97; // bl@122 ItemGen *v98; // ST10_4@122 int v99; // eax@122 char *v100; // eax@122 const char *v101; // ST18_4@122 unsigned __int16 v102; // ST14_2@122 int v103; // eax@122 signed int v104; // edi@123 Texture *v105; // eax@125 int v106; // ebx@126 unsigned int v108; // ST18_4@126 int v109; // eax@126 int v110; // ebx@127 GUIWindow *v111; // [sp-18h] [bp-11Ch]@36 unsigned int v112; // [sp-14h] [bp-118h]@13 int v113; // [sp-14h] [bp-118h]@36 unsigned int v115; // [sp-10h] [bp-114h]@13 ItemGen *v116; // [sp-10h] [bp-114h]@20 int v117; // [sp-10h] [bp-114h]@36 unsigned __int16 v119; // [sp-Ch] [bp-110h]@13 char *v121; // [sp-8h] [bp-10Ch]@13 int v122; // [sp-8h] [bp-10Ch]@20 unsigned int v123; // [sp-4h] [bp-108h]@13 __int64 *v124; // [sp-4h] [bp-108h]@20 int v125; // [sp-4h] [bp-108h]@68 int v126; // [sp-4h] [bp-108h]@76 int v127; // [sp-4h] [bp-108h]@126 POINT v128; // [sp+Ch] [bp-F8h]@8 POINT v129; // [sp+14h] [bp-F0h]@18 char v130; // [sp+1Ch] [bp-E8h]@120 POINT a2; // [sp+24h] [bp-E0h]@8 POINT v132; // [sp+2Ch] [bp-D8h]@120 POINT v133; // [sp+34h] [bp-D0h]@17 POINT v134; // [sp+3Ch] [bp-C8h]@97 POINT v135; // [sp+44h] [bp-C0h]@31 POINT v136; // [sp+4Ch] [bp-B8h]@97 POINT v137; // [sp+54h] [bp-B0h]@17 POINT v138; // [sp+5Ch] [bp-A8h]@32 POINT v139; // [sp+64h] [bp-A0h]@17 POINT v140; // [sp+6Ch] [bp-98h]@31 POINT v141; // [sp+74h] [bp-90h]@8 POINT v142; // [sp+7Ch] [bp-88h]@31 POINT v143; // [sp+84h] [bp-80h]@9 GUIWindow dialog_window; // [sp+8Ch] [bp-78h]@1 int v146; // [sp+E4h] [bp-20h]@24 int pYellowColor; // [sp+E8h] [bp-1Ch]@1 int pWhiteColor; // [sp+ECh] [bp-18h]@1 __int32 pItemCount; // [sp+F0h] [bp-14h]@8 int v152; // [sp+FCh] [bp-8h]@24 int v153; // [sp+100h] [bp-4h]@44 int th; short text_color; int pActiveButton; memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; dialog_window.uFrameZ = 334; pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu); pYellowColor = TargetColor(0xE1u, 0xCDu, 0x23u); switch (dialog_menu_id) { case HOUSE_DIALOGUE_MAIN: { if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard" pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special" pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; //"Display Inventory" pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; all_text_height = 0; for( int i = 0; i < 4; ++i ) all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); v146 = ( 174 - all_text_height ) / 4; v23 = ( 174 - 4 * ( 174 - all_text_height ) / 4 - all_text_height ) / 2 - ( 174 - all_text_height ) / 4 / 2 + 138; pNumString = 0; if ( pDialogueWindow->pNumPresenceButton>=0 ) { for (pActiveButton = pDialogueWindow->pStartingPosActiveItem; pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++pActiveButton) { pButton = pDialogueWindow->GetControl(pActiveButton); pButton->uY = v146 + v23; pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v23 = pButton->uY + pButton->uHeight - 1; pButton->uW = v23; pTextColor = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton ) pTextColor = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3); ++pNumString; } } } break; case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: { pRenderer->DrawTextureIndexed(8, 8, ShopTexture);// textureW = 0; v153 = 0; for ( int i = 0; i < 8; ++i )// { if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID) { textureW = ItemsInShopTexture[i]->uTextureWidth; textureH = ItemsInShopTexture[i]->uTextureHeight; if ( i >= 4 ) //low row { v60 = 90 - (textureW/2); pRenderer->DrawTextureTransparent(v60 + v153 - 420, 126, ItemsInShopTexture[i]); v59 = v60 + v153 + 80220; } else { pY_item = 98 - textureH; v152 = 86 - (textureW/2); pRenderer->DrawTextureTransparent(v152 + v153, pY_item, ItemsInShopTexture[i]); v59 = v153 + v152 + 640 * pY_item; } ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1); } v153 += 105; } if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; pItemCount = 0; for ( int i = 0; i < 8; ++i ) { if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID ) ++pItemCount; } if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) pStatusText = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" else pStatusText = pGlobalTXT_LocalizationStrings[185];//"Steal item" DrawTextAtStatusBar(pStatusText, 0); if ( pItemCount != 0 ) { v73 = pMouse->GetCursorPos(&v136); v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v134)->y]] & 0xFFFF; if ( !v74 ) return; pItemCount = v74 - 1; selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0) v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; } dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); return; } break; case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v11 = 0; v61 = 0; v153 = 0; do { if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v61].uItemID) { v62 = ItemsInShopTexture[v61]; if ( v61 >= 4 ) { v67 = 90 - ((signed int)v62->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v153 + v67 - 420, 0x7Eu, ItemsInShopTexture[v61]); v66 = v153 + v67 + 80220; } else { v63 = 98 - v62->uTextureHeight; v64 = ItemsInShopTexture[v61]; v65 = 98 - v62->uTextureHeight; v152 = 86 - ((signed int)v62->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v152 + v153, v65, v64); v66 = v152 + v153 + 640 * v63; } ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v66], ItemsInShopTexture[v61], v61 + 1); } v153 += 105; ++v61; } while ( v61 < 8 ); if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; v68 = 0; pItemCount = 0; do { if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(signed int)v68].uItemID) ++pItemCount; ++v68; } while ( v68 < 6 ); if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) pStatusText = pGlobalTXT_LocalizationStrings[196]; //Select the Special Item to Buy" else pStatusText = pGlobalTXT_LocalizationStrings[185]; DrawTextAtStatusBar(pStatusText, 0); if ( (char *)pItemCount != 0 ) { v73 = pMouse->GetCursorPos(&v136); v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v134)->y]] & 0xFFFF; if ( !v74 ) return; pItemCount = v74 - 1; if ( dialog_menu_id == 2 ) selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; else selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; } dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); return; } break; case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; //"Sell" pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; //"Identify" pShopOptions[2] = pGlobalTXT_LocalizationStrings[179]; //"Repair" all_text_height = 0; for ( int i = 0; i < 3; ++i ) all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); v152 = (174 - all_text_height) / 3; v86 = (3 * (58 - v152) - all_text_height) / 2 - v152 / 2 + 138; v24 = -pDialogueWindow->pNumPresenceButton < 0; pActiveButton = pDialogueWindow->pStartingPosActiveItem; if ( v24 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) ) { pNumString = 0; do { pButton = pDialogueWindow->GetControl((unsigned int)pActiveButton); pButton->uY = v152 + v86; pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); v90 = pButton->uY; pButton->uHeight = pTextHeight; v86 = v90 + pTextHeight - 1; pButton->uW = v86; pTextColor = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton ) pTextColor = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, v90, pTextColor, pShopOptions[pNumString], 3); ++pNumString; ++pActiveButton; } while ( (signed int)pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } return; } break; case HOUSE_DIALOGUE_SHOP_SELL: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell" if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) return; if((v9 = pMouse->GetCursorPos(&v139)->x - 14, pItemCount = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5), pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462 || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) ) return; v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10 - 1]; v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; } break; case HOUSE_DIALOGUE_SHOP_IDENTIFY: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify" if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v1 = pMouse->GetCursorPos(&a2)->x - 14; pItemCount = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v128)->y - 17) >> 5); if ( pMouse->GetCursorPos(&v141)->x > 13 ) { if ( pMouse->GetCursorPos(&v143)->x < 462 ) { v2 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount); if ( v2 ) { v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1]; if (v3->Identified()) v5 = "%24"; else { v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); v5 = (char *)pMerchantsIdentifyPhrases[v8]; } v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v6, 3); return; } } } } } break; case HOUSE_DIALOGUE_SHOP_REPAIR: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) return; if( (v31 = pMouse->GetCursorPos(&v135)->x - 14, pItemCount = (v31 >> 5) + 14 * ((pMouse->GetCursorPos(&v142)->y - 17) >> 5), pMouse->GetCursorPos(&v140)->x <= 13) || pMouse->GetCursorPos(&v138)->x >= 462 || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32) || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) ) return; v116 = &pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1]; v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5); v15 = (char *)pMerchantsRepairPhrases[v35]; v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; } break; case HOUSE_DIALOGUE_SHOP_6: //buy standart ??? { pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy" if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; pItemCount = 0; for( int i = 0; i < 6 ; ++i ) if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID) ++pItemCount; if ( pItemCount ) { v94 = pMouse->GetCursorPos(&v132); pItemCount = pRenderer->pActiveZBuffer[v94->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v130)->y]]; v95 = pItemCount; if ( pItemCount && pItemCount != -65536 ) { --pItemCount; v97 = uActiveCharacter - 1; v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2); v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3); } v104 = 0; v153 = 0; do { //if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v104].uItemID) { v105 = ItemsInShopTexture[v104]; if ( v104 >= 4 ) { v110 = 90 - ((signed int)v105->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v153 + v110 - 420, 0x7Eu, ItemsInShopTexture[v104]); v127 = v104 + 1; v109 = v153 + v110 + 80220; } else { v106 = 98 - v105->uTextureHeight; v108 = 98 - v105->uTextureHeight; v152 = 86 - ((signed int)v105->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v152 + v153, v108, ItemsInShopTexture[v104]); v127 = v104 + 1; v109 = v152 + v153 + 640 * v106; } ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v109], ItemsInShopTexture[v104], v127); } v153 += 105; ++v104; } while ( v104 < 8 ); return; } dialog_window.DrawCurrentTime(pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); return; } break; case HOUSE_DIALOGUE_LEARN_SKILLS: { if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; v152 = 0; v38 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); pActiveButton = v38 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; if ( (signed int)pActiveButton < v38 / 3 ) pActiveButton = v38 / 3; v39 = pDialogueWindow->pStartingPosActiveItem; v40 = pDialogueWindow->pNumPresenceButton; v153 = 0; if ( (signed int)v39 < (signed int)(v39 + v40) ) { do { v41 = pDialogueWindow->GetControl(v39)->msg_param - 36; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] && !pPlayers[uActiveCharacter]->pActiveSkills[v41] ) { v42 = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0); v152 += v42; ++v153; } ++v39; } while ( (signed int)v39 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); if ( v153 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pActiveButton); dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); pActiveButton = (149 - v152) / v153; if ( (149 - v152) / v153 > 32 ) pActiveButton = 32; v43 = (149 - v153 * (signed int)pActiveButton - v152) / 2 - (signed int)pActiveButton / 2 + 162; v152 = pDialogueWindow->pStartingPosActiveItem; v146 = v43; if ( v152 < v152 + pDialogueWindow->pNumPresenceButton ) { v153 = 2; do { pButton = pDialogueWindow->GetControl(v152); v46 = pButton->msg_param - 36; if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v46] || pPlayers[uActiveCharacter]->pActiveSkills[v46] ) { pButton->uW = 0; pButton->uHeight = 0; pButton->uY = 0; } else { pButton->uY = (unsigned int)((char *)pActiveButton + v146); pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v46], &dialog_window, 0, 0); v49 = pButton->uY; pButton->uHeight = pTextHeight; v51 = v49 + pTextHeight - 1; pButton->uW = v51; v146 = v51; pTextColor = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != v153 ) pTextColor = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, v49, pTextColor, pSkillNames[v46], 3); } v53 = pDialogueWindow->pStartingPosActiveItem; ++v152; textureH = pDialogueWindow->pNumPresenceButton + v53; ++v153; } while ( v152 < textureH ); } return; } } sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); //"Seek knowledge elsewhere %s the %s" strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." v115 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pYellowColor, pTmpBuf.data(), 3); return; } break; } } //----- (004B9CC6) -------------------------------------------------------- void __cdecl AlchemistDialog() { int v0; int pNumActiveItem; // eax@7 signed int v5; // esi@9 unsigned int v6; // esi@11 int v7; // eax@11 unsigned int v8; // eax@12 int v9; // eax@14 int v10; // ecx@19 int v13; // eax@21 char *v14; // eax@23 int v15; // eax@23 unsigned int v16; // ecx@23 int v17; // edx@23 int v18; // eax@23 int v20; // eax@27 char *v21; // edx@29 int v22; // esi@30 char **v23; // edi@30 int v24; // eax@31 int v26; // edx@32 int v27; // edi@32 unsigned __int8 v28; // sf@32 const char **v30; // eax@34 int v31; // eax@34 unsigned int v32; // ecx@34 int v34; // eax@34 signed int v36; // esi@39 ItemGen *v37; // eax@42 char *v38; // ecx@43 unsigned __int8 v39; // dl@44 int v40; // eax@46 int v41; // ST08_4@47 int v42; // eax@47 signed int v43; // esi@49 int v44; // ST08_4@52 int v45; // eax@52 Texture *v46; // ecx@55 unsigned int v47; // edi@55 unsigned int v48; // esi@57 int v49; // edx@61 Texture *v50; // ecx@67 unsigned int v51; // edi@67 unsigned int v52; // esi@69 int v53; // edx@73 Texture *v54; // ecx@79 unsigned int v55; // edi@79 unsigned int v56; // esi@81 int v57; // edx@85 Texture *v58; // ecx@91 unsigned int v59; // edi@91 unsigned int v60; // esi@93 int v61; // edx@97 signed int v62; // ecx@102 SHORT v63; // di@110 bool v64; // eax@110 const char *v65; // ecx@112 POINT *v66; // esi@117 int v67; // ecx@118 int v68; // eax@118 int v69; // ecx@118 ItemGen *v70; // esi@118 int v71; // eax@123 int all_text_height; // edi@125 char **v73; // esi@125 int v74; // eax@126 int pItemNum; int v76; // edx@127 int v77; // edi@127 GUIButton *pButton; // esi@129 const char **v79; // eax@129 int pTextHeight; // eax@129 unsigned int v81; // ecx@129 unsigned int pColorText; // ax@129 int v85; // [sp-14h] [bp-ECh]@29 int v86; // [sp-10h] [bp-E8h]@29 ItemGen *v87; // [sp-10h] [bp-E8h]@43 unsigned __int16 v88; // [sp-Ch] [bp-E4h]@29 void *v89; // [sp-Ch] [bp-E4h]@43 char *v90; // [sp-8h] [bp-E0h]@29 int v91; // [sp-8h] [bp-E0h]@42 unsigned int v92; // [sp-4h] [bp-DCh]@29 __int64 *v93; // [sp-4h] [bp-DCh]@42 POINT v94; // [sp+Ch] [bp-CCh]@39 POINT v95; // [sp+14h] [bp-C4h]@49 POINT v96; // [sp+1Ch] [bp-BCh]@117 POINT v97; // [sp+24h] [bp-B4h]@40 POINT v98; // [sp+2Ch] [bp-ACh]@117 POINT v99; // [sp+34h] [bp-A4h]@49 POINT v100; // [sp+3Ch] [bp-9Ch]@50 POINT v101; // [sp+44h] [bp-94h]@39 POINT v102; // [sp+4Ch] [bp-8Ch]@49 POINT a2; // [sp+54h] [bp-84h]@39 GUIWindow dialog_window; // [sp+5Ch] [bp-7Ch]@1 int v105; // [sp+B0h] [bp-28h]@19 int pColorYellow; // [sp+B4h] [bp-24h]@1 int Str; // [sp+B8h] [bp-20h]@23 int pColorWhite; // [sp+BCh] [bp-1Ch]@1 __int32 v109; // [sp+C0h] [bp-18h]@39 Player *pPlayer; // [sp+C4h] [bp-14h]@1 int pNumString; // [sp+C8h] [bp-10h]@9 unsigned int v112; // [sp+CCh] [bp-Ch]@9 unsigned __int8 v113; // [sp+D3h] [bp-5h]@47 int v114; // [sp+D4h] [bp-4h]@11 pPlayer = pPlayers[uActiveCharacter]; memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; dialog_window.uFrameZ = 334; pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u); switch(dialog_menu_id) { case HOUSE_DIALOGUE_MAIN: { if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; all_text_height = 0; for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 ); all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); Str = (174 - all_text_height) / 4; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v76 = pNumActiveItem + pDialogueWindow->pNumPresenceButton; v77 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; v28 = -pDialogueWindow->pNumPresenceButton < 0; if ( v28 ^ (pNumActiveItem > v76) ) { pItemNum = 2; pNumString = 0; do { pButton = pDialogueWindow->GetControl(pItemNum); pButton->uY = Str + v77; pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v77 = pButton->uY + pTextHeight - 1; pButton->uW = v77; pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); ++pItemNum; ++pNumString; pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } while ( pItemNum < pNumActiveItem ); } } return; } case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v114 = 0; do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) { v46 = ItemsInShopTexture[v114]; v47 = 152 - v46->uTextureHeight; if ( (signed int)v47 < 1 ) v47 = 0; v48 = 75 * v114 - v46->uTextureWidth / 2 + 40; if ( v114 ) { if ( v114 == 5 ) { v49 = ItemsInShopTexture[5]->uTextureWidth; if ( (signed int)v48 > 457 - v49 ) v48 = 457 - v49; } } else if ( (signed int)v48 < 18 ) v48 = 18; pRenderer->DrawTextureTransparent(v48, v47, v46); sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1); } ++v114; } while ( v114 < 6 ); v114 = 0; do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114 + 6].uItemID) { v50 = ItemsInShopTexture[v114 + 6]; v51 = 308 - v50->uTextureHeight; if ( (signed int)v51 < 1 ) v51 = 0; v52 = 75 * v114 - v50->uTextureWidth / 2 + 40; if ( v114 ) { if ( v114 == 5 ) { v53 = ItemsInShopTexture[11]->uTextureWidth; if ( (signed int)v52 > 457 - v53 ) v52 = 457 - v53; } } else { if ( (signed int)v52 < 18 ) v52 = 18; } pRenderer->DrawTextureTransparent(v52, v51, v50); sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7); } ++v114; } while ( v114 < 6 ); if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v62 = 0; v109 = 0; do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) ++v109; ++v62; } while ( v62 < 12 ); v63 = GetAsyncKeyState(17); v64 = pPlayer->CanSteal(); Str = v64; if ( v63 && v64 ) { v65 = pGlobalTXT_LocalizationStrings[185]; } else if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { v65 = pGlobalTXT_LocalizationStrings[195]; } else { v65 = pGlobalTXT_LocalizationStrings[196]; } DrawTextAtStatusBar(v65, 0); if ( !v109 ) { dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v66 = pMouse->GetCursorPos(&v98); pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]; if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) { v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return ; } } return; } case HOUSE_DIALOGUE_SHOP_SELL: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; if ((v43 = pMouse->GetCursorPos(&v99)->x - 14, v109 = (v43 >> 5) + 14 * ((pMouse->GetCursorPos(&v95)->y - 17) >> 5), pMouse->GetCursorPos(&v102)->x <= 13) || pMouse->GetCursorPos(&v100)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; v87 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3); return; } case HOUSE_DIALOGUE_SHOP_IDENTIFY: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; if ((v36 = pMouse->GetCursorPos(&a2)->x - 14, v109 = (v36 >> 5) + 14 * ((pMouse->GetCursorPos(&v94)->y - 17) >> 5), pMouse->GetCursorPos(&v101)->x <= 13) || pMouse->GetCursorPos(&v97)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; v37 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; if (!v37->Identified()) { v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); v38 = (char *)pMerchantsIdentifyPhrases[v42]; } else { v38 = "%24"; } v21 = BuilDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; } case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; all_text_height = 0; for ( int i = 0; i < 2; ++i ) all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); Str = (174 - all_text_height) / 2; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v26 = pNumActiveItem + pDialogueWindow->pNumPresenceButton; v27 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138; v28 = -pDialogueWindow->pNumPresenceButton < 0; if ( v28 ^ (pNumActiveItem > v26) ) { pItemNum = 2; pNumString = 0; do { pButton = pDialogueWindow->GetControl(pItemNum); pButton->uY = Str + v27; pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v27 = pButton->uY + pTextHeight - 1; pButton->uW = v27; pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); ++pItemNum; ++pNumString; pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } while ( pItemNum < pNumActiveItem ); } return; } case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v114 = 0; do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) { v54 = ItemsInShopTexture[v114]; v55 = 152 - v54->uTextureHeight; if ( (signed int)v55 < 1 ) v55 = 0; v56 = 75 * v114 - v54->uTextureWidth / 2 + 40; if ( v114 ) { if ( v114 == 5 ) { v57 = ItemsInShopTexture[5]->uTextureWidth; if ( (signed int)v56 > 457 - v57 ) v56 = 457 - v57; } } else { if ( (signed int)v56 < 18 ) v56 = 18; } pRenderer->DrawTextureTransparent(v56, v55, v54); sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1); } ++v114; } while ( v114 < 6 ); v114 = 0; do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114 + 6].uItemID) //not itemid { v58 = ItemsInShopTexture[v114 + 6]; v59 = 308 - v58->uTextureHeight; if ( (signed int)v59 < 1 ) v59 = 0; v60 = 75 * v114 - v58->uTextureWidth / 2 + 40; if ( v114 ) { if ( v114 == 5 ) { v61 = ItemsInShopTexture[11]->uTextureWidth; if ( (signed int)v60 > 457 - v61 ) v60 = 457 - v61; } } else { if ( (signed int)v60 < 18 ) v60 = 18; } pRenderer->DrawTextureTransparent(v60, v59, v58); sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7); } ++v114; } while ( v114 < 6 ); if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v62 = 0; v109 = 0; do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) ++v109; ++v62; } while ( v62 < 12 ); v63 = GetAsyncKeyState(17); v64 = pPlayer->CanSteal(); Str = v64; if ( v63 && v64 ) { v65 = pGlobalTXT_LocalizationStrings[185]; } else { v65 = pGlobalTXT_LocalizationStrings[195]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v65 = pGlobalTXT_LocalizationStrings[196]; } DrawTextAtStatusBar(v65, 0); if ( !v109 ) { dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v66 = pMouse->GetCursorPos(&v98); pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]; if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) { v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; v109 = v67; v68 = (int)window_SpeakInHouse->ptr_1C; // v69 = 9 * (v67 + 12 * v68); v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; } } return; } case HOUSE_DIALOGUE_LEARN_SKILLS: { if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) return; all_text_height = 0; v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); pItemNum = v5 * (100 - pPlayer->GetMerchant()) / 100; if ( pItemNum < v5 / 3 ) pItemNum = v5 / 3; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v114 = 0; if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); return; } do { v8 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v8] && !pPlayer->pActiveSkills[v8] ) { all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v8], &dialog_window, 0, 0); ++v114; } ++pNumActiveItem; } while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); if ( !v114 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); return; } if ( v114 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum); dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); v18 = (149 - all_text_height) / v114; if ( (149 - all_text_height) / v114 > 32 ) v18 = 32; pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v105 = (149 - v114 * v18 - all_text_height) / 2 - v18 / 2 + 162; if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) { pItemNum = 2; do { pButton = pDialogueWindow->GetControl(pItemNum); v13 = pButton->msg_param - 36; if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v13] || pPlayer->pActiveSkills[v13] ) { pButton->uW = 0; pButton->uHeight = 0; pButton->uY = 0; } else { pButton->uY = v18 + v105; pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v13], &dialog_window, 0, 0); pButton->uHeight = pTextHeight; v105 = pButton->uY + pTextHeight - 1; pButton->uW = v105; pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v13], 3); } pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; pItemNum++; } while ( pItemNum < pNumActiveItem ); } return; } } default: { return;// (POINT *)dialog_menu_id - 96; } } } //----- (004B4FCF) -------------------------------------------------------- void MagicShopDialog() { int result; // eax@6 signed int v2; // esi@8 unsigned int v3; // ebx@10 char *v4; // eax@11 char *v5; // eax@12 unsigned int v6; // eax@12 int v7; // ST08_4@14 int v8; // eax@14 unsigned __int8 v9; // dl@14 char *v10; // ecx@14 signed int v11; // esi@16 int v12; // ST08_4@19 int v13; // eax@19 int all_text_height; // edi@21 char **v15; // esi@21 int v16; // eax@22 int v18; // edx@23 int v19; // edi@23 unsigned __int8 v20; // sf@23 GUIButton *control_button; // esi@25 const char **v22; // eax@25 int v23; // eax@25 unsigned int v24; // ecx@25 const char **v25; // edx@25 unsigned __int16 text_color; // ax@25 signed int pTextHeight; // esi@30 int v28; // ST08_4@34 int v29; // eax@34 char *v30; // edx@35 void *v32; // eax@40 signed int v33; // esi@40 unsigned int v34; // esi@42 int v35; // eax@42 unsigned int v36; // eax@43 int v37; // eax@45 int v38; // ecx@50 int v41; // eax@52 char *v42; // eax@54 int v43; // eax@54 unsigned int v44; // ecx@54 int v45; // edx@54 int v46; // eax@54 unsigned __int16 v47; // ax@54 int v48; // eax@58 signed int v49; // esi@62 Texture *v50; // ecx@64 unsigned int v51; // edi@64 unsigned int v52; // esi@66 int v53; // edx@70 Texture *v54; // ecx@76 unsigned int v55; // edi@76 unsigned int v56; // esi@76 int v57; // edx@80 unsigned int v59; // edi@86 unsigned int v60; // esi@88 int v61; // edx@92 unsigned int v63; // edi@98 unsigned int v64; // esi@100 int v65; // edx@104 signed int v66; // ecx@109 SHORT v67; // di@117 bool v68; // eax@117 const char *v69; // ecx@119 POINT *v70; // esi@124 int v71; // ecx@125 int v73; // ecx@125 int v75; // eax@130 int v78; // eax@132 int v80; // edx@133 int v81; // edi@133 const char **v83; // eax@135 int v84; // eax@135 unsigned int v85; // ecx@135 int v86; // edx@135 int v89; // [sp-14h] [bp-10Ch]@35 int v91; // [sp-10h] [bp-108h]@35 unsigned __int16 v92; // [sp-Ch] [bp-104h]@12 void *v93; // [sp-Ch] [bp-104h]@14 int v94; // [sp-8h] [bp-100h]@11 char *v95; // [sp-8h] [bp-100h]@12 __int64 *v96; // [sp-4h] [bp-FCh]@11 unsigned int v97; // [sp-4h] [bp-FCh]@12 POINT v98; // [sp+Ch] [bp-ECh]@8 POINT v99; // [sp+14h] [bp-E4h]@16 POINT v100; // [sp+1Ch] [bp-DCh]@124 POINT v101; // [sp+24h] [bp-D4h]@17 POINT v102; // [sp+2Ch] [bp-CCh]@124 POINT v103; // [sp+34h] [bp-C4h]@9 POINT v104; // [sp+3Ch] [bp-BCh]@31 POINT v105; // [sp+44h] [bp-B4h]@16 POINT v106; // [sp+4Ch] [bp-ACh]@30 POINT v107; // [sp+54h] [bp-A4h]@16 POINT v108; // [sp+5Ch] [bp-9Ch]@30 POINT a2; // [sp+64h] [bp-94h]@8 POINT v110; // [sp+6Ch] [bp-8Ch]@30 POINT v111; // [sp+74h] [bp-84h]@8 GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 char *Str; // [sp+D0h] [bp-28h]@54 int v146; // [sp+D4h] [bp-24h]@23 unsigned int pYellowColor; // [sp+D8h] [bp-20h]@1 unsigned int pWhiteColor; // [sp+DCh] [bp-1Ch]@1 __int32 v117; // [sp+E0h] [bp-18h]@8 int v118; // [sp+E4h] [bp-14h]@40 const char **v119; // [sp+E8h] [bp-10h]@24 int _this; // [sp+ECh] [bp-Ch]@1 unsigned __int8 uPlayerID; // [sp+F3h] [bp-5h]@14 int v152; // [sp+F4h] [bp-4h]@23 int v122; int v114; int pSrtingNum; int pActiveItemNum; ItemGen *item; memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; dialog_window.uFrameZ = 334; pWhiteColor = TargetColor(255, 255, 255); pYellowColor = TargetColor(225, 205, 35); if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) { if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard" pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special" pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; //"Display Inventory" pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; all_text_height = 0; for ( int i = 0; i < 4; ++i ) all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); v146 = (174 - all_text_height) / 4; v23 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; int j = 0; if ( pDialogueWindow->pNumPresenceButton>=0 ) { int th = 2; for (v152 = pDialogueWindow->pStartingPosActiveItem; v152 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++v152) { control_button = pDialogueWindow->GetControl(v152); control_button->uY = v146 + v23; pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &dialog_window, 0, 0); control_button->uHeight = pTextHeight; v23 = control_button->uY + control_button->uHeight - 1; control_button->uW = v23; text_color = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != th ) text_color = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[j], 3); ++th; ++j; } } return; } if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v3 = 0; v49 = 0; v122 = 0; do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID) { v50 = ItemsInShopTexture[v49]; v51 = 152 - v50->uTextureHeight; if ( (signed int)v51 < 1 ) v51 = 0; v52 = 75 * v49 - v50->uTextureWidth / 2 + 40; if ( v122 ) { if ( v122 == 5 ) { v53 = ItemsInShopTexture[5]->uTextureWidth; if ( (signed int)v52 > 457 - v53 ) v52 = 457 - v53; } } else { if ( (signed int)v52 < 18 ) v52 = 18; } pRenderer->DrawTextureTransparent(v52, v51, v50); sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v122], v122 + 1); v49 = v122; } ++v49; v122 = v49; } while ( v49 < 6 ); v122 = 0; do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID) { v54 = ItemsInShopTexture[v122 + 6]; v55 = 306 - v54->uTextureHeight; v56 = 75 * v122 - v54->uTextureWidth / 2 + 40; if ( v122 ) { if ( v122 == 5 ) { v57 = ItemsInShopTexture[11]->uTextureWidth; if ( (signed int)v56 > 457 - v57 ) v56 = 457 - v57; } } else { if ( (signed int)v56 < 18 ) v56 = 18; } pRenderer->DrawTextureTransparent(v56, v55, v54); sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v122 + 6], v122 + 7); } ++v122; } while ( v122 < 6 ); if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v66 = 0; v117 = 0; if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v117; ++v66; } while ( v66 < 12 ); } else { do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) ++v117; ++v66; } while ( v66 < 12 ); } v67 = GetAsyncKeyState(VK_CONTROL); v68 = pPlayers[uActiveCharacter]->CanSteal(); Str = (char *)v68; if ( v67 && v68 ) { v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item" } else { v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy" if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy" } DrawTextAtStatusBar(v69, 0); if ( !v117 ) { dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v70 = pMouse->GetCursorPos(&v102); result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y]; if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) { v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1; item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; if ( v67 && Str ) v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } } return; } if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL) { pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v3 = 0; v49 = 0; v122 = 0; do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID) { v59 = 152 - ItemsInShopTexture[v49]->uTextureHeight; if ( (signed int)v59 < 1 ) v59 = 0; v60 = 75 * v49 - ItemsInShopTexture[v49]->uTextureWidth / 2 + 40; if ( v122 ) { if ( v122 == 5 ) { v61 = ItemsInShopTexture[5]->uTextureWidth; if ( (signed int)v60 > 457 - v61 ) v60 = 457 - v61; } } else { if ( (signed int)v60 < 18 ) v60 = 18; } pRenderer->DrawTextureTransparent(v60, v59, ItemsInShopTexture[v49]); sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v122], v122 + 1); v49 = v122; } ++v49; v122 = v49; } while ( v49 < 6 ); v122 = 0; do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID) { v63 = 306 - ItemsInShopTexture[v122 + 6]->uTextureHeight; if ( (signed int)v63 < 1 ) v63 = 0; v64 = 75 * v122 - ItemsInShopTexture[v122 + 6]->uTextureWidth / 2 + 40; if ( v122 ) { if ( v122 == 5 ) { v65 = ItemsInShopTexture[11]->uTextureWidth; if ( (signed int)v64 > 457 - v65 ) v64 = 457 - v65; } } else { if ( (signed int)v64 < 18 ) v64 = 18; } pRenderer->DrawTextureTransparent(v64, v63, ItemsInShopTexture[v122 + 6]); sub_40F92A(&pRenderer->pActiveZBuffer[v64 + 640 * v63], ItemsInShopTexture[v122 + 6], v122 + 7); } ++v122; } while ( v122 < 6 ); if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v66 = 0; v117 = 0; if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { do { if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v117; ++v66; } while ( v66 < 12 ); } else { do { if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) ++v117; ++v66; } while ( v66 < 12 ); } v67 = GetAsyncKeyState(VK_CONTROL); v68 = pPlayers[uActiveCharacter]->CanSteal(); Str = (char *)v68; if ( v67 && v68 ) { v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item" } else { v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy" if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy" } DrawTextAtStatusBar(v69, 0); if ( !v117 ) { dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v70 = pMouse->GetCursorPos(&v102); result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y]; if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) { v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1; item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; if ( v67 && Str ) v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } } return; } if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];// "Sell" pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];// "Identify" pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];// "Repair" all_text_height = 0; for ( uint i = 0; i < 3; ++i ) all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); _this = ((174 - all_text_height) / 3); v81 = (3 * (58 - (signed int)_this) - all_text_height) / 2 - (174 - all_text_height) / 3 / 2 + 138; v20 = -pDialogueWindow->pNumPresenceButton < 0; v118 = pDialogueWindow->pStartingPosActiveItem; if ( v20 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) ) { v122 = 2; pSrtingNum = 0; do { control_button = pDialogueWindow->GetControl(v118); control_button->uY = (unsigned int)((char *)_this + v81); pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pSrtingNum], &dialog_window, 0, 0); v85 = control_button->uY; control_button->uHeight = pTextHeight; v81 = pTextHeight + v85 - 1; control_button->uW = v81; text_color = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != v122 ) text_color = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, v85, text_color, pShopOptions[pSrtingNum], 3); ++v122; ++pSrtingNum; ++v118; } while ( v118 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } return; } if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_SELL) { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell" if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() || (v11 = pMouse->GetCursorPos(&v107)->x - 14, v117 = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v99)->y - 17) >> 5), result = (int)pMouse->GetCursorPos(&v105), *(int *)result <= 13) || (result = (int)pMouse->GetCursorPos(&v101), *(int *)result >= 462) || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) ) return; item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY) { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify" if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v2 = pMouse->GetCursorPos(&a2)->x - 14; v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5); result = (int)pMouse->GetCursorPos(&v111); if ( *(int *)result > 13 ) { result = (int)pMouse->GetCursorPos(&v103); if ( *(int *)result < 462 ) { result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117); if ( result ) { item = &pPlayers[uActiveCharacter]->pInventoryItems[result-1]; if ( item->uAttributes & 1 ) { v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3); return; } v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3); return; } } } } return; } if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR) { draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair" if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() || (pTextHeight = pMouse->GetCursorPos(&v110)->x - 14, v117 = (pTextHeight >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5), result = (int)pMouse->GetCursorPos(&v106), *(int *)result <= 13) || (result = (int)pMouse->GetCursorPos(&v104), *(int *)result >= 462) || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) // || (result *= 9, !(pPlayers[uActiveCharacter]->field_1F5[4 * result + 15] & 2)) ) || (!(pPlayers[uActiveCharacter]->pOwnItems[result-1].uAttributes& 2)) ) return; item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) { if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v3 = 0; all_text_height = 0; v33 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); v119 = (const char **)(v33 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100); if ( (signed int)v119 < v33 / 3 ) v119 = (const char **)(v33 / 3); pActiveItemNum = pDialogueWindow->pStartingPosActiveItem; v122 = 0; if ( (signed int)pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// // "Seek knowledge elsewhere %s the %s" strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf.data(), 3); return; } do { v36 = pDialogueWindow->GetControl(pActiveItemNum)->msg_param - 36; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v36] && !pPlayers[uActiveCharacter]->pActiveSkills[v36] ) { all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v36], &dialog_window, 0, 0); ++v122; } ++pActiveItemNum; } while ( pActiveItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); if ( !v122 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// // "Seek knowledge elsewhere %s the %s" strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf.data(), 3); return; } sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu" dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); v119 = (const char **)((149 - all_text_height) / v122); if ( (149 - all_text_height) / v122 > 32 ) v119 = (const char **)32; v38 = (149 - v122 * (signed int)v119 - all_text_height) / 2 - (signed int)v119 / 2 + 162; v118 = 2; if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) { v122 = 2; do { control_button = pDialogueWindow->GetControl(v122); v41 = control_button->msg_param - 36; if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] || pPlayers[uActiveCharacter]->pActiveSkills[v41] ) { control_button->uW = 0; control_button->uHeight = 0; control_button->uY = 0; } else { control_button->uY = (unsigned int)((char *)v119 + v38); pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0); v44 = control_button->uY; control_button->uHeight = pTextHeight; v38 = v44 + pTextHeight - 1; control_button->uW = v38; text_color = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != v122 ) text_color = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, v44, text_color, pSkillNames[v41], 3); } ++v122; } while ( v122 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } } return; } return; } //----- (004BDB56) -------------------------------------------------------- void __cdecl UIShop_Buy_Identify_Repair() { int v8; // eax@15 unsigned int pItemID; // esi@20 ItemGen *item; // esi@21 unsigned int v15; // eax@33 POINT *pCursorPos; // esi@37 int v18; // ecx@37 float pPriceMultiplier; // ST1C_4@38 int taken_item; // eax@40 ItemGen *bought_item; // esi@51 int party_reputation; // eax@55 int v39; // eax@63 int v42; // esi@74 signed int v43; // ebx@74 unsigned __int16 *pSkill; // esi@77 int v55; // [sp+0h] [bp-B4h]@26 POINT cursor; // [sp+40h] [bp-74h]@37 int a6; // [sp+98h] [bp-1Ch]@57 int a3; // [sp+9Ch] [bp-18h]@53 unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 unsigned int v79; // [sp+A8h] [bp-Ch]@9 int uPriceItemService; // [sp+ACh] [bp-8h]@12 if ( pCurrentScreen == SCREEN_E ) { OnInventoryLeftClick(); return; } if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } switch(dialog_menu_id) { case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; OnInventoryLeftClick(); break; } case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: { pCursorPos = pMouse->GetCursorPos(&cursor); v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF; if ( !v18 ) return; bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); GetAsyncKeyState(VK_CONTROL); if ( pParty->uNumGold < uPriceItemService ) { PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); return; } taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); if ( taken_item ) { bought_item->SetIdentified(); memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); dword_F8B1E4 = 1; Party::TakeGold(uPriceItemService); viewparams->bRedrawGameUI = 1; bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!" break; } case HOUSE_DIALOGUE_SHOP_SELL: { v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); if ( pMouse->GetCursorPos(&cursor)->x <= 13 || pMouse->GetCursorPos(&cursor)->x >= 462 || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) ) return; if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) ) { dword_F8B1E4 = 1; pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); viewparams->bRedrawGameUI = 1; pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); return; } pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0); pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); break; } case HOUSE_DIALOGUE_SHOP_IDENTIFY: { pMouse->GetCursorPos(&cursor); v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); if (cursor.x > 13 && cursor.x < 462) { pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); if ( pItemID ) { uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; if ( !(item->uAttributes & 1) ) { if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) { if ( pParty->uNumGold >= uPriceItemService ) { dword_F8B1E4 = 1; Party::TakeGold(uPriceItemService); item->uAttributes |= 1; pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); return; } PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); return; } pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); return; } } break; } case HOUSE_DIALOGUE_SHOP_REPAIR: { v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); if ( pMouse->GetCursorPos(&cursor)->x > 13 ) { if ( pMouse->GetCursorPos(&cursor)->x < 462 ) { pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); if ( pItemID ) { item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); if ( item->uAttributes & 2 ) { if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) { if ( pParty->uNumGold >= uPriceItemService ) { dword_F8B1E4 = 1; Party::TakeGold(uPriceItemService); v8 = item->uAttributes; LOBYTE(v8) = v8 & 0xFD; item->uAttributes = v8 | 1; pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); return; } PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); return; } pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); return; } } } break; } case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { pCursorPos = pMouse->GetCursorPos(&cursor); v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; if ( !v18 ) return; if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; else bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); uNumSeconds = 0; a3 = 0; if ( pMapStats->GetMapInfo(pCurrentMapName.data()) ) a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]._steal_perm; party_reputation = GetPartyReputation(); if (pPlayers[uActiveCharacter]->CanSteal()) { if ( GetAsyncKeyState(VK_CONTROL) ) { uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); if ( !uNumSeconds ) { sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); return; } } } if ( pParty->uNumGold < uPriceItemService ) { if ( uNumSeconds != 2 ) { if ( uNumSeconds != 1 ) { PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" return; } } } v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); if ( v39 ) { bought_item->SetIdentified(); memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen)); if ( pPlayers[uActiveCharacter]->CanSteal() ) { if ( GetAsyncKeyState(VK_CONTROL) ) { if ( uNumSeconds == 1 || uNumSeconds == 2 ) { pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen(); sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); viewparams->bRedrawGameUI = 1; bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } } } dword_F8B1E4 = 1; Party::TakeGold(uPriceItemService); viewparams->bRedrawGameUI = 1; bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" break; } default:// if click video screen in shop { __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum if( dialog_menu_id >= 36 && dialog_menu_id <= 72 ) { v42 = dialog_menu_id - 36; //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; if ( uPriceItemService < v43 / 3 ) uPriceItemService = v43 / 3; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) { pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; if ( !*pSkill ) { if ( pParty->uNumGold < uPriceItemService ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" if ( in_current_building_type == BildingType_Training ) v55 = 4; else v55 = 2; PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); return; } Party::TakeGold(uPriceItemService); dword_F8B1E4 = 1; *pSkill = 1; pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); return; } } } break; } } } //----- (004B1A2D) -------------------------------------------------------- void __cdecl ShowPopupShopItem() { POINT *v1; // esi@5 unsigned int v2; // eax@5 int v3; // ecx@5 POINT *v4; // esi@12 int v5; // eax@12 unsigned int v6; // eax@13 ItemGen *v7; // ecx@13 signed int v8; // esi@17 unsigned int v9; // eax@19 POINT v10; // [sp+8h] [bp-44h]@12 POINT v11; // [sp+10h] [bp-3Ch]@12 POINT v12; // [sp+18h] [bp-34h]@18 POINT v13; // [sp+20h] [bp-2Ch]@17 POINT v14; // [sp+28h] [bp-24h]@17 POINT v15; // [sp+30h] [bp-1Ch]@17 POINT v16; // [sp+38h] [bp-14h]@5 POINT a2; // [sp+40h] [bp-Ch]@5 if ( in_current_building_type <= 0 ) return; if ( in_current_building_type <= BildingType_AlchemistShop ) { if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD) return; if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) { v8 = pMouse->GetCursorPos(&v15)->x - 14; v5 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5); if ( pMouse->GetCursorPos(&v13)->x <= 13 || pMouse->GetCursorPos(&v12)->x >= 462 || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 ) return; GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItems[v9 - 1]); return; } if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) return; } v4 = pMouse->GetCursorPos(&v11); v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF; if ( !v5 ) return; v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C); v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4); if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1]; GameUI_DrawItemInfo(v7); return; } if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) { v1 = pMouse->GetCursorPos(&a2); v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; v5 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; if ( v5 ) sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)); } } //----- (004B1D27) -------------------------------------------------------- void __cdecl sub_4B1D27() { int v0; // edx@2 unsigned int v1; // ecx@7 signed int v2; // edi@10 int v3; // esi@10 __int16 v4; // ax@15 signed int v5; // edi@20 int v6; // esi@20 int v7[4]; // [sp+Ch] [bp-10h]@12 if ( in_current_building_type > 0 ) { v0 = 3; if ( in_current_building_type > BildingType_MagicShop ) { if ( in_current_building_type == BildingType_Bank ) { if ( !dword_F8B1E4 ) return; } else { if ( in_current_building_type != BildingType_Temple ) return; } v1 = (unsigned int)window_SpeakInHouse->ptr_1C; PlayHouseSound(v1, (HouseSoundID)v0); return; } v1 = (unsigned int)window_SpeakInHouse->ptr_1C; if ( (signed __int64)pParty->field_3C._shop_ban_times[v1 ]<= (signed __int64)pParty->uTimePlayed ) { if ( pParty->uNumGold <= 0x2710 ) { if ( !dword_F8B1E4 ) return; v0 = 4; PlayHouseSound(v1, (HouseSoundID)v0); return; } PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3)); if ( !dword_F8B1E4 && !qword_A750D8 ) { v5 = 0; v6 = 1; do { if ( pPlayers[v6]->CanAct() ) v7[v5++] = v6; ++v6; } while ( v6 <= 4 ); if ( v5 ) { qword_A750D8 = 256i64; word_A750E0 = 80; v4 = LOWORD(v7[rand() % v5]); word_A750E2 = v4; return; } } } else { if ( !qword_A750D8 ) { v2 = 0; v3 = 1; do { if ( pPlayers[v3]->CanAct() ) v7[v2++] = v3; ++v3; } while ( v3 <= 4 ); if ( v2 ) { qword_A750D8 = 256i64; word_A750E0 = 80; v4 = LOWORD(v7[rand() % v2]); word_A750E2 = v4; return; } } } } }