246 lines
9.7 KiB
Text
246 lines
9.7 KiB
Text
[gd_scene format=3 uid="uid://d0yivm54mjib2"]
|
|
|
|
[ext_resource type="PackedScene" uid="uid://hirlnhjbqv2u" path="res://assets/characters/bot.blend" id="1_eqqp1"]
|
|
[ext_resource type="PackedScene" uid="uid://cex7kfgjqwnl7" path="res://behaviours/trees/player_behaviours.tscn" id="2_uxov2"]
|
|
[ext_resource type="PackedScene" uid="uid://deuif6d8spece" path="res://objects/awareness_area.tscn" id="4_f46kd"]
|
|
[ext_resource type="Script" uid="uid://csqsliec0twij" path="res://scripts/damage_area.gd" id="4_nmc1l"]
|
|
[ext_resource type="Script" uid="uid://cfr2fxpk46n0b" path="res://scripts/weapon_parent.gd" id="5_f46kd"]
|
|
[ext_resource type="Script" uid="uid://bqyfpp0302pae" path="res://scripts/interactor.gd" id="6_3rerk"]
|
|
|
|
[sub_resource type="GDScript" id="GDScript_eqqp1"]
|
|
script/source = "extends CharacterBody3D
|
|
|
|
signal damaged(amount : int, source : Node3D)
|
|
|
|
var jab_queued : bool = false
|
|
var sweep_queued : bool = false
|
|
var backstep_queued : bool = false
|
|
var hurt_high : bool = false
|
|
var target : Node3D = null
|
|
var health : int = 6
|
|
|
|
func _ready():
|
|
damaged.connect(_damaged)
|
|
|
|
func _damaged(amount : int, source : Node3D):
|
|
hurt_high = true
|
|
target = source
|
|
health -= amount
|
|
|
|
func _physics_process(delta: float):
|
|
var root_velocity : Vector3 = %AnimationPlayer.get_root_motion_position() / delta
|
|
var y_velocity := velocity.y
|
|
velocity = global_basis.x * root_velocity.x + global_basis.z * root_velocity.z
|
|
velocity.y = y_velocity
|
|
if not is_on_floor():
|
|
velocity += get_gravity() * delta
|
|
move_and_slide()
|
|
|
|
func _unhandled_input(event : InputEvent):
|
|
if event.is_action_pressed(\"jab\"):
|
|
jab_queued = true
|
|
get_viewport().set_input_as_handled()
|
|
elif event.is_action_pressed(\"sweep\"):
|
|
sweep_queued = true
|
|
get_viewport().set_input_as_handled()
|
|
elif event.is_action_pressed(\"backstep\"):
|
|
backstep_queued = true
|
|
get_viewport().set_input_as_handled()
|
|
|
|
func equip_weapon(weapon : Area3D):
|
|
%WeaponParent.set_weapon(weapon)
|
|
|
|
func is_valid_target(node : Node3D) -> bool:
|
|
return node.health > 0
|
|
|
|
func find_targets() -> Array[Node3D]:
|
|
return $AwarenessArea.aware.filter(is_valid_target)
|
|
|
|
func get_current_weapon_type():
|
|
return %WeaponParent.weapon.animations if %WeaponParent.weapon != null else \"\"
|
|
|
|
func reset_inputs():
|
|
jab_queued = false
|
|
sweep_queued = false
|
|
backstep_queued = false
|
|
|
|
func wants_jab_attack() -> bool:
|
|
if jab_queued:
|
|
reset_inputs()
|
|
return true
|
|
return false
|
|
|
|
func wants_sweep_attack() -> bool:
|
|
if sweep_queued:
|
|
reset_inputs()
|
|
return true
|
|
return false
|
|
|
|
func wants_backstep() -> bool:
|
|
if backstep_queued:
|
|
reset_inputs()
|
|
return true
|
|
return false
|
|
"
|
|
|
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eqqp1"]
|
|
radius = 0.2783203
|
|
height = 2.112793
|
|
|
|
[sub_resource type="GDScript" id="GDScript_nmc1l"]
|
|
resource_name = "CameraPivot"
|
|
script/source = "extends Node3D
|
|
|
|
var input : Vector2 = Vector2.ZERO
|
|
var joystick_input : Vector2 = Vector2.ZERO
|
|
@onready var stored_rotation : Vector3 = global_rotation
|
|
|
|
func _ready():
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
|
|
func deadzone(value : float) -> float:
|
|
if abs(value) < 0.05:
|
|
return 0
|
|
else:
|
|
return value
|
|
|
|
func _unhandled_input(event : InputEvent):
|
|
if event is InputEventMouseMotion:
|
|
input = event.relative * 0.002
|
|
elif event is InputEventJoypadMotion:
|
|
match (event as InputEventJoypadMotion).axis:
|
|
JOY_AXIS_RIGHT_X:
|
|
joystick_input.x = deadzone(event.axis_value)
|
|
JOY_AXIS_RIGHT_Y:
|
|
joystick_input.y = deadzone(event.axis_value)
|
|
|
|
func _process(delta : float):
|
|
input += joystick_input * delta * 3.0
|
|
stored_rotation.y = wrapf(stored_rotation.y - input.x, 0, PI * 2.0)
|
|
stored_rotation.x = clampf(stored_rotation.x - input.y, -PI / 4.0, PI / 4.0)
|
|
global_rotation = stored_rotation
|
|
input = Vector2.ZERO
|
|
"
|
|
|
|
[sub_resource type="SphereShape3D" id="SphereShape3D_nmc1l"]
|
|
radius = 0.3
|
|
|
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f46kd"]
|
|
albedo_color = Color(0.8666667, 0.22352941, 0.41568628, 1)
|
|
|
|
[sub_resource type="BoxShape3D" id="BoxShape3D_uxov2"]
|
|
size = Vector3(0.33496094, 0.3552246, 0.26367188)
|
|
|
|
[sub_resource type="BoxShape3D" id="BoxShape3D_nmc1l"]
|
|
size = Vector3(0.33496094, 0.8294678, 0.4711914)
|
|
|
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_3rerk"]
|
|
height = 1.8466797
|
|
radius = 0.89404297
|
|
|
|
[node name="Player" unique_id=1341242765 groups=["PlayerHitbox"] instance=ExtResource("1_eqqp1")]
|
|
collision_layer = 2
|
|
collision_mask = 3
|
|
script = SubResource("GDScript_eqqp1")
|
|
|
|
[node name="PlayerBehaviours" parent="." index="0" unique_id=2061972400 instance=ExtResource("2_uxov2")]
|
|
|
|
[node name="PhysicsShape" type="CollisionShape3D" parent="." index="1" unique_id=1611683515]
|
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0563965, 0)
|
|
shape = SubResource("CapsuleShape3D_eqqp1")
|
|
debug_color = Color(0, 0.6, 0.69803923, 1)
|
|
|
|
[node name="AwarenessArea" parent="." index="2" unique_id=986494999 instance=ExtResource("4_f46kd")]
|
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0963671, 0)
|
|
target_group = "EnemyHitbox"
|
|
|
|
[node name="CameraPivot" type="Node3D" parent="." index="3" unique_id=1714065679]
|
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6702702, 0)
|
|
script = SubResource("GDScript_nmc1l")
|
|
|
|
[node name="SpringArm3D" type="SpringArm3D" parent="CameraPivot" index="0" unique_id=1656112632]
|
|
transform = Transform3D(0.98211235, 0, 0.18829599, 0, 1, 0, -0.18829599, 0, 0.98211235, -0.014201134, 0.2906257, -0.0010317713)
|
|
shape = SubResource("SphereShape3D_nmc1l")
|
|
spring_length = 4.0
|
|
|
|
[node name="Camera3D" type="Camera3D" parent="CameraPivot/SpringArm3D" index="0" unique_id=552400396]
|
|
transform = Transform3D(0.981895, -5.3638707e-09, -0.18942553, 5.529141e-09, 1, 3.4402312e-10, 0.18942553, -1.3851523e-09, 0.981895, 0, 0, 0)
|
|
current = true
|
|
fov = 52.5
|
|
|
|
[node name="Mesh" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(750883464) index="0" unique_id=233192374]
|
|
material_override = SubResource("StandardMaterial3D_f46kd")
|
|
|
|
[node name="HandR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(750883464) index="1" unique_id=385862689]
|
|
transform = Transform3D(0.015967373, -0.083946444, 0.9963424, -0.17989334, -0.98045003, -0.07972447, 0.9835564, -0.17796235, -0.030756809, 0.27221423, 0.7951686, 0.024477992)
|
|
bone_name = "hand.r"
|
|
bone_idx = 10
|
|
|
|
[node name="DamageAreaR" type="Area3D" parent="Character/Skeleton3D/HandR" index="0" unique_id=1170013417 node_paths=PackedStringArray("source")]
|
|
collision_layer = 0
|
|
collision_mask = 2
|
|
monitoring = false
|
|
monitorable = false
|
|
script = ExtResource("4_nmc1l")
|
|
source = NodePath("../../../..")
|
|
|
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Character/Skeleton3D/HandR/DamageAreaR" index="0" unique_id=580766922]
|
|
transform = Transform3D(1.0000031, -4.61936e-07, -1.6018748e-07, -3.7252903e-07, 1.0000017, -8.242205e-08, -1.8440187e-07, 3.776513e-07, 0.9999993, 9.43318e-05, 0.10188854, -0.010492876)
|
|
shape = SubResource("BoxShape3D_uxov2")
|
|
debug_color = Color(0.9966913, 0, 0.17880186, 1)
|
|
|
|
[node name="WeaponParent" type="Node3D" parent="Character/Skeleton3D/HandR" index="1" unique_id=1829622223]
|
|
unique_name_in_owner = true
|
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.7755576e-16, 0.10578142, 2.095476e-09)
|
|
script = ExtResource("5_f46kd")
|
|
damage_group = "EnemyHitbox"
|
|
deal_damage = true
|
|
|
|
[node name="HandL" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(750883464) index="2" unique_id=279793409]
|
|
transform = Transform3D(-0.039434362, 0.07924447, -0.9960749, 0.12679999, -0.9883944, -0.083653376, -0.99114394, -0.12960118, 0.028928574, -0.2710728, 0.7714727, 0.0945672)
|
|
bone_name = "hand.l"
|
|
bone_idx = 7
|
|
|
|
[node name="DamageAreaL" type="Area3D" parent="Character/Skeleton3D/HandL" index="0" unique_id=552609571 node_paths=PackedStringArray("source")]
|
|
collision_layer = 0
|
|
collision_mask = 2
|
|
monitoring = false
|
|
monitorable = false
|
|
script = ExtResource("4_nmc1l")
|
|
source = NodePath("../../../..")
|
|
|
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Character/Skeleton3D/HandL/DamageAreaL" index="0" unique_id=513165671]
|
|
transform = Transform3D(1.0000169, -1.5944242e-06, -4.04194e-07, 6.556511e-07, 1.0000216, -4.172325e-07, -2.7939663e-08, 8.046625e-07, 1.0000148, -4.8151425e-05, 0.101875424, -0.010286927)
|
|
shape = SubResource("BoxShape3D_uxov2")
|
|
debug_color = Color(0.9966913, 0, 0.17880186, 1)
|
|
|
|
[node name="LegR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(750883464) index="3" unique_id=2088257762]
|
|
transform = Transform3D(0.9947343, 0.10095803, 0.017639676, 0.10222586, -0.98967797, -0.1004331, 0.0073180734, 0.1017075, -0.9947873, 0.14436838, 0.42896914, -0.076926425)
|
|
bone_name = "leg.lower.r"
|
|
bone_idx = 14
|
|
|
|
[node name="DamageAreaLegR" type="Area3D" parent="Character/Skeleton3D/LegR" index="0" unique_id=744767490 node_paths=PackedStringArray("source")]
|
|
collision_layer = 0
|
|
collision_mask = 2
|
|
monitoring = false
|
|
monitorable = false
|
|
script = ExtResource("4_nmc1l")
|
|
source = NodePath("../../../..")
|
|
|
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Character/Skeleton3D/LegR/DamageAreaLegR" index="0" unique_id=836699763]
|
|
transform = Transform3D(1, -5.960372e-07, -1.0579633e-06, 5.960361e-07, 1, -1.0393298e-06, 1.0579639e-06, 1.0393292e-06, 1, -4.7951937e-05, 0.19483443, -0.114048116)
|
|
shape = SubResource("BoxShape3D_nmc1l")
|
|
debug_color = Color(0.9966913, 0, 0.17880186, 1)
|
|
|
|
[node name="AnimationPlayer" parent="." index="5" unique_id=1278488642]
|
|
unique_name_in_owner = true
|
|
root_motion_track = NodePath("Character/Skeleton3D:root")
|
|
|
|
[node name="Interactor" type="Area3D" parent="." index="6" unique_id=1212747319]
|
|
unique_name_in_owner = true
|
|
script = ExtResource("6_3rerk")
|
|
|
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Interactor" index="0" unique_id=978237070]
|
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.7906576, -0.5428387)
|
|
shape = SubResource("CylinderShape3D_3rerk")
|
|
debug_color = Color(0.31710953, 0.6258231, 0, 0.41960785)
|