From 58dbc63c6e85fecf9f13aea709e1397bd790161b Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Sun, 8 Apr 2018 15:24:34 +0200 Subject: [PATCH 1/3] Add HardRock position mangling for CatchTheBeat --- .../Mods/CatchModHardRock.cs | 77 ++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs index ed33bf7124..5dadec9b15 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs @@ -1,13 +1,88 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.MathUtils; +using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Mods; +using System; namespace osu.Game.Rulesets.Catch.Mods { - public class CatchModHardRock : ModHardRock + public class CatchModHardRock : ModHardRock, IApplicableToHitObject { public override double ScoreMultiplier => 1.12; public override bool Ranked => true; + + private float lastStartX; + private int lastStartTime; + + public void ApplyToHitObject(CatchHitObject hitObject) + { + // Code from Stable, we keep calculation on a scale of 0 to 512 + float position = hitObject.X * 512; + int startTime = (int)hitObject.StartTime; + + if (lastStartX == 0) + { + lastStartX = position; + lastStartTime = startTime; + return; + } + + float diff = lastStartX - position; + int timeDiff = startTime - lastStartTime; + + if (timeDiff > 1000) + { + lastStartX = position; + lastStartTime = startTime; + return; + } + + if (diff == 0) + { + bool right = RNG.NextBool(); + + float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4)); + + if (right) + { + if (position + rand <= 512) + position += rand; + else + position -= rand; + } + else + { + if (position - rand >= 0) + position -= rand; + else + position += rand; + } + + hitObject.X = position / 512; + + return; + } + + if (Math.Abs(diff) < timeDiff / 3) + { + if (diff > 0) + { + if (position - diff > 0) + position -= diff; + } + else + { + if (position - diff < 512) + position -= diff; + } + } + + hitObject.X = position / 512; + + lastStartX = position; + lastStartTime = startTime; + } } } From b40af0848f5cb2b4579ac30730bbd7606c3e5ee2 Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Sun, 8 Apr 2018 15:52:40 +0200 Subject: [PATCH 2/3] White space --- osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs index 5dadec9b15..97b1645e85 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Catch.Mods { public override double ScoreMultiplier => 1.12; public override bool Ranked => true; - + private float lastStartX; private int lastStartTime; From 82d9504cbf866e601dd3e7c519113354f7433c36 Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Mon, 9 Apr 2018 09:02:32 +0200 Subject: [PATCH 3/3] Changed relative position to [0, 1] --- osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs index 97b1645e85..1656a5c40b 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs @@ -3,6 +3,7 @@ using osu.Framework.MathUtils; using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Mods; using System; @@ -18,8 +19,7 @@ namespace osu.Game.Rulesets.Catch.Mods public void ApplyToHitObject(CatchHitObject hitObject) { - // Code from Stable, we keep calculation on a scale of 0 to 512 - float position = hitObject.X * 512; + float position = hitObject.X; int startTime = (int)hitObject.StartTime; if (lastStartX == 0) @@ -43,11 +43,11 @@ namespace osu.Game.Rulesets.Catch.Mods { bool right = RNG.NextBool(); - float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4)); + float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4d)) / CatchPlayfield.BASE_WIDTH; if (right) { - if (position + rand <= 512) + if (position + rand <= 1) position += rand; else position -= rand; @@ -60,12 +60,12 @@ namespace osu.Game.Rulesets.Catch.Mods position += rand; } - hitObject.X = position / 512; + hitObject.X = position; return; } - if (Math.Abs(diff) < timeDiff / 3) + if (Math.Abs(diff) < timeDiff / 3d) { if (diff > 0) { @@ -74,12 +74,12 @@ namespace osu.Game.Rulesets.Catch.Mods } else { - if (position - diff < 512) + if (position - diff < 1) position -= diff; } } - hitObject.X = position / 512; + hitObject.X = position; lastStartX = position; lastStartTime = startTime;