mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-07-02 16:22:14 +08:00
feat(战斗系统): 重构子弹追踪逻辑,使用实体当前焦点位置替代鼠标位置
修改所有子弹追踪逻辑,统一使用launcher.currentFocusedPosition作为目标位置 在EntityBase中新增currentFocusedPosition字段,用于存储当前焦点位置 调整MTY角色的攻击距离参数,使用常量定义最小招架和攻击距离
This commit is contained in:
@@ -38,7 +38,7 @@ func applyDot():
|
|||||||
bullet.arg2 = clAtkSpeed
|
bullet.arg2 = clAtkSpeed
|
||||||
if bullet is AcidP:
|
if bullet is AcidP:
|
||||||
bullet.arg1 = pOffset
|
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:
|
if bullet is AcidC:
|
||||||
bullet.arg1 = cAtk
|
bullet.arg1 = cAtk
|
||||||
await TickTool.millseconds(1000.0 / f)
|
await TickTool.millseconds(1000.0 / f)
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ func register():
|
|||||||
hitbox.disabled = true
|
hitbox.disabled = true
|
||||||
func ai():
|
func ai():
|
||||||
if timeLived() < waitTime:
|
if timeLived() < waitTime:
|
||||||
PresetBulletAI.lockLauncher(self, launcher, true)
|
PresetBulletAI.lockLauncher(self , launcher, true)
|
||||||
rotation = position.angle_to_point(get_global_mouse_position()) + offsetRotation
|
rotation = position.angle_to_point(launcher.currentFocusedPosition) + offsetRotation
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
trail.emitting = true
|
trail.emitting = true
|
||||||
hitbox.disabled = false
|
hitbox.disabled = false
|
||||||
speed = (1 - lifeTimePercent()) * initialSpeed
|
speed = (1 - lifeTimePercent()) * initialSpeed
|
||||||
baseDamage = speed * atk
|
baseDamage = speed * atk
|
||||||
PresetBulletAI.forward(self, rotation)
|
PresetBulletAI.forward(self , rotation)
|
||||||
if speed < 1:
|
if speed < 1:
|
||||||
tryDestroy()
|
tryDestroy()
|
||||||
func succeedToHit(_dmg: float, _entity: EntityBase):
|
func succeedToHit(_dmg: float, _entity: EntityBase):
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ func spawn():
|
|||||||
CameraManager.playAnimation("bigLaser")
|
CameraManager.playAnimation("bigLaser")
|
||||||
baseDamage *= launcher.fields[FieldStore.Entity.ATTACK_SPEED]
|
baseDamage *= launcher.fields[FieldStore.Entity.ATTACK_SPEED]
|
||||||
func ai():
|
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
|
position = launcher.texture.global_position
|
||||||
func applyDot():
|
func applyDot():
|
||||||
hitbox.disabled = true
|
hitbox.disabled = true
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ func spawn():
|
|||||||
await TickTool.millseconds(waitTime)
|
await TickTool.millseconds(waitTime)
|
||||||
tryDestroy()
|
tryDestroy()
|
||||||
func ai():
|
func ai():
|
||||||
PresetBulletAI.lockLauncher(self, launcher, true)
|
PresetBulletAI.lockLauncher(self , launcher, true)
|
||||||
rotation = position.angle_to_point(get_global_mouse_position())
|
rotation = position.angle_to_point(launcher.currentFocusedPosition)
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func ai():
|
|||||||
if accelerating:
|
if accelerating:
|
||||||
if roundBullets.count(self ) < 1:
|
if roundBullets.count(self ) < 1:
|
||||||
accelerating = false
|
accelerating = false
|
||||||
rotation = lerp_angle(rotation, position.angle_to_point(get_global_mouse_position()), 0.1)
|
rotation = lerp_angle(rotation, position.angle_to_point(launcher.currentFocusedPosition), 0.1)
|
||||||
speedV2 += (get_global_mouse_position() - position).normalized() * 1
|
speedV2 += (launcher.currentFocusedPosition - position).normalized() * 1
|
||||||
elif speed < 1 || baseDamage < 1:
|
elif speed < 1 || baseDamage < 1:
|
||||||
tryDestroy()
|
tryDestroy()
|
||||||
speedV2 *= 0.995
|
speedV2 *= 0.995
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ var dmg5: float = 0
|
|||||||
var splitAngle: float = 10
|
var splitAngle: float = 10
|
||||||
|
|
||||||
func ai():
|
func ai():
|
||||||
PresetBulletAI.lockLauncher(self, launcher, true)
|
PresetBulletAI.lockLauncher(self , launcher, true)
|
||||||
rotation = lerp_angle(
|
rotation = lerp_angle(
|
||||||
rotation,
|
rotation,
|
||||||
position.angle_to_point(get_global_mouse_position()),
|
position.angle_to_point(launcher.currentFocusedPosition),
|
||||||
rotates
|
rotates
|
||||||
)
|
)
|
||||||
func succeedToHit(_dmg: float, _entity: EntityBase):
|
func succeedToHit(_dmg: float, _entity: EntityBase):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class_name WuweiBullet
|
|||||||
func ai():
|
func ai():
|
||||||
if canMove:
|
if canMove:
|
||||||
PresetBulletAI.lockLauncher(self , launcher, true)
|
PresetBulletAI.lockLauncher(self , launcher, true)
|
||||||
PresetBulletAI.trace(self , get_global_mouse_position(), 0.1)
|
PresetBulletAI.trace(self , launcher.currentFocusedPosition, 0.1)
|
||||||
|
|
||||||
func shoot():
|
func shoot():
|
||||||
for bullet in BulletBase.generate(
|
for bullet in BulletBase.generate(
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
extends EntityBase
|
extends EntityBase
|
||||||
class_name MTY
|
class_name MTY
|
||||||
|
|
||||||
|
var MIN_PARRY_DISTANCE = 300
|
||||||
|
var MIN_ATTACK_DISTANCE = 400
|
||||||
|
|
||||||
func register():
|
func register():
|
||||||
fields[FieldStore.Entity.MAX_HEALTH] = 400
|
fields[FieldStore.Entity.MAX_HEALTH] = 400
|
||||||
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.9
|
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.9
|
||||||
@@ -13,24 +16,29 @@ func spawn():
|
|||||||
func ai():
|
func ai():
|
||||||
PresetEntityAI.follow(self , currentFocusedBoss)
|
PresetEntityAI.follow(self , currentFocusedBoss)
|
||||||
for i in 3:
|
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):
|
func attack(type: int):
|
||||||
if type == 0:
|
if type == 0:
|
||||||
trySprint()
|
trySprint()
|
||||||
elif type == 1:
|
elif type == 1:
|
||||||
var track = getTrackingAnchor()
|
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):
|
if is_instance_valid(bullet):
|
||||||
BulletBase.generate(ComponentManager.getBullet("Parrier"), self , track, track.angle_to_point(bullet.position))
|
BulletBase.generate(ComponentManager.getBullet("Parrier"), self , track, track.angle_to_point(bullet.position))
|
||||||
elif type == 2:
|
elif type == 2:
|
||||||
if is_instance_valid(currentFocusedBoss):
|
if is_instance_valid(currentFocusedBoss):
|
||||||
var track = getTrackingAnchor()
|
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))
|
BulletBase.generate(ComponentManager.getBullet("Parrier"), self , track, track.angle_to_point(currentFocusedBoss.position))
|
||||||
return true
|
return true
|
||||||
func sprint():
|
func sprint():
|
||||||
var track = getTrackingAnchor()
|
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):
|
if is_instance_valid(target):
|
||||||
var dir = (target.position - track).rotated(MathTool.randomChoiceFrom([-1, 1]) * deg_to_rad(90))
|
var dir = (target.position - track).rotated(MathTool.randomChoiceFrom([-1, 1]) * deg_to_rad(90))
|
||||||
move(dir.normalized() * sprintMultiplier, true)
|
move(dir.normalized() * sprintMultiplier, true)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ func register():
|
|||||||
chargeParticle.emitting = false
|
chargeParticle.emitting = false
|
||||||
|
|
||||||
func ai():
|
func ai():
|
||||||
|
currentFocusedPosition = get_global_mouse_position()
|
||||||
texture.play("walk")
|
texture.play("walk")
|
||||||
var direction = Vector2(
|
var direction = Vector2(
|
||||||
Input.get_axis("m_left", "m_right"),
|
Input.get_axis("m_left", "m_right"),
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ static var WAVE_MOWING = [
|
|||||||
Wave.create("MTY", 1, 5, false, 0, INF, 1),
|
Wave.create("MTY", 1, 5, false, 0, INF, 1),
|
||||||
]
|
]
|
||||||
static var WAVE_TESTMOB = [
|
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 WAVE_EMPTY = []
|
||||||
static var waveReleaseConfig = [WAVE_TESTBOSS, 1]
|
static var waveReleaseConfig = [WAVE_TESTBOSS, 1]
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ var trailing: bool = false
|
|||||||
|
|
||||||
var lastDirection: int = 1
|
var lastDirection: int = 1
|
||||||
var currentFocusedBoss: EntityBase = null
|
var currentFocusedBoss: EntityBase = null
|
||||||
|
var currentFocusedPosition: Vector2 = Vector2.ZERO
|
||||||
var charginup: bool = false
|
var charginup: bool = false
|
||||||
var weapons: Array[Weapon] = []
|
var weapons: Array[Weapon] = []
|
||||||
var weaponBag: Array[String] = []
|
var weaponBag: Array[String] = []
|
||||||
@@ -187,6 +188,8 @@ func _physics_process(_delta: float) -> void:
|
|||||||
if !isPlayer() && !currentFocusedBoss:
|
if !isPlayer() && !currentFocusedBoss:
|
||||||
currentFocusedBoss = MathTool.randomChoiceFrom(get_tree().get_nodes_in_group("players"))
|
currentFocusedBoss = MathTool.randomChoiceFrom(get_tree().get_nodes_in_group("players"))
|
||||||
animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.2))
|
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 sprinting:
|
||||||
if sprintAi():
|
if sprintAi():
|
||||||
sprinting = false
|
sprinting = false
|
||||||
|
|||||||
Reference in New Issue
Block a user