Mercurial > mm7
changeset 1881:fa3d4b400b8d
Actor::AI_RandomMove minor cleanup
author | Grumpy7 |
---|---|
date | Fri, 18 Oct 2013 09:31:35 +0200 |
parents | 52e98d25cd64 |
children | b3191dddab9f |
files | Actor.cpp |
diffstat | 1 files changed, 21 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Thu Oct 17 10:23:36 2013 +0200 +++ b/Actor.cpp Fri Oct 18 09:31:35 2013 +0200 @@ -1819,74 +1819,61 @@ //----- (004032B2) -------------------------------------------------------- void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength ) - { - unsigned int v4; // edi@1 +{ Actor *v5; // esi@1 - int v6; // ebx@1 - int v7; // ST08_4@1 - int v8; // eax@1 + int x; // ebx@1 + int absy; // eax@1 unsigned int v9; // ebx@11 int v10; // ebx@13 - signed __int16 v11; // cx@17 - unsigned int v12; // [sp-8h] [bp-44h]@10 - AIDirection *v13; // [sp-4h] [bp-40h]@10 - AIDirection v14; // [sp+Ch] [bp-30h]@7 - int v15; // [sp+28h] [bp-14h]@11 + AIDirection notInitializedBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7 unsigned int v16; // [sp+2Ch] [bp-10h]@1 int y; // [sp+30h] [bp-Ch]@1 - unsigned int uActorID; // [sp+34h] [bp-8h]@1 - int v19; // [sp+38h] [bp-4h]@1 - - //v14 never filled, maybe it is passed to function but optimized away as local variable - - uActorID = uActor_id; - v4 = uActor_id; + int absx; // [sp+38h] [bp-4h]@1 + v5 = &pActors[uActor_id]; v16 = uTarget_id; - v6 = v5->vInitialPosition.x - v5->vPosition.x; - v7 = v5->vInitialPosition.x - v5->vPosition.x; + x = v5->vInitialPosition.x - v5->vPosition.x; y = v5->vInitialPosition.y - v5->vPosition.y; - v19 = abs(v7); - v8 = abs(y); - if ( v19 <= v8 ) - v19 = v8 + (v19 >> 1); + absx = abs(x); + absy = abs(y); + if ( absx <= absy ) + absx = absy + (absx / 2 ); else - v19 += v8 >> 1; + absx = absx + absy / 2; if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { if ( !uActionLength ) uActionLength = 256; - Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14); + Actor::AI_StandOrBored(uActor_id, OBJECT_Player, uActionLength, ¬InitializedBecauseShouldBeRandom); return; } - if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) + if ( pActors[uActor_id].pMonsterInfo.uMovementType == 3 && absx < 128 ) { - Actor::AI_Stand(uActorID, uTarget_id, 256, &v14); + Actor::AI_Stand(uActor_id, uTarget_id, 256, ¬InitializedBecauseShouldBeRandom); return; } - v15 = (rand() & 0xF) << 12; - v19 += (unsigned __int64)(v15 * (signed __int64)radius) >> 16; - v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(v6, y); + absx += ((rand() & 0xF) * radius) / 16; + v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(x, y); if ( rand() % 100 < 25 ) { - Actor::StandAwhile(uActorID); + Actor::StandAwhile(uActor_id); return; } v10 = v9 + rand() % 256 - 128; if ( abs(v10 - v5->uYawAngle) > 256 && !(v5->uAttributes & 0x200000) ) { - Actor::AI_Stand(uActorID, uTarget_id, 256, &v14); + Actor::AI_Stand(uActor_id, uTarget_id, 256, ¬InitializedBecauseShouldBeRandom); return; } v5->uYawAngle = v10; if ( v5->uMovementSpeed) - v5->uCurrentActionLength = 32 * v19 / v5->uMovementSpeed; + v5->uCurrentActionLength = 32 * absx / v5->uMovementSpeed; else v5->uCurrentActionLength = 0; v5->uCurrentActionTime = 0; v5->uAIState = Tethered; if ( rand() % 100 < 2 ) - Actor::PlaySound(uActorID, 3u); + Actor::PlaySound(uActor_id, 3u); v5->UpdateAnimation(); }