Mercurial > mm7
changeset 391:86637e3f59a9
Some AI subs
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 08:46:50 +0200 |
parents | 35a62d1948d4 |
children | ff964014159f 9fb8fb53d588 |
files | mm7_3.cpp mm7_data.h |
diffstat | 2 files changed, 47 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/mm7_3.cpp Sat Feb 23 08:27:32 2013 +0200 +++ b/mm7_3.cpp Sat Feb 23 08:46:50 2013 +0200 @@ -17278,7 +17278,7 @@ //----- (004014E6) -------------------------------------------------------- -int __cdecl ODM_4014E6_AI() +void MakeActorAIList_ODM() { //Actor *v0; // esi@2 int v1; // eax@4 @@ -17293,26 +17293,27 @@ int v10; // ebx@14 //char v11; // zf@16 //int v12; // eax@22 - int result; // eax@24 - int v14; // edx@25 - int v15; // ecx@25 - int v16; // ebx@26 - unsigned int *v17; // ecx@27 - unsigned int v18; // esi@27 - int i; // edx@33 - char *v20; // ecx@34 + //int result; // eax@24 + //int v14; // edx@25 + //int v15; // ecx@25 + //int v16; // ebx@26 + //unsigned int *v17; // ecx@27 + //unsigned int v18; // esi@27 + //int i; // edx@33 + //char *v20; // ecx@34 int v21; // [sp+Ch] [bp-14h]@4 int v22; // [sp+10h] [bp-10h]@4 //int v23; // [sp+14h] [bp-Ch]@10 - int v24; // [sp+14h] [bp-Ch]@29 + //int v24; // [sp+14h] [bp-Ch]@29 //signed int v25; // [sp+18h] [bp-8h]@1 - signed int v26; // [sp+18h] [bp-8h]@25 - int v27; // [sp+1Ch] [bp-4h]@1 + //signed int v26; // [sp+18h] [bp-8h]@25 + //int v27; // [sp+1Ch] [bp-4h]@1 pParty->uFlags &= 0xFFFFFFCFu; - v27 = 0; + //v27 = 0; //v25 = 0; + ai_arrays_size = 0; for (uint i = 0; i < uNumActors; ++i) { auto actor = pActors + i; @@ -17374,13 +17375,14 @@ pParty->SetRedAlert(); } actor->uAttributes |= 0x00004000; - ai_near_actors_distances[v27] = v9; - ai_near_actors_ids[v27++] = i; + ai_near_actors_distances[ai_arrays_size] = v9; + ai_near_actors_ids[ai_arrays_size++] = i; } else actor->uAttributes &= 0xFFFFBFFF; } + /* result = v27; if ( v27 > 0 ) { @@ -17413,24 +17415,32 @@ v26 = v15; } while ( v15 - 1 < result ); - } - ai_arrays_size = result; - if ( result > 30 ) - { - result = 30; + }*/ + + for (uint i = 0; i < ai_arrays_size; ++i) + for (uint j = 0; j < i; ++j) + if (ai_near_actors_distances[j] > ai_near_actors_distances[i]) + { + int tmp = ai_near_actors_distances[j]; + ai_near_actors_distances[j] = ai_near_actors_distances[i]; + ai_near_actors_distances[i] = tmp; + + tmp = ai_near_actors_ids[j]; + ai_near_actors_ids[j] = ai_near_actors_ids[i]; + ai_near_actors_ids[i] = tmp; + } + + + if (ai_arrays_size > 30) ai_arrays_size = 30; - } - for ( i = 0; i < result; ++i ) - { - v20 = (char *)&pActors[ai_near_actors_ids[i]].uAttributes; - v20[1] |= 4u; - } - return result; + + for (uint i = 0; i < ai_arrays_size; ++i) + pActors[ai_near_actors_ids[i]].uAttributes |= 0x0400; } // 4F75D8: using guessed type int ai_arrays_size; //----- (004016FA) -------------------------------------------------------- -int __cdecl BLV_4016FA_AI() +int __cdecl MakeActorAIList_BLV() { Actor *v0; // esi@2 int v1; // eax@4 @@ -17478,6 +17488,7 @@ signed int v44; // [sp+1Ch] [bp-8h]@25 int v45; // [sp+20h] [bp-4h]@1 + __debugbreak(); // refactor for blv ai pParty->uFlags &= 0xFFFFFFCFu; v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); v45 = 0; @@ -17770,9 +17781,10 @@ signed int a2; // [sp+ACh] [bp-4h]@83 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - ODM_4014E6_AI(); - else - BLV_4016FA_AI(); + MakeActorAIList_ODM(); + else + MakeActorAIList_BLV(); + v0 = 0; if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) { @@ -17840,7 +17852,8 @@ --pTurnEngine->field_1C; } } - if ( pParty->bTurnBasedModeOn == 1 ) + + if (pParty->bTurnBasedModeOn) { pTurnEngine->_405E14(); return;
--- a/mm7_data.h Sat Feb 23 08:27:32 2013 +0200 +++ b/mm7_data.h Sat Feb 23 08:46:50 2013 +0200 @@ -1753,8 +1753,8 @@ #define __thiscall __cdecl // Test compile in C mode void __stdcall mm7__vector_constructor(void *a1, int objSize, int numObjs, int (__thiscall *constructor)(int)); -int __cdecl ODM_4014E6_AI(); -int __cdecl BLV_4016FA_AI(); +void MakeActorAIList_ODM(); +int __cdecl MakeActorAIList_BLV(); void __cdecl sub_401A91_AI(); bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID); bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *a4);