diff Player.cpp @ 1018:9ac94d00012e

Merge
author Grumpy7
date Tue, 21 May 2013 02:24:31 +0200
parents c45d51b3f4f4 a704435d3285
children 3413ad40cc88
line wrap: on
line diff
--- a/Player.cpp	Sun May 19 20:41:19 2013 +0200
+++ b/Player.cpp	Tue May 21 02:24:31 2013 +0200
@@ -113,6 +113,8 @@
 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};
 
 
+unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0};
+
 
 unsigned short base_recovery_times_per_weapon_type[12] =
 {
@@ -221,27 +223,21 @@
 
 
 //----- (004BE2DD) --------------------------------------------------------
-void Player::SalesProcess(unsigned int a2, int a3, int _2devent_idx)
-{
-  Player *v4; // edi@1
-  char *v5; // esi@1
+void Player::SalesProcess( unsigned int inventory_idnx, int item_index, int _2devent_idx )
+    {
   float v6; // ST04_4@1
-  signed int v7; // eax@1
-  signed int v8; // ebx@1
-
-  auto a4 = _2devent_idx;
-  v4 = this;
-  v5 = (char *)this + 36 * a3;
-  v6 = p2DEvents[a4 - 1].fPriceMultiplier;
-  //v6 = p2DEvents_minus1__20[13 * a4];
-  v7 = ((ItemGen *)(v5 + 532))->GetValue();
-  v8 = GetPriceSell(v7, v6);
-  if ( v5[552] & 2 )
-    v8 = 1;
-  if ( v8 < 1 )
-    v8 = 1;
-  RemoveItemAtInventoryIndex(a2);
-  Party::SetGold(pParty->uNumGold + v8);
+  signed int item_value; // eax@1
+  signed int sell_price; // ebx@1
+
+  item_value =pOwnItems[item_index].GetValue();
+  v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier;
+  sell_price = GetPriceSell(item_value, v6);
+  if ( pOwnItems[item_index].Broken() )
+    sell_price = 1;
+  if ( sell_price < 1 )
+    sell_price = 1;
+  RemoveItemAtInventoryIndex(inventory_idnx);
+  Party::SetGold(pParty->uNumGold + sell_price);
 }
 
 
@@ -249,35 +245,21 @@
 //----- (0043EEF3) --------------------------------------------------------
 bool Player::_43EEF3()
 {
-  signed int v1; // esi@1
-  PlayerEquipment *v2; // edx@1
-  bool result; // eax@2
-
-  v1 = 0;
-  v2 = &this->pEquipment;
-  while ( 1 )
-  {
-    result = v2->uShield;
-    if ( v2->uShield )
-    {
-      result = *(int *)&this->pInventoryItems[result-1];
-      if ( result )
-      {
-        if ( result != 64 && result != 65 )
-          break;
-      }
-    }
-    ++v1;
-    v2 = (PlayerEquipment *)((char *)v2 + 4);
-    if ( v1 >= 16 )
-    {
-      LOBYTE(result) = 1;
-      return result;
-    }
-  }
-  LOBYTE(result) = 0;
-  return result;
-}
+  signed int item_idx; // esi@1
+  signed int item_id; // esi@1
+  for (int i=0; i<16;++i)
+      {
+     item_idx=pEquipment.pIndices[i];
+     if (item_idx)
+         {
+         item_id=pOwnItems[item_idx-1].uItemID;
+         if (item_id!=64 &&  item_id!= 65 ) //blaster& blaster rifle
+             return false;
+         }
+      }
+      return true;
+  }
+  
 
 
 
@@ -457,7 +439,7 @@
 
   v1 = this;
   v2 = (signed int)window_SpeakInHouse->ptr_1C;
-  if ( v2 == 78 || v2 > 80 && v2 <= 82 )
+  if ( (v2 == 78 || v2 > 80) && v2 <= 82 )
   {
     if ( GetMajorConditionIdx() == 18 )
       goto LABEL_6;
@@ -478,97 +460,66 @@
 
 
 //----- (00421E75) --------------------------------------------------------
-unsigned int Player::GetItemIDAtInventoryIndex(int *a2)
-{
-  int v2; // eax@1
-  unsigned int result; // eax@3
-
-  v2 = *a2;
-  if ( *a2 >= 126 || v2 < 0 )
-  {
-    result = 0;
-  }
-  else
-  {
-    result = this->pInventoryIndices[v2];
-    if ( (result & 0x80000000u) != 0 )
-    {
-      *a2 = -1 - result;
-      result = this->pInventoryIndices[-1 - result];
-    }
-  }
-  return result;
+unsigned int Player::GetItemIDAtInventoryIndex(int *pitem_index)
+{
+  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->pInventoryIndices[item_idx];
+    if ( inv_index < 0 )
+    {
+      *pitem_index = -1 - inv_index;
+      inv_index = this->pInventoryIndices[-1 - inv_index];
+    }
+
+  return inv_index;
 }
 
 
 
 //----- (004160CA) --------------------------------------------------------
-char Player::_4160CA(int a2)
-{
-  Player *v2; // esi@1
-  signed int v3; // edx@1
-  signed int v4; // ebx@1
-  ItemGen *v5; // eax@1
-  int v6; // edi@2
-  signed int i; // edx@8
-  ItemGen **v8; // ecx@9
-  __int16 v10[137]; // [sp+Ch] [bp-118h]@1
-  __int16 v11; // [sp+11Eh] [bp-6h]@1
-  int v12; // [sp+120h] [bp-4h]@1
-
-  auto a1 = this;
-
-  v12 = a2;
-  v2 = a1;
-  v3 = 0;
-  v10[0] = 0;
-  v4 = 0;
-  memset(&v10[1], 0, 0x110u);
-  v11 = 0;
-  v5 = a1->pInventoryItems;
-  do
-  {
-    v6 = 0;
-    if ( (signed int)v5->uItemID > 0 && (signed int)v5->uItemID <= 134 )
-      v10[v4++] = v3;
-    ++v3;
-    ++v5;
-  }
-  while ( v3 < 138 );
-  if ( v4 )
-  {
-    if ( v12 )
-    {
-      if ( v12 > 0 )
-      {
-        do
+void Player::ItemsEnchant( int enchant_count )
+    {
+  int avalible_items; // ebx@1
+  int i; // edx@8
+  __int16 item_index_tabl[138]; // [sp+Ch] [bp-118h]@1
+ 
+  avalible_items = 0;
+  memset (item_index_tabl,0,sizeof(item_index_tabl));
+
+  for (i=0; i<138; ++i)
+      {
+       if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID<= 134))
+           item_index_tabl[avalible_items++] = i;
+      }
+
+  if ( avalible_items )
+  {
+    if ( enchant_count )
+    {
+    for ( i = 0; i < enchant_count; ++i )
         {
-          LOWORD(v5) = 9 * v10[v6];
-          if ( !(BYTE1(v2->pInventoryItems[v10[v6]].uAttributes) & 2) )
-          {
-            v5 = (ItemGen *)((char *)&v2->pInventoryItems[v10[rand() % v4]] + 20);
-            v5->uItemID |= 2u;
-          }
-          ++v6;
+        if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
+                pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes|=ITEM_ENCHANTED; 
         }
-        while ( v6 < v12 );
-      }
+       
     }
     else
     {
-      for ( i = 0; i < v4; ++i )
-      {
-        v8 = (ItemGen **)&v2->pInventoryItems[v10[i]].uAttributes;
-        v5 = *v8;
-        if ( !(BYTE1(v5) & 2) )
-        {
-          LOBYTE(v5) = (unsigned __int8)v5 | 2;
-          *v8 = v5;
-        }
-      }
-    }
-  }
-  return (char)v5;
+      for ( i = 0; i < avalible_items; ++i )
+      {
+        if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
+                pInventoryItems[item_index_tabl[i]].uAttributes|=ITEM_ENCHANTED;
+      }
+    }
+  }
+ ;
 }
 
 //----- (004948B1) --------------------------------------------------------
@@ -699,7 +650,7 @@
       {
         if ( v3 > 11 )
         {
-          if ( v3 == CHARACTER_EXPRESSION_PERTIFIED || v3 > 97 && v3 <= 99 )
+          if ( v3 == CHARACTER_EXPRESSION_PERTIFIED ||( v3 > 97 && v3 <= 99) )
             return;
           goto LABEL_15;
         }
@@ -1103,260 +1054,220 @@
 
 //----- (00492D65) --------------------------------------------------------
 int Player::SetCondition(unsigned int uConditionIdx, int a3)
-{
-  Player *v3; // esi@1
-  Player **v4; // ebx@2
-  Player *v5; // ecx@21
-  Player *v6; // ecx@22
-  Player *v7; // ecx@29
-  Player *v8; // ecx@30
-  Player *v9; // ecx@37
-  Player *v10; // ecx@38
-  Player *v11; // ecx@45
-  Player *v12; // ecx@46
-  char *v13; // eax@49
-  Player *v14; // ecx@58
-  Player *v15; // ecx@59
-  Player *v16; // ecx@60
-  signed int result; // eax@76
-  signed int v18; // ecx@77
-  int v19; // eax@77
-  char v20; // al@80
-  signed int v21; // ebx@82
-  signed int v22; // esi@82
-  int v23; // [sp-8h] [bp-1Ch]@7
-  int v24; // [sp-8h] [bp-1Ch]@15
-  int v25; // [sp-8h] [bp-1Ch]@53
-  int v26; // [sp-4h] [bp-18h]@7
-  signed int v27; // [sp-4h] [bp-18h]@15
-  int v28; // [sp-4h] [bp-18h]@53
-  char *v29; // [sp+Ch] [bp-8h]@1
-  int v30; // [sp+10h] [bp-4h]@2
-  int v31; // [sp+20h] [bp+Ch]@82
-
-  v3 = this;
-  v29 = (char *)this + 8 * uConditionIdx;
-  if ( *(_QWORD *)v29 )
-  {
-LABEL_76:
-    result = 0;
-  }
-  else
-  {
-    v4 = &pPlayers[1];
-    v30 = 0;
-    do
-    {
-      if ( (*v4)->CanAct() )
-        ++v30;
-      ++v4;
-    }
-    while ( (signed int)v4 <= (signed int)&pPlayers[4] );
+    {
+
+    signed int player_sex; // ecx@77
+    char zombi_face; // al@80
+    signed int remainig_player; // ebx@82
+    int players_before; // [sp+10h] [bp-4h]@2
+    int players_after; // [sp+20h] [bp+Ch]@82
+
+    if ( pConditions[uConditionIdx] )
+        return 0;
+    players_before = 0;
+    for (int i=1;i<5;++i)
+        if ( pPlayers[i]->CanAct() )
+            ++players_before;
+
     switch ( uConditionIdx )
-    {
-      case 0u:
-        v26 = 0;
-        v23 = 30;
-        goto LABEL_81;
-      case 1u:
+        {
+    case Condition_Cursed:
+        PlaySound((PlayerSpeech)30, 0);
+        break;
+    case Condition_Weak:
         if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 )
-          goto LABEL_10;
-        v26 = 0;
-        v23 = 25;
-        goto LABEL_81;
-      case 2u:
-        if ( a3 != 1 )
-          goto LABEL_82;
-        if ( v3->HasEnchantedItemEquipped(22) )
-          goto LABEL_76;
-        v27 = 3;
-        v24 = 505;
-        goto LABEL_16;
-      case 3u:
-        v26 = 0;
-        v23 = 26;
-        goto LABEL_81;
-      case 4u:
-        v26 = 0;
-        v23 = 31;
-        goto LABEL_81;
-      case 5u:
+            {--pParty->pPartyBuffs[13].uPower;
+        if ( pParty->pPartyBuffs[13].uPower < 1u )
+            pParty->pPartyBuffs[13].Reset();
+        return 0;
+            }
+
+        PlaySound((PlayerSpeech)25, 0);
+        break;
+    case Condition_Sleep:
+        if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||WearsItem(505, 3))) 
+            return 0;
+        break;
+
+    case Condition_Fear:
+        PlaySound((PlayerSpeech)26, 0);
+        break;
+    case Condition_Drunk:
+        PlaySound((PlayerSpeech)31, 0);
+        break;
+
+    case Condition_Insane:
         if ( a3 == 1
-          && (v3->HasEnchantedItemEquipped(19) || v5->WearsItem(505, 3) || v6->WearsItem(530, 6)) )
-          goto LABEL_76;
-        v26 = 0;
-        v23 = 29;
-        goto LABEL_81;
-      case 6u:
-      case 8u:
-      case 0xAu:
+            && (HasEnchantedItemEquipped(19) || WearsItem(505, 3) || WearsItem(530, 6)) )
+            return 0;
+
+        PlaySound((PlayerSpeech)29, 0);
+        break;
+    case Condition_Poison1:
+    case Condition_Poison2:
+    case Condition_Poison3:
+        if ( a3 == 1 )
+            {
+            if ( (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0i64 )
+                {
+                --pParty->pPartyBuffs[13].uPower;
+                if ( pParty->pPartyBuffs[13].uPower < 1u )
+                    pParty->pPartyBuffs[13].Reset();
+                }
+            if ( HasEnchantedItemEquipped(21)
+                || WearsItem(505, 3)
+                || WearsItem(530, 6) )
+                //goto LABEL_76;
+                return 0;
+            }
+
+        //v23 = 27;
+        PlaySound((PlayerSpeech)27, 0);
+        break;
+
+    case Condition_Disease1:
+    case Condition_Disease2:
+    case Condition_Disease3:
         if ( a3 == 1 )
-        {
-          if ( (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 )
-          {
+            {            
+            if ( pParty->pPartyBuffs[13].uExpireTime > 0i64 )
+                {
+                --pParty->pPartyBuffs[13].uPower;
+                if ( pParty->pPartyBuffs[13].uPower < 1u )
+                    pParty->pPartyBuffs[13].Reset();
+                return 0;
+                }
+
+            if ( HasEnchantedItemEquipped(18) ||WearsItem(505, 3) || WearsItem(530, 6) )
+                return 0;
+            }
+        PlaySound((PlayerSpeech)28, 0);
+        break;
+    case Condition_Paralyzed:
+        if ( a3 == 1 )
+            {
+            if ( pParty->pPartyBuffs[13].uExpireTime > 0i64 )
+                {
+                --pParty->pPartyBuffs[13].uPower;
+                if ( pParty->pPartyBuffs[13].uPower < 1u )
+                    pParty->pPartyBuffs[13].Reset();
+                return 0;
+                }
+
+            if ( HasEnchantedItemEquipped(20)|| WearsItem(505, 3)|| WearsItem(507, 16)||WearsItem(530, 6))
+                return 0;
+            }
+        break;
+    case Condition_Unconcious:
+        PlaySound(SPEECH_32, 0);
+        if ( sHealth > 0 )
+            sHealth = 0;
+        break;
+    case Condition_Dead:
+        if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0i64 && pParty->pPartyBuffs[13].uSkill >= 4u )
+            {
             --pParty->pPartyBuffs[13].uPower;
             if ( pParty->pPartyBuffs[13].uPower < 1u )
-              pParty->pPartyBuffs[13].Reset();
-          }
-          if ( v3->HasEnchantedItemEquipped(21)
-            || v7->WearsItem(505, 3)
-            || v8->WearsItem(530, 6) )
-            goto LABEL_76;
-        }
-        v26 = 0;
-        v23 = 27;
-        goto LABEL_81;
-      case 7u:
-      case 9u:
-      case 0xBu:
-        if ( a3 != 1 )
-          goto LABEL_40;
-        if ( SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) >= 0
-          && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[13].uExpireTime) > 0) )
-          goto LABEL_10;
-        if ( v3->HasEnchantedItemEquipped(18) || v3->WearsItem(505, 3) || v3->WearsItem(530, 6) )
-          goto LABEL_76;
-LABEL_40:
-        v26 = 0;
-        v23 = 28;
-        goto LABEL_81;
-      case 0xCu:
-        if ( a3 != 1 )
-          goto LABEL_82;
-        if ( SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) >= 0
-          && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[13].uExpireTime) > 0) )
-          goto LABEL_10;
-        if ( v3->HasEnchantedItemEquipped(20)
-          || v11->WearsItem(505, 3)
-          || v12->WearsItem(507, 16) )
-          goto LABEL_76;
-        v27 = 6;
-        v24 = 530;
-LABEL_16:
-        if ( v3->WearsItem(v24, v27) )
-          goto LABEL_76;
-        goto LABEL_82;
-      case 0xDu:
-        v3->PlaySound(SPEECH_32, 0);
-        v13 = (char *)&v3->sHealth;
-        goto LABEL_70;
-      case 0xEu:
-        if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 && pParty->pPartyBuffs[13].uSkill >= 4u )
-          goto LABEL_10;
-        v28 = 0;
-        v25 = 33;
-        goto LABEL_67;
-      case 0xFu:
+                pParty->pPartyBuffs[13].Reset();
+            }
+
+        PlaySound((PlayerSpeech)33, 0);
+        if ( sHealth > 0 )
+            sHealth = 0;
+        if ( sMana > 0 )
+            sMana = 0;
+        break;
+    case Condition_Pertified:
         if ( a3 == 1
-          && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) >= 0
-           && (SHIDWORD(pParty->pPartyBuffs[13].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[13].uExpireTime) > 0)
-           || v3->HasEnchantedItemEquipped(23)
-           || v14->WearsItem(520, 16)
-           || v15->WearsItem(505, 3)
-           || v16->WearsItem(530, 6)) )
-          goto LABEL_76;
-        v26 = 0;
-        v23 = 34;
-        goto LABEL_81;
-      case 0x10u:
-        if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 && pParty->pPartyBuffs[13].uSkill >= 4u )
-        {
-LABEL_10:
-          --pParty->pPartyBuffs[13].uPower;
-          if ( pParty->pPartyBuffs[13].uPower < 1u )
-            pParty->pPartyBuffs[13].Reset();
-          goto LABEL_76;
+            &&((pParty->pPartyBuffs[13].uExpireTime > 0i64)
+            || HasEnchantedItemEquipped(23)|| WearsItem(520, 16) || WearsItem(505, 3) || WearsItem(530, 6)) )
+
+            return 0;
+        PlaySound((PlayerSpeech)34, 0);
+        break;
+    case Condition_Eradicated:
+        if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 )&&( pParty->pPartyBuffs[13].uSkill >= 4u ))
+            {
+            --pParty->pPartyBuffs[13].uPower;
+            if ( pParty->pPartyBuffs[13].uPower < 1u )
+                pParty->pPartyBuffs[13].Reset();
+            return 0;
+            }
+        PlaySound(SPEECH_35, 0);
+        if (sHealth > 0 )
+            sHealth = 0;
+        if ( sMana > 0 )
+            sMana = 0;
+        break;
+    case Condition_Zombie:
+        if ( classType == PLAYER_CLASS_LICH || Eradicated() ||Zombie() || !Dead())
+            return 0;
+        memset(&pConditions[0], 0, sizeof(pConditions));
+        sHealth = GetMaxHealth();
+        sMana = 0;
+        player_sex = 0;
+        uPrevFace = uCurrentFace;
+        uPrevVoiceID = uVoiceID;
+        switch ( uVoiceID )
+            {
+        case 0:
+        case 1:
+        case 2:
+        case 3:
+        case 8:
+        case 9:
+        case 12:
+        case 13:
+        case 16:
+        case 17:
+        case 20:
+        case 23:
+            player_sex = 0;
+            break;
+        case 4:
+        case 5:
+        case 6:
+        case 7:
+        case 10:
+        case 11:
+        case 14:
+        case 15:
+        case 18:
+        case 19:
+        case 21:
+        case 24:
+            player_sex = 1;
+            break;
+        default:
+            break;
+            }
+
+        zombi_face = (player_sex != 0) + 23;
+        uCurrentFace = zombi_face;
+        uVoiceID = zombi_face;
+        PlaySound((PlayerSpeech)SPEECH_99, 0);
+        break;
         }
-        v28 = 0;
-        v25 = SPEECH_35;
-LABEL_67:
-        v3->PlaySound((PlayerSpeech)v25, v28);
-        if ( v3->sHealth > 0 )
-          v3->sHealth = 0;
-        v13 = (char *)&v3->sMana;
-LABEL_70:
-        if ( *(int *)v13 > 0 )
-          *(int *)v13 = 0;
-LABEL_82:
-        v21 = 0;
-        *(_QWORD *)v29 = pParty->uTimePlayed;
-        v31 = 0;
-        v22 = 1;
-        do
-        {
-          if ( pPlayers[v22]->CanAct() )
-          {
-            ++v31;
-            v21 = v22;
-          }
-          ++v22;
-        }
-        while ( v22 <= 4 );
-        if ( v30 == 2 )
-        {
-          if ( v31 == 1 )
-            pPlayers[v21]->PlaySound(SPEECH_107, 0);
-        }
-        result = 1;
-        break;
-      case 0x11u:
-        if ( v3->classType == PLAYER_CLASS_LICH || v3->Eradicated() ||
-            v3->Zombie() || !v3->Dead())
-          goto LABEL_76;
-        memset(v3, 0, 0xA0u);
-        v3->sHealth = v3->GetMaxHealth();
-        v18 = 0;
-        v3->field_1928 = v3->uFace;
-        v19 = v3->uVoiceID;
-        v3->sMana = 0;
-        v3->field_1924 = v19;
-        switch ( v19 )
+
+    remainig_player = 0;
+    pConditions[uConditionIdx] = pParty->uTimePlayed;
+    players_after = 0;
+    for (int i=1;i<5;++i)
         {
-          case 0:
-          case 1:
-          case 2:
-          case 3:
-          case 8:
-          case 9:
-          case 12:
-          case 13:
-          case 16:
-          case 17:
-          case 20:
-          case 23:
-            v18 = 0;
-            break;
-          case 4:
-          case 5:
-          case 6:
-          case 7:
-          case 10:
-          case 11:
-          case 14:
-          case 15:
-          case 18:
-          case 19:
-          case 21:
-          case 24:
-            v18 = 1;
-            break;
-          default:
-            break;
+
+
+        if ( pPlayers[i]->CanAct() )
+            {
+            remainig_player=i;
+            ++players_after;
+            }
         }
-        v26 = 0;
-        v20 = (v18 != 0) + 23;
-        v23 = SPEECH_99;
-        v3->uFace = v20;
-        v3->uVoiceID = v20;
-LABEL_81:
-        v3->PlaySound((PlayerSpeech)v23, v26);
-        goto LABEL_82;
-      default:
-        goto LABEL_82;
-    }
-  }
-  return result;
-}
+    if (( players_before == 2 )&&( players_after == 1 ))
+        {
+        pPlayers[remainig_player]->PlaySound(SPEECH_107, 0);
+        }
+    return 1;
+    }
 
 //----- (00492528) --------------------------------------------------------
 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID)
@@ -1377,7 +1288,7 @@
   if ( !areWeLoadingTexture )
   {
     v4->Release();
-    pIcons_LOD->_40F9C5();
+    pIcons_LOD->SyncLoadedFilesCount();
   }
   if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 )
   {
@@ -1472,7 +1383,7 @@
     if ( !areWeLoadingTexture )
     {
       v8->Release();
-      pIcons_LOD->_40F9C5();
+      pIcons_LOD->SyncLoadedFilesCount();
     }
     if ( (signed int)uItemIDa > 0 )
     {
@@ -1515,40 +1426,29 @@
 //----- (00492745) --------------------------------------------------------
 int Player::WearItem(unsigned int uItemID)
 {
-  signed int v2; // eax@1
-  ItemGen *v3; // edx@1
-  int v4; // edi@6
-  char *v5; // eax@6
-  char *v6; // esi@6
-
-  __debugbreak(); // sub is definetly broken
-
-  v2 = 0;
-  v3 = this->pInventoryItems;
-  while ( v3->uItemID )
-  {
-    ++v2;
-    ++v3;
-    if ( v2 >= 126 )
-    {
-      v2 = -1;
-      break;
-    }
-  }
-  if ( v2 != -1 )
-  {
-    v4 = v2 + 1;
-    v5 = (char *)this + 36 * v2;
-    v6 = &byte_4E8394[pItemsTable->pItems[uItemID].uEquipType + 4];
-    *(&this->pEquipment.uShield + (unsigned __int8)*v6) = v4;
-    *((int *)v5 + 133) = uItemID;
-    v5[556] = *v6 + 1;
+  int item_body_anch; // edi@6
+  int item_indx;
+  //find empty slot
+  for(item_indx=0;item_indx<126;++item_indx)
+      if (pInventoryItems[item_indx].uItemID==0)
+          break; 
+  if (item_indx==126) //not found
+      item_indx=-1;
+  
+  if ( item_indx != -1 )
+  {
+
+    pInventoryItems[item_indx].uItemID=uItemID;
+    item_body_anch=pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType];
+    pEquipment.pIndices[item_body_anch]=item_indx+1;
+    pInventoryItems[item_indx].uBodyAnchor=item_body_anch+1;
+
   }
   return 0;
 }
 
 //----- (004927A8) --------------------------------------------------------
-int Player::AddItem(unsigned int uSlot, unsigned int uItemID)
+int Player::AddItem(int uSlot, unsigned int uItemID)
 {
   signed int v3; // ebx@2
   signed int v4; // edi@3
@@ -1561,7 +1461,7 @@
   if ( uSlot == -1 )
   {
     v3 = 0;
-    while ( 2 )
+    while ( true )
     {
       v4 = 0;
       v5 = v3;
@@ -1595,7 +1495,7 @@
 }
 
 //----- (00492826) --------------------------------------------------------
-int Player::AddItem2(unsigned int uSlot, ItemGen *Src)
+int Player::AddItem2(int uSlot, ItemGen *Src)
 {
   unsigned int v3; // ebx@1
   unsigned int v4; // esi@3
@@ -1611,7 +1511,7 @@
   if ( uSlot == -1 )
   {
     uSlota = 0;
-    while ( 2 )
+    while ( true )
     {
       v4 = uSlota;
       v5 = 0;
@@ -1648,13 +1548,13 @@
   ItemGen *v4; // eax@1
   int result; // eax@6
   //unsigned int v6; // eax@7
-  Texture *v7; // esi@7
+  Texture *item_texture; // esi@7
   unsigned int v8; // edx@9
-  void *v9; // esi@10
-  unsigned int v10; // [sp+4h] [bp-Ch]@7
-  unsigned int v11; // [sp+8h] [bp-8h]@7
+  int *pInvPos; // esi@10
+  unsigned int slot_width; // [sp+4h] [bp-Ch]@7
+  unsigned int slot_height; // [sp+8h] [bp-8h]@7
   Player *v12; // [sp+Ch] [bp-4h]@1
-  unsigned int uSlota; // [sp+18h] [bp+8h]@10
+
 
   v12 = this;
   v3 = 0;
@@ -1675,30 +1575,28 @@
   }
   else
   {
-    v7 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[Src->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v10 = GetSizeInInventorySlots(v7->uTextureWidth);
-    v11 = GetSizeInInventorySlots(v7->uTextureHeight);
+    item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[Src->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+    slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
+    slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
     if ( !areWeLoadingTexture )
     {
-      v7->Release();
-      pIcons_LOD->_40F9C5();
-    }
-    v8 = uSlot;
-    if ( (signed int)v11 > 0 )
-    {
-      uSlota = v11;
-      v9 = &v12->pInventoryIndices[v8];
+      item_texture->Release();
+      pIcons_LOD->SyncLoadedFilesCount();
+    }
+    if ( slot_height > 0 )
+    {
+      pInvPos = &pInventoryIndices[uSlot];
       do
       {
-        if ( (signed int)v10 > 0 )
-          memset32(v9, -1 - v8, v10);
-        v9 = (char *)v9 + 56;
-        --uSlota;
-      }
-      while ( uSlota );
-    }
-    v12->pInventoryIndices[v8] = v3 + 1;
-    memcpy(&v12->pInventoryItems[v3], Src, 0x24u);
+        if ( slot_width > 0 )
+          memset32(pInvPos, -1 - uSlot, slot_width);
+        pInvPos +=14;
+        --slot_height;
+      }
+      while ( slot_height );
+    }
+    pInventoryIndices[uSlot] = v3 + 1;
+    memcpy(&pInventoryItems[v3], Src, sizeof(ItemGen));
     result = v3 + 1;
   }
   return result;
@@ -1706,83 +1604,74 @@
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (0049298B) --------------------------------------------------------
-bool Player::_49298B(ItemGen *a2, int a3, int a4)
-{
+int Player::PutItemArInventoryIndex( ItemGen *item, int item_id, int uSlot )
+    {
   //Player *v4; // ebx@1
   //unsigned int v5; // eax@1
-  Texture *v6; // esi@1
-  void *v7; // esi@4
-  unsigned int v9; // [sp+Ch] [bp-4h]@1
-  unsigned int a2a; // [sp+18h] [bp+8h]@1
-
-  v6 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[a2->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-  v9 = GetSizeInInventorySlots(v6->uTextureWidth);
-  a2a = GetSizeInInventorySlots(v6->uTextureHeight);
+  Texture *item_texture; // esi@1
+  int *pInvPos; // esi@4
+  unsigned int slot_width; // [sp+Ch] [bp-4h]@1
+  unsigned int slot_height; // [sp+18h] [bp+8h]@1
+
+  item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+  slot_width =  GetSizeInInventorySlots(item_texture->uTextureWidth);
+  slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
   if ( !areWeLoadingTexture )
   {
-    v6->Release();
-    pIcons_LOD->_40F9C5();
-  }
-  if ( (signed int)a2a > 0 )
-  {
-    v7 = &pInventoryIndices[a4];
+    item_texture->Release();
+    pIcons_LOD->SyncLoadedFilesCount();
+  }
+  if ( (signed int)slot_height > 0 )
+  {
+    pInvPos = &pInventoryIndices[uSlot]; //14x9
     do
     {
-      if ( (signed int)v9 > 0 )
-        memset32(v7, -1 - a4, v9);
-      v7 = (char *)v7 + 56;
-      --a2a;
-    }
-    while ( a2a );
-  }
-  pInventoryIndices[a4] = a3 + 1;
+      if ( (signed int)slot_width > 0 )
+        memset32(pInvPos, -1 - uSlot, slot_width);
+      pInvPos +=14;
+      --slot_height;
+    }
+    while ( slot_height );
+  }
+  pInventoryIndices[uSlot] = item_id + 1;
   return 1;
 }
 
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (00492A36) --------------------------------------------------------
-unsigned int Player::RemoveItemAtInventoryIndex(unsigned int uSlot)
-{
-  int *pIndices; // edi@1
-  ItemGen *v3; // ecx@1
-  unsigned int v4; // esi@1
-  //unsigned int v5; // eax@1
-  Texture *v6; // esi@1
-  unsigned int result; // eax@1
-  unsigned int v8; // ebp@1
-  void *v9; // edx@4
-  unsigned int uSlota; // [sp+14h] [bp+4h]@1
-
-  pIndices = &this->pInventoryIndices[uSlot];
-  v3 = &this->pInventoryItems[*pIndices-1];
-  v4 = v3->uItemID;
-  v3->Reset();
-  v6 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE);
-  uSlota = GetSizeInInventorySlots(v6->uTextureWidth);
-  result = GetSizeInInventorySlots(v6->uTextureHeight);
-  v8 = result;
+void Player::RemoveItemAtInventoryIndex( unsigned int uSlot )
+    {
+
+  ItemGen *item_in_slot; // ecx@1
+  Texture *item_texture; // esi@1
+  unsigned int slot_height; // ebp@1
+  int *pInvPos; // edx@4
+  unsigned int slot_width; // [sp+14h] [bp+4h]@1
+
+  item_in_slot = &this->pInventoryItems[pInventoryIndices[uSlot]-1];  
+  item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item_in_slot->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+  item_in_slot->Reset();
+  slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth);
+  slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight);
   if ( !areWeLoadingTexture )
   {
-    v6->Release();
-    result = pIcons_LOD->_40F9C5();
-  }
-  if ( (signed int)v8 > 0 )
-  {
-    v9 = pIndices;
+    item_texture->Release();
+    pIcons_LOD->SyncLoadedFilesCount();
+  }
+  if ( slot_height > 0 )
+  {
+    pInvPos = &pInventoryIndices[uSlot];
     do
     {
-      if ( (signed int)uSlota > 0 )
-      {
-        result = 0;
-        memset(v9, 0, 4 * uSlota);
-      }
-      v9 = (char *)v9 + 56;
-      --v8;
-    }
-    while ( v8 );
-  }
-  return result;
+      if (slot_width > 0 )
+        memset32(pInvPos, 0, slot_width);
+      pInvPos += 14;
+      --slot_height;
+    }
+    while ( slot_height );
+  }
+  
 }
 // 506128: using guessed type int areWeLoadingTexture;
 
@@ -1970,7 +1859,7 @@
 //----- (0049107D) --------------------------------------------------------
 int Player::GetBodybuilding()
 {
-  char v1; // al@1
+  int v1; // al@1
   int v2; // ecx@1
   int v4; // eax@3
   signed int v6; // [sp-4h] [bp-4h]@2
@@ -1983,7 +1872,7 @@
   }
   else
   {
-    if ( v1 >= 0 )
+    if ( (v1&0xFF) >= 0 )
     {
       v4 = ((v1 & 0x40) != 0) + 1;
       return v2 * v4;
@@ -1997,28 +1886,28 @@
 //----- (004910A8) --------------------------------------------------------
 int Player::GetMeditation()
 {
-  char v1; // al@1
-  int v2; // ecx@1
+  int v1; // al@1
+  int base_level; // ecx@1
   int v4; // eax@3
   signed int v6; // [sp-4h] [bp-4h]@2
 
   v1 = GetActualSkillLevel(PLAYER_SKILL_MEDITATION);
-  v2 = v1 & 0x3F;
+  base_level = v1 & 0x3F;
   if ( v1 & 0x100 )
   {
     v6 = 5;
   }
   else
   {
-    if ( v1 >= 0 )
+    if ( (v1&0xFF) >= 0 )
     {
       v4 = ((v1 & 0x40) != 0) + 1;
-      return v2 * v4;
+      return base_level * v4;
     }
     v6 = 3;
   }
   v4 = v6;
-  return v2 * v4;
+  return base_level * v4;
 }
 
 //----- (004910D3) --------------------------------------------------------
@@ -2078,7 +1967,6 @@
   int v4; // eax@3
   int v5; // edi@7
   signed int v6; // ebp@7
-  char v8; // al@10
   signed int v10; // [sp-4h] [bp-14h]@2
 
   
@@ -2088,9 +1976,9 @@
       CheckHiredNPCSpeciality(Alchemist) && v7->uEquipType >= 9 )
     return true;
 
-  LOBYTE(v2) = GetActualSkillLevel(PLAYER_SKILL_REPAIR);
+  v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR);
   v3 = v2;
-  if ( HIBYTE(v2) & 1 )
+  if (v2 & 0x100 )
   {
     v10 = 5;
   }
@@ -2131,15 +2019,15 @@
 
   v1 = this;
   v2 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT);
-  v3 = v1->pActiveSkills[22];
+  v3 = v1->pActiveSkills[PLAYER_SKILL_MERCHANT];
   v4 = v2 & 0x003F;
-  v5 = v1->pActiveSkills[22] & 0x3F;
+  v5 = v1->pActiveSkills[PLAYER_SKILL_MERCHANT] & 0x3F;
   if ( (signed int)SkillToMastery(v2) >= 4 )
     return 10000;
   v7 = GetPartyReputation();
   if ( !v4 )
     return -v7;
-  if ( HIBYTE(v3) & 1 )
+  if ( v3 & 0x100 )
   {
     v9 = 5;
   }
@@ -2168,13 +2056,13 @@
   signed int v8; // [sp-4h] [bp-10h]@4
 
   v1 = this;
-  v2 = (char)GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
-  v3 = v1->pActiveSkills[26];
+  v2 = GetActualSkillLevel(PLAYER_SKILL_PERCEPTION);
+  v3 = v1->pActiveSkills[PLAYER_SKILL_PERCEPTION];
   v4 = v2 & 0x3F;
-  v5 = v1->pActiveSkills[26] & 0x3F;
+  v5 = v1->pActiveSkills[PLAYER_SKILL_PERCEPTION] & 0x3F;
   if ( (signed int)SkillToMastery(v2) >= 4 )
     return 10000;
-  if ( HIBYTE(v3) & 1 )
+  if ( v3 & 0x100 )
   {
     v8 = 5;
   }
@@ -2203,7 +2091,7 @@
   signed int v8; // [sp-4h] [bp-14h]@6
 
   v1 = this;
-  LOBYTE(v2) = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM);
+  v2 = GetActualSkillLevel(PLAYER_SKILL_TRAP_DISARM);
   v3 = v1->pActiveSkills[29];
   v4 = v2 & 0x3F;
   v5 = v1->pActiveSkills[29] & 0x3F;
@@ -2211,7 +2099,7 @@
     return 10000;
   if ( HasEnchantedItemEquipped(35) )
     v4 *= 2;
-  if ( HIBYTE(v3) & 1 )
+  if ( v3 & 0x100 )
   {
     v8 = 5;
   }
@@ -2239,12 +2127,12 @@
   signed int v7; // [sp-4h] [bp-Ch]@3
 
   v1 = this;
-  LOBYTE(v2) = GetActualSkillLevel(PLAYER_SKILL_LEARNING);
+  v2 = GetActualSkillLevel(PLAYER_SKILL_LEARNING);
   v3 = v1->pActiveSkills[36];
   v4 = v2 & 0x3F;
   if ( v2 )
   {
-    if ( HIBYTE(v3) & 1 )
+    if (v3 & 0x100 )
     {
       v7 = 5;
     }
@@ -2286,7 +2174,7 @@
   }
 
   pName[0] = 0;
-  uFace = 0;
+  uCurrentFace = 0;
   uVoiceID = 0;
   memset(pConditions, 0, 20 * sizeof(__int64));
 
@@ -2381,8 +2269,8 @@
   int v10; // eax@11
   bool result; // eax@15
   std::string v12; // [sp-18h] [bp-40h]@9
-  const char *v13; // [sp-8h] [bp-30h]@9
-  int v14; // [sp-4h] [bp-2Ch]@9
+
+
   int v15[4] = {0, 1, 2, 3}; // [sp+Ch] [bp-1Ch]@3
   //int v16; // [sp+10h] [bp-18h]@3
   //int v17; // [sp+14h] [bp-14h]@3
@@ -2423,7 +2311,7 @@
     {
       v9 = &v20->pPlayers[v15[v8]];
       v19 = &v20->pPlayers[v15[v8]];
-      v10 = v19->AddItem(0xFFFFFFFFu, pItem->uItemID);
+      v10 = v19->AddItem(-1, pItem->uItemID);
       if ( v10 )
         break;
       ++v8;
@@ -2432,7 +2320,7 @@
         if ( !v21 )
         {
           v7->Release();
-          pIcons_LOD->_40F9C5();
+          pIcons_LOD->SyncLoadedFilesCount();
         }
         goto LABEL_15;
       }
@@ -2444,7 +2332,7 @@
     if ( !v21 )
     {
       v7->Release();
-      pIcons_LOD->_40F9C5();
+      pIcons_LOD->SyncLoadedFilesCount();
     }
     result = 1;
   }
@@ -2597,8 +2485,6 @@
 //----- (0048CABC) --------------------------------------------------------
 int Player::GetActualEndurance()
 {
-  int v6; // ebp@5
-
   uint uActualAge = GetBaseAge() + sAgeModifier;
   uint uAgeingMultiplier = 100;
   for (uint i = 0; i < 4; ++i)
@@ -3437,10 +3323,8 @@
 //----- (0048D709) --------------------------------------------------------
 bool Player::WearsItem(int a1, signed int a2)
 {
-  int v3; // edx@2
-  Player *v4; // ecx@2
+
   int v6; // esi@5
-  int v7; // edx@6
 
   if ( a2 >= 16 )
   {
@@ -3675,24 +3559,21 @@
 //----- (0048DBB9) --------------------------------------------------------
 void Player::Heal(int amount)
 {
-  Player *v2; // esi@1
-  signed int v3; // eax@3
-
-  v2 = this;
-  if ( !this->pConditions[16] && !this->pConditions[14] )
-  {
-    v3 = GetMaxHealth();
-    if ( v2->pConditions[17] )
-      v3 /= 2;
-    v2->sHealth += amount;
-    if ( v2->sHealth > v3 )
-      v2->sHealth = v3;
-    if ( v2->pConditions[13] )
-    {
-      if ( v2->sHealth > 0 )
-      {
-        LODWORD(v2->pConditions[13]) = 0;
-        HIDWORD(v2->pConditions[13]) = 0;
+  signed int max_health; // eax@3
+
+  if ( !pConditions[Condition_Eradicated] && !pConditions[Condition_Dead] )
+  {
+    max_health = GetMaxHealth();
+    if ( pConditions[Condition_Zombie] )
+      max_health /= 2;
+    sHealth += amount;
+    if ( sHealth > max_health )
+        sHealth = max_health;
+    if ( pConditions[Condition_Unconcious] )
+    {
+      if ( sHealth > 0 )
+      {
+        pConditions[Condition_Unconcious] = 0i64;
       }
     }
   }
@@ -3711,7 +3592,7 @@
   //signed int typea; // [sp+14h] [bp+8h]@1
 
   v3 = this;
-  this->pConditions[2] = 0i64;
+  this->pConditions[Condition_Sleep] = 0i64;
   v4 = CalculateIncommingDamage(resistance, type);
   v3->sHealth -= v4;
   //typea = v4;
@@ -3721,7 +3602,7 @@
   if ( v5 < 1 )
   {
     if ( v3->sHealth + v3->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1
-      || (signed __int64)v3->pPlayerBuffs[11].uExpireTime > 0 )
+      || (signed __int64)v3->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 )
     {
       SetCondition(0xDu, 0);
     }
@@ -3770,7 +3651,6 @@
   unsigned int v15; // edx@17
   int v16; // edx@26
   unsigned int v17; // edx@27
-  Player *v18; // ecx@32
   signed int v19; // edx@38
   int *v20; // ecx@38
   signed int v21; // eax@40
@@ -4154,7 +4034,8 @@
     else
       weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType];
   }
-  if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) // ADD: shield check because shield recovery is added later and can be accidentally doubled
+  if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) 
+      // ADD: shield check because shield recovery is added later and can be accidentally doubled
   {
     auto v12 = &pInventoryItems[pEquipment.uShield - 1];
     auto v12_desc = &pItemsTable->pItems[v12->uItemID];
@@ -4496,7 +4377,6 @@
   signed int v2; // edi@1
   Player *v3; // esi@1
   enum CHARACTER_RACE v4; // ebx@1
-  Player *v5; // ecx@8
   char v6; // zf@18
   int v7; // ebx@28
   int result; // eax@28
@@ -5645,8 +5525,8 @@
 }
 
 //----- (0048F882) --------------------------------------------------------
-char Player::GetActualSkillLevel(PLAYER_SKILL_TYPE uSkillType)
-{
+int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType )
+    {
   signed int v2; // esi@1
   unsigned __int16 v3; // ax@126
   char result; // al@127
@@ -5876,10 +5756,10 @@
   }
 
   v3 = pActiveSkills[uSkillType];
-  if ( v2 + (pActiveSkills[uSkillType] & 0x3F) < 60 )
+  if ( v2 + (v3 & 0x3F) < 60 )
     result = v2 + v3;
   else
-    result = v3 & 0xFC | 0x3C;
+    result = v3 & 0xFFFC | 0x3C; //al
   return result;
 }
 
@@ -6344,31 +6224,29 @@
 //                     24   zombie female
 enum CHARACTER_RACE Player::GetRace()
 {
-  if ( uFace > 15 )
-  {
-    if ( uFace >= 16 && uFace <= 19 )
+  if ( uCurrentFace > 15 )
+  {
+    if ( uCurrentFace >= 16 && uCurrentFace <= 19 )
       return CHARACTER_RACE_GOBLIN;
   }
   else
   {
-    if ( uFace >= 12 )
+    if ( uCurrentFace >= 12 )
     {
       return CHARACTER_RACE_DWARF;
     }
     else
     {
-      if ( uFace >= 0 )
-      {
-        if ( uFace <= 7 )
+      
+        if ( uCurrentFace <= 7 )
         {
           return CHARACTER_RACE_HUMAN;
         }
         else
         {
-          if ( uFace <= 11 )
+          if ( uCurrentFace <= 11 )
             return CHARACTER_RACE_ELF;
         }
-      }
     }
   }
   return CHARACTER_RACE_HUMAN;
@@ -6912,9 +6790,9 @@
   __int16 uGreen; // [sp+8h] [bp-8h]@1
   __int16 uRed; // [sp+Ch] [bp-4h]@1
 
-  uRed = TargetColor(0xFFu, 0x23u, 0);
-  uGreen = TargetColor(0, 0xFFu, 0);
-  uWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  uRed =   TargetColor(255,  35,   0);
+  uGreen = TargetColor(0,   255,   0);
+  uWhite = TargetColor(255, 255, 255);
   pBaseAttrValue = StatTable[GetRace()][uStat].uBaseValue;
 
   switch (uStat)
@@ -6939,20 +6817,13 @@
 //----- (004908A8) --------------------------------------------------------
 bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime)
 {
-  unsigned __int64 *result; // eax@1
-
-  result = (unsigned __int64 *)((char *)this + 8 * uCondition);
-  if ( *result && (signed __int64)uTime < (signed __int64)*result )
-  {
-    *(int *)result = 0;
-    *((int *)result + 1) = 0;
-    LOBYTE(result) = 1;
+  if ( pConditions[uCondition] && (uTime < pConditions[uCondition]) )
+  {
+    pConditions[uCondition]=0i64;
+    return true;
   }
   else
-  {
-    LOBYTE(result) = 0;
-  }
-  return (bool)result;
+   return false;
 }
 
 //----- (004680ED) --------------------------------------------------------
@@ -7793,7 +7664,7 @@
       dword_50C9EC[3 * dword_50C9E8 + 2] = a2 - 1;
       ++dword_50C9E8;
     }*/
-    pMessageQueue_50CBD0->AddMessage(UIMSG_92, 0, 0);
+    pMessageQueue_50C9E8->AddMessage(UIMSG_92, v24, a2 - 1);
     if ( pCurrentScreen
       && pGUIWindow_CurrentMenu
       && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
@@ -8649,19 +8520,19 @@
       v4->sResMindBase = 200;
       v4->sResBodyBase = 200;
       v11 = v4->GetSexByVoice();
-      v4->field_1924 = v4->uVoiceID;
-      v4->field_1928 = v4->uFace;
+      v4->uPrevVoiceID = v4->uVoiceID;
+      v4->uPrevFace = v4->uCurrentFace;
       if ( v11 )
       {
-        v4->uFace = 21;
+        v4->uCurrentFace = 21;
         v4->uVoiceID = 21;
       }
       else
       {
-        v4->uFace = 20;
+        v4->uCurrentFace = 20;
         v4->uVoiceID = 20;
       }
-      ReloadPlayerPortraits(currPlayerId, v4->uFace);
+      ReloadPlayerPortraits(currPlayerId, v4->uCurrentFace);
       goto LABEL_124;
     }
 LABEL_64: