Many fixes

This commit is contained in:
Rendo 2025-12-17 01:59:35 +05:00
commit e758c9f042
11 changed files with 8784 additions and 8739 deletions

View file

@ -6,10 +6,10 @@ func _on_visibility_changed() -> void:
process_mode = Node.PROCESS_MODE_INHERIT if visible else Node.PROCESS_MODE_DISABLED process_mode = Node.PROCESS_MODE_INHERIT if visible else Node.PROCESS_MODE_DISABLED
func _process(_delta: float) -> void: func _process(_delta: float) -> void:
return
if player_id == -1: if player_id == -1:
%PlayerNickname.text = "" %PlayerNickname.text = ""
%Money.text = "" %Money.text = ""
else: else:
if Session.player_data.has(player_id):
%PlayerNickname.text = Session.player_data[player_id]["nickname"] %PlayerNickname.text = Session.player_data[player_id]["nickname"]
%Money.text = str(Session.player_data[player_id]["money"]) %Money.text = str(Session.player_data[player_id]["money"])

View file

@ -8,6 +8,7 @@ signal lobby_created
signal lobby_joined signal lobby_joined
signal lobby_closed signal lobby_closed
signal update_teams_state signal update_teams_state
signal client_data_updated(id)
var in_lobby: bool = false var in_lobby: bool = false
@ -36,6 +37,7 @@ func player_left(id: int) -> void:
client_nicknames.erase(id) client_nicknames.erase(id)
update_teams_state.emit() update_teams_state.emit()
client_data_updated.emit(-id)
func server_disconnected() -> void: func server_disconnected() -> void:
leave() leave()
@ -84,6 +86,7 @@ func recieve_client_data(data: Dictionary):
client_nicknames[id] = nickname client_nicknames[id] = nickname
sync_client_data.rpc(client_nicknames) sync_client_data.rpc(client_nicknames)
client_data_updated.emit(id)
@rpc("authority","call_remote") @rpc("authority","call_remote")
func sync_client_data(new_client_nicknames: Dictionary[int,StringName]): func sync_client_data(new_client_nicknames: Dictionary[int,StringName]):

View file

@ -87,6 +87,8 @@ func send_session_data(peer_id: int = -1):
if multiplayer.is_server() == false or session_started_flag == false: if multiplayer.is_server() == false or session_started_flag == false:
return return
init_player_data(peer_id)
var data: PackedByteArray var data: PackedByteArray
data.resize(5) data.resize(5)
data.encode_u8(0,current_round) data.encode_u8(0,current_round)
@ -95,11 +97,29 @@ func send_session_data(peer_id: int = -1):
data.encode_u8(3,round_state) data.encode_u8(3,round_state)
data.encode_u8(4,session_started_flag) data.encode_u8(4,session_started_flag)
if peer_id == -1: if peer_id == -1:
recieve_session_data.rpc(data,player_data) recieve_session_data.rpc(data,player_data)
else: else:
recieve_session_data.rpc_id(peer_id,data,player_data) recieve_session_data.rpc_id(peer_id,data,player_data)
func init_player_data(id: int) -> void:
if Lobby.client_nicknames.has(id) == false:
while true:
var wait_id = await Lobby.client_data_updated
if wait_id == id:
break
elif wait_id == -id:
return
player_data[id] = {
"money" : START_MONEY,
"nickname" : Lobby.client_nicknames[id],
"saved_slots" : {},
"kills" : 0,
"deaths" : 0,
}
@rpc("authority","call_remote","unreliable") @rpc("authority","call_remote","unreliable")
func recieve_session_data(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]): func recieve_session_data(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]):
if not is_server_request(): if not is_server_request():

File diff suppressed because one or more lines are too long

View file

@ -76,3 +76,9 @@ func take_damage(damage: int):
hp -= damage hp -= damage
damaged.emit() damaged.emit()
$DamageAudio.multiplayer_play() $DamageAudio.multiplayer_play()
func show_weapon(weapon: StringName):
for model in weapon_models:
weapon_models[model].hide()
if weapon_models.has(weapon):
weapon_models[weapon].show()

View file

@ -65,11 +65,10 @@ func _ready() -> void:
func _enter() -> void: func _enter() -> void:
super() super()
player.weapon_models[weapon_gid].show() player.show_weapon(weapon_gid)
func _exit() -> void: func _exit() -> void:
super() super()
player.weapon_models[weapon_gid].hide()
func use_begin() -> void: func use_begin() -> void:
if current_state != null: if current_state != null:

View file

@ -97,8 +97,9 @@ func switch(to: StringName, exit: bool = true):
if exit: if exit:
current_state._exit() current_state._exit()
if current_state.can_be_previous: if current_state.can_be_previous:
var found = slots.find_key(current_state) last_slot = get_current_slot()
last_slot = found if found else "" else:
last_slot = ""
current_state = slots[to] current_state = slots[to]
current_state._enter() current_state._enter()
@ -107,11 +108,20 @@ func switch(to: StringName, exit: bool = true):
notify_slots_updated() notify_slots_updated()
func return_to_previous(exit: bool = true): func return_to_previous(exit: bool = true):
if last_slot == get_current_slot():
last_slot = "knife"
if last_slot != "": if last_slot != "":
switch(last_slot, exit) switch(last_slot, exit)
else: else:
switch("knife", exit) switch("knife", exit)
func get_current_slot() -> StringName:
if current_state == null:
return "knife"
else:
var found = slots.find_key(current_state)
return found if found else ""
func drop_current(): func drop_current():
drop(current_state) drop(current_state)
@ -180,7 +190,7 @@ func notify_slots_updated():
else: else:
display_slots[key] = slots[key].weapon_gid display_slots[key] = slots[key].weapon_gid
var current_slot: StringName = "" var current_slot: StringName = ""
var found = slots.find_key(current_state) var found = get_current_slot()
if found: if found:
current_slot = found current_slot = found

View file

@ -50,9 +50,9 @@ vertical_curve = SubResource("Curve_cmn6f")
horizontal_curve = SubResource("Curve_016ti") horizontal_curve = SubResource("Curve_016ti")
damage_reduction_curve = SubResource("Curve_bwg3m") damage_reduction_curve = SubResource("Curve_bwg3m")
emptyable = true emptyable = true
torso_damage = 22 torso_damage = 35
head_damage = 60 head_damage = 80
limb_damage = 12 limb_damage = 22
fire_timer = NodePath("../FireTimer") fire_timer = NodePath("../FireTimer")
[node name="Reload" type="Node" parent="."] [node name="Reload" type="Node" parent="."]

View file

@ -15,14 +15,15 @@ func _physics_process(delta: float) -> void:
var collision = move_and_collide(velocity * delta) var collision = move_and_collide(velocity * delta)
if collision: if collision:
if collision.get_normal().y > 0: if collision.get_normal().y > 0.05:
var fire: Node3D = preload("res://weapons/molikman/molik/molikman_molotov_fire.tscn").instantiate() var fire: Node3D = preload("res://weapons/molikman/molik/molikman_molotov_fire.tscn").instantiate()
Session.dynamic_objects_parent.add_child(fire,true) Session.dynamic_objects_parent.add_child(fire,true)
fire.global_position = global_position fire.global_position = global_position
fire.quaternion *= Quaternion(Vector3.UP,collision.get_normal())
queue_free() queue_free()
else: else:
var normal = collision.get_normal() var normal = collision.get_normal()
velocity = velocity.bounce(normal) * 0.5 velocity = velocity.bounce(normal) * 0.5
$MultiplayerAudio3D.multiplayer_play() $MultiplayerAudio3D.multiplayer_play()
$molotov2.quaternion *= Quaternion($molotov2.basis.y, velocity.normalized()) $molotov.quaternion *= Quaternion($molotov.basis.y, velocity.normalized())

View file

@ -18,7 +18,7 @@ properties/0/replication_mode = 1
collision_layer = 8 collision_layer = 8
script = ExtResource("1_aqokr") script = ExtResource("1_aqokr")
[node name="molotov2" parent="." instance=ExtResource("2_dcuri")] [node name="molotov" parent="." instance=ExtResource("2_dcuri")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_aqokr") shape = SubResource("SphereShape3D_aqokr")

View file

@ -12,6 +12,33 @@
[ext_resource type="Texture2D" uid="uid://va158xyrsvb4" path="res://textures/players/molikman/molotov/fire_particle.png" id="7_18xly"] [ext_resource type="Texture2D" uid="uid://va158xyrsvb4" path="res://textures/players/molikman/molotov/fire_particle.png" id="7_18xly"]
[ext_resource type="AudioStream" uid="uid://blnblkd6eoldv" path="res://audio/molik_idle.ogg" id="7_apqju"] [ext_resource type="AudioStream" uid="uid://blnblkd6eoldv" path="res://audio/molik_idle.ogg" id="7_apqju"]
[sub_resource type="Animation" id="Animation_bwl5g"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Decal:texture_albedo")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("2_fm7jn")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Decal:texture_emission")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("2_fm7jn")]
}
[sub_resource type="Animation" id="Animation_m625o"] [sub_resource type="Animation" id="Animation_m625o"]
resource_name = "main" resource_name = "main"
loop_mode = 1 loop_mode = 1
@ -41,33 +68,6 @@ tracks/1/keys = {
"values": [ExtResource("2_fm7jn"), ExtResource("3_18xly"), ExtResource("4_wpp30"), ExtResource("5_66mwf"), ExtResource("6_bt4sy")] "values": [ExtResource("2_fm7jn"), ExtResource("3_18xly"), ExtResource("4_wpp30"), ExtResource("5_66mwf"), ExtResource("6_bt4sy")]
} }
[sub_resource type="Animation" id="Animation_bwl5g"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Decal:texture_albedo")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("2_fm7jn")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Decal:texture_emission")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("2_fm7jn")]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_oujc3"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_oujc3"]
_data = { _data = {
&"RESET": SubResource("Animation_bwl5g"), &"RESET": SubResource("Animation_bwl5g"),
@ -75,6 +75,7 @@ _data = {
} }
[sub_resource type="CylinderShape3D" id="CylinderShape3D_fm7jn"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_fm7jn"]
height = 1.0615234
radius = 3.5 radius = 3.5
[sub_resource type="Gradient" id="Gradient_18xly"] [sub_resource type="Gradient" id="Gradient_18xly"]
@ -168,6 +169,9 @@ properties/0/replication_mode = 1
properties/1/path = NodePath("Decal:size") properties/1/path = NodePath("Decal:size")
properties/1/spawn = true properties/1/spawn = true
properties/1/replication_mode = 1 properties/1/replication_mode = 1
properties/2/path = NodePath(".:rotation")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="MolikmanMolotovFire" type="Area3D" node_paths=PackedStringArray("damage_timer")] [node name="MolikmanMolotovFire" type="Area3D" node_paths=PackedStringArray("damage_timer")]
collision_layer = 8 collision_layer = 8
@ -177,10 +181,11 @@ dps = 33.333
damage_timer = NodePath("DamageTimer") damage_timer = NodePath("DamageTimer")
[node name="Decal" type="Decal" parent="."] [node name="Decal" type="Decal" parent="."]
size = Vector3(7.5, 3, 7.5) size = Vector3(7.5, 3.2404785, 7.5)
texture_albedo = ExtResource("2_fm7jn") texture_albedo = ExtResource("2_fm7jn")
texture_emission = ExtResource("2_fm7jn") texture_emission = ExtResource("2_fm7jn")
emission_energy = 0.25 emission_energy = 0.25
normal_fade = 0.75
cull_mask = 1048572 cull_mask = 1048572
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -190,6 +195,7 @@ libraries = {
autoplay = "main" autoplay = "main"
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.46923828, 0)
shape = SubResource("CylinderShape3D_fm7jn") shape = SubResource("CylinderShape3D_fm7jn")
[node name="IdleParticles" type="GPUParticles3D" parent="."] [node name="IdleParticles" type="GPUParticles3D" parent="."]