Advertisement
Jousway

hey ciunek

May 2nd, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.50 KB | None | 0 0
  1. -----------------------------------------------------------
  2. -- StepMania 3.9 (Plus) Scorings by @803832
  3. -- 3.9 MAX2
  4. -- 3.9 5TH
  5. -- 3.9Plus HYBRID
  6. -- 3.9Plus SN
  7. -- 3.9Plus SN2
  8. -- note: 3.9Plus PIU Scoring cannot be implemented due to no NumTapsInRow
  9. -- in JudgmentMessage. This is fixed in hanubeki-modified-sm-ssc revision 6c7184e7df9a:
  10. -- http://code.google.com/r/hanubeki-modified-sm-ssc/source/detail?r=6c7184e7df9a3694649f965c2976859bb9e45963
  11. -----------------------------------------------------------
  12. local function isW2OrAbove(tns)
  13.     if tns == 'TapNoteScore_W1' or tns == 'TapNoteScore_W2' then
  14.         return true;
  15.     end;
  16.     return false;
  17. end
  18. local sm3_Steps = {0,0};
  19. local sm3_Score = {0,0};
  20. local sm3_CurMaxScore = {0,0};
  21. local sm3_Combo = {0,0};
  22. local sm3_CurMaxCombo = {0,0};
  23. local sm3_GradePoints = {0,0};
  24. local sm3_Bonus = {0,0};
  25. local sm3_MaxBonus = {0,0};
  26.  
  27. r["3.9 MAX2"] = function(params, pss)
  28.     local multLookup =
  29.     {
  30.         ['TapNoteScore_W1'] = 10,
  31.         ['TapNoteScore_W2'] = GAMESTATE:ShowW1() and 9 or 10,
  32.         ['TapNoteScore_W3'] = 5
  33.     };
  34.     setmetatable(multLookup, ZeroIfNotFound);
  35.     local radarValues = GetDirectRadar(params.Player);
  36.     local totalItems = GetTotalItems(radarValues);
  37.     -- 1+2+3+...+totalItems value/の値
  38.     local sTotal = (totalItems+1)*totalItems/2;
  39.     local steps = GAMESTATE:GetCurrentSteps(params.Player);
  40.     local meter = steps:GetMeter();
  41.     meter = clamp(meter,1,10);
  42.  
  43.     -- [ja] 満点を求める
  44.     local length = 1;
  45.     if (GAMESTATE:GetCurrentSong():IsMarathon()) then
  46.         length = 3;
  47.     elseif (GAMESTATE:GetCurrentSong():IsLong()) then
  48.         length = 2;
  49.     end;
  50.     local baseScore = meter * 10000000 * length;
  51.  
  52.     local sOne = baseScore/sTotal;
  53.  
  54.     local p = (params.Player == 'PlayerNumber_P1') and 1 or 2;
  55.  
  56.     -- [ja] スコアが0の時に初期化
  57.     if pss:GetScore()==0 then
  58.         sm3_Steps[p] = 0;
  59.     end;
  60.  
  61.     -- [ja] 現在のステップ数
  62.     -- [ja] 地雷とHoldCheckpointsの場合は加算しない
  63.     if params.TapNoteScore ~= "TapNoteScore_HitMine" and
  64.        params.TapNoteScore ~= "TapNoteScore_AvoidMine" and
  65.        params.TapNoteScore ~= "TapNoteScore_CheckpointHit" and
  66.        params.TapNoteScore ~= "TapNoteScore_CheckpointMiss"
  67.     then
  68.         sm3_Steps[p]=sm3_Steps[p]+1;
  69.     end;
  70.  
  71.     -- [en] current score
  72.     -- [ja] 今回加算するスコア(W1の時)
  73.     local vScore = sOne*sm3_Steps[p];
  74.     pss:SetCurMaxScore(pss:GetCurMaxScore()+math.floor(vScore));
  75.     -- [ja] 判定によって加算量を変更
  76.     if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  77.         vScore = vScore;
  78.     else
  79.         if (params.HoldNoteScore == 'HoldNoteScore_LetGo') then
  80.             vScore = 0;
  81.         else
  82.             vScore = vScore*multLookup[params.TapNoteScore]/10;
  83.         end;
  84.     end;
  85.  
  86.     -- [ja] 落ちていた場合は入るスコアが減る
  87.     if (pss:GetFailed()) then
  88.         if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  89.             -- [ja] O.K.判定時は10点
  90.             sm3_Score[p] = sm3_Score[p]+10;
  91.         elseif (params.HoldNoteScore ~= 'HoldNoteScore_LetGo') then
  92.             -- [ja] O.K.でもN.G.でもない場合のスコア:
  93.             -- W1 (Marvelous): 10
  94.             -- W2 (Perfect):    9
  95.             -- W3 (Great):      5
  96.             sm3_Score[p] = sm3_Score[p]+multLookup[params.TapNoteScore];
  97.         end;
  98.  
  99.         -- [ja] 5点単位の処理がなぜかここでされる
  100.         if multLookup[params.TapNoteScore] > 0 then
  101.             sm3_Score[p] = math.floor((sm3_Score[p] + 2) / 5) * 5;
  102.         end;
  103.     else
  104.         pss:SetScore(pss:GetScore()+math.floor(vScore));
  105.     end;
  106.  
  107.     if (sm3_Steps[p] == totalItems and not pss:GetFailed()) then
  108.         -- [ja] 最後の1ステップがW2以上の場合、端数を加算する
  109.         -- [ja] 端数は設定上の満点と最終ステップ時点での満点の差から求める
  110.         if (isW2OrAbove(params.TapNoteScore) or params.HoldNoteScore == 'HoldNoteScore_Held') then
  111.             pss:SetScore(pss:GetScore()+(baseScore-pss:GetCurMaxScore()));
  112.             pss:SetCurMaxScore(pss:GetCurMaxScore()+(baseScore-pss:GetCurMaxScore()));
  113.         end;
  114.     end;
  115. end;
  116.  
  117. -- TODO: Don't add combo bonus if autoplay
  118. r["3.9 5TH"] = function(params, pss)
  119.     local multLookup =
  120.     {
  121.         ['TapNoteScore_W1'] = 10,
  122.         ['TapNoteScore_W2'] = GAMESTATE:ShowW1() and 9 or 10,
  123.         ['TapNoteScore_W3'] = 5
  124.     };
  125.     setmetatable(multLookup, ZeroIfNotFound);
  126.     local radarValues = GetDirectRadar(params.Player);
  127.     local totalItems = GetTotalItems(radarValues);
  128.     -- 1+2+3+...+totalItems value/の値
  129.     local sTotal = (totalItems+1)*totalItems/2;
  130.     local steps = GAMESTATE:GetCurrentSteps(params.Player);
  131.     local meter = steps:GetMeter();
  132.     meter = clamp(meter,1,10);
  133.  
  134.     -- [ja] 満点を求める
  135.     local length = 1;
  136.     if (GAMESTATE:GetCurrentSong():IsMarathon()) then
  137.         length = 3;
  138.     elseif (GAMESTATE:GetCurrentSong():IsLong()) then
  139.         length = 2;
  140.     end;
  141.     local baseScore = (meter * length + 1) * 5000000;
  142.  
  143.     local sOne = baseScore/sTotal;
  144.  
  145.     local p = (params.Player == 'PlayerNumber_P1') and 1 or 2;
  146.  
  147.     -- [ja] スコアが0の時に初期化
  148.     if pss:GetScore()==0 then
  149.         sm3_Steps[p] = 0;
  150.         sm3_Score[p] = 0;
  151.         sm3_CurMaxScore[p] = 0;
  152.         sm3_Combo[p] = 0;
  153.         sm3_CurMaxCombo[p] = 0;
  154.         sm3_GradePoints[p] = 0;
  155.         sm3_Bonus[p] = 0;
  156.         sm3_MaxBonus[p] = 0;
  157.     end;
  158.  
  159.     -- [ja] 現在のステップ数
  160.     -- [ja] 地雷とHoldCheckpointsの場合は加算しない
  161.     if params.TapNoteScore ~= "TapNoteScore_HitMine" and
  162.        params.TapNoteScore ~= "TapNoteScore_AvoidMine" and
  163.        params.TapNoteScore ~= "TapNoteScore_CheckpointHit" and
  164.        params.TapNoteScore ~= "TapNoteScore_CheckpointMiss"
  165.     then
  166.         sm3_Steps[p]=sm3_Steps[p]+1;
  167.     end;
  168.  
  169.     -- [en] current score
  170.     -- [ja] 今回加算するスコア(W1の時)
  171.     local vScore = sOne*sm3_Steps[p];
  172.     sm3_CurMaxScore[p] = sm3_CurMaxScore[p]+math.floor(vScore);
  173.  
  174.     -- [ja] グレードの計算は5THではなくMAX2方式
  175.     local gradeWeightTable = {
  176.         ['TapNoteScore_W1'] = 2,
  177.         ['TapNoteScore_W2'] = 2,
  178.         ['TapNoteScore_W3'] = 1,
  179.         ['TapNoteScore_W5'] = -4,
  180.         ['TapNoteScore_Miss'] = -8,
  181.     };
  182.     setmetatable(gradeWeightTable, ZeroIfNotFound);
  183.  
  184.     -- [ja] 判定によって加算量を変更
  185.     if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  186.         vScore = vScore;
  187.         sm3_GradePoints[p] = sm3_GradePoints[p] + 6;
  188.     else
  189.         if (params.HoldNoteScore == 'HoldNoteScore_LetGo') then
  190.             vScore = 0;
  191.         else
  192.             vScore = vScore*multLookup[params.TapNoteScore]/10;
  193.             sm3_GradePoints[p] = sm3_GradePoints[p] + gradeWeightTable[params.TapNoteScore];
  194.         end;
  195.     end;
  196.  
  197.     -- [ja] コンボは自前で処理する
  198.     if not params.HoldNoteScore then
  199.         if params.TapNoteScore == 'TapNoteScore_W1' or
  200.            params.TapNoteScore == 'TapNoteScore_W2' or
  201.            (
  202.             GAMESTATE:GetPlayMode() ~= 'PlayMode_Oni' and
  203.             params.TapNoteScore == 'TapNoteScore_W3'
  204.            )
  205.         then
  206.             sm3_Combo[p] = sm3_Combo[p] + 1;
  207.         -- [ja] 地雷とHoldCheckpointsの場合はリセットしない
  208.         elseif params.TapNoteScore ~= "TapNoteScore_HitMine" and
  209.                params.TapNoteScore ~= "TapNoteScore_AvoidMine" and
  210.                params.TapNoteScore ~= "TapNoteScore_CheckpointHit" and
  211.                params.TapNoteScore ~= "TapNoteScore_CheckpointMiss"
  212.         then
  213.             sm3_Combo[p] = 0;
  214.         end;
  215.         sm3_CurMaxCombo[p] = sm3_CurMaxCombo[p] + 1;
  216.     end;
  217.  
  218.     local bonusTable =
  219.     {
  220.         ['TapNoteScore_W1'] = 55,
  221.         ['TapNoteScore_W2'] = 55,
  222.         ['TapNoteScore_W3'] = 33
  223.     };
  224.     setmetatable(bonusTable, ZeroIfNotFound);
  225.  
  226.     -- [ja] 落ちていた場合は入るスコアが減る
  227.     if (pss:GetFailed()) then
  228.         if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  229.             -- [ja] O.K.判定時は10点
  230.             sm3_Score[p] = sm3_Score[p]+10;
  231.         elseif (params.HoldNoteScore ~= 'HoldNoteScore_LetGo') then
  232.             -- [ja] O.K.でもN.G.でもない場合のスコア:
  233.             -- W1 (Marvelous): 10
  234.             -- W2 (Perfect):    9
  235.             -- W3 (Great):      5
  236.             sm3_Score[p] = sm3_Score[p]+multLookup[params.TapNoteScore];
  237.         end;
  238.  
  239.         -- [ja] 5点単位の処理がなぜかここでされる
  240.         if multLookup[params.TapNoteScore] > 0 then
  241.             sm3_Score[p] = math.floor((sm3_Score[p] + 2) / 5) * 5;
  242.         end;
  243.     else
  244.         sm3_Score[p] = sm3_Score[p]+math.floor(vScore);
  245.         if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  246.             sm3_Bonus[p] = sm3_Bonus[p]+55*sm3_Combo[p];
  247.         elseif (params.HoldNoteScore ~= 'HoldNoteScore_LetGo') then
  248.             sm3_Bonus[p] = sm3_Bonus[p]+bonusTable[params.TapNoteScore]*sm3_Combo[p];
  249.         end;
  250.         sm3_MaxBonus[p] = sm3_MaxBonus[p]+55*sm3_CurMaxCombo[p];
  251.     end;
  252.  
  253.     if (sm3_Steps[p] == totalItems and not pss:GetFailed()) then
  254.         -- [ja] 最後の1ステップがW2以上の場合、端数を加算する
  255.         -- [ja] 端数は設定上の満点と最終ステップ時点での満点の差から求める
  256.         if (isW2OrAbove(params.TapNoteScore) or params.HoldNoteScore == 'HoldNoteScore_Held') then
  257.             sm3_Score[p] = sm3_Score[p]+(baseScore-sm3_CurMaxScore[p]);
  258.             sm3_CurMaxScore[p] = sm3_CurMaxScore[p]+(baseScore-sm3_CurMaxScore[p]);
  259.         end;
  260.     end;
  261.  
  262.     -- [ja] 5点単位の処理は5TH方式のみでされる
  263.     pss:SetScore(sm3_Score[p] - sm3_Score[p] % 5);
  264.     pss:SetCurMaxScore(sm3_CurMaxScore[p] - sm3_CurMaxScore[p] % 5);
  265.  
  266.     if (sm3_Steps[p] == totalItems and not pss:GetFailed()) then
  267.         -- [ja] コンボボーナスとグレードボーナスを加算
  268.         -- [ja] 本当はリザルト画面でやりたいんだけどね
  269.         local totalTaps = radarValues:GetValue('RadarCategory_TapsAndHolds');
  270.         local totalHolds = radarValues:GetValue('RadarCategory_Holds') + radarValues:GetValue('RadarCategory_Rolls');
  271.  
  272.         local gradeBonusTable = {
  273.             -- Threshold: sm3_GradePoints[p] / (totalTaps * 2 + totalHolds * 6) * 100
  274.             { Threshold = 100, Bonus = 10000000 },
  275.             { Threshold =  93, Bonus =  1000000 },
  276.             { Threshold =  80, Bonus =   100000 },
  277.             { Threshold =  65, Bonus =    10000 },
  278.             { Threshold =  45, Bonus =     1000 },
  279.             -- [ja] 45%に達していない場合は100点とする
  280.         };
  281.  
  282.         local gradeBonus = 100;
  283.  
  284.         for i = 1,#gradeBonusTable do
  285.             if (sm3_GradePoints[p] / (totalTaps * 2 + totalHolds * 6) * 100 >= gradeBonusTable[i].Threshold) then
  286.                 gradeBonus = gradeBonusTable[i].Bonus;
  287.                 break;
  288.             end;
  289.         end;
  290.  
  291.         if pss:GetFailed() then
  292.             gradeBonus = 0;
  293.         end;
  294.  
  295.         pss:SetScore(pss:GetScore()+sm3_Bonus[p]+gradeBonus);
  296.         pss:SetCurMaxScore(pss:GetCurMaxScore()+sm3_MaxBonus[p]+10000000);
  297.     end;
  298. end;
  299.  
  300. r["3.9Plus HYBRID"] = function(params, pss)
  301.     local multLookup =
  302.     {
  303.         ['TapNoteScore_W1'] = 10,
  304.         ['TapNoteScore_W2'] = GAMESTATE:ShowW1() and 9 or 10,
  305.         ['TapNoteScore_W3'] = 5
  306.     };
  307.     setmetatable(multLookup, ZeroIfNotFound);
  308.     local radarValues = GetDirectRadar(params.Player);
  309.     local totalItems = GetTotalItems(radarValues);
  310.     -- 1+2+3+...+totalItems value/の値
  311.     local sTotal = (totalItems+1)*totalItems/2;
  312.     local steps = GAMESTATE:GetCurrentSteps(params.Player);
  313.     local meter = steps:GetMeter();
  314.     meter = clamp(meter,1,10);
  315.  
  316.     -- [ja] 満点を求める
  317.     local length = 1;
  318.     if (GAMESTATE:GetCurrentSong():IsMarathon()) then
  319.         length = 3;
  320.     elseif (GAMESTATE:GetCurrentSong():IsLong()) then
  321.         length = 2;
  322.     end;
  323.     local baseScore = 100000000 * length;
  324.  
  325.     local sOne = baseScore/sTotal;
  326.  
  327.     local p = (params.Player == 'PlayerNumber_P1') and 1 or 2;
  328.  
  329.     -- [ja] スコアが0の時に初期化
  330.     if pss:GetScore()==0 then
  331.         sm3_Steps[p] = 0;
  332.     end;
  333.  
  334.     -- [ja] 現在のステップ数
  335.     -- [ja] 地雷とHoldCheckpointsの場合は加算しない
  336.     if params.TapNoteScore ~= "TapNoteScore_HitMine" and
  337.        params.TapNoteScore ~= "TapNoteScore_AvoidMine" and
  338.        params.TapNoteScore ~= "TapNoteScore_CheckpointHit" and
  339.        params.TapNoteScore ~= "TapNoteScore_CheckpointMiss"
  340.     then
  341.         sm3_Steps[p]=sm3_Steps[p]+1;
  342.     end;
  343.  
  344.     -- [en] current score
  345.     -- [ja] 今回加算するスコア(W1の時)
  346.     local vScore = sOne*sm3_Steps[p];
  347.     pss:SetCurMaxScore(pss:GetCurMaxScore()+math.floor(vScore));
  348.     -- [ja] 判定によって加算量を変更
  349.     if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  350.         vScore = vScore;
  351.     else
  352.         if (params.HoldNoteScore == 'HoldNoteScore_LetGo') then
  353.             vScore = 0;
  354.         else
  355.             vScore = vScore*multLookup[params.TapNoteScore]/10;
  356.         end;
  357.     end;
  358.  
  359.     -- [ja] 落ちていた場合は入るスコアが減る
  360.     if (pss:GetFailed()) then
  361.         if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  362.             -- [ja] O.K.判定時は10点
  363.             pss:SetScore(pss:GetScore()+10);
  364.         elseif (params.HoldNoteScore ~= 'HoldNoteScore_LetGo') then
  365.             -- [ja] O.K.でもN.G.でもない場合のスコア:
  366.             -- W1 (Marvelous): 10
  367.             -- W2 (Perfect):    9
  368.             -- W3 (Great):      5
  369.             pss:SetScore(pss:GetScore()+multLookup[params.TapNoteScore]);
  370.         end;
  371.  
  372.         -- [ja] 5点単位の処理がなぜかここでされる
  373.         if multLookup[params.TapNoteScore] > 0 then
  374.             pss:SetScore(math.floor((pss:GetScore() + 2) / 5) * 5);
  375.         end;
  376.     else
  377.         pss:SetScore(pss:GetScore()+math.floor(vScore));
  378.     end;
  379.  
  380.     if (sm3_Steps[p] == totalItems and not pss:GetFailed()) then
  381.         -- [ja] 最後の1ステップがW2以上の場合、端数を加算する
  382.         -- [ja] 端数は設定上の満点と最終ステップ時点での満点の差から求める
  383.         if (isW2OrAbove(params.TapNoteScore) or params.HoldNoteScore == 'HoldNoteScore_Held') then
  384.             pss:SetScore(pss:GetScore()+(baseScore-pss:GetCurMaxScore()));
  385.             pss:SetCurMaxScore(pss:GetCurMaxScore()+(baseScore-pss:GetCurMaxScore()));
  386.         end;
  387.     end;
  388. end;
  389.  
  390. r["3.9Plus SN"] = function(params, pss)
  391.     local radarValues = GetDirectRadar(params.Player);
  392.     local totalItems = GetTotalItems(radarValues);
  393.  
  394.     -- [ja] 満点を求める
  395.     local length = 1;
  396.     if (GAMESTATE:GetCurrentSong():IsMarathon()) then
  397.         length = 3;
  398.     elseif (GAMESTATE:GetCurrentSong():IsLong()) then
  399.         length = 2;
  400.     end;
  401.     local baseScore = 10000000 * length;
  402.  
  403.     -- [en] current score
  404.     -- [ja] 今回加算するスコア
  405.     local multLookup =
  406.     {
  407.         ['TapNoteScore_W1'] = math.floor(baseScore / totalItems),
  408.         ['TapNoteScore_W2'] = math.floor(baseScore / totalItems),
  409.         ['TapNoteScore_W3'] = math.floor(math.floor(baseScore / 2) / totalItems)
  410.     };
  411.     setmetatable(multLookup, ZeroIfNotFound);
  412.     local vScore = multLookup[params.TapNoteScore];
  413.     pss:SetCurMaxScore(pss:GetCurMaxScore()+multLookup['TapNoteScore_W1']);
  414.  
  415.     -- [ja] 判定によって加算量を変更
  416.     if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  417.         vScore = multLookup['TapNoteScore_W1'];
  418.     elseif (params.HoldNoteScore == 'HoldNoteScore_LetGo') then
  419.         vScore = 0;
  420.     end;
  421.  
  422.     -- [ja] 落ちていた場合は入るスコアが減る
  423.     if (not pss:GetFailed()) then
  424.         pss:SetScore(pss:GetScore()+math.floor(vScore));
  425.     end;
  426.  
  427.     -- [ja] 端数の処理はされていないようだ
  428. end;
  429.  
  430. r["3.9Plus SN2"] = function(params, pss)
  431.     local radarValues = GetDirectRadar(params.Player);
  432.     local totalItems = GetTotalItems(radarValues);
  433.  
  434.     -- [ja] 満点を求める
  435.     local length = 1;
  436.     if (GAMESTATE:GetCurrentSong():IsMarathon()) then
  437.         length = 3;
  438.     elseif (GAMESTATE:GetCurrentSong():IsLong()) then
  439.         length = 2;
  440.     end;
  441.     local baseScore = 1000000 * length;
  442.  
  443.     -- [en] current score
  444.     -- [ja] 今回加算するスコア
  445.     local multLookup =
  446.     {
  447.         ['TapNoteScore_W1'] = math.floor(baseScore / totalItems),
  448.         ['TapNoteScore_W2'] = math.floor(baseScore / totalItems) - 10,
  449.         ['TapNoteScore_W3'] = math.floor(math.floor(baseScore / 2) / totalItems) - 10
  450.     };
  451.     setmetatable(multLookup, ZeroIfNotFound);
  452.     local vScore = multLookup[params.TapNoteScore];
  453.     pss:SetCurMaxScore(pss:GetCurMaxScore()+multLookup['TapNoteScore_W1']);
  454.  
  455.     -- [ja] 判定によって加算量を変更
  456.     if (params.HoldNoteScore == 'HoldNoteScore_Held') then
  457.         vScore = multLookup['TapNoteScore_W1'];
  458.     elseif (params.HoldNoteScore == 'HoldNoteScore_LetGo') then
  459.         vScore = 0;
  460.     end;
  461.  
  462.     -- [ja] 落ちていた場合は入るスコアが減る
  463.     if (not pss:GetFailed()) then
  464.         pss:SetScore(pss:GetScore()+math.floor(vScore));
  465.     end;
  466.  
  467.     -- [ja] 端数の処理はされていないようだ
  468. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement