Skip to content

Commit

Permalink
get the ohts right
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 25, 2020
1 parent 8f3b884 commit f8f0a2c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 11 deletions.
5 changes: 5 additions & 0 deletions Themes/Til Death/BGAnimations/_calcdisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,16 @@ local debugGroups = {
RanLen = true,
RanAnchLen = true,
RanAnchLenMod = true,
RanOHT = true,
RanOffS = true,
RanJack = true,
RanPropAll = true,
RanPropOHT = true,
RanPropOff = true,
RanPropOffS = true,
RanPropJack = true,


},
{},
[9] = {},
Expand Down
72 changes: 61 additions & 11 deletions src/Etterna/Globals/MinaCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,12 +1044,28 @@ update_col_time(const col_type& col, float arr[2], const float& val)
return;
};

// inverting col state for col_left or col_right only
inline col_type
invert_col(const col_type& col)
{
// this should crash or something idk.. this is just for flipping
// left->right and vice versa to be used in indexing... dangerous if misused
// due to unpredictable/undefined behavior
if (col != col_left && col != col_right)
return col_init;
return col == col_left ? col_right : col_left;
};

// inverting cc state for left_right or right_left only
inline cc_type
invert_cc(const cc_type& cc)
{
// this should also crash, but it's not as dangerous as above
if (cc != cc_left_right && cc != cc_right_left)
return cc_init;
return cc == cc_left_right ? cc_right_left : cc_left_right;
};

void
set_metanoteinfo_timings(metanoteinfo& mni,
const float cur[2],
Expand Down Expand Up @@ -1114,6 +1130,8 @@ struct nemnar
unsigned int total_taps = 0;
unsigned int ran_taps = 0;
col_type anchor_col = col_init;
cc_type last_cc = cc_init;
cc_type last_last_cc = cc_init;
unsigned int anchor_len = 0;
unsigned int off_taps_same = 0;
unsigned int oht_taps = 0; // not tracking yet
Expand All @@ -1131,14 +1149,18 @@ find_ranmen_tho(const vector<NoteInfo>& NoteInfo, nemnar& z, int t1, int t2){

};

static const int max_oht_len = 3;
static const int max_oht_len = 2;
static const int max_off_spacing = 2;
static const int max_burst_len = 6;
static const int max_jack_len = 1;

inline void
reset_ranmens(nemnar& rm)
{
// don't reset anchor_col or last_col
// we want to preserve the pattern state
// reset everything else tho

rm.trill_bill = false;
rm.is_bursting = false;
rm.had_burst = false;
Expand Down Expand Up @@ -1241,7 +1263,7 @@ handle_ranman_off_progression(nemnar& rm, const float& now)

// offnote, reset jack length & oht length
rm.jack_len = 0;
rm.oht_len = 0;
//rm.oht_len = 0;

rm.off_total_ms += ms_from(now, rm.last_anchor_time);

Expand Down Expand Up @@ -1270,6 +1292,22 @@ handle_ranman_jack_progression(nemnar& rm)
reset_ranmens(rm);
}

bool
is_oht(const cc_type& a, const cc_type& b, const cc_type& c)
{
// we are flipping b with invert col so make sure it's left_right or right_left
// single note, if either of the other two aren't this will fail anyway and
// it's fine
if (b != cc_left_right && b != cc_right_left)
return false;

bool loot = a ==
invert_cc(b);
bool doot = a == c;
// this is kind of big brain so if you don't get it that's ok
return loot && doot;
}

#pragma endregion
vector<vector<metanoteinfo>>
gen_metanoteinfo(const vector<vector<int>>& itv_rows,
Expand Down Expand Up @@ -1315,8 +1353,7 @@ gen_metanoteinfo(const vector<vector<int>>& itv_rows,
for (size_t i = 0; i < itv_rows.size(); ++i) {
p.clear();
auto& itv = itv_rows[i];
for (auto& row : itv)
{
for (auto& row : itv) {
metanoteinfo mni;
set_col_and_cc_types(mni,
NoteInfo[row].notes & t1,
Expand All @@ -1339,6 +1376,15 @@ gen_metanoteinfo(const vector<vector<int>>& itv_rows,
for (auto& rm : rms) {
rm.total_taps += column_count(cols);

// oht
if (is_oht(rm.last_last_cc, rm.last_cc, mni.cc)) {
++rm.oht_len;
++rm.oht_taps;
if (rm.oht_len > max_oht_len)
reset_ranmens(rm);
}


// if (offhand_tap) {
// // moved to the cc_empty case in the swtich cause i
// // think these are identical conditions
Expand Down Expand Up @@ -1436,11 +1482,13 @@ gen_metanoteinfo(const vector<vector<int>>& itv_rows,
default:
break;
}
rm.last_last_cc = rm.last_cc;
rm.last_cc = mni.cc;
}
ran_last = mni.col;
was_last_offhand_tap = offhand_tap;
}

// we don't want to set lasttime or lastcol for empty rows
if (mni.col == col_empty)
continue;
Expand Down Expand Up @@ -1504,7 +1552,8 @@ gen_metanoteinfo(const vector<vector<int>>& itv_rows,

propb = CalcClamp(propb, 0.1f, 1.1f);

// same hand off to ranmon prop
// same hand off to ranmon prop, if this is 0 we want to
// negate the ranmen bonus
float propc = 0.f;
if (rm.off_taps_same > 0)
propc = static_cast<float>(rm.off_taps_same) /
Expand All @@ -1529,9 +1578,10 @@ gen_metanoteinfo(const vector<vector<int>>& itv_rows,

// debug
doot[RanMan][i] = bazoink;
doot[RanLen][i] = rm.total_taps;
doot[RanAnchLen][i] = rm.anchor_len;
doot[RanAnchLenMod][i] = boopie;
doot[RanLen][i] = static_cast<float>(rm.total_taps) / 100.f;
doot[RanAnchLen][i] = static_cast<float>(rm.anchor_len) / 30.f;
doot[RanAnchLenMod][i] = boopie / 10.f;
doot[RanOHT][i] = rm.oht_taps;
doot[RanOffS][i] = rm.off_taps_same;
doot[RanJack][i] = rm.jack_taps;
doot[RanPropAll][i] = propa;
Expand All @@ -1543,8 +1593,8 @@ gen_metanoteinfo(const vector<vector<int>>& itv_rows,
}
}
}
Smooth(doot[RanMan], 1.f);
Smooth(doot[RanMan], 1.f);
// Smooth(doot[RanMan], 1.f);
// Smooth(doot[RanMan], 1.f);
return o;
}

Expand Down

0 comments on commit f8f0a2c

Please sign in to comment.