Mercurial > mm7
diff Player.cpp @ 1688:ece764a4672d
Player::StealFromActor finishing cleanup
author | Grumpy7 |
---|---|
date | Sun, 22 Sep 2013 04:31:34 +0200 |
parents | 5f01f1ed97f4 |
children | 133a5f62bc8c |
line wrap: on
line diff
--- a/Player.cpp Sun Sep 22 03:12:11 2013 +0200 +++ b/Player.cpp Sun Sep 22 04:31:34 2013 +0200 @@ -2118,83 +2118,80 @@ else { v11 = rand(); - if ( v11 % 100 >= 40 ) - { - if ( v11 % 100 >= 70 ) - { - enchBonusSum = 0; - for (int i = 0; i < v7; i++) + if ( v11 % 100 >= 70 ) //stealing gold + { + enchBonusSum = 0; + for (int i = 0; i < v7; i++) + { + enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; + } + if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) + return 2; + enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; + if ( (int)enchBonusSum >= *enchTypePtr ) + { + actroPtr->array_000234[3].uItemID = 0; + *enchTypePtr = 0; + } + else + { + *enchTypePtr -= enchBonusSum; + } + if ( enchBonusSum ) + { + party_finds_gold(enchBonusSum, 2); + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold + } + else + { + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything + } + ShowStatusBarString(pTmpBuf2.data(), 2u); + return 2; + } + else if ( v11 % 100 >= 40 ) //stealing an item + { + tempItem.Reset(); + HasFullItemSlots = false; + int i; + for (i = 0; i < 4; i++) + { + if ( actroPtr->array_000234[i].uItemID != 0 && pItemsTable->pItems[actroPtr->array_000234[i].uItemID].uEquipType != EQUIP_GOLD ) + break; + } + if (i == 4) + HasFullItemSlots = true; + carriedItemId = actroPtr->uCarriedItemID; + if ( carriedItemId != 0 || HasFullItemSlots ) + { + tempItem.Reset(); + if ( carriedItemId != 0 ) { - enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; - } - if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) - return 2; - enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; - if ( (int)enchBonusSum >= *enchTypePtr ) - { - actroPtr->array_000234[3].uItemID = 0; - *enchTypePtr = 0; - } - else - { - *enchTypePtr -= enchBonusSum; - } - if ( enchBonusSum ) - { - party_finds_gold(enchBonusSum, 2); - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold + actroPtr->uCarriedItemID = 0; + tempItem.uItemID = carriedItemId; + if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) + tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; + else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) + tempItem.uEnchantmentType = 2 * rand() % 4 + 2; } else { - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything - } - ShowStatusBarString(pTmpBuf2.data(), 2u); - return 2; - } - else - { - tempItem.Reset(); - HasFullItemSlots = false; - int i; - for (i = 0; i < 4; i++) - { - if ( actroPtr->array_000234[i].uItemID != 0 && pItemsTable->pItems[actroPtr->array_000234[i].uItemID].uEquipType != EQUIP_GOLD ) - break; + ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; + memcpy(&tempItem, itemToSteal, sizeof(tempItem)); + itemToSteal->Reset(); + carriedItemId = tempItem.uItemID; } - if (i == 4) - HasFullItemSlots = true; - carriedItemId = actroPtr->uCarriedItemID; - if ( carriedItemId != 0 || HasFullItemSlots ) - { - tempItem.Reset(); - if ( carriedItemId != 0 ) - { - actroPtr->uCarriedItemID = 0; - tempItem.uItemID = carriedItemId; - if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) - tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; - else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) - tempItem.uEnchantmentType = 2 * rand() % 4 + 2; - } - else - { - ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; - memcpy(&tempItem, itemToSteal, sizeof(tempItem)); - itemToSteal->Reset(); - carriedItemId = tempItem.uItemID; - } - sub_421B2C_PlaceInInventory_or_DropPickedItem(); - sprintf( - pTmpBuf2.data(), - pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message - this->pName, - pItemsTable->pItems[carriedItemId].pUnidentifiedName); - ShowStatusBarString(pTmpBuf2.data(), 2u); - sub_421B2C_PlaceInInventory_or_DropPickedItem(); - memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); - pMouse->SetCursorBitmapFromItemID(carriedItemId); - return 2; - } + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + sprintf( + pTmpBuf2.data(), + pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message + this->pName, + pItemsTable->pItems[carriedItemId].pUnidentifiedName); + ShowStatusBarString(pTmpBuf2.data(), 2u); + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); + pMouse->SetCursorBitmapFromItemID(carriedItemId); + return 2; } } sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything