Files
Super-Mario-Bros.-Remastere…/Scripts/Classes/Entities/Enemy.gd
T
SkyanUltra a76cade9d5 Castle Bridge touch-ups (#765)
- Bridges now play a unique "BridgeBreak" sound effect listed as "bridge_break" which mimics the functionality of the original game playing the brick break and bumping sounds simultaneously.
- Axes now have an optional "Cut" animation that plays if it exists upon picking it up rather than outright making the axe disappear.
- Bridges no longer check for EVERY bridge piece when running timer code, instead only caring about the bridge segments that are visible and tangible.
- Timers associated with bridges have been sped up and adjusted to better match the original game.
- Multiple axes being picked up should no longer cause errors when bowser is on screen.
- Bowser now ignores being caught by the "flag death" function if he is defeated by picking up an axe.
- Bowser no longer attempts to shoot fire or throw hammers if he is defeated by picking up an axe.
2025-12-06 14:14:27 +00:00

51 lines
1.4 KiB
GDScript

@icon("res://Assets/Sprites/Editor/Enemy.svg")
class_name Enemy
extends CharacterBody2D
signal killed(direction: int)
@export var on_screen_enabler: VisibleOnScreenNotifier2D = null
@export var score_note_adder: ScoreNoteSpawner = null
var direction := -1
var ignore_flag_die := false
func damage_player(player: Player) -> void:
player.damage()
func apply_enemy_gravity(delta: float) -> void:
velocity.y += (Global.entity_gravity / delta) * delta
velocity.y = clamp(velocity.y, -INF, Global.entity_max_fall_speed)
func die() -> void:
killed.emit([-1, 1].pick_random())
DiscoLevel.combo_amount += 1
DiscoLevel.combo_meter = 100
queue_free()
func die_from_object(obj: Node2D) -> void:
var dir = sign(global_position.x - obj.global_position.x)
if dir == 0:
dir = [-1, 1].pick_random()
DiscoLevel.combo_amount += 1
killed.emit(dir)
queue_free()
func flag_die() -> void:
if on_screen_enabler != null and ignore_flag_die == false:
if on_screen_enabler.is_on_screen():
queue_free()
if score_note_adder != null:
if score_note_adder.add_score == false:
Global.score += 500
score_note_adder.spawn_note(500)
func die_from_hammer(obj: Node2D) -> void:
var dir = sign(global_position.x - obj.global_position.x)
if dir == 0:
dir = [-1, 1].pick_random()
DiscoLevel.combo_amount += 1
AudioManager.play_sfx("hammer_hit", global_position)
killed.emit(dir)
queue_free()