Player 👍

This commit is contained in:
Rendo 2025-11-25 23:18:50 +05:00
commit 0ffc2b2497
5 changed files with 2101 additions and 12 deletions

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -198,7 +198,7 @@ bones/52/rotation = Quaternion(0.73236954, 0.00991537, -0.022315646, 0.6804694)
[node name="Skeleton3D" parent="Camera3D/molikman_hands/GunArm" index="0"]
bones/0/position = Vector3(-0.22279283, 0.7100338, -0.19202478)
bones/0/rotation = Quaternion(-0.006717509, 0.6971531, 0.71686494, -0.0060944925)
bones/1/position = Vector3(5.972106e-08, 0.06469955, 0.06380712)
bones/1/position = Vector3(5.970651e-08, 0.06469957, 0.06380712)
[node name="RayCast3D" type="RayCast3D" parent="Camera3D"]
target_position = Vector3(0, 0, -1000)
@ -248,15 +248,27 @@ crosses_offset = 3.0
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_qhqgy")
[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("default_pistol", "animation_player")]
[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("default_pistol", "default_knife", "animation_player")]
script = ExtResource("4_qlg0r")
default_pistol = NodePath("StartingPistol")
default_knife = NodePath("StartingPistol2")
animation_player = NodePath("../Camera3D/molikman_hands/AnimationPlayer")
[node name="StartingPistol" type="Node" parent="WeaponSystem" node_paths=PackedStringArray("raycast")]
script = ExtResource("6_tuyoq")
max_ammo = 10
semi_auto = true
emptyable = true
damage = 25
firerate = 0.1
prefix = "baked_sp"
raycast = NodePath("../../Camera3D/RayCast3D")
[node name="StartingPistol2" type="Node" parent="WeaponSystem" node_paths=PackedStringArray("raycast")]
script = ExtResource("6_tuyoq")
max_ammo = 10
semi_auto = true
emptyable = true
damage = 25
firerate = 0.1
prefix = "baked_sp"

View file

@ -3,6 +3,7 @@ extends Usable
@export var max_ammo: int
@export var semi_auto: bool
@export var emptyable: bool
@export var damage: int
@export var firerate: float
@ -13,7 +14,7 @@ extends Usable
var ammo_amount: int
var fire_timer: Timer
var state_locked: bool
func _ready() -> void:
fire_timer = Timer.new()
@ -36,15 +37,15 @@ func use_end() -> void:
fire_timer.one_shot = true
func fire() -> void:
if ammo_amount == 0:
if ammo_amount == 0 or state_locked:
if not semi_auto:
fire_timer.stop()
return
ammo_amount -= 1
system.animation_player.stop()
system.animation_player.play(prefix+"_shoot")
system.animation_player.queue(prefix+"_idle")
system.animation_player.play(prefix + with_empty_suffix("_shoot"))
system.animation_player.queue(prefix + with_empty_suffix("_idle"))
if raycast.is_colliding():
raycast.get_collider().hp -= damage
@ -57,17 +58,36 @@ func switch_mode() -> void:
pass
func enter() -> void:
system.animation_player.play(prefix+"_idle")
system.animation_player.animation_changed.connect(on_animation_changed)
state_locked = true
system.animation_player.stop()
system.animation_player.play(prefix+with_empty_suffix("_intro"))
system.animation_player.queue(prefix+with_empty_suffix("_idle"))
func exit() -> void:
system.animation_player.animation_changed.disconnect(on_animation_changed)
func on_animation_changed(old_animation: StringName,_new_animation: StringName) -> void:
if old_animation == prefix + with_empty_suffix("_reload"):
state_locked = false
ammo_amount = max_ammo
if old_animation == prefix + with_empty_suffix("_intro"):
state_locked = false
func _input(event: InputEvent) -> void:
if not system.is_multiplayer_authority(): return
if not system.is_multiplayer_authority() or not in_use: return
if event.is_action_pressed("plr_reload"):
init_reload.rpc()
@rpc("call_local","authority","reliable")
func init_reload():
if ammo_amount == max_ammo or system.animation_player.current_animation == prefix + "_reload":
if ammo_amount == max_ammo or state_locked:
return
system.animation_player.play(prefix+"_reload")
state_locked = true
system.animation_player.play(prefix + with_empty_suffix("_reload"))
system.animation_player.queue(prefix + "_idle")
ammo_amount = max_ammo
func with_empty_suffix(animation):
return (animation+"_empty") if emptyable and ammo_amount == 0 else animation

View file

@ -31,6 +31,8 @@ func _ready() -> void:
push_warning("Child of weapon system is not ability or weapon")
current_usable = default_pistol
slots["knife"] = default_knife
slots["secondary"] = default_pistol
current_usable.enter()
func can_add(slot: StringName) -> bool:
@ -47,9 +49,8 @@ func add(usable: Usable, slot: StringName) -> void:
func switch(to: StringName):
if slots.has(to) == false or slots[to] == null:
if slots.has(to) == false or slots[to] == null or slots[to] == current_usable:
return
current_usable.exit()
current_usable.in_use = false
current_usable = slots[to]