diff Player.cpp @ 1036:7f8be9f9769e

player recieve damage
author Gloval
date Wed, 22 May 2013 22:25:44 +0400
parents aa848c90181f
children ff2d888f8033
line wrap: on
line diff
--- a/Player.cpp	Tue May 21 23:45:26 2013 +0200
+++ b/Player.cpp	Wed May 22 22:25:44 2013 +0400
@@ -103,14 +103,14 @@
 unsigned char pAgeingSpeedMultiplier[4]        = {100, 100,  40, 10};
 unsigned char pAgeingLuckMultiplier[4]         = {100, 100, 100, 100};
 
-unsigned int pAgeingTable[4] = {50, 100, 150, 65535};
+signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF};
 
 unsigned int pConditionImportancyTable[18] = {16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0};
 
-short word_4EDFFC[30] = {500, 400, 350, 300, 275, 250, 225, 200, 175,
+short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175,
                          150, 125, 100,  75,  50,  40,  35,  30,  25,  21,
-                         19,   17,  15,  13,  11,   9,   7,   5,   3,   0, 0};
-signed int player_stat_bonuses[30] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, 0};
+                         19,   17,  15,  13,  11,   9,   7,   5,   3,   0};
+signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6};
 
 
 unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0};
@@ -264,9 +264,9 @@
 
 
 //----- (004B8040) --------------------------------------------------------
-int Player::_4B8040_condition_time(unsigned int uCondition)
-{
-  return (unsigned int)((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 0x18 % 7 + 1;
+int Player::GetConditionDayOfWeek( unsigned int uCondition )
+    {
+  return (unsigned int)(((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 24) % 7 + 1;
 }
 
 //----- (004B807C) --------------------------------------------------------
@@ -298,7 +298,7 @@
       v10 = 10;
       v9 = 16;
 LABEL_6:
-      v11 = _4B8040_condition_time(v9);
+      v11 = GetConditionDayOfWeek(v9);
       goto LABEL_13;
     }
   }
@@ -306,7 +306,7 @@
   v5 = 0;
   do
   {
-    v6 = _4B8040_condition_time(v5);
+    v6 = GetConditionDayOfWeek(v5);
     if ( v6 > v4 )
       v4 = v6;
     ++v5;
@@ -2574,42 +2574,41 @@
 //----- (0048CC33) --------------------------------------------------------
 int Player::GetActualLuck()
 {
-  Player *v1; // esi@1
-  unsigned int v2; // eax@7
-  signed int v3; // ecx@7
-  signed int v4; // ebx@10
-  int v5; // edi@11
-  int v6; // ebp@11
-  signed int v8; // [sp+10h] [bp-4h]@1
-
-  v8 = 0;
-  v1 = this;
+  signed int curr_age; // eax@7
+  signed int i; // ecx@7
+  signed int age_luck_pc; // ebx@10
+  int condition_luck_pc; // edi@11
+  int items_luck_bonus; // ebp@11
+  signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1
+  signed int magic_luck_bonus; // [sp+10h] [bp-4h]@1
+  int full_luck;
+
+  npc_luck_bonus = 0;
   if ( CheckHiredNPCSpeciality(Fool) )
-    v8 = 5;
+    npc_luck_bonus = 5;
   if ( CheckHiredNPCSpeciality(ChimneySweep) )
-    v8 += 20;
+    npc_luck_bonus += 20;
   if ( CheckHiredNPCSpeciality(Psychic) )
-    v8 += 10;
-  v2 = v1->sAgeModifier + GetBaseAge();
-  v3 = 0;
-  while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
-  {
-    ++v3;
-    if ( v3 >= 4 )
-    {
-      v4 = 100;
-      goto LABEL_11;
-    }
-  }
-  v4 = pAgeingLuckMultiplier[v3];
-LABEL_11:
-  v5 = pConditionLuckMultiplier[GetMajorConditionIdx()];
-  v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0);
-  return GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK)
-       + v6
-       + v8
-       + v5 * v4 * v1->uLuck / 100 / 100
-       + v1->uLuckBonus;
+    npc_luck_bonus += 10;
+  curr_age = sAgeModifier + GetBaseAge();
+  i = 0;
+  while ( curr_age >= pAgeingTable[i] )
+  {
+    ++i;
+    if ( i >= 4 )
+      break;
+  }
+  if (i < 4)
+    age_luck_pc = pAgeingLuckMultiplier[i];
+  else
+    age_luck_pc = 100;
+
+  condition_luck_pc = pConditionLuckMultiplier[GetMajorConditionIdx()];
+  items_luck_bonus = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0);
+  magic_luck_bonus = GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK);
+  full_luck = magic_luck_bonus  + items_luck_bonus   + npc_luck_bonus+  uLuckBonus
+                + condition_luck_pc * age_luck_pc * uLuck / 100 / 100;
+   return full_luck;
 }
 
 //----- (0048CCF5) --------------------------------------------------------
@@ -2623,7 +2622,7 @@
 
   v2 = this;
   v3 = GetActualAccuracy();
-  v4 = _48EA1B_get_static_effect(v3);
+  v4 = GetParameterBonus(v3);
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK);
   v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2);
   return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus;
@@ -2640,15 +2639,14 @@
   int v6; // esi@1
   signed int result; // eax@1
 
-  v1 = this;
+ 
   v2 = GetActualMight();
-  v3 = _48EA1B_get_static_effect(v2);
+  v3 = GetParameterBonus(v2);
   v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0) + v3;
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
-  v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
-  result = 1;
-  if ( v6 >= 1 )
-    result = v6;
+  result = _melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
+  if ( result < 1 )
+    result = 1;
   return result;
 }
 
@@ -2665,7 +2663,7 @@
 
   v1 = this;
   v2 = GetActualMight();
-  v3 = _48EA1B_get_static_effect(v2);
+  v3 = GetParameterBonus(v2);
   v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3;
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
   v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
@@ -2868,7 +2866,7 @@
   if ( !a2 )
   {
     v22 = GetActualMight();
-    v23 = _48EA1B_get_static_effect(v22);
+    v23 = GetParameterBonus(v22);
     v24 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v23;
     v21 += v5->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v24;
   }
@@ -2894,7 +2892,7 @@
   if ( v2 < 64 || v2 > 65 )
   {
     v4 = GetActualAccuracy();
-    v5 = _48EA1B_get_static_effect(v4);
+    v5 = GetParameterBonus(v4);
     v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5;
     v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6;
     v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7;
@@ -3038,114 +3036,97 @@
 //----- (0048D2EA) --------------------------------------------------------
 char *Player::GetMeleeDamageString()
 {
-  Player *v1; // esi@1
-  signed int v2; // eax@1
-  signed int v3; // edi@3
-  signed int v4; // eax@3
-  signed int v5; // ST0C_4@6
-  char *v6; // edi@6
-  signed int v7; // ST08_4@7
-  unsigned int v8; // eax@8
-  signed int v9; // esi@9
+signed int itemid; // eax@1
+int min_damage; // edi@3
+int max_damage; // eax@3
 
   static char player__getmeleedamagestring_static_buff[40]; // idb
 
-  v1 = this;
-  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
-  if ( v2 < 64 || v2 > 65 )
-  {
-    v3 = GetMeleeDamageMinimal();
-    v4 = GetMeleeDamageMaximal();
-  }
+  if ( pEquipment.uMainHand)
+      {
+      itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID;
+      if ( itemid < 64 || itemid > 65 ) //blasters
+          {
+          min_damage = GetMeleeDamageMinimal();
+          max_damage = GetMeleeDamageMaximal();
+          }
+      else
+          {  //for blasters
+          min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0);
+          max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0);
+          }
+      if ( max_damage )
+          {
+          if ( min_damage == max_damage )
+              {
+              sprintf(player__getmeleedamagestring_static_buff, "%d", min_damage);
+              }
+          else
+              {
+              sprintf(player__getmeleedamagestring_static_buff, "%d - %d", min_damage, max_damage);
+              }
+          }
+      else
+          {
+          strcpy(player__getmeleedamagestring_static_buff, "N/A");
+          }
+
+      if (( itemid >= 135 )&&( itemid <= 159 )) //wands
+          {
+          strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
+          }
+      }
   else
-  {
-    v3 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0);
-    v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0);
-  }
-  if ( v3 == v4 )
-  {
-    v5 = v3;
-    v6 = player__getmeleedamagestring_static_buff;
-    sprintf(player__getmeleedamagestring_static_buff, "%d", v5);
-  }
-  else
-  {
-    v7 = v3;
-    v6 = player__getmeleedamagestring_static_buff;
-    sprintf(player__getmeleedamagestring_static_buff, "%d - %d", v7, v4);
-  }
-  v8 = v1->pEquipment.uMainHand;
-  if ( v8 )
-  {
-    v9 = *(int *)&v1->pInventoryItems[v8-1];
-    if ( v9 >= 135 )
-    {
-      if ( v9 <= 159 )
-        strcpy(v6, pGlobalTXT_LocalizationStrings[595]);
-    }
-  }
-  return v6;
+      strcpy(player__getmeleedamagestring_static_buff, "N/A");
+  return player__getmeleedamagestring_static_buff;
 }
 
 //----- (0048D396) --------------------------------------------------------
 char *Player::GetRangedDamageString()
-{
-  Player *v1; // esi@1
-  signed int v2; // eax@1
-  int v3; // edi@3
-  int v4; // eax@3
-  char *v5; // edi@6
-  int v6; // ST0C_4@8
-  int v7; // ST08_4@9
-  unsigned int v8; // eax@10
-  signed int v9; // esi@11
-  
-  static char player__getrangeddamagestring_static_buff[40]; // idb
-
-  v1 = this;
-  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
-  if ( v2 < 64 || v2 > 65 )
-  {
-    v3 = GetRangedDamageMin();
-    v4 = GetRangedDamageMax();
-  }
-  else
-  {
-    v3 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1);
-    v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1);
-  }
-  if ( v4 )
-  {
-    if ( v3 == v4 )
-    {
-      v6 = v3;
-      v5 = player__getrangeddamagestring_static_buff;
-      sprintf(player__getrangeddamagestring_static_buff, "%d", v6);
-    }
+    {
+    signed int itemid; // eax@1
+    int min_damage; // edi@3
+    int max_damage; // eax@3
+
+    static char player__getrangeddamagestring_static_buff[40]; // idb
+    if ( pEquipment.uMainHand)
+        {
+        itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID;
+        if ( itemid < 64 || itemid > 65 ) //blasters
+            {
+            min_damage = GetRangedDamageMin();
+            max_damage = GetRangedDamageMax();
+            }
+        else
+            {  //for blasters
+            min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1);
+            max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1);
+            }
+        if ( max_damage )
+            {
+            if ( min_damage == max_damage )
+                {
+                sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage);
+                }
+            else
+                {
+                sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage);
+                }
+            }
+        else
+            {
+            strcpy(player__getrangeddamagestring_static_buff, "N/A");
+            }
+
+        if (( itemid >= 135 )&&( itemid <= 159 )) //wands
+            {
+            strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
+            }
+        }
     else
-    {
-      v7 = v3;
-      v5 = player__getrangeddamagestring_static_buff;
-      sprintf(player__getrangeddamagestring_static_buff, "%d - %d", v7, v4);
-    }
-  }
-  else
-  {
-    v5 = player__getrangeddamagestring_static_buff;
-    strcpy(player__getrangeddamagestring_static_buff, "N/A");
-  }
-  v8 = v1->pEquipment.uMainHand;
-  if ( v8 )
-  {
-    v9 = *(int *)&v1->pInventoryItems[v8-1];
-    if ( v9 >= 135 )
-    {
-      if ( v9 <= 159 )
-        strcpy(v5, pGlobalTXT_LocalizationStrings[595]);
-    }
-  }
-  return v5;
-}
+        strcpy(player__getrangeddamagestring_static_buff, "N/A");
+    return player__getrangeddamagestring_static_buff;
+    }
 
 //----- (0048D45A) --------------------------------------------------------
 bool Player::CanTrainToNextLevel()
@@ -3174,117 +3155,74 @@
 }
 
 //----- (0048D4B3) --------------------------------------------------------
-int Player::CalculateIncommingDamage(int resistance, signed int type)
-{
-  Player *v3; // esi@1
-  int v4; // edi@8
-  int v6; // eax@21
-  signed int v7; // ebx@21
-  int v8; // eax@22
-  signed int v9; // ebx@22
-  int v10; // eax@23
-  signed int v11; // ebx@23
-  int v12; // eax@24
-  signed int v13; // edi@24
-  unsigned int v14; // eax@27
-  int v15; // eax@29
-  double v16; // st7@32
-  enum CHARACTER_ATTRIBUTE_TYPE v17; // [sp-4h] [bp-10h]@9
-  signed int v18; // [sp+8h] [bp-4h]@17
-
-  v3 = this;
-  if ( !resistance )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)10;
-    goto LABEL_16;
-  }
-  if ( resistance == 1 )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)11;
-    goto LABEL_16;
-  }
-  if ( resistance == 2 )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)12;
-    goto LABEL_16;
-  }
-  if ( resistance == 3 )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)13;
-    goto LABEL_16;
-  }
-  if ( resistance == 6 )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)33;
-    goto LABEL_16;
-  }
-  if ( resistance == 7 )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)14;
-    goto LABEL_16;
-  }
-  if ( resistance == 8 )
-  {
-    v17 = (CHARACTER_ATTRIBUTE_TYPE)15;
-LABEL_16:
-    v4 = GetActualResistance(v17);
-    goto LABEL_17;
-  }
-  v4 = 0;
-LABEL_17:
-  v18 = type;
-  if ( v3->classType == PLAYER_CLASS_LICH && v4 >= 200 )
+int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int amount )
+    {
+
+  int resist_value; // edi@8
+  int player_luck; // eax@21
+  signed int res_rand_divider; // ebx@2
+  int armor_skill; // eax@29
+  enum CHARACTER_ATTRIBUTE_TYPE player_resist; // [sp-4h] [bp-10h]@9
+  signed int result_amount_dmg; // [sp+8h] [bp-4h]@17
+
+  player_resist=CHARACTER_ATTRIBUTE_STRENGTH;
+  switch(dmg_type)
+      {
+      case DMGT_FIRE:   player_resist=CHARACTER_ATTRIBUTE_RESIST_FIRE; break;
+      case DMGT_ELECTR: player_resist=CHARACTER_ATTRIBUTE_RESIST_AIR;  break;
+      case DMGT_COLD:   player_resist=CHARACTER_ATTRIBUTE_RESIST_WATER; break;
+      case DMGT_3: player_resist=CHARACTER_ATTRIBUTE_RESIST_EARTH; break;
+      
+      case DMGT_SPIRIT: player_resist=CHARACTER_ATTRIBUTE_RESIST_SPIRIT;break;
+      case DMGT_MIND: player_resist=CHARACTER_ATTRIBUTE_RESIST_MIND; break;
+      case DMGT_BODY: player_resist=CHARACTER_ATTRIBUTE_RESIST_BODY; break;
+      }
+  if (player_resist)
+    resist_value = GetActualResistance(player_resist);
+  else
+    resist_value = 0;
+
+  result_amount_dmg = amount;
+  if ( classType == PLAYER_CLASS_LICH && resist_value >= 200 )
     return 0;
-  if ( v4 )
-  {
-    v6 = GetActualLuck();
-    v7 = _48EA1B_get_static_effect(v6) + v4 + 30;
-    if ( rand() % v7 >= 30 )
-    {
-      v18 = type >> 1;
-      v8 = GetActualLuck();
-      v9 = _48EA1B_get_static_effect(v8) + v4 + 30;
-      if ( rand() % v9 >= 30 )
+  player_luck = GetActualLuck();
+  res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30;
+
+  if ( resist_value )
+  { 
+    if ( rand() % res_rand_divider >= 30 )
+    {
+      result_amount_dmg = amount >> 1;
+      if ( rand() % res_rand_divider >= 30 )
       {
-        v18 = type >> 2;
-        v10 = GetActualLuck();
-        v11 = _48EA1B_get_static_effect(v10) + v4 + 30;
-        if ( rand() % v11 >= 30 )
+        result_amount_dmg = amount >> 2;
+        if ( rand() % res_rand_divider >= 30 )
         {
-          v18 = type >> 3;
-          v12 = GetActualLuck();
-          v13 = _48EA1B_get_static_effect(v12) + v4 + 30;
-          if ( rand() % v13 >= 30 )
-            v18 = type >> 4;
+          result_amount_dmg = amount >> 3;
+          if ( rand() % res_rand_divider >= 30 )
+            result_amount_dmg = amount >> 4;
         }
       }
     }
   }
-  if ( resistance == 4 )
-  {
-    v14 = v3->pEquipment.uArmor;
-    if ( v14 )
-    {
-     // if ( !(v3->field_1F5[36 * v14 + 15] & 2) )
-      if (v3->pOwnItems[v14-1].uAttributes&2) 
+  if (( dmg_type == DMGT_PHISYCAL )&&( pEquipment.uArmor ))
+  {
+      if (!pOwnItems[pEquipment.uArmor-1].Broken()) 
       {
-        v15 = GetEquippedItemSkillType(EQUIP_ARMOUR) - 10;
-        if ( v15 )
+        armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR);
+        if ( armor_skill==PLAYER_SKILL_PLATE )
         {
-          if ( v15 != 1 || (signed int)SkillToMastery(v3->pActiveSkills[11]) < 3 )
-            return v18;
-          v16 = (double)v18 * 0.5;
-          return (signed __int64)v16;
+          if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 )
+              return (int)(double)result_amount_dmg * 0.5;
         }
-        if ( (signed int)SkillToMastery(v3->pActiveSkills[10]) >= 4 )
+        if (armor_skill==PLAYER_SKILL_CHAIN )
         {
-          v16 = (double)v18 * 0.66670001;
-          return (signed __int64)v16;
+          if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4) 
+             return (int)(double)result_amount_dmg * 0.66670001;
         }
       }
-    }
-  }
-  return v18;
+  }
+  return result_amount_dmg;
 }
 
 //----- (0048D62C) --------------------------------------------------------
@@ -3311,8 +3249,9 @@
 {
   auto i = pEquipment.pIndices[uEquipIndex];
   if (i)
-    return ~pInventoryItems[i - 1].uAttributes & 0x02;
-  else return false;
+    return ~(pInventoryItems[i - 1].uAttributes & ITEM_BROKEN);
+  else 
+    return false;
 }
 
 //----- (0048D6D0) --------------------------------------------------------
@@ -3588,58 +3527,45 @@
 }
 
 //----- (0048DC1E) --------------------------------------------------------
-int Player::ReceiveDamage(signed int type, int resistance)
-{
-  Player *v3; // esi@1
-  signed int v4; // eax@1
-  int v5; // eax@1
-  bool v6; // ebx@1
-  unsigned int v7; // eax@8
-  char *v8; // ecx@9
-  int v9; // eax@9
-  //signed int typea; // [sp+14h] [bp+8h]@1
-
-  v3 = this;
-  this->pConditions[Condition_Sleep] = 0i64;
-  v4 = CalculateIncommingDamage(resistance, type);
-  v3->sHealth -= v4;
-  //typea = v4;
-  v5 = v3->sHealth;
-  v6 = v5 < -10;
-  LOBYTE(v6) = v5 <= -10;
-  if ( v5 < 1 )
-  {
-    if ( v3->sHealth + v3->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1
-      || (signed __int64)v3->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 )
+int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type )
+    {
+  signed int recieved_dmg; // eax@1
+  unsigned int armor_indx; // eax@8
+  bool broke_armor;
+ 
+  pConditions[Condition_Sleep] = 0i64;
+  recieved_dmg = CalculateIncommingDamage(dmg_type, amount);
+  sHealth -= recieved_dmg;
+  broke_armor = sHealth <= -10;
+  if ( sHealth < 1 ) //
+  {
+    if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1)
+      || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0i64 )
     {
       SetCondition(Condition_Unconcious, 0);
     }
     else
     {
       SetCondition(Condition_Dead, 0);
-      v6 = LODWORD(pParty->uTimePlayed);
-      if ( v3->sHealth > 0 )
-        v3->sHealth = 0;
-    }
-    if ( v6 )
-    {
-      v7 = v3->pEquipment.uArmor;
-      if ( v7 )
+      //v6 = LODWORD(pParty->uTimePlayed); ???? if equals 0 do not broke armor?
+      if ( sHealth > 0 )
+        sHealth = 0;
+    }
+    if (broke_armor )
+    {
+      armor_indx = pEquipment.uArmor;
+      if ( armor_indx )
       {
-//        v8 = &v3->field_1F5[36 * v7 + 15];
-        v8=(char*)&v3->pOwnItems[v7-1].uAttributes;
-        v9 = *(int *)v8;
-        if ( !(BYTE1(v9) & 2) )
+        if ( !pOwnItems[armor_indx-1].uAttributes & ITEM_ENCHANTED)
         {
-          LOBYTE(v9) = v9 | 2;
-          *(int *)v8 = v9;
+          pOwnItems[armor_indx-1].uAttributes|=ITEM_BROKEN;
         }
       }
     }
   }
-  if ( v4 && CanAct() )
+  if ( recieved_dmg && CanAct() )
     PlaySound(SPEECH_24, 0);
-  return v4;
+  return recieved_dmg;
 }
 
 //----- (0048DCF6) --------------------------------------------------------
@@ -3730,9 +3656,9 @@
       goto LABEL_47;
     case 22:
       v8 = GetActualWillpower();
-      v9 = _48EA1B_get_static_effect(v8);
+      v9 = GetParameterBonus(v8);
       v10 = GetActualIntelligence();
-      v11 = (_48EA1B_get_static_effect(v10) + v9) >> 1;
+      v11 = (GetParameterBonus(v10) + v9) >> 1;
       break;
     case 17:
       v12 = 0;
@@ -3805,7 +3731,7 @@
       v47 = (unsigned __int8)v46[rand() % v4];
       v6 = GetActualAccuracy();
 LABEL_46:
-      v7 = _48EA1B_get_static_effect(v6);
+      v7 = GetParameterBonus(v6);
 LABEL_47:
       v11 = v7;
       break;
@@ -3814,7 +3740,7 @@
       break;
   }
   v22 = GetActualLuck();
-  v23 = _48EA1B_get_static_effect(v22) + v11 + 30;
+  v23 = GetParameterBonus(v22) + v11 + 30;
   if ( rand() % v23 >= 30 )
   {
 LABEL_87:
@@ -4110,7 +4036,7 @@
     shield_recovery = shield_base_recovery * SkillToMastery(pActiveSkills[skill_type]);
   }
 
-  uint player_speed_recovery_reduction = _48EA1B_get_static_effect(GetActualSpeed()),
+  uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()),
        sword_axe_bow_recovery_reduction = 0;
   bool shooting_laser = false;
   if (weapon_desc)
@@ -4171,7 +4097,7 @@
   int v4; // esi@1
   int v6; // esi@1
 
-  v3 = _48EA1B_get_static_effect(GetActualEndurance());
+  v3 = GetParameterBonus(GetActualEndurance());
   v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3);
   v6 = uFullHealthBonus
      + pBaseHealthByClass[classType / 4]
@@ -4209,7 +4135,7 @@
     case 0x22u:
     case 0x23u:
       v2 = GetActualIntelligence();
-      v3 = _48EA1B_get_static_effect(v2);
+      v3 = GetParameterBonus(v2);
       goto LABEL_6;
     case 9u:
     case 0xAu:
@@ -4223,7 +4149,7 @@
     case 0x1Au:
     case 0x1Bu:
       v2 = GetActualWillpower();
-      v3 = _48EA1B_get_static_effect(v2);
+      v3 = GetParameterBonus(v2);
       goto LABEL_6;
     case 0x15u:
     case 0x16u:
@@ -4233,9 +4159,9 @@
     case 0x1Eu:
     case 0x1Fu:
       v4 = GetActualWillpower();
-      v5 = _48EA1B_get_static_effect(v4);
+      v5 = GetParameterBonus(v4);
       v6 = GetActualIntelligence();
-      v3 = _48EA1B_get_static_effect(v6) + v5;
+      v3 = GetParameterBonus(v6) + v5;
 LABEL_6:
       v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3);
       v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA, 0) + v7;
@@ -4267,7 +4193,7 @@
 
   v1 = this;
   v2 = GetActualSpeed();
-  v3 = _48EA1B_get_static_effect(v2);
+  v3 = GetParameterBonus(v2);
   v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3;
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4;
   if ( v5 >= 1 )
@@ -4290,7 +4216,7 @@
 
   v1 = this;
   v2 = GetActualSpeed();
-  v3 = _48EA1B_get_static_effect(v2);
+  v3 = GetParameterBonus(v2);
   v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3;
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4;
   v6 = v1->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5;
@@ -4516,16 +4442,17 @@
 }
 
 //----- (0048EA1B) --------------------------------------------------------
-int Player::_48EA1B_get_static_effect(int a2)
-{
-  __int16 v2; // cx@1
-  int v3; // eax@1
-
-  v2 = word_4EDFFC[0];
-  v3 = 0;
-  while ( a2 < v2 && v2 )
-    v2 = word_4EDFFC[v3++ + 1];
-  return player_stat_bonuses[v3];
+int Player::GetParameterBonus( int player_parameter )
+    {
+  int i; // eax@1
+  i = 0;
+  while (param_to_bonus_table[i])
+      { 
+      if (player_parameter >= param_to_bonus_table[i])
+          break;
+      ++i;    
+      }   
+  return parameter_to_bonus_value[i];
 }
 
 //----- (0048EA46) --------------------------------------------------------
@@ -9277,7 +9204,7 @@
           pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
           return result;
         case VAR_CurrentHP:
-          ReceiveDamage((signed int)pValue, 4);
+          ReceiveDamage((signed int)pValue, DMGT_PHISYCAL);
           pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
           v8 = 8 * v4 + 400;
           LOBYTE(v8) = PID(OBJECT_Player,v4 - 112);