diff Engine/Objects/Items.cpp @ 2567:d569340b05ff

Few constants changed into enum values
author a.parshin
date Thu, 21 May 2015 01:50:59 +0200
parents a902abdfc7f2
children
line wrap: on
line diff
--- a/Engine/Objects/Items.cpp	Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Objects/Items.cpp	Thu May 21 01:50:59 2015 +0200
@@ -159,101 +159,101 @@
 
 
 //----- (00439DF3) --------------------------------------------------------
-int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP)
-	{
+int ItemGen::_439DF3_get_additional_damage(DAMAGE_TYPE *damage_type, bool *draintargetHP)
+{
     *draintargetHP = false;
-	*damage_type = 0;
-	if ( !uItemID )
-		return 0;
-	UpdateTempBonus(pParty->uTimePlayed);
-	if (uItemID == 501 )  //Iron Feather -sword
-		{
-		*damage_type = 1;
-		return rand() % 10 + 6;
-		}
-	if (uItemID == 507 ) //Ghoulsbane  -axe
-		{
-		*damage_type = 0;
-		return rand() % 16 + 3;
-		}
-	if ( uItemID == 510 ) //Ullyses  -bow
-		{
-		*damage_type = 2;
-		return rand() % 4 + 9;
-		}
-	if ( uItemID == 517 ) //Old Nick -dagger
-		{
-		*damage_type = 8;
-		return 8;
-		}
+    *damage_type = DMGT_FIRE;
+    if (uItemID == ITEM_NULL)
+        return 0;
+
+    UpdateTempBonus(pParty->uTimePlayed);
+    if (uItemID == ITEM_ARTIFACT_IRON_FEATHER)
+    {
+        *damage_type = DMGT_ELECTR;
+        return rand() % 10 + 6;
+    }
+    if (uItemID == ITEM_ARTIFACT_GHOULSBANE)
+    {
+        *damage_type = DMGT_FIRE;
+        return rand() % 16 + 3;
+    }
+    if (uItemID == ITEM_ARTEFACT_ULLYSES)
+    {
+        *damage_type = DMGT_COLD;
+        return rand() % 4 + 9;
+    }
+    if (uItemID == ITEM_RELIC_OLD_NICK)
+    {
+        *damage_type = DMGT_BODY;
+        return 8;
+    }
 
-	switch (uSpecEnchantmentType)
-		{
-	case 4:  //Adds 3-4 points of Cold damage.
-		*damage_type = 2;
-		return rand() % 2 + 3;
-		break;
-	case 5:  //Adds 6-8 points of Cold damage.
-		*damage_type = 2;
-		return rand() % 3 + 6;
-		break;
-	case 6: //Adds 9-12 points of Cold damage.
-		*damage_type = 2;
-		return rand() % 4 + 9;
-		break;
-	case 7: //Adds 2-5 points of Electrical damage.
-		*damage_type = 1;
-		return rand() % 4 + 2;
-		break;
-	case 8: //Adds 4-10 points of Electrical damage.
-		*damage_type = 1;
-		return rand() % 7 + 4;
-		break;
-	case 9: //Adds 6-15 points of Electrical damage.
-		*damage_type = 1;
-		return rand() % 10 + 6;
-		break;
-	case 10: //Adds 1-6 points of Fire damage.
-		*damage_type = 0;
-		return GetDiceResult(1, 6);
-		break;
-	case 11: //Adds 2-12 points of Fire damage.
-		*damage_type = 0;
-		return GetDiceResult(2, 6);
-		break;
-	case 12: //Adds 3-18 points of Fire damage.
-		*damage_type = 0;
-		return GetDiceResult(3, 6);
-		break;
-	case 13: //Adds 5 points of Body damage.
-		*damage_type = 8;
-		return 5;
-		break;
-	case 14: //Adds 8 points of Body damage.
-		*damage_type = 8;
-		return 8;
-		break;
-	case 15: //Adds 12 points of Body damage.
-		*damage_type = 8;
-		return 12;
-		break;
-	case 16: //Drain Hit Points from target.
-	case 41: //Drain Hit Points from target and Increased Weapon speed.
-		*damage_type = 10;
-		*draintargetHP = true;
-		return 0;
-		break;
-	case 46:  //Adds 10-20 points of Fire damage and +25 Might.
-		*damage_type = 0;
-		return rand() % 11 + 10;
-		break;
-	default:
-		*damage_type = 0;
-		return 0;
+    switch (special_enchantment)
+    {
+    case ITEM_ENCHANTMENT_OF_COLD:
+        *damage_type = DMGT_COLD;
+        return rand() % 2 + 3;
+        break;
+    case ITEM_ENCHANTMENT_OF_FROST:
+        *damage_type = DMGT_COLD;
+        return rand() % 3 + 6;
+        break;
+    case ITEM_ENCHANTMENT_OF_ICE:
+        *damage_type = DMGT_COLD;
+        return rand() % 4 + 9;
+        break;
+    case ITEM_ENCHANTMENT_OF_SPARKS:
+        *damage_type = DMGT_ELECTR;
+        return rand() % 4 + 2;
+        break;
+    case ITEM_ENCHANTMENT_OF_LIGHTNING:
+        *damage_type = DMGT_ELECTR;
+        return rand() % 7 + 4;
+        break;
+    case ITEM_ENCHANTMENT_OF_THUNDERBOLTS:
+        *damage_type = DMGT_ELECTR;
+        return rand() % 10 + 6;
+        break;
+    case ITEM_ENCHANTMENT_OF_FIRE:
+        *damage_type = DMGT_FIRE;
+        return GetDiceResult(1, 6);
+        break;
+    case ITEM_ENCHANTMENT_OF_FLAME:
+        *damage_type = DMGT_FIRE;
+        return GetDiceResult(2, 6);
+        break;
+    case ITEM_ENCHANTMENT_OF_INFERNOS:
+        *damage_type = DMGT_FIRE;
+        return GetDiceResult(3, 6);
+        break;
+    case ITEM_ENCHANTMENT_OF_POISON:
+        *damage_type = DMGT_BODY;
+        return 5;
+        break;
+    case ITEM_ENCHANTMENT_OF_VENOM:
+        *damage_type = DMGT_BODY;
+        return 8;
+        break;
+    case ITEM_ENCHANTMENT_OF_ACID:
+        *damage_type = DMGT_BODY;
+        return 12;
+        break;
+    case ITEM_ENCHANTMENT_VAMPIRIC:
+    case ITEM_ENCHANTMENT_OF_DARKNESS:
+        *damage_type = DMGT_DARK;
+        *draintargetHP = true;
+        return 0;
+        break;
 
-		}
-
-	}
+    case ITEM_ENCHANTMENT_OF_DRAGON:
+        *damage_type = DMGT_FIRE;
+        return rand() % 11 + 10;
+        break;
+    default:
+        *damage_type = DMGT_FIRE;
+        return 0;
+    }
+}
 
 
 //----- (00402F07) --------------------------------------------------------
@@ -262,10 +262,10 @@
   this->uHolderPlayer = 0;
   this->uAttributes = 0;
   this->uNumCharges = 0;
-  this->uSpecEnchantmentType = 0;
+  this->special_enchantment = ITEM_ENCHANTMENT_NULL;
   this->m_enchantmentStrength = 0;
   this->uEnchantmentType = 0;
-  this->uItemID = 0;
+  this->uItemID = ITEM_NULL;
   this->uBodyAnchor = 0;
   this->uExpireTime = 0i64;
 }
@@ -278,7 +278,7 @@
     if ( uTimePlayed > (signed __int64)this->uExpireTime )
     {
       this->uEnchantmentType = 0;
-      this->uSpecEnchantmentType = 0;
+      this->special_enchantment = ITEM_ENCHANTMENT_NULL;
       this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS);
     }
   }
@@ -315,414 +315,414 @@
 //----- (00456D84) --------------------------------------------------------
 void ItemsTable::Initialize()
 {
-  std::map<std::string, ITEM_EQUIP_TYPE, ci_less> equipStatMap;
-  equipStatMap["weapon"] = EQUIP_SINGLE_HANDED;
-  equipStatMap["weapon2"] = EQUIP_TWO_HANDED;
-  equipStatMap["weapon1or2"] = EQUIP_SINGLE_HANDED;
-  equipStatMap["missile"] = EQUIP_BOW;
-  equipStatMap["bow"] = EQUIP_BOW;
-  equipStatMap["armor"] = EQUIP_ARMOUR;
-  equipStatMap["shield"] = EQUIP_SHIELD;
-  equipStatMap["helm"] = EQUIP_HELMET;
-  equipStatMap["belt"] = EQUIP_BELT;
-  equipStatMap["cloak"] = EQUIP_CLOAK;
-  equipStatMap["gauntlets"] = EQUIP_GAUNTLETS;
-  equipStatMap["boots"] = EQUIP_BOOTS;
-  equipStatMap["ring"] = EQUIP_RING;
-  equipStatMap["amulet"] = EQUIP_AMULET;
-  equipStatMap["weaponw"] = EQUIP_WAND;
-  equipStatMap["herb"] = EQUIP_REAGENT;
-  equipStatMap["reagent"] = EQUIP_REAGENT;
-  equipStatMap["bottle"] = EQUIP_POTION;
-  equipStatMap["sscroll"] = EQUIP_SPELL_SCROLL;
-  equipStatMap["book"] = EQUIP_BOOK;
-  equipStatMap["mscroll"] = EQUIP_MESSAGE_SCROLL;
-  equipStatMap["gold"] = EQUIP_GOLD;
-  equipStatMap["gem"] = EQUIP_GEM;
+    std::map<std::string, ITEM_EQUIP_TYPE, ci_less> equipStatMap;
+    equipStatMap["weapon"] = EQUIP_SINGLE_HANDED;
+    equipStatMap["weapon2"] = EQUIP_TWO_HANDED;
+    equipStatMap["weapon1or2"] = EQUIP_SINGLE_HANDED;
+    equipStatMap["missile"] = EQUIP_BOW;
+    equipStatMap["bow"] = EQUIP_BOW;
+    equipStatMap["armor"] = EQUIP_ARMOUR;
+    equipStatMap["shield"] = EQUIP_SHIELD;
+    equipStatMap["helm"] = EQUIP_HELMET;
+    equipStatMap["belt"] = EQUIP_BELT;
+    equipStatMap["cloak"] = EQUIP_CLOAK;
+    equipStatMap["gauntlets"] = EQUIP_GAUNTLETS;
+    equipStatMap["boots"] = EQUIP_BOOTS;
+    equipStatMap["ring"] = EQUIP_RING;
+    equipStatMap["amulet"] = EQUIP_AMULET;
+    equipStatMap["weaponw"] = EQUIP_WAND;
+    equipStatMap["herb"] = EQUIP_REAGENT;
+    equipStatMap["reagent"] = EQUIP_REAGENT;
+    equipStatMap["bottle"] = EQUIP_POTION;
+    equipStatMap["sscroll"] = EQUIP_SPELL_SCROLL;
+    equipStatMap["book"] = EQUIP_BOOK;
+    equipStatMap["mscroll"] = EQUIP_MESSAGE_SCROLL;
+    equipStatMap["gold"] = EQUIP_GOLD;
+    equipStatMap["gem"] = EQUIP_GEM;
 
-  std::map<std::string, PLAYER_SKILL_TYPE, ci_less> equipSkillMap;
-  equipSkillMap["staff"] = PLAYER_SKILL_STAFF;
-  equipSkillMap["sword"] = PLAYER_SKILL_SWORD;
-  equipSkillMap["dagger"] = PLAYER_SKILL_DAGGER;
-  equipSkillMap["axe"] = PLAYER_SKILL_AXE;
-  equipSkillMap["spear"] = PLAYER_SKILL_SPEAR;
-  equipSkillMap["bow"] = PLAYER_SKILL_BOW;
-  equipSkillMap["mace"] = PLAYER_SKILL_MACE;
-  equipSkillMap["blaster"] = PLAYER_SKILL_BLASTER;
-  equipSkillMap["shield"] = PLAYER_SKILL_SHIELD;
-  equipSkillMap["leather"] = PLAYER_SKILL_LEATHER;
-  equipSkillMap["chain"] = PLAYER_SKILL_CHAIN;
-  equipSkillMap["plate"] = PLAYER_SKILL_PLATE;
-  equipSkillMap["club"] = PLAYER_SKILL_CLUB;
-  
-  std::map<std::string, ITEM_MATERIAL, ci_less> materialMap;
-  materialMap["artifact"] = MATERIAL_ARTEFACT;
-  materialMap["relic"] = MATERIAL_RELIC;
-  materialMap["special"] = MATERIAL_SPECIAL;
+    std::map<std::string, PLAYER_SKILL_TYPE, ci_less> equipSkillMap;
+    equipSkillMap["staff"] = PLAYER_SKILL_STAFF;
+    equipSkillMap["sword"] = PLAYER_SKILL_SWORD;
+    equipSkillMap["dagger"] = PLAYER_SKILL_DAGGER;
+    equipSkillMap["axe"] = PLAYER_SKILL_AXE;
+    equipSkillMap["spear"] = PLAYER_SKILL_SPEAR;
+    equipSkillMap["bow"] = PLAYER_SKILL_BOW;
+    equipSkillMap["mace"] = PLAYER_SKILL_MACE;
+    equipSkillMap["blaster"] = PLAYER_SKILL_BLASTER;
+    equipSkillMap["shield"] = PLAYER_SKILL_SHIELD;
+    equipSkillMap["leather"] = PLAYER_SKILL_LEATHER;
+    equipSkillMap["chain"] = PLAYER_SKILL_CHAIN;
+    equipSkillMap["plate"] = PLAYER_SKILL_PLATE;
+    equipSkillMap["club"] = PLAYER_SKILL_CLUB;
 
-  char* test_string;
-  int item_counter;
+    std::map<std::string, ITEM_MATERIAL, ci_less> materialMap;
+    materialMap["artifact"] = MATERIAL_ARTEFACT;
+    materialMap["relic"] = MATERIAL_RELIC;
+    materialMap["special"] = MATERIAL_SPECIAL;
 
-	pMapStats = new MapStats;
-	pMapStats->Initialize();
+    char* test_string;
+    int item_counter;
+
+    pMapStats = new MapStats;
+    pMapStats->Initialize();
 
-	pMonsterStats = new MonsterStats;
-	pMonsterStats->Initialize();
-	pMonsterStats->InitializePlacements();
+    pMonsterStats = new MonsterStats;
+    pMonsterStats->Initialize();
+    pMonsterStats->InitializePlacements();
 
-	pSpellStats = new SpellStats;
-	pSpellStats->Initialize();
+    pSpellStats = new SpellStats;
+    pSpellStats->Initialize();
 
-	LoadPotions();
-	LoadPotionNotes();
+    LoadPotions();
+    LoadPotionNotes();
 
-	pFactionTable = new FactionTable;
-	pFactionTable->Initialize();
+    pFactionTable = new FactionTable;
+    pFactionTable->Initialize();
 
-	pStorylineText = new StorylineText;
-	pStorylineText->Initialize();
+    pStorylineText = new StorylineText;
+    pStorylineText->Initialize();
 
-	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 (int i=0;i<24;++i)
-		{
-		test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    pEnchantments[i].pBonusStat=RemoveQuotes(tokens[0]);
-    pEnchantments[i].pOfName=RemoveQuotes(tokens[1]);
-    for (int j = 0; j < 9; j++)
+    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 (int i = 0; i < 24; ++i)
     {
-      pEnchantments[i].to_item[j]=atoi(tokens[j+2]);
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        pEnchantments[i].pBonusStat = RemoveQuotes(tokens[0]);
+        pEnchantments[i].pOfName = RemoveQuotes(tokens[1]);
+        for (int j = 0; j < 9; j++)
+        {
+            pEnchantments[i].to_item[j] = atoi(tokens[j + 2]);
+        }
     }
-	}
 
-	memset(&pEnchantmentsSumm, 0, 36);
-	for(int i=0;i<9;++i)
-		{
-		for (int j=0;j<24;++j)
-			pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i];
-		}
+    memset(&pEnchantmentsSumm, 0, 36);
+    for (int i = 0; i < 9; ++i)
+    {
+        for (int 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(int i=0;i<6;++i) //counted from 1
-  {
-    test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() == 4, "Invalid number of tokens");
-    bonus_ranges[i].minR = atoi(tokens[2]);
-    bonus_ranges[i].maxR =atoi(tokens[3]);
-	}
+    //Bonus range for Standard by Level
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    for (int i = 0; i < 6; ++i) //counted from 1
+    {
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() == 4, "Invalid number of tokens");
+        bonus_ranges[i].minR = atoi(tokens[2]);
+        bonus_ranges[i].maxR = atoi(tokens[3]);
+    }
 
 
-	pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
-	strtok(pSpcItemsTXT_Raw, "\r");
-	strtok(NULL, "\r");
-	strtok(NULL, "\r");
-	strtok(NULL, "\r");
-	for (int i=0;i<72;++i)
-	{
-    test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() >= 17, "Invalid number of tokens");
-    pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(tokens[0]);
-    pSpecialEnchantments[i].pNameAdd= RemoveQuotes(tokens[1]);
-    for (int j = 0; j < 12; j++)
+    pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0);
+    strtok(pSpcItemsTXT_Raw, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    for (int i = 0; i < 72; ++i)
     {
-      pSpecialEnchantments[i].to_item_apply[j]=atoi(tokens[j+2]);
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() >= 17, "Invalid number of tokens");
+        pSpecialEnchantments[i].pBonusStatement = RemoveQuotes(tokens[0]);
+        pSpecialEnchantments[i].pNameAdd = RemoveQuotes(tokens[1]);
+        for (int j = 0; j < 12; j++)
+        {
+            pSpecialEnchantments[i].to_item_apply[j] = atoi(tokens[j + 2]);
+        }
+        int res;
+        res = atoi(tokens[14]);
+        if (!res)
+        {
+            ++tokens[14];
+            while (*tokens[14] == ' ')//fix X 2 case
+                ++tokens[14];
+            res = atoi(tokens[14]);
+        }
+        pSpecialEnchantments[i].iValue = res;
+        pSpecialEnchantments[i].iTreasureLevel = tolower(tokens[15][0]) - 97;
     }
-    int res;
-    res=atoi(tokens[14]);
-    if(!res)
+
+    pSpecialEnchantments_count = 71;
+    memset(&pSpecialEnchantmentsSumm, 0, 96);
+    for (int i = 0; i < 12; ++i)
     {
-      ++tokens[14]; 
-      while (*tokens[14]==' ')//fix X 2 case
-        ++tokens[14]; 
-      res=atoi(tokens[14]);
-    }				
-    pSpecialEnchantments[i].iValue=res;
-    pSpecialEnchantments[i].iTreasureLevel=  tolower(tokens[15][0]) - 97;
-	}
+        for (unsigned int j = 0; j <= pSpecialEnchantments_count; ++j)
+            pSpecialEnchantmentsSumm[i] += pSpecialEnchantments[j].to_item_apply[i];
+    }
 
-	pSpecialEnchantments_count = 71;
-	memset(&pSpecialEnchantmentsSumm, 0, 96);
-	for(int i=0;i<12;++i)
-		{
-		for (unsigned int j=0;j<=pSpecialEnchantments_count;++j)
-			pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
-		}
-
-	InitializeBuildingResidents();
+    InitializeBuildingResidents();
 
-	pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0);
-	strtok(pItemsTXT_Raw, "\r");
-	strtok(NULL, "\r");
-	uAllItemsCount = 0;
-	item_counter = 0;
-	while (item_counter < 800)
-	{
-	test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    item_counter=atoi(tokens[0]);
-    uAllItemsCount=item_counter;
-    pItems[item_counter].pIconName = RemoveQuotes(tokens[1]);
-    pItems[item_counter].pName = RemoveQuotes(tokens[2]);
-    pItems[item_counter].uValue=atoi(tokens[3]);
-    auto findResult = equipStatMap.find(tokens[4]);
-    pItems[item_counter].uEquipType = findResult == equipStatMap.end() ? EQUIP_NONE : findResult->second;
-    auto findResult2 = equipSkillMap.find(tokens[5]);
-    pItems[item_counter].uSkillType = findResult2 == equipSkillMap.end() ? PLAYER_SKILL_MISC : findResult2->second;
-    auto tokens2 = Tokenize(tokens[6], 'd');
-    if (tokens2.size() == 2)
-    {
-      pItems[item_counter].uDamageDice=atoi(tokens2[0]);
-      pItems[item_counter].uDamageRoll=atoi(tokens2[1]);
-    }
-    else if (tolower(tokens2[0][0]) != 's')
-    {
-      pItems[item_counter].uDamageDice=atoi(tokens2[0]);
-      pItems[item_counter].uDamageRoll=1;
-    }
-    else
+    pItemsTXT_Raw = (char*)pEvents_LOD->LoadRaw("items.txt", 0);
+    strtok(pItemsTXT_Raw, "\r");
+    strtok(NULL, "\r");
+    uAllItemsCount = 0;
+    item_counter = 0;
+    while (item_counter < 800)
     {
-      pItems[item_counter].uDamageDice=0;
-      pItems[item_counter].uDamageRoll=0;
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        item_counter = atoi(tokens[0]);
+        uAllItemsCount = item_counter;
+        pItems[item_counter].pIconName = RemoveQuotes(tokens[1]);
+        pItems[item_counter].pName = RemoveQuotes(tokens[2]);
+        pItems[item_counter].uValue = atoi(tokens[3]);
+        auto findResult = equipStatMap.find(tokens[4]);
+        pItems[item_counter].uEquipType = findResult == equipStatMap.end() ? EQUIP_NONE : findResult->second;
+        auto findResult2 = equipSkillMap.find(tokens[5]);
+        pItems[item_counter].uSkillType = findResult2 == equipSkillMap.end() ? PLAYER_SKILL_MISC : findResult2->second;
+        auto tokens2 = Tokenize(tokens[6], 'd');
+        if (tokens2.size() == 2)
+        {
+            pItems[item_counter].uDamageDice = atoi(tokens2[0]);
+            pItems[item_counter].uDamageRoll = atoi(tokens2[1]);
+        }
+        else if (tolower(tokens2[0][0]) != 's')
+        {
+            pItems[item_counter].uDamageDice = atoi(tokens2[0]);
+            pItems[item_counter].uDamageRoll = 1;
+        }
+        else
+        {
+            pItems[item_counter].uDamageDice = 0;
+            pItems[item_counter].uDamageRoll = 0;
+        }
+        pItems[item_counter].uDamageMod = atoi(tokens[7]);
+        auto findResult3 = materialMap.find(tokens[8]);
+        pItems[item_counter].uMaterial = findResult3 == materialMap.end() ? MATERIAL_COMMON : findResult3->second;
+        pItems[item_counter].uItemID_Rep_St = atoi(tokens[9]);
+        pItems[item_counter].pUnidentifiedName = RemoveQuotes(tokens[10]);
+        pItems[item_counter].uSpriteID = atoi(tokens[11]);
+
+        pItems[item_counter]._additional_value = 0;
+        pItems[item_counter]._bonus_type = 0;
+        if (pItems[item_counter].uMaterial == MATERIAL_SPECIAL)
+        {
+            for (int ii = 0; ii < 24; ++ii)
+            {
+                if (!_stricmp(tokens[12], pEnchantments[ii].pOfName))
+                {
+                    pItems[item_counter]._bonus_type = ii + 1;
+                    break;
+                }
+            }
+            if (!pItems[item_counter]._bonus_type)
+            {
+                for (int ii = 0; ii < 72; ++ii)
+                {
+                    if (!_stricmp(tokens[12], pSpecialEnchantments[ii].pNameAdd))
+                    {
+                        pItems[item_counter]._additional_value = ii + 1;
+                    }
+                }
+            }
+        }
+
+        if ((pItems[item_counter].uMaterial == MATERIAL_SPECIAL) && (pItems[item_counter]._bonus_type))
+        {
+            char b_s = atoi(tokens[13]);
+            if (b_s)
+                pItems[item_counter]._bonus_strength = b_s;
+            else
+                pItems[item_counter]._bonus_strength = 1;
+        }
+        else
+            pItems[item_counter]._bonus_strength = 0;
+        pItems[item_counter].uEquipX = atoi(tokens[14]);
+        pItems[item_counter].uEquipY = atoi(tokens[15]);
+        pItems[item_counter].pDescription = RemoveQuotes(tokens[16]);
+        item_counter++;
     }
-    pItems[item_counter].uDamageMod=atoi(tokens[7]);
-    auto findResult3 = materialMap.find(tokens[8]);
-    pItems[item_counter].uMaterial = findResult3 == materialMap.end() ? MATERIAL_COMMON : findResult3->second;
-    pItems[item_counter].uItemID_Rep_St=atoi(tokens[9]);
-    pItems[item_counter].pUnidentifiedName = RemoveQuotes(tokens[10]);
-    pItems[item_counter].uSpriteID=atoi(tokens[11]);
 
-    pItems[item_counter]._additional_value=0;
-    pItems[item_counter]._bonus_type=0;
-    if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL)
+    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");
+    for (item_counter = 0; item_counter < 619; item_counter++)
     {
-      for(int ii=0; ii<24; ++ii)
-      {
-        if (!_stricmp(tokens[12],pEnchantments[ii].pOfName))
-        {
-          pItems[item_counter]._bonus_type=ii+1;
-          break;
-        }
-      }
-      if (!pItems[item_counter]._bonus_type)
-      {
-        for(int ii=0; ii<72; ++ii)
-        {
-          if (!_stricmp(tokens[12],pSpecialEnchantments[ii].pNameAdd))
-          {
-            pItems[item_counter]._additional_value=ii+1;
-          }
-        }
-      }
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() > 7, "Invalid number of tokens");
+        item_counter = atoi(tokens[0]);
+        pItems[item_counter].uChanceByTreasureLvl1 = atoi(tokens[2]);
+        pItems[item_counter].uChanceByTreasureLvl2 = atoi(tokens[3]);
+        pItems[item_counter].uChanceByTreasureLvl3 = atoi(tokens[4]);
+        pItems[item_counter].uChanceByTreasureLvl4 = atoi(tokens[5]);
+        pItems[item_counter].uChanceByTreasureLvl5 = atoi(tokens[6]);
+        pItems[item_counter].uChanceByTreasureLvl6 = atoi(tokens[7]);
+    }
+
+    //ChanceByTreasureLvl Summ - to calculate chance
+    memset(&uChanceByTreasureLvlSumm, 0, 24);
+    for (int i = 0; i < 6; ++i)
+    {
+        for (int j = 1; j < item_counter; ++j)
+            uChanceByTreasureLvlSumm[i] += pItems[j].uChanceByTreasureLvl[i];
     }
 
-    if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type))
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    strtok(NULL, "\r");
+    for (int i = 0; i < 3; ++i)
     {
-      char b_s=atoi(tokens[13]);
-      if (b_s)
-        pItems[item_counter]._bonus_strength=b_s;
-      else
-        pItems[item_counter]._bonus_strength=1;
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() > 7, "Invalid number of tokens");
+        switch (i)
+        {
+        case 0:
+            uBonusChanceStandart[0] = atoi(tokens[2]);
+            uBonusChanceStandart[1] = atoi(tokens[3]);
+            uBonusChanceStandart[2] = atoi(tokens[4]);
+            uBonusChanceStandart[3] = atoi(tokens[5]);
+            uBonusChanceStandart[4] = atoi(tokens[6]);
+            uBonusChanceStandart[5] = atoi(tokens[7]);
+            break;
+        case 1:
+            uBonusChanceSpecial[0] = atoi(tokens[2]);
+            uBonusChanceSpecial[1] = atoi(tokens[3]);
+            uBonusChanceSpecial[2] = atoi(tokens[4]);
+            uBonusChanceSpecial[3] = atoi(tokens[5]);
+            uBonusChanceSpecial[4] = atoi(tokens[6]);
+            uBonusChanceSpecial[5] = atoi(tokens[7]);
+            break;
+        case 2:
+            uBonusChanceWpSpecial[0] = atoi(tokens[2]);
+            uBonusChanceWpSpecial[1] = atoi(tokens[3]);
+            uBonusChanceWpSpecial[2] = atoi(tokens[4]);
+            uBonusChanceWpSpecial[3] = atoi(tokens[5]);
+            uBonusChanceWpSpecial[4] = atoi(tokens[6]);
+            uBonusChanceWpSpecial[5] = atoi(tokens[7]);
+            break;
+        }
     }
-    else
-      pItems[item_counter]._bonus_strength=0;
-    pItems[item_counter].uEquipX=atoi(tokens[14]);
-    pItems[item_counter].uEquipY=atoi(tokens[15]);
-    pItems[item_counter].pDescription = RemoveQuotes(tokens[16]);
-    item_counter++;
-	}
-
-	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");
-  for (item_counter = 0; item_counter < 619; item_counter++)
-		{
-		test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() > 7, "Invalid number of tokens");
-    item_counter = atoi(tokens[0]);
-    pItems[item_counter].uChanceByTreasureLvl1=atoi(tokens[2]);
-    pItems[item_counter].uChanceByTreasureLvl2=atoi(tokens[3]);
-    pItems[item_counter].uChanceByTreasureLvl3=atoi(tokens[4]);
-    pItems[item_counter].uChanceByTreasureLvl4=atoi(tokens[5]);
-    pItems[item_counter].uChanceByTreasureLvl5=atoi(tokens[6]);
-    pItems[item_counter].uChanceByTreasureLvl6=atoi(tokens[7]);
-  }
+    free(pRndItemsTXT_Raw);
+    pRndItemsTXT_Raw = nullptr;
 
-	//ChanceByTreasureLvl Summ - to calculate chance
-	memset(&uChanceByTreasureLvlSumm, 0, 24);
-	for(int i=0;i<6;++i)
-		{
-		for (int j=1;j<item_counter;++j)
-			uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i];
-		}
-
-	strtok(NULL, "\r");
-	strtok(NULL, "\r");
-	strtok(NULL, "\r");
-	strtok(NULL, "\r");
-	strtok(NULL, "\r");
-	for (int i=0;i<3;++i)
-		{
-		test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() > 7, "Invalid number of tokens");
-      switch (i)
-      {
-      case 0:
-        uBonusChanceStandart[0]=atoi(tokens[2]);
-        uBonusChanceStandart[1]=atoi(tokens[3]);
-        uBonusChanceStandart[2]=atoi(tokens[4]);
-        uBonusChanceStandart[3]=atoi(tokens[5]);
-        uBonusChanceStandart[4]=atoi(tokens[6]);
-        uBonusChanceStandart[5]=atoi(tokens[7]);
-        break;
-      case 1:
-        uBonusChanceSpecial[0]=atoi(tokens[2]);
-        uBonusChanceSpecial[1]=atoi(tokens[3]);
-        uBonusChanceSpecial[2]=atoi(tokens[4]);
-        uBonusChanceSpecial[3]=atoi(tokens[5]);
-        uBonusChanceSpecial[4]=atoi(tokens[6]);
-        uBonusChanceSpecial[5]=atoi(tokens[7]);
-        break;
-      case 2:
-        uBonusChanceWpSpecial[0]=atoi(tokens[2]);
-        uBonusChanceWpSpecial[1]=atoi(tokens[3]);
-        uBonusChanceWpSpecial[2]=atoi(tokens[4]);
-        uBonusChanceWpSpecial[3]=atoi(tokens[5]);
-        uBonusChanceWpSpecial[4]=atoi(tokens[6]);
-        uBonusChanceWpSpecial[5]=atoi(tokens[7]);
-        break;
-      }
-		}
-  free(pRndItemsTXT_Raw);
-  pRndItemsTXT_Raw = nullptr;
+    pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
+    strtok(pSkillDescTXT_Raw, "\r");
+    for (int i = 0; i < 37; ++i)
+    {
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() >= 6, "Invalid number of tokens");
+        pSkillDesc[i] = RemoveQuotes(tokens[1]);
+        pNormalSkillDesc[i] = RemoveQuotes(tokens[2]);
+        pExpertSkillDesc[i] = RemoveQuotes(tokens[3]);
+        pMasterSkillDesc[i] = RemoveQuotes(tokens[4]);
+        pGrandSkillDesc[i] = RemoveQuotes(tokens[5]);
+    }
 
-	pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0);
-	strtok(pSkillDescTXT_Raw, "\r");
-	for (int i=0; i<37; ++i)
-		{
-		test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() >= 6, "Invalid number of tokens");
-    pSkillDesc[i] = RemoveQuotes(tokens[1]);
-    pNormalSkillDesc[i] = RemoveQuotes(tokens[2]);
-    pExpertSkillDesc[i] = RemoveQuotes(tokens[3]);
-    pMasterSkillDesc[i] = RemoveQuotes(tokens[4]);
-    pGrandSkillDesc[i] = RemoveQuotes(tokens[5]);
-	}
-
-	pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
-	strtok(pStatsTXT_Raw, "\r");
-	for (int i=0; i<26; ++i)
-		{
-		test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() == 2, "Invalid number of tokens");
-    switch (i)
+    pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
+    strtok(pStatsTXT_Raw, "\r");
+    for (int i = 0; i < 26; ++i)
     {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-    case 4:
-    case 5:
-    case 6:
-      pAttributeDescriptions[i] = RemoveQuotes(tokens[1]);
-      break;
-    case 7:
-      pHealthPointsAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 8:
-      pArmourClassAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 9:
-      pSpellPointsAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 10:
-      pPlayerConditionAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 11:
-      pFastSpellAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 12:
-      pPlayerAgeAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 13:
-      pPlayerLevelAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 14:
-      pPlayerExperienceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 15:
-      pAttackBonusAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 16:
-      pAttackDamageAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 17:
-      pMissleBonusAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 18:
-      pMissleDamageAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 19:
-      pFireResistanceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 20:
-      pAirResistanceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 21:
-      pWaterResistanceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 22:
-      pEarthResistanceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 23:
-      pMindResistanceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 24:
-      pBodyResistanceAttributeDescription = RemoveQuotes(tokens[1]);
-      break;
-    case 25:
-      pSkillPointsAttributeDescription = RemoveQuotes(tokens[1]);
-      break;  
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() == 2, "Invalid number of tokens");
+        switch (i)
+        {
+        case 0:
+        case 1:
+        case 2:
+        case 3:
+        case 4:
+        case 5:
+        case 6:
+            pAttributeDescriptions[i] = RemoveQuotes(tokens[1]);
+            break;
+        case 7:
+            pHealthPointsAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 8:
+            pArmourClassAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 9:
+            pSpellPointsAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 10:
+            pPlayerConditionAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 11:
+            pFastSpellAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 12:
+            pPlayerAgeAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 13:
+            pPlayerLevelAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 14:
+            pPlayerExperienceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 15:
+            pAttackBonusAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 16:
+            pAttackDamageAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 17:
+            pMissleBonusAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 18:
+            pMissleDamageAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 19:
+            pFireResistanceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 20:
+            pAirResistanceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 21:
+            pWaterResistanceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 22:
+            pEarthResistanceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 23:
+            pMindResistanceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 24:
+            pBodyResistanceAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        case 25:
+            pSkillPointsAttributeDescription = RemoveQuotes(tokens[1]);
+            break;
+        }
     }
-  }
-  
-	pClassTXT_Raw = 0;
-	pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
-	strtok(pClassTXT_Raw, "\r");
-	for (int i=0; i<36; ++i)
-		{
-		test_string = strtok(NULL, "\r") + 1;
-    auto tokens = Tokenize(test_string, '\t');
-    Assert(tokens.size() == 3, "Invalid number of tokens");
-    pClassDescriptions[i]=RemoveQuotes(tokens[1]);
-	}
+
+    pClassTXT_Raw = 0;
+    pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0);
+    strtok(pClassTXT_Raw, "\r");
+    for (int i = 0; i < 36; ++i)
+    {
+        test_string = strtok(NULL, "\r") + 1;
+        auto tokens = Tokenize(test_string, '\t');
+        Assert(tokens.size() == 3, "Invalid number of tokens");
+        pClassDescriptions[i] = RemoveQuotes(tokens[1]);
+    }
 
 
-  
-  ItemGen::PopulateSpecialBonusMap();
-  ItemGen::PopulateArtifactBonusMap();
-  ItemGen::PopulateRegularBonusMap();
-  
 
-	}
+    ItemGen::PopulateSpecialBonusMap();
+    ItemGen::PopulateArtifactBonusMap();
+    ItemGen::PopulateRegularBonusMap();
+
+
+}
 
 //----- (00456D17) --------------------------------------------------------
 void ItemsTable::SetSpecialBonus(ItemGen *pItem)
@@ -730,7 +730,7 @@
   if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL )
   {
     pItem->uEnchantmentType = pItems[pItem->uItemID]._bonus_type;
-    pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value;
+    pItem->special_enchantment = (ITEM_ENCHANTMENT)pItems[pItem->uItemID]._additional_value;
     pItem->m_enchantmentStrength = pItems[pItem->uItemID]._bonus_strength;
   }
 }
@@ -878,9 +878,9 @@
 		return uBaseValue;
 	if (uEnchantmentType )
 		return uBaseValue + 100 * m_enchantmentStrength;;
-	if (uSpecEnchantmentType )
+	if (special_enchantment )
 		{
-		bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel;
+		bonus = pItemsTable->pSpecialEnchantments[special_enchantment].iTreasureLevel;
 		if ( bonus > 10 )
 			return uBaseValue + bonus;
 		else
@@ -935,30 +935,30 @@
     }
     else
     {
-      if ( !uSpecEnchantmentType )
+      if ( !special_enchantment )
         return item__getname_buffer.data();
-      if ( uSpecEnchantmentType == 16 //Drain Hit Points from target.
-        || uSpecEnchantmentType == 39 //Double damage vs Demons.
-        || uSpecEnchantmentType == 40 //Double damage vs Dragons
-        || uSpecEnchantmentType == 45 //+5 Speed and Accuracy
-        || uSpecEnchantmentType == 56 //+5 Might and Endurance.
-        || uSpecEnchantmentType == 57 //+5 Intellect and Personality.
-        || uSpecEnchantmentType == 58 //Increased Value.
-        || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills
-        || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills.
-        || uSpecEnchantmentType == 59  //Increased Weapon speed.
-        || uSpecEnchantmentType == 63 //Double Damage vs. Elves.
-        || uSpecEnchantmentType == 64 //Double Damage vs. Undead.
-        || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill.
-        || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class.
+      if ( special_enchantment == 16 //Drain Hit Points from target.
+        || special_enchantment == 39 //Double damage vs Demons.
+        || special_enchantment == 40 //Double damage vs Dragons
+        || special_enchantment == 45 //+5 Speed and Accuracy
+        || special_enchantment == 56 //+5 Might and Endurance.
+        || special_enchantment == 57 //+5 Intellect and Personality.
+        || special_enchantment == 58 //Increased Value.
+        || special_enchantment == 60 //+3 Unarmed and Dodging skills
+        || special_enchantment == 61 //+3 Stealing and Disarm skills.
+        || special_enchantment == 59  //Increased Weapon speed.
+        || special_enchantment == 63 //Double Damage vs. Elves.
+        || special_enchantment == 64 //Double Damage vs. Undead.
+        || special_enchantment == 67 //Adds 5 points of Body damage and +2 Disarm skill.
+        || special_enchantment == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class.
       {  //enchantment and name positions inverted!
         sprintf( item__getname_buffer.data(), "%s %s",
-				  pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd,
+				  pItemsTable->pSpecialEnchantments[special_enchantment-1].pNameAdd,
 				  pItemsTable->pItems[uItemID].pName);
         return item__getname_buffer.data();
       }
       strcat(item__getname_buffer.data(), " ");
-	  nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd;
+	  nameModificator = pItemsTable->pSpecialEnchantments[special_enchantment-1].pNameAdd;
     }
     strcat(item__getname_buffer.data(), nameModificator);
   }
@@ -968,7 +968,7 @@
 
 //----- (00456620) --------------------------------------------------------
 void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item)
-  {
+{
     int treasureLevelMinus1; // ebx@3
     int current_chance; // ebx@43
     int tmp_chance; // ecx@47
@@ -979,7 +979,7 @@
     unsigned int v27; // eax@89
     int v32; // ecx@91
     int v33; // eax@91
-//    unsigned int v34; // eax@97
+    //    unsigned int v34; // eax@97
     int v45; // eax@120
     int v46; // edx@120
     int j; // eax@121
@@ -994,12 +994,12 @@
 
 
     treasureLevelMinus1 = treasure_level - 1;
-    if ( uTreasureType ) //generate known treasure type
+    if (uTreasureType) //generate known treasure type
     {
         ITEM_EQUIP_TYPE   requested_equip;
         PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID;
         switch (uTreasureType)
-            {
+        {
         case 20: requested_equip = EQUIP_SINGLE_HANDED; break;
         case 21: requested_equip = EQUIP_ARMOUR; break;
         case 22: requested_skill = PLAYER_SKILL_MISC; break;
@@ -1031,147 +1031,147 @@
             __debugbreak(); // check this condition
             requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1);
             break;
-            }
+        }
         memset(val_list, 0, sizeof(val_list));
         total_chance = 0;
-        j=0;
+        j = 0;
         //a2a = 1;
         if (requested_skill == PLAYER_SKILL_INVALID)  // no skill for this item needed
+        {
+            for (uint i = 1; i < 500; ++i)
             {
-            for (uint i = 1; i < 500; ++i)
+                if (pItems[i].uEquipType == requested_equip)
                 {
-                if (pItems[i].uEquipType == requested_equip)
-                    {
                     val_list[j] = i;
                     ++j;
                     total_chance += pItems[i].uChanceByTreasureLvl[treasure_level - 1];
-                    }
                 }
             }
+        }
         else  //have needed skill
-            {
+        {
             for (uint i = 1; i < 500; ++i)
-                {
+            {
                 if (pItems[i].uSkillType == requested_skill)
-                    {
+                {
                     val_list[j] = i;
                     ++j;
                     total_chance += pItems[i].uChanceByTreasureLvl[treasure_level - 1];
-                    }
                 }
             }
+        }
 
         current_chance = 0;
-        if ( total_chance )
+        if (total_chance)
         {
-          current_chance = rand() % total_chance + 1;
-          tmp_chance = 0;
-          j=0;
-          while(tmp_chance < current_chance)
-          {
-            out_item->uItemID = val_list[j];
-            tmp_chance += pItems[val_list[j]].uChanceByTreasureLvl[treasure_level - 1];
-            ++j;
-          }
+            current_chance = rand() % total_chance + 1;
+            tmp_chance = 0;
+            j = 0;
+            while (tmp_chance < current_chance)
+            {
+                out_item->uItemID = val_list[j];
+                tmp_chance += pItems[val_list[j]].uChanceByTreasureLvl[treasure_level - 1];
+                ++j;
+            }
         }
         else
         {
-          out_item->uItemID = 1;
+            out_item->uItemID = ITEM_LONGSWORD_1;
         }
     }
     else
     {
-   //artifact
-        if ( treasureLevelMinus1 == 5 )
+        //artifact
+        if (treasureLevelMinus1 == 5)
         {
-          v56 = 0;
-          for(int i=0; i<29; ++i) 
-            v56 += pParty->pIsArtifactFound[i];
-          v17 = rand() % 29;
-          if ((rand() % 100 < 5) && !pParty->pIsArtifactFound[v17] && v56 < 13)
-          {
-            pParty->pIsArtifactFound[v17] = 1;
-            out_item->uAttributes = 0;
-            out_item->uItemID = v17 + 500;
-            SetSpecialBonus(out_item);
-            return;
-          }
+            v56 = 0;
+            for (int i = 0; i < 29; ++i)
+                v56 += pParty->pIsArtifactFound[i];
+            v17 = rand() % 29;
+            if ((rand() % 100 < 5) && !pParty->pIsArtifactFound[v17] && v56 < 13)
+            {
+                pParty->pIsArtifactFound[v17] = 1;
+                out_item->uAttributes = 0;
+                out_item->uItemID = v17 + ITEM_ARTIFACT_PUCK;
+                SetSpecialBonus(out_item);
+                return;
+            }
         }
-        
+
         v57 = 0;
         v18 = rand() % this->uChanceByTreasureLvlSumm[treasure_level - 1] + 1;
         while (v57 < v18)
         {
-          ++out_item->uItemID;
-          v57 += pItems[out_item->uItemID].uChanceByTreasureLvl[treasureLevelMinus1];
+            ++out_item->uItemID;
+            v57 += pItems[out_item->uItemID].uChanceByTreasureLvl[treasureLevelMinus1];
         }
     }
-    if (out_item->GetItemEquipType() == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
+    if (out_item->GetItemEquipType() == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE)
     {// if it potion set potion spec
-      out_item->uEnchantmentType = 0;
-      for (int i=0; i<2; ++i)
-        out_item->uEnchantmentType += rand() % 4 + 1;
-      out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; 
+        out_item->uEnchantmentType = 0;
+        for (int i = 0; i < 2; ++i)
+            out_item->uEnchantmentType += rand() % 4 + 1;
+        out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level;
     }
 
-    if ( out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
-        && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) )
+    if (out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
+        && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239))
         out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
-    if ( pItemsTable->pItems[out_item->uItemID].uItemID_Rep_St )
+    if (pItemsTable->pItems[out_item->uItemID].uItemID_Rep_St)
         out_item->uAttributes = 0;
     else
         out_item->uAttributes = 1;
 
-    if ( out_item->GetItemEquipType() != EQUIP_POTION )
-        {
-        out_item->uSpecEnchantmentType = 0;
+    if (out_item->GetItemEquipType() != EQUIP_POTION)
+    {
+        out_item->special_enchantment = ITEM_ENCHANTMENT_NULL;
         out_item->uEnchantmentType = 0;
-        }
+    }
     //try get special enhansment
     switch (out_item->GetItemEquipType())
-        {
+    {
     case EQUIP_SINGLE_HANDED:
-    case EQUIP_TWO_HANDED :   
-    case EQUIP_BOW :    
-        if ( !uBonusChanceWpSpecial[treasureLevelMinus1] )
+    case EQUIP_TWO_HANDED:
+    case EQUIP_BOW:
+        if (!uBonusChanceWpSpecial[treasureLevelMinus1])
             return;
-        if ((uint)(rand() % 100)>=uBonusChanceWpSpecial[treasureLevelMinus1])
+        if ((uint)(rand() % 100) >= uBonusChanceWpSpecial[treasureLevelMinus1])
             return;
         break;
-    case      EQUIP_ARMOUR :        
-    case      EQUIP_SHIELD :         
-    case      EQUIP_HELMET  :       
-    case      EQUIP_BELT   :          
-    case      EQUIP_CLOAK  :        
-    case      EQUIP_GAUNTLETS :      
-    case      EQUIP_BOOTS  :        
-    case      EQUIP_RING   : 
-        
-        if ( !uBonusChanceStandart[treasureLevelMinus1] )
+    case      EQUIP_ARMOUR:
+    case      EQUIP_SHIELD:
+    case      EQUIP_HELMET:
+    case      EQUIP_BELT:
+    case      EQUIP_CLOAK:
+    case      EQUIP_GAUNTLETS:
+    case      EQUIP_BOOTS:
+    case      EQUIP_RING:
+
+        if (!uBonusChanceStandart[treasureLevelMinus1])
             return;
         special_chance = rand() % 100;
-        if ( special_chance < uBonusChanceStandart[treasureLevelMinus1])
+        if (special_chance < uBonusChanceStandart[treasureLevelMinus1])
+        {
+            v26 = rand() % pEnchantmentsSumm[out_item->GetItemEquipType() - 3] + 1;
+            v27 = 0;
+            while (v27 < v26)
             {
-              v26 = rand() %pEnchantmentsSumm[out_item->GetItemEquipType()-3] + 1; 
-              v27 = 0;
-              while(v27 < v26)
-              {
                 ++out_item->uEnchantmentType;
-                v27+=pEnchantments[out_item->uEnchantmentType].to_item[out_item->GetItemEquipType()-3];
-              }
+                v27 += pEnchantments[out_item->uEnchantmentType].to_item[out_item->GetItemEquipType() - 3];
+            }
 
             v33 = rand() % (bonus_ranges[treasureLevelMinus1].maxR - bonus_ranges[treasureLevelMinus1].minR + 1);
             out_item->m_enchantmentStrength = v33 + bonus_ranges[treasureLevelMinus1].minR;
             v32 = out_item->uEnchantmentType - 1;
-            if ( v32 == 21 || v32 == 22 || v32 == 23 ) //Armsmaster skill, Dodge skill, Unarmed skill 
-                out_item->m_enchantmentStrength = out_item->m_enchantmentStrength/2;
-            if ( out_item->m_enchantmentStrength <= 0 )
+            if (v32 == 21 || v32 == 22 || v32 == 23) //Armsmaster skill, Dodge skill, Unarmed skill 
+                out_item->m_enchantmentStrength = out_item->m_enchantmentStrength / 2;
+            if (out_item->m_enchantmentStrength <= 0)
                 out_item->m_enchantmentStrength = 1;
             return;
-            
-            }
-        else if ( special_chance >= uBonusChanceStandart[treasureLevelMinus1] + uBonusChanceSpecial[treasureLevelMinus1] )
-          return;
+
+        }
+        else if (special_chance >= uBonusChanceStandart[treasureLevelMinus1] + uBonusChanceSpecial[treasureLevelMinus1])
+            return;
         break;
     case EQUIP_WAND:
         out_item->uNumCharges = rand() % 6 + out_item->GetDamageMod() + 1;
@@ -1179,38 +1179,38 @@
         return;
     default:
         return;
-        }
+    }
 
-    j=0;
-    int spc_sum=0;
+    j = 0;
+    int spc_sum = 0;
     int spc;
     memset(&val_list, 0, 3200);
-    for (unsigned int i=0; i<pSpecialEnchantments_count;++i)
+    for (unsigned int i = 0; i < pSpecialEnchantments_count; ++i)
     {
-      int tr_lv= pSpecialEnchantments[i].iTreasureLevel;
-      if ((treasure_level - 1 == 2) && ( tr_lv == 1 || tr_lv == 0 ) ||
-        (treasure_level - 1 == 3) && (tr_lv == 2 || tr_lv == 1 || tr_lv == 0) ||
-        (treasure_level - 1 == 4) && (tr_lv == 3 || tr_lv == 2 || tr_lv == 1) ||
-        (treasure_level - 1 == 5) && (tr_lv == 3)
-        )
-      {
-        spc=pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()];
-        spc_sum+=spc;
-        if(spc)
+        int tr_lv = pSpecialEnchantments[i].iTreasureLevel;
+        if ((treasure_level - 1 == 2) && (tr_lv == 1 || tr_lv == 0) ||
+            (treasure_level - 1 == 3) && (tr_lv == 2 || tr_lv == 1 || tr_lv == 0) ||
+            (treasure_level - 1 == 4) && (tr_lv == 3 || tr_lv == 2 || tr_lv == 1) ||
+            (treasure_level - 1 == 5) && (tr_lv == 3)
+            )
         {
-          val_list[j++]=i;  
+            spc = pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()];
+            spc_sum += spc;
+            if (spc)
+            {
+                val_list[j++] = i;
+            }
         }
-      }
     }
 
-    v46 = rand()%spc_sum+1;//случайные значения от 1 до spc_sum
-    j=0;
+    v46 = rand() % spc_sum + 1;//случайные значения от 1 до spc_sum
+    j = 0;
     v45 = 0;
-    while (v45<v46)
+    while (v45 < v46)
     {
-      ++j;
-      out_item->uSpecEnchantmentType=val_list[j];
-      v45+=pSpecialEnchantments[val_list[j]].to_item_apply[out_item->GetItemEquipType()];
+        ++j;
+        out_item->special_enchantment = (ITEM_ENCHANTMENT)val_list[j];
+        v45 += pSpecialEnchantments[val_list[j]].to_item_apply[out_item->GetItemEquipType()];
     }
 }
 
@@ -1658,7 +1658,7 @@
 
 void ItemGen::GetItemBonusSpecialEnchantment( Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus )
 {
-  auto bonusList = ItemGen::specialBonusMap.find(this->uSpecEnchantmentType);
+  auto bonusList = ItemGen::specialBonusMap.find(this->special_enchantment);
   if (bonusList == ItemGen::specialBonusMap.end())
   {
     return;
@@ -1787,7 +1787,7 @@
         if (item_count < 6)
         {
           pParty->StandartItemsInShops[shop_index][item_count].Reset();
-          pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220;  //potion bottle
+          pParty->StandartItemsInShops[shop_index][item_count].uItemID = ITEM_POTION_BOTTLE;  //potion bottle
           continue;
         }
         else
@@ -1840,7 +1840,7 @@
         if (item_count < 6)
         {
           pParty->SpecialItemsInShops[shop_index][item_count].Reset();
-          pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + 740;  //mscrool
+          pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + ITEM_RECIPE_REJUVENATION;  //mscrool
           continue;
         }
         else
@@ -1859,7 +1859,7 @@
 
 //----- (00450218) --------------------------------------------------------
 void GenerateItemsInChest()
-    {
+{
     unsigned int mapType; // eax@1
     MapInfo *currMapInfo; // esi@1
     ItemGen *currItem; // ebx@2
@@ -1875,82 +1875,82 @@
 
     mapType = pMapStats->GetMapInfo(pCurrentMapName);
     currMapInfo = &pMapStats->pInfos[mapType];
-    for(int i=1; i<20;++i)
+    for (int i = 1; i < 20; ++i)
     {
-        for(int j=0; j<140;++j)
+        for (int j = 0; j < 140; ++j)
         {
 
             currItem = &pChests[i].igChestItems[j];
-            if ( currItem->uItemID < 0 )
+            if (currItem->uItemID < 0)
             {
                 additionaItemCount = rand() % 5; //additional items in chect
-                treasureLevelBot = byte_4E8168[abs(currItem->uItemID)-1][2*currMapInfo->Treasure_prob];
-                treasureLevelTop = byte_4E8168[abs(currItem->uItemID)-1][2*currMapInfo->Treasure_prob+1];
+                treasureLevelBot = byte_4E8168[abs(currItem->uItemID) - 1][2 * currMapInfo->Treasure_prob];
+                treasureLevelTop = byte_4E8168[abs(currItem->uItemID) - 1][2 * currMapInfo->Treasure_prob + 1];
                 treasureLevelRange = treasureLevelTop - treasureLevelBot + 1;
                 resultTreasureLevel = treasureLevelBot + rand() % treasureLevelRange;  //treasure level 
-                if (resultTreasureLevel<7)
+                if (resultTreasureLevel < 7)
                 {
-                  v11 = 0;
-                  do 
-                  {
-                    whatToGenerateProb = rand() % 100;
-                    if (whatToGenerateProb<20)
-                    {
-                      currItem->Reset();
-                    }
-                    else if (whatToGenerateProb<60) //generate gold
+                    v11 = 0;
+                    do
                     {
-                      goldAmount=0;
-                      currItem->Reset();
-                      switch (resultTreasureLevel)
-                      {
-                      case 1: //small gold
-                        goldAmount = rand() % 51 + 50;
-                        currItem->uItemID = 197;
-                        break;
-                      case 2://small gold
-                        goldAmount = rand() % 101 + 100;
-                        currItem->uItemID = 197;
-                        break;
-                      case 3:  //medium
-                        goldAmount = rand() % 301 + 200;
-                        currItem->uItemID = 198;
-                        break;
-                      case 4: //medium
-                        goldAmount = rand() % 501 + 500;
-                        currItem->uItemID = 198;
-                        break;
-                      case 5: //big
-                        goldAmount = rand() % 1001 + 1000;
-                        currItem->uItemID = 199;
-                        break;
-                      case 6: //big
-                        goldAmount = rand() % 3001 + 2000;
-                        currItem->uItemID = 199;
-                        break;
-                      }
-                      currItem->SetIdentified();
-                      currItem->uSpecEnchantmentType = goldAmount;
-                    }
-                    else
-                    {
-                      pItemsTable->GenerateItem(resultTreasureLevel, 0, currItem);
-                    }
-                    v12 = 0;
-                    while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140))
-                    {
-                      ++v12;
-                    }
-                    if (v12 >= 140)
-                      break;
-                    currItem=&pChests[i].igChestItems[v12];
-                    v11++;
-                  } while (v11 < additionaItemCount + 1); // + 1 because it's the item at pChests[i].igChestItems[j] and the additional ones
+                        whatToGenerateProb = rand() % 100;
+                        if (whatToGenerateProb < 20)
+                        {
+                            currItem->Reset();
+                        }
+                        else if (whatToGenerateProb < 60) //generate gold
+                        {
+                            goldAmount = 0;
+                            currItem->Reset();
+                            switch (resultTreasureLevel)
+                            {
+                            case 1:
+                                goldAmount = rand() % 51 + 50;
+                                currItem->uItemID = ITEM_GOLD_SMALL;
+                                break;
+                            case 2:
+                                goldAmount = rand() % 101 + 100;
+                                currItem->uItemID = ITEM_GOLD_SMALL;
+                                break;
+                            case 3:
+                                goldAmount = rand() % 301 + 200;
+                                currItem->uItemID = ITEM_GOLD_MEDIUM;
+                                break;
+                            case 4:
+                                goldAmount = rand() % 501 + 500;
+                                currItem->uItemID = ITEM_GOLD_MEDIUM;
+                                break;
+                            case 5:
+                                goldAmount = rand() % 1001 + 1000;
+                                currItem->uItemID = ITEM_GOLD_LARGE;
+                                break;
+                            case 6:
+                                goldAmount = rand() % 3001 + 2000;
+                                currItem->uItemID = ITEM_GOLD_LARGE;
+                                break;
+                            }
+                            currItem->SetIdentified();
+                            currItem->special_enchantment = (ITEM_ENCHANTMENT)goldAmount;
+                        }
+                        else
+                        {
+                            pItemsTable->GenerateItem(resultTreasureLevel, 0, currItem);
+                        }
+                        v12 = 0;
+                        while (!(pChests[i].igChestItems[v12].uItemID == ITEM_NULL) && (v12 < 140))
+                        {
+                            ++v12;
+                        }
+                        if (v12 >= 140)
+                            break;
+                        currItem = &pChests[i].igChestItems[v12];
+                        v11++;
+                    } while (v11 < additionaItemCount + 1); // + 1 because it's the item at pChests[i].igChestItems[j] and the additional ones
                 }
                 else
                     currItem->GenerateArtifact();
             }
-        }			
+        }
     }
 
 }