Compare commits

...

11 commits

Author SHA1 Message Date
11eb875d2e Grenade bounce and radius 2025-12-10 00:43:05 +05:00
f99108c4f0 alleged fixes 2025-12-10 00:08:57 +05:00
e6a47a4772 Fixed some errors 2025-12-09 23:54:02 +05:00
87919ed890 State machine rework 2025-12-09 22:34:17 +05:00
3f99f1b8dd Refactor Part II 2025-12-09 21:02:29 +05:00
cd20f952ce Shop 2025-12-09 12:27:04 +05:00
06c5fea9bd why are you here 2025-12-09 11:58:13 +05:00
0589ca4e23 Global refactor 2025-12-09 11:53:52 +05:00
3868af29e3 Very bad implementation of shop and grenade 2025-12-09 10:46:13 +05:00
e9f4c6e5f8 Money 2025-12-08 22:03:29 +05:00
4e8971b12d Buy menu 2025-12-08 21:04:18 +05:00
189 changed files with 961 additions and 666 deletions

Binary file not shown.

View file

@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://dstie24qkbc86"]
[ext_resource type="PackedScene" uid="uid://bv6ptrditssow" path="res://scenes/gui/client_settings.tscn" id="1_yqjtg"]
[ext_resource type="PackedScene" uid="uid://cbtp4rvg66ba1" path="res://scenes/main_menu.tscn" id="2_lnu2h"]
[ext_resource type="Script" uid="uid://dj4mlrime72hx" path="res://scripts/multiplayer/level_container.gd" id="3_lnu2h"]
[ext_resource type="PackedScene" uid="uid://bv6ptrditssow" path="res://gui/client_settings/client_settings.tscn" id="1_yqjtg"]
[ext_resource type="PackedScene" uid="uid://cbtp4rvg66ba1" path="res://gui/main_menu/main_menu.tscn" id="2_lnu2h"]
[ext_resource type="Script" uid="uid://dj4mlrime72hx" path="res://multiplayer/level_container.gd" id="3_lnu2h"]
[node name="Game" type="Node"]

View file

@ -0,0 +1,16 @@
extends Button
@export var weapon: WeaponResource
func _ready() -> void:
icon = weapon.preview
text = str(weapon.cost)
func _pressed() -> void:
try_server_buy.rpc_id(1)
@rpc("any_peer","call_local","reliable")
func try_server_buy() -> void:
if not multiplayer.is_server():
return
Shop.buy(multiplayer.get_remote_sender_id(),weapon)

View file

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

View file

@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://b1ej6kmbjpm78"]
[ext_resource type="Texture2D" uid="uid://dnxw4x3cmu7io" path="res://icon.svg" id="1_apu4l"]
[ext_resource type="Script" uid="uid://bq32y7eee1f63" path="res://gui/buy_menu/buy_button/buy_button.gd" id="1_impj7"]
[node name="BuyButton" type="Button"]
anchors_preset = -1
anchor_right = 0.035
anchor_bottom = 0.075
offset_right = -4.799999
offset_bottom = -14.000004
text = "3600"
icon = ExtResource("1_apu4l")
icon_alignment = 1
vertical_icon_alignment = 0
expand_icon = true
script = ExtResource("1_impj7")

29
gui/buy_menu/buy_menu.gd Normal file
View file

@ -0,0 +1,29 @@
extends ColorRect
func _ready() -> void:
Session.round_state_changed.connect(on_round_state_changed)
func on_round_state_changed(state: int) -> void:
if state != Session.ROUND_STATES.BUY:
visible = false
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _input(event: InputEvent) -> void:
if event.is_action_pressed("plr_buy"):
if Session.round_state == Session.ROUND_STATES.BUY:
visible = not visible
else:
visible = false
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

View file

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

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=5 format=3 uid="uid://j5lgbg8c0pq"]
[ext_resource type="PackedScene" uid="uid://b1ej6kmbjpm78" path="res://gui/buy_menu/buy_button/buy_button.tscn" id="1_8guql"]
[ext_resource type="Script" uid="uid://dba17sgimp4j0" path="res://gui/buy_menu/buy_menu.gd" id="1_ko0fn"]
[ext_resource type="Resource" uid="uid://b081hg7uxx1wu" path="res://weapons/molikman_molotov.tres" id="2_0gws3"]
[ext_resource type="Script" uid="uid://dk4diwvruvkch" path="res://gui/buy_menu/player_money_label.gd" id="2_ll0n6"]
[node name="BuyMenu" type="ColorRect"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.22745098)
script = ExtResource("1_ko0fn")
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
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"]
layout_mode = 2
[node name="AbilitiesContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
script = ExtResource("2_ll0n6")
[node name="WeaponsContainer" type="GridContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
columns = 5
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
layout_mode = 2
[node name="BuyButton" parent="CenterContainer/PanelContainer/AbilitiesContainer/HBoxContainer" instance=ExtResource("1_8guql")]
layout_mode = 2
weapon = ExtResource("2_0gws3")

View file

@ -0,0 +1,7 @@
extends Label
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
var data = Session.get_player_data()
if data.has("money"):
text = str(data["money"])

View file

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

29
gui/buy_menu/shop.gd Normal file
View file

@ -0,0 +1,29 @@
extends Node
func can_buy(player_id: int,weapon: WeaponResource) -> bool:
return Session.player_data[player_id]["money"] >= weapon.cost
func buy(player_id: int, weapon: WeaponResource) -> void:
if not multiplayer.is_server() or can_buy(player_id,weapon) == false:
return
var player: Player = Session.player_nodes[player_id]
if player.hp == 0:
return
var weapon_system: WeaponSystem = player.get_node("%WeaponSystem")
var slot: StringName = ""
match weapon.slot:
"ability":
slot = weapon_system.get_empty_ability_slot()
var anything:
slot = anything
if not weapon_system.can_add(slot):
return
var player_data = Session.player_data[player_id]
player_data["money"] -= weapon.cost
weapon_system.add(weapon.weapon_system_scene.instantiate(),slot)

1
gui/buy_menu/shop.gd.uid Normal file
View file

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

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bv6ptrditssow"]
[ext_resource type="Script" uid="uid://ddi1alk8oyi1b" path="res://scripts/gui/client_settings_menu.gd" id="1_xqyus"]
[ext_resource type="Script" uid="uid://ddi1alk8oyi1b" path="res://gui/client_settings/client_settings_menu.gd" id="1_xqyus"]
[node name="ClientSettingsMenu" type="CanvasLayer"]
layer = 3

View file

@ -1,5 +1,4 @@
extends Label
func on_ammo_updated(ammo: int, remaining_ammo: int):
text = str(ammo)+"/"+str(remaining_ammo)

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://cbtp4rvg66ba1"]
[ext_resource type="Script" uid="uid://bsyuos803g7qf" path="res://scripts/gui/main_menu_gui.gd" id="1_l6cm7"]
[ext_resource type="Script" uid="uid://dh64rv15w8ecl" path="res://scripts/multiplayer/host_menu.gd" id="2_ekxnf"]
[ext_resource type="Script" uid="uid://bsyuos803g7qf" path="res://gui/main_menu/main_menu_gui.gd" id="1_l6cm7"]
[ext_resource type="Script" uid="uid://dh64rv15w8ecl" path="res://gui/main_menu/host_menu.gd" id="2_ekxnf"]
[node name="MainMenu" type="CenterContainer"]
anchors_preset = 15

View file

@ -1,7 +1,5 @@
extends Control
var cached_mouse_state: Input.MouseMode
func _on_spectator_button_pressed() -> void:
if Lobby.get_team() != Session.TEAMS.SPECTATE:
Lobby.switch_team(Session.TEAMS.SPECTATE)
@ -31,7 +29,9 @@ func _input(event: InputEvent) -> void:
func update_mouse() -> void:
if visible:
cached_mouse_state = Input.mouse_mode
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
Input.mouse_mode = cached_mouse_state
if Session.session_started_flag:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

View file

@ -0,0 +1,47 @@
[gd_scene load_steps=2 format=3 uid="uid://cmon3g1lsm3q"]
[ext_resource type="Script" uid="uid://m8qq2eynls6n" path="res://gui/team_choice/team_choice_menu.gd" id="1_kch1g"]
[node name="TeamChoiceMenu" type="CenterContainer"]
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_kch1g")
[node name="Panel" type="PanelContainer" parent="."]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
layout_mode = 2
[node name="Label" type="Label" parent="Panel/VBoxContainer"]
layout_mode = 2
text = "Choose your team"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"]
layout_mode = 2
[node name="SpectatorButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Spectators"
[node name="AttackButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Attackers"
[node name="DefenceButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Defenders"
[node name="CancelButton" type="Button" parent="Panel/VBoxContainer"]
layout_mode = 2
text = "Cancel"
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/SpectatorButton" to="." method="_on_spectator_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/AttackButton" to="." method="_on_attack_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/DefenceButton" to="." method="_on_defence_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]

View file

@ -6,20 +6,20 @@
[ext_resource type="Material" uid="uid://mlha6r17v2en" path="res://materials/DarkBluemat.tres" id="5_bno23"]
[ext_resource type="Material" uid="uid://duvlktlyurohd" path="res://materials/Yellowmat.tres" id="5_foctg"]
[ext_resource type="Material" uid="uid://jdfticwelku4" path="res://materials/Greenmat.tres" id="6_8bje3"]
[ext_resource type="Script" uid="uid://dncldab5y4yod" path="res://scripts/item_spawner.gd" id="6_61ure"]
[ext_resource type="PackedScene" uid="uid://cxdgk74ln5xpn" path="res://scenes/weapons/droppable_bomb.tscn" id="6_bno23"]
[ext_resource type="Script" uid="uid://dncldab5y4yod" path="res://systems/item_spawner.gd" id="6_61ure"]
[ext_resource type="PackedScene" uid="uid://cxdgk74ln5xpn" path="res://weapons/bomb/droppable_bomb.tscn" id="6_bno23"]
[ext_resource type="Material" uid="uid://cyej4ph6hcnou" path="res://materials/Orangemat.tres" id="6_foctg"]
[ext_resource type="Script" uid="uid://bqjv6l7hh0lix" path="res://scripts/multiplayer/spawn_system/dyn_objects_spawner.gd" id="6_oujx2"]
[ext_resource type="Material" uid="uid://cdeggf10dmama" path="res://materials/Purplemat.tres" id="7_8bje3"]
[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="Script" uid="uid://dk1gjbuydemmb" path="res://multiplayer/plant_site/plant_site.gd" id="8_oujx2"]
[ext_resource type="Script" uid="uid://b4cpux52fmx5o" path="res://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"]
[ext_resource type="Script" uid="uid://bala54fa32e35" path="res://scripts/gui/hud/player_round_display.gd" id="17_wsuwo"]
[ext_resource type="Script" uid="uid://bos7nftlx8tv3" path="res://scripts/gui/hud/player_round_time.gd" id="18_0hcup"]
[ext_resource type="Script" uid="uid://m8qq2eynls6n" path="res://scripts/gui/team_choice_menu.gd" id="19_0hcup"]
[ext_resource type="PackedScene" uid="uid://l4t1mflutm3t" path="res://scenes/projectiles/molikman/molikman_molotov_fire.tscn" id="20_gcyg7"]
[ext_resource type="Script" uid="uid://ypgm3aplt78m" path="res://multiplayer/team_spawner.gd" id="10_02ic3"]
[ext_resource type="Script" uid="uid://3i00rp8urth7" path="res://systems/object_container.gd" id="11_02ic3"]
[ext_resource type="Script" uid="uid://xwiw2g6uc21k" path="res://multiplayer/dynamic_objects_parent.gd" id="11_gcyg7"]
[ext_resource type="Script" uid="uid://bala54fa32e35" path="res://gui/hud/player_round_display.gd" id="17_wsuwo"]
[ext_resource type="Script" uid="uid://bos7nftlx8tv3" path="res://gui/hud/player_round_time.gd" id="18_0hcup"]
[ext_resource type="PackedScene" uid="uid://cmon3g1lsm3q" path="res://gui/team_choice/team_choice_menu.tscn" id="19_gcyg7"]
[ext_resource type="PackedScene" uid="uid://j5lgbg8c0pq" path="res://gui/buy_menu/buy_menu.tscn" id="20_gcyg7"]
[sub_resource type="BoxShape3D" id="BoxShape3D_ysk2e"]
size = Vector3(15.324341, 0.96273804, 21.381592)
@ -267,12 +267,12 @@ 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)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 37.170197, 0.5, -11.271502)
script = ExtResource("10_02ic3")
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)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -31.553003, 0.49999988, 20.371899)
script = ExtResource("10_02ic3")
team = 1
spawn_radius = 5.0
@ -289,12 +289,14 @@ spawn_path = NodePath("..")
[node name="DynamicObjectsContainer" type="Node3D" parent="." node_paths=PackedStringArray("exlusion_list")]
script = ExtResource("11_02ic3")
exlusion_list = [NodePath("MultiplayerSpawner"), NodePath("Bomb")]
exlusion_list = [NodePath("MultiplayerSpawner"), NodePath("Bomb"), NodePath("Parenter")]
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="DynamicObjectsContainer"]
_spawnable_scenes = PackedStringArray("uid://cxdgk74ln5xpn", "uid://dgfqppi21c2u0")
_spawnable_scenes = PackedStringArray("uid://cxdgk74ln5xpn", "uid://dtbpyfdawb02b", "uid://dgfqppi21c2u0", "uid://b6qahd6q60js7", "uid://l4t1mflutm3t")
spawn_path = NodePath("..")
script = ExtResource("6_oujx2")
[node name="Parenter" type="Node" parent="DynamicObjectsContainer"]
script = ExtResource("11_gcyg7")
[node name="Bomb" type="Node3D" parent="DynamicObjectsContainer"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -28.858309, 1.4657042, 12.873563)
@ -375,49 +377,7 @@ script = ExtResource("18_0hcup")
layout_mode = 2
script = ExtResource("17_wsuwo")
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"]
[node name="TeamChoiceMenu" parent="CanvasLayer" instance=ExtResource("19_gcyg7")]
[node name="BuyMenu" parent="CanvasLayer" instance=ExtResource("20_gcyg7")]
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("19_0hcup")
[node name="Panel" type="PanelContainer" parent="CanvasLayer/CenterContainer"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/CenterContainer/Panel"]
layout_mode = 2
[node name="Label" type="Label" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer"]
layout_mode = 2
text = "Choose your team"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer"]
layout_mode = 2
[node name="SpectatorButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Spectators"
[node name="AttackButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Attackers"
[node name="DefenceButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Defenders"
[node name="CancelButton" type="Button" parent="CanvasLayer/CenterContainer/Panel/VBoxContainer"]
layout_mode = 2
text = "Cancel"
[node name="MolikmanMolotovFire" parent="." instance=ExtResource("20_gcyg7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -25.65116, 0.67484045, 14.924126)
[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer/SpectatorButton" to="CanvasLayer/CenterContainer" method="_on_spectator_button_pressed"]
[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer/AttackButton" to="CanvasLayer/CenterContainer" method="_on_attack_button_pressed"]
[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/HBoxContainer/DefenceButton" to="CanvasLayer/CenterContainer" method="_on_defence_button_pressed"]
[connection signal="pressed" from="CanvasLayer/CenterContainer/Panel/VBoxContainer/CancelButton" to="CanvasLayer/CenterContainer" method="_on_cancel_button_pressed"]

View file

@ -2,11 +2,11 @@
[ext_resource type="Environment" uid="uid://ybeuqwdb504c" path="res://environments/split_environment.tres" id="1_muj2s"]
[ext_resource type="Material" uid="uid://bx3f5vx71ynh5" path="res://materials/Graymat.tres" id="4_mj4b4"]
[ext_resource type="Script" uid="uid://3i00rp8urth7" path="res://scripts/object_container.gd" id="9_klida"]
[ext_resource type="Script" uid="uid://ypgm3aplt78m" path="res://scripts/multiplayer/team_spawner.gd" id="10_n3y50"]
[ext_resource type="Script" uid="uid://bqjv6l7hh0lix" path="res://scripts/multiplayer/spawn_system/dyn_objects_spawner.gd" id="11_ydk8w"]
[ext_resource type="Script" uid="uid://dncldab5y4yod" path="res://scripts/item_spawner.gd" id="12_kry5j"]
[ext_resource type="PackedScene" uid="uid://cxdgk74ln5xpn" path="res://scenes/weapons/droppable_bomb.tscn" id="13_hy0sx"]
[ext_resource type="Script" uid="uid://3i00rp8urth7" path="res://systems/object_container.gd" id="9_klida"]
[ext_resource type="Script" uid="uid://ypgm3aplt78m" path="res://multiplayer/team_spawner.gd" id="10_n3y50"]
[ext_resource type="Script" path="res://multiplayer/spawn_system/dyn_objects_spawner.gd" id="11_ydk8w"]
[ext_resource type="Script" uid="uid://dncldab5y4yod" path="res://systems/item_spawner.gd" id="12_kry5j"]
[ext_resource type="PackedScene" uid="uid://cxdgk74ln5xpn" path="res://weapons/bomb/droppable_bomb.tscn" id="13_hy0sx"]
[node name="PrototypeScene" type="Node3D"]

View file

@ -0,0 +1,6 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Session.dynamic_objects_parent = get_parent()

View file

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

View file

@ -16,6 +16,9 @@ enum ROUND_STATES {
AFTER_SESSION = 5,
}
const WIN_MONEY: int = 3400
const LOSE_MONEY: int = 2000
const ATTACK_LAYER: int = 0b10000
const DEFENCE_LAYER: int = 0b100000
@ -27,27 +30,26 @@ signal round_state_changed(state: int)
signal player_stopped_interacting(id: int)
var player_nodes: Dictionary[int,Player] = {}
var object_containers: Array[ObjectContainer]
var player_data: Dictionary[int,Dictionary] = {}
var dynamic_objects_spawner: MultiplayerSpawner
var dynamic_objects_parent: Node3D
var object_containers: Array[ObjectContainer]
var plants: Array[PlantSite]
var plant_deadzones: Dictionary[StringName, Area3D]
var session_started_flag: bool = false
var round_state: ROUND_STATES
var current_round: int = 0
var attacker_score: int = 0
var defender_score: int = 0
var attackers_alive: int = 0
var defenders_alive: int = 0
var reference_round_time: float
var bomb_timer: Timer
var round_timer: Timer
var buy_timer: Timer
var round_state: ROUND_STATES
var session_started_flag: bool = false
var reference_round_time: float
func _ready() -> void:
if multiplayer.is_server() == false:
return
@ -72,6 +74,7 @@ func _ready() -> void:
add_child(buy_timer)
multiplayer.peer_connected.connect(sync_session_server)
multiplayer.peer_disconnected.connect(delete_player)
func sync_session_server(id: int):
if multiplayer.is_server() == false or session_started_flag == false:
@ -86,11 +89,11 @@ func sync_session_server(id: int):
data.encode_u8(4,defenders_alive)
data.encode_u8(5,round_state)
sync_session_client.rpc_id(id,data)
sync_session_client.rpc_id(id,data,player_data)
late_player_connected.emit(id)
@rpc("authority","call_remote","reliable")
func sync_session_client(data: PackedByteArray):
func sync_session_client(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]):
if not is_server_request():
return
@ -101,7 +104,36 @@ func sync_session_client(data: PackedByteArray):
defenders_alive = data.decode_u8(4)
round_state = data.decode_u8(5) as ROUND_STATES
session_started.emit()
player_data = players_data_sent
func send_session_data():
if multiplayer.is_server() == false or session_started_flag == false:
return
var data: PackedByteArray
data.resize(6)
data.encode_u8(0,current_round)
data.encode_u8(1,attacker_score)
data.encode_u8(2,defender_score)
data.encode_u8(3,attackers_alive)
data.encode_u8(4,defenders_alive)
data.encode_u8(5,round_state)
recieve_session_data.rpc(data,player_data)
@rpc("authority","call_remote","unreliable")
func recieve_session_data(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]):
if not is_server_request():
return
current_round = data.decode_u8(0)
attacker_score = data.decode_u8(1)
defender_score = data.decode_u8(2)
attackers_alive = data.decode_u8(3)
defenders_alive = data.decode_u8(4)
round_state = data.decode_u8(5) as ROUND_STATES
session_started.emit()
player_data = players_data_sent
func _process(_delta: float) -> void:
if multiplayer.is_server() == false or not session_started:
@ -116,6 +148,7 @@ func _process(_delta: float) -> void:
_:
reference_round_time = 0
update_clock.rpc(reference_round_time)
send_session_data()
@rpc("authority","call_remote","unreliable")
func update_clock(time: float):
@ -138,6 +171,14 @@ func start_session() -> void:
round_timer.wait_time = Lobby.round_time
buy_timer.wait_time = Lobby.buy_time
var all_players: PackedInt32Array = multiplayer.get_peers()
all_players.append(multiplayer.get_unique_id())
for player in all_players:
player_data[player] = {
"money" : 800,
"nickname" : "Seliboba"
}
start_round()
@rpc("authority","call_remote","reliable")
@ -155,9 +196,10 @@ func end_session() -> void:
session_started_flag = false
dynamic_objects_spawner = null
plants = []
plant_deadzones = {}
dynamic_objects_parent = null
func quit_session() -> void:
if multiplayer.is_server():
@ -205,8 +247,16 @@ func end_round(win_team: int) -> void:
if win_team == TEAMS.DEFENCE:
defender_score += 1
for defender in Lobby.defence_team:
player_data[defender].money += WIN_MONEY
for attacker in Lobby.attack_team:
player_data[attacker].money += LOSE_MONEY
elif win_team == TEAMS.ATTACK:
attacker_score += 1
for defender in Lobby.defence_team:
player_data[defender].money += LOSE_MONEY
for attacker in Lobby.attack_team:
player_data[attacker].money += WIN_MONEY
round_state = ROUND_STATES.AFTER_ROUND
@ -256,30 +306,6 @@ func add_dead(team: int):
func is_server_request() -> bool:
return multiplayer.is_server() or multiplayer.get_remote_sender_id() == 1
## Spawns dynamic object at game scene [br]
## Dictionary keys: [br]
## (Required) scene - path/uuid to scene [br]
## (Optional) position - position to spawn [br]
## (Optional) impulse - impulse to apply [br]
## (Optional but required for each other) [br]
## ammo, remaining_ammo, slot - data for dropped weapon [br]
## for more, see dyn_objects_spawner.gd
func spawn(data: Dictionary) -> void:
if multiplayer.is_server() == false:
return
var object = dynamic_objects_spawner.spawn(data)
if data.has("position"):
object.global_position = data.position
func despawn(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:
if multiplayer.is_server() == false:
return
@ -353,3 +379,19 @@ func kill_site(site: StringName) -> void:
func sync_score(attack: int, defence: int):
attacker_score = attack
defender_score = defence
@rpc("authority","call_remote","reliable")
func delete_player(id: int):
if not is_server_request():
return
if multiplayer.is_server():
delete_player.rpc_id(id)
player_data.erase(id)
func get_player_data() -> Dictionary:
var id: int = multiplayer.get_unique_id()
if player_data.has(id):
return player_data[id]
else:
return {}

View file

@ -32,7 +32,7 @@ func spawn():
spawn_spectator(specator)
func spawn_player(id: int) -> void:
var player: PackedScene = load("res://scenes/molikman.tscn")
var player: PackedScene = preload("uid://dpsr6ug3pkb40")
var inst: Player = player.instantiate()
Session.player_nodes[id] = inst
inst.name = str(id)
@ -50,7 +50,7 @@ func spawn_player(id: int) -> void:
inst.global_position = new_position
func spawn_spectator(id: int) -> void:
var spectator: PackedScene = load("res://scenes/spectator.tscn")
var spectator: PackedScene = load("res://players/spectator.tscn")
var inst = spectator.instantiate()
inst.name = str(id)

File diff suppressed because one or more lines are too long

View file

@ -1,33 +1,38 @@
extends Area3D
@export var weapon_spawner: MultiplayerSpawner
@export var weapon_system: WeaponSystem
var disabled: bool
func _ready() -> void:
if is_multiplayer_authority() == false: return
body_entered.connect(on_body_entered)
func disable() -> void:
disabled = true
func on_body_entered(body: Node3D):
if disabled:
return
if body is DroppableWeapon:
if weapon_system.can_add(body.slot) == false or (body.team != Session.TEAMS.UNASSIGNED and get_parent().team != body.team):
return
weapon_spawner.spawn({
"ammo": body.weapon.ammo,
"remaining_ammo": body.weapon.remaining_ammo,
"scene_file_path": body.weapon.scene_file_path,
"slot": body.slot
})
var weapon: WeaponSubStateMachine = body.weapon.duplicate()
weapon_system.add(weapon,weapon.slot)
Session.despawn(body.get_path())
body.queue_free()
func start_temp_ignore():
if disabled:
return
if is_multiplayer_authority() == false:
return
monitoring = false
get_tree().create_timer(0.5).timeout.connect(stop_temp_ignore)
func stop_temp_ignore():
if disabled:
return
if is_multiplayer_authority() == false:
return
monitoring = true

View file

@ -13,11 +13,11 @@ extends State
@export var crouch_time: float = 0.1
@export var weapon_system: WeaponSystem
func enter() -> void:
func _enter() -> void:
animation_player.play("crouch",-1,1/crouch_time)
player_input.crouch_end.connect(try_end_crouch)
func exit() -> void:
func _exit() -> void:
animation_player.play("crouch",-1,-1/crouch_time,true)
player_input.crouch_end.disconnect(try_end_crouch)

View file

@ -5,8 +5,8 @@ extends State
func on_death() -> void:
transition.emit("Death")
func enter() -> void:
func _enter() -> void:
animation_player.play("die")
func exit() -> void:
func _exit() -> void:
pass

View file

@ -8,10 +8,10 @@ extends State
@export var weapon_system: WeaponSystem
@export var land_sound: MultiplayerAudio3D
func enter() -> void:
func _enter() -> void:
pass
func exit() -> void:
func _exit() -> void:
pass

View file

@ -13,12 +13,13 @@ 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)
func _enter() -> void:
if Session.is_server_request():
player_input.jumped.connect(on_jumped)
player_input.crouch_begin.connect(begin_crouch)
player_input.walk_begin.connect(begin_walk)
func exit() -> void:
func _exit() -> void:
player_input.jumped.disconnect(on_jumped)
player_input.crouch_begin.disconnect(begin_crouch)
player_input.walk_begin.disconnect(begin_walk)

View file

@ -9,12 +9,12 @@ extends State
@export var player_input: PlayerInput
@export var weapon_system: WeaponSystem
func enter() -> void:
func _enter() -> void:
player_input.crouch_begin.connect(begin_crouch)
player_input.walk_end.connect(end_walk)
player_input.jumped.connect(on_jumped)
func exit() -> void:
func _exit() -> void:
player_input.crouch_begin.disconnect(begin_crouch)
player_input.walk_end.disconnect(end_walk)
player_input.jumped.disconnect(on_jumped)

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://ckjabjcvgki6n"]
[ext_resource type="Script" uid="uid://cikw7fcykkpd5" path="res://scripts/player/spectator.gd" id="1_jjbhc"]
[ext_resource type="Script" uid="uid://cikw7fcykkpd5" path="res://spectator.gd" id="1_jjbhc"]
[node name="Spectator" type="Camera3D"]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)

View file

@ -0,0 +1,5 @@
[gd_scene format=3 uid="uid://eaali3lbode2"]
[node name="WeaponSpawner" type="MultiplayerSpawner"]
_spawnable_scenes = PackedStringArray("uid://djwjl8xll53vn", "uid://ts4xccpkjd3g", "uid://bxdatd1ilfgmc", "uid://c5q7e5dj86187")
spawn_path = NodePath("..")

View file

@ -20,18 +20,25 @@ config/icon="res://icon.svg"
[autoload]
PlayerGlobal="*res://scripts/player/player_global.gd"
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"
PlayerGlobal="*res://players/player/player_global.gd"
Lobby="*res://multiplayer/lobby.gd"
Session="*res://multiplayer/session.gd"
ClientSettings="*res://gui/client_settings/client_settings.gd"
ClientSettingsMenu="res://gui/client_settings/client_settings.tscn"
Registry="*res://systems/registry.gd"
Shop="*res://gui/buy_menu/shop.gd"
[display]
window/size/viewport_width=1280
window/size/viewport_height=720
[file_customization]
folder_colors={
"res://gui/": "green"
}
[input]
plr_forward={
@ -164,6 +171,11 @@ menu_team_choice={
"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":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null)
]
}
plr_buy={
"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":66,"key_label":0,"unicode":98,"location":0,"echo":false,"script":null)
]
}
[layer_names]

View file

@ -1,49 +0,0 @@
[gd_scene load_steps=8 format=3 uid="uid://cheu6vds21er7"]
[ext_resource type="Script" uid="uid://t5jjqwnkxgvo" path="res://scripts/smoke_grenade.gd" id="1_acmqr"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_acmqr"]
bounce = 0.5
[sub_resource type="CapsuleMesh" id="CapsuleMesh_vb5ru"]
radius = 0.1
height = 0.5
[sub_resource type="FastNoiseLite" id="FastNoiseLite_acmqr"]
frequency = 0.1141
[sub_resource type="NoiseTexture3D" id="NoiseTexture3D_rx0m8"]
width = 128
height = 128
depth = 128
noise = SubResource("FastNoiseLite_acmqr")
[sub_resource type="FogMaterial" id="FogMaterial_rx0m8"]
resource_local_to_scene = true
density = 8.0
density_texture = SubResource("NoiseTexture3D_rx0m8")
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_acmqr"]
radius = 0.1
height = 0.5
[node name="Smoke" type="RigidBody3D" node_paths=PackedStringArray("fog")]
physics_material_override = SubResource("PhysicsMaterial_acmqr")
contact_monitor = true
max_contacts_reported = 1
script = ExtResource("1_acmqr")
radius = 10.0
fog = NodePath("FogVolume")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("CapsuleMesh_vb5ru")
[node name="FogVolume" type="FogVolume" parent="."]
size = Vector3(0, 0, 0)
shape = 0
material = SubResource("FogMaterial_rx0m8")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_acmqr")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View file

@ -1,6 +0,0 @@
extends Resource
@export var internal_id: StringName
@export var immediate: bool
@export var max_uses: int
@export var cost: int

View file

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

View file

@ -1,7 +0,0 @@
extends Node
func _ready() -> void:
Lobby.lobby_joined.connect(on_lobby_joined)
func on_lobby_joined() -> void:
$StartButton.hide()

View file

@ -1 +0,0 @@
uid://2uyxkfmbbims

View file

@ -1,7 +0,0 @@
extends Node
func _ready() -> void:
if not multiplayer.is_server():
return
Lobby.add_loaded_player(multiplayer.get_unique_id())

View file

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

View file

@ -1,44 +0,0 @@
extends MultiplayerSpawner
func _ready() -> void:
spawn_function = request_spawn
Session.dynamic_objects_spawner = self
func request_spawn(data: Variant) -> Node:
if data.has("type") == false or data.has("spawn_name") == false:
return Node.new()
match data.type:
"weapon":
var weapon: DroppableWeapon = Registry.weapons[data.spawn_name].dropped_scene.instantiate()
weapon.apply_central_impulse(data.impulse)
weapon.weapon.ammo = data.ammo
weapon.weapon.remaining_ammo = data.remaining_ammo
weapon.slot = Registry.weapons[data.spawn_name].slot
for key in data.keys():
if key == "impulse" or key == "ammo" or key == "remaining_ammo":
continue
weapon.set(key,data[key])
return weapon
"projectile":
var projectile: RigidBody3D = Registry.spawnable_objects[data.spawn_name].instantiate()
projectile.apply_central_impulse(data.impulse)
for key in data.keys():
if key == "impulse":
continue
projectile.set(key,data[key])
return projectile
"object":
var object: Node3D = Registry.spawnable_objects[data.spawn_name].instantiate()
for key in data.keys():
object.set(key,data[key])
return object
_:
return Node.new()

View file

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

Some files were not shown because too many files have changed in this diff Show more