Mercurial > mm7
changeset 1562:c44db078127d
Merge
author | Grumpy7 |
---|---|
date | Sun, 08 Sep 2013 01:23:37 +0200 |
parents | f8c15e45de7e (diff) 6292a522d322 (current diff) |
children | 0311debb684c |
files | Indoor.cpp |
diffstat | 8 files changed, 72 insertions(+), 151 deletions(-) [+] |
line wrap: on
line diff
--- a/CastSpellInfo.cpp Sat Sep 07 22:46:18 2013 +0200 +++ b/CastSpellInfo.cpp Sun Sep 08 01:23:37 2013 +0200 @@ -2957,7 +2957,7 @@ { sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) ) + if ( !pParty->AddItemToParty(&pSpriteObjects[v445].stru_24) ) pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24); } SpriteObject::OnInteraction(v445);
--- a/ErrorHandling.h Sat Sep 07 22:46:18 2013 +0200 +++ b/ErrorHandling.h Sun Sep 08 01:23:37 2013 +0200 @@ -1,9 +1,7 @@ #pragma once #define Error(format, ...) Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__) -#define Assert(condition, format, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, format, __VA_ARGS__) -#define Assert(condition) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, nullptr) - +#define Assert(condition, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, __VA_ARGS__) @@ -33,7 +31,7 @@ inline void Assert_impl_(const char *filename, const char *functionname, int line, - bool condition, const char *condition_string, const char *format, ...) + bool condition, const char *condition_string, const char *format = nullptr, ...) { if (condition) return;
--- a/Indoor.cpp Sat Sep 07 22:46:18 2013 +0200 +++ b/Indoor.cpp Sun Sep 08 01:23:37 2013 +0200 @@ -6058,7 +6058,7 @@ _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); if ( v19->uItemID == 455 ) _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); - if ( !pParty->AddItem(v19) ) + if ( !pParty->AddItemToParty(v19) ) pParty->SetHoldingItem(v19); v21 = v26; }
--- a/Items.h Sat Sep 07 22:46:18 2013 +0200 +++ b/Items.h Sun Sep 08 01:23:37 2013 +0200 @@ -6,7 +6,7 @@ DMGT_FIRE = 0, DMGT_ELECTR = 1, DMGT_COLD = 2, - DMGT_3 = 3, + DMGT_EARTH = 3, DMGT_PHISYCAL= 4, DMGT_5 = 5, DMGT_SPIRIT = 6,
--- a/Party.h Sat Sep 07 22:46:18 2013 +0200 +++ b/Party.h Sun Sep 08 01:23:37 2013 +0200 @@ -186,7 +186,7 @@ void SetHoldingItem(ItemGen *pItem); int GetNextActiveCharacter(); bool _497FC5_check_party_perception_against_level(); - bool AddItem(ItemGen *pItem); + bool AddItemToParty(ItemGen *pItem); void Yell(); void CountHirelings();
--- a/Player.cpp Sat Sep 07 22:46:18 2013 +0200 +++ b/Player.cpp Sun Sep 08 01:23:37 2013 +0200 @@ -1095,7 +1095,7 @@ price = this->GetPriceRepair(itemValue, multiplier); break; default: - Assert("(%u)", ShopMenuType); + Error("(%u)", ShopMenuType); break; } if ( merchantLevel ) @@ -1349,93 +1349,57 @@ } //----- (0048C6F6) -------------------------------------------------------- -bool Party::AddItem(ItemGen *pItem) +bool Party::AddItemToParty(ItemGen *pItem) //TODO move to party.cpp { unsigned int v2; // eax@1 - unsigned int v3; // ecx@4 - signed int v4; // edx@4 char *v5; // eax@8 - //unsigned int v6; // eax@10 Texture *v7; // ebx@10 signed int v8; // esi@10 Player *v9; // edi@11 int v10; // eax@11 - bool result; // eax@15 - std::string v12; // [sp-18h] [bp-40h]@9 - - - int v15[4] = {0, 1, 2, 3}; // [sp+Ch] [bp-1Ch]@3 - //int v16; // [sp+10h] [bp-18h]@3 - //int v17; // [sp+14h] [bp-14h]@3 - //int v18; // [sp+18h] [bp-10h]@3 - Player *v19; // [sp+1Ch] [bp-Ch]@9 - Party *v20; // [sp+20h] [bp-8h]@1 int v21; // [sp+24h] [bp-4h]@10 - auto thos = this; - - v20 = thos; v2 = pItem->uItemID; if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) pItem->SetIdentified(); - ///v15 = 0; - //v16 = 1; - //v18 = 3; - //v17 = 2; - if ( uActiveCharacter ) - { - v3 = uActiveCharacter - 1; - v4 = 0; - do - { - v15[v4++] = v3++; - if ( (signed int)v3 >= 4 ) - v3 = 0; - } - while ( v4 < 4 ); - } + v5 = pItemsTable->pItems[v2].pIconName; if ( v5 ) { v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); v21 = areWeLoadingTexture; v8 = 0; - while ( 1 ) - { - v9 = &v20->pPlayers[v15[v8]]; - v19 = &v20->pPlayers[v15[v8]]; - v10 = v19->AddItem(-1, pItem->uItemID); + int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0; + for (int i = 0; i < 4; i++) + { + v9 = &pPlayers[(startId + i) % 4]; //start with current active player, then cycle right if item won't fit + v10 = v9->AddItem(-1, pItem->uItemID); if ( v10 ) - break; - ++v8; - if ( v8 >= 4 ) { + memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); + pItem->Reset(); + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); + v9->PlaySound(SPEECH_60, 0); if ( !v21 ) { v7->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - goto LABEL_15; + return true; } } - memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); - pItem->Reset(); - pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); - v19->PlaySound(SPEECH_60, 0); if ( !v21 ) { v7->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - result = 1; + return false; } else { MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); -LABEL_15: - result = 0; - } - return result; + return false; + } } // 506128: using guessed type int areWeLoadingTexture; @@ -1573,31 +1537,26 @@ //----- (0048CCF5) -------------------------------------------------------- int Player::GetActualAttack(int a2) { - Player *v2; // esi@1 int v3; // eax@1 int v4; // edi@1 int v5; // ebx@1 int v6; // ebp@1 - v2 = this; v3 = GetActualAccuracy(); v4 = GetParameterBonus(v3); v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK); v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2); - return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus; + return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + this->_some_attack_bonus; } //----- (0048CD45) -------------------------------------------------------- int Player::GetMeleeDamageMinimal() { - Player *v1; // edi@1 int v2; // eax@1 int v3; // esi@1 int v4; // esi@1 int v5; // esi@1 - int v6; // esi@1 signed int result; // eax@1 - v2 = GetActualMight(); v3 = GetParameterBonus(v2); @@ -1612,7 +1571,6 @@ //----- (0048CD90) -------------------------------------------------------- int Player::GetMeleeDamageMaximal() { - Player *v1; // edi@1 int v2; // eax@1 int v3; // esi@1 int v4; // esi@1 @@ -1620,12 +1578,11 @@ int v6; // esi@1 signed int result; // eax@1 - v1 = this; v2 = GetActualMight(); v3 = GetParameterBonus(v2); v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3; v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; - v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; + v6 = this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; result = 1; if ( v6 >= 1 ) result = v6; @@ -1731,7 +1688,6 @@ //----- (0048D0B9) -------------------------------------------------------- int Player::GetRangedAttack() { - Player *v1; // esi@1 int v2; // eax@1 int v3; // edi@3 int v4; // eax@4 @@ -1739,7 +1695,6 @@ int v6; // edi@4 int v7; // edi@4 - v1 = this; v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1]; if ( v2 < ITEM_BLASTER || v2 > ITEM_LASER_RIFLE ) { @@ -1747,7 +1702,7 @@ v5 = GetParameterBonus(v4); v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5; v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; - v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; + v3 = this->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; } else { @@ -1759,17 +1714,14 @@ //----- (0048D124) -------------------------------------------------------- int Player::GetRangedDamageMin() { - Player *v1; // esi@1 int v2; // edi@1 int v3; // edi@1 int v4; // edi@1 - unsigned __int16 v5; // ax@1 int result; // eax@6 - v1 = this; v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN, 0); v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; - v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; + v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; if ( v4 >= 1 ) result = v4; else @@ -1780,17 +1732,14 @@ //----- (0048D191) -------------------------------------------------------- int Player::GetRangedDamageMax() { - Player *v1; // esi@1 int v2; // edi@1 int v3; // edi@1 int v4; // edi@1 - unsigned __int16 v5; // ax@1 int result; // eax@6 - v1 = this; v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX, 0); v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; - v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; + v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; if ( v4 >= 1 ) result = v4; else @@ -1801,11 +1750,8 @@ //----- (0048D1FE) -------------------------------------------------------- int Player::CalculateRangedDamageTo( int a2 ) { - bool result; // eax@1 ItemGen *v4; // ebx@2 unsigned int v5; // edi@2 - int v7; // edx@4 - char v8; // zf@4 int v9; // esi@5 int v10; // ebx@6 signed int v15; // [sp+8h] [bp-Ch]@2 @@ -1944,98 +1890,74 @@ //----- (0048D45A) -------------------------------------------------------- bool Player::CanTrainToNextLevel() { - int v1; // edx@1 - int v2; // eax@1 - int i; // esi@1 - - v1 = this->uLevel; - v2 = 0; - for ( i = 0; i < v1; ++i ) - v2 += i + 1; - return (signed __int64)this->uExperience >= 1000 * v2; + int lvl = this->uLevel; + int neededExp = ((lvl * (lvl - 1)) / 2 * 1000); } //----- (0048D498) -------------------------------------------------------- unsigned int Player::GetExperienceDisplayColor() { - unsigned int result; // eax@2 - if ( CanTrainToNextLevel() ) - result = ui_character_bonus_text_color; + return ui_character_bonus_text_color; else - result = ui_character_default_text_color; - return result; + return ui_character_default_text_color; } //----- (0048D4B3) -------------------------------------------------------- -int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int amount ) - { - +int Player::CalculateIncommingDamage( DAMAGE_TYPE dmg_type, int dmg ) +{ int resist_value; // edi@8 int player_luck; // eax@21 signed int res_rand_divider; // ebx@2 int armor_skill; // eax@29 - enum CHARACTER_ATTRIBUTE_TYPE player_resist; // [sp-4h] [bp-10h]@9 - signed int result_amount_dmg; // [sp+8h] [bp-4h]@17 - - player_resist=CHARACTER_ATTRIBUTE_STRENGTH; + + if ( classType == PLAYER_CLASS_LICH && (dmg_type == CHARACTER_ATTRIBUTE_RESIST_MIND || dmg_type == CHARACTER_ATTRIBUTE_RESIST_BODY || dmg_type == CHARACTER_ATTRIBUTE_RESIST_SPIRIT )) //TODO: determine if spirit resistance should be handled by body res. modifier + return 0; + + resist_value = 0; switch(dmg_type) { - case DMGT_FIRE: player_resist=CHARACTER_ATTRIBUTE_RESIST_FIRE; break; - case DMGT_ELECTR: player_resist=CHARACTER_ATTRIBUTE_RESIST_AIR; break; - case DMGT_COLD: player_resist=CHARACTER_ATTRIBUTE_RESIST_WATER; break; - case DMGT_3: player_resist=CHARACTER_ATTRIBUTE_RESIST_EARTH; break; + case DMGT_FIRE: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); break; + case DMGT_ELECTR: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); break; + case DMGT_COLD: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); break; + case DMGT_EARTH: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); break; - case DMGT_SPIRIT: player_resist=CHARACTER_ATTRIBUTE_RESIST_SPIRIT;break; - case DMGT_MIND: player_resist=CHARACTER_ATTRIBUTE_RESIST_MIND; break; - case DMGT_BODY: player_resist=CHARACTER_ATTRIBUTE_RESIST_BODY; break; + case DMGT_SPIRIT: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_SPIRIT);break; + case DMGT_MIND: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); break; + case DMGT_BODY: resist_value = GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); break; } - if (player_resist) - resist_value = GetActualResistance(player_resist); - else - resist_value = 0; - - result_amount_dmg = amount; - if ( classType == PLAYER_CLASS_LICH && resist_value >= 200 ) - return 0; + player_luck = GetActualLuck(); res_rand_divider = GetParameterBonus(player_luck) + resist_value + 30; - if ( resist_value ) + if ( GetParameterBonus(player_luck) + resist_value > 0 ) { - if ( rand() % res_rand_divider >= 30 ) - { - result_amount_dmg = amount >> 1; + for (int i = 0; i < 4; i++) + { if ( rand() % res_rand_divider >= 30 ) - { - result_amount_dmg = amount >> 2; - if ( rand() % res_rand_divider >= 30 ) - { - result_amount_dmg = amount >> 3; - if ( rand() % res_rand_divider >= 30 ) - result_amount_dmg = amount >> 4; - } - } - } - } - if (( dmg_type == DMGT_PHISYCAL )&&( pEquipment.uArmor )) - { - if (!pOwnItems[pEquipment.uArmor-1].Broken()) + dmg >>= 1; + else + break; + } + } + if (( dmg_type == DMGT_PHISYCAL ) && ( pEquipment.uArmor )) + { + if (!pOwnItems[pEquipment.uArmor - 1].Broken()) { armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR); if ( armor_skill==PLAYER_SKILL_PLATE ) { if ( SkillToMastery(pActiveSkills[PLAYER_SKILL_PLATE]) >= 3 ) - return (int)(double)result_amount_dmg * 0.5; + return dmg / 2; } if (armor_skill==PLAYER_SKILL_CHAIN ) { if (SkillToMastery(pActiveSkills[PLAYER_SKILL_CHAIN]) == 4) - return (int)(double)result_amount_dmg * 0.66670001; + return dmg * 2 / 3; } } } - return result_amount_dmg; + return dmg; } //----- (0048D62C) -------------------------------------------------------- @@ -2053,8 +1975,8 @@ //----- (0048D676) -------------------------------------------------------- bool Player::IsUnarmed() { - return HasItemEquipped(EQUIP_MAIN_HAND) != 0 && - !(HasItemEquipped(EQUIP_OFF_HAND) == 0 && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD); + return !HasItemEquipped(EQUIP_MAIN_HAND) && + (!HasItemEquipped(EQUIP_OFF_HAND) || GetEquippedItemEquipType(EQUIP_OFF_HAND) == EQUIP_SHIELD); } //----- (0048D6AA) -------------------------------------------------------- @@ -6863,7 +6785,7 @@ this->sResMagicBonus = (unsigned __int8)var_value; break; default: - Assert("Unexpected var_type: %u", var_type); + Error("Unexpected var_type: %u", var_type); return; break; }
--- a/Viewport.cpp Sat Sep 07 22:46:18 2013 +0200 +++ b/Viewport.cpp Sun Sep 08 01:23:37 2013 +0200 @@ -300,7 +300,7 @@ _449B7E_toggle_bit(pParty->_quest_bits, 184, 1); if ( pSpriteObjects[v21].stru_24.uItemID == 455 ) _449B7E_toggle_bit(pParty->_quest_bits, 185, 1); - if ( !pParty->AddItem(&pSpriteObjects[v21].stru_24) ) + if ( !pParty->AddItemToParty(&pSpriteObjects[v21].stru_24) ) pParty->SetHoldingItem(&pSpriteObjects[v21].stru_24); } SpriteObject::OnInteraction(a2.y);
--- a/mm7_6.cpp Sat Sep 07 22:46:18 2013 +0200 +++ b/mm7_6.cpp Sun Sep 08 01:23:37 2013 +0200 @@ -295,6 +295,7 @@ } } } + pActor->uCarriedItemID = 1; if ( pActor->uCarriedItemID ) { Dst.Reset(); @@ -318,12 +319,12 @@ if ( pItemsTable->pItems[v5].uEquipType == 14 && v4 != 220 ) Dst.uEnchantmentType = 2 * rand() % 4 + 2; pItemsTable->SetSpecialBonus(&Dst); - if ( !pParty->AddItem(&Dst) ) + if ( !pParty->AddItemToParty(&Dst) ) pParty->SetHoldingItem(&Dst); pActor->uCarriedItemID = 0; if ( pActor->array_000234[0].uItemID ) { - if ( !pParty->AddItem(pActor->array_000234) ) + if ( !pParty->AddItemToParty(pActor->array_000234) ) { sub_421B2C_PlaceInInventory_or_DropPickedItem(); pParty->SetHoldingItem(pActor->array_000234); @@ -332,7 +333,7 @@ } if ( pActor->array_000234[1].uItemID ) { - if ( !pParty->AddItem(&pActor->array_000234[1]) ) + if ( !pParty->AddItemToParty(&pActor->array_000234[1]) ) { sub_421B2C_PlaceInInventory_or_DropPickedItem(); pParty->SetHoldingItem(&pActor->array_000234[1]); @@ -354,7 +355,7 @@ else sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v11); ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( !pParty->AddItem(&Dst) ) + if ( !pParty->AddItemToParty(&Dst) ) pParty->SetHoldingItem(&Dst); v13 = 1; } @@ -374,13 +375,13 @@ sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v10); ShowStatusBarString(pTmpBuf2.data(), 2u); v8 = pParty; - if ( !pParty->AddItem(&Dst) ) + if ( !pParty->AddItemToParty(&Dst) ) pParty->SetHoldingItem(&Dst); v13 = 1; LABEL_45: if ( pActor->array_000234[0].uItemID ) { - if ( !v8->AddItem(pActor->array_000234) ) + if ( !v8->AddItemToParty(pActor->array_000234) ) { sub_421B2C_PlaceInInventory_or_DropPickedItem(); v8->SetHoldingItem(pActor->array_000234); @@ -390,7 +391,7 @@ } if ( pActor->array_000234[1].uItemID ) { - if ( !v8->AddItem(&pActor->array_000234[1]) ) + if ( !v8->AddItemToParty(&pActor->array_000234[1]) ) { sub_421B2C_PlaceInInventory_or_DropPickedItem(); v8->SetHoldingItem(&pActor->array_000234[1]);