changeset 1371:d1c8121cf0ad

Слияние
author Ritor1
date Mon, 15 Jul 2013 15:03:56 +0600
parents 14695590d7a6 (current diff) 8f339c3bbdaf (diff)
children 5572e7b02f45
files
diffstat 18 files changed, 767 insertions(+), 961 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/Actor.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -2046,17 +2046,17 @@
   {
     if ( v1 == 6 || v1 == 7 )
     {
-      _449B57_test_bit(pParty->_quest_bits, 99);
-      if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 100) )
+      pParty->IsPartyGood(); //the binary file contains this call. if someone finds out whether it's supposed to be here or not, feel free to apply the appropriate change
+      if ( pParty->IsPartyEvil() )
         return;
       goto LABEL_12;
     }
     if ( v1 != 8 )
       goto LABEL_12;
   }
-  if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 99) )
+  if ( pParty->IsPartyGood() )
     v3 = 0;
-  if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 100) )
+  if ( pParty->IsPartyEvil() )
     v3 = 1;
   if ( v3 )
   {
@@ -4906,9 +4906,9 @@
     v8 = 1;
   if ( !_stricmp(pCurrentMapName.data(), "d26.blv") )
     v6 = 1;
-  if (_449B57_test_bit(pParty->_quest_bits, 99))
+  if (pParty->IsPartyGood())
     v7 = 1;
-  if (_449B57_test_bit(pParty->_quest_bits, 100))
+  if (pParty->IsPartyEvil())
     v5 = 1;
 
   Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0;  original code behaviour is identical
@@ -5225,7 +5225,7 @@
   if ( !v57 )
     goto LABEL_67;
 LABEL_69:
-  if (player->Weak())
+  if (player->IsWeak())
     uDamageAmount /= 1;
   if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 )
     uDamageAmount = 0;
--- a/CastSpellInfo.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/CastSpellInfo.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -414,7 +414,7 @@
       continue;
     }
     v730 = pCastSpell->spellnum;
-    if (pPlayer->Cursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
+    if (pPlayer->IsCursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50)
     {
       if (!pParty->bTurnBasedModeOn)
       {
@@ -2503,7 +2503,7 @@
 						v726->sHealth = v726->GetMaxHealth();
 					if ( v726->sHealth > 0 )
 					{
-						v726->pConditions[Player::Condition_Unconcious] = 0;
+						v726->SetUnconcious(0);
 					}
 					v388 = _v733;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Conditions.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -0,0 +1,63 @@
+#pragma once
+#include "Conditions.h"
+#include "Party.h"
+std::array<ConditionProcessor, 18> conditionArray =
+{
+  // hint: condname, protfrommagic, gmprot, enchantment, ...
+  ConditionProcessor(Condition_Cursed,    false, false,  0),
+  ConditionProcessor(Condition_Weak,       true, false,  0),
+  ConditionProcessor(Condition_Sleep,     false, false, 22, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR),
+  ConditionProcessor(Condition_Fear,      false, false,  0),
+  ConditionProcessor(Condition_Drunk,     false, false,  0),
+  ConditionProcessor(Condition_Insane,    false, false, 19, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Poison1,    true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Disease1,   true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Poison2,    true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Disease2,   true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Poison3,    true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Disease3,   true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
+  ConditionProcessor(Condition_Paralyzed, false, false, 20, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY),
+  ConditionProcessor(Condition_Unconcious,false, false,  0),
+  ConditionProcessor(Condition_Dead,       true,  true,  0),
+  ConditionProcessor(Condition_Pertified,  true, false, 23, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_RELIC_KELEBRIM, EQIUP_ANY),
+  ConditionProcessor(Condition_Eradicated, true,  true,  0),
+  ConditionProcessor(Condition_Zombie,    false, false,  0)
+};
+
+bool ConditionProcessor::IsPlayerAffected( Player* inPlayer, int condToCheck, int blockable)
+{
+  if ( !blockable )
+  {
+    return true;
+  }
+  ConditionProcessor* thisProc = &conditionArray[condToCheck];
+  if (thisProc->m_IsBlockedByProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0)
+  {
+    if (!(thisProc->m_DoesNeedGmProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill < 4))
+    {
+      --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
+      if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
+        pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
+      return false;
+    }
+  }
+  if (thisProc->m_WorkingEnchantment != 0)
+  {
+    if (inPlayer->HasEnchantedItemEquipped(thisProc->m_WorkingEnchantment))
+      return false;
+  }
+  for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++)
+  {
+    if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0)
+    {
+      return true;
+    }
+    ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId;
+    ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot;
+    if (inPlayer->WearsItem(itemId, slot))
+    {
+      return false;
+    }
+  }
+  return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Conditions.h	Mon Jul 15 15:03:56 2013 +0600
@@ -0,0 +1,73 @@
+#pragma once
+#include "Items.h"
+#include <array>
+enum Condition: unsigned __int32
+{
+  Condition_Cursed = 0,
+  Condition_Weak = 1,
+  Condition_Sleep = 2,
+  Condition_Fear = 3,
+  Condition_Drunk = 4,
+  Condition_Insane = 5,
+  Condition_Poison1 = 6,
+  Condition_Disease1 = 7,
+  Condition_Poison2 = 8,
+  Condition_Disease2 = 9,
+  Condition_Poison3 = 10,
+  Condition_Disease3 = 11,
+  Condition_Paralyzed = 12,
+  Condition_Unconcious = 13,
+  Condition_Dead = 14,
+  Condition_Pertified = 15,
+  Condition_Eradicated = 16,
+  Condition_Zombie = 17,
+  Condition_Good = 18
+};
+
+
+class EquipemntPair
+{
+public:
+  ITEM_TYPE m_ItemId;
+  ITEM_EQUIP_TYPE  m_EquipSlot;
+  EquipemntPair(ITEM_TYPE type, ITEM_EQUIP_TYPE slot)
+  {
+    m_ItemId = type;
+    m_EquipSlot = slot;
+  }
+  EquipemntPair()
+  {
+    m_ItemId = (ITEM_TYPE)0;
+    m_EquipSlot = (ITEM_EQUIP_TYPE)0;
+  }
+};
+
+struct Player;
+
+class ConditionProcessor
+{
+public:
+  bool m_IsBlockedByProtFromMagic;
+  bool m_DoesNeedGmProtFromMagic;
+  int m_WorkingEnchantment;
+  std::array<EquipemntPair, 3> m_equipmentPairs;
+  ConditionProcessor(int, bool isblocked, bool needsGm, int enchantment, 
+    ITEM_TYPE itemtype1 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot1 = (ITEM_EQUIP_TYPE)0, 
+    ITEM_TYPE itemtype2 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot2 = (ITEM_EQUIP_TYPE)0, 
+    ITEM_TYPE itemtype3 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot3 = (ITEM_EQUIP_TYPE)0)
+  {
+    m_IsBlockedByProtFromMagic = isblocked;
+    m_DoesNeedGmProtFromMagic = needsGm;
+    m_WorkingEnchantment = enchantment;
+    m_equipmentPairs[0].m_ItemId = itemtype1;
+    m_equipmentPairs[0].m_EquipSlot = itemslot1;
+    m_equipmentPairs[1].m_ItemId = itemtype2;
+    m_equipmentPairs[1].m_EquipSlot = itemslot2;
+    m_equipmentPairs[2].m_ItemId = itemtype3;
+    m_equipmentPairs[2].m_EquipSlot = itemslot3;
+  }
+
+  static bool IsPlayerAffected(Player*, int, int);
+};
+
+extern std::array<ConditionProcessor, 18> conditionArray;
\ No newline at end of file
--- a/Items.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/Items.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -1481,7 +1481,7 @@
     return item__getname_buffer.data();
   }
   sprintf(item__getname_buffer.data(), "%s", pItemsTable->pItems[uItemID].pName);
-  if ( uItemID == ITEM_LICH_JAR )  //Lich Jar
+  if ( uItemID == ITEM_LICH_JAR_FULL )  //Lich Jar
   {
     if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) )
       {
--- a/Items.h	Mon Jul 15 15:03:40 2013 +0600
+++ b/Items.h	Mon Jul 15 15:03:56 2013 +0600
@@ -86,25 +86,32 @@
   ITEM_ARTIFACT_GHOULSBANE = 507,//1FA
   ITEM_ARTEFACT_ULLYSES =510, 
   ITEM_ARTIFACT_LEAGUE_BOOTS = 512,//200
+  ITEM_RELIC_ETHRICS_STAFF = 515,//204
   ITEM_RELIC_HARECS_LEATHER = 516,//204
+  ITEM_RELIC_OLD_NICK = 517,//204
   ITEM_RELIC_KELEBRIM = 520,//208
   ITEM_RELIC_TALEDONS_HELM = 521,//209
   ITEM_RELIC_SCHOLARS_CAP = 522,//20A
   ITEM_RELIC_PHYNAXIAN_CROWN = 523,//20B
   ITEM_RILIC_TITANS_BELT = 524,//20C
   ITEM_RELIC_TWILIGHT = 525,//20D
-  ITEM_RELIC_MEKORIGS_HAMMER = 0x210,
+  ITEM_RELIC_JUSTICE = 527,
+  ITEM_RELIC_MEKORIGS_HAMMER = 528,
   ITEM_ARTIFACT_HERMES_SANDALS = 529,
   ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP = 530,//212
+  ITEM_ARTIFACT_ELFBANE = 531,//212
   ITEM_ARTIFACT_MINDS_EYE = 532,//214
   ITEM_ELVEN_CHAINMAIL = 533,//215
+  ITEM_FORGE_GAUNTLETS = 534,
   ITEM_ARTIFACT_HEROS_BELT = 535,//217
   ITEM_ARTIFACT_LADYS_ESCORT = 536,
   ITEM_RARE_SHADOWS_MASK = 544,//220
   ITEM_RARE_SUN_CLOAK = 547,//223
   ITEM_RARE_MOON_CLOAK = 548,//224
   ITEM_RARE_VAMPIRES_CAPE = 550,//226
-  ITEM_LICH_JAR = 601
+  ITEM_LICH_JAR_FULL = 601,
+  ITEM_WETSUIT = 604,
+  ITEM_LICH_JAR_EMPTY = 615,
 };
 
 /*  331 */
--- a/Party.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/Party.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -26,6 +26,7 @@
 #include "Sprites.h"
 #include "SpriteObject.h"
 #include "ObjectList.h"
+#include "Conditions.h"
 
 Party *pParty; // idb
 
@@ -949,7 +950,7 @@
 
 
     auto condition = player->GetMajorConditionIdx();
-    if (condition == Player::Condition_Good || condition == Player::Condition_Zombie)
+    if (condition == Condition_Good || condition == Condition_Zombie)
     {
       if (player->uExpressionTimePassed < player->uExpressionTimeLength)
         continue;
@@ -999,23 +1000,23 @@
 
       switch (condition)
       {
-        case Player::Condition_Dead:        player->expression = CHARACTER_EXPRESSION_DEAD;      break;
-        case Player::Condition_Pertified:   player->expression = CHARACTER_EXPRESSION_PERTIFIED; break;
-        case Player::Condition_Eradicated:  player->expression = CHARACTER_EXPRESSION_ERADICATED; break;
-        case Player::Condition_Cursed:      player->expression = CHARACTER_EXPRESSION_CURSED; break;
-        case Player::Condition_Weak:        player->expression = CHARACTER_EXPRESSION_WEAK; break;
-        case Player::Condition_Sleep:       player->expression = CHARACTER_EXPRESSION_SLEEP; break;
-        case Player::Condition_Fear:        player->expression = CHARACTER_EXPRESSION_FEAR; break;
-        case Player::Condition_Drunk:       player->expression = CHARACTER_EXPRESSION_DRUNK; break;
-        case Player::Condition_Insane:      player->expression = CHARACTER_EXPRESSION_INSANE; break;
-        case Player::Condition_Poison1:
-        case Player::Condition_Poison2:
-        case Player::Condition_Poison3:     player->expression = CHARACTER_EXPRESSION_POISONED; break;
-        case Player::Condition_Disease1:
-        case Player::Condition_Disease2:
-        case Player::Condition_Disease3:    player->expression = CHARACTER_EXPRESSION_DISEASED; break;
-        case Player::Condition_Paralyzed:   player->expression = CHARACTER_EXPRESSION_PARALYZED; break;
-        case Player::Condition_Unconcious:  player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break;
+        case Condition_Dead:        player->expression = CHARACTER_EXPRESSION_DEAD;      break;
+        case Condition_Pertified:   player->expression = CHARACTER_EXPRESSION_PERTIFIED; break;
+        case Condition_Eradicated:  player->expression = CHARACTER_EXPRESSION_ERADICATED; break;
+        case Condition_Cursed:      player->expression = CHARACTER_EXPRESSION_CURSED; break;
+        case Condition_Weak:        player->expression = CHARACTER_EXPRESSION_WEAK; break;
+        case Condition_Sleep:       player->expression = CHARACTER_EXPRESSION_SLEEP; break;
+        case Condition_Fear:        player->expression = CHARACTER_EXPRESSION_FEAR; break;
+        case Condition_Drunk:       player->expression = CHARACTER_EXPRESSION_DRUNK; break;
+        case Condition_Insane:      player->expression = CHARACTER_EXPRESSION_INSANE; break;
+        case Condition_Poison1:
+        case Condition_Poison2:
+        case Condition_Poison3:     player->expression = CHARACTER_EXPRESSION_POISONED; break;
+        case Condition_Disease1:
+        case Condition_Disease2:
+        case Condition_Disease3:    player->expression = CHARACTER_EXPRESSION_DISEASED; break;
+        case Condition_Paralyzed:   player->expression = CHARACTER_EXPRESSION_PARALYZED; break;
+        case Condition_Unconcious:  player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break;
         default:
           assert(false);
       }
@@ -1153,6 +1154,7 @@
   }
   pParty->days_played_without_rest = 0;
 }
+
 //----- (004938D1) --------------------------------------------------------
 void __fastcall Rest(unsigned int uHoursToSleep)
 {
@@ -1458,7 +1460,7 @@
       v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID);
       if ( v4 )
 	  {
-		memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u);
+		memcpy(&pParty->pPlayers[v12].pInventoryItems[v4 - 1], &pParty->pPickedItem, 0x24u);
 		pMouse->RemoveHoldingItem();
 		break;
 	  }
@@ -1513,4 +1515,15 @@
     pIcons_LOD->SyncLoadedFilesCount();
   }
   return 1;
+}
+
+
+bool Party::IsPartyEvil()
+{
+  return _449B57_test_bit(_quest_bits, 100);
+}
+
+bool Party::IsPartyGood()
+{
+  return _449B57_test_bit(_quest_bits, 99);
 }
\ No newline at end of file
--- a/Party.h	Mon Jul 15 15:03:40 2013 +0600
+++ b/Party.h	Mon Jul 15 15:03:56 2013 +0600
@@ -194,6 +194,8 @@
   inline bool GetYellowAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_YELLOW) != 0;}
   inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;}
 
+  bool IsPartyEvil();
+  bool IsPartyGood();
 
   int field_0;
   unsigned int uPartyHeight;
--- a/Player.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/Player.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -235,22 +235,22 @@
 
 
 //----- (0043EEF3) --------------------------------------------------------
-bool Player::_43EEF3()
+bool Player::NothingOrJustBlastersEquipped()
 {
   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;
-  }
+  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;
+}
   
 
 
@@ -283,22 +283,19 @@
     }
     conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx);
   }
-  else if (conditionIdx < 14)
-  {
-    baseConditionMultiplier = 1;
-    conditionTimeMultiplier = 0;
-    for (int i = 0; i <= 13; i++)
-    {
-      v6 = GetConditionDayOfWeek(i);
-      if ( v6 > conditionTimeMultiplier )
-        conditionTimeMultiplier = v6;
-    }
-    if ( !conditionTimeMultiplier )
-      conditionTimeMultiplier = 1;
-  }
-  else{
+  else 
+  {
     conditionTimeMultiplier = 1;
     baseConditionMultiplier = 1;
+    if (conditionIdx < 14)
+    {
+      for (int i = 0; i <= 13; i++)
+      {
+        v6 = GetConditionDayOfWeek(i);
+        if ( v6 > conditionTimeMultiplier )
+          conditionTimeMultiplier = v6;
+      }
+    }
   }
   result = (int)((double)conditionTimeMultiplier * (double)baseConditionMultiplier * a2);
   if ( result < 1 )
@@ -415,26 +412,31 @@
 
 
 //----- (004B6FF9) --------------------------------------------------------
-int Player::IsPlayerHealableByTemple()
+bool Player::IsPlayerHealableByTemple()
 {
   signed int v2; // eax@1
   v2 = (signed int)window_SpeakInHouse->ptr_1C;
-
-  if ( this->sHealth < GetMaxHealth() || this->sMana < GetMaxMana() )
-  {
-    return 1;
-  }
-  else if (GetMajorConditionIdx() == Condition_Good)
-  {
-    return 0;
-  }
-  else if (GetMajorConditionIdx() == Condition_Zombie && (v2 == 78 || v2 == 81 || v2 == 82))
-  {
-    return 0;
+  if (this->sHealth >= GetMaxHealth() && this->sMana >= GetMaxMana() && GetMajorConditionIdx() == Condition_Good)
+  {
+    return false;
   }
   else
   {
-    return 1;
+    if (GetMajorConditionIdx() == Condition_Zombie)
+    {
+      if ((v2 == 78 || v2 == 81 || v2 == 82))
+      {
+        return false;
+      }
+      else
+      {
+        return true;
+      }
+    }
+    else
+    {
+      return true;
+    }
   }
 }
 
@@ -446,6 +448,7 @@
   int item_idx; // eax@1
   int inv_index; // eax@3
 
+
   item_idx = *pitem_index;
   if ( item_idx >125 || item_idx < 0 )
   {
@@ -474,61 +477,48 @@
   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;
-      }
+  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 )
-        {
+      for ( i = 0; i < enchant_count; ++i )
+      {
         if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
-                pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes|=ITEM_ENCHANTED; 
-        }
-       
+          pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_ENCHANTED; 
+      }
     }
     else
     {
       for ( i = 0; i < avalible_items; ++i )
       {
-        if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED))
-                pInventoryItems[item_index_tabl[i]].uAttributes|=ITEM_ENCHANTED;
-      }
-    }
-  }
- ;
+          pInventoryItems[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED;
+      }
+    }
+  }
 }
 
 //----- (004948B1) --------------------------------------------------------
 void Player::PlaySound(PlayerSpeech speech, int a3)
 {
-  //Player *pPlayer; // edi@1
-  //int v4; // eax@4
-  signed int v5; // esi@4
-  unsigned char *v6; // ebx@4
-  signed int v7; // ecx@5
+  signed int speechCount = 0; // esi@4
+  signed int expressionCount = 0; // esi@4
   unsigned __int8 v8; // al@6
-  int v9; // eax@10
-  //unsigned int pVoiceID; // ecx@10
-  int v11; // esi@10
-  //signed int v12; // eax@11
-  signed int v13; // esi@12
+  int pickedVariant; // esi@10
   int v14; // eax@12
-  //int v15; // eax@17
   CHARACTER_EXPRESSION_ID expression; // ebx@17
   signed int v17; // ecx@19
-  char *pSoundID; // edi@20
-  int v20[5]; // [sp+Ch] [bp-1Ch]@7
-  //Player *pPlayer2; // [sp+20h] [bp-8h]@1
+  unsigned int pSoundID; // edi@20
+  int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7
+  int expressionVariantArray[5]; 
   int pPlayerNum; // [sp+24h] [bp-4h]@1
-  int pSoundId; // [sp+30h] [bp+8h]@4
-
-  //pPlayer = this;
-  //pPlayer2 = this;
+  unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4
+  unsigned int expressionDuration = 0;
 
   pPlayerNum = 1;
   for (int i = 0; i < 4; ++i)
@@ -538,862 +528,372 @@
       break;
     }
 
-  //v4 = a2;//102
-  v5 = 0;
-  pSoundId = 0;
-  v6 = SoundSetAction[speech].data();//byte_4ED280 &byte_4ED3D8[4 * v4] ???
+  pickedSoundID = 0;
   if (uVoicesVolumeMultiplier)
   {
-    v7 = 0;
-    do
-    {
-      v8 = v6[v7];
+    for (int i = 0; i < 2; i++)
+    {
+      v8 = SoundSetAction[speech][i];
       if ( v8 )
-        v20[v5++] = v8;
-      ++v7;
-    }
-    while ( v7 < 2 );
-    if ( v5 )
-    {
-      v9 = rand();
-      //pVoiceID = uVoiceID;
-      v11 = v20[v9 % v5];
-
-      if (int _v1 = byte_4ECF08[v11 - 1][uVoiceID])
-      {
-        pSoundId = rand() % _v1 + 2 * (v11 + 50 * uVoiceID) + 4998;
-        pAudioPlayer->PlaySound((SoundID)pSoundId, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
-      }
-    }
-  }
-
-  v13 = 0;
-  v14 = (int)(v6 + 3);
-  do
-  {
-    if ( *(char *)v14 )
-      v20[v13++] = *(char *)v14;
-    ++v14;
-  }
-  while ( -3 - (signed int)v6 + v14 < 5 );
-  if ( v13 )
-  {
-    pPlayerNum = 0;
-    expression = (CHARACTER_EXPRESSION_ID)v20[rand() % v13];
-    if (expression == CHARACTER_EXPRESSION_21 && pSoundId )
-    {
-      v17 = 0;
+      {
+        speechVariantArray[speechCount] = v8;
+        speechCount++;
+      }
+    }
+    if ( speechCount )
+    {
+      pickedVariant = speechVariantArray[rand() % speechCount];
+      int numberOfSubvariants = byte_4ECF08[pickedVariant - 1][uVoiceID];
+      if (numberOfSubvariants > 0)
+      {
+        pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998;
+        pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0);
+      }
+    }
+  }
+
+  for (int i = 0; i < 5; i++)
+  {
+    v14 = SoundSetAction[speech][i + 3];
+    if ( v14 )
+    {
+      expressionVariantArray[expressionCount] = v14;
+      expressionCount++;
+    }
+  }
+  if ( expressionCount )
+  {
+    expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount];
+    if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID )
+    {
       if ( (signed int)pSoundList->sNumSounds <= 0 )
       {
-LABEL_23:
         v17 = 0;
       }
       else
       {
-        pSoundID = (char *)&pSoundList->pSounds->uSoundID;
-        while ( *(int *)pSoundID != pSoundId )
+        pSoundID = pSoundList->pSounds[0].uSoundID;
+        v17 = 0;
+        for (int i = 0; i < pSoundList->sNumSounds; i++)
         {
-          ++v17;
+          v17 = i;
+          if (pSoundID == pickedSoundID)
+          {
+            break;
+          }
           pSoundID += 120;
-          if ( v17 >= (signed int)pSoundList->sNumSounds )
-            goto LABEL_23;
         }
       }
       if ( pSoundList->pSounds[v17].pSoundData[0] )
-        pPlayerNum = (sLastTrackLengthMS << 7) / 1000;
-    }
-    /*LOWORD(v14) = */PlayEmotion(expression, pPlayerNum);
-  }
-  //return v14;
+        expressionDuration = (sLastTrackLengthMS << 7) / 1000;
+    }
+    PlayEmotion(expression, expressionDuration);
+  }
 }
 // 4948B1: using guessed type int var_1C[5];
 
 //----- (00494A25) --------------------------------------------------------
 void Player::PlayEmotion(CHARACTER_EXPRESSION_ID new_expression, int a3)
 {
-  //signed int v3; // eax@1
-  //CHARACTER_EXPRESSION_ID v4; // dx@1
-  signed int v5; // edi@15
-  PlayerFrame *v6; // esi@17
-  signed int v7; // eax@20
-
-  //LOWORD(v3) = this->expression;
-  //v4 = expr;
-  if (expression != CHARACTER_EXPRESSION_SLEEP &&
-      expression != CHARACTER_EXPRESSION_PERTIFIED || new_expression != CHARACTER_EXPRESSION_58)
-  {
-    int v3 = (unsigned)expression;
-    if ( (signed int)(unsigned __int16)v3 >= 2 )
-    {
-      if ( v3 <= 7 )
-        goto LABEL_12;
-      if ( v3 > 8 )
-      {
-        if ( v3 > 11 )
-        {
-          if ( v3 == CHARACTER_EXPRESSION_PERTIFIED ||( v3 > 97 && v3 <= 99) )
-            return;
-          goto LABEL_15;
-        }
-LABEL_12:
-        if (new_expression != CHARACTER_EXPRESSION_34 && new_expression != CHARACTER_EXPRESSION_35 && new_expression != CHARACTER_EXPRESSION_36)
-          return;
-        goto LABEL_15;
-      }
-    }
-  }
-LABEL_15:
-  //LOWORD(v3) = a3;
-  v5 = 0;
-  this->uExpressionTimeLength = a3;
+  unsigned int v3 = expression;
+  if (expression == CHARACTER_EXPRESSION_DEAD || expression == CHARACTER_EXPRESSION_ERADICATED)
+  {
+    return;
+  }
+  else if (expression == CHARACTER_EXPRESSION_PERTIFIED && new_expression != CHARACTER_EXPRESSION_FALLING)
+  {
+    return;
+  }
+  else 
+  {
+    if (expression != CHARACTER_EXPRESSION_SLEEP || new_expression != CHARACTER_EXPRESSION_FALLING)
+    {
+      if (v3 >= 2 && v3 <= 11 && v3 != 8 && !(new_expression == CHARACTER_EXPRESSION_DMGRECVD_MINOR || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MODERATE || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MAJOR))
+      {
+        return;
+      }
+    }
+  }
   this->uExpressionTimePassed = 0;
   if ( !a3 )
   {
-    if ( (signed int)pPlayerFrameTable->uNumFrames <= 0 )
-    {
-LABEL_20:
-      v7 = 0;
-    }
-    else
-    {
-      v6 = pPlayerFrameTable->pFrames;
-      while ( v6->expression != new_expression )
-      {
-        ++v5;
-        ++v6;
-        if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames )
-          goto LABEL_20;
-      }
-      v7 = v5;
-    }
-    //v4 = expr;
     this->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[a3].uAnimLength;
   }
+  else
+  {
+    this->uExpressionTimeLength = 0;
+  }
   expression = new_expression;
   viewparams->bRedrawGameUI = 1;
 }
 
 //----- (0049327B) --------------------------------------------------------
-int Player::_49327B(unsigned int uClass, int a3)
-{
-  Player *v3; // esi@1
-  char v4; // zf@4
-  __int16 v5; // dx@9
-  signed int result; // eax@84
-  unsigned int v7; // [sp-8h] [bp-10h]@3
-  int v8; // [sp-4h] [bp-Ch]@3
-
-  v3 = this;
+bool Player::ProfessionOrGuildFlagsCorrect( unsigned int uClass, int a3 )
+{
   if ( this->classType == uClass )
   {
-LABEL_84:
-    result = 1;
+    return true;
   }
   else
   {
+    if (!a3)
+    {
+      return false;
+    }
     switch ( uClass )
     {
-      case 0u:
-        v8 = a3;
-        v7 = 1;
-        goto LABEL_4;
-      case 1u:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 17)
-          || _49327B(2u, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 3;
-        goto LABEL_4;
-      case 2u:
-        v5 = 19;
-        goto LABEL_82;
-      case 3u:
-        v5 = 21;
-        goto LABEL_82;
-      case 4u:
-        v8 = a3;
-        v7 = 5;
-        goto LABEL_4;
-      case 5u:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 11)
-          || _49327B(6u, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 7;
-        goto LABEL_4;
-      case 6u:
-        if ( !a3 )
-          break;
-        v5 = 13;
-        goto LABEL_82;
-      case 7u:
-        if ( !a3 )
-          break;
-        v5 = 15;
-        goto LABEL_82;
-      case 8u:
-        v8 = a3;
-        v7 = 9;
-        goto LABEL_4;
-      case 9u:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 23)
-          || _49327B(0xAu, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 11;
-        goto LABEL_4;
-      case 0xAu:
-        if ( !a3 )
-          break;
-        v5 = 25;
-        goto LABEL_82;
-      case 0xBu:
-        if ( !a3 )
-          break;
-        v5 = 27;
-        goto LABEL_82;
-      case 0xCu:
-        v8 = a3;
-        v7 = 13;
-        goto LABEL_4;
-      case 0xDu:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 41)
-          || _49327B(0xEu, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 15;
-        goto LABEL_4;
-      case 0xEu:
-        if ( !a3 )
-          break;
-        v5 = 43;
-        goto LABEL_82;
-      case 0xFu:
-        if ( !a3 )
-          break;
-        v5 = 45;
-        goto LABEL_82;
-      case 0x10u:
-        v8 = a3;
-        v7 = 17;
-        goto LABEL_4;
-      case 0x11u:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 35)
-          || _49327B(0x12u, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 19;
-        goto LABEL_4;
-      case 0x12u:
-        if ( !a3 )
-          break;
-        v5 = 37;
-        goto LABEL_82;
-      case 0x13u:
-        v5 = 39;
-        goto LABEL_82;
-      case 0x14u:
-        v8 = a3;
-        v7 = 21;
-        goto LABEL_4;
-      case 0x15u:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 29)
-          || _49327B(0x16u, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 23;
-        goto LABEL_4;
-      case 0x16u:
-        if ( !a3 )
-          break;
-        v5 = 31;
-        goto LABEL_82;
-      case 0x17u:
-        if ( !a3 )
-          break;
-        v5 = 33;
-        goto LABEL_82;
-      case 0x18u:
-        if ( !_49327B(0x19u, a3) )
-          goto LABEL_56;
-        break;
-      case 0x19u:
-LABEL_56:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v3->_guilds_member_bits, 63)
-          || _49327B(0x1Au, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 27;
-        goto LABEL_4;
       case 0x1Au:
-        if ( !a3 )
-          break;
-        v5 = 65;
-        goto LABEL_82;
+        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 65));
       case 0x1Bu:
-        if ( !a3 )
-          break;
-        v5 = 67;
-        goto LABEL_82;
-      case 0x1Cu:
-        v8 = a3;
-        v7 = 29;
-        goto LABEL_4;
-      case 0x1Du:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 69)
-          || _49327B(0x1Eu, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 31;
-        goto LABEL_4;
-      case 0x1Eu:
-        if ( !a3 )
-          break;
-        v5 = 71;
-        goto LABEL_82;
-      case 0x1Fu:
-        if ( !a3 )
-          break;
-        v5 = 73;
-        goto LABEL_82;
-      case 0x20u:
-        v8 = a3;
-        v7 = 33;
-        goto LABEL_4;
-      case 0x21u:
-        if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 73)
-          || _49327B(0x22u, a3) )
-          goto LABEL_84;
-        v8 = a3;
-        v7 = 35;
-LABEL_4:
-        v4 = _49327B(v7, v8) == 0;
-        goto LABEL_83;
+        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 67));
       case 0x22u:
-        if ( !a3 )
-          break;
-        v5 = 77;
-        goto LABEL_82;
+        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 77));
       case 0x23u:
-        if ( a3 )
-        {
-          v5 = 79;
-LABEL_82:
-          v4 = (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, v5) == 0;
-LABEL_83:
-          if ( !v4 )
-            goto LABEL_84;
-        }
+        return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 79));
         break;
       default:
+        assert("Should not be able to get here" && false);
         break;
     }
-    result = 0;
-  }
-  return result;
+    return false;
+  }
 }
 
 
 //----- (00492C0B) --------------------------------------------------------
 bool Player::CanAct()
 {
-  bool result; // eax@2
-
-  if ( this->pConditions[Condition_Sleep] || this->pConditions[Condition_Paralyzed] || 
-       this->pConditions[Condition_Unconcious] || this->pConditions[Condition_Dead] || 
-       this->pConditions[Condition_Pertified] || this->pConditions[Condition_Eradicated] )
-    result = false;
+  if ( this->IsAsleep() || this->IsParalyzed() || 
+       this->IsUnconcious() || this->IsDead() || 
+       this->IsPertified() || this->IsEradicated() )
+    return false;
   else
-    result = true;
-  return result;
+    return true;
 }
 
 //----- (00492C40) --------------------------------------------------------
 bool Player::CanSteal()
 {
-  int v1; // eax@1
-
-  LOBYTE(v1) = GetActualSkillLevel(PLAYER_SKILL_STEALING);
-  return v1 != 0;
+  return GetActualSkillLevel(PLAYER_SKILL_STEALING) != 0;
 }
 
 //----- (00492C4E) --------------------------------------------------------
 bool Player::CanEquip_RaceAndAlignmentCheck(unsigned int uItemID)
 {
-  char v2; // zf@9
-  __int16 v4; // dx@13
-  char v5; // zf@15
-
-  if ( (signed int)uItemID > 532 )              //  if (uItemID == 514 ||                       // item233   ਪ              䠪, 
-                                                //      uItemID == 516 ||                       // item221                   䠪, 
-                                                //      uItemID == 524)                         // item325  ࠪ                    ५, 
-  {
-    if ( uItemID == 533 )
-    {
-      v2 = GetRace() == 1;
-    }
-    else
-    {
-      if ( uItemID != 534 )
-      {
-        if ( uItemID == 535 )                   // 
-                                                //  if (uItemID == 530)                         // item093                 䠪, 
-        {
-          switch ( this->uVoiceID )
-          {
-            default:
-              return 1;
-            case 4u:
-            case 5u:
-            case 6u:
-            case 7u:
-            case 0xAu:
-            case 0xBu:
-            case 0xEu:                          // 
-                                                //  if (uItemID == 535)                         // item129  ᪮                䠪, 騭
-            case 0xFu:
-            case 0x12u:
-            case 0x13u:
-            case 0x15u:
-            case 0x18u:
-              return 0;
-          }
-          return 0;
-        }
-        if ( uItemID == 536 )                   // 
-                                                //  if (uItemID == 531)                         // item093   ᫨                 䠪, 祫
-        {
-          switch ( this->uVoiceID )
-          {
-            case 4u:
-            case 5u:
-            case 6u:
-            case 7u:
-            case 0xAu:
-            case 0xBu:
-            case 0xEu:
-            case 0xFu:
-            case 0x12u:
-            case 0x13u:
-            case 0x15u:
-            case 0x18u:
-              return 1;
-            default:
-              return 0;
-          }
-          return 0;
-        }
-        if ( uItemID != 604 )                   // 
-                                                //  if (uItemID == 532)                         // item073  䨩᪠ 㣠       䠪, 
-          return 1;
-        v5 = _43EEF3() == 0;
-        goto LABEL_23;
-      }
-      v2 = GetRace() == 3;                     // 
-                                                //  if (uItemID == 533)                         // item113    㪠   䠪, 
-    }
-  }
-  else
-  {
-    if ( uItemID != 532 )
-    {
-      if ( uItemID != 515 && uItemID != 517 )   // 
-                                                //  if (uItemID == 534)                         // item104                   䠪, 稭
-      {
-        if ( uItemID == 521 )                   //  if (uItemID == 521 ||                       // item239                䠪, 
-                                                //      uItemID == 526)                         // item230  ࠢ            ५, 
-        {
-LABEL_13:
-          v4 = 99;
-LABEL_15:
-          v5 = (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) == 0;
-LABEL_23:
-          if ( !v5 )
-            return 1;
-          return 0;
-        }
-        if ( uItemID != 525 )
-        {
-          if ( uItemID != 527 )
-          {
-            if ( uItemID != 531 )
-              return 1;
-            v2 = GetRace() == 2;
-            goto LABEL_10;
-          }
-          goto LABEL_13;
-        }
-      }
-      v4 = 100;
-      goto LABEL_15;
-    }
-    v2 = GetRace() == 0;
-  }
-LABEL_10:
-  if ( v2 )
-    return 1;
-  return 0;
+  switch (uItemID)
+  {
+  case ITEM_RELIC_ETHRICS_STAFF: 
+  case ITEM_RELIC_OLD_NICK: 
+  case ITEM_RELIC_TWILIGHT: return pParty->IsPartyEvil(); break;
+  case ITEM_RELIC_TALEDONS_HELM: 
+  case ITEM_RELIC_JUSTICE: return pParty->IsPartyGood(); break;
+  case ITEM_ARTIFACT_ELFBANE: return IsRaceGoblin(); break;
+  case ITEM_ARTIFACT_MINDS_EYE: return IsRaceHuman(); break;
+  case ITEM_ELVEN_CHAINMAIL: return IsRaceElf(); break;
+  case ITEM_FORGE_GAUNTLETS: return IsRaceDwarf(); break;
+  case ITEM_ARTIFACT_HEROS_BELT: return IsMale(); break;
+  case ITEM_ARTIFACT_LADYS_ESCORT: return IsFemale(); break;
+  case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break;
+  default: return 1; break;
+  }
 }
 
 //----- (00492D65) --------------------------------------------------------
-int Player::SetCondition(unsigned int uConditionIdx, int a3)
-    {
-
-    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 Condition_Cursed:
-        PlaySound((PlayerSpeech)30, 0);
-        break;
-    case Condition_Weak:
-        if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 )
-            {--pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
-        if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
-            pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
-        return 0;
-            }
-
-        PlaySound((PlayerSpeech)25, 0);
-        break;
-    case Condition_Sleep:
-        if ( a3 == 1 &&(HasEnchantedItemEquipped(22)||
-            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR))) 
-            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
-            && (HasEnchantedItemEquipped(19) || 
-            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
-                          WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) )
-            return 0;
-
-        PlaySound((PlayerSpeech)29, 0);
-        break;
+void Player::SetCondition( unsigned int uConditionIdx, int a3 )
+{
+  signed int player_sex; // ecx@77
+  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;
+  
+  if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3))
+  {
+    return;
+  }
+
+  switch ( uConditionIdx )
+  {
+    case Condition_Cursed: PlaySound(SPEECH_30, 0); break;
+    case Condition_Weak: PlaySound(SPEECH_25, 0); break;
+    case Condition_Sleep: break; //nosound
+    case Condition_Fear: PlaySound(SPEECH_26, 0); break;
+    case Condition_Drunk: PlaySound(SPEECH_31, 0); break;
+    case Condition_Insane: PlaySound(SPEECH_29, 0); break;
     case Condition_Poison1:
     case Condition_Poison2:
-    case Condition_Poison3:
-        if ( a3 == 1 )
-            {
-            if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 )
-                {
-                --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
-                if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
-                    pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
-                }
-            if ( HasEnchantedItemEquipped(21)
-                || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)
-                || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) )
-                //goto LABEL_76;
-                return 0;
-            }
-
-        //v23 = 27;
-        PlaySound((PlayerSpeech)27, 0);
-        break;
-
+    case Condition_Poison3: PlaySound(SPEECH_27, 0); break;
     case Condition_Disease1:
     case Condition_Disease2:
-    case Condition_Disease3:
-        if ( a3 == 1 )
-            {            
-            if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 )
-                {
-                --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
-                if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
-                    pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
-                return 0;
-                }
-
-            if ( HasEnchantedItemEquipped(18) ||
-                WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
-                WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) )
-                return 0;
-            }
-        PlaySound((PlayerSpeech)28, 0);
-        break;
-    case Condition_Paralyzed:
-        if ( a3 == 1 )
-            {
-            if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 )
-                {
-                --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
-                if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
-                    pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
-                return 0;
-                }
-
-            if ( HasEnchantedItemEquipped(20)|| 
-                WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)|| 
-                WearsItem(ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY)||
-                WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK))
-                return 0;
-            }
-        break;
+    case Condition_Disease3: PlaySound(SPEECH_28, 0);break;
+    case Condition_Paralyzed: break;  //nosound
     case Condition_Unconcious:
-        PlaySound(SPEECH_32, 0);
-        if ( sHealth > 0 )
-            sHealth = 0;
-        break;
+      PlaySound(SPEECH_32, 0);
+      if ( sHealth > 0 )
+        sHealth = 0;
+    break;
     case Condition_Dead:
-        if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u )
-            {
-            --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
-            if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
-                pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
-            }
-
-        PlaySound((PlayerSpeech)33, 0);
-        if ( sHealth > 0 )
-            sHealth = 0;
-        if ( sMana > 0 )
-            sMana = 0;
-        break;
+      PlaySound(SPEECH_33, 0);
+      if ( sHealth > 0 )
+        sHealth = 0;
+      if ( sMana > 0 )
+        sMana = 0;
+    break;
     case Condition_Pertified:
-        if ( a3 == 1
-            &&((pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64)
-            || HasEnchantedItemEquipped(23)|| 
-            WearsItem(ITEM_RELIC_KELEBRIM, EQIUP_ANY) || 
-            WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || 
-            WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) )
-
-            return 0;
-        PlaySound((PlayerSpeech)34, 0);
-        break;
+      PlaySound(SPEECH_34, 0);
+    break;
     case Condition_Eradicated:
-        if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 )&&( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u ))
-            {
-            --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
-            if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u )
-                pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].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();
+      PlaySound(SPEECH_35, 0);
+      if (sHealth > 0 )
+        sHealth = 0;
+      if ( sMana > 0 )
         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;
-        }
-
-    remainig_player = 0;
-    pConditions[uConditionIdx] = pParty->uTimePlayed;
-    players_after = 0;
-    for (int i=1;i<5;++i)
-        {
-
-
-        if ( pPlayers[i]->CanAct() )
-            {
-            remainig_player=i;
-            ++players_after;
-            }
-        }
-    if (( players_before == 2 )&&( players_after == 1 ))
-        {
-        pPlayers[remainig_player]->PlaySound(SPEECH_107, 0);
-        }
-    return 1;
-    }
+    break;
+    case Condition_Zombie:
+      if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead())
+        return;
+      memset(&pConditions[0], 0, sizeof(pConditions));
+      sHealth = GetMaxHealth();
+      sMana = 0;
+      player_sex = 0;
+      uPrevFace = uCurrentFace;
+      uPrevVoiceID = uVoiceID;
+      if (IsMale())
+      {
+        uCurrentFace = 23;
+        uVoiceID = 23;
+      }
+      else
+      {
+        uCurrentFace = 24;
+        uVoiceID = 24;
+      }
+      PlaySound(SPEECH_99, 0);
+    break;
+  }
+
+  players_before = 0;
+  for (int i = 1; i < 5; ++i)
+  {
+    if ( pPlayers[i]->CanAct() )
+      ++players_before;
+  }
+
+  pConditions[uConditionIdx] = 1;
+
+  remainig_player = 0;
+  players_after = 0;
+  for (int i = 1; i < 5; ++i)
+  {
+    if ( pPlayers[i]->CanAct() )
+    {
+      remainig_player = i;
+      ++players_after;
+    }
+  }
+  if (( players_before == 2 ) && ( players_after == 1 ))
+  {
+    pPlayers[remainig_player]->PlaySound(SPEECH_107, 0);
+  }
+  return;
+}
 
 //----- (00492528) --------------------------------------------------------
 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID)
 {
-  //unsigned int v3; // eax@1
-  Texture *v4; // esi@1
-  unsigned int v5; // ebx@1
-  signed int v6; // edi@5
-  int *v7; // ecx@6
-  signed int v8; // edx@7
-  int *v9; // eax@8
-  //Player *v11; // [sp+Ch] [bp-4h]@1
-  unsigned int uItemIDa; // [sp+1Ch] [bp+Ch]@1
-
-  v4 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-  v5 = GetSizeInInventorySlots(v4->uTextureWidth);
-  uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight);
+  Texture *texture; // esi@1
+  unsigned int slotWidth; // ebx@1
+  unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1
+
+  texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+  slotWidth = GetSizeInInventorySlots(texture->uTextureWidth);
+  slotHeight = GetSizeInInventorySlots(texture->uTextureHeight);
   if ( !areWeLoadingTexture )
   {
-    v4->Release();
+    texture->Release();
     pIcons_LOD->SyncLoadedFilesCount();
   }
-  if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 )
-  {
-    v6 = 0;
-    if ( (signed int)uItemIDa <= 0 )
-      return 1;
-    v7 = &pInventoryIndices[uSlot];
-    while ( 1 )
-    {
-      v8 = 0;
-      if ( (signed int)v5 > 0 )
-        break;
-LABEL_11:
-      ++v6;
-      v7 += 14;
-      if ( v6 >= (signed int)uItemIDa )
-        return 1;
-    }
-    v9 = v7;
-    while ( !*v9 )
-    {
-      ++v8;
-      ++v9;
-      if ( v8 >= (signed int)v5 )
-        goto LABEL_11;
-    }
-  }
-  return 0;
+  if ( slotHeight == 0 || slotWidth == 0)
+  {
+    assert("Items should have nonzero dimensions");
+    return 1;
+  }
+  if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT )
+  {
+    int startOfInnerLoop = uSlot;
+    for (unsigned int y = 0; y < slotHeight; y++)
+    {
+      int innerLoopPos = startOfInnerLoop;
+      for (unsigned int x = 0; x < slotWidth; x++)
+      {
+        if (pInventoryIndices[innerLoopPos] != 0)
+        {
+          return false;
+        }
+        innerLoopPos++;
+      }
+      startOfInnerLoop += INVETORYSLOTSWIDTH;
+    }
+    return true;
+  }
+  return false;
 }
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (004925E6) --------------------------------------------------------
-unsigned int Player::FindFreeInventorySlot()
-{
-  unsigned int result; // eax@1
-  ItemGen *v2; // ecx@1
-
-  result = 0;
-  v2 = this->pInventoryItems;
-  while ( v2->uItemID )
-  {
-    ++result;
-    ++v2;
-    if ( (signed int)result >= 126 )
-      return -1;
-  }
-  return result;
+int Player::FindFreeInventorySlot()
+{
+  for (int i = 0; i < 126; i++ )
+  {
+    if (pInventoryItems[i].uItemID == 0)
+    {
+      return i;
+    }
+  }
+  return -1;
 }
 
 //----- (00492600) --------------------------------------------------------
 int Player::CreateItemInInventory(unsigned int uSlot, unsigned int uItemID)
 {
-  signed int v3; // edx@1
-  ItemGen *v4; // eax@1
   int result; // eax@8
-  unsigned int v6; // ebx@10
-  //unsigned int v7; // eax@10
-  Texture *v8; // esi@10
-  void *v9; // esi@13
-  unsigned int v10; // [sp+0h] [bp-Ch]@10
-  Player *v11; // [sp+4h] [bp-8h]@1
-  signed int v12; // [sp+8h] [bp-4h]@4
-  unsigned int uItemIDa; // [sp+18h] [bp+Ch]@10
-
-  v11 = this;
-  v3 = 0;
-  v4 = this->pInventoryItems;
-  while ( v4->uItemID )
-  {
-    ++v3;
-    ++v4;
-    if ( v3 >= 126 )
-    {
-      v12 = -1;
-      goto LABEL_5;
-    }
-  }
-  v12 = v3;
-LABEL_5:
-  if ( v12 == -1 )
+  Texture *texturePtr; // esi@10
+  int *v9; // esi@13
+  unsigned int widthInSlots; // [sp+0h] [bp-Ch]@10
+  signed int freeSlot; // [sp+8h] [bp-4h]@4
+  unsigned int heightInSlots; // [sp+18h] [bp+Ch]@10
+
+  freeSlot = FindFreeInventorySlot();
+  if ( freeSlot == -1 )
   {
     if ( uActiveCharacter )
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
-    result = 0;
+    return 0;
   }
   else
   {
-    v6 = uItemID;
-    v8 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v10 = GetSizeInInventorySlots(v8->uTextureWidth);
-    uItemIDa = GetSizeInInventorySlots(v8->uTextureHeight);
+    texturePtr = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+    widthInSlots = GetSizeInInventorySlots(texturePtr->uTextureWidth);
+    heightInSlots = GetSizeInInventorySlots(texturePtr->uTextureHeight);
     if ( !areWeLoadingTexture )
     {
-      v8->Release();
+      texturePtr->Release();
       pIcons_LOD->SyncLoadedFilesCount();
     }
-    if ( (signed int)uItemIDa > 0 )
-    {
-      v9 = &v11->pInventoryIndices[uSlot];
-      do
-      {
-        if ( (signed int)v10 > 0 )
-          memset32(v9, -1 - uSlot, v10);
-        v9 = (char *)v9 + 56;
-        --uItemIDa;
-      }
-      while ( uItemIDa );
-    }
-    result = v12 + 1;
-    v11->pInventoryIndices[uSlot] = v12 + 1;
-    v11->pInventoryItems[v12].uItemID = v6;
+    if (widthInSlots > 0)
+    {
+      v9 = &this->pInventoryIndices[uSlot];
+      for (unsigned int i = 0; i < heightInSlots; i++)
+      {
+        memset32(v9, -1 - uSlot, widthInSlots); //TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn
+        v9 += INVETORYSLOTSWIDTH;
+      }
+    }
+    result = freeSlot + 1;
+    this->pInventoryIndices[uSlot] = freeSlot + 1;
+    this->pInventoryItems[freeSlot].uItemID = uItemID;
   }
   return result;
 }
@@ -1914,7 +1414,7 @@
   signed int v6; // ebp@7
   char *v7; // esi@7
   signed int uSkillMultiplier; // [sp-4h] [bp-14h]@2
-  
+
   if (CheckHiredNPCSpeciality(Scholar))
     return true;
 
@@ -7834,10 +7334,10 @@
           for (int i = 0; i < 138; i++)
           {
             v9 = &this->pInventoryItems[i];
-            if (v9->uItemID == 615)
+            if (v9->uItemID == ITEM_LICH_JAR_EMPTY)
               break;
           }
-          if (v9 != NULL && v9->uItemID != 615)
+          if (v9 != NULL && v9->uItemID != ITEM_LICH_JAR_EMPTY)
           {
             v10 = (int)((char *)this + 36 * 138);   //originally 36 * v8. the code got to this condition only if v8 was equal to 138
             *(int *)(v10 + 532) = 601;
@@ -9367,7 +8867,7 @@
   int v4; // edx@1
   int v5; // esi@2
   //int v6; // eax@2
-  unsigned int v7; // eax@3
+  int v7; // eax@3
   ItemGen _this; // [sp+Ch] [bp-30h]@1
   //Player *v9; // [sp+30h] [bp-Ch]@1
   int v10; // [sp+34h] [bp-8h]@1
@@ -9436,6 +8936,8 @@
     }
   }
 }
+
+
 //----- (0049387A) --------------------------------------------------------
 int CycleCharacter(unsigned int _this)
 {
@@ -10238,4 +9740,155 @@
       }
     }
   }
-}
\ No newline at end of file
+}
+
+
+bool Player::IsWeak()
+{
+  return pConditions[Condition_Weak] != 0;
+}
+
+bool Player::IsDead()
+{
+  return pConditions[Condition_Dead] != 0;
+}
+
+bool Player::IsEradicated()
+{
+  return pConditions[Condition_Eradicated] != 0;
+}
+
+bool Player::IsZombie()
+{
+  return pConditions[Condition_Zombie] != 0;
+}
+
+bool Player::IsCursed()
+{
+  return pConditions[Condition_Cursed] != 0;
+}
+
+bool Player::IsPertified()
+{
+  return pConditions[Condition_Pertified] != 0;
+}
+
+bool Player::IsUnconcious()
+{
+  return pConditions[Condition_Unconcious] != 0;
+}
+
+bool Player::IsAsleep()
+{
+  return pConditions[Condition_Sleep] != 0;
+}
+
+bool Player::IsParalyzed()
+{
+  return pConditions[Condition_Paralyzed] != 0;
+}
+
+void Player::SetCursed( bool state )
+{
+  pConditions[Condition_Cursed] = state;
+}
+
+void Player::SetWeak( bool state )
+{
+  pConditions[Condition_Weak] = state;
+}
+
+void Player::SetAsleep( bool state )
+{
+  pConditions[Condition_Sleep] = state;
+}
+
+void Player::SetAfraid( bool state )
+{
+  pConditions[Condition_Fear] = state;
+}
+
+void Player::SetDrunk( bool state )
+{
+  pConditions[Condition_Drunk] = state;
+}
+
+void Player::SetInsane( bool state )
+{
+  pConditions[Condition_Insane] = state;
+}
+
+void Player::SetPoison1( bool state )
+{
+  pConditions[Condition_Poison1] = state;
+}
+
+void Player::SetDisease1( bool state )
+{
+  pConditions[Condition_Disease1] = state;
+}
+
+void Player::SetPoison2( bool state )
+{
+  pConditions[Condition_Poison2] = state;
+}
+
+void Player::SetDisease2( bool state )
+{
+  pConditions[Condition_Disease2] = state;
+}
+
+void Player::SetPoison3( bool state )
+{
+  pConditions[Condition_Poison3] = state;
+}
+
+void Player::SetDisease3( bool state )
+{
+  pConditions[Condition_Disease3] = state;
+}
+
+void Player::SetParalyzed( bool state )
+{
+  pConditions[Condition_Paralyzed] = state;
+}
+
+void Player::SetUnconcious( bool state )
+{
+  pConditions[Condition_Unconcious] = state;
+}
+
+void Player::SetDead( bool state )
+{
+  pConditions[Condition_Dead] = state;
+}
+
+void Player::SetPertified( bool state )
+{
+  pConditions[Condition_Pertified] = state;
+}
+
+void Player::SetEradicated( bool state )
+{
+  pConditions[Condition_Eradicated] = state;
+}
+
+void Player::SetZombie( bool state )
+{
+  pConditions[Condition_Zombie] = state;
+}
+
+void Player::SetCondWeakWithBlockCheck( int blockable )
+{
+  SetCondition(Condition_Weak, blockable);
+}
+
+void Player::SetCondInsaneWithBlockCheck( int blockable )
+{
+  SetCondition(Condition_Insane, blockable);
+}
+
+void Player::SetCondDeadWithBlockCheck( int blockable )
+{
+  SetCondition(Condition_Dead, blockable);
+}
--- a/Player.h	Mon Jul 15 15:03:40 2013 +0600
+++ b/Player.h	Mon Jul 15 15:03:56 2013 +0600
@@ -1,6 +1,7 @@
 #pragma once
 #include "Items.h"
 #include "Spells.h"
+#include "Conditions.h"
 
 
 
@@ -413,9 +414,9 @@
   CHARACTER_EXPRESSION_31 = 31,
   CHARACTER_EXPRESSION_32 = 32,
   CHARACTER_EXPRESSION_33 = 33,
-  CHARACTER_EXPRESSION_34 = 34,
-  CHARACTER_EXPRESSION_35 = 35,
-  CHARACTER_EXPRESSION_36 = 36,
+  CHARACTER_EXPRESSION_DMGRECVD_MINOR = 34,
+  CHARACTER_EXPRESSION_DMGRECVD_MODERATE = 35,
+  CHARACTER_EXPRESSION_DMGRECVD_MAJOR = 36,
   CHARACTER_EXPRESSION_37 = 37,
   CHARACTER_EXPRESSION_38 = 38,
   CHARACTER_EXPRESSION_39 = 39,
@@ -428,7 +429,7 @@
   CHARACTER_EXPRESSION_55 = 55,
   CHARACTER_EXPRESSION_56 = 56,
   CHARACTER_EXPRESSION_57 = 57,
-  CHARACTER_EXPRESSION_58 = 58,
+  CHARACTER_EXPRESSION_FALLING = 58,
 
   // ?
 
@@ -446,28 +447,9 @@
 #pragma pack(push, 1)
 struct Player
 {
-enum Condition: unsigned __int32
-    {
-    Condition_Cursed = 0,
-    Condition_Weak = 1,
-    Condition_Sleep = 2,
-    Condition_Fear = 3,
-    Condition_Drunk = 4,
-    Condition_Insane = 5,
-    Condition_Poison1 = 6,
-    Condition_Disease1 = 7,
-    Condition_Poison2 = 8,
-    Condition_Disease2 = 9,
-    Condition_Poison3 = 10,
-    Condition_Disease3 = 11,
-    Condition_Paralyzed = 12,
-    Condition_Unconcious = 13,
-    Condition_Dead = 14,
-    Condition_Pertified = 15,
-    Condition_Eradicated = 16,
-    Condition_Zombie = 17,
-    Condition_Good = 18
-    };
+  static const unsigned int INVETORYSLOTSWIDTH = 14;
+  static const unsigned int INVETORYSLOTSHEIGHT = 9;
+
 
   Player();
 
@@ -558,7 +540,7 @@
   int GetDisarmTrap();
   char GetLearningPercent();
   bool CanFitItem(unsigned int uSlot, unsigned int uItemID);
-  unsigned int FindFreeInventorySlot();
+  int FindFreeInventorySlot();
   int CreateItemInInventory(unsigned int uSlot, unsigned int uItemID);
   int HasSkill(unsigned int uSkillType);
   int WearItem(unsigned int uItemID);
@@ -570,13 +552,13 @@
   bool CanAct();
   bool CanSteal();
   bool CanEquip_RaceAndAlignmentCheck(unsigned int uItemID);
-  int SetCondition(unsigned int uConditionIdx, int a3);
-  int _49327B(unsigned int uClass, int a3);
+  void SetCondition(unsigned int uConditionIdx, int a3);
+  bool ProfessionOrGuildFlagsCorrect(unsigned int uClass, int a3);
   void PlaySound(PlayerSpeech speech, int a3);
   void PlayEmotion(CHARACTER_EXPRESSION_ID expression, int a3);
   void ItemsEnchant(int enchant_count);
   unsigned int GetItemIDAtInventoryIndex(int *a2);
-  int IsPlayerHealableByTemple();
+  bool IsPlayerHealableByTemple();
   int GetBaseIdentifyPrice(float a2);
   int GetBaseRepairPrice(int a2, float a3);
   int GetBaseBuyingPrice(int a2, float a3);
@@ -587,7 +569,7 @@
   int GetPriceSell(int uRealValue, float price_multiplier);
   int GetTempleHealCostModifier(float a2);
   int GetConditionDayOfWeek(unsigned int uCondition);
-  bool _43EEF3();
+  bool NothingOrJustBlastersEquipped();
   void SalesProcess(unsigned int inventory_idnx, int item_index, int _2devent_idx);//0x4BE2DD
   bool Recover(signed int a2);
   bool CanCastSpell(unsigned int uRequiredMana);
@@ -595,33 +577,46 @@
   void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId);
   void EquipBody(ITEM_EQUIP_TYPE uEquipType);
 
-  inline bool Weak()       {return pConditions[Condition_Weak] != 0;}
-  inline bool Dead()       {return pConditions[Condition_Dead] != 0;}
-  inline bool Eradicated() {return pConditions[Condition_Eradicated] != 0;}
-  inline bool Zombie()     {return pConditions[Condition_Zombie] != 0;}
-  inline bool Cursed()     {return pConditions[Condition_Cursed] != 0;}
-  inline bool Pertified()  {return pConditions[Condition_Pertified] != 0;}
+  bool IsWeak();
+  bool IsDead();
+  bool IsEradicated();
+  bool IsZombie();
+  bool IsCursed();
+  bool IsPertified();
+  bool IsUnconcious();
+  bool IsAsleep();
+  bool IsParalyzed();
 
-  inline void SetCursed(bool state)      {pConditions[Condition_Cursed] = state;}
-  inline void SetWeak(bool state)        {pConditions[Condition_Weak] = state;}
-  inline void SetAsleep(bool state)      {pConditions[Condition_Sleep] = state;}
-  inline void SetAfraid(bool state)      {pConditions[Condition_Fear] = state;}
-  inline void SetDrunk(bool state)       {pConditions[Condition_Drunk] = state;}
-  inline void SetInsane(bool state)      {pConditions[Condition_Insane] = state;}
-  inline void SetPoison1(bool state)     {pConditions[Condition_Poison1] = state;}
-  inline void SetDisease1(bool state)    {pConditions[Condition_Disease1] = state;}
-  inline void SetPoison2(bool state)     {pConditions[Condition_Poison2] = state;}
-  inline void SetDisease2(bool state)    {pConditions[Condition_Disease2] = state;}
-  inline void SetPoison3(bool state)     {pConditions[Condition_Poison3] = state;}
-  inline void SetDisease3(bool state)    {pConditions[Condition_Disease3] = state;}
-  inline void SetParalyzed(bool state)   {pConditions[Condition_Paralyzed] = state;}
-  inline void SetUnconcious(bool state)  {pConditions[Condition_Unconcious] = state;}
-  inline void SetDead(bool state)        {pConditions[Condition_Dead] = state;}
-  inline void SetPertified(bool state)   {pConditions[Condition_Pertified] = state;}
-  inline void SetEradicated(bool state)  {pConditions[Condition_Eradicated] = state;}
-  inline void SetZombie(bool state)      {pConditions[Condition_Zombie] = state;}
+  void SetCursed(bool state);
+  void SetWeak(bool state);
+  void SetAsleep(bool state);
+  void SetAfraid(bool state);
+  void SetDrunk(bool state);
+  void SetInsane(bool state);
+  void SetPoison1(bool state);
+  void SetDisease1(bool state);
+  void SetPoison2(bool state);
+  void SetDisease2(bool state);
+  void SetPoison3(bool state);
+  void SetDisease3(bool state);
+  void SetParalyzed(bool state);
+  void SetUnconcious(bool state);
+  void SetDead(bool state);
+  void SetPertified(bool state);
+  void SetEradicated(bool state);
+  void SetZombie(bool state);
 
+  void SetCondWeakWithBlockCheck (int blockable);
+  void SetCondInsaneWithBlockCheck (int blockable);
+  void SetCondDeadWithBlockCheck (int blockable);
 
+  inline bool IsRaceHuman() {return GetRace() == CHARACTER_RACE_HUMAN;}
+  inline bool IsRaceDwarf() {return GetRace() == CHARACTER_RACE_DWARF;}
+  inline bool IsRaceElf() {return GetRace() == CHARACTER_RACE_ELF;}
+  inline bool IsRaceGoblin() {return GetRace() == CHARACTER_RACE_GOBLIN;}
+
+  inline bool IsMale() { return GetSexByVoice() == SEX_MALE;}
+  inline bool IsFemale() { return !IsMale();}
   __int64 pConditions[20];
   unsigned __int64 uExperience;
   char pName[16];
--- a/Spells.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/Spells.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -974,7 +974,7 @@
         //v32 = pParty->pPlayers;//[0].pConditions[1];
         //do
         for (uint i = 0; i < 4; ++i)
-          if (pParty->pPlayers[i].pConditions[Player::Condition_Weak])
+          if (pParty->pPlayers[i].IsWeak())
             return;
 		//while ( v32 <= &pParty->pPlayers[3] );
         //if ( !levela )
--- a/UI/UICharacter.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/UI/UICharacter.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -2640,7 +2640,7 @@
   unsigned __int16 v5; // ax@7
   unsigned int v6; // edi@19
   int v7; // esi@27
-  unsigned int v8; // eax@29
+  int v8; // eax@29
   int v9; // edx@32
   int v10; // esi@34
   int v11; // eax@34
@@ -2655,10 +2655,10 @@
   int v20; // esi@60
   int v21; // eax@60
   unsigned int v22; // eax@61
-  unsigned int v23; // eax@62
+  int v23; // eax@62
   int v24; // esi@65
   int v25; // eax@65
-  unsigned int v26; // eax@69
+  int v26; // eax@69
   int v27; // esi@81
   int v28; // eax@81
   int v29; // esi@84
@@ -2677,7 +2677,7 @@
   unsigned int v49; // [sp+34h] [bp-18h]@57
   unsigned int v50; // [sp+38h] [bp-14h]@50
   int v51; // [sp+3Ch] [bp-10h]@1
-  unsigned int v52; // [sp+40h] [bp-Ch]@5
+  int v52; // [sp+40h] [bp-Ch]@5
   //int v53; // [sp+44h] [bp-8h]@1
   //unsigned int v54; // [sp+48h] [bp-4h]@1
 
@@ -2728,7 +2728,7 @@
         pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
         return;
     }
-    if ( pParty->pPickedItem.uItemID == 604 )
+    if ( pParty->pPickedItem.uItemID == ITEM_WETSUIT )
     {
       pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3);
       WetsuitOn(uActiveCharacter);
@@ -2756,7 +2756,7 @@
 			return;
 		}
         pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6);
-        if ( pParty->pPickedItem.uItemID == 604 )
+        if ( pParty->pPickedItem.uItemID == ITEM_WETSUIT )
           WetsuitOff(uActiveCharacter);
         return;
       case 0xAu:
@@ -2772,7 +2772,7 @@
           if ( !*(int *)v7 )
           {
             v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
-            if ( (v8 & 0x80000000u) == 0 )
+            if ( v8 >= 0 )
 			{
 			  v9 = v52;
 			  pParty->pPickedItem.uBodyAnchor = v52 + 1;
@@ -2831,7 +2831,7 @@
         else
         {
           v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
-          if ( (v52 & 0x80000000u) != 0 )
+          if ( v52 < 0 )
             return;
           if ( !v51 )
           {
@@ -2906,7 +2906,7 @@
 				break;
               }
               v23 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
-              if ( (v23 & 0x80000000u) != 0 )
+              if ( v23 < 0 )
                 return;
               pParty->pPickedItem.uBodyAnchor = 1;
               v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v23];
@@ -2929,7 +2929,7 @@
         if ( !v1 )
         {
           v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
-          if ( (v26 & 0x80000000u) != 0 )
+          if ( v26 < 0 )
             return;
           pParty->pPickedItem.uBodyAnchor = 2;
           v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v26];
@@ -3000,7 +3000,7 @@
         else
         {
           v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot();
-          if ( (v52 & 0x80000000u) == 0 )
+          if ( v52 >= 0 )
           {
             if ( v2 )
             {
@@ -3043,7 +3043,7 @@
     v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36);
     v50 = v37;
     v38 = (ItemGen *)(v37 + 532);
-    v14 = v38->uItemID == 604;
+    v14 = v38->uItemID == ITEM_WETSUIT;
     v52 = pItemsTable->pItems[v38->uItemID].uEquipType;
     if ( v14 )
     {
--- a/UI/UIRest.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/UI/UIRest.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -105,7 +105,7 @@
     text_color =   TargetColor(10, 0, 0);
     shadow_color = TargetColor(230, 214, 193);
     for(int i=1; i<5; ++i)
-        if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 )
+        if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 )
             ++live_characters;
 
     if ( live_characters )
--- a/UI/UiGame.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/UI/UiGame.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -968,9 +968,9 @@
   window->uFrameW = v9 + window->uFrameY - 1;
   window->DrawMessageBox(0);
 
-  if (player->Eradicated())
+  if (player->IsEradicated())
     v13 = pTexture_PlayerFaceEradicated;
-  else if (player->Dead())
+  else if (player->IsDead())
     v13 = pTexture_PlayerFaceDead;
   else
   {
@@ -2210,9 +2210,9 @@
 
     for (uint i = 0; i < 4; ++i)
         {
-        auto pPlayer = pParty->pPlayers + i;
+        Player* pPlayer = pParty->pPlayers + i;
 
-        if (pPlayer->Eradicated())
+        if (pPlayer->IsEradicated())
             {
             pFace = pTexture_PlayerFaceEradicated;
             pPortrait = pFace;
@@ -2232,7 +2232,7 @@
                 sub_441A4E(i);
             continue;
             }
-        if (pPlayer->Dead())
+        if (pPlayer->IsDead())
             {
             pFace = pTexture_PlayerFaceDead;
             pPortrait = pFace;
--- a/Viewport.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/Viewport.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -291,7 +291,7 @@
       {
         sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].pUnidentifiedName);
         ShowStatusBarString(pTmpBuf2.data(), 2u);
-        if ( pSpriteObjects[v21].stru_24.uItemID == 506 )
+        if ( pSpriteObjects[v21].stru_24.uItemID == ITEM_ARTIFACT_SPLITTER )
           _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
         if ( pSpriteObjects[v21].stru_24.uItemID == 455 )
           _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
--- a/mm7_2.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/mm7_2.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -825,13 +825,13 @@
   pWindow.uFrameZ = 543;
   pWindow.uFrameW = 397;
   pFont = LoadFont("endgame.fnt", "FONTPAL", NULL);
-  if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 99) )
+  if ( pParty->IsPartyGood() )
   {
     v1 = pGlobalTXT_LocalizationStrings[675];
   }
   else
   {
-    result = _449B57_test_bit(pParty->_quest_bits, 100);
+    result = pParty->IsPartyEvil();
     if ( !(short)result )
       return result;
     v1 = pGlobalTXT_LocalizationStrings[676];
--- a/mm7_4.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/mm7_4.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -1606,7 +1606,7 @@
     if (pParty->days_played_without_rest > 1)
     {
       for (uint i = 0; i < 4; ++i)
-        pParty->pPlayers[i].SetCondition(Player::Condition_Weak, 0);
+        pParty->pPlayers[i].SetCondWeakWithBlockCheck(0);
 
       if (pParty->uNumFoodRations)
         Party::TakeFood(1);
@@ -1617,16 +1617,16 @@
       if (pParty->days_played_without_rest > 3)
         for (uint i = 0; i < 4; ++i)
         {
-          auto player = pParty->pPlayers + i;
+          Player* player = pParty->pPlayers + i;
 
           player->Zero();
 
-          if (!player->Pertified() && !player->Eradicated() && !player->Dead())
+          if (!player->IsPertified() && !player->IsEradicated() && !player->IsDead())
           {
             if (rand() % 100 < 5 * pParty->days_played_without_rest)
-              player->SetCondition(Player::Condition_Dead, 0);
+              player->SetCondDeadWithBlockCheck(0);
             if (rand() % 100 < 10 * pParty->days_played_without_rest)
-              player->SetCondition(Player::Condition_Insane, 0);
+              player->SetCondInsaneWithBlockCheck(0);
           }
         }
     }
@@ -5238,7 +5238,7 @@
           v8 = 138;
           do
           {
-			if ( v7->uItemID == 601 )
+			if ( v7->uItemID == ITEM_LICH_JAR_FULL )
             {
 			  if ( !v7->uHolderPlayer )
 				  v9 = v7;
@@ -5497,13 +5497,13 @@
         switch ( dword_F8B1AC_award_bit_number )
         {
           case 19:
-            if ( pPlayers[uActiveCharacter]->_49327B(0x22u, 1) == 1 )
+            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x22u, 1) == 1 )
             {
               if ( !gold_transaction_amount )
                 goto LABEL_79;
               goto LABEL_42;
             }
-            if ( pPlayers[uActiveCharacter]->_49327B(26, 1) == 1 )
+            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Au, 1) == 1 )
             {
               if ( !gold_transaction_amount )
                 goto LABEL_79;
@@ -5511,13 +5511,13 @@
             }
             return v35;
           case 20:
-            if ( pPlayers[uActiveCharacter]->_49327B(0x23u, 1) == 1 )
+            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x23u, 1) == 1 )
             {
               if ( !gold_transaction_amount )
                 goto LABEL_79;
               goto LABEL_42;
             }
-            if ( pPlayers[uActiveCharacter]->_49327B(27, 1) == 1 )
+            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Bu, 1) == 1 )
             {
               if ( !gold_transaction_amount )
                 goto LABEL_79;
--- a/mm7_5.cpp	Mon Jul 15 15:03:40 2013 +0600
+++ b/mm7_5.cpp	Mon Jul 15 15:03:56 2013 +0600
@@ -2488,10 +2488,10 @@
           dword_506F14 = 2;
           pParty->RestAndHeal();
           pParty->days_played_without_rest = 0;
-          pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
-          pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
-          pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
-          pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+          pParty->pPlayers[3].SetAsleep(1);
+          pParty->pPlayers[2].SetAsleep(1);
+          pParty->pPlayers[1].SetAsleep(1);
+          pParty->pPlayers[0].SetAsleep(1);
           continue;
         case UIMSG_RestWindow:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -2598,10 +2598,10 @@
             dword_506F14 = 2;
             pParty->RestAndHeal();
             pParty->days_played_without_rest = 0;
-            pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
-            pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
-            pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
-            pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
+            pParty->pPlayers[3].SetAsleep(1);
+            pParty->pPlayers[2].SetAsleep(1);
+            pParty->pPlayers[1].SetAsleep(1);
+            pParty->pPlayers[0].SetAsleep(1);
           }
           continue;
         case UIMSG_AlreadyResting:
@@ -5614,7 +5614,7 @@
   v45 = v8 & 0x3F;
   pOut.y = SkillToMastery(v8);
   v10 = pOut.z;
-  if ( pParty->pPickedItem.uItemID == 220 )
+  if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE )
   {
 LABEL_116:
     GameUI_DrawItemInfo(&v0->pInventoryItems[v10]);