forked from bbpanzu/bb-fnf-mods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEtternaFunctions.hx
84 lines (75 loc) · 2.4 KB
/
EtternaFunctions.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class EtternaFunctions
{
// erf constants
public static var a1 = 0.254829592;
public static var a2 = -0.284496736;
public static var a3 = 1.421413741;
public static var a4 = -1.453152027;
public static var a5 = 1.061405429;
public static var p = 0.3275911;
public static function erf(x:Float):Float
{
// Save the sign of x
var sign = 1;
if (x < 0)
sign = -1;
x = Math.abs(x);
// A&S formula 7.1.26
var t = 1.0/(1.0 + p*x);
var y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*Math.exp(-x*x);
return sign*y;
}
public static function getNotes():Int
{
var notes:Int = 0;
for (i in 0...PlayState.SONG.notes.length)
{
for (ii in 0...PlayState.SONG.notes[i].sectionNotes.length)
{
var n = PlayState.SONG.notes[i].sectionNotes[ii];
if (n[1] <= 0)
notes++;
}
}
return notes;
}
public static function getHolds():Int
{
var notes:Int = 0;
for (i in 0...PlayState.SONG.notes.length)
{
trace(PlayState.SONG.notes[i]);
for (ii in 0...PlayState.SONG.notes[i].sectionNotes.length)
{
var n = PlayState.SONG.notes[i].sectionNotes[ii];
trace(n);
if (n[1] > 0)
notes++;
}
}
return notes;
}
public static function getMapMaxScore():Int
{
return (getNotes() * 350);
}
public static function wife3(maxms:Float, ts:Float)
{
var max_points = 1.0;
var miss_weight = -5.5;
var ridic= 5 * ts;
var max_boo_weight = 180 * ts;
var ts_pow = 0.75;
var zero = 65 * (Math.pow(ts,ts_pow));
var power = 2.5;
var dev = 22.7 * (Math.pow(ts,ts_pow));
if (maxms <= ridic) // anything below this (judge scaled) threshold is counted as full pts
return max_points;
else if (maxms <= zero) // ma/pa region, exponential
return max_points * erf((zero - maxms) / dev);
else if (maxms <= max_boo_weight)// cb region, linear
return (maxms - zero) * miss_weight / (max_boo_weight - zero);
else
return miss_weight;
}
}