Started fps system

This commit is contained in:
Rendo 2025-11-24 04:44:42 +05:00
commit cc26793ab6
32 changed files with 2756 additions and 11 deletions

42
export_presets.cfg Normal file
View file

@ -0,0 +1,42 @@
[preset.0]
name="Linux"
platform="Linux"
runnable=true
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="exports/Chelimbalo.x86_64"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
binary_format/embed_pck=true
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""

4
exports/Chelimbalo.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
printf '\033c\033]0;%s\a' Chelimbalo
base_path="$(dirname "$(realpath "$0")")"
"$base_path/Chelimbalo.x86_64" "$@"

BIN
exports/Chelimbalo.x86_64 Executable file

Binary file not shown.

View file

@ -41,5 +41,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5862943, 0)
script = ExtResource("4_pi0y7")
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
_spawnable_scenes = PackedStringArray("uid://dpsr6ug3pkb40")
_spawnable_scenes = PackedStringArray("uid://dpsr6ug3pkb40", "uid://cheu6vds21er7")
spawn_path = NodePath("..")

Binary file not shown.

BIN
models/molikman_hands.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 KiB

View file

@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://eo4fkc3b4h01"
path.s3tc="res://.godot/imported/molikman_hands_tex_Molikman.png-00eab978ebbbebd3d27ba6449445dd5a.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "adf17223cdac27afac207ae40df37427"
}
[deps]
source_file="res://models/molikman_hands_tex_Molikman.png"
dest_files=["res://.godot/imported/molikman_hands_tex_Molikman.png-00eab978ebbbebd3d27ba6449445dd5a.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View file

@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cheflq6sljpmk"
path.s3tc="res://.godot/imported/molikman_hands_tex_sp_albedo.png-1f43db41736e6d0c2527c3839e087d2e.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "6643bd50a4e6b8c34195f1c0b3363b30"
}
[deps]
source_file="res://models/molikman_hands_tex_sp_albedo.png"
dest_files=["res://.godot/imported/molikman_hands_tex_sp_albedo.png-1f43db41736e6d0c2527c3839e087d2e.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cppa8jv8ean45"
path.s3tc="res://.godot/imported/molikman_hands_tex_sp_roughness.png-ff414b619c112cac9e303a92eba0d925.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "8efa9a6c4e818d6467103a6b5a25a7bc"
}
[deps]
source_file="res://models/molikman_hands_tex_sp_roughness.png"
dest_files=["res://.godot/imported/molikman_hands_tex_sp_roughness.png-ff414b619c112cac9e303a92eba0d925.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

BIN
models/starting_pistol.glb Normal file

Binary file not shown.

View file

@ -0,0 +1,42 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://d3sjs6efbshpk"
path="res://.godot/imported/starting_pistol.glb-29198af604eac72687b4adaf951ef022.scn"
[deps]
source_file="res://models/starting_pistol.glb"
dest_files=["res://.godot/imported/starting_pistol.glb-29198af604eac72687b4adaf951ef022.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
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
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View file

@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://yl82ojt8wph5"
path.s3tc="res://.godot/imported/starting_pistol_tex_sp_albedo.png-8161f1ff7d1a76474d978c2a86f54261.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "6643bd50a4e6b8c34195f1c0b3363b30"
}
[deps]
source_file="res://models/starting_pistol_tex_sp_albedo.png"
dest_files=["res://.godot/imported/starting_pistol_tex_sp_albedo.png-8161f1ff7d1a76474d978c2a86f54261.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bb302fhk1eu05"
path.s3tc="res://.godot/imported/starting_pistol_tex_sp_roughness.png-2f38dacd3f9e1e69ced706fb91133b7c.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "8efa9a6c4e818d6467103a6b5a25a7bc"
}
[deps]
source_file="res://models/starting_pistol_tex_sp_roughness.png"
dest_files=["res://.godot/imported/starting_pistol_tex_sp_roughness.png-2f38dacd3f9e1e69ced706fb91133b7c.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View file

@ -112,9 +112,31 @@ plr_firemode={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":118,"location":0,"echo":false,"script":null)
]
}
plr_primary={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
]
}
plr_secondary={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null)
]
}
plr_knife={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":51,"location":0,"echo":false,"script":null)
]
}
plr_bomb={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":52,"key_label":0,"unicode":52,"location":0,"echo":false,"script":null)
]
}
[layer_names]
3d_render/layer_1="MainRender"
3d_render/layer_2="ViewRender"
3d_physics/layer_1="Surroundings"
3d_physics/layer_2="Players"
3d_physics/layer_3="Gadgets"

View file

@ -15,8 +15,8 @@ script = ExtResource("1_l6cm7")
[node name="MainMenu" type="PanelContainer" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
offset_right = 293.0
offset_bottom = 101.0
[node name="VBoxContainer" type="VBoxContainer" parent="MainMenu"]
layout_mode = 2
@ -29,6 +29,10 @@ text = "HOST"
layout_mode = 2
text = "CONNECT"
[node name="LineEdit" type="LineEdit" parent="MainMenu/VBoxContainer"]
layout_mode = 2
placeholder_text = "ip"
[node name="Lobby" type="PanelContainer" parent="."]
visible = false
layout_mode = 0

View file

@ -1,8 +1,11 @@
[gd_scene load_steps=11 format=3 uid="uid://dpsr6ug3pkb40"]
[gd_scene load_steps=14 format=3 uid="uid://dpsr6ug3pkb40"]
[ext_resource type="Script" uid="uid://3dphlay25fih" path="res://scripts/player/player.gd" id="1_g2els"]
[ext_resource type="Script" uid="uid://dalwlndejfdhm" path="res://scripts/player/crosshair.gd" id="3_dqkch"]
[ext_resource type="Script" uid="uid://bjhbdh6xsjgnn" path="res://scripts/player/player_camera.gd" id="3_qhqgy"]
[ext_resource type="PackedScene" uid="uid://c3hg4ux4j76j2" path="res://models/molikman_hands.glb" id="4_dqkch"]
[ext_resource type="Script" uid="uid://bmecgup3kcua7" path="res://scripts/weapon_system/system.gd" id="4_qlg0r"]
[ext_resource type="Script" uid="uid://c76n6qgu6o4hn" path="res://scripts/weapon_system/gun.gd" id="6_tuyoq"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_u8vuu"]
@ -110,6 +113,9 @@ properties/2/replication_mode = 1
properties/3/path = NodePath(".:crouched")
properties/3/spawn = true
properties/3/replication_mode = 1
properties/4/path = NodePath(".:hp")
properties/4/spawn = true
properties/4/replication_mode = 1
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("animation_player", "stand_up_area")]
collision_layer = 2
@ -128,6 +134,71 @@ cull_mask = 1048573
fov = 90.0
script = ExtResource("3_qhqgy")
[node name="molikman_hands" parent="Camera3D" instance=ExtResource("4_dqkch")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, -1, 0)
[node name="Skeleton3D" parent="Camera3D/molikman_hands/Hands" index="0"]
bones/1/position = Vector3(0.16239367, 0.7620353, -0.22555673)
bones/1/rotation = Quaternion(-0.013897974, 0.25458142, 0.93291974, 0.25427514)
bones/2/rotation = Quaternion(0.48351443, 0.011421198, -0.101050004, 0.8694092)
bones/3/rotation = Quaternion(-0.21969835, 0.9295987, -0.14384198, -0.25862813)
bones/4/rotation = Quaternion(-0.228779, -0.029572416, 0.054699976, 0.9714905)
bones/5/rotation = Quaternion(-0.0041055745, -0.00432046, 0.08434049, 0.99641925)
bones/6/rotation = Quaternion(0.0052072993, 0.00027607038, 0.0044955458, 0.99997634)
bones/7/rotation = Quaternion(-0.1004904, -0.0019074425, 0.13231255, 0.98609906)
bones/8/rotation = Quaternion(0.024437865, -0.009641473, 0.2161158, 0.97601426)
bones/9/rotation = Quaternion(0.026062598, -0.010100163, 0.3215908, 0.94646615)
bones/10/rotation = Quaternion(-0.053834017, -0.032078788, 0.06392841, 0.995985)
bones/11/rotation = Quaternion(0.04591663, -0.010990316, 0.29229766, 0.9551613)
bones/12/rotation = Quaternion(-0.008413597, 0.0025515698, 0.3356365, 0.9419506)
bones/13/rotation = Quaternion(-0.035504643, -0.11951073, 0.017020436, 0.99205184)
bones/14/rotation = Quaternion(0.07038061, -0.042397514, 0.3243001, 0.9423792)
bones/15/rotation = Quaternion(0.010458748, -0.003636818, 0.33499107, 0.9421562)
bones/16/rotation = Quaternion(0.023548108, -0.1841245, 0.118893534, 0.9754015)
bones/17/rotation = Quaternion(0.07007245, -0.05591666, 0.21599722, 0.9722697)
bones/18/rotation = Quaternion(-0.007437984, 0.00025136053, 0.082008004, 0.9966039)
bones/19/rotation = Quaternion(-0.228779, -0.029572409, 0.05469998, 0.9714905)
bones/20/rotation = Quaternion(-0.10049036, -0.0019074364, 0.13231257, 0.9860992)
bones/21/rotation = Quaternion(-0.053834017, -0.032078788, 0.06392841, 0.995985)
bones/22/rotation = Quaternion(-0.035504643, -0.11951072, 0.017020464, 0.99205184)
bones/23/rotation = Quaternion(0.023548096, -0.18412448, 0.11889355, 0.97540146)
bones/24/position = Vector3(-0.35145342, -0.009178132, -0.18038769)
bones/25/position = Vector3(0.16239375, 0.7620353, -0.22555672)
bones/25/rotation = Quaternion(0.98640305, 0.115810655, 0.1158104, -0.013596949)
bones/26/position = Vector3(-0.16605523, 0.503459, 0.34819144)
bones/26/rotation = Quaternion(0.80184454, 0.012367124, -0.00014036377, 0.5974047)
bones/27/rotation = Quaternion(0.02130827, -0.010780271, 0.9870714, 0.15849292)
bones/28/rotation = Quaternion(0.83065116, -0.0069491817, 0.17359851, 0.5289934)
bones/29/rotation = Quaternion(0.154159, 0.96413255, -0.21364379, -0.032244705)
bones/30/rotation = Quaternion(-0.2385772, -0.09427333, -0.5218142, 0.81357443)
bones/31/rotation = Quaternion(0.22222735, 0.37126783, 0.41440633, 0.8006513)
bones/32/rotation = Quaternion(-0.21135177, -0.40205637, 0.31771636, 0.83230853)
bones/33/rotation = Quaternion(-0.05823014, 0.07767168, -0.03485695, 0.99466646)
bones/34/rotation = Quaternion(0.025301827, 0.0070700953, -0.11431894, 0.9930967)
bones/35/rotation = Quaternion(0.027933404, -0.0009984301, 0.077792086, 0.9965778)
bones/36/rotation = Quaternion(0.06419258, 0.10893227, 0.010188486, 0.9919221)
bones/37/rotation = Quaternion(0.04615016, 0.009964154, -0.27093482, 0.9614392)
bones/38/rotation = Quaternion(-0.008443102, -0.0024520692, -0.3244902, 0.9458482)
bones/39/rotation = Quaternion(0.027152644, 0.0043768333, 0.076968625, 0.9966541)
bones/40/rotation = Quaternion(0.06997402, 0.04306513, -0.3332506, 0.9392513)
bones/41/rotation = Quaternion(0.009862088, 0.005034929, -0.46087027, 0.88739854)
bones/42/rotation = Quaternion(0.14311673, 0.16402356, -0.04056179, 0.9751763)
bones/43/rotation = Quaternion(0.07528415, 0.04867352, -0.11827113, 0.9889263)
bones/44/rotation = Quaternion(-0.007426173, 0.000489381, 0.017473433, 0.99981964)
bones/45/rotation = Quaternion(-0.2385772, -0.09427333, -0.52181435, 0.81357443)
bones/46/rotation = Quaternion(-0.058230132, 0.0776717, -0.034856908, 0.9946665)
bones/47/rotation = Quaternion(0.06419257, 0.10893226, 0.010188487, 0.9919221)
bones/48/rotation = Quaternion(0.027152658, 0.0043768324, 0.07696863, 0.9966541)
bones/49/rotation = Quaternion(0.14311673, 0.16402358, -0.040561832, 0.9751763)
bones/51/rotation = Quaternion(0.9864031, -0.11581065, -0.115810156, -0.013596978)
bones/52/position = Vector3(-0.24780756, 0.5192058, 0.3484822)
bones/52/rotation = Quaternion(0.73236954, 0.00991537, -0.022315646, 0.6804694)
[node name="Skeleton3D" parent="Camera3D/molikman_hands/GunArm" index="0"]
bones/0/position = Vector3(-0.22279283, 0.7100338, -0.19202478)
bones/0/rotation = Quaternion(-0.006717509, 0.6971531, 0.71686494, -0.0060944925)
bones/1/position = Vector3(5.972106e-08, 0.06469955, 0.06380712)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_qlg0r")
@ -170,3 +241,17 @@ crosses_offset = 3.0
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_qhqgy")
[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("default_pistol", "animation_player")]
script = ExtResource("4_qlg0r")
default_pistol = NodePath("StartingPistol")
animation_player = NodePath("../Camera3D/molikman_hands/AnimationPlayer")
[node name="StartingPistol" type="Node" parent="WeaponSystem"]
script = ExtResource("6_tuyoq")
max_ammo = 10
semi_auto = true
firerate = 0.1
prefix = "baked_sp"
[editable path="Camera3D/molikman_hands"]

View file

@ -5,6 +5,8 @@ func _ready() -> void:
func _on_leave_button_pressed() -> void:
Lobby.leave()
$"../..".hide()
$"../../../MainMenu".show()
func _on_start_button_pressed() -> void:
Lobby.start_game.rpc()

View file

@ -9,6 +9,11 @@ func _on_host_button_pressed() -> void:
func _on_connect_button_pressed() -> void:
Lobby.join("localhost")
var ip = $MainMenu/VBoxContainer/LineEdit.text
if ip == "":
ip = "localhost"
var joined = Lobby.join(ip)
if joined != Error.OK:
return
$MainMenu.hide()
$Lobby.show()

View file

@ -14,11 +14,14 @@ func host() -> void:
multiplayer.multiplayer_peer = peer
lobby_created.emit()
func join(ip: String) -> void:
func join(ip: String) -> Error:
var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new()
peer.create_client(ip,PORT)
var res = peer.create_client(ip,PORT)
if res != 0:
return res
multiplayer.multiplayer_peer = peer
lobby_joined.emit()
return Error.OK
func leave() -> void:
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()

View file

@ -1,5 +1,19 @@
extends CharacterBody3D
const MAX_HP = 100
@export var hp: int = 100:
set(value):
if value < 0:
hp = 0
else:
hp = value
if hp == 0:
die()
get:
return hp
@export var animation_player: AnimationPlayer
@export var stand_up_area: Area3D
@ -71,7 +85,6 @@ func _input(event: InputEvent) -> void:
crouched = true
elif event.is_action_released("plr_crouch") and TOGGLE_CROUCH == false:
crouched = false
if event.is_action_pressed("plr_drop"):
var grenade = preload("res://scenes/smoke.tscn").instantiate()
get_tree().current_scene.add_child(grenade)
grenade.global_position = global_position + Vector3.UP * 0.5
func die() -> void:
queue_free()

View file

@ -0,0 +1,67 @@
extends Usable
@export var max_ammo: int
@export var semi_auto: bool
@export var damage: int
@export var firerate: float
@export var prefix: String
var ammo_amount: int
var fire_timer: Timer
func _ready() -> void:
fire_timer = Timer.new()
fire_timer.wait_time = firerate
ammo_amount = max_ammo
add_child(fire_timer)
if not semi_auto:
fire_timer.timeout.connect(fire)
@rpc("authority","call_local","reliable")
func use_begin() -> void:
if fire_timer.is_stopped() == false:
return
fire_timer.start()
fire_timer.one_shot = true if semi_auto else false
fire()
@rpc("authority","call_local","reliable")
func use_end() -> void:
fire_timer.one_shot = true
func fire() -> void:
if ammo_amount == 0:
if not semi_auto:
fire_timer.stop()
return
ammo_amount -= 1
system.animation_player.stop()
system.animation_player.play(prefix+"_shoot")
system.animation_player.queue(prefix+"_idle")
func alternate_state() -> void:
pass
func switch_mode() -> void:
pass
func enter() -> void:
system.animation_player.play(prefix+"_idle")
func _input(event: InputEvent) -> void:
if not system.is_multiplayer_authority(): return
if event.is_action_pressed("plr_reload"):
init_reload.rpc()
@rpc("call_local","authority","reliable")
func init_reload():
if ammo_amount == max_ammo or system.animation_player.current_animation == prefix + "_reload":
return
system.animation_player.play(prefix+"_reload")
ammo_amount = max_ammo

View file

@ -0,0 +1 @@
uid://c76n6qgu6o4hn

View file

@ -0,0 +1,107 @@
extends Node
class_name WeaponSystem
@export var default_pistol: Usable
@export var default_knife: Usable
@export var animation_player: AnimationPlayer
var current_usable: Usable
var slots: Dictionary[StringName,Usable] = {
"primary": null,
"secondary": default_pistol,
"knife": default_knife,
"bomb": null,
"ability_first": null,
"ability_second": null,
"ability_third": null,
"ultimate": null
}
signal switched_to(usable: Usable)
func _ready() -> void:
for child in get_children():
if child is Usable:
child.system = self
else:
push_warning("Child of weapon system is not ability or weapon")
current_usable = default_pistol
current_usable.enter()
func can_add(slot: StringName) -> bool:
return slots.has(slot)
func add(usable: Usable, slot: StringName) -> void:
if can_add(slot) == false:
return
add_child(usable)
slots[slot] = usable
usable.system = self
func switch(to: StringName):
if slots.has(to) == false or slots[to] == null:
return
current_usable.exit()
current_usable.in_use = false
current_usable = slots[to]
current_usable.enter()
current_usable.in_use = true
switched_to.emit(current_usable)
update_remotes.rpc(to)
@rpc("authority","call_remote","reliable")
func update_remotes(to: StringName):
switch(to)
func _process(delta: float) -> void:
if current_usable == null:
push_error("State is not set")
return
current_usable.update(delta)
func _physics_process(delta: float) -> void:
if current_usable == null:
push_error("State is not set")
return
current_usable.physics_update(delta)
func _input(event: InputEvent) -> void:
if is_multiplayer_authority() == false: return
if event.is_action_pressed("plr_ult"):
switch("ultimate")
elif event.is_action_pressed("plr_bomb"):
switch("bomb")
elif event.is_action_pressed("plr_primary"):
switch("primary")
elif event.is_action_pressed("plr_active_first"):
switch("ability_first")
elif event.is_action_pressed("plr_active_second"):
switch("ability_second")
elif event.is_action_pressed("plr_active_third"):
switch("ability_third")
elif event.is_action_pressed("plr_secondary"):
switch("secondary")
elif event.is_action_pressed("plr_knife"):
switch("knife")
if event.is_action_pressed("plr_fire"):
current_usable.use_begin.rpc()
if event.is_action_released("plr_fire"):
current_usable.use_end.rpc()
if event.is_action_pressed("plr_scope"):
current_usable.alternate_state()
if event.is_action_pressed("plr_firemode"):
current_usable.switch_mode()

View file

@ -0,0 +1 @@
uid://bmecgup3kcua7

View file

@ -0,0 +1,25 @@
@abstract
extends Node
class_name Usable
var system: WeaponSystem
var in_use: bool = false
@rpc("authority","call_local","reliable")
@abstract func use_begin() -> void
@rpc("authority","call_local","reliable")
@abstract func use_end() -> void
@abstract func alternate_state() -> void
# Need to clarify naming; Switch mode like firemode. For different states use
# alternate_state
@abstract func switch_mode() -> void
func enter() -> void:
pass
func exit() -> void:
pass
func update(_delta: float) -> void:
pass
func physics_update(_delta: float) -> void:
pass

View file

@ -0,0 +1 @@
uid://qj4m67w7ps7j