From c0cd7c76e080b48ed6c5c1944b1c74cdfed7996d Mon Sep 17 00:00:00 2001 From: MoArtis Date: Sat, 14 Sep 2019 16:54:27 +0800 Subject: [PATCH] Update UserXpMod to 1.1 --- Code/ModifiedScripts.cs | 25 ++++-- Code/UserXpMod.cs | 156 +++++++++++++++++++++++++++++------- Data/ModData.json | 15 +++- Data/UserXpMod-HowToUse.txt | 74 +++++++++++++---- README.md | 70 ++++++++++++---- 5 files changed, 275 insertions(+), 65 deletions(-) diff --git a/Code/ModifiedScripts.cs b/Code/ModifiedScripts.cs index f3f9d35..b874b2b 100644 --- a/Code/ModifiedScripts.cs +++ b/Code/ModifiedScripts.cs @@ -1,3 +1,8 @@ + +IMPORTANT : +This file is not up to date. Most of the 1.1 changes are missing. +I need manually retrack them down as I want to put as little WF's code as possible in there. + // ** PlayerInput.cs ** protected override void Start() { @@ -71,11 +76,12 @@ protected void Awake() protected void Update() { - if ((Input.GetKeyDown(KeyCode.Escape) || Singleton.instance.ButtonDown(GlobalInput.Buttons.Start)) && (!AreAllVideosPlayed || !AreAllLegalScreensPlayed) && _AllowOnePressStartSkip) - { - SkipAllMovies = true; - OnPressSkip(); - } + //if ((Input.GetKeyDown(KeyCode.Escape) || Singleton.instance.ButtonDown(GlobalInput.Buttons.Start)) && (!AreAllVideosPlayed || !AreAllLegalScreensPlayed) && _AllowOnePressStartSkip) + if (AlreadyDoneDidThat && (Input.GetKeyDown(KeyCode.Escape) || Singleton.instance.ButtonDown(GlobalInput.Buttons.Start, GlobalInput.ControllerId.One)) && _AllowOnePressStartSkip) + { + SkipAllMovies = true; + OnPressSkip(); + } } //New coroutine to avoid some UI bugs when all the intro are skipped on start @@ -117,4 +123,13 @@ protected void SetStats() //Add this just after the line 135 if (_characterStats[i].StatToWatch == PlayerAttributeEnum.Stamina && Mod.UserXpMod.fixMaxStaminaBug) maxStatLevel = 39; +} + +// ** CinematicManager.cs ** +private void Update() +{ + if (Mod.UserXpMod.data.allowQuickSkip && (Input.GetKeyDown(KeyCode.Escape) || Singleton.instance.ButtonDown(GlobalInput.Buttons.Start, GlobalInput.ControllerId.One))) + { + OnCinematicSkip(); + } } \ No newline at end of file diff --git a/Code/UserXpMod.cs b/Code/UserXpMod.cs index 9d3a888..46eb635 100644 --- a/Code/UserXpMod.cs +++ b/Code/UserXpMod.cs @@ -9,16 +9,47 @@ namespace Mod { [System.Serializable] - public class ModData + public struct ModData { - public bool allowSkipSplashScreens; + public bool allowQuickSkip; public bool startFromMainMenu; + public string interactActionId; public InputConfig[] playerOneInputConfigs; public InputConfig[] playerTwoInputConfigs; public bool forceXInput; + public bool usePS4buttonPrompts; + public bool displayProgressionInfo; + + public int vSyncCount; + public int targetFramerate; + public bool useCustomFramelimiter; + + public bool displayDamageOnHit; + public Color xpGetTextColor; + public int xpGetTextFontSize; + public Color hitDmgTextColor; + public int hitDmgTextFontSizeMin; + public int hitDmgTextFontSizeMax; + + public bool noTutorialInNewGamePlus; + + public bool unlockSecretCharactersOnceForAllSave; + public bool fixBooksBug; public bool fixMaxStaminaBug; + + public InputConfig GetInputConfig(int playerId) + { + if (playerId == 0) + { + return playerOneInputConfigs[0]; + } + else + { + return playerTwoInputConfigs[0]; + } + } } [System.Serializable] @@ -78,24 +109,41 @@ public class UserXpMod private static string kbMapXmlTemplate = "{26}{27}000000000-0000-0000-0000-000000000000true011{0}0false0{13}000true011{1}0false1{14}000true001{2}0false1{15}000true001{3}0false0{16}000true091{4}0false0{17}000true031{5}0false0{18}000true041{6}0false0{19}000true021{7}0false0{20}000true051{8}0false0{21}000true061{9}0false0{22}000true071{10}0false0{23}000true0111{11}0false0{24}000true0121{12}0false0{25}000true"; - private static ModData data = null; - - public static bool startFromMainMenu { get { LoadModData(); return data.startFromMainMenu; } } + public static ModData data { get { LoadModData(); return _data; } set { _data = value; } } + private static ModData _data; - public static bool allowSkipSplashScreens { get { LoadModData(); return data.allowSkipSplashScreens; } } - - public static string interactActionId { get { LoadModData(); return data.interactActionId; } } - - public static bool fixBooksBug { get { LoadModData(); return data.fixBooksBug; } } - - public static bool fixMaxStaminaBug { get { LoadModData(); return data.fixMaxStaminaBug; } } + public static bool hasData = false; private static void LoadModData() { - if (data == null) + if (hasData == false) { string modDataJson = File.ReadAllText(".\\ModData.json"); data = JsonUtility.FromJson(modDataJson); + + if (data.interactActionId == "") + _data.interactActionId = "QuickAttack"; + + hasData = true; + } + } + + public static void ApplyFramerateConfig() + { + LoadModData(); + + if (hasData == false) + return; + + if (data.useCustomFramelimiter) + { + Application.targetFrameRate = -1; + QualitySettings.vSyncCount = 0; + } + else + { + Application.targetFrameRate = data.targetFramerate; + QualitySettings.vSyncCount = data.vSyncCount; } } @@ -103,23 +151,22 @@ public static void LoadCustomInputConfig() { LoadModData(); + if (hasData == false) + return; + if (data.forceXInput) { ReInput.configuration.windowsStandalonePrimaryInputSource = Rewired.Platforms.WindowsStandalonePrimaryInputSource.XInput; } - ReplacePlayerMaps(0, data); - ReplacePlayerMaps(1, data); - - //File.WriteAllText(".\\config.txt", string.Concat( - // ReInput.configuration.windowsStandalonePrimaryInputSource, "\n", - // ReInput.configuration.disableNativeInput, "\n", - // ReInput.configuration.useXInput, "\n" - // )); + ReplacePlayerMaps(0); + ReplacePlayerMaps(1); } - private static void ReplacePlayerMaps(int playerId, ModData inputData) + private static void ReplacePlayerMaps(int playerId) { + InputConfig inputConfig = data.GetInputConfig(playerId); + Player.ControllerHelper.MapHelper mapHelper = ReInput.players.GetPlayer(playerId).controllers.maps; //Clear previous maps @@ -133,14 +180,14 @@ private static void ReplacePlayerMaps(int playerId, ModData inputData) if (playerId == 0) { args.AddRange(playerOneElementIdentifierIds); - args.AddRange(inputData.playerOneInputConfigs[0].ToKeycodeArray()); } else { args.AddRange(playerTwoElementIdentifierIds); - args.AddRange(inputData.playerTwoInputConfigs[0].ToKeycodeArray()); } + args.AddRange(inputConfig.ToKeycodeArray()); + args.Add(playerId + 1); args.Add(playerId + 1); @@ -152,10 +199,65 @@ private static void ReplacePlayerMaps(int playerId, ModData inputData) { File.WriteAllText(string.Format(".\\Player{0}-Remap-ERROR.txt", playerId), string.Concat(e.Message, "\n", e.StackTrace)); } + } + + private static Dictionary actionIdToPromptTypes = new Dictionary() + { + { "Jump", PromptType.A }, + { "QuickAttack", PromptType.X }, + { "HeavyAttack", PromptType.Y }, + { "SpecialAttack", PromptType.B }, + { "Block", PromptType.RTrigger }, + { "Recruit", PromptType.LTrigger }, + { "Start", PromptType.Start }, + }; + + public static PromptType ActionIdToPromptType(string actionId) + { + if (actionIdToPromptTypes.ContainsKey(actionId)) + return actionIdToPromptTypes[actionId]; + else + return PromptType.X; + } + + private static long lastTime = HighResolutionTime.Time; + + public static void FrameLimiterUpdate() + { + if (hasData == false || data.useCustomFramelimiter == false || data.targetFramerate <= 0.0) return; - //Controller map - //??? + lastTime += TimeSpan.FromSeconds(1.0 / data.targetFramerate).Ticks; + + var now = HighResolutionTime.Time; + + if (now >= lastTime) + { + lastTime = now; + return; + } + else + { + //System.Threading.SpinWait.SpinUntil(() => { return (HighResolutionTime.Time >= lastTime); }); + while (HighResolutionTime.Time < lastTime) { } + } + } + + public static bool IsKunioAndRikkiUnlockedOnAnySaveSlot() + { + for (int i = 0; i < 4; i++) + { + List eventValues = SaveManager_Main.LoadOrGetDefaultObject($"Slot_{i}_saveKeySlotFinishedEvents", new List(), "savefile"); + for (int j = 0; j < eventValues.Count; j++) + { + if (eventValues[j].EventName == "Kill Final") + { + if (eventValues[j].TimesFired >= 1) + return true; + } + } + } + return false; } } -} +} \ No newline at end of file diff --git a/Data/ModData.json b/Data/ModData.json index 3af39eb..e93908a 100644 --- a/Data/ModData.json +++ b/Data/ModData.json @@ -1,5 +1,5 @@ { - "allowSkipSplashScreens" : true, + "allowQuickSkip" : true, "startFromMainMenu" : false, "interactActionId" : "Recruit", "playerOneInputConfigs" : [ @@ -33,6 +33,19 @@ } ], "forceXInput" : false, + "usePS4buttonPrompts" : false, + "displayProgressionInfo" : false, + "vSyncCount" : 1, + "targetFramerate" : -1, + "useCustomFramelimiter" : false, + "displayDamageOnHit" : true, + "xpGetTextColor" : { "r":1,"g":0.8470589,"b":0.4117647,"a":1}, + "xpGetTextFontSize" : 85, + "hitDmgTextColor" : {"r":1,"g":1,"b":1,"a":0}, + "hitDmgTextFontSizeMin" : 80, + "hitDmgTextFontSizeMax" : 125, + "noTutorialInNewGamePlus" : true, + "unlockSecretCharactersOnceForAllSave" : true, "fixBooksBug" : true, "fixMaxStaminaBug" : true } \ No newline at end of file diff --git a/Data/UserXpMod-HowToUse.txt b/Data/UserXpMod-HowToUse.txt index 916a1c3..200416e 100644 --- a/Data/UserXpMod-HowToUse.txt +++ b/Data/UserXpMod-HowToUse.txt @@ -1,22 +1,32 @@ -~** River City Girls UserXpMod 1.02 **~ +~** River City Girls UserXpMod 1.1 **~ ** What is it ** -This mod allows multiple small things to improve the user experience for PC users of the game. - -- Skip the legal splashscreen, logos, and the intro by just pressing the "Escape" key once. +This mod allows multiple small things to improve the user experience on PC. +[Menus] +- Skip any splash screen, video, dialog with just pressing Start or Escape once. - Start the game from the main menu. (Optional) +- [NEW] Display progression details in the save selection menu. (Off by default) +- [NEW] Skip the tutorial in New Game Plus. +[Settings] - Remap the "interact" action used to pick object on the floor or use doors. - -- Change the keyboard mapping from the config file. - -- Force the game to use XInput to potentially fix the controller related bugs. (Optional) - +- [NEW] Remapping the “interact” action will change the button prompt accordingly. +- Remap the keyboard from the mod’s config file. +- Force the game to use XInput to potentially fix the controller related bugs. (Off by default) +- [NEW] Display the PS4 controller’s button prompts instead of the Xbox ones. (Off by default) +- [NEW] Configure the vSync settings. +- [NEW] Use Unity’s frame limiter ("TargetFramerate") or a custom one. (Off by default) + +[Gameplay/Feedbacks] +- [NEW] Unlock the secret characters on every save once they are unlocked on at least one save. +- [NEW] Display the amount of damage on hit like other River City games. +- [NEW] Customize the color and the size of the Damage and XP gain feedbacks. + +[Bug fixes] - Fix a bug that prevented the Book items to work properly when using a character other than Misako. - -- Fix a bug that prevented the phone interface to display a maxed out Stamina stat. +- Fix a bug that prevented the phone interface to display a maxed-out Stamina stat. ** How to install ** @@ -34,15 +44,45 @@ Open it with any text editor. Following the order of the file, this is what you can modify: -- "allowSkipSplashScreens" : Can be set to true or false. if true, allows to skip all the intro screens and videos by pressing escape (all at once) or by holding the "Quick Attack" key (one by one). +- "allowQuickSkip": Can be set to true or false. if true, allows to skip any video, dialog and the whole intro by pressing Start or Escape once. + +- "startFromMainMenu": Can be set to true or false. If true, always start the game from the main menu. + +- "interactActionId": Can be set to any "action id" like "block" or "recruit" (full list just below). It will replace the button use for interacting with doors or grab objects on the floor. The game is using the "QuickAttack" by default which can be annoying when fighting next to a door or a weapon. + +- "playerOneInputConfigs" & "playerTwoInputConfigs": Each line can be set to a keyboard keycode (full list just below). Remap each action to a new keyboard key. + +- "forceXInput": Can be set to true or false. If true, it might fix some controller related bugs like controlling the two players with only one controller or the controller's inputs being not detected at all. + +- "usePS4buttonPrompts": Can be set to true or false. If true, it will replace the Xbox controller’s input prompts by the PS4 controller’s ones. + +- "displayProgressionInfo": Can be set to true or false. If true, it will display a detailed breakdown of the currently selected save in the save selection menu. + +- "vSyncCount": Can be set to 0, 1, 2, 3 or 4. 0 will deactivate the vertical sync and decouple the game’s framerate to the monitor refresh rate. Doing so will usually cause “screen tearing” but will allow to use frame limiters (see below). 1, the game default, will sync the framerate with the monitor’s refresh rate. Using 144hz monitor will make the game target a framerate of 144. As the number is the ratio between the monitor refresh rate and the framerate, 2 will make the game target a framerate of 72 (for the same 144hz monitor). Most user needs to keep that value to 1. + +- "targetFramerate": Can be set to -1 or any positive integer. This setting is ignored if the vSync is activated (vSync sets 1,2,3 or 4). If set to -1, the game will run as fast as possible (This will kill your battery very fast). Anything above 0 will use Unity’s built-in frame limiter to limit the framerate to the indicated value. Expect screen tearing when the camera is moving around in game. + +- "useCustomFramelimiter": Can be set to true or false. If true, the game will use a custom Frame limiter to do the same thing as described just before in the "targetFramerate" section. It might give better results than the built-in one. Don’t forget to set the targetFramerate before using this. + +- "displayDamageOnHit": Can be set to true or false. If true, the amount of damage will be displayed when the enemies or the player characters are hit. An exclamation mark will be added to the damage indicator when the “Bomb Bra” effect (One hit KO) is being applied. + +- "xpGetTextColor": Can be set to any real number between 0 and 1 for the Red, blue, green and alpha channels of the desired color. It corresponds to the desired color of the xp gain feedback displayed when an enemy is defeated. The alpha value (“a”) is ignored but setting it to 0 will pick the game’s default feedback text color. + +- "xpGetTextFontSize": Can be set to any positive integer. It defines the font size of the xp gain feedback. The game’s default is 80. Setting it to 0 or less will pick the default value. + +- "hitDmgTextColor": Can be set to any real number between 0 and 1 for the Red, blue, green and alpha channels of the desired color. The same usage as "xpGetTextColor" but for the Hit damage feedback. + +- "hitDmgTextFontSizeMin": Can be set to any positive integer. As the size of the Hit damage feedback is actually dynamic, a minimum and a maximum size can be set. For the players, the size depends on the amount of base damage compared to all the other move of the player’s character. For the enemies, the size is determined from the portion of health lost from their attacks. + +- "hitDmgTextFontSizeMax": Can be set to any positive integer. See "hitDmgTextFontSizeMin". -- "startFromMainMenu" : Can be set to true or false. If true, always start the game from the main menu. +- "noTutorialInNewGamePlus": Can be set to true or false. If true, remove the tutorial in New Game Plus. -- "interactActionId" : Can be set to any "action id" like "block" or "recruit" (full list just below). It will replace the button use for interacting with doors or grab objects on the floor. The game is using the "QuickAttack" by default which can be annoying when fighting next to a door or a weapon. +- "unlockSecretCharactersOnceForAllSave": Can be set to true or false. If true, unlocking the secret playable characters only need to be done once in order to make them available for any save. -- "playerOneInputConfigs" & "playerTwoInputConfigs" : Each line can be set to a keyboard keycode (full list just below). Remap each action to a new keyboard key. +- "fixBooksBug": Can be set to true or false. If true, fix a bug that prevented the Book items to work properly when using a character other than Misako. -- "forceXInput" : Can be set to true or false. If true, it might fix some controller related bugs like controlling the two players with only one controller or the controller's inputs being not detected at all. +- "fixMaxStaminaBug": Can be set to true or false. If true, fix a bug that prevented the phone interface to display a maxed-out Stamina stat. ** How to uninstall ** @@ -195,4 +235,4 @@ Help Print SysReq Break -Menu +Menu \ No newline at end of file diff --git a/README.md b/README.md index ad05194..2c2fca3 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,31 @@ ## ** What is it ** -This mod changes multiple small things to improve the user experience of the game. - -- Skip the legal splashscreen, logos, and the intro by just pressing the "Escape" key once. +This mod allows multiple small things to improve the user experience on PC. +[Menus] +- Skip any splash screen, video, dialog with just pressing Start or Escape once. - Start the game from the main menu. (Optional) +- [NEW] Display progression details in the save selection menu. (Off by default) +- [NEW] Skip the tutorial in New Game Plus. +[Settings] - Remap the "interact" action used to pick object on the floor or use doors. - -- Change the keyboard mapping from the config file. - -- Force the game to use Xinput to potentially fix the controller related bugs. (Optional) - +- [NEW] Remapping the “interact” action will change the button prompt accordingly. +- Remap the keyboard from the mod’s config file. +- Force the game to use XInput to potentially fix the controller related bugs. (Off by default) +- [NEW] Display the PS4 controller’s button prompts instead of the Xbox ones. (Off by default) +- [NEW] Configure the vSync settings. +- [NEW] Use Unity’s frame limiter ("TargetFramerate") or a custom one. (Off by default) + +[Gameplay/Feedbacks] +- [NEW] Unlock the secret characters on every save once they are unlocked on at least one save. +- [NEW] Display the amount of damage on hit like other River City games. +- [NEW] Customize the color and the size of the Damage and XP gain feedbacks. + +[Bug fixes] - Fix a bug that prevented the Book items to work properly when using a character other than Misako. - -- Fix a bug that prevented the phone interface to display a maxed out Stamina stat. +- Fix a bug that prevented the phone interface to display a maxed-out Stamina stat. ## ** How to install ** @@ -34,15 +44,45 @@ Open it with any text editor. Following the order of the file, this is what you can modify: -- "allowSkipSplashScreens" : Can be set to true or false. if true, allows to skip all the intro screens and videos by pressing escape (all at once) or by holding the "Quick Attack" key (one by one). +- "allowQuickSkip": Can be set to true or false. if true, allows to skip any video, dialog and the whole intro by pressing Start or Escape once. + +- "startFromMainMenu": Can be set to true or false. If true, always start the game from the main menu. + +- "interactActionId": Can be set to any "action id" like "block" or "recruit" (full list just below). It will replace the button use for interacting with doors or grab objects on the floor. The game is using the "QuickAttack" by default which can be annoying when fighting next to a door or a weapon. + +- "playerOneInputConfigs" & "playerTwoInputConfigs": Each line can be set to a keyboard keycode (full list just below). Remap each action to a new keyboard key. + +- "forceXInput": Can be set to true or false. If true, it might fix some controller related bugs like controlling the two players with only one controller or the controller's inputs being not detected at all. + +- "usePS4buttonPrompts": Can be set to true or false. If true, it will replace the Xbox controller’s input prompts by the PS4 controller’s ones. + +- "displayProgressionInfo": Can be set to true or false. If true, it will display a detailed breakdown of the currently selected save in the save selection menu. + +- "vSyncCount": Can be set to 0, 1, 2, 3 or 4. 0 will deactivate the vertical sync and decouple the game’s framerate to the monitor refresh rate. Doing so will usually cause “screen tearing” but will allow to use frame limiters (see below). 1, the game default, will sync the framerate with the monitor’s refresh rate. Using 144hz monitor will make the game target a framerate of 144. As the number is the ratio between the monitor refresh rate and the framerate, 2 will make the game target a framerate of 72 (for the same 144hz monitor). Most user needs to keep that value to 1. + +- "targetFramerate": Can be set to -1 or any positive integer. This setting is ignored if the vSync is activated (vSync sets 1,2,3 or 4). If set to -1, the game will run as fast as possible (This will kill your battery very fast). Anything above 0 will use Unity’s built-in frame limiter to limit the framerate to the indicated value. Expect screen tearing when the camera is moving around in game. + +- "useCustomFramelimiter": Can be set to true or false. If true, the game will use a custom Frame limiter to do the same thing as described just before in the "targetFramerate" section. It might give better results than the built-in one. Don’t forget to set the targetFramerate before using this. + +- "displayDamageOnHit": Can be set to true or false. If true, the amount of damage will be displayed when the enemies or the player characters are hit. An exclamation mark will be added to the damage indicator when the “Bomb Bra” effect (One hit KO) is being applied. + +- "xpGetTextColor": Can be set to any real number between 0 and 1 for the Red, blue, green and alpha channels of the desired color. It corresponds to the desired color of the xp gain feedback displayed when an enemy is defeated. The alpha value (“a”) is ignored but setting it to 0 will pick the game’s default feedback text color. + +- "xpGetTextFontSize": Can be set to any positive integer. It defines the font size of the xp gain feedback. The game’s default is 80. Setting it to 0 or less will pick the default value. + +- "hitDmgTextColor": Can be set to any real number between 0 and 1 for the Red, blue, green and alpha channels of the desired color. The same usage as "xpGetTextColor" but for the Hit damage feedback. + +- "hitDmgTextFontSizeMin": Can be set to any positive integer. As the size of the Hit damage feedback is actually dynamic, a minimum and a maximum size can be set. For the players, the size depends on the amount of base damage compared to all the other move of the player’s character. For the enemies, the size is determined from the portion of health lost from their attacks. + +- "hitDmgTextFontSizeMax": Can be set to any positive integer. See "hitDmgTextFontSizeMin". -- "startFromMainMenu" : Can be set to true or false. If true, always start the game from the main menu. +- "noTutorialInNewGamePlus": Can be set to true or false. If true, remove the tutorial in New Game Plus. -- "interactActionId" : Can be set to any "action id" like "block" or "recruit" (full list just below). It will replace the button use for interacting with doors or grab objects on the floor. The game is using the "QuickAttack" by default which can be annoying when fighting next to a door or a weapon. +- "unlockSecretCharactersOnceForAllSave": Can be set to true or false. If true, unlocking the secret playable characters only need to be done once in order to make them available for any save. -- "playerOneInputConfigs" & "playerTwoInputConfigs" : Each line can be set to a keyboard keycode (full list just below). Remap each action to a new keyboard key. +- "fixBooksBug": Can be set to true or false. If true, fix a bug that prevented the Book items to work properly when using a character other than Misako. -- "forceXInput" : Can be set to true or false. If true, it might fix some controller related bugs like controlling the two players with only one controller or the controller's inputs being not detected at all. +- "fixMaxStaminaBug": Can be set to true or false. If true, fix a bug that prevented the phone interface to display a maxed-out Stamina stat. ## ** How to uninstall **