diff Player.cpp @ 492:0e27362ac1d9

guild
author Gloval
date Thu, 28 Feb 2013 01:38:46 +0400
parents 7887a9cf9e7b
children 59649750a054
line wrap: on
line diff
--- a/Player.cpp	Wed Feb 27 22:48:10 2013 +0400
+++ b/Player.cpp	Thu Feb 28 01:38:46 2013 +0400
@@ -8205,9 +8205,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
@@ -8237,125 +8237,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 )
     {
@@ -8366,101 +8355,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;
@@ -8468,43 +8457,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;
@@ -8532,7 +8530,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;
@@ -8557,82 +8555,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;
@@ -8643,22 +8641,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);
@@ -8668,66 +8666,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;
 }
 
 
@@ -8862,7 +8879,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;