add kick system

This commit is contained in:
2026-04-22 17:44:54 +03:00
parent 0a637a6160
commit 8a6ecf3f45
4 changed files with 80 additions and 13 deletions
+22 -4
View File
@@ -18,6 +18,7 @@ var chain_factor: float = 0.65
var stun_time: float = 0.5
var base_scale: float = 1.0
var wave_num: int = 1
var damage_modifier: float = 0.75
var state: State = State.CHASING
var fly_vel: Vector3 = Vector3.ZERO
@@ -140,14 +141,18 @@ func _fly(delta: float) -> void:
hit_wall = true
break
elif col3d.is_in_group("enemies") and col3d != self:
var other: Node = col3d
if speed_now >= 3.0 and other.get("enemy_level") == enemy_level and other.get("is_upgrading") == false and is_upgrading == false:
_start_merge(other)
else:
var merged := KickSystem.resolve(self, col3d, fly_vel)
if not merged and is_instance_valid(col3d):
var chain_dir := col3d.global_position - global_position
chain_dir.y = 0.0
if chain_dir.length() > 0.01:
col3d.call("receive_kick", chain_dir.normalized(), speed_now * chain_factor)
elif col3d.is_in_group("rocks"):
KickSystem.resolve(self, col3d, fly_vel)
var rock_dir := col3d.global_position - global_position
rock_dir.y = 0.0
if rock_dir.length() > 0.01:
col3d.call("receive_kick", rock_dir.normalized(), speed_now * 0.5)
elif col3d.is_in_group("player"):
col3d.call("take_damage", int(speed_now * 0.6))
@@ -166,6 +171,19 @@ func _stun_tick(delta: float) -> void:
if stun_timer <= 0.0:
_enter_chase()
func can_merge_with(other: Node3D, collision_speed: float) -> bool:
return (collision_speed >= 3.0
and other.get("enemy_type") == enemy_type
and other.get("enemy_level") == enemy_level
and not is_upgrading
and not other.get("is_upgrading"))
func do_merge_with(other: Node3D) -> void:
_start_merge(other)
func apply_collision_damage(dmg: float) -> void:
_take_hit(int(dmg))
func receive_kick(direction: Vector3, force: float) -> void:
if state == State.DEAD:
return