|
|
|
@ -36,6 +36,7 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") |
|
|
|
var equipped_weapon: BaseWeapon = null # Main hand weapon |
|
|
|
var equipped_weapon: BaseWeapon = null # Main hand weapon |
|
|
|
var equipped_offhand: BaseWeapon = null # Off-hand weapon |
|
|
|
var equipped_offhand: BaseWeapon = null # Off-hand weapon |
|
|
|
var _nearby_weapons: Array[WorldWeapon] = [] |
|
|
|
var _nearby_weapons: Array[WorldWeapon] = [] |
|
|
|
|
|
|
|
var is_blocking: bool = false |
|
|
|
|
|
|
|
|
|
|
|
# Attack system |
|
|
|
# Attack system |
|
|
|
@export var attack_damage: float = 10.0 |
|
|
|
@export var attack_damage: float = 10.0 |
|
|
|
@ -165,8 +166,14 @@ func _process(delta): |
|
|
|
if Input.is_action_just_pressed("dash") and _dash_cooldown_timer <= 0 and not is_dead and is_on_floor(): |
|
|
|
if Input.is_action_just_pressed("dash") and _dash_cooldown_timer <= 0 and not is_dead and is_on_floor(): |
|
|
|
_perform_dash() |
|
|
|
_perform_dash() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Handle block input |
|
|
|
|
|
|
|
if Input.is_action_pressed("block") and not is_dead: |
|
|
|
|
|
|
|
_try_block() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
is_blocking = false |
|
|
|
|
|
|
|
|
|
|
|
# Handle attack input |
|
|
|
# Handle attack input |
|
|
|
if Input.is_action_just_pressed("attack") and not is_dead and not _is_dashing: |
|
|
|
if Input.is_action_just_pressed("attack") and not is_dead and not _is_dashing and not is_blocking: |
|
|
|
_perform_attack() |
|
|
|
_perform_attack() |
|
|
|
|
|
|
|
|
|
|
|
# Handle weapon pickup/drop |
|
|
|
# Handle weapon pickup/drop |
|
|
|
@ -270,6 +277,38 @@ func set_mesh_texture(mesh_instance: MeshInstance3D, texture: CompressedTexture2 |
|
|
|
new_material.albedo_texture = texture |
|
|
|
new_material.albedo_texture = texture |
|
|
|
mesh_instance.set_surface_override_material(0, new_material) |
|
|
|
mesh_instance.set_surface_override_material(0, new_material) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Block system |
|
|
|
|
|
|
|
func _try_block(): |
|
|
|
|
|
|
|
# Check if we have a weapon that can block |
|
|
|
|
|
|
|
var can_block_weapon = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if equipped_weapon and equipped_weapon.can_block(): |
|
|
|
|
|
|
|
can_block_weapon = true |
|
|
|
|
|
|
|
elif equipped_offhand and equipped_offhand.can_block(): |
|
|
|
|
|
|
|
can_block_weapon = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_blocking = can_block_weapon |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Could add blocking animation here |
|
|
|
|
|
|
|
# if is_blocking and _body: |
|
|
|
|
|
|
|
# _body.play_block_animation() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Get block reduction amount (0.0 to 1.0) |
|
|
|
|
|
|
|
func get_block_reduction() -> float: |
|
|
|
|
|
|
|
if not is_blocking: |
|
|
|
|
|
|
|
return 0.0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reduction = 0.0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use the highest block reduction from equipped weapons |
|
|
|
|
|
|
|
if equipped_weapon and equipped_weapon.can_block(): |
|
|
|
|
|
|
|
reduction = max(reduction, equipped_weapon.get_block_reduction()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if equipped_offhand and equipped_offhand.can_block(): |
|
|
|
|
|
|
|
reduction = max(reduction, equipped_offhand.get_block_reduction()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reduction |
|
|
|
|
|
|
|
|
|
|
|
## Attack system |
|
|
|
## Attack system |
|
|
|
func _perform_attack(): |
|
|
|
func _perform_attack(): |
|
|
|
if not is_multiplayer_authority() or is_dead: |
|
|
|
if not is_multiplayer_authority() or is_dead: |
|
|
|
|