comparison Items.cpp @ 570:f54481c85df8

itemgen working, i hope
author Gloval
date Wed, 06 Mar 2013 00:09:49 +0400
parents 09108e73f2f4
children f8a4a2e0b4c9
comparison
equal deleted inserted replaced
569:f451efdb7c8b 570:f54481c85df8
253 this->uHolderPlayer = 0; 253 this->uHolderPlayer = 0;
254 this->uAttributes = 0; 254 this->uAttributes = 0;
255 this->uNumCharges = 0; 255 this->uNumCharges = 0;
256 this->uSpecEnchantmentType = 0; 256 this->uSpecEnchantmentType = 0;
257 this->_bonus_strength = 0; 257 this->_bonus_strength = 0;
258 this->uEncantmentType = 0; 258 this->uEnchantmentType = 0;
259 this->uItemID = 0; 259 this->uItemID = 0;
260 this->uBodyAnchor = 0; 260 this->uBodyAnchor = 0;
261 this->uExpireTime = 0i64; 261 this->uExpireTime = 0i64;
262 } 262 }
263 263
266 { 266 {
267 if ( this->uAttributes & ITEM_TEMP_BONUS ) 267 if ( this->uAttributes & ITEM_TEMP_BONUS )
268 { 268 {
269 if ( uTimePlayed > (signed __int64)this->uExpireTime ) 269 if ( uTimePlayed > (signed __int64)this->uExpireTime )
270 { 270 {
271 this->uEncantmentType = 0; 271 this->uEnchantmentType = 0;
272 this->uSpecEnchantmentType = 0; 272 this->uSpecEnchantmentType = 0;
273 this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS); 273 this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS);
274 } 274 }
275 } 275 }
276 } 276 }
379 pEnchantments[i].to_item[decode_step-2]=atoi(test_string); 379 pEnchantments[i].to_item[decode_step-2]=atoi(test_string);
380 } 380 }
381 } 381 }
382 else 382 else
383 { 383 {
384 if (!decode_step) 384 if (decode_step)
385 break_loop = true; 385 break_loop = true;
386 } 386 }
387 ++decode_step; 387 ++decode_step;
388 test_string=tmp_pos+1; 388 test_string=tmp_pos+1;
389 } while ((decode_step<11)&&!break_loop); 389 } while ((decode_step<11)&&!break_loop);
483 pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string); 483 pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string);
484 } 484 }
485 } 485 }
486 else 486 else
487 { 487 {
488 if (!decode_step) 488 if (decode_step)
489 break_loop = true; 489 break_loop = true;
490 } 490 }
491 ++decode_step; 491 ++decode_step;
492 test_string=tmp_pos+1; 492 test_string=tmp_pos+1;
493 } while ((decode_step<16)&&!break_loop); 493 } while ((decode_step<16)&&!break_loop);
495 495
496 pSpecialEnchantments_count = 71; 496 pSpecialEnchantments_count = 71;
497 memset(&pSpecialEnchantmentsSumm, 0, 96); 497 memset(&pSpecialEnchantmentsSumm, 0, 96);
498 for(i=0;i<12;++i) 498 for(i=0;i<12;++i)
499 { 499 {
500 for (j=0;j<pSpecialEnchantments_count;++j) 500 for (j=0;j<=pSpecialEnchantments_count;++j)
501 pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; 501 pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i];
502 } 502 }
503 503
504 Initialize2DA(); 504 Initialize2DA();
505 505
836 836
837 } 837 }
838 } 838 }
839 else 839 else
840 { 840 {
841 if (!decode_step) 841 if (decode_step)
842 break_loop = true; 842 break_loop = true;
843 } 843 }
844 ++decode_step; 844 ++decode_step;
845 test_string=tmp_pos+1; 845 test_string=tmp_pos+1;
846 } while ((decode_step<17)&&!break_loop); 846 } while ((decode_step<17)&&!break_loop);
903 break; 903 break;
904 } 904 }
905 } 905 }
906 else 906 else
907 { 907 {
908 if (!decode_step) 908 if (decode_step)
909 break_loop = true; 909 break_loop = true;
910 } 910 }
911 ++decode_step; 911 ++decode_step;
912 test_string=tmp_pos+1; 912 test_string=tmp_pos+1;
913 } while ((decode_step<8)&&!break_loop); 913 } while ((decode_step<8)&&!break_loop);
1042 break; 1042 break;
1043 } 1043 }
1044 } 1044 }
1045 else 1045 else
1046 { 1046 {
1047 if (!decode_step) 1047 if (decode_step)
1048 break_loop = true; 1048 break_loop = true;
1049 } 1049 }
1050 ++decode_step; 1050 ++decode_step;
1051 test_string=tmp_pos+1; 1051 test_string=tmp_pos+1;
1052 } while ((decode_step<8)&&!break_loop); 1052 } while ((decode_step<8)&&!break_loop);
1094 break; 1094 break;
1095 } 1095 }
1096 } 1096 }
1097 else 1097 else
1098 { 1098 {
1099 if (!decode_step) 1099 if (decode_step)
1100 break_loop = true; 1100 break_loop = true;
1101 } 1101 }
1102 ++decode_step; 1102 ++decode_step;
1103 test_string=tmp_pos+1; 1103 test_string=tmp_pos+1;
1104 } while ((decode_step<6)&&!break_loop); 1104 } while ((decode_step<6)&&!break_loop);
1197 break; 1197 break;
1198 } 1198 }
1199 } 1199 }
1200 else 1200 else
1201 { 1201 {
1202 if (!decode_step) 1202 if (decode_step)
1203 break_loop = true; 1203 break_loop = true;
1204 } 1204 }
1205 ++decode_step; 1205 ++decode_step;
1206 test_string=tmp_pos+1; 1206 test_string=tmp_pos+1;
1207 } while ((decode_step<2)&&!break_loop); 1207 } while ((decode_step<2)&&!break_loop);
1234 //if(i) 1234 //if(i)
1235 pClassDescriptions[i]=RemoveQuotes(test_string); 1235 pClassDescriptions[i]=RemoveQuotes(test_string);
1236 } 1236 }
1237 else 1237 else
1238 { 1238 {
1239 if (!decode_step) 1239 if (decode_step)
1240 break_loop = true; 1240 break_loop = true;
1241 } 1241 }
1242 ++decode_step; 1242 ++decode_step;
1243 test_string=tmp_pos+1; 1243 test_string=tmp_pos+1;
1244 } while ((decode_step<2)&&!break_loop); 1244 } while ((decode_step<2)&&!break_loop);
1249 //----- (00456D17) -------------------------------------------------------- 1249 //----- (00456D17) --------------------------------------------------------
1250 void ItemsTable::SetSpecialBonus(ItemGen *pItem) 1250 void ItemsTable::SetSpecialBonus(ItemGen *pItem)
1251 { 1251 {
1252 if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ) 1252 if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL )
1253 { 1253 {
1254 pItem->uEncantmentType = pItems[pItem->uItemID]._bonus_type; 1254 pItem->uEnchantmentType = pItems[pItem->uItemID]._bonus_type;
1255 pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value; 1255 pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value;
1256 pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength; 1256 pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength;
1257 } 1257 }
1258 } 1258 }
1259 1259
1439 unsigned int bonus; 1439 unsigned int bonus;
1440 1440
1441 uBaseValue = pItemsTable->pItems[this->uItemID].uValue; 1441 uBaseValue = pItemsTable->pItems[this->uItemID].uValue;
1442 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) 1442 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) )
1443 return uBaseValue; 1443 return uBaseValue;
1444 if (uEncantmentType ) 1444 if (uEnchantmentType )
1445 return uBaseValue + 100 * _bonus_strength;; 1445 return uBaseValue + 100 * _bonus_strength;;
1446 if (uSpecEnchantmentType ) 1446 if (uSpecEnchantmentType )
1447 { 1447 {
1448 bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel; 1448 bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel;
1449 if ( bonus > 10 ) 1449 if ( bonus > 10 )
1492 return item__getname_buffer; 1492 return item__getname_buffer;
1493 } 1493 }
1494 } 1494 }
1495 if ( !pItemsTable->IsMaterialNonCommon(this) ) 1495 if ( !pItemsTable->IsMaterialNonCommon(this) )
1496 { 1496 {
1497 if ( uEncantmentType ) 1497 if ( uEnchantmentType )
1498 { 1498 {
1499 strcat(item__getname_buffer, " "); 1499 strcat(item__getname_buffer, " ");
1500 nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName; 1500 nameModificator = pItemsTable->pEnchantments[uEnchantmentType-1].pOfName;
1501 } 1501 }
1502 else 1502 else
1503 { 1503 {
1504 if ( !uSpecEnchantmentType ) 1504 if ( !uSpecEnchantmentType )
1505 return item__getname_buffer; 1505 return item__getname_buffer;
1691 while ( tmp_chance < current_chance ); 1691 while ( tmp_chance < current_chance );
1692 } 1692 }
1693 1693
1694 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) 1694 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
1695 {// if it potion set potion spec 1695 {// if it potion set potion spec
1696 out_item->uEncantmentType = 0; 1696 out_item->uEnchantmentType = 0;
1697 for (int i=0; i<2; ++i) 1697 for (int i=0; i<2; ++i)
1698 out_item->uEncantmentType += rand() % 4 + 1; 1698 out_item->uEnchantmentType += rand() % 4 + 1;
1699 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 1699 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level;
1700 } 1700 }
1701 } 1701 }
1702 else 1702 else
1703 { 1703 {
1704 //artifact 1704 //artifact
1731 out_item->uItemID = 1; 1731 out_item->uItemID = 1;
1732 if ( !out_item->uItemID ) 1732 if ( !out_item->uItemID )
1733 out_item->uItemID = 1; 1733 out_item->uItemID = 1;
1734 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) 1734 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
1735 {// if it potion set potion spec 1735 {// if it potion set potion spec
1736 out_item->uEncantmentType = 0; 1736 out_item->uEnchantmentType = 0;
1737 for (int i=0; i<2; ++i) 1737 for (int i=0; i<2; ++i)
1738 out_item->uEncantmentType += rand() % 4 + 1; 1738 out_item->uEnchantmentType += rand() % 4 + 1;
1739 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 1739 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level;
1740 } 1740 }
1741 out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; 1741 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level;
1742 } 1742 }
1743 1743
1744 if ( out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION 1744 if ( out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
1745 && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) 1745 && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) )
1746 out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; 1746 out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
1750 out_item->uAttributes = 1; 1750 out_item->uAttributes = 1;
1751 1751
1752 if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) 1752 if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION )
1753 { 1753 {
1754 out_item->uSpecEnchantmentType = 0; 1754 out_item->uSpecEnchantmentType = 0;
1755 out_item->uEncantmentType = 0; 1755 out_item->uEnchantmentType = 0;
1756 } 1756 }
1757 //try get special enhansment 1757 //try get special enhansment
1758 switch (pItems[out_item->uItemID].uEquipType) 1758 switch (pItems[out_item->uItemID].uEquipType)
1759 { 1759 {
1760 case EQUIP_ONE_OR_TWO_HANDS: 1760 case EQUIP_ONE_OR_TWO_HANDS:
1771 case EQUIP_BELT : 1771 case EQUIP_BELT :
1772 case EQUIP_CLOAK : 1772 case EQUIP_CLOAK :
1773 case EQUIP_GAUNTLETS : 1773 case EQUIP_GAUNTLETS :
1774 case EQUIP_BOOTS : 1774 case EQUIP_BOOTS :
1775 case EQUIP_RING : 1775 case EQUIP_RING :
1776 v22 = uBonusChanceStandart[v6]; 1776
1777 if ( !uBonusChanceStandart[v6] ) 1777 if ( !uBonusChanceStandart[v6] )
1778 return; 1778 return;
1779 v24 = v22;
1780 special_chance = rand() % 100; 1779 special_chance = rand() % 100;
1781 if ( !uBonusChanceSpecial[v6] && !(special_chance < uBonusChanceStandart[v6]))
1782 return;
1783 if ( special_chance < uBonusChanceStandart[v6]) 1780 if ( special_chance < uBonusChanceStandart[v6])
1784 { 1781 {
1785 v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[out_item->uItemID].uEquipType + 3]; 1782 v26 = rand() %pEnchantmentsSumm[pItems[out_item->uItemID].uEquipType-3];
1786 v27 = out_item->uItemID; 1783 out_item->uEnchantmentType = 0;
1787 out_item->uEncantmentType = 0; 1784 v27=pEnchantments[out_item->uEnchantmentType].to_item[pItems[out_item->uItemID].uEquipType-3];
1788 for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; 1785 if (v26>v27 )
1789 i < v26;
1790 i += pEnchantments[out_item->uEncantmentType].to_item[pItems[v29].uEquipType + 1] )
1791 { 1786 {
1792 v29 = out_item->uItemID; 1787 do
1793 ++out_item->uEncantmentType; 1788 {
1794 } 1789 ++out_item->uEnchantmentType;
1795 ++out_item->uEncantmentType; 1790 v27+=pEnchantments[out_item->uEnchantmentType].to_item[pItems[out_item->uItemID].uEquipType-3];
1796 v30 = bonus_ranges[v6].minR; 1791 } while (v26>v27);
1797 v32 = out_item->uEncantmentType - 1; 1792 }
1798 v33 = rand() % (bonus_ranges[v6].maxR - v30 + 1) + v30; 1793 ++out_item->uEnchantmentType;
1799 out_item->_bonus_strength = v33; 1794
1800 if ( v32 == 21 || v32 == 22 || v32 == 23 ) 1795 v33 = rand() % (bonus_ranges[v6].maxR - bonus_ranges[v6].minR + 1);
1801 out_item->_bonus_strength = v33 >> 1; 1796 out_item->_bonus_strength = v33 + bonus_ranges[v6].minR;
1797 v32 = out_item->uEnchantmentType - 1;
1798 if ( v32 == 21 || v32 == 22 || v32 == 23 ) //Armsmaster skill, Dodge skill, Unarmed skill
1799 out_item->_bonus_strength = out_item->_bonus_strength/2;
1802 if ( out_item->_bonus_strength <= 0 ) 1800 if ( out_item->_bonus_strength <= 0 )
1803 out_item->_bonus_strength = 1; 1801 out_item->_bonus_strength = 1;
1804 return; 1802 return;
1805 1803
1806 } 1804 }
1805 if ( !uBonusChanceSpecial[v6])
1806 return;
1807 v34 = uBonusChanceStandart[v6] + uBonusChanceSpecial[v6]; 1807 v34 = uBonusChanceStandart[v6] + uBonusChanceSpecial[v6];
1808 if ( special_chance<v34 ) 1808 if ( special_chance>v34 )
1809 return; 1809 return;
1810 break; 1810 break;
1811 case EQUIP_WAND: 1811 case EQUIP_WAND:
1812 out_item->uNumCharges = rand() % 6 + pItemsTable->pItems[out_item->uItemID].uDamageMod + 1; 1812 out_item->uNumCharges = rand() % 6 + pItemsTable->pItems[out_item->uItemID].uDamageMod + 1;
1813 out_item->uMaxCharges = out_item->uNumCharges; 1813 out_item->uMaxCharges = out_item->uNumCharges;