Skip to content

Commit

Permalink
bopper don't desync
Browse files Browse the repository at this point in the history
  • Loading branch information
MidyGamy committed Aug 5, 2024
1 parent 9b483de commit c154ec2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion source/funkin/play/stage/Bopper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,31 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
*/
public function onBeatHit(event:SongTimeScriptEvent):Void
{
if (danceEvery > 0 && event.beat % danceEvery == 0)
if (danceEvery > 0 && event.beat % calculateDanceEvery() == 0)
{
dance(shouldBop);
}
}

function calculateDanceEvery():Int
{
// return danceEvery;

if (danceEvery <= 0 || shouldAlternate || this.animation.getByName('idle') == null) return danceEvery;
else if (this.animation.curAnim.name == 'idle' && !this.animation.curAnim.finished) return 1;

var daIdle = this.animation.getByName('idle');
var calc:Float = (daIdle.numFrames / daIdle.frameRate) / (Conductor.instance.beatLengthMs / 1000);
var danceEveryNumBeats:Int = Math.ceil(calc);
var numeratorTweak:Int = (Conductor.instance.timeSignatureNumerator % 2 == 0) ? 2 : 3;
if (danceEveryNumBeats > numeratorTweak)
{
while (danceEveryNumBeats % numeratorTweak != 0)
danceEveryNumBeats++;
}
return Std.int(Math.max(danceEvery, danceEveryNumBeats));
}

/**
* Called every `danceEvery` beats of the song.
*/
Expand Down

0 comments on commit c154ec2

Please sign in to comment.