Mercurial > mm7
comparison Player.cpp @ 1714:bafc79e65a4d
Item getter functions to reduce the number of ugly array accesses, fixing a bug with Player::setrecoverytime
author | Grumpy7 |
---|---|
date | Wed, 25 Sep 2013 07:11:16 +0200 |
parents | 0f6cd60ca987 |
children | baa4eda7f924 |
comparison
equal
deleted
inserted
replaced
1710:0f6cd60ca987 | 1714:bafc79e65a4d |
---|---|
1606 } | 1606 } |
1607 else | 1607 else |
1608 { | 1608 { |
1609 if ( HasItemEquipped(EQUIP_MAIN_HAND) ) | 1609 if ( HasItemEquipped(EQUIP_MAIN_HAND) ) |
1610 { | 1610 { |
1611 ItemGen *mainHandItemGen = &this->pInventoryItemList[this->pEquipment.uMainHand-1]; | 1611 ItemGen *mainHandItemGen = this->GetMainHandItem(); |
1612 int itemId = mainHandItemGen->uItemID; | 1612 int itemId = mainHandItemGen->uItemID; |
1613 bool addOneDice = false; | 1613 bool addOneDice = false; |
1614 if ( pItemsTable->pItems[itemId].uSkillType == PLAYER_SKILL_SPEAR && !this->pEquipment.uShield ) | 1614 if ( pItemsTable->pItems[itemId].uSkillType == PLAYER_SKILL_SPEAR && !this->pEquipment.uShield ) |
1615 addOneDice = true; | 1615 addOneDice = true; |
1616 mainWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(mainHandItemGen, uTargetActorID, addOneDice); | 1616 mainWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(mainHandItemGen, uTargetActorID, addOneDice); |
1693 int v4; // eax@4 | 1693 int v4; // eax@4 |
1694 int v5; // edi@4 | 1694 int v5; // edi@4 |
1695 int v6; // edi@4 | 1695 int v6; // edi@4 |
1696 int v7; // edi@4 | 1696 int v7; // edi@4 |
1697 | 1697 |
1698 v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1]; | 1698 ItemGen* mainHandItem = GetMainHandItem(); |
1699 if ( v2 < ITEM_BLASTER || v2 > ITEM_LASER_RIFLE ) | 1699 if ( mainHandItem != nullptr && ( mainHandItem->uItemID < ITEM_BLASTER || mainHandItem->uItemID > ITEM_LASER_RIFLE )) |
1700 { | 1700 { |
1701 v4 = GetActualAccuracy(); | 1701 v4 = GetActualAccuracy(); |
1702 v5 = GetParameterBonus(v4); | 1702 v5 = GetParameterBonus(v4); |
1703 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v5; | 1703 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v5; |
1704 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; | 1704 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; |
1793 } | 1793 } |
1794 | 1794 |
1795 //----- (0048D2EA) -------------------------------------------------------- | 1795 //----- (0048D2EA) -------------------------------------------------------- |
1796 char *Player::GetMeleeDamageString() | 1796 char *Player::GetMeleeDamageString() |
1797 { | 1797 { |
1798 signed int itemid; // eax@1 | |
1799 int min_damage; // edi@3 | 1798 int min_damage; // edi@3 |
1800 int max_damage; // eax@3 | 1799 int max_damage; // eax@3 |
1801 | 1800 |
1802 static char player__getmeleedamagestring_static_buff[40]; // idb | 1801 static char player__getmeleedamagestring_static_buff[40]; // idb |
1803 | 1802 |
1804 if (pEquipment.uMainHand >= 0) | 1803 ItemGen* mainHandItem = GetMainHandItem(); |
1805 { | 1804 |
1806 itemid = pOwnItems[this->pEquipment.uMainHand-1].uItemID; | 1805 if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 )) |
1807 } | |
1808 | |
1809 if (pEquipment.uMainHand >= 0 && ( itemid >= 135 ) && ( itemid <= 159 )) | |
1810 { | 1806 { |
1811 strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" | 1807 strcpy(player__getmeleedamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" |
1812 return player__getmeleedamagestring_static_buff; | 1808 return player__getmeleedamagestring_static_buff; |
1813 } | 1809 } |
1814 else if (pEquipment.uMainHand >= 0 && (itemid == ITEM_BLASTER || itemid == ITEM_LASER_RIFLE)) | 1810 else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE)) |
1815 { | 1811 { |
1816 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); | 1812 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); |
1817 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); | 1813 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); |
1818 } | 1814 } |
1819 else | 1815 else |
1833 } | 1829 } |
1834 | 1830 |
1835 //----- (0048D396) -------------------------------------------------------- | 1831 //----- (0048D396) -------------------------------------------------------- |
1836 char *Player::GetRangedDamageString() | 1832 char *Player::GetRangedDamageString() |
1837 { | 1833 { |
1838 signed int itemid; // eax@1 | |
1839 int min_damage; // edi@3 | 1834 int min_damage; // edi@3 |
1840 int max_damage; // eax@3 | 1835 int max_damage; // eax@3 |
1841 | 1836 |
1842 static char player__getrangeddamagestring_static_buff[40]; // idb | 1837 static char player__getrangeddamagestring_static_buff[40]; // idb |
1843 | 1838 |
1844 if (pEquipment.uMainHand >= 0) | 1839 ItemGen* mainHandItem = GetMainHandItem(); |
1845 { | 1840 |
1846 itemid = pOwnItems[this->pEquipment.uMainHand-1].uItemID; | 1841 if (mainHandItem != nullptr && ( mainHandItem->uItemID >= 135 ) && ( mainHandItem->uItemID <= 159 )) |
1847 } | |
1848 | |
1849 if (pEquipment.uMainHand >= 0 && ( itemid >= 135 ) && ( itemid <= 159 )) | |
1850 { | 1842 { |
1851 strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" | 1843 strcpy(player__getrangeddamagestring_static_buff, pGlobalTXT_LocalizationStrings[595]); //"Wand" |
1852 return player__getrangeddamagestring_static_buff; | 1844 return player__getrangeddamagestring_static_buff; |
1853 } | 1845 } |
1854 else if (pEquipment.uMainHand >= 0 && (itemid == ITEM_BLASTER || itemid == ITEM_LASER_RIFLE)) | 1846 else if (mainHandItem != nullptr && (mainHandItem->uItemID == ITEM_BLASTER || mainHandItem->uItemID == ITEM_LASER_RIFLE)) |
1855 { | 1847 { |
1856 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); | 1848 min_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, true); |
1857 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); | 1849 max_damage = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, true); |
1858 } | 1850 } |
1859 else | 1851 else |
1931 dmg >>= 1; | 1923 dmg >>= 1; |
1932 else | 1924 else |
1933 break; | 1925 break; |
1934 } | 1926 } |
1935 } | 1927 } |
1936 if (( dmg_type == DMGT_PHISYCAL ) && ( pEquipment.uArmor )) | 1928 ItemGen* equippedArmor = GetArmorItem(); |
1937 { | 1929 if (( dmg_type == DMGT_PHISYCAL ) && ( equippedArmor != nullptr )) |
1938 if (!pOwnItems[pEquipment.uArmor - 1].IsBroken()) | 1930 { |
1939 { | 1931 if (!equippedArmor->IsBroken()) |
1940 armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR); | 1932 { |
1933 armor_skill = equippedArmor->GetPlayerSkillType(); | |
1941 if ( armor_skill==PLAYER_SKILL_PLATE ) | 1934 if ( armor_skill==PLAYER_SKILL_PLATE ) |
1942 { | 1935 { |
1943 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) | 1936 if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) |
1944 return dmg / 2; | 1937 return dmg / 2; |
1945 } | 1938 } |
1954 } | 1947 } |
1955 | 1948 |
1956 //----- (0048D62C) -------------------------------------------------------- | 1949 //----- (0048D62C) -------------------------------------------------------- |
1957 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) | 1950 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) |
1958 { | 1951 { |
1959 return pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].GetItemEquipType(); | 1952 return GetNthEquippedIndexItem(uEquipSlot)->GetItemEquipType(); |
1960 } | 1953 } |
1961 | 1954 |
1962 //----- (0048D651) -------------------------------------------------------- | 1955 //----- (0048D651) -------------------------------------------------------- |
1963 PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) | 1956 PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) |
1964 { | 1957 { |
1965 return (PLAYER_SKILL_TYPE)pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].GetPlayerSkillType(); | 1958 return (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(uEquipSlot)->GetPlayerSkillType(); |
1966 } | 1959 } |
1967 | 1960 |
1968 //----- (0048D676) -------------------------------------------------------- | 1961 //----- (0048D676) -------------------------------------------------------- |
1969 bool Player::IsUnarmed() | 1962 bool Player::IsUnarmed() |
1970 { | 1963 { |
1971 return !HasItemEquipped(EQUIP_MAIN_HAND) && | 1964 return !HasItemEquipped(EQUIP_MAIN_HAND) && |
1972 (!HasItemEquipped(EQUIP_OFF_HAND) || GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD); | 1965 (!HasItemEquipped(EQUIP_OFF_HAND) || GetOffHandItem()->GetItemEquipType() == EQUIP_SHIELD); |
1973 } | 1966 } |
1974 | 1967 |
1975 //----- (0048D6AA) -------------------------------------------------------- | 1968 //----- (0048D6AA) -------------------------------------------------------- |
1976 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) | 1969 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) |
1977 { | 1970 { |
1986 bool Player::HasEnchantedItemEquipped(int uEnchantment) | 1979 bool Player::HasEnchantedItemEquipped(int uEnchantment) |
1987 { | 1980 { |
1988 for (uint i = 0; i < 16; ++i) | 1981 for (uint i = 0; i < 16; ++i) |
1989 { | 1982 { |
1990 if (HasItemEquipped((ITEM_EQUIP_TYPE)i) && | 1983 if (HasItemEquipped((ITEM_EQUIP_TYPE)i) && |
1991 pOwnItems[pEquipment.pIndices[i]-1].uSpecEnchantmentType == uEnchantment) | 1984 GetNthEquippedIndexItem(i)->uSpecEnchantmentType == uEnchantment) |
1992 return true; | 1985 return true; |
1993 } | 1986 } |
1994 return false; | 1987 return false; |
1995 } | 1988 } |
1996 | 1989 |
1997 //----- (0048D709) -------------------------------------------------------- | 1990 //----- (0048D709) -------------------------------------------------------- |
1998 bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type ) | 1991 bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type ) |
1999 { | 1992 { |
2000 return ( HasItemEquipped(equip_type) && pInventoryItemList[pEquipment.pIndices[equip_type - 1]].uItemID == item_id ); | 1993 return ( HasItemEquipped(equip_type) && GetNthEquippedIndexItem(equip_type)->uItemID == item_id ); |
2001 } | 1994 } |
2002 | 1995 |
2003 bool Player::WearsItemAnyWhere(int item_id) | 1996 bool Player::WearsItemAnyWhere(int item_id) |
2004 { | 1997 { |
2005 for (int i = 0; i < 16; i++) | 1998 for (int i = 0; i < 16; i++) |
2228 | 2221 |
2229 //----- (0048DC1E) -------------------------------------------------------- | 2222 //----- (0048DC1E) -------------------------------------------------------- |
2230 int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type ) | 2223 int Player::ReceiveDamage( signed int amount, DAMAGE_TYPE dmg_type ) |
2231 { | 2224 { |
2232 signed int recieved_dmg; // eax@1 | 2225 signed int recieved_dmg; // eax@1 |
2233 unsigned int armor_indx; // eax@8 | |
2234 bool broke_armor; | 2226 bool broke_armor; |
2235 | 2227 |
2236 SetAsleep(false); | 2228 SetAsleep(false); |
2237 recieved_dmg = CalculateIncommingDamage(dmg_type, amount); | 2229 recieved_dmg = CalculateIncommingDamage(dmg_type, amount); |
2238 sHealth -= recieved_dmg; | 2230 sHealth -= recieved_dmg; |
2250 if ( sHealth > 0 ) | 2242 if ( sHealth > 0 ) |
2251 sHealth = 0; | 2243 sHealth = 0; |
2252 } | 2244 } |
2253 if (broke_armor ) | 2245 if (broke_armor ) |
2254 { | 2246 { |
2255 armor_indx = pEquipment.uArmor; | 2247 ItemGen* equippedArmor = GetArmorItem(); |
2256 if ( armor_indx ) | 2248 if ( equippedArmor != nullptr ) |
2257 { | 2249 { |
2258 if ( !(pOwnItems[armor_indx-1].uAttributes & ITEM_HARDENED)) | 2250 if ( !(equippedArmor->uAttributes & ITEM_HARDENED)) |
2259 { | 2251 { |
2260 pOwnItems[armor_indx-1].SetBroken(); | 2252 equippedArmor->SetBroken(); |
2261 } | 2253 } |
2262 } | 2254 } |
2263 } | 2255 } |
2264 } | 2256 } |
2265 if ( recieved_dmg && CanAct() ) | 2257 if ( recieved_dmg && CanAct() ) |
2576 uint weapon_recovery = base_recovery_times_per_weapon_type[0]; | 2568 uint weapon_recovery = base_recovery_times_per_weapon_type[0]; |
2577 if (bRangedAttack) | 2569 if (bRangedAttack) |
2578 { | 2570 { |
2579 if ( HasItemEquipped(EQUIP_BOW) ) | 2571 if ( HasItemEquipped(EQUIP_BOW) ) |
2580 { | 2572 { |
2581 weapon = &pInventoryItemList[pEquipment.uBow - 1]; | 2573 weapon = GetBowItem(); |
2582 weapon_desc = &pItemsTable->pItems[weapon->uItemID]; | 2574 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; |
2583 weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType]; | |
2584 } | 2575 } |
2585 } | 2576 } |
2586 else if ( IsUnarmed() == 1 && GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) | 2577 else if ( IsUnarmed() == 1 && GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) |
2587 { | 2578 { |
2588 weapon_recovery = base_recovery_times_per_weapon_type[1]; | 2579 weapon_recovery = base_recovery_times_per_weapon_type[1]; |
2589 } | 2580 } |
2590 else if ( HasItemEquipped(EQUIP_MAIN_HAND) ) | 2581 else if ( HasItemEquipped(EQUIP_MAIN_HAND) ) |
2591 { | 2582 { |
2592 weapon = &pInventoryItemList[pEquipment.uMainHand - 1]; | 2583 weapon = GetMainHandItem(); |
2593 weapon_desc = &pItemsTable->pItems[weapon->uItemID]; | 2584 if (weapon->GetItemEquipType() == EQUIP_WAND) |
2594 if (weapon_desc->uEquipType == EQUIP_WAND) | |
2595 { | 2585 { |
2596 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 | 2586 __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 |
2597 __debugbreak(); // looks like wands were two-handed weapons once, or supposed to be. should not get here now | 2587 __debugbreak(); // looks like wands were two-handed weapons once, or supposed to be. should not get here now |
2598 weapon_recovery = pSpellDatas[wand_spell_ids[weapon->uItemID - ITEM_WAND_FIRE]].uExpertLevelRecovery; | 2588 weapon_recovery = pSpellDatas[wand_spell_ids[weapon->uItemID - ITEM_WAND_FIRE]].uExpertLevelRecovery; |
2599 } | 2589 } |
2600 else | 2590 else |
2601 weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType]; | 2591 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; |
2602 } | 2592 } |
2603 if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) | 2593 if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) |
2604 // ADD: shield check because shield recovery is added later and can be accidentally doubled | 2594 // ADD: shield check because shield recovery is added later and can be accidentally doubled |
2605 { | 2595 { |
2606 auto v12 = &pInventoryItemList[pEquipment.uShield - 1]; | 2596 weapon = GetOffHandItem(); |
2607 auto v12_desc = &pItemsTable->pItems[v12->uItemID]; | 2597 if (base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()] > weapon_recovery) |
2608 if (base_recovery_times_per_weapon_type[v12_desc->uSkillType] > weapon_recovery) | 2598 { |
2609 { | |
2610 weapon = &pInventoryItemList[pEquipment.uShield - 1]; | |
2611 weapon_desc = &pItemsTable->pItems[weapon->uItemID]; | |
2612 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; | 2599 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; |
2613 } | 2600 } |
2614 } | 2601 } |
2615 | 2602 |
2616 uint armour_recovery = 0; | 2603 uint armour_recovery = 0; |
2617 if ( HasItemEquipped(EQUIP_ARMOUR) ) | 2604 if ( HasItemEquipped(EQUIP_ARMOUR) ) |
2618 { | 2605 { |
2619 auto armour_skill_type = pInventoryItemList[pEquipment.uArmor - 1].GetPlayerSkillType(); | 2606 auto armour_skill_type = GetArmorItem()->GetPlayerSkillType(); |
2620 uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; | 2607 uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; |
2621 float multiplier; | 2608 float multiplier; |
2622 | 2609 |
2623 if (armour_skill_type == PLAYER_SKILL_LEATHER) | 2610 if (armour_skill_type == PLAYER_SKILL_LEATHER) |
2624 { | 2611 { |
2642 } | 2629 } |
2643 | 2630 |
2644 uint shield_recovery = 0; | 2631 uint shield_recovery = 0; |
2645 if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD) | 2632 if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD) |
2646 { | 2633 { |
2647 auto shield = &pInventoryItemList[pEquipment.uShield - 1]; | 2634 auto skill_type = GetOffHandItem()->GetPlayerSkillType(); |
2648 auto skill_type = shield->GetPlayerSkillType(); | |
2649 | 2635 |
2650 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; | 2636 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; |
2651 float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); | 2637 float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); |
2652 shield_recovery = (uint)(shield_base_recovery * multiplier); | 2638 shield_recovery = (uint)(shield_base_recovery * multiplier); |
2653 } | 2639 } |
2654 | 2640 |
2655 uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()), | 2641 uint player_speed_recovery_reduction = GetParameterBonus(GetActualSpeed()), |
2656 sword_axe_bow_recovery_reduction = 0; | 2642 sword_axe_bow_recovery_reduction = 0; |
2657 bool shooting_laser = false; | 2643 bool shooting_laser = false; |
2658 if (weapon_desc) | 2644 if (weapon != nullptr) |
2659 { | 2645 { |
2660 if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon_desc->uSkillType) && | 2646 if (GetActualSkillLevel((PLAYER_SKILL_TYPE)weapon->GetPlayerSkillType()) && |
2661 (weapon_desc->uSkillType == PLAYER_SKILL_SWORD || weapon_desc->uSkillType == PLAYER_SKILL_AXE || weapon_desc->uSkillType == PLAYER_SKILL_BOW) ) | 2647 (weapon->GetPlayerSkillType() == PLAYER_SKILL_SWORD || weapon->GetPlayerSkillType() == PLAYER_SKILL_AXE || weapon->GetPlayerSkillType() == PLAYER_SKILL_BOW) ) |
2662 { | 2648 { |
2663 if (SkillToMastery(pActiveSkills[weapon_desc->uSkillType]) >= 2 ) // Expert Sword, Axe & Bow reduce recovery | 2649 if (SkillToMastery(pActiveSkills[weapon->GetPlayerSkillType()]) >= 2 ) // Expert Sword, Axe & Bow reduce recovery |
2664 sword_axe_bow_recovery_reduction = pActiveSkills[weapon_desc->uSkillType] & 0x3F; | 2650 sword_axe_bow_recovery_reduction = pActiveSkills[weapon_desc->uSkillType] & 0x3F; |
2665 } | 2651 } |
2666 if (weapon_desc->uSkillType == PLAYER_SKILL_BLASTER) | 2652 if (weapon_desc->uSkillType == PLAYER_SKILL_BLASTER) |
2667 shooting_laser = true; | 2653 shooting_laser = true; |
2668 } | 2654 } |
2969 Assert(rec >= 0); | 2955 Assert(rec >= 0); |
2970 | 2956 |
2971 if (rec > uTimeToRecovery) | 2957 if (rec > uTimeToRecovery) |
2972 uTimeToRecovery = rec; | 2958 uTimeToRecovery = rec; |
2973 | 2959 |
2974 if (pPlayers[uActiveCharacter] == this && !some_active_character) | 2960 if (uActiveCharacter != 0 && pPlayers[uActiveCharacter] == this && !some_active_character) |
2975 uActiveCharacter = pParty->GetNextActiveCharacter(); | 2961 uActiveCharacter = pParty->GetNextActiveCharacter(); |
2976 | 2962 |
2977 viewparams->bRedrawGameUI = true; | 2963 viewparams->bRedrawGameUI = true; |
2978 } | 2964 } |
2979 // 50C0C4: using guessed type int some_active_character; | 2965 // 50C0C4: using guessed type int some_active_character; |
3010 } | 2996 } |
3011 | 2997 |
3012 //----- (0048EA46) -------------------------------------------------------- | 2998 //----- (0048EA46) -------------------------------------------------------- |
3013 int Player::GetSpecialItemBonus( int enchantmentId ) | 2999 int Player::GetSpecialItemBonus( int enchantmentId ) |
3014 { | 3000 { |
3015 int inv_indx; // eax@3 | |
3016 | |
3017 for (int i = EQUIP_OFF_HAND; i < EQUIP_BOOK; ++i ) | 3001 for (int i = EQUIP_OFF_HAND; i < EQUIP_BOOK; ++i ) |
3018 { | 3002 { |
3019 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3003 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3020 { | 3004 { |
3021 inv_indx = pEquipment.pIndices[i] - 1; | |
3022 if (enchantmentId == 17) | 3005 if (enchantmentId == 17) |
3023 { | 3006 { |
3024 if ((pInventoryItemList[inv_indx].uSpecEnchantmentType == 17) || (pInventoryItemList[inv_indx].uItemID == 533)) //Elven Chainmail+Increases rate of Recovery | 3007 if ((GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 17) || (GetNthEquippedIndexItem(i)->uItemID == 533)) //Elven Chainmail+Increases rate of Recovery |
3025 return 50; | 3008 return 50; |
3026 } | 3009 } |
3027 if (enchantmentId == 24) | 3010 if (enchantmentId == 24) |
3028 { | 3011 { |
3029 if (pInventoryItemList[inv_indx].uSpecEnchantmentType == 24) //Increased Knockback. | 3012 if (GetNthEquippedIndexItem(i)->uSpecEnchantmentType == 24) //Increased Knockback. |
3030 return 5; | 3013 return 5; |
3031 } | 3014 } |
3032 } | 3015 } |
3033 } | 3016 } |
3034 return 0; | 3017 return 0; |
3040 int v5; // edi@1 | 3023 int v5; // edi@1 |
3041 int v9; // eax@49 | 3024 int v9; // eax@49 |
3042 int v14; // ecx@58 | 3025 int v14; // ecx@58 |
3043 int v15; // eax@58 | 3026 int v15; // eax@58 |
3044 int v17; // eax@62 | 3027 int v17; // eax@62 |
3045 int v20; // eax@69 | |
3046 int v22; // eax@76 | 3028 int v22; // eax@76 |
3047 int v23; // edx@76 | |
3048 int v25; // ecx@80 | 3029 int v25; // ecx@80 |
3049 int v26; // edi@80 | 3030 int v26; // edi@80 |
3050 int v31; // ebp@97 | |
3051 int v32; // eax@98 | 3031 int v32; // eax@98 |
3052 unsigned int v33; // eax@100 | |
3053 int v56; // eax@365 | 3032 int v56; // eax@365 |
3054 int v57; // ebx@368 | |
3055 signed int v58; // [sp-4h] [bp-20h]@10 | 3033 signed int v58; // [sp-4h] [bp-20h]@10 |
3056 int v61; // [sp+10h] [bp-Ch]@1 | 3034 int v61; // [sp+10h] [bp-Ch]@1 |
3057 int v62; // [sp+14h] [bp-8h]@1 | 3035 int v62; // [sp+14h] [bp-8h]@1 |
3058 ItemGen *currEquippedItem; // [sp+20h] [bp+4h]@101 | 3036 ItemGen *currEquippedItem; // [sp+20h] [bp+4h]@101 |
3059 bool no_skills; | 3037 bool no_skills; |
3098 switch(attr) //TODO would be nice to move these into separate functions | 3076 switch(attr) //TODO would be nice to move these into separate functions |
3099 { | 3077 { |
3100 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: | 3078 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: |
3101 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | 3079 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: |
3102 if ( HasItemEquipped(EQUIP_BOW) ) | 3080 if ( HasItemEquipped(EQUIP_BOW) ) |
3103 v5 = this->pOwnItems[this->pEquipment.uBow-1].GetDamageMod(); | 3081 v5 = GetBowItem()->GetDamageMod(); |
3104 return v5; | 3082 return v5; |
3105 break; | 3083 break; |
3106 | 3084 |
3107 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN: | 3085 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN: |
3108 if ( !HasItemEquipped(EQUIP_BOW) ) | 3086 if ( !HasItemEquipped(EQUIP_BOW) ) |
3109 return 0; | 3087 return 0; |
3110 v57 = this->pOwnItems[this->pEquipment.uBow-1].uItemID; | 3088 v5 = GetBowItem()->GetDamageMod(); |
3111 v5 = pItemsTable->pItems[v57].uDamageMod; | 3089 v56 = GetBowItem()->GetDamageDice(); |
3112 v56 = pItemsTable->pItems[v57].uDamageDice; | |
3113 return v5 + v56; | 3090 return v5 + v56; |
3114 break; | 3091 break; |
3115 | 3092 |
3116 case CHARACTER_ATTRIBUTE_RANGED_DMG_MAX: | 3093 case CHARACTER_ATTRIBUTE_RANGED_DMG_MAX: |
3117 if ( !HasItemEquipped(EQUIP_BOW) ) | 3094 if ( !HasItemEquipped(EQUIP_BOW) ) |
3118 return 0; | 3095 return 0; |
3119 v20 = this->pOwnItems[this->pEquipment.uBow-1].uItemID; | 3096 v5 = GetBowItem()->GetDamageDice() * GetBowItem()->GetDamageRoll(); |
3120 v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll; | 3097 v56 = GetBowItem()->GetDamageMod(); |
3121 v56 = pItemsTable->pItems[v20].uDamageMod; | |
3122 return v5 + v56; | 3098 return v5 + v56; |
3123 | 3099 |
3124 case CHARACTER_ATTRIBUTE_LEVEL: | 3100 case CHARACTER_ATTRIBUTE_LEVEL: |
3125 if ( !Player::HasEnchantedItemEquipped(25) ) | 3101 if ( !Player::HasEnchantedItemEquipped(25) ) |
3126 return 0; | 3102 return 0; |
3137 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) | 3113 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) |
3138 { | 3114 { |
3139 v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); | 3115 v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); |
3140 if ( v22 >= 0 && v22 <= 2) | 3116 if ( v22 >= 0 && v22 <= 2) |
3141 { | 3117 { |
3142 v23 = this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID; | 3118 ItemGen* mainHandItem = GetMainHandItem(); |
3143 v26 = pItemsTable->pItems[v23].uDamageRoll; | 3119 v26 = mainHandItem->GetDamageRoll(); |
3144 if ( this->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) | 3120 if ( GetOffHandItem() != nullptr || mainHandItem->GetPlayerSkillType() != 4 ) |
3145 { | 3121 { |
3146 v25 = pItemsTable->pItems[v23].uDamageDice; | 3122 v25 = mainHandItem->GetDamageDice(); |
3147 } | 3123 } |
3148 else | 3124 else |
3149 { | 3125 { |
3150 v25 = pItemsTable->pItems[v23].uDamageDice + 1; | 3126 v25 = mainHandItem->GetDamageDice() + 1; |
3151 } | 3127 } |
3152 v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26; | 3128 v5 = mainHandItem->GetDamageMod() + v25 * v26; |
3153 } | 3129 } |
3154 } | 3130 } |
3155 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0 || GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2)) | 3131 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0 || GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2)) |
3156 { | 3132 { |
3157 return v5; | 3133 return v5; |
3158 } | 3134 } |
3159 else | 3135 else |
3160 { | 3136 { |
3161 v23 = this->pOwnItems[this->pEquipment.uShield - 1].uItemID; | 3137 ItemGen* offHandItem = GetOffHandItem(); |
3162 v15 = pItemsTable->pItems[v23].uDamageMod; | 3138 v15 = offHandItem->GetDamageMod(); |
3163 v14 = pItemsTable->pItems[v23].uDamageDice * pItemsTable->pItems[v23].uDamageRoll; | 3139 v14 = offHandItem->GetDamageDice() * offHandItem->GetDamageRoll(); |
3164 return v5 + v15 + v14; | 3140 return v5 + v15 + v14; |
3165 } | 3141 } |
3166 } | 3142 } |
3167 break; | 3143 break; |
3168 | 3144 |
3175 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) | 3151 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) |
3176 { | 3152 { |
3177 v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); | 3153 v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); |
3178 if ( v17 >= 0 && v17 <= 2) | 3154 if ( v17 >= 0 && v17 <= 2) |
3179 { | 3155 { |
3180 v5 = this->pOwnItems[this->pEquipment.uMainHand-1].GetDamageMod(); | 3156 v5 = GetMainHandItem()->GetDamageMod(); |
3181 } | 3157 } |
3182 } | 3158 } |
3183 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 ) | 3159 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 ) |
3184 return v5; | 3160 return v5; |
3185 else | 3161 else |
3186 { | 3162 { |
3187 v20 = this->pOwnItems[this->pEquipment.uShield - 1].uItemID; | 3163 v56 = GetOffHandItem()->GetDamageMod(); |
3188 v56 = pItemsTable->pItems[v20].uDamageMod; | |
3189 return v5 + v56; | 3164 return v5 + v56; |
3190 } | 3165 } |
3191 break; | 3166 break; |
3192 | 3167 |
3193 case CHARACTER_ATTRIBUTE_MELEE_DMG_MIN: | 3168 case CHARACTER_ATTRIBUTE_MELEE_DMG_MIN: |
3198 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) | 3173 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) |
3199 { | 3174 { |
3200 v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); | 3175 v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); |
3201 if ( v9 >= 0 && v9 <= 2) | 3176 if ( v9 >= 0 && v9 <= 2) |
3202 { | 3177 { |
3203 v5 = this->pOwnItems[this->pEquipment.uMainHand - 1].GetDamageDice() + | 3178 ItemGen* mainHandItem = GetMainHandItem(); |
3204 this->pOwnItems[this->pEquipment.uMainHand - 1].GetDamageMod(); | 3179 v5 = mainHandItem->GetDamageDice() + |
3205 if ( !this->pEquipment.uShield && this->pOwnItems[this->pEquipment.uMainHand - 1].GetPlayerSkillType() == 4) | 3180 mainHandItem->GetDamageMod(); |
3181 if ( GetOffHandItem() == nullptr && mainHandItem->GetPlayerSkillType() == 4) | |
3206 { | 3182 { |
3207 ++v5; | 3183 ++v5; |
3208 } | 3184 } |
3209 } | 3185 } |
3210 } | 3186 } |
3213 { | 3189 { |
3214 return v5; | 3190 return v5; |
3215 } | 3191 } |
3216 else | 3192 else |
3217 { | 3193 { |
3218 v14 = this->pOwnItems[this->pEquipment.uShield].GetDamageMod(); | 3194 ItemGen* offHandItem = GetOffHandItem(); |
3219 v15 = this->pOwnItems[this->pEquipment.uShield].GetDamageDice(); | 3195 v14 = offHandItem->GetDamageMod(); |
3196 v15 = offHandItem->GetDamageDice(); | |
3220 return v5 + v15 + v14; | 3197 return v5 + v15 + v14; |
3221 } | 3198 } |
3222 break; | 3199 break; |
3223 | 3200 |
3224 case CHARACTER_ATTRIBUTE_STRENGTH: | 3201 case CHARACTER_ATTRIBUTE_STRENGTH: |
3264 case CHARACTER_ATTRIBUTE_SKILL_LEARNING: | 3241 case CHARACTER_ATTRIBUTE_SKILL_LEARNING: |
3265 for (int i = 0; i < 16; i++) | 3242 for (int i = 0; i < 16; i++) |
3266 { | 3243 { |
3267 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3244 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3268 { | 3245 { |
3269 v31 = this->pEquipment.pIndices[i] - 1; | 3246 currEquippedItem = GetNthEquippedIndexItem(i); |
3270 currEquippedItem = &this->pInventoryItemList[v31]; | |
3271 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS ) | 3247 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS ) |
3272 { | 3248 { |
3273 v32 = GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i); | 3249 v32 = currEquippedItem->GetItemEquipType(); |
3274 if ( v32 >= 3 && v32 <= 11 ) | 3250 if ( v32 >= 3 && v32 <= 11 ) |
3275 { | 3251 { |
3276 v33 = currEquippedItem->uItemID; | 3252 v5 += currEquippedItem->GetDamageDice() + currEquippedItem->GetDamageMod(); |
3277 v5 += pItemsTable->pItems[v33].uDamageDice + pItemsTable->pItems[v33].uDamageMod; | |
3278 } | 3253 } |
3279 } | 3254 } |
3280 if ( pItemsTable->IsMaterialNonCommon((ItemGen *)(currEquippedItem)) | 3255 if ( pItemsTable->IsMaterialNonCommon(currEquippedItem) |
3281 && !pItemsTable->IsMaterialSpecial(currEquippedItem) ) | 3256 && !pItemsTable->IsMaterialSpecial(currEquippedItem) ) |
3282 { | 3257 { |
3283 currEquippedItem->GetItemBonusArtifact(this, attr, &v62); | 3258 currEquippedItem->GetItemBonusArtifact(this, attr, &v62); |
3284 } | 3259 } |
3285 else if ( currEquippedItem->uEnchantmentType != 0 ) | 3260 else if ( currEquippedItem->uEnchantmentType != 0 ) |
3647 bool wearingLeather = false; | 3622 bool wearingLeather = false; |
3648 unsigned int ACSum = 0; | 3623 unsigned int ACSum = 0; |
3649 | 3624 |
3650 for (int j = 0; j < 16; ++j) | 3625 for (int j = 0; j < 16; ++j) |
3651 { | 3626 { |
3652 if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].IsBroken())) | 3627 ItemGen* currItem = GetNthEquippedIndexItem(j); |
3628 if (currItem != nullptr && (!currItem->IsBroken())) | |
3653 { | 3629 { |
3654 int curr_item = pOwnItems[pEquipment.pIndices[j] - 1].uItemID; | 3630 PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType(); |
3655 PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType; | |
3656 int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); | 3631 int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); |
3657 int multiplier = 0; | 3632 int multiplier = 0; |
3658 switch (itemSkillType) | 3633 switch (itemSkillType) |
3659 { | 3634 { |
3660 case PLAYER_SKILL_STAFF: | 3635 case PLAYER_SKILL_STAFF: |
3708 } | 3683 } |
3709 for (int i = 0; i < 16; ++i) | 3684 for (int i = 0; i < 16; ++i) |
3710 { | 3685 { |
3711 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3686 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3712 { | 3687 { |
3713 ItemDesc currItem = pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID]; | 3688 ItemGen* currItem = GetNthEquippedIndexItem(i); |
3714 if ( currItem.uEquipType <= EQUIP_MAIN_HAND) | 3689 if ( currItem->GetItemEquipType() <= EQUIP_MAIN_HAND) |
3715 { | 3690 { |
3716 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem.uSkillType; | 3691 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItem->GetPlayerSkillType(); |
3717 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | 3692 int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); |
3718 if (currItemSkillType == PLAYER_SKILL_BLASTER) | 3693 if (currItemSkillType == PLAYER_SKILL_BLASTER) |
3719 { | 3694 { |
3720 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5); | 3695 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 2, 3, 5); |
3721 return multiplier * (currentItemSkillLevel & 0x3F); | 3696 return multiplier * (currentItemSkillLevel & 0x3F); |
3739 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | 3714 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: |
3740 for (int i = 0; i < 16; i++) | 3715 for (int i = 0; i < 16; i++) |
3741 { | 3716 { |
3742 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3717 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3743 { | 3718 { |
3744 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].GetPlayerSkillType(); | 3719 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)GetNthEquippedIndexItem(i)->GetPlayerSkillType(); |
3745 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); | 3720 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); |
3746 if ( currentItemSkillType == PLAYER_SKILL_BOW ) | 3721 if ( currentItemSkillType == PLAYER_SKILL_BOW ) |
3747 { | 3722 { |
3748 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1); | 3723 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1); |
3749 return multiplier * (currentItemSkillLevel & 0x3F); | 3724 return multiplier * (currentItemSkillLevel & 0x3F); |
3771 } | 3746 } |
3772 for (int i = 0; i < 16; i++) | 3747 for (int i = 0; i < 16; i++) |
3773 { | 3748 { |
3774 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3749 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3775 { | 3750 { |
3776 ItemGen* currItemPtr = &this->pInventoryItemList[this->pEquipment.pIndices[i] - 1]; | 3751 ItemGen* currItemPtr = GetNthEquippedIndexItem(i); |
3777 if ( currItemPtr->GetItemEquipType() == EQUIP_MAIN_HAND || currItemPtr->GetItemEquipType() == EQUIP_OFF_HAND ) | 3752 if ( currItemPtr->GetItemEquipType() == EQUIP_MAIN_HAND || currItemPtr->GetItemEquipType() == EQUIP_OFF_HAND ) |
3778 { | 3753 { |
3779 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItemPtr->GetPlayerSkillType(); | 3754 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItemPtr->GetPlayerSkillType(); |
3780 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | 3755 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); |
3781 int baseSkillBonus; | 3756 int baseSkillBonus; |
5025 unsigned int v12; // eax@20 | 5000 unsigned int v12; // eax@20 |
5026 unsigned int test_bit_value; // eax@25 | 5001 unsigned int test_bit_value; // eax@25 |
5027 unsigned __int8 our_bit_value; // cl@25 | 5002 unsigned __int8 our_bit_value; // cl@25 |
5028 signed int v15; // ecx@28 | 5003 signed int v15; // ecx@28 |
5029 ItemGen *v16; // eax@28 | 5004 ItemGen *v16; // eax@28 |
5030 char v17; // zf@31 | |
5031 int v18; // edi@90 | 5005 int v18; // edi@90 |
5032 DDM_DLV_Header *v19; // eax@122 | 5006 DDM_DLV_Header *v19; // eax@122 |
5033 char v20; // cl@124 | |
5034 DDM_DLV_Header *v21; // eax@126 | 5007 DDM_DLV_Header *v21; // eax@126 |
5035 unsigned int v22; // edi@129 | 5008 unsigned int v22; // edi@129 |
5036 Player *v23; // esi@134 | 5009 Player *v23; // esi@134 |
5037 ItemGen *v24; // ecx@135 | 5010 ItemGen *v24; // ecx@135 |
5038 signed int v25; // edx@135 | 5011 signed int v25; // edx@135 |
7299 } | 7272 } |
7300 | 7273 |
7301 //----- (0043EE77) -------------------------------------------------------- | 7274 //----- (0043EE77) -------------------------------------------------------- |
7302 bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player | 7275 bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player |
7303 { | 7276 { |
7304 if (this->pEquipment.uArmor == 0 || this->pInventoryItemList[this->pEquipment.uArmor].uItemID != 604) | 7277 if (GetArmorItem() == nullptr || GetArmorItem()->uItemID != 604) |
7305 { | 7278 { |
7306 return false; | 7279 return false; |
7307 } | 7280 } |
7308 return true; | 7281 return true; |
7309 } | 7282 } |
7384 //----- (00439FCB) -------------------------------------------------------- | 7357 //----- (00439FCB) -------------------------------------------------------- |
7385 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4) | 7358 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4) |
7386 { | 7359 { |
7387 Player *playerPtr; // ebx@3 | 7360 Player *playerPtr; // ebx@3 |
7388 Actor *actorPtr; // esi@3 | 7361 Actor *actorPtr; // esi@3 |
7389 unsigned int v8; // eax@4 | |
7390 int spellId; // eax@38 | 7362 int spellId; // eax@38 |
7391 signed int recvdMagicDmg; // eax@139 | 7363 signed int recvdMagicDmg; // eax@139 |
7392 int v72[4]; // [sp+30h] [bp-24h]@164 | 7364 int v72[4]; // [sp+30h] [bp-24h]@164 |
7393 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 | 7365 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 |
7394 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 | 7366 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 |
7399 playerPtr = &pParty->pPlayers[a4]; | 7371 playerPtr = &pParty->pPlayers[a4]; |
7400 actorPtr = &pActors[uActorID]; | 7372 actorPtr = &pActors[uActorID]; |
7401 healthBeforeRecvdDamage = playerPtr->sHealth; | 7373 healthBeforeRecvdDamage = playerPtr->sHealth; |
7402 if ( PID_TYPE(uObjID) != 3 || !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) | 7374 if ( PID_TYPE(uObjID) != 3 || !stru_50C198.ActorHitOrMiss(actorPtr, playerPtr) ) |
7403 return; | 7375 return; |
7404 v8 = playerPtr->pEquipment.uArmor; | 7376 ItemGen* equippedArmor = playerPtr->GetArmorItem(); |
7405 SoundID soundToPlay; | 7377 SoundID soundToPlay; |
7406 if ( !v8 | 7378 if ( !equippedArmor |
7407 || playerPtr->pInventoryItemList[v8 - 1].IsBroken() | 7379 || equippedArmor->IsBroken() |
7408 || | 7380 || |
7409 (playerPtr->pInventoryItemList[v8 - 1].GetPlayerSkillType() != PLAYER_SKILL_CHAIN | 7381 (equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_CHAIN |
7410 && playerPtr->pInventoryItemList[v8 - 1].GetPlayerSkillType() != PLAYER_SKILL_PLATE | 7382 && equippedArmor->GetPlayerSkillType() != PLAYER_SKILL_PLATE |
7411 ) | 7383 ) |
7412 ) | 7384 ) |
7413 { | 7385 { |
7414 int randVal = rand() % 4; | 7386 int randVal = rand() % 4; |
7415 switch (randVal) | 7387 switch (randVal) |
7600 if ( playerPtr->HasEnchantedItemEquipped(36) ) | 7572 if ( playerPtr->HasEnchantedItemEquipped(36) ) |
7601 dmgToReceive >>= 1; | 7573 dmgToReceive >>= 1; |
7602 if ( playerPtr->HasEnchantedItemEquipped(69) ) | 7574 if ( playerPtr->HasEnchantedItemEquipped(69) ) |
7603 dmgToReceive >>= 1; | 7575 dmgToReceive >>= 1; |
7604 if ( playerPtr->HasItemEquipped(EQUIP_ARMOUR) | 7576 if ( playerPtr->HasItemEquipped(EQUIP_ARMOUR) |
7605 && playerPtr->pInventoryItemList[playerPtr->pEquipment.uArmor-1].uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR ) | 7577 && playerPtr->GetArmorItem()->uItemID == ITEM_ARTIFACT_GOVERNORS_ARMOR ) |
7606 dmgToReceive >>= 1; | 7578 dmgToReceive >>= 1; |
7607 if ( playerPtr->HasItemEquipped(EQUIP_MAIN_HAND)) | 7579 if ( playerPtr->HasItemEquipped(EQUIP_MAIN_HAND)) |
7608 { | 7580 { |
7609 int itemId = playerPtr->pInventoryItemList[playerPtr->pEquipment.uMainHand - 1].uItemID; | 7581 ItemGen* mainHandItem = playerPtr->GetMainHandItem(); |
7610 if ( itemId == ITEM_RELIC_KELEBRIM || itemId == ITEM_ARTIFACT_ELFBANE || (playerPtr->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) | 7582 if ( mainHandItem->uItemID == ITEM_RELIC_KELEBRIM || mainHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (mainHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) |
7611 dmgToReceive >>= 1; | 7583 dmgToReceive >>= 1; |
7612 } | 7584 } |
7613 if ( playerPtr->HasItemEquipped(EQUIP_OFF_HAND)) | 7585 if ( playerPtr->HasItemEquipped(EQUIP_OFF_HAND)) |
7614 { | 7586 { |
7615 int itemId = playerPtr->pInventoryItemList[playerPtr->pEquipment.uShield - 1].uItemID; | 7587 ItemGen* offHandItem = playerPtr->GetOffHandItem(); |
7616 if ( itemId == ITEM_RELIC_KELEBRIM || itemId == ITEM_ARTIFACT_ELFBANE || (playerPtr->GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) | 7588 if ( offHandItem->uItemID == ITEM_RELIC_KELEBRIM || offHandItem->uItemID == ITEM_ARTIFACT_ELFBANE || (offHandItem->GetItemEquipType() == EQUIP_SHIELD && SkillToMastery(playerPtr->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4)) |
7617 dmgToReceive >>= 1; | 7589 dmgToReceive >>= 1; |
7618 } | 7590 } |
7619 } | 7591 } |
7620 if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) | 7592 if ( actorPtr->pActorBuffs[3].uExpireTime > 0 ) |
7621 { | 7593 { |
7976 | 7948 |
7977 void Player::SetCondUnconsciousWithBlockCheck( int blockable ) | 7949 void Player::SetCondUnconsciousWithBlockCheck( int blockable ) |
7978 { | 7950 { |
7979 SetCondition(Condition_Dead, blockable); | 7951 SetCondition(Condition_Dead, blockable); |
7980 } | 7952 } |
7953 | |
7954 ItemGen* Player::GetOffHandItem() | |
7955 { | |
7956 return GetItem(&PlayerEquipment::uShield); | |
7957 } | |
7958 | |
7959 ItemGen* Player::GetMainHandItem() | |
7960 { | |
7961 return GetItem(&PlayerEquipment::uMainHand); | |
7962 } | |
7963 | |
7964 ItemGen* Player::GetBowItem() | |
7965 { | |
7966 return GetItem(&PlayerEquipment::uBow); | |
7967 } | |
7968 | |
7969 ItemGen* Player::GetArmorItem() | |
7970 { | |
7971 return GetItem(&PlayerEquipment::uArmor); | |
7972 } | |
7973 | |
7974 ItemGen* Player::GetHelmItem() | |
7975 { | |
7976 return GetItem(&PlayerEquipment::uHelm); | |
7977 } | |
7978 | |
7979 ItemGen* Player::GetBeltItem() | |
7980 { | |
7981 return GetItem(&PlayerEquipment::uBelt); | |
7982 } | |
7983 | |
7984 ItemGen* Player::GetCloakItem() | |
7985 { | |
7986 return GetItem(&PlayerEquipment::uCloak); | |
7987 } | |
7988 | |
7989 ItemGen* Player::GetGloveItem() | |
7990 { | |
7991 return GetItem(&PlayerEquipment::uGlove); | |
7992 } | |
7993 | |
7994 ItemGen* Player::GetBootItem() | |
7995 { | |
7996 return GetItem(&PlayerEquipment::uBoot); | |
7997 } | |
7998 | |
7999 ItemGen* Player::GetAmuletItem() | |
8000 { | |
8001 return GetItem(&PlayerEquipment::uAmulet); | |
8002 } | |
8003 | |
8004 ItemGen* Player::GetNthRingItem(int ringNum) | |
8005 { | |
8006 return GetNthEquippedIndexItem(ringNum + 10); | |
8007 } | |
8008 | |
8009 ItemGen* Player::GetNthEquippedIndexItem(int index) | |
8010 { | |
8011 if (this->pEquipment.pIndices[index] == 0) | |
8012 { | |
8013 return nullptr; | |
8014 } | |
8015 return &this->pInventoryItemList[this->pEquipment.pIndices[index] - 1]; | |
8016 } | |
8017 | |
8018 ItemGen* Player::GetItem(unsigned int PlayerEquipment::* itemPos) | |
8019 { | |
8020 if (this->pEquipment.*itemPos == 0) | |
8021 { | |
8022 return nullptr; | |
8023 } | |
8024 return &this->pInventoryItemList[this->pEquipment.*itemPos - 1]; | |
8025 } |