comparison Player.cpp @ 1604:4b79ff62df3a

Moved enchantment attribute bonus list to items.cpp/h, created static function that create the enchantments + helper functions to get the enchantment strength, moved the whole logic of Player::GetItemsBonus to a case
author Grumpy7
date Sat, 14 Sep 2013 06:04:18 +0200
parents 5ac59bcb68e9
children 434b796cdfd3
comparison
equal deleted inserted replaced
1603:c58916c53d8e 1604:4b79ff62df3a
153 10, // PLAYER_SKILL_SHIELD 153 10, // PLAYER_SKILL_SHIELD
154 10, // PLAYER_SKILL_LEATHER 154 10, // PLAYER_SKILL_LEATHER
155 20, // PLAYER_SKILL_CHAIN 155 20, // PLAYER_SKILL_CHAIN
156 30 // PLAYER_SKILL_PLATE 156 30 // PLAYER_SKILL_PLATE
157 }; 157 };
158
159 #include <map>
160 #include <list>
161
162 typedef struct CEnchantment
163 {
164 CEnchantment(int bonus, unsigned __int16 Player::* skillPtr = NULL):
165 statBonus(bonus),
166 statPtr(skillPtr)
167 {
168 }
169 int statBonus;
170 unsigned __int16 Player::* statPtr;
171 } CEnchantment;
172
173 #define NEWBONUSINTOSPECIALLIST(x,y) AddToMap(specialBonusMap, enchId, x, y);
174 #define NEWBONUSINTOSPECIALLIST2(x,y,z) AddToMap(specialBonusMap, enchId, x, y, z);
175
176 #define NEWBONUSINTOREGULARLIST(x) AddToMap(regularBonusMap, enchId, x);
177
178 #define NEWBONUSINTOARTIFACTLIST(x,y) AddToMap(artifactBonusMap, enchId, x, y);
179 #define NEWBONUSINTOARTIFACTLIST2(x,y,z) AddToMap(artifactBonusMap, enchId, x, y, z);
180
181 std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > regularBonusMap;
182 std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > specialBonusMap;
183 std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > artifactBonusMap;
184 //-------------------------------------------------------------------------
185
186 void AddToMap(std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* > &maptoadd,
187 int enchId,
188 CHARACTER_ATTRIBUTE_TYPE attrId,
189 int bonusValue = 0,
190 unsigned __int16 Player::* skillPtr = NULL)
191 {
192 auto key = maptoadd.find(enchId);
193 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currMap;
194 if (key == maptoadd.end())
195 {
196 currMap = new std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>;
197 maptoadd[enchId] = currMap;
198 }
199 else
200 {
201 currMap = key->second;
202 }
203 Assert(currMap->find(attrId) == currMap->end(), "Attribute %d already present for enchantment %d", attrId, enchId);
204 (*currMap)[attrId] = new CEnchantment(bonusValue, skillPtr);
205 }
206 //-------------------------------------------------------------------------
207
208 void PopulateSpecialBonusMap()
209 {
210 int enchId = 1;// of Protection, +10 to all Resistances
211 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 10);
212 NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_AIR, 10);
213 NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_WATER, 10);
214 NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_EARTH, 10);
215 NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_MIND, 10);
216 NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_BODY, 10);
217
218 enchId = 2;//of The Gods, +10 to all Seven Statistics
219 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10);
220 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10);
221 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10);
222 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10);
223 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10);
224 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 10);
225 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 10);
226
227 enchId = 26;//of Air Magic
228 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_AIR,0, &Player::skillAir);
229
230 enchId = 27;//of Body Magic
231 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_BODY,0, &Player::skillBody);
232
233 enchId = 28;//of Dark Magic
234 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK,0, &Player::skillDark);
235
236 enchId = 29;//of Earth Magic
237 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_EARTH,0, &Player::skillEarth);
238
239 enchId = 30;//of Fire Magic
240 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_FIRE,0, &Player::skillFire);
241
242 enchId = 31;//of Light Magic
243 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_LIGHT,0, &Player::skillLight);
244
245 enchId = 32;//of Mind Magic
246 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND,0, &Player::skillMind);
247
248 enchId = 33;//of Spirit Magic
249 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT,0, &Player::skillSpirit);
250
251 enchId = 34;//of Water Magic
252 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_WATER,0, &Player::skillWater);
253
254 enchId = 42;//of Doom
255 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 1);
256 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 1);
257 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 1);
258 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 1);
259 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 1);
260 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 1);
261 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 1);
262 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 1);
263 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 1);
264 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 1);
265 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 1);
266 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 1);
267 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 1);
268 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, 1);
269 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, 1);
270 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, 1);
271
272 enchId = 43;//of Earth
273 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10);
274 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 10);
275 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 10);
276
277 enchId = 44;//of Life
278 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 10);
279
280 enchId = 45;//Rogues
281 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 5);
282 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 5);
283
284 enchId = 46;//of The Dragon
285 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 25);
286
287 enchId = 47;//of The Eclipse
288 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 10);
289
290 enchId = 48;//of The Golem
291 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15);
292 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 5);
293
294 enchId = 49;//of The Moon
295 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10);
296 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 10);
297
298 enchId = 50;//of The Phoenix
299 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 30);
300
301 enchId = 51;//of The Sky
302 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 10);
303 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 10);
304 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10);
305
306 enchId = 52;//of The Stars
307 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10);
308 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10);
309
310 enchId = 53;//of The Sun
311 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10);
312 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10);
313
314 enchId = 54;//of The Troll
315 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15);
316
317 enchId = 55;//of The Unicorn
318 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 15);
319
320 enchId = 56;//Warriors
321 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 5);
322 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 5);
323
324 enchId = 57;//Wizards
325 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 5);
326 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 5);
327
328 enchId = 60;//Monks'
329 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_DODGE, 3, &Player::skillDodge);
330 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 3, &Player::skillUnarmed);
331
332 enchId = 61;//Thieves'
333 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 3, &Player::skillStealing);
334 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_STEALING, 3, &Player::skillDisarmTrap);
335
336 enchId = 62;//of Identifying
337 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 3, &Player::skillItemId);
338 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 3, &Player::skillMonsterId);
339
340 enchId = 67;//Assassins'
341 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 2, &Player::skillDisarmTrap);
342
343 enchId = 68;//Barbarians'
344 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 5);
345
346 enchId = 69;//of the Storm
347 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 20);
348
349 enchId = 70;//of the Ocean
350 NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 10);
351 NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 2, &Player::skillAlchemy);
352 }
353 //-------------------------------------------------------------------------
354
355 void PopulateRegularBonusMap()
356 {
357 int enchId = 1;//of Might
358 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_STRENGTH);
359
360 enchId = 2;//of Thought
361 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE);
362
363 enchId = 3;//of Charm
364 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_WILLPOWER);
365
366 enchId = 4;//of Vigor
367 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_ENDURANCE);
368
369 enchId = 5;//of Precision
370 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_ACCURACY);
371
372 enchId = 6;//of Speed
373 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SPEED);
374
375 enchId = 7;//of Luck
376 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_LUCK);
377
378 enchId = 8;//of Health
379 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_HEALTH);
380
381 enchId = 9;//of Magic
382 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_MANA);
383
384 enchId = 10;//of Defense
385 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_AC_BONUS);
386
387 enchId = 11;//of Fire Resistance
388 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE);
389
390 enchId = 12;//of Air Resistance
391 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_AIR);
392
393 enchId = 13;//of Water Resistance
394 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_WATER);
395
396 enchId = 14;//of Earth Resistance
397 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH);
398
399 enchId = 15;//of Mind Resistance
400 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_MIND);
401
402 enchId = 16;//of Body Resistance
403 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_BODY);
404
405 enchId = 17;//of Alchemy
406 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY);
407
408 enchId = 18;//of Stealing
409 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_STEALING);
410
411 enchId = 19;//of Disarming
412 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM);
413
414 enchId = 20;//of Items
415 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID);
416
417 enchId = 21;//of Monsters
418 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID);
419
420 enchId = 22;//of Arms
421 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER);
422
423 enchId = 23;//of Dodging
424 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_DODGE);
425
426 enchId = 24;//of the Fist
427 NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_UNARMED);
428 }
429
430 //-------------------------------------------------------------------------
431 void PopulateArtifactBonusMap()
432 {
433 int enchId = 1;//of Might
434 NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 5);
435 }
436 //-------------------------------------------------------------------------
437
438 void Player::GetItemBonusSpecialEnchantment(int enchantmentId, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus)
439 {
440 auto bonusList = specialBonusMap.find(enchantmentId);
441 if (bonusList == specialBonusMap.end())
442 {
443 return;
444 }
445 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second;
446 if (currList->find(attrToGet) != currList->end())
447 {
448 CEnchantment* currBonus = (*currList)[attrToGet];
449 if (currBonus->statPtr != NULL)
450 {
451 if (currBonus->statBonus == 0)
452 {
453 *halfSkillBonus = this->*currBonus->statPtr / 2;
454 }
455 else
456 {
457 if (*additiveBonus < currBonus->statBonus)
458 {
459 *additiveBonus = currBonus->statBonus;
460 }
461 }
462 }
463 else
464 {
465 *additiveBonus += currBonus->statBonus;
466 }
467 }
468 }
469
470 //-------------------------------------------------------------------------
471 bool IsRegularEnchanmentForAttribute(int enchantmentId, CHARACTER_ATTRIBUTE_TYPE attrToGet)
472 {
473 auto bonusList = specialBonusMap.find(enchantmentId);
474 if (bonusList == specialBonusMap.end())
475 {
476 return false;
477 }
478 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList = bonusList->second;
479 return (currList->find(attrToGet) != currList->end());
480 }
481 158
482 //----- (00490913) -------------------------------------------------------- 159 //----- (00490913) --------------------------------------------------------
483 int PlayerCreation_GetUnspentAttributePointCount() 160 int PlayerCreation_GetUnspentAttributePointCount()
484 { 161 {
485 signed int v0; // edi@1 162 signed int v0; // edi@1
1459 //----- (004910D3) -------------------------------------------------------- 1136 //----- (004910D3) --------------------------------------------------------
1460 bool Player::CanIdentify( ItemGen *pItem ) 1137 bool Player::CanIdentify( ItemGen *pItem )
1461 { 1138 {
1462 unsigned __int16 v2; // ax@1 1139 unsigned __int16 v2; // ax@1
1463 int v5; // edi@7 1140 int v5; // edi@7
1464 1141 return true;
1465 if (CheckHiredNPCSpeciality(Scholar)) 1142 if (CheckHiredNPCSpeciality(Scholar))
1466 return true; 1143 return true;
1467 1144
1468 v2 = GetActualSkillLevel(PLAYER_SKILL_ITEM_ID); 1145 v2 = GetActualSkillLevel(PLAYER_SKILL_ITEM_ID);
1469 if ( (signed int)SkillToMastery(v2) >= 4 ) 1146 if ( (signed int)SkillToMastery(v2) >= 4 )
1559 } 1236 }
1560 1237
1561 //----- (0048C6AF) -------------------------------------------------------- 1238 //----- (0048C6AF) --------------------------------------------------------
1562 Player::Player() 1239 Player::Player()
1563 { 1240 {
1564 if (specialBonusMap.empty())
1565 {
1566 PopulateSpecialBonusMap();
1567 }
1568
1569 memset(&pEquipment, 0, sizeof(PlayerEquipment)); 1241 memset(&pEquipment, 0, sizeof(PlayerEquipment));
1570 memset(pInventoryMatrix, 0, 126 * sizeof(int)); 1242 memset(pInventoryMatrix, 0, 126 * sizeof(int));
1571 for (uint i = 0; i < 126; ++i) 1243 for (uint i = 0; i < 126; ++i)
1572 pInventoryItemList[i].Reset(); 1244 pInventoryItemList[i].Reset();
1573 for (uint i = 0; i < 12; ++i) 1245 for (uint i = 0; i < 12; ++i)
3448 } 3120 }
3449 3121
3450 //----- (0048EAAE) -------------------------------------------------------- 3122 //----- (0048EAAE) --------------------------------------------------------
3451 int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ ) 3123 int Player::GetItemsBonus( enum CHARACTER_ATTRIBUTE_TYPE attr, bool getOnlyMainHandDmg /*= false*/ )
3452 { 3124 {
3453 // signed int v4; // eax@1
3454 int v5; // edi@1 3125 int v5; // edi@1
3455 Player *v8; // ecx@48
3456 int v9; // eax@49 3126 int v9; // eax@49
3457 int v10; // edx@49
3458 Player *v11; // ecx@55
3459 int v12; // eax@56
3460 int v13; // edx@56
3461 int v14; // ecx@58 3127 int v14; // ecx@58
3462 int v15; // eax@58 3128 int v15; // eax@58
3463 Player *v16; // ecx@61
3464 int v17; // eax@62 3129 int v17; // eax@62
3465 Player *v18; // ecx@66
3466 int v19; // eax@67
3467 int v20; // eax@69 3130 int v20; // eax@69
3468 Player *v21; // ecx@75
3469 int v22; // eax@76 3131 int v22; // eax@76
3470 int v23; // edx@76 3132 int v23; // edx@76
3471 //int v24; // eax@79
3472 int v25; // ecx@80 3133 int v25; // ecx@80
3473 int v26; // edi@80 3134 int v26; // edi@80
3474 Player *v27; // ecx@84
3475 int v28; // eax@85
3476 int v29; // edx@85
3477 Player *v30; // ecx@96
3478 int v31; // ebp@97 3135 int v31; // ebp@97
3479 int v32; // eax@98 3136 int v32; // eax@98
3480 unsigned int v33; // eax@100 3137 unsigned int v33; // eax@100
3481 int v34; // eax@103
3482 char v35; // zf@104
3483 char v36; // zf@107
3484 unsigned __int8 v37; // zf@119
3485 char v38; // sf@119
3486 unsigned __int8 v39; // of@119
3487 char v40; // zf@122
3488 char v41; // zf@145
3489 char v42; // zf@164
3490 char v43; // zf@173
3491 char v44; // zf@189
3492 char v45; // zf@198
3493 char v46; // zf@239
3494 int v47; // eax@268
3495 int v48; // eax@269
3496 int v49; // eax@291
3497 char v50; // zf@295
3498 int v51; // eax@306
3499 int v52; // eax@307
3500 char v53; // zf@312
3501 char v54; // zf@336
3502 char v55; // zf@348
3503 int v56; // eax@365 3138 int v56; // eax@365
3504 int v57; // ebx@368 3139 int v57; // ebx@368
3505 signed int v58; // [sp-4h] [bp-20h]@10 3140 signed int v58; // [sp-4h] [bp-20h]@10
3506 signed int v59; // [sp-4h] [bp-20h]@71
3507 signed int v60; // [sp-4h] [bp-20h]@347
3508 int v61; // [sp+10h] [bp-Ch]@1 3141 int v61; // [sp+10h] [bp-Ch]@1
3509 int v62; // [sp+14h] [bp-8h]@1 3142 int v62; // [sp+14h] [bp-8h]@1
3510 int v63; // [sp+18h] [bp-4h]@101 3143 ItemGen *currEquippedItem; // [sp+20h] [bp+4h]@101
3511 ItemGen *attra; // [sp+20h] [bp+4h]@101
3512 unsigned int v65; // [sp+24h] [bp+8h]@95
3513 bool no_skills; 3144 bool no_skills;
3514 3145
3515 v5 = 0; 3146 v5 = 0;
3516 v62 = 0; 3147 v62 = 0;
3517 v61 = 0; 3148 v61 = 0;
3518
3519 3149
3520 no_skills=false; 3150 no_skills=false;
3521 switch (attr) 3151 switch (attr)
3522 { 3152 {
3523 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: v58 = PLAYER_SKILL_ALCHEMY; break; 3153 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY: v58 = PLAYER_SKILL_ALCHEMY; break;
3548 { 3178 {
3549 if ( !this->pActiveSkills[v58] ) 3179 if ( !this->pActiveSkills[v58] )
3550 return 0; 3180 return 0;
3551 } 3181 }
3552 3182
3553 if ( (signed int)attr > 28 ) 3183 switch(attr) //TODO would be nice to move these into separate functions
3554 { 3184 {
3555 if ( attr == CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS || attr == CHARACTER_ATTRIBUTE_RANGED_ATTACK) 3185 case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS:
3556 { 3186 case CHARACTER_ATTRIBUTE_RANGED_ATTACK:
3557 if ( HasItemEquipped(EQUIP_BOW) ) 3187 if ( HasItemEquipped(EQUIP_BOW) )
3558 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uBow-1].uItemID].uDamageMod; 3188 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uBow-1].uItemID].uDamageMod;
3559 return v5 + v62 + v61; 3189 return v5;
3560 } 3190 break;
3561 if ( attr == CHARACTER_ATTRIBUTE_RANGED_DMG_MIN ) 3191
3562 { 3192 case CHARACTER_ATTRIBUTE_RANGED_DMG_MIN:
3563 if ( !HasItemEquipped(EQUIP_BOW) ) 3193 if ( !HasItemEquipped(EQUIP_BOW) )
3564 return v5 + v62 + v61; 3194 return 0;
3565 v57 = this->pOwnItems[this->pEquipment.uBow-1].uItemID; 3195 v57 = this->pOwnItems[this->pEquipment.uBow-1].uItemID;
3566 v5 = pItemsTable->pItems[v57].uDamageMod; 3196 v5 = pItemsTable->pItems[v57].uDamageMod;
3567 v56 = pItemsTable->pItems[v57].uDamageDice; 3197 v56 = pItemsTable->pItems[v57].uDamageDice;
3568 v5 += v56; 3198 return v5 + v56;
3569 return v5 + v62 + v61; 3199 break;
3570 } 3200
3571 if ( attr == CHARACTER_ATTRIBUTE_RANGED_DMG_MAX ) 3201 case CHARACTER_ATTRIBUTE_RANGED_DMG_MAX:
3572 {
3573 if ( !HasItemEquipped(EQUIP_BOW) ) 3202 if ( !HasItemEquipped(EQUIP_BOW) )
3574 return v5 + v62 + v61; 3203 return 0;
3575 v20 = this->pOwnItems[this->pEquipment.uBow-1].uItemID; 3204 v20 = this->pOwnItems[this->pEquipment.uBow-1].uItemID;
3576 v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll; 3205 v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll;
3577 v56 = pItemsTable->pItems[v20].uDamageMod; 3206 v56 = pItemsTable->pItems[v20].uDamageMod;
3578 v5 += v56; 3207 return v5 + v56;
3579 return v5 + v62 + v61; 3208
3580 } 3209 case CHARACTER_ATTRIBUTE_LEVEL:
3581 if ( (signed int)attr <= 33 || (signed int)attr > 46 ) 3210 if ( !Player::HasEnchantedItemEquipped(25) )
3582 return v5 + v62 + v61; 3211 return 0;
3583 LABEL_95: 3212 return 5;
3584 v65 = 0; 3213 break;
3585 while ( 1 ) 3214
3586 { 3215 case CHARACTER_ATTRIBUTE_MELEE_DMG_MAX:
3587 if ( !HasItemEquipped((ITEM_EQUIP_TYPE)v65) ) 3216 if ( IsUnarmed() )
3588 goto LABEL_361; 3217 {
3589 v31 = this->pEquipment.pIndices[v65] - 1; 3218 return 3;
3590 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS ) 3219 }
3591 { 3220 else
3592 v32 = GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v65); 3221 {
3593 if ( v32 >= 3 && v32 <= 11 ) 3222 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) )
3594 { 3223 {
3595 v33 = this->pInventoryItemList[v31].uItemID; 3224 v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
3596 v5 += pItemsTable->pItems[v33].uDamageDice + pItemsTable->pItems[v33].uDamageMod; 3225 if ( v22 >= 0 && v22 <= 2)
3597 }
3598 }
3599 v63 = (int)((char *)this + 36 * v31);
3600 attra = (ItemGen *)(v63 + 532);
3601 if ( pItemsTable->IsMaterialNonCommon((ItemGen *)(attra)) == 1
3602 && !pItemsTable->IsMaterialSpecial(attra) )
3603 {
3604 v34 = attra->uItemID;
3605 switch ( attra->uItemID )
3606 {
3607 case ITEM_ARTIFACT_PUCK:
3608 if ( attr == 5 )
3609 v5 += 50;
3610 goto LABEL_361;
3611 case ITEM_ARTIFACT_IRON_FEATHER:
3612 if ( attr == 0 )
3613 v5 += 40;
3614 goto LABEL_361;
3615 case ITEM_ARTIFACT_WALLACE:
3616 if ( attr == 21 )
3617 v61 += 10;
3618 if ( attr == 2 )
3619 v5 += 40;
3620 goto LABEL_361;
3621 case ITEM_ARTIFACT_CORSAIR:
3622 if ( attr == 17 )
3623 v61 += 5;
3624 if ( attr == 18 )
3625 v61 += 5;
3626 if ( attr == 6 )
3627 v5 += 40;
3628 goto LABEL_361;
3629 case ITEM_ARTICACT_GOVERNONS_ARMOR:
3630 if (attr <= 6)
3631 v5 += 10;
3632 goto LABEL_361;
3633 case ITEM_ARTIFACT_YORUBA:
3634 if ( attr == 3 )
3635 v5 += 25;
3636 goto LABEL_361;
3637 case ITEM_ARTIFACT_SPLITTER:
3638 if ( attr == 10 )
3639 v5 += 50;
3640 goto LABEL_361;
3641 case ITEM_ARTEFACT_ULLYSES:
3642 if ( attr == 4 )
3643 v5 += 50;
3644 goto LABEL_361;
3645 case ITEM_ARTEFACT_HANDS_OF_THE_MASTER:
3646 if ( attr == 23 )
3647 v61 += 10;
3648 if ( attr == 22 )
3649 v61 += 10;
3650 goto LABEL_361;
3651 case ITEM_ARTIFACT_LEAGUE_BOOTS:
3652 if ( attr == 36 )
3653 {
3654 v34 = this->pActiveSkills[PLAYER_SKILL_WATER];
3655 v62 = (v32 / 2) & 0x1F;
3656 }
3657 if ( attr == 5 )
3658 v5 += 40;
3659 goto LABEL_361;
3660 case ITEM_ARTIFACT_RULERS_RING:
3661 if ( attr == 39 )
3662 {
3663 v34 = this->pActiveSkills[PLAYER_SKILL_MIND];
3664 v62 = (v34 / 2 ) & 0x1F;
3665 }
3666 if ( attr == 42 )
3667 {
3668 v34 = this->pActiveSkills[PLAYER_SKILL_DARK];
3669 v62 = (v34 / 2 ) & 0x1F;
3670 }
3671 goto LABEL_361;
3672 case ITEM_RELIC_MASH:
3673 if ( attr == 0 )
3674 v5 += 150;
3675 if ( attr == 1 )
3676 v5 -= 40;
3677 if ( attr == 2 )
3678 v5 -= 40;
3679 if ( attr == 5 )
3680 v5 -= 40;
3681 goto LABEL_361;
3682 case ITEM_RELIC_ETHRICS_STAFF:
3683 if ( attr == 42 )
3684 {
3685 v34 = this->pActiveSkills[PLAYER_SKILL_DARK];
3686 v62 = (v34 / 2 ) & 0x1F;
3687 }
3688 if ( attr == 43 )
3689 v61 += 15;
3690 goto LABEL_361;
3691 case ITEM_RELIC_HARECS_LEATHER:
3692 if ( attr == 17 )
3693 v61 += 5;
3694 if ( attr == 18 )
3695 v61 += 5;
3696 if ( attr == 6 )
3697 v5 += 50;
3698 if ( attr == 11 || attr == 10 || attr == 12 || attr == 13 || attr == 33 || attr == 14 )
3699 {
3700 v5 -= 10;
3701 goto LABEL_361;
3702 }
3703 if ( attr == 15 )
3704 v5 -= 10;
3705 goto LABEL_361;
3706 case ITEM_RELIC_OLD_NICK:
3707 if ( attr == 18 )
3708 v61 += 5;
3709 goto LABEL_361;
3710 case ITEM_RELIC_AMUCK:
3711 if ( attr == 0)
3712 v5 += 100;
3713 if ( attr == 3 )
3714 v5 += 100;
3715 if ( attr == 9 )
3716 v5 -= 15;
3717 goto LABEL_361;
3718 case ITEM_RELIC_GLORY_SHIELD:
3719 if ( attr == 45 )
3720 v61 += 5;
3721 if ( attr == 15 )
3722 v5 -= 10;
3723 if ( attr == 14 )
3724 v5 -= 10;
3725 goto LABEL_361;
3726 case ITEM_RELIC_KELEBRIM:
3727 if ( attr == 3 )
3728 v5 += 50;
3729 goto LABEL_361;
3730 case ITEM_RELIC_TALEDONS_HELM:
3731 if ( attr == 2 )
3732 v5 += 15;
3733 if ( !attr )
3734 v5 += 15;
3735 if ( attr == 6 )
3736 v5 -= 40;
3737 goto LABEL_361;
3738 case ITEM_RELIC_SCHOLARS_CAP:
3739 if ( attr == 46 )
3740 v61 += 15;
3741 if ( attr == 3 )
3742 v5 -= 50;
3743 goto LABEL_361;
3744 case ITEM_RELIC_PHYNAXIAN_CROWN:
3745 if ( attr == 34 )
3746 {
3747 v34 = this->pActiveSkills[PLAYER_SKILL_FIRE];
3748 v62 = (v34 / 2 ) & 0x1F;
3749 }
3750 if ( attr == 12 )
3751 v5 += 50;
3752 if ( attr == 2 )
3753 v5 += 30;
3754 if ( attr == 9 )
3755 v5 -= 20;
3756 goto LABEL_361;
3757 case ITEM_RILIC_TITANS_BELT:
3758 if ( !attr )
3759 v5 += 75;
3760 if ( attr == 5 )
3761 v5 -= 40;
3762 goto LABEL_361;
3763 case ITEM_RELIC_TWILIGHT:
3764 if ( attr == CHARACTER_ATTRIBUTE_SPEED )
3765 v5 += 50;
3766 if ( attr == CHARACTER_ATTRIBUTE_LUCK )
3767 v5 += 50;
3768 if ( attr == CHARACTER_ATTRIBUTE_RESIST_AIR || attr == CHARACTER_ATTRIBUTE_RESIST_FIRE || attr == CHARACTER_ATTRIBUTE_RESIST_WATER || attr == CHARACTER_ATTRIBUTE_RESIST_EARTH || attr == CHARACTER_ATTRIBUTE_RESIST_SPIRIT || attr == CHARACTER_ATTRIBUTE_RESIST_MIND )
3769 {
3770 v5 -= 15;
3771 goto LABEL_361;
3772 }
3773 if ( attr == 15 )
3774 v5 -= 15;
3775 goto LABEL_361;
3776 case ITEM_RELIC_ANIA_SELVING:
3777 if ( attr == CHARACTER_ATTRIBUTE_ACCURACY )
3778 v5 += 150;
3779 if ( attr == CHARACTER_ATTRIBUTE_SKILL_BOW )
3780 v61 += 5;
3781 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS )
3782 v5 -= 25;
3783 goto LABEL_361;
3784 case ITEM_RELIC_JUSTICE:
3785 if ( attr == 39 )
3786 {
3787 v34 = this->pActiveSkills[PLAYER_SKILL_MIND];
3788 v62 = (v34 / 2 ) & 0x1F;
3789 }
3790 if ( attr == 40 )
3791 {
3792 v34 = this->pActiveSkills[PLAYER_SKILL_BODY];
3793 v62 = (v34 / 2 ) & 0x1F;
3794 }
3795 if ( attr == 5 )
3796 v5 -= 40;
3797 goto LABEL_361;
3798 case ITEM_RELIC_MEKORIGS_HAMMER:
3799 if ( attr == 38 )
3800 {
3801 v34 = this->pActiveSkills[PLAYER_SKILL_SPIRIT];
3802 v62 = ( v34 / 2 ) & 0x1F;
3803 }
3804 if ( attr == 0 )
3805 v5 += 75;
3806 if ( attr == 11 )
3807 v5 -= 50;
3808 goto LABEL_361;
3809 case ITEM_ARTIFACT_HERMES_SANDALS:
3810 if ( attr == 5 )
3811 v5 += 100;
3812 if ( attr == 4 )
3813 v5 += 50;
3814 if ( attr == 11 )
3815 v5 += 50;
3816 goto LABEL_361;
3817 case ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP:
3818 if ( attr == 1 )
3819 v5 -= 20;
3820 if ( attr == 2 )
3821 v5 -= 20;
3822 goto LABEL_361;
3823 case ITEM_ARTIFACT_MINDS_EYE:
3824 if ( attr == 1 )
3825 v5 += 15;
3826 if ( attr == 2 )
3827 v5 += 15;
3828 goto LABEL_361;
3829 case ITEM_ELVEN_CHAINMAIL:
3830 if ( attr == 5 )
3831 v5 += 15;
3832 if ( attr == 4 )
3833 v5 += 15;
3834 goto LABEL_361;
3835 case ITEM_FORGE_GAUNTLETS:
3836 if ( attr == 10 )
3837 v5 += 30;
3838 if ( attr == 0 )
3839 v5 += 15;
3840 if ( attr == 3 )
3841 v5 += 15;
3842 goto LABEL_361;
3843 case ITEM_ARTIFACT_HEROS_BELT:
3844 if ( attr == 21 )
3845 v61 += 5;
3846 if ( attr == 0 )
3847 v5 += 15;
3848 if (attr >= 10 && attr <= 15)
3849 v5 += 10;
3850 goto LABEL_361;
3851 case ITEM_ARTIFACT_LADYS_ESCORT:
3852 if (attr >= 10 && attr <= 15)
3853 v5 += 10;
3854 goto LABEL_361;
3855 default:
3856 goto LABEL_361;
3857 }
3858 goto LABEL_361;
3859 }
3860 if ( this->pOwnItems[v65].uEnchantmentType == attr + 1 )
3861 {
3862 if ( attr >= CHARACTER_ATTRIBUTE_STRENGTH )
3863 {
3864 if ( attr <= CHARACTER_ATTRIBUTE_RESIST_BODY )
3865 { 3226 {
3866 v5 += this->pOwnItems[v65].m_enchantmentStrength; 3227 v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID;
3867 } 3228 v26 = pItemsTable->pItems[v23].uDamageRoll;
3868 else
3869 {
3870 if ( attr <= CHARACTER_ATTRIBUTE_SKILL_UNARMED && v5 < this->pOwnItems[v65].m_enchantmentStrength )
3871 v5 = this->pOwnItems[v65].m_enchantmentStrength;
3872 }
3873 }
3874 }
3875 else
3876 {
3877 v34 = this->pOwnItems[v65].uSpecEnchantmentType;
3878 GetItemBonusSpecialEnchantment(v34, attr, &v5, &v61);
3879 }
3880
3881 LABEL_361:
3882 ++v65;
3883 if ( (signed int)v65 >= 16 )
3884 return v5 + v62 + v61;
3885 }
3886 }
3887 if ( attr == CHARACTER_ATTRIBUTE_MELEE_DMG_MAX )
3888 {
3889 if ( IsUnarmed() != 1 )
3890 {
3891 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) )
3892 {
3893 v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
3894 if ( v22 >= 0 )
3895 {
3896 if ( v22 <= 2 )
3897 {
3898 v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID;
3899 if ( this->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) 3229 if ( this->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 )
3900 { 3230 {
3901 v26 = pItemsTable->pItems[v23].uDamageRoll;
3902 v25 = pItemsTable->pItems[v23].uDamageDice; 3231 v25 = pItemsTable->pItems[v23].uDamageDice;
3903 } 3232 }
3904 else 3233 else
3905 { 3234 {
3906 v25 = pItemsTable->pItems[v23].uDamageRoll; 3235 v25 = pItemsTable->pItems[v23].uDamageDice + 1;
3907 v26 = pItemsTable->pItems[v23].uDamageDice + 1;
3908 } 3236 }
3909 v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26; 3237 v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26;
3910 } 3238 }
3911 } 3239 }
3912 } 3240 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0 && GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2))
3913 3241 {
3914 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) ) 3242 return v5;
3915 {
3916
3917 v28 = this->GetEquippedItemEquipType(EQUIP_OFF_HAND);
3918 if ((v28 < 0) || v28 > 2 )
3919 return v5 + v62 + v61;
3920 } 3243 }
3921 v15 = pItemsTable->pItems[v23].uDamageMod; 3244 else
3922 v14 = pItemsTable->pItems[v23].uDamageDice * pItemsTable->pItems[v23].uDamageRoll; 3245 {
3923 v5 += v15 + v14; 3246 v23 = this->pOwnItems[this->pEquipment.uShield].uItemID;
3924 return v5 + v62 + v61; 3247 v15 = pItemsTable->pItems[v23].uDamageMod;
3925 } 3248 v14 = pItemsTable->pItems[v23].uDamageDice * pItemsTable->pItems[v23].uDamageRoll;
3926 v59 = 3; 3249 return v5 + v15 + v14;
3927 v5 = v59; 3250 }
3928 return v5 + v62 + v61; 3251 }
3929 } 3252 break;
3930 if ( (signed int)attr < 0 ) 3253
3931 return v5 + v62 + v61; 3254 case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS:
3932 if ( (signed int)attr <= CHARACTER_ATTRIBUTE_SKILL_UNARMED ) 3255 case CHARACTER_ATTRIBUTE_ATTACK:
3933 goto LABEL_95; 3256 if ( IsUnarmed() )
3934 if ( attr == CHARACTER_ATTRIBUTE_LEVEL ) 3257 {
3935 { 3258 return 0;
3936 if ( !Player::HasEnchantedItemEquipped(25) ) 3259 }
3937 return v5 + v62 + v61; 3260 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) )
3938 v5 = 5; 3261 {
3939 return v5 + v62 + v61; 3262 v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
3940 } 3263 if ( v17 >= 0 && v17 <= 2)
3941 if ( (signed int)attr <= CHARACTER_ATTRIBUTE_LEVEL ) 3264 {
3942 return v5 + v62 + v61;
3943 if ( (signed int)attr <= CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS )
3944 {
3945 if ( IsUnarmed() == 1 )
3946 {
3947 v5 = 0;
3948 return v5 + v62 + v61;
3949 }
3950 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) )
3951 {
3952 v17 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
3953 if ( v17 >= 0 )
3954 {
3955 if ( v17 <= 2 )
3956 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand-1].uItemID].uDamageMod; 3265 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand-1].uItemID].uDamageMod;
3957 } 3266 }
3958 } 3267 }
3959 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (v19 = this->GetEquippedItemEquipType(EQUIP_OFF_HAND), v19 < 0) || v19 > 2 ) 3268 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 )
3960 return v5 + v62 + v61; 3269 return v5;
3961 v20 = this->pOwnItems[this->pEquipment.uShield - 1].uItemID; 3270 else
3962 v56 = pItemsTable->pItems[v20].uDamageMod; 3271 {
3963 v5 += v56; 3272 v20 = this->pOwnItems[this->pEquipment.uShield - 1].uItemID;
3964 return v5 + v62 + v61; 3273 v56 = pItemsTable->pItems[v20].uDamageMod;
3965 } 3274 return v5 + v56;
3966 if ( attr == CHARACTER_ATTRIBUTE_MELEE_DMG_MIN ) 3275 }
3967 { 3276 break;
3968 if ( IsUnarmed() == 1 ) 3277
3969 { 3278 case CHARACTER_ATTRIBUTE_MELEE_DMG_MIN:
3970 v5 = 1; 3279 if ( IsUnarmed() )
3971 return v5 + v62 + v61; 3280 {
3972 } 3281 return 1;
3973 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) ) 3282 }
3974 { 3283 if ( this->HasItemEquipped(EQUIP_MAIN_HAND) )
3975 v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); 3284 {
3976 if ( v9 >= 0 ) 3285 v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND);
3977 { 3286 if ( v9 >= 0 && v9 <= 2)
3978 if ( v9 <= 2 )
3979 { 3287 {
3980 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageDice + 3288 v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageDice +
3981 pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageMod; 3289 pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageMod;
3982 if ( !this->pEquipment.uShield ) 3290 if ( !this->pEquipment.uShield && pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uSkillType == 4)
3983 { 3291 {
3984 if ( pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uSkillType == 4 ) 3292 ++v5;
3985 ++v5;
3986 } 3293 }
3987 } 3294 }
3988 } 3295 }
3989 } 3296
3990 3297 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (this->GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0) || this->GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2 )
3991 if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND)) 3298 {
3299 return v5;
3300 }
3301 else
3302 {
3303 v14 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageMod;
3304 v15 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageDice;
3305 return v5 + v15 + v14;
3306 }
3307 break;
3308
3309 case CHARACTER_ATTRIBUTE_STRENGTH:
3310 case CHARACTER_ATTRIBUTE_INTELLIGENCE:
3311 case CHARACTER_ATTRIBUTE_WILLPOWER:
3312 case CHARACTER_ATTRIBUTE_ENDURANCE:
3313 case CHARACTER_ATTRIBUTE_ACCURACY:
3314 case CHARACTER_ATTRIBUTE_SPEED:
3315 case CHARACTER_ATTRIBUTE_LUCK:
3316 case CHARACTER_ATTRIBUTE_HEALTH:
3317 case CHARACTER_ATTRIBUTE_MANA:
3318 case CHARACTER_ATTRIBUTE_AC_BONUS:
3319
3320 case CHARACTER_ATTRIBUTE_RESIST_FIRE:
3321 case CHARACTER_ATTRIBUTE_RESIST_AIR:
3322 case CHARACTER_ATTRIBUTE_RESIST_WATER:
3323 case CHARACTER_ATTRIBUTE_RESIST_EARTH:
3324 case CHARACTER_ATTRIBUTE_RESIST_MIND:
3325 case CHARACTER_ATTRIBUTE_RESIST_BODY:
3326 case CHARACTER_ATTRIBUTE_RESIST_SPIRIT:
3327
3328 case CHARACTER_ATTRIBUTE_SKILL_ALCHEMY:
3329 case CHARACTER_ATTRIBUTE_SKILL_STEALING:
3330 case CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM:
3331 case CHARACTER_ATTRIBUTE_SKILL_ITEM_ID:
3332 case CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID:
3333 case CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER:
3334 case CHARACTER_ATTRIBUTE_SKILL_DODGE:
3335 case CHARACTER_ATTRIBUTE_SKILL_UNARMED:
3336
3337 case CHARACTER_ATTRIBUTE_SKILL_FIRE:
3338 case CHARACTER_ATTRIBUTE_SKILL_AIR:
3339 case CHARACTER_ATTRIBUTE_SKILL_WATER:
3340 case CHARACTER_ATTRIBUTE_SKILL_EARTH:
3341 case CHARACTER_ATTRIBUTE_SKILL_SPIRIT:
3342 case CHARACTER_ATTRIBUTE_SKILL_MIND:
3343 case CHARACTER_ATTRIBUTE_SKILL_BODY:
3344 case CHARACTER_ATTRIBUTE_SKILL_LIGHT:
3345 case CHARACTER_ATTRIBUTE_SKILL_DARK:
3346 case CHARACTER_ATTRIBUTE_SKILL_MEDITATION:
3347 case CHARACTER_ATTRIBUTE_SKILL_BOW:
3348 case CHARACTER_ATTRIBUTE_SKILL_SHIELD:
3349 case CHARACTER_ATTRIBUTE_SKILL_LEARNING:
3350 for (int i = 0; i < 16; i++)
3351 {
3352 if ( HasItemEquipped((ITEM_EQUIP_TYPE)i) )
3992 { 3353 {
3993 v12 = this->GetEquippedItemEquipType(EQUIP_OFF_HAND); 3354 v31 = this->pEquipment.pIndices[i] - 1;
3994 if ((v12 < 0) || v12 > 2 ) 3355 currEquippedItem = &this->pInventoryItemList[v31];
3995 return v5 + v62 + v61; 3356 if ( attr == CHARACTER_ATTRIBUTE_AC_BONUS )
3357 {
3358 v32 = GetEquippedItemEquipType((ITEM_EQUIP_TYPE)i);
3359 if ( v32 >= 3 && v32 <= 11 )
3360 {
3361 v33 = currEquippedItem->uItemID;
3362 v5 += pItemsTable->pItems[v33].uDamageDice + pItemsTable->pItems[v33].uDamageMod;
3363 }
3364 }
3365 if ( pItemsTable->IsMaterialNonCommon((ItemGen *)(currEquippedItem))
3366 && !pItemsTable->IsMaterialSpecial(currEquippedItem) )
3367 {
3368 currEquippedItem->GetItemBonusArtifact(this, attr, &v62);
3369 }
3370 else if ( currEquippedItem->uEnchantmentType != 0 )
3371 {
3372 if (currEquippedItem->IsRegularEnchanmentForAttribute(attr))
3373 {
3374 if ( attr > CHARACTER_ATTRIBUTE_RESIST_BODY && v5 < currEquippedItem->m_enchantmentStrength )
3375 v5 = currEquippedItem->m_enchantmentStrength;
3376 else
3377 v5 += currEquippedItem->m_enchantmentStrength;
3378 }
3379 }
3380 else
3381 {
3382 currEquippedItem->GetItemBonusSpecialEnchantment(this, attr, &v5, &v61);
3383 }
3996 } 3384 }
3997 v14 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageMod; 3385 }
3998 v15 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uShield].uItemID].uDamageDice; 3386 return v5 + v62 + v61;
3999 v5 += v15 + v14; 3387 break;
4000 } 3388 default:
4001 return v5 + v62 + v61; 3389 return 0;
3390 }
4002 } 3391 }
4003 3392
4004 //----- (0048F73C) -------------------------------------------------------- 3393 //----- (0048F73C) --------------------------------------------------------
4005 int Player::GetMagicalBonus(enum CHARACTER_ATTRIBUTE_TYPE a2) 3394 int Player::GetMagicalBonus(enum CHARACTER_ATTRIBUTE_TYPE a2)
4006 { 3395 {