Cmall fixes

This commit is contained in:
Rendo 2025-12-12 14:04:56 +05:00
commit de1ab2bb53
3 changed files with 14 additions and 15 deletions

View file

@ -86,14 +86,13 @@ func can_add_ability(ability: StringName, slot: StringName) -> bool:
return can_add(slot)
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 not is_multiplayer_authority():
return
if current_state != null and exit:
current_state._exit()
if current_state != null:
if exit:
current_state._exit()
if current_state.can_be_previous:
last_slot = slots.find_key(current_state)
else:
last_slot = ""
current_state = slots[to]
current_state._enter()
@ -128,8 +127,8 @@ func drop(weapon: WeaponSubStateMachine) -> void:
slots[slots.find_key(weapon)] = null
notify_slots_updated()
weapon.queue_free()
return_to_previous(false)
weapon.queue_free()
func drop_slot(slot: StringName):
if slots.has(slot) == false or slots[slot] == null:
@ -151,6 +150,7 @@ func check_for_empty() -> void:
if child == current_state:
return_to_previous(false)
child.queue_free()
notify_slots_updated()
func on_ammo_updated() -> void:

View file

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

View file

@ -12,18 +12,18 @@ func _exit() -> void:
func on_animation_finished(animation):
if animation == machine.animation_prefix + "throw" or animation == machine.animation_prefix + "shoot":
transition.emit("Idle")
machine.ammo -= 1
if is_multiplayer_authority():
var molotov: CharacterBody3D = molik.instantiate()
Session.dynamic_objects_parent.add_child(molotov,true)
molotov.global_transform = machine.player_camera.global_transform
molotov.velocity = -molotov.global_basis.z * 25 + machine.player.velocity
func fire() -> void:
if machine.ammo == 0:
return
machine.ammo -= 1
machine.animation_player.stop()
machine.animation_player.play(machine.animation_prefix + "shoot")
if is_multiplayer_authority():
var molotov: CharacterBody3D = molik.instantiate()
Session.dynamic_objects_parent.add_child(molotov,true)
molotov.global_transform = machine.player_camera.global_transform
molotov.velocity = -molotov.global_basis.z * 25 + machine.player.velocity