Mercurial > mm7
changeset 1620:61ea994a1812
sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped to Player::HasUnderwaterSuitEquipped, sub_43EDB9_get_some_race_sex_relation_2 to ShouldLoadTexturesForRaceAndGender, Player_has_item to Player::HasItem
author | Grumpy7 |
---|---|
date | Sun, 15 Sep 2013 02:20:06 +0200 |
parents | eceabd56f399 |
children | 25d3f9e43634 |
files | Outdoor.cpp Player.cpp Player.h UI/UICharacter.cpp mm7_4.cpp mm7_data.h |
diffstat | 6 files changed, 91 insertions(+), 165 deletions(-) [+] |
line wrap: on
line diff
--- a/Outdoor.cpp Sat Sep 14 19:09:44 2013 +0200 +++ b/Outdoor.cpp Sun Sep 15 02:20:06 2013 +0200 @@ -447,7 +447,10 @@ { if ( v9 == 4 ) // to & from Shoals { - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(0) ) + if ( pPlayers[1]->HasUnderwaterSuitEquipped() && + pPlayers[2]->HasUnderwaterSuitEquipped() && + pPlayers[3]->HasUnderwaterSuitEquipped() && + pPlayers[4]->HasUnderwaterSuitEquipped()) { uDefaultTravelTime_ByFoot = 1; strcpy(pOut, "out15.odm");
--- a/Player.cpp Sat Sep 14 19:09:44 2013 +0200 +++ b/Player.cpp Sun Sep 15 02:20:06 2013 +0200 @@ -7368,98 +7368,49 @@ //----- (0049387A) -------------------------------------------------------- int CycleCharacter(bool backwards) { - signed int result; // eax@1 - signed int v2; // ecx@2 - signed int v3; // ecx@8 - - result = uActiveCharacter; - if ( backwards ) - { - v2 = 0; - while ( 1 ) - { - --result; - if ( result < 1 ) - result = 4; - if ( !pPlayers[result]->uTimeToRecovery ) - break; - ++v2; - if ( v2 >= 4 ) - return uActiveCharacter; - } - } - else - { - v3 = 0; - while ( 1 ) - { - ++result; - if ( result > 4 ) - result = 1; - if ( !pPlayers[result]->uTimeToRecovery ) - break; - ++v3; - if ( v3 >= 4 ) - return uActiveCharacter; - } - } - return result; -} + const int PARTYSIZE = 4; + int valToAdd = backwards ? (PARTYSIZE - 2) : 0; + int mult = backwards ? -1 : 1; + + for (int i = 0; i < (PARTYSIZE - 1); i++) + { + int currCharId = ((uActiveCharacter + mult * i + valToAdd) % PARTYSIZE) + 1; + if ( pPlayers[currCharId]->uTimeToRecovery == 0 ) + { + return currCharId; + } + } + return uActiveCharacter; +} + //----- (0043EE77) -------------------------------------------------------- -bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1) -{ - bool result; // eax@0 - Player *v2; // edx@3 - int v3; // ecx@3 - Player **pPlayers; // esi@8 - //bool item_flag; - Player *v6; // edx@9 - - //if ( a1 < 1 || a1 > 4 ) - //{ - //if ( !a1 ) - //{ - //pPlayers = &::pPlayers[1]; - //v5 = 604; - //while ( 1 ) - Assert ( a1 > 0 && a1 < 5 ); - for ( uint i = 1; i < 5; ++i ) - { - //item_flag = Player_has_item(604, *pPlayers, 0); - if ( !Player_has_item(604, ::pPlayers[i], 0) ) - return false; - //__debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used - //result = ::pPlayers[i]->pEquipment.uArmor; - if ( !::pPlayers[i]->pEquipment.uArmor ) - return false; - //result *= 9; - if (::pPlayers[i]->pEquippedItems[::pPlayers[i]->pEquipment.uArmor].uItemID != 604 ) - return false; - //++pPlayers; - //if ( (signed int)pPlayers >= (signed int)&qword_A750D8 ) - //return true; - } - return true; - } +bool Player::HasUnderwaterSuitEquipped() //the original function took the player number as a parameter. if it was 0, the whole party was checked. calls with the parameter 0 have been changed to calls to this for every player +{ + if (this->pEquipment.uArmor == 0 || this->pInventoryItemList[this->pEquipment.uArmor].uItemID != 604) + { + return false; + } + return true; +} //----- (0043EE15) -------------------------------------------------------- -bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3) +bool Player::HasItem( unsigned int uItemID, char a3 ) { if ( !a3 || pParty->pPickedItem.uItemID != uItemID ) { for ( uint i = 0; i < 126; ++i ) { - if ( pPlayer->pInventoryMatrix[i] > 0 ) + if ( this->pInventoryMatrix[i] > 0 ) { - if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pInventoryMatrix[i] - 1].uItemID == uItemID ) + if ( (unsigned int)this->pInventoryItemList[this->pInventoryMatrix[i] - 1].uItemID == uItemID ) return true; } } for ( uint i = 0; i < 16; ++i ) { - if ( pPlayer->pEquipment.pIndices[i] ) + if ( this->pEquipment.pIndices[i] ) { - if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) + if ( (unsigned int)this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == uItemID ) return true; } } @@ -7467,64 +7418,36 @@ return false; } //----- (0043EDB9) -------------------------------------------------------- -bool sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1) -{ - unsigned int pNum; // ebp@1 - Player **pPlayer; // ebx@1 - Player *pPlayer2; // esi@2 - enum CHARACTER_RACE pRace; // edi@2 - bool pSex; // eax@2 - char v6; // zf@7 - -//pPlayer = &pPlayers[1]; - /*pNum = a1; - - while ( 1 ) - { - pPlayer2 = *pPlayer; - pRace = pPlayer2->GetRace(); - pSex = pPlayer2->GetSexByVoice(); - if ( !pRace ) - break; - if ( pRace == 1 || pRace == 2 ) - break; - if ( !pSex && pNum == 2 )// - //goto LABEL_15; - { - pSex = 1; - return pSex; - } - v6 = pNum == 3;// -LABEL_11: - if ( v6 ) - //goto LABEL_15; - { - pSex = 1; - return pSex; - } - ++pPlayer; - if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )// - { - pSex = 0; - return pSex; - } - } - if ( pSex || pNum ) - { - v6 = pNum == 1; - goto LABEL_11; - } -//LABEL_15: - pSex = 1; - return pSex;*/ - for (uint i = 1; i <= 4; ++i) - { - pRace = pPlayers[i]->GetRace(); - pSex = pPlayers[i]->GetSexByVoice(); - if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 ) - return 1; - } - return 0; +bool ShouldLoadTexturesForRaceAndGender(unsigned int _this) +{ + CHARACTER_RACE race; // edi@2 + PLAYER_SEX sex; // eax@2 + + for (int i = 1; i <= 4; i++) + { + race = pPlayers[i]->GetRace(); + sex = pPlayers[i]->GetSexByVoice(); + switch(_this) + { + case 0: + if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_MALE ) + return true; + break; + case 1: + if (( race == CHARACTER_RACE_HUMAN || race == CHARACTER_RACE_ELF || race == CHARACTER_RACE_GOBLIN ) && sex == SEX_FEMALE ) + return true; + break; + case 2: + if ( race == CHARACTER_RACE_DWARF && sex == SEX_MALE ) + return true; + break; + case 3: + if ( race == CHARACTER_RACE_DWARF && sex == SEX_FEMALE ) + return true; + break; + } + } + return false; } //----- (0043ED6F) -------------------------------------------------------- bool _43ED6F_check_party_races(bool a1)
--- a/Player.h Sat Sep 14 19:09:44 2013 +0200 +++ b/Player.h Sun Sep 15 02:20:06 2013 +0200 @@ -595,6 +595,8 @@ void PlaySoundBasedOnCondition(int currPlayerId); void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId); void EquipBody(ITEM_EQUIP_TYPE uEquipType); + bool HasUnderwaterSuitEquipped(); + bool HasItem(unsigned int uItemID, char a3); unsigned int GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4); int CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice);
--- a/UI/UICharacter.cpp Sat Sep 14 19:09:44 2013 +0200 +++ b/UI/UICharacter.cpp Sun Sep 15 02:20:06 2013 +0200 @@ -1698,7 +1698,7 @@ uTextureID_detaliz_close_button = uExitCancelTextureId; for ( uint i = 0; i < 4; ++i ) { - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(i + 1) ) + if ( pPlayers[i + 1]->HasUnderwaterSuitEquipped() ) { if ( pPlayers[i + 1]->GetRace() == CHARACTER_RACE_DWARF ) v3 = (pPlayers[i + 1]->GetSexByVoice() != 0) + 3; @@ -1757,7 +1757,7 @@ { for ( uint j = 0; j < 4; ++j) { - if ( Player_has_item(i + 66, &pParty->pPlayers[j], 0) ) + if ( pParty->pPlayers[j].HasItem(i + 66, 0) ) party_has_equipment[i] = 1; } } @@ -1767,23 +1767,23 @@ { auto player = pParty->pPlayers + i; - if (Player_has_item(ITEM_ARTICACT_GOVERNONS_ARMOR, player, 1)) byte_5111F6[0] = 1; - if (Player_has_item(ITEM_ARTIFACT_YORUBA, player, 1)) byte_5111F6[1] = 1; - if (Player_has_item(ITEM_RELIC_HARECS_LEATHER, player, 1)) byte_5111F6[2] = 1; - if (Player_has_item(ITEM_ARTIFACT_LEAGUE_BOOTS, player, 1)) byte_5111F6[3] = 1; - if (Player_has_item(ITEM_RELIC_TALEDONS_HELM, player, 1)) byte_5111F6[4] = 1; - if (Player_has_item(ITEM_RELIC_SCHOLARS_CAP, player, 1)) byte_5111F6[5] = 1; - if (Player_has_item(ITEM_RELIC_PHYNAXIAN_CROWN, player, 1)) byte_5111F6[6] = 1; - if (Player_has_item(ITEM_ARTIFACT_MINDS_EYE, player, 1)) byte_5111F6[7] = 1; - if (Player_has_item(ITEM_RARE_SHADOWS_MASK, player, 1)) byte_5111F6[8] = 1; - if (Player_has_item(ITEM_RILIC_TITANS_BELT, player, 1)) byte_5111F6[9] = 1; - if (Player_has_item(ITEM_ARTIFACT_HEROS_BELT, player, 1)) byte_5111F6[10] = 1; - if (Player_has_item(ITEM_RELIC_TWILIGHT, player, 1)) byte_5111F6[11] = 1; - if (Player_has_item(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, player, 1)) byte_5111F6[12] = 1; - if (Player_has_item(ITEM_RARE_SUN_CLOAK, player, 1)) byte_5111F6[13] = 1; - if (Player_has_item(ITEM_RARE_MOON_CLOAK, player, 1)) byte_5111F6[14] = 1; - if (Player_has_item(ITEM_RARE_VAMPIRES_CAPE, player, 1)) byte_5111F6[15] = 1; - if (Player_has_item(ITEM_ELVEN_CHAINMAIL, player, 1)) byte_5111F6[16] = 1; + if (player->HasItem(ITEM_ARTICACT_GOVERNONS_ARMOR, 1)) byte_5111F6[0] = 1; + if (player->HasItem(ITEM_ARTIFACT_YORUBA, 1)) byte_5111F6[1] = 1; + if (player->HasItem(ITEM_RELIC_HARECS_LEATHER, 1)) byte_5111F6[2] = 1; + if (player->HasItem(ITEM_ARTIFACT_LEAGUE_BOOTS, 1)) byte_5111F6[3] = 1; + if (player->HasItem(ITEM_RELIC_TALEDONS_HELM, 1)) byte_5111F6[4] = 1; + if (player->HasItem(ITEM_RELIC_SCHOLARS_CAP, 1)) byte_5111F6[5] = 1; + if (player->HasItem(ITEM_RELIC_PHYNAXIAN_CROWN, 1)) byte_5111F6[6] = 1; + if (player->HasItem(ITEM_ARTIFACT_MINDS_EYE, 1)) byte_5111F6[7] = 1; + if (player->HasItem(ITEM_RARE_SHADOWS_MASK, 1)) byte_5111F6[8] = 1; + if (player->HasItem(ITEM_RILIC_TITANS_BELT, 1)) byte_5111F6[9] = 1; + if (player->HasItem(ITEM_ARTIFACT_HEROS_BELT, 1)) byte_5111F6[10] = 1; + if (player->HasItem(ITEM_RELIC_TWILIGHT, 1)) byte_5111F6[11] = 1; + if (player->HasItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, 1)) byte_5111F6[12] = 1; + if (player->HasItem(ITEM_RARE_SUN_CLOAK, 1)) byte_5111F6[13] = 1; + if (player->HasItem(ITEM_RARE_MOON_CLOAK, 1)) byte_5111F6[14] = 1; + if (player->HasItem(ITEM_RARE_VAMPIRES_CAPE, 1)) byte_5111F6[15] = 1; + if (player->HasItem(ITEM_ELVEN_CHAINMAIL, 1)) byte_5111F6[16] = 1; } for (uint i = 0; i < 2; ++i) @@ -1816,7 +1816,7 @@ //v43 = 0; for (uint i = 0; i < 4; ++i) { - if ( sub_43EDB9_get_some_race_sex_relation_2(i) ) + if ( ShouldLoadTexturesForRaceAndGender(i) ) { GetItemTextureFilename(pContainer, 524, i + 1, 0); paperdoll_belt_texture[i][5] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Titans belt @@ -2404,7 +2404,7 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (pEquipType != EQUIP_ARMOUR || bUnderwater) ) + if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() && (pEquipType != EQUIP_ARMOUR || bUnderwater) ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; @@ -2415,7 +2415,7 @@ return; //------------------------dress rings(одевание колец)---------------------------------- case EQUIP_RING: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; @@ -2452,7 +2452,7 @@ return; //------------------dress shield(одеть щит)------------------------------------------------------ case EQUIP_SHIELD://Щит - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )//в акваланге + if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() )//в акваланге { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; @@ -2503,7 +2503,7 @@ //-------------------------taken in hand(взять в руку)------------------------------------------- case EQUIP_OFF_HAND: case EQUIP_WAND: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) + if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() && pParty->pPickedItem.uItemID != 64 && pParty->pPickedItem.uItemID != 65 ) { @@ -2607,7 +2607,7 @@ break; //---------------------------take two hands(взять двумя руками)--------------------------------- case EQUIP_MAIN_HAND: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + if ( pPlayers[uActiveCharacter]->HasUnderwaterSuitEquipped() ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return;
--- a/mm7_4.cpp Sat Sep 14 19:09:44 2013 +0200 +++ b/mm7_4.cpp Sun Sep 15 02:20:06 2013 +0200 @@ -1079,7 +1079,7 @@ else { //v58 = 0; - if ( !sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v12) ) + if ( !pPlayers[v12]->HasUnderwaterSuitEquipped() ) { //v14 = pPlayers[v12]; //v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1;
--- a/mm7_data.h Sat Sep 14 19:09:44 2013 +0200 +++ b/mm7_data.h Sun Sep 15 02:20:06 2013 +0200 @@ -1143,9 +1143,7 @@ void CharacterUI_LoadPaperdollTextures(); int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder); bool _43ED6F_check_party_races(bool b); -bool sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this); -bool __fastcall Player_has_item(unsigned int uItemID, struct Player *pPlayer, char a3); -bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1); +bool ShouldLoadTexturesForRaceAndGender(unsigned int _this); void WetsuitOn(unsigned int uPlayerID); // idb void WetsuitOff(unsigned int uPlayerID); void __fastcall PrepareDrawLists_BLV(struct IndoorLocation_drawstru *_this);