Run it
Copy the script and paste it into your executor.
Players = :()
Lighting = :()
RunService = :()
Stats = :()
Workspace = :()
CollectionService = :()
LocalPlayer = Players.LocalPlayer
Config = {
Name = , Version = ,
TargetFPS = , RecoveryFPS = , RecoverySeconds = ,
ParticleFlipbookFramerateCap = , ParticleSizeScale = ,
TrailMinLengthFloor = , TrailWidthScale = , BeamWidthScale = ,
SurfaceGuiPixelsPerStudCap = , SurfaceGuiMaxDistanceExtreme = ,
BillboardGuiMaxDistanceExtreme = , BillboardDistanceStep = ,
Tier1P95 = , Tier2FPS = , Tier2P95 = ,
Tier3FPS = , Tier3P95 = , Tier4FPS = , Tier4P95 = ,
TierChangeCooldown = , AdaptiveInterval = , MetricsInterval = ,
GuardInterval = , DistanceInterval = , DistanceSlowInterval = ,
BatchSize = , PanicBatchSize = , BatchBudgetSeconds = ,
BatchYield = , MaxQueueEntries = , MaxLogEntries = ,
MaxMetricSamples = , MaxFPSHistory = , MaxDistancePerPass = ,
SafeDecorDistance = , SafeDebrisDistance = , EffectDistance = ,
LightDistance = , AvatarDistance = , DistanceHysteresis = ,
SafeDecorAttribute = , SafeDebrisAttribute = ,
SafeDecorTag = , SafeDebrisTag = ,
SafeDebrisMaxMagnitude = , ParticleRateCap = , ParticleRateScale = ,
ParticleDensityScale = , ParticleLifetimeScale = , TrailLifetimeCap = ,
BeamSegmentsCap = , LightRangeCap = , LightBrightnessCap = ,
BillboardMaxDistance = , SurfaceGuiMaxDistance = ,
CacheMarkerSeconds = , CacheToolSeconds = , CachePlayerSeconds = ,
CacheMaintenanceInterval = ,
BenchmarkSeconds = , StartAutomatic = , StartAdaptive = ,
}
OptionDefinitions, Options = {}, {}
(key, name, category, description, defaultValue, risk, autoTier, supported, reason)
definition = {
Key = key, Name = name, Category = category, Description = description,
DefaultValue = defaultValue == , CurrentValue = defaultValue == ,
RiskLevel = risk , RequiresRestart = ,
ApplyHandler = , RestoreHandler = , Supported = supported ~= ,
UnsupportedReason = reason, AutoTier = autoTier, LastApplied = ,
}
.(OptionDefinitions, definition)
Options[key] = definition.DefaultValue
(, , , , )
(, , , , )
(, , , , )
(, , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , )
(, , , , , )
(, , , , , , )
(, , , , , )
(, , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , )
(, , , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
(, , , , , , )
QueueEngine, DistanceEngine, BackgroundMonitor, MemoryCleaner
MetricsMonitor, AdaptiveController, Benchmark, ProfileManager
BoosterController
State = {
Running = , Enabled = , OneClickActive = , Automatic = Config.StartAutomatic,
Adaptive = Config.StartAdaptive, Panic = , Tier = ,
TierReason = , Profile = , StartedAt = ,
LastTierChange = , RecoveryStartedAt = , LastGuardRun = ,
LastDistanceRun = , LastScanSeconds = , ProcessedInstances = , InitialScanDone = , InitialScanStarted = , ScanGeneration = ,
AppliedProperties = , RestoredProperties = , FailedProperties = ,
ExternalChangesPreserved = , QueueDropped = , QueueGeneration = ,
QueueWorker = , QueueHigh = {}, QueueNormal = {},
QueueHighHead = , QueueNormalHead = ,
Pending = ({}, { __mode = }),
SeenInstances = ({}, { __mode = }),
Original = ({}, { __mode = }),
DistanceCulled = ({}, { __mode = }),
DistanceCursor = , Connections = {},
PlayerConnections = ({}, { __mode = }),
Log = {}, LastLogSignature = , LastLogTime = , LastLogRepeat = ,
FrameTimes = {}, FrameTimeHead = , FrameTimeCount = ,
FPSHistory = {}, Samples = {}, FPS = , AverageFPS = ,
MinimumFPS = , MaximumFPS = , FrameTime = , SuddenDropCount = , LastSuddenDropTime = ,
AverageFrameTime = , P95FrameTime = , OnePercentLow = , SessionMinFrameTime = .huge, SessionMaxFrameTime = ,
Ping = , MemoryMB = , CurrentSampleCount = ,
CacheStats = { IsAHit = , IsAMiss = , MarkerHit = , MarkerMiss = ,
ToolHit = , ToolMiss = , PlayerHit = , PlayerMiss = , SequenceHit = , SequenceMiss = },
LastCacheMaintenance = ,
Benchmark = { Active = , Kind = , StartedAt = ,
Duration = Config.BenchmarkSeconds, FrameTimes = {}, Baseline = ,
Optimized = , LastComparison = },
Profiles = {}, ShutdownStarted = , BootstrapStarted = ,
}
Logger = {}
Logger.(level, category, message, instance, propertyName, result)
now = .()
fullName =
instance (instance) ==
(() fullName = instance:() )
signature = .({ (level), (category), (message),
fullName, (propertyName), (result) }, )
signature == State.LastLogSignature now - State.LastLogTime <
State.LastLogRepeat = State.LastLogRepeat +
last = State.Log[#State.Log]
last last.Repeats = State.LastLogRepeat
State.LastLogSignature, State.LastLogTime, State.LastLogRepeat = signature, now,
.(State.Log, {
Time = now, Clock = .(), Level = (level),
Category = (category), Message = (message), = fullName,
Property = propertyName (propertyName) ,
Result = result (result) , Repeats = ,
})
#State.Log > Config.MaxLogEntries .(State.Log, )
Logger.(message, category) Logger.(, category , message)
Logger.(message, category, instance, propertyName) Logger.(, category , message, instance, propertyName)
Logger.(message, category, instance, propertyName, result) Logger.(, category , message, instance, propertyName, result)
Logger.(message, instance, propertyName) Logger.(, , message, instance, propertyName, )
Logger.(message, instance, propertyName, result) Logger.(, , message, instance, propertyName, result )
Logger.() .(State.Log); State.LastLogSignature = ; State.LastLogRepeat =
Safe = {}
IsACache = ({}, { __mode = })
MarkerCache = ({}, { __mode = })
ToolAncestorCache = ({}, { __mode = })
PlayerAncestorCache = ({}, { __mode = })
AccessoryTypeCache = ({}, { __mode = })
Safe.(instance, className)
(instance) ~=
perInstance = IsACache[instance]
perInstance
cached = perInstance[className]
cached ~=
State.CacheStats.IsAHit = State.CacheStats.IsAHit +
cached
perInstance = {}
IsACache[instance] = perInstance
State.CacheStats.IsAMiss = State.CacheStats.IsAMiss +
ok, result = (() instance:(className) )
answer = ok result ==
perInstance[className] = answer
answer
Safe.(instance, propertyName)
(instance) ~= ,
ok, value = (() instance[propertyName] )
ok, value
Safe.(instance)
(instance) ~=
ok, parent = (() instance.Parent )
ok parent ~=
Safe.(instance, attributeName)
ok, value = (() instance:(attributeName) )
ok value ==
Safe.(instance, tagName)
ok, value = (() CollectionService:(instance, tagName) )
ok value ==
Safe.(instance, attributeName, tagName)
(instance) ~=
now = .()
key = (attributeName) .. .. (tagName)
byKey = MarkerCache[instance]
byKey
entry = byKey[key]
entry entry.Expires > now
State.CacheStats.MarkerHit = State.CacheStats.MarkerHit +
entry.Value
byKey = {}
MarkerCache[instance] = byKey
State.CacheStats.MarkerMiss = State.CacheStats.MarkerMiss +
cursor, depth, found = instance, ,
cursor cursor ~= depth <
Safe.(cursor, attributeName) Safe.(cursor, tagName)
found =
cursor, depth = cursor.Parent, depth +
byKey[key] = { Value = found, Expires = now + Config.CacheMarkerSeconds }
found
Safe.(instance)
(instance) ~=
now = .()
cached = ToolAncestorCache[instance]
cached cached.Expires > now
State.CacheStats.ToolHit = State.CacheStats.ToolHit +
cached.Value
State.CacheStats.ToolMiss = State.CacheStats.ToolMiss +
cursor, depth, found = instance, ,
cursor cursor ~= Workspace depth <
Safe.(cursor, ) found = ;
cursor, depth = cursor.Parent, depth +
ToolAncestorCache[instance] = { Value = found, Expires = now + Config.CacheToolSeconds }
found
Safe.(instance)
(instance) ~=
now = .()
cached = PlayerAncestorCache[instance]
cached cached.Expires > now
State.CacheStats.PlayerHit = State.CacheStats.PlayerHit +
cached.Player
State.CacheStats.PlayerMiss = State.CacheStats.PlayerMiss +
cursor, depth, owner = instance, ,
cursor cursor ~= Workspace depth <
Safe.(cursor, )
ok, player = (() Players:(cursor) )
ok player owner = player;
cursor, depth = cursor.Parent, depth +
PlayerAncestorCache[instance] = { Player = owner, Expires = now + Config.CachePlayerSeconds }
owner
Safe.(instance)
character = LocalPlayer LocalPlayer.Character
character (instance) ==
ok, isDescendant = (()
instance == character instance:(character)
)
ok isDescendant
Safe.(instance) == LocalPlayer
Safe.(instance)
owner = Safe.(instance)
owner ~= owner ~= LocalPlayer
Safe.(part, maximum)
Safe.(part, )
ok, size = Safe.(part, )
ok (size) == size.Magnitude <= (maximum Config.SafeDebrisMaxMagnitude)
Safe.(instance) Safe.(instance, Config.SafeDecorAttribute, Config.SafeDecorTag)
Safe.(instance) Safe.(instance, Config.SafeDebrisAttribute, Config.SafeDebrisTag)
Safe.(accessory)
cached = AccessoryTypeCache[accessory]
cached ~= cached
ok, kind = Safe.(accessory, )
ok
name =
(() name = kind.Name )
AccessoryTypeCache[accessory] = name
name
Safe.()
now = .()
now - State.LastCacheMaintenance < Config.CacheMaintenanceInterval
State.LastCacheMaintenance = now
.(MarkerCache)
.(ToolAncestorCache)
.(PlayerAncestorCache)
Safe.(accessory)
ok, handle = (() accessory:() )
ok handle Safe.(handle, ) handle
Safe.(instance)
Safe.(instance, ) Safe.(instance, )
Safe.(instance, ) Safe.(instance, )
Safe.(instance, )
Safe.(instance)
Safe.(instance, ) Safe.(instance, ) Safe.(instance, )
Safe.(instance)
Safe.(instance, ) Safe.(instance, )
Safe.(instance, )
PropertyStore = {}
PropertyStore.(instance, propertyName)
values = State.Original[instance]
values values[propertyName]
PropertyStore.(instance, propertyName)
entry = PropertyStore.(instance, propertyName)
ok, current = Safe.(instance, propertyName)
ok entry entry.Original
entry entry.Applied ~= current ~= entry.Applied
entry.Original = current
State.ExternalChangesPreserved = State.ExternalChangesPreserved +
entry entry.Original
current
PropertyStore.(instance, propertyName, desired)
Safe.(instance)
ok, current = Safe.(instance, propertyName)
ok
State.FailedProperties = State.FailedProperties +
values = State.Original[instance]
entry = values values[propertyName]
entry entry.Applied ~= current ~= entry.Applied
entry.Original = current
State.ExternalChangesPreserved = State.ExternalChangesPreserved +
current == desired
entry entry.Applied = desired
values values = {}; State.Original[instance] = values
entry
entry = { Original = current, Applied = , Writes = }
values[propertyName] = entry
changed, err = (() instance[propertyName] = desired )
changed
State.FailedProperties = State.FailedProperties +
Logger.(, , instance, propertyName, err)
entry.Applied = desired
entry.Writes = entry.Writes +
entry.ChangedAt = .()
State.AppliedProperties = State.AppliedProperties +
PropertyStore.(instance, propertyName)
values = State.Original[instance]
entry = values values[propertyName]
entry
Safe.(instance)
values[propertyName] =
(values) == State.Original[instance] =
ok, current = Safe.(instance, propertyName)
ok entry.Applied ~= current == entry.Applied
restored, err = (() instance[propertyName] = entry.Original )
restored
State.RestoredProperties = State.RestoredProperties +
Logger.(, instance, propertyName)
State.FailedProperties = State.FailedProperties +
Logger.(, , instance, propertyName, err)
State.ExternalChangesPreserved = State.ExternalChangesPreserved +
Logger.(, instance, propertyName, )
values[propertyName] =
(values) == State.Original[instance] =
PropertyStore.(instance)
values = State.Original[instance]
values
properties = {}
propertyName (values) .(properties, propertyName)
_, propertyName (properties) PropertyStore.(instance, propertyName)
PropertyStore.(instance, desired)
values = State.Original[instance]
values
toRestore = {}
propertyName (values)
desired[propertyName] == .(toRestore, propertyName)
_, propertyName (toRestore) PropertyStore.(instance, propertyName)
propertyName, value (desired) PropertyStore.(instance, propertyName, value)
PropertyStore.()
instances = {}
instance (State.Original) .(instances, instance)
_, instance (instances) PropertyStore.(instance)
Logger.(, )
PropertyStore.()
count =
_, values (State.Original) _ (values) count = count +
count
AdaptivePolicy = {}
OptimizerEngine = {}
(key) AdaptivePolicy.(key)
(desired, propertyName, value)
desired[propertyName] = value
NumberSequenceCache = ({}, { __mode = })
(sequence, factor)
(sequence) ~=
factorKey = .(, factor)
cachedByFactor = NumberSequenceCache[sequence]
cachedByFactor cachedByFactor[factorKey]
State.CacheStats.SequenceHit = State.CacheStats.SequenceHit +
cachedByFactor[factorKey]
State.CacheStats.SequenceMiss = State.CacheStats.SequenceMiss +
keypoints = {}
_, keypoint (sequence.Keypoints)
keypoints[#keypoints + ] = NumberSequenceKeypoint.(
keypoint.Time,
keypoint.Value * factor,
keypoint.Envelope * factor
)
#keypoints <
ok, scaled = (() NumberSequence.(keypoints) )
ok scaled
cachedByFactor
cachedByFactor = {}
NumberSequenceCache[sequence] = cachedByFactor
cachedByFactor[factorKey] = scaled
scaled
(instance)
cursor, depth = instance,
cursor cursor ~= Workspace depth <
Safe.(cursor, ) cursor
cursor, depth = cursor.Parent, depth +
(accessory)
kind = Safe.(accessory)
kind ==
kind ==
kind ==
kind ==
kind ==
kind ==
(instance, optionKey)
Safe.(instance) (optionKey)
(instance)
State.DistanceCulled[instance] ==
OptimizerEngine.(instance)
desired = {}
State.Enabled Safe.(instance) desired
localAvatar = Safe.(instance)
otherAvatar = Safe.(instance)
safeDecor = Safe.(instance)
safeDebris = Safe.(instance)
inTool = Safe.(instance)
distanceCulled = (instance)
Safe.(instance, )
localAvatar
() (desired, , )
() (desired, , .Material.SmoothPlastic)
() (desired, , )
safeDecor ()
(desired, , )
safeDecor () Safe.(instance, )
(desired, , )
safeDecor () (desired, , )
safeDebris () Safe.(instance)
(desired, , )
safeDecor ()
(desired, , .Material.SmoothPlastic)
safeDecor () (desired, , )
safeDecor () (desired, , )
safeDecor ()
(desired, , )
safeDebris (() distanceCulled)
Safe.(instance)
(desired, , )
()
(desired, , )
(desired, , )
safeDebris () Safe.(instance)
(desired, , )
(desired, , )
distanceCulled safeDecor (desired, , )
distanceCulled safeDebris Safe.(instance) (desired, , )
accessory = (instance)
accessory otherAvatar inTool
accessoryOption = (accessory)
accessoryOption (accessoryOption)
(desired, , )
Safe.(instance, )
() (safeDecor ())
(desired, , .RenderFidelity.Performance)
() inTool
(desired, , )
safeDecor ()
(desired, , )
() inTool
(desired, , )
avatarAccessory = (instance)
otherAvatar avatarAccessory () distanceCulled
(desired, , )
desired
Safe.(instance, ) Safe.(instance, )
localAvatar
Safe.(instance, ) () (desired, , )
Safe.(instance, ) () (desired, , )
() inTool
Safe.(instance, ) Safe.(instance, )
(desired, , )
safeDecor Safe.(instance, ) ()
(desired, , )
safeDecor Safe.(instance, ) ()
(desired, , )
otherAvatar (()
(() distanceCulled))
(desired, , )
desired
Safe.(instance, )
localAvatar (()
(safeDecor ())
(otherAvatar () distanceCulled))
(desired, , )
(desired, , )
(desired, , )
(desired, , )
desired
Safe.(instance)
individual =
Safe.(instance, ) individual = ()
Safe.(instance, ) individual = ()
Safe.(instance, ) individual = ()
Safe.(instance, ) individual = ()
Safe.(instance, ) individual = ()
() individual (desired, , )
desired
Safe.(instance, )
() ()
(desired, , )
() ()
(desired, , )
() ()
(desired, , )
desired
Safe.(instance, )
() (desired, , )
desired
Safe.(instance)
localAvatar
() (instance, )
(desired, , )
()
original = PropertyStore.(instance, )
(original) == (desired, , .(original, Config.LightRangeCap))
()
original = PropertyStore.(instance, )
(original) == (desired, , .(original, Config.LightBrightnessCap))
() (desired, , )
safeDecor () (desired, , )
distanceCulled (desired, , )
desired
Safe.(instance, )
avatarOff = (instance, )
localAvatar
() inTool
(desired, , )
() avatarOff
(desired, , )
originalRate = PropertyStore.(instance, )
(originalRate) ==
targetRate = originalRate
()
targetRate = targetRate * Config.ParticleDensityScale
()
targetRate = .(targetRate, Config.ParticleRateCap)
() targetRate =
targetRate ~= originalRate (desired, , targetRate)
()
range = PropertyStore.(instance, )
(range) ==
(desired, , NumberRange.(
.(, range.Min * Config.ParticleLifetimeScale),
.(, range.Max * Config.ParticleLifetimeScale)))
() (desired, , )
() (desired, , )
() (desired, , )
()
flipbookRate = PropertyStore.(instance, )
(flipbookRate) ==
cap = Config.ParticleFlipbookFramerateCap
(desired, , NumberRange.(
.(flipbookRate.Min, cap), .(flipbookRate.Max, cap)))
() (desired, , NumberRange.(, ))
() (desired, , .zero)
() (desired, , )
()
originalSize = PropertyStore.(instance, )
reducedSize = (originalSize, Config.ParticleSizeScale)
reducedSize (desired, , reducedSize)
distanceCulled (desired, , )
desired
Safe.(instance, )
avatarOff = (instance, )
localAvatar
() inTool
(desired, , )
() avatarOff
(desired, , )
originalLifetime = PropertyStore.(instance, )
(originalLifetime) == (() ())
(desired, , .(originalLifetime, Config.TrailLifetimeCap))
maxLength = PropertyStore.(instance, )
(maxLength) == ()
(desired, , .(maxLength, ))
()
originalMin = PropertyStore.(instance, )
effectiveMax = (maxLength) == maxLength .huge
(originalMin) ==
(desired, , .(.(originalMin, Config.TrailMinLengthFloor), effectiveMax))
()
originalWidth = PropertyStore.(instance, )
reducedWidth = (originalWidth, Config.TrailWidthScale)
reducedWidth (desired, , reducedWidth)
()
(desired, , )
(desired, , )
distanceCulled (desired, , )
desired
Safe.(instance, )
avatarOff = (instance, )
localAvatar
() inTool
(desired, , )
() avatarOff
(desired, , )
()
color = PropertyStore.(instance, )
transparency = PropertyStore.(instance, )
minimum =
(color) == minimum = .(minimum, #color.Keypoints - )
(transparency) == minimum = .(minimum, #transparency.Keypoints - )
segments = PropertyStore.(instance, )
(segments) == (desired, , .(minimum, .(segments, Config.BeamSegmentsCap)))
() (desired, , )
()
originalWidth0 = PropertyStore.(instance, )
originalWidth1 = PropertyStore.(instance, )
(originalWidth0) ==
(desired, , originalWidth0 * Config.BeamWidthScale)
(originalWidth1) ==
(desired, , originalWidth1 * Config.BeamWidthScale)
()
(desired, , )
(desired, , )
distanceCulled (desired, , )
desired
Safe.(instance, ) Safe.(instance, ) Safe.(instance, )
localAvatar (()
(instance, )
(otherAvatar () distanceCulled))
(desired, , )
desired
Safe.(instance)
() (desired, , )
desired
Safe.(instance, )
() ()
(desired, , )
(desired, , )
(desired, , )
(desired, , )
(desired, , )
(desired, , )
(desired, , )
(desired, , )
(desired, , )
(desired, , )
desired
Safe.(instance, )
otherAvatar localAvatar (()
(() distanceCulled))
(desired, , )
desired
Safe.(instance, )
localAvatar ((safeDecor ())
(otherAvatar (()
(() distanceCulled))))
(desired, , )
desired
localAvatar Safe.(instance, ) safeDecor
()
(desired, , )
originalMaxDistance = PropertyStore.(instance, )
() (originalMaxDistance) ==
(desired, , originalMaxDistance >
.(originalMaxDistance, Config.BillboardMaxDistance)
Config.BillboardMaxDistance)
() (originalMaxDistance) ==
(desired, , originalMaxDistance >
.(originalMaxDistance, Config.BillboardGuiMaxDistanceExtreme)
Config.BillboardGuiMaxDistanceExtreme)
()
(desired, , .(PropertyStore.(instance, ) , Config.BillboardDistanceStep))
desired
localAvatar Safe.(instance, ) safeDecor
()
(desired, , )
originalMaxDistance = PropertyStore.(instance, )
() (originalMaxDistance) ==
(desired, , originalMaxDistance >
.(originalMaxDistance, Config.SurfaceGuiMaxDistance)
Config.SurfaceGuiMaxDistance)
() (originalMaxDistance) ==
(desired, , originalMaxDistance >
.(originalMaxDistance, Config.SurfaceGuiMaxDistanceExtreme)
Config.SurfaceGuiMaxDistanceExtreme)
()
pixelsPerStud = PropertyStore.(instance, )
(pixelsPerStud) ==
(desired, , .(pixelsPerStud, Config.SurfaceGuiPixelsPerStudCap))
desired
localAvatar Safe.(instance, ) inTool
()
(safeDecor ())
(desired, , )
desired
safeDecor localAvatar
Safe.(instance, ) () (desired, , )
Safe.(instance, ) () (desired, , )
Safe.(instance, ) () (desired, , )
Safe.(instance, ) () (desired, , )
return desired
end
function OptimizerEngine.ApplyInstance(instance)
if not State.Enabled or not Safe.IsAlive(instance) then return false end
State.SeenInstances[instance] = true
local desired = OptimizerEngine.BuildDesiredProperties(instance)
PropertyStore.Reconcile(instance, desired)
State.ProcessedInstances = State.ProcessedInstances + 1
return true
end
function OptimizerEngine.ApplyGlobal()
if not State.Enabled then return end
local lightingDesired = {}
if Wants("GlobalShadows") then lightingDesired.GlobalShadows = false end
if Wants("Fog") then lightingDesired.FogStart = 0; lightingDesired.FogEnd = 1000000 end
if Wants("EnvironmentScales") then
lightingDesired.EnvironmentDiffuseScale = 0
lightingDesired.EnvironmentSpecularScale = 0
end
PropertyStore.Reconcile(Lighting, lightingDesired)
local terrain = Workspace:FindFirstChildOfClass("Terrain")
if terrain then
local terrainDesired = {}
if Wants("TerrainDecoration") then terrainDesired.Decoration = false end
if Wants("WaterWaves") then
terrainDesired.WaterWaveSize = 0
terrainDesired.WaterWaveSpeed = 0
end
if Wants("WaterReflectance") then terrainDesired.WaterReflectance = 0 end
if Wants("WaterInvisible") then terrainDesired.WaterTransparency = 1 end
PropertyStore.Reconcile(terrain, terrainDesired)
end
end
function OptimizerEngine.ReconcileTracked()
for instance in pairs(State.SeenInstances) do
if Safe.IsAlive(instance) then
OptimizerEngine.ApplyInstance(instance)
else
State.SeenInstances[instance] = nil
end
end
end
QueueEngine = {}
local function QueueCount(queue, head)
return math.max(0, #queue - head + 1)
end
function QueueEngine.Count()
return QueueCount(State.QueueHigh, State.QueueHighHead)
+ QueueCount(State.QueueNormal, State.QueueNormalHead)
end
function QueueEngine.GetBatchBudget()
local budget = Config.BatchBudgetSeconds
local fps = State.AverageFPS > 0 and State.AverageFPS or State.FPS
if State.Tier >= 4 then
budget = budget * 0.25
elseif State.Tier == 3 then
budget = budget * 0.40
elseif State.Tier == 2 then
budget = budget * 0.60
elseif State.Tier == 1 then
budget = budget * 0.80
end
if fps > 0 and fps < 35 then
budget = math.min(budget, 0.00065)
elseif fps > 0 and fps < 45 then
budget = math.min(budget, 0.00090)
end
return math.clamp(budget, 0.00035, Config.BatchBudgetSeconds)
end
function QueueEngine.Clear()
State.QueueGeneration = State.QueueGeneration + 1
table.clear(State.QueueHigh)
table.clear(State.QueueNormal)
table.clear(State.Pending)
State.QueueHighHead, State.QueueNormalHead = 1, 1
State.QueueDropped = 0
end
function QueueEngine.Compact(queueName)
local queue = queueName == "HIGH" and State.QueueHigh or State.QueueNormal
local headName = queueName == "HIGH" and "QueueHighHead" or "QueueNormalHead"
local head = State[headName]
if head <= 1 then return end
local compacted = {}
for index = head, #queue do
local instance = queue[index]
if instance then table.insert(compacted, instance) end
end
table.clear(queue)
for index, instance in ipairs(compacted) do queue[index] = instance end
State[headName] = 1
end
function QueueEngine.Pop()
if State.QueueHighHead <= #State.QueueHigh then
local item = State.QueueHigh[State.QueueHighHead]
State.QueueHighHead = State.QueueHighHead + 1
return item
end
if State.QueueNormalHead <= #State.QueueNormal then
local item = State.QueueNormal[State.QueueNormalHead]
State.QueueNormalHead = State.QueueNormalHead + 1
return item
end
return nil
end
function QueueEngine.Enqueue(instance, highPriority)
if not State.Enabled or typeof(instance) ~= "Instance" or not Safe.IsAlive(instance) then return false end
if not QueueEngine.IsCandidate(instance) then return false end
if State.Pending[instance] then return false end
if QueueEngine.Count() >= Config.MaxQueueEntries then
State.QueueDropped = State.QueueDropped + 1
return false
end
State.Pending[instance] = true
if highPriority then table.insert(State.QueueHigh, instance)
else table.insert(State.QueueNormal, instance) end
QueueEngine.StartWorker()
return true
end
function QueueEngine.StartWorker()
if State.QueueWorker or not State.Enabled then return end
State.QueueWorker = true
local workerGeneration = State.QueueGeneration
task.spawn(function()
while State.Running and State.Enabled and workerGeneration == State.QueueGeneration do
local started = os.clock()
local processed = 0
local batchBudget = QueueEngine.GetBatchBudget()
local tierScale = 1 - (State.Tier * 0.12)
local maxBatch = math.max(20, math.floor(Config.BatchSize * tierScale))
if State.Tier >= 4 then maxBatch = math.min(maxBatch, Config.PanicBatchSize) end
while processed < maxBatch
and os.clock() - started < batchBudget
and workerGeneration == State.QueueGeneration do
local instance = QueueEngine.Pop()
if not instance then break end
State.Pending[instance] = nil
if Safe.IsAlive(instance) then OptimizerEngine.ApplyInstance(instance) end
processed = processed + 1
end
if QueueEngine.Count() == 0 then break end
local yieldTime = State.Tier >= 4 and (Config.BatchYield * 3) or Config.BatchYield
task.wait(yieldTime)
end
if workerGeneration == State.QueueGeneration then
if State.QueueHighHead > #State.QueueHigh then
table.clear(State.QueueHigh); State.QueueHighHead = 1
elseif State.QueueHighHead > 512 then QueueEngine.Compact("HIGH") end
if State.QueueNormalHead > #State.QueueNormal then
table.clear(State.QueueNormal); State.QueueNormalHead = 1
elseif State.QueueNormalHead > 512 then QueueEngine.Compact("NORMAL") end
end
State.QueueWorker = false
if State.Running and State.Enabled and QueueEngine.Count() > 0 then QueueEngine.StartWorker() end
end)
end
function QueueEngine.IsCandidate(instance)
return Safe.IsA(instance, "BasePart") or Safe.IsA(instance, "Decal")
or Safe.IsA(instance, "Texture") or Safe.IsA(instance, "SurfaceAppearance")
or Safe.IsPostEffect(instance) or Safe.IsA(instance, "Atmosphere")
or Safe.IsA(instance, "Clouds") or Safe.IsLight(instance)
or Safe.IsA(instance, "ParticleEmitter") or Safe.IsA(instance, "Trail")
or Safe.IsA(instance, "Beam") or Safe.IsA(instance, "Fire")
or Safe.IsA(instance, "Smoke") or Safe.IsA(instance, "Sparkles")
or Safe.IsSoundEffect(instance) or Safe.IsA(instance, "Sky")
or Safe.IsA(instance, "WrapLayer") or Safe.IsA(instance, "Highlight")
or Safe.IsA(instance, "BillboardGui") or Safe.IsA(instance, "SurfaceGui")
or Safe.IsA(instance, "SpecialMesh")
or Safe.IsA(instance, "SelectionBox") or Safe.IsA(instance, "SelectionSphere")
or Safe.IsA(instance, "BoxHandleAdornment") or Safe.IsA(instance, "SphereHandleAdornment")
end
function QueueEngine.ScanRoot(root, highPriority, scanGeneration)
if not root or not State.Enabled then return end
local started = os.clock()
local stack = { [1] = root }
local stackHead, stackTail = 1, 1
local visited = 0
while stackHead <= stackTail and State.Running and State.Enabled
and (scanGeneration == nil or scanGeneration == State.ScanGeneration) do
local current = stack[stackHead]
stack[stackHead] = nil
stackHead = stackHead + 1
if current ~= root and QueueEngine.IsCandidate(current) then
QueueEngine.Enqueue(current, highPriority)
end
local ok, children = pcall(function() return current:GetChildren() end)
if ok then
for index = 1, #children do
stackTail = stackTail + 1
stack[stackTail] = children[index]
end
end
visited = visited + 1
if visited % 160 == 0 then task.wait() end
end
State.LastScanSeconds = os.clock() - started
Logger.Info(string.format("Scan incremental concluido: %d nos em %.2fs", visited, State.LastScanSeconds), "SCAN")
end
function QueueEngine.ScanWorld()
if State.InitialScanStarted or not State.Enabled then return end
State.InitialScanStarted = true
State.ScanGeneration = State.ScanGeneration + 1
local scanGeneration = State.ScanGeneration
task.spawn(function()
local started = os.clock()
QueueEngine.ScanRoot(Workspace, true, scanGeneration)
QueueEngine.ScanRoot(Lighting, true, scanGeneration)
for _, player in ipairs(Players:GetPlayers()) do
if scanGeneration ~= State.ScanGeneration or not State.Enabled then break end
if player.Character then QueueEngine.ScanRoot(player.Character, true, scanGeneration) end
end
if scanGeneration == State.ScanGeneration then
State.LastScanSeconds = os.clock() - started
State.InitialScanDone = State.Enabled
State.InitialScanStarted = false
if State.InitialScanDone then
Logger.Info(string.format("Varredura completa: %.2fs", State.LastScanSeconds), "SCAN")
end
end
end)
end
function QueueEngine.ReapplyTracked()
task.spawn(function()
local processed = 0
for instance in pairs(State.SeenInstances) do
if State.Running and State.Enabled and Safe.IsAlive(instance) then
if State.Automatic then QueueEngine.Enqueue(instance, false)
else OptimizerEngine.ApplyInstance(instance) end
end
processed = processed + 1
if processed % 100 == 0 then task.wait() end
end
end)
end
MemoryCleaner = {}
function MemoryCleaner.TrimLog()
while #State.Log > Config.MaxLogEntries do table.remove(State.Log, 1) end
end
function MemoryCleaner.CompactQueues()
if State.QueueHighHead > 256 then QueueEngine.Compact("HIGH") end
if State.QueueNormalHead > 256 then QueueEngine.Compact("NORMAL") end
end
function MemoryCleaner.Trim()
MemoryCleaner.TrimLog()
MemoryCleaner.CompactQueues()
Safe.TrimTimedCaches()
local ok = pcall(function() collectgarbage("step", 48) end)
if not ok then Logger.Warn("Coleta incremental nao disponivel neste contexto", "MEMORY") end
end
function MemoryCleaner.CleanNow()
local before
pcall(function() before = Stats:GetTotalMemoryUsageMb() end)
MemoryCleaner.Trim()
local after
pcall(function() after = Stats:GetTotalMemoryUsageMb() end)
if before and after then
Logger.Info(string.format("Limpeza de estruturas internas; memoria reportada %.1f -> %.1f MB (nao garantida)", before, after), "MEMORY")
else
Logger.Info("Estruturas internas do Booster compactadas; RAM do motor nao e controlavel", "MEMORY")
end
end
DistanceEngine = { Snapshot = {}, Cursor = 1, LastSnapshot = 0, Refreshing = false, Generation = 0 }
function DistanceEngine.IsEnabled()
if not Wants("CameraBasedCulling") then return false end
return Wants("AdaptiveRenderDistance") or Wants("SafeDecorDistanceCulling")
or Wants("SafeDebrisDistanceCulling") or Wants("DynamicEffectsDistance")
or Wants("DynamicLightsDistance") or Wants("DynamicDebrisDistance")
or Wants("DynamicAvatarDistance") or Wants("ParticleDistanceCulling")
or Wants("TrailDistanceOptimization") or Wants("BeamDistanceCulling")
or Wants("DistantLightCulling")
end
function DistanceEngine.GetCameraPosition()
local camera = Workspace.CurrentCamera
if not camera then return nil end
local ok, cframe = pcall(function() return camera.CFrame end)
if not ok then return nil end
return cframe.Position
end
function DistanceEngine.GetWorldPosition(instance)
if Safe.IsA(instance, "BasePart") then
local ok, position = Safe.Get(instance, "Position")
if ok then return position end
end
if Safe.IsA(instance, "Attachment") then
local ok, position = Safe.Get(instance, "WorldPosition")
if ok then return position end
end
local cursor, depth = instance, 0
while cursor and cursor ~= Workspace and depth < 18 do
if Safe.IsA(cursor, "BasePart") then
local ok, position = Safe.Get(cursor, "Position")
if ok then return position end
end
cursor, depth = cursor.Parent, depth + 1
end
local owner = Safe.GetPlayerFromAncestor(instance)
if owner and owner.Character then
local root = owner.Character:FindFirstChild("HumanoidRootPart")
if root then return root.Position end
end
return nil
end
function DistanceEngine.GetLimit(instance)
if Safe.IsDebris(instance) and (Wants("SafeDebrisDistanceCulling") or Wants("DynamicDebrisDistance")) then
return Config.SafeDebrisDistance
end
if Safe.IsDecor(instance) and (Wants("AdaptiveRenderDistance") or Wants("SafeDecorDistanceCulling")) then
return Config.SafeDecorDistance
end
if Safe.IsLight(instance) and (Wants("DynamicLightsDistance") or Wants("DistantLightCulling")) then
return Config.LightDistance
end
if (Safe.IsA(instance, "ParticleEmitter") and Wants("ParticleDistanceCulling"))
or (Safe.IsA(instance, "Trail") and Wants("TrailDistanceOptimization"))
or (Safe.IsA(instance, "Beam") and Wants("BeamDistanceCulling"))
or ((Safe.IsA(instance, "ParticleEmitter") or Safe.IsA(instance, "Trail") or Safe.IsA(instance, "Beam")) and Wants("DynamicEffectsDistance")) then
return Config.EffectDistance
end
if Safe.IsOtherAvatar(instance) and Wants("DynamicAvatarDistance") then
return Config.AvatarDistance
end
return nil
end
function DistanceEngine.RefreshSnapshot()
if DistanceEngine.Refreshing then return end
DistanceEngine.Refreshing = true
DistanceEngine.Generation = DistanceEngine.Generation + 1
local generation = DistanceEngine.Generation
task.spawn(function()
local snapshot = {}
local visited = 0
for instance in pairs(State.SeenInstances) do
if generation ~= DistanceEngine.Generation or not State.Running then break end
if Safe.IsAlive(instance) then snapshot[#snapshot + 1] = instance end
visited = visited + 1
if visited % 300 == 0 then task.wait() end
end
if generation == DistanceEngine.Generation then
DistanceEngine.Snapshot = snapshot
DistanceEngine.Cursor = 1
DistanceEngine.LastSnapshot = os.clock()
DistanceEngine.Refreshing = false
end
end)
end
function DistanceEngine.UpdateOne(instance, cameraPosition)
local limit = DistanceEngine.GetLimit(instance)
local shouldCull = false
if limit and cameraPosition then
local position = DistanceEngine.GetWorldPosition(instance)
if position then
local distance = (position - cameraPosition).Magnitude
local wasCulled = State.DistanceCulled[instance] == true
local threshold = wasCulled and limit * (1 - Config.DistanceHysteresis)
or limit * (1 + Config.DistanceHysteresis)
shouldCull = distance > threshold
end
end
local wasCulled = State.DistanceCulled[instance] == true
if shouldCull ~= wasCulled then
if shouldCull then State.DistanceCulled[instance] = true
else State.DistanceCulled[instance] = nil end
if State.Automatic then QueueEngine.Enqueue(instance, false)
else OptimizerEngine.ApplyInstance(instance) end
end
end
function DistanceEngine.Step()
if not State.Enabled or not DistanceEngine.IsEnabled() then return end
local now = os.clock()
local interval = Wants("DistanceUpdateThrottling") and Config.DistanceSlowInterval or Config.DistanceInterval
if now - State.LastDistanceRun < interval then return end
State.LastDistanceRun = now
if #DistanceEngine.Snapshot == 0 or DistanceEngine.Cursor > #DistanceEngine.Snapshot
or now - DistanceEngine.LastSnapshot > 5 then
DistanceEngine.RefreshSnapshot()
if DistanceEngine.Refreshing then return end
end
local cameraPosition = DistanceEngine.GetCameraPosition()
if not cameraPosition then return end
local processed = 0
local started = os.clock()
local distanceBudget = QueueEngine.GetBatchBudget() * 0.65
while DistanceEngine.Cursor <= #DistanceEngine.Snapshot
and processed < Config.MaxDistancePerPass
and os.clock() - started < distanceBudget do
local instance = DistanceEngine.Snapshot[DistanceEngine.Cursor]
DistanceEngine.Cursor = DistanceEngine.Cursor + 1
if instance and Safe.IsAlive(instance) then DistanceEngine.UpdateOne(instance, cameraPosition) end
processed = processed + 1
end
end
function DistanceEngine.Reset()
DistanceEngine.Generation = DistanceEngine.Generation + 1
DistanceEngine.Refreshing = false
table.clear(DistanceEngine.Snapshot)
DistanceEngine.Cursor = 1
DistanceEngine.LastSnapshot = 0
table.clear(State.DistanceCulled)
end
MetricsMonitor = {}
function MetricsMonitor.OnFrame(deltaTime)
if type(deltaTime) ~= "number" or deltaTime <= 0 or deltaTime > 1 then return end
local frameMs = deltaTime * 1000
if State.Benchmark and State.Benchmark.Active then
local frameTimes = State.Benchmark.FrameTimes
frameTimes[#frameTimes + 1] = frameMs
end
if frameMs < State.SessionMinFrameTime then State.SessionMinFrameTime = frameMs end
if frameMs > State.SessionMaxFrameTime then State.SessionMaxFrameTime = frameMs end
if frameMs > 50 then
State.SuddenDropCount = State.SuddenDropCount + 1
State.LastSuddenDropTime = os.clock()
end
local index = State.FrameTimeHead
State.FrameTimes[index] = frameMs
State.FrameTimeHead = (index % Config.MaxMetricSamples) + 1
State.FrameTimeCount = math.min(State.FrameTimeCount + 1, Config.MaxMetricSamples)
end
function MetricsMonitor.GetFrameSamples()
local result = {}
local count = State.FrameTimeCount
local start = State.FrameTimeCount == Config.MaxMetricSamples and State.FrameTimeHead or 1
for offset = 0, count - 1 do
local index = ((start + offset - 1) % Config.MaxMetricSamples) + 1
local value = State.FrameTimes[index]
if type(value) == "number" then result[#result + 1] = value end
end
return result
end
function MetricsMonitor.Percentile(sortedValues, percentile)
local count = #sortedValues
if count == 0 then return 0 end
local index = math.clamp(math.ceil(count * percentile), 1, count)
return sortedValues[index]
end
function MetricsMonitor.ReadPing()
local ok, pingSeconds = pcall(function() return LocalPlayer:GetNetworkPing() end)
if ok and type(pingSeconds) == "number" then State.Ping = pingSeconds * 1000 end
return State.Ping
end
function MetricsMonitor.ReadMemory()
local ok, memory = pcall(function() return Stats:GetTotalMemoryUsageMb() end)
if ok and type(memory) == "number" then State.MemoryMB = memory end
return State.MemoryMB
end
function MetricsMonitor.Recalculate()
local samples = MetricsMonitor.GetFrameSamples()
if #samples == 0 then return end
local current = samples[#samples]
local sum = 0
for _, frameMs in ipairs(samples) do
sum = sum + frameMs
end
local sorted = table.clone(samples)
table.sort(sorted)
State.FrameTime = current
State.AverageFrameTime = sum / #samples
State.P95FrameTime = MetricsMonitor.Percentile(sorted, 0.95)
local p99 = MetricsMonitor.Percentile(sorted, 0.99)
State.FPS = current > 0 and (1000 / current) or 0
State.AverageFPS = State.AverageFrameTime > 0 and (1000 / State.AverageFrameTime) or 0
State.MinimumFPS = State.SessionMaxFrameTime > 0 and (1000 / State.SessionMaxFrameTime) or 0
State.MaximumFPS = State.SessionMinFrameTime < math.huge and (1000 / State.SessionMinFrameTime) or 0
State.OnePercentLow = p99 > 0 and (1000 / p99) or 0
State.CurrentSampleCount = #samples
table.insert(State.FPSHistory, State.FPS)
while #State.FPSHistory > Config.MaxFPSHistory do table.remove(State.FPSHistory, 1) end
end
function MetricsMonitor.Snapshot()
return {
FPS = State.FPS, AverageFPS = State.AverageFPS,
MinimumFPS = State.MinimumFPS, MaximumFPS = State.MaximumFPS,
FrameTime = State.FrameTime, AverageFrameTime = State.AverageFrameTime,
P95FrameTime = State.P95FrameTime, OnePercentLow = State.OnePercentLow,
Ping = State.Ping, MemoryMB = State.MemoryMB,
ProcessedInstances = State.ProcessedInstances,
AppliedProperties = State.AppliedProperties,
RestoredProperties = State.RestoredProperties,
FailedProperties = State.FailedProperties,
ExternalChangesPreserved = State.ExternalChangesPreserved,
QueueSize = QueueEngine.Count(), LastScanSeconds = State.LastScanSeconds,
CacheStats = table.clone(State.CacheStats),
Tier = State.Tier, Profile = State.Profile,
}
end
function MetricsMonitor.Tick()
MetricsMonitor.Recalculate()
MetricsMonitor.ReadPing()
MetricsMonitor.ReadMemory()
end
function MetricsMonitor.Start()
if State.Connections.PreRender then return end
local callback = function(deltaTime) MetricsMonitor.OnFrame(deltaTime) end
local connected, connection = pcall(function()
return RunService.PreRender:Connect(callback)
end)
if not connected then
connected, connection = pcall(function()
return RunService.RenderStepped:Connect(callback)
end)
end
if connected then
State.Connections.PreRender = connection
else
Logger.Error("Nao foi possivel iniciar captura de frame-time", "METRICS", nil, nil, connection)
return
end
if State.MetricsLoopStarted then return end
State.MetricsLoopStarted = true
task.spawn(function()
while State.Running do
task.wait(State.Tier >= 4 and 1.25 or Config.MetricsInterval)
if State.Running then MetricsMonitor.Tick() end
end
end)
end
AdaptiveController = {}
State.TierHistory = {}
local TierNames = { [0] = "NORMAL", [1] = "OPTIMIZED", [2] = "EXTREME", [3] = "POTATO", [4] = "PANIC MODE" }
function AdaptiveController.CandidateTier()
local fps = State.AverageFPS > 0 and State.AverageFPS or State.FPS
local p95 = State.P95FrameTime
if fps <= 0 then return State.Tier, "Aguardando amostras suficientes" end
if os.clock() - State.LastSuddenDropTime < 1 and State.FrameTime > 50 then
return 4, "Queda repentina de frame-time detectada"
end
if fps < Config.Tier4FPS or p95 > Config.Tier4P95 then return 4, "FPS abaixo do limite critico ou p95 elevado" end
if fps < Config.Tier3FPS or p95 > Config.Tier3P95 then return 3, "FPS ou p95 no limite POTATO" end
if fps < Config.Tier2FPS or p95 > Config.Tier2P95 then return 2, "FPS ou p95 no limite EXTREME" end
if fps < Config.TargetFPS or p95 > Config.Tier1P95 then return 1, "Meta de FPS nao sustentada" end
return 0, "Desempenho dentro da meta configurada"
end
function AdaptiveController.RecordChange(oldTier, newTier, reason)
local event = { Time = os.clock(), From = oldTier, To = newTier, Reason = reason }
table.insert(State.TierHistory, event)
while #State.TierHistory > 100 do table.remove(State.TierHistory, 1) end
Logger.Write("INFO", "ADAPTIVE", string.format("%s -> %s: %s", TierNames[oldTier], TierNames[newTier], reason))
end
function AdaptiveController.ApplyTier(newTier, reason)
newTier = math.clamp(math.floor(newTier), 0, 4)
if State.Tier == newTier then State.TierReason = reason; return end
local oldTier = State.Tier
State.Tier = newTier
State.Panic = newTier >= 4
State.TierReason = reason
State.LastTierChange = os.clock()
AdaptiveController.RecordChange(oldTier, newTier, reason)
if State.Enabled then
OptimizerEngine.ApplyGlobal()
QueueEngine.ReapplyTracked()
end
end
function AdaptiveController.Update()
if not State.Enabled or not State.Adaptive then
if State.Tier ~= 0 then AdaptiveController.ApplyTier(0, "Adaptativo desativado") end
return
end
local candidate, reason = AdaptiveController.CandidateTier()
local now = os.clock()
if candidate > State.Tier then
State.RecoveryStartedAt = nil
if now - State.LastTierChange >= Config.TierChangeCooldown then
AdaptiveController.ApplyTier(candidate, reason)
end
return
end
if candidate < State.Tier then
if State.FPS >= Config.RecoveryFPS and State.P95FrameTime <= Config.Tier1P95 then
State.RecoveryStartedAt = State.RecoveryStartedAt or now
if now - State.RecoveryStartedAt >= Config.RecoverySeconds
and now - State.LastTierChange >= Config.TierChangeCooldown then
AdaptiveController.ApplyTier(State.Tier - 1, "Estabilidade recuperada por " .. Config.RecoverySeconds .. "s")
State.RecoveryStartedAt = nil
end
else
State.RecoveryStartedAt = nil
end
return
end
State.RecoveryStartedAt = nil
end
function AdaptiveController.Start()
if State.AdaptiveLoopStarted then return end
State.AdaptiveLoopStarted = true
task.spawn(function()
while State.Running do
task.wait(Config.AdaptiveInterval)
if State.Running then AdaptiveController.Update() end
end
end)
end
Benchmark = {}
local function SummarizeFrameTimes(frameTimes, duration)
if #frameTimes == 0 then return nil end
local sorted = table.clone(frameTimes)
table.sort(sorted)
local sum, maximumFrame = 0, 0
for _, frameMs in ipairs(frameTimes) do
sum = sum + frameMs
if frameMs > maximumFrame then maximumFrame = frameMs end
end
local averageFrame = sum / #frameTimes
return {
Count = #frameTimes,
AverageFPS = averageFrame > 0 and (1000 / averageFrame) or 0,
AverageFrameTime = averageFrame,
MinimumFPS = maximumFrame > 0 and (1000 / maximumFrame) or 0,
P95FrameTime = MetricsMonitor.Percentile(sorted, 0.95),
OnePercentLow = MetricsMonitor.Percentile(sorted, 0.99) > 0
and (1000 / MetricsMonitor.Percentile(sorted, 0.99)) or 0,
Duration = duration,
}
end
function Benchmark.Start(kind, duration)
if State.Benchmark.Active then
Logger.Warn("Benchmark ja esta em execucao", "BENCHMARK")
return false
end
if kind ~= "BASELINE" and kind ~= "OPTIMIZED" then return false end
if kind == "BASELINE" and State.Enabled then
Logger.Warn("Desative o Booster para medir o baseline", "BENCHMARK")
return false
end
if kind == "OPTIMIZED" and not State.Enabled then
Logger.Warn("Ative o Booster para medir o perfil otimizado", "BENCHMARK")
return false
end
State.Benchmark.Active = true
State.Benchmark.Kind = kind
State.Benchmark.StartedAt = os.clock()
State.Benchmark.Duration = math.clamp(tonumber(duration) or Config.BenchmarkSeconds, 5, 90)
State.Benchmark.FrameTimes = {}
Logger.Info("Benchmark " .. kind .. " iniciado", "BENCHMARK")
task.spawn(function()
while State.Running and State.Benchmark.Active do
if os.clock() - State.Benchmark.StartedAt >= State.Benchmark.Duration then break end
task.wait(0.1)
end
if State.Benchmark.Active then Benchmark.Stop() end
end)
return true
end
function Benchmark.Stop()
if not State.Benchmark.Active then return false end
local kind = State.Benchmark.Kind
local elapsed = math.max(0, os.clock() - State.Benchmark.StartedAt)
local summary = SummarizeFrameTimes(State.Benchmark.FrameTimes, elapsed)
State.Benchmark.Active = false
State.Benchmark.Kind = nil
if summary then
if kind == "BASELINE" then State.Benchmark.Baseline = summary
elseif kind == "OPTIMIZED" then State.Benchmark.Optimized = summary end
Logger.Info(string.format("%s: %.1f FPS medio, %.2fms medio, %d amostras", kind, summary.AverageFPS, summary.AverageFrameTime, summary.Count), "BENCHMARK")
else
Logger.Warn("Benchmark terminou sem amostras suficientes", "BENCHMARK")
end
return true
end
function Benchmark.Compare()
local baseline, optimized = State.Benchmark.Baseline, State.Benchmark.Optimized
if not baseline or not optimized then return nil end
local delta = optimized.AverageFPS - baseline.AverageFPS
local percent = baseline.AverageFPS > 0 and (delta / baseline.AverageFPS) * 100 or 0
local comparison = {
DeltaFPS = delta, DeltaPercent = percent,
DeltaFrameTime = optimized.AverageFrameTime - baseline.AverageFrameTime,
Baseline = baseline, Optimized = optimized,
}
State.Benchmark.LastComparison = comparison
return comparison
end
function Benchmark.Reset()
if State.Benchmark.Active then Benchmark.Stop() end
State.Benchmark.Baseline = nil
State.Benchmark.Optimized = nil
State.Benchmark.LastComparison = nil
State.Benchmark.FrameTimes = {}
Logger.Info("Historico de benchmark reiniciado", "BENCHMARK")
end
local DefinitionByKey = {}
for _, definition in ipairs(OptionDefinitions) do DefinitionByKey[definition.Key] = definition end
for _, key in ipairs({ "SurfaceAppearance", "SafeDecorSurfaceAppearanceReduction" }) do
local definition = DefinitionByKey[key]
if definition then
definition.Supported = false
definition.UnsupportedReason = "Map properties de SurfaceAppearance exigem permissao Plugin; LocalScript nao pode modifica-las."
definition.CurrentValue = false
Options[key] = false
end
end
local AntiResetGuard = {}
function AntiResetGuard.Run()
if not State.Enabled then return end
OptimizerEngine.ApplyGlobal()
State.LastGuardRun = os.clock()
end
BackgroundMonitor = {}
function BackgroundMonitor.DisconnectWorld()
for _, name in ipairs({ "WorkspaceAdded", "LightingAdded" }) do
local connection = State.Connections[name]
if connection then connection:Disconnect(); State.Connections[name] = nil end
end
end
function BackgroundMonitor.DisconnectPlayers()
for player, connection in pairs(State.PlayerConnections) do
if connection then pcall(function() connection:Disconnect() end) end
State.PlayerConnections[player] = nil
end
for _, name in ipairs({ "PlayerAdded", "PlayerRemoving" }) do
local connection = State.Connections[name]
if connection then connection:Disconnect(); State.Connections[name] = nil end
end
end
function BackgroundMonitor.ScanCharacter(character)
if character and State.Enabled then
local scanGeneration = State.ScanGeneration
task.spawn(function() QueueEngine.ScanRoot(character, true, scanGeneration) end)
end
end
function BackgroundMonitor.ConnectPlayer(player)
if State.PlayerConnections[player] then return end
local connection = player.CharacterAdded:Connect(function(character)
BackgroundMonitor.ScanCharacter(character)
end)
State.PlayerConnections[player] = connection
if player.Character then BackgroundMonitor.ScanCharacter(player.Character) end
end
function BackgroundMonitor.Refresh()
BackgroundMonitor.DisconnectWorld()
BackgroundMonitor.DisconnectPlayers()
if not State.Enabled or not State.Automatic or not Wants("LiveGuard") then return end
State.Connections.WorkspaceAdded = Workspace.DescendantAdded:Connect(function(instance)
QueueEngine.Enqueue(instance, false)
end)
State.Connections.LightingAdded = Lighting.DescendantAdded:Connect(function(instance)
QueueEngine.Enqueue(instance, true)
end)
for _, player in ipairs(Players:GetPlayers()) do BackgroundMonitor.ConnectPlayer(player) end
State.Connections.PlayerAdded = Players.PlayerAdded:Connect(function(player)
BackgroundMonitor.ConnectPlayer(player)
end)
State.Connections.PlayerRemoving = Players.PlayerRemoving:Connect(function(player)
local connection = State.PlayerConnections[player]
if connection then connection:Disconnect(); State.PlayerConnections[player] = nil end
end)
end
function BackgroundMonitor.Start()
if State.BackgroundStarted then return end
State.BackgroundStarted = true
DistanceEngine.Start()
task.spawn(function()
while State.Running do
task.wait(Config.GuardInterval)
if State.Running and State.Enabled and State.Automatic then
AntiResetGuard.Run()
MemoryCleaner.Trim()
end
end
end)
end
function BackgroundMonitor.ScanInitial()
if not State.Enabled then return end
QueueEngine.ScanWorld()
end
ProfileManager = {}
local function ProfileFromDefaults()
local values = {}
for _, definition in ipairs(OptionDefinitions) do
values[definition.Key] = definition.DefaultValue
end
return values
end
local function MakeProfile(overrides)
local profile = ProfileFromDefaults()
for key, value in pairs(overrides or {}) do
if DefinitionByKey[key] and DefinitionByKey[key].Supported then profile[key] = value == true end
end
return profile
end
local PresetProfiles = {}
PresetProfiles.DEFAULT = MakeProfile({})
PresetProfiles.BALANCED = MakeProfile({
GlobalShadows = true, PartShadows = true, SmoothPlastic = true, NoReflectance = true,
PostEffects = false, AtmosphereClouds = false, DynamicLights = false,
Particles = false, Trails = false, Beams = false, FireSmokeSparkles = false,
Decals = false, Textures = false, SurfaceAppearance = false, Sky = false,
TerrainDecoration = true, WaterWaves = true, WaterReflectance = true,
MeshPerformance = true, LayeredClothing = false, SoundEffects = true,
Fog = false, EnvironmentScales = true,
})
PresetProfiles["LOW END PC"] = MakeProfile({
GlobalShadows = true, PartShadows = true, SmoothPlastic = true, NoReflectance = true,
PostEffects = true, AtmosphereClouds = true, DynamicLights = true,
Particles = true, Trails = true, Beams = true, FireSmokeSparkles = true,
Decals = true, Textures = true, SurfaceAppearance = true, Sky = true,
TerrainDecoration = true, WaterWaves = true, WaterReflectance = true,
MeshPerformance = true, LayeredClothing = true, SoundEffects = true,
Fog = true, EnvironmentScales = true, ParticleRateLimiter = true,
ParticleLifetimeReduction = true, TrailLifetimeLimiter = true,
BeamSegmentReduction = true, LightRangeLimiter = true, LightBrightnessLimiter = true,
SafeDecorDistanceCulling = true, SafeDebrisDistanceCulling = true,
})
PresetProfiles.POTATO = MakeProfile({
GlobalShadows = true, PartShadows = true, SmoothPlastic = true, NoReflectance = true,
PostEffects = true, AtmosphereClouds = true, DynamicLights = true,
Particles = true, Trails = true, Beams = true, FireSmokeSparkles = true,
Decals = true, Textures = true, SurfaceAppearance = true, Sky = true,
TerrainDecoration = true, WaterWaves = true, WaterReflectance = true,
WaterInvisible = true, MeshPerformance = true, MeshTextures = true,
LayeredClothing = true, SoundEffects = true, Fog = true, EnvironmentScales = true,
ParticleBurstOptimization = true, SafeDecorLocalHide = true, TaggedDebrisHide = true,
AdaptiveRenderDistance = true, DynamicEffectsDistance = true, DynamicLightsDistance = true,
SafeDecorDistanceCulling = true, SafeDebrisDistanceCulling = true,
})
PresetProfiles.EXTREME = MakeProfile({
GlobalShadows = true, PartShadows = true, SmoothPlastic = true, NoReflectance = true,
PostEffects = true, AtmosphereClouds = true, DynamicLights = true,
Particles = true, Trails = true, Beams = true, FireSmokeSparkles = true,
Decals = true, Textures = true, SurfaceAppearance = true, Sky = true,
TerrainDecoration = true, WaterWaves = true, WaterReflectance = true, WaterInvisible = true,
MeshPerformance = true, MeshTextures = true, LayeredClothing = true, SoundEffects = true,
Fog = true, EnvironmentScales = true, ParticleBurstOptimization = true,
ParticleRateLimiter = true, ParticleLifetimeReduction = true,
ParticleLightEmissionReduction = true, ParticleLightInfluenceReduction = true,
ParticleDistanceCulling = true, ParticleDensityControl = true,
TrailLifetimeLimiter = true, TrailDistanceOptimization = true,
BeamSegmentReduction = true, BeamTextureAnimationControl = true, BeamDistanceCulling = true,
TrailRenderingReduction = true, LightRangeLimiter = true, LightBrightnessLimiter = true,
DistantLightCulling = true, SelectiveShadowRemoval = true, DecorativeLightReduction = true,
SelectiveHighlightRemoval = true, SafeBillboardGuiOptimization = true,
SafeSurfaceGuiOptimization = true, SelectionBoxOptimization = true,
SelectionSphereOptimization = true, BoxHandleAdornmentOptimization = true,
SphereHandleAdornmentOptimization = true, IndividualBloomControl = true,
IndividualBlurControl = true, IndividualColorCorrectionControl = true,
IndividualSunRaysControl = true, IndividualDepthOfFieldControl = true,
AtmosphereDensityController = true, AtmosphereHazeController = true,
AtmosphereGlareController = true, SkyboxTextureOptimization = true,
SafeDecorLocalHide = true, SafeDecorDistanceCulling = true,
SafeDecorMaterialSimplification = true, SafeDecorMeshOptimization = true,
SafeDecorMeshTextureRemoval = true, SafeDecorSurfaceAppearanceReduction = true,
SafeDecorDecalReduction = true, SafeDecorTextureReduction = true,
SafeDebrisDistanceCulling = true, SafeDebrisSizeControl = true,
SafeDebrisShadowRemoval = true, AdaptiveRenderDistance = true,
DynamicEffectsDistance = true, DynamicLightsDistance = true,
DynamicDebrisDistance = true, CameraBasedCulling = true,
})
PresetProfiles["NUCLEAR POTATO"] = MakeProfile({
GlobalShadows = true, PartShadows = true, SmoothPlastic = true, NoReflectance = true,
PostEffects = true, AtmosphereClouds = true, DynamicLights = true,
Particles = true, Trails = true, Beams = true, FireSmokeSparkles = true,
Decals = true, Textures = true, SurfaceAppearance = true, Sky = true,
TerrainDecoration = true, WaterWaves = true, WaterReflectance = true, WaterInvisible = true,
MeshPerformance = true, MeshTextures = true, LayeredClothing = true, SoundEffects = true,
Fog = true, EnvironmentScales = true, ParticleBurstOptimization = true,
ParticleRateLimiter = true, ParticleLifetimeReduction = true,
ParticleLightEmissionReduction = true, ParticleLightInfluenceReduction = true,
ParticleDistanceCulling = true, ParticleDensityControl = true,
TrailLifetimeLimiter = true, TrailDistanceOptimization = true,
BeamSegmentReduction = true, BeamTextureAnimationControl = true, BeamDistanceCulling = true,
TrailRenderingReduction = true, LightRangeLimiter = true, LightBrightnessLimiter = true,
DistantLightCulling = true, SelectiveShadowRemoval = true, DecorativeLightReduction = true,
SelectiveHighlightRemoval = true, SafeBillboardGuiOptimization = true,
SafeSurfaceGuiOptimization = true, SelectionBoxOptimization = true,
SelectionSphereOptimization = true, BoxHandleAdornmentOptimization = true,
SphereHandleAdornmentOptimization = true, IndividualBloomControl = true,
IndividualBlurControl = true, IndividualColorCorrectionControl = true,
IndividualSunRaysControl = true, IndividualDepthOfFieldControl = true,
AtmosphereDensityController = true, AtmosphereHazeController = true,
AtmosphereGlareController = true, SkyboxTextureOptimization = true,
SafeDecorLocalHide = true, SafeDecorDistanceCulling = true,
SafeDecorMaterialSimplification = true, SafeDecorMeshOptimization = true,
SafeDecorMeshTextureRemoval = true, SafeDecorSurfaceAppearanceReduction = true,
SafeDecorDecalReduction = true, SafeDecorTextureReduction = true,
TaggedDebrisHide = true, SafeDebrisDistanceCulling = true,
SafeDebrisSizeControl = true, SafeDebrisShadowRemoval = true,
OtherPlayersHairReduction = true, OtherPlayersHatReduction = true,
OtherPlayersFaceAccessoriesReduction = true, OtherPlayersBackAccessoriesReduction = true,
OtherPlayersShoulderAccessoriesReduction = true, OtherPlayersWaistAccessoriesReduction = true,
OtherPlayersCharacterDecalsReduction = true, OtherPlayersCharacterParticlesReduction = true,
OtherPlayersCharacterTrailsReduction = true, OtherPlayersCharacterHighlightsReduction = true,
OtherPlayersCharacterLightsReduction = true, AdaptiveRenderDistance = true,
DynamicEffectsDistance = true, DynamicLightsDistance = true,
DynamicDebrisDistance = true, DynamicAvatarDistance = true, CameraBasedCulling = true,
})
local V4MaxOptions = {
"ParticleFlipbookBlendOff", "ParticleFlipbookFramerateCap", "ParticleRotationSpeedZero",
"ParticleAccelerationZero", "ParticleDragZero", "ParticleSizeReduction",
"TrailMinLengthOptimization", "TrailWidthScaleReduction", "TrailLightBlendReduction",
"BeamWidthReduction", "BeamLightBlendReduction", "SurfaceGuiPixelDensityCap",
"SurfaceGuiDistanceCulling", "BillboardGuiDistanceCulling", "BillboardGuiDistanceStep",
"SafeDecorBillboardDisable", "SafeDecorSurfaceGuiDisable",
"SafeDecorSpecialMeshTextureClear", "SafeDecorMeshDoubleSidedOff",
"SafeDecorMaterialVariantClear",
"SpecialMeshTextureClearGlobal", "DecalTextureAssetClearGlobal",
"ParticleEmitterTextureClearGlobal", "TrailTextureClearGlobal",
"BeamTextureClearGlobal", "MeshPartDoubleSidedOffGlobal",
}
for _, key in ipairs(V4MaxOptions) do
PresetProfiles.POTATO[key] = true
PresetProfiles.EXTREME[key] = true
PresetProfiles["NUCLEAR POTATO"][key] = true
end
PresetProfiles.COMPETITIVE = MakeProfile({
GlobalShadows = true, PartShadows = true, SmoothPlastic = true, NoReflectance = true,
PostEffects = true, AtmosphereClouds = false, DynamicLights = false,
Particles = false, Trails = false, Beams = false, FireSmokeSparkles = false,
Decals = false, Textures = false, SurfaceAppearance = false, Sky = false,
TerrainDecoration = true, WaterWaves = true, WaterReflectance = true,
WaterInvisible = false, MeshPerformance = true, MeshTextures = false,
LayeredClothing = false, SoundEffects = true, Fog = false, EnvironmentScales = false,
OtherPlayersHairReduction = false, OtherPlayersHatReduction = false,
OtherPlayersFaceAccessoriesReduction = false, OtherPlayersBackAccessoriesReduction = false,
OtherPlayersShoulderAccessoriesReduction = false, OtherPlayersWaistAccessoriesReduction = false,
OtherPlayersCharacterDecalsReduction = false, OtherPlayersCharacterParticlesReduction = false,
OtherPlayersCharacterTrailsReduction = false, OtherPlayersCharacterHighlightsReduction = false,
OtherPlayersCharacterLightsReduction = false, AdaptiveRenderDistance = false,
DynamicAvatarDistance = false,
})
PresetProfiles.CUSTOM = ProfileFromDefaults()
function ProfileManager.GetNames()
local names = {}
for name in pairs(PresetProfiles) do names[#names + 1] = name end
for name in pairs(State.Profiles) do names[#names + 1] = name end
table.sort(names)
return names
end
function ProfileManager.Get(name)
return State.Profiles[name] or PresetProfiles[name]
end
function ProfileManager.Save(name)
if type(name) ~= "string" or name == "" then return false end
if PresetProfiles[name] then
Logger.Warn("Nome reservado para preset; escolha outro nome para salvar", "PROFILE")
return false
end
local copy = {}
for _, definition in ipairs(OptionDefinitions) do copy[definition.Key] = Options[definition.Key] == true end
State.Profiles[name] = copy
Logger.Info("Perfil salvo na sessao: " .. name, "PROFILE")
return true
end
function ProfileManager.Duplicate(sourceName, newName)
local source = ProfileManager.Get(sourceName)
if not source or type(newName) ~= "string" or newName == "" then return false end
local copy = {}
for key, value in pairs(source) do copy[key] = value == true end
State.Profiles[newName] = copy
Logger.Info("Perfil duplicado: " .. sourceName .. " -> " .. newName, "PROFILE")
return true
end
function ProfileManager.Compare(firstName, secondName)
local first, second = ProfileManager.Get(firstName), ProfileManager.Get(secondName)
if not first or not second then return nil end
local differences = {}
for _, definition in ipairs(OptionDefinitions) do
if (first[definition.Key] == true) ~= (second[definition.Key] == true) then
differences[#differences + 1] = {
Key = definition.Key, Name = definition.Name,
First = first[definition.Key] == true, Second = second[definition.Key] == true,
}
end
end
return differences
end
function DistanceEngine.Start()
if State.DistanceLoopStarted then return end
State.DistanceLoopStarted = true
task.spawn(function()
while State.Running do
if State.Enabled and DistanceEngine.IsEnabled() then
DistanceEngine.Step()
local interval = Wants("DistanceUpdateThrottling")
and Config.DistanceSlowInterval or Config.DistanceInterval
task.wait(math.max(0.08, interval))
else
task.wait(0.5)
end
end
end)
end
BoosterController = {}
function BoosterController.ApplyTracked()
if not State.Enabled then return end
if State.Automatic then QueueEngine.ReapplyTracked()
else
task.spawn(function()
local processed = 0
for instance in pairs(State.SeenInstances) do
if Safe.IsAlive(instance) then OptimizerEngine.ApplyInstance(instance) end
processed = processed + 1
if processed % 100 == 0 then task.wait() end
end
end)
end
end
function BoosterController.ToggleOption(key, value)
local definition = DefinitionByKey[key]
if not definition or not definition.Supported then return false, "OPTION_UNSUPPORTED" end
if definition.RiskLevel == "HIGH" and value == true then return false, "CONFIRM_HIGH_IMPACT" end
AdaptivePolicy.Set(key, value)
if key == "LiveGuard" and value == false then
State.ScanGeneration = State.ScanGeneration + 1
State.InitialScanStarted = false
State.InitialScanDone = false
end
if State.Enabled then
table.clear(State.DistanceCulled)
OptimizerEngine.ApplyGlobal()
BoosterController.ApplyTracked()
BackgroundMonitor.Refresh()
if key == "LiveGuard" and value == true and State.Automatic and not State.InitialScanDone then
BackgroundMonitor.ScanInitial()
end
end
Logger.Info(string.format("Opcao %s: %s", key, tostring(Options[key])), "OPTIMIZATION")
return true
end
function BoosterController.EnableAll(confirmed)
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported and definition.RiskLevel == "HIGH" and not confirmed then
return false, "CONFIRM_HIGH_IMPACT"
end
end
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported then AdaptivePolicy.Set(definition.Key, true) end
end
if State.Enabled then
table.clear(State.DistanceCulled)
OptimizerEngine.ApplyGlobal()
BoosterController.ApplyTracked()
BackgroundMonitor.Refresh()
end
Logger.Warn("Todas as opcoes suportadas foram ativadas", "CONFIG")
return true
end
function BoosterController.ToggleOneClick()
if State.OneClickActive then
State.OneClickActive = false
BoosterController.Disable()
State.Profile = "DEFAULT"
return false
end
State.Adaptive = true
State.Automatic = true
table.clear(State.UserOverrides)
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported then
AdaptivePolicy.Set(definition.Key, true)
end
end
State.Profile = "ONE-CLICK MAX"
State.OneClickActive = true
if not State.Enabled then
BoosterController.Enable()
else
table.clear(State.DistanceCulled)
OptimizerEngine.ApplyGlobal()
BoosterController.ApplyTracked()
BackgroundMonitor.Refresh()
if not State.InitialScanDone and not State.InitialScanStarted then
BackgroundMonitor.ScanInitial()
end
end
Logger.Warn("ONE-CLICK MAX: todos os modulos suportados foram ativados", "CONFIG")
return true
end
function BoosterController.DisableAllOptions()
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported then AdaptivePolicy.Set(definition.Key, false) end
end
if State.Enabled then
table.clear(State.DistanceCulled)
OptimizerEngine.ApplyGlobal()
BoosterController.ApplyTracked()
BackgroundMonitor.Refresh()
end
Logger.Info("Todas as opcoes suportadas foram desativadas", "CONFIG")
end
function BoosterController.Enable()
if State.Enabled or not State.Running then return false end
State.Enabled = true
State.StartedAt = os.clock()
State.Tier = 0
State.Panic = false
State.RecoveryStartedAt = nil
QueueEngine.Clear()
Logger.Info("Ultra Potato V4 ativado", "SYSTEM")
OptimizerEngine.ApplyGlobal()
BackgroundMonitor.Start()
MetricsMonitor.Start()
AdaptiveController.Start()
BackgroundMonitor.Refresh()
if State.InitialScanDone then BoosterController.ApplyTracked()
else BackgroundMonitor.ScanInitial() end
return true
end
function BoosterController.Disable()
if not State.Enabled then
State.OneClickActive = false
return false
end
State.OneClickActive = false
State.Enabled = false
State.Panic = false
State.Tier = 0
State.RecoveryStartedAt = nil
BackgroundMonitor.Refresh()
State.ScanGeneration = State.ScanGeneration + 1
State.InitialScanStarted = false
State.InitialScanDone = false
QueueEngine.Clear()
DistanceEngine.Reset()
PropertyStore.RestoreAll()
Logger.Info("Booster desativado; propriedades ainda sob controle foram restauradas", "SYSTEM")
return true
end
function BoosterController.RestoreAll()
if State.Enabled then return BoosterController.Disable() end
PropertyStore.RestoreAll()
DistanceEngine.Reset()
return true
end
function BoosterController.ToggleAdaptive()
State.Adaptive = not State.Adaptive
if not State.Adaptive and State.Tier ~= 0 then AdaptiveController.ApplyTier(0, "Adaptativo desligado") end
Logger.Info("Adaptativo: " .. tostring(State.Adaptive), "ADAPTIVE")
end
function BoosterController.ToggleAutomatic()
State.Automatic = not State.Automatic
if not State.Automatic then
State.ScanGeneration = State.ScanGeneration + 1
State.InitialScanStarted = false
State.InitialScanDone = false
end
if State.Enabled then
BackgroundMonitor.Refresh()
if State.Automatic then BackgroundMonitor.ScanInitial() end
end
Logger.Info("Atualizacao automatica: " .. tostring(State.Automatic), "SYSTEM")
end
function BoosterController.PanicNow()
if not State.Enabled then return false end
AdaptiveController.ApplyTier(4, "Modo de emergencia acionado manualmente")
State.RecoveryStartedAt = nil
return true
end
function BoosterController.Shutdown()
if State.ShutdownStarted then return end
State.ShutdownStarted = true
if State.Enabled then BoosterController.Disable() end
State.Running = false
QueueEngine.Clear()
for name, connection in pairs(State.Connections) do
if connection then pcall(function() connection:Disconnect() end) end
State.Connections[name] = nil
end
BackgroundMonitor.DisconnectPlayers()
end
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported then
definition.ApplyHandler = function(instance)
return OptimizerEngine.ApplyInstance(instance)
end
definition.RestoreHandler = function(instance)
return PropertyStore.RestoreInstance(instance)
end
end
end
State.UserOverrides = {}
function AdaptivePolicy.IsActive(key)
local definition = DefinitionByKey[key]
if not definition or not definition.Supported then return false end
local override = State.UserOverrides[key]
if override ~= nil then return override end
if Options[key] == true then return true end
return State.Enabled and State.Adaptive and definition.RiskLevel ~= "HIGH"
and definition.AutoTier ~= nil and State.Tier >= definition.AutoTier
end
function AdaptivePolicy.Set(key, value)
local definition = DefinitionByKey[key]
if not definition or not definition.Supported then return false end
Options[key] = value == true
State.UserOverrides[key] = value == true
definition.CurrentValue = Options[key]
definition.LastApplied = os.clock()
return true
end
function ProfileManager.Apply(name, confirmed)
local profile = ProfileManager.Get(name)
if not profile then return false, "Perfil nao encontrado" end
local highImpact = false
for _, definition in ipairs(OptionDefinitions) do
if definition.RiskLevel == "HIGH" and profile[definition.Key] == true then highImpact = true; break end
end
if highImpact and not confirmed then return false, "CONFIRM_HIGH_IMPACT" end
table.clear(State.UserOverrides)
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported then
Options[definition.Key] = profile[definition.Key] == true
definition.CurrentValue = Options[definition.Key]
end
end
State.Profile = name
table.clear(State.DistanceCulled)
if State.Enabled then
OptimizerEngine.ApplyGlobal()
BoosterController.ApplyTracked()
BackgroundMonitor.Refresh()
end
Logger.Info("Perfil aplicado: " .. name, "PROFILE")
return true
end
local function Initialize()
if State.BootstrapStarted then
return State.Enabled
end
State.BootstrapStarted = true
local preserve = DefinitionByKey.PreserveLocalAvatar
if preserve then
preserve.Supported = false
preserve.UnsupportedReason = "Protecao fixa: o personagem local nunca e alterado."
end
local compatibility = DefinitionByKey.CoreCompatibilityMode
if compatibility then
compatibility.Supported = false
compatibility.UnsupportedReason = "pcall e verificacoes sao invariantes de seguranca."
end
if not LocalPlayer then
local deadline = os.clock() + 10
repeat
task.wait(0.1)
LocalPlayer = Players.LocalPlayer
until LocalPlayer or os.clock() >= deadline
end
if not LocalPlayer then
Logger.Error("LocalPlayer indisponivel; bootstrap cancelado", "BOOTSTRAP")
warn("[UltraPotato V4 AUTO] ERRO: LocalPlayer indisponivel. Execute depois de entrar completamente no jogo.")
return false
end
State.Running = true
State.Automatic = true
State.Adaptive = true
State.Profile = "ONE-CLICK MAX (AUTO)"
State.OneClickActive = true
table.clear(State.UserOverrides)
local supportedCount = 0
local unsupportedCount = 0
for _, definition in ipairs(OptionDefinitions) do
if definition.Supported then
if AdaptivePolicy.Set(definition.Key, true) then
supportedCount = supportedCount + 1
else
unsupportedCount = unsupportedCount + 1
end
else
unsupportedCount = unsupportedCount + 1
end
end
if script then
pcall(function()
if script.Destroying then
State.Connections.ScriptDestroying = script.Destroying:Connect(function()
BoosterController.Shutdown()
end)
end
end)
end
warn(string.format(
"[UltraPotato V4 AUTO] Iniciando ONE-CLICK MAX | opcoes=%d | ativadas=%d | indisponiveis=%d",
#OptionDefinitions,
supportedCount,
unsupportedCount
))
local callOk, enabled = pcall(function()
return BoosterController.Enable()
end)
if not callOk or enabled ~= true then
State.OneClickActive = false
pcall(function()
BoosterController.Disable()
end)
local reason = callOk and "BoosterController.Enable retornou false" or tostring(enabled)
Logger.Error("Falha ao ativar automaticamente: " .. reason, "BOOTSTRAP")
warn("[UltraPotato V4 AUTO] FALHA AO ATIVAR: " .. reason)
return false
end
Logger.Warn(
string.format("ONE-CLICK MAX automatico ativo: %d opcoes suportadas ativadas", supportedCount),
"BOOTSTRAP"
)
warn(string.format(
"[UltraPotato V4.2 AUTO] ATIVO | opcoes=%d | ativadas=%d | cache IsA=%d/%d",
#OptionDefinitions, supportedCount,
State.CacheStats.IsAHit, State.CacheStats.IsAMiss
))
return true
end
Initialize()A lightweight Roblox optimization script focused on reducing unnecessary graphical effects and improving client-side performance. Features Reduced shadows and lighting effects Texture and decal optimization Particle, beam and trail reduction Simplified visual effects Mesh and material adjustments Player character visual optimization Automatic optimization on execution No GUI or external dependencies Compatibility: Roblox Client Language: Luau Execution: Client-side Designed for low-end systems where performance takes priority over visual quality. Performance gains vary depending on the game, hardware and rendering limitations.

Universal