comparison UI/UIHouses.cpp @ 1529:61458df2cb4f

bountyHunting fix
author Ritor1
date Fri, 06 Sep 2013 16:42:23 +0600
parents f47eab1a70d8
children 2ae4c5a5b4e5
comparison
equal deleted inserted replaced
1526:f47eab1a70d8 1529:61458df2cb4f
987 //----- (004BCACC) -------------------------------------------------------- 987 //----- (004BCACC) --------------------------------------------------------
988 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam) 988 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam)
989 { 989 {
990 int experience_for_next_level; // eax@5 990 int experience_for_next_level; // eax@5
991 GUIWindow *v8; // esi@10 991 GUIWindow *v8; // esi@10
992 int v10; // esi@31 992 //int v11; // edi@31
993 int v11; // edi@31
994 int v12; // esi@32
995 __int16 v13; // bp@32
996 int v14; // edx@32
997 GUIWindow *v15; // eax@32
998 int v16; // eax@32 993 int v16; // eax@32
999 int v17; // eax@33 994 int v17; // eax@33
1000 int v18; // eax@34 995 int v18; // eax@34
1001 int v19; // eax@35 996 int v19; // eax@35
1002 __int16 v20; // ax@37 997 __int16 v20; // ax@37
1003 __int16 v21; // ax@76 998 __int16 v21; // ax@76
1004 __int16 v22; // ax@107 999 __int16 v22; // ax@107
1005 __int16 v23; // ax@132 1000 __int16 v23; // ax@132
1006 __int16 v24; // ax@163 1001 __int16 v24; // ax@163
1007 int v25; // esi@190
1008 __int16 v26; // ax@190
1009 char v27; // zf@190
1010 Player *v28; // edi@192
1011 int v29; // eax@204
1012 //void *v30; // esi@208
1013 //unsigned __int64 v31; // qax@208
1014 //signed int v32; // edi@209
1015 //int v33; // eax@210
1016 unsigned int v34; // eax@211 1002 unsigned int v34; // eax@211
1017 signed int v36; // esi@227 1003 signed int v36; // esi@227
1018 int v37; // ecx@227 1004 int v37; // ecx@227
1019 int v38; // esi@230 1005 int v38; // esi@230
1020 int v39; // edx@235 1006 int v39; // edx@235
1030 int v50; // eax@256 1016 int v50; // eax@256
1031 unsigned int v51; // eax@257 1017 unsigned int v51; // eax@257
1032 void *v52; // eax@260 1018 void *v52; // eax@260
1033 signed int v53; // edi@260 1019 signed int v53; // edi@260
1034 int v54; // eax@262 1020 int v54; // eax@262
1035 int v56; // [sp+14h] [bp-Ch]@31
1036 1021
1037 if ( !pDialogueWindow->pNumPresenceButton ) 1022 if ( !pDialogueWindow->pNumPresenceButton )
1038 return; 1023 return;
1039 pRenderer->ClearZBuffer(0, 479); 1024 pRenderer->ClearZBuffer(0, 479);
1040 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN) 1025 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN)
1041 v8 = window_SpeakInHouse; 1026 v8 = window_SpeakInHouse;
1042 if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) 1027 if (dialog_menu_id == HOUSE_DIALOGUE_MAIN)
1043 { 1028 {
1044 if ( in_current_building_type == BuildingType_Training ) 1029 if ( in_current_building_type == BuildingType_Training )
1045 { 1030 {
1046 if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) 1031 if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
1047 { 1032 {
1048 experience_for_next_level = 0; 1033 experience_for_next_level = 0;
1049 if ( pPlayers[uActiveCharacter]->uLevel > 0 ) 1034 if ( pPlayers[uActiveCharacter]->uLevel > 0 )
1050 { 1035 {
1051 for( uint i = 0; i < pPlayers[uActiveCharacter]->uLevel; i++ ) 1036 for( uint i = 0; i < pPlayers[uActiveCharacter]->uLevel; i++ )
1052 experience_for_next_level += i + 1; 1037 experience_for_next_level += i + 1;
1053 } 1038 }
1054 if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] && 1039 if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] &&
1055 (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * experience_for_next_level) 1040 (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * experience_for_next_level)//test experience
1056 return; 1041 return;
1057 } 1042 }
1058 pDialogueWindow->Release(); 1043 pDialogueWindow->Release();
1059 pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); 1044 pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
1060 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" 1045 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
1061 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); 1046 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
1062 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); 1047 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
1063 v8 = window_SpeakInHouse; 1048 v8 = window_SpeakInHouse;
1064 } 1049 }
1065 if ( in_current_building_type != BuildingType_Training ) 1050 if ( in_current_building_type != BuildingType_Training )
1066 { 1051 {
1067 v8 = window_SpeakInHouse; 1052 v8 = window_SpeakInHouse;
1068 if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && 1053 if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) &&
1069 transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] 1054 transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7]
1070 || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) 1055 || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
1071 { 1056 {
1072 pDialogueWindow->Release(); 1057 pDialogueWindow->Release();
1073 pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); 1058 pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
1074 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" 1059 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
1075 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); 1060 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
1076 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); 1061 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
1077 v8 = window_SpeakInHouse; 1062 v8 = window_SpeakInHouse;
1078 } 1063 }
1079 else if (uActiveCharacter) 1064 else if (uActiveCharacter)
1080 { 1065 {
1081 if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() ) 1066 if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
1082 return; 1067 return;
1083 v8 = window_SpeakInHouse; 1068 v8 = window_SpeakInHouse;
1084 } 1069 }
1085 } 1070 }
1086 dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; 1071 dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
1087 if ( in_current_building_type < BuildingType_19 ) 1072 if ( in_current_building_type < BuildingType_19 )
1088 { 1073 {
1089 ShopTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE)]; 1074 ShopTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE)];
1090 v8 = window_SpeakInHouse; 1075 v8 = window_SpeakInHouse;
1091 } 1076 }
1092 } 1077 }
1093 1078
1094 //NEW 1079 //NEW
1095 switch (in_current_building_type) 1080 switch (in_current_building_type)
1096 { 1081 {
1105 case BuildingType_DarkGuild: 1090 case BuildingType_DarkGuild:
1106 case BuildingType_14: 1091 case BuildingType_14:
1107 case BuildingType_15: 1092 case BuildingType_15:
1108 case BuildingType_16: 1093 case BuildingType_16:
1109 { 1094 {
1110 if ( pParty->field_3C.field_50[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed ) 1095 if ( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed )
1111 { 1096 {
1112 for ( uint i = 0; i < 12; ++i ) 1097 for ( uint i = 0; i < 12; ++i )
1113 { 1098 {
1114 if ( pParty->SpellBooksInGuilds[v8->par1C-139][i].uItemID ) 1099 if ( pParty->SpellBooksInGuilds[v8->par1C-139][i].uItemID )
1115 { 1100 {
1117 v8 = window_SpeakInHouse; 1102 v8 = window_SpeakInHouse;
1118 ItemsInShopTexture[i] = &pIcons_LOD->pTextures[v34]; 1103 ItemsInShopTexture[i] = &pIcons_LOD->pTextures[v34];
1119 } 1104 }
1120 } 1105 }
1121 } 1106 }
1122 else 1107 else//generation new books
1123 { 1108 {
1124 SpellBookGenerator(); 1109 SpellBookGenerator();
1125 pParty->field_3C.field_50[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000 1110 pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000
1126 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); 1111 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335);
1127 } 1112 }
1128 //return;
1129 break; 1113 break;
1130 } 1114 }
1131 case BuildingType_TownHall: 1115 case BuildingType_TownHall:
1132 { 1116 {
1133 if ( uMessageParam == 99 ) 1117 if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_MESSAGE )
1134 { 1118 {
1135 v10 = (int)((char *)v8->ptr_1C - 102); 1119 if ( pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)v8->ptr_1C - 102)] < (signed __int64)pParty->uTimePlayed )//new generation
1136 v56 = v10; 1120 {
1137 v11 = 8 * v10 + 11325428; 1121 pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] = false;
1138 if ( pParty->field_3C.field_0[2 * v10 + 1] >= (signed __int64)pParty->uTimePlayed 1122 pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)v8->ptr_1C - 102)] = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
1139 && pParty->field_3C.field_0[2 * v10] >= (signed __int64)pParty->uTimePlayed ) 1123 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
1140 { 1124 v16 = (int)((char *)window_SpeakInHouse->ptr_1C - 102);
1141 v13 = 0; 1125 if ( !v16 )
1126 {
1127 while ( 1 )
1128 {
1129 v24 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
1130 if ( (unsigned __int16)v24 < 115 || (unsigned __int16)v24 > 132 )
1131 {
1132 if ( ((unsigned __int16)v24 < 235 || (unsigned __int16)v24 > 252)
1133 && ((unsigned __int16)v24 < 133 || (unsigned __int16)v24 > 150)
1134 && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
1135 && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
1136 && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
1137 && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
1138 && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
1139 && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
1140 && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
1141 && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
1142 && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
1143 break;
1144 }
1145 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
1146 }
1147 }
1148 if ( v16 == 1 )
1149 {
1150 while ( 1 )
1151 {
1152 v23 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
1153 if ( (unsigned __int16)v23 < 115 || (unsigned __int16)v23 > 132 )
1154 {
1155 if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
1156 && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
1157 && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
1158 && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
1159 && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
1160 && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
1161 && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
1162 && ((unsigned __int16)v23 < 4 || (unsigned __int16)v23 > 6)
1163 && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
1164 && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
1165 && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
1166 && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
1167 && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
1168 && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
1169 break;
1170 }
1171 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
1172 }
1173 }
1174 if ( v16 == 2 )
1175 {
1176 while ( 1 )
1177 {
1178 v22 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
1179 if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
1180 {
1181 if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
1182 && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
1183 && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
1184 && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
1185 && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
1186 && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
1187 && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
1188 && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
1189 && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
1190 && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
1191 && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
1192 break;
1193 }
1194 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
1195 }
1196 }
1197 if ( v16 == 3 )
1198 {
1199 while ( 1 )
1200 {
1201 v21 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
1202 if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
1203 {
1204 if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
1205 && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
1206 && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
1207 && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
1208 && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
1209 && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
1210 && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
1211 && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
1212 && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
1213 && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
1214 && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
1215 && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
1216 && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
1217 && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
1218 break;
1219 }
1220 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
1221 }
1222 }
1223 if ( v16 == 4 )
1224 {
1225 while ( 1 )
1226 {
1227 v20 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
1228 if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
1229 {
1230 if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
1231 && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
1232 && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
1233 && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
1234 && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
1235 && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
1236 && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
1237 && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
1238 && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
1239 && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
1240 && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
1241 && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
1242 && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
1243 && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
1244 && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
1245 && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
1246 && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
1247 && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
1248 break;
1249 }
1250 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1;
1251 }
1252 }
1253 }
1254 bountyHunting_monster_id_for_hunting = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)];
1255 if ( !pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] )
1256 {
1257 bountyHunting_text = pNPCTopics[351].pText;//"В этом месяцу назначена награда за голову %s..."
1258 if ( !pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] )
1259 bountyHunting_text = pNPCTopics[353].pText;//"Кое кто уже приходил в этом месяце за наградой"
1142 } 1260 }
1143 else 1261 else
1144 { 1262 {
1145 v12 = v10; 1263 if ( pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] > 0 )//get prize
1146 v13 = 0;
1147 pParty->field_75A[v12] = 0;
1148 *(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
1149 v14 = rand() % 258;
1150 v15 = window_SpeakInHouse;
1151 pParty->field_750[v12] = v14 + 1;
1152 v16 = (int)((char *)v15->ptr_1C - 102);
1153 if ( v16 )
1154 { 1264 {
1155 v17 = v16 - 1; 1265 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]].uLevel, 0);
1156 if ( v17 ) 1266 for ( uint i = 0; i < 4; ++i )
1157 { 1267 pParty->pPlayers[i].SetVariable(VAR_Award, 86);
1158 v18 = v17 - 1; 1268 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]].uLevel;
1159 if ( v18 ) 1269 pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = 0;
1160 { 1270 pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] = false;
1161 v19 = v18 - 1; 1271 }
1162 if ( v19 ) 1272 bountyHunting_text = pNPCTopics[352].pText;//"Поздравляю! Вы успешно..."
1163 { 1273 }
1164 if ( v19 == 1 ) 1274 }
1165 { 1275 else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_PAY_FINE )
1166 while ( 1 ) 1276 pKeyActionMap->EnterText(1, 10, v8);
1167 { 1277 break;
1168 v20 = pParty->field_750[v12]; 1278 }
1169 if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
1170 {
1171 if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
1172 && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
1173 && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
1174 && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
1175 && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
1176 && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
1177 && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
1178 && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
1179 && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
1180 && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
1181 && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
1182 && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
1183 && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
1184 && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
1185 && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
1186 && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
1187 && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
1188 && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
1189 break;
1190 }
1191 pParty->field_750[v12] = rand() % 258 + 1;
1192 }
1193 }
1194 }
1195 else
1196 {
1197 while ( 1 )
1198 {
1199 v21 = pParty->field_750[v12];
1200 if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
1201 {
1202 if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
1203 && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
1204 && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
1205 && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
1206 && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
1207 && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
1208 && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
1209 && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
1210 && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
1211 && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
1212 && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
1213 && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
1214 && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
1215 && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
1216 break;
1217 }
1218 pParty->field_750[v12] = rand() % 258 + 1;
1219 }
1220 }
1221 }
1222 else
1223 {
1224 while ( 1 )
1225 {
1226 v22 = pParty->field_750[v12];
1227 if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
1228 {
1229 if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
1230 && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
1231 && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
1232 && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
1233 && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
1234 && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
1235 && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
1236 && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
1237 && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
1238 && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
1239 && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
1240 break;
1241 }
1242 pParty->field_750[v12] = rand() % 258 + 1;
1243 }
1244 }
1245 }
1246 else
1247 {
1248 while ( 1 )
1249 {
1250 v23 = pParty->field_750[v12];
1251 if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u )
1252 {
1253 if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
1254 && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
1255 && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
1256 && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
1257 && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
1258 && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
1259 && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
1260 && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u)
1261 && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
1262 && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
1263 && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
1264 && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
1265 && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
1266 && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
1267 break;
1268 }
1269 pParty->field_750[v12] = rand() % 258 + 1;
1270 }
1271 }
1272 }
1273 else
1274 {
1275 while ( 1 )
1276 {
1277 v24 = pParty->field_750[v12];
1278 if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u )
1279 {
1280 if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu)
1281 && ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u)
1282 && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
1283 && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
1284 && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
1285 && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
1286 && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
1287 && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
1288 && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
1289 && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
1290 && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
1291 break;
1292 }
1293 pParty->field_750[v12] = rand() % 258 + 1;
1294 }
1295 }
1296 v10 = v56;
1297 }
1298 v25 = v10;
1299 v26 = pParty->field_750[v25];
1300 v27 = pParty->field_75A[v25] == v13;
1301 word_F8B1A0 = pParty->field_750[v25];
1302 if ( v27 )
1303 {
1304 //v1 = 0;
1305 v27 = v26 == v13;
1306 v29 = (int)pNPCTopics[351].pText;
1307 if ( v27 )
1308 v29 = (int)pNPCTopics[353].pText;
1309 dword_F8B1A4 = (char *)v29;
1310 }
1311 else
1312 {
1313 if ( v26 != v13 )
1314 {
1315 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0);
1316 v28 = pParty->pPlayers;
1317 do
1318 {
1319 v28->SetVariable(VAR_Award, 86);
1320 ++v28;
1321 }
1322 while ( (signed int)v28 < (signed int)pParty->pHirelings );
1323 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
1324 pParty->field_750[v25] = v13;
1325 pParty->field_75A[v25] = v13;
1326 }
1327 //v1 = 0;
1328 dword_F8B1A4 = pNPCTopics[352].pText;
1329 }
1330 }
1331 else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_100 )
1332 {
1333 pKeyActionMap->EnterText(1, 10, v8);
1334 }
1335 break;
1336 }
1337 case BuildingType_Bank: 1279 case BuildingType_Bank:
1338 { 1280 {
1339 if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) 1281 if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
1340 pKeyActionMap->EnterText(1, 10, v8); 1282 pKeyActionMap->EnterText(1, 10, v8);
1341 return; 1283 return;
1581 v10 = v56; 1523 v10 = v56;
1582 } 1524 }
1583 v25 = v10; 1525 v25 = v10;
1584 v26 = pParty->field_750[v25]; 1526 v26 = pParty->field_750[v25];
1585 v27 = pParty->field_75A[v25] == v13; 1527 v27 = pParty->field_75A[v25] == v13;
1586 word_F8B1A0 = pParty->field_750[v25]; 1528 bountyHunting_monster_id_for_hunting = pParty->field_750[v25];
1587 if ( v27 ) 1529 if ( v27 )
1588 { 1530 {
1589 //v1 = 0; 1531 //v1 = 0;
1590 v27 = v26 == v13; 1532 v27 = v26 == v13;
1591 v29 = (int)pNPCTopics[351].pText; 1533 v29 = (int)pNPCTopics[351].pText;
1592 if ( v27 ) 1534 if ( v27 )
1593 v29 = (int)pNPCTopics[353].pText; 1535 v29 = (int)pNPCTopics[353].pText;
1594 dword_F8B1A4 = (char *)v29; 1536 bountyHunting_text = (char *)v29;
1595 } 1537 }
1596 else 1538 else
1597 { 1539 {
1598 if ( v26 != v13 ) 1540 if ( v26 != v13 )
1599 { 1541 {
1608 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel; 1550 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
1609 pParty->field_750[v25] = v13; 1551 pParty->field_750[v25] = v13;
1610 pParty->field_75A[v25] = v13; 1552 pParty->field_75A[v25] = v13;
1611 } 1553 }
1612 //v1 = 0; 1554 //v1 = 0;
1613 dword_F8B1A4 = pNPCTopics[352].pText; 1555 bountyHunting_text = pNPCTopics[352].pText;
1614 } 1556 }
1615 } 1557 }
1616 else if ( uMessageParam == 100 ) 1558 else if ( uMessageParam == 100 )
1617 { 1559 {
1618 pKeyActionMap->EnterText(1, 10, v8); 1560 pKeyActionMap->EnterText(1, 10, v8);
1660 break; 1602 break;
1661 } 1603 }
1662 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: 1604 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
1663 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: 1605 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
1664 { 1606 {
1665 if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) 1607 if ( pParty->field_3C.Shops_next_generation_time[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
1666 { 1608 {
1667 GenerateStandartShopItems(); 1609 GenerateStandartShopItems();
1668 GenerateSpecialShopItems(); 1610 GenerateSpecialShopItems();
1669 pParty->field_3C.field_50[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); 1611 pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335);
1670 } 1612 }
1671 if ( uMessageParam == HOUSE_DIALOGUE_SHOP_BUY_STANDARD ) 1613 if ( uMessageParam == HOUSE_DIALOGUE_SHOP_BUY_STANDARD )
1672 { 1614 {
1673 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) 1615 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
1674 { 1616 {
1856 } 1798 }
1857 } 1799 }
1858 sub_421B2C_PlaceInInventory_or_DropPickedItem(); 1800 sub_421B2C_PlaceInInventory_or_DropPickedItem();
1859 return; 1801 return;
1860 } 1802 }
1861 if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) 1803 if ( pParty->field_3C.Shops_next_generation_time[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
1862 { 1804 {
1863 GenerateStandartShopItems(); 1805 GenerateStandartShopItems();
1864 GenerateSpecialShopItems(); 1806 GenerateSpecialShopItems();
1865 v8 = window_SpeakInHouse; 1807 v8 = window_SpeakInHouse;
1866 v40 = window_SpeakInHouse->par1C; 1808 v40 = window_SpeakInHouse->par1C;
1867 //v3 = dword_F8B198; 1809 //v3 = dword_F8B198;
1868 v41 = pParty->uTimePlayed 1810 v41 = pParty->uTimePlayed
1869 //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) 1811 //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
1870 + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) 1812 + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C)
1871 * 0.033333335); 1813 * 0.033333335);
1872 pParty->field_3C.field_50[v40] = v41; 1814 pParty->field_3C.Shops_next_generation_time[v40] = v41;
1873 1815
1874 } 1816 }
1875 v42 = v8->ptr_1C; 1817 v42 = v8->ptr_1C;
1876 v43 = 0; 1818 v43 = 0;
1877 //v44 = p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]; 1819 //v44 = p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C];
2298 2240
2299 2241
2300 //----- (004B7911) -------------------------------------------------------- 2242 //----- (004B7911) --------------------------------------------------------
2301 void TownHallDialog() 2243 void TownHallDialog()
2302 { 2244 {
2303 GUIWindow *v0; // eax@4
2304 int v1; // eax@10 2245 int v1; // eax@10
2305 int v2; // esi@10 2246 int v2; // esi@10
2306 GUIFont *v3; // ST20_4@20 2247 signed int pStringSum; // ebx@24
2307 int v4; // eax@20
2308 MonsterInfo *v5; // edi@21
2309 unsigned int v6; // ST20_4@21
2310 char *v7; // ST1C_4@21
2311 unsigned int v8; // eax@21
2312 int v9; // esi@21
2313 char *v10; // eax@23
2314 signed int v11; // ebx@24
2315 signed int i; // esi@26
2316 int v13; // eax@27
2317 GUIWindow *v14; // ecx@28
2318 __int64 v15; // qax@28
2319 signed int v16; // ebx@28 2248 signed int v16; // ebx@28
2320 int v17; // ebx@28 2249 int v17; // ebx@28
2321 unsigned __int8 v18; // sf@28 2250 GUIButton *pButton; // eax@30
2322 char **v19; // edi@29 2251 int pTextHeight; // eax@30
2323 GUIButton *v20; // eax@30
2324 GUIButton *v21; // esi@30
2325 int v22; // eax@30
2326 unsigned int v23; // ecx@30 2252 unsigned int v23; // ecx@30
2327 unsigned __int16 v24; // ax@30 2253 unsigned __int16 pTextColor; // ax@30
2328 GUIWindow a1; // [sp+Ch] [bp-110h]@21 2254 GUIWindow window; // [sp+60h] [bp-BCh]@21
2329 GUIWindow w; // [sp+60h] [bp-BCh]@21 2255 GUIWindow townHall_window; // [sp+B4h] [bp-68h]@1
2330 GUIWindow _this; // [sp+B4h] [bp-68h]@1
2331 int v28; // [sp+108h] [bp-14h]@1
2332 int v29; // [sp+10Ch] [bp-10h]@28 2256 int v29; // [sp+10Ch] [bp-10h]@28
2333 int v30; // [sp+110h] [bp-Ch]@1
2334 int v31; // [sp+114h] [bp-8h]@29 2257 int v31; // [sp+114h] [bp-8h]@29
2335 GUIFont *pOutString; // [sp+118h] [bp-4h]@21 2258 GUIFont *pOutString; // [sp+118h] [bp-4h]@21
2336 2259
2337 memcpy(&_this, window_SpeakInHouse, sizeof(_this)); 2260 memcpy(&townHall_window, window_SpeakInHouse, sizeof(townHall_window));
2338 _this.uFrameX = 483; 2261 townHall_window.uFrameX = 483;
2339 _this.uFrameWidth = 148; 2262 townHall_window.uFrameWidth = 148;
2340 _this.uFrameZ = 334; 2263 townHall_window.uFrameZ = 334;
2341 v28 = TargetColor(0xFFu, 0xFFu, 0xFFu); 2264 sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);//Текущий штраф
2342 v30 = TargetColor(0xFFu, 0xFFu, 0x9Bu); 2265 townHall_window.DrawTitleText(pFontArrus, 0, 260, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
2343 sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
2344 _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf.data(), 3u);
2345 switch(dialog_menu_id) 2266 switch(dialog_menu_id)
2346 { 2267 {
2347 case HOUSE_DIALOGUE_MAIN: 2268 case HOUSE_DIALOGUE_MAIN:
2348 { 2269 {
2349 v11 = 1; 2270 pStringSum = 1;
2350 pOutString = 0; 2271 pTextHeight = 0;
2351 pShopOptions[0] = pGlobalTXT_LocalizationStrings[604]; 2272 pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];//Охота за вознаграждение
2352 if ( pParty->uFine ) 2273 if ( pParty->uFine > 0 )
2353 { 2274 {
2354 pShopOptions[1] = pGlobalTXT_LocalizationStrings[603]; 2275 pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];//Заплатить штраф
2355 v11 = 2; 2276 pStringSum = 2;
2356 } 2277 }
2357 for ( i = 0; i < v11; ++i ) 2278 for ( uint i = 0; i < pStringSum; ++i )
2358 { 2279 pTextHeight += pFontArrus->CalcTextHeight(pShopOptions[i], &townHall_window, 0, 0);
2359 v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0); 2280 v29 = (100 - pTextHeight) / pStringSum;
2360 pOutString = (GUIFont *)((char *)pOutString + v13); 2281 v16 = 80 - pStringSum * ((100 - pTextHeight) / pStringSum);
2361 } 2282 v17 = (v16 / 2) - v29 / 2 + 158;
2362 v29 = (100 - (signed int)pOutString) / v11; 2283 if ( pDialogueWindow->pNumPresenceButton > 0 )
2363 v14 = pDialogueWindow; 2284 {
2364 v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString; 2285 v31 = 2;
2365 v16 = v15 - HIDWORD(v15); 2286 uint j = 0;
2366 LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem; 2287 for ( uint i = pDialogueWindow->pStartingPosActiveItem;
2367 HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton; 2288 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
2368 v17 = (v16 >> 1) - v29 / 2 + 158; 2289 {
2369 v18 = -pDialogueWindow->pNumPresenceButton < 0; 2290 pButton = pDialogueWindow->GetControl(i);
2370 pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; 2291 pButton->uY = v29 + v17;
2371 if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) ) 2292 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &townHall_window, 0, 0);
2372 { 2293 v23 = pButton->uY;
2373 v31 = 2; 2294 pButton->uHeight = pTextHeight;
2374 v19 = pShopOptions.data(); 2295 v17 = v23 + pTextHeight - 1;
2375 do 2296 pButton->uW = v17;
2376 { 2297 pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
2377 v20 = v14->GetControl((unsigned int)pOutString); 2298 if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
2378 v21 = v20; 2299 pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
2379 v20->uY = v29 + v17; 2300 townHall_window.DrawTitleText(pFontArrus, 0, v23, pTextColor, pShopOptions[j], 3);
2380 v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0); 2301 ++v31;
2381 v23 = v21->uY; 2302 ++j;
2382 v21->uHeight = v22; 2303 }
2383 v17 = v23 + v22 - 1; 2304 }
2384 v21->uW = v17; 2305 break;
2385 v24 = v30; 2306 }
2386 if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) 2307 case HOUSE_DIALOGUE_TOWNHALL_MESSAGE:
2387 v24 = v28; 2308 {
2388 _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u); 2309 sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu),
2389 v14 = pDialogueWindow; 2310 pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName, TargetColor(0xFFu, 0xFFu, 0xFFu));
2390 ++v31; 2311 sprintf(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].uLevel);
2391 ++v19; 2312 current_npc_text = pTmpBuf2.data();
2392 pOutString = (GUIFont *)((char *)pOutString + 1); 2313 memcpy(&window, pDialogueWindow, sizeof(window));
2393 } 2314 window.uFrameWidth = 458;
2394 while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); 2315 window.uFrameZ = 457;
2395 } 2316 pOutString = pFontArrus;
2396 break; 2317 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &window, 13, 0) + 7;
2397 } 2318 if ( 352 - pTextHeight < 8 )
2398 2319 {
2399 case HOUSE_DIALOGUE_TOWNHALL_99: 2320 pOutString = pFontCreate;
2400 { 2321 pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &window, 13, 0) + 7;
2401 v5 = &pMonsterStats->pInfos[word_F8B1A0]; 2322 }
2402 v6 = TargetColor(0xFFu, 0xFFu, 0xFFu); 2323 pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
2403 v7 = v5->pName; 2324 pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
2404 v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu); 2325 window.DrawText(pOutString, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pOutString, &window, 13, 0), 0, 0, 0);
2405 sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", v8, v7, v6); 2326 break;
2406 sprintf(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * v5->uLevel); 2327 }
2407 current_npc_text = pTmpBuf2.data(); 2328 case HOUSE_DIALOGUE_TOWNHALL_PAY_FINE:
2408 memcpy(&a1, pDialogueWindow, sizeof(a1)); 2329 {
2409 w.uFrameWidth = 458; 2330 if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
2410 w.uFrameZ = 457; 2331 {
2411 pOutString = pFontArrus; 2332 sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?"
2412 v9 = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &w, 13, 0) + 7; 2333 townHall_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
2413 if ( 352 - v9 < 8 ) 2334 townHall_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
2414 { 2335 townHall_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
2415 pOutString = pFontCreate; 2336 return;
2416 v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; 2337 }
2417 } 2338 if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
2418 2339 {
2419 auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); 2340 v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
2420 pRenderer->GetLeather(8, 352 - v9, pTex, pTex->uTextureHeight - v9); 2341 v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
2421 pRenderer->DrawTextureIndexed(8, 347 - v9, pTexture_591428); 2342 if ( v1 <= 0 )
2422 v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 13, 0); 2343 {
2423 a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0); 2344 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
2424 break; 2345 return;
2425 } 2346 }
2426 case HOUSE_DIALOGUE_TOWNHALL_100: 2347 if ( v1 > pParty->uNumGold )
2427 { 2348 {
2428 v0 = window_SpeakInHouse; 2349 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
2429 if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) 2350 v2 = pParty->uNumGold;
2430 { 2351 }
2431 sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?" 2352 if ( v2 > pParty->uFine )
2432 _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf.data(), 3u); 2353 v2 = pParty->uFine;
2433 _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3); 2354 Party::TakeGold(v2);
2434 v3 = pFontArrus; 2355 pParty->uFine -= v2;
2435 v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); 2356 if ( pParty->uFine < 0 )
2436 _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3); 2357 pParty->uFine = 0;
2437 return; 2358 if ( uActiveCharacter )
2438 } 2359 pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
2439 if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) 2360 }
2440 { 2361 if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
2441 v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); 2362 {
2442 v2 = v1; 2363 window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
2443 if ( v1 <= 0 ) 2364 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
2444 { 2365 }
2445 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); 2366 break;
2446 return; 2367 }
2447 } 2368 default:
2448 if ( v1 > pParty->uNumGold ) 2369 break;
2449 {
2450 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
2451 v2 = pParty->uNumGold;
2452 }
2453 if ( v2 > pParty->uFine )
2454 v2 = pParty->uFine;
2455 Party::TakeGold(v2);
2456 pParty->uFine -= v2;
2457 if ( pParty->uFine < 0 )
2458 pParty->uFine = 0;
2459 if ( uActiveCharacter )
2460 pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
2461 v0 = window_SpeakInHouse;
2462 }
2463 if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
2464 {
2465 v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
2466 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
2467 }
2468 break;
2469 }
2470 default:
2471 {
2472 break;
2473 }
2474 } 2370 }
2475 return; 2371 return;
2476 } 2372 }
2477 2373
2478 //----- (004B7D7E) -------------------------------------------------------- 2374 //----- (004B7D7E) --------------------------------------------------------
4172 if ( !v26 ) 4068 if ( !v26 )
4173 { 4069 {
4174 v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C); 4070 v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C);
4175 LABEL_44: 4071 LABEL_44:
4176 v15 = v33; 4072 v15 = v33;
4177 LABEL_45:
4178 v16 = (GUIButton *)pInString; 4073 v16 = (GUIButton *)pInString;
4179 goto LABEL_49; 4074 goto LABEL_49;
4180 } 4075 }
4181 v27 = v26 - 3; 4076 v27 = v26 - 3;
4182 if ( !v27 ) 4077 if ( !v27 )
4185 goto LABEL_44; 4080 goto LABEL_44;
4186 } 4081 }
4187 v28 = v27 - 1; 4082 v28 = v27 - 1;
4188 if ( !v28 ) 4083 if ( !v28 )
4189 { 4084 {
4190 v29 = (char *)&pMonsterStats + 88 * word_F8B1A0; 4085 v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName;
4191 v30 = TargetColor(0xFFu, 0xFFu, 0xFFu); 4086 v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
4192 v31 = *(int *)v29; 4087 v31 = *(int *)v29;
4193 v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu); 4088 v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
4194 sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30); 4089 sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30);
4195 sprintfex(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); 4090 sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]);
4196 current_npc_text = pTmpBuf2.data(); 4091 current_npc_text = pTmpBuf2.data();
4197 v15 = ""; 4092 v15 = "";
4198 goto LABEL_45; 4093 v16 = (GUIButton *)pInString;
4094 goto LABEL_49;
4199 } 4095 }
4200 if ( v28 != 10 ) 4096 if ( v28 != 10 )
4201 goto LABEL_41; 4097 goto LABEL_41;
4202 } 4098 }
4203 else 4099 else
4235 if ( uDialogueType != 84 ) 4131 if ( uDialogueType != 84 )
4236 goto LABEL_49; 4132 goto LABEL_49;
4237 sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName); 4133 sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName);
4238 sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); 4134 sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data());
4239 current_npc_text = pTmpBuf2.data(); 4135 current_npc_text = pTmpBuf2.data();
4240 goto LABEL_45; 4136 v16 = (GUIButton *)pInString;
4137 goto LABEL_49;
4241 } 4138 }
4242 v21 = v20 - 1; 4139 v21 = v20 - 1;
4243 if ( !v21 ) 4140 if ( !v21 )
4244 { 4141 {
4245 v23 = v58->evt_C; 4142 v23 = v58->evt_C;