2025-12-07 17:04:47 +08:00
|
|
|
extends EntityBase
|
|
|
|
|
class_name MTY
|
|
|
|
|
|
|
|
|
|
func register():
|
|
|
|
|
fields[FieldStore.Entity.MAX_HEALTH] = 400
|
|
|
|
|
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.9
|
2026-01-18 14:49:06 +08:00
|
|
|
attackCooldownMap[0] = 1000
|
|
|
|
|
attackCooldownMap[1] = 250
|
2025-12-07 17:04:47 +08:00
|
|
|
sprintMultiplier = 5
|
2026-01-18 14:49:06 +08:00
|
|
|
func spawn():
|
|
|
|
|
texture.play("walk")
|
2025-12-07 17:04:47 +08:00
|
|
|
func ai():
|
|
|
|
|
PresetEntityAI.follow(self, currentFocusedBoss)
|
|
|
|
|
tryAttack(0)
|
2025-12-14 15:29:44 +08:00
|
|
|
tryAttack(1)
|
2025-12-07 17:04:47 +08:00
|
|
|
func attack(type: int):
|
|
|
|
|
if type == 0:
|
|
|
|
|
trySprint()
|
2025-12-14 15:29:44 +08:00
|
|
|
elif type == 1:
|
|
|
|
|
BulletBase.generate(ComponentManager.getBullet("MTYSprint"), self, position, 0)
|
2025-12-07 17:04:47 +08:00
|
|
|
return true
|
|
|
|
|
func sprint():
|
|
|
|
|
var target = BulletTool.findClosetBulletCanDamage(position, get_tree(), self)
|
|
|
|
|
if is_instance_valid(target):
|
2025-12-14 15:06:22 +08:00
|
|
|
var dir = (target.position - position).rotated(MathTool.randomChoiceFrom([-1, 1]) * deg_to_rad(90))
|
2025-12-07 17:04:47 +08:00
|
|
|
move(dir.normalized() * sprintMultiplier, true)
|