comparison Player.cpp @ 1685:2a309997c42f

Player::StealFromShop started cleanup, fixing a few errors caused by not commiting everything
author Grumpy7
date Sat, 21 Sep 2013 12:38:43 +0200
parents f84b8b2a875c
children df30a0c901e5
comparison
equal deleted inserted replaced
1684:f84b8b2a875c 1685:2a309997c42f
58 {{14, 30, 1, 2}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {9, 20, 1, 1}} 58 {{14, 30, 1, 2}, {11, 25, 1, 1}, {11, 25, 1, 1}, {14, 30, 1, 2}, { 7, 15, 2, 1}, { 7, 15, 2, 1}, {9, 20, 1, 1}}
59 }; 59 };
60 60
61 61
62 62
63 std::array<int, 5> StealingMasteryBonuses = {0, 100, 200, 300, 500};
64 std::array<int, 5> StealingRandomBonuses = {-200, -100, 0, 100, 200};
65 std::array<int, 5> StealingEnchantmentBonusForSkill = {0, 2, 4, 6, 10};
63 66
64 67
65 68
66 // available skills per class ( 9 classes X 37 skills ) 69 // available skills per class ( 9 classes X 37 skills )
67 // 0 - not available 70 // 0 - not available
2020 int v10; // eax@8 2023 int v10; // eax@8
2021 int v11; // edi@12 2024 int v11; // edi@12
2022 bool result; // eax@13 2025 bool result; // eax@13
2023 2026
2024 if ( !itemToSteal 2027 if ( !itemToSteal
2025 || this->pConditions[16] 2028 || this->IsEradicated()
2026 || this->pConditions[14] 2029 || this->IsDead()
2027 || this->pConditions[15] 2030 || this->IsPertified()
2028 || this->pConditions[4] 2031 || this->pConditions[Condition_Drunk]
2029 || this->pConditions[13] 2032 || this->IsUnconcious()
2030 || this->pConditions[2] ) 2033 || this->IsAsleep() )
2031 { 2034 {
2032 result = 0; 2035 result = 0;
2033 } 2036 }
2034 else 2037 else
2035 { 2038 {
2038 v8 = SkillToMastery(v6); 2041 v8 = SkillToMastery(v6);
2039 itemvalue = itemToSteal->GetValue(); 2042 itemvalue = itemToSteal->GetValue();
2040 v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType; 2043 v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType;
2041 if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 ) 2044 if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 )
2042 itemvalue *= 3; 2045 itemvalue *= 3;
2043 v11 = dword_4EDEB4[rand() % 100 / 20] + v7 * dword_4EDEA0[v8]; 2046 v11 = StealingRandomBonuses[rand() % 100 / 20] + v7 * StealingMasteryBonuses[v8];
2044 *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0); 2047 *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0);
2045 if ( rand() % 100 >= 5 ) 2048 if ( rand() % 100 >= 5 )
2046 { 2049 {
2047 if ( *a6 > v11 ) 2050 if ( *a6 > v11 )
2048 result = *a6 - v11 < 500; 2051 result = *a6 - v11 < 500;
2106 pActors[uActorID].SetRandomGoldIfTheresNoItem(); 2109 pActors[uActorID].SetRandomGoldIfTheresNoItem();
2107 v6 = v4->pActiveSkills[34]; 2110 v6 = v4->pActiveSkills[34];
2108 v7 = v6 & 0x3F; 2111 v7 = v6 & 0x3F;
2109 v8 = SkillToMastery(v6); 2112 v8 = SkillToMastery(v6);
2110 v9 = rand(); 2113 v9 = rand();
2111 v28 = 4 * v8; 2114 v30 = StealingMasteryBonuses[v8];
2112 v30 = dword_4EDEA0[v8]; 2115 v29 = StealingRandomBonuses[v9 % 100 / 20];
2113 v29 = dword_4EDEB4[v9 % 100 / 20];
2114 v10 = v5->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); 2116 v10 = v5->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation);
2115 if ( rand() % 100 < 5 || v10 > v29 + v7 * v30 || (_steal_perma = 2, BYTE2(v5->uAttributes) & 8) ) 2117 if ( rand() % 100 < 5 || v10 > v29 + v7 * v30 || (_steal_perma = 2, BYTE2(v5->uAttributes) & 8) )
2116 { 2118 {
2117 Actor::AggroSurroundingPeasants(uActorID, 1); 2119 Actor::AggroSurroundingPeasants(uActorID, 1);
2118 _steal_perma = 0; 2120 _steal_perma = 0;
2130 if ( v7 > 0 ) 2132 if ( v7 > 0 )
2131 { 2133 {
2132 do 2134 do
2133 { 2135 {
2134 --v7; 2136 --v7;
2135 v19 += rand() % dword_4EDEC4[v28 / 4] + 1; 2137 v19 += rand() % StealingEnchantmentBonusForSkill[v8] + 1;
2136 } 2138 }
2137 while ( v7 ); 2139 while ( v7 );
2138 } 2140 }
2139 if ( pItemsTable->pItems[v5->array_000234[3].uItemID].uEquipType != 18 ) 2141 if ( pItemsTable->pItems[v5->array_000234[3].uItemID].uEquipType != 18 )
2140 return _steal_perma; 2142 return _steal_perma;
7947 bool Player::IsParalyzed() 7949 bool Player::IsParalyzed()
7948 { 7950 {
7949 return pConditions[Condition_Paralyzed] != 0; 7951 return pConditions[Condition_Paralyzed] != 0;
7950 } 7952 }
7951 7953
7954 bool Player::IsDrunk()
7955 {
7956 return pConditions[Condition_Drunk] != 0;
7957 }
7958
7952 void Player::SetCursed( bool state ) 7959 void Player::SetCursed( bool state )
7953 { 7960 {
7954 pConditions[Condition_Cursed] = state; 7961 pConditions[Condition_Cursed] = state;
7955 } 7962 }
7956 7963