Mercurial > mm7
comparison Player.cpp @ 1688:ece764a4672d
Player::StealFromActor finishing cleanup
author | Grumpy7 |
---|---|
date | Sun, 22 Sep 2013 04:31:34 +0200 |
parents | 5f01f1ed97f4 |
children | 133a5f62bc8c |
comparison
equal
deleted
inserted
replaced
1687:5f01f1ed97f4 | 1688:ece764a4672d |
---|---|
2116 return 0; | 2116 return 0; |
2117 } | 2117 } |
2118 else | 2118 else |
2119 { | 2119 { |
2120 v11 = rand(); | 2120 v11 = rand(); |
2121 if ( v11 % 100 >= 40 ) | 2121 if ( v11 % 100 >= 70 ) //stealing gold |
2122 { | 2122 { |
2123 if ( v11 % 100 >= 70 ) | 2123 enchBonusSum = 0; |
2124 { | 2124 for (int i = 0; i < v7; i++) |
2125 enchBonusSum = 0; | 2125 { |
2126 for (int i = 0; i < v7; i++) | 2126 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; |
2127 } | |
2128 if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) | |
2129 return 2; | |
2130 enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; | |
2131 if ( (int)enchBonusSum >= *enchTypePtr ) | |
2132 { | |
2133 actroPtr->array_000234[3].uItemID = 0; | |
2134 *enchTypePtr = 0; | |
2135 } | |
2136 else | |
2137 { | |
2138 *enchTypePtr -= enchBonusSum; | |
2139 } | |
2140 if ( enchBonusSum ) | |
2141 { | |
2142 party_finds_gold(enchBonusSum, 2); | |
2143 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold | |
2144 } | |
2145 else | |
2146 { | |
2147 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | |
2148 } | |
2149 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
2150 return 2; | |
2151 } | |
2152 else if ( v11 % 100 >= 40 ) //stealing an item | |
2153 { | |
2154 tempItem.Reset(); | |
2155 HasFullItemSlots = false; | |
2156 int i; | |
2157 for (i = 0; i < 4; i++) | |
2158 { | |
2159 if ( actroPtr->array_000234[i].uItemID != 0 && pItemsTable->pItems[actroPtr->array_000234[i].uItemID].uEquipType != EQUIP_GOLD ) | |
2160 break; | |
2161 } | |
2162 if (i == 4) | |
2163 HasFullItemSlots = true; | |
2164 carriedItemId = actroPtr->uCarriedItemID; | |
2165 if ( carriedItemId != 0 || HasFullItemSlots ) | |
2166 { | |
2167 tempItem.Reset(); | |
2168 if ( carriedItemId != 0 ) | |
2127 { | 2169 { |
2128 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; | 2170 actroPtr->uCarriedItemID = 0; |
2129 } | 2171 tempItem.uItemID = carriedItemId; |
2130 if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) | 2172 if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) |
2131 return 2; | 2173 tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; |
2132 enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; | 2174 else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) |
2133 if ( (int)enchBonusSum >= *enchTypePtr ) | 2175 tempItem.uEnchantmentType = 2 * rand() % 4 + 2; |
2134 { | |
2135 actroPtr->array_000234[3].uItemID = 0; | |
2136 *enchTypePtr = 0; | |
2137 } | 2176 } |
2138 else | 2177 else |
2139 { | 2178 { |
2140 *enchTypePtr -= enchBonusSum; | 2179 ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; |
2180 memcpy(&tempItem, itemToSteal, sizeof(tempItem)); | |
2181 itemToSteal->Reset(); | |
2182 carriedItemId = tempItem.uItemID; | |
2141 } | 2183 } |
2142 if ( enchBonusSum ) | 2184 sub_421B2C_PlaceInInventory_or_DropPickedItem(); |
2143 { | 2185 sprintf( |
2144 party_finds_gold(enchBonusSum, 2); | 2186 pTmpBuf2.data(), |
2145 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold | 2187 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message |
2146 } | 2188 this->pName, |
2147 else | 2189 pItemsTable->pItems[carriedItemId].pUnidentifiedName); |
2148 { | |
2149 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | |
2150 } | |
2151 ShowStatusBarString(pTmpBuf2.data(), 2u); | 2190 ShowStatusBarString(pTmpBuf2.data(), 2u); |
2191 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2192 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); | |
2193 pMouse->SetCursorBitmapFromItemID(carriedItemId); | |
2152 return 2; | 2194 return 2; |
2153 } | |
2154 else | |
2155 { | |
2156 tempItem.Reset(); | |
2157 HasFullItemSlots = false; | |
2158 int i; | |
2159 for (i = 0; i < 4; i++) | |
2160 { | |
2161 if ( actroPtr->array_000234[i].uItemID != 0 && pItemsTable->pItems[actroPtr->array_000234[i].uItemID].uEquipType != EQUIP_GOLD ) | |
2162 break; | |
2163 } | |
2164 if (i == 4) | |
2165 HasFullItemSlots = true; | |
2166 carriedItemId = actroPtr->uCarriedItemID; | |
2167 if ( carriedItemId != 0 || HasFullItemSlots ) | |
2168 { | |
2169 tempItem.Reset(); | |
2170 if ( carriedItemId != 0 ) | |
2171 { | |
2172 actroPtr->uCarriedItemID = 0; | |
2173 tempItem.uItemID = carriedItemId; | |
2174 if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) | |
2175 tempItem.uNumCharges = rand() % 6 + pItemsTable->pItems[carriedItemId].uDamageMod + 1; | |
2176 else if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_POTION && carriedItemId != ITEM_POTION_BOTTLE) | |
2177 tempItem.uEnchantmentType = 2 * rand() % 4 + 2; | |
2178 } | |
2179 else | |
2180 { | |
2181 ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; | |
2182 memcpy(&tempItem, itemToSteal, sizeof(tempItem)); | |
2183 itemToSteal->Reset(); | |
2184 carriedItemId = tempItem.uItemID; | |
2185 } | |
2186 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2187 sprintf( | |
2188 pTmpBuf2.data(), | |
2189 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message | |
2190 this->pName, | |
2191 pItemsTable->pItems[carriedItemId].pUnidentifiedName); | |
2192 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
2193 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2194 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); | |
2195 pMouse->SetCursorBitmapFromItemID(carriedItemId); | |
2196 return 2; | |
2197 } | |
2198 } | 2195 } |
2199 } | 2196 } |
2200 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | 2197 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything |
2201 ShowStatusBarString(pTmpBuf2.data(), 2u); | 2198 ShowStatusBarString(pTmpBuf2.data(), 2u); |
2202 return 2; | 2199 return 2; |