Mercurial > mm7
changeset 1893:7293e7e8810b
Actor::_SelectTarget final cleanup
author | Grumpy7 |
---|---|
date | Sun, 20 Oct 2013 00:38:38 -0700 |
parents | 9995cbcc62e0 |
children | fe7182c30aad |
files | Actor.cpp |
diffstat | 1 files changed, 24 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sun Oct 20 00:21:16 2013 -0700 +++ b/Actor.cpp Sun Oct 20 00:38:38 2013 -0700 @@ -2361,56 +2361,33 @@ v6->UpdateAnimation(); } -//----- (00SelectTarget) -------------------------------------------------------- +//----- (00401221) -------------------------------------------------------- void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) { - //Actor *v3; // esi@1 - //unsigned int v4; // ebx@1 int v5; // ecx@1 - //unsigned int v6; // eax@1 - //Actor *v7; // edi@2 - //__int16 v8; // ax@3 - int v9; // eax@10 signed int v10; // eax@13 int v11; // ebx@16 int v12; // eax@16 - //int v13; // eax@25 signed int v14; // eax@31 int v15; // edi@43 int v16; // ebx@45 int v17; // eax@45 - //int v18; // eax@51 - //int *v20; // [sp+10h] [bp-20h]@1 - signed int v21; // [sp+14h] [bp-1Ch]@1 - //unsigned int v22; // [sp+18h] [bp-18h]@1 + signed int closestId; // [sp+14h] [bp-1Ch]@1 int v23; // [sp+1Ch] [bp-14h]@16 - //unsigned int v24; // [sp+20h] [bp-10h]@1 - unsigned int v25; // [sp+24h] [bp-Ch]@1 - //signed int v26; // [sp+28h] [bp-8h]@1 + unsigned int lowestRadius; // [sp+24h] [bp-Ch]@1 int v27; // [sp+2Ch] [bp-4h]@16 int v28; // [sp+2Ch] [bp-4h]@45 - v25 = UINT_MAX; - //v22 = uActorID; - //v3 = &pActors[uActorID]; - //v4 = 0; + lowestRadius = UINT_MAX; v5 = 0; - //v6 = v3->uLastCharacterIDToHit; *a2 = 0; - //v20 = a2; - v21 = 0; - //v24 = v3->uLastCharacterIDToHit; - //v26 = 0; + closestId = 0; assert(uActorID < uNumActors); Actor* thisActor = &pActors[uActorID]; for (uint i = 0; i < uNumActors; ++i) { - auto actor = &pActors[i]; - //v7 = pActors; - //do - //{ - //v8 = v7->uAIState; + Actor* actor = &pActors[i]; if (actor->uAIState == Dead || actor->uAIState == Dying || actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) continue; @@ -2430,7 +2407,6 @@ } else { - //v18 = actor->uGroup; if ( (actor->uGroup != 0 || thisActor->uGroup != 0) && actor->uGroup == thisActor->uGroup ) continue; v10 = 4; @@ -2445,51 +2421,42 @@ && v27 <= v11 && v12 <= v11 && sub_4070EF_prolly_detect_player(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) - && v23 * v23 + v27 * v27 + v12 * v12 < v25 ) + && v23 * v23 + v27 * v27 + v12 * v12 < lowestRadius ) { - v25 = v23 * v23 + v27 * v27 + v12 * v12; - v21 = i; + lowestRadius = v23 * v23 + v27 * v27 + v12 * v12; + closestId = i; } - //v4 = 0; - //++v7; - //v5 = v26++ + 1; - //} - //while ( v26 < (signed int)uNumActors ); - } - if ( v25 != -1 ) - { - //v13 = 8 * v21; - //LOBYTE(v13) = PID(OBJECT_Actor,v21); - *a2 = PID(OBJECT_Actor, v21); - } + + if ( lowestRadius != UINT_MAX ) + { + *a2 = PID(OBJECT_Actor, closestId); + } if (pParty->Invisible()) can_target_party = false; if (can_target_party) { - v14 = thisActor->GetActorsRelation(0); - if ( BYTE2(thisActor->uAttributes) & 8 - && SHIDWORD(thisActor->pActorBuffs[12].uExpireTime) <= (signed int)0 - && (SHIDWORD(thisActor->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(thisActor->pActorBuffs[12].uExpireTime) <= 0) - && SHIDWORD(thisActor->pActorBuffs[1].uExpireTime) <= (signed int)0 - && (SHIDWORD(thisActor->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(thisActor->pActorBuffs[1].uExpireTime) <= 0) - && SHIDWORD(thisActor->pActorBuffs[2].uExpireTime) <= (signed int)0 - && (SHIDWORD(thisActor->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(thisActor->pActorBuffs[2].uExpireTime) <= 0) ) + if ( thisActor->uAttributes & 0x80000 + && thisActor->pActorBuffs[12].uExpireTime <= 0 + && thisActor->pActorBuffs[1].uExpireTime <= 0 + && thisActor->pActorBuffs[2].uExpireTime <= 0 ) v14 = 4; + else + v14 = thisActor->GetActorsRelation(0); if ( v14 != 0 ) { - v15 = dword_4DF380[4]; if ( !thisActor->pMonsterInfo.uHostilityType ) v15 = dword_4DF380[v14]; + else + v15 = dword_4DF380[4]; v16 = abs(thisActor->vPosition.x - pParty->vPosition.x); v28 = abs(thisActor->vPosition.y - pParty->vPosition.y); v17 = abs(thisActor->vPosition.z - pParty->vPosition.z); - if ( v16 <= v15 && v28 <= v15 && v17 <= v15 ) + if ( v16 <= v15 && v28 <= v15 && v17 <= v15 && (v16 * v16 + v28 * v28 + v17 * v17 < lowestRadius)) { - if ( v16 * v16 + v28 * v28 + v17 * v17 < v25 ) - *a2 = OBJECT_Player; + *a2 = OBJECT_Player; } } }