#5 mostly works

This commit is contained in:
Paul Black 2023-03-06 00:35:22 -07:00
parent a895ebf791
commit 80a9797c0f
7 changed files with 119 additions and 6 deletions

View file

@ -140,3 +140,69 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\"" rm -rf \"{temp_dir}\""
[preset.2]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="export/Project Teddy.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.2.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=1
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PackedStringArray()
application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
Start-ScheduledTask -TaskName godot_remote_debug
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force '{temp_dir}'"

View file

@ -26,7 +26,7 @@ func _physics_process(delta):
var playerShot = body.get_multiplayer_authority() var playerShot = body.get_multiplayer_authority()
print("Bullet hit ", playerShot) print("Bullet hit ", playerShot)
rpc("damage_player") rpc("damage_player")
rpc_id(playerShot,"take_damage") rpc_id(playerShot,"take_damage", Global.playerName)
self.queue_free() self.queue_free()
elif body.is_in_group("AI"): elif body.is_in_group("AI"):
print("Bullet hit an AI player") print("Bullet hit an AI player")
@ -48,6 +48,7 @@ func damage_player(): # This can be used later to make sure the server and all o
self.queue_free() self.queue_free()
@rpc("any_peer", "call_remote") @rpc("any_peer", "call_remote")
func take_damage(): func take_damage(damager):
var damage = RandomNumberGenerator.new().randf_range(7.0, 16.0) var damage = RandomNumberGenerator.new().randf_range(7.0, 16.0)
Global.playerHealth = Global.playerHealth - damage Global.playerHealth = Global.playerHealth - damage
Global.lastPersonToHitMe = damager

View file

@ -4,6 +4,9 @@ var roundTimer := 600.0
var minutes var minutes
var seconds var seconds
var scores: Array[int] = []
var scoresInitalized = false
func _ready(): func _ready():
minutes = roundTimer / 60 minutes = roundTimer / 60
seconds = fmod(roundTimer, 60) seconds = fmod(roundTimer, 60)
@ -15,6 +18,9 @@ func _process(delta):
$Fatigue.value = Global.fatigue $Fatigue.value = Global.fatigue
$Health.value = Global.playerHealth $Health.value = Global.playerHealth
if Global.roundInSession == true and roundTimer >= 0: if Global.roundInSession == true and roundTimer >= 0:
if scoresInitalized == false:
scoresInitalized = true
fill_scores_with_zeros(Global.connectedPlayers.size())
$startLabel.text = "" $startLabel.text = ""
roundTimer -= delta roundTimer -= delta
minutes = roundTimer / 60 minutes = roundTimer / 60
@ -22,3 +28,28 @@ func _process(delta):
$timer.text = "%02d:%02d" % [minutes, seconds] $timer.text = "%02d:%02d" % [minutes, seconds]
if roundTimer <= 0.0: if roundTimer <= 0.0:
Global.HUDStartLabelText = "GAME OVER" Global.HUDStartLabelText = "GAME OVER"
if Global.HUDPlayerDied:
Global.HUDPlayerDied = false
rpc("update_scores", Global.lastPersonToHitMe)
update_scores(Global.lastPersonToHitMe)
if Global.roundInSession == false:
for i in range(Global.connectedPlayers.size()):
if Global.connectedPlayers[i]:
var objectLabel = "player" + str(i) + "Label"
var numlabel = i + 1
get_node("player" + str(numlabel) + "Label").text = Global.connectedPlayers[i] + ": " + "0"
@rpc("any_peer", "reliable")
func update_scores(name):
for i in range(Global.connectedPlayers.size()):
if Global.connectedPlayers[i] == name:
var objectLabel = "player" + str(i) + "Label"
var numlabel = i + 1
var currentScore = scores[i] + 1
scores[i] += 1
get_node("player" + str(numlabel) + "Label").text = Global.connectedPlayers[i] + ": " + str(currentScore)
func fill_scores_with_zeros(num_of_players):
scores.resize(num_of_players)
for i in num_of_players:
scores[i] = 0

View file

@ -4,13 +4,12 @@ var deathTimer = 0
var teddyNode var teddyNode
func _ready(): func _ready():
pass Global.playerAlive = false
if Global.roundInSession:
Global.HUDPlayerDied = true
func _process(delta): func _process(delta):
#teddyNode = get_node(Global.selfTeddy)
Global.playerAlive = false
#teddyNode.visible = false
if deathTimer < 100: if deathTimer < 100:
deathTimer = deathTimer + 10 * delta deathTimer = deathTimer + 10 * delta
if deathTimer > 100: if deathTimer > 100:

View file

@ -21,6 +21,9 @@ var teddyAuthorityID # Defined from teddy.gd after object is initalized
var miniMenuResume = false # Set to true by mainmenu.gd var miniMenuResume = false # Set to true by mainmenu.gd
var roundInSession = false # Goes true once the round is started in Teddy.gd var roundInSession = false # Goes true once the round is started in Teddy.gd
var HUDStartLabelText = "" # The text displayed at the bottom of the screen of the server var HUDStartLabelText = "" # The text displayed at the bottom of the screen of the server
var lastPersonToHitMe = 0 # Defined in the Bullet RPC
var HUDPlayerDied = false # Tells the HUD.gd script that a point should be added or deducted
var connectedPlayers = [] # Currently connected players by their name (NOT THEIR ID)
func _process(delta): func _process(delta):
if godMode: if godMode:

View file

@ -42,6 +42,7 @@ func _on_start_button_pressed():
Networking.create_server(intPORT, intMAX) Networking.create_server(intPORT, intMAX)
Networking.load_map(SCENE) Networking.load_map(SCENE)
Networking.add_player_node(1) Networking.add_player_node(1)
Global.connectedPlayers += [Global.playerName]
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else: else:
$mapSelected.text = "NO MAX PLAYERS SELECTED" $mapSelected.text = "NO MAX PLAYERS SELECTED"

View file

@ -23,6 +23,7 @@ func create_server(port, maxPlayers):
await get_tree().create_timer(0.5).timeout ## REQUIRED, THE RPC IS MADE BEFORE THE CLIENT IS FULLY CONNECTED await get_tree().create_timer(0.5).timeout ## REQUIRED, THE RPC IS MADE BEFORE THE CLIENT IS FULLY CONNECTED
rpc("add_newly_connected_player_character", new_peer_id) rpc("add_newly_connected_player_character", new_peer_id)
rpc_id(new_peer_id, "add_previously_connected_player_characters", connected_peers) rpc_id(new_peer_id, "add_previously_connected_player_characters", connected_peers)
rpc_id(new_peer_id, "sync_names", Global.connectedPlayers)
add_player_node(new_peer_id) add_player_node(new_peer_id)
) )
@ -57,3 +58,14 @@ func add_previously_connected_player_characters(peer_ids):
@rpc @rpc
func disconnect_peer(peer_id): func disconnect_peer(peer_id):
peer_id.queue_free() peer_id.queue_free()
@rpc("any_peer", "reliable")
func sync_names(connectedPlayers):
Global.connectedPlayers = connectedPlayers
rpc("sync_name_all_peers", Global.playerName)
sync_name_all_peers(Global.playerName)
@rpc("any_peer", "reliable")
func sync_name_all_peers(name):
Global.connectedPlayers += [name]
print(Global.connectedPlayers)