Mercurial > mm7
changeset 501:6fa3ff8ef729
SubtractVariables
author | Ritor1 |
---|---|
date | Fri, 01 Mar 2013 17:37:47 +0600 |
parents | 63b171359be2 |
children | dd5124185551 |
files | Events.cpp Player.cpp Player.h Spells.h mm7_1.cpp mm7_3.cpp mm7_4.cpp mm7_data.h stru6.cpp |
diffstat | 9 files changed, 338 insertions(+), 290 deletions(-) [+] |
line wrap: on
line diff
--- a/Events.cpp Thu Feb 28 10:36:37 2013 +0600 +++ b/Events.cpp Fri Mar 01 17:37:47 2013 +0600 @@ -204,7 +204,7 @@ int v60; // eax@126 int v61; // edx@133 int v62; // eax@139 - void *v63; // ebp@145 + int v63; // ebp@145 signed int v64; // edi@146 unsigned int v65; // edx@148 Player *v66; // ecx@148 @@ -221,8 +221,8 @@ signed int v77; // ebp@186 int v78; // edx@186 Player *v79; // esi@187 - signed int v80; // ebp@200 - int v81; // edx@200 + //signed int v80; // ebp@200 + //int v81; // edx@200 Player *v82; // esi@201 int v83; // eax@212 int v84; // ebp@220 @@ -266,7 +266,7 @@ int curr_seq_num; // [sp+10h] [bp-498h]@4 //char *v123; // [sp+14h] [bp-494h]@0 signed int v124; // [sp+18h] [bp-490h]@7 - signed int v125; // [sp+1Ch] [bp-48Ch]@155 + //signed int v125; // [sp+1Ch] [bp-48Ch]@155 int v126; // [sp+1Ch] [bp-48Ch]@262 int player_choose; // [sp+20h] [bp-488h]@4 int v128; // [sp+24h] [bp-484h]@21 @@ -821,7 +821,7 @@ //v6 = v123; //v7 = ""; break; - case EVENT_Compare://_evt->_e_type == 14 cmp in Global.evt event 6 + case EVENT_Compare: pValue = EVT_DWORD(_evt->v7); if ( player_choose <= 3 ) { @@ -882,12 +882,12 @@ v4 = v124; break; case EVENT_Substract: - v63 = (void *)(_evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8)); - if ( _evt->v5 + ((uint)_evt->v6 << 8) == VAR_PlayerItemInHands ) + pValue = EVT_DWORD(_evt->v7); + if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) + { + v64 = 0; + if ( pParty->pPickedItem.uItemID == pValue ) { - v64 = 0; - if ( (void *)pParty->pPickedItem.uItemID == v63 ) - { pMouse->RemoveHoldingItem(); ++curr_seq_num; v4 = v124; @@ -895,14 +895,14 @@ //v6 = v123; //v7 = ""; break; - } + } v65 = 0; v66 = pPlayers[uActiveCharacter]; v67 = (int)v66->pInventoryIndices; do + { + if ( (int)&v66->pInventoryItems[v67] == pValue ) { - if ( *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v67 + 5] == v63 ) - { v66->RemoveItemAtInventoryIndex(v65); ++curr_seq_num; v4 = v124; @@ -910,17 +910,17 @@ //v6 = v123; //v7 = ""; break; - } + } ++v65; v67 += 4; - } - while ( (signed int)v65 < 126 ); + } + while ( (signed int)v65 < 126 ); v68 = 0; v69 = (int)&v66->pEquipment; do + { + if ( *(int *)v69 && (int)&v66->pInventoryItems[v69] == pValue ) { - if ( *(int *)v69 && *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v69 + 5] == v63 ) - { *(&v66->pEquipment.uOffHand + v68) = 0; ++curr_seq_num; v4 = v124; @@ -928,105 +928,143 @@ //v6 = v123; //v7 = ""; break; - } + } ++v68; v69 += 4; - } - while ( v68 < 16 ); - v125 = (signed int)&pPlayers[1]; + } + while ( v68 < 16 ); + pPlayer = pPlayers[1]; while ( 1 ) + { + v70 = pPlayer; + if ( !v64 ) { - v70 = *(Player **)v125; - if ( !v64 ) - { v71 = 0; v72 = (int)v70->pInventoryIndices; do + { + if ( (int)&v70->pInventoryItems[v72] == pValue ) { - if ( *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v72 + 5] == v63 ) - { v70->RemoveItemAtInventoryIndex(v71); goto LABEL_169; - } + } ++v71; v72 += 4; - } - while ( (signed int)v71 < 126 ); + } + while ( (signed int)v71 < 126 ); v73 = 0; v74 = (int)&v70->pEquipment; - while ( !*(int *)v74 - || *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v74 + 5] != v63 ) - { + while ( !*(int *)v74 || (int)&v70->pInventoryItems[v74] != pValue ) + { ++v73; v74 += 4; if ( v73 >= 16 ) goto LABEL_170; - } + } *(&v70->pEquipment.uOffHand + v73) = 0; LABEL_169: v64 = 1; - } + } LABEL_170: - v125 += 4; - if ( v125 > (signed int)&pPlayers[4] ) - { + pPlayer += 4; + if ( pPlayer > pPlayers[4] ) + { ++curr_seq_num; v4 = v124; //v6 = v123; //v7 = ""; break; - } } + } } v75 = player_choose; - if ( player_choose != 5 ) + if ( player_choose <= 3 ) + { + pPlayer = &pParty->pPlayers[v75]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + ++curr_seq_num; + //v4 = v124; + break; + } + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) { + pPlayer = pPlayers[uActiveCharacter]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + ++curr_seq_num; + v4 = v124; + break; + } + } + else if ( player_choose == 5 )//all + { + v130=0; + for(int i=0; i<4; ++i) + { + if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + { + ++curr_seq_num; + break; + } + } + ++v130; + break; + } + else if ( player_choose == 6 ) //random + { + v75 = rand() % 4; + pPlayer = &pParty->pPlayers[v75]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + ++curr_seq_num; + v4 = v124; + break; + } +/* if ( player_choose != 5 ) + { if ( player_choose < 0 ) goto LABEL_183; - if ( player_choose > 3 ) + //if ( player_choose > 3 ) + //{ + if ( player_choose != 4 ) { - if ( player_choose != 4 ) - { if ( player_choose == 6 ) goto LABEL_180; LABEL_183: - ((Player *)v6)->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63); + ((Player *)v6)->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); ++curr_seq_num; v4 = v124; //v6 = v123; //v7 = ""; break; - } + } if ( uActiveCharacter ) - { + { v6 = pPlayers[uActiveCharacter]; goto LABEL_182; - } + } LABEL_180: v75 = rand() % 4; - } + //} v6 = &pParty->pPlayers[v75]; LABEL_182: //v123 = v6; goto LABEL_183; - } - v76 = pParty->pPlayers; - v130 = 4; - do + } + v130=0; + for(int i=0; i<4; ++i) + { + if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) { - v76->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63); - ++v76; + ++curr_seq_num; + break; } - while ( (signed int)v76 < (signed int)pParty->pHirelings ); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; + } + ++v130; + break;*/ case EVENT_Set: v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); v78 = player_choose; @@ -1078,8 +1116,8 @@ //v7 = ""; break; case EVENT_Add: - v80 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); - v81 = player_choose; + pValue = EVT_DWORD(_evt->v7); + //v81 = player_choose; if ( player_choose != 5 ) { if ( player_choose < 0 ) @@ -1091,7 +1129,7 @@ if ( player_choose == 6 ) goto LABEL_208; LABEL_211: - ((Player *)v6)->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v80); + ((Player *)v6)->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), pValue); goto LABEL_212; } if ( uActiveCharacter ) @@ -1100,31 +1138,23 @@ goto LABEL_210; } LABEL_208: - v81 = rand() % 4; + player_choose = rand() % 4; } - v6 = &pParty->pPlayers[v81]; + v6 = &pParty->pPlayers[player_choose]; LABEL_210: //v123 = v6; goto LABEL_211; } - v82 = pParty->pPlayers; - v130 = 4; - do - { - v82->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v80); - ++v82; - } - while ( (signed int)v82 < (signed int)pParty->pHirelings ); + v130 = 0; + for(int i=1; i<5; ++i) + pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); LABEL_212: - v83 = _evt->v5 + ((uint)_evt->v6 << 8); + v83 = EVT_WORD(_evt->v5); if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 ) viewparams->bRedrawGameUI = 1; ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_InputString: if ( !start_event_seq_number )
--- a/Player.cpp Thu Feb 28 10:36:37 2013 +0600 +++ b/Player.cpp Fri Mar 01 17:37:47 2013 +0600 @@ -1744,7 +1744,6 @@ unsigned int uSlota; // [sp+14h] [bp+4h]@1 pIndices = &this->pInventoryIndices[uSlot]; - v3 = &this->pInventoryItems[*pIndices-1]; v4 = v3->uItemID; v3->Reset(); @@ -8893,11 +8892,11 @@ //&& (&dword_722F10)[4 * val] ) && pQuestTable[val-1] ) { - v17 = pPlayers[uPlayerIdx + 1]; + //v17 = pPlayers[uPlayerIdx + 1]; bFlashQuestBook = 1; v34 = 1; v3 = 1; - v17->PlaySound(SPEECH_93, 0); + pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_93, 0); } v15 = (char *)pParty->_quest_bits; LABEL_44: @@ -9279,11 +9278,11 @@ //----- (0044B9C4) -------------------------------------------------------- -void Player::SubtractVariable(enum VariableType var, void *a3) +bool Player::SubtractVariable(enum VariableType VarNum, signed int pValue) { unsigned int v3; // ebx@1 signed int v4; // esi@1 - enum VariableType v5; // eax@8 + bool result; // eax@8 int v6; // esi@11 int v7; // edi@14 signed int v8; // eax@17 @@ -9293,10 +9292,10 @@ char *v12; // ecx@27 __int64 v13; // qax@27 unsigned __int8 v14; // cf@27 - char *v15; // edx@29 + int *v15; // edx@29 char *v16; // eax@90 char *v17; // ecx@94 - void *v18; // esi@97 + int v18; // esi@97 signed int v19; // edx@97 char *v20; // ecx@98 int v21; // eax@100 @@ -9324,52 +9323,53 @@ } v4 = v24; LABEL_8: - v5 = var; - if ( (signed int)var > 222 ) - { - if ( (signed int)var <= 307 ) - { - if ( var == 307 ) - { - pParty->uNumDeaths -= (unsigned int)a3; - return; - } - if ( var == 223 ) + result = false; + if ( (signed int)VarNum > 222 ) + { + if ( (signed int)VarNum <= 307 ) + { + if ( VarNum == 307 ) + { + pParty->uNumDeaths -= (unsigned int)pValue; + return pValue; + } + if ( VarNum == 223 ) { v11 = (char *)pParty->_autonote_bits; - v22 = (short)a3 - 1; + v22 = (short)pValue - 1; } else { - if ( var != 231 ) + if ( VarNum != 231 ) { - switch ( var ) + switch ( VarNum ) { case 232: - var = (VariableType)0; - GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&var); - dword_5B65CC = 0; - if ( (void *)var == a3 ) + VarNum = (VariableType)0; + GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&VarNum); + result = (bool) pValue; + dword_5B65CC = 0; + if ( (int)VarNum == pValue ) { - dword_5B65CC = (int)a3; + dword_5B65CC = (int)pValue; } else { pParty->field_709 = 0; - LOBYTE(pNPCStats->pNewNPCData[(int)a3].uFlags) &= 0x7Fu; + LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu; sub_44A56A(); viewparams->bRedrawGameUI = 1; } break; case 241: - v18 = a3; + v18 = pValue; v19 = 0; if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) { v20 = (char *)&pNPCStats->pNewNPCData[0].uFlags; do { - if ( *((void **)v20 + 4) == v18 ) + if ( *((void **)v20 + 4) == (void *)v18 ) { v21 = *(int *)v20; if ( (char)*(int *)v20 < 0 ) @@ -9383,17 +9383,21 @@ } while ( v19 < (signed int)pNPCStats->uNumNewNPCs ); } - if ( (void *)pParty->pHirelings[0].uProfession == v18 ) + if ( pParty->pHirelings[0].uProfession == v18 ) memset(pParty->pHirelings, 0, 0x4Cu); - if ( (void *)pParty->pHirelings[1].uProfession == v18 ) + if ( pParty->pHirelings[1].uProfession == v18 ) memset(&pParty->pHirelings[1], 0, 0x4Cu); pParty->field_709 = 0; sub_44A56A(); break; case 243: v17 = (char *)&this->uSkillPoints; - if ( (unsigned int)a3 <= *(int *)v17 ) - *(int *)v17 -= (int)a3; + result = *v17; + if ( (unsigned int)pValue <= *(int *)v17 ) + { + *(int *)v17 -= (int)pValue; + result = v17; + } else *(int *)v17 = 0; break; @@ -9401,70 +9405,80 @@ v16 = (char *)&pOutdoor->ddm; if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) v16 = (char *)&pIndoor->dlv; - *((int *)v16 + 2) -= (int)a3; + *((int *)v16 + 2) -= (int)pValue; if ( *((int *)v16 + 2) < -10000 ) *((int *)v16 + 2) = -10000; break; case 306: - if ( (unsigned int)a3 <= pParty->uNumGoldInBank ) - pParty->uNumGoldInBank -= (unsigned int)a3; + result = VarNum - 306; + if ( (unsigned int)pValue <= pParty->uNumGoldInBank ) + { + result = (bool)pValue; + pParty->uNumGoldInBank -= (unsigned int)pValue; + } else LABEL_88: dword_5B65C4 = 1; break; } - return; + return result; } v11 = this->field_1A50; LABEL_112: - v22 = (signed __int16)a3; + v22 = (signed __int16)pValue; } _449B7E_toggle_bit((unsigned char *)v11, v22, 0); - return; - } - switch ( var ) + return result; + } + switch ( VarNum ) { case 308: - pParty->uNumBountiesCollected -= (unsigned int)a3; + result = (bool)pValue; + pParty->uNumBountiesCollected -= (unsigned int)pValue; break; case 309: - pParty->uNumPrisonTerms -= (int)a3; + result = (bool)pValue; + pParty->uNumPrisonTerms -= (int)pValue; break; case 310: - pParty->uNumArenaPageWins -= (char)a3; + result = (bool)pValue; + pParty->uNumArenaPageWins -= (char)pValue; break; case 311: - pParty->uNumArenaSquireWins -= (char)a3; + result = (bool)pValue; + pParty->uNumArenaSquireWins -= (char)pValue; break; case 312: - pParty->uNumArenaKnightWins -= (char)a3; + result = (bool)pValue; + pParty->uNumArenaKnightWins -= (char)pValue; break; case 313: - pParty->uNumArenaLordWins -= (char)a3; + result = (bool)pValue; + pParty->uNumArenaLordWins -= (char)pValue; break; } } else { - if ( (signed int)var >= 123 ) - { - byte_5E4C15[var] -= (char)a3; + if ( (signed int)VarNum >= 123 ) + { + byte_5E4C15[VarNum] -= (char)pValue; } else { - switch ( var ) + switch ( VarNum ) { case VAR_RandomGold: - v6 = rand() % (signed int)a3 + 1; + v6 = rand() % (signed int)pValue + 1; if ( v6 > pParty->uNumGold ) v6 = pParty->uNumGold; Party::TakeGold(v6); sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[503], v6); ShowStatusBarString(pTmpBuf, 2u); GameUI_DrawFoodAndGold(); - return; + return result; case VAR_RandomFood: - v7 = rand() % (signed int)a3 + 1; + v7 = rand() % (signed int)pValue + 1; if ( v7 > pParty->uNumFoodRations ) v7 = pParty->uNumFoodRations; Party::TakeFood(v7); @@ -9473,162 +9487,162 @@ GameUI_DrawFoodAndGold(); goto LABEL_17; default: - return; + return result; case VAR_CurrentHP: - ReceiveDamage((signed int)a3, 4); + ReceiveDamage((signed int)pValue, 4); goto LABEL_17; case VAR_CurrentSP: v9 = (char *)&this->sMana; - v10 = this->sMana - (signed int)a3 < 0; - *(int *)v9 -= (int)a3; + v10 = this->sMana - (signed int)pValue < 0; + *(int *)v9 -= (int)pValue; if ( v10 ) *(int *)v9 = 0; goto LABEL_17; case VAR_ACModifier: - this->sACModifier -= (unsigned __int8)a3; + this->sACModifier -= (unsigned __int8)pValue; goto LABEL_17; case VAR_BaseLevel: - this->uLevel -= (unsigned __int8)a3; + this->uLevel -= (unsigned __int8)pValue; goto LABEL_17; case VAR_LevelModifier: - this->sLevelModifier -= (unsigned __int8)a3; + this->sLevelModifier -= (unsigned __int8)pValue; goto LABEL_17; case VAR_Age: - this->sAgeModifier -= (signed __int16)a3; - return; + this->sAgeModifier -= (signed __int16)pValue; + return result; case VAR_Award: v11 = this->_guilds_member_bits; goto LABEL_112; case VAR_Experience: v12 = (char *)&this->uExperience; - v13 = (signed int)a3; - v14 = *(int *)v12 < (unsigned int)a3; - *(int *)v12 -= (int)a3; + v13 = (signed int)pValue; + v14 = *(int *)v12 < (unsigned int)pValue; + *(int *)v12 -= (int)pValue; *((int *)v12 + 1) -= v14 + HIDWORD(v13); goto LABEL_17; case VAR_QBits_QuestsDone: - _449B7E_toggle_bit(pParty->_quest_bits, (__int16)a3, 0); + _449B7E_toggle_bit(pParty->_quest_bits, (__int16)pValue, 0); pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0); - return; + return true; case VAR_PlayerItemInHands: - v15 = (char *)this->pInventoryIndices; + v15 = this->pInventoryIndices; break; case VAR_FixedGold: - if ( (unsigned int)a3 > pParty->uNumGold ) + if ( (unsigned int)pValue > pParty->uNumGold ) goto LABEL_88; - Party::TakeGold((unsigned int)a3); - return; + Party::TakeGold((unsigned int)pValue); + return result; case VAR_MightBonus: case VAR_ActualMight: - this->uMightBonus -= (unsigned __int16)a3; + this->uMightBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_IntellectBonus: case VAR_ActualIntellect: - this->uIntelligenceBonus -= (unsigned __int16)a3; + this->uIntelligenceBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_PersonalityBonus: case VAR_ActualPersonality: - this->uWillpowerBonus -= (unsigned __int16)a3; + this->uWillpowerBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_EnduranceBonus: case VAR_ActualEndurance: - this->uEnduranceBonus -= (unsigned __int16)a3; + this->uEnduranceBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_SpeedBonus: case VAR_ActualSpeed: - this->uSpeedBonus -= (unsigned __int16)a3; + this->uSpeedBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_AccuracyBonus: case VAR_ActualAccuracy: - this->uAccuracyBonus -= (unsigned __int16)a3; + this->uAccuracyBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_LuckBonus: case VAR_ActualLuck: - this->uLuckBonus -= (unsigned __int16)a3; + this->uLuckBonus -= (unsigned __int16)pValue; goto LABEL_72; case VAR_BaseMight: - this->uMight -= (unsigned __int16)a3; + this->uMight -= (unsigned __int16)pValue; goto LABEL_45; case VAR_BaseIntellect: - this->uIntelligence -= (unsigned __int16)a3; + this->uIntelligence -= (unsigned __int16)pValue; goto LABEL_45; case VAR_BasePersonality: - this->uWillpower -= (unsigned __int16)a3; + this->uWillpower -= (unsigned __int16)pValue; goto LABEL_45; case VAR_BaseEndurance: - this->uEndurance -= (unsigned __int16)a3; + this->uEndurance -= (unsigned __int16)pValue; goto LABEL_45; case VAR_BaseSpeed: - this->uSpeed -= (unsigned __int16)a3; + this->uSpeed -= (unsigned __int16)pValue; goto LABEL_45; case VAR_BaseAccuracy: - this->uAccuracy -= (unsigned __int16)a3; + this->uAccuracy -= (unsigned __int16)pValue; goto LABEL_45; case VAR_BaseLuck: - this->uLuck -= (unsigned __int16)a3; + this->uLuck -= (unsigned __int16)pValue; goto LABEL_45; case VAR_FireResistance: - this->sResFireBase -= (signed __int16)a3; + this->sResFireBase -= (signed __int16)pValue; goto LABEL_45; case VAR_AirResistance: - this->sResAirBase -= (signed __int16)a3; + this->sResAirBase -= (signed __int16)pValue; goto LABEL_45; case VAR_WaterResistance: - this->sResWaterBase -= (signed __int16)a3; + this->sResWaterBase -= (signed __int16)pValue; goto LABEL_45; case VAR_EarthResistance: - this->sResEarthBase -= (signed __int16)a3; + this->sResEarthBase -= (signed __int16)pValue; goto LABEL_45; case VAR_SpiritResistance: - this->sResSpiritBase -= (signed __int16)a3; + this->sResSpiritBase -= (signed __int16)pValue; goto LABEL_45; case VAR_MindResistance: - this->sResMindBase -= (signed __int16)a3; + this->sResMindBase -= (signed __int16)pValue; goto LABEL_45; case VAR_BodyResistance: - this->sResBodyBase -= (signed __int16)a3; + this->sResBodyBase -= (signed __int16)pValue; goto LABEL_45; case VAR_LightResistance: - this->sResLightBase -= (signed __int16)a3; + this->sResLightBase -= (signed __int16)pValue; goto LABEL_45; case VAR_DarkResistance: - this->sResDarkBase -= (signed __int16)a3; + this->sResDarkBase -= (signed __int16)pValue; goto LABEL_45; case VAR_MagicResistance: - this->sResMagicBase -= (signed __int16)a3; + this->sResMagicBase -= (signed __int16)pValue; goto LABEL_45; case VAR_FireResistanceBonus: - this->sResFireBonus -= (signed __int16)a3; + this->sResFireBonus -= (signed __int16)pValue; goto LABEL_45; case VAR_AirResistanceBonus: - this->sResAirBonus -= (signed __int16)a3; + this->sResAirBonus -= (signed __int16)pValue; LABEL_45: v25 = 0; v23 = 92; goto LABEL_73; case VAR_WaterResistanceBonus: - this->sResWaterBonus -= (signed __int16)a3; + this->sResWaterBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_EarthResistanceBonus: - this->sResEarthBonus -= (signed __int16)a3; + this->sResEarthBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_SpiritResistanceBonus: - this->sResSpiritBonus -= (signed __int16)a3; + this->sResSpiritBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_MindResistanceBonus: - this->sResMindBonus -= (signed __int16)a3; + this->sResMindBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_BodyResistanceBonus: - this->sResBodyBonus -= (signed __int16)a3; + this->sResBodyBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_LightResistanceBonus: - this->sResLightBonus -= (signed __int16)a3; + this->sResLightBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_DarkResistanceBonus: - this->sResDarkBonus -= (signed __int16)a3; + this->sResDarkBonus -= (signed __int16)pValue; goto LABEL_72; case VAR_MagicResistanceBonus: - this->sResMagicBonus -= (signed __int16)a3; + this->sResMagicBonus -= (signed __int16)pValue; LABEL_72: v25 = 0; v23 = SPEECH_91; @@ -9636,7 +9650,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25); goto LABEL_17; case VAR_FixedFood: - Party::TakeFood((unsigned int)a3); + Party::TakeFood((unsigned int)pValue); goto LABEL_17; case VAR_StaffSkill: case VAR_SwordSkill: @@ -9668,7 +9682,7 @@ case VAR_DiplomacySkill: case VAR_DisarmTrapSkill: case VAR_LearningSkill: - *((short *)&this->pConditions[16] + var) -= (unsigned __int8)a3; + *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue; goto LABEL_17; case VAR_Cursed: case VAR_Weak: @@ -9687,28 +9701,33 @@ case VAR_Dead: case VAR_Stoned: case VAR_Eradicated: - *((int *)this + 2 * var - 210) = 0; - *((int *)this + 2 * v5 - 209) = 0; + *((int *)this + 2 * VarNum - 210) = 0; + *((int *)this + 2 * result - 209) = 0; LABEL_17: pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; LOBYTE(v8) = (8 * v4 - 112) | 4; pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); - return; - } - do - { - if ( *(void **)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v15 + 5] == a3 ) + return result; + } + //do + for (v3 = 1; v3 < 126; v3++) + { + if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue )//pValue = ItemID, pInventoryItems[3] = 222 { - RemoveItemAtInventoryIndex(v3); - return; + RemoveItemAtInventoryIndex(v3);// &this->pInventoryIndices[puSlot], pInventoryIndices[1] = 4 + return true; } - ++v3; - v15 += 4; - } - while ( (signed int)v3 < 126 ); - if ( (void *)pParty->pPickedItem.uItemID == a3 ) - pMouse->RemoveHoldingItem(); + //++v3; + //v15 ++; + } + //while ( (signed int)v3 < 126 ); + if ( pParty->pPickedItem.uItemID == pValue ) + { + pMouse->RemoveHoldingItem(); + return true; + } + return false; } } }
--- a/Player.h Thu Feb 28 10:36:37 2013 +0600 +++ b/Player.h Fri Mar 01 17:37:47 2013 +0600 @@ -448,7 +448,7 @@ void SetVariable(enum VariableType var, signed int a3); void AddVariable(enum VariableType var, signed int val); - void SubtractVariable(enum VariableType var, void *a3); + bool SubtractVariable(enum VariableType VarNum, signed int pValue); bool CompareVariable(enum VariableType VarNum, signed int pValue); void UseItem_DrinkPotion_etc(signed int a2, int a3); bool AddItem(struct ItemGen *pItem);
--- a/Spells.h Thu Feb 28 10:36:37 2013 +0600 +++ b/Spells.h Fri Mar 01 17:37:47 2013 +0600 @@ -118,7 +118,7 @@ SPELL_LASER_PROJECTILE = 102, SPELL_150 = 150, - SPELL_151 = 151, + SPELL_QUEST_COMPLETED = 151, SPELL_152 = 152, SPELL_153 = 153 };
--- a/mm7_1.cpp Thu Feb 28 10:36:37 2013 +0600 +++ b/mm7_1.cpp Fri Mar 01 17:37:47 2013 +0600 @@ -5075,88 +5075,90 @@ int a4; // [sp+44h] [bp-4h]@2 v0 = pPlayers[uActiveCharacter]; - if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103 - || (pMouse->GetClickPos(&pX, &pY), - v1 = pY - 17, - v2 = pX - 14, - pY = v1, - pX = v2, - v3 = 14 * (v1 >> 5), - v2 >>= 5, - v4 = v2 + v3 < 0, - v5 = v2 + v3, - a4 = v5, - v4) - || v5 > 126 - || pMouse->GetCursorPos(&a2)->x >= 462 - || pMouse->GetCursorPos(&a2)->x < 14 ) - return; - if ( unk_50C9A0 ) + if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) { - v6 = v0->GetItemIDAtInventoryIndex(&a4); - if ( v6 ) + pMouse->GetClickPos(&pX, &pY); + pY = pY - 17; + v2 =pX - 14; + pX = v2; + v3 = 14 * (pY >> 5); + v2 >>= 5; + v4 = v2 + v3 < 0; + v5 = v2 + v3; + a4 = v5; + if ( !v4 ) { - *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; - *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; - *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; - *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; - ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1]; - unk_50C9A0 = 0; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMouse->SetCursorBitmap("MICON1"); - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 256; - } - return; - } - if ( ptr_50C9A4 ) - return; - v7 = pParty->pPickedItem.uItemID; - v8 = v0->GetItemIDAtInventoryIndex(&a4); - if ( !v7 ) - { - if ( !v8 ) - return; - memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); - v0->RemoveItemAtInventoryIndex(a4); - v9 = pParty->pPickedItem.uItemID; - goto LABEL_24; - } - v13 = v8; - if ( v8 ) - { - a2.y = (LONG)&v0->pInventoryItems[v8-1]; - memcpy(&this_, (const void *)a2.y, sizeof(this_)); - v0->RemoveItemAtInventoryIndex(a4); - pX = v0->AddItem2(a4, &pParty->pPickedItem); - if ( !pX ) - { - pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); - if ( !pX ) + if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462 + && pMouse->GetCursorPos(&a2)->x >= 14 ) { - v0->_49298B(&this_, v13 - 1, a4); - memcpy((void *)a2.y, &this_, sizeof(ItemGen)); - return; + if ( unk_50C9A0 ) + { + v6 = v0->GetItemIDAtInventoryIndex(&a4); + if ( v6 ) + { + *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; + *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; + *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; + *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; + ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1]; + unk_50C9A0 = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMouse->SetCursorBitmap("MICON1"); + dword_50C9D0 = 113; + dword_50C9D4 = 0; + dword_50C9D8 = 256; + } + return; + } + if ( ptr_50C9A4 ) + return; + v7 = pParty->pPickedItem.uItemID; + v8 = v0->GetItemIDAtInventoryIndex(&a4); + if ( !v7 ) + { + if ( !v8 ) + return; + memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); + v0->RemoveItemAtInventoryIndex(a4); + v9 = pParty->pPickedItem.uItemID; + goto LABEL_24; + } + v13 = v8; + if ( v8 ) + { + a2.y = (LONG)&v0->pInventoryItems[v8-1]; + memcpy(&this_, (const void *)a2.y, sizeof(this_)); + v0->RemoveItemAtInventoryIndex(a4); + pX = v0->AddItem2(a4, &pParty->pPickedItem); + if ( !pX ) + { + pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); + if ( !pX ) + { + v0->_49298B(&this_, v13 - 1, a4); + memcpy((void *)a2.y, &this_, sizeof(ItemGen)); + return; + } + } + v9 = this_.uItemID; + memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); +LABEL_24: + pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); + return; + } + v10 = v0->AddItem(a4, v7); + pX = v10; + if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) + { + memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); + } } } - v9 = this_.uItemID; - memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); -LABEL_24: - pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); - return; - } - v10 = v0->AddItem(a4, v7); - pX = v10; - if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) - { - memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); } } - //----- (0042213C) -------------------------------------------------------- void __cdecl OnGameViewportClick() {
--- a/mm7_3.cpp Thu Feb 28 10:36:37 2013 +0600 +++ b/mm7_3.cpp Fri Mar 01 17:37:47 2013 +0600 @@ -17087,20 +17087,17 @@ } //----- (00449B7E) -------------------------------------------------------- -unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) +void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) { signed int v3; // esi@1 - unsigned char *result; // eax@1 - unsigned int v5; // edx@1 + unsigned char set_bit; // edx@1 v3 = a2 - 1; - result = &pArray[v3 / 8]; - v5 = 0x80 >> v3 % 8; + set_bit = 0x80 >> v3 % 8; if ( bToggle ) - *result |= v5; - else - *result &= ~(unsigned char)v5; - return result; + pArray[v3 / 8] |= set_bit; + else + pArray[v3 / 8] &= ~set_bit; }
--- a/mm7_4.cpp Thu Feb 28 10:36:37 2013 +0600 +++ b/mm7_4.cpp Fri Mar 01 17:37:47 2013 +0600 @@ -8941,7 +8941,8 @@ v10 = result->_guilds_member_bits; result = (Player *)_449B57_test_bit((unsigned __int8 *)result->_guilds_member_bits, 1); if ( !(short)result ) - result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u); + __debugbreak; + //result = (Player *)_449B7E_toggle_bit((unsigned char *)v10, 1, 1u); } ++v8; }
--- a/mm7_data.h Thu Feb 28 10:36:37 2013 +0600 +++ b/mm7_data.h Fri Mar 01 17:37:47 2013 +0600 @@ -2045,7 +2045,7 @@ void __thiscall TeleportToStartingPoint(unsigned int uPointType); // idb __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb unsigned int __fastcall _449B57_test_bit(unsigned __int8 *a1, __int16 a2); -unsigned char *_449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb +void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb void __cdecl sub_44A56A(); void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds); void __cdecl ShowNothingHereStatus();
--- a/stru6.cpp Thu Feb 28 10:36:37 2013 +0600 +++ b/stru6.cpp Fri Mar 01 17:37:47 2013 +0600 @@ -1349,8 +1349,7 @@ v6 = "spboost1"; break; - case SPELL_151: - __debugbreak(); // spell id == 151 wtf + case SPELL_QUEST_COMPLETED: case SPELL_AIR_INVISIBILITY: case SPELL_WATER_WATER_WALK: case SPELL_SPIRIT_PRESERVATION: