Mercurial > mm7
comparison Player.cpp @ 1687:5f01f1ed97f4
Player::StealFromActor cleanup, renamed UIMSG_1B to UIMSG_STEALFROMACTOR
author | Grumpy7 |
---|---|
date | Sun, 22 Sep 2013 03:12:11 +0200 |
parents | df30a0c901e5 |
children | ece764a4672d |
comparison
equal
deleted
inserted
replaced
1686:df30a0c901e5 | 1687:5f01f1ed97f4 |
---|---|
2025 | 2025 |
2026 if ( !itemToSteal | 2026 if ( !itemToSteal |
2027 || this->IsEradicated() | 2027 || this->IsEradicated() |
2028 || this->IsDead() | 2028 || this->IsDead() |
2029 || this->IsPertified() | 2029 || this->IsPertified() |
2030 || this->pConditions[Condition_Drunk] | 2030 || this->IsDrunk() |
2031 || this->IsUnconcious() | 2031 || this->IsUnconcious() |
2032 || this->IsAsleep() ) | 2032 || this->IsAsleep() ) |
2033 { | 2033 { |
2034 return 0; | 2034 return 0; |
2035 } | 2035 } |
2038 v6 = this->pActiveSkills[34]; | 2038 v6 = this->pActiveSkills[34]; |
2039 v7 = v6 & 0x3F; | 2039 v7 = v6 & 0x3F; |
2040 v8 = SkillToMastery(v6); | 2040 v8 = SkillToMastery(v6); |
2041 itemvalue = itemToSteal->GetValue(); | 2041 itemvalue = itemToSteal->GetValue(); |
2042 v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType; | 2042 v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType; |
2043 if ( v10 == 0 || v10 == 1 || v10 == 2 ) | 2043 if ( v10 == EQUIP_OFF_HAND || v10 == EQUIP_MAIN_HAND || v10 == EQUIP_BOW ) |
2044 itemvalue *= 3; | 2044 itemvalue *= 3; |
2045 currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; | 2045 currMaxItemValue = StealingRandomBonuses[rand() % 5] + v7 * StealingMasteryBonuses[v8]; |
2046 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; | 2046 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue; |
2047 if (a5) | 2047 if (a5) |
2048 { | 2048 { |
2072 // 4EDEB4: using guessed type int dword_4EDEB4[]; | 2072 // 4EDEB4: using guessed type int dword_4EDEB4[]; |
2073 | 2073 |
2074 //----- (0048D88B) -------------------------------------------------------- | 2074 //----- (0048D88B) -------------------------------------------------------- |
2075 int Player::StealFromActor(unsigned int uActorID, int _steal_perm, int reputation) | 2075 int Player::StealFromActor(unsigned int uActorID, int _steal_perm, int reputation) |
2076 { | 2076 { |
2077 Player *v4; // esi@1 | 2077 Actor *actroPtr; // edi@1 |
2078 Actor *v5; // edi@1 | |
2079 unsigned __int16 v6; // cx@10 | |
2080 int v7; // ebx@10 | 2078 int v7; // ebx@10 |
2081 unsigned int v8; // esi@10 | 2079 unsigned int stealingMastery; // esi@10 |
2082 int v9; // eax@10 | 2080 int fineIfFailed; // esi@10 |
2083 int v10; // esi@10 | |
2084 int v11; // eax@13 | 2081 int v11; // eax@13 |
2085 signed int v12; // ebx@15 | 2082 bool HasFullItemSlots; // ebx@15 |
2086 signed int v13; // edx@15 | 2083 unsigned __int16 carriedItemId; // si@21 |
2087 int v14; // ecx@15 | 2084 unsigned int enchBonusSum; // esi@31 |
2088 unsigned __int16 v15; // si@21 | 2085 int *enchTypePtr; // eax@34 |
2089 unsigned int v16; // ebx@24 | 2086 ItemGen tempItem; // [sp+8h] [bp-34h]@15 |
2090 int v17; // esi@24 | 2087 int currMaxItemValue; |
2091 const void *v18; // eax@29 | 2088 |
2092 unsigned int v19; // esi@31 | 2089 actroPtr = &pActors[uActorID]; |
2093 int v20; // eax@34 | 2090 if ( !actroPtr |
2094 char v21; // zf@36 | 2091 || this->IsEradicated() |
2095 unsigned int v22; // ST0C_4@39 | 2092 || this->IsDead() |
2096 char *v23; // esi@39 | 2093 || this->IsPertified() |
2097 const char *v25; // [sp-Ch] [bp-48h]@40 | 2094 || this->IsDrunk() |
2098 int v26; // [sp-8h] [bp-44h]@40 | 2095 || this->IsUnconcious() |
2099 ItemGen v27; // [sp+8h] [bp-34h]@15 | 2096 || this->IsAsleep() ) |
2100 unsigned int v28; // [sp+2Ch] [bp-10h]@10 | 2097 { |
2101 int v29; // [sp+30h] [bp-Ch]@10 | 2098 return 0; |
2102 int v30; // [sp+34h] [bp-8h]@10 | 2099 } |
2103 Player *v31; // [sp+38h] [bp-4h]@1 | 2100 pGlobalTXT_LocalizationStrings[1]; |
2104 signed int _steal_perma; // [sp+48h] [bp+Ch]@12 | 2101 if ( !(BYTE2(actroPtr->uAttributes) & 0x80) ) |
2105 | 2102 actroPtr->SetRandomGoldIfTheresNoItem(); |
2106 v4 = this; | 2103 unsigned __int16 v6 = this->pActiveSkills[34]; |
2107 v5 = &pActors[uActorID]; | 2104 v7 = v6 & 0x3F; |
2108 v31 = this; | 2105 stealingMastery = SkillToMastery(v6); |
2109 if ( &pActors[uActorID] | 2106 int v30 = StealingMasteryBonuses[stealingMastery]; |
2110 && !this->pConditions[16] | 2107 int v29 = StealingRandomBonuses[rand() % 5]; |
2111 && !this->pConditions[14] | 2108 fineIfFailed = actroPtr->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); |
2112 && !this->pConditions[15] | 2109 currMaxItemValue = v29 + v7 * v30; |
2113 && !this->pConditions[4] | 2110 pGlobalTXT_LocalizationStrings[200]; |
2114 && !this->pConditions[13] | 2111 if ( false && (rand() % 100 < 5 || fineIfFailed > currMaxItemValue || BYTE2(actroPtr->uAttributes) & 8) ) |
2115 && !this->pConditions[2] ) | 2112 { |
2116 { | 2113 Actor::AggroSurroundingPeasants(uActorID, 1); |
2117 if ( !(BYTE2(v5->uAttributes) & 0x80) ) | 2114 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[376], this->pName); |
2118 pActors[uActorID].SetRandomGoldIfTheresNoItem(); | 2115 ShowStatusBarString(pTmpBuf2.data(), 2u); |
2119 v6 = v4->pActiveSkills[34]; | 2116 return 0; |
2120 v7 = v6 & 0x3F; | 2117 } |
2121 v8 = SkillToMastery(v6); | 2118 else |
2122 v9 = rand(); | 2119 { |
2123 v30 = StealingMasteryBonuses[v8]; | 2120 v11 = rand(); |
2124 v29 = StealingRandomBonuses[v9 % 100 / 20]; | 2121 if ( v11 % 100 >= 40 ) |
2125 v10 = v5->pMonsterInfo.uLevel + 100 * (_steal_perm + reputation); | 2122 { |
2126 if ( rand() % 100 < 5 || v10 > v29 + v7 * v30 || (_steal_perma = 2, BYTE2(v5->uAttributes) & 8) ) | 2123 if ( v11 % 100 >= 70 ) |
2127 { | 2124 { |
2128 Actor::AggroSurroundingPeasants(uActorID, 1); | 2125 enchBonusSum = 0; |
2129 _steal_perma = 0; | 2126 for (int i = 0; i < v7; i++) |
2130 v26 = (int)v31->pName; | |
2131 v25 = pGlobalTXT_LocalizationStrings[376]; | |
2132 } | |
2133 else | |
2134 { | |
2135 v11 = rand(); | |
2136 if ( v11 % 100 >= 40 ) | |
2137 { | |
2138 if ( v11 % 100 >= 70 ) | |
2139 { | 2127 { |
2140 v19 = 0; | 2128 enchBonusSum += rand() % StealingEnchantmentBonusForSkill[stealingMastery] + 1; |
2141 if ( v7 > 0 ) | 2129 } |
2142 { | 2130 if ( pItemsTable->pItems[actroPtr->array_000234[3].uItemID].uEquipType != EQUIP_GOLD ) |
2143 do | 2131 return 2; |
2144 { | 2132 enchTypePtr = &actroPtr->array_000234[3].uSpecEnchantmentType; |
2145 --v7; | 2133 if ( (int)enchBonusSum >= *enchTypePtr ) |
2146 v19 += rand() % StealingEnchantmentBonusForSkill[v8] + 1; | 2134 { |
2147 } | 2135 actroPtr->array_000234[3].uItemID = 0; |
2148 while ( v7 ); | 2136 *enchTypePtr = 0; |
2149 } | |
2150 if ( pItemsTable->pItems[v5->array_000234[3].uItemID].uEquipType != 18 ) | |
2151 return _steal_perma; | |
2152 v20 = (int)&v5->array_000234[3].uSpecEnchantmentType; | |
2153 if ( (signed int)v19 > v5->array_000234[3].uSpecEnchantmentType ) | |
2154 v19 = v5->array_000234[3].uSpecEnchantmentType; | |
2155 v21 = *(int *)v20 == v19; | |
2156 *(int *)v20 -= v19; | |
2157 if ( v21 ) | |
2158 v5->array_000234[3].uItemID = 0; | |
2159 if ( v19 ) | |
2160 { | |
2161 party_finds_gold(v19, 2); | |
2162 v22 = v19; | |
2163 v23 = pTmpBuf2.data(); | |
2164 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], v31->pName, v22); | |
2165 LABEL_43: | |
2166 ShowStatusBarString(v23, 2u); | |
2167 return _steal_perma; | |
2168 } | |
2169 } | 2137 } |
2170 else | 2138 else |
2171 { | 2139 { |
2172 v27.Reset(); | 2140 *enchTypePtr -= enchBonusSum; |
2173 v12 = 0; | 2141 } |
2174 v13 = 0; | 2142 if ( enchBonusSum ) |
2175 v14 = (int)v5->array_000234; | 2143 { |
2176 while ( !*(int *)v14 || pItemsTable->pItems[*(int *)v14].uEquipType == 18 ) | 2144 party_finds_gold(enchBonusSum, 2); |
2145 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[302], this->pName, enchBonusSum); //%stole %d gold | |
2146 } | |
2147 else | |
2148 { | |
2149 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything | |
2150 } | |
2151 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
2152 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 ) | |
2177 { | 2171 { |
2178 ++v13; | 2172 actroPtr->uCarriedItemID = 0; |
2179 v14 += 36; | 2173 tempItem.uItemID = carriedItemId; |
2180 if ( v13 >= 4 ) | 2174 if ( pItemsTable->pItems[carriedItemId].uEquipType == EQUIP_WAND ) |
2181 goto LABEL_21; | 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; | |
2182 } | 2178 } |
2183 v12 = 1; | 2179 else |
2184 LABEL_21: | |
2185 v15 = v5->uCarriedItemID; | |
2186 if ( v15 || v12 ) | |
2187 { | 2180 { |
2188 v27.Reset(); | 2181 ItemGen* itemToSteal = &actroPtr->array_000234[rand() % 4]; |
2189 if ( v15 ) | 2182 memcpy(&tempItem, itemToSteal, sizeof(tempItem)); |
2190 { | 2183 itemToSteal->Reset(); |
2191 v16 = (signed __int16)v15; | 2184 carriedItemId = tempItem.uItemID; |
2192 v5->uCarriedItemID = 0; | |
2193 v27.uItemID = (signed __int16)v15; | |
2194 v17 = (signed __int16)v15; | |
2195 if ( pItemsTable->pItems[v17].uEquipType == 12 ) | |
2196 v27.uNumCharges = rand() % 6 + pItemsTable->pItems[v17].uDamageMod + 1; | |
2197 if ( pItemsTable->pItems[v17].uEquipType == 14 ) | |
2198 { | |
2199 if ( v16 != 220 ) | |
2200 v27.uEnchantmentType = 2 * rand() % 4 + 2; | |
2201 } | |
2202 } | |
2203 else | |
2204 { | |
2205 v18 = &v5->array_000234[rand() % 4]; | |
2206 memcpy(&v27, v18, sizeof(v27)); | |
2207 ((ItemGen *)v18)->Reset(); | |
2208 v16 = v27.uItemID; | |
2209 } | |
2210 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2211 sprintf( | |
2212 pTmpBuf2.data(), | |
2213 pGlobalTXT_LocalizationStrings[304], | |
2214 v31->pName, | |
2215 pItemsTable->pItems[v16].pUnidentifiedName); | |
2216 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
2217 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
2218 memcpy(&pParty->pPickedItem, &v27, sizeof(pParty->pPickedItem)); | |
2219 pMouse->SetCursorBitmapFromItemID(v16); | |
2220 return _steal_perma; | |
2221 } | 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; | |
2222 } | 2197 } |
2223 } | 2198 } |
2224 v26 = (int)v31->pName; | 2199 } |
2225 v25 = pGlobalTXT_LocalizationStrings[377]; | 2200 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[377], this->pName); //%s failed to steal anything |
2226 } | 2201 ShowStatusBarString(pTmpBuf2.data(), 2u); |
2227 v23 = pTmpBuf2.data(); | 2202 return 2; |
2228 sprintfex(pTmpBuf2.data(), v25, v26); | 2203 } |
2229 goto LABEL_43; | |
2230 } | |
2231 return 0; | |
2232 } | 2204 } |
2233 // 4EDEA0: using guessed type int dword_4EDEA0[]; | 2205 // 4EDEA0: using guessed type int dword_4EDEA0[]; |
2234 // 4EDEB4: using guessed type int dword_4EDEB4[]; | 2206 // 4EDEB4: using guessed type int dword_4EDEB4[]; |
2235 // 4EDEC4: using guessed type int dword_4EDEC4[]; | 2207 // 4EDEC4: using guessed type int dword_4EDEC4[]; |
2236 | 2208 |