Jump to content
Sign in to follow this  

commander special vision

Recommended Posts

when you are commander of a group by pressing dot on numpad you can have a expanded view

is there anyway to add this feature to players who are not commander?

Share this post

Link to post
Share on other sites

The short answer is no. Only group leaders can access the "commander view".

The long answer is it can be fudged, either by modifying the unit's class in its respective config.cpp, or by using a rather extreme camera script.

For the first option you would need to modify or override the unit or a parent class' ViewPilot class. E.g.

class Man:Land

class ViewPilot:ViewPilotBase


This doesn't actually allow you to move the camera toward/away from the unit since the camera is fixed by the extCameraPosition array. What it will do is extend the minimum FOV that you can obtain using the "zoom out" key binding. This will give a "fisheye" effect at extreme FOVs (>0.9). It will also affect first person view as well.

Second option requires a rather complicated script like this:

_unit = _this select 0
hintc "Press V to exit camera control, press L to toggle crosshair, use move up/down/left/right/forward/back to move camera."
_pos = getpos _unit
_theta = ((getdir _unit) +180) mod 360
_r = 4
_phi = 20
_rx = _r * (sin _theta) * (cos _phi)
_ry = _r * (cos _theta) * (cos _phi)
_rz = _r * (sin _phi)
_cx = 0
_cy = 0
_cz = 0
_camera = "camera" camCreate [(_pos select 0) + _rx, (_pos select 1) + _ry, _rz]
_camera cameraEffect ["internal","back"]
_camera camSetTarget _pos
_camera camSetFOV 0.7
_camera camCommit 0
@camCommitted _camera
_campos = GetPos _camera
_i = 0
_pos = getpos _unit
;_pos set[2,1]
_rx = _r * (sin _theta) * (cos _phi)
_ry = _r * (cos _theta) * (cos _phi)
_rz = (_r * (sin _phi)) + (_pos select 2)
_camera camSetPos [(_pos select 0) + _rx, (_pos select 1) + _ry, _rz]
_camera camSetTarget _pos
_camera camcommit 0
@camCommitted _camera
_camera camCommand "Manual on"
_oldpos = getpos _camera
_oldDist = _unit distance _camera
?(_camera != _camera):  goto "end"
_camera camCommand "Manual off"
_newDist = _unit distance _camera
_newpos = getpos _camera
_cz = ((_newpos select 2)-(_oldpos select 2))
;_i = _i + 1
;?(_i == 10): _i = 0; titletext[Format["%1 %2 %3 %4",_cx, _cy, _cz, _theta],"PLAIN DOWN",0.05] 
_phi = _phi + (_cz * 10)
;?((_cz > 0.05) or (_cz < -0.05)): goto "orbit"
_cy = _newDist - _oldDist
_r = _r + (_cy * 2)
?(_r > 40): _r = 40
?((_cy > 0.1) or (_cy < -0.1)): goto "orbit"
?(_newDist < 1): goto "orbit"
_cx = (((_pos select 0) - (_oldpos select 0)) atan2 ((_pos select 1) - (_oldpos select 1)))
_cx = _cx - (((_pos select 0) - (_newpos select 0)) atan2 ((_pos select 1) - (_newpos select 1)))
_theta = _theta - _cx
goto "orbit"

_camera camCommand "Manual on"
_camera cameraEffect ["Terminate","back"]
_camera camcommit 0
@camcommitted _camera
camDestroy _camera

The above code is pushing the game really hard due to the high speed needed to "interlace" camera movements with scripted translations. You could improve the performance by putting the maths either side of the 20 millisecond delay into sqf functions which will remove the overhead caused by parsing the sqs each iteration. I have listed all the code in one script for clarity's sake, although that won't help much if you don't understand how spherical coordinates work :)

The script is called with [player] exec "MyScriptsName.sqs", but you can actually pass a reference to whatever unit you want.

Oh by the way, the script is designed for slow moving or stationary objects. There should a way to cancel out the unit's velocity but I'll leave that open for discussion :P

Edited by *Zeewolf*

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