From 276164cb2dd5a3c1e339d8ec704a81f35e3874d8 Mon Sep 17 00:00:00 2001 From: Leon Buckel Date: Tue, 4 May 2021 18:23:30 +0200 Subject: [PATCH] Add option to set a custom factor for the view shake --- Mod/Classes/ModGameOptionsMenu.uc | 17 +++++++++++++---- Mod/Classes/SWRCFix.uc | 25 ++++++++++++++++++++++++- Mod/Inc/ModClasses.h | 13 ++----------- Mod/Src/ModRenderDevice.cpp | 24 ------------------------ 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Mod/Classes/ModGameOptionsMenu.uc b/Mod/Classes/ModGameOptionsMenu.uc index 7a04f084..9b573a50 100644 --- a/Mod/Classes/ModGameOptionsMenu.uc +++ b/Mod/Classes/ModGameOptionsMenu.uc @@ -7,7 +7,7 @@ var() MenuSprite OptionsDescBorder; var() MenuText OptionDesc; -const NUM_OPTIONS = 12; +const NUM_OPTIONS = 13; var() MenuText OptionLabels[NUM_OPTIONS]; var() MenuButtonEnum Options[NUM_OPTIONS]; @@ -185,6 +185,7 @@ simulated function Refresh() Options[10].Current = i; Options[11].Current = SWRCFix.HudArmsFOVFactor * 10; + Options[12].Current = SWRCFix.ViewShake * 10; if ( !bInMultiplayer ) { @@ -339,22 +340,25 @@ simulated function ChangeOption( int i, int Delta ) GetPlayerOwner().TacticalModeIntensity = float(Options[i].Current) / 10.0f; GetPlayerOwner().SaveConfig(); GetPlayerOwner().PassOnTacticalIntensity(); - break; case 9: SWRCFix.FpsLimit = float(Options[9].Items[Options[9].Current]); - + SWRCFix.SaveConfig(); break; case 10: SWRCFix.SetFov(GetPlayerOwner(), float(Options[10].Items[Options[10].Current])); - break; case 11: SWRCFix.HudArmsFOVFactor = float(Options[11].Items[Options[11].Current]); SWRCFix.SetFOV(GetPlayerOwner(), SWRCFix.FOV); + break; + + case 12: + SWRCFix.ViewShake = float(Options[12].Items[Options[12].Current]); + SWRCFix.SaveConfig(); } GetPlayerOwner().PropagateSettings(); @@ -436,6 +440,7 @@ defaultproperties OptionLabels(9)=(Text="FPS LIMIT") OptionLabels(10)=(Text="FIELD OF VIEW") OptionLabels(11)=(Text="WEAPON FOV FACTOR") + OptionLabels(12)=(Text="VIEW SHAKE") Options(0)=(Items=("1","2","3","4","5","6","7","8","9","10"),Blurred=(PosX=0.77375,PosY=0.12,ScaleX=0.6,ScaleY=0.6),BackgroundBlurred=(PosX=0.77375,PosY=0.12,ScaleX=0.26,ScaleY=0.02666),OnLeft="OnLeft",OnRight="OnRight",Pass=2,Style="ButtonEnumStyle1") Options(1)=(Items=("YES","NO"),Blurred=(PosY=0.16),BackgroundBlurred=(PosY=0.16)) Options(2)=(Items=("ON","OFF")) @@ -448,6 +453,7 @@ defaultproperties Options(9)=(Items=("NONE","30","60","75","100","120","144","240","360")); Options(10)=(Items=("85","90","95","100","105","110","115","120","125","130")) Options(11)=(Items=("0.0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1.0")) + Options(12)=(Items=("0.0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1.0")) OptionLeftArrows(0)=(Blurred=(WidgetTexture=Texture'GUIContent.Menu.CT_ArrowLeft',DrawColor=(B=255,G=255,R=255,A=255),DrawPivot=DP_MiddleMiddle,PosX=0.62625,PosY=0.12,ScaleX=0.5,ScaleY=0.5),Focused=(DrawColor=(B=255,G=255,R=255,A=255),ScaleX=0.65,ScaleY=0.65),bIgnoreController=1,OnSelect="OnLeft",Pass=2) OptionLeftArrows(1)=(Blurred=(PosX=0.62625,PosY=0.16)) OptionLeftArrows(2)=(Blurred=(PosX=0.62625)) @@ -460,6 +466,7 @@ defaultproperties OptionLeftArrows(9)=(Blurred=(PosX=0.62625)) OptionLeftArrows(10)=(Blurred=(PosX=0.62625)) OptionLeftArrows(11)=(Blurred=(PosX=0.62625)) + OptionLeftArrows(12)=(Blurred=(PosX=0.62625)) OptionRightArrows(0)=(Blurred=(WidgetTexture=Texture'GUIContent.Menu.CT_ArrowRight',DrawColor=(B=255,G=255,R=255,A=255),DrawPivot=DP_MiddleMiddle,PosX=0.9225,PosY=0.12,ScaleX=0.5,ScaleY=0.5),Focused=(DrawColor=(B=255,G=255,R=255,A=255),ScaleX=0.65,ScaleY=0.65),bIgnoreController=1,OnSelect="OnRight",Pass=2) OptionRightArrows(1)=(Blurred=(PosX=0.9225,PosY=0.16)) OptionRightArrows(2)=(Blurred=(PosX=0.9225)) @@ -472,6 +479,7 @@ defaultproperties OptionRightArrows(9)=(Blurred=(PosX=0.9225)) OptionRightArrows(10)=(Blurred=(PosX=0.9225)) OptionRightArrows(11)=(Blurred=(PosX=0.9225)) + OptionRightArrows(12)=(Blurred=(PosX=0.9225)) OptionDefaults(0)=5 OptionDefaults(1)=1 OptionDefaults(2)=1 @@ -479,6 +487,7 @@ defaultproperties OptionDefaults(7)=2 OptionDefaults(8)=2 OptionDefaults(11)=10 + OptionDefaults(12)=10 GameLabel=(MenuFont=Font'OrbitFonts.OrbitBold15',Text="GAME",DrawColor=(A=255),DrawPivot=DP_MiddleLeft,PosX=0.05375,PosY=0.2,ScaleX=1,ScaleY=0.8,Pass=2) GameLabelBackground=(WidgetTexture=Texture'GUIContent.Menu.CT_ButtonFocus',DrawColor=(B=255,G=255,R=255,A=192),DrawPivot=DP_MiddleLeft,PosX=0.04375,PosY=0.2,ScaleX=0.245,ScaleY=0.04333,ScaleMode=MSCM_FitStretch,Pass=1) GameLabelConnector=(WidgetTexture=Texture'GUIContent.Menu.CT_ButtonFocus',DrawColor=(B=255,G=255,R=255,A=192),DrawPivot=DP_MiddleLeft,PosX=0.295,PosY=0.2,ScaleX=0.005,ScaleY=0.04333,ScaleMode=MSCM_FitStretch) diff --git a/Mod/Classes/SWRCFix.uc b/Mod/Classes/SWRCFix.uc index bbcef4f5..50faf3cb 100644 --- a/Mod/Classes/SWRCFix.uc +++ b/Mod/Classes/SWRCFix.uc @@ -2,6 +2,7 @@ class SWRCFix extends Object config native transient; #exec OBJ LOAD FILE="Properties.u" +var() config float ViewShake; var() config float FpsLimit; var() config float FOV; var() config float HudArmsFOVFactor; @@ -12,6 +13,8 @@ var() config bool EnableEditorSelectionFix; // Only here for convenience. The var FunctionOverride CTPlayerEndZoomOverride; var FunctionOverride CTPlayerResetFOVOverride; +var FunctionOverride PlayerControllerShakeViewOverride; + var FunctionOverride WeaponSetWeapFOVOverride; var FunctionOverride MenuBaseCallMenuClassOverride; @@ -26,6 +29,9 @@ event InitScript(){ CTPlayerEndZoomOverride.Init(class'CTPlayer', 'EndZoom', self, 'CTPlayerEndZoom'); CTPlayerResetFOVOverride = new class'FunctionOverride'; CTPlayerResetFOVOverride.Init(class'CTPlayer', 'ResetFOV', self, 'CTPlayerResetFOV'); + // PlayerController + PlayerControllerShakeViewOverride = new class'FunctionOverride'; + PlayerControllerShakeViewOverride.Init(class'PlayerController', 'ShakeView', self, 'PlayerControllerShakeView'); // Weapon WeaponSetWeapFOVOverride = new class'FunctionOverride'; WeaponSetWeapFOVOverride.Init(class'Weapon', 'SetWeapFOV', self, 'WeaponSetWeapFOV'); @@ -132,13 +138,29 @@ function SetViewFOV(PlayerController Player){ Player.FOVAngle = CurrentFOV; } -event SetFOV(PlayerController Player, float NewFOV){ +function SetFOV(PlayerController Player, float NewFOV){ FOV = NewFOV; SaveConfig(); SetViewFOV(Player); } +// View shake + +function PlayerControllerShakeView(float InTime, float SustainTime, float OutTime, float XMag, float YMag, float ZMag, float YawMag, float PitchMag, float Frequency){ + if(ViewShake > 0){ + PlayerController(PlayerControllerShakeViewOverride.CurrentSelf).ShakeView(InTime, + SustainTime, + OutTime, + XMag * ViewShake, + YMag * ViewShake, + ZMag * ViewShake, + YawMag * ViewShake, + PitchMag * ViewShake, + Frequency); + } +} + // Menu stuff simulated function MenuBaseCallMenuClass(String MenuClassName, optional String Args){ @@ -183,6 +205,7 @@ cpptext defaultproperties { + ViewShake=1.0 FOV=85.0 HUDArmsFOVFactor=1.0 LimitHudArmsFOV=true diff --git a/Mod/Inc/ModClasses.h b/Mod/Inc/ModClasses.h index d03a6831..d5d3b6c2 100644 --- a/Mod/Inc/ModClasses.h +++ b/Mod/Inc/ModClasses.h @@ -42,6 +42,7 @@ class MOD_API UFunctionOverride : public UObject class MOD_API USWRCFix : public UObject { public: + FLOAT ViewShake; FLOAT FpsLimit; FLOAT FOV; FLOAT HudArmsFOVFactor; @@ -50,6 +51,7 @@ class MOD_API USWRCFix : public UObject BITFIELD EnableEditorSelectionFix:1; class UFunctionOverride* CTPlayerEndZoomOverride GCC_PACK(4); class UFunctionOverride* CTPlayerResetFOVOverride; + class UFunctionOverride* PlayerControllerShakeViewOverride; class UFunctionOverride* WeaponSetWeapFOVOverride; class UFunctionOverride* MenuBaseCallMenuClassOverride; class UFunctionOverride* MenuBaseOverlayMenuClassOverride; @@ -59,17 +61,6 @@ class MOD_API USWRCFix : public UObject DECLARE_NAME(InitScript); ProcessEvent(NInitScript, NULL); } - void SetFOV(class APlayerController* Player, FLOAT NewFOV) - { - DECLARE_NAME(SetFOV); - struct { - class APlayerController* Player; - FLOAT NewFOV; - } Parms; - Parms.Player=Player; - Parms.NewFOV=NewFOV; - ProcessEvent(NSetFOV, &Parms); - } DECLARE_CLASS(USWRCFix,UObject,0|CLASS_Transient|CLASS_Config,Mod) void Init(); diff --git a/Mod/Src/ModRenderDevice.cpp b/Mod/Src/ModRenderDevice.cpp index a0836ba0..40ee8737 100644 --- a/Mod/Src/ModRenderDevice.cpp +++ b/Mod/Src/ModRenderDevice.cpp @@ -536,30 +536,6 @@ UBOOL UModRenderDevice::Exec(const TCHAR* Cmd, FOutputDevice& Ar){ debugf("Selection fix %s", bEnableSelectionFix ? "enabled" : "disabled"); - return 1; - } - }else if(USWRCFix::Instance){ - if(ParseCommand(&Cmd, "SETFOV")){ - TObjectIterator It; - - checkSlow(It); - - FLOAT FOV = appAtof(Cmd); - - Ar.Logf("Setting field of view to %f", FOV); - USWRCFix::Instance->SetFOV(It->Actor, FOV); - - return 1; - }else if(ParseCommand(&Cmd, "SETFPSLIMIT")){ - if(appStrlen(Cmd) > 0){ - USWRCFix::Instance->FpsLimit = Max(0.0f, appAtof(Cmd)); - USWRCFix::Instance->SaveConfig(); - } - - return 1; - }else if(ParseCommand(&Cmd, "GETFPSLIMIT")){ - Ar.Logf("%f", USWRCFix::Instance->FpsLimit); - return 1; } }