diff --git a/README.md b/README.md index a6f55257..5790ee59 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,13 @@ If you would like to help just drop a pull request in with your changes! Please try to keep your coding clean! +<<<<<<< HEAD +Workshop branch! + + +======= # License +>>>>>>> master Copyright 2009-2017 SB Dev Team @@ -60,4 +66,51 @@ Unless required by applicable law or agreed to in writing, software distributed [facepunch]: [discord]: [spacebuild]: +[Garry's Mod][garrysmod] Spacebuild Enhancement Project for [Spacebuild][spacebuild] + +Facepunch Page: [Located Here][facepunch] + +Discord Server: [Located Here][discord] + + +# Status + +Working on SB4! + + +# Workshop Installation(OUTDATED) +*The SBEP workshop is currently outdated because of issues with the workshop, we're working to resolve this for the upcoming alpha of Spacebuild 4* + +SBEP is available via the Steam Workshop! Go to [its Workshop page][workshop] and press `Subscribe`, and it will automatically appear in Garry's Mod. + + +# Manual Installation(DO THIS!) + +How to Tortoise Git + Clone/Pull: http://steamcommunity.com/groups/spacebuild/discussions/0/144513670980243163/ + +Simply clone this repository into your `addons` folder: + + cd "%programfiles(x86)%/Steam/SteamApps/common/GarrysMod/garrysmod/addons" + git clone https://github.com/spacebuild/spacebuild.git spacebuild + + +Contributors +=========== +- SnakeSVx +- generalwrex +- TheMerkyShadow +- X-Coder +- thrimbor +- copperwarrior +# License + +Copyright 2009-2017 SB Dev Team +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +[garrysmod]: +[workshop]: +[facepunch]: +[discord]: +[spacebuild]: diff --git a/addon.json b/addon.json index ec024c98..a3b65687 100644 --- a/addon.json +++ b/addon.json @@ -1,5 +1,5 @@ { - "title" : "Spacebuild 3 Enhancement Pack", + "title" : "Spacebuild Enhancement Pack Unofficial V5", "type" : "tool", "tags" : [ "fun", "build" ], "ignore": @@ -11,6 +11,7 @@ "*.bat", "LICENSE", "NOTICE", - "README.md" + "README.md", + "*.jpg" ] } diff --git a/addon.txt b/addon.txt index 3507eda8..e6027f04 100644 --- a/addon.txt +++ b/addon.txt @@ -1,9 +1,9 @@ "AddonInfo" { - "name" "SpaceBuild Enhancement Project" - "version" "6.0" + "name" "SpaceBuild Enhancement Project Unofficial V5" + "version" "7.0" "up_date" "16/10/2012" - "author_name" "Sam Elmer, Firgof Umbra, Hysteria, Slyfo, Paradukes, Fishface, Cerus, DataSchmuck, SnakeSVx, Radon, RevoluPowered" + "author_name" "Sam Elmer, Firgof Umbra, Hysteria, Slyfo, Paradukes, Fishface, Cerus, DataSchmuck, SnakeSVx, Radon, RevoluPowered, stpM64" "author_email" "" "author_url" "" "info" "SBEP" diff --git a/lua/autorun/sbep_part_data.lua b/lua/autorun/sbep_part_data.lua index 4704d5fc..e10711ab 100644 --- a/lua/autorun/sbep_part_data.lua +++ b/lua/autorun/sbep_part_data.lua @@ -8,7 +8,9 @@ general syntax are correct, and generally making the whole thing slightly less horrendous to read. It has also just occurred to me that it would be beneficial to only do this when the tool is first equipped in any given game , at least clientside - preventing the vast amount of memory -hogging that is performed on load at the moment .]]-- ---[[ TYPE CODES:Smallbridge:SWSH - Single width, single height +--[[ TYPE CODES: +Smallbridge: +SWSH - Single width, single height DWSH - Double width, single height SWDH - Single width, double height DWDH - Double width, double height @@ -17,9 +19,11 @@ ESML - Elevator, small ELRG - Elevator, large INSR - Insert Component -Medbridge :MBSH - Medium Bridge, Single Height +Medbridge: +MBSH - Medium Bridge, Single Height -Modbridge:MOD1x1 - Modbridge, square peice +Modbridge: +MOD1x1 - Modbridge, square peice MOD2x1 -Modbridge, double width, single height MOD3x1 - Modbridge, triple width, single height MOD3x2 - Modbridge, triple width, double height @@ -651,10 +655,10 @@ are all one -orientation - only.Then open cl_init .lua and make a new entry in t }, ["models/smallbridge/panels/sbpaneldockin.mdl"] = { { type = "SWSH", pos = Vector(0, 0, 0), dir = Angle(0, 0, 0) }, - { type = "SWSH", pos = Vector(0, 0, 0), dir = Angle(0, 180, 0) } + -- { type = "SWSH", pos = Vector(0, 0, 0), dir = Angle(0, 180, 0) } }, ["models/smallbridge/panels/sbpaneldockout.mdl"] = { - { type = "SWSH", pos = Vector(0, 0, 0), dir = Angle(0, 0, 0) }, + -- { type = "SWSH", pos = Vector(0, 0, 0), dir = Angle(0, 0, 0) }, { type = "SWSH", pos = Vector(0, 0, 0), dir = Angle(0, 180, 0) } }, ["models/smallbridge/panels/sbpaneldoor.mdl"] = { diff --git a/lua/entities/gyropod_advanced.lua b/lua/entities/gyropod_advanced.lua new file mode 100644 index 00000000..301252fc --- /dev/null +++ b/lua/entities/gyropod_advanced.lua @@ -0,0 +1,705 @@ +AddCSLuaFile() +ENT.Type = "anim" +ENT.Base = "base_gmodentity" +ENT.PrintName = "Advanced Gyro Pod" +ENT.Author = "Paradukes and Data" +ENT.Spawnable = false +ENT.RenderGroup = RENDERGROUP_OPAQUE +ENT.AdminSpawnable = false + +if CLIENT then return end + +local math_abs, math_round, math_clamp = math.abs, math.Round, math.Clamp +local math_NormalizeAngle = math.NormalizeAngle + +local function bool_to_number(bool) + return Either(bool, 1, 0) +end + +ENT.Owner = nil +ENT.SPL = nil +ENT.Firing = false +ENT.Vec = nil +ENT.Pitch = 0 +ENT.Yaw = 0 +ENT.Roll = 0 +ENT.MChange = false +ENT.Speed = 0 +ENT.Active = false +ENT.Launchy = false +ENT.Launch = 0 +ENT.Land = true +ENT.LandTime = 0 +ENT.TakeOff = false +ENT.OldAngle = Angle(0, 0, 0) +ENT.EPrs = false +ENT.LTog = false +ENT.MTog = false +ENT.MCC = false +ENT.GPod = true + +function ENT:Initialize() + self:PhysicsInit(SOLID_VPHYSICS) + self:SetMoveType(MOVETYPE_VPHYSICS) + self:SetSolid(SOLID_VPHYSICS) + self:SetMaterial("spacebuild/SBLight5") + + self.Inputs = WireLib.CreateSpecialInputs(self, { + "Activate", "Forward", "Back", + "MoveLeft", "MoveRight", + "MoveUp", "MoveDown", + "RollLeft", "RollRight", + "PitchUp", "PitchDown", + "YawLeft", "YawRight", + "PitchMult", "YawMult", "RollMult", + "ThrustMult", + "MPH Limit", "Damper", "Level", "Roll Lock", "Freeze", "Antigravity", + "AimMode", "AimX", "AimY", "AimZ", "AimVec [VECTOR]" + }) + + self.Outputs = WireLib.CreateSpecialOutputs(self, { + "On", "Frozen", "Targeting Mode", "MPH", "KmPH", "Leveler", "Total Mass", "Props Linked", "Angles [ANGLE]" + }) + + local phys = self:GetPhysicsObject() + + if (IsValid(phys)) then + phys:Wake() + end + + self.LogicCases = ents.FindByClass("logic_case") + self.AllGyroConstraints = {} + self.MoveTable = {} + self.SystemOn = false + self.FreezeOn = false + self.AimModeOn = false + self.GyroSpeed = 0 + self.VSpeed = 0 + self.HSpeed = 0 + self.PMult = 1 + self.RMult = 1 + self.YaMult = 1 + self.TMult = 1 + self.SpdL = 250 + self.Damper = 5 + self.Forw = 0 + self.Back = 0 + self.SLeft = 0 + self.SRight = 0 + self.HUp = 0 + self.HDown = 0 + self.RollLeft = 0 + self.RollRight = 0 + self.GyroPitchUp = 0 + self.GyroPitchDown = 0 + self.GyroYawLeft = 0 + self.GyroYawRight = 0 + self.GyroLvl = false + self.RollLock = false + self.TarPos = Vector(0, 0, 0) + self.GyroMass = 0 + self.Debug = 0 + self.GyroPitch = 0 + self.GyroYaw = 0 + self.EntSoundSource = self + + self.EnableAntigravity = false +end + +function ENT:TriggerInput(iname, value) + if (iname == "Activate") then + self.SystemOn = value ~= 0 + self:UpdateSystemOn(self.SystemOn) + elseif (iname == "Freeze") then + self.FreezeOn = value ~= 0 + self:UpdateFreeze(self.FreezeOn) + elseif (iname == "AimMode") then + self.AimModeOn = value ~= 0 + self:UpdateAimMode(self.AimModeOn) + elseif (iname == "Forward") then + self.Forw = value + elseif (iname == "Back") then + self.Back = value + elseif (iname == "MoveLeft") then + self.SLeft = value + elseif (iname == "MoveRight") then + self.SRight = value + elseif (iname == "MoveUp") then + self.HUp = value + elseif (iname == "MoveDown") then + self.HDown = value + elseif (iname == "RollLeft") then + self.RollLeft = value + elseif (iname == "RollRight") then + self.RollRight = value + elseif (iname == "PitchUp") then + self.GyroPitchUp = value + elseif (iname == "PitchDown") then + self.GyroPitchDown = value + elseif (iname == "YawLeft") then + self.GyroYawLeft = value + elseif (iname == "YawRight") then + self.GyroYawRight = value + elseif (iname == "PitchMult") then + if value ~= 0 then + self.PMult = value + else + self.PMult = 1 + end + elseif (iname == "YawMult") then + if value ~= 0 then + self.YaMult = value + else + self.YaMult = 1 + end + elseif (iname == "RollMult") then + if value ~= 0 then + self.RMult = value + else + self.RMult = 1 + end + elseif (iname == "ThrustMult") then + if value ~= 0 then + self.TMult = value + else + self.TMult = 1 + end + elseif (iname == "AimX") then + self.TarPos.x = value + elseif (iname == "AimY") then + self.TarPos.y = value + elseif (iname == "AimZ") then + self.TarPos.z = value + elseif (iname == "AimVec") then + self.TarPos = value + elseif (iname == "MPH Limit") then + if (value ~= 0) then + self.SpdL = math.Clamp(math.math_abs(value), 0, 999) + else + self.SpdL = 250 + end + elseif (iname == "Damper") then + if (value ~= 0) then + self.Damper = math.Clamp(math.math_abs(value), 0.1, 30) + else + self.Damper = 5 + end + elseif (iname == "Level") then + self.GyroLvl = value ~= 0 + elseif (iname == "Roll Lock") then + self.RollLock = value ~= 0 + elseif (iname == "Antigravity") then + self.EnableAntigravity = value ~= 0 + end +end + +function ENT:UpdateSystemOn(active) + if active then + self.AllGyroConstraints = table.GetKeys( + constraint.GetAllConstrainedEntities(self) + ) + + if self.HighEngineSound or self.LowDroneSound then + self.HighEngineSound:Stop() + self.LowDroneSound:Stop() + end + + self.HighEngineSound = CreateSound(self.EntSoundSource, Sound("ambient/atmosphere/outdoor2.wav")) + self.LowDroneSound = CreateSound(self.EntSoundSource, Sound("ambient/atmosphere/indoor1.wav")) + self.HighEngineSound:Play() + self.LowDroneSound:Play() + self.EntSoundSource:EmitSound("buttons/button1.wav") + else + self.EntSoundSource:EmitSound("buttons/button18.wav") + end +end + +local function Sign(n) + if n < 0 then return -1 + elseif n > 0 then return 1 + else return 0 end +end + +local function GetSpeed(speed, movement_dir, movement_value, speed_limit, damper) + local speed_sign = Sign(speed) + local movement_sign = Sign(movement_dir) + + movement_value = movement_value * math_abs(movement_dir) + + local speed_abs = math_abs(speed) + + if movement_sign == 0 then -- No movement input + local value = speed_abs / 17.6 * 0.2 + damper + + if speed == 0 then + return 0 + elseif speed > 0 then + return speed - value + else + return speed + value + end + end + + local result_delta + + if speed_sign ~= -movement_sign then -- Forward movement + if speed_abs / 17.6 >= speed_limit then + return speed + end + + result_delta = (speed_limit - speed_abs / 17.6) * movement_value * 0.05 + else -- Backward movement + result_delta = -speed_abs / 17.6 - damper + end + + if speed > 0 then + return speed + result_delta + else + return speed - result_delta + end +end + +function ENT:ThinkActive(entpos, entorparvel, localentorparvel, speedmph, rotation_extra_mul) + local gyroshipangles = self:GetAngles() + + if not self.weighttrigger then + self:GyroWeight() + end + + --changing sounds based on speed + if speedmph > 80 then + self.HighEngineVolume = math_clamp(((speedmph * 0.035) - 2.6), 0, 1) + else + self.HighEngineVolume = speedmph * 0.0025 + end + + self.HighEnginePitch = (speedmph * 1.2) + 60 + self.LowDronePitch = (speedmph * 0.2) + 35 + + self.HighEngineSound.ChangeVolume(self.HighEngineSound, self.HighEngineVolume, 0) + + self.HighEngineSound.ChangePitch(self.HighEngineSound, math.Clamp(self.HighEnginePitch, 0, 255), 0) + self.LowDroneSound.ChangePitch(self.LowDroneSound, math.Clamp(self.LowDronePitch, 0, 255), 0) + + local MulForward, MulRight, MulUp = + self.Forw - self.Back, + self.SRight - self.SLeft, + self.HUp - self.HDown + + local GyroRoll = self.RollRight - self.RollLeft + + + self.GyroSpeed = GetSpeed(self.GyroSpeed, MulForward, self.TMult, self.SpdL, self.Damper) + self.HSpeed = GetSpeed(self.HSpeed, MulRight, self.TMult, self.SpdL, self.Damper) + self.VSpeed = GetSpeed(self.VSpeed, MulUp, self.TMult, self.SpdL, self.Damper) + --Force Application + local mass = self.GyroMass * 0.2 + + local entfor, entright, entup = self:GetForward(), self:GetRight(), self:GetUp() + + local velocity = (entfor * self.GyroSpeed) + (entup * self.VSpeed) + (entright * self.HSpeed) + + local pos_front = entpos + entfor * self.frontlength + local pos_rear = entpos + entfor * -self.rearlength + local pos_right = entpos + entright * self.rightwidth + local pos_left = entpos + entright * -self.leftwidth + + local force_pitch + local force_yaw = entright * self.GyroYaw * self.YaMult * mass * rotation_extra_mul + local force_roll + + if self.GyroLvl then + force_pitch = entup * math_NormalizeAngle(-gyroshipangles.p * 0.05) * self.PMult * mass + else + force_pitch = entup * self.GyroPitch * self.PMult * mass * rotation_extra_mul + end + + if self.GyroLvl then + force_roll = entup * math_NormalizeAngle(gyroshipangles.r * 0.05) * self.RMult * mass + elseif self.RollLock and GyroRoll == 0 then + local RMM = mass * self.RMult * 0.0005--0.00005 + local gyrophys = self:GetPhysicsObject():GetAngleVelocity() + local wlrm + + if math_abs(gyroshipangles.p) > 80 then + wlrm = gyrophys.r * (-0.0132 * RMM) + --print(">1", wlrm) + elseif math_abs(gyroshipangles.r) < 100 then + wlrm = gyroshipangles.r * (0.25 * RMM) + --print(">2", wlrm) + else + wlrm = math_NormalizeAngle(gyroshipangles.r + 180) * (0.25 * RMM) + --print(">3", wlrm) + end + + force_roll = entup * math_abs(wlrm) * wlrm * mass + else + force_roll = entup * -GyroRoll * self.RMult * mass + end + + --[[debugoverlay.Line(entpos + entfor * 16, entpos + entfor * 16 + force_pitch, 1, Color(255,0,0), true) + debugoverlay.Line(entpos - entfor * 16, entpos - entfor * 16 - force_pitch, 1, Color(0,255,255), true) + + debugoverlay.Line(entpos + entfor * 16, entpos + entfor * 16 + force_yaw, 1, Color(0,255,0), true) + debugoverlay.Line(entpos - entfor * 16, entpos - entfor * 16 - force_yaw, 1, Color(255,0,255), true) + + debugoverlay.Line(entpos + entright * 16, entpos + entright * 16 + force_roll, 1, Color(0,0,255), true) + debugoverlay.Line(entpos - entright * 16, entpos - entright * 16 - force_roll, 1, Color(255,255,0), true)]] + + for _, ent in ipairs(self.MoveTable) do + if not IsValid(ent) then continue end + + local phy = ent:GetPhysicsObject() + + phy:SetVelocity(velocity) + phy:AddAngleVelocity(-phy:GetAngleVelocity()) + + phy:ApplyForceOffset(-force_pitch, pos_front) + phy:ApplyForceOffset(force_pitch, pos_rear) + + phy:ApplyForceOffset(-force_yaw, pos_front) + phy:ApplyForceOffset(force_yaw, pos_rear) + + phy:ApplyForceOffset(force_roll, pos_right) + phy:ApplyForceOffset(-force_roll, pos_left) + end +end + +function ENT:ThinkUnactive(localentorparvel, speedmph) + if speedmph > 10 then + self:UpdateGravity() + end + + if self.weighttrigger then + self:GyroWeight() + end + + self.GyroSpeed, self.VSpeed, self.HSpeed = localentorparvel.x, localentorparvel.z, -localentorparvel.y + + --Wind down engine sound when turned off + if self.HighEngineSound or self.LowDroneSound then + self.HighEnginePitch = math_clamp(self.HighEnginePitch - 0.7, 0, 300) + self.LowDronePitch = math_clamp(self.LowDronePitch - 0.3, 0, 300) + self.HighEngineVolume = math_clamp(self.HighEngineVolume - 0.005, 0, 2) + self.HighEngineSound.ChangeVolume(self.HighEngineSound, self.HighEngineVolume, 0) + self.HighEngineSound.ChangePitch(self.HighEngineSound, self.HighEnginePitch, 0) + self.LowDroneSound.ChangePitch(self.LowDroneSound, self.LowDronePitch, 0) + + if self.LowDronePitch < 1 then + self.LowDroneSound:Stop() + self.HighEngineSound:Stop() + end + end +end + +function ENT:Think() + --Determines whether stuff comes from vehicle or entity + if IsValid(self.Pod) then + self.GyroDriver, self.EntSoundSource = self.Pod:GetDriver(), self.Pod + else + self.EntSoundSource = self + end + + local ent_measure = self + + while IsValid(ent_measure:GetParent()) do + ent_measure = ent_measure:GetParent() + end + + local entpos, entorparvel = self:GetPos(), ent_measure:GetVelocity() + local localentorparvel = self:WorldToLocal(entorparvel + entpos) --most of the features rely on these numbers + local speedmph = math_round(localentorparvel:Length() / 17.6) + + if self.FreezeOn then + self.GyroSpeed, self.VSpeed, self.HSpeed = 0, 0, 0 + end + + if self.SystemOn then + local rotation_extra_mul = 1 + + if self.AimModeOn then + self:AimByTarPos() + else + --increase pitch yaw during high speeds + if speedmph > 75 then + rotation_extra_mul = speedmph / 75 + end + + if (self.GyroDriver and IsValid(self.GyroDriver)) then + self:AimByMouse() + else + self.GyroPitch = (self.GyroPitchDown - self.GyroPitchUp) * 2 + self.GyroYaw = self.GyroYawLeft - self.GyroYawRight + self.ViewDelay = true + end + end + + self:ThinkActive(entpos, entorparvel, localentorparvel, speedmph, rotation_extra_mul) + else + self:ThinkUnactive(localentorparvel, speedmph) + end + + Wire_TriggerOutput(self, "On", bool_to_number(self.SystemOn)) + Wire_TriggerOutput(self, "Frozen", bool_to_number(self.FreezeOn)) + Wire_TriggerOutput(self, "Targeting Mode", bool_to_number(self.AimModeOn)) + Wire_TriggerOutput(self, "MPH", speedmph) + Wire_TriggerOutput(self, "KmPH", math_round(localentorparvel:Length() / 10.93613297222)) + Wire_TriggerOutput(self, "Leveler", bool_to_number(self.GyroLvl)) + Wire_TriggerOutput(self, "Total Mass", self.GyroMass) + Wire_TriggerOutput(self, "Props Linked", table.Count(self.MoveTable)) + Wire_TriggerOutput(self, "Angles", self:GetAngles()) + self:NextThink(CurTime() + 0.01) + + return true +end + +--Aiming mode Calculations +function ENT:AimByTarPos() + self:PodModelFix() + local PodPos, PodUp = self.EntSoundSource:GetPos(), self.EntSoundSource:GetUp() + local TarPosVec = self.TarPos - PodPos + TarPosVec:Normalize() + local TarMod = PodPos + TarPosVec * 100 + local FDistP = TarMod:Distance(PodPos + PodUp * 500) + local BDistP = TarMod:Distance(PodPos + PodUp * -500) + self.GyroPitch = (FDistP - BDistP) * 0.1 + local FDistY = TarMod:Distance(PodPos + self.T90 * -self.Tmod) + local BDistY = TarMod:Distance(PodPos + self.T90 * self.Tmod) + self.GyroYaw = (BDistY - FDistY) * 0.1 +end + +--Mouselook Calculations (whoever figured this out is my personal hero) +function ENT:AimByMouse() + --small delay beofre mouse look is enabled + if self.ViewDelay then + self.ViewDelayOut = 0 + + timer.Simple(1.5, function() + self.ViewDelay = false + end) + else + self.GyroDriver:CrosshairEnable() + self.ViewDelayOut = 1 + end + + self:PodModelFix() + local PodPos, PodUp = self.Pod:GetPos(), self.Pod:GetUp() + local PodAim = self.GyroDriver:GetAimVector() + local PRel = PodPos + PodAim * 100 + local FDistP = PRel:Distance(PodPos + PodUp * 500) + local BDistP = PRel:Distance(PodPos + PodUp * -500) + local PitchA = math_clamp((FDistP - BDistP) * 0.03, -7, 7) + + if (PitchA > 0.3) then + self.GyroPitch = (PitchA - 0.3) * self.ViewDelayOut + elseif (PitchA < -0.3) then + self.GyroPitch = (PitchA + 0.3) * self.ViewDelayOut + else + self.GyroPitch = 0 + end + + local FDistY = PRel:Distance(PodPos + self.T90 * -self.Tmod) + local BDistY = PRel:Distance(PodPos + self.T90 * self.Tmod) + local YawA = math_clamp((BDistY - FDistY) * 0.03, -7, 7) + + if (YawA > 0.3) then + self.GyroYaw = (YawA - 0.3) * self.ViewDelayOut + elseif (YawA < -0.3) then + self.GyroYaw = (YawA + 0.3) * self.ViewDelayOut + else + self.GyroYaw = 0 + end +end + +function ENT:UpdateAimMode(active) + if active then + self.EntSoundSource:EmitSound("buttons/combine_button3.wav") + else + self.EntSoundSource:EmitSound("buttons/combine_button2.wav") + end +end + +--fixing the strange bug where some vehicles are rotated 90 degrees +function ENT:PodModelFix() + if (self.Pod and IsValid(self.Pod)) then + local podmodel = self.Pod:GetModel() + + if (string.find(podmodel, "carseat") or string.find(podmodel, "nova") or string.find(podmodel, "prisoner_pod_inner")) then + local podright = self.Pod:GetRight() + self.T90, self.Tmod = podright, 500 + else + local podfor = self.Pod:GetForward() + self.T90, self.Tmod = podfor, -500 + end + else + local entright = self:GetRight() + self.T90, self.Tmod = entright, 500 + end +end + +function ENT:GyroWeight() + if not self.SystemOn then + self.MoveTable = {} + self.GyroMass = 0 + self.weighttrigger = false + + return + end + + local entities = {} + + local GyroPos = self:GetPos() + local gyrofor = GyroPos + (self:GetForward() * 5000) + local gyroback = GyroPos + (self:GetForward() * -5000) + local gyroright = GyroPos + (self:GetRight() * 5000) + local gyroleft = GyroPos + (self:GetRight() * -5000) + + local mindist_front, mindist_back, mindist_right, mindist_left = math.huge, math.huge, math.huge, math.huge + local max_mass = 0 + + for _, ent in ipairs(self.AllGyroConstraints) do + if not IsValid(ent) then continue end + + local linkphys = ent:GetPhysicsObject() + local mass = linkphys:GetMass() + local entspos = ent:GetPos() + local frontdist = entspos:Distance(gyrofor) + local backdist = entspos:Distance(gyroback) + local rightdist = entspos:Distance(gyroright) + local leftdist = entspos:Distance(gyroleft) + self.GyroMass = (self.GyroMass + mass) + + if mass > 10 then + mindist_front = math.min(mindist_front, frontdist) + mindist_back = math.min(mindist_back, backdist) + mindist_right = math.min(mindist_right, rightdist) + mindist_left = math.min(mindist_left, leftdist) + max_mass = math.max(max_mass, mass) + + table.insert(entities, ent) + end + end + + self.frontlength, self.rearlength, self.rightwidth, self.leftwidth = + math_round(mindist_front), math_round(mindist_back), + math_round(mindist_right), math_round(mindist_left) + + max_mass = math_round(max_mass) + + + local parent = self:GetParent() + + --[[ + for _, ent in ipairs(entities) do + local ilinkphys = ent:GetPhysicsObject() + local ipos = ent:GetPos() + + if math_round(ipos:Distance(gyrofor)) == self.frontlength or + math_round(ipos:Distance(gyroback)) == self.rearlength or + math_round(ipos:Distance(gyroright)) == self.rightwidth or + math_round(ipos:Distance(gyroleft)) == self.leftwidth or + math_round(ilinkphys:GetMass()) == max_mass or + ent == parent then + + table.insert(self.MoveTable, ent) + end + end]] + + if IsValid(parent) then + table.insert(entities, parent) + end + + self.MoveTable = entities + + self:UpdateGravity() + self.weighttrigger = true +end + +--Turns on/off gravity for all constrained entities +function ENT:UpdateGravity() + for _, ent in ipairs(self.AllGyroConstraints) do + if (not IsValid(ent)) then return end + local linkphys = ent:GetPhysicsObject() + linkphys:EnableDrag(false) + + if self.SystemOn or self.EnableAntigravity then + linkphys:EnableGravity(false) + else + linkphys:EnableGravity(true) + end + end +end + +--Freezes all constrained entities +function ENT:UpdateFreeze(activate) + local constrainedents = constraint.GetAllConstrainedEntities(self) + + if activate then + self.EntSoundSource:EmitSound("buttons/lever7.wav") + else + self.EntSoundSource:EmitSound("buttons/button6.wav") + end + + for _, ent in pairs(constrainedents) do + if not IsValid(ent) then return end + local physobj = ent:GetPhysicsObject() + + physobj:EnableMotion(not activate) + physobj:Wake() + end +end + +function ENT:Link(pod) + if not pod then return false end + self.Pod = pod + + return true +end + +function ENT:OnRemove() + if self.sound then + self.HighEngineSound:Stop() + self.LowDroneSound:Stop() + end + + for _, ent in ipairs(self.AllGyroConstraints) do + if (not IsValid(ent)) then return end + local linkphys = ent:GetPhysicsObject() + + if IsValid(linkphys) then + linkphys:EnableDrag(true) + linkphys:EnableGravity(true) + end + end +end + +function ENT:PreEntityCopy() + local DI = {} + + if (self.Pod and IsValid(self.Pod)) then + DI.Pod = self.Pod:EntIndex() + end + + if WireAddon then + DI.WireData = WireLib.BuildDupeInfo(self) + end + + duplicator.StoreEntityModifier(self, "SBEPGyroAdv", DI) +end + +duplicator.RegisterEntityModifier("SBEPGyroAdv", function() end) + +function ENT:PostEntityPaste(pl, Ent, CreatedEntities) + local DI = Ent.EntityMods.SBEPGyroAdv + + if (DI.Pod) then + self.Pod = CreatedEntities[DI.Pod] + --[[if (!self.Pod) then + self.Pod = ents.GetByIndex(DI.Pod) + end]] + end + + if (Ent.EntityMods and Ent.EntityMods.SBEPGyroAdv.WireData) then + WireLib.ApplyDupeInfo(pl, Ent, Ent.EntityMods.SBEPGyroAdv.WireData, function(id) return CreatedEntities[id] end) + end +end \ No newline at end of file diff --git a/lua/entities/gyropod_advanced/cl_init.lua b/lua/entities/gyropod_advanced/cl_init.lua deleted file mode 100644 index 7cf34bc3..00000000 --- a/lua/entities/gyropod_advanced/cl_init.lua +++ /dev/null @@ -1,7 +0,0 @@ -include('shared.lua') -ENT.RenderGroup = RENDERGROUP_OPAQUE -function ENT:Initialize() -end -function ENT:Draw() - self:DrawModel() -end diff --git a/lua/entities/gyropod_advanced/init.lua b/lua/entities/gyropod_advanced/init.lua deleted file mode 100644 index 51f5c44c..00000000 --- a/lua/entities/gyropod_advanced/init.lua +++ /dev/null @@ -1,740 +0,0 @@ -AddCSLuaFile( "cl_init.lua" ) -AddCSLuaFile( "shared.lua" ) ---include('entities/base_wire_entity/init.lua') -include( 'shared.lua' ) - -util.PrecacheSound( "ambient/atmosphere/outdoor2.wav" ) -util.PrecacheSound( "ambient/atmosphere/indoor1.wav" ) -util.PrecacheSound( "buttons/button1.wav" ) -util.PrecacheSound( "buttons/button18.wav" ) -util.PrecacheSound( "buttons/button6.wav" ) -util.PrecacheSound( "buttons/combine_button3.wav" ) -util.PrecacheSound( "buttons/combine_button2.wav" ) -util.PrecacheSound( "buttons/lever7.wav" ) - -function ENT:Initialize() - self:SetName("advanced_gyropod") - self:PhysicsInit( SOLID_VPHYSICS ) - self:SetMoveType( MOVETYPE_VPHYSICS ) - self:SetSolid( SOLID_VPHYSICS ) - self:SetMaterial("spacebuild/SBLight5"); - self.Inputs = WireLib.CreateSpecialInputs( self, {"Activate", "Forward", "Back", "SpeedAbs", "MoveLeft", "MoveRight", "Lateral", "MoveUp", "MoveDown", "Vertical", "RollLeft", "RollRight", "RollAbs", - "PitchUp", "PitchDown", "PitchAbs", "YawLeft", "YawRight", "YawAbs", "PitchMult", "YawMult", "RollMult", "ThrustMult", "MPH Limit", "Damper", "Level", "Roll Lock", "Freeze", "AimMode", - "AimX", "AimY", "AimZ", "AimVec"},{"NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL", - "NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","NORMAL","VECTOR"} ) - self.Outputs = WireLib.CreateSpecialOutputs(self, { "On", "Frozen", "Targeting Mode", "MPH", "KmPH", "Leveler", "Total Mass", "Props Linked", "Angles" }, { "NORMAL", "NORMAL", "NORMAL", "NORMAL", "NORMAL", "NORMAL", "NORMAL", "NORMAL", "ANGLE" }) - local phys = self:GetPhysicsObject() - if (IsValid(phys)) then - phys:Wake() - end - self.LogicCases = ents.FindByClass( "logic_case" ) - self.AllGyroConstraints = {} - self.PhysTable = {} - self.FrontDist = {} - self.BackDist = {} - self.RightDist = {} - self.LeftDist = {} - self.MassTable = {} - self.MoveTable = {} - self.SystemOn = false - self.FreezeOn = false - self.AimModeOn = false - self.PMult = 1 - self.RMult = 1 - self.YaMult = 1 - self.TMult = 1 - self.SpdL = 250 - self.Damper = 5 - self.Forw = 0 - self.Back = 0 - self.SLeft = 0 - self.SRight = 0 - self.HUp = 0 - self.HDown = 0 - self.RollLeft = 0 - self.RollRight = 0 - self.GyroPitchUp = 0 - self.GyroPitchDown = 0 - self.GyroYawLeft = 0 - self.GyroYawRight = 0 - self.GyroLvl = false - self.RollLock = false - self.TarPos = Vector(0, 0, 0) - self.ModeOut = 0 - self.GyroMass = 0 - self.GyroLevelerOut = 0 - self.GyroParentIndex = 0 - lastshipangle = Angle(0, 0, 0) - self.OnPlanet = true - self.GravTrigger = true - GyroPitchComp = 0 - self.Debug = 0 - self.GyroPitch = 0 - self.GyroYaw = 0 - self.PitchAbs = 0 - self.RollAbs = 0 - self.YawAbs = 0 - self.SpAbs = 0 - self.LatAbs = 0 - self.VertAbs = 0 -end - -function ENT:TriggerInput(iname, value) - if (iname == "Activate") then - if (value ~= 0) then - self.SystemOn = true - else - self.SystemOn = false - end - elseif (iname == "Freeze") then - if (value ~= 0) then - self.FreezeOn = true - else - self.FreezeOn = false - end - elseif (iname == "AimMode") then - if (value ~= 0) then - self.AimModeOn = true - else - self.AimModeOn = false - end - elseif (iname == "Forward") then - if (value ~= 0) then - self.Forw = 1 - else - self.Forw = 0 - end - elseif (iname == "Back") then - if (value ~= 0) then - self.Back = 1 - else - self.Back = 0 - end - elseif (iname == "SpeedAbs") then - self.SpAbs = value - elseif (iname == "MoveLeft") then - if (value ~= 0) then - self.SLeft = 1 - else - self.SLeft = 0 - end - elseif (iname == "MoveRight") then - if (value ~= 0) then - self.SRight = 1 - else - self.SRight = 0 - end - elseif (iname == "Lateral") then - self.LatAbs = value - elseif (iname == "MoveUp") then - if (value ~= 0) then - self.HUp = 1 - else - self.HUp = 0 - end - elseif (iname == "MoveDown") then - if (value ~= 0) then - self.HDown = 1 - else - self.HDown = 0 - end - elseif (iname == "Vertical") then - self.VertAbs = value - elseif (iname == "RollLeft") then - if (value ~= 0) then - self.RollLeft = 1 - else - self.RollLeft = 0 - end - elseif (iname == "RollRight") then - if (value ~= 0) then - self.RollRight = 1 - else - self.RollRight = 0 - end - elseif (iname == "RollAbs") then - self.RollAbs = value - elseif (iname == "PitchUp") then - if (value ~= 0) then - self.GyroPitchUp = 1 - else - self.GyroPitchUp = 0 - end - elseif (iname == "PitchDown") then - if (value ~= 0) then - self.GyroPitchDown = 1 - else - self.GyroPitchDown = 0 - end - elseif (iname == "PitchAbs") then - self.PitchAbs = value - elseif (iname == "YawLeft") then - if (value ~= 0) then - self.GyroYawLeft = 1 - else - self.GyroYawLeft = 0 - end - elseif (iname == "YawRight") then - if (value ~= 0) then - self.GyroYawRight = 1 - else - self.GyroYawRight = 0 - end - elseif (iname == "YawAbs") then - self.YawAbs = value - elseif (iname == "PitchMult") then - if value ~= 0 then - self.PMult = value - else - self.PMult = 1 - end - elseif (iname == "YawMult") then - if value ~= 0 then - self.YaMult = value - else - self.YaMult = 1 - end - elseif (iname == "RollMult") then - if value ~= 0 then - self.RMult = value - else - self.RMult = 1 - end - elseif (iname == "ThrustMult") then - if value ~= 0 then - self.TMult = value - else - self.TMult = 1 - end - elseif (iname == "AimX") then - self.TarPos.x = value - elseif (iname == "AimY") then - self.TarPos.y = value - elseif (iname == "AimZ") then - self.TarPos.z = value - elseif (iname == "AimVec") then - self.TarPos = value - elseif (iname == "MPH Limit") then - if (value ~= 0) then - self.SpdL = math.Clamp(math.abs(value), 0, 999) - else - self.SpdL = 250 - end - elseif (iname == "Damper") then - if (value ~= 0) then - self.Damper = math.Clamp(math.abs(value), 0.1, 30) - else - self.Damper = 5 - end - elseif (iname == "Level") then - if (value ~= 0) then - self.GyroLevelerOut = 1 - self.GyroLvl = true - else - self.GyroLevelerOut = 0 - self.GyroLvl = false - end - elseif (iname == "Roll Lock") then - if (value ~= 0) then - --self.RollLockOut = 1 - self.RollLock = true - else - --self.RollLockOut = 0 - self.RollLock = false - end - end -end - -function ENT:Think() - - - - local abs, round, clamp, sqrt = math.abs, math.Round, math.Clamp, math.sqrt --speed up math - local gyroshipangles = self:GetAngles() - if (self.Pod and IsValid(self.Pod)) then --Determines whether stuff comes from vehicle or entity - self.GyroDriver, self.entorpod = self.Pod:GetDriver(), self.Pod - else - self.entorpod = self - end - if IsValid(self:GetParent()) then --Determines whether to get local velocity from the Gyropod, or the entity it is parented to, if it exists - entorpar = self:GetParent() - else - entorpar = self - end - local entpos, entorparvel = self:GetPos(), entorpar:GetVelocity() - local localentorparvel = self:WorldToLocal(entorparvel + entpos)--most of the features rely on these numbers - local speedmph = round(localentorparvel:Length() / 17.6) - - if self.FreezeOn then --convert toggled to non-toggled for freezing - if !self.freezetrigger then - self.entorpod:EmitSound( "buttons/lever7.wav" ) - self:FreezeMotion() - end - self.GyroSpeed, self.VSpeed, self.HSpeed = 0, 0, 0 - self.FreezeOut = 1 - else - if self.freezetrigger then - self.entorpod:EmitSound( "buttons/button6.wav" ) - self:FreezeMotion() - end - self.FreezeOut = 0 - end - - if self.AimModeOn then - self.ModeOut = 1 - if !self.AimSound then - self.entorpod:EmitSound( "buttons/combine_button3.wav" ) - self.AimSound = true - end - if self.SystemOn then - self:AimByTarPos() - end - else - if speedmph > 75 then --increase pitch yaw during high speeds - NTC = speedmph / 75 - else - NTC = 1 - end - self.ModeOut = 0 - if self.AimSound then - self.entorpod:EmitSound( "buttons/combine_button2.wav" ) - self.AimSound = false - end - if self.SystemOn then - if (self.GyroDriver and IsValid(self.GyroDriver)) then - self:AimByMouse() - else - self.GyroPitch = ((self.GyroPitchDown - self.GyroPitchUp) + self.PitchAbs )* 2 - self.GyroYaw = (self.GyroYawLeft - self.GyroYawRight)+ self.YawAbs - self.ViewDelay = true - end - end - end - - if self.SystemOn then - self.OnOut = 1 - self.OnPlanet = false - self.plantrigger = true - -- if self.GravTrigger then - -- self:Gravity() - -- self.GravTrigger = false - -- end - if !self.gyroenginesound then - self.AllGyroConstraints = constraint.GetAllConstrainedEntities( self ) - if self.HighEngineSound or self.LowDroneSound then - self.HighEngineSound:Stop() - self.LowDroneSound:Stop() - end - self.HighEngineSound = CreateSound(self.entorpod, Sound("ambient/atmosphere/outdoor2.wav")) - self.LowDroneSound = CreateSound(self.entorpod, Sound("ambient/atmosphere/indoor1.wav")) - self.HighEngineSound:Play() - self.LowDroneSound:Play() - self.entorpod:EmitSound( "buttons/button1.wav" ) - self.gyroenginesound = true - end - - if !self.weighttrigger then - self:GyroWeight() - end - - if speedmph > 80 then --changing sounds based on speed - self.HighEngineVolume = clamp(((speedmph * 0.035)-2.6), 0, 1) - else - self.HighEngineVolume = speedmph * 0.0025 - end - self.HighEnginePitch = (speedmph * 1.2) + 60 - self.LowDronePitch = 35+(speedmph * 0.2) - self.HighEngineSound.ChangeVolume(self.HighEngineSound, self.HighEngineVolume, 0) - self.HighEngineSound.ChangePitch(self.HighEngineSound, math.Clamp(self.HighEnginePitch, 0, 255), 0) - self.LowDroneSound.ChangePitch(self.LowDroneSound, math.Clamp(self.LowDronePitch, 0, 255), 0) - - local speedx, speedy, speedz = abs(localentorparvel.x) / 17.6, abs(localentorparvel.y) / 17.6, abs(localentorparvel.z) / 17.6 - local SMult, HMult, VMult, GyroRoll = (self.Forw - self.Back) + self.SpAbs, (self.SRight - self.SLeft) + self.LatAbs, (self.HUp - self.HDown) + self.VertAbs, (self.RollRight - self.RollLeft) + self.RollAbs - if abs(speedx) >= self.SpdL then --Speed Limit modifiers - self.XMult = 0 - else - self.XMult = 1 - end - if abs(speedy) >= self.SpdL then - self.YMult = 0 - else - self.YMult = 1 - end - if abs(speedz) >= self.SpdL then - self.ZMult = 0 - else - self.ZMult = 1 - end - - if (SMult > 0) and (self.GyroSpeed >= 0) then --pressing forward and moving forwards - self.GyroSpeed = self.GyroSpeed + ( self.TMult * self.XMult * (self.SpdL - abs(speedx)) * 0.05 ) - elseif (SMult < 0) and (self.GyroSpeed <= 0) then --pressing reverse moving backwards - self.GyroSpeed = self.GyroSpeed - ( self.TMult * self.XMult * (self.SpdL - abs(speedx)) * 0.05 ) - elseif (SMult > 0) and (self.GyroSpeed < 0) then --pressing forward and moving backwards, increase speed faster until moving forwards again - self.GyroSpeed = self.GyroSpeed + ((abs(speedx) ) + self.Damper) - elseif (SMult < 0) and (self.GyroSpeed > 0) then --pressing reverse and moving forwards, reverse speed faster until moving backwards again - self.GyroSpeed = self.GyroSpeed - ((abs(speedx) ) + self.Damper) - elseif (SMult == 0) and (self.GyroSpeed > 0) then --not pressing for or back and moving forwards, slow movement faster until stopped - self.GyroSpeed = self.GyroSpeed - ((abs(speedx) * 0.2) + self.Damper) - elseif (SMult == 0) and (self.GyroSpeed < 0) then --not pressing forw or back and moving backwards slow movement faster until stopped - self.GyroSpeed = self.GyroSpeed + ((abs(speedx) * 0.2) + self.Damper) - end - - if (HMult > 0) and (self.HSpeed >= 0) then --Strafe movement - self.HSpeed = self.HSpeed + ( self.TMult * self.YMult * (self.SpdL - abs(speedy)) * 0.05 ) - elseif (HMult < 0) and (self.HSpeed <= 0) then - self.HSpeed = self.HSpeed - ( self.TMult * self.YMult * (self.SpdL - abs(speedy)) * 0.05 ) - elseif (HMult > 0) and (self.HSpeed < 0) then - self.HSpeed = self.HSpeed + ((abs(speedy) ) + self.Damper) - elseif (HMult < 0) and (self.HSpeed > 0) then - self.HSpeed = self.HSpeed - ((abs(speedy) ) + self.Damper) - elseif (HMult == 0) and (self.HSpeed > 0) then - self.HSpeed = self.HSpeed - ((abs(speedy) * 0.2) + self.Damper) - elseif (HMult == 0) and (self.HSpeed < 0) then - self.HSpeed = self.HSpeed + ((abs(speedy) * 0.2) + self.Damper) - end - if (VMult > 0) and (self.VSpeed >= 0) then --Height Movement - self.VSpeed = self.VSpeed + ( self.TMult * self.ZMult * (self.SpdL - abs(speedz)) * 0.05 ) - elseif (VMult < 0) and (self.VSpeed <= 0) then - self.VSpeed = self.VSpeed - ( self.TMult * self.ZMult * (self.SpdL - abs(speedz)) * 0.05 ) - elseif (VMult > 0) and (self.VSpeed < 0) then - self.VSpeed = self.VSpeed + ((abs(speedz) ) + self.Damper) - elseif (VMult < 0) and (self.VSpeed > 0) then - self.VSpeed = self.VSpeed - ((abs(speedz) ) + self.Damper) - elseif (VMult == 0) and (self.VSpeed > 0) then - self.VSpeed = self.VSpeed - ((abs(speedz) * 0.2) + self.Damper) - elseif (VMult == 0) and (self.VSpeed < 0) then - self.VSpeed = self.VSpeed + ((abs(speedz) * 0.2) + self.Damper) - end - - --Force Application - local mass, entfor, entright, entup = self.GyroMass * 0.2, self:GetForward(), self:GetRight(), self:GetUp() - for x, c in pairs(self.MoveTable) do - if (IsValid(c)) then - local physobj = c:GetPhysicsObject() - local physvel, physangvel = physobj:GetVelocity(), physobj:GetAngleVelocity() - - physobj:SetVelocity( (entfor * self.GyroSpeed) + (entup * self.VSpeed) + (entright * self.HSpeed) ) - physobj:AddAngleVelocity(physangvel * -1) - if self.GyroLvl then - physobj:ApplyForceOffset( entup * math.NormalizeAngle(gyroshipangles.p * 0.05) * self.PMult * mass, entpos + entfor * self.frontlength ) - physobj:ApplyForceOffset( entup * math.NormalizeAngle(-gyroshipangles.p * 0.05) * self.PMult * mass, entpos + entfor * -self.rearlength ) - physobj:ApplyForceOffset( entup * math.NormalizeAngle(gyroshipangles.r * 0.05) * self.RMult * mass, entpos + entright * self.rightwidth ) - physobj:ApplyForceOffset( entup * math.NormalizeAngle(-gyroshipangles.r * 0.05) * self.RMult * mass, entpos + entright * -self.leftwidth ) - elseif self.RollLock then - physobj:ApplyForceOffset( entup * -(self.GyroPitch + GyroPitchComp) * self.PMult * mass * NTC, entpos + entfor * self.frontlength ) - physobj:ApplyForceOffset( entup * (self.GyroPitch + GyroPitchComp) * self.PMult * mass * NTC, entpos + entfor * -self.rearlength ) - if abs(GyroRoll) > 0 then - physobj:ApplyForceOffset( entup * -GyroRoll * self.RMult * mass, entpos + entright * self.rightwidth ) - physobj:ApplyForceOffset( entup * GyroRoll * self.RMult * mass, entpos + entright * -self.leftwidth ) - else - local RMM = mass * 0.00005 * self.RMult - local gyrophys = self:GetPhysicsObject():GetAngleVelocity() - - if abs(gyroshipangles.p) > 80 then - self.WLRM = gyrophys.r * (-0.0132 * RMM) - else - if abs(gyroshipangles.r) < 100 then - self.WLRM = gyroshipangles.r * (0.25 * RMM) - else - self.WLRM = math.NormalizeAngle(gyroshipangles.r + 180) * (0.25 * RMM) - end - end - local GyroRollLvl = -abs(self.WLRM) - physobj:ApplyForceOffset( entup * -GyroRollLvl * self.WLRM * mass, entpos + entright * self.rightwidth ) - physobj:ApplyForceOffset( entup * GyroRollLvl * self.WLRM * mass, entpos + entright * -self.leftwidth ) - end - else - physobj:ApplyForceOffset( entup * -(self.GyroPitch + GyroPitchComp) * self.PMult * mass * NTC, entpos + entfor * self.frontlength ) - physobj:ApplyForceOffset( entup * (self.GyroPitch + GyroPitchComp) * self.PMult * mass * NTC, entpos + entfor * -self.rearlength ) - physobj:ApplyForceOffset( entup * -GyroRoll * self.RMult * mass, entpos + entright * self.rightwidth ) - physobj:ApplyForceOffset( entup * GyroRoll * self.RMult * mass, entpos + entright * -self.leftwidth ) - end - physobj:ApplyForceOffset( entright * -self.GyroYaw * self.YaMult * mass * NTC, entpos + entfor * self.frontlength ) - physobj:ApplyForceOffset( entright * self.GyroYaw * self.YaMult * mass * NTC, entpos + entfor * -self.rearlength ) - end - end - else - - if self.plantrigger or speedmph > 10 then - self.OnPlanet = false - for _, logs in ipairs( self.LogicCases ) do - if self.OnPlanet then break end - local logvalues = logs:GetKeyValues() - for key, logvalue1 in pairs(logvalues) do - if self.OnPlanet then break end - if key == "Case01" then - if logvalue1 == "planet" or logvalue1 == "planet2" then - local pradius - for key2, logvalue2 in pairs(logvalues) do - if (key2 == "Case02") then - pradius = tonumber(logvalue2) - local pdist = self:GetPos():Distance(logs:GetPos()) - if pdist < pradius then - self.OnPlanet = true - break - else - self.OnPlanet = false - end - end - end - end - end - end - end - self:Gravity() - self.plantrigger = false - self.GravTrigger = true - end - if self.gyroenginesound then - self.entorpod:EmitSound( "buttons/button18.wav" ) - self.gyroenginesound = false - end - - if self.weighttrigger then - self:GyroWeight() - end - - self.OnOut, self.GyroSpeed, self.VSpeed, self.HSpeed = 0, localentorparvel.x, localentorparvel.z, -localentorparvel.y - lastshipangle = self:GetAngles() - - if self.HighEngineSound or self.LowDroneSound then --Wind down engine sound when turned off - self.HighEnginePitch = clamp(self.HighEnginePitch - 0.7, 0, 300) - self.LowDronePitch = clamp(self.LowDronePitch - 0.3, 0, 300) - self.HighEngineVolume = clamp(self.HighEngineVolume - 0.005, 0, 2) - self.HighEngineSound.ChangeVolume(self.HighEngineSound, self.HighEngineVolume, 0) - self.HighEngineSound.ChangePitch(self.HighEngineSound, self.HighEnginePitch, 0) - self.LowDroneSound.ChangePitch(self.LowDroneSound, self.LowDronePitch, 0) - if self.LowDronePitch < 1 then - self.LowDroneSound:Stop() - self.HighEngineSound:Stop() - end - end - end - Wire_TriggerOutput(self, "On", self.OnOut) - Wire_TriggerOutput(self, "Frozen", self.FreezeOut) - Wire_TriggerOutput(self, "Targeting Mode", self.ModeOut) - Wire_TriggerOutput(self, "MPH", speedmph) - Wire_TriggerOutput(self, "KmPH", round(localentorparvel:Length() / 10.93613297222)) - Wire_TriggerOutput(self, "Leveler", self.GyroLevelerOut) - Wire_TriggerOutput(self, "Total Mass", self.GyroMass) - Wire_TriggerOutput(self, "Props Linked", table.Count(self.MoveTable)) - Wire_TriggerOutput(self, "Angles", gyroshipangles) - - self:NextThink( CurTime() + 0.01 ) - return true -end - -function ENT:AimByTarPos() --Aiming mode Calculations - self:PodModelFix() - local PodPos, PodUp = self.entorpod:GetPos(), self.entorpod:GetUp() - local TarPosVec = self.TarPos - PodPos - TarPosVec:Normalize() - local TarMod = PodPos + TarPosVec * 100 - local FDistP = TarMod:Distance( PodPos + PodUp * 500 ) - local BDistP = TarMod:Distance( PodPos + PodUp * -500 ) - self.GyroPitch = (FDistP - BDistP) * 0.1 - local FDistY = TarMod:Distance( PodPos + self.T90 * -self.Tmod ) - local BDistY = TarMod:Distance( PodPos + self.T90 * self.Tmod ) - self.GyroYaw = (BDistY - FDistY) * 0.1 -end - -function ENT:AimByMouse() --Mouselook Calculations (whoever figured this out is my personal hero) - local clamp = math.Clamp - if self.ViewDelay then --small delay beofre mouse look is enabled - self.ViewDelayOut = 0 - timer.Simple(1.5,function() - self.ViewDelay = false - end) - else - self.GyroDriver:CrosshairEnable() - self.ViewDelayOut = 1 - end - self:PodModelFix() - local PodPos, PodUp = self.Pod:GetPos(), self.Pod:GetUp() - local PodAim = self.GyroDriver:GetAimVector() - local PRel = PodPos + PodAim * 100 - local FDistP = PRel:Distance( PodPos + PodUp * 500 ) - local BDistP = PRel:Distance( PodPos + PodUp * -500 ) - local PitchA = clamp((FDistP - BDistP) * 0.03, -7, 7) - if (PitchA > 0.3) then - self.GyroPitch = (PitchA - 0.3) * self.ViewDelayOut - elseif (PitchA < -0.3) then - self.GyroPitch = (PitchA + 0.3) * self.ViewDelayOut - else - self.GyroPitch = 0 - end - local FDistY = PRel:Distance( PodPos + self.T90 * -self.Tmod ) - local BDistY = PRel:Distance( PodPos + self.T90 * self.Tmod ) - local YawA = clamp((BDistY - FDistY) * 0.03, -7, 7) - if (YawA > 0.3) then - self.GyroYaw = (YawA - 0.3) * self.ViewDelayOut - elseif (YawA < -0.3) then - self.GyroYaw = (YawA + 0.3) * self.ViewDelayOut - else self.GyroYaw = 0 - end -end - -function ENT:PodModelFix() --fixing the strange bug where some vehicles are rotated 90 degrees - if (self.Pod and IsValid(self.Pod)) then - local podmodel = self.Pod:GetModel() - if (string.find(podmodel, "carseat") or string.find(podmodel, "nova") or string.find(podmodel, "prisoner_pod_inner")) then - local podright = self.Pod:GetRight() - self.T90, self.Tmod = podright, 500 - else - local podfor = self.Pod:GetForward() - self.T90, self.Tmod = podfor, -500 - end - else - local entright = self:GetRight() - self.T90, self.Tmod = entright, 500 - end -end - -function ENT:GyroWeight() - local rnd = math.Round - local GyroPos = self:GetPos() - local gyrofor = GyroPos + (self:GetForward() * 5000) - local gyroback = GyroPos + (self:GetForward() * -5000) - local gyroright = GyroPos + (self:GetRight() * 5000) - local gyroleft = GyroPos + (self:GetRight() * -5000) - if self.SystemOn then - for _, ents in pairs( self.AllGyroConstraints ) do - if (!IsValid(ents)) then return end - local linkphys = ents:GetPhysicsObject() - local mass = linkphys:GetMass() - local entspos = ents:GetPos() - local frontdist = entspos:Distance(gyrofor) - local backdist = entspos:Distance(gyroback) - local rightdist = entspos:Distance(gyroright) - local leftdist = entspos:Distance(gyroleft) - self.GyroMass = (self.GyroMass + mass) - if (linkphys:GetMass() > 10) then - table.insert(self.MassTable, mass) - table.insert(self.FrontDist, frontdist) - table.insert(self.BackDist, backdist) - table.insert(self.RightDist, rightdist) - table.insert(self.LeftDist, leftdist) - table.SortDesc(self.MassTable) - table.sort(self.FrontDist) - table.sort(self.BackDist) - table.sort(self.RightDist) - table.sort(self.LeftDist) - table.insert(self.PhysTable, ents) - end - end - local frontent, rearent, rightent, leftent, heaviest = rnd(self.FrontDist[1]), rnd(self.BackDist[1]), rnd(self.RightDist[1]), rnd(self.LeftDist[1]), rnd(self.MassTable[1]) - self.frontlength, self.rearlength, self.rightwidth, self.leftwidth = frontent, rearent, rightent, leftent - if IsValid(self:GetParent()) then - local par = self:GetParent() - self.GyroParentIndex = par:EntIndex() - end - for _, i in pairs( self.PhysTable ) do - local ilinkphys = i:GetPhysicsObject() - local ipos = i:GetPos() - local idx = i:EntIndex() - if rnd(ipos:Distance(gyrofor)) == frontent or rnd(ipos:Distance(gyroback)) == rearent or rnd(ipos:Distance(gyroright)) == rightent or rnd(ipos:Distance(gyroleft)) == leftent or rnd(ilinkphys:GetMass()) == heaviest or idx == self.GyroParentIndex then - table.insert(self.MoveTable, i) - end - end - self:Gravity() - self.weighttrigger = true - else - table.Empty(self.MassTable) - table.Empty(self.PhysTable) - table.Empty(self.FrontDist) - table.Empty(self.BackDist) - table.Empty(self.RightDist) - table.Empty(self.LeftDist) - table.Empty(self.MoveTable) - self.GyroMass = 0 - self.weighttrigger= false - end -end - - -function ENT:Gravity() --Turns on/off gravity for all constrained entities - local constrained = self.AllGyroConstraints - for _, ents in pairs( constrained ) do - if (!IsValid(ents)) then return end - local linkphys = ents:GetPhysicsObject() - linkphys:EnableDrag(false) - if self.SystemOn or !self.OnPlanet then - linkphys:EnableGravity(false) - else - linkphys:EnableGravity(true) - end - end - -end - -function ENT:FreezeMotion() --Freezes all constrained entities - local constrainedents = constraint.GetAllConstrainedEntities( self ) - for _, ents in pairs( constrainedents ) do - if (!IsValid(ents))then return end - if self.FreezeOn then - local physobj = ents:GetPhysicsObject() - physobj:EnableMotion(false) - physobj:Wake() - self.freezetrigger = true - else - local physobj = ents:GetPhysicsObject() - physobj:EnableMotion(true) - physobj:Wake() - self.freezetrigger = false - end - end -end - -function ENT:Link(pod) - if !pod then return false end - self.Pod = pod - return true -end - -function ENT:OnRemove() - if self.sound then - self.HighEngineSound:Stop() - self.LowDroneSound:Stop() - end - local constrained = self.AllGyroConstraints - for _, ents in pairs( constrained ) do - if (!IsValid(ents)) then return end - local linkphys = ents:GetPhysicsObject() - if IsValid(linkphys) then - linkphys:EnableDrag(true) - linkphys:EnableGravity(true) - end - end -end - -function ENT:PreEntityCopy() - local DI = {} - - if (self.Pod and IsValid(self.Pod)) then - DI.Pod = self.Pod:EntIndex() - end - - if WireAddon then - DI.WireData = WireLib.BuildDupeInfo( self ) - end - - duplicator.StoreEntityModifier(self, "SBEPGyroAdv", DI) -end -duplicator.RegisterEntityModifier( "SBEPGyroAdv" , function() end) - -function ENT:PostEntityPaste(pl, Ent, CreatedEntities) - local DI = Ent.EntityMods.SBEPGyroAdv - - if (DI.Pod) then - self.Pod = CreatedEntities[ DI.Pod ] - /*if (!self.Pod) then - self.Pod = ents.GetByIndex(DI.Pod) - end*/ - end - - if(Ent.EntityMods and Ent.EntityMods.SBEPGyroAdv.WireData) then - WireLib.ApplyDupeInfo( pl, Ent, Ent.EntityMods.SBEPGyroAdv.WireData, function(id) return CreatedEntities[id] end) - end - -end diff --git a/lua/entities/gyropod_advanced/shared.lua b/lua/entities/gyropod_advanced/shared.lua deleted file mode 100644 index 0398dc63..00000000 --- a/lua/entities/gyropod_advanced/shared.lua +++ /dev/null @@ -1,27 +0,0 @@ -ENT.Type = "anim" -ENT.Base = "base_gmodentity" -ENT.PrintName = "Advanced Gyro Pod" -ENT.Author = "Paradukes and Data" -ENT.Spawnable = false -ENT.AdminSpawnable = false -ENT.Owner = nil -ENT.SPL = nil -ENT.Firing = false -ENT.Vec = nil -ENT.Pitch = 0 -ENT.Yaw = 0 -ENT.Roll = 0 -ENT.MChange = false -ENT.Speed = 0 -ENT.Active = false -ENT.Launchy = false -ENT.Launch = 0 -ENT.Land = true -ENT.LandTime = 0 -ENT.TakeOff = false -ENT.OldAngle = Angle( 0, 0, 0 ) -ENT.EPrs = false -ENT.LTog = false -ENT.MTog = false -ENT.MCC = false -ENT.GPod = true \ No newline at end of file diff --git a/lua/entities/livable_module/init.lua b/lua/entities/livable_module/init.lua index f8f28c90..6feebc3b 100644 --- a/lua/entities/livable_module/init.lua +++ b/lua/entities/livable_module/init.lua @@ -1,3 +1,4 @@ +if CAF == nil then return end AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) @@ -22,7 +23,7 @@ function ENT:Initialize() else self.Inputs = { { Name = "On" }, { Name = "Radius" }, { Name = "Gravity" }, { Name = "Max O2 level" } } end - CAF.GetAddon("Resource Distribution").RegisterNonStorageDevice(self) + CAF.LibRD.RegisterNonStorageDevice(self) end function ENT:TurnOn() @@ -100,12 +101,12 @@ function ENT:Repair() end function ENT:Destruct() - CAF.GetAddon("Spacebuild").RemoveEnvironment(self) - CAF.GetAddon("Life Support").LS_Destruct(self, true) + CAF.LibSB.RemoveEnvironment(self) + CAF.LibLS.LS_Destruct(self, true) end function ENT:OnRemove() - CAF.GetAddon("Spacebuild").RemoveEnvironment(self) + CAF.LibSB.RemoveEnvironment(self) self.BaseClass.OnRemove(self) self:StopSound("apc_engine_start") end diff --git a/lua/weapons/gmod_tool/stools/gyropod_advanced.lua b/lua/weapons/gmod_tool/stools/gyropod_advanced.lua index 1ede12da..aa640e99 100644 --- a/lua/weapons/gmod_tool/stools/gyropod_advanced.lua +++ b/lua/weapons/gmod_tool/stools/gyropod_advanced.lua @@ -1,5 +1,5 @@ TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#Gyro-Pod" TOOL.Command = nil TOOL.ConfigName = "" @@ -27,10 +27,12 @@ function TOOL:RightClick(trace) return true elseif self:GetStage() == 1 and trace.Entity.GetPassenger then local owner = self:GetOwner() - if self.AdvGyro:Link(trace.Entity) then - owner:PrintMessage(HUD_PRINTTALK,"Vehicle linked to Gyro-Pod!") - else - owner:PrintMessage(HUD_PRINTTALK,"Link failed!") + if SERVER then + if self.AdvGyro:Link(trace.Entity) then + owner:PrintMessage(HUD_PRINTTALK,"Vehicle linked to Gyro-Pod!") + else + owner:PrintMessage(HUD_PRINTTALK,"Link failed!") + end end self:SetStage(0) self.AdvGyro = nil @@ -109,11 +111,8 @@ function TOOL.BuildCPanel(panel) panel:SetSpacing( 10 ) panel:SetName( "SBEP Gyro-Pod (Advanced)" ) - local BindLabel0 = {} - local BindLabel1 = {} - local BindLabel2 = {} - BindLabel0.Text = + panel:Help( [[BASIC INSTRUCTIONS 1: Left Click to create a Gyro-Pod. @@ -133,9 +132,9 @@ function TOOL.BuildCPanel(panel) 9: Use the keys you wired to the movement controls to move the ship through space. ADVANCED CONTROLS (OPTIONAL) -]] +]]) - BindLabel1.Text = + panel:Help( [[MULTIPLIERS Controls axis sensitivity. Values from 0.0 to 0.99 reduce sensitivity. @@ -145,7 +144,7 @@ Defaults for all are 1 SPEED LIMIT Limits the speed in MPH. -Default is 112. Max is 112 +Default is 112. Max is 112 AIMING MODE Points ship towards GPS coords. @@ -156,32 +155,22 @@ FREEZE SHIP All CONSTRAINED entities will be frozen Wire the FREEZE Input to a TOGGLED output. You CAN still use your physgun's reload function to unfreeze the ship. -]] +]]) - BindLabel2.Text = +panel:Help( [[AUTOLEVEL Keeps ship's roll and pitch at 0. Wire LEVEL to a TOGGLED output. TIPS * Press Reload on any prop to set the model of the Gyro-Pod to that prop. - * You do not need to gyro-link anything anymore. Any props whos mass is over 20 will be automatically linked. Wire components are never linked. + * You do not need to gyro-link anything anymore. Any props whos mass is over 20 will be automatically linked. Wire components are never linked. * If you need to cancel a link, press Reload on the Gyro-Pod. - * If you PARENT the Gyro-Pod, you will lose the ability to modify the wiring, so save parenting for last. + * [Probably not an issue more] If you PARENT the Gyro-Pod, you will lose the ability to modify the wiring, so save parenting for last. * Try wiring a 'Not' gate to the 'Active' Output of your pod controller, then wiring the 'Freeze' Input of the Gyro-Pod to the 'Not' gate. * Joystick is supported, but not tested - Credit goes to Paradukes and the SBEP Team for creating the original Gyro-Pod. I (DataSchmuck) just modified the code a bit.]] - - BindLabel0.Description = "Basic Instructions1" - panel:AddControl("Label", BindLabel0 ) - - BindLabel1.Description = "Basic Instructions2" - panel:AddControl("Label", BindLabel1 ) - - BindLabel2.Description = "Basic Instructions3" - panel:AddControl("Label", BindLabel2 ) - +Credit goes to Paradukes and the SBEP Team for creating the original Gyro-Pod. I (DataSchmuck) just modified the code a bit. Additional improvements by stpM64.]]) end diff --git a/lua/weapons/gmod_tool/stools/sbep_docking_clamp.lua b/lua/weapons/gmod_tool/stools/sbep_docking_clamp.lua index b5c888dd..83d1a2c1 100644 --- a/lua/weapons/gmod_tool/stools/sbep_docking_clamp.lua +++ b/lua/weapons/gmod_tool/stools/sbep_docking_clamp.lua @@ -1,5 +1,5 @@ TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#Docking Clamp" TOOL.Command = nil TOOL.ConfigName = "" diff --git a/lua/weapons/gmod_tool/stools/sbep_door.lua b/lua/weapons/gmod_tool/stools/sbep_door.lua index 92ac7a27..cc56a473 100644 --- a/lua/weapons/gmod_tool/stools/sbep_door.lua +++ b/lua/weapons/gmod_tool/stools/sbep_door.lua @@ -1,6 +1,5 @@ TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#Door" TOOL.Command = nil TOOL.ConfigName = "" @@ -12,11 +11,6 @@ if CLIENT then language.Add( "Tool.sbep_door.desc" , "Create an SBEP door." ) language.Add( "Tool.sbep_door.0" , "Left click to spawn a door. Right-click a door to cycle through any alternative models." ) language.Add( "undone_SBEP Door" , "Undone SBEP Door" ) - - local function SBEPDoorToolError( um ) - GAMEMODE:AddNotify( um:ReadString() , um:ReadFloat() , um:ReadFloat() ) - end - usermessage.Hook( "SBEPDoorToolError_cl" , SBEPDoorToolError ) end local CategoryTable = {} @@ -52,21 +46,16 @@ if ( SERVER ) then end duplicator.RegisterEntityClass( "sbep_base_door_controller", MakeDoorController, "Data" ) - end function TOOL:LeftClick( tr ) if CLIENT then return end - + local ply = self:GetOwner() if ply:GetInfoNum( "sbep_door_wire", 1 ) == 0 and ply:GetInfoNum( "sbep_door_enableuse", 1 ) == 0 then - umsg.Start( "SBEPDoorToolError_cl" , RecipientFilter():AddPlayer( ply ) ) - umsg.String( "Cannot be both unusable and unwireable." ) - umsg.Float( 1 ) - umsg.Float( 4 ) - umsg.End() + ply:AddHint("Cannot be both unusable and unwireable.", NOTIFY_ERROR, 4) return end @@ -81,12 +70,12 @@ function TOOL:LeftClick( tr ) DoorController:Spawn() DoorController:Activate() - + DoorController:SetPos( pos - Vector(0,0, DoorController:OBBMins().z ) ) - + if CPPI then DoorController:CPPISetOwner(ply) end DoorController:AddDoors() - + DoorController:MakeWire( ply:GetInfoNum( "sbep_door_wire", 1 ) == 1 ) undo.Create("SBEP Door") @@ -98,7 +87,7 @@ function TOOL:LeftClick( tr ) end undo.SetPlayer( ply ) undo.Finish() - + return true end @@ -108,11 +97,11 @@ function TOOL:RightClick( tr ) if !tr.Hit or !tr.Entity or !tr.Entity:IsValid() then return end local door = tr.Entity local entclass = door:GetClass() - + if entclass == "sbep_base_door" then class = door:GetDoorClass() door:SetDoorClass( class + 1 ) - + return true end end @@ -131,14 +120,14 @@ function TOOL.BuildCPanel( panel ) WireCheckBox:SetTextColor(Color(0,0,0,255)) WireCheckBox:SetConVar( "sbep_door_wire" ) WireCheckBox:SetValue( GetConVar( "sbep_door_wire" ):GetBool() ) - + local UseCheckBox = vgui.Create( "DCheckBoxLabel", panel ) UseCheckBox:Dock(TOP) UseCheckBox:SetText( "Enable Use Key:" ) UseCheckBox:SetTextColor(Color(0,0,0,255)) UseCheckBox:SetConVar( "sbep_door_enableuse" ) UseCheckBox:SetValue( GetConVar( "sbep_door_enableuse" ):GetBool() ) - + for Tab,v in pairs( DoorToolModels ) do for Category, models in pairs( v ) do local catPanel = vgui.Create( "DCollapsibleCategory", panel ) @@ -146,25 +135,22 @@ function TOOL.BuildCPanel( panel ) catPanel:DockMargin(2,2,2,2) catPanel:SetText(Category) catPanel:SetLabel(Category) - + local grid = vgui.Create( "DGrid", catPanel ) grid:Dock( TOP ) - - local width,_ = catPanel:GetSize() + grid:SetColWide( 64 ) grid:SetRowHeight( 64 ) - + for key, modelpath in pairs( models ) do local icon = vgui.Create( "SpawnIcon", panel ) - --icon:Dock( TOP ) icon:SetModel( modelpath ) - icon:SetToolTip( modelpath ) - icon.DoClick = function( panel ) + icon:SetTooltip( modelpath ) + icon.DoClick = function() RunConsoleCommand( "sbep_door_model", modelpath ) end - --icon:SetIconSize( width ) grid:AddItem( icon ) - + end catPanel:SetExpanded( 0 ) end diff --git a/lua/weapons/gmod_tool/stools/sbep_lift_designer.lua b/lua/weapons/gmod_tool/stools/sbep_lift_designer.lua index 7eb9f67a..6a030e76 100644 --- a/lua/weapons/gmod_tool/stools/sbep_lift_designer.lua +++ b/lua/weapons/gmod_tool/stools/sbep_lift_designer.lua @@ -1,5 +1,5 @@ TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#Lift System Designer" TOOL.Command = nil TOOL.ConfigName = "" @@ -495,8 +495,8 @@ if CLIENT then end local function CLNWLift( entLift ) - timer.Simple( 0.2, function() - if entLift:GetNWBool( "Sendable" ) and IsValid(entLift) and LocalPlayer() == entLift:GetOwner() then + timer.Simple( 0.2, function() + if IsValid(entLift) and entLift:GetNWBool( "Sendable" ) and LocalPlayer() == entLift:GetOwner() then LD.SBEP_OpenLiftDesignMenu( entLift ) RunConsoleCommand( "SBEP_LiftGetCamHeight_ser" ) return true diff --git a/lua/weapons/gmod_tool/stools/sbep_part_assembler.lua b/lua/weapons/gmod_tool/stools/sbep_part_assembler.lua index cf459493..87c5daa8 100644 --- a/lua/weapons/gmod_tool/stools/sbep_part_assembler.lua +++ b/lua/weapons/gmod_tool/stools/sbep_part_assembler.lua @@ -1,8 +1,8 @@ -- By Tingle TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" -TOOL.Name = "#Part Assembler" -TOOL.Command = nil +TOOL.Tab = "Custom Addon Framework" +TOOL.Name = "#Part Assembler" +TOOL.Command = nil TOOL.ConfigName = "" TOOL.ClientConVar["skin"] = 0 diff --git a/lua/weapons/gmod_tool/stools/sbep_part_spawner.lua b/lua/weapons/gmod_tool/stools/sbep_part_spawner.lua index e5a25d50..6c79523b 100644 --- a/lua/weapons/gmod_tool/stools/sbep_part_spawner.lua +++ b/lua/weapons/gmod_tool/stools/sbep_part_spawner.lua @@ -1,5 +1,5 @@ TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#Part Spawner" TOOL.Command = nil TOOL.ConfigName = "" @@ -31,7 +31,7 @@ function TOOL:LeftClick(trace) local SMBProp = nil - if hab == 1 then + if hab == 1 and CAF ~= nil then SMBProp = ents.Create("livable_module") else SMBProp = ents.Create("prop_physics") diff --git a/lua/weapons/gmod_tool/stools/sbep_smb_skin_selector.lua b/lua/weapons/gmod_tool/stools/sbep_smb_skin_selector.lua index e8a5f739..a8062848 100644 --- a/lua/weapons/gmod_tool/stools/sbep_smb_skin_selector.lua +++ b/lua/weapons/gmod_tool/stools/sbep_smb_skin_selector.lua @@ -1,5 +1,5 @@ TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#SmallBridge Skin Selector" TOOL.Command = nil TOOL.ConfigName = "" diff --git a/lua/weapons/gmod_tool/stools/wireless_gyropod.lua b/lua/weapons/gmod_tool/stools/wireless_gyropod.lua index b97ff75e..be3ff835 100644 --- a/lua/weapons/gmod_tool/stools/wireless_gyropod.lua +++ b/lua/weapons/gmod_tool/stools/wireless_gyropod.lua @@ -1,7 +1,7 @@ --gyropod_advanced coders: Paradukes, DataSchmuck --wireless_gyropod coder: LoRAWN TOOL.Category = "SBEP" -TOOL.Tab = "Spacebuild" +TOOL.Tab = "Custom Addon Framework" TOOL.Name = "#Wireless Gyropod" TOOL.Command = nil TOOL.ConfigName = "" @@ -24,16 +24,17 @@ end if ( SERVER ) then CreateConVar( "sbox_max" .. RegisterName, 20 ) -end +end + cleanup.Register( RegisterName ) if ( SERVER ) then --stuff needed for setting up ghost and model selection function ConstructGyropod( owner, model, pos, ang ) - if ( !owner:CheckLimit( RegisterName ) ) then return false end + if not owner:CheckLimit( RegisterName ) then return false end local gyropod = ents.Create( ClassName ) - if not(IsValid(gyropod)) then return nil end + if not IsValid(gyropod) then return nil end gyropod:SetAngles(ang) gyropod:SetPos(pos) gyropod:SetModel(model) @@ -47,17 +48,16 @@ if ( SERVER ) then return gyropod end duplicator.RegisterEntityClass(ClassName, ConstructGyropod, "Model", "Pos", "Angle") - end --spawn a gyropod function TOOL:LeftClick( trace ) local owner = self:GetOwner() - if ( !trace.HitPos ) then return false end - if ( trace.Entity:IsPlayer() ) then return false end - if ( CLIENT ) then return true end - if ( !self:GetSWEP():CheckLimit( RegisterName ) ) then return false end - if ( trace.Entity:IsValid() and trace.Entity:GetClass() == ClassName and trace.Entity:GetTable().pl == owner ) then return true end + if not trace.HitPos then return false end + if trace.Entity:IsPlayer() then return false end + if CLIENT then return true end + if not self:GetSWEP():CheckLimit( RegisterName ) then return false end + if trace.Entity:IsValid() and trace.Entity:GetClass() == ClassName and trace.Entity:GetTable().pl == owner then return true end local angle = trace.HitNormal:Angle() angle.pitch = angle.pitch + 90 local model = self:GetClientInfo( "model" ) @@ -75,8 +75,8 @@ end --link a vehicle to a gyropod function TOOL:RightClick( trace ) local owner = self:GetOwner() - if ( self:GetStage() == 0 ) then - if( trace.Entity:GetClass() == ClassName ) then + if self:GetStage() == 0 then + if trace.Entity:GetClass() == ClassName then self.gyro = trace.Entity self:SetStage( 1 ) return true @@ -84,11 +84,13 @@ function TOOL:RightClick( trace ) owner:PrintMessage( HUD_PRINTTALK, "Entity is not a gyropod!" ) return false end - if( trace.Entity:IsVehicle() ) then - if ( self.gyro:Link( trace.Entity ) ) then - owner:PrintMessage( HUD_PRINTTALK, "Link successful!" ) - else - owner:PrintMessage( HUD_PRINTTALK, "Link failed!" ) + if trace.Entity:IsVehicle() then + if SERVER then + if ( self.gyro:Link( trace.Entity ) ) then + owner:PrintMessage( HUD_PRINTTALK, "Link successful!" ) + else + owner:PrintMessage( HUD_PRINTTALK, "Link failed!" ) + end end self.gyro = nil self:SetStage( 0 ) @@ -100,12 +102,12 @@ end --Set the gyropods model, also clear the selected ent function TOOL:Reload( trace ) - if ( self:GetStage()== 0 ) and trace.Entity:GetClass() == ClassName then self.gyro = nil end - if ( self:GetStage()== 0 ) then + if ( self:GetStage() == 0 ) and trace.Entity:GetClass() == ClassName then self.gyro = nil end + if ( self:GetStage() == 0 ) then if CLIENT and trace.Entity:IsValid() then return true end if not trace.Entity:IsValid() then return false end local model = trace.Entity:GetModel() - self:GetOwner():ConCommand(ClassName .. "_model " .. model); + self:GetOwner():ConCommand(ClassName .. "_model " .. model) self.Model = model end self:SetStage(0) @@ -159,13 +161,12 @@ Duck = Accelerate Downward * DataSchmuck for improving the code. * LoRAWN for improving the code even more. - ]] + ]] BindLabel0.Description = "Basic Instructions1" panel:AddControl("Label", BindLabel0 ) BindLabel1.Description = "Basic Instructions2" panel:AddControl("Label", BindLabel1 ) BindLabel2.Description = "Basic Instructions3" panel:AddControl("Label", BindLabel2 ) - end diff --git a/models/cerus/mcorvette/bridge1.dx80.vtx b/models/cerus/mcorvette/bridge1.dx80.vtx index f7d8f0c2..373aa6df 100644 Binary files a/models/cerus/mcorvette/bridge1.dx80.vtx and b/models/cerus/mcorvette/bridge1.dx80.vtx differ diff --git a/models/cerus/mcorvette/bridge1.dx90.vtx b/models/cerus/mcorvette/bridge1.dx90.vtx index 00aa37b5..545769ab 100644 Binary files a/models/cerus/mcorvette/bridge1.dx90.vtx and b/models/cerus/mcorvette/bridge1.dx90.vtx differ diff --git a/models/cerus/mcorvette/bridge1.mdl b/models/cerus/mcorvette/bridge1.mdl index ca86184b..db408573 100644 Binary files a/models/cerus/mcorvette/bridge1.mdl and b/models/cerus/mcorvette/bridge1.mdl differ diff --git a/models/cerus/mcorvette/bridge1.phy b/models/cerus/mcorvette/bridge1.phy index 0882c52f..bffec907 100644 Binary files a/models/cerus/mcorvette/bridge1.phy and b/models/cerus/mcorvette/bridge1.phy differ diff --git a/models/cerus/mcorvette/bridge1.sw.vtx b/models/cerus/mcorvette/bridge1.sw.vtx index 22bceed9..5fb637f5 100644 Binary files a/models/cerus/mcorvette/bridge1.sw.vtx and b/models/cerus/mcorvette/bridge1.sw.vtx differ diff --git a/models/cerus/mcorvette/bridge1.vvd b/models/cerus/mcorvette/bridge1.vvd index 662a003c..a329b27b 100644 Binary files a/models/cerus/mcorvette/bridge1.vvd and b/models/cerus/mcorvette/bridge1.vvd differ diff --git a/models/spacebuild/nova/blimp.dx80.vtx b/models/spacebuild/nova/blimp.dx80.vtx index a1f135fb..e5ce7236 100644 Binary files a/models/spacebuild/nova/blimp.dx80.vtx and b/models/spacebuild/nova/blimp.dx80.vtx differ diff --git a/models/spacebuild/nova/blimp.dx90.vtx b/models/spacebuild/nova/blimp.dx90.vtx index fd16442d..37fdaefb 100644 Binary files a/models/spacebuild/nova/blimp.dx90.vtx and b/models/spacebuild/nova/blimp.dx90.vtx differ diff --git a/models/spacebuild/nova/blimp.mdl b/models/spacebuild/nova/blimp.mdl index 54056382..a9d60ab5 100644 Binary files a/models/spacebuild/nova/blimp.mdl and b/models/spacebuild/nova/blimp.mdl differ diff --git a/models/spacebuild/nova/blimp.phy b/models/spacebuild/nova/blimp.phy index e16d7530..8e777ea3 100644 Binary files a/models/spacebuild/nova/blimp.phy and b/models/spacebuild/nova/blimp.phy differ diff --git a/models/spacebuild/nova/blimp.sw.vtx b/models/spacebuild/nova/blimp.sw.vtx index 316e0622..cb3d3c02 100644 Binary files a/models/spacebuild/nova/blimp.sw.vtx and b/models/spacebuild/nova/blimp.sw.vtx differ diff --git a/models/spacebuild/nova/blimp.vvd b/models/spacebuild/nova/blimp.vvd index cf838536..9ad359d7 100644 Binary files a/models/spacebuild/nova/blimp.vvd and b/models/spacebuild/nova/blimp.vvd differ diff --git a/models/spacebuild/nova/braudside1.dx80.vtx b/models/spacebuild/nova/braudside1.dx80.vtx index a31c0c74..5f0af291 100644 Binary files a/models/spacebuild/nova/braudside1.dx80.vtx and b/models/spacebuild/nova/braudside1.dx80.vtx differ diff --git a/models/spacebuild/nova/braudside1.dx90.vtx b/models/spacebuild/nova/braudside1.dx90.vtx index d2a1ad12..e9581e2d 100644 Binary files a/models/spacebuild/nova/braudside1.dx90.vtx and b/models/spacebuild/nova/braudside1.dx90.vtx differ diff --git a/models/spacebuild/nova/braudside1.mdl b/models/spacebuild/nova/braudside1.mdl index 0c029ad2..7ff00d11 100644 Binary files a/models/spacebuild/nova/braudside1.mdl and b/models/spacebuild/nova/braudside1.mdl differ diff --git a/models/spacebuild/nova/braudside1.phy b/models/spacebuild/nova/braudside1.phy index c0baa392..71d3f9bf 100644 Binary files a/models/spacebuild/nova/braudside1.phy and b/models/spacebuild/nova/braudside1.phy differ diff --git a/models/spacebuild/nova/braudside1.sw.vtx b/models/spacebuild/nova/braudside1.sw.vtx index 9f3ce2b1..0fe06ba3 100644 Binary files a/models/spacebuild/nova/braudside1.sw.vtx and b/models/spacebuild/nova/braudside1.sw.vtx differ diff --git a/models/spacebuild/nova/braudside1.vvd b/models/spacebuild/nova/braudside1.vvd index bd5f202e..61abb4fd 100644 Binary files a/models/spacebuild/nova/braudside1.vvd and b/models/spacebuild/nova/braudside1.vvd differ diff --git a/models/spacebuild/nova/crewquarters.dx80.vtx b/models/spacebuild/nova/crewquarters.dx80.vtx index 73034260..b92c5c2e 100644 Binary files a/models/spacebuild/nova/crewquarters.dx80.vtx and b/models/spacebuild/nova/crewquarters.dx80.vtx differ diff --git a/models/spacebuild/nova/crewquarters.dx90.vtx b/models/spacebuild/nova/crewquarters.dx90.vtx index 0f4503e5..763b870b 100644 Binary files a/models/spacebuild/nova/crewquarters.dx90.vtx and b/models/spacebuild/nova/crewquarters.dx90.vtx differ diff --git a/models/spacebuild/nova/crewquarters.mdl b/models/spacebuild/nova/crewquarters.mdl index 58e03cd4..c6462dde 100644 Binary files a/models/spacebuild/nova/crewquarters.mdl and b/models/spacebuild/nova/crewquarters.mdl differ diff --git a/models/spacebuild/nova/crewquarters.phy b/models/spacebuild/nova/crewquarters.phy index e34b1f23..90e1caf8 100644 Binary files a/models/spacebuild/nova/crewquarters.phy and b/models/spacebuild/nova/crewquarters.phy differ diff --git a/models/spacebuild/nova/crewquarters.sw.vtx b/models/spacebuild/nova/crewquarters.sw.vtx index 34e8fa18..f369c59d 100644 Binary files a/models/spacebuild/nova/crewquarters.sw.vtx and b/models/spacebuild/nova/crewquarters.sw.vtx differ diff --git a/models/spacebuild/nova/crewquarters.vvd b/models/spacebuild/nova/crewquarters.vvd index 86c99fcb..5f3005fa 100644 Binary files a/models/spacebuild/nova/crewquarters.vvd and b/models/spacebuild/nova/crewquarters.vvd differ diff --git a/models/spacebuild/nova/hull_lift_doublelift.dx80.vtx b/models/spacebuild/nova/hull_lift_doublelift.dx80.vtx index 57b89943..9024fccf 100644 Binary files a/models/spacebuild/nova/hull_lift_doublelift.dx80.vtx and b/models/spacebuild/nova/hull_lift_doublelift.dx80.vtx differ diff --git a/models/spacebuild/nova/hull_lift_doublelift.dx90.vtx b/models/spacebuild/nova/hull_lift_doublelift.dx90.vtx index e6cd2271..5fbf82cd 100644 Binary files a/models/spacebuild/nova/hull_lift_doublelift.dx90.vtx and b/models/spacebuild/nova/hull_lift_doublelift.dx90.vtx differ diff --git a/models/spacebuild/nova/hull_lift_doublelift.mdl b/models/spacebuild/nova/hull_lift_doublelift.mdl index cc7d2c15..3d6a7179 100644 Binary files a/models/spacebuild/nova/hull_lift_doublelift.mdl and b/models/spacebuild/nova/hull_lift_doublelift.mdl differ diff --git a/models/spacebuild/nova/hull_lift_doublelift.phy b/models/spacebuild/nova/hull_lift_doublelift.phy index 2c0b130c..94d84a39 100644 Binary files a/models/spacebuild/nova/hull_lift_doublelift.phy and b/models/spacebuild/nova/hull_lift_doublelift.phy differ diff --git a/models/spacebuild/nova/hull_lift_doublelift.sw.vtx b/models/spacebuild/nova/hull_lift_doublelift.sw.vtx index 52a26863..ecf60ef6 100644 Binary files a/models/spacebuild/nova/hull_lift_doublelift.sw.vtx and b/models/spacebuild/nova/hull_lift_doublelift.sw.vtx differ diff --git a/models/spacebuild/nova/hull_lift_doublelift.vvd b/models/spacebuild/nova/hull_lift_doublelift.vvd index 425b345c..c03fc642 100644 Binary files a/models/spacebuild/nova/hull_lift_doublelift.vvd and b/models/spacebuild/nova/hull_lift_doublelift.vvd differ diff --git a/models/spacebuild/nova/macbig.dx80.vtx b/models/spacebuild/nova/macbig.dx80.vtx index 93e7e817..7932ce00 100644 Binary files a/models/spacebuild/nova/macbig.dx80.vtx and b/models/spacebuild/nova/macbig.dx80.vtx differ diff --git a/models/spacebuild/nova/macbig.dx90.vtx b/models/spacebuild/nova/macbig.dx90.vtx index a8629fcd..1158c9ac 100644 Binary files a/models/spacebuild/nova/macbig.dx90.vtx and b/models/spacebuild/nova/macbig.dx90.vtx differ diff --git a/models/spacebuild/nova/macbig.mdl b/models/spacebuild/nova/macbig.mdl index 22c7963d..7c231c71 100644 Binary files a/models/spacebuild/nova/macbig.mdl and b/models/spacebuild/nova/macbig.mdl differ diff --git a/models/spacebuild/nova/macbig.phy b/models/spacebuild/nova/macbig.phy index e1de06dc..0585daec 100644 Binary files a/models/spacebuild/nova/macbig.phy and b/models/spacebuild/nova/macbig.phy differ diff --git a/models/spacebuild/nova/macbig.sw.vtx b/models/spacebuild/nova/macbig.sw.vtx index a21ebb04..2bcf9532 100644 Binary files a/models/spacebuild/nova/macbig.sw.vtx and b/models/spacebuild/nova/macbig.sw.vtx differ diff --git a/models/spacebuild/nova/macbig.vvd b/models/spacebuild/nova/macbig.vvd index 2cc1c4bd..6ebaf1ca 100644 Binary files a/models/spacebuild/nova/macbig.vvd and b/models/spacebuild/nova/macbig.vvd differ diff --git a/models/spacebuild/nova/machuge.dx80.vtx b/models/spacebuild/nova/machuge.dx80.vtx index fa99c225..827b4972 100644 Binary files a/models/spacebuild/nova/machuge.dx80.vtx and b/models/spacebuild/nova/machuge.dx80.vtx differ diff --git a/models/spacebuild/nova/machuge.dx90.vtx b/models/spacebuild/nova/machuge.dx90.vtx index 25b01a78..a9f194ee 100644 Binary files a/models/spacebuild/nova/machuge.dx90.vtx and b/models/spacebuild/nova/machuge.dx90.vtx differ diff --git a/models/spacebuild/nova/machuge.mdl b/models/spacebuild/nova/machuge.mdl index cd9d5a90..d94dc6d7 100644 Binary files a/models/spacebuild/nova/machuge.mdl and b/models/spacebuild/nova/machuge.mdl differ diff --git a/models/spacebuild/nova/machuge.phy b/models/spacebuild/nova/machuge.phy index c86e4e5d..7b6090ec 100644 Binary files a/models/spacebuild/nova/machuge.phy and b/models/spacebuild/nova/machuge.phy differ diff --git a/models/spacebuild/nova/machuge.sw.vtx b/models/spacebuild/nova/machuge.sw.vtx index 811421ac..55f45f11 100644 Binary files a/models/spacebuild/nova/machuge.sw.vtx and b/models/spacebuild/nova/machuge.sw.vtx differ diff --git a/models/spacebuild/nova/machuge.vvd b/models/spacebuild/nova/machuge.vvd index 1d63bf79..108d47b9 100644 Binary files a/models/spacebuild/nova/machuge.vvd and b/models/spacebuild/nova/machuge.vvd differ diff --git a/models/spacebuild/nova/med-mac2.dx80.vtx b/models/spacebuild/nova/med-mac2.dx80.vtx index f0943ec2..fb6f5629 100644 Binary files a/models/spacebuild/nova/med-mac2.dx80.vtx and b/models/spacebuild/nova/med-mac2.dx80.vtx differ diff --git a/models/spacebuild/nova/med-mac2.dx90.vtx b/models/spacebuild/nova/med-mac2.dx90.vtx index e6a2e42d..05e12051 100644 Binary files a/models/spacebuild/nova/med-mac2.dx90.vtx and b/models/spacebuild/nova/med-mac2.dx90.vtx differ diff --git a/models/spacebuild/nova/med-mac2.mdl b/models/spacebuild/nova/med-mac2.mdl index d2a084b9..0e492a9d 100644 Binary files a/models/spacebuild/nova/med-mac2.mdl and b/models/spacebuild/nova/med-mac2.mdl differ diff --git a/models/spacebuild/nova/med-mac2.phy b/models/spacebuild/nova/med-mac2.phy index f826ec71..a14d27fe 100644 Binary files a/models/spacebuild/nova/med-mac2.phy and b/models/spacebuild/nova/med-mac2.phy differ diff --git a/models/spacebuild/nova/med-mac2.sw.vtx b/models/spacebuild/nova/med-mac2.sw.vtx index e8e8ebf0..7f83fc44 100644 Binary files a/models/spacebuild/nova/med-mac2.sw.vtx and b/models/spacebuild/nova/med-mac2.sw.vtx differ diff --git a/models/spacebuild/nova/med-mac2.vvd b/models/spacebuild/nova/med-mac2.vvd index d1a306e3..4c223b8f 100644 Binary files a/models/spacebuild/nova/med-mac2.vvd and b/models/spacebuild/nova/med-mac2.vvd differ diff --git a/models/spacebuild/nova/med-mac2_1.dx80.vtx b/models/spacebuild/nova/med-mac2_1.dx80.vtx index 9d19fd82..ece0c168 100644 Binary files a/models/spacebuild/nova/med-mac2_1.dx80.vtx and b/models/spacebuild/nova/med-mac2_1.dx80.vtx differ diff --git a/models/spacebuild/nova/med-mac2_1.dx90.vtx b/models/spacebuild/nova/med-mac2_1.dx90.vtx index ede4b02d..34cae541 100644 Binary files a/models/spacebuild/nova/med-mac2_1.dx90.vtx and b/models/spacebuild/nova/med-mac2_1.dx90.vtx differ diff --git a/models/spacebuild/nova/med-mac2_1.mdl b/models/spacebuild/nova/med-mac2_1.mdl index 9e1e6b46..db1f7c0d 100644 Binary files a/models/spacebuild/nova/med-mac2_1.mdl and b/models/spacebuild/nova/med-mac2_1.mdl differ diff --git a/models/spacebuild/nova/med-mac2_1.phy b/models/spacebuild/nova/med-mac2_1.phy index c67b92cb..a429c55a 100644 Binary files a/models/spacebuild/nova/med-mac2_1.phy and b/models/spacebuild/nova/med-mac2_1.phy differ diff --git a/models/spacebuild/nova/med-mac2_1.sw.vtx b/models/spacebuild/nova/med-mac2_1.sw.vtx index 667105db..0bc32b9b 100644 Binary files a/models/spacebuild/nova/med-mac2_1.sw.vtx and b/models/spacebuild/nova/med-mac2_1.sw.vtx differ diff --git a/models/spacebuild/nova/med-mac2_1.vvd b/models/spacebuild/nova/med-mac2_1.vvd index afd620d4..3d3e30a9 100644 Binary files a/models/spacebuild/nova/med-mac2_1.vvd and b/models/spacebuild/nova/med-mac2_1.vvd differ diff --git a/models/spacebuild/nova/pulsecannon2.dx80.vtx b/models/spacebuild/nova/pulsecannon2.dx80.vtx index 43fe33e3..14fc0da5 100644 Binary files a/models/spacebuild/nova/pulsecannon2.dx80.vtx and b/models/spacebuild/nova/pulsecannon2.dx80.vtx differ diff --git a/models/spacebuild/nova/pulsecannon2.dx90.vtx b/models/spacebuild/nova/pulsecannon2.dx90.vtx index d61b2751..cc7dabea 100644 Binary files a/models/spacebuild/nova/pulsecannon2.dx90.vtx and b/models/spacebuild/nova/pulsecannon2.dx90.vtx differ diff --git a/models/spacebuild/nova/pulsecannon2.mdl b/models/spacebuild/nova/pulsecannon2.mdl index d1eee86b..78128db5 100644 Binary files a/models/spacebuild/nova/pulsecannon2.mdl and b/models/spacebuild/nova/pulsecannon2.mdl differ diff --git a/models/spacebuild/nova/pulsecannon2.phy b/models/spacebuild/nova/pulsecannon2.phy index 5e653713..12f2a758 100644 Binary files a/models/spacebuild/nova/pulsecannon2.phy and b/models/spacebuild/nova/pulsecannon2.phy differ diff --git a/models/spacebuild/nova/pulsecannon2.sw.vtx b/models/spacebuild/nova/pulsecannon2.sw.vtx index a28f857c..7df805df 100644 Binary files a/models/spacebuild/nova/pulsecannon2.sw.vtx and b/models/spacebuild/nova/pulsecannon2.sw.vtx differ diff --git a/models/spacebuild/nova/pulsecannon2.vvd b/models/spacebuild/nova/pulsecannon2.vvd index 93232861..d88b8030 100644 Binary files a/models/spacebuild/nova/pulsecannon2.vvd and b/models/spacebuild/nova/pulsecannon2.vvd differ diff --git a/sbep.jpg b/sbep.jpg new file mode 100644 index 00000000..4c0bcd89 Binary files /dev/null and b/sbep.jpg differ