Fix for botched BPM calculations
authorCameron Ball <c.ball1729@gmail.com>
Mon, 16 Dec 2013 16:41:49 +0000 (00:41 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Mon, 16 Dec 2013 16:43:43 +0000 (00:43 +0800)
Themes/GrooveNights/Scripts/SpeedMods.lua

index c14428c..6778f5d 100644 (file)
@@ -170,8 +170,18 @@ function GetSpeedMod(pn)
                end\r
        end\r
        \r
-       -- If we get here, chances are that m0 was applied. TODO: Maybe put a check in to see that it was?\r
-       return { Name = 'm0', Base = "0", Extra = "0", Type = "m-mod" }\r
+       return { Name = 'm0', Base = '0', Extra = '0', Type = 'm-mod' }\r
+       \r
+       --[[ M-Mods need to be checked last, as when the game starts m0 is always applied (even if a different default modifier has been chosen)\r
+    for n = 1, table.getn(BaseSpeeds) do\r
+        if SpeedModRowType == "pro" then\r
+           for m = 1, table.getn(ExtraSpeeds) do\r
+               local CombinedSpeeds = BaseSpeeds[n] + string.gsub(ExtraSpeeds[m], 'x', '') --combines the speeds in to things like 4.50                        \r
+                               if GAMESTATE:PlayerIsUsingModifier(pn, 'm' .. CombinedSpeeds*100) then return { Name = 'm' .. CombinedSpeeds*100, Base = BaseSpeeds[n], Extra = ExtraSpeeds[m], Type = 'm-mod' } end\r
+            end\r
+        end\r
+    end]]--\r
+\r
 end\r
 \r
 function SpeedMods(name)\r
@@ -205,6 +215,7 @@ function SpeedMods(name)
     end\r
 \r
     local function Save(self, list, pn)\r
+\r
         local SpeedMod = GetSpeedMod(pn)\r
 \r
         for i = 1, table.getn(modList) do\r
@@ -219,8 +230,8 @@ function SpeedMods(name)
             GAMESTATE:ApplyGameCommand('mod,' .. SpeedMod.Base, pn+1)\r
             MESSAGEMAN:Broadcast('SpeedModChangedP' .. pn+1)\r
         else\r
-            local SpeedModNumber = SpeedMod.Base + SpeedMod.Extra\r
-            local SpeedModToApply = "1x"\r
+               \r
+            local SpeedModNumber = SpeedMod.Base + SpeedMod.Extra          \r
 \r
             if SpeedMod.Type == 'c-mod' then SpeedModToApply = 'c' .. SpeedModNumber*100 end\r
             if SpeedMod.Type == 'm-mod' then SpeedModToApply = 'm' .. SpeedModNumber*100 end\r
@@ -232,10 +243,24 @@ function SpeedMods(name)
             you choose 0x or m0 and then try change the mod type). This is a silly fix that checks what the mod being\r
             set is, then set the other one (IE if we're setting X, then change M) to a value outside of where GetSpeedMod\r
             will ever look ]]--\r
-            if ModType == 'm-mod' then GAMESTATE:ApplyGameCommand('mod,9999x',pn+1) end\r
-            if ModType == 'x-mod' then GAMESTATE:ApplyGameCommand('mod,m9999',pn+1) end\r
-            GAMESTATE:ApplyGameCommand('mod,'..SpeedModToApply,pn+1) --this is so annoying, the player number has to be 1 or 2 for ApplyGameCommand\r
-            MESSAGEMAN:Broadcast('SpeedModChangedP' .. pn+1)\r
+            if SpeedMod.Type == 'm-mod' then GAMESTATE:ApplyGameCommand('mod,9999x',pn+1) end\r
+            if SpeedMod.Type == 'x-mod' then GAMESTATE:ApplyGameCommand('mod,m9999',pn+1) end\r
+                       \r
+                       if SpeedModToApply == "m0" then\r
+                               --This message comes up more than once (I guess Save is called multiple times?) Not sure if this is a problem.\r
+                               SCREENMAN:SystemMessage("Invalid mod, M0. Applying 1x instead.")\r
+                               \r
+                               --[[\r
+                               This is an awful hack. Basically the getspeedmod thing will never look for 1.0001x.\r
+                               If I use 1.0x then things go wrong because getspeedmod starts returning that the current\r
+                               mod is 1.0x instead of m0, and that throws out the bpm calculations. Doing this simply\r
+                               results in x1 showing up on screenevaluation.\r
+                               ]]--\r
+                               GAMESTATE:ApplyGameCommand('mod,1.0001x')\r
+                       end\r
+                       \r
+                       GAMESTATE:ApplyGameCommand('mod,'..SpeedModToApply,pn+1) --this is so annoying, the player number has to be 1 or 2 for ApplyGameCommand\r
+                       MESSAGEMAN:Broadcast('SpeedModChangedP' .. pn+1)\r
         end\r
     end\r
 \r