Mercurial > mm7
diff mm7_5.cpp @ 1576:e66e0c89d81b
More OnInventoryItemRightClick (not finished)
author | Nomad |
---|---|
date | Tue, 10 Sep 2013 12:54:07 +0200 |
parents | 43d3536a20f7 |
children | 1b6217e07b26 |
line wrap: on
line diff
--- a/mm7_5.cpp Mon Sep 09 20:09:01 2013 +0200 +++ b/mm7_5.cpp Tue Sep 10 12:54:07 2013 +0200 @@ -4920,7 +4920,7 @@ int v7; // eax@7 //unsigned __int16 v8; // ax@10 int v9; // edi@10 - int v10; // eax@10 + //int v10; // eax@10 //int v11; // edx@13 //LONG v12; // edx@23 //signed int v13; // edx@23 @@ -4939,12 +4939,12 @@ int v26; // eax@84 ItemGen *v27; // esi@98 //unsigned int v28; // eax@98 - ItemGen *v29; // edi@98 - unsigned int v30; // ecx@103 + //ItemGen *v29; // edi@98 + //unsigned int v30; // ecx@103 double v31; // st7@112 - unsigned __int64 v32; // qax@113 + //unsigned __int64 v32; // qax@113 //unsigned int v33; // ecx@117 - int v34; // eax@126 + //int v34; // eax@126 //unsigned int v35; // ecx@127 double v36; // st7@132 signed __int64 v37; // qax@135 @@ -4957,7 +4957,7 @@ //unsigned int pY; // [sp+60h] [bp-30h]@2 int v45; // [sp+64h] [bp-2Ch]@10 //unsigned int pX; // [sp+68h] [bp-28h]@2 - int v47; // [sp+6Ch] [bp-24h]@25 + //int v47; // [sp+6Ch] [bp-24h]@25 //POINT y; // [sp+70h] [bp-20h]@2 POINT a2; // [sp+78h] [bp-18h]@2 //Vec3_int_ pOut; // [sp+80h] [bp-10h]@2 @@ -5016,14 +5016,107 @@ v9 = alchemy_level & 0x3F; //v45 = alchemy_level & 0x3F; int alchemy_skill = SkillToMastery(alchemy_level); - v10 = item_pid; - if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE ) + + auto item = &player->pInventoryItemList[item_pid]; + if (pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE) { LABEL_116: - GameUI_DrawItemInfo(&player->pInventoryItemList[v10]); + GameUI_DrawItemInfo(item); return; } + if (pParty->pPickedItem.uItemID == ITEM_POTION_RECHARGE_ITEM) + { + if (item->uItemID != ITEM_POTION_BOTTLE && // cant recharge bottle + item->uItemID < ITEM_POTION_CATALYST && // cant recharge + item->uItemID > ITEM_POTION_REJUVENATION) // all potions + { + if (pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_WAND) // can recharge only wands + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + + v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; + if ( v36 < 0.0 ) + v36 = 0.0; + v37 = (signed __int64)((double)item->uMaxCharges - v36 * (double)item->uMaxCharges); + item->uMaxCharges = v37; + item->uNumCharges = v37; + + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = 1; + return; + } + } + + else if (pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM) + { + if (item->uItemID != ITEM_POTION_BOTTLE && // cant harden bottle + item->uItemID < ITEM_POTION_CATALYST && // cant harden + item->uItemID > ITEM_POTION_REJUVENATION) // all potions + { + if (item->IsBroken() || // cant harden broken items + item->uItemID >= ITEM_ARTIFACT_PUCK || // cant harden artifacts + pItemsTable->pItems[item->uItemID].uEquipType < EQUIP_OFF_HAND || + pItemsTable->pItems[item->uItemID].uEquipType > EQUIP_WAND) + goto __invalid_item; + + item->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_ENCHANTED; + + _50C9A8_item_enchantment_timer = 256; + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; + } + } + + else if (pParty->pPickedItem.uItemID >= ITEM_POTION_FLAMING_POTION && + pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION || + pParty->pPickedItem.uItemID == ITEM_POTION_SLAYING_POTION) + { + if (item->uItemID != ITEM_POTION_BOTTLE && // cant enchant bottle + item->uItemID < ITEM_POTION_CATALYST && // cant enchant + item->uItemID > ITEM_POTION_REJUVENATION) // all potions + { + if (item->uItemID >= ITEM_BLASTER && item->uItemID <= ITEM_LASER_RIFLE || + item->uItemID >= ITEM_ARTIFACT_PUCK || + item->IsBroken() || + item->uSpecEnchantmentType || + item->uEnchantmentType || + pItemsTable->pItems[item->uItemID].uEquipType >= EQUIP_ARMOUR) // only melee weapons and bows + goto __invalid_item; + + item->UpdateTempBonus(pParty->uTimePlayed); + if (pParty->pPickedItem.uItemID == ITEM_POTION_SLAYING_POTION) + { + item->uSpecEnchantmentType = 40; // of Slaying + v31 = (double)(1800 * pParty->pPickedItem.uEnchantmentType * 128); + } + else + { + static int _4E2904_enchantment_by_potion_lut[] = + { + 164, 93, 22, + 164, 93, 22, + 11, 5, 13, 7, 59 + }; + item->uSpecEnchantmentType = _4E2904_enchantment_by_potion_lut[pParty->pPickedItem.uItemID - 240]; + v31 = (double)(1800 * pParty->pPickedItem.uEnchantmentType * 128); + } + + v27->uExpireTime = pParty->uTimePlayed + v31 * 0.033333335; + v27->uAttributes = alchemy_skill | 0x18; + + _50C9A8_item_enchantment_timer = 256; + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; + } + } + + + if (pParty->pPickedItem.uItemID < ITEM_REAGENT_WIDOWSWEEP_BERRIES || pParty->pPickedItem.uItemID > ITEM_REAGENT_PHILOSOPHERS_STONE || player->pInventoryItemList[item_pid].uItemID != ITEM_POTION_BOTTLE) @@ -5031,127 +5124,40 @@ if (pParty->pPickedItem.uItemID < ITEM_POTION_CATALYST || pParty->pPickedItem.uItemID > ITEM_POTION_REJUVENATION || player->pInventoryItemList[item_pid].uItemID < ITEM_POTION_CATALYST || - player->pInventoryItemList[item_pid].uItemID >= ITEM_POTION_REJUVENATION) + player->pInventoryItemList[item_pid].uItemID > ITEM_POTION_REJUVENATION) { if (pParty->pPickedItem.uItemID != ITEM_POTION_HARDEN_ITEM && (pParty->pPickedItem.uItemID < ITEM_POTION_FLAMING_POTION || pParty->pPickedItem.uItemID > ITEM_POTION_SWIFT_POTION) && pParty->pPickedItem.uItemID != ITEM_POTION_SLAYING_POTION && pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM) goto LABEL_116; + } - int a2_y; - v27 = &player->pInventoryItemList[item_pid]; - v51 = pItemsTable->pItems[v27->uItemID].uEquipType; - v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType); - if ( pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM ) - { - if ( pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM ) - { - if (v27->IsBroken() || v51 < EQUIP_OFF_HAND || v51 > EQUIP_WAND || v27->uItemID >= ITEM_ARTIFACT_PUCK ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = true; - return; - } - v27->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_ENCHANTED; - } - else - { - if (pParty->pPickedItem.uItemID <= ITEM_POTION_ACCURACY_BOOST ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = true; - return; - } - if (pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION) - { - v27->UpdateTempBonus(pParty->uTimePlayed); - if ( (signed int)v27->uItemID >= 64 && (signed int)v27->uItemID <= 65 - || (alchemy_skill = v27->uAttributes, alchemy_skill & 2) - || v27->uSpecEnchantmentType - || v27->uEnchantmentType - || v51 && v51 != 1 && v51 != 2 - || (signed int)v27->uItemID >= 500 ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; - a2_y = (int)v29 << 7; - v31 = (double)(signed int)((int)v29 << 7); - v27->uSpecEnchantmentType = v34; - } - else - { - if ( pParty->pPickedItem.uItemID != 263 - || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64) - && (signed int)v30 <= 65 - || (alchemy_skill = v27->uAttributes, alchemy_skill & 2) - || v27->uSpecEnchantmentType - || v27->uEnchantmentType - || v51 && v51 != 1 && v51 != 2 - || (signed int)v30 >= 500 ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - a2_y = (int)v29 << 7; - v27->uSpecEnchantmentType = 40; - v31 = (double)a2_y; - } - v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335); - LODWORD(v27->uExpireTime) = v32; - LODWORD(v32) = alchemy_skill; - LOBYTE(v32) = LOBYTE(alchemy_skill) | 0x18; - HIDWORD(v27->uExpireTime) = HIDWORD(v32); - v27->uAttributes = v32; - } - _50C9A8_item_enchantment_timer = 256; - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; - if ( v36 < 0.0 ) - v36 = 0.0; - if ( v51 != 12 ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - a2_y = v27->uMaxCharges; - v37 = (signed __int64)((double)a2_y - v36 * (double)a2_y); - v27->uMaxCharges = v37; - v27->uNumCharges = (unsigned __int8)v37; - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - v14 = player->pInventoryItemList[item_pid].uItemID - 222; - v15 = pParty->pPickedItem.uItemID - 222; - v47 = v14; + // src not reagent, dst not bottle + // src potion, dst potion - if ( pParty->pPickedItem.uItemID == 221 || player->pInventoryItemList[item_pid].uItemID == 221 ) + v14 = item->uItemID - ITEM_POTION_CURE_WOUNDS; + v15 = pParty->pPickedItem.uItemID - ITEM_POTION_CURE_WOUNDS; + + if ( pParty->pPickedItem.uItemID == ITEM_POTION_CATALYST || + item->uItemID == ITEM_POTION_CATALYST ) { v16 = 5; } else { - v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388]; - v10 = item_pid; + v16 = pItemsTable->potion_data[v15][v14 + 2]; } v51 = v16; if ( v9 ) { - if ( v16 < 225 || v16 > 227 ) + if ( v16 < ITEM_POTION_CURE_DISEASE || v16 > ITEM_POTION_AWAKEN ) { - if ( v16 < 228 || v16 > 239 ) + if ( v16 < ITEM_POTION_HASTE || v16 > ITEM_POTION_CURE_INSANITY ) { - if ( v16 < 240 || v16 > 261 ) + if ( v16 < ITEM_POTION_MIGHT_BOOST || v16 > ITEM_POTION_BODY_RESISTANE ) { - if ( v16 >= 262 && alchemy_level != 4 ) + if ( v16 >= ITEM_POTION_STONE_TO_FLESH && alchemy_level != 4 ) { LABEL_53: v51 = 4; @@ -5181,21 +5187,21 @@ } else { - if ( v16 >= 225 && v16 <= 227 ) + if ( v16 >= ITEM_POTION_CURE_DISEASE && v16 <= ITEM_POTION_AWAKEN ) { v51 = 1; goto LABEL_54; } - if ( v16 >= 228 && v16 <= 239 ) + if ( v16 >= ITEM_POTION_HASTE && v16 <= ITEM_POTION_CURE_INSANITY ) goto LABEL_35; - if ( v16 >= 240 && v16 <= 261 ) + if ( v16 >= ITEM_POTION_MIGHT_BOOST && v16 <= ITEM_POTION_BODY_RESISTANE ) goto LABEL_38; - if ( v16 >= 262 ) + if ( v16 >= ITEM_POTION_STONE_TO_FLESH ) goto LABEL_53; } LABEL_54: int pOut_y = 0; - int pOut_x = v10 + 1; + int pOut_x = item_pid + 1; v17 = (int)player->pInventoryMatrix; while ( *(int *)v17 != pOut_x ) { @@ -5210,11 +5216,7 @@ v18 = pOut_y; LABEL_59: if ( !v51 ) - { -LABEL_115: - v10 = item_pid; goto LABEL_116; - } if ( v51 == 1 ) { player->RemoveItemAtInventoryIndex(v18); @@ -5254,7 +5256,7 @@ if ( v19 ) // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; player->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED; - v20 = v47 + 50 * v15; + v20 = v14 + 50 * v15; player->pInventoryItemList[item_pid].uItemID = v51; player->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType + player->pInventoryItemList[item_pid].uEnchantmentType) @@ -5288,7 +5290,7 @@ player->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED; goto LABEL_74; } - goto LABEL_115; + goto LABEL_116; } player->RemoveItemAtInventoryIndex(v18); player->SetCondition(0x10u, 0); @@ -5320,6 +5322,8 @@ return; } + // end alchemy + player->pInventoryItemList[item_pid].uEnchantmentType = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice; switch ( pParty->pPickedItem.uItemID ) { @@ -5361,6 +5365,13 @@ player->PlaySound(SPEECH_16, 0); dword_4E455C = 0; } + return; + + +__invalid_item: + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; } //----- (00417AD4) --------------------------------------------------------