I don’t know what that is or how it behaves but if you want a hitscan laser that follows the player instead of directly targeting them, I can propose this:
(1) Define a target angle for your enemy’s hitscan as ANGLE3D (e.g. m_aTowardsTarget) and optionally set it to the enemy’s orientation angle on start.
(2) When the enemy begins attacking, calculate an angle towards the target (m_penEnemy in enemy’s case) with a small delay before the actual attack:
FLOAT3D vToTarget = (m_penEnemy->GetPlacement().pl_PositionVector - GetPlacement().pl_PositionVector).Normalize();
ANGLE3D aToTarget;
DirectionVectorToAngles(vToTarget, aToTarget);
m_aTowardsTarget = aToTarget;
(3) During a continuous hitscan in a loop, calculate an angle difference between the current target angle and the angle towards the target. Reuse the same code as in step 2 but instead of setting angle to m_aTowardsTarget, do this:
aToTarget -= m_aTowardsTarget;
aToTarget(1) = NormalizeAngle(aToTarget(1));
aToTarget(2) = NormalizeAngle(aToTarget(2));
m_aTowardsTarget += aToTarget / 2;
Here the difference is divided by 2 to make it follow the target twice as slow. Adjust as needed or even clamp the maximum speed of each angle like this:
aToTarget(1) = Clamp(NormalizeAngle(aToTarget(1)), -30.0f, +30.0f);
(4) Then use the resulting angle in the CCastRay as the source:
CPlacement3D plLaser(vLaserPosRelativeToEnemy, m_aTowardsTarget);
CCastRay crLaser(this, plLaser, 500);
Or if the laser needs to just go from one side to another in the general direction of the player, add an initial angle to that target angle so it starts to the side and just add a specific fixed amount to the angle each loop iteration instead of the difference relative to the target.