Loading...
Loading...
Compare original and translation side by side
target.health -= 10target.health -= 10MANDATORY: Read the appropriate script before implementing the corresponding pattern.
强制要求:在实现对应模式前,请先阅读相应的脚本。
undefinedundefinedundefinedundefinedundefinedundefined if health_component:
health_component.take_damage(damage)
```gdscript if health_component:
health_component.take_damage(damage)
```gdscript# Calculate knockback direction
if owner_node:
var direction := (global_position - owner_node.global_position).normalized()
data.knockback = direction * knockback_force
return dataundefined# Calculate knockback direction
if owner_node:
var direction := (global_position - owner_node.global_position).normalized()
data.knockback = direction * knockback_force
return dataundefinedundefinedundefinedvar old_health := current_health
current_health -= data.amount
current_health = clampf(current_health, 0, max_health)
health_changed.emit(old_health, current_health)
if current_health <= 0:
died.emit()healed.emit(amount)
health_changed.emit(old_health, current_health)undefinedvar old_health := current_health
current_health -= data.amount
current_health = clampf(current_health, 0, max_health)
health_changed.emit(old_health, current_health)
if current_health <= 0:
died.emit()healed.emit(amount)
health_changed.emit(old_health, current_health)undefinedundefinedundefinedcurrent_state = State.ATTACKING
can_act = false
return truecurrent_state = State.DODGING
can_act = false
return trueundefinedcurrent_state = State.ATTACKING
can_act = false
return truecurrent_state = State.DODGING
can_act = false
return trueundefinedundefinedundefinedif current_time - last_input_time > combo_window:
combo_buffer.clear()
combo_buffer.append(action)
last_input_time = current_time
check_combos()undefinedif current_time - last_input_time > combo_window:
combo_buffer.clear()
combo_buffer.append(action)
last_input_time = current_time
check_combos()undefinedundefinedundefinedis_on_cooldown = true
# Execute ability logic
_execute(caster)
# Start cooldown
await caster.get_tree().create_timer(cooldown).timeout
is_on_cooldown = falseundefinedis_on_cooldown = true
# Execute ability logic
_execute(caster)
# Start cooldown
await caster.get_tree().create_timer(cooldown).timeout
is_on_cooldown = falseundefinedundefinedundefinedif is_crit:
modulate = Color.RED
scale = Vector2(1.5, 1.5)
var tween := create_tween()
tween.set_parallel(true)
tween.tween_property(self, "position:y", position.y - 50, 1.0)
tween.tween_property(self, "modulate:a", 0.0, 1.0)
tween.finished.connect(queue_free)undefinedif is_crit:
modulate = Color.RED
scale = Vector2(1.5, 1.5)
var tween := create_tween()
tween.set_parallel(true)
tween.tween_property(self, "position:y", position.y - 50, 1.0)
tween.tween_property(self, "modulate:a", 0.0, 1.0)
tween.finished.connect(queue_free)undefinedfunc calculate_damage(base_damage: float, crit_chance: float = 0.1) -> DamageData:
var data := DamageData.new(base_damage)
if randf() < crit_chance:
data.is_critical = true
data.amount *= 2.0
return datafunc calculate_damage(base_damage: float, crit_chance: float = 0.1) -> DamageData:
var data := DamageData.new(base_damage)
if randf() < crit_chance:
data.is_critical = true
data.amount *= 2.0
return datagodot-2d-physicsgodot-animation-playergodot-characterbody-2dgodot-2d-physicsgodot-animation-playergodot-characterbody-2d