From f6a31f8508e0113d7e7f8094b91c601246468675 Mon Sep 17 00:00:00 2001 From: SkyanUltra Date: Sun, 28 Sep 2025 06:25:50 -0400 Subject: [PATCH] New Optional Animation States (#420) * new animation states additional conditional animation states, including: - SkidAttack - IdleAttack - WalkAttack - RunAttack - CrouchJump - CrouchMove ... along with a new set of animations, the Bump animations (play when hitting your head on a block) - JumpBump - CrouchBump - SwimBump * added fly animations & tweaked bump animation time new anims for FlyIdle, FlyUp, FlyMove, FlyAttack, and FlyBump, which all fallback on their Swim counterparts if not found. also changed around some animation fallbacks which made more sense, like bumps using fall animations instead if applicable. * added bump ignore checks and added a general bump animation you can now define Bump which will define a bump animation for all bump animations. additionally, bump animations will only play if they can detect an animation. no more fallbacks needed --- Scripts/Classes/Entities/Player.gd | 29 +++++++++++- Scripts/Classes/States/Player/Normal.gd | 60 ++++++++++++++++++++----- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/Scripts/Classes/Entities/Player.gd b/Scripts/Classes/Entities/Player.gd index 98fd404..d21b4ab 100644 --- a/Scripts/Classes/Entities/Player.gd +++ b/Scripts/Classes/Entities/Player.gd @@ -62,7 +62,12 @@ var character := "Mario" var crouching := false var skidding := false +var bumping := false var can_bump_sfx := true +var can_bump_jump = false +var can_bump_crouch = false +var can_bump_swim = false +var can_bump_fly = false @export var player_id := 0 const ONE_UP_NOTE = preload("uid://dopxwjj37gu0l") @@ -131,6 +136,7 @@ static var CHARACTER_PALETTES := [ const ANIMATION_FALLBACKS := { "JumpFall": "Jump", + "JumpBump": "Bump", "Fall": "Move", "Pipe": "Idle", "Walk": "Move", @@ -138,10 +144,24 @@ const ANIMATION_FALLBACKS := { "PipeWalk": "Move", "LookUp": "Idle", "CrouchFall": "Crouch", - "CrouchAttack": "Attack", + "CrouchJump": "Crouch", + "CrouchBump": "Bump", + "CrouchMove": "Crouch", + "IdleAttack": "Attack", + "CrouchAttack": "IdleAttack", + "MoveAttack": "IdleAttack", + "WalkAttack": "MoveAttack", + "RunAttack": "MoveAttack", + "SkidAttack": "MoveAttack", + "FlyIdle": "SwimIdle", + "FlyUp": "SwimUp", + "FlyMove": "SwimMove", + "FlyAttack": "SwimAttack", + "FlyBump": "SwimBump", "FlagSlide": "Climb", "WaterMove": "Move", "WaterIdle": "Idle", + "SwimBump": "Bump", "DieFreeze": "Die", "StarJump": "Jump", "StarFall": "StarJump" @@ -410,9 +430,12 @@ func bump_ceiling() -> void: AudioManager.play_sfx("bump", global_position) velocity.y = CEILING_BUMP_SPEED can_bump_sfx = false + bumping = true await get_tree().create_timer(0.1).timeout AudioManager.kill_sfx("small_jump") AudioManager.kill_sfx("big_jump") + await get_tree().create_timer(0.1).timeout + bumping = false func super_star() -> void: DiscoLevel.combo_meter += 1 @@ -617,6 +640,10 @@ func set_power_state_frame() -> void: $ResourceSetterNew.update_resource() if %Sprite.sprite_frames != null: can_pose = %Sprite.sprite_frames.has_animation("PoseDoor") + can_bump_jump = %Sprite.sprite_frames.has_animation("JumpBump") + can_bump_crouch = %Sprite.sprite_frames.has_animation("CrouchBump") + can_bump_swim = %Sprite.sprite_frames.has_animation("SwimBump") + can_bump_fly = %Sprite.sprite_frames.has_animation("FlyBump") func get_power_up(power_name := "") -> void: if is_dead: diff --git a/Scripts/Classes/States/Player/Normal.gd b/Scripts/Classes/States/Player/Normal.gd index 21ac11d..c1d48be 100644 --- a/Scripts/Classes/States/Player/Normal.gd +++ b/Scripts/Classes/States/Player/Normal.gd @@ -186,22 +186,47 @@ func get_animation_name() -> String: if player.attacking: if player.crouching: return "CrouchAttack" - if player.is_actually_on_floor(): - return "Attack" - elif player.in_water or player.flight_meter > 0: - return "SwimAttack" + elif player.is_actually_on_floor(): + if player.skidding: + return "SkidAttack" + elif abs(player.velocity.x) >= 5 and not player.is_actually_on_wall(): + if player.in_water: + return "SwimAttack" + elif player.flight_meter > 0: + return "FlyAttack" + elif abs(player.velocity.x) < player.RUN_SPEED - 10: + return "WalkAttack" + else: + return "RunAttack" + else: + return "IdleAttack" else: - return "AirAttack" + if player.in_water: + return "SwimAttack" + elif player.flight_meter > 0: + return "FlyAttack" + else: + return "AirAttack" if player.crouching and not wall_pushing: - if player.velocity.y > 0 and player.is_on_floor() == false: - return "CrouchFall" + if player.bumping and player.can_bump_crouch: + return "CrouchBump" + elif player.is_on_floor() == false: + if player.velocity.y > 0: + return "CrouchFall" + elif player.velocity.y < 0: + return "CrouchJump" + elif player.is_actually_on_floor(): + if abs(player.velocity.x) >= 5 and not player.is_actually_on_wall(): + return "CrouchMove" return "Crouch" if player.is_actually_on_floor(): if player.skidding: return "Skid" elif abs(player.velocity.x) >= 5 and not player.is_actually_on_wall(): - if player.in_water or player.flight_meter > 0: + if player.in_water: return "WaterMove" + elif player.flight_meter > 0: + return "FlyMove" elif abs(player.velocity.x) < player.RUN_SPEED - 10: return "Walk" else: @@ -213,13 +238,26 @@ func get_animation_name() -> String: return "LookUp" return "Idle" else: - if player.in_water or player.flight_meter > 0: + if player.in_water: if swim_up_meter > 0: - return "SwimUp" + if player.bumping and player.can_bump_swim: + return "SwimBump" + else: + return "SwimUp" else: return "SwimIdle" + elif player.flight_meter > 0: + if swim_up_meter > 0: + if player.bumping and player.can_bump_fly: + return "FlyBump" + else: + return "FlyUp" + else: + return "FlyIdle" if player.has_jumped: - if player.velocity.y < 0: + if player.bumping and player.can_bump_jump: + return "JumpBump" + elif player.velocity.y < 0: if player.is_invincible: return "StarJump" return "Jump"