Combat improvements, new weapon stats for range, width and swooshies

This commit is contained in:
toasterpanic 2026-05-16 13:25:59 -04:00
parent 96b1862312
commit c9bb3287de
11 changed files with 225 additions and 33 deletions

BIN
ouch-x86_64-linux-musl Executable file

Binary file not shown.

View file

@ -0,0 +1,63 @@
[gd_scene format=3 uid="uid://cll52paotcjr7"]
[ext_resource type="Texture2D" uid="uid://n3qlhp2lbgfd" path="res://textures/pierce.png" id="1_ye47h"]
[ext_resource type="Script" uid="uid://d26yt0riuggb4" path="res://scripts/effects/slash.gd" id="2_sysig"]
[sub_resource type="AtlasTexture" id="AtlasTexture_sysig"]
atlas = ExtResource("1_ye47h")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ln4oc"]
atlas = ExtResource("1_ye47h")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_77j1u"]
atlas = ExtResource("1_ye47h")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_d0p3v"]
atlas = ExtResource("1_ye47h")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_8ses3"]
atlas = ExtResource("1_ye47h")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_8tm8q"]
atlas = ExtResource("1_ye47h")
region = Rect2(240, 0, 48, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_jqp4x"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_sysig")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ln4oc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_77j1u")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d0p3v")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8ses3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8tm8q")
}],
"loop": false,
"name": &"default",
"speed": 24.0
}]
[node name="Pierce" type="AnimatedSprite3D" unique_id=1787289120]
transform = Transform3D(-1.5, -8.742278e-08, -3.821371e-15, 0, -4.371139e-08, 1, -1.3113416e-07, 1, 4.371139e-08, 0, 0, 0)
pixel_size = 0.04
texture_filter = 0
sprite_frames = SubResource("SpriteFrames_jqp4x")
frame = 5
frame_progress = 1.0
script = ExtResource("2_sysig")

View file

@ -25,6 +25,7 @@ cell_size = 0.05
cell_height = 0.05 cell_height = 0.05
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_yqjtg"] [sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_yqjtg"]
auto_exposure_scale = 0.3
[sub_resource type="SphereShape3D" id="SphereShape3D_kvuet"] [sub_resource type="SphereShape3D" id="SphereShape3D_kvuet"]
radius = 0.001 radius = 0.001
@ -41,7 +42,7 @@ size = Vector3(0.65, 1, 0.65)
[sub_resource type="Environment" id="Environment_uwrxv"] [sub_resource type="Environment" id="Environment_uwrxv"]
background_mode = 1 background_mode = 1
background_color = Color(1, 1, 1, 1) background_color = Color(0.15027824, 1.627421e-05, 0.15027693, 1)
tonemap_mode = 2 tonemap_mode = 2
volumetric_fog_enabled = true volumetric_fog_enabled = true
adjustment_enabled = true adjustment_enabled = true
@ -332,7 +333,7 @@ collision_layer = 0
collision_mask = 2 collision_mask = 2
[node name="Shape" type="CollisionShape3D" parent="Player/HitCollision" unique_id=653786925] [node name="Shape" type="CollisionShape3D" parent="Player/HitCollision" unique_id=653786925]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 0, 0)
shape = SubResource("BoxShape3D_0tnpc") shape = SubResource("BoxShape3D_0tnpc")
[node name="DreamerBody" parent="Player" unique_id=723408850 instance=ExtResource("4_p57ef")] [node name="DreamerBody" parent="Player" unique_id=723408850 instance=ExtResource("4_p57ef")]

View file

@ -0,0 +1,11 @@
[gd_scene format=3 uid="uid://cq8a8t5g3nko3"]
[ext_resource type="Texture2D" uid="uid://b5g7bhk0kj16" path="res://textures/weapons/inhands/basic_spear.png" id="1_titaa"]
[node name="Sword" type="Sprite3D" unique_id=1724644759]
offset = Vector2(0, 9.5)
pixel_size = 0.03
shaded = true
alpha_cut = 2
texture_filter = 0
texture = ExtResource("1_titaa")

View file

@ -135,7 +135,7 @@ func _physics_process(delta: float) -> void:
state = STATE_ATTACK state = STATE_ATTACK
$DreamerBody/Animator.set("parameters/swing_weapon/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE) $DreamerBody/Animator.set("parameters/swing_weapon/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
var slash = load("res://scenes/effects/slash.tscn").instantiate() var slash = Global.effects.attack_swooshy.slash.instantiate()
game.add_child(slash) game.add_child(slash)
slash.global_position = global_position slash.global_position = global_position
slash.global_rotation.y = $HitCollision.global_rotation.y + deg_to_rad(90) slash.global_rotation.y = $HitCollision.global_rotation.y + deg_to_rad(90)
@ -155,10 +155,10 @@ func _physics_process(delta: float) -> void:
$DreamerBody/Animator.set("parameters/hit/blend_amount", 1.0) $DreamerBody/Animator.set("parameters/hit/blend_amount", 1.0)
$DreamerBody/Animator.set("parameters/dead/blend_amount", 0.0) $DreamerBody/Animator.set("parameters/dead/blend_amount", 0.0)
if (health <= 0) and ((state_timer <= 0) or is_on_floor()): if health <= 0:
if (state_timer <= 0) or is_on_floor():
state = STATE_DEAD state = STATE_DEAD
elif state_timer <= 0:
if state_timer <= 0:
$DreamerBody/Animator.set("parameters/hit/blend_amount", 0.0) $DreamerBody/Animator.set("parameters/hit/blend_amount", 0.0)
state = STATE_APPROACH_ENEMY state = STATE_APPROACH_ENEMY

View file

@ -13,6 +13,11 @@ const weapons = {
"knockback": 3.5, "knockback": 3.5,
"knockback_mid_combo": 0.75, "knockback_mid_combo": 0.75,
"stun_time": 0.4, "stun_time": 0.4,
"range": 1.2,
"width": 1.3,
"attack_swooshy": "slash",
}, },
"basic_knife": { "basic_knife": {
"combo_weapon": true, "combo_weapon": true,
@ -26,6 +31,12 @@ const weapons = {
"knockback": 2.5, "knockback": 2.5,
"knockback_mid_combo": 0.3, "knockback_mid_combo": 0.3,
"stun_time": 0.4, "stun_time": 0.4,
"range": 1,
"width": 1,
"attack_swooshy": "slash",
"attack_swooshy_scale": Vector3(0.8, 0.6, 1),
}, },
"basic_hammer": { "basic_hammer": {
"combo_weapon": true, "combo_weapon": true,
@ -39,11 +50,44 @@ const weapons = {
"knockback": 5.5, "knockback": 5.5,
"knockback_mid_combo": 1.5, "knockback_mid_combo": 1.5,
"stun_time": 0.6, "stun_time": 0.6,
}
"range": 1.2,
"width": 1.3,
"attack_swooshy": "pierce",
},
"basic_spear": {
"combo_weapon": true,
"hits_to_finish": 3,
"swing_time": 0.16,
"combo_timeout": 0.35,
"swing_time_combo_finish": 0.55,
"damage": 10,
"damage_mid_combo": 7,
"knockback": 3.5,
"knockback_mid_combo": 0.75,
"stun_time": 0.4,
"range": 1.75,
"width": 0.7,
"attack_swooshy": "pierce",
"attack_swooshy_scale": Vector3(1.5, 1, 1),
},
} }
const inhands = { const inhands = {
"basic_sword": preload("res://scenes/inhands/basic_sword.tscn"), "basic_sword": preload("res://scenes/inhands/basic_sword.tscn"),
"basic_hammer": preload("res://scenes/inhands/basic_hammer.tscn"), "basic_hammer": preload("res://scenes/inhands/basic_hammer.tscn"),
"basic_knife": preload("res://scenes/inhands/basic_knife.tscn") "basic_knife": preload("res://scenes/inhands/basic_knife.tscn"),
"basic_spear": preload("res://scenes/inhands/basic_spear.tscn")
}
const effects = {
"attack_swooshy": {
"slash": preload("res://scenes/effects/attack_swooshy/slash.tscn"),
"pierce": preload("res://scenes/effects/attack_swooshy/pierce.tscn")
}
} }

View file

@ -44,9 +44,21 @@ func on_hit(hitter: Node3D = null) -> void:
velocity += hitter.global_position.direction_to(global_position) * 8 velocity += hitter.global_position.direction_to(global_position) * 8
velocity.y = 0 velocity.y = 0
func set_weapon(weapon_name: String = "basic_sword") -> void:
current_weapon = weapon_name
$DreamerBody.set_inhand(current_weapon)
var range = get_weapon_info(current_weapon, "range")
var width = get_weapon_info(current_weapon, "width")
$HitCollision/Shape.shape.size = Vector3(range, 1.0, width)
$HitCollision/Shape.position.x = range * -0.5
func _ready() -> void: func _ready() -> void:
LimboConsole.register_command(hit_me) LimboConsole.register_command(hit_me)
$DreamerBody.set_inhand(current_weapon) LimboConsole.register_command(set_weapon)
set_weapon(current_weapon)
func _process(delta: float) -> void: func _process(delta: float) -> void:
@ -84,6 +96,7 @@ func _physics_process(delta: float) -> void:
var mouse_point_angle = player_position.angle_to_point(get_viewport().get_mouse_position()) var mouse_point_angle = player_position.angle_to_point(get_viewport().get_mouse_position())
if combatable: if combatable:
if ((swing_timer <= 0) or (combo_hits < 0)):
$HitCollision.rotation.y = -mouse_point_angle + face_rotation $HitCollision.rotation.y = -mouse_point_angle + face_rotation
if abs(rad_to_deg(mouse_point_angle) - (-90)) < 50: if abs(rad_to_deg(mouse_point_angle) - (-90)) < 50:
@ -141,13 +154,19 @@ func _physics_process(delta: float) -> void:
if swing_timer == null: swing_timer = 0.0 if swing_timer == null: swing_timer = 0.0
if combo_timer == null: combo_timer = 0.0 if combo_timer == null: combo_timer = 0.0
combo_hits += 1 var swooshy_id = get_my_weapon_info("attack_swooshy")
if not swooshy_id: swooshy_id = "slash"
var slash = load("res://scenes/effects/slash.tscn").instantiate()
game.add_child(slash) var attack_swooshy = Global.effects.attack_swooshy[swooshy_id].instantiate()
slash.global_position = global_position game.add_child(attack_swooshy)
slash.global_rotation.y = $HitCollision.global_rotation.y + deg_to_rad(180)
slash.play_effect() var attack_swooshy_scale = get_my_weapon_info("attack_swooshy_scale")
if attack_swooshy_scale: attack_swooshy.scale = attack_swooshy_scale
attack_swooshy.global_position = global_position
attack_swooshy.global_rotation.y = $HitCollision.global_rotation.y + deg_to_rad(180)
attack_swooshy.play_effect()
$DreamerBody/Animator.set("parameters/swing_weapon/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE) $DreamerBody/Animator.set("parameters/swing_weapon/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
@ -156,7 +175,21 @@ func _physics_process(delta: float) -> void:
var knockback = 0 var knockback = 0
var damage = 0 var damage = 0
velocity = global_position.direction_to($HitCollision/Shape.global_position) * 4
velocity.y = 0
if get_my_weapon_info("combo_weapon"): if get_my_weapon_info("combo_weapon"):
var earned_combo_hit = false
for body in hits:
if body == self: continue
if ("health" in body) and (body.health > 0):
earned_combo_hit = true
if earned_combo_hit: combo_hits += 1
else: combo_hits = 0
if combo_hits < get_my_weapon_info("hits_to_finish"): if combo_hits < get_my_weapon_info("hits_to_finish"):
damage = get_my_weapon_info("damage_mid_combo") damage = get_my_weapon_info("damage_mid_combo")
knockback = get_my_weapon_info("knockback_mid_combo") knockback = get_my_weapon_info("knockback_mid_combo")
@ -204,7 +237,7 @@ func _physics_process(delta: float) -> void:
damage_text.get_node("Label").text = str(floor(damage)) damage_text.get_node("Label").text = str(floor(damage))
var direction = (camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() var direction = (camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction and (knockback_time <= 0): if direction and (knockback_time <= 0) and (swing_timer <= 0):
velocity.x = direction.x * SPEED velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED velocity.z = direction.z * SPEED

BIN
textures/pierce.ase Normal file

Binary file not shown.

BIN
textures/pierce.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://n3qlhp2lbgfd"
path="res://.godot/imported/pierce.png-c457f33d8ab80ac399d54cda9022be2d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/pierce.png"
dest_files=["res://.godot/imported/pierce.png-c457f33d8ab80ac399d54cda9022be2d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0