1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-23 21:56:46 +00:00

Fix several character animation issues

This commit is contained in:
EliteMasterEric 2024-06-28 22:29:59 -04:00
parent dd30012d80
commit 84dd1cd3b9
4 changed files with 102 additions and 27 deletions

2
assets

@ -1 +1 @@
Subproject commit 225e248f148a92500a6fe90e4f10e4cd2acee782
Subproject commit 9050732ec1cc69cbca9a9a73ee817459f84bdc53

View file

@ -151,7 +151,8 @@ class HitNoteScriptEvent extends NoteScriptEvent
public var hitDiff:Float = 0;
/**
* If the hit causes a notesplash
* Whether this note hit causes a note splash to display.
* Defaults to true only on "sick" notes.
*/
public var doesNotesplash:Bool = false;

View file

@ -308,13 +308,26 @@ class BaseCharacter extends Bopper
// so we can query which ones are available.
this.comboNoteCounts = findCountAnimations('combo'); // example: combo50
this.dropNoteCounts = findCountAnimations('drop'); // example: drop50
// trace('${this.animation.getNameList()}');
// trace('Combo note counts: ' + this.comboNoteCounts);
// trace('Drop note counts: ' + this.dropNoteCounts);
if (comboNoteCounts.length > 0) trace('Combo note counts: ' + this.comboNoteCounts);
if (dropNoteCounts.length > 0) trace('Drop note counts: ' + this.dropNoteCounts);
super.onCreate(event);
}
override function onAnimationFinished(animationName:String):Void
{
super.onAnimationFinished(animationName);
trace('${characterId} has finished animation: ${animationName}');
if ((animationName.endsWith(Constants.ANIMATION_END_SUFFIX) && !animationName.startsWith('idle') && !animationName.startsWith('dance'))
|| animationName.startsWith('combo')
|| animationName.startsWith('drop'))
{
// Force the character to play the idle after the animation ends.
this.dance(true);
}
}
function resetCameraFocusPoint():Void
{
// Calculate the camera focus point
@ -368,9 +381,11 @@ class BaseCharacter extends Bopper
// and Darnell (this keeps the flame on his lighter flickering).
// Works for idle, singLEFT/RIGHT/UP/DOWN, alt singing animations, and anything else really.
if (!getCurrentAnimation().endsWith('-hold') && hasAnimation(getCurrentAnimation() + '-hold') && isAnimationFinished())
if (!getCurrentAnimation().endsWith(Constants.ANIMATION_HOLD_SUFFIX)
&& hasAnimation(getCurrentAnimation() + Constants.ANIMATION_HOLD_SUFFIX)
&& isAnimationFinished())
{
playAnimation(getCurrentAnimation() + '-hold');
playAnimation(getCurrentAnimation() + Constants.ANIMATION_HOLD_SUFFIX);
}
// Handle character note hold time.
@ -395,9 +410,27 @@ class BaseCharacter extends Bopper
{
trace('holdTimer reached ${holdTimer}sec (> ${singTimeSec}), stopping sing animation');
holdTimer = 0;
var currentAnimation:String = getCurrentAnimation();
// Strip "-hold" from the end.
if (currentAnimation.endsWith(Constants.ANIMATION_HOLD_SUFFIX)) currentAnimation = currentAnimation.substring(0,
currentAnimation.length - Constants.ANIMATION_HOLD_SUFFIX.length);
var endAnimation:String = currentAnimation + Constants.ANIMATION_END_SUFFIX;
if (hasAnimation(endAnimation))
{
// Play the '-end' animation, if one exists.
trace('${characterId}: playing ${endAnimation}');
playAnimation(endAnimation);
}
else
{
// Play the idle animation.
trace('${characterId}: attempting dance');
dance(true);
}
}
}
else
{
holdTimer = 0;
@ -408,7 +441,8 @@ class BaseCharacter extends Bopper
public function isSinging():Bool
{
return getCurrentAnimation().startsWith('sing');
var currentAnimation:String = getCurrentAnimation();
return currentAnimation.startsWith('sing') && !currentAnimation.endsWith(Constants.ANIMATION_END_SUFFIX);
}
override function dance(force:Bool = false):Void
@ -418,15 +452,15 @@ class BaseCharacter extends Bopper
if (!force)
{
// Prevent dancing while a singing animation is playing.
if (isSinging()) return;
// Prevent dancing while a non-idle special animation is playing.
var currentAnimation:String = getCurrentAnimation();
if ((currentAnimation == 'hey' || currentAnimation == 'cheer') && !isAnimationFinished()) return;
if (!currentAnimation.startsWith('dance') && !currentAnimation.startsWith('idle') && !isAnimationFinished()) return;
}
// Prevent dancing while another animation is playing.
if (!force && isSinging()) return;
trace('${characterId}: Actually dancing');
// Otherwise, fallback to the super dance() method, which handles playing the idle animation.
super.dance();
}
@ -499,6 +533,16 @@ class BaseCharacter extends Bopper
this.playSingAnimation(event.note.noteData.getDirection(), false);
holdTimer = 0;
}
else if (characterType == GF && event.note.noteData.getMustHitNote())
{
switch (event.judgement)
{
case 'sick' | 'good':
playComboAnimation(event.comboCount);
default:
playComboDropAnimation(event.comboCount);
}
}
}
/**
@ -521,26 +565,41 @@ class BaseCharacter extends Bopper
}
else if (event.note.noteData.getMustHitNote() && characterType == GF)
{
var dropAnim = '';
playComboDropAnimation(Highscore.tallies.combo);
}
}
function playComboAnimation(comboCount:Int):Void
{
var comboAnim = 'combo${comboCount}';
if (hasAnimation(comboAnim))
{
trace('Playing GF combo animation: ${comboAnim}');
this.playAnimation(comboAnim, true, true);
}
}
function playComboDropAnimation(comboCount:Int):Void
{
var dropAnim:Null<String> = null;
// Choose the combo drop anim to play.
// If there are several (for example, drop10 and drop50) the highest one will be used.
// If the combo count is too low, no animation will be played.
for (count in dropNoteCounts)
{
if (event.comboCount >= count)
if (comboCount >= count)
{
dropAnim = 'drop${count}';
}
}
if (dropAnim != '')
if (dropAnim != null)
{
trace('Playing GF combo drop animation: ${dropAnim}');
this.playAnimation(dropAnim, true, true);
}
}
}
/**
* Every time a wrong key is pressed, play the miss animation if we are Boyfriend.

View file

@ -283,6 +283,21 @@ class Constants
*/
public static final DEFAULT_TIME_SIGNATURE_DEN:Int = 4;
/**
* ANIMATIONS
*/
// ==============================
/**
* A suffix used for animations played when an animation would loop.
*/
public static final ANIMATION_HOLD_SUFFIX:String = '-hold';
/**
* A suffix used for animations played when an animation would end before transitioning to another.
*/
public static final ANIMATION_END_SUFFIX:String = '-end';
/**
* TIMING
*/