Skip to content

Commit

Permalink
crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Dec 15, 2023
1 parent 053984c commit 907aba1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
8 changes: 8 additions & 0 deletions source/game/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ class Character extends FlxSprite {
if (!animation.exists(AnimName))
return;


if (singAnimPrefix != 'sing' && AnimName.contains('sing')){
var anim = AnimName;
anim = anim.replace('sing', singAnimPrefix);
if (animation.getByName(anim) != null) //check if it exists so no broken anims
AnimName = anim;
}

preventDanceForAnim = false; //reset it

if(useTextureAtlas){
Expand Down
4 changes: 3 additions & 1 deletion source/states/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,9 @@ class FreeplayState extends MusicBeatState {
iconArray[i].animation.curAnim.curFrame = 0;
}

iconArray[curSelected].alpha = 1;
if (curSelected >= 0 && (curSelected <= iconArray.length)){
iconArray[curSelected].alpha = 1;
}

if (iconArray[curSelected].animation.curAnim != null && !iconArray[curSelected].animatedIcon) {
iconArray[curSelected].animation.curAnim.curFrame = 2;
Expand Down
23 changes: 21 additions & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2629,9 +2629,14 @@ class PlayState extends MusicBeatState {
if (!daNote.mustPress && daNote.strumTime <= Conductor.songPosition && daNote.shouldHit) {
camZooming = true;

var singAnim:String = NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(false) - 1][Std.int(Math.abs(daNote.noteData))] + (characterPlayingAs == 0 ? altAnim : "") + daNote.singAnimSuffix;
if (daNote.singAnimPrefix != 'sing'){
singAnim = singAnim.replace('sing', daNote.singAnimPrefix);
}

if (characterPlayingAs == 0) {
if (dad.otherCharacters == null || dad.otherCharacters.length - 1 < daNote.character)
dad.playAnim(NoteVariables.Character_Animation_Arrays[SONG.keyCount - 1][Std.int(Math.abs(daNote.noteData))] + altAnim, true);
dad.playAnim(singAnim, true);
else {
if (daNote.characters.length <= 1)
dad.otherCharacters[daNote.character].playAnim(NoteVariables.Character_Animation_Arrays[SONG.keyCount - 1][Std.int(Math.abs(daNote.noteData))]
Expand Down Expand Up @@ -2679,7 +2684,7 @@ class PlayState extends MusicBeatState {
}
} else {
if (boyfriend.otherCharacters == null || boyfriend.otherCharacters.length - 1 < daNote.character)
boyfriend.playAnim(NoteVariables.Character_Animation_Arrays[SONG.keyCount - 1][Std.int(Math.abs(daNote.noteData))], true);
boyfriend.playAnim(singAnim, true);
else if (daNote.characters.length <= 1)
boyfriend.otherCharacters[daNote.character].playAnim(NoteVariables.Character_Animation_Arrays[SONG.keyCount - 1][Std.int(Math.abs(daNote.noteData))],
true);
Expand Down Expand Up @@ -4010,6 +4015,11 @@ class PlayState extends MusicBeatState {

var lua_Data:Array<Dynamic> = [note.noteData, Conductor.songPosition, note.arrow_Type, note.strumTime, note.character];

var singAnim:String = NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][Std.int(Math.abs(note.noteData % getCorrectKeyCount(true)))] + (characterPlayingAs == 1 ? altAnim : "") + note.singAnimSuffix;
if (note.singAnimPrefix != 'sing'){
singAnim = singAnim.replace('sing', note.singAnimPrefix);
}

if (characterPlayingAs == 0) {
if (boyfriend.otherCharacters != null && !(boyfriend.otherCharacters.length - 1 < note.character))
if (note.characters.length <= 1)
Expand Down Expand Up @@ -5181,6 +5191,15 @@ class PlayState extends MusicBeatState {
scripts.push(noteScript);
}
}
function getCorrectKeyCount(player:Bool)
{
var kc = SONG.keyCount;
if ((player && characterPlayingAs == 0) || (characterPlayingAs == 1 && !player))
{
kc = SONG.playerKeyCount;
}
return kc;
}
}

enum Execute_On {
Expand Down

0 comments on commit 907aba1

Please sign in to comment.