Jump to content
Sign in to follow this  
lonesoldier

Making a missile lock on in a cutscene...

Recommended Posts

Ok, Heres what i need to do:

In my missions intro it starts with a missile CamCreated and the camera follows it, but when the chopper flys past the missile hits it on the odd occasion. so how can i make the missile lock onto it? The missile is CamCreated remember. Also whats the command to make a unit kneeling with a rocket launcher? Because the missile is cam createdbut i need a guy to be holding the rocket launcher so it looks like he fired the missile.

Thanks in advance. Oh one more thing. In my intro.sqs how do i make the binocular view on the camera lens? So it looks like its through binocs...

Share this post


Link to post
Share on other sites

*bump*

Come on, dont ignore this thread, surely someone knows how. I NEED to know, it is essential.

Share this post


Link to post
Share on other sites

first question: I'd like to know the answer, myself: (not possible, afaik)

second question: unitname selectWeapon "lawlauncher"

it also helps to set the unit to combat mode: unitname setBehaviour "combat"

third question: cutRsc ["binocular", "PLAIN"], you will want to remove the cinematic bars beforehand: showCinemaBorder false

don't forget to turn the cinematic bars back on when you cut from binocular: cutRsc ["", "PLAIN"] showCinemaBorder true

blalalalal

dismas?

Share this post


Link to post
Share on other sites

for question 1:

You need to update the position of the Helo with a loop, so the cam always follows the actual position of the Helo.

There was a cam-script for a camera attached to a vehicle at Edcentrer, but the page seems to be currently down.

Maybe there is a topic here at the forums also that explains, how to automatically update the cam´s position relatively to a moving target. This would solve your problem.

Share this post


Link to post
Share on other sites

Heres a "guided missle" script made by sefe:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Guided missile script v1.1

;by SEFE

_Target = _this Select 0

_MissileType = _this Select 1

_MissilePos = _this Select 2

_MissileDir = _this Select 3

_MissileElev = _this Select 4

_LockAngle = _this Select 5

_SAM = _this Select 6

_Internal = _this Select 7

SetAccTime 1

_LockedOn = TRUE

;Create missile

_Missile = _MissileType CamCreate [_MissilePos Select 0, _MissilePos Select 1, 1000]

_Missile SetDir _MissileDir

;Create tracking object (needed to calculate the missile's barometric altitude - also used in terrain following mode) - GetPos returns the altitude AGL but SetPos expects the barometric altitude

_Tracker = "PipeBomb" CamCreate [_MissilePos Select 0, _MissilePos Select 1, 0]

~0.2

;Calculate initial missile altitude

_InitialMisAlt = (_MissilePos Select 2)

_Tracker SetPos [_MissilePos Select 0, _MissilePos Select 1, 0]

_MissileAlt = _InitialMisAlt - ((GetPos _Tracker) Select 2)

;Set initial missile position

_Missile SetPos [_MissilePos Select 0, _MissilePos Select 1, _MissileAlt]

;Get initial target altitude

_TargetPos = GetPos _Target

_Tracker SetPos [_TargetPos Select 0, _TargetPos Select 1, 0]

_TargetAlt = (_TargetPos Select 2) - ((GetPos _Tracker) Select 2)

;Get the missile's initial distance to target

_DistanceToTarget = _Missile Distance _Target

_DeltaTargDist = 0

;Init the missile's lock angle

_LockAngle = _LockAngle / 2

;Init the missile's vertical angle

? _MissileElev > 70 : _MissileElev = 70

? _MissileElev < -70 : _MissileElev = -70

;View through missile camera

? _Internal : _Missile CameraEffect["INTERNAL", "BACK"]

#CalculateTrajectory

;Get the positions and altitudes of the target and the missile

_MissilePos = GetPos _Missile

_TargetPos = GetPos _Target

_Tracker SetPos [_MissilePos Select 0, _MissilePos Select 1, 0]

_MissileAlt = (_MissilePos Select 2) - ((GetPos _Tracker) Select 2)

_Tracker SetPos [_TargetPos Select 0, _TargetPos Select 1, 0]

_OldTargetAlt = _TargetAlt

_TargetAlt = (_TargetPos Select 2) - ((GetPos _Tracker) Select 2)

;Get the missile speed

_MissileSpeed = Speed _Missile

;Get the missile's direction

_MissileDir = GetDir _Missile

;Get the missile's distance to the target

;_OldDistanceToTarget = _DistanceToTarget

;_DistanceToTarget = _Missile Distance _Target

;_DeltaTargDist = _DistanceToTarget - _OldDistanceToTarget

;Get the missile's horizontal angle to the target (using trigonometry)

_DeltaX = (_TargetPos Select 0) - (_MissilePos Select 0)

_DeltaY = (_TargetPos Select 1) - (_MissilePos Select 1)

? (_DeltaY == 0) && (_DeltaX >= 0) : _TargetAngle = 90

? (_DeltaY == 0) && (_DeltaX < 0) : _TargetAngle = 270

? _DeltaY > 0 : _TargetAngle = ATan (_DeltaX / _DeltaY)

? _DeltaY < 0 : _TargetAngle = ATan (_DeltaX / _DeltaY) + 180

? _TargetAngle < 0 : _TargetAngle = _TargetAngle + 360

;If it is an AA missile, we have to guide it to the interception point, not to the target itself (using even more trigonometry)

? not _SAM : Goto "NoDeflectionShooting"

;Calculate the deflection angle and add it to the target angle

? _MissileSpeed != 0 : _TargetAngle = _TargetAngle + ASin ((Sin ((GetDir _Target) - _TargetAngle)) * (Speed _Target) / _MissileSpeed)

#NoDeflectionShooting

;Get the horizontal angle between the missile's direction and the target

_RelTargetAngle = _TargetAngle - _MissileDir

? _RelTargetAngle > 180 : _RelTargetAngle = _RelTargetAngle - 360

? _RelTargetAngle < -180 : _RelTargetAngle = 360 - _RelTargetAngle

;Calculate the missiles horizontal angle change

_HorzDelta = _RelTargetAngle

? (_HorzDelta > 4) && _SAM : _HorzDelta = 4

? (_HorzDelta < -4) && _SAM : _HorzDelta = -4

? (_HorzDelta > 2) && not _SAM : _HorzDelta = 2

? (_HorzDelta < -2) && not _SAM : _HorzDelta = -2

;Check if the missile has lost it's horizontal lock

? (Abs _RelTargetAngle) > _LockAngle : _HorzDelta = 0; _LockedOn = FALSE

;Calculate the missile's new direction

_NewMissileDir = (GetDir _Missile) + _HorzDelta

;Roughly calculate the missile's horizontal position in the next cycle (needed to evade obstacles on the ground)

_MissileVector = _DeltaTargDist

? _MissileVector > _DistanceToTarget : _MissileVector = _DistanceToTarget

_NextMissileX = (_MissilePos Select 0) + (Sin _NewMissileDir) * _MissileVector

_NextMissileY = (_MissilePos Select 1) + (Cos _NewMissileDir) * _MissileVector

;Calculate the ground elevation at the missile's next horizontal position

_Tracker SetPos [_NextMissileX, _NextMissileY, 0]

_NextGroundElev = -((GetPos _Tracker) Select 2)

;Define vertical flight path (guess... using trigonometry)

;The flight path is calculated differently for AA and AG missiles

? not _SAM : Goto "CalcAGMissile"

;Get the missile's vertical flight angle to the target

_DeltaZ = (_TargetAlt - _MissileAlt) + 3

;An AA missile will try to reach the target altitude as quickly as possible

? (_DistanceToTarget == 0) && (_DeltaZ >= 0) : _ClimbAngle = 90

? (_DistanceToTarget == 0) && (_DeltaZ < 0) : _ClimbAngle = -90

? _DistanceToTarget != 0 : _ClimbAngle = ATan (_DeltaZ / _DistanceToTarget)

? (_DeltaZ > 40) : _ClimbAngle = 30

? (_DeltaZ > 60) : _ClimbAngle = 45

? (_DeltaZ > 80) : _ClimbAngle = 60

? (_DeltaZ < -40) : _ClimbAngle = -30

? (_DeltaZ < -60) : _ClimbAngle = -45

? (_DeltaZ < -80) : _ClimbAngle = -60

;Calculate vertical deflection

? _DeltaTargDist != 0 : _ClimbAngle = _ClimbAngle - (ATan ((_OldTargetAlt - _TargetAlt) / _DeltaTargDist))

;Avoid obstacles on the ground

_MinAltitude = 8

? _DistanceToTarget < 150 : _MinAltitude = 0

? (_TargetPos Select 2) < _MinAltitude : _MinAltitude = (_TargetPos Select 2)

_MinElev = -70

? _MissileVector != 0: _MinElev = ATan((_MinAltitude + _NextGroundElev - _MissileAlt) / _MissileVector)

? _ClimbAngle < _MinElev : _ClimbAngle = _MinElev

Goto "CalcVertAngle"

#CalcAGMissile

;An AG missile will follow the terrain until it's near the target

? _DistanceToTarget < ((_MissilePos Select 2) * 8) : Goto "FinalSequence"

_DeltaZ = _InitialMisAlt - (_MissilePos Select 2)

;An AG missile will try to keep it's initial height

? (_MissileVector == 0) && (_DeltaZ >= 0) : _ClimbAngle = 90

? (_MissileVector == 0) && (_DeltaZ < 0) : _ClimbAngle = -90

? _MissileVector != 0 : _ClimbAngle = ATan (_DeltaZ / _MissileVector)

? (_DeltaZ > 40) : _ClimbAngle = 30

? (_DeltaZ < -40) : _ClimbAngle = -30

;Follow terrain elevations

? _MinElev = -70

? _MissileVector != 0 : _MinElev = ATan((_InitialMisAlt + _NextGroundElev - _MissileAlt) / _MissileVector)

? _ClimbAngle < _MinElev : _ClimbAngle = _MinElev

Goto "CalcVertAngle"

#FinalSequence

_DeltaZ = (_TargetAlt - _MissileAlt) + 1

? (_DistanceToTarget == 0) && (_DeltaZ >= 0) : _ClimbAngle = 90

? (_DistanceToTarget == 0) && (_DeltaZ < 0) : _ClimbAngle = -90

? _DistanceToTarget != 0 : _ClimbAngle = ATan (_DeltaZ / _DistanceToTarget)

#CalcVertAngle

;Get the vertical angle between the missile's direction and it's vertical flight path

_RelTargetElevation = _ClimbAngle - _MissileElev

? _RelTargetElevation > 180 : _RelTargetElevation = _RelTargetElevation - 360

? _RelTargetElevation < -180 : _RelTargeElevation = 360 - _RelTargetElevation

;Calculate the missiles vertical angle change

_VertDelta = _RelTargetElevation

? _VertDelta > 4 && _SAM : _VertDelta = 4

? _VertDelta < -4 && _SAM : _VertDelta = -4

? _VertDelta > 1 && not _SAM : _VertDelta = 6

? _VertDelta < -1 && not _SAM : _VertDelta = -6

;Check if the missile has lost it's vertical lock

? (Abs _RelTargetElevation) > _LockAngle : _VertDelta = 0; _LockedOn = FALSE

;Calculate the missile's new vertical direction

_MissileElev = _MissileElev + _VertDelta

? _MissileElev > 70 : _MissileElev = 70

? _MissileElev < -70 : _MissileElev = -70

;Apply all changes to the missile's trajectory

;Change the missile's horizontal direction

_Missile SetDir _NewMissileDir

;Change the missile's altitude

_OldDistanceToTarget = _DistanceToTarget

~0.005

_MissilePos = GetPos _Missile

_DistanceToTarget = _Missile Distance _Target

_DeltaTargDist = Abs(_DistanceToTarget - _OldDistanceToTarget)

_MissileAlt = _MissileAlt + (Tan(_MissileElev) * _DeltaTargDist)

;Set the missile's new position

_Missile SetPos [_MissilePos Select 0, _MissilePos Select 1, _MissileAlt]

;Loop to next scan cycle

? (Speed _Missile > 0) : Goto "CalculateTrajectory"

;Reset cam mode

? _Internal : _Missile CameraEffect["TERMINATE", "BACK"]

;Destroy missile

CamDestroy _TrackingMissile

CamDestroy _Missile

Exit<span id='postcolor'>

Ahem...ok. Well enjoy! Oh and when is my lovely OFPEC coming back to us with its brand spanking new stuff! wow.gif

tounge.gif PEACE

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×