Merge branch 'feat/inventory' into 'develop'

 Inventory, Weapons and refactoring

See merge request open-fpsz/open-fpsz!92
This commit is contained in:
anyreso 2024-05-07 14:21:10 +00:00
commit 5e85e609eb
74 changed files with 1812 additions and 3895 deletions

View file

@ -1,8 +1,10 @@
[gd_scene load_steps=8 format=3 uid="uid://blaieaqp413k7"]
[ext_resource type="Terrain3DStorage" uid="uid://dyon4xda4k40d" path="res://maps/genesis/resources/storage.res" id="1_8wr5r"]
[ext_resource type="Script" path="res://addons/terrain_3d/tools/importer.gd" id="1_60b8f"]
[sub_resource type="Terrain3DStorage" id="Terrain3DStorage_5p5ir"]
version = 0.842
[sub_resource type="Gradient" id="Gradient_5sc5a"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
@ -40,14 +42,13 @@ _shader_parameters = {
}
show_checkered = true
[sub_resource type="Terrain3DTextureList" id="Terrain3DTextureList_i35jn"]
[sub_resource type="Terrain3DTextureList" id="Terrain3DTextureList_4yf1r"]
[node name="Importer" type="Terrain3D"]
storage = ExtResource("1_8wr5r")
storage = SubResource("Terrain3DStorage_5p5ir")
material = SubResource("Terrain3DMaterial_f0cwi")
texture_list = SubResource("Terrain3DTextureList_i35jn")
texture_list = SubResource("Terrain3DTextureList_4yf1r")
script = ExtResource("1_60b8f")
height_file_name = "C:/msys64/home/osram/GODOT/develop/levels/greth_vortex/Vortex_Smooth2_2048.r16"
import_position = Vector3(-1024, 0, -1024)
r16_range = Vector2(0, 250)
r16_size = Vector2i(2048, 2048)

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://qb5sf7awdeui"]
[ext_resource type="Script" path="res://entities/components/explosive_damage_component.gd" id="1_alx3x"]
[sub_resource type="SphereShape3D" id="SphereShape3D_1htx7"]
radius = 5.0
[node name="ExplosiveDamage" type="Area3D"]
collision_mask = 13
script = ExtResource("1_alx3x")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_1htx7")
[connection signal="area_shape_entered" from="." to="." method="_on_area_shape_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View file

@ -14,26 +14,39 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ExplosiveDamageComponent extends Area3D
## Emitted when the scale tween is finished
signal finished
@export var damage : int = 35
@export var impulse_force : int = 1000
var damage_dealer : MatchParticipantComponent
var _damaged_objects : Dictionary= {
"bodies": [],
"areas": []
}
func _ready() -> void:
# this component only scans to apply explosion damage/impulse
# at the moment layers: 1 Object, 3 Damage, 4 Objective
monitorable = false
monitoring = true
collision_mask = 0b10000000_00000000_00000000_00001101
# scale explosive damage aoe
var tween : Tween = get_tree().create_tween()
tween.set_trans(Tween.TRANS_SINE)
tween.tween_property($CollisionShape3D,
"scale", Vector3.ONE, .3).from(Vector3.ZERO)
tween.tween_property($CollisionShape3D,
"scale", Vector3.ZERO, .1).from(Vector3.ONE)
tween.finished.connect(func() -> void: finished.emit(); queue_free())
func _physics_process(_delta : float) -> void:
for body in get_overlapping_bodies():
if body is RigidBody3D:
var center_of_mass_global_position : Vector3 = body.center_of_mass + body.global_position
var direction : Vector3 = ( center_of_mass_global_position - global_position).normalized()
body.apply_central_impulse(direction * impulse_force)
func _on_body_entered(body: Node3D) -> void:
if body is RigidBody3D and body not in _damaged_objects["bodies"]:
var center_of_mass_global_position : Vector3 = body.center_of_mass + body.global_position
var direction : Vector3 = ( center_of_mass_global_position - global_position).normalized()
body.apply_central_impulse(direction * impulse_force)
_damaged_objects["bodies"].append(body)
for area in get_overlapping_areas():
if area is HealthComponent and is_multiplayer_authority():
(area as HealthComponent).damage.rpc(damage, damage_dealer.player_id, damage_dealer.team_id)
set_physics_process(false)
func _on_area_shape_entered(_area_rid: RID, area: Area3D, _area_shape_index: int, _local_shape_index: int) -> void:
if area is HealthComponent and area not in _damaged_objects["areas"]:
if not is_multiplayer_authority():
return
assert(damage_dealer)
area.damage.rpc(damage, damage_dealer.player_id, damage_dealer.team_id)
_damaged_objects["areas"].append(area)

View file

@ -29,7 +29,7 @@ func _ready() -> void:
collision_layer = 0b00000000_00000000_00000000_00000100
monitoring = false
collision_mask = 0
heal_full()
call_deferred("heal_full")
@rpc("call_local", "reliable")
func damage(amount : float, damage_dealer_player_id : int, damage_dealer_team_id : int) -> void:

View file

@ -0,0 +1,74 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## This component allows its entity to interact with pickable nodes
class_name Inventory extends Node3D
const _max_items = 3
## This is the total capacity of inventory.
@export_range(0, _max_items) var capacity : int = _max_items:
set(value):
capacity = clamp(value, 1, _max_items)
@export var selected : Node3D
signal selection_changed(selected : Node3D, index : int)
func _ready() -> void:
# make sure a child is selected if any
if not selected and get_child_count() > 0:
selected = get_child(0)
# make sure this inventory is linked to its owner
if not owner.inventory:
owner.inventory = self
## This method overrides [method Node.add_child] method to make sure not to exceed the inventory capacity
func _add_child(node: Node, force_readable_name: bool = false, internal: InternalMode = InternalMode.INTERNAL_MODE_DISABLED) -> void:
if get_child_count() <= capacity:
super.add_child(node, force_readable_name, internal)
else:
push_warning("inventory is full")
## This method cycles through the items in the inventory. If an item is already
## [member selected], it hides the current item, shifts by the specified number
## of items, and shows the new selected item. If no item is selected, it selects
## the first item. If the inventory is empty, it displays a warning message.
func cycle(shift : int = 1) -> void:
var child_count : int = get_child_count()
if selected:
selected.hide()
var index : int = wrapi(selected.get_index() + shift, 0, child_count)
selected = get_child(index)
selection_changed.emit(selected, index)
selected.show()
elif child_count > 0:
selected = get_child(0)
selection_changed.emit(selected, 0)
selected.show()
else:
push_warning("inventory is empty")
## This method moves the [member selected] cursor to a specific inventory item.
func select(index : int) -> void:
if selected:
selected.hide()
selected = get_child(index)
if selected:
selection_changed.emit(selected, index)
selected.show()
else:
selected = get_child(index)
if selected:
selection_changed.emit(selected, index)
selected.show()

View file

@ -13,7 +13,7 @@ signal nickname_changed(new_nickname : String)
player_id_changed.emit(player_id)
@export var team_id : int = 1
func _ready() -> void:
func _enter_tree() -> void:
root_path = "."
replication_config = SceneReplicationConfig.new()
for prop : String in ["player_id", "team_id", "nickname"]:

View file

@ -0,0 +1,31 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ProjectileSpawner extends Node3D
@export_category("Projectile")
@export var PROJECTILE : PackedScene
@export_range(0., 1., .01) var inheritance : float = .5 # ratio
func new_projectile(
projectile_type : Object,
owner_velocity : Vector3,
shooter : MatchParticipantComponent
) -> Node3D:
return projectile_type.new_projectile(
self,
owner_velocity * inheritance,
shooter,
PROJECTILE
)

View file

@ -4,12 +4,12 @@ importer="scene"
importer_version=1
type="PackedScene"
uid="uid://chuein4frnvwt"
path="res://.godot/imported/player_mesh.glb-a0e04e00b0469c9659174448aceb10a7.scn"
path="res://.godot/imported/player_mesh.glb-8a1e1c6070971fc6184d85747185f28c.scn"
[deps]
source_file="res://entities/target_dummy/assets/player_mesh.glb"
dest_files=["res://.godot/imported/player_mesh.glb-a0e04e00b0469c9659174448aceb10a7.scn"]
source_file="res://entities/dummy_target/assets/player_mesh.glb"
dest_files=["res://.godot/imported/player_mesh.glb-8a1e1c6070971fc6184d85747185f28c.scn"]
[params]

View file

@ -0,0 +1,68 @@
[gd_scene load_steps=5 format=3 uid="uid://dpnu1lvfncx6q"]
[ext_resource type="Script" path="res://entities/dummy_target/dummy_target.gd" id="1_iup5v"]
[ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/collision_shape.tres" id="2_i5k5j"]
[ext_resource type="PackedScene" uid="uid://chuein4frnvwt" path="res://entities/dummy_target/assets/player_mesh.glb" id="4_fuync"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_b0142"]
friction = 0.5
bounce = 0.5
[node name="DummyTarget" type="RigidBody3D"]
collision_layer = 2147483649
collision_mask = 2147483649
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
mass = 75.0
physics_material_override = SubResource("PhysicsMaterial_b0142")
center_of_mass_mode = 1
center_of_mass = Vector3(0, 1, 0)
continuous_cd = true
script = ExtResource("1_iup5v")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = ExtResource("2_i5k5j")
[node name="TargetMesh" parent="." instance=ExtResource("4_fuync")]
transform = Transform3D(0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0, 0, 0)
[node name="playerrig" parent="TargetMesh" index="2"]
transform = Transform3D(2.56873e-07, 0, 1.31928, 0, 1.31928, 0, -1.31928, 0, 2.56873e-07, 0, 0, 0)
[node name="Skeleton3D" parent="TargetMesh/playerrig" index="0"]
bones/6/rotation = Quaternion(-0.605155, -0.345862, -0.356135, 0.622363)
bones/7/rotation = Quaternion(0.18188, 0.221628, -0.929157, 0.233384)
bones/8/rotation = Quaternion(0.128862, -0.709864, -0.133277, 0.679504)
bones/9/rotation = Quaternion(0.126866, -0.0346058, -0.00662176, 0.991294)
bones/11/rotation = Quaternion(-0.0630718, -0.16283, 0.0971492, 0.979832)
bones/13/rotation = Quaternion(0.0299552, -0.545663, -0.00259936, 0.837465)
bones/14/rotation = Quaternion(-0.0636278, -0.0624373, 0.0299354, 0.995569)
bones/17/rotation = Quaternion(0.0486079, -0.0407852, 0.014286, 0.997883)
bones/19/rotation = Quaternion(-0.12453, -0.526036, 0.129609, 0.831252)
bones/20/rotation = Quaternion(-0.0225172, -0.0668488, 0.0231689, 0.99724)
bones/21/rotation = Quaternion(-0.00114936, 0.0252308, -0.0174874, 0.999528)
bones/25/rotation = Quaternion(-0.608395, 0.196282, 0.258426, 0.724254)
bones/26/rotation = Quaternion(0.161981, -0.321612, 0.619315, 0.697694)
bones/27/rotation = Quaternion(0.426391, 0.0868582, 0.53013, 0.727742)
bones/28/rotation = Quaternion(-0.217102, 0.0422089, 0.0230506, 0.974963)
bones/33/rotation = Quaternion(-0.0636278, 0.0624373, -0.0299354, 0.995569)
bones/36/rotation = Quaternion(-0.4266, 0.0977703, 0.332942, 0.835226)
bones/37/rotation = Quaternion(-0.632018, -0.129105, 0.241206, 0.725055)
bones/39/rotation = Quaternion(-0.479327, 0.030236, 0.338389, 0.809212)
bones/40/rotation = Quaternion(-0.540176, -0.0581251, 0.395197, 0.740709)
bones/42/rotation = Quaternion(-0.451682, -0.0170105, 0.326969, 0.829931)
bones/43/rotation = Quaternion(-0.512965, -0.0942157, 0.391943, 0.757873)
bones/44/rotation = Quaternion(0.986515, -3.3762e-16, 1.34771e-25, 0.163672)
bones/46/rotation = Quaternion(-0.574131, 2.92207e-06, -4.58343e-06, 0.818763)
bones/49/rotation = Quaternion(0.986515, -3.3762e-16, 1.34771e-25, 0.163672)
bones/51/rotation = Quaternion(-0.574131, -2.92207e-06, 4.58343e-06, 0.818763)
[node name="AnimationPlayer" parent="TargetMesh" index="4"]
autoplay = "gunTwoHanded"
[node name="Marker3D" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
[editable path="TargetMesh"]

View file

@ -10,7 +10,7 @@ friction = 0.5
bounce = 0.5
[sub_resource type="BoxShape3D" id="BoxShape3D_fkf1k"]
size = Vector3(0.5, 2, 0.1)
size = Vector3(0.5, 2.33994, 0.5)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_lpijf"]
properties/0/path = NodePath(".:position")
@ -35,12 +35,12 @@ axis_lock_angular_z = true
mass = 40.0
physics_material_override = SubResource("PhysicsMaterial_4ymrw")
center_of_mass_mode = 1
center_of_mass = Vector3(0, 0.5, 0)
center_of_mass = Vector3(0, 1, 0)
continuous_cd = true
script = ExtResource("1_y7d3d")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.175, 0)
shape = SubResource("BoxShape3D_fkf1k")
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,148 @@
[gd_scene load_steps=23 format=3 uid="uid://cry3qxi8dxwae"]
[ext_resource type="Texture2D" uid="uid://ct1v5iadtpadm" path="res://entities/player/assets/jetpackfx/smoke_01.png" id="1_ycxvc"]
[ext_resource type="Texture2D" uid="uid://doxo4vfn0bjlp" path="res://entities/player/assets/jetpackfx/smoke_02.png" id="2_ssb7j"]
[ext_resource type="Texture2D" uid="uid://dmf12llra7aq5" path="res://entities/player/assets/jetpackfx/Particle01.png" id="3_1luuf"]
[sub_resource type="Gradient" id="Gradient_3u0pn"]
offsets = PackedFloat32Array(0, 0.872727)
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_wjoiw"]
gradient = SubResource("Gradient_3u0pn")
[sub_resource type="Curve" id="Curve_pmb0n"]
max_value = 2.0
_data = [Vector2(0, 0.197802), 0.0, 0.0, 0, 0, Vector2(1, 2), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_cj8ky"]
curve = SubResource("Curve_pmb0n")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_v556h"]
emission_shape = 1
emission_sphere_radius = 0.1
angle_min = -381.7
angle_max = 381.7
gravity = Vector3(0, -5, 0)
tangential_accel_min = -5.0
tangential_accel_max = 5.0
scale_curve = SubResource("CurveTexture_cj8ky")
color_ramp = SubResource("GradientTexture1D_wjoiw")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_27esd"]
transparency = 1
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("1_ycxvc")
billboard_mode = 1
billboard_keep_scale = true
[sub_resource type="QuadMesh" id="QuadMesh_hegkl"]
material = SubResource("StandardMaterial3D_27esd")
[sub_resource type="Gradient" id="Gradient_f4nyt"]
offsets = PackedFloat32Array(0, 0.972727)
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_ovx5q"]
gradient = SubResource("Gradient_f4nyt")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_l8e6j"]
emission_shape = 1
emission_sphere_radius = 0.1
angle_min = -381.7
angle_max = 381.7
gravity = Vector3(0, -5, 0)
tangential_accel_min = -5.0
tangential_accel_max = 5.0
scale_curve = SubResource("CurveTexture_cj8ky")
color_ramp = SubResource("GradientTexture1D_ovx5q")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bknuu"]
transparency = 1
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("2_ssb7j")
billboard_mode = 1
billboard_keep_scale = true
grow_amount = 1.506
[sub_resource type="QuadMesh" id="QuadMesh_aeure"]
material = SubResource("StandardMaterial3D_bknuu")
[sub_resource type="Gradient" id="Gradient_t1nsw"]
offsets = PackedFloat32Array(0, 0.627273, 0.927273)
colors = PackedColorArray(1, 0.858824, 0.0784314, 1, 1, 0, 0, 1, 1, 0, 0, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_x0y0j"]
gradient = SubResource("Gradient_t1nsw")
[sub_resource type="Curve" id="Curve_fkrx7"]
max_value = 2.0
_data = [Vector2(0, 0.197802), 0.0, 0.0, 0, 0, Vector2(0.594203, 0.395604), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 3
[sub_resource type="CurveTexture" id="CurveTexture_frkde"]
curve = SubResource("Curve_fkrx7")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_q1vdw"]
emission_shape = 1
emission_sphere_radius = 0.05
angle_min = -381.7
angle_max = 381.7
direction = Vector3(0, -1, 0)
spread = 25.0
initial_velocity_min = 0.5
initial_velocity_max = 1.5
gravity = Vector3(0, -5, 0)
tangential_accel_min = -5.0
tangential_accel_max = 5.0
scale_min = 0.5
scale_max = 0.75
scale_curve = SubResource("CurveTexture_frkde")
color_ramp = SubResource("GradientTexture1D_x0y0j")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2jwv2"]
render_priority = -1
transparency = 1
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("3_1luuf")
emission_enabled = true
emission = Color(1, 0.823529, 0.701961, 1)
billboard_mode = 3
billboard_keep_scale = true
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
[sub_resource type="QuadMesh" id="QuadMesh_uc7ts"]
material = SubResource("StandardMaterial3D_2jwv2")
[node name="JetpackFX" type="Node3D"]
[node name="Smoke1" type="GPUParticles3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.150648, 0)
emitting = false
lifetime = 0.5
one_shot = true
process_material = SubResource("ParticleProcessMaterial_v556h")
draw_pass_1 = SubResource("QuadMesh_hegkl")
[node name="Smoke2" type="GPUParticles3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.108846, 0)
emitting = false
lifetime = 0.5
one_shot = true
process_material = SubResource("ParticleProcessMaterial_l8e6j")
draw_pass_1 = SubResource("QuadMesh_aeure")
[node name="Fire1" type="GPUParticles3D" parent="."]
emitting = false
amount = 16
lifetime = 0.3
one_shot = true
speed_scale = 2.0
process_material = SubResource("ParticleProcessMaterial_q1vdw")
draw_pass_1 = SubResource("QuadMesh_uc7ts")

View file

@ -17,6 +17,14 @@ class_name Player extends RigidBody3D
enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
@export var iff : Control
@export var health_component : HealthComponent
@export var walkable_surface_sensor : ShapeCast3D
## The inventory component can store up to [member Inventory.slots] objects. It
## also has specific slots to hold grenades, packs and a flag.
@export var inventory : Inventory
@export var tp_mesh : Vanguard
@export_category("Parameters")
@export var ground_speed : float = 48 / 3.6 # m/s
@ -37,28 +45,23 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
@export var player_state : PlayerState = PlayerState.PLAYER_ALIVE
@onready var input : PlayerInput = $PlayerInput
@onready var camera : Camera3D = $Smoothing/SpringArm3D/Camera3D
@onready var camera : Camera3D = %Pivot/Camera3D
@onready var hud : CanvasLayer = $HUD
@onready var walkable_surface_sensor : ShapeCast3D = $WalkableSurfaceSensor
@onready var weapon : Node3D = $Smoothing/SpringArm3D/Inventory/SpaceGun
@onready var animation_player : AnimationPlayer = $AnimationPlayer
@onready var health_component : Area3D = $HealthComponent
@onready var collision_shape : CollisionShape3D = $CollisionShape3D
@onready var flag_carry_component : FlagCarryComponent = $Smoothing/SpringArm3D/FlagCarryComponent
@onready var spring_arm_height : float = $Smoothing/SpringArm3D.position.y
@onready var _original_weapon_transform : Transform3D = weapon.transform
@onready var tp_player : Vanguard = $Smoothing/ThirdPerson/PlayerMesh
@onready var jetpack_particles : Array = $Smoothing/ThirdPerson/PlayerMesh/JetpackFX.get_children()
@onready var flag_carry_component : FlagCarryComponent = %Pivot/FlagCarryComponent
@onready var jetpack_particles : Array = $Smoothing/ThirdPerson/Mesh/JetpackFX.get_children()
@onready var match_participant_component : MatchParticipantComponent = $MatchParticipantComponent
signal died(player : Player, killer_id : int)
signal energy_changed(energy : float)
static var pawn_player : Player
var g : float = ProjectSettings.get_setting("physics/3d/default_gravity") # in m/s²
var gravity : Vector3 = g * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
var _jumping : bool = false
static var pawn_player : Player
func _ready() -> void:
match_participant_component.player_id_changed.connect(_setup_pawn)
match_participant_component.player_id_changed.connect(input.update_multiplayer_authority)
@ -67,43 +70,57 @@ func _ready() -> void:
health_component.health_changed.connect(iff._on_health_changed)
health_component.health_changed.emit(health_component.health)
health_component.health_zeroed.connect(die)
inventory.selection_changed.connect(_on_inventory_selection_changed)
energy_changed.connect(hud._on_energy_changed)
input.fired_primary.connect(_fire_primary)
input.fired_primary.connect(_trigger)
input.jumped.connect(_jump)
input.throwed_flag.connect(_throw_flag)
input.MOUSE_SENSITIVITY = Settings.get_value("controls", "mouse_sensitivity")
input.inverted_y_axis = Settings.get_value("controls", "inverted_y_axis")
func _process(_delta : float) -> void:
if _is_player_dead():
iff.hide()
return
else:
iff.show()
%Pivot.global_transform.basis = Basis.from_euler(Vector3(input.camera_rotation.y, input.camera_rotation.x, 0.0))
if not _is_pawn():
tp_mesh.global_transform.basis = Basis.from_euler(Vector3(.0, input.camera_rotation.x + PI, 0.0))
func _physics_process(delta : float) -> void:
_update_jetpack_energy(delta)
func _setup_pawn(_new_player_id : int) -> void:
if _is_pawn():
camera.current = true
camera.fov = Settings.get_value("video", "fov")
pawn_player = self
# set the spring arm translation to be about head height level
$Smoothing/SpringArm3D.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
else:
# set the iff attachment translation to be about head height level
$Smoothing/ThirdPerson/IFFAttachment.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
$Smoothing/ThirdPerson.show()
%Inventory.hide()
hud.hide()
weapon.hide()
func _is_pawn() -> bool:
var game : Node3D = get_node("/root/Game")
var peer_is_pawn = multiplayer.get_unique_id() == match_participant_component.player_id
return game.mode is Singleplayer or peer_is_pawn
var peer_is_pawn : bool = multiplayer.get_unique_id() == match_participant_component.player_id
return GameManager.mode is Singleplayer or peer_is_pawn
func _fire_primary() -> void:
if _is_player_dead():
return
if not weapon.can_fire():
return
var current_weapon_transform : Transform3D = weapon.transform
weapon.transform = _original_weapon_transform
weapon.fire_primary()
weapon.transform = current_weapon_transform
# @NOTE: this method works only because `tp_mesh` duplicates weapons meshes from the inventory
func _on_inventory_selection_changed(_selected : Node3D, index : int) -> void:
# hide any visible weapon
for child in tp_mesh.hand_attachment.get_children():
child.hide()
# get corresponding selected weapon mesh for third person
var tp_weapon : Node3D = tp_mesh.hand_attachment.get_child(index)
if tp_weapon:
tp_weapon.show()
func _trigger() -> void:
if not _is_player_dead() and inventory.selected:
if inventory.selected.has_method("trigger"):
inventory.selected.trigger()
else:
push_warning("cannot trigger weapon")
func _jump() -> void:
if _is_player_dead():
@ -124,38 +141,21 @@ func _handle_aerial_control(direction : Vector3) -> void:
apply_force(direction * aerial_control_force)
func _handle_jetpack(direction : Vector3) -> void:
if input.jetting:
if energy > 0:
var up_vector : Vector3 = Vector3.UP * jetpack_vertical_force * jetpack_force_factor
var side_vector : Vector3 = direction * jetpack_horizontal_force * jetpack_force_factor
apply_force(up_vector + side_vector)
display_jetpack_particles()
if input.jetting and energy > 0:
var up_vector : Vector3 = Vector3.UP * jetpack_vertical_force * jetpack_force_factor
var side_vector : Vector3 = direction * jetpack_horizontal_force * jetpack_force_factor
apply_force(up_vector + side_vector)
display_jetpack_particles()
func _update_jetpack_energy(delta : float) -> void:
if input.jetting:
if energy > 0:
energy -= energy_drain_rate * delta
if input.jetting and energy > 0:
energy -= energy_drain_rate * delta
else:
energy += energy_charge_rate * delta
energy = clamp(energy, 0, energy_max)
energy_changed.emit(energy)
func _process(_delta : float) -> void:
if _is_player_dead():
iff.hide()
return
else:
iff.show()
if not _is_pawn():
tp_player.global_transform.basis = Basis.from_euler(Vector3(0.0, input.camera_rotation.x + PI, 0.0))
elif not %Inventory/SpaceGun/Mesh/AnimationPlayer.is_playing():
%Inventory/SpaceGun/Mesh/AnimationPlayer.play("idle")
%SpringArm3D.global_transform.basis = Basis.from_euler(Vector3(input.camera_rotation.y, input.camera_rotation.x, 0.0))
func _physics_process(delta : float) -> void:
_update_jetpack_energy(delta)
func _handle_movement() -> void:
# retrieve user's direction vector
var _input_dir : Vector2 = input.direction
@ -168,7 +168,7 @@ func _handle_movement() -> void:
return
# adjust direction based on spring arm rotation
_direction = _direction.rotated(Vector3.UP, $Smoothing/SpringArm3D.rotation.y)
_direction = _direction.rotated(Vector3.UP, %Pivot.rotation.y)
_handle_aerial_control(_direction)
_handle_jetpack(_direction)
@ -206,16 +206,16 @@ func _update_third_person_animations() -> void:
return
if _is_player_dead():
tp_player.set_ground_state(Vanguard.GroundState.GROUND_STATE_DEAD)
tp_mesh.set_ground_state(Vanguard.GroundState.GROUND_STATE_DEAD)
return
if is_on_floor():
tp_player.set_ground_state(Vanguard.GroundState.GROUND_STATE_GROUNDED)
tp_mesh.set_ground_state(Vanguard.GroundState.GROUND_STATE_GROUNDED)
else:
tp_player.set_ground_state(Vanguard.GroundState.GROUND_STATE_MID_AIR)
var local_velocity : Vector3 = (tp_player.global_basis.inverse() * linear_velocity)
tp_mesh.set_ground_state(Vanguard.GroundState.GROUND_STATE_MID_AIR)
var local_velocity : Vector3 = (tp_mesh.global_basis.inverse() * linear_velocity)
const bias : float = 1.2 # Basically match feet speed with ground speed
tp_player.set_locomotion(Vector2(local_velocity.x, local_velocity.z), bias)
tp_mesh.set_locomotion(Vector2(local_velocity.x, local_velocity.z), bias)
func _is_player_dead() -> bool:
return player_state != PlayerState.PLAYER_ALIVE

View file

@ -1,20 +1,23 @@
[gd_scene load_steps=41 format=3 uid="uid://cbhx1xme0sb7k"]
[gd_scene load_steps=45 format=3 uid="uid://cbhx1xme0sb7k"]
[ext_resource type="Script" path="res://entities/player/player.gd" id="1_mk68k"]
[ext_resource type="PackedScene" uid="uid://drbefw6akui2v" path="res://entities/player/assets/vanguard.tscn" id="2_beyex"]
[ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/collision_shape.tres" id="2_vjqny"]
[ext_resource type="PackedScene" uid="uid://bcv81ku26xo" path="res://interfaces/hud/hud.tscn" id="3_ccety"]
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://entities/weapons/space_gun/space_gun.tscn" id="4_6jh57"]
[ext_resource type="Script" path="res://entities/components/match_participant_component.gd" id="6_lrose"]
[ext_resource type="Script" path="res://entities/player/player_input.gd" id="6_ymcrr"]
[ext_resource type="PackedScene" uid="uid://dsysi2rd3bu76" path="res://interfaces/hud/iffs/iff.tscn" id="7_8hc80"]
[ext_resource type="Script" path="res://entities/components/inventory.gd" id="8_768qh"]
[ext_resource type="PackedScene" uid="uid://drbefw6akui2v" path="res://entities/player/vanguard.tscn" id="8_eiy7q"]
[ext_resource type="Script" path="res://entities/components/flag_carry_component.gd" id="8_pdfbn"]
[ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" path="res://entities/flag/assets/flag.glb" id="9_fce2y"]
[ext_resource type="Texture2D" uid="uid://ct1v5iadtpadm" path="res://entities/player/assets/jetpackfx/smoke_01.png" id="9_4pant"]
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://entities/weapons/space_gun/space_gun.tscn" id="9_achlo"]
[ext_resource type="Texture2D" uid="uid://doxo4vfn0bjlp" path="res://entities/player/assets/jetpackfx/smoke_02.png" id="10_5b1bx"]
[ext_resource type="Texture2D" uid="uid://dmf12llra7aq5" path="res://entities/player/assets/jetpackfx/Particle01.png" id="11_6ndfi"]
[ext_resource type="Script" path="res://addons/smoothing/smoothing.gd" id="11_k330l"]
[ext_resource type="Texture2D" uid="uid://ct1v5iadtpadm" path="res://entities/player/assets/jetpackfx/smoke_01.png" id="12_ypuho"]
[ext_resource type="Texture2D" uid="uid://doxo4vfn0bjlp" path="res://entities/player/assets/jetpackfx/smoke_02.png" id="13_wvbf0"]
[ext_resource type="Script" path="res://entities/components/health_component.gd" id="14_ctgxn"]
[ext_resource type="Texture2D" uid="uid://dmf12llra7aq5" path="res://entities/player/assets/jetpackfx/Particle01.png" id="14_vughy"]
[ext_resource type="PackedScene" uid="uid://b0xql5hi0b52y" path="res://entities/weapons/chaingun/chaingun.tscn" id="15_io0a3"]
[ext_resource type="PackedScene" uid="uid://cstl7yxc75572" path="res://entities/weapons/grenade_launcher/grenade_launcher.tscn" id="16_4xs2j"]
[ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" path="res://entities/flag/assets/flag.glb" id="18_7nkei"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_clur0"]
resource_local_to_scene = true
@ -29,26 +32,26 @@ resource_name = "death"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Smoothing/SpringArm3D:position")
tracks/0/path = NodePath("Pivot:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0.5, 0), Vector3(0, -0.114794, 0)]
"values": [Vector3(0, 0, 0), Vector3(-1.35254, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Smoothing/SpringArm3D:rotation")
tracks/1/path = NodePath("Pivot:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(-1.35254, 0, 0)]
"values": [Vector3(0, 0.5, 0), Vector3(0, -0.114794, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hg307"]
@ -58,16 +61,16 @@ _data = {
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rqdp6"]
properties/0/path = NodePath(".:linear_velocity")
properties/0/spawn = true
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:position")
properties/1/spawn = true
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("HealthComponent:health")
properties/2/spawn = true
properties/2/spawn = false
properties/2/replication_mode = 2
properties/3/path = NodePath(".:player_state")
properties/3/spawn = true
properties/3/spawn = false
properties/3/replication_mode = 2
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5j4ew"]
@ -84,6 +87,17 @@ properties/3/path = NodePath(".:skiing")
properties/3/spawn = false
properties/3/replication_mode = 2
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_7na0c"]
properties/0/path = NodePath("MatchParticipantComponent:player_id")
properties/0/spawn = false
properties/0/replication_mode = 2
properties/1/path = NodePath("MatchParticipantComponent:team_id")
properties/1/spawn = false
properties/1/replication_mode = 2
properties/2/path = NodePath("MatchParticipantComponent:nickname")
properties/2/spawn = false
properties/2/replication_mode = 2
[sub_resource type="Gradient" id="Gradient_3u0pn"]
offsets = PackedFloat32Array(0, 0.872727)
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
@ -113,7 +127,7 @@ color_ramp = SubResource("GradientTexture1D_wjoiw")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_27esd"]
transparency = 1
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("12_ypuho")
albedo_texture = ExtResource("9_4pant")
billboard_mode = 1
billboard_keep_scale = true
@ -141,7 +155,7 @@ color_ramp = SubResource("GradientTexture1D_ovx5q")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bknuu"]
transparency = 1
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("13_wvbf0")
albedo_texture = ExtResource("10_5b1bx")
billboard_mode = 1
billboard_keep_scale = true
grow_amount = 1.506
@ -180,7 +194,7 @@ transparency = 1
blend_mode = 1
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("14_vughy")
albedo_texture = ExtResource("11_6ndfi")
emission_enabled = true
emission = Color(1, 0.823529, 0.701961, 1)
billboard_mode = 3
@ -192,7 +206,7 @@ particles_anim_loop = false
[sub_resource type="QuadMesh" id="QuadMesh_uc7ts"]
material = SubResource("StandardMaterial3D_2jwv2")
[node name="Player" type="RigidBody3D" node_paths=PackedStringArray("iff")]
[node name="Player" type="RigidBody3D" node_paths=PackedStringArray("iff", "health_component", "walkable_surface_sensor", "inventory", "tp_mesh") groups=["Player"]]
collision_mask = 2147483649
axis_lock_angular_x = true
axis_lock_angular_y = true
@ -203,17 +217,12 @@ can_sleep = false
continuous_cd = true
script = ExtResource("1_mk68k")
iff = NodePath("Smoothing/ThirdPerson/IFF")
health_component = NodePath("HealthComponent")
walkable_surface_sensor = NodePath("WalkableSurfaceSensor")
inventory = NodePath("Pivot/Inventory")
tp_mesh = NodePath("Smoothing/ThirdPerson/Mesh")
jump_height = 1.5
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = ExtResource("2_vjqny")
[node name="WalkableSurfaceSensor" type="ShapeCast3D" parent="."]
transform = Transform3D(1.05, 0, 0, 0, 1.05, 0, 0, 0, 1.05, 0, -0.85, 0)
shape = SubResource("SphereShape3D_hwe6e")
target_position = Vector3(0, 0, 0)
collision_mask = 2147483648
[node name="Sensor" type="Area3D" parent="."]
collision_layer = 0
collision_mask = 8
@ -229,6 +238,15 @@ match_participant_component = NodePath("../MatchParticipantComponent")
[node name="CollisionShape3D" type="CollisionShape3D" parent="HealthComponent"]
shape = ExtResource("2_vjqny")
[node name="WalkableSurfaceSensor" type="ShapeCast3D" parent="."]
transform = Transform3D(1.05, 0, 0, 0, 1.05, 0, 0, 0, 1.05, 0, -0.85, 0)
shape = SubResource("SphereShape3D_hwe6e")
target_position = Vector3(0, 0, 0)
collision_mask = 2147483648
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = ExtResource("2_vjqny")
[node name="HUD" parent="." instance=ExtResource("3_ccety")]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -247,73 +265,175 @@ replication_config = SubResource("SceneReplicationConfig_5j4ew")
script = ExtResource("6_ymcrr")
[node name="MatchParticipantComponent" type="MultiplayerSynchronizer" parent="."]
root_path = NodePath(".")
replication_config = SubResource("SceneReplicationConfig_7na0c")
script = ExtResource("6_lrose")
[node name="Pivot" type="Node3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
[node name="Camera3D" type="Camera3D" parent="Pivot"]
fov = 90.0
near = 0.1
[node name="Inventory" type="Node3D" parent="Pivot"]
unique_name_in_owner = true
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.15, -0.2, -0.45)
script = ExtResource("8_768qh")
[node name="SpaceGun" parent="Pivot/Inventory" instance=ExtResource("9_achlo")]
[node name="ChainGun" parent="Pivot/Inventory" instance=ExtResource("15_io0a3")]
transform = Transform3D(0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0.1)
visible = false
[node name="GrenadeLauncher" parent="Pivot/Inventory" instance=ExtResource("16_4xs2j")]
visible = false
[node name="FlagCarryComponent" type="Node3D" parent="Pivot" node_paths=PackedStringArray("sensor", "carrier")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
visible = false
script = ExtResource("8_pdfbn")
sensor = NodePath("../../Sensor")
carrier = NodePath("../..")
[node name="FlagMesh" parent="Pivot/FlagCarryComponent" instance=ExtResource("18_7nkei")]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1.559e-08, -0.462981, -0.178329)
[node name="SpineIKTarget" type="Marker3D" parent="Pivot"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
[node name="Smoothing" type="Node3D" parent="."]
script = ExtResource("11_k330l")
target = NodePath("..")
flags = 3
[node name="SpringArm3D" type="SpringArm3D" parent="Smoothing"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
spring_length = 0.0
[node name="Camera3D" type="Camera3D" parent="Smoothing/SpringArm3D"]
fov = 90.0
near = 0.1
[node name="Inventory" type="Node3D" parent="Smoothing/SpringArm3D"]
unique_name_in_owner = true
[node name="SpaceGun" parent="Smoothing/SpringArm3D/Inventory" node_paths=PackedStringArray("holder") instance=ExtResource("4_6jh57")]
transform = Transform3D(-1, 0, 2.53518e-06, 0, 1, 0, -2.53518e-06, 0, -1, 0.15, -0.3, -0.55)
holder = NodePath("../../../../MatchParticipantComponent")
[node name="SpineIKTarget" type="Node3D" parent="Smoothing/SpringArm3D"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
[node name="FlagCarryComponent" type="Node3D" parent="Smoothing/SpringArm3D" node_paths=PackedStringArray("sensor", "carrier")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
visible = false
script = ExtResource("8_pdfbn")
sensor = NodePath("../../../Sensor")
carrier = NodePath("../../..")
[node name="FlagMesh" parent="Smoothing/SpringArm3D/FlagCarryComponent" instance=ExtResource("9_fce2y")]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1.559e-08, -0.462981, -0.178329)
[node name="ThirdPerson" type="Node3D" parent="Smoothing"]
visible = false
[node name="PlayerMesh" parent="Smoothing/ThirdPerson" node_paths=PackedStringArray("spine_ik_target_attachment") instance=ExtResource("2_beyex")]
[node name="Mesh" parent="Smoothing/ThirdPerson" node_paths=PackedStringArray("spine_ik_target_attachment") instance=ExtResource("8_eiy7q")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
spine_ik_target_attachment = NodePath("../../SpringArm3D/SpineIKTarget")
spine_ik_target_attachment = NodePath("../../../Pivot/SpineIKTarget")
[node name="JetpackFX" type="Node3D" parent="Smoothing/ThirdPerson/PlayerMesh"]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.187666, 0.238235, -0.147731)
[node name="Skeleton3D" parent="Smoothing/ThirdPerson/Mesh/Node" index="0"]
bones/0/position = Vector3(-0.0048219, 0.946668, 0.00678214)
bones/0/rotation = Quaternion(-0.0341192, -0.409249, -0.0209221, 0.911545)
bones/2/rotation = Quaternion(-0.00595832, -0.0014545, 0.0101407, 0.99993)
bones/4/rotation = Quaternion(0.0691268, 0.00227406, 0.0147948, 0.997496)
bones/6/rotation = Quaternion(0.160951, 0.00623474, 0.0096637, 0.986895)
bones/8/rotation = Quaternion(0.675761, -0.399581, 0.409695, 0.464577)
bones/10/rotation = Quaternion(0.212344, -0.0870591, -0.287653, 0.929831)
bones/12/rotation = Quaternion(0.0811501, 0.206806, -0.754068, 0.618084)
bones/14/position = Vector3(-0.074525, 0.220475, 0.075475)
bones/14/rotation = Quaternion(0.00943715, 0.0971687, -0.145046, 0.984597)
bones/20/rotation = Quaternion(-0.123455, 0.0248346, 0.23344, 0.964183)
bones/24/rotation = Quaternion(0.0450683, -0.000817796, 0.0508488, 0.997689)
bones/26/rotation = Quaternion(0.100545, -1.16532e-07, 0.00792588, 0.994901)
bones/28/rotation = Quaternion(0.288532, -1.83796e-07, 0.0227447, 0.9572)
bones/32/rotation = Quaternion(0.00674081, -0.0316083, 0.105474, 0.993897)
bones/34/rotation = Quaternion(0.780684, 4.23384e-08, 0.0615407, 0.621889)
bones/36/rotation = Quaternion(0.580978, -1.56224e-07, 0.0457976, 0.81263)
bones/40/rotation = Quaternion(0.0913739, 0.113691, 0.100265, 0.984211)
bones/42/rotation = Quaternion(0.836841, 4.40546e-07, 0.0659669, 0.543457)
bones/44/rotation = Quaternion(0.633142, 6.48257e-09, 0.04991, 0.772425)
bones/50/rotation = Quaternion(0.729888, -4.88266e-08, 0.0575362, 0.681141)
bones/52/rotation = Quaternion(0.624011, -9.63141e-08, 0.04919, 0.779865)
bones/56/rotation = Quaternion(-0.0254885, 0.0439755, -0.00910637, 0.998666)
bones/58/rotation = Quaternion(-0.0119802, 0.289956, -0.0527053, 0.955513)
bones/62/rotation = Quaternion(0.689943, 0.375565, -0.410267, 0.463261)
bones/64/rotation = Quaternion(0.337746, -0.290519, 0.159479, 0.880961)
bones/66/position = Vector3(0.055475, 0.231475, 0.000474975)
bones/66/rotation = Quaternion(0.540371, -0.580679, 0.406779, 0.453147)
bones/68/position = Vector3(-0.014525, 0.270475, -0.054525)
bones/68/rotation = Quaternion(0.0150529, -0.289001, 0.0720108, 0.954498)
bones/70/rotation = Quaternion(0.155965, 0.0109114, -0.00107202, 0.987702)
bones/72/rotation = Quaternion(0.563923, 4.19095e-08, -0.0577906, 0.823803)
bones/74/rotation = Quaternion(0.285209, 0.0197164, -0.0936782, 0.953673)
bones/78/rotation = Quaternion(0.057484, -0.0698946, -0.0100642, 0.995846)
bones/80/rotation = Quaternion(0.433127, 5.44824e-08, -0.0443866, 0.900239)
bones/82/rotation = Quaternion(0.274138, -1.97906e-08, -0.0280937, 0.96128)
bones/86/rotation = Quaternion(0.244152, 0.0521336, 0.176446, 0.952123)
bones/88/rotation = Quaternion(0.0146391, -1.48637e-07, -0.121951, 0.992428)
bones/90/rotation = Quaternion(-0.147655, -0.0737763, 0.197847, 0.966236)
bones/94/rotation = Quaternion(0.180682, 0.0832945, -0.00387314, 0.980001)
bones/96/rotation = Quaternion(0.245651, -6.35919e-08, -0.0251742, 0.969032)
bones/98/rotation = Quaternion(0.246432, 7.6252e-08, -0.0252543, 0.968831)
bones/102/rotation = Quaternion(0.179829, 0.0890365, -0.000307644, 0.97966)
bones/104/rotation = Quaternion(0.388149, 1.28057e-07, -0.0397774, 0.920738)
bones/106/rotation = Quaternion(0.372324, -1.37021e-07, -0.0381557, 0.927318)
bones/110/rotation = Quaternion(-0.167577, 0.223934, 0.958827, 0.0492099)
bones/112/rotation = Quaternion(-0.466474, -0.0088339, -0.0232928, 0.884184)
bones/114/rotation = Quaternion(0.575696, 0.0793941, -0.0250592, 0.813414)
bones/116/rotation = Quaternion(0.355062, 0.0493655, 0.0246355, 0.933213)
bones/120/rotation = Quaternion(0.115252, 0.282473, 0.945749, -0.111737)
bones/122/rotation = Quaternion(-0.494906, -0.0647935, 0.0183973, 0.866332)
bones/124/rotation = Quaternion(0.417677, -0.0431149, 0.00625689, 0.90755)
bones/126/rotation = Quaternion(0.397818, -0.0427722, -0.00601182, 0.916447)
[node name="Smoke1" type="GPUParticles3D" parent="Smoothing/ThirdPerson/PlayerMesh/JetpackFX"]
[node name="HandAttachment" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D" index="0"]
transform = Transform3D(-0.152214, 0.0548832, 0.986823, 0.933991, 0.334546, 0.125459, -0.323252, 0.94078, -0.102183, -0.191759, 1.06335, 0.0698007)
[node name="grip" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="main" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="sides" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="BarrelsInner" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="BarrelsOuter" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Base" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Grip" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Barrels" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun" index="3"]
transform = Transform3D(-1, 0, 8.9407e-08, 8.47504e-08, 0, 1, 0, 1, -3.72529e-09, 0, -2.38419e-07, -0.55315)
[node name="barrel" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
[node name="grip" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.082471, -0.0653242)
[node name="main" parent="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
[node name="JetpackFX" type="Node3D" parent="Smoothing/ThirdPerson/Mesh"]
transform = Transform3D(0.467164, -0.312366, -0.827155, -0.12476, 0.902867, -0.41142, 0.875325, 0.295397, 0.382816, 0.143745, 0.353192, -0.140279)
[node name="Smoke1" type="GPUParticles3D" parent="Smoothing/ThirdPerson/Mesh/JetpackFX"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.150648, 0)
emitting = false
lifetime = 0.5
one_shot = true
fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_v556h")
draw_pass_1 = SubResource("QuadMesh_hegkl")
[node name="Smoke2" type="GPUParticles3D" parent="Smoothing/ThirdPerson/PlayerMesh/JetpackFX"]
[node name="Smoke2" type="GPUParticles3D" parent="Smoothing/ThirdPerson/Mesh/JetpackFX"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.108846, 0)
emitting = false
lifetime = 0.5
one_shot = true
fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_l8e6j")
draw_pass_1 = SubResource("QuadMesh_aeure")
[node name="Fire1" type="GPUParticles3D" parent="Smoothing/ThirdPerson/PlayerMesh/JetpackFX"]
[node name="Fire1" type="GPUParticles3D" parent="Smoothing/ThirdPerson/Mesh/JetpackFX"]
emitting = false
amount = 16
lifetime = 0.3
one_shot = true
fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_q1vdw")
draw_pass_1 = SubResource("QuadMesh_uc7ts")
@ -324,3 +444,11 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.27457, 0)
player = NodePath("../../..")
match_participant_component = NodePath("../../../MatchParticipantComponent")
attach_point = NodePath("../IFFAttachment")
[connection signal="energy_changed" from="." to="HUD" method="_on_player_energy_changed"]
[editable path="Smoothing/ThirdPerson/Mesh"]
[editable path="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/SpaceGun"]
[editable path="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/SpaceGun/Mesh"]
[editable path="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/ChainGun"]
[editable path="Smoothing/ThirdPerson/Mesh/Node/Skeleton3D/HandAttachment/GrenadeLauncher"]

View file

@ -18,21 +18,16 @@ class_name PlayerInput extends MultiplayerSynchronizer
@export var skiing : bool = false
@export var direction : Vector2 = Vector2.ZERO
@export var camera_rotation : Vector2
@export var MOUSE_SENSITIVITY : float = .6
@export var inverted_y_axis : bool = false
signal jumped
signal fired_primary
signal throwed_flag
func _ready() -> void:
func _enter_tree() -> void:
update_multiplayer_authority(0)
func update_multiplayer_authority(player_id : int) -> void:
set_multiplayer_authority(player_id)
var has_authority : bool = is_multiplayer_authority()
set_process(has_authority)
set_process_unhandled_input(has_authority)
func _unhandled_input(event: InputEvent) -> void:
var mouse_mode : Input.MouseMode = Input.get_mouse_mode()
@ -41,37 +36,55 @@ func _unhandled_input(event: InputEvent) -> void:
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
# retrieve mouse position relative to last frame
_update_camera(event.relative)
if is_multiplayer_authority():
if event is InputEventMouseButton:
# @NOTE: there could be a control setting for direction
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
_cycle.rpc(1)
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
_cycle.rpc(-1)
if event is InputEventKey:
match event.keycode:
KEY_1: _select.rpc(0)
KEY_2: _select.rpc(1)
KEY_3: _select.rpc(2)
direction = Input.get_vector("left", "right", "forward", "backward")
if Input.is_action_just_pressed("jump_and_jet"):
_jump.rpc()
if Input.is_action_just_pressed("fire_primary"):
_fire_primary.rpc()
if Input.is_action_just_pressed("throw_flag"):
_throw_flag.rpc()
jetting = Input.is_action_pressed("jump_and_jet")
skiing = Input.is_action_pressed("ski")
func _update_camera(relative_motion : Vector2) -> void:
# reverse y axis
if inverted_y_axis:
if Settings.get_value("controls", "inverted_y_axis"):
relative_motion.y *= -1.0
# clamp vertical rotation (head motion)
camera_rotation.y -= relative_motion.y * MOUSE_SENSITIVITY / 100
camera_rotation.y -= relative_motion.y * Settings.get_value("controls", "mouse_sensitivity") / 100
camera_rotation.y = clamp(camera_rotation.y, deg_to_rad(-90.0), deg_to_rad(90.0))
# wrap horizontal rotation (to prevent accumulation)
camera_rotation.x -= relative_motion.x * MOUSE_SENSITIVITY / 100
camera_rotation.x -= relative_motion.x * Settings.get_value("controls", "mouse_sensitivity") / 100
camera_rotation.x = wrapf(camera_rotation.x, deg_to_rad(0.0), deg_to_rad(360.0))
func _process(_delta : float) -> void:
direction = Input.get_vector("left", "right", "forward", "backward")
if Input.is_action_just_pressed("jump_and_jet"):
_jump.rpc()
if Input.is_action_just_pressed("fire_primary"):
_fire_primary.rpc()
if Input.is_action_just_pressed("throw_flag"):
_throw_flag.rpc()
jetting = Input.is_action_pressed("jump_and_jet")
skiing = Input.is_action_pressed("ski")
@rpc("call_local")
@rpc("call_local", "reliable")
func _jump() -> void:
jumped.emit()
@rpc("call_local")
@rpc("call_local", "reliable")
func _fire_primary() -> void:
fired_primary.emit()
@rpc("call_local")
@rpc("call_local", "reliable")
func _cycle(shift : int) -> void:
%Inventory.cycle(shift)
@rpc("call_local", "reliable")
func _select(index : int) -> void:
%Inventory.select(index)
@rpc("call_local", "reliable")
func _throw_flag() -> void:
throwed_flag.emit()

View file

@ -1,6 +1,7 @@
class_name Vanguard extends Node
@export var spine_ik_target_attachment : Node3D
@export var spine_ik_target_attachment : Marker3D
@export var hand_attachment : BoneAttachment3D
@onready var animation_tree : AnimationTree = $AnimationTree
@onready var spine_ik : SkeletonIK3D = $Node/Skeleton3D/SpineIK

View file

@ -0,0 +1,230 @@
[gd_scene load_steps=20 format=3 uid="uid://drbefw6akui2v"]
[ext_resource type="PackedScene" uid="uid://4naw661fqmjg" path="res://entities/player/assets/vanguard.glb" id="1_d2ik6"]
[ext_resource type="Script" path="res://entities/player/vanguard.gd" id="2_c22xr"]
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://entities/weapons/space_gun/space_gun.tscn" id="3_cfjna"]
[ext_resource type="PackedScene" uid="uid://b0xql5hi0b52y" path="res://entities/weapons/chaingun/chaingun.tscn" id="4_0qqks"]
[ext_resource type="PackedScene" uid="uid://cstl7yxc75572" path="res://entities/weapons/grenade_launcher/grenade_launcher.tscn" id="5_p6n3u"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lw37l"]
animation = &"death"
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_ncg4i"]
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_ugw6e"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dyfkg"]
animation = &"jump"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_x158p"]
animation = &"jump_up"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_l3m4j"]
animation = &"run_right"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_a1e0h"]
animation = &"run_backward"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_sjcrs"]
animation = &"run_left"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_vf3mp"]
animation = &"run_forward"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_n6f67"]
animation = &"idle"
[sub_resource type="AnimationNodeBlendSpace2D" id="AnimationNodeBlendSpace2D_oxci6"]
blend_point_0/node = SubResource("AnimationNodeAnimation_l3m4j")
blend_point_0/pos = Vector2(-1, 0)
blend_point_1/node = SubResource("AnimationNodeAnimation_a1e0h")
blend_point_1/pos = Vector2(0, -1)
blend_point_2/node = SubResource("AnimationNodeAnimation_sjcrs")
blend_point_2/pos = Vector2(1, 0)
blend_point_3/node = SubResource("AnimationNodeAnimation_vf3mp")
blend_point_3/pos = Vector2(0, 1)
blend_point_4/node = SubResource("AnimationNodeAnimation_n6f67")
blend_point_4/pos = Vector2(0, 0)
sync = true
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_ax6or"]
[sub_resource type="AnimationNodeTransition" id="AnimationNodeTransition_c220w"]
xfade_time = 0.1
input_0/name = "grounded"
input_0/auto_advance = false
input_0/reset = true
input_1/name = "mid_air"
input_1/auto_advance = false
input_1/reset = true
input_2/name = "dead"
input_2/auto_advance = false
input_2/reset = true
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_1ok7t"]
nodes/Death/node = SubResource("AnimationNodeOneShot_ncg4i")
nodes/Death/position = Vector2(880, 500)
"nodes/Death 2/node" = SubResource("AnimationNodeAnimation_lw37l")
"nodes/Death 2/position" = Vector2(674.414, 529.106)
nodes/GroundSpeed/node = SubResource("AnimationNodeTimeScale_ugw6e")
nodes/GroundSpeed/position = Vector2(920, 20)
nodes/JumpLoop/node = SubResource("AnimationNodeAnimation_dyfkg")
nodes/JumpLoop/position = Vector2(500, 400)
nodes/JumpUp/node = SubResource("AnimationNodeAnimation_x158p")
nodes/JumpUp/position = Vector2(500, 240)
nodes/Locomotion/node = SubResource("AnimationNodeBlendSpace2D_oxci6")
nodes/Locomotion/position = Vector2(680, 40)
nodes/OneShot/node = SubResource("AnimationNodeOneShot_ax6or")
nodes/OneShot/position = Vector2(880, 240)
nodes/Transition/node = SubResource("AnimationNodeTransition_c220w")
nodes/Transition/position = Vector2(1200, 80)
nodes/output/position = Vector2(1400, 0)
node_connections = [&"Death", 0, &"Death 2", &"GroundSpeed", 0, &"Locomotion", &"OneShot", 0, &"JumpUp", &"OneShot", 1, &"JumpLoop", &"Transition", 0, &"GroundSpeed", &"Transition", 1, &"OneShot", &"Transition", 2, &"Death", &"output", 0, &"Transition"]
[node name="Vanguard" node_paths=PackedStringArray("spine_ik_target_attachment", "hand_attachment") instance=ExtResource("1_d2ik6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.61612e-06, 0.000176162, 0.000105232)
script = ExtResource("2_c22xr")
spine_ik_target_attachment = NodePath("SpineIKTarget")
hand_attachment = NodePath("Node/Skeleton3D/HandAttachment")
[node name="Skeleton3D" parent="Node" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00146306, 0, -0.00178421)
bones/0/position = Vector3(-0.0048219, 0.946668, 0.00678214)
bones/0/rotation = Quaternion(-0.0341192, -0.409249, -0.0209221, 0.911545)
bones/2/rotation = Quaternion(-0.00595832, -0.0014545, 0.0101407, 0.99993)
bones/4/rotation = Quaternion(0.0691268, 0.00227406, 0.0147948, 0.997496)
bones/6/rotation = Quaternion(0.160951, 0.00623474, 0.0096637, 0.986895)
bones/8/rotation = Quaternion(0.675761, -0.399581, 0.409695, 0.464577)
bones/10/rotation = Quaternion(0.212344, -0.0870591, -0.287653, 0.929831)
bones/12/rotation = Quaternion(0.0811501, 0.206806, -0.754068, 0.618084)
bones/14/rotation = Quaternion(0.00943715, 0.0971687, -0.145046, 0.984597)
bones/20/rotation = Quaternion(-0.123455, 0.0248346, 0.23344, 0.964183)
bones/24/rotation = Quaternion(0.0450683, -0.000817796, 0.0508488, 0.997689)
bones/26/rotation = Quaternion(0.100545, -1.16532e-07, 0.00792588, 0.994901)
bones/28/rotation = Quaternion(0.288532, -1.83796e-07, 0.0227447, 0.9572)
bones/32/rotation = Quaternion(0.00674081, -0.0316083, 0.105474, 0.993897)
bones/34/rotation = Quaternion(0.780684, 4.23384e-08, 0.0615407, 0.621889)
bones/36/rotation = Quaternion(0.580978, -1.56224e-07, 0.0457976, 0.81263)
bones/40/rotation = Quaternion(0.0913739, 0.113691, 0.100265, 0.984211)
bones/42/rotation = Quaternion(0.836841, 4.40546e-07, 0.0659669, 0.543457)
bones/44/rotation = Quaternion(0.633142, 6.48257e-09, 0.04991, 0.772425)
bones/50/rotation = Quaternion(0.729888, -4.88266e-08, 0.0575362, 0.681141)
bones/52/rotation = Quaternion(0.624011, -9.63141e-08, 0.04919, 0.779865)
bones/54/rotation = Quaternion(-1.18924e-16, 2.81961e-21, -4.50738e-10, 1)
bones/56/rotation = Quaternion(-0.0254885, 0.0439755, -0.00910637, 0.998666)
bones/58/rotation = Quaternion(-0.0119802, 0.289956, -0.0527053, 0.955513)
bones/62/rotation = Quaternion(0.689943, 0.375565, -0.410267, 0.463261)
bones/64/rotation = Quaternion(0.337746, -0.290519, 0.159479, 0.880961)
bones/66/rotation = Quaternion(0.540371, -0.580679, 0.406779, 0.453147)
bones/68/position = Vector3(0.000474975, 0.275475, 0.035475)
bones/68/rotation = Quaternion(0.0150529, -0.289001, 0.0720108, 0.954498)
bones/70/rotation = Quaternion(0.155965, 0.0109114, -0.00107202, 0.987702)
bones/72/rotation = Quaternion(0.563923, 4.19095e-08, -0.0577906, 0.823803)
bones/74/rotation = Quaternion(0.285209, 0.0197164, -0.0936782, 0.953673)
bones/78/rotation = Quaternion(0.057484, -0.0698946, -0.0100642, 0.995846)
bones/80/rotation = Quaternion(0.433127, 5.44824e-08, -0.0443866, 0.900239)
bones/82/rotation = Quaternion(0.274138, -1.97906e-08, -0.0280937, 0.96128)
bones/86/rotation = Quaternion(0.244152, 0.0521336, 0.176446, 0.952123)
bones/88/rotation = Quaternion(0.0146391, -1.48637e-07, -0.121951, 0.992428)
bones/90/rotation = Quaternion(-0.147655, -0.0737763, 0.197847, 0.966236)
bones/94/rotation = Quaternion(0.180682, 0.0832945, -0.00387314, 0.980001)
bones/96/rotation = Quaternion(0.245651, -6.35919e-08, -0.0251742, 0.969032)
bones/98/rotation = Quaternion(0.246432, 7.6252e-08, -0.0252543, 0.968831)
bones/100/rotation = Quaternion(-6.44756e-14, -1.4372e-11, -3.12192e-10, 1)
bones/102/rotation = Quaternion(0.179829, 0.0890365, -0.000307644, 0.97966)
bones/104/rotation = Quaternion(0.388149, 1.28057e-07, -0.0397774, 0.920738)
bones/106/rotation = Quaternion(0.372324, -1.37021e-07, -0.0381557, 0.927318)
bones/110/rotation = Quaternion(-0.167577, 0.223934, 0.958827, 0.0492099)
bones/112/rotation = Quaternion(-0.466474, -0.0088339, -0.0232928, 0.884184)
bones/114/rotation = Quaternion(0.575696, 0.0793941, -0.0250592, 0.813414)
bones/116/rotation = Quaternion(0.355062, 0.0493655, 0.0246355, 0.933213)
bones/120/rotation = Quaternion(0.115252, 0.282473, 0.945749, -0.111737)
bones/122/rotation = Quaternion(-0.494906, -0.0647935, 0.0183973, 0.866332)
bones/124/rotation = Quaternion(0.417677, -0.0431149, 0.00625689, 0.90755)
bones/126/rotation = Quaternion(0.397818, -0.0427722, -0.00601182, 0.916447)
[node name="HandAttachment" type="BoneAttachment3D" parent="Node/Skeleton3D" index="0"]
transform = Transform3D(-0.152214, 0.0548832, 0.986823, 0.933991, 0.334546, 0.125459, -0.323252, 0.94078, -0.102183, -0.261612, 1.14328, 0.0896011)
bone_name = "mixamorigRightHand"
bone_idx = 14
[node name="SpaceGun" parent="Node/Skeleton3D/HandAttachment" index="0" instance=ExtResource("3_cfjna")]
transform = Transform3D(-0.170368, 0.95438, -0.24522, -0.0464896, 0.240797, 0.969461, 0.984283, 0.176566, 0.00334465, 0.0409744, 0.381457, 0.0445086)
script = null
[node name="grip" parent="Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="main" parent="Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="sides" parent="Node/Skeleton3D/HandAttachment/SpaceGun/Mesh/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="ChainGun" parent="Node/Skeleton3D/HandAttachment" index="1" instance=ExtResource("4_0qqks")]
transform = Transform3D(-0.0425921, 0.235665, -0.0717487, -0.0116224, 0.0708099, 0.23948, 0.246071, 0.0441354, -0.00110777, -0.00204359, 0.464663, 0.0585247)
visible = false
script = null
[node name="BarrelsInner" parent="Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="BarrelsOuter" parent="Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Base" parent="Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Grip" parent="Node/Skeleton3D/HandAttachment/ChainGun/Armature/Skeleton3D" index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Barrels" parent="Node/Skeleton3D/HandAttachment/ChainGun" index="3"]
transform = Transform3D(-1, -7.45058e-09, 8.70787e-08, 8.56817e-08, 3.72529e-09, 1, 0, 1, 0, 0, -1.19209e-07, -0.55315)
[node name="GrenadeLauncher" parent="Node/Skeleton3D/HandAttachment" index="2" instance=ExtResource("5_p6n3u")]
transform = Transform3D(-0.170368, 0.95438, -0.24522, -0.0464896, 0.240797, 0.969461, 0.984283, 0.176566, 0.00334465, 0.0409744, 0.381457, 0.0445086)
visible = false
script = null
[node name="barrel" parent="Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
[node name="grip" parent="Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.082471, -0.0653242)
[node name="main" parent="Node/Skeleton3D/HandAttachment/GrenadeLauncher/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
[node name="SpineIK" type="SkeletonIK3D" parent="Node/Skeleton3D" index="3"]
process_priority = 1
root_bone = &"mixamorigHips"
tip_bone = &"mixamorigSpine2"
override_tip_basis = false
target_node = NodePath("../../../SpineIKTarget")
[node name="AnimationPlayer" parent="." index="1"]
autoplay = "idle"
playback_default_blend_time = 0.2
[node name="AnimationTree" type="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeBlendTree_1ok7t")
anim_player = NodePath("../AnimationPlayer")
parameters/Death/active = false
parameters/Death/internal_active = false
parameters/Death/request = 0
parameters/GroundSpeed/scale = 0.0
parameters/Locomotion/blend_position = Vector2(0.0952381, 0.280822)
parameters/OneShot/active = false
parameters/OneShot/internal_active = false
parameters/OneShot/request = 0
parameters/Transition/current_state = "grounded"
parameters/Transition/transition_request = ""
parameters/Transition/current_index = 0
[node name="SpineIKTarget" type="Marker3D" parent="." index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.479842, 0)
[editable path="Node/Skeleton3D/HandAttachment/SpaceGun"]
[editable path="Node/Skeleton3D/HandAttachment/SpaceGun/Mesh"]
[editable path="Node/Skeleton3D/HandAttachment/ChainGun"]
[editable path="Node/Skeleton3D/HandAttachment/GrenadeLauncher"]

View file

@ -1,22 +0,0 @@
[gd_scene load_steps=4 format=3 uid="uid://dpnu1lvfncx6q"]
[ext_resource type="Script" path="res://entities/target_dummy/target_dummy.gd" id="1_iup5v"]
[ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/collision_shape.tres" id="2_i5k5j"]
[ext_resource type="PackedScene" uid="uid://chuein4frnvwt" path="res://entities/target_dummy/assets/player_mesh.glb" id="4_fuync"]
[node name="DummyTarget" type="RigidBody3D"]
collision_layer = 2147483649
collision_mask = 2147483649
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
mass = 75.0
continuous_cd = true
script = ExtResource("1_iup5v")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = ExtResource("2_i5k5j")
[node name="TargetMesh" parent="." instance=ExtResource("4_fuync")]
transform = Transform3D(0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0, 0, 0)

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cumv8wij5uufk"
path="res://.godot/imported/chaingun.glb-16cef2303c058492773f5f33b566245e.scn"
[deps]
source_file="res://entities/weapons/chaingun/assets/chaingun.glb"
dest_files=["res://.godot/imported/chaingun.glb-16cef2303c058492773f5f33b566245e.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

View file

@ -0,0 +1,17 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://dkyb51bkvgamw"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_343cd"]
load_path = "res://.godot/imported/Flare00.png-75515c1e8df86aba86a9e55bb8ca7901.s3tc.ctex"
[resource]
transparency = 1
cull_mode = 2
shading_mode = 0
vertex_color_use_as_albedo = true
albedo_color = Color(0.860369, 0.860369, 0.860369, 1)
albedo_texture = SubResource("CompressedTexture2D_343cd")
billboard_mode = 3
billboard_keep_scale = true
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false

View file

@ -0,0 +1,27 @@
[gd_resource type="ParticleProcessMaterial" load_steps=5 format=3 uid="uid://drjuqikmi1uth"]
[sub_resource type="Gradient" id="Gradient_4bco7"]
offsets = PackedFloat32Array(0.00806452, 1)
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_gtja2"]
gradient = SubResource("Gradient_4bco7")
[sub_resource type="Curve" id="Curve_d0rrq"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.980263, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_5xpsc"]
curve = SubResource("Curve_d0rrq")
[resource]
lifetime_randomness = 1.0
emission_shape = 1
emission_sphere_radius = 0.3
spread = 180.0
gravity = Vector3(0, -2, 0)
scale_min = 0.75
scale_max = 1.5
scale_curve = SubResource("CurveTexture_5xpsc")
color = Color(5, 2, 1, 1)
color_ramp = SubResource("GradientTexture1D_gtja2")

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bf7v57agnxtcp"
path="res://.godot/imported/tracer.glb-49c5c0f531fb5d373b2273b8c055ba52.scn"
[deps]
source_file="res://entities/weapons/chaingun/assets/tracer.glb"
dest_files=["res://.godot/imported/tracer.glb-49c5c0f531fb5d373b2273b8c055ba52.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

View file

@ -0,0 +1,44 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ChainGun extends Node3D
@export_range(0, 250) var ammo : int = 250
@export var fire_rate : float = .1 # seconds
@export var reload_time : float = 0. # seconds
@export_category("Animations")
@export var anim_player : AnimationPlayer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func trigger() -> void:
# play the fire animation
anim_player.play("fire")
# init projectile
var projectile : Node3D = $ProjectileSpawner.new_projectile(
ChainGunProjectile,
owner.linear_velocity,
owner.match_participant_component
)
# add to owner of player for now
GameManager.mode.add_child(projectile)
projectile.shape_cast.add_exception(owner)
func _on_visibility_changed() -> void:
if self.visible:
anim_player.play("equip")
#self.sounds.play("equip")

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=5 format=3 uid="uid://b0xql5hi0b52y"]
[ext_resource type="PackedScene" uid="uid://cumv8wij5uufk" path="res://entities/weapons/chaingun/assets/chaingun.glb" id="1_d8tdv"]
[ext_resource type="Script" path="res://entities/weapons/chaingun/chaingun.gd" id="2_qsqeh"]
[ext_resource type="Script" path="res://entities/components/projectile_spawner.gd" id="3_knyrc"]
[ext_resource type="PackedScene" uid="uid://b0sfwgilfbpx5" path="res://entities/weapons/chaingun/projectile.tscn" id="4_p63ts"]
[node name="ChainGun" node_paths=PackedStringArray("anim_player") instance=ExtResource("1_d8tdv")]
script = ExtResource("2_qsqeh")
anim_player = NodePath("AnimationPlayer")
[node name="ProjectileSpawner" type="Marker3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.124544, 0.476417)
script = ExtResource("3_knyrc")
PROJECTILE = ExtResource("4_p63ts")
inheritance = 1.0
[node name="Skeleton3D" parent="Armature" index="0"]
bones/1/rotation = Quaternion(3.09086e-08, 0.707107, 0.707107, 3.09086e-08)
bones/2/rotation = Quaternion(3.09086e-08, 0.707107, 0.707107, -3.09086e-08)
bones/3/rotation = Quaternion(3.09086e-08, 0.707107, 0.707107, -3.09086e-08)
[node name="BarrelsInner" parent="Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="BarrelsOuter" parent="Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Base" parent="Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="Grip" parent="Armature/Skeleton3D" index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.692504, 1.30946)
[node name="AnimationPlayer" parent="." index="2"]
autoplay = "idle"
[node name="Barrels" type="BoneAttachment3D" parent="." index="3"]
transform = Transform3D(-1, 0, 8.74227e-08, 8.74227e-08, 0, 1, 0, 1, 0, -2.32831e-10, 0.692504, 0.756307)
bone_name = "barrels"
bone_idx = 1
use_external_skeleton = true
external_skeleton = NodePath("../Armature/Skeleton3D")
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]

View file

@ -0,0 +1,55 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ChainGunProjectile extends Node3D
@export var speed : float = 180. # m/s
@export var lifespan : float = .5 # in seconds
@export var build_up_time : float = .6 # seconds
var shooter : MatchParticipantComponent
var velocity : Vector3 = Vector3.ZERO
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$Timer.wait_time = lifespan
func _on_timer_timeout() -> void:
queue_free()
func _physics_process(delta : float) -> void:
global_position += velocity * delta
if shape_cast.is_colliding():
for collision_id in shape_cast.get_collision_count():
var collider : Object = shape_cast.get_collider(collision_id)
if collider is Player:
if is_multiplayer_authority():
assert(shooter)
collider.health_component.damage.rpc(18, shooter.player_id, shooter.team_id)
queue_free()
## This method is a parameterized constructor for the [ChainGunProjectile] scene of the [ChainGun]
static func new_projectile(
origin : Marker3D,
inherited_velocity : Vector3,
_shooter : MatchParticipantComponent,
scene : PackedScene
) -> ChainGunProjectile:
var projectile : ChainGunProjectile = scene.instantiate()
projectile.shooter = _shooter
projectile.transform = origin.global_transform
projectile.velocity = origin.global_basis.z.normalized() * projectile.speed + inherited_velocity
return projectile

View file

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=3 uid="uid://b0sfwgilfbpx5"]
[ext_resource type="PackedScene" uid="uid://bf7v57agnxtcp" path="res://entities/weapons/chaingun/assets/tracer.glb" id="1_p7mmn"]
[ext_resource type="Script" path="res://entities/weapons/chaingun/projectile.gd" id="2_jjfwk"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dbodg"]
radius = 0.2
height = 2.5
[node name="ChainGunProjectile" instance=ExtResource("1_p7mmn")]
script = ExtResource("2_jjfwk")
[node name="ShapeCast3D" type="ShapeCast3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 4.29628)
shape = SubResource("CapsuleShape3D_dbodg")
target_position = Vector3(0, -3, 0)
collision_mask = 2147483653
[node name="tracerinner" parent="." index="1"]
transform = Transform3D(0.0505494, 0, 0, 0, 0.0505494, 0, 0, 0, 0.0505494, 0, 0, 2.49628)
[node name="Timer" type="Timer" parent="." index="2"]
autostart = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View file

@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bbp260t2qivxk"
path="res://.godot/imported/grenade_launcher.glb-a6b40e53ec47b6674efe99dda067cfdf.scn"
[deps]
source_file="res://entities/weapons/grenade_launcher/assets/models/grenade_launcher.glb"
dest_files=["res://.godot/imported/grenade_launcher.glb-a6b40e53ec47b6674efe99dda067cfdf.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

View file

@ -0,0 +1,13 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bbqjhgs44rnss"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_uiuwk"]
load_path = "res://.godot/imported/Flare00.png-75515c1e8df86aba86a9e55bb8ca7901.s3tc.ctex"
[resource]
transparency = 1
cull_mode = 2
shading_mode = 0
vertex_color_use_as_albedo = true
albedo_color = Color(0.860369, 0.860369, 0.860369, 1)
albedo_texture = SubResource("CompressedTexture2D_uiuwk")
billboard_keep_scale = true

View file

@ -0,0 +1,27 @@
[gd_resource type="ParticleProcessMaterial" load_steps=5 format=3 uid="uid://c78xg30ynapmt"]
[sub_resource type="Gradient" id="Gradient_q75yo"]
offsets = PackedFloat32Array(0.00806452, 1)
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_gt2l8"]
gradient = SubResource("Gradient_q75yo")
[sub_resource type="Curve" id="Curve_jt11q"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.980263, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_nb67t"]
curve = SubResource("Curve_jt11q")
[resource]
lifetime_randomness = 1.0
emission_shape = 1
emission_sphere_radius = 0.3
spread = 180.0
gravity = Vector3(0, -2, 0)
scale_min = 0.75
scale_max = 1.5
scale_curve = SubResource("CurveTexture_nb67t")
color = Color(5, 2, 1, 1)
color_ramp = SubResource("GradientTexture1D_gt2l8")

View file

@ -0,0 +1,15 @@
[gd_resource type="ParticleProcessMaterial" load_steps=3 format=3 uid="uid://cykwajkj5aaqx"]
[sub_resource type="Curve" id="Curve_2oi53"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_ml1t5"]
curve = SubResource("Curve_2oi53")
[resource]
gravity = Vector3(0, 0, 0)
scale_min = 4.0
scale_max = 4.0
scale_curve = SubResource("CurveTexture_ml1t5")
color = Color(2.5, 1, 0.5, 1)

View file

@ -0,0 +1,31 @@
[gd_resource type="ParticleProcessMaterial" load_steps=5 format=3 uid="uid://v7s5w3uw4hmb"]
[sub_resource type="Curve" id="Curve_ei0ls"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="Curve" id="Curve_q68ud"]
max_value = 5.0
_data = [Vector2(0, 5), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="Curve" id="Curve_1s1qr"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveXYZTexture" id="CurveXYZTexture_eoauk"]
curve_x = SubResource("Curve_ei0ls")
curve_y = SubResource("Curve_q68ud")
curve_z = SubResource("Curve_1s1qr")
[resource]
particle_flag_align_y = true
emission_shape = 1
emission_sphere_radius = 0.2
spread = 180.0
initial_velocity_min = 20.0
initial_velocity_max = 25.0
gravity = Vector3(0, -19.6, 0)
scale_min = 0.2
scale_curve = SubResource("CurveXYZTexture_eoauk")
color = Color(5, 2, 1, 1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://df1te2nwndirs"
path="res://.godot/imported/Circle00.png-abb71ef9f4ed014b9c4576f63601e876.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/weapons/grenade_launcher/assets/textures/Circle00.png"
dest_files=["res://.godot/imported/Circle00.png-abb71ef9f4ed014b9c4576f63601e876.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chchhrpwmho2c"
path.s3tc="res://.godot/imported/Flare00.png-75515c1e8df86aba86a9e55bb8ca7901.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://entities/weapons/grenade_launcher/assets/textures/Flare00.png"
dest_files=["res://.godot/imported/Flare00.png-75515c1e8df86aba86a9e55bb8ca7901.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bt14yn3vctir"
path="res://.godot/imported/Flare01.png-4090d4d992d997383a0becd557b43261.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/weapons/grenade_launcher/assets/textures/Flare01.png"
dest_files=["res://.godot/imported/Flare01.png-4090d4d992d997383a0becd557b43261.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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=1

View file

@ -0,0 +1,38 @@
class_name GrenadeLauncherProjectileExplosion extends Node3D
## The component responsible for explosion damages
@export var explosive_damage : ExplosiveDamageComponent
## The component responsible for owner identification
var shooter : MatchParticipantComponent:
set(value):
shooter = value
explosive_damage.damage_dealer = value
## This is increment by 1 when a particle emitter is finished
var _finished_count : int = 0
## Called when the node enters the scene tree for the first time.
func _ready() -> void:
for child in $Particles.get_children():
child.emitting = true
child.finished.connect(_on_finished)
## This is called by children particle nodes to destruct our
## [GrenadeLauncherProjectileExplosion] once all emitters are finished
func _on_finished() -> void:
_finished_count += 1
if _finished_count == $Particles.get_child_count():
queue_free()
## This method is a static factory constructor for the
## [GrenadeLauncherProjectileExplosion] scene of the [GrenadeLauncherProjectile].
static func new_explosion(
origin : Vector3,
_shooter : MatchParticipantComponent,
scene : PackedScene
) -> GrenadeLauncherProjectileExplosion:
var explosion : GrenadeLauncherProjectileExplosion = scene.instantiate()
explosion.position = origin
explosion.shooter = _shooter
return explosion

View file

@ -0,0 +1,56 @@
[gd_scene load_steps=9 format=3 uid="uid://bb43ae1f5j8lw"]
[ext_resource type="Script" path="res://entities/weapons/grenade_launcher/explosion.gd" id="1_xb4jo"]
[ext_resource type="PackedScene" uid="uid://qb5sf7awdeui" path="res://entities/components/explosive_damage.tscn" id="2_rq8du"]
[ext_resource type="Material" uid="uid://v7s5w3uw4hmb" path="res://entities/weapons/grenade_launcher/assets/resources/particle_process_material_sparks.tres" id="3_4u6ue"]
[ext_resource type="Material" uid="uid://bbqjhgs44rnss" path="res://entities/weapons/grenade_launcher/assets/resources/material_flare.tres" id="4_634rq"]
[ext_resource type="Material" uid="uid://cykwajkj5aaqx" path="res://entities/weapons/grenade_launcher/assets/resources/particle_process_material_flash.tres" id="5_mntrp"]
[ext_resource type="Material" uid="uid://c78xg30ynapmt" path="res://entities/weapons/grenade_launcher/assets/resources/particle_process_material_fire.tres" id="6_s25g3"]
[sub_resource type="QuadMesh" id="QuadMesh_wt5ts"]
material = ExtResource("4_634rq")
[sub_resource type="QuadMesh" id="QuadMesh_mv2qw"]
material = ExtResource("4_634rq")
[node name="GrenadeLauncherProjectileExplosion" type="Node3D" node_paths=PackedStringArray("explosive_damage")]
script = ExtResource("1_xb4jo")
explosive_damage = NodePath("ExplosiveDamage")
[node name="ExplosiveDamage" parent="." instance=ExtResource("2_rq8du")]
[node name="Particles" type="Node3D" parent="."]
[node name="Sparks" type="GPUParticles3D" parent="Particles"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00311279, 0.0152655, -0.000196457)
emitting = false
amount = 20
lifetime = 0.3
one_shot = true
explosiveness = 1.0
fixed_fps = 60
process_material = ExtResource("3_4u6ue")
draw_pass_1 = SubResource("QuadMesh_wt5ts")
[node name="Flash" type="GPUParticles3D" parent="Particles"]
emitting = false
amount = 1
lifetime = 0.1
one_shot = true
explosiveness = 1.0
fixed_fps = 60
process_material = ExtResource("5_mntrp")
draw_pass_1 = SubResource("QuadMesh_mv2qw")
[node name="Fire" type="GPUParticles3D" parent="Particles"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00311279, 0.0152655, -0.000196457)
emitting = false
amount = 13
lifetime = 0.55
one_shot = true
explosiveness = 1.0
fixed_fps = 60
process_material = ExtResource("6_s25g3")
draw_pass_1 = SubResource("QuadMesh_wt5ts")
[editable path="ExplosiveDamage"]

View file

@ -0,0 +1,29 @@
class_name GrenadeLauncher extends Node3D
@export_range(0, 24) var ammo : int = 24
@export var fire_rate : float = 1. # seconds
@export var reload_time : float = 1. # seconds
@export_category("Animations")
@export var anim_player : AnimationPlayer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func trigger() -> void:
# play the fire animation
anim_player.play("fire")
# init projectile
var projectile : Node3D = $ProjectileSpawner.new_projectile(
GrenadeLauncherProjectile,
owner.linear_velocity,
owner.match_participant_component
)
# add to owner of player for now
GameManager.mode.add_child(projectile)
func _on_visibility_changed() -> void:
if self.visible:
anim_player.play("equip")
#self.sounds.play("equip")

View file

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=3 uid="uid://cstl7yxc75572"]
[ext_resource type="PackedScene" uid="uid://bbp260t2qivxk" path="res://entities/weapons/grenade_launcher/assets/models/grenade_launcher.glb" id="1_keuur"]
[ext_resource type="Script" path="res://entities/weapons/grenade_launcher/grenade_launcher.gd" id="2_38xn3"]
[ext_resource type="PackedScene" uid="uid://dak767xehqa6x" path="res://entities/weapons/grenade_launcher/projectile.tscn" id="3_rg5nk"]
[ext_resource type="Script" path="res://entities/components/projectile_spawner.gd" id="4_5h5sw"]
[node name="GrenadeLauncher" node_paths=PackedStringArray("anim_player") instance=ExtResource("1_keuur")]
script = ExtResource("2_38xn3")
anim_player = NodePath("AnimationPlayer")
[node name="ProjectileSpawner" type="Node3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1)
script = ExtResource("4_5h5sw")
PROJECTILE = ExtResource("3_rg5nk")
inheritance = 0.75
[node name="barrel" parent="Armature/Skeleton3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
[node name="grip" parent="Armature/Skeleton3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.082471, -0.0653242)
[node name="main" parent="Armature/Skeleton3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.19209e-07, 0)
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]

View file

@ -0,0 +1,57 @@
# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name GrenadeLauncherProjectile extends RigidBody3D
@export_category("Parameters")
@export var EXPLOSION : PackedScene
@export var collider : CollisionShape3D
@export var speed : float = 44. # m/s
@export var lifespan : float = 1.6 # in seconds
var shooter : MatchParticipantComponent
var pending_explosion : bool = false
## Called when the node enters the scene tree for the first time.
func _ready() -> void:
$Timer.wait_time = lifespan
$Timer.start()
## This method enable collision signals to be emitted when the lifespan timer
## is finished.
func _on_timer_timeout() -> void:
max_contacts_reported = 1
set_contact_monitor(true)
## This method is responsible for spawning the projectile explosion and freeing
## it when a collision is detected once the lifespan timer is finished.
func _on_body_entered(_body : Node) -> void:
var explosion : GrenadeLauncherProjectileExplosion = \
GrenadeLauncherProjectileExplosion.new_explosion(position, shooter, EXPLOSION)
add_sibling(explosion)
queue_free()
## This method is a static factory constructor for the [GrenadeLauncherProjectile]
## scene of the [GrenadeLauncher].
static func new_projectile(
origin : Node3D,
inherited_velocity : Vector3,
_shooter : MatchParticipantComponent,
scene : PackedScene
) -> GrenadeLauncherProjectile:
var projectile : GrenadeLauncherProjectile = scene.instantiate()
projectile.shooter = _shooter
projectile.transform = origin.global_transform
projectile.linear_velocity = origin.global_basis.z.normalized() * projectile.speed + inherited_velocity
return projectile

View file

@ -0,0 +1,46 @@
[gd_scene load_steps=7 format=3 uid="uid://dak767xehqa6x"]
[ext_resource type="Script" path="res://entities/weapons/grenade_launcher/projectile.gd" id="1_i8v2u"]
[ext_resource type="PackedScene" uid="uid://bb43ae1f5j8lw" path="res://entities/weapons/grenade_launcher/explosion.tscn" id="2_cxty7"]
[ext_resource type="Script" path="res://addons/smoothing/smoothing.gd" id="3_wyge0"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_r263x"]
rough = true
bounce = 0.5
[sub_resource type="SphereShape3D" id="SphereShape3D_kipwv"]
radius = 0.062
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_miu4v"]
albedo_color = Color(0.2, 0.2, 0.2, 1)
[node name="GrenadeLauncherProjectile" type="RigidBody3D" node_paths=PackedStringArray("collider")]
collision_layer = 2147483648
collision_mask = 2147483648
mass = 5.0
physics_material_override = SubResource("PhysicsMaterial_r263x")
continuous_cd = true
script = ExtResource("1_i8v2u")
EXPLOSION = ExtResource("2_cxty7")
collider = NodePath("CollisionShape3D")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_kipwv")
[node name="Timer" type="Timer" parent="."]
one_shot = true
[node name="Smoothing" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.000792712, 0, -0.000432983)
script = ExtResource("3_wyge0")
flags = 3
[node name="Mesh" type="CSGSphere3D" parent="Smoothing"]
radius = 0.062
radial_segments = 24
rings = 12
material = SubResource("StandardMaterial3D_miu4v")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="body_shape_entered" from="." to="." method="_on_body_shape_entered"]
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View file

@ -12,7 +12,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name Projectile extends Node3D
class_name SpaceGunProjectile extends Node3D
@export_category("Parameters")
@export var EXPLOSION : PackedScene
@ -28,7 +28,6 @@ var velocity : Vector3 = Vector3.ZERO
var shooter : MatchParticipantComponent
func _ready() -> void:
assert(shooter)
var lifespan_timer : Timer = Timer.new()
lifespan_timer.wait_time = lifespan
lifespan_timer.one_shot = true
@ -45,12 +44,9 @@ func _ready() -> void:
func self_destruct() -> void:
explode(position)
func explode(spawn_location : Vector3) -> void:
var spawned_explosion : Node = EXPLOSION.instantiate()
spawned_explosion.position = spawn_location
spawned_explosion.shooter = shooter
game.add_child(spawned_explosion)
func explode(spawn_position : Vector3) -> void:
game.add_child(SpaceGunProjectileExplosion.new_explosion(spawn_position, shooter, EXPLOSION))
queue_free()
func _physics_process(delta : float) -> void:
@ -61,5 +57,18 @@ func _physics_process(delta : float) -> void:
var contact_point : Vector3 = shape_cast.collision_result[0].point
explode(contact_point)
## This method is a parameterized constructor for the [SpaceGunProjectile] scene of the [SpaceGun]
static func new_projectile(
origin : Marker3D,
inherited_velocity : Vector3,
_shooter : MatchParticipantComponent,
scene : PackedScene
) -> SpaceGunProjectile:
var projectile : SpaceGunProjectile = scene.instantiate()
projectile.shooter = _shooter
projectile.transform = origin.global_transform
projectile.velocity = origin.global_basis.z.normalized() * projectile.speed + inherited_velocity
return projectile
func _enable_trail() -> void:
projectile_trail._trail_enabled = true

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://dn1tcakam5egs"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile.gd" id="1_4j1dp"]
[ext_resource type="PackedScene" uid="uid://8atq41j7wd55" path="res://entities/weapons/space_gun/projectile_explosion.tscn" id="2_llml6"]
[ext_resource type="PackedScene" path="res://entities/weapons/space_gun/projectile_explosion.tscn" id="2_llml6"]
[ext_resource type="Script" path="res://addons/smoothing/smoothing.gd" id="3_dmi64"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile_trail.gd" id="3_ygqbh"]

View file

@ -12,16 +12,27 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends Node3D
class_name SpaceGunProjectileExplosion extends Node3D
var shooter : MatchParticipantComponent
@export var explosive_damage : ExplosiveDamageComponent
@onready var fire : GPUParticles3D = $Fire
@onready var explosive_damage : ExplosiveDamageComponent = $ExplosiveDamageComponent
var explosion_effect_pending : bool = false
var shooter : MatchParticipantComponent:
set(value):
shooter = value
assert(explosive_damage)
explosive_damage.damage_dealer = value
func _ready() -> void:
assert(shooter)
explosive_damage.damage_dealer = shooter
fire.emitting = true
fire.finished.connect(func() -> void: queue_free())
## This method is a parameterized constructor for the [SpaceGunProjectileExplosion] scene of the [SpaceGunProjectile]
static func new_explosion(spawn_position : Vector3, _shooter : MatchParticipantComponent, scene : PackedScene) -> SpaceGunProjectileExplosion:
var explosion : SpaceGunProjectileExplosion = scene.instantiate()
explosion.shooter = _shooter
explosion.position = spawn_position
return explosion

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=9 format=3 uid="uid://8atq41j7wd55"]
[gd_scene load_steps=8 format=3 uid="uid://8atq41j7wd55"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile_explosion.gd" id="1_fp5td"]
[ext_resource type="Script" path="res://entities/components/explosive_damage_component.gd" id="2_28ymv"]
[ext_resource type="PackedScene" uid="uid://qb5sf7awdeui" path="res://entities/components/explosive_damage.tscn" id="2_js0ht"]
[sub_resource type="Curve" id="Curve_rg204"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
@ -25,12 +25,9 @@ emission_energy_multiplier = 4.0
[sub_resource type="SphereMesh" id="SphereMesh_k3pnh"]
material = SubResource("StandardMaterial3D_wpu51")
[sub_resource type="SphereShape3D" id="SphereShape3D_nj68w"]
margin = 0.05
radius = 5.0
[node name="ProjectileExplosion" type="Node3D"]
[node name="ProjectileExplosion" type="Node3D" node_paths=PackedStringArray("explosive_damage")]
script = ExtResource("1_fp5td")
explosive_damage = NodePath("ExplosiveDamage")
[node name="Fire" type="GPUParticles3D" parent="."]
emitting = false
@ -42,8 +39,6 @@ fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_3mf41")
draw_pass_1 = SubResource("SphereMesh_k3pnh")
[node name="ExplosiveDamageComponent" type="Area3D" parent="."]
script = ExtResource("2_28ymv")
[node name="ExplosiveDamage" parent="." instance=ExtResource("2_js0ht")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="ExplosiveDamageComponent"]
shape = SubResource("SphereShape3D_nj68w")
[editable path="ExplosiveDamage"]

View file

@ -12,45 +12,40 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
extends Node3D
class_name SpaceGun
class_name SpaceGun extends Node3D
@export var PROJECTILE : PackedScene
@export var holder : MatchParticipantComponent
@onready var nozzle : Node3D = $Nozzle
@onready var inventory : Node3D = get_parent()
@export var fire_rate : float = 1. # seconds
@export var reload_time : float = 1. # seconds
@export var anim_player : AnimationPlayer
enum WeaponState { WEAPON_READY, WEAPON_RELOADING }
var weapon_state : WeaponState = WeaponState.WEAPON_READY
const inheritance : float = .5 # ratio
const reload_time : float = 1. # seconds
var state : WeaponState = WeaponState.WEAPON_READY
func can_fire() -> bool:
return weapon_state == WeaponState.WEAPON_READY
return state == WeaponState.WEAPON_READY
func fire_primary() -> void:
func trigger() -> void:
# check permission
if not can_fire():
return
# init projectile
var projectile : Node = PROJECTILE.instantiate()
# configure projectile
projectile.shooter = holder
projectile.transform = nozzle.global_transform
projectile.velocity = nozzle.global_basis.z.normalized() * projectile.speed
var inheritance_factor : float = clamp(inheritance, 0., 1.)
projectile.velocity += (inventory.owner.linear_velocity * inheritance_factor)
# play the fire animation
$Mesh/AnimationPlayer.play("fire")
# add projectile as sibling of the owner
inventory.owner.add_sibling(projectile)
anim_player.play("fire")
var projectile : Node3D = $ProjectileSpawner.new_projectile(
SpaceGunProjectile,
owner.linear_velocity,
owner.match_participant_component
)
# add to owner of player for now
GameManager.mode.add_child(projectile)
# ensure projectile does not collide with owner
var collider : ShapeCast3D = projectile.shape_cast
collider.add_exception(inventory.owner)
collider.add_exception(owner)
# update states
weapon_state = WeaponState.WEAPON_RELOADING
state = WeaponState.WEAPON_RELOADING
await get_tree().create_timer(reload_time).timeout
weapon_state = WeaponState.WEAPON_READY
state = WeaponState.WEAPON_READY
func _on_visibility_changed() -> void:
if self.visible:
anim_player.play("equip")
#self.sounds.play("equip")

View file

@ -1,16 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://c8co0qa2omjmh"]
[gd_scene load_steps=5 format=3 uid="uid://c8co0qa2omjmh"]
[ext_resource type="Script" path="res://entities/weapons/space_gun/space_gun.gd" id="1_6sm4s"]
[ext_resource type="PackedScene" uid="uid://dn1tcakam5egs" path="res://entities/weapons/space_gun/projectile.tscn" id="2_wvneg"]
[ext_resource type="PackedScene" uid="uid://bjcn37ops3bro" path="res://entities/weapons/space_gun/assets/disclauncher.glb" id="3_5k2xm"]
[ext_resource type="Script" path="res://entities/components/projectile_spawner.gd" id="3_ihk6g"]
[node name="SpaceGun" type="Node3D"]
[node name="SpaceGun" type="Node3D" node_paths=PackedStringArray("anim_player")]
script = ExtResource("1_6sm4s")
anim_player = NodePath("Mesh/AnimationPlayer")
[node name="ProjectileSpawner" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.27)
script = ExtResource("3_ihk6g")
PROJECTILE = ExtResource("2_wvneg")
[node name="Mesh" parent="." instance=ExtResource("3_5k2xm")]
[node name="Skeleton3D" parent="Mesh/Armature" index="0"]
bones/0/rotation = Quaternion(0.707107, -5.33851e-08, -5.33851e-08, 0.707107)
bones/0/scale = Vector3(1, 1, 1)
bones/1/rotation = Quaternion(-0.707107, 5.33851e-08, 5.33851e-08, 0.707107)
bones/1/scale = Vector3(1, 1, 1)
@ -20,15 +27,17 @@ bones/3/rotation = Quaternion(-0.707107, 5.33851e-08, 5.33851e-08, 0.707107)
bones/3/scale = Vector3(1, 1, 1)
[node name="grip" parent="Mesh/Armature/Skeleton3D" index="0"]
transform = Transform3D(1, -4.26326e-14, -2.13163e-14, 2.84217e-14, 1, -3.57628e-07, 3.2684e-14, 3.57628e-07, 1, -1.42109e-14, -2.98023e-07, 2.38419e-07)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="main" parent="Mesh/Armature/Skeleton3D" index="1"]
transform = Transform3D(1, -4.26326e-14, -2.13163e-14, 2.84217e-14, 1, -3.57628e-07, 3.2684e-14, 3.57628e-07, 1, -1.42109e-14, -2.98023e-07, 2.38419e-07)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="sides" parent="Mesh/Armature/Skeleton3D" index="2"]
transform = Transform3D(1, -4.26326e-14, -2.13163e-14, 2.84217e-14, 1, -3.57628e-07, 3.2684e-14, 3.57628e-07, 1, -1.42109e-14, -2.98023e-07, 2.38419e-07)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84217e-14, 1.19209e-07, 2.38419e-07)
[node name="Nozzle" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.27)
[node name="AnimationPlayer" parent="Mesh" index="1"]
autoplay = "idle"
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[editable path="Mesh"]

View file

@ -31,14 +31,14 @@ func _ready() -> void:
func _update_energy_bar(energy : float) -> void:
_energy_bar.value = energy
func _on_energy_changed(new_energy : float) -> void:
_update_energy_bar(new_energy)
func _update_health_bar(health : float) -> void:
_health_bar.value = health
func _on_health_changed(new_health : float) -> void:
_update_health_bar(new_health)
func _on_player_energy_changed(new_energy : float) -> void:
_update_energy_bar(new_energy)
"
[sub_resource type="GDScript" id="GDScript_w8l21"]

View file

@ -1,8 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://ma1if3sjox6i"]
[gd_scene load_steps=5 format=3 uid="uid://dr8salxjlpsba"]
[ext_resource type="PackedScene" uid="uid://boviiugcnfyrj" path="res://modes/singleplayer/demo.tscn" id="1_50a80"]
[ext_resource type="PackedScene" uid="uid://bjctlqvs33nqy" path="res://interfaces/menus/boot/boot.tscn" id="1_acy5o"]
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer/multiplayer.tscn" id="2_g8xeb"]
[ext_resource type="PackedScene" uid="uid://boviiugcnfyrj" path="res://modes/singleplayer/demo.tscn" id="1_vgk6g"]
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer/multiplayer.tscn" id="2_iumx3"]
[ext_resource type="PackedScene" uid="uid://bjctlqvs33nqy" path="res://interfaces/menus/boot/boot.tscn" id="3_s8c8j"]
[sub_resource type="GDScript" id="GDScript_e61dq"]
script/source = "# This file is part of open-fpsz.
@ -25,22 +25,11 @@ class_name Game extends Node3D
@export var SINGLEPLAYER : PackedScene
@export var MULTIPLAYER : PackedScene
var mode : Node:
set(new_mode):
# clean up previous mode
if mode != null:
mode.queue_free()
# keep reference to new mode
mode = new_mode
# setup new mode
if new_mode != null:
add_child(new_mode)
func _ready() -> void:
# only run server in headless
if DisplayServer.get_name() == \"headless\":
mode = MULTIPLAYER.instantiate()
mode.start_server(9000, MapsManager.maps[MapsManager._rng.randi_range(0, len(MapsManager.maps) - 1)])
GameManager.mode = MULTIPLAYER.instantiate()
GameManager.mode.start_server(9000, MapsManager.maps[MapsManager._rng.randi_range(0, len(MapsManager.maps) - 1)])
return
# connect boot menu signals
$BootMenu.start_demo.connect(_start_demo)
@ -52,12 +41,12 @@ func _ready() -> void:
func _unhandled_input(event : InputEvent) -> void:
if event.is_action_pressed(\"exit\"):
if mode is Multiplayer:
if GameManager.mode is Multiplayer:
$BootMenu._on_multiplayer_pressed()
else:
$BootMenu._on_main_menu_pressed()
# reset game mode and get back to main menu
mode = null
GameManager.mode = null
if DisplayServer.get_name() != \"headless\":
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
return
@ -77,27 +66,27 @@ func _unhandled_input(event : InputEvent) -> void:
func _start_demo() -> void:
mode = SINGLEPLAYER.instantiate()
GameManager.mode = SINGLEPLAYER.instantiate()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
$BootMenu.hide()
func _start_server(port : int, nickname : String) -> void:
mode = MULTIPLAYER.instantiate()
mode.start_server(port, MapsManager.maps[$BootMenu/MultiplayerPanelContainer.map_selector.selected], nickname)
GameManager.mode = MULTIPLAYER.instantiate()
GameManager.mode.start_server(port, MapsManager.maps[$BootMenu/MultiplayerPanelContainer.map_selector.selected], nickname)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
$BootMenu.hide()
func _join_server(host : String, port : int, nickname : String) -> void:
mode = MULTIPLAYER.instantiate()
mode.connected_to_server.connect($BootMenu/MultiplayerPanelContainer._on_connected_to_server)
mode.connection_failed.connect($BootMenu/MultiplayerPanelContainer._on_connection_failed)
mode.join_server(host, port, nickname)
GameManager.mode = MULTIPLAYER.instantiate()
GameManager.mode.connected_to_server.connect($BootMenu/MultiplayerPanelContainer._on_connected_to_server)
GameManager.mode.connection_failed.connect($BootMenu/MultiplayerPanelContainer._on_connection_failed)
GameManager.mode.join_server(host, port, nickname)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
"
[node name="Game" type="Node3D"]
script = SubResource("GDScript_e61dq")
SINGLEPLAYER = ExtResource("1_50a80")
MULTIPLAYER = ExtResource("2_g8xeb")
SINGLEPLAYER = ExtResource("1_vgk6g")
MULTIPLAYER = ExtResource("2_iumx3")
[node name="BootMenu" parent="." instance=ExtResource("1_acy5o")]
[node name="BootMenu" parent="." instance=ExtResource("3_s8c8j")]

View file

@ -1,15 +1,15 @@
[gd_scene load_steps=6 format=3 uid="uid://btlkog4b87p4x"]
[ext_resource type="Terrain3DStorage" uid="uid://wgmg245njt8e" path="res://maps/desert/resources/storage.res" id="1_7nbyj"]
[ext_resource type="Terrain3DMaterial" uid="uid://c3isipd4wqxpk" path="res://maps/desert/resources/material.tres" id="2_psdr0"]
[ext_resource type="Terrain3DTextureList" uid="uid://d1j24k8sq8qpj" path="res://maps/desert/resources/textures.tres" id="3_aowug"]
[ext_resource type="Environment" uid="uid://nw62ce5cglvs" path="res://maps/desert/resources/env.tres" id="5_4l4vc"]
[ext_resource type="PackedScene" uid="uid://brux62vritay" path="res://entities/buildings/flag_stand.tscn" id="5_5n76t"]
[ext_resource type="Terrain3DStorage" uid="uid://wgmg245njt8e" path="res://maps/desert/resources/storage.res" id="1_lmk23"]
[ext_resource type="Terrain3DMaterial" uid="uid://c3isipd4wqxpk" path="res://maps/desert/resources/material.tres" id="2_n44fh"]
[ext_resource type="Terrain3DTextureList" uid="uid://d1j24k8sq8qpj" path="res://maps/desert/resources/textures.tres" id="3_w1yus"]
[ext_resource type="Environment" uid="uid://nw62ce5cglvs" path="res://maps/desert/resources/env.tres" id="4_m7p64"]
[ext_resource type="PackedScene" uid="uid://brux62vritay" path="res://entities/buildings/flag_stand.tscn" id="5_7ta6y"]
[node name="Desert" type="Terrain3D"]
storage = ExtResource("1_7nbyj")
material = ExtResource("2_psdr0")
texture_list = ExtResource("3_aowug")
storage = ExtResource("1_lmk23")
material = ExtResource("2_n44fh")
texture_list = ExtResource("3_w1yus")
collision_layer = 2147483648
collision_mask = 2147483648
@ -18,7 +18,7 @@ transform = Transform3D(0.5, 0.55667, -0.663414, 0, 0.766044, 0.642788, 0.866025
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource("5_4l4vc")
environment = ExtResource("4_m7p64")
[node name="PlayerSpawns" type="Node" parent="."]
@ -34,5 +34,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 895.356, 147.271, 888.261)
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 1024, 920, 1024)
[node name="FlagStand2" parent="." instance=ExtResource("5_5n76t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 895.366, 145.193, 888.267)
[node name="FlagPillar" parent="." instance=ExtResource("5_7ta6y")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 895.366, 145.291, 888.267)

View file

@ -15,5 +15,6 @@ background_mode = 2
sky = SubResource("Sky_mobku")
tonemap_mode = 3
tonemap_exposure = 0.85
ssr_enabled = true
volumetric_fog_density = 0.005
adjustment_brightness = 0.85

Binary file not shown.

View file

@ -1,23 +1,23 @@
[gd_resource type="Terrain3DTextureList" load_steps=7 format=3 uid="uid://d1j24k8sq8qpj"]
[ext_resource type="Texture2D" uid="uid://dwk8islw7ebab" path="res://maps/desert/assets/textures/rock029_alb_ht.png" id="1_v6d2c"]
[ext_resource type="Texture2D" uid="uid://lgfhdcsb2ryx" path="res://maps/desert/assets/textures/rock029_nrm_rgh.png" id="2_06nlf"]
[ext_resource type="Texture2D" uid="uid://cngjywcua4vv8" path="res://maps/desert/assets/textures/ground054_alb_ht.png" id="3_ik3f2"]
[ext_resource type="Texture2D" uid="uid://cbk7l6hs0yrcc" path="res://maps/desert/assets/textures/ground054_nrm_rgh.png" id="4_waajq"]
[ext_resource type="Texture2D" uid="uid://dwk8islw7ebab" path="res://maps/desert/assets/textures/rock029_alb_ht.png" id="1_onshe"]
[ext_resource type="Texture2D" uid="uid://lgfhdcsb2ryx" path="res://maps/desert/assets/textures/rock029_nrm_rgh.png" id="2_ij8ws"]
[ext_resource type="Texture2D" uid="uid://cngjywcua4vv8" path="res://maps/desert/assets/textures/ground054_alb_ht.png" id="3_1p8kc"]
[ext_resource type="Texture2D" uid="uid://cbk7l6hs0yrcc" path="res://maps/desert/assets/textures/ground054_nrm_rgh.png" id="4_2trjt"]
[sub_resource type="Terrain3DTexture" id="Terrain3DTexture_wue72"]
name = "Rock"
albedo_color = Color(0.921569, 0.890196, 0.933333, 1)
albedo_texture = ExtResource("1_v6d2c")
normal_texture = ExtResource("2_06nlf")
albedo_texture = ExtResource("1_onshe")
normal_texture = ExtResource("2_ij8ws")
uv_scale = 0.05
[sub_resource type="Terrain3DTexture" id="Terrain3DTexture_dkh73"]
name = "Sand"
texture_id = 1
albedo_color = Color(0.792157, 0.72549, 0.694118, 1)
albedo_texture = ExtResource("3_ik3f2")
normal_texture = ExtResource("4_waajq")
albedo_texture = ExtResource("3_1p8kc")
normal_texture = ExtResource("4_2trjt")
uv_scale = 0.15
[resource]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -14,14 +14,26 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name Singleplayer extends Node
@export var FLAG : PackedScene
@onready var player_node : Player = $Player
@onready var target_dummy : RigidBody3D = $TargetDummy
@onready var player_respawn_location : Vector3 = player_node.position
func _ready() -> void:
player_node.died.connect(respawn_player)
player_node.match_participant_component.player_id = 1
MapsManager.current_map = $Desert
_add_flag()
func respawn_player(player : Player, _killer_id : int) -> void:
player.respawn(player_respawn_location)
var spawn : Marker3D = MapsManager.get_player_spawn()
if spawn:
player.respawn(spawn.position)
else:
push_error("MapsManager.get_player_spawn could not find a spawn marker")
func _add_flag() -> void:
var flag : Flag = FLAG.instantiate()
add_child(flag)
var flagstand : Marker3D = MapsManager.current_map.get_node("FlagStand")
if flagstand:
flag.global_position = flagstand.position

View file

@ -2,9 +2,9 @@
[ext_resource type="Script" path="res://modes/singleplayer/demo.gd" id="1_kkjqs"]
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_6wbjq"]
[ext_resource type="PackedScene" uid="uid://dpnu1lvfncx6q" path="res://entities/target_dummy/target_dummy.tscn" id="3_fkq5v"]
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="4_1j2pw"]
[ext_resource type="PackedScene" uid="uid://btlkog4b87p4x" path="res://maps/desert/desert.tscn" id="4_dogmv"]
[ext_resource type="PackedScene" uid="uid://dpnu1lvfncx6q" path="res://entities/dummy_target/dummy_target.tscn" id="5_euor2"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_c5jqv"]
resource_local_to_scene = true
@ -13,16 +13,13 @@ absorbent = true
[node name="Demo" type="Node"]
script = ExtResource("1_kkjqs")
FLAG = ExtResource("4_1j2pw")
[node name="Player" parent="." instance=ExtResource("2_6wbjq")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 589.786, 209.119, 853.632)
physics_material_override = SubResource("PhysicsMaterial_c5jqv")
[node name="TargetDummy" parent="." instance=ExtResource("3_fkq5v")]
transform = Transform3D(-0.789567, 0, 0.613666, 0, 1, 0, -0.613666, 0, -0.789567, 418.132, 195.484, 802.593)
[node name="Flag" parent="." instance=ExtResource("4_1j2pw")]
transform = Transform3D(0.405891, 0, -0.913922, 0, 1, 0, 0.913922, 0, 0.405891, 890.762, 179.326, 1005.33)
[node name="Desert" parent="." instance=ExtResource("4_dogmv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0566101, 1456.67, 0.597462)
[node name="DummyTarget" parent="." instance=ExtResource("5_euor2")]

View file

@ -19,6 +19,7 @@ config/icon="res://icon.svg"
Settings="*res://systems/settings.gd"
MapsManager="*res://systems/maps_manager.gd"
GameManager="*res://systems/game_manager.gd"
[debug]

13
systems/game_manager.gd Normal file
View file

@ -0,0 +1,13 @@
extends Node
## This is the mode currently used by the game.
var mode : Node:
set(new_mode):
# clean up previous mode
if mode != null:
mode.queue_free()
# keep reference to new mode
mode = new_mode
# setup new mode
if new_mode != null:
add_child(new_mode)