FreeSpace Releases > Scripting Releases

Zoom script

(1/16) > >>

m!m:
Something I always missed in FS is the ability to zoom in so I can snipe a few precise shots.
I also had 15 minutes left today so I put together this script.

Zoom in using the d key (it was the first key not occupied by default )

Just unzip the file either in its own folder or into the mediavps folder to use it.

Known issues:

* Handling while in zoom is difficult because scripting is unable to manipulate sensitivity
* I haven't tested it very much :P
m!m

EDIT: Find the recent version here: http://www.hard-light.net/wiki/index.php/Script_-_Zoom

The E:
Very nice. Couple of notes, though:

1. It's best to distribute scripts as un-vped versions, IMHO
2. Can you put it on the wiki's scripting examples category?

AFTER fixing these bugs, of course:
-If you press d, zoom in a bit, release it, then press it again while the fov is resetting itself, then release again, the zoom will not wind back properly.

EDIT: Here's the fix. In zoom_key_pressed, do this:

--- Code: ---if runZoomScript then
if not zooming then
plr = hv.Player
if plr:isValid() then
if #gr.Cameras > 0 then
cam = gr.Cameras[1]
if cam:isValid() then
zooming = true
tempFOV = normalFOV
zoom = tempFOV * zoomValue
cam:setFOV(zoom,2,1,0.5)
end
end
end
end
end
--- End code ---

m!m:
Thank you for your feedback The E.

Fixing the mentioned things here is an updated version.
Now it's in one tbm and un-vped.
I'll add it to the wiki once it is sure that the script works correctly (and once i figure out how to do that  :nervous:)

EDIT: look in the wiki for the script

The E:
Here, with a bit more cleanup:

--- Code: ---#Conditional Hooks

$Application: FS2_Open
$On Mission Start:
[
runZoomScript = true
zoomValue = 0.1
normalFOV = 0.75
zooming = false
defaultZoomSet = false
]

$Application: FS2_Open
$On Mission End:
[
runZoomScript = false
]

$State: GS_STATE_GAME_PLAY
$KeyPress: d
$On Key Pressed: [
if runZoomScript then
if not zooming then
plr = hv.Player
if plr:isValid() then
if #gr.Cameras > 0 then
cam = gr.Cameras[1]
if cam:isValid() then
zooming = true
if not defaultZoomSet then
normalFOV = cam.FOV
defaultZoomSet = true
end
zoom = normalFOV * zoomValue
cam:setFOV(zoom,2,1,0.5)
end
end
end
end
end
]

$On Key Released: [
if runZoomScript then
if zooming then
plr = hv.Player
if plr:isValid() then
if #gr.Cameras > 0 then
cam = gr.Cameras[1]
if cam:isValid() then
zooming = false
cam:setFOV(normalFOV,2,1,0.5)
end
end
end
end
end
]

#End
--- End code ---

As for the wiki, you need to make an account, then make a new page with your script, then link it to the scripting examples category. Take a look at the other scripting examples to see how it's done.

Sushi:
Once we have the New Pilot Code and can create new keybindings, I would love to see a native in-code version of Zoom In/Out. We could even include the aforementioned sensitivity reduction. :)

Navigation

[0] Message Index

[#] Next page

Go to full version