Made more enemies, easier to kill, more slashy. You get passive health regen, health orbs. Little key bindings tooltip.
This commit is contained in:
@@ -13,6 +13,7 @@ class_name BasicEnemy
|
||||
@export var attack_damage: float = 15.0
|
||||
@export var attack_knockback: float = 10.0
|
||||
@export var attack_cooldown: float = 1.5
|
||||
@export var health_orb_drop_chance: float = 0.4 ## Chance (0-1) to drop a health orb on death
|
||||
@export_category("Attack Timing")
|
||||
@export var attack_startup: float = 0.3 # Wind-up before hit
|
||||
@export var attack_active: float = 0.4 # Hit window duration
|
||||
@@ -36,6 +37,9 @@ func _enter_tree():
|
||||
func _ready():
|
||||
super._ready()
|
||||
|
||||
# Wave lobsters die for good — no reviving (BaseEnemy defaults this to true)
|
||||
can_respawn = false
|
||||
|
||||
# Find mesh, hitbox, and hurtbox
|
||||
_mesh = get_node_or_null("Mesh")
|
||||
_hitbox = get_node_or_null("HitBox")
|
||||
@@ -255,6 +259,34 @@ func _reset_material():
|
||||
if _mesh and _original_material:
|
||||
_mesh.set_surface_override_material(0, _original_material.duplicate())
|
||||
|
||||
## Handle death: drop loot, then despawn (server-authoritative, fires once per death)
|
||||
func _die(killer_id: int):
|
||||
var already_dead = is_dead
|
||||
super._die(killer_id)
|
||||
|
||||
if not multiplayer.is_server() or already_dead:
|
||||
return
|
||||
|
||||
# Chance to drop a health orb
|
||||
if randf() < health_orb_drop_chance:
|
||||
var level = get_tree().get_current_scene()
|
||||
if level and level.has_method("spawn_health_orb"):
|
||||
level.spawn_health_orb(global_position + Vector3.UP)
|
||||
|
||||
# Non-reviving enemies remove their corpse on every client after a short beat
|
||||
if not can_respawn:
|
||||
_schedule_despawn()
|
||||
|
||||
## Free this enemy on all peers a couple seconds after death
|
||||
func _schedule_despawn():
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
if is_instance_valid(self):
|
||||
rpc("_despawn")
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func _despawn():
|
||||
queue_free()
|
||||
|
||||
## Death callback
|
||||
func _on_enemy_died(killer_id: int):
|
||||
super._on_enemy_died(killer_id)
|
||||
|
||||
Reference in New Issue
Block a user