Mercurial > mm7
comparison Player.cpp @ 1709:8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
author | Grumpy7 |
---|---|
date | Tue, 24 Sep 2013 07:29:55 +0200 |
parents | f8414042db1f |
children | 0f6cd60ca987 |
comparison
equal
deleted
inserted
replaced
1708:f8414042db1f | 1709:8251e59fd7c1 |
---|---|
505 { | 505 { |
506 if ( enchant_count ) | 506 if ( enchant_count ) |
507 { | 507 { |
508 for ( i = 0; i < enchant_count; ++i ) | 508 for ( i = 0; i < enchant_count; ++i ) |
509 { | 509 { |
510 if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED)) | 510 if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_HARDENED)) |
511 pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_ENCHANTED; | 511 pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_HARDENED; |
512 } | 512 } |
513 } | 513 } |
514 else | 514 else |
515 { | 515 { |
516 for ( i = 0; i < avalible_items; ++i ) | 516 for ( i = 0; i < avalible_items; ++i ) |
517 { | 517 { |
518 pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED; | 518 pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_HARDENED; |
519 } | 519 } |
520 } | 520 } |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
1006 unsigned int slot_height; // ebp@1 | 1006 unsigned int slot_height; // ebp@1 |
1007 int *pInvPos; // edx@4 | 1007 int *pInvPos; // edx@4 |
1008 unsigned int slot_width; // [sp+14h] [bp+4h]@1 | 1008 unsigned int slot_width; // [sp+14h] [bp+4h]@1 |
1009 | 1009 |
1010 item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1]; | 1010 item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1]; |
1011 item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item_in_slot->uItemID].pIconName, TEXTURE_16BIT_PALETTE); | 1011 item_texture = pIcons_LOD->LoadTexturePtr(item_in_slot->GetIconName(), TEXTURE_16BIT_PALETTE); |
1012 item_in_slot->Reset(); | 1012 item_in_slot->Reset(); |
1013 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); | 1013 slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); |
1014 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); | 1014 slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); |
1015 if ( !areWeLoadingTexture ) | 1015 if ( !areWeLoadingTexture ) |
1016 { | 1016 { |
1039 int merchantLevel; // [sp+10h] [bp-8h]@1 | 1039 int merchantLevel; // [sp+10h] [bp-8h]@1 |
1040 int itemValue; | 1040 int itemValue; |
1041 | 1041 |
1042 merchantLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); | 1042 merchantLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); |
1043 idemId = pItem->uItemID; | 1043 idemId = pItem->uItemID; |
1044 equipType = pItemsTable->pItems[idemId].uEquipType; | 1044 equipType = pItem->GetItemEquipType(); |
1045 itemValue = pItem->GetValue(); | 1045 itemValue = pItem->GetValue(); |
1046 | 1046 |
1047 switch (building_type) | 1047 switch (building_type) |
1048 { | 1048 { |
1049 case BuildingType_WeaponShop: | 1049 case BuildingType_WeaponShop: |
1158 bool Player::CanRepair( ItemGen *pItem ) | 1158 bool Player::CanRepair( ItemGen *pItem ) |
1159 { | 1159 { |
1160 unsigned __int16 v2; // ax@1 | 1160 unsigned __int16 v2; // ax@1 |
1161 int v5; // edi@7 | 1161 int v5; // edi@7 |
1162 | 1162 |
1163 ItemDesc* v7 = &pItemsTable->pItems[pItem->uItemID]; | 1163 ITEM_EQUIP_TYPE equipType = pItem->GetItemEquipType(); |
1164 if (CheckHiredNPCSpeciality(Smith) && v7->uEquipType <= 2 || | 1164 if (CheckHiredNPCSpeciality(Smith) && equipType <= 2 || |
1165 CheckHiredNPCSpeciality(Armorer) && v7->uEquipType >= 3 && v7->uEquipType <= 9 || | 1165 CheckHiredNPCSpeciality(Armorer) && equipType >= 3 && equipType <= 9 || |
1166 CheckHiredNPCSpeciality(Alchemist) && v7->uEquipType >= 9 ) | 1166 CheckHiredNPCSpeciality(Alchemist) && equipType >= 9 ) |
1167 return true; | 1167 return true; |
1168 | 1168 |
1169 v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR); | 1169 v2 = GetActualSkillLevel(PLAYER_SKILL_REPAIR); |
1170 if ( (signed int)SkillToMastery(v2) >= 4 ) | 1170 if ( (signed int)SkillToMastery(v2) >= 4 ) |
1171 return true; | 1171 return true; |
1172 | 1172 |
1173 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); | 1173 int multiplier = GetMultiplierForSkillLevel(v2, 1, 2, 3, 5); |
1174 v5 = multiplier * (v2 & 0x3F); | 1174 v5 = multiplier * (v2 & 0x3F); |
1175 return v5 >= v7->uItemID_Rep_St; | 1175 return v5 >= pItemsTable->pItems[pItem->uItemID].uItemID_Rep_St; |
1176 } | 1176 } |
1177 | 1177 |
1178 //----- (004911F3) -------------------------------------------------------- | 1178 //----- (004911F3) -------------------------------------------------------- |
1179 int Player::GetMerchant() | 1179 int Player::GetMerchant() |
1180 { | 1180 { |
1618 if ( !ignoreOffhand ) | 1618 if ( !ignoreOffhand ) |
1619 { | 1619 { |
1620 if ( this->HasItemEquipped(EQUIP_OFF_HAND) ) | 1620 if ( this->HasItemEquipped(EQUIP_OFF_HAND) ) |
1621 { | 1621 { |
1622 ItemGen *offHandItemGen = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uShield - 1]; | 1622 ItemGen *offHandItemGen = (ItemGen *)&this->pInventoryItemList[this->pEquipment.uShield - 1]; |
1623 int itemId = offHandItemGen->uItemID; | 1623 if ( offHandItemGen->GetItemEquipType() != EQUIP_SHIELD ) |
1624 if ( pItemsTable->pItems[itemId].uEquipType != EQUIP_SHIELD ) | |
1625 { | 1624 { |
1626 offHndWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(offHandItemGen, uTargetActorID, false); | 1625 offHndWpnDmg = CalculateMeleeDmgToEnemyWithWeapon(offHandItemGen, uTargetActorID, false); |
1627 } | 1626 } |
1628 } | 1627 } |
1629 } | 1628 } |
1955 } | 1954 } |
1956 | 1955 |
1957 //----- (0048D62C) -------------------------------------------------------- | 1956 //----- (0048D62C) -------------------------------------------------------- |
1958 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) | 1957 ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) |
1959 { | 1958 { |
1960 return pItemsTable->pItems[pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uEquipType; | 1959 return pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].GetItemEquipType(); |
1961 } | 1960 } |
1962 | 1961 |
1963 //----- (0048D651) -------------------------------------------------------- | 1962 //----- (0048D651) -------------------------------------------------------- |
1964 PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) | 1963 PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) |
1965 { | 1964 { |
1966 return (PLAYER_SKILL_TYPE)pItemsTable->pItems[pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType; | 1965 return (PLAYER_SKILL_TYPE)pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].GetPlayerSkillType(); |
1967 } | 1966 } |
1968 | 1967 |
1969 //----- (0048D676) -------------------------------------------------------- | 1968 //----- (0048D676) -------------------------------------------------------- |
1970 bool Player::IsUnarmed() | 1969 bool Player::IsUnarmed() |
1971 { | 1970 { |
1976 //----- (0048D6AA) -------------------------------------------------------- | 1975 //----- (0048D6AA) -------------------------------------------------------- |
1977 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) | 1976 bool Player::HasItemEquipped(ITEM_EQUIP_TYPE uEquipIndex) |
1978 { | 1977 { |
1979 auto i = pEquipment.pIndices[uEquipIndex]; | 1978 auto i = pEquipment.pIndices[uEquipIndex]; |
1980 if (i) | 1979 if (i) |
1981 return (~(pOwnItems[i - 1].uAttributes & ITEM_BROKEN)) != 0; | 1980 return !pOwnItems[i - 1].IsBroken(); |
1982 else | 1981 else |
1983 return false; | 1982 return false; |
1984 } | 1983 } |
1985 | 1984 |
1986 //----- (0048D6D0) -------------------------------------------------------- | 1985 //----- (0048D6D0) -------------------------------------------------------- |
2037 { | 2036 { |
2038 v6 = this->pActiveSkills[34]; | 2037 v6 = this->pActiveSkills[34]; |
2039 v7 = v6 & 0x3F; | 2038 v7 = v6 & 0x3F; |
2040 v8 = SkillToMastery(v6); | 2039 v8 = SkillToMastery(v6); |
2041 itemvalue = itemToSteal->GetValue(); | 2040 itemvalue = itemToSteal->GetValue(); |
2042 v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType; | 2041 v10 = itemToSteal->GetItemEquipType(); |
2043 if ( v10 == EQUIP_OFF_HAND || v10 == EQUIP_MAIN_HAND || v10 == EQUIP_BOW ) | 2042 if ( v10 == EQUIP_OFF_HAND || v10 == EQUIP_MAIN_HAND || v10 == EQUIP_BOW ) |
2044 itemvalue *= 3; | 2043 itemvalue *= 3; |
2045 currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; | 2044 currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; |
2046 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; | 2045 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; |
2047 if (a5) | 2046 if (a5) |
2123 enchBonusSum = 0; | 2122 enchBonusSum = 0; |
2124 for (int i = 0; i < v7; i++) | 2123 for (int i = 0; i < v7; i++) |
2125 { | 2124 { |
2126 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; | 2125 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; |
2127 } | 2126 } |
2128 if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) | 2127 if ( actroPtr->array_000234[3].GetItemEquipType() != EQUIP_GOLD ) |
2129 return 2; | 2128 return 2; |
2130 enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; | 2129 enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; |
2131 if ( (int)enchBonusSum >= *enchTypePtr ) | 2130 if ( (int)enchBonusSum >= *enchTypePtr ) |
2132 { | 2131 { |
2133 actroPtr->array_000234[3].uItemID = 0; | 2132 actroPtr->array_000234[3].uItemID = 0; |
2154 tempItem.Reset(); | 2153 tempItem.Reset(); |
2155 HasFullItemSlots = false; | 2154 HasFullItemSlots = false; |
2156 int i; | 2155 int i; |
2157 for (i = 0; i < 4; i++) | 2156 for (i = 0; i < 4; i++) |
2158 { | 2157 { |
2159 if ( actroPtr->array_000234[i].uItemID != 0 && pItemsTable->pItems[actroPtr->array_000234[i].uItemID].uEquipType != EQUIP_GOLD ) | 2158 if ( actroPtr->array_000234[i].uItemID != 0 && actroPtr->array_000234[i].GetItemEquipType() != EQUIP_GOLD ) |
2160 break; | 2159 break; |
2161 } | 2160 } |
2162 if (i == 4) | 2161 if (i == 4) |
2163 HasFullItemSlots = true; | 2162 HasFullItemSlots = true; |
2164 carriedItemId = actroPtr->uCarriedItemID; | 2163 carriedItemId = actroPtr->uCarriedItemID; |
2179 ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; | 2178 ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; |
2180 memcpy(&tempItem, itemToSteal, sizeof(tempItem)); | 2179 memcpy(&tempItem, itemToSteal, sizeof(tempItem)); |
2181 itemToSteal->Reset(); | 2180 itemToSteal->Reset(); |
2182 carriedItemId = tempItem.uItemID; | 2181 carriedItemId = tempItem.uItemID; |
2183 } | 2182 } |
2184 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | 2183 if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems |
2185 sprintf( | 2184 { |
2186 pTmpBuf2.data(), | 2185 sub_421B2C_PlaceInInventory_or_DropPickedItem(); |
2187 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message | 2186 sprintf( |
2188 this->pName, | 2187 pTmpBuf2.data(), |
2189 pItemsTable->pItems[carriedItemId].pUnidentifiedName); | 2188 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message |
2190 ShowStatusBarString(pTmpBuf2.data(), 2u); | 2189 this->pName, |
2191 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | 2190 pItemsTable->pItems[carriedItemId].pUnidentifiedName); |
2192 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); | 2191 ShowStatusBarString(pTmpBuf2.data(), 2u); |
2193 pMouse->SetCursorBitmapFromItemID(carriedItemId); | 2192 sub_421B2C_PlaceInInventory_or_DropPickedItem(); |
2194 return 2; | 2193 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); |
2194 pMouse->SetCursorBitmapFromItemID(carriedItemId); | |
2195 return 2; | |
2196 } | |
2195 } | 2197 } |
2196 } | 2198 } |
2197 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | 2199 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything |
2198 ShowStatusBarString(pTmpBuf2.data(), 2u); | 2200 ShowStatusBarString(pTmpBuf2.data(), 2u); |
2199 return 2; | 2201 return 2; |
2253 if (broke_armor ) | 2255 if (broke_armor ) |
2254 { | 2256 { |
2255 armor_indx = pEquipment.uArmor; | 2257 armor_indx = pEquipment.uArmor; |
2256 if ( armor_indx ) | 2258 if ( armor_indx ) |
2257 { | 2259 { |
2258 if ( !(pOwnItems[armor_indx-1].uAttributes & ITEM_ENCHANTED)) | 2260 if ( !(pOwnItems[armor_indx-1].uAttributes & ITEM_HARDENED)) |
2259 { | 2261 { |
2260 pOwnItems[armor_indx-1].SetBroken(); | 2262 pOwnItems[armor_indx-1].SetBroken(); |
2261 } | 2263 } |
2262 } | 2264 } |
2263 } | 2265 } |
2332 v46[v4++] = i; | 2334 v46[v4++] = i; |
2333 } | 2335 } |
2334 if ( !v4 ) | 2336 if ( !v4 ) |
2335 return 0; | 2337 return 0; |
2336 v48 = &this->pInventoryItemList[v46[rand() % v4]]; | 2338 v48 = &this->pInventoryItemList[v46[rand() % v4]]; |
2337 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod); | 2339 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); |
2338 break; | 2340 break; |
2339 case SPECIAL_ATTACK_BREAK_ARMOR: | 2341 case SPECIAL_ATTACK_BREAK_ARMOR: |
2340 for (int i = 0; i < 16; i++ ) | 2342 for (int i = 0; i < 16; i++ ) |
2341 { | 2343 { |
2342 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 2344 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
2348 } | 2350 } |
2349 } | 2351 } |
2350 if ( !v4 ) | 2352 if ( !v4 ) |
2351 return 0; | 2353 return 0; |
2352 v48 = &this->pInventoryItemList[v46[rand() % v4]]; | 2354 v48 = &this->pInventoryItemList[v46[rand() % v4]]; |
2353 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod); | 2355 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); |
2354 break; | 2356 break; |
2355 case SPECIAL_ATTACK_BREAK_WEAPON: | 2357 case SPECIAL_ATTACK_BREAK_WEAPON: |
2356 for (int i = 0; i < 16; i++ ) | 2358 for (int i = 0; i < 16; i++ ) |
2357 { | 2359 { |
2358 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 2360 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
2365 } | 2367 } |
2366 } | 2368 } |
2367 if ( !v4 ) | 2369 if ( !v4 ) |
2368 return 0; | 2370 return 0; |
2369 v48 = &this->pInventoryItemList[v46[rand() % v4]]; | 2371 v48 = &this->pInventoryItemList[v46[rand() % v4]]; |
2370 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + pItemsTable->pItems[v48->uItemID].uDamageMod); | 2372 v11 = 3 * (pItemsTable->pItems[v48->uItemID].uMaterial + v48->GetDamageMod()); |
2371 break; | 2373 break; |
2372 case SPECIAL_ATTACK_STEAL: | 2374 case SPECIAL_ATTACK_STEAL: |
2373 for ( int i = 0; i < 126; i++ ) | 2375 for ( int i = 0; i < 126; i++ ) |
2374 { | 2376 { |
2375 int ItemPosInList = this->pInventoryMatrix[i]; | 2377 int ItemPosInList = this->pInventoryMatrix[i]; |
2505 return 1; | 2507 return 1; |
2506 break; | 2508 break; |
2507 case SPECIAL_ATTACK_BREAK_ANY: | 2509 case SPECIAL_ATTACK_BREAK_ANY: |
2508 case SPECIAL_ATTACK_BREAK_ARMOR: | 2510 case SPECIAL_ATTACK_BREAK_ARMOR: |
2509 case SPECIAL_ATTACK_BREAK_WEAPON: | 2511 case SPECIAL_ATTACK_BREAK_WEAPON: |
2510 if ( !(v48->uAttributes & ITEM_ENCHANTED) ) | 2512 if ( !(v48->uAttributes & ITEM_HARDENED) ) |
2511 { | 2513 { |
2512 PlaySound(SPEECH_40, 0); | 2514 PlaySound(SPEECH_40, 0); |
2513 v48->SetBroken(); | 2515 v48->SetBroken(); |
2514 pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); | 2516 pAudioPlayer->PlaySound((SoundID)47, 0, 0, -1, 0, 0, 0, 0); |
2515 } | 2517 } |
2607 auto v12_desc = &pItemsTable->pItems[v12->uItemID]; | 2609 auto v12_desc = &pItemsTable->pItems[v12->uItemID]; |
2608 if (base_recovery_times_per_weapon_type[v12_desc->uSkillType] > weapon_recovery) | 2610 if (base_recovery_times_per_weapon_type[v12_desc->uSkillType] > weapon_recovery) |
2609 { | 2611 { |
2610 weapon = &pInventoryItemList[pEquipment.uShield - 1]; | 2612 weapon = &pInventoryItemList[pEquipment.uShield - 1]; |
2611 weapon_desc = &pItemsTable->pItems[weapon->uItemID]; | 2613 weapon_desc = &pItemsTable->pItems[weapon->uItemID]; |
2612 weapon_recovery = base_recovery_times_per_weapon_type[pItemsTable->pItems[weapon->uItemID].uSkillType]; | 2614 weapon_recovery = base_recovery_times_per_weapon_type[weapon->GetPlayerSkillType()]; |
2613 } | 2615 } |
2614 } | 2616 } |
2615 | 2617 |
2616 uint armour_recovery = 0; | 2618 uint armour_recovery = 0; |
2617 if ( HasItemEquipped(EQUIP_ARMOUR) ) | 2619 if ( HasItemEquipped(EQUIP_ARMOUR) ) |
2618 { | 2620 { |
2619 auto armour_skill_type = pItemsTable->pItems[pInventoryItemList[pEquipment.uArmor - 1].uItemID].uSkillType; | 2621 auto armour_skill_type = pInventoryItemList[pEquipment.uArmor - 1].GetPlayerSkillType(); |
2620 uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; | 2622 uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; |
2621 float multiplier; | 2623 float multiplier; |
2622 | 2624 |
2623 if (armour_skill_type == PLAYER_SKILL_LEATHER) | 2625 if (armour_skill_type == PLAYER_SKILL_LEATHER) |
2624 { | 2626 { |
2643 | 2645 |
2644 uint shield_recovery = 0; | 2646 uint shield_recovery = 0; |
2645 if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD) | 2647 if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD) |
2646 { | 2648 { |
2647 auto shield = &pInventoryItemList[pEquipment.uShield - 1]; | 2649 auto shield = &pInventoryItemList[pEquipment.uShield - 1]; |
2648 auto skill_type = pItemsTable->pItems[shield->uItemID].uSkillType; | 2650 auto skill_type = shield->GetPlayerSkillType(); |
2649 | 2651 |
2650 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; | 2652 uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; |
2651 float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); | 2653 float multiplier = GetArmorRecoveryMultiplierFromSkillLevel(skill_type, 1.0f, 0, 0, 0); |
2652 shield_recovery = (uint)(shield_base_recovery * multiplier); | 2654 shield_recovery = (uint)(shield_base_recovery * multiplier); |
2653 } | 2655 } |
3098 switch(attr) //TODO would be nice to move these into separate functions | 3100 switch(attr) //TODO would be nice to move these into separate functions |
3099 { | 3101 { |
3100 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: | 3102 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: |
3101 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | 3103 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: |
3102 if ( HasItemEquipped(EQUIP_BOW) ) | 3104 if ( HasItemEquipped(EQUIP_BOW) ) |
3103 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uBow-1].uItemID].uDamageMod; | 3105 v5 = this->pOwnItems[this->pEquipment.uBow-1].GetDamageMod(); |
3104 return v5; | 3106 return v5; |
3105 break; | 3107 break; |
3106 | 3108 |
3107 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN: | 3109 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN: |
3108 if ( !HasItemEquipped(EQUIP_BOW) ) | 3110 if ( !HasItemEquipped(EQUIP_BOW) ) |
3175 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) | 3177 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) |
3176 { | 3178 { |
3177 v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); | 3179 v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); |
3178 if ( v17 >= 0 && v17 <= 2) | 3180 if ( v17 >= 0 && v17 <= 2) |
3179 { | 3181 { |
3180 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand-1].uItemID].uDamageMod; | 3182 v5 = this->pOwnItems[this->pEquipment.uMainHand-1].GetDamageMod(); |
3181 } | 3183 } |
3182 } | 3184 } |
3183 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 ) | 3185 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 ) |
3184 return v5; | 3186 return v5; |
3185 else | 3187 else |
3198 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) | 3200 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) |
3199 { | 3201 { |
3200 v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); | 3202 v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); |
3201 if ( v9 >= 0 && v9 <= 2) | 3203 if ( v9 >= 0 && v9 <= 2) |
3202 { | 3204 { |
3203 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID].uDamageDice + | 3205 v5 = this->pOwnItems[this->pEquipment.uMainHand - 1].GetDamageDice() + |
3204 pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID].uDamageMod; | 3206 this->pOwnItems[this->pEquipment.uMainHand - 1].GetDamageMod(); |
3205 if ( !this->pEquipment.uShield && pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID].uSkillType == 4) | 3207 if ( !this->pEquipment.uShield && this->pOwnItems[this->pEquipment.uMainHand - 1].GetPlayerSkillType() == 4) |
3206 { | 3208 { |
3207 ++v5; | 3209 ++v5; |
3208 } | 3210 } |
3209 } | 3211 } |
3210 } | 3212 } |
3213 { | 3215 { |
3214 return v5; | 3216 return v5; |
3215 } | 3217 } |
3216 else | 3218 else |
3217 { | 3219 { |
3218 v14 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageMod; | 3220 v14 = this->pOwnItems[this->pEquipment.uShield].GetDamageMod(); |
3219 v15 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageDice; | 3221 v15 = this->pOwnItems[this->pEquipment.uShield].GetDamageDice(); |
3220 return v5 + v15 + v14; | 3222 return v5 + v15 + v14; |
3221 } | 3223 } |
3222 break; | 3224 break; |
3223 | 3225 |
3224 case CHARACTER_ATTRIBUTE_STRENGTH: | 3226 case CHARACTER_ATTRIBUTE_STRENGTH: |
3739 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: | 3741 case CHARACTER_ATTRIBUTE_RANGED_ATTACK: |
3740 for (int i = 0; i < 16; i++) | 3742 for (int i = 0; i < 16; i++) |
3741 { | 3743 { |
3742 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3744 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3743 { | 3745 { |
3744 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType; | 3746 PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].GetPlayerSkillType(); |
3745 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); | 3747 int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); |
3746 if ( currentItemSkillType == PLAYER_SKILL_BOW ) | 3748 if ( currentItemSkillType == PLAYER_SKILL_BOW ) |
3747 { | 3749 { |
3748 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1); | 3750 int multiplier = GetMultiplierForSkillLevel(currentItemSkillLevel, 1, 1, 1, 1); |
3749 return multiplier * (currentItemSkillLevel & 0x3F); | 3751 return multiplier * (currentItemSkillLevel & 0x3F); |
3771 } | 3773 } |
3772 for (int i = 0; i < 16; i++) | 3774 for (int i = 0; i < 16; i++) |
3773 { | 3775 { |
3774 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) | 3776 if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) |
3775 { | 3777 { |
3776 int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID; | 3778 ItemGen* currItemPtr = &this->pInventoryItemList[this->pEquipment.pIndices[i] - 1]; |
3777 if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND ) | 3779 if ( currItemPtr->GetItemEquipType() == EQUIP_MAIN_HAND || currItemPtr->GetItemEquipType() == EQUIP_OFF_HAND ) |
3778 { | 3780 { |
3779 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType; | 3781 PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)currItemPtr->GetPlayerSkillType(); |
3780 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); | 3782 int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); |
3781 int baseSkillBonus; | 3783 int baseSkillBonus; |
3782 int multiplier; | 3784 int multiplier; |
3783 switch (currItemSkillType) | 3785 switch (currItemSkillType) |
3784 { | 3786 { |
4376 thisb = this; | 4378 thisb = this; |
4377 playerAffected = &pParty->pPlayers[player_num-1]; | 4379 playerAffected = &pParty->pPlayers[player_num-1]; |
4378 v73 = 1; | 4380 v73 = 1; |
4379 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) ) | 4381 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) ) |
4380 return; | 4382 return; |
4381 if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_REAGENT ) | 4383 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_REAGENT ) |
4382 { | 4384 { |
4383 if ( pParty->pPickedItem.uItemID == 160 ) | 4385 if ( pParty->pPickedItem.uItemID == 160 ) |
4384 { | 4386 { |
4385 playerAffected->SetCondition(Condition_Poison1, 1); | 4387 playerAffected->SetCondition(Condition_Poison1, 1); |
4386 } | 4388 } |
4426 } | 4428 } |
4427 pMouse->RemoveHoldingItem(); | 4429 pMouse->RemoveHoldingItem(); |
4428 return; | 4430 return; |
4429 } | 4431 } |
4430 | 4432 |
4431 if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_POTION ) | 4433 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_POTION ) |
4432 { | 4434 { |
4433 switch ( pParty->pPickedItem.uItemID ) | 4435 switch ( pParty->pPickedItem.uItemID ) |
4434 { | 4436 { |
4435 case 221: //Catalyst | 4437 case 221: //Catalyst |
4436 playerAffected->SetCondition(Condition_Poison1, 1); | 4438 playerAffected->SetCondition(Condition_Poison1, 1); |
4722 pMouse->RemoveHoldingItem(); | 4724 pMouse->RemoveHoldingItem(); |
4723 return; | 4725 return; |
4724 } | 4726 } |
4725 | 4727 |
4726 | 4728 |
4727 if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_SPELL_SCROLL ) | 4729 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_SPELL_SCROLL ) |
4728 { | 4730 { |
4729 if ( pCurrentScreen == SCREEN_CASTING ) | 4731 if ( pCurrentScreen == SCREEN_CASTING ) |
4730 return; | 4732 return; |
4731 if ( !playerAffected->CanAct() ) | 4733 if ( !playerAffected->CanAct() ) |
4732 { | 4734 { |
4766 } | 4768 } |
4767 } | 4769 } |
4768 return; | 4770 return; |
4769 } | 4771 } |
4770 | 4772 |
4771 if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_BOOK ) | 4773 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_BOOK ) |
4772 { | 4774 { |
4773 v15 = pParty->pPickedItem.uItemID - 400; | 4775 v15 = pParty->pPickedItem.uItemID - 400; |
4774 v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2; | 4776 v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2; |
4775 if ( v72 ) | 4777 if ( v72 ) |
4776 { | 4778 { |
4838 // } | 4840 // } |
4839 pMouse->RemoveHoldingItem(); | 4841 pMouse->RemoveHoldingItem(); |
4840 return; | 4842 return; |
4841 } | 4843 } |
4842 | 4844 |
4843 if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_MESSAGE_SCROLL ) | 4845 if ( pParty->pPickedItem.GetItemEquipType() == EQUIP_MESSAGE_SCROLL ) |
4844 { | 4846 { |
4845 if ( playerAffected->CanAct() ) | 4847 if ( playerAffected->CanAct() ) |
4846 { | 4848 { |
4847 CreateMsgScrollWindow(pParty->pPickedItem.uItemID); | 4849 CreateMsgScrollWindow(pParty->pPickedItem.uItemID); |
4848 playerAffected->PlaySound(SPEECH_37, 0); | 4850 playerAffected->PlaySound(SPEECH_37, 0); |
6236 item.uItemID = val; | 6238 item.uItemID = val; |
6237 if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER ) | 6239 if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER ) |
6238 pParty->pIsArtifactFound[val-500] = 1; | 6240 pParty->pIsArtifactFound[val-500] = 1; |
6239 if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION ) | 6241 if ( val >= ITEM_WAND_FIRE && val <= ITEM_WAND_INCENERATION ) |
6240 { | 6242 { |
6241 item.uNumCharges = rand() % 6 + pItemsTable->pItems[item.uItemID].uDamageMod + 1; | 6243 item.uNumCharges = rand() % 6 + item.GetDamageMod() + 1; |
6242 item.uMaxCharges = LOBYTE(item.uNumCharges); | 6244 item.uMaxCharges = LOBYTE(item.uNumCharges); |
6243 } | 6245 } |
6244 pParty->SetHoldingItem(&item); | 6246 pParty->SetHoldingItem(&item); |
6245 return; | 6247 return; |
6246 case VAR_FixedGold: | 6248 case VAR_FixedGold: |
7404 v8 = playerPtr->pEquipment.uArmor; | 7406 v8 = playerPtr->pEquipment.uArmor; |
7405 SoundID soundToPlay; | 7407 SoundID soundToPlay; |
7406 if ( !v8 | 7408 if ( !v8 |
7407 || playerPtr->pInventoryItemList[v8 - 1].IsBroken() | 7409 || playerPtr->pInventoryItemList[v8 - 1].IsBroken() |
7408 || | 7410 || |
7409 (pItemsTable->pItems[playerPtr->pInventoryItemList[v8 - 1].uItemID].uSkillType != PLAYER_SKILL_CHAIN | 7411 (playerPtr->pInventoryItemList[v8 - 1].GetPlayerSkillType() != PLAYER_SKILL_CHAIN |
7410 && pItemsTable->pItems[playerPtr->pInventoryItemList[v8 - 1].uItemID].uSkillType != PLAYER_SKILL_PLATE | 7412 && playerPtr->pInventoryItemList[v8 - 1].GetPlayerSkillType() != PLAYER_SKILL_PLATE |
7411 ) | 7413 ) |
7412 ) | 7414 ) |
7413 { | 7415 { |
7414 int randVal = rand() % 4; | 7416 int randVal = rand() % 4; |
7415 switch (randVal) | 7417 switch (randVal) |
7790 return; | 7792 return; |
7791 } | 7793 } |
7792 } | 7794 } |
7793 v9 = tmpItem.uItemID; | 7795 v9 = tmpItem.uItemID; |
7794 memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); | 7796 memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); |
7795 pMouse->SetCursorBitmap(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName); | 7797 pMouse->SetCursorBitmap(pParty->pPickedItem.GetIconName()); |
7796 return; | 7798 return; |
7797 } | 7799 } |
7798 else | 7800 else |
7799 { | 7801 { |
7800 v10 = this->AddItem(invMatrixIndex, pickedItemId); | 7802 v10 = this->AddItem(invMatrixIndex, pickedItemId); |