2025-08-26 13:56:12 +08:00
|
|
|
extends EntityBase
|
|
|
|
|
class_name Chick
|
|
|
|
|
|
2025-11-16 16:31:50 +08:00
|
|
|
var played: bool = false
|
|
|
|
|
|
2025-08-29 10:50:22 +08:00
|
|
|
func register():
|
2025-11-30 16:25:56 +08:00
|
|
|
fields[FieldStore.Entity.MAX_HEALTH] = 2500
|
2025-09-14 16:22:01 +08:00
|
|
|
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.4
|
2025-09-26 22:12:48 +08:00
|
|
|
attackCooldownMap[0] = 400
|
2026-01-24 08:34:03 +08:00
|
|
|
attackCooldownMap[1] = 10000
|
|
|
|
|
attackCooldownMap[2] = 3000
|
|
|
|
|
attackCooldownMap[3] = 2000
|
|
|
|
|
attackCooldownMap[4] = 2500
|
2025-09-20 07:18:23 +08:00
|
|
|
sprintMultiplier = 50
|
2025-11-16 16:31:50 +08:00
|
|
|
healthChanged.connect(
|
|
|
|
|
func(h):
|
|
|
|
|
if !played and h <= fields.get(FieldStore.Entity.MAX_HEALTH) * 0.1:
|
|
|
|
|
played = true
|
|
|
|
|
playSound("readyToDie")
|
|
|
|
|
)
|
2025-08-29 12:51:43 +08:00
|
|
|
func spawn():
|
|
|
|
|
texture.play("walk")
|
2025-08-26 14:47:12 +08:00
|
|
|
|
|
|
|
|
func ai():
|
2025-11-16 16:01:03 +08:00
|
|
|
tryAttack(4)
|
2025-09-06 18:33:11 +08:00
|
|
|
PresetEntityAI.follow(self, currentFocusedBoss, 0)
|
2025-11-16 16:01:03 +08:00
|
|
|
PresetEntityAI.distanceAttack(self, currentFocusedBoss, 0, 500, 2)
|
|
|
|
|
PresetEntityAI.distanceAttack(self, currentFocusedBoss, 500, 1000, 1)
|
|
|
|
|
PresetEntityAI.distanceAction(self, currentFocusedBoss, 1000, INF,
|
2025-09-06 18:45:05 +08:00
|
|
|
func():
|
|
|
|
|
PresetEntityAI.weightAttack(self, [0, 3], [5, 1], func(index): return index == 3)
|
|
|
|
|
)
|
2025-08-26 14:47:12 +08:00
|
|
|
func attack(type):
|
|
|
|
|
if type == 0:
|
|
|
|
|
var weaponPos = findWeaponAnchor("normal")
|
2025-09-26 22:12:48 +08:00
|
|
|
for i in randi_range(7, 16):
|
2026-01-18 15:31:52 +08:00
|
|
|
BulletBase.generate(ComponentManager.getBullet("Diamond"), self, weaponPos + MathTool.sampleInCircle(20), rotation + deg_to_rad(randf_range(-90, 90)))
|
2025-08-26 17:28:20 +08:00
|
|
|
elif type == 1:
|
2026-01-24 08:34:03 +08:00
|
|
|
var laserCount = randi_range(3, 4)
|
2025-09-20 07:18:23 +08:00
|
|
|
for i in laserCount:
|
2025-09-21 13:11:31 +08:00
|
|
|
BulletBase.generate(ComponentManager.getBullet("ChickLaser"), self, texture.global_position, deg_to_rad(360.0 / laserCount * i))
|
2025-08-27 08:58:14 +08:00
|
|
|
elif type == 2:
|
2025-08-26 17:28:20 +08:00
|
|
|
var weaponPos = findWeaponAnchor("normal")
|
2025-11-22 08:25:26 +08:00
|
|
|
BulletBase.generate(ComponentManager.getBullet("FireScan"), self, weaponPos, weaponPos.angle_to_point(currentFocusedBoss.getTrackingAnchor()))
|
2025-08-29 13:56:31 +08:00
|
|
|
elif type == 3:
|
2025-09-21 13:11:31 +08:00
|
|
|
BulletBase.generate(ComponentManager.getBullet("ChickSprint"), self, position, 0)
|
2025-08-29 14:29:07 +08:00
|
|
|
trySprint()
|
2025-11-16 16:01:03 +08:00
|
|
|
elif type == 4:
|
|
|
|
|
BulletBase.generate(ComponentManager.getBullet("FoxZhua"), self, findWeaponAnchor("foot"), deg_to_rad(90))
|
2025-08-27 15:38:30 +08:00
|
|
|
return true
|
2025-08-29 13:56:31 +08:00
|
|
|
func sprint():
|
|
|
|
|
move((currentFocusedBoss.position - position).normalized() * sprintMultiplier, true)
|