diff 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
line wrap: on
line diff
--- a/mm7_5.cpp	Wed Sep 25 12:54:34 2013 +0600
+++ b/mm7_5.cpp	Wed Sep 25 17:29:14 2013 +0600
@@ -4904,452 +4904,6 @@
   DrawCopyrightWindow();
 }
 
-
-int no_rightlick_in_inventory = false; // 0050CDCC
-//----- (00416196) --------------------------------------------------------
-void OnInventoryItemRightClick()
-{
-  int v7; // eax@7
-  int v9; // edi@10
-  int v14; // edx@25
-  unsigned int v15; // edi@25
-  signed int v16; // edx@27
-  int v17; // eax@54
-  unsigned int v18; // edx@57
-  int v19; // eax@65
-  int v20; // edi@67
-  int v21; // eax@72
-  int v22; // ecx@74
-  int v23; // edx@78
-  int v24; // eax@79
-  int v25; // eax@80
-  int v26; // eax@84
-  ItemGen *v27; // esi@98
-  double v31; // st7@112
-  double v36; // st7@132
-  signed __int64 v37; // qax@135
-  Vec3_int_ v39; // [sp-18h] [bp-A8h]@83
-  GUIWindow v43; // [sp+Ch] [bp-84h]@137
-  int v45; // [sp+64h] [bp-2Ch]@10
-  POINT a2; // [sp+78h] [bp-18h]@2
-  unsigned int v51; // [sp+8Ch] [bp-4h]@23
-
-  if (no_rightlick_in_inventory)
-    return;
-
-  pMouse->GetCursorPos(&a2);
-  if (a2.x <= 13 || a2.x >= 462)
-    return;
-
-  int item_pid = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
-  if (!item_pid)
-  {
-    int inventory_mouse_x = a2.x - 14;
-    int inventory_mouse_y = a2.y - 17;
-
-    int mouse_cell_x = inventory_mouse_x / 32;
-    int mouse_cell_y = inventory_mouse_y / 32;
-
-    if (mouse_cell_x + mouse_cell_y < 0)
-      return;
-
-    int inventory_idx = mouse_cell_x + 14 * mouse_cell_y;
-    if (inventory_idx > 126)
-      return;
-
-    v7 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&inventory_idx);
-    if (v7 == 0)
-      return;
-
-    item_pid = v7;
-  }
-
-  if (!pPlayers[uActiveCharacter]->CanAct())
-  {
-    sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//%s не в состоянии %s Опознать предметы
-    v43.Hint = pTmpBuf.data();
-    v43.uFrameWidth = 384;
-    v43.uFrameHeight = 180;
-    if (a2.x <= 320 )
-      v43.uFrameX = a2.x + 30;
-    else
-      v43.uFrameX = a2.x - 414;
-    v43.uFrameY = 40;
-    v43.DrawMessageBox(0);
-    return;
-  }
-
-  --item_pid;
-  int alchemy_level = (int8_t)pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
-  v9 = alchemy_level & 0x3F;
-  //v45 = alchemy_level & 0x3F;
-  int alchemy_skill = SkillToMastery(alchemy_level);
-
-  auto item = &pPlayers[uActiveCharacter]->pInventoryItemList[item_pid];
-  if (pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE)
-  {
-    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 (item->GetItemEquipType() != 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;
-    }
-    GameUI_DrawItemInfo(item);
-    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
-          item->GetItemEquipType() < EQUIP_OFF_HAND ||
-          item->GetItemEquipType() > EQUIP_WAND)
-        goto __invalid_item;
-
-      item->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_HARDENED;
-
-      _50C9A8_item_enchantment_timer = 256;
-      pMouse->RemoveHoldingItem();
-      no_rightlick_in_inventory = true;
-      return;
-    }
-    GameUI_DrawItemInfo(item);
-    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 ||
-          item->GetItemEquipType() >= 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;
-    }
-    GameUI_DrawItemInfo(item);
-    return;
-  }
-
-
-
-  if (pParty->pPickedItem.uItemID < ITEM_REAGENT_WIDOWSWEEP_BERRIES ||
-      pParty->pPickedItem.uItemID > ITEM_REAGENT_PHILOSOPHERS_STONE ||
-      pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID != ITEM_POTION_BOTTLE)
-  {
-    if (pParty->pPickedItem.uItemID < ITEM_POTION_CATALYST ||
-        pParty->pPickedItem.uItemID > ITEM_POTION_REJUVENATION ||
-        pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID < ITEM_POTION_CATALYST ||
-        pPlayers[uActiveCharacter]->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)
-       GameUI_DrawItemInfo(item);
-       return;
-    }
-
-    // src not reagent,  dst not bottle
-    // src potion,       dst potion
-
-    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 = pItemsTable->potion_data[v15][v14 + 2];
-    }
-    v51 = v16;
-    if ( v9 )
-    {
-      if ( v16 < ITEM_POTION_CURE_DISEASE || v16 > ITEM_POTION_AWAKEN )
-      {
-        if ( v16 < ITEM_POTION_HASTE || v16 > ITEM_POTION_CURE_INSANITY )
-        {
-          if ( v16 < ITEM_POTION_MIGHT_BOOST || v16 > ITEM_POTION_BODY_RESISTANE )
-          {
-            if ( v16 >= ITEM_POTION_STONE_TO_FLESH && alchemy_level != 4 )
-            {
-LABEL_53:
-              v51 = 4;
-              goto LABEL_54;
-            }
-          }
-          else
-          {
-            if ( alchemy_level <= 2 )
-            {
-LABEL_38:
-              v51 = 3;
-              goto LABEL_54;
-            }
-          }
-        }
-        else
-        {
-          if ( alchemy_level == 1 )
-          {
-LABEL_35:
-            v51 = 2;
-            goto LABEL_54;
-          }
-        }
-      }
-    }
-    else
-    {
-      if ( v16 >= ITEM_POTION_CURE_DISEASE && v16 <= ITEM_POTION_AWAKEN )
-      {
-        v51 = 1;
-        goto LABEL_54;
-      }
-      if ( v16 >= ITEM_POTION_HASTE && v16 <= ITEM_POTION_CURE_INSANITY )
-        goto LABEL_35;
-      if ( v16 >= ITEM_POTION_MIGHT_BOOST && v16 <= ITEM_POTION_BODY_RESISTANE )
-        goto LABEL_38;
-      if ( v16 >= ITEM_POTION_STONE_TO_FLESH )
-        goto LABEL_53;
-    }
-LABEL_54:
-    int pOut_y = 0;
-    int pOut_x = item_pid + 1;
-    v17 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix;
-    while ( *(int *)v17 != pOut_x )
-    {
-      ++pOut_y;
-      v17 += 4;
-      if ( pOut_y >= 126 )
-      {
-        v18 = pOut_y;
-        goto LABEL_59;
-      }
-    }
-    v18 = pOut_y;
-LABEL_59:
-    if ( !v51 )
-      GameUI_DrawItemInfo(item);
-      return;
-    if ( v51 == 1 )
-    {
-      pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18);
-      v26 = rand();
-      pPlayers[uActiveCharacter]->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE);
-      pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
-
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-
-      v39.z = pParty->vPosition.z + pParty->sEyelevel;
-    }
-    else
-    {
-      if ( v51 == 2 )
-      {
-        pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18);
-        v25 = rand();
-        pPlayers[uActiveCharacter]->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE);
-        v23 = 1;
-      }
-      else
-      {
-        if ( v51 == 3 )
-        {
-          pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18);
-          v24 = rand();
-          pPlayers[uActiveCharacter]->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE);
-          v23 = 5;
-        }
-        else
-        {
-          if ( v51 != 4 )
-          {
-            if ( v51 != 5 )
-            {
-              v19 = pPlayers[uActiveCharacter]->AddItem(-1, 0xDCu);
-              if ( v19 )
-               // *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
-                 pPlayers[uActiveCharacter]->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED;
-              v20 = v14 + 50 * v15;
-              pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = v51;
-              pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType
-                                                       + pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uEnchantmentType)
-                                                      / 2;
-              pPlayers[uActiveCharacter]->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168  + 388
-LABEL_74:
-              v22 = (int)((char *)pPlayers[uActiveCharacter] + 36 * item_pid);
-              if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) )
-                *(int *)(v22 + 552) |= 1u;
-              if ( !dword_4E455C )
-			  {
-				pMouse->RemoveHoldingItem();
-				no_rightlick_in_inventory = 1;
-				return;
-			  }
-              pPlayers[uActiveCharacter]->PlaySound(SPEECH_16, 0);
-			  dword_4E455C = 0;
-			  pMouse->RemoveHoldingItem();
-			  no_rightlick_in_inventory = 1;
-			  return;
-            }
-            if ( v9 )
-            {
-              if ( *(int *)(pPlayers[uActiveCharacter] + 36 * item_pid + 532) == 221 )
-                *(int *)(pPlayers[uActiveCharacter] + 36 * item_pid + 532) = pParty->pPickedItem.uItemID;
-              else
-                *(int *)(pPlayers[uActiveCharacter] + 36 * item_pid + 536) = pParty->pPickedItem.uEnchantmentType;
-              v21 = pPlayers[uActiveCharacter]->AddItem(-1, 0xDCu);
-              if ( v21 )
-                //*(int *)&v0->field_1F5[36 * v21 + 15] = 1;
-                pPlayers[uActiveCharacter]->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED;
-              goto LABEL_74;
-            }
-            GameUI_DrawItemInfo(item);
-            return;
-          }
-          pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v18);
-          pPlayers[uActiveCharacter]->SetCondition(0x10u, 0);
-          v23 = 0;
-        }
-      }
-      pPlayers[uActiveCharacter]->ItemsEnchant(v23);
-      pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
-
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-
-      v39.z = pParty->vPosition.z + pParty->sEyelevel;
-    }
-    v39.x = pParty->vPosition.x;
-    v39.y = pParty->vPosition.y;
-
-    int rot_x, rot_y, rot_z;
-    Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, &rot_x, &rot_y, &rot_z);
-    sub_42F7EB_DropItemAt(0x41Bu, rot_x, rot_y, rot_z, 0, 1, 0, 0, 0);
-    if ( dword_4E455C )
-    {
-      if ( pPlayers[uActiveCharacter]->CanAct() )
-        pPlayers[uActiveCharacter]->PlaySound(SPEECH_17, 0);
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
-      dword_4E455C = 0;
-    }
-    pMouse->RemoveHoldingItem();
-    no_rightlick_in_inventory = 1;
-    return;
-  }
-
-  // end alchemy
-
-  pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uEnchantmentType = v9 + pParty->pPickedItem.GetDamageDice();
-  switch ( pParty->pPickedItem.uItemID )
-  {
-    case 0xC8u:
-    case 0xC9u:
-    case 0xCAu:
-    case 0xCBu:
-    case 0xCCu:
-      pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 222;
-      break;
-    case 0xCDu:
-    case 0xCEu:
-    case 0xCFu:
-    case 0xD0u:
-    case 0xD1u:
-      pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 223;
-      break;
-    case 0xD2u:
-    case 0xD3u:
-    case 0xD4u:
-    case 0xD5u:
-    case 0xD6u:
-      pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 224;
-      break;
-    case 0xD7u:
-    case 0xD8u:
-    case 0xD9u:
-    case 0xDAu:
-    case 0xDBu:
-      pPlayers[uActiveCharacter]->pInventoryItemList[item_pid].uItemID = 221;
-      break;
-    default:
-      break;
-  }
-  pMouse->RemoveHoldingItem();
-  no_rightlick_in_inventory = 1;
-  if ( dword_4E455C )
-  {
-    pPlayers[uActiveCharacter]->PlaySound(SPEECH_16, 0);
-    dword_4E455C = 0;
-  }
-  return;
-
-
-__invalid_item:
-  pMouse->RemoveHoldingItem();
-  no_rightlick_in_inventory = true;
-  return;
-}
-
 //----- (00417AD4) --------------------------------------------------------
 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level)
 {