changeset 2238:f66d8be6ad5b

_4B254D_SkillMasteryTeacher unrolling switches
author Grumpy7
date Sun, 23 Feb 2014 15:42:15 +0100
parents d903816e972e
children 699bd6ee5ad0
files mm7_4.cpp
diffstat 1 files changed, 541 insertions(+), 276 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_4.cpp	Sun Feb 23 14:12:07 2014 +0100
+++ b/mm7_4.cpp	Sun Feb 23 15:42:15 2014 +0100
@@ -1825,72 +1825,34 @@
 //----- (004B254D) --------------------------------------------------------
 const char * _4B254D_SkillMasteryTeacher(int _this)
 {
-  //Player *v1; // esi@1
-  int v2; // edx@1
-  int v3; // ecx@1
+  int teacherLevel; // edx@1
+  int skillBeingTaught; // ecx@1
   int pClassType; // eax@7
-  int v6; // eax@7
+  int currClassMaxMastery; // eax@7
   int pointsInSkillWOutMastery; // ebx@7
-  //int v8; // ebx@8
-  signed int v9; // esi@8
   int classBaseId; // eax@8
-  char *v11; // ecx@8
-  //int v12; // edi@9
-  //char *v13; // edx@9
-  signed int v14; // edi@10
   unsigned int skillMastery; // eax@29
-  //int v17; // eax@36
-  char v18; // cl@46
-  __int16 v19; // dx@56
-  int v20; // eax@60
-  //char *v21; // [sp-Ch] [bp-38h]@82
-  //const char *v22; // [sp-8h] [bp-34h]@21
-  //unsigned int v23; // [sp-8h] [bp-34h]@38
-  //char *v24; // [sp-8h] [bp-34h]@82
-  const char *v25; // [sp-4h] [bp-30h]@14
-  //int v26; // [sp-4h] [bp-30h]@38
-  //int v27; // [sp-4h] [bp-30h]@82
-  char v28[4]; // [sp+Ch] [bp-20h]@9
   unsigned __int16 pointsInSkill; // [sp+1Ch] [bp-10h]@7
-  //int v33; // [sp+20h] [bp-Ch]@7
-  int v34; // [sp+24h] [bp-8h]@7
-  char *v35; // [sp+28h] [bp-4h]@1
+  int masteryLevelBeingTaught; // [sp+24h] [bp-8h]@7
 
   contract_approved = 0;
-  v2 = (_this - 200) % 3;
-  v3 = (_this - 200) / 3;
-  v35 = (char *)pNPCTopics[127].pText;
-    dword_F8B1AC_award_bit_number = v3;
-  switch(v2)
-  {
-    case 0: 
-      gold_transaction_amount = 2000;
-      dword_F8B1B0 = 2;
-      break;
-    case 1: 
-      gold_transaction_amount = 5000;
-      dword_F8B1B0 = 3;
-      break;
-    case 2: 
-      gold_transaction_amount = 8000;
-      dword_F8B1B0 = 4;
-      break;
-  }
+  teacherLevel = (_this - 200) % 3;
+  skillBeingTaught = (_this - 200) / 3;
   pClassType = pPlayers[uActiveCharacter]->classType;
-  //v33 = pClassType;
-  v6 = byte_4ED970_skill_learn_ability_by_class_table[pClassType][v3];
-  v34 = v2 + 2;
-  if ( v6 < v2 + 2 )
+  currClassMaxMastery = byte_4ED970_skill_learn_ability_by_class_table[pClassType][skillBeingTaught];
+  masteryLevelBeingTaught = teacherLevel + 2;
+  dword_F8B1B0 = masteryLevelBeingTaught;
+  if ( currClassMaxMastery < masteryLevelBeingTaught )
   {
     classBaseId = pClassType - pClassType % 4;
-    if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 1][v3] >= v34)
+    if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 1][skillBeingTaught] >= masteryLevelBeingTaught)
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[633], pClassNames[classBaseId + 1]);//Вы должны достичь звания %s для обучения этому уровню навыка. You have to be promoted to %s to learn this skill level.
-    else if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 2][v3] >= v34
-      && byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 3][v3] >= v34)
+    else if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 2][skillBeingTaught] >= masteryLevelBeingTaught
+      && byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 3][skillBeingTaught] >= masteryLevelBeingTaught)
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[634], pClassNames[classBaseId + 2], pClassNames[classBaseId + 3]);//Вы должны достичь звания %s или %s для обучения этому уровню навыка. You have to be promoted to %s or %s to learn this skill level.
-    else if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 2][v3] >= v34)
+    else if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 2][skillBeingTaught] >= masteryLevelBeingTaught)
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[633], pClassNames[classBaseId + 2]);//Вы должны достичь звания %s для обучения этому уровню навыка. You have to be promoted to %s to learn this skill level.
-    else if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 3][v3] >= v34)
+    else if (byte_4ED970_skill_learn_ability_by_class_table[classBaseId + 3][skillBeingTaught] >= masteryLevelBeingTaught)
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[633], pClassNames[classBaseId + 3]);//Вы должны достичь звания %s для обучения этому уровню навыка. You have to be promoted to %s to learn this skill level.
     else
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[632], pClassNames[pClassType]);//Этот уровень навыка не может быть постигнут классом %s. This skill level can not be learned by the %s class.
@@ -1898,251 +1860,554 @@
   }
   if ( !pPlayers[uActiveCharacter]->CanAct() )
     return pNPCTopics[122].pText; //Not in your condition!
-  pointsInSkill = pPlayers[uActiveCharacter]->pActiveSkills[v3];
+  pointsInSkill = pPlayers[uActiveCharacter]->pActiveSkills[skillBeingTaught];
   pointsInSkillWOutMastery = pointsInSkill & 0x3F;
   if ( !pointsInSkillWOutMastery )
     return pNPCTopics[131].pText; //You must know the skill before you can become an expert in it!
   skillMastery = SkillToMastery(pointsInSkill);
-  if ( (signed int)skillMastery > v2 + 1 )  // You are already an SKILLLEVEL in this skill.	
-    return pNPCTopics[v2 + 128].pText;
-  if ( v34 != 2 )
+  if ( (signed int)skillMastery > teacherLevel + 1 )  
+    return pNPCTopics[teacherLevel + 128].pText;    // You are already an SKILLLEVEL in this skill.	
+  dword_F8B1AC_award_bit_number = skillBeingTaught;
+  if ( masteryLevelBeingTaught == 2 && pointsInSkillWOutMastery < 4 
+    || masteryLevelBeingTaught == 3 && pointsInSkillWOutMastery < 7
+    || masteryLevelBeingTaught == 4 && pointsInSkillWOutMastery < 10
+    )
+    return pNPCTopics[127].pText;  //"You don't meet the requirements, and cannot be taught until you do."
+  switch (dword_F8B1AC_award_bit_number)
   {
-    if ( v34 == 3 )
-    {
-      if ( (signed int)skillMastery >= 2 && pointsInSkillWOutMastery >= 7 )
+    case PLAYER_SKILL_STAFF:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_SWORD:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_DAGGER:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_AXE:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_SPEAR:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_BOW:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_MACE:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_BLASTER:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 0;
+        break;
+      case 3:
+        gold_transaction_amount = 0;
+        break;
+      case 4:
+        gold_transaction_amount = 0;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_SHIELD:
+      switch (masteryLevelBeingTaught)
       {
-        switch ( dword_F8B1AC_award_bit_number )
-        {
-          case 12:    //Fire magic
-          case 13:    //Air magic
-          case 14:    //Water magic
-          case 15:    //Earth magic
-          case 16:    //Spirit magic
-          case 17:    //Mind magic
-          case 18:    //Body magic
-            gold_transaction_amount = 4000;
-            goto LABEL_42;
-          case 19:    //Light magic
-            v19 = 114;
-            if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v19) )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 20:    //Dark magic
-            v19 = 110;
-            if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v19) )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 22:     //Merchant
-            v20 = pPlayers[uActiveCharacter]->GetBaseWillpower();
-            if ( v20 < 50 )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 24:     //Body Building
-            gold_transaction_amount = 2500;
-            v20 = pPlayers[uActiveCharacter]->GetBaseEndurance();
-            if ( v20 < 50 )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 36:     //Learning
-            v20 = pPlayers[uActiveCharacter]->GetBaseIntelligence();
-            if ( v20 < 50 )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 21:     //Identify Item
-          case 23:     //Repait Item
-          case 25:     //Meditation
-          case 26:     //Perception
-          case 29:     //Disarm Trap
-          case 32:     //Identify Monster
-          case 34:     //Stealing
-          case 35:     //Alchemy
-            gold_transaction_amount = 2500;
-            goto LABEL_42;
-          case 8:     //Shield
-          case 9:     //Leather
-          case 10:     //Chain
-          case 11:     //Plate
-            gold_transaction_amount = 3000;
-            goto LABEL_42;
-          case 7:     //Blaster
-            gold_transaction_amount = 0;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          default:
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-        }
-        gold_transaction_amount = 0;
-        if ( !gold_transaction_amount )
-          goto LABEL_79;
-        goto LABEL_42;
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 3000;
+        break;
+      case 4:
+        gold_transaction_amount = 7000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_LEATHER:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 3000;
+        break;
+      case 4:
+        gold_transaction_amount = 7000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_CHAIN:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 3000;
+        break;
+      case 4:
+        gold_transaction_amount = 7000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_PLATE:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 3000;
+        break;
+      case 4:
+        gold_transaction_amount = 7000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_FIRE:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
       }
-    }
-    else
-    {
-      if ( v34 != 4 )
+      break;
+    case PLAYER_SKILL_AIR:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_WATER:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_EARTH:
+      switch (masteryLevelBeingTaught)
       {
-        if ( !gold_transaction_amount )
-          goto LABEL_79;
-        goto LABEL_42;
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
       }
-      if ( (signed int)skillMastery >= 3 && pointsInSkillWOutMastery >= 10 )
+      break;
+    case PLAYER_SKILL_SPIRIT:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_MIND:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_BODY:
+      switch (masteryLevelBeingTaught)
       {
-        switch ( dword_F8B1AC_award_bit_number )
-        {
-        case 19:     //Light Magic
-            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x22u, 1) == 1 )
-            {
-              if ( !gold_transaction_amount )
-                goto LABEL_79;
-              goto LABEL_42;
-            }
-            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Au, 1) == 1 )
-            {
-              if ( !gold_transaction_amount )
-                goto LABEL_79;
-              goto LABEL_42;
-            }
-            return v35;
-          case 20:     //Dark Magic
-            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x23u, 1) == 1 )
-            {
-              if ( !gold_transaction_amount )
-                goto LABEL_79;
-              goto LABEL_42;
-            }
-            if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Bu, 1) == 1 )
-            {
-              if ( !gold_transaction_amount )
-                goto LABEL_79;
-              goto LABEL_42;
-            }
-            return v35;
-          case 30:     //Dodging
-            v18 = LOBYTE(pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_UNARMED]);
-            if ( (v18 & 0x3Fu) < 0xA )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 31:     //Unarmed
-            v18 = LOBYTE(pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_DODGE]);
-            if ( (v18 & 0x3Fu) < 0xA )
-              return v35;
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-          case 21:     //Identify Item
-          case 23:     //Repait Item
-          case 24:     //Body Building
-          case 25:     //Meditation
-          case 26:     //Perception
-          case 29:     //Disarm Trap
-          case 32:     //Identify Monster
-          case 34:     //Stealing
-          case 35:     //Alchemy
-            gold_transaction_amount = 6000;
-            goto LABEL_42;
-          case 8:     //Shield
-          case 9:     //Leather
-          case 10:     //Chain
-          case 11:     //Plate
-            gold_transaction_amount = 7000;
-            goto LABEL_42;
-          case 7:    //Blaster
-            break;
-          default:
-            if ( !gold_transaction_amount )
-              goto LABEL_79;
-            goto LABEL_42;
-        }
-        gold_transaction_amount = 0;
-        if ( !gold_transaction_amount )
-          goto LABEL_79;
-        goto LABEL_42;
+      case 2:
+        gold_transaction_amount = 1000;
+        break;
+      case 3:
+        gold_transaction_amount = 4000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_LIGHT:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 114) )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        if ( !pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x22u, 1) ||
+          !pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Au, 1))
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_DARK:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 110) )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        if ( !pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x23u, 1) 
+          || !pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Bu, 1))
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_ITEM_ID:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_MERCHANT:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        if ( pPlayers[uActiveCharacter]->GetBaseWillpower() < 50 )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_REPAIR:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_BODYBUILDING:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        if ( pPlayers[uActiveCharacter]->GetBaseEndurance() < 50 )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_MEDITATION:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
       }
-    }
-    return v35;
-  }
-  if ( pointsInSkillWOutMastery < 4 )
-    return v35;
-  if ( dword_F8B1AC_award_bit_number > 27 )
-  {
-    if ( dword_F8B1AC_award_bit_number != 29
-      && dword_F8B1AC_award_bit_number != 32
-      && (dword_F8B1AC_award_bit_number <= 33 || dword_F8B1AC_award_bit_number > 35) )
-    {
-      if ( !gold_transaction_amount )
-        goto LABEL_79;
-      goto LABEL_42;
-    }
-    gold_transaction_amount = 500;
-    if ( !gold_transaction_amount )
-      goto LABEL_79;
-    goto LABEL_42;
-  }
-  if ( dword_F8B1AC_award_bit_number >= 23 )
-  {
-    gold_transaction_amount = 500;
-    if ( !gold_transaction_amount )
-      goto LABEL_79;
-    goto LABEL_42;
+      break;
+    case PLAYER_SKILL_PERCEPTION:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_DIPLOMACY:
+      Error("Diplomacy not used");
+      break;
+    case PLAYER_SKILL_TIEVERY:
+      Error("Thievery not used");
+      break;
+    case PLAYER_SKILL_TRAP_DISARM:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_DODGE:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        if ( (pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_UNARMED] & 63) < 0xA )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_UNARMED:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        if ( (pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_DODGE] & 63) < 0xA )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_MONSTER_ID:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_ARMSMASTER:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_STEALING:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_ALCHEMY:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 500;
+        break;
+      case 3:
+        gold_transaction_amount = 2500;
+        break;
+      case 4:
+        gold_transaction_amount = 6000;
+        break;
+      }
+      break;
+    case PLAYER_SKILL_LEARNING:
+      switch (masteryLevelBeingTaught)
+      {
+      case 2:
+        gold_transaction_amount = 2000;
+        break;
+      case 3:
+        if ( pPlayers[uActiveCharacter]->GetBaseIntelligence() < 50 )
+          return pNPCTopics[127].pText;
+        gold_transaction_amount = 5000;
+        break;
+      case 4:
+        gold_transaction_amount = 8000;
+        break;
+      }
+      break;
+    default:
+      Error("Unknown skill");
   }
-  if ( dword_F8B1AC_award_bit_number == 7 )
-  {
-    gold_transaction_amount = 0;
-    goto LABEL_79;
-  }
-  if ( dword_F8B1AC_award_bit_number <= 7 )
-  {
-    if ( !gold_transaction_amount )
-      goto LABEL_79;
-    goto LABEL_42;
-  }
-  if ( dword_F8B1AC_award_bit_number > 18 )
-  {
-    if ( dword_F8B1AC_award_bit_number != 21 )
-    {
-      if ( !gold_transaction_amount )
-        goto LABEL_79;
-      goto LABEL_42;
-    }
-    gold_transaction_amount = 500;
-    if ( !gold_transaction_amount )
-      goto LABEL_79;
-    goto LABEL_42;
-  }
-  gold_transaction_amount = 1000;
-LABEL_42:
   if ( gold_transaction_amount > pParty->uNumGold )
-    return (char *)pNPCTopics[124].pText;
-LABEL_79:
+    return pNPCTopics[124].pText;  //You don't have enough gold!
   contract_approved = 1;
-  if ( v34 == 2 )
+  if ( masteryLevelBeingTaught == 2 )
   {
     sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[534],//Получить степень ^Pr[%s] в навыке ^Pr[%s] за ^I[%lu] золот^L[ой;ых;ых]
               pGlobalTXT_LocalizationStrings[433], pSkillNames[dword_F8B1AC_award_bit_number], gold_transaction_amount);//Эксперт
-    return pTmpBuf2.data();
   }
-  if ( v34 == 3 )
+  if ( masteryLevelBeingTaught == 3 )
   {
     sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[534],
               pGlobalTXT_LocalizationStrings[432], pSkillNames[dword_F8B1AC_award_bit_number], gold_transaction_amount);//Мастер
-    return pTmpBuf2.data();
   }
-  if ( v34 == 4 )
+  if ( masteryLevelBeingTaught == 4 )
     sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[534],
               pGlobalTXT_LocalizationStrings[225], pSkillNames[dword_F8B1AC_award_bit_number], gold_transaction_amount);//Великий Магистр
   return pTmpBuf2.data();