comparison Player.cpp @ 1559:1f3f01d39300

Player::CanTrainToNextLevel simplified, Player::GetExperienceDisplayColor shortened a bit Player::CalculateIncommingDamage + fixed resistances not working if no resistance bonus (ignored luck bonus)
author Grumpy7
date Sun, 08 Sep 2013 00:35:03 +0200
parents 30db6d265ceb
children a0cd6465ae0d
comparison
equal deleted inserted replaced
1558:30db6d265ceb 1559:1f3f01d39300
1888 } 1888 }
1889 1889
1890 //----- (0048D45A) -------------------------------------------------------- 1890 //----- (0048D45A) --------------------------------------------------------
1891 bool Player::CanTrainToNextLevel() 1891 bool Player::CanTrainToNextLevel()
1892 { 1892 {
1893 int v1; // edx@1 1893 int lvl = this->uLevel;
1894 int v2; // eax@1 1894 int neededExp = ((lvl * (lvl - 1)) / 2 * 1000);
1895 int i; // esi@1
1896
1897 v1 = this->uLevel;
1898 v2 = 0;
1899 for ( i = 0; i < v1; ++i )
1900 v2 += i + 1;
1901 return (signed __int64)this->uExperience >= 1000 * v2;
1902 } 1895 }
1903 1896
1904 //----- (0048D498) -------------------------------------------------------- 1897 //----- (0048D498) --------------------------------------------------------
1905 unsigned int Player::GetExperienceDisplayColor() 1898 unsigned int Player::GetExperienceDisplayColor()
1906 { 1899 {
1907 unsigned int result; // eax@2
1908
1909 if ( CanTrainToNextLevel() ) 1900 if ( CanTrainToNextLevel() )
1910 result = ui_character_bonus_text_color; 1901 return ui_character_bonus_text_color;
1911 else 1902 else
1912 result = ui_character_default_text_color; 1903 return ui_character_default_text_color;
1913 return result;
1914 } 1904 }
1915 1905
1916 //----- (0048D4B3) -------------------------------------------------------- 1906 //----- (0048D4B3) --------------------------------------------------------
1917 int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int amount ) 1907 int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int dmg )
1918 { 1908 {
1919 1909
1920 int resist_value; // edi@8 1910 int resist_value; // edi@8
1921 int player_luck; // eax@21 1911 int player_luck; // eax@21
1922 signed int res_rand_divider; // ebx@2 1912 signed int res_rand_divider; // ebx@2
1923 int armor_skill; // eax@29 1913 int armor_skill; // eax@29
1924 enum CHARACTER_ATTRIBUTE_TYPE player_resist; // [sp-4h] [bp-10h]@9 1914
1925 signed int result_amount_dmg; // [sp+8h] [bp-4h]@17 1915 resist_value = 0;
1926
1927 player_resist=CHARACTER_ATTRIBUTE_STRENGTH;
1928 switch(dmg_type) 1916 switch(dmg_type)
1929 { 1917 {
1930 case DMGT_FIRE: player_resist=CHARACTER_ATTRIBUTE_RESIST_FIRE; break; 1918 case DMGT_FIRE: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); break;
1931 case DMGT_ELECTR: player_resist=CHARACTER_ATTRIBUTE_RESIST_AIR; break; 1919 case DMGT_ELECTR: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); break;
1932 case DMGT_COLD: player_resist=CHARACTER_ATTRIBUTE_RESIST_WATER; break; 1920 case DMGT_COLD: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); break;
1933 case DMGT_3: player_resist=CHARACTER_ATTRIBUTE_RESIST_EARTH; break; 1921 case DMGT_EARTH: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); break;
1934 1922
1935 case DMGT_SPIRIT: player_resist=CHARACTER_ATTRIBUTE_RESIST_SPIRIT;break; 1923 case DMGT_SPIRIT: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_SPIRIT);break;
1936 case DMGT_MIND: player_resist=CHARACTER_ATTRIBUTE_RESIST_MIND; break; 1924 case DMGT_MIND: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); break;
1937 case DMGT_BODY: player_resist=CHARACTER_ATTRIBUTE_RESIST_BODY; break; 1925 case DMGT_BODY: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); break;
1938 } 1926 }
1939 if (player_resist) 1927
1940 resist_value = GetActualResistance(player_resist);
1941 else
1942 resist_value = 0;
1943
1944 result_amount_dmg = amount;
1945 if ( classType == PLAYER_CLASS_LICH && resist_value >= 200 ) 1928 if ( classType == PLAYER_CLASS_LICH && resist_value >= 200 )
1946 return 0; 1929 return 0;
1947 player_luck = GetActualLuck(); 1930 player_luck = GetActualLuck();
1948 res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30; 1931 res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30;
1949 1932
1950 if ( resist_value ) 1933 if ( GetParameterBonus(player_luck) + resist_value > 0 )
1951 { 1934 {
1952 if ( rand() % res_rand_divider >= 30 ) 1935 for (int i = 0; i < 4; i++)
1953 { 1936 {
1954 result_amount_dmg = amount >> 1;
1955 if ( rand() % res_rand_divider >= 30 ) 1937 if ( rand() % res_rand_divider >= 30 )
1956 { 1938 dmg >>= 1;
1957 result_amount_dmg = amount >> 2; 1939 else
1958 if ( rand() % res_rand_divider >= 30 ) 1940 break;
1959 { 1941 }
1960 result_amount_dmg = amount >> 3; 1942 }
1961 if ( rand() % res_rand_divider >= 30 ) 1943 if (( dmg_type == DMGT_PHISYCAL ) && ( pEquipment.uArmor ))
1962 result_amount_dmg = amount >> 4; 1944 {
1963 } 1945 if (!pOwnItems[pEquipment.uArmor - 1].Broken())
1964 }
1965 }
1966 }
1967 if (( dmg_type == DMGT_PHISYCAL )&&( pEquipment.uArmor ))
1968 {
1969 if (!pOwnItems[pEquipment.uArmor-1].Broken())
1970 { 1946 {
1971 armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR); 1947 armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR);
1972 if ( armor_skill==PLAYER_SKILL_PLATE ) 1948 if ( armor_skill==PLAYER_SKILL_PLATE )
1973 { 1949 {
1974 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) 1950 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 )
1975 return (int)(double)result_amount_dmg * 0.5; 1951 return dmg / 2;
1976 } 1952 }
1977 if (armor_skill==PLAYER_SKILL_CHAIN ) 1953 if (armor_skill==PLAYER_SKILL_CHAIN )
1978 { 1954 {
1979 if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4) 1955 if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4)
1980 return (int)(double)result_amount_dmg * 0.66670001; 1956 return dmg * 2 / 3;
1981 } 1957 }
1982 } 1958 }
1983 } 1959 }
1984 return result_amount_dmg; 1960 return dmg;
1985 } 1961 }
1986 1962
1987 //----- (0048D62C) -------------------------------------------------------- 1963 //----- (0048D62C) --------------------------------------------------------
1988 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) 1964 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot)
1989 { 1965 {