WIP: Start working on the frag/damage system
This commit is contained in:
@ -4,10 +4,12 @@ class_name MapController extends Node
|
||||
const PLAYER_SPAWNER: String = "res://scenes/maps/base/player_spawner/player_spawner.tscn"
|
||||
const OBJECT_SPAWNER: String = "res://scenes/maps/base/object_spawner/object_spawner.tscn"
|
||||
const BULLET_SPAWNER: String = "res://scenes/maps/base/bullet_spawner/bullet_spawner.tscn"
|
||||
const NPC_SPAWNER: String = "res://scenes/maps/base/npc_spawner/npc_spawner.tscn"
|
||||
|
||||
var player_spawner: PlayerSpawnerController
|
||||
var object_spawner: Node3D
|
||||
var bullet_spawner: BulletSpawnerController
|
||||
var npc_spawner: Node3D
|
||||
@onready var spawn_locations: SpawnController = $SpawnLocations
|
||||
|
||||
func _on_player_connected(id):
|
||||
@ -89,6 +91,17 @@ func _add_bullet_spawner() -> Error :
|
||||
add_child(node)
|
||||
bullet_spawner = node
|
||||
return OK
|
||||
|
||||
func _add_npc_spawner() -> Error :
|
||||
if not ResourceLoader.exists(NPC_SPAWNER):
|
||||
return ERR_DOES_NOT_EXIST
|
||||
var scene: PackedScene = ResourceLoader.load(NPC_SPAWNER)
|
||||
if not scene.can_instantiate():
|
||||
return ERR_CANT_OPEN
|
||||
var node: Node3D = scene.instantiate()
|
||||
add_child(node)
|
||||
npc_spawner = node
|
||||
return OK
|
||||
|
||||
# -- TODO: Better bullet naming handler
|
||||
var bullet_amount: int = -2147483647
|
||||
|
8
scenes/maps/base/npc_spawner/npc_spawner.tscn
Normal file
8
scenes/maps/base/npc_spawner/npc_spawner.tscn
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://bgb01iv0fekje"]
|
||||
|
||||
[node name="NpcSpawner" type="Node3D"]
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
|
||||
spawn_path = NodePath("../NPC")
|
||||
|
||||
[node name="NPC" type="Node3D" parent="."]
|
@ -1,7 +1,9 @@
|
||||
[gd_scene load_steps=76 format=4 uid="uid://dddu0t2sdcy8h"]
|
||||
[gd_scene load_steps=79 format=4 uid="uid://dddu0t2sdcy8h"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/maps/base/map_loader.gd" id="1_innhj"]
|
||||
[ext_resource type="Script" path="res://scenes/maps/base/spawn_controller.gd" id="2_1ss1b"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdcbn8mglqlyh" path="res://scenes/maps/tools/hit_detector.tscn" id="3_hjypr"]
|
||||
[ext_resource type="PackedScene" uid="uid://b7vj5j6wxqrfr" path="res://scenes/characters/npc/zombie/zombie.tscn" id="4_32d4x"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_umuqw"]
|
||||
resource_name = "Material_146"
|
||||
@ -755,14 +757,17 @@ sky = SubResource("Sky_8ov8p")
|
||||
ambient_light_source = 3
|
||||
ambient_light_color = Color(1, 1, 1, 1)
|
||||
reflected_light_source = 2
|
||||
ssao_enabled = true
|
||||
glow_enabled = true
|
||||
fog_density = 0.3
|
||||
fog_enabled = true
|
||||
fog_density = 0.103
|
||||
fog_height = 1.5
|
||||
fog_height_density = 2.0
|
||||
volumetric_fog_density = 0.5118
|
||||
volumetric_fog_albedo = Color(0.574998, 0.574998, 0.574998, 1)
|
||||
|
||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_402xp"]
|
||||
dof_blur_far_transition = -1.0
|
||||
|
||||
[node name="Map" type="Node3D"]
|
||||
script = ExtResource("1_innhj")
|
||||
|
||||
@ -973,10 +978,11 @@ use_collision = true
|
||||
[node name="Light" type="Node3D" parent="."]
|
||||
|
||||
[node name="MainLight" type="DirectionalLight3D" parent="Light"]
|
||||
transform = Transform3D(-0.080856, -0.707107, 0.702469, -0.0808559, 0.707107, 0.702469, -0.993441, 1.60778e-07, -0.114348, 79.2354, 89.2354, -3.02637e-06)
|
||||
transform = Transform3D(-0.080856, -0.707107, 0.702469, -0.0808559, 0.707107, 0.702469, -0.993441, 1.60778e-07, -0.114348, 54.2751, 36.4316, 6.32922)
|
||||
light_energy = 3.325
|
||||
light_indirect_energy = 3.457
|
||||
light_volumetric_fog_energy = 1.64
|
||||
shadow_enabled = true
|
||||
directional_shadow_mode = 1
|
||||
|
||||
[node name="SpawnLocations" type="Node3D" parent="."]
|
||||
@ -1018,3 +1024,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -42.595, -0.0187502, -17.3639
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_3ha0j")
|
||||
camera_attributes = SubResource("CameraAttributesPractical_402xp")
|
||||
|
||||
[node name="HitDetector" parent="." instance=ExtResource("3_hjypr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 32.1837, 9.29777, -7.02714)
|
||||
|
||||
[node name="Zombie" parent="." instance=ExtResource("4_32d4x")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 32.4367, -0.00937653, -3.80586)
|
||||
|
24
scenes/maps/tools/hit_detector.gd
Normal file
24
scenes/maps/tools/hit_detector.gd
Normal file
@ -0,0 +1,24 @@
|
||||
extends CSGBox3D
|
||||
class_name HitDetector
|
||||
|
||||
var health = 5
|
||||
|
||||
@export var color: Color = Color(0, 0, 0)
|
||||
|
||||
var colors = [Color(1.0, 0.0, 0.0, 1.0),
|
||||
Color(0.0, 1.0, 0.0, 1.0),
|
||||
Color(0.0, 0.0, 1.0, 0.0)]
|
||||
|
||||
func hit(damage: int):
|
||||
color = Color(randf(), randf(), randf())
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
material_override.albedo_color = color
|
||||
if health < 1:
|
||||
queue_free()
|
24
scenes/maps/tools/hit_detector.tscn
Normal file
24
scenes/maps/tools/hit_detector.tscn
Normal file
@ -0,0 +1,24 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cdcbn8mglqlyh"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/maps/tools/hit_detector.gd" id="1_4w4v8"]
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_8tws6"]
|
||||
properties/0/path = NodePath("Box:color")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_petk4"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5m44n"]
|
||||
|
||||
[node name="HitDetector" type="Node3D"]
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="." groups=["target"]]
|
||||
replication_config = SubResource("SceneReplicationConfig_8tws6")
|
||||
|
||||
[node name="Box" type="CSGBox3D" parent="." groups=["target"]]
|
||||
material_override = SubResource("StandardMaterial3D_petk4")
|
||||
use_collision = true
|
||||
collision_layer = 9
|
||||
material = SubResource("StandardMaterial3D_5m44n")
|
||||
script = ExtResource("1_4w4v8")
|
Reference in New Issue
Block a user