mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(武器): 添加鸡毛弓武器及相关箭矢功能
实现鸡毛弓武器系统,包括武器脚本、箭矢脚本和场景配置 修改实体伤害处理逻辑,分离普通伤害和子弹伤害方法 更新公鸡角色配置,添加鸡毛弓作为默认武器
This commit is contained in:
@@ -1,13 +1,18 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://wy8wqwhwr4fb"]
|
[gd_scene load_steps=5 format=3 uid="uid://wy8wqwhwr4fb"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_0wuio"]
|
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_0wuio"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dadbn306owsy3" path="res://resources/bullets/arrow/arrow.png" id="2_b2ohg"]
|
[ext_resource type="Texture2D" uid="uid://dadbn306owsy3" path="res://resources/bullets/arrow/arrow.png" id="2_b2ohg"]
|
||||||
|
[ext_resource type="Script" uid="uid://u5x40y0cvqq2" path="res://scripts/Contents/Bullets/Arrow.gd" id="2_qddg0"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_b2ohg"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_b2ohg"]
|
||||||
|
|
||||||
[node name="Arrow" instance=ExtResource("1_0wuio")]
|
[node name="Arrow" instance=ExtResource("1_0wuio")]
|
||||||
|
script = ExtResource("2_qddg0")
|
||||||
displayName = "鸡毛箭"
|
displayName = "鸡毛箭"
|
||||||
|
speed = 20.0
|
||||||
|
damage = 50.0
|
||||||
penerate = 1.0
|
penerate = 1.0
|
||||||
|
lifeDistance = 1200.0
|
||||||
|
|
||||||
[node name="static" type="Sprite2D" parent="texture" index="1"]
|
[node name="static" type="Sprite2D" parent="texture" index="1"]
|
||||||
scale = Vector2(0.06775362, 0.06775362)
|
scale = Vector2(0.06775362, 0.06775362)
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://c2ga3ktbxdfc5"]
|
[gd_scene load_steps=4 format=3 uid="uid://c2ga3ktbxdfc5"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_t0pyo"]
|
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_t0pyo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://7us1po711e3o" path="res://resources/weapons/鸡毛弓.png" id="2_two1a"]
|
[ext_resource type="Texture2D" uid="uid://7us1po711e3o" path="res://resources/weapons/鸡毛弓.png" id="2_two1a"]
|
||||||
|
[ext_resource type="Script" uid="uid://dnnxxqpbpwohf" path="res://scripts/Contents/Bullets/Bow.gd" id="2_wtwgr"]
|
||||||
|
|
||||||
[node name="Bow" instance=ExtResource("1_t0pyo")]
|
[node name="Bow" instance=ExtResource("1_t0pyo")]
|
||||||
|
script = ExtResource("2_wtwgr")
|
||||||
|
metadata/_edit_vertical_guides_ = [88.0]
|
||||||
|
|
||||||
[node name="static" type="Sprite2D" parent="texture" index="1"]
|
[node name="static" type="Sprite2D" parent="texture" index="1"]
|
||||||
|
position = Vector2(150, 0)
|
||||||
scale = Vector2(0.055427626, 0.055427626)
|
scale = Vector2(0.055427626, 0.055427626)
|
||||||
texture = ExtResource("2_two1a")
|
texture = ExtResource("2_two1a")
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=15 format=3 uid="uid://bm7ymrri6pykb"]
|
[gd_scene load_steps=16 format=3 uid="uid://bm7ymrri6pykb"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"]
|
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"]
|
||||||
[ext_resource type="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"]
|
[ext_resource type="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dclinyhu256xi" path="res://resources/sounds/effect/Low Whoosh.mp3" id="3_4syso"]
|
[ext_resource type="AudioStream" uid="uid://dclinyhu256xi" path="res://resources/sounds/effect/Low Whoosh.mp3" id="3_4syso"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dgka15811lrrj" path="res://components/Weapons/Bow.tscn" id="3_fkh3f"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c0n3igy4hucrg" path="res://components/Weapons/PurpleCrystal.tscn" id="3_jluqw"]
|
[ext_resource type="PackedScene" uid="uid://c0n3igy4hucrg" path="res://components/Weapons/PurpleCrystal.tscn" id="3_jluqw"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"]
|
[ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"]
|
||||||
[ext_resource type="PackedScene" uid="uid://u0djqwuuysp8" path="res://components/Weapons/Volcano.tscn" id="4_jluqw"]
|
[ext_resource type="PackedScene" uid="uid://u0djqwuuysp8" path="res://components/Weapons/Volcano.tscn" id="4_jluqw"]
|
||||||
@@ -51,17 +52,21 @@ radius = 61.204575
|
|||||||
script = ExtResource("2_oqdqd")
|
script = ExtResource("2_oqdqd")
|
||||||
displayName = "公鸡"
|
displayName = "公鸡"
|
||||||
useStatic = true
|
useStatic = true
|
||||||
metadata/_edit_horizontal_guides_ = [-139.0]
|
metadata/_edit_horizontal_guides_ = [-188.0]
|
||||||
metadata/_edit_vertical_guides_ = [58.0]
|
metadata/_edit_vertical_guides_ = [71.0]
|
||||||
|
|
||||||
[node name="weaponStore" parent="." index="1"]
|
[node name="weaponStore" parent="." index="1"]
|
||||||
process_mode = 4
|
process_mode = 4
|
||||||
|
|
||||||
[node name="PurpleCrystal" parent="weaponStore" index="0" instance=ExtResource("3_jluqw")]
|
[node name="Bow" parent="weaponStore" index="0" instance=ExtResource("3_fkh3f")]
|
||||||
|
offset_bottom = 374.0
|
||||||
|
debugRebuild = false
|
||||||
|
|
||||||
|
[node name="PurpleCrystal" parent="weaponStore" index="1" instance=ExtResource("3_jluqw")]
|
||||||
offset_bottom = 350.0
|
offset_bottom = 350.0
|
||||||
debugRebuild = false
|
debugRebuild = false
|
||||||
|
|
||||||
[node name="Volcano" parent="weaponStore" index="1" instance=ExtResource("4_jluqw")]
|
[node name="Volcano" parent="weaponStore" index="2" instance=ExtResource("4_jluqw")]
|
||||||
debugRebuild = false
|
debugRebuild = false
|
||||||
|
|
||||||
[node name="sprint" parent="sounds" index="0"]
|
[node name="sprint" parent="sounds" index="0"]
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dgka15811lrrj"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ckq2cq6m23hq3" path="res://components/Abstracts/WeaponCardBase.tscn" id="1_fhedw"]
|
||||||
|
[ext_resource type="Script" uid="uid://1u8t36atj041" path="res://scripts/Contents/Weapons/Bow.gd" id="2_bou5i"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://7us1po711e3o" path="res://resources/weapons/鸡毛弓.png" id="2_ex3jl"]
|
||||||
|
|
||||||
|
[node name="Bow" instance=ExtResource("1_fhedw")]
|
||||||
|
script = ExtResource("2_bou5i")
|
||||||
|
avatarTexture = ExtResource("2_ex3jl")
|
||||||
|
displayName = "鸡毛弓"
|
||||||
|
quality = 2
|
||||||
|
costBeachball = 50
|
||||||
|
store = {
|
||||||
|
"atk": 3,
|
||||||
|
"count": 1,
|
||||||
|
"self": 0.5
|
||||||
|
}
|
||||||
|
storeType = {
|
||||||
|
"atk": 2,
|
||||||
|
"count": 1,
|
||||||
|
"self": 0
|
||||||
|
}
|
||||||
|
descriptionTemplate = "消耗$self点生命值,发射$count支[b]鸡毛箭[/b],每支造成当前飞行速度的$atk伤害。"
|
||||||
|
needEnergy = 20.0
|
||||||
|
cooldown = 500.0
|
||||||
|
debugRebuild = true
|
||||||
|
|
||||||
|
[node name="avatar" parent="container/info" index="0"]
|
||||||
|
texture = ExtResource("2_ex3jl")
|
||||||
|
|
||||||
|
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
|
||||||
|
text = "20.0"
|
||||||
|
|
||||||
|
[node name="beachball" parent="container/info/infos" index="1"]
|
||||||
|
count = 50
|
||||||
|
|
||||||
|
[node name="soul" parent="container/info/infos" index="2"]
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
[node name="name" parent="container/info" index="2"]
|
||||||
|
displayName = "鸡毛弓"
|
||||||
|
quality = 2
|
||||||
|
|
||||||
|
[node name="description" parent="container" index="2"]
|
||||||
|
text = "[center]消耗[color=cyan]0.50[/color]点生命值,发射[color=cyan]1[/color]支[b]鸡毛箭[/b],每支造成当前飞行速度的[color=cyan]300%[/color]伤害。[/center]"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
extends BulletBase
|
||||||
|
class_name Arrow
|
||||||
|
|
||||||
|
var atk: float = 0
|
||||||
|
|
||||||
|
func ai():
|
||||||
|
speed = (1 - lifeDistancePercent()) * initialSpeed
|
||||||
|
damage = speed * atk
|
||||||
|
PresetBulletAI.forward(self, rotation)
|
||||||
|
if speed < 1:
|
||||||
|
tryDestroy()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://u5x40y0cvqq2
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
extends BulletBase
|
||||||
|
class_name Bow
|
||||||
|
|
||||||
|
var count: int = 0
|
||||||
|
var atk: float = 0
|
||||||
|
|
||||||
|
func spawn():
|
||||||
|
await TickTool.millseconds(250)
|
||||||
|
var startAngle = rotation - deg_to_rad(count * 10.0 / 2)
|
||||||
|
for c in count:
|
||||||
|
for i in BulletBase.generate(
|
||||||
|
ComponentManager.getBullet("Arrow"),
|
||||||
|
launcher,
|
||||||
|
position,
|
||||||
|
startAngle + deg_to_rad(c * 10)
|
||||||
|
):
|
||||||
|
var bullet: Arrow = i
|
||||||
|
bullet.atk = atk
|
||||||
|
tryDestroy()
|
||||||
|
func ai():
|
||||||
|
PresetBulletAI.lockLauncher(self, launcher, true)
|
||||||
|
rotation = position.angle_to_point(get_global_mouse_position())
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dnnxxqpbpwohf
|
||||||
@@ -11,4 +11,4 @@ func ai():
|
|||||||
tryDestroy()
|
tryDestroy()
|
||||||
func destroy(beacuseMap: bool):
|
func destroy(beacuseMap: bool):
|
||||||
if beacuseMap:
|
if beacuseMap:
|
||||||
launcher.takeDamage(self, MathTool.rate(0.5))
|
launcher.bulletHit(self, MathTool.rate(0.5))
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
@tool
|
||||||
|
extends Weapon
|
||||||
|
|
||||||
|
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||||
|
origin["atk"] += 0.05 * to * soulLevel
|
||||||
|
origin["count"] = 1 * soulLevel
|
||||||
|
origin["self"] += 0.1 * to
|
||||||
|
return origin
|
||||||
|
func attack(entity: EntityBase):
|
||||||
|
entity.takeDamage(readStore("self"))
|
||||||
|
var weaponPos = entity.findWeaponAnchor("normal")
|
||||||
|
for i in BulletBase.generate(
|
||||||
|
ComponentManager.getBullet("Bow"),
|
||||||
|
entity,
|
||||||
|
weaponPos,
|
||||||
|
weaponPos.angle_to_point(get_global_mouse_position())
|
||||||
|
):
|
||||||
|
var bullet: Bow = i
|
||||||
|
bullet.count = readStore("count")
|
||||||
|
bullet.atk = readStore("atk")
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://1u8t36atj041
|
||||||
@@ -88,7 +88,7 @@ func hit(target: Node):
|
|||||||
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
||||||
if !entity || !launcher: return
|
if !entity || !launcher: return
|
||||||
if !BulletTool.canDamage(self, entity): return
|
if !BulletTool.canDamage(self, entity): return
|
||||||
var resultDamage = entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE]))
|
var resultDamage = entity.bulletHit(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE]))
|
||||||
succeedToHit(resultDamage, entity)
|
succeedToHit(resultDamage, entity)
|
||||||
if MathTool.rate(fullPenerate()):
|
if MathTool.rate(fullPenerate()):
|
||||||
penerate -= entity.fields[FieldStore.Entity.PENARATION_RESISTANCE]
|
penerate -= entity.fields[FieldStore.Entity.PENARATION_RESISTANCE]
|
||||||
|
|||||||
@@ -224,7 +224,15 @@ func getSprintInitialDisplace():
|
|||||||
return displace(velocity) * sprintMultiplier
|
return displace(velocity) * sprintMultiplier
|
||||||
func getSprintProgress():
|
func getSprintProgress():
|
||||||
return velocity.length() / getSprintInitialDisplace().length()
|
return velocity.length() / getSprintInitialDisplace().length()
|
||||||
func takeDamage(bullet: BulletBase, crit: bool):
|
func takeDamage(baseDamage: float, crit: bool = false, perfectMiss: bool = false):
|
||||||
|
var resultDamage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE)
|
||||||
|
health -= resultDamage
|
||||||
|
healthChanged.emit(health)
|
||||||
|
DamageLabel.create(resultDamage, crit || perfectMiss, damageAnchor.global_position + MathTool.randv2_range(GameRule.damageLabelSpawnOffset))
|
||||||
|
if health <= 0:
|
||||||
|
tryDie(null)
|
||||||
|
return resultDamage
|
||||||
|
func bulletHit(bullet: BulletBase, crit: bool):
|
||||||
# 当受伤时
|
# 当受伤时
|
||||||
hurtAnimator.play("hurt")
|
hurtAnimator.play("hurt")
|
||||||
var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
|
var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
|
||||||
|
|||||||
Reference in New Issue
Block a user