diff Items.cpp @ 570:f54481c85df8

itemgen working, i hope
author Gloval
date Wed, 06 Mar 2013 00:09:49 +0400
parents 09108e73f2f4
children f8a4a2e0b4c9
line wrap: on
line diff
--- a/Items.cpp	Tue Mar 05 16:14:22 2013 +0200
+++ b/Items.cpp	Wed Mar 06 00:09:49 2013 +0400
@@ -255,7 +255,7 @@
   this->uNumCharges = 0;
   this->uSpecEnchantmentType = 0;
   this->_bonus_strength = 0;
-  this->uEncantmentType = 0;
+  this->uEnchantmentType = 0;
   this->uItemID = 0;
   this->uBodyAnchor = 0;
   this->uExpireTime = 0i64;
@@ -268,7 +268,7 @@
   {
     if ( uTimePlayed > (signed __int64)this->uExpireTime )
     {
-      this->uEncantmentType = 0;
+      this->uEnchantmentType = 0;
       this->uSpecEnchantmentType = 0;
       this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS);
     }
@@ -381,7 +381,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -485,7 +485,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -497,7 +497,7 @@
 	memset(&pSpecialEnchantmentsSumm, 0, 96);
 	for(i=0;i<12;++i)
 		{
-		for (j=0;j<pSpecialEnchantments_count;++j)
+		for (j=0;j<=pSpecialEnchantments_count;++j)
 			pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
 		}
 
@@ -838,7 +838,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -905,7 +905,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -1044,7 +1044,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -1096,7 +1096,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -1199,7 +1199,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -1236,7 +1236,7 @@
 				}
 			else
 				{ 
-				if (!decode_step)
+				if (decode_step)
 					break_loop = true;
 				}
 			++decode_step;
@@ -1251,7 +1251,7 @@
 {
   if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL )
   {
-    pItem->uEncantmentType = pItems[pItem->uItemID]._bonus_type;
+    pItem->uEnchantmentType = pItems[pItem->uItemID]._bonus_type;
     pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value;
     pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength;
   }
@@ -1441,7 +1441,7 @@
 	uBaseValue = pItemsTable->pItems[this->uItemID].uValue;
 	if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) )
 		return uBaseValue;
-	if (uEncantmentType )
+	if (uEnchantmentType )
 		return uBaseValue + 100 * _bonus_strength;;
 	if (uSpecEnchantmentType )
 		{
@@ -1494,10 +1494,10 @@
   }
   if ( !pItemsTable->IsMaterialNonCommon(this) )
   {
-    if ( uEncantmentType )
+    if ( uEnchantmentType )
     {
       strcat(item__getname_buffer, " ");
-      nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName;
+      nameModificator = pItemsTable->pEnchantments[uEnchantmentType-1].pOfName;
     }
     else
     {
@@ -1693,10 +1693,10 @@
 
         if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
             {// if it potion set potion spec
-            out_item->uEncantmentType = 0;
+            out_item->uEnchantmentType = 0;
             for (int i=0; i<2; ++i)
-                out_item->uEncantmentType += rand() % 4 + 1;
-            out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
+                out_item->uEnchantmentType += rand() % 4 + 1;
+            out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; 
             }
         }
     else
@@ -1733,12 +1733,12 @@
             out_item->uItemID = 1;
         if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
             {// if it potion set potion spec
-            out_item->uEncantmentType = 0;
+            out_item->uEnchantmentType = 0;
             for (int i=0; i<2; ++i)
-                out_item->uEncantmentType += rand() % 4 + 1;
-            out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
+                out_item->uEnchantmentType += rand() % 4 + 1;
+            out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; 
             }
-        out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 
+        out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; 
         }
 
     if ( out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
@@ -1752,7 +1752,7 @@
     if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION )
         {
         out_item->uSpecEnchantmentType = 0;
-        out_item->uEncantmentType = 0;
+        out_item->uEnchantmentType = 0;
         }
     //try get special enhansment
     switch (pItems[out_item->uItemID].uEquipType)
@@ -1773,39 +1773,39 @@
     case      EQUIP_GAUNTLETS :      
     case      EQUIP_BOOTS  :        
     case      EQUIP_RING   : 
-        v22 = uBonusChanceStandart[v6];
+        
         if ( !uBonusChanceStandart[v6] )
             return;
-        v24 = v22;
         special_chance = rand() % 100;
-        if ( !uBonusChanceSpecial[v6] && !(special_chance < uBonusChanceStandart[v6]))
-            return;
         if ( special_chance < uBonusChanceStandart[v6])
             {
-            v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[out_item->uItemID].uEquipType + 3];
-            v27 = out_item->uItemID;
-            out_item->uEncantmentType = 0;
-            for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1];
-                i < v26;
-                i += pEnchantments[out_item->uEncantmentType].to_item[pItems[v29].uEquipType + 1] )
+              v26 = rand() %pEnchantmentsSumm[pItems[out_item->uItemID].uEquipType-3]; 
+            out_item->uEnchantmentType = 0;
+            v27=pEnchantments[out_item->uEnchantmentType].to_item[pItems[out_item->uItemID].uEquipType-3];
+            if (v26>v27 )
+                {
+                do 
                 {
-                v29 = out_item->uItemID;
-                ++out_item->uEncantmentType;
-                }
-            ++out_item->uEncantmentType;
-            v30 = bonus_ranges[v6].minR;
-            v32 = out_item->uEncantmentType - 1;
-            v33 = rand() % (bonus_ranges[v6].maxR - v30 + 1) + v30;
-            out_item->_bonus_strength = v33;
-            if ( v32 == 21 || v32 == 22 || v32 == 23 )
-                out_item->_bonus_strength = v33 >> 1;
+                ++out_item->uEnchantmentType;
+                v27+=pEnchantments[out_item->uEnchantmentType].to_item[pItems[out_item->uItemID].uEquipType-3];
+                } while (v26>v27);
+            }
+            ++out_item->uEnchantmentType;
+
+            v33 = rand() % (bonus_ranges[v6].maxR - bonus_ranges[v6].minR + 1);
+            out_item->_bonus_strength = v33 + bonus_ranges[v6].minR;
+            v32 = out_item->uEnchantmentType - 1;
+            if ( v32 == 21 || v32 == 22 || v32 == 23 ) //Armsmaster skill, Dodge skill, Unarmed skill 
+                out_item->_bonus_strength = out_item->_bonus_strength/2;
             if ( out_item->_bonus_strength <= 0 )
                 out_item->_bonus_strength = 1;
             return;
             
             }
+        if ( !uBonusChanceSpecial[v6])
+            return;
         v34 = uBonusChanceStandart[v6] + uBonusChanceSpecial[v6];
-        if ( special_chance<v34 )
+        if ( special_chance>v34 )
             return;
         break;
     case EQUIP_WAND: