1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Bullets/Cogwheel.gd
T
fallingshrimp a72c0032d5 feat(武器): 添加齿轮回旋镖武器及其子弹效果
添加新的武器"齿轮回旋镖"及其配套子弹资源:
1. 实现齿轮武器的基本逻辑,包括攻击和属性计算
2. 添加齿轮子弹的旋转、减速和回旋行为
3. 包含相关资源文件(图片、场景、脚本)
4. 将新武器添加到公鸡角色的武器库中
2026-02-15 19:36:46 +08:00

33 lines
980 B
GDScript

extends BulletBase
class_name CogwheelBullet
var initialRotate: float = 0
var rotateSpeed: float = 0
var dotTime: float = 0
var slow: float = 0.2
func ai():
PresetBulletAI.forward(self, rotation)
texture.rotation_degrees += rotateSpeed
if rotateSpeed < 0:
speed += slow
PresetBulletAI.trace(self, launcher.position, 0.1)
if position.distance_to(launcher.position) < 100:
tryDestroy()
else:
speed = initialSpeed * (rotateSpeed / initialRotate)
dotTime = 1000 / (rotateSpeed)
rotateSpeed -= slow
func applyDot():
hitbox.disabled = true
await TickTool.frame()
hitbox.disabled = false
await TickTool.millseconds(dotTime / launcher.fields[FieldStore.Entity.ATTACK_SPEED])
await TickTool.frame() # 等至少一帧,防止跳帧导致没检测到伤害
return true
func refract(newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float):
if newBullet is CogwheelBullet:
newBullet.rotateSpeed = initialRotate
return newBullet