Skip to content

Commit

Permalink
i love fixing dumb sing animation dodge things
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Jan 27, 2024
1 parent 4acd36f commit 3964bc2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
2 changes: 2 additions & 0 deletions source/game/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ class Character extends FlxSprite {
}

public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void {
if (playFullAnim)
return;
if (!animation.exists(AnimName))
return;

Expand Down
7 changes: 6 additions & 1 deletion source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,14 @@ class Note extends FlxSkewedSprite {
}
}

public inline function checkPlayerMustPress() //flips must press for opponent mode
{
return (PlayState.characterPlayingAs == 1 ? !mustPress : mustPress);
}

public function calculateCanBeHit() {
if (this != null) {
if (mustPress) {
if (checkPlayerMustPress()) {
/**
TODO: make this shit use something from the arrow config .txt file
**/
Expand Down
4 changes: 4 additions & 0 deletions source/modding/ModchartUtilities.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,10 @@ class ModchartUtilities {
PlayState.instance.notes.members[id].modAngle = angle;
});

setLuaFunction("getUnspawnedNoteSingAnimPrefix", function(id:Int) {
return PlayState.instance.unspawnNotes[id].singAnimPrefix;
});

setLuaFunction("setUnspawnedNoteSingAnimPrefix", function(id:Int, prefix:String) {
PlayState.instance.unspawnNotes[id].singAnimPrefix = prefix;
});
Expand Down
42 changes: 19 additions & 23 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ class PlayState extends MusicBeatState {

if (generatedMusic && !switchedStates && startedCountdown && notes != null && playerStrums.members.length != 0 && enemyStrums.members.length != 0) {
notes.forEachAlive(function(daNote:Note) {
var coolStrum = (daNote.mustPress ? playerStrums.members[Math.floor(Math.abs(daNote.noteData))%playerStrums.members.length] : enemyStrums.members[Math.floor(Math.abs(daNote.noteData))%enemyStrums.members.length]);
var coolStrum = (daNote.checkPlayerMustPress() ? playerStrums.members[Math.floor(Math.abs(daNote.noteData))%playerStrums.members.length] : enemyStrums.members[Math.floor(Math.abs(daNote.noteData))%enemyStrums.members.length]);
var strumY = coolStrum.y;
daNote.visible = true;
daNote.active = true;
Expand Down Expand Up @@ -2606,7 +2606,7 @@ class PlayState extends MusicBeatState {



if (!daNote.mustPress && daNote.strumTime <= Conductor.songPosition && daNote.shouldHit) {
if (!daNote.checkPlayerMustPress() && 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;
Expand All @@ -2619,13 +2619,11 @@ class PlayState extends MusicBeatState {
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))]
+ altAnim, true);
dad.otherCharacters[daNote.character].playAnim(singAnim);
else {
for (character in daNote.characters) {
if (dad.otherCharacters.length - 1 >= character)
dad.otherCharacters[character].playAnim(NoteVariables.Character_Animation_Arrays[SONG.keyCount - 1][Std.int(Math.abs(daNote.noteData))]
+ altAnim, true);
dad.otherCharacters[character].playAnim(singAnim);
}
}
}
Expand Down Expand Up @@ -2773,7 +2771,7 @@ class PlayState extends MusicBeatState {
}

if (daNote != null && coolStrum != null) {
if (daNote.mustPress && daNote != null)
if (daNote.checkPlayerMustPress() && daNote != null)
{
var coolStrum = playerStrums.members[Math.floor(Math.abs(daNote.noteData))];
var arrayVal = Std.string([daNote.noteData, daNote.arrow_Type, daNote.isSustainNote]);
Expand Down Expand Up @@ -2863,7 +2861,7 @@ class PlayState extends MusicBeatState {
}

if (Conductor.songPosition - Conductor.safeZoneOffset > daNote.strumTime) {
if (daNote.mustPress
if (daNote.checkPlayerMustPress()
&& daNote.playMissOnMiss
&& !(daNote.isSustainNote && daNote.animation.curAnim.name == "holdend")
&& !daNote.wasGoodHit && daNote != null) {
Expand Down Expand Up @@ -3566,7 +3564,7 @@ class PlayState extends MusicBeatState {
inputs.remove(input);
} else if (input[2] == 2 && Conductor.songPosition >= input[1] + input[3]) {
for (note in notes) {
if (note.mustPress
if (note.checkPlayerMustPress()
&& FlxMath.roundDecimal(note.strumTime, 2) == FlxMath.roundDecimal(input[1], 2)
&& note.noteData == input[0]) {
justPressedArray[input[0]] = true;
Expand Down Expand Up @@ -3632,7 +3630,7 @@ class PlayState extends MusicBeatState {
notes.forEachAlive(function(note:Note) {
note.calculateCanBeHit();

if (note.canBeHit && note.mustPress && !note.tooLate && !note.isSustainNote)
if (note.canBeHit && note.checkPlayerMustPress() && !note.tooLate && !note.isSustainNote)
possibleNotes.push(note);
});

Expand Down Expand Up @@ -3726,7 +3724,7 @@ class PlayState extends MusicBeatState {
notes.forEachAlive(function(daNote:Note) {
daNote.calculateCanBeHit();

if (heldArray[daNote.noteData] && daNote.isSustainNote && daNote.mustPress) {
if (heldArray[daNote.noteData] && daNote.isSustainNote && daNote.checkPlayerMustPress()) {
if (daNote.canBeHit) {
if (characterPlayingAs == 0) {
if (boyfriend.otherCharacters == null || boyfriend.otherCharacters.length - 1 < daNote.character)
Expand Down Expand Up @@ -3810,7 +3808,7 @@ class PlayState extends MusicBeatState {
} else {
notes.forEachAlive(function(note:Note) {
if (note.shouldHit) {
if (note.mustPress && note.strumTime <= Conductor.songPosition) {
if (note.checkPlayerMustPress() && note.strumTime <= Conductor.songPosition) {
if (characterPlayingAs == 0) {
if (boyfriend.otherCharacters == null || boyfriend.otherCharacters.length - 1 < note.character)
boyfriend.holdTimer = 0;
Expand Down Expand Up @@ -3888,7 +3886,7 @@ class PlayState extends MusicBeatState {
if (note == null)
canMiss = true;
else {
if (note.mustPress)
if (note.checkPlayerMustPress())
canMiss = true;
}

Expand Down Expand Up @@ -4036,13 +4034,11 @@ class PlayState extends MusicBeatState {
if (characterPlayingAs == 0) {
if (boyfriend.otherCharacters != null && !(boyfriend.otherCharacters.length - 1 < note.character))
if (note.characters.length <= 1)
boyfriend.otherCharacters[note.character].playAnim(NoteVariables.Character_Animation_Arrays[SONG.playerKeyCount - 1][Std.int(Math.abs(note.noteData % SONG.playerKeyCount))],
true);
boyfriend.otherCharacters[note.character].playAnim(singAnim);
else {
for (character in note.characters) {
if (boyfriend.otherCharacters.length - 1 >= character)
boyfriend.otherCharacters[character].playAnim(NoteVariables.Character_Animation_Arrays[SONG.playerKeyCount - 1][Std.int(Math.abs(note.noteData % SONG.playerKeyCount))],
true);
boyfriend.otherCharacters[character].playAnim(singAnim);
}
}
else
Expand Down Expand Up @@ -4586,7 +4582,7 @@ class PlayState extends MusicBeatState {
}
for (note in notes.members){
if(note.affectedbycolor){
var charColors = (note.mustPress) ? boyfriend : dad;
var charColors = (note.checkPlayerMustPress()) ? boyfriend : dad;
var noteColor;
if (!Options.getData("customNoteColors"))
noteColor = charColors.noteColors[SONG.keyCount - 1][note.noteData];
Expand All @@ -4599,7 +4595,7 @@ class PlayState extends MusicBeatState {
}
for (note in unspawnNotes){
if(note.affectedbycolor){
var charColors = (note.mustPress) ? boyfriend : dad;
var charColors = (note.checkPlayerMustPress()) ? boyfriend : dad;
var noteColor;
if (!Options.getData("customNoteColors"))
noteColor = charColors.noteColors[SONG.keyCount - 1][note.noteData];
Expand Down Expand Up @@ -5013,11 +5009,11 @@ class PlayState extends MusicBeatState {
}
notes.forEachAlive(function(note:Note)
{
note.reloadNotes(note.strumTime, note.noteData, note.prevNote, note.isSustainNote, note.character, note.arrow_Type, PlayState.SONG, note.characters, note.mustPress, note.inEditor);
note.reloadNotes(note.strumTime, note.noteData, note.prevNote, note.isSustainNote, note.character, note.arrow_Type, PlayState.SONG, note.characters, note.checkPlayerMustPress(), note.inEditor);
});
for (i in 0...unspawnNotes.length) {
unspawnNotes[i].reloadNotes(unspawnNotes[i].strumTime, unspawnNotes[i].noteData, null, unspawnNotes[i].isSustainNote, unspawnNotes[i].character,
unspawnNotes[i].arrow_Type, PlayState.SONG, unspawnNotes[i].characters, unspawnNotes[i].mustPress, unspawnNotes[i].inEditor);
unspawnNotes[i].arrow_Type, PlayState.SONG, unspawnNotes[i].characters, unspawnNotes[i].checkPlayerMustPress(), unspawnNotes[i].inEditor);
}
#if linc_luajit
for (i in 0...strumLineNotes.length) {
Expand Down Expand Up @@ -5109,10 +5105,10 @@ class PlayState extends MusicBeatState {
}
}
for (note in unspawnNotes) {
note.reloadNotes(note.strumTime, note.noteData, note.prevNote, note.isSustainNote, note.character, note.arrow_Type, PlayState.SONG, note.characters, note.mustPress, note.inEditor);
note.reloadNotes(note.strumTime, note.noteData, note.prevNote, note.isSustainNote, note.character, note.arrow_Type, PlayState.SONG, note.characters, note.checkPlayerMustPress(), note.inEditor);
}
for (note in notes.members) {
note.reloadNotes(note.strumTime, note.noteData, null, note.isSustainNote, note.character, note.arrow_Type, PlayState.SONG, note.characters, note.mustPress, note.inEditor);
note.reloadNotes(note.strumTime, note.noteData, null, note.isSustainNote, note.character, note.arrow_Type, PlayState.SONG, note.characters, note.checkPlayerMustPress(), note.inEditor);
}
}

Expand Down

0 comments on commit 3964bc2

Please sign in to comment.