comparison Player.cpp @ 1329:27a699abee51

Слияние
author Ritor1
date Tue, 02 Jul 2013 14:08:40 +0600
parents d9e4c0bbb2d2
children 1e35cfed7928 1434b36f4bdb
comparison
equal deleted inserted replaced
1328:8ed112935a48 1329:27a699abee51
89 unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; 89 unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0};
90 unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0}; 90 unsigned char pBaseManaByClass[12] = { 0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0};
91 unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; 91 unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3};
92 unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6}; 92 unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6};
93 93
94 unsigned char pConditionStrengthMultiplier[19] = {100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}; 94 unsigned char pConditionAttributeModifier[7][19] =
95 unsigned char pConditionIntelligenceMultiplier[19] = {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}; 95 {{100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Might
96 unsigned char pConditionWillpowerMultiplier[19] = {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}; 96 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Intelligence
97 unsigned char pConditionEnduranceMultiplier[19] = {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}; 97 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Willpower
98 unsigned char pConditionAccuracyMultiplier[19] = {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}; 98 {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Endurance
99 unsigned char pConditionSpeedMultiplier[19] = {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}; 99 {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Accuracy
100 unsigned char pConditionLuckMultiplier[19] = {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; 100 {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Speed
101 101 {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}}; //Luck
102 unsigned char pAgeingStrengthMultiplier[4] = {100, 75, 40, 10}; 102
103 unsigned char pAgeingIntelligenceMultiplier[4] = {100, 150, 100, 10}; 103 unsigned char pAgingAttributeModifier[7][4] =
104 unsigned char pAgeingWillpowerMultiplier[4] = {100, 150, 100, 10}; 104 {{100, 75, 40, 10}, //Might
105 unsigned char pAgeingEnduranceMultiplier[4] = {100, 75, 40, 10}; 105 {100, 150, 100, 10}, //Intelligence
106 unsigned char pAgeingAccuracyMultiplier[4] = {100, 100, 40, 10}; 106 {100, 150, 100, 10}, //Willpower
107 unsigned char pAgeingSpeedMultiplier[4] = {100, 100, 40, 10}; 107 {100, 75, 40, 10}, //Endurance
108 unsigned char pAgeingLuckMultiplier[4] = {100, 100, 100, 100}; 108 {100, 100, 40, 10}, //Accuracy
109 {100, 100, 40, 10}, //Speed
110 {100, 100, 100, 100}}; //Luck
109 111
110 signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; 112 signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF};
111 113
112 std::array<unsigned int, 18> pConditionImportancyTable = {{16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}}; 114 std::array<unsigned int, 18> pConditionImportancyTable = {{16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}};
113 115
420 422
421 if ( this->sHealth < GetMaxHealth() || this->sMana < GetMaxMana() ) 423 if ( this->sHealth < GetMaxHealth() || this->sMana < GetMaxMana() )
422 { 424 {
423 return 1; 425 return 1;
424 } 426 }
425 else if (GetMajorConditionIdx() == 18) 427 else if (GetMajorConditionIdx() == Condition_Good)
426 { 428 {
427 return 0; 429 return 0;
428 } 430 }
429 else if (GetMajorConditionIdx() == 17 && (v2 == 78 || v2 > 80) && v2 <= 82) 431 else if (GetMajorConditionIdx() == Condition_Zombie && (v2 == 78 || v2 == 81 || v2 == 82))
430 { 432 {
431 return 0; 433 return 0;
432 } 434 }
433 else 435 else
434 { 436 {
2400 } 2402 }
2401 2403
2402 //----- (0048C93C) -------------------------------------------------------- 2404 //----- (0048C93C) --------------------------------------------------------
2403 int Player::GetActualMight() 2405 int Player::GetActualMight()
2404 { 2406 {
2405 Player *v1; // esi@1 2407 return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH);
2406 unsigned int v2; // eax@1
2407 signed int v3; // ecx@1
2408 signed int v4; // ebx@4
2409 int v5; // edi@5
2410 int v6; // ST14_4@5
2411
2412 v1 = this;
2413 v2 = this->sAgeModifier + GetBaseAge();
2414 v3 = 0;
2415 while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
2416 {
2417 ++v3;
2418 if ( v3 >= 4 )
2419 {
2420 v4 = 100;
2421 goto LABEL_5;
2422 }
2423 }
2424 v4 = pAgeingStrengthMultiplier[v3];
2425 LABEL_5:
2426 v5 = pConditionStrengthMultiplier[GetMajorConditionIdx()];
2427 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH, 0);
2428 return v5 * v4 * v1->uMight / 100 / 100 + GetMagicalBonus((CHARACTER_ATTRIBUTE_TYPE)0) + v6 + v1->uMightBonus;
2429 } 2408 }
2430 2409
2431 //----- (0048C9C2) -------------------------------------------------------- 2410 //----- (0048C9C2) --------------------------------------------------------
2432 int Player::GetActualIntelligence() 2411 int Player::GetActualIntelligence()
2433 { 2412 {
2434 Player *v1; // esi@1 2413 return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE);
2435 unsigned int sAge; // eax@1
2436 signed int uAgeLevel; // ecx@1
2437 signed int v4; // ebx@4
2438 int v5; // edi@5
2439 int v6; // ebp@5
2440
2441 v1 = this;
2442 sAge = this->sAgeModifier + GetBaseAge();
2443 uAgeLevel = 0;
2444 while ( (signed int)sAge >= (signed int)pAgeingTable[uAgeLevel] )
2445 {
2446 ++uAgeLevel;
2447 if ( uAgeLevel >= 4 )
2448 {
2449 v4 = 100;
2450 goto LABEL_5;
2451 }
2452 }
2453 v4 = pAgeingIntelligenceMultiplier[uAgeLevel];
2454 LABEL_5:
2455 v5 = pConditionIntelligenceMultiplier[GetMajorConditionIdx()];
2456 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE, 0);
2457 return v5 * v4 * v1->uIntelligence / 100 / 100
2458 + GetMagicalBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE)
2459 + v6
2460 + v1->uIntelligenceBonus;
2461 } 2414 }
2462 2415
2463 //----- (0048CA3F) -------------------------------------------------------- 2416 //----- (0048CA3F) --------------------------------------------------------
2464 int Player::GetActualWillpower() 2417 int Player::GetActualWillpower()
2465 { 2418 {
2466 int v5; // edi@5 2419 return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER);
2467
2468 uint uActualAge = GetBaseAge() + sAgeModifier;
2469 uint uAgeingMultiplier = 100;
2470 for (uint i = 0; i < 4; ++i)
2471 if (uActualAge >= pAgeingTable[i])
2472 uAgeingMultiplier = pAgeingWillpowerMultiplier[i];
2473 else break;
2474
2475 v5 = pConditionWillpowerMultiplier[GetMajorConditionIdx()];
2476 return v5 * uAgeingMultiplier * uWillpower / 100 / 100
2477 + GetMagicalBonus(CHARACTER_ATTRIBUTE_WILLPOWER)
2478 + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER, 0)
2479 + uWillpowerBonus;
2480 } 2420 }
2481 2421
2482 //----- (0048CABC) -------------------------------------------------------- 2422 //----- (0048CABC) --------------------------------------------------------
2483 int Player::GetActualEndurance() 2423 int Player::GetActualEndurance()
2484 { 2424 {
2485 uint uActualAge = GetBaseAge() + sAgeModifier; 2425 return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE);
2486 uint uAgeingMultiplier = 100;
2487 for (uint i = 0; i < 4; ++i)
2488 if (uActualAge >= pAgeingTable[i])
2489 uAgeingMultiplier = pAgeingEnduranceMultiplier[i];
2490 else break;
2491
2492 auto uConditionMult = pConditionEnduranceMultiplier[GetMajorConditionIdx()];
2493 auto uItemBonus = GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0);
2494 return uConditionMult * uAgeingMultiplier * uEndurance / 100 / 100
2495 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ENDURANCE)
2496 + uItemBonus
2497 + uEnduranceBonus;
2498 } 2426 }
2499 2427
2500 //----- (0048CB39) -------------------------------------------------------- 2428 //----- (0048CB39) --------------------------------------------------------
2501 int Player::GetActualAccuracy() 2429 int Player::GetActualAccuracy()
2502 { 2430 {
2503 Player *v1; // esi@1 2431 return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY);
2504 unsigned int v2; // eax@1
2505 signed int v3; // ecx@1
2506 signed int v4; // ebx@4
2507 int v5; // edi@5
2508 int v6; // ebp@5
2509
2510 v1 = this;
2511 v2 = this->sAgeModifier + GetBaseAge();
2512 v3 = 0;
2513 while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
2514 {
2515 ++v3;
2516 if ( v3 >= 4 )
2517 {
2518 v4 = 100;
2519 goto LABEL_5;
2520 }
2521 }
2522 v4 = pAgeingAccuracyMultiplier[v3];
2523 LABEL_5:
2524 v5 = pConditionAccuracyMultiplier[GetMajorConditionIdx()];
2525 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY, 0);
2526 return v5 * v4 * v1->uAccuracy / 100 / 100
2527 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ACCURACY)
2528 + v6
2529 + v1->uAccuracyBonus;
2530 } 2432 }
2531 2433
2532 //----- (0048CBB6) -------------------------------------------------------- 2434 //----- (0048CBB6) --------------------------------------------------------
2533 int Player::GetActualSpeed() 2435 int Player::GetActualSpeed()
2534 { 2436 {
2535 Player *v1; // esi@1 2437 return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED);
2536 unsigned int v2; // eax@1
2537 signed int v3; // ecx@1
2538 signed int v4; // ebx@4
2539 int v5; // edi@5
2540 int v6; // ebp@5
2541
2542 v1 = this;
2543 v2 = this->sAgeModifier + GetBaseAge();
2544 v3 = 0;
2545 while ( (signed int)v2 >= (signed int)pAgeingTable[v3] )
2546 {
2547 ++v3;
2548 if ( v3 >= 4 )
2549 {
2550 v4 = 100;
2551 goto LABEL_5;
2552 }
2553 }
2554 v4 = pAgeingSpeedMultiplier[v3];
2555 LABEL_5:
2556 v5 = pConditionSpeedMultiplier[GetMajorConditionIdx()];
2557 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED, 0);
2558 return v5 * v4 * v1->uSpeed / 100 / 100
2559 + GetMagicalBonus(CHARACTER_ATTRIBUTE_SPEED)
2560 + v6
2561 + v1->uSpeedBonus;
2562 } 2438 }
2563 2439
2564 //----- (0048CC33) -------------------------------------------------------- 2440 //----- (0048CC33) --------------------------------------------------------
2565 int Player::GetActualLuck() 2441 int Player::GetActualLuck()
2566 { 2442 {
2567 signed int curr_age; // eax@7
2568 signed int i; // ecx@7
2569 signed int age_luck_pc; // ebx@10
2570 int condition_luck_pc; // edi@11
2571 int items_luck_bonus; // ebp@11
2572 signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1 2443 signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1
2573 signed int magic_luck_bonus; // [sp+10h] [bp-4h]@1
2574 int full_luck;
2575 2444
2576 npc_luck_bonus = 0; 2445 npc_luck_bonus = 0;
2577 if ( CheckHiredNPCSpeciality(Fool) ) 2446 if ( CheckHiredNPCSpeciality(Fool) )
2578 npc_luck_bonus = 5; 2447 npc_luck_bonus = 5;
2579 if ( CheckHiredNPCSpeciality(ChimneySweep) ) 2448 if ( CheckHiredNPCSpeciality(ChimneySweep) )
2580 npc_luck_bonus += 20; 2449 npc_luck_bonus += 20;
2581 if ( CheckHiredNPCSpeciality(Psychic) ) 2450 if ( CheckHiredNPCSpeciality(Psychic) )
2582 npc_luck_bonus += 10; 2451 npc_luck_bonus += 10;
2583 curr_age = sAgeModifier + GetBaseAge(); 2452
2584 i = 0; 2453 return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK)
2585 while ( curr_age >= pAgeingTable[i] ) 2454 + npc_luck_bonus;
2586 { 2455 }
2587 ++i; 2456
2588 if ( i >= 4 ) 2457 //----- (new function) --------------------------------------------------------
2458 int Player::GetActualAttribute( CHARACTER_ATTRIBUTE_TYPE attrId )
2459 {
2460 unsigned __int16 attrValue = 0;
2461 unsigned __int16 attrBonus = 0;
2462 switch (attrId)
2463 {
2464 case CHARACTER_ATTRIBUTE_STRENGTH:
2465 attrValue = uMight;
2466 attrBonus = uMightBonus;
2467 break;
2468 case CHARACTER_ATTRIBUTE_INTELLIGENCE:
2469 attrValue = uIntelligence;
2470 attrBonus = uIntelligenceBonus;
2471 break;
2472 case CHARACTER_ATTRIBUTE_WILLPOWER:
2473 attrValue = uWillpower;
2474 attrBonus = uWillpowerBonus;
2475 break;
2476 case CHARACTER_ATTRIBUTE_ENDURANCE:
2477 attrValue = uEndurance;
2478 attrBonus = uEnduranceBonus;
2479 break;
2480 case CHARACTER_ATTRIBUTE_ACCURACY:
2481 attrValue = uAccuracy;
2482 attrBonus = uAccuracyBonus;
2483 break;
2484 case CHARACTER_ATTRIBUTE_SPEED:
2485 attrValue = uSpeed;
2486 attrBonus = uSpeedBonus;
2487 break;
2488 case CHARACTER_ATTRIBUTE_LUCK:
2489 attrValue = uLuck;
2490 attrBonus = uLuckBonus;
2491 break;
2492 default:
2493 return 0;
2494 }
2495
2496 uint uActualAge = this->sAgeModifier + GetBaseAge();
2497 uint uAgeingMultiplier = 100;
2498 for (uint i = 0; i < 4; ++i)
2499 {
2500 if (uActualAge >= pAgeingTable[i])
2501 uAgeingMultiplier = pAgingAttributeModifier[attrId][i];
2502 else
2589 break; 2503 break;
2590 } 2504 }
2591 if (i < 4) 2505
2592 age_luck_pc = pAgeingLuckMultiplier[i]; 2506 auto uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()];
2593 else 2507 int magicBonus = GetMagicalBonus(attrId);
2594 age_luck_pc = 100; 2508 int itemBonus = GetItemsBonus(attrId, 0);
2595 2509 return uConditionMult * uAgeingMultiplier * attrValue / 100 / 100
2596 condition_luck_pc = pConditionLuckMultiplier[GetMajorConditionIdx()]; 2510 + magicBonus
2597 items_luck_bonus = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0); 2511 + magicBonus
2598 magic_luck_bonus = GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK); 2512 + attrBonus;
2599 full_luck = magic_luck_bonus + items_luck_bonus + npc_luck_bonus+ uLuckBonus
2600 + condition_luck_pc * age_luck_pc * uLuck / 100 / 100;
2601 return full_luck;
2602 } 2513 }
2603 2514
2604 //----- (0048CCF5) -------------------------------------------------------- 2515 //----- (0048CCF5) --------------------------------------------------------
2605 int Player::GetActualAttack(int a2) 2516 int Player::GetActualAttack(int a2)
2606 { 2517 {
7922 { 7833 {
7923 v9 = &this->pInventoryItems[i]; 7834 v9 = &this->pInventoryItems[i];
7924 if (v9->uItemID == 615) 7835 if (v9->uItemID == 615)
7925 break; 7836 break;
7926 } 7837 }
7927 if (v9 != NULL || v9->uItemID != 615) 7838 if (v9 != NULL && v9->uItemID != 615)
7928 { 7839 {
7929 v10 = (int)((char *)this + 36 * 138); //originally 36 * v8. the code got to this condition only if v8 was equal to 138 7840 v10 = (int)((char *)this + 36 * 138); //originally 36 * v8. the code got to this condition only if v8 was equal to 138
7930 *(int *)(v10 + 532) = 601; 7841 *(int *)(v10 + 532) = 601;
7931 *(char *)(v10 + 558) = currPlayerId + 1; 7842 *(char *)(v10 + 558) = currPlayerId + 1;
7932 } 7843 }