Code:
_pos = getpos player
; Cutrsc for opening laptop
;cutrsc["RscLaptopOpen","PLAIN"]
; Setup ammo
_missiles = 14
_missileStatus = "| | | | | | | | | | | | | |"
; Set velocity (300m/s)
_vel = 6
; Setup zoom levels
_currentFOV = 2
_zooms = [0.7,0.4,0.1,0.05]
_panGain = [60,30,10,5]
; setup Night vision
_removeGogs = false
?((Daytime < 17) and (Daytime > 7)) : goto "start"
?!(player hasweapon "NVGoggles"): _removeGogs = true;
player removeweapon "NVGoggles"
player addweapon "NVGoggles"
player action["NVGoggles"]
#start
~0.5
; calculate random azimuth
_theta = random 360
; set radius (500m for MP purposes)
_r = 500
; set polar angle
_phi = (random 30) + 45
; calculate initial cartesian position
_rx = _r * (sin _theta) * (cos _phi)
_ry = _r * (cos _theta) * (cos _phi)
_rz = _r * (sin _phi)
; clear laptop cutrsc
cutrsc["Default","PLAIN"]
; create the camera
_camera = "camera" camCreate [(_pos select 0) + _rx, (_pos select 1) + _ry, _rz]
_camera cameraEffect ["internal","back"]
_camera camSetTarget _pos
_camera camSetFOV 0.1
_camera camCommit 0
@camCommitted _camera
_campos = getPos _camera
; set one minute timer
_timeout = _time + 60
; set random orbit direction
_direction = 1
?(random 2 > 1) : _direction = -1
; set initial camera target
_tx = _pos select 0
_ty = _pos select 1
; initialise frame counter
_i = 0
#orbit
; update azimuth
_theta = _theta + (_direction * 0.0688)
_theta = _theta mod 360
; update cartesian position
_rx = _r * (sin _theta) * (cos _phi)
_ry = _r * (cos _theta) * (cos _phi)
; update camera
_camera camSetPos [(_pos select 0) + _rx, (_pos select 1) + _ry, _rz]
_camera camSetTarget [_tx,_ty,0]
_camera camSetFOV (_zooms select _currentFOV)
_camera camcommit 0
@camCommitted _camera
; set camera to manual until next frame
_camera camCommand "Manual on"
; save current position
_campos = getpos _camera
; wait for next frame
~0.02
; increment frame counter
_i = _i + 1
; display status every ten frames
?(_i == 10): _i = 0; titletext[Format["\nHeading: %1 %2 %3\nAGL: %4 ", (direction _camera) - (direction _camera mod 1),_missileStatus, (_timeout - _time),_campos select 2],"PLAIN DOWN",0.05]
; detect user pressing V
?(_camera != _camera):camdestroy _camera;_ret = "orbit"; goto "zoom"
; turn manual mode off
_camera camCommand "Manual off"
; calculate change in camera position due to user input
_cx = (_panGain select _currentFOV)*((getpos _camera select 0)-(_campos select 0))
_cy = (_panGain select _currentFOV)*((getpos _camera select 1)-(_campos select 1))
_cz = (getpos _camera select 2)-(_campos select 2)
; update target position
_tx = _tx + _cx
_ty = _ty + _cy
; calculate change in height due to user input
?((_cz < -0.05) and (_cx == 0) and (_cy == 0)): goto "fire"
?((_cz > 0.05) and (_cx == 0) and (_cy == 0)): _ret = "orbit"; goto "zoom"
; check for timeout and player death
?((_timeout > _time) and (alive player)) : goto "orbit"
; reset nightvision
?(_removeGogs) : player removeweapon "NVGoggles"
; terminate and destroy camera
_camera cameraEffect ["Terminate","back"]
_camera camcommit 0
@camcommitted _camera
camDestroy _camera
; Laptop close animation requires custom reversed .rtm
;cutrsc["RscLaptopClose","PLAIN"]
~0.5
; clear laptop cutrsc
cutrsc["Default","PLAIN"]
exit
#fire
; update ammo status display
_i = 0
_missileStatus = ""
_missiles = _missiles - 1
?(_missiles == 0): _missileStatus = " "; goto "calculateShot"
#updateStatus1
_missileStatus = format["%1| ",_missileStatus]
_i = _i + 1
?(_i < _missiles): goto "updateStatus1"
#updateStatus2
_missileStatus = format["%1 ",_missileStatus]
_i = _i + 1
?(_i < 14): goto "updateStatus2"
#calculateShot
; calculate azimuth and polar angle for missile
_mphi = (_campos select 2) atan2 _distance
_mtheta = _rx atan2 _ry
; calculate velocity vector for missile
_vx = _vel * (cos _mphi) * -(sin _mtheta)
_vy = _vel * (cos _mphi) * -(cos _mtheta)
_vz = _vel * (sin _mphi)
; calculate distance to target
_dx = (_campos select 0)-_tx
_dy = (_campos select 1)-_ty
; set initial missile position
_mx = _campos select 0
_my = _campos select 1
_mz = _campos select 2
; reset frame counter
_i = 0
#home
; update camera
_camera camSetPos [(_pos select 0) + _rx, (_pos select 1) + _ry, _rz]
_camera camSetTarget [_tx,_ty,0]
_camera camCommit 0
@camCommitted _camera
; update camera azimuth
_theta = _theta + (_direction * 0.0688)
_theta = _theta mod 360
; update camera position
_rx = _r * (sin _theta) * (cos _phi)
_ry = _r * (cos _theta) * (cos _phi)
; save camera position
_campos = GetPos _camera
; set manual mode to detect user input
_camera camCommand "Manual on"
; update distance to target
_dx = _mx-_tx
_dy = _my-_ty
_distance = (sqrt((_dx^2)+(_dy^2)))
; update missile azimuth and polar angle
_mphi = _mz atan2 _distance
_mtheta = _dx atan2 _dy
; update missile velocity vector
_vx = _vel * (cos _mphi) * - (sin _mtheta)
_vy = _vel * (cos _mphi) * - (cos _mtheta)
_vz = _vel * (sin _mphi)
; update missile position
_mx = _mx + _vx
_my = _my + _vy
_mz = _mz - _vz
; create Nikiller missile smoke
drop ["cl_basic","","Billboard",10,random(3)+3,[_mx,_my+(random 2)-1,_mz],[(random 3)-1.5,(random 3)-1.5,(random 3)-1.5],0,1.22,1,0.2,[1,5],[[0.95,0.95,0.95, 0.15],[0.95,0.95, 0.95,0]],[0],0.75,0.5,"","",""];
~0.02
; increment frame counter
_i = _i + 1
; update status display every ten frames
?(_i == 10): _i = 0; titletext[Format["\nHeading: %1 %2 %3\nAGL: %4 %5 ", (direction _camera) - (direction _camera mod 1),_missileStatus, (_timeout - _time),_campos select 2,_mz],"PLAIN DOWN",0.05]
; detect change in camera position due to user input
_cx = (_panGain select _currentFOV)*((getpos _camera select 0)-(_campos select 0))
_cy = (_panGain select _currentFOV)*((getpos _camera select 1)-(_campos select 1))
_cz = (getpos _camera select 2)-(_campos select 2)
; update camera target
_tx = _tx + _cx
_ty = _ty + _cy
; detect change in camera height due to user input
?((_cz > 0.05) and (_cx == 0) and (_cy == 0)): _ret = "home"; goto "zoom"
?(_camera != _camera):camdestroy _camera;_ret = "home"; goto "zoom"
; switch manual mode off
_camera camCommand "Manual off"
; loop until missile hits ground
?(_mz > 1) : goto "home"
; spawn warhead
_bang = "maverick" createvehicle [_tx, _ty,0]
; if ammo remaining continue orbit
?(_missiles > 0): goto "orbit"
; reset nightvision
?(_removeGogs) : player removeweapon "NVGoggles"
; terminate and destroy camera
_camera cameraEffect ["Terminate","back"]
_camera camcommit 0
@camcommitted _camera
camDestroy _camera
; laptop close animation requires custom .rtm
;cutrsc["RscLaptopClose","PLAIN"]
~0.5
; clear laptop cutrsc
cutrsc["Default","PLAIN"]
exit
#zoom
; update FOV selection
_currentFOV = _currentFOV + 1
; clip FOV selection
?(_currentFOV == count _zooms): _currentFOV = 0
; black out camera
titletext["","BLACK IN",10];
; destroy old camera
camdestroy _camera
; create a new camera
_camera = "camera" camcreate _campos
_camera cameraEffect ["internal","back"]
_camera camSetTarget _pos
_camera camSetFOV (_zooms select _currentFOV)
_camera camCommit 0
@camcommitted _camera
~0.1
; black back in
titletext["","BLACK IN",0.1]
; return to caller
goto _ret
I'm sure you'll agree the missile smoke looks very nice, trouble is there is no solid object in front of it. I don't want to spawn a real missile or shell on the front of it and move it around or apply relative acceleration, because the whole purpose of this style of scripting is to cut down on bandwidth intensive commands like setpos and setvelocity. Any ideas on a way to put a solid looking object on the front of the smoke trail without broadcasting its position to other clients?