comparison Player.cpp @ 1325:d9e4c0bbb2d2

GetActual(stat) common code extracted
author Grumpy7
date Tue, 02 Jul 2013 01:15:03 +0200
parents 78f0f74eab1d
children 1e35cfed7928 1434b36f4bdb
comparison
equal deleted inserted replaced
1324:78f0f74eab1d 1325:d9e4c0bbb2d2
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 uint uActualAge = GetBaseAge() + this->sAgeModifier; 2407 return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH);
2406 uint uAgeingMultiplier = 100;
2407 for (uint i = 0; i < 4; ++i)
2408 if (uActualAge >= pAgeingTable[i])
2409 uAgeingMultiplier = pAgeingStrengthMultiplier[i];
2410 else break;
2411
2412 auto uConditionMult = pConditionStrengthMultiplier[GetMajorConditionIdx()];
2413 return uConditionMult * uAgeingMultiplier * uMight / 100 / 100
2414 + GetMagicalBonus(CHARACTER_ATTRIBUTE_STRENGTH)
2415 + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH, 0)
2416 + uMightBonus;
2417 } 2408 }
2418 2409
2419 //----- (0048C9C2) -------------------------------------------------------- 2410 //----- (0048C9C2) --------------------------------------------------------
2420 int Player::GetActualIntelligence() 2411 int Player::GetActualIntelligence()
2421 { 2412 {
2422 uint uActualAge = GetBaseAge() + this->sAgeModifier; 2413 return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE);
2423 uint uAgeingMultiplier = 100;
2424 for (uint i = 0; i < 4; ++i)
2425 if (uActualAge >= pAgeingTable[i])
2426 uAgeingMultiplier = pAgeingIntelligenceMultiplier[i];
2427 else break;
2428
2429 auto uConditionMult = pConditionIntelligenceMultiplier[GetMajorConditionIdx()];
2430 return uConditionMult * uAgeingMultiplier * uIntelligence / 100 / 100
2431 + GetMagicalBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE)
2432 + GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE, 0)
2433 + uIntelligenceBonus;
2434 } 2414 }
2435 2415
2436 //----- (0048CA3F) -------------------------------------------------------- 2416 //----- (0048CA3F) --------------------------------------------------------
2437 int Player::GetActualWillpower() 2417 int Player::GetActualWillpower()
2438 { 2418 {
2439 uint uActualAge = GetBaseAge() + sAgeModifier; 2419 return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER);
2440 uint uAgeingMultiplier = 100;
2441 for (uint i = 0; i < 4; ++i)
2442 if (uActualAge >= pAgeingTable[i])
2443 uAgeingMultiplier = pAgeingWillpowerMultiplier[i];
2444 else break;
2445
2446 auto uConditionMult = pConditionWillpowerMultiplier[GetMajorConditionIdx()];
2447 return uConditionMult * uAgeingMultiplier * uWillpower / 100 / 100
2448 + GetMagicalBonus(CHARACTER_ATTRIBUTE_WILLPOWER)
2449 + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER, 0)
2450 + uWillpowerBonus;
2451 } 2420 }
2452 2421
2453 //----- (0048CABC) -------------------------------------------------------- 2422 //----- (0048CABC) --------------------------------------------------------
2454 int Player::GetActualEndurance() 2423 int Player::GetActualEndurance()
2455 { 2424 {
2456 uint uActualAge = GetBaseAge() + sAgeModifier; 2425 return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE);
2457 uint uAgeingMultiplier = 100;
2458 for (uint i = 0; i < 4; ++i)
2459 if (uActualAge >= pAgeingTable[i])
2460 uAgeingMultiplier = pAgeingEnduranceMultiplier[i];
2461 else break;
2462
2463 auto uConditionMult = pConditionEnduranceMultiplier[GetMajorConditionIdx()];
2464 return uConditionMult * uAgeingMultiplier * uEndurance / 100 / 100
2465 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ENDURANCE)
2466 + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0)
2467 + uEnduranceBonus;
2468 } 2426 }
2469 2427
2470 //----- (0048CB39) -------------------------------------------------------- 2428 //----- (0048CB39) --------------------------------------------------------
2471 int Player::GetActualAccuracy() 2429 int Player::GetActualAccuracy()
2472 { 2430 {
2473 2431 return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY);
2474 uint uActualAge = this->sAgeModifier + GetBaseAge();
2475 uint uAgeingMultiplier = 100;
2476 for (uint i = 0; i < 4; ++i)
2477 if (uActualAge >= pAgeingTable[i])
2478 uAgeingMultiplier = pAgeingAccuracyMultiplier[i];
2479 else break;
2480
2481 auto uConditionMult = pConditionAccuracyMultiplier[GetMajorConditionIdx()];
2482 return uConditionMult * uAgeingMultiplier * uAccuracy / 100 / 100
2483 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ACCURACY)
2484 + GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY, 0)
2485 + uAccuracyBonus;
2486 } 2432 }
2487 2433
2488 //----- (0048CBB6) -------------------------------------------------------- 2434 //----- (0048CBB6) --------------------------------------------------------
2489 int Player::GetActualSpeed() 2435 int Player::GetActualSpeed()
2490 { 2436 {
2491 uint uActualAge = this->sAgeModifier + GetBaseAge(); 2437 return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED);
2492 uint uAgeingMultiplier = 100;
2493 for (uint i = 0; i < 4; ++i)
2494 if (uActualAge >= pAgeingTable[i])
2495 uAgeingMultiplier = pAgeingSpeedMultiplier[i];
2496 else break;
2497
2498 auto uConditionMult = pConditionSpeedMultiplier[GetMajorConditionIdx()];
2499 return uConditionMult * uAgeingMultiplier * uSpeed / 100 / 100
2500 + GetMagicalBonus(CHARACTER_ATTRIBUTE_SPEED)
2501 + GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED, 0)
2502 + uSpeedBonus;
2503 } 2438 }
2504 2439
2505 //----- (0048CC33) -------------------------------------------------------- 2440 //----- (0048CC33) --------------------------------------------------------
2506 int Player::GetActualLuck() 2441 int Player::GetActualLuck()
2507 { 2442 {
2513 if ( CheckHiredNPCSpeciality(ChimneySweep) ) 2448 if ( CheckHiredNPCSpeciality(ChimneySweep) )
2514 npc_luck_bonus += 20; 2449 npc_luck_bonus += 20;
2515 if ( CheckHiredNPCSpeciality(Psychic) ) 2450 if ( CheckHiredNPCSpeciality(Psychic) )
2516 npc_luck_bonus += 10; 2451 npc_luck_bonus += 10;
2517 2452
2453 return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK)
2454 + npc_luck_bonus;
2455 }
2456
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
2518 uint uActualAge = this->sAgeModifier + GetBaseAge(); 2496 uint uActualAge = this->sAgeModifier + GetBaseAge();
2519 uint uAgeingMultiplier = 100; 2497 uint uAgeingMultiplier = 100;
2520 for (uint i = 0; i < 4; ++i) 2498 for (uint i = 0; i < 4; ++i)
2499 {
2521 if (uActualAge >= pAgeingTable[i]) 2500 if (uActualAge >= pAgeingTable[i])
2522 uAgeingMultiplier = pAgeingLuckMultiplier[i]; 2501 uAgeingMultiplier = pAgingAttributeModifier[attrId][i];
2523 else break; 2502 else
2524 2503 break;
2525 auto uConditionMult = pConditionLuckMultiplier[GetMajorConditionIdx()]; 2504 }
2526 return uConditionMult * uAgeingMultiplier * uLuck / 100 / 100 2505
2527 + GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK) 2506 auto uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()];
2528 + GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0) 2507 int magicBonus = GetMagicalBonus(attrId);
2529 + uLuckBonus 2508 int itemBonus = GetItemsBonus(attrId, 0);
2530 + npc_luck_bonus; 2509 return uConditionMult * uAgeingMultiplier * attrValue / 100 / 100
2510 + magicBonus
2511 + magicBonus
2512 + attrBonus;
2531 } 2513 }
2532 2514
2533 //----- (0048CCF5) -------------------------------------------------------- 2515 //----- (0048CCF5) --------------------------------------------------------
2534 int Player::GetActualAttack(int a2) 2516 int Player::GetActualAttack(int a2)
2535 { 2517 {