Combo attacks, weapon stats
This commit is contained in:
parent
40262103b2
commit
83119f7b7b
8 changed files with 170 additions and 83 deletions
|
|
@ -3,50 +3,6 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://dp3jbqmr5toth" path="res://textures/character-body.png" id="1_06ej8"]
|
[ext_resource type="Texture2D" uid="uid://dp3jbqmr5toth" path="res://textures/character-body.png" id="1_06ej8"]
|
||||||
[ext_resource type="Texture2D" uid="uid://3ptkafoafq14" path="res://textures/character-leg.png" id="2_54k0m"]
|
[ext_resource type="Texture2D" uid="uid://3ptkafoafq14" path="res://textures/character-leg.png" id="2_54k0m"]
|
||||||
[ext_resource type="Texture2D" uid="uid://rgxhw23471ut" path="res://textures/character-arm.png" id="3_yptk5"]
|
[ext_resource type="Texture2D" uid="uid://rgxhw23471ut" path="res://textures/character-arm.png" id="3_yptk5"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bkthnj23dxsc4" path="res://textures/slash.png" id="4_ny5xw"]
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vtaks"]
|
|
||||||
atlas = ExtResource("4_ny5xw")
|
|
||||||
region = Rect2(0, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kvpfn"]
|
|
||||||
atlas = ExtResource("4_ny5xw")
|
|
||||||
region = Rect2(48, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dinhu"]
|
|
||||||
atlas = ExtResource("4_ny5xw")
|
|
||||||
region = Rect2(96, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kvuet"]
|
|
||||||
atlas = ExtResource("4_ny5xw")
|
|
||||||
region = Rect2(144, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_trtic"]
|
|
||||||
atlas = ExtResource("4_ny5xw")
|
|
||||||
region = Rect2(192, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_ir15t"]
|
|
||||||
animations = [{
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_vtaks")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_kvpfn")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_dinhu")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_kvuet")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_trtic")
|
|
||||||
}],
|
|
||||||
"loop": false,
|
|
||||||
"name": &"default",
|
|
||||||
"speed": 16.0
|
|
||||||
}]
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_gee14"]
|
[sub_resource type="Animation" id="Animation_gee14"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
|
|
@ -637,16 +593,6 @@ texture_filter = 0
|
||||||
render_priority = -1
|
render_priority = -1
|
||||||
texture = ExtResource("3_yptk5")
|
texture = ExtResource("3_yptk5")
|
||||||
|
|
||||||
[node name="Slash" type="AnimatedSprite3D" parent="Body/ArmPivot" unique_id=387297010]
|
|
||||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, -0.1500001, 0)
|
|
||||||
pixel_size = 0.04
|
|
||||||
no_depth_test = true
|
|
||||||
texture_filter = 0
|
|
||||||
render_priority = 99
|
|
||||||
sprite_frames = SubResource("SpriteFrames_ir15t")
|
|
||||||
frame = 4
|
|
||||||
frame_progress = 1.0
|
|
||||||
|
|
||||||
[node name="Animations" type="AnimationPlayer" parent="." unique_id=705651586]
|
[node name="Animations" type="AnimationPlayer" parent="." unique_id=705651586]
|
||||||
libraries/ = SubResource("AnimationLibrary_vtaks")
|
libraries/ = SubResource("AnimationLibrary_vtaks")
|
||||||
|
|
||||||
|
|
|
||||||
58
scenes/effects/slash.tscn
Normal file
58
scenes/effects/slash.tscn
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
[gd_scene format=3 uid="uid://eycadu74k5yx"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bkthnj23dxsc4" path="res://textures/slash.png" id="1_edkvd"]
|
||||||
|
[ext_resource type="Script" uid="uid://d26yt0riuggb4" path="res://scripts/effects/slash.gd" id="2_dcbvk"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_vtaks"]
|
||||||
|
atlas = ExtResource("1_edkvd")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_kvpfn"]
|
||||||
|
atlas = ExtResource("1_edkvd")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_dinhu"]
|
||||||
|
atlas = ExtResource("1_edkvd")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_kvuet"]
|
||||||
|
atlas = ExtResource("1_edkvd")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_trtic"]
|
||||||
|
atlas = ExtResource("1_edkvd")
|
||||||
|
region = Rect2(192, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_ir15t"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_vtaks")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_kvpfn")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_dinhu")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_kvuet")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_trtic")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 16.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[node name="Slash" type="AnimatedSprite3D" unique_id=1787289120]
|
||||||
|
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
||||||
|
pixel_size = 0.04
|
||||||
|
no_depth_test = true
|
||||||
|
texture_filter = 0
|
||||||
|
render_priority = 99
|
||||||
|
sprite_frames = SubResource("SpriteFrames_ir15t")
|
||||||
|
frame = 4
|
||||||
|
frame_progress = 1.0
|
||||||
|
script = ExtResource("2_dcbvk")
|
||||||
9
scripts/effects/slash.gd
Normal file
9
scripts/effects/slash.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends AnimatedSprite3D
|
||||||
|
|
||||||
|
|
||||||
|
func play_effect():
|
||||||
|
play("default")
|
||||||
|
|
||||||
|
await animation_finished
|
||||||
|
|
||||||
|
queue_free()
|
||||||
1
scripts/effects/slash.gd.uid
Normal file
1
scripts/effects/slash.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d26yt0riuggb4
|
||||||
|
|
@ -1,5 +1,17 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const weapons = {
|
const weapons = {
|
||||||
|
"test_sword": {
|
||||||
|
"combo_weapon": true,
|
||||||
|
"hits_to_finish": 3,
|
||||||
|
"swing_time": 0.1,
|
||||||
|
"combo_timeout": 0.35,
|
||||||
|
"swing_time_combo_finish": 0.42,
|
||||||
|
"damage": 15,
|
||||||
|
"damage_mid_combo": 10,
|
||||||
|
|
||||||
|
"knockback": 3.5,
|
||||||
|
"knockback_mid_combo": 0.25,
|
||||||
|
"stun_time": 0.4,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,14 @@ var iframes = 0
|
||||||
var knockback_time = 0
|
var knockback_time = 0
|
||||||
var health = 100
|
var health = 100
|
||||||
|
|
||||||
|
var combo_hits = 0
|
||||||
|
var combo_timer = 0
|
||||||
|
var swing_timer = 0
|
||||||
|
|
||||||
|
var queue_swing = false
|
||||||
|
|
||||||
|
var current_weapon = "test_sword"
|
||||||
|
|
||||||
@onready var game = get_parent()
|
@onready var game = get_parent()
|
||||||
@onready var camera = game.get_node("PlayerCamera")
|
@onready var camera = game.get_node("PlayerCamera")
|
||||||
|
|
||||||
|
|
@ -20,6 +28,16 @@ func hit_me():
|
||||||
iframes = 0.5
|
iframes = 0.5
|
||||||
health -= 10
|
health -= 10
|
||||||
|
|
||||||
|
func get_my_weapon_info(value: String):
|
||||||
|
return get_weapon_info(current_weapon, value)
|
||||||
|
|
||||||
|
func get_weapon_info(weapon: String, value: String):
|
||||||
|
print(weapon, value)
|
||||||
|
if value in Global.weapons[weapon]:
|
||||||
|
print("YAYA", Global.weapons[weapon][value])
|
||||||
|
return Global.weapons[weapon][value]
|
||||||
|
else: return null
|
||||||
|
|
||||||
func on_hit(hitter: Node3D = null) -> void:
|
func on_hit(hitter: Node3D = null) -> void:
|
||||||
iframes = 0.8
|
iframes = 0.8
|
||||||
|
|
||||||
|
|
@ -57,9 +75,10 @@ func _physics_process(delta: float) -> void:
|
||||||
else:
|
else:
|
||||||
$DreamerBody.rotation.y = face_rotation
|
$DreamerBody.rotation.y = face_rotation
|
||||||
|
|
||||||
if combatable:
|
|
||||||
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())
|
||||||
$DreamerBody/Body/ArmPivot.rotation.z = mouse_point_angle
|
|
||||||
|
if combatable:
|
||||||
|
#$DreamerBody/Body/ArmPivot.rotation.z = mouse_point_angle
|
||||||
$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:
|
||||||
|
|
@ -69,12 +88,11 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
if (rad_to_deg(mouse_point_angle) < -90) or (rad_to_deg(mouse_point_angle) > 90):
|
if (rad_to_deg(mouse_point_angle) < -90) or (rad_to_deg(mouse_point_angle) > 90):
|
||||||
face_left = true
|
face_left = true
|
||||||
$DreamerBody/Body/ArmPivot.scale.y = -1
|
|
||||||
$DreamerBody/Body/ArmPivot.scale.x = -1
|
|
||||||
var mouse_pos = get_viewport().get_mouse_position()
|
var mouse_pos = get_viewport().get_mouse_position()
|
||||||
mouse_pos.y = (viewport_half.y) + ((viewport_half.y) - mouse_pos.y)
|
mouse_pos.y = (viewport_half.y) + ((viewport_half.y) - mouse_pos.y)
|
||||||
|
|
||||||
$DreamerBody/Body/ArmPivot.rotation.z = viewport_half.angle_to_point(mouse_pos)
|
#$DreamerBody/Body/ArmPivot.rotation.z = viewport_half.angle_to_point(mouse_pos)
|
||||||
else:
|
else:
|
||||||
face_left = false
|
face_left = false
|
||||||
$DreamerBody/Body/ArmPivot.scale.y = 1
|
$DreamerBody/Body/ArmPivot.scale.y = 1
|
||||||
|
|
@ -96,22 +114,68 @@ func _physics_process(delta: float) -> void:
|
||||||
if input_dir.x < 0:
|
if input_dir.x < 0:
|
||||||
face_left = true
|
face_left = true
|
||||||
|
|
||||||
if Input.is_action_just_pressed("attack"):
|
if swing_timer > 0: swing_timer -= delta
|
||||||
$DreamerBody/Body/ArmPivot/Slash.play("default")
|
if combo_timer > 0:
|
||||||
|
combo_timer -= delta
|
||||||
|
if combo_timer <= 0:
|
||||||
|
combo_hits = 0
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("attack") or queue_swing:
|
||||||
|
if swing_timer > 0:
|
||||||
|
if swing_timer < 0.1:
|
||||||
|
queue_swing = true
|
||||||
|
else:
|
||||||
|
queue_swing = false
|
||||||
|
|
||||||
|
swing_timer = get_my_weapon_info("swing_time")
|
||||||
|
combo_timer = get_my_weapon_info("combo_timeout")
|
||||||
|
if swing_timer == null: swing_timer = 0.0
|
||||||
|
if combo_timer == null: combo_timer = 0.0
|
||||||
|
|
||||||
|
combo_hits += 1
|
||||||
|
|
||||||
|
var slash = load("res://scenes/effects/slash.tscn").instantiate()
|
||||||
|
game.add_child(slash)
|
||||||
|
slash.global_position = global_position
|
||||||
|
slash.rotation.x = face_rotation
|
||||||
|
slash.rotation.z = -mouse_point_angle + deg_to_rad(180)
|
||||||
|
slash.play_effect()
|
||||||
|
|
||||||
var hits = $HitCollision.get_overlapping_bodies()
|
var hits = $HitCollision.get_overlapping_bodies()
|
||||||
|
|
||||||
|
var knockback = 0
|
||||||
|
var damage = 0
|
||||||
|
|
||||||
|
if get_my_weapon_info("combo_weapon"):
|
||||||
|
if combo_hits < get_my_weapon_info("hits_to_finish"):
|
||||||
|
damage = get_my_weapon_info("damage_mid_combo")
|
||||||
|
knockback = get_my_weapon_info("knockback_mid_combo")
|
||||||
|
else:
|
||||||
|
damage = get_my_weapon_info("damage")
|
||||||
|
knockback = get_my_weapon_info("knockback")
|
||||||
|
|
||||||
|
combo_hits = 0
|
||||||
|
|
||||||
|
swing_timer = get_my_weapon_info("swing_time_combo_finish")
|
||||||
|
if swing_timer == null: swing_timer = 0.0
|
||||||
|
else:
|
||||||
|
damage = get_my_weapon_info("damage")
|
||||||
|
knockback = get_my_weapon_info("knockback")
|
||||||
|
|
||||||
|
combo_hits = 0
|
||||||
|
|
||||||
for body in hits:
|
for body in hits:
|
||||||
if body == self: continue
|
if body == self: continue
|
||||||
|
|
||||||
if "health" in body:
|
if "health" in body:
|
||||||
body.health -= 10
|
body.health -= damage
|
||||||
|
|
||||||
body.position.y += 0.2
|
body.position.y += 0.2
|
||||||
body.velocity.y = 0.4
|
body.velocity.y = 0.4
|
||||||
body.velocity += global_position.direction_to(body.global_position) * 5
|
body.velocity += global_position.direction_to(body.global_position) * knockback
|
||||||
|
|
||||||
if body.velocity.length() > 5:
|
if body.velocity.length() > knockback:
|
||||||
body.velocity = body.velocity.normalized() * 5
|
body.velocity = body.velocity.normalized() * knockback
|
||||||
|
|
||||||
if "mid_knockback" in body:
|
if "mid_knockback" in body:
|
||||||
body.mid_knockback = true
|
body.mid_knockback = true
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,6 @@ func _physics_process(delta: float) -> void:
|
||||||
var viewport_half = (get_viewport().get_visible_rect().size / 2.0)
|
var viewport_half = (get_viewport().get_visible_rect().size / 2.0)
|
||||||
var player_position = camera.unproject_position(global_transform.origin)
|
var player_position = camera.unproject_position(global_transform.origin)
|
||||||
|
|
||||||
print(viewport_half)
|
|
||||||
print(player_position)
|
|
||||||
|
|
||||||
if face_left:
|
if face_left:
|
||||||
$Body.rotation.y = face_rotation + deg_to_rad(180)
|
$Body.rotation.y = face_rotation + deg_to_rad(180)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 137 B |
Loading…
Reference in a new issue