-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.txt
479 lines (352 loc) · 15.5 KB
/
text.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
-- Services
local Players = game:GetService("Players")
local ReSt = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local CG = game:GetService("CoreGui")
-- Variables
local Plr = Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local Camera = workspace.CurrentCamera
local StaticRushSpeed = 60
local FindPartOnRayWithIgnoreList = workspace.FindPartOnRayWithIgnoreList
local WorldToViewportPoint = Camera.WorldToViewportPoint
local SelfModules = {
DefaultConfig = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Doors%20Entity%20Spawner/DefaultConfig.lua"))(),
Functions = loadstring(game:HttpGet("https://raw.githubusercontent.com/RegularVynixu/Utilities/main/Functions.lua"))(),
}
local ModuleScripts = {
ModuleEvents = require(ReSt.ClientModules.Module_Events),
MainGame = require(Plr.PlayerGui.MainUI.Initiator.Main_Game),
}
local EntityConnections = {}
local Spawner = {}
-- Misc Functions
function getPlayerRoot()
return Char:FindFirstChild("HumanoidRootPart") or Char:FindFirstChild("Head")
end
function dragEntity(entityModel, pos, speed)
local entityConnections = EntityConnections[entityModel]
if entityConnections.movementNode then
entityConnections.movementNode:Disconnect()
end
entityConnections.movementNode = RS.Stepped:Connect(function(_, step)
if entityModel.Parent and not entityModel:GetAttribute("NoAI") then
local rootPos = entityModel.PrimaryPart.Position
local diff = Vector3.new(pos.X, pos.Y, pos.Z) - rootPos
if diff.Magnitude > 0.1 then
entityModel:SetPrimaryPartCFrame(CFrame.new(rootPos + diff.Unit * math.min(step * speed, diff.Magnitude)))
else
entityConnections.movementNode:Disconnect()
end
end
end)
repeat task.wait() until not entityConnections.movementNode.Connected
end
function loadSound(soundData)
local sound = Instance.new("Sound")
local soundId = tostring(soundData[1])
local properties = soundData[2]
for i, v in next, properties do
if i ~= "SoundId" and i ~= "Parent" then
sound[i] = v
end
end
if soundId:find("rbxasset://") then -- Custom audio
sound.SoundId = soundId
else
local numberId = soundId:gsub("%D", "")
sound.SoundId = "rbxassetid://".. numberId
end
sound.Parent = workspace
return sound
end
-- Functions
Spawner.createEntity = function(config)
for i, v in next, SelfModules.DefaultConfig do
if config[i] == nil then
config[i] = v
end
end
config.Speed = StaticRushSpeed / 100 * config.Speed
-- Model
local entityModel = LoadCustomInstance(config.Model)
if typeof(entityModel) == "Instance" and entityModel.ClassName == "Model" then
entityModel.PrimaryPart = entityModel.PrimaryPart or entityModel:FindFirstChildWhichIsA("BasePart")
if entityModel.PrimaryPart then
entityModel.PrimaryPart.Anchored = true
if config.CustomName then
entityModel.Name = config.CustomName
end
entityModel:SetAttribute("IsCustomEntity", true)
entityModel:SetAttribute("NoAI", false)
-- EntityTable
local entityTable = {
Model = entityModel,
Config = config,
Debug = {
OnEntitySpawned = function() end,
OnEntityDespawned = function() end,
OnEntityStartMoving = function() end,
OnEntityFinishedRebound = function() end,
OnEntityEnteredRoom = function() end,
OnLookAtEntity = function() end,
OnDeath = function() end
}
}
return entityTable
end
end
end
Spawner.runEntity = function(entityTable)
-- Nodes
local entityNodes = {}
for _, room in next, workspace.CurrentRooms:GetChildren() do
local nodes = room:WaitForChild("Nodes", 1)
if nodes then
nodes = nodes:GetChildren()
table.sort(nodes, function(a, b)
return a.Name < b.Name
end)
for _, node in next, nodes do
entityNodes[#entityNodes + 1] = node
end
end
end
-- Spawn
local entityModel = entityTable.Model:Clone()
local startNodeIndex = entityTable.Config.BackwardsMovement and #entityNodes or 1
local startNodeOffset = entityTable.Config.BackwardsMovement and -50 or 50
EntityConnections[entityModel] = {}
local entityConnections = EntityConnections[entityModel]
entityModel:SetPrimaryPartCFrame(entityNodes[startNodeIndex].CFrame * CFrame.new(0, 0, startNodeOffset) + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0))
entityModel.Parent = workspace
task.spawn(entityTable.Debug.OnEntitySpawned)
-- Mute entity on spawn
if CG:FindFirstChild("Jumpscare") or (Plr.PlayerGui.MainUI.Death.HelpfulDialogue.Visible and not Plr.PlayerGui.MainUI.DeathPanelDead.Visible) then
warn("on death screen, mute entity")
for _, v in next, entityModel:GetDescendants() do
if v.ClassName == "Sound" and v.Playing then
v:Stop()
end
end
end
-- Flickering
if entityTable.Config.FlickerLights[1] then
ModuleScripts.ModuleEvents.flickerLights(workspace.CurrentRooms[ReSt.GameData.LatestRoom.Value], entityTable.Config.FlickerLights[2])
end
-- Movement
task.wait(entityTable.Config.DelayTime)
local enteredRooms = {}
entityConnections.movementTick = RS.Stepped:Connect(function()
if entityModel.Parent and not entityModel:GetAttribute("NoAI") then
local entityPos = entityModel.PrimaryPart.Position
local rootPos = getPlayerRoot().Position
local floorRay = FindPartOnRayWithIgnoreList(workspace, Ray.new(entityPos, Vector3.new(0, -10, 0)), {entityModel, Char})
local playerInSight = FindPartOnRayWithIgnoreList(workspace, Ray.new(entityPos, rootPos - entityPos), {entityModel, Char}) == nil
-- Entered room
if floorRay ~= nil and floorRay.Name == "Floor" then
for _, room in next, workspace.CurrentRooms:GetChildren() do
if floorRay:IsDescendantOf(room) and not table.find(enteredRooms, room) then
enteredRooms[#enteredRooms + 1] = room
task.spawn(entityTable.Debug.OnEntityEnteredRoom, room)
-- Break lights
if entityTable.Config.BreakLights then
ModuleScripts.ModuleEvents.breakLights(room)
end
break
end
end
end
-- Camera shaking
local shakeConfig = entityTable.Config.CamShake
local shakeMag = (getPlayerRoot().Position - entityModel.PrimaryPart.Position).Magnitude
if shakeConfig[1] and shakeMag <= shakeConfig[3] then
local shakeRep = {}
for i, v in next, shakeConfig[2] do
shakeRep[i] = v
end
shakeRep[1] = shakeConfig[2][1] / shakeConfig[3] * (shakeConfig[3] - shakeMag)
ModuleScripts.MainGame.camShaker.ShakeOnce(ModuleScripts.MainGame.camShaker, table.unpack(shakeRep))
end
-- Player in sight
if playerInSight then
-- Look at entity
local _, onScreen = WorldToViewportPoint(Camera, entityModel.PrimaryPart.Position)
if onScreen then
task.spawn(entityTable.Debug.OnLookAtEntity)
end
-- Kill player
if entityTable.Config.CanKill and not Char:GetAttribute("IsDead") and not Char:GetAttribute("Invincible") and not Char:GetAttribute("Hiding") and (getPlayerRoot().Position - entityModel.PrimaryPart.Position).Magnitude <= entityTable.Config.KillRange then
task.spawn(function()
Char:SetAttribute("IsDead", true)
-- Mute entity
warn("mute entity")
for _, v in next, entityModel:GetDescendants() do
if v.ClassName == "Sound" and v.Playing then
v:Stop()
end
end
-- Jumpscare
if entityTable.Config.Jumpscare[1] then
Spawner.runJumpscare(entityTable.Config.Jumpscare[2])
end
-- Death handling
task.spawn(entityTable.Debug.OnDeath)
Hum.Health = 0
ReSt.GameStats["Player_".. Plr.Name].Total.DeathCause.Value = entityModel.Name
if #entityTable.Config.CustomDialog > 0 then
firesignal(ReSt.Bricks.DeathHint.OnClientEvent, entityTable.Config.CustomDialog)
end
-- Unmute entity
task.spawn(function()
repeat task.wait() until Plr.PlayerGui.MainUI.DeathPanelDead.Visible
warn("unmute entity:", entityModel)
for _, v in next, entityModel:GetDescendants() do
if v.ClassName == "Sound" then
local oldVolume = v.Volume
v.Volume = 0
v:Play()
TS:Create(v, TweenInfo.new(2), {Volume = oldVolume}):Play()
end
end
end)
end)
end
end
end
end)
task.spawn(entityTable.Debug.OnEntityStartMoving)
-- Cycles
local cyclesConfig = entityTable.Config.Cycles
if entityTable.Config.BackwardsMovement then
local inverseNodes = {}
for nodeIdx = #entityNodes, 1, -1 do
inverseNodes[#inverseNodes + 1] = entityNodes[nodeIdx]
end
entityNodes = inverseNodes
end
for cycle = 1, math.max(math.random(cyclesConfig.Min, cyclesConfig.Max), 1) do
for nodeIdx = 1, #entityNodes, 1 do
dragEntity(entityModel, entityNodes[nodeIdx].Position + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0), entityTable.Config.Speed)
end
if cyclesConfig.Max > 1 then
for nodeIdx = #entityNodes, 1, -1 do
dragEntity(entityModel, entityNodes[nodeIdx].Position + Vector3.new(0, 3.5 + entityTable.Config.HeightOffset, 0), entityTable.Config.Speed)
end
end
-- Rebound finished
task.spawn(entityTable.Debug.OnEntityFinishedRebound)
if cycle < cyclesConfig.Max then
task.wait(cyclesConfig.WaitTime)
end
end
-- Destroy
if not entityModel:GetAttribute("NoAI") then
for _, v in next, entityConnections do
v:Disconnect()
end
entityModel:Destroy()
task.spawn(entityTable.Debug.OnEntityDespawned)
end
end
Spawner.runJumpscare = function(config)
-- Variables
local image1 = LoadCustomAsset(config.Image1)
local image2 = LoadCustomAsset(config.Image2)
local sound1, sound2 = nil, nil
if config.Sound1 then
sound1 = loadSound(config.Sound1)
end
if config.Sound2 then
sound2 = loadSound(config.Sound2)
end
-- UI Construction
local Jumpscare = Instance.new("ScreenGui")
local Background = Instance.new("Frame")
local Face = Instance.new("ImageLabel")
Jumpscare.Name = "Jumpscare"
Jumpscare.IgnoreGuiInset = true
Jumpscare.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
Background.Name = "Background"
Background.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
Background.BorderSizePixel = 0
Background.Size = UDim2.new(1, 0, 1, 0)
Background.ZIndex = 999
Face.Name = "Face"
Face.AnchorPoint = Vector2.new(0.5, 0.5)
Face.BackgroundTransparency = 1
Face.Position = UDim2.new(0.5, 0, 0.5, 0)
Face.ResampleMode = Enum.ResamplerMode.Pixelated
Face.Size = UDim2.new(0, 150, 0, 150)
Face.Image = image1
Face.Parent = Background
Background.Parent = Jumpscare
Jumpscare.Parent = CG
-- Tease
local teaseConfig = config.Tease
local absHeight = Jumpscare.AbsoluteSize.Y
local minTeaseSize = absHeight / 5
local maxTeaseSize = absHeight / 2.5
if teaseConfig[1] then
local teaseAmount = math.random(teaseConfig.Min, teaseConfig.Max)
sound1:Play()
for _ = teaseConfig.Min, teaseAmount do
task.wait(math.random(100, 200) / 100)
local growFactor = (maxTeaseSize - minTeaseSize) / teaseAmount
Face.Size = UDim2.new(0, Face.AbsoluteSize.X + growFactor, 0, Face.AbsoluteSize.Y + growFactor)
end
task.wait(math.random(100, 200) / 100)
end
-- Flashing
if config.Flashing[1] then
task.spawn(function()
while Jumpscare.Parent do
Background.BackgroundColor3 = config.Flashing[2]
task.wait(math.random(25, 100) / 1000)
Background.BackgroundColor3 = Color3.new(0, 0, 0)
task.wait(math.random(25, 100) / 1000)
end
end)
end
-- Shaking
if config.Shake then
task.spawn(function()
local origin = Face.Position
while Jumpscare.Parent do
Face.Position = origin + UDim2.new(0, math.random(-10, 10), 0, math.random(-10, 10))
Face.Rotation = math.random(-5, 5)
task.wait()
end
end)
end
-- Jumpscare
Face.Image = image2
Face.Size = UDim2.new(0, maxTeaseSize, 0, maxTeaseSize)
sound2:Play()
TS:Create(Face, TweenInfo.new(0.75), {Size = UDim2.new(0, absHeight * 3, 0, absHeight * 3), ImageTransparency = 0.5}):Play()
task.wait(0.75)
Jumpscare:Destroy()
if sound1 then
sound1:Destroy()
end
if sound2 then
sound2:Destroy()
end
end
-- Scripts
task.spawn(function()
while true do
local inSession = false
for _, v in next, workspace:GetChildren() do
if v.Name == "RushMoving" or v.Name == "Exotic" or v:GetAttribute("IsCustomEntity") then
inSession = true
break
end
end
ReSt.GameData.ChaseInSession.Value = inSession
task.wait(0.5)
end
end)
return Spawner