Mercurial > mm7
changeset 1037:ff2d888f8033
Merge
author | Gloval |
---|---|
date | Wed, 22 May 2013 22:26:31 +0400 |
parents | 7f8be9f9769e (diff) 306ec23b37df (current diff) |
children | 682ba1c83fd3 4430136083a6 |
files | Player.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp |
diffstat | 10 files changed, 290 insertions(+), 354 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Wed May 22 14:12:51 2013 +0200 +++ b/Actor.cpp Wed May 22 22:26:31 2013 +0400 @@ -992,11 +992,11 @@ do { v58 = (*v57)->GetActualWillpower(); - v59 = (*v57)->_48EA1B_get_static_effect(v58); + v59 = (*v57)->GetParameterBonus(v58); v60 = (*v57)->GetActualIntelligence(); - v61 = ((*v57)->_48EA1B_get_static_effect(v60) + v59) >> 1; + v61 = ((*v57)->GetParameterBonus(v60) + v59) >> 1; v62 = (*v57)->GetActualLuck(); - v63 = v61 + (*v57)->_48EA1B_get_static_effect(v62) + 30; + v63 = v61 + (*v57)->GetParameterBonus(v62) + 30; if ( rand() % v63 < 30 ) { v64 = 6048; @@ -3114,9 +3114,7 @@ if ( (signed __int64)v2->pActorBuffs[3].uExpireTime <= 0 ) { v12 = 0; - v11 = 0; - v10 = 0; - v9 = 0; + v8 = -1; } else @@ -3142,12 +3140,10 @@ v6 = 33075; } v12 = v6; - v11 = 0; - v10 = 0; - v9 = 0; + v8 = 0; } - pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, v9, v10, v11, v12); + pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, 0, 0, 0, v12); } }
--- a/Events.cpp Wed May 22 14:12:51 2013 +0200 +++ b/Events.cpp Wed May 22 22:26:31 2013 +0400 @@ -1037,7 +1037,7 @@ v115 = EVT_DWORD(_evt->v7 ); v89 = (unsigned __int8)v86; v88 = &pParty->pPlayers[v89]; - v88->ReceiveDamage(v115, v119); + v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); ++curr_seq_num; v4 = v124; break; @@ -1056,7 +1056,7 @@ v119 = _evt->v6; v88 = pPlayers[uActiveCharacter]; v115 = EVT_DWORD(_evt->v7 ); - v88->ReceiveDamage(v115, v119); + v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); ++curr_seq_num; v4 = v124; break; @@ -1067,7 +1067,7 @@ v115 = EVT_DWORD(_evt->v7 ); v89 = rand() % 4; v88 = &pParty->pPlayers[v89]; - v88->ReceiveDamage(v115, v119); + v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); ++curr_seq_num; v4 = v124; @@ -1078,7 +1078,7 @@ v87 = pParty->pPlayers; do { - v87->ReceiveDamage(v85, _evt->v6); + v87->ReceiveDamage(v85, (DAMAGE_TYPE)_evt->v6); ++v87; } while ( (signed int)v87 < (signed int)pParty->pHirelings );
--- a/Items.h Wed May 22 14:12:51 2013 +0200 +++ b/Items.h Wed May 22 22:26:31 2013 +0400 @@ -1,6 +1,18 @@ #pragma once - +enum DAMAGE_TYPE:unsigned int + { + DMGT_FIRE = 0, + DMGT_ELECTR = 1, + DMGT_COLD = 2, + DMGT_3 = 3, + DMGT_PHISYCAL= 4, + DMGT_5 = 5, + DMGT_SPIRIT = 6, + DMGT_MIND = 7, + DMGT_BODY = 8, + DMGT_DARK =10 + };
--- a/Player.cpp Wed May 22 14:12:51 2013 +0200 +++ b/Player.cpp Wed May 22 22:26:31 2013 +0400 @@ -103,14 +103,14 @@ unsigned char pAgeingSpeedMultiplier[4] = {100, 100, 40, 10}; unsigned char pAgeingLuckMultiplier[4] = {100, 100, 100, 100}; -unsigned int pAgeingTable[4] = {50, 100, 150, 65535}; +signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; unsigned int pConditionImportancyTable[18] = {16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}; -short word_4EDFFC[30] = {500, 400, 350, 300, 275, 250, 225, 200, 175, +short param_to_bonus_table[29] = {500, 400, 350, 300, 275, 250, 225, 200, 175, 150, 125, 100, 75, 50, 40, 35, 30, 25, 21, - 19, 17, 15, 13, 11, 9, 7, 5, 3, 0, 0}; -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}; + 19, 17, 15, 13, 11, 9, 7, 5, 3, 0}; +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}; unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0}; @@ -264,9 +264,9 @@ //----- (004B8040) -------------------------------------------------------- -int Player::_4B8040_condition_time(unsigned int uCondition) -{ - return (unsigned int)((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 0x18 % 7 + 1; +int Player::GetConditionDayOfWeek( unsigned int uCondition ) + { + return (unsigned int)(((signed __int64)((double)this->pConditions[uCondition] * 0.234375) / 60 / 60) / 24) % 7 + 1; } //----- (004B807C) -------------------------------------------------------- @@ -298,7 +298,7 @@ v10 = 10; v9 = 16; LABEL_6: - v11 = _4B8040_condition_time(v9); + v11 = GetConditionDayOfWeek(v9); goto LABEL_13; } } @@ -306,7 +306,7 @@ v5 = 0; do { - v6 = _4B8040_condition_time(v5); + v6 = GetConditionDayOfWeek(v5); if ( v6 > v4 ) v4 = v6; ++v5; @@ -2574,42 +2574,41 @@ //----- (0048CC33) -------------------------------------------------------- int Player::GetActualLuck() { - Player *v1; // esi@1 - unsigned int v2; // eax@7 - signed int v3; // ecx@7 - signed int v4; // ebx@10 - int v5; // edi@11 - int v6; // ebp@11 - signed int v8; // [sp+10h] [bp-4h]@1 - - v8 = 0; - v1 = this; + signed int curr_age; // eax@7 + signed int i; // ecx@7 + signed int age_luck_pc; // ebx@10 + int condition_luck_pc; // edi@11 + int items_luck_bonus; // ebp@11 + signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1 + signed int magic_luck_bonus; // [sp+10h] [bp-4h]@1 + int full_luck; + + npc_luck_bonus = 0; if ( CheckHiredNPCSpeciality(Fool) ) - v8 = 5; + npc_luck_bonus = 5; if ( CheckHiredNPCSpeciality(ChimneySweep) ) - v8 += 20; + npc_luck_bonus += 20; if ( CheckHiredNPCSpeciality(Psychic) ) - v8 += 10; - v2 = v1->sAgeModifier + GetBaseAge(); - v3 = 0; - while ( (signed int)v2 >= (signed int)pAgeingTable[v3] ) - { - ++v3; - if ( v3 >= 4 ) - { - v4 = 100; - goto LABEL_11; - } - } - v4 = pAgeingLuckMultiplier[v3]; -LABEL_11: - v5 = pConditionLuckMultiplier[GetMajorConditionIdx()]; - v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0); - return GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK) - + v6 - + v8 - + v5 * v4 * v1->uLuck / 100 / 100 - + v1->uLuckBonus; + npc_luck_bonus += 10; + curr_age = sAgeModifier + GetBaseAge(); + i = 0; + while ( curr_age >= pAgeingTable[i] ) + { + ++i; + if ( i >= 4 ) + break; + } + if (i < 4) + age_luck_pc = pAgeingLuckMultiplier[i]; + else + age_luck_pc = 100; + + condition_luck_pc = pConditionLuckMultiplier[GetMajorConditionIdx()]; + items_luck_bonus = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0); + magic_luck_bonus = GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK); + full_luck = magic_luck_bonus + items_luck_bonus + npc_luck_bonus+ uLuckBonus + + condition_luck_pc * age_luck_pc * uLuck / 100 / 100; + return full_luck; } //----- (0048CCF5) -------------------------------------------------------- @@ -2623,7 +2622,7 @@ v2 = this; v3 = GetActualAccuracy(); - v4 = _48EA1B_get_static_effect(v3); + v4 = GetParameterBonus(v3); v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK); v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2); return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus; @@ -2640,15 +2639,14 @@ int v6; // esi@1 signed int result; // eax@1 - v1 = this; + v2 = GetActualMight(); - v3 = _48EA1B_get_static_effect(v2); + v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; - v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; - result = 1; - if ( v6 >= 1 ) - result = v6; + result = _melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; + if ( result < 1 ) + result = 1; return result; } @@ -2665,7 +2663,7 @@ v1 = this; v2 = GetActualMight(); - v3 = _48EA1B_get_static_effect(v2); + v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; @@ -2868,7 +2866,7 @@ if ( !a2 ) { v22 = GetActualMight(); - v23 = _48EA1B_get_static_effect(v22); + v23 = GetParameterBonus(v22); v24 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v23; v21 += v5->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v24; } @@ -2894,7 +2892,7 @@ if ( v2 < 64 || v2 > 65 ) { v4 = GetActualAccuracy(); - v5 = _48EA1B_get_static_effect(v4); + v5 = GetParameterBonus(v4); v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5; v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; @@ -3038,114 +3036,97 @@ //----- (0048D2EA) -------------------------------------------------------- char *Player::GetMeleeDamageString() { - Player *v1; // esi@1 - signed int v2; // eax@1 - signed int v3; // edi@3 - signed int v4; // eax@3 - signed int v5; // ST0C_4@6 - char *v6; // edi@6 - signed int v7; // ST08_4@7 - unsigned int v8; // eax@8 - signed int v9; // esi@9 +signed int itemid; // eax@1 +int min_damage; // edi@3 +int max_damage; // eax@3 static char player__getmeleedamagestring_static_buff[40]; // idb - v1 = this; - v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; - if ( v2 < 64 || v2 > 65 ) - { - v3 = GetMeleeDamageMinimal(); - v4 = GetMeleeDamageMaximal(); - } + if ( pEquipment.uMainHand) + { + itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID; + if ( itemid < 64 || itemid > 65 ) //blasters + { + min_damage = GetMeleeDamageMinimal(); + max_damage = GetMeleeDamageMaximal(); + } + else + { //for blasters + min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0); + max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0); + } + if ( max_damage ) + { + if ( min_damage == max_damage ) + { + sprintf(player__getmeleedamagestring_static_buff, "%d", min_damage); + } + else + { + sprintf(player__getmeleedamagestring_static_buff, "%d - %d", min_damage, max_damage); + } + } + else + { + strcpy(player__getmeleedamagestring_static_buff, "N/A"); + } + + if (( itemid >= 135 )&&( itemid <= 159 )) //wands + { + strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" + } + } else - { - v3 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0); - v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0); - } - if ( v3 == v4 ) - { - v5 = v3; - v6 = player__getmeleedamagestring_static_buff; - sprintf(player__getmeleedamagestring_static_buff, "%d", v5); - } - else - { - v7 = v3; - v6 = player__getmeleedamagestring_static_buff; - sprintf(player__getmeleedamagestring_static_buff, "%d - %d", v7, v4); - } - v8 = v1->pEquipment.uMainHand; - if ( v8 ) - { - v9 = *(int *)&v1->pInventoryItems[v8-1]; - if ( v9 >= 135 ) - { - if ( v9 <= 159 ) - strcpy(v6, pGlobalTXT_LocalizationStrings[595]); - } - } - return v6; + strcpy(player__getmeleedamagestring_static_buff, "N/A"); + return player__getmeleedamagestring_static_buff; } //----- (0048D396) -------------------------------------------------------- char *Player::GetRangedDamageString() -{ - Player *v1; // esi@1 - signed int v2; // eax@1 - int v3; // edi@3 - int v4; // eax@3 - char *v5; // edi@6 - int v6; // ST0C_4@8 - int v7; // ST08_4@9 - unsigned int v8; // eax@10 - signed int v9; // esi@11 - - static char player__getrangeddamagestring_static_buff[40]; // idb - - v1 = this; - v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; - if ( v2 < 64 || v2 > 65 ) - { - v3 = GetRangedDamageMin(); - v4 = GetRangedDamageMax(); - } - else - { - v3 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1); - v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1); - } - if ( v4 ) - { - if ( v3 == v4 ) - { - v6 = v3; - v5 = player__getrangeddamagestring_static_buff; - sprintf(player__getrangeddamagestring_static_buff, "%d", v6); - } + { + signed int itemid; // eax@1 + int min_damage; // edi@3 + int max_damage; // eax@3 + + static char player__getrangeddamagestring_static_buff[40]; // idb + if ( pEquipment.uMainHand) + { + itemid= pOwnItems[this->pEquipment.uMainHand-1].uItemID; + if ( itemid < 64 || itemid > 65 ) //blasters + { + min_damage = GetRangedDamageMin(); + max_damage = GetRangedDamageMax(); + } + else + { //for blasters + min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 1); + max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 1); + } + if ( max_damage ) + { + if ( min_damage == max_damage ) + { + sprintf(player__getrangeddamagestring_static_buff, "%d", min_damage); + } + else + { + sprintf(player__getrangeddamagestring_static_buff, "%d - %d", min_damage, max_damage); + } + } + else + { + strcpy(player__getrangeddamagestring_static_buff, "N/A"); + } + + if (( itemid >= 135 )&&( itemid <= 159 )) //wands + { + strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" + } + } else - { - v7 = v3; - v5 = player__getrangeddamagestring_static_buff; - sprintf(player__getrangeddamagestring_static_buff, "%d - %d", v7, v4); - } - } - else - { - v5 = player__getrangeddamagestring_static_buff; - strcpy(player__getrangeddamagestring_static_buff, "N/A"); - } - v8 = v1->pEquipment.uMainHand; - if ( v8 ) - { - v9 = *(int *)&v1->pInventoryItems[v8-1]; - if ( v9 >= 135 ) - { - if ( v9 <= 159 ) - strcpy(v5, pGlobalTXT_LocalizationStrings[595]); - } - } - return v5; -} + strcpy(player__getrangeddamagestring_static_buff, "N/A"); + return player__getrangeddamagestring_static_buff; + } //----- (0048D45A) -------------------------------------------------------- bool Player::CanTrainToNextLevel() @@ -3174,117 +3155,74 @@ } //----- (0048D4B3) -------------------------------------------------------- -int Player::CalculateIncommingDamage(int resistance, signed int type) -{ - Player *v3; // esi@1 - int v4; // edi@8 - int v6; // eax@21 - signed int v7; // ebx@21 - int v8; // eax@22 - signed int v9; // ebx@22 - int v10; // eax@23 - signed int v11; // ebx@23 - int v12; // eax@24 - signed int v13; // edi@24 - unsigned int v14; // eax@27 - int v15; // eax@29 - double v16; // st7@32 - enum CHARACTER_ATTRIBUTE_TYPE v17; // [sp-4h] [bp-10h]@9 - signed int v18; // [sp+8h] [bp-4h]@17 - - v3 = this; - if ( !resistance ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)10; - goto LABEL_16; - } - if ( resistance == 1 ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)11; - goto LABEL_16; - } - if ( resistance == 2 ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)12; - goto LABEL_16; - } - if ( resistance == 3 ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)13; - goto LABEL_16; - } - if ( resistance == 6 ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)33; - goto LABEL_16; - } - if ( resistance == 7 ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)14; - goto LABEL_16; - } - if ( resistance == 8 ) - { - v17 = (CHARACTER_ATTRIBUTE_TYPE)15; -LABEL_16: - v4 = GetActualResistance(v17); - goto LABEL_17; - } - v4 = 0; -LABEL_17: - v18 = type; - if ( v3->classType == PLAYER_CLASS_LICH && v4 >= 200 ) +int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int amount ) + { + + int resist_value; // edi@8 + int player_luck; // eax@21 + signed int res_rand_divider; // ebx@2 + int armor_skill; // eax@29 + enum CHARACTER_ATTRIBUTE_TYPE player_resist; // [sp-4h] [bp-10h]@9 + signed int result_amount_dmg; // [sp+8h] [bp-4h]@17 + + player_resist=CHARACTER_ATTRIBUTE_STRENGTH; + switch(dmg_type) + { + case DMGT_FIRE: player_resist=CHARACTER_ATTRIBUTE_RESIST_FIRE; break; + case DMGT_ELECTR: player_resist=CHARACTER_ATTRIBUTE_RESIST_AIR; break; + case DMGT_COLD: player_resist=CHARACTER_ATTRIBUTE_RESIST_WATER; break; + case DMGT_3: player_resist=CHARACTER_ATTRIBUTE_RESIST_EARTH; break; + + case DMGT_SPIRIT: player_resist=CHARACTER_ATTRIBUTE_RESIST_SPIRIT;break; + case DMGT_MIND: player_resist=CHARACTER_ATTRIBUTE_RESIST_MIND; break; + case DMGT_BODY: player_resist=CHARACTER_ATTRIBUTE_RESIST_BODY; break; + } + if (player_resist) + resist_value = GetActualResistance(player_resist); + else + resist_value = 0; + + result_amount_dmg = amount; + if ( classType == PLAYER_CLASS_LICH && resist_value >= 200 ) return 0; - if ( v4 ) - { - v6 = GetActualLuck(); - v7 = _48EA1B_get_static_effect(v6) + v4 + 30; - if ( rand() % v7 >= 30 ) - { - v18 = type >> 1; - v8 = GetActualLuck(); - v9 = _48EA1B_get_static_effect(v8) + v4 + 30; - if ( rand() % v9 >= 30 ) + player_luck = GetActualLuck(); + res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30; + + if ( resist_value ) + { + if ( rand() % res_rand_divider >= 30 ) + { + result_amount_dmg = amount >> 1; + if ( rand() % res_rand_divider >= 30 ) { - v18 = type >> 2; - v10 = GetActualLuck(); - v11 = _48EA1B_get_static_effect(v10) + v4 + 30; - if ( rand() % v11 >= 30 ) + result_amount_dmg = amount >> 2; + if ( rand() % res_rand_divider >= 30 ) { - v18 = type >> 3; - v12 = GetActualLuck(); - v13 = _48EA1B_get_static_effect(v12) + v4 + 30; - if ( rand() % v13 >= 30 ) - v18 = type >> 4; + result_amount_dmg = amount >> 3; + if ( rand() % res_rand_divider >= 30 ) + result_amount_dmg = amount >> 4; } } } } - if ( resistance == 4 ) - { - v14 = v3->pEquipment.uArmor; - if ( v14 ) - { - // if ( !(v3->field_1F5[36 * v14 + 15] & 2) ) - if (v3->pOwnItems[v14-1].uAttributes&2) + if (( dmg_type == DMGT_PHISYCAL )&&( pEquipment.uArmor )) + { + if (!pOwnItems[pEquipment.uArmor-1].Broken()) { - v15 = GetEquippedItemSkillType(EQUIP_ARMOUR) - 10; - if ( v15 ) + armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR); + if ( armor_skill==PLAYER_SKILL_PLATE ) { - if ( v15 != 1 || (signed int)SkillToMastery(v3->pActiveSkills[11]) < 3 ) - return v18; - v16 = (double)v18 * 0.5; - return (signed __int64)v16; + if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) + return (int)(double)result_amount_dmg * 0.5; } - if ( (signed int)SkillToMastery(v3->pActiveSkills[10]) >= 4 ) + if (armor_skill==PLAYER_SKILL_CHAIN ) { - v16 = (double)v18 * 0.66670001; - return (signed __int64)v16; + if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4) + return (int)(double)result_amount_dmg * 0.66670001; } } - } - } - return v18; + } + return result_amount_dmg; } //----- (0048D62C) -------------------------------------------------------- @@ -3311,8 +3249,9 @@ { auto i = pEquipment.pIndices[uEquipIndex]; if (i) - return ~pInventoryItems[i - 1].uAttributes & 0x02; - else return false; + return ~(pInventoryItems[i - 1].uAttributes & ITEM_BROKEN); + else + return false; } //----- (0048D6D0) -------------------------------------------------------- @@ -3588,58 +3527,45 @@ } //----- (0048DC1E) -------------------------------------------------------- -int Player::ReceiveDamage(signed int type, int resistance) -{ - Player *v3; // esi@1 - signed int v4; // eax@1 - int v5; // eax@1 - bool v6; // ebx@1 - unsigned int v7; // eax@8 - char *v8; // ecx@9 - int v9; // eax@9 - //signed int typea; // [sp+14h] [bp+8h]@1 - - v3 = this; - this->pConditions[Condition_Sleep] = 0i64; - v4 = CalculateIncommingDamage(resistance, type); - v3->sHealth -= v4; - //typea = v4; - v5 = v3->sHealth; - v6 = v5 < -10; - LOBYTE(v6) = v5 <= -10; - if ( v5 < 1 ) - { - if ( v3->sHealth + v3->uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1 - || (signed __int64)v3->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 ) +int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type ) + { + signed int recieved_dmg; // eax@1 + unsigned int armor_indx; // eax@8 + bool broke_armor; + + pConditions[Condition_Sleep] = 0i64; + recieved_dmg = CalculateIncommingDamage(dmg_type, amount); + sHealth -= recieved_dmg; + broke_armor = sHealth <= -10; + if ( sHealth < 1 ) // + { + if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1) + || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0i64 ) { SetCondition(Condition_Unconcious, 0); } else { SetCondition(Condition_Dead, 0); - v6 = LODWORD(pParty->uTimePlayed); - if ( v3->sHealth > 0 ) - v3->sHealth = 0; - } - if ( v6 ) - { - v7 = v3->pEquipment.uArmor; - if ( v7 ) + //v6 = LODWORD(pParty->uTimePlayed); ???? if equals 0 do not broke armor? + if ( sHealth > 0 ) + sHealth = 0; + } + if (broke_armor ) + { + armor_indx = pEquipment.uArmor; + if ( armor_indx ) { -// v8 = &v3->field_1F5[36 * v7 + 15]; - v8=(char*)&v3->pOwnItems[v7-1].uAttributes; - v9 = *(int *)v8; - if ( !(BYTE1(v9) & 2) ) + if ( !pOwnItems[armor_indx-1].uAttributes & ITEM_ENCHANTED) { - LOBYTE(v9) = v9 | 2; - *(int *)v8 = v9; + pOwnItems[armor_indx-1].uAttributes|=ITEM_BROKEN; } } } } - if ( v4 && CanAct() ) + if ( recieved_dmg && CanAct() ) PlaySound(SPEECH_24, 0); - return v4; + return recieved_dmg; } //----- (0048DCF6) -------------------------------------------------------- @@ -3730,9 +3656,9 @@ goto LABEL_47; case 22: v8 = GetActualWillpower(); - v9 = _48EA1B_get_static_effect(v8); + v9 = GetParameterBonus(v8); v10 = GetActualIntelligence(); - v11 = (_48EA1B_get_static_effect(v10) + v9) >> 1; + v11 = (GetParameterBonus(v10) + v9) >> 1; break; case 17: v12 = 0; @@ -3805,7 +3731,7 @@ v47 = (unsigned __int8)v46[rand() % v4]; v6 = GetActualAccuracy(); LABEL_46: - v7 = _48EA1B_get_static_effect(v6); + v7 = GetParameterBonus(v6); LABEL_47: v11 = v7; break; @@ -3814,7 +3740,7 @@ break; } v22 = GetActualLuck(); - v23 = _48EA1B_get_static_effect(v22) + v11 + 30; + v23 = GetParameterBonus(v22) + v11 + 30; if ( rand() % v23 >= 30 ) { LABEL_87: @@ -4110,7 +4036,7 @@ shield_recovery = shield_base_recovery * SkillToMastery(pActiveSkills[skill_type]); } - uint player_speed_recovery_reduction = _48EA1B_get_static_effect(GetActualSpeed()), + uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()), sword_axe_bow_recovery_reduction = 0; bool shooting_laser = false; if (weapon_desc) @@ -4171,7 +4097,7 @@ int v4; // esi@1 int v6; // esi@1 - v3 = _48EA1B_get_static_effect(GetActualEndurance()); + v3 = GetParameterBonus(GetActualEndurance()); v4 = pBaseHealthPerLevelByClass[classType] * (GetActualLevel() + v3); v6 = uFullHealthBonus + pBaseHealthByClass[classType / 4] @@ -4209,7 +4135,7 @@ case 0x22u: case 0x23u: v2 = GetActualIntelligence(); - v3 = _48EA1B_get_static_effect(v2); + v3 = GetParameterBonus(v2); goto LABEL_6; case 9u: case 0xAu: @@ -4223,7 +4149,7 @@ case 0x1Au: case 0x1Bu: v2 = GetActualWillpower(); - v3 = _48EA1B_get_static_effect(v2); + v3 = GetParameterBonus(v2); goto LABEL_6; case 0x15u: case 0x16u: @@ -4233,9 +4159,9 @@ case 0x1Eu: case 0x1Fu: v4 = GetActualWillpower(); - v5 = _48EA1B_get_static_effect(v4); + v5 = GetParameterBonus(v4); v6 = GetActualIntelligence(); - v3 = _48EA1B_get_static_effect(v6) + v5; + v3 = GetParameterBonus(v6) + v5; LABEL_6: v7 = pBaseManaPerLevelByClass[classType] * (GetActualLevel() + v3); v8 = GetItemsBonus(CHARACTER_ATTRIBUTE_MANA, 0) + v7; @@ -4267,7 +4193,7 @@ v1 = this; v2 = GetActualSpeed(); - v3 = _48EA1B_get_static_effect(v2); + v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; if ( v5 >= 1 ) @@ -4290,7 +4216,7 @@ v1 = this; v2 = GetActualSpeed(); - v3 = _48EA1B_get_static_effect(v2); + v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_AC_BONUS, 0) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v4; v6 = v1->sACModifier + GetMagicalBonus(CHARACTER_ATTRIBUTE_AC_BONUS) + v5; @@ -4516,16 +4442,17 @@ } //----- (0048EA1B) -------------------------------------------------------- -int Player::_48EA1B_get_static_effect(int a2) -{ - __int16 v2; // cx@1 - int v3; // eax@1 - - v2 = word_4EDFFC[0]; - v3 = 0; - while ( a2 < v2 && v2 ) - v2 = word_4EDFFC[v3++ + 1]; - return player_stat_bonuses[v3]; +int Player::GetParameterBonus( int player_parameter ) + { + int i; // eax@1 + i = 0; + while (param_to_bonus_table[i]) + { + if (player_parameter >= param_to_bonus_table[i]) + break; + ++i; + } + return parameter_to_bonus_value[i]; } //----- (0048EA46) -------------------------------------------------------- @@ -9277,7 +9204,7 @@ pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_CurrentHP: - ReceiveDamage((signed int)pValue, 4); + ReceiveDamage((signed int)pValue, DMGT_PHISYCAL); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; LOBYTE(v8) = PID(OBJECT_Player,v4 - 112);
--- a/Player.h Wed May 22 14:12:51 2013 +0200 +++ b/Player.h Wed May 22 22:26:31 2013 +0400 @@ -184,6 +184,7 @@ CHARACTER_ATTRIBUTE_RANGED_DAMAGE_BONUS = 0x1E, CHARACTER_ATTRIBUTE_RANGED_DAMAGE_MIN = 0x1F, CHARACTER_ATTRIBUTE_RANGED_DAMAGE_MAX = 0x20, + CHARACTER_ATTRIBUTE_RESIST_SPIRIT = 0x21 }; /* 328 */ @@ -491,7 +492,7 @@ char *GetRangedDamageString(); bool CanTrainToNextLevel(); unsigned int GetExperienceDisplayColor(); - int CalculateIncommingDamage(int resistance, signed int type); + int CalculateIncommingDamage(DAMAGE_TYPE dmg_type, int amount); ITEM_EQUIP_TYPE GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot); PLAYER_SKILL_TYPE GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot); bool IsUnarmed(); @@ -501,7 +502,7 @@ bool StealFromShop(struct ItemGen *a2, int a3, int a4, int a5, int *a6); int StealFromActor(unsigned int uActorID, int _steal_perm, int reputation); void Heal(int amount); - int ReceiveDamage(signed int type, int resistance); + int ReceiveDamage(signed int amount, DAMAGE_TYPE dmg_type); int _48DCF6(int a2, struct Actor *pActor); unsigned int GetSpellSchool(unsigned int uSpellID); int GetAttackRecoveryTime(bool bRangedAttack); @@ -516,7 +517,7 @@ void SetRecoveryTime(signed int sRecoveryTime); void RandomizeName(); unsigned int GetMajorConditionIdx(); - int _48EA1B_get_static_effect(int a2); + int GetParameterBonus(int player_parameter); int _48EA46_calc_special_bonus_by_items(int a2); int GetItemsBonus(enum CHARACTER_ATTRIBUTE_TYPE attr, int a3); int GetMagicalBonus(enum CHARACTER_ATTRIBUTE_TYPE a2); @@ -571,7 +572,7 @@ int GetBuyingPrice(unsigned int uRealValue, float price_multiplier); int GetPriceSell(int uRealValue, float price_multiplier); int _4B807C(float a2); - int _4B8040_condition_time(unsigned int uCondition); + int GetConditionDayOfWeek(unsigned int uCondition); bool _43EEF3(); void SalesProcess(unsigned int inventory_idnx, int item_index, int _2devent_idx);//0x4BE2DD bool Recover(signed int a2);
--- a/SpriteObject.cpp Wed May 22 14:12:51 2013 +0200 +++ b/SpriteObject.cpp Wed May 22 22:26:31 2013 +0400 @@ -1080,7 +1080,7 @@ if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) (*v12)->PlaySound(SPEECH_6, 0); else - (*v12)->ReceiveDamage(v11, v18); + (*v12)->ReceiveDamage(v11, (DAMAGE_TYPE)v18); ++v12; } while ( (signed int)v12 <= (signed int)&pPlayers[4] );
--- a/UIHouses.cpp Wed May 22 14:12:51 2013 +0200 +++ b/UIHouses.cpp Wed May 22 22:26:31 2013 +0400 @@ -4797,7 +4797,7 @@ HIDWORD(v59) = TargetColor(0xFFu, 0xFFu, 0x9Bu); v1 = pPlayers[uActiveCharacter]; //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]); - v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier); + v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[v0->par1C - 1].fPriceMultiplier); HIDWORD(v60) = v2; if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) {
--- a/mm7_3.cpp Wed May 22 14:12:51 2013 +0200 +++ b/mm7_3.cpp Wed May 22 22:26:31 2013 +0400 @@ -1662,8 +1662,8 @@ auto player = pParty->pPlayers + i; if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, 8)) { - player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, 4); - v10 = (double)(20 - player->_48EA1B_get_static_effect(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; + player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL); + v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; player->SetRecoveryTime((signed __int64)v10); } } @@ -2301,8 +2301,8 @@ { player->ReceiveDamage( (signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(player->GetMaxHealth() / 10)) / 256, - 4); - v105 = 20 - player->_48EA1B_get_static_effect(player->GetActualEndurance()); + DMGT_PHISYCAL); + v105 = 20 - player->GetParameterBonus(player->GetActualEndurance()); player->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); } //} @@ -3081,9 +3081,9 @@ v110 = (*v74)->GetMaxHealth(); (*v74)->ReceiveDamage( (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, - 4); + DMGT_PHISYCAL); v75 = (*v74)->GetActualEndurance(); - v110 = 20 - (*v74)->_48EA1B_get_static_effect(v75); + v110 = 20 - (*v74)->GetParameterBonus(v75); (*v74)->SetRecoveryTime( (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); ++v74; @@ -3203,9 +3203,9 @@ v110 = (*v84)->GetMaxHealth(); (*v84)->ReceiveDamage( (signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, - 4); + DMGT_PHISYCAL); v85 = (*v84)->GetActualEndurance(); - v110 = 20 - (*v84)->_48EA1B_get_static_effect(v85); + v110 = 20 - (*v84)->GetParameterBonus(v85); (*v84)->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); ++v84; } @@ -14552,7 +14552,7 @@ { pPlayer = *v8; if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) - pPlayer->ReceiveDamage(v4, 5); + pPlayer->ReceiveDamage(v4, DMGT_5); ++v8; } while ( (signed int)v8 <= (signed int)&pPlayers[4] );
--- a/mm7_4.cpp Wed May 22 14:12:51 2013 +0200 +++ b/mm7_4.cpp Wed May 22 22:26:31 2013 +0400 @@ -2395,7 +2395,7 @@ { v14 = pPlayers[v12]; v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1; - v14->ReceiveDamage((signed __int64)v15, 0); + v14->ReceiveDamage((signed __int64)v15, DMGT_FIRE); if ( pParty->uFlags & 4 ) { strcpy(GameUI_Footer_TimedString, pGlobalTXT_LocalizationStrings[660]); @@ -2424,7 +2424,7 @@ { v17 = *v16; v18 = (double)(*v16)->GetMaxHealth() * 0.1; - v17->ReceiveDamage((signed __int64)v18, 0); + v17->ReceiveDamage((signed __int64)v18, DMGT_FIRE); if ( pParty->uFlags & 0x200 ) { strcpy(GameUI_Footer_TimedString, pGlobalTXT_LocalizationStrings[661]);
--- a/mm7_5.cpp Wed May 22 14:12:51 2013 +0200 +++ b/mm7_5.cpp Wed May 22 22:26:31 2013 +0400 @@ -4760,7 +4760,7 @@ && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41 || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41) && uDamageAmount != v41 ) - player->ReceiveDamage(uDamageAmount, a2); + player->ReceiveDamage(uDamageAmount, (DAMAGE_TYPE)a2); v50 = 24; v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; if ( (player->_48EA46_calc_special_bonus_by_items(24) || hit_will_stun != v41) @@ -5012,7 +5012,7 @@ LABEL_43: if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { - v24 = v6->ReceiveDamage(v77, v22); + v24 = v6->ReceiveDamage(v77, (DAMAGE_TYPE)v22); if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0 && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) ) { @@ -5075,7 +5075,7 @@ if ( !pParty->bTurnBasedModeOn ) { v35 = v6->GetActualEndurance(); - v36 = (double)(20 - v6->_48EA1B_get_static_effect(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; + v36 = (double)(20 - v6->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; v6->SetRecoveryTime((signed __int64)v36); } if ( v77 ) @@ -5197,7 +5197,7 @@ LABEL_133: if ( !(dword_6BE368_debug_settings_2 & 0x10) ) { - v54 = v45->ReceiveDamage(v77, v50); + v54 = v45->ReceiveDamage(v77, (DAMAGE_TYPE)v50); if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) >= 0 ) { if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v45->pPlayerBuffs[10].uExpireTime) ) @@ -5263,7 +5263,7 @@ if ( !pParty->bTurnBasedModeOn ) { v65 = v45->GetActualEndurance(); - v66 = (double)(20 - v45->_48EA1B_get_static_effect(v65)) + v66 = (double)(20 - v45->GetParameterBonus(v65)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; v45->SetRecoveryTime((signed __int64)v66); @@ -5294,7 +5294,7 @@ v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0); v69 = 0; } - a4b->ReceiveDamage(v68, v69); + a4b->ReceiveDamage(v68, (DAMAGE_TYPE)v69); if ( v38 == OBJECT_Player && !qword_A750D8 ) { qword_A750D8 = 256i64; @@ -10768,7 +10768,7 @@ { v0->RemoveItemAtInventoryIndex(v18); v26 = rand(); - v0->ReceiveDamage(v26 % 11 + 10, 0); + v0->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE); pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); @@ -10784,7 +10784,7 @@ { v0->RemoveItemAtInventoryIndex(v18); v25 = rand(); - v0->ReceiveDamage(v25 % 71 + 30, 0); + v0->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE); v23 = 1; } else @@ -10793,7 +10793,7 @@ { v0->RemoveItemAtInventoryIndex(v18); v24 = rand(); - v0->ReceiveDamage(v24 % 201 + 50, 0); + v0->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE); v23 = 5; } else