# HG changeset patch # User Grumpy7 # Date 1381998216 -7200 # Node ID 52e98d25cd64844861d465a23c7d98b264885ea2 # Parent 7efa09ddb8b4e422070e5bceb2cb20ede1c74894 Actor::AI_MissileAttack1 and Actor::AI_MissileAttack2 cleaned up diff -r 7efa09ddb8b4 -r 52e98d25cd64 Actor.cpp --- a/Actor.cpp Thu Oct 17 10:00:57 2013 +0200 +++ b/Actor.cpp Thu Oct 17 10:23:36 2013 +0200 @@ -1617,7 +1617,7 @@ return; } v19 = v3->uActorHeight; - v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); + v7.z = v3->vPosition.z - (int)(v19 * -0.75); v7.y = v3->vPosition.y; v7.x = v3->vPosition.x; if ( sub_407A1C(v4, v5, v21, v7) ) @@ -1668,91 +1668,75 @@ void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 - AIDirection *v4; // esi@3 - AIDirection *v5; // edi@3 + int16_t v4; // esi@3 + int16_t v5; // edi@3 signed int v6; // eax@4 Vec3_int_ v7; // ST04_12@6 - //unsigned int result; // eax@7 AIDirection *v9; // eax@8 - unsigned int v10; // esi@8 - AIDirection *v11; // esi@9 - SpriteFrame *v12; // ecx@10 __int16 v13; // ax@10 - unsigned int v14; // ecx@10 - signed __int64 v15; // qax@10 AIDirection a3; // [sp+Ch] [bp-48h]@9 AIDirection v17; // [sp+28h] [bp-2Ch]@9 int v18; // [sp+44h] [bp-10h]@6 - //signed int a2; // [sp+48h] [bp-Ch]@1 int v20; // [sp+4Ch] [bp-8h]@3 - unsigned int v21; // [sp+50h] [bp-4h]@1 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 - v21 = uActorID; v3 = &pActors[uActorID]; - //a2 = edx0; if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { v6 = PID_ID(sTargetPid); - v4 = (AIDirection *)pActors[v6].vPosition.x; - v5 = (AIDirection *)pActors[v6].vPosition.y; - v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); + v4 = pActors[v6].vPosition.x; + v5 = pActors[v6].vPosition.y; + v20 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); + } + else if ( PID_TYPE(sTargetPid) == OBJECT_Player) + { + v4 = pParty->vPosition.x; + v5 = pParty->vPosition.y; + v20 = pParty->vPosition.z + pParty->sEyelevel; } else { - if ( PID_TYPE(sTargetPid) == OBJECT_Player) + Error("Should not get here"); + return; + } + v18 = v3->uActorHeight; + v7.z = v3->vPosition.z - (int)(v18 * -0.75); + v7.y = v3->vPosition.y; + v7.x = v3->vPosition.x; + if ( sub_407A1C(v4, v5, v20, v7) ) + { + if ( pDir == nullptr ) { - v4 = (AIDirection *)pParty->vPosition.x; - v5 = (AIDirection *)pParty->vPosition.y; - v20 = pParty->vPosition.z + pParty->sEyelevel; + v9 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); } else { - v4 = pDir; - v5 = pDir; + v9 = pDir; } - } - v18 = v3->uActorHeight; - v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v18 * -0.75); - v7.y = v3->vPosition.y; - v7.x = v3->vPosition.x; - if ( sub_407A1C((int)v4, (int)v5, v20, v7) ) - { - v9 = pDir; - v10 = 0; - if ( !pDir ) + v3->uYawAngle = LOWORD(v9->uYawAngle); + v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; + v3->uCurrentActionLength = 8 * v13; + v3->uCurrentActionTime = 0; + v3->uAIState = AttackingRanged2; + Actor::PlaySound(uActorID, 0); + pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; + if ( v3->pActorBuffs[7].uExpireTime > 0 ) { - v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); - v9 = &v17; - memcpy(&v17, v11, sizeof(v17)); - v10 = 0; - } - v12 = pSpriteFrameTable->pSpriteSFrames; - v3->uYawAngle = LOWORD(v9->uYawAngle); - v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; - v14 = v21; - v3->uCurrentActionLength = 8 * v13; - v3->uCurrentActionTime = v10; - v3->uAIState = AttackingRanged2; - Actor::PlaySound(v14, 0); - LODWORD(v15) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v10 - && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v10 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v10) ) - { - LODWORD(v15) = 2 * v15; - pDira = v15; + pDira *= 2; } if ( pParty->bTurnBasedModeOn != 1 ) - v15 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)pDira * 2.133333333333333); - v3->pMonsterInfo.uRecoveryTime = v15; - v3->vVelocity.z = v10; - v3->vVelocity.y = v10; - v3->vVelocity.x = v10; + v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); + else + { + v3->pMonsterInfo.uRecoveryTime = pDira; + } + v3->vVelocity.z = 0; + v3->vVelocity.y = 0; + v3->vVelocity.x = 0; v3->UpdateAnimation(); } else - Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); + Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); } //----- (00403476) -------------------------------------------------------- @@ -1763,24 +1747,15 @@ int v5; // edi@3 signed int v6; // eax@4 Vec3_int_ v7; // ST04_12@6 - unsigned char v8[12]; // ST04_12@7 - //unsigned int result; // eax@8 AIDirection *v10; // eax@9 - unsigned int v11; // esi@9 - AIDirection *v12; // esi@10 - SpriteFrame *v13; // ecx@11 __int16 v14; // ax@11 - unsigned int v15; // ecx@11 - unsigned int v16; // eax@11 AIDirection a3; // [sp+Ch] [bp-48h]@10 AIDirection v18; // [sp+28h] [bp-2Ch]@10 int v19; // [sp+44h] [bp-10h]@6 //signed int a2; // [sp+48h] [bp-Ch]@1 - unsigned int v21; // [sp+4Ch] [bp-8h]@1 int v22; // [sp+50h] [bp-4h]@3 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 - v21 = uActorID; v3 = &pActors[uActorID]; //a2 = edx0; if ( PID_TYPE(sTargetPid) == OBJECT_Actor) @@ -1788,7 +1763,7 @@ v6 = PID_ID(sTargetPid); v4 = pActors[v6].vPosition.x; v5 = pActors[v6].vPosition.y; - v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); + v22 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); } else { @@ -1808,55 +1783,38 @@ v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); v7.y = v3->vPosition.y; v7.x = v3->vPosition.x; - if ( sub_407A1C(v4, v5, v22, v7) - || (*(unsigned int *)&v8[8] = v22, - v19 = v3->uActorHeight, - *(_QWORD *)v8 = __PAIR__(v5, v4), - sub_407A1C( - v3->vPosition.x, - v3->vPosition.y, - v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75), - *(Vec3_int_ *)v8)) ) + if ( sub_407A1C(v4, v5, v22, v7) || sub_407A1C(v7.x, v7.y, v7.z, Vec3_int_(v4, v5, v22))) { - v10 = pDir; - v11 = 0; - if ( !pDir ) + if ( pDir == nullptr ) + { + v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); + } + else { - v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); - v10 = &v18; - memcpy(&v18, v12, sizeof(v18)); - v11 = 0; + v10 = pDir; } - v13 = pSpriteFrameTable->pSpriteSFrames; v3->uYawAngle = LOWORD(v10->uYawAngle); - v14 = v13[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; - v15 = v21; + v14 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; v3->uCurrentActionLength = 8 * v14; - v3->uCurrentActionTime = v11; + v3->uCurrentActionTime = 0; v3->uAIState = AttackingRanged1; - Actor::PlaySound(v15, 0); - v16 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; + Actor::PlaySound(uActorID, 0); pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v11 - && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v11 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v11) ) + if ( v3->pActorBuffs[7].uExpireTime > 0 ) { - v16 *= 2; - pDira = v16; + pDira *= 2; } if ( pParty->bTurnBasedModeOn == 1 ) - v3->pMonsterInfo.uRecoveryTime = v16; + v3->pMonsterInfo.uRecoveryTime = pDira; else - v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength - - (unsigned int)(signed __int64)(flt_6BE3A8_debug_recmod2 - * (double)(signed int)pDira - * -2.133333333333333); - v3->vVelocity.z = v11; - v3->vVelocity.y = v11; - v3->vVelocity.x = v11; + v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength - (int)(flt_6BE3A8_debug_recmod2 * pDira * -2.133333333333333); + v3->vVelocity.z = 0; + v3->vVelocity.y = 0; + v3->vVelocity.x = 0; v3->UpdateAnimation(); } else - Actor::AI_Pursue1(v21, sTargetPid, v21, 64, pDir); + Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); } //----- (004032B2) --------------------------------------------------------