comparison Player.cpp @ 1036:7f8be9f9769e

player recieve damage
author Gloval
date Wed, 22 May 2013 22:25:44 +0400
parents aa848c90181f
children ff2d888f8033
comparison
equal deleted inserted replaced
1034:aa848c90181f 1036:7f8be9f9769e
101 unsigned char pAgeingEnduranceMultiplier[4] = {100, 75, 40, 10}; 101 unsigned char pAgeingEnduranceMultiplier[4] = {100, 75, 40, 10};
102 unsigned char pAgeingAccuracyMultiplier[4] = {100, 100, 40, 10}; 102 unsigned char pAgeingAccuracyMultiplier[4] = {100, 100, 40, 10};
103 unsigned char pAgeingSpeedMultiplier[4] = {100, 100, 40, 10}; 103 unsigned char pAgeingSpeedMultiplier[4] = {100, 100, 40, 10};
104 unsigned char pAgeingLuckMultiplier[4] = {100, 100, 100, 100}; 104 unsigned char pAgeingLuckMultiplier[4] = {100, 100, 100, 100};
105 105
106 unsigned int pAgeingTable[4] = {50, 100, 150, 65535}; 106 signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF};
107 107
108 unsigned int pConditionImportancyTable[18] = {16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}; 108 unsigned int pConditionImportancyTable[18] = {16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0};
109 109
110 short word_4EDFFC[30] = {500, 400, 350, 300, 275, 250, 225, 200, 175, 110 short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175,
111 150, 125, 100, 75, 50, 40, 35, 30, 25, 21, 111 150, 125, 100, 75, 50, 40, 35, 30, 25, 21,
112 19, 17, 15, 13, 11, 9, 7, 5, 3, 0, 0}; 112 19, 17, 15, 13, 11, 9, 7, 5, 3, 0};
113 signed int player_stat_bonuses[30] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, 0}; 113 signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6};
114 114
115 115
116 unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0}; 116 unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0};
117 117
118 118
262 262
263 263
264 264
265 265
266 //----- (004B8040) -------------------------------------------------------- 266 //----- (004B8040) --------------------------------------------------------
267 int Player::_4B8040_condition_time(unsigned int uCondition) 267 int Player::GetConditionDayOfWeek( unsigned int uCondition )
268 { 268 {
269 return (unsigned int)((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 0x18 % 7 + 1; 269 return (unsigned int)(((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 24) % 7 + 1;
270 } 270 }
271 271
272 //----- (004B807C) -------------------------------------------------------- 272 //----- (004B807C) --------------------------------------------------------
273 int Player::_4B807C(float a2) 273 int Player::_4B807C(float a2)
274 { 274 {
296 if ( v3 == 16 ) 296 if ( v3 == 16 )
297 { 297 {
298 v10 = 10; 298 v10 = 10;
299 v9 = 16; 299 v9 = 16;
300 LABEL_6: 300 LABEL_6:
301 v11 = _4B8040_condition_time(v9); 301 v11 = GetConditionDayOfWeek(v9);
302 goto LABEL_13; 302 goto LABEL_13;
303 } 303 }
304 } 304 }
305 v10 = 1; 305 v10 = 1;
306 v5 = 0; 306 v5 = 0;
307 do 307 do
308 { 308 {
309 v6 = _4B8040_condition_time(v5); 309 v6 = GetConditionDayOfWeek(v5);
310 if ( v6 > v4 ) 310 if ( v6 > v4 )
311 v4 = v6; 311 v4 = v6;
312 ++v5; 312 ++v5;
313 } 313 }
314 while ( (signed int)v5 <= 13 ); 314 while ( (signed int)v5 <= 13 );
2572 } 2572 }
2573 2573
2574 //----- (0048CC33) -------------------------------------------------------- 2574 //----- (0048CC33) --------------------------------------------------------
2575 int Player::GetActualLuck() 2575 int Player::GetActualLuck()
2576 { 2576 {
2577 Player *v1; // esi@1 2577 signed int curr_age; // eax@7
2578 unsigned int v2; // eax@7 2578 signed int i; // ecx@7
2579 signed int v3; // ecx@7 2579 signed int age_luck_pc; // ebx@10
2580 signed int v4; // ebx@10 2580 int condition_luck_pc; // edi@11
2581 int v5; // edi@11 2581 int items_luck_bonus; // ebp@11
2582 int v6; // ebp@11 2582 signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1
2583 signed int v8; // [sp+10h] [bp-4h]@1 2583 signed int magic_luck_bonus; // [sp+10h] [bp-4h]@1
2584 2584 int full_luck;
2585 v8 = 0; 2585
2586 v1 = this; 2586 npc_luck_bonus = 0;
2587 if ( CheckHiredNPCSpeciality(Fool) ) 2587 if ( CheckHiredNPCSpeciality(Fool) )
2588 v8 = 5; 2588 npc_luck_bonus = 5;
2589 if ( CheckHiredNPCSpeciality(ChimneySweep) ) 2589 if ( CheckHiredNPCSpeciality(ChimneySweep) )
2590 v8 += 20; 2590 npc_luck_bonus += 20;
2591 if ( CheckHiredNPCSpeciality(Psychic) ) 2591 if ( CheckHiredNPCSpeciality(Psychic) )
2592 v8 += 10; 2592 npc_luck_bonus += 10;
2593 v2 = v1->sAgeModifier + GetBaseAge(); 2593 curr_age = sAgeModifier + GetBaseAge();
2594 v3 = 0; 2594 i = 0;
2595 while ( (signed int)v2 >= (signed int)pAgeingTable[v3] ) 2595 while ( curr_age >= pAgeingTable[i] )
2596 { 2596 {
2597 ++v3; 2597 ++i;
2598 if ( v3 >= 4 ) 2598 if ( i >= 4 )
2599 { 2599 break;
2600 v4 = 100; 2600 }
2601 goto LABEL_11; 2601 if (i < 4)
2602 } 2602 age_luck_pc = pAgeingLuckMultiplier[i];
2603 } 2603 else
2604 v4 = pAgeingLuckMultiplier[v3]; 2604 age_luck_pc = 100;
2605 LABEL_11: 2605
2606 v5 = pConditionLuckMultiplier[GetMajorConditionIdx()]; 2606 condition_luck_pc = pConditionLuckMultiplier[GetMajorConditionIdx()];
2607 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0); 2607 items_luck_bonus = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0);
2608 return GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK) 2608 magic_luck_bonus = GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK);
2609 + v6 2609 full_luck = magic_luck_bonus + items_luck_bonus + npc_luck_bonus+ uLuckBonus
2610 + v8 2610 + condition_luck_pc * age_luck_pc * uLuck / 100 / 100;
2611 + v5 * v4 * v1->uLuck / 100 / 100 2611 return full_luck;
2612 + v1->uLuckBonus;
2613 } 2612 }
2614 2613
2615 //----- (0048CCF5) -------------------------------------------------------- 2614 //----- (0048CCF5) --------------------------------------------------------
2616 int Player::GetActualAttack(int a2) 2615 int Player::GetActualAttack(int a2)
2617 { 2616 {
2621 int v5; // ebx@1 2620 int v5; // ebx@1
2622 int v6; // ebp@1 2621 int v6; // ebp@1
2623 2622
2624 v2 = this; 2623 v2 = this;
2625 v3 = GetActualAccuracy(); 2624 v3 = GetActualAccuracy();
2626 v4 = _48EA1B_get_static_effect(v3); 2625 v4 = GetParameterBonus(v3);
2627 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK); 2626 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK);
2628 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2); 2627 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2);
2629 return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus; 2628 return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus;
2630 } 2629 }
2631 2630
2638 int v4; // esi@1 2637 int v4; // esi@1
2639 int v5; // esi@1 2638 int v5; // esi@1
2640 int v6; // esi@1 2639 int v6; // esi@1
2641 signed int result; // eax@1 2640 signed int result; // eax@1
2642 2641
2643 v1 = this; 2642
2644 v2 = GetActualMight(); 2643 v2 = GetActualMight();
2645 v3 = _48EA1B_get_static_effect(v2); 2644 v3 = GetParameterBonus(v2);
2646 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0) + v3; 2645 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0) + v3;
2647 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; 2646 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
2648 v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; 2647 result = _melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
2649 result = 1; 2648 if ( result < 1 )
2650 if ( v6 >= 1 ) 2649 result = 1;
2651 result = v6;
2652 return result; 2650 return result;
2653 } 2651 }
2654 2652
2655 //----- (0048CD90) -------------------------------------------------------- 2653 //----- (0048CD90) --------------------------------------------------------
2656 int Player::GetMeleeDamageMaximal() 2654 int Player::GetMeleeDamageMaximal()
2663 int v6; // esi@1 2661 int v6; // esi@1
2664 signed int result; // eax@1 2662 signed int result; // eax@1
2665 2663
2666 v1 = this; 2664 v1 = this;
2667 v2 = GetActualMight(); 2665 v2 = GetActualMight();
2668 v3 = _48EA1B_get_static_effect(v2); 2666 v3 = GetParameterBonus(v2);
2669 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3; 2667 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3;
2670 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; 2668 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
2671 v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; 2669 v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
2672 result = 1; 2670 result = 1;
2673 if ( v6 >= 1 ) 2671 if ( v6 >= 1 )
2866 LABEL_62: 2864 LABEL_62:
2867 v21 = v32 + v34; 2865 v21 = v32 + v34;
2868 if ( !a2 ) 2866 if ( !a2 )
2869 { 2867 {
2870 v22 = GetActualMight(); 2868 v22 = GetActualMight();
2871 v23 = _48EA1B_get_static_effect(v22); 2869 v23 = GetParameterBonus(v22);
2872 v24 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v23; 2870 v24 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v23;
2873 v21 += v5->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v24; 2871 v21 += v5->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v24;
2874 } 2872 }
2875 result = 1; 2873 result = 1;
2876 if ( v21 >= 1 ) 2874 if ( v21 >= 1 )
2892 v1 = this; 2890 v1 = this;
2893 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; 2891 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
2894 if ( v2 < 64 || v2 > 65 ) 2892 if ( v2 < 64 || v2 > 65 )
2895 { 2893 {
2896 v4 = GetActualAccuracy(); 2894 v4 = GetActualAccuracy();
2897 v5 = _48EA1B_get_static_effect(v4); 2895 v5 = GetParameterBonus(v4);
2898 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5; 2896 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5;
2899 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; 2897 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6;
2900 v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; 2898 v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7;
2901 } 2899 }
2902 else 2900 else
3036 } 3034 }
3037 3035
3038 //----- (0048D2EA) -------------------------------------------------------- 3036 //----- (0048D2EA) --------------------------------------------------------
3039 char *Player::GetMeleeDamageString() 3037 char *Player::GetMeleeDamageString()
3040 { 3038 {
3041 Player *v1; // esi@1 3039 signed int itemid; // eax@1
3042 signed int v2; // eax@1 3040 int min_damage; // edi@3
3043 signed int v3; // edi@3 3041 int max_damage; // eax@3
3044 signed int v4; // eax@3
3045 signed int v5; // ST0C_4@6
3046 char *v6; // edi@6
3047 signed int v7; // ST08_4@7
3048 unsigned int v8; // eax@8
3049 signed int v9; // esi@9
3050 3042
3051 static char player__getmeleedamagestring_static_buff[40]; // idb 3043 static char player__getmeleedamagestring_static_buff[40]; // idb
3052 3044
3053 v1 = this; 3045 if ( pEquipment.uMainHand)
3054 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; 3046 {
3055 if ( v2 < 64 || v2 > 65 ) 3047 itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID;
3056 { 3048 if ( itemid < 64 || itemid > 65 ) //blasters
3057 v3 = GetMeleeDamageMinimal(); 3049 {
3058 v4 = GetMeleeDamageMaximal(); 3050 min_damage = GetMeleeDamageMinimal();
3059 } 3051 max_damage = GetMeleeDamageMaximal();
3052 }
3053 else
3054 { //for blasters
3055 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0);
3056 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0);
3057 }
3058 if ( max_damage )
3059 {
3060 if ( min_damage == max_damage )
3061 {
3062 sprintf(player__getmeleedamagestring_static_buff, "%d", min_damage);
3063 }
3064 else
3065 {
3066 sprintf(player__getmeleedamagestring_static_buff, "%d - %d", min_damage, max_damage);
3067 }
3068 }
3069 else
3070 {
3071 strcpy(player__getmeleedamagestring_static_buff, "N/A");
3072 }
3073
3074 if (( itemid >= 135 )&&( itemid <= 159 )) //wands
3075 {
3076 strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
3077 }
3078 }
3060 else 3079 else
3061 { 3080 strcpy(player__getmeleedamagestring_static_buff, "N/A");
3062 v3 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0); 3081 return player__getmeleedamagestring_static_buff;
3063 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0);
3064 }
3065 if ( v3 == v4 )
3066 {
3067 v5 = v3;
3068 v6 = player__getmeleedamagestring_static_buff;
3069 sprintf(player__getmeleedamagestring_static_buff, "%d", v5);
3070 }
3071 else
3072 {
3073 v7 = v3;
3074 v6 = player__getmeleedamagestring_static_buff;
3075 sprintf(player__getmeleedamagestring_static_buff, "%d - %d", v7, v4);
3076 }
3077 v8 = v1->pEquipment.uMainHand;
3078 if ( v8 )
3079 {
3080 v9 = *(int *)&v1->pInventoryItems[v8-1];
3081 if ( v9 >= 135 )
3082 {
3083 if ( v9 <= 159 )
3084 strcpy(v6, pGlobalTXT_LocalizationStrings[595]);
3085 }
3086 }
3087 return v6;
3088 } 3082 }
3089 3083
3090 //----- (0048D396) -------------------------------------------------------- 3084 //----- (0048D396) --------------------------------------------------------
3091 char *Player::GetRangedDamageString() 3085 char *Player::GetRangedDamageString()
3092 { 3086 {
3093 Player *v1; // esi@1 3087 signed int itemid; // eax@1
3094 signed int v2; // eax@1 3088 int min_damage; // edi@3
3095 int v3; // edi@3 3089 int max_damage; // eax@3
3096 int v4; // eax@3 3090
3097 char *v5; // edi@6 3091 static char player__getrangeddamagestring_static_buff[40]; // idb
3098 int v6; // ST0C_4@8 3092 if ( pEquipment.uMainHand)
3099 int v7; // ST08_4@9 3093 {
3100 unsigned int v8; // eax@10 3094 itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID;
3101 signed int v9; // esi@11 3095 if ( itemid < 64 || itemid > 65 ) //blasters
3102 3096 {
3103 static char player__getrangeddamagestring_static_buff[40]; // idb 3097 min_damage = GetRangedDamageMin();
3104 3098 max_damage = GetRangedDamageMax();
3105 v1 = this; 3099 }
3106 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; 3100 else
3107 if ( v2 < 64 || v2 > 65 ) 3101 { //for blasters
3108 { 3102 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1);
3109 v3 = GetRangedDamageMin(); 3103 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1);
3110 v4 = GetRangedDamageMax(); 3104 }
3111 } 3105 if ( max_damage )
3112 else 3106 {
3113 { 3107 if ( min_damage == max_damage )
3114 v3 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1); 3108 {
3115 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1); 3109 sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage);
3116 } 3110 }
3117 if ( v4 ) 3111 else
3118 { 3112 {
3119 if ( v3 == v4 ) 3113 sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage);
3120 { 3114 }
3121 v6 = v3; 3115 }
3122 v5 = player__getrangeddamagestring_static_buff; 3116 else
3123 sprintf(player__getrangeddamagestring_static_buff, "%d", v6); 3117 {
3124 } 3118 strcpy(player__getrangeddamagestring_static_buff, "N/A");
3119 }
3120
3121 if (( itemid >= 135 )&&( itemid <= 159 )) //wands
3122 {
3123 strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand"
3124 }
3125 }
3125 else 3126 else
3126 { 3127 strcpy(player__getrangeddamagestring_static_buff, "N/A");
3127 v7 = v3; 3128 return player__getrangeddamagestring_static_buff;
3128 v5 = player__getrangeddamagestring_static_buff; 3129 }
3129 sprintf(player__getrangeddamagestring_static_buff, "%d - %d", v7, v4);
3130 }
3131 }
3132 else
3133 {
3134 v5 = player__getrangeddamagestring_static_buff;
3135 strcpy(player__getrangeddamagestring_static_buff, "N/A");
3136 }
3137 v8 = v1->pEquipment.uMainHand;
3138 if ( v8 )
3139 {
3140 v9 = *(int *)&v1->pInventoryItems[v8-1];
3141 if ( v9 >= 135 )
3142 {
3143 if ( v9 <= 159 )
3144 strcpy(v5, pGlobalTXT_LocalizationStrings[595]);
3145 }
3146 }
3147 return v5;
3148 }
3149 3130
3150 //----- (0048D45A) -------------------------------------------------------- 3131 //----- (0048D45A) --------------------------------------------------------
3151 bool Player::CanTrainToNextLevel() 3132 bool Player::CanTrainToNextLevel()
3152 { 3133 {
3153 int v1; // edx@1 3134 int v1; // edx@1
3172 result = ui_character_default_text_color; 3153 result = ui_character_default_text_color;
3173 return result; 3154 return result;
3174 } 3155 }
3175 3156
3176 //----- (0048D4B3) -------------------------------------------------------- 3157 //----- (0048D4B3) --------------------------------------------------------
3177 int Player::CalculateIncommingDamage(int resistance, signed int type) 3158 int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int amount )
3178 { 3159 {
3179 Player *v3; // esi@1 3160
3180 int v4; // edi@8 3161 int resist_value; // edi@8
3181 int v6; // eax@21 3162 int player_luck; // eax@21
3182 signed int v7; // ebx@21 3163 signed int res_rand_divider; // ebx@2
3183 int v8; // eax@22 3164 int armor_skill; // eax@29
3184 signed int v9; // ebx@22 3165 enum CHARACTER_ATTRIBUTE_TYPE player_resist; // [sp-4h] [bp-10h]@9
3185 int v10; // eax@23 3166 signed int result_amount_dmg; // [sp+8h] [bp-4h]@17
3186 signed int v11; // ebx@23 3167
3187 int v12; // eax@24 3168 player_resist=CHARACTER_ATTRIBUTE_STRENGTH;
3188 signed int v13; // edi@24 3169 switch(dmg_type)
3189 unsigned int v14; // eax@27 3170 {
3190 int v15; // eax@29 3171 case DMGT_FIRE: player_resist=CHARACTER_ATTRIBUTE_RESIST_FIRE; break;
3191 double v16; // st7@32 3172 case DMGT_ELECTR: player_resist=CHARACTER_ATTRIBUTE_RESIST_AIR; break;
3192 enum CHARACTER_ATTRIBUTE_TYPE v17; // [sp-4h] [bp-10h]@9 3173 case DMGT_COLD: player_resist=CHARACTER_ATTRIBUTE_RESIST_WATER; break;
3193 signed int v18; // [sp+8h] [bp-4h]@17 3174 case DMGT_3: player_resist=CHARACTER_ATTRIBUTE_RESIST_EARTH; break;
3194 3175
3195 v3 = this; 3176 case DMGT_SPIRIT: player_resist=CHARACTER_ATTRIBUTE_RESIST_SPIRIT;break;
3196 if ( !resistance ) 3177 case DMGT_MIND: player_resist=CHARACTER_ATTRIBUTE_RESIST_MIND; break;
3197 { 3178 case DMGT_BODY: player_resist=CHARACTER_ATTRIBUTE_RESIST_BODY; break;
3198 v17 = (CHARACTER_ATTRIBUTE_TYPE)10; 3179 }
3199 goto LABEL_16; 3180 if (player_resist)
3200 } 3181 resist_value = GetActualResistance(player_resist);
3201 if ( resistance == 1 ) 3182 else
3202 { 3183 resist_value = 0;
3203 v17 = (CHARACTER_ATTRIBUTE_TYPE)11; 3184
3204 goto LABEL_16; 3185 result_amount_dmg = amount;
3205 } 3186 if ( classType == PLAYER_CLASS_LICH && resist_value >= 200 )
3206 if ( resistance == 2 )
3207 {
3208 v17 = (CHARACTER_ATTRIBUTE_TYPE)12;
3209 goto LABEL_16;
3210 }
3211 if ( resistance == 3 )
3212 {
3213 v17 = (CHARACTER_ATTRIBUTE_TYPE)13;
3214 goto LABEL_16;
3215 }
3216 if ( resistance == 6 )
3217 {
3218 v17 = (CHARACTER_ATTRIBUTE_TYPE)33;
3219 goto LABEL_16;
3220 }
3221 if ( resistance == 7 )
3222 {
3223 v17 = (CHARACTER_ATTRIBUTE_TYPE)14;
3224 goto LABEL_16;
3225 }
3226 if ( resistance == 8 )
3227 {
3228 v17 = (CHARACTER_ATTRIBUTE_TYPE)15;
3229 LABEL_16:
3230 v4 = GetActualResistance(v17);
3231 goto LABEL_17;
3232 }
3233 v4 = 0;
3234 LABEL_17:
3235 v18 = type;
3236 if ( v3->classType == PLAYER_CLASS_LICH && v4 >= 200 )
3237 return 0; 3187 return 0;
3238 if ( v4 ) 3188 player_luck = GetActualLuck();
3239 { 3189 res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30;
3240 v6 = GetActualLuck(); 3190
3241 v7 = _48EA1B_get_static_effect(v6) + v4 + 30; 3191 if ( resist_value )
3242 if ( rand() % v7 >= 30 ) 3192 {
3243 { 3193 if ( rand() % res_rand_divider >= 30 )
3244 v18 = type >> 1; 3194 {
3245 v8 = GetActualLuck(); 3195 result_amount_dmg = amount >> 1;
3246 v9 = _48EA1B_get_static_effect(v8) + v4 + 30; 3196 if ( rand() % res_rand_divider >= 30 )
3247 if ( rand() % v9 >= 30 ) 3197 {
3248 { 3198 result_amount_dmg = amount >> 2;
3249 v18 = type >> 2; 3199 if ( rand() % res_rand_divider >= 30 )
3250 v10 = GetActualLuck();
3251 v11 = _48EA1B_get_static_effect(v10) + v4 + 30;
3252 if ( rand() % v11 >= 30 )
3253 { 3200 {
3254 v18 = type >> 3; 3201 result_amount_dmg = amount >> 3;
3255 v12 = GetActualLuck(); 3202 if ( rand() % res_rand_divider >= 30 )
3256 v13 = _48EA1B_get_static_effect(v12) + v4 + 30; 3203 result_amount_dmg = amount >> 4;
3257 if ( rand() % v13 >= 30 )
3258 v18 = type >> 4;
3259 } 3204 }
3260 } 3205 }
3261 } 3206 }
3262 } 3207 }
3263 if ( resistance == 4 ) 3208 if (( dmg_type == DMGT_PHISYCAL )&&( pEquipment.uArmor ))
3264 { 3209 {
3265 v14 = v3->pEquipment.uArmor; 3210 if (!pOwnItems[pEquipment.uArmor-1].Broken())
3266 if ( v14 ) 3211 {
3267 { 3212 armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR);
3268 // if ( !(v3->field_1F5[36 * v14 + 15] & 2) ) 3213 if ( armor_skill==PLAYER_SKILL_PLATE )
3269 if (v3->pOwnItems[v14-1].uAttributes&2)
3270 {
3271 v15 = GetEquippedItemSkillType(EQUIP_ARMOUR) - 10;
3272 if ( v15 )
3273 { 3214 {
3274 if ( v15 != 1 || (signed int)SkillToMastery(v3->pActiveSkills[11]) < 3 ) 3215 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 )
3275 return v18; 3216 return (int)(double)result_amount_dmg * 0.5;
3276 v16 = (double)v18 * 0.5;
3277 return (signed __int64)v16;
3278 } 3217 }
3279 if ( (signed int)SkillToMastery(v3->pActiveSkills[10]) >= 4 ) 3218 if (armor_skill==PLAYER_SKILL_CHAIN )
3280 { 3219 {
3281 v16 = (double)v18 * 0.66670001; 3220 if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4)
3282 return (signed __int64)v16; 3221 return (int)(double)result_amount_dmg * 0.66670001;
3283 } 3222 }
3284 } 3223 }
3285 } 3224 }
3286 } 3225 return result_amount_dmg;
3287 return v18;
3288 } 3226 }
3289 3227
3290 //----- (0048D62C) -------------------------------------------------------- 3228 //----- (0048D62C) --------------------------------------------------------
3291 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) 3229 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot)
3292 { 3230 {
3309 //----- (0048D6AA) -------------------------------------------------------- 3247 //----- (0048D6AA) --------------------------------------------------------
3310 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) 3248 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex)
3311 { 3249 {
3312 auto i = pEquipment.pIndices[uEquipIndex]; 3250 auto i = pEquipment.pIndices[uEquipIndex];
3313 if (i) 3251 if (i)
3314 return ~pInventoryItems[i - 1].uAttributes & 0x02; 3252 return ~(pInventoryItems[i - 1].uAttributes & ITEM_BROKEN);
3315 else return false; 3253 else
3254 return false;
3316 } 3255 }
3317 3256
3318 //----- (0048D6D0) -------------------------------------------------------- 3257 //----- (0048D6D0) --------------------------------------------------------
3319 bool Player::HasEnchantedItemEquipped(int uEnchantment) 3258 bool Player::HasEnchantedItemEquipped(int uEnchantment)
3320 { 3259 {
3586 } 3525 }
3587 } 3526 }
3588 } 3527 }
3589 3528
3590 //----- (0048DC1E) -------------------------------------------------------- 3529 //----- (0048DC1E) --------------------------------------------------------
3591 int Player::ReceiveDamage(signed int type, int resistance) 3530 int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type )
3592 { 3531 {
3593 Player *v3; // esi@1 3532 signed int recieved_dmg; // eax@1
3594 signed int v4; // eax@1 3533 unsigned int armor_indx; // eax@8
3595 int v5; // eax@1 3534 bool broke_armor;
3596 bool v6; // ebx@1 3535
3597 unsigned int v7; // eax@8 3536 pConditions[Condition_Sleep] = 0i64;
3598 char *v8; // ecx@9 3537 recieved_dmg = CalculateIncommingDamage(dmg_type, amount);
3599 int v9; // eax@9 3538 sHealth -= recieved_dmg;
3600 //signed int typea; // [sp+14h] [bp+8h]@1 3539 broke_armor = sHealth <= -10;
3601 3540 if ( sHealth < 1 ) //
3602 v3 = this; 3541 {
3603 this->pConditions[Condition_Sleep] = 0i64; 3542 if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1)
3604 v4 = CalculateIncommingDamage(resistance, type); 3543 || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0i64 )
3605 v3->sHealth -= v4;
3606 //typea = v4;
3607 v5 = v3->sHealth;
3608 v6 = v5 < -10;
3609 LOBYTE(v6) = v5 <= -10;
3610 if ( v5 < 1 )
3611 {
3612 if ( v3->sHealth + v3->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1
3613 || (signed __int64)v3->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 )
3614 { 3544 {
3615 SetCondition(Condition_Unconcious, 0); 3545 SetCondition(Condition_Unconcious, 0);
3616 } 3546 }
3617 else 3547 else
3618 { 3548 {
3619 SetCondition(Condition_Dead, 0); 3549 SetCondition(Condition_Dead, 0);
3620 v6 = LODWORD(pParty->uTimePlayed); 3550 //v6 = LODWORD(pParty->uTimePlayed); ???? if equals 0 do not broke armor?
3621 if ( v3->sHealth > 0 ) 3551 if ( sHealth > 0 )
3622 v3->sHealth = 0; 3552 sHealth = 0;
3623 } 3553 }
3624 if ( v6 ) 3554 if (broke_armor )
3625 { 3555 {
3626 v7 = v3->pEquipment.uArmor; 3556 armor_indx = pEquipment.uArmor;
3627 if ( v7 ) 3557 if ( armor_indx )
3628 { 3558 {
3629 // v8 = &v3->field_1F5[36 * v7 + 15]; 3559 if ( !pOwnItems[armor_indx-1].uAttributes & ITEM_ENCHANTED)
3630 v8=(char*)&v3->pOwnItems[v7-1].uAttributes;
3631 v9 = *(int *)v8;
3632 if ( !(BYTE1(v9) & 2) )
3633 { 3560 {
3634 LOBYTE(v9) = v9 | 2; 3561 pOwnItems[armor_indx-1].uAttributes|=ITEM_BROKEN;
3635 *(int *)v8 = v9;
3636 } 3562 }
3637 } 3563 }
3638 } 3564 }
3639 } 3565 }
3640 if ( v4 && CanAct() ) 3566 if ( recieved_dmg && CanAct() )
3641 PlaySound(SPEECH_24, 0); 3567 PlaySound(SPEECH_24, 0);
3642 return v4; 3568 return recieved_dmg;
3643 } 3569 }
3644 3570
3645 //----- (0048DCF6) -------------------------------------------------------- 3571 //----- (0048DCF6) --------------------------------------------------------
3646 int Player::_48DCF6(int a2, Actor *pActor) 3572 int Player::_48DCF6(int a2, Actor *pActor)
3647 { 3573 {
3728 LABEL_5: 3654 LABEL_5:
3729 v7 = GetActualResistance(v40); 3655 v7 = GetActualResistance(v40);
3730 goto LABEL_47; 3656 goto LABEL_47;
3731 case 22: 3657 case 22:
3732 v8 = GetActualWillpower(); 3658 v8 = GetActualWillpower();
3733 v9 = _48EA1B_get_static_effect(v8); 3659 v9 = GetParameterBonus(v8);
3734 v10 = GetActualIntelligence(); 3660 v10 = GetActualIntelligence();
3735 v11 = (_48EA1B_get_static_effect(v10) + v9) >> 1; 3661 v11 = (GetParameterBonus(v10) + v9) >> 1;
3736 break; 3662 break;
3737 case 17: 3663 case 17:
3738 v12 = 0; 3664 v12 = 0;
3739 v13 = this->pInventoryItems; 3665 v13 = this->pInventoryItems;
3740 do 3666 do
3803 if ( !v4 ) 3729 if ( !v4 )
3804 goto LABEL_87; 3730 goto LABEL_87;
3805 v47 = (unsigned __int8)v46[rand() % v4]; 3731 v47 = (unsigned __int8)v46[rand() % v4];
3806 v6 = GetActualAccuracy(); 3732 v6 = GetActualAccuracy();
3807 LABEL_46: 3733 LABEL_46:
3808 v7 = _48EA1B_get_static_effect(v6); 3734 v7 = GetParameterBonus(v6);
3809 LABEL_47: 3735 LABEL_47:
3810 v11 = v7; 3736 v11 = v7;
3811 break; 3737 break;
3812 default: 3738 default:
3813 v11 = 0; 3739 v11 = 0;
3814 break; 3740 break;
3815 } 3741 }
3816 v22 = GetActualLuck(); 3742 v22 = GetActualLuck();
3817 v23 = _48EA1B_get_static_effect(v22) + v11 + 30; 3743 v23 = GetParameterBonus(v22) + v11 + 30;
3818 if ( rand() % v23 >= 30 ) 3744 if ( rand() % v23 >= 30 )
3819 { 3745 {
3820 LABEL_87: 3746 LABEL_87:
3821 result = 0; 3747 result = 0;
3822 } 3748 }
4108 4034
4109 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; 4035 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type];
4110 shield_recovery = shield_base_recovery * SkillToMastery(pActiveSkills[skill_type]); 4036 shield_recovery = shield_base_recovery * SkillToMastery(pActiveSkills[skill_type]);
4111 } 4037 }
4112 4038
4113 uint player_speed_recovery_reduction = _48EA1B_get_static_effect(GetActualSpeed()), 4039 uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()),
4114 sword_axe_bow_recovery_reduction = 0; 4040 sword_axe_bow_recovery_reduction = 0;
4115 bool shooting_laser = false; 4041 bool shooting_laser = false;
4116 if (weapon_desc) 4042 if (weapon_desc)
4117 { 4043 {
4118 if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon_desc->uSkillType) && 4044 if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon_desc->uSkillType) &&
4169 { 4095 {
4170 int v3; // esi@1 4096 int v3; // esi@1
4171 int v4; // esi@1 4097 int v4; // esi@1
4172 int v6; // esi@1 4098 int v6; // esi@1
4173 4099
4174 v3 = _48EA1B_get_static_effect(GetActualEndurance()); 4100 v3 = GetParameterBonus(GetActualEndurance());
4175 v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3); 4101 v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3);
4176 v6 = uFullHealthBonus 4102 v6 = uFullHealthBonus
4177 + pBaseHealthByClass[classType / 4] 4103 + pBaseHealthByClass[classType / 4]
4178 + GetSkillBonus(CHARACTER_ATTRIBUTE_HEALTH) 4104 + GetSkillBonus(CHARACTER_ATTRIBUTE_HEALTH)
4179 + GetItemsBonus(CHARACTER_ATTRIBUTE_HEALTH, 0) + v4; 4105 + GetItemsBonus(CHARACTER_ATTRIBUTE_HEALTH, 0) + v4;
4207 case 0x20u: 4133 case 0x20u:
4208 case 0x21u: 4134 case 0x21u:
4209 case 0x22u: 4135 case 0x22u:
4210 case 0x23u: 4136 case 0x23u:
4211 v2 = GetActualIntelligence(); 4137 v2 = GetActualIntelligence();
4212 v3 = _48EA1B_get_static_effect(v2); 4138 v3 = GetParameterBonus(v2);
4213 goto LABEL_6; 4139 goto LABEL_6;
4214 case 9u: 4140 case 9u:
4215 case 0xAu: 4141 case 0xAu:
4216 case 0xBu: 4142 case 0xBu:
4217 case 0xCu: 4143 case 0xCu:
4221 case 0x18u: 4147 case 0x18u:
4222 case 0x19u: 4148 case 0x19u:
4223 case 0x1Au: 4149 case 0x1Au:
4224 case 0x1Bu: 4150 case 0x1Bu:
4225 v2 = GetActualWillpower(); 4151 v2 = GetActualWillpower();
4226 v3 = _48EA1B_get_static_effect(v2); 4152 v3 = GetParameterBonus(v2);
4227 goto LABEL_6; 4153 goto LABEL_6;
4228 case 0x15u: 4154 case 0x15u:
4229 case 0x16u: 4155 case 0x16u:
4230 case 0x17u: 4156 case 0x17u:
4231 case 0x1Cu: 4157 case 0x1Cu:
4232 case 0x1Du: 4158 case 0x1Du:
4233 case 0x1Eu: 4159 case 0x1Eu:
4234 case 0x1Fu: 4160 case 0x1Fu:
4235 v4 = GetActualWillpower(); 4161 v4 = GetActualWillpower();
4236 v5 = _48EA1B_get_static_effect(v4); 4162 v5 = GetParameterBonus(v4);
4237 v6 = GetActualIntelligence(); 4163 v6 = GetActualIntelligence();
4238 v3 = _48EA1B_get_static_effect(v6) + v5; 4164 v3 = GetParameterBonus(v6) + v5;
4239 LABEL_6: 4165 LABEL_6:
4240 v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3); 4166 v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3);
4241 v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA, 0) + v7; 4167 v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA, 0) + v7;
4242 v9 = uFullManaBonus 4168 v9 = uFullManaBonus
4243 + pBaseManaByClass[classType / 4] 4169 + pBaseManaByClass[classType / 4]
4265 int v5; // esi@1 4191 int v5; // esi@1
4266 int result; // eax@2 4192 int result; // eax@2
4267 4193
4268 v1 = this; 4194 v1 = this;
4269 v2 = GetActualSpeed(); 4195 v2 = GetActualSpeed();
4270 v3 = _48EA1B_get_static_effect(v2); 4196 v3 = GetParameterBonus(v2);
4271 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3; 4197 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3;
4272 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; 4198 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4;
4273 if ( v5 >= 1 ) 4199 if ( v5 >= 1 )
4274 result = v5; 4200 result = v5;
4275 else 4201 else
4288 int v6; // esi@1 4214 int v6; // esi@1
4289 int result; // eax@2 4215 int result; // eax@2
4290 4216
4291 v1 = this; 4217 v1 = this;
4292 v2 = GetActualSpeed(); 4218 v2 = GetActualSpeed();
4293 v3 = _48EA1B_get_static_effect(v2); 4219 v3 = GetParameterBonus(v2);
4294 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3; 4220 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3;
4295 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; 4221 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4;
4296 v6 = v1->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5; 4222 v6 = v1->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5;
4297 if ( v6 >= 1 ) 4223 if ( v6 >= 1 )
4298 result = v6; 4224 result = v6;
4514 4440
4515 return 18; 4441 return 18;
4516 } 4442 }
4517 4443
4518 //----- (0048EA1B) -------------------------------------------------------- 4444 //----- (0048EA1B) --------------------------------------------------------
4519 int Player::_48EA1B_get_static_effect(int a2) 4445 int Player::GetParameterBonus( int player_parameter )
4520 { 4446 {
4521 __int16 v2; // cx@1 4447 int i; // eax@1
4522 int v3; // eax@1 4448 i = 0;
4523 4449 while (param_to_bonus_table[i])
4524 v2 = word_4EDFFC[0]; 4450 {
4525 v3 = 0; 4451 if (player_parameter >= param_to_bonus_table[i])
4526 while ( a2 < v2 && v2 ) 4452 break;
4527 v2 = word_4EDFFC[v3++ + 1]; 4453 ++i;
4528 return player_stat_bonuses[v3]; 4454 }
4455 return parameter_to_bonus_value[i];
4529 } 4456 }
4530 4457
4531 //----- (0048EA46) -------------------------------------------------------- 4458 //----- (0048EA46) --------------------------------------------------------
4532 int Player::_48EA46_calc_special_bonus_by_items(int a2) 4459 int Player::_48EA46_calc_special_bonus_by_items(int a2)
4533 { 4460 {
9275 v8 = 8 * v4 + 400; 9202 v8 = 8 * v4 + 400;
9276 LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); 9203 LOBYTE(v8) = PID(OBJECT_Player,v4 - 112);
9277 pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); 9204 pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
9278 return result; 9205 return result;
9279 case VAR_CurrentHP: 9206 case VAR_CurrentHP:
9280 ReceiveDamage((signed int)pValue, 4); 9207 ReceiveDamage((signed int)pValue, DMGT_PHISYCAL);
9281 pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); 9208 pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4);
9282 v8 = 8 * v4 + 400; 9209 v8 = 8 * v4 + 400;
9283 LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); 9210 LOBYTE(v8) = PID(OBJECT_Player,v4 - 112);
9284 pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); 9211 pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0);
9285 return result; 9212 return result;