Compare commits

23 Commits

Author SHA1 Message Date
ce7b74c832 Networking 2023-01-17 22:30:12 +01:00
9893bc45b4 fully sync player movements over network 2023-01-17 13:54:26 +01:00
1ef5d54d6c start Multiplayer 2023-01-15 23:59:12 +01:00
5cfc0839f7 add entity collision option 2023-01-03 23:43:30 +01:00
2e4c378991 small fix 2023-01-03 23:29:55 +01:00
40d73f2590 improve runtimeloader for glb files 2023-01-03 23:28:43 +01:00
a7118b3d77 update scoom data 2023-01-03 23:18:52 +01:00
b2b82271f7 fix weapon draw bug 2023-01-03 23:16:05 +01:00
b5286a5f54 extend PCK support 2023-01-03 01:00:11 +01:00
4c8499f4f0 add Scoom-Data submodule 2023-01-02 22:10:27 +01:00
5a891a5636 delete unwanted files 2023-01-02 22:07:30 +01:00
701bcfd39c PCK File loader 2023-01-02 17:55:28 +01:00
4de8162f48 Merge branch 'main' of ssh://git.peroxy.dev:222/kookroach/Scoom 2023-01-01 19:35:00 +01:00
face5c4527 Pre-Release 2023-01-01 19:34:37 +01:00
2c2641c1d3 Add 'README.md' 2022-12-31 12:01:35 +01:00
54a90ab22c add trenchbroom map 2022-12-31 03:49:35 +01:00
d808ef5a53 add runtime object loader (gltf only) 2022-12-31 03:49:01 +01:00
56255f5473 add modding support 2022-12-31 03:48:00 +01:00
d2ed1afdc7 Add modified weapon models 2022-12-07 08:41:10 +01:00
307eec1f4e Add Reload Animation 2022-12-06 15:10:38 +01:00
9eb5099b0e Update 'README.md' 2022-12-06 14:04:08 +01:00
140a97a15a Update README.md 2022-12-06 14:03:36 +01:00
6bc2b07ab6 Start Hitscan & add Crosshair shader 2022-12-06 14:02:22 +01:00
80 changed files with 1648 additions and 1961 deletions

BIN
.exr Normal file

Binary file not shown.

View File

@@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bk3khvviorvmm" uid="uid://bpsjhyhlis3ov"
path="res://.godot/imported/untitled.png-d7b497081dc8ae225dae2b6ac59973dc.ctex" path="res://.godot/imported/.exr-a7725c7e971a9679cf60303f5fa7defa.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://assets/Weapons/Bullet/untitled.png" source_file="res://.exr"
dest_files=["res://.godot/imported/untitled.png-d7b497081dc8ae225dae2b6ac59973dc.ctex"] dest_files=["res://.godot/imported/.exr-a7725c7e971a9679cf60303f5fa7defa.ctex"]
[params] [params]

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "scoom"]
path = scoom
url = ssh://git@git.peroxy.dev:222/kookroach/Scoom-Data.git

BIN
Game.exr

Binary file not shown.

View File

@@ -1,28 +0,0 @@
[remap]
importer="2d_array_texture"
type="CompressedTexture2DArray"
uid="uid://djhovwrdokme0"
path.etc2="res://.godot/imported/Game.exr-72bd638e1628ca77f007b851e1ccfc0d.etc2.ctexarray"
path.s3tc="res://.godot/imported/Game.exr-72bd638e1628ca77f007b851e1ccfc0d.s3tc.ctexarray"
metadata={
"imported_formats": ["etc2", "s3tc"],
"vram_texture": true
}
[deps]
source_file="res://Game.exr"
dest_files=["res://.godot/imported/Game.exr-72bd638e1628ca77f007b851e1ccfc0d.etc2.ctexarray", "res://.godot/imported/Game.exr-72bd638e1628ca77f007b851e1ccfc0d.s3tc.ctexarray"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/channel_pack=1
mipmaps/generate=false
mipmaps/limit=-1
slices/horizontal=1
slices/vertical=1

29
Game.gd
View File

@@ -1,18 +1,30 @@
extends Node3D extends Node3D
class_name Game
signal game_loaded
@onready var label : Label = $CanvasLayer/Label var init_config
@onready var player : CharacterBody3D = $PlayerQ3 var weapon_config
func _ready(): func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) weapon_config = Runtimeloader.loadConfig("weapons.cfg") as ConfigFile
init_config = Runtimeloader.loadConfig("init.cfg") as ConfigFile
print("Loading PCK...")
for map_list in init_config.get_section_keys("MAPS"):
for map in init_config.get_value("MAPS", map_list):
Runtimeloader.loadPCK(map)
func _process(_delta): for weapons_list in init_config.get_section_keys("WEAPONS"):
label.text = "H Velocity: %3.2f" % [Vector2(player.velocity.x, player.velocity.z).length()] for weapon in init_config.get_value("WEAPONS", weapons_list):
label.text += "\nV Velocity: %3.2f" % [player.velocity.y] Runtimeloader.loadPCK(weapon)
label.text += "\nOn floor: %s" % player.is_on_floor()
print("Loading Resources Done.")
func load_map():
Runtimeloader.loadScene("maps/test_map.tscn", self)
#Runtimeloader.get_all_entities(node)
game_loaded.emit()
func _input(event): func _input(event):
@@ -24,3 +36,4 @@ func _input(event):
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
elif event.keycode == KEY_ESCAPE: elif event.keycode == KEY_ESCAPE:
get_tree().quit() get_tree().quit()

Binary file not shown.

View File

@@ -1,51 +0,0 @@
[gd_scene load_steps=8 format=3 uid="uid://cqutof7bvocqc"]
[ext_resource type="LightmapGIData" uid="uid://k5haifo34pp6" path="res://Game.lmbake" id="2_3k1jt"]
[ext_resource type="PackedScene" uid="uid://bl7jynld7s25o" path="res://scenes/player/PlayerQ3.tscn" id="2_dhifo"]
[ext_resource type="Script" path="res://Game.gd" id="3"]
[ext_resource type="PackedScene" uid="uid://bke5cip8sjpoq" path="res://scenes/map/entity_0_worldspawn.tscn" id="3_3r3q4"]
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_mv01y"]
[sub_resource type="Sky" id="Sky_ybtis"]
sky_material = SubResource("PhysicalSkyMaterial_mv01y")
[sub_resource type="Environment" id="Environment_ul6y4"]
background_mode = 2
sky = SubResource("Sky_ybtis")
ambient_light_source = 3
reflected_light_source = 2
tonemap_mode = 2
tonemap_exposure = 2.0
[node name="Game" type="Node3D"]
script = ExtResource("3")
[node name="LightmapGI" type="LightmapGI" parent="."]
visible = false
quality = 2
bounces = 6
light_data = ExtResource("2_3k1jt")
[node name="LightmapProbe" type="LightmapProbe" parent="."]
visible = false
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_ul6y4")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.77938, 0.395123, -0.486256, 0.383799, 0.312364, 0.86898, 0.495243, -0.86389, 0.0918022, 0, 22.9909, 0)
light_indirect_energy = 1.5
light_bake_mode = 1
shadow_enabled = true
[node name="entity_0_worldspawn" parent="." instance=ExtResource("3_3r3q4")]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Label" type="Label" parent="CanvasLayer"]
offset_right = 40.0
offset_bottom = 14.0
[node name="PlayerQ3" parent="." instance=ExtResource("2_dhifo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.6672, 11.2181)

View File

@@ -1,4 +1,6 @@
# SCOOM (name may be changed) # SCOOM (name may be changed)
Developing a 3D game inspired by Doom64 on Godot 4 engine. Developing a 3D game inspired by Doom64 on Godot 4 engine.
[Simple-Q3-Controller](https://github.com/fossegutten/Simple-Q3-Controller) by fossegutten Using:
- [Simple-Q3-Controller](https://github.com/fossegutten/Simple-Q3-Controller) by fossegutten
- [CrosshairShader](https://github.com/0xspig/CrosshairShader) by 0xspig

View File

@@ -1,20 +0,0 @@
@tool
extends EditorPlugin
func _enter_tree() -> void:
add_custom_type(
"SfxrStreamPlayer", "AudioStreamPlayer", load("res://addons/godot_sfxr/SfxrStreamPlayer.gd"),
get_editor_interface().get_base_control().get_theme_icon("AudioStreamPlayer", "EditorIcons"))
add_custom_type(
"SfxrStreamPlayer2D", "AudioStreamPlayer2D", load("res://addons/godot_sfxr/SfxrStreamPlayer2D.gd"),
get_editor_interface().get_base_control().get_theme_icon("AudioStreamPlayer2D", "EditorIcons"))
add_custom_type(
"SfxrStreamPlayer3D", "AudioStreamPlayer3D", load("res://addons/godot_sfxr/SfxrStreamPlayer3D.gd"),
get_editor_interface().get_base_control().get_theme_icon("AudioStreamPlayer3D", "EditorIcons"))
func _exit_tree() -> void:
remove_custom_type("SfxrStreamPlayer")
remove_custom_type("SfxrStreamPlayer2D")
remove_custom_type("SfxrStreamPlayer3D")

View File

@@ -1,309 +0,0 @@
extends RefCounted
class_name SfxrGenerator
var params
var wave_shape: int
var repeat_time: float
var elapsed_since_repeat: float
var arpeggio_time: int
var arpeggio_multiplier: float
var period: float
var period_mult: float
var period_mult_slide: float
var period_max: float
var enable_frequency_cutoff: bool
var duty_cycle: float
var duty_cycle_slide: float
var fltw: float
var fltw_d: float
var fltdmp: float
var flthp: float
var flthp_d: float
var enable_low_pass_filter: bool
var vibrato_speed: float
var vibrato_amplitude: float
var envelope_length: Array
var envelope_punch: float
var flanger_offset: float
var flanger_offset_slide: float
var gain: float
var sample_rate: float
func init_params(stream_player) -> void:
params = stream_player
prepare_values()
# Wave shape
wave_shape = params.wave_type
# Filter
fltw = pow(params.p_lpf_freq, 3.0) * 0.1
enable_low_pass_filter = params.p_lpf_freq != 1.0
fltw_d = 1.0 + params.p_lpf_ramp * 0.0001
fltdmp = 5.0 / (1.0 + pow(params.p_lpf_resonance, 2.0) * 20.0) * (0.01 + fltw)
if (fltdmp > 0.8):
fltdmp = 0.8
flthp = pow(params.p_hpf_freq, 2.0) * 0.1
flthp_d = 1 + params.p_hpf_ramp * 0.0003
# Vibrato
vibrato_speed = pow(params.p_vib_speed, 2.0) * 0.01
vibrato_amplitude = params.p_vib_strength * 0.5
# Envelope
envelope_length = [
floor(params.p_env_attack * params.p_env_attack * 100000.0),
floor(params.p_env_sustain * params.p_env_sustain * 100000.0),
floor(params.p_env_decay * params.p_env_decay * 100000.0),
]
envelope_punch = params.p_env_punch
# Flanger
flanger_offset = pow(params.p_pha_offset, 2.0) * 1020.0
if (params.p_pha_offset < 0.0):
flanger_offset = -flanger_offset
flanger_offset_slide = pow(params.p_pha_ramp, 2.0) * 1.0
if (params.p_pha_ramp < 0.0):
flanger_offset_slide = -flanger_offset_slide
# Repeat
repeat_time = floor(pow(1 - params.p_repeat_speed, 2.0) * 20000.0 + 32.0)
if (params.p_repeat_speed == 0.0):
repeat_time = 0.0
gain = exp(params.sound_vol) - 1.0
sample_rate = params.sample_rate
func prepare_values() -> void:
elapsed_since_repeat = 0.0
period = 100.0 / (params.p_base_freq * params.p_base_freq + 0.001)
period_max = 100.0 / (params.p_freq_limit * params.p_freq_limit + 0.001)
enable_frequency_cutoff = params.p_freq_limit > 0.0
period_mult = 1.0 - pow(params.p_freq_ramp, 3.0) * 0.01
period_mult_slide = -pow(params.p_freq_dramp, 3.0) * 0.000001
duty_cycle = 0.5 - params.p_duty * 0.5
duty_cycle_slide = -params.p_duty_ramp * 0.00005
if (params.p_arp_mod >= 0.0):
arpeggio_multiplier = 1.0 - pow(params.p_arp_mod, 2.0) * 0.9
else:
arpeggio_multiplier = 1.0 + pow(params.p_arp_mod, 2.0) * 10.0
arpeggio_time = floor(pow(1.0 - params.p_arp_speed, 2.0) * 20000.0 + 32.0)
if (params.p_arp_speed == 1.0):
arpeggio_time = 0
func get_raw_buffer() -> Array:
randomize()
var fltp: float = 0.0
var fltdp: float = 0.0
var fltphp: float = 0.0
var noise_buffer_length: int = 32
var noise_buffer: Array = []
for i in noise_buffer_length:
noise_buffer.append(randf() * 2.0 - 1.0)
var envelope_stage: int = 0
var envelope_elapsed: float = 0.0
var vibrato_phase: float = 0.0
var phase: int = 0
var ipp: int = 0
var flanger_buffer_length: int = 1024
var flanger_buffer: Array = []
for i in flanger_buffer_length:
flanger_buffer.append(0.0)
var _buffer: Array = []
var sample_sum: float = 0.0
var num_summed: float = 0.0
var summands: int = floor(44100.0 / sample_rate)
var t: float = -1.0
while t < INF:
t += 1
# Repeats
elapsed_since_repeat += 1.0
if (repeat_time != 0.0 and elapsed_since_repeat >= repeat_time):
prepare_values()
# Arpeggio (single)
if (arpeggio_time != 0 and t >= arpeggio_time):
arpeggio_time = 0
period *= arpeggio_multiplier
# Frequency slide, and frequency slide slide!
period_mult += period_mult_slide
period *= period_mult
if (period > period_max):
period = period_max
if (enable_frequency_cutoff):
break
# Vibrato
var rfperiod: float = period
if (vibrato_amplitude > 0.0):
vibrato_phase += vibrato_speed
rfperiod = period * (1.0 + sin(vibrato_phase) * vibrato_amplitude)
var iperiod: int = floor(rfperiod)
if (iperiod < SfxrGlobals.OVERSAMPLING):
iperiod = SfxrGlobals.OVERSAMPLING
# Square wave duty cycle
duty_cycle = duty_cycle + duty_cycle_slide
if (duty_cycle > 0.5):
duty_cycle = 0.5
elif (duty_cycle < 0.0):
duty_cycle = 0.0
# Volume envelope
envelope_elapsed += 1.0
if (envelope_elapsed > envelope_length[envelope_stage]):
envelope_elapsed = 0.0
envelope_stage += 1.0
if (envelope_stage > 2.0):
break
if (envelope_length[envelope_stage] == 0):
continue
var env_vol: float = 0.0
var envf: float = envelope_elapsed / envelope_length[envelope_stage]
if (envelope_stage == 0.0): # Attack
env_vol = envf
elif (envelope_stage == 1.0): # Sustain
env_vol = 1.0 + (1.0 - envf) * 2.0 * envelope_punch
else: # Decay
env_vol = 1.0 - envf
# Flanger step
flanger_offset += flanger_offset_slide
var iphase: int = abs(floor(flanger_offset))
if (iphase > 1023):
iphase = 1023
if (flthp_d != 0.0):
flthp = flthp * flthp_d
if (flthp > 0.1):
flthp = 0.1
elif (flthp < 0.00001):
flthp = 0.00001
# 8x Oversampling
var sample: float = 0.0
for i in SfxrGlobals.OVERSAMPLING:
var sub_sample: float = 0.0
phase += 1
if (phase >= iperiod):
phase %= iperiod
if (wave_shape == SfxrGlobals.WAVE_SHAPES.NOISE):
for j in noise_buffer_length:
noise_buffer[i] = randf() * 2.0 - 1.0
# Base waveform
var fp: float = float(phase) / float(iperiod)
if (wave_shape == SfxrGlobals.WAVE_SHAPES.SQUARE):
if (fp < duty_cycle):
sub_sample = 0.5
else:
sub_sample = -0.5
elif (wave_shape == SfxrGlobals.WAVE_SHAPES.SAWTOOTH):
if (fp < duty_cycle):
sub_sample = -1.0 + 2.0 * fp / duty_cycle
else:
sub_sample = 1.0 - 2.0 * (fp - duty_cycle) / (1 - duty_cycle)
elif (wave_shape == SfxrGlobals.WAVE_SHAPES.SINE):
sub_sample = sin(fp * 2.0 * PI)
elif (wave_shape == SfxrGlobals.WAVE_SHAPES.NOISE):
sub_sample = noise_buffer[int(floor(phase * 32.0 / iperiod))]
else:
printerr("ERROR: Bad wave type: " + str(wave_shape))
sub_sample = 0
# Low-pass filter
var pp: float = fltp
fltw *= fltw_d
if (fltw > 0.1):
fltw = 0.1
elif (fltw < 0.0):
fltw = 0.0
if (enable_low_pass_filter):
fltdp += (sub_sample - fltp) * fltw
fltdp -= fltdp * fltdmp
else:
fltp = sub_sample
fltdp = 0.0
fltp += fltdp
# High-pass filter
fltphp += fltp - pp
fltphp -= fltphp * flthp
sub_sample = fltphp
# Flanger
flanger_buffer[ipp & 1023] = sub_sample
sub_sample += flanger_buffer[(ipp - iphase + 1024) & 1023]
ipp = (ipp + 1) & 1023
# Final accumulation and envelope application
sample += sub_sample * env_vol
# Accumulate samples appropriately for sample rate
sample_sum += sample
num_summed += 1.0
if (num_summed >= summands):
num_summed = 0.0
sample = sample_sum / summands
sample_sum = 0.0
else:
continue
sample = sample / SfxrGlobals.OVERSAMPLING * SfxrGlobals.MASTER_VOLUME
sample *= gain
sample = floor((sample + 1) * 128)
if (sample > 255):
sample = 255;
elif (sample < 0):
sample = 0
sample += 128
if sample > 255:
sample -= 255
_buffer.append(sample)
return _buffer
func build_sample(stream_player):
init_params(stream_player)
var sample: AudioStreamWAV = stream_player.stream
if (not sample):
stream_player.stream = AudioStreamWAV.new()
sample = stream_player.stream
sample.mix_rate = sample_rate
sample.data = PackedByteArray(get_raw_buffer())
return sample

View File

@@ -1,30 +0,0 @@
extends Object
class_name SfxrGlobals
enum WAVE_SHAPES {
SQUARE,
SAWTOOTH,
SINE,
NOISE,
}
enum PRESETS {
NONE,
PICKUP,
LASER,
EXPLOSION,
POWERUP,
HIT,
JUMP,
CLICK,
BLIP,
SYNTH,
RANDOM,
TONE,
MUTATE,
}
const OVERSAMPLING = 8
const MASTER_VOLUME = 1

View File

@@ -1,119 +0,0 @@
@tool
extends AudioStreamPlayer
# Wave Shape
var wave_type: int
# Envelope
var p_env_attack: float
var p_env_sustain: float
var p_env_punch: float
var p_env_decay: float
# Tone
var p_base_freq: float
var p_freq_limit: float
var p_freq_ramp: float
var p_freq_dramp: float
# Vibrato
var p_vib_strength: float
var p_vib_speed: float
# Tonal Change
var p_arp_mod: float
var p_arp_speed: float
# Square wve duty (proportion of time signal is high vs low)
var p_duty: float
var p_duty_ramp: float
# Repeat
var p_repeat_speed: float
# Flanger
var p_pha_offset: float
var p_pha_ramp: float
# Low-pass filter
var p_lpf_freq: float
var p_lpf_ramp: float
var p_lpf_resonance: float
# High-pass filter
var p_hpf_freq: float
var p_hpf_ramp: float
# Sample parameters
var sound_vol: float
var sample_rate: float
# Sfx Generation
var sfx_timer: SceneTreeTimer
##################################
# Inspector Properties
##################################
func _get_property_list() -> Array:
return SfxrStreamPlayerInterface.object_get_property_list()
func _get(property):
return SfxrStreamPlayerInterface.object_get(self, property)
func _set(property, value) -> bool:
return SfxrStreamPlayerInterface.object_set(self, property, value)
##################################
# Defaults
##################################
func _init():
SfxrStreamPlayerInterface.object_set_defaults(self)
func property_can_revert(property: String):
return SfxrStreamPlayerInterface.object_property_can_revert(property)
func property_get_revert(property: String):
return SfxrStreamPlayerInterface.object_property_get_revert(property)
##################################
# Presets
##################################
func random_preset() -> bool:
return SfxrStreamPlayerInterface.random_preset(self)
func preset_values(preset_key: int) -> bool:
return SfxrStreamPlayerInterface.preset_values(self, preset_key)
##################################
# Playback
##################################
func _on_sfx_timer_timeout(timer: SceneTreeTimer, play_after_build: bool):
SfxrStreamPlayerInterface._on_sfx_timer_timeout(self, timer, play_after_build)
func build_sfx(play_after_build: bool = false):
SfxrStreamPlayerInterface.build_sfx(self, play_after_build)
func play(from_position: float = 0.0):
if playing:
stop()
super.play(from_position)

View File

@@ -1,119 +0,0 @@
@tool
extends AudioStreamPlayer2D
# Wave Shape
var wave_type: int
# Envelope
var p_env_attack: float
var p_env_sustain: float
var p_env_punch: float
var p_env_decay: float
# Tone
var p_base_freq: float
var p_freq_limit: float
var p_freq_ramp: float
var p_freq_dramp: float
# Vibrato
var p_vib_strength: float
var p_vib_speed: float
# Tonal Change
var p_arp_mod: float
var p_arp_speed: float
# Square wve duty (proportion of time signal is high vs low)
var p_duty: float
var p_duty_ramp: float
# Repeat
var p_repeat_speed: float
# Flanger
var p_pha_offset: float
var p_pha_ramp: float
# Low-pass filter
var p_lpf_freq: float
var p_lpf_ramp: float
var p_lpf_resonance: float
# High-pass filter
var p_hpf_freq: float
var p_hpf_ramp: float
# Sample parameters
var sound_vol: float
var sample_rate: float
# Sfx Generation
var sfx_timer: SceneTreeTimer
##################################
# Inspector Properties
##################################
func _get_property_list() -> Array:
return SfxrStreamPlayerInterface.object_get_property_list()
func _get(property):
return SfxrStreamPlayerInterface.object_get(self, property)
func _set(property, value) -> bool:
return SfxrStreamPlayerInterface.object_set(self, property, value)
##################################
# Defaults
##################################
func _init():
SfxrStreamPlayerInterface.object_set_defaults(self)
func property_can_revert(property: String):
return SfxrStreamPlayerInterface.object_property_can_revert(property)
func property_get_revert(property: String):
return SfxrStreamPlayerInterface.object_property_get_revert(property)
##################################
# Presets
##################################
func random_preset() -> bool:
return SfxrStreamPlayerInterface.random_preset(self)
func preset_values(preset_key: int) -> bool:
return SfxrStreamPlayerInterface.preset_values(self, preset_key)
##################################
# Playback
##################################
func _on_sfx_timer_timeout(timer: SceneTreeTimer, play_after_build: bool):
SfxrStreamPlayerInterface._on_sfx_timer_timeout(self, timer, play_after_build)
func build_sfx(play_after_build: bool = false):
SfxrStreamPlayerInterface.build_sfx(self, play_after_build)
func play(from_position: float = 0.0):
if playing:
stop()
super.play(from_position)

View File

@@ -1,119 +0,0 @@
@tool
extends AudioStreamPlayer3D
# Wave Shape
var wave_type: int
# Envelope
var p_env_attack: float
var p_env_sustain: float
var p_env_punch: float
var p_env_decay: float
# Tone
var p_base_freq: float
var p_freq_limit: float
var p_freq_ramp: float
var p_freq_dramp: float
# Vibrato
var p_vib_strength: float
var p_vib_speed: float
# Tonal Change
var p_arp_mod: float
var p_arp_speed: float
# Square wve duty (proportion of time signal is high vs low)
var p_duty: float
var p_duty_ramp: float
# Repeat
var p_repeat_speed: float
# Flanger
var p_pha_offset: float
var p_pha_ramp: float
# Low-pass filter
var p_lpf_freq: float
var p_lpf_ramp: float
var p_lpf_resonance: float
# High-pass filter
var p_hpf_freq: float
var p_hpf_ramp: float
# Sample parameters
var sound_vol: float
var sample_rate: float
# Sfx Generation
var sfx_timer: SceneTreeTimer
##################################
# Inspector Properties
##################################
func _get_property_list() -> Array:
return SfxrStreamPlayerInterface.object_get_property_list()
func _get(property):
return SfxrStreamPlayerInterface.object_get(self, property)
func _set(property, value):
return SfxrStreamPlayerInterface.object_set(self, property, value)
##################################
# Defaults
##################################
func _init():
SfxrStreamPlayerInterface.object_set_defaults(self)
func property_can_revert(property: String):
return SfxrStreamPlayerInterface.object_property_can_revert(property)
func property_get_revert(property: String):
return SfxrStreamPlayerInterface.object_property_get_revert(property)
##################################
# Presets
##################################
func random_preset() -> bool:
return SfxrStreamPlayerInterface.random_preset(self)
func preset_values(preset_key: int) -> bool:
return SfxrStreamPlayerInterface.preset_values(self, preset_key)
##################################
# Playback
##################################
func _on_sfx_timer_timeout(timer: SceneTreeTimer, play_after_build: bool):
SfxrStreamPlayerInterface._on_sfx_timer_timeout(self, timer, play_after_build)
func build_sfx(play_after_build: bool = false):
SfxrStreamPlayerInterface.build_sfx(self, play_after_build)
func play(from_position: float = 0.0):
if playing:
stop()
super.play(from_position)

View File

@@ -1,477 +0,0 @@
extends Object
class_name SfxrStreamPlayerInterface
##################################
# Inspector Properties
##################################
const PROPERTY_MAP = {
# Sample params
"sample_params/sound_vol": {"name": "sound_vol", "hint_string": "0,1,0.000000001", "default": 0.25},
"sample_params/sample_rate": {"name": "sample_rate", "hint_string": "6000,44100,1", "default": 44100.0},
# Envelope
"envelope/attack_time": {"name": "p_env_attack", "hint_string": "0,1,0.000000001", "default": 0.0},
"envelope/sustain_time": {"name": "p_env_sustain", "hint_string": "0,1,0.000000001", "default": 0.6641},
"envelope/punch_time": {"name": "p_env_punch", "hint_string": "0,1,0.000000001", "default": 0.0},
"envelope/decay_time": {"name": "p_env_decay", "hint_string": "0,1,0.000000001", "default": 0.0},
# Frequency
"frequency/start_frequency": {"name": "p_base_freq", "hint_string": "0,1,0.000000001", "default": 0.35173364},
"frequency/min_freq_cutoff": {"name": "p_freq_limit", "hint_string": "0,1,0.000000001", "default": 0.0},
"frequency/slide": {"name": "p_freq_ramp", "hint_string": "-1,1,0.000000001", "default": 0.0},
"frequency/delta_slide": {"name": "p_freq_dramp", "hint_string": "-1,1,0.000000001", "default": 0.0},
# Vibrato
"vibrato/depth": {"name": "p_vib_strength", "hint_string": "0,1,0.000000001", "default": 0.0},
"vibrato/speed": {"name": "p_vib_speed", "hint_string": "0,1,0.000000001", "default": 0.0},
# Arpeggiation
"arpeggiation/frequency_mult": {"name": "p_arp_mod", "hint_string": "-1,1,0.000000001", "default": 0.0},
"arpeggiation/change_speed": {"name": "p_arp_speed", "hint_string": "0,1,0.000000001", "default": 0.0},
# Duty cycle
"duty_cycle/duty_cycle": {"name": "p_duty", "hint_string": "0,1,0.000000001", "default": 0.0},
"duty_cycle/sweep": {"name": "p_duty_ramp", "hint_string": "-1,1,0.000000001", "default": 0.0},
# Retrigger
"retrigger/rate": {"name": "p_repeat_speed", "hint_string": "0,1,0.000000001", "default": 0.0},
# Flanger
"flanger/offset": {"name": "p_pha_offset", "hint_string": "-1,1,0.000000001", "default": 0.0},
"flanger/sweep": {"name": "p_pha_ramp", "hint_string": "-1,1,0.000000001", "default": 0.0},
# Low-pass filter
"low_pass_filter/cutoff_frequency": {"name": "p_lpf_freq", "hint_string": "0,1,0.000000001", "default": 1.0},
"low_pass_filter/cutoff_sweep": {"name": "p_lpf_ramp", "hint_string": "-1,1,0.000000001", "default": 0.0},
"low_pass_filter/resonance": {"name": "p_lpf_resonance", "hint_string": "0,1,0.000000001", "default": 0.0},
# High-pass filter
"high_pass_filter/cutoff_frequency": {"name": "p_hpf_freq", "hint_string": "0,1,0.000000001", "default": 0.0},
"high_pass_filter/cutoff_sweep": {"name": "p_hpf_ramp", "hint_string": "-1,1,0.000000001", "default": 0.0},
}
static func object_get_property_list() -> Array:
var presets = SfxrGlobals.PRESETS.keys()
presets.pop_front()
var props = []
props.append({
"name": "SfxrStreamPlayer",
"type": TYPE_NIL,
"usage": PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_SCRIPT_VARIABLE,
})
for preset in presets:
props.append({
"name": "generators/" + str(preset).to_lower(),
"type": TYPE_BOOL,
"usage": PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE,
})
props.append({
"name": "wave/type",
"type": TYPE_INT,
"hint": PROPERTY_HINT_ENUM,
"hint_string": ",".join(PackedStringArray(SfxrGlobals.WAVE_SHAPES.keys())),
})
for property in PROPERTY_MAP:
props.append({
"name": property,
"type": TYPE_FLOAT,
"hint": PROPERTY_HINT_RANGE,
"hint_string": PROPERTY_MAP[property]["hint_string"],
})
props.append_array([
{
"name": "actions/force_rebuild",
"type": TYPE_BOOL,
"usage": PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE,
},
])
return props
static func object_get(object: Node, property: String):
if property in PROPERTY_MAP:
return object[PROPERTY_MAP[property]["name"]]
elif property == "wave/type":
return object.wave_type
static func object_set(object: Node, property: String, value) -> bool:
var auto_build = Engine.is_editor_hint() and object.is_inside_tree()
if property in PROPERTY_MAP:
object[PROPERTY_MAP[property]["name"]] = value
if auto_build:
_schedule_build_sfx(object, true)
return true
elif property == "wave/type":
object.wave_type = value
if auto_build:
_schedule_build_sfx(object, true)
return true
elif property == "actions/force_rebuild":
if value and auto_build:
build_sfx(object, true)
return true
elif property == "sfxr_generator":
if not value:
value = 0
if preset_values(object, value) and auto_build:
build_sfx(object, true)
return true
elif property.begins_with("generators/"):
property = property.replace("generators/", "").to_upper()
if preset_values(object, SfxrGlobals.PRESETS.get(property, -1)) and auto_build:
build_sfx(object, true)
return true
return false
##################################
# Defaults
##################################
static func object_set_defaults(object: Node):
object.wave_type = SfxrGlobals.WAVE_SHAPES.SAWTOOTH
for property in PROPERTY_MAP:
object[PROPERTY_MAP[property]["name"]] = PROPERTY_MAP[property]["default"]
static func object_property_can_revert(property: String):
return property in PROPERTY_MAP
static func object_property_get_revert(property: String):
return PROPERTY_MAP[property]["default"]
##################################
# Helpers
##################################
static func frnd(rrange) -> float:
return randf() * rrange
static func rndr(from, to) -> float:
return randf() * (to - from) + from
static func rnd(rmax) -> float:
return floor(randf() * (rmax + 1))
##################################
# Presets
##################################
static func _presets_pickup(object: Node):
object_set_defaults(object)
object.wave_type = SfxrGlobals.WAVE_SHAPES.SAWTOOTH
object.p_base_freq = 0.4 + frnd(0.5)
object.p_env_attack = 0
object.p_env_sustain = frnd(0.1)
object.p_env_decay = 0.1 + frnd(0.4)
object.p_env_punch = 0.3 + frnd(0.3)
if rnd(1):
object.p_arp_speed = 0.5 + frnd(0.2)
object.p_arp_mod = 0.2 + frnd(0.4)
static func _presets_laser(object: Node):
object_set_defaults(object)
object.wave_type = rnd(2)
if object.wave_type == SfxrGlobals.WAVE_SHAPES.SINE and rnd(1):
object.wave_type = rnd(1)
if rnd(2) == 0:
object.p_base_freq = 0.3 + frnd(0.6)
object.p_freq_limit = frnd(0.1)
object.p_freq_ramp = -0.35 - frnd(0.3)
else:
object.p_base_freq = 0.5 + frnd(0.5)
object.p_freq_limit = object.p_base_freq - 0.2 - frnd(0.6)
if object.p_freq_limit < 0.2:
object.p_freq_limit = 0.2
object.p_freq_ramp = -0.15 - frnd(0.2)
if object.wave_type == SfxrGlobals.WAVE_SHAPES.SAWTOOTH:
object.p_duty = 1
if rnd(1):
object.p_duty = frnd(0.5)
object.p_duty_ramp = frnd(0.2)
else:
object.p_duty = 0.4 + frnd(0.5)
object.p_duty_ramp = -frnd(0.7)
object.p_env_attack = 0
object.p_env_sustain = 0.1 + frnd(0.2)
object.p_env_decay = frnd(0.4)
if rnd(1):
object.p_env_punch = frnd(0.3)
if rnd(2) == 0:
object.p_pha_offset = frnd(0.2)
object.p_pha_ramp = -frnd(0.2)
object.p_hpf_freq = frnd(0.3)
static func _presets_explosion(object: Node):
object_set_defaults(object)
object.wave_type = SfxrGlobals.WAVE_SHAPES.NOISE
if rnd(1):
object.p_base_freq = pow(0.1 + frnd(0.4), 2)
object.p_freq_ramp = -0.1 + frnd(0.4)
else:
object.p_base_freq = pow(0.2 + frnd(0.7), 2)
object.p_freq_ramp = -0.2 - frnd(0.2)
if rnd(4) == 0:
object.p_freq_ramp = 0
if rnd(2) == 0:
object.p_repeat_speed = 0.3 + frnd(0.5)
object.p_env_attack = 0
object.p_env_sustain = 0.1 + frnd(0.3)
object.p_env_decay = frnd(0.5)
if rnd(1):
object.p_pha_offset = -0.3 + frnd(0.9)
object.p_pha_ramp = -frnd(0.3)
object.p_env_punch = 0.2 + frnd(0.6)
if rnd(1):
object.p_vib_strength = frnd(0.7)
object.p_vib_speed = frnd(0.6)
if rnd(2) == 0:
object.p_arp_speed = 0.6 + frnd(0.3)
object.p_arp_mod = 0.8 - frnd(1.6)
static func _presets_powerup(object: Node):
object_set_defaults(object)
if rnd(1):
object.wave_type = SfxrGlobals.WAVE_SHAPES.SAWTOOTH
object.p_duty = 1
else:
object.p_duty = frnd(0.6)
object.p_base_freq = 0.2 + frnd(0.3)
if rnd(1):
object.p_freq_ramp = 0.1 + frnd(0.4)
object.p_repeat_speed = 0.4 + frnd(0.4)
else:
object.p_freq_ramp = 0.05 + frnd(0.2)
if rnd(1):
object.p_vib_strength = frnd(0.7)
object.p_vib_speed = frnd(0.6)
object.p_env_attack = 0
object.p_env_sustain = frnd(0.4)
object.p_env_decay = 0.1 + frnd(0.4)
static func _presets_hit(object: Node):
object_set_defaults(object)
object.wave_type = rnd(2)
if object.wave_type == SfxrGlobals.WAVE_SHAPES.SINE:
object.wave_type = SfxrGlobals.WAVE_SHAPES.NOISE
if object.wave_type == SfxrGlobals.WAVE_SHAPES.SQUARE:
object.p_duty = frnd(0.6)
if object.wave_type == SfxrGlobals.WAVE_SHAPES.SAWTOOTH:
object.p_duty = 1
object.p_base_freq = 0.2 + frnd(0.6)
object.p_freq_ramp = -0.3 - frnd(0.4)
object.p_env_attack = 0
object.p_env_sustain = frnd(0.1)
object.p_env_decay = 0.1 + frnd(0.2)
if rnd(1):
object.p_hpf_freq = frnd(0.3)
static func _presets_jump(object: Node):
object_set_defaults(object)
object.wave_type = SfxrGlobals.WAVE_SHAPES.SQUARE
object.p_duty = frnd(0.6)
object.p_base_freq = 0.3 + frnd(0.3)
object.p_freq_ramp = 0.1 + frnd(0.2)
object.p_env_attack = 0
object.p_env_sustain = 0.1 + frnd(0.3)
object.p_env_decay = 0.1 + frnd(0.2)
if rnd(1):
object.p_hpf_freq = frnd(0.3)
if rnd(1):
object.p_lpf_freq = 1 - frnd(0.6)
static func _presets_blip(object: Node):
object_set_defaults(object)
object.wave_type = rnd(1)
if object.wave_type == SfxrGlobals.WAVE_SHAPES.SQUARE:
object.p_duty = frnd(0.6)
else:
object.p_duty = 1
object.p_base_freq = 0.2 + frnd(0.4)
object.p_env_attack = 0
object.p_env_sustain = 0.1 + frnd(0.1)
object.p_env_decay = frnd(0.2)
object.p_hpf_freq = 0.1
static func _presets_synth(object: Node):
object_set_defaults(object)
object.wave_type = rnd(1)
object.p_base_freq = [0.2723171360931539, 0.19255692561524382, 0.13615778746815113][rnd(2)]
object.p_env_attack = frnd(0.5) if rnd(4) > 3 else 0
object.p_env_sustain = frnd(1)
object.p_env_punch = frnd(1)
object.p_env_decay = frnd(0.9) + 0.1
object.p_arp_mod = [0, 0, 0, 0, -0.3162, 0.7454, 0.7454][rnd(6)]
object.p_arp_speed = frnd(0.5) + 0.4
object.p_duty = frnd(1)
object.p_duty_ramp = frnd(1) if rnd(2) == 2 else 0
object.p_lpf_freq = [1, frnd(1) * frnd(1)][rnd(1)]
object.p_lpf_ramp = rndr(-1, 1)
object.p_lpf_resonance = frnd(1)
object.p_hpf_freq = frnd(1) if rnd(3) == 3 else 0
object.p_hpf_ramp = frnd(1) if rnd(3) == 3 else 0
static func _presets_tone(object: Node):
object_set_defaults(object)
static func _presets_click(object: Node):
if rnd(1):
_presets_hit(object)
else:
_presets_explosion(object)
if rnd(1):
object.p_freq_ramp = -0.5 + frnd(1.0)
if rnd(1):
object.p_env_sustain = (frnd(0.4) + 0.2) * object.p_env_sustain
object.p_env_decay = (frnd(0.4) + 0.2) * object.p_env_decay
if rnd(3) == 0:
object.p_env_attack = frnd(0.3)
object.p_base_freq = 1 - frnd(0.25)
object.p_hpf_freq = 1 - frnd(0.1)
static func _presets_random(object: Node):
object_set_defaults(object)
object.wave_type = rnd(3)
if rnd(1):
object.p_base_freq = pow(frnd(2) - 1, 3) + 0.5
else:
object.p_base_freq = pow(frnd(1), 2)
object.p_freq_limit = 0
object.p_freq_ramp = pow(frnd(2) - 1, 5)
if object.p_base_freq > 0.7 and object.p_freq_ramp > 0.2:
object.p_freq_ramp = -object.p_freq_ramp
if object.p_base_freq < 0.2 and object.p_freq_ramp < -0.05:
object.p_freq_ramp = -object.p_freq_ramp
object.p_freq_dramp = pow(frnd(2) - 1, 3)
object.p_duty = frnd(2) - 1
object.p_duty_ramp = pow(frnd(2) - 1, 3)
object.p_vib_strength = pow(frnd(2) - 1, 3)
object.p_vib_speed = rndr(-1, 1)
object.p_env_attack = pow(rndr(-1, 1), 3)
object.p_env_sustain = pow(rndr(-1, 1), 2)
object.p_env_decay = rndr(-1, 1)
object.p_env_punch = pow(frnd(0.8), 2)
if object.p_env_attack + object.p_env_sustain + object.p_env_decay < 0.2:
object.p_env_sustain += 0.2 + frnd(0.3)
object.p_env_decay += 0.2 + frnd(0.3)
object.p_lpf_resonance = rndr(-1, 1)
object.p_lpf_freq = 1 - pow(frnd(1), 3)
object.p_lpf_ramp = pow(frnd(2) - 1, 3)
if object.p_lpf_freq < 0.1 and object.p_lpf_ramp < -0.05:
object.p_lpf_ramp = -object.p_lpf_ramp
object.p_hpf_freq = pow(frnd(1), 5)
object.p_hpf_ramp = pow(frnd(2) - 1, 5)
object.p_pha_offset = pow(frnd(2) - 1, 3)
object.p_pha_ramp = pow(frnd(2) - 1, 3)
object.p_repeat_speed = frnd(2) - 1
object.p_arp_speed = frnd(2) - 1
object.p_arp_mod = frnd(2) - 1
static func _presets_mutate(object: Node):
if rnd(1): object.p_base_freq += frnd(0.1) - 0.05
if rnd(1): object.p_freq_ramp += frnd(0.1) - 0.05
if rnd(1): object.p_freq_dramp += frnd(0.1) - 0.05
if rnd(1): object.p_duty += frnd(0.1) - 0.05
if rnd(1): object.p_duty_ramp += frnd(0.1) - 0.05
if rnd(1): object.p_vib_strength += frnd(0.1) - 0.05
if rnd(1): object.p_vib_speed += frnd(0.1) - 0.05
if rnd(1): object.p_env_attack += frnd(0.1) - 0.05
if rnd(1): object.p_env_sustain += frnd(0.1) - 0.05
if rnd(1): object.p_env_decay += frnd(0.1) - 0.05
if rnd(1): object.p_env_punch += frnd(0.1) - 0.05
if rnd(1): object.p_lpf_resonance += frnd(0.1) - 0.05
if rnd(1): object.p_lpf_freq += frnd(0.1) - 0.05
if rnd(1): object.p_lpf_ramp += frnd(0.1) - 0.05
if rnd(1): object.p_hpf_freq += frnd(0.1) - 0.05
if rnd(1): object.p_hpf_ramp += frnd(0.1) - 0.05
if rnd(1): object.p_pha_offset += frnd(0.1) - 0.05
if rnd(1): object.p_pha_ramp += frnd(0.1) - 0.05
if rnd(1): object.p_repeat_speed += frnd(0.1) - 0.05
if rnd(1): object.p_arp_speed += frnd(0.1) - 0.05
if rnd(1): object.p_arp_mod += frnd(0.1) - 0.05
static func random_preset(object: Node) -> bool:
return preset_values(object, (randi() % (len(SfxrGlobals.PRESETS) - 1)) + 1)
static func preset_values(object: Node, preset_key: int) -> bool:
if preset_key >= 0 and preset_key < len(SfxrGlobals.PRESETS):
var preset = SfxrGlobals.PRESETS.keys()[preset_key].to_lower()
match preset:
"pickup":
_presets_pickup(object)
return true
"laser":
_presets_laser(object)
return true
"explosion":
_presets_explosion(object)
return true
"powerup":
_presets_powerup(object)
return true
"hit":
_presets_hit(object)
return true
"jump":
_presets_jump(object)
return true
"click":
_presets_click(object)
return true
"blip":
_presets_blip(object)
return true
"synth":
_presets_synth(object)
return true
"random":
_presets_random(object)
return true
"tone":
_presets_tone(object)
return true
"mutate":
_presets_mutate(object)
return true
return false
##################################
# Playback
##################################
static func _schedule_build_sfx(object: Node, play_after_build: bool):
var timer: SceneTreeTimer = object.get_tree().create_timer(.5)
object.sfx_timer = timer
timer.timeout.connect(func(): object._on_sfx_timer_timeout(timer, play_after_build))
static func _on_sfx_timer_timeout(object: Node, timer: SceneTreeTimer, play_after_build: bool):
if timer == object.sfx_timer:
build_sfx(object, play_after_build)
static func build_sfx(object: Node, play_after_build: bool = false):
var sfxg = SfxrGenerator.new()
sfxg.build_sample(object)
if play_after_build:
object.play()
object.notify_property_list_changed()

View File

@@ -1,7 +0,0 @@
[plugin]
name="GodotSfxr"
description="Sfx Generator. Port of jsfxr (https://sfxr.me - by Eric Fredricksen) which is a port of sfxr (https://www.drpetter.se/project_sfxr.html - by DrPetter)."
author="Tomeyro"
version="1.0"
script="GodotSfxr.gd"

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
addons/tbloader/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://dqv5atotjgx01" uid="uid://cbbpw5sol06i6"
path="res://.godot/imported/untitled_DefaultMaterial_Normal.png-1d66825270be8b0e737ff63c686f533c.ctex" path="res://.godot/imported/icon.png-7c6403be1be0a98a34b14bf837b41c44.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://assets/Weapons/Bullet/untitled_DefaultMaterial_Normal.png" source_file="res://addons/tbloader/icon.png"
dest_files=["res://.godot/imported/untitled_DefaultMaterial_Normal.png-1d66825270be8b0e737ff63c686f533c.ctex"] dest_files=["res://.godot/imported/icon.png-7c6403be1be0a98a34b14bf837b41c44.ctex"]
[params] [params]

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>TBLoader</title>
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:title>TBLoader</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g transform="matrix(.23996 0 0 .24633 -15.301 -26.547)" fill="none">
<path d="m97.213 109.57-30.357 8.4385-5.37e-4 -5.6e-4 8.3597 29.977 21.989 21.198v8.6e-4l9.36e-4 -5.5e-4 5.35e-4 5.5e-4v-8.6e-4l21.99-21.198 8.356-29.965 0.0192-0.0115zm0 25.412 0.0083 0.5401-0.01402 9e-3zm-0.0083 0.54822 0.0022 8.5e-4 -9.37e-4 0.94463z" stop-color="#000000" style="-inkscape-stroke:none;font-variation-settings:normal"/>
<path transform="translate(-6.7616,1.2332)" d="m103.97 109.62-29.045 8.0742 29.039 16.766 6e-3 -0.52539 8e-3 0.52539 29.039-16.766z" stop-color="#000000" stroke="#fb8080" stroke-miterlimit="3" stroke-width="3.3" style="-inkscape-stroke:none;font-variation-settings:normal;paint-order:normal"/>
<path d="m68.168 118.93 29.038 16.766 0.01581 32.214-21.055-20.297zm58.077 0-29.038 16.766-0.01581 32.214 21.055-20.297z" stop-color="#000000" stroke="#fb8080" stroke-miterlimit="3" stroke-width="3.3" style="-inkscape-stroke:none;font-variation-settings:normal;paint-order:normal"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b6bigon1m2gl"
path="res://.godot/imported/tbloader.svg-ac537690612434f49f9a80d3b536a819.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/tbloader/icons/tbloader.svg"
dest_files=["res://.godot/imported/tbloader.svg-ac537690612434f49f9a80d3b536a819.ctex"]
[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
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/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,7 @@
[plugin]
name="TBLoader"
description="TrenchBroom map loader."
author="Codecat"
version="0.9.0"
script="src/plugin.gd"

View File

@@ -0,0 +1,64 @@
@tool
extends EditorPlugin
class_name TBPlugin
var map_control: Control = null
var editing_loader: WeakRef = weakref(null)
func _enter_tree():
set_icons(true)
map_control = create_map_control()
map_control.set_visible(false)
add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU, map_control)
func _exit_tree():
set_icons(false)
remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU, map_control)
map_control.queue_free()
map_control = null
func _handles(object):
return object is TBLoader
func _make_visible(visible: bool):
map_control.set_visible(visible)
func _edit(object):
editing_loader = weakref(object)
func create_map_control() -> Control:
var button_build_meshes = Button.new()
button_build_meshes.flat = true
button_build_meshes.text = "Build Meshes"
button_build_meshes.connect("pressed", Callable(self, "build_meshes"))
var button_build_csg = Button.new()
button_build_csg.flat = true
button_build_csg.text = "Build Combined CSG"
button_build_csg.connect("pressed", Callable(self, "build_combined_csg"))
var ret = HBoxContainer.new()
ret.add_child(button_build_meshes)
ret.add_child(button_build_csg)
return ret
func build_meshes():
var loader = editing_loader.get_ref()
loader.build_meshes()
func build_combined_csg():
var loader = editing_loader.get_ref()
loader.build_combined_csg()
func set_icons(on):
var editor_interface = get_editor_interface()
var base_control = editor_interface.get_base_control()
var theme = base_control.theme
if on:
var texture = ResourceLoader.load("res://addons/tbloader/icons/tbloader.svg")
theme.set_icon("TBLoader", "EditorIcons", texture)
else:
theme.clear_icon("TBLoader", "EditorIcons")

View File

@@ -0,0 +1,7 @@
[configuration]
entry_symbol = "tbloader_init"
[libraries]
windows.64 = "bin/tbloader.windows.x86_64.dll"
linux.64 = "bin/libtbloader.linux.x86_64.so"
macos.64 = "bin/libtbloader.macos.universal.dylib"

View File

@@ -1,173 +0,0 @@
{
"asset": {
"generator": "FBX2glTF",
"version": "2.0"
},
"scene": 0,
"buffers": [
{
"byteLength": 6920,
"uri": "buffer.bin"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 1128,
"byteOffset": 0,
"target": 34963
},
{
"buffer": 0,
"byteLength": 2172,
"byteOffset": 1128,
"target": 34962
},
{
"buffer": 0,
"byteLength": 2172,
"byteOffset": 3300,
"target": 34962
},
{
"buffer": 0,
"byteLength": 1448,
"byteOffset": 5472,
"target": 34962
}
],
"scenes": [
{
"name": "Root Scene",
"nodes": [
0
]
}
],
"accessors": [
{
"componentType": 5123,
"type": "SCALAR",
"count": 564,
"bufferView": 0,
"byteOffset": 0
},
{
"componentType": 5126,
"type": "VEC3",
"count": 181,
"bufferView": 1,
"byteOffset": 0,
"min": [
-0.0108033427968621,
-0.0108033427968621,
-0.00999999977648258
],
"max": [
0.0108033427968621,
0.0108033427968621,
0.0483268722891808
]
},
{
"componentType": 5126,
"type": "VEC3",
"count": 181,
"bufferView": 2,
"byteOffset": 0
},
{
"componentType": 5126,
"type": "VEC2",
"count": 181,
"bufferView": 3,
"byteOffset": 0
}
],
"samplers": [
{}
],
"materials": [
{
"name": "DefaultMaterial",
"alphaMode": "OPAQUE",
"extras": {
"fromFBX": {
"shadingModel": "Lambert",
"isTruePBR": false
}
},
"pbrMetallicRoughness": {
"baseColorFactor": [
0.5,
0.5,
0.5,
1.0
],
"metallicFactor": 0.200000002980232,
"roughnessFactor": 0.800000011920929
}
}
],
"meshes": [
{
"name": "Cylinder",
"primitives": [
{
"material": 0,
"mode": 4,
"attributes": {
"NORMAL": 2,
"POSITION": 1,
"TEXCOORD_0": 3
},
"indices": 0
}
]
}
],
"nodes": [
{
"name": "RootNode",
"translation": [
0.0,
0.0,
0.0
],
"rotation": [
0.0,
0.0,
0.0,
1.0
],
"scale": [
1.0,
1.0,
1.0
],
"children": [
1
]
},
{
"name": "Cylinder",
"translation": [
0.0,
0.0,
0.0
],
"rotation": [
-0.707106828689575,
0.0,
0.0,
0.707106709480286
],
"scale": [
100.0,
100.0,
100.0
],
"mesh": 0
}
]
}

View File

@@ -1,30 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://b214bo6dwp0rh"
path="res://.godot/imported/Bullet.gltf-2a14837db27fd94e8b92de2a56a298d3.scn"
[deps]
source_file="res://assets/Weapons/Bullet/Bullet.gltf"
dest_files=["res://.godot/imported/Bullet.gltf-2a14837db27fd94e8b92de2a56a298d3.scn"]
[params]
nodes/root_type="Node3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
import_script/path=""
_subresources={}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -1,9 +0,0 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://cui8yu4njh1td"]
[ext_resource type="Texture2D" uid="uid://670hioiwiwy0" path="res://assets/Weapons/Gun/untitled.png" id="1_2k5kb"]
[ext_resource type="Texture2D" uid="uid://bsfkj480gegj3" path="res://assets/Weapons/Gun/Revolver_Material_Metallic.png" id="2_3065p"]
[resource]
albedo_texture = ExtResource("1_2k5kb")
metallic = 1.0
metallic_texture = ExtResource("2_3065p")

View File

@@ -1,173 +0,0 @@
{
"asset": {
"generator": "FBX2glTF",
"version": "2.0"
},
"scene": 0,
"buffers": [
{
"byteLength": 66576,
"uri": "buffer.bin"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 7824,
"byteOffset": 0,
"target": 34963
},
{
"buffer": 0,
"byteLength": 22032,
"byteOffset": 7824,
"target": 34962
},
{
"buffer": 0,
"byteLength": 22032,
"byteOffset": 29856,
"target": 34962
},
{
"buffer": 0,
"byteLength": 14688,
"byteOffset": 51888,
"target": 34962
}
],
"scenes": [
{
"name": "Root Scene",
"nodes": [
0
]
}
],
"accessors": [
{
"componentType": 5123,
"type": "SCALAR",
"count": 3912,
"bufferView": 0,
"byteOffset": 0
},
{
"componentType": 5126,
"type": "VEC3",
"count": 1836,
"bufferView": 1,
"byteOffset": 0,
"min": [
-0.015752213075757,
-0.00636364426463842,
-0.056483943015337
],
"max": [
0.015752213075757,
0.131857424974442,
0.00461326725780964
]
},
{
"componentType": 5126,
"type": "VEC3",
"count": 1836,
"bufferView": 2,
"byteOffset": 0
},
{
"componentType": 5126,
"type": "VEC2",
"count": 1836,
"bufferView": 3,
"byteOffset": 0
}
],
"samplers": [
{}
],
"materials": [
{
"name": "Material",
"alphaMode": "OPAQUE",
"extras": {
"fromFBX": {
"shadingModel": "Phong",
"isTruePBR": false
}
},
"pbrMetallicRoughness": {
"baseColorFactor": [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1.0
],
"metallicFactor": 0.400000005960464,
"roughnessFactor": 0.229415729641914
}
}
],
"meshes": [
{
"name": "Cube.011",
"primitives": [
{
"material": 0,
"mode": 4,
"attributes": {
"NORMAL": 2,
"POSITION": 1,
"TEXCOORD_0": 3
},
"indices": 0
}
]
}
],
"nodes": [
{
"name": "RootNode",
"translation": [
0.0,
0.0,
0.0
],
"rotation": [
0.0,
0.0,
0.0,
1.0
],
"scale": [
1.0,
1.0,
1.0
],
"children": [
1
]
},
{
"name": "Cube.011",
"translation": [
-1.86264514923096e-09,
1.2553083896637,
3.58785033226013
],
"rotation": [
-0.707106828689575,
0.0,
0.0,
0.707106709480286
],
"scale": [
100.0,
100.0,
100.0
],
"mesh": 0
}
]
}

View File

@@ -1,37 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://beiad4ywiojba"
path="res://.godot/imported/Revolver.gltf-1c0c2c3864f727f53cf3435925795736.scn"
[deps]
source_file="res://assets/Weapons/Gun/Revolver.gltf"
dest_files=["res://.godot/imported/Revolver.gltf-1c0c2c3864f727f53cf3435925795736.scn"]
[params]
nodes/root_type="Node3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
import_script/path=""
_subresources={
"materials": {
"Material": {
"use_external/enabled": true,
"use_external/path": "res://assets/Weapons/Gun/Gun.tres"
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,55 @@
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
uniform float viewmodel_fov = 50.0f;
uniform vec4 albedo = vec4(1.0);
uniform sampler2D texture_albedo;
uniform float specular = 0.5f;
uniform float metallic = 1.0f;
uniform float roughness : hint_range(0,1) = 1.0f;
uniform float point_size : hint_range(0,128);
uniform sampler2D texture_metallic;
uniform vec4 metallic_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
uniform sampler2D texture_roughness;
uniform vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
//uniform sampler2D texture_emission : hint_black_albedo;
//uniform vec4 emission : hint_color;
//uniform float emission_energy;
uniform sampler2D texture_normal : hint_normal;
uniform float normal_scale : hint_range(-16,16) = 0.5f;
uniform vec3 uv1_scale = vec3(1.0f);
uniform vec3 uv1_offset = vec3(0.0f);
uniform vec3 uv2_scale = vec3(1.0f);
uniform vec3 uv2_offset = vec3(0.0f);
void vertex() {
UV = UV * uv1_scale.xy + uv1_offset.xy;
/* begin shader magic*/
float onetanfov = 1.0f / tan(0.5f * (viewmodel_fov * PI / 180.0f));
float aspect = VIEWPORT_SIZE.x / VIEWPORT_SIZE.y;
// modify projection matrix
PROJECTION_MATRIX[1][1] = onetanfov;
PROJECTION_MATRIX[0][0] = onetanfov / aspect;
// draws the viewmodel over everything (disable if you want dof near on viewmodel)
POSITION = PROJECTION_MATRIX * MODELVIEW_MATRIX * vec4(VERTEX.xyz, 1.0);
POSITION.z = mix(POSITION.z, 0, 0.999);
/* end shader magic */
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
albedo_tex *= COLOR;
ALBEDO = albedo.rgb * albedo_tex.rgb;
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
METALLIC = metallic_tex * metallic;
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
SPECULAR = specular;
NORMAL_MAP = texture(texture_normal,base_uv).rgb;
NORMAL_MAP_DEPTH = normal_scale;
//vec3 emission_tex = texture(texture_emission,base_uv).rgb;
//EMISSION = (emission.rgb+emission_tex)*emission_energy;
}

View File

@@ -0,0 +1,42 @@
shader_type canvas_item;
uniform bool center_enabled = true;
uniform bool legs_enabled = true;
uniform bool inverted = false;
uniform int color_id = 0;
uniform vec4 color_0 = vec4(0., 1, 0., 1.);
uniform vec4 color_1 = vec4(1., 0., 0., 1.);
uniform vec4 color_2 = vec4(0., 0., 1., 1.);
uniform float center_radius = .001;
uniform float width = .001;
uniform float len = .005;
uniform float spacing = .008;
uniform float spread = 1.;
void fragment(){
float a = SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y;
vec2 UVa = vec2(UV.x / a, UV.y);
vec2 center = vec2(.5 / a, .5);
float point = step(distance(UVa, center), center_radius);
float h = step(center.x - len - spacing*spread, UVa.x) - step(center.x - spacing*spread, UVa.x);
h += step(center.x + spacing*spread, UVa.x) - step(center.x + len + spacing*spread, UVa.x);
h *= step(center.y - width, UVa.y) - step(center.y + width, UVa.y);
float v = step(center.y - len - spacing*spread, UVa.y) - step(center.y - spacing*spread, UVa.y);
v += step(center.y + spacing*spread, UVa.y) - step(center.y + len + spacing*spread, UVa.y);
v *= step(center.x - width, UVa.x) - step(center.x + width, UVa.x);
float crosshair;
crosshair = (h+v) * float(legs_enabled) + point * float(center_enabled);
if(!inverted){
COLOR = (color_0 * float(color_id == 0) + color_1 * float(color_id == 1) + color_2 * float(color_id == 2)) * crosshair;
}else{
COLOR = vec4((cos(textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb * 3.1415926534) + 1.)/2., 1.) * crosshair;
}
}

View File

@@ -0,0 +1,9 @@
shader_type spatial;
render_mode cull_back;
uniform float z_offset : hint_range(-1, 1);
void fragment() {
// write the final depth value to the depth buffer
DEPTH = 0.9;
}

14
assets/shader/test.tscn Normal file
View File

@@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://tojfiub8y1f6"]
[ext_resource type="Shader" path="res://assets/shader/no_depth.gdshader" id="2_lklwv"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_5pubw"]
render_priority = 0
shader = ExtResource("2_lklwv")
shader_parameter/z_offset = null
[node name="Chainsaw_test"]
[node name="Cube014" parent="." index="0"]
material_override = SubResource("ShaderMaterial_5pubw")
transparency = 0.02

View File

@@ -1,7 +0,0 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="Sky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

100
entities/Player.tscn Normal file
View File

@@ -0,0 +1,100 @@
[gd_scene load_steps=11 format=3 uid="uid://bl7jynld7s25o"]
[ext_resource type="Script" path="res://scripts/player/PlayerQ3.gd" id="1"]
[ext_resource type="Script" path="res://scripts/player/Weapons.gd" id="2_dl1i1"]
[ext_resource type="Texture2D" uid="uid://17b1nu8spjfi" path="res://textures/icon.png" id="2_mxb5i"]
[ext_resource type="Shader" path="res://assets/shader/crosshair.gdshader" id="3_3vnqi"]
[ext_resource type="Script" path="res://entities/PlayerSync.gd" id="5_828co"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6d8kk"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ikq67"]
albedo_texture = ExtResource("2_mxb5i")
uv1_scale = Vector3(3, 2, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_4e7dm"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_08bwh"]
shader = ExtResource("3_3vnqi")
shader_parameter/center_enabled = null
shader_parameter/legs_enabled = null
shader_parameter/inverted = null
shader_parameter/color_id = null
shader_parameter/color_0 = null
shader_parameter/color_1 = null
shader_parameter/color_2 = null
shader_parameter/center_radius = null
shader_parameter/width = null
shader_parameter/len = null
shader_parameter/spacing = null
shader_parameter/spread = null
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rfdcv"]
properties/0/path = NodePath("Body/Head:rotation")
properties/0/spawn = true
properties/0/sync = true
properties/1/path = NodePath("Body:rotation")
properties/1/spawn = true
properties/1/sync = true
properties/2/path = NodePath("Networking:player_state")
properties/2/spawn = false
properties/2/sync = true
properties/3/path = NodePath("Networking:sync_position")
properties/3/spawn = true
properties/3/sync = false
properties/4/path = NodePath("Networking:sync_velocity")
properties/4/spawn = true
properties/4/sync = false
[node name="PlayerQ3" type="CharacterBody3D"]
script = ExtResource("1")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CylinderShape3D_6d8kk")
[node name="Body" type="Node3D" parent="."]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
material_override = SubResource("StandardMaterial3D_ikq67")
mesh = SubResource("CylinderMesh_4e7dm")
skeleton = NodePath("../../CollisionShape3D")
[node name="Head" type="Node3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.75, 0)
[node name="Hand" type="Node3D" parent="Body/Head"]
script = ExtResource("2_dl1i1")
[node name="Crosshair" type="ColorRect" parent="Body/Head/Hand"]
material = SubResource("ShaderMaterial_08bwh")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="Camera3D" type="Camera3D" parent="Body/Head"]
cull_mask = 1048573
current = true
[node name="AimCast" type="RayCast3D" parent="Body/Head/Camera3D"]
target_position = Vector3(0, 0, -1)
collision_mask = 512
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Label" type="Label" parent="CanvasLayer"]
offset_right = 40.0
offset_bottom = 14.0
metadata/_edit_use_anchors_ = true
[node name="Networking" type="Node" parent="."]
script = ExtResource("5_828co")
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="Networking"]
root_path = NodePath("../..")
replication_config = SubResource("SceneReplicationConfig_rfdcv")

31
entities/PlayerSync.gd Normal file
View File

@@ -0,0 +1,31 @@
extends Node
###SYNC PLAYER###
const PLAYER_STATE_SIZE = 13
var player_state:
get:
var buf = PackedByteArray()
buf.resize(PLAYER_STATE_SIZE)
buf.encode_half(0, sync_position.x)
buf.encode_half(2, sync_position.y)
buf.encode_half(4, sync_position.z)
buf.encode_half(6, sync_velocity.x)
buf.encode_half(8, sync_velocity.y)
buf.encode_half(10, sync_velocity.z)
return buf
set(value):
assert(typeof(value) == TYPE_PACKED_BYTE_ARRAY and value.size() == PLAYER_STATE_SIZE,
"Invalid `player_state` array type or size (must be TYPE_PACKED_BYTE_ARRAY of size 11).")
sync_position = Vector3(value.decode_half(0), value.decode_half(2), value.decode_half(4))
sync_velocity = Vector3(value.decode_half(6), value.decode_half(8), value.decode_half(10))
var sync_position : Vector3:
set(value):
sync_position = value
processed_position = false
var sync_velocity : Vector3
var sync_is_jumping : bool
var processed_position : bool

BIN
entities/Weapon.scn Normal file

Binary file not shown.

24
entities/enemy/dummy.tscn Normal file
View File

@@ -0,0 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://bp5ekvan8qsmc"]
[ext_resource type="Script" path="res://scripts/player/Hitable.gd" id="1_f1sho"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_uw38t"]
albedo_color = Color(0.85098, 0, 0.172549, 1)
[sub_resource type="CapsuleMesh" id="CapsuleMesh_3ufk0"]
material = SubResource("StandardMaterial3D_uw38t")
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_mfgnk"]
[node name="Enemy" type="CharacterBody3D"]
collision_layer = 512
collision_mask = 512
script = ExtResource("1_f1sho")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
mesh = SubResource("CapsuleMesh_3ufk0")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_mfgnk")

View File

@@ -9,20 +9,20 @@
config_version=5 config_version=5
_global_script_classes=[{ _global_script_classes=[{
"base": "RefCounted", "base": "Node3D",
"class": &"SfxrGenerator", "class": &"Game",
"language": &"GDScript", "language": &"GDScript",
"path": "res://addons/godot_sfxr/SfxrGenerator.gd" "path": "res://Game.gd"
}, { }, {
"base": "Object", "base": "Node",
"class": &"SfxrGlobals", "class": &"Hitable",
"language": &"GDScript", "language": &"GDScript",
"path": "res://addons/godot_sfxr/SfxrGlobals.gd" "path": "res://scripts/player/Hitable.gd"
}, { }, {
"base": "Object", "base": "EditorPlugin",
"class": &"SfxrStreamPlayerInterface", "class": &"TBPlugin",
"language": &"GDScript", "language": &"GDScript",
"path": "res://addons/godot_sfxr/SfxrStreamPlayerInterface.gd" "path": "res://addons/tbloader/src/plugin.gd"
}, { }, {
"base": "Node3D", "base": "Node3D",
"class": &"Weapon", "class": &"Weapon",
@@ -30,19 +30,24 @@ _global_script_classes=[{
"path": "res://scripts/player/Weapon.gd" "path": "res://scripts/player/Weapon.gd"
}] }]
_global_script_class_icons={ _global_script_class_icons={
"SfxrGenerator": "", "Game": "",
"SfxrGlobals": "", "Hitable": "",
"SfxrStreamPlayerInterface": "", "TBPlugin": "",
"Weapon": "" "Weapon": ""
} }
[application] [application]
config/name="Scoom" config/name="Scoom"
run/main_scene="res://Game.tscn" run/main_scene="res://scenes/map/Game.tscn"
config/features=PackedStringArray("4.0") config/features=PackedStringArray("4.0")
config/icon="res://textures/icon.png" config/icon="res://textures/icon.png"
[autoload]
Runtimeloader="*res://scripts/utils/runtimeloader.gd"
Network="*res://scripts/utils/network.gd"
[display] [display]
window/stretch/mode="2d" window/stretch/mode="2d"
@@ -53,7 +58,7 @@ window/size/test_height=720
[editor_plugins] [editor_plugins]
enabled=PackedStringArray("res://addons/godot_sfxr/plugin.cfg") enabled=PackedStringArray("res://addons/tbloader/plugin.cfg")
[input] [input]
@@ -97,6 +102,11 @@ wheel_down={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"pressed":false,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"pressed":false,"double_click":false,"script":null)
] ]
} }
reload={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"unicode":0,"echo":false,"script":null)
]
}
[physics] [physics]
@@ -104,4 +114,8 @@ common/enable_pause_aware_picking=true
[rendering] [rendering]
textures/default_filters/use_nearest_mipmap_filter=true
textures/default_filters/anisotropic_filtering_level=4
textures/canvas_textures/default_texture_filter=2
textures/canvas_textures/default_texture_repeat=1
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"

57
scenes/GUI/MAIN.tscn Normal file
View File

@@ -0,0 +1,57 @@
[gd_scene load_steps=2 format=3 uid="uid://3o430r2kys4k"]
[ext_resource type="Script" path="res://scenes/GUI/main.gd" id="1_i8nr4"]
[node name="MAIN" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_i8nr4")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -198.0
offset_top = -104.0
offset_right = 199.0
offset_bottom = 64.0
grow_horizontal = 2
grow_vertical = 2
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 2
[node name="Start" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Start Game"
[node name="ModsMenu" type="MenuButton" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "Select Mod"
flat = false
item_count = 2
popup/item_0/text = "test1"
popup/item_0/id = 0
popup/item_1/text = "test2"
popup/item_1/id = 1
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 10
[node name="SettingsButton" type="Button" parent="VBoxContainer/VBoxContainer2"]
layout_mode = 2
text = "Game Settings"
icon_alignment = 1
[node name="ExitButton" type="Button" parent="VBoxContainer/VBoxContainer2"]
layout_mode = 2
text = "Exit"
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Start" to="." method="_on_start_pressed"]

26
scenes/GUI/Main Menu.tscn Normal file
View File

@@ -0,0 +1,26 @@
[gd_scene load_steps=4 format=3 uid="uid://dsnlwjofq6psf"]
[ext_resource type="Script" path="res://scenes/GUI/MainMenu.gd" id="1_23sw7"]
[ext_resource type="PackedScene" uid="uid://3o430r2kys4k" path="res://scenes/GUI/MAIN.tscn" id="1_sojs8"]
[ext_resource type="PackedScene" uid="uid://d0kkhtesg83g" path="res://scenes/GUI/START_GAME.tscn" id="2_ipoll"]
[node name="Main Menu" type="Control"]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_23sw7")
metadata/_edit_use_anchors_ = true
[node name="MAIN" parent="." instance=ExtResource("1_sojs8")]
[node name="START GAME" parent="." instance=ExtResource("2_ipoll")]
visible = false
[connection signal="start_game" from="MAIN" to="." method="_on_main_start_game"]
[connection signal="back" from="START GAME" to="." method="_on_start_game_back"]
[connection signal="start_game" from="START GAME" to="." method="_on_start_game_start_game"]

25
scenes/GUI/MainMenu.gd Normal file
View File

@@ -0,0 +1,25 @@
extends Control
@onready var game = get_tree().get_current_scene() as Game
@onready var previous = $MAIN
@onready var current = $MAIN
func _on_main_start_game():
previous = current
current = $"START GAME"
$"START GAME".show()
func back():
current.hide()
previous.show()
var tmp = current
current = previous
previous = tmp
func _on_start_game_start_game():
game.load_map()
self.hide()
func _on_start_game_back():
previous = $MAIN
back()

View File

@@ -0,0 +1,62 @@
[gd_scene load_steps=2 format=3 uid="uid://d0kkhtesg83g"]
[ext_resource type="Script" path="res://scenes/GUI/start_game.gd" id="1_amknd"]
[node name="START GAME" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_amknd")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -198.0
offset_top = -104.0
offset_right = 199.0
offset_bottom = 64.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
metadata/_edit_use_anchors_ = true
[node name="HostContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 2
[node name="HostButton" type="Button" parent="VBoxContainer/HostContainer"]
layout_mode = 2
text = "Host"
[node name="JoinContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 2
[node name="IPAdress" type="TextEdit" parent="VBoxContainer/JoinContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 13
placeholder_text = "localhost"
[node name="JoinButton" type="Button" parent="VBoxContainer/JoinContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
text = "Join
"
[node name="BackContainer" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
[node name="BackButton" type="Button" parent="VBoxContainer/BackContainer"]
layout_mode = 2
text = "Back"
[connection signal="pressed" from="VBoxContainer/HostContainer/HostButton" to="." method="_on_host_button_pressed"]
[connection signal="pressed" from="VBoxContainer/JoinContainer/JoinButton" to="." method="_on_join_button_pressed"]
[connection signal="pressed" from="VBoxContainer/BackContainer/BackButton" to="." method="_on_back_button_pressed"]

7
scenes/GUI/main.gd Normal file
View File

@@ -0,0 +1,7 @@
extends Control
signal start_game;
func _on_start_pressed():
start_game.emit()
hide()

27
scenes/GUI/start_game.gd Normal file
View File

@@ -0,0 +1,27 @@
extends Control
@onready var IPAdress_Field = $VBoxContainer/JoinContainer/IPAdress as TextEdit
signal start_game
signal back
func _on_join_button_pressed():
if not try_connection():
return
Network.start_network(false, IPAdress_Field.text)
start_game.emit()
func try_connection():
if IPAdress_Field.text.is_empty():
return false
return true
func _on_host_button_pressed():
Network.start_network(true)
start_game.emit()
func _on_back_button_pressed():
hide()
back.emit()

View File

@@ -0,0 +1,5 @@
extends MultiplayerSpawner
func _spawn_custom(data):
return

39
scenes/map/Game.tscn Normal file
View File

@@ -0,0 +1,39 @@
[gd_scene load_steps=6 format=3 uid="uid://8g7w4uv2xsck"]
[ext_resource type="Script" path="res://Game.gd" id="1_71dcv"]
[ext_resource type="PackedScene" uid="uid://dsnlwjofq6psf" path="res://scenes/GUI/Main Menu.tscn" id="2_448f8"]
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_2n8qo"]
[sub_resource type="Sky" id="Sky_ybtis"]
sky_material = SubResource("PhysicalSkyMaterial_2n8qo")
[sub_resource type="Environment" id="Environment_oqaam"]
background_mode = 2
sky = SubResource("Sky_ybtis")
ambient_light_source = 3
reflected_light_source = 2
tonemap_mode = 2
tonemap_exposure = 2.0
ssao_enabled = true
volumetric_fog_density = 0.02
adjustment_enabled = true
adjustment_saturation = 1.27
[node name="Game" type="Node3D"]
script = ExtResource("1_71dcv")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.92272, 0.189417, -0.335722, 0.371956, -0.208918, 0.904435, 0.101177, -0.959414, -0.263228, 13.9136, 14.2605, -2.0311)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_oqaam")
[node name="Main Menu" parent="." instance=ExtResource("2_448f8")]
[node name="Networking" type="Node" parent="."]
[node name="PlayerSpawner" type="MultiplayerSpawner" parent="Networking"]
_spawnable_scenes = PackedStringArray("res://entities/Player.tscn")
spawn_path = NodePath("..")

129
scenes/map/Map_TB.tscn Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

193
scenes/map/test.map Normal file
View File

@@ -0,0 +1,193 @@
// Game: Godot
// Format: Standard
// entity 0
{
"classname" "worldspawn"
"_tb_textures" "textures"
// brush 0
{
( -800 -272 -32 ) ( -800 -264.875 -32 ) ( -800 -272 -31 ) concrete_15 0 0 0 1 1
( -816 0 -32 ) ( -816 0 -31 ) ( -808.625 0 -32 ) concrete_15 0 0 0 1 1
( -816 -272 -32 ) ( -808.625 -272 -32 ) ( -816 -264.875 -32 ) concrete_15 0 0 0 1 1
( 128 640 0 ) ( 128 647.125 0 ) ( 135.375 640 0 ) concrete_15 0 0 0 1 1
( 128 1344 0 ) ( 135.375 1344 0 ) ( 128 1344 1 ) concrete_15 0 0 0 1 1
( 0 640 0 ) ( 0 640 1 ) ( 0 647.125 0 ) concrete_15 0 0 0 1 1
}
// brush 1
{
( -800 0 80 ) ( -800 1 80 ) ( -800 0 81 ) dark 0 512 0 0.015625 0.015625
( -800 0 80 ) ( -800 0 81 ) ( -799 0 80 ) dark 0 512 0 0.015625 0.015625
( -800 0 0 ) ( -799 0 0 ) ( -800 1 0 ) dark 0 512 0 0.015625 0.015625
( -736 144 208 ) ( -736 145 208 ) ( -735 144 208 ) dark 0 512 0 0.015625 0.015625
( -736 1344 96 ) ( -735 1344 96 ) ( -736 1344 97 ) dark 0 512 0 0.015625 0.015625
( -784 144 96 ) ( -784 144 97 ) ( -784 145 96 ) dark 0 512 0 0.015625 0.015625
}
// brush 2
{
( -784 0 208 ) ( -784 1 208 ) ( -784 0 209 ) dark 0 512 180 0.015625 0.015625
( -80 0 208 ) ( -80 0 209 ) ( -79 0 208 ) dark 0 512 180 0.015625 0.015625
( -80 0 0 ) ( -79 0 0 ) ( -80 1 0 ) dark 0 512 180 0.015625 0.015625
( 0 16 208 ) ( 0 17 208 ) ( 1 16 208 ) dark 0 512 180 0.015625 0.015625
( 0 16 224 ) ( 1 16 224 ) ( 0 16 225 ) dark 0 512 180 0.015625 0.015625
( 0 16 224 ) ( 0 16 225 ) ( 0 17 224 ) dark 0 512 180 0.015625 0.015625
}
// brush 3
{
( -16 496 0 ) ( -16 497 0 ) ( -16 496 1 ) dark 0 512 180 0.015625 0.015625
( -32 16 0 ) ( -32 16 1 ) ( -31 16 0 ) dark 0 512 180 0.015625 0.015625
( -32 496 0 ) ( -31 496 0 ) ( -32 497 0 ) dark 0 512 180 0.015625 0.015625
( 0 624 208 ) ( 0 625 208 ) ( 1 624 208 ) dark 0 512 180 0.015625 0.015625
( 0 1344 16 ) ( 1 1344 16 ) ( 0 1344 17 ) dark 0 512 180 0.015625 0.015625
( 0 624 16 ) ( 0 624 17 ) ( 0 625 16 ) dark 0 512 180 0.015625 0.015625
}
// brush 4
{
( -784 1328 0 ) ( -784 1329 0 ) ( -784 1328 1 ) dark 0 512 0 0.015625 0.015625
( -576 1328 0 ) ( -576 1328 1 ) ( -575 1328 0 ) dark 0 512 0 0.015625 0.015625
( -576 1328 0 ) ( -575 1328 0 ) ( -576 1329 0 ) dark 0 512 0 0.015625 0.015625
( -16 1344 208 ) ( -16 1345 208 ) ( -15 1344 208 ) dark 0 512 0 0.015625 0.015625
( -16 1344 16 ) ( -15 1344 16 ) ( -16 1344 17 ) dark 0 512 0 0.015625 0.015625
( -16 1344 16 ) ( -16 1344 17 ) ( -16 1345 16 ) dark 0 512 0 0.015625 0.015625
}
// brush 5
{
( -784 752 0 ) ( -784 752 96 ) ( -784 432 0 ) dark 0 512 0 0.015625 0.015625
( -784 752 96 ) ( -592 752 96 ) ( -592 432 0 ) dark 0 512 0 0.015625 0.015625
( -592 432 0 ) ( -592 752 0 ) ( -784 752 0 ) dark 0 512 0 0.015625 0.015625
( -592 752 0 ) ( -592 752 96 ) ( -784 752 96 ) dark 0 512 0 0.015625 0.015625
( -592 432 0 ) ( -592 752 96 ) ( -592 752 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 6
{
( -80 256 0 ) ( -16 256 72 ) ( -16 208 72 ) dark 0 512 0 0.015625 0.015625
( -80 208 0 ) ( -16 208 72 ) ( -16 208 0 ) dark 0 512 0 0.015625 0.015625
( -16 208 0 ) ( -16 256 0 ) ( -80 256 0 ) dark 0 512 0 0.015625 0.015625
( -16 256 0 ) ( -16 256 72 ) ( -80 256 0 ) dark 0 512 0 0.015625 0.015625
( -16 208 72 ) ( -16 256 72 ) ( -16 256 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 7
{
( -80 336 0 ) ( -16 336 80 ) ( -16 288 80 ) dark 0 512 0 0.015625 0.015625
( -80 288 0 ) ( -16 288 80 ) ( -16 288 0 ) dark 0 512 0 0.015625 0.015625
( -16 288 0 ) ( -16 336 0 ) ( -80 336 0 ) dark 0 512 0 0.015625 0.015625
( -16 336 0 ) ( -16 336 80 ) ( -80 336 0 ) dark 0 512 0 0.015625 0.015625
( -16 288 80 ) ( -16 336 80 ) ( -16 336 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 8
{
( -80 416 16 ) ( -80 368 16 ) ( -80 368 0 ) dark 0 512 0 0.015625 0.015625
( -80 368 16 ) ( -16 368 16 ) ( -16 368 0 ) dark 0 512 0 0.015625 0.015625
( -16 368 0 ) ( -16 416 0 ) ( -80 416 0 ) dark 0 512 0 0.015625 0.015625
( -80 416 16 ) ( -16 416 16 ) ( -16 368 16 ) dark 0 512 0 0.015625 0.015625
( -16 416 0 ) ( -16 416 16 ) ( -80 416 16 ) dark 0 512 0 0.015625 0.015625
( -16 368 16 ) ( -16 416 16 ) ( -16 416 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 9
{
( -80 544 32 ) ( -80 496 32 ) ( -80 496 0 ) dark 0 512 0 0.015625 0.015625
( -80 496 32 ) ( -16 496 32 ) ( -16 496 0 ) dark 0 512 0 0.015625 0.015625
( -16 496 0 ) ( -16 544 0 ) ( -80 544 0 ) dark 0 512 0 0.015625 0.015625
( -80 544 32 ) ( -16 544 32 ) ( -16 496 32 ) dark 0 512 0 0.015625 0.015625
( -16 544 0 ) ( -16 544 32 ) ( -80 544 32 ) dark 0 512 0 0.015625 0.015625
( -16 496 32 ) ( -16 544 32 ) ( -16 544 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 10
{
( -80 480 24 ) ( -80 432 24 ) ( -80 432 0 ) dark 0 512 0 0.015625 0.015625
( -80 432 24 ) ( -16 432 24 ) ( -16 432 0 ) dark 0 512 0 0.015625 0.015625
( -16 432 0 ) ( -16 480 0 ) ( -80 480 0 ) dark 0 512 0 0.015625 0.015625
( -80 480 24 ) ( -16 480 24 ) ( -16 432 24 ) dark 0 512 0 0.015625 0.015625
( -16 480 0 ) ( -16 480 24 ) ( -80 480 24 ) dark 0 512 0 0.015625 0.015625
( -16 432 24 ) ( -16 480 24 ) ( -16 480 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 11
{
( -80 608 40 ) ( -80 560 40 ) ( -80 560 0 ) dark 0 512 0 0.015625 0.015625
( -80 560 40 ) ( -16 560 40 ) ( -16 560 0 ) dark 0 512 0 0.015625 0.015625
( -16 560 0 ) ( -16 608 0 ) ( -80 608 0 ) dark 0 512 0 0.015625 0.015625
( -80 608 40 ) ( -16 608 40 ) ( -16 560 40 ) dark 0 512 0 0.015625 0.015625
( -16 608 0 ) ( -16 608 40 ) ( -80 608 40 ) dark 0 512 0 0.015625 0.015625
( -16 560 40 ) ( -16 608 40 ) ( -16 608 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 12
{
( -80 176 0 ) ( -16 176 64 ) ( -16 128 64 ) dark 0 512 0 0.015625 0.015625
( -80 128 0 ) ( -16 128 64 ) ( -16 128 0 ) dark 0 512 0 0.015625 0.015625
( -16 128 0 ) ( -16 176 0 ) ( -80 176 0 ) dark 0 512 0 0.015625 0.015625
( -16 176 0 ) ( -16 176 64 ) ( -80 176 0 ) dark 0 512 0 0.015625 0.015625
( -16 128 64 ) ( -16 176 64 ) ( -16 176 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 13
{
( -80 96 56 ) ( -80 80 56 ) ( -80 80 40 ) dark 0 512 0 0.015625 0.015625
( -80 80 56 ) ( -64 80 56 ) ( -64 80 40 ) dark 0 512 0 0.015625 0.015625
( -64 80 40 ) ( -64 96 40 ) ( -80 96 40 ) dark 0 512 0 0.015625 0.015625
( -80 96 56 ) ( -64 96 56 ) ( -64 80 56 ) dark 0 512 0 0.015625 0.015625
( -64 96 40 ) ( -64 96 56 ) ( -80 96 56 ) dark 0 512 0 0.015625 0.015625
( -64 80 56 ) ( -64 96 56 ) ( -64 96 40 ) dark 0 512 0 0.015625 0.015625
}
// brush 14
{
( -80 672 48 ) ( -80 624 48 ) ( -80 624 0 ) dark 0 512 0 0.015625 0.015625
( -80 624 48 ) ( -16 624 48 ) ( -16 624 0 ) dark 0 512 0 0.015625 0.015625
( -16 624 0 ) ( -16 672 0 ) ( -80 672 0 ) dark 0 512 0 0.015625 0.015625
( -80 672 48 ) ( -16 672 48 ) ( -16 624 48 ) dark 0 512 0 0.015625 0.015625
( -16 672 0 ) ( -16 672 48 ) ( -80 672 48 ) dark 0 512 0 0.015625 0.015625
( -16 624 48 ) ( -16 672 48 ) ( -16 672 0 ) dark 0 512 0 0.015625 0.015625
}
// brush 15
{
( -467.7128129211019 637.2820323027552 64 ) ( -383.712812921102 491.7897644669695 64 ) ( -383.712812921102 491.7897644669695 0 ) shipping_container_01_side -175.73987 0 0 0.4330127 0.5
( -412.2871870788979 669.2820323027552 0 ) ( -412.2871870788979 669.2820323027552 64 ) ( -467.7128129211019 637.2820323027552 64 ) shipping_container_01_front 63.30011 1.3402672 0 0.42977914 0.49051714
( -328.2871870788979 523.7897644669695 0 ) ( -412.2871870788979 669.2820323027552 0 ) ( -467.7128129211019 637.2820323027552 0 ) shipping_container_01_side -38.589844 9.75885 30 1 1
( -467.7128129211019 637.2820323027552 64 ) ( -412.2871870788979 669.2820323027552 64 ) ( -328.2871870788979 523.7897644669695 64 ) shipping_container_01_front -75.654724 84.19873 30 0.4645997 1.319437
( -383.712812921102 491.7897644669695 64 ) ( -328.2871870788979 523.7897644669695 64 ) ( -328.2871870788979 523.7897644669695 0 ) shipping_container_01_front 1.0908203 0 0 0.426851 0.49832597
( -328.2871870788979 523.7897644669695 64 ) ( -412.2871870788979 669.2820323027552 64 ) ( -412.2871870788979 669.2820323027552 0 ) shipping_container_01_side -249.64062 0 0 0.4330127 0.5
}
// brush 16
{
( -784 1120 80 ) ( -784 1121 80 ) ( -784 1120 81 ) __TB_empty 0 0 0 1 1
( -784 1120 80 ) ( -784 1120 81 ) ( -783 1120 80 ) __TB_empty 0 0 0 1 1
( -784 1120 80 ) ( -783 1120 80 ) ( -784 1121 80 ) __TB_empty 0 0 0 1 1
( -640 1344 96 ) ( -640 1345 96 ) ( -639 1344 96 ) __TB_empty 0 0 0 1 1
( -640 1344 96 ) ( -639 1344 96 ) ( -640 1344 97 ) __TB_empty 0 0 0 1 1
( -640 1344 96 ) ( -640 1344 97 ) ( -640 1345 96 ) __TB_empty 0 0 0 1 1
}
// brush 17
{
( -784 1120 0 ) ( -784 1121 0 ) ( -784 1120 1 ) __TB_empty 0 0 0 1 1
( -784 1120 0 ) ( -784 1120 1 ) ( -783 1120 0 ) __TB_empty 0 0 0 1 1
( -784 1120 0 ) ( -783 1120 0 ) ( -784 1121 0 ) __TB_empty 0 0 0 1 1
( -640 1136 80 ) ( -640 1137 80 ) ( -639 1136 80 ) __TB_empty 0 0 0 1 1
( -640 1136 80 ) ( -639 1136 80 ) ( -640 1136 81 ) __TB_empty 0 0 0 1 1
( -640 1136 80 ) ( -640 1136 81 ) ( -640 1137 80 ) __TB_empty 0 0 0 1 1
}
// brush 18
{
( -656 1168 0 ) ( -656 1169 0 ) ( -656 1168 1 ) __TB_empty 0 0 0 1 1
( -656 1168 0 ) ( -656 1168 1 ) ( -655 1168 0 ) __TB_empty 0 0 0 1 1
( -656 1168 0 ) ( -655 1168 0 ) ( -656 1169 0 ) __TB_empty 0 0 0 1 1
( -640 1344 80 ) ( -640 1345 80 ) ( -639 1344 80 ) __TB_empty 0 0 0 1 1
( -640 1344 80 ) ( -639 1344 80 ) ( -640 1344 81 ) __TB_empty 0 0 0 1 1
( -640 1344 80 ) ( -640 1344 81 ) ( -640 1345 80 ) __TB_empty 0 0 0 1 1
}
// brush 19
{
( -736 1232 0 ) ( -736 1233 0 ) ( -736 1232 1 ) __TB_empty 0 0 0 1 1
( -736 1232 0 ) ( -736 1232 1 ) ( -735 1232 0 ) __TB_empty 0 0 0 1 1
( -736 1232 0 ) ( -735 1232 0 ) ( -736 1233 0 ) __TB_empty 0 0 0 1 1
( -704 1264 32 ) ( -704 1265 32 ) ( -703 1264 32 ) __TB_empty 0 0 0 1 1
( -704 1264 32 ) ( -703 1264 32 ) ( -704 1264 33 ) __TB_empty 0 0 0 1 1
( -704 1264 32 ) ( -704 1264 33 ) ( -704 1265 32 ) __TB_empty 0 0 0 1 1
}
}
// entity 1
{
"classname" "light"
"origin" "-724 1324 44"
}
// entity 2
{
"classname" "Player"
"origin" "-560 304 16"
}

15
scenes/map/test.mtl Normal file
View File

@@ -0,0 +1,15 @@
newmtl __TB_empty
map_Kd textures/__TB_empty.png
newmtl concrete_15
map_Kd textures/concrete_15.jpg
newmtl dark
map_Kd textures/dark.png
newmtl shipping_container_01_front
map_Kd textures/shipping_container_01_front.jpg
newmtl shipping_container_01_side
map_Kd textures/shipping_container_01_side.jpg

View File

@@ -0,0 +1,21 @@
[remap]
importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://dp182aa7i4tc2"
path="res://.godot/imported/test.obj-d0933098473ad0b52c714a3e29132649.mesh"
[deps]
files=["res://.godot/imported/test.obj-d0933098473ad0b52c714a3e29132649.mesh"]
source_file="res://scenes/map/test.obj"
dest_files=["res://.godot/imported/test.obj-d0933098473ad0b52c714a3e29132649.mesh", "res://.godot/imported/test.obj-d0933098473ad0b52c714a3e29132649.mesh"]
[params]
generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true

File diff suppressed because one or more lines are too long

View File

@@ -1,26 +0,0 @@
[gd_scene load_steps=4 format=3 uid="uid://bl7jynld7s25o"]
[ext_resource type="Script" path="res://scripts/player/PlayerQ3.gd" id="1"]
[ext_resource type="Script" path="res://scripts/player/Weapons.gd" id="2_dl1i1"]
[sub_resource type="CylinderShape3D" id="1"]
[node name="PlayerQ3" type="CharacterBody3D"]
script = ExtResource("1")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("1")
[node name="Body" type="Node3D" parent="."]
[node name="Head" type="Node3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.75, 0)
[node name="Hand" type="Node3D" parent="Body/Head"]
script = ExtResource("2_dl1i1")
sway_left = Vector3(0, 0.1, 0)
sway_right = Vector3(0, -0.1, 0)
[node name="Camera3D" type="Camera3D" parent="Body/Head"]
current = true

View File

@@ -1,11 +0,0 @@
extends Node3D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@@ -1,13 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://p3r1q0d3ibmj"]
[ext_resource type="PackedScene" uid="uid://beiad4ywiojba" path="res://assets/Weapons/Gun/Revolver.gltf" id="1_j6rkf"]
[node name="Revolver" instance=ExtResource("1_j6rkf")]
transform = Transform3D(0.05, 0, 0, 0, 0.017101, -0.0469845, 0, 0.0469845, 0.017101, 0, -0.5, -0.3)
[node name="RootNode" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.30501, 7.01204)
[node name="Cube011" parent="RootNode" index="0"]
cast_shadow = 0
gi_lightmap_scale = 2

1
scoom Submodule

Submodule scoom added at 81bf2c532a

10
scripts/player/Hitable.gd Normal file
View File

@@ -0,0 +1,10 @@
extends Node
class_name Hitable
var health = 200
func Hit(dmg):
#var tween = create_tween()
health -= dmg
if(health <= 0):
queue_free()

View File

@@ -2,6 +2,9 @@ extends CharacterBody3D
const DIST_FLOOR_SNAP := Vector3.DOWN * 0.2 const DIST_FLOOR_SNAP := Vector3.DOWN * 0.2
@onready var label : Label = $CanvasLayer/Label
@onready var networking = $Networking
@onready var body : Node3D = $Body @onready var body : Node3D = $Body
@onready var head : Node3D = $Body/Head @onready var head : Node3D = $Body/Head
@onready var cam : Camera3D = $Body/Head/Camera3D @onready var cam : Camera3D = $Body/Head/Camera3D
@@ -26,9 +29,27 @@ const DIST_FLOOR_SNAP := Vector3.DOWN * 0.2
var floor_snap := Vector3.ZERO var floor_snap := Vector3.ZERO
func _enter_tree():
$Networking/MultiplayerSynchronizer.set_multiplayer_authority(str(name).to_int())
$Body/Head/Camera3D.current = is_local_authority()
if is_local_authority():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func init():
$Body/Head/Hand.set_weapons()
func is_local_authority():
return $Networking/MultiplayerSynchronizer.get_multiplayer_authority() == multiplayer.get_unique_id()
func _process(_delta):
if not is_local_authority():
return
label.text = "H Velocity: %3.2f" % [Vector2(velocity.x, velocity.z).length()]
label.text += "\nV Velocity: %3.2f" % [velocity.y]
label.text += "\nOn floor: %s" % is_on_floor()
label.text += "\nNetwork ID: %d" % multiplayer.get_unique_id()
func get_move_direction() -> Vector3: func get_move_direction() -> Vector3:
var input_dir := Vector2( var input_dir := Vector2(
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward"), Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward"),
Input.get_action_strength("move_right") - Input.get_action_strength("move_left") Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
@@ -36,18 +57,24 @@ func get_move_direction() -> Vector3:
return input_dir.x * body.global_transform.basis.z + input_dir.y * body.global_transform.basis.x return input_dir.x * body.global_transform.basis.z + input_dir.y * body.global_transform.basis.x
func _input(event): func _input(event):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED and event is InputEventMouseMotion: if is_local_authority():
rotate_look(event.relative * 0.001 * mouse_sensitivity) if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED and event is InputEventMouseMotion:
rotate_look(event.relative * 0.001 * mouse_sensitivity)
func rotate_look(amount : Vector2) -> void: func rotate_look(amount : Vector2) -> void:
body.rotation.y -= amount.x body.rotation.y -= amount.x
head.rotation.x = clamp(head.rotation.x - amount.y, -PI * 0.5, PI * 0.5) head.rotation.x = clamp(head.rotation.x - amount.y, -PI * 0.5, PI * 0.5)
func _physics_process(delta): func _physics_process(delta):
if !is_local_authority():
if not networking.processed_position:
position = networking.sync_position
networking.processed_position = true
velocity = networking.sync_velocity
move_and_slide()
return
var was_on_floor : bool = is_on_floor() var was_on_floor : bool = is_on_floor()
var h_target_dir : Vector3 = get_move_direction() var h_target_dir : Vector3 = get_move_direction()
@@ -79,6 +106,8 @@ func _physics_process(delta):
elif was_on_floor and !is_on_floor(): elif was_on_floor and !is_on_floor():
floor_snap = Vector3.ZERO floor_snap = Vector3.ZERO
networking.sync_position = position
networking.sync_velocity = velocity
func accelerate(delta : float, p_target_dir : Vector3, p_target_speed : float, p_accel : float): func accelerate(delta : float, p_target_dir : Vector3, p_target_speed : float, p_accel : float):
var current_speed : float = velocity.dot(p_target_dir) var current_speed : float = velocity.dot(p_target_dir)
@@ -87,10 +116,9 @@ func accelerate(delta : float, p_target_dir : Vector3, p_target_speed : float, p
var accel_speed : float = min(add_speed, p_accel * delta * p_target_speed) var accel_speed : float = min(add_speed, p_accel * delta * p_target_speed)
velocity += p_target_dir * accel_speed velocity += p_target_dir * accel_speed
func apply_friction(delta : float): func apply_friction(delta : float):
var vec : Vector3 = velocity #var vec : Vector3 = velocity
var speed : float = velocity.length() var speed : float = velocity.length()
if is_zero_approx(speed): if is_zero_approx(speed):
velocity = Vector3.ZERO velocity = Vector3.ZERO

View File

@@ -8,8 +8,7 @@ const RELOAD = 3
const DRAW_TIME = 0.35 const DRAW_TIME = 0.35
#TODO: Load gun config from file var MELEE : bool
var MAX_CLIP : int var MAX_CLIP : int
var DAMAGE : float var DAMAGE : float
var MOMENTUM : Vector2 var MOMENTUM : Vector2
@@ -20,55 +19,78 @@ var DRAW_POS : Vector3
var DRAW_ROT : Vector3 var DRAW_ROT : Vector3
var MODEL : Node3D var MODEL : Node3D
var FIREMODE : int var FIREMODE : int
var HITSCAN : bool
var RAY_LEN : float = 1000
var RELOAD_TIME : float
var RELOAD_MOMENTUM : Vector3
var RELOAD_ANGULAR_MOMENTUM : Vector3
var SHOOTING_SPEED: float var SHOOTING_SPEED: float
var can_shoot : bool var can_shoot : bool
var clip = 444444 var clip : int
var state = DEFAULT var state = DEFAULT
var tween : Tween
func stop_tween():
if(tween.is_running()):
tween.stop()
func init(): func init():
visible = true state = DEFAULT
SHOOTING_SPEED = 60.0 / RPM SHOOTING_SPEED = 60.0 / RPM
var tween = create_tween() if(tween != null && tween.is_running()):
tween.stop()
MODEL.position = DRAW_POS MODEL.position = DRAW_POS
MODEL.rotation = DRAW_ROT MODEL.rotation = DRAW_ROT
tween.set_trans(Tween.TRANS_CIRC)
tween.set_ease(Tween.EASE_IN_OUT)
can_shoot = true can_shoot = true
tween.tween_callback(InitialPos).set_delay(DRAW_TIME) InitialPos(DRAW_TIME, DRAW_TIME)
func InitialPos(): func InitialPos(draw_time, ready_time):
var tween = create_tween() tween = create_tween()
tween.set_trans(Tween.TRANS_CIRC) tween.set_trans(Tween.TRANS_QUAD)
tween.set_ease(Tween.EASE_IN_OUT)
tween.set_parallel(true) tween.set_parallel(true)
tween.tween_property(MODEL, "position", Vector3.ZERO, RECOIL_COOLDOWN / 2) tween.tween_property(MODEL, "position", Vector3.ZERO, draw_time)
tween.tween_property(MODEL, "rotation", Vector3.ZERO, RECOIL_COOLDOWN / 2) tween.tween_property(MODEL, "rotation", Vector3.ZERO, draw_time)
tween.tween_callback(func(): state = INITIAL).set_delay(SHOOTING_SPEED / 2) tween.tween_callback(func(): state = INITIAL).set_delay(ready_time)
@rpc
func Shoot(): func Shoot():
if clip > 0 && state == INITIAL && can_shoot: if CanShoot():
if !FIREMODE: if not FIREMODE:
can_shoot = false can_shoot = false
clip -= 1 if not MELEE:
state = SHOOT; clip -= 1
var tween = create_tween() rpc("rpc_AnimShoot")
tween.set_trans(Tween.TRANS_ELASTIC)
tween.set_ease(Tween.EASE_OUT)
tween.set_parallel(true)
tween.tween_property(MODEL, "position", Vector3(.0, MOMENTUM.x, MOMENTUM.y), RECOIL_COOLDOWN / 2)
var rand_rot_y = randi_range(-ANGULAR_MOMENTUM.y,ANGULAR_MOMENTUM.y)
var rand_rot_z = randi_range(-ANGULAR_MOMENTUM.z,ANGULAR_MOMENTUM.z)
tween.tween_property(MODEL, "rotation", Vector3(deg_to_rad(ANGULAR_MOMENTUM.x),deg_to_rad(rand_rot_y),deg_to_rad(rand_rot_z)),RECOIL_COOLDOWN /2)
tween.tween_callback(InitialPos).set_delay(SHOOTING_SPEED / 2)
return true return true
return false return false
@rpc(call_local, any_peer)
func rpc_AnimShoot():
state = SHOOT;
tween = create_tween()
tween.set_trans(Tween.TRANS_ELASTIC)
tween.set_ease(Tween.EASE_OUT)
tween.set_parallel(true)
tween.tween_property(MODEL, "position", Vector3(.0, MOMENTUM.x, MOMENTUM.y), RECOIL_COOLDOWN / 2)
var rand_rot_y = randf_range(-ANGULAR_MOMENTUM.y,ANGULAR_MOMENTUM.y)
var rand_rot_z = randf_range(-ANGULAR_MOMENTUM.z,ANGULAR_MOMENTUM.z)
tween.tween_property(MODEL, "rotation", Vector3(deg_to_rad(ANGULAR_MOMENTUM.x),deg_to_rad(rand_rot_y),deg_to_rad(rand_rot_z)),RECOIL_COOLDOWN /2)
tween.tween_callback(func(): InitialPos(RECOIL_COOLDOWN / 2, SHOOTING_SPEED / 2)).set_delay(SHOOTING_SPEED / 2)
func CanShoot():
return clip > 0 && state == INITIAL && can_shoot
@rpc
func Release(): func Release():
rpc("rpc_Release")
@rpc(call_local, any_peer)
func rpc_Release():
if !FIREMODE: if !FIREMODE:
can_shoot = true can_shoot = true
@@ -76,6 +98,13 @@ func Release():
func Reload(): func Reload():
if(clip < MAX_CLIP && state == INITIAL): if(clip < MAX_CLIP && state == INITIAL):
state = RELOAD state = RELOAD
tween = create_tween()
tween.set_trans(Tween.TRANS_CIRC)
tween.set_ease(Tween.EASE_IN)
tween.set_parallel(true)
tween.tween_property(MODEL, "position", RELOAD_MOMENTUM, RELOAD_TIME)
tween.tween_property(MODEL, "rotation", RELOAD_ANGULAR_MOMENTUM, RELOAD_TIME)
tween.tween_callback(init).set_delay(RELOAD_TIME)
clip = MAX_CLIP
return true return true
return false return false

View File

@@ -1,101 +1,117 @@
extends Node3D extends Node3D
const CONFIG_PATH = "user://weapons.scoom" const WEAPON_SCENE = preload("res://entities/Weapon.scn")
const REVOLVER = 0
@onready var player_root = get_node("../../..")
@onready var raycast = get_node("../Camera3D/AimCast") as RayCast3D
#@onready var crosshair = $Crosshair
const REST = 0 var ALL_WEAPONS = []
const BOB = 1
var state = 0
@onready var player_root = get_node("../../../../PlayerQ3") as CharacterBody3D
var weapons = [] var weapons = []
var current_weapon = 0 var current_weapon_index = 0
var current_weapon = null
var file_data = {
REVOLVER:
{
"HAND_POS": Vector3(0.4,-0.45,-1),
"HAND_ROT": Vector3(0,PI,0),
"MODEL": "Revolver",
"MAX_CLIP": 5,
"DAMAGE": 25,
"MOMENTUM": Vector2(0.3, -0.25),
"ANGULAR_MOMENTUM": Vector3(-60, 7, 10),
"RECOIL_COOLDOWN": 0.35,
"RPM": 120,
"DRAW_POS": Vector3(0,-0.5,-0.3),
"DRAW_ROT": Vector3(1.3, 0, 0)
}
}
var mouse_mov : Vector3 var mouse_mov : Vector3
var sway_threshold = 5
var sway_lerp = 5 var sway_lerp = 5
@onready var game = get_node("/root/Game") as Game
@export var sway_left : Vector3
@export var sway_right : Vector3
@export var sway_normal : Vector3
func _ready(): func _ready():
save_data(file_data) Init_Config(game.weapon_config)
load_data() if not player_root.is_local_authority():
for w_name in game.init_config.get_value("PLAYER", "starting_weapons"):
GiveWeapon(w_name)
for i in range(0, file_data.size()): func set_weapons():
var root = Weapon.new() for w_name in game.init_config.get_value("PLAYER", "starting_weapons"):
root.name = str(i) rpc("GiveWeapon",w_name)
var resource = "res://scenes/weapons/" + file_data[i].MODEL + ".tscn"
var weapon_model_resource = load(resource) @rpc(call_local, any_peer)
var weapon_model = weapon_model_resource.instantiate() func GiveWeapon(weapon_name):
root.add_child(weapon_model) for i in ALL_WEAPONS.size():
root.position = file_data[i].HAND_POS if(ALL_WEAPONS[i].name != weapon_name):
root.rotation = file_data[i].HAND_ROT continue
root.hide() if(weapons.has(i)):
add_child(root) return
root.MAX_CLIP = file_data[i].MAX_CLIP
root.DAMAGE = file_data[i].DAMAGE weapons.append(i)
root.MOMENTUM = file_data[i].MOMENTUM if(current_weapon == null):
root.ANGULAR_MOMENTUM = file_data[i].ANGULAR_MOMENTUM rpc("ChangeWeapon", ((posmod(current_weapon_index, weapons.size()))))
root.RECOIL_COOLDOWN = file_data[i].RECOIL_COOLDOWN return
root.RPM = file_data[i].RPM
root.MODEL = root.get_node(file_data[i].MODEL) @rpc(call_local, any_peer)
root.DRAW_POS = file_data[i].DRAW_POS func TakeWeapon(weapon_name):
root.DRAW_ROT = file_data[i].DRAW_ROT for i in ALL_WEAPONS.size():
weapons.append(root) if(ALL_WEAPONS[i].name != weapon_name):
weapons[current_weapon].init() continue
weapons.erase(i)
if(current_weapon == ALL_WEAPONS[i]):
rpc("ChangeWeapon", ((posmod(current_weapon_index, weapons.size()))))
func _input(event): func _input(event):
if not player_root.is_local_authority():
return
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
mouse_mov.y = clampf(-event.relative.x, -0.1, 0.1) mouse_mov.y = clampf(-event.relative.x, -0.1, 0.1)
mouse_mov.x = clampf(event.relative.y, -0.1, 0.1) mouse_mov.x = clampf(event.relative.y, -0.1, 0.1)
if event is InputEventKey and event.is_pressed():
if event.keycode == KEY_T:
rpc("GiveWeapon","CHAINSAW")
func _unhandled_input(_event): func _unhandled_input(_event):
if weapons.size() > 1 && Input.is_action_just_released("wheel_up"): if not player_root.is_local_authority():
weapons[current_weapon].hide() return
current_weapon = (current_weapon + 1) % weapons.size()
weapons[current_weapon].init()
if weapons.size() > 1 && Input.is_action_just_released("wheel_down"):
weapons[current_weapon].hide()
current_weapon = (current_weapon - 1) % weapons.size()
weapons[current_weapon].init()
if(weapons.size() == 0):
return
if weapons.size() > 1 && Input.is_action_just_released("wheel_up"):
rpc("ChangeWeapon", (posmod((current_weapon_index + 1),weapons.size())))
if weapons.size() > 1 && Input.is_action_just_released("wheel_down"):
rpc("ChangeWeapon", (posmod((current_weapon_index - 1),weapons.size())))
if Input.is_action_just_pressed("reload"):
current_weapon.Reload()
@rpc(call_local, any_peer)
func ChangeWeapon(i):
if(current_weapon):
current_weapon.hide()
if(weapons.size() == 0):
current_weapon = null
return
current_weapon_index = i
var w_index = weapons[current_weapon_index]
current_weapon = ALL_WEAPONS[w_index]
current_weapon.show()
current_weapon.init()
raycast.target_position.z = -current_weapon.RAY_LEN
var time = 0 var time = 0
func _process(delta): func _process(delta):
if Input.is_action_pressed("shoot"): if not player_root.is_local_authority():
weapons[current_weapon].Shoot() return
if(current_weapon == null):
return
if Input.is_action_pressed("shoot") && current_weapon.Shoot():
if(current_weapon.HITSCAN):
HitScan()
else:
Projectile()
if Input.is_action_just_released("shoot"): if Input.is_action_just_released("shoot"):
weapons[current_weapon].Release() current_weapon.Release()
#SWAY #SWAY
if mouse_mov != null && mouse_mov.length() > 0: if mouse_mov != null && mouse_mov.length() > 0:
weapons[current_weapon].MODEL.rotation = weapons[current_weapon].MODEL.rotation.lerp(mouse_mov, sway_lerp * delta) current_weapon.MODEL.rotation = current_weapon.MODEL.rotation.lerp(mouse_mov, sway_lerp * delta)
mouse_mov = Vector3.ZERO mouse_mov = Vector3.ZERO
else: else:
weapons[current_weapon].MODEL.rotation = weapons[current_weapon].MODEL.rotation.lerp(Vector3.ZERO, sway_lerp * delta) current_weapon.MODEL.rotation = current_weapon.MODEL.rotation.lerp(Vector3.ZERO, sway_lerp * delta)
#BOB #BOB
if player_root.velocity.length() > 0: if player_root.velocity.length() > 0:
@@ -104,19 +120,64 @@ func _process(delta):
position.y = bobOscillate position.y = bobOscillate
bobOscillate = sin(time * 4 * (PI) + PI/4) * 0.015 bobOscillate = sin(time * 4 * (PI) + PI/4) * 0.015
position.x = bobOscillate position.x = bobOscillate
#else:
#position = lerp(position, Vector3.ZERO, ) @rpc(call_local, any_peer)
func HitScan():
if(raycast.is_colliding()):
var target = raycast.get_collider()
print_debug("Hit target ", target.name, " with ", current_weapon.name, " ",current_weapon_index, ". Dealt damage ", current_weapon.DAMAGE)
if(raycast.get_collision_mask_value(10)):
if(target is Hitable):
target.Hit(current_weapon.DAMAGE)
func Projectile():
pass
func Init_Config(config):
for weapon in config.get_sections():
var root = WEAPON_SCENE.instantiate()
root.name = weapon
func save_data(data): var model_path = config.get_value(weapon, "MODEL") as String
var file = FileAccess.open(CONFIG_PATH, FileAccess.WRITE) var weapon_model
file.store_var(data) if(model_path.ends_with(".glb") or model_path.ends_with(".gltf")):
weapon_model = Runtimeloader.load_gltf(model_path, root) as Node3D
elif(model_path.ends_with(".tscn") or model_path.ends_with(".scn")):
weapon_model = Runtimeloader.loadScene(model_path, root)
else:
printerr("Invalid file extension for "+ model_path)
continue
func load_data():
var file = FileAccess.open(CONFIG_PATH, FileAccess.READ)
var data = file.get_var()
file_data = data
root.position = config.get_value(weapon, "HAND_POS")
root.rotation = config.get_value(weapon, "HAND_ROT")
root.hide()
add_child(root)
#Set Weapon Data
root.MELEE = config.get_value(weapon, "MELEE")
root.MAX_CLIP = config.get_value(weapon, "MAX_CLIP")
root.clip = root.MAX_CLIP
root.DAMAGE = config.get_value(weapon, "DAMAGE")
root.RPM = config.get_value(weapon, "RPM")
root.FIREMODE = config.get_value(weapon, "FIREMODE")
root.HITSCAN = config.get_value(weapon, "HITSCAN")
if(not root.HITSCAN):
print("Projectile stats")
else:
root.RAY_LEN = config.get_value(weapon, "RAY_LEN")
#Set Anim Data
root.MODEL = weapon_model
root.DRAW_POS = config.get_value(weapon, "DRAW_POS")
root.DRAW_ROT = config.get_value(weapon, "DRAW_ROT")
root.MOMENTUM = config.get_value(weapon, "MOMENTUM")
root.ANGULAR_MOMENTUM = config.get_value(weapon, "ANGULAR_MOMENTUM")
root.RECOIL_COOLDOWN = config.get_value(weapon, "RECOIL_COOLDOWN")
root.RELOAD_MOMENTUM = config.get_value(weapon, "RELOAD_MOMENTUM")
root.RELOAD_ANGULAR_MOMENTUM = config.get_value(weapon, "RELOAD_ANGULAR_MOMENTUM")
root.RELOAD_TIME = config.get_value(weapon, "RELOAD_TIME")
ALL_WEAPONS.append(root)

45
scripts/utils/network.gd Normal file
View File

@@ -0,0 +1,45 @@
extends Node
signal player_spawn
# The player scene (which we want to configure for replication).
const Player = preload("res://entities/Player.tscn")
@onready var NetworkingRoot = get_node("/root/Game/Networking")
func start_network(server: bool, ip="localhost"):
var peer = ENetMultiplayerPeer.new()
if server:
peer.create_server(27015)
# Listen to peer connections, and create new player for them
multiplayer.peer_connected.connect(create_player)
# Listen to peer disconnections, and destroy their players
multiplayer.peer_disconnected.connect(destroy_player)
multiplayer.set_multiplayer_peer(peer)
create_player()
else:
peer.create_client(ip, 27015)
multiplayer.set_multiplayer_peer(peer)
func add_network_entity(path):
var spawner = NetworkingRoot.get_node("Networking") as MultiplayerSpawner
spawner.add_spawnable_scene(path)
func create_player(id=1):
# Instantiate a new player for this client.
var p = Player.instantiate()
# Sets the player name (only sent during spawn).
#p.player_name = "Player %d" % id
# Set a random position (sent on every replicator update).
#p.position = Vector2(randi() % 500, randi() % 500)
# Add it to the "Players" node.
# We give the new Node a name for easy retrieval, but that's not necessary.
p.name = str(id)
#p.set_multiplayer_authority(id)
NetworkingRoot.add_child(p)
p.init()
func destroy_player(id):
# Delete this peer's node.
NetworkingRoot.get_node(str(id)).queue_free()

View File

@@ -0,0 +1,107 @@
extends Node
var PATH = "res://scoom/"
var EXTERNAL_PATH = "res://scoom/"
const ENTITY_CONFIG = "entity.cfg"
func _ready():
if(not OS.has_feature("editor")):
EXTERNAL_PATH = OS.get_executable_path().get_base_dir() + "/scoom/"
func get_all_children(in_node, arr = []):
arr.push_back(in_node)
for child in in_node.get_children():
arr = get_all_children(child,arr)
return arr
func load_gltf(file, parent = self, hasCollision = false, trimesh = false):
if(file == null):
printerr("No model provided to load")
return
var gltf := GLTFDocument.new()
var gltf_state := GLTFState.new()
var snd_file = FileAccess.open(EXTERNAL_PATH + file, FileAccess.READ)
var fileBytes = PackedByteArray()
fileBytes = snd_file.get_buffer(snd_file.get_length())
gltf.append_from_buffer(fileBytes, "", gltf_state)
print("Loading ", EXTERNAL_PATH + file)
var node = gltf.generate_scene(gltf_state) as Node
parent.add_child(node)
get_all_entities(node)
if not hasCollision:
return node
for o in get_all_children(node):
if o is MeshInstance3D:
if(trimesh):
o.create_trimesh_collision()
else:
o.create_convex_collision()
return node
func get_all_entities(at_node):
var entity_count = 0
for o in get_all_children(at_node):
if o.name.begins_with("entity_"):
print("Loading entity ", o.name)
if loadEntity(o):
entity_count += 1;
if(entity_count > 0):
print("Loaded ", entity_count, " entities.")
func loadEntity(node):
var config = ConfigFile.new()
var err = config.load(PATH + ENTITY_CONFIG)
if err != OK:
printerr("COULD NOT LOAD ENTITY : ", node.name)
return false
if(not config.has_section(node.name)):
printerr("NO CONFIG FOUND FOR ENTITY : ", node.name)
return false
var model = config.get_value(node.name, "model")
var has_collision = config.get_value(node.name, "has_collision")
var has_trimesh_col = config.get_value(node.name, "has_trimesh_col")
var entity = load_gltf(model, node.get_parent(), has_collision, has_trimesh_col) as Node3D
if(entity == null):
printerr("ENTITY COULD NOT BE CREATED : ", node.name)
return false
entity.transform.origin = node.transform.origin
entity.scale = config.get_value(node.name, "scale")
node.queue_free()
return true
func loadPCK(file):
var success = ProjectSettings.load_resource_pack(EXTERNAL_PATH + file)
if success:
print("Resource pack loaded ", EXTERNAL_PATH + file)
func loadConfig(file):
var config = ConfigFile.new()
var err = config.load(EXTERNAL_PATH + file)
if err != OK:
printerr("FAILED LOADING CONFIG DATA @ ",EXTERNAL_PATH + file)
return config
func loadScene(file, parent = self):
var res = load(PATH + file) as PackedScene
var scene = res.instantiate()
get_all_entities(scene)
parent.add_child(scene)
return scene

BIN
textures/concrete_15.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -2,9 +2,9 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://670hioiwiwy0" uid="uid://bx4pdgghucl4k"
path.s3tc="res://.godot/imported/untitled.png-171f6a3e6ab8f7068ee4dcf93c2569b8.s3tc.ctex" path.s3tc="res://.godot/imported/concrete_15.jpg-42bf7bde5374d09a0bcdd2247a5e3ed8.s3tc.ctex"
path.etc2="res://.godot/imported/untitled.png-171f6a3e6ab8f7068ee4dcf93c2569b8.etc2.ctex" path.etc2="res://.godot/imported/concrete_15.jpg-42bf7bde5374d09a0bcdd2247a5e3ed8.etc2.ctex"
metadata={ metadata={
"imported_formats": ["s3tc", "etc2"], "imported_formats": ["s3tc", "etc2"],
"vram_texture": true "vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps] [deps]
source_file="res://assets/Weapons/Gun/untitled.png" source_file="res://textures/concrete_15.jpg"
dest_files=["res://.godot/imported/untitled.png-171f6a3e6ab8f7068ee4dcf93c2569b8.s3tc.ctex", "res://.godot/imported/untitled.png-171f6a3e6ab8f7068ee4dcf93c2569b8.etc2.ctex"] dest_files=["res://.godot/imported/concrete_15.jpg-42bf7bde5374d09a0bcdd2247a5e3ed8.s3tc.ctex", "res://.godot/imported/concrete_15.jpg-42bf7bde5374d09a0bcdd2247a5e3ed8.etc2.ctex"]
[params] [params]

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@@ -2,9 +2,9 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bsfkj480gegj3" uid="uid://dpbikwjv4uetu"
path.s3tc="res://.godot/imported/Revolver_Material_Metallic.png-09ddab5aa35e1ae97c0eefe8e355e0f2.s3tc.ctex" path.s3tc="res://.godot/imported/concrete_floor_01.jpg-d3402f38e00e3b9e2ee61f78df3279e4.s3tc.ctex"
path.etc2="res://.godot/imported/Revolver_Material_Metallic.png-09ddab5aa35e1ae97c0eefe8e355e0f2.etc2.ctex" path.etc2="res://.godot/imported/concrete_floor_01.jpg-d3402f38e00e3b9e2ee61f78df3279e4.etc2.ctex"
metadata={ metadata={
"imported_formats": ["s3tc", "etc2"], "imported_formats": ["s3tc", "etc2"],
"vram_texture": true "vram_texture": true
@@ -12,8 +12,8 @@ metadata={
[deps] [deps]
source_file="res://assets/Weapons/Gun/Revolver_Material_Metallic.png" source_file="res://textures/concrete_floor_01.jpg"
dest_files=["res://.godot/imported/Revolver_Material_Metallic.png-09ddab5aa35e1ae97c0eefe8e355e0f2.s3tc.ctex", "res://.godot/imported/Revolver_Material_Metallic.png-09ddab5aa35e1ae97c0eefe8e355e0f2.etc2.ctex"] dest_files=["res://.godot/imported/concrete_floor_01.jpg-d3402f38e00e3b9e2ee61f78df3279e4.s3tc.ctex", "res://.godot/imported/concrete_floor_01.jpg-d3402f38e00e3b9e2ee61f78df3279e4.etc2.ctex"]
[params] [params]

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c52qu6ad3taix"
path.s3tc="res://.godot/imported/shipping_container_01_front.jpg-6818bcd06a43db2b17373db471516d58.s3tc.ctex"
path.etc2="res://.godot/imported/shipping_container_01_front.jpg-6818bcd06a43db2b17373db471516d58.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}
[deps]
source_file="res://textures/shipping_container_01_front.jpg"
dest_files=["res://.godot/imported/shipping_container_01_front.jpg-6818bcd06a43db2b17373db471516d58.s3tc.ctex", "res://.godot/imported/shipping_container_01_front.jpg-6818bcd06a43db2b17373db471516d58.etc2.ctex"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bt671xkej3a2s"
path.s3tc="res://.godot/imported/shipping_container_01_side.jpg-9d52ac7e86de9e14fde2e6a8a43fe4af.s3tc.ctex"
path.etc2="res://.godot/imported/shipping_container_01_side.jpg-9d52ac7e86de9e14fde2e6a8a43fe4af.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}
[deps]
source_file="res://textures/shipping_container_01_side.jpg"
dest_files=["res://.godot/imported/shipping_container_01_side.jpg-9d52ac7e86de9e14fde2e6a8a43fe4af.s3tc.ctex", "res://.godot/imported/shipping_container_01_side.jpg-9d52ac7e86de9e14fde2e6a8a43fe4af.etc2.ctex"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0