changeset 2156:eaaaa50d34e9

GetItemBonusEnchantment
author Ritor1
date Fri, 10 Jan 2014 17:42:37 +0600
parents d28d3c006077
children c6d8253d4cbc
files Outdoor.cpp Player.cpp UI/UICharacter.cpp
diffstat 3 files changed, 62 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor.cpp	Thu Jan 09 02:34:20 2014 +0200
+++ b/Outdoor.cpp	Fri Jan 10 17:42:37 2014 +0600
@@ -4209,7 +4209,7 @@
   stru_721530.field_84 = -1;
   stru_721530.field_70 = 0;
   stru_721530.prolly_normal_d = pParty->field_14_radius;
-  stru_721530.field_8_radius = pParty->field_14_radius >> 1;
+  stru_721530.field_8_radius = pParty->field_14_radius / 2;
   stru_721530.field_0 = 1;
   stru_721530.height = pParty->uPartyHeight - 32;
   for ( uint i = 0; i < 100; i++ )
@@ -4661,6 +4661,7 @@
     }
   }
 }
+
 //----- (0046D8E3) --------------------------------------------------------
 int GetCeilingHeight(int Party_X, signed int Party_Y, int Party_ZHeight, int pFaceID)
 {
--- a/Player.cpp	Thu Jan 09 02:34:20 2014 +0200
+++ b/Player.cpp	Fri Jan 10 17:42:37 2014 +0600
@@ -25,7 +25,7 @@
 #include "MM7.h"
 #include "SpriteObject.h"
 #include "DecalBuilder.h"
-
+#include "CastSpellInfo.h"
 
 
 
@@ -217,8 +217,6 @@
   return remainingStatPoints;
 }
 
-
-
 //----- (00427730) --------------------------------------------------------
 bool Player::CanCastSpell(unsigned int uRequiredMana)
 {
@@ -232,7 +230,6 @@
   return false;
 }
 
-
 //----- (004BE2DD) --------------------------------------------------------
 void Player::SalesProcess( unsigned int inventory_idnx, int item_index, int _2devent_idx )
     {
@@ -251,8 +248,6 @@
   Party::SetGold(pParty->uNumGold + sell_price);
 }
 
-
-
 //----- (0043EEF3) --------------------------------------------------------
 bool Player::NothingOrJustBlastersEquipped()
 {
@@ -270,9 +265,6 @@
   }
   return true;
 }
-  
-
-
 
 //----- (004B8040) --------------------------------------------------------
 int Player::GetConditionDayOfWeek( unsigned int uCondition )
@@ -293,13 +285,9 @@
   if ( conditionIdx >= 14 && conditionIdx <= 16)
   {
     if ( conditionIdx <= 15 )
-    {
       baseConditionMultiplier = 5;
-    }
     else //if ( conditionIdx == 16 )
-    {
       baseConditionMultiplier = 10;
-    }
     conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx);
   }
   else 
@@ -425,40 +413,24 @@
   return v3;
 }
 
-
-
-
-
 //----- (004B6FF9) --------------------------------------------------------
 bool Player::IsPlayerHealableByTemple()
 {
-  signed int v2; // eax@1
-  v2 = (signed int)window_SpeakInHouse->ptr_1C;
   if (this->sHealth >= GetMaxHealth() && this->sMana >= GetMaxMana() && GetMajorConditionIdx() == Condition_Good)
-  {
     return false;
-  }
   else
   {
     if (GetMajorConditionIdx() == Condition_Zombie)
     {
-      if ((v2 == 78 || v2 == 81 || v2 == 82))
-      {
+      if (((signed int)window_SpeakInHouse->ptr_1C == 78 || (signed int)window_SpeakInHouse->ptr_1C == 81 || (signed int)window_SpeakInHouse->ptr_1C == 82))
         return false;
-      }
       else
-      {
         return true;
-      }
     }
     else
-    {
       return true;
-    }
-  }
-}
-
-
+  }
+}
 
 //----- (00421E75) --------------------------------------------------------
 unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index)
@@ -466,25 +438,18 @@
   int item_idx; // eax@1
   int inv_index; // eax@3
 
-
   item_idx = *pitem_index;
   if ( item_idx >125 || item_idx < 0 )
-  {
     return 0;
-  }
-  
-    inv_index = this->pInventoryMatrix[item_idx];
-    if ( inv_index < 0 )
-    {
-      *pitem_index = -1 - inv_index;
-      inv_index = this->pInventoryMatrix[-1 - inv_index];
-    }
-
+  inv_index = this->pInventoryMatrix[item_idx];
+  if ( inv_index < 0 )
+  {
+    *pitem_index = -1 - inv_index;
+    inv_index = this->pInventoryMatrix[-1 - inv_index];
+  }
   return inv_index;
 }
 
-
-
 //----- (004160CA) --------------------------------------------------------
 void Player::ItemsEnchant( int enchant_count )
     {
@@ -3208,7 +3173,7 @@
           }
           else if ( currEquippedItem->uEnchantmentType != 0 )
           {
-            if (currEquippedItem->IsRegularEnchanmentForAttribute(attr))
+            if (this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uEnchantmentType - 1 == attr)//if (currEquippedItem->IsRegularEnchanmentForAttribute(attr))
             {
               if ( attr > CHARACTER_ATTRIBUTE_RESIST_BODY && v5 < currEquippedItem->m_enchantmentStrength )
                 v5 = currEquippedItem->m_enchantmentStrength;
@@ -4786,8 +4751,8 @@
           return;
       }
       v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
-      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);
-      ShowStatusBarString(pTmpBuf.data(), 2u);
+      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);//That player is %s
+      ShowStatusBarString(pTmpBuf.data(), 2);
       pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
       return;
   }
@@ -4852,32 +4817,32 @@
             {
             case 0:
                 playerAffected->sResFireBase += thisa;
-                v13 = pGlobalTXT_LocalizationStrings[87];
+                v13 = pGlobalTXT_LocalizationStrings[87];//Fire
                 break;
             case 1:
                 playerAffected->sResAirBase += thisa;
-                v13 = pGlobalTXT_LocalizationStrings[6];
+                v13 = pGlobalTXT_LocalizationStrings[6];//Air
                 break;
             case 2:
                 playerAffected->sResWaterBase += thisa;
-                v13 = pGlobalTXT_LocalizationStrings[240];
+                v13 = pGlobalTXT_LocalizationStrings[240];//Water
                 break;
             case 3:
                 playerAffected->sResEarthBase += thisa;
-                v13 = pGlobalTXT_LocalizationStrings[70];
+                v13 = pGlobalTXT_LocalizationStrings[70];//Earth
                 break;
             case 4:
                 playerAffected->sResMindBase += thisa;
-                v13 = pGlobalTXT_LocalizationStrings[142];
+                v13 = pGlobalTXT_LocalizationStrings[142];//Mind
                 break;
             case 5:
                 playerAffected->sResBodyBase += thisa;
-                v13 = pGlobalTXT_LocalizationStrings[29];
+                v13 = pGlobalTXT_LocalizationStrings[29];//Body
                 break;
             default: ("Unexpected attribute");
               return;
             }
-            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]);
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]);//Permanent
             break;
 
       }
@@ -4949,7 +4914,6 @@
   }
 }
 
-
 bool CmpSkillValue(int valToCompare, int skillValue)
 {
   int v4;
@@ -7130,41 +7094,36 @@
 void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType)
 {
   int itemAnchor; // ebx@1
-  Player *currChar; // eax@1
   int itemInvLocation; // edx@1
   int freeSlot; // eax@3
   ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1
-  unsigned int *equipAnchor; // [sp+38h] [bp-4h]@1
 
   tempPickedItem.Reset();
   itemAnchor = pEquipTypeToBodyAnchor[uEquipType];
-  currChar = pPlayers[uActiveCharacter];
-  equipAnchor = &currChar->pEquipment.pIndices[itemAnchor];
-  itemInvLocation = currChar->pEquipment.pIndices[itemAnchor];
-  if ( itemInvLocation )
+  itemInvLocation = pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor];
+  if ( itemInvLocation )//переодеться в другую вещь
   {
     memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem));
-    currChar->pInventoryItemList[itemInvLocation - 1].uBodyAnchor = 0;
+    pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1].uBodyAnchor = 0;
     pParty->pPickedItem.Reset();
-    pParty->SetHoldingItem(&currChar->pInventoryItemList[itemInvLocation - 1]);
+    pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1]);
     tempPickedItem.uBodyAnchor = itemAnchor + 1;
-    memcpy(&currChar->pInventoryItemList[itemInvLocation - 1], &tempPickedItem, sizeof(ItemGen));
-    *equipAnchor = itemInvLocation;
-  }
-  else
-  {
-    freeSlot = currChar->FindFreeInventoryListSlot();
+    memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[itemInvLocation - 1], &tempPickedItem, sizeof(ItemGen));
+    pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor] = itemInvLocation;
+  }
+  else//одеть вещь
+  {
+    freeSlot = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot();
     if (freeSlot >= 0)
     {
       pParty->pPickedItem.uBodyAnchor = itemAnchor + 1;
-      memcpy(&currChar->pInventoryItemList[freeSlot], &pParty->pPickedItem, sizeof(ItemGen));
-      *equipAnchor = freeSlot + 1;
+      memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[freeSlot], &pParty->pPickedItem, sizeof(ItemGen));
+      pPlayers[uActiveCharacter]->pEquipment.pIndices[itemAnchor] = freeSlot + 1;
       pMouse->RemoveHoldingItem();
     }
   }
 }
 
-
 //----- (0049387A) --------------------------------------------------------
 int CycleCharacter(bool backwards)
 {
@@ -7268,8 +7227,6 @@
   return false;
 }
 
-
-
 //----- (00439FCB) --------------------------------------------------------
 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int dmgSource, Vec3_int_ *pPos, signed int a4)
 {
@@ -7614,6 +7571,7 @@
   ItemGen tmpItem; // [sp+Ch] [bp-3Ch]@1
   unsigned int pY; // [sp+3Ch] [bp-Ch]@2
   unsigned int pX; // [sp+40h] [bp-8h]@2
+  CastSpellInfo *pSpellInfo;
 
   if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )
   {
@@ -7628,10 +7586,15 @@
         enchantedItemPos = this->GetItemIDAtInventoryIndex(&invMatrixIndex);
         if ( enchantedItemPos )
         {
-          *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
+         /* *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
           *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
           *((int *)pGUIWindow_Settings->ptr_1C + 3) = enchantedItemPos - 1;
-          *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex;
+          *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex;*/
+          pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C;
+          pSpellInfo->uFlags &= 0x7F;
+          pSpellInfo->uPlayerID_2 = uActiveCharacter - 1;
+          pSpellInfo->spell_target_pid = enchantedItemPos - 1;
+          pSpellInfo->field_6 = invMatrixIndex;
           ptr_50C9A4_ItemToEnchant = &this->pInventoryItemList[enchantedItemPos-1];
           _50C9A0_IsEnchantingInProgress = 0;
           if ( pMessageQueue_50CBD0->uNumMessages )
--- a/UI/UICharacter.cpp	Thu Jan 09 02:34:20 2014 +0200
+++ b/UI/UICharacter.cpp	Fri Jan 10 17:42:37 2014 +0600
@@ -2178,6 +2178,7 @@
   if ( player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY) > 99 || player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY) > 99 )
     a2 = "%s\f%05u\t180%d\f00000 / %d\n";
   pY += LOBYTE(pFontArrus->uFontHeight) - 2;
+  int it = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
   sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[29],
           UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY)),
           player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY));
@@ -2331,14 +2332,13 @@
   int v23; // eax@62
   int v26; // eax@69
   int v34; // esi@90
-  int v36; // esi@93
-  ItemGen *v38; // edi@93
   ItemGen _this; // [sp+Ch] [bp-40h]@1
   unsigned int v48; // [sp+30h] [bp-1Ch]@88
   unsigned int v50; // [sp+38h] [bp-14h]@50
   int v51; // [sp+3Ch] [bp-10h]@1
   int v52; // [sp+40h] [bp-Ch]@5
   ITEM_EQUIP_TYPE pEquipType;
+  CastSpellInfo *pSpellInfo;
 
   v51 = 0;
   _this.Reset();
@@ -2618,7 +2618,7 @@
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
-        if ( v1 )//взять двуручный меч кода нет щита(замещение оружия)
+        if ( v1 )//взять двуручный меч когда нет щита(замещение оружия)
         {
           if ( v2 )
           {
@@ -2639,7 +2639,7 @@
           v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot();
           if ( v52 >= 0 )
           {
-            if ( v2 )//взять двуручный меч кода есть щит(замещение щитом)
+            if ( v2 )//взять двуручный меч когда есть щит(замещение щитом)
             {
               v2--;
               memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
@@ -2672,10 +2672,10 @@
   v34 = pRenderer->pActiveZBuffer[pMouse->uMouseClickX + pSRZBufferLineOffsets[pMouse->uMouseClickY]] & 0xFFFF;
   if ( v34 )
   {
-    v36 = v34 - 1;
-    v38 = &pPlayers[uActiveCharacter]->pInventoryItemList[v36];
-    pEquipType = v38->GetItemEquipType();
-    if ( v38->uItemID == ITEM_WETSUIT )
+    //v36 = v34 - 1;
+    //v38 = &pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1];
+    pEquipType = pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1].GetItemEquipType();
+    if ( pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1].uItemID == ITEM_WETSUIT )
     {
       if ( bUnderwater )
       {
@@ -2686,11 +2686,17 @@
     }
     if ( _50C9A0_IsEnchantingInProgress )//наложить закл на экипировку
     {
-      *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;//CastSpellInfo
+      /* *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;//CastSpellInfo
       *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
       *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36;
-      *((short *)pGUIWindow_Settings->ptr_1C + 3) = pEquipType;
-      ptr_50C9A4_ItemToEnchant = v38;
+      *((short *)pGUIWindow_Settings->ptr_1C + 3) = pEquipType;*/
+      pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C;
+      pSpellInfo->uFlags &= 0x7F;
+      pSpellInfo->uPlayerID_2 = uActiveCharacter - 1;
+      pSpellInfo->spell_target_pid = v34 - 1;
+      pSpellInfo->field_6 = pEquipType;
+
+      ptr_50C9A4_ItemToEnchant = &pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1];
       _50C9A0_IsEnchantingInProgress = 0;
       if ( pMessageQueue_50CBD0->uNumMessages )
         pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -2703,9 +2709,9 @@
     {
       if ( !ptr_50C9A4_ItemToEnchant )//снять вещь
       {
-        pParty->SetHoldingItem(v38);
-        pPlayers[uActiveCharacter]->pEquipment.pIndices[pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor - 1] = 0;
-        v38->Reset();
+        pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1]);
+        pPlayers[uActiveCharacter]->pEquipment.pIndices[pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1].uBodyAnchor - 1] = 0;
+        pPlayers[uActiveCharacter]->pInventoryItemList[v34 - 1].Reset();
       }
     }
   }