mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
b58667d2d7
将小鸡AI的攻击距离阈值从300调整为200,以优化战斗行为
48 lines
1.7 KiB
GDScript
48 lines
1.7 KiB
GDScript
extends EntityBase
|
|
class_name Chick
|
|
|
|
@onready var firepot = $"%firepot"
|
|
|
|
const laserCount = 4
|
|
|
|
func register():
|
|
fields[FieldStore.Entity.MAX_HEALTH] = 2000
|
|
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.35
|
|
attackCooldownMap[0] = 500
|
|
attackCooldownMap[1] = 6000
|
|
attackCooldownMap[2] = 100
|
|
attackCooldownMap[3] = 500
|
|
sprintMultiplier = 60
|
|
func spawn():
|
|
texture.play("walk")
|
|
|
|
func ai():
|
|
move(currentFocusedBoss.position - position)
|
|
if currentFocusedBoss.position.distance_to(position) < 200:
|
|
tryAttack(2)
|
|
elif currentFocusedBoss.position.distance_to(position) < 700:
|
|
tryAttack(1)
|
|
else:
|
|
var method = MathTool.randc_from([0, 3, 0]) # 0: 钻石, 1: 激光, 2: 喷火, 3: 冲刺,这里随机到钻石的概率比冲刺大一倍
|
|
tryAttack(method, method == 3)
|
|
func attack(type):
|
|
if type == 0:
|
|
var weaponPos = findWeaponAnchor("normal")
|
|
for i in randi_range(10, 20):
|
|
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90)))
|
|
elif type == 1:
|
|
for i in range(laserCount):
|
|
BulletBase.generate(preload("res://components/Bullets/ChickLaser.tscn"), self, texture.global_position, deg_to_rad(90 * i))
|
|
elif type == 2:
|
|
var weaponPos = findWeaponAnchor("normal")
|
|
var target = weaponPos.angle_to_point(currentFocusedBoss.position)
|
|
firepot.global_rotation = target
|
|
firepot.shot()
|
|
BulletBase.generate(preload("res://components/Bullets/FireScan.tscn"), self, weaponPos, target)
|
|
elif type == 3:
|
|
BulletBase.generate(preload("res://components/Bullets/ChickSprint.tscn"), self, position, 0)
|
|
trySprint()
|
|
return true
|
|
func sprint():
|
|
move((currentFocusedBoss.position - position).normalized() * sprintMultiplier, true)
|