From 2622d508d9628d8f12a509ad2c6e2943fb677221 Mon Sep 17 00:00:00 2001 From: "Gabriel T. Nardy" Date: Sun, 6 Jun 2021 06:50:42 -0300 Subject: [PATCH] Ordened List of Spawn Menu; Added Lamp tool; Added Trail tool; Added Resizer sound and reset key; Fixed some UI errors and bugs; Replaced SpawnParticle by Particle spawn directly; --- Client/SpawnMenu.lua | 17 +++++++++------ Client/Tools/Lamp.lua | 33 ++++++++++++++++++++++++++++ Client/Tools/Resizer.lua | 13 +++++++++-- Client/Tools/Thruster.lua | 3 +-- Client/Tools/Trail.lua | 27 +++++++++++++++++++++++ Client/UI/index.js | 8 ++++++- Client/UI/style.css | 1 - Server/Index.lua | 6 ++++- Server/SpawnMenu.lua | 30 ++++++++++++++----------- Server/Tools/Balloon.lua | 6 ++--- Server/Tools/Color.lua | 3 ++- Server/Tools/Lamp.lua | 46 +++++++++++++++++++++++++++++++++++++++ Server/Tools/Light.lua | 14 +++++++----- Server/Tools/Resizer.lua | 3 ++- Server/Tools/Rope.lua | 4 ++-- Server/Tools/Thruster.lua | 6 ++--- Server/Tools/Trail.lua | 38 ++++++++++++++++++++++++++++++++ Server/Tools/Weld.lua | 4 ++-- 18 files changed, 217 insertions(+), 45 deletions(-) create mode 100644 Client/Tools/Lamp.lua create mode 100644 Client/Tools/Trail.lua create mode 100644 Server/Tools/Lamp.lua create mode 100644 Server/Tools/Trail.lua diff --git a/Client/SpawnMenu.lua b/Client/SpawnMenu.lua index 5390727..a694c5f 100644 --- a/Client/SpawnMenu.lua +++ b/Client/SpawnMenu.lua @@ -37,11 +37,11 @@ main_hud:Subscribe("Ready", function() -- Loads all StaticMeshes as Props local props = Assets:GetStaticMeshes(asset_pack.Path) for i, prop in pairs(props) do - -- Adds to the list all Props, we use as pattern the images located at a Thumbnails/ folder inside the Asset Pack - SpawnMenuItems[asset_pack.Path].props[prop] = { + table.insert(SpawnMenuItems[asset_pack.Path].props, { + id = prop, name = prop, image = "assets///" .. asset_pack.Path .. "/Thumbnails/" .. prop .. ".jpg" - } + }) end main_hud:CallEvent("AddAssetPack", {asset_pack.Path, JSON.stringify(SpawnMenuItems[asset_pack.Path])}) @@ -157,10 +157,11 @@ function AddSpawnMenuItem(asset_pack, category, id, name, image) SpawnMenuItems[asset_pack][category] = {} end - SpawnMenuItems[asset_pack][category][id] = { + table.insert(SpawnMenuItems[asset_pack][category], { + id = id, name = name, image = image - } + }) end -- Exposes this to other packages @@ -169,12 +170,14 @@ Package:Export("AddSpawnMenuItem", AddSpawnMenuItem) -- Requires all Tools Package:Require("Tools/Balloon.lua") Package:Require("Tools/Color.lua") +Package:Require("Tools/Lamp.lua") Package:Require("Tools/Light.lua") Package:Require("Tools/PhysicsGun.lua") Package:Require("Tools/Remover.lua") Package:Require("Tools/Resizer.lua") Package:Require("Tools/Rope.lua") Package:Require("Tools/Thruster.lua") +Package:Require("Tools/Trail.lua") Package:Require("Tools/Weld.lua") -- Adds the default NanosWorld items @@ -183,12 +186,12 @@ AddSpawnMenuItem("NanosWorld", "weapons", "AK47", "AK47", "assets///NanosWorld/T AddSpawnMenuItem("NanosWorld", "weapons", "AK74U", "AK74U", "assets///NanosWorld/Thumbnails/SK_AK74U.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "AP5", "AP5", "assets///NanosWorld/Thumbnails/SK_AP5.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "AR4", "AR4", "assets///NanosWorld/Thumbnails/SK_AR4.jpg") +AddSpawnMenuItem("NanosWorld", "weapons", "ASVal", "ASVal", "assets///NanosWorld/Thumbnails/SK_ASVal.jpg") +AddSpawnMenuItem("NanosWorld", "weapons", "DesertEagle", "DesertEagle", "assets///NanosWorld/Thumbnails/SK_DesertEagle.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "GE36", "GE36", "assets///NanosWorld/Thumbnails/SK_GE36.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "Glock", "Glock", "assets///NanosWorld/Thumbnails/SK_Glock.jpg") -AddSpawnMenuItem("NanosWorld", "weapons", "DesertEagle", "DesertEagle", "assets///NanosWorld/Thumbnails/SK_DesertEagle.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "Moss500", "Moss500", "assets///NanosWorld/Thumbnails/SK_Moss500.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "SMG11", "SMG11", "assets///NanosWorld/Thumbnails/SK_SMG11.jpg") -AddSpawnMenuItem("NanosWorld", "weapons", "ASVal", "ASVal", "assets///NanosWorld/Thumbnails/SK_ASVal.jpg") AddSpawnMenuItem("NanosWorld", "weapons", "Grenade", "Grenade", "assets///NanosWorld/Thumbnails/SK_G67.jpg") -- Default Vehicles diff --git a/Client/Tools/Lamp.lua b/Client/Tools/Lamp.lua new file mode 100644 index 0000000..1bf15c1 --- /dev/null +++ b/Client/Tools/Lamp.lua @@ -0,0 +1,33 @@ +-- Method to handle when Player picks up the Tool +function HandleLampTool(weapon) + -- Subscribe when the player fires with this weapon + weapon:Subscribe("Fire", function(weapon, shooter) + -- Makes a trace 10000 units ahead + local trace_result = TraceFor(10000, CollisionChannel.WorldStatic | CollisionChannel.WorldDynamic | CollisionChannel.PhysicsBody | CollisionChannel.Vehicle | CollisionChannel.Pawn) + + if (trace_result.Success) then + local distance_trace_object = Vector() + if (trace_result.Entity) then + -- If hit an entity, then calculates the offset distance from the Hit and the Object + distance_trace_object = trace_result.Entity:GetLocation() - trace_result.Location + end + + -- Calls remote to spawn the Lamp + Events:CallRemote("SpawnLamp", {trace_result.Location, trace_result.Normal, trace_result.Entity, distance_trace_object}) + else + -- If didn't hit anything, plays a negative sound + Sound(Vector(), "NanosWorld::A_Invalid_Action", true, true, SoundType.SFX, 1) + end + end) +end + +Events:Subscribe("PickUpToolGun_LampTool", function(tool) + HandleLampTool(tool) +end) + +Events:Subscribe("DropToolGun_LampTool", function(tool) + tool:Unsubscribe("Fire") +end) + +-- Adds this tool to the Sandbox Spawn Menu +AddSpawnMenuItem("NanosWorld", "tools", "LampTool", "Lamps", "assets///NanosWorld/Thumbnails/SK_Blaster.jpg") \ No newline at end of file diff --git a/Client/Tools/Resizer.lua b/Client/Tools/Resizer.lua index 6d0d7b8..16a35d1 100644 --- a/Client/Tools/Resizer.lua +++ b/Client/Tools/Resizer.lua @@ -56,7 +56,7 @@ Client:Subscribe("MouseUp", function(key_name) if (key_name == "MouseScrollUp") then if (ResizerTool.resizing_object) then ResizerTool.current_scale = ResizerTool.current_scale + 0.1 - Events:CallRemote("ResizeObject", {ResizerTool.resizing_object, ResizerTool.current_scale}) + Events:CallRemote("ResizeObject", {ResizerTool.resizing_object, ResizerTool.current_scale, true}) end return end @@ -71,12 +71,21 @@ Client:Subscribe("MouseUp", function(key_name) ResizerTool.current_scale = Vector(0.1) end - Events:CallRemote("ResizeObject", {ResizerTool.resizing_object, ResizerTool.current_scale}) + Events:CallRemote("ResizeObject", {ResizerTool.resizing_object, ResizerTool.current_scale, false}) end return end end) +Client:Subscribe("KeyPress", function(key_name) + if (not ResizerTool.weapon or not ResizerTool.resizing_object) then return end + + if (key_name == "R") then + ResizerTool.current_scale = Vector(1, 1, 1) + Events:CallRemote("ResizeObject", {ResizerTool.resizing_object, Vector(1, 1, 1), true}) + end +end) + Events:Subscribe("PickUpToolGun_ResizerTool", function(tool, character) HandleResizerTool(tool, character) end) diff --git a/Client/Tools/Thruster.lua b/Client/Tools/Thruster.lua index 71b4d99..0c4557f 100644 --- a/Client/Tools/Thruster.lua +++ b/Client/Tools/Thruster.lua @@ -7,8 +7,7 @@ function HandleThrusterTool(weapon) -- If hit some object, then spawns a thruster on attached it if (trace_result.Success and trace_result.Entity) then - local distance_trace_object = trace_result.Entity:GetLocation() - trace_result.Location - Events:CallRemote("SpawnThruster", {trace_result.Location, trace_result.Normal, trace_result.Entity, distance_trace_object}) + Events:CallRemote("SpawnThruster", {trace_result.Location, trace_result.Normal, trace_result.Entity}) else -- If didn't hit anything, plays a negative sound Sound(Vector(), "NanosWorld::A_Invalid_Action", true, true, SoundType.SFX, 1) diff --git a/Client/Tools/Trail.lua b/Client/Tools/Trail.lua new file mode 100644 index 0000000..124af63 --- /dev/null +++ b/Client/Tools/Trail.lua @@ -0,0 +1,27 @@ +-- Method to handle when Player picks up the Tool +function HandleTrailTool(weapon) + -- Subscribe when the player fires with this weapon + weapon:Subscribe("Fire", function(weapon, shooter) + -- Makes a trace 10000 units ahead to spawn the balloon + local trace_result = TraceFor(10000, CollisionChannel.WorldStatic | CollisionChannel.WorldDynamic | CollisionChannel.PhysicsBody | CollisionChannel.Vehicle | CollisionChannel.Pawn) + + -- If hit some object, then spawns a trail on attached it + if (trace_result.Success and trace_result.Entity) then + Events:CallRemote("SpawnTrail", {trace_result.Location, trace_result.Normal, trace_result.Entity}) + else + -- If didn't hit anything, plays a negative sound + Sound(Vector(), "NanosWorld::A_Invalid_Action", true, true, SoundType.SFX, 1) + end + end) +end + +Events:Subscribe("PickUpToolGun_TrailTool", function(tool, character) + HandleTrailTool(tool) +end) + +Events:Subscribe("DropToolGun_TrailTool", function(tool, character) + tool:Unsubscribe("Fire") +end) + +-- Adds this tool to the Sandbox Spawn Menu +AddSpawnMenuItem("NanosWorld", "tools", "TrailTool", "Trail", "assets///NanosWorld/Thumbnails/SK_Blaster.jpg") \ No newline at end of file diff --git a/Client/UI/index.js b/Client/UI/index.js index a03ca0e..260317e 100644 --- a/Client/UI/index.js +++ b/Client/UI/index.js @@ -13,6 +13,9 @@ Events.Subscribe("ToggleVoice", function(name, enable) { document.querySelector("#voice_chats").prepend(span); } else { + if (!existing_span) + return; + existing_span.remove(); } }); @@ -90,6 +93,9 @@ Events.Subscribe("UpdatePlayer", function(id, active, name, ping) { document.querySelector("#scoreboard_tbody").prepend(scoreboard_entry_tr); } else { + if (!existing_scoreboard_entry) + return; + existing_scoreboard_entry.remove(); } }); @@ -185,7 +191,7 @@ function RefreshAssets() { for (let asset_pack in assets) { for (let asset_pack_item in assets[asset_pack][current_tab]) { let item = assets[asset_pack][current_tab][asset_pack_item]; - DisplayAsset(asset_pack, asset_pack_item, item.name, item.image); + DisplayAsset(asset_pack, item.id, item.name, item.image); } } diff --git a/Client/UI/style.css b/Client/UI/style.css index c14dbc8..7ddc805 100644 --- a/Client/UI/style.css +++ b/Client/UI/style.css @@ -8,7 +8,6 @@ body { font-size: 14px; margin: 0px; padding: 0px; - margin-bottom: 20px; color: #ffffffe6; user-select: none; } diff --git a/Server/Index.lua b/Server/Index.lua index 4ff6c87..05a513a 100644 --- a/Server/Index.lua +++ b/Server/Index.lua @@ -208,7 +208,11 @@ function SpawnPlayer(player, location, rotation) -- Sets a callback to automatically respawn the character, 10 seconds after he dies new_char:Subscribe("Death", function(chara, last_damage_taken, last_bone_damaged, damage_reason, hit_from, instigator) if (instigator) then - Server:BroadcastChatMessage("" .. instigator:GetName() .. " killed " .. player:GetName() .. "") + if (instigator == player) then + Server:BroadcastChatMessage("" .. instigator:GetName() .. " committed suicide") + else + Server:BroadcastChatMessage("" .. instigator:GetName() .. " killed " .. player:GetName() .. "") + end else Server:BroadcastChatMessage("" .. player:GetName() .. " died") end diff --git a/Server/SpawnMenu.lua b/Server/SpawnMenu.lua index 2975b26..e00c06e 100644 --- a/Server/SpawnMenu.lua +++ b/Server/SpawnMenu.lua @@ -161,21 +161,23 @@ function DestroyItem(item) -- If this item has a Particle, destroys it as well local particle = item:GetValue("Particle") - if (particle) then - particle:Destroy() - end - - -- If this item has a Cable, destroys it as well - local cable = item:GetValue("Cable") - if (cable) then - cable:Destroy() - end + if (particle) then particle:Destroy() end -- If this item has a Light, destroys it as well local light = item:GetValue("Light") - if (light) then - light:Destroy() - end + if (light) then light:Destroy() end + + -- If this item has a Light, destroys it as well + local bulb = item:GetValue("Bulb") + if (bulb) then bulb:Destroy() end + + -- If this item has a Thruster attached, destroys it as well + local thruster = item:GetValue("Thruster") + if (thruster) then thruster:Destroy() end + + -- If this item has a Trail attached, destroys it as well + local trail = item:GetValue("Trail") + if (trail) then trail:Destroy() end -- Destroys the item itself item:Destroy() @@ -185,7 +187,7 @@ end Events:Subscribe("DestroyItem", function(player, item) -- Spawns some sounds and particles Events:BroadcastRemote("SpawnSound", {item:GetLocation(), "NanosWorld::A_Player_Eject", false, 0.3, 1}) - Events:BroadcastRemote("SpawnParticle", {item:GetLocation() + Vector(0, 0, 30), Rotator(), "NanosWorld::P_OmnidirectionalBurst"}) + Particle(item:GetLocation() + Vector(0, 0, 30), Rotator(), "NanosWorld::P_OmnidirectionalBurst") DestroyItem(item) end) @@ -245,10 +247,12 @@ AddSpawnMenuItem("NanosWorld", "tools", "RemoverTool", function() return SpawnGe -- Requires all the Tools Package:Require("Tools/Balloon.lua") Package:Require("Tools/Color.lua") +Package:Require("Tools/Lamp.lua") Package:Require("Tools/Light.lua") Package:Require("Tools/PhysicsGun.lua") Package:Require("Tools/Resizer.lua") Package:Require("Tools/Rope.lua") Package:Require("Tools/Thruster.lua") Package:Require("Tools/Torch.lua") +Package:Require("Tools/Trail.lua") Package:Require("Tools/Weld.lua") \ No newline at end of file diff --git a/Server/Tools/Balloon.lua b/Server/Tools/Balloon.lua index 0291a61..bb5ee74 100644 --- a/Server/Tools/Balloon.lua +++ b/Server/Tools/Balloon.lua @@ -43,7 +43,6 @@ Events:Subscribe("SpawnBalloon", function(player, spawn_location, rotation, forc -- Sets some values to be used later on (such as Balloon color to be used on popping Particles and the Cable itself to be able to destroy it properly) balloon:SetValue("Color", color, true) - balloon:SetValue("Cable", cable) balloon:SetValue("Balloon", true) -- Attaches the Cable to the Balloon @@ -57,15 +56,14 @@ Events:Subscribe("SpawnBalloon", function(player, spawn_location, rotation, forc -- Calls the Client to spawn ballons spawning sounds Events:BroadcastRemote("SpawnSound", {spawn_location, "NanosWorld::A_Balloon_Inflate", false, 0.75, 1}) - Events:BroadcastRemote("SpawnParticle", {spawn_location, rotation, "NanosWorld::P_DirectionalBurst", color}) + Particle(spawn_location, rotation, "NanosWorld::P_DirectionalBurst"):SetParameterColor("Color", color) end) -- Helper to destroy and pop properly the balloon function DestroyBalloon(balloon) Events:BroadcastRemote("SpawnSound", {balloon:GetLocation(), "NanosWorld::A_Balloon_Pop", false, 1, 1}) - Events:BroadcastRemote("SpawnParticle", {balloon:GetLocation() + Vector(0, 0, 30), Rotator(), "NanosWorld::P_OmnidirectionalBurst", balloon:GetValue("Color")}) + Particle(balloon:GetLocation() + Vector(0, 0, 30), Rotator(), "NanosWorld::P_OmnidirectionalBurst"):SetParameterColor("Color", balloon:GetValue("Color")) - balloon:GetValue("Cable"):Destroy() balloon:Destroy() end diff --git a/Server/Tools/Color.lua b/Server/Tools/Color.lua index abb0751..e5d00c5 100644 --- a/Server/Tools/Color.lua +++ b/Server/Tools/Color.lua @@ -2,7 +2,8 @@ -- Painting can only affect meshes which materials has the Color Parameter 'Tint' Events:Subscribe("ColorObject", function(player, entity, hit_location, direction, color) entity:SetMaterialColorParameter("Tint", color) - Events:BroadcastRemote("SpawnParticle", {hit_location, direction:Rotation(), "NanosWorld::P_DirectionalBurst", color}) + + Particle(hit_location, direction:Rotation(), "NanosWorld::P_DirectionalBurst"):SetParameterColor("Color", color) end) -- Adds this tool to the Sandbox Spawn Menu diff --git a/Server/Tools/Lamp.lua b/Server/Tools/Lamp.lua new file mode 100644 index 0000000..2e83bd5 --- /dev/null +++ b/Server/Tools/Lamp.lua @@ -0,0 +1,46 @@ +-- Event when Client calls to spawn a Lamp +Events:Subscribe("SpawnLamp", function(player, spawn_location, direction, entity, distance_trace_object) + local rotation = direction:Rotation() + Rotator(-90, 0, 0) + + -- Spawns a Lamp Bulb prop + local prop_lamp = Prop(spawn_location, Rotator(), "NanosWorld::SM_TeaPot_Interior") + + -- Sets the player to be the network authority immediately of this Prop + prop_lamp:SetNetworkAuthority(player) + + -- Sets the prop mesh emissive color to a random color + local color = Color(1, 0.6, 0.4) + + local prop_lamp_bulb = Prop(spawn_location, Rotator(), "NanosWorld::SM_Sphere", CollisionType.NoCollision, true, false) + prop_lamp_bulb:AttachTo(prop_lamp) + prop_lamp_bulb:SetScale(Vector(0.175, 0.175, 0.175)) + prop_lamp_bulb:SetRelativeLocation(Vector(-1.5, 0, 17.5)) + prop_lamp_bulb:SetMaterialColorParameter("Emissive", color * 50) + prop_lamp:SetValue("Bulb", prop_lamp_bulb) + + -- Spawns a Point Light, with the color + local intensity = 100 + local light = Light(Vector(), Rotator(), color, LightType.Spot, intensity, 1000, 25, 0.975, 2000, false) + + -- Attaches the lamp to the prop, offseting 25 downwards + light:AttachTo(prop_lamp) + light:SetRelativeLocation(Vector(0, 0, 30)) + light:SetRelativeRotation(Rotator(90, 0, 0)) + + -- If to attach to an entity, otherwise creates and attaches to a fixed invisible mesh + if (entity) then + prop_lamp:AttachTo(entity, AttachmentRule.KeepWorld) + prop_lamp:SetGrabbable(false) + end + + prop_lamp:SetValue("Light", light) + prop_lamp:SetRotation(rotation) + + -- Calls the client to add it to his spawn history + Events:CallRemote("SpawnedItem", player, {prop_lamp}) + + Particle(spawn_location, direction:Rotation(), "NanosWorld::P_DirectionalBurst"):SetParameterColor("Color", color) +end) + +-- Adds this tool to the Sandbox Spawn Menu +AddSpawnMenuItem("NanosWorld", "tools", "LampTool", function() return SpawnGenericToolGun(Vector(), Rotator(), Color.YELLOW) end) \ No newline at end of file diff --git a/Server/Tools/Light.lua b/Server/Tools/Light.lua index b018704..dd4bd98 100644 --- a/Server/Tools/Light.lua +++ b/Server/Tools/Light.lua @@ -1,19 +1,22 @@ -- Event when Client calls to spawn a Light Events:Subscribe("SpawnLight", function(player, spawn_location, direction, entity, distance_trace_object) + local rotation = direction:Rotation() + Rotator(90, 0, 0) + -- Spawns a Light Bulb prop - local prop_light = Prop(spawn_location + Vector(0, 0, (direction * 30).Z), Rotator(), "NanosWorld::SM_Lamp", CollisionType.Normal, true, false) + local prop_light = Prop(spawn_location, Rotator(), "NanosWorld::SM_Lamp", CollisionType.Normal, true, false) + prop_light:SetCollision(CollisionType.StaticOnly) -- Sets the player to be the network authority immediately of this Prop prop_light:SetNetworkAuthority(player) -- Sets the prop mesh emissive color to a random color local color = Color.RandomPalette() - prop_light:SetMaterialColorParameter("Emissive", color * 10) + prop_light:SetMaterialColorParameter("Emissive", color * 50) -- prop_light:SetPhysicsDamping(5, 10) -- Spawns a Point Light, with the color local intensity = 100 - local light = Light(Vector(), Rotator(), color, LightType.Point, intensity) + local light = Light(Vector(), Rotator(), color, LightType.Point, intensity, 250, 44, 0, 2000) -- Attaches the light to the prop, offseting 25 downwards light:AttachTo(prop_light) @@ -36,13 +39,14 @@ Events:Subscribe("SpawnLight", function(player, spawn_location, direction, entit end cable:AttachEndTo(prop_light) - prop_light:SetValue("Cable", cable) prop_light:SetValue("Light", light) + prop_light:SetRotation(rotation) + prop_light:SetLocation(spawn_location) -- Calls the client to add it to his spawn history Events:CallRemote("SpawnedItem", player, {prop_light}) - Events:BroadcastRemote("SpawnParticle", {spawn_location, direction:Rotation(), "NanosWorld::P_DirectionalBurst", color}) + Particle(spawn_location, direction:Rotation(), "NanosWorld::P_DirectionalBurst"):SetParameterColor("Color", color) end) -- Adds this tool to the Sandbox Spawn Menu diff --git a/Server/Tools/Resizer.lua b/Server/Tools/Resizer.lua index a7c0605..9828c94 100644 --- a/Server/Tools/Resizer.lua +++ b/Server/Tools/Resizer.lua @@ -1,6 +1,7 @@ -- Subscribes for client event to resize an object -Events:Subscribe("ResizeObject", function(player, object, scale) +Events:Subscribe("ResizeObject", function(player, object, scale, up) object:SetScale(scale) + Events:BroadcastRemote("SpawnSound", {object:GetLocation(), "NanosWorld::A_Object_Snaps_To_Grid", false, 1, up and 0.9 or 0.8}) end) -- Subscribes for client event to start resizing an object diff --git a/Server/Tools/Rope.lua b/Server/Tools/Rope.lua index fe324d6..d04c40b 100644 --- a/Server/Tools/Rope.lua +++ b/Server/Tools/Rope.lua @@ -34,8 +34,8 @@ Events:Subscribe("RopeAttach", function(player, attaching_start_to, attaching_st -- Calls the client to update his history Events:CallRemote("SpawnedItem", player, {cable}) - Events:BroadcastRemote("SpawnParticle", {attaching_start_location, Rotator(), "NanosWorld::P_OmnidirectionalBurst"}) - Events:BroadcastRemote("SpawnParticle", {attaching_end_location, Rotator(), "NanosWorld::P_OmnidirectionalBurst"}) + Particle(attaching_start_location, Rotator(), "NanosWorld::P_OmnidirectionalBurst") + Particle(attaching_end_location, Rotator(), "NanosWorld::P_OmnidirectionalBurst") end) -- Adds this tool to the Sandbox Spawn Menu diff --git a/Server/Tools/Thruster.lua b/Server/Tools/Thruster.lua index 5953b89..1c55743 100644 --- a/Server/Tools/Thruster.lua +++ b/Server/Tools/Thruster.lua @@ -1,5 +1,5 @@ -- Subscribes for Client Event for spawning a Thruster -Events:Subscribe("SpawnThruster", function(player, spawn_location, direction, entity, distance_trace_object) +Events:Subscribe("SpawnThruster", function(player, spawn_location, direction, entity) -- Calculates the Thruster Rotation to spawn it local rotation = (direction * -1):Rotation() @@ -20,6 +20,7 @@ Events:Subscribe("SpawnThruster", function(player, spawn_location, direction, en -- Gets the relative location rotated to attach to the exact point the player aimed thruster:AttachTo(entity, AttachmentRule.KeepWorld) + entity:SetValue("Thruster", thruster) -- Updates the client's spawn history Events:CallRemote("SpawnedItem", player, {thruster}) @@ -27,8 +28,7 @@ Events:Subscribe("SpawnThruster", function(player, spawn_location, direction, en -- Calls the client to spawns a thruster sound and attach to the thruster (currently sounds are client-only) Events:BroadcastRemote("SpawnThruster", {thruster}) - -- Calls the Client to spawn ballons spawning sounds - Events:BroadcastRemote("SpawnParticle", {spawn_location, rotation, "NanosWorld::P_DirectionalBurst"}) + Particle(spawn_location, rotation, "NanosWorld::P_DirectionalBurst") end) -- Adds this tool to the Sandbox Spawn Menu diff --git a/Server/Tools/Trail.lua b/Server/Tools/Trail.lua new file mode 100644 index 0000000..d1270ff --- /dev/null +++ b/Server/Tools/Trail.lua @@ -0,0 +1,38 @@ +-- Subscribes for Client Event for spawning a Trail +Events:Subscribe("SpawnTrail", function(player, spawn_location, direction, entity) + -- Calculates the Trail Rotation to spawn it + local rotation = (direction * -1):Rotation() + Rotator(90, 0, 0) + + -- Spawns a Trail Prop + local trail = Prop(spawn_location, rotation, "NanosWorld::SM_CupC", CollisionType.NoCollision, true, false) + + -- Spawns a Particle and attaches it to the trail + local particle = Particle(spawn_location, Rotator(), "NanosWorld::P_Ribbon", false, true) + + local color = Color.RandomPalette() + trail:SetMaterialColorParameter("Tint", color) + + particle:SetParameterColor("Color", color) + particle:SetParameterFloat("LifeTime", 2) + particle:SetParameterFloat("SpawnRate", 60) + + particle:AttachTo(trail) + particle:SetRelativeLocation(rotation:RotateVector(direction * 10)) + + trail:SetValue("Particle", particle) + + -- Sets the player to be the network authority immediately of this Prop (so he can immediately start applying the force on it - on the client side) + trail:SetNetworkAuthority(player) + + -- Gets the relative location rotated to attach to the exact point the player aimed + trail:AttachTo(entity, AttachmentRule.KeepWorld) + entity:SetValue("Trail", trail) + + -- Updates the client's spawn history + Events:CallRemote("SpawnedItem", player, {trail}) + + Particle(spawn_location, rotation, "NanosWorld::P_DirectionalBurst") +end) + +-- Adds this tool to the Sandbox Spawn Menu +AddSpawnMenuItem("NanosWorld", "tools", "TrailTool", function() return SpawnGenericToolGun(Vector(), Rotator(), Color.VIOLET) end) \ No newline at end of file diff --git a/Server/Tools/Weld.lua b/Server/Tools/Weld.lua index e33843c..5bf0de9 100644 --- a/Server/Tools/Weld.lua +++ b/Server/Tools/Weld.lua @@ -21,8 +21,8 @@ Events:Subscribe("Weld", function(player, welding_start, welding_end, welding_en -- Calls the client to update it's action history Events:CallRemote("SpawnedItem", player, {cable}) - Events:BroadcastRemote("SpawnParticle", {welding_start:GetLocation(), Rotator(), "NanosWorld::P_OmnidirectionalBurst"}) - Events:BroadcastRemote("SpawnParticle", {welding_end_location, Rotator(), "NanosWorld::P_OmnidirectionalBurst"}) + Particle(welding_start:GetLocation(), Rotator(), "NanosWorld::P_OmnidirectionalBurst") + Particle(welding_end_location, Rotator(), "NanosWorld::P_OmnidirectionalBurst") end) -- Adds this tool to the Sandbox Spawn Menu