From 973ac74455b8f3bfb8f23759bbc80c6761404b8f Mon Sep 17 00:00:00 2001 From: chendian <-> Date: Fri, 7 Mar 2025 12:14:02 +0800 Subject: [PATCH] fix bug --- config/character_stun/normal.tres | 2 +- script/character/battle.gd | 2 +- script/character/buff.gd | 14 +++-- script/character/character.gd | 1 + script/character/skill.gd | 2 +- script/character/view.gd | 88 +++++++++++++++++-------------- 6 files changed, 62 insertions(+), 47 deletions(-) diff --git a/config/character_stun/normal.tres b/config/character_stun/normal.tres index aba3cd9..c76b9a8 100644 --- a/config/character_stun/normal.tres +++ b/config/character_stun/normal.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="StunCfg" load_steps=2 format=3 uid="uid://cac6mk6g078vn"] -[ext_resource type="Script" path="res://script/config/stun_cfg.gd" id="1_2kfjh"] +[ext_resource type="Script" uid="uid://cgkbmwusqtrme" path="res://script/config/stun_cfg.gd" id="1_2kfjh"] [resource] script = ExtResource("1_2kfjh") diff --git a/script/character/battle.gd b/script/character/battle.gd index b8546c9..4873162 100644 --- a/script/character/battle.gd +++ b/script/character/battle.gd @@ -492,7 +492,7 @@ func on_skill_trigger(skill_name: String, trigger_name: String) -> void: #====skill_trigger==== func on_hero01_long_stab01_cast(): - if status.skill_repeat_count >= 5: + if status.skill_repeat_count >= 4: skill.cast_skill_by_name("hero01_long_stab02", status.move_dir) diff --git a/script/character/buff.gd b/script/character/buff.gd index fba277c..62863e6 100644 --- a/script/character/buff.gd +++ b/script/character/buff.gd @@ -28,7 +28,7 @@ func _process(delta): return tick(delta_cache) buff_tick_frame = 0 - buff_tick_frame = 0 + delta_cache = 0 func tick(delta) -> void: for buff_name in buff_map: @@ -203,16 +203,20 @@ func on_end_weapon_index_change(_rate) -> void: #表现 -func on_start_freeze(_rate) -> void: status.set_status("is_pause", true) +func on_start_freeze(_rate) -> void: + status.set_status("is_pause", true) -func on_end_freeze(_rate) -> void: status.set_status("is_pause", false) +func on_end_freeze(_rate) -> void: + status.set_status("is_pause", false) -func on_second_pause(_rate) -> void: status.set_status("is_pause", true) +func on_second_pause(_rate) -> void: + status.set_status("is_pause", true) -func on_end_pause(_rate) -> void: status.set_status("is_pause", false) +func on_end_pause(_rate) -> void: + status.set_status("is_pause", false) func on_start_flash_white(_rate) -> void: status.set_status("flash_white_rate", 1) diff --git a/script/character/character.gd b/script/character/character.gd index 947fe69..2c6213d 100644 --- a/script/character/character.gd +++ b/script/character/character.gd @@ -131,6 +131,7 @@ func set_pos(pos_new: Vector3): func emit_pos_changed(): SignalManager.character_pos_changed.emit(id(), pos()) + SignalManager.character_ui_pos_changed.emit(id(), ui_pos()) func move_to(dir: Vector2): set_status("move_dir", dir.normalized()) diff --git a/script/character/skill.gd b/script/character/skill.gd index 95fb6aa..7c35e50 100644 --- a/script/character/skill.gd +++ b/script/character/skill.gd @@ -143,7 +143,7 @@ func cast_skill(cfg: SkillCfg, cast_dir: Vector2, action_key: String = "") -> vo #技能重复次数 if status.skill_cfg and status.skill_cfg == cfg: - status.set_status("skill_repeat_count", 1) + status.set_status("skill_repeat_count", status.skill_repeat_count + 1) else: status.set_status("skill_repeat_count", 0) diff --git a/script/character/view.gd b/script/character/view.gd index dd96a24..c288867 100644 --- a/script/character/view.gd +++ b/script/character/view.gd @@ -12,8 +12,9 @@ class Trans: var to: StringName var trigger_name: StringName -var trans_dict: Dictionary = {} # {condition/trigger:{from:Trans}} +var trans_dict: Dictionary = {} # {condition/trigger:{from:Trans[]}} var move_sprite_frames: SpriteFrames +var current_animation: String func init(default: SpriteFrames): sprite_frames = default @@ -59,26 +60,30 @@ func trans_register() -> void: run("mhit", "idle_loop") run("lhit", "idle_loop") + #地面眩晕受击 + trigger_with_condition("any", "stunhit", "trigger_stun_hit", "is_on_floor", "=", true) + run("stunhit", "ground_stun1_loop") + #空中受击 trigger("any", "airhit1", "trigger_air_hit_up") trigger("any", "airhit4_loop", "trigger_air_hit_down") run("airhit1", "airhit2_loop") trans("airhit2_loop", "airhit3", "speed_y", "<=", 0) run("airhit3", "airhit4_loop") - trans("airhit4_loop", "airhit5", "is_on_floor", "=", true) + trans("airhit4_loop", "airhit5_select", "is_on_floor", "=", true) + + #空中受击落地 + run_with_condition("airhit5_select", "airhit5_stun", "is_stun", "=", true) + run_with_condition("airhit5_select", "airhit5", "is_stun", "=", false) + run("airhit5_stun", "ground_stun1_loop") run("airhit5", "ground1_loop") + + #起身 trans("ground1_loop", "ground2", "is_stagger", "=", false) run("ground2", "idle_loop") - - #眩晕受击 - trigger_with_condition("any", "stunhit", "trigger_stun_hit", "is_on_floor", "=", true) - run("stunhit", "ground_stun1_loop") trans("ground_stun1_loop", "ground_stun2", "is_stun", "=", false) run("ground_stun2", "idle_loop") - #空中眩晕受击 - trans("airhit5", "airhit5_stun", "is_stun", "=", true) - run("airhit5_stun", "ground_stun1_loop") #落地反弹 trigger("any", "rebound", "trigger_rebound") @@ -112,24 +117,27 @@ func _on_frame_changed() -> void: update_material_tex() - func run(from: StringName, to: StringName): - _add_trans(from, to, "animation_end", "", "", "") + _add_trans(from, to, "animation_end", "", "", "", "") + + +func run_with_condition(from: StringName, to: StringName, condition, compareType, conditionValue): + _add_trans(from, to, "animation_end", condition, compareType, conditionValue, "") func trans(from: StringName, to: StringName, condition, compareType, conditionValue): - _add_trans(from, to, condition, compareType, conditionValue, "") + _add_trans(from, to, condition, condition, compareType, conditionValue, "") func trigger(from: StringName, to: StringName, trigger_name: StringName): - _add_trans(from, to, "", "", "", trigger_name) + _add_trans(from, to, trigger_name, "", "", "", trigger_name) func trigger_with_condition(from: StringName, to: StringName, trigger_name: StringName, condition, compareType, conditionValue): - _add_trans(from, to, condition, compareType, conditionValue, trigger_name) + _add_trans(from, to, trigger_name, condition, compareType, conditionValue, trigger_name) -func _add_trans(from: StringName, to: StringName, condition, compareType, conditionValue, trigger_name: StringName): +func _add_trans(from: StringName, to: StringName, key: String, condition, compareType, conditionValue, trigger_name: StringName): var new_trans = Trans.new() new_trans.condition = condition new_trans.compareType = compareType @@ -138,38 +146,39 @@ func _add_trans(from: StringName, to: StringName, condition, compareType, condit new_trans.to = to new_trans.trigger_name = trigger_name - - if trigger_name != "": - if not trigger_name in trans_dict: - trans_dict[trigger_name] = {} - trans_dict[trigger_name][from] = new_trans - else: - if not condition in trans_dict: - trans_dict[condition] = {} - trans_dict[condition][from] = new_trans + if not key in trans_dict: + trans_dict[key] = {} + if not from in trans_dict[key]: + trans_dict[key][from] = [] + trans_dict[key][from].append(new_trans) func update_trans(key: String, value) -> void: if not key in trans_dict: return - if animation in trans_dict[key]: - update_trans_single(trans_dict[key][animation], value) + if current_animation in trans_dict[key]: + update_trans_single(trans_dict[key][current_animation], value) if "any" in trans_dict[key]: update_trans_single(trans_dict[key]["any"], value) -func update_trans_single(trans_single: Trans, value) -> void: - if trans_single.condition != "": - match trans_single.compareType: - ">": if value <= trans_single.conditionValue: return - "<": if value >= trans_single.conditionValue: return - ">=": if value < trans_single.conditionValue: return - "<=": if value > trans_single.conditionValue: return - "=": if value != trans_single.conditionValue: return - if trans_single.trigger_name != "": - if status.get(trans_single.trigger_name): - status.set(trans_single.trigger_name, false) - play_animation(trans_single.to) +func update_trans_single(trans_list, value) -> void: + for trans_single in trans_list: + if trans_single.condition != "": + if value == null: + value = status.get_status(trans_single.condition) + match trans_single.compareType: + ">": if value <= trans_single.conditionValue: continue + "<": if value >= trans_single.conditionValue: continue + ">=": if value < trans_single.conditionValue: continue + "<=": if value > trans_single.conditionValue: continue + "=": if value != trans_single.conditionValue: continue + if trans_single.trigger_name != "": + if status.get_status(trans_single.trigger_name): + status.set_status(trans_single.trigger_name, false) + else: + continue + play_animation(trans_single.to) func update_view(): @@ -216,10 +225,11 @@ func _update_material_tex(): func play_animation(animation_name: String) -> void: + current_animation = animation_name if not sprite_frames: return if not sprite_frames.has_animation(animation_name): - print("无效动画:", animation_name) + update_trans("animation_end", null) return if animation_name == animation: frame = 0