Mercurial > mm7
comparison mm7_5.cpp @ 1729:f44b6e02e81c
pop-up window in character(paperdill) window, alchemy
author | Ritor1 |
---|---|
date | Wed, 25 Sep 2013 17:29:14 +0600 |
parents | 2c38e17e5a3f |
children | 421c29d4ab3e |
comparison
equal
deleted
inserted
replaced
1728:7b6b4ce8da76 | 1729:f44b6e02e81c |
---|---|
4902 { | 4902 { |
4903 MainMenuUI_LoadFontsAndSomeStuff(); | 4903 MainMenuUI_LoadFontsAndSomeStuff(); |
4904 DrawCopyrightWindow(); | 4904 DrawCopyrightWindow(); |
4905 } | 4905 } |
4906 | 4906 |
4907 | |
4908 int no_rightlick_in_inventory = false; // 0050CDCC | |
4909 //----- (00416196) -------------------------------------------------------- | |
4910 void OnInventoryItemRightClick() | |
4911 { | |
4912 int v7; // eax@7 | |
4913 int v9; // edi@10 | |
4914 int v14; // edx@25 | |
4915 unsigned int v15; // edi@25 | |
4916 signed int v16; // edx@27 | |
4917 int v17; // eax@54 | |
4918 unsigned int v18; // edx@57 | |
4919 int v19; // eax@65 | |
4920 int v20; // edi@67 | |
4921 int v21; // eax@72 | |
4922 int v22; // ecx@74 | |
4923 int v23; // edx@78 | |
4924 int v24; // eax@79 | |
4925 int v25; // eax@80 | |
4926 int v26; // eax@84 | |
4927 ItemGen *v27; // esi@98 | |
4928 double v31; // st7@112 | |
4929 double v36; // st7@132 | |
4930 signed __int64 v37; // qax@135 | |
4931 Vec3_int_ v39; // [sp-18h] [bp-A8h]@83 | |
4932 GUIWindow v43; // [sp+Ch] [bp-84h]@137 | |
4933 int v45; // [sp+64h] [bp-2Ch]@10 | |
4934 POINT a2; // [sp+78h] [bp-18h]@2 | |
4935 unsigned int v51; // [sp+8Ch] [bp-4h]@23 | |
4936 | |
4937 if (no_rightlick_in_inventory) | |
4938 return; | |
4939 | |
4940 pMouse->GetCursorPos(&a2); | |
4941 if (a2.x <= 13 || a2.x >= 462) | |
4942 return; | |
4943 | |
4944 int item_pid = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; | |
4945 if (!item_pid) | |
4946 { | |
4947 int inventory_mouse_x = a2.x - 14; | |
4948 int inventory_mouse_y = a2.y - 17; | |
4949 | |
4950 int mouse_cell_x = inventory_mouse_x / 32; | |
4951 int mouse_cell_y = inventory_mouse_y / 32; | |
4952 | |
4953 if (mouse_cell_x + mouse_cell_y < 0) | |
4954 return; | |
4955 | |
4956 int inventory_idx = mouse_cell_x + 14 * mouse_cell_y; | |
4957 if (inventory_idx > 126) | |
4958 return; | |
4959 | |
4960 v7 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&inventory_idx); | |
4961 if (v7 == 0) | |
4962 return; | |
4963 | |
4964 item_pid = v7; | |
4965 } | |
4966 | |
4967 if (!pPlayers[uActiveCharacter]->CanAct()) | |
4968 { | |
4969 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//%s не в состоянии %s Опознать предметы | |
4970 v43.Hint = pTmpBuf.data(); | |
4971 v43.uFrameWidth = 384; | |
4972 v43.uFrameHeight = 180; | |
4973 if (a2.x <= 320 ) | |
4974 v43.uFrameX = a2.x + 30; | |
4975 else | |
4976 v43.uFrameX = a2.x - 414; | |
4977 v43.uFrameY = 40; | |
4978 v43.DrawMessageBox(0); | |
4979 return; | |
4980 } | |
4981 | |
4982 --item_pid; | |
4983 int alchemy_level = (int8_t)pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY); | |
4984 v9 = alchemy_level & 0x3F; | |
4985 //v45 = alchemy_level & 0x3F; | |
4986 int alchemy_skill = SkillToMastery(alchemy_level); | |
4987 | |
4988 auto item = &pPlayers[uActiveCharacter]->pInventoryItemList[item_pid]; | |
4989 if (pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE) | |
4990 { | |
4991 GameUI_DrawItemInfo(item); | |
4992 return; | |
4993 } | |
4994 | |
4995 if (pParty->pPickedItem.uItemID == ITEM_POTION_RECHARGE_ITEM) | |
4996 { | |
4997 if (item->uItemID != ITEM_POTION_BOTTLE && // cant recharge bottle | |
4998 item->uItemID < ITEM_POTION_CATALYST && // cant recharge | |
4999 item->uItemID > ITEM_POTION_REJUVENATION) // all potions | |
5000 { | |
5001 if (item->GetItemEquipType() != EQUIP_WAND) // can recharge only wands | |
5002 { | |
5003 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
5004 return; | |
5005 } | |
5006 | |
5007 v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; | |
5008 if ( v36 < 0.0 ) | |
5009 v36 = 0.0; | |
5010 v37 = (signed __int64)((double)item->uMaxCharges - v36 * (double)item->uMaxCharges); | |
5011 item->uMaxCharges = v37; | |
5012 item->uNumCharges = v37; | |
5013 | |
5014 pMouse->RemoveHoldingItem(); | |
5015 no_rightlick_in_inventory = 1; | |
5016 return; | |
5017 } | |
5018 GameUI_DrawItemInfo(item); | |
5019 return; | |
5020 } | |
5021 | |
5022 else if (pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM) | |
5023 { | |
5024 if (item->uItemID != ITEM_POTION_BOTTLE && // cant harden bottle | |
5025 item->uItemID < ITEM_POTION_CATALYST && // cant harden | |
5026 item->uItemID > ITEM_POTION_REJUVENATION) // all potions | |
5027 { | |
5028 if (item->IsBroken() || // cant harden broken items | |
5029 item->uItemID >= ITEM_ARTIFACT_PUCK || // cant harden artifacts | |
5030 item->GetItemEquipType() < EQUIP_OFF_HAND || | |
5031 item->GetItemEquipType() > EQUIP_WAND) | |
5032 goto __invalid_item; | |
5033 | |
5034 item->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_HARDENED; | |
5035 | |
5036 _50C9A8_item_enchantment_timer = 256; | |
5037 pMouse->RemoveHoldingItem(); | |
5038 no_rightlick_in_inventory = true; | |
5039 return; | |
5040 } | |
5041 GameUI_DrawItemInfo(item); | |
5042 return; | |
5043 } | |
5044 | |
5045 else if (pParty->pPickedItem.uItemID >= ITEM_POTION_FLAMING_POTION && | |
5046 pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION || | |
5047 pParty->pPickedItem.uItemID == ITEM_POTION_SLAYING_POTION) | |
5048 { | |
5049 if (item->uItemID != ITEM_POTION_BOTTLE && // cant enchant bottle | |
5050 item->uItemID < ITEM_POTION_CATALYST && // cant enchant | |
5051 item->uItemID > ITEM_POTION_REJUVENATION) // all potions | |
5052 { | |
5053 if (item->uItemID >= ITEM_BLASTER && item->uItemID <= ITEM_LASER_RIFLE || | |
5054 item->uItemID >= ITEM_ARTIFACT_PUCK || | |
5055 item->IsBroken() || | |
5056 item->uSpecEnchantmentType || | |
5057 item->uEnchantmentType || | |
5058 item->GetItemEquipType() >= EQUIP_ARMOUR) // only melee weapons and bows | |
5059 goto __invalid_item; | |
5060 | |
5061 item->UpdateTempBonus(pParty->uTimePlayed); | |
5062 if (pParty->pPickedItem.uItemID == ITEM_POTION_SLAYING_POTION) | |
5063 { | |
5064 item->uSpecEnchantmentType = 40; // of Slaying | |
5065 v31 = (double)(1800 * pParty->pPickedItem.uEnchantmentType * 128); | |
5066 } | |
5067 else | |
5068 { | |
5069 static int _4E2904_enchantment_by_potion_lut[] = | |
5070 { | |
5071 164, 93, 22, | |
5072 164, 93, 22, | |
5073 11, 5, 13, 7, 59 | |
5074 }; | |
5075 item->uSpecEnchantmentType = _4E2904_enchantment_by_potion_lut[pParty->pPickedItem.uItemID - 240]; | |
5076 v31 = (double)(1800 * pParty->pPickedItem.uEnchantmentType * 128); | |
5077 } | |
5078 | |
5079 v27->uExpireTime = pParty->uTimePlayed + v31 * 0.033333335; | |
5080 v27->uAttributes = alchemy_skill | 0x18; | |
5081 | |
5082 _50C9A8_item_enchantment_timer = 256; | |
5083 pMouse->RemoveHoldingItem(); | |
5084 no_rightlick_in_inventory = true; | |
5085 return; | |
5086 } | |
5087 GameUI_DrawItemInfo(item); | |
5088 return; | |
5089 } | |
5090 | |
5091 | |
5092 | |
5093 if (pParty->pPickedItem.uItemID < ITEM_REAGENT_WIDOWSWEEP_BERRIES || | |
5094 pParty->pPickedItem.uItemID > ITEM_REAGENT_PHILOSOPHERS_STONE || | |
5095 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID != ITEM_POTION_BOTTLE) | |
5096 { | |
5097 if (pParty->pPickedItem.uItemID < ITEM_POTION_CATALYST || | |
5098 pParty->pPickedItem.uItemID > ITEM_POTION_REJUVENATION || | |
5099 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID < ITEM_POTION_CATALYST || | |
5100 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID > ITEM_POTION_REJUVENATION) | |
5101 { | |
5102 if (pParty->pPickedItem.uItemID != ITEM_POTION_HARDEN_ITEM && | |
5103 (pParty->pPickedItem.uItemID < ITEM_POTION_FLAMING_POTION || pParty->pPickedItem.uItemID > ITEM_POTION_SWIFT_POTION) && | |
5104 pParty->pPickedItem.uItemID != ITEM_POTION_SLAYING_POTION && | |
5105 pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM) | |
5106 GameUI_DrawItemInfo(item); | |
5107 return; | |
5108 } | |
5109 | |
5110 // src not reagent, dst not bottle | |
5111 // src potion, dst potion | |
5112 | |
5113 v14 = item->uItemID - ITEM_POTION_CURE_WOUNDS; | |
5114 v15 = pParty->pPickedItem.uItemID - ITEM_POTION_CURE_WOUNDS; | |
5115 | |
5116 if ( pParty->pPickedItem.uItemID == ITEM_POTION_CATALYST || | |
5117 item->uItemID == ITEM_POTION_CATALYST ) | |
5118 { | |
5119 v16 = 5; | |
5120 } | |
5121 else | |
5122 { | |
5123 v16 = pItemsTable->potion_data[v15][v14 + 2]; | |
5124 } | |
5125 v51 = v16; | |
5126 if ( v9 ) | |
5127 { | |
5128 if ( v16 < ITEM_POTION_CURE_DISEASE || v16 > ITEM_POTION_AWAKEN ) | |
5129 { | |
5130 if ( v16 < ITEM_POTION_HASTE || v16 > ITEM_POTION_CURE_INSANITY ) | |
5131 { | |
5132 if ( v16 < ITEM_POTION_MIGHT_BOOST || v16 > ITEM_POTION_BODY_RESISTANE ) | |
5133 { | |
5134 if ( v16 >= ITEM_POTION_STONE_TO_FLESH && alchemy_level != 4 ) | |
5135 { | |
5136 LABEL_53: | |
5137 v51 = 4; | |
5138 goto LABEL_54; | |
5139 } | |
5140 } | |
5141 else | |
5142 { | |
5143 if ( alchemy_level <= 2 ) | |
5144 { | |
5145 LABEL_38: | |
5146 v51 = 3; | |
5147 goto LABEL_54; | |
5148 } | |
5149 } | |
5150 } | |
5151 else | |
5152 { | |
5153 if ( alchemy_level == 1 ) | |
5154 { | |
5155 LABEL_35: | |
5156 v51 = 2; | |
5157 goto LABEL_54; | |
5158 } | |
5159 } | |
5160 } | |
5161 } | |
5162 else | |
5163 { | |
5164 if ( v16 >= ITEM_POTION_CURE_DISEASE && v16 <= ITEM_POTION_AWAKEN ) | |
5165 { | |
5166 v51 = 1; | |
5167 goto LABEL_54; | |
5168 } | |
5169 if ( v16 >= ITEM_POTION_HASTE && v16 <= ITEM_POTION_CURE_INSANITY ) | |
5170 goto LABEL_35; | |
5171 if ( v16 >= ITEM_POTION_MIGHT_BOOST && v16 <= ITEM_POTION_BODY_RESISTANE ) | |
5172 goto LABEL_38; | |
5173 if ( v16 >= ITEM_POTION_STONE_TO_FLESH ) | |
5174 goto LABEL_53; | |
5175 } | |
5176 LABEL_54: | |
5177 int pOut_y = 0; | |
5178 int pOut_x = item_pid + 1; | |
5179 v17 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix; | |
5180 while ( *(int *)v17 != pOut_x ) | |
5181 { | |
5182 ++pOut_y; | |
5183 v17 += 4; | |
5184 if ( pOut_y >= 126 ) | |
5185 { | |
5186 v18 = pOut_y; | |
5187 goto LABEL_59; | |
5188 } | |
5189 } | |
5190 v18 = pOut_y; | |
5191 LABEL_59: | |
5192 if ( !v51 ) | |
5193 GameUI_DrawItemInfo(item); | |
5194 return; | |
5195 if ( v51 == 1 ) | |
5196 { | |
5197 pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18); | |
5198 v26 = rand(); | |
5199 pPlayers[uActiveCharacter]->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE); | |
5200 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); | |
5201 | |
5202 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
5203 | |
5204 v39.z = pParty->vPosition.z + pParty->sEyelevel; | |
5205 } | |
5206 else | |
5207 { | |
5208 if ( v51 == 2 ) | |
5209 { | |
5210 pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18); | |
5211 v25 = rand(); | |
5212 pPlayers[uActiveCharacter]->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE); | |
5213 v23 = 1; | |
5214 } | |
5215 else | |
5216 { | |
5217 if ( v51 == 3 ) | |
5218 { | |
5219 pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18); | |
5220 v24 = rand(); | |
5221 pPlayers[uActiveCharacter]->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE); | |
5222 v23 = 5; | |
5223 } | |
5224 else | |
5225 { | |
5226 if ( v51 != 4 ) | |
5227 { | |
5228 if ( v51 != 5 ) | |
5229 { | |
5230 v19 = pPlayers[uActiveCharacter]->AddItem(-1, 0xDCu); | |
5231 if ( v19 ) | |
5232 // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; | |
5233 pPlayers[uActiveCharacter]->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED; | |
5234 v20 = v14 + 50 * v15; | |
5235 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = v51; | |
5236 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType | |
5237 + pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uEnchantmentType) | |
5238 / 2; | |
5239 pPlayers[uActiveCharacter]->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 | |
5240 LABEL_74: | |
5241 v22 = (int)((char *)pPlayers[uActiveCharacter] + 36 * item_pid); | |
5242 if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) | |
5243 *(int *)(v22 + 552) |= 1u; | |
5244 if ( !dword_4E455C ) | |
5245 { | |
5246 pMouse->RemoveHoldingItem(); | |
5247 no_rightlick_in_inventory = 1; | |
5248 return; | |
5249 } | |
5250 pPlayers[uActiveCharacter]->PlaySound(SPEECH_16, 0); | |
5251 dword_4E455C = 0; | |
5252 pMouse->RemoveHoldingItem(); | |
5253 no_rightlick_in_inventory = 1; | |
5254 return; | |
5255 } | |
5256 if ( v9 ) | |
5257 { | |
5258 if ( *(int *)(pPlayers[uActiveCharacter] + 36 * item_pid + 532) == 221 ) | |
5259 *(int *)(pPlayers[uActiveCharacter] + 36 * item_pid + 532) = pParty->pPickedItem.uItemID; | |
5260 else | |
5261 *(int *)(pPlayers[uActiveCharacter] + 36 * item_pid + 536) = pParty->pPickedItem.uEnchantmentType; | |
5262 v21 = pPlayers[uActiveCharacter]->AddItem(-1, 0xDCu); | |
5263 if ( v21 ) | |
5264 //*(int *)&v0->field_1F5[36 * v21 + 15] = 1; | |
5265 pPlayers[uActiveCharacter]->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED; | |
5266 goto LABEL_74; | |
5267 } | |
5268 GameUI_DrawItemInfo(item); | |
5269 return; | |
5270 } | |
5271 pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18); | |
5272 pPlayers[uActiveCharacter]->SetCondition(0x10u, 0); | |
5273 v23 = 0; | |
5274 } | |
5275 } | |
5276 pPlayers[uActiveCharacter]->ItemsEnchant(v23); | |
5277 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); | |
5278 | |
5279 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
5280 | |
5281 v39.z = pParty->vPosition.z + pParty->sEyelevel; | |
5282 } | |
5283 v39.x = pParty->vPosition.x; | |
5284 v39.y = pParty->vPosition.y; | |
5285 | |
5286 int rot_x, rot_y, rot_z; | |
5287 Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, &rot_x, &rot_y, &rot_z); | |
5288 sub_42F7EB_DropItemAt(0x41Bu, rot_x, rot_y, rot_z, 0, 1, 0, 0, 0); | |
5289 if ( dword_4E455C ) | |
5290 { | |
5291 if ( pPlayers[uActiveCharacter]->CanAct() ) | |
5292 pPlayers[uActiveCharacter]->PlaySound(SPEECH_17, 0); | |
5293 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u); | |
5294 dword_4E455C = 0; | |
5295 } | |
5296 pMouse->RemoveHoldingItem(); | |
5297 no_rightlick_in_inventory = 1; | |
5298 return; | |
5299 } | |
5300 | |
5301 // end alchemy | |
5302 | |
5303 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uEnchantmentType = v9 + pParty->pPickedItem.GetDamageDice(); | |
5304 switch ( pParty->pPickedItem.uItemID ) | |
5305 { | |
5306 case 0xC8u: | |
5307 case 0xC9u: | |
5308 case 0xCAu: | |
5309 case 0xCBu: | |
5310 case 0xCCu: | |
5311 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 222; | |
5312 break; | |
5313 case 0xCDu: | |
5314 case 0xCEu: | |
5315 case 0xCFu: | |
5316 case 0xD0u: | |
5317 case 0xD1u: | |
5318 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 223; | |
5319 break; | |
5320 case 0xD2u: | |
5321 case 0xD3u: | |
5322 case 0xD4u: | |
5323 case 0xD5u: | |
5324 case 0xD6u: | |
5325 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 224; | |
5326 break; | |
5327 case 0xD7u: | |
5328 case 0xD8u: | |
5329 case 0xD9u: | |
5330 case 0xDAu: | |
5331 case 0xDBu: | |
5332 pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 221; | |
5333 break; | |
5334 default: | |
5335 break; | |
5336 } | |
5337 pMouse->RemoveHoldingItem(); | |
5338 no_rightlick_in_inventory = 1; | |
5339 if ( dword_4E455C ) | |
5340 { | |
5341 pPlayers[uActiveCharacter]->PlaySound(SPEECH_16, 0); | |
5342 dword_4E455C = 0; | |
5343 } | |
5344 return; | |
5345 | |
5346 | |
5347 __invalid_item: | |
5348 pMouse->RemoveHoldingItem(); | |
5349 no_rightlick_in_inventory = true; | |
5350 return; | |
5351 } | |
5352 | |
5353 //----- (00417AD4) -------------------------------------------------------- | 4907 //----- (00417AD4) -------------------------------------------------------- |
5354 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) | 4908 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) |
5355 { | 4909 { |
5356 switch (uPlayerClass % 4) | 4910 switch (uPlayerClass % 4) |
5357 { | 4911 { |