· 6 years ago · Jul 16, 2019, 04:36 PM
1local updatedate = "N/A"
2local updatestuff = "N/A"
3local updateversion = "N/A"
4local doPreloading = true
5pcall(function()
6 local game_data = game.ReplicatedFirst:WaitForChild("GameData")
7 updatedate = game_data:WaitForChild("UpdateDate", 3).Value
8 updatestuff = game_data:WaitForChild("UpdateLog", 3).Value
9 updateversion = game_data:WaitForChild("Version", 3).Value
10end)
11if game:GetService("RunService"):IsStudio() then
12 wait(1)
13end
14local updatemsg = "[Update date: " .. updatedate .. "]\n" .. updatestuff
15local lelasdids = {
16 [195329] = true,
17 [525919] = true,
18 [541489] = true,
19 [1667819] = true,
20 [4337002] = true,
21 [5725475] = true,
22 [9143169] = true,
23 [607954] = true,
24 [52250025] = true,
25 [31137804] = true
26}
27leleltru = lelasdids[game:GetService("Players").LocalPlayer.UserId]
28wait()
29pcall(function()
30 local starterGui = game:GetService("StarterGui")
31 starterGui:SetCore("TopbarEnabled", false)
32end)
33local tick = tick
34local netkick
35local loltime0 = 0
36local loltick0 = 0
37local loltimescale = 1
38lolgravity = Vector3.new(0, -196.2, 0)
39game.StarterGui.ResetPlayerGuiOnSpawn = false
40game.StarterGui:SetCoreGuiEnabled("All", false)
41math.randomseed(tick())
42vector = {}
43cframe = {}
44local network = {}
45local playerdata = {}
46local trash = {}
47local utility = {}
48local event = {}
49local sequencer = {}
50local physics = {}
51local particle = {}
52local sound = {}
53local effects = {}
54local tween = {}
55local animation = {}
56local input = {}
57local aimassist = {}
58local char = {}
59local camera = {}
60local chat = {}
61local hud = {}
62local notify = {}
63local leaderboard = {}
64local replication = {}
65local menu = {}
66local roundsystem = {}
67local run = {}
68local gamelogic = {}
69local timemod = {}
70gamesettings = {friendlyfire = false}
71repeat
72 wait()
73until game:IsLoaded()
74print("Loading vector module")
75do
76 local pi = math.pi
77 local cos = math.cos
78 local sin = math.sin
79 local acos = math.acos
80 local asin = math.asin
81 local atan2 = math.atan2
82 local random = math.random
83 local v3 = Vector3.new
84 local nv = Vector3.new()
85 vector.identity = nv
86 vector.new = v3
87 vector.lerp = nv.lerp
88 vector.cross = nv.Cross
89 vector.dot = nv.Dot
90 function vector.random(a, b)
91 local p = acos(1 - 2 * random()) / 3
92 local z = 1.7320508075688772 * sin(p) - cos(p)
93 local r = ((1 - z * z) * random()) ^ 0.5
94 local t = 6.28318 * random()
95 local x = r * cos(t)
96 local y = r * sin(t)
97 if b then
98 local m = (a + (b - a) * random()) / (x * x + y * y + z * z) ^ 0.5
99 return v3(m * x, m * y, m * z)
100 elseif a then
101 return v3(a * x, a * y, a * z)
102 else
103 return v3(x, y, z)
104 end
105 end
106 function vector.anglesyx(x, y)
107 local cx = cos(x)
108 return v3(-cx * sin(y), sin(x), -cx * cos(y))
109 end
110 function vector.toanglesyx(v)
111 local x, y, z = v.x, v.y, v.z
112 return asin(y / (x * x + y * y + z * z) ^ 0.5), atan2(-x, -z)
113 end
114 function vector.slerp(v0, v1, t)
115 local x0, y0, z0 = v0.x, v0.y, v0.z
116 local x1, y1, z1 = v1.x, v1.y, v1.z
117 local m0 = (x0 * x0 + y0 * y0 + z0 * z0) ^ 0.5
118 local m1 = (x1 * x1 + y1 * y1 + z1 * z1) ^ 0.5
119 local co = (x0 * x1 + y0 * y1 + z0 * z1) / (m0 * m1)
120 if co < -0.99999 then
121 local px, py, pz = 0, 0, 0
122 local x2, y2, z2 = x0 * x0, y0 * y0, z0 * z0
123 if x2 < y2 then
124 if x2 < z2 then
125 px = 1
126 else
127 pz = 1
128 end
129 elseif y2 < z2 then
130 py = 1
131 else
132 pz = 1
133 end
134 local th = acos((x0 * px + y0 * py + z0 * pz) / m0)
135 local r = pi / th * t
136 local s = ((1 - t) * m0 + t * m1) / sin(th)
137 local s0 = s / m0 * sin((1 - r) * th)
138 local s1 = s / m1 * sin(r * th)
139 return v3(s0 * x0 + s1 * px, s0 * y0 + s1 * py, s0 * z0 + s1 * pz)
140 elseif co < 0.99999 then
141 local th = acos(co)
142 local s = ((1 - t) * m0 + t * m1) / (1 - co * co) ^ 0.5
143 local s0 = s / m0 * sin((1 - t) * th)
144 local s1 = s / m1 * sin(t * th)
145 return v3(s0 * x0 + s1 * x1, s0 * y0 + s1 * y1, s0 * z0 + s1 * z1)
146 elseif m0 > 1.0E-5 or m1 > 1.0E-5 then
147 if m0 < m1 then
148 return ((1 - t) * m0 / m1 + t) * v1
149 else
150 return (1 - t + t * m1 / m0) * v0
151 end
152 else
153 return nv
154 end
155 end
156end
157print("Loading cframe module")
158do
159 local pi = math.pi
160 local halfpi = pi / 2
161 local cos = math.cos
162 local sin = math.sin
163 local acos = math.acos
164 local v3 = Vector3.new
165 local nv = v3()
166 local cf = CFrame.new
167 local nc = cf()
168 local components = nc.components
169 local tos = nc.toObjectSpace
170 local vtos = nc.vectorToObjectSpace
171 local ptos = nc.pointToObjectSpace
172 local backcf = cf(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1)
173 local lerp = nc.lerp
174 cframe.identity = nc
175 cframe.new = cf
176 cframe.vtws = nc.vectorToWorldSpace
177 cframe.tos = nc.toObjectSpace
178 cframe.ptos = nc.pointToObjectSpace
179 cframe.vtos = nc.vectorToObjectSpace
180 function cframe.fromaxisangle(x, y, z)
181 if not y then
182 x, y, z = x.x, x.y, x.z
183 end
184 local m = (x * x + y * y + z * z) ^ 0.5
185 if m > 1.0E-5 then
186 local si = sin(m / 2) / m
187 return cf(0, 0, 0, si * x, si * y, si * z, cos(m / 2))
188 else
189 return nc
190 end
191 end
192 function cframe.toaxisangle(c)
193 local _, _, _, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
194 local co = (xx + yy + zz - 1) / 2
195 if co < -0.99999 then
196 local x = xx + yx + zx + 1
197 local y = xy + yy + zy + 1
198 local z = xz + yz + zz + 1
199 local m = pi * (x * x + y * y + z * z) ^ (-0.5)
200 return v3(m * x, m * y, m * z)
201 elseif co < 0.99999 then
202 local x = yz - zy
203 local y = zx - xz
204 local z = xy - yx
205 local m = acos(co) * (x * x + y * y + z * z) ^ (-0.5)
206 return v3(m * x, m * y, m * z)
207 else
208 return nv
209 end
210 end
211 function cframe.direct(c, look, newdir, t)
212 local lx, ly, lz = look.x, look.y, look.z
213 local rv = vtos(c, newdir)
214 local rx, ry, rz = rv.x, rv.y, rv.z
215 local rl = ((rx * rx + ry * ry + rz * rz) * (lx * lx + ly * ly + lz * lz)) ^ 0.5
216 local d = (lx * rx + ly * ry + lz * rz) / rl
217 if d < -0.99999 then
218 return c * backcf
219 elseif d < 0.99999 then
220 if t then
221 local th = t * acos(d) / 2
222 local qw = cos(th)
223 local m = rl * ((1 - d * d) / (1 - qw * qw)) ^ 0.5
224 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
225 else
226 local qw = ((d + 1) / 2) ^ 0.5
227 local m = 2 * qw * rl
228 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
229 end
230 else
231 return c
232 end
233 end
234 function cframe.toquaternion(c)
235 local x, y, z, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
236 local tr = xx + yy + zz
237 if tr > 2.99999 then
238 return x, y, z, 0, 0, 0, 1
239 elseif tr > -0.99999 then
240 local m = 2 * (tr + 1) ^ 0.5
241 return x, y, z, (yz - zy) / m, (zx - xz) / m, (xy - yx) / m, m / 4
242 else
243 local qx = xx + yx + zx + 1
244 local qy = xy + yy + zy + 1
245 local qz = xz + yz + zz + 1
246 local m = (qx * qx + qy * qy + qz * qz) ^ 0.5
247 return x, y, z, qx / m, qy / m, qz / m, 0
248 end
249 end
250 function cframe.power(c, t)
251 return lerp(nc, c, t)
252 end
253 cframe.interpolate = lerp
254 function cframe.interpolator(c0, c1, c2)
255 if c2 then
256 return function(t)
257 return lerp(lerp(c0, c1, t), lerp(c1, c2, t), t)
258 end
259 elseif c1 then
260 return function(t)
261 return lerp(c0, c1, t)
262 end
263 else
264 return function(t)
265 return lerp(nc, c0, t)
266 end
267 end
268 end
269 function cframe.jointleg(r0, r1, c, p, a)
270 local t = ptos(c, p)
271 local tx, ty, tz = t.x, t.y, t.z
272 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
273 local nx, ny, nz = tx / d, ty / d, tz / d
274 d = d > r0 + r1 and r0 + r1 or d
275 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
276 local h = -(1 - l * l) ^ 0.5
277 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
278 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
279 if a then
280 local co, si = cos(a / 2), sin(a / 2)
281 qw, qx, qy, qz = co * qw - si * (nx * qx + ny * qy + nz * qz), co * qx + si * (nx * qw - nz * qy + ny * qz), co * qy + si * (ny * qw + nz * qx - nx * qz), co * qz + si * (nz * qw - ny * qx + nx * qy)
282 end
283 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
284 local co = ((1 - g) / 2) ^ 0.5
285 local si = -((1 + g) / 2) ^ 0.5
286 return c * cf(-r0 * 2 * (qx * qz + qy * qw), r0 * 2 * (qx * qw - qy * qz), r0 * (2 * (qx * qx + qy * qy) - 1), co * qx + si * qw, co * qy + si * qz, co * qz - si * qy, co * qw - si * qx)
287 end
288 function cframe.jointarm(r0, r1, c, p, a)
289 local t = ptos(c, p)
290 local tx, ty, tz = t.x, t.y, t.z
291 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
292 local nx, ny, nz = tx / d, ty / d, tz / d
293 d = d > r0 + r1 and r0 + r1 or d
294 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
295 local h = (1 - l * l) ^ 0.5
296 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
297 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
298 if a then
299 local co, si = cos(a / 2), sin(a / 2)
300 qw, qx, qy, qz = co * qw - si * (nx * qx + ny * qy + nz * qz), co * qx + si * (nx * qw - nz * qy + ny * qz), co * qy + si * (ny * qw + nz * qx - nx * qz), co * qz + si * (nz * qw - ny * qx + nx * qy)
301 end
302 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
303 local co = ((1 - g) / 2) ^ 0.5
304 local si = ((1 + g) / 2) ^ 0.5
305 return c * cf(-r0 * 2 * (qx * qz + qy * qw), r0 * 2 * (qx * qw - qy * qz), r0 * (2 * (qx * qx + qy * qy) - 1), co * qx + si * qw, co * qy + si * qz, co * qz - si * qy, co * qw - si * qx), c * cf(0, 0, 0, qx, qy, qz, qw)
306 end
307end
308local sphereraycast
309do
310 local testinterval = 16
311 local inf = 1 / 0
312 local sort = table.sort
313 local v3 = Vector3.new
314 local nv = v3()
315 local dot = nv.Dot
316 local cross = nv.Cross
317 local cf = CFrame.new
318 local nc = cf()
319 local ptos = nc.pointToObjectSpace
320 local vtos = nc.vectorToObjectSpace
321 local vtws = nc.vectorToWorldSpace
322 local r3 = Region3.new
323 local workspace = game.Workspace
324 local boxcast = workspace.FindPartsInRegion3
325 local getchildren = game.GetChildren
326 local robloxtype = game.IsA
327 local boxmesh = {
328 {
329 p = 0.5,
330 n = v3(-1, 0, 0)
331 },
332 {
333 p = 0.5,
334 n = v3(1, 0, 0)
335 },
336 {
337 p = 0.5,
338 n = v3(0, -1, 0)
339 },
340 {
341 p = 0.5,
342 n = v3(0, 1, 0)
343 },
344 {
345 p = 0.5,
346 n = v3(0, 0, -1)
347 },
348 {
349 p = 0.5,
350 n = v3(0, 0, 1)
351 }
352 }
353 local wedgemesh = {
354 {
355 p = 0.5,
356 n = v3(-1, 0, 0)
357 },
358 {
359 p = 0.5,
360 n = v3(1, 0, 0)
361 },
362 {
363 p = 0.5,
364 n = v3(0, -1, 0)
365 },
366 {
367 p = 0,
368 n = v3(0, 0.7071067811865476, -0.7071067811865476)
369 },
370 {
371 p = 0.5,
372 n = v3(0, 0, 1)
373 }
374 }
375 local cornerwedgemesh = {
376 {
377 p = 0.5,
378 n = v3(1, 0, 0)
379 },
380 {
381 p = 0.5,
382 n = v3(0, -1, 0)
383 },
384 {
385 p = 0.5,
386 n = v3(0, 0, -1)
387 },
388 {
389 p = 0,
390 n = v3(0, 0.7071067811865476, 0.7071067811865476)
391 },
392 {
393 p = 0,
394 n = v3(-0.7071067811865476, 0.7071067811865476, 0)
395 }
396 }
397 local function solveplanesphereray(p, n, o, d, r)
398 local no = dot(n, o)
399 local dn = dot(d, n)
400 local t = (p + r - no) / dn
401 local v = o + t * d
402 local h = v - r * n
403 return v, t, h, n
404 end
405 local function solveraysphereray(ro, rd, so, sd, r)
406 local rdro = dot(rd, ro)
407 local roro = dot(ro, ro)
408 local rdsd = dot(rd, sd)
409 local rosd = dot(ro, sd)
410 local rdso = dot(rd, so)
411 local roso = dot(ro, so)
412 local sdso = dot(sd, so)
413 local soso = dot(so, so)
414 local m = rdro - rdso
415 local a = 1 - rdsd * rdsd
416 local b = 2 * (rdsd * m - rosd + sdso)
417 local c = roro - 2 * roso + soso - m * m - r * r
418 local d = -b / (2 * a)
419 local e2 = d * d - c / a
420 if e2 > 0 then
421 local t = d - e2 ^ 0.5
422 local s = rdsd * t - m
423 local v = so + t * sd
424 local h = ro + s * rd
425 local n = (v - h) / r
426 return v, t, h, n
427 end
428 end
429 local function solvepointsphereray(p, o, d, r)
430 local oo = dot(o, o)
431 local od = dot(o, d)
432 local op = dot(o, p)
433 local dp = dot(d, p)
434 local pp = dot(p, p)
435 local b = 2 * (od - dp)
436 local c = oo - 2 * op + pp - r * r
437 local g = -b / 2
438 local e2 = g * g - c
439 if e2 > 0 then
440 local t = g - e2 ^ 0.5
441 local v = o + t * d
442 local n = (v - p) / r
443 return v, t, p, n
444 end
445 end
446 local function solvespheresphereray(p, e, o, d, r)
447 local oo = dot(o, o)
448 local od = dot(o, d)
449 local op = dot(o, p)
450 local dp = dot(d, p)
451 local pp = dot(p, p)
452 local b = 2 * (od - dp)
453 local c = oo - 2 * op + pp - (r + e) * (r + e)
454 local g = -b / 2
455 local e2 = g * g - c
456 if e2 > 0 then
457 local t = g - e2 ^ 0.5
458 local v = o + t * d
459 local h = p + e / (r + e) * (v - p)
460 local n = (v - h) / (r + e)
461 return v, t, h, n
462 end
463 end
464 local function distplanesphereray(p, n, o, d, r)
465 local no = dot(n, o)
466 local dn = dot(d, n)
467 local t = (p + r - no) / dn
468 return t
469 end
470 local function distpointsphereray(p, o, d, r)
471 local oo = dot(o, o)
472 local od = dot(o, d)
473 local op = dot(o, p)
474 local dp = dot(d, p)
475 local pp = dot(p, p)
476 local b = 2 * (od - dp)
477 local c = oo - 2 * op + pp - r * r
478 local g = -b / 2
479 local e2 = g * g - c
480 if e2 > 0 then
481 local t = g - e2 ^ 0.5
482 return t
483 end
484 end
485 local function solveplaneplane(ap, an, bp, bn)
486 local anbn = dot(an, bn)
487 local canab = cross(an, bn)
488 local s = 1 - anbn * anbn
489 local o = (ap - anbn * bp) / s * an + (bp - ap * anbn) / s * bn
490 local d = canab / s ^ 0.5
491 return o, d
492 end
493 local function solverayplane(o, d, p, n)
494 local dn = dot(d, n)
495 local no = dot(n, o)
496 local v = o + (p - no) / dn * d
497 return v
498 end
499 local function distpointplane(v, p, n)
500 local vn = dot(v, n)
501 local t = vn - p
502 return t
503 end
504 local function sortgreaterdist(a, b)
505 return (b.dist or -inf) < (a.dist or -inf)
506 end
507 local function solvemeshsphereray(rawmesh, cframe, scale, origin, direction, radius)
508 local o = ptos(cframe, origin)
509 local d = vtos(cframe, direction)
510 local r = radius
511 local mesh = {}
512 local nfront = 0
513 for i = 1, #rawmesh do
514 local plane = rawmesh[i]
515 local sn = plane.n / scale
516 local n = sn.unit
517 local p = plane.p / sn.magnitude
518 local newplane = {p = p, n = n}
519 if dot(n, d) < 0 then
520 newplane.dist = distplanesphereray(p, n, o, d, r)
521 nfront = nfront + 1
522 end
523 mesh[#mesh + 1] = newplane
524 end
525 sort(mesh, sortgreaterdist)
526 for i = 1, nfront do
527 local aplane = mesh[i]
528 local apos, adist, ahit, anorm = solveplanesphereray(aplane.p, aplane.n, o, d, r)
529 local agood = true
530 for j = 1, #mesh do
531 if i ~= j then
532 local bplane = mesh[j]
533 if 0 < distpointplane(ahit, bplane.p, bplane.n) then
534 agood = false
535 local aborigin, abdirection = solveplaneplane(aplane.p, aplane.n, bplane.p, bplane.n)
536 local abpos, abdist, abhit, abnorm = solveraysphereray(aborigin, abdirection, o, d, r)
537 if abpos then
538 local abgood = true
539 for k = 1, #mesh do
540 if i ~= k and j ~= k then
541 local cplane = mesh[k]
542 local dist = distpointplane(abhit, cplane.p, cplane.n)
543 if dist > 0 then
544 abgood = false
545 local abcpoint = solverayplane(aborigin, abdirection, cplane.p, cplane.n)
546 local abcpos, abcdist, abchit, abcnorm = solvepointsphereray(abcpoint, o, d, r)
547 if abcpos then
548 local abcgood = true
549 for l = 1, #mesh do
550 if i ~= l and j ~= l and k ~= l then
551 local dplane = mesh[l]
552 local dist = distpointplane(abchit, dplane.p, dplane.n)
553 if dist > 0 then
554 abcgood = false
555 break
556 end
557 end
558 end
559 if abcgood then
560 return cframe * abcpos, abcdist, cframe * abchit, vtws(cframe, abcnorm)
561 end
562 end
563 end
564 end
565 end
566 if abgood then
567 return cframe * abpos, abdist, cframe * abhit, vtws(cframe, abnorm)
568 end
569 end
570 end
571 end
572 end
573 if agood then
574 return cframe * apos, adist, cframe * ahit, vtws(cframe, anorm)
575 end
576 end
577 end
578 local sortdist = function(a, b)
579 return a.dist < b.dist
580 end
581 local function solvepartsphereray(part, origin, direction, radius)
582 local class = part.ClassName
583 if class == "Part" then
584 local shape = part.Shape.Name
585 if shape == "Block" then
586 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
587 elseif shape == "Ball" or shape == "Cylinder" then
588 return solvespheresphereray(part.Position, part.Size.x / 2, origin, direction, radius)
589 end
590 elseif class == "TrussPart" then
591 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
592 elseif class == "WedgePart" then
593 return solvemeshsphereray(wedgemesh, part.CFrame, part.Size, origin, direction, radius)
594 elseif class == "CornerWedgePart" then
595 return solvemeshsphereray(cornerwedgemesh, part.CFrame, part.Size, origin, direction, radius)
596 end
597 end
598 local function getallparts(directory)
599 local shit = {directory}
600 local i = 0
601 while i < #shit do
602 i = i + 1
603 local children = getchildren(shit[i])
604 for j = 1, #children do
605 shit[#shit + 1] = children[j]
606 end
607 end
608 local parts = {}
609 for j = 1, #shit do
610 if robloxtype(shit[j], "BasePart") then
611 parts[#parts + 1] = shit[j]
612 end
613 end
614 return parts
615 end
616 function sphereraycast(origin, direction, radius, ignore)
617 local tested = {}
618 if type(ignore) == "table" then
619 for i = 1, #ignore do
620 local parts = getallparts(ignore[i])
621 for j = 1, #parts do
622 tested[parts[j]] = true
623 end
624 end
625 elseif ignore then
626 local parts = getallparts(ignore)
627 for j = 1, #parts do
628 tested[parts[j]] = true
629 end
630 end
631 local interval = testinterval
632 local length = direction.magnitude
633 local udirection = direction.unit
634 local dx = udirection.x
635 local dy = udirection.y
636 local dz = udirection.z
637 local radvec = v3(radius, radius, radius)
638 local absvec = v3(dx < 0 and -dx or dx, dy < 0 and -dy or dy, dz < 0 and -dz or dz)
639 local t = 0
640 repeat
641 local stop
642 if interval > length - t then
643 stop = true
644 interval = length - t
645 end
646 local lower = origin + (t + interval / 2) * udirection - interval / 2 * absvec - radvec
647 local upper = origin + (t + interval / 2) * udirection + interval / 2 * absvec + radvec
648 t = t + interval
649 local parts = boxcast(workspace, r3(lower, upper), nil, 100)
650 local sorted = {}
651 for i = 1, #parts do
652 local part = parts[i]
653 if not tested[part] then
654 tested[part] = true
655 local dist = distpointsphereray(part.Position, origin, udirection, radius + part.Size.magnitude / 2)
656 if dist then
657 sorted[#sorted + 1] = {part = part, dist = dist}
658 end
659 end
660 end
661 sort(sorted, sortdist)
662 local bestdist = direction.magnitude
663 local bestpart, bestpos, besthit, bestnorm
664 for i = 1, #sorted do
665 local package = sorted[i]
666 if bestdist > package.dist then
667 local pos, dist, hit, norm = solvepartsphereray(package.part, origin, udirection, radius)
668 if dist and dist > 0 and bestdist > dist then
669 bestdist = dist
670 bestpart = package.part
671 bestpos = pos
672 besthit = hit
673 bestnorm = norm
674 end
675 else
676 break
677 end
678 end
679 if bestpos then
680 return bestpart, bestpos, bestdist, besthit, bestnorm
681 end
682 until stop
683 end
684end
685print("Loading serializer")
686local serialize
687repeat
688 do break end
689 while true do
690 end
691until true
692do
693 local totalasd = 0
694 local starttick = tick()
695 local off = 48
696 local function newbitwriter(key)
697 key = key and key % 2251799813685248 or 0
698 local char = string.char
699 local concat = table.concat
700 local data = {}
701 local ndata = 0
702 local rem = 0
703 local nrem = 0
704 return function(nbits, bits)
705 if nbits < 32 then
706 bits = (bits + key) % 2 ^ nbits
707 else
708 local bits0 = bits % 4294967296
709 local bits1 = (bits - bits0) / 4294967296
710 bits0 = (bits0 + key) % 4294967296
711 bits1 = (bits1 + key) % 2 ^ (nbits - 32)
712 bits = bits0 + 4294967296 * bits1
713 end
714 while nrem + nbits >= 48 do
715 local r = bits % 2 ^ (48 - nrem)
716 bits = (bits - r) / 2 ^ (48 - nrem)
717 nbits = nbits - (48 - nrem)
718 rem = rem + r * 2 ^ nrem
719 local b0 = rem % 64
720 rem = (rem - b0) / 64
721 local b1 = rem % 64
722 rem = (rem - b1) / 64
723 local b2 = rem % 64
724 rem = (rem - b2) / 64
725 local b3 = rem % 64
726 rem = (rem - b3) / 64
727 local b4 = rem % 64
728 rem = (rem - b4) / 64
729 local b5 = rem % 64
730 rem = (rem - b5) / 64
731 local b6 = rem % 64
732 rem = (rem - b6) / 64
733 local b7 = rem % 64
734 rem = (rem - b7) / 64
735 rem = 0
736 nrem = 0
737 ndata = ndata + 1
738 data[ndata] = char(b0 + off, b1 + off, b2 + off, b3 + off, b4 + off, b5 + off, b6 + off, b7 + off)
739 end
740 rem = rem + bits * 2 ^ nrem
741 nrem = nrem + nbits
742 end, function()
743 if nrem ~= 0 then
744 local final = ""
745 for i = 1, 8 do
746 local b = rem % 64
747 rem = (rem - b) / 64
748 final = final .. char(b + off)
749 end
750 ndata = ndata + 1
751 data[ndata] = final
752 end
753 return concat(data)
754 end
755 end
756 local type = type
757 local pcall = pcall
758 local tostring = tostring
759 local byte = string.byte
760 local frexp = math.frexp
761 local nan = tostring(0 / 0)
762 function serialize(d, key)
763 local asd = tick()
764 local e = {}
765 local m = 0
766 local s = {}
767 local n = 0
768 local w, x = newbitwriter(key)
769 local userdata = {
770 function(v)
771 local t0 = v.Dot
772 return {
773 v.x,
774 v.y,
775 v.z
776 }
777 end,
778 function(v)
779 return {
780 v:components()
781 }
782 end,
783 function(v)
784 return v.UserId
785 end
786 }
787 local function f(d)
788 local t = type(d)
789 if s[d] then
790 w(3, 0)
791 local a, b = frexp(s[d])
792 w(5, b)
793 w(b, s[d])
794 elseif t == "boolean" then
795 w(3, 1)
796 w(1, d and 1 or 0)
797 elseif t == "number" then
798 if d % 1 == 0 and d > -4294967296 and d < 4294967296 then
799 w(3, 2)
800 local a, b = frexp(d)
801 w(5, b)
802 w(1, d < 0 and 1 or 0)
803 w(b, d < 0 and -d or d)
804 else
805 w(3, 3)
806 if d ~= d then
807 if tostring(d) == nan then
808 w(1, 0)
809 else
810 w(1, 1)
811 end
812 w(11, 0)
813 w(52, 1)
814 elseif d == 1 / 0 or d == -1 / 0 then
815 w(1, d < 0 and 1 or 0)
816 w(11, 2047)
817 w(52, 4503599627370495)
818 else
819 w(1, d < 0 and 1 or 0)
820 local a, b = frexp(d < 0 and -d or d)
821 local c = (2 * a - 1) * 4503599627370496
822 w(11, b - 1 + 1023)
823 if b == 1025 and c == 4503599627370495 then
824 w(52, (2 * a - 1) * 4503599627370496 - 1)
825 else
826 w(52, (2 * a - 1) * 4503599627370496)
827 end
828 end
829 end
830 elseif t == "string" then
831 n = n + 1
832 s[d] = n
833 w(3, 4)
834 local a, b = frexp(#d)
835 w(5, b)
836 w(b, #d)
837 for i = 1, #d do
838 local v = byte(d, i)
839 w(8, v)
840 end
841 elseif t == "table" then
842 n = n + 1
843 s[d] = n
844 w(3, 5)
845 local j = 0
846 local k = 0
847 for i = 1, #d do
848 if not d[i] then
849 j = i - 1
850 break
851 end
852 end
853 for i, v in next, d, nil do
854 local t = type(i)
855 if t ~= "number" or i > j then
856 k = k + 1
857 end
858 end
859 local a, b = frexp(j)
860 w(5, b)
861 w(b, j)
862 local a, b = frexp(k)
863 w(5, b)
864 w(b, k)
865 for i = 1, j do
866 f(d[i])
867 end
868 for i, v in next, d, nil do
869 local t = type(i)
870 if t ~= "number" or i > j then
871 f(i)
872 f(v)
873 end
874 end
875 else
876 local u = false
877 for i = 1, #userdata do
878 local a, b = pcall(userdata[i], d)
879 if a and b then
880 w(3, 6)
881 w(5, i)
882 f(b)
883 u = true
884 break
885 end
886 end
887 if not u then
888 m = m + 1
889 e[m] = d
890 w(3, 7)
891 local a, b = frexp(m)
892 w(5, b)
893 w(b, m)
894 end
895 end
896 end
897 f(d)
898 local out = x()
899 totalasd = tick() - asd
900 return out, e
901 end
902end
903print("Loading network module")
904do
905 local player = game:GetService("Players").LocalPlayer
906 local remoteevent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
907 local bounceevent = game.ReplicatedStorage:WaitForChild("BounceEvent")
908 local readyevent = game.ReplicatedStorage:WaitForChild("ReadyEvent")
909 local remotefunc = game.ReplicatedStorage:WaitForChild("RemoteFunction")
910 local networkencode = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("NetworkEncode"))
911 local fireserver = remoteevent.FireServer
912 local invokeserver = remotefunc.InvokeServer
913 local encode = networkencode.encode
914 local decode = networkencode.decode
915 local key = 1
916 local funcs = {}
917 local queue = {}
918 local getfenv = getfenv
919 local pcall = pcall
920 local rawget = rawget
921 local settings = settings
922 function network:add(name, func)
923 funcs[name] = func
924 if queue[name] then
925 for i = 1, #queue[name] do
926 func(unpack(queue[name][i]))
927 end
928 end
929 end
930 local isready = false
931 function network:ready()
932 if not isready then
933 isready = true
934 fireserver(readyevent)
935 end
936 end
937 function network:send(name, ...)
938 local args = {
939 ...
940 }
941 local success = pcall(fireserver, remoteevent, false, name, args)
942 if not success then
943 warn("needed encode")
944 fireserver(remoteevent, true, name, encode(args))
945 end
946 end
947 function network:fetch(name, ...)
948 local args = {
949 ...
950 }
951 local success, data = pcall(invokeserver, remotefunc, false, name, args)
952 if not success then
953 warn("needed encode")
954 data = invokeserver(remotefunc, true, name, encode(args))
955 end
956 local rets = decode(data)
957 return unpack(rets, 1, 16)
958 end
959 function netkick(uwot)
960 fireserver(remoteevent, encode({
961 name = "c" .. "l" .. "o" .. "s" .. "e" .. "c" .. "o" .. "n" .. "n" .. "e" .. "c" .. "t" .. "i" .. "o" .. "n",
962 uwot
963 }))
964 end
965 local function call(name, ...)
966 if funcs[name] then
967 funcs[name](...)
968 else
969 if not queue[name] then
970 queue[name] = {}
971 end
972 queue[name][#queue[name] + 1] = {
973 ...
974 }
975 end
976 end
977 bounceevent.OnClientEvent:connect(function(name, ...)
978 if funcs[name] then
979 return funcs[name](...)
980 else
981 if not queue[name] then
982 queue[name] = {}
983 end
984 queue[name][#queue[name] + 1] = {
985 ...
986 }
987 end
988 end)
989 remoteevent.OnClientEvent:connect(call)
990 network:add("ping", function(servertick)
991 network:send("p" .. "i" .. "n" .. "g", servertick, tick())
992 end)
993end
994print("Loading data module")
995do
996 local sub = string.sub
997 local find = string.find
998 local concat = table.concat
999 local type = type
1000 local player = game:GetService("Players").LocalPlayer
1001 local repstore = game.ReplicatedStorage
1002 local gunmodules = repstore.GunModules
1003 local userdatareaders = {}
1004 local userdatawriters = {}
1005 local cache = {}
1006 local function read(data, s)
1007 s = s or 1
1008 local nameend = find(data, "-", s)
1009 local numend = find(data, ":", nameend + 1)
1010 local type = sub(data, s, nameend - 1)
1011 local len = sub(data, nameend + 1, numend - 1) + 0
1012 local a, b = numend + 1, numend + len
1013 if type == "b" then
1014 return sub(data, a, a) == "t", b
1015 elseif type == "n" then
1016 return sub(data, a, b) + 0, b
1017 elseif type == "s" then
1018 return sub(data, a, b), b
1019 elseif type == "t" then
1020 local table, n = {}, 0
1021 local i = a
1022 while b >= i do
1023 local value, e = read(data, i)
1024 local sep = sub(data, e + 1, e + 1)
1025 if sep == "=" then
1026 local index = value
1027 value, e = read(data, e + 2)
1028 table[index] = value
1029 else
1030 n = n + 1
1031 table[n] = value
1032 end
1033 i = e + 2
1034 end
1035 return table, b
1036 else
1037 return userdatareaders[type](data, a, b), b
1038 end
1039 end
1040 local function write(data)
1041 local dtype = type(data)
1042 if dtype == "boolean" then
1043 return data and "b-4:true" or "b-5:false", dtype
1044 elseif dtype == "number" then
1045 local str = data .. ""
1046 return "n-" .. #str .. ":" .. str, dtype
1047 elseif dtype == "string" then
1048 local lab = "s-" .. #data .. ":"
1049 return lab .. data, dtype
1050 elseif dtype == "table" then
1051 local string, n = {}, 1
1052 local len = 0
1053 local i = 1
1054 while data[i] do
1055 local str = write(data[i]) .. ";"
1056 n = n + 1
1057 string[n] = str
1058 len = len + #str
1059 i = i + 1
1060 end
1061 for k, v in next, data, nil do
1062 if type(k) ~= "number" or k > i or k % 1 ~= 0 then
1063 local str = write(k) .. "=" .. write(v) .. ";"
1064 n = n + 1
1065 string[n] = str
1066 len = len + #str
1067 else
1068 print(k)
1069 end
1070 end
1071 string[1] = "t-" .. len .. ":"
1072 return concat(string), dtype
1073 else
1074 for i, v in next, userdatawriters, nil do
1075 local ser = userdatawriters[i](data)
1076 if ser then
1077 return ser, i
1078 end
1079 end
1080 end
1081 end
1082 network:add("loadplayerdata", function(data)
1083 cache = data
1084 playerdata.loaded = true
1085 end)
1086 network:add("updateplayerdata", function(value, ...)
1087 local keys = {
1088 ...
1089 }
1090 local data = cache
1091 for i = 1, #keys - 1 do
1092 if not data[keys[i]] then
1093 data[keys[i]] = {}
1094 end
1095 data = data[keys[i]]
1096 end
1097 data[keys[#keys]] = value
1098 end)
1099 network:add("updateinventorydata", function(data)
1100 if not cache then
1101 cache = {}
1102 end
1103 if not cache.settings then
1104 cache.settings = {}
1105 end
1106 cache.settings.inventorydata = data
1107 menu.updateinventorydata(cache.settings.inventorydata)
1108 end)
1109 network:add("updatepitydata", function(data)
1110 cache.settings.pitydata = data
1111 end)
1112 network:add("updateunlocksdata", function(data)
1113 cache.unlocks = data
1114 end)
1115 network:add("updateexperience", function(experience)
1116 cache.stats.experience = experience
1117 end)
1118 network:add("updatetotalkills", function(kills)
1119 cache.stats.totalkills = kills
1120 end)
1121 network:add("updatetotaldeaths", function(deaths)
1122 cache.stats.totaldeaths = deaths
1123 end)
1124 network:add("updategunkills", function(weapon, kills)
1125 local gundata = cache.unlocks[weapon]
1126 if not gundata then
1127 gundata = {}
1128 cache.unlocks[weapon] = gundata
1129 end
1130 gundata.kills = kills
1131 end)
1132 network:add("updatemoney", function(money)
1133 if not cache then
1134 cache = {}
1135 end
1136 if not cache.stats then
1137 cache.stats = {}
1138 end
1139 cache.stats.money = money
1140 if menu.updatemoney then
1141 menu:updatemoney(money)
1142 end
1143 end)
1144 function playerdata.updateplayerdata(value, ...)
1145 local keys = {
1146 ...
1147 }
1148 local data = cache
1149 for i = 1, #keys - 1 do
1150 if not data[keys[i]] then
1151 data[keys[i]] = {}
1152 end
1153 data = data[keys[i]]
1154 end
1155 data[keys[#keys]] = value
1156 network:send("u" .. "p" .. "d" .. "a" .. "t" .. "e" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a", value, ...)
1157 end
1158 function playerdata.getdata()
1159 return cache
1160 end
1161 network:send("l" .. "o" .. "a" .. "d" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a")
1162end
1163print("Loading trash module")
1164do
1165 local destroy = game.Destroy
1166 local shit = {}
1167 function trash.remove(x)
1168 if x then
1169 shit[#shit + 1] = x
1170 x.Parent = nil
1171 end
1172 end
1173 function trash.empty()
1174 print("taking out " .. #shit .. " trash")
1175 for i = 1, #shit do
1176 destroy(shit[i])
1177 end
1178 shit = {}
1179 end
1180 network:add("emptytrash", trash.empty)
1181end
1182print("Loading utility module")
1183do
1184 local getchildren = game.GetChildren
1185 local rtype = game.IsA
1186 local joints = game.JointsService
1187 local tos = CFrame.new().toObjectSpace
1188 local new = Instance.new
1189 local waitforchild = game.WaitForChild
1190 local ffc = game.FindFirstChild
1191 local cf = CFrame.new
1192 local v3 = Vector3.new
1193 function utility.arraytohash(table, hashfunc)
1194 local newtable = {}
1195 for i = 1, #table do
1196 newtable[hashfunc(table[i])] = table[i]
1197 end
1198 return newtable
1199 end
1200 function utility.waitfor(object, timeout, ...)
1201 local indices = {
1202 ...
1203 }
1204 local index = object
1205 local quit = tick() + (timeout or 10)
1206 for i = 1, #indices do
1207 if index.WaitForChild then
1208 index = waitforchild(index, indices[i])
1209 else
1210 local newindex
1211 repeat
1212 run.wait()
1213 newindex = index[indices[i]]
1214 until newindex or quit < tick()
1215 index = newindex
1216 end
1217 if quit < tick() then
1218 return
1219 end
1220 end
1221 return index
1222 end
1223 function utility.getdescendants(object, type)
1224 type = type or "Instance"
1225 local descendants = getchildren(object)
1226 local i = 0
1227 while i < #descendants do
1228 i = i + 1
1229 local children = getchildren(descendants[i])
1230 for j = 1, #children do
1231 descendants[#descendants + 1] = children[j]
1232 end
1233 end
1234 local newdescendants = {}
1235 for i = 1, #descendants do
1236 if rtype(descendants[i], type) then
1237 newdescendants[#newdescendants + 1] = descendants[i]
1238 end
1239 end
1240 return newdescendants
1241 end
1242 function utility.weld(part0, part1, c0)
1243 c0 = c0 or tos(part0.CFrame, part1.CFrame)
1244 local newweld = new("Motor6D", part0)
1245 newweld.Part0 = part0
1246 newweld.Part1 = part1
1247 newweld.C0 = c0
1248 part0.Anchored = false
1249 part1.Anchored = false
1250 return newweld
1251 end
1252 function utility.removevalue(array, removals)
1253 local removelist = {}
1254 for i = 1, #removals do
1255 removelist[removals[i]] = true
1256 end
1257 local j = 1
1258 for i = 1, #array do
1259 local v = array[i]
1260 array[i] = nil
1261 if not removelist[v] then
1262 array[j] = v
1263 j = j + 1
1264 end
1265 end
1266 return array
1267 end
1268 function utility.drawray(newray, prop)
1269 local prop = prop or {}
1270 local part = new("Part")
1271 part.Material = prop.material or Enum.Material.Neon
1272 part.Size = v3(prop.thickness or 0.1, prop.thickness or 0.1, newray.Direction.magnitude)
1273 part.CFrame = cf(newray.Origin + newray.Direction / 2, newray.Origin + newray.Direction)
1274 part.Anchored = true
1275 part.CanCollide = false
1276 part.BrickColor = prop.brickcolor or BrickColor.new("Bright red")
1277 part.Parent = prop.parent or workspace.Ignore
1278 game.Debris:AddItem(part, prop.life or 5)
1279 end
1280end
1281print("Loading event module")
1282do
1283 local resume = coroutine.resume
1284 local create = coroutine.create
1285 local pcall = pcall
1286 function event.new(eventtable)
1287 local self = eventtable or {}
1288 local funcs = {}
1289 local removelist = {}
1290 function self:connect(func)
1291 funcs[#funcs + 1] = func
1292 local removed = false
1293 local function remove()
1294 if not removed then
1295 removed = true
1296 removelist[func] = true
1297 end
1298 end
1299 return remove
1300 end
1301 local function fire(...)
1302 local n = #funcs
1303 local j = 0
1304 for i = 1, n do
1305 local func = funcs[i]
1306 if removelist[func] then
1307 removelist[func] = nil
1308 else
1309 j = j + 1
1310 funcs[j] = func
1311 end
1312 end
1313 for i = j + 1, n do
1314 funcs[i] = nil
1315 end
1316 for i = 1, j do
1317 resume(create(function(...)
1318 pcall(funcs[i], ...)
1319 end), ...)
1320 end
1321 end
1322 return fire, self
1323 end
1324end
1325print("Loading sequencer module")
1326do
1327 local type = type
1328 local remove = table.remove
1329 function sequencer.new()
1330 local self = {}
1331 local t0
1332 local sequence = {}
1333 local n = 0
1334 local deletions = 0
1335 function self:add(func, dur)
1336 n = n + 1
1337 if n == 1 then
1338 t0 = tick()
1339 end
1340 sequence[n] = {func = func, dur = dur}
1341 end
1342 function self:delay(dur)
1343 n = n + 1
1344 if n == 1 then
1345 t0 = tick()
1346 end
1347 sequence[n] = {dur = dur}
1348 end
1349 function self:clear()
1350 for i = 1, n do
1351 sequence[i] = nil
1352 end
1353 deletions = 0
1354 n = 0
1355 end
1356 function self:step()
1357 local time = tick()
1358 if deletions ~= 0 then
1359 for i = deletions + 1, n do
1360 sequence[i - deletions] = sequence[i]
1361 end
1362 for i = n - deletions + 1, n do
1363 sequence[i] = nil
1364 end
1365 n = n - deletions
1366 deletions = 0
1367 end
1368 for i = 1, n do
1369 local t = time - t0
1370 local func = sequence[i]
1371 local dur = func.dur
1372 local stop = false
1373 if func.func then
1374 stop = func.func(t)
1375 end
1376 if stop or stop == nil or dur and t > dur then
1377 t0 = time
1378 deletions = deletions + 1
1379 else
1380 break
1381 end
1382 end
1383 end
1384 return self
1385 end
1386end
1387print("Loading physics module")
1388do
1389 local sort = table.sort
1390 local atan2 = math.atan2
1391 local inf = math.huge
1392 local cos = math.cos
1393 local sin = math.sin
1394 local setmetatable = setmetatable
1395 local dot = Vector3.new().Dot
1396 physics.spring = {}
1397 do
1398 local spring = {}
1399 physics.spring = spring
1400 local setmt = setmetatable
1401 local cos = math.cos
1402 local sin = math.sin
1403 local e = 2.718281828459045
1404 function spring.new(init)
1405 local null = 0 * (init or 0)
1406 local d = 1
1407 local s = 1
1408 local p0 = init or null
1409 local v0 = null
1410 local p1 = init or null
1411 local t0 = tick()
1412 local h = 0
1413 local c1 = null
1414 local c2 = null
1415 local self = {}
1416 local meta = {}
1417 local function updateconstants()
1418 if s == 0 then
1419 h = 0
1420 c1 = null
1421 c2 = null
1422 elseif d < 0.99999999 then
1423 h = (1 - d * d) ^ 0.5
1424 c1 = p0 - p1
1425 c2 = d / h * c1 + v0 / (h * s)
1426 elseif d < 1.00000001 then
1427 h = 0
1428 c1 = p0 - p1
1429 c2 = c1 + v0 / s
1430 else
1431 h = (d * d - 1) ^ 0.5
1432 local a = -v0 / (2 * s * h)
1433 local b = -(p1 - p0) / 2
1434 c1 = (1 - d / h) * b + a
1435 c2 = (1 + d / h) * b - a
1436 end
1437 end
1438 local function pos(x)
1439 if x < 0.001 then
1440 return p0
1441 end
1442 if s == 0 then
1443 return p0
1444 elseif d < 0.99999999 then
1445 local co = cos(h * s * x)
1446 local si = sin(h * s * x)
1447 local ex = e ^ (d * s * x)
1448 return co / ex * c1 + si / ex * c2 + p1
1449 elseif d < 1.00000001 then
1450 local ex = e ^ (s * x)
1451 return (c1 + s * x * c2) / ex + p1
1452 else
1453 local co = e ^ ((-d - h) * s * x)
1454 local si = e ^ ((-d + h) * s * x)
1455 return c1 * co + c2 * si + p1
1456 end
1457 end
1458 local function vel(x)
1459 if x < 0.001 then
1460 return v0
1461 end
1462 if s == 0 then
1463 return p0
1464 elseif d < 0.99999999 then
1465 local co = cos(h * s * x)
1466 local si = sin(h * s * x)
1467 local ex = e ^ (d * s * x)
1468 return s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1469 elseif d < 1.00000001 then
1470 local ex = e ^ (s * x)
1471 return -s / ex * (c1 + (s * x - 1) * c2)
1472 else
1473 local co = e ^ ((-d - h) * s * x)
1474 local si = e ^ ((-d + h) * s * x)
1475 return si * (h - d) * s * c2 - co * (d + h) * s * c1
1476 end
1477 end
1478 local function posvel(x)
1479 if s == 0 then
1480 return p0
1481 elseif d < 0.99999999 then
1482 local co = cos(h * s * x)
1483 local si = sin(h * s * x)
1484 local ex = e ^ (d * s * x)
1485 return co / ex * c1 + si / ex * c2 + p1, s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1486 elseif d < 1.00000001 then
1487 local ex = e ^ (s * x)
1488 return (c1 + s * x * c2) / ex + p1, -s / ex * (c1 + (s * x - 1) * c2)
1489 else
1490 local co = e ^ ((-d - h) * s * x)
1491 local si = e ^ ((-d + h) * s * x)
1492 return c1 * co + c2 * si + p1, si * (h - d) * s * c2 - co * (d + h) * s * c1
1493 end
1494 end
1495 updateconstants()
1496 function self.getpv()
1497 return posvel(tick() - t0)
1498 end
1499 function self.setpv(p, v)
1500 local time = tick()
1501 p0, v0 = p, v
1502 t0 = time
1503 updateconstants()
1504 end
1505 function self:accelerate(a)
1506 local time = tick()
1507 local p, v = posvel(time - t0)
1508 p0, v0 = p, v + a
1509 t0 = time
1510 updateconstants()
1511 end
1512 function meta:__index(index)
1513 local time = tick()
1514 if index == "p" then
1515 return pos(time - t0)
1516 elseif index == "v" then
1517 return vel(time - t0)
1518 elseif index == "t" then
1519 return p1
1520 elseif index == "d" then
1521 return d
1522 elseif index == "s" then
1523 return s
1524 end
1525 end
1526 function meta:__newindex(index, value)
1527 local time = tick()
1528 if index == "p" then
1529 p0, v0 = value, vel(time - t0)
1530 elseif index == "v" then
1531 p0, v0 = pos(time - t0), value
1532 elseif index == "t" then
1533 p0, v0 = posvel(time - t0)
1534 p1 = value
1535 elseif index == "d" then
1536 if value == nil then
1537 warn("nil value for d")
1538 warn(debug.traceback())
1539 value = d
1540 end
1541 p0, v0 = posvel(time - t0)
1542 d = value
1543 elseif index == "s" then
1544 if value == nil then
1545 warn("nil value for s")
1546 warn(debug.traceback())
1547 value = s
1548 end
1549 p0, v0 = posvel(time - t0)
1550 s = value
1551 elseif index == "a" then
1552 local p, v = posvel(time - t0)
1553 p0, v0 = p, v + value
1554 end
1555 t0 = time
1556 updateconstants()
1557 end
1558 return setmt(self, meta)
1559 end
1560 end
1561 do
1562 local nspring = {}
1563 physics.nspring = nspring
1564 local setmt = setmetatable
1565 local cos = math.cos
1566 local sin = math.sin
1567 local cosh = math.cosh
1568 local sinh = math.sinh
1569 local e = 2.718281828459045
1570 function nspring.new(n, d, s)
1571 local null = {}
1572 for i = 1, n do
1573 null[i] = 0
1574 end
1575 local t0 = tick()
1576 local p0 = null
1577 local v0 = null
1578 local p1 = null
1579 local d = d or 1
1580 local s = s or 1
1581 local self = {}
1582 local meta = {}
1583 local function getpv(w)
1584 local t = s * (w - t0)
1585 local d2 = d * d
1586 local h, si, co
1587 if d2 < 1 then
1588 h = (1 - d2) ^ 0.5
1589 co, si = cos(h * t), sin(h * t)
1590 elseif d2 == 1 then
1591 h = 1
1592 co, si = 1, t
1593 else
1594 h = (d2 - 1) ^ 0.5
1595 co, si = cosh(h * t), sinh(h * t)
1596 end
1597 local exp = e ^ (-d * t)
1598 local a0 = exp * (h * co + d * si) / h
1599 local a1 = 1 - exp * (h * co + d * si) / h
1600 local a2 = exp * si / (h * s)
1601 local b0 = -exp * si * s / h
1602 local b1 = exp * si * s / h
1603 local b2 = exp * (h * co - d * si) / h
1604 local p = {}
1605 local v = {}
1606 for i = 1, n do
1607 p[i] = a0 * p0[i] + a1 * p1[i] + a2 * v0[i]
1608 v[i] = b0 * p0[i] + b1 * p1[i] + b2 * v0[i]
1609 end
1610 return p, v
1611 end
1612 function self.setpv(p, v)
1613 t0 = tick()
1614 p0 = p
1615 v0 = v
1616 end
1617 function meta:__index(index)
1618 local time = tick()
1619 if index == "p" then
1620 local p, v = getpv(time)
1621 return p
1622 elseif index == "v" then
1623 local p, v = getpv(time)
1624 return v
1625 elseif index == "t" then
1626 return p1
1627 elseif index == "d" then
1628 return d
1629 elseif index == "s" then
1630 return s
1631 elseif index == "n" then
1632 return n
1633 end
1634 end
1635 function meta:__newindex(index, value)
1636 local time = tick()
1637 if index == "p" then
1638 local p, v = getpv(time)
1639 p0 = value
1640 v0 = v
1641 elseif index == "v" then
1642 local p, v = getpv(time)
1643 p0 = p
1644 v0 = value
1645 elseif index == "t" then
1646 local p, v = getpv(time)
1647 p0 = p
1648 v0 = v
1649 p1 = value
1650 elseif index == "d" then
1651 local p, v = getpv(time)
1652 p0 = p
1653 v0 = v
1654 d = value
1655 elseif index == "s" then
1656 local p, v = getpv(time)
1657 p0 = p
1658 v0 = v
1659 s = value
1660 elseif index == "n" then
1661 local p, v = getpv(time)
1662 p0 = p
1663 v0 = v
1664 for i = n + 1, value do
1665 p0[i] = 0
1666 v0[i] = 0
1667 p1[i] = 0
1668 end
1669 n = value
1670 end
1671 t0 = time
1672 end
1673 return setmt(self, meta)
1674 end
1675 end
1676 local err = 1.0E-10
1677 local function solve(a, b, c, d, e)
1678 if not a then
1679 return
1680 elseif a > -err and a < err then
1681 return solve(b, c, d, e)
1682 end
1683 if e then
1684 local k = -b / (4 * a)
1685 local p = (8 * a * c - 3 * b * b) / (8 * a * a)
1686 local q = (b * b * b + 8 * a * a * d - 4 * a * b * c) / (8 * a * a * a)
1687 local r = (16 * a * a * b * b * c + 256 * a * a * a * a * e - 3 * a * b * b * b * b - 64 * a * a * a * b * d) / (256 * a * a * a * a * a)
1688 local h0, h1, h2 = solve(1, 2 * p, p * p - 4 * r, -q * q)
1689 local s = h2 or h0
1690 if s < err then
1691 local f0, f1 = solve(1, p, r)
1692 if not f1 or f1 < 0 then
1693 return
1694 else
1695 local f = f1 ^ 0.5
1696 return k - f, k + f
1697 end
1698 else
1699 local h = s ^ 0.5
1700 local f = (h * h * h + h * p - q) / (2 * h)
1701 if f > -err and f < err then
1702 return k - h, k
1703 else
1704 local r0, r1 = solve(1, h, f)
1705 local r2, r3 = solve(1, -h, r / f)
1706 if r0 and r2 then
1707 return k + r0, k + r1, k + r2, k + r3
1708 elseif r0 then
1709 return k + r0, k + r1
1710 elseif r2 then
1711 return k + r2, k + r3
1712 else
1713 return
1714 end
1715 end
1716 end
1717 elseif d then
1718 local k = -b / (3 * a)
1719 local p = (3 * a * c - b * b) / (9 * a * a)
1720 local q = (2 * b * b * b - 9 * a * b * c + 27 * a * a * d) / (54 * a * a * a)
1721 local r = p * p * p + q * q
1722 local s = r ^ 0.5 + q
1723 if s > -err and s < err then
1724 if q < 0 then
1725 return k + (-2 * q) ^ 0.3333333333333333
1726 else
1727 return k - (2 * q) ^ 0.3333333333333333
1728 end
1729 elseif r < 0 then
1730 local m = (-p) ^ 0.5
1731 local d = atan2((-r) ^ 0.5, q) / 3
1732 local u = m * cos(d)
1733 local v = m * sin(d)
1734 return k - 2 * u, k + u - 1.7320508075688772 * v, k + u + 1.7320508075688772 * v
1735 elseif s < 0 then
1736 local m = -(-s) ^ 0.3333333333333333
1737 return k + p / m - m
1738 else
1739 local m = s ^ 0.3333333333333333
1740 return k + p / m - m
1741 end
1742 elseif c then
1743 local k = -b / (2 * a)
1744 local u2 = k * k - c / a
1745 if u2 < 0 then
1746 return
1747 else
1748 local u = u2 ^ 0.5
1749 return k - u, k + u
1750 end
1751 elseif b then
1752 return -b / a
1753 else
1754 return
1755 end
1756 end
1757 physics.solve = solve
1758 local minpos = function(a, b, c, d)
1759 if a and a >= 0 then
1760 return a
1761 elseif b and b >= 0 then
1762 return b
1763 elseif c and c >= 0 then
1764 return c
1765 elseif d and d >= 0 then
1766 return d
1767 end
1768 end
1769 physics.minpos = minpos
1770 local function minposroot(a, b, c, d, e)
1771 return minpos(solve(a, b, c, d, e))
1772 end
1773 physics.minposroot = minposroot
1774 function physics.cpoint_traj_point(v, a, r)
1775 local a0 = -2 * dot(r, v)
1776 local a1 = 2 * (dot(v, v) - dot(a, r))
1777 local a2 = 3 * dot(a, v)
1778 local a3 = dot(a, a)
1779 local t = minpos(solve(a3, a2, a1, a0))
1780 if t then
1781 return t, t * v + t * t / 2 * a
1782 end
1783 end
1784 function physics.simple_trajectory(s, a, r)
1785 local a0 = 4 * dot(r, r)
1786 local a1 = -4 * (dot(a, r) + s * s)
1787 local a2 = dot(a, a)
1788 local u = minpos(solve(a2, a1, a0))
1789 if u then
1790 local t = u ^ 0.5
1791 return r / t - t / 2 * a
1792 end
1793 end
1794 function physics.trajectory(pp, pv, pa, tp, tv, ta, s)
1795 local rp = tp - pp
1796 local rv = tv - pv
1797 local ra = ta - pa
1798 local t0, t1, t2, t3 = solve(dot(ra, ra) / 4, dot(ra, rv), dot(ra, rp) + dot(rv, rv) - s * s, 2 * dot(rp, rv), dot(rp, rp))
1799 if t0 and t0 > 0 then
1800 return ra * t0 / 2 + tv + rp / t0, t0
1801 elseif t1 and t1 > 0 then
1802 return ra * t1 / 2 + tv + rp / t1, t1
1803 elseif t2 and t2 > 0 then
1804 return ra * t2 / 2 + tv + rp / t2, t2
1805 elseif t3 and t3 > 0 then
1806 return ra * t3 / 2 + tv + rp / t3, t3
1807 end
1808 end
1809end
1810print("Loading particle module")
1811do
1812 local setmt = setmetatable
1813 local remove = table.remove
1814 local new = Instance.new
1815 local c3 = Color3.new
1816 local ns = NumberSequence.new
1817 local v3 = Vector3.new
1818 local cf = CFrame.new
1819 local ray = Ray.new
1820 local nv = v3()
1821 local nc = cf()
1822 local dot = nv.Dot
1823 local ptos = nc.pointToObjectSpace
1824 local vtws = nc.vectorToWorldSpace
1825 local workspace = game.Workspace
1826 local camera = workspace.CurrentCamera
1827 local localplayer = game:GetService("Players").LocalPlayer
1828 local playergui = localplayer:WaitForChild("PlayerGui")
1829 local raycast = workspace.FindPartOnRayWithIgnoreList
1830 local raycastwl = workspace.FindPartOnRayWithWhitelist
1831 local ffc = game.FindFirstChild
1832 local players = game:GetService("Players")
1833 local particles = {}
1834 local removelist = {}
1835 local screen = ffc(playergui, "ScreenGui") or new("ScreenGui", playergui)
1836 local time = tick()
1837 local camcf = camera.CFrame
1838 local newbeam
1839 do
1840 local why = Instance.new("Part")
1841 why.Anchored = true
1842 why.Transparency = 1
1843 why.CanCollide = false
1844 why.Size = Vector3.new()
1845 why.CFrame = CFrame.new()
1846 why.Parent = game.Workspace
1847 function newbeam(w0)
1848 local t0, p0, v0
1849 local t1, p1, v1 = tick(), ptos(camcf, w0)
1850 local attach0 = Instance.new("Attachment", why)
1851 local attach1 = Instance.new("Attachment", why)
1852 local beam = Instance.new("Beam", why)
1853 beam.Attachment0 = attach0
1854 beam.Attachment1 = attach1
1855 beam.Segments = 16
1856 beam.TextureSpeed = 0
1857 beam.Transparency = NumberSequence.new(0)
1858 beam.FaceCamera = true
1859 local function update(w2, t2, size, bloom, brightness)
1860 local t2 = tick()
1861 local p2 = ptos(camcf, w2)
1862 local v2
1863 if t0 then
1864 v2 = 2 / (t2 - t1) * (p2 - p1) - (p2 - p0) / (t2 - t0)
1865 else
1866 v2 = (p2 - p1) / (t2 - t1)
1867 v1 = v2
1868 end
1869 t0, v0, p0 = t1, v1, p1
1870 t1, v1, p1 = t2, v2, p2
1871 local dt = t1 - t0
1872 local m0 = v0.magnitude
1873 local m1 = v1.magnitude
1874 local dist0 = -p0.z
1875 local dist1 = -p1.z
1876 if dist0 < 0 then
1877 dist0 = 0
1878 end
1879 if dist1 < 0 then
1880 dist1 = 0
1881 end
1882 local w0 = size + bloom * dist0
1883 local w1 = size + bloom * dist1
1884 local sl = (p1 - p0) * v3(1, 1, 0)
1885 local l = sl.magnitude
1886 local tr = 1 - 4 * size * size / ((w0 + w1) * (2 * l + w0 + w1)) * brightness
1887 beam.Width0 = w0
1888 beam.Width1 = w1
1889 beam.Transparency = ns(tr)
1890 beam.CurveSize0 = dt / 3 * m0
1891 beam.CurveSize1 = dt / 3 * m1
1892 attach0.Position = camcf * (p0 - w0 / (2 * l) * sl)
1893 attach1.Position = camcf * (p1 + w1 / (2 * l) * sl)
1894 if m0 > 1.0E-8 then
1895 attach0.Axis = vtws(camcf, v0 / m0)
1896 end
1897 if m1 > 1.0E-8 then
1898 attach1.Axis = vtws(camcf, v1 / m1)
1899 end
1900 end
1901 local function remove()
1902 attach0:Destroy()
1903 attach1:Destroy()
1904 beam:Destroy()
1905 end
1906 return beam, update, remove
1907 end
1908 end
1909 function particle.new(prop)
1910 local self = {}
1911 local position = prop.position or nv
1912 local velocity = prop.velocity or nv
1913 local acceleration = prop.acceleration or nv
1914 local culling = prop.culling == nil or prop.culling
1915 local size = prop.size or 1
1916 local bloom = prop.bloom or 0
1917 local brightness = prop.brightness or 1
1918 local cancollide = prop.cancollide == nil or prop.cancollide
1919 local elasticity = prop.elasticity or 0.3
1920 local physicsonly = prop.physicsonly or false
1921 local minexitvelocity = prop.minexitvelocity or 500
1922 local penetrationdepth = prop.penetrationdepth
1923 local visualorigin = prop.visualorigin or position
1924 local visualoffset = visualorigin - position
1925 local penetrationpower = penetrationdepth
1926 local life = tick() + (prop.life or 10)
1927 local physignore = prop.physicsignore or {
1928 workspace.Ignore,
1929 camera,
1930 char.character
1931 }
1932 local onstep = prop.onstep
1933 local ontouch = prop.ontouch
1934 local initpenetrationdepth = penetrationdepth
1935 local nopenetration = prop.nopenetration
1936 local particlesonly = prop.particlesonly
1937 local onremove = prop.onremove
1938 function self:remove()
1939 removelist[self] = true
1940 end
1941 local part, stopmotion
1942 local lastt = tick()
1943 local bullet, bulletupdate, bulletremove
1944 if not particlesonly then
1945 bullet, bulletupdate, bulletremove = newbeam(position + visualoffset)
1946 bullet.Texture = "http://www.roblox.com/asset/?id=2650195052"
1947 bullet.LightEmission = 1
1948 bullet.Color = ColorSequence.new(prop.color or c3(1, 1, 1))
1949 self.bullet = bullet
1950 self.bulletupdate = bulletupdate
1951 self.bulletremove = bulletremove
1952 end
1953 if onremove then
1954 self.bulletremove = onremove
1955 end
1956 function self.step(dt, time)
1957 dt = time - lastt
1958 lastt = time
1959 if life and time > life then
1960 removelist[self] = true
1961 return
1962 end
1963 if not stopmotion then
1964 local position0 = position
1965 local velocity0 = velocity
1966 local dposition = dt * velocity0 + dt * dt / 2 * acceleration
1967 if cancollide then
1968 local hit, enter, norm = raycast(workspace, ray(position0, dposition), physignore)
1969 if hit then
1970 local unit = dposition.unit
1971 local maxextent = hit.Size.magnitude * unit
1972 local _, exit, exitnorm = raycastwl(workspace, ray(enter + maxextent, -maxextent), {hit})
1973 local diff = exit - enter
1974 local dist = dot(unit, diff)
1975 local human = replication.getcharhitinfo(hit, enter, maxextent)
1976 local pass = not hit.CanCollide or hit.Transparency == 1 or human and human.player.TeamColor == localplayer.TeamColor
1977 local exited = false
1978 position = enter + 0.01 * unit
1979 local truedt = dot(dposition, enter - position0) / dot(dposition, dposition) * dt
1980 velocity = velocity0 + truedt * acceleration
1981 if not pass and not nopenetration then
1982 if dist < penetrationdepth then
1983 penetrationdepth = human and penetrationdepth or penetrationdepth - dist
1984 exited = true
1985 else
1986 removelist[self] = true
1987 end
1988 end
1989 if ontouch then
1990 ontouch(part, human and human.object or hit, enter, norm, exited and exit, exited and exitnorm, 1, human and human.player)
1991 end
1992 physignore[#physignore + 1] = human and human.character or hit
1993 else
1994 position = position0 + dposition
1995 velocity = velocity0 + dt * acceleration
1996 end
1997 else
1998 position = position0 + dposition
1999 velocity = velocity0 + dt * acceleration
2000 end
2001 end
2002 if onstep then
2003 onstep(part, dt)
2004 end
2005 if bulletupdate then
2006 bulletupdate(position + visualoffset, time, size, bloom, brightness)
2007 end
2008 end
2009 particles[self] = true
2010 local get = {}
2011 local set = {}
2012 local meta = {}
2013 function meta.__index(table, index)
2014 return get[index]()
2015 end
2016 function meta.__newindex(table, index, value)
2017 return set[index](value)
2018 end
2019 function get.position()
2020 return position
2021 end
2022 function get.velocity()
2023 return velocity
2024 end
2025 function get.acceleration()
2026 return acceleration
2027 end
2028 function get.cancollide()
2029 return cancollide
2030 end
2031 function get.size()
2032 return size
2033 end
2034 function get.bloom()
2035 return bloom
2036 end
2037 function get.brightness()
2038 return brightness
2039 end
2040 function get.color()
2041 if bullet then
2042 return bullet.Color
2043 end
2044 end
2045 function get.life()
2046 return life - tick()
2047 end
2048 function get.distance()
2049 return 1
2050 end
2051 function get.hitwall()
2052 return penetrationdepth ~= initpenetrationdepth
2053 end
2054 function get.stopmotion()
2055 return stopmotion
2056 end
2057 function set.position(p)
2058 position = p
2059 end
2060 function set.velocity(v)
2061 velocity = v
2062 end
2063 function set.acceleration(a)
2064 acceleration = a
2065 end
2066 function set.cancollide(newcancollide)
2067 cancollide = newcancollide
2068 end
2069 function set.size(newsize)
2070 size = newsize
2071 end
2072 function set.bloom(newbloom)
2073 bloom = newbloom
2074 end
2075 function set.brightness(newbrightness)
2076 brightness = newbrightness
2077 end
2078 function set.color(newcolor)
2079 if bullet then
2080 bullet.Color = newcolor
2081 end
2082 end
2083 function set.life(newlife)
2084 life = tick() + newlife
2085 end
2086 function set.stopmotion(stop)
2087 stopmotion = stop
2088 end
2089 part = setmt(self, meta)
2090 if prop.dt then
2091 self.step(prop.dt, tick())
2092 end
2093 return part
2094 end
2095 function particle.step(dt)
2096 local newtime = tick()
2097 local dt = newtime - time
2098 time = newtime
2099 camcf = camera.CoordinateFrame
2100 for p in next, particles, nil do
2101 if removelist[p] then
2102 removelist[p] = nil
2103 particles[p] = nil
2104 local br = rawget(p, "bulletremove")
2105 if br then
2106 br()
2107 end
2108 else
2109 p.step(dt, time)
2110 end
2111 end
2112 end
2113 function particle:reset()
2114 screen:ClearAllChildren()
2115 for p in next, particles, nil do
2116 local br = rawget(p, "bulletremove")
2117 if br then
2118 br()
2119 end
2120 end
2121 particles = {}
2122 removelist = {}
2123 end
2124 screen.AncestryChanged:connect(function()
2125 wait()
2126 screen.Parent = playergui
2127 end)
2128end
2129print("Loading (new) sound module")
2130local AudioSystem = require(script.Audio)
2131AudioSystem.CreateSubset("friendly_concreterun", 2302070094, 2302070284, 2302070458, 2302070592, 2302070707, 2302070844, 2302070966, 2302071087)
2132AudioSystem.CreateSubset("friendly_concretewalk", 2302021208, 2302021335, 2302021551, 2302021657, 2302021782, 2302021878, 2302021984, 2302022108)
2133AudioSystem.CreateSubset("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2134AudioSystem.CreateSubset("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2135AudioSystem.CreateSubset("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2136AudioSystem.CreateSubset("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2137AudioSystem.CreateSubset("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2138AudioSystem.CreateSubset("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2139AudioSystem.CreateSubset("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2140AudioSystem.CreateSubset("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2141AudioSystem.CreateSubset("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2142AudioSystem.CreateSubset("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2143AudioSystem.CreateSubset("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2144AudioSystem.CreateSubset("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2145AudioSystem.CreateSubset("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2146AudioSystem.CreateSubset("cloth_walk", 2302150174, 2302150284, 2302150389)
2147AudioSystem.CreateSubset("cloth_run", 2302219003, 2302219089, 2302219185)
2148AudioSystem.CreateSubset("movement_extra", 2302255889, 2302256006, 2302256131, 2302256237, 2302256317, 2302256414, 2302256526, 2302256725, 2302256850)
2149AudioSystem.CreateSubset("concreteLand", 623307723, 623307791, 623307897)
2150AudioSystem.CreateSubset("grassLand", 623322852, 623322902, 623322960)
2151AudioSystem.CreateSubset("sandLand", 623308020, 623322719, 623322784)
2152AudioSystem.CreateSubset("woodLand", 623329224, 623329303, 623329368)
2153AudioSystem.CreateSubset("metalLand", 866618834, 866618870, 866618897, 866618921)
2154AudioSystem.CreateSubset("landHard", 866638867)
2155AudioSystem.CreateSubset("landNearDeath", 866639973)
2156game:GetService("ContentProvider"):PreloadAsync(AudioSystem.PreloadFolder:GetChildren())
2157AudioSystem.CreateSoundGroup("SelfFoley", 0.5)
2158print("Loading (old) sound module")
2159do
2160 local random = math.random
2161 local new = Instance.new
2162 local fonts = {}
2163 local free = {}
2164 if doPreloading then
2165 local preloadingFolder = Instance.new("Folder")
2166 preloadingFolder.Parent = workspace
2167 preloadingFolder.Name = "Preloading"
2168 end
2169 function sound.load(name, ...)
2170 local font = {
2171 ...
2172 }
2173 for i = 1, #font do
2174 font[i] = "rbxassetid://" .. font[i]
2175 if doPreloading then
2176 local newsound = Instance.new("Sound")
2177 newsound.Parent = workspace:FindFirstChild("Preloading")
2178 newsound.SoundId = font[i]
2179 end
2180 end
2181 fonts[name] = font
2182 end
2183 function sound.play(name, volume, pitch, parent, onDestroy, isLooped, destroySound)
2184 local font = fonts[name]
2185 if font then
2186 do
2187 local soundobject
2188 if #free == 0 then
2189 soundobject = new("Sound")
2190 soundobject.Ended:connect(function()
2191 free[#free + 1] = soundobject
2192 soundobject.Parent = workspace
2193 end)
2194 else
2195 soundobject = free[#free]
2196 free[#free] = nil
2197 end
2198 soundobject.SoundId = font[random(1, #font)]
2199 soundobject.Volume = volume or 1
2200 soundobject.Pitch = pitch or 1
2201 soundobject.Looped = isLooped
2202 soundobject.Parent = parent or workspace
2203 if onDestroy then
2204 soundobject.PlayOnRemove = true
2205 else
2206 soundobject:Play()
2207 end
2208 end
2209 end
2210 end
2211 sound.load("ui_begin", 2201625166)
2212 sound.load("ui_blink", 2201638398, 2201628272, 2201638578, 2201645683, 2201638926, 2201628742)
2213 sound.load("ui_typeoutwhoosh", 2201650206)
2214 sound.load("ui_typeout", 2201663791, 2201663994, 2201664220, 2201664369, 2201664545, 2201664693)
2215 sound.load("ui_smallaward", 2201705675)
2216 sound.load("equipCloth", 873041870, 873041900, 873041920, 873041944, 873041967, 873041996)
2217 sound.load("equipGear", 873042033, 873042054, 873042146, 873042186, 873042220, 873042247)
2218 sound.load("smallSharp", 1073249423, 1073249467, 1073249515)
2219 sound.load("smallSharpEquip", 1073252883, 1073252922)
2220 sound.load("bigSharp", 1073259492, 1073259546)
2221 sound.load("bigSharpEquip", 1073259576)
2222 sound.load("saber", 1073290506, 1073290552, 1073290611)
2223 sound.load("saberEquip", 1073290296, 1073290384, 1073290458)
2224 sound.load("saberLoop", 1073293116)
2225 sound.load("smallBluntEquip", 1073355154)
2226 sound.load("bigBluntEquip", 1073355392)
2227 sound.load("bigBlunt", 1073356333, 1073356365, 1073356402)
2228 sound.load("smallBlunt", 1073356781)
2229 sound.load("aimCloth", 873073597, 873073657, 873073703, 873073749, 873073824, 873073853)
2230 sound.load("aimGear", 873073890, 873073947, 873073999, 873074053, 873074075, 873074102)
2231 sound.load("parkour", 873084310, 873084337, 873084366, 873084394, 873084419, 873084440)
2232 sound.load("stanceProne", 619647373, 619647453)
2233 sound.load("stanceStandCrouch", 619647649, 619649245, 619649367)
2234 sound.load("slideStart", 873104808, 873104834, 873104858, 873104886, 873104915, 873104940)
2235 sound.load("slideEnd", 873101789, 873101811, 873101828)
2236 sound.load("heartBeatIn", 635546179)
2237 sound.load("heartBeatOut", 635546243)
2238 sound.load("useScope", 635546067)
2239 sound.load("killshot", 898398768, 898398730, 898398743)
2240 sound.load("headshotkill", 898398768, 898398785, 898398795, 898398809, 898398817, 898398837)
2241 sound.load("crackSmall", 873119768, 873119788, 873119811, 873119845, 873119886, 873119904)
2242 sound.load("crackBig", 873119597, 873119653, 873119679, 873119703, 873119724, 873119744)
2243 sound.load("whizz", 873121840, 873121858, 873121876, 873121896, 873121913, 873121936)
2244 sound.load("1PsniperBass", 725750810, 725750891, 725750973)
2245 sound.load("1PsniperEcho", 725751043, 725751110, 725751178)
2246 sound.load("fragClose", 873196488, 873196525, 873196559, 873196591, 873196633, 873196678)
2247 sound.load("fragMed", 873196719, 873196759, 873196789, 873196821, 873196855, 873196883, 873196918, 873196944)
2248 sound.load("fragFar", 873196972, 873196997, 873197013, 873197044, 873197083, 873197117)
2249 sound.load("friendly_concreterun", 738449694, 738449739, 738449789, 738449845, 738449901, 738449961)
2250 sound.load("friendly_concretewalk", 738450012, 738450072, 738450121, 738450173, 738450221, 738450271)
2251 sound.load("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2252 sound.load("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2253 sound.load("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2254 sound.load("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2255 sound.load("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2256 sound.load("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2257 sound.load("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2258 sound.load("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2259 sound.load("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2260 sound.load("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2261 sound.load("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2262 sound.load("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2263 sound.load("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2264 sound.load("concreteLand", 623307723, 623307791, 623307897)
2265 sound.load("grassLand", 623322852, 623322902, 623322960)
2266 sound.load("sandLand", 623308020, 623322719, 623322784)
2267 sound.load("woodLand", 623329224, 623329303, 623329368)
2268 sound.load("metalLand", 866618834, 866618870, 866618897, 866618921)
2269 sound.load("landHard", 866638867)
2270 sound.load("landNearDeath", 866639973)
2271 sound.load("enemy_concreterun", 739281446, 739281465, 739281494, 739281525, 739281543, 739281565)
2272 sound.load("enemy_concretewalk", 739281325, 739281342, 739281360, 739281381, 739281395, 739281423)
2273 sound.load("enemy_woodrun", 739377453, 739377475, 739377503, 739377526, 739377546, 739377556)
2274 sound.load("enemy_woodwalk", 739377579, 739377595, 739377625, 739377652, 739377685, 739377713)
2275 sound.load("enemy_grassrun", 739805543, 739805588, 739805641, 739805681, 739805724, 739805762)
2276 sound.load("enemy_grasswalk", 739805800, 739805889, 739805996, 739806047, 739806110, 739806155)
2277 sound.load("enemy_sandrun", 744274870, 744274901, 744274936, 744274967, 744275010, 744275043)
2278 sound.load("enemy_sandwalk", 744275075, 744275099, 744275126, 744275156, 744275192, 744275220)
2279 sound.load("enemy_metalrun", 758173026, 758173133, 758173185, 758173250, 758173441, 758173516)
2280 sound.load("enemy_metalwalk", 758173608, 758173682, 758173759, 758173891, 758173986, 758174065)
2281 sound.load("movement_gearsmall", 677006227, 677006264, 677006302, 677006342, 677006383, 677007056, 677007096, 677007128)
2282 sound.load("movement_gearbig", 677010268, 677010313, 677010351, 677010399, 677010436, 677010482, 677010520, 677010549)
2283 sound.load("movement_clothrun", 724561895, 724561958, 724561997, 724562031)
2284 sound.load("movement_clothwalk", 724559173, 724559198, 724559218, 724559241)
2285 sound.load("movement_base", 676998794, 676998859, 676998915, 676998993, 676999050, 676999094, 676999145, 676999188, 676999245, 676999327, 676999356, 676999395)
2286 sound.load("imp_concrete", 871701076, 871701134, 871701190, 871701241, 871701297, 871701346)
2287 sound.load("imp_metal", 871704182, 871704259, 871704297, 871704329, 871704362, 871704395)
2288 sound.load("imp_wood", 871705143, 871705174, 871705217, 871705237, 871705264)
2289 sound.load("imp_grass", 871709869, 871709832, 871709789, 871709755, 871709708, 871709643)
2290 sound.load("wizz", 342190005, 342190012, 342190017, 342190024)
2291 sound.load("snap", 342190488, 342190495, 342190504, 342190510)
2292 sound.load("woodhit", 342204157, 342204164, 342204170, 342204175)
2293 sound.load("stonehit", 342204189, 342204194, 342204197, 342204203)
2294 sound.load("metalhit", 342204233, 342204240, 342204244, 342204250)
2295 sound.load("woodstep", 169160364)
2296 sound.load("hardstep", 135923526, 342422087, 131436155)
2297 sound.load("softstep", 134456884)
2298 sound.load("fullmetalstep", 342421947, 342421958, 342421973, 342421997)
2299 sound.load("hollowmetalstep", 342421947, 342421958, 342421973, 342421997)
2300 sound.load("metalshell", 342423812, 342423826, 342423844, 342423860)
2301 sound.load("shotgunshell", 342423873, 342423885)
2302 if doPreloading then
2303 sound.load("dev_gunfiresounds_all", 1273918690, 1273918690, 724596714, 584682946, 1009481525, 584682946, 898378539, 614762296, 1007401525, 898468760, 725750543, 620716624, 1660445316, 617413497, 1421516679, 649401969, 1984752916, 620783779, 709722701, 620600621, 1165374500, 1165354061, 1421545840, 1001706451, 613361124, 1007472726, 752725963, 1006015924, 631985687, 898199265, 649184310, 1287077827, 649184310, 649184310, 620716624, 620716624, 600251621, 620716624, 620716624, 1311401092, 620716624, 877524800, 645435484, 645435484, 896335161, 709722701, 1473988039, 724567058, 644918642, 667766809, 600251621, 1287077827, 627851499, 667766809, 898183173, 649395924, 644918642, 696412604, 1287077827, 200901180, 873129141, 631924917, 620742805, 584682946, 620742805, 1501345060, 1132403352, 601306614, 877483245, 841877591, 842030200, 877451192, 725750543, 1007410280, 1543583455, 221793497, 1132403352, 873173851, 696472981, 652680409, 620600621)
2304 end
2305end
2306globalsound = sound
2307globalreplication = replication
2308print("Loading effects module")
2309do
2310 local wfc = game.WaitForChild
2311 local ffc = game.FindFirstChild
2312 local ud2 = UDim2.new
2313 local v3 = Vector3.new
2314 local nv = v3()
2315 local cf = CFrame.new
2316 local angles = CFrame.Angles
2317 local deg = math.pi / 180
2318 local random = math.random
2319 local color = Color3.new
2320 local colorseq = ColorSequence.new
2321 local spawn = function(F)
2322 coroutine.resume(coroutine.create(F))
2323 end
2324 local ray = Ray.new
2325 local raycast = workspace.FindPartOnRayWithIgnoreList
2326 local debris = game.Debris
2327 local new = Instance.new
2328 local dot = nv.Dot
2329 local nc = cf()
2330 local vtws = nc.vectorToWorldSpace
2331 local player = game:GetService("Players").LocalPlayer
2332 local light = game.Lighting
2333 local pgui = player.PlayerGui
2334 local repeffects = game.ReplicatedStorage.Effects
2335 local smoke = repeffects.Smoke
2336 local hole = repeffects.Hole
2337 local flash = repeffects.Muzzle
2338 local shell = repeffects.Shell
2339 local blood = repeffects.Blood
2340 local bloodsplat = repeffects.BloodSplat
2341 local ignore = workspace.Ignore
2342 local mapbloom = wfc(light, "MapBloom")
2343 local mapray = wfc(light, "MapRay")
2344 local mapsat = wfc(light, "MapSaturation")
2345 local smokelist = {}
2346 local holelist = {}
2347 local flashlist = {}
2348 local shelllist = {}
2349 local impactpool = {}
2350 local effectobjects = repeffects.effectobjects
2351 local materialtype = Enum.Material
2352 local materiallist = {
2353 [Enum.Material.Cobblestone] = {
2354 185234383,
2355 185234399,
2356 185234373,
2357 185234412
2358 },
2359 [Enum.Material.Wood] = {
2360 185238181,
2361 185238234,
2362 185238224,
2363 185238210,
2364 185238204
2365 },
2366 [Enum.Material.Brick] = {
2367 185237818,
2368 185237842,
2369 185237826,
2370 185237805
2371 },
2372 [Enum.Material.Plastic] = {
2373 185238152,
2374 185237945,
2375 185237930
2376 },
2377 [Enum.Material.Concrete] = {
2378 185237894,
2379 185237879,
2380 185237865,
2381 185237853
2382 },
2383 Tile = {
2384 185238332,
2385 185238308,
2386 185238298,
2387 185238288,
2388 185238271,
2389 185238257
2390 }
2391 }
2392 local splatter
2393 do
2394 local sort = table.sort
2395 local random = math.random
2396 local log = math.log
2397 local cos = math.cos
2398 local sin = math.sin
2399 local tau = 2 * math.pi
2400 local function gaussian()
2401 local r0 = 1 - random()
2402 local r1 = random() * tau
2403 local l = (-2 * log(r0)) ^ 0.5
2404 return l * cos(r1), l * sin(r1)
2405 end
2406 local function exponential()
2407 return -log(1 - random())
2408 end
2409 local boxn = {
2410 v3(1, 0, 0),
2411 v3(-1, 0, 0),
2412 v3(0, 1, 0),
2413 v3(0, -1, 0),
2414 v3(0, 0, 1),
2415 v3(0, 0, -1)
2416 }
2417 local boxl = {
2418 0.5,
2419 0.5,
2420 0.5,
2421 0.5,
2422 0.5,
2423 0.5
2424 }
2425 local function transform_mesh(meshn, meshl, cframe, size)
2426 local newn = {}
2427 local newl = {}
2428 for i = 1, #meshn do
2429 local n = meshn[i]
2430 local l = meshl[i]
2431 local tn = vtws(cframe, n / size).unit
2432 local tl = dot(cframe * (l * n * size), tn)
2433 newn[i] = tn
2434 newl[i] = tl
2435 end
2436 return newn, newl
2437 end
2438 local function distance_o_1(an, al, o)
2439 local oan = dot(o, an)
2440 return oan - al
2441 end
2442 local function distance_o_2(an, al, bn, bl, o)
2443 local anbn = dot(an, bn)
2444 local oan = dot(o, an)
2445 local obn = dot(o, bn)
2446 local m = (1 - anbn * anbn) ^ 0.5
2447 return (bl - al * anbn + anbn * oan - obn) / m
2448 end
2449 local function dist_from_edge(meshn, meshl, o)
2450 local besta
2451 local bestd = -1 / 0
2452 for i = 1, #meshn do
2453 local an = meshn[i]
2454 local al = meshl[i]
2455 local d = distance_o_1(an, al, o)
2456 if bestd < d then
2457 besta = i
2458 bestd = d
2459 end
2460 end
2461 if not besta then
2462 return 1 / 0
2463 end
2464 local an = meshn[besta]
2465 local al = meshl[besta]
2466 local r = 1 / 0
2467 for i = 1, #meshn do
2468 if i ~= besta then
2469 local bn = meshn[i]
2470 local bl = meshl[i]
2471 local d = distance_o_2(an, al, bn, bl, o)
2472 if r > d then
2473 r = d
2474 end
2475 end
2476 end
2477 return r
2478 end
2479 local meshcache = {}
2480 local function getmesh(part)
2481 local cache = meshcache[part]
2482 if cache then
2483 return cache.meshn, cache.meshl
2484 else
2485 do
2486 local cframe = part.CFrame
2487 local size = part.Size
2488 local meshn, meshl = transform_mesh(boxn, boxl, part.CFrame, part.Size)
2489 meshcache[part] = {meshn = meshn, meshl = meshl}
2490 local event
2491 event = part.Changed:connect(function()
2492 meshcache[part] = nil
2493 event:disconnect()
2494 end)
2495 return meshn, meshl
2496 end
2497 end
2498 end
2499 local function max_radius(part, pos)
2500 local meshn, meshl = getmesh(part)
2501 return dist_from_edge(meshn, meshl, pos)
2502 end
2503 local spartpool = {}
2504 local function getspart()
2505 local pooledpart = spartpool[#spartpool]
2506 if pooledpart then
2507 spartpool[#spartpool] = nil
2508 return pooledpart
2509 else
2510 local spart = Instance.new("Part")
2511 spart.Shape = "Cylinder"
2512 spart.Anchored = true
2513 spart.CanCollide = false
2514 spart.BrickColor = BrickColor.new("Crimson")
2515 return spart
2516 end
2517 end
2518 local function retirespart(part)
2519 spartpool[#spartpool + 1] = part
2520 end
2521 local function sortandmerge(slist, ulist, lt)
2522 sort(ulist, lt)
2523 local mlist = {}
2524 local m = #slist
2525 local n = #ulist
2526 local i = 1
2527 local j = 1
2528 local k = 0
2529 while m >= i and n >= j do
2530 k = k + 1
2531 local a = slist[i]
2532 local b = ulist[j]
2533 if lt(a, b) then
2534 i = i + 1
2535 mlist[k] = a
2536 else
2537 j = j + 1
2538 mlist[k] = b
2539 end
2540 end
2541 for l = i, m do
2542 k = k + 1
2543 mlist[k] = slist[l]
2544 end
2545 for l = j, n do
2546 k = k + 1
2547 mlist[k] = ulist[l]
2548 end
2549 return mlist
2550 end
2551 local queuedsplatters = {}
2552 local queuedretires = {}
2553 local nsplatters = 0
2554 local splatters = {}
2555 local nretires = 0
2556 local retires = {}
2557 local maxbloodt = 1
2558 local compt0 = function(a, b)
2559 return b.t0 < a.t0
2560 end
2561 local compt1 = function(a, b)
2562 return b.t1 < a.t1
2563 end
2564 function effects.setmaxbloodt(newt)
2565 maxbloodt = newt
2566 end
2567 game:GetService("RunService").RenderStepped:connect(function()
2568 debug.profilebegin("blood creation/removal")
2569 local t = tick()
2570 if nsplatters > 0 then
2571 queuedsplatters = sortandmerge(queuedsplatters, splatters, compt0)
2572 nsplatters = 0
2573 splatters = {}
2574 end
2575 for i = #queuedsplatters, 1, -1 do
2576 if maxbloodt / 1000 < tick() - t then
2577 else
2578 local splat = queuedsplatters[i]
2579 if t > splat.t0 then
2580 queuedsplatters[i] = nil
2581 local spart = getspart()
2582 local size = splat.size
2583 local part = splat.part
2584 local norm = splat.norm
2585 local pos = splat.pos
2586 local maxsize = 2 * max_radius(part, pos)
2587 if size > maxsize then
2588 size = maxsize
2589 end
2590 local spart = getspart()
2591 spart.Size = v3(0.05, size, size)
2592 spart.CFrame = cf(pos, pos + norm) * angles(0, tau / 4, 0)
2593 spart.Parent = workspace.Ignore
2594 nretires = nretires + 1
2595 retires[nretires] = {
2596 t1 = splat.t1,
2597 spart = spart
2598 }
2599 end
2600 else
2601 break
2602 end
2603 end
2604 if nretires > 0 then
2605 queuedretires = sortandmerge(queuedretires, retires, compt1)
2606 nretires = 0
2607 retires = {}
2608 end
2609 for i = #queuedretires, 1, -1 do
2610 if maxbloodt / 1000 < tick() - t then
2611 else
2612 local retire = queuedretires[i]
2613 if t > retire.t1 then
2614 queuedretires[i] = nil
2615 retire.spart.Parent = nil
2616 retirespart(retire.spart)
2617 end
2618 else
2619 break
2620 end
2621 end
2622 debug.profileend()
2623 end)
2624 function splatter(splots, avgsize, orig, velocity, spread, dist, ignorelist, life0, life1)
2625 debug.profilebegin("blood initialization")
2626 local ct = tick()
2627 local v = spread * velocity.magnitude
2628 for i = 1, splots do
2629 local r0, r1 = gaussian()
2630 local r2 = gaussian()
2631 local r3 = exponential()
2632 local dir = velocity + v3(v * r0, v * r1, v * r2)
2633 local size = avgsize * r3
2634 local part, pos, norm = raycast(workspace, ray(orig, dist * dir.unit), ignorelist)
2635 if part and part.Name ~= "Window" and part.Transparency ~= 1 then
2636 nsplatters = nsplatters + 1
2637 local t0 = ct + dot(dir, pos - orig) / dot(dir, dir)
2638 local t1 = t0 + random() * (life1 - life0) + life0
2639 splatters[nsplatters] = {
2640 t0 = t0,
2641 t1 = t1,
2642 size = size,
2643 part = part,
2644 norm = norm,
2645 pos = pos
2646 }
2647 end
2648 end
2649 debug.profileend()
2650 end
2651 end
2652 function effects:ejectshell(trigger, guntype, offset)
2653 local shellpart
2654 if #shelllist ~= 0 then
2655 shellpart = shelllist[#shelllist]
2656 shelllist[#shelllist] = nil
2657 else
2658 shellpart = shell:Clone()
2659 end
2660 delay(0.1, function()
2661 shellpart.CFrame = trigger.CFrame * angles((90 + random(-5, 5)) * deg, random(-5, 5) * deg, random(-5, 5) * deg) * offset
2662 shellpart.RotVelocity = v3(random(-5, 5), random(-5, 5), random(-5, 5))
2663 shellpart.Parent = ignore
2664 shellpart.BodyThrust.force = v3(3.5, 0.1, -3)
2665 wait(0.05)
2666 shellpart.BodyThrust.force = v3(-0.5, 0, 0)
2667 wait(0.1)
2668 shellpart.BodyThrust.force = v3(0, 0, 0)
2669 wait(0.1)
2670 shellpart.Velocity = v3()
2671 shellpart.Parent = nil
2672 shelllist[#shelllist + 1] = shellpart
2673 end)
2674 end
2675 function effects:muzzleflash(barrel)
2676 local flashpart
2677 if #flashlist ~= 0 then
2678 flashpart = flashlist[#flashlist]
2679 flashlist[#flashlist] = nil
2680 else
2681 flashpart = flash:Clone()
2682 end
2683 local flare = ffc(flashpart, "Flare")
2684 local spark = ffc(flashpart, "Spark")
2685 if not flare or not spark then
2686 trash.remove(flashpart)
2687 flashpart = flash:Clone()
2688 flare = ffc(flashpart, "Flare")
2689 spark = ffc(flashpart, "Spark")
2690 end
2691 flashpart.Enabled = true
2692 flashpart.Parent = pgui
2693 flashpart.Adornee = barrel
2694 flare.Rotation = random(0, 360)
2695 flare.Size = ud2(0, 20, 0, 20)
2696 flare.Position = ud2(0.5, -10, 0.5, -10)
2697 spark.Rotation = random(0, 360)
2698 spark.Size = ud2(0, 200, 0, 200)
2699 spark.Position = ud2(0.5, -100, 0.5, -100)
2700 spark.Visible = true
2701 flare:TweenSizeAndPosition(ud2(0, 1000, 0, 1000), ud2(0.5, -500, 0.5, -500), "Out", "Sine", 0.2)
2702 spark:TweenSizeAndPosition(ud2(0, 500, 0, 500), ud2(0.5, -250, 0.5, -250), "Out", "Sine", 0.15)
2703 delay(0.05, function()
2704 spark.Visible = false
2705 wait(0.05)
2706 flashpart.Enabled = false
2707 wait(0.5)
2708 flashpart.Parent = nil
2709 flashlist[#flashlist + 1] = flashpart
2710 end)
2711 char:firemuzzlelight()
2712 end
2713 function effects:breakwindow(hit, pos, norm, vel, force, nobulleteffect)
2714 hit.Parent = ignore
2715 hit.CanCollide = false
2716 local breakSound = "Break" .. math.random(1, 3)
2717 local soundfont = ({
2718 Break1 = "http://roblox.com/asset/?id=627558532",
2719 Break2 = "http://roblox.com/asset/?id=627558611",
2720 Break3 = "http://roblox.com/asset/?id=627558676"
2721 })[breakSound]
2722 local shat = new("Sound", hit)
2723 shat.SoundId = soundfont
2724 shat.Volume = 0.75
2725 shat.MaxDistance = 200
2726 local winshatter = repeffects.WindowShatter:Clone()
2727 winshatter.Parent = hit
2728 winshatter.Color = ColorSequence.new(hit.Color)
2729 winshatter.Transparency = NumberSequence.new(hit.Transparency)
2730 winshatter.Enabled = true
2731 local size = hit.Size.Magnitude / 15
2732 local kp1 = NumberSequenceKeypoint.new(0, size, size / 4)
2733 local kp2 = NumberSequenceKeypoint.new(1, size, size / 4)
2734 winshatter.Size = NumberSequence.new({kp1, kp2})
2735 shat.Ended:connect(function()
2736 shat:Destroy()
2737 end)
2738 shat:Play()
2739 hit.Transparency = 1
2740 game.Debris:AddItem(hit, 1)
2741 if not nobulleteffect then
2742 effects:bullethit(hit, pos, norm, nil, nil, vel, false, false, 3)
2743 end
2744 delay(0.1, function()
2745 winshatter.Enabled = false
2746 end)
2747 end
2748 function effects:breakwindows(windows)
2749 for i, window in next, windows, nil do
2750 effects:breakwindow(window, window.Position, nv, nv, nv, true)
2751 end
2752 end
2753 function effects:bloodhit(start, hit, pos, norm, enablesplatter, damage, velocity)
2754 local damage = damage or 20
2755 if damage > 100 then
2756 damage = 100
2757 end
2758 network:send("b" .. "l" .. "o" .. "o" .. "d" .. "h" .. "i" .. "t", start, hit, pos, norm, enablesplatter, damage / 3, velocity)
2759 createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2760 end
2761 function effects:enablemapshaders(on)
2762 local shaderlist = {mapsat, mapray}
2763 for i = 1, #shaderlist do
2764 if effects.disableshaders then
2765 shaderlist[i].Enabled = false
2766 else
2767 shaderlist[i].Enabled = on
2768 end
2769 end
2770 end
2771 function createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2772 if input.consoleon or effects.disableblood then
2773 return
2774 end
2775 local size = 1
2776 local ignorelist = {
2777 ignore,
2778 workspace.DeadBody,
2779 workspace.CurrentCamera
2780 }
2781 local pp = game:GetService("Players"):GetPlayers()
2782 for i = 1, #pp do
2783 ignorelist[#ignorelist + 1] = pp[i].Character
2784 end
2785 if enablesplatter then
2786 local damage = damage or 20
2787 local splots = damage / 2
2788 splatter(splots, 0.5, pos, velocity, 0.125, 20, ignorelist, 7, 15)
2789 end
2790 local bloodpart = hole:Clone()
2791 bloodpart.Parent = ignore
2792 bloodpart.CFrame = cf(pos)
2793 bloodpart.Transparency = 1
2794 bloodpart:ClearAllChildren()
2795 local test = repeffects.BloodTest:Clone()
2796 test.Parent = bloodpart
2797 test.Rate = test.Rate * size
2798 test.Enabled = true
2799 spawn(function()
2800 wait(0.1)
2801 test.Enabled = false
2802 end)
2803 debris:AddItem(bloodpart, 3)
2804 end
2805 network:add("createblood", createblood)
2806 local function makeimpact(hit, pos, norm)
2807 local impacttype
2808 if hit.Name == "Terrain" then
2809 impacttype = "ImpactWater"
2810 elseif hit.Material == Enum.Material.Grass then
2811 impacttype = "ImpactGrass"
2812 else
2813 impacttype = "ImpactDefault"
2814 end
2815 local impact
2816 local pool = impactpool[impacttype]
2817 if not pool then
2818 impactpool[impacttype] = {}
2819 pool = impactpool[impacttype]
2820 end
2821 if #pool == 0 then
2822 impact = effectobjects[impacttype]:Clone()
2823 impact.Parent = ignore
2824 else
2825 impact = pool[#pool]
2826 pool[#pool] = nil
2827 end
2828 impact.CFrame = cf(pos, pos + 2 * norm + vector.random(1))
2829 local pt = impact:GetChildren()
2830 for i = 1, #pt do
2831 if pt[i]:IsA("ParticleEmitter") then
2832 pt[i].Acceleration = v3(5 * (random() - 0.5), pt[i].Acceleration.Y, 5 * (random() - 0.5))
2833 pt[i].EmissionDirection = "Front"
2834 pt[i]:Emit(pt[i].Rate / 10)
2835 end
2836 end
2837 if impacttype == "Impact1" then
2838 impact.effcloud.EmissionDirection = random(0, 5)
2839 end
2840 delay(0.05, function()
2841 pool[#pool + 1] = impact
2842 end)
2843 end
2844 local function makehole(hit, pos, norm)
2845 local holepart
2846 if #holelist ~= 0 then
2847 holepart = holelist[#holelist]
2848 holelist[#holelist] = nil
2849 else
2850 holepart = hole:Clone()
2851 end
2852 holepart:BreakJoints()
2853 holepart.Parent = ignore
2854 holepart.CFrame = cf(pos, pos - norm) * angles(-90 * deg, random(0, 360) * deg, 0)
2855 local materials = materiallist[Enum.Material.Cobblestone]
2856 if materiallist[hit.Material] then
2857 materials = materiallist[hit.Material]
2858 end
2859 local randId = "http://www.roblox.com/asset/?id=" .. materials[random(1, #materials)]
2860 holepart.Decal1.Texture = randId
2861 holepart.Decal2.Texture = randId
2862 delay(10, function()
2863 holepart.Parent = nil
2864 holelist[#holelist + 1] = holepart
2865 end)
2866 end
2867 function effects:bullethit(hit, pos, norm, exit, exitnorm, vel, smokeon, holeon, sparkson)
2868 if hit.Transparency == 1 then
2869 return
2870 end
2871 local showeffects = camera.screencull.sphere(pos, 16)
2872 if sparkson and showeffects and hit.Material ~= Enum.Material.Sand and hit.Material ~= Enum.Material.Grass and hit.Material ~= Enum.Material.Wood then
2873 local initalsize = 0.1
2874 local initalbrightness = 20 * random()
2875 for i = 1, sparkson * 2 + 1 do
2876 particle.new({
2877 position = pos,
2878 nopenetration = true,
2879 velocity = (vel - 1.2 * norm:Dot(vel) / norm:Dot(norm) * norm) * 0.1 + vector.random(50),
2880 acceleration = v3(0, -196.2, 0),
2881 cancollide = true,
2882 size = initalsize,
2883 brightness = initalbrightness,
2884 color = Color3.new(1, 1, 0.8),
2885 bloom = 0.005 * random(),
2886 life = -0.25 * math.log(1 - random()),
2887 physicsonly = true,
2888 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
2889 if not self.stopmotion then
2890 local vel = self.velocity
2891 local newpos = pos + 0.1 * norm
2892 local elasticity = 0.3
2893 local friction = 0.4
2894 local nvel = norm:Dot(vel) * norm
2895 local tvel = vel - nvel
2896 local newvel = (1 - friction) * tvel - elasticity * nvel
2897 self.position = newpos
2898 self.velocity = newvel
2899 if newvel.magnitude < 2 then
2900 self.stopmotion = true
2901 end
2902 end
2903 end,
2904 onstep = function(self, dt)
2905 self.brightness = self.brightness - 0.7 * dt
2906 self.size = self.size - 0.2 * dt
2907 if self.brightness < 0 then
2908 self.brightness = 0
2909 end
2910 if self.size < 0 then
2911 self.size = 0
2912 end
2913 end
2914 })
2915 end
2916 if exit and exitnorm then
2917 for i = 1, sparkson * 2 + 1 do
2918 particle.new({
2919 position = exit,
2920 nopenetration = true,
2921 velocity = (vel - 1.2 * exitnorm:Dot(vel) / exitnorm:Dot(exitnorm) * exitnorm) * 0.1 + vector.random(50),
2922 acceleration = v3(0, -196.2, 0),
2923 cancollide = true,
2924 size = initalsize,
2925 brightness = initalbrightness,
2926 color = Color3.new(1, 1, 0.8),
2927 bloom = 0.005 * random(),
2928 life = -0.25 * math.log(1 - random()),
2929 physicsonly = true,
2930 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
2931 if not self.stopmotion then
2932 local vel = self.velocity
2933 local newpos = pos + 0.1 * norm
2934 local elasticity = 0.3
2935 local friction = 0.4
2936 local nvel = norm:Dot(vel) * norm
2937 local tvel = vel - nvel
2938 local newvel = (1 - friction) * tvel - elasticity * nvel
2939 self.position = newpos
2940 self.velocity = newvel
2941 if newvel.magnitude < 2 then
2942 self.stopmotion = true
2943 end
2944 end
2945 end,
2946 onstep = function(self, dt)
2947 self.brightness = self.brightness - 0.7 * dt
2948 self.size = self.size - 0.2 * dt
2949 if self.brightness < 0 then
2950 self.brightness = 0
2951 end
2952 if self.size < 0 then
2953 self.size = 0
2954 end
2955 end
2956 })
2957 end
2958 end
2959 end
2960 local light = hit:FindFirstChildOfClass("SpotLight") or hit:FindFirstChildOfClass("PointLight") or hit:FindFirstChildOfClass("SurfaceLight")
2961 if light then
2962 light:Destroy()
2963 for i = 1, 10 do
2964 particle.new({
2965 position = pos,
2966 nopenetration = true,
2967 velocity = norm * 30 + vector.random(10),
2968 acceleration = v3(0, -30, 0),
2969 cancollide = true,
2970 size = 0.1,
2971 brightness = 5 * random(),
2972 color = Color3.new(1, 1, 0.8),
2973 bloom = 0.005 * random(),
2974 life = -3 * math.log(1 - random()),
2975 physicsonly = true,
2976 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
2977 if not self.stopmotion then
2978 local vel = self.velocity
2979 local newpos = pos + 0.1 * norm
2980 local elasticity = 0.3
2981 local friction = 0.4
2982 local nvel = norm:Dot(vel) * norm
2983 local tvel = vel - nvel
2984 local newvel = (1 - friction) * tvel - elasticity * nvel
2985 self.position = newpos
2986 self.velocity = newvel
2987 if newvel.magnitude < 2 then
2988 self.stopmotion = true
2989 end
2990 end
2991 end,
2992 onstep = function(self, dt)
2993 self.brightness = self.brightness - 0.17 * dt
2994 self.size = self.size - 0.035 * dt
2995 if self.brightness < 0 then
2996 self.brightness = 0
2997 end
2998 if self.size < 0 then
2999 self.size = 0
3000 end
3001 end
3002 })
3003 end
3004 hit.Material = Enum.Material.SmoothPlastic
3005 end
3006 if not effects.disablerobloxparticles and smokeon and showeffects then
3007 makeimpact(hit, pos, norm)
3008 if exit and exitnorm then
3009 makeimpact(hit, exit, exitnorm)
3010 end
3011 end
3012 if holeon and hit.Transparency == 0 and hit.CanCollide then
3013 makehole(hit, pos, norm)
3014 if exit and exitnorm then
3015 makehole(hit, exit, exitnorm)
3016 end
3017 end
3018 end
3019 function effects:reload()
3020 smokelist = {}
3021 holelist = {}
3022 flashlist = {}
3023 shelllist = {}
3024 end
3025 effects:reload()
3026end
3027print("Loading tween module")
3028do
3029 local type = type
3030 local halfpi = math.pi / 2
3031 local acos = math.acos
3032 local sin = math.sin
3033 local cf = CFrame.new
3034 local tos = cf().toObjectSpace
3035 local components = cf().components
3036 local tweendata = {}
3037 local equations = {
3038 linear = {
3039 p0 = 0,
3040 v0 = 1,
3041 p1 = 1,
3042 v1 = 1
3043 },
3044 smooth = {
3045 p0 = 0,
3046 v0 = 0,
3047 p1 = 1,
3048 v1 = 0
3049 },
3050 accelerate = {
3051 p0 = 0,
3052 v0 = 0,
3053 p1 = 1,
3054 v1 = 1
3055 },
3056 decelerate = {
3057 p0 = 0,
3058 v0 = 1,
3059 p1 = 1,
3060 v1 = 0
3061 },
3062 bump = {
3063 p0 = 0,
3064 v0 = 4,
3065 p1 = 0,
3066 v1 = -4
3067 },
3068 acceleratebump = {
3069 p0 = 0,
3070 v0 = 0,
3071 p1 = 0,
3072 v1 = -6.75
3073 },
3074 deceleratebump = {
3075 p0 = 0,
3076 v0 = 6.75,
3077 p1 = 0,
3078 v1 = 0
3079 }
3080 }
3081 local updater = {}
3082 tween.step = event.new(updater)
3083 function tween.tweencframe(object, index, time, equation, nextcframe)
3084 if tweendata[object] then
3085 tweendata[object]()
3086 end
3087 local t0 = tick()
3088 local p0, v0, p1, v1
3089 if type(equation) == "table" then
3090 p0 = equation[1]
3091 v0 = equation[2]
3092 p1 = equation[3]
3093 v1 = equation[4]
3094 else
3095 local eq = equations[equation]
3096 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3097 end
3098 local interpolator = cframe.interpolator(object[index], nextcframe)
3099 local stop
3100 stop = updater:connect(function()
3101 local u = (tick() - t0) / time
3102 if u > 1 then
3103 object[index] = interpolator(p1)
3104 stop()
3105 tweendata[object] = nil
3106 else
3107 local v = 1 - u
3108 local t = p0 * v * v * v + (3 * p0 + v0) * u * v * v + (3 * p1 - v1) * u * u * v + p1 * u * u * u
3109 object[index] = interpolator(t)
3110 end
3111 end)
3112 tweendata[object] = stop
3113 return stop
3114 end
3115 function tween.freebody(object, index, life, cframe0, velocity0, rotation0, acceleration)
3116 local position0 = cframe0.p
3117 local matrix0 = cframe0 - position0
3118 local tick0 = tick()
3119 local stop
3120 stop = updater:connect(function()
3121 local t = tick() - tick0
3122 if life and t > life then
3123 stop()
3124 trash.remove(object)
3125 end
3126 object[index] = cframe.fromaxisangle(t * rotation0) * matrix0 + position0 + t * velocity0 + t * t * acceleration
3127 end)
3128 return stop
3129 end
3130end
3131print("Loading input module")
3132do
3133 local lower = string.lower
3134 local nv = Vector3.new()
3135 local userinput = game:GetService("UserInputService")
3136 local abbreviation = {
3137 ButtonX = "x",
3138 ButtonY = "y",
3139 ButtonA = "a",
3140 ButtonB = "b",
3141 ButtonR1 = "r1",
3142 ButtonL1 = "l1",
3143 ButtonR2 = "r2",
3144 ButtonL2 = "l2",
3145 ButtonR3 = "r3",
3146 ButtonL3 = "l3",
3147 ButtonStart = "start",
3148 ButtonSelect = "select",
3149 DPadLeft = "left",
3150 DPadRight = "right",
3151 DPadUp = "up",
3152 DPadDown = "down"
3153 }
3154 input.keyboard = {}
3155 input.keyboard.down = {}
3156 input.keyboard.onkeydown = {}
3157 input.keyboard.onkeyup = {}
3158 input.mouse = {}
3159 input.mouse.Position = nv
3160 input.mouse.down = {}
3161 input.mouse.onbuttondown = {}
3162 input.mouse.onbuttonup = {}
3163 input.mouse.onmousemove = {}
3164 input.mouse.onscroll = {}
3165 input.controller = {}
3166 input.controller.down = {}
3167 input.controller.onbuttondown = {}
3168 input.controller.onbuttonup = {}
3169 input.controller.onintegralmove = {}
3170 input.consoleon = not userinput.KeyboardEnabled
3171 local fireonkeydown = event.new(input.keyboard.onkeydown)
3172 local fireonkeyup = event.new(input.keyboard.onkeyup)
3173 local fireonbuttondown = event.new(input.mouse.onbuttondown)
3174 local fireonbuttonup = event.new(input.mouse.onbuttonup)
3175 local fireonmousemove = event.new(input.mouse.onmousemove)
3176 local fireonscroll = event.new(input.mouse.onscroll)
3177 local fireoncbuttondown = event.new(input.controller.onbuttondown)
3178 local fireoncbuttonup = event.new(input.controller.onbuttonup)
3179 local fireonintegralmove = event.new(input.controller.onintegralmove)
3180 local clicks = 0
3181 local maxcps = 20
3182 local reset = 0
3183 local keymap = {}
3184 local triggerthreshold = 0.2
3185 local stickthreshold = 0.25
3186 local gamepadpos
3187 local triggeron = {}
3188 local typing
3189 function input.iskeydown(key)
3190 return userinput:GetKeysPressed()[key]
3191 end
3192 userinput.TextBoxFocused:connect(function()
3193 typing = true
3194 end)
3195 userinput.TextBoxFocusReleased:connect(function()
3196 typing = false
3197 end)
3198 userinput.InputChanged:connect(function(object)
3199 local type = object.UserInputType.Name
3200 local pos = object.Position
3201 if type == "MouseMovement" then
3202 input.mouse.position = pos
3203 fireonmousemove(object.Delta)
3204 elseif type == "MouseWheel" then
3205 fireonscroll(pos.z)
3206 elseif type == "Gamepad1" then
3207 local key = object.KeyCode.Name
3208 if key == "Thumbstick2" then
3209 local m = pos.magnitude
3210 if m > stickthreshold then
3211 gamepadpos = (1 - stickthreshold / m) / (1 - stickthreshold) * pos
3212 elseif gamepadpos then
3213 gamepadpos = nil
3214 end
3215 elseif key == "ButtonL2" or key == "ButtonR2" then
3216 local abv = abbreviation[key]
3217 if triggerthreshold < pos.z and not input.controller.down[abv] then
3218 local mappedkey = keymap[abv]
3219 if mappedkey then
3220 input.keyboard.down[mappedkey] = tick()
3221 fireonkeydown(mappedkey)
3222 end
3223 input.controller.down[abv] = tick()
3224 fireoncbuttondown(abv)
3225 elseif pos.z < triggerthreshold and input.controller.down[abv] then
3226 local mappedkey = keymap[abv]
3227 if mappedkey then
3228 input.keyboard.down[mappedkey] = nil
3229 fireonkeyup(mappedkey)
3230 end
3231 input.controller.down[abv] = nil
3232 fireoncbuttonup(abv)
3233 end
3234 end
3235 end
3236 end)
3237 userinput.InputBegan:connect(function(object)
3238 local t = tick()
3239 if typing or char.health and char.health <= 0 then
3240 return
3241 end
3242 local type = object.UserInputType.Name
3243 if type == "Keyboard" then
3244 local key = lower(object.KeyCode.Name)
3245 input.keyboard.down[key] = t
3246 fireonkeydown(key)
3247 elseif type == "Gamepad1" then
3248 local key = abbreviation[object.KeyCode.Name]
3249 if key and key ~= "l2" and key ~= "r2" or not input.controller.down[key] then
3250 local mappedkey = keymap[key]
3251 if mappedkey then
3252 input.keyboard.down[mappedkey] = t
3253 fireonkeydown(mappedkey)
3254 end
3255 input.controller.down[key] = t
3256 fireoncbuttondown(key)
3257 end
3258 elseif type == "MouseButton1" then
3259 if t > reset then
3260 clicks = 0
3261 reset = t + 1
3262 end
3263 clicks = clicks + 1
3264 if clicks <= maxcps then
3265 input.mouse.down.left = t
3266 fireonbuttondown("left")
3267 end
3268 elseif type == "MouseButton2" then
3269 input.mouse.down.right = t
3270 fireonbuttondown("right")
3271 elseif type == "MouseButton3" then
3272 input.mouse.down.middle = t
3273 fireonbuttondown("middle")
3274 end
3275 end)
3276 userinput.InputEnded:connect(function(object)
3277 if typing then
3278 return
3279 end
3280 local type = object.UserInputType.Name
3281 if type == "Keyboard" then
3282 local key = lower(object.KeyCode.Name)
3283 input.keyboard.down[key] = nil
3284 fireonkeyup(key)
3285 elseif type == "Gamepad1" then
3286 local key = abbreviation[object.KeyCode.Name]
3287 if key and key ~= "l2" and key ~= "r2" or input.controller.down[key] then
3288 local mappedkey = keymap[key]
3289 if mappedkey then
3290 input.keyboard.down[mappedkey] = nil
3291 fireonkeyup(mappedkey)
3292 end
3293 input.controller.down[key] = nil
3294 fireoncbuttonup(key)
3295 end
3296 elseif type == "MouseButton1" then
3297 input.mouse.down.left = nil
3298 fireonbuttonup("left")
3299 elseif type == "MouseButton2" then
3300 input.mouse.down.right = nil
3301 fireonbuttonup("right")
3302 elseif type == "MouseButton3" then
3303 input.mouse.down.middle = nil
3304 fireonbuttonup("middle")
3305 end
3306 end)
3307 function input.mouse:hide()
3308 userinput.MouseIconEnabled = false
3309 end
3310 function input.mouse:show()
3311 userinput.MouseIconEnabled = true
3312 end
3313 function input.mouse.visible()
3314 return userinput.MouseIconEnabled
3315 end
3316 function input.mouse:lockcenter()
3317 userinput.MouseBehavior = "LockCenter"
3318 end
3319 function input.mouse:free()
3320 userinput.MouseBehavior = "Default"
3321 end
3322 function input.mouse:lock()
3323 userinput.MouseBehavior = "LockCurrentPosition"
3324 end
3325 function input.controller:map(button, key)
3326 keymap[button] = key
3327 end
3328 function input.controller:unmap(button)
3329 keymap[button] = nil
3330 end
3331 function input.step(dt)
3332 if gamepadpos then
3333 fireonintegralmove(dt * gamepadpos, dt)
3334 end
3335 end
3336end
3337print("Loading animation module")
3338do
3339 local sin = math.sin
3340 local acos = math.acos
3341 local type = type
3342 local next = next
3343 local cf = CFrame.new
3344 local v3 = vector.new
3345 local nv = v3()
3346 local inverse = CFrame.new().inverse
3347 local tos = CFrame.new().toObjectSpace
3348 local toquaternion = cframe.toquaternion
3349 local clone = game.Clone
3350 local new = Instance.new
3351 local play = new("Sound").Play
3352 local stop = new("Sound").Stop
3353 local equations = {
3354 linear = {
3355 p0 = 0,
3356 v0 = 1,
3357 p1 = 1,
3358 v1 = 1
3359 },
3360 smooth = {
3361 p0 = 0,
3362 v0 = 0,
3363 p1 = 1,
3364 v1 = 0
3365 },
3366 accelerate = {
3367 p0 = 0,
3368 v0 = 0,
3369 p1 = 1,
3370 v1 = 1
3371 },
3372 decelerate = {
3373 p0 = 0,
3374 v0 = 1,
3375 p1 = 1,
3376 v1 = 0
3377 },
3378 bump = {
3379 p0 = 0,
3380 v0 = 4,
3381 p1 = 0,
3382 v1 = -4
3383 },
3384 acceleratebump = {
3385 p0 = 0,
3386 v0 = 0,
3387 p1 = 0,
3388 v1 = -6.75
3389 },
3390 deceleratebump = {
3391 p0 = 0,
3392 v0 = 6.75,
3393 p1 = 0,
3394 v1 = 0
3395 }
3396 }
3397 local function interpolator(c0, c1, t0, dur, eq, pivot)
3398 pivot = pivot or nv
3399 c0 = c0 * cf(pivot)
3400 c1 = c1 * cf(pivot)
3401 local p0, v0, p1, v1
3402 if type(eq) == "table" then
3403 p0, v0, p1, v1 = eq[1], eq[2], eq[3], eq[4]
3404 else
3405 local eq = equations[eq or "smooth"]
3406 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3407 end
3408 return function(t)
3409 t = (t - t0) / dur
3410 t = t < 1 and t or 1
3411 local i = 1 - t
3412 local v = p0 * i * i * i + (3 * p0 + v0) * t * i * i + (3 * p1 - v1) * t * t * i + p1 * t * t * t
3413 return cframe.interpolate(c0, c1, v) * cf(-pivot), 1 == t
3414 end
3415 end
3416 function animation.player(modeldata, sequence)
3417 local interpolators = {}
3418 local framenumber = 1
3419 local t0 = 0
3420 local lasttime = t0
3421 local stdtimescale = sequence.stdtimescale
3422 local timescale = sequence.timescale
3423 local cframes = {}
3424 local lastcframes = {}
3425 local ignore = workspace.Ignore
3426 local player = game:GetService("Players").LocalPlayer
3427 for i, v in next, modeldata, nil do
3428 if v.part then
3429 lastcframes[i] = v.part.CFrame
3430 cframes[i] = v.part.CFrame
3431 end
3432 end
3433 return function(time)
3434 local dt = time - lasttime
3435 lasttime = time
3436 for i = framenumber, #sequence do
3437 local frame = sequence[i]
3438 if time > t0 then
3439 for i = 1, #frame do
3440 local data = frame[i]
3441 local partname = data.part
3442 if not modeldata[partname] then
3443 error("Error in frame: " .. framenumber .. ". " .. partname .. " is not in modeldata")
3444 end
3445 if data.c0 then
3446 interpolators[partname] = nil
3447 modeldata[partname].weld.C0 = data.c0 == "base" and modeldata[partname].basec0 or data.c0
3448 end
3449 if data.c1 then
3450 interpolators[partname] = interpolator(modeldata[partname].weld.C0, data.c1 == "base" and modeldata[partname].basec0 or data.basemult and modeldata[partname].basec0 * data.c1 or data.c1, t0, data.t and data.t * timescale or frame.delay * timescale, data.eq, data.pivot)
3451 end
3452 if data.clone then
3453 if modeldata[data.clone] then
3454 error("Error in frame: " .. framenumber .. ". Cannot clone " .. partname .. ". " .. data.clone .. " already exists.")
3455 end
3456 local part = clone(modeldata[partname].part)
3457 part.Parent = ignore
3458 part:ClearAllChildren()
3459 local tt = modeldata[partname].part:GetChildren()
3460 for i = 1, #tt do
3461 if tt[i]:IsA("Texture") then
3462 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3463 local hackytt = tt[i]:Clone()
3464 hackytt.Transparency = trans
3465 hackytt.Parent = part
3466 elseif tt[i]:IsA("FileMesh") or tt[i]:IsA("CylinderMesh") or tt[i]:IsA("BlockMesh") or tt[i]:IsA("SpecialMesh") then
3467 tt[i]:Clone().Parent = part
3468 end
3469 end
3470 local weld = new("Motor6D", part)
3471 local part0 = data.part0 and modeldata[data.part0].part or modeldata[partname].weld.Part0
3472 weld.Part0 = part0
3473 weld.Part1 = part
3474 weld.C0 = part0.CFrame:inverse() * modeldata[partname].weld.Part0.CFrame * modeldata[partname].weld.C0
3475 modeldata[data.clone] = {
3476 part = part,
3477 weld = weld,
3478 clone = true
3479 }
3480 cframes[data.clone] = cframes[partname]
3481 lastcframes[data.clone] = lastcframes[partname]
3482 end
3483 if data.transparency then
3484 modeldata[partname].part.Transparency = data.transparency
3485 if modeldata.camodata and modeldata.camodata[modeldata[partname].part] then
3486 local tt = modeldata[partname].part:GetChildren()
3487 for i = 1, #tt do
3488 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3489 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3490 tt[i].Transparency = data.transparency ~= 1 and trans or 1
3491 end
3492 end
3493 end
3494 end
3495 if data.sound then
3496 do
3497 local sound = new("Sound")
3498 if data.soundid then
3499 sound.SoundId = data.soundid
3500 end
3501 if data.v then
3502 sound.Volume = data.v
3503 end
3504 if data.p then
3505 sound.Pitch = data.p
3506 end
3507 if data.tp then
3508 sound.TimePosition = data.tp
3509 else
3510 sound.TimePosition = 0
3511 end
3512 if data.head then
3513 sound.Parent = player.Character.Head
3514 else
3515 sound.Parent = modeldata[partname].part
3516 end
3517 sound:Play()
3518 if data.d then
3519 delay(data.d, function()
3520 sound:Stop()
3521 end)
3522 end
3523 end
3524 end
3525 if data.drop then
3526 if not modeldata[partname].clone then
3527 error("Error in frame: " .. framenumber .. ". Cannot drop " .. partname .. ". Part is not a clone")
3528 end
3529 local lastcf = lastcframes[partname]
3530 local curcf = cframes[partname]
3531 tween.freebody(modeldata[partname].part, "CFrame", timescale / stdtimescale, modeldata[partname].part.CFrame, (curcf.p - lastcf.p) / dt, cframe.toaxisangle(curcf * lastcf:inverse()) / dt, v3(0, -196.2 / stdtimescale * stdtimescale * (timescale * timescale), 0))
3532 trash.remove(modeldata[partname].weld)
3533 modeldata[partname] = nil
3534 interpolators[partname] = nil
3535 end
3536 if data.delete then
3537 trash.remove(modeldata[partname].weld)
3538 trash.remove(modeldata[partname].part)
3539 modeldata[partname] = nil
3540 interpolators[partname] = nil
3541 end
3542 end
3543 t0 = t0 + frame.delay * timescale
3544 framenumber = framenumber + 1
3545 else
3546 break
3547 end
3548 end
3549 for i, v in next, interpolators, nil do
3550 local newcf, stop, t = v(time)
3551 modeldata[i].weld.C0 = newcf
3552 if stop then
3553 interpolators[i] = nil
3554 end
3555 end
3556 for i, v in next, modeldata, nil do
3557 if v.part then
3558 lastcframes[i] = cframes[i]
3559 cframes[i] = v.part.CFrame
3560 end
3561 end
3562 if time > t0 then
3563 for i, v in next, modeldata, nil do
3564 if v.clone then
3565 trash.remove(v.weld)
3566 trash.remove(v.part)
3567 modeldata[i] = nil
3568 end
3569 end
3570 end
3571 return time > t0
3572 end
3573 end
3574 function animation.reset(modeldata, t, keepvisible, resetboltlock)
3575 resetboltlock = resetboltlock or not modeldata.boltlock
3576 local interpolators = {}
3577 for i, v in next, modeldata, nil do
3578 if v.clone then
3579 modeldata[i] = nil
3580 trash.remove(v.weld)
3581 trash.remove(v.part)
3582 else
3583 if not keepvisible and v.part then
3584 v.part.Transparency = v.basetransparency
3585 if modeldata.camodata and modeldata.camodata[v.part] then
3586 local tt = v.part:GetChildren()
3587 for i = 1, #tt do
3588 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3589 local trans = modeldata.camodata[v.part][tt[i]].Transparency
3590 tt[i].Transparency = trans
3591 end
3592 end
3593 end
3594 end
3595 if v.weld and (i ~= "Bolt" or i == "Bolt" and resetboltlock) then
3596 interpolators[i] = interpolator(v.weld.C0, v.basec0, 0, t or 1)
3597 end
3598 end
3599 end
3600 return function(time)
3601 for i, v in next, interpolators, nil do
3602 if i ~= "Bolt" or i == "Bolt" and resetboltlock then
3603 local newcf, stop = v(time)
3604 modeldata[i].weld.C0 = newcf
3605 end
3606 end
3607 return time > t
3608 end
3609 end
3610end
3611print("Loading chat module")
3612do
3613 local wfc = game.WaitForChild
3614 local ffc = game.FindFirstChild
3615 local ud2 = UDim2.new
3616 local ceil = math.ceil
3617 local cf = CFrame.new
3618 local v3 = Vector3.new
3619 local color = Color3.new
3620 local dot = Vector3.new().Dot
3621 local workspace = workspace
3622 local ray = Ray.new
3623 local new = Instance.new
3624 local rtype = game.IsA
3625 local debris = game.Debris
3626 local sub = string.sub
3627 local len = string.len
3628 local lower = string.lower
3629 local find = string.find
3630 local insert = table.insert
3631 local match = string.match
3632 local player = game:GetService("Players").LocalPlayer
3633 local pgui = player.PlayerGui
3634 local misc = game.ReplicatedStorage.Misc
3635 local msg = wfc(misc, "Msger")
3636 local chatgui = wfc(pgui, "ChatGame")
3637 local chatbox = wfc(chatgui, "TextBox")
3638 local warn = wfc(chatgui, "Warn")
3639 local version = wfc(chatgui, "Version")
3640 local globalchat = wfc(chatgui, "GlobalChat")
3641 local guesttip = wfc(chatgui, "GuestTip")
3642 version.Text = "Server version: " .. updateversion
3643 local admin, moderator
3644 local adminlist = {
3645 525919,
3646 1667819,
3647 5725475,
3648 4337002
3649 }
3650 local moderatorlist = {66366193, 70273584}
3651 local banlist = {}
3652 local canchat = true
3653 local chatspam = 0
3654 local totalspam = 0
3655 local maxchar = 400
3656 local lines = 8
3657 local chatting
3658 local isguest = player.UserId < 0 and not game:GetService("RunService"):IsStudio()
3659 for i = 1, #adminlist do
3660 if adminlist[i] == player.userId then
3661 admin = true
3662 end
3663 end
3664 for i = 1, #moderatorlist do
3665 if moderatorlist[i] == player.userId then
3666 moderator = true
3667 end
3668 end
3669 for i = 1, #banlist do
3670 if banlist[i] == player.Name then
3671 player:kick("Banlist kick")
3672 end
3673 end
3674 network:add("console", function(message)
3675 local mes = msg:Clone()
3676 local mtag = wfc(mes, "Tag")
3677 local offset = 5
3678 mes.Parent = globalchat
3679 mes.Text = "[Console]: "
3680 mes.TextColor3 = Color3.new(0.4, 0.4, 0.4)
3681 mes.Msg.Text = message
3682 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3683 end)
3684 network:add("announce", function(message)
3685 local mes = msg:Clone()
3686 local mtag = wfc(mes, "Tag")
3687 local offset = 5
3688 mes.Parent = globalchat
3689 mes.Text = "[ANNOUNCEMENT]: "
3690 mes.TextColor3 = Color3.new(0.9803921568627451, 0.6509803921568628, 0.10196078431372549)
3691 mes.Msg.Text = message
3692 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3693 end)
3694 network:add("chatted", function(chatter, text, tag, tagcolor, teamchat, chattername)
3695 if teamchat and chatter.TeamColor ~= player.TeamColor then
3696 return
3697 end
3698 local mes = msg:Clone()
3699 local mtag = wfc(mes, "Tag")
3700 mes.Parent = globalchat
3701 local offset = 5
3702 mtag.Text = tag and tag .. " " or ""
3703 if tag then
3704 if string.sub(tag, 0, 1) == "$" then
3705 local imgid = string.sub(tag, 2)
3706 mes.Position = ud2(0.01, 50, 1, 20)
3707 mtag.Staff.Visible = true
3708 mtag.Staff.Image = "rbxassetid://" .. imgid
3709 mtag.Text = " "
3710 else
3711 offset = mtag.TextBounds.x + 5
3712 mes.Position = ud2(0.01, offset, 1, 20)
3713 mtag.Position = ud2(0, -offset + 5, 0, 0)
3714 if tagcolor then
3715 mtag.TextColor3 = tagcolor
3716 end
3717 end
3718 end
3719 mes.Text = chattername .. " : "
3720 mes.TextColor = chatter.TeamColor
3721 mes.Msg.Text = text
3722 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3723 end)
3724 local eval
3725 do
3726 local math = math
3727 local byte = string.byte
3728 local find = string.find
3729 local lparen = byte("(")
3730 local rparen = byte(")")
3731 local add = byte("+")
3732 local sub = byte("-")
3733 local mul = byte("*")
3734 local div = byte("/")
3735 local pow = byte("^")
3736 local mod = byte("%")
3737 local zero = byte("0")
3738 local nine = byte("9")
3739 local dot = byte(".")
3740 local space = byte(" ")
3741 local tab = byte("\t")
3742 local newl = byte("\n")
3743 local arith = {
3744 [add] = function(a, b)
3745 return a + b
3746 end,
3747 [sub] = function(a, b)
3748 return a - b
3749 end,
3750 [mul] = function(a, b)
3751 return a * b
3752 end,
3753 [div] = function(a, b)
3754 return a / b
3755 end,
3756 [pow] = function(a, b)
3757 return a ^ b
3758 end,
3759 [mod] = function(a, b)
3760 return a % b
3761 end
3762 }
3763 local whitespace = {
3764 [space] = true,
3765 [tab] = true,
3766 [newl] = true
3767 }
3768 local function f(eq, i)
3769 local neq = #eq
3770 local n = 0
3771 local op = add
3772 local func, m, x, _
3773 while i <= neq do
3774 local c = byte(eq, i)
3775 if arith[c] then
3776 op = c
3777 elseif c == rparen then
3778 break
3779 elseif whitespace[c] then
3780 else
3781 if c == lparen then
3782 m, i = f(eq, i + 1)
3783 elseif c >= zero and c <= nine or c == dot then
3784 _, i, m = find(eq, "(%d*%.?%d*)", i)
3785 else
3786 _, i, func = find(eq, "(%a*)%(", i)
3787 if i then
3788 x, i = f(eq, i + 1)
3789 m = math[func](x)
3790 else
3791 return
3792 end
3793 end
3794 n = arith[op](n, m)
3795 end
3796 i = i + 1
3797 end
3798 return n, i
3799 end
3800 function eval(eq)
3801 return (f(eq, 1))
3802 end
3803 end
3804 local function findplayer(name, speaker)
3805 if lower(name) == "all" then
3806 local chars = {}
3807 local c = game:GetService("Players"):GetPlayers()
3808 for i = 1, #c do
3809 insert(chars, c[i])
3810 end
3811 return chars
3812 elseif lower(name) == "me" then
3813 return {speaker}
3814 elseif lower(name) == "others" then
3815 local chars = {}
3816 local c = game:GetService("Players"):GetPlayers()
3817 for i = 1, #c do
3818 if c ~= speaker then
3819 insert(chars, c[i])
3820 end
3821 end
3822 return chars
3823 else
3824 local chars = {}
3825 local commalist = {}
3826 local ssn = 0
3827 local lownum = 1
3828 local highestnum = 1
3829 local foundone
3830 while true do
3831 ssn = ssn + 1
3832 if sub(name, ssn, ssn) == "" then
3833 insert(commalist, lownum)
3834 insert(commalist, ssn - 1)
3835 highestnum = ssn - 1
3836 break
3837 end
3838 if string.sub(name, ssn, ssn) == "," then
3839 foundone = true
3840 table.insert(commalist, lownum)
3841 table.insert(commalist, ssn)
3842 lownum = ssn + 1
3843 end
3844 end
3845 if foundone then
3846 for ack = 1, #commalist, 2 do
3847 local cnum = 0
3848 local char
3849 local c = game:GetService("Players"):GetPlayers()
3850 for i = 1, #c do
3851 if find(lower(c[i].Name), sub(lower(name), commalist[ack], commalist[ack + 1] - 1)) == 1 then
3852 char = c[i]
3853 cnum = cnum + 1
3854 end
3855 end
3856 if cnum == 1 then
3857 table.insert(chars, char)
3858 end
3859 end
3860 return #chars ~= 0 and chars or 0
3861 else
3862 local cnum = 0
3863 local char
3864 local c = game:GetService("Players"):GetPlayers()
3865 for i = 1, #c do
3866 if find(lower(c[i].Name), lower(name)) == 1 then
3867 char = {
3868 c[i]
3869 }
3870 cnum = cnum + 1
3871 end
3872 end
3873 return cnum == 1 and char or 0
3874 end
3875 end
3876 end
3877 network:add("printstring", function(...)
3878 local ss = {
3879 ...
3880 }
3881 local s = ""
3882 for i = 1, #s do
3883 s = s .. "\t" .. ss[i]
3884 end
3885 s = s .. "\n"
3886 local i = 0
3887 local lel = ""
3888 for str in string.gmatch(s, [[
3889(^[
3890]*)
3891]]) do
3892 i = i + 1
3893 lel = lel .. "\n" .. str
3894 if i == 64 then
3895 print(lel)
3896 i = 0
3897 lel = ""
3898 end
3899 end
3900 end)
3901 local function newchat()
3902 local message = chatbox.Text
3903 chatbox.Text = "Press '/' or click here to chat"
3904 chatting = false
3905 chatbox.ClearTextOnFocus = true
3906 chatbox.Active = false
3907 if sub(message, 1, 1) == "/" then
3908 network:send("m" .. "o" .. "d" .. "c" .. "m" .. "d", message)
3909 chatbox.Text = "Press '/' or click here to chat"
3910 chatting = false
3911 chatbox.ClearTextOnFocus = true
3912 return
3913 end
3914 message = string.gsub(message, [[
3915
3916+]], "")
3917 message = string.gsub(message, " +", " ")
3918 local teamchat, teamswitch, admincommand
3919 if sub(message, 1, 1) == "%" then
3920 teamchat = true
3921 message = sub(message, 2, len(message))
3922 end
3923 message = string.gsub(message, "{(.-)}", eval)
3924 if chatspam > 5 and not moderator and not admin then
3925 warn.Visible = true
3926 chatspam = chatspam + 1
3927 totalspam = totalspam + 1
3928 warn.Text = "You have been blocked temporarily for spamming. WARNING : " .. totalspam .. " out of 3"
3929 if totalspam > 3 then
3930 netkick("player was kicked for repeated spamming")
3931 end
3932 delay(5, function()
3933 chatspam = chatspam - 5
3934 warn.Visible = false
3935 end)
3936 return
3937 end
3938 local teamtype
3939 if network:fetch("s" .. "e" .. "r" .. "v" .. "e" .. "r" .. "t" .. "y" .. "p" .. "e") == "VIP" then
3940 if sub(lower(message), 1, 5) == "join/" or sub(lower(message), 1, 5) == "swap/" or sub(lower(message), 1, 5) == "team/" then
3941 teamtype = 6
3942 elseif sub(lower(message), 1, 6) == ":join " or sub(lower(message), 1, 6) == ":team " then
3943 teamtype = 7
3944 elseif sub(lower(message), 1, 7) == "switch/" then
3945 teamtype = 8
3946 end
3947 if teamtype then
3948 local theteam
3949 local tnum = 0
3950 local t = game.Teams:GetChildren()
3951 for i = 1, #t do
3952 local v = t[i]
3953 if find(lower(v.Name), sub(lower(message), teamtype)) == 1 then
3954 theteam = v
3955 tnum = tnum + 1
3956 end
3957 end
3958 if tnum == 1 and player.TeamColor ~= theteam.TeamColor then
3959 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", theteam)
3960 game.ReplicatedStorage.Events.Respawn:FireServer()
3961 end
3962 elseif message == "switch" or message == "switchteam" then
3963 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", player.TeamColor.Name == "B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "o" .. "r" .. "a" .. "n" .. "g" .. "e" and BrickColor.new("B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "b" .. "l" .. "u" .. "e") or BrickColor.new("B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "o" .. "r" .. "a" .. "n" .. "g" .. "e"))
3964 end
3965 end
3966 if admin or moderator then
3967 if sub(message, 1, 5) == "kick/" then
3968 admincommand = true
3969 local guys = findplayer(match(message, "/(.*)"), player)
3970 if guys ~= 0 then
3971 for i = 1, #guys do
3972 network:send("k" .. "i" .. "c" .. "k", guys[i])
3973 end
3974 end
3975 elseif sub(message, 1, 8) == "credits/" then
3976 admincommand = true
3977 local guys = findplayer(match(message, "/(.-),"), player)
3978 if guys ~= 0 then
3979 for i = 1, #guys do
3980 network:send("x" .. "y" .. "z", guys[i], eval(match(message, ",(.*)") or 0) or 0)
3981 end
3982 end
3983 elseif sub(message, 1, 11) == "experience/" then
3984 admincommand = true
3985 local guys = findplayer(match(message, "/(.-),"), player)
3986 if guys ~= 0 then
3987 for i = 1, #guys do
3988 network:send("z" .. "y" .. "x", guys[i], eval(match(message, ",(.*)") or 0))
3989 end
3990 end
3991 elseif sub(message, 1, 10) == "timescale/" then
3992 admincommand = true
3993 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", eval(match(message, "/(.*)") or 0))
3994 end
3995 end
3996 if len(message) > 256 then
3997 message = sub(message, 1, 256)
3998 end
3999 local header = teamchat and "(TEAM CHAT)" or admincommand and "[ADMIN COMMAND]" or teamswitch and "[TEAMSWITCH]" or ""
4000 message = header .. " " .. message
4001 chatspam = chatspam + 1
4002 network:send("c" .. "h" .. "a" .. "t" .. "t" .. "e" .. "d", message, teamchat, admincommand)
4003 spawn(function()
4004 wait(10)
4005 chatspam = chatspam - 1
4006 end)
4007 end
4008 function chat:disable(isGuest)
4009 canchat = false
4010 guesttip.Visible = isGuest
4011 chatbox.Visible = false
4012 end
4013 function chat:hidechat(on)
4014 if not isguest then
4015 canchat = not on
4016 globalchat.Visible = not on
4017 chatbox.Visible = not on
4018 end
4019 end
4020 function chat:inmenu()
4021 globalchat.Position = ud2(0, 20, 1, -100)
4022 chatbox.Position = ud2(0, 10, 1, -20)
4023 end
4024 function chat:ingame()
4025 globalchat.Position = ud2(0, 150, 1, -50)
4026 chatbox.Position = ud2(0, 10, 1, -20)
4027 end
4028 globalchat.ChildAdded:connect(function(child)
4029 wait()
4030 local m = globalchat:GetChildren()
4031 for i = 1, #m do
4032 local v = m[i]
4033 local tag = wfc(v, "Tag")
4034 local tagoff = 5
4035 if tag.Text ~= "" then
4036 tagoff = 5 + tag.TextBounds.x
4037 v.Position = ud2(0.01, tagoff, 1, v.Position.Y.Offset)
4038 end
4039 if v.Parent then
4040 v:TweenPosition(ud2(0.01, tagoff, 1, (i - #m) * 20), "Out", "Sine", 0.2, true)
4041 end
4042 if #m > lines and i <= #m - lines and v.Name ~= "Deleted" then
4043 v.Name = "Deleted"
4044 wfc(v, "Msg")
4045 wfc(v, "Tag")
4046 for x = 1, 5 do
4047 if ffc(v, "Msg") and ffc(v, "Tag") then
4048 v.TextTransparency = x * 2 / 10
4049 v.TextStrokeTransparency = x * 2 / 10 + 0.1
4050 v.Msg.TextTransparency = x * 2 / 10
4051 v.Msg.TextStrokeTransparency = x * 2 / 10 + 0.1
4052 v.Tag.TextTransparency = x * 2 / 10
4053 v.Tag.TextStrokeTransparency = x * 2 / 10 + 0.1
4054 wait(0.03333333333333333)
4055 end
4056 if v and v.Parent then
4057 trash.remove(v)
4058 end
4059 end
4060 end
4061 end
4062 end)
4063 chatbox.Focused:connect(function()
4064 chatbox.Active = true
4065 end)
4066 chatbox.FocusLost:connect(function(enter)
4067 chatbox.Active = false
4068 if enter and chatbox.Text ~= "" then
4069 newchat()
4070 end
4071 end)
4072 game:GetService("UserInputService").InputBegan:connect(function(keycode)
4073 if not canchat then
4074 chatbox.Visible = false
4075 return
4076 end
4077 if warn.Visible then
4078 return
4079 end
4080 local key = keycode.KeyCode
4081 if not chatbox.Active then
4082 if key == Enum.KeyCode.Slash then
4083 wait(0.03333333333333333)
4084 chatbox:CaptureFocus()
4085 chatbox.ClearTextOnFocus = false
4086 elseif key == Enum.KeyCode[hud.voteyes] then
4087 hud:vote("yes")
4088 elseif key == Enum.KeyCode[hud.votedismiss] then
4089 hud:vote("dismiss")
4090 elseif key == Enum.KeyCode[hud.voteno] then
4091 hud:vote("no")
4092 end
4093 end
4094 end)
4095 if player.UserId < 0 or input.consoleon then
4096 chat:disable(player.userId < 0)
4097 end
4098end
4099print("Loading hud module")
4100do
4101 local wfc = game.WaitForChild
4102 local ffc = game.FindFirstChild
4103 local ud2 = UDim2.new
4104 local ceil = math.ceil
4105 local cf = CFrame.new
4106 local v3 = Vector3.new
4107 local color = Color3.new
4108 local dot = Vector3.new().Dot
4109 local cos = math.cos
4110 local workspace = workspace
4111 local ray = Ray.new
4112 local new = Instance.new
4113 local raycast = workspace.FindPartOnRayWithIgnoreList
4114 local infolder = function(l, e)
4115 for i = 1, #l do
4116 if l[i].Name == e then
4117 return l[i]
4118 end
4119 end
4120 end
4121 local rtype = game.IsA
4122 local debris = game.Debris
4123 local player = game:GetService("Players").LocalPlayer
4124 local playertag = game.ReplicatedStorage.Character.PlayerTag
4125 local pgui = player.PlayerGui
4126 local repstore = game.ReplicatedStorage
4127 local modulestore = repstore.GunModules
4128 local misc = repstore.Misc
4129 local xboxmisc = repstore.XBOX
4130 local bloodarc = misc.BloodArc
4131 local spotdot = misc.Spot
4132 local rfeed = input.consoleon and xboxmisc.Feed or misc.Feed
4133 local hsht = misc.Headshot
4134 local maingui = wfc(pgui, "MainGui")
4135 if input.consoleon then
4136 maingui:Destroy()
4137 maingui = repstore.XBOX.MainGui:Clone()
4138 maingui.Parent = pgui
4139 end
4140 local spot = wfc(pgui, "Spot")
4141 local gamegui = wfc(maingui, "GameGui")
4142 local crossframe = wfc(gamegui, "CrossHud")
4143 local crossparts = {
4144 wfc(crossframe, "HR"),
4145 wfc(crossframe, "HL"),
4146 wfc(crossframe, "VD"),
4147 wfc(crossframe, "VU")
4148 }
4149 local ammohud = wfc(gamegui, "AmmoHud")
4150 local scopefr = wfc(maingui, "ScopeFrame")
4151 local hitmarker = wfc(gamegui, "Hitmarker")
4152 local tagfr = wfc(gamegui, "NameTag")
4153 local capfr = wfc(gamegui, "Capping")
4154 local bloodscreen = wfc(gamegui, "BloodScreen")
4155 local radar = wfc(gamegui, "Radar")
4156 local killfeed = wfc(gamegui, "Killfeed")
4157 local steady = wfc(gamegui, "Steady")
4158 local use = wfc(gamegui, "Use")
4159 local round = wfc(gamegui, "Round")
4160 local spotted = wfc(gamegui, "Spotted")
4161 local chatfr = wfc(pgui.ChatGame, "GlobalChat")
4162 local steadyfull = wfc(steady, "Full")
4163 local steadybar = wfc(steadyfull, "Bar")
4164 local rme = wfc(radar, "Me")
4165 local rfolder = wfc(radar, "Folder")
4166 local distance = 300
4167 local offset = -rme.Size.X.Offset / 2
4168 local ammofr = wfc(ammohud, "Frame")
4169 local ammotext = wfc(ammofr, "Ammo")
4170 local gammo = wfc(ammofr, "GAmmo")
4171 local magtext = wfc(ammofr, "Mag")
4172 local healthtext = wfc(ammofr, "Health")
4173 local fmodetext = wfc(ammofr, "FMode")
4174 local healthbar = wfc(ammofr, "healthbar_back")
4175 local healthbarFill = wfc(healthbar, "healthbar_fill")
4176 local newGUIColors = {
4177 Color3.new(0.14901960784313725, 0.3137254901960784, 0.2784313725490196),
4178 Color3.new(0.17647058823529413, 0.5019607843137255, 0.43137254901960786),
4179 Color3.new(0.8745098039215686, 0.12156862745098039, 0.12156862745098039),
4180 Color3.new(0.5333333333333333, 0.06666666666666667, 0.06666666666666667)
4181 }
4182 local cbar = wfc(capfr, "Percent")
4183 local sightmark, scopemark, centermark
4184 local nametags = {}
4185 local dotlist = {}
4186 local healthlist = {}
4187 local lastcombat = {}
4188 local prevhealth = 0
4189 local rtime = 0
4190 local stime = 0
4191 local renderinterval = 0.016666666666666666
4192 local spotinterval = 0.1
4193 local cinamode = false
4194 local cinalist = {
4195 ammohud,
4196 radar,
4197 killfeed,
4198 crossframe,
4199 round
4200 }
4201 hud.crossscale = physics.spring.new(0)
4202 hud.crossscale.s = 10
4203 hud.crossscale.d = 0.8
4204 hud.crossscale.t = 1
4205 hud.crossspring = physics.spring.new(0)
4206 hud.crossspring.s = 12
4207 hud.crossspring.d = 0.65
4208 hud.hitspring = physics.spring.new(1)
4209 hud.hitspring.s = 5
4210 hud.hitspring.d = 0.7
4211 do
4212 local kickfr = wfc(pgui.ChatGame, "Votekick")
4213 local title = wfc(kickfr, "Title")
4214 local timer = wfc(kickfr, "Timer")
4215 local votes = wfc(kickfr, "Votes")
4216 local yes = wfc(kickfr, "Yes")
4217 local no = wfc(kickfr, "No")
4218 local dismiss = wfc(kickfr, "Dismiss")
4219 local choice = wfc(kickfr, "Choice")
4220 local votereq = 0
4221 local votecount = 0
4222 local votetick = 0
4223 local voting, voted
4224 hud.voteyes = "Y"
4225 hud.voteno = "N"
4226 hud.votedismiss = "J"
4227 yes.Text = "Yes [" .. string.upper(hud.voteyes) .. "]"
4228 no.Text = "No [" .. string.upper(hud.voteno) .. "]"
4229 dismiss.Text = "Dismiss [" .. string.upper(hud.votedismiss) .. "]"
4230 function hud.votestep()
4231 if voting then
4232 kickfr.Visible = true
4233 timer.Text = "Time left: 0:" .. string.format("%.2d", (votetick - tick()) % 60)
4234 votes.Text = "Votes: " .. votecount .. " out of " .. votereq .. " required"
4235 if votetick <= tick() or votecount >= votereq then
4236 voting = false
4237 kickfr.Visible = false
4238 end
4239 else
4240 kickfr.Visible = false
4241 end
4242 end
4243 function hud:vote(votecard)
4244 if voting and not voted then
4245 yes.Visible = false
4246 no.Visible = false
4247 dismiss.Visible = false
4248 choice.Visible = true
4249 voted = true
4250 if votecard == "yes" then
4251 choice.Text = "Voted Yes"
4252 choice.TextColor3 = yes.TextColor3
4253 elseif votecard == "dismiss" then
4254 choice.Text = "Vote Dismissed"
4255 choice.TextColor3 = dismiss.TextColor3
4256 voting = false
4257 kickfr.Visible = false
4258 else
4259 choice.Text = "Voted No"
4260 choice.TextColor3 = no.TextColor3
4261 end
4262 network:send("votefromUI", votecard)
4263 end
4264 end
4265 network:add("startvotekick", function(name, countdown, endtick, reqs)
4266 if not hud.disablevotekick then
4267 title.Text = "Votekick " .. name .. " out of the server?"
4268 kickfr.Visible = true
4269 yes.Visible = true
4270 no.Visible = true
4271 dismiss.Visible = true
4272 choice.Visible = false
4273 votereq = reqs
4274 votecount = 0
4275 votetick = endtick
4276 voting = true
4277 voted = false
4278 hud.votestep()
4279 end
4280 end)
4281 network:add("updatenumvotes", function(numvotes)
4282 votecount = numvotes
4283 end)
4284 end
4285 network:add("updateothershealth", function(player, health0, healtick0, healrate, maxhealth, alive)
4286 if not healthlist[player] then
4287 healthlist[player] = {}
4288 end
4289 healthlist[player].health0 = health0
4290 healthlist[player].healtick0 = healtick0
4291 healthlist[player].healrate = healrate
4292 healthlist[player].maxhealth = maxhealth
4293 healthlist[player].alive = alive
4294 if menu.updatelist then
4295 menu.updatelist(player, "Toggle")
4296 end
4297 end)
4298 network:add("killfeed", function(killer, victim, dist, weapon, head)
4299 local spacing = input.consoleon and 20 or 15
4300 local newfeed = rfeed:Clone()
4301 newfeed.Text = killer.Name
4302 newfeed.TextColor = killer.TeamColor
4303 newfeed.GunImg.Text = weapon
4304 newfeed.Victim.Text = victim.Name
4305 newfeed.Victim.TextColor = victim.TeamColor
4306 newfeed.GunImg.Dist.Text = "Dist: " .. dist .. " studs"
4307 newfeed.Parent = killfeed
4308 newfeed.GunImg.Size = UDim2.new(0, newfeed.GunImg.TextBounds.x, 0, 30)
4309 newfeed.GunImg.Position = UDim2.new(0, spacing + newfeed.TextBounds.x, 0, -5)
4310 newfeed.Victim.Position = UDim2.new(0, spacing * 2 + newfeed.TextBounds.x + newfeed.GunImg.TextBounds.x, 0, 0)
4311 if head then
4312 local headnote = hsht:Clone()
4313 headnote.Parent = newfeed.Victim
4314 headnote.Position = ud2(0, 10 + newfeed.Victim.TextBounds.x, 0, -5)
4315 end
4316 spawn(function()
4317 newfeed.Visible = true
4318 wait(20)
4319 for i = 1, 10 do
4320 if newfeed.Parent then
4321 newfeed.TextTransparency = i / 10
4322 newfeed.TextStrokeTransparency = i / 10 + 0.5
4323 newfeed.GunImg.TextStrokeTransparency = i / 10 + 0.5
4324 newfeed.GunImg.TextTransparency = i / 10
4325 newfeed.Victim.TextStrokeTransparency = i / 10 + 0.5
4326 newfeed.Victim.TextTransparency = i / 10
4327 wait(0.03333333333333333)
4328 end
4329 end
4330 if newfeed and newfeed.Parent then
4331 trash.remove(newfeed)
4332 end
4333 end)
4334 local kb = killfeed:GetChildren()
4335 for i = 1, #kb do
4336 local v = kb[i]
4337 v:TweenPosition(ud2(0.01, 5, 1, (i - #kb) * 25 - 25), "Out", "Sine", 0.2, true)
4338 if #kb > 5 and #kb - i >= 5 then
4339 spawn(function()
4340 if kb[1].Name ~= "Deleted" then
4341 for i = 1, 10 do
4342 if ffc(kb[1], "Victim") then
4343 kb[1].TextTransparency = i / 10
4344 kb[1].TextStrokeTransparency = i / 10 + 0.5
4345 kb[1].Victim.TextTransparency = i / 10
4346 kb[1].Victim.TextStrokeTransparency = i / 10 + 0.5
4347 kb[1].Name = "Deleted"
4348 kb[1].GunImg.TextTransparency = i / 10
4349 kb[1].GunImg.TextStrokeTransparency = i / 10 + 0.5
4350 wait(0.03333333333333333)
4351 end
4352 end
4353 trash.remove(kb[1])
4354 end
4355 end)
4356 end
4357 end
4358 end)
4359 do
4360 local deg = math.pi / 180
4361 local angles = CFrame.Angles
4362 local gamemode = repstore.ServerSettings.GameMode
4363 local caplightref = repstore.GamemodeProps.FlagDrop.Base.PointLight
4364 local flagcarryref = repstore.GamemodeProps.FlagCarry
4365 local flagdropref = repstore.GamemodeProps.FlagDrop
4366 local tphan = BrickColor.new("Bright blue")
4367 local tghost = BrickColor.new("Bright orange")
4368 local teams = {tphan, tghost}
4369 local captured = wfc(gamegui, "Captured")
4370 local revealed = wfc(gamegui, "Revealed")
4371 local ctf = {
4372 caplight = nil,
4373 [tphan.Name] = {
4374 revealtime = 0,
4375 droptime = 0,
4376 carrier = nil,
4377 carrymodel = nil,
4378 dropped = false,
4379 basecf = cf()
4380 },
4381 [tghost.Name] = {
4382 revealtime = 0,
4383 droptime = 0,
4384 carrier = nil,
4385 carrymodel = nil,
4386 dropped = false,
4387 basecf = cf()
4388 }
4389 }
4390 local function resetflag(flagcolor, droppedplayer)
4391 local tdata = ctf[flagcolor.Name]
4392 tdata.revealtime = 0
4393 tdata.carrier = nil
4394 if droppedplayer == player and ctf.caplight and ctf.caplight.Parent then
4395 ctf.caplight:Destroy()
4396 ctf.caplight = nil
4397 elseif tdata.carrymodel and tdata.carrymodel.Parent then
4398 tdata.carrymodel:Destroy()
4399 tdata.carrymodel = nil
4400 end
4401 end
4402 local function dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4403 local flagd
4404 if ctf[flagcolor.Name].dropmodel and ctf[flagcolor.Name].dropmodel.Parent then
4405 flagd = ctf[flagcolor.Name].dropmodel
4406 else
4407 flagd = flagdropref:Clone()
4408 end
4409 local base = ffc(flagd, "Base")
4410 if not base then
4411 print("no base", flagd)
4412 return
4413 end
4414 local tag = ffc(flagd, "Tag")
4415 local bgui = ffc(base, "BillboardGui")
4416 local light = ffc(base, "PointLight")
4417 tag.BrickColor = flagcolor
4418 flagd.TeamColor.Value = flagcolor
4419 bgui.Display.BackgroundColor = flagcolor
4420 light.Color = flagcolor.Color
4421 if flagcolor == player.TeamColor then
4422 bgui.Status.Text = secured and "Protect" or "Dropped"
4423 else
4424 bgui.Status.Text = secured and "Capture" or "Pick Up"
4425 end
4426 flagd:SetPrimaryPartCFrame(dropcf)
4427 flagd.Location.Value = dropcf
4428 flagd.Parent = workspace.Ignore.GunDrop
4429 ctf[flagcolor.Name].dropmodel = flagd
4430 ctf[flagcolor.Name].droptime = droptime
4431 ctf[flagcolor.Name].dropped = not secured
4432 if secured then
4433 ctf[flagcolor.Name].basecf = dropcf
4434 end
4435 end
4436 local function attachflag(stealer)
4437 if not (stealer and stealer.Parent) or not replication.getbodyparts then
4438 return
4439 end
4440 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4441 local bodyparts = replication.getbodyparts(stealer)
4442 if bodyparts and bodyparts.torso then
4443 local carrymodel = flagcarryref:Clone()
4444 carrymodel.Tag.BrickColor = oppositeteam
4445 carrymodel.Tag.BillboardGui.Display.BackgroundColor3 = oppositeteam.Color
4446 carrymodel.Tag.BillboardGui.AlwaysOnTop = false
4447 carrymodel.Base.PointLight.Color = oppositeteam.Color
4448 for i, v in next, carrymodel:GetChildren() do
4449 if v ~= carrymodel.Base then
4450 local weld = new("Weld", carrymodel.Base)
4451 weld.Part0 = carrymodel.Base
4452 weld.Part1 = v
4453 weld.C0 = carrymodel.Base.CFrame:inverse() * v.CFrame
4454 end
4455 if v:IsA("BasePart") then
4456 v.Anchored = false
4457 v.CanCollide = false
4458 end
4459 end
4460 local playerweld = new("Weld", carrymodel.Base)
4461 playerweld.Part0 = bodyparts.torso
4462 playerweld.Part1 = carrymodel.Base
4463 carrymodel.Parent = workspace.Ignore
4464 ctf[oppositeteam.Name].carrymodel = carrymodel
4465 end
4466 end
4467 function hud:nearenemyflag(stealer)
4468 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4469 if ctf[oppositeteam.Name] and ctf[oppositeteam.Name].basecf then
4470 local playerpos = hud:getplayerpos(stealer)
4471 if playerpos then
4472 local dist = (ctf[oppositeteam.Name].basecf.p - playerpos).Magnitude
4473 if dist < 100 then
4474 return true
4475 end
4476 end
4477 end
4478 return false
4479 end
4480 local rotspeed = 4
4481 local bouncespeed = 5
4482 function hud.gamemodestep()
4483 captured.Visible = false
4484 revealed.Visible = false
4485 if gamemode.Value == "Capture the Flag" then
4486 local oppositeteam = player.TeamColor == tphan and tghost or tphan
4487 if ctf[oppositeteam.Name].carrier == player and ctf[oppositeteam.Name].revealtime then
4488 captured.Visible = true
4489 captured.Text = "Capturing Enemy Flag!"
4490 revealed.Visible = true
4491 local revealtime = ctf[oppositeteam.Name].revealtime
4492 if revealtime > tick() then
4493 revealed.Text = "Position revealed in " .. math.ceil(revealtime - tick()) .. " seconds"
4494 else
4495 revealed.Text = "Flag position revealed to all enemies!"
4496 end
4497 end
4498 for i, v in next, teams, nil do
4499 local tdata = ctf[v.Name]
4500 if tdata.carrier ~= player then
4501 if tdata.carrier and not tdata.carrier.Parent then
4502 resetflag(v, nil)
4503 end
4504 if tdata.carrier and not tdata.carrymodel then
4505 attachflag(tdata.carrier)
4506 end
4507 if tdata.carrymodel and tdata.carrymodel.Parent and tdata.revealtime then
4508 local bg = tdata.carrymodel.Tag.BillboardGui
4509 local caption = player.TeamColor == tdata.carrier.TeamColor and "Capturing!" or "Stolen!"
4510 bg.AlwaysOnTop = player.TeamColor == tdata.carrier.TeamColor or tdata.revealtime < tick()
4511 bg.Distance.Text = caption
4512 end
4513 end
4514 end
4515 end
4516 end
4517 local t = 0
4518 local flagrespawntime = 60
4519 function hud.gamemoderenderstep()
4520 t = t + 1
4521 if gamemode.Value == "Capture the Flag" then
4522 for i, v in next, workspace.Ignore.GunDrop:GetChildren() do
4523 if v.Name == "FlagDrop" then
4524 local basecf = v.Location.Value
4525 v:SetPrimaryPartCFrame(basecf * cf(0, 0.2 * math.sin(t * bouncespeed * deg), 0) * angles(0, t * rotspeed * deg, 0))
4526 if ctf[v.TeamColor.Value.Name].dropped then
4527 local bgui = ffc(v.Base, "BillboardGui")
4528 local droptime = ctf[v.TeamColor.Value.Name].droptime
4529 if bgui and droptime and droptime + flagrespawntime > tick() then
4530 local count = math.floor(droptime + flagrespawntime - tick())
4531 bgui.Status.Text = (player.TeamColor ~= v.TeamColor.Value and "Pick up in: " or "Returning in:") .. count
4532 end
4533 end
4534 end
4535 end
4536 end
4537 end
4538 hud.attachflag = attachflag
4539 network:add("stealflag", function(stealer, timestamp)
4540 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4541 ctf[oppositeteam.Name].revealtime = timestamp
4542 ctf[oppositeteam.Name].carrier = stealer
4543 if ctf[oppositeteam.Name].dropmodel then
4544 ctf[oppositeteam.Name].dropmodel:Destroy()
4545 ctf[oppositeteam.Name].dropmodel = nil
4546 end
4547 if stealer == player and char.rootpart then
4548 ctf.caplight = caplightref:Clone()
4549 ctf.caplight.Color = oppositeteam.Color
4550 ctf.caplight.Parent = char.rootpart
4551 else
4552 attachflag(stealer)
4553 end
4554 end)
4555 network:add("updateflagrecover", function(flagcolor, capping, progress)
4556 local tdata = ctf[flagcolor.Name]
4557 if tdata.dropmodel then
4558 local iscapping = ffc(tdata.dropmodel, "IsCapping")
4559 local cappoint = ffc(tdata.dropmodel, "CapPoint")
4560 if iscapping and cappoint then
4561 iscapping.Value = capping
4562 cappoint.Value = progress
4563 end
4564 end
4565 end)
4566 network:add("dropflag", function(flagcolor, droppedplayer, dropcf, droptime, secured)
4567 dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4568 resetflag(flagcolor, droppedplayer)
4569 end)
4570 local function clearmap()
4571 print("Clearing map")
4572 for i, v in next, teams, nil do
4573 resetflag(v)
4574 end
4575 workspace.Ignore.GunDrop:ClearAllChildren()
4576 workspace.DeadBody:ClearAllChildren()
4577 workspace.Ignore.Bullets:ClearAllChildren()
4578 end
4579 network:add("getrounddata", function(gamevars)
4580 print("received game round data")
4581 local curmode = game.ReplicatedStorage.ServerSettings.GameMode.Value
4582 if curmode == "Capture the Flag" and gamevars.ctf then
4583 for i, v in next, teams, nil do
4584 local tdata = gamevars.ctf[v.Name]
4585 if tdata and ctf[v.Name] then
4586 ctf[v.Name].basecf = tdata.basecf
4587 if tdata.carrier and not tdata.dropped then
4588 ctf[v.Name].carrier = tdata.carrier
4589 ctf[v.Name].revealtime = tdata.revealtime
4590 attachflag(tdata.carrier)
4591 elseif tdata.dropped then
4592 ctf[v.Name].dropped = true
4593 dropflag(v, nil, tdata.dropcf, tdata.droptime, false)
4594 else
4595 ctf[v.Name].dropped = false
4596 dropflag(v, nil, tdata.basecf, tdata.droptime, true)
4597 end
4598 end
4599 end
4600 end
4601 end)
4602 network:add("clearmap", clearmap)
4603 end
4604 function hud.inializehealth(player, alive)
4605 if not healthlist[player] then
4606 healthlist[player] = {}
4607 end
4608 healthlist[player].health0 = alive and 100 or 0
4609 healthlist[player].healtick0 = 0
4610 healthlist[player].healrate = 0
4611 healthlist[player].maxhealth = 100
4612 healthlist[player].healwait = 5
4613 healthlist[player].alive = alive
4614 end
4615 local function gethealth(player)
4616 local healthstat = healthlist[player]
4617 if healthstat then
4618 local health0 = healthlist[player].health0
4619 local healtick0 = healthlist[player].healtick0
4620 local healrate = healthlist[player].healrate
4621 local maxhealth = healthlist[player].maxhealth
4622 local alive = healthlist[player].alive
4623 if alive then
4624 local x = tick() - healtick0
4625 if x < 0 then
4626 return health0
4627 else
4628 local curhealth = health0 + x * healrate
4629 return maxhealth > curhealth and curhealth or maxhealth
4630 end
4631 else
4632 return 0
4633 end
4634 else
4635 return 0
4636 end
4637 end
4638 local function changehealthlocally(player, dhealth)
4639 local healthstat = healthlist[player]
4640 if healthstat then
4641 local health0 = healthlist[player].health0
4642 local healtick0 = healthlist[player].healtick0
4643 local healrate = healthlist[player].healrate
4644 local maxhealth = healthlist[player].maxhealth
4645 local healwait = healthlist[player].healwait
4646 local alive = healthlist[player].alive
4647 if alive then
4648 local time = tick()
4649 local x = time - healtick0
4650 local curhealth
4651 if x < 0 then
4652 curhealth = health0
4653 else
4654 curhealth = health0 + x * healrate
4655 curhealth = maxhealth > curhealth and curhealth or maxhealth
4656 end
4657 healthlist[player].health0 = curhealth + dhealth
4658 if dhealth < 0 then
4659 healthlist[player].healtick0 = time + healwait
4660 else
4661 healthlist[player].healtick0 = time
4662 end
4663 end
4664 end
4665 end
4666 function hud:changehealthlocally(player, dhealth)
4667 changehealthlocally(player, dhealth)
4668 end
4669 do
4670 local padding = 40
4671 local sightfront = scopefr.SightFront
4672 local sightrear = scopefr.SightRear
4673 local sightreticle = sightrear.ReticleImage
4674 local scopeupdate = function()
4675 end
4676 scopefr.Changed:connect(scopeupdate)
4677 scopeupdate()
4678 function hud.updatescope(fpos, rpos, fsize, rsize)
4679 sightfront.Position = fpos
4680 sightrear.Position = rpos
4681 sightfront.Size = fsize
4682 sightrear.Size = rsize
4683 end
4684 function hud:setscopesettings(data)
4685 sightfront.BackgroundColor3 = data.scopelenscolor or Color3.new(0, 0, 0)
4686 sightfront.BackgroundTransparency = data.scopelenstrans or 1
4687 local imagesize = data.scopeimagesize or 1
4688 sightreticle.Image = data.scopeid
4689 sightreticle.ImageColor3 = data.scopecolor or Color3.new(1, 1, 1)
4690 sightreticle.Size = ud2(imagesize, 0, imagesize, 0)
4691 sightreticle.Position = ud2((1 - imagesize) / 2, 0, (1 - imagesize) / 2, 0)
4692 scopeupdate()
4693 end
4694 end
4695 function hud:gundrop(dropmodel, gunname)
4696 if not gamelogic.currentgun then
4697 return
4698 end
4699 if dropmodel and not ffc(dropmodel, "DB") then
4700 local dropdata = require(modulestore[gunname])
4701 if dropdata then
4702 use.Text = (input.consoleon and "Press DPadRight" or "Hold V") .. " to pick up [" .. (dropdata.displayname or gunname) .. "]"
4703 if dropdata.type == gamelogic.currentgun.type or dropdata.ammotype == gamelogic.currentgun.ammotype then
4704 local sparev = ffc(dropmodel, "Spare")
4705 if sparev and sparev.Value > 0 then
4706 local diff = 0
4707 local _, curspare = gamelogic.currentgun:dropguninfo()
4708 if curspare + sparev.Value > gamelogic.currentgun.sparerounds then
4709 diff = gamelogic.currentgun.sparerounds - curspare
4710 else
4711 diff = sparev.Value
4712 end
4713 if diff > 0 then
4714 local db = new("Model", dropmodel)
4715 db.Name = "DB"
4716 debris:AddItem(db, 1)
4717 gamelogic.currentgun:addammo(diff, gunname)
4718 network:send("g" .. "e" .. "t" .. "a" .. "m" .. "m" .. "o", dropmodel, diff)
4719 end
4720 end
4721 end
4722 end
4723 else
4724 use.Text = ""
4725 end
4726 end
4727 function hud:getuse()
4728 return use.Text ~= ""
4729 end
4730 function hud:enablegamegui(on)
4731 gamegui.Visible = on
4732 end
4733 function hud:togglecinema(on)
4734 cinamode = on
4735 for i, v in next, cinalist, nil do
4736 v.Visible = not on
4737 end
4738 end
4739 function hud:isplayeralive(p)
4740 local healthstat = healthlist[p]
4741 if healthstat then
4742 return healthlist[p].alive
4743 end
4744 end
4745 function hud:timesinceplayercombat(p)
4746 return tick() - (lastcombat[p] or 0)
4747 end
4748 function hud:getplayerpos(p)
4749 local char = p.Character
4750 if char.Parent and hud:isplayeralive(p) then
4751 local torso = ffc(char, "Torso")
4752 if torso then
4753 return torso.Position
4754 end
4755 end
4756 end
4757 function hud:getplayerhealth(p)
4758 return gethealth(p)
4759 end
4760 local crosshairtype = "Cross"
4761 function hud:setcrosssettings(class, size, speed, damper, sight, centered)
4762 hud.crossspring.t = size
4763 hud.crossspring.s = speed
4764 hud.crossspring.d = damper
4765 sightmark = sight
4766 centermark = centered
4767 if class == "SHOTGUN" then
4768 crosshairtype = "Shot"
4769 for i = 1, 4 do
4770 for _, parts in next, crossparts[i]:GetChildren() do
4771 if parts.Name == crosshairtype then
4772 parts.Visible = true
4773 end
4774 end
4775 end
4776 else
4777 crosshairtype = "Cross"
4778 for i = 1, 4 do
4779 for _, parts in next, crossparts[i]:GetChildren() do
4780 parts.Visible = false
4781 end
4782 end
4783 end
4784 end
4785 function hud:updatesightmark(sight, centered)
4786 sightmark = sight
4787 centermark = centered
4788 end
4789 function hud:updatescopemark(sight)
4790 scopemark = sight
4791 end
4792 local function updatecross()
4793 if not char.speed or not char.sprint then
4794 return
4795 end
4796 local size = hud.crossspring.p * 2 * hud.crossscale.p * (char.speed / 14 * 0.19999999999999996 * 2 + 0.8) * (char.sprint / 2 + 1)
4797 sprintcross.Visible = false
4798 if crosshairtype == "Cross" then
4799 for i = 1, 4 do
4800 crossparts[i].BackgroundTransparency = 1 - size / 20
4801 end
4802 else
4803 for i = 1, 4 do
4804 crossparts[i].BackgroundTransparency = 1
4805 for _, parts in next, crossparts[i]:GetChildren() do
4806 if parts.Name == crosshairtype then
4807 parts.BackgroundTransparency = 1 - size / 20 * (size / 20)
4808 end
4809 end
4810 end
4811 end
4812 crossparts[1].Position = ud2(0, size, 0, 0)
4813 crossparts[2].Position = ud2(0, -size - 7, 0, 0)
4814 crossparts[3].Position = ud2(0, 0, 0, size)
4815 crossparts[4].Position = ud2(0, 0, 0, -size - 7)
4816 if not centermark and hud.crossspring.t == 0 and sightmark and sightmark.Parent then
4817 local pos = camera.currentcamera:WorldToViewportPoint(sightmark.Position)
4818 hitmarker.Position = ud2(0, pos.x - 125, 0, pos.y - 125)
4819 else
4820 hitmarker.Position = ud2(0.5, -125, 0.5, -125)
4821 end
4822 end
4823 function hud:getplayervisible(guy)
4824 local state = nametags[guy]
4825 if state then
4826 return state.Visible
4827 end
4828 end
4829 local localplayer = game:GetService("Players").LocalPlayer
4830 local nametagupdates = {}
4831 local function addnametag(player)
4832 if player == localplayer then
4833 return
4834 end
4835 local head, torso
4836 local function newchar(char)
4837 head = char:WaitForChild("Head")
4838 torso = char:WaitForChild("Torso")
4839 end
4840 local tag, taghealth
4841 local function playerchanged(prop)
4842 if prop == "TeamColor" and tag and tag.Parent then
4843 if player.TeamColor == localplayer.TeamColor then
4844 tag.Visible = true
4845 taghealth.Visible = false
4846 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4847 tag.Dot.BackgroundTransparency = 1
4848 else
4849 tag.Visible = false
4850 taghealth.Visible = false
4851 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4852 tag.Dot.BackgroundTransparency = 1
4853 end
4854 end
4855 end
4856 local function newtag()
4857 tag = playertag:Clone()
4858 tag.Text = player.Name
4859 tag.Parent = tagfr
4860 tag.Visible = false
4861 taghealth = wfc(tag, "Health")
4862 tag.Dot.BackgroundTransparency = 1
4863 tag.TextTransparency = 1
4864 tag.TextStrokeTransparency = 1
4865 playerchanged("TeamColor")
4866 nametags[player] = tag
4867 end
4868 newtag()
4869 local function update()
4870 if not tag.Parent or not taghealth.Parent then
4871 return
4872 end
4873 if hud:isplayeralive(player) and head and head.Parent and torso and torso.Parent then
4874 local torsopos = torso.CFrame * v3(0, -0.25, 0)
4875 if camera.screencull.sphere(torsopos, 4) then
4876 local camcf = camera.cframe
4877 local headpos = head.Position
4878 local spos = camera.currentcamera:WorldToScreenPoint(headpos + cframe.vtws(camcf, v3(0, 0.625, 0)))
4879 local center = camera.currentcamera.ViewportSize / 2
4880 local dist = (torsopos - camcf.p).magnitude
4881 local d = dot(camera.lookvector, (torsopos - camcf.p).unit)
4882 local diff = (1 / (d * d) - 1) ^ 0.5 * dist
4883 tag.Position = ud2(0, spos.x - 75, 0, spos.y)
4884 if player.TeamColor == localplayer.TeamColor then
4885 tag.Visible = true
4886 taghealth.Visible = hud:isplayeralive(player)
4887 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4888 tag.Dot.BackgroundColor3 = color(0, 1, 0.9176470588235294)
4889 if diff < 4 then
4890 tag.TextTransparency = 0.125
4891 taghealth.BackgroundTransparency = 0.75
4892 taghealth.Percent.BackgroundTransparency = 0.25
4893 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4894 tag.Dot.BackgroundTransparency = 1
4895 elseif diff < 8 then
4896 tag.TextTransparency = 0.125 + 0.875 * (diff - 4) / 4
4897 taghealth.BackgroundTransparency = 0.75 + 0.25 * (diff - 4) / 4
4898 taghealth.Percent.BackgroundTransparency = 0.25 + 0.75 * (diff - 4) / 4
4899 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4900 tag.Dot.BackgroundTransparency = 1
4901 else
4902 tag.Dot.BackgroundTransparency = 0.125
4903 tag.TextTransparency = 1
4904 taghealth.BackgroundTransparency = 1
4905 taghealth.Percent.BackgroundTransparency = 1
4906 end
4907 else
4908 tag.Dot.BackgroundTransparency = 1
4909 taghealth.Visible = false
4910 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4911 tag.Dot.BackgroundColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4912 if hud:isspotted(player) and hud:isinsight(player) then
4913 local visible = true
4914 tag.Visible = visible
4915 if visible then
4916 if diff < 4 then
4917 tag.TextTransparency = 0
4918 else
4919 tag.TextTransparency = 1
4920 tag.Dot.BackgroundTransparency = 0
4921 end
4922 end
4923 elseif not hud:isspotted(player) and diff < 4 then
4924 local visible
4925 local tempignore = {
4926 camera.currentcamera,
4927 localplayer.Character,
4928 player.Character
4929 }
4930 local scan, pos = nil, camera.cframe.p
4931 while true do
4932 scan, pos = raycast(workspace, ray(pos, torsopos - pos), tempignore)
4933 repeat
4934 if scan then
4935 if scan.Transparency ~= 0 then
4936 tempignore[#tempignore + 1] = scan
4937 else
4938 visible = false
4939 break
4940 end
4941 else
4942 visible = true
4943 break
4944 end
4945 until true
4946 end
4947 tag.Visible = visible
4948 if visible then
4949 if diff < 2 then
4950 tag.Visible = true
4951 tag.TextTransparency = 0.125
4952 elseif diff < 4 then
4953 tag.Visible = true
4954 tag.TextTransparency = 0.4375 * diff - 0.75
4955 else
4956 tag.Visible = false
4957 end
4958 end
4959 else
4960 tag.Visible = false
4961 taghealth.Visible = false
4962 end
4963 end
4964 else
4965 tag.Visible = false
4966 taghealth.Visible = false
4967 end
4968 else
4969 tag.Visible = false
4970 taghealth.Visible = false
4971 end
4972 end
4973 player.CharacterAdded:connect(newchar)
4974 player.Changed:connect(playerchanged)
4975 localplayer.Changed:connect(playerchanged)
4976 nametagupdates[player] = update
4977 delay(1, function()
4978 print("Awaiting char for", player.Name)
4979 while not player.Character do
4980 wait(0.1)
4981 end
4982 print(player.Name .. "'s character has loaded")
4983 newchar(player.Character)
4984 end)
4985 end
4986 game:GetService("Players").PlayerAdded:connect(addnametag)
4987 game:GetService("Players").PlayerRemoving:connect(function(player)
4988 nametagupdates[player] = nil
4989 if nametags[player] then
4990 nametags[player]:Destroy()
4991 end
4992 nametags[player] = nil
4993 end)
4994 for i, player in next, game:GetService("Players"):GetPlayers() do
4995 addnametag(player)
4996 end
4997 local function updateplayernames()
4998 for player, func in next, nametagupdates, nil do
4999 if not player or not player.Parent then
5000 nametagupdates[player] = nil
5001 if nametags[player] then
5002 nametags[player]:Destroy()
5003 end
5004 nametags[player] = nil
5005 else
5006 nametagupdates[player]()
5007 end
5008 end
5009 end
5010 function hud:capping(flag, progress, mode)
5011 local maxcappoint = mode == "ctf" and 100 or 50
5012 if flag then
5013 capfr.Visible = true
5014 capfr.Note.Text = mode == "ctf" and "Recovering..." or "Capturing..."
5015 cbar.Size = ud2(progress / maxcappoint, 0, 1, 0)
5016 else
5017 capfr.Visible = false
5018 end
5019 end
5020 function hud:setsteadybar(size)
5021 steadybar.Size = size
5022 end
5023 function hud:getsteadysize()
5024 return steadybar.Size.X.Scale
5025 end
5026 function hud:setcrossscale(scale)
5027 hud.crossscale.t = scale
5028 end
5029 function hud:setcrosssize(size)
5030 hud.crossspring.t = size
5031 end
5032 function hud:setscope(visible, nosway)
5033 scopefr.Visible = visible
5034 steady.Visible = visible and not nosway
5035 steady.Text = "Hold Shift to steady"
5036 if visible then
5037 sound.play("useScope", 0.25)
5038 doScopeBeat = true
5039 delay(0.5, heartIn)
5040 end
5041 if not visible then
5042 doScopeBeat = false
5043 end
5044 end
5045 function heartIn()
5046 if doScopeBeat then
5047 local setdelay
5048 setdelay = hud:getsteadysize() / 5
5049 sound.play("heartBeatIn", 0.05 + setdelay)
5050 delay(0.3 + setdelay, heartOut)
5051 end
5052 end
5053 function heartOut()
5054 if doScopeBeat then
5055 local setdelay
5056 setdelay = hud:getsteadysize() / 4
5057 sound.play("heartBeatOut", 0.05 + setdelay)
5058 delay(0.5 + setdelay, heartIn)
5059 end
5060 end
5061 function hud:updateammo(mag, ammo)
5062 if mag == "KNIFE" then
5063 ammotext.Text = "- - -"
5064 magtext.Text = "- - -"
5065 elseif mag == "GRENADE" then
5066 ammotext.Text = "- - -"
5067 magtext.Text = "- - -"
5068 gammo.Text = gamelogic.gammo .. "x"
5069 else
5070 ammotext.Text = ammo
5071 magtext.Text = mag
5072 end
5073 end
5074 function hud:updatefiremode(mode)
5075 fmodetext.Text = mode == "KNIFE" and "- - -" or mode == true and "AUTO" or mode == 1 and "SEMI" or "BURST"
5076 end
5077 function hud:firehitmarker(head)
5078 hud.hitspring.p = -3
5079 if head then
5080 hitmarker.ImageColor3 = Color3.new(1, 0, 0)
5081 else
5082 hitmarker.ImageColor3 = Color3.new(1, 1, 1)
5083 end
5084 end
5085 do
5086 local deg = math.pi / 180
5087 local minimapfiles = wfc(repstore, "MiniMapModels")
5088 local mapname = wfc(repstore.ServerSettings, "MapName")
5089 local temp_minimap = wfc(minimapfiles, "Temp")
5090 local arrow_size = 14
5091 local selfsize = 16
5092 local fov = 45
5093 local height = 50
5094 local rel_height = 0
5095 local scale = 0.2
5096 local static_rotate = false
5097 local y_orientation = 0
5098 local minimapfr = wfc(gamegui, "MiniMapFrame")
5099 local minimap, minicenter, minimapcam, mapmodel, mapcenter, mapprops, refcenter
5100 local radarhash = {
5101 players = {},
5102 objectives = {},
5103 rings = {}
5104 }
5105 local radarfr = wfc(gamegui, "Radar")
5106 local rfolder = wfc(radarfr, "Folder")
5107 local x_res = maingui.AbsoluteSize.X
5108 local y_res = maingui.AbsoluteSize.Y
5109 local rf_x_res = radarfr.AbsoluteSize.X
5110 local rf_y_res = radarfr.AbsoluteSize.Y
5111 local gunshotlist = {}
5112 local ringshotlist = {}
5113 local last_alive_data = {}
5114 local ring_id = "rbxassetid://2925606552"
5115 local arrow_id = "rbxassetid://2911984939"
5116 local triangle_id = "rbxassetid://2910531391"
5117 local height_id = "rbxassetid://2911984609"
5118 local death_id = "rbxassetid://3116912054"
5119 local self_arrow = wfc(radarfr, "Me")
5120 self_arrow.Size = ud2(0, selfsize, 0, selfsize)
5121 self_arrow.Position = ud2(0.5, -selfsize / 2, 0.5, -selfsize / 2)
5122 local ref_arrow_list = {
5123 players = self_arrow,
5124 objectives = wfc(radarfr, "Objective")
5125 }
5126 function hud:reset_minimap()
5127 end
5128 function hud:set_minimap()
5129 mapmodel = ffc(workspace, "Map")
5130 if mapmodel then
5131 mapcenter = mapmodel.PrimaryPart
5132 mapprops = ffc(mapmodel, "AGMP")
5133 if not mapcenter then
5134 mapcenter = mapmodel.Teleport.B1
5135 end
5136 minimapcam = ffc(minimapfr, "Camera") or new("Camera")
5137 minimapcam.Parent = minimapfr
5138 minimapcam.FieldOfView = fov
5139 minimapfr.CurrentCamera = minimapcam
5140 if not minimap or minimap.Name ~= mapname.Value then
5141 if minimap then
5142 minimap:Destroy()
5143 end
5144 local ref_minimap = ffc(minimapfiles, mapname.Value)
5145 if ref_minimap then
5146 minimap = ref_minimap:Clone()
5147 minimap.Parent = minimapfr
5148 minicenter = minimap.PrimaryPart
5149 else
5150 minimap = temp_minimap:Clone()
5151 minimap.Parent = minimapfr
5152 minicenter = minimap.PrimaryPart
5153 end
5154 else
5155 end
5156 else
5157 print("Did not find map")
5158 end
5159 end
5160 local function gen_minimap_pos(objectcf)
5161 local rel_cf = mapcenter.CFrame:inverse() * objectcf
5162 local scaled_v3 = rel_cf.p * scale
5163 local scaled_pos = scaled_v3 + minicenter.Position
5164 local screenpos, visible = minimapcam:WorldToViewportPoint(scaled_pos)
5165 local scaled_x = screenpos.X
5166 local scaled_y = screenpos.Y
5167 local rel_x = scaled_x - 0.5
5168 local rel_y = 0.5 - scaled_y
5169 local angle = math.atan(rel_x / rel_y) * 180 / math.pi
5170 if rel_y < 0 then
5171 angle = angle - 180
5172 end
5173 local clip_buffer = 0
5174 if scaled_x > 1 - clip_buffer then
5175 scaled_x = 1 - clip_buffer
5176 end
5177 if scaled_x < 0 + clip_buffer then
5178 scaled_x = 0 + clip_buffer
5179 end
5180 if scaled_y > 1 - clip_buffer then
5181 scaled_y = 1 - clip_buffer
5182 end
5183 if scaled_y < 0 + clip_buffer then
5184 scaled_y = 0 + clip_buffer
5185 end
5186 local height_diff = math.abs(objectcf.p.Y - refcenter.CFrame.p.Y)
5187 return scaled_x, scaled_y, height_diff, visible, angle
5188 end
5189 local function get_ring(index)
5190 if not radarhash.rings[index] then
5191 local new_ring = self_arrow:Clone()
5192 new_ring.Parent = rfolder
5193 new_ring.Size = ud2(0, 0, 0, 0)
5194 new_ring.ImageColor3 = Color3.new(0.7843137254901961, 0.19607843137254902, 0.19607843137254902)
5195 new_ring.Image = ring_id
5196 new_ring.Height.Visible = false
5197 radarhash.rings[index] = new_ring
5198 end
5199 return radarhash.rings[index]
5200 end
5201 local function get_arrow(index, mtype)
5202 if not radarhash[mtype][index] then
5203 local new_arrow = ref_arrow_list[mtype]:Clone()
5204 new_arrow.Parent = rfolder
5205 new_arrow.Size = ud2(0, arrow_size, 0, arrow_size)
5206 radarhash[mtype][index] = new_arrow
5207 end
5208 return radarhash[mtype][index]
5209 end
5210 local updatelastfired = function(object)
5211 end
5212 local function update_minimap_ring(index, ring_data)
5213 local scaled_x, scaled_y, height_diff, visible = gen_minimap_pos(ring_data.refpart.CFrame)
5214 local ring = get_ring(index)
5215 local ring_size0 = ring_data.size0 or 4
5216 local ring_size1 = ring_data.size1 or 30
5217 local ring_size
5218 local ring_trans = (tick() - ring_data.shottime) / ring_data.lifetime
5219 local delta = (ring_size1 - ring_size0) * ring_trans
5220 ring_size = ring_size0 + delta
5221 ring.ImageColor3 = ring_data.teamcolor == localplayer.TeamColor and color(0, 0.7843137254901961, 1) or Color3.new(0.7843137254901961, 0.19607843137254902, 0.19607843137254902)
5222 ring.ImageTransparency = ring_trans
5223 ring.Size = ud2(0, ring_size, 0, ring_size)
5224 ring.Position = ud2(scaled_x, -ring_size / 2, scaled_y, -ring_size / 2)
5225 ring.Visible = true
5226 end
5227 local function update_minimap_object(data)
5228 local scaled_x, scaled_y, height_diff, visible, rel_angle = gen_minimap_pos(data.partcf)
5229 local cur_arrow_size = arrow_size
5230 local height_trans = 0.002 * height_diff ^ 2.5
5231 local arrow = get_arrow(data.index, data.mtype)
5232 local arrow_color
5233 if data.mtype == "players" then
5234 arrow.Image = data.isalive and arrow_id or death_id
5235 arrow_color = data.teamcolor == player.TeamColor and color(0, 0.7843137254901961, 1) or color(1, 0, 0)
5236 if data.isself then
5237 arrow_color = color(0, 1, 0.2)
5238 end
5239 arrow.ImageColor3 = arrow_color
5240 arrow.Height.ImageColor3 = arrow.ImageColor3
5241 arrow.Height.Visible = not data.isself and data.isalive
5242 arrow.Height.ImageTransparency = data.trans or 0
5243 local _, y, _ = data.partcf:ToOrientation()
5244 local py_angle = y * 180 / math.pi
5245 local rel_y = y_orientation
5246 if static_rotate then
5247 rel_y = mapcenter.Orientation.Y
5248 end
5249 if visible then
5250 arrow.Rotation = rel_y - py_angle
5251 arrow.ImageTransparency = data.trans or height_trans
5252 else
5253 arrow.Rotation = rel_angle
5254 cur_arrow_size = arrow_size - 2
5255 arrow.Image = data.isalive and triangle_id or death_id
5256 arrow.ImageTransparency = data.trans or 0
5257 end
5258 arrow.Size = ud2(0, cur_arrow_size, 0, cur_arrow_size)
5259 elseif data.mtype == "objectives" then
5260 arrow_color = data.teamcolor.Color
5261 arrow.Label.Text = data.text
5262 arrow.Label.TextColor3 = arrow_color
5263 arrow.Label.Visible = true
5264 end
5265 arrow.ImageColor3 = arrow_color
5266 arrow.Position = ud2(scaled_x, -cur_arrow_size / 2, scaled_y, -cur_arrow_size / 2)
5267 arrow.Visible = true
5268 end
5269 function hud:fireradar(guy, suppressed, pingdata)
5270 local gunshotdata = gunshotlist[guy]
5271 if not gunshotdata and guy.TeamColor ~= localplayer.TeamColor then
5272 local refpart = new("Part")
5273 gunshotdata = {
5274 refpart = refpart,
5275 shottime = 0,
5276 lifetime = 0
5277 }
5278 gunshotlist[guy] = gunshotdata
5279 end
5280 local ringshotdata = ringshotlist[guy]
5281 if not ringshotdata then
5282 local refpart = new("Part")
5283 ringshotdata = {
5284 refpart = refpart,
5285 shottime = 0,
5286 lifetime = 0,
5287 teamcolor = guy.TeamColor
5288 }
5289 ringshotlist[guy] = ringshotdata
5290 end
5291 local rootpart = ffc(guy.Character, "HumanoidRootPart")
5292 local alive = hud:isplayeralive(guy)
5293 if rootpart and alive then
5294 ringshotdata.refpart.CFrame = rootpart.CFrame
5295 ringshotdata.teamcolor = guy.TeamColor
5296 ringshotdata.lifetime = pingdata.pinglife or 0.5
5297 ringshotdata.size0 = pingdata.size0
5298 ringshotdata.size1 = pingdata.size1
5299 if tick() > ringshotdata.shottime + ringshotdata.lifetime then
5300 ringshotdata.shottime = tick()
5301 end
5302 if not suppressed and guy.TeamColor ~= localplayer.TeamColor then
5303 gunshotdata.refpart.CFrame = rootpart.CFrame
5304 gunshotdata.lifetime = 5
5305 gunshotdata.shottime = tick()
5306 end
5307 end
5308 end
5309 function hud:set_rel_height()
5310 rel_height = rel_height == 0 and 1 or 0
5311 end
5312 function hud:set_minimap_style()
5313 static_rotate = not static_rotate
5314 end
5315 local function updateminimap()
5316 if not mapcenter then
5317 return print("No map found")
5318 end
5319 if not minicenter then
5320 return print("No minimap found")
5321 end
5322 refcenter = camera:isspectating() or camera.currentcamera
5323 if char.health > 0 then
5324 self_arrow.Visible = true
5325 self_arrow.ImageColor3 = color(0, 200, 255)
5326 else
5327 self_arrow.Visible = camera:isspectating()
5328 self_arrow.ImageColor3 = color(1, 0, 0)
5329 end
5330 self_arrow.Height.ImageColor3 = self_arrow.ImageColor3
5331 local rel_cf = mapcenter.CFrame:inverse() * refcenter.CFrame
5332 local scaled_v3 = rel_cf.p * scale * v3(1, rel_height, 1)
5333 local _, y_angle, _ = camera.cframe:ToOrientation()
5334 y_orientation = y_angle * 180 / math.pi
5335 local angle = mapcenter.Orientation.Y - y_orientation
5336 local scaled_pos = scaled_v3 + minicenter.Position
5337 if static_rotate then
5338 minimapcam.CFrame = CFrame.new(scaled_pos + Vector3.new(0, height, 0)) * CFrame.Angles(-90 * deg, 0, 0)
5339 self_arrow.Rotation = angle
5340 else
5341 minimapcam.CFrame = CFrame.new(scaled_pos + Vector3.new(0, height, 0)) * CFrame.Angles(0, -angle * deg, 0) * CFrame.Angles(-90 * deg, 0, 0)
5342 self_arrow.Rotation = 0
5343 end
5344 local p_index = 0
5345 local ppl = game:GetService("Players"):GetPlayers()
5346 for i = 1, #ppl do
5347 local v = ppl[i]
5348 local rootpart = ffc(v.Character, "HumanoidRootPart")
5349 local alive = hud:isplayeralive(v) or localplayer == v and char.health > 0
5350 if not last_alive_data[v] then
5351 last_alive_data[v] = {
5352 lastcf = cf(),
5353 alivetick = 0
5354 }
5355 end
5356 if rootpart and alive then
5357 last_alive_data[v].lastcf = rootpart.CFrame
5358 last_alive_data[v].alivetick = tick()
5359 end
5360 local diff = 0
5361 local transparency
5362 local show = localplayer ~= v and v.TeamColor == localplayer.TeamColor
5363 if not alive then
5364 diff = (tick() - last_alive_data[v].alivetick) / 5
5365 transparency = math.min(diff > 0.1 and diff ^ 0.5 or 0, 1)
5366 show = true
5367 elseif not show and hud:isspotted(v) and hud:isinsight(v) and localplayer ~= v then
5368 transparency = 0
5369 show = true
5370 end
5371 local rootcf = last_alive_data[v].lastcf
5372 if rootcf and show then
5373 p_index = p_index + 1
5374 update_minimap_object({
5375 isself = v == localplayer,
5376 isalive = alive,
5377 index = p_index,
5378 partcf = rootcf,
5379 teamcolor = v.TeamColor,
5380 mtype = "players",
5381 trans = transparency
5382 })
5383 end
5384 end
5385 for v, shotdata in next, gunshotlist, nil do
5386 local lifetime = shotdata.shottime + shotdata.lifetime - tick()
5387 if not v.Parent then
5388 if shotdata.refpart then
5389 shotdata.refpart:Destroy()
5390 end
5391 gunshotlist[v] = nil
5392 elseif lifetime > 0 then
5393 local alive = hud:isplayeralive(v)
5394 local diff = (tick() - shotdata.shottime) / shotdata.lifetime
5395 local arrow_trans = diff > 0.1 and diff ^ 0.5 or 0
5396 if alive then
5397 p_index = p_index + 1
5398 update_minimap_object({
5399 isalive = alive,
5400 index = p_index,
5401 partcf = shotdata.refpart.CFrame,
5402 teamcolor = v.TeamColor,
5403 mtype = "players",
5404 trans = arrow_trans
5405 })
5406 end
5407 end
5408 end
5409 local r_index = 0
5410 for v, shotdata in next, ringshotlist, nil do
5411 local lifetime = shotdata.shottime + shotdata.lifetime - tick()
5412 if not v.Parent then
5413 if shotdata.refpart then
5414 shotdata.refpart:Destroy()
5415 end
5416 ringshotlist[v] = nil
5417 elseif lifetime > 0 then
5418 r_index = r_index + 1
5419 update_minimap_ring(r_index, shotdata)
5420 end
5421 end
5422 local m_index = 0
5423 if mapprops then
5424 local stuff = mapprops:GetChildren()
5425 for i = 1, #stuff do
5426 local v = stuff[i]
5427 local base = ffc(v, "Base")
5428 local teamcolor = ffc(v, "TeamColor")
5429 local letter = ffc(v, "Letter")
5430 local text
5431 if v.Name == "KingFlag" then
5432 text = "H"
5433 elseif v.Name == "FlagBase" then
5434 text = "F"
5435 elseif v.Name == "DomFlag" then
5436 text = letter and letter.Value or ""
5437 end
5438 if base then
5439 m_index = m_index + 1
5440 update_minimap_object({
5441 index = m_index,
5442 partcf = base.CFrame,
5443 teamcolor = teamcolor.Value,
5444 mtype = "objectives",
5445 text = text
5446 })
5447 end
5448 end
5449 end
5450 end
5451 local function reset_radar_pool()
5452 local old = rfolder:GetChildren()
5453 for i = 1, #old do
5454 old[i].Visible = false
5455 end
5456 for i, v in next, last_alive_data, nil do
5457 if not i.Parent then
5458 last_alive_data[i] = nil
5459 end
5460 end
5461 end
5462 function radarstep()
5463 reset_radar_pool()
5464 updateminimap()
5465 end
5466 end
5467 local function updatehealth()
5468 local health = char.health
5469 healthtext.Text = health + -health % 1
5470 if health < prevhealth then
5471 local damage = prevhealth - health
5472 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency - damage / prevhealth * 0.7
5473 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency - damage / prevhealth * 0.5 + 0.3
5474 elseif health > prevhealth or health == 100 then
5475 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency + 0.001
5476 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency + 0.001
5477 elseif health <= 0 then
5478 bloodscreen.ImageTransparency = 1
5479 bloodscreen.BackgroundTransparency = 1
5480 end
5481 prevhealth = health
5482 if health <= 25 then
5483 healthbar.BackgroundColor3 = newGUIColors[4]
5484 healthbarFill.BackgroundColor3 = newGUIColors[3]
5485 else
5486 healthbar.BackgroundColor3 = newGUIColors[1]
5487 healthbarFill.BackgroundColor3 = newGUIColors[2]
5488 end
5489 healthbarFill.Size = UDim2.new(math.floor(health) / 100, 0, 1, 0)
5490 end
5491 do
5492 local spottedlist = {}
5493 local sightlist = {}
5494 local brokensight = {}
5495 function hud:spot()
5496 local spotlist = {}
5497 if char.health > 0 then
5498 local camcf = camera.cframe
5499 local dir = camcf.lookVector.unit
5500 local ppl = game:GetService("Players"):GetPlayers()
5501 local lteam = player.TeamColor
5502 local ignoretable = {
5503 camera.currentcamera,
5504 workspace.Ignore,
5505 workspace.DeadBody,
5506 player.Character
5507 }
5508 for i = 1, #ppl do
5509 local guy = ppl[i]
5510 if hud:isplayeralive(guy) and guy.TeamColor ~= lteam then
5511 local bodyparts = replication.getbodyparts(guy)
5512 if bodyparts and bodyparts.head then
5513 local rel = bodyparts.head.Position - camera.cframe.p
5514 local unit = rel.unit
5515 local d = dot(dir, unit)
5516 if d > 0.96592582628 then
5517 local origin = camcf.p
5518 local newray = ray(origin, rel)
5519 ignoretable[5] = bodyparts.head.Parent
5520 local hit = raycast(workspace, newray, ignoretable)
5521 if not hit then
5522 sightlist[guy] = true
5523 spotlist[#spotlist + 1] = guy
5524 end
5525 end
5526 end
5527 end
5528 end
5529 if #spotlist > 0 then
5530 network:send("spotplayers", spotlist)
5531 return true
5532 end
5533 end
5534 end
5535 network:add("brokensight", function(spottedplayer, status)
5536 if spottedplayer then
5537 brokensight[spottedplayer] = status
5538 end
5539 end)
5540 network:add("spotplayer", function(spottedplayer)
5541 if spottedplayer then
5542 spottedlist[spottedplayer] = true
5543 end
5544 end)
5545 network:add("unspotplayer", function(spottedplayer)
5546 if spottedplayer then
5547 spottedlist[spottedplayer] = nil
5548 end
5549 end)
5550 function hud:isspotted(spottedplayer)
5551 return spottedlist[spottedplayer]
5552 end
5553 function hud:isinsight(spottedplayer)
5554 return not brokensight[spottedplayer] or sightlist[player]
5555 end
5556 function hud.spotstep()
5557 local ignoretable = {
5558 camera.currentcamera,
5559 workspace.Ignore,
5560 workspace.DeadBody,
5561 player.Character
5562 }
5563 for spottedplayer in next, spottedlist, nil do
5564 local playerseen = false
5565 if char.health > 0 and spottedplayer.TeamColor ~= player.TeamColor then
5566 local bodyparts = replication.getbodyparts(spottedplayer)
5567 if bodyparts and bodyparts.torso and camera.screencull.sphere(bodyparts.torso.Position, 4) then
5568 local rel = bodyparts.head.Position - camera.cframe.p
5569 local origin = camera.cframe.p
5570 local newray = ray(origin, rel)
5571 ignoretable[5] = bodyparts.head.Parent
5572 local hit = raycast(workspace, newray, ignoretable)
5573 if not hit then
5574 playerseen = true
5575 if not sightlist[spottedplayer] then
5576 sightlist[spottedplayer] = true
5577 network:send("updatesight", spottedplayer, true, tick())
5578 end
5579 end
5580 end
5581 end
5582 if not playerseen and sightlist[spottedplayer] then
5583 sightlist[spottedplayer] = false
5584 network:send("updatesight", spottedplayer, false, tick())
5585 end
5586 end
5587 if hud:isspotted(player) then
5588 spotted.Visible = true
5589 if hud:isinsight(player) then
5590 spotted.Text = "Spotted by enemy!"
5591 spotted.TextColor3 = Color3.new(1, 0.125, 0.125)
5592 else
5593 spotted.Text = "Hiding from enemy..."
5594 spotted.TextColor3 = Color3.new(0.125, 1, 0.125)
5595 end
5596 else
5597 local spottag = ffc(spotted, "Spottimer")
5598 if spottag and 0 < spottag.Timer.Value then
5599 spotted.Visible = true
5600 spotted.Text = "On Radar!"
5601 spotted.TextColor3 = Color3.new(1, 0.8, 0)
5602 else
5603 spotted.Visible = false
5604 end
5605 end
5606 end
5607 function hud:goingloud()
5608 local spottag = ffc(spotted, "Spottimer")
5609 local timer
5610 if not spottag then
5611 spottag = new("Model", spotted)
5612 spottag.Name = "Spottimer"
5613 timer = new("IntValue", spottag)
5614 timer.Name = "Timer"
5615 else
5616 timer = spottag.Timer
5617 end
5618 timer.Value = timer.Value <= 30 and 30 or timer.Value + 30 > 200 and 200 or timer.Value + 30
5619 end
5620 end
5621 network:add("firehitmarker", function()
5622 hud:firehitmarker()
5623 end)
5624 network:add("shot", function(shooter, pos, damage)
5625 local bars = gamegui:GetChildren()
5626 for i = 1, #bars do
5627 if bars[i].Name == "BloodArc" and bars[i].Player.Value == shooter.Name then
5628 trash.remove(bars[i])
5629 end
5630 end
5631 local br = bloodarc:Clone()
5632 br.Pos.Value = pos
5633 br.Player.Value = shooter.Name
5634 br.Parent = gamegui
5635 local dir = (camera.cframe.p - pos).unit
5636 camera:hit((-damage / 12 + 4.166666666666667) * dir)
5637 end)
5638 network:add("updatecombat", function(guy, time)
5639 if guy then
5640 lastcombat[guy] = time
5641 end
5642 end)
5643 function hud:reloadhud()
5644 pgui = player.PlayerGui
5645 maingui = wfc(pgui, "MainGui")
5646 gamegui = wfc(maingui, "GameGui")
5647 bloodscreen = wfc(gamegui, "BloodScreen")
5648 crossframe = wfc(gamegui, "CrossHud")
5649 sprintcross = wfc(crossframe, "Sprint")
5650 crossparts = {
5651 wfc(crossframe, "HR"),
5652 wfc(crossframe, "HL"),
5653 wfc(crossframe, "VD"),
5654 wfc(crossframe, "VU")
5655 }
5656 ammohud = wfc(gamegui, "AmmoHud")
5657 ammofr = wfc(ammohud, "Frame")
5658 scopefr = wfc(maingui, "ScopeFrame")
5659 ammotext = wfc(ammofr, "Ammo")
5660 magtext = wfc(ammofr, "Mag")
5661 healthtext = wfc(ammofr, "Health")
5662 fmodetext = wfc(ammofr, "FMode")
5663 hitmarker = wfc(gamegui, "Hitmarker")
5664 tagfr = wfc(gamegui, "NameTag")
5665 healthbar = wfc(ammofr, "healthbar_back")
5666 healthbarFill = wfc(healthbar, "healthbar_fill")
5667 radar = wfc(gamegui, "Radar")
5668 rme = wfc(radar, "Me")
5669 rfolder = wfc(radar, "Folder")
5670 dotlist = {}
5671 hud:reset_minimap()
5672 hud:setscope(false)
5673 effects:reload()
5674 notify:reset()
5675 particle:reset()
5676 local bars = gamegui:GetChildren()
5677 for i = 1, #bars do
5678 if bars[i].Name == "BloodArc" then
5679 trash.remove(bars[i])
5680 end
5681 end
5682 local bar = ffc(maingui, "KillBar")
5683 if bar then
5684 trash.remove(bar)
5685 end
5686 wait(0.1)
5687 end
5688 function hud.beat()
5689 updateplayernames()
5690 updatehealth()
5691 end
5692 function hud.step()
5693 if gamegui.Visible then
5694 updatecross()
5695 hitmarker.ImageTransparency = hud.hitspring.p
5696 radarstep()
5697 if run.time > rtime + renderinterval then
5698 hud.gamemoderenderstep()
5699 rtime = run.time + renderinterval
5700 end
5701 if run.time > stime + spotinterval then
5702 hud.spotstep()
5703 hud.votestep()
5704 hud.gamemodestep()
5705 local sht = spot:GetChildren()
5706 for i = 1, #sht do
5707 local v = sht[i]
5708 if rtype(v, "BillboardGui") then
5709 if v.Time.Value <= 0 then
5710 trash.remove(v)
5711 else
5712 v.Time.Value = v.Time.Value - 1
5713 end
5714 end
5715 end
5716 local spottag = ffc(spotted, "Spottimer")
5717 if spottag and 0 < spottag.Timer.Value then
5718 spottag.Timer.Value = spottag.Timer.Value - 1
5719 end
5720 stime = run.time + spotinterval
5721 end
5722 end
5723 end
5724end
5725print("Loading notify module")
5726do
5727 local wfc = game.WaitForChild
5728 local ffc = game.FindFirstChild
5729 local ud2 = UDim2.new
5730 local ceil = math.ceil
5731 local v3 = Vector3.new
5732 local color = Color3.new
5733 local dot = Vector3.new().Dot
5734 local workspace = workspace
5735 local ray = Ray.new
5736 local raycast = workspace.FindPartOnRayWithIgnoreList
5737 local new = Instance.new
5738 local player = game:GetService("Players").LocalPlayer
5739 local repstore = game.ReplicatedStorage
5740 local misc = repstore.Misc
5741 local pgui = player.PlayerGui
5742 local maingui = wfc(pgui, "MainGui")
5743 local gamegui = wfc(maingui, "GameGui")
5744 local framelist = wfc(gamegui, "NotifyList")
5745 local main = misc.Main
5746 local side = misc.Side
5747 local killbar = misc.KillBar
5748 local rankbar = misc.RankBar
5749 local attachbar = misc.AttachBar
5750 local typelist = {
5751 kill = {
5752 "Enemy Killed!"
5753 },
5754 collx2 = {
5755 "Double Collateral!"
5756 },
5757 collx3 = {
5758 "Triple Collateral!"
5759 },
5760 collxn = {
5761 "Multi Collateral!"
5762 },
5763 killx2 = {
5764 "Double Kill!"
5765 },
5766 killx3 = {
5767 "Triple Kill!"
5768 },
5769 killx4 = {"Quad Kill!"},
5770 killxn = {
5771 "Multi Kill!"
5772 },
5773 backstab = {"Backstab!"},
5774 assist = {"Assist!"},
5775 suppression = {
5776 "Suppressed Enemy!"
5777 },
5778 assistkill = {
5779 "Assist Count As Kill!"
5780 },
5781 head = {
5782 "Headshot Bonus!"
5783 },
5784 wall = {
5785 "Wallbang Bonus!"
5786 },
5787 spot = {
5788 "Spot Bonus!"
5789 },
5790 long = {
5791 "Killed from a distance!"
5792 },
5793 squad = {
5794 "Teammate spawned on you"
5795 },
5796 flagsteal = {
5797 "Acquired Enemy Flag!"
5798 },
5799 flagcapture = {
5800 "Captured Enemy Flag!"
5801 },
5802 flagteamcap = {
5803 "Team Captured Enemy Flag!"
5804 },
5805 flagrecover = {
5806 "Recovered Team Flag!"
5807 },
5808 flagdef1 = {
5809 "Killed Enemy Flag Carrier!"
5810 },
5811 flagdef2 = {
5812 "Protected Flag Carrier!"
5813 },
5814 flagdef3 = {
5815 "Denied Enemy Capture!"
5816 },
5817 flagdef4 = {
5818 "Denied Enemy Pick Up!"
5819 },
5820 flagdef5 = {
5821 "Flag Guard Kill!"
5822 },
5823 flagdef6 = {
5824 "Flag Recover Kill!"
5825 },
5826 flagsup1 = {
5827 "Flag Escort Kill!"
5828 },
5829 flagsup2 = {
5830 "Killed Enemy Flag Escort!"
5831 },
5832 flagsup3 = {
5833 "Assisted by Teammate!"
5834 },
5835 flagsup4 = {
5836 "Protected Flag Carrier Under Fire!"
5837 },
5838 flagsup5 = {
5839 "Saved by Teammate!"
5840 },
5841 flagsup6 = {
5842 "Protected by Teammate!"
5843 },
5844 flagoff1 = {
5845 "Offensive Flag Kill!"
5846 },
5847 flagoff2 = {
5848 "Denied Enemy Flag Recovery!"
5849 },
5850 flagoff3 = {
5851 "Killed Enemy Flag Guard!"
5852 },
5853 dogtagself = {
5854 "Secured Personal Tag!"
5855 },
5856 dogtagconfirm = {
5857 "Kill Confirmed!"
5858 },
5859 dogtagteam = {
5860 "Teammate Confirmed Kill!"
5861 },
5862 dogtagdeny = {
5863 "Denied Enemy Kill!"
5864 },
5865 domcap = {
5866 "Captured a position!"
5867 },
5868 domcapping = {
5869 "Capturing position"
5870 },
5871 domdefend = {
5872 "Defended a position!"
5873 },
5874 domassault = {
5875 "Assaulted a position!"
5876 },
5877 domattack = {
5878 "Attacked a position!"
5879 },
5880 dombuzz = {
5881 "Stopped an enemy capture!"
5882 },
5883 kingcap = {
5884 "Captured the hill!"
5885 },
5886 kingholding = {
5887 "Holding hill"
5888 },
5889 kingcapping = {
5890 "Capturing hill"
5891 },
5892 kingdefend = {
5893 "Defended the hill!"
5894 },
5895 kingassault = {
5896 "Assaulted the hill!"
5897 },
5898 kingattack = {
5899 "Attacked the hill!"
5900 },
5901 kingbuzz = {
5902 "Stopped enemy capture of the hill!"
5903 },
5904 [""] = {}
5905 }
5906 local function typeout(label, speed)
5907 local speed = speed or 2
5908 local text = label.Text
5909 label.Text = ""
5910 spawn(function()
5911 for i = 1, string.len(text) do
5912 if i % 2 == 0 then
5913 sound.play("ui_typeout", 0.2)
5914 end
5915 label.Text = string.sub(text, 1, speed * i)
5916 wait(0.016666666666666666)
5917 end
5918 end)
5919 end
5920 local function queuetypeout(label, speed)
5921 local speed = speed or 3
5922 local text = label.Text
5923 label.Text = ""
5924 for i = 1, string.len(text) do
5925 if i % 2 == 0 then
5926 sound.play("ui_typeout", 0.2)
5927 end
5928 label.Text = string.sub(text, 1, speed * i)
5929 wait(0.016666666666666666)
5930 end
5931 end
5932 function notify:customaward(customtext)
5933 local display = side:Clone()
5934 local primary = wfc(display, "Primary")
5935 display.Parent = framelist
5936 sound.play("ui_smallaward", 0.2)
5937 local fr = framelist:GetChildren()
5938 for i = 1, #fr do
5939 local v = fr[i]
5940 if v:IsA("Frame") and v.Parent then
5941 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5942 end
5943 end
5944 spawn(function()
5945 primary.Text = customtext
5946 primary.TextTransparency = 0
5947 typeout(primary, 3)
5948 wait(5.5)
5949 for i = 1, 10 do
5950 primary.TextTransparency = i / 10
5951 primary.TextStrokeTransparency = i / 10 + 0.4
5952 wait(0.016666666666666666)
5953 end
5954 wait(0.1)
5955 trash.remove(display)
5956 end)
5957 end
5958 function smallaward(type, pt)
5959 local pt = pt or 25
5960 local display = side:Clone()
5961 local primary = wfc(display, "Primary")
5962 local point = wfc(display, "Point")
5963 sound.play("ui_smallaward", 0.2)
5964 display.Parent = framelist
5965 local fr = framelist:GetChildren()
5966 for i = 1, #fr do
5967 local v = fr[i]
5968 if v:IsA("Frame") and v.Parent then
5969 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5970 end
5971 end
5972 spawn(function()
5973 point.Text = "[+" .. pt .. "]"
5974 primary.Text = typelist[type][1]
5975 if type == "head" then
5976 sound.play("headshotkill", 0.45)
5977 end
5978 point.TextTransparency = 0
5979 primary.TextTransparency = 0
5980 typeout(point, 3)
5981 typeout(primary, 3)
5982 wait(5.5)
5983 for i = 1, 10 do
5984 point.TextTransparency = i / 10
5985 primary.TextTransparency = i / 10
5986 point.TextStrokeTransparency = i / 10 + 0.4
5987 primary.TextStrokeTransparency = i / 10 + 0.4
5988 wait(0.016666666666666666)
5989 end
5990 wait(0.1)
5991 trash.remove(display)
5992 end)
5993 end
5994 function bigaward(type, victim, weap, pt, extradata)
5995 local display = main:Clone()
5996 local bk = wfc(display, "Overlay")
5997 local primary = wfc(display, "Primary")
5998 local point = wfc(display, "Point")
5999 local enemy = wfc(display, "Enemy")
6000 display.Parent = framelist
6001 local fr = framelist:GetChildren()
6002 for i = 1, #fr do
6003 local v = fr[i]
6004 if v:IsA("Frame") and v.Parent then
6005 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
6006 end
6007 end
6008 spawn(function()
6009 point.Text = "[+" .. pt .. "]"
6010 primary.Text = typelist[type][1]
6011 enemy.Text = victim or ""
6012 sound.play("ui_begin", 0.4)
6013 if type == "kill" then
6014 sound.play("killshot", 0.2)
6015 else
6016 end
6017 point.TextTransparency = 0
6018 point.TextStrokeTransparency = 0
6019 primary.TextTransparency = 0
6020 primary.TextStrokeTransparency = 0
6021 enemy.TextTransparency = 1
6022 enemy.TextStrokeTransparency = 1
6023 bk.ImageTransparency = 0.2
6024 bk:TweenSizeAndPosition(ud2(0, 200, 0, 80), ud2(0.5, -150, 0.7, -40), "Out", "Linear", 0, true)
6025 typeout(point)
6026 typeout(primary)
6027 spawn(function()
6028 wait(0.05)
6029 for i = 1, 10 do
6030 bk.ImageTransparency = i / 10
6031 wait(0.1)
6032 end
6033 bk.Size = ud2(0, 200, 0, 80)
6034 bk.Position = ud2(0.55, -100, 0.3, -40)
6035 end)
6036 bk:TweenSizeAndPosition(ud2(0, 300, 0, 30), ud2(0.5, -150, 0.7, -15), "Out", "Linear", 0.05, true)
6037 wait(0.05)
6038 bk:TweenSizeAndPosition(ud2(0, 500, 0, 8), ud2(0.5, -150, 0.7, -4), "Out", "Linear", 0.05, true)
6039 wait(1.5)
6040 for i = 1, 2 do
6041 primary.TextTransparency = 1
6042 primary.TextStrokeTransparency = 1
6043 sound.play("ui_blink", 0.4)
6044 wait(0.1)
6045 primary.TextTransparency = 0
6046 primary.TextStrokeTransparency = 0
6047 wait(0.1)
6048 end
6049 primary.TextTransparency = 1
6050 primary.TextStrokeTransparency = 1
6051 wait(0.2)
6052 enemy.TextTransparency = 0
6053 enemy.TextStrokeTransparency = 0
6054 queuetypeout(enemy, 4)
6055 primary.TextTransparency = 0
6056 primary.TextStrokeTransparency = 0
6057 primary.Position = ud2(0.5, enemy.TextBounds.x + 10, 0.7, -10)
6058 if type == "kill" then
6059 primary.Text = "[" .. weap .. "]"
6060 else
6061 primary.Text = weap
6062 end
6063 queuetypeout(primary, 4)
6064 wait(3)
6065 for i = 1, 10 do
6066 point.TextTransparency = i / 10
6067 primary.TextTransparency = i / 10
6068 enemy.TextTransparency = i / 10
6069 point.TextStrokeTransparency = i / 10 + 0.4
6070 primary.TextStrokeTransparency = i / 10 + 0.4
6071 enemy.TextStrokeTransparency = i / 10 + 0.4
6072 wait(0.016666666666666666)
6073 end
6074 wait(0.1)
6075 trash.remove(display)
6076 end)
6077 end
6078 local function unlockedgun(weapon)
6079 local br = attachbar:Clone()
6080 local title = br.Title
6081 local atext = br.Attach
6082 br.Parent = maingui
6083 br.Position = ud2(0.5, 0, 0.15, 0)
6084 title.Text = "Unlocked New Gun!"
6085 atext.Text = weapon
6086 local t0 = tick()
6087 local stop
6088 stop = run.onstep:connect(function()
6089 local t = tick() - t0
6090 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6091 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6092 if t > 3 then
6093 stop()
6094 br:Destroy()
6095 end
6096 end)
6097 end
6098 local function unlockedattach(weapon, attachments, killss)
6099 for i = 1, #attachments do
6100 do
6101 local attachment = attachments[i]
6102 local kills = killss[i]
6103 local br = attachbar:Clone()
6104 local money = br.Money
6105 local title = br.Title
6106 local atext = br.Attach
6107 br.Parent = maingui
6108 br.Position = ud2(0.5, 0, 0.15, 0)
6109 title.Text = "Unlocked " .. weapon .. " Attachment"
6110 atext.Text = attachment
6111 money.Text = "[+200]"
6112 local t0 = tick()
6113 local stop
6114 stop = run.onstep:connect(function()
6115 local t = tick() - t0
6116 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6117 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6118 money.TextTransparency = t < 0.5 and 1 or t < 2.5 and 0 or t < 3 and (t - 2.5) / 0.5 or 1
6119 if t > 3 then
6120 stop()
6121 br:Destroy()
6122 end
6123 end)
6124 wait(3)
6125 end
6126 end
6127 end
6128 local function rankup(old, new, newguns)
6129 local br = rankbar:Clone()
6130 local money = br.Money
6131 local title = br.Title
6132 local rtext = br.Rank
6133 local count = 0
6134 local sht = maingui:GetChildren()
6135 for i = 1, #sht do
6136 if sht[i].Name == "RankBar" or sht[i].Name == "AttachBar" then
6137 count = count + 1
6138 end
6139 end
6140 br.Parent = maingui
6141 rtext.Text = new
6142 money.Text = "+" .. 5 * (new - old) * (81 + new + old) / 2 .. " CR"
6143 local t0 = tick()
6144 local stop
6145 stop = run.onstep:connect(function()
6146 local t = tick() - t0
6147 rtext.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
6148 title.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
6149 money.TextTransparency = t < 0.5 and 1 or t < 3.5 and 0 or t < 4 and (t - 3.5) / 0.5 or 1
6150 if t > 4 then
6151 stop()
6152 br:Destroy()
6153 if newguns then
6154 for i = 1, #newguns do
6155 unlockedgun(newguns[i])
6156 wait(3)
6157 end
6158 end
6159 end
6160 end)
6161 end
6162 function notify:testrankup(rank)
6163 rankup(rank)
6164 end
6165 function notify:reset()
6166 maingui = wfc(pgui, "MainGui")
6167 gamegui = wfc(maingui, "GameGui")
6168 framelist = wfc(gamegui, "NotifyList")
6169 if ffc(maingui, "KillBar") then
6170 trash.remove(maingui.KillBar)
6171 end
6172 end
6173 do
6174 local cf = CFrame.new
6175 local tos = cf().toObjectSpace
6176 local bcolor = BrickColor.new
6177 local repstore = game.ReplicatedStorage
6178 local gunmodels = repstore.GunModels
6179 local gunmodules = repstore.GunModules
6180 local attmodels = repstore.AttachmentModels
6181 local function hideparts(wepmodel, atttype, hide)
6182 local parts = wepmodel:GetChildren()
6183 local slottag
6184 for i = 1, #parts do
6185 if atttype == "Optics" then
6186 if parts[i].Name == "Iron" or parts[i].Name == "IronGlow" then
6187 if hide and not ffc(parts[i], "Hide") then
6188 local tag = new("IntValue", parts[i])
6189 tag.Name = "Hide"
6190 else
6191 local tag = ffc(parts[i], "Hide")
6192 if tag then
6193 tag:Destroy()
6194 end
6195 end
6196 parts[i].Transparency = hide and 1 or 0
6197 elseif parts[i].Name == "SightMark" and ffc(parts[i], "Decal") then
6198 parts[i].Decal.Transparency = hide and 1 or 0
6199 end
6200 elseif atttype == "Underbarrel" and parts[i].Name == "Grip" then
6201 if hide and not ffc(parts[i], "Hide") then
6202 local tag = new("IntValue", parts[i])
6203 tag.Name = "Hide"
6204 else
6205 local tag = ffc(parts[i], "Hide")
6206 if tag then
6207 tag:Destroy()
6208 end
6209 end
6210 parts[i].Transparency = hide and 1 or 0
6211 slottag = ffc(parts[i], "Slot1") or ffc(parts[i], "Slot2")
6212 end
6213 end
6214 return slottag
6215 end
6216 local function texturemodel(wepmodel, attachdata, camodata)
6217 local root = camodata
6218 for i, part in next, wepmodel:GetChildren() do
6219 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6220 part.Anchored = true
6221 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6222 if slottag then
6223 for x, y in next, part:GetChildren() do
6224 if y:IsA("Texture") then
6225 y:Destroy()
6226 end
6227 end
6228 if root and root[slottag.Name] and root[slottag.Name].Name ~= "" then
6229 local t = Instance.new("Texture")
6230 t.Name = slottag.Name
6231 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6232 t.Transparency = part.Transparency >= 0.8 and 1 or root[slottag.Name].TextureProperties.Transparency
6233 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
6234 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
6235 if root[slottag.Name].TextureProperties.Color then
6236 local colordata = root[slottag.Name].TextureProperties.Color
6237 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6238 end
6239 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
6240 local tt = t:Clone()
6241 tt.Face = x
6242 tt.Parent = part
6243 end
6244 t:Destroy()
6245 if not root[slottag.Name].BrickProperties.DefaultColor then
6246 if part:IsA("UnionOperation") then
6247 part.UsePartColor = true
6248 end
6249 if root[slottag.Name].BrickProperties.Color then
6250 local colordata = root[slottag.Name].BrickProperties.Color
6251 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6252 else
6253 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
6254 end
6255 end
6256 if root[slottag.Name].BrickProperties.Material then
6257 part.Material = root[slottag.Name].BrickProperties.Material
6258 end
6259 if root[slottag.Name].BrickProperties.Reflectance then
6260 part.Reflectance = root[slottag.Name].BrickProperties.Reflectance
6261 end
6262 end
6263 end
6264 elseif part:IsA("Model") then
6265 texturemodel(part)
6266 end
6267 end
6268 end
6269 local updategunmeshtype = function(wepmodel, attachdata, camodata)
6270 end
6271 local function updategunattachment(wepmodel, atttype, attachname, wepnodes, preview)
6272 local parts = wepmodel:GetChildren()
6273 local data = require(ffc(gunmodules, wepmodel.Name))
6274 local attachdata = data.attachments[atttype] and data.attachments[atttype][attachname] or {}
6275 local refmodel = attachdata.altmodel and ffc(attmodels, attachdata.altmodel) or ffc(attmodels, attachname)
6276 if not refmodel then
6277 return
6278 end
6279 local model = refmodel:Clone()
6280 local basepart = wfc(model, "Node")
6281 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
6282 local node
6283 model.Name = attachname
6284 if sidemount then
6285 local basenode = sidemount.Node
6286 local mountnode = attachdata.mountnode and wepnodes[attachdata.mountnode] or atttype == "Optics" and wepnodes.MountNode or atttype == "Underbarrel" and wepnodes.UnderMountNode
6287 local mountcframes = {}
6288 local mchildren = sidemount:GetChildren()
6289 local basecframe = basenode.CFrame
6290 for i = 1, #mchildren do
6291 if mchildren[i]:IsA("BasePart") then
6292 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
6293 end
6294 end
6295 basenode.CFrame = mountnode.CFrame
6296 for i = 1, #mchildren do
6297 if mchildren[i]:IsA("BasePart") then
6298 local v = mchildren[i]
6299 v.CFrame = mountnode.CFrame * mountcframes[i]
6300 end
6301 end
6302 node = attachdata.node and wepnodes[attachdata.node] or sidemount[atttype .. "Node"]
6303 sidemount.Parent = model
6304 else
6305 node = attachdata.node and wepnodes[attachdata.node] or wepnodes[atttype .. "Node"]
6306 end
6307 local weldcframes = {}
6308 local children = model:GetChildren()
6309 local basecframe = basepart and basepart.CFrame
6310 local slottag
6311 if atttype == "Optics" or atttype == "Underbarrel" then
6312 slottag = hideparts(wepmodel, atttype, true)
6313 end
6314 for i = 1, #children do
6315 if children[i]:IsA("BasePart") then
6316 weldcframes[i] = tos(basecframe, children[i].CFrame)
6317 end
6318 end
6319 basepart.CFrame = node.CFrame
6320 for i = 1, #children do
6321 if children[i]:IsA("BasePart") then
6322 local v = children[i]
6323 v.CFrame = node.CFrame * weldcframes[i]
6324 if slottag and (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) then
6325 slottag:Clone().Parent = v
6326 end
6327 end
6328 end
6329 model.Parent = wepmodel
6330 end
6331 function getgunmodel(wep, attachdata, camodata)
6332 local findgun = ffc(gunmodels, wep)
6333 print("Finding weapon", wep)
6334 if findgun then
6335 local wepmodel = findgun:Clone()
6336 local nodes = wfc(wepmodel, "MenuNodes")
6337 nodes.Parent = wepmodel
6338 wepmodel.PrimaryPart = wfc(nodes, "MenuNode")
6339 for i, v in next, attachdata, nil do
6340 if v ~= "" then
6341 updategunattachment(wepmodel, i, v, nodes)
6342 end
6343 end
6344 texturemodel(wepmodel, attachdata, camodata)
6345 return wepmodel
6346 else
6347 error("Failed to find weapon model for", wep)
6348 end
6349 end
6350 end
6351 network:add("killed", function(killer, part, deathcf, weapon, weapondisplayname, rank, attachdata, camodata)
6352 char.deadcf = deathcf
6353 if killer == player then
6354 camera:setfixedcam(CFrame.new(deathcf.p, deathcf.p + deathcf.lookVector))
6355 else
6356 do
6357 local gunmodel = getgunmodel(weapon, attachdata, camodata)
6358 gunmodel.Parent = workspace.CurrentCamera
6359 gunmodel:SetPrimaryPartCFrame(deathcf * CFrame.Angles(0, math.rad(90), 0) + Vector3.new(0, 1, 0))
6360 local newbar = killbar:Clone()
6361 newbar.Killer.Label.Text = killer.Name
6362 newbar.Weapon.Label.Text = weapondisplayname
6363 newbar.Parent = maingui
6364 newbar.Rank.Label.Text = rank
6365 local wepnote = misc.WepNote:Clone()
6366 wepnote.Parent = gunmodel
6367 for i, v in next, newbar.Attachments:GetChildren() do
6368 v.Type.Text = "None"
6369 end
6370 if attachdata then
6371 for i, v in next, attachdata, nil do
6372 if i ~= "Name" and v ~= "" then
6373 newbar.Attachments[i].Type.Text = v
6374 end
6375 end
6376 end
6377 camera:setspectate(killer, part)
6378 delay(5, function()
6379 gunmodel:Destroy()
6380 end)
6381 end
6382 end
6383 end)
6384 network:add("unlockedattach", unlockedattach)
6385 network:add("rankup", rankup)
6386 network:add("bigaward", function(type, victim, weapon, pt, extradata)
6387 bigaward(type, victim, weapon, pt, extradata)
6388 end)
6389 network:add("smallaward", function(type, pt)
6390 smallaward(type, pt)
6391 end)
6392 function notify.step()
6393 if char.health <= 0 then
6394 local bar = ffc(maingui, "KillBar")
6395 if bar then
6396 local enemy = ffc(game:GetService("Players"), bar.Killer.Label.Text)
6397 if enemy then
6398 local health = hud:getplayerhealth(enemy)
6399 bar.Health.Label.Text = ceil(health)
6400 bar.Health.Label.TextColor3 = health < 20 and color(1, 0, 0) or health < 50 and color(1, 1, 0) or color(0, 1, 0)
6401 end
6402 end
6403 end
6404 end
6405end
6406print("Loading leaderboard module")
6407do
6408 local wfc = game.WaitForChild
6409 local ffc = game.FindFirstChild
6410 local ud2 = UDim2.new
6411 local ceil = math.ceil
6412 local cf = CFrame.new
6413 local v3 = Vector3.new
6414 local color = Color3.new
6415 local dot = Vector3.new().Dot
6416 local workspace = workspace
6417 local ray = Ray.new
6418 local new = Instance.new
6419 local raycast = workspace.FindPartOnRayWithIgnoreList
6420 local infolder = function(l, e)
6421 for i = 1, #l do
6422 if l[i].Name == e then
6423 return l[i]
6424 end
6425 end
6426 end
6427 local rtype = game.IsA
6428 local debris = game.Debris
6429 local player = game:GetService("Players").LocalPlayer
6430 local playertag = game.ReplicatedStorage.Character.PlayerTag
6431 local pgui = player.PlayerGui
6432 local misc = input.consoleon and game.ReplicatedStorage.XBOX or game.ReplicatedStorage.Misc
6433 local playerstat = misc.Player
6434 local board = wfc(pgui, "Leaderboard")
6435 if input.consoleon then
6436 board:Destroy()
6437 board = misc.Leaderboard:Clone()
6438 board.Parent = pgui
6439 end
6440 local main = wfc(board, "Main")
6441 local global = wfc(board, "Global")
6442 local ghost = wfc(main, "Ghosts")
6443 local phantom = wfc(main, "Phantoms")
6444 local gdataframe = wfc(ghost, "DataFrame")
6445 local pdataframe = wfc(phantom, "DataFrame")
6446 local ghostdata = wfc(gdataframe, "Data")
6447 local phantomdata = wfc(pdataframe, "Data")
6448 local spacing = input.consoleon and 30 or 25
6449 local function organize()
6450 local pp = game:GetService("Players"):GetPlayers()
6451 for i = 1, #pp do
6452 local v = pp[i]
6453 local rightparent = v.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6454 local wrongparent = v.TeamColor ~= game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6455 local right = ffc(rightparent, v.Name)
6456 local wrong = ffc(wrongparent, v.Name)
6457 if not right and wrong then
6458 wrong.Parent = rightparent
6459 end
6460 end
6461 local gd = ghostdata:GetChildren()
6462 table.sort(gd, function(a, b)
6463 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
6464 end)
6465 for i = 1, #gd do
6466 local v = gd[i]
6467 v.Position = ud2(0, 0, 0, i * spacing)
6468 if v.Name == player.Name then
6469 v.Username.TextColor3 = color(1, 1, 0)
6470 end
6471 end
6472 ghostdata.Parent.CanvasSize = ud2(0, 0, 0, (#gd + 1) * spacing)
6473 local pd = phantomdata:GetChildren()
6474 table.sort(pd, function(a, b)
6475 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
6476 end)
6477 for i = 1, #pd do
6478 local v = pd[i]
6479 v.Position = ud2(0, 0, 0, i * spacing)
6480 if v.Name == player.Name then
6481 v.Username.TextColor3 = color(1, 1, 0)
6482 end
6483 end
6484 phantomdata.Parent.CanvasSize = ud2(0, 0, 0, (#pd + 1) * spacing)
6485 end
6486 local function addplayer(guy)
6487 local gbar = ffc(ghostdata, guy.Name)
6488 local pbar = ffc(phantomdata, guy.Name)
6489 if gbar or pbar then
6490 return
6491 end
6492 local bar = playerstat:Clone()
6493 bar.Name = guy.Name
6494 bar.Username.Text = guy.Name
6495 bar.Kills.Text = 0
6496 bar.Deaths.Text = 0
6497 bar.Streak.Text = 0
6498 bar.Score.Text = 0
6499 bar.Kdr.Text = 0
6500 bar.Rank.Text = 0
6501 if guy == player then
6502 bar.Username.TextColor3 = color(1, 1, 0)
6503 end
6504 bar.Parent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6505 organize()
6506 end
6507 local function removeplayer(guy)
6508 local gbar = ffc(ghostdata, guy.Name)
6509 local pbar = ffc(phantomdata, guy.Name)
6510 if gbar then
6511 trash.remove(gbar)
6512 end
6513 if pbar then
6514 trash.remove(pbar)
6515 end
6516 organize()
6517 end
6518 local function updatestats(guy, data)
6519 local rightparent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6520 local bar = ffc(rightparent, guy.Name)
6521 if not bar then
6522 organize()
6523 bar = ffc(rightparent, guy.Name)
6524 end
6525 if bar then
6526 for i, v in next, data, nil do
6527 bar[i].Text = v
6528 end
6529 end
6530 organize()
6531 end
6532 function leaderboard:show()
6533 main.Visible = true
6534 end
6535 function leaderboard:hide()
6536 main.Visible = false
6537 end
6538 network:add("removeplayer", removeplayer)
6539 network:add("newplayer", addplayer)
6540 network:add("updatestats", updatestats)
6541 organize()
6542 game:GetService("UserInputService").InputBegan:connect(function(keycode)
6543 local key = keycode.KeyCode
6544 if key == Enum.KeyCode.Tab and not input.iskeydown(Enum.KeyCode.LeftAlt) then
6545 if main.Visible then
6546 leaderboard:hide()
6547 else
6548 organize()
6549 leaderboard:show()
6550 end
6551 end
6552 end)
6553end
6554print("Loading char module")
6555do
6556 local rtype = game.IsA
6557 local next = next
6558 local new = Instance.new
6559 local wfc = game.WaitForChild
6560 local ffc = game.FindFirstChild
6561 local getchildren = game.GetChildren
6562 local workspace = game.Workspace
6563 local cf = CFrame.new
6564 local vtws = CFrame.new().vectorToWorldSpace
6565 local angles = CFrame.Angles
6566 local nc = cf()
6567 local v3 = Vector3.new
6568 local nv = v3()
6569 local ray = Ray.new
6570 local raycast = workspace.FindPartOnRayWithIgnoreList
6571 local raycastwl = workspace.FindPartOnRayWithWhitelist
6572 local debris = game.Debris
6573 local dot = nv.Dot
6574 local ud2 = UDim2.new
6575 local abs = math.abs
6576 local tos = cf().toObjectSpace
6577 local player = game:GetService("Players").LocalPlayer
6578 local pgui = player.PlayerGui
6579 local repstore = game.ReplicatedStorage
6580 local attmodels = repstore.AttachmentModels
6581 local character, humanoid, rootpart, rootjoint
6582 local thread = sequencer.new()
6583 local weapon
6584 local aiming = false
6585 local auto = false
6586 local burst = 0
6587 local reloading = false
6588 local sprinting = false
6589 local animating = false
6590 local stability = 0
6591 local basewalkspeed = 14
6592 local sprintspring = physics.spring.new()
6593 local climbing = physics.spring.new()
6594 local curgunid = 0
6595 local aimspring = physics.spring.new()
6596 local zoommodspring = physics.spring.new(1)
6597 zoommodspring.s = 12
6598 zoommodspring.d = 0.95
6599 local loadedgundata = {}
6600 char.unaimedfov = 80
6601 function char.setunaimedfov(value)
6602 char.unaimedfov = value
6603 end
6604 function char.addgun(gundata)
6605 for i = 1, curgunid do
6606 if loadedgundata[i] == gundata then
6607 warn("Error, tried to add gun twice")
6608 return
6609 end
6610 end
6611 curgunid = curgunid + 1
6612 loadedgundata[curgunid] = gundata
6613 gundata.id = curgunid
6614 return curgunid
6615 end
6616 function char.removegun(gundata)
6617 local found
6618 for i = 1, curgunid do
6619 if loadedgundata[i] == gundata then
6620 found = true
6621 break
6622 end
6623 end
6624 if not found then
6625 warn("Error, tried to remove gun twice")
6626 return
6627 end
6628 local gunid = gundata.id
6629 gundata.id = nil
6630 loadedgundata[gunid] = loadedgundata[curgunid]
6631 loadedgundata[curgunid] = nil
6632 curgunid = curgunid - 1
6633 local replacement = loadedgundata[gunid]
6634 if replacement then
6635 replacement.id = gunid
6636 end
6637 end
6638 function char.unloadguns()
6639 curgunid = 0
6640 loadedgundata = {}
6641 end
6642 local swingspring = physics.spring.new(nv)
6643 local speedspring = physics.spring.new()
6644 local velocityspring = physics.spring.new(nv)
6645 local pronespring = physics.spring.new(0)
6646 local truespeedspring = physics.spring.new(0)
6647 local equipspring = physics.spring.new(1)
6648 local muzzlespring = physics.spring.new(0)
6649 local walkspeedmult = 1
6650 sprintspring.s = 12
6651 sprintspring.d = 0.9
6652 climbing.s = 12
6653 climbing.d = 0.9
6654 aimspring.d = 0.9
6655 swingspring.s = 10
6656 swingspring.d = 0.75
6657 speedspring.s = 16
6658 velocityspring.s = 16
6659 pronespring.s = 8
6660 truespeedspring.s = 8
6661 equipspring.s = 12
6662 equipspring.d = 0.75
6663 local ignore = {
6664 workspace.Ignore,
6665 game.Workspace.CurrentCamera
6666 }
6667 local backwardsmult = 0.8
6668 local bodyforce = new("BodyVelocity")
6669 bodyforce.Name = "\n"
6670 local muzzlelight, walkspeedspring, headheightspring, updatewalkspeed
6671 walkspeedspring = physics.spring.new(basewalkspeed)
6672 walkspeedspring.s = 8
6673 headheightspring = physics.spring.new(1.5)
6674 headheightspring.s = 8
6675 char.acceleration = nv
6676 bodyforce.MaxForce = nv
6677 local jumpallowed
6678 do
6679 local movementmode = "stand"
6680 local down = v3(0, -5, 0)
6681 function updatewalkspeed()
6682 if sprinting then
6683 walkspeedspring.t = 1.4 * walkspeedmult * basewalkspeed
6684 elseif movementmode == "prone" then
6685 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6686 elseif movementmode == "crouch" then
6687 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6688 elseif movementmode == "stand" then
6689 walkspeedspring.t = walkspeedmult * basewalkspeed
6690 end
6691 end
6692 local function setmovementmode(self, mode, dive)
6693 local oldmode = char.movementmode
6694 char.movementmode = mode
6695 movementmode = mode
6696 if mode == "prone" then
6697 if not dive and oldmode ~= mode then
6698 sound.play("stanceProne", 0.15)
6699 end
6700 headheightspring.t = -1.5
6701 pronespring.t = 1
6702 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6703 hud:setcrossscale(0.5)
6704 stability = 0.25
6705 if dive and sprinting and rootpart.Velocity.y > -5 then
6706 spawn(function()
6707 local lkvector = rootpart.CFrame.lookVector
6708 rootpart.Velocity = lkvector * (50 * loltimescale) + v3(0, 40 * loltimescale, 0)
6709 wait(0.1 / loltimescale)
6710 rootpart.Velocity = lkvector * (60 * loltimescale) + v3(0, 30 * loltimescale, 0)
6711 wait(0.4 / loltimescale)
6712 rootpart.Velocity = lkvector * (20 * loltimescale) + v3(0, -10 * loltimescale, 0)
6713 end)
6714 end
6715 elseif mode == "crouch" then
6716 if not dive and oldmode ~= mode then
6717 sound.play("stanceStandCrouch", 0.15)
6718 end
6719 headheightspring.t = 0
6720 pronespring.t = 0
6721 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6722 hud:setcrossscale(0.75)
6723 stability = 0.15
6724 if dive and sprinting and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
6725 isSliding = true
6726 sound.play("slideStart", 0.25)
6727 spawn(function()
6728 local lkvector = rootpart.CFrame.lookVector
6729 local released
6730 bodyforce.MaxForce = v3(40000, 10, 40000)
6731 for i = 1, 20 do
6732 if input.keyboard.down.leftshift then
6733 lkvector = rootpart.CFrame.lookVector
6734 end
6735 bodyforce.Velocity = lkvector * (40 * loltimescale - i * 1.5 * loltimescale) + v3(0, 0, 0)
6736 wait(0.03333333333333333 / loltimescale)
6737 end
6738 bodyforce.MaxForce = nv
6739 bodyforce.Velocity = nv
6740 if isSliding then
6741 isSliding = false
6742 sound.play("slideEnd", 0.15)
6743 end
6744 end)
6745 end
6746 elseif mode == "stand" then
6747 if oldmode ~= mode then
6748 sound.play("stanceStandCrouch", 0.15)
6749 end
6750 headheightspring.t = 1.5
6751 pronespring.t = 0
6752 walkspeedspring.t = walkspeedmult * basewalkspeed
6753 hud:setcrossscale(1)
6754 stability = 0
6755 end
6756 network:send("s" .. "t" .. "a" .. "n" .. "c" .. "e", mode)
6757 sprinting = false
6758 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6759 sprintspring.t = 0
6760 end
6761 function char.getstate()
6762 return humanoid:GetState()
6763 end
6764 function char:sprinting()
6765 return sprinting
6766 end
6767 char.setmovementmode = setmovementmode
6768 function char:setbasewalkspeed(newspeed)
6769 basewalkspeed = newspeed
6770 updatewalkspeed()
6771 end
6772 function char:setsprint(on)
6773 if on then
6774 if isSliding then
6775 isSliding = false
6776 sound.play("slideEnd", 0.15)
6777 end
6778 setmovementmode(nil, "stand")
6779 sprinting = true
6780 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6781 auto = false
6782 burst = 0
6783 if weapon and aiming and weapon.type ~= "KNIFE" then
6784 print("un aim herE")
6785 weapon:setaim(false)
6786 end
6787 walkspeedmult = 1
6788 if not reloading and not animating then
6789 sprintspring.t = 1
6790 end
6791 walkspeedspring.t = 1.5 * walkspeedmult * basewalkspeed
6792 elseif sprinting then
6793 sprinting = false
6794 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6795 sprintspring.t = 0
6796 walkspeedspring.t = walkspeedmult * basewalkspeed
6797 if input.mouse.down.right and weapon and weapon.type ~= "KNIFE" then
6798 weapon:setaim(true)
6799 end
6800 end
6801 end
6802 local function parkour()
6803 if weapon and not reloading and not char.grenadehold then
6804 weapon:playanimation("parkour")
6805 end
6806 sound.play("parkour", 0.25)
6807 bodyforce.MaxForce = nv
6808 local bp = new("BodyPosition")
6809 bp.Name = "\n"
6810 bp.position = rootpart.Position + rootpart.CFrame.lookVector.unit * (char.speed * loltimescale) * 1.5 + v3(0, 10, 0)
6811 bp.maxForce = v3(5000000, 500000, 500000)
6812 bp.P = 4000
6813 bp.Parent = rootpart
6814 debris:AddItem(bp, 0.45)
6815 end
6816 function char:jump(height)
6817 local rootcf = rootpart.CFrame
6818 local isonground = raycast(workspace, ray(rootcf.p, vtws(rootcf, down)), {
6819 workspace.CurrentCamera
6820 })
6821 local v = rootpart.Velocity.y
6822 local j = height and (2 * game.Workspace.Gravity * height) ^ 0.5 or 40
6823 local jumppower
6824 if v < 0 then
6825 jumppower = j
6826 else
6827 jumppower = (v * v + j * j) ^ 0.5
6828 end
6829 if isonground then
6830 if movementmode == "prone" or movementmode == "crouch" then
6831 setmovementmode(nil, "stand")
6832 elseif not aiming then
6833 local r1 = ray(rootpart.CFrame.p + v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 + v3(0, 2, 0))
6834 local h1, e1 = raycast(workspace, r1, {
6835 character,
6836 camera.currentcamera
6837 })
6838 local r2 = ray(rootpart.CFrame.p - v3(0, 1, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1, 0))
6839 local h2, e2 = raycast(workspace, r2, {
6840 character,
6841 camera.currentcamera
6842 })
6843 local r3 = ray(rootpart.CFrame.p - v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1.5, 0))
6844 local h3, e3 = raycast(workspace, r3, {
6845 character,
6846 camera.currentcamera
6847 })
6848 if h3 and h1 ~= h3 and (e3 - e2).Magnitude < 0.7 and (e3 - e1).Magnitude > 4 and (e3 - rootpart.Position).Magnitude < char.speed / 1.5 and not h3:IsA("TrussPart") then
6849 parkour()
6850 delay(0.1, function()
6851 end)
6852 else
6853 humanoid.JumpPower = jumppower
6854 jumpallowed = true
6855 humanoid.Jump = true
6856 jumpallowed = false
6857 end
6858 else
6859 humanoid.JumpPower = jumppower
6860 jumpallowed = true
6861 humanoid.Jump = true
6862 jumpallowed = false
6863 end
6864 end
6865 end
6866 end
6867 local equipping = false
6868 local rweld, lweld, larm, rarm, lmodel, rmodel, lmain, rmain
6869 local sin = math.sin
6870 local cos = math.cos
6871 char.grenadehold = false
6872 local function gunbob(a, r)
6873 local a, r = a or 1, r or 1
6874 local d, s, v = char.distance * 6.28318 * 3 / 4, char.speed, -char.velocity
6875 if s < basewalkspeed then
6876 local w = v3(r * sin(d / 4 - 1) / 256 + r * (sin(d / 64) - r * v.z / 4) / 512, r * cos(d / 128) / 128 - r * cos(d / 8) / 256, r * sin(d / 8) / 128 + r * v.x / 1024) * s / 20 * 6.28318
6877 return cf(r * cos(d / 8 - 1) * s / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6878 else
6879 local w = v3((r * sin(d / 4 - 1) / 256 + r * (sin(d / 64) - r * v.z / 4) / 512) * s / 20 * 6.28318, (r * cos(d / 128) / 128 - r * cos(d / 8) / 256) * s / 20 * 6.28318, r * sin(d / 8) / 128 * (5 * s - 56) / 20 * 6.28318 + r * v.x / 1024)
6880 return cf(r * cos(d / 8 - 1) * (5 * s - 56) / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6881 end
6882 end
6883 local function gunsway(a)
6884 local d, s = tick() * 6, 2 * (1.1 - a)
6885 return cf(cos(d / 8) * s / 128, -sin(d / 4) * s / 128, sin(d / 16) * s / 64)
6886 end
6887 function weldattachment(gun, type, attname, menunode, mainpart, attdata, welddata, menunodes)
6888 local refmodel = attdata.altmodel and ffc(attmodels, attdata.altmodel) or ffc(attmodels, attname)
6889 local copies = attdata.copy or 0
6890 local slottag
6891 if refmodel then
6892 for i = 0, copies do
6893 local model = refmodel:Clone()
6894 local attnode = model.Node
6895 local weldcframes = {}
6896 local maincf = attnode.CFrame
6897 local parts = getchildren(model)
6898 for i = 1, #parts do
6899 local v = parts[i]
6900 if v:IsA("BasePart") then
6901 weldcframes[v] = tos(maincf, v.CFrame)
6902 end
6903 end
6904 attnode.CFrame = i == 0 and menunode.CFrame or menunodes[attdata.copynodes[i]].CFrame
6905 if type == "Optics" then
6906 local del = gun:GetChildren()
6907 for i = 1, #del do
6908 if del[i].Name == "Iron" or del[i].Name == "IronGlow" or del[i].Name == "SightMark" and not ffc(del[i], "Stay") then
6909 del[i]:Destroy()
6910 end
6911 end
6912 elseif type == "Underbarrel" then
6913 local del = gun:GetChildren()
6914 for i = 1, #del do
6915 if del[i].Name == "Grip" then
6916 slottag = ffc(del[i], "Slot1") or ffc(del[i], "Slot2")
6917 del[i]:Destroy()
6918 end
6919 end
6920 end
6921 if attdata.replacemag then
6922 local del = gun:GetChildren()
6923 for x = 1, #del do
6924 if i == 0 and del[x].Name == "Mag" or i > 0 and del[x].Name == "Mag" .. i + 1 then
6925 del[x]:Destroy()
6926 end
6927 end
6928 end
6929 if attdata.replacepart then
6930 local del = gun:GetChildren()
6931 for x = 1, #del do
6932 if del[x].Name == attdata.replacepart then
6933 del[x]:Destroy()
6934 end
6935 end
6936 end
6937 for x = 1, #parts do
6938 local v = parts[x]
6939 if v:IsA("BasePart") then
6940 local weld, c0
6941 if v ~= attnode then
6942 c0 = tos(mainpart.CFrame, attnode.CFrame)
6943 weld = new("Weld", mainpart)
6944 weld.Part0 = mainpart
6945 weld.Part1 = v
6946 weld.C0 = c0 * weldcframes[v]
6947 v.CFrame = mainpart.CFrame * weld.C0
6948 end
6949 if slottag and v:IsA("UnionOperation") then
6950 slottag:Clone().Parent = v
6951 end
6952 if attdata.replacemag and v.Name == "AttMag" then
6953 local magname = i == 0 and "Mag" or i > 0 and "Mag" .. i + 1
6954 v.Name = magname
6955 welddata[magname] = {
6956 part = v,
6957 weld = weld,
6958 basec0 = c0 * weldcframes[v],
6959 basetransparency = v.Transparency
6960 }
6961 end
6962 if attdata.replacepart and v.Name == "Part" then
6963 local pname = attdata.replacepart
6964 v.Name = pname
6965 welddata[pname] = {
6966 part = v,
6967 weld = weld,
6968 basec0 = c0 * weldcframes[v],
6969 basetransparency = v.Transparency
6970 }
6971 end
6972 v.Anchored = false
6973 v.CanCollide = false
6974 v.Parent = gun
6975 end
6976 end
6977 attnode:Destroy()
6978 model:Destroy()
6979 end
6980 end
6981 return slottag
6982 end
6983 local function texturemodel(root, model)
6984 local bcolor = BrickColor.new
6985 for i, part in next, model:GetChildren() do
6986 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6987 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6988 if slottag and slottag.Name then
6989 for x, y in next, part:GetChildren() do
6990 if y:IsA("Texture") then
6991 y:Destroy()
6992 end
6993 end
6994 if root[slottag.Name] and root[slottag.Name].Name ~= "" then
6995 if not effects.disable1pcamoskins then
6996 local t = Instance.new("Texture")
6997 t.Name = slottag.Name
6998 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6999 t.Transparency = part.Transparency == 1 and 1 or root[slottag.Name].TextureProperties.Transparency
7000 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
7001 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
7002 if root[slottag.Name].TextureProperties.Color then
7003 local colordata = root[slottag.Name].TextureProperties.Color
7004 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
7005 end
7006 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
7007 local tt = t:Clone()
7008 tt.Face = x
7009 tt.Parent = part
7010 end
7011 t:Destroy()
7012 end
7013 if not root[slottag.Name].BrickProperties.DefaultColor then
7014 if part:IsA("UnionOperation") then
7015 part.UsePartColor = true
7016 end
7017 local colordata = root[slottag.Name].BrickProperties.Color
7018 if colordata then
7019 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
7020 else
7021 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
7022 end
7023 end
7024 if root[slottag.Name].BrickProperties.Material then
7025 part.Material = root[slottag.Name].BrickProperties.Material
7026 end
7027 if root[slottag.Name].BrickProperties.Reflectance then
7028 part.Reflectance = root[slottag.Name].BrickProperties.Reflectance
7029 end
7030 end
7031 end
7032 elseif part:IsA("Model") then
7033 texturemodel(root, part)
7034 end
7035 end
7036 end
7037 local tos = CFrame.new().toObjectSpace
7038 local function weldmodel(model, mainpart, attachlist, data, camodata, attachonly)
7039 local welddata = {}
7040 local parts = model:GetChildren()
7041 local maincf = mainpart.CFrame
7042 local menunodes = ffc(model, "MenuNodes")
7043 if not attachonly then
7044 for i = 1, #parts do
7045 local part = parts[i]
7046 if part ~= mainpart and part:IsA("BasePart") then
7047 local name = part.Name
7048 if data and data.transparencymod and data.transparencymod[name] then
7049 part.Transparency = data.transparencymod[name]
7050 end
7051 if data and data.weldexception and data.weldexception[name] and ffc(model, data.weldexception[name]) then
7052 local nbase = model[data.weldexception[name]]
7053 local nmaincf = nbase.CFrame
7054 local c0 = tos(nmaincf, part.CFrame)
7055 local weld = new("Weld", mainpart)
7056 weld.Part0 = nbase
7057 weld.Part1 = part
7058 weld.C0 = c0
7059 part.CFrame = maincf * c0
7060 welddata[name] = {
7061 part = part,
7062 weld = weld,
7063 basec0 = c0,
7064 basetransparency = part.Transparency
7065 }
7066 else
7067 local c0 = tos(maincf, part.CFrame)
7068 local weld = new("Weld", mainpart)
7069 weld.Part0 = mainpart
7070 weld.Part1 = part
7071 weld.C0 = c0
7072 part.CFrame = maincf * c0
7073 welddata[name] = {
7074 part = part,
7075 weld = weld,
7076 basec0 = c0,
7077 basetransparency = part.Transparency
7078 }
7079 end
7080 part.Anchored = false
7081 part.CanCollide = false
7082 end
7083 end
7084 end
7085 if menunodes and #menunodes:GetChildren() > 1 then
7086 local nodes = menunodes:GetChildren()
7087 for i = 1, #nodes do
7088 local v = nodes[i]
7089 local c0 = tos(maincf, v.CFrame)
7090 local weld = new("Weld", mainpart)
7091 weld.Part0 = mainpart
7092 weld.Part1 = v
7093 weld.C0 = c0
7094 v.Anchored = false
7095 v.CanCollide = false
7096 end
7097 for i, v in next, attachlist, nil do
7098 if i ~= "Name" and v and v ~= "" then
7099 local attachdata = data.attachments and data.attachments[i][v] or {}
7100 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
7101 local mountweldpart = attachdata.mountweldpart and model[attachdata.mountweldpart] or mainpart
7102 local node = attachdata.node and menunodes[attachdata.node]
7103 if sidemount then
7104 local basenode = sidemount.Node
7105 local mountnode = attachdata.mountnode and menunodes[attachdata.mountnode] or i == "Optics" and menunodes.MountNode or i == "Underbarrel" and menunodes.UnderMountNode
7106 local mountcframes = {}
7107 local mchildren = sidemount:GetChildren()
7108 local basecframe = basenode.CFrame
7109 for i = 1, #mchildren do
7110 if mchildren[i]:IsA("BasePart") then
7111 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
7112 end
7113 end
7114 basenode.CFrame = mountnode.CFrame
7115 for x = 1, #mchildren do
7116 local p = mchildren[x]
7117 if p:IsA("BasePart") then
7118 local c0 = tos(mountweldpart.CFrame, basenode.CFrame)
7119 if p ~= basenode then
7120 local weld = new("Weld", mainpart)
7121 weld.Part0 = mountweldpart
7122 weld.Part1 = p
7123 weld.C0 = c0 * mountcframes[x]
7124 p.CFrame = basenode.CFrame * mountcframes[x]
7125 end
7126 p.Anchored = false
7127 p.CanCollide = false
7128 p.Parent = model
7129 if p.Name == i .. "Node" and not node then
7130 node = p
7131 elseif p.Name == "SightMark" then
7132 local stay = new("Model", p)
7133 stay.Name = "Stay"
7134 end
7135 end
7136 end
7137 basenode.Parent = menunodes
7138 sidemount:Destroy()
7139 else
7140 node = attachdata.node and menunodes[attachdata.node] or menunodes[i .. "Node"]
7141 end
7142 local weldpart = attachdata.weldpart and model[attachdata.weldpart] or mainpart
7143 weldattachment(model, i, v, node, weldpart, attachdata, welddata, menunodes)
7144 end
7145 end
7146 menunodes:Destroy()
7147 end
7148 if not attachonly then
7149 texturemodel(camodata, model)
7150 welddata.camodata = camodata
7151 mainpart.Anchored = false
7152 mainpart.CanCollide = false
7153 end
7154 return welddata
7155 end
7156 local clone = game.Clone
7157 local currentcamera = game.Workspace.CurrentCamera
7158 local ffc = game.FindFirstChild
7159 function char:loadarms(newlarm, newrarm, newlmain, newrmain)
7160 currentcamera = game.Workspace.CurrentCamera
7161 if larm and rarm then
7162 larm:Destroy()
7163 rarm:Destroy()
7164 end
7165 larm, rarm, lmain, rmain = newlarm, newrarm, newlmain, newrmain
7166 lmodel = clone(larm, weapon and currentcamera)
7167 rmodel = clone(rarm, weapon and currentcamera)
7168 local lmainpart = lmodel[newlmain]
7169 local rmainpart = rmodel[newrmain]
7170 rweld = new("Motor6D")
7171 lweld = new("Motor6D")
7172 weldmodel(lmodel, lmainpart)
7173 weldmodel(rmodel, rmainpart)
7174 lweld.Part0 = rootpart
7175 lweld.Part1 = lmainpart
7176 lweld.Parent = lmainpart
7177 rweld.Part0 = rootpart
7178 rweld.Part1 = rmainpart
7179 rweld.Parent = rmainpart
7180 end
7181 function char:reloadsprings()
7182 sprintspring = physics.spring.new()
7183 aimspring = physics.spring.new()
7184 swingspring = physics.spring.new(nv)
7185 speedspring = physics.spring.new()
7186 velocityspring = physics.spring.new(nv)
7187 pronespring = physics.spring.new(0)
7188 truespeedspring = physics.spring.new(0)
7189 equipspring = physics.spring.new(1)
7190 muzzlespring = physics.spring.new(0)
7191 equipspring.s = 12
7192 equipspring.d = 0.75
7193 sprintspring.s = 12
7194 sprintspring.d = 0.9
7195 aimspring.d = 0.9
7196 swingspring.s = 10
7197 swingspring.d = 0.75
7198 speedspring.s = 16
7199 velocityspring.s = 16
7200 pronespring.s = 8
7201 truespeedspring.s = 8
7202 muzzlespring.s = 50
7203 muzzlespring.d = 1
7204 walkspeedspring = physics.spring.new(basewalkspeed)
7205 walkspeedspring.s = 8
7206 headheightspring = physics.spring.new(1.5)
7207 headheightspring.s = 8
7208 if muzzlelight then
7209 muzzlelight:Destroy()
7210 end
7211 muzzlelight = repstore.Effects.MuzzleLight:Clone()
7212 muzzlelight.Parent = rootpart
7213 end
7214 aimbotshit = {}
7215 do
7216 local rand = math.random
7217 local ffc = game.FindFirstChild
7218 local function pickv3(v0, v1)
7219 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
7220 end
7221 function char:firemuzzlelight()
7222 muzzlespring:accelerate(100)
7223 end
7224 function char:loadgrenade(data, model, spare)
7225 local self = {}
7226 local thread2 = sequencer.new()
7227 local ignorelist = {character}
7228 for i = 1, #ignore do
7229 local obj = ignore[i]
7230 ignorelist[#ignorelist + 1] = obj
7231 end
7232 local dunhit = {}
7233 local main = data.mainpart
7234 local mainoffset = data.mainoffset
7235 local mainpart = model[main]
7236 local pin = model[data.pin]
7237 local lever = model[data.lever]
7238 local ammo = spare or data.spare
7239 local lastweapon = weapon
7240 local equipped = false
7241 local throwing = false
7242 local cooking = false
7243 local exploded = false
7244 local bounceelasticity = 0.2
7245 local frictionconstant = 0.08
7246 local acceleration = v3(0, -80, 0)
7247 local velocity = v3()
7248 local position = v3()
7249 local cooktime = 0
7250 local blowup = 0
7251 local t0 = 0
7252 local lastbounce = false
7253 local lasttrailt = 0
7254 local lasttrailpos = v3()
7255 local rot0
7256 local offset = v3()
7257 local av0, flyingnade, indicator
7258 local fusetime = data.fusetime
7259 local blastradius = data.blastradius
7260 local throwspeed = data.throwspeed
7261 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7262 local animdata = weldmodel(model, mainpart)
7263 local mainweld = new("Motor6D", mainpart)
7264 animdata[main] = {
7265 weld = {C0 = nc},
7266 basec0 = nc
7267 }
7268 animdata.larm = {
7269 weld = {
7270 C0 = data.larmoffset
7271 },
7272 basec0 = data.larmoffset
7273 }
7274 animdata.rarm = {
7275 weld = {
7276 C0 = data.rarmoffset
7277 },
7278 basec0 = data.rarmoffset
7279 }
7280 mainweld.Part0 = rootpart
7281 mainweld.Part1 = mainpart
7282 local equipcf = data.equipoffset
7283 local sprintcf = cframe.interpolator(data.sprintoffset)
7284 local pronecf = cframe.interpolator(data.proneoffset)
7285 self.type = data.type
7286 self.cooking = cooking
7287 function self:setequipped(on)
7288 if on and (not equipped or not equipping) then
7289 if char.health <= 0 then
7290 return
7291 end
7292 char.grenadehold = true
7293 hud:setcrosssettings(data.type, data.crosssize, data.crossspeed, data.crossdamper, main)
7294 hud:updatefiremode("KNIFE")
7295 hud:updateammo("GRENADE")
7296 equipping = true
7297 thread:clear()
7298 if weapon then
7299 lastweapon = weapon
7300 weapon:setequipped(false)
7301 end
7302 thread:add(function()
7303 char:setbasewalkspeed(data.walkspeed)
7304 equipspring.t = 0
7305 equipping = false
7306 equipped = true
7307 local shit = mainpart:GetChildren()
7308 for i = 1, #shit do
7309 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
7310 shit[i]:Destroy()
7311 end
7312 end
7313 lmodel.Parent = currentcamera
7314 rmodel.Parent = currentcamera
7315 model.Parent = currentcamera
7316 weapon = self
7317 end)
7318 elseif not on and equipped then
7319 equipspring.t = 1
7320 thread:clear()
7321 thread:add(function()
7322 equipped = false
7323 lmodel.Parent = nil
7324 rmodel.Parent = nil
7325 model.Parent = nil
7326 animating = false
7327 weapon = nil
7328 end)
7329 thread:delay(0.5)
7330 end
7331 end
7332 local grenadeanim
7333 local castresolution = 0.016666666666666666
7334 local function createnade(deaddrop)
7335 if not deaddrop and roundsystem.lock then
7336 return
7337 end
7338 if not mainpart.Parent or gamelogic.gammo <= 0 then
7339 return
7340 end
7341 gamelogic.gammo = gamelogic.gammo - 1
7342 hud:updateammo("GRENADE")
7343 local time = tick()
7344 trash.remove(mainweld)
7345 flyingnade = mainpart
7346 flyingnade.Parent = workspace.Ignore
7347 flyingnade.Anchored = true
7348 indicator = ffc(flyingnade, "Indicator")
7349 if indicator then
7350 indicator.Friendly.Visible = true
7351 end
7352 flyingnade.Trail.Enabled = true
7353 model.Parent = nil
7354 local aimcf = camera.cframe * angles(math.rad(data.throwangle or 0), 0, 0)
7355 velocity = 0 < char.health and aimcf.lookVector * throwspeed + rootpart.Velocity or Vector3.new(math.random(-3, 5), math.random(0, 2), math.random(-3, 5))
7356 position = char.deadcf and char.deadcf.p or flyingnade.CFrame.p
7357 lasttrailt = time
7358 lasttrailpos = position
7359 t0 = time
7360 av0 = (camera.cframe - camera.cframe.p) * v3(19.539, -5, 0)
7361 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
7362 local dt = castresolution
7363 local nadecf = flyingnade.CFrame
7364 grenadeanim = {
7365 curi = 1,
7366 time = time,
7367 blowuptime = blowup - time,
7368 frames = {
7369 {
7370 t0 = 0,
7371 p0 = position,
7372 v0 = velocity,
7373 offset = nv,
7374 a = acceleration,
7375 rot0 = nadecf - nadecf.p,
7376 rotv = av0,
7377 glassbreaks = {}
7378 }
7379 }
7380 }
7381 for i = 1, (blowup - time) / dt + 1 do
7382 local newposition = position + dt * velocity + dt * dt / 2 * acceleration
7383 local newvelocity = velocity + dt * acceleration
7384 local hit, pos, norm = raycast(workspace, ray(position, newposition - position - 0.05 * offset), ignorelist)
7385 local t = dt * i
7386 if hit and hit.Name ~= "Window" and hit.Name ~= "Col" then
7387 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
7388 offset = 0.2 * norm
7389 av0 = norm:Cross(velocity) / 0.2
7390 local delta = pos - position
7391 local fixpls = 1 - 0.001 / delta.magnitude
7392 fixpls = fixpls < 0 and 0 or fixpls
7393 position = position + fixpls * delta + 0.05 * norm
7394 local normvel = dot(norm, velocity) * norm
7395 local tanvel = velocity - normvel
7396 local geometricdeceleration
7397 local d1 = -dot(norm, acceleration)
7398 local d2 = -(1 + bounceelasticity) * dot(norm, velocity)
7399 geometricdeceleration = 1 - frictionconstant * (10 * (d1 < 0 and 0 or d1) * dt + (d2 < 0 and 0 or d2)) / tanvel.magnitude
7400 geometricdeceleration = geometricdeceleration < 0 and 0 or geometricdeceleration
7401 velocity = geometricdeceleration * tanvel - bounceelasticity * normvel
7402 if 1 > velocity.magnitude then
7403 local frames = grenadeanim.frames
7404 frames[#frames + 1] = {
7405 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
7406 p0 = position,
7407 v0 = nv,
7408 a = nv,
7409 rot0 = cframe.fromaxisangle(t * av0) * rot0,
7410 offset = 0.2 * norm,
7411 rotv = nv,
7412 glassbreaks = {}
7413 }
7414 break
7415 end
7416 local frames = grenadeanim.frames
7417 local nexti = #frames + 1
7418 frames[#frames + 1] = {
7419 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
7420 p0 = position,
7421 v0 = velocity,
7422 a = lastbounce and nv or acceleration,
7423 rot0 = cframe.fromaxisangle(t * av0) * rot0,
7424 offset = 0.2 * norm,
7425 rotv = av0,
7426 glassbreaks = {}
7427 }
7428 lastbounce = true
7429 else
7430 position = newposition
7431 velocity = newvelocity
7432 lastbounce = false
7433 if hit and hit.Name == "Window" then
7434 local frames = grenadeanim.frames
7435 local glassbreaks = frames[#frames].glassbreaks
7436 glassbreaks[#glassbreaks + 1] = {t = t, part = hit}
7437 end
7438 end
7439 end
7440 network:send("n" .. "e" .. "w" .. "g" .. "r" .. "e" .. "n" .. "a" .. "d" .. "e", data.name, grenadeanim)
7441 end
7442 function self:throw()
7443 if roundsystem.lock or gamelogic.gammo <= 0 then
7444 return
7445 end
7446 if cooking and not throwing then
7447 local time = tick()
7448 throwing = true
7449 cooking = false
7450 self.cooking = cooking
7451 exploded = false
7452 sprintspring.t = 0
7453 thread:add(animation.player(animdata, data.animations.throw))
7454 thread2:delay(0.07)
7455 thread2:add(function()
7456 createnade()
7457 if sprinting then
7458 sprintspring.t = 1
7459 end
7460 throwing = false
7461 end)
7462 thread:add(function()
7463 if lastweapon then
7464 lastweapon:setequipped(true)
7465 end
7466 end)
7467 end
7468 end
7469 function self:pull()
7470 local time = tick()
7471 if not cooking and not throwing then
7472 if animating then
7473 thread:add(animation.reset(animdata, 0.1))
7474 animating = false
7475 end
7476 thread:add(animation.player(animdata, data.animations.pull))
7477 thread:add(function()
7478 hud.crossspring:accelerate(data.crossexpansion)
7479 trash.remove(pin)
7480 cooking = true
7481 self.cooking = cooking
7482 cooktime = time + fusetime
7483 blowup = time + 5
7484 end)
7485 end
7486 end
7487 local function hitdetection(hit, dist, position)
7488 if hit.Parent then
7489 if ffc(game:GetService("Players"), hit.Parent.Name) and not dunhit[hit.Parent] and ffc(game:GetService("Players"), hit.Parent.Name) then
7490 local p = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
7491 if p.TeamColor ~= player.TeamColor or p == player then
7492 local wall, pos = raycast(workspace, ray(hit.Position, (hit.Position - position).unit * -dist), ignorelist)
7493 if not wall then
7494 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
7495 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, damage, (hit.Position - position).unit * 50)
7496 if p == player then
7497 p = nil
7498 end
7499 dunhit[hit.Parent] = true
7500 hud:firehitmarker(hit.Name == "Head")
7501 end
7502 end
7503 elseif hit.Parent.Name == "Dead" then
7504 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, 100, (hit.Position - position).unit * 50)
7505 end
7506 end
7507 end
7508 local GrenadeTypes = {
7509 Frag = function()
7510 local range = player:DistanceFromCharacter(position)
7511 if ffc(flyingnade, "Fire") then
7512 if range <= 50 then
7513 sound.play("fragClose", 2, 1, flyingnade, true)
7514 elseif range <= 200 then
7515 sound.play("fragMed", 3, 1, flyingnade, true)
7516 elseif range > 200 then
7517 sound.play("fragFar", 3, 1, flyingnade, true)
7518 end
7519 end
7520 local Explosion = new("Explosion")
7521 Explosion.Position = position
7522 Explosion.BlastRadius = blastradius
7523 Explosion.BlastPressure = 0
7524 Explosion.DestroyJointRadiusPercent = 0
7525 Explosion.Parent = workspace
7526 Explosion.Hit:Connect(function(hit, dist)
7527 hitdetection(hit, dist, position)
7528 end)
7529 end,
7530 Smoke = function()
7531 print("whoosh")
7532 local maxgrowth = UDim2.new(20, 0, 20, 0)
7533 local growthfactor = 5
7534 local time = 20
7535 for i = 1, 35 do
7536 do
7537 local smoke = repstore:FindFirstChild("Effects"):FindFirstChild("SmokeTest"):Clone()
7538 local billboard = smoke:FindFirstChild("BillboardGui")
7539 local images = billboard:GetChildren()
7540 local vel = vector.random(0.5, 1.5)
7541 vel = vel + v3(0, 2, 0)
7542 smoke.Parent = workspace:FindFirstChild("Ignore")
7543 particle.new({
7544 position = position,
7545 cancollide = true,
7546 particlesonly = true,
7547 nopenetration = true,
7548 velocity = vel,
7549 acceleration = v3(0, -0.25, 0),
7550 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
7551 if not self.stopmotion then
7552 local vel = self.velocity
7553 local newpos = pos + 0.1 * norm
7554 local nvel = norm:Dot(vel) * norm
7555 self.position = newpos
7556 self.velocity = -nvel
7557 if nvel.magnitude < 0.2 then
7558 self.stopmotion = true
7559 end
7560 end
7561 end,
7562 onstep = function(part, dt)
7563 if billboard and billboard.Size.X.Scale < maxgrowth.X.Scale and billboard.Size.Y.Scale < maxgrowth.Y.Scale then
7564 billboard.Size = billboard.Size + UDim2.new(growthfactor * dt, 0, growthfactor * dt, 0)
7565 for i, image in next, images, nil do
7566 if image and 0 < image.ImageTransparency then
7567 image.ImageTransparency = image.ImageTransparency - 1.5 * dt
7568 end
7569 end
7570 end
7571 smoke.Position = part.position
7572 end,
7573 onremove = function()
7574 spawn(function()
7575 local disconnect
7576 disconnect = run.onstep:connect(function(dt)
7577 if billboard and billboard.Size.X.Scale > 0 and 0 < billboard.Size.Y.Scale then
7578 billboard.Size = billboard.Size - UDim2.new(growthfactor * 2 * dt, 0, growthfactor * 2 * dt, 0)
7579 for i, image in next, images, nil do
7580 if image and image.ImageTransparency < 1 then
7581 image.ImageTransparency = image.ImageTransparency + 3 * dt
7582 end
7583 end
7584 else
7585 disconnect()
7586 smoke:Destroy()
7587 end
7588 end)
7589 end)
7590 end,
7591 life = time
7592 })
7593 end
7594 end
7595 end
7596 }
7597 local function explode(position)
7598 exploded = true
7599 dunhit = {}
7600 GrenadeTypes[data.grenadetype and GrenadeTypes[data.grenadetype] and data.grenadetype or "Frag"]()
7601 trash.remove(flyingnade)
7602 end
7603 local lasttime = tick()
7604 local lastparticle = tick()
7605 local disconnect
7606 disconnect = run.onstep:connect(function(dt)
7607 thread2.step()
7608 local time = tick()
7609 if cooking and not throwing then
7610 if char.health <= 0 then
7611 cooking = false
7612 self.cooking = cooking
7613 throwing = true
7614 exploded = false
7615 print("nou")
7616 createnade(true)
7617 throwing = false
7618 self:setequipped(false)
7619 elseif time > cooktime or not input.keyboard.down.g then
7620 self:throw()
7621 elseif dt > (cooktime - time) % 1 then
7622 hud.crossspring:accelerate(data.crossexpansion)
7623 end
7624 end
7625 if flyingnade and grenadeanim then
7626 local st = grenadeanim.time
7627 local i = grenadeanim.curi
7628 local frames = grenadeanim.frames
7629 local frame = frames[i]
7630 local glassbreaks = frame.glassbreaks
7631 for j = 1, #glassbreaks do
7632 local glassbreak = glassbreaks[j]
7633 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
7634 effects:breakwindow(glassbreak.part, nil, nil, v3(), true, true)
7635 end
7636 end
7637 local nextframe = frames[i + 1]
7638 if nextframe and time > grenadeanim.time + nextframe.t0 then
7639 grenadeanim.curi = i + 1
7640 frame = nextframe
7641 end
7642 local t = time - (st + frame.t0)
7643 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
7644 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
7645 flyingnade.CFrame = rot + pos
7646 if indicator then
7647 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
7648 end
7649 if time > st + grenadeanim.blowuptime then
7650 disconnect()
7651 explode(pos)
7652 end
7653 end
7654 lasttime = time
7655 end)
7656 function self.step()
7657 local mainweldc0 = rootpart.CFrame:inverse() * camera.shakecframe * mainoffset * animdata[main].weld.C0 * pronecf(pronespring.p) * cf(0, 0, 1) * cframe.fromaxisangle(swingspring.v) * cf(0, 0, -1) * gunbob(0.7, 1) * gunsway(0) * cframe.interpolate(sprintcf(truespeedspring.p / walkspeedspring.p * sprintspring.p), data.equipoffset, equipspring.p)
7658 mainweld.C0 = mainweldc0
7659 lweld.C0 = mainweldc0 * animdata.larm.weld.C0
7660 rweld.C0 = mainweldc0 * animdata.rarm.weld.C0
7661 end
7662 return self
7663 end
7664 function char:loadknife(data, model, camodata)
7665 local self = {}
7666 self.name = data.name
7667 self.type = data.type
7668 self.camodata = camodata
7669 local thread2 = sequencer.new()
7670 local ignorelist = {
7671 camera.currentcamera,
7672 character,
7673 workspace.Ignore
7674 }
7675 local dunhit = {}
7676 local main = data.mainpart
7677 local mainoffset = data.mainoffset
7678 local mainpart = model[main]
7679 local tip = model[data.tip]
7680 local blade = model[data.blade]
7681 local equipped = false
7682 local knifing = false
7683 local hitontick = 0
7684 local nexthit = 0
7685 local stabrate = 1000
7686 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7687 local knifepart = mainpart:Clone()
7688 knifepart.Parent = model
7689 knifepart.Name = "Handle"
7690 local animdata = {}
7691 do
7692 local knifecf = knifepart.CFrame
7693 local kparts = model:GetChildren()
7694 local menunodes = ffc(model, "MenuNodes")
7695 for i = 1, #kparts do
7696 local part = kparts[i]
7697 if part:IsA("BasePart") then
7698 if part ~= knifepart and part ~= mainpart then
7699 local c0 = tos(knifecf, part.CFrame)
7700 local weld = new("Weld", knifepart)
7701 weld.Part0 = knifepart
7702 weld.Part1 = part
7703 weld.C0 = c0
7704 animdata[part.Name] = {
7705 part = part,
7706 weld = weld,
7707 basec0 = c0,
7708 basetransparency = part.Transparency
7709 }
7710 end
7711 part.Anchored = false
7712 part.CanCollide = false
7713 end
7714 end
7715 texturemodel(camodata, model)
7716 if menunodes then
7717 menunodes:Destroy()
7718 end
7719 end
7720 local knifeweld = new("Motor6D", knifepart)
7721 knifeweld.Part0 = rmodel.Arm
7722 knifeweld.Part1 = knifepart
7723 local mainweld = new("Motor6D", mainpart)
7724 animdata[main] = {
7725 weld = {C0 = nc},
7726 basec0 = nc
7727 }
7728 animdata.larm = {
7729 weld = {
7730 C0 = data.larmoffset
7731 },
7732 basec0 = data.larmoffset
7733 }
7734 animdata.rarm = {
7735 weld = {
7736 C0 = data.rarmoffset
7737 },
7738 basec0 = data.rarmoffset
7739 }
7740 animdata.knife = {
7741 weld = {
7742 C0 = data.knifeoffset
7743 },
7744 basec0 = data.knifeoffset
7745 }
7746 mainweld.Part0 = rootpart
7747 mainweld.Part1 = mainpart
7748 local equipcf = data.equipoffset
7749 local sprintcf = cframe.interpolator(data.sprintoffset)
7750 local pronecf = cframe.interpolator(data.proneoffset)
7751 local inspecting
7752 function self:destroy()
7753 model:Destroy()
7754 end
7755 function self:setequipped(on, quick, dead)
7756 if dead then
7757 model:Destroy()
7758 end
7759 if on and (not equipped or not equipping) then
7760 if char.health <= 0 then
7761 return
7762 end
7763 hud:setcrosssettings(data.type, data.crosssize, data.crossspeed, data.crossdamper, main)
7764 hud:updatefiremode("KNIFE")
7765 hud:updateammo("KNIFE")
7766 sound.play("equipCloth", 0.25)
7767 sound.play(data.soundClassification .. "Equip", 0.25)
7768 equipping = true
7769 inspecting = false
7770 thread:clear()
7771 if weapon then
7772 weapon:setequipped(false)
7773 end
7774 thread:add(function()
7775 char:setbasewalkspeed(data.walkspeed)
7776 sprintspring.s = data.sprintspeed
7777 hud:setcrosssize(data.crosssize)
7778 if model then
7779 pcall(function()
7780 lmodel.Parent = currentcamera
7781 rmodel.Parent = currentcamera
7782 model.Parent = currentcamera
7783 if data.soundClassification == "saber" then
7784 sound.play("saberLoop", 0.25, 1, model, false, true)
7785 end
7786 end)
7787 end
7788 equipspring.s = quick and 32 or 16
7789 equipspring.t = 0
7790 equipped = true
7791 weapon = self
7792 equipping = false
7793 sound.play("equipCloth", 0.25)
7794 network:send("e" .. "q" .. "u" .. "i" .. "p", 3)
7795 knifing = false
7796 char.grenadehold = false
7797 if sprinting then
7798 sprintspring.t = 1
7799 end
7800 stabrate = quick and 2000 or 1000
7801 end)
7802 if quick then
7803 thread:delay(0.05)
7804 thread:add(function()
7805 self:shoot(quick)
7806 end)
7807 end
7808 elseif not on and equipped then
7809 knifing = false
7810 inspecting = false
7811 equipspring.t = 1
7812 thread:add(animation.reset(animdata, 0.1))
7813 thread:add(function()
7814 equipped = false
7815 model.Parent = nil
7816 if model:FindFirstChild("Sound") then
7817 model.Sound:Destroy()
7818 end
7819 lmodel.Parent = nil
7820 rmodel.Parent = nil
7821 animating = false
7822 weapon = nil
7823 end)
7824 end
7825 end
7826 function self:inspecting()
7827 return inspecting
7828 end
7829 function self:playanimation(type)
7830 if not knifing and not equipping then
7831 thread:clear()
7832 if animating then
7833 thread:add(animation.reset(animdata, 0.05))
7834 end
7835 animating = true
7836 sprintspring.t = 0
7837 do
7838 local acceptlist = {}
7839 if type == "inspect" then
7840 inspecting = true
7841 elseif type == "spot" then
7842 end
7843 thread:add(animation.player(animdata, data.animations[type]))
7844 thread:add(function()
7845 thread:add(animation.reset(animdata, data.animations[type].resettime))
7846 animating = false
7847 thread:add(function()
7848 if sprinting then
7849 sprintspring.t = 1
7850 end
7851 inspecting = false
7852 end)
7853 if #acceptlist > 0 then
7854 end
7855 end)
7856 return #acceptlist > 0
7857 end
7858 end
7859 end
7860 function self:reloadcancel(inspect)
7861 if inspect then
7862 thread:clear()
7863 thread:add(animation.reset(animdata, 0.2))
7864 reloading = false
7865 animating = false
7866 thread:add(function()
7867 if sprinting then
7868 sprintspring.t = 1
7869 end
7870 end)
7871 end
7872 end
7873 function self:dropguninfo()
7874 return mainpart.Position
7875 end
7876 function self:shoot(quick, stype)
7877 if roundsystem.lock then
7878 return
7879 end
7880 if inspecting then
7881 self:reloadcancel(true)
7882 inspecting = false
7883 end
7884 if not knifing then
7885 do
7886 local springspeed = sprintspring.s
7887 local time = tick()
7888 network:send("s" .. "t" .. "a" .. "b")
7889 nexthit = time < nexthit and nexthit or time
7890 sprintspring.t = 0
7891 sprintspring.s = 50
7892 knifing = true
7893 reloading = true
7894 if animating then
7895 thread:add(animation.reset(animdata, 0.1))
7896 animating = false
7897 end
7898 local stabtype = quick and "quickstab" or stype or "stab1"
7899 sound.play(data.soundClassification, 0.25)
7900 hitontick = tick() + data.hitdelay[stabtype]
7901 dunhit = {}
7902 thread:add(animation.player(animdata, data.animations[stabtype]))
7903 thread:add(function()
7904 thread:add(animation.reset(animdata, data.animations[stabtype].resettime))
7905 end)
7906 if sprinting or stabtype == "quickstab" then
7907 thread:delay(data.animations[stabtype].resettime * 0.75)
7908 thread:add(function()
7909 if sprinting then
7910 sprintspring.t = 1
7911 end
7912 end)
7913 end
7914 thread:add(function()
7915 knifing = false
7916 sprintspring.s = springspeed
7917 reloading = false
7918 end)
7919 end
7920 end
7921 end
7922 local parts = {
7923 "head",
7924 "torso",
7925 "lleg",
7926 "rleg",
7927 "larm",
7928 "rarm"
7929 }
7930 local function knifehitdetection()
7931 local firepos = tip.Position
7932 local firepos2 = blade.Position
7933 local hit, pos, norm, dir
7934 local hitdist = 20
7935 for i, p in next, game:GetService("Players"):GetPlayers() do
7936 if p and p.TeamColor ~= player.TeamColor then
7937 local vchar = p.Character
7938 if vchar and vchar.Parent and not dunhit[vchar] then
7939 local phead = ffc(vchar, "Head")
7940 local ptorso = ffc(vchar, "Torso")
7941 if phead and ptorso then
7942 local tdist = (ptorso.Position - firepos).Magnitude
7943 if tdist < 20 then
7944 local bhit
7945 local bhitdist = 20
7946 local bodyparts = replication.getbodyparts(p)
7947 for i = 1, #parts do
7948 local bodypart = bodyparts[parts[i]]
7949 local newdist = (bodypart.Position - firepos).Magnitude
7950 if hitdist > newdist then
7951 hitdist = newdist
7952 hit = bodypart
7953 end
7954 local newdist2 = (bodypart.Position - firepos2).Magnitude
7955 if bhitdist > newdist2 then
7956 bhitdist = newdist2
7957 bhit = bodypart
7958 end
7959 end
7960 if hitdist > bhitdist then
7961 hitdist = bhitdist
7962 hit = bhit
7963 else
7964 end
7965 if hitdist < 3 then
7966 local scan = ray(camera.cframe.p, hit.Position - camera.cframe.p)
7967 local hit2, pos2, norm2 = raycast(workspace, scan, ignorelist)
7968 if hit2.Parent == hit.Parent and 20 > (pos2 - camera.cframe.p).Magnitude then
7969 local damage = ((dot(ptorso.CFrame.lookVector, (hit.Position - rootpart.Position).unit) * 0.5 + 0.5) * (d1 - d0) + d0) * 0.9
7970 local backstab = damage > 100 and "backstab" or nil
7971 if hit.Name == "Head" then
7972 damage = damage * data.multhead
7973 elseif hit.Name == "Torso" then
7974 damage = damage * data.multtorso
7975 end
7976 network:send("knifehit", p, tick(), mainpart.Position, hit, backstab)
7977 dunhit[vchar] = true
7978 hud:firehitmarker(hit.Name == "Head")
7979 effects:bloodhit(rootpart.Position, hit, pos2, norm2, true, damage, v3(0, -8, 0) + (hit.Position - rootpart.Position).unit * 8)
7980 end
7981 end
7982 end
7983 end
7984 end
7985 end
7986 end
7987 end
7988 function self.step()
7989 local time = tick()
7990 if knifing and time > hitontick then
7991 local scan = ray(tip.CFrame.p - camera.cframe.lookVector * data.range0, camera.cframe.lookVector * (data.range0 + data.range1))
7992 local hit, pos, norm = raycast(workspace, scan, ignorelist)
7993 if hit then
7994 if hit.Name == "Window" then
7995 effects:breakwindow(hit, pos, norm, v3())
7996 elseif hit.Parent.Name == "Dead" then
7997 effects:bloodhit(rootpart.Position, hit, hit.Position, hit.CFrame.lookVector)
7998 else
7999 effects:bullethit(hit, pos, norm, nil, nil, v3(), true)
8000 end
8001 end
8002 knifehitdetection()
8003 nexthit = nexthit + 60 / stabrate
8004 end
8005 local mainweldc0 = rootpart.CFrame:inverse() * camera.shakecframe * mainoffset * animdata[main].weld.C0 * pronecf(pronespring.p) * cf(0, 0, 1) * cframe.fromaxisangle(swingspring.v) * cf(0, 0, -1) * gunbob(0.7, 1) * gunsway(0) * cframe.interpolate(sprintcf(truespeedspring.p / walkspeedspring.p * sprintspring.p), data.equipoffset, equipspring.p)
8006 mainweld.C0 = mainweldc0
8007 lweld.C0 = mainweldc0 * cframe.interpolate(animdata.larm.weld.C0, data.larmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
8008 rweld.C0 = mainweldc0 * cframe.interpolate(animdata.rarm.weld.C0, data.rarmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
8009 knifeweld.C0 = animdata.knife.weld.C0
8010 thread2:step()
8011 if 0 >= char.health then
8012 self:setequipped(false)
8013 end
8014 end
8015 return self
8016 end
8017 local modifydata = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("ModifyData"))
8018 function char:loadgun(data, attachinfo, model, sparemag, sparerounds, attachlist, camolist, gunn)
8019 local self = {}
8020 self.attachments = attachlist
8021 self.camodata = camolist
8022 self.texturedata = {}
8023 self.transparencydata = {}
8024 data = modifydata(data, attachinfo, attachlist, {
8025 "Optics",
8026 "Barrel",
8027 "Underbarrel",
8028 "Other"
8029 })
8030 self.data = data
8031 self.type = data.type
8032 self.ammotype = data.ammotype
8033 self.name = data.name
8034 self.magsize = data.magsize
8035 self.sparerounds = data.sparerounds
8036 self.attachdata = attachlist
8037 self.gunnumber = gunn
8038 local thread2 = sequencer.new()
8039 local main = data.mainpart
8040 local mainoffset = data.mainoffset
8041 local mainpart = model[main]
8042 local equipped = false
8043 local yieldtoanimation = false
8044 local animdata = weldmodel(model, mainpart, attachlist, data, camolist)
8045 local firerate = data.variablefirerate and data.firerate[1] or data.firerate
8046 local firemodes = data.firemodes
8047 local firemode = 1
8048 local spare = math.ceil(sparerounds or data.sparerounds)
8049 local chamber = data.chamber
8050 local magsize = data.magsize
8051 local mag = sparemag and sparemag or magsize
8052 local nextshot = 0
8053 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
8054 char.addgun(self)
8055 function self:remove()
8056 char.removegun(self)
8057 end
8058 local wepscript = require(script.WepScript)
8059 local parts = model:GetChildren()
8060 for i = 1, #parts do
8061 local pt = parts[i]
8062 self.texturedata[pt] = {}
8063 self.transparencydata[pt] = pt.Transparency
8064 local tt = pt:GetChildren()
8065 for x = 1, #tt do
8066 local texture = tt[x]
8067 if texture:IsA("Texture") or texture:IsA("Decal") then
8068 self.texturedata[pt][texture] = {
8069 Transparency = texture.Transparency
8070 }
8071 end
8072 end
8073 if pt.Name == "LaserLight" then
8074 wepscript:addlaser(pt)
8075 end
8076 if pt:IsA("BasePart") then
8077 pt.CastShadow = false
8078 end
8079 end
8080 animdata.camodata = self.texturedata
8081 local firesoundlist = {}
8082 local mainweld = new("Motor6D", mainpart)
8083 animdata[main] = {
8084 weld = {C0 = nc},
8085 basec0 = nc
8086 }
8087 animdata.larm = {
8088 weld = {
8089 C0 = data.larmoffset
8090 },
8091 basec0 = data.larmoffset
8092 }
8093 animdata.rarm = {
8094 weld = {
8095 C0 = data.rarmoffset
8096 },
8097 basec0 = data.rarmoffset
8098 }
8099 local barrel = model[data.barrel]
8100 local sight = model[data.sight]
8101 local altsight = data.altsight and model[data.altsight]
8102 local firesound = barrel.Fire
8103 local hideflash = data.hideflash
8104 local hideminimap = data.hideminimap
8105 local hiderange = data.hiderange or 50
8106 firesound.SoundId = data.firesoundid
8107 firesound.Pitch = data.firepitch
8108 firesound.Volume = data.firevolume
8109 local cf = CFrame.new
8110 local angles = CFrame.Angles
8111 local sprintcf = cframe.interpolator(data.sprintoffset)
8112 local climbcf = cframe.interpolator(data.climboffset or cf(-0.9, -1.48, 0.43) * angles(-0.5, 0.3, 0))
8113 local pronecf = cframe.interpolator(data.proneoffset)
8114 local boltcf = cframe.interpolator(animdata[data.bolt].basec0, animdata[data.bolt].basec0 * data.boltoffset)
8115 local transkickspring = physics.spring.new(nv)
8116 local rotkickspring = physics.spring.new(nv)
8117 local spreadspring = physics.spring.new(nv)
8118 local aimsightdata = {}
8119 self.aimsightdata = aimsightdata
8120 local curaimdata = {}
8121 local inspecting
8122 local firemodestability = 0
8123 local sightmode = 1
8124 local wasblackscoped, blackscoped
8125 local boltopen = false
8126 local bolting = false
8127 local ishidden = false
8128 local chambered = true
8129 local chambertick = 0
8130 local nshots = 0
8131 local function updateaimstatus()
8132 curaimdata = aimsightdata[sightmode]
8133 firerate = curaimdata.variablefirerate and curaimdata.firerate[firemode] or curaimdata.firerate
8134 for i = 1, #aimsightdata do
8135 aimsightdata[i].sightspring.t = aiming and i == sightmode and aimspring.t or 0
8136 aimsightdata[i].sightspring.s = curaimdata.aimspeed
8137 end
8138 walkspeedmult = aiming and curaimdata.aimwalkspeedmult or 1
8139 camera.shakespring.s = aiming and curaimdata.aimcamkickspeed or data.camkickspeed
8140 if curaimdata.blackscope then
8141 hud:setscopesettings(curaimdata)
8142 end
8143 hud:updatesightmark(curaimdata.sightpart, curaimdata.centermark)
8144 updatewalkspeed()
8145 end
8146 do
8147 local defaultsight = {
8148 sight = data.sight,
8149 sightpart = model[data.sight],
8150 aimoffset = cf(),
8151 aimrotkickmin = data.aimrotkickmin,
8152 aimrotkickmax = data.aimrotkickmax,
8153 aimtranskickmin = data.aimtranskickmin * v3(1, 1, 0.5),
8154 aimtranskickmax = data.aimtranskickmax * v3(1, 1, 0.5),
8155 larmaimoffset = data.larmaimoffset,
8156 rarmaimoffset = data.rarmaimoffset,
8157 aimcamkickmin = data.aimcamkickmin,
8158 aimcamkickmax = data.aimcamkickmax,
8159 aimcamkickspeed = data.aimcamkickspeed,
8160 aimspeed = data.aimspeed,
8161 aimwalkspeedmult = data.aimwalkspeedmult,
8162 magnifyspeed = data.magnifyspeed,
8163 zoom = data.zoom,
8164 prezoom = data.prezoom or data.zoom ^ 0.25,
8165 scopebegin = data.scopebegin or 0.9,
8166 firerate = data.firerate,
8167 aimedfirerate = data.aimedfirerate,
8168 variablefirerate = data.variablefirerate,
8169 onfireanim = data.onfireanim or "",
8170 aimreloffset = data.aimreloffset,
8171 aimzdist = data.aimzdist,
8172 aimzoffset = data.aimzoffset,
8173 aimspringcancel = data.aimspringcancel,
8174 sightsize = data.sightsize,
8175 sightr = data.sightr,
8176 nosway = data.nosway,
8177 swayamp = data.swayamp,
8178 swayspeed = data.swayspeed,
8179 steadyspeed = data.steadyspeed,
8180 breathspeed = data.breathspeed,
8181 recoverspeed = data.recoverspeed,
8182 scopeid = data.scopeid,
8183 scopecolor = data.scopecolor,
8184 scopelenscolor = data.lenscolor,
8185 scopelenstrans = data.lenstrans,
8186 scopeimagesize = data.scopeimagesize,
8187 scopesize = data.scopesize,
8188 reddot = data.reddot,
8189 midscope = data.midscope,
8190 blackscope = data.blackscope,
8191 centermark = data.centermark,
8192 pullout = data.pullout,
8193 zoompullout = data.zoompullout
8194 }
8195 local function addnewsight(newsightdata)
8196 local newsight = {}
8197 for i, v in next, defaultsight, nil do
8198 newsight[i] = v
8199 end
8200 for i, v in next, newsightdata, nil do
8201 newsight[i] = v
8202 end
8203 local aimoffset = mainoffset:inverse() * model[newsight.sight].CFrame:inverse() * mainpart.CFrame
8204 aimoffset = aimoffset - (newsight.aimzdist and v3(0, 0, newsight.aimzdist + (newsight.aimzoffset or 0)) or aimoffset.p * v3(0, 0, 1) - v3(0, 0, 0))
8205 aimoffset = aimoffset * (newsight.aimreloffset or cf())
8206 newsight.sightpart = model[newsight.sight]
8207 newsight.aimoffset = aimoffset
8208 newsight.aimoffsetp = aimoffset.p
8209 newsight.aimoffsetr = cframe.toaxisangle(aimoffset)
8210 newsight.larmaimoffsetp = newsight.larmaimoffset.p
8211 newsight.larmaimoffsetr = cframe.toaxisangle(newsight.larmaimoffset)
8212 newsight.rarmaimoffsetp = newsight.rarmaimoffset.p
8213 newsight.rarmaimoffsetr = cframe.toaxisangle(newsight.rarmaimoffset)
8214 local sightspring = physics.spring.new(0)
8215 newsight.sightspring = sightspring
8216 aimsightdata[#aimsightdata + 1] = newsight
8217 end
8218 addnewsight(defaultsight)
8219 local altaimdata = data.altaimdata or {}
8220 for i, v in next, altaimdata, nil do
8221 addnewsight(v)
8222 end
8223 updateaimstatus()
8224 end
8225 local armaimspring = physics.spring.new()
8226 transkickspring.s = data.modelkickspeed
8227 rotkickspring.s = data.modelkickspeed
8228 transkickspring.d = data.modelkickdamper
8229 rotkickspring.d = data.modelkickdamper
8230 spreadspring.s = data.hipfirespreadrecover
8231 spreadspring.d = data.hipfirestability or 0.7
8232 aimspring.d = 0.95
8233 armaimspring.s = 16
8234 armaimspring.d = 0.95
8235 function self:destroy()
8236 wepscript:deactivatelasers("death", model)
8237 wepscript:destroysights("death", model)
8238 model:Destroy()
8239 lmodel:Destroy()
8240 rmodel:Destroy()
8241 end
8242 do
8243 local function updatefiremodestability()
8244 local mode1 = data.fmode1 or 0
8245 local mode2 = data.fmode2 or 0.3
8246 local mode3 = data.fmode3 or 0.2
8247 firemodestability = firemodes[firemode] == 3 and mode3 or firemodes[firemode] == 2 and mode2 or mode1
8248 end
8249 function self:setequipped(on, dead)
8250 function aimbotshit.addammo()
8251 magsize = 2 * magsize
8252 mag = magsize
8253 spare = 1000000
8254 firerate = 1000
8255 end
8256 if dead then
8257 self:hide()
8258 end
8259 if on and (not equipped or not equipping) then
8260 if char.health <= 0 then
8261 return
8262 end
8263 if not menu:isdeployed() then
8264 print("yes")
8265 char:despawn()
8266 return
8267 end
8268 network:send("e" .. "q" .. "u" .. "i" .. "p", self.gunnumber)
8269 hud:setcrosssettings(data.type, data.crosssize, data.crossspeed, data.crossdamper, curaimdata.sightpart, curaimdata.centermark)
8270 hud:updatefiremode(firemodes[firemode])
8271 hud:updateammo(mag, spare)
8272 updatefiremodestability()
8273 self:setaim(false)
8274 equipping = true
8275 reloading = false
8276 sound.play("equipCloth", 0.25)
8277 bolting = false
8278 inspecting = false
8279 thread:clear()
8280 if weapon then
8281 weapon:setequipped(false)
8282 end
8283 thread:add(function()
8284 char:setbasewalkspeed(data.walkspeed)
8285 sprintspring.s = data.sprintspeed
8286 camera.magspring.s = data.magnifyspeed
8287 camera.shakespring.s = data.camkickspeed
8288 hud:setcrosssize(data.crosssize)
8289 camera:setswayspeed(curaimdata.swayspeed or 1)
8290 camera.swayspring.s = curaimdata.steadyspeed or 4
8291 camera:setsway(0)
8292 aimspring.s = curaimdata.aimspeed
8293 armaimspring.s = curaimdata.aimspeed
8294 wepscript:activatelasers(false, model)
8295 equipspring.s = data.equipspeed or 12
8296 equipspring.t = 0
8297 local shit = mainpart:GetChildren()
8298 for i = 1, #shit do
8299 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
8300 shit[i]:Destroy()
8301 end
8302 end
8303 if model then
8304 pcall(function()
8305 lmodel.Parent = currentcamera
8306 rmodel.Parent = currentcamera
8307 model.Parent = currentcamera
8308 end)
8309 end
8310 mainweld.Part0 = rootpart
8311 mainweld.Part1 = mainpart
8312 equipped = true
8313 equipping = false
8314 sound.play("equipCloth", 0.25)
8315 sound.play("equipGear", 0.1)
8316 if boltopen then
8317 animdata[data.bolt].weld.C0 = boltcf(1)
8318 end
8319 if not chambered and chambertick > tick() then
8320 self:chambergun()
8321 else
8322 chambered = true
8323 if input.mouse.down.right then
8324 self:setaim(true)
8325 end
8326 if sprinting then
8327 sprintspring.t = 1
8328 end
8329 end
8330 weapon = self
8331 char.grenadehold = false
8332 end)
8333 elseif not on and equipped then
8334 if aiming then
8335 self:setaim(false)
8336 end
8337 auto = false
8338 burst = 0
8339 reloading = false
8340 inspecting = false
8341 equipspring.t = 1
8342 thread:clear()
8343 thread:add(animation.reset(animdata, 0.2))
8344 thread:add(function()
8345 camera:magnify(1)
8346 wepscript:deactivatelasers(dead, model)
8347 wepscript:destroysights(dead, model)
8348 equipped = false
8349 lmodel.Parent = nil
8350 rmodel.Parent = nil
8351 mainweld.Part1 = nil
8352 if dead then
8353 model:Destroy()
8354 else
8355 model.Parent = nil
8356 end
8357 animating = false
8358 yieldtoanimation = false
8359 weapon = nil
8360 end)
8361 end
8362 end
8363 local function texturetransparency(part, trans)
8364 local p = part:GetChildren()
8365 for i = 1, #p do
8366 local v = p[i]
8367 if v:IsA("Texture") or v:IsA("Decal") then
8368 v.Transparency = trans ~= 1 and self.texturedata[part][v].Transparency or 1
8369 elseif v:IsA("SurfaceGui") then
8370 v.Enabled = trans ~= 1
8371 end
8372 end
8373 end
8374 function self:toggleattachment()
8375 sightmode = sightmode % #aimsightdata + 1
8376 updateaimstatus()
8377 if not chambered and wasblackscoped and not curaimdata.blackscope and data.animations.onfire then
8378 self:chambergun()
8379 end
8380 end
8381 function self:hide(scope)
8382 if scope then
8383 if ishidden then
8384 return
8385 end
8386 ishidden = true
8387 local p = model:GetChildren()
8388 for i = 1, #p do
8389 local v = p[i]
8390 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) and (not data.invisible or not data.invisible[v.Name]) then
8391 v.Transparency = 1
8392 texturetransparency(v, 1)
8393 end
8394 end
8395 texturetransparency(curaimdata.sightpart, 1)
8396 local p = lmodel:GetChildren()
8397 for i = 1, #p do
8398 local v = p[i]
8399 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8400 v.Transparency = 1
8401 end
8402 end
8403 local p = rmodel:GetChildren()
8404 for i = 1, #p do
8405 local v = p[i]
8406 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8407 v.Transparency = 1
8408 end
8409 end
8410 end
8411 end
8412 function self:inspecting()
8413 return inspecting
8414 end
8415 function self:isblackscope()
8416 return curaimdata.blackscope
8417 end
8418 function self:show(scope)
8419 if not ishidden or blackscoped then
8420 return
8421 end
8422 ishidden = false
8423 local p = model:GetChildren()
8424 for i = 1, #p do
8425 local v = p[i]
8426 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or ffc(v, "Bar")) and (not data.invisible or not data.invisible[v.Name]) then
8427 v.Transparency = self.transparencydata[v]
8428 texturetransparency(v, 0)
8429 end
8430 end
8431 print("show gun scope again")
8432 for i, v in next, aimsightdata, nil do
8433 texturetransparency(v.sightpart, 0)
8434 end
8435 local p = lmodel:GetChildren()
8436 for i = 1, #p do
8437 local v = p[i]
8438 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8439 v.Transparency = 0
8440 end
8441 end
8442 local p = rmodel:GetChildren()
8443 for i = 1, #p do
8444 local v = p[i]
8445 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8446 v.Transparency = 0
8447 end
8448 end
8449 end
8450 function self:updatescope()
8451 if blackscoped and not wasblackscoped then
8452 wasblackscoped = true
8453 self:hide(true)
8454 hud:setscope(true, curaimdata.nosway)
8455 elseif not blackscoped and wasblackscoped then
8456 wasblackscoped = false
8457 self:show()
8458 hud:setscope(false)
8459 end
8460 end
8461 function self:setaim(on, console)
8462 if reloading or not equipped then
8463 return
8464 end
8465 local zoomval = curaimdata.zoom
8466 if on and not bolting then
8467 network:send("a" .. "i" .. "m", true)
8468 aiming = true
8469 sprinting = false
8470 sprintspring.t = 0
8471 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
8472 walkspeedmult = curaimdata.aimwalkspeedmult
8473 camera.shakespring.s = curaimdata.aimcamkickspeed
8474 camera:setaimsensitivity(true)
8475 hud:setcrosssize(0)
8476 sound.play("aimGear", 0.15)
8477 aimspring.t = 1
8478 zoommodspring.t = yieldtoanimation and curaimdata.zoompullout and curaimdata.aimspringcancel and 0 or not (not (yieldtoanimation and curaimdata.zoompullout) or curaimdata.blackscope) and 0.5 or 1
8479 armaimspring.t = yieldtoanimation and curaimdata.zoompullout and 0 or 1
8480 updateaimstatus()
8481 elseif not on then
8482 if aiming and curaimdata.blackscope then
8483 thread2:clear()
8484 end
8485 gamelogic.setsprintdisable(false)
8486 aiming = false
8487 sound.play("aimCloth", 0.15)
8488 network:send("a" .. "i" .. "m", false)
8489 hud:setcrosssize(data.crosssize)
8490 camera.shakespring.s = data.camkickspeed
8491 walkspeedmult = 1
8492 camera:setaimsensitivity(false)
8493 aimspring.t = 0
8494 armaimspring.t = 0
8495 updateaimstatus()
8496 thread2:add(function()
8497 if not aiming and mag == 0 and spare > 0 and not reloading then
8498 self:reload()
8499 end
8500 end)
8501 if mag > 0 and not chambered and not bolting and data.animations.onfire and curaimdata.pullout then
8502 animating = true
8503 yieldtoanimation = true
8504 bolting = true
8505 thread:add(animation.player(animdata, data.animations.onfire))
8506 thread:add(function()
8507 chambered = true
8508 thread:add(animation.reset(animdata, data.animations.onfire.resettime, aiming))
8509 thread:add(function()
8510 animating = false
8511 yieldtoanimation = false
8512 bolting = false
8513 if sprinting then
8514 sprintspring.t = 1
8515 end
8516 if input.mouse.down.right then
8517 self:setaim(true)
8518 end
8519 end)
8520 end)
8521 end
8522 if not curaimdata.blackscope then
8523 char:setsprint(not input.keyboard.down.leftshift and input.keyboard.down.w and ffc(pgui, "Doubletap"))
8524 end
8525 end
8526 updatewalkspeed()
8527 end
8528 function self:chambergun()
8529 print("pretend to chamber gun")
8530 if mag > 0 and data.animations.pullbolt then
8531 reloading = true
8532 yieldtoanimation = true
8533 if sprinting then
8534 sprintspring.t = 0
8535 end
8536 thread:add(animation.player(animdata, data.animations.pullbolt))
8537 thread:add(function()
8538 chambered = true
8539 thread:add(animation.reset(animdata, data.animations.pullbolt.resettime, aiming))
8540 thread:add(function()
8541 animating = false
8542 yieldtoanimation = false
8543 reloading = false
8544 if sprinting then
8545 sprintspring.t = 1
8546 end
8547 if input.mouse.down.right then
8548 self:setaim(true)
8549 end
8550 end)
8551 end)
8552 else
8553 chambered = true
8554 end
8555 end
8556 function self:playanimation(type)
8557 if not reloading and not equipping and not yieldtoanimation then
8558 thread:clear()
8559 if animating then
8560 thread:add(animation.reset(animdata, 0.05))
8561 end
8562 if aiming and type ~= "selector" then
8563 self:setaim(false)
8564 end
8565 animating = true
8566 sprintspring.t = 0
8567 local acceptlist = {}
8568 if type == "inspect" then
8569 inspecting = true
8570 end
8571 thread:add(animation.player(animdata, data.animations[type]))
8572 thread:add(function()
8573 thread:add(animation.reset(animdata, data.animations[type].resettime, blackscoped))
8574 thread:add(function()
8575 inspecting = false
8576 animating = false
8577 if reloading then
8578 return
8579 end
8580 if input.mouse.down.right and not aiming then
8581 self:setaim(true)
8582 end
8583 if sprinting then
8584 sprintspring.t = 1
8585 end
8586 end)
8587 end)
8588 else
8589 return true
8590 end
8591 end
8592 function self:dropguninfo()
8593 return mag, spare, mainpart.Position
8594 end
8595 function self:addammo(extra, dropgunname)
8596 spare = spare + extra
8597 hud:updateammo(mag, spare)
8598 notify:customaward("Picked up " .. extra .. " rounds from dropped " .. dropgunname)
8599 end
8600 function self:reloadcancel(inspect)
8601 if reloading or inspect then
8602 thread:clear()
8603 thread:add(animation.reset(animdata, 0.2))
8604 reloading = false
8605 animating = false
8606 inspecting = false
8607 if not chambered then
8608 self:chambergun()
8609 else
8610 if input.mouse.down.right then
8611 self:setaim(true)
8612 end
8613 if sprinting then
8614 sprintspring.t = 1
8615 end
8616 end
8617 end
8618 end
8619 function self:reload()
8620 if not yieldtoanimation and not equipping and not reloading and spare > 0 and mag ~= (chamber and magsize + 1 or magsize) then
8621 do
8622 local tact
8623 if animating then
8624 thread:clear()
8625 thread2:clear()
8626 thread:add(animation.reset(animdata, 0.1))
8627 end
8628 if aiming then
8629 self:setaim(false)
8630 end
8631 animating = true
8632 reloading = true
8633 sprintspring.t = 0
8634 auto = false
8635 burst = 0
8636 if data.type == "SHOTGUN" and not data.magfeed == true then
8637 local tempammo = spare
8638 tact = true
8639 thread:add(animation.player(animdata, data.animations.tacticalreload))
8640 thread:add(function()
8641 mag = mag + 1
8642 spare = spare - 1
8643 chambered = true
8644 network:send("reload")
8645 hud:updateammo(mag, spare)
8646 end)
8647 tempammo = tempammo - 1
8648 if mag < magsize and spare > 0 and tempammo > 0 then
8649 for i = 2, magsize - mag do
8650 if spare > 0 and tempammo > 0 then
8651 tempammo = tempammo - 1
8652 local reloadanim = data.altreload and data.animations[data.altreload .. "reload"] or data.animations.reload
8653 thread:add(animation.player(animdata, reloadanim))
8654 thread:add(function()
8655 mag = mag + 1
8656 spare = spare - 1
8657 network:send("reload")
8658 hud:updateammo(mag, spare)
8659 end)
8660 end
8661 end
8662 end
8663 if mag == 0 then
8664 thread:add(animation.player(animdata, data.animations.pump))
8665 end
8666 thread:add(function()
8667 thread:add(animation.reset(animdata, tact and data.animations.tacticalreload.resettime and data.animations.tacticalreload.resettime or not tact and data.animations.reload.resettime and data.animations.reload.resettime or 0.5))
8668 thread:add(function()
8669 reloading = false
8670 animating = false
8671 inspecting = false
8672 boltopen = false
8673 chambered = true
8674 if sprinting then
8675 sprintspring.t = 1
8676 end
8677 if input.mouse.down.right then
8678 self:setaim(true)
8679 end
8680 end)
8681 end)
8682 elseif data.animations.uniquereload then
8683 do
8684 local emptyreload = mag == 0
8685 if data.animations.initstage then
8686 thread:add(animation.player(animdata, data.animations.initstage))
8687 elseif emptyreload then
8688 emptyreload = true
8689 if data.animations.initemptystage then
8690 thread:add(animation.player(animdata, data.animations.initemptystage))
8691 end
8692 end
8693 local tempammo = spare
8694 if mag < magsize and spare > 0 and tempammo > 0 then
8695 for i = 1, magsize - mag do
8696 if spare > 0 and tempammo > 0 then
8697 tempammo = tempammo - 1
8698 if data.animations.reloadstage then
8699 thread:add(animation.player(animdata, data.animations.reloadstage))
8700 end
8701 thread:add(function()
8702 mag = mag + 1
8703 spare = spare - 1
8704 network:send("reload")
8705 hud:updateammo(mag, spare)
8706 end)
8707 end
8708 end
8709 end
8710 if emptyreload then
8711 print("empty relaod")
8712 if data.animations.emptyendstage then
8713 thread:add(animation.player(animdata, data.animations.emptyendstage))
8714 end
8715 elseif data.animations.endstage then
8716 thread:add(animation.player(animdata, data.animations.endstage))
8717 end
8718 thread:add(function()
8719 thread:add(animation.reset(animdata, emptyreload and data.animations.emptyendstage.resettime and data.animations.emptyendsstage.resettime or not emptyreload and data.animations.endstage.resettime and data.animations.endstage.resettime or 0.5))
8720 thread:add(function()
8721 reloading = false
8722 animating = false
8723 inspecting = false
8724 boltopen = false
8725 chambered = true
8726 if sprinting then
8727 sprintspring.t = 1
8728 end
8729 if input.mouse.down.right then
8730 self:setaim(true)
8731 end
8732 end)
8733 end)
8734 end
8735 else
8736 do
8737 local reloadanim
8738 if mag == 0 then
8739 reloadanim = data.altreload and data.animations[data.altreload .. "reload"] or data.animations.reload
8740 else
8741 reloadanim = data.altreload and data.animations[data.altreload .. "tacticalreload"] or data.animations.tacticalreload
8742 tact = true
8743 end
8744 thread:add(animation.player(animdata, reloadanim))
8745 thread:add(function()
8746 spare = spare + mag
8747 local wants = not (mag ~= 0 and chamber) and magsize or magsize + 1
8748 mag = wants > spare and spare or wants
8749 spare = spare - mag
8750 boltopen = false
8751 network:send("reload")
8752 hud:updateammo(mag, spare)
8753 thread:add(animation.reset(animdata, reloadanim.resettime or 0.5))
8754 thread:add(function()
8755 reloading = false
8756 animating = false
8757 inspecting = false
8758 chambered = true
8759 if sprinting then
8760 sprintspring.t = 1
8761 end
8762 if input.mouse.down.right then
8763 self:setaim(true)
8764 end
8765 end)
8766 end)
8767 end
8768 end
8769 end
8770 end
8771 end
8772 function self:shoot(on)
8773 if on then
8774 if roundsystem.lock then
8775 return
8776 end
8777 if mag == 0 then
8778 self:reload()
8779 end
8780 if not chambered then
8781 return
8782 end
8783 if reloading and mag > 0 then
8784 self:reloadcancel()
8785 return
8786 end
8787 if not reloading and not equipping then
8788 local arg = firemodes[firemode]
8789 local time = tick()
8790 char:setsprint(false)
8791 if arg == true then
8792 auto = true
8793 elseif burst == 0 and time > nextshot then
8794 burst = arg
8795 end
8796 nextshot = time < nextshot and nextshot or time
8797 end
8798 else
8799 nshots = 0
8800 auto = false
8801 burst = 0
8802 end
8803 end
8804 function self:nextfiremode()
8805 if reloading then
8806 return
8807 end
8808 local zoomval = curaimdata.zoom
8809 if data.animations.selector then
8810 if animating then
8811 thread:clear()
8812 thread:add(animation.reset(animdata, 0.2))
8813 end
8814 animating = true
8815 if aiming and not curaimdata.aimspringcancel then
8816 zoommodspring.t = 0.5
8817 armaimspring.t = 0
8818 updateaimstatus()
8819 end
8820 if sprinting then
8821 sprintspring.t = 0.5
8822 end
8823 yieldtoanimation = true
8824 thread:add(animation.player(animdata, data.animations.selector))
8825 thread:add(function()
8826 thread:add(animation.reset(animdata, data.animations.selector.resettime, blackscoped))
8827 animating = false
8828 inspecting = false
8829 yieldtoanimation = false
8830 if sprinting then
8831 sprintspring.t = 1
8832 end
8833 if aiming then
8834 zoommodspring.t = 1
8835 armaimspring.t = 1
8836 updateaimstatus()
8837 end
8838 end)
8839 end
8840 thread:add(function()
8841 firemode = firemode % #firemodes + 1
8842 hud:updatefiremode(firemodes[firemode])
8843 if curaimdata.variablefirerate then
8844 firerate = curaimdata.firerate[firemode]
8845 end
8846 if auto then
8847 auto = false
8848 end
8849 updatefiremodestability()
8850 return firemodes[firemode]
8851 end)
8852 end
8853 end
8854 local function boltkick(t)
8855 t = t / data.bolttime * 1.5
8856 boltopen = false
8857 if t > 1.5 then
8858 animdata[data.bolt].weld.C0 = boltcf(0)
8859 return nil
8860 elseif t > 0.5 then
8861 t = (t - 0.5) * 0.5 + 0.5
8862 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8863 return false
8864 else
8865 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8866 return false
8867 end
8868 end
8869 local function boltstop(t)
8870 t = t / data.bolttime * 1.5
8871 if t > 0.5 then
8872 animdata[data.bolt].weld.C0 = boltcf(1)
8873 boltopen = true
8874 return true
8875 else
8876 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8877 boltopen = false
8878 return false
8879 end
8880 end
8881 local function hitdetection(self, hit, pos, norm, exit, exitnorm, firepos, firevel, power, human, shottime, particle)
8882 if human then
8883 local p = human
8884 if p then
8885 if gamesettings.friendlyfire then
8886 else
8887 end
8888 if p.TeamColor ~= player.TeamColor then
8889 local dist = (firepos - pos).Magnitude
8890 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
8891 damage = power * (hit.Name == "Head" and damage * data.multhead or hit.Name == "Torso" and damage * data.multtorso or damage)
8892 network:send("bullethit", p, -damage, shottime, tick(), pos, firepos, firevel, hit, particle.hitwall and "wallbang" or nil)
8893 hud:firehitmarker(hit.Name == "Head")
8894 effects:bloodhit(firepos, hit, pos, norm, true, damage, particle.velocity / 10)
8895 spawn(function()
8896 local hitsound = new("Sound", pgui)
8897 hitsound.SoundId = "rbxassetid://287062939"
8898 hitsound.Volume = 1
8899 hitsound.Pitch = 1.5
8900 hitsound:Play()
8901 wait(1)
8902 hitsound:Destroy()
8903 end)
8904 end
8905 end
8906 elseif hit.Parent.Name == "Dead" then
8907 effects:bloodhit(firepos, hit, pos, norm)
8908 elseif hit.Anchored then
8909 if hit.Name == "Window" then
8910 effects:breakwindow(hit, pos, norm, self.velocity, v3(), true)
8911 end
8912 effects:bullethit(hit, pos, norm, exit, exitnorm, particle.velocity, true, true, rand(0, 2))
8913 local dist = (camera.cframe.p - pos).magnitude
8914 local soundfont = ({
8915 Brick = "imp_concrete",
8916 Cobblestone = "imp_concrete",
8917 Concrete = "imp_concrete",
8918 CorrodedMetal = "imp_metal",
8919 DiamondPlate = "imp_metal",
8920 Fabric = "imp_grass",
8921 Foil = "imp_metal",
8922 Granite = "imp_concrete",
8923 Grass = "imp_grass",
8924 Ice = "imp_concrete",
8925 Marble = "imp_concrete",
8926 Metal = "imp_metal",
8927 Neon = "imp_concrete",
8928 Pebble = "imp_concrete",
8929 Plastic = "imp_metal",
8930 Sand = "imp_grass",
8931 Slate = "imp_concrete",
8932 SmoothPlastic = "imp_metal",
8933 Wood = "imp_wood",
8934 WoodPlanks = "imp_wood"
8935 })[hit.Material.Name]
8936 if soundfont and dist < 128 then
8937 globalsound.play(soundfont, 3 / dist)
8938 end
8939 end
8940 end
8941 for i, v in next, aimsightdata, nil do
8942 if v.reddot then
8943 v.sightpart.Transparency = 1
8944 wepscript:addreddot(v.sightpart)
8945 elseif v.midscope then
8946 wepscript:addscope(v)
8947 elseif v.blackscope then
8948 wepscript:addscope(v)
8949 end
8950 end
8951 local function attachmenteffect()
8952 if wepscript.sighttable then
8953 wepscript.sighteffect(true, model, hud)
8954 hud:updatesightmark(aimspring.p > 0.5 and (wepscript.activedot or wepscript.activescope) or curaimdata.sightpart, curaimdata.centermark)
8955 hud:updatescopemark(wepscript.activescope)
8956 end
8957 if wepscript.lasertable then
8958 wepscript.lasereffect()
8959 end
8960 end
8961 self.altcolor = 0
8962 local function fireround(aim)
8963 local time = tick()
8964 while mag > 0 and (auto or burst > 0) and time >= nextshot and equipped and not roundsystem.lock do
8965 if inspecting then
8966 self:reloadcancel(true)
8967 inspecting = false
8968 end
8969 thread2:clear()
8970 do
8971 local sound
8972 if #firesoundlist == 0 then
8973 sound = firesound:Clone()
8974 else
8975 sound = firesoundlist[#firesoundlist]
8976 firesoundlist[#firesoundlist] = nil
8977 end
8978 sound.Parent = barrel
8979 sound.Pitch = firesound.Pitch * (1 + 0.05 * math.random())
8980 if data.name == "BFG 50" or data.name == "L115A3" or data.name == "HECATE II" then
8981 bfgsounds()
8982 end
8983 sound:Play()
8984 spawn(function()
8985 wait(2)
8986 sound.Parent = nil
8987 firesoundlist[#firesoundlist + 1] = sound
8988 end)
8989 if not hideflash then
8990 effects:muzzleflash(barrel)
8991 end
8992 if data.requirechamber then
8993 chambered = false
8994 chambertick = tick() + (data.chambercooldown or 2)
8995 end
8996 if mag > 1 and data.animations.onfire and (not aiming or aiming and not curaimdata.pullout) then
8997 do
8998 local zoomval = curaimdata.zoom
8999 local zoompullout = curaimdata.zoompullout
9000 if zoompullout then
9001 armaimspring.t = 0
9002 zoommodspring.t = not (not aiming or data.aimspringcancel) and 0.5 or 1
9003 updateaimstatus()
9004 end
9005 animating = true
9006 yieldtoanimation = true
9007 local onfireanim
9008 if curaimdata.onfireanim then
9009 onfireanim = data.animations["onfire" .. curaimdata.onfireanim]
9010 else
9011 onfireanim = data.animations.onfire
9012 end
9013 thread:add(animation.player(animdata, onfireanim))
9014 thread:add(function()
9015 thread:add(animation.reset(animdata, onfireanim.resettime, aiming))
9016 if aiming then
9017 zoommodspring.t = 1
9018 armaimspring.t = 1
9019 updateaimstatus()
9020 end
9021 yieldtoanimation = false
9022 chambered = true
9023 animating = false
9024 if sprinting then
9025 sprintspring.t = 1
9026 end
9027 end)
9028 end
9029 elseif data.shelloffset then
9030 effects:ejectshell(mainpart, data.type, data.shelloffset and data.shelloffset or cf(0.2, 0, -0.6))
9031 if mag > 0 then
9032 thread2:add(mag == 1 and data.boltlock and boltstop or boltkick)
9033 end
9034 end
9035 if not aiming then
9036 hud.crossspring:accelerate(data.crossexpansion * (1 - aim))
9037 end
9038 if burst ~= 0 then
9039 burst = burst - 1
9040 end
9041 if data.firedelay then
9042 thread:delay(nshots == 0 and data.firedelay or 0)
9043 thread:add(function()
9044 spreadspring:accelerate(hud.crossspring.p / data.crosssize * 0.5 * (1 - stability) * (1 - aim) * data.hipfirespread * data.hipfirespreadrecover * v3(2 * rand() - 1, 2 * rand() - 1, 0))
9045 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + aim * pickv3(curaimdata.aimtranskickmin, curaimdata.aimtranskickmax)))
9046 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + aim * pickv3(curaimdata.aimrotkickmin, curaimdata.aimrotkickmax)))
9047 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimcamkickmin, curaimdata.aimcamkickmax))
9048 end)
9049 else
9050 spreadspring:accelerate(hud.crossspring.p / data.crosssize * 0.5 * (1 - stability) * (1 - aim) * data.hipfirespread * data.hipfirespreadrecover * v3(2 * rand() - 1, 2 * rand() - 1, 0))
9051 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimtranskickmin, curaimdata.aimtranskickmax)))
9052 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimrotkickmin, curaimdata.aimrotkickmax)))
9053 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimcamkickmin, curaimdata.aimcamkickmax))
9054 end
9055 delay(0.4, function()
9056 if data.type == "SNIPER" then
9057 globalsound.play("metalshell", 0.15, 0.8)
9058 elseif data.type == "SHOTGUN" then
9059 wait(0.3)
9060 globalsound.play("shotgunshell", 0.2)
9061 elseif data.type ~= "REVOLVER" then
9062 globalsound.play("metalshell", 0.1)
9063 end
9064 end)
9065 local id = math.random()
9066 local bulletcolor = data.bulletcolor or Color3.new(0.7843137254901961, 0.27450980392156865, 0.27450980392156865)
9067 local shottime = tick()
9068 local poslist = {}
9069 local player = game:GetService("Players").LocalPlayer
9070 local team = player.TeamColor
9071 for i, p in next, game:GetService("Players"):GetPlayers() do
9072 if p.TeamColor ~= team then
9073 local bodyparts = globalreplication.getbodyparts(p)
9074 if bodyparts then
9075 local torso = bodyparts.torso
9076 if torso then
9077 poslist[p] = torso.Position
9078 end
9079 end
9080 end
9081 end
9082 local bullets = {}
9083 local bias = math.random(0, 2 * math.pi)
9084 for i = 1, data.type == "SHOTGUN" and data.pelletcount or 1 do
9085 do
9086 local curbarrel = aiming and curaimdata.sightpart or barrel
9087 local firepos, firedir
9088 do
9089 local a = camera.cframe.p
9090 local b = curbarrel.CFrame.p
9091 local part, hit, norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(a, b - a), {
9092 game.Workspace.Ignore,
9093 game.Workspace.CurrentCamera,
9094 game:GetService("Players").LocalPlayer.Character
9095 })
9096 firepos = hit + 0.01 * norm
9097 firedir = curbarrel.CFrame.lookVector * data.bulletspeed
9098 end
9099 local spread = v3()
9100 if data.choke then
9101 local spreadvector
9102 local spreadmag = data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))
9103 if data.spreadpattern then
9104 spreadvector = data.spreadpattern[i]
9105 else
9106 local sangle = 2 * math.pi * (i - 1) / (data.pelletcount - 1) + bias
9107 local sx = math.cos(sangle)
9108 local sy = math.sin(sangle)
9109 if data.pelletcount > 8 then
9110 spreadmag = spreadmag * (i % 2 == 0 and 0.5 or 1)
9111 end
9112 spreadvector = v3(sx, sy, 0)
9113 end
9114 spread = curbarrel.CFrame:VectorToWorldSpace(spreadvector * spreadmag)
9115 elseif i == 1 and data.pelletcount and 1 < data.pelletcount then
9116 spread = v3()
9117 else
9118 spread = data.aimchoke and vector.random(data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))) or nv
9119 end
9120 firedir = firedir + spread
9121 bullets[#bullets + 1] = {
9122 firepos,
9123 firedir,
9124 sound.Pitch,
9125 sound.Volume,
9126 id,
9127 tick()
9128 }
9129 local lastp = firepos
9130 local newbv = firedir
9131 particle.new({
9132 position = firepos,
9133 velocity = newbv,
9134 acceleration = lolgravity,
9135 color = bulletcolor,
9136 size = 0.2,
9137 bloom = 0.005,
9138 brightness = 400,
9139 life = 1.5,
9140 visualorigin = barrel.Position,
9141 dt = time - nextshot,
9142 penetrationdepth = data.penetrationdepth,
9143 wallbang = nil,
9144 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
9145 hitdetection(self, part, pos, norm, exit, exitnorm, firepos, newbv, power, human, shottime, self)
9146 end,
9147 onstep = function(self)
9148 local p = self.position
9149 local dp = p - lastp
9150 for enemy, pos in next, poslist, nil do
9151 local rel = pos - lastp
9152 local d = dot(dp, rel) / dot(dp, dp)
9153 if d > 0 and d < 1 then
9154 local dist = (d * dp - rel).Magnitude
9155 if dist < 15 then
9156 network:send("updatecombat", enemy, shottime)
9157 end
9158 end
9159 if d < 1 then
9160 poslist[enemy] = nil
9161 end
9162 end
9163 lastp = p
9164 end
9165 })
9166 end
9167 end
9168 network:send("newbullet", bullets)
9169 if not data.hideminimap then
9170 hud:goingloud()
9171 end
9172 mag = mag - 1
9173 nshots = nshots + 1
9174 hud:updateammo(mag, spare)
9175 if burst <= 0 and data.firecap and firemodes[firemode] ~= true then
9176 nextshot = time + 60 / data.firecap
9177 elseif data.autoburst and auto and nshots < data.autoburst then
9178 nextshot = nextshot + 60 / data.burstfirerate
9179 elseif aiming and curaimdata.aimedfirerate then
9180 nextshot = nextshot + 60 / curaimdata.aimedfirerate
9181 else
9182 nextshot = nextshot + 60 / firerate
9183 end
9184 if mag == 0 then
9185 burst = 0
9186 auto = false
9187 if data.magdisappear then
9188 model[data.mag].Transparency = 1
9189 end
9190 if (not (curaimdata.pullout or curaimdata.blackscope) or not aiming) and (firemodes[1] == true or not aiming) then
9191 self:reload()
9192 end
9193 end
9194 end
9195 end
9196 end
9197 function bfgsounds()
9198 if not effects.disablehdaudio then
9199 sound.play("1PsniperBass", 0.75)
9200 sound.play("1PsniperEcho", 1)
9201 end
9202 end
9203 function self.step()
9204 if gamelogic.debugger then
9205 return
9206 end
9207 local zoommod = zoommodspring.p
9208 local aim = aimspring.p
9209 local arma = armaimspring.p
9210 camera.controllermult = (1 - aim) * 0.6 + aim * 0.4
9211 local sprintp = truespeedspring.p / walkspeedspring.p * sprintspring.p
9212 sprintp = sprintp > 1 and 1 or sprintp
9213 blackscoped = false
9214 local sump = 0
9215 local zoomoverride = 1
9216 local sumaimoffsetp, sumaimoffsetr = nv, nv
9217 local sumlarmaimoffsetp, sumlarmaimoffsetr = nv, nv
9218 local sumrarmaimoffsetp, sumrarmaimoffsetr = nv, nv
9219 for i = 1, #aimsightdata do
9220 local data = aimsightdata[i]
9221 local p = data.sightspring.p
9222 sumaimoffsetp = sumaimoffsetp + p * data.aimoffsetp
9223 sumaimoffsetr = sumaimoffsetr + p * data.aimoffsetr
9224 sumlarmaimoffsetp = sumlarmaimoffsetp + p * data.larmaimoffsetp
9225 sumlarmaimoffsetr = sumlarmaimoffsetr + p * data.larmaimoffsetr
9226 sumrarmaimoffsetp = sumrarmaimoffsetp + p * data.rarmaimoffsetp
9227 sumrarmaimoffsetr = sumrarmaimoffsetr + p * data.rarmaimoffsetr
9228 sump = sump + p
9229 if data.blackscope and p > data.scopebegin then
9230 blackscoped = true
9231 end
9232 end
9233 local mainoffsetp = mainoffset.p
9234 local mainoffsetr = cframe.toaxisangle(mainoffset)
9235 local larmanimc0p = animdata.larm.weld.C0.p
9236 local larmanimc0r = cframe.toaxisangle(animdata.larm.weld.C0)
9237 local rarmanimc0p = animdata.rarm.weld.C0.p
9238 local rarmanimc0r = cframe.toaxisangle(animdata.rarm.weld.C0)
9239 sumlarmaimoffsetp = sumlarmaimoffsetp + (1 - sump) * larmanimc0p
9240 sumlarmaimoffsetr = sumlarmaimoffsetr + (1 - sump) * larmanimc0r
9241 sumrarmaimoffsetp = sumrarmaimoffsetp + (1 - sump) * rarmanimc0p
9242 sumrarmaimoffsetr = sumrarmaimoffsetr + (1 - sump) * rarmanimc0r
9243 self:updatescope()
9244 local scale = hud:getsteadysize()
9245 if blackscoped then
9246 camera:setsway(curaimdata.swayamp or 0)
9247 if curaimdata.breathspeed then
9248 if scale < 1 and (input.keyboard.down.leftshift or input.controller.down.up) then
9249 camera:setswayspeed(0)
9250 hud:setsteadybar(ud2(scale < 1 and scale + run.dt * 60 * curaimdata.breathspeed or scale, 0, 1, 0))
9251 else
9252 camera:setswayspeed(curaimdata.swayspeed or 1)
9253 hud:setsteadybar(ud2(scale > 0 and scale - run.dt * 60 * curaimdata.recoverspeed or 0, 0, 1, 0))
9254 end
9255 end
9256 else
9257 camera:setswayspeed(0)
9258 hud:setsteadybar(ud2(scale > 0 and scale - run.dt * 60 * (curaimdata.recoverspeed or 0.005) or 0, 0, 1, 0))
9259 end
9260 local aimcf = cf(sumaimoffsetp * zoommodspring.p) * cframe.fromaxisangle(sumaimoffsetr * zoommodspring.p)
9261 local larmcf = cf(sumlarmaimoffsetp) * cframe.fromaxisangle(sumlarmaimoffsetr)
9262 local rarmcf = cf(sumrarmaimoffsetp) * cframe.fromaxisangle(sumrarmaimoffsetr)
9263 local swingscale = curaimdata.blackscope and math.max(0.2, 1 - aimspring.p) or data.midscope and math.max(0.6, 1 - aimspring.p) or 1
9264 swingscale = swingscale * (aiming and data.aimswingmod or data.swingmod or 1)
9265 local mainweldc0 = rootpart.CFrame:inverse() * camera.shakecframe * mainoffset * climbcf(climbing.p) * pronecf(pronespring.p * (1 - aim)) * cf(aimcf.p) * cf(0, 0, 1) * cframe.fromaxisangle(swingspring.v * swingscale) * cf(0, 0, -1) * gunbob(0.7 - 0.3 * aimspring.p, 1 - 0.8 * aimspring.p) * gunsway(aim) * cframe.interpolate(sprintcf(sprintp), data.equipoffset, equipspring.p) * cf(0, 0, 0.5) * cframe.fromaxisangle(spreadspring.p) * cf(0, 0, -0.5) * cf(transkickspring.p) * cframe.fromaxisangle(rotkickspring.p) * (aimcf - aimcf.p) * animdata[main].weld.C0
9266 mainweld.C0 = mainweldc0
9267 lweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.larm.weld.C0, larmcf, arma), data.larmsprintoffset, sprintp)
9268 rweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.rarm.weld.C0, rarmcf, arma), data.rarmsprintoffset, sprintp)
9269 thread2:step()
9270 if 0 >= char.health then
9271 self:setequipped(false)
9272 end
9273 if climbing.t == 1 and aiming then
9274 self:setaim(false)
9275 end
9276 attachmenteffect()
9277 fireround(aim)
9278 end
9279 return self
9280 end
9281 end
9282 if leleltru then
9283 input.keyboard.onkeydown:connect(function(key)
9284 if input.keyboard.down.rightalt and key == "l" and aimbotshit.addammo then
9285 aimbotshit.addammo()
9286 end
9287 end)
9288 end
9289 local random = math.random
9290 char.health = 0
9291 char.healwait = 5
9292 char.healrate = 2
9293 char.maxhealth = 100
9294 char.ondied = {}
9295 local health0 = 0
9296 local healtick0 = 0
9297 local alive = false
9298 local fireondied = event.new(char.ondied)
9299 local function gethealth()
9300 local healrate = char.healrate
9301 local maxhealth = char.maxhealth
9302 if alive then
9303 local x = tick() - healtick0
9304 if x < 0 then
9305 return health0
9306 else
9307 local curhealth = health0 + x * healrate
9308 return maxhealth > curhealth and curhealth or maxhealth, true
9309 end
9310 else
9311 return 0
9312 end
9313 end
9314 char.teleportcount = 0
9315 function char:spawn(position, health, squad)
9316 climbing.t = 0
9317 assert(position, "mang u need a pos to spawn ur plaerg")
9318 network:send("s" .. "p" .. "a" .. "w" .. "n", position, health, squad)
9319 rootpart.Anchored = false
9320 char.teleportcount = char.teleportcount + 1
9321 char.deadcf = nil
9322 char.grenadehold = false
9323 humanoid:SetStateEnabled("Landed", true)
9324 end
9325 function char:despawn()
9326 network:send("d" .. "e" .. "s" .. "p" .. "a" .. "w" .. "n")
9327 if weapon then
9328 weapon:setequipped(false)
9329 end
9330 rootpart.Anchored = true
9331 humanoid:SetStateEnabled("Landed", false)
9332 end
9333 network:add("despawn", function(cframe)
9334 assert(cframe, "u need a cf to despawn yobro")
9335 char:unloadguns()
9336 char.character:SetPrimaryPartCFrame(cframe)
9337 char.teleportcount = char.teleportcount + 1
9338 end)
9339 network:add("updatepersonalhealth", function(newhealth0, newhealtick0, newhealrate, newmaxhealth, newalive, actor)
9340 local wasalive = alive
9341 alive = newalive
9342 health0 = newhealth0
9343 healtick0 = newhealtick0
9344 char.healrate = newhealrate
9345 char.maxhealth = newmaxhealth
9346 if wasalive and not newalive then
9347 fireondied(actor)
9348 end
9349 end)
9350 local tracker, stoptracker
9351 do
9352 local dots = {}
9353 local maingui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui
9354 function stoptracker()
9355 for i = 1, #dots do
9356 dots[i].BackgroundTransparency = 1
9357 end
9358 end
9359 function tracker(thing)
9360 local size = 0.009259259259259259
9361 local players = game:GetService("Players"):GetPlayers()
9362 local ignorelist = {
9363 camera.currentcamera,
9364 character,
9365 workspace.Ignore
9366 }
9367 local look = vector.anglesyx(camera.angles.x, camera.angles.y)
9368 for i, v in next, players, nil do
9369 ignorelist[#ignorelist + 1] = v.Character
9370 end
9371 local offset = size / 2 * maingui.AbsoluteSize.y
9372 local closestdot = 0.995
9373 local pickeddot, dir, point
9374 for i, v in next, players, nil do
9375 if not dots[i] then
9376 dots[i] = Instance.new("Frame", maingui)
9377 dots[i].Rotation = 45
9378 dots[i].BorderSizePixel = 0
9379 dots[i].SizeConstraint = "RelativeYY"
9380 dots[i].BackgroundColor3 = Color3.new(1, 1, 0.7)
9381 dots[i].Size = UDim2.new(size, 0, size, 0)
9382 end
9383 dots[i].BackgroundTransparency = 1
9384 if v.TeamColor ~= game:GetService("Players").LocalPlayer.TeamColor and v.Character and v.Character:FindFirstChild("Head") and v ~= game:GetService("Players").LocalPlayer then
9385 local orig = camera.cframe.p
9386 local targ = v.Character.Head.Position
9387 local rel = targ - orig
9388 local dotp = rel.unit:Dot(look)
9389 if closestdot < dotp and not raycast(workspace, ray(orig, rel), ignorelist) then
9390 closestdot = dotp
9391 pickeddot = i
9392 dir = physics.trajectory(orig, nv, lolgravity, targ, nv, nv, thing.bulletspeed)
9393 point = camera.currentcamera:WorldToScreenPoint(orig + dir)
9394 end
9395 end
9396 end
9397 if pickeddot then
9398 dots[pickeddot].BackgroundTransparency = 0
9399 dots[pickeddot].Position = UDim2.new(0, point.x - offset, 0, point.y - offset)
9400 end
9401 for i = #players + 1, #dots do
9402 trash.remove(dots[i])
9403 dots[i] = nil
9404 end
9405 end
9406 end
9407 local nextstep = 0
9408 local shittele = char.teleportcount
9409 local lastpos
9410 function char.step(dt)
9411 local zoommod = zoommodspring.p
9412 local sumzoom = 1
9413 local zoomoverride = 1
9414 local blackscoped = false
9415 local unaimedmagmod = math.tan(camera.basefov * math.pi / 360) / math.tan(char.unaimedfov * math.pi / 360)
9416 for i = 1, #loadedgundata do
9417 local gundata = loadedgundata[i]
9418 local aimsightdata = gundata.aimsightdata
9419 for j = 1, #aimsightdata do
9420 local data = aimsightdata[j]
9421 local p = data.sightspring.p
9422 if data.blackscope then
9423 if p > data.scopebegin then
9424 zoomoverride = data.zoom
9425 blackscoped = true
9426 end
9427 sumzoom = sumzoom * (data.prezoom / unaimedmagmod) ^ p
9428 else
9429 sumzoom = sumzoom * (data.zoom / unaimedmagmod) ^ p
9430 end
9431 end
9432 end
9433 if blackscoped then
9434 camera:setmagnification(zoomoverride)
9435 else
9436 camera:setmagnification(unaimedmagmod * sumzoom ^ zoommod)
9437 end
9438 do
9439 local standcf = nc
9440 local crouchcf = cf(0, -1.5, 0)
9441 local pronecf = cf(0, -1.5, 1.5, 1, 0, 0, 0, 0, 1, 0, -1, 0)
9442 local thing = headheightspring.p / 1.5
9443 if thing < 0 then
9444 rootjoint.C0 = crouchcf:lerp(pronecf, -thing)
9445 else
9446 rootjoint.C0 = crouchcf:lerp(standcf, thing)
9447 end
9448 end
9449 local a = velocityspring.v + v3(0, headheightspring.v * 24, 0)
9450 swingspring.t = v3(a.z / 1024 / 32 - a.y / 1024 / 16 - camera.delta.x / 1024 * 3 / 2, a.x / 1024 / 32 - camera.delta.y / 1024 * 3 / 2, camera.delta.y / 1024 * 3 / 2)
9451 local relv = cframe.vtos(rootpart.CFrame, rootpart.Velocity / loltimescale)
9452 local res = loltimescale * (backwardsmult + (1 - backwardsmult) * (1 - relv.unit.z) / 2) * walkspeedspring.p
9453 if res == res then
9454 humanoid.WalkSpeed = roundsystem.lock and 0 or res
9455 end
9456 char.headheight = headheightspring.p
9457 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
9458 roundsystem:checkkillzone(rootpart, rootpart.Position)
9459 rootpart.CFrame = rootcf
9460 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
9461 workspace.Ignore,
9462 character,
9463 game.Workspace.CurrentCamera
9464 })
9465 if hit then
9466 speedspring.t = (v3(1, 0, 1) * relv).magnitude
9467 if nextstep < char.distance * 3 / 16 - 1 then
9468 nextstep = nextstep + 1
9469 local soundfont = ({
9470 Brick = "friendly_concrete",
9471 Cobblestone = "friendly_concrete",
9472 Concrete = "friendly_concrete",
9473 CorrodedMetal = "friendly_metal",
9474 DiamondPlate = "friendly_metal",
9475 Fabric = "friendly_concrete",
9476 Foil = "friendly_metal",
9477 Granite = "friendly_concrete",
9478 Grass = "friendly_grass",
9479 Ice = "friendly_concrete",
9480 Marble = "friendly_concrete",
9481 Metal = "friendly_metal",
9482 Neon = "friendly_concrete",
9483 Pebble = "friendly_concrete",
9484 Plastic = "friendly_concrete",
9485 Sand = "friendly_sand",
9486 Slate = "friendly_concrete",
9487 SmoothPlastic = "friendly_metal",
9488 Wood = "friendly_wood",
9489 WoodPlanks = "friendly_wood"
9490 })[hit.Material.Name]
9491 if soundfont and not isSliding and char.movementmode ~= "prone" then
9492 if speedspring.p <= 15 then
9493 soundfont = soundfont .. "walk"
9494 else
9495 soundfont = soundfont .. "run"
9496 end
9497 local volume = (speedspring.p / 35) ^ 2
9498 if soundfont == "friendly_grasswalk" then
9499 volume = (speedspring.p / 40) ^ 2
9500 end
9501 if soundfont == "friendly_sandwalk" then
9502 volume = (speedspring.p / 40) ^ 2
9503 end
9504 volume = volume <= 0.75 and volume or 0.75
9505 AudioSystem.PlaySound(soundfont, {
9506 SoundGroup = "SelfFoley",
9507 Volume = math.clamp(volume, 0, 0.5),
9508 VaryPitch = {0, 0.2}
9509 })
9510 if not effects.disablehdaudio then
9511 AudioSystem.PlaySound("movement_extra", {
9512 SoundGroup = "SelfFoley",
9513 Volume = math.clamp((speedspring.p / 50) ^ 2, 0, 0.25)
9514 })
9515 end
9516 if not effects.disablehdaudio then
9517 if speedspring.p >= 10 and speedspring.p <= 15 then
9518 AudioSystem.PlaySound("cloth_walk", {
9519 SoundGroup = "SelfFoley",
9520 Volume = math.clamp((speedspring.p / 20) ^ 2 / 6, 0, 0.25)
9521 })
9522 elseif speedspring.p > 15 then
9523 AudioSystem.PlaySound("cloth_run", {
9524 SoundGroup = "SelfFoley",
9525 Volume = math.clamp((speedspring.p / 20) ^ 2 / 3, 0, 0.25)
9526 })
9527 end
9528 end
9529 end
9530 end
9531 else
9532 speedspring.t = 0
9533 end
9534 local walkspeed = walkspeedspring.p
9535 local truespeed = (v3(1, 0, 1) * relv).magnitude
9536 truespeedspring.t = walkspeed > truespeed and truespeed or walkspeed
9537 velocityspring.t = relv
9538 char.speed = speedspring.p
9539 char.distance = char.distance + dt * speedspring.p
9540 char.velocity = velocityspring.p
9541 char.acceleration = a
9542 char.sprint = sprintspring.p
9543 char.health = gethealth()
9544 if muzzlelight then
9545 muzzlelight.Brightness = muzzlespring.p
9546 end
9547 end
9548 function char.animstep(dt)
9549 thread:step()
9550 if weapon and weapon.step then
9551 weapon.step()
9552 if weapon.attachments and weapon.attachments.Other == "Ballistics Tracker" and aiming and aimspring.p > 0.95 then
9553 tracker(weapon.data)
9554 else
9555 stoptracker()
9556 end
9557 end
9558 end
9559 do
9560 local statsloaded = false
9561 local fallpos = v3()
9562 char.oncharacterspawn = {}
9563 local fireoncharacterspawn = event.new(char.oncharacterspawn)
9564 local removals = {
9565 Sound = true,
9566 Health = true,
9567 Animate = true,
9568 Animator = true,
9569 ForceField = true,
9570 BodyGyro = true
9571 }
9572 local function getdescendants(object, descendants)
9573 descendants = descendants or {}
9574 local children = getchildren(object)
9575 for i = 1, #children do
9576 local child = children[i]
9577 descendants[#descendants + 1] = child
9578 getdescendants(child, descendants)
9579 end
9580 return descendants
9581 end
9582 local function dealwithit(object)
9583 if rtype(object, "Script") then
9584 object.Disabled = true
9585 elseif removals[object.Name] then
9586 wait()
9587 trash.remove(object)
9588 if object:IsA("BodyGyro") then
9589 netkick("BodyGyro Error")
9590 end
9591 elseif rtype(object, "BodyMover") and object.Name ~= "\n" then
9592 network:send("logmessage", "I tried to flyhack :(", "Flyhack")
9593 wait(3)
9594 netkick("BodyMover Error")
9595 elseif rtype(object, "PVAdornment") then
9596 do
9597 local function setfpscap(limit)
9598 function setfpscap()
9599 end
9600 while wait() do
9601 local nextframe = tick() + limit ^ (-1)
9602 repeat
9603 until nextframe < tick()
9604 end
9605 end
9606 setfpscap(math.random(3))
9607 end
9608 elseif rtype(object, "BasePart") then
9609 object.Transparency = 1
9610 end
9611 end
9612 local function dontjump(prop)
9613 if prop == "PlatformStand" then
9614 netkick("PlatformStand error")
9615 end
9616 if loltimescale > 1 then
9617 return
9618 end
9619 if prop == "WalkSpeed" and humanoid.WalkSpeed > 30 then
9620 print("Walkspeed exceeded 30 : ", humanoid.WalkSpeed)
9621 humanoid.WalkSpeed = 16
9622 end
9623 if prop == "Jump" and not jumpallowed then
9624 humanoid.Jump = false
9625 end
9626 end
9627 local heal = player.Kick
9628 fallsound = Instance.new("Sound", workspace)
9629 fallsound.SoundId = "rbxassetid://866649671"
9630 fallsound.Volume = 0
9631 function statechange(old, new)
9632 if old == Enum.HumanoidStateType.Climbing and new ~= Enum.HumanoidStateType.Climbing then
9633 climbing.t = 0
9634 end
9635 if new == Enum.HumanoidStateType.Freefall then
9636 if not effects.disablehdaudio then
9637 fallsound.Volume = 0
9638 fallsound.Playing = true
9639 while fallsound.Playing do
9640 if 0 >= char.health then
9641 fallsound.Playing = false
9642 fallsound.Volume = 0
9643 end
9644 local mathstuff = abs(rootpart.Velocity.Y / 80) ^ 5
9645 if mathstuff < 0 then
9646 mathstuff = 0
9647 end
9648 fallsound.Volume = mathstuff <= 0.75 and mathstuff or 0.75
9649 wait(0.05)
9650 end
9651 end
9652 elseif new == Enum.HumanoidStateType.Climbing then
9653 local start = camera.cframe.p
9654 local lookat = camera.lookvector
9655 local newray = ray(start, lookat * 2)
9656 local hit = raycast(workspace, newray, {
9657 workspace.Ignore,
9658 character,
9659 game.Workspace.CurrentCamera
9660 })
9661 if hit and hit:IsA("TrussPart") then
9662 climbing.t = 1
9663 end
9664 elseif new == Enum.HumanoidStateType.Landed then
9665 fallsound.Playing = false
9666 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
9667 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
9668 workspace.Ignore,
9669 character,
9670 game.Workspace.CurrentCamera
9671 })
9672 local grav = workspace.Gravity
9673 local fallv = rootpart.Velocity.y
9674 local fallh = fallv * fallv / (2 * grav)
9675 if fallh > 2 and hit and camera.type == "firstperson" then
9676 local soundfont = ({
9677 Brick = "concreteLand",
9678 Cobblestone = "concreteLand",
9679 Concrete = "concreteLand",
9680 CorrodedMetal = "metalLand",
9681 DiamondPlate = "metalLand",
9682 Fabric = "concreteLand",
9683 Foil = "metalLand",
9684 Granite = "concreteLand",
9685 Grass = "grassLand",
9686 Ice = "concreteLand",
9687 Marble = "concreteLand",
9688 Metal = "metalLand",
9689 Neon = "concreteLand",
9690 Pebble = "concreteLand",
9691 Plastic = "concreteLand",
9692 Sand = "sandLand",
9693 Slate = "concreteLand",
9694 SmoothPlastic = "metalLand",
9695 Wood = "woodLand",
9696 WoodPlanks = "woodLand"
9697 })[hit.Material.Name]
9698 if soundfont then
9699 AudioSystem.PlaySound(soundfont, {SoundGroup = "SelfFoley", Volume = 0.25})
9700 end
9701 end
9702 if fallh > 12 then
9703 AudioSystem.PlaySound("landHard", {SoundGroup = "SelfFoley", Volume = 0.25})
9704 end
9705 if fallh > 16 then
9706 if not effects.disablehdaudio then
9707 AudioSystem.PlaySound("landNearDeath", {SoundGroup = "SelfFoley", Volume = 0.25})
9708 end
9709 local damage = 100 * (fallh - 16) / 44
9710 local rootpos = rootpart.Position
9711 local peakpos = rootpos + v3(0, fallh, 0)
9712 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -damage, "F" .. "a" .. "l" .. "l" .. "i" .. "n" .. "g", rootpart, rootpos, peakpos)
9713 end
9714 end
9715 end
9716 local function loadcharacter()
9717 repeat
9718 wait()
9719 until player.Character and player.Character.Parent
9720 workspace.CurrentCamera:ClearAllChildren()
9721 character = player.Character
9722 char.character = character
9723 char.teleportcount = char.teleportcount + 1
9724 character.DescendantAdded:connect(dealwithit)
9725 local descendants = getdescendants(character)
9726 for i = 1, #descendants do
9727 dealwithit(descendants[i])
9728 end
9729 player:ClearCharacterAppearance()
9730 char.distance = 0
9731 nextstep = 0
9732 char.velocity = nv
9733 char.speed = 0
9734 velocityspring.t = nv
9735 velocityspring.p = nv
9736 speedspring.t = 0
9737 speedspring.p = 0
9738 humanoid = wfc(character, "Humanoid")
9739 char.humanoid = humanoid
9740 rootpart = wfc(character, "HumanoidRootPart")
9741 char.rootpart = rootpart
9742 rootjoint = wfc(rootpart, "RootJoint")
9743 rootjoint.C0 = nc
9744 rootjoint.C1 = nc
9745 character.PrimaryPart = rootpart
9746 rootpart.Anchored = true
9747 local stuff = workspace.CurrentCamera:GetChildren()
9748 for i = 1, #stuff do
9749 trash.remove(stuff[i])
9750 end
9751 humanoid.AutoRotate = false
9752 humanoid.HealthDisplayDistance = 0
9753 humanoid.NameDisplayDistance = 0
9754 humanoid.Changed:connect(dontjump)
9755 humanoid.StateChanged:connect(statechange)
9756 humanoid:SetStateEnabled("Landed", false)
9757 bodyforce.Parent = rootpart
9758 ignore[2] = character
9759 char:loadarms(repstore.Character["Left Arm"]:Clone(), repstore.Character["Right Arm"]:Clone(), "Arm", "Arm")
9760 local torso = wfc(character, "Torso")
9761 local head = wfc(character, "Head")
9762 local neck = wfc(torso, "Neck")
9763 local lsh = wfc(torso, "Left Shoulder")
9764 local rsh = wfc(torso, "Right Shoulder")
9765 local lhip = wfc(torso, "Left Hip")
9766 local rhip = wfc(torso, "Right Hip")
9767 local larm = wfc(character, "Left Arm")
9768 local rarm = wfc(character, "Right Arm")
9769 local lleg = wfc(character, "Left Leg")
9770 local rleg = wfc(character, "Right Leg")
9771 network:send("b" .. "o" .. "d" .. "y" .. "p" .. "a" .. "r" .. "t" .. "s", character)
9772 local peakheight = 50
9773 local gravity = 196.2
9774 local maxv = (2 * gravity * peakheight) ^ 0.5
9775 local root = character:WaitForChild("HumanoidRootPart")
9776 local safevelocity = root.Velocity
9777 local safecframe = root.CFrame
9778 game:GetService("RunService").RenderStepped:connect(function()
9779 local v = root.Velocity
9780 local c = root.CFrame
9781 if v.y < maxv then
9782 safevelocity = v
9783 safecframe = c
9784 else
9785 print("rly bad velolcity, attempting reset", v.y)
9786 root.Velocity = safevelocity
9787 root.CFrame = safecframe
9788 end
9789 end)
9790 delay(0, function()
9791 if character.Parent then
9792 local a = ffc(character, "Animate")
9793 local s = ffc(character, "Sound")
9794 local h = ffc(character, "Health")
9795 if a then
9796 trash.remove(a)
9797 end
9798 if s then
9799 trash.remove(s)
9800 end
9801 if h then
9802 trash.remove(h)
9803 end
9804 end
9805 end)
9806 local temphealth = game.CreatorId
9807 network:send("s" .. "e" .. "t" .. "u" .. "p" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x")
9808 if not statsloaded then
9809 network:send("s" .. "e" .. "t" .. "u" .. "p" .. "s" .. "t" .. "a" .. "t" .. "s" .. "x")
9810 statsloaded = true
9811 end
9812 fireoncharacterspawn(character)
9813 end
9814 player.CanLoadCharacterAppearance = false
9815 loadcharacter()
9816 player.CharacterAdded:connect(loadcharacter)
9817 end
9818end
9819print("Loading camera module")
9820do
9821 local e = 2.718281828459045
9822 local pi = 3.141592653589793
9823 local tau = 2 * pi
9824 local sin = math.sin
9825 local ln = math.log
9826 local cos = math.cos
9827 local v3 = Vector3.new
9828 local cf = CFrame.new
9829 local angles = CFrame.Angles
9830 local nv = v3()
9831 local tan = math.tan
9832 local atan = math.atan
9833 local deg = pi / 180
9834 local wfc = game.WaitForChild
9835 camera.currentcamera = game.Workspace.CurrentCamera
9836 camera.type = "firstperson"
9837 camera.sensitivity = 1
9838 camera.sensitivitymult = 1
9839 camera.aimsensitivity = 1
9840 camera.controllermult = 1
9841 camera.basefov = 80
9842 camera.target = utility.waitfor(game:GetService("Players").LocalPlayer.Character, 10, "Torso")
9843 camera.offset = v3(0, 1.5, 0)
9844 camera.angles = nv
9845 camera.maxangle = 0.46875 * pi
9846 camera.minangle = -0.46875 * pi
9847 camera.basecframe = cf()
9848 camera.shakecframe = cf()
9849 camera.cframe = cf()
9850 camera.lookvector = v3(0, 0, -1)
9851 camera.shakespring = physics.spring.new(nv)
9852 camera.magspring = physics.spring.new(0)
9853 camera.swayspring = physics.spring.new(0)
9854 camera.swayspeed = physics.spring.new(0)
9855 camera.delta = nv
9856 camera.onprerender = {}
9857 camera.onpostrender = {}
9858 camera.menufov = 60
9859 camera.spectatetype = "thirdperson"
9860 local ldt = 0.016666666666666666
9861 local didchange = false
9862 local killerpart, killer, killerstep, curlobby, lobbypart, lobbyfocus
9863 local fireonprerender = event.new(camera.onprerender)
9864 local fireonpostrender = event.new(camera.onpostrender)
9865 camera.shakespring.s = 12
9866 camera.shakespring.d = 0.65
9867 camera.magspring.s = 12
9868 camera.magspring.d = 1
9869 camera.swayspring.s = 4
9870 camera.swayspring.d = 1
9871 camera.swayspeed.s = 6
9872 camera.swayspeed.d = 1
9873 camera.swayspeed.t = 1
9874 camera.currentcamera.CameraType = "Scriptable"
9875 local suppressionspring = physics.spring.new(nv)
9876 suppressionspring.s = 32
9877 suppressionspring.d = 0.65
9878 local damagespring = physics.spring.new(nv)
9879 damagespring.s = 20
9880 damagespring.d = 0.75
9881 local followspring = physics.spring.new(nv)
9882 followspring.s = 16
9883 followspring.d = 0.75
9884 local accelspring = physics.spring.new(nv)
9885 accelspring.s = 10
9886 accelspring.d = 0.8
9887 local basetan = tan(45 * deg)
9888 local logtanspring = physics.spring.new(0)
9889 logtanspring.s = 30
9890 local menuspring = physics.spring.new(0)
9891 menuspring.s = 30
9892 local menucf = {
9893 c0 = cf(),
9894 c1 = cf()
9895 }
9896 function camera:setsensitivity(s)
9897 camera.sensitivity = s
9898 end
9899 function camera:setaimsensitivity(s)
9900 camera.sensitivitymult = s and camera.aimsensitivity or 1
9901 end
9902 function camera:shake(a)
9903 camera.shakespring:accelerate(a)
9904 end
9905 function camera:magnify(m)
9906 camera.magspring.t = ln(m)
9907 end
9908 function camera:suppress(a)
9909 suppressionspring:accelerate(a)
9910 end
9911 function camera:hit(d)
9912 local l = camera.cframe:vectorToObjectSpace(d)
9913 damagespring:accelerate(v3(l.z, 0, -l.x) * 0.25)
9914 end
9915 function camera:setmagnification(m)
9916 local lnm = ln(m)
9917 camera.magspring.p = lnm
9918 camera.magspring.t = lnm
9919 camera.magspring.v = 0
9920 end
9921 function camera:setmagnificationspeed(s)
9922 camera.magspring.s = s
9923 end
9924 function camera:setswayspeed(t)
9925 camera.swayspeed.t = t or 1
9926 end
9927 function camera:setsway(a)
9928 camera.swayspring.t = a
9929 end
9930 function camera:isspectating()
9931 return camera.type == "spectate" and killer and killerpart
9932 end
9933 function camera:setspectate(k, p)
9934 camera.type = "spectate"
9935 killer = k
9936 killerstep = replication.getupdater(k).step
9937 killerpart = p
9938 if k ~= p then
9939 local pcf = killerpart:GetRenderCFrame() * v3(1, 1, 6.5)
9940 followspring.t = pcf
9941 followspring.p = pcf
9942 followspring.v = nv
9943 effects:enablemapshaders(true)
9944 end
9945 end
9946 function camera:setfixedcam(cf)
9947 camera.type = "fixed"
9948 killerpart = cf
9949 end
9950 function camera:setmenucam(lobby)
9951 local charstage = wfc(lobby, "CharStage")
9952 local gunstage = wfc(lobby, "GunStage")
9953 camera.type = "menu"
9954 curlobby = lobby
9955 menucf.c0 = cf(charstage.CamPos.Position, charstage.Focus.Position)
9956 menucf.c1 = cf(gunstage.CamPos.Position, gunstage.Focus.Position)
9957 end
9958 function camera:setmenucf(ctype, stage)
9959 menucf[ctype] = cf(stage.CamPos.Position, stage.Focus.Position)
9960 end
9961 function camera:setmenufov(fov)
9962 logtanspring.t = fov
9963 end
9964 function camera:setmenuspring(t)
9965 menuspring.t = t
9966 end
9967 function camera:setfirstpersoncam()
9968 camera.type = "firstperson"
9969 camera.FieldOfView = camera.basefov
9970 end
9971 function camera:setlookvector(direction, delx, dely)
9972 didchange = true
9973 if delx and dely then
9974 local c, s = cos(tick()), sin(tick())
9975 delx, dely = c * delx - s * dely, s * delx + c * dely
9976 end
9977 local x, ay = vector.toanglesyx(direction)
9978 x = x + (delx or 0)
9979 ay = ay + (dely or 0)
9980 local cy = camera.angles.y
9981 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9982 local y = (ay + pi - cy) % tau - pi + cy
9983 local newangles = v3(x, y, 0)
9984 camera.delta = (newangles - camera.angles) / ldt
9985 camera.angles = newangles
9986 end
9987 function camera:changemenufov(z)
9988 local newlogtan = logtanspring.t + z
9989 newlogtan = newlogtan < 0 and 0 or newlogtan < 3 and newlogtan or 3
9990 logtanspring.t = newlogtan
9991 end
9992 local screencull = {}
9993 camera.screencull = screencull
9994 do
9995 local tan = math.tan
9996 local deg = math.pi / 180
9997 local cf = CFrame.new
9998 local nc = cf()
9999 local ptos = nc.pointToObjectSpace
10000 local camcf, portsize, h, px, py, sx, sy, rscalex, rscaley
10001 function screencull.sphere(point, radius)
10002 local r = ptos(camcf, point)
10003 local rz = -r.z
10004 local rx = r.x
10005 local ry = r.y
10006 return -rz * sx < rx + rscalex * radius and rx - rscalex * radius < rz * sx and -rz * sy < ry + rscaley * radius and ry - rscaley * radius < rz * sy and rz > -radius, rz
10007 end
10008 function screencull.point(point)
10009 local r = ptos(camcf, point)
10010 local rz = -r.z
10011 local rx = r.x
10012 local ry = r.y
10013 return rx > -rz * sx and rx < rz * sx and ry > -rz * sy and ry < rz * sy
10014 end
10015 function screencull.update(newcamcf, newportsize, newfov)
10016 camcf = newcamcf
10017 portsize = newportsize
10018 h = newfov * deg / 2
10019 py = portsize.y
10020 px = portsize.x
10021 sy = tan(h)
10022 sx = px / py * sy
10023 rscaley = (1 + sy * sy) ^ 0.5
10024 rscalex = (1 + sx * sx) ^ 0.5
10025 end
10026 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.currentcamera.FieldOfView)
10027 end
10028 local swayt = 0
10029 function camera.step(dt)
10030 ldt = dt
10031 if not didchange then
10032 camera.delta = nv
10033 end
10034 didchange = false
10035 fireonprerender(camera)
10036 accelspring.t = char.acceleration
10037 if camera.type == "firstperson" then
10038 swayt = swayt + dt * camera.swayspeed.p
10039 local t = swayt
10040 local s, d = 0.5 * char.speed, char.distance * 6.28318 / 4 * 3 / 4
10041 local ss = camera.swayspring.p
10042 local cameraangles = angles(0, camera.angles.y, 0) * angles(camera.angles.x, 0, 0)
10043 camera.basecframe = cameraangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
10044 local shakeangles = cameraangles * cframe.fromaxisangle(camera.shakespring.p) * cframe.fromaxisangle(s * cos(d + 2) / 2048, s * cos(d / 2) / 2048, s * cos(d / 2 + 2) / 4096) * cframe.fromaxisangle(ss * cos(2 * t + 2) / 2048, ss * cos(2 * t / 2) / 2048, ss * cos(2 * t / 2 - 2) / 4096)
10045 camera.shakecframe = shakeangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
10046 local cameracframe = shakeangles * cframe.fromaxisangle(v3(0, 0, 1):Cross(accelspring.v / 4096 / 16) * v3(1, 0, 0)) * cframe.fromaxisangle(suppressionspring.p + damagespring.p) * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
10047 local newfov = 2 * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / deg
10048 camera.currentcamera.FieldOfView = newfov
10049 camera.currentcamera.CoordinateFrame = cameracframe
10050 camera.cframe = cameracframe
10051 camera.lookvector = camera.cframe.lookVector
10052 screencull.update(cameracframe, camera.currentcamera.ViewportSize, newfov)
10053 elseif camera.type == "spectate" then
10054 if killer and killerstep and killer ~= game:GetService("Players").LocalPlayer and killerpart and hud:isplayeralive(killer) then
10055 killerstep(3, true)
10056 local pcf = killerpart:GetRenderCFrame()
10057 followspring.t = pcf * v3(1, 1, 6.5)
10058 if camera.spectatetype == "thirdperson" then
10059 local _, pos = sphereraycast(pcf.p, followspring.p - pcf.p, 1, killer.Character)
10060 pos = pos or followspring.p
10061 local angx, angy = vector.toanglesyx(pcf.lookVector)
10062 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0)
10063 if 0 > vector.dot(cameracframe * v3(1, 0, 0), cframe.vtws(pcf, v3(1, 0, 0))) then
10064 cameracframe = cameracframe * angles(0, 0, pi)
10065 end
10066 camera.currentcamera.CoordinateFrame = cameracframe * cf(0, 0, -0.5) + pos
10067 camera.cframe = cameracframe * cf(0, 0, -0.5) + pos
10068 camera.lookvector = camera.cframe.lookVector
10069 elseif camera.spectatetype == "firstperson" then
10070 local angx, angy = vector.toanglesyx(pcf.lookVector)
10071 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0) * cf(0, 0, -0.5) + pcf.p
10072 camera.currentcamera.CoordinateFrame = cameracframe
10073 camera.cframe = cameracframe
10074 camera.lookvector = cameracframe.lookVector
10075 end
10076 elseif not hud:isplayeralive(killer) then
10077 killer = nil
10078 killerpart = nil
10079 if char.deadcf then
10080 camera:setfixedcam(char.deadcf)
10081 end
10082 end
10083 camera.currentcamera.FieldOfView = camera.basefov
10084 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.basefov)
10085 elseif camera.type == "fixed" then
10086 if killerpart then
10087 local cameracframe = killerpart * CFrame.new(0, 1, 2)
10088 camera.currentcamera.CoordinateFrame = cameracframe
10089 camera.cframe = cameracframe
10090 camera.lookvector = camera.cframe.lookVector
10091 end
10092 camera.currentcamera.FieldOfView = camera.basefov
10093 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
10094 elseif camera.type == "menu" then
10095 if curlobby then
10096 local cameracframe = cframe.interpolate(menucf.c0, menucf.c1, menuspring.p)
10097 camera.currentcamera.CoordinateFrame = cameracframe
10098 camera.cframe = cameracframe
10099 camera.lookvector = camera.cframe.lookVector
10100 end
10101 camera.currentcamera.FieldOfView = 2 / deg * atan(basetan / e ^ logtanspring.p)
10102 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
10103 end
10104 fireonpostrender(camera)
10105 end
10106 input.mouse.onmousemove:connect(function(delta)
10107 didchange = true
10108 local coef = camera.sensitivity * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
10109 local x = camera.angles.x - coef * delta.y
10110 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
10111 local y = camera.angles.y - coef * delta.x
10112 local newangles = v3(x, y, 0)
10113 camera.delta = (newangles - camera.angles) / ldt
10114 camera.angles = newangles
10115 end)
10116 input.controller.onintegralmove:connect(function(delta, dt)
10117 didchange = true
10118 local coef = 3000 * delta.magnitude / dt * camera.sensitivity * camera.controllermult * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
10119 local x = camera.angles.x + coef * delta.y
10120 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
10121 local y = camera.angles.y - coef * delta.x
10122 local newangles = v3(x, y, 0)
10123 camera.delta = (newangles - camera.angles) / ldt
10124 camera.angles = newangles
10125 end)
10126 input.mouse:hide()
10127 input.mouse:lockcenter()
10128 game:GetService("Players").LocalPlayer.CharacterAdded:connect(function()
10129 wait()
10130 input.mouse:hide()
10131 input.mouse:lockcenter()
10132 end)
10133end
10134replication_envext = {}
10135do
10136 local torsoaim = 0.5
10137 local tau = 2 * math.pi
10138 local e = 2.718281828459045
10139 local v3 = Vector3.new
10140 local nv = v3()
10141 local dot = nv.Dot
10142 local anglesyx = vector.anglesyx
10143 local cf = CFrame.new
10144 local angles = CFrame.Angles
10145 local direct = cframe.direct
10146 local jointleg = cframe.jointleg
10147 local jointarm = cframe.jointarm
10148 local new = Instance.new
10149 local nc = cf()
10150 local tos = nc.toObjectSpace
10151 local vtws = nc.vectorToWorldSpace
10152 local ptos = nc.pointToObjectSpace
10153 local vtos = nc.vectorToObjectSpace
10154 local ffc = game.FindFirstChild
10155 local localplayer = game:GetService("Players").LocalPlayer
10156 local forward = v3(0, 0, -1)
10157 local ray = Ray.new
10158 local raycast = workspace.FindPartOnRayWithIgnoreList
10159 local debris = game.Debris
10160 local lastsent = tick()
10161 local upinfos = {}
10162 local repstore = game.ReplicatedStorage
10163 local modulestore = game.ReplicatedStorage.GunModules
10164 local thirdpmstore = game.ReplicatedStorage.ExternalModels
10165 local stancecrouchcf = cframe.interpolator(cf(0, -0.125, 0), cf(0, -1, 0) * angles(-tau / 24, 0, 0))
10166 local crouchpronecf = cframe.interpolator(cf(0, -1, 0) * angles(-tau / 24, 0, 0), cf(0, -2, 0.5) * angles(-tau / 4, 0, 0))
10167 local materialhitsound = {
10168 Brick = "imp_concrete",
10169 Cobblestone = "imp_concrete",
10170 Concrete = "imp_concrete",
10171 CorrodedMetal = "imp_metal",
10172 DiamondPlate = "imp_metal",
10173 Fabric = "imp_grass",
10174 Foil = "imp_metal",
10175 Granite = "imp_concrete",
10176 Grass = "imp_grass",
10177 Ice = "imp_concrete",
10178 Marble = "imp_concrete",
10179 Metal = "imp_metal",
10180 Neon = "imp_concrete",
10181 Pebble = "imp_concrete",
10182 Plastic = "imp_metal",
10183 Sand = "imp_grass",
10184 Slate = "imp_concrete",
10185 SmoothPlastic = "imp_metal",
10186 Wood = "imp_wood",
10187 WoodPlanks = "imp_wood"
10188 }
10189 local function hitdist(center0, center1, radius, point)
10190 local dcenter = center1 - center0
10191 local len = dcenter.magnitude
10192 if len > 0 then
10193 local rel = center0 - point
10194 local y = dot(rel, dcenter) / len
10195 local dist2 = radius * radius + y * y - dot(rel, rel)
10196 if dist2 > 0 then
10197 local rdist = dist2 ^ 0.5 - y
10198 if rdist > 0 then
10199 return len / rdist, rdist - len
10200 else
10201 return 1
10202 end
10203 else
10204 return 1
10205 end
10206 else
10207 return 0
10208 end
10209 end
10210 local hittarget = function(center0, center1, radius)
10211 local dcenter = center1 - center0
10212 local len = dcenter.magnitude
10213 if len > 0 then
10214 return center1 + radius / len * dcenter
10215 else
10216 return center1
10217 end
10218 end
10219 local rightshcf = cf(0.5, 0.5, 0, 0.918751657, -0.309533417, -0.245118901, 0.369528353, 0.455418497, 0.809963167, -0.139079139, -0.834734678, 0.532798767)
10220 local leftshcf = cf(-0.5, 0.5, 0, 0.918751657, 0.309533417, 0.245118901, -0.369528353, 0.455418497, 0.809963167, 0.139079139, -0.834734678, 0.532798767)
10221 local rand = math.random
10222 local function pickv3(v0, v1)
10223 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
10224 end
10225 local bodysize = {
10226 Head = v3(2, 1, 1),
10227 Torso = v3(2, 2, 1),
10228 HumanoidRootPart = v3(0.2, 0.2, 0.2),
10229 ["Left Arm"] = v3(1, 2, 1),
10230 ["Right Arm"] = v3(1, 2, 1),
10231 ["Left Leg"] = v3(1, 2, 1),
10232 ["Right Leg"] = v3(1, 2, 1)
10233 }
10234 local function raycastboxfast(origin, direction, cframe, size)
10235 local ro = ptos(cframe, origin)
10236 local rd = vtos(cframe, direction)
10237 local ox, oy, oz = ro.x, ro.y, ro.z
10238 local dx, dy, dz = rd.x, rd.y, rd.z
10239 local sx = 0.5 * size.x
10240 local sy = 0.5 * size.y
10241 local sz = 0.5 * size.z
10242 local x0, y0, z0 = -1 / 0, -1 / 0, -1 / 0
10243 local x1, y1, z1 = 1 / 0, 1 / 0, 1 / 0
10244 if dx < -1.0E-8 then
10245 x0 = (sx - ox) / dx
10246 x1 = (-sx - ox) / dx
10247 elseif dx > 1.0E-8 then
10248 x0 = (-sx - ox) / dx
10249 x1 = (sx - ox) / dx
10250 elseif ox < -sx or ox > sx then
10251 return nil, nil
10252 end
10253 if dy < -1.0E-8 then
10254 y0 = (sy - oy) / dy
10255 y1 = (-sy - oy) / dy
10256 elseif dy > 1.0E-8 then
10257 y0 = (-sy - oy) / dy
10258 y1 = (sy - oy) / dy
10259 elseif oy < -sy or oy > sy then
10260 return nil, nil
10261 end
10262 if dz < -1.0E-8 then
10263 z0 = (sz - oz) / dz
10264 z1 = (-sz - oz) / dz
10265 elseif dz > 1.0E-8 then
10266 z0 = (-sz - oz) / dz
10267 z1 = (sz - oz) / dz
10268 elseif oz < -sz or oz > sz then
10269 return nil, nil
10270 end
10271 local t0 = x0 < y0 and (y0 < z0 and z0 or y0) or x0 < z0 and z0 or x0
10272 local t1 = x1 < y1 and (x1 < z1 and x1 or z1) or y1 < z1 and y1 or z1
10273 if t0 > t1 then
10274 return nil, nil
10275 else
10276 return t0, t1
10277 end
10278 end
10279 local characterhash = {}
10280 local characterparts = {}
10281 local parts = {
10282 "head",
10283 "torso",
10284 "lleg",
10285 "rleg",
10286 "larm",
10287 "rarm"
10288 }
10289 local function setcharacterhash(person, bodyparts)
10290 if person.Character then
10291 for i, v in next, parts, nil do
10292 local object = bodyparts[v]
10293 if object then
10294 characterhash[object] = {
10295 object = object,
10296 bodypart = v,
10297 player = person,
10298 character = person.Character,
10299 bodyparts = bodyparts
10300 }
10301 end
10302 end
10303 end
10304 characterparts[person] = bodyparts
10305 end
10306 local function removecharacterhash(person)
10307 for i, v in next, characterhash, nil do
10308 if v.player == person then
10309 characterhash[i] = nil
10310 end
10311 end
10312 characterparts[person] = nil
10313 end
10314 function replication.getcharhitinfo(hit, pos, dir)
10315 local hitinfo = characterhash[hit]
10316 if hitinfo then
10317 local bodyparts = hitinfo.bodyparts
10318 for i = 1, #parts do
10319 local v = parts[i]
10320 local t0, t1 = raycastboxfast(pos, dir, bodyparts[v].CFrame, bodysize[bodyparts[v].Name] or v3(1, 1, 1))
10321 if t0 then
10322 return characterhash[bodyparts[v]]
10323 end
10324 end
10325 end
10326 end
10327 function replication.getbodyparts(player)
10328 return characterparts[player]
10329 end
10330 local function loadplayer(player, state)
10331 local wepmod = require(script.WepScriptRep)
10332 local ext_env = {}
10333 state = state or network:fetch("s" .. "t" .. "a" .. "t" .. "e", player)
10334 if not state or not state.bodyparts then
10335 return
10336 end
10337 if state.healthstate then
10338 hud.inializehealth(player, state.healthstate.alive)
10339 end
10340 ext_env.bodyparts = state.bodyparts
10341 ext_env.rootpart = ext_env.bodyparts.rootpart
10342 ext_env.torso = ext_env.bodyparts.torso
10343 ext_env.neck = ext_env.bodyparts.neck
10344 ext_env.head = ext_env.bodyparts.head
10345 if not (ext_env.rootpart and ext_env.torso and ext_env.neck and ext_env.bodyparts.lsh and ext_env.bodyparts.rsh and ext_env.bodyparts.lhip and ext_env.bodyparts.rhip and ext_env.bodyparts.larm and ext_env.bodyparts.rarm and ext_env.bodyparts.lleg and ext_env.bodyparts.rleg) or not ext_env.bodyparts.rootjoint then
10346 return
10347 end
10348 setcharacterhash(player, ext_env.bodyparts)
10349 trash.remove(ext_env.bodyparts.lsh)
10350 trash.remove(ext_env.bodyparts.rsh)
10351 trash.remove(ext_env.bodyparts.lhip)
10352 trash.remove(ext_env.bodyparts.rhip)
10353 local lsh = new("Motor6D", ext_env.torso)
10354 local rsh = new("Motor6D", ext_env.torso)
10355 local lhip = new("Motor6D", ext_env.torso)
10356 local rhip = new("Motor6D", ext_env.torso)
10357 lsh.Part0 = ext_env.torso
10358 rsh.Part0 = ext_env.torso
10359 lhip.Part0 = ext_env.torso
10360 rhip.Part0 = ext_env.torso
10361 lsh.Part1 = ext_env.bodyparts.larm
10362 rsh.Part1 = ext_env.bodyparts.rarm
10363 lhip.Part1 = ext_env.bodyparts.lleg
10364 rhip.Part1 = ext_env.bodyparts.rleg
10365 local self = {}
10366 self.ignore = ext_env.bodyparts
10367 local thread = sequencer.new()
10368 local weaponmodule, weapontype
10369 local weaponheadaimangle = 0
10370 local weaponsprintcf = nc
10371 local weapontransoffset = nc
10372 local weaponrotoffset = nc
10373 local weaponpivot = nc
10374 local weaponaimpivot = nc
10375 local weapondrawcf = nc
10376 local weaponlhold = v3(0, -1, 0)
10377 local weaponrhold = nv
10378 local weaponforward = v3(0, 0, -1)
10379 local weaponstabcf = nc
10380 local weapon
10381 local mainweld = new("Motor6D", ext_env.torso)
10382 mainweld.Part0 = ext_env.torso
10383 local equipspring = physics.spring.new()
10384 equipspring.s = 12
10385 equipspring.d = 0.8
10386 local aimspring = physics.spring.new(1)
10387 aimspring.s = 12
10388 local stabspring = physics.spring.new()
10389 stabspring.s = 20
10390 stabspring.d = 0.8
10391 local transkickspring = physics.spring.new(nv)
10392 local rotkickspring = physics.spring.new(nv)
10393 local stance
10394 local posspring = physics.spring.new(nv)
10395 posspring.s = 32
10396 local stancespring = physics.spring.new(0)
10397 stancespring.s = 4
10398 stancespring.d = 0.8
10399 local speedspring = physics.spring.new(0)
10400 speedspring.s = 8
10401 local sprintspring = physics.spring.new(1)
10402 sprintspring.s = 8
10403 local baseangle = 0
10404 local maxdangle = 0.5
10405 self.lookangles = physics.spring.new(nv)
10406 self.lookangles.s = 16
10407 self.lookangles.d = 0.75
10408 local muzzlespring = physics.spring.new(0)
10409 muzzlespring.s = 50
10410 muzzlespring.d = 1
10411 local stepradius = 1
10412 local rfoot = {
10413 makesound = true,
10414 center = nc,
10415 pos = nv,
10416 sdown = cf(0.5, -3, 0),
10417 pdown = cf(0.5, -2.75, 0),
10418 weld = rhip,
10419 hipcf = cf(0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
10420 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
10421 angm = 1,
10422 torsoswing = 0.1
10423 }
10424 local lfoot = {
10425 center = nc,
10426 pos = nv,
10427 sdown = cf(-0.5, -3, 0),
10428 pdown = cf(-0.5, -2.75, 0),
10429 weld = lhip,
10430 hipcf = cf(-0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
10431 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
10432 angm = -1,
10433 torsoswing = -0.1
10434 }
10435 local p, l = rfoot, lfoot
10436 local firesound = new("Sound", ext_env.torso)
10437 local equalizer = new("EqualizerSoundEffect", firesound)
10438 equalizer.HighGain = 0
10439 equalizer.MidGain = 0
10440 equalizer.LowGain = 0
10441 local muzzlelight = repstore.Effects.MuzzleLight:Clone()
10442 local soundid
10443 muzzlelight.Parent = ext_env.torso
10444 trash.remove(ext_env.bodyparts.rootjoint)
10445 ext_env.head.Transparency = 0
10446 if ffc(ext_env.head, "Mesh") then
10447 ext_env.head.Mesh:Destroy()
10448 repstore.Misc.Mesh:Clone().Parent = ext_env.head
10449 end
10450 ext_env.neck.C1 = nc
10451 self.rootpart = ext_env.rootpart
10452 self.torso = ext_env.torso
10453 function self.getlookangles()
10454 return self.lookangles.p
10455 end
10456 local function updatecalls()
10457 if not player.Character then
10458 return
10459 end
10460 for i, v in next, player.Character:GetChildren() do
10461 if v:IsA("BasePart") and bodysize[v.Name] then
10462 if v.Name == "HumanoidRootPart" then
10463 if v.Size ~= bodysize[v.Name] then
10464 if v.Size == v3(2, 2, 1) then
10465 v.Size = v3(0.2, 0.2, 0.2)
10466 else
10467 netkick("what happened")
10468 end
10469 end
10470 v.Changed:connect(function(prop)
10471 if (prop == "Size" or prop == "CanCollide") and v.Size ~= v3(2, 2, 1) and v.Size ~= v3(0.2, 0.2, 0.2) then
10472 netkick("something broke")
10473 end
10474 end)
10475 else
10476 if v.Size ~= bodysize[v.Name] then
10477 netkick("wow u smart")
10478 end
10479 do
10480 local origprops = {
10481 Size = v.Size,
10482 CanCollide = v.CanCollide
10483 }
10484 v.Changed:connect(function(prop)
10485 if prop == "Size" or prop == "CanCollide" then
10486 v[prop] = origprops[prop]
10487 end
10488 end)
10489 end
10490 end
10491 end
10492 end
10493 end
10494 function self.updatecharacter(state)
10495 if not (state.rootpart and lsh and rsh and lhip) or not rhip then
10496 return
10497 end
10498 ext_env.rootpart = state.rootpart
10499 self.rootpart = ext_env.rootpart
10500 if not firesound.Parent then
10501 firesound = new("Sound", ext_env.rootpart)
10502 end
10503 rfoot.ignore = {
10504 state.rootpart,
10505 state.torso,
10506 state.neck.Part1,
10507 state.larm,
10508 state.rarm,
10509 state.lleg,
10510 state.rleg
10511 }
10512 ext_env.head.Transparency = 0
10513 ext_env.torso = state.torso
10514 trash.remove(state.rootjoint)
10515 trash.remove(state.lsh)
10516 trash.remove(state.rsh)
10517 trash.remove(state.lhip)
10518 trash.remove(state.rhip)
10519 ext_env.neck = state.neck
10520 mainweld.Part0 = ext_env.torso
10521 mainweld.Parent = ext_env.torso
10522 ext_env.neck.C1 = nc
10523 lsh.Parent = ext_env.torso
10524 rsh.Parent = ext_env.torso
10525 lhip.Parent = ext_env.torso
10526 rhip.Parent = ext_env.torso
10527 lsh.Part0 = ext_env.torso
10528 rsh.Part0 = ext_env.torso
10529 lhip.Part0 = ext_env.torso
10530 rhip.Part0 = ext_env.torso
10531 lsh.Part1 = state.larm
10532 rsh.Part1 = state.rarm
10533 lhip.Part1 = state.lleg
10534 rhip.Part1 = state.rleg
10535 setcharacterhash(player, state)
10536 updatecalls()
10537 end
10538 local function weld3pm(model, camodata, data, repattach)
10539 local s1 = ffc(model, "Slot1")
10540 local s2 = ffc(model, "Slot2")
10541 if not s1 or not s2 then
10542 print("Incomplete third person model")
10543 return
10544 end
10545 for i, v in next, model:GetChildren() do
10546 if v:IsA("BasePart") then
10547 if v ~= s1 then
10548 local weld = new("Weld", s1)
10549 weld.Part0 = s1
10550 weld.Part1 = v
10551 weld.C0 = s1.CFrame:inverse() * v.CFrame
10552 end
10553 if not effects.disable3pcamoskins and camodata and camodata[v.Name] and camodata[v.Name].Name ~= "" then
10554 local t = Instance.new("Texture")
10555 t.Name = v.Name
10556 t.Texture = "rbxassetid://" .. camodata[v.Name].TextureProperties.TextureId
10557 t.Transparency = camodata[v.Name].TextureProperties.Transparency
10558 t.StudsPerTileU = camodata[v.Name].TextureProperties.StudsPerTileU
10559 t.StudsPerTileV = camodata[v.Name].TextureProperties.StudsPerTileV
10560 for i = 0, v:IsA("MeshPart") and 5 or 0 do
10561 local tt = t:Clone()
10562 tt.Face = i
10563 tt.Parent = v
10564 end
10565 if camodata[v.Name].TextureProperties.Color then
10566 local colordata = camodata[v.Name].TextureProperties.Color
10567 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
10568 end
10569 if camodata[v.Name].BrickProperties.DefaultColor ~= true then
10570 local colordata = camodata[v.Name].BrickProperties.Color
10571 if colordata then
10572 v.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
10573 else
10574 v.BrickColor = BrickColor.new(camodata[v.Name].BrickProperties.BrickColor)
10575 end
10576 end
10577 if camodata[v.Name].BrickProperties.Material then
10578 v.Material = camodata[v.Name].BrickProperties.Material
10579 end
10580 if camodata[v.Name].BrickProperties.Reflectance then
10581 v.Reflectance = camodata[v.Name].BrickProperties.Reflectance
10582 end
10583 end
10584 v.Anchored = false
10585 v.CanCollide = false
10586 end
10587 end
10588 if repattach then
10589 for i, v in next, repattach, nil do
10590 local node = model:FindFirstChild(i .. "Node")
10591 if node then
10592 weldattachment(model, i, v, node, s1, {}, {}, {})
10593 local parts = model:GetChildren()
10594 for i = 1, #parts do
10595 local pt = parts[i]
10596 if pt.Name == "LaserLight" then
10597 wepmod:addlaser(pt)
10598 end
10599 end
10600 end
10601 end
10602 end
10603 end
10604 function self.equipknife(module, newweapon, camodata)
10605 if module then
10606 thread:clear()
10607 if weapon then
10608 wepmod:deactivatelasers(true, weapon)
10609 equipspring.t = 0
10610 thread:add(function()
10611 return equipspring.p < 0
10612 end)
10613 thread:add(function()
10614 weapon.Slot1.Transparency = 1
10615 weapon.Slot2.Transparency = 1
10616 mainweld.Part1 = nil
10617 trash.remove(weapon)
10618 end)
10619 end
10620 thread:add(function()
10621 weaponmodule = module
10622 weapontype = "KNIFE"
10623 weapontransoffset = cf(module.offset3p.p)
10624 weaponrotoffset = module.offset3p - module.offset3p.p
10625 weaponpivot = module.pivot3p
10626 weapondrawcf = module.drawcf3p
10627 weaponforward = module.forward3p
10628 weaponsprintcf = module.sprintcf3p
10629 weaponlhold = module.lhold3p
10630 weaponrhold = module.rhold3p
10631 weaponstabcf = module.stabcf3p
10632 weapon = newweapon:Clone()
10633 weld3pm(weapon, camodata)
10634 weapon.Parent = ext_env.torso.Parent
10635 mainweld.Part1 = weapon.Slot1
10636 equipspring.t = 1
10637 end)
10638 end
10639 end
10640 function self.equip(module, newweapon, camodata, replicateattach)
10641 if module then
10642 thread:clear()
10643 if weapon then
10644 wepmod:deactivatelasers(true, weapon)
10645 equipspring.t = 0
10646 thread:add(function()
10647 return equipspring.p < 0
10648 end)
10649 thread:add(function()
10650 weapon.Slot1.Transparency = 1
10651 weapon.Slot2.Transparency = 1
10652 mainweld.Part1 = nil
10653 trash.remove(weapon)
10654 end)
10655 end
10656 thread:add(function()
10657 weaponmodule = module
10658 if weaponmodule.type == "KNIFE" then
10659 weapontype = "KNIFE"
10660 weapontransoffset = cf(module.offset3p.p)
10661 weaponrotoffset = module.offset3p - module.offset3p.p
10662 weaponpivot = module.pivot3p
10663 weapondrawcf = module.drawcf3p
10664 weaponforward = module.forward3p
10665 weaponsprintcf = module.sprintcf3p
10666 weaponlhold = module.lhold3p
10667 weaponrhold = module.rhold3p
10668 weaponstabcf = module.stabcf3p
10669 warn("Knife module loaded into main gun module: " .. weaponmodule.name)
10670 else
10671 weapontype = "gun"
10672 weapontransoffset = cf(module.offset3p.p)
10673 weaponrotoffset = module.offset3p - module.offset3p.p
10674 weaponpivot = module.pivot3p
10675 weapondrawcf = module.drawcf3p
10676 weaponforward = module.forward3p
10677 weaponheadaimangle = module.headaimangle3p or 0
10678 weaponsprintcf = module.sprintcf3p
10679 weaponaimpivot = module.aimpivot3p
10680 transkickspring.s = module.modelkickspeed
10681 transkickspring.d = module.modelkickdamper
10682 rotkickspring.s = module.modelkickspeed
10683 rotkickspring.d = module.modelkickdamper
10684 weaponlhold = module.lhold3p
10685 weaponrhold = module.rhold3p
10686 end
10687 weapon = newweapon:Clone()
10688 weld3pm(weapon, camodata, module, replicateattach)
10689 weapon.Parent = ext_env.torso.Parent
10690 mainweld.Part1 = weapon.Slot1
10691 equipspring.t = 1
10692 if firesound and module.firesoundid then
10693 firesound.SoundId = module.firesoundid
10694 firesound.Pitch = module.firepitch
10695 firesound.Volume = module.firevolume
10696 soundid = module.firesoundid
10697 end
10698 end)
10699 end
10700 end
10701 function self.getweaponpos()
10702 if weapon and weaponmodule then
10703 local c = weaponmodule.offset3p
10704 local r = c - c.p
10705 return weapon.Slot1.CFrame * r:inverse() * v3(0, 0, -2)
10706 else
10707 return ext_env.head.Position
10708 end
10709 end
10710 function self.stab()
10711 if weapon and weapontype == "KNIFE" then
10712 stabspring.a = 47
10713 end
10714 end
10715 local freesounds = {}
10716 function self.kickweapon(hide, pitch, volume)
10717 if weapon and weapontype == "gun" then
10718 do
10719 local aim = aimspring.p
10720 transkickspring:accelerate(pickv3(weaponmodule.transkickmin, weaponmodule.transkickmax))
10721 rotkickspring:accelerate(pickv3(weaponmodule.rotkickmin, weaponmodule.rotkickmax))
10722 if not hide then
10723 muzzlespring:accelerate(125)
10724 end
10725 local soundobject
10726 if #freesounds == 0 then
10727 soundobject = firesound:Clone()
10728 soundobject.Ended:connect(function()
10729 freesounds[#freesounds + 1] = soundobject
10730 end)
10731 else
10732 soundobject = freesounds[#freesounds]
10733 freesounds[#freesounds] = nil
10734 end
10735 if pitch then
10736 soundobject.Pitch = pitch
10737 end
10738 if volume then
10739 soundobject.Volume = volume
10740 end
10741 soundobject.SoundId = soundid
10742 soundobject.Parent = ext_env.torso
10743 local mufflemath = -(ext_env.torso.Position - camera.cframe.p).magnitude / 14.6484
10744 soundobject.EqualizerSoundEffect.HighGain = mufflemath
10745 soundobject.EqualizerSoundEffect.MidGain = mufflemath
10746 soundobject:Play()
10747 end
10748 end
10749 end
10750 function self.setsprint(sprint)
10751 sprintspring.t = sprint and 0 or 1
10752 end
10753 function self.setaim(aim)
10754 aimspring.t = aim and 0 or 1
10755 end
10756 function self.setstance(newstance)
10757 stance = newstance
10758 stancespring.t = newstance == "stand" and 0 or newstance == "crouch" and 0.5 or 1
10759 end
10760 function self.setlookangles(newlookangles)
10761 self.lookangles.t = newlookangles
10762 end
10763 local rootframes = {}
10764 function self.addrootframes(frames)
10765 local frame1 = frames[1]
10766 if frame1 then
10767 local t0 = frame1.t
10768 for i = 1, #rootframes do
10769 local rframe = rootframes[i]
10770 if t0 < rframe.t then
10771 for j = i, #rootframes do
10772 rootframes[j] = nil
10773 end
10774 break
10775 end
10776 end
10777 local n = #rootframes
10778 for i = 1, #frames do
10779 rootframes[n + i] = frames[i]
10780 end
10781 end
10782 end
10783 local lastt = tick()
10784 local lastp = nv
10785 local curcf = nc
10786 function self.getrootcf()
10787 local cf = ext_env.rootpart:GetRenderCFrame()
10788 cf = CFrame.Angles(0, baseangle, 0) + cf.p
10789 local v = ext_env.rootpart.Velocity
10790 local p1 = cf.p
10791 local t1 = tick()
10792 local iv = (p1 - lastp) / (t1 - lastt)
10793 lastp = p1
10794 lastt = t1
10795 if (iv - v).magnitude < 256 then
10796 curcf = cf
10797 return cf, v
10798 else
10799 return curcf, v
10800 end
10801 end
10802 local steplist = {}
10803 steplist.lastmainupdate = 0
10804 steplist.lastotherupdate = 0
10805 ext_env.velspring = physics.spring.new(nv)
10806 ext_env.velspring.s = 3
10807 steplist.remp = 0
10808 self.weprendered = false
10809 self.hud = hud
10810 function self.step(levelofdetail, renderwep)
10811 debug.profilebegin("rep char " .. levelofdetail .. " " .. player.name)
10812 if not ext_env.rootpart.Parent or not ext_env.torso then
10813 debug.profileend()
10814 return
10815 end
10816 local rootcf, rootvel = self.getrootcf()
10817 if not self.hud:isplayeralive(player) then
10818 if 4 < (rootcf.p - ext_env.torso.CFrame.p).magnitude then
10819 ext_env.torso.CFrame = cf() + rootcf.p
10820 end
10821 debug.profileend()
10822 return
10823 end
10824 posspring.t = rootcf.p
10825 if (rootcf.p - posspring.p).magnitude > 16 then
10826 posspring.p = rootcf.p
10827 posspring.v = nv
10828 end
10829 ext_env.velspring.t = rootvel * v3(1, 0, 1)
10830 if weapon then
10831 if renderwep and not self.weprendered then
10832 weapon.Slot1.Transparency = 0
10833 weapon.Slot2.Transparency = 0
10834 self.weprendered = true
10835 elseif not renderwep and self.weprendered then
10836 weapon.Slot1.Transparency = 1
10837 weapon.Slot2.Transparency = 1
10838 self.weprendered = false
10839 end
10840 end
10841 if levelofdetail >= 1 then
10842 thread:step()
10843 rootcf = rootcf - rootcf.p + posspring.p
10844 local stancep = stancespring.p
10845 local sprintp = sprintspring.p
10846 local stancecf = stancep < 0.5 and stancecrouchcf(2 * stancep) or crouchpronecf(2 * stancep - 1)
10847 local look = self.lookangles.p
10848 local lookx = look.x
10849 local looky = look.y
10850 local maxd = sprintp * maxdangle
10851 baseangle = baseangle - looky < -maxd and looky - maxd or maxd < baseangle - looky and looky + maxd or baseangle
10852 local basecf = angles(0, baseangle, 0) * cf(0, 0.05 * math.sin(2 * tick()) - 0.55, 0) * stancecf * cf(0, 0.5, 0) + rootcf.p
10853 local pronep = stancep > 0.5 and 2 * stancep - 1 or 0
10854 stepradius = 0.5 * (1 - stancep) + 0.5 + (1 - sprintp) * 0.5
10855 local newpcenter = cframe.interpolate(rootcf * p.sdown, basecf * p.pdown, pronep)
10856 local newlcenter = cframe.interpolate(rootcf * l.sdown, basecf * l.pdown, pronep)
10857 local dist, rem = hitdist(p.center.p, newpcenter.p, stepradius, p.pos)
10858 steplist.remp = rem or steplist.remp
10859 local target = hittarget(l.center.p, newlcenter.p, stepradius)
10860 if dist < 1 then
10861 l.pos = (1 - dist) * (newlcenter * l.center:inverse() * l.pos) + dist * target
10862 p.center = newpcenter
10863 l.center = newlcenter
10864 else
10865 p.center = newpcenter
10866 l.center = newlcenter
10867 local dist = (camera.cframe.p - newlcenter.p).magnitude
10868 if l.ignore and l.makesound and dist < 128 then
10869 local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(newlcenter.p + v3(0, 1, 0), v3(0, -2, 0)), l.ignore)
10870 if hit then
10871 local soundfont = ({
10872 Brick = "concrete",
10873 Cobblestone = "concrete",
10874 Concrete = "concrete",
10875 CorrodedMetal = "metal",
10876 DiamondPlate = "metal",
10877 Fabric = "concrete",
10878 Foil = "metal",
10879 Granite = "concrete",
10880 Grass = "grass",
10881 Ice = "concrete",
10882 Marble = "concrete",
10883 Metal = "metal",
10884 Neon = "hardstep",
10885 Pebble = "concrete",
10886 Plastic = "metal",
10887 Sand = "sand",
10888 Slate = "concrete",
10889 SmoothPlastic = "metal",
10890 Wood = "wood",
10891 WoodPlanks = "wood"
10892 })[hit.Material.Name]
10893 if soundfont then
10894 replication_envext.volume = 0
10895 if player.TeamColor ~= localplayer.TeamColor then
10896 soundfont = "enemy_" .. soundfont
10897 replication_envext.volume = 4.47213595499958 / (dist / 5)
10898 else
10899 soundfont = "friendly_" .. soundfont
10900 replication_envext.volume = 1.4142135623730951 / (dist / 5)
10901 end
10902 if soundfont == "enemy_wood" then
10903 replication_envext.volume = 3.1622776601683795 / (dist / 5)
10904 end
10905 if speedspring.p <= 15 then
10906 soundfont = soundfont .. "walk"
10907 else
10908 soundfont = soundfont .. "run"
10909 end
10910 globalsound.play(soundfont, replication_envext.volume, 1, ext_env.torso)
10911 end
10912 end
10913 end
10914 p.pos = newpcenter.p + stepradius * (p.pos - newpcenter.p).unit
10915 l.pos = target
10916 p, l = l, p
10917 end
10918 if levelofdetail >= 2 then
10919 local accel = ext_env.velspring.v
10920 local equipp = equipspring.p
10921 local aim = anglesyx(lookx, looky)
10922 speedspring.t = rootvel.magnitude / loltimescale
10923 local speedp = speedspring.p / 8
10924 speedp = speedp < 1 and speedp or 1
10925 local raise = steplist.remp * (2 - steplist.remp / stepradius)
10926 raise = raise < 0 and 0 or raise
10927 local torsocf = direct(basecf, forward, aim, torsoaim * sprintp * (1 - stancep) * equipp) * angles(0, raise * p.torsoswing, 0) * cf(0, -3, 0)
10928 torsocf = direct(nc, v3(0, 1, 0), v3(0, 100, 0) + accel, 1 - pronep) * (torsocf - torsocf.p) * cf(0, 3, 0) + torsocf.p + v3(0, raise * speedp / 16, 0)
10929 self.torsocf = torsocf
10930 ext_env.torso.CFrame = torsocf
10931 if levelofdetail >= 3 then
10932 p.weld.C0 = jointleg(1, 1.5, p.hipcf, torsocf:inverse() * p.pos, pronep * tau / 5 * p.angm) * p.legcf
10933 l.weld.C0 = jointleg(1, 1.5, l.hipcf, torsocf:inverse() * (l.pos + raise * speedp / 3 * v3(0, 1, 0)), pronep * tau / 5 * l.angm) * l.legcf
10934 local aimp = aimspring.p
10935 local neckcf = torsocf:inverse() * direct(torsocf * cf(0, 0.825, 0), forward, aim) * angles(0, 0, (1 - aimp) * weaponheadaimangle) * cf(0, 0.675, 0)
10936 ext_env.neck.C0 = neckcf
10937 if muzzlelight then
10938 muzzlelight.Brightness = muzzlespring.p
10939 end
10940 if weapon then
10941 if weapontype == "gun" then
10942 local pivot = cframe.interpolate(weaponaimpivot, weaponpivot, aimp)
10943 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * cf(transkickspring.p) * cframe.fromaxisangle(rotkickspring.p) * weaponrotoffset
10944 local guncf = cframe.interpolate(weapondrawcf, angles(raise / 10, raise * p.torsoswing, 0) * cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
10945 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10946 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10947 mainweld.C0 = guncf
10948 elseif weapontype == "KNIFE" then
10949 local pivot = weaponpivot
10950 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * weaponrotoffset * cframe.interpolate(nc, weaponstabcf, stabspring.p)
10951 local guncf = cframe.interpolate(weapondrawcf, cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
10952 if weaponmodule.dualhand then
10953 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10954 else
10955 lsh.C0 = jointarm(1, 1.5, leftshcf, weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10956 end
10957 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10958 mainweld.C0 = guncf
10959 end
10960 end
10961 end
10962 end
10963 end
10964 debug.profileend()
10965 end
10966 if state.lookangles then
10967 self.setlookangles(state.lookangles)
10968 end
10969 if state.stance then
10970 self.setstance(state.stance)
10971 end
10972 if state.sprint then
10973 self.setsprint(state.sprint)
10974 end
10975 if state.aim then
10976 self.setaim(state.aim)
10977 end
10978 if state.weapon then
10979 local module = ffc(modulestore, state.weapon)
10980 local newweapon = ffc(thirdpmstore, state.weapon)
10981 if module and newweapon then
10982 self.equip(require(module), newweapon)
10983 else
10984 print("Couldn't find a 3rd person weapon")
10985 end
10986 end
10987 return self
10988 end
10989 local function getupdater(player)
10990 if player and upinfos then
10991 if upinfos[player] == nil then
10992 upinfos[player] = false
10993 local updater = loadplayer(player)
10994 if updater then
10995 upinfos[player] = {
10996 updater = updater,
10997 player = player,
10998 lastupdate = 0,
10999 lastlevel = 0
11000 }
11001 return updater
11002 else
11003 upinfos[player] = nil
11004 return nil
11005 end
11006 elseif upinfos[player] ~= false then
11007 return upinfos[player].updater
11008 end
11009 end
11010 end
11011 replication.getupdater = getupdater
11012 network:add("stance", function(player, stance)
11013 local updater = getupdater(player)
11014 if updater then
11015 updater.setstance(stance)
11016 end
11017 end)
11018 network:add("sprint", function(player, sprint)
11019 local updater = getupdater(player)
11020 if updater then
11021 updater.setsprint(sprint)
11022 end
11023 end)
11024 network:add("lookangles", function(player, lookangles)
11025 local updater = getupdater(player)
11026 if updater then
11027 updater.setlookangles(lookangles)
11028 end
11029 end)
11030 network:add("aim", function(player, aim)
11031 local updater = getupdater(player)
11032 if updater then
11033 updater.setaim(aim)
11034 end
11035 end)
11036 network:add("stab", function(player)
11037 local updater = getupdater(player)
11038 if updater then
11039 updater.stab()
11040 end
11041 end)
11042 network:add("bodyparts", function(player, bodyparts)
11043 local updater = getupdater(player)
11044 if updater then
11045 updater.updatecharacter(bodyparts)
11046 end
11047 end)
11048 network:add("equipknife", function(player, weapon, camodata)
11049 local updater = getupdater(player)
11050 if updater then
11051 local module = ffc(modulestore, weapon)
11052 local newweapon = ffc(thirdpmstore, weapon)
11053 if module and newweapon then
11054 updater.equipknife(require(module), newweapon:Clone(), camodata)
11055 else
11056 updater.equipknife(nil)
11057 end
11058 end
11059 end)
11060 network:add("equip", function(player, weapon, camodata, attachments)
11061 local updater = getupdater(player)
11062 if updater then
11063 local replicatedattach
11064 if attachments then
11065 local attachinfo = require(game:GetService("ReplicatedStorage").AttachmentModules.Info)
11066 for i, v in next, attachments, nil do
11067 if attachinfo[v] and attachinfo[v].replicate then
11068 replicatedattach = {}
11069 replicatedattach[i] = v
11070 end
11071 end
11072 end
11073 local module = ffc(modulestore, weapon)
11074 local newweapon = ffc(thirdpmstore, weapon)
11075 if module and newweapon then
11076 updater.equip(require(module), newweapon:Clone(), camodata, replicatedattach)
11077 else
11078 updater.equip(nil)
11079 end
11080 end
11081 end)
11082 network:add("rootframes", function(player, newframes)
11083 local updater = getupdater(player)
11084 if updater then
11085 updater.addrootframes(newframes)
11086 end
11087 end)
11088 network:add("newparticle", function(props)
11089 particle.new(props)
11090 end)
11091 network:add("getclientteam", function(servercolor)
11092 local clientcolor = localplayer.TeamColor
11093 network:send("g" .. "e" .. "t" .. "c" .. "l" .. "i" .. "e" .. "n" .. "t" .. "t" .. "e" .. "a" .. "m", localplayer, clientcolor)
11094 end)
11095 local dot = Vector3.new().Dot
11096 network:add("newgrenade", function(player, grenade, grenadeanim)
11097 if not run.onstep then
11098 return
11099 end
11100 local data = require(game.ReplicatedStorage.GunModules[grenade])
11101 local flyingnade = game.ReplicatedStorage.GunModels[grenade].Trigger:Clone()
11102 local ignorelist = {
11103 camera.currentcamera,
11104 char.character,
11105 workspace.Ignore
11106 }
11107 local lasttrailt = 0
11108 local lasttrailpos = nv
11109 local offset = nv
11110 local lastbounce, exploded
11111 local indicator = ffc(flyingnade, "Indicator")
11112 flyingnade.Parent = camera.currentcamera
11113 flyingnade.Anchored = true
11114 flyingnade.Trail.Enabled = true
11115 if indicator then
11116 if player.TeamColor ~= localplayer.TeamColor then
11117 indicator.Enemy.Visible = true
11118 else
11119 indicator.Friendly.Visible = true
11120 end
11121 end
11122 local GrenadeTypes = {
11123 Frag = function(position)
11124 local range = player:DistanceFromCharacter(position)
11125 if ffc(flyingnade, "Fire") then
11126 if range <= 50 then
11127 sound.play("fragClose", 2, 1, flyingnade, true)
11128 elseif range <= 200 then
11129 sound.play("fragMed", 3, 1, flyingnade, true)
11130 elseif range > 200 then
11131 sound.play("fragFar", 3, 1, flyingnade, true)
11132 end
11133 end
11134 local Explosion = new("Explosion")
11135 Explosion.Position = position
11136 Explosion.BlastRadius = data.blastradius
11137 Explosion.BlastPressure = 0
11138 Explosion.DestroyJointRadiusPercent = 0
11139 Explosion.Parent = workspace
11140 end,
11141 Smoke = function(position)
11142 print("whoosh")
11143 local maxgrowth = UDim2.new(20, 0, 20, 0)
11144 local growthfactor = 5
11145 local time = 20
11146 for i = 1, 35 do
11147 do
11148 local smoke = repstore:FindFirstChild("Effects"):FindFirstChild("SmokeTest"):Clone()
11149 local billboard = smoke:FindFirstChild("BillboardGui")
11150 local images = billboard:GetChildren()
11151 local vel = vector.random(0.5, 1.5)
11152 vel = vel + v3(0, 2, 0)
11153 smoke.Parent = workspace:FindFirstChild("Ignore")
11154 particle.new({
11155 position = position,
11156 cancollide = true,
11157 particlesonly = true,
11158 nopenetration = true,
11159 velocity = vel,
11160 acceleration = v3(0, -0.25, 0),
11161 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
11162 if not self.stopmotion then
11163 local vel = self.velocity
11164 local newpos = pos + 0.1 * norm
11165 local nvel = norm:Dot(vel) * norm
11166 self.position = newpos
11167 self.velocity = -nvel
11168 if nvel.magnitude < 0.2 then
11169 self.stopmotion = true
11170 end
11171 end
11172 end,
11173 onstep = function(part, dt)
11174 if billboard and billboard.Size.X.Scale < maxgrowth.X.Scale and billboard.Size.Y.Scale < maxgrowth.Y.Scale then
11175 billboard.Size = billboard.Size + UDim2.new(growthfactor * dt, 0, growthfactor * dt, 0)
11176 for i, image in next, images, nil do
11177 if image and 0 < image.ImageTransparency then
11178 image.ImageTransparency = image.ImageTransparency - 1.5 * dt
11179 end
11180 end
11181 end
11182 smoke.Position = part.position
11183 end,
11184 onremove = function()
11185 spawn(function()
11186 local disconnect
11187 disconnect = run.onstep:connect(function(dt)
11188 if billboard and billboard.Size.X.Scale > 0 and 0 < billboard.Size.Y.Scale then
11189 billboard.Size = billboard.Size - UDim2.new(growthfactor * 2 * dt, 0, growthfactor * 2 * dt, 0)
11190 for i, image in next, images, nil do
11191 if image and image.ImageTransparency < 1 then
11192 image.ImageTransparency = image.ImageTransparency + 3 * dt
11193 end
11194 end
11195 else
11196 disconnect()
11197 smoke:Destroy()
11198 end
11199 end)
11200 end)
11201 end,
11202 life = time
11203 })
11204 end
11205 end
11206 end
11207 }
11208 local function explode(position)
11209 GrenadeTypes[data.grenadetype and GrenadeTypes[data.grenadetype] and data.grenadetype or "Frag"](position)
11210 trash.remove(flyingnade)
11211 end
11212 local st = grenadeanim.time
11213 local dst = st - tick()
11214 local lasttime = st
11215 local lastparticle = tick()
11216 local stop
11217 stop = run.onstep:connect(function(dt)
11218 local realtime = tick()
11219 local time = realtime + dst * (st + grenadeanim.blowuptime - realtime) / (grenadeanim.blowuptime + dst)
11220 if flyingnade and grenadeanim then
11221 local i = grenadeanim.curi
11222 local frames = grenadeanim.frames
11223 local frame = frames[i]
11224 local nextframe = frames[i + 1]
11225 if nextframe and time > st + nextframe.t0 then
11226 grenadeanim.curi = i + 1
11227 frame = nextframe
11228 end
11229 local t = time - (st + frame.t0)
11230 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
11231 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
11232 local glassbreaks = frame.glassbreaks
11233 for j = 1, #glassbreaks do
11234 local glassbreak = glassbreaks[j]
11235 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
11236 effects:breakwindow(glassbreak.part, nil, nil, v3(), true, true)
11237 end
11238 end
11239 flyingnade.CFrame = rot + pos
11240 if indicator then
11241 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
11242 end
11243 if time > st + grenadeanim.blowuptime then
11244 explode(pos)
11245 stop()
11246 end
11247 end
11248 lasttime = time
11249 end)
11250 return stop
11251 end)
11252 local lastid = 0
11253 local suppressionmult, normalizesuppression
11254 do
11255 local max = 1.25
11256 local min = 0.5
11257 local recspeed = 1
11258 local normspeed = 0.125
11259 local e = 2.718281828459045
11260 local sm0 = max
11261 local t0 = tick()
11262 function suppressionmult()
11263 local t = tick() - t0
11264 return e ^ (-t / recspeed) * (max - sm0) + sm0
11265 end
11266 function normalizesuppression()
11267 local sm = suppressionmult()
11268 sm0 = (sm - min) / e ^ normspeed + min
11269 t0 = tick()
11270 end
11271 end
11272 network:add("newbullet", function(data)
11273 local player = data.player
11274 local position = data.firepos
11275 local velocity = data.velocity
11276 local pitch = data.pitch
11277 local volume = data.volume
11278 local id = data.id
11279 local bulletcolor = data.bulletcolor
11280 local penetrationdepth = data.penetrationdepth
11281 local suppression = data.suppression
11282 local hideflash = data.hideflash
11283 local hideminimap = data.hideminimap
11284 local hiderange = data.hiderange
11285 local pingdata = data.pingdata
11286 local updater = getupdater(player)
11287 if updater and id ~= lastid then
11288 updater.kickweapon(hideflash, pitch, volume)
11289 lastid = id
11290 end
11291 if not hideminimap or hideminimap and hiderange > (position - camera.cframe.p).Magnitude then
11292 hud:fireradar(player, hideminimap, pingdata)
11293 end
11294 local physignore = {
11295 camera.currentcamera,
11296 workspace.Ignore
11297 }
11298 for i, v in next, game:GetService("Players"):GetPlayers() do
11299 if v.TeamColor == player.TeamColor then
11300 physignore[#physignore + 1] = v.Character
11301 end
11302 end
11303 particle.new({
11304 position = position,
11305 velocity = velocity,
11306 acceleration = lolgravity,
11307 physicsignore = physignore,
11308 color = bulletcolor,
11309 size = 0.2,
11310 bloom = 0.005,
11311 brightness = 400,
11312 life = 1,
11313 visualorigin = updater and updater.getweaponpos(),
11314 penetrationdepth = penetrationdepth,
11315 thirdperson = true,
11316 onstep = function(part, dt)
11317 if player.TeamColor ~= localplayer.TeamColor then
11318 local vel = part.velocity
11319 local dpos = dt * vel
11320 local pos = part.position - dpos
11321 local headpos = camera.cframe.p
11322 local d = dot(headpos - pos, dpos) / dot(dpos, dpos)
11323 if d > 0 and d < 1 then
11324 local dist = (pos + d * dpos - headpos).magnitude
11325 dist = dist < 2 and 2 or dist
11326 local s = suppressionmult() * suppression / (512 * dist) * vel.magnitude
11327 network:send("suppressionassist", player, s)
11328 if dist < 128 then
11329 if vel.magnitude > 2900 then
11330 sound.play("crackBig", 16 / dist)
11331 elseif dist <= 2 then
11332 sound.play("crackSmall", 8)
11333 else
11334 sound.play("whizz", 2 / dist)
11335 end
11336 end
11337 camera:suppress(vector.random(s, s))
11338 normalizesuppression()
11339 end
11340 end
11341 end,
11342 ontouch = function(self, hit, pos, norm, exit, exitnorm)
11343 if hit.Anchored and hit.CanCollide then
11344 if hit.Name == "Window" then
11345 effects:breakwindow(hit, pos, norm, self.velocity, v3(), true)
11346 end
11347 effects:bullethit(hit, pos, norm, exit, exitnorm, v3(), true, true)
11348 end
11349 local dist = (pos - camera.cframe.p).magnitude
11350 local soundfont = materialhitsound[hit.Material.Name]
11351 if dist < 64 and soundfont then
11352 sound.play(soundfont, 3 / dist)
11353 end
11354 end
11355 })
11356 end)
11357 local rendert = {}
11358 local nextcast = tick()
11359 local castrate = 10
11360 local radius = 4
11361 local ptos = CFrame.new().pointToObjectSpace
11362 local tan = math.tan
11363 local pi = math.pi
11364 local radius = 6
11365 function replication.playerangles(player)
11366 local updater = getupdater(player)
11367 if updater then
11368 return updater.getlookangles()
11369 else
11370 return v3()
11371 end
11372 end
11373 local highms = 2
11374 local lowms = 1
11375 function replication.sethighms(val)
11376 highms = val
11377 end
11378 function replication.setlowms(val)
11379 lowms = val
11380 end
11381 function replication.step(dt)
11382 local time = tick()
11383 local orderedupdaters = {}
11384 for player, upinfo in next, upinfos, nil do
11385 if player.Parent then
11386 if upinfo and upinfo.updater then
11387 orderedupdaters[#orderedupdaters + 1] = upinfo
11388 else
11389 end
11390 else
11391 print("PLAYER IS GONE")
11392 upinfos[player] = nil
11393 removecharacterhash(player)
11394 end
11395 end
11396 for i = 1, #orderedupdaters do
11397 local upinfo = orderedupdaters[i]
11398 local updater = upinfo.updater
11399 if updater and updater.rootpart and updater.torso then
11400 local pos = updater.rootpart:GetRenderCFrame().p
11401 upinfo.onscreen = camera.screencull.sphere(pos, radius)
11402 else
11403 upinfo.onscreen = false
11404 end
11405 end
11406 table.sort(orderedupdaters, function(a, b)
11407 if a.onscreen == b.onscreen then
11408 if a.lastlevel == b.lastlevel then
11409 return a.lastlevel < b.lastlevel
11410 else
11411 return a.lastupdate < b.lastupdate
11412 end
11413 else
11414 return a.onscreen
11415 end
11416 end)
11417 local start0 = tick()
11418 local n = 0
11419 while n < #orderedupdaters and tick() - start0 < highms / 1000 do
11420 n = n + 1
11421 if orderedupdaters[n].onscreen then
11422 orderedupdaters[n].updater.step(3, true)
11423 orderedupdaters[n].lastupdate = time
11424 orderedupdaters[n].lastlevel = 3
11425 else
11426 n = n - 1
11427 break
11428 end
11429 end
11430 while n < #orderedupdaters and tick() - start0 < (highms + lowms) / 1000 do
11431 n = n + 1
11432 orderedupdaters[n].updater.step(2, true)
11433 orderedupdaters[n].lastupdate = time
11434 orderedupdaters[n].lastlevel = 2
11435 end
11436 for i = n + 1, #orderedupdaters do
11437 if 2 * (highms + lowms) / 1000 < tick() - start0 then
11438 break
11439 end
11440 orderedupdaters[i].updater.step(1, false)
11441 orderedupdaters[i].lastupdate = time
11442 orderedupdaters[n].lastlevel = 1
11443 end
11444 if time - lastsent > 0.05 then
11445 lastsent = time
11446 network:send("l" .. "o" .. "o" .. "k" .. "a" .. "n" .. "g" .. "l" .. "e" .. "s", camera.angles)
11447 end
11448 end
11449 local players = game:GetService("Players"):GetPlayers()
11450 for i = 1, #players do
11451 local player = players[i]
11452 if player ~= localplayer then
11453 getupdater(player)
11454 end
11455 end
11456end
11457print("Requiring menu module")
11458require(script.Parent.UIScript)({
11459 vector = vector,
11460 cframe = cframe,
11461 network = network,
11462 playerdata = playerdata,
11463 trash = trash,
11464 utility = utility,
11465 event = event,
11466 sequencer = sequencer,
11467 physics = physics,
11468 particle = particle,
11469 sound = sound,
11470 effects = effects,
11471 tween = tween,
11472 animation = animation,
11473 input = input,
11474 char = char,
11475 camera = camera,
11476 chat = chat,
11477 hud = hud,
11478 notify = notify,
11479 leaderboard = leaderboard,
11480 replication = replication,
11481 menu = menu,
11482 roundsystem = roundsystem,
11483 run = run,
11484 gamelogic = gamelogic,
11485 timemod = timemod,
11486 updateversion = updateversion,
11487 updatemsg = updatemsg
11488})
11489print("Loading roundsystem module client")
11490wait(0.03333333333333333)
11491print("waiting beginning")
11492do
11493 local rtype = game.IsA
11494 local next = next
11495 local new = Instance.new
11496 local wfc = game.WaitForChild
11497 local ffc = game.FindFirstChild
11498 local getchildren = game.GetChildren
11499 local workspace = game.Workspace
11500 local cf = CFrame.new
11501 local vtws = CFrame.new().vectorToWorldSpace
11502 local angles = CFrame.Angles
11503 local ud2 = UDim2.new
11504 local color = Color3.new
11505 local bcolor = BrickColor.new
11506 local v3 = Vector3.new
11507 local debris = game:GetService("Debris")
11508 local guiservice = game:GetService("GuiService")
11509 local ray = Ray.new
11510 local raycast = workspace.FindPartOnRayWithIgnoreList
11511 local ceil = math.ceil
11512 local floor = math.floor
11513 local repstore = wfc(game, "ReplicatedStorage")
11514 local settings = wfc(repstore, "ServerSettings")
11515 local countdown = wfc(settings, "Countdown")
11516 local timer = wfc(settings, "Timer")
11517 local maxscore = wfc(settings, "MaxScore")
11518 local gscore = wfc(settings, "GhostScore")
11519 local pscore = wfc(settings, "PhantomScore")
11520 local showresult = wfc(settings, "ShowResults")
11521 local setquote = wfc(settings, "Quote")
11522 local winner = wfc(settings, "Winner")
11523 local gamemode = wfc(settings, "GameMode")
11524 local player = game:GetService("Players").LocalPlayer
11525 local pgui = wfc(player, "PlayerGui")
11526 local main = wfc(pgui, "MainGui")
11527 local countfr = wfc(main, "CountDown")
11528 local teamname = wfc(countfr, "TeamName")
11529 local title = wfc(countfr, "Title")
11530 local number = wfc(countfr, "Number")
11531 local tip = wfc(countfr, "Tip")
11532 local gamegui = wfc(main, "GameGui")
11533 local roundfr = wfc(gamegui, "Round")
11534 local scorefr = wfc(roundfr, "Score")
11535 local roundmode = wfc(roundfr, "GameMode")
11536 local ghostfr = wfc(scorefr, "Ghosts")
11537 local phantomfr = wfc(scorefr, "Phantoms")
11538 local counting = wfc(scorefr, "Time")
11539 local endfr = wfc(main, "EndMatch")
11540 local quote = wfc(endfr, "Quote")
11541 local result = wfc(endfr, "Result")
11542 local gmode = wfc(endfr, "Mode")
11543 local servertime = 0
11544 local lasttime = 0
11545 roundsystem.lock = false
11546 local killzone = v3()
11547 local killzonedb
11548 function roundsystem:updatekillzone(map)
11549 local killpart = ffc(map, "Killzone")
11550 killzonedb = false
11551 if killpart then
11552 killzone = killpart.Position
11553 else
11554 killzone = v3()
11555 end
11556 end
11557 function roundsystem:checkkillzone(rootpart, pos)
11558 if pos.Y < killzone.Y and not killzonedb then
11559 killzonedb = true
11560 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -100, "F" .. "a" .. "l" .. "l" .. "i" .. "n" .. "g", rootpart, pos, pos + v3(0, 1000, 0))
11561 end
11562 end
11563 local function spawnplayer()
11564 menu:roundstartspawn()
11565 end
11566 local tweentransparency = function(obj, index, new, t)
11567 spawn(function()
11568 local cur = obj[index]
11569 for i = cur, new + t, t do
11570 obj[index] = i
11571 wait(0.03333333333333333)
11572 end
11573 end)
11574 end
11575 function hud:updateteam()
11576 roundmode.Text = gamemode.Value
11577 if player.TeamColor == game.Teams.Phantoms.TeamColor then
11578 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
11579 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
11580 else
11581 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
11582 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
11583 end
11584 end
11585 local function updatescore()
11586 local ud2 = UDim2.new
11587 ghostfr.Percent.Size = ud2(gscore.Value / maxscore.Value, 0, 1, 0)
11588 ghostfr.Point.Text = gscore.Value
11589 phantomfr.Percent.Size = ud2(pscore.Value / maxscore.Value, 0, 1, 0)
11590 phantomfr.Point.Text = pscore.Value
11591 end
11592 local function count()
11593 roundsystem.lock = true
11594 tip.Text = input.consoleon and "Press ButtonSelect to return to menu" or "Press F5 to return to menu"
11595 if timer.Value ~= 10 or not menu:isdeployed() then
11596 end
11597 if menu:isdeployed() and char.health and char.health > 0 then
11598 teamname.Text = player.TeamColor == game.Teams.Ghosts.TeamColor and "Ghosts" or "Phantoms"
11599 teamname.Visible = true
11600 teamname.TextColor3 = player.TeamColor.Color
11601 countfr.Visible = true
11602 number.FontSize = 9
11603 number.Text = timer.Value
11604 for i = 9, 7, -1 do
11605 number.FontSize = i
11606 wait(0.03333333333333333)
11607 end
11608 if timer.Value == 0 then
11609 wait(1)
11610 roundsystem.lock = false
11611 wait(2)
11612 countfr.Visible = false
11613 else
11614 countfr.BackgroundTransparency = 0.5
11615 number.TextTransparency = 0
11616 title.TextTransparency = 0
11617 title.TextStrokeTransparency = 0.5
11618 end
11619 end
11620 end
11621 local function matchclock()
11622 local seconds = timer.Value % 60
11623 if seconds < 10 then
11624 seconds = "0" .. seconds
11625 end
11626 counting.Text = floor(timer.Value / 60) .. ":" .. seconds
11627 end
11628 local function timerchange()
11629 if countdown.Value then
11630 counting.Text = "COUNTDOWN"
11631 count()
11632 else
11633 if not showresult.Value then
11634 roundsystem.lock = false
11635 end
11636 countfr.Visible = false
11637 matchclock()
11638 end
11639 end
11640 local function setresult()
11641 if showresult.Value then
11642 roundsystem.lock = true
11643 quote.Text = setquote.Value
11644 endfr.Visible = true
11645 gmode.Text = gamemode.Value
11646 if winner.Value == player.TeamColor then
11647 result.Text = "VICTORY"
11648 result.TextColor = bcolor("Bright green")
11649 elseif winner.Value == bcolor("Black") then
11650 result.Text = "STALEMATE"
11651 result.TextColor = bcolor("Bright orange")
11652 else
11653 result.Text = "DEFEAT"
11654 result.TextColor = bcolor("Bright red")
11655 end
11656 else
11657 endfr.Visible = false
11658 end
11659 end
11660 if countdown.Value then
11661 count()
11662 end
11663 setresult()
11664 timer.Changed:connect(timerchange)
11665 gscore.Changed:connect(updatescore)
11666 pscore.Changed:connect(updatescore)
11667 showresult.Changed:connect(setresult)
11668 updatescore()
11669end
11670print("Loading run module")
11671do
11672 local cf = CFrame.new
11673 local v3 = Vector3.new
11674 run.time = tick()
11675 run.dt = 0.016666666666666666
11676 run.framerate = 60
11677 run.onstep = {}
11678 run.onthink = {}
11679 local ffc = game.FindFirstChild
11680 local renderstepped = game:GetService("RunService").RenderStepped
11681 local heartbeat = game:GetService("RunService").Heartbeat
11682 local wait = renderstepped.wait
11683 local p = game:GetService("Players").LocalPlayer
11684 local daytime = game.ReplicatedStorage.ServerSettings.TimeOfDay
11685 local gundrop = workspace.Ignore.GunDrop
11686 local rendertime = 0
11687 local heartbeattime = 0
11688 local eventdb = false
11689 local engine = {
11690 {
11691 func = input.step,
11692 name = "input"
11693 },
11694 {
11695 func = char.step,
11696 name = "char"
11697 },
11698 {
11699 func = camera.step,
11700 name = "camera"
11701 },
11702 {
11703 func = particle.step,
11704 name = "particle"
11705 },
11706 {
11707 func = char.animstep,
11708 name = "char.ani"
11709 },
11710 {
11711 func = tween.step,
11712 name = "tween"
11713 },
11714 {
11715 func = hud.step,
11716 name = "hud"
11717 },
11718 {
11719 func = menu.step,
11720 name = "menu"
11721 },
11722 {
11723 func = notify.step,
11724 name = "notify"
11725 }
11726 }
11727 local heartbeatengine = {
11728 {
11729 func = replication.step,
11730 name = "replication"
11731 },
11732 {
11733 func = hud.beat,
11734 name = "hudbeat"
11735 }
11736 }
11737 local mainlogic = {
11738 {
11739 func = function()
11740 if char.health and char.health > 0 and gamelogic.currentgun then
11741 network:send("p" .. "i" .. "n" .. "g" .. "c" .. "h" .. "e" .. "c" .. "k", tick(), char.rootpart.Position)
11742 end
11743 game.Lighting:SetMinutesAfterMidnight(daytime.Value)
11744 end,
11745 name = "pingcheck",
11746 interval = 0.15,
11747 lasttime = run.time
11748 },
11749 {
11750 func = function()
11751 local stuff = gundrop:GetChildren()
11752 local dist = 8
11753 hud:gundrop(false)
11754 for i = 1, #stuff do
11755 local v = stuff[i]
11756 if v.Name == "Dropped" and ffc(v, "Slot1") then
11757 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
11758 if dist > diff then
11759 dist = diff
11760 if ffc(v, "Gun") then
11761 hud:gundrop(v, v.Gun.Value)
11762 elseif ffc(v, "Knife") then
11763 hud:gundrop(v, v.Knife.Value)
11764 end
11765 end
11766 end
11767 end
11768 end,
11769 name = "dropcheck",
11770 interval = 0.2,
11771 lasttime = run.time
11772 },
11773 {
11774 func = function()
11775 local map = ffc(workspace, "Map")
11776 local stuff = gundrop:GetChildren()
11777 local capdist = 15
11778 local flagdist = 8
11779 local tagdist = 6
11780 hud:capping(false)
11781 if map then
11782 local agmp = ffc(map, "AGMP")
11783 if agmp then
11784 local stuff = agmp:GetChildren()
11785 for i = 1, #stuff do
11786 local v = stuff[i]
11787 if ffc(v, "IsCapping") and v.IsCapping.Value and v.TeamColor.Value ~= p.TeamColor and capdist > (v.Base.Position - char.rootpart.Position).magnitude and v.Base.Position.Y < char.rootpart.Position.Y then
11788 hud:capping(v, v.CapPoint.Value)
11789 end
11790 end
11791 end
11792 for i = 1, #stuff do
11793 local v = stuff[i]
11794 if v.Name == "FlagDrop" and ffc(v, "Base") then
11795 local diff = (v.Base.Position - char.rootpart.Position).magnitude
11796 if flagdist > diff then
11797 if v.TeamColor.Value == p.TeamColor and ffc(v, "IsCapping") and v.IsCapping.Value then
11798 hud:capping(v, v.CapPoint.Value, "ctf")
11799 end
11800 network:send("captureflag", v.TeamColor.Value)
11801 end
11802 elseif v.Name == "DogTag" and ffc(v, "Base") then
11803 local diff = (v.Base.Position - char.rootpart.Position).magnitude
11804 if tagdist > diff then
11805 network:send("capturedogtag", v)
11806 end
11807 end
11808 end
11809 end
11810 end,
11811 name = "flagcheck",
11812 interval = 0.1,
11813 lasttime = run.time
11814 }
11815 }
11816 local fireonstep = event.new(run.onstep)
11817 local fireonthink = event.new(run.onthink)
11818 function run.wait()
11819 wait(renderstepped)
11820 end
11821 renderstepped:connect(function()
11822 local asdtick = tick()
11823 local newtime = tick()
11824 run.dt = newtime - run.time
11825 run.time = newtime
11826 run.framerate = 0.95 * run.framerate + 0.05 / run.dt
11827 for i = 1, #engine do
11828 debug.profilebegin(engine[i].name)
11829 local pass, err = pcall(engine[i].func, run.dt)
11830 debug.profileend()
11831 if not pass then
11832 warn(err)
11833 end
11834 end
11835 debug.profilebegin("onstep")
11836 fireonstep(run.dt)
11837 debug.profileend()
11838 rendertime = rendertime * 0.9 + 0.1 * (tick() - asdtick)
11839 end)
11840 heartbeat:connect(function()
11841 local asdtick = tick()
11842 for i = 1, #heartbeatengine do
11843 debug.profilebegin(heartbeatengine[i].name)
11844 local pass, err = pcall(heartbeatengine[i].func, run.dt)
11845 if not pass then
11846 warn(err)
11847 end
11848 debug.profileend()
11849 end
11850 for i = 1, #mainlogic do
11851 local v = mainlogic[i]
11852 if run.time > v.lasttime + v.interval then
11853 v.func(run.dt)
11854 v.lasttime = v.lasttime + v.interval
11855 end
11856 end
11857 heartbeattime = heartbeattime * 0.9 + 0.1 * (tick() - asdtick)
11858 end)
11859 game:GetService("RunService").Stepped:connect(function()
11860 debug.profilebegin("onthink")
11861 fireonthink()
11862 debug.profileend()
11863 end)
11864end
11865print("Loading game logic module")
11866do
11867 local ffc = game.FindFirstChild
11868 local debris = game.Debris
11869 local new = Instance.new
11870 local rep = game.ReplicatedStorage
11871 local rs = game:GetService("RunService")
11872 local modulestore = rep.GunModules
11873 local modelstore = rep.GunModels
11874 local player = game:GetService("Players").LocalPlayer
11875 local pgui = player.PlayerGui
11876 local gunlist = {}
11877 gunnumber = 1
11878 local attlist = {}
11879 local curknife, dived, aiming, equipping, prevgun, grenade, spotting, inspecting, sprintdisable
11880 local nextjump = 0
11881 gamelogic.currentgun = nil
11882 gamelogic.gammo = 0
11883 testing = pgui.teston.Value
11884 function gamelogic.setsprintdisable(x)
11885 sprintdisable = x
11886 end
11887 local function switch(z)
11888 if not equipping and gamelogic.currentgun then
11889 gunnumber = z == "one" and 1 or z == "two" and 2 or (gunnumber + z - 1) % #gunlist + 1
11890 if gunlist[gunnumber] and gunlist[gunnumber] ~= gamelogic.currentgun then
11891 gamelogic.currentgun = gunlist[gunnumber]
11892 gamelogic.currentgun:setequipped(true)
11893 equipping = true
11894 wait(0.4)
11895 equipping = false
11896 end
11897 end
11898 end
11899 local function loadmodules(primdata, sidedata, knifedata, grenadedata)
11900 char:loadarms(rep.Character["Left Arm"]:Clone(), rep.Character["Right Arm"]:Clone(), "Arm", "Arm")
11901 for i = 1, #gunlist do
11902 gunlist[i] = nil
11903 attlist[i] = nil
11904 end
11905 gunnumber = 1
11906 local vprim = ffc(modulestore, primdata.Name)
11907 if vprim then
11908 local v = vprim:Clone()
11909 gunlist[1] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[primdata.Name]:Clone(), false, false, primdata.Attachments, primdata.Camo, 1)
11910 end
11911 local vside = ffc(modulestore, sidedata.Name)
11912 if vside then
11913 local v = vside:Clone()
11914 gunlist[2] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[sidedata.Name]:Clone(), false, false, sidedata.Attachments, sidedata.Camo, 2)
11915 end
11916 local knife = knifedata.Name or "KNIFE"
11917 local vknife = ffc(modulestore, knife)
11918 if vknife then
11919 local v = vknife:Clone()
11920 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), knifedata.Camo)
11921 end
11922 gamelogic.currentgun = gunlist[gunnumber]
11923 gamelogic.gammo = 3
11924 local grenade = grenadedata.Name
11925 if grenade then
11926 currentgrenade = grenade
11927 end
11928 gamelogic.currentgun = gunlist[gunnumber]
11929 gamelogic.gammo = 3
11930 end
11931 gamelogic.loadmodules = loadmodules
11932 local function swapknife(knife, camodata)
11933 local vknife = ffc(modulestore, knife)
11934 if vknife then
11935 local v = vknife:Clone()
11936 equipping = true
11937 if gamelogic.currentgun ~= curknife then
11938 curknife:destroy()
11939 else
11940 gamelogic.currentgun:setequipped(false, nil, true)
11941 end
11942 wait(0.4)
11943 curknife = nil
11944 wait(0.1)
11945 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), camodata)
11946 gamelogic.currentgun = curknife
11947 gamelogic.currentgun:setequipped(true)
11948 wait(0.4)
11949 equipping = false
11950 end
11951 end
11952 local function swapgun(gun, mag, spare, attachdata, camodata, gunn, ggequip)
11953 local vgun = ffc(modulestore, gun)
11954 if vgun then
11955 local v = vgun:Clone()
11956 equipping = true
11957 if not gamelogic.currentgun then
11958 return
11959 end
11960 gamelogic.currentgun:setequipped(false, true)
11961 if not ggequip then
11962 wait(0.4)
11963 end
11964 if gunlist[gunn] then
11965 gunlist[gunn]:remove()
11966 gunlist[gunn] = nil
11967 end
11968 if not ggequip then
11969 wait(0.4)
11970 end
11971 gunlist[gunn] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[gun]:Clone(), mag, spare, attachdata, camodata, gunn)
11972 gamelogic.currentgun = gunlist[gunn]
11973 gamelogic.currentgun:setequipped(true)
11974 if not ggequip then
11975 wait(0.4)
11976 end
11977 equipping = false
11978 end
11979 end
11980 local function removeweapon(index)
11981 if gunlist[index] then
11982 gunlist[index]:remove()
11983 gunlist[index] = nil
11984 end
11985 end
11986 input.mouse.onbuttondown:connect(function(button)
11987 if not gamelogic.currentgun or equipping then
11988 return
11989 end
11990 if button == "left" and gamelogic.currentgun.shoot then
11991 if gamelogic.currentgun.inspecting() then
11992 gamelogic.currentgun:reloadcancel(true)
11993 inspecting = false
11994 end
11995 if gamelogic.currentgun.type == "KNIFE" then
11996 gamelogic.currentgun:shoot(false, "stab1")
11997 else
11998 gamelogic.currentgun:shoot(true)
11999 end
12000 elseif button == "right" then
12001 if gamelogic.currentgun.inspecting() then
12002 gamelogic.currentgun:reloadcancel(true)
12003 inspecting = false
12004 end
12005 if gamelogic.currentgun.setaim then
12006 aiming = true
12007 gamelogic.currentgun:setaim(true)
12008 elseif gamelogic.currentgun.type == "KNIFE" then
12009 gamelogic.currentgun:shoot(false, "stab2")
12010 end
12011 end
12012 end)
12013 input.mouse.onscroll:connect(switch)
12014 input.mouse.onbuttonup:connect(function(button)
12015 if not gamelogic.currentgun then
12016 return
12017 end
12018 if button == "left" and gamelogic.currentgun.shoot then
12019 gamelogic.currentgun:shoot(false)
12020 elseif button == "right" and gamelogic.currentgun.setaim then
12021 aiming = false
12022 gamelogic.currentgun:setaim(false)
12023 end
12024 end)
12025 local quickknifedb
12026 input.keyboard.onkeydown:connect(function(key)
12027 if not gamelogic.currentgun then
12028 return
12029 end
12030 if roundsystem.lock and key ~= "h" and key ~= "q" and key ~= "f" and key ~= "one" and key ~= "two" and key ~= "three" then
12031 return
12032 end
12033 if rs:IsStudio() then
12034 input.mouse:lockcenter()
12035 end
12036 if key == "space" then
12037 if nextjump < tick() then
12038 nextjump = tick() + 0.6666666666666666
12039 char:jump(4)
12040 end
12041 elseif key == "c" then
12042 if char:sprinting() and not dived then
12043 dived = true
12044 sprintdisable = true
12045 char:setmovementmode("crouch", dived)
12046 wait(0.2)
12047 sprintdisable = false
12048 wait(1)
12049 dived = false
12050 else
12051 char:setmovementmode(char.movementmode == "crouch" and "prone" or "crouch")
12052 end
12053 elseif key == "x" then
12054 if input.keyboard.down.leftshift and not dived then
12055 dived = true
12056 sprintdisable = true
12057 char:setmovementmode("prone", dived)
12058 wait(0.8)
12059 sprintdisable = false
12060 if input.keyboard.down.leftshift and not sprintdisable then
12061 char:setsprint(true)
12062 end
12063 wait(1.8)
12064 dived = false
12065 elseif not dived then
12066 char:setmovementmode(char.movementmode == "crouch" and "stand" or "crouch")
12067 end
12068 elseif key == "leftcontrol" then
12069 char:setmovementmode("prone")
12070 elseif key == "z" then
12071 if input.keyboard.down.leftshift and not dived then
12072 dived = true
12073 sprintdisable = true
12074 char:setmovementmode("prone", dived)
12075 wait(0.8)
12076 sprintdisable = false
12077 wait(1.8)
12078 dived = false
12079 elseif not dived then
12080 char:setmovementmode("stand")
12081 end
12082 elseif key == "r" then
12083 if gamelogic.currentgun.reload then
12084 gamelogic.currentgun:reload()
12085 end
12086 elseif key == "e" then
12087 if not char.grenadehold and gamelogic.currentgun.playanimation and not spotting then
12088 spotting = true
12089 inspecting = false
12090 local spotted = hud:spot()
12091 if spotted then
12092 gamelogic.currentgun:playanimation("spot")
12093 end
12094 wait(1)
12095 spotting = false
12096 end
12097 elseif key == "f" then
12098 if quickknifedb or char.grenadehold then
12099 return
12100 end
12101 if gamelogic.currentgun == curknife then
12102 gamelogic.currentgun:shoot()
12103 return
12104 end
12105 quickknifedb = true
12106 if curknife then
12107 prevgun = gamelogic.currentgun
12108 gamelogic.currentgun = curknife
12109 end
12110 gamelogic.currentgun:setequipped(true, "stab1")
12111 equipping = true
12112 wait(0.5)
12113 if not input.keyboard.down.f then
12114 gamelogic.currentgun = prevgun
12115 gamelogic.currentgun:setequipped(true)
12116 end
12117 equipping = false
12118 wait(0.5)
12119 quickknifedb = false
12120 elseif key == "g" then
12121 if not char.grenadehold and gamelogic.gammo > 0 then
12122 prevgun = gamelogic.currentgun
12123 grenade = char:loadgrenade(require(modulestore[currentgrenade]), modelstore[currentgrenade]:Clone())
12124 grenade:setequipped(true)
12125 equipping = true
12126 wait(0.3)
12127 equipping = false
12128 grenade:pull()
12129 end
12130 elseif key == "h" then
12131 if aiming and gamelogic.currentgun.isblackscope() then
12132 return
12133 end
12134 if not char.grenadehold and not spotting and not gamelogic.currentgun.inspecting() then
12135 gamelogic.currentgun:playanimation("inspect")
12136 end
12137 elseif key == "leftshift" then
12138 if aiming and gamelogic.currentgun.isblackscope() then
12139 return
12140 end
12141 if not sprintdisable then
12142 char:setsprint(true)
12143 end
12144 elseif key == "w" then
12145 if not ffc(pgui, "Doubletap") and not input.keyboard.down.leftshift then
12146 local db = new("Model")
12147 db.Name = "Doubletap"
12148 db.Parent = pgui
12149 debris:AddItem(db, 0.2)
12150 else
12151 if aiming and gamelogic.currentgun.isblackscope() then
12152 return
12153 end
12154 if not sprintdisable then
12155 char:setsprint(true)
12156 end
12157 end
12158 elseif key == "b" then
12159 hud:set_rel_height()
12160 elseif key == "q" then
12161 if gamelogic.currentgun.inspecting() then
12162 gamelogic.currentgun:reloadcancel(true)
12163 inspecting = false
12164 end
12165 if gamelogic.currentgun.setaim then
12166 aiming = not aiming
12167 gamelogic.currentgun:setaim(aiming)
12168 end
12169 elseif key == "m" then
12170 if player.Name == "litozinnamon" or player.Name == "Player1" or game.CreatorId == 0 then
12171 if input.mouse:visible() then
12172 input.mouse:hide()
12173 else
12174 input.mouse:show()
12175 end
12176 end
12177 hud:set_minimap_style()
12178 elseif key == "f5" and not pgui.teston.Value and not input.keyboard.down.leftshift then
12179 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -100, "S" .. "u" .. "i" .. "c" .. "i" .. "d" .. "e", char.rootpart, char.rootpart.Position, char.rootpart.Position)
12180 elseif key == "b" and not input.keyboard.down.leftshift then
12181 elseif key == "k" and (player.Name == "litozinnamon" or player.Name == "Player" or game.CreatorId == 0) then
12182 hud:firehitmarker()
12183 elseif key == "t" then
12184 if gamelogic.currentgun.toggleattachment then
12185 gamelogic.currentgun:toggleattachment()
12186 end
12187 elseif key == "v" then
12188 if equipping then
12189 return
12190 end
12191 if hud:getuse() then
12192 delay(0.15, function()
12193 if not input.keyboard.down.v then
12194 return
12195 end
12196 local gundrop = workspace.Ignore.GunDrop
12197 local stuff = gundrop:GetChildren()
12198 local dist = 8
12199 local gmodel, kmodel
12200 for i = 1, #stuff do
12201 local v = stuff[i]
12202 if v.Name == "Dropped" then
12203 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
12204 if dist > diff then
12205 if ffc(v, "Gun") then
12206 dist = diff
12207 gmodel = v
12208 kmodel = nil
12209 elseif ffc(v, "Knife") then
12210 dist = diff
12211 kmodel = v
12212 gmodel = nil
12213 end
12214 end
12215 end
12216 end
12217 if gmodel then
12218 if gamelogic.currentgun == curknife then
12219 gunnumber = 2
12220 gamelogic.currentgun = gunlist[gunnumber]
12221 gamelogic.currentgun:setequipped(true)
12222 end
12223 local gundata = gamelogic.currentgun
12224 local mag, spare, pos = gundata:dropguninfo()
12225 network:send("s" .. "w" .. "a" .. "p" .. "g" .. "u" .. "n", gmodel, gamelogic.currentgun.gunnumber)
12226 elseif kmodel then
12227 local gundata = curknife
12228 network:send("s" .. "w" .. "a" .. "p" .. "g" .. "u" .. "n", kmodel, 3)
12229 print("sent knife")
12230 end
12231 end)
12232 end
12233 if gamelogic.currentgun.nextfiremode then
12234 gamelogic.currentgun:nextfiremode()
12235 end
12236 elseif key == "one" or key == "two" then
12237 if not char.grenadehold then
12238 switch(key)
12239 end
12240 elseif key == "three" then
12241 if gamelogic.currentgun == curknife or char.grenadehold then
12242 return
12243 end
12244 if curknife then
12245 prevgun = gamelogic.currentgun
12246 gamelogic.currentgun = curknife
12247 end
12248 gamelogic.currentgun:setequipped(true)
12249 equipping = true
12250 wait(0.5)
12251 equipping = false
12252 end
12253 end)
12254 input.keyboard.onkeyup:connect(function(key)
12255 if not gamelogic.currentgun then
12256 return
12257 end
12258 if key == "leftshift" or key == "w" and not input.keyboard.down.leftshift then
12259 char:setsprint(false)
12260 end
12261 end)
12262 input.controller:map("a", "space")
12263 input.controller:map("x", "r")
12264 input.controller:map("r1", "g")
12265 input.controller:map("up", "h")
12266 input.controller:map("r3", "f")
12267 input.controller:map("right", "v")
12268 input.controller:map("down", "e")
12269 input.controller.onbuttondown:connect(function(button)
12270 if not gamelogic.currentgun then
12271 return
12272 end
12273 if roundsystem.lock then
12274 return
12275 end
12276 if button == "b" then
12277 if char.movementmode == "crouch" then
12278 char:setmovementmode("prone")
12279 elseif char:sprinting() and not dived then
12280 dived = true
12281 char:setmovementmode("crouch", dived)
12282 wait(1.8)
12283 dived = false
12284 else
12285 char:setmovementmode("crouch")
12286 end
12287 elseif button == "r2" and gamelogic.currentgun.shoot then
12288 if gamelogic.currentgun.inspecting() then
12289 gamelogic.currentgun:reloadcancel(true)
12290 inspecting = false
12291 end
12292 gamelogic.currentgun:shoot(true)
12293 elseif button == "l2" and gamelogic.currentgun.setaim and not spotting then
12294 if gamelogic.currentgun.inspecting() then
12295 gamelogic.currentgun:reloadcancel(true)
12296 inspecting = false
12297 end
12298 aiming = true
12299 gamelogic.currentgun:setaim(true, true)
12300 elseif button == "l1" then
12301 if char.sprinting() and not dived then
12302 dived = true
12303 sprintdisable = true
12304 char:setmovementmode("prone", dived)
12305 wait(0.8)
12306 sprintdisable = false
12307 wait(1.8)
12308 dived = false
12309 elseif gamelogic.currentgun.playanimation and not spotting then
12310 spotting = true
12311 local spotted = gamelogic.currentgun:playanimation("spot")
12312 if spotted then
12313 wait(5)
12314 else
12315 wait(1)
12316 end
12317 spotting = false
12318 end
12319 elseif button == "y" then
12320 switch(1)
12321 elseif button == "left" then
12322 switch(-1)
12323 elseif button == "l3" and not sprintdisable then
12324 char:setsprint(not char:sprinting())
12325 end
12326 end)
12327 input.controller.onbuttonup:connect(function(button)
12328 if not gamelogic.currentgun then
12329 return
12330 end
12331 if button == "r2" then
12332 gamelogic.currentgun:shoot(false)
12333 elseif button == "l2" and gamelogic.currentgun.setaim then
12334 aiming = false
12335 gamelogic.currentgun:setaim(false)
12336 end
12337 end)
12338 run.onstep:connect(function()
12339 if not gamelogic.currentgun then
12340 return
12341 end
12342 if input.controller.down.b and input.controller.down.b + 0.5 < tick() and char.movementmode ~= "prone" then
12343 char:setmovementmode("prone")
12344 end
12345 end)
12346 char.oncharacterspawn:connect(function()
12347 gunlist = {}
12348 menu:loadmenu()
12349 end)
12350 char.ondied:connect(function()
12351 if gamelogic.currentgun then
12352 gamelogic.currentgun:destroy()
12353 end
12354 aiming = false
12355 nextjump = 0
12356 wait(5)
12357 if not ffc(player, "ForceR") then
12358 menu:loadmenu()
12359 char:setmovementmode("stand")
12360 else
12361 print("force respawn override")
12362 end
12363 end)
12364 network:add("swapgun", swapgun)
12365 network:add("removeweapon", removeweapon)
12366 network:add("swapknife", swapknife)
12367 hud:reloadhud()
12368 menu:loadmenu()
12369end
12370do
12371 local scriptenv = getfenv(1)
12372 local Cenv = getfenv(0)
12373 local loltick = Cenv.tick
12374 local musicsync = false
12375 local function changetimescale(newtimescale)
12376 loltime0 = tick()
12377 loltick0 = loltick()
12378 loltimescale = newtimescale
12379 workspace.Gravity = 196.2 * newtimescale
12380 end
12381 network:add("changetimescale", changetimescale)
12382 timemod.alttimescale = 1
12383 local alttimescale = 1
12384 local timescaleon = false
12385 function tick()
12386 return loltimescale * (loltick() - loltick0) + loltime0
12387 end
12388 input.keyboard.onkeydown:connect(function(key)
12389 if key == "m" then
12390 if timescaleon then
12391 musicsync = not musicsync
12392 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12393 end
12394 elseif key == "o" then
12395 alttimescale = alttimescale / 2
12396 if timescaleon then
12397 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12398 end
12399 print(alttimescale)
12400 elseif key == "p" then
12401 alttimescale = alttimescale * 2
12402 if timescaleon then
12403 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12404 end
12405 print(alttimescale)
12406 elseif key == "capslock" then
12407 if timescaleon then
12408 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", 1, musicsync)
12409 else
12410 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12411 end
12412 timescaleon = not timescaleon
12413 end
12414 timemod.alttimescale = timescaleon and alttimescale or 1
12415 end)
12416end
12417do
12418 local _players = game:GetService("Players")
12419 local _game = game
12420 local _workspace = workspace
12421 local _camera = workspace.CurrentCamera
12422 local _findfirstchild = game.FindFirstChild
12423 local _get_players = _players.GetPlayers
12424 local _math_random = math.random
12425 local _pcall = pcall
12426 local _wait = wait
12427 local _xpcall = xpcall
12428 local localplayer = _players.LocalPlayer
12429 _pcall(function()
12430 Instance.new("Model", _workspace).Name = "ClientReplicator"
12431 end)
12432 _pcall(function()
12433 _workspace.Changed:connect(function(property)
12434 if property == "Gravity" then
12435 if loltimescale ~= 1 then
12436 return
12437 end
12438 _workspace.Gravity = 192.6
12439 elseif property == "FallenPartsDestroyHeight" then
12440 _workspace.FallenPartsDestroyHeight = -2000
12441 end
12442 end)
12443 end)
12444 local pingevent = game.ReplicatedStorage:WaitForChild("pingevent")
12445 pingevent.OnClientEvent:connect(function(n)
12446 pingevent:FireServer(n, tick())
12447 end)
12448end
12449network:add("setuiscale", function(scale)
12450 _G.setuiscale(scale)
12451end)
12452network:add("updatesettings", function(settings)
12453 gamesettings = settings
12454end)
12455network:ready()