changeset 224:9917d3b4925e

items init refactored
author Gloval
date Sun, 17 Feb 2013 14:46:05 +0400
parents 1bd823f52e3a
children e3fd201a58f0
files Items.cpp Items.h mm7_6.cpp
diffstat 3 files changed, 651 insertions(+), 1225 deletions(-) [+]
line wrap: on
line diff
--- a/Items.cpp	Sun Feb 17 11:41:44 2013 +0400
+++ b/Items.cpp	Sun Feb 17 14:46:05 2013 +0400
@@ -241,311 +241,206 @@
 
 //----- (00456D84) --------------------------------------------------------
 void ItemsTable::Initialize()
-{
-  //ItemsTable *v1; // edi@1
-  char *v2; // eax@1
-  char *v3; // eax@2
-  char v4; // cl@3
-  int v5; // esi@3
-  char *v6; // esi@21
-  unsigned char *v7; // eax@21
-  unsigned char *v8; // ecx@22
-  char *v9; // eax@26
-  char v10; // dl@27
-  int v11; // ecx@27
-  int v12; // esi@31
-  char *v13; // eax@39
-  int v14; // esi@40
-  char v15; // cl@41
-  int v16; // eax@41
-  char v17; // zf@53
-  int v18; // eax@57
-  int *v19; // esi@66
-  char *v20; // edx@66
-  int v21; // eax@66
-  char *v22; // ecx@68
-  char *v23; // eax@71
-  int v24; // esi@71
-  char *v25; // ebx@72
-  char v26; // cl@73
-  int v27; // eax@73
-  char *v28; // ST3C_4@160
-  char *v29; // ST3C_4@163
-  char *v30; // eax@175
-  char *v31; // eax@188
-  char v32; // al@190
-  char *v33; // eax@199
-  const char *v34; // ebx@199
-  int v35; // esi@199
-  char *v36; // eax@200
-  char v37; // dl@201
-  int v38; // ecx@201
-  char *v39; // esi@229
-  char *v40; // eax@229
-  char *v41; // ecx@230
-  char *v42; // esi@233
-  char *v43; // eax@234
-  char v44; // dl@235
-  int v45; // ecx@235
-  signed int v46; // edi@287
-  char *v47; // ecx@288
-  char v48; // dl@289
-  int v49; // eax@289
-  int v50; // esi@293
-  signed int v51; // edi@312
-  char *v52; // ecx@312
-  char v53; // dl@313
-  int v54; // eax@313
-  int v55; // esi@317
-  signed int v56; // edi@348
-  char *v57; // eax@348
-  char v58; // dl@349
-  int v59; // ecx@349
-  int v60; // esi@353
-  char *Str; // [sp+Ch] [bp-18h]@1
-  signed int Stra; // [sp+Ch] [bp-18h]@22
-  signed int Strb; // [sp+Ch] [bp-18h]@25
-  signed int Strc; // [sp+Ch] [bp-18h]@39
-  signed int Strd; // [sp+Ch] [bp-18h]@66
-  signed int Stre; // [sp+Ch] [bp-18h]@156
-  const char **Strf; // [sp+Ch] [bp-18h]@176
-  const char **Strg; // [sp+Ch] [bp-18h]@182
-  signed int Strh; // [sp+Ch] [bp-18h]@230
-  signed int Stri; // [sp+Ch] [bp-18h]@311
-  char **Strj; // [sp+Ch] [bp-18h]@347
-  int v72; // [sp+10h] [bp-14h]@7
-  signed int v73; // [sp+10h] [bp-14h]@21
-  int v74; // [sp+10h] [bp-14h]@45
-  int v75; // [sp+10h] [bp-14h]@77
-  int v76; // [sp+10h] [bp-14h]@205
-  signed int v77; // [sp+10h] [bp-14h]@229
-  int v78; // [sp+10h] [bp-14h]@239
-  signed int v79; // [sp+14h] [bp-10h]@1
-  char *v80; // [sp+14h] [bp-10h]@39
-  char *v81; // [sp+14h] [bp-10h]@175
-  char *v82; // [sp+14h] [bp-10h]@188
-  int v83; // [sp+18h] [bp-Ch]@67
-  size_t v84; // [sp+18h] [bp-Ch]@156
-  signed int v85; // [sp+18h] [bp-Ch]@176
-  signed int v86; // [sp+18h] [bp-Ch]@182
-  signed int v87; // [sp+18h] [bp-Ch]@233
-  signed int v88; // [sp+1Ch] [bp-8h]@2
-  signed int v89; // [sp+1Ch] [bp-8h]@26
-  signed int v90; // [sp+1Ch] [bp-8h]@40
-  signed int v91; // [sp+1Ch] [bp-8h]@72
-  signed int v92; // [sp+1Ch] [bp-8h]@200
-  signed int v93; // [sp+1Ch] [bp-8h]@234
-  signed int v94; // [sp+1Ch] [bp-8h]@288
-  signed int v95; // [sp+1Ch] [bp-8h]@312
-  signed int v96; // [sp+1Ch] [bp-8h]@348
-  signed int v97; // [sp+20h] [bp-4h]@2
-  signed int v98; // [sp+20h] [bp-4h]@26
-  signed int v99; // [sp+20h] [bp-4h]@40
-  signed int v100; // [sp+20h] [bp-4h]@72
-  signed int v101; // [sp+20h] [bp-4h]@200
-  signed int v102; // [sp+20h] [bp-4h]@234
-  signed int v103; // [sp+20h] [bp-4h]@288
-  int i,j;
-  char* test_string;
-  char c;
-  bool break_loop;
-  unsigned int temp_str_len;
-  char* tmp_pos;
-  int decode_step;
-  int item_counter;
-  //v1 = this;
+	{
+	int i,j;
+	char* test_string;
+	char c;
+	bool break_loop;
+	unsigned int temp_str_len;
+	char* tmp_pos;
+	int decode_step;
+	int item_counter;
+
+	pMapStats = new MapStats;
+	pMapStats->Initialize();
+
+	pMonsterStats = new MonsterStats;
+	pMonsterStats->Initialize();
+	pMonsterStats->InitializePlacements();
+
+	pSpellStats = new SpellStats;
+	pSpellStats->Initialize();
+
+	LoadPotions();
+	LoadPotionNotes();
+
+	pFactionTable = new FactionTable;
+	pFactionTable->Initialize();
+
+	pStorylineText = new StorylineText;
+	pStorylineText->Initialize();
 
-  pMapStats = new MapStats;
-  pMapStats->Initialize();
-
-  pMonsterStats = new MonsterStats;
-  pMonsterStats->Initialize();
-  pMonsterStats->InitializePlacements();
+	pStdItemsTXT_Raw = NULL;
+	pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0);
+	strtok(pStdItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	//Standard Bonuses by Group	
+	for (i=0;i<24;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: 
+					pEnchantments[i].pBonusStat=RemoveQuotes(test_string);
+					break;
+				case 1:
+					pEnchantments[i].pOfName= RemoveQuotes(test_string);
+					break;
+				default:
+					pEnchantments[i].to_item[decode_step-2]=atoi(test_string);
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<11)&&!break_loop);
+		}
 
-  pSpellStats = new SpellStats;
-  pSpellStats->Initialize();
-
-  LoadPotions();
-  LoadPotionNotes();
-
-  pFactionTable = new FactionTable;
-  pFactionTable->Initialize();
-
-  pStorylineText = new StorylineText;
-  pStorylineText->Initialize();
+	memset(&pEnchantmentsSumm, 0, 36);
+	for(i=0;i<9;++i)
+		{
+		for (j=0;j<24;++j)
+			pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i];
+		}
 
-  pStdItemsTXT_Raw = 0;
-  pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0);
-  strtok(pStdItemsTXT_Raw, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  //Standard Bonuses by Group	
-  for (i=0;i<24;++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  switch (decode_step)
-				  {
-			  case 0: 
-				  pEnchantments[i].pBonusStat=RemoveQuotes(test_string);
-				  break;
-			  case 1:
-				  pEnchantments[i].pOfName= RemoveQuotes(test_string);
-				  break;
-			  default:
-				  pEnchantments[i].to_item[decode_step-2]=atoi(test_string);
-				  }
-			  }
-		  else
-			  { 
-			  if (!decode_step)
-				  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<11)&&!break_loop);
-	  }
- //Value Mod= (+100 / Plus of Item)?
-  
-  memset(&pEnchantmentsSumm, 0, 36);
- for(i=0;i<9;++i)
-	 {
-	 for (j=0;j<24;++j)
-		pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i];
-	 }
-  
-  //Bonus range for Standard by Level
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  for(i=0;i<6;++i) //counted from 1
-	 {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if  (decode_step==2)
-			  bonus_ranges[i].minR = atoi(test_string);
-		  else if (decode_step==3)
-			   bonus_ranges[i].maxR =atoi(test_string);
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<4)&&!break_loop);
-	  }
-  
+	//Bonus range for Standard by Level
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	for(i=0;i<6;++i) //counted from 1
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if  (decode_step==2)
+				bonus_ranges[i].minR = atoi(test_string);
+			else if (decode_step==3)
+				bonus_ranges[i].maxR =atoi(test_string);
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<4)&&!break_loop);
+		}
+
 
-  pSpcItemsTXT_Raw = 0;
-  pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
-  strtok(pSpcItemsTXT_Raw, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  strtok(NULL, "\r");
-  for (i=0;i<72;++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  switch (decode_step)
-				  {
-			  case 0: 
-				  pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string);
-				  break;
-			  case 1:
-				  pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string);
-				  break;
-			  case 14:
-				  int res;
-				  res=atoi(test_string);
-				  if(!res)
-					  {
-					  ++test_string; 
-					  while (*test_string==' ')//fix X 2 case
-						  ++test_string; 
+	pSpcItemsTXT_Raw = 0;
+	pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
+	strtok(pSpcItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	for (i=0;i<72;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: 
+					pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string);
+					break;
+				case 1:
+					pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string);
+					break;
+				case 14:
+					int res;
+					res=atoi(test_string);
+					if(!res)
+						{
+						++test_string; 
+						while (*test_string==' ')//fix X 2 case
+							++test_string; 
 						res=atoi(test_string);
-					  }				
-				   pSpecialEnchantments[i].iValue=res;
-				  break;
-			  case 15:
-				  pSpecialEnchantments[i].iTreasureLevel=  tolower(*test_string) - 97;;
-				  break;
-			  default:
-				  pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string);
-				  }
-			  }
-		  else
-			  { 
-			  if (!decode_step)
-				  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<16)&&!break_loop);
-	  }
-  
-  pSpecialEnchantments_count = 71;
-  memset(&pSpecialEnchantmentsSumm, 0, 96);
-  for(i=0;i<12;++i)
-	  {
-	  for (j=0;j<pSpecialEnchantments_count;++j)
-		  pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
-	  }
+						}				
+					pSpecialEnchantments[i].iValue=res;
+					break;
+				case 15:
+					pSpecialEnchantments[i].iTreasureLevel=  tolower(*test_string) - 97;;
+					break;
+				default:
+					pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string);
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<16)&&!break_loop);
+		}
+
+	pSpecialEnchantments_count = 71;
+	memset(&pSpecialEnchantmentsSumm, 0, 96);
+	for(i=0;i<12;++i)
+		{
+		for (j=0;j<pSpecialEnchantments_count;++j)
+			pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
+		}
 
 
 
-  Initialize2DA();
+	Initialize2DA();
 
-  pItemsTXT_Raw = NULL;
-  pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0);
-  strtok(pItemsTXT_Raw, "\r");
-  strtok(NULL, "\r");
-  uAllItemsCount = 0;
-    item_counter = 0;
+	pItemsTXT_Raw = NULL;
+	pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0);
+	strtok(pItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	uAllItemsCount = 0;
+	item_counter = 0;
 	while (true)
 		{
 		test_string = strtok(NULL, "\r") + 1;
@@ -822,31 +717,33 @@
 					pItems[item_counter].uSpriteID=atoi(test_string);
 					break;
 				case 12: //VarA
+					{
 					pItems[item_counter]._additional_value=0;
 					pItems[item_counter]._bonus_type=0;
 					if (pItems[item_counter].uMaterial==3)
 						{
-						  for(int ii=0; ii<24; ++ii)
-							  {
-							  if (stricmp(test_string,pEnchantments[ii].pBonusStat))
-							  {
-							    pItems[item_counter]._bonus_type=ii+1;
+						for(int ii=0; ii<24; ++ii)
+							{
+							if (stricmp(test_string,pEnchantments[ii].pBonusStat))
+								{
+								pItems[item_counter]._bonus_type=ii+1;
 								break;
-							  }
-							  }
-						  if (!pItems[item_counter]._bonus_type)
-							  {
-								for(int ii=0; ii<72; ++ii)
+								}
+							}
+						if (!pItems[item_counter]._bonus_type)
+							{
+							for(int ii=0; ii<72; ++ii)
+								{
+								if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement))
 									{
-									if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement))
-										{
-										 pItems[item_counter]._additional_value=ii+1;
-										}
+									pItems[item_counter]._additional_value=ii+1;
 									}
-							  }
+								}
+							}
 						}
-					
+
 					break;
+					}
 				case 13: //VarB
 					if ((pItems[item_counter].uMaterial==3)&&(pItems[item_counter]._bonus_type))
 						{
@@ -868,7 +765,7 @@
 				case 16: //Notes
 					pItems[item_counter].pDescription = RemoveQuotes(test_string);
 					break;
-					
+
 					}
 				}
 			else
@@ -884,880 +781,402 @@
 				break;
 		}
 
-/*
-  while ( 2 )
-  {
-    v100 = 0;
-    v25 = strtok(0, "\r") + 1;
-    v91 = 0;
-    while ( 2 )
-    {
-      v26 = *v25;
-      v27 = 0;
-      while ( v26 != 9 && v26 )
-      {
-        ++v27;
-        v26 = v25[v27];
-      }
-      v75 = (int)&v25[v27];
-      if ( !v25[v27] )
-        v91 = 1;
-      v25[v27] = 0;
-      if ( v27 )
-      {
-        switch ( v100 )
-        {
-          case 0:
-            v24 = atoi(v25);
-            break;
-          case 1:
-            pItems[v24].pIconName = (char *)RemoveQuotes(v25);
-            break;
-          case 2:
-            pItems[v24].pName = (char *)RemoveQuotes(v25);
-            break;
-          case 3:
-            pItems[v24].uValue = atoi(v25);
-            break;
-          case 4:
-            if ( !_strcmpi(v25, "weapon") )
-              goto LABEL_89;
-            if ( _strcmpi(v25, "weapon2") )
-            {
-              if ( _strcmpi(v25, "weapon1or2") )
-              {
-                if ( _strcmpi(v25, "missile") && _strcmpi(v25, "bow") )
-                {
-                  if ( _strcmpi(v25, "armor") )
-                  {
-                    if ( _strcmpi(v25, "shield") )
-                    {
-                      if ( _strcmpi(v25, "helm") )
-                      {
-                        if ( _strcmpi(v25, "belt") )
-                        {
-                          if ( _strcmpi(v25, "cloak") )
-                          {
-                            if ( _strcmpi(v25, "gauntlets") )
-                            {
-                              if ( _strcmpi(v25, "boots") )
-                              {
-                                if ( _strcmpi(v25, "ring") )
-                                {
-                                  if ( _strcmpi(v25, "amulet") )
-                                  {
-                                    if ( _strcmpi(v25, "weaponw") )
-                                    {
-                                      if ( _strcmpi(v25, "herb") && _strcmpi(v25, "reagent") )
-                                      {
-                                        if ( _strcmpi(v25, "bottle") )
-                                        {
-                                          if ( _strcmpi(v25, "sscroll") )
-                                          {
-                                            if ( _strcmpi(v25, "book") )
-                                            {
-                                              if ( _strcmpi(v25, "mscroll") )
-                                              {
-                                                if ( _strcmpi(v25, "gold") )
-                                                {
-                                                  if ( _strcmpi(v25, "gem") )
-                                                    pItems[v24].uEquipType = 20;
-                                                  else
-                                                    pItems[v24].uEquipType = 19;
-                                                }
-                                                else
-                                                {
-                                                  pItems[v24].uEquipType = 18;
-                                                }
-                                              }
-                                              else
-                                              {
-                                                pItems[v24].uEquipType = 17;
-                                              }
-                                            }
-                                            else
-                                            {
-                                              pItems[v24].uEquipType = 16;
-                                            }
-                                          }
-                                          else
-                                          {
-                                            pItems[v24].uEquipType = 15;
-                                          }
-                                        }
-                                        else
-                                        {
-                                          pItems[v24].uEquipType = 14;
-                                        }
-                                      }
-                                      else
-                                      {
-                                        pItems[v24].uEquipType = 13;
-                                      }
-                                    }
-                                    else
-                                    {
-                                      pItems[v24].uEquipType = 12;
-                                    }
-                                  }
-                                  else
-                                  {
-                                    pItems[v24].uEquipType = 11;
-                                  }
-                                }
-                                else
-                                {
-                                  pItems[v24].uEquipType = 10;
-                                }
-                              }
-                              else
-                              {
-                                pItems[v24].uEquipType = 9;
-                              }
-                            }
-                            else
-                            {
-                              pItems[v24].uEquipType = 8;
-                            }
-                          }
-                          else
-                          {
-                            pItems[v24].uEquipType = 7;
-                          }
-                        }
-                        else
-                        {
-                          pItems[v24].uEquipType = 6;
-                        }
-                      }
-                      else
-                      {
-                        pItems[v24].uEquipType = 5;
-                      }
-                    }
-                    else
-                    {
-                      pItems[v24].uEquipType = 4;
-                    }
-                  }
-                  else
-                  {
-                    pItems[v24].uEquipType = 3;
-                  }
-                }
-                else
-                {
-                  pItems[v24].uEquipType = 2;
-                }
-              }
-              else
-              {
-LABEL_89:
-                pItems[v24].uEquipType = 0;
-              }
-            }
-            else
-            {
-              pItems[v24].uEquipType = 1;
-            }
-            break;
-          case 5:
-            if ( _strcmpi(v25, "staff") )
-            {
-              if ( _strcmpi(v25, "sword") )
-              {
-                if ( _strcmpi(v25, "dagger") )
-                {
-                  if ( _strcmpi(v25, "axe") )
-                  {
-                    if ( _strcmpi(v25, "spear") )
-                    {
-                      if ( _strcmpi(v25, "bow") )
-                      {
-                        if ( _strcmpi(v25, "mace") )
-                        {
-                          if ( _strcmpi(v25, "blaster") )
-                          {
-                            if ( _strcmpi(v25, "shield") )
-                            {
-                              if ( _strcmpi(v25, "leather") )
-                              {
-                                if ( _strcmpi(v25, "chain") )
-                                {
-                                  if ( _strcmpi(v25, "plate") )
-                                  {
-                                    if ( _strcmpi(v25, "club") )
-                                      pItems[v24].uSkillType = 38;
-                                    else
-                                      pItems[v24].uSkillType = 37;
-                                  }
-                                  else
-                                  {
-                                    pItems[v24].uSkillType = 11;
-                                  }
-                                }
-                                else
-                                {
-                                  pItems[v24].uSkillType = 10;
-                                }
-                              }
-                              else
-                              {
-                                pItems[v24].uSkillType = 9;
-                              }
-                            }
-                            else
-                            {
-                              pItems[v24].uSkillType = 8;
-                            }
-                          }
-                          else
-                          {
-                            pItems[v24].uSkillType = 7;
-                          }
-                        }
-                        else
-                        {
-                          pItems[v24].uSkillType = 6;
-                        }
-                      }
-                      else
-                      {
-                        pItems[v24].uSkillType = 5;
-                      }
-                    }
-                    else
-                    {
-                      pItems[v24].uSkillType = 4;
-                    }
-                  }
-                  else
-                  {
-                    pItems[v24].uSkillType = 3;
-                  }
-                }
-                else
-                {
-                  pItems[v24].uSkillType = 2;
-                }
-              }
-              else
-              {
-                pItems[v24].uSkillType = 1;
-              }
-            }
-            else
-            {
-              pItems[v24].uSkillType = 0;
-            }
-            break;
-          case 6:
-            Stre = 0;
-            v84 = strlen(v25);
-            if ( (signed int)v84 > 0 )
-            {
-              while ( tolower((unsigned __int8)v25[Stre]) != 'd' )
-              {
-                ++Stre;
-                if ( Stre >= (signed int)v84 )
-                  goto LABEL_161;
-              }
-              v25[Stre] = 0;
-              v28 = (char *)&pItems[v24];
-              v28[34] = atoi(v25);
-              v28[35] = atoi(&v25[Stre + 1]);
-              v25[Stre] = 'd';
-            }
-LABEL_161:
-            if ( Stre == v84 && tolower((unsigned __int8)*v25) != 115 )
-            {
-              v29 = (char *)&pItems[v24];
-              v29[34] = atoi(v25);
-              v29[35] = 1;
-            }
-            break;
-          case 7:
-            pItems[v24].uDamageMod = atoi(v25);
-            break;
-          case 8:
-            if ( _strcmpi(v25, "artifact") )
-            {
-              if ( _strcmpi(v25, "relic") )
-              {
-                if ( _strcmpi(v25, "special") )
-                  pItems[v24].uMaterial = 0;
-                else
-                  pItems[v24].uMaterial = 3;
-              }
-              else
-              {
-                pItems[v24].uMaterial = 2;
-              }
-            }
-            else
-            {
-              pItems[v24].uMaterial = 1;
-            }
-            break;
-          case 9:
-            BYTE2(pItems[v24 + 1].uItemID) = atoi(v25);
-            break;
-          case 10:
-            pItems[v24].pUnidentifiedName = (char *)RemoveQuotes(v25);
-            break;
-          case 11:
-            pItems[v24].uSpriteID = atoi(v25);
-            break;
-          case 12:
-            v30 = (char *)&pItems[v24];
-            v81 = v30;
-            if ( v30[37] == 3 )
-            {
-              v85 = 0;
-              Strf = (const char **)&pEnchantments[0].pOfName;
-              while ( _strcmpi(*Strf, v25) )
-              {
-                ++v85;
-                Strf += 5;
-                if ( v85 >= 24 )
-                  goto LABEL_181;
-              }
-              v81[39] = v85 + 1;
-LABEL_181:
-              if ( !v81[39] )
-              {
-                v86 = 0;
-                Strg = (const char **)&pSpecialEnchantments[0].pNameAdd;
-                while ( _strcmpi(*Strg, v25) )
-                {
-                  ++v86;
-                  Strg += 7;
-                  if ( v86 >= 72 )
-                    goto LABEL_196;
-                }
-                v81[38] = v86 + 1;
-              }
-            }
-            else
-            {
-              v30[38] = 0;
-              v30[39] = 0;
-            }
-            break;
-          case 13:
-            v31 = (char *)&pItems[v24];
-            v82 = v31;
-            if ( v31[37] == 3 && v31[39] )
-            {
-              v32 = atoi(v25);
-              v82[40] = v32;
-              if ( !v32 )
-                v82[40] = 1;
-            }
-            else
-            {
-              v31[40] = 0;
-            }
-            break;
-          case 14:
-            pItems[v24].uEquipX = atoi(v25);
-            break;
-          case 15:
-            pItems[v24].uEquipY = atoi(v25);
-            break;
-          case 16:
-            pItems[v24].pDescription = (char *)RemoveQuotes(v25);
-            break;
-          default:
-            break;
-        }
-      }
-LABEL_196:
-      ++v100;
-      v25 = (char *)(v75 + 1);
-      if ( v100 <= 16 && !v91 )
-        continue;
-      break;
-    }
-    ++v24;
-    if ( v24 < 800 )
-      continue;
-    break;
-  }
-  */
+
+	pRndItemsTXT_Raw = NULL;
+	uAllItemsCount = item_counter;
+	pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0);
+	strtok(pRndItemsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	item_counter = 0;
+	while (true)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 0: 
+					item_counter=atoi(test_string);
+					break;
+				case 2:
+					pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string);
+					break;
+				case 3:
+					pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string);
+					break;
+				case 4:
+					pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string);
+					break;
+				case 5:
+					pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string);
+					break;
+				case 6:
+					pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string);
+					break;
+				case 7:
+					pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string);
+					break;
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<8)&&!break_loop);
+			++item_counter;
+			if (item_counter>618)
+				break;
+		}
+
+	if ( pRndItemsTXT_Raw )
+		{
+		pAllocator->FreeChunk(pRndItemsTXT_Raw);
+		pRndItemsTXT_Raw = NULL;
+		}
+	//ChanceByTreasureLvl Summ - anti cheating?
+	memset(&uChanceByTreasureLvlSumm, 0, 24);
+	for(i=0;i<6;++i)
+		{
+		for (j=0;j<800;++j)
+			uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i];
+		}
 
-  pRndItemsTXT_Raw = NULL;
-  uAllItemsCount = item_counter;
-  pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0);
-  strtok(pRndItemsTXT_Raw, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	strtok(NULL, "\r");
+	for (i=0;i<3;++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 2: 
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[0]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[0]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[0]=atoi(test_string);
+						break;
+						}
+					break;
+				case 3:
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[1]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[1]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[1]=atoi(test_string);
+						break;
+						}
+					break;
+				case 4: 
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[2]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[2]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[2]=atoi(test_string);
+						break;
+						}
+					break;
+				case 5:
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[3]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[3]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[3]=atoi(test_string);
+						break;
+						}
+					break;
+				case 6: 
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[4]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[4]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[4]=atoi(test_string);
+						break;
+						}
+					break;
+				case 7:
+					switch (i)
+						{
+					case 0:
+						uBonusChanceStandart[5]=atoi(test_string);
+						break;
+					case 1:
+						uBonusChanceSpecial[5]=atoi(test_string);
+						break;
+					case 2:
+						uBonusChanceWpSpecial[5]=atoi(test_string);
+						break;
+						}
+					break;
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<8)&&!break_loop);
+		}
 
-  v35 = 0;
-  do
-  {
-    v101 = 0;
-    v36 = strtok(0, "\r") + 1;
-    v92 = 0;
-    do
-    {
-      v37 = *v36;
-      v38 = 0;
-      while ( v37 != 9 && v37 )
-      {
-        ++v38;
-        v37 = v36[v38];
-      }
-      v76 = (int)&v36[v38];
-      if ( !v36[v38] )
-        v92 = 1;
-      *(unsigned char *)v76 = 0;
-      if ( v38 )
-      {
-        if ( v101 )
-        {
-          switch ( v101 )
-          {
-            case 2:
-            //  pItems[v35].field_2C = atoi(v36);
-              break;
-            case 3:
-           //   pItems[v35].field_2D = atoi(v36);
-              break;
-            case 4:
-          //    pItems[v35].field_2E = atoi(v36);
-              break;
-            case 5:
-         //     pItems[v35].field_2F = atoi(v36);
-              break;
-            case 6:
-              //*((unsigned char *)&pItems[0].uItemID + 16 * (3 * v35 + 3)) = atoi(v36);
-              break;
-            case 7:
-            //  BYTE1(pItems[v35 + 1].uItemID) = atoi(v36);
-              break;
-          }
-        }
-        else
-        {
-          v35 = atoi(v36);
-        }
-      }
-      else
-      {
-        if ( !v101 )
-          v92 = 1;
-      }
-      ++v101;
-      v36 = (char *)(v76 + 1);
-    }
-    while ( v101 <= 7 && !v92 );
-    ++v35;
-  }
-  while ( v35 < 619 );
+	pSkillDescTXT_Raw = NULL;
+	pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
+	strtok(pSkillDescTXT_Raw, "\r");
+	for (i=0; i<37; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (decode_step)
+					{
+				case 1:
+					pSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 2:
+					pNormalSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 3:
+					pExpertSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 4:
+					pMasterSkillDesc[i] = RemoveQuotes(test_string);
+					break;
+				case 5:
+					pGrandSkillDesc[i] = RemoveQuotes(test_string);
+					break;	  
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<6)&&!break_loop);
+		}
+
+	pStatsTXT_Raw = 0;
+	pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
+	strtok(pStatsTXT_Raw, "\r");
+	for (i=0; i<26; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				switch (i)
+					{
+				case 0:
+				case 1:
+				case 2:
+				case 3:
+				case 4:
+				case 5:
+				case 6:
+					pAttributeDescriptions[i] = RemoveQuotes(test_string);
+					break;
+				case 7:
+					pHealthPointsAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 8:
+					pArmourClassAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 9:
+					pSpellPointsAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 10:
+					pPlayerConditionAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 11:
+					pFastSpellAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 12:
+					pPlayerAgeAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 13:
+					pPlayerLevelAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 14:
+					pPlayerExperienceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 15:
+					pAttackBonusAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 16:
+					pAttackDamageAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 17:
+					pMissleBonusAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 18:
+					pMissleDamageAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 19:
+					pFireResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 20:
+					pAirResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 21:
+					pWaterResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 22:
+					pEarthResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 23:
+					pMindResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 24:
+					pBodyResistanceAttributeDescription = RemoveQuotes(test_string);
+					break;
+				case 25:
+					pSkillPointsAttributeDescription = RemoveQuotes(test_string);
+					break;  
+					}
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
 
 
-  if ( pRndItemsTXT_Raw )
-  {
-    pAllocator->FreeChunk(pRndItemsTXT_Raw);
-    pRndItemsTXT_Raw = 0;
-  }
-  v39 = (char *)field_11684;
-  memset(field_11684, 0, 0x18u);
-  v40 = &pItems[0].field_2C;
-  v77 = 6;
-  do
-  {
-    v41 = v40;
-    Strh = 800;
-    do
-    {
-      *(unsigned int *)v39 += (unsigned __int8)*v41;
-      v41 += 48;
-      --Strh;
-    }
-    while ( Strh );
-    v39 += 4;
-    ++v40;
-    --v77;
-  }
-  while ( v77 );
-
-  v42 = 0;
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  strtok(0, "\r");
-  v87 = 0;
-  do
-  {
-    v43 = strtok(v42, "\r") + 1;
-    v102 = (signed int)v42;
-    v93 = (signed int)v42;
-    do
-    {
-      v44 = *v43;
-      v45 = 0;
-      while ( v44 != 9 && v44 )
-      {
-        ++v45;
-        v44 = v43[v45];
-      }
-      v78 = (int)&v43[v45];
-      if ( !v43[v45] )
-        v93 = 1;
-      v42 = 0;
-      *(unsigned char *)v78 = 0;
-      if ( v45 )
-      {
-        switch ( v102 )
-        {
-          case 2:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[24] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  *(unsigned int *)&field_1169C[48] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[0] = atoi(v43);
-            }
-            break;
-          case 3:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[28] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  *(unsigned int *)&field_1169C[52] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[4] = atoi(v43);
-            }
-            break;
-          case 4:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[32] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  *(unsigned int *)&field_1169C[56] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[8] = atoi(v43);
-            }
-            break;
-          case 5:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[36] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  field_116D8[0] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[12] = atoi(v43);
-            }
-            break;
-          case 6:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[40] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  field_116D8[1] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[16] = atoi(v43);
-            }
-            break;
-          case 7:
-            if ( v87 )
-            {
-              if ( v87 == 1 )
-              {
-                *(unsigned int *)&field_1169C[44] = atoi(v43);
-              }
-              else
-              {
-                if ( v87 == 2 )
-                  field_116D8[2] = atoi(v43);
-              }
-            }
-            else
-            {
-              *(unsigned int *)&field_1169C[20] = atoi(v43);
-            }
-            break;
-        }
-      }
-      ++v102;
-      v43 = (char *)(v78 + 1);
-    }
-    while ( v102 <= 7 && !v93 );
-    ++v87;
-  }
-  while ( v87 < 3 );
-
-
+	pClassTXT_Raw = 0;
+	pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
+	strtok(pClassTXT_Raw, "\r");
+	for (i=0; i<36; ++i)
+		{
+		test_string = strtok(NULL, "\r") + 1;
+		break_loop = false;
+		decode_step=0;
+		do 
+			{
+			c = *(unsigned char*)test_string;
+			temp_str_len = 0;
+			while((c!='\t')&&(c>0))
+				{
+				++temp_str_len;
+				c=test_string[temp_str_len];
+				}		
+			tmp_pos=test_string+temp_str_len;
+			if (*tmp_pos == 0)
+				break_loop = true;
+			*tmp_pos = 0;
+			if (temp_str_len)
+				{
+				if(i) 
+					pClassDescriptions[i]=RemoveQuotes(test_string);
+				}
+			else
+				{ 
+				if (!decode_step)
+					break_loop = true;
+				}
+			++decode_step;
+			test_string=tmp_pos+1;
+			} while ((decode_step<2)&&!break_loop);
+		}
 
-  pSkillDescTXT_Raw = 0;
-  pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
-  strtok(pSkillDescTXT_Raw, "\r");
-  v46 = 0;
-  do
-  {
-    v103 = 0;
-    v94 = 0;
-    v47 = strtok(0, "\r") + 1;
-    do
-    {
-      v48 = *v47;
-      v49 = 0;
-      while ( v48 != 9 && v48 )
-      {
-        ++v49;
-        v48 = v47[v49];
-      }
-      v50 = (int)&v47[v49];
-      if ( !v47[v49] )
-        v94 = 1;
-      *(unsigned char *)v50 = 0;
-      if ( v49 )
-      {
-        switch ( v103 )
-        {
-          case 1:
-            pSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 2:
-            pNormalSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 3:
-            pExpertSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 4:
-            pMasterSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-          case 5:
-            pGrandSkillDesc[v46] = (char *)RemoveQuotes(v47);
-            break;
-        }
-      }
-      else
-      {
-        if ( !v103 )
-          v94 = 1;
-      }
-      ++v103;
-      v47 = (char *)(v50 + 1);
-    }
-    while ( v103 <= 5 && !v94 );
-    ++v46;
-  }
-  while ( v46 < 37 );
-
-
-  pStatsTXT_Raw = 0;
-  pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
-  strtok(pStatsTXT_Raw, "\r");
-  Stri = 0;
-  do
-  {
-    v51 = 0;
-    v95 = 0;
-    v52 = strtok(0, pStatsTXT_Raw) + 1;
-    do
-    {
-      v53 = *v52;
-      v54 = 0;
-      if ( *v52 != 9 )
-      {
-        do
-        {
-          if ( !v53 )
-            break;
-          ++v54;
-          v53 = v52[v54];
-        }
-        while ( v53 != 9 );
-        v34 = "\r";
-      }
-      v55 = (int)&v52[v54];
-      if ( !v52[v54] )
-        v95 = 1;
-      *(unsigned char *)v55 = 0;
-      if ( v54 )
-      {
-        if ( v51 )
-        {
-          switch ( Stri )
-          {
-            case 0:
-            case 1:
-            case 2:
-            case 3:
-            case 4:
-            case 5:
-            case 6:
-              pAttributeDescriptions[Stri] = (char *)RemoveQuotes(v52);
-              break;
-            case 7:
-              pHealthPointsAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 8:
-              pArmourClassAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 9:
-              pSpellPointsAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 10:
-              pPlayerConditionAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 11:
-              pFastSpellAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 12:
-              pPlayerAgeAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 13:
-              pPlayerLevelAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 14:
-              pPlayerExperienceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 15:
-              pAttackBonusAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 16:
-              pAttackDamageAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 17:
-              pMissleBonusAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 18:
-              pMissleDamageAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 19:
-              pFireResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 20:
-              pAirResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 21:
-              pWaterResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 22:
-              pEarthResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 23:
-              pMindResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 24:
-              pBodyResistanceAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            case 25:
-              pSkillPointsAttributeDescription = (char *)RemoveQuotes(v52);
-              break;
-            default:
-              break;
-          }
-        }
-      }
-      else
-      {
-        if ( !v51 )
-          v95 = 1;
-      }
-      ++v51;
-      v52 = (char *)(v55 + 1);
-    }
-    while ( v51 < 2 && !v95 );
-    ++Stri;
-  }
-  while ( Stri < 26 );
-
-
-  pClassTXT_Raw = 0;
-  pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
-  strtok(pClassTXT_Raw, v34);
-  Strj = pClassDescriptions;
-  do
-  {
-    v56 = 0;
-    v57 = strtok(0, v34) + 1;
-    v96 = 0;
-    do
-    {
-      v58 = *v57;
-      v59 = 0;
-      if ( *v57 != 9 )
-      {
-        do
-        {
-          if ( !v58 )
-            break;
-          ++v59;
-          v58 = v57[v59];
-        }
-        while ( v58 != 9 );
-        v34 = "\r";
-      }
-      v60 = (int)&v57[v59];
-      if ( !v57[v59] )
-        v96 = 1;
-      *(unsigned char *)v60 = 0;
-      if ( v59 )
-      {
-        if ( v56 )
-          *Strj = (char *)RemoveQuotes(v57);
-      }
-      else
-      {
-        if ( !v56 )
-          v96 = 1;
-      }
-      ++v56;
-      v57 = (char *)(v60 + 1);
-    }
-    while ( v56 < 2 && !v96 );
-    ++Strj;
-  }
-  while ( (signed int)Strj <= (signed int)&pClassDescriptions[35] );
-}
+	}
 
 //----- (00456D17) --------------------------------------------------------
 void ItemsTable::SetSpecialBonus(ItemGen *pItem)
@@ -2251,7 +1670,7 @@
     if ( v53 == -1 )
     {
       v53 = (int)&v5->pItems[1].uEquipType;
-      v9 = (int)(&v5->pItems[1].field_2C + v6);
+      v9 = (int)(&v5->pItems[1].uChanceByTreasureLvl[0] + v6);
       do
       {
         if ( *(unsigned char *)v53 == a3 )
@@ -2269,7 +1688,7 @@
     else
     {
       v55 = (int)&v5->pItems[1].uSkillType;
-      v8 = (int)(&v5->pItems[1].field_2C + v6);
+      v8 = (int)(&v5->pItems[1].uChanceByTreasureLvl[0] + v6);
       do
       {
         if ( *(unsigned char *)v55 == v53 )
@@ -2290,7 +1709,7 @@
     v4->uItemID = *(uint *)Dst;
     if ( !Dst )
       v4->uItemID = 1;
-    v11 = *(&v5->pItems[v4->uItemID].field_2C + v54);
+    v11 = *(&v5->pItems[v4->uItemID].uChanceByTreasureLvl[0] + v54);
     if ( v11 < v10 )
     {
       v12 = (uint *)Dst;
@@ -2299,7 +1718,7 @@
         ++v12;
         v13 = *v12;
         v4->uItemID = *v12;
-        v11 += *(&v5->pItems[v13].field_2C + v54);
+        v11 += *(&v5->pItems[v13].uChanceByTreasureLvl[0] + v54);
       }
       while ( v11 < v10 );
     }
@@ -2336,12 +1755,12 @@
       return;
     }
     v57 = 0;
-    v18 = rand() % v5->field_11684[v54];
+    v18 = rand() % 10;// v5->field_11684[v54];
     v4->uItemID = 0;
     if ( v18 > 0 )
     {
       do
-        v57 += *(&v5->pItems[v4->uItemID++ + 1].field_2C + v54);
+        v57 += *(&v5->pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[0] + v54);
       while ( v57 < v18 );
     }
     if ( !v18 )
@@ -2378,7 +1797,7 @@
   v20 = v5->pItems[v4->uItemID].uEquipType;
   if ( v20 <= EQUIP_BOW )
   {
-    v37 = (int)&v5->field_1169C[4 * v54 + 48];
+    v37 = 10;//(int)&v5->field_1169C[4 * v54 + 48];
     if ( !*(unsigned int *)v37 )
       return;
     v38 = rand() % 100;
@@ -2397,7 +1816,7 @@
       }
       return;
     }
-    v22 = (int)&v5->field_1169C[4 * v54];
+    v22 = (int)&v5->uBonusChanceStandart[v54];
     if ( !*(unsigned int *)v22 )
       return;
     v23 = rand();
@@ -2405,12 +1824,12 @@
     v25 = v23 % 100;
     if ( v23 % 100 < v24 )
       goto LABEL_127;
-    if ( !*(unsigned int *)&v5->field_1169C[4 * v54 + 24] )
-      return;
+    if ( !v5->uBonusChanceSpecial[v54] )
+        return;
     if ( v25 < v24 )
     {
 LABEL_127:
-      v26 = rand() % v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
+      v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
       v27 = v4->uItemID;
       v4->_bonus_type = 0;
       for ( i = v5->pEnchantments[0].to_item[v5->pItems[v27].uEquipType + 1];
@@ -2421,10 +1840,10 @@
         ++v4->_bonus_type;
       }
       ++v4->_bonus_type;
-      v30 = v5->field_116D8[2 * v54 + 12];
+      v30 = 10;// v5->field_116D8[2 * v54 + 12];
       v31 = rand();
       v32 = v4->_bonus_type - 1;
-      v33 = v31 % (v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
+      v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
       v4->_bonus_strength = v33;
       if ( v32 == 21 || v32 == 22 || v32 == 23 )
         v4->_bonus_strength = v33 >> 1;
@@ -2432,7 +1851,7 @@
         v4->_bonus_strength = 1;
       return;
     }
-    v34 = v24 + *(unsigned int *)&v5->field_1169C[4 * v54 + 24];
+    v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24];
     v36 = __OFSUB__(v25, v34);
     v35 = v25 - v34 < 0;
   }
--- a/Items.h	Sun Feb 17 11:41:44 2013 +0400
+++ b/Items.h	Sun Feb 17 14:46:05 2013 +0400
@@ -143,16 +143,22 @@
   char _additional_value; //22 26
   char _bonus_type; //23  27
   char _bonus_strength; //24 28
-  char field_25;  //
-  char field_26;
-  char field_27;
-  char field_28; 
-  char field_29;
-  char field_2a;
-  char field_2b;
-  char field_2C;
-  unsigned char uItemID_Rep_St; //2d
-  char field_2e;
+  char field_25;  // 25  29
+  char field_26;  //26   2A
+  char field_27; // 27   2b
+  union
+	  {
+	unsigned __int8 uChanceByTreasureLvl[6];
+  struct {
+  unsigned __int8 uChanceByTreasureLvl1; // 28  2c
+  unsigned __int8 uChanceByTreasureLvl2;  // 29  2d 
+  unsigned __int8 uChanceByTreasureLvl3;  // 2A   2e
+  unsigned __int8 uChanceByTreasureLvl4;  // 2B  2f
+  unsigned __int8 uChanceByTreasureLvl5;  // 2C  30
+  unsigned __int8 uChanceByTreasureLvl6;  // 2D  32
+	  };
+	  };
+  unsigned char uItemID_Rep_St; //2e 32
   char field_2f;
 };
 #pragma pack(pop)
@@ -220,24 +226,25 @@
   ItemDesc pItems[800]; //4-9604h
   ItemEnchantment pEnchantments[24]; //9604h
   ItemSpecialEnchantment pSpecialEnchantments[72]; //97E4h
-  char field_9FC0[5000];
+  char field_9FC4[5000];
   char field_B348[5000];
   char field_C6D0[5000];
   char field_DA58[5000];
-  char field_EDE0[184];
+  char field_EDE0[180];
   unsigned __int16 potion_data[50][50]; // 77B2h*2=EF64h  -102ECh
   unsigned __int16 potion_note[50][50]; // 8176h*2=102ECh -11674h
   char *pItemsTXT_Raw; //11674h
   char *pRndItemsTXT_Raw;
   char *pStdItemsTXT_Raw; //1167Ch
   char *pSpcItemsTXT_Raw; //11680h
-  int field_11684[6];
-  char field_1169C[60];
-  int field_116D8[3];
+  unsigned int uChanceByTreasureLvlSumm[6]; //11684
+  unsigned int uBonusChanceStandart[6]; //1169c
+  unsigned int uBonusChanceSpecial[6]; //116B4
+  unsigned int uBonusChanceWpSpecial[6]; //116cc -116e4
   unsigned int pEnchantmentsSumm[9]; //116E4h -11708h
   BonusRange bonus_ranges[6]; //45C2h*4 =11708h
-  int pSpecialEnchantmentsSumm[24]; //11738h
-  int pSpecialEnchantments_count; //11798h
+  unsigned int pSpecialEnchantmentsSumm[24]; //11738h
+  unsigned int pSpecialEnchantments_count; //11798h
   char field_1179C;
 };
 #pragma pack(pop)
--- a/mm7_6.cpp	Sun Feb 17 11:41:44 2013 +0400
+++ b/mm7_6.cpp	Sun Feb 17 14:46:05 2013 +0400
@@ -5265,7 +5265,7 @@
                             v313 = *(char *)(LODWORD(v725) + 28);
                             if ( v313 == 3 | v313 == 4 | v313 == 5 | v313 == 6 | v313 == 7 | v313 == 8 | v313 == 9 | v313 == 10 | v313 == 11 )
                             {
-                              v314 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
+                              v314 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
                               *(int *)(v245 + 4) = 0;
                               for ( j = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType
                                                                            + 1];
@@ -5278,8 +5278,8 @@
                                   break;
                               }
                               v254 = rand();
-                              v255 = pItemsTable->field_116D8[17];
-                              v256 = pItemsTable->field_116D8[16];
+                              v255 = 10;//pItemsTable->field_116D8[17];
+                              v256 = 10;//pItemsTable->field_116D8[16];
 LABEL_611:
                               *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1);
 LABEL_612:
@@ -5352,7 +5352,7 @@
               if ( rand() % 100 < 80
                 && !(*(char *)(LODWORD(v273) + 28) == 0 | *(char *)(LODWORD(v273) + 28) == 1 | *(char *)(LODWORD(v273) + 28) == 2) )
               {
-                v275 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
+                v275 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
                 *(int *)(v245 + 4) = 0;
                 for ( k = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
                       ;
@@ -5364,8 +5364,8 @@
                     break;
                 }
                 v254 = rand();
-                v255 = pItemsTable->field_116D8[19];
-                v256 = pItemsTable->field_116D8[18];
+                v255 = 10;//pItemsTable->field_116D8[19];
+                v256 = 10;//pItemsTable->field_116D8[18];
                 goto LABEL_611;
               }
               v277 = pItemsTable->pSpecialEnchantments_count;
@@ -5450,7 +5450,7 @@
               if ( rand() % 100 < 80
                 && !(*(char *)(LODWORD(v250) + 28) == 0 | *(char *)(LODWORD(v250) + 28) == 1 | *(char *)(LODWORD(v250) + 28) == 2) )
               {
-                v252 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
+                v252 = rand() % 10;//pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
                 *(int *)(v245 + 4) = 0;
                 for ( m = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
                       ;
@@ -5462,8 +5462,8 @@
                     break;
                 }
                 v254 = rand();
-                v255 = pItemsTable->field_116D8[21];
-                v256 = pItemsTable->field_116D8[20];
+                v255 = 10;// pItemsTable->field_116D8[21];
+                v256 =  10;//pItemsTable->field_116D8[20];
                 goto LABEL_611;
               }
               v257 = pItemsTable->pSpecialEnchantments_count;
@@ -5602,7 +5602,7 @@
         {
           v293 = rand();
           v294 = _this;
-          v295 = v293 % pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
+          v295 = v293 % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
           _this->_bonus_type = 0;
           for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1];
                 ;
@@ -5613,8 +5613,8 @@
             if ( kk >= v295 )
               break;
           }
-          v294->_bonus_strength = pItemsTable->field_116D8[18]
-                                + rand() % (pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1);
+          v294->_bonus_strength = 10//pItemsTable->field_116D8[18]
+                                + rand() % 10;//(pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1);
         }
         v294->uAttributes |= 0x20u;
         goto LABEL_1055;