Mercurial > mm7
diff mm7_3.cpp @ 423:88c30918eef7
NPC_EventProcessor
author | Gloval |
---|---|
date | Sat, 23 Feb 2013 23:09:48 +0400 |
parents | d8b3056df4e2 |
children | afad358dc684 |
line wrap: on
line diff
--- a/mm7_3.cpp Sat Feb 23 19:35:32 2013 +0400 +++ b/mm7_3.cpp Sat Feb 23 23:09:48 2013 +0400 @@ -14703,10 +14703,10 @@ pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)]; v1 = pMapStats->GetMapInfo(pCurrentMapName); if ( v1 ) - sprintf(byte_591098, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" - else - strcpy(byte_591098, pGlobalTXT_LocalizationStrings[79]);// "Exit" - result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)byte_591098); + sprintf(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" + else + strcpy(sHouseName, pGlobalTXT_LocalizationStrings[79]);// "Exit" + result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)sHouseName); pDialogueWindow = result; return result; } @@ -15675,94 +15675,85 @@ } //----- (004466C4) -------------------------------------------------------- -bool __thiscall sub_4466C4(void *_this) -{ - signed int v1; // ebp@1 - bool result; // eax@2 - int v3; // esi@3 - signed int v4; // edx@3 - signed int v5; // eax@4 - unsigned int v6; // ebx@6 - char *v7; // eax@6 - signed int v8; // edi@18 - int v9; // eax@19 - Player *v10; // [sp+8h] [bp-10h]@18 - signed int v11; // [sp+Ch] [bp-Ch]@3 - signed int v12; // [sp+10h] [bp-8h]@3 - void *v13; // [sp+14h] [bp-4h]@1 - - v1 = 0; - v13 = _this; - if ( !_this ) +int NPC_EventProcessor( int npc_event_id ) + { + signed int event_index; // ebp@1 + int evt_seq_num; // esi@3 + bool ready_to_exit; // [sp+Ch] [bp-Ch]@3 + signed int npc_activity; // [sp+10h] [bp-8h]@3 + int result; + + event_index = 0; + if ( !npc_event_id ) return 0; - v3 = start_event_seq_number; + evt_seq_num = start_event_seq_number; pSomeOtherEVT = pGlobalEVT; uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents; - memcpy(pSomeOtherEVT_Events, pGlobalEVT_Index, 0xCE40u); - v4 = 1; - v12 = 1; - v11 = 0; - if ( (signed int)uSomeOtherEVT_NumEvents <= 0 ) - goto LABEL_16; + memcpy(pSomeOtherEVT_Events, pGlobalEVT_Index, sizeof(EventIndex)*4400); + npc_activity = 1; + ready_to_exit = false; + if ( uSomeOtherEVT_NumEvents <= 0 ) + return 2; do { - v5 = v1; - if ( (void *)pSomeOtherEVT_Events[v1].uEventID == v13 && pSomeOtherEVT_Events[v5].event_sequence_num == v3 ) - { - v6 = pSomeOtherEVT_Events[v5].uEventOffsetInEVT; - v7 = &pSomeOtherEVT[v6]; - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 1 ) - break; - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 44 ) - { - v11 = v4; - v10 = pParty->pPlayers; - v8 = (unsigned __int8)v7[7] - + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8); - while ( 1 ) - { - LOBYTE(v9) = v10->CompareVariable( - (enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5] - + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)), - v8); - if ( v9 ) - break; - ++v10; - if ( (signed int)v10 >= (signed int)pParty->pHirelings ) - goto LABEL_13; - } - } - else - { - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 45 ) - break; - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 46 ) - { - v11 = v4; - v12 = (unsigned __int8)v7[5]; - goto LABEL_13; - } - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] != 52 - || !IsActorAlive( - (unsigned __int8)v7[5], - (unsigned __int8)v7[6] - + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8), - (unsigned __int8)v7[10]) ) - goto LABEL_13; - } - v1 = -1; - v3 = (unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; -LABEL_13: - ++v3; - v4 = 1; - } - ++v1; - } - while ( v1 < (signed int)uSomeOtherEVT_NumEvents ); - if ( v11 ) - result = v12 != 0; - else -LABEL_16: + if ( (pSomeOtherEVT_Events[event_index].uEventID == npc_event_id) && (pSomeOtherEVT_Events[event_index].event_sequence_num == evt_seq_num) ) + { + _evt_raw *_evt = (_evt_raw *)&pSomeOtherEVT[pSomeOtherEVT_Events[event_index].uEventOffsetInEVT]; + switch(_evt->_e_type) + { + case EVENT_Exit: + //exit + if ( ready_to_exit ) + result = npc_activity != 0; + else + result = 2; + return result; + break; + case EVENT_OnCanShowDialogItemCmp: + ready_to_exit = true; + //v8 = (unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8); + for(int i=0; i<4; ++i) + { + // if (pParty->pPlayers[i].CompareVariable((enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5] + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)), + // v8)) + if (pParty->pPlayers[i].CompareVariable((enum VariableType)EVT_WORD(_evt->v5), EVT_DWORD(_evt->v7))) + { + event_index = -1; + evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; + break; + } + } + break; + case EVENT_EndCanShowDialogItem : + if ( ready_to_exit ) + result = npc_activity != 0; + else + result = 2; + return result; + break; + case EVENT_SetCanShowDialogItem : + ready_to_exit = true; + npc_activity = EVT_BYTE(_evt->v5); //(unsigned __int8)v7[5]; + break; + case EVENT_IsActorAssasinated : + // if (IsActorAlive( (unsigned __int8)v7[5], + // (unsigned __int8)v7[6] + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8), + // (unsigned __int8)v7[10]) ) + if (IsActorAlive( EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) + { // drop linear sequense, going to new seq + event_index = -1; + evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; + } + break; + } + ++evt_seq_num; + } + ++event_index; + } + while ( event_index < uSomeOtherEVT_NumEvents ); + if ( ready_to_exit ) + result = npc_activity != 0; + else result = 2; return result; }