forked from unfa/liblast
Implemented fake death to workaround a Godot bug. Added health and jetpack bars to HUD.
parent
500473e517
commit
377d74286b
|
@ -88,12 +88,35 @@ var jetpack_was_active = false
|
||||||
var velocity := Vector3.ZERO
|
var velocity := Vector3.ZERO
|
||||||
var gravity_vec := Vector3.ZERO
|
var gravity_vec := Vector3.ZERO
|
||||||
|
|
||||||
|
var dead = false: # used to workaround Godot crash when destroying player_nodes
|
||||||
|
set(value):
|
||||||
|
match value:
|
||||||
|
true:
|
||||||
|
#input_active = false
|
||||||
|
self.hide()
|
||||||
|
$Body.disabled = true
|
||||||
|
#set_physics_process(false)
|
||||||
|
false:
|
||||||
|
#input_active = true
|
||||||
|
self.show()
|
||||||
|
$Body.disabled = false
|
||||||
|
#set_physics_process(true)
|
||||||
|
dead = value
|
||||||
|
|
||||||
@rpc(auth, nosync,unreliable) func update_movement(player_transform, head_rotation, lin_velocity, jetpack):
|
@rpc(auth, nosync,unreliable) func update_movement(player_transform, head_rotation, lin_velocity, jetpack):
|
||||||
global_transform = player_transform
|
global_transform = player_transform
|
||||||
head.set_rotation(head_rotation)
|
head.set_rotation(head_rotation)
|
||||||
jetpack_active = jetpack
|
jetpack_active = jetpack
|
||||||
linear_velocity = lin_velocity
|
linear_velocity = lin_velocity
|
||||||
|
|
||||||
|
@rpc(any, sync, reliable) func set_dead(is_dead: bool):
|
||||||
|
#print("Recieved RPC call for set_dead ", is_dead)
|
||||||
|
self.dead = is_dead
|
||||||
|
|
||||||
|
# if is_multiplayer_authority():
|
||||||
|
# print("Rebroadcasting RPC call for set_dead ", dead)
|
||||||
|
# rpc(&'set_dead', dead)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
view_zoom_target = 1.0
|
view_zoom_target = 1.0
|
||||||
|
@ -124,6 +147,9 @@ func aim(event) -> void:
|
||||||
head.rotation.x = clamp(current_tilt, deg2rad(-90), deg2rad(90))
|
head.rotation.x = clamp(current_tilt, deg2rad(-90), deg2rad(90))
|
||||||
|
|
||||||
func _input(event) -> void:
|
func _input(event) -> void:
|
||||||
|
if dead:
|
||||||
|
return
|
||||||
|
|
||||||
if not input_active:
|
if not input_active:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -161,6 +187,9 @@ func _input(event) -> void:
|
||||||
weapon.trigger(1, false)
|
weapon.trigger(1, false)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if dead:
|
||||||
|
return
|
||||||
|
|
||||||
$Jetpack/GPUParticles3D.emitting = jetpack_active
|
$Jetpack/GPUParticles3D.emitting = jetpack_active
|
||||||
|
|
||||||
if jetpack_active:
|
if jetpack_active:
|
||||||
|
@ -185,12 +214,14 @@ func _process(delta):
|
||||||
elif not view_zoom_direction and view_zoom > view_zoom_target:
|
elif not view_zoom_direction and view_zoom > view_zoom_target:
|
||||||
view_zoom = max(view_zoom_target, view_zoom - delta * 4)
|
view_zoom = max(view_zoom_target, view_zoom - delta * 4)
|
||||||
|
|
||||||
|
hud.get_node("Stats").get_node("JetpackBar").value = (jetpack_fuel / jetpack_tank) * 100
|
||||||
|
|
||||||
|
|
||||||
func damage(hp: int):
|
func damage(hp: int):
|
||||||
var target = main.player_list.players[self.get_multiplayer_authority()]
|
var target = main.player_list.players[self.get_multiplayer_authority()]
|
||||||
target.health -= hp
|
target.health -= hp
|
||||||
|
|
||||||
@rpc(any, nosync, reliable) func die(killer_pid: int):
|
@rpc(any, sync, reliable) func die(killer_pid: int):
|
||||||
var gibs = gibs_vfx.instantiate()
|
var gibs = gibs_vfx.instantiate()
|
||||||
get_tree().root.add_child(gibs)
|
get_tree().root.add_child(gibs)
|
||||||
gibs.global_transform = self.global_transform
|
gibs.global_transform = self.global_transform
|
||||||
|
@ -200,6 +231,7 @@ func damage(hp: int):
|
||||||
# return
|
# return
|
||||||
#main.rpc(&'destroy_player', self.get_multiplayer_authority())
|
#main.rpc(&'destroy_player', self.get_multiplayer_authority())
|
||||||
main.destroy_player(self.get_multiplayer_authority())
|
main.destroy_player(self.get_multiplayer_authority())
|
||||||
|
set_dead(true)
|
||||||
#main.chat.rpc(&'chat_notification', "Player [/i][b][color=" + main.player_list.players[self.get_multiplayer_authority()].color.to_html() + "]" + main.player_list.players[self.get_multiplayer_authority()].name + "[/color][/b][i] was killed by " + main.player_list.players[killer_pid].name )
|
#main.chat.rpc(&'chat_notification', "Player [/i][b][color=" + main.player_list.players[self.get_multiplayer_authority()].color.to_html() + "]" + main.player_list.players[self.get_multiplayer_authority()].name + "[/color][/b][i] was killed by " + main.player_list.players[killer_pid].name )
|
||||||
main.chat.chat_notification("Player [/i][b][color=" + main.player_list.players[self.get_multiplayer_authority()].color.to_html() + "]" + main.player_list.players[self.get_multiplayer_authority()].name + "[/color][/b][i] was killed by " + main.player_list.players[killer_pid].name )
|
main.chat.chat_notification("Player [/i][b][color=" + main.player_list.players[self.get_multiplayer_authority()].color.to_html() + "]" + main.player_list.players[self.get_multiplayer_authority()].name + "[/color][/b][i] was killed by " + main.player_list.players[killer_pid].name )
|
||||||
|
|
||||||
|
@ -216,6 +248,10 @@ func update_color(color) -> void: #change player's wolrldmodel color
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
|
||||||
|
if dead: # workaround for Godot player destruction crash
|
||||||
|
linear_velocity = Vector3.ZERO
|
||||||
|
return
|
||||||
|
|
||||||
if not is_multiplayer_authority():
|
if not is_multiplayer_authority():
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
return
|
return
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="96"
|
||||||
|
height="96"
|
||||||
|
viewBox="0 0 25.399999 25.400001"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
|
||||||
|
sodipodi:docname="HeathBarEmpty.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#545454"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="3.959798"
|
||||||
|
inkscape:cx="85.752294"
|
||||||
|
inkscape:cy="55.305259"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="true"
|
||||||
|
units="px"
|
||||||
|
inkscape:snap-global="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1006"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid833"
|
||||||
|
empspacing="32" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:none;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:#ffffff"
|
||||||
|
id="rect835"
|
||||||
|
width="23.847076"
|
||||||
|
height="23.847076"
|
||||||
|
x="0.77646106"
|
||||||
|
y="0.77646106"
|
||||||
|
rx="3.0779727"
|
||||||
|
ry="3.0779727" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture2D"
|
||||||
|
uid="uid://dvt25wji1pdyl"
|
||||||
|
path="res://.godot/imported/BarOver.svg-3e206b7d7b36feafb9ac8b93edd2c46b.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/HUD/BarOver.svg"
|
||||||
|
dest_files=["res://.godot/imported/BarOver.svg-3e206b7d7b36feafb9ac8b93edd2c46b.stex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
compress/streamed=false
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="96"
|
||||||
|
height="96"
|
||||||
|
viewBox="0 0 25.399999 25.400001"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
|
||||||
|
sodipodi:docname="HeathBarProgress.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#545454"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="3.959798"
|
||||||
|
inkscape:cx="85.752294"
|
||||||
|
inkscape:cy="55.305259"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="true"
|
||||||
|
units="px"
|
||||||
|
inkscape:snap-global="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1051"
|
||||||
|
inkscape:window-x="1920"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid833"
|
||||||
|
empspacing="32" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#ffffff;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:none;fill-opacity:1"
|
||||||
|
id="rect835"
|
||||||
|
width="23.847076"
|
||||||
|
height="23.847076"
|
||||||
|
x="0.77646106"
|
||||||
|
y="0.77646106"
|
||||||
|
rx="3.0779727"
|
||||||
|
ry="3.0779727" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture2D"
|
||||||
|
uid="uid://0j6rxd7ncmu1"
|
||||||
|
path="res://.godot/imported/BarProgress.svg-38f8fe7383fae81cc6603349ccd802d9.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/HUD/BarProgress.svg"
|
||||||
|
dest_files=["res://.godot/imported/BarProgress.svg-38f8fe7383fae81cc6603349ccd802d9.stex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
compress/streamed=false
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="96"
|
||||||
|
height="96"
|
||||||
|
viewBox="0 0 25.399999 25.400001"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
|
||||||
|
sodipodi:docname="HeathBarUnder.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#545454"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="3.959798"
|
||||||
|
inkscape:cx="85.752294"
|
||||||
|
inkscape:cy="55.305259"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="true"
|
||||||
|
units="px"
|
||||||
|
inkscape:snap-global="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1051"
|
||||||
|
inkscape:window-x="1920"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid833"
|
||||||
|
empspacing="32" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#ffffff;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:none"
|
||||||
|
id="rect835"
|
||||||
|
width="23.847076"
|
||||||
|
height="23.847076"
|
||||||
|
x="0.77646106"
|
||||||
|
y="0.77646106"
|
||||||
|
rx="3.0779727"
|
||||||
|
ry="3.0779727" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture2D"
|
||||||
|
uid="uid://ck4exwgifde4n"
|
||||||
|
path="res://.godot/imported/BarUnder.svg-95ef68273b3476991eb89e9f1df4b93d.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/HUD/BarUnder.svg"
|
||||||
|
dest_files=["res://.godot/imported/BarUnder.svg-95ef68273b3476991eb89e9f1df4b93d.stex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
compress/streamed=false
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=13 format=3 uid="uid://bff5uslrxesjx"]
|
[gd_scene load_steps=16 format=3 uid="uid://bff5uslrxesjx"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://blnjjtjifk22i" path="res://Assets/HUD/Vignette.png" id="1"]
|
[ext_resource type="Texture2D" uid="uid://blnjjtjifk22i" path="res://Assets/HUD/Vignette.png" id="1"]
|
||||||
[ext_resource type="Script" path="res://Assets/HUD/HUD.gd" id="1_wc430"]
|
[ext_resource type="Script" path="res://Assets/HUD/HUD.gd" id="1_wc430"]
|
||||||
|
@ -8,6 +8,9 @@
|
||||||
[ext_resource type="AudioStream" uid="uid://bllgajqussdi5" path="res://Assets/SFX/HUD_Confirm_Kill.wav" id="5_hh74r"]
|
[ext_resource type="AudioStream" uid="uid://bllgajqussdi5" path="res://Assets/SFX/HUD_Confirm_Kill.wav" id="5_hh74r"]
|
||||||
[ext_resource type="Script" path="res://Assets/HUD/Chat.gd" id="6"]
|
[ext_resource type="Script" path="res://Assets/HUD/Chat.gd" id="6"]
|
||||||
[ext_resource type="Theme" uid="uid://ddtu7o1dbp0s8" path="res://Assets/HUD/Theme.tres" id="7"]
|
[ext_resource type="Theme" uid="uid://ddtu7o1dbp0s8" path="res://Assets/HUD/Theme.tres" id="7"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ck4exwgifde4n" path="res://Assets/HUD/BarUnder.svg" id="9_q07oy"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dvt25wji1pdyl" path="res://Assets/HUD/BarOver.svg" id="10_5i332"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://0j6rxd7ncmu1" path="res://Assets/HUD/BarProgress.svg" id="11_tlgqu"]
|
||||||
|
|
||||||
[sub_resource type="Animation" id="1"]
|
[sub_resource type="Animation" id="1"]
|
||||||
resource_name = "Default"
|
resource_name = "Default"
|
||||||
|
@ -310,4 +313,59 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Stats" type="VBoxContainer" parent="."]
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -200.0
|
||||||
|
offset_top = -68.0
|
||||||
|
offset_right = -32.0
|
||||||
|
offset_bottom = -32.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
script = null
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HealthBar" type="TextureProgressBar" parent="Stats"]
|
||||||
|
offset_right = 200.0
|
||||||
|
offset_bottom = 32.0
|
||||||
|
rect_min_size = Vector2(200, 32)
|
||||||
|
value = 100.0
|
||||||
|
allow_greater = true
|
||||||
|
allow_lesser = true
|
||||||
|
texture_under = ExtResource( "9_q07oy" )
|
||||||
|
texture_over = ExtResource( "10_5i332" )
|
||||||
|
texture_progress = ExtResource( "11_tlgqu" )
|
||||||
|
tint_under = Color(0, 0, 0, 0.12549)
|
||||||
|
tint_over = Color(0, 0.780392, 1, 1)
|
||||||
|
tint_progress = Color(0, 0.745098, 1, 1)
|
||||||
|
nine_patch_stretch = true
|
||||||
|
stretch_margin_left = 16
|
||||||
|
stretch_margin_top = 16
|
||||||
|
stretch_margin_right = 16
|
||||||
|
stretch_margin_bottom = 16
|
||||||
|
script = null
|
||||||
|
|
||||||
|
[node name="JetpackBar" type="TextureProgressBar" parent="Stats"]
|
||||||
|
offset_top = 36.0
|
||||||
|
offset_right = 200.0
|
||||||
|
offset_bottom = 68.0
|
||||||
|
rect_min_size = Vector2(200, 32)
|
||||||
|
value = 100.0
|
||||||
|
texture_under = ExtResource( "9_q07oy" )
|
||||||
|
texture_over = ExtResource( "10_5i332" )
|
||||||
|
texture_progress = ExtResource( "11_tlgqu" )
|
||||||
|
tint_under = Color(0, 0, 0, 0.12549)
|
||||||
|
tint_over = Color(1, 0.764706, 0, 1)
|
||||||
|
tint_progress = Color(1, 0.760784, 0, 1)
|
||||||
|
nine_patch_stretch = true
|
||||||
|
stretch_margin_left = 16
|
||||||
|
stretch_margin_top = 16
|
||||||
|
stretch_margin_right = 16
|
||||||
|
stretch_margin_bottom = 16
|
||||||
|
script = null
|
||||||
|
|
||||||
[connection signal="text_submitted" from="Chat/VBoxContainer/Typing/Editor" to="Chat" method="_on_Editor_text_submitted"]
|
[connection signal="text_submitted" from="Chat/VBoxContainer/Typing/Editor" to="Chat" method="_on_Editor_text_submitted"]
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="96"
|
||||||
|
height="96"
|
||||||
|
viewBox="0 0 25.399999 25.400001"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
|
||||||
|
sodipodi:docname="Panel.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#545454"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="3.959798"
|
||||||
|
inkscape:cx="85.752294"
|
||||||
|
inkscape:cy="55.305259"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="true"
|
||||||
|
units="px"
|
||||||
|
inkscape:snap-global="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1051"
|
||||||
|
inkscape:window-x="1920"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid833"
|
||||||
|
empspacing="32" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#000000;stroke-width:0.79375;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers fill stroke;stroke:#ffffff;fill-opacity:0.25"
|
||||||
|
id="rect835"
|
||||||
|
width="23.847076"
|
||||||
|
height="23.847076"
|
||||||
|
x="0.77646106"
|
||||||
|
y="0.77646106"
|
||||||
|
rx="3.0779727"
|
||||||
|
ry="3.0779727" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture2D"
|
||||||
|
uid="uid://duxv0vin55qyy"
|
||||||
|
path="res://.godot/imported/Panel.svg-123d44a61e9822e83e9dafcfaffa99a9.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/HUD/Panel.svg"
|
||||||
|
dest_files=["res://.godot/imported/Panel.svg-123d44a61e9822e83e9dafcfaffa99a9.stex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
compress/streamed=false
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,22 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamSample"
|
||||||
|
uid="uid://d2siwe07rwepl"
|
||||||
|
path="res://.godot/imported/Weapons_Handgun_Casing_01.wav-80f393f0b224823a59ba1d5e69dc8cdd.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/SFX/Weapons_Handgun_Casing_01.wav"
|
||||||
|
dest_files=["res://.godot/imported/Weapons_Handgun_Casing_01.wav-80f393f0b224823a59ba1d5e69dc8cdd.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop=false
|
||||||
|
compress/mode=0
|
72
Game/Main.gd
72
Game/Main.gd
|
@ -73,6 +73,8 @@ var spawn_queue = {}
|
||||||
|
|
||||||
var game_score_limit = 15
|
var game_score_limit = 15
|
||||||
|
|
||||||
|
const destroy_free_player_crash_workaround = true
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
uptime += delta
|
uptime += delta
|
||||||
|
|
||||||
|
@ -88,6 +90,10 @@ func _process(delta):
|
||||||
$Label.text += "\n\nspawn_queue: \n"
|
$Label.text += "\n\nspawn_queue: \n"
|
||||||
$Label.text += str(spawn_queue)
|
$Label.text += str(spawn_queue)
|
||||||
|
|
||||||
|
if local_player:
|
||||||
|
$Label.text += "\n\nLOCAL PLAYER DEAD: " + str(local_player.dead)
|
||||||
|
|
||||||
|
|
||||||
for i in spawn_queue.keys():
|
for i in spawn_queue.keys():
|
||||||
if spawn_queue[i] <= uptime:
|
if spawn_queue[i] <= uptime:
|
||||||
var is_local = true if i == get_tree().multiplayer.get_unique_id() else false
|
var is_local = true if i == get_tree().multiplayer.get_unique_id() else false
|
||||||
|
@ -109,25 +115,27 @@ class PlayerList:
|
||||||
|
|
||||||
@onready var player_list = PlayerList.new()
|
@onready var player_list = PlayerList.new()
|
||||||
|
|
||||||
var focus = GameFocus.MENU :
|
var focus:GameFocus:
|
||||||
set(new_focus):
|
set(new_focus):
|
||||||
if local_player != null:
|
if local_player != null:
|
||||||
assert(local_player != null, "local_player is not null but it is null, WTF?!")
|
assert(local_player != null, "local_player is not null but it is null, WTF?!")
|
||||||
match new_focus:
|
match new_focus:
|
||||||
0:
|
0: # MENU
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
gui.show()
|
gui.show()
|
||||||
|
hud.hide()
|
||||||
if local_player:
|
if local_player:
|
||||||
local_player.input_active = false
|
local_player.input_active = false
|
||||||
1:
|
1: # GAME
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
gui.hide()
|
gui.hide()
|
||||||
|
hud.show()
|
||||||
if local_player:
|
if local_player:
|
||||||
local_player.input_active = true
|
local_player.input_active = true
|
||||||
2:
|
2: # CHAT
|
||||||
if local_player:
|
if local_player:
|
||||||
local_player.input_active = false
|
local_player.input_active = false
|
||||||
3:
|
3: #AWAY
|
||||||
if local_player:
|
if local_player:
|
||||||
local_player.input_active = true
|
local_player.input_active = true
|
||||||
|
|
||||||
|
@ -155,6 +163,16 @@ func check_game_win_condition():
|
||||||
game_over()
|
game_over()
|
||||||
|
|
||||||
func update_hud():
|
func update_hud():
|
||||||
|
|
||||||
|
### Health
|
||||||
|
|
||||||
|
hud.get_node("Stats").get_node("HealthBar").value = player_list.get( get_tree().multiplayer.get_unique_id() ).health
|
||||||
|
|
||||||
|
if player_list.players.size() <= 1:
|
||||||
|
return # if we're the sole player in the server, stop here
|
||||||
|
|
||||||
|
### SCORE, RANK, GAP/LEAD
|
||||||
|
|
||||||
hud.get_node("ScoreRank").text = "SCORE: " + str(player_list.get( get_tree().multiplayer.get_unique_id() ).score)
|
hud.get_node("ScoreRank").text = "SCORE: " + str(player_list.get( get_tree().multiplayer.get_unique_id() ).score)
|
||||||
|
|
||||||
var score = player_list.get( get_tree().multiplayer.get_unique_id() ).score
|
var score = player_list.get( get_tree().multiplayer.get_unique_id() ).score
|
||||||
|
@ -199,11 +217,11 @@ func update_hud():
|
||||||
update_hud()
|
update_hud()
|
||||||
|
|
||||||
func push_local_player_info(): #
|
func push_local_player_info(): #
|
||||||
var id = get_tree().multiplayer.get_unique_id()
|
var pid = get_tree().multiplayer.get_unique_id()
|
||||||
|
|
||||||
rpc(&'player_list_update', player_list.get(id).serialize(), get_tree().multiplayer.get_unique_id())
|
rpc(&'player_list_update', player_list.get(pid).serialize(), pid)
|
||||||
|
|
||||||
@rpc func destroy_player(pid: int):
|
@rpc(sync, any, reliable) func destroy_player(pid: int):
|
||||||
print("DESTROY_PLAYER called on ", get_tree().multiplayer.get_unique_id(), " by ", get_tree().multiplayer.get_remote_sender_id(), " regarding ", pid)
|
print("DESTROY_PLAYER called on ", get_tree().multiplayer.get_unique_id(), " by ", get_tree().multiplayer.get_remote_sender_id(), " regarding ", pid)
|
||||||
|
|
||||||
#assert($Players.has_node(str(pid)), "Attempting to destroy a player that does not exist")
|
#assert($Players.has_node(str(pid)), "Attempting to destroy a player that does not exist")
|
||||||
|
@ -218,13 +236,40 @@ func push_local_player_info(): #
|
||||||
|
|
||||||
#assert(player_node != null, "Attempting to delete a player node that does not exist")
|
#assert(player_node != null, "Attempting to delete a player node that does not exist")
|
||||||
|
|
||||||
player_node.name = str(player_node.name) + "_dead" # avoids name collision when instancing another player scene
|
# alternative finale to this function that is a workaround to avoid Godot crashing due to an engine bug
|
||||||
print("before free")
|
# https://github.com/godotengine/godot/issues/52853
|
||||||
player_node.queue_free()
|
if destroy_free_player_crash_workaround:
|
||||||
print("after free")
|
print("Setting player ", pid, " as DEAD")
|
||||||
|
player_node.set_dead(true)
|
||||||
|
else: # regular method follows
|
||||||
|
player_node.name = str(player_node.name) + "_dead" # avoids name collision when instancing another player scene
|
||||||
|
|
||||||
|
print("before free")
|
||||||
|
player_node.queue_free()
|
||||||
|
print("after free")
|
||||||
|
# respawn queue applies ot both implementations of death
|
||||||
spawn_queue[pid] = uptime + respawn_delay
|
spawn_queue[pid] = uptime + respawn_delay
|
||||||
|
|
||||||
|
if pid == get_tree().multiplayer.get_unique_id():
|
||||||
|
update_hud()
|
||||||
|
|
||||||
func create_player(pid: int, is_local:= false, respawn:= false) -> void:
|
func create_player(pid: int, is_local:= false, respawn:= false) -> void:
|
||||||
|
if destroy_free_player_crash_workaround:
|
||||||
|
var player_node
|
||||||
|
if $Players.has_node(str(pid)): # if this is a respawn
|
||||||
|
player_node = $Players.get_node(str(pid))
|
||||||
|
print("Setting player ", pid, " as ALIVE")
|
||||||
|
player_node.set_dead(false)
|
||||||
|
|
||||||
|
var spawnpoint = $Map/SpawnPoints.get_children()[randi() % len($Map/SpawnPoints.get_children())]
|
||||||
|
player_node.global_transform = spawnpoint.global_transform
|
||||||
|
player_list.players[pid].health = 100
|
||||||
|
push_local_player_info()
|
||||||
|
|
||||||
|
#focus = GameFocus.GAME # make sure the player has no menu displayed when they respawn
|
||||||
|
return # avoid running the rest of this function
|
||||||
|
else:
|
||||||
|
pass # if this is not a respawn, let it carry on
|
||||||
var new_player
|
var new_player
|
||||||
new_player = player_scene.instantiate()
|
new_player = player_scene.instantiate()
|
||||||
|
|
||||||
|
@ -261,6 +306,8 @@ func create_player(pid: int, is_local:= false, respawn:= false) -> void:
|
||||||
# new_player.get_node("Head/Camera").current = false
|
# new_player.get_node("Head/Camera").current = false
|
||||||
# local_player.get_node("Head/Camera").current = true
|
# local_player.get_node("Head/Camera").current = true
|
||||||
#new_player.rpc(&'set_color', player_list.get(pid).color)
|
#new_player.rpc(&'set_color', player_list.get(pid).color)
|
||||||
|
|
||||||
|
#update_hud()
|
||||||
|
|
||||||
func start_dedicated_server(): # start server without creating a local player
|
func start_dedicated_server(): # start server without creating a local player
|
||||||
role = MultiplayerRole.DEDICATED_SERVER
|
role = MultiplayerRole.DEDICATED_SERVER
|
||||||
|
@ -326,6 +373,7 @@ func _server_disconnected() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
hud.hide() # start in the menu
|
||||||
#peer.compression_mode = NetworkedMultiplayerENet.COMPRESS_ZSTD
|
#peer.compression_mode = NetworkedMultiplayerENet.COMPRESS_ZSTD
|
||||||
print("Commandline arguments: ", OS.get_cmdline_args())
|
print("Commandline arguments: ", OS.get_cmdline_args())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue