Mercurial > mm7
changeset 223:1bd823f52e3a
Merge
author | Gloval |
---|---|
date | Sun, 17 Feb 2013 11:41:44 +0400 |
parents | 8113753ed2ae (diff) 335db7429f7c (current diff) |
children | 9917d3b4925e |
files | Items.cpp Items.h Player.cpp mm7_1.cpp mm7_5.cpp mm7_6.cpp stru157.h |
diffstat | 7 files changed, 993 insertions(+), 600 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Sun Feb 17 05:31:47 2013 +0200 +++ b/AudioPlayer.cpp Sun Feb 17 11:41:44 2013 +0400 @@ -2066,7 +2066,7 @@ int Data; // [sp+Ch] [bp-8h]@1 HKEY hKey; // [sp+10h] [bp-4h]@1 char v6; // [sp+1Ch] [bp+8h]@0 - + v6=0; //to fix hKey = 0; cbData = 4; Data = 0;
--- a/Items.cpp Sun Feb 17 05:31:47 2013 +0200 +++ b/Items.cpp Sun Feb 17 11:41:44 2013 +0400 @@ -248,8 +248,8 @@ char v4; // cl@3 int v5; // esi@3 char *v6; // esi@21 - char *v7; // eax@21 - char *v8; // ecx@22 + unsigned char *v7; // eax@21 + unsigned char *v8; // ecx@22 char *v9; // eax@26 char v10; // dl@27 int v11; // ecx@27 @@ -345,7 +345,14 @@ 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; pMapStats = new MapStats; @@ -368,234 +375,516 @@ pStorylineText->Initialize(); pStdItemsTXT_Raw = 0; - v2 = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); - pStdItemsTXT_Raw = v2; - strtok(v2, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - Str = (char *)&pEnchantments[0].pParam; - v79 = 24; - do - { - v3 = strtok(0, "\r") + 1; - v97 = 0; - v88 = 0; - do - { - v4 = *v3; - v5 = 0; - while ( v4 != 9 && v4 ) - { - ++v5; - v4 = v3[v5]; - } - v72 = (int)&v3[v5]; - if ( !v3[v5] ) - v88 = 1; - v3[v5] = 0; - if ( v5 ) - { - if ( v97 ) - { - if ( v97 == 1 ) - { - *(unsigned int *)Str = (int)RemoveQuotes(v3); - } - else - { - if ( v97 > 1 ) - Str[v97 + 6] = atoi(v3); - } - } - else - { - *((char **)Str + 1) = RemoveQuotes(v3); - } - } - else - { - if ( !v97 ) - v88 = 1; - } - ++v97; - v3 = (char *)(v72 + 1); - } - while ( v97 <= 10 && !v88 ); - Str += 20; - --v79; - } - while ( v79 ); - v6 = (char *)&field_116D8[3]; - memset(&field_116D8[3], 0, 0x24u); - v7 = &pEnchantments[0].field_8[4]; - v73 = 9; - do - { - v8 = v7; - Stra = 24; - do - { - *(unsigned int *)v6 += (unsigned __int8)*v8; - v8 += 20; - --Stra; - } - while ( Stra ); - v6 += 4; - ++v7; - --v73; - } - while ( v73 ); - strtok(0, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - Strb = 17856; - do - { - v9 = strtok(0, "\r") + 1; - v98 = 0; - v89 = 0; - do - { - v10 = *v9; - v11 = 0; - while ( v10 != 9 && v10 ) - { - ++v11; - v10 = v9[v11]; - } - v12 = (int)&v9[v11]; - if ( !v9[v11] ) - v89 = 1; - *(unsigned char *)v12 = 0; - if ( v11 && v98 > 1 ) - *(&pItems[0].uItemID + v98 + Strb) = atoi(v9); - ++v98; - v9 = (char *)(v12 + 1); - } - while ( v98 < 4 && !v89 ); - Strb += 2; - } - while ( Strb < 17868 ); + 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); + } + + pSpcItemsTXT_Raw = 0; - v13 = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); - pSpcItemsTXT_Raw = v13; - strtok(v13, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - strtok(0, "\r"); - v80 = (char *)&pSpecialEnchantments[0].pParam; - Strc = 72; - do - { - v99 = 0; - v14 = (int)(strtok(0, "\r") + 1); - v90 = 0; - do - { - v15 = *(unsigned char *)v14; - v16 = 0; - while ( v15 != 9 && v15 ) - { - ++v16; - v15 = *(unsigned char *)(v16 + v14); - } - v74 = v16 + v14; - if ( !*(unsigned char *)(v16 + v14) ) - v90 = 1; - *(unsigned char *)(v16 + v14) = 0; - if ( v16 ) - { - if ( v99 ) - { - if ( v99 == 1 ) - { - *(char **)v80 = RemoveQuotes((char *)v14); - } - else - { - if ( v99 <= 1 ) - { - v17 = v99 == 14; - } - else - { - v17 = v99 == 14; - if ( v99 < 14 ) - { - v80[v99 + 6] = atoi((const char *)v14); - goto LABEL_63; - } - } - if ( v17 ) - { - v18 = atoi((const char *)v14); - *((unsigned int *)v80 + 5) = v18; - if ( !v18 ) - *((unsigned int *)v80 + 5) = atoi((const char *)(v14 + 1)); - } - else - { - if ( v99 == 15 ) - v80[24] = tolower(*(unsigned char *)v14) - 97; - } - } - } - else - { - *((char **)v80 + 1) = RemoveQuotes((char *)v14); - } - } - else - { - if ( !v99 ) - v90 = 1; - } -LABEL_63: - ++v99; - v14 = v74 + 1; - } - while ( v99 <= 15 && !v90 ); - v80 += 28; - --Strc; - } - while ( Strc ); - v19 = field_11738; - memset(field_11738, 0, 0x60u); - v20 = &pSpecialEnchantments[0].field_8[4]; - Strd = 12; - v21 = 71; - field_11798 = 71; - do - { - v83 = 0; - if ( v21 > 0 ) - { - v22 = v20; - do - { - *v19 += (unsigned __int8)*v22; - ++v83; - v21 = field_11798; - v22 += 28; - } - while ( v83 < v21 ); - } - ++v19; - ++v20; - --Strd; - } - while ( Strd ); + 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]; + } + + + Initialize2DA(); - pItemsTXT_Raw = 0; - v23 = (char *)pEvents_LOD->LoadRaw("items.txt", 0); - pItemsTXT_Raw = v23; - strtok(v23, "\r"); - v24 = 0; - strtok(0, "\r"); - pItems[0].uItemID = 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; + 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 # + item_counter=atoi(test_string); + uAllItemsCount=item_counter; + break; + case 1: //Pic File + pItems[item_counter].pIconName = RemoveQuotes(test_string); + break; + case 2: //Name + pItems[item_counter].pName = RemoveQuotes(test_string); + break; + case 3: //Value + pItems[item_counter].uValue=atoi(test_string); + break; + case 4: //Equip Stat + { + if ( !_strcmpi(test_string, "weapon") ) + { + pItems[item_counter].uEquipType = 0; + break; + } + if ( !_strcmpi(test_string, "weapon2") ) + { + pItems[item_counter].uEquipType = 1; + break; + } + if ( !_strcmpi(test_string, "weapon1or2") ) + { + pItems[item_counter].uEquipType = 0; + break; + } + if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow"))) + { + pItems[item_counter].uEquipType = 2; + break; + } + if ( !_strcmpi(test_string, "armor") ) + { + pItems[item_counter].uEquipType = 3; + break; + } + if ( !_strcmpi(test_string, "shield") ) + { + pItems[item_counter].uEquipType = 4; + break; + } + if ( !_strcmpi(test_string, "helm") ) + { + pItems[item_counter].uEquipType = 5; + break; + } + if ( !_strcmpi(test_string, "belt") ) + { + pItems[item_counter].uEquipType = 6; + break; + } + if ( !_strcmpi(test_string, "cloak") ) + { + pItems[item_counter].uEquipType = 7; + break; + } + if ( !_strcmpi(test_string, "gauntlets") ) + { + pItems[item_counter].uEquipType = 8; + break; + } + if ( !_strcmpi(test_string, "boots") ) + { + pItems[item_counter].uEquipType = 9; + break; + } + if ( !_strcmpi(test_string, "ring") ) + { + pItems[item_counter].uEquipType = 10; + break; + } + if ( !_strcmpi(test_string, "amulet") ) + { + pItems[item_counter].uEquipType = 11; + break; + } + if ( !_strcmpi(test_string, "weaponw") ) + { + pItems[item_counter].uEquipType = 12; + break; + } + if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent"))) + { + pItems[item_counter].uEquipType = 13; + break; + } + if ( !_strcmpi(test_string, "bottle") ) + { + pItems[item_counter].uEquipType = 14; + break; + } + if ( !_strcmpi(test_string, "sscroll") ) + { + pItems[item_counter].uEquipType = 15; + break; + } + if ( !_strcmpi(test_string, "book") ) + { + pItems[item_counter].uEquipType = 16; + break; + } + if ( !_strcmpi(test_string, "mscroll") ) + { + pItems[item_counter].uEquipType = 17; + break; + } + if ( !_strcmpi(test_string, "gold") ) + { + pItems[item_counter].uEquipType = 18; + break; + } + if ( !_strcmpi(test_string, "gem") ) + { + pItems[item_counter].uEquipType = 19; + break; + } + pItems[item_counter].uEquipType = 20; + break; + } + case 5: //Skill Group + { + if ( !_strcmpi(test_string, "staff") ) + { + pItems[item_counter].uSkillType = 0; + break; + } + if ( !_strcmpi(test_string, "sword") ) + { + pItems[item_counter].uSkillType = 1; + break; + } + if ( !_strcmpi(test_string, "dagger") ) + { + pItems[item_counter].uSkillType = 2; + break; + } + if ( !_strcmpi(test_string, "axe") ) + { + pItems[item_counter].uSkillType = 3; + break; + } + if ( !_strcmpi(test_string, "spear") ) + { + pItems[item_counter].uSkillType = 4; + break; + } + if ( !_strcmpi(test_string, "bow") ) + { + pItems[item_counter].uSkillType = 5; + break; + } + if ( !_strcmpi(test_string, "mace") ) + { + pItems[item_counter].uSkillType = 6; + break; + } + if ( !_strcmpi(test_string, "blaster") ) + { + pItems[item_counter].uSkillType = 7; + break; + } + if ( !_strcmpi(test_string, "shield") ) + { + pItems[item_counter].uSkillType = 8; + break; + } + if ( !_strcmpi(test_string, "leather") ) + { + pItems[item_counter].uSkillType = 9; + break; + } + if ( !_strcmpi(test_string, "chain") ) + { + pItems[item_counter].uSkillType = 10; + break; + } + if ( !_strcmpi(test_string, "plate") ) + { + pItems[item_counter].uSkillType = 11; + break; + } + if ( !_strcmpi(test_string, "club") ) + { + pItems[item_counter].uSkillType = 37; + break; + } + pItems[item_counter].uSkillType = 38; + break; + } + case 6: //Mod1 + { + int ii; + char* test_char; + int tst_len; + tst_len=strlen(test_string); + pItems[item_counter].uDamageDice=0; + pItems[item_counter].uDamageRoll=0; + test_char=test_string; + for (ii=0; ii<tst_len; ++ii) + { + if (tolower(*test_char)=='d') + { + *test_char=0; + pItems[item_counter].uDamageDice=atoi(test_string); + pItems[item_counter].uDamageRoll=atoi(test_char+1); + *test_char='d'; + break; + } + ++test_char; + } + test_char=test_string; + if ((ii==tst_len)&&(tolower(*test_char)=='s')) + { + pItems[item_counter].uDamageDice=atoi(test_char+1); + pItems[item_counter].uDamageRoll=1; + } + break; + } + case 7: //Mod2 + pItems[item_counter].uDamageMod=atoi(test_string); + break; + case 8: //material + { + if ( !_strcmpi(test_string, "artifact") ) + { + pItems[item_counter].uMaterial = 1; + break; + } + if ( !_strcmpi(test_string, "relic") ) + { + pItems[item_counter].uMaterial = 2; + break; + } + if ( !_strcmpi(test_string, "special") ) + { + pItems[item_counter].uMaterial = 3; + break; + } + pItems[item_counter].uMaterial = 0; + break;} + case 9: //ID/Rep/St + pItems[item_counter].uItemID_Rep_St=atoi(test_string); + break; + case 10: //Not identified name + pItems[item_counter].pUnidentifiedName = RemoveQuotes(test_string); + break; + case 11: //Sprite Index + 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; + break; + } + } + if (!pItems[item_counter]._bonus_type) + { + for(int ii=0; ii<72; ++ii) + { + if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement)) + { + pItems[item_counter]._additional_value=ii+1; + } + } + } + } + + break; + case 13: //VarB + if ((pItems[item_counter].uMaterial==3)&&(pItems[item_counter]._bonus_type)) + { + char b_s=atoi(test_string); + if (b_s) + pItems[item_counter]._bonus_strength=b_s; + else + pItems[item_counter]._bonus_strength=1; + } + else + pItems[item_counter]._bonus_strength=0; + break; + case 14: //Equip X + pItems[item_counter].uEquipX=atoi(test_string); + break; + case 15: //Equip Y + pItems[item_counter].uEquipY=atoi(test_string); + break; + case 16: //Notes + pItems[item_counter].pDescription = RemoveQuotes(test_string); + break; + + } + } + else + { + if (!decode_step) + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<17)&&!break_loop); + ++item_counter; + if (item_counter>799) + break; + } + +/* while ( 2 ) { v100 = 0; @@ -925,7 +1214,7 @@ if ( v30[37] == 3 ) { v85 = 0; - Strf = (const char **)&pEnchantments[0].pParam; + Strf = (const char **)&pEnchantments[0].pOfName; while ( _strcmpi(*Strf, v25) ) { ++v85; @@ -938,7 +1227,7 @@ if ( !v81[39] ) { v86 = 0; - Strg = (const char **)&pSpecialEnchantments[0].pParam; + Strg = (const char **)&pSpecialEnchantments[0].pNameAdd; while ( _strcmpi(*Strg, v25) ) { ++v86; @@ -995,16 +1284,17 @@ continue; break; } - pRndItemsTXT_Raw = 0; - pItems[0].uItemID = v24; - v33 = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); - v34 = "\r"; - pRndItemsTXT_Raw = v33; - strtok(v33, "\r"); - v35 = 0; + */ + + 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"); + + v35 = 0; do { v101 = 0; @@ -1029,15 +1319,23 @@ { switch ( v101 ) { - case 2: pItems[v35].field_2C[0] = atoi(v36); break; - case 3: pItems[v35].field_2C[1] = atoi(v36); break; - case 4: pItems[v35].field_2C[2] = atoi(v36); break; - case 5: pItems[v35].field_2C[3] = atoi(v36); break; + 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); + //*((unsigned char *)&pItems[0].uItemID + 16 * (3 * v35 + 3)) = atoi(v36); break; case 7: - BYTE1(pItems[v35 + 1].uItemID) = atoi(v36); + // BYTE1(pItems[v35 + 1].uItemID) = atoi(v36); break; } } @@ -1058,6 +1356,8 @@ ++v35; } while ( v35 < 619 ); + + if ( pRndItemsTXT_Raw ) { pAllocator->FreeChunk(pRndItemsTXT_Raw); @@ -1065,7 +1365,7 @@ } v39 = (char *)field_11684; memset(field_11684, 0, 0x18u); - v40 = pItems[0].field_2C; + v40 = &pItems[0].field_2C; v77 = 6; do { @@ -1083,6 +1383,7 @@ --v77; } while ( v77 ); + v42 = 0; strtok(0, "\r"); strtok(0, "\r"); @@ -1230,6 +1531,9 @@ ++v87; } while ( v87 < 3 ); + + + pSkillDescTXT_Raw = 0; pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); strtok(pSkillDescTXT_Raw, "\r"); @@ -1285,6 +1589,8 @@ ++v46; } while ( v46 < 37 ); + + pStatsTXT_Raw = 0; pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); strtok(pStatsTXT_Raw, "\r"); @@ -1293,7 +1599,7 @@ { v51 = 0; v95 = 0; - v52 = strtok(0, v34) + 1; + v52 = strtok(0, pStatsTXT_Raw) + 1; do { v53 = *v52; @@ -1403,6 +1709,8 @@ ++Stri; } while ( Stri < 26 ); + + pClassTXT_Raw = 0; pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); strtok(pClassTXT_Raw, v34); @@ -1483,18 +1791,18 @@ //----- (00453B3C) -------------------------------------------------------- void ItemsTable::LoadPotions() -{ - - CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26 - char* test_string; - unsigned int uRow; - unsigned int uColumn; - unsigned __int8 potion_value; + { - if ( pPotionsTXT_Raw ) - pAllocator->FreeChunk(pPotionsTXT_Raw); - pPotionsTXT_Raw = NULL; - pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); + CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26 + char* test_string; + unsigned int uRow; + unsigned int uColumn; + unsigned __int8 potion_value; + + if ( pPotionsTXT_Raw ) + pAllocator->FreeChunk(pPotionsTXT_Raw); + pPotionsTXT_Raw = NULL; + pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); test_string = strtok(pPotionsTXT_Raw,"\t\r\n"); while ( 1 ) { @@ -1505,142 +1813,140 @@ } if ( !strcmp(test_string, "222") ) break; - + test_string = strtok(NULL, "\t\r\n"); } - while ( 1 ) - { - test_string = strtok(NULL, "\t\r\n"); - - if ( !test_string ) + while ( 1 ) { - MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; + test_string = strtok(NULL, "\t\r\n"); + + if ( !test_string ) + { + MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); + return; + } + if ( !strcmp(test_string, "222") ) + break; } -if ( !strcmp(test_string, "222") ) - break; - } - for (uRow = 0;uRow < 50; ++uRow) - { - int skip_count; - for (skip_count = 0;skip_count < 6; ++skip_count) - { - if ( !strtok(NULL, "\r\t\n") ) - break; - } - if ( skip_count != 6 ) - break; - for (uColumn = 0; uColumn < 50; ++uColumn) + for (uRow = 0;uRow < 50; ++uRow) { - test_string = strtok(NULL, "\r\t\n"); - if ( !test_string ) - break; - potion_value = atoi(test_string); - char c=*test_string; - if ( !potion_value ) - { - if ( tolower(c) == 'e' ) - potion_value = atoi(test_string + 1); - else - potion_value = 0; - } - this->potion_data[uRow][uColumn]=potion_value; - } - if ( uColumn != 50 ) - break; - strtok(NULL, "\r\t\n"); - } + int skip_count; + for (skip_count = 0;skip_count < 6; ++skip_count) + { + if ( !strtok(NULL, "\r\t\n") ) + break; + } + if ( skip_count != 6 ) + break; + for (uColumn = 0; uColumn < 50; ++uColumn) + { + test_string = strtok(NULL, "\r\t\n"); + if ( !test_string ) + break; + potion_value = atoi(test_string); + char c=*test_string; + if ( !potion_value ) + { + if ( tolower(c) == 'e' ) + potion_value = atoi(test_string + 1); + else + potion_value = 0; + } + this->potion_data[uRow][uColumn]=potion_value; + } + if ( uColumn != 50 ) + break; + strtok(NULL, "\r\t\n"); + } - if ( uRow != 50 ) - { - wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); - MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - } - if ( pPotionsTXT_Raw ) - { - pAllocator->FreeChunk(pPotionsTXT_Raw); - pPotionsTXT_Raw = 0; - } -} + if ( uRow != 50 ) + { + wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); + MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); + } + if ( pPotionsTXT_Raw ) + { + pAllocator->FreeChunk(pPotionsTXT_Raw); + pPotionsTXT_Raw = 0; + } + } //----- (00453CE5) -------------------------------------------------------- void ItemsTable::LoadPotionNotes() -{ - - CHAR Text[90]; - char* test_string; - unsigned int uRow; - unsigned int uColumn; - unsigned __int8 potion_note; + { + + CHAR Text[90]; + char* test_string; + unsigned int uRow; + unsigned int uColumn; + unsigned __int8 potion_note; + + if ( pPotionNotesTXT_Raw ) + pAllocator->FreeChunk(pPotionNotesTXT_Raw); + pPotionNotesTXT_Raw = NULL; + pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); + test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n"); + while ( 1 ) + { + if ( !test_string ) + { + MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); + return; + } + if ( !strcmp(test_string, "222") ) + break; + test_string = strtok(NULL, "\t\r\n"); + } + while ( 1 ) + { + test_string = strtok(NULL, "\t\r\n"); + + if ( !test_string ) + { + MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); + return; + } + if ( !strcmp(test_string, "222") ) + break; + } - if ( pPotionNotesTXT_Raw ) - pAllocator->FreeChunk(pPotionNotesTXT_Raw); - pPotionNotesTXT_Raw = NULL; - pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); - test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n"); - while ( 1 ) - { - - if ( !test_string ) - { - MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - if ( !strcmp(test_string, "222") ) - break; - test_string = strtok(NULL, "\t\r\n"); - } - while ( 1 ) - { - test_string = strtok(NULL, "\t\r\n"); - - if ( !test_string ) - { - MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - if ( !strcmp(test_string, "222") ) - break; - } - - for (uRow = 0;uRow < 50; ++uRow) - { - int skip_count; - for (skip_count = 0;skip_count < 6; ++skip_count) - { - if ( !strtok(NULL, "\r\t\n") ) - break; - } - if ( skip_count != 6 ) - break; - for (uColumn = 0; uColumn < 50; ++uColumn) - { - test_string = strtok(NULL, "\r\t\n"); - if ( !test_string ) - break; - potion_note = atoi(test_string); - char c=*test_string; - if ( !potion_note ) - { - if ( tolower(c) == 'e' ) - potion_note = atoi(test_string + 1); - else - potion_note = 0; - } - this->potion_note[uRow][uColumn]=potion_note; - } - if ( uColumn != 50 ) - break; - strtok(NULL, "\r\t\n"); - } - - if ( uRow != 50 ) - { - wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); - MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - } -} + for (uRow = 0;uRow < 50; ++uRow) + { + int skip_count; + for (skip_count = 0;skip_count < 6; ++skip_count) + { + if ( !strtok(NULL, "\r\t\n") ) + break; + } + if ( skip_count != 6 ) + break; + for (uColumn = 0; uColumn < 50; ++uColumn) + { + test_string = strtok(NULL, "\r\t\n"); + if ( !test_string ) + break; + potion_note = atoi(test_string); + char c=*test_string; + if ( !potion_note ) + { + if ( tolower(c) == 'e' ) + potion_note = atoi(test_string + 1); + else + potion_note = 0; + } + this->potion_note[uRow][uColumn]=potion_note; + } + if ( uColumn != 50 ) + break; + strtok(NULL, "\r\t\n"); + } + if ( uRow != 50 ) + { + wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); + MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); + } + } //----- (00456442) -------------------------------------------------------- @@ -1669,7 +1975,7 @@ } else { - v3 = *(unsigned int *)&pItemsTable->pEnchantments[23].field_8[28 * v4 + 8]; + v3 = *(unsigned int *)&pItemsTable->pEnchantments[23].to_item[28 * v4 + 8]; if ( (unsigned int)v3 > 0xA ) return uBaseValue + v3; result = uBaseValue * v3; @@ -1765,12 +2071,12 @@ sprintf( item__getname_buffer, "%s %s", - *(unsigned int *)&pItemsTable->pEnchantments[22].field_8[28 * v7 + 8], + *(unsigned int *)&pItemsTable->pEnchantments[22].to_item[28 * v7 + 8], pItemsTable->pItems[v1->uItemID].pName); return v4; } strcat(item__getname_buffer, " "); - v9 = *(const char **)&pItemsTable->pEnchantments[22].field_8[28 * v1->uAdditionalValue + 8]; + v9 = *(const char **)&pItemsTable->pEnchantments[22].to_item[28 * v1->uAdditionalValue + 8]; } strcat(item__getname_buffer, v9); } @@ -1779,14 +2085,14 @@ //----- (00456620) -------------------------------------------------------- -void ItemsTable::GenerateItem(int a2, int a3, ItemGen *out_item) +void ItemsTable::GenerateItem(int a2, int a3, ItemGen *pItem) { - //ItemGen *v4; // esi@1 - //ItemsTable *v5; // edi@1 + ItemGen *v4; // esi@1 + ItemsTable *v5; // edi@1 int v6; // ebx@3 int *v7; // ecx@33 - //int v8; // eax@34 - //int v9; // eax@39 + int v8; // eax@34 + int v9; // eax@39 int v10; // ebx@43 int v11; // ecx@47 unsigned int *v12; // edx@48 @@ -1828,101 +2134,163 @@ unsigned int v48; // ecx@123 int v49; // eax@123 int v50; // eax@123 - int Dst[800]; // [sp+Ch] [bp-C88h]@33 + unsigned char Dst[0xC80]; // [sp+Ch] [bp-C88h]@33 int v52; // [sp+C8Ch] [bp-8h]@33 - //int v53; // [sp+C90h] [bp-4h]@1 + int v53; // [sp+C90h] [bp-4h]@1 int v54; // [sp+C9Ch] [bp+8h]@3 - //int v55; // [sp+CA0h] [bp+Ch]@34 + int v55; // [sp+CA0h] [bp+Ch]@34 signed int v56; // [sp+CA0h] [bp+Ch]@55 int v57; // [sp+CA0h] [bp+Ch]@62 int *v58; // [sp+CA0h] [bp+Ch]@102 int v59; // [sp+CA0h] [bp+Ch]@123 - //signed int a2a; // [sp+CA4h] [bp+10h]@33 + signed int a2a; // [sp+CA4h] [bp+10h]@33 int a2b; // [sp+CA4h] [bp+10h]@101 int a2c; // [sp+CA4h] [bp+10h]@120 - //v53 = -1; - //v4 = pItem; - //v5 = this; - if ( !out_item ) - out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen"); - memset(out_item, 0, sizeof(*out_item)); + v53 = -1; + v4 = pItem; + v5 = this; + if ( !pItem ) + v4 = (ItemGen *)pAllocator->AllocNamedChunk(pItem, 0x24u, "newItemGen"); + memset(v4, 0, 0x24u); v6 = a2 - 1; v54 = a2 - 1; if ( a3 ) { - ITEM_EQUIP_TYPE requested_equip; - PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; - switch (a3) + switch ( a3 ) { - case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break; - case 21: requested_equip = EQUIP_ARMOUR; break; - case 22: requested_skill = (PLAYER_SKILL_TYPE)38; __debugbreak();/*check this skill*/ break; - case 23: requested_skill = PLAYER_SKILL_SWORD; break; - case 24: requested_skill = PLAYER_SKILL_DAGGER; break; - case 25: requested_skill = PLAYER_SKILL_AXE; break; - case 26: requested_skill = PLAYER_SKILL_SPEAR; break; - case 27: requested_skill = PLAYER_SKILL_BOW; break; - case 28: requested_skill = PLAYER_SKILL_MACE; break; - case 29: requested_skill = (PLAYER_SKILL_TYPE)37; __debugbreak();/*check this skill*/break; - case 30: requested_skill = PLAYER_SKILL_STAFF; break; - case 31: requested_skill = PLAYER_SKILL_LEATHER; break; - case 32: requested_skill = PLAYER_SKILL_CHAIN; break; - case 33: requested_skill = PLAYER_SKILL_PLATE; break; - case 34: requested_equip = EQUIP_SHIELD; break; - case 35: requested_equip = EQUIP_HELMET; break; - case 36: requested_equip = EQUIP_BELT; break; - case 37: requested_equip = EQUIP_CLOAK; break; - case 38: requested_equip = EQUIP_GAUNTLETS; break; - case 39: requested_equip = EQUIP_BOOTS; break; - case 40: requested_equip = EQUIP_RING; break; - case 41: requested_equip = EQUIP_AMULET; break; - case 42: requested_equip = EQUIP_C; break; - case 43: requested_equip = EQUIP_F; break; - case 44: requested_equip = EQUIP_POTION; break; - case 45: requested_equip = EQUIP_REAGENT; break; - case 46: requested_equip = EQUIP_GEM; break; + case 20: + a3 = EQUIP_ONE_OR_TWO_HANDS; + break; + case 21: + a3 = 3; + break; + case 22: + v53 = 38; + break; + case 23: + v53 = 1; + break; + case 24: + v53 = 2; + break; + case 25: + v53 = 3; + break; + case 26: + v53 = 4; + break; + case 27: + v53 = 5; + break; + case 28: + v53 = 6; + break; + case 30: + v53 = 0; + break; + case 31: + v53 = 9; + break; + case 32: + v53 = 10; + break; + case 33: + v53 = 0xBu; + break; + case 34: + a3 = 4; + break; + case 35: + a3 = 5; + break; + case 36: + a3 = 6; + break; + case 37: + a3 = 7; + break; + case 38: + a3 = 8; + break; + case 39: + a3 = EQUIP_BOOTS; + break; + case 40: + a3 = EQUIP_RING; + break; + case 41: + a3 = 0xBu; + break; + case 42: + a3 = EQUIP_C; + break; + case 43: + a3 = EQUIP_F; + break; + case 44: + a3 = EQUIP_POTION; + break; + case 45: + a3 = EQUIP_REAGENT; + break; + case 46: + a3 = EQUIP_GEM; + break; + case 29: + v53 = 37; + break; default: - __debugbreak(); // check this condition - requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1); + --a3; break; } - - memset(Dst, 0, sizeof(Dst)); - + memset(&Dst, 0, 0xC80u); v52 = 0; - v7 = Dst; - - if (requested_skill == PLAYER_SKILL_INVALID) + v7 = (int *)&Dst; + a2a = 1; + if ( v53 == -1 ) { - for (uint i = 1; i < 500; ++i) + v53 = (int)&v5->pItems[1].uEquipType; + v9 = (int)(&v5->pItems[1].field_2C + v6); + do { - if (pItems[i].uEquipType == requested_equip) + if ( *(unsigned char *)v53 == a3 ) { - *v7++ = i; - v52 += pItems[i].field_2C[v6]; + *v7 = a2a; + ++v7; + v52 += *(unsigned char *)v9; } + ++a2a; + v53 += 48; + v9 += 48; } + while ( a2a < 500 ); } else { - for (uint i = 1; i < 500; ++i) + v55 = (int)&v5->pItems[1].uSkillType; + v8 = (int)(&v5->pItems[1].field_2C + v6); + do { - if (pItems[i].uSkillType == requested_skill) + if ( *(unsigned char *)v55 == v53 ) { - *v7++ = i; - v52 += pItems[i].field_2C[v6]; + *v7 = a2a; + ++v7; + v52 += *(unsigned char *)v8; } + ++a2a; + v55 += 48; + v8 += 48; } + while ( a2a < 500 ); } - v10 = 0; if ( v52 ) v10 = rand() % v52; - out_item->uItemID = *Dst; - if ( !*Dst ) - out_item->uItemID = 1; - v11 = pItems[out_item->uItemID].field_2C[v54]; + v4->uItemID = *(uint *)Dst; + if ( !Dst ) + v4->uItemID = 1; + v11 = *(&v5->pItems[v4->uItemID].field_2C + v54); if ( v11 < v10 ) { v12 = (uint *)Dst; @@ -1930,24 +2298,24 @@ { ++v12; v13 = *v12; - out_item->uItemID = *v12; - v11 += pItems[v13].field_2C[v54]; + v4->uItemID = *v12; + v11 += *(&v5->pItems[v13].field_2C + v54); } while ( v11 < v10 ); } - if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE) + if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) { - out_item->_bonus_type = 0; + v4->_bonus_type = 0; v14 = 2; do { - out_item->_bonus_type += rand() % 4 + 1; - v15 = out_item->_bonus_type; + v4->_bonus_type += rand() % 4 + 1; + v15 = v4->_bonus_type; --v14; } while ( v14 ); LABEL_72: - out_item->_bonus_type = v15 * (v54 + 1); + v4->_bonus_type = v15 * (v54 + 1); goto LABEL_73; } } @@ -1962,32 +2330,32 @@ if ( v54 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) { pParty->field_7BA[v17] = 1; - out_item->uAttributes = 0; - out_item->uItemID = v17 + 500; - SetSpecialBonus(out_item); + v4->uAttributes = 0; + v4->uItemID = v17 + 500; + v5->SetSpecialBonus(v4); return; } v57 = 0; - v18 = rand() % field_11684[v54]; - out_item->uItemID = 0; + v18 = rand() % v5->field_11684[v54]; + v4->uItemID = 0; if ( v18 > 0 ) { do - v57 += pItems[out_item->uItemID++ + 1].field_2C[v54]; + v57 += *(&v5->pItems[v4->uItemID++ + 1].field_2C + v54); while ( v57 < v18 ); } if ( !v18 ) - out_item->uItemID = 1; - if ( !out_item->uItemID ) - out_item->uItemID = 1; - if ( pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) + v4->uItemID = 1; + if ( !v4->uItemID ) + v4->uItemID = 1; + if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) { - out_item->_bonus_type = 0; + v4->_bonus_type = 0; v19 = 2; do { - out_item->_bonus_type += rand() % 4 + 1; - v15 = out_item->_bonus_type; + v4->_bonus_type += rand() % 4 + 1; + v15 = v4->_bonus_type; --v19; } while ( v19 ); @@ -1995,22 +2363,22 @@ } } LABEL_73: - if (out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION + if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) - out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; - if ( BYTE2(pItems[out_item->uItemID + 1].uItemID) ) - out_item->uAttributes = 0; + v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; + if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St ) + v4->uAttributes = 0; else - out_item->uAttributes = 1; - if (pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) + v4->uAttributes = 1; + if ( v5->pItems[v4->uItemID].uEquipType != EQUIP_POTION ) { - out_item->uAdditionalValue = 0; - out_item->_bonus_type = 0; + v4->uAdditionalValue = 0; + v4->_bonus_type = 0; } - v20 = pItems[out_item->uItemID].uEquipType; + v20 = v5->pItems[v4->uItemID].uEquipType; if ( v20 <= EQUIP_BOW ) { - v37 = (int)&field_1169C[4 * v54 + 48]; + v37 = (int)&v5->field_1169C[4 * v54 + 48]; if ( !*(unsigned int *)v37 ) return; v38 = rand() % 100; @@ -2023,13 +2391,13 @@ { if ( v20 == EQUIP_C ) { - v21 = rand() % 6 + pItems[out_item->uItemID].uDamageMod + 1; - out_item->uNumCharges = v21; - out_item->uMaxCharges = v21; + v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; + v4->uNumCharges = v21; + v4->uMaxCharges = v21; } return; } - v22 = (int)&field_1169C[4 * v54]; + v22 = (int)&v5->field_1169C[4 * v54]; if ( !*(unsigned int *)v22 ) return; v23 = rand(); @@ -2037,34 +2405,34 @@ v25 = v23 % 100; if ( v23 % 100 < v24 ) goto LABEL_127; - if ( !*(unsigned int *)&field_1169C[4 * v54 + 24] ) + if ( !*(unsigned int *)&v5->field_1169C[4 * v54 + 24] ) return; if ( v25 < v24 ) { LABEL_127: - v26 = rand() % field_116D8[pItems[out_item->uItemID].uEquipType]; - v27 = out_item->uItemID; - out_item->_bonus_type = 0; - for ( i = pEnchantments[0].field_8[pItems[v27].uEquipType + 1]; + v26 = rand() % 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]; i < v26; - i += pEnchantments[out_item->_bonus_type].field_8[pItems[v29].uEquipType + 1] ) + i += v5->pEnchantments[v4->_bonus_type].to_item[v5->pItems[v29].uEquipType + 1] ) { - v29 = out_item->uItemID; - ++out_item->_bonus_type; + v29 = v4->uItemID; + ++v4->_bonus_type; } - ++out_item->_bonus_type; - v30 = field_116D8[2 * v54 + 12]; + ++v4->_bonus_type; + v30 = v5->field_116D8[2 * v54 + 12]; v31 = rand(); - v32 = out_item->_bonus_type - 1; - v33 = v31 % (field_116D8[2 * v54 + 13] - v30 + 1) + v30; - out_item->_bonus_strength = v33; + v32 = v4->_bonus_type - 1; + v33 = v31 % (v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; + v4->_bonus_strength = v33; if ( v32 == 21 || v32 == 22 || v32 == 23 ) - out_item->_bonus_strength = v33 >> 1; - if ( out_item->_bonus_strength <= 0 ) - out_item->_bonus_strength = 1; + v4->_bonus_strength = v33 >> 1; + if ( v4->_bonus_strength <= 0 ) + v4->_bonus_strength = 1; return; } - v34 = v24 + *(unsigned int *)&field_1169C[4 * v54 + 24]; + v34 = v24 + *(unsigned int *)&v5->field_1169C[4 * v54 + 24]; v36 = __OFSUB__(v25, v34); v35 = v25 - v34 < 0; } @@ -2073,11 +2441,11 @@ memset(&Dst, 0, 0xC80u); v39 = 0; a2b = 0; - if ( field_11798 > 0 ) + if ( v5->pSpecialEnchantments_count > 0 ) { - v52 = -16 - (uint)this; + v52 = -16 - (uint)v5; v58 = (int *)&Dst; - v40 = (int)&pSpecialEnchantments[1]; + v40 = (int)&v5->pSpecialEnchantments[1]; do { switch ( v54 ) @@ -2092,8 +2460,8 @@ if ( !*(unsigned char *)v40 || v43 == 1 ) { LABEL_117: - v39 += *((unsigned char *)&pItems[0].uItemID + v40 + v52 + pItems[out_item->uItemID].uEquipType); - if ( *((unsigned char *)&pItems[0].uItemID + v40 + v52 + pItems[out_item->uItemID].uEquipType) ) + v39 += *((unsigned char *)&v5->uAllItemsCount + v40 + v52 + v5->pItems[v4->uItemID].uEquipType); + if ( *((unsigned char *)&v5->uAllItemsCount + v40 + v52 + v5->pItems[v4->uItemID].uEquipType) ) { v44 = v58; ++v58; @@ -2121,27 +2489,27 @@ ++a2b; v40 += 28; } - while ( a2b < field_11798 ); + while ( a2b < v5->pSpecialEnchantments_count ); } v45 = rand(); - out_item->uAdditionalValue = *Dst; + v4->uAdditionalValue = *(uint *)Dst; v46 = v45 % v39 + 1; - a2c = *((unsigned char *)&pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + pItems[out_item->uItemID].uEquipType); + a2c = *((unsigned char *)&v5->uAllItemsCount + 28 * (*(uint *)Dst + 1389) + v5->pItems[v4->uItemID].uEquipType); if ( a2c < v46 ) { for ( j = (int *)&Dst; ; j = (int *)v59 ) { - v48 = out_item->uItemID; + v48 = v4->uItemID; v49 = (int)(j + 1); v59 = v49; v50 = *(unsigned int *)v49; - out_item->uAdditionalValue = v50; - a2c += *((unsigned char *)&pItems[0].uItemID + 28 * (v50 + 1389) + pItems[v48].uEquipType); + v4->uAdditionalValue = v50; + a2c += *((unsigned char *)&v5->uAllItemsCount + 28 * (v50 + 1389) + v5->pItems[v48].uEquipType); if ( a2c >= v46 ) break; } } - ++out_item->uAdditionalValue; + ++v4->uAdditionalValue; } //----- (004505CC) --------------------------------------------------------
--- a/Items.h Sun Feb 17 05:31:47 2013 +0200 +++ b/Items.h Sun Feb 17 11:41:44 2013 +0400 @@ -72,7 +72,7 @@ EQUIP_BOOTS = 0x9, EQUIP_RING = 0xA, EQUIP_AMULET = 0xB, - EQUIP_C = 0xC, // wand? + EQUIP_C = 0xC, EQUIP_REAGENT = 0xD, EQUIP_POTION = 0xE, EQUIP_F = 0xF, @@ -123,30 +123,37 @@ /* 175 */ #pragma pack(push, 1) struct ItemDesc -{ - unsigned int uItemID; - char *pIconName; - char *pName; - char *pUnidentifiedName; - char *pDescription; - unsigned int uValue; - unsigned __int16 uSpriteID; - __int16 field_1A; - unsigned __int16 uEquipX; - unsigned __int16 uEquipY; - unsigned __int8 uEquipType; - unsigned __int8 uSkillType; - unsigned __int8 uDamageDice; - unsigned __int8 uDamageRoll; - unsigned __int8 uDamageMod; - unsigned __int8 uMaterial; - char _additional_value; - char _bonus_type; - char _bonus_strength; +{ //Item # |Pic File|Name|Value|Equip Stat|Skill Group|Mod1|Mod2|material| + ///ID/Rep/St|Not identified name|Sprite Index|VarA|VarB|Equip X|Equip Y|Notes + char *pIconName; //0 4 + char *pName; //4 8 + char *pUnidentifiedName; //8 c + char *pDescription; //0c 10 + unsigned int uValue; //10 14 + unsigned __int16 uSpriteID; //14 18 + __int16 field_1A; //16 + unsigned __int16 uEquipX; //18 1c + unsigned __int16 uEquipY; //1a 1e + unsigned __int8 uEquipType; //1c 20 + unsigned __int8 uSkillType; //1d 21 + unsigned __int8 uDamageDice; //1e 22 + unsigned __int8 uDamageRoll; //1f 23 + unsigned __int8 uDamageMod; //20 24 + unsigned __int8 uMaterial; //21 25 + 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[4]; + char field_2a; + char field_2b; + char field_2C; + unsigned char uItemID_Rep_St; //2d + char field_2e; + char field_2f; }; #pragma pack(pop) @@ -155,26 +162,46 @@ /* 177 */ #pragma pack(push, 1) struct ItemEnchantment -{ - char *pName; - char *pParam; - char field_8[12]; -}; + { //Bonus|Sta|Of Name|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul + char *pBonusStat; + char *pOfName; +/* union{ + struct { + unsigned char to_arm; + unsigned char to_shld; + unsigned char to_helm; + unsigned char to_belt; + unsigned char to_cape; + unsigned char to_gaunt; + unsigned char to_boot; + unsigned char to_ring; + unsigned char to_amul; + }; */ + unsigned char to_item[12]; + // }; + }; #pragma pack(pop) /* 178 */ #pragma pack(push, 1) struct ItemSpecialEnchantment -{ - char *pName; - char *pParam; - char field_8[12]; - int field_14; - int field_18; +{ //Bonus Stat|Name Add|W1|W2|Miss|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul|Value|Lvl|Description fo special Bonuses and values + + char *pBonusStatement; + char *pNameAdd; + char to_item_apply[12]; + int iValue; + int iTreasureLevel; }; #pragma pack(pop) - +#pragma pack(push, 1) +struct BonusRange +{ + unsigned int minR; + unsigned int maxR; +}; +#pragma pack(pop) /* 176 */ #pragma pack(push, 1) @@ -189,30 +216,28 @@ bool _456D5E_is_some_material(ItemGen *pItem); char *Release(); - - ItemDesc pItems[638]; - char align1[18]; - unsigned __int8 potion_data[50][50]; //int8!!!! not int16 as in decomp code. hexrays wrong!! - unsigned __int8 potion_note[50][50]; - char align2[2758]; - ItemEnchantment pEnchantments[24]; - ItemSpecialEnchantment pSpecialEnchantments[72]; + int uAllItemsCount; + ItemDesc pItems[800]; //4-9604h + ItemEnchantment pEnchantments[24]; //9604h + ItemSpecialEnchantment pSpecialEnchantments[72]; //97E4h char field_9FC0[5000]; char field_B348[5000]; char field_C6D0[5000]; char field_DA58[5000]; - char field_EDE0[5000]; - char field_10168[5000]; - char field_114F0[388]; - char *pItemsTXT_Raw; + char field_EDE0[184]; + 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; - char *pSpcItemsTXT_Raw; + char *pStdItemsTXT_Raw; //1167Ch + char *pSpcItemsTXT_Raw; //11680h int field_11684[6]; char field_1169C[60]; - int field_116D8[24]; - int field_11738[24]; - int field_11798; + int field_116D8[3]; + unsigned int pEnchantmentsSumm[9]; //116E4h -11708h + BonusRange bonus_ranges[6]; //45C2h*4 =11708h + int pSpecialEnchantmentsSumm[24]; //11738h + int pSpecialEnchantments_count; //11798h char field_1179C; }; #pragma pack(pop)
--- a/Player.cpp Sun Feb 17 05:31:47 2013 +0200 +++ b/Player.cpp Sun Feb 17 11:41:44 2013 +0400 @@ -2348,7 +2348,7 @@ v20 = thos; v2 = pItem->uItemID; - if ( !BYTE2(pItemsTable->pItems[v2 + 1].uItemID) ) + if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) pItem->uAttributes |= 1u; ///v15 = 0; //v16 = 1;
--- a/mm7_1.cpp Sun Feb 17 05:31:47 2013 +0200 +++ b/mm7_1.cpp Sun Feb 17 11:41:44 2013 +0400 @@ -2780,7 +2780,7 @@ goto LABEL_65; } v60 = _this->_bonus_strength; - v55 = *((int *)&pItemsTable->pEnchantments[23].pName + 7 * v26); + v55 = *((int *)&pItemsTable->pEnchantments[23].pBonusStat + 7 * v26); v50 = pGlobalTXT_LocalizationStrings[210]; v46 = "%s: %s"; }
--- a/mm7_5.cpp Sun Feb 17 05:31:47 2013 +0200 +++ b/mm7_5.cpp Sun Feb 17 11:41:44 2013 +0400 @@ -15885,10 +15885,10 @@ v0->pInventoryItems[pOut.z]._bonus_type = (pParty->pPickedItem._bonus_type + v0->pInventoryItems[pOut.z]._bonus_type) / 2; - v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->field_10168[2 * v20 + 388]); + v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 LABEL_74: v22 = (int)((char *)v0 + 36 * pOut.z); - if ( !BYTE2(pItemsTable->pItems[*(int *)(v22 + 532) + 1].uItemID) ) + if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) *(int *)(v22 + 552) |= 1u; if ( !dword_4E455C ) goto LABEL_92;
--- a/mm7_6.cpp Sun Feb 17 05:31:47 2013 +0200 +++ b/mm7_6.cpp Sun Feb 17 11:41:44 2013 +0400 @@ -5267,10 +5267,10 @@ { v314 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType]; *(int *)(v245 + 4) = 0; - for ( j = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + for ( j = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; ; - j += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + j += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1] ) { ++*(int *)(v245 + 4); @@ -5354,9 +5354,9 @@ { v275 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType]; *(int *)(v245 + 4) = 0; - for ( k = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; + for ( k = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; ; - k += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + k += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1] ) { ++*(int *)(v245 + 4); @@ -5368,19 +5368,19 @@ v256 = pItemsTable->field_116D8[18]; goto LABEL_611; } - v277 = pItemsTable->field_11798; + v277 = pItemsTable->pSpecialEnchantments_count; v278 = 0; v725 = 0.0; HIDWORD(v733) = 0; - if ( pItemsTable->field_11798 > 0 ) + if ( pItemsTable->pSpecialEnchantments_count > 0 ) { v730 = (int)&v679; do { - v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pName); + v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pBonusStatement); if ( !v279 || v279 == 1 ) { - v280 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + v280 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4] + v278 * 28); LODWORD(v725) += v280; @@ -5399,7 +5399,7 @@ v282 = rand() % SLODWORD(v725); v283 = v679; *(int *)(v245 + 12) = v679; - v284 = pItemsTable->pSpecialEnchantments[v283].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; + v284 = pItemsTable->pSpecialEnchantments[v283].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; v285 = v282 + 1; if ( v284 < v285 ) { @@ -5409,7 +5409,7 @@ v732 = v287; v288 = *(int *)v287; *(int *)(v245 + 12) = v288; - v284 += pItemsTable->pSpecialEnchantments[v288].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + v284 += pItemsTable->pSpecialEnchantments[v288].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; if ( v284 >= v285 ) break; @@ -5452,9 +5452,9 @@ { v252 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType]; *(int *)(v245 + 4) = 0; - for ( m = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; + for ( m = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1]; ; - m += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + m += pItemsTable->pEnchantments[*(int *)(v245 + 4)].to_item[pItemsTable->pItems[*(int *)v245].uEquipType + 1] ) { ++*(int *)(v245 + 4); @@ -5466,19 +5466,19 @@ v256 = pItemsTable->field_116D8[20]; goto LABEL_611; } - v257 = pItemsTable->field_11798; + v257 = pItemsTable->pSpecialEnchantments_count; v258 = 0; v725 = 0.0; HIDWORD(v733) = 0; - if ( pItemsTable->field_11798 > 0 ) + if ( pItemsTable->pSpecialEnchantments_count > 0 ) { v730 = (int)&v679; do { - v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pName); + v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement); if ( !v259 || v259 == 1 ) { - v260 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4] + v258 * 28); LODWORD(v725) += v260; @@ -5497,7 +5497,7 @@ v262 = rand() % SLODWORD(v725); v263 = v679; *(int *)(v245 + 12) = v679; - v264 = pItemsTable->pSpecialEnchantments[v263].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; + v264 = pItemsTable->pSpecialEnchantments[v263].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; v265 = v262 + 1; if ( v264 < v265 ) { @@ -5507,7 +5507,7 @@ v732 = v267; v268 = *(int *)v267; *(int *)(v245 + 12) = v268; - v264 += pItemsTable->pSpecialEnchantments[v268].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[pItemsTable->pItems[*(int *)v245].uEquipType + 4]; if ( v264 >= v265 ) break; @@ -5550,20 +5550,20 @@ } if ( rand() % 100 >= 80 ) { - v297 = pItemsTable->field_11798; + v297 = pItemsTable->pSpecialEnchantments_count; v294 = _this; v298 = 0; v725 = 0.0; HIDWORD(v733) = 0; - if ( pItemsTable->field_11798 > 0 ) + if ( pItemsTable->pSpecialEnchantments_count > 0 ) { v730 = (int)&v679; do { - v299 = LOBYTE(pItemsTable->pSpecialEnchantments[v298 + 1].pName); + v299 = LOBYTE(pItemsTable->pSpecialEnchantments[v298 + 1].pBonusStatement); if ( !v299 || v299 == 1 ) { - v300 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4] + v300 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4] + v298 * 28); LODWORD(v725) += v300; if ( v300 ) @@ -5581,7 +5581,7 @@ v302 = rand() % SLODWORD(v725); v303 = v679; v294->uAdditionalValue = v679; - v304 = pItemsTable->pSpecialEnchantments[v303].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; + v304 = pItemsTable->pSpecialEnchantments[v303].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; v305 = v302 + 1; if ( v304 < v305 ) { @@ -5591,7 +5591,7 @@ v732 = v307; v308 = *(int *)v307; v294->uAdditionalValue = v308; - v304 += pItemsTable->pSpecialEnchantments[v308].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; + v304 += pItemsTable->pSpecialEnchantments[v308].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; if ( v304 >= v305 ) break; } @@ -5604,9 +5604,9 @@ v294 = _this; v295 = v293 % pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; _this->_bonus_type = 0; - for ( kk = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 1]; + for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1]; ; - kk += pItemsTable->pEnchantments[v294->_bonus_type].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + kk += pItemsTable->pEnchantments[v294->_bonus_type].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1] ) { ++v294->_bonus_type; @@ -8575,14 +8575,14 @@ if ( !(a1a.uAttributes & 0x10) ) { v13 = 0; - if ( (signed int)pItemsTable->pItems[0].uItemID > 0 ) + if ( (signed int)pItemsTable->uAllItemsCount > 0 ) { v14 = (char *)&pItemsTable->pItems[0].uSpriteID; while ( *(short *)v14 != v9 ) { ++v13; v14 += 48; - if ( (signed int)v13 >= (signed int)pItemsTable->pItems[0].uItemID ) + if ( (signed int)v13 >= (signed int)pItemsTable->uAllItemsCount ) goto LABEL_16; } a1a.stru_24.uItemID = v13;