# HG changeset patch # User Ritor1 # Date 1379907263 -21600 # Node ID cc1d68c17e19c4e6245d425a7a54d938d022fa14 # Parent ffef0fe0b59d1ef3358e4fb39a25d7604899ceb3# Parent 5cbd88f8a2ebe5f8d5c18b9d5934f3778305da46 Слияние diff -r ffef0fe0b59d -r cc1d68c17e19 Arcomage.cpp --- a/Arcomage.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Arcomage.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -47,25 +47,25 @@ void DrawCards(); void DrawCardAnimation(int a1); int GetPlayerHandCardCount(int player_num); -signed int DrawCardsRectangles(int player_num); -bool DiscardCard(int player_num, signed int card_slot_index); -bool PlayCard(int player_num, signed int card_slot_num); +int DrawCardsRectangles(int player_num); +bool DiscardCard(int player_num, int card_slot_index); +bool PlayCard(int player_num, int card_slot_num); bool CanCardBePlayed(int player_num, int hand_card_indx); void ApplyCardToPlayer(int player_num, unsigned int uCardID); int am_40D2B4(POINT* a1, int a2); // weak int ApplyDamageToBuildings(int player_num, int damage); // weak void GameResultsApply(); -void pPrimaryWindow_draws_text(int a1, const char *pText, POINT *pXY); +void am_DrawText(int a1, const char *pText, POINT *pXY); void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb void __fastcall Blt_Chroma(RECT *pSrcXYZW, POINT *pTargetXY, int a3, int a4); void Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3); void am_EndScene(); void DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill); -void SetPixel2sq( POINT *pTargetXY, unsigned __int16 uColor ); -void SetPixel(POINT *pTargetXY, unsigned __int16 uColor); +void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor ); +void DrawPixel(POINT *pTargetXY, unsigned __int16 uColor); int rand_interval(int min, int max); // idb -void __fastcall intToString(int val, char *pOut); +void __fastcall am_IntToString(int val, char *pOut); //----- (0040DEDB) -------------------------------------------------------- unsigned int R8G8B8_to_TargetFormat(int uColor) @@ -112,17 +112,16 @@ ArcomageGame *pArcomageGame = new ArcomageGame; -ArcomagePlayer am_Players[2]; -Acromage_st1 shown_cards[10]; //amuint_4FAA78; // weak -stru272 array_4FABD0[10]; - - -ArcomageDeck playDeck; -ArcomageDeck deckMaster; +ArcomagePlayer am_Players[2]; // 00505708 +AcromageCardOnTable shown_cards[10]; // 004FAA78 +stru272 array_4FABD0[10]; // 4FABD0 + + +ArcomageDeck playDeck; // 00505288 +ArcomageDeck deckMaster; // 005054C8 char Player2Name[] = "Enemy"; char Player1Name[] = "Player"; -char pDeckMaster[] = "Master Deck"; /* 267 */ #pragma pack(push, 1) @@ -163,7 +162,7 @@ int start_zoo_level; -int minimum_cards_at_hand = 5; +int minimum_cards_at_hand = 5; // 004E1874 int quarry_bonus = 1; int magic_bonus = 1; int zoo_bonus = 1; @@ -173,17 +172,17 @@ int opponent_mastery = 1 ; // weak -char byte_4FAA2C; // weak +bool am_gameover; // 004FAA2C char byte_4FAA2D; // weak -int current_player_num; // idb -char need_to_discard_card; // weak - -signed int current_card_slot_index; -int played_card_id; // idb 4FABC0 -int uCardID; // idb 4FAA50 - -int deck_walk_index; +int current_player_num; // 004FAA6C +char need_to_discard_card; // 04FAA77 + +int current_card_slot_index; // 004FABBC +int played_card_id; // 4FABC0 +int uCardID; // 4FAA50 + +int deck_walk_index; // 004FABC8 int start_bricks_amount; int start_gems_amount; @@ -242,20 +241,20 @@ } //----- (0040DFD1) -------------------------------------------------------- -void stru272_stru0::Ctor(stru272_stru0 **a1) - { - stru272_stru0 *v2; // eax@1 - v2 = (stru272_stru0 *)malloc(0x5Cu); - *a1 = v2; +stru272_stru0 *stru272_stru0::New() +{ + stru272_stru0 *v2 = (stru272_stru0 *)malloc(0x5Cu); v2->signature = SIG_trpg; v2->position_in_sparks_arr = 0; v2->field_30 = 0.0; v2->field_58 = 0; v2->field_59 = 0; - } + + return v2; +} //----- (0040DFFE) -------------------------------------------------------- -int stru272_stru0::Dtor() +int stru272_stru0::Free() { if ( this->signature == SIG_trpg ) @@ -299,7 +298,7 @@ } //----- (0040E0F5) -------------------------------------------------------- -int stru272_stru0::Empty(char a2, char a3) +int stru272_stru0::Clear(char a2, char a3) { if ( signature == SIG_trpg) { @@ -982,7 +981,6 @@ //----- (00408BB4) -------------------------------------------------------- bool OpponentsAITurn(int player_num) { - char result; // al@3 signed int v2; // ebx@8 int v3; // esi@8 @@ -1269,7 +1267,7 @@ pArcomageGame->GameOver = 1; } GameResultsApply(); - if ( byte_4FAA2C ) + if ( am_gameover ) { dword_4FAA70 = 0; } @@ -1277,23 +1275,21 @@ { dword_4FAA70 = -1; } - pVideoPlayer->BinkUpdatePalette(dword_4FAA28); for(int i=0; i<10; ++i) - { - array_4FABD0[i].field_40->Empty(1,1); - array_4FABD0[i].field_40->Dtor(); - } + { + array_4FABD0[i].field_40->Clear(1, 1); + array_4FABD0[i].field_40->Free(); + } pArcomageGame->pGameBackground.Release(); pArcomageGame->pSprites.Release(); - pArcomageGame->bGameInProgress = 0; - viewparams->bRedrawGameUI = 1; + pArcomageGame->bGameInProgress = false; + viewparams->bRedrawGameUI = true; if ( pVideoPlayer->AnyMovieLoaded() ) pVideoPlayer->_4BF5B2(); for(int i=0; i<12; ++i) pSoundList->UnloadSound(am_sounds[i], 1); - } @@ -1301,8 +1297,7 @@ //----- (00409FE9) -------------------------------------------------------- void SetStartGameData() - { - +{ signed int j; // edx@7 int card_id_counter; // edx@13 signed int i; // ecx@13 @@ -1349,7 +1344,7 @@ } } } - strcpy(deckMaster.name, pDeckMaster); + strcpy(deckMaster.name, "Master Deck"); for (i=0, card_dispenser_counter=-2, card_id_counter=0; i= 2 ) @@ -1548,13 +1542,13 @@ // v4 = 0; v11.y = 260; v11.x = 320;// - 12 * v4 / 2; - pPrimaryWindow_draws_text(-1, player_name, &v11); + am_DrawText(-1, player_name, &v11); /* v6.left = 0; v6.right = 640; v6.top = 0; v6.bottom = 480;*/ //nullsub_1(); - CallRenderPresent(); + pRenderer->Present(); //nullsub_1(); while ( 1 ) { @@ -1583,7 +1577,7 @@ v6.top = 0; v6.bottom = 480;*/ //nullsub_1(); - CallRenderPresent(); + pRenderer->Present(); } } } @@ -1591,7 +1585,7 @@ //----- (0040A514) -------------------------------------------------------- bool IsGameOver() - { +{ bool result; // eax@1 result = false; @@ -1606,10 +1600,8 @@ || am_Players[i].resource_beasts >= max_resources_amount ) result = true; } - - if ( result ) - byte_4FAA2C = 1; - return result; + + return am_gameover = result; } @@ -1649,7 +1641,7 @@ } while (v3 < 6); - pArcomageGame->event_timer_time = (unsigned int )pEventTimer->Time(); + pArcomageGame->event_timer_time = (unsigned int)pEventTimer->Time(); if ( pArcomageGame->field_F4 ) break_loop = 1; ArcomageGame::MsgLoop(0, &a2); @@ -1834,8 +1826,7 @@ //----- (0040A9AF) -------------------------------------------------------- void DrawGameUI( int animation_stage ) - { - +{ am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); DrawRectanglesForText(); am_EndScene(); @@ -1880,9 +1871,9 @@ if (array_4FABD0[i].effect_sparks[j].have_spark > 0) { if (j%2) - SetPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); + DrawPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); else - SetPixel2sq(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); + DrawSquare(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color); } } } @@ -1892,10 +1883,10 @@ //----- (0040AB0A) -------------------------------------------------------- void DrawRectanglesForText() - { - +{ RECT pSrcRect; // [sp+Ch] [bp-18h]@1 POINT pTargetXY; // [sp+1Ch] [bp-8h]@1 + //resources rectangles pSrcRect.left = 765; pSrcRect.top = 0; @@ -1963,46 +1954,46 @@ strcpy(text_buff, pGlobalTXT_LocalizationStrings[266]);// DISCARD A CARD text_position.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(text_buff) / 2; text_position.y = 306; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); + am_DrawText(-1, text_buff, &text_position); } strcpy( text_buff, am_Players[0].pPlayerName); if ( !current_player_num ) strcat(text_buff, "***"); text_position.x = 47 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; text_position.y = 21; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); + am_DrawText(-1, text_buff, &text_position); strcpy(text_buff, am_Players[1].pPlayerName); if ( current_player_num == 1 ) strcat(text_buff, "***" ); text_position.x = 595 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; text_position.y = 21; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); - - intToString(am_Players[0].tower_height, text_buff); + am_DrawText(-1, text_buff, &text_position); + + am_IntToString(am_Players[0].tower_height, text_buff); text_position.x = 123 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; text_position.y = 305; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); - - intToString(am_Players[1].tower_height, text_buff); + am_DrawText(-1, text_buff, &text_position); + + am_IntToString(am_Players[1].tower_height, text_buff); text_position.x = 515 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; text_position.y = 305; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); - - intToString(am_Players[0].wall_height, text_buff); + am_DrawText(-1, text_buff, &text_position); + + am_IntToString(am_Players[0].wall_height, text_buff); text_position.x = 188 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; text_position.y = 305; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); - - intToString(am_Players[1].wall_height, text_buff); + am_DrawText(-1, text_buff, &text_position); + + am_IntToString(am_Players[1].wall_height, text_buff); text_position.x = 451 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2; text_position.y = 305; - pPrimaryWindow_draws_text(-1, text_buff, &text_position); + am_DrawText(-1, text_buff, &text_position); res_value = am_Players[0].quarry_level; if ( use_start_bonus ) res_value =am_Players[0].quarry_level + quarry_bonus; - intToString(res_value, text_buff); + am_IntToString(res_value, text_buff); text_position.x = 14;// - 6 * 0 / 2; text_position.y = 92; DrawPlayerLevels(-1, text_buff, &text_position); @@ -2010,7 +2001,7 @@ res_value = am_Players[1].quarry_level; if ( use_start_bonus ) res_value = am_Players[1].quarry_level + quarry_bonus; - intToString(res_value, text_buff); + am_IntToString(res_value, text_buff); // v2 = 0; text_position.y = 92; text_position.x = 561; //- 6 * v2 / 2; @@ -2019,7 +2010,7 @@ res_value = am_Players[0].magic_level; if ( use_start_bonus ) res_value = am_Players[0].magic_level + magic_bonus; - intToString(res_value, text_buff); + am_IntToString(res_value, text_buff); // v4 = 0; text_position.y = 164; text_position.x = 14; //- 6 * v4 / 2; @@ -2028,7 +2019,7 @@ res_value = am_Players[1].magic_level; if ( use_start_bonus ) res_value = am_Players[1].magic_level + magic_bonus; - intToString(res_value, text_buff); + am_IntToString(res_value, text_buff); // v6 = 0; text_position.y = 164; text_position.x = 561; //- 6 * v6 / 2; @@ -2037,7 +2028,7 @@ res_value = am_Players[0].zoo_level; if ( use_start_bonus ) res_value = am_Players[0].zoo_level + zoo_bonus; - intToString(res_value, text_buff); + am_IntToString(res_value, text_buff); // v8 = 0; text_position.y = 236; text_position.x = 14;// - 6 * v8 / 2; @@ -2046,38 +2037,38 @@ res_value = am_Players[1].zoo_level; if ( use_start_bonus ) res_value = am_Players[1].zoo_level + zoo_bonus; - intToString(res_value, text_buff); + am_IntToString(res_value, text_buff); // v10 = 0; text_position.y = 236; text_position.x = 561;// - 6 * v10 / 2; DrawPlayerLevels(-1, text_buff, &text_position); - intToString(am_Players[0].resource_bricks, text_buff); + am_IntToString(am_Players[0].resource_bricks, text_buff); text_position.y = 114; text_position.x = 10; DrawBricksCount(-1, text_buff, &text_position); - intToString(am_Players[1].resource_bricks, text_buff); + am_IntToString(am_Players[1].resource_bricks, text_buff); text_position.x = 557; text_position.y = 114; DrawBricksCount(-1, text_buff, &text_position); - intToString(am_Players[0].resource_gems, text_buff); + am_IntToString(am_Players[0].resource_gems, text_buff); text_position.x = 10; text_position.y = 186; DrawGemsCount(-1, text_buff, &text_position); - intToString(am_Players[1].resource_gems, text_buff); + am_IntToString(am_Players[1].resource_gems, text_buff); text_position.x = 557; text_position.y = 186; DrawGemsCount(-1, text_buff, &text_position); - intToString(am_Players[0].resource_beasts, text_buff); + am_IntToString(am_Players[0].resource_beasts, text_buff); text_position.x = 10; text_position.y = 258; DrawBeastsCount(-1, text_buff, &text_position); - intToString(am_Players[1].resource_beasts, text_buff); + am_IntToString(am_Players[1].resource_beasts, text_buff); text_position.x = 557; text_position.y = 258; DrawBeastsCount(-1, text_buff, &text_position); @@ -2344,7 +2335,7 @@ int v16; // ecx@25 POINT *v17; // esi@26 signed int v18; // eax@29 -Acromage_st1 *v19; // ecx@29 +AcromageCardOnTable *v19; // ecx@29 int v20; // ecx@31 int v21; // [sp-4h] [bp-2Ch]@8 RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@8 @@ -2475,7 +2466,7 @@ RECT *v6; // ecx@6 int v8; // eax@15 -Acromage_st1 *v9; // ecx@15 +AcromageCardOnTable *v9; // ecx@15 int v10; // ecx@19 int v11; // eax@20 int v12; // ecx@20 @@ -2702,9 +2693,7 @@ //----- (0040BB67) -------------------------------------------------------- signed int DrawCardsRectangles( int player_num ) - { -//need do fix rectangle not fit to card - +{ //int v1; // esi@1 signed int result; // eax@1 int v3; // ebx@1 @@ -2738,6 +2727,7 @@ char v32; // [sp+45h] [bp-3h]@12 char v33; // [sp+46h] [bp-2h]@12 +__debugbreak(); // need do fix rectangle not fit to card v30 = 0; result = -1; @@ -2900,9 +2890,8 @@ //----- (0040BE0E) -------------------------------------------------------- -bool PlayCard( int player_num, signed int card_slot_num ) - { - +bool PlayCard( int player_num, int card_slot_num ) +{ int v3; // ebp@1 int v4; // ecx@2 ArcomagePlayer *v5; // esi@2 @@ -2962,8 +2951,8 @@ } //----- (0040BF15) -------------------------------------------------------- -bool CanCardBePlayed( int player_num, int hand_card_indx ) - { +bool CanCardBePlayed(int player_num, int hand_card_indx) +{ bool result; // eax@1 ArcomageCard *test_card; // ecx@1 ArcomagePlayer *pPlayer; // esi@1 @@ -2975,7 +2964,7 @@ result = false; if ( test_card->needed_magic_level > pPlayer->magic_level ) result = false; - if ( test_card->needed_might_level > pPlayer->zoo_level ) + if ( test_card->needed_zoo_level > pPlayer->zoo_level ) result = false; if ( test_card->needed_bricks > pPlayer->resource_bricks ) result = false; @@ -3766,7 +3755,7 @@ // v2 = 0; xy.y = 160; xy.x = 320; //- 12 * v2 / 2; -// pPrimaryWindow_draws_text(-1, pText, xy); +// am_DrawText(-1, pText, xy); if ( am_Players[0].tower_height < max_tower_height ) { if ( am_Players[1].tower_height < max_tower_height ) @@ -4001,20 +3990,20 @@ am_EndScene(); pRenderer->Present(); ArcomageGame::LoadSprites(); - CallRenderPresent(); + pRenderer->Present(); v4 = 120; for (int i=0; i<12; ++i) am_sounds[i] = pSoundList->LoadSound(v4++, 0); for (int i=0; i<10; ++i) - stru272_stru0::Ctor(&array_4FABD0[i].field_40); + array_4FABD0[i].field_40 = stru272_stru0::New(); current_card_slot_index = -1; amuint_4FAA4C = -1; byte_4FAA74 = 0; pArcomageGame->field_F4 = 0; - byte_4FAA2C = 0; + am_gameover = false; byte_505880 = 0; dword_4FAA70 = 0; need_to_discard_card = 0; @@ -4066,7 +4055,7 @@ //----- (0040D75D) -------------------------------------------------------- -void pPrimaryWindow_draws_text( int a1, const char *pText, POINT *pXY ) +void am_DrawText( int a1, const char *pText, POINT *pXY ) { pPrimaryWindow->DrawText( pFontComic, pXY->x, pXY->y - ((pFontComic->uFontHeight - 3) >> 1) + 3, 0, pText, 0, 0, 0); } @@ -4095,7 +4084,7 @@ pRenderer->EndScene(); } -void SetPixel2sq( POINT *pTargetXY, unsigned __int16 uColor ) +void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor ) { pRenderer->BeginScene(); if ( pRenderer->uNumSceneBegins ) @@ -4114,7 +4103,7 @@ } //----- (0040DBD3) -------------------------------------------------------- -void SetPixel( POINT *pTargetXY, unsigned __int16 uColor ) +void DrawPixel( POINT *pTargetXY, unsigned __int16 uColor ) { pRenderer->BeginScene(); if ( pRenderer->uNumSceneBegins ) @@ -4138,9 +4127,9 @@ //----- (0040DEC8) -------------------------------------------------------- -void __fastcall intToString(int val, char *pOut) +void __fastcall am_IntToString(int val, char *pOut) { - sprintf(pOut, "%d", val); + sprintfex(pOut, "%d", val); } void set_stru1_field_8_InArcomage(int inValue) diff -r ffef0fe0b59d -r cc1d68c17e19 Arcomage.h --- a/Arcomage.h Mon Sep 23 09:33:13 2013 +0600 +++ b/Arcomage.h Mon Sep 23 09:34:23 2013 +0600 @@ -4,18 +4,6 @@ #include "Texture.h" -/* 401 */ -#pragma pack(push, 1) -struct Acromage_st1 -{ - int uCardId; - int field_4; - POINT field_8; - int field_10_xplus; - int field_14_y_plus; - POINT field_18_point; -}; -#pragma pack(pop) /* 272 */ @@ -27,11 +15,11 @@ char field_24; char needed_quarry_level; char needed_magic_level; - char needed_might_level; + char needed_zoo_level; char needed_bricks; char needed_gems; char needed_beasts; - char can_be_discarded; + bool can_be_discarded; int compare_param; char field_30; char draw_extra_card_count; @@ -97,6 +85,18 @@ #pragma pack(pop) +/* 401 */ +#pragma pack(push, 1) +struct AcromageCardOnTable +{ + int uCardId; + int field_4; + POINT field_8; + int field_10_xplus; + int field_14_y_plus; + POINT field_18_point; +}; +#pragma pack(pop) #pragma pack(push, 1) @@ -232,10 +232,11 @@ #pragma pack(push, 1) struct stru272_stru0 // ARCOMAGE stuff { - static void Ctor(stru272_stru0 **a1); - int Dtor(); + static stru272_stru0 *New(); + + int Free(); int StartFill(stru272_stru2* a2); - int Empty(char a2, char a3); + int Clear(char a2, char a3); int DrawEffect(); int _40E2A7(); diff -r ffef0fe0b59d -r cc1d68c17e19 CastSpellInfo.cpp --- a/CastSpellInfo.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/CastSpellInfo.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -1020,9 +1020,9 @@ break; } - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); @@ -1886,9 +1886,9 @@ if ( pItemsTable->pItems[v240->uItemID].uEquipType != 12 || v240->uAttributes & 2 ) { - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); @@ -1919,9 +1919,9 @@ if ( uNewCharges <= 0 ) { v240 = 0; - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); pCastSpell->uSpellID = 0; @@ -1936,7 +1936,7 @@ case SPELL_WATER_ENCHANT_ITEM: { if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; + break; uRequiredMana = 0; amount = 10 * v2; v730 = 1; @@ -3650,9 +3650,9 @@ || (v591 = _v732->uEquipType) != 0 && v591 != 1 && v591 != 2 || pItemsTable->IsMaterialNonCommon(_v733) ) { - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 1; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); @@ -4102,7 +4102,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -4329,7 +4329,7 @@ pGUIWindow_Settings = nullptr; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -4377,7 +4377,7 @@ if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; pGUIWindow_Settings = pCastSpellInfo[result].GetCastSpellInInventoryWindow(); - unk_50C9A0 = 1; + _50C9A0_IsEnchantingInProgress = 1; some_active_character = uActiveCharacter; sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; diff -r ffef0fe0b59d -r cc1d68c17e19 Chest.cpp --- a/Chest.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Chest.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -801,7 +801,7 @@ } // 506128: using guessed type int areWeLoadingTexture; //----- (00420E01) -------------------------------------------------------- -void OnChestLeftClick() +void OnChestLeftClick() { int chest_id; // edi@1 POINT *v1; // esi@2 diff -r ffef0fe0b59d -r cc1d68c17e19 GUIWindow.h --- a/GUIWindow.h Mon Sep 23 09:33:13 2013 +0600 +++ b/GUIWindow.h Mon Sep 23 09:34:23 2013 +0600 @@ -24,7 +24,7 @@ UIMSG_CastQuickSpell = 25, - UIMSG_1B = 27, + UIMSG_STEALFROMACTOR = 27, UIMSG_1C = 28, UIMSG_PlayArcomage = 29, diff -r ffef0fe0b59d -r cc1d68c17e19 Items.cpp --- a/Items.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Items.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -143,7 +143,7 @@ int sub_4BE571(int a1, int *a2, int a3, int a4); -ItemGen *ptr_50C9A4; +ItemGen *ptr_50C9A4_ItemToEnchant; struct ItemsTable *pItemsTable; // 005D29E0 @@ -2388,7 +2388,7 @@ bool ItemGen::IsRegularEnchanmentForAttribute( CHARACTER_ATTRIBUTE_TYPE attrToGet ) { - auto bonusList = ItemGen::specialBonusMap.find(this->uSpecEnchantmentType); + auto bonusList = ItemGen::specialBonusMap.find(this->uEnchantmentType); if (bonusList == ItemGen::specialBonusMap.end()) { return false; diff -r ffef0fe0b59d -r cc1d68c17e19 Items.h --- a/Items.h Mon Sep 23 09:33:13 2013 +0600 +++ b/Items.h Mon Sep 23 09:34:23 2013 +0600 @@ -414,7 +414,7 @@ void GenerateItemsInChest(); extern std::array uItemsAmountPerShopType; // weak -extern ItemGen *ptr_50C9A4; +extern ItemGen *ptr_50C9A4_ItemToEnchant; extern struct ItemsTable *pItemsTable; diff -r ffef0fe0b59d -r cc1d68c17e19 Monsters.cpp --- a/Monsters.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Monsters.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -893,8 +893,8 @@ { int str_len=0; int str_pos=0; - pInfos[curr_rec_num].uSpecialAttackType=1; - pInfos[curr_rec_num].uSpecialAttack=0; + pInfos[curr_rec_num].uSpecialAttackLevel=1; + pInfos[curr_rec_num].uSpecialAttackType=(SPECIAL_ATTACK_TYPE)0; str_len=strlen(test_string); if (str_len>1) { @@ -903,12 +903,12 @@ if (tolower(test_string[str_pos])=='x') { test_string[str_pos]='\0'; - pInfos[curr_rec_num].uSpecialAttackType=atoi(&test_string[str_pos+1]); + pInfos[curr_rec_num].uSpecialAttackLevel=atoi(&test_string[str_pos+1]); test_string[str_pos]='x'; break; } } - pInfos[curr_rec_num].uSpecialAttack=ParseSpecialAttack(test_string); + pInfos[curr_rec_num].uSpecialAttackType=(SPECIAL_ATTACK_TYPE)ParseSpecialAttack(test_string); } } break; diff -r ffef0fe0b59d -r cc1d68c17e19 Monsters.h --- a/Monsters.h Mon Sep 23 09:33:13 2013 +0600 +++ b/Monsters.h Mon Sep 23 09:34:23 2013 +0600 @@ -82,6 +82,33 @@ MONSTER_SUPERTYPE_8 = 0x8, }; +enum SPECIAL_ATTACK_TYPE : unsigned __int8 +{ + SPECIAL_ATTACK_NONE = 0, + SPECIAL_ATTACK_CURSE = 1, + SPECIAL_ATTACK_WEAK = 2, + SPECIAL_ATTACK_SLEEP = 3, + SPECIAL_ATTACK_DRUNK = 4, + SPECIAL_ATTACK_INSANE = 5, + SPECIAL_ATTACK_POISON1 = 6, + SPECIAL_ATTACK_POISON2 = 7, + SPECIAL_ATTACK_POISON3 = 8, + SPECIAL_ATTACK_DISEASE1 = 9, + SPECIAL_ATTACK_DISEASE2 = 10, + SPECIAL_ATTACK_DISEASE3 = 11, + SPECIAL_ATTACK_PARALYZED = 12, + SPECIAL_ATTACK_UNCONSCIOUS = 13, + SPECIAL_ATTACK_DEAD = 14, + SPECIAL_ATTACK_PETRIFIED = 15, + SPECIAL_ATTACK_ERADICATED = 16, + SPECIAL_ATTACK_BREAK_ANY = 17, + SPECIAL_ATTACK_BREAK_ARMOR = 18, + SPECIAL_ATTACK_BREAK_WEAPON = 19, + SPECIAL_ATTACK_STEAL = 20, + SPECIAL_ATTACK_AGING = 21, + SPECIAL_ATTACK_MANA_DRAIN = 22, + SPECIAL_ATTACK_FEAR = 23, +}; /* 187 */ @@ -114,8 +141,8 @@ unsigned __int8 uAIType; HostilityRadius uHostilityType; char field_12; - unsigned __int8 uSpecialAttack; - unsigned __int8 uSpecialAttackType; + SPECIAL_ATTACK_TYPE uSpecialAttackType; + unsigned __int8 uSpecialAttackLevel; unsigned __int8 uAttack1Type; unsigned __int8 uAttack1DamageDiceRolls; unsigned __int8 uAttack1DamageDiceSides; diff -r ffef0fe0b59d -r cc1d68c17e19 Mouse.cpp --- a/Mouse.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Mouse.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -603,7 +603,7 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_1B, PID_ID(v6), 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_STEALFROMACTOR, PID_ID(v6), 0); if ( pParty->bTurnBasedModeOn == 1 ) { diff -r ffef0fe0b59d -r cc1d68c17e19 Player.cpp --- a/Player.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Player.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -60,6 +60,9 @@ +std::array StealingMasteryBonuses = {0, 100, 200, 300, 500}; //dword_4EDEA0 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one +std::array StealingRandomBonuses = {-200, -100, 0, 100, 200}; //dword_4EDEB4 +std::array StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10}; //dword_4EDEC4 //the zeroth element isn't accessed, it just helps avoid -1 indexing, originally 4 element array off by one @@ -130,7 +133,7 @@ {100, 100, 40, 10}, //Speed {100, 100, 100, 100}}; //Luck -signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; +unsigned int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; std::array pConditionImportancyTable = {{16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}}; @@ -1533,7 +1536,7 @@ } //----- (0048CCF5) -------------------------------------------------------- -int Player::GetActualAttack(int a2) +int Player::GetActualAttack( bool a2 ) { int v3; // eax@1 int v4; // edi@1 @@ -1704,7 +1707,7 @@ } else { - v3 = GetActualAttack(1); + v3 = GetActualAttack(true); } return v3; } @@ -2011,25 +2014,24 @@ } //----- (0048D76C) -------------------------------------------------------- -bool Player::StealFromShop(ItemGen *itemToSteal, int a3, int reputation, int a5, int *a6) //check stealing in IDA pro once I get home. The whole thing looks odd, dword_4EDEB4 and dword_4EDEA0 are never filled, might be a bug, might me on purpose +int Player::StealFromShop( ItemGen *itemToSteal, int extraStealDifficulty, int reputation, int a5, int *fineIfFailed ) //returns an int, but is the return value is compared to zero, so might change to bool { unsigned __int16 v6; // cx@8 int v7; // edi@8 unsigned int v8; // ebx@8 unsigned int itemvalue; // esi@8 int v10; // eax@8 - int v11; // edi@12 - bool result; // eax@13 + int currMaxItemValue; // edi@12 if ( !itemToSteal - || this->pConditions[16] - || this->pConditions[14] - || this->pConditions[15] - || this->pConditions[4] - || this->pConditions[13] - || this->pConditions[2] ) - { - result = 0; + || this->IsEradicated() + || this->IsDead() + || this->IsPertified() + || this->IsDrunk() + || this->IsUnconcious() + || this->IsAsleep() ) + { + return 0; } else { @@ -2038,23 +2040,33 @@ v8 = SkillToMastery(v6); itemvalue = itemToSteal->GetValue(); v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType; - if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 ) + if ( v10 == EQUIP_OFF_HAND || v10 == EQUIP_MAIN_HAND || v10 == EQUIP_BOW ) itemvalue *= 3; - v11 = dword_4EDEB4[rand() % 100 / 20] + v7 * dword_4EDEA0[v8]; - *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0); + currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; + *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; + if (a5) + { + *fineIfFailed += 500; + } if ( rand() % 100 >= 5 ) { - if ( *a6 > v11 ) - result = *a6 - v11 < 500; + if ( *fineIfFailed > currMaxItemValue ) + if (*fineIfFailed - currMaxItemValue < 500) + { + return 1; + } + else + { + return 0; + } else - result = 2; + return 2; } else { - result = 0; - } - } - return result; + return 0; + } + } } // 4EDEA0: using guessed type int dword_4EDEA0[]; // 4EDEB4: using guessed type int dword_4EDEB4[]; @@ -2062,162 +2074,130 @@ //----- (0048D88B) -------------------------------------------------------- int Player::StealFromActor(unsigned int uActorID, int _steal_perm, int reputation) { - Player *v4; // esi@1 - Actor *v5; // edi@1 - unsigned __int16 v6; // cx@10 + Actor *actroPtr; // edi@1 int v7; // ebx@10 - unsigned int v8; // esi@10 - int v9; // eax@10 - int v10; // esi@10 + unsigned int stealingMastery; // esi@10 + int fineIfFailed; // esi@10 int v11; // eax@13 - signed int v12; // ebx@15 - signed int v13; // edx@15 - int v14; // ecx@15 - unsigned __int16 v15; // si@21 - unsigned int v16; // ebx@24 - int v17; // esi@24 - const void *v18; // eax@29 - unsigned int v19; // esi@31 - int v20; // eax@34 - char v21; // zf@36 - unsigned int v22; // ST0C_4@39 - char *v23; // esi@39 - const char *v25; // [sp-Ch] [bp-48h]@40 - int v26; // [sp-8h] [bp-44h]@40 - ItemGen v27; // [sp+8h] [bp-34h]@15 - unsigned int v28; // [sp+2Ch] [bp-10h]@10 - int v29; // [sp+30h] [bp-Ch]@10 - int v30; // [sp+34h] [bp-8h]@10 - Player *v31; // [sp+38h] [bp-4h]@1 - signed int _steal_perma; // [sp+48h] [bp+Ch]@12 - - v4 = this; - v5 = &pActors[uActorID]; - v31 = this; - if ( &pActors[uActorID] - && !this->pConditions[16] - && !this->pConditions[14] - && !this->pConditions[15] - && !this->pConditions[4] - && !this->pConditions[13] - && !this->pConditions[2] ) - { - if ( !(BYTE2(v5->uAttributes) & 0x80) ) - pActors[uActorID].SetRandomGoldIfTheresNoItem(); - v6 = v4->pActiveSkills[34]; - v7 = v6 & 0x3F; - v8 = SkillToMastery(v6); - v9 = rand(); - v28 = 4 * v8; - v30 = dword_4EDEA0[v8]; - v29 = dword_4EDEB4[v9 % 100 / 20]; - v10 = v5->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); - if ( rand() % 100 < 5 || v10 > v29 + v7 * v30 || (_steal_perma = 2, BYTE2(v5->uAttributes) & 8) ) - { - Actor::AggroSurroundingPeasants(uActorID, 1); - _steal_perma = 0; - v26 = (int)v31->pName; - v25 = pGlobalTXT_LocalizationStrings[376]; - } - else - { - v11 = rand(); - if ( v11 % 100 >= 40 ) - { - if ( v11 % 100 >= 70 ) + bool HasFullItemSlots; // ebx@15 + unsigned __int16 carriedItemId; // si@21 + unsigned int enchBonusSum; // esi@31 + int *enchTypePtr; // eax@34 + ItemGen tempItem; // [sp+8h] [bp-34h]@15 + int currMaxItemValue; + + actroPtr = &pActors[uActorID]; + if ( !actroPtr + || this->IsEradicated() + || this->IsDead() + || this->IsPertified() + || this->IsDrunk() + || this->IsUnconcious() + || this->IsAsleep() ) + { + return 0; + } + pGlobalTXT_LocalizationStrings[1]; + if ( !(BYTE2(actroPtr->uAttributes) & 0x80) ) + actroPtr->SetRandomGoldIfTheresNoItem(); + unsigned __int16 v6 = this->pActiveSkills[34]; + v7 = v6 & 0x3F; + stealingMastery = SkillToMastery(v6); + int v30 = StealingMasteryBonuses[stealingMastery]; + int v29 = StealingRandomBonuses[rand() % 5]; + fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); + currMaxItemValue = v29 + v7 * v30; + pGlobalTXT_LocalizationStrings[200]; + if ( false && (rand() % 100 < 5 || fineIfFailed > currMaxItemValue || BYTE2(actroPtr->uAttributes) & 8) ) + { + Actor::AggroSurroundingPeasants(uActorID, 1); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[376], this->pName); + ShowStatusBarString(pTmpBuf2.data(), 2u); + return 0; + } + else + { + v11 = rand(); + if ( v11 % 100 >= 70 ) //stealing gold + { + enchBonusSum = 0; + for (int i = 0; i < v7; i++) + { + enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; + } + if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) + return 2; + enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; + if ( (int)enchBonusSum >= *enchTypePtr ) + { + actroPtr->array_000234[3].uItemID = 0; + *enchTypePtr = 0; + } + else + { + *enchTypePtr -= enchBonusSum; + } + if ( enchBonusSum ) + { + party_finds_gold(enchBonusSum, 2); + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold + } + else + { + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything + } + ShowStatusBarString(pTmpBuf2.data(), 2u); + return 2; + } + else if ( v11 % 100 >= 40 ) //stealing an item + { + tempItem.Reset(); + HasFullItemSlots = false; + int i; + for (i = 0; i < 4; i++) + { + if ( actroPtr->array_000234[i].uItemID != 0 && pItemsTable->pItems[actroPtr->array_000234[i].uItemID].uEquipType != EQUIP_GOLD ) + break; + } + if (i == 4) + HasFullItemSlots = true; + carriedItemId = actroPtr->uCarriedItemID; + if ( carriedItemId != 0 || HasFullItemSlots ) + { + tempItem.Reset(); + if ( carriedItemId != 0 ) { - v19 = 0; - if ( v7 > 0 ) - { - do - { - --v7; - v19 += rand() % dword_4EDEC4[v28 / 4] + 1; - } - while ( v7 ); - } - if ( pItemsTable->pItems[v5->array_000234[3].uItemID].uEquipType != 18 ) - return _steal_perma; - v20 = (int)&v5->array_000234[3].uSpecEnchantmentType; - if ( (signed int)v19 > v5->array_000234[3].uSpecEnchantmentType ) - v19 = v5->array_000234[3].uSpecEnchantmentType; - v21 = *(int *)v20 == v19; - *(int *)v20 -= v19; - if ( v21 ) - v5->array_000234[3].uItemID = 0; - if ( v19 ) - { - party_finds_gold(v19, 2); - v22 = v19; - v23 = pTmpBuf2.data(); - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], v31->pName, v22); -LABEL_43: - ShowStatusBarString(v23, 2u); - return _steal_perma; - } + actroPtr->uCarriedItemID = 0; + tempItem.uItemID = carriedItemId; + if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) + tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; + else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) + tempItem.uEnchantmentType = 2 * rand() % 4 + 2; } else { - v27.Reset(); - v12 = 0; - v13 = 0; - v14 = (int)v5->array_000234; - while ( !*(int *)v14 || pItemsTable->pItems[*(int *)v14].uEquipType == 18 ) - { - ++v13; - v14 += 36; - if ( v13 >= 4 ) - goto LABEL_21; - } - v12 = 1; -LABEL_21: - v15 = v5->uCarriedItemID; - if ( v15 || v12 ) - { - v27.Reset(); - if ( v15 ) - { - v16 = (signed __int16)v15; - v5->uCarriedItemID = 0; - v27.uItemID = (signed __int16)v15; - v17 = (signed __int16)v15; - if ( pItemsTable->pItems[v17].uEquipType == 12 ) - v27.uNumCharges = rand() % 6 + pItemsTable->pItems[v17].uDamageMod + 1; - if ( pItemsTable->pItems[v17].uEquipType == 14 ) - { - if ( v16 != 220 ) - v27.uEnchantmentType = 2 * rand() % 4 + 2; - } - } - else - { - v18 = &v5->array_000234[rand() % 4]; - memcpy(&v27, v18, sizeof(v27)); - ((ItemGen *)v18)->Reset(); - v16 = v27.uItemID; - } - sub_421B2C_PlaceInInventory_or_DropPickedItem(); - sprintf( - pTmpBuf2.data(), - pGlobalTXT_LocalizationStrings[304], - v31->pName, - pItemsTable->pItems[v16].pUnidentifiedName); - ShowStatusBarString(pTmpBuf2.data(), 2u); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); - memcpy(&pParty->pPickedItem, &v27, sizeof(pParty->pPickedItem)); - pMouse->SetCursorBitmapFromItemID(v16); - return _steal_perma; - } + ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; + memcpy(&tempItem, itemToSteal, sizeof(tempItem)); + itemToSteal->Reset(); + carriedItemId = tempItem.uItemID; } - } - v26 = (int)v31->pName; - v25 = pGlobalTXT_LocalizationStrings[377]; - } - v23 = pTmpBuf2.data(); - sprintfex(pTmpBuf2.data(), v25, v26); - goto LABEL_43; - } - return 0; + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + sprintf( + pTmpBuf2.data(), + pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message + this->pName, + pItemsTable->pItems[carriedItemId].pUnidentifiedName); + ShowStatusBarString(pTmpBuf2.data(), 2u); + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); + pMouse->SetCursorBitmapFromItemID(carriedItemId); + return 2; + } + } + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything + ShowStatusBarString(pTmpBuf2.data(), 2u); + return 2; + } } // 4EDEA0: using guessed type int dword_4EDEA0[]; // 4EDEB4: using guessed type int dword_4EDEB4[]; @@ -2288,173 +2268,125 @@ } //----- (0048DCF6) -------------------------------------------------------- -int Player::_48DCF6(int a2, Actor *pActor) //TODO check this with IDA to see what the uninitialized vars are supposed to contain -{ +int Player::ReceiveSpecialAttackEffect( int attType, struct Actor *pActor ) +{ + SPECIAL_ATTACK_TYPE attTypeCast = (SPECIAL_ATTACK_TYPE) attType; signed int v3; // edi@1 signed int v4; // ebx@1 - Player *v5; // esi@1 int v6; // eax@2 - int v7; // eax@5 int v8; // eax@8 - int v9; // ebx@8 int v10; // eax@8 int v11; // ebx@8 - signed int v12; // edx@9 ItemGen *v13; // eax@9 - int v14; // edx@16 - unsigned int v15; // edx@17 - int v16; // edx@26 - unsigned int v17; // edx@27 - signed int v19; // edx@38 - int *v20; // ecx@38 - signed int v21; // eax@40 int v22; // eax@49 signed int v23; // ebx@49 - unsigned int v24; // eax@60 - int v25; // ecx@61 - int v26; // ebx@74 void *v27; // ecx@76 - unsigned int v28; // ebx@78 - signed int result; // eax@86 - SoundID v30; // [sp-20h] [bp-C0h]@56 - signed int v31; // [sp-1Ch] [bp-BCh]@56 - unsigned int v32; // [sp-18h] [bp-B8h]@56 - signed int v33; // [sp-14h] [bp-B4h]@56 - signed int v34; // [sp-10h] [bp-B0h]@56 - int v35; // [sp-Ch] [bp-ACh]@56 - unsigned int v36; // [sp-8h] [bp-A8h]@51 - unsigned int v37; // [sp-8h] [bp-A8h]@56 - unsigned int v38; // [sp-8h] [bp-A8h]@57 - unsigned int v39; // [sp-8h] [bp-A8h]@68 - enum CHARACTER_ATTRIBUTE_TYPE v40; // [sp-4h] [bp-A4h]@4 - int v41; // [sp-4h] [bp-A4h]@51 - int v42; // [sp-4h] [bp-A4h]@56 - int v43; // [sp-4h] [bp-A4h]@57 - signed int v44; // [sp-4h] [bp-A4h]@59 - int v45; // [sp-4h] [bp-A4h]@68 char v46[140]; // [sp+Ch] [bp-94h]@13 unsigned int v47; // [sp+98h] [bp-8h]@1 - int v48; // [sp+9Ch] [bp-4h]@1 - - v3 = 0; + ItemGen* v48; // [sp+9Ch] [bp-4h]@1 + v4 = 0; - v5 = this; v47 = 0; - v48 = 0; - switch ( a2 ) - { - case 1: + switch ( attTypeCast ) + { + case SPECIAL_ATTACK_CURSE: v6 = GetActualWillpower(); - goto LABEL_46; - case 2: - case 3: - case 4: - case 9: - case 10: - case 11: - case 13: - case 21: + v11 = GetParameterBonus(v6); + break; + case SPECIAL_ATTACK_WEAK: + case SPECIAL_ATTACK_SLEEP: + case SPECIAL_ATTACK_DRUNK: + case SPECIAL_ATTACK_DISEASE1: + case SPECIAL_ATTACK_DISEASE2: + case SPECIAL_ATTACK_DISEASE3: + case SPECIAL_ATTACK_UNCONSCIOUS: + case SPECIAL_ATTACK_AGING: v6 = GetActualEndurance(); - goto LABEL_46; - case 5: - case 12: - case 23: - v40 = (CHARACTER_ATTRIBUTE_TYPE)14; - goto LABEL_5; - case 15: - v40 = (CHARACTER_ATTRIBUTE_TYPE)13; - goto LABEL_5; - case 6: - case 7: - case 8: - case 14: - case 16: - v40 = (CHARACTER_ATTRIBUTE_TYPE)15; -LABEL_5: - v7 = GetActualResistance(v40); - goto LABEL_47; - case 22: + v11 = GetParameterBonus(v6); + break; + case SPECIAL_ATTACK_INSANE: + case SPECIAL_ATTACK_PARALYZED: + case SPECIAL_ATTACK_FEAR: + v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); + break; + case SPECIAL_ATTACK_PETRIFIED: + v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); + break; + case SPECIAL_ATTACK_POISON1: + case SPECIAL_ATTACK_POISON2: + case SPECIAL_ATTACK_POISON3: + case SPECIAL_ATTACK_DEAD: + case SPECIAL_ATTACK_ERADICATED: + v11 = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); + break; + case SPECIAL_ATTACK_MANA_DRAIN: v8 = GetActualWillpower(); - v9 = GetParameterBonus(v8); v10 = GetActualIntelligence(); - v11 = (GetParameterBonus(v10) + v9) >> 1; + v11 = (GetParameterBonus(v10) + GetParameterBonus(v8)) / 2; break; - case 17: - v12 = 0; - v13 = this->pInventoryItemList; - do - { - if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->IsBroken()) - v46[v4++] = v12; - ++v12; - ++v13; - } - while ( v12 < 138 ); - goto LABEL_36; - case 18: - v14 = 0; - do - { - if ( HasItemEquipped((ITEM_EQUIP_TYPE)v14) ) + case SPECIAL_ATTACK_BREAK_ANY: + for (int i = 0; i < 138; i++) + { + v13 = &this->pInventoryItemList[i]; + if ( v13->uItemID > 0 && v13->uItemID <= 134 && !v13->IsBroken()) + v46[v4++] = i; + } + if ( !v4 ) + return 0; + v48 = &this->pInventoryItemList[v46[rand() % v4]]; + v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod); + break; + case SPECIAL_ATTACK_BREAK_ARMOR: + for (int i = 0; i < 16; i++ ) + { + if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { - __debugbreak(); // player.cpp(2871): warning C4700: uninitialized local variable 'v15' used - if ( v15 == EQUIP_ARMOUR ) - v46[v4++] = LOBYTE(v5->pEquipment.uArmor) - 1; - if ( (!v15 || v15 == 1) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v15) == 4 ) - v46[v4++] = *((char *)&v5->pEquipment.uShield + 4 * v15) - 1; + if ( i == EQUIP_ARMOUR ) + v46[v4++] = this->pEquipment.uArmor - 1; + if ( (i == EQUIP_OFF_HAND || i == EQUIP_MAIN_HAND) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_SHIELD ) + v46[v4++] = this->pEquipment.pIndices[i] - 1; } - v14 = v15 + 1; - } - while ( v14 < 16 ); - goto LABEL_36; - case 19: - v16 = 0; - do - { - if ( HasItemEquipped((ITEM_EQUIP_TYPE)v16) ) + } + if ( !v4 ) + return 0; + v48 = &this->pInventoryItemList[v46[rand() % v4]]; + v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod); + break; + case SPECIAL_ATTACK_BREAK_WEAPON: + for (int i = 0; i < 16; i++ ) + { + if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { - __debugbreak(); // player.cpp(2886): warning C4700: uninitialized local variable 'v17' used - if ( v17 == 2 ) - v46[v4++] = LOBYTE(v5->pEquipment.uBow) - 1; - if ( (!v17 || v17 == 1) - && (!GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v17) || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v17) == 1) ) - v46[v4++] = *((char *)&v5->pEquipment.uShield + 4 * v17) - 1; + if ( i == EQUIP_BOW ) + v46[v4++] = LOBYTE(this->pEquipment.uBow) - 1; + if ( (i == EQUIP_OFF_HAND || i == EQUIP_MAIN_HAND) + && (GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_OFF_HAND || GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i) == EQUIP_MAIN_HAND) ) + v46[v4++] = this->pEquipment.pIndices[i] - 1; } - v16 = v17 + 1; - } - while ( v16 < 16 ); -LABEL_36: + } if ( !v4 ) - goto LABEL_87; - v48 = (int)&v5->pInventoryItemList[(unsigned __int8)v46[rand() % v4]]; - v11 = 3 * (pItemsTable->pItems[*(int *)v48].uMaterial + pItemsTable->pItems[*(int *)v48].uDamageMod); + return 0; + v48 = &this->pInventoryItemList[v46[rand() % v4]]; + v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod); break; - case 20: - v19 = 0; - v20 = this->pInventoryMatrix; - do - { - if ( *v20 > 0 ) + case SPECIAL_ATTACK_STEAL: + for ( int i = 0; i < 126; i++ ) + { + int ItemPosInList = this->pInventoryMatrix[i]; + if (ItemPosInList > 0) { - v21 = *(int *)&v5->pInventoryItemList[*v20-1]; - if ( v21 > 0 ) + ItemGen* v21 = &this->pInventoryItemList[ItemPosInList - 1]; + if ( v21->uItemID > 0 && v21->uItemID <= 134 ) { - if ( v21 <= 134 ) - v46[v4++] = v19; + v46[v4++] = i; } } - ++v19; - ++v20; - } - while ( v19 < 126 ); + } if ( !v4 ) - goto LABEL_87; - v47 = (unsigned __int8)v46[rand() % v4]; + return 0; + v47 = v46[rand() % v4]; v6 = GetActualAccuracy(); -LABEL_46: - v7 = GetParameterBonus(v6); -LABEL_47: - v11 = v7; + v11 = GetParameterBonus(v6); break; default: v11 = 0; @@ -2464,185 +2396,168 @@ v23 = GetParameterBonus(v22) + v11 + 30; if ( rand() % v23 >= 30 ) { -LABEL_87: - result = 0; + return 0; } else { - switch ( a2 ) - { - case 1: - v41 = 1; - v36 = 0; - goto LABEL_56; - case 2: - v41 = 1; - v36 = 1; - goto LABEL_56; - case 3: - v41 = 1; - v36 = 2; - goto LABEL_56; - case 23: - v41 = 1; - v36 = 3; - goto LABEL_56; - case 4: - v41 = 1; - v36 = 4; -LABEL_56: - SetCondition(v36, v41); - v42 = 0; - v37 = 0; - v35 = 0; - v34 = 0; - v33 = -1; - v32 = 0; - v31 = 0; - v30 = (SoundID)221; - goto LABEL_83; - case 5: - v43 = 1; - v38 = 5; - goto LABEL_70; - case 6: - case 7: - case 8: - if ( a2 == 6 ) + for ( v3 = 0; v3 < 4; v3++ ) + { + if ( this == pPlayers[v3 + 1] ) + break; + } + + switch ( attTypeCast ) + { + case SPECIAL_ATTACK_CURSE: + SetCondition(Condition_Cursed, 1); + pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_WEAK: + SetCondition(Condition_Weak, 1); + pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_SLEEP: + SetCondition(Condition_Sleep, 1); + pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_DRUNK: + SetCondition(Condition_Drunk, 1); + pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_INSANE: + SetCondition(Condition_Insane, 1); + pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_POISON1: + SetCondition(Condition_Poison1, 1); + pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_POISON2: + SetCondition(Condition_Poison2, 1); + pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_POISON3: + SetCondition(Condition_Poison3, 1); + pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_DISEASE1: + SetCondition(Condition_Disease1, 1); + pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_DISEASE2: + SetCondition(Condition_Disease2, 1); + pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_DISEASE3: + SetCondition(Condition_Disease3, 1); + pAudioPlayer->PlaySound((SoundID)222, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_PARALYZED: + SetCondition(Condition_Paralyzed, 1); + pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_UNCONSCIOUS: + SetCondition(Condition_Unconcious, 1); + pAudioPlayer->PlaySound((SoundID)224, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_DEAD: + SetCondition(Condition_Dead, 1); + pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_PETRIFIED: + SetCondition(Condition_Pertified, 1); + pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_ERADICATED: + SetCondition(Condition_Eradicated, 1); + pAudioPlayer->PlaySound((SoundID)225, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_BREAK_ANY: + case SPECIAL_ATTACK_BREAK_ARMOR: + case SPECIAL_ATTACK_BREAK_WEAPON: + if ( !(v48->uAttributes & ITEM_ENCHANTED) ) { - v44 = 6; - goto LABEL_60; - } - v25 = 2 * (a2 != 8) + 8; - goto LABEL_65; - case 9: - if ( a2 == 6 ) - { - v44 = 7; -LABEL_60: - v24 = v44; - } - else - { - v25 = 2 * (a2 != 8) + 9; -LABEL_65: - v24 = v25; + PlaySound(SPEECH_40, 0); + v48->SetBroken(); + pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); } - SetCondition(v24, 1); - v42 = 0; - v37 = 0; - v35 = 0; - v34 = 0; - v33 = -1; - v32 = 0; - v31 = 0; - v30 = (SoundID)222; -LABEL_83: - pAudioPlayer->PlaySound(v30, v31, v32, v33, v34, v35, v37, v42); - do - { -LABEL_84: - if ( v5 == pPlayers[v3 + 1] ) - break; - ++v3; - } - while ( v3 < 4 ); pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); - result = 1; + return 1; break; - case 12: - v43 = 1; - v38 = 12; - goto LABEL_70; - case 15: - v45 = 1; - v39 = 15; - goto LABEL_73; - case 13: - v43 = 1; - v38 = 13; -LABEL_70: - SetCondition(v38, v43); - v42 = 0; - v37 = 0; - v35 = 0; - v34 = 0; - v33 = -1; - v32 = 0; - v31 = 0; - v30 = (SoundID)224; - goto LABEL_83; - case 14: - v45 = 1; - v39 = 14; - goto LABEL_73; - case 16: - v45 = 1; - v39 = 16; -LABEL_73: - SetCondition(v39, v45); - v42 = 0; - v37 = 0; - v35 = 0; - v34 = 0; - v33 = -1; - v32 = 0; - v31 = 0; - v30 = (SoundID)225; - goto LABEL_83; - case 17: - case 18: - case 19: - v26 = v48; - if ( *(char *)(v48 + 21) & 2 ) - goto LABEL_84; - PlaySound(SPEECH_40, 0); - *(int *)(v26 + 20) |= 2u; - goto LABEL_79; - case 20: + case SPECIAL_ATTACK_STEAL: PlaySound(SPEECH_40, 0); v27 = pActor->array_000234; if ( pActor->array_000234[0].uItemID ) { v27 = &pActor->array_000234[1]; if ( pActor->array_000234[1].uItemID ) - goto LABEL_84; + { + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + } } - v28 = v47; - memcpy(v27, &v5->pInventoryItemList[v5->pInventoryMatrix[v47]-1], 0x24u); - RemoveItemAtInventoryIndex(v28); -LABEL_79: - v42 = 0; - v37 = 0; - v35 = 0; - v34 = 0; - v33 = -1; - v32 = 0; - v31 = 0; - v30 = (SoundID)47; - goto LABEL_83; - case 21: + memcpy(v27, &this->pInventoryItemList[this->pInventoryMatrix[v47]-1], 0x24u); + RemoveItemAtInventoryIndex(v47); + pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_AGING: PlaySound(SPEECH_42, 0); - ++v5->sAgeModifier; - goto LABEL_82; - case 22: + ++this->sAgeModifier; + pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_MANA_DRAIN: PlaySound(SPEECH_41, 0); - v5->sMana = 0; -LABEL_82: - v42 = 0; - v37 = 0; - v35 = 0; - v34 = 0; - v33 = -1; - v32 = 0; - v31 = 0; - v30 = (SoundID)226; - goto LABEL_83; + this->sMana = 0; + pAudioPlayer->PlaySound((SoundID)226, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; + case SPECIAL_ATTACK_FEAR: + SetCondition(Condition_Fear, 1); + pAudioPlayer->PlaySound((SoundID)221, 0, 0, -1, 0, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x99u, v3); + return 1; + break; default: - goto LABEL_87; - } - } - return result; + return 0; + } + } } // 48DCF6: using guessed type char var_94[140]; @@ -4419,7 +4334,7 @@ //----- (004908A8) -------------------------------------------------------- bool Player::DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime) { - if ( pConditions[uCondition] && (uTime < pConditions[uCondition]) ) + if ( pConditions[uCondition] && (uTime < (signed long long)pConditions[uCondition]) ) { pConditions[uCondition] = 0i64; return true; @@ -4506,7 +4421,7 @@ } else { - thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); + thisb->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); } } pMouse->RemoveHoldingItem(); @@ -4801,7 +4716,7 @@ } else { - thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); + thisb->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); } } pMouse->RemoveHoldingItem(); @@ -7467,68 +7382,27 @@ //----- (00439FCB) -------------------------------------------------------- -void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4) -{ - signed int v4; // esi@1 - unsigned int v5; // ecx@1 +void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4) +{ Player *playerPtr; // ebx@3 Actor *actorPtr; // esi@3 unsigned int v8; // eax@4 - int v11; // edx@8 - int v14; // edx@16 - enum SoundID v17; // eax@24 - unsigned __int16 v21; // ax@29 - signed int v22; // edi@36 - int v23; // eax@38 - signed int v24; // eax@44 - AIState v25; // cx@47 - signed int v26; // eax@49 - int v27; // eax@54 - int v34; // edi@61 - int v35; // eax@70 - int v36; // st7@70 - SpriteObject *v37; // ebx@77 - int v38; // edi@77 - int v39; // esi@77 - int v40; // eax@77 - int v41; // eax@77 - Player *v43; // eax@81 - //Actor *actorPtr; // esi@82 - Player *v45; // edi@84 - unsigned __int16 v46; // ax@84 - int v48; // eax@107 - unsigned __int16 v49; // ax@116 - int v50; // ebx@123 - unsigned __int16 v51; // ax@124 - int v53; // eax@128 - signed int v54; // eax@134 - unsigned __int16 v55; // cx@137 + int spellId; // eax@38 signed int recvdMagicDmg; // eax@139 - int v57; // eax@144 - int v64; // ebx@151 - int v65; // eax@161 - int v66; // st7@161 - signed int v68; // eax@170 - int v69; // ecx@170 - int v70; // eax@171 int v72[4]; // [sp+30h] [bp-24h]@164 - signed int v74; // [sp+44h] [bp-10h]@1 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 - int dmgToReceive; // [sp+50h] [bp-4h]@26 - - v4 = PID_ID(uObjID); - v5 = PID_TYPE(uObjID) - 2; - v74 = a2; - uActorID = v4; - if ( v5 ) + + uActorID = PID_ID(uObjID); + if ( PID_TYPE(uObjID) != 2) { playerPtr = &pParty->pPlayers[a4]; - actorPtr = &pActors[v4]; + actorPtr = &pActors[uActorID]; healthBeforeRecvdDamage = playerPtr->sHealth; - if ( v5 != 1 || !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) + if ( PID_TYPE(uObjID) != 3 || !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) return; v8 = playerPtr->pEquipment.uArmor; + SoundID soundToPlay; if ( !v8 || playerPtr->pInventoryItemList[v8 - 1].IsBroken() || @@ -7537,101 +7411,102 @@ ) ) { - v14 = rand() % 4; - switch (v14) - { - case 0 : v17 = (SoundID)108; break; - case 1 : v17 = (SoundID)109; break; - case 2 : v17 = (SoundID)110; break; - case 3 : v17 = (SoundID)44; break; + int randVal = rand() % 4; + switch (randVal) + { + case 0 : soundToPlay = (SoundID)108; break; + case 1 : soundToPlay = (SoundID)109; break; + case 2 : soundToPlay = (SoundID)110; break; + case 3 : soundToPlay = (SoundID)44; break; } } else { - v11 = rand() % 4; - switch (v11) - { - case 0 : v17 = (SoundID)105; break; - case 1 : v17 = (SoundID)106; break; - case 2 : v17 = (SoundID)107; break; - case 3 : v17 = (SoundID)45; break; - } - } - pAudioPlayer->PlaySound(v17, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); - dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, v74); + int randVal = rand() % 4; + switch (randVal) + { + case 0 : soundToPlay = (SoundID)105; break; + case 1 : soundToPlay = (SoundID)106; break; + case 2 : soundToPlay = (SoundID)107; break; + case 3 : soundToPlay = (SoundID)45; break; + } + } + pAudioPlayer->PlaySound(soundToPlay, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); + int dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, element); if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) { - v21 = actorPtr->pActorBuffs[3].uPower; - if ( v21 ) - dmgToReceive /= (signed int)v21; - } - switch (v74) - { - case 0: v22 = actorPtr->pMonsterInfo.uAttack1Type; + __int16 spellPower = actorPtr->pActorBuffs[3].uPower; + if ( spellPower ) + dmgToReceive /= (signed int)spellPower; + } + int damageType; + switch (element) + { + case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type; break; - case 1: v22 = actorPtr->pMonsterInfo.uAttack2Type; + case 1: damageType = actorPtr->pMonsterInfo.uAttack2Type; break; - case 2: v23 = actorPtr->pMonsterInfo.uSpell1ID; - v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool); + case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID; + damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; - case 3: v23 = actorPtr->pMonsterInfo.uSpell2ID; - v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool); + case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID; + damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; - case 4: v22 = actorPtr->pMonsterInfo.field_3C_some_special_attack; + case 4: damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; break; default: - case 5: v22 = 4; //yes, the original just assigned the value 4 + case 5: damageType = 4; //yes, the original just assigned the value 4 break; } if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { - v24 = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)v22); + dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) { - v25 = actorPtr->uAIState; - if ( v25 != Dying && v25 != Dead) + int actorState = actorPtr->uAIState; + if ( actorState != Dying && actorState != Dead) { - v26 = stru_50C198.CalcMagicalDamageToActor(actorPtr, v22, v24); - actorPtr->sCurrentHP -= v26; - if ( v26 >= 0 ) + int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, dmgToReceive); + actorPtr->sCurrentHP -= reflectedDamage; + if ( reflectedDamage >= 0 ) { if ( actorPtr->sCurrentHP >= 1 ) { - Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); + Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); //todo extract this branch to a function once Actor::functions are changed to nonstatic actor functions Actor::AggroSurroundingPeasants(uActorID, 1); } else { if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) { - v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; - pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)v27, 0, 0); + int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; + pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0); } Actor::Die(uActorID); Actor::ApplyFineForKillingPeasant(uActorID); Actor::AggroSurroundingPeasants(uActorID, 1); if ( actorPtr->pMonsterInfo.uExp ) GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); - v34 = SPEECH_51; + int speechToPlay = SPEECH_51; if ( rand() % 100 < 20 ) - v34 = ((signed int)actorPtr->pMonsterInfo.uHP >= 100) + 1; - playerPtr->PlaySound((PlayerSpeech)v34, 0); + speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; + playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0); } } } } if ( !(dword_6BE368_debug_settings_2 & 0x10) - && actorPtr->pMonsterInfo.uSpecialAttack - && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackType ) - { - playerPtr->_48DCF6(actorPtr->pMonsterInfo.uSpecialAttack, actorPtr); + && actorPtr->pMonsterInfo.uSpecialAttackType + && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel ) + { + playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr); } } if ( !pParty->bTurnBasedModeOn ) { - v35 = playerPtr->GetActualEndurance(); - v36 = (int)((20 - playerPtr->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333); - playerPtr->SetRecoveryTime(v36); + int actEndurance = playerPtr->GetActualEndurance(); + int recoveryTime = (int)((20 - playerPtr->GetParameterBonus(actEndurance)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333); + playerPtr->SetRecoveryTime(recoveryTime); } int yellThreshold = playerPtr->GetMaxHealth() / 4; if ( yellThreshold < playerPtr->sHealth && yellThreshold >= healthBeforeRecvdDamage && playerPtr->sHealth > 0 ) @@ -7643,35 +7518,35 @@ } else { - v37 = &pSpriteObjects[uActorID]; - v38 = PID_TYPE(v37->spell_caster_pid); - v39 = PID_ID(v37->spell_caster_pid); - v40 = PID_TYPE(v37->spell_caster_pid); - uActorID = PID_ID(v37->spell_caster_pid); - v41 = v40 - 2; - if ( v40 == 2 ) - { + SpriteObject* v37 = &pSpriteObjects[uActorID]; + int uActorType = PID_TYPE(v37->spell_caster_pid); + int uActorID = PID_ID(v37->spell_caster_pid); + if ( uActorType == 2 ) + { + Player *playerPtr; // eax@81 if ( a4 != -1 ) { - v43 = &pParty->pPlayers[a4]; + playerPtr = &pParty->pPlayers[a4]; } else { - v74 = 0; + element = 0; for (int i = 1; i <= 4; i++) { - v72[v74] = i; - v74++; + v72[element] = i; + element++; } - if ( v74 ) + if ( element ) { - v43 = &pParty->pPlayers[v72[rand() % v74]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; + playerPtr = &pParty->pPlayers[v72[rand() % element]];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; } } - if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW) - { - v70 = v43->GetMaxHealth(); - v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70); + int v68; + int v69; + if ( uActorType != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW) + { + int playerMaxHp = playerPtr->GetMaxHealth(); + v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, playerMaxHp); v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool); } else @@ -7679,8 +7554,8 @@ v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0); v69 = 0; } - v43->ReceiveDamage(v68, (DAMAGE_TYPE)v69); - if ( v38 == OBJECT_Player && !qword_A750D8 ) + playerPtr->ReceiveDamage(v68, (DAMAGE_TYPE)v69); + if ( uActorType == OBJECT_Player && !qword_A750D8 ) { qword_A750D8 = 256i64; PlayerSpeechID = SPEECH_44; @@ -7688,98 +7563,99 @@ } return; } - else if ( v40 == 3 ) - { - actorPtr = &pActors[v39]; + else if ( uActorType == 3 ) + { + Actor *actorPtr = &pActors[uActorID]; if ( a4 == -1 ) a4 = stru_50C198.which_player_would_attack(actorPtr); - v45 = &pParty->pPlayers[a4]; - dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, v74); - v46 = v37->uType; + Player *playerPtr = &pParty->pPlayers[a4]; + int dmgToReceive = Actor::_43B3E0_CalcDamage(actorPtr, element); + unsigned __int16 spriteType = v37->uType; if ( v37->uType == 545 ) { - v51 = v45->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - if ( SkillToMastery(v51) >= 4 && rand() % 100 < (v51 & 0x3F) ) + __int16 skillLevel = playerPtr->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + if ( SkillToMastery(skillLevel) >= 4 && rand() % 100 < (skillLevel & 0x3F) ) { - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], v45->pName); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], playerPtr->pName); ShowStatusBarString(pTmpBuf.data(), 2u); - v45->PlaySound(SPEECH_6, 0); + playerPtr->PlaySound(SPEECH_6, 0); return; } } - else if ( v46 == 555 - || v46 == 510 - || v46 == 500 - || v46 == 515 - || v46 == 505 - || v46 == 530 - || v46 == 525 - || v46 == 520 - || v46 == 535 - || v46 == 540 ) - { - if ( !stru_50C198.ActorHitOrMiss(actorPtr, v45) ) + else if ( spriteType == 555 + || spriteType == 510 + || spriteType == 500 + || spriteType == 515 + || spriteType == 505 + || spriteType == 530 + || spriteType == 525 + || spriteType == 520 + || spriteType == 535 + || spriteType == 540 ) + { + if ( !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) return; - if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 ) + if ( playerPtr->pPlayerBuffs[13].uExpireTime > 0 ) dmgToReceive >>= 1; - if ( v45->HasEnchantedItemEquipped(36) ) + if ( playerPtr->HasEnchantedItemEquipped(36) ) dmgToReceive >>= 1; - if ( v45->HasEnchantedItemEquipped(69) ) + if ( playerPtr->HasEnchantedItemEquipped(69) ) dmgToReceive >>= 1; - if ( v45->HasItemEquipped(EQUIP_ARMOUR) - && v45->pInventoryItemList[v45->pEquipment.uArmor-1].uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR ) + if ( playerPtr->HasItemEquipped(EQUIP_ARMOUR) + && playerPtr->pInventoryItemList[playerPtr->pEquipment.uArmor-1].uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR ) dmgToReceive >>= 1; - if ( v45->HasItemEquipped(EQUIP_MAIN_HAND)) + if ( playerPtr->HasItemEquipped(EQUIP_MAIN_HAND)) { - v48 = v45->pInventoryItemList[v45->pEquipment.uMainHand - 1].uItemID; - if ( v48 == ITEM_RELIC_KELEBRIM || v48 == ITEM_ARTIFACT_ELFBANE || (v45->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) + int itemId = playerPtr->pInventoryItemList[playerPtr->pEquipment.uMainHand - 1].uItemID; + if ( itemId == ITEM_RELIC_KELEBRIM || itemId == ITEM_ARTIFACT_ELFBANE || (playerPtr->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) dmgToReceive >>= 1; } - if ( v45->HasItemEquipped(EQUIP_OFF_HAND)) + if ( playerPtr->HasItemEquipped(EQUIP_OFF_HAND)) { - v48 = v45->pInventoryItemList[v45->pEquipment.uShield - 1].uItemID; - if ( v48 == ITEM_RELIC_KELEBRIM || v48 == ITEM_ARTIFACT_ELFBANE || (v45->GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) + int itemId = playerPtr->pInventoryItemList[playerPtr->pEquipment.uShield - 1].uItemID; + if ( itemId == ITEM_RELIC_KELEBRIM || itemId == ITEM_ARTIFACT_ELFBANE || (playerPtr->GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) dmgToReceive >>= 1; } } if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) { - v49 = actorPtr->pActorBuffs[3].uPower; - if ( v49 ) - dmgToReceive /= (signed int)v49; - } - switch(v74) + int spellPower = actorPtr->pActorBuffs[3].uPower; + if ( spellPower ) + dmgToReceive /= (signed int)spellPower; + } + int damageType; + switch(element) { case 0: - v50 = actorPtr->pMonsterInfo.uAttack1Type; + damageType = actorPtr->pMonsterInfo.uAttack1Type; break; case 1: - v50 = actorPtr->pMonsterInfo.uAttack2Type; + damageType = actorPtr->pMonsterInfo.uAttack2Type; break; case 2: - v53 = actorPtr->pMonsterInfo.uSpell1ID; - v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool); + spellId = actorPtr->pMonsterInfo.uSpell1ID; + damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; case 3: - v53 = actorPtr->pMonsterInfo.uSpell2ID; - v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool); + spellId = actorPtr->pMonsterInfo.uSpell2ID; + damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); break; case 4: - v50 = actorPtr->pMonsterInfo.field_3C_some_special_attack; + damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; break; case 5: - v50 = 4; + damageType = 4; break; } if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { - v54 = v45->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)v50); - if ( v45->pPlayerBuffs[10].uExpireTime > 0 ) + int reflectedDmg = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); + if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) { - v55 = actorPtr->uAIState; - if ( v55 != Dying && v55 != Dead) + unsigned __int16 actorState = actorPtr->uAIState; + if ( actorState != Dying && actorState != Dead) { - recvdMagicDmg = stru_50C198.CalcMagicalDamageToActor(actorPtr, v50, v54); + recvdMagicDmg = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, reflectedDmg); actorPtr->sCurrentHP -= recvdMagicDmg; if ( recvdMagicDmg >= 0 ) { @@ -7792,37 +7668,37 @@ { if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) { - v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; - pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)v57, 0, 0); + int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius; + pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0); } Actor::Die(uActorID); Actor::ApplyFineForKillingPeasant(uActorID); Actor::AggroSurroundingPeasants(uActorID, 1); if ( actorPtr->pMonsterInfo.uExp ) GivePartyExp(pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].uExp); - v64 = SPEECH_51; + int speechToPlay = SPEECH_51; if ( rand() % 100 < 20 ) - v64 = ((signed int)actorPtr->pMonsterInfo.uHP >= 100) + 1; - v45->PlaySound((PlayerSpeech)v64, 0); + speechToPlay = actorPtr->pMonsterInfo.uHP >= 100 ? 2 : 1; + playerPtr->PlaySound((PlayerSpeech)speechToPlay, 0); } } } } } - if ( !v74 + if ( !element && !(dword_6BE368_debug_settings_2 & 0x10) - && actorPtr->pMonsterInfo.uSpecialAttack - && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackType ) - { - v45->_48DCF6(actorPtr->pMonsterInfo.uSpecialAttack, actorPtr); + && actorPtr->pMonsterInfo.uSpecialAttackType + && rand() % 100 < actorPtr->pMonsterInfo.uLevel * actorPtr->pMonsterInfo.uSpecialAttackLevel ) + { + playerPtr->ReceiveSpecialAttackEffect(actorPtr->pMonsterInfo.uSpecialAttackType, actorPtr); } if ( !pParty->bTurnBasedModeOn ) { - v65 = v45->GetActualEndurance(); - v66 = (int)((20 - v45->GetParameterBonus(v65)) + int actEnd = playerPtr->GetActualEndurance(); + int recTime = (int)((20 - playerPtr->GetParameterBonus(actEnd)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333); - v45->SetRecoveryTime(v66); + playerPtr->SetRecoveryTime(recTime); } return; } @@ -7833,105 +7709,109 @@ } } //----- (00421EA6) -------------------------------------------------------- -void OnInventoryLeftClick() -{ - Player *v0; // ebx@1 - signed int v1; // eax@2 +void Player::OnInventoryLeftClick() +{ signed int v2; // ecx@2 int v3; // eax@2 - char v4; // sf@2 - int v5; // eax@2 + int invMatrixIndex; // eax@2 unsigned int v6; // eax@7 - unsigned int v7; // esi@12 - unsigned int v8; // eax@12 + unsigned int pickedItemId; // esi@12 + unsigned int invItemIndex; // eax@12 unsigned int v9; // eax@16 unsigned int v10; // eax@18 - ItemGen this_; // [sp+Ch] [bp-3Ch]@1 + ItemGen tmpItem; // [sp+Ch] [bp-3Ch]@1 POINT a2; // [sp+30h] [bp-18h]@4 - unsigned int v13; // [sp+38h] [bp-10h]@13 unsigned int pY; // [sp+3Ch] [bp-Ch]@2 unsigned int pX; // [sp+40h] [bp-8h]@2 - int a4; // [sp+44h] [bp-4h]@2 - - v0 = pPlayers[uActiveCharacter]; + if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) { pMouse->GetClickPos(&pX, &pY); - pY = pY - 17; - v2 =pX - 14; - pX = v2; - v3 = 14 * (pY >> 5); - v2 >>= 5; - v4 = v2 + v3 < 0; - v5 = v2 + v3; - a4 = v5; - if ( !v4 ) - { - if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462 + v3 = Player::INVETORYSLOTSWIDTH * ((pY - 17) / 32); + v2 = (pX - 14) / 32; + invMatrixIndex = v2 + v3; + if ( v2 + v3 >= 0 ) + { + if ( invMatrixIndex <= 126 && pMouse->GetCursorPos(&a2)->x < 462 && pMouse->GetCursorPos(&a2)->x >= 14 ) { - if ( unk_50C9A0 ) + if ( _50C9A0_IsEnchantingInProgress ) { - v6 = v0->GetItemIDAtInventoryIndex(&a4); + v6 = this->GetItemIDAtInventoryIndex(&invMatrixIndex); if ( v6 ) { *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; - *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; - ptr_50C9A4 = (ItemGen *)&v0->pInventoryItemList[v6-1]; - unk_50C9A0 = 0; + *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex; + ptr_50C9A4_ItemToEnchant = &this->pInventoryItemList[v6-1]; + _50C9A0_IsEnchantingInProgress = 0; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pMouse->SetCursorBitmap("MICON1"); - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 256; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 256; } return; } - if ( ptr_50C9A4 ) + if ( ptr_50C9A4_ItemToEnchant ) return; - v7 = pParty->pPickedItem.uItemID; - v8 = v0->GetItemIDAtInventoryIndex(&a4); - if ( !v7 ) + pickedItemId = pParty->pPickedItem.uItemID; + invItemIndex = this->GetItemIDAtInventoryIndex(&invMatrixIndex); + if (!pickedItemId) { - if ( !v8 ) + if ( !invItemIndex ) return; - memcpy(&pParty->pPickedItem, &v0->pInventoryItemList[v8-1], sizeof(pParty->pPickedItem)); - v0->RemoveItemAtInventoryIndex(a4); - v9 = pParty->pPickedItem.uItemID; - pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); - return; + else + { + memcpy(&pParty->pPickedItem, &this->pInventoryItemList[invItemIndex-1], sizeof(pParty->pPickedItem)); + this->RemoveItemAtInventoryIndex(invMatrixIndex); + v9 = pParty->pPickedItem.uItemID; + pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); + return; + } } - v13 = v8; - if ( v8 ) + else { - a2.y = (LONG)&v0->pInventoryItemList[v8-1]; - memcpy(&this_, (const void *)a2.y, sizeof(this_)); - v0->RemoveItemAtInventoryIndex(a4); - pX = v0->AddItem2(a4, &pParty->pPickedItem); - if ( !pX ) + if ( invItemIndex ) { - pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); - if ( !pX ) + ItemGen* invItemPtr = &this->pInventoryItemList[invItemIndex-1]; + memcpy(&tmpItem, invItemPtr, sizeof(tmpItem)); + this->RemoveItemAtInventoryIndex(invMatrixIndex); + int emptyIndex = this->AddItem2(invMatrixIndex, &pParty->pPickedItem); + if ( !emptyIndex ) { - v0->PutItemArInventoryIndex(this_.uItemID, v13 - 1, a4); - memcpy((void *)a2.y, &this_, sizeof(ItemGen)); + emptyIndex = this->AddItem2(-1, &pParty->pPickedItem); + if ( !emptyIndex ) + { + this->PutItemArInventoryIndex(tmpItem.uItemID, invItemIndex - 1, invMatrixIndex); + memcpy(invItemPtr, &tmpItem, sizeof(ItemGen)); + return; + } + } + v9 = tmpItem.uItemID; + memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); + pMouse->SetCursorBitmap(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName); + return; + } + else + { + v10 = this->AddItem(invMatrixIndex, pickedItemId); + if ( v10 ) + { + memcpy(&this->pInventoryItemList[v10-1], &pParty->pPickedItem, sizeof(ItemGen)); + pMouse->RemoveHoldingItem(); + return; + } + v10 = this->AddItem(-1, pickedItemId); + if ( v10 ) + { + memcpy(&this->pInventoryItemList[v10-1], &pParty->pPickedItem, sizeof(ItemGen)); + pMouse->RemoveHoldingItem(); return; } } - v9 = this_.uItemID; - memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); - pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); - return; - } - v10 = v0->AddItem(a4, v7); - pX = v10; - if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) - { - memcpy(&v0->pInventoryItemList[v10-1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); } } } @@ -7984,6 +7864,11 @@ return pConditions[Condition_Paralyzed] != 0; } +bool Player::IsDrunk() +{ + return pConditions[Condition_Drunk] != 0; +} + void Player::SetCursed( bool state ) { pConditions[Condition_Cursed] = state; diff -r ffef0fe0b59d -r cc1d68c17e19 Player.h --- a/Player.h Mon Sep 23 09:33:13 2013 +0600 +++ b/Player.h Mon Sep 23 09:34:23 2013 +0600 @@ -495,7 +495,7 @@ int GetActualAccuracy(); int GetActualSpeed(); int GetActualLuck(); - int GetActualAttack(int a2); + int GetActualAttack(bool a2); int GetMeleeDamageMinimal(); int GetMeleeDamageMaximal(); int CalculateMeleeDamageTo(bool ignoreSkillBonus, bool ignoreOffhand, unsigned int uTargetActorID); @@ -514,11 +514,11 @@ bool HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex); bool HasEnchantedItemEquipped(int uEnchantment); bool WearsItem(int item_id, ITEM_EQUIP_TYPE equip_type); - bool StealFromShop(struct ItemGen *a2, int a3, int a4, int a5, int *a6); + int StealFromShop( ItemGen *itemToSteal, int a3, int reputation, int a5, int *fineIfFailed); int StealFromActor(unsigned int uActorID, int _steal_perm, int reputation); void Heal(int amount); int ReceiveDamage(signed int amount, DAMAGE_TYPE dmg_type); - int _48DCF6(int a2, struct Actor *pActor); + int ReceiveSpecialAttackEffect(int attType, struct Actor *pActor); unsigned int GetSpellSchool(unsigned int uSpellID); int GetAttackRecoveryTime(bool bRangedAttack); int GetMaxHealth(); @@ -597,6 +597,7 @@ void EquipBody(ITEM_EQUIP_TYPE uEquipType); bool HasUnderwaterSuitEquipped(); bool HasItem(unsigned int uItemID, char a3); + void OnInventoryLeftClick(); unsigned int GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4); int CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice); @@ -612,6 +613,7 @@ bool IsUnconcious(); bool IsAsleep(); bool IsParalyzed(); + bool IsDrunk(); void SetCursed(bool state); void SetWeak(bool state); diff -r ffef0fe0b59d -r cc1d68c17e19 Render.cpp --- a/Render.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Render.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -8717,9 +8717,4 @@ assert(false); break; } -} -//----- (0040DF3D) -------------------------------------------------------- -void CallRenderPresent() -{ - pRenderer->Present(); -} +} \ No newline at end of file diff -r ffef0fe0b59d -r cc1d68c17e19 Spells.cpp --- a/Spells.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/Spells.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -1168,8 +1168,8 @@ { bool result; // eax@2 - __debugbreak(); // refactor - if ( *(&pSpellDatas[0].field_12 + 20 * uSpellID) & 0xC ) + __debugbreak(); // wut is dat? + if ( pSpellDatas[uSpellID].field_12 & 0xC ) result = 1; else result = 0; diff -r ffef0fe0b59d -r cc1d68c17e19 TurnEngine.cpp --- a/TurnEngine.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/TurnEngine.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -545,8 +545,8 @@ } //----- (004063A1) -------------------------------------------------------- - int stru262_TurnBased::StepTurnQueue() - { + bool stru262_TurnBased::StepTurnQueue() + { int v9; // dx@12 int j; @@ -564,7 +564,7 @@ } --turn_initiative; if (turn_initiative == 0) - return 1; + return true; } while (pQueue[0].actor_initiative != 0); } @@ -586,14 +586,14 @@ } --turn_initiative; if (turn_initiative == 0) - return 1; + return true; } while (pQueue[0].actor_initiative > 0); } } } } - return 0; + return false; } //----- (00406457) -------------------------------------------------------- diff -r ffef0fe0b59d -r cc1d68c17e19 TurnEngine.h --- a/TurnEngine.h Mon Sep 23 09:33:13 2013 +0600 +++ b/TurnEngine.h Mon Sep 23 09:34:23 2013 +0600 @@ -54,14 +54,14 @@ pending_actions = 0; } - void SortTurnQueue(); + void SortTurnQueue(); void ApplyPlayerAction(); - void Start(); + void Start(); void End(bool bPlaySound); void AITurnBasedAction(); void StartTurn(); void NextTurn(); - int StepTurnQueue(); + bool StepTurnQueue(); void _406457(int a2); void SetAIRecoveryTimes(); void _4065B0(); diff -r ffef0fe0b59d -r cc1d68c17e19 UI/UICharacter.cpp --- a/UI/UICharacter.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/UI/UICharacter.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -819,7 +819,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -863,7 +863,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), @@ -924,7 +924,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -989,7 +989,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][0]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1051,7 +1051,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v59), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1120,7 +1120,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v75), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1208,7 +1208,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v94), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1251,7 +1251,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1314,7 +1314,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1377,7 +1377,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v127), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1435,7 +1435,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1507,7 +1507,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v153), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1584,7 +1584,7 @@ { _50C9A8_item_enchantment_timer = 0; LOBYTE(player->pInventoryItemList[player->pInventoryMatrix[i] - 1].uAttributes) &= 0xF; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(uCellX, uCellY, pTexture, pTexture, GetTickCount() * 0.1, 0, 255); ZBuffer_Fill(&pRenderer->pActiveZBuffer[v17], item_texture_id, player->pInventoryMatrix[i]); @@ -1626,7 +1626,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0F; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } pRenderer->DrawAura(x, y, item_texture, enchantment_texture, GetTickCount() * 0.1, 0, 255); } @@ -2109,7 +2109,7 @@ pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += 2 * LOBYTE(pFontArrus->uFontHeight); - sprintf(pTmpBuf.data(), "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], player->GetActualAttack(0)); + sprintf(pTmpBuf.data(), "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], player->GetActualAttack(false)); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; @@ -2682,27 +2682,27 @@ } WetsuitOff(uActiveCharacter); } - if ( unk_50C9A0 )// + if ( _50C9A0_IsEnchantingInProgress )// { *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;//CastSpellInfo *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36; *((short *)pGUIWindow_Settings->ptr_1C + 3) = pEquipType; - ptr_50C9A4 = v38; - unk_50C9A0 = 0; + ptr_50C9A4_ItemToEnchant = v38; + _50C9A0_IsEnchantingInProgress = 0; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pMouse->SetCursorBitmap("MICON1"); - dword_50C9D4 = 0; - dword_50C9D0 = 113; - dword_50C9D8 = 256; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D8_AfterEnchClickEventTimeout = 256; } else { - if ( !ptr_50C9A4 )// + if ( !ptr_50C9A4_ItemToEnchant )// { pParty->SetHoldingItem(v38); - *(&pPlayers[uActiveCharacter]->uBirthYear + pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor) = 0;// pPlayers[uActiveCharacter]->pEquipment[pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor] + pPlayers[uActiveCharacter]->pEquipment.pIndices[pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor - 1] = 0; v38->Reset(); } } diff -r ffef0fe0b59d -r cc1d68c17e19 UI/UIPopup.cpp --- a/UI/UIPopup.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/UI/UIPopup.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -106,61 +106,17 @@ //----- (0041D895) -------------------------------------------------------- void GameUI_DrawItemInfo( struct ItemGen* inspect_item ) - { - ItemGen *v1; // esi@1 +{ unsigned int v2; // eax@3 - signed int v6; // eax@5 - int v7; // edx@5 - char v10; // zf@16 - ItemGen *v11; // eax@16 - ItemGen *v12; // eax@25 - const char *v16; // eax@34 - int v17; // eax@36 - int v18; // esi@37 - unsigned __int16 v19; // ax@37 - char v21; // al@44 - int v24; // eax@52 - int v25; // eax@57 - int v26; // eax@60 - int v27; // eax@67 const char *v28; // edi@69 - int v29; // eax@70 - char v30; // edi@78 - const char *v31; // eax@78 - int v32; // ecx@81 - unsigned int v33; // eax@81 int v34; // esi@81 - const char *v35; // eax@85 - const char *v36; // eax@87 - unsigned int v37; // eax@109 - unsigned int v38; // eax@109 - int v39; // eax@113 - GUIFont *v40; // edx@113 - signed int v41; // [sp-20h] [bp-298h]@113 - int v42; // [sp-1Ch] [bp-294h]@113 - unsigned int v44; // [sp-18h] [bp-290h]@113 - const char *v46; // [sp-14h] [bp-28Ch]@58 - char *v47; // [sp-14h] [bp-28Ch]@110 - const char *v49; // [sp-10h] [bp-288h]@56 - char *v50; // [sp-10h] [bp-288h]@58 - int v51; // [sp-10h] [bp-288h]@110 - const char *v52; // [sp-Ch] [bp-284h]@36 - char *v54; // [sp-Ch] [bp-284h]@56 - int v55; // [sp-Ch] [bp-284h]@58 - int v56; // [sp-Ch] [bp-284h]@110 - unsigned int v57; // [sp-8h] [bp-280h]@36 - int v59; // [sp-8h] [bp-280h]@56 - int v60; // [sp-8h] [bp-280h]@58 - unsigned int v61; // [sp-8h] [bp-280h]@110 + char *pText; // [sp-14h] [bp-28Ch]@110 char out_text[300]; // [sp+8h] [bp-270h]@40 char v65[120]; // [sp+134h] [bp-144h]@92 - char Source[40]; // [sp+1ACh] [bp-CCh]@49 stru351_summoned_item v67; - int var88; // [sp+1F0h] [bp-88h]@1 - Texture *v73; // [sp+1F4h] [bp-84h]@5 int v77; // [sp+200h] [bp-78h]@12 int v78; // [sp+204h] [bp-74h]@5 - GUIWindow wHintWindow; // [sp+208h] [bp-70h]@2 + GUIWindow iteminfo_window; // [sp+208h] [bp-70h]@2 POINT a2; // [sp+25Ch] [bp-1Ch]@2 int v81; // [sp+264h] [bp-14h]@5 PlayerSpeech v83; // [sp+26Ch] [bp-Ch]@18 @@ -168,175 +124,146 @@ int v85; char *Str; // [sp+270h] [bp-8h]@65 - v1 = inspect_item; - var88 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - if (!inspect_item->uItemID) - return; - - wHintWindow.Hint = 0; - wHintWindow.uFrameWidth = 384; - wHintWindow.uFrameHeight = 180; - wHintWindow.uFrameY = 40; - if ( pMouse->GetCursorPos(&a2)->x <= 320 ) - v2 = pMouse->GetCursorPos(&a2)->x + 30; - else - v2 = pMouse->GetCursorPos(&a2)->x - wHintWindow.uFrameWidth - 30; - wHintWindow.uFrameX = v2; - auto item_desc = &pItemsTable->pItems[inspect_item->uItemID]; - //v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName; - //v76 = v3; - //v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[_this->uItemID].pIconName, TEXTURE_16BIT_PALETTE); - //v5 = v4; - //v4 *= 72; - //v75 = v4; - //v73 = &pIcons_LOD->pTextures[v4]; - v73 = pIcons_LOD->LoadTexturePtr(item_desc->pIconName, TEXTURE_16BIT_PALETTE); - v6 = 100 - v73->uTextureWidth; - v7 = v73->uTextureHeight; - v78 = v6; - v81 = 144 - v7; - if ( v6 > 0 ) - v78 = v6 >> 1; - if ( v81 <= 0 ) - v81 = 0; - else - v81 >>= 1; - if ( !item_desc->uItemID_Rep_St ) + if (!inspect_item->uItemID) + return; + iteminfo_window.Hint = 0; + iteminfo_window.uFrameWidth = 384; + iteminfo_window.uFrameHeight = 180; + iteminfo_window.uFrameY = 40; + if ( pMouse->GetCursorPos(&a2)->x <= 320 ) + v2 = pMouse->GetCursorPos(&a2)->x + 30; + else + v2 = pMouse->GetCursorPos(&a2)->x - iteminfo_window.uFrameWidth - 30; + iteminfo_window.uFrameX = v2; + v78 = 100 - pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->uTextureWidth; + v81 = 144 - pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->uTextureHeight; + if ( v78 > 0 ) + v78 = v78 / 2; + if ( v81 <= 0 ) + v81 = 0; + else + v81 = v81 / 2; + if ( !pItemsTable->pItems[inspect_item->uItemID].uItemID_Rep_St ) + inspect_item->SetIdentified(); + v77 = 0; + if (pItemsTable->pItems[inspect_item->uItemID].uEquipType == EQUIP_GOLD) + v77 = inspect_item->uSpecEnchantmentType; + if ( uActiveCharacter ) + { + //try to identify + if (!inspect_item->IsIdentified()) + { + //v11 = inspect_item; + if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 ) inspect_item->SetIdentified(); - //v9 = v8->uAttributes; - v77 = 0; - //a2.y = v8->uAttributes & 2; - if (pItemsTable->pItems[inspect_item->uItemID].uEquipType == EQUIP_GOLD) - v77 = inspect_item->uSpecEnchantmentType; - if ( uActiveCharacter ) - { - //try to identify - if (!inspect_item->IsIdentified()) - { - - v11 = inspect_item; - if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 ) - inspect_item->SetIdentified(); - v83 = SPEECH_9; - if ( !inspect_item->IsIdentified() ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);//"Identify Failed" - } - else - { - v83 = SPEECH_8; - if ( inspect_item->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) ) - v83 = SPEECH_7; - } - if ( dword_4E455C ) - { - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0); - dword_4E455C = 0; - } - } - inspect_item->UpdateTempBonus(pParty->uTimePlayed); - if (inspect_item->IsBroken()) - { - if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 ) - inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1; - v83 = SPEECH_11; - if ( !inspect_item->IsBroken() ) - v83 = SPEECH_10; - else - ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);//"Repair Failed" - if ( dword_4E455C ) - { - pPlayers[uActiveCharacter]->PlaySound(v83, 0); - dword_4E455C = 0; - } - } - } - //v13 = _this->uAttributes; - //v14 = _this->Identified(); - //a2.y = inspect_item->Identified(); + v83 = SPEECH_9; + if ( !inspect_item->IsIdentified() ) + ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2);//"Identify Failed" + else + { + v83 = SPEECH_8; + if ( inspect_item->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) ) + v83 = SPEECH_7; + } + if ( dword_4E455C ) + { + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0); + dword_4E455C = 0; + } + } + inspect_item->UpdateTempBonus(pParty->uTimePlayed); if (inspect_item->IsBroken()) - { - wHintWindow.DrawMessageBox(0); - //v15 = &; - pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12, - wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, - wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12); - wHintWindow.uFrameWidth -= 24; - wHintWindow.uFrameHeight -= 12; - wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; - wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; - pRenderer->DrawTransparentRedShade(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73); - if ( inspect_item->IsIdentified()) - v16 = inspect_item->GetIdentifiedName(); - else - v16 = item_desc->pUnidentifiedName; - wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u); - v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &wHintWindow, 0, 0); //"Broken Item" - v18 = v17 >> 1; - v19 = TargetColor(0xFFu, 0x19u, 0x19u); - wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item" - pRenderer->ResetTextureClipRect(); - if ( !areWeLoadingTexture ) - { - v73->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return; - } - if (!inspect_item->IsIdentified()) - { - wHintWindow.DrawMessageBox(0); - pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12, - wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, - wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12); - wHintWindow.uFrameWidth -= 24; - wHintWindow.uFrameHeight -= 12; - wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; - wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; - pRenderer->DrawTextureTransparent(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73); - wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u); - v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &wHintWindow, 0, 0); ///"Not Identified" - v18 = v17 >> 1; - v19 = TargetColor(0xFFu, 0x19u, 0x19u); - wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3); - pRenderer->ResetTextureClipRect(); - if ( !areWeLoadingTexture ) - { - v73->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return; - } - - sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName); //"Type: %s" - out_text[100] = 0; - out_text[200] = 0; - //v20 = item_desc->uEquipType; - switch (item_desc->uEquipType) - { + { + if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 ) + inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1; + v83 = SPEECH_11; + if ( !inspect_item->IsBroken() ) + v83 = SPEECH_10; + else + ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2);//"Repair Failed" + if ( dword_4E455C ) + { + pPlayers[uActiveCharacter]->PlaySound(v83, 0); + dword_4E455C = 0; + } + } + } + if (inspect_item->IsBroken()) + { + iteminfo_window.DrawMessageBox(0); + pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12, + iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, + iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12); + iteminfo_window.uFrameWidth -= 24; + iteminfo_window.uFrameHeight -= 12; + iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1; + iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1; + pRenderer->DrawTransparentRedShade(iteminfo_window.uFrameX + v78, v81 + iteminfo_window.uFrameY + 30, pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)); + if ( inspect_item->IsIdentified()) + pText = (char *)inspect_item->GetIdentifiedName(); + else + pText = pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName; + iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pText, 3); + iteminfo_window.DrawTitleText(pFontArrus, 0x64u, ((signed int)iteminfo_window.uFrameHeight >> 1) - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &iteminfo_window, 0, 0) / 2, + TargetColor(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item" + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } + if (!inspect_item->IsIdentified()) + { + iteminfo_window.DrawMessageBox(0); + pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12, + iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12); + iteminfo_window.uFrameWidth -= 24; + iteminfo_window.uFrameHeight -= 12; + iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1; + iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1; + pRenderer->DrawTextureTransparent(iteminfo_window.uFrameX + v78, v81 + iteminfo_window.uFrameY + 30, pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)); + iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName, 3); + iteminfo_window.DrawTitleText(pFontArrus, 0x64u, ((signed int)iteminfo_window.uFrameHeight >> 1) - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &iteminfo_window, 0, 0) / 2, + TargetColor(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[232], 3);//"Not Identified" + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } + sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName); //"Type: %s" + out_text[100] = 0; + out_text[200] = 0; + switch (pItemsTable->pItems[inspect_item->uItemID].uEquipType) + { case EQUIP_OFF_HAND: case EQUIP_MAIN_HAND: - sprintfex(out_text + 100, "%s: +%d %s: %dd%d", pGlobalTXT_LocalizationStrings[LOCSTR_ATTACK], - (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll); //"Damage" - if (item_desc->uDamageMod) - { - char mod[16]; - sprintf(mod, "+%d", (int)item_desc->uDamageMod); - strcat(out_text + 100, mod); - } - break; + sprintfex(out_text + 100, "%s: +%d %s: %dd%d", pGlobalTXT_LocalizationStrings[LOCSTR_ATTACK], + (int)pItemsTable->pItems[inspect_item->uItemID].uDamageMod, pGlobalTXT_LocalizationStrings[53], + (int)pItemsTable->pItems[inspect_item->uItemID].uDamageDice, (int)pItemsTable->pItems[inspect_item->uItemID].uDamageRoll); //"Damage" + if (pItemsTable->pItems[inspect_item->uItemID].uDamageMod) + { + char mod[16]; + sprintf(mod, "+%d", (int)pItemsTable->pItems[inspect_item->uItemID].uDamageMod); + strcat(out_text + 100, mod); + } + break; case EQUIP_BOW: - sprintfex(out_text + 100, "%s: +%d %s: %dd%d", pGlobalTXT_LocalizationStrings[203], //"Shoot" - (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], //"Damage" - (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll); - if (item_desc->uDamageMod) - { - char mod[16]; - sprintf(mod, "+%d", (int)item_desc->uDamageMod); - strcat(out_text + 100, mod); - } - break; + sprintfex(out_text + 100, "%s: +%d %s: %dd%d", pGlobalTXT_LocalizationStrings[203], //"Shoot" + (int)pItemsTable->pItems[inspect_item->uItemID].uDamageMod, pGlobalTXT_LocalizationStrings[53], //"Damage" + (int)pItemsTable->pItems[inspect_item->uItemID].uDamageDice, (int)pItemsTable->pItems[inspect_item->uItemID].uDamageRoll); + if (pItemsTable->pItems[inspect_item->uItemID].uDamageMod) + { + char mod[16]; + sprintf(mod, "+%d", (int)pItemsTable->pItems[inspect_item->uItemID].uDamageMod); + strcat(out_text + 100, mod); + } + break; case EQUIP_ARMOUR: case EQUIP_SHIELD: @@ -347,260 +274,179 @@ case EQUIP_BOOTS: case EQUIP_RING: case EQUIP_AMULET: - if (item_desc->uDamageDice) //"Armor" - sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod); - break; - - } - - if ( !v77 ) - { - if (item_desc->uEquipType ==EQUIP_POTION) //this is CORRECT! do not move to switch! - { - if ( inspect_item->uEnchantmentType ) - sprintf(out_text + 200, "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power" - } - else if (item_desc->uEquipType == EQUIP_REAGENT) - { - sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power" - } - - else if ( inspect_item->uEnchantmentType ) - { - sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], - pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->m_enchantmentStrength); //"Special" - } - else if ( inspect_item->uSpecEnchantmentType ) - { - sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], - pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->m_enchantmentStrength); - } - - else if ( inspect_item->uNumCharges ) - { - sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges" + if (pItemsTable->pItems[inspect_item->uItemID].uDamageDice) //"Armor" + sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], + pItemsTable->pItems[inspect_item->uItemID].uDamageDice + pItemsTable->pItems[inspect_item->uItemID].uDamageMod); + break; + } - } - } - wHintWindow.uFrameWidth -= 12; - v85 = 3; - wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; - wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; - Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8)); - v84 = &out_text[0]; - do - { - if ( *v84 ) - { - v27 = pFontComic->CalcTextHeight(v84, &wHintWindow, 100, 0); - Str += v27 + 3; - } - v84 += 100; - --v85; - } - while ( v85 ); - v28 = item_desc->pDescription; - if ( *v28 ) - { - v29 = pFontSmallnum->CalcTextHeight(v28, &wHintWindow, 100, 0); - Str += v29; - } - wHintWindow.uFrameHeight = v73->uTextureHeight + v81 + 54; - if ( (signed int)Str > (signed int)wHintWindow.uFrameHeight ) - wHintWindow.uFrameHeight = (unsigned int)Str; - if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) ) - wHintWindow.uFrameHeight += LOBYTE(pFontComic->uFontHeight); - v85 = 0; - if ( pFontArrus->uFontHeight ) - { - wHintWindow.uFrameWidth -= 24; - v30 = pFontArrus->uFontHeight; - v31 = inspect_item->GetIdentifiedName(); - if ( pFontArrus->CalcTextHeight(v31, &wHintWindow, 0, 0) / (signed int)v30 ) - v85 = v30; - wHintWindow.uFrameWidth += 24; - } - wHintWindow.uFrameWidth += 12; - wHintWindow.uFrameHeight += (unsigned int)v85; - wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; - wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; - wHintWindow.DrawMessageBox(0); - //v15 = pRenderer; - pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12, - wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12); - wHintWindow.uFrameWidth -= 12; - v32 = v73->uTextureHeight; - v33 = wHintWindow.uFrameHeight; - wHintWindow.uFrameHeight -= 12; - wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; - wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; - pRenderer->DrawTextureTransparent( - wHintWindow.uFrameX + v78, - wHintWindow.uFrameY + (signed int)(v33 - v32) / 2, - v73); + if ( !v77 ) + { + if (pItemsTable->pItems[inspect_item->uItemID].uEquipType ==EQUIP_POTION) //this is CORRECT! do not move to switch! + { + if ( inspect_item->uEnchantmentType ) + sprintf(out_text + 200, "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power" + } + else if (pItemsTable->pItems[inspect_item->uItemID].uEquipType == EQUIP_REAGENT) + sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power" + else if ( inspect_item->uEnchantmentType ) + sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->m_enchantmentStrength); //"Special" + else if ( inspect_item->uSpecEnchantmentType ) + sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->m_enchantmentStrength); + else if ( inspect_item->uNumCharges ) + sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges" + } + iteminfo_window.uFrameWidth -= 12; + iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1; + iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1; + Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8)); + v84 = &out_text[0]; + for ( uint i = 1; i <= 3; i++ ) + { + if ( *v84 ) + Str += pFontComic->CalcTextHeight(v84, &iteminfo_window, 100, 0) + 3; + v84 += 100; + } + v28 = pItemsTable->pItems[inspect_item->uItemID].pDescription; + if ( *v28 ) + Str += pFontSmallnum->CalcTextHeight(pItemsTable->pItems[inspect_item->uItemID].pDescription, &iteminfo_window, 100, 0); + iteminfo_window.uFrameHeight = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, + TEXTURE_16BIT_PALETTE)->uTextureHeight + v81 + 54; + if ( (signed int)Str > (signed int)iteminfo_window.uFrameHeight ) + iteminfo_window.uFrameHeight = (unsigned int)Str; + if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) ) + iteminfo_window.uFrameHeight += LOBYTE(pFontComic->uFontHeight); + v85 = 0; + if ( pFontArrus->uFontHeight ) + { + iteminfo_window.uFrameWidth -= 24; + if ( pFontArrus->CalcTextHeight(inspect_item->GetIdentifiedName(), &iteminfo_window, 0, 0) / (signed int)pFontArrus->uFontHeight ) + v85 = pFontArrus->uFontHeight; + iteminfo_window.uFrameWidth += 24; + } + iteminfo_window.uFrameWidth += 12; + iteminfo_window.uFrameHeight += (unsigned int)v85; + iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1; + iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1; + iteminfo_window.DrawMessageBox(0); + pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12, + iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12); + iteminfo_window.uFrameWidth -= 12; + //v32 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->uTextureHeight; + iteminfo_window.uFrameHeight -= 12; + iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1; + iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1; + pRenderer->DrawTextureTransparent(iteminfo_window.uFrameX + v78, + iteminfo_window.uFrameY + (signed int)(iteminfo_window.uFrameHeight - pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->uTextureHeight) / 2, + pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)); - v34 = (int)(v85 + 35); - v85 = 3; - Str = out_text; - do - { - if ( *Str ) - { - wHintWindow.DrawText(pFontComic, 100, v34, 0, Str, 0, 0, 0); - v34 += pFontComic->CalcTextHeight(Str, &wHintWindow, 100, 0) + 3; - } - Str += 100; - --v85; - } - while (v85 ); - v35 = item_desc->pDescription; - if ( *v35 ) - wHintWindow.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0); - wHintWindow.uFrameX += 12; - wHintWindow.uFrameWidth -= 24; - v36 = inspect_item->GetIdentifiedName(); - wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u); - wHintWindow.uFrameWidth += 24; - wHintWindow.uFrameX -= 12; - if ( v77 ) - { - sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value" - v40 = pFontComic; - v61 = 0; - v56 = 0; - v51 = 0; - v47 = pTmpBuf.data(); - v44 = 0; - v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight); - v41 = 100; - } - else - { - if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) ) - { - init_summoned_item(&v67, inspect_item->uExpireTime - pParty->uTimePlayed); - strcpy(pTmpBuf.data(), "Duration:"); - Str = (char *)(v67.field_18_expire_year - game_starting_year); - if (v67.field_18_expire_year != 1168 ) - { - sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year); - strcat(pTmpBuf.data(), v65); - } - if ( (((v67.field_14_exprie_month || Str) && - ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str) - || v67.field_C_expire_day) - && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || - v67.field_C_expire_day) - || v67.field_8_expire_hour) - && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || - v67.field_C_expire_day || v67.field_8_expire_hour) - || v67.field_4_expire_minute ) - { - sprintf(v65, " %d:mn", v67.field_4_expire_minute); - strcat(pTmpBuf.data(), v65); - } - wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - 2 * LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); - } - v37 = inspect_item->GetValue(); - sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37); - wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); - v38 = inspect_item->uAttributes; - if ( BYTE1(v38) & 1 ) - { - v61 = 0; - v56 = 0; - v51 = 0; - v47 = pGlobalTXT_LocalizationStrings[187]; //"Stolen" - } - else - { - if ( !(BYTE1(v38) & 2) ) - { - pRenderer->ResetTextureClipRect(); - if ( !areWeLoadingTexture ) - { - v73->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return; - } - v61 = 0; - v56 = 0; - v51 = 0; - v47 = pGlobalTXT_LocalizationStrings[651]; //"Hardened" - } - LOWORD(v38) = LOWORD(pRenderer->uTargetRMask); - v44 = v38; - v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight); - v39 = pFontComic->GetLineWidth(pTmpBuf.data()); - v40 = pFontComic; - v41 = v39 + 132; - } - wHintWindow.DrawText(v40, v41, v42, v44, v47, v51, v56, v61); - pRenderer->ResetTextureClipRect(); - if ( !areWeLoadingTexture ) - { - v73->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return; + v34 = (int)(v85 + 35); + Str = out_text; + for ( uint i = 1; i <= 3; i++ ) + { + if ( *Str ) + { + iteminfo_window.DrawText(pFontComic, 100, v34, 0, Str, 0, 0, 0); + v34 += pFontComic->CalcTextHeight(Str, &iteminfo_window, 100, 0) + 3; } + Str += 100; + } + v28 = pItemsTable->pItems[inspect_item->uItemID].pDescription; + if ( *v28 ) + iteminfo_window.DrawText(pFontSmallnum, 100, v34, 0, v28, 0, 0, 0); + iteminfo_window.uFrameX += 12; + iteminfo_window.uFrameWidth -= 24; + iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), inspect_item->GetIdentifiedName(), 3); + iteminfo_window.uFrameWidth += 24; + iteminfo_window.uFrameX -= 12; + if ( v77 ) + { + sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value" + iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); + pRenderer->ResetTextureClipRect(); + } + else + { + if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) ) + { + init_summoned_item(&v67, inspect_item->uExpireTime - pParty->uTimePlayed); + strcpy(pTmpBuf.data(), "Duration:"); + Str = (char *)(v67.field_18_expire_year - game_starting_year); + if (v67.field_18_expire_year != 1168 ) + { + sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year); + strcat(pTmpBuf.data(), v65); + } + if ( (((v67.field_14_exprie_month || Str) && + ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str) + || v67.field_C_expire_day) + && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || + v67.field_C_expire_day) + || v67.field_8_expire_hour) + && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || + v67.field_C_expire_day || v67.field_8_expire_hour) + || v67.field_4_expire_minute ) + { + sprintf(v65, " %d:mn", v67.field_4_expire_minute); + strcat(pTmpBuf.data(), v65); + } + iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - 2 * LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); + } + sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], inspect_item->GetValue()); + iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); + if ( BYTE1(inspect_item->uAttributes) & 1 ) + pText = pGlobalTXT_LocalizationStrings[187]; //"Stolen" + else + { + if ( !(BYTE1(inspect_item->uAttributes) & 2) ) + { + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } + pText = pGlobalTXT_LocalizationStrings[651]; //"Hardened" + } + LOWORD(inspect_item->uAttributes) = LOWORD(pRenderer->uTargetRMask); + iteminfo_window.DrawText(pFontComic, pFontComic->GetLineWidth(pTmpBuf.data()) + 132, + iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), inspect_item->uAttributes, pText, 0, 0, 0); + pRenderer->ResetTextureClipRect(); + } + if ( !areWeLoadingTexture ) + { + pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[inspect_item->uItemID].pIconName, TEXTURE_16BIT_PALETTE)->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; +} // 4E455C: using guessed type int dword_4E455C; // 506128: using guessed type int areWeLoadingTexture; - - //----- (0041E360) -------------------------------------------------------- -void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *edx0) +void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *window) { - unsigned int v2; // esi@1 - Actor *v3; // esi@3 - int v4; // eax@3 - //unsigned int v5; // ecx@3 - NPCData *v6; // eax@3 - unsigned __int16 v7; // cx@3 int v8; // eax@4 unsigned __int16 v9; // dx@4 SpriteFrame *v10; // edi@17 - LODSprite *v11; // esi@17 - unsigned int v12; // ecx@17 - Sprite *v13; // edi@18 - //int v14; // ecx@18 - //int v15; // edx@18 - //int v16; // edx@18 - //int v17; // eax@18 unsigned int v18; // ecx@19 unsigned int v19; // eax@21 char *v20; // esi@28 int v21; // edx@29 unsigned __int16 *v22; // ecx@29 int v23; // eax@29 - int v24; // eax@32 int v25; // esi@32 char *v26; // edx@34 unsigned __int8 v27; // sf@36 unsigned __int8 v28; // of@36 - //int v29; // esi@40 - //unsigned __int16 *v30; // ecx@40 - //int v31; // eax@40 - //int v32; // esi@43 - //unsigned __int16 v33; // ax@45 - //int v34; // edx@45 - //int v35; // eax@45 - int v36; // eax@49 - //char *v37; // eax@52 - int v38; // eax@55 - unsigned __int16 v39; // ax@59 SpellBuff *v40; // eax@60 int v41; // edi@61 unsigned int v42; // eax@61 int v43; // eax@62 int v44; // eax@63 signed int v45; // edi@65 - unsigned __int16 v46; // ax@73 - Player *v47; // ecx@77 - //unsigned int v48; // eax@85 - GUIFont *v49; // edi@90 int v50; // edi@90 SpellBuff *v51; // eax@91 char *v52; // ecx@98 @@ -614,21 +460,16 @@ unsigned __int8 v60; // dl@138 char *v62; // eax@147 int v63; // eax@152 - //char *result; // eax@152 int v65; // eax@155 - const char *v66; // [sp-10h] [bp-1FCh]@121 const char *v67; // [sp-10h] [bp-1FCh]@125 const char *v68; // [sp-10h] [bp-1FCh]@142 - int v69; // [sp-Ch] [bp-1F8h]@121 char *v70; // [sp-Ch] [bp-1F8h]@125 char *v71; // [sp-Ch] [bp-1F8h]@142 char *v72; // [sp-8h] [bp-1F4h]@54 int v73; // [sp-8h] [bp-1F4h]@79 - int v74; // [sp-8h] [bp-1F4h]@121 int v75; // [sp-8h] [bp-1F4h]@125 int v76; // [sp-8h] [bp-1F4h]@142 size_t v77; // [sp-4h] [bp-1F0h]@54 - unsigned int v78; // [sp-4h] [bp-1F0h]@121 unsigned int v79; // [sp-4h] [bp-1F0h]@125 char *v80; // [sp-4h] [bp-1F0h]@142 char *v81; // [sp-4h] [bp-1F0h]@148 @@ -642,25 +483,17 @@ unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34 unsigned int v109; // [sp+1A8h] [bp-44h]@32 LPVOID v110; // [sp+1ACh] [bp-40h]@28 - unsigned int v111; // [sp+1B0h] [bp-3Ch]@29 int v112; // [sp+1B4h] [bp-38h]@3 int v222; // [sp+1B8h] [bp-34h]@18 unsigned __int8 v114; // [sp+1BFh] [bp-2Dh]@133 int v115; // [sp+1C0h] [bp-2Ch]@3 unsigned int v116; // [sp+1C4h] [bp-28h]@18 int i; // [sp+1C8h] [bp-24h]@18 - int a2; // [sp+1CCh] [bp-20h]@28 int v119; // [sp+1D0h] [bp-1Ch]@18 SpellBuff *v120; // [sp+1D4h] [bp-18h]@18 - Actor *v121; // [sp+1D8h] [bp-14h]@3 - int a5; // [sp+1DCh] [bp-10h]@3 - GUIWindow *a1; // [sp+1E0h] [bp-Ch]@1 int v124; // [sp+1E4h] [bp-8h]@18 int a4; // [sp+1E8h] [bp-4h]@18 - a1 = edx0; - v2 = uActorID; - static Actor pMonsterInfoUI_Doll; /*if ( !(bMonsterInfoUI_bDollInitialized & 1) ) { @@ -669,26 +502,15 @@ atexit(nullsub_3); }*/ v106.uParentBillboardID = -1; - v3 = &pActors[v2]; - v121 = v3; - v4 = TargetColor(0xE1u, 255, 0x9Bu); - //v5 = v3->sNPC_ID; - a5 = v4; - v6 = GetNPCData(v3->sNPC_ID); - v7 = v3->pMonsterInfo.uID; - //v112 = (char **)v6; - v115 = monster_popup_y_offsets[((signed __int16)v7 - 1) / 3] - 40; - if ( v7 == pMonsterInfoUI_Doll.pMonsterInfo.uID ) - { + v115 = monster_popup_y_offsets[((signed __int16)pActors[uActorID].pMonsterInfo.uID - 1) / 3] - 40; + if ( pActors[uActorID].pMonsterInfo.uID == pMonsterInfoUI_Doll.pMonsterInfo.uID ) v9 = pMonsterInfoUI_Doll.uCurrentActionLength; - } else { - memcpy(&pMonsterInfoUI_Doll, v3, sizeof(pMonsterInfoUI_Doll)); + memcpy(&pMonsterInfoUI_Doll, &pActors[uActorID], sizeof(pMonsterInfoUI_Doll)); pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Bored; pMonsterInfoUI_Doll.uCurrentActionTime = 0; v8 = rand(); - v3 = v121; v9 = v8 % 256 + 128; pMonsterInfoUI_Doll.uCurrentActionLength = v8 % 256 + 128; } @@ -708,59 +530,44 @@ if ( (pMonsterInfoUI_Doll.pMonsterInfo.uID < 115 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 186) && (pMonsterInfoUI_Doll.pMonsterInfo.uID < 232 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 249) && rand() % 30 < 100 ) pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_AtkMelee; - pMonsterInfoUI_Doll.uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation]].uAnimLength; + pMonsterInfoUI_Doll.uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation]].uAnimLength; } } - v10 = pSpriteFrameTable->GetFrame( v3->pSpriteIDs[pMonsterInfoUI_Doll.uCurrentActionAnimation], pMonsterInfoUI_Doll.uCurrentActionTime); - v11 = &pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]];//40 * v10->pHwSpriteIDs[0] + 7218180; + v10 = pSpriteFrameTable->GetFrame( pActors[uActorID].pSpriteIDs[pMonsterInfoUI_Doll.uCurrentActionAnimation], pMonsterInfoUI_Doll.uCurrentActionTime); v106.pTarget = pRenderer->pTargetSurface; v106.pTargetZ = pRenderer->pActiveZBuffer; v106.uTargetPitch = pRenderer->uTargetSurfacePitch; - v12 = a1->uFrameY + 52; - v106.uViewportX = a1->uFrameX + 13; - v106.uViewportY = v12; - v106.uViewportW = v12 + 128; + v106.uViewportX = window->uFrameX + 13; + v106.uViewportY = window->uFrameY + 52; + v106.uViewportW = (window->uFrameY + 52) + 128; v106.uViewportZ = v106.uViewportX + 128; v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2; v106._screenspace_x_scaler_packedfloat = 65536; v106._screenspace_y_scaler_packedfloat = 65536; - v106.uScreenSpaceY = v115 + v12 + v11->uHeight; + v106.uScreenSpaceY = v115 + (window->uFrameY + 52) + pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].uHeight; v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1); v106.sZValue = 0; v106.uFlags = 0; pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu); - pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, a5); - pRenderer->RasterLine2D( v106.uViewportX + 129, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportW + 1, a5); - pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, a5); - pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, a5); + pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, TargetColor(0xE1u, 255, 0x9Bu)); + pRenderer->RasterLine2D( v106.uViewportX + 129, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportW + 1, TargetColor(0xE1u, 255, 0x9Bu)); + pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, TargetColor(0xE1u, 255, 0x9Bu)); + pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, TargetColor(0xE1u, 255, 0x9Bu)); if ( pRenderer->pRenderD3D ) { - v13 = &pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]]; - v106.uScreenSpaceY = v115 + v106.uViewportY + v13->uBufferHeight; - //v222 = (IDirectDrawSurface *)v13->pTextureSurface; + v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight; memset(&Dst, 0, 0x64u); Dst.dwSize = 100; Dst.dwFillColor = 0; memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - v13->pTextureSurface->GetSurfaceDesc(&pDesc); - //v14 = v13->uBufferHeight; - //v120 = (SpellBuff *)v13->uBufferWidth; + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->GetSurfaceDesc(&pDesc); v107 = 0; - //v15 = v13->uAreaX; - //v119 = v13->uBufferWidth / 2; i = 0; - //a4 = v106.uScreenSpaceX + v15 - v13->uBufferWidth / 2; - int dst_x = v106.uScreenSpaceX + v13->uAreaX - v13->uBufferWidth / 2; - //v115 = v13->uAreaY; - //v16 = v13->uAreaWidth + v13->uBufferWidth / 2 + v13->uAreaX - v13->uBufferWidth; - //v124 = v106.uScreenSpaceY + v115 - v14; - int dst_y = v106.uScreenSpaceY + v13->uAreaY - v13->uBufferHeight; - //v17 = v13->uAreaHeight + v13->uAreaY - v14; - //v116 = v106.uScreenSpaceX + v16; - uint dst_z = v106.uScreenSpaceX + v13->uAreaX + v13->uAreaWidth + v13->uBufferWidth / 2 - v13->uBufferWidth; - //v119 = v106.uScreenSpaceY + v17; - uint dst_w = v106.uScreenSpaceY + v13->uAreaY + v13->uAreaHeight - v13->uBufferHeight; + int dst_x = v106.uScreenSpaceX + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaX - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferWidth / 2; + int dst_y = v106.uScreenSpaceY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaY - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight; + uint dst_z = v106.uScreenSpaceX + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaX + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferWidth / 2 - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferWidth; + uint dst_w = v106.uScreenSpaceY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight - pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight; if (dst_x < v106.uViewportX) { v18 = v106.uViewportX - dst_x; @@ -789,117 +596,105 @@ __debugbreak(); // no monster popup for r5g5b5 yet memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4(v13->pTextureSurface, &pDesc, DDLOCK_WAIT)) - { - v20 = (char *)dst_y; - v110 = pDesc.lpSurface; - a2 = dst_y; - if (dst_y < dst_w) - { - //v111 = 2 * pRenderer->uTargetSurfacePitch; - v21 = dst_x; - v22 = &pRenderer->pTargetSurface[dst_y * pRenderer->uTargetSurfacePitch + dst_x]; - auto _v22_2 = v22; - v23 = i - dst_y; - //v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; - v115 = i - dst_y; - while ( 1 ) - { - dst_y = v21; - if ( v21 < dst_z ) - { - v24 = (int)&v20[v23]; - v25 = v107 - v21; - v109 = v24; - for ( i = v107 - v21; ; v25 = i ) - { - v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight); - v26 = (char *)v108 + pDesc.dwWidth * (v25 + dst_y++) / v13->uAreaWidth; - *v22 = *((short *)v110 + (int)v26); - ++v22; - if ( dst_y >= dst_z ) - break; - } - v23 = v115; - } - v22 = (unsigned __int16 *)((char *)_v22_2 + 2 * pRenderer->uTargetSurfacePitch); - _v22_2 = v22; - v20 = (char *)(a2 + 1); - v28 = __OFSUB__(a2 + 1, dst_w); - v27 = (signed int)(a2++ + 1 - dst_w) < 0; - //a2 = (Player *)((char *)a2 + 1); - //v120 = (SpellBuff *)((char *)v120 + v111); - if ( !(v27 ^ v28) ) - break; - v21 = dst_x; - } - } - v13->pTextureSurface->Unlock(0); - } + if ( pRenderer->LockSurface_DDraw4(pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface, &pDesc, DDLOCK_WAIT)) + { + v20 = (char *)dst_y; + v110 = pDesc.lpSurface; + //a2 = dst_y; + if (dst_y < dst_w) + { + v21 = dst_x; + v22 = &pRenderer->pTargetSurface[dst_y * pRenderer->uTargetSurfacePitch + dst_x]; + auto _v22_2 = v22; + v23 = i - dst_y; + v115 = i - dst_y; + while ( 1 ) + { + dst_y = v21; + if ( v21 < dst_z ) + { + v25 = v107 - v21; + v109 = (int)&v20[v23]; + for ( i = v107 - v21; ; v25 = i ) + { + v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight); + v26 = (char *)v108 + pDesc.dwWidth * (v25 + dst_y++) / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth; + *v22 = *((short *)v110 + (int)v26); + ++v22; + if ( dst_y >= dst_z ) + break; + } + v23 = v115; + } + v22 = (unsigned __int16 *)((char *)_v22_2 + 2 * pRenderer->uTargetSurfacePitch); + _v22_2 = v22; + v20 = (char *)(dst_y + 1); + v28 = __OFSUB__(dst_y + 1, dst_w); + v27 = (signed int)(dst_y++ + 1 - dst_w) < 0; + if ( !(v27 ^ v28) ) + break; + v21 = dst_x; + } + } + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0); + } } - else - { - memset(&pDesc, 0, 0x7Cu); - pDesc.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4(v13->pTextureSurface, &pDesc, DDLOCK_WAIT) ) - { - auto src = (unsigned __int16 *)pDesc.lpSurface; - - uint num_top_scanlines_above_frame_y = i - dst_y; - for (uint y = dst_y; y < dst_w; ++y) - { - auto dst = &pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + dst_x]; + else + { + memset(&pDesc, 0, 0x7Cu); + pDesc.dwSize = 124; + if ( pRenderer->LockSurface_DDraw4(pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface, &pDesc, DDLOCK_WAIT) ) + { + auto src = (unsigned __int16 *)pDesc.lpSurface; + uint num_top_scanlines_above_frame_y = i - dst_y; + for (uint y = dst_y; y < dst_w; ++y) + { + auto dst = &pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + dst_x]; - uint src_y = num_top_scanlines_above_frame_y + y; - for (uint x = dst_x; x < dst_z; ++x) - { - uint src_x = v107 - dst_x + x; // num scanlines left to frame_x + current x + uint src_y = num_top_scanlines_above_frame_y + y; + for (uint x = dst_x; x < dst_z; ++x) + { + uint src_x = v107 - dst_x + x; // num scanlines left to frame_x + current x - uint idx = pDesc.dwHeight * src_y / v13->uAreaHeight * (pDesc.lPitch / sizeof(short)) + - pDesc.dwWidth * src_x / v13->uAreaWidth; - uint b = src[idx] & 0x1F; - *dst++ = b | 2 * (src[idx] & 0xFFE0); - } - } - v13->pTextureSurface->Unlock(0); - } - } + uint idx = pDesc.dwHeight * src_y / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight * (pDesc.lPitch / sizeof(short)) + + pDesc.dwWidth * src_x / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth; + uint b = src[idx] & 0x1F; + *dst++ = b | 2 * (src[idx] & 0xFFE0); + } + } + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0); + } + } } else { pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0); - v36 = v10->pHwSpriteIDs[0]; - if ( v36 >= 0 ) - pSprites_LOD->pSpriteHeaders[v36].DrawSprite_sw(&v106, 0); + if ( v10->pHwSpriteIDs[0] >= 0 ) + pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].DrawSprite_sw(&v106, 0); } - if ( v121->sNPC_ID ) + if ( pActors[uActorID].sNPC_ID ) { - //v37 = v6->uProfession; - if (v6->uProfession) + if (GetNPCData(pActors[uActorID].sNPC_ID)->uProfession) + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], GetNPCData(pActors[uActorID].sNPC_ID)->pName, aNPCProfessionNames[GetNPCData(pActors[uActorID].sNPC_ID)->uProfession]); // "%s the %s" / ^Pi[%s] %s + else { - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v6->uProfession]); // "%s the %s" / ^Pi[%s] %s + v77 = 2000; + v72 = GetNPCData(pActors[uActorID].sNPC_ID)->pName; } - else - { - v77 = 2000; - v72 = v6->pName; - } } else { - v38 = v121->dword_000334_unique_name; v77 = 2000; - if ( v38 ) - v72 = pMonsterStats->pPlaceStrings[v38]; + if ( pActors[uActorID].dword_000334_unique_name ) + v72 = pMonsterStats->pPlaceStrings[pActors[uActorID].dword_000334_unique_name]; else - v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName; + v72 = pMonsterStats->pInfos[pActors[uActorID].pMonsterInfo.uID].pName; } - if(!v121->sNPC_ID || (v121->sNPC_ID && !v6->uProfession)) + if(!pActors[uActorID].sNPC_ID || (pActors[uActorID].sNPC_ID && !GetNPCData(pActors[uActorID].sNPC_ID)->uProfession)) strncpy(pTmpBuf.data(), v72, v77); - v39 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf.data(), 3u); - Actor::DrawHealthBar(v121, a1); + window->DrawTitleText(pFontComic, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); + Actor::DrawHealthBar(&pActors[uActorID], window); v119 = 0; pMonsterInfoUI_Doll.uCurrentActionTime += pMiscTimer->uTimeElapsed; v115 = 0; @@ -907,133 +702,110 @@ i = 0; v112 = 0; if ( !uActiveCharacter ) - { v45 = 1; - } else { - LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); - v120 = v40; - if ( !v40 ) - v45 = 1; - else - { - v41 = (unsigned __int8)v40 & 0x3F; - v42 = SkillToMastery((unsigned __int16)v40) - 1; - if ( !v42 ) - { - if ( v41 + 10 >= v121->pMonsterInfo.uLevel ) - { - v45 = 1; - v119 = 1; - } - else - v45 = 1; - } - else - { - v43 = v42 - 1; - if ( !v43 ) - { - if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel ) - { - v45 = 1; - v119 = 1; - v116 = 1; - } - else - v45 = 1; - } - else - { - v44 = v43 - 1; - if ( !v44 ) - { - if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel ) - { - v45 = 1; - v119 = 1; - v116 = 1; - i = 1; - } - else - { - v45 = 1; - } - } - else - { - if ( v44 != 1 ) - v45 = 1; - else - { - v45 = 1; - v119 = 1; - v116 = 1; - i = 1; - v112 = 1; - } - } - } - } - } - // LABEL_73: - v46 = v121->uAIState; - if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 ) - { - v47 = pPlayers[uActiveCharacter]; - if ( v119 | v116 | i | (unsigned int)v112 ) - { - if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 ) - v73 = SPEECH_105; - else - v73 = SPEECH_104; - } - else - { - v73 = SPEECH_106; - } - v47->PlaySound((PlayerSpeech)v73, 0); - } + LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); + v120 = v40; + if ( !v40 ) + v45 = 1; + else + { + v41 = (unsigned __int8)v40 & 0x3F; + v42 = SkillToMastery((unsigned __int16)v40) - 1; + if ( !v42 ) + { + if ( v41 + 10 >= pActors[uActorID].pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + } + else + v45 = 1; + } + else + { + v43 = v42 - 1; + if ( !v43 ) + { + if ( 2 * v41 + 10 >= pActors[uActorID].pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + v116 = 1; + } + else + v45 = 1; + } + else + { + v44 = v43 - 1; + if ( !v44 ) + { + if ( 3 * v41 + 10 >= pActors[uActorID].pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + v116 = 1; + i = 1; + } + else + v45 = 1; + } + else + { + if ( v44 != 1 ) + v45 = 1; + else + { + v45 = 1; + v119 = 1; + v116 = 1; + i = 1; + v112 = 1; + } + } + } + } + } + if ( pActors[uActorID].uAIState != Dead + && pActors[uActorID].uAIState != Dying + && !dword_507BF0_is_there_popup_onscreen && v120 ) + { + if ( v119 | v116 | i | (unsigned int)v112 ) + { + if ( pActors[uActorID].pMonsterInfo.uLevel >= pPlayers[uActiveCharacter]->uLevel - 5 ) + v73 = SPEECH_105; + else + v73 = SPEECH_104; + } + else + v73 = SPEECH_106; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)v73, 0); + } } - for (uint _it = 0; _it < 4; ++_it) + for (uint i = 0; i < 4; ++i) { - auto player = pParty->pPlayers + _it; - - //LOBYTE(v48) = player->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); - //v111 = v48; - v111 = player->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); v120 = (SpellBuff *)138; do { - if ( (signed int)SkillToMastery(v111) >= 3 ) + if ( (signed int)SkillToMastery(pParty->pPlayers[i].GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID)) >= 3 ) v115 = v45; v120 = (SpellBuff *)((char *)v120 - 1); } while ( v120 ); - //++a2; } - //while ( (signed int)a2 < (signed int)pParty->pHirelings ); - v49 = pFontSmallnum; - a2 = (int)pFontSmallnum; - a1->DrawText(pFontSmallnum, 12, 196, a5, pGlobalTXT_LocalizationStrings[631], 0, 0, 0); - v50 = LOBYTE(v49->uFontHeight) + 193; + window->DrawText(pFontSmallnum, 12, 196, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0); if ( !v115 ) - { - v78 = 0; - v74 = 0; - v69 = 0; - v66 = pGlobalTXT_LocalizationStrings[630]; - a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); - } + window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0); else { a4 = 0; - v51 = &v121->pActorBuffs[1]; + v51 = &pActors[uActorID].pActorBuffs[1]; v222 = 0; - v120 = &v121->pActorBuffs[1]; + v120 = &pActors[uActorID].pActorBuffs[1]; do { if ( (signed __int64)v51->uExpireTime > 0 ) @@ -1137,8 +909,8 @@ { v54 = (char *)a4; v55 = GetSpellColor(v124); - a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0); - v50 = v50 + *(char *)(a2 + 5) - 3; + window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, v55, v54, 0, 0, 0); + v50 = (LOBYTE(pFontSmallnum->uFontHeight) + 193) + *(char *)((int)pFontSmallnum + 5) - 3; v51 = v120; } } @@ -1153,22 +925,16 @@ while (true); if ( !a4 ) - { - v78 = 0; - v74 = 0; - v69 = 0; - v66 = pGlobalTXT_LocalizationStrings[153]; - a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); - } + window->DrawText(pFontSmallnum, 28, v50, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0); } v56 = pFontSmallnum; a4 = v106.uViewportY; if ( v119 ) { - sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, pActors[uActorID].pMonsterInfo.uHP); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); a4 = a4 + LOBYTE(v56->uFontHeight) - 3; - v79 = v121->pMonsterInfo.uAC; + v79 = pActors[uActorID].pMonsterInfo.uAC; v75 = 0; v70 = pGlobalTXT_LocalizationStrings[12]; v67 = "%s\f%05u\t100%d\n"; @@ -1176,7 +942,7 @@ else { sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630]; v75 = 0; v70 = pGlobalTXT_LocalizationStrings[12]; @@ -1184,7 +950,7 @@ v67 = "%s\f%05u\t100%s\n"; } sprintf(pTmpBuf.data(), v67, v70, v75, v79); - a1->DrawText(v56, 150, a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); a4 = a4 + LOBYTE(v56->uFontHeight) - 6 + LOBYTE(v56->uFontHeight); v95[0] = pGlobalTXT_LocalizationStrings[87]; v95[1] = pGlobalTXT_LocalizationStrings[6]; @@ -1199,25 +965,25 @@ v95[10] = pGlobalTXT_LocalizationStrings[54]; if ( v116 ) { - sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, v95[v121->pMonsterInfo.uAttack1Type]); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, v95[pActors[uActorID].pMonsterInfo.uAttack1Type]); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); a4 = a4 + LOBYTE(v56->uFontHeight) - 3; - v57 = v121->pMonsterInfo.uAttack1DamageBonus; + v57 = pActors[uActorID].pMonsterInfo.uAttack1DamageBonus; if ( v57 ) sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53], - 0, v121->pMonsterInfo.uAttack1DamageDiceRolls, v121->pMonsterInfo.uAttack1DamageDiceSides, v57); + 0, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceRolls, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceSides, v57); else sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d\n", pGlobalTXT_LocalizationStrings[53], - 0, v121->pMonsterInfo.uAttack1DamageDiceRolls, v121->pMonsterInfo.uAttack1DamageDiceSides); + 0, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceRolls, pActors[uActorID].pMonsterInfo.uAttack1DamageDiceSides); } else { sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); a4 = a4 + LOBYTE(v56->uFontHeight) - 3; sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]); } - a1->DrawText(v56, 150, a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = a4 + v58 - 6 + v58; if ( !i ) @@ -1227,33 +993,33 @@ v71 = pGlobalTXT_LocalizationStrings[628]; v68 = "%s\f%05u\t080%s\n"; sprintf(pTmpBuf.data(), v68, v71, v76, v80); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = a4 + v58 - 3; } else { v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; - v59 = v121; - v114 = v121->pMonsterInfo.uSpell1ID; - if ( v114 && v121->pMonsterInfo.uSpell2ID ) + v59 = &pActors[uActorID]; + v114 = pActors[uActorID].pMonsterInfo.uSpell1ID; + if ( v114 && pActors[uActorID].pMonsterInfo.uSpell2ID ) v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; if ( v114 ) { sprintf(pTmpBuf.data(), "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = a4 + v58 - 3; - v59 = v121; + v59 = &pActors[uActorID]; } v60 = v59->pMonsterInfo.uSpell2ID; if ( v60 ) { sprintf(pTmpBuf.data(), "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = a4 + v58 - 3; - v59 = v121; + v59 = &pActors[uActorID]; } if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID ) { @@ -1262,13 +1028,13 @@ v71 = pGlobalTXT_LocalizationStrings[628]; v68 = "%s\f%05u\t060%s\n"; sprintf(pTmpBuf.data(), v68, v71, v76, v80); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 150, (int)a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = a4 + v58 - 3; } } a4 = a4 + v58 - 3; - a1->DrawText(v56, 150, a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0); + window->DrawText(v56, 150, a4, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[626], 0, 0, 0); a4 = a4 + LOBYTE(v56->uFontHeight) - 3; v85[0] = pGlobalTXT_LocalizationStrings[87]; v85[1] = pGlobalTXT_LocalizationStrings[6]; @@ -1280,16 +1046,16 @@ v85[7] = pGlobalTXT_LocalizationStrings[133]; v85[8] = pGlobalTXT_LocalizationStrings[54]; v85[9] = pGlobalTXT_LocalizationStrings[624]; - v95[1] = (char *)v121->pMonsterInfo.uResFire; - v95[2] = (char *)v121->pMonsterInfo.uResAir; - v95[3] = (char *)v121->pMonsterInfo.uResWater; - v95[4] = (char *)v121->pMonsterInfo.uResEarth; - v95[5] = (char *)v121->pMonsterInfo.uResMind; - v95[6] = (char *)v121->pMonsterInfo.uResSpirit; - v95[7] = (char *)v121->pMonsterInfo.uResBody; - v95[8] = (char *)v121->pMonsterInfo.uResLight; - v95[9] = (char *)v121->pMonsterInfo.uResPhysical; - v95[10] = (char *)v121->pMonsterInfo.uResDark; + v95[1] = (char *)pActors[uActorID].pMonsterInfo.uResFire; + v95[2] = (char *)pActors[uActorID].pMonsterInfo.uResAir; + v95[3] = (char *)pActors[uActorID].pMonsterInfo.uResWater; + v95[4] = (char *)pActors[uActorID].pMonsterInfo.uResEarth; + v95[5] = (char *)pActors[uActorID].pMonsterInfo.uResMind; + v95[6] = (char *)pActors[uActorID].pMonsterInfo.uResSpirit; + v95[7] = (char *)pActors[uActorID].pMonsterInfo.uResBody; + v95[8] = (char *)pActors[uActorID].pMonsterInfo.uResLight; + v95[9] = (char *)pActors[uActorID].pMonsterInfo.uResPhysical; + v95[10] = (char *)pActors[uActorID].pMonsterInfo.uResDark; if ( v112 ) { v124 = 0; @@ -1308,7 +1074,7 @@ v81 = pGlobalTXT_LocalizationStrings[153]; } sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", v85[v124], 0, v81); - a1->DrawText(v56, 170, a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 170, a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v63 = LOBYTE(v56->uFontHeight); v124 += 4; a4 = a4 + v63 - 3; @@ -1321,7 +1087,7 @@ do { sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", v85[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?" - a1->DrawText(v56, 170, a4, a5, pTmpBuf.data(), 0, 0, 0); + window->DrawText(v56, 170, a4, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0); v65 = LOBYTE(v56->uFontHeight); ++i; a4 = a4 + v65 - 3; @@ -1330,9 +1096,9 @@ } if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].uExpireTime > 0 ) { - sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP); + sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[650], pActors[uActorID].sCurrentHP); pFontSmallnum->GetLineWidth(pTmpBuf.data()); - a1->DrawTitleText(pFontSmallnum, 0, a1->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf.data(), 3); + window->DrawTitleText(pFontSmallnum, 0, window->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf.data(), 3); } } diff -r ffef0fe0b59d -r cc1d68c17e19 UI/UIShops.cpp --- a/UI/UIShops.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/UI/UIShops.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -2317,7 +2317,7 @@ if ( pCurrentScreen == SCREEN_E ) { - OnInventoryLeftClick(); + pPlayers[uActiveCharacter]->OnInventoryLeftClick(); return; } if ( !HouseUI_CheckIfPlayerCanInteract() ) @@ -2331,7 +2331,7 @@ case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - OnInventoryLeftClick(); + pPlayers[uActiveCharacter]->OnInventoryLeftClick(); break; } case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: diff -r ffef0fe0b59d -r cc1d68c17e19 UI/UiGame.cpp --- a/UI/UiGame.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/UI/UiGame.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -887,7 +887,7 @@ pY = pFontHeight + pY; if ( !i ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[18], 60, 0);// - sprintf(pTmpBuf.data(), "%+d", player->GetActualAttack(0)); + sprintf(pTmpBuf.data(), "%+d", player->GetActualAttack(false)); pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pTmpBuf.data(), 84, 0); pY = pFontHeight + pY; if ( !i ) @@ -1230,7 +1230,7 @@ if ( !pLevelDecorations[v19].uEventID ) { if ( pLevelDecorations[v19].IsInteractive() ) - pText = pNPCTopics[stru_5E4C90._decor_events[pLevelDecorations[v19]._idx_in_stru123 - 75] + 379].pTopic; + pText = pNPCTopics[stru_5E4C90._decor_events[pLevelDecorations[v19]._idx_in_stru123 - 75] + 379].pTopic;// else pText = pDecorationList->pDecorations[pLevelDecorations[v19].uDecorationDescID].field_20; GameUI_SetFooterString(pText); diff -r ffef0fe0b59d -r cc1d68c17e19 mm7_5.cpp --- a/mm7_5.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/mm7_5.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -1004,7 +1004,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1036,15 +1036,15 @@ some_active_character = 0; if ( pParty->bTurnBasedModeOn ) pTurnEngine->ApplyPlayerAction(); - dword_50C9D0 = 0; - dword_50C9D4 = 0; - dword_50C9D8 = 0; + _50C9D0_AfterEnchClickEventId = 0; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 0; } - if ( ptr_50C9A4 && ptr_50C9A4->uItemID ) + if ( ptr_50C9A4_ItemToEnchant && ptr_50C9A4_ItemToEnchant->uItemID ) { - LOBYTE(ptr_50C9A4->uAttributes) &= 0xFu; + LOBYTE(ptr_50C9A4_ItemToEnchant->uAttributes) &= 0xFu; _50C9A8_item_enchantment_timer = 0; - ptr_50C9A4 = 0; + ptr_50C9A4_ItemToEnchant = 0; } if ( pGUIWindow_Settings ) { @@ -1058,7 +1058,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1090,7 +1090,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1274,7 +1274,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1324,7 +1324,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1408,7 +1408,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1436,7 +1436,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1464,7 +1464,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1496,7 +1496,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); } } @@ -1563,7 +1563,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); continue; } @@ -1802,7 +1802,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); continue; } @@ -1820,7 +1820,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); continue; } @@ -1847,7 +1847,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); continue; } @@ -1867,7 +1867,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); continue; case UIMSG_CastSpell_Character_Big_Improvement://Preservation and blessing, treatment paralysis, hand hammers(individual upgrade) @@ -1875,7 +1875,7 @@ case UIMSG_HiredNPC_CastSpell: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( unk_50C9A0 ) + if ( _50C9A0_IsEnchantingInProgress ) { uActiveCharacter = uMessageParam; viewparams->bRedrawGameUI = 1; @@ -1904,7 +1904,7 @@ pEventTimer->Resume(); pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; } } continue; @@ -2388,7 +2388,7 @@ pGUIWindow_Settings = 0; pMouse->SetCursorBitmap("MICON1"); GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; + _50C9A0_IsEnchantingInProgress = 0; back_to_game(); continue; case UIMSG_1C: @@ -2399,8 +2399,7 @@ pCurrentScreen = SCREEN_19; pEventTimer->Pause(); continue; - case UIMSG_1B: - __debugbreak(); + case UIMSG_STEALFROMACTOR: if ( !uActiveCharacter ) continue; if ( pParty->bTurnBasedModeOn != 1 ) @@ -3046,13 +3045,13 @@ case UIMSG_CHEST_ClickItem: if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) { - OnInventoryLeftClick(); + pPlayers[uActiveCharacter]->OnInventoryLeftClick(); continue; } OnChestLeftClick(); continue; case UIMSG_InventoryLeftClick: - OnInventoryLeftClick(); + pPlayers[uActiveCharacter]->OnInventoryLeftClick(); continue; case UIMSG_MouseLeftClickInGame: if ( !pRenderer->pRenderD3D ) @@ -3218,10 +3217,10 @@ } else { - if ( dword_50C9D0 > 0 ) + if ( _50C9D0_AfterEnchClickEventId > 0 ) { - dword_50C9D8 -= pEventTimer->uTimeElapsed; - if ( dword_50C9D8 <= 0 ) + _50C9D8_AfterEnchClickEventTimeout -= pEventTimer->uTimeElapsed; + if ( _50C9D8_AfterEnchClickEventTimeout <= 0 ) { /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { @@ -3230,10 +3229,10 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; }*/ - pMessageQueue_50CBD0->AddMessage((UIMessageType)dword_50C9D0, dword_50C9D4, 0); - dword_50C9D0 = 0; - dword_50C9D4 = 0; - dword_50C9D8 = 0; + pMessageQueue_50CBD0->AddMessage((UIMessageType)_50C9D0_AfterEnchClickEventId, _50C9D4_AfterEnchClickEventSecondParam, 0); + _50C9D0_AfterEnchClickEventId = 0; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 0; } } } diff -r ffef0fe0b59d -r cc1d68c17e19 mm7_6.cpp --- a/mm7_6.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/mm7_6.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -767,7 +767,7 @@ if ( a3 ) v8 = pPlayer->GetRangedAttack(); else - v8 = pPlayer->GetActualAttack(0); + v8 = pPlayer->GetActualAttack(false); v9 = rand() % (v7 + 2 * v8 + 30); if ( a3 == 2 ) { diff -r ffef0fe0b59d -r cc1d68c17e19 mm7_data.cpp --- a/mm7_data.cpp Mon Sep 23 09:33:13 2013 +0600 +++ b/mm7_data.cpp Mon Sep 23 09:34:23 2013 +0600 @@ -783,9 +783,6 @@ 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 4, 0, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, }}; -std::array dword_4EDEA0; // weak -std::array dword_4EDEB4; // weak -std::array dword_4EDEC4; // weak _UNKNOWN unk_4EDF40; // weak std::array pHiredNPCsIconsOffsetsX = {489, 559}; std::array pHiredNPCsIconsOffsetsY = {152, 152}; @@ -995,12 +992,12 @@ int dword_50C994 = 0; // weak int dword_50C998_turnbased_icon_1A = 0; // weak int uSpriteID_Spell11; // idb -_UNKNOWN unk_50C9A0; // weak +bool _50C9A0_IsEnchantingInProgress; // weak int _50C9A8_item_enchantment_timer = 0; // weak int dword_50C9AC; // weak -int dword_50C9D0; // weak -int dword_50C9D4; // weak -int dword_50C9D8; // weak +int _50C9D0_AfterEnchClickEventId; // weak +int _50C9D4_AfterEnchClickEventSecondParam; // weak +int _50C9D8_AfterEnchClickEventTimeout; // weak int dword_50C9DC; // weak struct NPCData *ptr_50C9E0; //int dword_50C9E8; // idb diff -r ffef0fe0b59d -r cc1d68c17e19 mm7_data.h --- a/mm7_data.h Mon Sep 23 09:33:13 2013 +0600 +++ b/mm7_data.h Mon Sep 23 09:34:23 2013 +0600 @@ -511,9 +511,6 @@ extern std::array, 110> SoundSetAction; // weak extern std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing; extern std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table; -extern std::array dword_4EDEA0; // weak -extern std::array dword_4EDEB4; // weak -extern std::array dword_4EDEC4; // weak extern _UNKNOWN unk_4EDF40; // weak extern std::array pHiredNPCsIconsOffsetsX; extern std::array pHiredNPCsIconsOffsetsY; @@ -677,12 +674,12 @@ extern int dword_50C994; // weak extern int dword_50C998_turnbased_icon_1A; // weak extern int uSpriteID_Spell11; // idb -extern _UNKNOWN unk_50C9A0; // weak +extern bool _50C9A0_IsEnchantingInProgress; // weak extern int _50C9A8_item_enchantment_timer; // weak extern int dword_50C9AC; // weak -extern int dword_50C9D0; // weak -extern int dword_50C9D4; // weak -extern int dword_50C9D8; // weak +extern int _50C9D0_AfterEnchClickEventId; // weak +extern int _50C9D4_AfterEnchClickEventSecondParam; // weak +extern int _50C9D8_AfterEnchClickEventTimeout; // weak extern int dword_50C9DC; // weak extern struct NPCData *ptr_50C9E0; //extern int dword_50C9E8; // idb @@ -1103,7 +1100,6 @@ unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2); void PrepareArcomage(); unsigned short TargetColor(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb -void CallRenderPresent(); void DoBlt_Copy(unsigned __int16 *pPixels); // idb void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue); void __fastcall ZBuffer_DoFill(int *pZBuffer, struct Texture *pTex, int uZValue); @@ -1124,7 +1120,7 @@ void __fastcall sub_41D20D_buff_remaining_time_string(int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2); bool UI_OnKeyDown(unsigned int vkKey); void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb -void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *edx0); +void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *window); void LoadActualSkyFrame(); void Sleep6Hours(); void ChestUI_WritePointedObjectStatusString(); @@ -1133,7 +1129,6 @@ void GameUI_WritePointedObjectStatusString(); bool sub_421B2C_PlaceInInventory_or_DropPickedItem(); void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID); // idb -void OnInventoryLeftClick(); void OnGameViewportClick(); bool PauseGameDrawing(); void SetUserInterface(enum PartyAlignment alignment, bool bReplace);