WIP: Start working on the frag/damage system
This commit is contained in:
@ -8,8 +8,12 @@ class_name PlayerPlaceholder
|
||||
@onready var server_node: PlayerServerNode = $ServerControlledNode
|
||||
@export var character_speed: int = 5
|
||||
@onready var bullet_starting_poing: Node3D = $ServerControlledNode/BulletStartingPoint
|
||||
@export var default_weapon: String = "deagle"
|
||||
|
||||
|
||||
@export var weapon_slot_1: String = "ak"
|
||||
@export var weapon_slot_2: String = "deagle"
|
||||
@export var weapon_slot_3: String = ""
|
||||
@export var weapon_slot_4: String = ""
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@ -18,10 +22,14 @@ func _ready() -> void:
|
||||
$PlayerControlledNode/CameraMount.set_multiplayer_authority(owner_id)
|
||||
switch_players_camera.rpc_id(owner_id)
|
||||
server_node.global_position = initial_position
|
||||
|
||||
client_node.global_position = server_node.global_position
|
||||
client_node.rotation.y = server_node.rotation.y
|
||||
client_node.rotation.x = server_node.rotation.x
|
||||
|
||||
client_node.set_default_weapon_meta.rpc_id(owner_id, 1, "ak")
|
||||
client_node.set_default_weapon_meta.rpc_id(owner_id, 2, "deagle")
|
||||
client_node.set_default_weapon_meta.rpc_id(owner_id, 3, "vector")
|
||||
client_node._preload_weapon.rpc_id(owner_id)
|
||||
if multiplayer.is_server():
|
||||
$Timer.start()
|
||||
if owner_id != multiplayer.get_unique_id():
|
||||
@ -30,7 +38,8 @@ func _ready() -> void:
|
||||
pass
|
||||
#client_node._add_legs_to_first_view()
|
||||
|
||||
|
||||
func _set_default_weapon():
|
||||
pass
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
#if desired_player_state.globa_position != real_player_state.globa_position:
|
||||
|
@ -3,7 +3,6 @@
|
||||
[ext_resource type="Script" path="res://scenes/player/player_input_controller.gd" id="1_m6tul"]
|
||||
[ext_resource type="Script" path="res://scenes/player/placeholder.gd" id="1_ts455"]
|
||||
[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="3_8ulsx"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtvo21mk1webd" path="res://scenes/weapon/guns/ak/with_hands.tscn" id="3_xxv4y"]
|
||||
[ext_resource type="PackedScene" uid="uid://1txob6jskn5s" path="res://scenes/characters/blue/dummy.tscn" id="5_16l76"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_taqso"]
|
||||
@ -17,6 +16,10 @@ font_size = 70
|
||||
font_size = 100
|
||||
font_color = Color(0.756874, 0, 0.223924, 1)
|
||||
|
||||
[sub_resource type="Environment" id="Environment_i2xeo"]
|
||||
sdfgi_enabled = true
|
||||
glow_enabled = true
|
||||
|
||||
[sub_resource type="Animation" id="Animation_falg4"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
@ -184,8 +187,10 @@ size = Vector2i(1920, 1964)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.30409, -0.371306)
|
||||
cull_mask = 524288
|
||||
fov = 40.0
|
||||
environment = SubResource("Environment_i2xeo")
|
||||
fov = 50.0
|
||||
|
||||
[node name="GunMount" type="Node3D" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D"]
|
||||
|
||||
@ -194,12 +199,8 @@ libraries = {
|
||||
"": SubResource("AnimationLibrary_u1b6p")
|
||||
}
|
||||
|
||||
[node name="WithHands" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount" instance=ExtResource("3_xxv4y")]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, -0.3, -0.4, 0)
|
||||
visible = false
|
||||
|
||||
[node name="BulletStartingPoint" type="Node3D" parent="PlayerControlledNode/CameraMount"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -0.42185)
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -0.00364852)
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="PlayerControlledNode"]
|
||||
|
||||
@ -217,7 +218,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.786919, 0)
|
||||
shape = SubResource("CapsuleShape3D_taqso")
|
||||
|
||||
[node name="BulletStartingPoint" type="Node3D" parent="ServerControlledNode"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.287, -0.54568)
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.287, -0.37786)
|
||||
|
||||
[node name="Dummy" parent="ServerControlledNode" instance=ExtResource("5_16l76")]
|
||||
visible = false
|
||||
|
@ -18,7 +18,7 @@ const JUMP_VELOCITY = 4.5
|
||||
|
||||
|
||||
#func _ready() -> void:
|
||||
var current_gun: String = "ak"
|
||||
var current_gun: String = "m1"
|
||||
@onready var gun_mount: Node3D = $CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount
|
||||
@onready var gun_mount_anim: AnimationPlayer = $CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount/AnimationPlayer
|
||||
var gun_with_hands: Node3D = null
|
||||
@ -30,28 +30,79 @@ var current_weapon_bullet_speed: int
|
||||
var current_weapon_cooldown_interwal: float
|
||||
var look_dir: Vector2
|
||||
var moving = false
|
||||
|
||||
@export var equipment_meta: Dictionary = {}
|
||||
@export var equipment: Dictionary = {}
|
||||
var chosen_weapon: int = 1
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
global_position = $"..".initial_position
|
||||
_add_legs_to_first_view()
|
||||
# -- TODO: It should not be hardcoded
|
||||
# Define a format string with placeholder '%s'
|
||||
#var path_tmpl := "res://scenes/weapon/guns/%s/with_hands.tscn"
|
||||
#var path := path_tmpl % current_gun
|
||||
#var scene: PackedScene = ResourceLoader.load(path)
|
||||
#var node: Node3D = scene.instantiate()
|
||||
#node.scale = Vector3(0.5,0.5,0.5)
|
||||
#node.position = Vector3(-0.3, -0.4, 0)
|
||||
#current_weapon_bullet_speed = node.bullet_speed
|
||||
#current_weapon_cooldown_interwal = node.cooldown
|
||||
#current_weapon_damage = node.damage
|
||||
#gun_with_hands = node
|
||||
#gun_mount.add_child(node)
|
||||
|
||||
@rpc('any_peer', 'call_local', "reliable")
|
||||
func set_default_weapon_meta(slot: int, name: String):
|
||||
equipment_meta[slot] = name
|
||||
print(equipment_meta)
|
||||
|
||||
func load_weapon(name: String) -> Error:
|
||||
var path_tmpl := "res://scenes/weapon/guns/%s/with_hands.tscn"
|
||||
var path := path_tmpl % current_gun
|
||||
var path := path_tmpl % name
|
||||
var scene: PackedScene = ResourceLoader.load(path)
|
||||
var node: Node3D = scene.instantiate()
|
||||
node.scale = Vector3(0.5,0.5,0.5)
|
||||
node.position = Vector3(-0.3, -0.4, 0)
|
||||
current_weapon_bullet_speed = node.bullet_speed
|
||||
current_weapon_cooldown_interwal = node.cooldown
|
||||
current_weapon_damage = node.damage
|
||||
gun_with_hands = node
|
||||
gun_mount.add_child(node)
|
||||
return OK
|
||||
|
||||
@rpc('any_peer', 'call_local', "reliable")
|
||||
func _preload_weapon():
|
||||
for i in equipment_meta:
|
||||
var weapon_name = equipment_meta[i]
|
||||
print(weapon_name)
|
||||
var path_tmpl := "res://scenes/weapon/guns/%s/with_hands.tscn"
|
||||
var path := path_tmpl % weapon_name
|
||||
var scene: PackedScene = ResourceLoader.load(path)
|
||||
var node: Node3D = scene.instantiate()
|
||||
node.scale = Vector3(0.5,0.5,0.5)
|
||||
node.position = Vector3(-0.3, -0.4, 0)
|
||||
node.name = "CurrentWeapon"
|
||||
node.visible = 0
|
||||
equipment[weapon_name] = node
|
||||
gun_mount.add_child(node)
|
||||
|
||||
|
||||
func _choose_weapon(slot: int):
|
||||
if chosen_weapon != slot:
|
||||
if equipment_meta.has(chosen_weapon):
|
||||
if equipment.has(equipment_meta[chosen_weapon]):
|
||||
if equipment[equipment_meta[chosen_weapon]] != null:
|
||||
equipment[equipment_meta[chosen_weapon]].visible = 0
|
||||
chosen_weapon = slot
|
||||
if equipment_meta.has(slot):
|
||||
var desired_weapon: String = equipment_meta[slot]
|
||||
if equipment.has(desired_weapon):
|
||||
equipment[equipment_meta[chosen_weapon]].visible = 1
|
||||
|
||||
|
||||
func _input(event):
|
||||
if multiplayer.get_unique_id() == get_multiplayer_authority():
|
||||
if Input.is_action_just_pressed("jump"): jumping = true
|
||||
if Input.is_action_just_pressed("shoot"): shooting = true
|
||||
if Input.is_action_just_released("shoot"): shooting = false
|
||||
if Input.is_action_just_pressed("weapon_slot_1"): _choose_weapon(1)
|
||||
if Input.is_action_just_pressed("weapon_slot_2"): _choose_weapon(2)
|
||||
if Input.is_action_just_pressed("weapon_slot_3"): _choose_weapon(3)
|
||||
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
look_dir = event.relative * 1
|
||||
rotation.y -= look_dir.x * camera_sens * 1.0
|
||||
@ -95,9 +146,11 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if moving:
|
||||
gun_mount_anim.play("move")
|
||||
pass
|
||||
#gun_mount_anim.play("move")
|
||||
else:
|
||||
gun_mount_anim.stop()
|
||||
pass
|
||||
#gun_mount_anim.stop()
|
||||
move_and_slide()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user