From 91a6b772ff17900d523dc230d6e59f7bf695acea Mon Sep 17 00:00:00 2001 From: Spel0 <75626813+Spel0@users.noreply.github.com> Date: Fri, 13 Aug 2021 19:36:56 +0300 Subject: [PATCH] Ability for BF to have idle and notes alt anims + failsafe --- source/Character.hx | 9 +++++++++ source/ChartingState.hx | 2 +- source/PlayState.hx | 21 +++++++++------------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/source/Character.hx b/source/Character.hx index c99941c..1e520b8 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -483,6 +483,15 @@ class Character extends FlxSprite public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void { + + if (AnimName.endsWith('alt') && animation.getByName(AnimName) == null) + { + #if debug + FlxG.log.warn(['Such alt animation doesnt exist: ' + AnimName]); + #end + AnimName = AnimName.split('-')[0]; + } + animation.play(AnimName, Force, Reversed, Frame); var daOffset = animOffsets.get(AnimName); diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 602e4a3..fc39343 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -3027,7 +3027,7 @@ class ChartingState extends MusicBeatState } else { - var note:Note = new Note(n.strumTime, n.noteData % 4,null,false,true); + var note:Note = new Note(n.strumTime, n.noteData % 4,null,false,true, n.isAlt); note.rawNoteData = n.noteData; note.sustainLength = noteSus; note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); diff --git a/source/PlayState.hx b/source/PlayState.hx index c8ef22a..799f5e5 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -4358,17 +4358,14 @@ class PlayState extends MusicBeatState else totalNotesHit += 1; - switch (note.noteData) - { - case 2: - boyfriend.playAnim('singUP', true); - case 3: - boyfriend.playAnim('singRIGHT', true); - case 1: - boyfriend.playAnim('singDOWN', true); - case 0: - boyfriend.playAnim('singLEFT', true); - } + var altAnim:String = ""; + if (note.isAlt) + { + altAnim = '-alt'; + trace("Alt note on BF"); + } + + boyfriend.playAnim('sing' + dataSuffix[note.noteData] + altAnim, true); #if windows if (luaModchart != null) @@ -4631,7 +4628,7 @@ class PlayState extends MusicBeatState if (!boyfriend.animation.curAnim.name.startsWith("sing") && (curBeat % idleBeat == 0 || !idleToBeat)) { - boyfriend.playAnim('idle', idleToBeat); + boyfriend.playAnim('idle' + ((SONG.notes[Math.floor(curStep / 16)].altAnim && boyfriend.animation.getByName('idle-alt') != null) ? '-alt' : ''), idleToBeat); } /*if (!dad.animation.curAnim.name.startsWith("sing"))