From 87c392d8a45e86c2270c679ac41340433533d278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sat, 25 Apr 2026 13:28:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=88=98=E6=96=97=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=AD=90=E5=BC=B9=E8=BF=BD=E8=B8=AA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=AE=9E=E4=BD=93=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=84=A6=E7=82=B9=E4=BD=8D=E7=BD=AE=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改所有子弹追踪逻辑,统一使用launcher.currentFocusedPosition作为目标位置 在EntityBase中新增currentFocusedPosition字段,用于存储当前焦点位置 调整MTY角色的攻击距离参数,使用常量定义最小招架和攻击距离 --- scripts/Contents/Bullets/AcidStorm.gd | 2 +- scripts/Contents/Bullets/Arrow.gd | 6 +++--- scripts/Contents/Bullets/BigLaser.gd | 2 +- scripts/Contents/Bullets/Bow.gd | 4 ++-- scripts/Contents/Bullets/MagicMissle.gd | 4 ++-- scripts/Contents/Bullets/Volcano.gd | 4 ++-- scripts/Contents/Bullets/Wuwei.gd | 2 +- scripts/Contents/Characters/MTY.gd | 16 ++++++++++++---- scripts/Contents/Characters/Rooster.gd | 1 + scripts/Contents/Wave.gd | 2 +- scripts/Statemachine/EntityBase.gd | 3 +++ 11 files changed, 29 insertions(+), 17 deletions(-) diff --git a/scripts/Contents/Bullets/AcidStorm.gd b/scripts/Contents/Bullets/AcidStorm.gd index b4efce1..579b638 100644 --- a/scripts/Contents/Bullets/AcidStorm.gd +++ b/scripts/Contents/Bullets/AcidStorm.gd @@ -38,7 +38,7 @@ func applyDot(): bullet.arg2 = clAtkSpeed if bullet is AcidP: bullet.arg1 = pOffset - bullet.arg2 = EntityTool.findClosetEntity(get_global_mouse_position(), get_tree(), !launcher.isPlayer(), launcher.isPlayer()) + bullet.arg2 = EntityTool.findClosetEntity(launcher.currentFocusedPosition, get_tree(), !launcher.isPlayer(), launcher.isPlayer()) if bullet is AcidC: bullet.arg1 = cAtk await TickTool.millseconds(1000.0 / f) diff --git a/scripts/Contents/Bullets/Arrow.gd b/scripts/Contents/Bullets/Arrow.gd index 61c81e8..7a3bb9e 100644 --- a/scripts/Contents/Bullets/Arrow.gd +++ b/scripts/Contents/Bullets/Arrow.gd @@ -12,15 +12,15 @@ func register(): hitbox.disabled = true func ai(): if timeLived() < waitTime: - PresetBulletAI.lockLauncher(self, launcher, true) - rotation = position.angle_to_point(get_global_mouse_position()) + offsetRotation + PresetBulletAI.lockLauncher(self , launcher, true) + rotation = position.angle_to_point(launcher.currentFocusedPosition) + offsetRotation return else: trail.emitting = true hitbox.disabled = false speed = (1 - lifeTimePercent()) * initialSpeed baseDamage = speed * atk - PresetBulletAI.forward(self, rotation) + PresetBulletAI.forward(self , rotation) if speed < 1: tryDestroy() func succeedToHit(_dmg: float, _entity: EntityBase): diff --git a/scripts/Contents/Bullets/BigLaser.gd b/scripts/Contents/Bullets/BigLaser.gd index db01f26..259fe1d 100644 --- a/scripts/Contents/Bullets/BigLaser.gd +++ b/scripts/Contents/Bullets/BigLaser.gd @@ -8,7 +8,7 @@ func spawn(): CameraManager.playAnimation("bigLaser") baseDamage *= launcher.fields[FieldStore.Entity.ATTACK_SPEED] func ai(): - rotation = lerp_angle(rotation, ((get_global_mouse_position() - position).angle()), 0.1) + rotation = lerp_angle(rotation, ((launcher.currentFocusedPosition - position).angle()), 0.1) position = launcher.texture.global_position func applyDot(): hitbox.disabled = true diff --git a/scripts/Contents/Bullets/Bow.gd b/scripts/Contents/Bullets/Bow.gd index a733b95..2c6d016 100644 --- a/scripts/Contents/Bullets/Bow.gd +++ b/scripts/Contents/Bullets/Bow.gd @@ -21,5 +21,5 @@ func spawn(): await TickTool.millseconds(waitTime) tryDestroy() func ai(): - PresetBulletAI.lockLauncher(self, launcher, true) - rotation = position.angle_to_point(get_global_mouse_position()) + PresetBulletAI.lockLauncher(self , launcher, true) + rotation = position.angle_to_point(launcher.currentFocusedPosition) diff --git a/scripts/Contents/Bullets/MagicMissle.gd b/scripts/Contents/Bullets/MagicMissle.gd index af2e658..25a6260 100644 --- a/scripts/Contents/Bullets/MagicMissle.gd +++ b/scripts/Contents/Bullets/MagicMissle.gd @@ -10,8 +10,8 @@ func ai(): if accelerating: if roundBullets.count(self ) < 1: accelerating = false - rotation = lerp_angle(rotation, position.angle_to_point(get_global_mouse_position()), 0.1) - speedV2 += (get_global_mouse_position() - position).normalized() * 1 + rotation = lerp_angle(rotation, position.angle_to_point(launcher.currentFocusedPosition), 0.1) + speedV2 += (launcher.currentFocusedPosition - position).normalized() * 1 elif speed < 1 || baseDamage < 1: tryDestroy() speedV2 *= 0.995 diff --git a/scripts/Contents/Bullets/Volcano.gd b/scripts/Contents/Bullets/Volcano.gd index 7eb1ad3..e757f92 100644 --- a/scripts/Contents/Bullets/Volcano.gd +++ b/scripts/Contents/Bullets/Volcano.gd @@ -10,10 +10,10 @@ var dmg5: float = 0 var splitAngle: float = 10 func ai(): - PresetBulletAI.lockLauncher(self, launcher, true) + PresetBulletAI.lockLauncher(self , launcher, true) rotation = lerp_angle( rotation, - position.angle_to_point(get_global_mouse_position()), + position.angle_to_point(launcher.currentFocusedPosition), rotates ) func succeedToHit(_dmg: float, _entity: EntityBase): diff --git a/scripts/Contents/Bullets/Wuwei.gd b/scripts/Contents/Bullets/Wuwei.gd index 765010d..f8949a5 100644 --- a/scripts/Contents/Bullets/Wuwei.gd +++ b/scripts/Contents/Bullets/Wuwei.gd @@ -6,7 +6,7 @@ class_name WuweiBullet func ai(): if canMove: PresetBulletAI.lockLauncher(self , launcher, true) - PresetBulletAI.trace(self , get_global_mouse_position(), 0.1) + PresetBulletAI.trace(self , launcher.currentFocusedPosition, 0.1) func shoot(): for bullet in BulletBase.generate( diff --git a/scripts/Contents/Characters/MTY.gd b/scripts/Contents/Characters/MTY.gd index 9e48857..6f422fc 100644 --- a/scripts/Contents/Characters/MTY.gd +++ b/scripts/Contents/Characters/MTY.gd @@ -1,6 +1,9 @@ extends EntityBase class_name MTY +var MIN_PARRY_DISTANCE = 300 +var MIN_ATTACK_DISTANCE = 400 + func register(): fields[FieldStore.Entity.MAX_HEALTH] = 400 fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.9 @@ -13,24 +16,29 @@ func spawn(): func ai(): PresetEntityAI.follow(self , currentFocusedBoss) for i in 3: - tryAttack(i) + if i == 1: + var track = getTrackingAnchor() + if is_instance_valid(BulletTool.findClosetBulletCanDamage(track, get_tree(), self , MIN_PARRY_DISTANCE)): + tryAttack(1) + else: + tryAttack(i) func attack(type: int): if type == 0: trySprint() elif type == 1: var track = getTrackingAnchor() - var bullet = BulletTool.findClosetBulletCanDamage(track, get_tree(), self , 450) + var bullet = BulletTool.findClosetBulletCanDamage(track, get_tree(), self , MIN_PARRY_DISTANCE) if is_instance_valid(bullet): BulletBase.generate(ComponentManager.getBullet("Parrier"), self , track, track.angle_to_point(bullet.position)) elif type == 2: if is_instance_valid(currentFocusedBoss): var track = getTrackingAnchor() - if currentFocusedBoss.position.distance_to(track) <= 400: + if currentFocusedBoss.position.distance_to(track) <= MIN_ATTACK_DISTANCE: BulletBase.generate(ComponentManager.getBullet("Parrier"), self , track, track.angle_to_point(currentFocusedBoss.position)) return true func sprint(): var track = getTrackingAnchor() - var target = BulletTool.findClosetBulletCanDamage(track, get_tree(), self , 300) + var target = BulletTool.findClosetBulletCanDamage(track, get_tree(), self , MIN_PARRY_DISTANCE) if is_instance_valid(target): var dir = (target.position - track).rotated(MathTool.randomChoiceFrom([-1, 1]) * deg_to_rad(90)) move(dir.normalized() * sprintMultiplier, true) diff --git a/scripts/Contents/Characters/Rooster.gd b/scripts/Contents/Characters/Rooster.gd index 5c2e0e9..0289754 100644 --- a/scripts/Contents/Characters/Rooster.gd +++ b/scripts/Contents/Characters/Rooster.gd @@ -17,6 +17,7 @@ func register(): chargeParticle.emitting = false func ai(): + currentFocusedPosition = get_global_mouse_position() texture.play("walk") var direction = Vector2( Input.get_axis("m_left", "m_right"), diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index cc4b5ae..08dd15b 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -51,7 +51,7 @@ static var WAVE_MOWING = [ Wave.create("MTY", 1, 5, false, 0, INF, 1), ] static var WAVE_TESTMOB = [ - Wave.create("MTY", 1, 10, false, 0, INF, 1) + Wave.create("MTY", 1, 1, false, 0, INF, 1) ] static var WAVE_EMPTY = [] static var waveReleaseConfig = [WAVE_TESTBOSS, 1] diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 9320b14..56aeb10 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -108,6 +108,7 @@ var trailing: bool = false var lastDirection: int = 1 var currentFocusedBoss: EntityBase = null +var currentFocusedPosition: Vector2 = Vector2.ZERO var charginup: bool = false var weapons: Array[Weapon] = [] var weaponBag: Array[String] = [] @@ -187,6 +188,8 @@ func _physics_process(_delta: float) -> void: if !isPlayer() && !currentFocusedBoss: currentFocusedBoss = MathTool.randomChoiceFrom(get_tree().get_nodes_in_group("players")) animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.2)) + if is_instance_valid(currentFocusedBoss): + currentFocusedPosition = currentFocusedBoss.position if sprinting: if sprintAi(): sprinting = false