comparison Party.cpp @ 1297:5450af4f57ef

moving files mm7_x ending
author Ritor1
date Wed, 19 Jun 2013 17:06:58 +0600
parents c423f946dc99
children 0665a061132b
comparison
equal deleted inserted replaced
1296:c423f946dc99 1297:5450af4f57ef
19 19
20 #include "mm7_data.h" 20 #include "mm7_data.h"
21 #include "MM7.h" 21 #include "MM7.h"
22 #include "Outdoor.h" 22 #include "Outdoor.h"
23 #include "Indoor.h" 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 28 #include "ObjectList.h"
29 29
30 Party *pParty; // idb 30 Party *pParty; // idb
31 31
32 struct ActionQueue *pPartyActionQueue = new ActionQueue; 32 struct ActionQueue *pPartyActionQueue = new ActionQueue;
33 33
1209 ++v6; 1209 ++v6;
1210 } 1210 }
1211 while ( v6 <= &pParty->pPlayers[3] ); 1211 while ( v6 <= &pParty->pPlayers[3] );
1212 pParty->UpdatePlayersAndHirelingsEmotions(); 1212 pParty->UpdatePlayersAndHirelingsEmotions();
1213 } 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
1214 //----- (0047752B) -------------------------------------------------------- 1260 //----- (0047752B) --------------------------------------------------------
1215 int __cdecl GetPartyReputation() 1261 int __cdecl GetPartyReputation()
1216 { 1262 {
1217 DDM_DLV_Header *v0; // ebx@1 1263 DDM_DLV_Header *v0; // ebx@1
1218 signed int v1; // esi@3 1264 signed int v1; // esi@3
1264 } 1310 }
1265 } 1311 }
1266 } 1312 }
1267 } 1313 }
1268 } 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 }