Mercurial > mm7
comparison Items.cpp @ 1709:8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
author | Grumpy7 |
---|---|
date | Tue, 24 Sep 2013 07:29:55 +0200 |
parents | 2a309997c42f |
children | bdac32c645c5 |
comparison
equal
deleted
inserted
replaced
1708:f8414042db1f | 1709:8251e59fd7c1 |
---|---|
1477 unsigned __int8 equip_type; | 1477 unsigned __int8 equip_type; |
1478 const char *player_name; | 1478 const char *player_name; |
1479 const char *nameModificator; | 1479 const char *nameModificator; |
1480 const char *format_str; | 1480 const char *format_str; |
1481 | 1481 |
1482 equip_type = pItemsTable->pItems[uItemID].uEquipType; | 1482 equip_type = GetItemEquipType(); |
1483 if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) | 1483 if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) |
1484 { | 1484 { |
1485 sprintf(item__getname_buffer.data(), "%s", pItemsTable->pItems[uItemID].pName); | 1485 sprintf(item__getname_buffer.data(), "%s", pItemsTable->pItems[uItemID].pName); |
1486 return item__getname_buffer.data(); | 1486 return item__getname_buffer.data(); |
1487 } | 1487 } |
1697 tmp_chance += pItems[val_list[j]].uChanceByTreasureLvl[treasure_level - 1]; | 1697 tmp_chance += pItems[val_list[j]].uChanceByTreasureLvl[treasure_level - 1]; |
1698 } | 1698 } |
1699 while ( tmp_chance < current_chance ); | 1699 while ( tmp_chance < current_chance ); |
1700 } | 1700 } |
1701 | 1701 |
1702 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) | 1702 if (out_item->GetItemEquipType() == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) |
1703 {// if it potion set potion spec | 1703 {// if it potion set potion spec |
1704 out_item->uEnchantmentType = 0; | 1704 out_item->uEnchantmentType = 0; |
1705 for (int i=0; i<2; ++i) | 1705 for (int i=0; i<2; ++i) |
1706 out_item->uEnchantmentType += rand() % 4 + 1; | 1706 out_item->uEnchantmentType += rand() % 4 + 1; |
1707 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; | 1707 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; |
1740 | 1740 |
1741 if ( !v18 ) | 1741 if ( !v18 ) |
1742 out_item->uItemID = 1; | 1742 out_item->uItemID = 1; |
1743 if ( !out_item->uItemID ) | 1743 if ( !out_item->uItemID ) |
1744 out_item->uItemID = 1; | 1744 out_item->uItemID = 1; |
1745 if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) | 1745 if (out_item->GetItemEquipType() == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) |
1746 {// if it potion set potion spec | 1746 {// if it potion set potion spec |
1747 out_item->uEnchantmentType = 0; | 1747 out_item->uEnchantmentType = 0; |
1748 for (int i=0; i<2; ++i) | 1748 for (int i=0; i<2; ++i) |
1749 out_item->uEnchantmentType += rand() % 4 + 1; | 1749 out_item->uEnchantmentType += rand() % 4 + 1; |
1750 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; | 1750 out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; |
1758 if ( pItemsTable->pItems[out_item->uItemID + 1].uItemID_Rep_St ) | 1758 if ( pItemsTable->pItems[out_item->uItemID + 1].uItemID_Rep_St ) |
1759 out_item->uAttributes = 0; | 1759 out_item->uAttributes = 0; |
1760 else | 1760 else |
1761 out_item->uAttributes = 1; | 1761 out_item->uAttributes = 1; |
1762 | 1762 |
1763 if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) | 1763 if ( out_item->GetItemEquipType() != EQUIP_POTION ) |
1764 { | 1764 { |
1765 out_item->uSpecEnchantmentType = 0; | 1765 out_item->uSpecEnchantmentType = 0; |
1766 out_item->uEnchantmentType = 0; | 1766 out_item->uEnchantmentType = 0; |
1767 } | 1767 } |
1768 //try get special enhansment | 1768 //try get special enhansment |
1769 switch (pItems[out_item->uItemID].uEquipType) | 1769 switch (out_item->GetItemEquipType()) |
1770 { | 1770 { |
1771 case EQUIP_OFF_HAND: | 1771 case EQUIP_OFF_HAND: |
1772 case EQUIP_MAIN_HAND : | 1772 case EQUIP_MAIN_HAND : |
1773 case EQUIP_BOW : | 1773 case EQUIP_BOW : |
1774 if ( !uBonusChanceWpSpecial[v6] ) | 1774 if ( !uBonusChanceWpSpecial[v6] ) |
1788 if ( !uBonusChanceStandart[v6] ) | 1788 if ( !uBonusChanceStandart[v6] ) |
1789 return; | 1789 return; |
1790 special_chance = rand() % 100; | 1790 special_chance = rand() % 100; |
1791 if ( special_chance < uBonusChanceStandart[v6]) | 1791 if ( special_chance < uBonusChanceStandart[v6]) |
1792 { | 1792 { |
1793 v26 = rand() %pEnchantmentsSumm[pItems[out_item->uItemID].uEquipType-3]; | 1793 v26 = rand() %pEnchantmentsSumm[out_item->GetItemEquipType()-3]; |
1794 out_item->uEnchantmentType = 0; | 1794 out_item->uEnchantmentType = 0; |
1795 v27=pEnchantments[out_item->uEnchantmentType].to_item[pItems[out_item->uItemID].uEquipType-3]; | 1795 v27=pEnchantments[out_item->uEnchantmentType].to_item[out_item->GetItemEquipType()-3]; |
1796 if (v26>v27 ) | 1796 if (v26>v27 ) |
1797 { | 1797 { |
1798 do | 1798 do |
1799 { | 1799 { |
1800 ++out_item->uEnchantmentType; | 1800 ++out_item->uEnchantmentType; |
1801 v27+=pEnchantments[out_item->uEnchantmentType].to_item[pItems[out_item->uItemID].uEquipType-3]; | 1801 v27+=pEnchantments[out_item->uEnchantmentType].to_item[out_item->GetItemEquipType()-3]; |
1802 } while (v26>v27); | 1802 } while (v26>v27); |
1803 } | 1803 } |
1804 ++out_item->uEnchantmentType; | 1804 ++out_item->uEnchantmentType; |
1805 | 1805 |
1806 v33 = rand() % (bonus_ranges[v6].maxR - bonus_ranges[v6].minR + 1); | 1806 v33 = rand() % (bonus_ranges[v6].maxR - bonus_ranges[v6].minR + 1); |
1818 v34 = uBonusChanceStandart[v6] + uBonusChanceSpecial[v6]; | 1818 v34 = uBonusChanceStandart[v6] + uBonusChanceSpecial[v6]; |
1819 if ( special_chance>v34 ) | 1819 if ( special_chance>v34 ) |
1820 return; | 1820 return; |
1821 break; | 1821 break; |
1822 case EQUIP_WAND: | 1822 case EQUIP_WAND: |
1823 out_item->uNumCharges = rand() % 6 + pItemsTable->pItems[out_item->uItemID].uDamageMod + 1; | 1823 out_item->uNumCharges = rand() % 6 + out_item->GetDamageMod() + 1; |
1824 out_item->uMaxCharges = out_item->uNumCharges; | 1824 out_item->uMaxCharges = out_item->uNumCharges; |
1825 default: | 1825 default: |
1826 return; | 1826 return; |
1827 } | 1827 } |
1828 | 1828 |
1836 switch ( treasure_level - 1 ) | 1836 switch ( treasure_level - 1 ) |
1837 { | 1837 { |
1838 case 2: | 1838 case 2: |
1839 if ((tr_lv==1)||(tr_lv==0)) | 1839 if ((tr_lv==1)||(tr_lv==0)) |
1840 { | 1840 { |
1841 spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType]; | 1841 spc=pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()]; |
1842 spc_sum+=spc; | 1842 spc_sum+=spc; |
1843 if(spc) | 1843 if(spc) |
1844 { | 1844 { |
1845 val_list[j++]=i; | 1845 val_list[j++]=i; |
1846 } | 1846 } |
1847 } | 1847 } |
1848 break; | 1848 break; |
1849 case 3: | 1849 case 3: |
1850 if ((tr_lv==2)||(tr_lv==1)||(tr_lv==0)) | 1850 if ((tr_lv==2)||(tr_lv==1)||(tr_lv==0)) |
1851 { | 1851 { |
1852 spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType]; | 1852 spc=pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()]; |
1853 spc_sum+=spc; | 1853 spc_sum+=spc; |
1854 if(spc) | 1854 if(spc) |
1855 { | 1855 { |
1856 val_list[j++]=i; | 1856 val_list[j++]=i; |
1857 } | 1857 } |
1858 } | 1858 } |
1859 break; | 1859 break; |
1860 case 4: | 1860 case 4: |
1861 if ((tr_lv==3)||(tr_lv==2)||(tr_lv==1)) | 1861 if ((tr_lv==3)||(tr_lv==2)||(tr_lv==1)) |
1862 { | 1862 { |
1863 spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType]; | 1863 spc=pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()]; |
1864 spc_sum+=spc; | 1864 spc_sum+=spc; |
1865 if(spc) | 1865 if(spc) |
1866 { | 1866 { |
1867 val_list[j++]=i; | 1867 val_list[j++]=i; |
1868 } | 1868 } |
1869 } | 1869 } |
1870 break; | 1870 break; |
1871 case 5: | 1871 case 5: |
1872 if (tr_lv==3) | 1872 if (tr_lv==3) |
1873 { | 1873 { |
1874 spc=pSpecialEnchantments[i].to_item_apply[pItems[out_item->uItemID].uEquipType]; | 1874 spc=pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()]; |
1875 spc_sum+=spc; | 1875 spc_sum+=spc; |
1876 if(spc) | 1876 if(spc) |
1877 { | 1877 { |
1878 val_list[j++]=i; | 1878 val_list[j++]=i; |
1879 } | 1879 } |
1883 } | 1883 } |
1884 | 1884 |
1885 v46 = rand()%spc_sum+1; | 1885 v46 = rand()%spc_sum+1; |
1886 j=0; | 1886 j=0; |
1887 out_item->uSpecEnchantmentType =val_list[j]; | 1887 out_item->uSpecEnchantmentType =val_list[j]; |
1888 v45=pSpecialEnchantments[val_list[j]].to_item_apply[pItems[out_item->uItemID].uEquipType]; | 1888 v45=pSpecialEnchantments[val_list[j]].to_item_apply[out_item->GetItemEquipType()]; |
1889 if (v45<v46) | 1889 if (v45<v46) |
1890 { | 1890 { |
1891 do | 1891 do |
1892 { | 1892 { |
1893 ++j; | 1893 ++j; |
1894 out_item->uSpecEnchantmentType=val_list[j]; | 1894 out_item->uSpecEnchantmentType=val_list[j]; |
1895 v45+=pSpecialEnchantments[val_list[j]].to_item_apply[pItems[out_item->uItemID].uEquipType]; | 1895 v45+=pSpecialEnchantments[val_list[j]].to_item_apply[out_item->GetItemEquipType()]; |
1896 } while (v45<v46); | 1896 } while (v45<v46); |
1897 } | 1897 } |
1898 ++out_item->uSpecEnchantmentType; | 1898 ++out_item->uSpecEnchantmentType; |
1899 } | 1899 } |
1900 | 1900 |
2396 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second; | 2396 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second; |
2397 return (currList->find(attrToGet) != currList->end()); | 2397 return (currList->find(attrToGet) != currList->end()); |
2398 return false; | 2398 return false; |
2399 } | 2399 } |
2400 | 2400 |
2401 ITEM_EQUIP_TYPE ItemGen::GetItemEquipType() | |
2402 { | |
2403 return pItemsTable->pItems[this->uItemID].uEquipType; | |
2404 } | |
2405 | |
2406 unsigned char ItemGen::GetPlayerSkillType() | |
2407 { | |
2408 return pItemsTable->pItems[this->uItemID].uSkillType; | |
2409 } | |
2410 | |
2411 char* ItemGen::GetIconName() | |
2412 { | |
2413 return pItemsTable->pItems[this->uItemID].pIconName; | |
2414 } | |
2415 | |
2416 unsigned __int8 ItemGen::GetDamageDice() | |
2417 { | |
2418 return pItemsTable->pItems[this->uItemID].uDamageDice; | |
2419 } | |
2420 | |
2421 unsigned __int8 ItemGen::GetDamageRoll() | |
2422 { | |
2423 return pItemsTable->pItems[this->uItemID].uDamageRoll; | |
2424 } | |
2425 | |
2426 unsigned __int8 ItemGen::GetDamageMod() | |
2427 { | |
2428 return pItemsTable->pItems[this->uItemID].uDamageMod; | |
2429 } | |
2401 //----- (004B8E3D) -------------------------------------------------------- | 2430 //----- (004B8E3D) -------------------------------------------------------- |
2402 void GenerateStandartShopItems() | 2431 void GenerateStandartShopItems() |
2403 { | 2432 { |
2404 signed int item_count; | 2433 signed int item_count; |
2405 signed int shop_index; | 2434 signed int shop_index; |