Jump to content

[REQ] Dynamic or Toggle FOV


vinniewryan

Recommended Posts

Hello, I have a simple idea that I think can be done with a few lines of SKSE or Script Dragon based code. Oh, how simple you ask? This simple.

 

When you hold 'A-button' or 'E-key' or whatever button you have set as activate, the FOV goes down to like 43. Then when you release, it goes back out to 90 or whatever.

It would be good to have an ini file where the user can set the zoom and normal FOV. Also, would be good to be able to change the button this script looks for, so players who use different key configurations can still use it.

 

Further, it would be nice if when you hold 'E', it softly transitions from normal to zoomed FOV, similar to when you sprint and the FOV goes up slightly.

 

If this is possible I would love to have this feature for taking screenshots, placing objects around the world, looking at things close up, and trying to make out objects in the distance (identifying enemies, creatures, etc)

 

I think when you zoom with a bow, it does this exactly, so maybe its as easy as attaching that camera path to the 'activate' key/button.

 

Thoughts?

Link to comment
Share on other sites

With some help, I came up with a script. now I'm working on applying it. Later once this works, I'll remove the debugging and make the FOV transition smooth instead of instant.

 

Edit: I fixed the compile errors. Now I'm setting up a Game Start quest to run it and test.

Addition: I ran the game, the quest started and printed the initialization text, however it did not print the correct value for the FOV saved in the ini.

 

It was suggested that I attach the player as an alias to the quest which has this script attached. I created a new alias and under Fill Type, I selected 'Player'.

I'm not sure exactly what that did or if it helped anything at all, so I'll be researching this a bit more. There isn't nearly enough documentation online for working with the CK.

 

Here is my init function:

Event OnInit()
fDFOV = Utility.GetIniInt("fdefaultfov:General")
     Debug.Notification("FOV Initialized, FOV = " + fDFOV)
EndEvent

 

It's printing 0.000 as the result :/

Edited by vinniewryan
Link to comment
Share on other sites

ScriptName vwrFOVScript Extends Quest

Float Property MinFOV = 43.0 Auto
Float Property MaxFOV = 80.0 Auto
Float Property fDFOV = 4.0 Auto
Float Property CurrentFOV = 0.0 Auto
Int Property iHotkey = 184 Auto

Event OnInit()
fDFOV = Utility.GetIniInt("fdefaultfov:General")
Debug.Notification("FOV Initialized, FOV = " + fDFOV)
EndEvent

Event OnKeyDown(Int KeyCode)
If KeyCode == iHotkey
    		Debug.Notification("Alt Pressed")
    		StillHolding()
    	endif
EndEvent

Function StillHolding()
Utility.Wait(0.3)

        if (Input.IsKeyPressed(iHotkey))
             Debug.Notification("Alt Held!")
             if( CurrentFOV > MinFOV )
                ZoomOut()
             else
                ZoomIn()
             endif
        endif
EndFunction

Function ZoomIn()
    Utility.SetINIfloat("fdefaultfov:General", MinFOV)
    CurrentFOV=MinFOV
EndFunction

Function ZoomOut()
    Utility.SetINIfloat("fdefaultfov:General", MaxFOV)
    CurrentFOV=MaxFOV
EndFunction

Link to comment
Share on other sites

ScriptName vwrFOVScript Extends Quest

import Utility
import input

float Property MinFOV = 43.0000 Auto
float Property MaxFOV = 80.0000 Auto
float Property CurrentFOV = 43.0000 Auto
Int Property iHotkey = 18 Auto

Function SetCameraFOV(float float1) native global

Function ZoomIn()
   SetCameraFOV(MinFOV)
   Debug.Notification("in")
   CurrentFOV = MinFOV
EndFunction

Function ZoomOut()
   SetCameraFOV(MaxFOV)
   Debug.Notification("out")
   CurrentFOV = MaxFOV
EndFunction

Function StillHolding()
   Wait(0.6)

if (IsKeyPressed(iHotkey))
       if CurrentFOV == MaxFOV
           ZoomIn()
       else
           ZoomOut()
       endif
   endif
EndFunction

Event OnUpdate()
if (IsKeyPressed(iHotkey))
	Debug.Notification("E")
	StillHolding()
EndIf

RegisterForSingleUpdate(0.1000)
EndEvent

Event OnInit()
   Debug.Notification("FOV Initialized")
   RegisterForSingleUpdate(0.1000)
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...