require(GlobalDependencys:GetDependency("StandardBase"):GetPackageName())

--GAME VARS
fAdditionalFPFOV = 0
fAdditionalTPFOV = 0
fAdditionalDialogFOV = 0
fAdditionalWeaponFOV = 0
fHUDSafeZoneX = 0
fHUDSafeZoneY = 0
Default_Auto = 2.388888836
Default_FPFOV = 0
Default_TPFOV = 0
Default_Safe_Zone_X = 0
Default_Safe_Zone_Y = 0
fAspectRatio = DisplayInfo:GetWidth() / DisplayInfo:GetHeight()

--ControlVars
bFixEnabled = true
bFPFOV = false
bTPFOV = false
bDialogFOV = false
bWeaponFOV = false
bHUD = false
bAspect = false
bPhotoMode = true
AdditionalFPFOV = 1.0

--PROCESS VARS
Process_FriendlyName = Module:GetFriendlyName()
Process_WindowName = "*"
Process_ClassName = "*"
Process_EXEName = "starfield.exe"

--INJECTION BEHAVIOUR
InjectDelay = 100
WriteInterval = 500
SearchInterval = 2000
SuspendThread = false

--Name                         Manual/Auto/Hybrid  		Steam/Origin/Any                IncludeFile:Configure;Enable;Periodic;Disable;
SupportedVersions = { 		
{"Automatically Detect",       "Hybrid",  			"Any",	                         "Configure_SignatureScan;Enable_Inject;Periodic;Disable_Inject;"},
}

function Init_Controls()

	DefaultControls.AddHeader("Header_FixesEnableDisable","Individual Fixes",245,70,210,17)	
	DefaultControls.AddFixToggle("CKFPFOVAdjustment_Enable","1st person FOV Adjustment","CKFPFOV_Changed",255,100,180,14)
	DefaultControls.AddFixToggle("CKTPFOVAdjustment_Enable","3rd person FOV Adjustment","CKTPFOV_Changed",255,120,180,14)
	DefaultControls.AddFixToggle("CKDIALOGFOVAdjustment_Enable","Dialog FOV Adjustment","CKDIALOGFOV_Changed",255,140,180,14)
	DefaultControls.AddFixToggle("CKWEAPONFOVAdjustment_Enable","Weapon FOV Adjustment","CKWEAPONFOV_Changed",255,160,180,14)
	DefaultControls.AddFixToggle("CKDisableLetterBox_Enable","Override aspect limitation","CKAspect_Changed",255,180,180,14)
	DefaultControls.AddFixToggle("CKHUDSafeZone_Enable","HUD Safe zone adjustment","CKHUDSafeZone_Changed",255,200,180,14)
	DefaultControls.AddFixToggle("CKPhotoMode_Enable","Disable photomode black bars","CKPhotoMode_Changed",255,220,190,14)
	
	DefaultControls.AddHeader("Header_FPFOV","1st person FOV Fine adjustment",15,70,210,17)
	DefaultControls.AddFixedFOVSlider("FPFOVSlider","FPFOVSlider_Changed",55,100,125,35,0,40,0,1)
	
	FPFOVSlider:SetTickFrequency(10)
	FPFOVSlider:SetLabel1Text("0")
	FPFOVSlider:SetLabel2Text("40")

	DefaultControls.AddHeader("Header_TPFOV","3rd person FOV Fine adjustment",15,155,210,17)
	DefaultControls.AddFixedFOVSlider("TPFOVSlider","TPFOVSlider_Changed",55,185,125,35,0,90,0,1)

	TPFOVSlider:SetTickFrequency(10)
	TPFOVSlider:SetLabel1Text("0")
	TPFOVSlider:SetLabel2Text("90")

	DefaultControls.AddHeader("Header_WEAPONFOV","Weapon FOV Fine adjustment",15,270,210,17)
	DefaultControls.AddFixedFOVSlider("WEAPONFOVSlider","WEAPONFOVSlider_Changed",55,300,125,35,0,50,0,1)

	WEAPONFOVSlider:SetTickFrequency(10)
	WEAPONFOVSlider:SetLabel1Text("0")
	WEAPONFOVSlider:SetLabel2Text("50")

	DefaultControls.AddHeader("Header_DIALOGFOV","Dialog FOV Fine adjustment",245,270,210,17)
	DefaultControls.AddFixedFOVSlider("DIALOGFOVSlider","DIALOGFOVSlider_Changed",245,300,125,35,0,70,0,1)

	DIALOGFOVSlider:SetTickFrequency(10)
	DIALOGFOVSlider:SetLabel1Text("0")
	DIALOGFOVSlider:SetLabel2Text("70")
	
	DefaultControls.AddHeader("Header_SZONEX","HUD width scaling",15,360,210,17)
	DefaultControls.AddFixedFOVSlider("SZONEXFOVSlider","SZONEXFOVSlider_Changed",55,390,125,35,0,80,0,1)

	SZONEXFOVSlider:SetTickFrequency(10)
	SZONEXFOVSlider:SetLabel1Text("0")
	SZONEXFOVSlider:SetLabel2Text("80")

	DefaultControls.AddHeader("Header_SZONEY","HUD height scaling",245,360,210,17)
	DefaultControls.AddFixedFOVSlider("SZONEYFOVSlider","SZONEYFOVSlider_Changed",245,390,125,35,0,80,0,1)

	SZONEYFOVSlider:SetTickFrequency(10)
	SZONEYFOVSlider:SetLabel1Text("0")
	SZONEYFOVSlider:SetLabel2Text("80")

end

function Configure_SignatureScan() 
		
	local tAddress = HackTool:AddAddress("FPFOV")
	if HackTool:SignatureScan("E8 ?? ?? ?? ?? C4 C1 ?? ?? ?? ?? ?? ?? ?? B1 ?? E8",tAddress,PAGE_EXECUTE_READ,0x0,Process_EXEName) == 0 then	
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else	
		--Starfield.exe+2873F25 - 48 8B CE              		- mov rcx,rsi
		--Starfield.exe+2873F28 - E8 73 EE FF FF           		- call Starfield.exe+2872DA0
		--Starfield.exe+2873F2D - E8 EA 3A 71 FF           		- call Starfield.exe+1F87A1C
		--Starfield.exe+2873F32 - C4 C1 7A 11 86 60 02 00 00  	- vmovss [r14+00000260],xmm0
		--Starfield.exe+2873F3B - 48 8B CE              		- mov rcx,rsi
		print( tAddress:GetInfo(TYPE_ADDRESS) )
	end
	
	local tAddress = HackTool:AddAddress("TPFOV")
	if HackTool:SignatureScan("E8 ?? ?? ?? ?? C4 C1 ?? ?? ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C5 ?? ?? ?? 48 8B",tAddress,PAGE_EXECUTE_READ,0x0,Process_EXEName) == 0 then
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else	
		--Starfield.exe+2883593 - E8 5C E1 FF FF           		- call Starfield.exe+28816F4
		--Starfield.exe+2883598 - B1 01                 		- mov cl,01
		--Starfield.exe+288359A - E8 E9 44 70 FF           		- call Starfield.exe+1F87A88
		--Starfield.exe+288359F - C4 C1 7A 11 86 60 02 00 00  	- vmovss [r14+00000260],xmm0
		--Starfield.exe+28835A8 - E8 B3 CD FF FF           		- call Starfield.exe+2880360
		print( tAddress:GetInfo(TYPE_ADDRESS) )
	end

	local tAddress = HackTool:AddAddress("WeaponFOV")
	if HackTool:SignatureScan("80 3D ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? C5 FA",tAddress,PAGE_EXECUTE_READ,0x07,Process_EXEName) == 0 then
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else
		--Starfield.exe+1F817A2 - E8 65 92 8E 00           - call Starfield.exe+286AA0C
		--Starfield.exe+1F817A7 - 80 3D CA F5 98 03 00     - cmp byte ptr [Starfield.exe+5910D78],00
		--Starfield.exe+1F817AE - 48 8B 05 23 C9 76 03     - mov rax,[Starfield.exe+56EE0D8]
		--Starfield.exe+1F817B5 - C5 FA 11 80 D8 02 00 00  - vmovss [rax+000002D8],xmm0
		--Starfield.exe+1F817BD - 48 8B 05 DC 31 9B 03     - mov rax,[Starfield.exe+59349A0]
		print( tAddress:GetInfo(TYPE_ADDRESS) )
	end
	
	local tAddress = HackTool:AddAddress("Aspect")
	if HackTool:SignatureScan("C5 FA ?? ?? ?? ?? ?? ?? C5 FA ?? ?? ?? ?? ?? ?? C5 F8 ?? ?? 76 ?? C5 E2 ?? ??",tAddress,PAGE_EXECUTE_READ,0x0,Process_EXEName) == 0 then
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else
		--Starfield.exe+2DFE45F - C5 F8 28 C1              	- vmovaps xmm0,xmm1
		--Starfield.exe+2DFE463 - EB 10                 	- jmp Starfield.exe+2DFE475
		--Starfield.exe+2DFE465 - C5 FA 10 0D C3 3B 7E 02   - vmovss xmm1,[Starfield.exe+55E2030]
		--Starfield.exe+2DFE46D - C5 FA 10 05 DB 3B 7E 02   - vmovss xmm0,[Starfield.exe+55E2050]
		--Starfield.exe+2DFE475 - C5 F8 2F D1              	- vcomiss xmm2,xmm1
		print( tAddress:GetInfo(TYPE_ADDRESS) )		
		tAddress:AcquireAddress(0x4)		
		print( tAddress:GetInfo(TYPE_FLOAT) )		
		Default_Auto = tAddress:ReadFloat()
		tAddress:SetAutoUnprotect(true)	
	end

	local tAddress = HackTool:AddAddress("DialogFOV")
	if HackTool:SignatureScan("74 ?? C5 FA ?? ?? ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8D",tAddress,PAGE_EXECUTE_READ,0x0,Process_EXEName) == 0 then								   
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else
		--Starfield.exe+1A55802 - C5 FA 11 85 A8 01 00 00   - vmovss [rbp+000001A8],xmm0
		--Starfield.exe+1A5580A - F6 87 A4 00 00 00 08     	- test byte ptr [rdi+000000A4],08
		--Starfield.exe+1A55811 - 74 0D                 	- je Starfield.exe+1A55820
		--Starfield.exe+1A55813 - C5 FA 10 35 4D 06 B1 03  	- vmovss xmm6,[Starfield.exe+5565E68]
		--Starfield.exe+1A5581B - E9 C9 00 00 00           	- jmp Starfield.exe+1A558E9
		local DialogFOV_1 = HackTool:AddAddress("DialogFOV_1", tAddress)
		local DialogFOV_2 = HackTool:AddAddress("DialogFOV_2", tAddress)
		DialogFOV_1:OffsetAddress(0xa)

		print( DialogFOV_1:GetInfo(TYPE_ADDRESS) )	
		print( DialogFOV_2:GetInfo(TYPE_ADDRESS) )
	end

	local tAddress = HackTool:AddAddress("SafeZone")
	if HackTool:SignatureScan("C5 F8 ?? ?? ?? ?? ?? ?? 76 ?? C4 E1",tAddress,PAGE_EXECUTE_READ,0x0a,Process_EXEName) == 0 then
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else
		--Starfield.exe+2E70AE8 - C5 F8 2F 0D A8 01 92 01    	- vcomiss xmm1,[Starfield.exe+4790C98]
		--Starfield.exe+2E70AF0 - 76 14                 		- jna Starfield.exe+2E70B06
		--Starfield.exe+2E70AF2 - C4 E1 FA 2C 0D 85 50 77 02  	- vcvttss2si rcx,[Starfield.exe+55E5B80]
		--Starfield.exe+2E70AFB - C4 E1 FA 2C 15 9C 50 77 02  	- vcvttss2si rdx,[Starfield.exe+55E5BA0]
		--Starfield.exe+2E70B04 - EB 12                 		- jmp Starfield.exe+2E70B18
		
		local SafeZoneX = HackTool:AddAddress("SafeZoneX", tAddress)
		local SafeZoneY = HackTool:AddAddress("SafeZoneY", tAddress)
		SafeZoneY:OffsetAddress(0x9)		
		
		print( SafeZoneX:GetInfo(TYPE_ADDRESS) )		
		SafeZoneX:AcquireAddress(0x5)		
		print( SafeZoneX:GetInfo(TYPE_FLOAT) )		
		Default_Safe_Zone_X = SafeZoneX:ReadFloat()
		SafeZoneX:SetAutoUnprotect(true)
		
		print( SafeZoneY:GetInfo(TYPE_ADDRESS) )		
		SafeZoneY:AcquireAddress(0x5)		
		print( SafeZoneY:GetInfo(TYPE_FLOAT) )		
		Default_Safe_Zone_Y = SafeZoneY:ReadFloat()
		SafeZoneY:SetAutoUnprotect(true)	
	end
	
	local tAddress = HackTool:AddAddress("PhotoMode")
	if HackTool:SignatureScan("C7 47 ?? ?? ?? ?? ?? C6 ?? ?? ?? EB ?? 38",tAddress,PAGE_EXECUTE_READ,0x0,Process_EXEName) == 0 then
		return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
	else
		--Starfield.exe+2E79A9E - 48 8B 0D 33 46 87 02  - mov rcx,[Starfield.exe+56EE0D8]
		--Starfield.exe+2E79AA5 - 48 83 C1 08           - add rcx,08
		--Starfield.exe+2E79AA9 - C7 41 44 39 8E E3 3F  - mov [rcx+44],3FE38E39
		--Starfield.exe+2E79AB0 - C6 41 42 01           - mov byte ptr [rcx+42],01
		--Starfield.exe+2E79AB4 - EB 16                 - jmp Starfield.exe+2E79ACC
		print( tAddress:GetInfo(TYPE_ADDRESS) )
	end

	return true

end


function Enable_Inject() 

	local Variables = HackTool:AllocateMemory("Variables",0)
	Variables:PushFloat("FOVFP_In")
	Variables:PushFloat("FOVFP_Out")
	Variables:PushFloat("FOVTP_In")
	Variables:PushFloat("FOVTP_Out")
	Variables:PushFloat("FOVDialog_In")
	Variables:PushFloat("FOVDialog_Out")
	Variables:PushFloat("FOVWeapon_In")
	Variables:PushFloat("FOVWeapon_Out")
	Variables:PushFloat("AdditionalFPFOV")
	Variables:PushFloat("AdditionalTPFOV")
	Variables:PushFloat("AdditionalDialogFOV")
	Variables:PushFloat("AdditionalWeaponFOV")
	Variables:PushFloat("AspectRatio")
	Variables:Allocate()
	Variables["AspectRatio"]:WriteFloat(fAspectRatio)
	
	ResolutionChanged()
	

	asm = [[	
		
		(codecave:jmp)FPFOV,FPFOV_cc:
			%originalcode%
			movss [(allocation)Variables->FOVFP_In],xmm0
			addss xmm0, [(allocation)Variables->AdditionalFPFOV]
			movss [(allocation)Variables->FOVFP_Out],xmm0
			jmp %returnaddress%
			%end%
			
		(codecave:jmp)TPFOV,TPFOV_cc:
			%originalcode%
			movss [(allocation)Variables->FOVTP_In],xmm0
			addss xmm0, [(allocation)Variables->AdditionalTPFOV]
			movss [(allocation)Variables->FOVTP_Out],xmm0
			jmp %returnaddress%
			%end%
						
		(codecave:jmp)WeaponFOV,WeaponFOV_cc:
			movss [(allocation)Variables->FOVWeapon_In],xmm0
			addss xmm0, [(allocation)Variables->AdditionalWeaponFOV]
			movss [(allocation)Variables->FOVWeapon_Out],xmm0
			%originalcode%
			jmp %returnaddress%
			%end%
					
		(codecave:jmp)PhotoMode,PhotoMode_cc:
			fld dword ptr [(allocation)Variables->AspectRatio]
			fstp dword ptr [$$1]								$ctx=1
			jmp %returnaddress%
			%end%
					
		(codecave:jmp)DialogFOV_1,DialogFOV_1_cc:
			movss [(allocation)Variables->FOVDialog_In],xmm6
			addss xmm6, [(allocation)Variables->AdditionalDialogFOV]
			movss [(allocation)Variables->FOVDialog_Out],xmm6
			%originalcode%
			jmp %returnaddress%
			%end%

		(codecave)DialogFOV_2,DialogFOV_2_cc:
			nop
			nop
			%end%			
			
	]]

	if HackTool:CompileAssembly(asm,"Fixes") == nil then
		return ErrorOccurred("Assembly compilation failed...")
	else
		Toggle_CodeCave("FPFOV_cc",bFPFOV)
		Toggle_CodeCave("TPFOV_cc",bTPFOV)
		Toggle_CodeCave("DialogFOV_1_cc",bDialogFOV)
		Toggle_CodeCave("DialogFOV_2_cc",bDialogFOV)
		Toggle_CodeCave("WeaponFOV_cc",bWeaponFOV)
		Toggle_CodeCave("PhotoMode_cc",bPhotoMode)
	end

	if bFPFOV == true then
		WriteFPFOV()
	end
	
	if bTPFOV == true then
		WriteTPFOV()
	end

	if bDialogFOV == true then
		WriteDialogFOV()
	end
	
	WriteWeaponFOV()
	
	if bAspect == true then
		WriteAspectRatio()
	end

	if bHUD == true then
		WriteHUDSafeZone()
	end

end

function Periodic()

	PluginViewport:AppendStatusMessage( "\r\n" )

	local Variables = HackTool:GetAllocation("Variables")
	
	if Variables and Variables["FOVFP_In"] then
		if bFPFOV or bTPFOV == true then
			PluginViewport:AppendStatusMessage( string.format("1st person FOV In=%.2f, Out=%.2f  --  3rd person FOV In=%.2f, Out=%.2f\r\nDialog FOV In=%.2f, Out=%.2f  --  Weapon FOV In=%.2f, Out=%.2f", Variables["FOVFP_In"]:ReadFloat(), Variables["FOVFP_Out"]:ReadFloat(), Variables["FOVTP_In"]:ReadFloat(), Variables["FOVTP_Out"]:ReadFloat(), Variables["FOVDialog_In"]:ReadFloat(), Variables["FOVDialog_Out"]:ReadFloat(), Variables["FOVWeapon_In"]:ReadFloat(), Variables["FOVWeapon_Out"]:ReadFloat()) )
		end
	end

end

function Disable_Inject()

	if bFPFOV == true then
		RestoreFPFOV()
	end

	if bTPFOV == true then
		RestoreTPFOV()
	end
	
	if bAspect == true then
		RestoreAspectDefaults()
	end
	
	CleanUp()
	
end

function FPFOVSlider_Changed(Sender)

	fAdditionalFPFOV = Sender:GetPosition()
	lblFPFOVSlider.Caption:SetCaption( string.format("Value: +%.0f",fAdditionalFPFOV) )
		
	if bFPFOV == true then
		WriteFPFOV()
	end
	
	ForceUpdate()

end

function TPFOVSlider_Changed(Sender)

	fAdditionalTPFOV = Sender:GetPosition()
	lblTPFOVSlider.Caption:SetCaption( string.format("Value: +%.0f",fAdditionalTPFOV) )
		
	if bTPFOV == true then
		WriteTPFOV()
	end
	
	ForceUpdate()
	
end

function WEAPONFOVSlider_Changed(Sender)

	fAdditionalWeaponFOV = Sender:GetPosition()
	lblWEAPONFOVSlider.Caption:SetCaption( string.format("Value: +%.0f",fAdditionalWeaponFOV) )
		
	if bWeaponFOV == true then
		WriteWeaponFOV()
	end
	
	ForceUpdate()

end

function DIALOGFOVSlider_Changed(Sender)

	fAdditionalDialogFOV = Sender:GetPosition()
	lblDIALOGFOVSlider.Caption:SetCaption( string.format("Value: +%.0f",fAdditionalDialogFOV) )
		
	if bDialogFOV == true then
		WriteDialogFOV()
	end
	
	ForceUpdate()

end

function SZONEXFOVSlider_Changed(Sender)

	fHUDSafeZoneX = Sender:GetPosition()
	lblSZONEXFOVSlider.Caption:SetCaption( string.format("Value: %.0f%%",fHUDSafeZoneX) )
		
	if bHUD == true then
		WriteHUDSafeZone()
	end
	
	ForceUpdate()
	
end

function SZONEYFOVSlider_Changed(Sender)

	fHUDSafeZoneY = Sender:GetPosition()
	lblSZONEYFOVSlider.Caption:SetCaption( string.format("Value: %.0f%%",fHUDSafeZoneY) )
		
	if bHUD == true then
		WriteHUDSafeZone()
	end
	
	ForceUpdate()
	
end

function CKFPFOV_Changed(Sender)

	bFPFOV = Toggle_CheckFix(Sender)
	Toggle_CodeCave("FPFOV_cc",bFPFOV)
	ForceUpdate()
	
end

function CKTPFOV_Changed(Sender)

	bTPFOV = Toggle_CheckFix(Sender)
	Toggle_CodeCave("TPFOV_cc",bTPFOV)
	ForceUpdate()
	
end

function CKWEAPONFOV_Changed(Sender)

	bWeaponFOV = Toggle_CheckFix(Sender)
	Toggle_CodeCave("WeaponFOV_cc",bWeaponFOV)
	ForceUpdate()

end

function CKDIALOGFOV_Changed(Sender)

	bDialogFOV = Toggle_CheckFix(Sender)
	Toggle_CodeCave("DialogFOV_1_cc",bDialogFOV)
	Toggle_CodeCave("DialogFOV_2_cc",bDialogFOV)
	ForceUpdate()
	
end

function CKAspect_Changed(Sender)

	bAspect = Toggle_CheckFix(Sender)
	
	if bAspect == false then
		RestoreAspectDefaults()
	else 
		WriteAspectRatio()
	end
	
	ForceUpdate()
	
end

function CKHUDSafeZone_Changed(Sender)

	bHUD = Toggle_CheckFix(Sender)
	
	if bHUD == false then
		RestoreHUDDefaults()
	else 
		WriteHUDSafeZone()
	end
	
	ForceUpdate()

end

function CKPhotoMode_Changed(Sender)

	bPhotoMode = Toggle_CheckFix(Sender)
	Toggle_CodeCave("PhotoMode_cc",bPhotoMode)
	ForceUpdate()

end

function ResolutionChanged() 
	
	fAspectRatio = DisplayInfo:GetAspectRatio()
	if bAspect == true then
		WriteAspectRatio()
	end
	
end

function WriteAspectRatio()

	local AspectRatio = HackTool:GetAddress("Aspect")
	if AspectRatio then
		AspectRatio:WriteFloat(fAspectRatio)
		print("Updated aspect ratio")
	end

end

function RestoreAspectDefaults()

	local AspectRatio = HackTool:GetAddress("Aspect")
	
	if AspectRatio then
		AspectRatio:WriteFloat(Default_Auto)		
		print("Restored aspect ratio default")
	end

end

function WriteHUDSafeZone()

	local HUDSafeZoneX = HackTool:GetAddress("SafeZoneX")
	local HUDSafeZoneY = HackTool:GetAddress("SafeZoneY")
	local fSaveZoneX = (DisplayInfo:GetWidth() / 2) * (fHUDSafeZoneX / 100)
	local fSaveZoneY = (DisplayInfo:GetHeight() / 2) * (fHUDSafeZoneY / 100)
	if HUDSafeZoneX and HUDSafeZoneY then
		HUDSafeZoneX:WriteFloat(fSaveZoneX)
		HUDSafeZoneY:WriteFloat(fSaveZoneY)
	end
	
end

function RestoreHUDDefaults()

	local HUDSafeZoneX = HackTool:GetAddress("SafeZoneX")
	local HUDSafeZoneY = HackTool:GetAddress("SafeZoneY")
	
	if HUDSafeZoneX and HUDSafeZoneY then
		HUDSafeZoneX:WriteFloat(Default_Safe_Zone_X)
		HUDSafeZoneY:WriteFloat(Default_Safe_Zone_Y)
	end

end

function WriteFPFOV() 

	local Variables = HackTool:GetAllocation("Variables")
	
	if Variables and Variables["AdditionalFPFOV"] then
		Variables["AdditionalFPFOV"]:WriteFloat(fAdditionalFPFOV)
	end

end

function WriteTPFOV() 

	local Variables = HackTool:GetAllocation("Variables")
	
	if Variables and Variables["AdditionalTPFOV"] then
		Variables["AdditionalTPFOV"]:WriteFloat(fAdditionalTPFOV)
	end

end

function WriteDialogFOV()

	local Variables = HackTool:GetAllocation("Variables")
	
	if Variables and Variables["AdditionalDialogFOV"] then
		Variables["AdditionalDialogFOV"]:WriteFloat(fAdditionalDialogFOV)
	end
	
end

function WriteWeaponFOV()

	local Variables = HackTool:GetAllocation("Variables")
	
	if Variables and Variables["AdditionalWeaponFOV"] then
		Variables["AdditionalWeaponFOV"]:WriteFloat(fAdditionalWeaponFOV)
	end

end

function RestoreFPFOV()

	local FPFOV = HackTool:GetAddress("FPFOV")

	if FPFOV then
		FPFOV:WriteFloat(Default_FPFOV)
	end

end

function RestoreTPFOV()

	local TPFOV = HackTool:GetAddress("TPFOV")

	if TPFOV then
		TPFOV:WriteFloat(Default_TPFOV)
	end

end

function Init()	
	Init_BaseControls()
	Init_Controls()
end

function DeInit()
	DisableFix()
end
