# HG changeset patch # User Nomad # Date 1361108746 -7200 # Node ID 46ae2602aceb3b11db821f2b82c70829aca0b105 # Parent bcd55744c2f44cf58f6a0db9ef8964732c140e01 Item generation doesn't crash (thou still generates weird stuff) diff -r bcd55744c2f4 -r 46ae2602aceb Items.cpp --- a/Items.cpp Sun Feb 17 15:09:31 2013 +0200 +++ b/Items.cpp Sun Feb 17 15:45:46 2013 +0200 @@ -1,4 +1,5 @@ #include +#include #include "Items.h" #include "MapInfo.h" @@ -1504,14 +1505,14 @@ //----- (00456620) -------------------------------------------------------- -void ItemsTable::GenerateItem(int a2, int a3, ItemGen *pItem) +void ItemsTable::GenerateItem(int treasure_level, int a3, ItemGen *out_item) { - 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 @@ -1553,163 +1554,103 @@ unsigned int v48; // ecx@123 int v49; // eax@123 int v50; // eax@123 - unsigned char Dst[0xC80]; // [sp+Ch] [bp-C88h]@33 + int Dst[800]; // [sp+Ch] [bp-C88h]@33 int v52; // [sp+C8Ch] [bp-8h]@33 - int v53; // [sp+C90h] [bp-4h]@1 - int v54; // [sp+C9Ch] [bp+8h]@3 - int v55; // [sp+CA0h] [bp+Ch]@34 + //int v53; // [sp+C90h] [bp-4h]@1 + //int v54; // [sp+C9Ch] [bp+8h]@3 + //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 ( !pItem ) - v4 = (ItemGen *)pAllocator->AllocNamedChunk(pItem, 0x24u, "newItemGen"); - memset(v4, 0, 0x24u); - v6 = a2 - 1; - v54 = a2 - 1; + //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)); + + auto v4 = out_item; + v6 = treasure_level - 1; + //v54 = treasure_level - 1; if ( a3 ) { - switch ( a3 ) + ITEM_EQUIP_TYPE requested_equip; + PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; + 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; + default: + __debugbreak(); // check this condition + requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1); + break; + } + memset(Dst, 0, sizeof(Dst)); + v52 = 0; + v7 = Dst; + //a2a = 1; + if (requested_skill == PLAYER_SKILL_INVALID) { - 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: - --a3; - break; - } - memset(&Dst, 0, 0xC80u); - v52 = 0; - v7 = (int *)&Dst; - a2a = 1; - if ( v53 == -1 ) - { - v53 = (int)&v5->pItems[1].uEquipType; - v9 = (int)(&v5->pItems[1].uChanceByTreasureLvl[0] + v6); - do + for (uint i = 1; i < 500; ++i) { - if ( *(unsigned char *)v53 == a3 ) + if (pItems[i].uEquipType == requested_equip) { - *v7 = a2a; - ++v7; - v52 += *(unsigned char *)v9; + *v7++ = i; + v52 += pItems[i].uChanceByTreasureLvl[v6]; } - ++a2a; - v53 += 48; - v9 += 48; } - while ( a2a < 500 ); } else { - v55 = (int)&v5->pItems[1].uSkillType; - v8 = (int)(&v5->pItems[1].uChanceByTreasureLvl[0] + v6); - do + for (uint i = 1; i < 500; ++i) { - if ( *(unsigned char *)v55 == v53 ) + if (pItems[i].uSkillType == requested_skill) { - *v7 = a2a; - ++v7; - v52 += *(unsigned char *)v8; + *v7++ = i; + v52 += pItems[i].uChanceByTreasureLvl[v6]; } - ++a2a; - v55 += 48; - v8 += 48; } - while ( a2a < 500 ); } + v10 = 0; if ( v52 ) v10 = rand() % v52; - v4->uItemID = *(uint *)Dst; - if ( !Dst ) + + v4->uItemID = *Dst; + if (!v4->uItemID) v4->uItemID = 1; - v11 = *(&v5->pItems[v4->uItemID].uChanceByTreasureLvl[0] + v54); + + v11 = pItems[v4->uItemID].uChanceByTreasureLvl[v6]; if ( v11 < v10 ) { v12 = (uint *)Dst; @@ -1718,11 +1659,11 @@ ++v12; v13 = *v12; v4->uItemID = *v12; - v11 += *(&v5->pItems[v13].uChanceByTreasureLvl[0] + v54); + v11 += pItems[v13].uChanceByTreasureLvl[v6]; } while ( v11 < v10 ); } - if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) + if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) { v4->_bonus_type = 0; v14 = 2; @@ -1734,7 +1675,7 @@ } while ( v14 ); LABEL_72: - v4->_bonus_type = v15 * (v54 + 1); + v4->_bonus_type = v15 * treasure_level; goto LABEL_73; } } @@ -1746,12 +1687,12 @@ v56 += pParty->field_7BA[v16++]; while ( v16 < 29 ); v17 = rand() % 29; - if ( v54 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) + if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) { pParty->field_7BA[v17] = 1; v4->uAttributes = 0; v4->uItemID = v17 + 500; - v5->SetSpecialBonus(v4); + SetSpecialBonus(v4); return; } v57 = 0; @@ -1760,14 +1701,14 @@ if ( v18 > 0 ) { do - v57 += *(&v5->pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[0] + v54); + v57 += pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[v6]; while ( v57 < v18 ); } if ( !v18 ) v4->uItemID = 1; if ( !v4->uItemID ) v4->uItemID = 1; - if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) + if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE) { v4->_bonus_type = 0; v19 = 2; @@ -1789,12 +1730,12 @@ v4->uAttributes = 0; else v4->uAttributes = 1; - if ( v5->pItems[v4->uItemID].uEquipType != EQUIP_POTION ) + if ( pItems[v4->uItemID].uEquipType != EQUIP_POTION ) { v4->uAdditionalValue = 0; v4->_bonus_type = 0; } - v20 = v5->pItems[v4->uItemID].uEquipType; + v20 = pItems[v4->uItemID].uEquipType; if ( v20 <= EQUIP_BOW ) { v37 = 10;//(int)&v5->field_1169C[4 * v54 + 48]; @@ -1816,7 +1757,7 @@ } return; } - v22 = (int)&v5->uBonusChanceStandart[v54]; + v22 = (int)&uBonusChanceStandart[v6]; if ( !*(unsigned int *)v22 ) return; v23 = rand(); @@ -1824,7 +1765,7 @@ v25 = v23 % 100; if ( v23 % 100 < v24 ) goto LABEL_127; - if ( !v5->uBonusChanceSpecial[v54] ) + if ( !uBonusChanceSpecial[v6] ) return; if ( v25 < v24 ) { @@ -1832,9 +1773,9 @@ v26 = rand() % 10;//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]; + for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; i < v26; - i += v5->pEnchantments[v4->_bonus_type].to_item[v5->pItems[v29].uEquipType + 1] ) + i += pEnchantments[v4->_bonus_type].to_item[pItems[v29].uEquipType + 1] ) { v29 = v4->uItemID; ++v4->_bonus_type; @@ -1860,14 +1801,14 @@ memset(&Dst, 0, 0xC80u); v39 = 0; a2b = 0; - if ( v5->pSpecialEnchantments_count > 0 ) + if ( pSpecialEnchantments_count > 0 ) { - v52 = -16 - (uint)v5; + v52 = -16 - (uint)this; v58 = (int *)&Dst; - v40 = (int)&v5->pSpecialEnchantments[1]; + v40 = (int)&pSpecialEnchantments[1]; do { - switch ( v54 ) + switch ( v6 ) { case 2: if ( !*(unsigned char *)v40 ) @@ -1879,8 +1820,8 @@ if ( !*(unsigned char *)v40 || v43 == 1 ) { LABEL_117: - v39 += *((unsigned char *)&v5->uAllItemsCount + v40 + v52 + v5->pItems[v4->uItemID].uEquipType); - if ( *((unsigned char *)&v5->uAllItemsCount + v40 + v52 + v5->pItems[v4->uItemID].uEquipType) ) + v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); + if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) { v44 = v58; ++v58; @@ -1897,7 +1838,7 @@ v41 = v42 == 3; break; default: - if ( v54 != 5 ) + if ( v6 != 5 ) goto LABEL_119; v41 = *(unsigned char *)v40 == 3; break; @@ -1908,12 +1849,12 @@ ++a2b; v40 += 28; } - while ( a2b < v5->pSpecialEnchantments_count ); + while ( a2b < pSpecialEnchantments_count ); } v45 = rand(); v4->uAdditionalValue = *(uint *)Dst; v46 = v45 % v39 + 1; - a2c = *((unsigned char *)&v5->uAllItemsCount + 28 * (*(uint *)Dst + 1389) + v5->pItems[v4->uItemID].uEquipType); + a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType); if ( a2c < v46 ) { for ( j = (int *)&Dst; ; j = (int *)v59 ) @@ -1923,7 +1864,7 @@ v59 = v49; v50 = *(unsigned int *)v49; v4->uAdditionalValue = v50; - a2c += *((unsigned char *)&v5->uAllItemsCount + 28 * (v50 + 1389) + v5->pItems[v48].uEquipType); + a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType); if ( a2c >= v46 ) break; } diff -r bcd55744c2f4 -r 46ae2602aceb Items.h --- a/Items.h Sun Feb 17 15:09:31 2013 +0200 +++ b/Items.h Sun Feb 17 15:45:46 2013 +0200 @@ -216,7 +216,7 @@ void Initialize(); void LoadPotions(); void LoadPotionNotes(); - void GenerateItem(int a2, int a3, ItemGen *pItem); + void GenerateItem(int treasure_level, int a3, ItemGen *pItem); void SetSpecialBonus(ItemGen *pItem); bool _456D43_is_material_equals_3(ItemGen *pItem); bool _456D5E_is_some_material(ItemGen *pItem); diff -r bcd55744c2f4 -r 46ae2602aceb mm7_4.cpp --- a/mm7_4.cpp Sun Feb 17 15:09:31 2013 +0200 +++ b/mm7_4.cpp Sun Feb 17 15:45:46 2013 +0200 @@ -5845,7 +5845,7 @@ //----- (00497526) -------------------------------------------------------- bool __cdecl PlayerCreationUI_Loop() { - RGBTexture *pTexture; // ebx@1 + //RGBTexture *pTexture; // ebx@1 UINT v1; // esi@1 unsigned int v2; // ecx@3 LONG uMouseX; // edi@6 @@ -5859,7 +5859,7 @@ Player *v11; // esi@38 signed int uSpellBookPageCount; // ecx@40 int v13; // eax@40 - signed int uSkillIdx; // eax@45 + //signed int uSkillIdx; // eax@45 int v15; // eax@70 signed int v16; // ecx@70 //unsigned int v18; // [sp-4h] [bp-84h]@48 @@ -5871,10 +5871,10 @@ MSG Msg; // [sp+50h] [bp-30h]@17 POINT v25; // [sp+6Ch] [bp-14h]@6 bool v26; // [sp+74h] [bp-Ch]@1 - POINT v24; // [sp+78h] [bp-8h]@6 - Player *pPlayer; - - pTexture = &pTexture_PCX; + //POINT v24; // [sp+78h] [bp-8h]@6 + //Player *pPlayer; + + //pTexture = &pTexture_PCX; v1 = 0; v26 = 0; pTexture_PCX.Release(); @@ -5889,7 +5889,7 @@ { if ( pAsyncMouse != (void *)v1 ) pAsyncMouse->_46B736_consume_click_lists(1); - uMouseX = pMouse->GetCursorPos(&v24)->x; + uMouseX = pMouse->GetCursorPos(&v25)->x; uMouseY = pMouse->GetCursorPos(&v25)->y; pControlsHead = pGUIWindow_CurrentMenu->pControlsHead; if ( pControlsHead != (GUIButton *)v1 ) @@ -5904,7 +5904,7 @@ if ( (signed int)pNumMessage < 40 ) { pMessageQueue_50CBD0->pMessages[pNumMessage].eType = (UIMessageType)pControlsHead->field_1C; - pTexture = &pTexture_PCX; + //pTexture = &pTexture_PCX; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = pControlParam; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; pNumMessage = pMessageQueue_50CBD0->uNumMessages + 1; @@ -5953,13 +5953,11 @@ } } } - pTexture->Release(); + pTexture_PCX.Release(); pGUIWindow_CurrentMenu->Release(); pIcons_LOD->_4114F2(); - v20[0] = 0; - memset(&v20[1], 0, 0x1Cu); - *(_WORD*)&v20[29] = 0; - v20[31] = 0; + + memset(v20, 0, 32); do { v8 = 0; @@ -5985,112 +5983,107 @@ v20[v9] = 1; } while ( (signed int)v1 < 32 ); + //v10 = (char *)&pParty->pPlayers[0].sResMagicBase; + item.Reset(); - //v10 = (char *)&pParty->pPlayers[0].sResMagicBase; - for ( pPlayer = &pParty->pPlayers[0]; pPlayer < &pParty->pPlayers[4]; pPlayer++) - { + //for ( pPlayer = &pParty->pPlayers[0]; pPlayer < &pParty->pPlayers[4]; pPlayer++) + for (uint i = 0; i < 4; ++i) + { + auto player = &pParty->pPlayers[i]; //v11 = pPlayer; - if (pPlayer->classType == PLAYER_CLASS_KNIGHT) - pPlayer->sResMagicBase = 10; + if (player->classType == PLAYER_CLASS_KNIGHT) + player->sResMagicBase = 10; //*((short *)v10 + 400) = 0; - pPlayer->pPlayerBuffs[22].uExpireTime = 0; + player->pPlayerBuffs[22].uExpireTime = 0; uSpellBookPageCount = 0; - for ( int i = 0; i < 9; i++) - { - if ( pPlayer->pActiveSkills[12+i] ) + for (uint j = 0; j < 9; j++) + { + if (player->pActiveSkills[PLAYER_SKILL_FIRE + j]) ++uSpellBookPageCount; } - pPlayer->lastOpenedSpellbookPage = uSpellBookPageCount; + player->lastOpenedSpellbookPage = uSpellBookPageCount; pItemsTable->GenerateItem(2, 40, &item); - pPlayer->AddItem2(-1, &item); - uSkillIdx = 0; - v24.y = 0; - do - { - if ( pPlayer->pActiveSkills[uSkillIdx] ) - { - switch ( uSkillIdx ) - { - case PLAYER_SKILL_STAFF: pPlayer->AddItem(-1, 61); break; - case PLAYER_SKILL_SWORD: pPlayer->AddItem(-1, 1); break; - case PLAYER_SKILL_DAGGER: pPlayer->AddItem(-1, 15); break; - case PLAYER_SKILL_AXE: pPlayer->AddItem(-1, 23); break; - case PLAYER_SKILL_SPEAR: pPlayer->AddItem(-1, 31); break; - case PLAYER_SKILL_BOW: pPlayer->AddItem(-1, 47); break; - case PLAYER_SKILL_MACE: pPlayer->AddItem(-1, 50); break; - case PLAYER_SKILL_BLASTER: assert(false); break; - case PLAYER_SKILL_SHIELD: pPlayer->AddItem(-1, 84); break; - case PLAYER_SKILL_LEATHER: pPlayer->AddItem(-1, 66); break; - case PLAYER_SKILL_CHAIN: pPlayer->AddItem(-1, 71); break; - case PLAYER_SKILL_PLATE: pPlayer->AddItem(-1, 76); break; - case PLAYER_SKILL_FIRE: - pPlayer->AddItem(-1, 0x191); - pPlayer->spellbook.pFireSpellbook.bIsSpellAvailable[0] = true; - break; - case PLAYER_SKILL_AIR: - pPlayer->AddItem(-1, 0x19C); - pPlayer->spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; - break; - case PLAYER_SKILL_WATER: - pPlayer->AddItem(-1, 0x1A7); - pPlayer->spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; + player->AddItem2(-1, &item); + //uSkillIdx = 0; + //v24.y = 0; + + player->sHealth = player->GetMaxHealth(); + player->sMana = player->GetMaxMana(); + for (uint j = 0; j < 37; ++j) + { + if (!player->pActiveSkills[j]) + continue; + + switch (j) + { + case PLAYER_SKILL_STAFF: player->AddItem(-1, 61); break; + case PLAYER_SKILL_SWORD: player->AddItem(-1, 1); break; + case PLAYER_SKILL_DAGGER: player->AddItem(-1, 15); break; + case PLAYER_SKILL_AXE: player->AddItem(-1, 23); break; + case PLAYER_SKILL_SPEAR: player->AddItem(-1, 31); break; + case PLAYER_SKILL_BOW: player->AddItem(-1, 47); break; + case PLAYER_SKILL_MACE: player->AddItem(-1, 50); break; + case PLAYER_SKILL_BLASTER: assert(false); break; + case PLAYER_SKILL_SHIELD: player->AddItem(-1, 84); break; + case PLAYER_SKILL_LEATHER: player->AddItem(-1, 66); break; + case PLAYER_SKILL_CHAIN: player->AddItem(-1, 71); break; + case PLAYER_SKILL_PLATE: player->AddItem(-1, 76); break; + case PLAYER_SKILL_FIRE: + player->AddItem(-1, 0x191); + player->spellbook.pFireSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_AIR: + player->AddItem(-1, 0x19C); + player->spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_WATER: + player->AddItem(-1, 0x1A7); + player->spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_EARTH: + player->AddItem(-1, 0x1B2); + player->spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_SPIRIT: + player->AddItem(-1, 0x1BD); + player->spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_MIND: + player->AddItem(-1, 0x1C8); + player->spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_BODY: + player->AddItem(-1, 0x1D3); + player->spellbook.pBodySpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_LIGHT: + case PLAYER_SKILL_DARK: + case PLAYER_SKILL_DIPLOMACY: + assert(false); + break; + case PLAYER_SKILL_ITEM_ID: + case PLAYER_SKILL_REPAIR: + case PLAYER_SKILL_MEDITATION: + case PLAYER_SKILL_PERCEPTION: + case PLAYER_SKILL_TRAP_DISARM: + case PLAYER_SKILL_LEARNING: + player->AddItem(-1, 0xDC); + player->AddItem(-1, 5 * (rand() % 3 + 40)); + break; + case PLAYER_SKILL_DODGE: player->AddItem(-1, 115); break; + case PLAYER_SKILL_UNARMED: player->AddItem(-1, 110); break; + default: break; - case PLAYER_SKILL_EARTH: - pPlayer->AddItem(-1, 0x1B2); - pPlayer->spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; - break; - case PLAYER_SKILL_SPIRIT: - pPlayer->AddItem(-1, 0x1BD); - pPlayer->spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; - break; - case PLAYER_SKILL_MIND: - pPlayer->AddItem(-1, 0x1C8); - pPlayer->spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; - break; - case PLAYER_SKILL_BODY: - pPlayer->AddItem(-1, 0x1D3); - pPlayer->spellbook.pBodySpellbook.bIsSpellAvailable[0] = true; - break; - case PLAYER_SKILL_LIGHT: - case PLAYER_SKILL_DARK: - case PLAYER_SKILL_DIPLOMACY: - assert(false); - break; - case PLAYER_SKILL_ITEM_ID: - case PLAYER_SKILL_REPAIR: - case PLAYER_SKILL_MEDITATION: - case PLAYER_SKILL_PERCEPTION: - case PLAYER_SKILL_TRAP_DISARM: - case PLAYER_SKILL_LEARNING: - pPlayer->AddItem(-1, 0xDC); - pPlayer->AddItem(-1, 5 * (rand() % 3 + 40)); - break; - case PLAYER_SKILL_DODGE: - pPlayer->AddItem(-1, 115); - break; - case PLAYER_SKILL_UNARMED: - pPlayer->AddItem(-1, 110); - break; - default: - break; - } - for ( int i = 0; i < 138; i++) - { - if ( &pPlayer->pInventoryItems[i] ) - pPlayer->pInventoryItems[i].uAttributes |= 1; - } - pPlayer->sHealth = pPlayer->GetMaxHealth(); - pPlayer->sMana = pPlayer->GetMaxMana(); - uSkillIdx = v24.y; - } - ++uSkillIdx; - v24.y = uSkillIdx; - } - while ( uSkillIdx < 37 ); - //v10 += 6972; - //pPlayer++; - } - //while ( (signed int)v10 < (signed int)((char *)&pParty->field_871C[455] + 2) ); + } + + for (uint k = 0; k < 138; k++) + { + if (&player->pInventoryItems[k]) + player->pInventoryItems[k].uAttributes |= 1; + } + } + } + pAudioPlayer->StopChannels(-1, -1); if (pAsyncMouse) pAsyncMouse->Suspend();