# HG changeset patch # User Ritor1 # Date 1379250761 -21600 # Node ID a6642179aa33a12a38b0c8745128faf7d07cb042 # Parent 01c04ff9b7a52e25dd83427fba208605a8775e4a# Parent 25d3f9e43634c52ee5bd24b93157ce670225b131 Merge diff -r 01c04ff9b7a5 -r a6642179aa33 Math.h --- a/Math.h Sun Sep 15 19:12:34 2013 +0600 +++ b/Math.h Sun Sep 15 19:12:41 2013 +0600 @@ -25,6 +25,7 @@ #pragma pack(pop) __int64 fixpoint_sub0(int, int); +__int64 fixpoint_sub2(int, int); __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2); __int64 fixpoint_div(int, int); __int64 fixpoint_mul(int, int); diff -r 01c04ff9b7a5 -r a6642179aa33 Outdoor.cpp --- a/Outdoor.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/Outdoor.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -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"); diff -r 01c04ff9b7a5 -r a6642179aa33 Player.cpp --- a/Player.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/Player.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -3468,7 +3468,7 @@ //----- (0048F882) -------------------------------------------------------- int Player::GetActualSkillLevel( PLAYER_SKILL_TYPE uSkillType ) - { +{ signed int bonus_value; // esi@1 unsigned __int16 skill_value; // ax@126 int result; // al@127 @@ -3941,40 +3941,31 @@ // 24 zombie female enum CHARACTER_RACE Player::GetRace() { - if ( uCurrentFace > 15 ) - { - if ( uCurrentFace >= 16 && uCurrentFace <= 19 ) - return CHARACTER_RACE_GOBLIN; + if ( uCurrentFace <= 7 ) + { + return CHARACTER_RACE_HUMAN; + } + else if ( uCurrentFace <= 11 ) + { + return CHARACTER_RACE_ELF; + } + else if ( uCurrentFace <= 15 ) + { + return CHARACTER_RACE_DWARF; + } + else if ( uCurrentFace <= 19 ) + { + return CHARACTER_RACE_GOBLIN; } else { - if ( uCurrentFace >= 12 ) - { - return CHARACTER_RACE_DWARF; - } - else - { - - if ( uCurrentFace <= 7 ) - { - return CHARACTER_RACE_HUMAN; - } - else - { - if ( uCurrentFace <= 11 ) - return CHARACTER_RACE_ELF; - } - } - } - return CHARACTER_RACE_HUMAN; + return CHARACTER_RACE_HUMAN; + } } //----- (00490141) -------------------------------------------------------- PLAYER_SEX Player::GetSexByVoice() { - signed int result; // eax@1 - - result = 0; switch ( this->uVoiceID ) { case 0u: @@ -4024,7 +4015,7 @@ //----- (004901FC) -------------------------------------------------------- void Player::SetSexByVoice() - { +{ switch ( this->uVoiceID) { case 0: @@ -4056,6 +4047,7 @@ this->uSex = SEX_FEMALE; break; default: + Error("(%u)", this->uVoiceID); break; } @@ -4264,18 +4256,16 @@ //unsigned __int16 PartyCreation_BtnMinusClick(Player *_this, int eAttribute) void Player::DecreaseAttribute(int eAttribute) { - int v2; // eax@1 int pBaseValue; // ecx@1 int pDroppedStep; // ebx@1 int pStep; // esi@1 - unsigned __int16 result; // ax@7 int uMinValue; // [sp+Ch] [bp-4h]@1 - v2 = eAttribute + 7 * GetRace(); - pBaseValue = StatTable[0][v2].uBaseValue; - pDroppedStep = StatTable[0][v2].uDroppedStep; + int raceId = GetRace(); + pBaseValue = StatTable[raceId][eAttribute].uBaseValue; + pDroppedStep = StatTable[raceId][eAttribute].uDroppedStep; uMinValue = pBaseValue - 2; - pStep = StatTable[0][v2].uBaseStep; + pStep = StatTable[raceId][eAttribute].uBaseStep; unsigned short* AttrToChange = nullptr; switch ( eAttribute ) { @@ -4440,680 +4430,670 @@ //----- (004680ED) -------------------------------------------------------- void Player::UseItem_DrinkPotion_etc(signed int player_num, int a3) - { - Player *v3; // esi@1 - signed int v5; // eax@17 - int v8; // edx@39 - char *v13; // eax@45 - signed int v15; // edi@68 - int v16; // edx@73 - unsigned __int16 v17; // edi@73 - unsigned int v18; // eax@73 - const char *v22; // eax@84 - int scroll_id; // esi@96 - int v25; // eax@109 - int v26; // eax@113 - int new_mana_val; // edi@114 - signed __int64 v28; // qax@120 - __int64 v30; // edi@137 - __int64 v32; // ST3C_4@137 - __int64 v34; // ST34_4@137 - unsigned __int16 v50; // [sp-Ch] [bp-38h]@120 - const char *v66; // [sp-4h] [bp-30h]@69 - signed int v67; // [sp-4h] [bp-30h]@77 - const char *v68; // [sp-4h] [bp-30h]@89 - char v72; // [sp+20h] [bp-Ch]@68 - signed int v73; // [sp+24h] [bp-8h]@1 - char* v74; // [sp+24h] [bp-8h]@23 - Player *thisb; // [sp+28h] [bp-4h]@1 - unsigned int thisa; // [sp+28h] [bp-4h]@22 - - thisb = this; - v3 = &pParty->pPlayers[player_num-1]; - v73 = 1; - if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) ) - return; - if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_REAGENT ) - { - if ( pParty->pPickedItem.uItemID == 160 ) - { - pParty->pPlayers[player_num-1].SetCondition(Condition_Poison1, 1); - } - else if ( pParty->pPickedItem.uItemID == 161 ) - { - new_mana_val = v3->sMana; - new_mana_val += 2; - if ( new_mana_val > v3->GetMaxMana() ) - new_mana_val = v3->GetMaxMana(); - v3->PlaySound(SPEECH_36, 0); - } - else if ( pParty->pPickedItem.uItemID == 162 ) - { - pParty->pPlayers[player_num-1].Heal(2); - v3->PlaySound(SPEECH_36, 0); - - } - else - { - v68 = pParty->pPickedItem.GetDisplayName(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" - ShowStatusBarString(pTmpBuf.data(), 2); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - return; - } - pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0); - - if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - } - if ( v73 ) - { - if ( pParty->bTurnBasedModeOn ) - { - pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; - thisb->SetRecoveryTime(100); - pTurnEngine->ApplyPlayerAction(); - } - else - { - thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); - } - } - pMouse->RemoveHoldingItem(); - return; - - - } - if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_POTION ) - { - switch ( pParty->pPickedItem.uItemID ) - { - case 221: //Catalyst - pParty->pPlayers[player_num-1].SetCondition(Condition_Poison1, 1); - break; - case 222: //Cure Wounds - v25 = pParty->pPickedItem.uEnchantmentType + 10; - pParty->pPlayers[player_num-1].Heal(v25); - v3->PlaySound(SPEECH_36, 0); - break; - case 223: //Magic Potion - v26 = pParty->pPickedItem.uEnchantmentType + 10; - new_mana_val = v3->sMana; - new_mana_val += v26; - if ( new_mana_val > v3->GetMaxMana() ) - new_mana_val = v3->GetMaxMana(); - v3->PlaySound(SPEECH_36, 0); - break; - case 224: //Cure Weakness - v3->pConditions[Condition_Weak] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 225: //Cure Disease - v3->pConditions[Condition_Disease3] = 0i64; - v3->pConditions[Condition_Disease2] = 0i64; - v3->pConditions[Condition_Disease1] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 226: //Cure Poison - v3->pConditions[Condition_Poison3] = 0i64; - v3->pConditions[Condition_Poison2] = 0i64; - v3->pConditions[Condition_Poison1] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 227: //Awaken - v3->pConditions[Condition_Sleep] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 228: //Haste - if ( !v3->pConditions[Condition_Weak] ) - { +{ + Player *playerAffected; // esi@1 + signed int v5; // eax@17 + int v8; // edx@39 + char *v13; // eax@45 + signed int v15; // edi@68 + int v16; // edx@73 + unsigned __int16 v17; // edi@73 + unsigned int v18; // eax@73 + const char *v22; // eax@84 + int scroll_id; // esi@96 + int v25; // eax@109 + int v26; // eax@113 + int new_mana_val; // edi@114 + signed __int64 v28; // qax@120 + __int64 v30; // edi@137 + __int64 v32; // ST3C_4@137 + __int64 v34; // ST34_4@137 + unsigned __int16 v50; // [sp-Ch] [bp-38h]@120 + const char *v66; // [sp-4h] [bp-30h]@69 + signed int v67; // [sp-4h] [bp-30h]@77 + const char *v68; // [sp-4h] [bp-30h]@89 + char v72; // [sp+20h] [bp-Ch]@68 + signed int v73; // [sp+24h] [bp-8h]@1 + char* v74; // [sp+24h] [bp-8h]@23 + Player *thisb; // [sp+28h] [bp-4h]@1 + unsigned int thisa; // [sp+28h] [bp-4h]@22 + + thisb = this; + playerAffected = &pParty->pPlayers[player_num-1]; + v73 = 1; + if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) ) + return; + if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_REAGENT ) + { + if ( pParty->pPickedItem.uItemID == 160 ) + { + playerAffected->SetCondition(Condition_Poison1, 1); + } + else if ( pParty->pPickedItem.uItemID == 161 ) + { + new_mana_val = playerAffected->sMana; + new_mana_val += 2; + if ( new_mana_val > playerAffected->GetMaxMana() ) + new_mana_val = playerAffected->GetMaxMana(); + playerAffected->PlaySound(SPEECH_36, 0); + } + else if ( pParty->pPickedItem.uItemID == 162 ) + { + playerAffected->Heal(2); + playerAffected->PlaySound(SPEECH_36, 0); + } + else + { + v68 = pParty->pPickedItem.GetDisplayName(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" + ShowStatusBarString(pTmpBuf.data(), 2); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + return; + } + pAudioPlayer->PlaySound((SoundID)211, 0, 0, -1, 0, 0, 0, 0); + + if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + if ( v73 ) + { + if ( pParty->bTurnBasedModeOn ) + { + pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; + thisb->SetRecoveryTime(100); + pTurnEngine->ApplyPlayerAction(); + } + else + { + thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); + } + } + pMouse->RemoveHoldingItem(); + return; + } + + if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_POTION ) + { + switch ( pParty->pPickedItem.uItemID ) + { + case 221: //Catalyst + playerAffected->SetCondition(Condition_Poison1, 1); + break; + case 222: //Cure Wounds + v25 = pParty->pPickedItem.uEnchantmentType + 10; + playerAffected->Heal(v25); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 223: //Magic Potion + v26 = pParty->pPickedItem.uEnchantmentType + 10; + new_mana_val = playerAffected->sMana; + new_mana_val += v26; + if ( new_mana_val > playerAffected->GetMaxMana() ) + new_mana_val = playerAffected->GetMaxMana(); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 224: //Cure Weakness + playerAffected->pConditions[Condition_Weak] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 225: //Cure Disease + playerAffected->pConditions[Condition_Disease3] = 0i64; + playerAffected->pConditions[Condition_Disease2] = 0i64; + playerAffected->pConditions[Condition_Disease1] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 226: //Cure Poison + playerAffected->pConditions[Condition_Poison3] = 0i64; + playerAffected->pConditions[Condition_Poison2] = 0i64; + playerAffected->pConditions[Condition_Poison1] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 227: //Awaken + playerAffected->pConditions[Condition_Sleep] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 228: //Haste + if ( !playerAffected->pConditions[Condition_Weak] ) + { v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[7].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); - v3->PlaySound(SPEECH_36, 0); - } - break; - case 229: //Heroism - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[8].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 230: //Bless - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 231: //Preservation - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 232: //Shield - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[13].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 234: //Stoneskin - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[14].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 235: //Water Breathing - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335), - v3->pPlayerBuffs[23].Apply(pParty->uTimePlayed +v28, 3, 5, 0, 0); - break; - case 237: //Remove Fear - v3->pConditions[Condition_Fear] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 238: //Remove Curse - v3->pConditions[Condition_Cursed] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 239: //Cure Insanity - v3->pConditions[Condition_Insane] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 240: //Might Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[19].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 241: //Intellect Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[17].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 242: //Personality Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[20].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 243://Endurance Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[16].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 244: //Speed Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[21].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 245: //Accuracy Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[15].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 251: //Cure Paralysis - v3->pConditions[Condition_Paralyzed] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 252://Divine Restoration - v30 = v3->pConditions[Condition_Dead]; - v32 = v3->pConditions[Condition_Pertified]; - v34 = v3->pConditions[Condition_Eradicated]; - memset(&pParty->pPlayers[player_num-1].pConditions,0,sizeof(pConditions)); - v3->pConditions[Condition_Dead] = v30; - v3->pConditions[Condition_Pertified] = v32; - v3->pConditions[Condition_Eradicated] = v34; - v3->PlaySound(SPEECH_36, 0); - break; - case 253: //Divine Cure - v25 = 5 * pParty->pPickedItem.uEnchantmentType; - pParty->pPlayers[player_num-1].Heal(v25); - v3->PlaySound(SPEECH_36, 0); - break; - case 254: //Divine Power - v26 = 5 * pParty->pPickedItem.uEnchantmentType; - new_mana_val = v3->sMana; - new_mana_val += v26; - if ( new_mana_val > v3->GetMaxMana() ) - new_mana_val = v3->GetMaxMana(); - v3->PlaySound(SPEECH_36, 0); - break; - case 255: //Luck Boost - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[18].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 256: //Fire Resistance - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[5].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 257: //Air Resistance - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[0].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 258: //Water Resistance - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[22].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 259: //Earth Resistance - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[3].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 260: //Mind Resistance - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[9].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 261: //Body Resistance - v50 = 3 * pParty->pPickedItem.uEnchantmentType; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); - v3->pPlayerBuffs[2].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); - v3->PlaySound(SPEECH_36, 0); - break; - case 262: //Stone to Flesh - v3->pConditions[Condition_Pertified] = 0i64; - v3->PlaySound(SPEECH_36, 0); - break; - case 264: //Pure Luck - if ( !v3->pure_luck_used ) - { - v3->uLuck += 50; - v3->pure_luck_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 265: //Pure Speed - if ( !v3->pure_speed_used ) - { - v3->uSpeed += 50; - v3->pure_speed_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 266: //Pure Intellect - if ( !v3->pure_intellect_used ) - { - v3->uIntelligence += 50; - v3->pure_intellect_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 267: //Pure Endurance - if ( !v3->pure_endurance_used ) - { - v3->uEndurance += 50; - v3->pure_endurance_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 268: //Pure Personality - if ( !v3->pure_willpower_used ) - { - v3->uWillpower += 50; - v3->pure_willpower_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 269: //Pure Accuracy - if ( !v3->pure_accuracy_used ) - { - v3->uAccuracy += 50; - v3->pure_accuracy_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 270: //Pure Might - if ( !v3->pure_might_used ) - { - v3->uMight += 50; - v3->pure_might_used = 1; - } - v3->PlaySound(SPEECH_36, 0); - break; - case 271: //Rejuvenation - v3->sAgeModifier = 0; - v3->PlaySound(SPEECH_36, 0); - break; - - default: - v68 = pParty->pPickedItem.GetDisplayName(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" - ShowStatusBarString(pTmpBuf.data(), 2u); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - return; - } - pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0); - if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) - { - if ( !v73 ) - { - pMouse->RemoveHoldingItem(); - return; - } - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - } - if ( v73 ) - { - if ( pParty->bTurnBasedModeOn ) - { - pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; - thisb->SetRecoveryTime(100); - pTurnEngine->ApplyPlayerAction(); - } - else - { - thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); - } - } - pMouse->RemoveHoldingItem(); + playerAffected->pPlayerBuffs[7].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + } + break; + case 229: //Heroism + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[8].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 230: //Bless + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 231: //Preservation + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[11].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 232: //Shield + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[13].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 234: //Stoneskin + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[14].Apply(pParty->uTimePlayed + v28, 3, 5, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 235: //Water Breathing + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335), + playerAffected->pPlayerBuffs[23].Apply(pParty->uTimePlayed +v28, 3, 5, 0, 0); + break; + case 237: //Remove Fear + playerAffected->pConditions[Condition_Fear] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 238: //Remove Curse + playerAffected->pConditions[Condition_Cursed] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 239: //Cure Insanity + playerAffected->pConditions[Condition_Insane] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 240: //Might Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[19].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 241: //Intellect Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[17].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 242: //Personality Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[20].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 243://Endurance Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[16].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 244: //Speed Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[21].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 245: //Accuracy Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[15].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 251: //Cure Paralysis + playerAffected->pConditions[Condition_Paralyzed] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 252://Divine Restoration + v30 = playerAffected->pConditions[Condition_Dead]; + v32 = playerAffected->pConditions[Condition_Pertified]; + v34 = playerAffected->pConditions[Condition_Eradicated]; + memset(&playerAffected->pConditions,0,sizeof(pConditions)); + playerAffected->pConditions[Condition_Dead] = v30; + playerAffected->pConditions[Condition_Pertified] = v32; + playerAffected->pConditions[Condition_Eradicated] = v34; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 253: //Divine Cure + v25 = 5 * pParty->pPickedItem.uEnchantmentType; + playerAffected->Heal(v25); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 254: //Divine Power + v26 = 5 * pParty->pPickedItem.uEnchantmentType; + new_mana_val = playerAffected->sMana; + new_mana_val += v26; + if ( new_mana_val > playerAffected->GetMaxMana() ) + new_mana_val = playerAffected->GetMaxMana(); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 255: //Luck Boost + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[18].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 256: //Fire Resistance + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[5].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 257: //Air Resistance + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[0].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 258: //Water Resistance + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[22].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 259: //Earth Resistance + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[3].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 260: //Mind Resistance + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[9].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 261: //Body Resistance + v50 = 3 * pParty->pPickedItem.uEnchantmentType; + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEnchantmentType) * 0.033333335); + playerAffected->pPlayerBuffs[2].Apply(pParty->uTimePlayed + v28, 0, v50, 0, 0); + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 262: //Stone to Flesh + playerAffected->pConditions[Condition_Pertified] = 0i64; + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 264: //Pure Luck + if ( !playerAffected->pure_luck_used ) + { + playerAffected->uLuck += 50; + playerAffected->pure_luck_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 265: //Pure Speed + if ( !playerAffected->pure_speed_used ) + { + playerAffected->uSpeed += 50; + playerAffected->pure_speed_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 266: //Pure Intellect + if ( !playerAffected->pure_intellect_used ) + { + playerAffected->uIntelligence += 50; + playerAffected->pure_intellect_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 267: //Pure Endurance + if ( !playerAffected->pure_endurance_used ) + { + playerAffected->uEndurance += 50; + playerAffected->pure_endurance_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 268: //Pure Personality + if ( !playerAffected->pure_willpower_used ) + { + playerAffected->uWillpower += 50; + playerAffected->pure_willpower_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 269: //Pure Accuracy + if ( !playerAffected->pure_accuracy_used ) + { + playerAffected->uAccuracy += 50; + playerAffected->pure_accuracy_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 270: //Pure Might + if ( !playerAffected->pure_might_used ) + { + playerAffected->uMight += 50; + playerAffected->pure_might_used = 1; + } + playerAffected->PlaySound(SPEECH_36, 0); + break; + case 271: //Rejuvenation + playerAffected->sAgeModifier = 0; + playerAffected->PlaySound(SPEECH_36, 0); + break; + + default: + v68 = pParty->pPickedItem.GetDisplayName(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36], v68);//"%s can not be used that way" + ShowStatusBarString(pTmpBuf.data(), 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + return; + } + pAudioPlayer->PlaySound((SoundID)210, 0, 0, -1, 0, 0, 0, 0); + if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + { +// if ( !v73 ) v73 is always 1 at this point +// { +// pMouse->RemoveHoldingItem(); +// return; +// } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + if ( v73 ) + { + if ( pParty->bTurnBasedModeOn ) + { + pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; + thisb->SetRecoveryTime(100); + pTurnEngine->ApplyPlayerAction(); + } + else + { + thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); + } + } + pMouse->RemoveHoldingItem(); + return; + } + + + if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_SPELL_SCROLL ) + { + if ( pCurrentScreen == SCREEN_CASTING ) return; - - } - - - if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_SPELL_SCROLL ) - { - - - if ( pCurrentScreen == SCREEN_CASTING ) - return; - if ( !pParty->pPlayers[player_num-1].CanAct() ) - { - - v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); + if ( !playerAffected->CanAct() ) + { + + v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); + ShowStatusBarString(pTmpBuf.data(), 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( bUnderwater == 1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + return; + } + dword_50C9AC = 1; + scroll_id = pParty->pPickedItem.uItemID - 299; + if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura + { + pMouse->RemoveHoldingItem(); + pGUIWindow_CurrentMenu->Release(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0); + } + else + { + _720984_unused = pParty->pPickedItem.uItemID; + pMouse->RemoveHoldingItem(); + pMessageQueue_50C9E8->AddMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1); + if ( pCurrentScreen && pGUIWindow_CurrentMenu + && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + } + return; + } + + if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_BOOK ) + { + v15 = pParty->pPickedItem.uItemID - 400; + v72 = playerAffected->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2; + if ( v72 ) + { + v66 = pParty->pPickedItem.GetDisplayName(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell" ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; - } - if ( bUnderwater == 1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2u);//"You can not do that while you are underwater!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - return; - } - dword_50C9AC = 1; - scroll_id = pParty->pPickedItem.uItemID - 299; - if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura - { - pMouse->RemoveHoldingItem(); - pGUIWindow_CurrentMenu->Release(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0); - } - else - { - _720984_unused = pParty->pPickedItem.uItemID; - pMouse->RemoveHoldingItem(); - pMessageQueue_50C9E8->AddMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1); - if ( pCurrentScreen && pGUIWindow_CurrentMenu - && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - } - } + } + if ( !playerAffected->CanAct() ) + { + v66 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s" + ShowStatusBarString(pTmpBuf.data(), 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; - } - - if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_BOOK ) - - { - v15 = pParty->pPickedItem.uItemID - 400; - v72 = v3->spellbook.bHaveSpell[pParty->pPickedItem.uItemID-400];//(char *)&v3->pConditions[0] + pParty->pPickedItem.uItemID + 2; - if ( v72 ) - { - v66 = pParty->pPickedItem.GetDisplayName(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[380], v66);//"You already know the %s spell" - ShowStatusBarString(pTmpBuf.data(), 2u); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pParty->pPlayers[player_num-1].CanAct() ) - { - v66 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v66);//"That player is %s" - ShowStatusBarString(pTmpBuf.data(), 2u); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - return; - } - v16 = v15 % 11 + 1; - v17 = v3->pActiveSkills[v15 / 11 + 12]; - v18 = SkillToMastery(v17) - 1; - switch (v18) - { + } + v16 = v15 % 11 + 1; + v17 = playerAffected->pActiveSkills[v15 / 11 + 12]; + v18 = SkillToMastery(v17) - 1; + switch (v18) + { case 0: v67 = 4; break; case 1: v67 = 7; break; case 2: v67 = 10; break; case 3: v67 = 11; break; default: - v67 = player_num; - } + v67 = player_num; + } - if ( v16 > v67 || !v17 ) - { - v22 = pParty->pPickedItem.GetDisplayName(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s" - ShowStatusBarString(pTmpBuf.data(), 2u); - v3->PlaySound((PlayerSpeech)20, 0); - return; - } - // v72 = 1; - v3->PlaySound(SPEECH_21, 0); - v73 = 0; - - - if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) - { - if ( !v73 ) - { - pMouse->RemoveHoldingItem(); - return; - } - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - } - if ( v73 ) + if ( v16 > v67 || !v17 ) + { + v22 = pParty->pPickedItem.GetDisplayName(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[381], v22); //"You don't have the skill to learn %s" + ShowStatusBarString(pTmpBuf.data(), 2u); + playerAffected->PlaySound((PlayerSpeech)20, 0); + return; + } + // v72 = 1; + playerAffected->PlaySound(SPEECH_21, 0); + v73 = 0; + + + if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + { + if ( !v73 ) + { + pMouse->RemoveHoldingItem(); + return; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } +// if ( v73 ) v73 is always 0 at this point +// { +// if ( pParty->bTurnBasedModeOn ) +// { +// pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; +// thisb->SetRecoveryTime(100); +// pTurnEngine->ApplyPlayerAction(); +// } +// else +// { +// thisb->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * 213.3333333333333); +// } +// } + pMouse->RemoveHoldingItem(); + return; + } + + if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_MESSAGE_SCROLL ) + { + if ( playerAffected->CanAct() ) + { + CreateMsgScrollWindow(pParty->pPickedItem.uItemID); + playerAffected->PlaySound(SPEECH_37, 0); + return; + } + v68 = aCharacterConditionNames[playerAffected->GetMajorConditionIdx()]; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); + ShowStatusBarString(pTmpBuf.data(), 2u); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + return; + } + else + { + if (pParty->pPickedItem.uItemID == 616) //Genie Lamp + { + thisa = pParty->uCurrentMonthWeek + 1; + if ( pParty->uCurrentMonth >= 7 ) + v74 = NULL; + else + v74 = aAttributeNames[pParty->uCurrentMonth]; + switch ( pParty->uCurrentMonth ) + { + case 0: + playerAffected->uMight += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 1: + playerAffected->uIntelligence += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 2: + playerAffected->uWillpower += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 3: + playerAffected->uEndurance += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 4: + playerAffected->uAccuracy += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 5: + playerAffected->uSpeed += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 6: + playerAffected->uLuck += thisa; + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" + break; + case 7: + party_finds_gold(1000 * thisa, 0); + sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold" + break; + case 8: + Party::GiveFood(5 * thisa); + sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food" + break; + case 9u: + playerAffected->uSkillPoints += 2 * thisa; + sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]); + break; + case 10: + playerAffected->uExperience += 2500 * thisa; + sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]); + break; + case 11: + v8 = rand() % 6; + switch (v8) { - if ( pParty->bTurnBasedModeOn ) - { - pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100; - thisb->SetRecoveryTime(100); - pTurnEngine->ApplyPlayerAction(); - } - else - { - thisb->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); - } + case 0: + playerAffected->sResFireBase += thisa; + v13 = pGlobalTXT_LocalizationStrings[87]; + break; + case 1: + playerAffected->sResAirBase += thisa; + v13 = pGlobalTXT_LocalizationStrings[6]; + break; + case 2: + playerAffected->sResWaterBase += thisa; + v13 = pGlobalTXT_LocalizationStrings[240]; + break; + case 3: + playerAffected->sResEarthBase += thisa; + v13 = pGlobalTXT_LocalizationStrings[70]; + break; + case 4: + playerAffected->sResMindBase += thisa; + v13 = pGlobalTXT_LocalizationStrings[142]; + break; + case 5: + playerAffected->sResBodyBase += thisa; + v13 = pGlobalTXT_LocalizationStrings[29]; + break; } - pMouse->RemoveHoldingItem(); + sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]); + break; + + } + ShowStatusBarString(pTmpBuf.data(), 2u); + pMouse->RemoveHoldingItem(); + pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); + playerAffected->PlaySound(SPEECH_93, 0); + pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); + if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 ) + { + playerAffected->SetCondition(Condition_Eradicated, 0); + pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); + } + else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 ) + { + playerAffected->SetCondition(Condition_Dead, 0); + pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); + } + else if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 ) + { + playerAffected->SetCondition(Condition_Pertified, 0); + pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); + } + return; + } + else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple + { + Party::GiveFood(1u); + pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0); + } + else if ( pParty->pPickedItem.uItemID == 632 ) //Lute + { + pAudioPlayer->PlaySound(SOUND_PlayLute, 0, 0, -1, 0, 0, 0, 0); return; - - } - - if ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType == EQUIP_MESSAGE_SCROLL ) - - { - if ( pParty->pPlayers[player_num-1].CanAct() ) - { - CreateMsgScrollWindow(pParty->pPickedItem.uItemID); - v3->PlaySound(SPEECH_37, 0); - return; - } - v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[382], v68); + } + else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes + { + pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes, 0, 0, -1, 0, 0, 0, 0); + return; + } + else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet + { + pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet, 0, 0, -1, 0, 0, 0, 0); + return; + } + else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe + { + pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); + v5 = PID(OBJECT_Player, player_num + 49); + pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0); + playerAffected->AddVariable(VAR_NumSkillPoints, 2); + } + else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle + { + TeleportToNWCDungeon(); + return; + } + else + { + v68 = pParty->pPickedItem.GetDisplayName(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way" ShowStatusBarString(pTmpBuf.data(), 2u); pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); return; - } - else - { - if (pParty->pPickedItem.uItemID == 616) //Genie Lamp - { - thisa = pParty->uCurrentMonthWeek + 1; - if ( pParty->uCurrentMonth >= 7 ) - v74 = NULL; - else - v74 = aAttributeNames[pParty->uCurrentMonth]; - switch ( pParty->uCurrentMonth ) - { - case 0: - v3->uMight += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 1: - v3->uIntelligence += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 2: - v3->uWillpower += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 3: - v3->uEndurance += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 4: - v3->uAccuracy += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 5: - v3->uSpeed += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 6: - v3->uLuck += thisa; - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v74, pGlobalTXT_LocalizationStrings[121]);//"Permanent" - break; - case 7: - party_finds_gold(1000 * thisa, 0); - sprintf(pTmpBuf.data(), "+%u %s", 1000 * thisa, pGlobalTXT_LocalizationStrings[97]);//"Gold" - break; - case 8: - Party::GiveFood(5 * thisa); - sprintf(pTmpBuf.data(), "+%u %s",5 * thisa , pGlobalTXT_LocalizationStrings[653]);//"Food" - break; - case 9u: - v3->uSkillPoints += 2 * thisa; - sprintf(pTmpBuf.data(), "+%u %s", 2 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_SKILL_POINTS]); - break; - case 10: - v3->uExperience += 2500 * thisa; - sprintf(pTmpBuf.data(), "+%u %s", 2500 * thisa, pGlobalTXT_LocalizationStrings[LOCSTR_EXPIRIENCE]); - break; - case 11: - v8 = rand() % 6; - switch (v8) - { - case 0: - v3->sResFireBase += thisa; - v13 = pGlobalTXT_LocalizationStrings[87]; - break; - case 1: - v3->sResAirBase += thisa; - v13 = pGlobalTXT_LocalizationStrings[6]; - break; - case 2: - v3->sResWaterBase += thisa; - v13 = pGlobalTXT_LocalizationStrings[240]; - break; - case 3: - v3->sResEarthBase += thisa; - v13 = pGlobalTXT_LocalizationStrings[70]; - break; - case 4: - v3->sResMindBase += thisa; - v13 = pGlobalTXT_LocalizationStrings[142]; - break; - case 5: - v3->sResBodyBase += thisa; - v13 = pGlobalTXT_LocalizationStrings[29]; - break; - } - sprintf(pTmpBuf.data(), "+%u %s %s", thisa, v13, pGlobalTXT_LocalizationStrings[121]); - break; - - } - ShowStatusBarString(pTmpBuf.data(), 2u); - pMouse->RemoveHoldingItem(); - pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); - v3->PlaySound(SPEECH_93, 0); - pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); - if ( pParty->uDaysPlayed == 6 || pParty->uDaysPlayed == 20 ) - { - v3->SetCondition(Condition_Eradicated, 0); - pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); - } - else if ( pParty->uDaysPlayed == 12 || pParty->uDaysPlayed == 26 ) - { - v3->SetCondition(Condition_Dead, 0); - pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); - } - else if ( pParty->uDaysPlayed == 4 || pParty->uDaysPlayed == 25 ) - { - v3->SetCondition(Condition_Pertified, 0); - pAudioPlayer->PlaySound((SoundID)215, 0, 0, -1, 0, 0, 0, 0); - } - return; - } - else if ( pParty->pPickedItem.uItemID == 630 ) //Red Apple - { - Party::GiveFood(1u); - pAudioPlayer->PlaySound(SOUND_EatApple, 0, 0, -1, 0, 0, 0, 0); - } - else if ( pParty->pPickedItem.uItemID == 632 ) //Lute - { - pAudioPlayer->PlaySound(SOUND_PlayLute, 0, 0, -1, 0, 0, 0, 0); - return; - } - else if ( pParty->pPickedItem.uItemID == 633 ) //Faerie Pipes - { - pAudioPlayer->PlaySound(SOUND_PlayFaeriePipes, 0, 0, -1, 0, 0, 0, 0); - return; - } - else if ( pParty->pPickedItem.uItemID == 634 ) //Gryphonheart's Trumpet - { - pAudioPlayer->PlaySound(SOUND_PlayGryphonheartsTrumpet, 0, 0, -1, 0, 0, 0, 0); - return; - } - else if ( pParty->pPickedItem.uItemID == 646 ) //Horseshoe - { - pGame->pStru6Instance->SetPlayerBuffAnim(SPELL_QUEST_COMPLETED, player_num - 1); - v5 = PID(OBJECT_Player, player_num + 49); - pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0); - v3->AddVariable(VAR_NumSkillPoints, 2); - } - else if ( pParty->pPickedItem.uItemID == 650 ) //Temple in a Bottle - { - TeleportToNWCDungeon(); - return; - } - else - { - - v68 = pParty->pPickedItem.GetDisplayName(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[36],v68);//"%s can not be used that way" - ShowStatusBarString(pTmpBuf.data(), 2u); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - return; - } - - pMouse->RemoveHoldingItem(); - return; - } - - } + } + + pMouse->RemoveHoldingItem(); + return; + } +} //----- (00449BB4) -------------------------------------------------------- bool Player::CompareVariable( enum VariableType VarNum, signed int pValue ) @@ -5672,6 +5652,7 @@ { if ( (signed int)var_type >= 0xF5 ) { + __debugbreak(); //how do I get here? *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed); *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); } @@ -5680,9 +5661,11 @@ switch ( var_type ) { case VAR_MonthEquals|VAR_CurrentSP: + __debugbreak(); //how do I get here? _449B7E_toggle_bit((unsigned char *)field_1A50, var_value, 1u); break; case VAR_NPCs2: + __debugbreak(); //how do I get here? pParty->field_709 = 0; LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u; pParty->CountHirelings(); @@ -5699,6 +5682,7 @@ return; if ( (signed int)var_type <= 0x112 ) { + __debugbreak(); //how do I get here? *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed); *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed); } @@ -5721,6 +5705,7 @@ v23 = pStorylineText->StoreLine[v22].pText == 0,//*(&pStorylineText->field_0 + 3 * v22) == 0, pParty->field_3C.field_4F0[2 * (var_type - 276) + 1] = HIDWORD(pParty->uTimePlayed), v23) ) + __debugbreak(); //how do I get here? return; bFlashHistoryBook = 1; } @@ -7344,35 +7329,27 @@ //----- (00467E7F) -------------------------------------------------------- void Player::EquipBody(ITEM_EQUIP_TYPE uEquipType) { - //unsigned int v1; // esi@1 int v2; // ebx@1 Player *v3; // eax@1 int v4; // edx@1 - int v5; // esi@2 - //int v6; // eax@2 int v7; // eax@3 - ItemGen _this; // [sp+Ch] [bp-30h]@1 - //Player *v9; // [sp+30h] [bp-Ch]@1 - int v10; // [sp+34h] [bp-8h]@1 - int *v11; // [sp+38h] [bp-4h]@1 - - - _this.Reset(); + ItemGen tempPickedItem; // [sp+Ch] [bp-30h]@1 + unsigned int *v11; // [sp+38h] [bp-4h]@1 + + tempPickedItem.Reset(); v2 = pEquipTypeToBodyAnchor[uEquipType]; v3 = pPlayers[uActiveCharacter]; - v11 = (int *)&v3->pEquipment.pIndices[v2]; + v11 = &v3->pEquipment.pIndices[v2]; v4 = *v11; - v10 = *v11; - if ( v10 ) - { - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v5 = (int)((char *)v3 + 4 * (9 * v4 - 9)); - *(char *)(v5 + 556) = 0; + if ( v4 ) + { + memcpy(&tempPickedItem, &pParty->pPickedItem, sizeof(tempPickedItem)); + v3->pInventoryItemList[v4 - 1].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v5 + 532)); - _this.uBodyAnchor = v2 + 1; - memcpy((void *)(v5 + 532), &_this, 0x24u); - *v11 = v10; + pParty->SetHoldingItem(&v3->pInventoryItemList[v4 - 1]); + tempPickedItem.uBodyAnchor = v2 + 1; + memcpy(&v3->pInventoryItemList[v4 - 1], &tempPickedItem, sizeof(ItemGen)); + *v11 = v4; } else { @@ -7380,7 +7357,7 @@ if (v7 >= 0) { pParty->pPickedItem.uBodyAnchor = v2 + 1; - memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItemList[v7])); + memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(ItemGen)); *v11 = v7 + 1; pMouse->RemoveHoldingItem(); } @@ -7391,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; } } @@ -7490,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) diff -r 01c04ff9b7a5 -r a6642179aa33 Player.h --- a/Player.h Sun Sep 15 19:12:34 2013 +0600 +++ b/Player.h Sun Sep 15 19:12:41 2013 +0600 @@ -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); diff -r 01c04ff9b7a5 -r a6642179aa33 UI/UICharacter.cpp --- a/UI/UICharacter.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/UI/UICharacter.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -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; diff -r 01c04ff9b7a5 -r a6642179aa33 mm7_1.cpp --- a/mm7_1.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/mm7_1.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -65,6 +65,14 @@ { return ((__int64)a1 * (__int64)a2) >> 16; } +__int64 fixpoint_sub2(int a1, int a2) +{ + signed __int64 v3; // qtt@1 + + LODWORD(v3) = a1 << 16; + HIDWORD(v3) = a1 >> 16; + return v3 / a2; +} __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2) { diff -r 01c04ff9b7a5 -r a6642179aa33 mm7_4.cpp --- a/mm7_4.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/mm7_4.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -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; diff -r 01c04ff9b7a5 -r a6642179aa33 mm7_5.cpp --- a/mm7_5.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/mm7_5.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -4302,264 +4302,274 @@ bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID) { signed int v2; // eax@1 - //unsigned int v3; // ecx@1 - //signed int v4; // esi@1 int v5; // ecx@2 - signed int v6; // eax@4 - int object1_sector; // eax@4 + int obj1_sector; // eax@4 float v8; // ST24_4@5 double v9; // ST18_8@5 - signed int v10; // eax@6 int v11; // ecx@6 signed int v12; // eax@7 int v13; // esi@7 int v14; // esi@8 int v15; // esi@9 - signed int v16; // eax@11 int obj2_z; // edi@11 int obj2_x; // esi@11 int obj2_sector; // eax@13 float v20; // ST24_4@14 double v21; // ST18_8@14 - signed int v22; // eax@15 - int dist2_x; // ebx@16 - signed int v24; // ecx@16 + int dist_x; // ebx@16 + signed int dist_3d; // ecx@16 int v25; // eax@18 - //int v26; // eax@28 - //BLVSector *v27; // edx@31 - //int v28; // ecx@31 BLVFace *v29; // ebx@32 Vec3_short_ *v30; // esi@32 int v31; // eax@32 int v32; // ST50_4@44 int v33; // ST54_4@44 int v34; // eax@44 - char v35; // zf@44 - int v36; // edi@44 - int v37; // eax@45 signed int v38; // esi@45 - int v39; // ST4C_4@49 signed __int64 v40; // qtt@50 - __int16 v42; // bx@58 + __int16 next_sector; // bx@58 int v43; // [sp-8h] [bp-70h]@11 int v44; // [sp-4h] [bp-6Ch]@11 - //int v45; // [sp+Ch] [bp-5Ch]@32 - //__int16 v46; // [sp+10h] [bp-58h]@32 int v47; // [sp+18h] [bp-50h]@20 int v48; // [sp+1Ch] [bp-4Ch]@20 int v49; // [sp+20h] [bp-48h]@20 - int dist2_z; // [sp+24h] [bp-44h]@16 - signed int v51; // [sp+24h] [bp-44h]@27 - signed int v52; // [sp+28h] [bp-40h]@26 - signed int v53; // [sp+2Ch] [bp-3Ch]@23 - signed int v54; // [sp+30h] [bp-38h]@22 - signed int v55; // [sp+34h] [bp-34h]@21 - signed int v56; // [sp+38h] [bp-30h]@20 - signed int v57; // [sp+3Ch] [bp-2Ch]@28 + int dist_z; // [sp+24h] [bp-44h]@16 + signed int higher_z; // [sp+24h] [bp-44h]@27 + signed int lower_z; // [sp+28h] [bp-40h]@26 + signed int higher_y; // [sp+2Ch] [bp-3Ch]@23 + signed int lower_y; // [sp+30h] [bp-38h]@22 + signed int higher_x; // [sp+34h] [bp-34h]@21 + signed int lower_x; // [sp+38h] [bp-30h]@20 + signed int sectors_visited; // [sp+3Ch] [bp-2Ch]@28 int v58; // [sp+44h] [bp-24h]@50 int v59; // [sp+48h] [bp-20h]@44 int obj2_y; // [sp+50h] [bp-18h]@11 - signed int v61; // [sp+50h] [bp-18h]@31 - //int v62; // [sp+54h] [bp-14h]@16 - int obj_x; // [sp+58h] [bp-10h]@4 - int obj_y; // [sp+5Ch] [bp-Ch]@4 - int obj_z; // [sp+60h] [bp-8h]@4 - int v66; // [sp+64h] [bp-4h]@7 + int obj1_x; // [sp+58h] [bp-10h]@4 + int obj1_y; // [sp+5Ch] [bp-Ch]@4 + int obj1_z; // [sp+60h] [bp-8h]@4 + int current_sector; // [sp+64h] [bp-4h]@7 + int dist_y; + int v70; v2 = PID_ID(uObjID); - if ( PID_TYPE(uObjID) == 5 ) + switch( PID_TYPE(uObjID) ) { - v6 = v2; - obj_x = pLevelDecorations[v6].vPosition.x; - obj_y = pLevelDecorations[v6].vPosition.y; - obj_z = pLevelDecorations[v6].vPosition.z; - object1_sector = pIndoor->GetSector(obj_x, obj_y, obj_z); - } - else if ( PID_TYPE(uObjID) == 3 ) - { - obj_x = pActors[v2].vPosition.x; - obj_y = pActors[v2].vPosition.y; + case OBJECT_Decoration: + obj1_x = pLevelDecorations[v2].vPosition.x; + obj1_y = pLevelDecorations[v2].vPosition.y; + obj1_z = pLevelDecorations[v2].vPosition.z; + obj1_sector = pIndoor->GetSector(obj1_x, obj1_y, obj1_z); + break; + case OBJECT_Actor: + obj1_x = pActors[v2].vPosition.x; + obj1_y = pActors[v2].vPosition.y; v8 = (double)pActors[v2].uActorHeight * 0.69999999; //v9 = v8 + 6.7553994e15; - //obj_z = LODWORD(v9) + pActors[v2].vPosition.z; - obj_z = (int)v8 + pActors[v2].vPosition.z; - object1_sector = pActors[v2].uSectorID; + //obj1_z = LODWORD(v9) + pActors[v2].vPosition.z; + obj1_z = (int)v8 + pActors[v2].vPosition.z; + obj1_sector = pActors[v2].uSectorID; + break; + case OBJECT_Item: + obj1_x = pSpriteObjects[v2].vPosition.x; + obj1_y = pSpriteObjects[v2].vPosition.y; + obj1_z = pSpriteObjects[v2].vPosition.z; + obj1_sector = pSpriteObjects[v2].uSectorID; + break; + default: + return 0; } - else if ( PID_TYPE(uObjID) == 2 ) - { - v10 = v2; - obj_x = pSpriteObjects[v10].vPosition.x; - obj_y = pSpriteObjects[v10].vPosition.y; - obj_z = pSpriteObjects[v10].vPosition.z; - object1_sector = pSpriteObjects[v10].uSectorID; - } - else - return 0; - v66 = object1_sector; v12 = PID_ID(uObj2ID); - if ( PID_TYPE(uObj2ID) == 5) + switch( PID_TYPE(uObj2ID) ) { - v16 = v12; - obj2_z = pLevelDecorations[v16].vPosition.z; - obj2_x = pLevelDecorations[v16].vPosition.x; - obj2_y = pLevelDecorations[v16].vPosition.y; - obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); - } - else if ( PID_TYPE(uObj2ID) == 4) - { - obj2_x = pParty->vPosition.x; - obj2_z = pParty->sEyelevel + pParty->vPosition.z; - obj2_y = pParty->vPosition.y; - obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); - } - - else if( PID_TYPE(uObj2ID) == 3) - { - obj2_y = pActors[v12].vPosition.y; - obj2_x = pActors[v12].vPosition.x; - v20 = (double)pActors[v12].uActorHeight * 0.69999999; - //v21 = v20 + 6.7553994e15; - //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z; - obj2_z = (int)v20 + pActors[v12].vPosition.z; - obj2_sector = pActors[v12].uSectorID; + case OBJECT_Decoration: + obj2_z = pLevelDecorations[v12].vPosition.z; + obj2_x = pLevelDecorations[v12].vPosition.x; + obj2_y = pLevelDecorations[v12].vPosition.y; + obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); + break; + case OBJECT_Player: + obj2_x = pParty->vPosition.x; + obj2_z = pParty->sEyelevel + pParty->vPosition.z; + obj2_y = pParty->vPosition.y; + obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); + break; + case OBJECT_Actor: + obj2_y = pActors[v12].vPosition.y; + obj2_x = pActors[v12].vPosition.x; + v20 = (double)pActors[v12].uActorHeight * 0.69999999; + //v21 = v20 + 6.7553994e15; + //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z; + obj2_z = (int)v20 + pActors[v12].vPosition.z; + obj2_sector = pActors[v12].uSectorID; + break; + case OBJECT_Item: + obj2_x = pSpriteObjects[v12].vPosition.x; + obj2_z = pSpriteObjects[v12].vPosition.z; + obj2_y = pSpriteObjects[v12].vPosition.y; + obj2_sector = pSpriteObjects[v12].uSectorID; + break; + default: + return 0; } - - else if ( PID_TYPE(uObj2ID) == 2) - { - v22 = v12; - obj2_x = pSpriteObjects[v22].vPosition.x; - obj2_z = pSpriteObjects[v22].vPosition.z; - obj2_y = pSpriteObjects[v22].vPosition.y; - obj2_sector = pSpriteObjects[v22].uSectorID; - } - else - return 0; - dist2_x = obj2_x - obj_x; - dist2_z = obj2_z - obj_z; - v24 = integer_sqrt(dist2_x * dist2_x + (obj2_y - obj_y) * (obj2_y - obj_y) + dist2_z * dist2_z); - if ( v24 > 5120 ) + dist_x = obj2_x - obj1_x; + dist_z = obj2_z - obj1_z; + dist_y = obj2_y - obj1_y; + dist_3d = integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z); + //range check + if ( dist_3d > 5120 ) return 0; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) return 1; v25 = 65536; - if ( v24 ) - v25 = 65536 / v24; - v49 = dist2_x * v25; - v47 = dist2_z * v25; - v48 = (obj2_y - obj_y) * v25; - if ( obj_x < obj2_x ) + if ( dist_3d ) + v25 = 65536 / dist_3d; + v49 = dist_x * v25; + v47 = dist_z * v25; + v48 = dist_y * v25; + if ( obj1_x < obj2_x ) { - v56 = obj_x; - v55 = obj2_x; + lower_x = obj1_x; + higher_x = obj2_x; } else { - v56 = obj2_x; - v55 = obj_x; + lower_x = obj2_x; + higher_x = obj1_x; } - if ( obj_y < obj2_y ) + if ( obj1_y < obj2_y ) { - v54 = obj_y; - v53 = obj2_y; + lower_y = obj1_y; + higher_y = obj2_y; } else { - v54 = obj2_y; - v53 = obj_y; + lower_y = obj2_y; + higher_y = obj1_y; } - if ( obj_z < obj2_z ) + if ( obj1_z < obj2_z ) { - v52 = obj_z; - v51 = obj2_z; + lower_z = obj1_z; + higher_z = obj2_z; } else { - v52 = obj2_z; - v51 = obj_z; + lower_z = obj2_z; + higher_z = obj1_z; } - v57 = 0; - if ( v66 == obj2_sector ) + sectors_visited = 0; + //monster in same sector with player + if ( obj1_sector == obj2_sector ) return 1; - //for ( v57 = 0; v57 < 30; v57++ ) - if ( v57 < 30 && !(v61 = 0, pIndoor->pSectors[v66].uNumPortals <= 0) ) - for( int v61 = 0; v61 < pIndoor->pSectors[v66].uNumPortals; v61++ ) + //search starts from monster + current_sector = obj1_sector; + for( int current_portal = 0; current_portal < pIndoor->pSectors[current_sector].uNumPortals; current_portal++ ) + { + v29 = &pIndoor->pFaces[pIndoor->pSectors[current_sector].pPortals[current_portal]]; + v30 = &pIndoor->pVertices[*v29->pVertexIDs]; + v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj1_z) + + v29->pFacePlane_old.vNormal.y * (v30->y - obj1_y) + + v29->pFacePlane_old.vNormal.x * (v30->x - obj1_x); + + if ( current_sector != v29->uSectorID ) + v31 = -v31; + + if ( v31 >= 0 && v30->x != obj1_x && v30->y != obj1_y && v30->z != obj1_z) + continue; + + if( lower_x > v29->pBounding.x2 + || higher_x < v29->pBounding.x1 + || lower_y > v29->pBounding.y2 + || higher_y < v29->pBounding.y1 + || lower_z > v29->pBounding.z2 + || higher_z < v29->pBounding.z1 ) + { + continue; + } + + v32 = fixpoint_sub0(v29->pFacePlane_old.vNormal.x,v49); + v33 = fixpoint_sub0(v29->pFacePlane_old.vNormal.z,v47); + v34 = fixpoint_sub0(v29->pFacePlane_old.vNormal.y,v48); + v59 = v32 + v33 + v34; + if ( v59 ) { - v29 = &pIndoor->pFaces[pIndoor->pSectors[v66].pPortals[v61]]; - v30 = &pIndoor->pVertices[*v29->pVertexIDs]; - //v45 = *(int *)&v30->x; - //v46 = v30->z; - //v31 = v29->pFacePlane_old.vNormal.z * (v46 - obj_z) - v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj_z) - //+ v29->pFacePlane_old.vNormal.y * (SHIWORD(v45) - obj_y) - + v29->pFacePlane_old.vNormal.y * (v30->y - obj_y) - //+ v29->pFacePlane_old.vNormal.x * ((signed __int16)v45 - obj_x); - + v29->pFacePlane_old.vNormal.x * (v30->x - obj_x); - if ( v66 != v29->uSectorID ) - v31 = -v31; - //if (!( v31 >= 0 && (signed __int16)v45 != obj_x && SHIWORD(v45) != obj_y && v46 != obj_z - if (!( v31 >= 0 && v30->x != obj_x && v30->y != obj_y && v30->z != obj_z - || v56 > v29->pBounding.x2 - || v55 < v29->pBounding.x1 - || v54 > v29->pBounding.y2 - || v53 < v29->pBounding.y1 - || v52 > v29->pBounding.z2 - || v51 < v29->pBounding.z1 ) ) - { - v32 = (unsigned __int64)(v49 * (signed __int64)v29->pFacePlane_old.vNormal.x) >> 16; - v33 = (unsigned __int64)(v47 * (signed __int64)v29->pFacePlane_old.vNormal.z) >> 16; - v34 = (unsigned __int64)(v48 * (signed __int64)v29->pFacePlane_old.vNormal.y) >> 16; - v35 = v32 + v33 + v34 == 0; - v36 = v32 + v33 + v34; - v59 = v32 + v33 + v34; - if ( !v35 ) - { - v37 = obj_z * v29->pFacePlane_old.vNormal.z; - v38 = -(v29->pFacePlane_old.dist + v37 + obj_x * v29->pFacePlane_old.vNormal.x + obj_y * v29->pFacePlane_old.vNormal.y); - if ( v36 <= 0 ^ v29->pFacePlane_old.dist + v37 + obj_x * v29->pFacePlane_old.vNormal.x + obj_y * v29->pFacePlane_old.vNormal.y <= 0) - { - v39 = abs(-(v29->pFacePlane_old.dist - + v37 - + obj_x * v29->pFacePlane_old.vNormal.x - + obj_y * v29->pFacePlane_old.vNormal.y)) >> 14; - if ( v39 > abs(v36) - || (LODWORD(v40) = v38 << 16, HIDWORD(v40) = v38 >> 16, v58 = v40 / v59, (signed int)(v40 / v59) < 0) - || !sub_4075DB( - obj_x + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v49) >> 16) + 32768) >> 16), - obj_y + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v48) >> 16) + 32768) >> 16), - obj_z + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v47) >> 16) + 32768) >> 16), - v29) ) - { - continue; - } - if ( v29->uSectorID == v66 ) - v42 = v29->uBackSectorID; - else - v42 = v29->uSectorID; - if ( v42 != v66 ) - { - ++v57; - v66 = v42; - if ( v42 == obj2_sector ) - return 1; - if ( v57 < 30 && pIndoor->pSectors[v66].uNumPortals > 0) - { - v61=-1; - continue; - } + v70 = v29->pFacePlane_old.dist + + obj1_z * v29->pFacePlane_old.vNormal.z + + obj1_x * v29->pFacePlane_old.vNormal.x + + obj1_y * v29->pFacePlane_old.vNormal.y; + v38 = -v70; + + // if ( v59 <= 0 ^ v70 <= 0 ) + + /* TEMPORARY + if ( v59 <= 0 && v70 <= 0 ) + { + continue; + } + if ( !(v59 <= 0 && v70 <= 0) ) + { + continue; + } + */ + + if( abs(v38) >> 14 > abs(v59) ) + continue; + + v58 = fixpoint_sub2(v38,v59); + + if( v58 < 0 ) + { + continue; + } - } - break; - } - } - } - } - if ( v66 != obj2_sector ) + if(!sub_4075DB( + obj1_x + ((fixpoint_sub0(v49,v58) + 32768) >> 16), + obj1_y + ((fixpoint_sub0(v48,v58) + 32768) >> 16), + obj1_z + ((fixpoint_sub0(v47,v58) + 32768) >> 16), + v29) ) + { + continue; + } + + //if there is no next sector turn back + if ( v29->uSectorID == current_sector ) + next_sector = v29->uBackSectorID; + else + next_sector = v29->uSectorID; + + //no more portals, quit + if ( next_sector == current_sector ) + { + break; + } + + ++sectors_visited; + current_sector = next_sector; + + //found player, quit + if ( next_sector == obj2_sector ) + return 1; + + current_sector = next_sector; + + //did we hit limit for portals? + //does the next room have portals? + if ( sectors_visited < 30 && pIndoor->pSectors[current_sector].uNumPortals > 0) + { + current_portal=-1; + continue; + } + else + break; + } + } + //did we stop in the sector where player is? + if ( current_sector != obj2_sector ) return 0; return 1; } //----- (004075DB) -------------------------------------------------------- -bool __fastcall sub_4075DB(int a1, int a2, int a3, BLVFace *a4) +bool __fastcall sub_4075DB(int x, int y, int z, BLVFace *a4) { unsigned int v5; // esi@1 char v7; // zf@2 @@ -4590,57 +4600,57 @@ v9 = pIndoor->pVertices; if ( v5 & FACE_XY_PLANE ) { - a4a = a1; - v8 = a2; + a4a = x; + v8 = y; for(int i = 0; i < a4->uNumVertices; i++) { dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].x; - dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i]].y; + dword_4F5CC8_ys[i] = v9[a4->pVertexIDs[i]].y; } } else { - v8 = a3; - if ( v5 & FACE_XY_PLANE ) + v8 = z; + if ( v5 & FACE_XZ_PLANE ) { - a4a = a1; + a4a = x; for(int i = 0; i < a4->uNumVertices; i++) { dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].x; - dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i]].z; + dword_4F5CC8_ys[i] = v9[a4->pVertexIDs[i]].z; } } else { - a4a = a2; + a4a = y; for(int i = 0; i < a4->uNumVertices; i++) { dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].y; - dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i]].z; + dword_4F5CC8_ys[i] = v9[a4->pVertexIDs[i]].z; } } } a3a = 0; dword_4F5D98_xs[a4->uNumVertices] = dword_4F5D98_xs[0]; - dword_4F5CC4_ys[a4->uNumVertices + 1] = dword_4F5CC4_ys[1]; - for(int i = 0; i < a4->uNumVertices; i++) + dword_4F5CC8_ys[a4->uNumVertices] = dword_4F5CC8_ys[0]; + for(int i = 0; i < a4->uNumVertices && a3a < 2; i++) { - if ( a3a >= 2 ) - break; - if ( dword_4F5CC4_ys[i + 1] >= v8 ^ (dword_4F5CC4_ys[i + 2] >= v8) ) + if ( dword_4F5CC8_ys[i] >= v8 ^ (dword_4F5CC8_ys[i + 1] >= v8) ) { - if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a) + //if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a) + if( !(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a)) { - if ( (dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] >= a4a) - || (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], - LODWORD(v26) = v25 << 16, - HIDWORD(v26) = v25 >> 16, - dword_4F5D98_xs[i] - + ((signed int)(((unsigned __int64)(v26 - / (dword_4F5CC4_ys[i + 2] - dword_4F5CC4_ys[i + 1]) - * ((v8 - dword_4F5CC4_ys[i + 1]) << 16)) >> 16) - + 32768) >> 16) >= a4a) ) - ++a3a; + if ( (dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a) ) + ++a3a; + //|| (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],LODWORD(v26) = v25 << 16, HIDWORD(v26) = v25 >> 16, + //dword_4F5D98_xs[i] + ((signed int)(((unsigned __int64)(v26 / (dword_4F5CC4_ys[i + 2] - dword_4F5CC4_ys[i + 1])* ((v8 - dword_4F5CC4_ys[i + 1]) << 16)) >> 16) + // + 32768) >> 16) >= a4a) ) + else + { + v25 = fixpoint_sub2(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); + if( dword_4F5D98_xs[i] + (fixpoint_sub0(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 32768 >> 16) >= a4a) + ++a3a; + } } } } diff -r 01c04ff9b7a5 -r a6642179aa33 mm7_data.cpp --- a/mm7_data.cpp Sun Sep 15 19:12:34 2013 +0600 +++ b/mm7_data.cpp Sun Sep 15 19:12:41 2013 +0600 @@ -860,10 +860,10 @@ int dword_4F5428[777]; // weak int dword_4F542C[777]; // weak _UNKNOWN crtunk_4F54B8; // weak -std::array dword_4F5B24_ys; // idb -std::array dword_4F5BF4_xs; // idb -std::array dword_4F5CC4_ys; // idb -std::array dword_4F5D98_xs; // idb +std::array dword_4F5B24_ys; // idb +std::array dword_4F5BF4_xs; // idb +std::array dword_4F5CC8_ys; // idb +std::array dword_4F5D98_xs; // idb std::array ai_array_4F5E68; std::array ai_array_4F6638_actor_ids; std::array ai_near_actors_targets_pid; diff -r 01c04ff9b7a5 -r a6642179aa33 mm7_data.h --- a/mm7_data.h Sun Sep 15 19:12:34 2013 +0600 +++ b/mm7_data.h Sun Sep 15 19:12:41 2013 +0600 @@ -509,10 +509,10 @@ extern int dword_4F5428[]; // weak extern int dword_4F542C[]; // weak extern _UNKNOWN crtunk_4F54B8; // weak -extern std::array dword_4F5B24_ys; // idb -extern std::array dword_4F5BF4_xs; // idb -extern std::array dword_4F5CC4_ys; // idb -extern std::array dword_4F5D98_xs; // idb +extern std::array dword_4F5B24_ys; // idb +extern std::array dword_4F5BF4_xs; // idb +extern std::array dword_4F5CC8_ys; // idb +extern std::array dword_4F5D98_xs; // idb extern std::array ai_array_4F5E68; extern std::array ai_array_4F6638_actor_ids; extern std::array ai_near_actors_targets_pid; @@ -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);