Mercurial > mm7
changeset 2025:4000f8184c29
EVENT_Substract fix
author | Ritor1 |
---|---|
date | Sun, 17 Nov 2013 01:14:58 +0600 |
parents | bb0da61e4a7e |
children | 23ef3589440f |
files | Events.cpp Player.cpp |
diffstat | 2 files changed, 76 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/Events.cpp Sat Nov 16 00:02:24 2013 +0600 +++ b/Events.cpp Sun Nov 17 01:14:58 2013 +0600 @@ -945,7 +945,7 @@ break; case EVENT_Substract: pValue = EVT_DWORD(_evt->v7); - if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) + /*if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) { if ( pParty->pPickedItem.uItemID == pValue )//In hand { @@ -957,124 +957,110 @@ //v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix.data(); for ( v65 = 0; v65 < 126; ++v65 ) { - v67 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&pPlayers[uActiveCharacter]->pInventoryMatrix[v65]); - if (v67) - { - if ( pPlayers[uActiveCharacter]->pInventoryItemList[v67 - 1].uItemID == pValue ) + v67 = &pPlayers[uActiveCharacter]->pInventoryMatrix[v65]; + if ( v67 > 0 ) { - pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(pPlayers[uActiveCharacter]->pInventoryMatrix[v65]); - ++curr_seq_num; - v4 = v124; - goto substract; + if ( pPlayers[uActiveCharacter]->pInventoryItemList[v67 - 1].uItemID == pValue ) + { + pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); + //++curr_seq_num; + //v4 = v124; + goto substract; + } } - } //v67 += 4; } //while ( (signed int)v65 < 126 ); - v69 = (int)&pPlayers[uActiveCharacter]->pEquipment; + //v69 = (int)&pPlayers[uActiveCharacter]->pEquipment.pIndices; for ( v68 = 0; v68 < 16; ++v68 ) { - if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v69] == pValue ) + if ( pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->pEquipment.pIndices[v68]].uItemID == pValue ) { - *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v68) = 0; - ++curr_seq_num; - v4 = v124; - break; + pPlayers[uActiveCharacter]->pEquipment.pIndices[v68] = 0; + //++curr_seq_num; + //v4 = v124; + goto substract; } - v69 += 4; + //v69 += 4; } for (int i = 1; i < 5; i++) { //v72 = (int)pPlayers[i]->pInventoryMatrix.data(); for ( int v71 = 0; v71 < 126; ++v71 ) { - v72 = pPlayers[i]->GetItemIDAtInventoryIndex(&pPlayers[i]->pInventoryMatrix[v71]); - if (v72) - { - if ( pPlayers[i]->pInventoryItemList[v72 - 1].uItemID == pValue ) + v72 = &pPlayers[i]->pInventoryMatrix[v71]; + if ( v72 > 0 ) { - pPlayers[i]->RemoveItemAtInventoryIndex(pPlayers[i]->pInventoryMatrix[v71]); - goto substract; + if ( pPlayers[i]->pInventoryItemList[v72 - 1].uItemID == pValue ) + { + pPlayers[i]->RemoveItemAtInventoryIndex(v71); + goto substract; + } } - } //v72 += 4; } - v73 = 0; - v74 = (int)&pPlayers[i]->pEquipment; - while ( !*(int *)v74 || (int)&pPlayer->pInventoryItemList[v74] != pValue ) + for ( v73 = 0; v73 < 16; ++v73 ) { - ++v73; - v74 += 4; - if ( v73 >= 16 ) - break; + //v74 = (int)&pPlayers[i]->pEquipment; + if (pPlayers[i]->pEquipment.pIndices[v73]) + { + if (pPlayers[i]->pInventoryItemList[pPlayers[i]->pEquipment.pIndices[v73] - 1].uItemID == pValue ) + { + pPlayers[i]->pEquipment.pIndices[v73] = 0; + //v74 += 4; + goto substract; + } + } } - *(&pPlayers[i]->pEquipment.uShield + v73) = 0; } - } + }*/ if ( player_choose <= 3 ) - { - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pParty->pPlayers[player_choose].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); else if ( player_choose == 4 ) //active { if ( uActiveCharacter ) - { - pPlayer = pPlayers[uActiveCharacter]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pPlayers[uActiveCharacter]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } else if ( player_choose == 5 )//all { - v130 = 0; for(int i = 1; i < 5; ++i) { pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } - ++v130; } else if ( player_choose == 6 ) //random { player_choose = rand() % 4; - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + pParty->pPlayers[player_choose].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } -substract: +//substract: ++curr_seq_num; v4 = v124; break; case EVENT_Set: pValue = EVT_DWORD(_evt->v7); if ( player_choose <= 3 ) - { - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pParty->pPlayers[player_choose].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); else if ( player_choose == 4 ) //active { if ( uActiveCharacter ) - { - pPlayer = pPlayers[uActiveCharacter]; - pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pPlayers[uActiveCharacter]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } else if ( player_choose == 5 )//all { //recheck v130 - for(int i = 1; i < 5; ++i) + for ( int i = 1; i < 5; ++i ) pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } else if ( player_choose == 6 ) //random { player_choose = rand() % 4; pPlayer = &pParty->pPlayers[player_choose]; pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - ++curr_seq_num; - v4 = v124; - break; + ++curr_seq_num; + v4 = v124; + break; case EVENT_Add: pValue = EVT_DWORD(_evt->v7); if ( player_choose <= 3 ) @@ -1085,34 +1071,28 @@ else if ( player_choose == 4 ) //active { if ( uActiveCharacter ) - { - pPlayer = pPlayers[uActiveCharacter]; - pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + pPlayers[uActiveCharacter]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } else if ( player_choose == 5 )//all { - //v130 = 0; for(int i = 1; i < 5; ++i) pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } else if ( player_choose == 6 ) //random { player_choose = rand() % 4; - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + pParty->pPlayers[player_choose].AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); } - v83 = EVT_WORD(_evt->v5); - if (v83 == 21 || // gold well on emerald isle - v83 == 22 || v83 == 23 || v83 == 24 ) - { - //__debugbreak(); // bonfire - viewparams->bRedrawGameUI = true; - } - ++curr_seq_num; - v4 = v124; - break; + v83 = EVT_WORD(_evt->v5); + if (v83 == 21 || // gold well on emerald isle + v83 == 22 || v83 == 23 || v83 == 24 ) + { + //__debugbreak(); // bonfire + viewparams->bRedrawGameUI = true; + } + ++curr_seq_num; + v4 = v124; + break; case EVENT_InputString: if ( !entry_line ) {
--- a/Player.cpp Sat Nov 16 00:02:24 2013 +0600 +++ b/Player.cpp Sun Nov 17 01:14:58 2013 +0600 @@ -6602,12 +6602,27 @@ this->PlaySound(SPEECH_96, 0); return; case VAR_PlayerItemInHands: + for ( uint i = 0; i < 16; ++i ) + { + int id_ = this->pEquipment.pIndices[i]; + if ( id_ > 0 ) + { + if ( this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID == pValue ) + { + this->pEquipment.pIndices[i] = 0; + } + } + } for (int i = 0; i < 126; i++) { - if ( this->pInventoryItemList[pInventoryMatrix[i]].uItemID == pValue ) + int id_ = this->pInventoryMatrix[i]; + if ( id_ > 0 ) { - RemoveItemAtInventoryIndex(i); - return; + if ( this->pInventoryItemList[id_ - 1].uItemID == pValue ) + { + RemoveItemAtInventoryIndex(i); + return; + } } } if ( pParty->pPickedItem.uItemID == pValue )