Fixed some errors

This commit is contained in:
Rendo 2025-12-09 23:54:02 +05:00
commit e6a47a4772
9 changed files with 32 additions and 32 deletions

View file

@ -267,12 +267,12 @@ script = ExtResource("11_02ic3")
exlusion_list = [NodePath("DefenceSpawn"), NodePath("AttackSpawn"), NodePath("SpectatorSpawn"), NodePath("MultiplayerSpawner")] exlusion_list = [NodePath("DefenceSpawn"), NodePath("AttackSpawn"), NodePath("SpectatorSpawn"), NodePath("MultiplayerSpawner")]
[node name="DefenceSpawn" type="Marker3D" parent="PlayersContainer"] [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") script = ExtResource("10_02ic3")
spawn_radius = 10.0 spawn_radius = 10.0
[node name="AttackSpawn" type="Marker3D" parent="PlayersContainer"] [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") script = ExtResource("10_02ic3")
team = 1 team = 1
spawn_radius = 5.0 spawn_radius = 5.0

View file

@ -14,9 +14,10 @@ extends State
var step_time: float var step_time: float
func _enter() -> void: func _enter() -> void:
player_input.jumped.connect(on_jumped) if Session.is_server_request():
player_input.crouch_begin.connect(begin_crouch) player_input.jumped.connect(on_jumped)
player_input.walk_begin.connect(begin_walk) 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.jumped.disconnect(on_jumped)

View file

@ -13,6 +13,8 @@ func _ready() -> void:
else: else:
push_warning("Child of state machine is not state") push_warning("Child of state machine is not state")
await get_tree().process_frame
await get_tree().process_frame
current_state.enter() current_state.enter()
func on_transition_required(to: StringName): func on_transition_required(to: StringName):

View file

@ -5,10 +5,11 @@ class_name SubStateMachine
@export var enter_state: State @export var enter_state: State
func _enter() -> void: func _enter() -> void:
change_state(enter_state) if is_multiplayer_authority():
change_state(enter_state)
func _exit() -> void: func _exit() -> void:
current_state.exit() pass
func update(delta: float) -> void: func update(delta: float) -> void:
if current_state == null: if current_state == null:

View file

@ -56,7 +56,10 @@ func add(state: WeaponSubStateMachine, slot: StringName) -> void:
if current_state == null: if current_state == null:
current_state = state current_state = state
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo) ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
state._enter.call_deferred() #Replace with way to ensure all players loaded
await get_tree().process_frame
await get_tree().process_frame
state._enter()
func process_spawned_weapon(weapon_node: Node): func process_spawned_weapon(weapon_node: Node):
@ -83,13 +86,13 @@ 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 (multiplayer.get_remote_sender_id() != 1 and is_multiplayer_authority() == false):
return return
if current_state != null and exit: if current_state != null and exit:
current_state._exit() current_state.exit()
if current_state.can_be_previous: if current_state.can_be_previous:
last_slot = slots.find_key(current_state) last_slot = slots.find_key(current_state)
else: else:
last_slot = "" last_slot = ""
current_state = slots[to] current_state = slots[to]
current_state._enter() current_state.enter()
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo) ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
switched_to.emit(current_state) switched_to.emit(current_state)

View file

@ -3,10 +3,12 @@ extends WeaponState
@export var emptyable: bool @export var emptyable: bool
func _enter() -> void: func _enter() -> void:
machine.animation_player.play(with_morphems("intro")) machine.animation_player.play(with_morphems("intro"))
machine.animation_player.animation_finished.connect(on_animation_finished) machine.animation_player.animation_finished.connect(on_animation_finished)
func _exit() -> void: func _exit() -> void:
machine.animation_player.animation_finished.disconnect(on_animation_finished) machine.animation_player.animation_finished.disconnect(on_animation_finished)
func on_animation_finished(animation): func on_animation_finished(animation):

View file

@ -1,12 +1,13 @@
extends RigidBody3D extends CharacterBody3D
func _physics_process(delta: float) -> void:
var contacts: int = 0
velocity += get_gravity() * delta
func _on_body_entered(_body: Node) -> void:
contacts += 1 if is_on_floor():
if contacts > 2: var fire: Node3D = preload("res://weapons/molikman/molik/molikman_molotov_fire.tscn").instantiate()
var fire = preload("uid://l4t1mflutm3t").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
queue_free() queue_free()
move_and_slide()

View file

@ -1,10 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://b6qahd6q60js7"] [gd_scene load_steps=5 format=3 uid="uid://b6qahd6q60js7"]
[ext_resource type="Script" uid="uid://y1s64ppporww" path="res://weapons/molikman/molik/molik.gd" id="1_aqokr"] [ext_resource type="Script" uid="uid://y1s64ppporww" path="res://weapons/molikman/molik/molik.gd" id="1_aqokr"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_aqokr"]
bounce = 0.53
[sub_resource type="SphereMesh" id="SphereMesh_fwcyt"] [sub_resource type="SphereMesh" id="SphereMesh_fwcyt"]
radius = 0.05 radius = 0.05
height = 0.1 height = 0.1
@ -17,13 +14,8 @@ properties/0/path = NodePath(".:position")
properties/0/spawn = true properties/0/spawn = true
properties/0/replication_mode = 1 properties/0/replication_mode = 1
[node name="Molik" type="RigidBody3D"] [node name="Molik" type="CharacterBody3D"]
collision_layer = 8 collision_layer = 8
physics_material_override = SubResource("PhysicsMaterial_aqokr")
gravity_scale = 0.25
continuous_cd = true
contact_monitor = true
max_contacts_reported = 2
script = ExtResource("1_aqokr") script = ExtResource("1_aqokr")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."] [node name="MeshInstance3D" type="MeshInstance3D" parent="."]
@ -34,5 +26,3 @@ shape = SubResource("SphereShape3D_aqokr")
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_6ic6f") replication_config = SubResource("SceneReplicationConfig_6ic6f")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View file

@ -22,7 +22,7 @@ func fire() -> void:
machine.animation_player.play(machine.animation_prefix + "shoot") machine.animation_player.play(machine.animation_prefix + "shoot")
if is_multiplayer_authority(): if is_multiplayer_authority():
var molotov: RigidBody3D = molik.instantiate() var molotov: CharacterBody3D = molik.instantiate()
Session.dynamic_objects_parent.add_child(molotov,true) Session.dynamic_objects_parent.add_child(molotov,true)
molotov.global_transform = machine.player_camera.global_transform molotov.global_transform = machine.player_camera.global_transform
molotov.apply_impulse(-molotov.global_basis.z * 10) molotov.velocity = -molotov.global_basis.z * 100