diff --git a/.gitignore b/.gitignore index 6d16b6c..83dc4b6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ .godot/ /android/ exports/ -deploy.sh diff --git a/export_presets.cfg b/export_presets.cfg index 82ebb18..6239d0e 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -43,7 +43,7 @@ rm -rf \"{temp_dir}\"" [preset.1] -name="Windows" +name="Windows Desktop" platform="Windows Desktop" runnable=true advanced_options=false diff --git a/levels/prototype_scene.tscn b/levels/prototype_scene.tscn index bdf218b..40de8a2 100644 --- a/levels/prototype_scene.tscn +++ b/levels/prototype_scene.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=21 format=3 uid="uid://cqrh2cc7m2i7f"] +[gd_scene load_steps=24 format=3 uid="uid://cqrh2cc7m2i7f"] [ext_resource type="Environment" uid="uid://d0cfgtx2yxw13" path="res://environments/prototype_environment.tres" id="1_i6jab"] +[ext_resource type="Script" uid="uid://ypgm3aplt78m" path="res://scripts/multiplayer/team_spawner.gd" id="4_pi0y7"] [ext_resource type="Material" uid="uid://bx3f5vx71ynh5" path="res://materials/Graymat.tres" id="4_y6i55"] [ext_resource type="Material" uid="uid://dynpcduei1wfn" path="res://materials/Bluemat.tres" id="4_yx0ab"] [ext_resource type="Material" uid="uid://mlha6r17v2en" path="res://materials/DarkBluemat.tres" id="5_bno23"] @@ -14,9 +15,22 @@ [ext_resource type="Script" uid="uid://dk1gjbuydemmb" path="res://scripts/multiplayer/plant_site/plant_site.gd" id="8_oujx2"] [ext_resource type="Script" uid="uid://b4cpux52fmx5o" path="res://scripts/multiplayer/plant_site/plant_deadzone.gd" id="9_1wlgq"] [ext_resource type="Material" uid="uid://c6xa4phihtya2" path="res://materials/Redmat.tres" id="9_ysk2e"] -[ext_resource type="Script" uid="uid://ypgm3aplt78m" path="res://scripts/multiplayer/spawn_system/team_spawner.gd" id="10_02ic3"] [ext_resource type="Script" uid="uid://3i00rp8urth7" path="res://scripts/object_container.gd" id="11_02ic3"] +[sub_resource type="Animation" id="Animation_y6i55"] +length = 0.001 + +[sub_resource type="Animation" id="Animation_pi0y7"] +resource_name = "main" +length = 5.0 +loop_mode = 2 + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_bno23"] +_data = { +&"RESET": SubResource("Animation_y6i55"), +&"main": SubResource("Animation_pi0y7") +} + [sub_resource type="BoxShape3D" id="BoxShape3D_ysk2e"] size = Vector3(15.324341, 0.96273804, 21.381592) @@ -225,24 +239,30 @@ operation = 2 size = Vector3(20.339264, 4.566284, 3.4625244) material = ExtResource("7_8bje3") +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +&"": SubResource("AnimationLibrary_bno23") +} +autoplay = "main" + [node name="PlayersContainer" type="Node3D" parent="." node_paths=PackedStringArray("exlusion_list")] script = ExtResource("11_02ic3") exlusion_list = [NodePath("DefenceSpawn"), NodePath("AttackSpawn"), NodePath("SpectatorSpawn"), NodePath("MultiplayerSpawner")] [node name="DefenceSpawn" type="Marker3D" parent="PlayersContainer"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 37.170197, 0.5180037, -11.271502) -script = ExtResource("10_02ic3") +script = ExtResource("4_pi0y7") spawn_radius = 10.0 [node name="AttackSpawn" type="Marker3D" parent="PlayersContainer"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -31.553003, 0.5180037, 20.371899) -script = ExtResource("10_02ic3") +script = ExtResource("4_pi0y7") team = 1 spawn_radius = 5.0 [node name="SpectatorSpawn" type="Marker3D" parent="PlayersContainer"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.1422176, 39.792877, -1.3889732) -script = ExtResource("10_02ic3") +script = ExtResource("4_pi0y7") team = 2 spawn_radius = 10.0 @@ -255,7 +275,7 @@ script = ExtResource("11_02ic3") exlusion_list = [NodePath("MultiplayerSpawner"), NodePath("Bomb")] [node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="DynamicObjectsContainer"] -_spawnable_scenes = PackedStringArray("uid://cxdgk74ln5xpn", "uid://dgfqppi21c2u0") +_spawnable_scenes = PackedStringArray("uid://dtbpyfdawb02b", "uid://cxdgk74ln5xpn", "uid://dgfqppi21c2u0") spawn_path = NodePath("..") script = ExtResource("6_oujx2") diff --git a/models/characters/worldmodels/molikman_ingame_tex_Molikman.png b/models/characters/worldmodels/molikman_ingame_tex_Molikman.png deleted file mode 100644 index bd2b19c..0000000 Binary files a/models/characters/worldmodels/molikman_ingame_tex_Molikman.png and /dev/null differ diff --git a/models/characters/worldmodels/molikman_ingame_tex_Molikman.png.import b/models/characters/worldmodels/molikman_ingame_tex_Molikman.png.import deleted file mode 100644 index 18b55fa..0000000 --- a/models/characters/worldmodels/molikman_ingame_tex_Molikman.png.import +++ /dev/null @@ -1,43 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://50bjd4m600y" -path="res://.godot/imported/molikman_ingame_tex_Molikman.png-fa994ec91481577d99049156480274fc.ctex" -metadata={ -"vram_texture": false -} -generator_parameters={ -"md5": "adf17223cdac27afac207ae40df37427" -} - -[deps] - -source_file="res://models/characters/worldmodels/molikman_ingame_tex_Molikman.png" -dest_files=["res://.godot/imported/molikman_ingame_tex_Molikman.png-fa994ec91481577d99049156480274fc.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/uastc_level=0 -compress/rdo_quality_loss=0.0 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=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=1 diff --git a/project.godot b/project.godot index 41109f9..564cd6d 100644 --- a/project.godot +++ b/project.godot @@ -22,7 +22,6 @@ Lobby="*res://scripts/multiplayer/lobby.gd" Session="*res://scripts/multiplayer/session.gd" ClientSettings="*res://scripts/client_settings.gd" Registry="*res://scripts/registry.gd" -ClientSettingsMenu="res://scenes/gui/client_settings.tscn" [display] @@ -168,7 +167,3 @@ menu_settings={ 3d_physics/layer_5="Players Attack Team" 3d_physics/layer_6="Players Defence Team" 3d_physics/layer_7="Interactible" - -[physics] - -3d/default_gravity=39.2 diff --git a/scenes/gui/client_settings.tscn b/scenes/gui/client_settings.tscn index e3974a6..6ab0368 100644 --- a/scenes/gui/client_settings.tscn +++ b/scenes/gui/client_settings.tscn @@ -2,36 +2,29 @@ [ext_resource type="Script" uid="uid://ddi1alk8oyi1b" path="res://scripts/gui/client_settings_menu.gd" id="1_xqyus"] -[node name="ClientSettingsMenu" type="CanvasLayer"] - -[node name="CenterContainer" type="CenterContainer" parent="."] +[node name="ClientSettings" type="PanelContainer"] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -mouse_filter = 2 - -[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"] -visible = false -layout_mode = 2 script = ExtResource("1_xqyus") -[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 2 -[node name="FullscreenButton" type="CheckButton" parent="CenterContainer/PanelContainer/VBoxContainer"] +[node name="FullscreenButton" type="CheckButton" parent="VBoxContainer"] layout_mode = 2 text = "Полный экран" -[node name="Sensitivity" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer"] +[node name="Sensitivity" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/Sensitivity"] +[node name="Label" type="Label" parent="VBoxContainer/Sensitivity"] layout_mode = 2 text = "Чувствительность" -[node name="HSlider" type="HSlider" parent="CenterContainer/PanelContainer/VBoxContainer/Sensitivity"] +[node name="HSlider" type="HSlider" parent="VBoxContainer/Sensitivity"] custom_minimum_size = Vector2(256, 0) layout_mode = 2 size_flags_horizontal = 3 @@ -40,7 +33,7 @@ max_value = 0.1 step = 0.001 value = 0.02 -[node name="SpinBox" type="SpinBox" parent="CenterContainer/PanelContainer/VBoxContainer/Sensitivity"] +[node name="SpinBox" type="SpinBox" parent="VBoxContainer/Sensitivity"] layout_mode = 2 max_value = 0.1 step = 0.001 @@ -48,21 +41,21 @@ value = 0.02 allow_greater = true allow_lesser = true -[node name="GameplayMainAudio" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer"] +[node name="GameplayMainAudio" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/GameplayMainAudio"] +[node name="Label" type="Label" parent="VBoxContainer/GameplayMainAudio"] layout_mode = 2 text = "Геймплейные звуки" -[node name="GameplayMainSlider" type="HSlider" parent="CenterContainer/PanelContainer/VBoxContainer/GameplayMainAudio"] +[node name="GameplayMainSlider" type="HSlider" parent="VBoxContainer/GameplayMainAudio"] layout_mode = 2 size_flags_horizontal = 3 max_value = 1.0 step = 0.01 value = 1.0 -[connection signal="toggled" from="CenterContainer/PanelContainer/VBoxContainer/FullscreenButton" to="." method="_on_check_button_toggled"] -[connection signal="value_changed" from="CenterContainer/PanelContainer/VBoxContainer/Sensitivity/HSlider" to="." method="_on_h_slider_value_changed"] -[connection signal="value_changed" from="CenterContainer/PanelContainer/VBoxContainer/Sensitivity/SpinBox" to="." method="_on_spin_box_value_changed"] -[connection signal="value_changed" from="CenterContainer/PanelContainer/VBoxContainer/GameplayMainAudio/GameplayMainSlider" to="." method="_on_gameplay_main_slider_value_changed"] +[connection signal="toggled" from="VBoxContainer/FullscreenButton" to="." method="_on_check_button_toggled"] +[connection signal="value_changed" from="VBoxContainer/Sensitivity/HSlider" to="." method="_on_h_slider_value_changed"] +[connection signal="value_changed" from="VBoxContainer/Sensitivity/SpinBox" to="." method="_on_spin_box_value_changed"] +[connection signal="value_changed" from="VBoxContainer/GameplayMainAudio/GameplayMainSlider" to="." method="_on_gameplay_main_slider_value_changed"] diff --git a/scenes/molikman.tscn b/scenes/molikman.tscn index f05943c..7fdbf83 100644 --- a/scenes/molikman.tscn +++ b/scenes/molikman.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=84 format=4 uid="uid://dpsr6ug3pkb40"] +[gd_scene load_steps=81 format=4 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"] @@ -23,6 +23,7 @@ [ext_resource type="Script" uid="uid://gan0amqbhi4i" path="res://scripts/gui/hud/player_ammo_display.gd" id="12_iortg"] [ext_resource type="Script" uid="uid://bala54fa32e35" path="res://scripts/gui/hud/player_round_display.gd" id="13_x73hv"] [ext_resource type="Script" uid="uid://bos7nftlx8tv3" path="res://scripts/gui/hud/player_round_time.gd" id="13_xar7t"] +[ext_resource type="PackedScene" uid="uid://bv6ptrditssow" path="res://scenes/gui/client_settings.tscn" id="16_d267o"] [ext_resource type="AudioStream" uid="uid://bd4iofirvmiu6" path="res://audio/step_wood.ogg" id="16_fbysy"] [ext_resource type="Script" uid="uid://da0xv360va3b3" path="res://scripts/audio_system/multiplayer_audio_3d.gd" id="17_0cqlf"] [ext_resource type="Script" uid="uid://xsgfbuyje35p" path="res://scripts/player/player_pickup.gd" id="17_fjvrb"] @@ -36,8 +37,6 @@ [ext_resource type="Script" uid="uid://b2djbdh05pbcn" path="res://scripts/player/team_color_switcher.gd" id="25_1mtds"] [ext_resource type="Material" uid="uid://cjb0h3of85nc2" path="res://materials/players/molikman/mat_Molikman.tres" id="26_r2jxp"] [ext_resource type="Texture2D" uid="uid://15mf4452fse0" path="res://textures/players/molikman/molikman_ingame_Molikman_blue.png" id="27_j3w78"] -[ext_resource type="Script" uid="uid://dsp1sq46c5i3y" path="res://scripts/player/player_interaction.gd" id="37_5amik"] -[ext_resource type="Script" uid="uid://dfvnx8f1v6m5g" path="res://scripts/multiplayer/player_input.gd" id="37_b2eak"] [sub_resource type="ArrayMesh" id="ArrayMesh_lot4n"] _surfaces = [{ @@ -7402,14 +7401,6 @@ _data = { &"baked_sp_shoot_empty": SubResource("Animation_do7kw") } -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_b2eak"] -properties/0/path = NodePath(".:rotation") -properties/0/spawn = true -properties/0/replication_mode = 1 -properties/1/path = NodePath("..:rotation") -properties/1/spawn = true -properties/1/replication_mode = 1 - [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_g2els"] height = 1.2958984 @@ -7420,21 +7411,18 @@ font_size = 32 properties/0/path = NodePath(".:position") properties/0/spawn = true properties/0/replication_mode = 1 -properties/1/path = NodePath(".:hp") +properties/1/path = NodePath(".:rotation") properties/1/spawn = true properties/1/replication_mode = 1 -properties/2/path = NodePath(".:team") +properties/2/path = NodePath("Camera3D:rotation") properties/2/spawn = true -properties/2/replication_mode = 2 -properties/3/path = NodePath(".:player_id") +properties/2/replication_mode = 1 +properties/3/path = NodePath(".:hp") properties/3/spawn = true -properties/3/replication_mode = 0 -properties/4/path = NodePath(".:collision_layer") +properties/3/replication_mode = 1 +properties/4/path = NodePath(".:team") properties/4/spawn = true -properties/4/replication_mode = 0 -properties/5/path = NodePath(".:collision_mask") -properties/5/spawn = true -properties/5/replication_mode = 0 +properties/4/replication_mode = 2 [sub_resource type="Curve" id="Curve_fbysy"] _data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 2.5229826, 0.0, 0, 0] @@ -7617,14 +7605,6 @@ _data = { radius = 0.82177734 height = 3.7087402 -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_5amik"] -properties/0/path = NodePath("PlayerInput:direction") -properties/0/spawn = true -properties/0/replication_mode = 1 -properties/1/path = NodePath("PlayerInput:compressed_states") -properties/1/spawn = true -properties/1/replication_mode = 1 - [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("weapon_models")] collision_layer = 2 collision_mask = 3 @@ -8107,11 +8087,9 @@ mesh = SubResource("ArrayMesh_aj0lc") skin = SubResource("Skin_53wat") surface_material_override/0 = ExtResource("26_r2jxp") -[node name="PlayerBasedVisibility" type="Node" parent="molikman_ingame" node_paths=PackedStringArray("reference_player")] +[node name="VisibleEnabler" type="Node" parent="molikman_ingame"] script = ExtResource("4_smehm") visible_for_others = true -reference_player = NodePath("../..") -metadata/_custom_type_script = "uid://dd5mp72dq43v6" [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) @@ -8595,17 +8573,13 @@ libraries = { &"": SubResource("AnimationLibrary_kyf2b") } -[node name="VisibilityToggler" type="Node" parent="Camera3D/molikman_hands" node_paths=PackedStringArray("reference_player")] +[node name="VisibilityToggler" type="Node" parent="Camera3D/molikman_hands"] script = ExtResource("4_smehm") -reference_player = NodePath("../../..") [node name="DeadSpectator" type="Camera3D" parent="Camera3D"] fov = 90.0 script = ExtResource("8_rwwcc") -[node name="CameraSync" type="MultiplayerSynchronizer" parent="Camera3D"] -replication_config = SubResource("SceneReplicationConfig_b2eak") - [node name="StandArea" type="Area3D" parent="."] collision_layer = 0 @@ -8662,9 +8636,8 @@ crosses_width = 2.0 crosses_length = 6.0 crosses_offset = 3.0 -[node name="VisibleDisabler" type="Node" parent="HUD" node_paths=PackedStringArray("reference_player")] +[node name="VisibleDisabler" type="Node" parent="HUD"] script = ExtResource("4_smehm") -reference_player = NodePath("../..") [node name="Healthbar" type="ProgressBar" parent="HUD"] layout_mode = 1 @@ -8717,7 +8690,19 @@ script = ExtResource("13_xar7t") layout_mode = 2 script = ExtResource("13_x73hv") -[node name="PlayerPropertiesSync" type="MultiplayerSynchronizer" parent="."] +[node name="CenterContainer" type="CenterContainer" parent="HUD"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ClientSettings" parent="HUD/CenterContainer" instance=ExtResource("16_d267o")] +visible = false +layout_mode = 2 + +[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] replication_config = SubResource("SceneReplicationConfig_qhqgy") [node name="StepAudio" type="AudioStreamPlayer3D" parent="."] @@ -8773,7 +8758,7 @@ script = ExtResource("8_f1ej7") current_state = NodePath("Stand") metadata/_custom_type_script = "uid://3777rkbebgjm" -[node name="Crouch" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("stand_up_area", "player", "player_movement", "player_input", "animation_player", "weapon_system")] +[node name="Crouch" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("stand_up_area", "player", "player_movement", "animation_player", "weapon_system")] script = ExtResource("9_oprun") max_speed = 3.0 acceleration = 50.0 @@ -8781,39 +8766,36 @@ deceleration = 50.0 stand_up_area = NodePath("../../StandArea") player = NodePath("../..") player_movement = NodePath("../../PlayerMovement") -player_input = NodePath("../../PlayerInput") animation_player = NodePath("../../AnimationPlayer") weapon_system = NodePath("../../WeaponSystem") -[node name="Stand" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "player_input", "weapon_system", "audio")] +[node name="Stand" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "weapon_system", "audio")] script = ExtResource("10_a8ls1") max_speed = 6.0 acceleration = 100.0 deceleration = 50.0 -step_delay = 0.25 -step_speed_curve = SubResource("Curve_fbysy") +JUMP_VELOCITY = 6.0 player = NodePath("../..") player_movement = NodePath("../../PlayerMovement") -player_input = NodePath("../../PlayerInput") weapon_system = NodePath("../../WeaponSystem") audio = NodePath("../../StepAudio") +step_delay = 0.25 +step_speed_curve = SubResource("Curve_fbysy") -[node name="Walk" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "player_input", "weapon_system")] +[node name="Walk" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "weapon_system")] script = ExtResource("11_qfm1y") max_speed = 3.0 acceleration = 50.0 deceleration = 50.0 player = NodePath("../..") player_movement = NodePath("../../PlayerMovement") -player_input = NodePath("../../PlayerInput") weapon_system = NodePath("../../WeaponSystem") -[node name="Fall" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "player_input", "weapon_system", "land_sound")] +[node name="Fall" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "weapon_system", "land_sound")] script = ExtResource("12_fulsm") -acceleration = 25.0 player = NodePath("../..") player_movement = NodePath("../../PlayerMovement") -player_input = NodePath("../../PlayerInput") +acceleration = 25.0 weapon_system = NodePath("../../WeaponSystem") land_sound = NodePath("../../LandAudio") @@ -8821,18 +8803,15 @@ land_sound = NodePath("../../LandAudio") script = ExtResource("19_rwwcc") animation_player = NodePath("../../AnimationPlayer") -[node name="PlayerMovement" type="Node" parent="." node_paths=PackedStringArray("player", "player_input")] +[node name="PlayerMovement" type="Node" parent="." node_paths=PackedStringArray("player")] script = ExtResource("19_70eug") -jump_velocity = 12.0 player = NodePath("..") -player_input = NodePath("../PlayerInput") -[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("animation_player", "camera", "player", "player_input")] +[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("animation_player", "camera", "player")] script = ExtResource("4_qlg0r") animation_player = NodePath("../Camera3D/molikman_hands/AnimationPlayer") camera = NodePath("../Camera3D") player = NodePath("..") -player_input = NodePath("../PlayerInput") [node name="WeaponSpawner" type="MultiplayerSpawner" parent="WeaponSystem"] spawn_path = NodePath("..") @@ -8850,9 +8829,9 @@ libraries = { [node name="TeamUpdater" type="Node" parent="." node_paths=PackedStringArray("player")] script = ExtResource("7_a8ls1") +player = NodePath("..") layer = true inverse = true -player = NodePath("..") [node name="PickupRange" type="Area3D" parent="." node_paths=PackedStringArray("weapon_spawner", "weapon_system")] collision_layer = 0 @@ -8868,21 +8847,15 @@ shape = SubResource("CapsuleShape3D_3xmak") [node name="TeamMaterialSwitcher" type="Node" parent="." node_paths=PackedStringArray("player")] script = ExtResource("25_1mtds") material = ExtResource("26_r2jxp") -blue_team_texture = ExtResource("27_j3w78") player = NodePath("..") +blue_team_texture = ExtResource("27_j3w78") -[node name="Interaction" type="Node" parent="."] -script = ExtResource("37_5amik") - -[node name="PlayerInput" type="MultiplayerSynchronizer" parent="."] -replication_config = SubResource("SceneReplicationConfig_5amik") -script = ExtResource("37_b2eak") - +[connection signal="died" from="." to="molikman_ingame/VisibleEnabler" method="reverse"] [connection signal="died" from="." to="Camera3D" method="disable"] [connection signal="died" from="." to="Camera3D/DeadSpectator" method="set_active"] [connection signal="died" from="." to="BodyStateMachine/Death" method="on_death"] [connection signal="died" from="." to="PlayerMovement" method="disable"] [connection signal="died" from="." to="WeaponSystem" method="disable"] [connection signal="health_changed" from="." to="HUD/Healthbar" method="on_hp_changed"] -[connection signal="interact_begin" from="PlayerInput" to="Interaction" method="on_player_start_interacting"] -[connection signal="interact_end" from="PlayerInput" to="Interaction" method="on_player_end_interacting"] +[connection signal="spawned" from="." to="TeamUpdater" method="on_spawned"] +[connection signal="ammo_updated" from="WeaponSystem" to="HUD/AmmoDisplay" method="on_ammo_updated"] diff --git a/scripts/client_settings.gd b/scripts/client_settings.gd index 1b15ec0..741e8f1 100644 --- a/scripts/client_settings.gd +++ b/scripts/client_settings.gd @@ -2,6 +2,3 @@ extends Node var SENSITIVITY: float = 0.02 -var TOGGLE_CROUCH: bool = false -var TOGGLE_SCOPE: bool = false -var TOGGLE_WALK: bool = false diff --git a/scripts/gui/client_settings_menu.gd b/scripts/gui/client_settings_menu.gd index cc19bfd..5aaf95e 100644 --- a/scripts/gui/client_settings_menu.gd +++ b/scripts/gui/client_settings_menu.gd @@ -1,6 +1,5 @@ extends Control -var cached_mouse_state: Input.MouseMode func _on_check_button_toggled(toggled_on: bool) -> void: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN if toggled_on else DisplayServer.WINDOW_MODE_WINDOWED) @@ -18,11 +17,7 @@ func _on_spin_box_value_changed(value: float) -> void: func _input(event: InputEvent) -> void: if event.is_action_pressed("menu_settings"): visible = not visible - if visible: - cached_mouse_state = Input.mouse_mode - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - else: - Input.mouse_mode = cached_mouse_state + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE if visible else Input.MOUSE_MODE_CAPTURED func _on_gameplay_main_slider_value_changed(value: float) -> void: diff --git a/scripts/multiplayer/lobby.gd b/scripts/multiplayer/lobby.gd index d90dbda..da93c49 100644 --- a/scripts/multiplayer/lobby.gd +++ b/scripts/multiplayer/lobby.gd @@ -78,20 +78,6 @@ func set_teams(attack: Array[int],defence: Array[int],spectators: Array[int]): func switch_team(team: int) -> void: team_switch_notification.rpc(multiplayer.get_unique_id(),team) -func swap_teams() -> void: - if not multiplayer.is_server(): - return - - var temp_defenders = defence_team.duplicate() - - for attacker in attack_team: - server_team_switch.rpc(attacker,Session.TEAMS.DEFENCE) - - for defender in temp_defenders: - server_team_switch.rpc(defender,Session.TEAMS.ATTACK) - - update_peers.rpc() - @rpc("any_peer","call_local","reliable") func team_switch_notification(id: int, team: int) -> void: if (team == Session.TEAMS.DEFENCE and len(defence_team) > 4) or (team == Session.TEAMS.ATTACK and len(attack_team) > 4): @@ -119,32 +105,6 @@ func team_switch_notification(id: int, team: int) -> void: update_teams_state.emit() -@rpc("authority","call_local","reliable") -func server_team_switch(id: int, team: int) -> void: - if multiplayer.get_remote_sender_id() != 1 and not multiplayer.is_server(): - return - - if team == Session.TEAMS.DEFENCE: - if attack_team.has(id): - attack_team.erase(id) - if specators_team.has(id): - specators_team.erase(id) - defence_team.append(id) - - if team == Session.TEAMS.ATTACK: - if defence_team.has(id): - defence_team.erase(id) - if specators_team.has(id): - specators_team.erase(id) - attack_team.append(id) - - if team == Session.TEAMS.SPECTATE: - if attack_team.has(id): - attack_team.erase(id) - elif defence_team.has(id): - defence_team.erase(id) - specators_team.append(id) - @rpc("authority","call_local","reliable") func start_game() -> void: get_tree().change_scene_to_file("res://levels/prototype_scene.tscn") @@ -161,7 +121,3 @@ func get_team() -> Session.TEAMS: if specators_team.has(id): return Session.TEAMS.SPECTATE return Session.TEAMS.UNASSIGNED - -@rpc("authority","call_local","reliable") -func update_peers(): - update_teams_state.emit() diff --git a/scripts/multiplayer/own_visibility_toggle.gd b/scripts/multiplayer/own_visibility_toggle.gd index db47a4e..b2c51dd 100644 --- a/scripts/multiplayer/own_visibility_toggle.gd +++ b/scripts/multiplayer/own_visibility_toggle.gd @@ -1,12 +1,9 @@ extends Node -class_name PlayerBasedVisibility - @export var visible_for_others: bool = false -@export var reference_player: Player func _ready() -> void: - get_parent().visible = (reference_player.player_id != multiplayer.get_unique_id()) == visible_for_others + get_parent().visible = (get_multiplayer_authority() != multiplayer.get_unique_id()) == visible_for_others func reverse() -> void: get_parent().visible = not get_parent().visible diff --git a/scripts/multiplayer/player_input.gd b/scripts/multiplayer/player_input.gd deleted file mode 100644 index b234210..0000000 --- a/scripts/multiplayer/player_input.gd +++ /dev/null @@ -1,182 +0,0 @@ -extends MultiplayerSynchronizer - -class_name PlayerInput - -const SCOPE: int = 0b1 -const CROUCH: int = 0b10 -const WALK: int = 0b100 - -#region SYNC -@export var direction: Vector2 -@export var compressed_states: int -#endregion - -signal jumped -signal drop -signal switch_weapon(to_slot: StringName) -signal fire_begin -signal fire_end -signal alternate_state -signal switch_firemode -signal reload -signal scope_begin -signal scope_end -signal crouch_begin -signal crouch_end -signal walk_begin -signal walk_end -signal interact_begin -signal interact_end - -func _process(_delta: float) -> void: - if not is_multiplayer_authority(): return - direction = Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward") - -func _input(event: InputEvent) -> void: - if not is_multiplayer_authority(): return - if event.is_action_pressed("plr_ult"): - switch_on_server.rpc_id(1,"ultimate") - elif event.is_action_pressed("plr_bomb"): - switch_on_server.rpc_id(1,"bomb") - elif event.is_action_pressed("plr_primary"): - switch_on_server.rpc_id(1,"primary") - elif event.is_action_pressed("plr_active_first"): - switch_on_server.rpc_id(1,"ability_first") - elif event.is_action_pressed("plr_active_second"): - switch_on_server.rpc_id(1,"ability_second") - elif event.is_action_pressed("plr_active_third"): - switch_on_server.rpc_id(1,"ability_third") - elif event.is_action_pressed("plr_secondary"): - switch_on_server.rpc_id(1,"secondary") - elif event.is_action_pressed("plr_knife"): - switch_on_server.rpc_id(1,"knife") - - if event.is_action_pressed("plr_fire"): - fire_on_server.rpc_id(1,false) - if event.is_action_released("plr_fire"): - fire_on_server.rpc_id(1,true) - if event.is_action_pressed("plr_scope"): - alternate_state_on_server.rpc_id(1) - if event.is_action_pressed("plr_firemode"): - switch_firemode_on_server.rpc_id(1) - - if event.is_action_pressed("plr_drop"): - drop_on_server.rpc_id(1) - - var crouching: bool = compressed_states & CROUCH - var walking: bool = compressed_states & WALK - var scoping: bool = compressed_states & SCOPE - - if event.is_action_pressed("plr_crouch"): - if ClientSettings.TOGGLE_CROUCH: - crouch_on_server.rpc_id(1,crouching) - compressed_states ^= CROUCH - elif not crouching: - compressed_states |= CROUCH - crouch_on_server.rpc_id(1,false) - if event.is_action_released("plr_crouch") and not ClientSettings.TOGGLE_CROUCH and crouching: - compressed_states &= ~CROUCH - crouch_on_server.rpc_id(1,true) - - if event.is_action_pressed("plr_walk"): - if ClientSettings.TOGGLE_WALK: - walk_on_server.rpc_id(1,walking) - compressed_states ^= WALK - elif not walking: - compressed_states |= WALK - walk_on_server.rpc_id(1,false) - if event.is_action_released("plr_walk") and not ClientSettings.TOGGLE_WALK and walking: - compressed_states &= ~WALK - walk_on_server.rpc_id(1,true) - - if event.is_action_pressed("plr_scope"): - if ClientSettings.TOGGLE_SCOPE: - scope_on_server.rpc_id(1,scoping) - compressed_states ^= SCOPE - elif not scoping: - compressed_states |= SCOPE - scope_on_server.rpc_id(1,false) - if event.is_action_released("plr_scope") and not ClientSettings.TOGGLE_SCOPE and scoping: - compressed_states &= ~SCOPE - scope_on_server.rpc_id(1,true) - - if event.is_action_pressed("plr_reload"): - reload_on_server.rpc_id(1) - - if event.is_action_pressed("plr_interact"): - interact_on_server.rpc_id(1,false) - if event.is_action_released("plr_interact"): - interact_on_server.rpc_id(1,true) - - if event.is_action_pressed("plr_jump"): - jump_on_server.rpc_id(1) - -@rpc("authority","call_local","reliable") -func switch_on_server(slot: StringName) -> void: - if not multiplayer.is_server(): return - switch_weapon.emit(slot) - -@rpc("authority","call_local","reliable") -func drop_on_server() -> void: - if not multiplayer.is_server(): return - drop.emit() - -@rpc("authority","call_local","reliable") -func fire_on_server(end: bool) -> void: - if not multiplayer.is_server(): return - if end: - fire_end.emit() - else: - fire_begin.emit() - -@rpc("authority","call_local","reliable") -func alternate_state_on_server() -> void: - if not multiplayer.is_server(): return - alternate_state.emit() - -@rpc("authority","call_local","reliable") -func switch_firemode_on_server() -> void: - if not multiplayer.is_server(): return - switch_firemode.emit() - -@rpc("authority","call_local","reliable") -func crouch_on_server(end: bool) -> void: - if not multiplayer.is_server(): return - if end: - crouch_end.emit() - else: - crouch_begin.emit() - -@rpc("authority","call_local","reliable") -func walk_on_server(end: bool) -> void: - if not multiplayer.is_server(): return - if end: - walk_end.emit() - else: - walk_begin.emit() - -@rpc("authority","call_local","reliable") -func scope_on_server(end: bool) -> void: - if not multiplayer.is_server(): return - if end: - scope_end.emit() - else: - scope_begin.emit() - -@rpc("authority","call_local","reliable") -func reload_on_server() -> void: - if not multiplayer.is_server(): return - reload.emit() - -@rpc("authority","call_local","reliable") -func interact_on_server(end: bool) -> void: - if not multiplayer.is_server(): return - if end: - interact_end.emit() - else: - interact_begin.emit() - -@rpc("authority","call_local","reliable") -func jump_on_server() -> void: - if not multiplayer.is_server(): return - jumped.emit() diff --git a/scripts/multiplayer/player_input.gd.uid b/scripts/multiplayer/player_input.gd.uid deleted file mode 100644 index b86efb9..0000000 --- a/scripts/multiplayer/player_input.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dfvnx8f1v6m5g diff --git a/scripts/multiplayer/session.gd b/scripts/multiplayer/session.gd index 7810ba2..4bd2e79 100644 --- a/scripts/multiplayer/session.gd +++ b/scripts/multiplayer/session.gd @@ -86,7 +86,7 @@ func _process(_delta: float) -> void: func update_clock(time: float): reference_round_time = time -@rpc("authority","call_remote","reliable") +@rpc("any_peer","call_remote","reliable") func start_session() -> void: if not is_server_request(): return @@ -100,7 +100,7 @@ func start_session() -> void: start_round() -@rpc("authority","call_remote","reliable") +@rpc("any_peer","call_remote","reliable") func end_session() -> void: if not is_server_request(): return @@ -114,7 +114,7 @@ func end_session() -> void: session_started = false -@rpc("authority","call_remote","reliable") +@rpc("any_peer","call_remote","reliable") func start_round() -> void: if not is_server_request(): return @@ -134,26 +134,23 @@ func start_round() -> void: round_state = ROUND_STATES.BUY round_state_changed.emit.call_deferred(round_state) -@rpc("authority","call_remote","reliable") +@rpc("any_peer","call_remote","reliable") func end_round(win_team: int) -> void: if not is_server_request(): return if multiplayer.is_server(): get_tree().create_timer(5).timeout.connect(start_round) end_round.rpc(win_team) - if current_round == Lobby.half_rounds: - Lobby.swap_teams() if win_team == TEAMS.DEFENCE: defender_score += 1 elif win_team == TEAMS.ATTACK: attacker_score += 1 - round_state = ROUND_STATES.AFTER_ROUND round_state_changed.emit(round_state) -@rpc("authority","call_remote","reliable") +@rpc("any_peer","call_remote","reliable") func begin_main_stage() -> void: if not is_server_request(): return @@ -164,7 +161,7 @@ func begin_main_stage() -> void: round_state = ROUND_STATES.ROUND round_state_changed.emit(round_state) -@rpc("authority","call_remote","reliable") +@rpc("any_peer","call_remote","reliable") func begin_bomb_stage() -> void: if not is_server_request(): return @@ -182,6 +179,7 @@ func defuse_win() -> void: bomb_timer.stop() end_round(TEAMS.DEFENCE) +@rpc("any_peer","call_local","reliable") func add_dead(team: int): if multiplayer.is_server() == false: return @@ -206,7 +204,12 @@ func is_server_request() -> bool: ## ammo, remaining_ammo, slot - data for dropped weapon [br] ## for more, see dyn_objects_spawner.gd func spawn(data: Dictionary) -> void: + spawn_internal.rpc_id(1,data) + +@rpc("any_peer","call_local","reliable") +func spawn_internal(data: Dictionary) -> void: if multiplayer.is_server() == false: + printerr(str(multiplayer.get_remote_sender_id())+" tried to spawn internally on "+str(multiplayer.get_unique_id())) return var object = dynamic_objects_spawner.spawn(data) @@ -214,14 +217,25 @@ func spawn(data: Dictionary) -> void: if data.has("position"): object.global_position = data.position -func despawn(path: NodePath) -> void: +func despawn(path: NodePath): + despawn_internal.rpc_id(1,path) + +@rpc("any_peer","call_local","reliable") +func despawn_internal(path: NodePath) -> void: if multiplayer.is_server() == false: printerr(str(multiplayer.get_remote_sender_id())+" tried to despawn internally on "+str(multiplayer.get_unique_id())) return get_node(path).queue_free() -func shoot(id:int , damage: int, distance: float) -> void: +func shoot(damage: int,distance: float = 100) -> void: + if multiplayer.get_unique_id() == 1: + shoot_internal(1,damage,distance) + else: + shoot_internal.rpc_id(1,multiplayer.get_unique_id(),damage,distance) + +@rpc("any_peer","call_local","reliable") +func shoot_internal(id:int , damage: int, distance: float) -> void: if multiplayer.is_server() == false: return @@ -244,10 +258,16 @@ func shoot(id:int , damage: int, distance: float) -> void: var collision = space.intersect_ray(ray) if collision != {} and collision["collider"] is Player: - collision["collider"].take_damage(damage) + collision["collider"].take_damage.rpc_id(int(collision["collider"].name),damage) +func interact() -> void: + if multiplayer.get_unique_id() == 1: + interact_internal(1) + else: + interact_internal.rpc_id(1,multiplayer.get_unique_id()) -func interact(id: int) -> void: +@rpc("any_peer","call_local","reliable") +func interact_internal(id:int) -> void: if multiplayer.is_server() == false: return @@ -265,20 +285,27 @@ func interact(id: int) -> void: if collision != {} and collision["collider"] is Interactible: collision["collider"].interaction_start(id) -func stop_interact(id: int) -> void: +func stop_interact(): + if multiplayer.get_unique_id() == 1: + stop_interact_internal(1) + else: + stop_interact_internal.rpc_id(1,multiplayer.get_unique_id()) + +@rpc("any_peer","call_local","reliable") +func stop_interact_internal(id: int) -> void: if multiplayer.is_server() == false: return player_stopped_interacting.emit(id) -func is_on_site(id: int) -> bool: +func is_on_site() -> bool: for plant in plants: - if plant.is_player_on_site(id): + if plant.is_player_on_site(multiplayer.get_unique_id()): return true return false -func get_site(id: int) -> PlantSite: +func get_site() -> PlantSite: for plant in plants: - if plant.is_player_on_site(id): + if plant.is_player_on_site(multiplayer.get_unique_id()): return plant return null diff --git a/scripts/multiplayer/spawn_system/team_spawner.gd b/scripts/multiplayer/team_spawner.gd similarity index 76% rename from scripts/multiplayer/spawn_system/team_spawner.gd rename to scripts/multiplayer/team_spawner.gd index a7f73ff..e38e87a 100644 --- a/scripts/multiplayer/spawn_system/team_spawner.gd +++ b/scripts/multiplayer/team_spawner.gd @@ -15,8 +15,6 @@ func _exit_tree() -> void: Session.round_started.disconnect(spawn) func spawn(): - if not multiplayer.is_server(): - return match team: Session.TEAMS.ATTACK: for attacker in Lobby.attack_team: @@ -38,22 +36,18 @@ func spawn_player(id: int) -> void: elif team == Session.TEAMS.ATTACK: Session.attackers_alive += 1 - var distance = randf_range(0,spawn_radius) - var angle = randf_range(0,TAU) - var new_position = global_position + Vector3.RIGHT.rotated(Vector3.UP,angle) * distance - inst.player_id = id - inst.team = team - get_parent().add_child(inst) - inst.global_position = new_position + deferred_setup.bind(inst,team).call_deferred() func spawn_spectator(id: int) -> void: var spectator: PackedScene = load("res://scenes/spectator.tscn") var inst = spectator.instantiate() inst.name = str(id) + deferred_setup.bind(inst,Session.TEAMS.SPECTATE).call_deferred() + +func deferred_setup(what: Node3D, new_team: Session.TEAMS): + get_parent().add_child(what,true) var distance = randf_range(0,spawn_radius) var angle = randf_range(0,TAU) var new_position = global_position + Vector3.RIGHT.rotated(Vector3.UP,angle) * distance - inst.team = team - get_parent().add_child(inst) - inst.global_position = new_position + what.set_after_spawn.rpc_id(int(what.name),new_position,new_team) diff --git a/scripts/multiplayer/spawn_system/team_spawner.gd.uid b/scripts/multiplayer/team_spawner.gd.uid similarity index 100% rename from scripts/multiplayer/spawn_system/team_spawner.gd.uid rename to scripts/multiplayer/team_spawner.gd.uid diff --git a/scripts/player/collision_team_updater.gd b/scripts/player/collision_team_updater.gd index fa9c0c4..a4028bf 100644 --- a/scripts/player/collision_team_updater.gd +++ b/scripts/player/collision_team_updater.gd @@ -7,10 +7,17 @@ extends Node const ATTACK_LAYER: int = 0b10000 const DEFENCE_LAYER: int = 0b100000 -func _ready() -> void: - if is_multiplayer_authority() == false: return +func on_spawned() -> void: var mask = (ATTACK_LAYER if (player.team == Session.TEAMS.DEFENCE != inverse) else DEFENCE_LAYER) if layer: get_parent().collision_layer |= mask else: get_parent().collision_mask |= mask + global_update.rpc(layer,mask) + +@rpc +func global_update(new_layer,mask) -> void: + if new_layer: + get_parent().collision_layer |= mask + else: + get_parent().collision_mask |= mask diff --git a/scripts/player/dead_player_spectator.gd b/scripts/player/dead_player_spectator.gd index fa50239..1efc8fa 100644 --- a/scripts/player/dead_player_spectator.gd +++ b/scripts/player/dead_player_spectator.gd @@ -4,8 +4,9 @@ extends Camera3D var active: bool -func _enter_tree() -> void: - set_multiplayer_authority(int(get_parent().get_parent().name)) +func _ready() -> void: + if not is_multiplayer_authority(): + return func set_active() -> void: if not is_multiplayer_authority(): diff --git a/scripts/player/player.gd b/scripts/player/player.gd index 02b87fa..0dd68f7 100644 --- a/scripts/player/player.gd +++ b/scripts/player/player.gd @@ -4,14 +4,10 @@ class_name Player @export var team: Session.TEAMS @export var weapon_models: Dictionary[StringName,Node3D] -@export var player_id: int = 1: - set(id): - player_id = id - $PlayerInput.set_multiplayer_authority(id) - $Camera3D.set_multiplayer_authority(id) var passived: bool = false +signal spawned signal health_changed(to: int) signal died @@ -30,24 +26,52 @@ const MAX_HP = 100 get: return hp +func _enter_tree() -> void: + set_multiplayer_authority(str(name).to_int()) + func _physics_process(_delta: float) -> void: - if not multiplayer.is_server(): + if not is_multiplayer_authority(): return move_and_slide() func die() -> void: - if (not multiplayer.is_server()): + if (not is_multiplayer_authority()): return - Session.add_dead(team) + Session.add_dead.rpc(team) died.emit() passived = true +@rpc("any_peer","call_local","reliable") func passive() -> void: passived = true +@rpc("any_peer","call_local","reliable") func depassive() -> void: passived = false +@rpc("any_peer","call_local","reliable") +func kill_request() -> void: + if multiplayer.get_remote_sender_id() != 1: + return + + die() + +@rpc("any_peer","call_local","reliable") +func set_after_spawn(start_position: Vector3,new_team: int): + global_position = start_position + team = new_team as Session.TEAMS + spawned.emit() + +@rpc("any_peer","call_local","reliable") func take_damage(damage: int): hp -= damage + $DamageAudio.multiplayer_play() + +func _input(event: InputEvent) -> void: + if not is_multiplayer_authority(): + return + if event.is_action_pressed("plr_interact"): + Session.interact() + if event.is_action_released("plr_interact"): + Session.stop_interact() diff --git a/scripts/player/player_interaction.gd b/scripts/player/player_interaction.gd deleted file mode 100644 index ab041f8..0000000 --- a/scripts/player/player_interaction.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Node - - -func on_player_start_interacting(): - Session.interact(get_parent().player_id) - -func on_player_end_interacting(): - Session.stop_interact(get_parent().player_id) diff --git a/scripts/player/player_interaction.gd.uid b/scripts/player/player_interaction.gd.uid deleted file mode 100644 index 202792c..0000000 --- a/scripts/player/player_interaction.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dsp1sq46c5i3y diff --git a/scripts/player/player_movement.gd b/scripts/player/player_movement.gd index 74dce84..84f1f42 100644 --- a/scripts/player/player_movement.gd +++ b/scripts/player/player_movement.gd @@ -3,9 +3,6 @@ extends Node class_name PlayerMovement @export var player: Player -@export var player_input: PlayerInput - -@export var jump_velocity: float var disabled: bool func disable() -> void: @@ -18,7 +15,7 @@ func process_movement(max_speed: float,acceleration: float,deceleration: float,d player.velocity.x = 0 player.velocity.z = 0 return - var input_dir := player_input.direction + var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward") var direction := (player.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() if direction: player.velocity.x = clamp(player.velocity.x + direction.x * acceleration * delta,-max_speed*abs(direction.x),max_speed*abs(direction.x)) @@ -26,6 +23,3 @@ func process_movement(max_speed: float,acceleration: float,deceleration: float,d else: player.velocity.x = move_toward(player.velocity.x, 0, deceleration*delta) player.velocity.z = move_toward(player.velocity.z, 0, deceleration*delta) - -func jump() -> void: - player.velocity.y = jump_velocity diff --git a/scripts/player/states/crouching.gd b/scripts/player/states/crouching.gd index 5783cfd..9bdff3f 100644 --- a/scripts/player/states/crouching.gd +++ b/scripts/player/states/crouching.gd @@ -8,22 +8,22 @@ extends State @export var stand_up_area: Area3D @export var player: Player @export var player_movement: PlayerMovement -@export var player_input: PlayerInput @export var animation_player: AnimationPlayer @export var crouch_time: float = 0.1 @export var weapon_system: WeaponSystem func enter() -> void: animation_player.play("crouch",-1,1/crouch_time) - player_input.crouch_end.connect(try_end_crouch) func exit() -> void: animation_player.play("crouch",-1,-1/crouch_time,true) - player_input.crouch_end.disconnect(try_end_crouch) func physics_update(delta: float) -> void: if not is_multiplayer_authority(): return + if Input.is_action_just_pressed("plr_jump") and player.is_on_floor() and toggle: + transition.emit("Stand") + return if not player.is_on_floor(): transition.emit("Fall") @@ -31,6 +31,7 @@ func physics_update(delta: float) -> void: player_movement.process_movement(max_speed * weapon_system.get_speed_modifier(),acceleration,deceleration,delta) -func try_end_crouch() -> void: - if player.is_on_floor() and stand_up_area.has_overlapping_bodies() == false: - transition.emit("Stand") +func state_input(event: InputEvent) -> void: + if (toggle == true and event.is_action_pressed("plr_crouch")) or (toggle == false and event.is_action_released("plr_crouch")): + if stand_up_area.has_overlapping_bodies() == false: + transition.emit("Stand") diff --git a/scripts/player/states/falling.gd b/scripts/player/states/falling.gd index 2b7750a..317fe1c 100644 --- a/scripts/player/states/falling.gd +++ b/scripts/player/states/falling.gd @@ -2,7 +2,6 @@ extends State @export var player: Player @export var player_movement: PlayerMovement -@export var player_input: PlayerInput @export var max_speed: float = 5.0 @export var acceleration: float @export var weapon_system: WeaponSystem @@ -19,12 +18,7 @@ func physics_update(delta: float) -> void: if not is_multiplayer_authority(): return if player.is_on_floor(): - if player_input.compressed_states & PlayerInput.CROUCH: - transition.emit("Crouch") - elif player_input.compressed_states & PlayerInput.WALK: - transition.emit("Walk") - else: - transition.emit("Stand") + transition.emit("Stand") land_sound.multiplayer_play() player.velocity += player.get_gravity() * delta diff --git a/scripts/player/states/standing.gd b/scripts/player/states/standing.gd index 31151a0..f98fb74 100644 --- a/scripts/player/states/standing.gd +++ b/scripts/player/states/standing.gd @@ -3,9 +3,9 @@ extends State @export var max_speed: float = 5.0 @export var acceleration: float = 2.0 @export var deceleration: float = 200.0 +@export var JUMP_VELOCITY: float = 4.5 @export var player: Player @export var player_movement: PlayerMovement -@export var player_input: PlayerInput @export var weapon_system: WeaponSystem @export var audio: MultiplayerAudio3D @export var step_delay: float @@ -14,19 +14,18 @@ extends State var step_time: float func enter() -> void: - player_input.jumped.connect(on_jumped) - player_input.crouch_begin.connect(begin_crouch) - player_input.walk_begin.connect(begin_walk) + pass func exit() -> void: - player_input.jumped.disconnect(on_jumped) - player_input.crouch_begin.disconnect(begin_crouch) - player_input.walk_begin.disconnect(begin_walk) step_time = 0 func physics_update(delta: float) -> void: if not is_multiplayer_authority(): return + if Input.is_action_just_pressed("plr_jump") and player.is_on_floor(): + player.velocity.y = JUMP_VELOCITY * sign(weapon_system.get_speed_modifier()) + transition.emit("Fall") + return if not player.is_on_floor(): transition.emit("Fall") @@ -39,13 +38,9 @@ func physics_update(delta: float) -> void: player_movement.process_movement(max_speed * weapon_system.get_speed_modifier(),acceleration,deceleration,delta) -func on_jumped() -> void: - if player.is_on_floor(): - player_movement.jump() - transition.emit("Fall") - -func begin_walk() -> void: - transition.emit("Walk") - -func begin_crouch() -> void: - transition.emit("Crouch") +func state_input(event: InputEvent) -> void: + if event.is_action_pressed("plr_crouch"): + transition.emit("Crouch") + + if event.is_action_pressed("plr_walk"): + transition.emit("Walk") diff --git a/scripts/player/states/walk.gd b/scripts/player/states/walk.gd index 8d31be5..579e7d1 100644 --- a/scripts/player/states/walk.gd +++ b/scripts/player/states/walk.gd @@ -6,22 +6,21 @@ extends State @export var JUMP_VELOCITY: float = 4.5 @export var player: Player @export var player_movement: PlayerMovement -@export var player_input: PlayerInput @export var weapon_system: WeaponSystem func enter() -> void: - player_input.crouch_begin.connect(begin_crouch) - player_input.walk_end.connect(end_walk) - player_input.jumped.connect(on_jumped) + pass func exit() -> void: - player_input.crouch_begin.disconnect(begin_crouch) - player_input.walk_end.disconnect(end_walk) - player_input.jumped.disconnect(on_jumped) + pass func physics_update(delta: float) -> void: if not is_multiplayer_authority(): return + if Input.is_action_just_pressed("plr_jump") and player.is_on_floor(): + player.velocity.y = JUMP_VELOCITY + transition.emit("Fall") + return if not player.is_on_floor(): transition.emit("Fall") @@ -29,13 +28,9 @@ func physics_update(delta: float) -> void: player_movement.process_movement(max_speed * weapon_system.get_speed_modifier(),acceleration,deceleration,delta) -func on_jumped() -> void: - if player.is_on_floor(): - player_movement.jump() - transition.emit("Fall") - -func end_walk() -> void: - transition.emit("Stand") - -func begin_crouch() -> void: - transition.emit("Crouch") +func state_input(event: InputEvent) -> void: + if event.is_action_released("plr_walk"): + transition.emit("Stand") + + if event.is_action_pressed("plr_crouch"): + transition.emit("Crouch") diff --git a/scripts/player/team_color_switcher.gd b/scripts/player/team_color_switcher.gd index f855555..3410814 100644 --- a/scripts/player/team_color_switcher.gd +++ b/scripts/player/team_color_switcher.gd @@ -5,5 +5,8 @@ extends Node @export var blue_team_texture: Texture2D func _ready() -> void: + get_tree().create_timer(1).timeout.connect(on_player_spawned) + +func on_player_spawned() -> void: if player.team == Session.TEAMS.DEFENCE: material.albedo_texture = blue_team_texture diff --git a/scripts/state_machine/machine.gd b/scripts/state_machine/machine.gd index bfcd0dd..9735686 100644 --- a/scripts/state_machine/machine.gd +++ b/scripts/state_machine/machine.gd @@ -13,7 +13,6 @@ func _ready() -> void: else: push_warning("Child of state machine is not state") - current_state.enter() func on_transition_required(to: StringName): if is_multiplayer_authority() == false: @@ -31,7 +30,7 @@ func change_state(to_state: State) -> void: current_state = to_state current_state.enter() -@rpc("authority","call_local","reliable") +@rpc func change_state_to_name(to_name: StringName): if current_state != null: current_state.exit() diff --git a/scripts/weapon_system/bomb/active_bomb.gd b/scripts/weapon_system/bomb/active_bomb.gd index dcc2419..d981d1e 100644 --- a/scripts/weapon_system/bomb/active_bomb.gd +++ b/scripts/weapon_system/bomb/active_bomb.gd @@ -40,10 +40,10 @@ func interaction_start(player_id: int): super(player_id) defuse_timer.start() $DefuseAudio.multiplayer_play() - Session.player_nodes[player_id].passive() + Session.player_nodes[player_id].passive.rpc_id(player_id) func interaction_end(): - Session.player_nodes[interacted_id].depassive() + Session.player_nodes[interacted_id].depassive.rpc_id(interacted_id) super() defuse_timer.stop() diff --git a/scripts/weapon_system/bomb/bomb_idle_state.gd b/scripts/weapon_system/bomb/bomb_idle_state.gd index 2761471..0d2c89c 100644 --- a/scripts/weapon_system/bomb/bomb_idle_state.gd +++ b/scripts/weapon_system/bomb/bomb_idle_state.gd @@ -7,6 +7,6 @@ func enter() -> void: func exit() -> void: pass -func use_begin() -> void: - if Session.is_on_site(machine.player.player_id): +func state_input(event: InputEvent) -> void: + if event.is_action("plr_bomb") and Session.is_on_site(): transition.emit("Plant") diff --git a/scripts/weapon_system/bomb/bomb_main_state.gd b/scripts/weapon_system/bomb/bomb_main_state.gd index 88e86d0..869e343 100644 --- a/scripts/weapon_system/bomb/bomb_main_state.gd +++ b/scripts/weapon_system/bomb/bomb_main_state.gd @@ -3,9 +3,8 @@ extends WeaponState func enter(): machine.animation_player.play(machine.animation_prefix+"plant") machine.animation_player.animation_finished.connect(on_animation_finished) - if is_multiplayer_authority(): - machine.speed_modifier = 0.0 - machine.player.get_node("PlantAudio").multiplayer_play() + machine.speed_modifier = 0.0 + machine.player.get_node("PlantAudio").multiplayer_play() func exit(): machine.animation_player.animation_finished.disconnect(on_animation_finished) @@ -15,13 +14,15 @@ func on_animation_finished(animation: StringName): if is_multiplayer_authority() == false: return if animation == machine.animation_prefix + "plant": - Session.spawn({"type": "object","spawn_name": "active_bomb", "position": machine.player_camera.get_parent().global_position,"plant": Session.get_site(machine.player.player_id).name}) + + Session.spawn({"type": "object","spawn_name": "active_bomb", "position": machine.player_camera.get_parent().global_position,"plant": Session.get_site().name}) machine.ammo -= 1 return_to_previous.emit() -func use_end() -> void: +func state_input(event: InputEvent) -> void: if is_multiplayer_authority() == false: return - transition.emit("Idle") - machine.player.get_node("PlantAudio").multiplayer_stop() + if event.is_action_released("plr_bomb"): + transition.emit("Idle") + machine.player.get_node("PlantAudio").multiplayer_stop() diff --git a/scripts/weapon_system/gun/idle_state.gd b/scripts/weapon_system/gun/idle_state.gd index 821a3dd..bda469f 100644 --- a/scripts/weapon_system/gun/idle_state.gd +++ b/scripts/weapon_system/gun/idle_state.gd @@ -4,10 +4,15 @@ extends WeaponState func enter() -> void: machine.animation_player.play(with_morphems("idle")) - machine.player.get_node("PlayerInput").reload.connect(init_reload) func exit() -> void: - machine.player.get_node("PlayerInput").reload.disconnect(init_reload) + pass + +func state_input(event: InputEvent) -> void: + if not machine.is_multiplayer_authority() or Input.mouse_mode != Input.MouseMode.MOUSE_MODE_CAPTURED: return + + if event.is_action_pressed("plr_reload"): + init_reload.rpc() func use_begin() -> void: if machine.ammo > 0: diff --git a/scripts/weapon_system/gun/semi_auto_shoot_state.gd b/scripts/weapon_system/gun/semi_auto_shoot_state.gd index f603f64..d60f8a8 100644 --- a/scripts/weapon_system/gun/semi_auto_shoot_state.gd +++ b/scripts/weapon_system/gun/semi_auto_shoot_state.gd @@ -31,6 +31,7 @@ func use_begin() -> void: func fire() -> void: if machine.ammo == 0 or fire_timer.time_left > 0: return + machine.player.get_node("ShootAudio").multiplayer_play() machine.ammo -= 1 bullets_shot += 1 @@ -38,8 +39,7 @@ func fire() -> void: machine.animation_player.play(with_morphems("shoot")) if is_multiplayer_authority(): - Session.shoot(int(machine.player.name),damage,shoot_distance) - machine.player.get_node("ShootAudio").multiplayer_play() + Session.shoot(damage,shoot_distance) fire_timer.start() machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot)) diff --git a/scripts/weapon_system/knife/knife_attack.gd b/scripts/weapon_system/knife/knife_attack.gd index 57285f6..5b1ef7b 100644 --- a/scripts/weapon_system/knife/knife_attack.gd +++ b/scripts/weapon_system/knife/knife_attack.gd @@ -14,7 +14,7 @@ func exit() -> void: func attack() -> void: if is_multiplayer_authority(): - Session.shoot(int(machine.player.name),damage,1.5) + Session.shoot(damage,1.5) func on_animation_finished(animation): if animation == machine.animation_prefix + "attack": diff --git a/scripts/weapon_system/knife/knife_attack_heavy.gd b/scripts/weapon_system/knife/knife_attack_heavy.gd index 2b5a557..68d1739 100644 --- a/scripts/weapon_system/knife/knife_attack_heavy.gd +++ b/scripts/weapon_system/knife/knife_attack_heavy.gd @@ -12,7 +12,7 @@ func exit() -> void: func attack() -> void: if is_multiplayer_authority(): - Session.shoot(int(machine.player.name),damage,1.5) + Session.shoot(damage,1.5) func on_animation_finished(animation): if animation == machine.animation_prefix + "heavy_attack": diff --git a/scripts/weapon_system/weapon_substate_machine.gd b/scripts/weapon_system/weapon_substate_machine.gd index d7e1752..d70ef96 100644 --- a/scripts/weapon_system/weapon_substate_machine.gd +++ b/scripts/weapon_system/weapon_substate_machine.gd @@ -64,7 +64,6 @@ func exit() -> void: @rpc("authority","call_local","reliable") func use_begin() -> void: current_state.use_begin() - @rpc("authority","call_local","reliable") func use_end() -> void: current_state.use_end() diff --git a/scripts/weapon_system/weapon_system.gd b/scripts/weapon_system/weapon_system.gd index f30d7f5..2ecb45c 100644 --- a/scripts/weapon_system/weapon_system.gd +++ b/scripts/weapon_system/weapon_system.gd @@ -5,7 +5,6 @@ class_name WeaponSystem @export var animation_player: AnimationPlayer @export var camera: PlayerCamera @export var player: Player -@export var player_input: PlayerInput var current_state: WeaponSubStateMachine var last_slot: StringName @@ -28,12 +27,6 @@ signal ammo_updated(ammo: int, remaining_ammo: int) func _ready() -> void: $WeaponSpawner.spawn_function = pick_up_weapon - player_input.drop.connect(drop_current) - player_input.fire_begin.connect(use_begin) - player_input.fire_end.connect(use_end) - player_input.switch_weapon.connect(switch) - player_input.alternate_state.connect(alternate_state) - player_input.switch_firemode.connect(switch_mode) func get_speed_modifier() -> float: if current_state == null: @@ -71,9 +64,8 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa ammo_updated.emit(current_state.ammo,current_state.remaining_ammo) state.enter.call_deferred() -@rpc("authority","call_remote","reliable") func switch(to: StringName, exit: bool = true): - if slots.has(to) == false or slots[to] == null or slots[to] == current_state or (multiplayer.get_remote_sender_id() != 1 and is_multiplayer_authority() == false): + if slots.has(to) == false or slots[to] == null or slots[to] == current_state or is_multiplayer_authority() == false: return if current_state != null and exit: current_state.exit() @@ -86,8 +78,8 @@ func switch(to: StringName, exit: bool = true): ammo_updated.emit(current_state.ammo,current_state.remaining_ammo) switched_to.emit(current_state) - if is_multiplayer_authority(): - switch.rpc(to,exit) + + update_remotes.rpc(to,exit) func return_to_previous(exit: bool = true): if last_slot != "": @@ -95,12 +87,19 @@ func return_to_previous(exit: bool = true): else: switch("knife", exit) +@rpc("authority","call_remote","reliable") +func update_remotes(to: StringName,exit: bool): + if current_state != null and exit: + current_state.exit() + current_state = slots[to] + current_state.enter() + + switched_to.emit(current_state) + func drop_current(): drop(current_state) func drop(weapon: WeaponSubStateMachine) -> void: - if not is_multiplayer_authority(): - return if slots.find_key(weapon) == "knife": return var drop_data: Dictionary = {} @@ -175,14 +174,39 @@ func _physics_process(delta: float) -> void: return current_state.physics_update(delta) -func use_begin() -> void: - current_state.use_begin.rpc() - -func use_end() -> void: - current_state.use_end.rpc() - -func alternate_state() -> void: - current_state.alternate_state() - -func switch_mode() -> void: - current_state.switch_mode() +func _input(event: InputEvent) -> void: + if is_multiplayer_authority() == false or disabled: return + + if current_state != null: + current_state.state_input(event) + + 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 not Session.round_state == Session.ROUND_STATES.BUY and not player.passived: + if event.is_action_pressed("plr_fire"): + current_state.use_begin.rpc() + if event.is_action_released("plr_fire"): + current_state.use_end.rpc() + if event.is_action_pressed("plr_scope"): + current_state.alternate_state() + if event.is_action_pressed("plr_firemode"): + current_state.switch_mode() + + if event.is_action_pressed("plr_drop"): + drop_current() +