Mercurial > mm7
comparison Party.cpp @ 1306:13b7be8b06a0
Слияние
author | Ritor1 |
---|---|
date | Sun, 23 Jun 2013 14:27:57 +0600 |
parents | 5450af4f57ef |
children | 0665a061132b |
comparison
equal
deleted
inserted
replaced
1305:1ab9bff65f01 | 1306:13b7be8b06a0 |
---|---|
17 #include "GUIWindow.h" | 17 #include "GUIWindow.h" |
18 #include "texts.h" | 18 #include "texts.h" |
19 | 19 |
20 #include "mm7_data.h" | 20 #include "mm7_data.h" |
21 #include "MM7.h" | 21 #include "MM7.h" |
22 | 22 #include "Outdoor.h" |
23 | 23 #include "Indoor.h" |
24 | 24 #include "Texture.h" |
25 | 25 #include "LOD.h" |
26 | 26 #include "Sprites.h" |
27 | 27 #include "SpriteObject.h" |
28 #include "ObjectList.h" | |
28 | 29 |
29 Party *pParty; // idb | 30 Party *pParty; // idb |
30 | 31 |
31 struct ActionQueue *pPartyActionQueue = new ActionQueue; | 32 struct ActionQueue *pPartyActionQueue = new ActionQueue; |
32 | 33 |
1150 pPlayer->sMana = 0; | 1151 pPlayer->sMana = 0; |
1151 UpdatePlayersAndHirelingsEmotions(); | 1152 UpdatePlayersAndHirelingsEmotions(); |
1152 } | 1153 } |
1153 pParty->days_played_without_rest = 0; | 1154 pParty->days_played_without_rest = 0; |
1154 } | 1155 } |
1156 //----- (004938D1) -------------------------------------------------------- | |
1157 void __fastcall Rest(unsigned int uHoursToSleep) | |
1158 { | |
1159 unsigned int v1; // esi@1 | |
1160 double v2; // st7@3 | |
1161 Player **v3; // esi@3 | |
1162 | |
1163 v1 = uHoursToSleep; | |
1164 if ( uHoursToSleep > 240 ) | |
1165 InitializeActors(); | |
1166 v2 = (double)(7680 * v1) * 0.033333335; | |
1167 pParty->uTimePlayed += (signed __int64)v2; | |
1168 v3 = &pPlayers[1]; | |
1169 do | |
1170 { | |
1171 (*v3)->Recover((signed __int64)v2); | |
1172 ++v3; | |
1173 } | |
1174 while ( (signed int)v3 <= (signed int)&pPlayers[4] ); | |
1175 _494035_timed_effects__water_walking_damage__etc(); | |
1176 } | |
1177 //----- (004B1BDB) -------------------------------------------------------- | |
1178 void __stdcall RestAndHeal(__int64 uNumMinutes) | |
1179 { | |
1180 signed __int64 v1; // ST2C_8@1 | |
1181 signed __int64 v2; // qax@1 | |
1182 signed __int64 v3; // ST1C_8@1 | |
1183 unsigned __int64 v4; // qax@1 | |
1184 unsigned int v5; // ebx@1 | |
1185 Player *v6; // ebx@1 | |
1186 | |
1187 pParty->pHirelings[0].bHasUsedTheAbility = 0; | |
1188 pParty->pHirelings[1].bHasUsedTheAbility = 0; | |
1189 pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); | |
1190 v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); | |
1191 v2 = v1 / 60 / 60; | |
1192 v3 = v2; | |
1193 v4 = (unsigned int)v2 / 0x18; | |
1194 v5 = (unsigned int)(v4 / 7) >> 2; | |
1195 pParty->uCurrentTimeSecond = v1 % 60; | |
1196 pParty->uCurrentMinute = v1 / 60 % 60; | |
1197 pParty->uCurrentHour = v3 % 24; | |
1198 pParty->uCurrentMonthWeek = v4 / 7 & 3; | |
1199 pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; | |
1200 pParty->uCurrentMonth = v5 % 0xC; | |
1201 pParty->uCurrentYear = v5 / 0xC + game_starting_year; | |
1202 pParty->RestAndHeal(); | |
1203 dword_507B94 = 1; | |
1204 v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay; | |
1205 do | |
1206 { | |
1207 v6->uTimeToRecovery = 0; | |
1208 memset(&v6->uTimeToRecovery, 0, 4u); | |
1209 ++v6; | |
1210 } | |
1211 while ( v6 <= &pParty->pPlayers[3] ); | |
1212 pParty->UpdatePlayersAndHirelingsEmotions(); | |
1213 } | |
1214 //----- (0041F5BE) -------------------------------------------------------- | |
1215 void __cdecl Sleep6Hours() | |
1216 { | |
1217 if ( _506F18_num_hours_to_sleep < 6 ) | |
1218 { | |
1219 pParty->pPlayers[3].SetAsleep(false); | |
1220 pParty->pPlayers[2].SetAsleep(false); | |
1221 pParty->pPlayers[1].SetAsleep(false); | |
1222 pParty->pPlayers[0].SetAsleep(false); | |
1223 if ( _506F18_num_hours_to_sleep ) | |
1224 { | |
1225 Rest(_506F18_num_hours_to_sleep); | |
1226 _506F18_num_hours_to_sleep = 0; | |
1227 LoadActualSkyFrame(); | |
1228 } | |
1229 if ( dword_506F14 == 2 ) | |
1230 { | |
1231 pGUIWindow_CurrentMenu->Release(); | |
1232 pEventTimer->Resume(); | |
1233 if ( pTexture_RestUI_CurrentSkyFrame ) | |
1234 pTexture_RestUI_CurrentSkyFrame->Release(); | |
1235 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
1236 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
1237 pTexture_RestUI_CurrentHourglassFrame = 0; | |
1238 pTexture_RestUI_CurrentSkyFrame = 0; | |
1239 pIcons_LOD->_4114F2(); | |
1240 pIcons_LOD->SyncLoadedFilesCount(); | |
1241 pCurrentScreen = SCREEN_GAME; | |
1242 viewparams->bRedrawGameUI = 1; | |
1243 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1244 { | |
1245 pOutdoor->UpdateSunlightVectors(); | |
1246 pOutdoor->UpdateFog(); | |
1247 } | |
1248 } | |
1249 dword_506F14 = 0; | |
1250 } | |
1251 else | |
1252 { | |
1253 Rest(6u); | |
1254 _506F18_num_hours_to_sleep -= 6; | |
1255 LoadActualSkyFrame(); | |
1256 } | |
1257 viewparams->bRedrawGameUI = 1; | |
1258 } | |
1259 | |
1260 //----- (0047752B) -------------------------------------------------------- | |
1261 int __cdecl GetPartyReputation() | |
1262 { | |
1263 DDM_DLV_Header *v0; // ebx@1 | |
1264 signed int v1; // esi@3 | |
1265 | |
1266 v0 = &pOutdoor->ddm; | |
1267 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) | |
1268 v0 = &pIndoor->dlv; | |
1269 v1 = 0; | |
1270 if ( CheckHiredNPCSpeciality(Pirate) ) | |
1271 v1 += 5; | |
1272 if ( CheckHiredNPCSpeciality(Burglar) ) | |
1273 v1 += 5; | |
1274 if ( CheckHiredNPCSpeciality(Gypsy) ) | |
1275 v1 += 5; | |
1276 if ( CheckHiredNPCSpeciality(Duper) ) | |
1277 v1 += 5; | |
1278 if ( CheckHiredNPCSpeciality(FallenWizard) ) | |
1279 v1 += 5; | |
1280 return v1 + v0->uReputation; | |
1281 } | |
1282 //----- (004269A2) -------------------------------------------------------- | |
1283 void __fastcall GivePartyExp(unsigned int pEXPNum) | |
1284 { | |
1285 signed int pActivePlayerCount; // ecx@1 | |
1286 int pLearningPercent; // eax@13 | |
1287 | |
1288 pActivePlayerCount = 0; | |
1289 for ( uint i = 0; i < 4; ++i ) | |
1290 { | |
1291 if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] ) | |
1292 pActivePlayerCount ++; | |
1293 } | |
1294 if ( pActivePlayerCount ) | |
1295 { | |
1296 pEXPNum = pEXPNum / pActivePlayerCount; | |
1297 for ( uint i = 0; i < 4; ++i ) | |
1298 { | |
1299 if ( !pParty->pPlayers[i].pConditions[13] && !pParty->pPlayers[i].pConditions[14] && !pParty->pPlayers[i].pConditions[15] && !pParty->pPlayers[i].pConditions[16] ) | |
1300 { | |
1301 if ( pEXPNum ) | |
1302 { | |
1303 pLearningPercent = pParty->pPlayers[i].GetLearningPercent(); | |
1304 pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100; | |
1305 pParty->pPlayers[i].uExperience += pEXPNum; | |
1306 if ( pParty->pPlayers[i].uExperience > 4000000000i64 ) | |
1307 { | |
1308 pParty->pPlayers[i].uExperience = 0; | |
1309 } | |
1310 } | |
1311 } | |
1312 } | |
1313 } | |
1314 } | |
1315 //----- (00420C05) -------------------------------------------------------- | |
1316 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) | |
1317 { | |
1318 unsigned int v2; // edi@1 | |
1319 int v3; // ebp@1 | |
1320 unsigned int v4; // esi@1 | |
1321 int v5; // ecx@6 | |
1322 NPCData *v6; // eax@6 | |
1323 signed int v7; // edx@8 | |
1324 signed int v8; // ebx@10 | |
1325 char *v9; // edi@11 | |
1326 signed int v10; // ecx@17 | |
1327 int v11; // eax@21 | |
1328 NPCData *v12; // ecx@21 | |
1329 unsigned int v13; // ecx@23 | |
1330 signed int v14; // [sp+Ch] [bp-4h]@6 | |
1331 | |
1332 v2 = 0; | |
1333 v3 = 0; | |
1334 v4 = uNumGold; | |
1335 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal ) | |
1336 { | |
1337 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) | |
1338 { | |
1339 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! | |
1340 } | |
1341 else | |
1342 { | |
1343 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) | |
1344 pTmpBuf2[0] = 0; | |
1345 } | |
1346 } | |
1347 else | |
1348 { | |
1349 v14 = 0; | |
1350 v5 = 0; | |
1351 v6 = pParty->pHirelings; | |
1352 do | |
1353 { | |
1354 if ( v6->pName ) | |
1355 { | |
1356 v7 = v14++; | |
1357 pTmpBuf[v7] = v5; | |
1358 } | |
1359 ++v6; | |
1360 ++v5; | |
1361 } | |
1362 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
1363 v8 = 0; | |
1364 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
1365 { | |
1366 v9 = (char *)pNPCStats->pNewNPCData; | |
1367 do | |
1368 { | |
1369 if ( v9[8] & 0x80 | |
1370 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName)) | |
1371 && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) ) | |
1372 { | |
1373 v10 = v14++; | |
1374 pTmpBuf[v10] = v8 + 2; | |
1375 } | |
1376 ++v8; | |
1377 v9 += 76; | |
1378 } | |
1379 while ( v8 < (signed int)pNPCStats->uNumNewNPCs ); | |
1380 v2 = 0; | |
1381 } | |
1382 if ( v14 > 0 ) | |
1383 { | |
1384 do | |
1385 { | |
1386 v11 = (unsigned __int8)pTmpBuf[v2]; | |
1387 v12 = &pNPCStats->pNPCData[v11 + 499]; | |
1388 if ( (unsigned __int8)pTmpBuf[v2] < 2 ) | |
1389 v12 = &pParty->pHirelings[v11]; | |
1390 v13 = v12->uProfession; | |
1391 if ( v13 ) | |
1392 v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); | |
1393 ++v2; | |
1394 } | |
1395 while ( (signed int)v2 < v14 ); | |
1396 } | |
1397 if ( CheckHiredNPCSpeciality(Factor) ) | |
1398 v4 += (signed int)(10 * v4) / 100; | |
1399 if ( CheckHiredNPCSpeciality(Banker) ) | |
1400 v4 += (signed int)(20 * v4) / 100; | |
1401 if ( CheckHiredNPCSpeciality(Pirate) ) | |
1402 v4 += (signed int)(10 * v4) / 100; | |
1403 if ( v3 ) | |
1404 { | |
1405 v3 = (signed int)(v4 * v3 / 100) / 100; | |
1406 if ( v3 < 1 ) | |
1407 v3 = 1; | |
1408 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)! | |
1409 } | |
1410 else | |
1411 { | |
1412 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold! | |
1413 } | |
1414 v2 = 0; | |
1415 } | |
1416 pParty->uNumGold += v4 - v3; | |
1417 pUIAnim_Gold->uAnimTime = v2; | |
1418 pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; | |
1419 if ( pTmpBuf2[0] ) | |
1420 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
1421 pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2); | |
1422 } | |
1423 //----- (00421B2C) -------------------------------------------------------- | |
1424 bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem() | |
1425 { | |
1426 unsigned int v0; // eax@2 | |
1427 Texture *v1; // ebx@2 | |
1428 int v2; // eax@3 | |
1429 Player *v3; // esi@5 | |
1430 int v4; // eax@6 | |
1431 unsigned __int16 v5; // dx@11 | |
1432 signed int v6; // eax@11 | |
1433 char *v7; // edi@12 | |
1434 __int16 v8; // ax@16 | |
1435 SpriteObject a1; // [sp+4h] [bp-78h]@11 | |
1436 int v11; // [sp+74h] [bp-8h]@2 | |
1437 int v12; // [sp+78h] [bp-4h]@5 | |
1438 | |
1439 if ( !pParty->pPickedItem.uItemID ) | |
1440 return 1; | |
1441 v0 = pIcons_LOD->LoadTexture( | |
1442 pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, | |
1443 TEXTURE_16BIT_PALETTE); | |
1444 v1 = pIcons_LOD->GetTexture(v0); | |
1445 v11 = areWeLoadingTexture; | |
1446 if ( uActiveCharacter | |
1447 && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) | |
1448 { | |
1449 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); | |
1450 pMouse->RemoveHoldingItem(); | |
1451 } | |
1452 else | |
1453 { | |
1454 v12 = 0; | |
1455 v3 = pParty->pPlayers; | |
1456 while ( v3 <= &pParty->pPlayers[3] ) | |
1457 { | |
1458 v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); | |
1459 if ( v4 ) | |
1460 { | |
1461 memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); | |
1462 pMouse->RemoveHoldingItem(); | |
1463 break; | |
1464 } | |
1465 ++v12; | |
1466 ++v3; | |
1467 } | |
1468 if ( v12 == 4 ) | |
1469 { | |
1470 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
1471 v6 = 0; | |
1472 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
1473 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1474 { | |
1475 LOWORD(v6) = 0; | |
1476 } | |
1477 else | |
1478 { | |
1479 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
1480 while ( v5 != *(short *)v7 ) | |
1481 { | |
1482 ++v6; | |
1483 v7 += 56; | |
1484 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
1485 { | |
1486 LOWORD(v6) = 0; | |
1487 break; | |
1488 } | |
1489 } | |
1490 } | |
1491 a1.spell_caster_pid = OBJECT_Player; | |
1492 a1.uObjectDescID = v6; | |
1493 a1.vPosition.y = pParty->vPosition.y; | |
1494 a1.vPosition.x = pParty->vPosition.x; | |
1495 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
1496 a1.uSoundID = 0; | |
1497 a1.uFacing = 0; | |
1498 a1.uAttributes = 8; | |
1499 v8 = pIndoor->GetSector( | |
1500 pParty->vPosition.x, | |
1501 pParty->vPosition.y, | |
1502 pParty->sEyelevel + pParty->vPosition.z); | |
1503 a1.uSpriteFrameID = 0; | |
1504 a1.uSectorID = v8; | |
1505 memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); | |
1506 a1.Create(pParty->sRotationY, 184, 200, 0); | |
1507 pMouse->RemoveHoldingItem(); | |
1508 } | |
1509 } | |
1510 if ( !v11 ) | |
1511 { | |
1512 v1->Release(); | |
1513 pIcons_LOD->SyncLoadedFilesCount(); | |
1514 } | |
1515 return 1; | |
1516 } |