comparison mm7_5.cpp @ 1575:43d3536a20f7

OnInventoryItemRightClick
author Nomad
date Mon, 09 Sep 2013 20:09:01 +0200
parents 9a6567c6c76c
children e66e0c89d81b
comparison
equal deleted inserted replaced
1574:2d9c8f609a3c 1575:43d3536a20f7
3240 } 3240 }
3241 CastSpellInfoHelpers::_427E01_cast_spell(); 3241 CastSpellInfoHelpers::_427E01_cast_spell();
3242 } 3242 }
3243 3243
3244 //----- (004356FF) -------------------------------------------------------- 3244 //----- (004356FF) --------------------------------------------------------
3245 void back_to_game() 3245 void back_to_game()
3246 { 3246 {
3247 dword_507BF0_is_there_popup_onscreen = 0; 3247 dword_507BF0_is_there_popup_onscreen = 0;
3248 dword_4E455C = 1; 3248 dword_4E455C = 1;
3249 dword_50CDCC = 0; 3249
3250 extern int no_rightlick_in_inventory;
3251 no_rightlick_in_inventory = false;
3252
3250 if ( pGUIWindow_ScrollWindow ) 3253 if ( pGUIWindow_ScrollWindow )
3251 free_book_subwindow(); 3254 free_book_subwindow();
3252 if ( !pCurrentScreen && !pGUIWindow_Settings ) 3255 if ( !pCurrentScreen && !pGUIWindow_Settings )
3253 pEventTimer->Resume(); 3256 pEventTimer->Resume();
3254 viewparams->bRedrawGameUI = 1; 3257 viewparams->bRedrawGameUI = 1;
4901 MainMenuUI_LoadFontsAndSomeStuff(); 4904 MainMenuUI_LoadFontsAndSomeStuff();
4902 DrawCopyrightWindow(); 4905 DrawCopyrightWindow();
4903 } 4906 }
4904 4907
4905 4908
4909 int no_rightlick_in_inventory = false; // 0050CDCC
4906 //----- (00416196) -------------------------------------------------------- 4910 //----- (00416196) --------------------------------------------------------
4907 void identify_item() 4911 void OnInventoryItemRightClick()
4908 { 4912 {
4909 Player *v0; // esi@2 4913 //Player *v0; // esi@2
4910 POINT *v1; // edi@2 4914 //POINT *v1; // edi@2
4911 signed int v2; // ecx@5 4915 //signed int v2; // ecx@5
4912 signed int v3; // eax@5 4916 //signed int v3; // eax@5
4913 int v4; // eax@5 4917 //int v4; // eax@5
4914 char v5; // sf@5 4918 //char v5; // sf@5
4915 int v6; // eax@5 4919 //int v6; // eax@5
4916 int v7; // eax@7 4920 int v7; // eax@7
4917 unsigned __int16 v8; // ax@10 4921 //unsigned __int16 v8; // ax@10
4918 int v9; // edi@10 4922 int v9; // edi@10
4919 int v10; // eax@10 4923 int v10; // eax@10
4920 int v11; // edx@13 4924 //int v11; // edx@13
4921 LONG v12; // edx@23 4925 //LONG v12; // edx@23
4922 signed int v13; // edx@23 4926 //signed int v13; // edx@23
4923 int v14; // edx@25 4927 int v14; // edx@25
4924 unsigned int v15; // edi@25 4928 unsigned int v15; // edi@25
4925 signed int v16; // edx@27 4929 signed int v16; // edx@27
4926 int v17; // eax@54 4930 int v17; // eax@54
4927 unsigned int v18; // edx@57 4931 unsigned int v18; // edx@57
4932 int v23; // edx@78 4936 int v23; // edx@78
4933 int v24; // eax@79 4937 int v24; // eax@79
4934 int v25; // eax@80 4938 int v25; // eax@80
4935 int v26; // eax@84 4939 int v26; // eax@84
4936 ItemGen *v27; // esi@98 4940 ItemGen *v27; // esi@98
4937 unsigned int v28; // eax@98 4941 //unsigned int v28; // eax@98
4938 ItemGen *v29; // edi@98 4942 ItemGen *v29; // edi@98
4939 unsigned int v30; // ecx@103 4943 unsigned int v30; // ecx@103
4940 double v31; // st7@112 4944 double v31; // st7@112
4941 unsigned __int64 v32; // qax@113 4945 unsigned __int64 v32; // qax@113
4942 unsigned int v33; // ecx@117 4946 //unsigned int v33; // ecx@117
4943 int v34; // eax@126 4947 int v34; // eax@126
4944 unsigned int v35; // ecx@127 4948 //unsigned int v35; // ecx@127
4945 double v36; // st7@132 4949 double v36; // st7@132
4946 signed __int64 v37; // qax@135 4950 signed __int64 v37; // qax@135
4947 unsigned int v38; // eax@138 4951 //unsigned int v38; // eax@138
4948 Vec3_int_ v39; // [sp-18h] [bp-A8h]@83 4952 Vec3_int_ v39; // [sp-18h] [bp-A8h]@83
4949 int *v40; // [sp-Ch] [bp-9Ch]@83 4953 //int *v40; // [sp-Ch] [bp-9Ch]@83
4950 int *v41; // [sp-8h] [bp-98h]@83 4954 //int *v41; // [sp-8h] [bp-98h]@83
4951 int *v42; // [sp-4h] [bp-94h]@83 4955 //int *v42; // [sp-4h] [bp-94h]@83
4952 GUIWindow v43; // [sp+Ch] [bp-84h]@137 4956 GUIWindow v43; // [sp+Ch] [bp-84h]@137
4953 unsigned int pY; // [sp+60h] [bp-30h]@2 4957 //unsigned int pY; // [sp+60h] [bp-30h]@2
4954 int v45; // [sp+64h] [bp-2Ch]@10 4958 int v45; // [sp+64h] [bp-2Ch]@10
4955 unsigned int pX; // [sp+68h] [bp-28h]@2 4959 //unsigned int pX; // [sp+68h] [bp-28h]@2
4956 int v47; // [sp+6Ch] [bp-24h]@25 4960 int v47; // [sp+6Ch] [bp-24h]@25
4957 POINT y; // [sp+70h] [bp-20h]@2 4961 //POINT y; // [sp+70h] [bp-20h]@2
4958 POINT a2; // [sp+78h] [bp-18h]@2 4962 POINT a2; // [sp+78h] [bp-18h]@2
4959 Vec3_int_ pOut; // [sp+80h] [bp-10h]@2 4963 //Vec3_int_ pOut; // [sp+80h] [bp-10h]@2
4960 unsigned int v51; // [sp+8Ch] [bp-4h]@23 4964 unsigned int v51; // [sp+8Ch] [bp-4h]@23
4961 4965
4962 if ( dword_50CDCC ) 4966 if (no_rightlick_in_inventory)
4963 return; 4967 return;
4964 v0 = pPlayers[uActiveCharacter]; 4968
4965 v1 = pMouse->GetCursorPos(&a2); 4969 if (a2.x <= 13 || a2.x >= 462)
4966 pOut.z = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&y)->y]] & 0xFFFF; 4970 return;
4967 pMouse->GetClickPos(&pX, &pY); 4971
4968 if ( !pOut.z ) 4972 auto player = pPlayers[uActiveCharacter];
4973
4974 pMouse->GetCursorPos(&a2);
4975 int item_pid = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
4976 //pMouse->GetClickPos(&pX, &pY);
4977 if (!item_pid)
4969 { 4978 {
4970 if ( (signed int)pX <= 13 4979 int inventory_mouse_x = a2.x - 14;
4971 || (signed int)pX >= 462 4980 int inventory_mouse_y = a2.y - 17;
4972 || (v2 = pX - 14, 4981
4973 v3 = pY - 17, 4982 int mouse_cell_x = inventory_mouse_x / 32;
4974 pX = v2, 4983 int mouse_cell_y = inventory_mouse_y / 32;
4975 pY = v3, 4984
4976 v4 = 14 * (v3 >> 5), 4985 if (mouse_cell_x + mouse_cell_y < 0)
4977 v2 >>= 5,
4978 v5 = v2 + v4 < 0,
4979 v6 = v2 + v4,
4980 pOut.z = v6,
4981 v5)
4982 || v6 > 126
4983 || (v7 = v0->GetItemIDAtInventoryIndex(&pOut.z)) == 0 )
4984 return; 4986 return;
4985 pOut.z = v7; 4987
4988 int inventory_idx = mouse_cell_x + 14 * mouse_cell_y;
4989 if (inventory_idx > 126)
4990 return;
4991
4992 v7 = player->GetItemIDAtInventoryIndex(&inventory_idx);
4993 if (v7 == 0)
4994 return;
4995
4996 item_pid = v7;
4986 } 4997 }
4987 if ( !v0->CanAct() ) 4998
4999 if (!player->CanAct())
4988 { 5000 {
4989 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]); 5001 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], player->pName, pGlobalTXT_LocalizationStrings[541]);
4990 v43.Hint = pTmpBuf.data(); 5002 v43.Hint = pTmpBuf.data();
4991 v43.uFrameWidth = 384; 5003 v43.uFrameWidth = 384;
4992 v43.uFrameHeight = 180; 5004 v43.uFrameHeight = 180;
5005 if (a2.x <= 320 )
5006 v43.uFrameX = a2.x + 30;
5007 else
5008 v43.uFrameX = a2.x - 414;
4993 v43.uFrameY = 40; 5009 v43.uFrameY = 40;
4994 if ( pMouse->GetCursorPos(&a2)->x <= 320 )
4995 v38 = pMouse->GetCursorPos(&a2)->x + 30;
4996 else
4997 v38 = pMouse->GetCursorPos(&a2)->x - 414;
4998 v43.uFrameX = v38;
4999 v43.DrawMessageBox(0); 5010 v43.DrawMessageBox(0);
5000 return; 5011 return;
5001 } 5012 }
5002 --pOut.z; 5013
5003 LOBYTE(v8) = v0->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY); 5014 --item_pid;
5004 v9 = v8 & 0x3F; 5015 int alchemy_level = (int8_t)player->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
5005 v45 = v8 & 0x3F; 5016 v9 = alchemy_level & 0x3F;
5006 pOut.y = SkillToMastery(v8); 5017 //v45 = alchemy_level & 0x3F;
5007 v10 = pOut.z; 5018 int alchemy_skill = SkillToMastery(alchemy_level);
5019 v10 = item_pid;
5008 if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE ) 5020 if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE )
5009 { 5021 {
5010 LABEL_116: 5022 LABEL_116:
5011 GameUI_DrawItemInfo(&v0->pInventoryItemList[v10]); 5023 GameUI_DrawItemInfo(&player->pInventoryItemList[v10]);
5012 return; 5024 return;
5013 } 5025 }
5014 if ( (signed int)pParty->pPickedItem.uItemID < 200 5026
5015 || (signed int)pParty->pPickedItem.uItemID > 219 5027 if (pParty->pPickedItem.uItemID < ITEM_REAGENT_WIDOWSWEEP_BERRIES ||
5016 || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) ) 5028 pParty->pPickedItem.uItemID > ITEM_REAGENT_PHILOSOPHERS_STONE ||
5029 player->pInventoryItemList[item_pid].uItemID != ITEM_POTION_BOTTLE)
5017 { 5030 {
5018 if ( (signed int)pParty->pPickedItem.uItemID < 221 5031 if (pParty->pPickedItem.uItemID < ITEM_POTION_CATALYST ||
5019 || (signed int)pParty->pPickedItem.uItemID > 271 5032 pParty->pPickedItem.uItemID > ITEM_POTION_REJUVENATION ||
5020 || (v12 = (LONG)((char *)v0 + 36 * pOut.z), a2.y = v12, v13 = *(int *)(v12 + 532), v51 = v13, v13 < 221) 5033 player->pInventoryItemList[item_pid].uItemID < ITEM_POTION_CATALYST ||
5021 || v13 > 271 ) 5034 player->pInventoryItemList[item_pid].uItemID >= ITEM_POTION_REJUVENATION)
5022 { 5035 {
5023 if ( pParty->pPickedItem.uItemID != 236 5036 if (pParty->pPickedItem.uItemID != ITEM_POTION_HARDEN_ITEM &&
5024 && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250) 5037 (pParty->pPickedItem.uItemID < ITEM_POTION_FLAMING_POTION || pParty->pPickedItem.uItemID > ITEM_POTION_SWIFT_POTION) &&
5025 && pParty->pPickedItem.uItemID != 263 5038 pParty->pPickedItem.uItemID != ITEM_POTION_SLAYING_POTION &&
5026 && pParty->pPickedItem.uItemID != 233 ) 5039 pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM)
5027 goto LABEL_116; 5040 goto LABEL_116;
5028 v27 = &v0->pInventoryItemList[pOut.z]; 5041
5029 v28 = v27->uItemID; 5042 int a2_y;
5043 v27 = &player->pInventoryItemList[item_pid];
5030 v51 = pItemsTable->pItems[v27->uItemID].uEquipType; 5044 v51 = pItemsTable->pItems[v27->uItemID].uEquipType;
5031 v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType); 5045 v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType);
5032 if ( pParty->pPickedItem.uItemID != 233 ) 5046 if ( pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM )
5033 { 5047 {
5034 if ( pParty->pPickedItem.uItemID == 236 ) 5048 if ( pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM )
5035 { 5049 {
5036 v35 = v27->uAttributes; 5050 if (v27->IsBroken() || v51 < EQUIP_OFF_HAND || v51 > EQUIP_WAND || v27->uItemID >= ITEM_ARTIFACT_PUCK )
5037 if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
5038 { 5051 {
5039 pMouse->RemoveHoldingItem(); 5052 pMouse->RemoveHoldingItem();
5040 dword_50CDCC = 1; 5053 no_rightlick_in_inventory = true;
5041 return; 5054 return;
5042 } 5055 }
5043 LOWORD(v35) = v35 | 0x210; 5056 v27->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_ENCHANTED;
5044 v27->uAttributes = v35;
5045 } 5057 }
5046 else 5058 else
5047 { 5059 {
5048 if ( (signed int)pParty->pPickedItem.uItemID <= 245 ) 5060 if (pParty->pPickedItem.uItemID <= ITEM_POTION_ACCURACY_BOOST )
5049 { 5061 {
5050 pMouse->RemoveHoldingItem(); 5062 pMouse->RemoveHoldingItem();
5051 dword_50CDCC = 1; 5063 no_rightlick_in_inventory = true;
5052 return; 5064 return;
5053 } 5065 }
5054 if ( (signed int)pParty->pPickedItem.uItemID <= 250 ) 5066 if (pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION)
5055 { 5067 {
5056 v27->UpdateTempBonus(pParty->uTimePlayed); 5068 v27->UpdateTempBonus(pParty->uTimePlayed);
5057 v33 = v27->uItemID; 5069 if ( (signed int)v27->uItemID >= 64 && (signed int)v27->uItemID <= 65
5058 if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65 5070 || (alchemy_skill = v27->uAttributes, alchemy_skill & 2)
5059 || (pOut.y = v27->uAttributes, pOut.y & 2)
5060 || v27->uSpecEnchantmentType 5071 || v27->uSpecEnchantmentType
5061 || v27->uEnchantmentType 5072 || v27->uEnchantmentType
5062 || v51 && v51 != 1 && v51 != 2 5073 || v51 && v51 != 1 && v51 != 2
5063 || (signed int)v33 >= 500 ) 5074 || (signed int)v27->uItemID >= 500 )
5064 { 5075 {
5065 pMouse->RemoveHoldingItem(); 5076 pMouse->RemoveHoldingItem();
5066 dword_50CDCC = 1; 5077 no_rightlick_in_inventory = 1;
5067 return; 5078 return;
5068 } 5079 }
5069 v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; 5080 v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
5070 a2.y = (int)v29 << 7; 5081 a2_y = (int)v29 << 7;
5071 v31 = (double)(signed int)((int)v29 << 7); 5082 v31 = (double)(signed int)((int)v29 << 7);
5072 v27->uSpecEnchantmentType = v34; 5083 v27->uSpecEnchantmentType = v34;
5073 } 5084 }
5074 else 5085 else
5075 { 5086 {
5076 if ( pParty->pPickedItem.uItemID != 263 5087 if ( pParty->pPickedItem.uItemID != 263
5077 || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64) 5088 || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64)
5078 && (signed int)v30 <= 65 5089 && (signed int)v30 <= 65
5079 || (pOut.y = v27->uAttributes, pOut.y & 2) 5090 || (alchemy_skill = v27->uAttributes, alchemy_skill & 2)
5080 || v27->uSpecEnchantmentType 5091 || v27->uSpecEnchantmentType
5081 || v27->uEnchantmentType 5092 || v27->uEnchantmentType
5082 || v51 && v51 != 1 && v51 != 2 5093 || v51 && v51 != 1 && v51 != 2
5083 || (signed int)v30 >= 500 ) 5094 || (signed int)v30 >= 500 )
5084 { 5095 {
5085 pMouse->RemoveHoldingItem(); 5096 pMouse->RemoveHoldingItem();
5086 dword_50CDCC = 1; 5097 no_rightlick_in_inventory = 1;
5087 return; 5098 return;
5088 } 5099 }
5089 a2.y = (int)v29 << 7; 5100 a2_y = (int)v29 << 7;
5090 v27->uSpecEnchantmentType = 40; 5101 v27->uSpecEnchantmentType = 40;
5091 v31 = (double)a2.y; 5102 v31 = (double)a2_y;
5092 } 5103 }
5093 v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335); 5104 v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335);
5094 LODWORD(v27->uExpireTime) = v32; 5105 LODWORD(v27->uExpireTime) = v32;
5095 LODWORD(v32) = pOut.y; 5106 LODWORD(v32) = alchemy_skill;
5096 LOBYTE(v32) = LOBYTE(pOut.y) | 0x18; 5107 LOBYTE(v32) = LOBYTE(alchemy_skill) | 0x18;
5097 HIDWORD(v27->uExpireTime) = HIDWORD(v32); 5108 HIDWORD(v27->uExpireTime) = HIDWORD(v32);
5098 v27->uAttributes = v32; 5109 v27->uAttributes = v32;
5099 } 5110 }
5100 _50C9A8_item_enchantment_timer = 256; 5111 _50C9A8_item_enchantment_timer = 256;
5101 pMouse->RemoveHoldingItem(); 5112 pMouse->RemoveHoldingItem();
5102 dword_50CDCC = 1; 5113 no_rightlick_in_inventory = 1;
5103 return; 5114 return;
5104 } 5115 }
5105 v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; 5116 v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01;
5106 if ( v36 < 0.0 ) 5117 if ( v36 < 0.0 )
5107 v36 = 0.0; 5118 v36 = 0.0;
5108 if ( v51 != 12 ) 5119 if ( v51 != 12 )
5109 { 5120 {
5110 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); 5121 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
5111 return; 5122 return;
5112 } 5123 }
5113 a2.y = v27->uMaxCharges; 5124 a2_y = v27->uMaxCharges;
5114 v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y); 5125 v37 = (signed __int64)((double)a2_y - v36 * (double)a2_y);
5115 v27->uMaxCharges = v37; 5126 v27->uMaxCharges = v37;
5116 v27->uNumCharges = (unsigned __int8)v37; 5127 v27->uNumCharges = (unsigned __int8)v37;
5117 pMouse->RemoveHoldingItem(); 5128 pMouse->RemoveHoldingItem();
5118 dword_50CDCC = 1; 5129 no_rightlick_in_inventory = 1;
5119 return; 5130 return;
5120 } 5131 }
5121 v14 = v13 - 222; 5132 v14 = player->pInventoryItemList[item_pid].uItemID - 222;
5122 v15 = pParty->pPickedItem.uItemID - 222; 5133 v15 = pParty->pPickedItem.uItemID - 222;
5123 v47 = v14; 5134 v47 = v14;
5124 y.y = 0; 5135
5125 if ( pParty->pPickedItem.uItemID == 221 || v51 == 221 ) 5136 if ( pParty->pPickedItem.uItemID == 221 || player->pInventoryItemList[item_pid].uItemID == 221 )
5126 { 5137 {
5127 v16 = 5; 5138 v16 = 5;
5128 } 5139 }
5129 else 5140 else
5130 { 5141 {
5131 v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388]; 5142 v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388];
5132 v10 = pOut.z; 5143 v10 = item_pid;
5133 } 5144 }
5134 v51 = v16; 5145 v51 = v16;
5135 if ( v45 ) 5146 if ( v9 )
5136 { 5147 {
5137 if ( v16 < 225 || v16 > 227 ) 5148 if ( v16 < 225 || v16 > 227 )
5138 { 5149 {
5139 if ( v16 < 228 || v16 > 239 ) 5150 if ( v16 < 228 || v16 > 239 )
5140 { 5151 {
5141 if ( v16 < 240 || v16 > 261 ) 5152 if ( v16 < 240 || v16 > 261 )
5142 { 5153 {
5143 if ( v16 >= 262 && pOut.y != 4 ) 5154 if ( v16 >= 262 && alchemy_level != 4 )
5144 { 5155 {
5145 LABEL_53: 5156 LABEL_53:
5146 v51 = 4; 5157 v51 = 4;
5147 goto LABEL_54; 5158 goto LABEL_54;
5148 } 5159 }
5149 } 5160 }
5150 else 5161 else
5151 { 5162 {
5152 if ( pOut.y <= 2 ) 5163 if ( alchemy_level <= 2 )
5153 { 5164 {
5154 LABEL_38: 5165 LABEL_38:
5155 v51 = 3; 5166 v51 = 3;
5156 goto LABEL_54; 5167 goto LABEL_54;
5157 } 5168 }
5158 } 5169 }
5159 } 5170 }
5160 else 5171 else
5161 { 5172 {
5162 if ( pOut.y == 1 ) 5173 if ( alchemy_level == 1 )
5163 { 5174 {
5164 LABEL_35: 5175 LABEL_35:
5165 v51 = 2; 5176 v51 = 2;
5166 goto LABEL_54; 5177 goto LABEL_54;
5167 } 5178 }
5181 goto LABEL_38; 5192 goto LABEL_38;
5182 if ( v16 >= 262 ) 5193 if ( v16 >= 262 )
5183 goto LABEL_53; 5194 goto LABEL_53;
5184 } 5195 }
5185 LABEL_54: 5196 LABEL_54:
5186 pOut.y = 0; 5197 int pOut_y = 0;
5187 pOut.x = v10 + 1; 5198 int pOut_x = v10 + 1;
5188 v17 = (int)v0->pInventoryMatrix; 5199 v17 = (int)player->pInventoryMatrix;
5189 while ( *(int *)v17 != pOut.x ) 5200 while ( *(int *)v17 != pOut_x )
5190 { 5201 {
5191 ++pOut.y; 5202 ++pOut_y;
5192 v17 += 4; 5203 v17 += 4;
5193 if ( pOut.y >= 126 ) 5204 if ( pOut_y >= 126 )
5194 { 5205 {
5195 v18 = y.y; 5206 v18 = pOut_y;
5196 goto LABEL_59; 5207 goto LABEL_59;
5197 } 5208 }
5198 } 5209 }
5199 v18 = pOut.y; 5210 v18 = pOut_y;
5200 LABEL_59: 5211 LABEL_59:
5201 if ( !v51 ) 5212 if ( !v51 )
5202 { 5213 {
5203 LABEL_115: 5214 LABEL_115:
5204 v10 = pOut.z; 5215 v10 = item_pid;
5205 goto LABEL_116; 5216 goto LABEL_116;
5206 } 5217 }
5207 if ( v51 == 1 ) 5218 if ( v51 == 1 )
5208 { 5219 {
5209 v0->RemoveItemAtInventoryIndex(v18); 5220 player->RemoveItemAtInventoryIndex(v18);
5210 v26 = rand(); 5221 v26 = rand();
5211 v0->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE); 5222 player->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE);
5212 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); 5223 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
5213 5224
5214 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); 5225 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
5215 5226
5216 v42 = (int *)&a2.y;
5217 v41 = (int *)&y.y;
5218 v40 = (int *)&pOut;
5219 v39.z = pParty->vPosition.z + pParty->sEyelevel; 5227 v39.z = pParty->vPosition.z + pParty->sEyelevel;
5220 } 5228 }
5221 else 5229 else
5222 { 5230 {
5223 if ( v51 == 2 ) 5231 if ( v51 == 2 )
5224 { 5232 {
5225 v0->RemoveItemAtInventoryIndex(v18); 5233 player->RemoveItemAtInventoryIndex(v18);
5226 v25 = rand(); 5234 v25 = rand();
5227 v0->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE); 5235 player->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE);
5228 v23 = 1; 5236 v23 = 1;
5229 } 5237 }
5230 else 5238 else
5231 { 5239 {
5232 if ( v51 == 3 ) 5240 if ( v51 == 3 )
5233 { 5241 {
5234 v0->RemoveItemAtInventoryIndex(v18); 5242 player->RemoveItemAtInventoryIndex(v18);
5235 v24 = rand(); 5243 v24 = rand();
5236 v0->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE); 5244 player->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE);
5237 v23 = 5; 5245 v23 = 5;
5238 } 5246 }
5239 else 5247 else
5240 { 5248 {
5241 if ( v51 != 4 ) 5249 if ( v51 != 4 )
5242 { 5250 {
5243 if ( v51 != 5 ) 5251 if ( v51 != 5 )
5244 { 5252 {
5245 v19 = v0->AddItem(-1, 0xDCu); 5253 v19 = player->AddItem(-1, 0xDCu);
5246 if ( v19 ) 5254 if ( v19 )
5247 // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; 5255 // *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
5248 v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED; 5256 player->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED;
5249 v20 = v47 + 50 * v15; 5257 v20 = v47 + 50 * v15;
5250 v0->pInventoryItemList[pOut.z].uItemID = v51; 5258 player->pInventoryItemList[item_pid].uItemID = v51;
5251 v0->pInventoryItemList[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType 5259 player->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType
5252 + v0->pInventoryItemList[pOut.z].uEnchantmentType) 5260 + player->pInventoryItemList[item_pid].uEnchantmentType)
5253 / 2; 5261 / 2;
5254 v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 5262 player->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388
5255 LABEL_74: 5263 LABEL_74:
5256 v22 = (int)((char *)v0 + 36 * pOut.z); 5264 v22 = (int)((char *)player + 36 * item_pid);
5257 if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) 5265 if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) )
5258 *(int *)(v22 + 552) |= 1u; 5266 *(int *)(v22 + 552) |= 1u;
5259 if ( !dword_4E455C ) 5267 if ( !dword_4E455C )
5260 { 5268 {
5261 pMouse->RemoveHoldingItem(); 5269 pMouse->RemoveHoldingItem();
5262 dword_50CDCC = 1; 5270 no_rightlick_in_inventory = 1;
5263 return; 5271 return;
5264 } 5272 }
5265 v0->PlaySound(SPEECH_16, 0); 5273 player->PlaySound(SPEECH_16, 0);
5266 dword_4E455C = 0; 5274 dword_4E455C = 0;
5267 pMouse->RemoveHoldingItem(); 5275 pMouse->RemoveHoldingItem();
5268 dword_50CDCC = 1; 5276 no_rightlick_in_inventory = 1;
5269 return; 5277 return;
5270 } 5278 }
5271 if ( v45 ) 5279 if ( v9 )
5272 { 5280 {
5273 if ( *(int *)(a2.y + 532) == 221 ) 5281 if ( *(int *)(player + 36 * item_pid + 532) == 221 )
5274 *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID; 5282 *(int *)(player + 36 * item_pid + 532) = pParty->pPickedItem.uItemID;
5275 else 5283 else
5276 *(int *)(a2.y + 536) = pParty->pPickedItem.uEnchantmentType; 5284 *(int *)(player + 36 * item_pid + 536) = pParty->pPickedItem.uEnchantmentType;
5277 v21 = v0->AddItem(-1, 0xDCu); 5285 v21 = player->AddItem(-1, 0xDCu);
5278 if ( v21 ) 5286 if ( v21 )
5279 //*(int *)&v0->field_1F5[36 * v21 + 15] = 1; 5287 //*(int *)&v0->field_1F5[36 * v21 + 15] = 1;
5280 v0->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED; 5288 player->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED;
5281 goto LABEL_74; 5289 goto LABEL_74;
5282 } 5290 }
5283 goto LABEL_115; 5291 goto LABEL_115;
5284 } 5292 }
5285 v0->RemoveItemAtInventoryIndex(v18); 5293 player->RemoveItemAtInventoryIndex(v18);
5286 v0->SetCondition(0x10u, 0); 5294 player->SetCondition(0x10u, 0);
5287 v23 = 0; 5295 v23 = 0;
5288 } 5296 }
5289 } 5297 }
5290 v0->ItemsEnchant(v23); 5298 player->ItemsEnchant(v23);
5291 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); 5299 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
5292 5300
5293 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); 5301 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
5294 5302
5295 v42 = (int *)&a2.y;
5296 v41 = (int *)&y.y;
5297 v40 = (int *)&pOut;
5298 v39.z = pParty->vPosition.z + pParty->sEyelevel; 5303 v39.z = pParty->vPosition.z + pParty->sEyelevel;
5299 } 5304 }
5300 *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x; 5305 v39.x = pParty->vPosition.x;
5301 Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42); 5306 v39.y = pParty->vPosition.y;
5302 sub_42F7EB_DropItemAt(0x41Bu, pOut.x, y.y, a2.y, 0, 1, 0, 0, 0); 5307
5308 int rot_x, rot_y, rot_z;
5309 Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, &rot_x, &rot_y, &rot_z);
5310 sub_42F7EB_DropItemAt(0x41Bu, rot_x, rot_y, rot_z, 0, 1, 0, 0, 0);
5303 if ( dword_4E455C ) 5311 if ( dword_4E455C )
5304 { 5312 {
5305 if ( v0->CanAct() ) 5313 if ( player->CanAct() )
5306 v0->PlaySound(SPEECH_17, 0); 5314 player->PlaySound(SPEECH_17, 0);
5307 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u); 5315 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
5308 dword_4E455C = 0; 5316 dword_4E455C = 0;
5309 } 5317 }
5310 pMouse->RemoveHoldingItem(); 5318 pMouse->RemoveHoldingItem();
5311 dword_50CDCC = 1; 5319 no_rightlick_in_inventory = 1;
5312 return; 5320 return;
5313 } 5321 }
5314 *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice; 5322
5323 player->pInventoryItemList[item_pid].uEnchantmentType = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
5315 switch ( pParty->pPickedItem.uItemID ) 5324 switch ( pParty->pPickedItem.uItemID )
5316 { 5325 {
5317 case 0xC8u: 5326 case 0xC8u:
5318 case 0xC9u: 5327 case 0xC9u:
5319 case 0xCAu: 5328 case 0xCAu:
5320 case 0xCBu: 5329 case 0xCBu:
5321 case 0xCCu: 5330 case 0xCCu:
5322 v0->pInventoryItemList[pOut.z].uItemID = 222; 5331 player->pInventoryItemList[item_pid].uItemID = 222;
5323 break; 5332 break;
5324 case 0xCDu: 5333 case 0xCDu:
5325 case 0xCEu: 5334 case 0xCEu:
5326 case 0xCFu: 5335 case 0xCFu:
5327 case 0xD0u: 5336 case 0xD0u:
5328 case 0xD1u: 5337 case 0xD1u:
5329 v0->pInventoryItemList[pOut.z].uItemID = 223; 5338 player->pInventoryItemList[item_pid].uItemID = 223;
5330 break; 5339 break;
5331 case 0xD2u: 5340 case 0xD2u:
5332 case 0xD3u: 5341 case 0xD3u:
5333 case 0xD4u: 5342 case 0xD4u:
5334 case 0xD5u: 5343 case 0xD5u:
5335 case 0xD6u: 5344 case 0xD6u:
5336 v0->pInventoryItemList[pOut.z].uItemID = 224; 5345 player->pInventoryItemList[item_pid].uItemID = 224;
5337 break; 5346 break;
5338 case 0xD7u: 5347 case 0xD7u:
5339 case 0xD8u: 5348 case 0xD8u:
5340 case 0xD9u: 5349 case 0xD9u:
5341 case 0xDAu: 5350 case 0xDAu:
5342 case 0xDBu: 5351 case 0xDBu:
5343 v0->pInventoryItemList[pOut.z].uItemID = 221; 5352 player->pInventoryItemList[item_pid].uItemID = 221;
5344 break; 5353 break;
5345 default: 5354 default:
5346 break; 5355 break;
5347 } 5356 }
5348 pMouse->RemoveHoldingItem(); 5357 pMouse->RemoveHoldingItem();
5349 dword_50CDCC = 1; 5358 no_rightlick_in_inventory = 1;
5350 if ( dword_4E455C ) 5359 if ( dword_4E455C )
5351 { 5360 {
5352 v0->PlaySound(SPEECH_16, 0); 5361 player->PlaySound(SPEECH_16, 0);
5353 dword_4E455C = 0; 5362 dword_4E455C = 0;
5354 } 5363 }
5355 } 5364 }
5356 5365
5357 //----- (00417AD4) -------------------------------------------------------- 5366 //----- (00417AD4) --------------------------------------------------------
5393 return ui_character_skillinfo_cant_learn; 5402 return ui_character_skillinfo_cant_learn;
5394 return ui_character_skillinfo_can_learn; 5403 return ui_character_skillinfo_can_learn;
5395 } 5404 }
5396 break; 5405 break;
5397 } 5406 }
5398 assert(false); 5407 Error("Invalid player class: %u", uPlayerClass);
5399 return 0;
5400 } 5408 }