Skip to content

Commit

Permalink
faster load, fixed setsimrad, luau table optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
KadeTheExploiter authored Jul 27, 2024
1 parent 06d19a2 commit 3f582b9
Showing 1 changed file with 56 additions and 44 deletions.
100 changes: 56 additions & 44 deletions Module.luau
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
-- // Defining Variables: Settings

local Configuration = Configuration or {}
local ReturnOnDeath = Configuration.ReturnOnDeath or false

local RigName = Configuration.RigName or "Evolution, it must've passed you by."

local WaitTime = Configuration.WaitTime or 0.2
local TeleportOffsetRadius = Configuration.TeleportOffsetRadius or 12

local Flinging = Configuration.Flinging or false
local Animations = Configuration.Animations or true
local WaitTime = Configuration.WaitTime or 0.178
local RigName = Configuration.RigName or "Evolution, it must've passed you by."
local NoCollisions = Configuration.NoCollisions or Flinging or false
local AntiVoiding = Configuration.AntiVoiding or false
local SetSimulationRadius = Configuration.SetSimulationRadius or true
local DisableCharacterScripts = Configuration.DisableCharacterScripts or true
local TeleportOffsetRadius = Configuration.TeleportOffsetRadius or 22
local ReturnOnDeath = Configuration.ReturnOnDeath or false
local ForceMobileMode = Configuration.ForceMobileMode or false
local ForceDesktopMode = Configuration.ForceDesktopMode or false
local NoCollisions = Configuration.NoCollisions or Flinging or false
local SetSimulationRadius = Configuration.SetSimulationRadius or true
local DisableCharacterScripts = Configuration.DisableCharacterScripts or true

local Hats = Configuration.Hats or {
["Right Arm"] = {
{Texture = "14255544465", Mesh = "14255522247", Name = "RARM", Offset = CFrame.Angles(0, 0, math.rad(90))}
Expand Down Expand Up @@ -93,16 +97,18 @@ local TeleportOffset = Vector3.zero

local MouseDown = nil
local SpaceDown = nil
local SafeToLoad = nil
local AnimationHandlingFunction = nil

local RecoverTime = WaitTime / 1.75

local RespawnEvent = Instance.new("BindableEvent")

local RBXSignals = {}
local HatsInUse = {}
local KeyInputs = {[Enum.KeyCode.W] = {false, 0, -1}, [Enum.KeyCode.A] = {false, -1, 0}, [Enum.KeyCode.S] = {false, 0, 1}, [Enum.KeyCode.D] = {false, 1, 0}}
local RBXSignals = table.create(15, nil)
local HatsInUse = table.create(15, nil)
local KeyInputs = table.create(4, nil) -- optimized

KeyInputs[Enum.KeyCode.W] = {false, 0, -1}
KeyInputs[Enum.KeyCode.A] = {false, -1, 0}
KeyInputs[Enum.KeyCode.S] = {false, 0, 1}
KeyInputs[Enum.KeyCode.D] = {false, 1, 0}

local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
Expand Down Expand Up @@ -460,6 +466,7 @@ do -- [[ Scoped Rig Creating. ]]
end

-- // RunTime: Functions

local function IsNetworkOwner(Part) -- <BasePart> : Boolean
return Part and Part.ReceiveAge == 0
end
Expand Down Expand Up @@ -578,12 +585,14 @@ local function ArePlayersNearby() -- : Boolean
local Model = Part.Parent

if BetterIsA(Model, "Model") then
if Model ~= FakeRig or Model ~= Character then
return Model.PrimaryPart ~= nil
if BetterFindFirstChildOfClass(Model, "Humanoid") then
if not (Model == Character and Model == FakeRig) then
return Model.PrimaryPart ~= nil
end
end
end
end

return true
end

Expand All @@ -592,6 +601,7 @@ end
local function SetCameraTarget() -- Function | SIGNAL: Camera:GetPropertySignalChanged("CameraSubject")
PreviousCameraCFrame = Camera.CFrame
Camera.CameraSubject = FakeHumanoid

RunService.PreRender:Wait()
Camera.CFrame = PreviousCameraCFrame
end
Expand Down Expand Up @@ -642,31 +652,29 @@ end

local function OnPostSimulation() -- SIGNAL: RunService.PostSimulation
StarterGui:SetCore("ResetButtonCallback", RespawnEvent)
local Multiply = SafeToLoad and 4 or 2
local ReverseSleep = Vector3.new(0.0075 * math.sin(os.clock() * 7), 0, 0.0085 * math.cos(os.clock() * 16))
local SafeYAxis = 35 - 3 * math.sin(os.clock() * 10)

if CanCallSimRadius then
Player.SimulationRadius = 1000
end

for Handle, Data in HatsInUse do
local OtherLimb = Data[1]

if OtherLimb and IsNetworkOwner(Handle) then
local Part1Offset = Data[2]
local Part1Magnitude = OtherLimb.Size.Magnitude
local Part1Velocity = OtherLimb.AssemblyLinearVelocity * Part1Magnitude
local CalculatedVel = Part1Velocity * Multiply

local ClampedAxisY = math.clamp(Part1Velocity.Y, SafeYAxis, 1024)
local Velocity = Vector3.new(CalculatedVel.X, ClampedAxisY, CalculatedVel.Z)

local CFrameOffset = OtherLimb.CFrame * Part1Offset

Handle.AssemblyLinearVelocity = Velocity
Handle.AssemblyAngularVelocity = OtherLimb.AssemblyAngularVelocity
Handle.CFrame = SafeToLoad and Handle.CFrame:Lerp(CFrameOffset + ReverseSleep, 1) or RootPart.CFrame
if OtherLimb then
if IsNetworkOwner(Handle) then
local Part1Offset = Data[2]

local Part1Magnitude = OtherLimb.Size.Magnitude
local Part1Velocity = OtherLimb.AssemblyLinearVelocity * Part1Magnitude
local CalculatedVel = Part1Velocity * 2.5

local ClampedAxisY = math.clamp(Part1Velocity.Y, SafeYAxis, 1024)
local Velocity = Vector3.new(CalculatedVel.X, ClampedAxisY, CalculatedVel.Z)

local CFrameOffset = OtherLimb.CFrame * Part1Offset

Handle.AssemblyLinearVelocity = Velocity
Handle.AssemblyAngularVelocity = OtherLimb.AssemblyAngularVelocity
Handle.CFrame = Handle.CFrame:Lerp(CFrameOffset + ReverseSleep, 1)
end
end
end
end
Expand All @@ -682,6 +690,10 @@ local function OnPreSimulation() -- SIGNAL: RunService.PreSimulation
end
end

if CanCallSimRadius then
Player.SimulationRadius = 1000
end

if AntiVoiding then
if FakeRoot.Position.Y < FallenPartsDestroyHeight then
FakeRoot.CFrame = CFrameBackup
Expand Down Expand Up @@ -717,7 +729,6 @@ local function OnCharacterAdded() -- SIGNAL : Player.CharacterAdded
table.clear(HatsInUse)
SetCameraTarget()

SafeToLoad = false
Character = Player.Character

if Character and LastCharacter ~= Character then
Expand All @@ -728,7 +739,7 @@ local function OnCharacterAdded() -- SIGNAL : Player.CharacterAdded

if Humanoid and RootPart then
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
Humanoid:ChangeState(7)
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

if DisableCharacterScripts then
for _, Instance in Character:GetDescendants() do
Expand Down Expand Up @@ -761,11 +772,9 @@ local function OnCharacterAdded() -- SIGNAL : Player.CharacterAdded

SetUpHatConfig()
FakeRigChildren = FakeRig:GetChildren()
Humanoid:ChangeState(Enum.HumanoidStateType.Dead)

task.wait(RecoverTime)

SafeToLoad = true
RunService.PostSimulation:Wait()
Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
end
end
end
Expand Down Expand Up @@ -798,6 +807,7 @@ end
if IsMobile then -- Mobile Support (I know this is badly written but dont attack me please )
local StartPosition = nil
local IsActive = nil

local MovementVector = Vector3.zero

local function OnTouchBegan(Input)
Expand Down Expand Up @@ -837,7 +847,6 @@ if IsMobile then -- Mobile Support (I know this is badly written but dont attack
end)
end


-- // Finalizing: Connecting Events

SetCameraTarget()
Expand All @@ -848,7 +857,11 @@ Humanoid:ChangeState(Enum.HumanoidStateType.Dead)

RBXSignals[2] = Player.CharacterAdded:Connect(OnCharacterAdded)
RBXSignals[3] = RunService.PostSimulation:Connect(OnPostSimulation)
RBXSignals[4] = RunService.PreAnimation:Connect(OnPreSimulation)

if IsKeyboard or SetSimulationRadius or NoCollisions or AntiVoiding then
RBXSignals[4] = RunService.PreAnimation:Connect(OnPreSimulation)
end

RBXSignals[5] = Camera:GetPropertyChangedSignal("CameraSubject"):Connect(SetCameraTarget)
RBXSignals[6] = Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(UponCameraChange)
RBXSignals[7] = FakeRoot:GetPropertyChangedSignal("Parent"):Connect(UponParentChange)
Expand All @@ -860,4 +873,3 @@ RBXSignals[11] = UserInputService.InputEnded:Connect(function(Input, GameProcess
task.wait(WaitTime)

FakeRigChildren = FakeRig:GetChildren()
SafeToLoad = true

0 comments on commit 3f582b9

Please sign in to comment.