Mercurial > mm7
diff Player.cpp @ 1048:d36681a9e4f8
Слияние
author | Ritor1 |
---|---|
date | Thu, 23 May 2013 11:17:01 +0600 |
parents | b725a9cdec0c c5498375832a |
children | efe228ab5003 |
line wrap: on
line diff
--- a/Player.cpp Thu May 23 11:16:46 2013 +0600 +++ b/Player.cpp Thu May 23 11:17:01 2013 +0600 @@ -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; @@ -2917,9 +2915,9 @@ int result; // eax@6 v1 = this; - v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DAMAGE_MIN, 0); - v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DAMAGE_BONUS) + v2; - v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DAMAGE_BONUS) + v3; + v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN, 0); + v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; + v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; v5 = v1->pActiveSkills[5]; if ( v5 && (signed int)SkillToMastery(v5) >= 4 && HasItemEquipped(EQUIP_BOW) ) v4 += v1->pActiveSkills[5] & 0x3F; @@ -2941,9 +2939,9 @@ int result; // eax@6 v1 = this; - v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DAMAGE_MAX, 0); - v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DAMAGE_BONUS) + v2; - v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DAMAGE_BONUS) + v3; + v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX, 0); + v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; + v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; v5 = v1->pActiveSkills[5]; if ( v5 && (signed int)SkillToMastery(v5) >= 4 && HasItemEquipped(EQUIP_BOW) ) v4 += v1->pActiveSkills[5] & 0x3F; @@ -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,53 +4442,48 @@ } //----- (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) -------------------------------------------------------- int Player::_48EA46_calc_special_bonus_by_items(int a2) { - int v3; // esi@1 - int v4; // edx@2 - int v5; // eax@3 - char *v6; // eax@4 - - v3 = 0; - while ( 1 ) - { - if ( !HasItemEquipped((ITEM_EQUIP_TYPE)v3) ) - goto LABEL_11; - v5 = pEquipment.pIndices[v3] - 1; - if ( a2 != 17 ) - { - if ( a2 != 24 || this->pInventoryItems[v5].uSpecEnchantmentType != 24 ) - goto LABEL_11; - return 5; - } - v6 = (char *)this + 36 * v5; - if ( *((int *)v6 + 133) == 533 || *((int *)v6 + 136) == 17 ) - return 50; -LABEL_11: - ++v3; - if ( (signed int)v3 >= 16 ) - return 0; - } + int inv_indx; // eax@3 + + for (int i=EQUIP_OFF_HAND; i<EQUIP_BOOK; ++i ) + { + if ( !HasItemEquipped((ITEM_EQUIP_TYPE)i) ) + continue; + inv_indx = pEquipment.pIndices[i] - 1; + if (a2==17) + { + if ((pInventoryItems[inv_indx].uSpecEnchantmentType==17)||(pInventoryItems[inv_indx].uItemID=533)) //Elven Chainmail+Increases rate of Recovery + return 50; + } + if (a2==24) + { + if (pInventoryItems[inv_indx].uSpecEnchantmentType==24) //Increased Knockback. + return 5; + } + } + return 0; } //----- (0048EAAE) -------------------------------------------------------- int Player::GetItemsBonus(CHARACTER_ATTRIBUTE_TYPE attr, int a3) { CHARACTER_ATTRIBUTE_TYPE v3; // esi@1 - signed int v4; // eax@1 + // signed int v4; // eax@1 int v5; // edi@1 Player *v6; // ebx@1 Player *v8; // ecx@48 @@ -4623,145 +4544,73 @@ int v63; // [sp+18h] [bp-4h]@101 ItemGen *attra; // [sp+20h] [bp+4h]@101 unsigned int v65; // [sp+24h] [bp+8h]@95 + bool no_skills; v3 = attr; - v4 = 36; v5 = 0; v6 = this; v62 = 0; v61 = 0; + + no_skills=false; switch (attr) - { - case CHARACTER_ATTRIBUTE_LEVEL: - if (HasEnchantedItemEquipped(25)) - return 5; - return 0; - }; - - if ( (signed int)attr > 36 ) - { - switch ( attr ) - { - case 37: - v58 = 15; - goto LABEL_35; - case 38: - v58 = 16; - goto LABEL_35; - case 39: - v58 = 17; - goto LABEL_35; - case 40: - v58 = 18; - goto LABEL_35; - case 41: - v58 = 19; - goto LABEL_35; - case 42: - v58 = 20; - goto LABEL_35; - case 43: - v58 = 25; - goto LABEL_35; - case 44: - v58 = 5; - goto LABEL_35; - case 45: - v58 = 8; - goto LABEL_35; - case 46: - goto LABEL_36; - default: - break; - } - } - else - { - if ( attr == 36 ) - { - v58 = 14; - } - else - { - if ( (signed int)attr > 21 ) { - switch ( attr ) - { - case 22: - v58 = 30; - break; - case 23: - v58 = 31; - break; - case 34: - v58 = 12; - break; - default: - if ( attr != 35 ) - goto LABEL_38; - v58 = 13; - break; - } + case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: v58 = PLAYER_SKILL_ALCHEMY; break; + case CHARACTER_ATTRIBUTE_SKILL_STEALING: v58 = PLAYER_SKILL_STEALING; break; + case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM: v58 = PLAYER_SKILL_TRAP_DISARM; break; + case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID: v58 = PLAYER_SKILL_ITEM_ID; break; + case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID: v58 = PLAYER_SKILL_MONSTER_ID; break; + case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER: v58 = PLAYER_SKILL_ARMSMASTER; break; + case CHARACTER_ATTRIBUTE_SKILL_DODGE: v58 = PLAYER_SKILL_DODGE; break; + case CHARACTER_ATTRIBUTE_SKILL_UNARMED: v58 = PLAYER_SKILL_UNARMED; break; + case CHARACTER_ATTRIBUTE_SKILL_FIRE: v58 = PLAYER_SKILL_FIRE; break; + case CHARACTER_ATTRIBUTE_SKILL_AIR: v58 = PLAYER_SKILL_AIR; break; + case CHARACTER_ATTRIBUTE_SKILL_WATER: v58 = PLAYER_SKILL_WATER; break; + case CHARACTER_ATTRIBUTE_SKILL_EARTH: v58 = PLAYER_SKILL_EARTH; break; + case CHARACTER_ATTRIBUTE_SKILL_SPIRIT: v58 = PLAYER_SKILL_SPIRIT; break; + case CHARACTER_ATTRIBUTE_SKILL_MIND: v58 = PLAYER_SKILL_MIND; break; + case CHARACTER_ATTRIBUTE_SKILL_BODY: v58 = PLAYER_SKILL_BODY; break; + case CHARACTER_ATTRIBUTE_SKILL_LIGHT: v58 = PLAYER_SKILL_LIGHT; break; + case CHARACTER_ATTRIBUTE_SKILL_DARK: v58 = PLAYER_SKILL_DARK; break; + case CHARACTER_ATTRIBUTE_SKILL_MEDITATION: v58 = PLAYER_SKILL_MEDITATION; break; + case CHARACTER_ATTRIBUTE_SKILL_BOW: v58 = PLAYER_SKILL_BOW; break; + case CHARACTER_ATTRIBUTE_SKILL_SHIELD: v58 = PLAYER_SKILL_SHIELD; break; + case CHARACTER_ATTRIBUTE_SKILL_LEARNING: v58 = PLAYER_SKILL_LEARNING; break; + default: + no_skills=true; } - else + if (!no_skills) { - switch ( attr ) - { - case 21: - v58 = 33; - break; - case 16: - v58 = 35; - break; - case 17: - v58 = 34; - break; - case 18: - v58 = 29; - break; - case 19: - v58 = 21; - break; - default: - if ( attr != 20 ) - goto LABEL_38; - v58 = 32; - break; - } + if ( !this->pActiveSkills[v58] ) + return 0; } - } -LABEL_35: - v4 = v58; -LABEL_36: - if ( !this->pActiveSkills[v4] ) - return 0; - } -LABEL_38: + if ( (signed int)attr > 28 ) { if ( (signed int)attr < 29 ) return v5 + v62 + v61; - if ( (signed int)attr <= 30 ) + if ( (signed int)attr <= CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS ) { if ( HasItemEquipped(EQUIP_BOW) ) - v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]].uDamageMod; + v5 = pItemsTable->pItems[v6->pOwnItems[v6->pEquipment.uBow-1].uItemID].uDamageMod; return v5 + v62 + v61; } - if ( attr == 31 ) + if ( attr == CHARACTER_ATTRIBUTE_RANGED_DMG_MIN ) { if ( !HasItemEquipped(EQUIP_BOW) ) return v5 + v62 + v61; - v57 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]; + v57 = v6->pOwnItems[v6->pEquipment.uBow-1].uItemID; v5 = pItemsTable->pItems[v57].uDamageMod; v56 = pItemsTable->pItems[v57].uDamageDice; - goto LABEL_366; - } - if ( attr == 32 ) + v5 += v56; + return v5 + v62 + v61; + } + if ( attr == CHARACTER_ATTRIBUTE_RANGED_DMG_MAX ) { if ( !HasItemEquipped(EQUIP_BOW) ) return v5 + v62 + v61; - v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]; + v20 = v6->pOwnItems[v6->pEquipment.uBow-1].uItemID; v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll; LABEL_365: v56 = pItemsTable->pItems[v20].uDamageMod; @@ -5337,7 +5186,7 @@ return v5 + v62 + v61; } } - if ( attr == 28 ) + if ( attr == CHARACTER_ATTRIBUTE_MELEE_DMG_MAX ) { if ( IsUnarmed() != 1 ) { @@ -5348,7 +5197,7 @@ { if ( v22 <= 2 ) { - v23 = this->pInventoryItems[this->pEquipment.uMainHand].uItemID; + v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID; if ( v6->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) { v24 = v23; @@ -5364,11 +5213,18 @@ } } } - if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v28 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND), v28 < 0) || v28 > 2 ) - return v5 + v62 + v61; + + if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) ) + { + + v28 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND); + if ((v28 < 0) || v28 > 2 ) + return v5 + v62 + v61; + } v15 = pItemsTable->pItems[v29].uDamageMod; v14 = pItemsTable->pItems[v29].uDamageDice * pItemsTable->pItems[v29].uDamageRoll; - goto LABEL_88; + v5 += v15 + v14; + return v5 + v62 + v61 } v59 = 3; LABEL_74: @@ -5377,11 +5233,18 @@ } if ( (signed int)attr < 0 ) return v5 + v62 + v61; - if ( (signed int)attr <= 23 ) + if ( (signed int)attr <= CHARACTER_ATTRIBUTE_SKILL_UNARMED ) goto LABEL_95; - if ( (signed int)attr <= 24 ) + if ( attr == CHARACTER_ATTRIBUTE_LEVEL ) + { + if ( !Player::HasEnchantedItemEquipped(25) ) + return v5 + v62 + v61; + v5 = 5; + return v5 + v62 + v61; + } + if ( (signed int)attr <= CHARACTER_ATTRIBUTE_LEVEL ) return v5 + v62 + v61; - if ( (signed int)attr <= 26 ) + if ( (signed int)attr <= CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) { if ( IsUnarmed() == 1 ) { @@ -5394,15 +5257,17 @@ if ( v17 >= 0 ) { if ( v17 <= 2 ) - v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uMainHand-1]].uDamageMod; + v5 = pItemsTable->pItems[v6->pOwnItems[v6->pEquipment.uMainHand-1].uItemID].uDamageMod; } } if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v19 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND), v19 < 0) || v19 > 2 ) return v5 + v62 + v61; - v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uShield - 1]; - goto LABEL_365; - } - if ( attr == 27 ) + v20 = v6->pOwnItems[v6->pEquipment.uShield - 1].uItemID; + v56 = pItemsTable->pItems[v20].uDamageMod; + v5 += v56; + return v5 + v62 + v61; + } + if ( attr == CHARACTER_ATTRIBUTE_MELEE_DMG_MIN ) { if ( IsUnarmed() == 1 ) { @@ -5416,20 +5281,25 @@ { if ( v9 <= 2 ) { - v5 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uMainHand].uItemID].uDamageDice + - pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uMainHand].uItemID].uDamageMod; + v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageDice + + pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageMod; if ( !v6->pEquipment.uShield ) { - if ( pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uMainHand].uItemID].uSkillType == 4 ) + if ( pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uSkillType == 4 ) ++v5; } } } } - if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v12 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND), v12 < 0) || v12 > 2 ) - return v5 + v62 + v61; - v14 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uShield].uItemID].uDamageMod; - v15 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uShield].uItemID].uDamageDice; + + if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND)) + { + v12 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND); + if ((v12 < 0) || v12 > 2 ) + return v5 + v62 + v61; + } + v14 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageMod; + v15 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageDice; LABEL_88: v5 += v15 + v14; } @@ -5555,8 +5425,7 @@ v2 = 6; if ( CheckHiredNPCSpeciality(Sage) ) v2 += 6; - v8 = (CHARACTER_ATTRIBUTE_TYPE)20; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 0); } break; @@ -5566,8 +5435,7 @@ v2 = 2; if ( CheckHiredNPCSpeciality(Weaponsmaster) ) v2 += 3; - v8 = (CHARACTER_ATTRIBUTE_TYPE)21; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 0); } break; @@ -5575,8 +5443,7 @@ { if (CheckHiredNPCSpeciality(Burglar)) v2 = 8; - v8 = (CHARACTER_ATTRIBUTE_TYPE)17; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_STEALING, 0); } break; @@ -5587,8 +5454,7 @@ v2 = 4; if ( CheckHiredNPCSpeciality(Apothecary) ) v2 += 8; - v8 = (CHARACTER_ATTRIBUTE_TYPE)16; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 0); } break; @@ -5600,8 +5466,7 @@ v2 += 15; if ( CheckHiredNPCSpeciality(Scholar) ) v2 += 5; - v8 = (CHARACTER_ATTRIBUTE_TYPE)46; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LEARNING, 0); } break; @@ -5609,8 +5474,7 @@ { if (CheckHiredNPCSpeciality(Monk) ) v2 = 2; - v8 = (CHARACTER_ATTRIBUTE_TYPE)23; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 0); } break; @@ -5618,18 +5482,15 @@ { if ( CheckHiredNPCSpeciality(Monk) ) v2 = 2; - v8 = (CHARACTER_ATTRIBUTE_TYPE)22; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DODGE, 0); } break; case PLAYER_SKILL_BOW: - v8 = (CHARACTER_ATTRIBUTE_TYPE)44; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BOW, 0); break; case PLAYER_SKILL_SHIELD: - v8 = (CHARACTER_ATTRIBUTE_TYPE)45; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 0); break; case PLAYER_SKILL_EARTH: @@ -5641,8 +5502,7 @@ v2 += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) v2 += 3; - v8 = (CHARACTER_ATTRIBUTE_TYPE)37; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_EARTH, 0); break; case PLAYER_SKILL_FIRE: if ( CheckHiredNPCSpeciality(Apprentice) ) @@ -5653,8 +5513,7 @@ v2 += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) v2 += 3; - v8 = (CHARACTER_ATTRIBUTE_TYPE)34; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0); break; case PLAYER_SKILL_AIR: if ( CheckHiredNPCSpeciality(Apprentice) ) @@ -5665,8 +5524,7 @@ v2 += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) v2 += 3; - v8 = (CHARACTER_ATTRIBUTE_TYPE)35; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_AIR, 0); break; case PLAYER_SKILL_WATER: if ( CheckHiredNPCSpeciality(Apprentice) ) @@ -5677,8 +5535,7 @@ v2 += 4; if ( classType == PLAYER_CLASS_WARLOCK && PartyHasDragon() ) v2 += 3; - v8 = (CHARACTER_ATTRIBUTE_TYPE)36; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_WATER, 0); break; case PLAYER_SKILL_SPIRIT: if ( CheckHiredNPCSpeciality(Acolyte2) ) @@ -5687,8 +5544,7 @@ v2 += 3; if ( CheckHiredNPCSpeciality(Prelate) ) v2 += 4; - v8 = (CHARACTER_ATTRIBUTE_TYPE)38; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0); break; case PLAYER_SKILL_MIND: if ( CheckHiredNPCSpeciality(Acolyte2) ) @@ -5697,8 +5553,7 @@ v2 += 3; if ( CheckHiredNPCSpeciality(Prelate) ) v2 += 4; - v8 = (CHARACTER_ATTRIBUTE_TYPE)39; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MIND, 0); break; case PLAYER_SKILL_BODY: if ( CheckHiredNPCSpeciality(Acolyte2) ) @@ -5707,17 +5562,14 @@ v2 += 3; if ( CheckHiredNPCSpeciality(Prelate) ) v2 += 4; - v8 = (CHARACTER_ATTRIBUTE_TYPE)40; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_BODY, 0); break; case PLAYER_SKILL_LIGHT: - v8 = (CHARACTER_ATTRIBUTE_TYPE)41; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0); break; case PLAYER_SKILL_DARK: { - v8 = (CHARACTER_ATTRIBUTE_TYPE)42; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_DARK, 0); } break; @@ -5744,12 +5596,10 @@ break; case PLAYER_SKILL_ITEM_ID: - v8 = (CHARACTER_ATTRIBUTE_TYPE)19; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 0); break; case PLAYER_SKILL_MEDITATION: - v8 = (CHARACTER_ATTRIBUTE_TYPE)43; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 0); break; case PLAYER_SKILL_TRAP_DISARM: { @@ -5759,8 +5609,7 @@ v2 += 6; if ( CheckHiredNPCSpeciality(Burglar) ) v2 += 8; - v8 = (CHARACTER_ATTRIBUTE_TYPE)18; - v2 += GetItemsBonus(v8, 0); + v2 += GetItemsBonus(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 0); } break; } @@ -6605,43 +6454,43 @@ pStep = StatTable[0][v2].uBaseStep; switch ( eAttribute ) { - case CHARACTER_MIGHT: + case CHARACTER_ATTRIBUTE_STRENGTH: if ( this->uMight <= pBaseValue ) pStep = pDroppedStep; if ( this->uMight - pStep >= uMinValue ) this->uMight -= pStep; break; - case CHARACTER_INTELLIGANCE: + case CHARACTER_ATTRIBUTE_INTELLIGENCE: if ( this->uIntelligence <= pBaseValue ) pStep = pDroppedStep; if ( this->uIntelligence - pStep >= uMinValue ) this->uIntelligence -= pStep; break; - case CHARACTER_WILLPOWER: + case CHARACTER_ATTRIBUTE_WILLPOWER: if ( this->uWillpower <= pBaseValue ) pStep = pDroppedStep; if ( this->uWillpower - pStep >= uMinValue ) this->uWillpower -= pStep; break; - case CHARACTER_ENDURANCE: + case CHARACTER_ATTRIBUTE_ENDURANCE: if ( this->uEndurance <= pBaseValue ) pStep = pDroppedStep; if ( this->uEndurance - pStep >= uMinValue ) this->uEndurance -= pStep; break; - case CHARACTER_ACCURACY: + case CHARACTER_ATTRIBUTE_ACCURACY: if ( this->uAccuracy <= pBaseValue ) pStep = pDroppedStep; if ( this->uAccuracy - pStep >= uMinValue ) this->uAccuracy -= pStep; break; - case CHARACTER_SPEED: + case CHARACTER_ATTRIBUTE_SPEED: if ( this->uSpeed <= pBaseValue ) pStep = pDroppedStep; if ( this->uSpeed - pStep >= uMinValue ) this->uSpeed -= pStep; break; - case CHARACTER_LUCK: + case CHARACTER_ATTRIBUTE_LUCK: if ( this->uLuck <= pBaseValue ) pStep = pDroppedStep; if ( this->uLuck - pStep >= uMinValue ) @@ -6836,78 +6685,29 @@ void Player::UseItem_DrinkPotion_etc(signed int player_num, int a3) { Player *v3; // esi@1 - unsigned int v4; // ebx@4 signed int v5; // eax@17 - unsigned int v6; // eax@26 - unsigned __int8 v7; // cf@37 int v8; // edx@39 - int v9; // edx@40 - int v10; // edx@41 - int v11; // edx@42 - int v12; // edx@43 char *v13; // eax@45 - AudioPlayer *v14; // ecx@62 signed int v15; // edi@68 int v16; // edx@73 unsigned __int16 v17; // edi@73 unsigned int v18; // eax@73 - int v19; // eax@74 - int v20; // eax@75 - signed int v21; // eax@81 const char *v22; // eax@84 - char *v23; // ecx@90 int scroll_id; // esi@96 int v25; // eax@109 int v26; // eax@113 int new_mana_val; // edi@114 signed __int64 v28; // qax@120 - char *v29; // ecx@120 __int64 v30; // edi@137 - int v31; // ST30_4@137 __int64 v32; // ST3C_4@137 - int v33; // ST40_4@137 __int64 v34; // ST34_4@137 - int v35; // ST38_4@137 - unsigned __int8 v36; // al@173 - SoundID v37; // [sp-20h] [bp-4Ch]@18 - SoundID v38; // [sp-20h] [bp-4Ch]@174 - signed int v39; // [sp-1Ch] [bp-48h]@18 - signed int v40; // [sp-1Ch] [bp-48h]@174 - unsigned int v41; // [sp-18h] [bp-44h]@18 - unsigned int v42; // [sp-18h] [bp-44h]@174 - signed int v43; // [sp-14h] [bp-40h]@18 - signed int v44; // [sp-14h] [bp-40h]@174 - signed int v45; // [sp-10h] [bp-3Ch]@18 - unsigned __int16 v46; // [sp-10h] [bp-3Ch]@120 - signed int v47; // [sp-10h] [bp-3Ch]@174 - int v48; // [sp-Ch] [bp-38h]@18 - unsigned int v49; // [sp-Ch] [bp-38h]@33 unsigned __int16 v50; // [sp-Ch] [bp-38h]@120 - int v51; // [sp-Ch] [bp-38h]@174 - unsigned int v52; // [sp-8h] [bp-34h]@18 - char *v53; // [sp-8h] [bp-34h]@33 - int v54; // [sp-8h] [bp-34h]@34 - unsigned int v55; // [sp-8h] [bp-34h]@60 - int v56; // [sp-8h] [bp-34h]@66 - const char *v57; // [sp-8h] [bp-34h]@69 - const char *v58; // [sp-8h] [bp-34h]@89 - int v59; // [sp-8h] [bp-34h]@120 - unsigned int v60; // [sp-8h] [bp-34h]@174 - int v61; // [sp-4h] [bp-30h]@18 - char *v62; // [sp-4h] [bp-30h]@33 - char *v63; // [sp-4h] [bp-30h]@34 - int v64; // [sp-4h] [bp-30h]@60 - int v65; // [sp-4h] [bp-30h]@66 const char *v66; // [sp-4h] [bp-30h]@69 signed int v67; // [sp-4h] [bp-30h]@77 const char *v68; // [sp-4h] [bp-30h]@89 - int v69; // [sp-4h] [bp-30h]@110 - unsigned __int8 v70; // [sp-4h] [bp-30h]@120 - int v71; // [sp-4h] [bp-30h]@174 char v72; // [sp+20h] [bp-Ch]@68 signed int v73; // [sp+24h] [bp-8h]@1 - char *v74; // [sp+24h] [bp-8h]@23 - int v75; // [sp+24h] [bp-8h]@73 + char* v74; // [sp+24h] [bp-8h]@23 Player *thisb; // [sp+28h] [bp-4h]@1 unsigned int thisa; // [sp+28h] [bp-4h]@22 @@ -6916,7 +6716,6 @@ v73 = 1; if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3) ) return; - v4 = 0; if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_REAGENT ) { if ( pParty->pPickedItem.uItemID == 160 ) @@ -6940,13 +6739,33 @@ else { v68 = pParty->pPickedItem.GetDisplayName(); - v58 = pGlobalTXT_LocalizationStrings[36];//"%s can not be used that way" - sprintfex(pTmpBuf, v58, v68); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" ShowStatusBarString(pTmpBuf, 2); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } - goto LABEL_173; + pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0); + + if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + if ( v73 ) + { + if ( pParty->bTurnBasedModeOn ) + { + pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; + thisb->SetRecoveryTime(100); + pTurnEngine->_40471C(); + } + else + { + thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); + } + } + pMouse->RemoveHoldingItem(); + return; + } if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_POTION ) @@ -7008,13 +6827,13 @@ v3->PlaySound(SPEECH_36, 0); break; case 231: //Preservation - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 232: //Shield - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[13].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); @@ -7041,37 +6860,37 @@ v3->PlaySound(SPEECH_36, 0); break; case 240: //Might Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[19].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 241: //Intellect Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[17].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 242: //Personality Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[20].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 243://Endurance Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[16].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 244: //Speed Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[21].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 245: //Accuracy Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[15].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); @@ -7104,43 +6923,43 @@ v3->PlaySound(SPEECH_36, 0); break; case 255: //Luck Boost - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[18].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 256: //Fire Resistance - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[5].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); - goto LABEL_173; + break; case 257: //Air Resistance - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[0].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 258: //Water Resistance - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[22].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 259: //Earth Resistance - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[3].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 260: //Mind Resistance - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[9].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); break; case 261: //Body Resistance - v50 = 3 * LOWORD(pParty->pPickedItem.uEnchantmentType); + v50 = 3 * pParty->pPickedItem.uEnchantmentType; v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); v3->pPlayerBuffs[2].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); v3->PlaySound(SPEECH_36, 0); @@ -7212,15 +7031,37 @@ default: v68 = pParty->pPickedItem.GetDisplayName(); - v58 = pGlobalTXT_LocalizationStrings[36]; //"%s can not be used that way" - sprintfex(pTmpBuf, v58, v68); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" ShowStatusBarString(pTmpBuf, 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; - + } + pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0); + if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + { + if ( !v73 ) + { + pMouse->RemoveHoldingItem(); + return; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } - // pParty->pPlayers[player_num-1].SetCondition(Condition_Poison1, 1); - goto LABEL_173; + if ( v73 ) + { + if ( pParty->bTurnBasedModeOn ) + { + pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; + thisb->SetRecoveryTime(100); + pTurnEngine->_40471C(); + } + else + { + thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); + } + } + pMouse->RemoveHoldingItem(); + return; + } @@ -7233,39 +7074,16 @@ if ( !pParty->pPlayers[player_num-1].CanAct() ) { - v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; - v58 = pGlobalTXT_LocalizationStrings[382]; - sprintfex(pTmpBuf, v58, v68); - v23 = pTmpBuf; - - ShowStatusBarString(v23, 2u); - v4 = 0; - v61 = v4; - v52 = v4; - v48 = v4; - v45 = v4; - v43 = -1; - v41 = v4; - v39 = v4; - v37 = (SoundID)27; - pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[382], v68); + ShowStatusBarString(pTmpBuf, 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } if ( bUnderwater == 1 ) { - v23 = pGlobalTXT_LocalizationStrings[652]; //"You can not do that while you are underwater!" - ShowStatusBarString(v23, 2u); - v4 = 0; - v61 = v4; - v52 = v4; - v48 = v4; - v45 = v4; - v43 = -1; - v41 = v4; - v39 = v4; - v37 = (SoundID)27; - pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } dword_50C9AC = 1; @@ -7301,143 +7119,70 @@ if ( v72 ) { v66 = pParty->pPickedItem.GetDisplayName(); - v57 = pGlobalTXT_LocalizationStrings[380];//"You already know the %s spell" -LABEL_72: - sprintf(pTmpBuf, v57, v66); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell" ShowStatusBarString(pTmpBuf, 2u); -LABEL_92: - v61 = v4; - v52 = v4; - v48 = v4; - v45 = v4; - v43 = -1; - v41 = v4; - v39 = v4; - v37 = (SoundID)27; -LABEL_93: - v14 = pAudioPlayer; -LABEL_63: - pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } if ( !pParty->pPlayers[player_num-1].CanAct() ) { v66 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; - v57 = pGlobalTXT_LocalizationStrings[382];//"That player is %s" - sprintf(pTmpBuf, v57, v66); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s" ShowStatusBarString(pTmpBuf, 2u); - v61 = v4; - v52 = v4; - v48 = v4; - v45 = v4; - v43 = -1; - v41 = v4; - v39 = v4; - v37 = (SoundID)27; - v14 = pAudioPlayer; - pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } v16 = v15 % 11 + 1; v17 = v3->pActiveSkills[v15 / 11 + 12]; - v75 = v16; v18 = SkillToMastery(v17) - 1; - if ( v18 ) + switch (v18) + { + case 0: v67 = 4; break; + case 1: v67 = 7; break; + case 2: v67 = 10; break; + case 3: v67 = 11; break; + default: + v67 = player_num; + } + + if ( v16 > v67 || !v17 ) { - v19 = v18 - 1; - if ( v19 ) + v22 = pParty->pPickedItem.GetDisplayName(); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s" + ShowStatusBarString(pTmpBuf, 2u); + v3->PlaySound((PlayerSpeech)20, 0); + return; + } + // v72 = 1; + v3->PlaySound(SPEECH_21, 0); + v73 = 0; + + + if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + { + if ( !v73 ) { - v20 = v19 - 1; - if ( v20 ) - { - if ( v20 != 1 ) - { - v21 = player_num; -LABEL_83: - if ( v75 > v21 || !v17 ) - { - v22 = pParty->pPickedItem.GetDisplayName(); - sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[381], v22); - ShowStatusBarString(pTmpBuf, 2u); - v3->PlaySound((PlayerSpeech)20, 0); - return; - } - v72 = 1; - v3->PlaySound(SPEECH_21, 0); - v73 = 0; -LABEL_173: - v36 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; - if ( v36 == EQUIP_POTION ) - { - v71 = 0; - v60 = 0; - v51 = 0; - v47 = 0; - v44 = -1; - v42 = 0; - v40 = 0; - v38 = (SoundID)210; - } - else - { - if ( v36 != EQUIP_REAGENT ) - { -LABEL_178: - if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) - { - if ( !v73 ) - { - pMouse->RemoveHoldingItem(); - return; - } - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - } - if ( v73 ) - { - if ( pParty->bTurnBasedModeOn ) - { - *(&pParty->field_16140 + player_num) = 100; - thisb->SetRecoveryTime(100); - pTurnEngine->_40471C(); - } - else - { - thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); - } - } - pMouse->RemoveHoldingItem(); - return; - } - v71 = 0; - v60 = 0; - v51 = 0; - v47 = 0; - v44 = -1; - v42 = 0; - v40 = 0; - v38 = (SoundID)211; - } - pAudioPlayer->PlaySound(v38, v40, v42, v44, v47, v51, v60, v71); - goto LABEL_178; - } - v67 = 11; - } - else - { - v67 = 10; - } + pMouse->RemoveHoldingItem(); + return; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + if ( v73 ) + { + if ( pParty->bTurnBasedModeOn ) + { + pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; + thisb->SetRecoveryTime(100); + pTurnEngine->_40471C(); } else { - v67 = 7; + thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); } } - else - { - v67 = 4; - } - v21 = v67; - goto LABEL_83; + pMouse->RemoveHoldingItem(); + return; + } if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_MESSAGE_SCROLL ) @@ -7446,30 +7191,13 @@ if ( pParty->pPlayers[player_num-1].CanAct() ) { CreateMsgScrollWindow(pParty->pPickedItem.uItemID); - v65 = 0; - v56 = SPEECH_37; -LABEL_67: - v3->PlaySound((PlayerSpeech)v56, v65); + v3->PlaySound(SPEECH_37, 0); return; } -LABEL_89: v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; - v58 = pGlobalTXT_LocalizationStrings[382]; -LABEL_90: - sprintfex(pTmpBuf, v58, v68); - v23 = pTmpBuf; -LABEL_91: - ShowStatusBarString(v23, 2u); - v4 = 0; - v61 = v4; - v52 = v4; - v48 = v4; - v45 = v4; - v43 = -1; - v41 = v4; - v39 = v4; - v37 = (SoundID)27; - pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[382], v68); + ShowStatusBarString(pTmpBuf, 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } else @@ -7478,90 +7206,54 @@ { thisa = pParty->uCurrentMonthWeek + 1; if ( pParty->uCurrentMonth >= 7 ) - v74 = 0; + v74 = NULL; else v74 = aAttributeNames[pParty->uCurrentMonth]; switch ( pParty->uCurrentMonth ) { case 0: - v6 = pParty->uCurrentMonthWeek + 1; v3->uMight += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; //"Permanent" - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 1: - v6 = pParty->uCurrentMonthWeek + 1; v3->uIntelligence += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 2: - v6 = pParty->uCurrentMonthWeek + 1; v3->uWillpower += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 3: - v6 = pParty->uCurrentMonthWeek + 1; v3->uEndurance += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 4: - v6 = pParty->uCurrentMonthWeek + 1; v3->uAccuracy += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 5: - v6 = pParty->uCurrentMonthWeek + 1; v3->uSpeed += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 6: - v6 = pParty->uCurrentMonthWeek + 1; v3->uLuck += thisa; - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v74; - v49 = v6; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" break; case 7: party_finds_gold(1000 * thisa, 0); - v63 = pGlobalTXT_LocalizationStrings[97];//"Gold" - v54 = 1000 * thisa; - sprintf(pTmpBuf, "+%u %s", v54, v63); + sprintf(pTmpBuf, "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold" break; case 8: Party::GiveFood(5 * thisa); - v63 = pGlobalTXT_LocalizationStrings[653]; //"Food" - v54 = 5 * thisa; - sprintf(pTmpBuf, "+%u %s", v54, v63); + sprintf(pTmpBuf, "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food" break; case 9u: - v63 = pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]; v3->uSkillPoints += 2 * thisa; - v54 = 2 * thisa; - sprintf(pTmpBuf, "+%u %s", v54, v63); + sprintf(pTmpBuf, "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]); break; case 10: - v63 = pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]; - v54 = 2500 * thisa; v3->uExperience += 2500 * thisa; - sprintf(pTmpBuf, "+%u %s", v54, v63); + sprintf(pTmpBuf, "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]); break; case 11: v8 = rand() % 6; @@ -7592,10 +7284,7 @@ v13 = pGlobalTXT_LocalizationStrings[29]; break; } - v62 = pGlobalTXT_LocalizationStrings[121]; - v53 = v13; - v49 = thisa; - sprintf(pTmpBuf, "+%u %s %s", v49, v53, v62); + sprintf(pTmpBuf, "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]); break; } @@ -7603,7 +7292,7 @@ pMouse->RemoveHoldingItem(); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, player_num - 1); v3->PlaySound(SPEECH_93, 0); - pAudioPlayer->PlaySound((SoundID)(SOUND_Bell|0x2), 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 ) { v3->SetCondition(Condition_Eradicated, 0); @@ -7642,11 +7331,10 @@ pAudioPlayer->PlaySound((SoundID)135, 0, 0, -1, 0, 0, 0, 0); return; } - else if ( pParty->pPickedItem.uItemID == 646 ) + else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe { pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, player_num - 1); - v5 = 8 * player_num + 392; - LOBYTE(v5) = PID(OBJECT_Player,player_num - 120); + v5 = PID(OBJECT_Player,player_num + 49); pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0); v3->AddVariable(VAR_NumSkillPoints, 2); } @@ -7659,24 +7347,12 @@ { v68 = pParty->pPickedItem.GetDisplayName(); - v58 = pGlobalTXT_LocalizationStrings[36]; - sprintfex(pTmpBuf, v58, v68); - v23 = pTmpBuf; - ShowStatusBarString(v23, 2u); - v4 = 0; - v61 = v4; - v52 = v4; - v48 = v4; - v45 = v4; - v43 = -1; - v41 = v4; - v39 = v4; - v37 = (SoundID)27; - pAudioPlayer->PlaySound(v37, v39, v41, v43, v45, v48, v52, v61); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way" + ShowStatusBarString(pTmpBuf, 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; } - -LABEL_187: + pMouse->RemoveHoldingItem(); return; } @@ -7685,7 +7361,7 @@ //----- (00449BB4) -------------------------------------------------------- bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) - { +{ Player *v3; // esi@1 signed int v4; // edi@1 unsigned int v5; // eax@8 @@ -7820,8 +7496,8 @@ case VAR_NPCs2: return pNPCStats->pNewNPCData[pValue].Hired(); case VAR_MonthEquals|VAR_CurrentSP: - test_bit_value = 0x80u >> ((signed __int16)a1 - 1) % 8; - our_bit_value = this->field_1A50[((signed __int16)a1 - 1)/8]; + test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; + our_bit_value = this->field_1A50[((signed __int16)pValue - 1)/8]; if ( !((unsigned __int8)test_bit_value & our_bit_value) ) return v4 >= pValue; v4 = pValue; @@ -7882,8 +7558,8 @@ } if ( VarNum == VAR_AutoNotes ) { - test_bit_value = 0x80u >> ((signed __int16)(a1 - 1) - 1) % 8; - our_bit_value = pParty->_autonote_bits[((signed __int16)(a1 - 1) - 1) /8]; + test_bit_value = 0x80u >> ((signed __int16)(pValue - 1) - 1) % 8; + our_bit_value = pParty->_autonote_bits[((signed __int16)(pValue - 1) - 1) /8]; if ( !((unsigned __int8)test_bit_value & our_bit_value) ) return false; return true; @@ -7952,8 +7628,8 @@ v12 = GetActualAge(); goto _j_cmp_against_arg; case VAR_Award: - test_bit_value = 0x80u >> ((signed __int16)a1 - 1) % 8; - our_bit_value = this->_guilds_member_bits[((signed __int16)a1 - 1) /8]; + test_bit_value = 0x80u >> ((signed __int16)pValue - 1) % 8; + our_bit_value = this->_guilds_member_bits[((signed __int16)pValue - 1) /8]; if ( !((unsigned __int8)test_bit_value & our_bit_value) ) return true; return false; @@ -8253,8 +7929,8 @@ case VAR_NPCs2: pParty->field_709 = 0; LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; - Party__CountHirelings(); - viewparams->bRedrawGameUI = 1; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; break; case VAR_NumSkillPoints: this->uSkillPoints = var_value; @@ -9209,8 +8885,8 @@ case VAR_NPCs2: pParty->field_709 = 0; LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u; - Party__CountHirelings(); - viewparams->bRedrawGameUI = 1; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; break; case VAR_NumSkillPoints: Dst->uSkillPoints += val; @@ -9325,8 +9001,8 @@ { pParty->field_709 = 0; LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; - Party__CountHirelings(); - viewparams->bRedrawGameUI = 1; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; } break; case 241: @@ -9352,7 +9028,7 @@ if ( pParty->pHirelings[1].uProfession == pValue ) memset(&pParty->pHirelings[1], 0, 0x4Cu); pParty->field_709 = 0; - Party__CountHirelings(); + pParty->CountHirelings(); break; case 243: v17 = (char *)&this->uSkillPoints; @@ -9454,7 +9130,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);