changeset 1621:25d3f9e43634

Merge
author Grumpy7
date Sun, 15 Sep 2013 02:21:26 +0200
parents 61ea994a1812 (diff) de6e646822a6 (current diff)
children a6642179aa33 511cd6dd1048
files mm7_data.h
diffstat 6 files changed, 780 insertions(+), 877 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor.cpp	Sat Sep 14 22:43:45 2013 +0100
+++ b/Outdoor.cpp	Sun Sep 15 02:21:26 2013 +0200
@@ -447,7 +447,10 @@
   {
     if ( v9 == 4 ) // to & from Shoals
     {
-      if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(0) )
+      if ( pPlayers[1]->HasUnderwaterSuitEquipped() &&
+           pPlayers[2]->HasUnderwaterSuitEquipped() &&
+           pPlayers[3]->HasUnderwaterSuitEquipped() &&
+           pPlayers[4]->HasUnderwaterSuitEquipped())
       {
         uDefaultTravelTime_ByFoot = 1;
         strcpy(pOut, "out15.odm");
--- a/Player.cpp	Sat Sep 14 22:43:45 2013 +0100
+++ b/Player.cpp	Sun Sep 15 02:21:26 2013 +0200
@@ -3468,7 +3468,7 @@
 
 //----- (0048F882) --------------------------------------------------------
 int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType )
-    {
+{
   signed int bonus_value; // esi@1
   unsigned __int16 skill_value; // ax@126
   int result; // al@127
@@ -3941,40 +3941,31 @@
 //                     24   zombie female
 enum CHARACTER_RACE Player::GetRace()
 {
-  if ( uCurrentFace > 15 )
-  {
-    if ( uCurrentFace >= 16 && uCurrentFace <= 19 )
-      return CHARACTER_RACE_GOBLIN;
+  if ( uCurrentFace <= 7 )
+  {
+    return CHARACTER_RACE_HUMAN;
+  }
+  else if ( uCurrentFace <= 11 )
+  {
+      return CHARACTER_RACE_ELF;
+  }
+  else if ( uCurrentFace <= 15 )
+  {
+    return CHARACTER_RACE_DWARF;
+  }
+  else if ( uCurrentFace <= 19 )
+  {
+    return CHARACTER_RACE_GOBLIN;
   }
   else
   {
-    if ( uCurrentFace >= 12 )
-    {
-      return CHARACTER_RACE_DWARF;
-    }
-    else
-    {
-      
-        if ( uCurrentFace <= 7 )
-        {
-          return CHARACTER_RACE_HUMAN;
-        }
-        else
-        {
-          if ( uCurrentFace <= 11 )
-            return CHARACTER_RACE_ELF;
-        }
-    }
-  }
-  return CHARACTER_RACE_HUMAN;
+    return CHARACTER_RACE_HUMAN;
+  }
 }
 
 //----- (00490141) --------------------------------------------------------
 PLAYER_SEX Player::GetSexByVoice()
 {
-  signed int result; // eax@1
-
-  result = 0;
   switch ( this->uVoiceID )
   {
     case 0u:
@@ -4024,7 +4015,7 @@
 
 //----- (004901FC) --------------------------------------------------------
 void Player::SetSexByVoice()
-    {
+{
   switch ( this->uVoiceID)
   {
     case 0:
@@ -4056,6 +4047,7 @@
       this->uSex = SEX_FEMALE;
       break;
     default:
+      Error("(%u)", this->uVoiceID);
       break;
   }
  
@@ -4264,18 +4256,16 @@
 //unsigned __int16 PartyCreation_BtnMinusClick(Player *_this, int eAttribute)
 void Player::DecreaseAttribute(int eAttribute)
 {
-  int v2; // eax@1
   int pBaseValue; // ecx@1
   int pDroppedStep; // ebx@1
   int pStep; // esi@1
-  unsigned __int16 result; // ax@7
   int uMinValue; // [sp+Ch] [bp-4h]@1
 
-  v2 = eAttribute + 7 * GetRace();
-  pBaseValue = StatTable[0][v2].uBaseValue;
-  pDroppedStep = StatTable[0][v2].uDroppedStep;
+  int raceId = GetRace();
+  pBaseValue = StatTable[raceId][eAttribute].uBaseValue;
+  pDroppedStep = StatTable[raceId][eAttribute].uDroppedStep;
   uMinValue = pBaseValue - 2;
-  pStep = StatTable[0][v2].uBaseStep;
+  pStep = StatTable[raceId][eAttribute].uBaseStep;
   unsigned short* AttrToChange = nullptr;
   switch ( eAttribute )
   {
@@ -4440,680 +4430,670 @@
 
 //----- (004680ED) --------------------------------------------------------
 void Player::UseItem_DrinkPotion_etc(signed int player_num, int a3)
-    {
-    Player *v3; // esi@1
-    signed int v5; // eax@17
-    int v8; // edx@39
-    char *v13; // eax@45
-    signed int v15; // edi@68
-    int v16; // edx@73
-    unsigned __int16 v17; // edi@73
-    unsigned int v18; // eax@73
-    const char *v22; // eax@84
-    int scroll_id; // esi@96
-    int v25; // eax@109
-    int v26; // eax@113
-    int new_mana_val; // edi@114
-    signed __int64 v28; // qax@120
-    __int64 v30; // edi@137
-    __int64 v32; // ST3C_4@137
-    __int64 v34; // ST34_4@137
-    unsigned __int16 v50; // [sp-Ch] [bp-38h]@120
-    const char *v66; // [sp-4h] [bp-30h]@69
-    signed int v67; // [sp-4h] [bp-30h]@77
-    const char *v68; // [sp-4h] [bp-30h]@89
-    char v72; // [sp+20h] [bp-Ch]@68
-    signed int v73; // [sp+24h] [bp-8h]@1
-    char*  v74; // [sp+24h] [bp-8h]@23
-    Player *thisb; // [sp+28h] [bp-4h]@1
-    unsigned int thisa; // [sp+28h] [bp-4h]@22
-
-    thisb = this;
-    v3 = &pParty->pPlayers[player_num-1];
-    v73 = 1;
-    if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) )
-        return;
-    if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_REAGENT )
-        {
-        if ( pParty->pPickedItem.uItemID == 160 )
-            { 
-            pParty->pPlayers[player_num-1].SetCondition(Condition_Poison1, 1);
-            }
-        else if ( pParty->pPickedItem.uItemID == 161 )
-            {
-            new_mana_val = v3->sMana;
-            new_mana_val += 2;
-            if ( new_mana_val > v3->GetMaxMana() )
-                new_mana_val = v3->GetMaxMana();
-            v3->PlaySound(SPEECH_36, 0);
-            }
-        else if ( pParty->pPickedItem.uItemID == 162 )
-            {
-            pParty->pPlayers[player_num-1].Heal(2);
-            v3->PlaySound(SPEECH_36, 0);
-            
-            }
-        else
-            {    
-            v68 = pParty->pPickedItem.GetDisplayName();
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way"
-            ShowStatusBarString(pTmpBuf.data(), 2);
-            pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-            return;
-            }
-        pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0);
-
-        if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
-            {
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-            }
-        if ( v73 )
-            {
-            if ( pParty->bTurnBasedModeOn )
-                {
-                pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
-                thisb->SetRecoveryTime(100);
-                pTurnEngine->ApplyPlayerAction();
-                }
-            else
-                {
-                thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
-                }
-            }
-        pMouse->RemoveHoldingItem();
-        return;
-
-
-        }
-    if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_POTION )
-        {
-        switch ( pParty->pPickedItem.uItemID )
-            {
-        case 221: //Catalyst
-            pParty->pPlayers[player_num-1].SetCondition(Condition_Poison1, 1);
-            break;
-        case 222: //Cure Wounds
-            v25 = pParty->pPickedItem.uEnchantmentType + 10;
-            pParty->pPlayers[player_num-1].Heal(v25);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 223: //Magic Potion
-            v26 = pParty->pPickedItem.uEnchantmentType + 10;
-            new_mana_val = v3->sMana;
-            new_mana_val += v26;
-            if ( new_mana_val > v3->GetMaxMana() )
-                new_mana_val = v3->GetMaxMana();
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 224: //Cure Weakness
-            v3->pConditions[Condition_Weak] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 225: //Cure Disease
-            v3->pConditions[Condition_Disease3] = 0i64;      
-            v3->pConditions[Condition_Disease2] = 0i64;
-            v3->pConditions[Condition_Disease1] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 226: //Cure Poison
-            v3->pConditions[Condition_Poison3] = 0i64;
-            v3->pConditions[Condition_Poison2] = 0i64;
-            v3->pConditions[Condition_Poison1] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 227: //Awaken
-            v3->pConditions[Condition_Sleep] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 228: //Haste
-            if ( !v3->pConditions[Condition_Weak] )
-                {
+{
+  Player *playerAffected; // esi@1
+  signed int v5; // eax@17
+  int v8; // edx@39
+  char *v13; // eax@45
+  signed int v15; // edi@68
+  int v16; // edx@73
+  unsigned __int16 v17; // edi@73
+  unsigned int v18; // eax@73
+  const char *v22; // eax@84
+  int scroll_id; // esi@96
+  int v25; // eax@109
+  int v26; // eax@113
+  int new_mana_val; // edi@114
+  signed __int64 v28; // qax@120
+  __int64 v30; // edi@137
+  __int64 v32; // ST3C_4@137
+  __int64 v34; // ST34_4@137
+  unsigned __int16 v50; // [sp-Ch] [bp-38h]@120
+  const char *v66; // [sp-4h] [bp-30h]@69
+  signed int v67; // [sp-4h] [bp-30h]@77
+  const char *v68; // [sp-4h] [bp-30h]@89
+  char v72; // [sp+20h] [bp-Ch]@68
+  signed int v73; // [sp+24h] [bp-8h]@1
+  char*  v74; // [sp+24h] [bp-8h]@23
+  Player *thisb; // [sp+28h] [bp-4h]@1
+  unsigned int thisa; // [sp+28h] [bp-4h]@22
+
+  thisb = this;
+  playerAffected = &pParty->pPlayers[player_num-1];
+  v73 = 1;
+  if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) )
+      return;
+  if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_REAGENT )
+  {
+    if ( pParty->pPickedItem.uItemID == 160 )
+    { 
+      playerAffected->SetCondition(Condition_Poison1, 1);
+    }
+    else if ( pParty->pPickedItem.uItemID == 161 )
+    {
+      new_mana_val = playerAffected->sMana;
+      new_mana_val += 2;
+      if ( new_mana_val > playerAffected->GetMaxMana() )
+        new_mana_val = playerAffected->GetMaxMana();
+      playerAffected->PlaySound(SPEECH_36, 0);
+    }
+    else if ( pParty->pPickedItem.uItemID == 162 )
+    {
+      playerAffected->Heal(2);
+      playerAffected->PlaySound(SPEECH_36, 0);
+    }
+    else
+    {    
+      v68 = pParty->pPickedItem.GetDisplayName();
+      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way"
+      ShowStatusBarString(pTmpBuf.data(), 2);
+      pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
+      return;
+    }
+    pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0);
+
+    if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
+    {
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+    }
+    if ( v73 )
+    {
+      if ( pParty->bTurnBasedModeOn )
+      {
+        pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
+        thisb->SetRecoveryTime(100);
+        pTurnEngine->ApplyPlayerAction();
+      }
+      else
+      {
+        thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333);
+      }
+    }
+    pMouse->RemoveHoldingItem();
+    return;
+  }
+
+  if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_POTION )
+  {
+      switch ( pParty->pPickedItem.uItemID )
+      {
+          case 221: //Catalyst
+              playerAffected->SetCondition(Condition_Poison1, 1);
+              break;
+          case 222: //Cure Wounds
+              v25 = pParty->pPickedItem.uEnchantmentType + 10;
+              playerAffected->Heal(v25);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 223: //Magic Potion
+              v26 = pParty->pPickedItem.uEnchantmentType + 10;
+              new_mana_val = playerAffected->sMana;
+              new_mana_val += v26;
+              if ( new_mana_val > playerAffected->GetMaxMana() )
+                  new_mana_val = playerAffected->GetMaxMana();
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 224: //Cure Weakness
+              playerAffected->pConditions[Condition_Weak] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 225: //Cure Disease
+              playerAffected->pConditions[Condition_Disease3] = 0i64;      
+              playerAffected->pConditions[Condition_Disease2] = 0i64;
+              playerAffected->pConditions[Condition_Disease1] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 226: //Cure Poison
+              playerAffected->pConditions[Condition_Poison3] = 0i64;
+              playerAffected->pConditions[Condition_Poison2] = 0i64;
+              playerAffected->pConditions[Condition_Poison1] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 227: //Awaken
+              playerAffected->pConditions[Condition_Sleep] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 228: //Haste
+              if ( !playerAffected->pConditions[Condition_Weak] )
+              {
                 v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-                v3->pPlayerBuffs[7].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
-                v3->PlaySound(SPEECH_36, 0);
-                }
-            break;
-        case 229: //Heroism
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[8].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 230: //Bless
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 231: //Preservation
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 232: //Shield
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[13].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 234: //Stoneskin
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[14].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 235: //Water Breathing
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335),
-            v3->pPlayerBuffs[23].Apply(pParty->uTimePlayed +v28,  3, 5, 0, 0);
-            break;
-        case 237: //Remove Fear
-            v3->pConditions[Condition_Fear] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 238: //Remove Curse
-            v3->pConditions[Condition_Cursed] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 239: //Cure Insanity
-            v3->pConditions[Condition_Insane] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 240: //Might Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[19].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 241: //Intellect Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[17].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 242: //Personality Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[20].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 243://Endurance Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[16].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 244: //Speed Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[21].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 245: //Accuracy Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[15].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 251: //Cure Paralysis
-            v3->pConditions[Condition_Paralyzed] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 252://Divine Restoration
-            v30 = v3->pConditions[Condition_Dead];
-            v32 = v3->pConditions[Condition_Pertified];
-            v34 = v3->pConditions[Condition_Eradicated];    
-            memset(&pParty->pPlayers[player_num-1].pConditions,0,sizeof(pConditions));
-            v3->pConditions[Condition_Dead] = v30;
-            v3->pConditions[Condition_Pertified] = v32;
-            v3->pConditions[Condition_Eradicated] = v34;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 253: //Divine Cure
-            v25 = 5 * pParty->pPickedItem.uEnchantmentType;
-            pParty->pPlayers[player_num-1].Heal(v25);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 254: //Divine Power
-            v26 = 5 * pParty->pPickedItem.uEnchantmentType;
-            new_mana_val = v3->sMana;
-            new_mana_val += v26;
-            if ( new_mana_val > v3->GetMaxMana() )
-                new_mana_val = v3->GetMaxMana();
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 255: //Luck Boost
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[18].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 256: //Fire Resistance
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[5].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 257: //Air Resistance
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[0].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 258: //Water Resistance
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[22].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 259: //Earth Resistance
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[3].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 260: //Mind Resistance
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[9].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 261: //Body Resistance
-            v50 = 3 * pParty->pPickedItem.uEnchantmentType;
-            v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
-            v3->pPlayerBuffs[2].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
-            v3->PlaySound(SPEECH_36, 0);
-           break;
-        case 262: //Stone to Flesh
-            v3->pConditions[Condition_Pertified] = 0i64;
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 264: //Pure Luck
-            if ( !v3->pure_luck_used )
-                {
-                v3->uLuck += 50;
-                v3->pure_luck_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 265: //Pure Speed
-            if ( !v3->pure_speed_used )
-                {
-                v3->uSpeed += 50;
-                v3->pure_speed_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 266: //Pure Intellect
-            if ( !v3->pure_intellect_used )
-                {
-                v3->uIntelligence += 50;
-                v3->pure_intellect_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-           break;
-        case 267: //Pure Endurance
-            if ( !v3->pure_endurance_used )
-                {
-                v3->uEndurance += 50;
-                v3->pure_endurance_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 268:  //Pure Personality
-            if ( !v3->pure_willpower_used )
-                {
-                v3->uWillpower += 50;
-                v3->pure_willpower_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 269: //Pure Accuracy
-            if ( !v3->pure_accuracy_used )
-                {
-                v3->uAccuracy += 50;
-                v3->pure_accuracy_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 270: //Pure Might
-            if ( !v3->pure_might_used )
-                {
-                v3->uMight += 50;
-                v3->pure_might_used = 1;
-                }
-            v3->PlaySound(SPEECH_36, 0);
-            break;
-        case 271: //Rejuvenation
-            v3->sAgeModifier = 0;
-            v3->PlaySound(SPEECH_36, 0);
-           break;
-
-        default:
-            v68 = pParty->pPickedItem.GetDisplayName();
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way"
-            ShowStatusBarString(pTmpBuf.data(), 2u);
-            pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-            return;
-            }
-        pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0);
-        if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
-            {
-            if ( !v73 )
-                {
-                pMouse->RemoveHoldingItem();
-                return;
-                }
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-            }
-        if ( v73 )
-            {
-            if ( pParty->bTurnBasedModeOn )
-                {
-                pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
-                thisb->SetRecoveryTime(100);
-                pTurnEngine->ApplyPlayerAction();
-                }
-            else
-                {
-                thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
-                }
-            }
-        pMouse->RemoveHoldingItem();
+                playerAffected->pPlayerBuffs[7].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
+                playerAffected->PlaySound(SPEECH_36, 0);
+              }
+              break;
+          case 229: //Heroism
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[8].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 230: //Bless
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 231: //Preservation
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 232: //Shield
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[13].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 234: //Stoneskin
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[14].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 235: //Water Breathing
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335),
+              playerAffected->pPlayerBuffs[23].Apply(pParty->uTimePlayed +v28,  3, 5, 0, 0);
+              break;
+          case 237: //Remove Fear
+              playerAffected->pConditions[Condition_Fear] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 238: //Remove Curse
+              playerAffected->pConditions[Condition_Cursed] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 239: //Cure Insanity
+              playerAffected->pConditions[Condition_Insane] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 240: //Might Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[19].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 241: //Intellect Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[17].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 242: //Personality Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[20].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 243://Endurance Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[16].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 244: //Speed Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[21].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 245: //Accuracy Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[15].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 251: //Cure Paralysis
+              playerAffected->pConditions[Condition_Paralyzed] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 252://Divine Restoration
+              v30 = playerAffected->pConditions[Condition_Dead];
+              v32 = playerAffected->pConditions[Condition_Pertified];
+              v34 = playerAffected->pConditions[Condition_Eradicated];    
+              memset(&playerAffected->pConditions,0,sizeof(pConditions));
+              playerAffected->pConditions[Condition_Dead] = v30;
+              playerAffected->pConditions[Condition_Pertified] = v32;
+              playerAffected->pConditions[Condition_Eradicated] = v34;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 253: //Divine Cure
+              v25 = 5 * pParty->pPickedItem.uEnchantmentType;
+              playerAffected->Heal(v25);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 254: //Divine Power
+              v26 = 5 * pParty->pPickedItem.uEnchantmentType;
+              new_mana_val = playerAffected->sMana;
+              new_mana_val += v26;
+              if ( new_mana_val > playerAffected->GetMaxMana() )
+                  new_mana_val = playerAffected->GetMaxMana();
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 255: //Luck Boost
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[18].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 256: //Fire Resistance
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[5].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 257: //Air Resistance
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[0].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 258: //Water Resistance
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[22].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 259: //Earth Resistance
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[3].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 260: //Mind Resistance
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[9].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 261: //Body Resistance
+              v50 = 3 * pParty->pPickedItem.uEnchantmentType;
+              v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335);
+              playerAffected->pPlayerBuffs[2].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0);
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 262: //Stone to Flesh
+              playerAffected->pConditions[Condition_Pertified] = 0i64;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 264: //Pure Luck
+              if ( !playerAffected->pure_luck_used )
+              {
+                playerAffected->uLuck += 50;
+                playerAffected->pure_luck_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 265: //Pure Speed
+              if ( !playerAffected->pure_speed_used )
+              {
+                playerAffected->uSpeed += 50;
+                playerAffected->pure_speed_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 266: //Pure Intellect
+              if ( !playerAffected->pure_intellect_used )
+              {
+                playerAffected->uIntelligence += 50;
+                playerAffected->pure_intellect_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 267: //Pure Endurance
+              if ( !playerAffected->pure_endurance_used )
+              {
+                playerAffected->uEndurance += 50;
+                playerAffected->pure_endurance_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 268:  //Pure Personality
+              if ( !playerAffected->pure_willpower_used )
+              {
+                playerAffected->uWillpower += 50;
+                playerAffected->pure_willpower_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 269: //Pure Accuracy
+              if ( !playerAffected->pure_accuracy_used )
+              {
+                playerAffected->uAccuracy += 50;
+                playerAffected->pure_accuracy_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 270: //Pure Might
+              if ( !playerAffected->pure_might_used )
+              {
+                playerAffected->uMight += 50;
+                playerAffected->pure_might_used = 1;
+              }
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+          case 271: //Rejuvenation
+              playerAffected->sAgeModifier = 0;
+              playerAffected->PlaySound(SPEECH_36, 0);
+              break;
+
+          default:
+          v68 = pParty->pPickedItem.GetDisplayName();
+          sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way"
+          ShowStatusBarString(pTmpBuf.data(), 2u);
+          pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
+          return;
+      }
+      pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0);
+      if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
+      {
+//         if ( !v73 )                                            v73 is always 1 at this point
+//         {
+//           pMouse->RemoveHoldingItem();
+//           return;
+//         }
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      }
+      if ( v73 )
+      {
+        if ( pParty->bTurnBasedModeOn )
+        {
+          pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
+          thisb->SetRecoveryTime(100);
+          pTurnEngine->ApplyPlayerAction();
+        }
+        else
+        {
+          thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333);
+        }
+      }
+      pMouse->RemoveHoldingItem();
+      return;
+  }
+
+
+  if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_SPELL_SCROLL )
+  {
+    if ( pCurrentScreen == SCREEN_CASTING )
         return;
-    
-        }
-
-
-    if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_SPELL_SCROLL )
-        {
-
-
-        if ( pCurrentScreen == SCREEN_CASTING )
-            return;
-        if ( !pParty->pPlayers[player_num-1].CanAct() )
-            {
-
-            v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()];
-        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);
+    if ( !playerAffected->CanAct() )
+    {
+
+      v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
+      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);
+      ShowStatusBarString(pTmpBuf.data(), 2u);
+      pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
+      return;
+    }
+    if ( bUnderwater == 1 )
+    {
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!"
+      pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
+      return;
+    }
+    dword_50C9AC = 1;
+    scroll_id = pParty->pPickedItem.uItemID - 299;
+    if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura
+    {
+      pMouse->RemoveHoldingItem();
+      pGUIWindow_CurrentMenu->Release();
+      pIcons_LOD->RemoveTexturesPackFromTextureList();
+      pCurrentScreen = SCREEN_GAME;
+      viewparams->bRedrawGameUI = 1;
+      _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0);
+    }
+    else
+    {
+      _720984_unused = pParty->pPickedItem.uItemID;
+      pMouse->RemoveHoldingItem();
+      pMessageQueue_50C9E8->AddMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1);
+      if ( pCurrentScreen && pGUIWindow_CurrentMenu
+        && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null))
+      {
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      }
+    }
+    return;
+  }
+
+  if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_BOOK )
+  {  
+      v15 = pParty->pPickedItem.uItemID - 400;
+      v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2;
+      if ( v72 )
+      {
+        v66 = pParty->pPickedItem.GetDisplayName();
+        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell"
         ShowStatusBarString(pTmpBuf.data(), 2u);
         pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
         return;
-            }
-        if ( bUnderwater == 1 )
-            {
-            ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!"
-            pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-            return;
-            }
-        dword_50C9AC = 1;
-        scroll_id = pParty->pPickedItem.uItemID - 299;
-        if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura
-            {
-            pMouse->RemoveHoldingItem();
-            pGUIWindow_CurrentMenu->Release();
-            pIcons_LOD->RemoveTexturesPackFromTextureList();
-            pCurrentScreen = SCREEN_GAME;
-            viewparams->bRedrawGameUI = 1;
-            _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0);
-            }
-        else
-            {
-            _720984_unused = pParty->pPickedItem.uItemID;
-            pMouse->RemoveHoldingItem();
-            pMessageQueue_50C9E8->AddMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1);
-            if ( pCurrentScreen && pGUIWindow_CurrentMenu
-                && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null))
-                {
-                pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-                }
-            }
+      }
+      if ( !playerAffected->CanAct() )
+      {
+        v66 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
+        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s"
+        ShowStatusBarString(pTmpBuf.data(), 2u);
+        pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
         return;
-        }
-
-    if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_BOOK )
-
-        {  
-        v15 = pParty->pPickedItem.uItemID - 400;
-        v72 = v3->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2;
-        if ( v72 )
-            {
-            v66 = pParty->pPickedItem.GetDisplayName();
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell"
-            ShowStatusBarString(pTmpBuf.data(), 2u);
-            pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-            return;
-            }
-        if ( !pParty->pPlayers[player_num-1].CanAct() )
-            {
-            v66 = aCharacterConditionNames[v3->GetMajorConditionIdx()];
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s"
-            ShowStatusBarString(pTmpBuf.data(), 2u);
-            pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-            return;
-            }
-        v16 = v15 % 11 + 1;
-        v17 = v3->pActiveSkills[v15 / 11 + 12];
-        v18 = SkillToMastery(v17) - 1;
-        switch (v18)
-            {
+      }
+      v16 = v15 % 11 + 1;
+      v17 = playerAffected->pActiveSkills[v15 / 11 + 12];
+      v18 = SkillToMastery(v17) - 1;
+      switch (v18)  
+      {
         case 0: v67 = 4; break;
         case 1: v67 = 7; break;
         case 2: v67 = 10; break;
         case 3: v67 = 11; break;
         default:
-            v67 = player_num;   
-            }
+          v67 = player_num;   
+      }
   
-        if ( v16 > v67 || !v17 )
-            {
-            v22 = pParty->pPickedItem.GetDisplayName();
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s"
-            ShowStatusBarString(pTmpBuf.data(), 2u);
-            v3->PlaySound((PlayerSpeech)20, 0);
-            return; 
-            }
-     //   v72 = 1;
-        v3->PlaySound(SPEECH_21, 0);
-        v73 = 0;
-
-
-        if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
-            {
-            if ( !v73 )
-                {
-                pMouse->RemoveHoldingItem();
-                return;
-                }
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-            }
-        if ( v73 )
+      if ( v16 > v67 || !v17 )
+      {
+        v22 = pParty->pPickedItem.GetDisplayName();
+        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s"
+        ShowStatusBarString(pTmpBuf.data(), 2u);
+        playerAffected->PlaySound((PlayerSpeech)20, 0);
+        return; 
+      }
+    //   v72 = 1;
+      playerAffected->PlaySound(SPEECH_21, 0);
+      v73 = 0;
+
+
+      if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
+      {
+        if ( !v73 )
+        {
+          pMouse->RemoveHoldingItem();
+          return;
+        }
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      }
+//       if ( v73 )                                                v73 is always 0 at this point
+//       {
+//         if ( pParty->bTurnBasedModeOn )
+//         {
+//           pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
+//           thisb->SetRecoveryTime(100);
+//           pTurnEngine->ApplyPlayerAction();
+//         }
+//         else
+//         {
+//           thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333);
+//         }
+//       }
+      pMouse->RemoveHoldingItem();
+      return;
+  }
+
+  if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_MESSAGE_SCROLL )
+  {
+      if ( playerAffected->CanAct() )
+      {
+          CreateMsgScrollWindow(pParty->pPickedItem.uItemID);
+          playerAffected->PlaySound(SPEECH_37, 0);
+          return;
+      }
+      v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()];
+      sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);
+      ShowStatusBarString(pTmpBuf.data(), 2u);
+      pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
+      return;
+  }
+  else
+  {
+    if (pParty->pPickedItem.uItemID == 616) //Genie Lamp
+    {
+      thisa = pParty->uCurrentMonthWeek + 1;
+      if ( pParty->uCurrentMonth >= 7 )
+          v74 = NULL;
+      else
+          v74 = aAttributeNames[pParty->uCurrentMonth];
+      switch ( pParty->uCurrentMonth )
+      {
+        case 0:
+            playerAffected->uMight += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 1:
+            playerAffected->uIntelligence += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 2:
+            playerAffected->uWillpower += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 3:
+            playerAffected->uEndurance += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 4:
+            playerAffected->uAccuracy += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 5:
+            playerAffected->uSpeed += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 6:
+            playerAffected->uLuck += thisa;
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
+            break;
+        case 7:
+            party_finds_gold(1000 * thisa, 0);
+            sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold"
+            break;
+        case 8:
+            Party::GiveFood(5 * thisa); 
+            sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food"
+            break;
+        case 9u:
+            playerAffected->uSkillPoints += 2 * thisa;
+            sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]);
+            break;
+        case 10:
+            playerAffected->uExperience += 2500 * thisa;
+            sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]);
+            break;
+        case 11:
+            v8 = rand() % 6;
+            switch (v8)
             {
-            if ( pParty->bTurnBasedModeOn )
-                {
-                pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
-                thisb->SetRecoveryTime(100);
-                pTurnEngine->ApplyPlayerAction();
-                }
-            else
-                {
-                thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
-                }
+            case 0:
+                playerAffected->sResFireBase += thisa;
+                v13 = pGlobalTXT_LocalizationStrings[87];
+                break;
+            case 1:
+                playerAffected->sResAirBase += thisa;
+                v13 = pGlobalTXT_LocalizationStrings[6];
+                break;
+            case 2:
+                playerAffected->sResWaterBase += thisa;
+                v13 = pGlobalTXT_LocalizationStrings[240];
+                break;
+            case 3:
+                playerAffected->sResEarthBase += thisa;
+                v13 = pGlobalTXT_LocalizationStrings[70];
+                break;
+            case 4:
+                playerAffected->sResMindBase += thisa;
+                v13 = pGlobalTXT_LocalizationStrings[142];
+                break;
+            case 5:
+                playerAffected->sResBodyBase += thisa;
+                v13 = pGlobalTXT_LocalizationStrings[29];
+                break;
             }
-        pMouse->RemoveHoldingItem();
+            sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]);
+            break;
+
+      }
+      ShowStatusBarString(pTmpBuf.data(), 2u);
+      pMouse->RemoveHoldingItem();
+      pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1);
+      playerAffected->PlaySound(SPEECH_93, 0);
+      pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0);
+      if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 )
+          {
+          playerAffected->SetCondition(Condition_Eradicated, 0);
+          pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0);
+          }
+      else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 )
+          {
+          playerAffected->SetCondition(Condition_Dead, 0);
+          pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0);
+          }
+      else  if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 )
+      {
+        playerAffected->SetCondition(Condition_Pertified, 0);
+        pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0);                 
+      }
+      return;
+      }
+      else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple
+      {
+          Party::GiveFood(1u);
+          pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0);
+      }
+      else if ( pParty->pPickedItem.uItemID == 632 ) //Lute
+      {
+        pAudioPlayer->PlaySound(SOUND_PlayLute,  0, 0, -1, 0, 0, 0, 0);
         return;
-
-        }
-
-    if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_MESSAGE_SCROLL )
-
-        {
-        if ( pParty->pPlayers[player_num-1].CanAct() )
-            {
-            CreateMsgScrollWindow(pParty->pPickedItem.uItemID);
-            v3->PlaySound(SPEECH_37, 0);
-            return;
-            }
-        v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()];
-        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68);
+      }
+      else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes
+      {
+        pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes,  0, 0, -1, 0, 0, 0, 0);
+        return;
+      }
+      else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet
+      {
+        pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet,  0, 0, -1, 0, 0, 0, 0);
+        return;
+      }
+      else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe
+      {
+        pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1);
+        v5 = PID(OBJECT_Player, player_num + 49);
+        pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0);
+        playerAffected->AddVariable(VAR_NumSkillPoints, 2);
+      }
+      else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle
+      {
+        TeleportToNWCDungeon();
+        return;
+      }
+      else
+      {
+        v68 = pParty->pPickedItem.GetDisplayName();
+        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way"
         ShowStatusBarString(pTmpBuf.data(), 2u);
         pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
         return;
-        }
-    else
-    {
-      if (pParty->pPickedItem.uItemID == 616) //Genie Lamp
-      {
-            thisa = pParty->uCurrentMonthWeek + 1;
-            if ( pParty->uCurrentMonth >= 7 )
-                v74 = NULL;
-            else
-                v74 = aAttributeNames[pParty->uCurrentMonth];
-            switch ( pParty->uCurrentMonth )
-                {
-            case 0:
-                v3->uMight += thisa;
-                sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 1:
-                v3->uIntelligence += thisa;
-                sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 2:
-                v3->uWillpower += thisa;
-                sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 3:
-                v3->uEndurance += thisa;
-                sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 4:
-                v3->uAccuracy += thisa;
-               sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 5:
-                v3->uSpeed += thisa;
-                sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 6:
-                v3->uLuck += thisa;
-               sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent"	
-                break;
-            case 7:
-                party_finds_gold(1000 * thisa, 0);
-                sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold"
-                break;
-            case 8:
-                Party::GiveFood(5 * thisa); 
-                sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food"
-                break;
-            case 9u:
-                v3->uSkillPoints += 2 * thisa;
-                sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]);
-                break;
-            case 10:
-                v3->uExperience += 2500 * thisa;
-                sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]);
-                break;
-            case 11:
-                v8 = rand() % 6;
-                switch (v8)
-                    {
-                case 0:
-                    v3->sResFireBase += thisa;
-                    v13 = pGlobalTXT_LocalizationStrings[87];
-                    break;
-                case 1:
-                    v3->sResAirBase += thisa;
-                    v13 = pGlobalTXT_LocalizationStrings[6];
-                    break;
-                case 2:
-                    v3->sResWaterBase += thisa;
-                    v13 = pGlobalTXT_LocalizationStrings[240];
-                    break;
-                case 3:
-                    v3->sResEarthBase += thisa;
-                    v13 = pGlobalTXT_LocalizationStrings[70];
-                    break;
-                case 4:
-                    v3->sResMindBase += thisa;
-                    v13 = pGlobalTXT_LocalizationStrings[142];
-                    break;
-                case 5:
-                    v3->sResBodyBase += thisa;
-                    v13 = pGlobalTXT_LocalizationStrings[29];
-                    break;
-                    }
-                sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]);
-                break;
-
-                }
-            ShowStatusBarString(pTmpBuf.data(), 2u);
-            pMouse->RemoveHoldingItem();
-            pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1);
-            v3->PlaySound(SPEECH_93, 0);
-            pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0);
-            if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 )
-                {
-                v3->SetCondition(Condition_Eradicated, 0);
-                pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0);
-                }
-            else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 )
-                {
-                v3->SetCondition(Condition_Dead, 0);
-                pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0);
-                }
-            else  if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 )
-                {
-                v3->SetCondition(Condition_Pertified, 0);
-                pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0);                 
-                }
-            return;
-            }
-        else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple
-        {
-            Party::GiveFood(1u);
-            pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0);
-        }
-        else if ( pParty->pPickedItem.uItemID == 632 ) //Lute
-                {
-                pAudioPlayer->PlaySound(SOUND_PlayLute,  0, 0, -1, 0, 0, 0, 0);
-                return;
-                }
-        else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes
-                {
-                pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes,  0, 0, -1, 0, 0, 0, 0);
-                return;
-                }
-        else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet
-                {
-                pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet,  0, 0, -1, 0, 0, 0, 0);
-                return;
-                }
-        else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe
-        {
-                pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1);
-                v5 = PID(OBJECT_Player, player_num + 49);
-                pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0);
-                v3->AddVariable(VAR_NumSkillPoints, 2);
-                }
-        else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle
-                    {
-                    TeleportToNWCDungeon();
-                    return;
-                    }
-        else
-                {
-   
-                v68 = pParty->pPickedItem.GetDisplayName();
-                sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way"
-                ShowStatusBarString(pTmpBuf.data(), 2u);
-                pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-                return;
-                }
-
-        pMouse->RemoveHoldingItem();
-        return;
-        }
-
-    }
+      }
+
+      pMouse->RemoveHoldingItem();
+      return;
+  }
+}
 
 //----- (00449BB4) --------------------------------------------------------
 bool Player::CompareVariable( enum VariableType VarNum, signed int pValue )
@@ -5672,6 +5652,7 @@
       {
         if ( (signed int)var_type >= 0xF5 )
         {
+          __debugbreak(); //how do I get here?
           *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);
           *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed);
         }
@@ -5680,9 +5661,11 @@
           switch ( var_type )
           {
             case VAR_MonthEquals|VAR_CurrentSP:
+              __debugbreak(); //how do I get here?
               _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u);
               break;
             case VAR_NPCs2:
+              __debugbreak(); //how do I get here?
               pParty->field_709 = 0;
               LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u;
               pParty->CountHirelings();
@@ -5699,6 +5682,7 @@
         return;
       if ( (signed int)var_type <= 0x112 )
       {
+        __debugbreak(); //how do I get here?
         *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);
         *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed);
       }
@@ -5721,6 +5705,7 @@
               v23 = pStorylineText->StoreLine[v22].pText == 0,//*(&pStorylineText->field_0 + 3 * v22) == 0,
               pParty->field_3C.field_4F0[2 * (var_type - 276) + 1] = HIDWORD(pParty->uTimePlayed),
               v23) )
+              __debugbreak(); //how do I get here?
           return;
         bFlashHistoryBook = 1;
       }
@@ -7344,35 +7329,27 @@
 //----- (00467E7F) --------------------------------------------------------
 void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType)
 {
-  //unsigned int v1; // esi@1
   int v2; // ebx@1
   Player *v3; // eax@1
   int v4; // edx@1
-  int v5; // esi@2
-  //int v6; // eax@2
   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
-  int *v11; // [sp+38h] [bp-4h]@1
-
-
-  _this.Reset();
+  ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1
+  unsigned int *v11; // [sp+38h] [bp-4h]@1
+
+  tempPickedItem.Reset();
   v2 = pEquipTypeToBodyAnchor[uEquipType];
   v3 = pPlayers[uActiveCharacter];
-  v11 = (int *)&v3->pEquipment.pIndices[v2];
+  v11 = &v3->pEquipment.pIndices[v2];
   v4 = *v11;
-  v10 = *v11;
-  if ( v10 )
-  {
-    memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-    v5 = (int)((char *)v3 + 4 * (9 * v4 - 9));
-    *(char *)(v5 + 556) = 0;
+  if ( v4 )
+  {
+    memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem));
+    v3->pInventoryItemList[v4 - 1].uBodyAnchor = 0;
     pParty->pPickedItem.Reset();
-    pParty->SetHoldingItem((ItemGen *)(v5 + 532));
-    _this.uBodyAnchor = v2 + 1;
-    memcpy((void *)(v5 + 532), &_this, 0x24u);
-    *v11 = v10;
+    pParty->SetHoldingItem(&v3->pInventoryItemList[v4 - 1]);
+    tempPickedItem.uBodyAnchor = v2 + 1;
+    memcpy(&v3->pInventoryItemList[v4 - 1], &tempPickedItem, sizeof(ItemGen));
+    *v11 = v4;
   }
   else
   {
@@ -7380,7 +7357,7 @@
     if (v7 >= 0)
     {
       pParty->pPickedItem.uBodyAnchor = v2 + 1;
-      memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItemList[v7]));
+      memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(ItemGen));
       *v11 = v7 + 1;
       pMouse->RemoveHoldingItem();
     }
@@ -7391,98 +7368,49 @@
 //----- (0049387A) --------------------------------------------------------
 int CycleCharacter(bool backwards)
 {
-  signed int result; // eax@1
-  signed int v2; // ecx@2
-  signed int v3; // ecx@8
-
-  result = uActiveCharacter;
-  if ( backwards )
-  {
-    v2 = 0;
-    while ( 1 )
-    {
-      --result;
-      if ( result < 1 )
-        result = 4;
-      if ( !pPlayers[result]->uTimeToRecovery )
-        break;
-      ++v2;
-      if ( v2 >= 4 )
-        return uActiveCharacter;
-    }
-  }
-  else
-  {
-    v3 = 0;
-    while ( 1 )
-    {
-      ++result;
-      if ( result > 4 )
-        result = 1;
-      if ( !pPlayers[result]->uTimeToRecovery )
-        break;
-      ++v3;
-      if ( v3 >= 4 )
-        return uActiveCharacter;
-    }
-  }
-  return result;
-}
+  const int PARTYSIZE = 4;
+  int valToAdd = backwards ? (PARTYSIZE - 2) : 0;
+  int mult = backwards ? -1 : 1;
+
+  for (int i = 0; i < (PARTYSIZE - 1); i++)
+  {
+    int currCharId = ((uActiveCharacter + mult * i + valToAdd) % PARTYSIZE) + 1;
+    if ( pPlayers[currCharId]->uTimeToRecovery == 0 )
+    {
+      return currCharId;
+    }
+  }
+  return uActiveCharacter;
+}
+
 //----- (0043EE77) --------------------------------------------------------
-bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1)
-{
-  bool result; // eax@0
-  Player *v2; // edx@3
-  int v3; // ecx@3
-  Player **pPlayers; // esi@8
-  //bool item_flag;
-  Player *v6; // edx@9
-
-  //if ( a1 < 1 || a1 > 4 )
-  //{
-    //if ( !a1 )
-    //{
-      //pPlayers = &::pPlayers[1];
-      //v5 = 604;
-      //while ( 1 )
-  Assert ( a1 > 0 && a1 < 5 );
-      for ( uint i = 1; i < 5; ++i )
-      {
-        //item_flag = Player_has_item(604, *pPlayers, 0);
-        if ( !Player_has_item(604, ::pPlayers[i], 0) )
-          return false;
-        //__debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used
-        //result = ::pPlayers[i]->pEquipment.uArmor;
-        if ( !::pPlayers[i]->pEquipment.uArmor )
-          return false;
-        //result *= 9;
-        if (::pPlayers[i]->pEquippedItems[::pPlayers[i]->pEquipment.uArmor].uItemID != 604 )
-          return false;
-        //++pPlayers;
-        //if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
-          //return true;
-      }
-      return true;
-    }
+bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player
+{
+  if (this->pEquipment.uArmor == 0 || this->pInventoryItemList[this->pEquipment.uArmor].uItemID != 604)
+  {
+    return false;
+  }
+  return true;
+}
 
 //----- (0043EE15) --------------------------------------------------------
-bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
+bool Player::HasItem( unsigned int uItemID, char a3 )
 {
   if ( !a3 || pParty->pPickedItem.uItemID != uItemID )
   {
     for ( uint i = 0; i < 126; ++i )
     {
-      if ( pPlayer->pInventoryMatrix[i] > 0 )
+      if ( this->pInventoryMatrix[i] > 0 )
       {
-        if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pInventoryMatrix[i] - 1].uItemID == uItemID )
+        if ( (unsigned int)this->pInventoryItemList[this->pInventoryMatrix[i] - 1].uItemID == uItemID )
           return true;
       }
     }
     for ( uint i = 0; i < 16; ++i )
     {
-      if ( pPlayer->pEquipment.pIndices[i] )
+      if ( this->pEquipment.pIndices[i] )
       {
-        if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID )
+        if ( (unsigned int)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == uItemID )
           return true;
       }
     }
@@ -7490,64 +7418,36 @@
   return false;
 }
 //----- (0043EDB9) --------------------------------------------------------
-bool  sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1)
-{
-  unsigned int pNum; // ebp@1
-  Player **pPlayer; // ebx@1
-  Player *pPlayer2; // esi@2
-  enum CHARACTER_RACE pRace; // edi@2
-  bool pSex; // eax@2
-  char v6; // zf@7
-
-//pPlayer = &pPlayers[1];
-  /*pNum = a1;
-  
-  while ( 1 )
-  {
-    pPlayer2 = *pPlayer;
-    pRace = pPlayer2->GetRace();
-    pSex = pPlayer2->GetSexByVoice();
-    if ( !pRace )
-      break;
-    if ( pRace == 1 || pRace == 2 )
-      break;
-    if ( !pSex && pNum == 2 )//
-      //goto LABEL_15;
-    {
-      pSex = 1;
-      return pSex;
-    }
-    v6 = pNum == 3;//
-LABEL_11:
-    if ( v6 )
-      //goto LABEL_15;
-    {
-      pSex = 1;
-      return pSex;
-    }
-    ++pPlayer;
-    if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )//
-    {
-      pSex = 0;
-      return pSex;
-    }
-  }
-  if ( pSex || pNum )
-  {
-    v6 = pNum == 1;
-    goto LABEL_11;
-  }
-//LABEL_15:
-  pSex = 1;
-  return pSex;*/
-  for (uint i = 1; i <= 4; ++i)
-    {
-      pRace = pPlayers[i]->GetRace();
-      pSex = pPlayers[i]->GetSexByVoice();
-      if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 )
-        return 1;
-    }
- return 0;
+bool ShouldLoadTexturesForRaceAndGender(unsigned int _this)
+{
+  CHARACTER_RACE race; // edi@2
+  PLAYER_SEX sex; // eax@2
+
+  for (int i = 1; i <= 4; i++)
+  {
+    race = pPlayers[i]->GetRace();
+    sex = pPlayers[i]->GetSexByVoice();
+    switch(_this)
+    {
+       case 0:
+         if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_MALE )
+           return true;
+         break;
+       case 1:
+         if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_FEMALE )
+           return true;
+         break;
+       case 2:
+         if ( race == CHARACTER_RACE_DWARF && sex == SEX_MALE )
+           return true;
+         break;
+       case 3:
+         if ( race == CHARACTER_RACE_DWARF && sex == SEX_FEMALE )
+           return true;
+         break;
+    }
+  }
+  return false;
 }
 //----- (0043ED6F) --------------------------------------------------------
 bool _43ED6F_check_party_races(bool a1)
--- a/Player.h	Sat Sep 14 22:43:45 2013 +0100
+++ b/Player.h	Sun Sep 15 02:21:26 2013 +0200
@@ -595,6 +595,8 @@
   void PlaySoundBasedOnCondition(int currPlayerId);
   void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId);
   void EquipBody(ITEM_EQUIP_TYPE uEquipType);
+  bool HasUnderwaterSuitEquipped();
+  bool HasItem(unsigned int uItemID, char a3);
 
   unsigned int GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4);
   int CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice);
--- a/UI/UICharacter.cpp	Sat Sep 14 22:43:45 2013 +0100
+++ b/UI/UICharacter.cpp	Sun Sep 15 02:21:26 2013 +0200
@@ -1698,7 +1698,7 @@
   uTextureID_detaliz_close_button = uExitCancelTextureId;
   for ( uint i = 0; i < 4; ++i )
   {
-    if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(i + 1) )
+    if ( pPlayers[i + 1]->HasUnderwaterSuitEquipped() )
     {
       if ( pPlayers[i + 1]->GetRace() == CHARACTER_RACE_DWARF )
         v3 = (pPlayers[i + 1]->GetSexByVoice() != 0) + 3;
@@ -1757,7 +1757,7 @@
     {
       for ( uint j = 0; j < 4; ++j)
       {
-        if ( Player_has_item(i + 66, &pParty->pPlayers[j], 0) )
+        if ( pParty->pPlayers[j].HasItem(i + 66, 0) )
           party_has_equipment[i] = 1;
       }
     }
@@ -1767,23 +1767,23 @@
   {
     auto player = pParty->pPlayers + i;
 
-    if (Player_has_item(ITEM_ARTICACT_GOVERNONS_ARMOR, player, 1))    byte_5111F6[0] = 1;
-    if (Player_has_item(ITEM_ARTIFACT_YORUBA, player, 1))             byte_5111F6[1] = 1;
-    if (Player_has_item(ITEM_RELIC_HARECS_LEATHER, player, 1))        byte_5111F6[2] = 1;
-    if (Player_has_item(ITEM_ARTIFACT_LEAGUE_BOOTS, player, 1))       byte_5111F6[3] = 1;
-    if (Player_has_item(ITEM_RELIC_TALEDONS_HELM, player, 1))         byte_5111F6[4] = 1;
-    if (Player_has_item(ITEM_RELIC_SCHOLARS_CAP, player, 1))          byte_5111F6[5] = 1;
-    if (Player_has_item(ITEM_RELIC_PHYNAXIAN_CROWN, player, 1))       byte_5111F6[6] = 1;
-    if (Player_has_item(ITEM_ARTIFACT_MINDS_EYE, player, 1))          byte_5111F6[7] = 1;
-    if (Player_has_item(ITEM_RARE_SHADOWS_MASK, player, 1))           byte_5111F6[8] = 1;
-    if (Player_has_item(ITEM_RILIC_TITANS_BELT, player, 1))           byte_5111F6[9] = 1;
-    if (Player_has_item(ITEM_ARTIFACT_HEROS_BELT, player, 1))         byte_5111F6[10] = 1;
-    if (Player_has_item(ITEM_RELIC_TWILIGHT, player, 1))              byte_5111F6[11] = 1;
-    if (Player_has_item(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, player, 1)) byte_5111F6[12] = 1;
-    if (Player_has_item(ITEM_RARE_SUN_CLOAK, player, 1))              byte_5111F6[13] = 1;
-    if (Player_has_item(ITEM_RARE_MOON_CLOAK, player, 1))             byte_5111F6[14] = 1;
-    if (Player_has_item(ITEM_RARE_VAMPIRES_CAPE, player, 1))          byte_5111F6[15] = 1;
-    if (Player_has_item(ITEM_ELVEN_CHAINMAIL, player, 1))             byte_5111F6[16] = 1;
+    if (player->HasItem(ITEM_ARTICACT_GOVERNONS_ARMOR, 1))    byte_5111F6[0] = 1;
+    if (player->HasItem(ITEM_ARTIFACT_YORUBA, 1))             byte_5111F6[1] = 1;
+    if (player->HasItem(ITEM_RELIC_HARECS_LEATHER, 1))        byte_5111F6[2] = 1;
+    if (player->HasItem(ITEM_ARTIFACT_LEAGUE_BOOTS, 1))       byte_5111F6[3] = 1;
+    if (player->HasItem(ITEM_RELIC_TALEDONS_HELM, 1))         byte_5111F6[4] = 1;
+    if (player->HasItem(ITEM_RELIC_SCHOLARS_CAP, 1))          byte_5111F6[5] = 1;
+    if (player->HasItem(ITEM_RELIC_PHYNAXIAN_CROWN, 1))       byte_5111F6[6] = 1;
+    if (player->HasItem(ITEM_ARTIFACT_MINDS_EYE, 1))          byte_5111F6[7] = 1;
+    if (player->HasItem(ITEM_RARE_SHADOWS_MASK, 1))           byte_5111F6[8] = 1;
+    if (player->HasItem(ITEM_RILIC_TITANS_BELT, 1))           byte_5111F6[9] = 1;
+    if (player->HasItem(ITEM_ARTIFACT_HEROS_BELT, 1))         byte_5111F6[10] = 1;
+    if (player->HasItem(ITEM_RELIC_TWILIGHT, 1))              byte_5111F6[11] = 1;
+    if (player->HasItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, 1)) byte_5111F6[12] = 1;
+    if (player->HasItem(ITEM_RARE_SUN_CLOAK, 1))              byte_5111F6[13] = 1;
+    if (player->HasItem(ITEM_RARE_MOON_CLOAK, 1))             byte_5111F6[14] = 1;
+    if (player->HasItem(ITEM_RARE_VAMPIRES_CAPE, 1))          byte_5111F6[15] = 1;
+    if (player->HasItem(ITEM_ELVEN_CHAINMAIL, 1))             byte_5111F6[16] = 1;
   }
 
   for (uint i = 0; i < 2; ++i)
@@ -1816,7 +1816,7 @@
   //v43 = 0;
   for (uint i = 0; i < 4; ++i)
   {
-    if ( sub_43EDB9_get_some_race_sex_relation_2(i) )
+    if ( ShouldLoadTexturesForRaceAndGender(i) )
     {
       GetItemTextureFilename(pContainer, 524, i + 1, 0);
       paperdoll_belt_texture[i][5] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Titans belt
@@ -2404,7 +2404,7 @@
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
-        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (pEquipType != EQUIP_ARMOUR || bUnderwater) )
+        if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() && (pEquipType != EQUIP_ARMOUR || bUnderwater) )
         {
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
           return;
@@ -2415,7 +2415,7 @@
         return;
 //------------------------dress rings(одевание колец)----------------------------------
       case EQUIP_RING:
-        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
+        if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() )
         {
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
           return;
@@ -2452,7 +2452,7 @@
         return;
 //------------------dress shield(одеть щит)------------------------------------------------------
       case EQUIP_SHIELD://Щит
-        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )//в акваланге
+        if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() )//в акваланге
         {
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
           return;
@@ -2503,7 +2503,7 @@
 //-------------------------taken in hand(взять в руку)-------------------------------------------
       case EQUIP_OFF_HAND:
       case EQUIP_WAND:
-        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter)
+        if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped()
           && pParty->pPickedItem.uItemID != 64
           && pParty->pPickedItem.uItemID != 65 )
         {
@@ -2607,7 +2607,7 @@
         break;
 //---------------------------take two hands(взять двумя руками)---------------------------------
       case EQUIP_MAIN_HAND:
-        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
+        if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() )
         {
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
           return;
--- a/mm7_4.cpp	Sat Sep 14 22:43:45 2013 +0100
+++ b/mm7_4.cpp	Sun Sep 15 02:21:26 2013 +0200
@@ -1079,7 +1079,7 @@
       else
       {
         //v58 = 0;
-        if ( !sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v12) )
+        if ( !pPlayers[v12]->HasUnderwaterSuitEquipped() )
         {
           //v14 = pPlayers[v12];
           //v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1;
--- a/mm7_data.h	Sat Sep 14 22:43:45 2013 +0100
+++ b/mm7_data.h	Sun Sep 15 02:21:26 2013 +0200
@@ -1143,9 +1143,7 @@
 void CharacterUI_LoadPaperdollTextures();
 int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder);
 bool _43ED6F_check_party_races(bool b);
-bool  sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this);
-bool __fastcall Player_has_item(unsigned int uItemID, struct Player *pPlayer, char a3);
-bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1);
+bool  ShouldLoadTexturesForRaceAndGender(unsigned int _this);
 void WetsuitOn(unsigned int uPlayerID); // idb
 void WetsuitOff(unsigned int uPlayerID);
 void __fastcall PrepareDrawLists_BLV(struct IndoorLocation_drawstru *_this);