rework of player rotation, add killog
This commit is contained in:
parent
eb1ba01812
commit
aaedb60b86
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=17 format=3 uid="uid://gxfhitfre2fj"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://gxfhitfre2fj"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c4pah1vj0aa4x" path="res://textures/prototype-textures/Prototype_symbol_cross_32x32px.png" id="1_g1v70"]
|
||||
[ext_resource type="Texture2D" uid="uid://na1y6c7osyj2" path="res://textures/logo/health.svg" id="1_ts1uf"]
|
||||
|
@ -43,15 +43,6 @@ font_color = Color(0.992157, 0.415686, 0.631373, 1)
|
|||
shadow_size = 9
|
||||
shadow_color = Color(0, 0, 0, 0.772549)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ouyds"]
|
||||
bg_color = Color(0.117647, 0.117647, 0.117647, 0.368627)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color(0.737255, 0.619608, 0.239216, 1)
|
||||
border_blend = true
|
||||
|
||||
[node name="HUD" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
@ -304,6 +295,7 @@ offset_bottom = 66.0
|
|||
theme_override_styles/panel = SubResource("StyleBoxFlat_pxi8e")
|
||||
|
||||
[node name="cs_score_game" type="Label" parent="round_status"]
|
||||
layout_mode = 0
|
||||
offset_left = -52.0
|
||||
offset_top = -2.0
|
||||
offset_right = -35.0
|
||||
|
@ -312,6 +304,7 @@ text = "0"
|
|||
label_settings = SubResource("LabelSettings_l41k6")
|
||||
|
||||
[node name="cs_score_round" type="Label" parent="round_status"]
|
||||
layout_mode = 0
|
||||
offset_left = -48.0
|
||||
offset_top = 39.0
|
||||
offset_right = -38.0
|
||||
|
@ -319,6 +312,7 @@ offset_bottom = 62.0
|
|||
text = "0"
|
||||
|
||||
[node name="os_score_round" type="Label" parent="round_status"]
|
||||
layout_mode = 0
|
||||
offset_left = 83.0
|
||||
offset_top = 39.0
|
||||
offset_right = 93.0
|
||||
|
@ -326,6 +320,7 @@ offset_bottom = 62.0
|
|||
text = "0"
|
||||
|
||||
[node name="os_score_game" type="Label" parent="round_status"]
|
||||
layout_mode = 0
|
||||
offset_left = 79.0
|
||||
offset_top = -2.0
|
||||
offset_right = 96.0
|
||||
|
@ -361,10 +356,13 @@ label_settings = SubResource("LabelSettings_ky32e")
|
|||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="kill_log" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1088.0
|
||||
offset_top = 3.0
|
||||
offset_right = 1148.0
|
||||
offset_bottom = 28.0
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_ouyds")
|
||||
[node name="kill_log" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -156.0
|
||||
offset_right = 155.0
|
||||
offset_bottom = 314.0
|
||||
grow_horizontal = 0
|
||||
scale = Vector2(0.5, 0.5)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dvrv2bfmotivm"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bmuo2tbe3r8ih" path="res://textures/logo/ammo.svg" id="1_p3k0o"]
|
||||
[ext_resource type="Script" path="res://scripts/kill_log_entry.gd" id="1_tki6n"]
|
||||
|
||||
[node name="kill_log_entry" type="HBoxContainer"]
|
||||
offset_right = 311.0
|
||||
offset_bottom = 102.0
|
||||
scale = Vector2(0.275, 0.275)
|
||||
script = ExtResource("1_tki6n")
|
||||
|
||||
[node name="killer" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Unnamed"
|
||||
|
||||
[node name="logo" type="TextureRect" parent="."]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("1_p3k0o")
|
||||
|
||||
[node name="victim" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Unnamed"
|
|
@ -88,7 +88,8 @@ func sync_client(client_id, position, rotation):
|
|||
var internal_id = str(client["internal_id"])
|
||||
var client_playermodel = ServerUtils.find_playermodel_by_internal_id(internal_id)
|
||||
client_playermodel.position = position
|
||||
client_playermodel.find_child("Head").rotation.y = rotation.y
|
||||
#client_playermodel.find_child("Head").rotation.y = rotation.y
|
||||
client_playermodel.rotation.y = rotation.y
|
||||
client_playermodel.find_child("Head").find_child("Camera").rotation.x = rotation.x
|
||||
client["position"] = position
|
||||
client["rotation"] = rotation
|
||||
|
@ -140,6 +141,15 @@ func shot(client_id):
|
|||
|
||||
var target = weapon_raycast.get_collider()
|
||||
|
||||
var time_since_last_shot = (Time.get_ticks_msec() - client["last_shot"]) / 1000.
|
||||
|
||||
if (time_since_last_shot < current_weapon_settings["fireRate"] and client["last_shot"] > 0):
|
||||
return
|
||||
|
||||
if (client["current_weapon"]["magazine"] == 0):
|
||||
return
|
||||
client["last_shot"] = Time.get_ticks_msec()
|
||||
|
||||
if (target is CharacterBody3D):
|
||||
var target_internal_id = int(target.name.get_slice("player", 1))
|
||||
var target_client
|
||||
|
@ -158,14 +168,6 @@ func shot(client_id):
|
|||
damage = current_weapon_settings["damage"][s]
|
||||
break
|
||||
|
||||
var time_since_last_shot = (Time.get_ticks_msec() - client["last_shot"]) / 1000.
|
||||
|
||||
if (time_since_last_shot < current_weapon_settings["fireRate"] and client["last_shot"] > 0):
|
||||
return
|
||||
|
||||
if (client["current_weapon"]["magazine"] == 0):
|
||||
return
|
||||
client["last_shot"] = Time.get_ticks_msec()
|
||||
var target_client_team = 1 if target_client["class_type"] > 0 else -1
|
||||
var client_team = 1 if client["class_type"] > 0 else -1
|
||||
|
||||
|
@ -175,7 +177,7 @@ func shot(client_id):
|
|||
else:
|
||||
target_client["HP"] -= damage
|
||||
|
||||
if (target_client["HP"] <= 0):
|
||||
if (target_client["HP"] <= 0): ###########killed
|
||||
var index = abs(client["class_type"])
|
||||
var respawn = Vector3(0, 10 ,0)
|
||||
if (target_client_team == 1):
|
||||
|
@ -189,6 +191,7 @@ func shot(client_id):
|
|||
target_client["position"] = respawn
|
||||
target_client["HP"] = 100
|
||||
target.teleport.rpc_id(target_client_id, target_client["position"])
|
||||
NetUtils.send_everyone(["kill_notification", client["nickname"], target_client["nickname"]])
|
||||
ServerUtils.check_gamemode_end_conditions()
|
||||
target.set_hp.rpc_id(target_client_id, target_client["HP"])
|
||||
elif (target is StaticBody3D):
|
||||
|
|
|
@ -60,7 +60,7 @@ var round_status = {
|
|||
@onready var head = $Head
|
||||
@onready var camera: Camera3D = $Head/Camera
|
||||
@onready var playerCharacterBody = $"."
|
||||
|
||||
@onready var collision_shapes = find_children("collision*","",false)
|
||||
var HUD
|
||||
var healthLabel
|
||||
var armorLabel
|
||||
|
@ -74,6 +74,7 @@ var osScoreGameLabel
|
|||
var roundNumberLabel
|
||||
var timeLabel
|
||||
var winnerLabel
|
||||
var killLogList
|
||||
|
||||
func set_properties(props):
|
||||
properties = props
|
||||
|
@ -104,6 +105,8 @@ func init_hud():
|
|||
roundNumberLabel = $"HUD/round_status/round_number"
|
||||
timeLabel = $"HUD/round_status/time"
|
||||
winnerLabel = $"HUD/round_status/winner"
|
||||
|
||||
killLogList = $"HUD/kill_log"
|
||||
|
||||
func update_hud():
|
||||
healthLabel.text = str(properties["HP"])
|
||||
|
@ -219,15 +222,15 @@ func _unhandled_input(event):
|
|||
change_weapon(properties["current_weapon"]["number"])
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
head.rotate_y(-event.relative.x * SENSETIVITY)
|
||||
rotate_y(-event.relative.x * SENSETIVITY)
|
||||
camera.rotate_x(-event.relative.y * SENSETIVITY)
|
||||
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-50), deg_to_rad(60))
|
||||
|
||||
func _physics_process(delta):
|
||||
#var collision_shapes = find_children("collision*","",false)
|
||||
#print(str(collision_shapes))
|
||||
#for shape:CollisionShape3D in collision_shapes:
|
||||
#shape.rotation = rotation
|
||||
##shape.rotation = self.rotation
|
||||
#shape.rotate_y(head.rotation.y)
|
||||
#shapee.
|
||||
if (!properties["is_playable"]): return
|
||||
if (game_settings == null): return
|
||||
if (multiplayer.multiplayer_peer == null):
|
||||
|
@ -248,7 +251,7 @@ func _physics_process(delta):
|
|||
get_tree().create_timer(game_settings["weapons"][current_weapon]["reload"]).connect("timeout", reload)
|
||||
|
||||
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
||||
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
|
||||
if direction:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * acceleration)
|
||||
|
@ -284,7 +287,7 @@ func _physics_process(delta):
|
|||
climbing = false
|
||||
#print("Collided with: " + body.name)
|
||||
if (!multiplayer.is_server()):
|
||||
Networking.sync_client.rpc_id(1, multiplayer.get_unique_id(), $".".position, {"y": head.rotation.y, "x": camera.rotation.x})
|
||||
Networking.sync_client.rpc_id(1, multiplayer.get_unique_id(), $".".position, {"y": rotation.y, "x": camera.rotation.x})
|
||||
#print("I am " + $"..".name +", belonging of " + str(multiplayer.get_unique_id()) + ", with internal ID: " + str(properties["internal_id"]))
|
||||
|
||||
@rpc ("authority", "call_remote", "unreliable")
|
||||
|
@ -293,7 +296,7 @@ func sync_puppet(i_id, p, rot):
|
|||
if(properties["is_playable"]): return
|
||||
if (int(i_id) == properties["internal_id"]):
|
||||
playerCharacterBody.position = p
|
||||
head.rotation.y = rot.y
|
||||
rotation.y = rot.y
|
||||
camera.rotation.x = rot.x
|
||||
|
||||
@rpc ("authority", "call_remote", "reliable")
|
||||
|
@ -340,3 +343,7 @@ func end_round(result):
|
|||
winnerLabel.visible = false
|
||||
winnerLabel.text = ""
|
||||
|
||||
@rpc("authority", "call_remote", "reliable")
|
||||
func kill_notification(killer, victim):
|
||||
var entry = load("res://scenes/models/kill_log_entry.tscn").instantiate()
|
||||
killLogList.add_child(entry)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
extends HBoxContainer
|
||||
|
||||
|
||||
func _ready():
|
||||
await get_tree().create_timer(5).timeout
|
||||
for alpha in range(100, -1, -1):
|
||||
print(str(float(alpha) / 100.))
|
||||
|
||||
self.modulate = Color(1, 1, 1, float(alpha) / 100.)
|
||||
await get_tree().create_timer(0.01).timeout
|
||||
|
||||
free()
|
Loading…
Reference in New Issue