reloading and interaction. Started cleaning up player
This commit is contained in:
parent
d79db8a8d8
commit
daa83ce96d
2 changed files with 26 additions and 33 deletions
|
|
@ -21,6 +21,8 @@ signal crouch_begin
|
||||||
signal crouch_end
|
signal crouch_end
|
||||||
signal walk_begin
|
signal walk_begin
|
||||||
signal walk_end
|
signal walk_end
|
||||||
|
signal interact_begin
|
||||||
|
signal interact_end
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
set_multiplayer_authority(int(get_parent().name))
|
set_multiplayer_authority(int(get_parent().name))
|
||||||
|
|
@ -60,37 +62,44 @@ func _input(event: InputEvent) -> void:
|
||||||
|
|
||||||
if event.is_action_pressed("plr_crouch"):
|
if event.is_action_pressed("plr_crouch"):
|
||||||
if ClientSettings.TOGGLE_CROUCH:
|
if ClientSettings.TOGGLE_CROUCH:
|
||||||
crouch_on_server(crouching)
|
crouch_on_server.rpc_id(1,crouching)
|
||||||
crouching = not crouching
|
crouching = not crouching
|
||||||
elif not crouching:
|
elif not crouching:
|
||||||
crouching = true
|
crouching = true
|
||||||
crouch_on_server(false)
|
crouch_on_server.rpc_id(1,false)
|
||||||
if event.is_action_released("plr_crouch") and not ClientSettings.TOGGLE_CROUCH and crouching:
|
if event.is_action_released("plr_crouch") and not ClientSettings.TOGGLE_CROUCH and crouching:
|
||||||
crouching = false
|
crouching = false
|
||||||
crouch_on_server(false)
|
crouch_on_server.rpc_id(1,false)
|
||||||
|
|
||||||
if event.is_action_pressed("plr_walk"):
|
if event.is_action_pressed("plr_walk"):
|
||||||
if ClientSettings.TOGGLE_WALK:
|
if ClientSettings.TOGGLE_WALK:
|
||||||
walk_on_server(walking)
|
walk_on_server.rpc_id(1,walking)
|
||||||
walking = not walking
|
walking = not walking
|
||||||
elif not walking:
|
elif not walking:
|
||||||
walking = true
|
walking = true
|
||||||
walk_on_server(false)
|
walk_on_server.rpc_id(1,false)
|
||||||
if event.is_action_released("plr_walk") and not ClientSettings.TOGGLE_WALK and walking:
|
if event.is_action_released("plr_walk") and not ClientSettings.TOGGLE_WALK and walking:
|
||||||
walking = false
|
walking = false
|
||||||
walk_on_server(false)
|
walk_on_server.rpc_id(1,false)
|
||||||
|
|
||||||
if event.is_action_pressed("plr_scope"):
|
if event.is_action_pressed("plr_scope"):
|
||||||
if ClientSettings.TOGGLE_SCOPE:
|
if ClientSettings.TOGGLE_SCOPE:
|
||||||
scope_on_server(scoping)
|
scope_on_server.rpc_id(1,scoping)
|
||||||
scoping = not scoping
|
scoping = not scoping
|
||||||
elif not scoping:
|
elif not scoping:
|
||||||
scoping = true
|
scoping = true
|
||||||
scope_on_server(false)
|
scope_on_server.rpc_id(1,false)
|
||||||
if event.is_action_released("plr_scope") and not ClientSettings.TOGGLE_SCOPE and scoping:
|
if event.is_action_released("plr_scope") and not ClientSettings.TOGGLE_SCOPE and scoping:
|
||||||
scoping = false
|
scoping = false
|
||||||
scope_on_server(false)
|
scope_on_server.rpc_id(1,false)
|
||||||
|
|
||||||
|
if event.is_action_pressed("plr_reload"):
|
||||||
|
reload_on_server.rpc_id(1)
|
||||||
|
|
||||||
|
if event.is_action_pressed("plr_interact"):
|
||||||
|
interact_on_server.rpc_id(1,false)
|
||||||
|
if event.is_action_released("plr_interact"):
|
||||||
|
interact_on_server.rpc_id(1,true)
|
||||||
|
|
||||||
@rpc("authority","call_local","reliable")
|
@rpc("authority","call_local","reliable")
|
||||||
func switch_on_server(slot: StringName) -> void:
|
func switch_on_server(slot: StringName) -> void:
|
||||||
|
|
@ -148,3 +157,11 @@ func scope_on_server(end: bool) -> void:
|
||||||
func reload_on_server() -> void:
|
func reload_on_server() -> void:
|
||||||
if not multiplayer.is_server(): return
|
if not multiplayer.is_server(): return
|
||||||
reload.emit()
|
reload.emit()
|
||||||
|
|
||||||
|
@rpc("authority","call_local","reliable")
|
||||||
|
func interact_on_server(end: bool) -> void:
|
||||||
|
if not multiplayer.is_server(): return
|
||||||
|
if end:
|
||||||
|
interact_end.emit()
|
||||||
|
else:
|
||||||
|
interact_begin.emit()
|
||||||
|
|
|
||||||
|
|
@ -39,35 +39,11 @@ func die() -> void:
|
||||||
died.emit()
|
died.emit()
|
||||||
passived = true
|
passived = true
|
||||||
|
|
||||||
@rpc("any_peer","call_local","reliable")
|
|
||||||
func passive() -> void:
|
func passive() -> void:
|
||||||
passived = true
|
passived = true
|
||||||
|
|
||||||
@rpc("any_peer","call_local","reliable")
|
|
||||||
func depassive() -> void:
|
func depassive() -> void:
|
||||||
passived = false
|
passived = false
|
||||||
|
|
||||||
@rpc("any_peer","call_local","reliable")
|
|
||||||
func kill_request() -> void:
|
|
||||||
if multiplayer.get_remote_sender_id() != 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
die()
|
|
||||||
|
|
||||||
@rpc("any_peer","call_local","reliable")
|
|
||||||
func set_after_spawn(start_position: Vector3,new_team: int):
|
|
||||||
global_position = start_position
|
|
||||||
team = new_team as Session.TEAMS
|
|
||||||
spawned.emit()
|
|
||||||
|
|
||||||
@rpc("any_peer","call_local","reliable")
|
|
||||||
func take_damage(damage: int):
|
func take_damage(damage: int):
|
||||||
hp -= damage
|
hp -= damage
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
|
||||||
if not is_multiplayer_authority():
|
|
||||||
return
|
|
||||||
if event.is_action_pressed("plr_interact"):
|
|
||||||
Session.interact()
|
|
||||||
if event.is_action_released("plr_interact"):
|
|
||||||
Session.stop_interact()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue