comparison Player.cpp @ 1597:33a82b36c3e8

Player::GetActualResistance cleaned up, some minor changes in Player::Recover, _48EA46_calc_special_bonus_by_items renamed to GetSpecialItemBonus
author Grumpy7
date Tue, 10 Sep 2013 04:08:15 +0200
parents a52a01aaf439
children 11bb463837b1
comparison
equal deleted inserted replaced
1596:061f0e5a284d 1597:33a82b36c3e8
2937 2937
2938 //----- (0048E73F) -------------------------------------------------------- 2938 //----- (0048E73F) --------------------------------------------------------
2939 int Player::GetBaseResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) 2939 int Player::GetBaseResistance(enum CHARACTER_ATTRIBUTE_TYPE a2)
2940 { 2940 {
2941 int v7; // esi@20 2941 int v7; // esi@20
2942
2943 int racialBonus = 0; 2942 int racialBonus = 0;
2944
2945 __int16* resStat; 2943 __int16* resStat;
2946 2944
2947 switch (a2) 2945 switch (a2)
2948 { 2946 {
2949 case CHARACTER_ATTRIBUTE_RESIST_FIRE: 2947 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
2983 } 2981 }
2984 2982
2985 //----- (0048E7D0) -------------------------------------------------------- 2983 //----- (0048E7D0) --------------------------------------------------------
2986 int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2) 2984 int Player::GetActualResistance(enum CHARACTER_ATTRIBUTE_TYPE a2)
2987 { 2985 {
2988 signed int v2; // edi@1 2986 signed int v10 = 0; // [sp+14h] [bp-4h]@1
2989 Player *v3; // esi@1 2987 __int16* resStat;
2990 enum CHARACTER_RACE v4; // ebx@1 2988 int result;
2991 char v6; // zf@18 2989 int baseRes;
2992 int v7; // ebx@28 2990
2993 int result; // eax@28 2991 int leatherArmorSkillLevel = GetActualSkillLevel(PLAYER_SKILL_LEATHER);
2994 signed int v9; // [sp+10h] [bp-8h]@1
2995 signed int v10; // [sp+14h] [bp-4h]@1
2996
2997 v2 = 0;
2998 v3 = this;
2999 v10 = 0;
3000 v9 = 0;
3001 v4 = GetRace();
3002 if ( CheckHiredNPCSpeciality(Enchanter) ) 2992 if ( CheckHiredNPCSpeciality(Enchanter) )
3003 v10 = 20; 2993 v10 = 20;
3004 if ( (a2 == CHARACTER_ATTRIBUTE_RESIST_FIRE 2994 if ( (a2 == CHARACTER_ATTRIBUTE_RESIST_FIRE
3005 || a2 == CHARACTER_ATTRIBUTE_RESIST_AIR 2995 || a2 == CHARACTER_ATTRIBUTE_RESIST_AIR
3006 || a2 == CHARACTER_ATTRIBUTE_RESIST_WATER 2996 || a2 == CHARACTER_ATTRIBUTE_RESIST_WATER
3007 || a2 == CHARACTER_ATTRIBUTE_RESIST_EARTH) 2997 || a2 == CHARACTER_ATTRIBUTE_RESIST_EARTH)
3008 && SkillToMastery(v3->pActiveSkills[9]) == 4 2998 && SkillToMastery(leatherArmorSkillLevel) == 4
3009 && HasItemEquipped(EQUIP_ARMOUR) 2999 && HasItemEquipped(EQUIP_ARMOUR)
3010 && GetEquippedItemSkillType(EQUIP_ARMOUR) == PLAYER_SKILL_LEATHER ) 3000 && GetEquippedItemSkillType(EQUIP_ARMOUR) == PLAYER_SKILL_LEATHER )
3011 v10 += v3->pActiveSkills[9] & 0x3F; 3001 v10 += leatherArmorSkillLevel & 0x3F;
3012 if ( a2 == CHARACTER_ATTRIBUTE_RESIST_FIRE ) 3002 switch (a2)
3013 goto LABEL_25; 3003 {
3014 if ( a2 == CHARACTER_ATTRIBUTE_RESIST_AIR ) 3004 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
3015 { 3005 resStat = &sResFireBonus;
3016 v2 = 1; 3006 break;
3017 LABEL_25: 3007 case CHARACTER_ATTRIBUTE_RESIST_AIR:
3018 v6 = v4 == 2; 3008 resStat = &sResAirBonus;
3019 LABEL_26: 3009 break;
3020 if ( v6 ) 3010 case CHARACTER_ATTRIBUTE_RESIST_WATER:
3021 v9 = 5; 3011 resStat = &sResWaterBonus;
3022 goto LABEL_28; 3012 break;
3023 } 3013 case CHARACTER_ATTRIBUTE_RESIST_EARTH:
3024 if ( a2 == CHARACTER_ATTRIBUTE_RESIST_WATER ) 3014 resStat = &sResEarthBonus;
3025 { 3015 break;
3026 v6 = v4 == 3; 3016 case CHARACTER_ATTRIBUTE_RESIST_MIND:
3027 v2 = 2; 3017 resStat = &sResMindBonus;
3028 goto LABEL_26; 3018 break;
3029 } 3019 case CHARACTER_ATTRIBUTE_RESIST_BODY:
3030 if ( a2 == CHARACTER_ATTRIBUTE_RESIST_EARTH ) 3020 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT:
3031 { 3021 resStat = &sResBodyBonus;
3032 v2 = 3; 3022 break;
3033 if ( v4 == 3 ) 3023 }
3034 v10 += 5; 3024 baseRes = GetBaseResistance(a2);
3035 } 3025 result = v10 + GetMagicalBonus(a2) + baseRes + *(resStat);
3036 else
3037 {
3038 if ( a2 != CHARACTER_ATTRIBUTE_RESIST_MIND )
3039 {
3040 if ( a2 != CHARACTER_ATTRIBUTE_RESIST_BODY && a2 != 33 )
3041 goto LABEL_28;
3042 v2 = 8;
3043 v6 = v4 == 0;
3044 goto LABEL_26;
3045 }
3046 v2 = 7;
3047 if ( v4 == 1 )
3048 v9 = 10;
3049 }
3050 LABEL_28:
3051 v7 = GetItemsBonus(a2);
3052 result = v10 + GetMagicalBonus(a2) + v7 + v9 + *(&v3->sResFireBonus + v2) + *(&v3->sResFireBase + v2);
3053 if ( v3->classType == PLAYER_CLASS_LICH )
3054 {
3055 if ( result > 200 )
3056 result = 200;
3057 }
3058 return result; 3026 return result;
3059 } 3027 }
3060 3028
3061 //----- (0048E8F5) -------------------------------------------------------- 3029 //----- (0048E8F5) --------------------------------------------------------
3062 bool Player::Recover(int dt) 3030 bool Player::Recover(int dt)
3063 { 3031 {
3064 //Player *v2; // esi@1 3032 int v3; // qax@1
3065 signed __int64 v3; // qax@1 3033
3066 //bool result; // eax@4 3034 v3 = (int)(dt * GetSpecialItemBonus(17) * 0.01 + dt);
3067
3068 //v2 = this;
3069 v3 = (signed __int64)((double)(dt * _48EA46_calc_special_bonus_by_items(17)) * 0.01 + (double)dt);
3070 3035
3071 Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery); 3036 Log::Warning(L"Recover(dt = %u/%u - %u", dt, (uint)v3, (uint)uTimeToRecovery);
3072 3037
3073 if (uTimeToRecovery > v3) 3038 if (uTimeToRecovery > v3)
3074 { 3039 {
3117 return 18; 3082 return 18;
3118 } 3083 }
3119 3084
3120 //----- (0048EA1B) -------------------------------------------------------- 3085 //----- (0048EA1B) --------------------------------------------------------
3121 int Player::GetParameterBonus( int player_parameter ) 3086 int Player::GetParameterBonus( int player_parameter )
3122 { 3087 {
3123 int i; // eax@1 3088 int i; // eax@1
3124 i = 0; 3089 i = 0;
3125 while (param_to_bonus_table[i]) 3090 while (param_to_bonus_table[i])
3126 { 3091 {
3127 if (player_parameter >= param_to_bonus_table[i]) 3092 if (player_parameter >= param_to_bonus_table[i])
3128 break; 3093 break;
3129 ++i; 3094 ++i;
3130 } 3095 }
3131 return parameter_to_bonus_value[i]; 3096 return parameter_to_bonus_value[i];
3132 } 3097 }
3133 3098
3134 //----- (0048EA46) -------------------------------------------------------- 3099 //----- (0048EA46) --------------------------------------------------------
3135 int Player::_48EA46_calc_special_bonus_by_items(int a2) 3100 int Player::GetSpecialItemBonus( int enchantmentId )
3136 { 3101 {
3137 int inv_indx; // eax@3 3102 int inv_indx; // eax@3
3138 3103
3139 for (int i=EQUIP_OFF_HAND; i<EQUIP_BOOK; ++i ) 3104 for (int i = EQUIP_OFF_HAND; i < EQUIP_BOOK; ++i )
3140 { 3105 {
3141 if ( !HasItemEquipped((ITEM_EQUIP_TYPE)i) ) 3106 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
3142 continue; 3107 {
3143 inv_indx = pEquipment.pIndices[i] - 1; 3108 inv_indx = pEquipment.pIndices[i] - 1;
3144 if (a2==17) 3109 if (enchantmentId == 17)
3145 { 3110 {
3146 if ((pInventoryItemList[inv_indx].uSpecEnchantmentType==17)||(pInventoryItemList[inv_indx].uItemID==533)) //Elven Chainmail+Increases rate of Recovery 3111 if ((pInventoryItemList[inv_indx].uSpecEnchantmentType==17) || (pInventoryItemList[inv_indx].uItemID == 533)) //Elven Chainmail+Increases rate of Recovery
3147 return 50; 3112 return 50;
3148 } 3113 }
3149 if (a2==24) 3114 if (enchantmentId == 24) //XXX: never actually used on mm7
3150 { 3115 {
3151 if (pInventoryItemList[inv_indx].uSpecEnchantmentType==24) //Increased Knockback. 3116 if (pInventoryItemList[inv_indx].uSpecEnchantmentType == 24) //Increased Knockback.
3152 return 5; 3117 return 5;
3153 } 3118 }
3154 } 3119 }
3120 }
3155 return 0; 3121 return 0;
3156 } 3122 }
3157 3123
3158 //----- (0048EAAE) -------------------------------------------------------- 3124 //----- (0048EAAE) --------------------------------------------------------
3159 int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ ) 3125 int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ )