diff Player.cpp @ 510:7c86030324a5

Слияние
author Ritor1
date Fri, 01 Mar 2013 18:38:12 +0600
parents 00ce82758c72 6fa3ff8ef729
children 663c4f618f56
line wrap: on
line diff
--- a/Player.cpp	Fri Mar 01 18:37:54 2013 +0600
+++ b/Player.cpp	Fri Mar 01 18:38:12 2013 +0600
@@ -189,21 +189,14 @@
 //----- (00427730) --------------------------------------------------------
 bool Player::CanCastSpell(unsigned int uRequiredMana)
 {
-  int v2; // eax@1
-  bool result; // eax@2
-
-  v2 = this->sMana;
-  if ( v2 >= (signed int)uRequiredMana )
-  {
-    this->sMana = v2 - uRequiredMana;
-    result = 1;
-  }
-  else
-  {
-    pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-    result = 0;
-  }
-  return result;
+  if (sMana >= uRequiredMana)
+  {
+    sMana -= uRequiredMana;
+    return true;
+  }
+
+  pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+  return false;
 }
 
 
@@ -1751,7 +1744,6 @@
   unsigned int uSlota; // [sp+14h] [bp+4h]@1
 
   pIndices = &this->pInventoryIndices[uSlot];
-
   v3 = &this->pInventoryItems[*pIndices-1];
   v4 = v3->uItemID;
   v3->Reset();
@@ -4150,7 +4142,7 @@
     v9 = *(int *)v8;
     v3 = (char *)&pItemsTable->pItems[v9].pIconName;
     if ( v3[28] == 12 )
-      v10 = *(&pSpellDatas[0].field_A + 10 * *((int *)&pSpellDatas[66].field_8 + v9));
+      v10 = *(&pSpellDatas[0].uExpertLevelRecovery + 10 * *((int *)&pSpellDatas[66].uNormalLevelRecovery + v9));
     else
       v10 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]];
     v47 = v10;
@@ -6498,7 +6490,11 @@
 
     switch (i)
     {
-      case PLAYER_SKILL_FIRE:   spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;   break;
+      case PLAYER_SKILL_FIRE:   spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;
+        spellbook.pFireSpellbook.bIsSpellAvailable[1] = true;
+        spellbook.pFireSpellbook.bIsSpellAvailable[2] = true;
+        spellbook.pFireSpellbook.bIsSpellAvailable[3] = true;
+        break;
       case PLAYER_SKILL_AIR:    spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;    break;
       case PLAYER_SKILL_WATER:  spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;  break;
       case PLAYER_SKILL_EARTH:  spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;  break;
@@ -8201,9 +8197,9 @@
 
 
 //----- (0044A5CB) --------------------------------------------------------
-void Player::SetVariable(enum VariableType var, signed int a3)
-{
-  signed int v3; // ebx@1
+void Player::SetVariable(enum VariableType var_type, signed int var_value)
+{
+  signed int currPlayerId; // ebx@1
   Player *v4; // esi@1
   unsigned int v5; // edi@1
   unsigned int v6; // esi@13
@@ -8233,125 +8229,114 @@
   char v30; // [sp+32h] [bp-2h]@1
   char v31; // [sp+33h] [bp-1h]@1
 
-  v3 = 0;
+  currPlayerId = 0;
   v30 = 0;
   v31 = 0;
   v4 = this;
   v5 = 0;
   if ( this == pPlayers[2] )
-  {
-    v3 = 1;
-    goto LABEL_8;
-  }
-  if ( this == pPlayers[3] )
-  {
-    v27 = 2;
-  }
-  else
-  {
-    if ( this != pPlayers[4] )
-      goto LABEL_8;
-    v27 = 3;
-  }
-  v3 = v27;
-LABEL_8:
-  if ( var > VAR_AutoNotes )
-  {
-    if ( var <= VAR_GoldInBank )
-    {
-      if ( var == VAR_GoldInBank )
-      {
-        pParty->uNumGoldInBank = a3;
+    currPlayerId = 1;
+  else if ( this == pPlayers[3] )
+    currPlayerId = 2;
+  else if ( this == pPlayers[4] );
+     currPlayerId  = 3;
+  if ( var_type > VAR_AutoNotes )
+  {
+    if ( var_type <= VAR_GoldInBank )
+    {
+      if ( var_type == VAR_GoldInBank )
+      {
+        pParty->uNumGoldInBank = var_value;
         return;
       }
-      if ( var <= VAR_Counter8 )
-      {
-        if ( (signed int)var >= 0xF5 )
+      if ( var_type <= VAR_Counter8 )
+      {
+        if ( (signed int)var_type >= 0xF5 )
         {
-          *(int *)&stru_AA1058[3].pSounds[8 * var + 44300] = LODWORD(pParty->uTimePlayed);
-          *(int *)&stru_AA1058[3].pSounds[8 * var + 44304] = HIDWORD(pParty->uTimePlayed);
+          *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed);
+          *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed);
         }
         else
         {
-          switch ( var )
+          switch ( var_type )
           {
             case VAR_MonthEquals|VAR_CurrentSP:
-              _449B7E_toggle_bit((unsigned char *)field_1A50, a3, 1u);
+              _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u);
               break;
             case VAR_NPCs2:
               pParty->field_709 = 0;
-              LOBYTE(pNPCStats->pNewNPCData[a3].uFlags) |= 0x80u;
+              LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u;
               sub_44A56A();
               viewparams->bRedrawGameUI = 1;
               break;
             case VAR_NumSkillPoints:
-              this->uSkillPoints = a3;
+              this->uSkillPoints = var_value;
               break;
           }
         }
         return;
       }
-      if ( var < VAR_Counter9 )
+      if ( var_type < VAR_Counter9 )
         return;
-      if ( (signed int)var <= 0x112 )
-      {
-        *(int *)&stru_AA1058[3].pSounds[8 * var + 44532] = LODWORD(pParty->uTimePlayed);
-        *(int *)&stru_AA1058[3].pSounds[8 * var + 44536] = HIDWORD(pParty->uTimePlayed);
+      if ( (signed int)var_type <= 0x112 )
+      {
+        *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed);
+        *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed);
       }
       else
       {
-        if ( var == VAR_ReputationInCurrentLocation )
+        if ( var_type == VAR_ReputationInCurrentLocation )
         {
           v24 = &pOutdoor->ddm;
           if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
             v24 = &pIndoor->dlv;
-          v24->uReputation = a3;
-          if ( a3 > 10000 )
+          v24->uReputation = var_value;
+          if ( var_value > 10000 )
             v24->uReputation = 10000;
           return;
         }
-        if ( var <= VAR_ReputationInCurrentLocation
-          || var > VAR_History_28
-          || (v22 = var - 276, pParty->field_3C.field_4F0[2 * v22 + 1] | pParty->field_3C.field_4F0[2 * v22])
-          || (pParty->field_3C.field_4F0[2 * (var - 276)] = LODWORD(pParty->uTimePlayed),
+        if ( var_type <= VAR_ReputationInCurrentLocation
+          || var_type > VAR_History_28
+          || (v22 = var_type - 276, pParty->field_3C.field_4F0[2 * v22 + 1] | pParty->field_3C.field_4F0[2 * v22])
+          || (pParty->field_3C.field_4F0[2 * (var_type - 276)] = LODWORD(pParty->uTimePlayed),
               v23 = pStorylineText->StoreLine[v22].pText==0,//*(&pStorylineText->field_0 + 3 * v22) == 0,
-              pParty->field_3C.field_4F0[2 * (var - 276) + 1] = HIDWORD(pParty->uTimePlayed),
+              pParty->field_3C.field_4F0[2 * (var_type - 276) + 1] = HIDWORD(pParty->uTimePlayed),
               v23) )
           return;
         bFlashHistoryBook = 1;
       }
 LABEL_172:
-      v25 = 8 * v3 + 400;
-      LOBYTE(v25) = (8 * v3 - 112) | 4;
+      v25 = 8 * currPlayerId + 400;
+      LOBYTE(v25) = (8 * currPlayerId - 112) | 4;
       pAudioPlayer->PlaySound(SOUND_20001, v25, v5, -1, v5, v5, v5, v5);
       return;
     }
-    if ( var != 307 )
-    {
-      switch ( var )
+    if ( var_type != 307 )
+    {
+      switch ( var_type )
       {
         case 308:
-          pParty->uNumBountiesCollected = a3;
+          pParty->uNumBountiesCollected = var_value;
           break;
         case 309:
-          pParty->uNumPrisonTerms = a3;
+          pParty->uNumPrisonTerms = var_value;
           break;
         case 310:
-          pParty->uNumArenaPageWins = a3;
+          pParty->uNumArenaPageWins = var_value;
           break;
         case 311:
-          pParty->uNumArenaSquireWins = a3;
+          pParty->uNumArenaSquireWins = var_value;
           break;
         case 312:
-          pParty->uNumArenaKnightWins = a3;
+          pParty->uNumArenaKnightWins = var_value;
           break;
         case 313:
-          pParty->uNumArenaLordWins = a3;
+          pParty->uNumArenaLordWins = var_value;
           break;
       }
       return;
     }
-    pParty->uNumDeaths = a3;
+    pParty->uNumDeaths = var_value;
 LABEL_168:
     if ( v30 != 1 )
     {
@@ -8362,101 +8347,101 @@
       goto LABEL_172;
     }
 LABEL_169:
-    pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, v3);
+    pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
     goto LABEL_170;
   }
-  if ( var == VAR_AutoNotes )
-  {
-    if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pParty->_autonote_bits[((signed __int16)a3 - 1) >> 3])
+  if ( var_type == VAR_AutoNotes )
+  {
+    if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3])
       //&& (&dword_723718_autonote_related)[8 * a3] )
-	  && pAutonoteTxt[a3-1].pText )
-    {
-      v20 = pPlayers[v3 + 1];
+	  && pAutonoteTxt[var_value-1].pText )
+    {
+      v20 = pPlayers[currPlayerId + 1];
       v30 = 1;
       v20->PlaySound(SPEECH_96, 0);
-	  v21 = pAutonoteTxt[a3-1].eType;// dword_72371C[2 * a3];
+	  v21 = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3];
       bFlashAutonotesBook = 1;
       dword_506568 = v21;
     }
-    _449B7E_toggle_bit(pParty->_autonote_bits, a3, 1u);
+    _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u);
     v31 = 1;
     goto LABEL_168;
   }
-  if ( var <= VAR_ActualMight )
-  {
-    if ( var != VAR_ActualMight )
-    {
-      switch ( var )
+  if ( var_type <= VAR_ActualMight )
+  {
+    if ( var_type != VAR_ActualMight )
+    {
+      switch ( var_type )
       {
         case VAR_RandomGold:
-          v6 = rand() % a3 + 1;
+          v6 = rand() % var_value + 1;
           Party::SetGold(v6);
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold
           ShowStatusBarString(pTmpBuf, 2u);
           GameUI_DrawFoodAndGold();
           return;
         case VAR_RandomFood:
-          v7 = rand() % a3 + 1;
+          v7 = rand() % var_value + 1;
           Party::SetFood(v7);
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food
           ShowStatusBarString(pTmpBuf, 2u);
           GameUI_DrawFoodAndGold();
           goto LABEL_124;
         case VAR_Sex:
-          this->uSex = (PLAYER_SEX)a3;
+          this->uSex = (PLAYER_SEX)var_value;
           goto LABEL_124;
         case VAR_Class:
-          this->classType = (PLAYER_CLASS_TYPE)a3;
-          if ( (char)a3 != 35 )
+          this->classType = (PLAYER_CLASS_TYPE)var_value;
+          if ( (char)var_value != 35 )
             goto LABEL_124;
           v8 = 0;
           v9 = this->pInventoryItems;
           break;
         case VAR_CurrentHP:
-          this->sHealth = a3;
+          this->sHealth = var_value;
           goto LABEL_124;
         case VAR_MaxHP:
           this->sHealth = GetMaxHealth();
           return;
         case VAR_CurrentSP:
-          this->sMana = a3;
+          this->sMana = var_value;
           goto LABEL_124;
         case VAR_MaxSP:
           this->sMana = GetMaxMana();
           return;
         case VAR_ACModifier:
-          this->sACModifier = (unsigned __int8)a3;
+          this->sACModifier = (unsigned __int8)var_value;
           goto LABEL_124;
         case VAR_BaseLevel:
-          this->uLevel = (unsigned __int8)a3;
+          this->uLevel = (unsigned __int8)var_value;
           goto LABEL_124;
         case VAR_LevelModifier:
-          this->sLevelModifier = (unsigned __int8)a3;
+          this->sLevelModifier = (unsigned __int8)var_value;
           goto LABEL_124;
         case VAR_Age:
-          this->sAgeModifier = a3;
+          this->sAgeModifier = var_value;
           return;
         case VAR_Award:
-          if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pPlayers[v3 + 1]->_guilds_member_bits[((signed __int16)a3 - 1) >> 3])
+          if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & 
+			  pPlayers[currPlayerId + 1]->_guilds_member_bits[((signed __int16)var_value - 1)/ 8])
             //&& dword_723E80_award_related[2 * a3] )
-			&& pAwards[a3-1].pText )
+			&& pAwards[var_value].pText )
           {
-            v12 = pPlayers[v3 + 1];
             v30 = 1;
             v31 = 1;
-            v12->PlaySound(SPEECH_96, 0);
+            pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0);
           }
-          v13 = v4->_guilds_member_bits;
-          goto LABEL_51;
+		  _449B7E_toggle_bit((unsigned char *)v4->_guilds_member_bits, var_value, 1u);
+          goto LABEL_168;
         case VAR_Experience:
-          this->uExperience = a3;
+          this->uExperience = var_value;
           goto LABEL_124;
         case VAR_QBits_QuestsDone:
-          if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pParty->_quest_bits[((signed __int16)a3 - 1) >> 3])
+          if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3])
            // && (&dword_722F10)[4 * a3] )
-		   && pQuestTable[a3-1] )
+		   && pQuestTable[var_value-1] )
           {
-            v14 = pPlayers[v3 + 1];
+            v14 = pPlayers[currPlayerId + 1];
             bFlashQuestBook = 1;
             v30 = 1;
             v31 = 1;
@@ -8464,43 +8449,52 @@
           }
           v13 = (char *)pParty->_quest_bits;
 LABEL_51:
-          _449B7E_toggle_bit((unsigned char *)v13, a3, 1u);
-          goto LABEL_168;
+          _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u);
+		  if (( v30 != 1 )&&( v31 != 1 ))
+				  return;
+		  else
+			  pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
+		  if ( v31 != 1 )
+			  return;
+		  v25 = 8 * currPlayerId + 400;
+		  LOBYTE(v25) = (8 * currPlayerId - 112) | 4;
+		  pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
+		  return;
         case VAR_PlayerItemInHands:
           item.Reset();
           item.Reset();
-          item.uItemID = a3;
+          item.uItemID = var_value;
           item.uAttributes = 1;
           pParty->SetHoldingItem(&item);
-          if ( a3 >= ITEM_ARTIFACT_PUCK && a3 <= ITEM_RELIC_MEKORIGS_HAMMER )
-            pParty->pIsArtifactFound[a3-500] = 1;
+          if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER )
+            pParty->pIsArtifactFound[var_value-500] = 1;
           return;
         case VAR_FixedGold:
-          Party::SetGold(a3);
+          Party::SetGold(var_value);
           return;
         case VAR_BaseMight:
-          this->uMight = (unsigned __int8)a3;
+          this->uMight = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_BaseIntellect:
-          this->uIntelligence = (unsigned __int8)a3;
+          this->uIntelligence = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_BasePersonality:
-          this->uWillpower = (unsigned __int8)a3;
+          this->uWillpower = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_BaseEndurance:
-          this->uEndurance = (unsigned __int8)a3;
+          this->uEndurance = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_BaseSpeed:
-          this->uSpeed = (unsigned __int8)a3;
+          this->uSpeed = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_BaseAccuracy:
-          this->uAccuracy = (unsigned __int8)a3;
+          this->uAccuracy = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_BaseLuck:
-          this->uLuck = (unsigned __int8)a3;
+          this->uLuck = (unsigned __int8)var_value;
           goto LABEL_84;
         case VAR_FixedFood:
-          Party::SetFood(a3);
+          Party::SetFood(var_value);
           goto LABEL_124;
         case VAR_MightBonus:
           goto LABEL_64;
@@ -8528,7 +8522,7 @@
       }
       v10 = (int)((char *)v4 + 36 * v8);
       *(int *)(v10 + 532) = 601;
-      *(char *)(v10 + 558) = v3 + 1;
+      *(char *)(v10 + 558) = currPlayerId + 1;
 LABEL_22:
       if ( v4->sResFireBase < 20 )
         v4->sResFireBase = 20;
@@ -8553,82 +8547,82 @@
         v4->uFace = 20;
         v4->uVoiceID = 20;
       }
-      ReloadPlayerPortraits(v3, v4->uFace);
+      ReloadPlayerPortraits(currPlayerId, v4->uFace);
       goto LABEL_124;
     }
 LABEL_64:
-    this->uMightBonus = (unsigned __int8)a3;
+    this->uMightBonus = (unsigned __int8)var_value;
 LABEL_111:
     v28 = 0;
     v26 = SPEECH_91;
 LABEL_112:
-    v19 = pPlayers[v3 + 1];
+    v19 = pPlayers[currPlayerId + 1];
     v31 = 1;
     v19->PlaySound((PlayerSpeech)v26, v28);
     goto LABEL_169;
   }
-  if ( var <= VAR_FireResistanceBonus )
-  {
-    if ( var == VAR_FireResistanceBonus )
-    {
-      this->sResFireBonus = (unsigned __int8)a3;
+  if ( var_type <= VAR_FireResistanceBonus )
+  {
+    if ( var_type == VAR_FireResistanceBonus )
+    {
+      this->sResFireBonus = (unsigned __int8)var_value;
       goto LABEL_111;
     }
-    switch ( var )
+    switch ( var_type )
     {
       case VAR_ActualIntellect:
 LABEL_68:
-        this->uIntelligenceBonus = (unsigned __int8)a3;
+        this->uIntelligenceBonus = (unsigned __int8)var_value;
         goto LABEL_111;
       case VAR_ActualPersonality:
 LABEL_69:
-        this->uWillpowerBonus = (unsigned __int8)a3;
+        this->uWillpowerBonus = (unsigned __int8)var_value;
         goto LABEL_111;
       case VAR_ActualEndurance:
 LABEL_70:
-        this->uEnduranceBonus = (unsigned __int8)a3;
+        this->uEnduranceBonus = (unsigned __int8)var_value;
         goto LABEL_111;
       case VAR_ActualSpeed:
 LABEL_71:
-        this->uSpeedBonus = (unsigned __int8)a3;
+        this->uSpeedBonus = (unsigned __int8)var_value;
         goto LABEL_111;
       case VAR_ActualAccuracy:
 LABEL_72:
-        this->uAccuracyBonus = (unsigned __int8)a3;
+        this->uAccuracyBonus = (unsigned __int8)var_value;
         goto LABEL_111;
       case VAR_ActualLuck:
 LABEL_73:
-        this->uLuckBonus = (unsigned __int8)a3;
+        this->uLuckBonus = (unsigned __int8)var_value;
         goto LABEL_111;
       case VAR_FireResistance:
-        this->sResFireBase = (unsigned __int8)a3;
+        this->sResFireBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_AirResistance:
-        this->sResAirBase = (unsigned __int8)a3;
+        this->sResAirBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_WaterResistance:
-        this->sResWaterBase = (unsigned __int8)a3;
+        this->sResWaterBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_EarthResistance:
-        this->sResEarthBase = (unsigned __int8)a3;
+        this->sResEarthBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_SpiritResistance:
-        this->sResSpiritBase = (unsigned __int8)a3;
+        this->sResSpiritBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_MindResistance:
-        this->sResMindBase = (unsigned __int8)a3;
+        this->sResMindBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_BodyResistance:
-        this->sResBodyBase = (unsigned __int8)a3;
+        this->sResBodyBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_LightResistance:
-        this->sResLightBase = (unsigned __int8)a3;
+        this->sResLightBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_DarkResistance:
-        this->sResDarkBase = (unsigned __int8)a3;
+        this->sResDarkBase = (unsigned __int8)var_value;
         goto LABEL_84;
       case VAR_MagicResistance:
-        this->sResMagicBase = (unsigned __int8)a3;
+        this->sResMagicBase = (unsigned __int8)var_value;
 LABEL_84:
         v28 = 0;
         v26 = 92;
@@ -8639,22 +8633,22 @@
     return;
   }
   HIWORD(v15) = 0;
-  if ( var > VAR_DisarmTrapSkill )
-  {
-    if ( var != VAR_LearningSkill )
-    {
-      if ( var <= VAR_LearningSkill )
+  if ( var_type > VAR_DisarmTrapSkill )
+  {
+    if ( var_type != VAR_LearningSkill )
+    {
+      if ( var_type <= VAR_LearningSkill )
         return;
-      if ( var <= VAR_Eradicated )
-      {
-        v4->SetCondition(var - 105, 1);
+      if ( var_type <= VAR_Eradicated )
+      {
+        v4->SetCondition(var_type - 105, 1);
       }
       else
       {
-        if ( var != VAR_MajorCondition )
+        if ( var_type != VAR_MajorCondition )
         {
-          if ( var > VAR_MajorCondition && var <= VAR_ActiveSpells )
-            byte_5E4C15[var] = a3;
+          if ( var_type > VAR_MajorCondition && var_type <= VAR_ActiveSpells )
+            byte_5E4C15[var_type] = var_value;
           return;
         }
         memset(v4, 0, 0xA0u);
@@ -8664,66 +8658,85 @@
       goto LABEL_169;
     }
 LABEL_106:
-    v16 = (int)((char *)&v4->pConditions[16] + 2 * var);
+    v16 = (int)((char *)&v4->pConditions[16] + 2 * var_type);
     v17 = *(char *)v16;
-    if ( a3 <= VAR_BodyResistanceBonus )
-    {
-      LOWORD(v15) = (unsigned __int8)a3;
+    if ( var_value <= VAR_BodyResistanceBonus )
+    {
+      LOWORD(v15) = (unsigned __int8)var_value;
       v18 = v15 | v17 & VAR_BodyResistanceBonus;
     }
     else
     {
-      LOWORD(v18) = (unsigned __int8)(a3 | v17 & 0xC0);
+      LOWORD(v18) = (unsigned __int8)(var_value | v17 & 0xC0);
     }
     *(short *)v16 = v18;
     goto LABEL_124;
   }
-  if ( var == VAR_DisarmTrapSkill )
-    goto LABEL_106;
-  if ( var <= VAR_BodyResistanceBonus )
-  {
-    switch ( var )
+  if ( var_type == VAR_DisarmTrapSkill )
+	  if ( v30 != 1 )
+		  {
+		  if ( v31 != 1 )
+			  return;
+		  v5 = 0;
+		  goto LABEL_172;
+		  }
+	  pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
+	  goto LABEL_170;
+  if ( var_type <= VAR_BodyResistanceBonus )
+  {
+    switch ( var_type )
     {
       case VAR_BodyResistanceBonus:
-        v4->sResBodyBonus = (unsigned __int8)a3;
+        v4->sResBodyBonus = (unsigned __int8)var_value;
         break;
       case VAR_AirResistanceBonus:
-        v4->sResAirBonus = (unsigned __int8)a3;
+        v4->sResAirBonus = (unsigned __int8)var_value;
         break;
       case VAR_WaterResistanceBonus:
-        v4->sResWaterBonus = (unsigned __int8)a3;
+        v4->sResWaterBonus = (unsigned __int8)var_value;
         break;
       case VAR_EarthResistanceBonus:
-        v4->sResEarthBonus = (unsigned __int8)a3;
+        v4->sResEarthBonus = (unsigned __int8)var_value;
         break;
       case VAR_SpiritResistanceBonus:
-        v4->sResSpiritBonus = (unsigned __int8)a3;
+        v4->sResSpiritBonus = (unsigned __int8)var_value;
         break;
       default:
-        if ( var != 62 )
+        if ( var_type != 62 )
           return;
-        v4->sResMindBonus = (unsigned __int8)a3;
+        v4->sResMindBonus = (unsigned __int8)var_value;
         break;
     }
     goto LABEL_111;
   }
-  if ( var == VAR_LightResistanceBonus )
-  {
-    v4->sResLightBonus = (unsigned __int8)a3;
+  if ( var_type == VAR_LightResistanceBonus )
+  {
+    v4->sResLightBonus = (unsigned __int8)var_value;
     goto LABEL_111;
   }
-  if ( var == VAR_DarkResistanceBonus )
-  {
-    v4->sResDarkBonus = (unsigned __int8)a3;
+  if ( var_type == VAR_DarkResistanceBonus )
+  {
+    v4->sResDarkBonus = (unsigned __int8)var_value;
+    goto LABEL_111;
+  }
+  if ( var_type == VAR_MagicResistanceBonus )
+  {
+    v4->sResMagicBonus = (unsigned __int8)var_value;
     goto LABEL_111;
   }
-  if ( var == VAR_MagicResistanceBonus )
-  {
-    v4->sResMagicBonus = (unsigned __int8)a3;
-    goto LABEL_111;
-  }
-  if ( var > VAR_MagicResistanceBonus && var <= VAR_DiplomacySkill )
-    goto LABEL_106;
+  if ( var_type > VAR_MagicResistanceBonus && var_type <= VAR_DiplomacySkill )
+	  if ( v30 != 1 )
+		  {
+		  if ( v31 != 1 )
+			  return;
+		  v5 = 0;
+		  v25 = 8 * currPlayerId + 400;
+		  LOBYTE(v25) = (8 * currPlayerId - 112) | 4;
+		  pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
+		  return;
+		  }
+	  pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
+	  goto LABEL_170;
 }
 
 
@@ -8858,7 +8871,7 @@
               v33 = 0x80u >> ((signed __int16)val - 1) % 8;
               if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & v13->_guilds_member_bits[((signed __int16)val - 1) >> 3])
                 //&& dword_723E80_award_related[2 * val] )
-				&& pAwards[val-1].pText )
+				&& pAwards[val].pText )
               {
                 v14 = pPlayers[uPlayerIdx + 1];
                 v34 = 1;
@@ -8879,11 +8892,11 @@
                 //&& (&dword_722F10)[4 * val] )
 				&& pQuestTable[val-1] )
               {
-                v17 = pPlayers[uPlayerIdx + 1];
+                //v17 = pPlayers[uPlayerIdx + 1];
                 bFlashQuestBook = 1;
                 v34 = 1;
                 v3 = 1;
-                v17->PlaySound(SPEECH_93, 0);
+                pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_93, 0);
               }
               v15 = (char *)pParty->_quest_bits;
 LABEL_44:
@@ -9265,11 +9278,11 @@
 
 
 //----- (0044B9C4) --------------------------------------------------------
-void Player::SubtractVariable(enum VariableType var, void *a3)
+bool Player::SubtractVariable(enum VariableType VarNum, signed int pValue)
 {
   unsigned int v3; // ebx@1
   signed int v4; // esi@1
-  enum VariableType v5; // eax@8
+  bool result; // eax@8
   int v6; // esi@11
   int v7; // edi@14
   signed int v8; // eax@17
@@ -9279,10 +9292,10 @@
   char *v12; // ecx@27
   __int64 v13; // qax@27
   unsigned __int8 v14; // cf@27
-  char *v15; // edx@29
+  int *v15; // edx@29
   char *v16; // eax@90
   char *v17; // ecx@94
-  void *v18; // esi@97
+  int v18; // esi@97
   signed int v19; // edx@97
   char *v20; // ecx@98
   int v21; // eax@100
@@ -9310,52 +9323,53 @@
   }
   v4 = v24;
 LABEL_8:
-  v5 = var;
-  if ( (signed int)var > 222 )
-  {
-    if ( (signed int)var <= 307 )
-    {
-      if ( var == 307 )
-      {
-        pParty->uNumDeaths -= (unsigned int)a3;
-        return;
-      }
-      if ( var == 223 )
+  result = false;
+  if ( (signed int)VarNum > 222 )
+  {
+    if ( (signed int)VarNum <= 307 )
+    {
+      if ( VarNum == 307 )
+      {
+        pParty->uNumDeaths -= (unsigned int)pValue;
+        return pValue;
+      }
+      if ( VarNum == 223 )
       {
         v11 = (char *)pParty->_autonote_bits;
-        v22 = (short)a3 - 1;
+        v22 = (short)pValue - 1;
       }
       else
       {
-        if ( var != 231 )
+        if ( VarNum != 231 )
         {
-          switch ( var )
+          switch ( VarNum )
           {
             case 232:
-              var = (VariableType)0;
-              GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&var);
-              dword_5B65CC = 0;
-              if ( (void *)var == a3 )
+              VarNum = (VariableType)0;
+              GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&VarNum);
+              result = (bool) pValue;
+			  dword_5B65CC = 0;
+              if ( (int)VarNum == pValue )
               {
-                dword_5B65CC = (int)a3;
+                dword_5B65CC = (int)pValue;
               }
               else
               {
                 pParty->field_709 = 0;
-                LOBYTE(pNPCStats->pNewNPCData[(int)a3].uFlags) &= 0x7Fu;
+                LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu;
                 sub_44A56A();
                 viewparams->bRedrawGameUI = 1;
               }
               break;
             case 241:
-              v18 = a3;
+              v18 = pValue;
               v19 = 0;
               if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
               {
                 v20 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
                 do
                 {
-                  if ( *((void **)v20 + 4) == v18 )
+                  if ( *((void **)v20 + 4) == (void *)v18 )
                   {
                     v21 = *(int *)v20;
                     if ( (char)*(int *)v20 < 0 )
@@ -9369,17 +9383,21 @@
                 }
                 while ( v19 < (signed int)pNPCStats->uNumNewNPCs );
               }
-              if ( (void *)pParty->pHirelings[0].uProfession == v18 )
+              if ( pParty->pHirelings[0].uProfession == v18 )
                 memset(pParty->pHirelings, 0, 0x4Cu);
-              if ( (void *)pParty->pHirelings[1].uProfession == v18 )
+              if ( pParty->pHirelings[1].uProfession == v18 )
                 memset(&pParty->pHirelings[1], 0, 0x4Cu);
               pParty->field_709 = 0;
               sub_44A56A();
               break;
             case 243:
               v17 = (char *)&this->uSkillPoints;
-              if ( (unsigned int)a3 <= *(int *)v17 )
-                *(int *)v17 -= (int)a3;
+			  result = *v17;
+              if ( (unsigned int)pValue <= *(int *)v17 )
+              {
+					*(int *)v17 -= (int)pValue;
+					result = v17;
+			  }
               else
                 *(int *)v17 = 0;
               break;
@@ -9387,70 +9405,80 @@
               v16 = (char *)&pOutdoor->ddm;
               if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
                 v16 = (char *)&pIndoor->dlv;
-              *((int *)v16 + 2) -= (int)a3;
+              *((int *)v16 + 2) -= (int)pValue;
               if ( *((int *)v16 + 2) < -10000 )
                 *((int *)v16 + 2) = -10000;
               break;
             case 306:
-              if ( (unsigned int)a3 <= pParty->uNumGoldInBank )
-                pParty->uNumGoldInBank -= (unsigned int)a3;
+				result = VarNum - 306;
+              if ( (unsigned int)pValue <= pParty->uNumGoldInBank )
+			  {
+				result = (bool)pValue;
+                pParty->uNumGoldInBank -= (unsigned int)pValue;
+			  }
               else
 LABEL_88:
                 dword_5B65C4 = 1;
               break;
           }
-          return;
+          return result;
         }
         v11 = this->field_1A50;
 LABEL_112:
-        v22 = (signed __int16)a3;
+        v22 = (signed __int16)pValue;
       }
       _449B7E_toggle_bit((unsigned char *)v11, v22, 0);
-      return;
-    }
-    switch ( var )
+      return result;
+    }
+    switch ( VarNum )
     {
       case 308:
-        pParty->uNumBountiesCollected -= (unsigned int)a3;
+		  result = (bool)pValue;
+        pParty->uNumBountiesCollected -= (unsigned int)pValue;
         break;
       case 309:
-        pParty->uNumPrisonTerms -= (int)a3;
+		  result = (bool)pValue;
+        pParty->uNumPrisonTerms -= (int)pValue;
         break;
       case 310:
-        pParty->uNumArenaPageWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaPageWins -= (char)pValue;
         break;
       case 311:
-        pParty->uNumArenaSquireWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaSquireWins -= (char)pValue;
         break;
       case 312:
-        pParty->uNumArenaKnightWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaKnightWins -= (char)pValue;
         break;
       case 313:
-        pParty->uNumArenaLordWins -= (char)a3;
+		  result = (bool)pValue;
+        pParty->uNumArenaLordWins -= (char)pValue;
         break;
     }
   }
   else
   {
-    if ( (signed int)var >= 123 )
-    {
-      byte_5E4C15[var] -= (char)a3;
+    if ( (signed int)VarNum >= 123 )
+    {
+      byte_5E4C15[VarNum] -= (char)pValue;
     }
     else
     {
-      switch ( var )
+      switch ( VarNum )
       {
         case VAR_RandomGold:
-          v6 = rand() % (signed int)a3 + 1;
+          v6 = rand() % (signed int)pValue + 1;
           if ( v6 > pParty->uNumGold )
             v6 = pParty->uNumGold;
           Party::TakeGold(v6);
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[503], v6);
           ShowStatusBarString(pTmpBuf, 2u);
           GameUI_DrawFoodAndGold();
-          return;
+          return result;
         case VAR_RandomFood:
-          v7 = rand() % (signed int)a3 + 1;
+          v7 = rand() % (signed int)pValue + 1;
           if ( v7 > pParty->uNumFoodRations )
             v7 = pParty->uNumFoodRations;
           Party::TakeFood(v7);
@@ -9459,162 +9487,162 @@
           GameUI_DrawFoodAndGold();
           goto LABEL_17;
         default:
-          return;
+          return result;
         case VAR_CurrentHP:
-          ReceiveDamage((signed int)a3, 4);
+          ReceiveDamage((signed int)pValue, 4);
           goto LABEL_17;
         case VAR_CurrentSP:
           v9 = (char *)&this->sMana;
-          v10 = this->sMana - (signed int)a3 < 0;
-          *(int *)v9 -= (int)a3;
+          v10 = this->sMana - (signed int)pValue < 0;
+          *(int *)v9 -= (int)pValue;
           if ( v10 )
             *(int *)v9 = 0;
           goto LABEL_17;
         case VAR_ACModifier:
-          this->sACModifier -= (unsigned __int8)a3;
+          this->sACModifier -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_BaseLevel:
-          this->uLevel -= (unsigned __int8)a3;
+          this->uLevel -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_LevelModifier:
-          this->sLevelModifier -= (unsigned __int8)a3;
+          this->sLevelModifier -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_Age:
-          this->sAgeModifier -= (signed __int16)a3;
-          return;
+          this->sAgeModifier -= (signed __int16)pValue;
+          return result;
         case VAR_Award:
           v11 = this->_guilds_member_bits;
           goto LABEL_112;
         case VAR_Experience:
           v12 = (char *)&this->uExperience;
-          v13 = (signed int)a3;
-          v14 = *(int *)v12 < (unsigned int)a3;
-          *(int *)v12 -= (int)a3;
+          v13 = (signed int)pValue;
+          v14 = *(int *)v12 < (unsigned int)pValue;
+          *(int *)v12 -= (int)pValue;
           *((int *)v12 + 1) -= v14 + HIDWORD(v13);
           goto LABEL_17;
         case VAR_QBits_QuestsDone:
-          _449B7E_toggle_bit(pParty->_quest_bits, (__int16)a3, 0);
+          _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0);
           pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0);
-          return;
+          return true;
         case VAR_PlayerItemInHands:
-          v15 = (char *)this->pInventoryIndices;
+          v15 = this->pInventoryIndices;
           break;
         case VAR_FixedGold:
-          if ( (unsigned int)a3 > pParty->uNumGold )
+          if ( (unsigned int)pValue > pParty->uNumGold )
             goto LABEL_88;
-          Party::TakeGold((unsigned int)a3);
-          return;
+          Party::TakeGold((unsigned int)pValue);
+          return result;
         case VAR_MightBonus:
         case VAR_ActualMight:
-          this->uMightBonus -= (unsigned __int16)a3;
+          this->uMightBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_IntellectBonus:
         case VAR_ActualIntellect:
-          this->uIntelligenceBonus -= (unsigned __int16)a3;
+          this->uIntelligenceBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_PersonalityBonus:
         case VAR_ActualPersonality:
-          this->uWillpowerBonus -= (unsigned __int16)a3;
+          this->uWillpowerBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_EnduranceBonus:
         case VAR_ActualEndurance:
-          this->uEnduranceBonus -= (unsigned __int16)a3;
+          this->uEnduranceBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_SpeedBonus:
         case VAR_ActualSpeed:
-          this->uSpeedBonus -= (unsigned __int16)a3;
+          this->uSpeedBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_AccuracyBonus:
         case VAR_ActualAccuracy:
-          this->uAccuracyBonus -= (unsigned __int16)a3;
+          this->uAccuracyBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_LuckBonus:
         case VAR_ActualLuck:
-          this->uLuckBonus -= (unsigned __int16)a3;
+          this->uLuckBonus -= (unsigned __int16)pValue;
           goto LABEL_72;
         case VAR_BaseMight:
-          this->uMight -= (unsigned __int16)a3;
+          this->uMight -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseIntellect:
-          this->uIntelligence -= (unsigned __int16)a3;
+          this->uIntelligence -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BasePersonality:
-          this->uWillpower -= (unsigned __int16)a3;
+          this->uWillpower -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseEndurance:
-          this->uEndurance -= (unsigned __int16)a3;
+          this->uEndurance -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseSpeed:
-          this->uSpeed -= (unsigned __int16)a3;
+          this->uSpeed -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseAccuracy:
-          this->uAccuracy -= (unsigned __int16)a3;
+          this->uAccuracy -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_BaseLuck:
-          this->uLuck -= (unsigned __int16)a3;
+          this->uLuck -= (unsigned __int16)pValue;
           goto LABEL_45;
         case VAR_FireResistance:
-          this->sResFireBase -= (signed __int16)a3;
+          this->sResFireBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_AirResistance:
-          this->sResAirBase -= (signed __int16)a3;
+          this->sResAirBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_WaterResistance:
-          this->sResWaterBase -= (signed __int16)a3;
+          this->sResWaterBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_EarthResistance:
-          this->sResEarthBase -= (signed __int16)a3;
+          this->sResEarthBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_SpiritResistance:
-          this->sResSpiritBase -= (signed __int16)a3;
+          this->sResSpiritBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_MindResistance:
-          this->sResMindBase -= (signed __int16)a3;
+          this->sResMindBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_BodyResistance:
-          this->sResBodyBase -= (signed __int16)a3;
+          this->sResBodyBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_LightResistance:
-          this->sResLightBase -= (signed __int16)a3;
+          this->sResLightBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_DarkResistance:
-          this->sResDarkBase -= (signed __int16)a3;
+          this->sResDarkBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_MagicResistance:
-          this->sResMagicBase -= (signed __int16)a3;
+          this->sResMagicBase -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_FireResistanceBonus:
-          this->sResFireBonus -= (signed __int16)a3;
+          this->sResFireBonus -= (signed __int16)pValue;
           goto LABEL_45;
         case VAR_AirResistanceBonus:
-          this->sResAirBonus -= (signed __int16)a3;
+          this->sResAirBonus -= (signed __int16)pValue;
 LABEL_45:
           v25 = 0;
           v23 = 92;
           goto LABEL_73;
         case VAR_WaterResistanceBonus:
-          this->sResWaterBonus -= (signed __int16)a3;
+          this->sResWaterBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_EarthResistanceBonus:
-          this->sResEarthBonus -= (signed __int16)a3;
+          this->sResEarthBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_SpiritResistanceBonus:
-          this->sResSpiritBonus -= (signed __int16)a3;
+          this->sResSpiritBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_MindResistanceBonus:
-          this->sResMindBonus -= (signed __int16)a3;
+          this->sResMindBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_BodyResistanceBonus:
-          this->sResBodyBonus -= (signed __int16)a3;
+          this->sResBodyBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_LightResistanceBonus:
-          this->sResLightBonus -= (signed __int16)a3;
+          this->sResLightBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_DarkResistanceBonus:
-          this->sResDarkBonus -= (signed __int16)a3;
+          this->sResDarkBonus -= (signed __int16)pValue;
           goto LABEL_72;
         case VAR_MagicResistanceBonus:
-          this->sResMagicBonus -= (signed __int16)a3;
+          this->sResMagicBonus -= (signed __int16)pValue;
 LABEL_72:
           v25 = 0;
           v23 = SPEECH_91;
@@ -9622,7 +9650,7 @@
           pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25);
           goto LABEL_17;
         case VAR_FixedFood:
-          Party::TakeFood((unsigned int)a3);
+          Party::TakeFood((unsigned int)pValue);
           goto LABEL_17;
         case VAR_StaffSkill:
         case VAR_SwordSkill:
@@ -9654,7 +9682,7 @@
         case VAR_DiplomacySkill:
         case VAR_DisarmTrapSkill:
         case VAR_LearningSkill:
-          *((short *)&this->pConditions[16] + var) -= (unsigned __int8)a3;
+          *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue;
           goto LABEL_17;
         case VAR_Cursed:
         case VAR_Weak:
@@ -9673,28 +9701,33 @@
         case VAR_Dead:
         case VAR_Stoned:
         case VAR_Eradicated:
-          *((int *)this + 2 * var - 210) = 0;
-          *((int *)this + 2 * v5 - 209) = 0;
+          *((int *)this + 2 * VarNum - 210) = 0;
+          *((int *)this + 2 * result - 209) = 0;
 LABEL_17:
           pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
           v8 = 8 * v4 + 400;
           LOBYTE(v8) = (8 * v4 - 112) | 4;
           pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
-          return;
-      }
-      do
-      {
-        if ( *(void **)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v15 + 5] == a3 )
+          return result;
+      }
+      //do
+	  for (v3 = 1; v3 < 126; v3++)
+      {
+		  if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue )//pValue = ItemID, pInventoryItems[3] = 222
         {
-          RemoveItemAtInventoryIndex(v3);
-          return;
+          RemoveItemAtInventoryIndex(v3);// &this->pInventoryIndices[puSlot], pInventoryIndices[1] = 4
+          return true;
         }
-        ++v3;
-        v15 += 4;
-      }
-      while ( (signed int)v3 < 126 );
-      if ( (void *)pParty->pPickedItem.uItemID == a3 )
-        pMouse->RemoveHoldingItem();
+        //++v3;
+        //v15 ++;
+      }
+      //while ( (signed int)v3 < 126 );
+      if ( pParty->pPickedItem.uItemID == pValue )
+      {
+         pMouse->RemoveHoldingItem();
+		 return true;
+	  }
+	  return false;
     }
   }
 }