1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00
Files

28 lines
710 B
GDScript
Raw Permalink Normal View History

extends SummonBase
class_name GoboSummon
var percent: float = 0.0
var healthSinceLastLaunch: float = 0
var targetDamage: float = 0.0
var count: int = 0
func initHealth(maxHealth: float):
super.initHealth(maxHealth)
healthSinceLastLaunch = maxHealth
func register():
fields[FieldStore.Entity.MOVEMENT_SPEED] = 1.5
healthChanged.connect(
func(newHealth):
if healthSinceLastLaunch - newHealth >= targetDamage:
launch()
healthSinceLastLaunch = newHealth
)
func ai():
var target = BulletTool.findClosetBulletCanDamage(position, get_tree(), self)
if is_instance_valid(target):
move(target.position - position)
func launch():
ItemDropped.generate(ItemStore.ItemType.APPLE, count, position)