· 7 years ago · Nov 27, 2018, 09:12 AM
1-- Synapse Decompiler
2-- Purchase Here: https://brack4712.xyz/synapse/purchase/
3
4local updatedate = "N/A"
5local updatestuff = "N/A"
6local updateversion = "N/A"
7pcall(function()
8 local game_data = game.ReplicatedFirst:WaitForChild("GameData")
9 updatedate = game_data:WaitForChild("UpdateDate", 3).Value
10 updatestuff = game_data:WaitForChild("UpdateLog", 3).Value
11 updateversion = game_data:WaitForChild("Version", 3).Value
12end)
13if game:GetService("RunService"):IsStudio() then
14 wait(1)
15end
16local updatemsg = "[Update date: " .. updatedate .. "]\n" .. updatestuff
17local lelasdids = {
18 [195329] = true,
19 [525919] = true,
20 [541489] = true,
21 [1667819] = true,
22 [4337002] = true,
23 [5725475] = true,
24 [9143169] = true,
25 [607954] = true,
26 [52250025] = true
27}
28leleltru = lelasdids[game:GetService("Players").LocalPlayer.UserId]
29wait()
30pcall(function()
31 local starterGui = game:GetService("StarterGui")
32 starterGui:SetCore("TopbarEnabled", false)
33end)
34local testing
35local loltime0 = 0
36local loltick0 = 0
37local loltimescale = 1
38local lolgravity = Vector3.new(0, -196.2, 0)
39local loltick = tick
40local function tick()
41 return loltimescale * (loltick() - loltick0) + loltime0
42end
43game.StarterGui.ResetPlayerGuiOnSpawn = false
44game.StarterGui:SetCoreGuiEnabled("All", false)
45math.randomseed(tick())
46local eventmod = {}
47local vector = {}
48local cframe = {}
49local network = {}
50local playerdata = {}
51local trash = {}
52local utility = {}
53local event = {}
54local sequencer = {}
55local physics = {}
56local particle = {}
57local sound = {}
58local effects = {}
59local tween = {}
60local animation = {}
61local input = {}
62aimassist = {}
63local char = {}
64local camera = {}
65local chat = {}
66local hud = {}
67local notify = {}
68local leaderboard = {}
69local replication = {}
70local menu = {}
71local roundsystem = {}
72local run = {}
73local gamelogic = {}
74local timemod = {}
75local require = require
76repeat
77 wait()
78until game:IsLoaded()
79print("Loading eventmod module")
80function eventmod:ison()
81 return false
82end
83print("Loading vector module")
84do
85 local pi = math.pi
86 local cos = math.cos
87 local sin = math.sin
88 local acos = math.acos
89 local asin = math.asin
90 local atan2 = math.atan2
91 local random = math.random
92 local v3 = Vector3.new
93 local nv = Vector3.new()
94 vector.identity = nv
95 vector.new = v3
96 vector.lerp = nv.lerp
97 vector.cross = nv.Cross
98 vector.dot = nv.Dot
99 function vector.random(a, b)
100 local p = acos(1 - 2 * random()) / 3
101 local z = 1.7320508075688772 * sin(p) - cos(p)
102 local r = ((1 - z * z) * random()) ^ 0.5
103 local t = 6.28318 * random()
104 local x = r * cos(t)
105 local y = r * sin(t)
106 if b then
107 local m = (a + (b - a) * random()) / (x * x + y * y + z * z) ^ 0.5
108 return v3(m * x, m * y, m * z)
109 elseif a then
110 return v3(a * x, a * y, a * z)
111 else
112 return v3(x, y, z)
113 end
114 end
115 function vector.anglesyx(x, y)
116 local cx = cos(x)
117 return v3(-cx * sin(y), sin(x), -cx * cos(y))
118 end
119 function vector.toanglesyx(v)
120 local x, y, z = v.x, v.y, v.z
121 return asin(y / (x * x + y * y + z * z) ^ 0.5), atan2(-x, -z)
122 end
123 function vector.slerp(v0, v1, t)
124 local x0, y0, z0 = v0.x, v0.y, v0.z
125 local x1, y1, z1 = v1.x, v1.y, v1.z
126 local m0 = (x0 * x0 + y0 * y0 + z0 * z0) ^ 0.5
127 local m1 = (x1 * x1 + y1 * y1 + z1 * z1) ^ 0.5
128 local co = (x0 * x1 + y0 * y1 + z0 * z1) / (m0 * m1)
129 if co < -0.99999 then
130 local px, py, pz = 0, 0, 0
131 local x2, y2, z2 = x0 * x0, y0 * y0, z0 * z0
132 if x2 < y2 then
133 if x2 < z2 then
134 px = 1
135 else
136 pz = 1
137 end
138 elseif y2 < z2 then
139 py = 1
140 else
141 pz = 1
142 end
143 local th = acos((x0 * px + y0 * py + z0 * pz) / m0)
144 local r = pi / th * t
145 local s = ((1 - t) * m0 + t * m1) / sin(th)
146 local s0 = s / m0 * sin((1 - r) * th)
147 local s1 = s / m1 * sin(r * th)
148 return v3(s0 * x0 + s1 * px, s0 * y0 + s1 * py, s0 * z0 + s1 * pz)
149 elseif co < 0.99999 then
150 local th = acos(co)
151 local s = ((1 - t) * m0 + t * m1) / (1 - co * co) ^ 0.5
152 local s0 = s / m0 * sin((1 - t) * th)
153 local s1 = s / m1 * sin(t * th)
154 return v3(s0 * x0 + s1 * x1, s0 * y0 + s1 * y1, s0 * z0 + s1 * z1)
155 elseif m0 > 1.0E-5 or m1 > 1.0E-5 then
156 if m0 < m1 then
157 return ((1 - t) * m0 / m1 + t) * v1
158 else
159 return (1 - t + t * m1 / m0) * v0
160 end
161 else
162 return nv
163 end
164 end
165end
166print("Loading cframe module")
167do
168 local pi = math.pi
169 local halfpi = pi / 2
170 local cos = math.cos
171 local sin = math.sin
172 local acos = math.acos
173 local v3 = Vector3.new
174 local nv = v3()
175 local cf = CFrame.new
176 local nc = cf()
177 local components = nc.components
178 local tos = nc.toObjectSpace
179 local vtos = nc.vectorToObjectSpace
180 local ptos = nc.pointToObjectSpace
181 local backcf = cf(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1)
182 local lerp = nc.lerp
183 cframe.identity = nc
184 cframe.new = cf
185 cframe.vtws = nc.vectorToWorldSpace
186 cframe.tos = nc.toObjectSpace
187 cframe.ptos = nc.pointToObjectSpace
188 cframe.vtos = nc.vectorToObjectSpace
189 function cframe.fromaxisangle(x, y, z)
190 if not y then
191 x, y, z = x.x, x.y, x.z
192 end
193 local m = (x * x + y * y + z * z) ^ 0.5
194 if m > 1.0E-5 then
195 local si = sin(m / 2) / m
196 return cf(0, 0, 0, si * x, si * y, si * z, cos(m / 2))
197 else
198 return nc
199 end
200 end
201 function cframe.toaxisangle(c)
202 local _, _, _, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
203 local co = (xx + yy + zz - 1) / 2
204 if co < -0.99999 then
205 local x = xx + yx + zx + 1
206 local y = xy + yy + zy + 1
207 local z = xz + yz + zz + 1
208 local m = pi * (x * x + y * y + z * z) ^ (-0.5)
209 return v3(m * x, m * y, m * z)
210 elseif co < 0.99999 then
211 local x = yz - zy
212 local y = zx - xz
213 local z = xy - yx
214 local m = acos(co) * (x * x + y * y + z * z) ^ (-0.5)
215 return v3(m * x, m * y, m * z)
216 else
217 return nv
218 end
219 end
220 function cframe.direct(c, look, newdir, t)
221 local lx, ly, lz = look.x, look.y, look.z
222 local rv = vtos(c, newdir)
223 local rx, ry, rz = rv.x, rv.y, rv.z
224 local rl = ((rx * rx + ry * ry + rz * rz) * (lx * lx + ly * ly + lz * lz)) ^ 0.5
225 local d = (lx * rx + ly * ry + lz * rz) / rl
226 if d < -0.99999 then
227 return c * backcf
228 elseif d < 0.99999 then
229 if t then
230 local th = t * acos(d) / 2
231 local qw = cos(th)
232 local m = rl * ((1 - d * d) / (1 - qw * qw)) ^ 0.5
233 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
234 else
235 local qw = ((d + 1) / 2) ^ 0.5
236 local m = 2 * qw * rl
237 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
238 end
239 else
240 return c
241 end
242 end
243 function cframe.toquaternion(c)
244 local x, y, z, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
245 local tr = xx + yy + zz
246 if tr > 2.99999 then
247 return x, y, z, 0, 0, 0, 1
248 elseif tr > -0.99999 then
249 local m = 2 * (tr + 1) ^ 0.5
250 return x, y, z, (yz - zy) / m, (zx - xz) / m, (xy - yx) / m, m / 4
251 else
252 local qx = xx + yx + zx + 1
253 local qy = xy + yy + zy + 1
254 local qz = xz + yz + zz + 1
255 local m = (qx * qx + qy * qy + qz * qz) ^ 0.5
256 return x, y, z, qx / m, qy / m, qz / m, 0
257 end
258 end
259 function cframe.power(c, t)
260 return lerp(nc, c, t)
261 end
262 cframe.interpolate = lerp
263 function cframe.interpolator(c0, c1, c2)
264 if c2 then
265 return function(t)
266 return lerp(lerp(c0, c1, t), lerp(c1, c2, t), t)
267 end
268 elseif c1 then
269 return function(t)
270 return lerp(c0, c1, t)
271 end
272 else
273 return function(t)
274 return lerp(nc, c0, t)
275 end
276 end
277 end
278 function cframe.jointleg(r0, r1, c, p, a)
279 local t = ptos(c, p)
280 local tx, ty, tz = t.x, t.y, t.z
281 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
282 local nx, ny, nz = tx / d, ty / d, tz / d
283 d = d > r0 + r1 and r0 + r1 or d
284 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
285 local h = -(1 - l * l) ^ 0.5
286 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
287 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
288 if a then
289 local co, si = cos(a / 2), sin(a / 2)
290 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)
291 end
292 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
293 local co = ((1 - g) / 2) ^ 0.5
294 local si = -((1 + g) / 2) ^ 0.5
295 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)
296 end
297 function cframe.jointarm(r0, r1, c, p, a)
298 local t = ptos(c, p)
299 local tx, ty, tz = t.x, t.y, t.z
300 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
301 local nx, ny, nz = tx / d, ty / d, tz / d
302 d = d > r0 + r1 and r0 + r1 or d
303 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
304 local h = (1 - l * l) ^ 0.5
305 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
306 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
307 if a then
308 local co, si = cos(a / 2), sin(a / 2)
309 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)
310 end
311 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
312 local co = ((1 - g) / 2) ^ 0.5
313 local si = ((1 + g) / 2) ^ 0.5
314 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)
315 end
316end
317local sphereraycast
318do
319 local testinterval = 16
320 local inf = 1 / 0
321 local sort = table.sort
322 local v3 = Vector3.new
323 local nv = v3()
324 local dot = nv.Dot
325 local cross = nv.Cross
326 local cf = CFrame.new
327 local nc = cf()
328 local ptos = nc.pointToObjectSpace
329 local vtos = nc.vectorToObjectSpace
330 local vtws = nc.vectorToWorldSpace
331 local r3 = Region3.new
332 local workspace = game.Workspace
333 local boxcast = workspace.FindPartsInRegion3
334 local getchildren = game.GetChildren
335 local robloxtype = game.IsA
336 local boxmesh = {
337 {
338 p = 0.5,
339 n = v3(-1, 0, 0)
340 },
341 {
342 p = 0.5,
343 n = v3(1, 0, 0)
344 },
345 {
346 p = 0.5,
347 n = v3(0, -1, 0)
348 },
349 {
350 p = 0.5,
351 n = v3(0, 1, 0)
352 },
353 {
354 p = 0.5,
355 n = v3(0, 0, -1)
356 },
357 {
358 p = 0.5,
359 n = v3(0, 0, 1)
360 }
361 }
362 local wedgemesh = {
363 {
364 p = 0.5,
365 n = v3(-1, 0, 0)
366 },
367 {
368 p = 0.5,
369 n = v3(1, 0, 0)
370 },
371 {
372 p = 0.5,
373 n = v3(0, -1, 0)
374 },
375 {
376 p = 0,
377 n = v3(0, 0.7071067811865476, -0.7071067811865476)
378 },
379 {
380 p = 0.5,
381 n = v3(0, 0, 1)
382 }
383 }
384 local cornerwedgemesh = {
385 {
386 p = 0.5,
387 n = v3(1, 0, 0)
388 },
389 {
390 p = 0.5,
391 n = v3(0, -1, 0)
392 },
393 {
394 p = 0.5,
395 n = v3(0, 0, -1)
396 },
397 {
398 p = 0,
399 n = v3(0, 0.7071067811865476, 0.7071067811865476)
400 },
401 {
402 p = 0,
403 n = v3(-0.7071067811865476, 0.7071067811865476, 0)
404 }
405 }
406 local function solveplanesphereray(p, n, o, d, r)
407 local no = dot(n, o)
408 local dn = dot(d, n)
409 local t = (p + r - no) / dn
410 local v = o + t * d
411 local h = v - r * n
412 return v, t, h, n
413 end
414 local function solveraysphereray(ro, rd, so, sd, r)
415 local rdro = dot(rd, ro)
416 local roro = dot(ro, ro)
417 local rdsd = dot(rd, sd)
418 local rosd = dot(ro, sd)
419 local rdso = dot(rd, so)
420 local roso = dot(ro, so)
421 local sdso = dot(sd, so)
422 local soso = dot(so, so)
423 local m = rdro - rdso
424 local a = 1 - rdsd * rdsd
425 local b = 2 * (rdsd * m - rosd + sdso)
426 local c = roro - 2 * roso + soso - m * m - r * r
427 local d = -b / (2 * a)
428 local e2 = d * d - c / a
429 if e2 > 0 then
430 local t = d - e2 ^ 0.5
431 local s = rdsd * t - m
432 local v = so + t * sd
433 local h = ro + s * rd
434 local n = (v - h) / r
435 return v, t, h, n
436 end
437 end
438 local function solvepointsphereray(p, o, d, r)
439 local oo = dot(o, o)
440 local od = dot(o, d)
441 local op = dot(o, p)
442 local dp = dot(d, p)
443 local pp = dot(p, p)
444 local b = 2 * (od - dp)
445 local c = oo - 2 * op + pp - r * r
446 local g = -b / 2
447 local e2 = g * g - c
448 if e2 > 0 then
449 local t = g - e2 ^ 0.5
450 local v = o + t * d
451 local n = (v - p) / r
452 return v, t, p, n
453 end
454 end
455 local function solvespheresphereray(p, e, o, d, r)
456 local oo = dot(o, o)
457 local od = dot(o, d)
458 local op = dot(o, p)
459 local dp = dot(d, p)
460 local pp = dot(p, p)
461 local b = 2 * (od - dp)
462 local c = oo - 2 * op + pp - (r + e) * (r + e)
463 local g = -b / 2
464 local e2 = g * g - c
465 if e2 > 0 then
466 local t = g - e2 ^ 0.5
467 local v = o + t * d
468 local h = p + e / (r + e) * (v - p)
469 local n = (v - h) / (r + e)
470 return v, t, h, n
471 end
472 end
473 local function distplanesphereray(p, n, o, d, r)
474 local no = dot(n, o)
475 local dn = dot(d, n)
476 local t = (p + r - no) / dn
477 return t
478 end
479 local function distpointsphereray(p, o, d, r)
480 local oo = dot(o, o)
481 local od = dot(o, d)
482 local op = dot(o, p)
483 local dp = dot(d, p)
484 local pp = dot(p, p)
485 local b = 2 * (od - dp)
486 local c = oo - 2 * op + pp - r * r
487 local g = -b / 2
488 local e2 = g * g - c
489 if e2 > 0 then
490 local t = g - e2 ^ 0.5
491 return t
492 end
493 end
494 local function solveplaneplane(ap, an, bp, bn)
495 local anbn = dot(an, bn)
496 local canab = cross(an, bn)
497 local s = 1 - anbn * anbn
498 local o = (ap - anbn * bp) / s * an + (bp - ap * anbn) / s * bn
499 local d = canab / s ^ 0.5
500 return o, d
501 end
502 local function solverayplane(o, d, p, n)
503 local dn = dot(d, n)
504 local no = dot(n, o)
505 local v = o + (p - no) / dn * d
506 return v
507 end
508 local function distpointplane(v, p, n)
509 local vn = dot(v, n)
510 local t = vn - p
511 return t
512 end
513 local function sortgreaterdist(a, b)
514 return (b.dist or -inf) < (a.dist or -inf)
515 end
516 local function solvemeshsphereray(rawmesh, cframe, scale, origin, direction, radius)
517 local o = ptos(cframe, origin)
518 local d = vtos(cframe, direction)
519 local r = radius
520 local mesh = {}
521 local nfront = 0
522 for i = 1, #rawmesh do
523 local plane = rawmesh[i]
524 local sn = plane.n / scale
525 local n = sn.unit
526 local p = plane.p / sn.magnitude
527 local newplane = {p = p, n = n}
528 if dot(n, d) < 0 then
529 newplane.dist = distplanesphereray(p, n, o, d, r)
530 nfront = nfront + 1
531 end
532 mesh[#mesh + 1] = newplane
533 end
534 sort(mesh, sortgreaterdist)
535 for i = 1, nfront do
536 local aplane = mesh[i]
537 local apos, adist, ahit, anorm = solveplanesphereray(aplane.p, aplane.n, o, d, r)
538 local agood = true
539 for j = 1, #mesh do
540 if i ~= j then
541 local bplane = mesh[j]
542 if 0 < distpointplane(ahit, bplane.p, bplane.n) then
543 agood = false
544 local aborigin, abdirection = solveplaneplane(aplane.p, aplane.n, bplane.p, bplane.n)
545 local abpos, abdist, abhit, abnorm = solveraysphereray(aborigin, abdirection, o, d, r)
546 if abpos then
547 local abgood = true
548 for k = 1, #mesh do
549 if i ~= k and j ~= k then
550 local cplane = mesh[k]
551 local dist = distpointplane(abhit, cplane.p, cplane.n)
552 if dist > 0 then
553 abgood = false
554 local abcpoint = solverayplane(aborigin, abdirection, cplane.p, cplane.n)
555 local abcpos, abcdist, abchit, abcnorm = solvepointsphereray(abcpoint, o, d, r)
556 if abcpos then
557 local abcgood = true
558 for l = 1, #mesh do
559 if i ~= l and j ~= l and k ~= l then
560 local dplane = mesh[l]
561 local dist = distpointplane(abchit, dplane.p, dplane.n)
562 if dist > 0 then
563 abcgood = false
564 break
565 end
566 end
567 end
568 if abcgood then
569 return cframe * abcpos, abcdist, cframe * abchit, vtws(cframe, abcnorm)
570 end
571 end
572 end
573 end
574 end
575 if abgood then
576 return cframe * abpos, abdist, cframe * abhit, vtws(cframe, abnorm)
577 end
578 end
579 end
580 end
581 end
582 if agood then
583 return cframe * apos, adist, cframe * ahit, vtws(cframe, anorm)
584 end
585 end
586 end
587 local sortdist = function(a, b)
588 return a.dist < b.dist
589 end
590 local function solvepartsphereray(part, origin, direction, radius)
591 local class = part.ClassName
592 if class == "Part" then
593 local shape = part.Shape.Name
594 if shape == "Block" then
595 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
596 elseif shape == "Ball" or shape == "Cylinder" then
597 return solvespheresphereray(part.Position, part.Size.x / 2, origin, direction, radius)
598 end
599 elseif class == "TrussPart" then
600 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
601 elseif class == "WedgePart" then
602 return solvemeshsphereray(wedgemesh, part.CFrame, part.Size, origin, direction, radius)
603 elseif class == "CornerWedgePart" then
604 return solvemeshsphereray(cornerwedgemesh, part.CFrame, part.Size, origin, direction, radius)
605 end
606 end
607 local function getallparts(directory)
608 local shit = {directory}
609 local i = 0
610 while i < #shit do
611 i = i + 1
612 local children = getchildren(shit[i])
613 for j = 1, #children do
614 shit[#shit + 1] = children[j]
615 end
616 end
617 local parts = {}
618 for j = 1, #shit do
619 if robloxtype(shit[j], "BasePart") then
620 parts[#parts + 1] = shit[j]
621 end
622 end
623 return parts
624 end
625 function sphereraycast(origin, direction, radius, ignore)
626 local tested = {}
627 if type(ignore) == "table" then
628 for i = 1, #ignore do
629 local parts = getallparts(ignore[i])
630 for j = 1, #parts do
631 tested[parts[j]] = true
632 end
633 end
634 elseif ignore then
635 local parts = getallparts(ignore)
636 for j = 1, #parts do
637 tested[parts[j]] = true
638 end
639 end
640 local interval = testinterval
641 local length = direction.magnitude
642 local udirection = direction.unit
643 local dx = udirection.x
644 local dy = udirection.y
645 local dz = udirection.z
646 local radvec = v3(radius, radius, radius)
647 local absvec = v3(dx < 0 and -dx or dx, dy < 0 and -dy or dy, dz < 0 and -dz or dz)
648 local t = 0
649 repeat
650 local stop
651 if interval > length - t then
652 stop = true
653 interval = length - t
654 end
655 local lower = origin + (t + interval / 2) * udirection - interval / 2 * absvec - radvec
656 local upper = origin + (t + interval / 2) * udirection + interval / 2 * absvec + radvec
657 t = t + interval
658 local parts = boxcast(workspace, r3(lower, upper), nil, 100)
659 local sorted = {}
660 for i = 1, #parts do
661 local part = parts[i]
662 if not tested[part] then
663 tested[part] = true
664 local dist = distpointsphereray(part.Position, origin, udirection, radius + part.Size.magnitude / 2)
665 if dist then
666 sorted[#sorted + 1] = {part = part, dist = dist}
667 end
668 end
669 end
670 sort(sorted, sortdist)
671 local bestdist = direction.magnitude
672 local bestpart, bestpos, besthit, bestnorm
673 for i = 1, #sorted do
674 local package = sorted[i]
675 if bestdist > package.dist then
676 local pos, dist, hit, norm = solvepartsphereray(package.part, origin, udirection, radius)
677 if dist and dist > 0 and bestdist > dist then
678 bestdist = dist
679 bestpart = package.part
680 bestpos = pos
681 besthit = hit
682 bestnorm = norm
683 end
684 else
685 break
686 end
687 end
688 if bestpos then
689 return bestpart, bestpos, bestdist, besthit, bestnorm
690 end
691 until stop
692 end
693end
694print("Loading serializer")
695local serialize
696repeat
697 do break end
698 while true do
699 end
700until true
701do
702 local totalasd = 0
703 local starttick = tick()
704 local off = 48
705 local function newbitwriter(key)
706 key = key and key % 2251799813685248 or 0
707 local char = string.char
708 local concat = table.concat
709 local data = {}
710 local ndata = 0
711 local rem = 0
712 local nrem = 0
713 return function(nbits, bits)
714 if nbits < 32 then
715 bits = (bits + key) % 2 ^ nbits
716 else
717 local bits0 = bits % 4294967296
718 local bits1 = (bits - bits0) / 4294967296
719 bits0 = (bits0 + key) % 4294967296
720 bits1 = (bits1 + key) % 2 ^ (nbits - 32)
721 bits = bits0 + 4294967296 * bits1
722 end
723 while nrem + nbits >= 48 do
724 local r = bits % 2 ^ (48 - nrem)
725 bits = (bits - r) / 2 ^ (48 - nrem)
726 nbits = nbits - (48 - nrem)
727 rem = rem + r * 2 ^ nrem
728 local b0 = rem % 64
729 rem = (rem - b0) / 64
730 local b1 = rem % 64
731 rem = (rem - b1) / 64
732 local b2 = rem % 64
733 rem = (rem - b2) / 64
734 local b3 = rem % 64
735 rem = (rem - b3) / 64
736 local b4 = rem % 64
737 rem = (rem - b4) / 64
738 local b5 = rem % 64
739 rem = (rem - b5) / 64
740 local b6 = rem % 64
741 rem = (rem - b6) / 64
742 local b7 = rem % 64
743 rem = (rem - b7) / 64
744 rem = 0
745 nrem = 0
746 ndata = ndata + 1
747 data[ndata] = char(b0 + off, b1 + off, b2 + off, b3 + off, b4 + off, b5 + off, b6 + off, b7 + off)
748 end
749 rem = rem + bits * 2 ^ nrem
750 nrem = nrem + nbits
751 end, function()
752 if nrem ~= 0 then
753 local final = ""
754 for i = 1, 8 do
755 local b = rem % 64
756 rem = (rem - b) / 64
757 final = final .. char(b + off)
758 end
759 ndata = ndata + 1
760 data[ndata] = final
761 end
762 return concat(data)
763 end
764 end
765 local type = type
766 local pcall = pcall
767 local tostring = tostring
768 local byte = string.byte
769 local frexp = math.frexp
770 local nan = tostring(0 / 0)
771 function serialize(d, key)
772 local asd = tick()
773 local e = {}
774 local m = 0
775 local s = {}
776 local n = 0
777 local w, x = newbitwriter(key)
778 local userdata = {
779 function(v)
780 local t0 = v.Dot
781 return {
782 v.x,
783 v.y,
784 v.z
785 }
786 end,
787 function(v)
788 return {
789 v:components()
790 }
791 end,
792 function(v)
793 return v.UserId
794 end
795 }
796 local function f(d)
797 local t = type(d)
798 if s[d] then
799 w(3, 0)
800 local a, b = frexp(s[d])
801 w(5, b)
802 w(b, s[d])
803 elseif t == "boolean" then
804 w(3, 1)
805 w(1, d and 1 or 0)
806 elseif t == "number" then
807 if d % 1 == 0 and d > -4294967296 and d < 4294967296 then
808 w(3, 2)
809 local a, b = frexp(d)
810 w(5, b)
811 w(1, d < 0 and 1 or 0)
812 w(b, d < 0 and -d or d)
813 else
814 w(3, 3)
815 if d ~= d then
816 if tostring(d) == nan then
817 w(1, 0)
818 else
819 w(1, 1)
820 end
821 w(11, 0)
822 w(52, 1)
823 elseif d == 1 / 0 or d == -1 / 0 then
824 w(1, d < 0 and 1 or 0)
825 w(11, 2047)
826 w(52, 4503599627370495)
827 else
828 w(1, d < 0 and 1 or 0)
829 local a, b = frexp(d < 0 and -d or d)
830 local c = (2 * a - 1) * 4503599627370496
831 w(11, b - 1 + 1023)
832 if b == 1025 and c == 4503599627370495 then
833 w(52, (2 * a - 1) * 4503599627370496 - 1)
834 else
835 w(52, (2 * a - 1) * 4503599627370496)
836 end
837 end
838 end
839 elseif t == "string" then
840 n = n + 1
841 s[d] = n
842 w(3, 4)
843 local a, b = frexp(#d)
844 w(5, b)
845 w(b, #d)
846 for i = 1, #d do
847 local v = byte(d, i)
848 w(8, v)
849 end
850 elseif t == "table" then
851 n = n + 1
852 s[d] = n
853 w(3, 5)
854 local j = 0
855 local k = 0
856 for i = 1, #d do
857 if not d[i] then
858 j = i - 1
859 break
860 end
861 end
862 for i, v in next, d, nil do
863 local t = type(i)
864 if t ~= "number" or i > j then
865 k = k + 1
866 end
867 end
868 local a, b = frexp(j)
869 w(5, b)
870 w(b, j)
871 local a, b = frexp(k)
872 w(5, b)
873 w(b, k)
874 for i = 1, j do
875 f(d[i])
876 end
877 for i, v in next, d, nil do
878 local t = type(i)
879 if t ~= "number" or i > j then
880 f(i)
881 f(v)
882 end
883 end
884 else
885 local u = false
886 for i = 1, #userdata do
887 local a, b = pcall(userdata[i], d)
888 if a and b then
889 w(3, 6)
890 w(5, i)
891 f(b)
892 u = true
893 break
894 end
895 end
896 if not u then
897 m = m + 1
898 e[m] = d
899 w(3, 7)
900 local a, b = frexp(m)
901 w(5, b)
902 w(b, m)
903 end
904 end
905 end
906 f(d)
907 local out = x()
908 totalasd = tick() - asd
909 return out, e
910 end
911end
912print("Loading network module")
913do
914 local tick = tick
915 local player = game:GetService("Players").LocalPlayer
916 local remoteevent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
917 local bounceevent = game.ReplicatedStorage:WaitForChild("BounceEvent")
918 local remotefunc = game.ReplicatedStorage:WaitForChild("RemoteFunction")
919 local fireserver = remoteevent.FireServer
920 local invokeserver = remotefunc.InvokeServer
921 local key = 1
922 local funcs = {}
923 local queue = {}
924 local getfenv = getfenv
925 local pcall = pcall
926 local rawget = rawget
927 local settings = settings
928 function network:add(name, func)
929 funcs[name] = func
930 if queue[name] then
931 for i = 1, #queue[name] do
932 func(unpack(queue[name][i]))
933 end
934 end
935 end
936 local function getkey()
937 key = 94906230 * key % 94906249
938 return key
939 end
940 function network:send(name, ...)
941 local caller = getfenv(2)
942 if rawset(caller, "no u", settings) and rawget(caller, "no u") and caller["no u"] == settings and not pcall(caller["no u"]) then
943 return fireserver(remoteevent, serialize({
944 name = name,
945 ...
946 }, getkey()))
947 end
948 fireserver(remoteevent, serialize({
949 name = "logmessage",
950 "Network Hijacking"
951 }, getkey()))
952 return "no"
953 end
954 function network:bounce(name, ...)
955 local caller = getfenv(2)
956 if rawset(caller, "no u", settings) and rawget(caller, "no u") and caller["no u"] == settings and not pcall(caller["no u"]) then
957 return fireserver(bounceevent, serialize({
958 name = name,
959 ...
960 }, getkey()))
961 end
962 fireserver(remoteevent, serialize({
963 name = "logmessage",
964 "Network Hijacking"
965 }, getkey()))
966 return "no"
967 end
968 function network:fetch(name, ...)
969 local caller = getfenv(2)
970 if rawset(caller, "no u", settings) and rawget(caller, "no u") and caller["no u"] == settings and not pcall(caller["no u"]) then
971 return invokeserver(remotefunc, serialize({
972 name = name,
973 ...
974 }, getkey()))
975 end
976 fireserver(remoteevent, serialize({
977 name = "logmessage",
978 "Network Hijacking"
979 }, getkey()))
980 return "no"
981 end
982 function network:e(message)
983 network:send("c" .. "l" .. "o" .. "s" .. "e" .. "c" .. "o" .. "n" .. "n" .. "e" .. "c" .. "t" .. "i" .. "o" .. "n", message)
984 end
985 local function call(name, ...)
986 if funcs[name] then
987 funcs[name](...)
988 else
989 if not queue[name] then
990 queue[name] = {}
991 end
992 queue[name][#queue[name] + 1] = {
993 ...
994 }
995 end
996 end
997 bounceevent.OnClientEvent:connect(function(name, ...)
998 if funcs[name] then
999 return funcs[name](...)
1000 else
1001 if not queue[name] then
1002 queue[name] = {}
1003 end
1004 queue[name][#queue[name] + 1] = {
1005 ...
1006 }
1007 end
1008 end)
1009 remoteevent.OnClientEvent:connect(call)
1010 network:add("ping", function(servertick)
1011 network:send("p" .. "i" .. "n" .. "g", servertick, tick())
1012 end)
1013end
1014print("Loading data module")
1015do
1016 local sub = string.sub
1017 local find = string.find
1018 local concat = table.concat
1019 local type = type
1020 local player = game:GetService("Players").LocalPlayer
1021 local repstore = game.ReplicatedStorage
1022 local gunmodules = repstore.GunModules
1023 local userdatareaders = {}
1024 local userdatawriters = {}
1025 local cache = {}
1026 local function read(data, s)
1027 s = s or 1
1028 local nameend = find(data, "-", s)
1029 local numend = find(data, ":", nameend + 1)
1030 local type = sub(data, s, nameend - 1)
1031 local len = sub(data, nameend + 1, numend - 1) + 0
1032 local a, b = numend + 1, numend + len
1033 if type == "b" then
1034 return sub(data, a, a) == "t", b
1035 elseif type == "n" then
1036 return sub(data, a, b) + 0, b
1037 elseif type == "s" then
1038 return sub(data, a, b), b
1039 elseif type == "t" then
1040 local table, n = {}, 0
1041 local i = a
1042 while b >= i do
1043 local value, e = read(data, i)
1044 local sep = sub(data, e + 1, e + 1)
1045 if sep == "=" then
1046 local index = value
1047 value, e = read(data, e + 2)
1048 table[index] = value
1049 else
1050 n = n + 1
1051 table[n] = value
1052 end
1053 i = e + 2
1054 end
1055 return table, b
1056 else
1057 return userdatareaders[type](data, a, b), b
1058 end
1059 end
1060 local function write(data)
1061 local dtype = type(data)
1062 if dtype == "boolean" then
1063 return data and "b-4:true" or "b-5:false", dtype
1064 elseif dtype == "number" then
1065 local str = data .. ""
1066 return "n-" .. #str .. ":" .. str, dtype
1067 elseif dtype == "string" then
1068 local lab = "s-" .. #data .. ":"
1069 return lab .. data, dtype
1070 elseif dtype == "table" then
1071 local string, n = {}, 1
1072 local len = 0
1073 local i = 1
1074 while data[i] do
1075 local str = write(data[i]) .. ";"
1076 n = n + 1
1077 string[n] = str
1078 len = len + #str
1079 i = i + 1
1080 end
1081 for k, v in next, data, nil do
1082 if type(k) ~= "number" or k > i or k % 1 ~= 0 then
1083 local str = write(k) .. "=" .. write(v) .. ";"
1084 n = n + 1
1085 string[n] = str
1086 len = len + #str
1087 else
1088 print(k)
1089 end
1090 end
1091 string[1] = "t-" .. len .. ":"
1092 return concat(string), dtype
1093 else
1094 for i, v in next, userdatawriters, nil do
1095 local ser = userdatawriters[i](data)
1096 if ser then
1097 return ser, i
1098 end
1099 end
1100 end
1101 end
1102 network:add("loadplayerdata", function(data)
1103 cache = data
1104 playerdata.loaded = true
1105 end)
1106 network:add("updateplayerdata", function(value, ...)
1107 local keys = {
1108 ...
1109 }
1110 local data = cache
1111 for i = 1, #keys - 1 do
1112 if not data[keys[i]] then
1113 data[keys[i]] = {}
1114 end
1115 data = data[keys[i]]
1116 end
1117 data[keys[#keys]] = value
1118 end)
1119 network:add("updateinventorydata", function(data)
1120 cache.settings.inventorydata = data
1121 menu.updateinventorydata(cache.settings.inventorydata)
1122 end)
1123 network:add("updatepitydata", function(data)
1124 cache.settings.pitydata = data
1125 end)
1126 network:add("updateunlocksdata", function(data)
1127 cache.unlocks = data
1128 end)
1129 network:add("updateexperience", function(experience)
1130 cache.stats.experience = experience
1131 end)
1132 network:add("updatetotalkills", function(kills)
1133 cache.stats.totalkills = kills
1134 end)
1135 network:add("updatetotaldeaths", function(deaths)
1136 cache.stats.totaldeaths = deaths
1137 end)
1138 network:add("updategunkills", function(weapon, kills)
1139 local gundata = cache.unlocks[weapon]
1140 if not gundata then
1141 gundata = {}
1142 cache.unlocks[weapon] = gundata
1143 end
1144 gundata.kills = kills
1145 end)
1146 network:add("purchasegunconfirm", function(weapon)
1147 local gundata = cache.unlocks[weapon]
1148 if not gundata then
1149 gundata = {}
1150 cache.unlocks[weapon] = gundata
1151 end
1152 gundata.paid = true
1153 end)
1154 network:add("purchaseattachment", function(weapon, attachname)
1155 local gundata = cache.unlocks[weapon]
1156 if not gundata then
1157 gundata = {}
1158 cache.unlocks[weapon] = gundata
1159 end
1160 gundata[attachname] = true
1161 menu:updateattachpurchase(weapon, attachname)
1162 end)
1163 network:add("updatemoney", function(money)
1164 cache.stats.money = money
1165 menu:updatemoney(money)
1166 end)
1167 function playerdata.updateplayerdata(value, ...)
1168 local keys = {
1169 ...
1170 }
1171 local data = cache
1172 for i = 1, #keys - 1 do
1173 if not data[keys[i]] then
1174 data[keys[i]] = {}
1175 end
1176 data = data[keys[i]]
1177 end
1178 data[keys[#keys]] = value
1179 network:send("u" .. "p" .. "d" .. "a" .. "t" .. "e" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a", value, ...)
1180 end
1181 function playerdata.getdata()
1182 return cache
1183 end
1184 network:send("l" .. "o" .. "a" .. "d" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a")
1185end
1186print("Loading trash module")
1187do
1188 local destroy = game.Destroy
1189 local shit = {}
1190 function trash.remove(x)
1191 if x then
1192 shit[#shit + 1] = x
1193 x.Parent = nil
1194 end
1195 end
1196 function trash.empty()
1197 print("taking out " .. #shit .. " trash")
1198 for i = 1, #shit do
1199 destroy(shit[i])
1200 end
1201 shit = {}
1202 end
1203 network:add("emptytrash", trash.empty)
1204end
1205print("Loading utility module")
1206do
1207 local getchildren = game.GetChildren
1208 local rtype = game.IsA
1209 local joints = game.JointsService
1210 local tos = CFrame.new().toObjectSpace
1211 local tick = tick
1212 local new = Instance.new
1213 local waitforchild = game.WaitForChild
1214 local ffc = game.FindFirstChild
1215 local cf = CFrame.new
1216 local v3 = Vector3.new
1217 function utility.arraytohash(table, hashfunc)
1218 local newtable = {}
1219 for i = 1, #table do
1220 newtable[hashfunc(table[i])] = table[i]
1221 end
1222 return newtable
1223 end
1224 function utility.waitfor(object, timeout, ...)
1225 local indices = {
1226 ...
1227 }
1228 local index = object
1229 local quit = tick() + (timeout or 10)
1230 for i = 1, #indices do
1231 if index.WaitForChild then
1232 index = waitforchild(index, indices[i])
1233 else
1234 local newindex
1235 repeat
1236 run.wait()
1237 newindex = index[indices[i]]
1238 until newindex or quit < tick()
1239 index = newindex
1240 end
1241 if quit < tick() then
1242 return
1243 end
1244 end
1245 return index
1246 end
1247 function utility.getdescendants(object, type)
1248 type = type or "Instance"
1249 local descendants = getchildren(object)
1250 local i = 0
1251 while i < #descendants do
1252 i = i + 1
1253 local children = getchildren(descendants[i])
1254 for j = 1, #children do
1255 descendants[#descendants + 1] = children[j]
1256 end
1257 end
1258 local newdescendants = {}
1259 for i = 1, #descendants do
1260 if rtype(descendants[i], type) then
1261 newdescendants[#newdescendants + 1] = descendants[i]
1262 end
1263 end
1264 return newdescendants
1265 end
1266 function utility.weld(part0, part1, c0)
1267 c0 = c0 or tos(part0.CFrame, part1.CFrame)
1268 local newweld = new("Motor6D", part0)
1269 newweld.Part0 = part0
1270 newweld.Part1 = part1
1271 newweld.C0 = c0
1272 part0.Anchored = false
1273 part1.Anchored = false
1274 return newweld
1275 end
1276 function utility.removevalue(array, removals)
1277 local removelist = {}
1278 for i = 1, #removals do
1279 removelist[removals[i]] = true
1280 end
1281 local j = 1
1282 for i = 1, #array do
1283 local v = array[i]
1284 array[i] = nil
1285 if not removelist[v] then
1286 array[j] = v
1287 j = j + 1
1288 end
1289 end
1290 return array
1291 end
1292 function utility.drawray(newray, prop)
1293 local part = new("Part")
1294 part.Material = prop.material or Enum.Material.Neon
1295 part.Size = v3(prop.thickness or 0.1, prop.thickness or 0.1, newray.Direction.magnitude)
1296 part.CFrame = cf(newray.Origin + newray.Direction / 2, newray.Origin + newray.Direction)
1297 part.Anchored = true
1298 part.CanCollide = false
1299 part.BrickColor = prop.brickcolor or BrickColor.new("Bright red")
1300 part.Parent = prop.parent or workspace.Ignore
1301 game.Debris:AddItem(part, prop.life or 5)
1302 end
1303end
1304print("Loading event module")
1305do
1306 local resume = coroutine.resume
1307 local create = coroutine.create
1308 local pcall = pcall
1309 function event.new(eventtable)
1310 local self = eventtable or {}
1311 local funcs = {}
1312 local removelist = {}
1313 function self:connect(func)
1314 funcs[#funcs + 1] = func
1315 local removed = false
1316 local function remove()
1317 if not removed then
1318 removed = true
1319 removelist[func] = true
1320 end
1321 end
1322 return remove
1323 end
1324 local function fire(...)
1325 local n = #funcs
1326 local j = 0
1327 for i = 1, n do
1328 local func = funcs[i]
1329 if removelist[func] then
1330 removelist[func] = nil
1331 else
1332 j = j + 1
1333 funcs[j] = func
1334 end
1335 end
1336 for i = j + 1, n do
1337 funcs[i] = nil
1338 end
1339 for i = 1, j do
1340 resume(create(function(...)
1341 pcall(funcs[i], ...)
1342 end), ...)
1343 end
1344 end
1345 return fire, self
1346 end
1347end
1348print("Loading sequencer module")
1349do
1350 local tick = tick
1351 local type = type
1352 local remove = table.remove
1353 function sequencer.new()
1354 local self = {}
1355 local t0
1356 local sequence = {}
1357 local n = 0
1358 local deletions = 0
1359 function self:add(func, dur)
1360 n = n + 1
1361 if n == 1 then
1362 t0 = tick()
1363 end
1364 sequence[n] = {func = func, dur = dur}
1365 end
1366 function self:delay(dur)
1367 n = n + 1
1368 if n == 1 then
1369 t0 = tick()
1370 end
1371 sequence[n] = {dur = dur}
1372 end
1373 function self:clear()
1374 for i = 1, n do
1375 sequence[i] = nil
1376 end
1377 deletions = 0
1378 n = 0
1379 end
1380 function self:step()
1381 local time = tick()
1382 if deletions ~= 0 then
1383 for i = deletions + 1, n do
1384 sequence[i - deletions] = sequence[i]
1385 end
1386 for i = n - deletions + 1, n do
1387 sequence[i] = nil
1388 end
1389 n = n - deletions
1390 deletions = 0
1391 end
1392 for i = 1, n do
1393 local t = time - t0
1394 local func = sequence[i]
1395 local dur = func.dur
1396 local stop = false
1397 if func.func then
1398 stop = func.func(t)
1399 end
1400 if stop or stop == nil or dur and t > dur then
1401 t0 = time
1402 deletions = deletions + 1
1403 else
1404 break
1405 end
1406 end
1407 end
1408 return self
1409 end
1410end
1411print("Loading physics module")
1412do
1413 local sort = table.sort
1414 local atan2 = math.atan2
1415 local inf = math.huge
1416 local cos = math.cos
1417 local sin = math.sin
1418 local setmetatable = setmetatable
1419 local tick = tick
1420 local dot = Vector3.new().Dot
1421 physics.spring = {}
1422 do
1423 local spring = {}
1424 physics.spring = spring
1425 local tick = tick
1426 local setmt = setmetatable
1427 local cos = math.cos
1428 local sin = math.sin
1429 local e = 2.718281828459045
1430 function spring.new(init)
1431 local null = 0 * (init or 0)
1432 local d = 1
1433 local s = 1
1434 local p0 = init or null
1435 local v0 = null
1436 local p1 = init or null
1437 local t0 = tick()
1438 local h = 0
1439 local c1 = null
1440 local c2 = null
1441 local self = {}
1442 local meta = {}
1443 local function updateconstants()
1444 if s == 0 then
1445 h = 0
1446 c1 = null
1447 c2 = null
1448 elseif d < 0.99999999 then
1449 h = (1 - d * d) ^ 0.5
1450 c1 = p0 - p1
1451 c2 = d / h * c1 + v0 / (h * s)
1452 elseif d < 1.00000001 then
1453 h = 0
1454 c1 = p0 - p1
1455 c2 = c1 + v0 / s
1456 else
1457 h = (d * d - 1) ^ 0.5
1458 local a = -v0 / (2 * s * h)
1459 local b = -(p1 - p0) / 2
1460 c1 = (1 - d / h) * b + a
1461 c2 = (1 + d / h) * b - a
1462 end
1463 end
1464 local function pos(x)
1465 if x < 0.001 then
1466 return p0
1467 end
1468 if s == 0 then
1469 return p0
1470 elseif d < 0.99999999 then
1471 local co = cos(h * s * x)
1472 local si = sin(h * s * x)
1473 local ex = e ^ (d * s * x)
1474 return co / ex * c1 + si / ex * c2 + p1
1475 elseif d < 1.00000001 then
1476 local ex = e ^ (s * x)
1477 return (c1 + s * x * c2) / ex + p1
1478 else
1479 local co = e ^ ((-d - h) * s * x)
1480 local si = e ^ ((-d + h) * s * x)
1481 return c1 * co + c2 * si + p1
1482 end
1483 end
1484 local function vel(x)
1485 if x < 0.001 then
1486 return v0
1487 end
1488 if s == 0 then
1489 return p0
1490 elseif d < 0.99999999 then
1491 local co = cos(h * s * x)
1492 local si = sin(h * s * x)
1493 local ex = e ^ (d * s * x)
1494 return s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1495 elseif d < 1.00000001 then
1496 local ex = e ^ (s * x)
1497 return -s / ex * (c1 + (s * x - 1) * c2)
1498 else
1499 local co = e ^ ((-d - h) * s * x)
1500 local si = e ^ ((-d + h) * s * x)
1501 return si * (h - d) * s * c2 - co * (d + h) * s * c1
1502 end
1503 end
1504 local function posvel(x)
1505 if s == 0 then
1506 return p0
1507 elseif d < 0.99999999 then
1508 local co = cos(h * s * x)
1509 local si = sin(h * s * x)
1510 local ex = e ^ (d * s * x)
1511 return co / ex * c1 + si / ex * c2 + p1, s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1512 elseif d < 1.00000001 then
1513 local ex = e ^ (s * x)
1514 return (c1 + s * x * c2) / ex + p1, -s / ex * (c1 + (s * x - 1) * c2)
1515 else
1516 local co = e ^ ((-d - h) * s * x)
1517 local si = e ^ ((-d + h) * s * x)
1518 return c1 * co + c2 * si + p1, si * (h - d) * s * c2 - co * (d + h) * s * c1
1519 end
1520 end
1521 updateconstants()
1522 function self.getpv()
1523 return posvel(tick() - t0)
1524 end
1525 function self.setpv(p, v)
1526 local time = tick()
1527 p0, v0 = p, v
1528 t0 = time
1529 updateconstants()
1530 end
1531 function self:accelerate(a)
1532 local time = tick()
1533 local p, v = posvel(time - t0)
1534 p0, v0 = p, v + a
1535 t0 = time
1536 updateconstants()
1537 end
1538 function meta:__index(index)
1539 local time = tick()
1540 if index == "p" then
1541 return pos(time - t0)
1542 elseif index == "v" then
1543 return vel(time - t0)
1544 elseif index == "t" then
1545 return p1
1546 elseif index == "d" then
1547 return d
1548 elseif index == "s" then
1549 return s
1550 end
1551 end
1552 function meta:__newindex(index, value)
1553 local time = tick()
1554 if index == "p" then
1555 p0, v0 = value, vel(time - t0)
1556 elseif index == "v" then
1557 p0, v0 = pos(time - t0), value
1558 elseif index == "t" then
1559 p0, v0 = posvel(time - t0)
1560 p1 = value
1561 elseif index == "d" then
1562 p0, v0 = posvel(time - t0)
1563 d = value
1564 elseif index == "s" then
1565 p0, v0 = posvel(time - t0)
1566 s = value
1567 elseif index == "a" then
1568 local p, v = posvel(time - t0)
1569 p0, v0 = p, v + value
1570 end
1571 t0 = time
1572 updateconstants()
1573 end
1574 return setmt(self, meta)
1575 end
1576 end
1577 local err = 1.0E-10
1578 local function solve(a, b, c, d, e)
1579 if not a then
1580 return
1581 elseif a > -err and a < err then
1582 return solve(b, c, d, e)
1583 end
1584 if e then
1585 local k = -b / (4 * a)
1586 local p = (8 * a * c - 3 * b * b) / (8 * a * a)
1587 local q = (b * b * b + 8 * a * a * d - 4 * a * b * c) / (8 * a * a * a)
1588 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)
1589 local h0, h1, h2 = solve(1, 2 * p, p * p - 4 * r, -q * q)
1590 local s = h2 or h0
1591 if s < err then
1592 local f0, f1 = solve(1, p, r)
1593 if not f1 or f1 < 0 then
1594 return
1595 else
1596 local f = f1 ^ 0.5
1597 return k - f, k + f
1598 end
1599 else
1600 local h = s ^ 0.5
1601 local f = (h * h * h + h * p - q) / (2 * h)
1602 if f > -err and f < err then
1603 return k - h, k
1604 else
1605 local r0, r1 = solve(1, h, f)
1606 local r2, r3 = solve(1, -h, r / f)
1607 if r0 and r2 then
1608 return k + r0, k + r1, k + r2, k + r3
1609 elseif r0 then
1610 return k + r0, k + r1
1611 elseif r2 then
1612 return k + r2, k + r3
1613 else
1614 return
1615 end
1616 end
1617 end
1618 elseif d then
1619 local k = -b / (3 * a)
1620 local p = (3 * a * c - b * b) / (9 * a * a)
1621 local q = (2 * b * b * b - 9 * a * b * c + 27 * a * a * d) / (54 * a * a * a)
1622 local r = p * p * p + q * q
1623 local s = r ^ 0.5 + q
1624 if s > -err and s < err then
1625 if q < 0 then
1626 return k + (-2 * q) ^ 0.3333333333333333
1627 else
1628 return k - (2 * q) ^ 0.3333333333333333
1629 end
1630 elseif r < 0 then
1631 local m = (-p) ^ 0.5
1632 local d = atan2((-r) ^ 0.5, q) / 3
1633 local u = m * cos(d)
1634 local v = m * sin(d)
1635 return k - 2 * u, k + u - 1.7320508075688772 * v, k + u + 1.7320508075688772 * v
1636 elseif s < 0 then
1637 local m = -(-s) ^ 0.3333333333333333
1638 return k + p / m - m
1639 else
1640 local m = s ^ 0.3333333333333333
1641 return k + p / m - m
1642 end
1643 elseif c then
1644 local k = -b / (2 * a)
1645 local u2 = k * k - c / a
1646 if u2 < 0 then
1647 return
1648 else
1649 local u = u2 ^ 0.5
1650 return k - u, k + u
1651 end
1652 elseif b then
1653 return -b / a
1654 else
1655 return
1656 end
1657 end
1658 physics.solve = solve
1659 local minpos = function(a, b, c, d)
1660 if a and a >= 0 then
1661 return a
1662 elseif b and b >= 0 then
1663 return b
1664 elseif c and c >= 0 then
1665 return c
1666 elseif d and d >= 0 then
1667 return d
1668 end
1669 end
1670 physics.minpos = minpos
1671 local function minposroot(a, b, c, d, e)
1672 return minpos(solve(a, b, c, d, e))
1673 end
1674 physics.minposroot = minposroot
1675 function physics.cpoint_traj_point(v, a, r)
1676 local a0 = -2 * dot(r, v)
1677 local a1 = 2 * (dot(v, v) - dot(a, r))
1678 local a2 = 3 * dot(a, v)
1679 local a3 = dot(a, a)
1680 local t = minpos(solve(a3, a2, a1, a0))
1681 if t then
1682 return t, t * v + t * t / 2 * a
1683 end
1684 end
1685 function physics.simple_trajectory(s, a, r)
1686 local a0 = 4 * dot(r, r)
1687 local a1 = -4 * (dot(a, r) + s * s)
1688 local a2 = dot(a, a)
1689 local u = minpos(solve(a2, a1, a0))
1690 if u then
1691 local t = u ^ 0.5
1692 return r / t - t / 2 * a
1693 end
1694 end
1695 function physics.trajectory(pp, pv, pa, tp, tv, ta, s)
1696 local rp = tp - pp
1697 local rv = tv - pv
1698 local ra = ta - pa
1699 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))
1700 if t0 and t0 > 0 then
1701 return ra * t0 / 2 + tv + rp / t0, t0
1702 elseif t1 and t1 > 0 then
1703 return ra * t1 / 2 + tv + rp / t1, t1
1704 elseif t2 and t2 > 0 then
1705 return ra * t2 / 2 + tv + rp / t2, t2
1706 elseif t3 and t3 > 0 then
1707 return ra * t3 / 2 + tv + rp / t3, t3
1708 end
1709 end
1710end
1711print("Loading particle module")
1712do
1713 local setmt = setmetatable
1714 local remove = table.remove
1715 local airdensity = 0.001225
1716 local ln = math.log
1717 local tan = math.tan
1718 local atan2 = math.atan2
1719 local deg = math.pi / 180
1720 local tick = tick
1721 local playergui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
1722 local camera = game.Workspace.CurrentCamera
1723 local workspace = game.Workspace
1724 local components = CFrame.new().components
1725 local v3 = Vector3.new
1726 local dot = v3().Dot
1727 local ray = Ray.new
1728 local raycast = workspace.FindPartOnRayWithIgnoreList
1729 local raycastwl = workspace.FindPartOnRayWithWhitelist
1730 local c3 = Color3.new
1731 local ud2 = UDim2.new
1732 local new = Instance.new
1733 local ffc = game.FindFirstChild
1734 local players = game:GetService("Players")
1735 local frames = {}
1736 local bullets = {}
1737 local rendignore = {}
1738 local particles = {}
1739 local removelist = {}
1740 local screen = ffc(playergui, "ScreenGui") or new("ScreenGui", playergui)
1741 local time = tick()
1742 local planey, planex, pixelcoef
1743 local cameraposition = camera.CoordinateFrame.p
1744 local cpx, cpy, cpz, cxx, cxy, cxz, cyx, cyy, cyz, czx, czy, czz = components(camera.CoordinateFrame)
1745 function particle.new(prop)
1746 local self = {}
1747 local px, py, pz = 0, 0, 0
1748 local vx, vy, vz = 0, 0, 0
1749 local ax, ay, az = 0, 0, 0
1750 local lx, ly, lz
1751 local culling = prop.culling == nil or prop.culling
1752 local size = prop.size or 1
1753 local bloom = prop.bloom or 0
1754 local brightness = prop.brightness or 1
1755 local style = prop.style or "round"
1756 local maxrange = prop.maxrange or 1000
1757 local cancollide = prop.cancollide == nil or prop.cancollide
1758 local resistance = prop.resistance or 1
1759 local elasticity = prop.elasticity or 0.3
1760 local physicsonly = prop.physicsonly or false
1761 local minexitvelocity = prop.minexitvelocity or 500
1762 local penetrationdepth = prop.penetrationdepth or leleltru and 1000000 or 0.5
1763 local penetrationpower = penetrationdepth
1764 local life = tick() + (prop.life or 10)
1765 local physignore = prop.physicsignore or {
1766 workspace.Ignore,
1767 camera,
1768 char.character
1769 }
1770 local rendignore = prop.renderignore or rendignore
1771 local onstep = prop.onstep
1772 local ontouch = prop.ontouch
1773 local wasrendered = false
1774 local wasobstructed
1775 local distance = 0
1776 local frame
1777 if #frames ~= 0 then
1778 frame = frames[#frames]
1779 frames[#frames] = nil
1780 else
1781 frame = new("ImageLabel", screen)
1782 frame.BorderSizePixel = 0
1783 end
1784 if style == "box" then
1785 frame.BackgroundColor3 = prop.color or c3(1, 1, 1)
1786 frame.BackgroundTransparency = 0
1787 frame.Image = nil
1788 else
1789 frame.ImageColor3 = prop.color or c3(1, 1, 1)
1790 frame.BackgroundTransparency = 1
1791 frame.Image = "rbxassetid://553151967"
1792 if style == "round" then
1793 frame.ScaleType = "Slice"
1794 frame.SliceCenter = Rect.new(512, 512, 512, 512)
1795 elseif style == "oval" then
1796 frame.ScaleType = "Stretch"
1797 end
1798 end
1799 self.frame = frame
1800 if prop.position then
1801 local pos = prop.position
1802 px, py, pz = pos.x, pos.y, pos.z
1803 end
1804 if prop.velocity then
1805 local vel = prop.velocity
1806 vx, vy, vz = vel.x, vel.y, vel.z
1807 end
1808 if prop.acceleration then
1809 local acc = prop.acceleration
1810 ax, ay, az = acc.x, acc.y, acc.z
1811 end
1812 lx = (px - cpx) * cxx + (py - cpy) * cxy + (py - cpz) * cxz
1813 ly = (px - cpx) * cyx + (py - cpy) * cyy + (py - cpz) * cyz
1814 lz = -((px - cpx) * czx + (py - cpy) * czy + (py - cpz) * czz)
1815 wasobstructed = true
1816 function self:remove()
1817 removelist[self] = true
1818 end
1819 local part
1820 do
1821 local bullet
1822 if effects.disabletreyparticles then
1823 if #bullets ~= 0 then
1824 bullet = bullets[#bullets]
1825 bullets[#bullets] = nil
1826 else
1827 bullet = game.ReplicatedStorage.Effects.Bullet:Clone()
1828 bullet.Parent = workspace.Ignore.Bullets
1829 end
1830 bullet.Trail.Color = ColorSequence.new(prop.color or c3(1, 1, 1))
1831 bullet.Board.Dot.ImageColor3 = prop.color or c3(1, 1, 1)
1832 bullet.Board.Enabled = true
1833 bullet.Trail.Enabled = true
1834 self.bullet = bullet
1835 else
1836 self.bullet = false
1837 end
1838 end
1839 function self.step(dt, time)
1840 if life and time > life then
1841 removelist[self] = true
1842 return
1843 end
1844 do
1845 local qx, qy, qz = px, py, pz
1846 local ix, iy, iz = vx, vy, vz
1847 local v = (vx * vx + vy * vy + vz * vz) ^ 0.5
1848 vx, vy, vz = vx + dt * ax, vy + dt * ay, vz + dt * az
1849 local dx, dy, dz = dt / 2 * (ix + vx), dt / 2 * (iy + vy), dt / 2 * (iz + vz)
1850 if cancollide then
1851 local direction = v3(dx, dy, dz)
1852 local hit, pos, norm = raycast(workspace, ray(v3(px, py, pz), direction), physignore)
1853 if hit then
1854 local unit = direction.unit
1855 local dir = hit.Size.magnitude * unit
1856 local nextpos = pos + dir
1857 local _, exit, exitnorm = raycastwl(workspace, ray(nextpos, -dir), {hit})
1858 local diff = exit - pos
1859 local dist = diff.magnitude
1860 local pass = not hit.CanCollide
1861 local human = replication.getcharhitinfo(hit, pos, dir)
1862 local penetrationratio
1863 if penetrationpower == 0 then
1864 penetrationratio = 1
1865 else
1866 penetrationratio = penetrationdepth / penetrationpower
1867 end
1868 if dist > 0 then
1869 if pass then
1870 px, py, pz = exit.x, exit.y, exit.z
1871 elseif dist < penetrationdepth then
1872 local newexit = pos + 0.01 * unit
1873 px, py, pz = newexit.x, newexit.y, newexit.z
1874 local rx, ry, rz = px - qx, py - qy, pz - qz
1875 distance = distance + (pos - v3(qx, qy, qz)).magnitude
1876 local gv = 2.7182818459045 ^ (-resistance * dist)
1877 vx, vy, vz = gv * vx, gv * vy, gv * vz
1878 penetrationdepth = human and penetrationdepth or penetrationdepth - dist
1879 else
1880 removelist[self] = true
1881 px, py, pz = pos.x, pos.y, pos.z
1882 end
1883 else
1884 if not pass then
1885 removelist[self] = true
1886 end
1887 px, py, pz = nextpos.x, nextpos.y, nextpos.z
1888 local gv = 2.7182818459045 ^ (-resistance * dot(unit, nextpos - pos))
1889 vx, vy, vz = gv * vx, gv * vy, gv * vz
1890 end
1891 if ontouch then
1892 ontouch(part, human and human.object or hit, pos, norm, penetrationratio, human and human.player)
1893 end
1894 physignore[#physignore + 1] = human and human.character or hit
1895 else
1896 px, py, pz = px + dx, py + dy, pz + dz
1897 end
1898 else
1899 local rx, ry, rz = px - qx, py - qy, pz - qz
1900 distance = distance + (rx * rx + ry * ry + rz * rz) ^ 0.5
1901 px, py, pz = px + dx, py + dy, pz + dz
1902 end
1903 local rx, ry, rz = px - qx, py - qy, pz - qz
1904 distance = distance + (rx * rx + ry * ry + rz * rz) ^ 0.5
1905 if self.bullet then
1906 self.bullet.CFrame = CFrame.new(px, py, pz)
1907 end
1908 end
1909 if onstep then
1910 onstep(part, dt)
1911 end
1912 if prop.physicsonly then
1913 return "physics only"
1914 end
1915 if not self.bullet then
1916 local rx, ry, rz = px - cpx, py - cpy, pz - cpz
1917 local dx = rx * cxx + ry * cxy + rz * cxz
1918 local dy = rx * cyx + ry * cyy + rz * cyz
1919 local dz = -(rx * czx + ry * czy + rz * czz)
1920 if brightness == 0 or dz < 1 and lz < 1 then
1921 if wasrendered then
1922 wasrendered = false
1923 frame.BackgroundTransparency = 1
1924 frame.ImageTransparency = 1
1925 end
1926 lx, ly, lz = dx, dy, dz
1927 wasobstructed = false
1928 return "behind or tansparent"
1929 end
1930 local obstructed
1931 if maxrange * maxrange < dx * dx + dy * dy + dz * dz then
1932 obstructed = true
1933 elseif culling then
1934 obstructed = raycast(workspace, ray(cameraposition, v3(px, py, pz) - cameraposition), rendignore)
1935 end
1936 if obstructed or wasobstructed then
1937 if wasrendered then
1938 wasrendered = false
1939 frame.BackgroundTransparency = 1
1940 frame.ImageTransparency = 1
1941 end
1942 lx, ly, lz = dx, dy, dz
1943 wasobstructed = obstructed
1944 return "obstructed"
1945 end
1946 local rx, ry, rdepth, sx, sy, sdepth
1947 if dz > 1 and lz > 1 then
1948 rx, ry, rdepth = lx / lz, ly / lz, lz
1949 sx, sy, sdepth = dx / dz, dy / dz, dz
1950 elseif dz < 1 then
1951 local d = (1 - dz) / (lz - dz)
1952 rx, ry, rdepth = lx / lz, ly / lz, lz
1953 sx, sy, sdepth = d * (lx - dx) + dx, d * (ly - dy) + dy, 1
1954 else
1955 local d = (1 - lz) / (dz - lz)
1956 rx, ry, rdepth = d * (dx - lx) + lx, d * (dy - ly) + ly, 1
1957 sx, sy, sdepth = dx / dz, dy / dz, dz
1958 end
1959 if rx < -planex and sx < -planex or rx > planex and sx > planex or ry < -planey and sy < -planey or ry > planey and sy > planey then
1960 if wasrendered then
1961 wasrendered = false
1962 frame.BackgroundTransparency = 1
1963 frame.ImageTransparency = 1
1964 end
1965 lx, ly, lz = dx, dy, dz
1966 wasobstructed = obstructed
1967 return "off screen"
1968 end
1969 local slope = (sy - ry) / (sx - rx)
1970 local hx, hy, hz = dx - lx, dy - ly, dz - lz
1971 if rx < -planex and sx > -planex then
1972 rx, ry = -planex, sy - slope * (planex + sx)
1973 rdepth = lz - (lz * planex + lx) / (hz * planex + hx) * hz
1974 elseif rx > -planex and sx < -planex then
1975 sx, sy = -planex, ry - slope * (planex + rx)
1976 sdepth = lz - (lz * planex + lx) / (hz * planex + hx) * hz
1977 end
1978 if rx < planex and sx > planex then
1979 sx, sy = planex, ry + slope * (planex - rx)
1980 sdepth = lz - (lz * planex - lx) / (hz * planex - hx) * hz
1981 elseif rx > planex and sx < planex then
1982 rx, ry = planex, sy + slope * (planex - sx)
1983 rdepth = lz - (lz * planex - lx) / (hz * planex - hx) * hz
1984 end
1985 if ry < -planey and sy > -planey then
1986 ry, rx = -planey, sx - (planey + sy) / slope
1987 rdepth = lz - (lz * planey + ly) / (hz * planey + hy) * hz
1988 elseif ry > -planey and sy < -planey then
1989 sy, sx = -planey, rx - (planey + ry) / slope
1990 sdepth = lz - (lz * planey + ly) / (hz * planey + hy) * hz
1991 end
1992 if ry < planey and sy > planey then
1993 sy, sx = planey, rx + (planey - ry) / slope
1994 sdepth = lz - (lz * planey - ly) / (hz * planey - hy) * hz
1995 elseif ry > planey and sy < planey then
1996 ry, rx = planey, sx + (planey - sy) / slope
1997 rdepth = lz - (lz * planey - ly) / (hz * planey - hy) * hz
1998 end
1999 local ux, uy = pixelcoef * (rx + planex), pixelcoef * (planey - ry) - 36
2000 local vx, vy = pixelcoef * (sx + planex), pixelcoef * (planey - sy) - 36
2001 local wx, wy = vx - ux, vy - uy
2002 local s = pixelcoef * size / (rdepth * sdepth) ^ 0.5
2003 local area = s * s
2004 local b = pixelcoef * bloom + s
2005 local sx, sy = (wx * wx + wy * wy) ^ 0.5 + b, b
2006 local transparency = 1 - brightness * area / (sx * sy)
2007 frame.Size = ud2(0, sx, 0, sy)
2008 frame.Position = ud2(0, (ux + vx - sx) / 2, 0, (uy + vy - s) / 2)
2009 if prop.style == "box" then
2010 frame.BackgroundTransparency = transparency
2011 else
2012 frame.ImageTransparency = transparency
2013 end
2014 if wx ~= 0 then
2015 frame.Rotation = atan2(wy, wx) / deg
2016 end
2017 lx, ly, lz = dx, dy, dz
2018 wasrendered = true
2019 wasobstructed = obstructed
2020 return "rendered"
2021 end
2022 end
2023 particles[#particles + 1] = self
2024 local get = {}
2025 local set = {}
2026 local meta = {}
2027 function meta.__index(table, index)
2028 return get[index]()
2029 end
2030 function meta.__newindex(table, index, value)
2031 return set[index](value)
2032 end
2033 function get.position()
2034 return v3(px, py, pz)
2035 end
2036 function get.velocity()
2037 return v3(vx, vy, vz)
2038 end
2039 function get.acceleration()
2040 return v3(ax, ay, az)
2041 end
2042 function get.cancollide()
2043 return cancollide
2044 end
2045 function get.size()
2046 return size
2047 end
2048 function get.bloom()
2049 return bloom
2050 end
2051 function get.brightness()
2052 return brightness
2053 end
2054 function get.color()
2055 return frame.BackgroundColor3
2056 end
2057 function get.life()
2058 return life - tick()
2059 end
2060 function get.distance()
2061 return distance
2062 end
2063 function set.position(p)
2064 px, py, pz = p.x, p.y, p.z
2065 end
2066 function set.velocity(v)
2067 vx, vy, vz = v.x, v.y, v.z
2068 end
2069 function set.acceleration(a)
2070 ax, ay, az = a.x, a.y, a.z
2071 end
2072 function set.cancollide(newcancollide)
2073 cancollide = newcancollide
2074 end
2075 function set.size(newsize)
2076 size = newsize
2077 end
2078 function set.bloom(newbloom)
2079 bloom = newbloom
2080 end
2081 function set.brightness(newbrightness)
2082 brightness = newbrightness
2083 end
2084 function set.color(newcolor)
2085 frame.BackgroundColor3 = newcolor
2086 end
2087 function set.life(newlife)
2088 life = tick() + newlife
2089 end
2090 part = setmt(self, meta)
2091 if prop.dt then
2092 self.step(prop.dt, tick())
2093 end
2094 return part
2095 end
2096 local avg = 800
2097 local asd = 0
2098 function particle.step(dt)
2099 local newtime = tick()
2100 local dt = newtime - time
2101 time = newtime
2102 local cameracf = camera.CoordinateFrame
2103 local screenx, screeny = camera.ViewportSize.x, camera.ViewportSize.y
2104 planey = tan(camera.FieldOfView / 2 * deg)
2105 planex = screenx / screeny * planey
2106 pixelcoef = screeny / (2 * planey)
2107 cameraposition = cameracf.p
2108 cpx, cpy, cpz, cxx, cyx, czx, cxy, cyy, czy, cxz, cyz, czz = components(cameracf)
2109 local j = 0
2110 for i = 1, #particles do
2111 local p = particles[i]
2112 particles[i] = nil
2113 if removelist[p] then
2114 p.frame.BackgroundTransparency = 1
2115 p.frame.ImageTransparency = 1
2116 frames[#frames + 1] = p.frame
2117 if p.bullet then
2118 p.bullet.Board.Enabled = false
2119 p.bullet.Trail.Enabled = false
2120 bullets[#bullets + 1] = p.bullet
2121 end
2122 removelist[p] = nil
2123 elseif p then
2124 p.step(dt, time)
2125 j = j + 1
2126 particles[j] = p
2127 end
2128 end
2129 if #particles > 0 then
2130 local d = #particles / 60 / (tick() - time)
2131 avg = avg * 0.95 + d * 0.05
2132 end
2133 if asd == 0 then
2134 end
2135 asd = (asd + 1) % 60
2136 end
2137 function particle:addtorenderignore(object)
2138 for i = 1, #rendignore do
2139 if rendignore[i] == object then
2140 return
2141 end
2142 end
2143 local init = #rendignore + 1
2144 rendignore[init] = object
2145 object.Changed:connect(function(prop)
2146 if prop == "Parent" and not object.Parent then
2147 for i = init, 1, -1 do
2148 if rendignore[i] == object then
2149 remove(rendignore, i)
2150 break
2151 end
2152 end
2153 end
2154 end)
2155 end
2156 function particle:reset()
2157 screen:ClearAllChildren()
2158 workspace.Ignore.Bullets:ClearAllChildren()
2159 bullets = {}
2160 frames = {}
2161 particles = {}
2162 end
2163 screen.AncestryChanged:connect(function()
2164 wait()
2165 screen.Parent = playergui
2166 end)
2167end
2168print("Loading sound module")
2169do
2170 local random = math.random
2171 local new = Instance.new
2172 local fonts = {}
2173 local free = {}
2174 function sound.load(name, ...)
2175 local font = {
2176 ...
2177 }
2178 for i = 1, #font do
2179 font[i] = "rbxassetid://" .. font[i]
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", workspace)
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.Parent = parent or workspace
2199 soundobject.SoundId = font[random(1, #font)]
2200 soundobject.Volume = volume or 1
2201 soundobject.Pitch = pitch or 1
2202 soundobject.Looped = isLooped
2203 if onDestroy then
2204 soundobject.PlayOnRemove = true
2205 else
2206 soundobject:Play()
2207 end
2208 end
2209 end
2210 end
2211 sound.load("equipCloth", 873041870, 873041900, 873041920, 873041944, 873041967, 873041996)
2212 sound.load("equipGear", 873042033, 873042054, 873042146, 873042186, 873042220, 873042247)
2213 sound.load("smallSharp", 1073249423, 1073249467, 1073249515)
2214 sound.load("smallSharpEquip", 1073252883, 1073252922)
2215 sound.load("bigSharp", 1073259492, 1073259546)
2216 sound.load("bigSharpEquip", 1073259576)
2217 sound.load("saber", 1073290506, 1073290552, 1073290611)
2218 sound.load("saberEquip", 1073290296, 1073290384, 1073290458)
2219 sound.load("saberLoop", 1073293116)
2220 sound.load("smallBluntEquip", 1073355154)
2221 sound.load("bigBluntEquip", 1073355392)
2222 sound.load("bigBlunt", 1073356333, 1073356365, 1073356402)
2223 sound.load("smallBlunt", 1073356781)
2224 sound.load("aimCloth", 873073597, 873073657, 873073703, 873073749, 873073824, 873073853)
2225 sound.load("aimGear", 873073890, 873073947, 873073999, 873074053, 873074075, 873074102)
2226 sound.load("parkour", 873084310, 873084337, 873084366, 873084394, 873084419, 873084440)
2227 sound.load("stanceProne", 619647373, 619647453)
2228 sound.load("stanceStandCrouch", 619647649, 619649245, 619649367)
2229 sound.load("slideStart", 873104808, 873104834, 873104858, 873104886, 873104915, 873104940)
2230 sound.load("slideEnd", 873101789, 873101811, 873101828)
2231 sound.load("heartBeatIn", 635546179)
2232 sound.load("heartBeatOut", 635546243)
2233 sound.load("useScope", 635546067)
2234 sound.load("killshot", 898398768, 898398730, 898398743)
2235 sound.load("headshotkill", 898398768, 898398785, 898398795, 898398809, 898398817, 898398837)
2236 sound.load("crackSmall", 873119768, 873119788, 873119811, 873119845, 873119886, 873119904)
2237 sound.load("crackBig", 873119597, 873119653, 873119679, 873119703, 873119724, 873119744)
2238 sound.load("whizz", 873121840, 873121858, 873121876, 873121896, 873121913, 873121936)
2239 sound.load("1PsniperBass", 725750810, 725750891, 725750973)
2240 sound.load("1PsniperEcho", 725751043, 725751110, 725751178)
2241 sound.load("fragClose", 873196488, 873196525, 873196559, 873196591, 873196633, 873196678)
2242 sound.load("fragMed", 873196719, 873196759, 873196789, 873196821, 873196855, 873196883, 873196918, 873196944)
2243 sound.load("fragFar", 873196972, 873196997, 873197013, 873197044, 873197083, 873197117)
2244 sound.load("friendly_concreterun", 738449694, 738449739, 738449789, 738449845, 738449901, 738449961)
2245 sound.load("friendly_concretewalk", 738450012, 738450072, 738450121, 738450173, 738450221, 738450271)
2246 sound.load("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2247 sound.load("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2248 sound.load("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2249 sound.load("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2250 sound.load("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2251 sound.load("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2252 sound.load("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2253 sound.load("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2254 sound.load("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2255 sound.load("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2256 sound.load("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2257 sound.load("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2258 sound.load("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2259 sound.load("concreteLand", 623307723, 623307791, 623307897)
2260 sound.load("grassLand", 623322852, 623322902, 623322960)
2261 sound.load("sandLand", 623308020, 623322719, 623322784)
2262 sound.load("woodLand", 623329224, 623329303, 623329368)
2263 sound.load("metalLand", 866618834, 866618870, 866618897, 866618921)
2264 sound.load("landHard", 866638867)
2265 sound.load("landNearDeath", 866639973)
2266 sound.load("enemy_concreterun", 739281446, 739281465, 739281494, 739281525, 739281543, 739281565)
2267 sound.load("enemy_concretewalk", 739281325, 739281342, 739281360, 739281381, 739281395, 739281423)
2268 sound.load("enemy_woodrun", 739377453, 739377475, 739377503, 739377526, 739377546, 739377556)
2269 sound.load("enemy_woodwalk", 739377579, 739377595, 739377625, 739377652, 739377685, 739377713)
2270 sound.load("enemy_grassrun", 739805543, 739805588, 739805641, 739805681, 739805724, 739805762)
2271 sound.load("enemy_grasswalk", 739805800, 739805889, 739805996, 739806047, 739806110, 739806155)
2272 sound.load("enemy_sandrun", 744274870, 744274901, 744274936, 744274967, 744275010, 744275043)
2273 sound.load("enemy_sandwalk", 744275075, 744275099, 744275126, 744275156, 744275192, 744275220)
2274 sound.load("enemy_metalrun", 758173026, 758173133, 758173185, 758173250, 758173441, 758173516)
2275 sound.load("enemy_metalwalk", 758173608, 758173682, 758173759, 758173891, 758173986, 758174065)
2276 sound.load("movement_gearsmall", 677006227, 677006264, 677006302, 677006342, 677006383, 677007056, 677007096, 677007128)
2277 sound.load("movement_gearbig", 677010268, 677010313, 677010351, 677010399, 677010436, 677010482, 677010520, 677010549)
2278 sound.load("movement_clothrun", 724561895, 724561958, 724561997, 724562031)
2279 sound.load("movement_clothwalk", 724559173, 724559198, 724559218, 724559241)
2280 sound.load("movement_base", 676998794, 676998859, 676998915, 676998993, 676999050, 676999094, 676999145, 676999188, 676999245, 676999327, 676999356, 676999395)
2281 sound.load("imp_concrete", 871701076, 871701134, 871701190, 871701241, 871701297, 871701346)
2282 sound.load("imp_metal", 871704182, 871704259, 871704297, 871704329, 871704362, 871704395)
2283 sound.load("imp_wood", 871705143, 871705174, 871705195, 871705217, 871705237, 871705264)
2284 sound.load("imp_grass", 871709869, 871709832, 871709789, 871709755, 871709708, 871709643)
2285 sound.load("wizz", 342190005, 342190012, 342190017, 342190024)
2286 sound.load("snap", 342190488, 342190495, 342190504, 342190510)
2287 sound.load("woodhit", 342204157, 342204164, 342204170, 342204175)
2288 sound.load("stonehit", 342204189, 342204194, 342204197, 342204203)
2289 sound.load("metalhit", 342204233, 342204240, 342204244, 342204250)
2290 sound.load("woodstep", 169160364)
2291 sound.load("hardstep", 135923526, 342422087, 131436155)
2292 sound.load("softstep", 134456884)
2293 sound.load("fullmetalstep", 342421947, 342421958, 342421973, 342421997)
2294 sound.load("hollowmetalstep", 342421947, 342421958, 342421973, 342421997)
2295 sound.load("metalshell", 342423812, 342423826, 342423844, 342423860)
2296 sound.load("shotgunshell", 342423873, 342423885)
2297end
2298globalsound = sound
2299globalnetwork = network
2300globalreplication = replication
2301print("Loading effects module")
2302do
2303 local wfc = game.WaitForChild
2304 local ffc = game.FindFirstChild
2305 local ud2 = UDim2.new
2306 local v3 = Vector3.new
2307 local nv = v3()
2308 local cf = CFrame.new
2309 local angles = CFrame.Angles
2310 local deg = math.pi / 180
2311 local random = math.random
2312 local color = Color3.new
2313 local colorseq = ColorSequence.new
2314 local spawn = function(F)
2315 coroutine.resume(coroutine.create(F))
2316 end
2317 local ray = Ray.new
2318 local raycast = workspace.FindPartOnRayWithIgnoreList
2319 local debris = game.Debris
2320 local new = Instance.new
2321 local dot = nv.Dot
2322 local nc = cf()
2323 local vtws = nc.vectorToWorldSpace
2324 local player = game:GetService("Players").LocalPlayer
2325 local light = game.Lighting
2326 local pgui = player.PlayerGui
2327 local repeffects = game.ReplicatedStorage.Effects
2328 local smoke = repeffects.Smoke
2329 local hole = repeffects.Hole
2330 local flash = repeffects.Muzzle
2331 local shell = repeffects.Shell
2332 local blood = repeffects.Blood
2333 local bloodsplat = repeffects.BloodSplat
2334 local ignore = workspace.Ignore
2335 local mapbloom = wfc(light, "MapBloom")
2336 local mapray = wfc(light, "MapRay")
2337 local mapsat = wfc(light, "MapSaturation")
2338 local smokelist = {}
2339 local holelist = {}
2340 local flashlist = {}
2341 local shelllist = {}
2342 local impactpool = {}
2343 local effectobjects = repeffects.effectobjects
2344 local materialtype = Enum.Material
2345 local materiallist = {
2346 [Enum.Material.Cobblestone] = {
2347 185234383,
2348 185234399,
2349 185234373,
2350 185234412
2351 },
2352 [Enum.Material.Wood] = {
2353 185238181,
2354 185238234,
2355 185238224,
2356 185238210,
2357 185238204
2358 },
2359 [Enum.Material.Brick] = {
2360 185237818,
2361 185237842,
2362 185237826,
2363 185237805
2364 },
2365 [Enum.Material.Plastic] = {
2366 185238152,
2367 185237945,
2368 185237930
2369 },
2370 [Enum.Material.Concrete] = {
2371 185237894,
2372 185237879,
2373 185237865,
2374 185237853
2375 },
2376 Tile = {
2377 185238332,
2378 185238308,
2379 185238298,
2380 185238288,
2381 185238271,
2382 185238257
2383 }
2384 }
2385 local splatter
2386 do
2387 local sort = table.sort
2388 local random = math.random
2389 local log = math.log
2390 local cos = math.cos
2391 local sin = math.sin
2392 local tau = 2 * math.pi
2393 local function gaussian()
2394 local r0 = 1 - random()
2395 local r1 = random() * tau
2396 local l = (-2 * log(r0)) ^ 0.5
2397 return l * cos(r1), l * sin(r1)
2398 end
2399 local function exponential()
2400 return -log(1 - random())
2401 end
2402 local boxn = {
2403 v3(1, 0, 0),
2404 v3(-1, 0, 0),
2405 v3(0, 1, 0),
2406 v3(0, -1, 0),
2407 v3(0, 0, 1),
2408 v3(0, 0, -1)
2409 }
2410 local boxl = {
2411 0.5,
2412 0.5,
2413 0.5,
2414 0.5,
2415 0.5,
2416 0.5
2417 }
2418 local function transform_mesh(meshn, meshl, cframe, size)
2419 local newn = {}
2420 local newl = {}
2421 for i = 1, #meshn do
2422 local n = meshn[i]
2423 local l = meshl[i]
2424 local tn = vtws(cframe, n / size).unit
2425 local tl = dot(cframe * (l * n * size), tn)
2426 newn[i] = tn
2427 newl[i] = tl
2428 end
2429 return newn, newl
2430 end
2431 local function distance_o_1(an, al, o)
2432 local oan = dot(o, an)
2433 return oan - al
2434 end
2435 local function distance_o_2(an, al, bn, bl, o)
2436 local anbn = dot(an, bn)
2437 local oan = dot(o, an)
2438 local obn = dot(o, bn)
2439 local m = (1 - anbn * anbn) ^ 0.5
2440 return (bl - al * anbn + anbn * oan - obn) / m
2441 end
2442 local function dist_from_edge(meshn, meshl, o)
2443 local besta
2444 local bestd = -1 / 0
2445 for i = 1, #meshn do
2446 local an = meshn[i]
2447 local al = meshl[i]
2448 local d = distance_o_1(an, al, o)
2449 if bestd < d then
2450 besta = i
2451 bestd = d
2452 end
2453 end
2454 if not besta then
2455 return 1 / 0
2456 end
2457 local an = meshn[besta]
2458 local al = meshl[besta]
2459 local r = 1 / 0
2460 for i = 1, #meshn do
2461 if i ~= besta then
2462 local bn = meshn[i]
2463 local bl = meshl[i]
2464 local d = distance_o_2(an, al, bn, bl, o)
2465 if r > d then
2466 r = d
2467 end
2468 end
2469 end
2470 return r
2471 end
2472 local meshcache = {}
2473 local function getmesh(part)
2474 local cache = meshcache[part]
2475 if cache then
2476 return cache.meshn, cache.meshl
2477 else
2478 do
2479 local cframe = part.CFrame
2480 local size = part.Size
2481 local meshn, meshl = transform_mesh(boxn, boxl, part.CFrame, part.Size)
2482 meshcache[part] = {meshn = meshn, meshl = meshl}
2483 local event
2484 event = part.Changed:connect(function()
2485 meshcache[part] = nil
2486 event:disconnect()
2487 end)
2488 return meshn, meshl
2489 end
2490 end
2491 end
2492 local function max_radius(part, pos)
2493 local meshn, meshl = getmesh(part)
2494 return dist_from_edge(meshn, meshl, pos)
2495 end
2496 local spartpool = {}
2497 local function getspart()
2498 local pooledpart = spartpool[#spartpool]
2499 if pooledpart then
2500 spartpool[#spartpool] = nil
2501 return pooledpart
2502 else
2503 local spart = Instance.new("Part")
2504 spart.Shape = "Cylinder"
2505 spart.Anchored = true
2506 spart.CanCollide = false
2507 spart.BrickColor = BrickColor.new("Crimson")
2508 return spart
2509 end
2510 end
2511 local function retirespart(part)
2512 spartpool[#spartpool + 1] = part
2513 end
2514 local function sortandmerge(slist, ulist, lt)
2515 sort(ulist, lt)
2516 local mlist = {}
2517 local m = #slist
2518 local n = #ulist
2519 local i = 1
2520 local j = 1
2521 local k = 0
2522 while m >= i and n >= j do
2523 k = k + 1
2524 local a = slist[i]
2525 local b = ulist[j]
2526 if lt(a, b) then
2527 i = i + 1
2528 mlist[k] = a
2529 else
2530 j = j + 1
2531 mlist[k] = b
2532 end
2533 end
2534 for l = i, m do
2535 k = k + 1
2536 mlist[k] = slist[l]
2537 end
2538 for l = j, n do
2539 k = k + 1
2540 mlist[k] = ulist[l]
2541 end
2542 return mlist
2543 end
2544 local queuedsplatters = {}
2545 local queuedretires = {}
2546 local nsplatters = 0
2547 local splatters = {}
2548 local nretires = 0
2549 local retires = {}
2550 local maxbloodt = 1
2551 local compt0 = function(a, b)
2552 return b.t0 < a.t0
2553 end
2554 local compt1 = function(a, b)
2555 return b.t1 < a.t1
2556 end
2557 function effects.setmaxbloodt(newt)
2558 maxbloodt = newt
2559 end
2560 game:GetService("RunService").RenderStepped:connect(function()
2561 debug.profilebegin("blood creation/removal")
2562 local t = tick()
2563 if nsplatters > 0 then
2564 queuedsplatters = sortandmerge(queuedsplatters, splatters, compt0)
2565 nsplatters = 0
2566 splatters = {}
2567 end
2568 for i = #queuedsplatters, 1, -1 do
2569 if maxbloodt / 1000 < tick() - t then
2570 break
2571 end
2572 local splat = queuedsplatters[i]
2573 if t > splat.t0 then
2574 queuedsplatters[i] = nil
2575 local spart = getspart()
2576 local size = splat.size
2577 local part = splat.part
2578 local norm = splat.norm
2579 local pos = splat.pos
2580 local maxsize = 2 * max_radius(part, pos)
2581 if size > maxsize then
2582 size = maxsize
2583 end
2584 local spart = getspart()
2585 spart.Size = v3(0.05, size, size)
2586 spart.CFrame = cf(pos, pos + norm) * angles(0, tau / 4, 0)
2587 spart.Parent = workspace.Ignore
2588 nretires = nretires + 1
2589 retires[nretires] = {
2590 t1 = splat.t1,
2591 spart = spart
2592 }
2593 else
2594 break
2595 end
2596 end
2597 if nretires > 0 then
2598 queuedretires = sortandmerge(queuedretires, retires, compt1)
2599 nretires = 0
2600 retires = {}
2601 end
2602 for i = #queuedretires, 1, -1 do
2603 if maxbloodt / 1000 < tick() - t then
2604 break
2605 end
2606 local retire = queuedretires[i]
2607 if t > retire.t1 then
2608 queuedretires[i] = nil
2609 retire.spart.Parent = nil
2610 retirespart(retire.spart)
2611 else
2612 break
2613 end
2614 end
2615 debug.profileend()
2616 end)
2617 function splatter(splots, avgsize, orig, velocity, spread, dist, ignorelist, life0, life1)
2618 debug.profilebegin("blood initialization")
2619 local ct = tick()
2620 local v = spread * velocity.magnitude
2621 for i = 1, splots do
2622 local r0, r1 = gaussian()
2623 local r2 = gaussian()
2624 local r3 = exponential()
2625 local dir = velocity + v3(v * r0, v * r1, v * r2)
2626 local size = avgsize * r3
2627 local part, pos, norm = raycast(workspace, ray(orig, dist * dir.unit), ignorelist)
2628 if part then
2629 nsplatters = nsplatters + 1
2630 local t0 = ct + dot(dir, pos - orig) / dot(dir, dir)
2631 local t1 = t0 + random() * (life1 - life0) + life0
2632 splatters[nsplatters] = {
2633 t0 = t0,
2634 t1 = t1,
2635 size = size,
2636 part = part,
2637 norm = norm,
2638 pos = pos
2639 }
2640 end
2641 end
2642 debug.profileend()
2643 end
2644 end
2645 function effects:ejectshell(trigger, guntype, offset)
2646 local shellpart
2647 if #shelllist ~= 0 then
2648 shellpart = shelllist[#shelllist]
2649 shelllist[#shelllist] = nil
2650 else
2651 shellpart = shell:Clone()
2652 end
2653 delay(0.1, function()
2654 shellpart.CFrame = trigger.CFrame * angles((90 + random(-5, 5)) * deg, random(-5, 5) * deg, random(-5, 5) * deg) * offset
2655 shellpart.RotVelocity = v3(random(-5, 5), random(-5, 5), random(-5, 5))
2656 shellpart.Parent = ignore
2657 shellpart.BodyThrust.force = v3(3.5, 0.1, -3)
2658 wait(0.05)
2659 shellpart.BodyThrust.force = v3(-0.5, 0, 0)
2660 wait(0.1)
2661 shellpart.BodyThrust.force = v3(0, 0, 0)
2662 wait(0.1)
2663 shellpart.Velocity = v3()
2664 shellpart.Parent = nil
2665 shelllist[#shelllist + 1] = shellpart
2666 end)
2667 end
2668 function effects:muzzleflash(barrel)
2669 local flashpart
2670 if #flashlist ~= 0 then
2671 flashpart = flashlist[#flashlist]
2672 flashlist[#flashlist] = nil
2673 else
2674 flashpart = flash:Clone()
2675 end
2676 local flare = ffc(flashpart, "Flare")
2677 local spark = ffc(flashpart, "Spark")
2678 if not flare or not spark then
2679 trash.remove(flashpart)
2680 flashpart = flash:Clone()
2681 flare = ffc(flashpart, "Flare")
2682 spark = ffc(flashpart, "Spark")
2683 end
2684 flashpart.Enabled = true
2685 flashpart.Parent = pgui
2686 flashpart.Adornee = barrel
2687 flare.Rotation = random(0, 360)
2688 flare.Size = ud2(0, 20, 0, 20)
2689 flare.Position = ud2(0.5, -10, 0.5, -10)
2690 spark.Rotation = random(0, 360)
2691 spark.Size = ud2(0, 200, 0, 200)
2692 spark.Position = ud2(0.5, -100, 0.5, -100)
2693 spark.Visible = true
2694 flare:TweenSizeAndPosition(ud2(0, 1000, 0, 1000), ud2(0.5, -500, 0.5, -500), "Out", "Sine", 0.2)
2695 spark:TweenSizeAndPosition(ud2(0, 500, 0, 500), ud2(0.5, -250, 0.5, -250), "Out", "Sine", 0.15)
2696 delay(0.05, function()
2697 spark.Visible = false
2698 wait(0.05)
2699 flashpart.Enabled = false
2700 wait(0.5)
2701 flashpart.Parent = nil
2702 flashlist[#flashlist + 1] = flashpart
2703 end)
2704 char:firemuzzlelight()
2705 end
2706 function effects:breakwindow(hit, pos, norm, force, nobulleteffect)
2707 hit.Parent = ignore
2708 network:send("b" .. "r" .. "e" .. "a" .. "k" .. "w" .. "i" .. "n" .. "d" .. "o" .. "w", hit)
2709 if not nobulleteffect then
2710 effects:bullethit(hit, pos, norm, false, false, 3)
2711 end
2712 end
2713 function effects:bloodhit(start, hit, pos, norm, enablesplatter, damage, velocity)
2714 local damage = damage or 20
2715 if damage > 100 then
2716 damage = 100
2717 end
2718 network:send("b" .. "l" .. "o" .. "o" .. "d" .. "h" .. "i" .. "t", start, hit, pos, norm, enablesplatter, damage / 3, velocity)
2719 createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2720 end
2721 function effects:enablemapshaders(on)
2722 local shaderlist = {mapsat, mapray}
2723 for i = 1, #shaderlist do
2724 if effects.disableshaders then
2725 shaderlist[i].Enabled = false
2726 else
2727 shaderlist[i].Enabled = on
2728 end
2729 end
2730 end
2731 function createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2732 if input.consoleon or effects.disableblood then
2733 return
2734 end
2735 local size = 1
2736 local ignorelist = {
2737 ignore,
2738 workspace.DeadBody,
2739 workspace.CurrentCamera
2740 }
2741 local pp = game:GetService("Players"):GetPlayers()
2742 for i = 1, #pp do
2743 ignorelist[#ignorelist + 1] = pp[i].Character
2744 end
2745 if enablesplatter then
2746 local damage = damage or 20
2747 local splots = damage / 2
2748 splatter(splots, 0.5, pos, velocity, 0.125, 20, ignorelist, 7, 15)
2749 end
2750 local bloodpart = hole:Clone()
2751 bloodpart.Parent = ignore
2752 bloodpart.CFrame = cf(pos)
2753 bloodpart.Transparency = 1
2754 bloodpart:ClearAllChildren()
2755 local test = repeffects.BloodTest:Clone()
2756 test.Parent = bloodpart
2757 test.Rate = test.Rate * size
2758 test.Enabled = true
2759 spawn(function()
2760 wait(0.1)
2761 test.Enabled = false
2762 end)
2763 debris:AddItem(bloodpart, 3)
2764 end
2765 network:add("createblood", createblood)
2766 function effects:bullethit(hit, pos, norm, smokeon, holeon, sparkson)
2767 if hit.Transparency == 1 then
2768 return
2769 end
2770 local light = hit:FindFirstChildOfClass("SpotLight") or hit:FindFirstChildOfClass("PointLight") or hit:FindFirstChildOfClass("SurfaceLight")
2771 if light then
2772 light:Destroy()
2773 for i = 1, 10 do
2774 particle.new({
2775 position = pos,
2776 velocity = norm * 30 + vector.random(10),
2777 acceleration = v3(0, -20, 0),
2778 cancollide = false,
2779 size = 0.1,
2780 brightness = 20 * random(),
2781 color = Color3.new(1, 1, 0.8),
2782 bloom = 0.005 * random(),
2783 life = 10,
2784 physicsonly = true
2785 })
2786 end
2787 network:send("breaklights", hit)
2788 end
2789 if not effects.disablerobloxparticles and smokeon then
2790 do
2791 local impacttype
2792 if hit.Name == "Terrain" then
2793 impacttype = "ImpactWater"
2794 elseif hit.Material == Enum.Material.Grass then
2795 impacttype = "ImpactGrass"
2796 elseif eventmod.ison() then
2797 impacttype = "ImpactLaser"
2798 else
2799 impacttype = "ImpactDefault"
2800 end
2801 local impact
2802 local pool = impactpool[impacttype]
2803 if not pool then
2804 impactpool[impacttype] = {}
2805 pool = impactpool[impacttype]
2806 end
2807 if #pool == 0 then
2808 impact = effectobjects[impacttype]:Clone()
2809 impact.Parent = ignore
2810 else
2811 impact = pool[#pool]
2812 pool[#pool] = nil
2813 end
2814 impact.CFrame = cf(pos, pos + 2 * norm + v3(random() - 0.5, random() - 0.5, random() - 0.5))
2815 local pt = impact:GetChildren()
2816 for i = 1, #pt do
2817 if pt[i]:IsA("ParticleEmitter") then
2818 pt[i].Acceleration = v3(5 * (random() - 0.5), pt[i].Acceleration.Y, 5 * (random() - 0.5))
2819 pt[i].EmissionDirection = "Front"
2820 pt[i]:Emit(pt[i].Rate / 10)
2821 end
2822 end
2823 if impacttype == "Impact1" then
2824 impact.effcloud.EmissionDirection = random(0, 5)
2825 end
2826 delay(0.05, function()
2827 pool[#pool + 1] = impact
2828 end)
2829 end
2830 end
2831 if holeon and hit.Transparency == 0 and hit.CanCollide then
2832 do
2833 local holepart
2834 if #holelist ~= 0 then
2835 holepart = holelist[#holelist]
2836 holelist[#holelist] = nil
2837 else
2838 holepart = hole:Clone()
2839 end
2840 holepart:BreakJoints()
2841 holepart.Parent = ignore
2842 holepart.CFrame = cf(pos, pos - norm) * angles(-90 * deg, random(0, 360) * deg, 0)
2843 local materials = materiallist[Enum.Material.Cobblestone]
2844 if materiallist[hit.Material] then
2845 materials = materiallist[hit.Material]
2846 end
2847 local randId = "http://www.roblox.com/asset/?id=" .. materials[random(1, #materials)]
2848 holepart.Decal1.Texture = randId
2849 holepart.Decal2.Texture = randId
2850 delay(4, function()
2851 holepart.Parent = nil
2852 holelist[#holelist + 1] = holepart
2853 end)
2854 end
2855 end
2856 end
2857 function effects:reload()
2858 smokelist = {}
2859 holelist = {}
2860 flashlist = {}
2861 shelllist = {}
2862 end
2863 effects:reload()
2864end
2865print("Loading tween module")
2866do
2867 local type = type
2868 local halfpi = math.pi / 2
2869 local acos = math.acos
2870 local sin = math.sin
2871 local cf = CFrame.new
2872 local tos = cf().toObjectSpace
2873 local components = cf().components
2874 local tick = tick
2875 local tweendata = {}
2876 local equations = {
2877 linear = {
2878 p0 = 0,
2879 v0 = 1,
2880 p1 = 1,
2881 v1 = 1
2882 },
2883 smooth = {
2884 p0 = 0,
2885 v0 = 0,
2886 p1 = 1,
2887 v1 = 0
2888 },
2889 accelerate = {
2890 p0 = 0,
2891 v0 = 0,
2892 p1 = 1,
2893 v1 = 1
2894 },
2895 decelerate = {
2896 p0 = 0,
2897 v0 = 1,
2898 p1 = 1,
2899 v1 = 0
2900 },
2901 bump = {
2902 p0 = 0,
2903 v0 = 4,
2904 p1 = 0,
2905 v1 = -4
2906 },
2907 acceleratebump = {
2908 p0 = 0,
2909 v0 = 0,
2910 p1 = 0,
2911 v1 = -6.75
2912 },
2913 deceleratebump = {
2914 p0 = 0,
2915 v0 = 6.75,
2916 p1 = 0,
2917 v1 = 0
2918 }
2919 }
2920 local updater = {}
2921 tween.step = event.new(updater)
2922 function tween.tweencframe(object, index, time, equation, nextcframe)
2923 if tweendata[object] then
2924 tweendata[object]()
2925 end
2926 local t0 = tick()
2927 local p0, v0, p1, v1
2928 if type(equation) == "table" then
2929 p0 = equation[1]
2930 v0 = equation[2]
2931 p1 = equation[3]
2932 v1 = equation[4]
2933 else
2934 local eq = equations[equation]
2935 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
2936 end
2937 local interpolator = cframe.interpolator(object[index], nextcframe)
2938 local stop
2939 stop = updater:connect(function()
2940 local u = (tick() - t0) / time
2941 if u > 1 then
2942 object[index] = interpolator(p1)
2943 stop()
2944 tweendata[object] = nil
2945 else
2946 local v = 1 - u
2947 local t = p0 * v * v * v + (3 * p0 + v0) * u * v * v + (3 * p1 - v1) * u * u * v + p1 * u * u * u
2948 object[index] = interpolator(t)
2949 end
2950 end)
2951 tweendata[object] = stop
2952 return stop
2953 end
2954 function tween.freebody(object, index, life, cframe0, velocity0, rotation0, acceleration)
2955 local position0 = cframe0.p
2956 local matrix0 = cframe0 - position0
2957 local tick0 = tick()
2958 local stop
2959 stop = updater:connect(function()
2960 local t = tick() - tick0
2961 if life and t > life then
2962 stop()
2963 trash.remove(object)
2964 end
2965 object[index] = cframe.fromaxisangle(t * rotation0) * matrix0 + position0 + t * velocity0 + t * t * acceleration
2966 end)
2967 return stop
2968 end
2969end
2970print("Loading input module")
2971do
2972 local tick = tick
2973 local lower = string.lower
2974 local nv = Vector3.new()
2975 local userinput = game:GetService("UserInputService")
2976 local abbreviation = {
2977 ButtonX = "x",
2978 ButtonY = "y",
2979 ButtonA = "a",
2980 ButtonB = "b",
2981 ButtonR1 = "r1",
2982 ButtonL1 = "l1",
2983 ButtonR2 = "r2",
2984 ButtonL2 = "l2",
2985 ButtonR3 = "r3",
2986 ButtonL3 = "l3",
2987 ButtonStart = "start",
2988 ButtonSelect = "select",
2989 DPadLeft = "left",
2990 DPadRight = "right",
2991 DPadUp = "up",
2992 DPadDown = "down"
2993 }
2994 input.keyboard = {}
2995 input.keyboard.down = {}
2996 input.keyboard.onkeydown = {}
2997 input.keyboard.onkeyup = {}
2998 input.mouse = {}
2999 input.mouse.Position = nv
3000 input.mouse.down = {}
3001 input.mouse.onbuttondown = {}
3002 input.mouse.onbuttonup = {}
3003 input.mouse.onmousemove = {}
3004 input.mouse.onscroll = {}
3005 input.controller = {}
3006 input.controller.down = {}
3007 input.controller.onbuttondown = {}
3008 input.controller.onbuttonup = {}
3009 input.controller.onintegralmove = {}
3010 input.consoleon = not userinput.KeyboardEnabled
3011 local fireonkeydown = event.new(input.keyboard.onkeydown)
3012 local fireonkeyup = event.new(input.keyboard.onkeyup)
3013 local fireonbuttondown = event.new(input.mouse.onbuttondown)
3014 local fireonbuttonup = event.new(input.mouse.onbuttonup)
3015 local fireonmousemove = event.new(input.mouse.onmousemove)
3016 local fireonscroll = event.new(input.mouse.onscroll)
3017 local fireoncbuttondown = event.new(input.controller.onbuttondown)
3018 local fireoncbuttonup = event.new(input.controller.onbuttonup)
3019 local fireonintegralmove = event.new(input.controller.onintegralmove)
3020 local keymap = {}
3021 local triggerthreshold = 0.2
3022 local stickthreshold = 0.25
3023 local gamepadpos
3024 local triggeron = {}
3025 local typing
3026 function input.iskeydown(key)
3027 return userinput:GetKeysPressed()[key]
3028 end
3029 userinput.TextBoxFocused:connect(function()
3030 typing = true
3031 end)
3032 userinput.TextBoxFocusReleased:connect(function()
3033 typing = false
3034 end)
3035 userinput.InputChanged:connect(function(object)
3036 local type = object.UserInputType.Name
3037 local pos = object.Position
3038 if type == "MouseMovement" then
3039 input.mouse.position = pos
3040 fireonmousemove(object.Delta)
3041 elseif type == "MouseWheel" then
3042 fireonscroll(pos.z)
3043 elseif type == "Gamepad1" then
3044 local key = object.KeyCode.Name
3045 if key == "Thumbstick2" then
3046 local m = pos.magnitude
3047 if m > stickthreshold then
3048 gamepadpos = (1 - stickthreshold / m) / (1 - stickthreshold) * pos
3049 elseif gamepadpos then
3050 gamepadpos = nil
3051 end
3052 elseif key == "ButtonL2" or key == "ButtonR2" then
3053 local abv = abbreviation[key]
3054 if triggerthreshold < pos.z and not input.controller.down[abv] then
3055 local mappedkey = keymap[abv]
3056 if mappedkey then
3057 input.keyboard.down[mappedkey] = tick()
3058 fireonkeydown(mappedkey)
3059 end
3060 input.controller.down[abv] = tick()
3061 fireoncbuttondown(abv)
3062 elseif pos.z < triggerthreshold and input.controller.down[abv] then
3063 local mappedkey = keymap[abv]
3064 if mappedkey then
3065 input.keyboard.down[mappedkey] = nil
3066 fireonkeyup(mappedkey)
3067 end
3068 input.controller.down[abv] = nil
3069 fireoncbuttonup(abv)
3070 end
3071 end
3072 end
3073 end)
3074 userinput.InputBegan:connect(function(object)
3075 if typing or char.health and char.health <= 0 then
3076 return
3077 end
3078 local type = object.UserInputType.Name
3079 if type == "Keyboard" then
3080 local key = lower(object.KeyCode.Name)
3081 input.keyboard.down[key] = tick()
3082 fireonkeydown(key)
3083 elseif type == "Gamepad1" then
3084 local key = abbreviation[object.KeyCode.Name]
3085 if key and key ~= "l2" and key ~= "r2" or not input.controller.down[key] then
3086 local mappedkey = keymap[key]
3087 if mappedkey then
3088 input.keyboard.down[mappedkey] = tick()
3089 fireonkeydown(mappedkey)
3090 end
3091 input.controller.down[key] = tick()
3092 fireoncbuttondown(key)
3093 end
3094 elseif type == "MouseButton1" then
3095 input.mouse.down.left = tick()
3096 fireonbuttondown("left")
3097 elseif type == "MouseButton2" then
3098 input.mouse.down.right = tick()
3099 fireonbuttondown("right")
3100 elseif type == "MouseButton3" then
3101 input.mouse.down.middle = tick()
3102 fireonbuttondown("middle")
3103 end
3104 end)
3105 userinput.InputEnded:connect(function(object)
3106 if typing then
3107 return
3108 end
3109 local type = object.UserInputType.Name
3110 if type == "Keyboard" then
3111 local key = lower(object.KeyCode.Name)
3112 input.keyboard.down[key] = nil
3113 fireonkeyup(key)
3114 elseif type == "Gamepad1" then
3115 local key = abbreviation[object.KeyCode.Name]
3116 if key and key ~= "l2" and key ~= "r2" or input.controller.down[key] then
3117 local mappedkey = keymap[key]
3118 if mappedkey then
3119 input.keyboard.down[mappedkey] = nil
3120 fireonkeyup(mappedkey)
3121 end
3122 input.controller.down[key] = nil
3123 fireoncbuttonup(key)
3124 end
3125 elseif type == "MouseButton1" then
3126 input.mouse.down.left = nil
3127 fireonbuttonup("left")
3128 elseif type == "MouseButton2" then
3129 input.mouse.down.right = nil
3130 fireonbuttonup("right")
3131 elseif type == "MouseButton3" then
3132 input.mouse.down.middle = nil
3133 fireonbuttonup("middle")
3134 end
3135 end)
3136 function input.mouse:hide()
3137 userinput.MouseIconEnabled = false
3138 end
3139 function input.mouse:show()
3140 userinput.MouseIconEnabled = true
3141 end
3142 function input.mouse.visible()
3143 return userinput.MouseIconEnabled
3144 end
3145 function input.mouse:lockcenter()
3146 userinput.MouseBehavior = "LockCenter"
3147 end
3148 function input.mouse:free()
3149 userinput.MouseBehavior = "Default"
3150 end
3151 function input.mouse:lock()
3152 userinput.MouseBehavior = "LockCurrentPosition"
3153 end
3154 function input.controller:map(button, key)
3155 keymap[button] = key
3156 end
3157 function input.controller:unmap(button)
3158 keymap[button] = nil
3159 end
3160 function input.step(dt)
3161 if gamepadpos then
3162 fireonintegralmove(dt * gamepadpos, dt)
3163 end
3164 end
3165end
3166print("Loading animation module")
3167do
3168 local sin = math.sin
3169 local acos = math.acos
3170 local type = type
3171 local next = next
3172 local tick = tick
3173 local cf = CFrame.new
3174 local v3 = vector.new
3175 local nv = v3()
3176 local inverse = CFrame.new().inverse
3177 local tos = CFrame.new().toObjectSpace
3178 local toquaternion = cframe.toquaternion
3179 local clone = game.Clone
3180 local new = Instance.new
3181 local play = new("Sound").Play
3182 local stop = new("Sound").Stop
3183 local equations = {
3184 linear = {
3185 p0 = 0,
3186 v0 = 1,
3187 p1 = 1,
3188 v1 = 1
3189 },
3190 smooth = {
3191 p0 = 0,
3192 v0 = 0,
3193 p1 = 1,
3194 v1 = 0
3195 },
3196 accelerate = {
3197 p0 = 0,
3198 v0 = 0,
3199 p1 = 1,
3200 v1 = 1
3201 },
3202 decelerate = {
3203 p0 = 0,
3204 v0 = 1,
3205 p1 = 1,
3206 v1 = 0
3207 },
3208 bump = {
3209 p0 = 0,
3210 v0 = 4,
3211 p1 = 0,
3212 v1 = -4
3213 },
3214 acceleratebump = {
3215 p0 = 0,
3216 v0 = 0,
3217 p1 = 0,
3218 v1 = -6.75
3219 },
3220 deceleratebump = {
3221 p0 = 0,
3222 v0 = 6.75,
3223 p1 = 0,
3224 v1 = 0
3225 }
3226 }
3227 local function interpolator(c0, c1, t0, dur, eq, pivot)
3228 pivot = pivot or nv
3229 c0 = c0 * cf(pivot)
3230 c1 = c1 * cf(pivot)
3231 local p0, v0, p1, v1
3232 if type(eq) == "table" then
3233 p0, v0, p1, v1 = eq[1], eq[2], eq[3], eq[4]
3234 else
3235 local eq = equations[eq or "smooth"]
3236 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3237 end
3238 return function(t)
3239 t = (t - t0) / dur
3240 t = t < 1 and t or 1
3241 local i = 1 - t
3242 local v = p0 * i * i * i + (3 * p0 + v0) * t * i * i + (3 * p1 - v1) * t * t * i + p1 * t * t * t
3243 return cframe.interpolate(c0, c1, v) * cf(-pivot), 1 == t
3244 end
3245 end
3246 function animation.player(modeldata, sequence)
3247 local interpolators = {}
3248 local framenumber = 1
3249 local t0 = 0
3250 local lasttime = t0
3251 local stdtimescale = sequence.stdtimescale
3252 local timescale = sequence.timescale
3253 local cframes = {}
3254 local lastcframes = {}
3255 local ignore = workspace.Ignore
3256 local player = game:GetService("Players").LocalPlayer
3257 for i, v in next, modeldata, nil do
3258 if v.part then
3259 lastcframes[i] = v.part.CFrame
3260 cframes[i] = v.part.CFrame
3261 end
3262 end
3263 return function(time)
3264 local dt = time - lasttime
3265 lasttime = time
3266 for i = framenumber, #sequence do
3267 local frame = sequence[i]
3268 if time > t0 then
3269 for i = 1, #frame do
3270 local data = frame[i]
3271 local partname = data.part
3272 if not modeldata[partname] then
3273 error("Error in frame: " .. framenumber .. ". " .. partname .. " is not in modeldata")
3274 end
3275 if data.c0 then
3276 interpolators[partname] = nil
3277 modeldata[partname].weld.C0 = data.c0 == "base" and modeldata[partname].basec0 or data.c0
3278 end
3279 if data.c1 then
3280 interpolators[partname] = interpolator(modeldata[partname].weld.C0, data.c1 == "base" and modeldata[partname].basec0 or data.c1, t0, data.t and data.t * timescale or frame.delay * timescale, data.eq, data.pivot)
3281 end
3282 if data.clone then
3283 if modeldata[data.clone] then
3284 error("Error in frame: " .. framenumber .. ". Cannot clone " .. partname .. ". " .. data.clone .. " already exists.")
3285 end
3286 local part = clone(modeldata[partname].part)
3287 part.Parent = ignore
3288 part:ClearAllChildren()
3289 local tt = modeldata[partname].part:GetChildren()
3290 for i = 1, #tt do
3291 if tt[i]:IsA("Texture") then
3292 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3293 local hackytt = tt[i]:Clone()
3294 hackytt.Transparency = trans
3295 hackytt.Parent = part
3296 elseif tt[i]:IsA("FileMesh") then
3297 tt[i]:Clone().Parent = part
3298 end
3299 end
3300 local weld = new("Motor6D", part)
3301 local part0 = data.part0 and modeldata[data.part0].part or modeldata[partname].weld.Part0
3302 weld.Part0 = part0
3303 weld.Part1 = part
3304 weld.C0 = part0.CFrame:inverse() * modeldata[partname].weld.Part0.CFrame * modeldata[partname].weld.C0
3305 modeldata[data.clone] = {
3306 part = part,
3307 weld = weld,
3308 clone = true
3309 }
3310 cframes[data.clone] = cframes[partname]
3311 lastcframes[data.clone] = lastcframes[partname]
3312 end
3313 if data.transparency then
3314 modeldata[partname].part.Transparency = data.transparency
3315 if modeldata.camodata and modeldata.camodata[modeldata[partname].part] then
3316 local tt = modeldata[partname].part:GetChildren()
3317 for i = 1, #tt do
3318 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3319 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3320 tt[i].Transparency = data.transparency ~= 1 and trans or 1
3321 end
3322 end
3323 end
3324 end
3325 if data.sound then
3326 do
3327 local sound = new("Sound")
3328 if data.soundid then
3329 sound.SoundId = data.soundid
3330 end
3331 if data.v then
3332 sound.Volume = data.v
3333 end
3334 if data.p then
3335 sound.Pitch = data.p
3336 end
3337 if data.tp then
3338 sound.TimePosition = data.tp
3339 else
3340 sound.TimePosition = 0
3341 end
3342 if data.head then
3343 sound.Parent = player.Character.Head
3344 else
3345 sound.Parent = modeldata[partname].part
3346 end
3347 sound:Play()
3348 if data.d then
3349 delay(data.d, function()
3350 sound:Stop()
3351 end)
3352 end
3353 end
3354 end
3355 if data.drop then
3356 if not modeldata[partname].clone then
3357 error("Error in frame: " .. framenumber .. ". Cannot drop " .. partname .. ". Part is not a clone")
3358 end
3359 local lastcf = lastcframes[partname]
3360 local curcf = cframes[partname]
3361 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))
3362 trash.remove(modeldata[partname].weld)
3363 modeldata[partname] = nil
3364 interpolators[partname] = nil
3365 end
3366 if data.delete then
3367 trash.remove(modeldata[partname].weld)
3368 trash.remove(modeldata[partname].part)
3369 modeldata[partname] = nil
3370 interpolators[partname] = nil
3371 end
3372 end
3373 t0 = t0 + frame.delay * timescale
3374 framenumber = framenumber + 1
3375 else
3376 break
3377 end
3378 end
3379 for i, v in next, interpolators, nil do
3380 local newcf, stop, t = v(time)
3381 modeldata[i].weld.C0 = newcf
3382 if stop then
3383 interpolators[i] = nil
3384 end
3385 end
3386 for i, v in next, modeldata, nil do
3387 if v.part then
3388 lastcframes[i] = cframes[i]
3389 cframes[i] = v.part.CFrame
3390 end
3391 end
3392 if time > t0 then
3393 for i, v in next, modeldata, nil do
3394 if v.clone then
3395 trash.remove(v.weld)
3396 trash.remove(v.part)
3397 modeldata[i] = nil
3398 end
3399 end
3400 end
3401 return time > t0
3402 end
3403 end
3404 function animation.reset(modeldata, t)
3405 local interpolators = {}
3406 for i, v in next, modeldata, nil do
3407 if v.clone then
3408 modeldata[i] = nil
3409 trash.remove(v.weld)
3410 trash.remove(v.part)
3411 else
3412 if v.part then
3413 v.part.Transparency = v.basetransparency
3414 if modeldata.camodata and modeldata.camodata[v.part] then
3415 local tt = v.part:GetChildren()
3416 for i = 1, #tt do
3417 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3418 local trans = modeldata.camodata[v.part][tt[i]].Transparency
3419 tt[i].Transparency = trans
3420 end
3421 end
3422 end
3423 end
3424 if v.weld then
3425 interpolators[i] = interpolator(v.weld.C0, v.basec0, 0, t or 1)
3426 end
3427 end
3428 end
3429 return function(time)
3430 for i, v in next, interpolators, nil do
3431 local newcf, stop = v(time)
3432 modeldata[i].weld.C0 = newcf
3433 end
3434 return time > t
3435 end
3436 end
3437end
3438print("Loading chat module")
3439do
3440 local wfc = game.WaitForChild
3441 local ffc = game.FindFirstChild
3442 local ud2 = UDim2.new
3443 local ceil = math.ceil
3444 local cf = CFrame.new
3445 local v3 = Vector3.new
3446 local color = Color3.new
3447 local dot = Vector3.new().Dot
3448 local workspace = workspace
3449 local ray = Ray.new
3450 local new = Instance.new
3451 local rtype = game.IsA
3452 local debris = game.Debris
3453 local sub = string.sub
3454 local len = string.len
3455 local lower = string.lower
3456 local find = string.find
3457 local insert = table.insert
3458 local match = string.match
3459 local player = game:GetService("Players").LocalPlayer
3460 local pgui = player.PlayerGui
3461 local misc = game.ReplicatedStorage.Misc
3462 local msg = wfc(misc, "Msger")
3463 local chatgui = wfc(pgui, "ChatGame")
3464 local chatbox = wfc(chatgui, "TextBox")
3465 local warn = wfc(chatgui, "Warn")
3466 local version = wfc(chatgui, "Version")
3467 local globalchat = wfc(chatgui, "GlobalChat")
3468 local guesttip = wfc(chatgui, "GuestTip")
3469 version.Text = "Server version: " .. updateversion
3470 local admin, moderator
3471 local adminlist = {
3472 525919,
3473 1667819,
3474 5725475,
3475 4337002
3476 }
3477 local moderatorlist = {66366193, 70273584}
3478 local banlist = {}
3479 local canchat = true
3480 local chatspam = 0
3481 local totalspam = 0
3482 local maxchar = 400
3483 local lines = 8
3484 local chatting
3485 local isguest = player.UserId < 0 and not game:GetService("RunService"):IsStudio()
3486 for i = 1, #adminlist do
3487 if adminlist[i] == player.userId then
3488 admin = true
3489 end
3490 end
3491 for i = 1, #moderatorlist do
3492 if moderatorlist[i] == player.userId then
3493 moderator = true
3494 end
3495 end
3496 for i = 1, #banlist do
3497 if banlist[i] == player.Name then
3498 player:kick("Banlist kick")
3499 end
3500 end
3501 network:add("console", function(message)
3502 local mes = msg:Clone()
3503 local mtag = wfc(mes, "Tag")
3504 local offset = 5
3505 mes.Parent = globalchat
3506 mes.Text = "[Console]: "
3507 mes.TextColor3 = Color3.new(0.4, 0.4, 0.4)
3508 mes.Msg.Text = message
3509 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3510 end)
3511 network:add("announce", function(message)
3512 local mes = msg:Clone()
3513 local mtag = wfc(mes, "Tag")
3514 local offset = 5
3515 mes.Parent = globalchat
3516 mes.Text = "[ANNOUNCEMENT]: "
3517 mes.TextColor3 = Color3.new(0.9803921568627451, 0.6509803921568628, 0.10196078431372549)
3518 mes.Msg.Text = message
3519 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3520 end)
3521 network:add("chatted", function(chatter, text, tag, tagcolor, teamchat, chattername)
3522 if teamchat and chatter.TeamColor ~= player.TeamColor then
3523 return
3524 end
3525 local mes = msg:Clone()
3526 local mtag = wfc(mes, "Tag")
3527 mes.Parent = globalchat
3528 local offset = 5
3529 mtag.Text = tag and tag .. " " or ""
3530 if tag then
3531 offset = mtag.TextBounds.x + 5
3532 mes.Position = ud2(0.01, offset, 1, 20)
3533 mtag.Position = ud2(0, -offset + 5, 0, 0)
3534 if tagcolor then
3535 mtag.TextColor3 = tagcolor
3536 end
3537 end
3538 mes.Text = chattername .. " : "
3539 mes.TextColor = chatter.TeamColor
3540 mes.Msg.Text = text
3541 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3542 end)
3543 local eval
3544 do
3545 local math = math
3546 local byte = string.byte
3547 local find = string.find
3548 local lparen = byte("(")
3549 local rparen = byte(")")
3550 local add = byte("+")
3551 local sub = byte("-")
3552 local mul = byte("*")
3553 local div = byte("/")
3554 local pow = byte("^")
3555 local mod = byte("%")
3556 local zero = byte("0")
3557 local nine = byte("9")
3558 local dot = byte(".")
3559 local space = byte(" ")
3560 local tab = byte("\t")
3561 local newl = byte("\n")
3562 local arith = {
3563 [add] = function(a, b)
3564 return a + b
3565 end,
3566 [sub] = function(a, b)
3567 return a - b
3568 end,
3569 [mul] = function(a, b)
3570 return a * b
3571 end,
3572 [div] = function(a, b)
3573 return a / b
3574 end,
3575 [pow] = function(a, b)
3576 return a ^ b
3577 end,
3578 [mod] = function(a, b)
3579 return a % b
3580 end
3581 }
3582 local whitespace = {
3583 [space] = true,
3584 [tab] = true,
3585 [newl] = true
3586 }
3587 local function f(eq, i)
3588 local neq = #eq
3589 local n = 0
3590 local op = add
3591 local func, m, x, _
3592 while i <= neq do
3593 local c = byte(eq, i)
3594 if arith[c] then
3595 op = c
3596 elseif c == rparen then
3597 break
3598 elseif whitespace[c] then
3599 else
3600 if c == lparen then
3601 m, i = f(eq, i + 1)
3602 elseif c >= zero and c <= nine or c == dot then
3603 _, i, m = find(eq, "(%d*%.?%d*)", i)
3604 else
3605 _, i, func = find(eq, "(%a*)%(", i)
3606 if i then
3607 x, i = f(eq, i + 1)
3608 m = math[func](x)
3609 else
3610 return
3611 end
3612 end
3613 n = arith[op](n, m)
3614 end
3615 i = i + 1
3616 end
3617 return n, i
3618 end
3619 function eval(eq)
3620 return (f(eq, 1))
3621 end
3622 end
3623 local function findplayer(name, speaker)
3624 if lower(name) == "all" then
3625 local chars = {}
3626 local c = game:GetService("Players"):GetPlayers()
3627 for i = 1, #c do
3628 insert(chars, c[i])
3629 end
3630 return chars
3631 elseif lower(name) == "me" then
3632 return {speaker}
3633 elseif lower(name) == "others" then
3634 local chars = {}
3635 local c = game:GetService("Players"):GetPlayers()
3636 for i = 1, #c do
3637 if c ~= speaker then
3638 insert(chars, c[i])
3639 end
3640 end
3641 return chars
3642 else
3643 local chars = {}
3644 local commalist = {}
3645 local ssn = 0
3646 local lownum = 1
3647 local highestnum = 1
3648 local foundone
3649 while true do
3650 ssn = ssn + 1
3651 if sub(name, ssn, ssn) == "" then
3652 insert(commalist, lownum)
3653 insert(commalist, ssn - 1)
3654 highestnum = ssn - 1
3655 break
3656 end
3657 if string.sub(name, ssn, ssn) == "," then
3658 foundone = true
3659 table.insert(commalist, lownum)
3660 table.insert(commalist, ssn)
3661 lownum = ssn + 1
3662 end
3663 end
3664 if foundone then
3665 for ack = 1, #commalist, 2 do
3666 local cnum = 0
3667 local char
3668 local c = game:GetService("Players"):GetPlayers()
3669 for i = 1, #c do
3670 if find(lower(c[i].Name), sub(lower(name), commalist[ack], commalist[ack + 1] - 1)) == 1 then
3671 char = c[i]
3672 cnum = cnum + 1
3673 end
3674 end
3675 if cnum == 1 then
3676 table.insert(chars, char)
3677 end
3678 end
3679 return #chars ~= 0 and chars or 0
3680 else
3681 local cnum = 0
3682 local char
3683 local c = game:GetService("Players"):GetPlayers()
3684 for i = 1, #c do
3685 if find(lower(c[i].Name), lower(name)) == 1 then
3686 char = {
3687 c[i]
3688 }
3689 cnum = cnum + 1
3690 end
3691 end
3692 return cnum == 1 and char or 0
3693 end
3694 end
3695 end
3696 network:add("printstring", function(...)
3697 local ss = {
3698 ...
3699 }
3700 local s = ""
3701 for i = 1, #s do
3702 s = s .. "\t" .. ss[i]
3703 end
3704 s = s .. "\n"
3705 local i = 0
3706 local lel = ""
3707 for str in string.gmatch(s, [[
3708(^[
3709]*)
3710]]) do
3711 i = i + 1
3712 lel = lel .. "\n" .. str
3713 if i == 64 then
3714 print(lel)
3715 i = 0
3716 lel = ""
3717 end
3718 end
3719 end)
3720 local function newchat()
3721 local message = chatbox.Text
3722 if sub(message, 1, 1) == "/" then
3723 network:send("m" .. "o" .. "d" .. "c" .. "m" .. "d", message)
3724 chatbox.Text = "Press '/' or click here to chat"
3725 chatting = false
3726 chatbox.ClearTextOnFocus = true
3727 return
3728 end
3729 message = string.gsub(message, [[
3730
3731+]], "")
3732 message = string.gsub(message, " +", " ")
3733 local teamchat, teamswitch, admincommand
3734 if sub(message, 1, 1) == "%" then
3735 teamchat = true
3736 message = sub(message, 2, len(message))
3737 end
3738 message = string.gsub(message, "{(.-)}", eval)
3739 if chatspam > 5 and not moderator and not admin then
3740 warn.Visible = true
3741 chatspam = chatspam + 1
3742 totalspam = totalspam + 1
3743 warn.Text = "You have been blocked temporarily for spamming. WARNING : " .. totalspam .. " out of 3"
3744 if totalspam > 3 then
3745 network:e("player was kicked for repeated spamming")
3746 end
3747 delay(5, function()
3748 chatspam = chatspam - 5
3749 warn.Visible = false
3750 end)
3751 return
3752 end
3753 local teamtype
3754 if network:fetch("s" .. "e" .. "r" .. "v" .. "e" .. "r" .. "t" .. "y" .. "p" .. "e") == "VIP" then
3755 if sub(lower(message), 1, 5) == "join/" or sub(lower(message), 1, 5) == "swap/" or sub(lower(message), 1, 5) == "team/" then
3756 teamtype = 6
3757 elseif sub(lower(message), 1, 6) == ":join " or sub(lower(message), 1, 6) == ":team " then
3758 teamtype = 7
3759 elseif sub(lower(message), 1, 7) == "switch/" then
3760 teamtype = 8
3761 end
3762 if teamtype then
3763 local theteam
3764 local tnum = 0
3765 local t = game.Teams:GetChildren()
3766 for i = 1, #t do
3767 local v = t[i]
3768 if find(lower(v.Name), sub(lower(message), teamtype)) == 1 then
3769 theteam = v
3770 tnum = tnum + 1
3771 end
3772 end
3773 if tnum == 1 and player.TeamColor ~= theteam.TeamColor then
3774 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", theteam)
3775 game.ReplicatedStorage.Events.Respawn:FireServer()
3776 end
3777 elseif message == "switch" or message == "switchteam" then
3778 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"))
3779 end
3780 end
3781 if admin or moderator then
3782 if sub(message, 1, 5) == "kick/" then
3783 admincommand = true
3784 local guys = findplayer(match(message, "/(.*)"), player)
3785 if guys ~= 0 then
3786 for i = 1, #guys do
3787 network:send("k" .. "i" .. "c" .. "k", guys[i])
3788 end
3789 end
3790 elseif sub(message, 1, 8) == "credits/" then
3791 admincommand = true
3792 local guys = findplayer(match(message, "/(.-),"), player)
3793 if guys ~= 0 then
3794 for i = 1, #guys do
3795 network:send("x" .. "y" .. "z", guys[i], eval(match(message, ",(.*)") or 0) or 0)
3796 end
3797 end
3798 elseif sub(message, 1, 11) == "experience/" then
3799 admincommand = true
3800 local guys = findplayer(match(message, "/(.-),"), player)
3801 if guys ~= 0 then
3802 for i = 1, #guys do
3803 network:send("z" .. "y" .. "x", guys[i], eval(match(message, ",(.*)") or 0))
3804 end
3805 end
3806 elseif sub(message, 1, 10) == "timescale/" then
3807 admincommand = true
3808 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", eval(match(message, "/(.*)") or 0))
3809 end
3810 end
3811 if len(message) > 256 then
3812 message = sub(message, 1, 256)
3813 end
3814 chatbox.Text = "Press '/' or click here to chat"
3815 chatting = false
3816 chatbox.ClearTextOnFocus = true
3817 local header = teamchat and "(TEAM CHAT)" or admincommand and "[ADMIN COMMAND]" or teamswitch and "[TEAMSWITCH]" or ""
3818 message = header .. " " .. message
3819 chatspam = chatspam + 1
3820 network:send("c" .. "h" .. "a" .. "t" .. "t" .. "e" .. "d", message, teamchat, admincommand)
3821 spawn(function()
3822 wait(10)
3823 chatspam = chatspam - 1
3824 end)
3825 end
3826 function chat:disable(isGuest)
3827 canchat = false
3828 guesttip.Visible = isGuest
3829 chatbox.Visible = false
3830 end
3831 function chat:hidechat(on)
3832 if not isguest then
3833 canchat = not on
3834 globalchat.Visible = not on
3835 chatbox.Visible = not on
3836 end
3837 end
3838 function chat:inmenu()
3839 globalchat.Position = ud2(0, 20, 1, -100)
3840 chatbox.Position = ud2(0, 10, 1, -20)
3841 end
3842 function chat:ingame()
3843 globalchat.Position = ud2(0, 150, 1, -50)
3844 chatbox.Position = ud2(0, 10, 1, -20)
3845 end
3846 globalchat.ChildAdded:connect(function(child)
3847 wait()
3848 local m = globalchat:GetChildren()
3849 for i = 1, #m do
3850 local v = m[i]
3851 local tag = wfc(v, "Tag")
3852 local tagoff = 5
3853 if tag.Text ~= "" then
3854 tagoff = 5 + tag.TextBounds.x
3855 v.Position = ud2(0.01, tagoff, 1, v.Position.Y.Offset)
3856 end
3857 if v.Parent then
3858 v:TweenPosition(ud2(0.01, tagoff, 1, (i - #m) * 20), "Out", "Sine", 0.2, true)
3859 end
3860 if #m > lines and i <= #m - lines and v.Name ~= "Deleted" then
3861 v.Name = "Deleted"
3862 wfc(v, "Msg")
3863 wfc(v, "Tag")
3864 for x = 1, 5 do
3865 if ffc(v, "Msg") and ffc(v, "Tag") then
3866 v.TextTransparency = x * 2 / 10
3867 v.TextStrokeTransparency = x * 2 / 10 + 0.1
3868 v.Msg.TextTransparency = x * 2 / 10
3869 v.Msg.TextStrokeTransparency = x * 2 / 10 + 0.1
3870 v.Tag.TextTransparency = x * 2 / 10
3871 v.Tag.TextStrokeTransparency = x * 2 / 10 + 0.1
3872 wait(0.03333333333333333)
3873 end
3874 if v and v.Parent then
3875 trash.remove(v)
3876 end
3877 end
3878 end
3879 end
3880 end)
3881 chatbox.Focused:connect(function()
3882 chatbox.Active = true
3883 end)
3884 chatbox.FocusLost:connect(function(enter)
3885 chatbox.Active = false
3886 if enter and chatbox.Text ~= "" then
3887 newchat()
3888 end
3889 end)
3890 game:GetService("UserInputService").InputBegan:connect(function(keycode)
3891 if not canchat then
3892 chatbox.Visible = false
3893 return
3894 end
3895 if warn.Visible then
3896 return
3897 end
3898 local key = keycode.KeyCode
3899 if not chatbox.Active then
3900 if key == Enum.KeyCode.Slash then
3901 wait(0.03333333333333333)
3902 chatbox:CaptureFocus()
3903 chatbox.ClearTextOnFocus = false
3904 elseif key == Enum.KeyCode[hud.voteyes] then
3905 hud:vote("yes")
3906 elseif key == Enum.KeyCode[hud.voteno] then
3907 hud:vote("no")
3908 end
3909 end
3910 end)
3911 if player.UserId < 0 or input.consoleon then
3912 chat:disable(player.userId < 0)
3913 end
3914end
3915print("Loading hud module")
3916do
3917 local wfc = game.WaitForChild
3918 local ffc = game.FindFirstChild
3919 local ud2 = UDim2.new
3920 local ceil = math.ceil
3921 local cf = CFrame.new
3922 local v3 = Vector3.new
3923 local color = Color3.new
3924 local dot = Vector3.new().Dot
3925 local cos = math.cos
3926 local workspace = workspace
3927 local ray = Ray.new
3928 local new = Instance.new
3929 local raycast = workspace.FindPartOnRayWithIgnoreList
3930 local infolder = function(l, e)
3931 for i = 1, #l do
3932 if l[i].Name == e then
3933 return l[i]
3934 end
3935 end
3936 end
3937 local rtype = game.IsA
3938 local debris = game.Debris
3939 local player = game:GetService("Players").LocalPlayer
3940 local playertag = game.ReplicatedStorage.Character.PlayerTag
3941 local pgui = player.PlayerGui
3942 local repstore = game.ReplicatedStorage
3943 local modulestore = repstore.GunModules
3944 local misc = repstore.Misc
3945 local xboxmisc = repstore.XBOX
3946 local bloodarc = misc.BloodArc
3947 local spotdot = misc.Spot
3948 local rfeed = input.consoleon and xboxmisc.Feed or misc.Feed
3949 local hsht = misc.Headshot
3950 local maingui = wfc(pgui, "MainGui")
3951 if input.consoleon then
3952 maingui:Destroy()
3953 maingui = repstore.XBOX.MainGui:Clone()
3954 maingui.Parent = pgui
3955 end
3956 local spot = wfc(pgui, "Spot")
3957 local gamegui = wfc(maingui, "GameGui")
3958 local crossframe = wfc(gamegui, "CrossHud")
3959 local crossparts = {
3960 wfc(crossframe, "HR"),
3961 wfc(crossframe, "HL"),
3962 wfc(crossframe, "VD"),
3963 wfc(crossframe, "VU")
3964 }
3965 local ammohud = wfc(gamegui, "AmmoHud")
3966 local scopefr = wfc(gamegui, "ScopeFrame")
3967 local hitmarker = wfc(gamegui, "Hitmarker")
3968 local tagfr = wfc(gamegui, "NameTag")
3969 local capfr = wfc(gamegui, "Capping")
3970 local bloodscreen = wfc(gamegui, "BloodScreen")
3971 local radar = wfc(gamegui, "Radar")
3972 local killfeed = wfc(gamegui, "Killfeed")
3973 local steady = wfc(gamegui, "Steady")
3974 local use = wfc(gamegui, "Use")
3975 local round = wfc(gamegui, "Round")
3976 local spotted = wfc(gamegui, "Spotted")
3977 local chatfr = wfc(pgui.ChatGame, "GlobalChat")
3978 local steadyfull = wfc(steady, "Full")
3979 local steadybar = wfc(steadyfull, "Bar")
3980 local rme = wfc(radar, "Me")
3981 local rfolder = wfc(radar, "Folder")
3982 local distance = 300
3983 local offset = -rme.Size.X.Offset / 2
3984 local ammofr = wfc(ammohud, "Frame")
3985 local ammotext = wfc(ammofr, "Ammo")
3986 local gammo = wfc(ammofr, "GAmmo")
3987 local magtext = wfc(ammofr, "Mag")
3988 local healthtext = wfc(ammofr, "Health")
3989 local fmodetext = wfc(ammofr, "FMode")
3990 local healthbar = wfc(ammofr, "healthbar_back")
3991 local healthbarFill = wfc(healthbar, "healthbar_fill")
3992 local newGUIColors = {
3993 Color3.new(0.14901960784313725, 0.3137254901960784, 0.2784313725490196),
3994 Color3.new(0.17647058823529413, 0.5019607843137255, 0.43137254901960786),
3995 Color3.new(0.8745098039215686, 0.12156862745098039, 0.12156862745098039),
3996 Color3.new(0.5333333333333333, 0.06666666666666667, 0.06666666666666667)
3997 }
3998 local cbar = wfc(capfr, "Percent")
3999 local sightmark, centermark
4000 local nametags = {}
4001 local dotlist = {}
4002 local healthlist = {}
4003 local lastcombat = {}
4004 local prevhealth = 0
4005 local rtime = 0
4006 local stime = 0
4007 local radarinterval = 0.016666666666666666
4008 local spotinterval = 0.1
4009 local cinamode = false
4010 local cinalist = {
4011 ammohud,
4012 radar,
4013 killfeed,
4014 crossframe,
4015 round
4016 }
4017 hud.crossscale = physics.spring.new(0)
4018 hud.crossscale.s = 10
4019 hud.crossscale.d = 0.8
4020 hud.crossscale.t = 1
4021 hud.crossspring = physics.spring.new(0)
4022 hud.crossspring.s = 12
4023 hud.crossspring.d = 0.65
4024 hud.hitspring = physics.spring.new(1)
4025 hud.hitspring.s = 5
4026 hud.hitspring.d = 0.7
4027 do
4028 local kickfr = wfc(pgui.ChatGame, "Votekick")
4029 local title = wfc(kickfr, "Title")
4030 local timer = wfc(kickfr, "Timer")
4031 local votes = wfc(kickfr, "Votes")
4032 local yes = wfc(kickfr, "Yes")
4033 local no = wfc(kickfr, "No")
4034 local choice = wfc(kickfr, "Choice")
4035 local votereq = 0
4036 local votecount = 0
4037 local votetick = 0
4038 local voting, voted
4039 hud.voteyes = "O"
4040 hud.voteno = "P"
4041 yes.Text = "Yes - Press " .. string.upper(hud.voteyes)
4042 no.Text = "No - Press " .. string.upper(hud.voteno)
4043 function hud.votestep()
4044 if voting then
4045 kickfr.Visible = true
4046 timer.Text = "Time left: 0:" .. string.format("%.2d", (votetick - tick()) % 60)
4047 votes.Text = "Votes: " .. votecount .. " out of " .. votereq .. " required"
4048 if votetick <= tick() or votecount >= votereq then
4049 voting = false
4050 kickfr.Visible = false
4051 end
4052 else
4053 kickfr.Visible = false
4054 end
4055 end
4056 function hud:vote(votecard)
4057 if voting and not voted then
4058 yes.Visible = false
4059 no.Visible = false
4060 choice.Visible = true
4061 voted = true
4062 if votecard == "yes" then
4063 choice.Text = "Voted Yes"
4064 choice.TextColor3 = yes.TextColor3
4065 else
4066 choice.Text = "Voted No"
4067 choice.TextColor3 = no.TextColor3
4068 end
4069 network:send("votefromUI", votecard)
4070 end
4071 end
4072 network:add("startvotekick", function(name, countdown, endtick, reqs)
4073 if not hud.disablevotekick then
4074 title.Text = "Votekick " .. name .. " out of the server?"
4075 kickfr.Visible = true
4076 yes.Visible = true
4077 no.Visible = true
4078 choice.Visible = false
4079 votereq = reqs
4080 votecount = 0
4081 votetick = endtick
4082 voting = true
4083 voted = false
4084 hud.votestep()
4085 end
4086 end)
4087 network:add("updatenumvotes", function(numvotes)
4088 votecount = numvotes
4089 end)
4090 end
4091 network:add("updateothershealth", function(player, health0, healtick0, healrate, maxhealth, alive)
4092 if not healthlist[player] then
4093 healthlist[player] = {}
4094 end
4095 healthlist[player].health0 = health0
4096 healthlist[player].healtick0 = healtick0
4097 healthlist[player].healrate = healrate
4098 healthlist[player].maxhealth = maxhealth
4099 healthlist[player].alive = alive
4100 if menu.updatelist then
4101 menu.updatelist(player, "Toggle")
4102 end
4103 end)
4104 network:add("killfeed", function(killer, victim, dist, weapon, head)
4105 local spacing = input.consoleon and 20 or 15
4106 local newfeed = rfeed:Clone()
4107 newfeed.Text = killer.Name
4108 newfeed.TextColor = killer.TeamColor
4109 newfeed.GunImg.Text = weapon
4110 newfeed.Victim.Text = victim.Name
4111 newfeed.Victim.TextColor = victim.TeamColor
4112 newfeed.GunImg.Dist.Text = "Dist: " .. dist .. " studs"
4113 newfeed.Parent = killfeed
4114 newfeed.GunImg.Size = UDim2.new(0, newfeed.GunImg.TextBounds.x, 0, 30)
4115 newfeed.GunImg.Position = UDim2.new(0, spacing + newfeed.TextBounds.x, 0, -5)
4116 newfeed.Victim.Position = UDim2.new(0, spacing * 2 + newfeed.TextBounds.x + newfeed.GunImg.TextBounds.x, 0, 0)
4117 if head then
4118 local headnote = hsht:Clone()
4119 headnote.Parent = newfeed.Victim
4120 headnote.Position = ud2(0, 10 + newfeed.Victim.TextBounds.x, 0, -5)
4121 end
4122 spawn(function()
4123 newfeed.Visible = true
4124 wait(20)
4125 for i = 1, 10 do
4126 if newfeed.Parent then
4127 newfeed.TextTransparency = i / 10
4128 newfeed.TextStrokeTransparency = i / 10 + 0.5
4129 newfeed.GunImg.TextStrokeTransparency = i / 10 + 0.5
4130 newfeed.GunImg.TextTransparency = i / 10
4131 newfeed.Victim.TextStrokeTransparency = i / 10 + 0.5
4132 newfeed.Victim.TextTransparency = i / 10
4133 wait(0.03333333333333333)
4134 end
4135 end
4136 if newfeed and newfeed.Parent then
4137 trash.remove(newfeed)
4138 end
4139 end)
4140 local kb = killfeed:GetChildren()
4141 for i = 1, #kb do
4142 local v = kb[i]
4143 v:TweenPosition(ud2(0.01, 5, 1, (i - #kb) * 25 - 25), "Out", "Sine", 0.2, true)
4144 if #kb > 5 and #kb - i >= 5 then
4145 spawn(function()
4146 if kb[1].Name ~= "Deleted" then
4147 for i = 1, 10 do
4148 if ffc(kb[1], "Victim") then
4149 kb[1].TextTransparency = i / 10
4150 kb[1].TextStrokeTransparency = i / 10 + 0.5
4151 kb[1].Victim.TextTransparency = i / 10
4152 kb[1].Victim.TextStrokeTransparency = i / 10 + 0.5
4153 kb[1].Name = "Deleted"
4154 kb[1].GunImg.TextTransparency = i / 10
4155 kb[1].GunImg.TextStrokeTransparency = i / 10 + 0.5
4156 wait(0.03333333333333333)
4157 end
4158 end
4159 trash.remove(kb[1])
4160 end
4161 end)
4162 end
4163 end
4164 end)
4165 function hud.inializehealth(player, alive)
4166 if not healthlist[player] then
4167 healthlist[player] = {}
4168 end
4169 healthlist[player].health0 = alive and 100 or 0
4170 healthlist[player].healtick0 = 0
4171 healthlist[player].healrate = 0
4172 healthlist[player].maxhealth = 100
4173 healthlist[player].healwait = 5
4174 healthlist[player].alive = alive
4175 end
4176 local function gethealth(player)
4177 local healthstat = healthlist[player]
4178 if healthstat then
4179 local health0 = healthlist[player].health0
4180 local healtick0 = healthlist[player].healtick0
4181 local healrate = healthlist[player].healrate
4182 local maxhealth = healthlist[player].maxhealth
4183 local alive = healthlist[player].alive
4184 if alive then
4185 local x = tick() - healtick0
4186 if x < 0 then
4187 return health0
4188 else
4189 local curhealth = health0 + x * healrate
4190 return maxhealth > curhealth and curhealth or maxhealth
4191 end
4192 else
4193 return 0
4194 end
4195 else
4196 return 0
4197 end
4198 end
4199 local function changehealthlocally(player, dhealth)
4200 local healthstat = healthlist[player]
4201 if healthstat then
4202 local health0 = healthlist[player].health0
4203 local healtick0 = healthlist[player].healtick0
4204 local healrate = healthlist[player].healrate
4205 local maxhealth = healthlist[player].maxhealth
4206 local healwait = healthlist[player].healwait
4207 local alive = healthlist[player].alive
4208 if alive then
4209 local time = tick()
4210 local x = time - healtick0
4211 local curhealth
4212 if x < 0 then
4213 curhealth = health0
4214 else
4215 curhealth = health0 + x * healrate
4216 curhealth = maxhealth > curhealth and curhealth or maxhealth
4217 end
4218 healthlist[player].health0 = curhealth + dhealth
4219 if dhealth < 0 then
4220 healthlist[player].healtick0 = time + healwait
4221 else
4222 healthlist[player].healtick0 = time
4223 end
4224 end
4225 end
4226 end
4227 function hud:changehealthlocally(player, dhealth)
4228 changehealthlocally(player, dhealth)
4229 end
4230 function hud:setscopeid(id)
4231 scopefr.BlackEdge.ScopeImage.Image = id
4232 end
4233 function hud:gundrop(dropmodel, gunname)
4234 if not gamelogic.currentgun then
4235 return
4236 end
4237 if dropmodel and not ffc(dropmodel, "DB") then
4238 local dropdata = require(modulestore[gunname])
4239 if dropdata then
4240 use.Text = (input.consoleon and "Press DPadRight" or "Hold V") .. " to pick up [" .. (dropdata.displayname or gunname) .. "]"
4241 if dropdata.type == gamelogic.currentgun.type or dropdata.ammotype == gamelogic.currentgun.ammotype then
4242 local sparev = ffc(dropmodel, "Spare")
4243 if sparev and sparev.Value > 0 then
4244 local diff = 0
4245 local _, curspare = gamelogic.currentgun:dropguninfo()
4246 if curspare + sparev.Value > gamelogic.currentgun.sparerounds then
4247 diff = gamelogic.currentgun.sparerounds - curspare
4248 else
4249 diff = sparev.Value
4250 end
4251 if diff > 0 then
4252 local db = new("Model", dropmodel)
4253 db.Name = "DB"
4254 debris:AddItem(db, 1)
4255 gamelogic.currentgun:addammo(diff, gunname)
4256 network:send("g" .. "e" .. "t" .. "a" .. "m" .. "m" .. "o", dropmodel, diff)
4257 end
4258 end
4259 end
4260 end
4261 else
4262 use.Text = ""
4263 end
4264 end
4265 function hud:getuse()
4266 return use.Text ~= ""
4267 end
4268 function hud:enablegamegui(on)
4269 gamegui.Visible = on
4270 end
4271 function hud:togglecinema(on)
4272 cinamode = on
4273 for i, v in next, cinalist, nil do
4274 v.Visible = not on
4275 end
4276 end
4277 function hud:isplayeralive(p)
4278 local healthstat = healthlist[p]
4279 if healthstat then
4280 return healthlist[p].alive
4281 end
4282 end
4283 function hud:timesinceplayercombat(p)
4284 return tick() - (lastcombat[p] or 0)
4285 end
4286 function hud:getplayerhealth(p)
4287 return gethealth(p)
4288 end
4289 local function updatecross()
4290 if not char.speed or not char.sprint then
4291 return
4292 end
4293 local size = hud.crossspring.p * 4 * hud.crossscale.p * (char.speed / 14 * 0.19999999999999996 * 2 + 0.8) * (char.sprint + 1) / 2
4294 for i = 1, 4 do
4295 crossparts[i].BackgroundTransparency = 1 - size / 20
4296 end
4297 crossparts[1].Position = ud2(0, size, 0, 0)
4298 crossparts[2].Position = ud2(0, -size - 7, 0, 0)
4299 crossparts[3].Position = ud2(0, 0, 0, size)
4300 crossparts[4].Position = ud2(0, 0, 0, -size - 7)
4301 if not centermark and hud.crossspring.t == 0 and not scopefr.Visible and sightmark and sightmark.Parent then
4302 local pos = camera.currentcamera:WorldToViewportPoint(sightmark.Position)
4303 hitmarker.Position = ud2(0, pos.x - 125, 0, pos.y - 125)
4304 else
4305 hitmarker.Position = ud2(0.5, -125, 0.5, -125)
4306 end
4307 end
4308 function hud:getplayervisible(guy)
4309 local state = nametags[guy]
4310 if state then
4311 return state.Visible
4312 end
4313 end
4314 local localplayer = game:GetService("Players").LocalPlayer
4315 local nametagupdates = {}
4316 local function addnametag(player)
4317 local head, torso
4318 local function newchar(char)
4319 head = char:WaitForChild("Head")
4320 torso = char:WaitForChild("Torso")
4321 end
4322 local tag, taghealth
4323 local function playerchanged(prop)
4324 if prop == "TeamColor" and tag then
4325 if player.TeamColor == localplayer.TeamColor then
4326 tag.Visible = true
4327 taghealth.Visible = false
4328 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4329 tag.Dot.BackgroundTransparency = 1
4330 else
4331 tag.Visible = false
4332 taghealth.Visible = false
4333 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4334 tag.Dot.BackgroundTransparency = 1
4335 end
4336 end
4337 end
4338 local function newtag()
4339 tag = playertag:Clone()
4340 tag.Text = player.Name
4341 tag.Parent = tagfr
4342 tag.Visible = false
4343 taghealth = wfc(tag, "Health")
4344 tag.Dot.BackgroundTransparency = 1
4345 tag.TextTransparency = 1
4346 tag.TextStrokeTransparency = 1
4347 playerchanged("TeamColor")
4348 nametags[player] = tag
4349 end
4350 newtag()
4351 local function update()
4352 if not tag.Parent or not taghealth.Parent then
4353 return
4354 end
4355 if hud:isplayeralive(player) and head and head.Parent and torso and torso.Parent then
4356 local torsopos = torso.CFrame * v3(0, -0.25, 0)
4357 if camera.screencull.sphere(torsopos, 4) then
4358 local camcf = camera.cframe
4359 local headpos = head.Position
4360 local spos = camera.currentcamera:WorldToScreenPoint(headpos + cframe.vtws(camcf, v3(0, 0.625, 0)))
4361 local center = camera.currentcamera.ViewportSize / 2
4362 local dist = (torsopos - camcf.p).magnitude
4363 local d = dot(camera.lookvector, (torsopos - camcf.p).unit)
4364 local diff = (1 / (d * d) - 1) ^ 0.5 * dist
4365 tag.Position = ud2(0, spos.x - 75, 0, spos.y)
4366 if player.TeamColor == localplayer.TeamColor then
4367 tag.Visible = true
4368 taghealth.Visible = hud:isplayeralive(player)
4369 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4370 tag.Dot.BackgroundColor3 = color(0, 1, 0.9176470588235294)
4371 if diff < 4 then
4372 tag.TextTransparency = 0.125
4373 taghealth.BackgroundTransparency = 0.75
4374 taghealth.Percent.BackgroundTransparency = 0.25
4375 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4376 tag.Dot.BackgroundTransparency = 1
4377 elseif diff < 8 then
4378 tag.TextTransparency = 0.125 + 0.875 * (diff - 4) / 4
4379 taghealth.BackgroundTransparency = 0.75 + 0.25 * (diff - 4) / 4
4380 taghealth.Percent.BackgroundTransparency = 0.25 + 0.75 * (diff - 4) / 4
4381 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4382 tag.Dot.BackgroundTransparency = 1
4383 else
4384 tag.Dot.BackgroundTransparency = 0.125
4385 tag.TextTransparency = 1
4386 taghealth.BackgroundTransparency = 1
4387 taghealth.Percent.BackgroundTransparency = 1
4388 end
4389 else
4390 tag.Dot.BackgroundTransparency = 1
4391 taghealth.Visible = false
4392 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4393 tag.Dot.BackgroundColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4394 if hud:isspotted(player) and hud:isinsight(player) then
4395 local visible = true
4396 tag.Visible = visible
4397 if visible then
4398 if diff < 4 then
4399 tag.TextTransparency = 0
4400 else
4401 tag.TextTransparency = 1
4402 tag.Dot.BackgroundTransparency = 0
4403 end
4404 end
4405 elseif not hud:isspotted(player) and diff < 4 then
4406 local visible
4407 local tempignore = {
4408 camera.currentcamera,
4409 localplayer.Character,
4410 player.Character
4411 }
4412 local scan, pos = nil, camera.cframe.p
4413 while true do
4414 scan, pos = raycast(workspace, ray(pos, torsopos - pos), tempignore)
4415 if scan then
4416 if scan.Transparency ~= 0 then
4417 tempignore[#tempignore + 1] = scan
4418 else
4419 visible = false
4420 break
4421 end
4422 else
4423 visible = true
4424 break
4425 end
4426 end
4427 tag.Visible = visible
4428 if visible then
4429 if diff < 2 then
4430 tag.Visible = true
4431 tag.TextTransparency = 0.125
4432 elseif diff < 4 then
4433 tag.Visible = true
4434 tag.TextTransparency = 0.4375 * diff - 0.75
4435 else
4436 tag.Visible = false
4437 end
4438 end
4439 else
4440 tag.Visible = false
4441 taghealth.Visible = false
4442 end
4443 end
4444 else
4445 tag.Visible = false
4446 taghealth.Visible = false
4447 end
4448 else
4449 tag.Visible = false
4450 taghealth.Visible = false
4451 end
4452 end
4453 player.CharacterAdded:connect(newchar)
4454 player.Changed:connect(playerchanged)
4455 localplayer.Changed:connect(playerchanged)
4456 nametagupdates[player] = update
4457 delay(1, function()
4458 print("Awaiting char for", player.Name)
4459 while not player.Character do
4460 wait(0.1)
4461 end
4462 print(player.Name .. "'s character has loaded")
4463 newchar(player.Character)
4464 end)
4465 end
4466 game:GetService("Players").PlayerAdded:connect(addnametag)
4467 game:GetService("Players").PlayerRemoving:connect(function(player)
4468 nametagupdates[player] = nil
4469 if nametags[player] then
4470 nametags[player]:Destroy()
4471 end
4472 nametags[player] = nil
4473 end)
4474 for i, player in next, game:GetService("Players"):GetPlayers() do
4475 addnametag(player)
4476 end
4477 local function updateplayernames()
4478 for player, func in next, nametagupdates, nil do
4479 if not player or not player.Parent then
4480 nametagupdates[player] = nil
4481 if nametags[player] then
4482 nametags[player]:Destroy()
4483 end
4484 nametags[player] = nil
4485 else
4486 nametagupdates[player]()
4487 end
4488 end
4489 end
4490 function hud:capping(flag, progress)
4491 if flag then
4492 capfr.Visible = true
4493 cbar.Size = ud2(progress / 50, 0, 1, 0)
4494 else
4495 capfr.Visible = false
4496 end
4497 end
4498 function hud:setsteadybar(size)
4499 steadybar.Size = size
4500 end
4501 function hud:getsteadysize()
4502 return steadybar.Size.X.Scale
4503 end
4504 function hud:setcrossscale(scale)
4505 hud.crossscale.t = scale
4506 end
4507 function hud:setcrosssize(size)
4508 hud.crossspring.t = size
4509 end
4510 function hud:setscope(visible, console)
4511 scopefr.Visible = visible
4512 steady.Visible = visible
4513 steady.Text = (input.consoleon or console) and "Hold DPadUp to steady" or "Hold Shift to steady"
4514 if visible then
4515 sound.play("useScope", 0.25)
4516 doScopeBeat = true
4517 delay(0.5, heartIn)
4518 end
4519 if not visible then
4520 doScopeBeat = false
4521 end
4522 end
4523 function heartIn()
4524 if doScopeBeat then
4525 local setdelay
4526 setdelay = hud:getsteadysize() / 5
4527 sound.play("heartBeatIn", 0.05 + setdelay)
4528 delay(0.3 + setdelay, heartOut)
4529 end
4530 end
4531 function heartOut()
4532 if doScopeBeat then
4533 local setdelay
4534 setdelay = hud:getsteadysize() / 4
4535 sound.play("heartBeatOut", 0.05 + setdelay)
4536 delay(0.5 + setdelay, heartIn)
4537 end
4538 end
4539 function hud:setcrosssettings(size, speed, damper, sight, centered)
4540 hud.crossspring.t = size
4541 hud.crossspring.s = speed
4542 hud.crossspring.d = damper
4543 sightmark = sight
4544 centermark = centered
4545 end
4546 function hud:updatesightmark(sight, centered)
4547 sightmark = sight
4548 centermark = centered
4549 end
4550 function hud:updateammo(mag, ammo)
4551 if mag == "KNIFE" then
4552 ammotext.Text = "- - -"
4553 magtext.Text = "- - -"
4554 elseif mag == "GRENADE" then
4555 ammotext.Text = "- - -"
4556 magtext.Text = "- - -"
4557 gammo.Text = gamelogic.gammo .. "x"
4558 else
4559 ammotext.Text = ammo
4560 magtext.Text = mag
4561 end
4562 end
4563 function hud:updatefiremode(mode)
4564 fmodetext.Text = mode == "KNIFE" and "- - -" or mode == true and "AUTO" or mode == 1 and "SEMI" or "BURST"
4565 end
4566 function hud:firehitmarker(head)
4567 hud.hitspring.p = -3
4568 if head then
4569 hitmarker.ImageColor3 = Color3.new(1, 0, 0)
4570 else
4571 hitmarker.ImageColor3 = Color3.new(1, 1, 1)
4572 end
4573 end
4574 function hud:fireradar(guy)
4575 local prev = infolder(spot:GetChildren(), guy.Name)
4576 if prev then
4577 prev.Time.Value = prev.Time.Value <= 30 and 30 or prev.Time.Value + 30 > 200 and 200 or prev.Time.Value + 30
4578 else
4579 local mark = spotdot:Clone()
4580 mark.Parent = spot
4581 mark.Name = guy.Name
4582 mark.Time.Value = 30
4583 mark.Adornee = char.rootpart
4584 mark.Dot.Visible = false
4585 end
4586 end
4587 local function updatehealth()
4588 local health = char.health
4589 if health > 100 then
4590 player:kick("Health Error")
4591 end
4592 healthtext.Text = health + -health % 1
4593 if health < prevhealth then
4594 local damage = prevhealth - health
4595 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency - damage / prevhealth * 0.7
4596 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency - damage / prevhealth * 0.5 + 0.3
4597 elseif health > prevhealth or health == 100 then
4598 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency + 0.001
4599 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency + 0.001
4600 elseif health <= 0 then
4601 bloodscreen.ImageTransparency = 1
4602 bloodscreen.BackgroundTransparency = 1
4603 end
4604 prevhealth = health
4605 if health <= 25 then
4606 healthbar.BackgroundColor3 = newGUIColors[4]
4607 healthbarFill.BackgroundColor3 = newGUIColors[3]
4608 else
4609 healthbar.BackgroundColor3 = newGUIColors[1]
4610 healthbarFill.BackgroundColor3 = newGUIColors[2]
4611 end
4612 healthbarFill.Size = UDim2.new(math.floor(health) / 100, 0, 1, 0)
4613 end
4614 local function update_pos(ref, pos, color, trans)
4615 local dot = dotlist[ref]
4616 if not dot then
4617 return
4618 end
4619 dot.Visible = true
4620 dot.BackgroundColor3 = color
4621 dot.Position = pos
4622 dot.BackgroundTransparency = trans
4623 end
4624 local function updateradar()
4625 if char.health <= 0 then
4626 return
4627 end
4628 local old = rfolder:GetChildren()
4629 for i = 1, #old do
4630 old[i].Visible = false
4631 end
4632 local torso = char.rootpart
4633 local look = torso.CFrame.lookVector
4634 local cameracf = cf(torso.CFrame.p, torso.CFrame.p + look)
4635 local ppl = game:GetService("Players"):GetPlayers()
4636 local dotcounter = 0
4637 for i = 1, #ppl do
4638 local v = ppl[i]
4639 if v ~= player and v.Character and ffc(workspace, v.Name) then
4640 local tor = ffc(v.Character, "Torso")
4641 local alive = hud:isplayeralive(v)
4642 if tor and alive then
4643 if v.TeamColor == player.TeamColor or hud:isspotted(v) and hud:isinsight(player) or infolder(spot:GetChildren(), v.Name) then
4644 local diff = cameracf:inverse() * tor.Position
4645 local x = 0.5 + diff.x / distance
4646 local z = 0.5 + diff.z / distance
4647 local pos = ud2(x, offset, z, offset)
4648 local c = v.TeamColor == player.TeamColor and color(0.5, 1, 0.5) or color(1, 0, 0)
4649 dotcounter = dotcounter + 1
4650 update_pos(dotcounter, pos, c, -0.5 + (torso.Position - tor.Position).Magnitude / 150)
4651 end
4652 elseif not alive then
4653 local ghosttag = infolder(spot:GetChildren(), v.Name)
4654 if ghosttag then
4655 ghosttag:Destroy()
4656 print("removed tag for", v.Name)
4657 end
4658 end
4659 end
4660 end
4661 local map = ffc(workspace, "Map")
4662 if map then
4663 local agmp = ffc(map, "AGMP")
4664 if agmp then
4665 local stuff = agmp:GetChildren()
4666 for i = 1, #stuff do
4667 local v = stuff[i]
4668 local base = ffc(v, "Base")
4669 local teamcolor = ffc(v, "TeamColor")
4670 if base then
4671 local diff = cameracf:inverse() * base.Position
4672 local x = 0.5 + diff.x / distance
4673 local z = 0.5 + diff.z / distance
4674 local pos = ud2(x, offset, z, offset)
4675 local c = teamcolor.Value.Color
4676 dotcounter = dotcounter + 1
4677 update_pos(dotcounter, pos, c, -0.5 + (torso.Position - base.Position).magnitude / 150)
4678 end
4679 end
4680 end
4681 end
4682 end
4683 do
4684 local spottedlist = {}
4685 local sightlist = {}
4686 local brokensight = {}
4687 function hud:spot()
4688 local spotlist = {}
4689 if char.health > 0 then
4690 local camcf = camera.cframe
4691 local dir = camcf.lookVector.unit
4692 local ppl = game:GetService("Players"):GetPlayers()
4693 local lteam = player.TeamColor
4694 local ignoretable = {
4695 camera.currentcamera,
4696 workspace.Ignore,
4697 workspace.DeadBody,
4698 player.Character
4699 }
4700 for i = 1, #ppl do
4701 local guy = ppl[i]
4702 if hud:isplayeralive(guy) and guy.TeamColor ~= lteam then
4703 local bodyparts = replication.getbodyparts(guy)
4704 if bodyparts and bodyparts.head then
4705 local rel = bodyparts.head.Position - camera.cframe.p
4706 local unit = rel.unit
4707 local d = dot(dir, unit)
4708 if d > 0.96592582628 then
4709 local origin = camcf.p
4710 local newray = ray(origin, rel)
4711 ignoretable[5] = bodyparts.head.Parent
4712 local hit = raycast(workspace, newray, ignoretable)
4713 if not hit then
4714 spotlist[#spotlist + 1] = guy
4715 end
4716 end
4717 end
4718 end
4719 end
4720 if #spotlist > 0 then
4721 network:send("spotplayers", spotlist)
4722 end
4723 end
4724 end
4725 network:add("brokensight", function(spottedplayer, status)
4726 brokensight[spottedplayer] = status
4727 end)
4728 network:add("spotplayer", function(spottedplayer)
4729 spottedlist[spottedplayer] = true
4730 end)
4731 network:add("unspotplayer", function(spottedplayer)
4732 spottedlist[spottedplayer] = nil
4733 end)
4734 function hud:isspotted(spottedplayer)
4735 return spottedlist[spottedplayer]
4736 end
4737 function hud:isinsight(spottedplayer)
4738 return not brokensight[spottedplayer] or sightlist[player]
4739 end
4740 function hud.spotstep()
4741 local ignoretable = {
4742 camera.currentcamera,
4743 workspace.Ignore,
4744 workspace.DeadBody,
4745 player.Character
4746 }
4747 for spottedplayer in next, spottedlist, nil do
4748 local playerseen = false
4749 if char.health > 0 and spottedplayer.TeamColor ~= player.TeamColor then
4750 local bodyparts = replication.getbodyparts(spottedplayer)
4751 if bodyparts and bodyparts.torso and camera.screencull.sphere(bodyparts.torso.Position, 4) then
4752 local rel = bodyparts.head.Position - camera.cframe.p
4753 local origin = camera.cframe.p
4754 local newray = ray(origin, rel)
4755 ignoretable[5] = bodyparts.head.Parent
4756 local hit = raycast(workspace, newray, ignoretable)
4757 if not hit then
4758 playerseen = true
4759 if not sightlist[spottedplayer] then
4760 sightlist[spottedplayer] = true
4761 network:send("updatesight", spottedplayer, true, tick())
4762 end
4763 end
4764 end
4765 end
4766 if not playerseen and sightlist[spottedplayer] then
4767 sightlist[spottedplayer] = false
4768 network:send("updatesight", spottedplayer, false, tick())
4769 end
4770 end
4771 if hud:isspotted(player) then
4772 spotted.Visible = true
4773 if hud:isinsight(player) then
4774 spotted.Text = "Spotted by enemy!"
4775 spotted.TextColor3 = Color3.new(1, 0.125, 0.125)
4776 else
4777 spotted.Text = "Hiding from enemy..."
4778 spotted.TextColor3 = Color3.new(0.125, 1, 0.125)
4779 end
4780 else
4781 local spottag = ffc(spotted, "Spottimer")
4782 if spottag and 0 < spottag.Timer.Value then
4783 spotted.Visible = true
4784 spotted.Text = "On Radar!"
4785 spotted.TextColor3 = Color3.new(1, 0.8, 0)
4786 else
4787 spotted.Visible = false
4788 end
4789 end
4790 end
4791 function hud:goingloud()
4792 local spottag = ffc(spotted, "Spottimer")
4793 local timer
4794 if not spottag then
4795 spottag = new("Model", spotted)
4796 spottag.Name = "Spottimer"
4797 timer = new("IntValue", spottag)
4798 timer.Name = "Timer"
4799 else
4800 timer = spottag.Timer
4801 end
4802 timer.Value = timer.Value <= 30 and 30 or timer.Value + 30 > 200 and 200 or timer.Value + 30
4803 end
4804 end
4805 network:add("firehitmarker", function()
4806 hud:firehitmarker()
4807 end)
4808 network:add("shot", function(shooter, pos, damage)
4809 local bars = gamegui:GetChildren()
4810 for i = 1, #bars do
4811 if bars[i].Name == "BloodArc" and bars[i].Player.Value == shooter.Name then
4812 trash.remove(bars[i])
4813 end
4814 end
4815 local br = bloodarc:Clone()
4816 br.Pos.Value = pos
4817 br.Player.Value = shooter.Name
4818 br.Parent = gamegui
4819 local dir = (camera.cframe.p - pos).unit
4820 camera:hit((-damage / 12 + 4.166666666666667) * dir)
4821 end)
4822 network:add("updatecombat", function(guy, time)
4823 if guy then
4824 lastcombat[guy] = time
4825 end
4826 end)
4827 function hud:reloadhud()
4828 pgui = player.PlayerGui
4829 maingui = wfc(pgui, "MainGui")
4830 gamegui = wfc(maingui, "GameGui")
4831 bloodscreen = wfc(gamegui, "BloodScreen")
4832 crossframe = wfc(gamegui, "CrossHud")
4833 crossparts = {
4834 wfc(crossframe, "HR"),
4835 wfc(crossframe, "HL"),
4836 wfc(crossframe, "VD"),
4837 wfc(crossframe, "VU")
4838 }
4839 ammohud = wfc(gamegui, "AmmoHud")
4840 ammofr = wfc(ammohud, "Frame")
4841 scopefr = wfc(gamegui, "ScopeFrame")
4842 ammotext = wfc(ammofr, "Ammo")
4843 magtext = wfc(ammofr, "Mag")
4844 healthtext = wfc(ammofr, "Health")
4845 fmodetext = wfc(ammofr, "FMode")
4846 hitmarker = wfc(gamegui, "Hitmarker")
4847 tagfr = wfc(gamegui, "NameTag")
4848 healthbar = wfc(ammofr, "healthbar_back")
4849 healthbarFill = wfc(healthbar, "healthbar_fill")
4850 radar = wfc(gamegui, "Radar")
4851 rme = wfc(radar, "Me")
4852 rfolder = wfc(radar, "Folder")
4853 dotlist = {}
4854 rfolder:ClearAllChildren()
4855 hud:setscope(false)
4856 effects:reload()
4857 notify:reset()
4858 particle:reset()
4859 local bars = gamegui:GetChildren()
4860 for i = 1, #bars do
4861 if bars[i].Name == "BloodArc" then
4862 trash.remove(bars[i])
4863 end
4864 end
4865 local bar = ffc(maingui, "KillBar")
4866 if bar then
4867 trash.remove(bar)
4868 end
4869 for i = 1, 50 do
4870 local dot = rme:Clone()
4871 dot.Parent = rfolder
4872 dot.Visible = false
4873 dotlist[#dotlist + 1] = dot
4874 end
4875 wait(0.1)
4876 end
4877 function hud.beat()
4878 updateplayernames()
4879 updatehealth()
4880 end
4881 function hud.step()
4882 updatecross()
4883 hitmarker.ImageTransparency = hud.hitspring.p
4884 if run.time > rtime + radarinterval then
4885 updateradar()
4886 rtime = run.time + radarinterval
4887 end
4888 if run.time > stime + spotinterval then
4889 hud.spotstep()
4890 hud.votestep()
4891 local sht = spot:GetChildren()
4892 for i = 1, #sht do
4893 local v = sht[i]
4894 if rtype(v, "BillboardGui") then
4895 if v.Time.Value <= 0 then
4896 trash.remove(v)
4897 else
4898 v.Time.Value = v.Time.Value - 1
4899 end
4900 end
4901 end
4902 local spottag = ffc(spotted, "Spottimer")
4903 if spottag and 0 < spottag.Timer.Value then
4904 spottag.Timer.Value = spottag.Timer.Value - 1
4905 end
4906 stime = run.time + spotinterval
4907 end
4908 end
4909end
4910print("Loading notify module")
4911do
4912 local wfc = game.WaitForChild
4913 local ffc = game.FindFirstChild
4914 local ud2 = UDim2.new
4915 local ceil = math.ceil
4916 local v3 = Vector3.new
4917 local color = Color3.new
4918 local dot = Vector3.new().Dot
4919 local workspace = workspace
4920 local ray = Ray.new
4921 local raycast = workspace.FindPartOnRayWithIgnoreList
4922 local new = Instance.new
4923 local player = game:GetService("Players").LocalPlayer
4924 local repstore = game.ReplicatedStorage
4925 local misc = repstore.Misc
4926 local pgui = player.PlayerGui
4927 local maingui = wfc(pgui, "MainGui")
4928 local gamegui = wfc(maingui, "GameGui")
4929 local framelist = wfc(gamegui, "NotifyList")
4930 local main = misc.Main
4931 local side = misc.Side
4932 local killbar = misc.KillBar
4933 local rankbar = misc.RankBar
4934 local attachbar = misc.AttachBar
4935 local typelist = {
4936 kill = {
4937 "Enemy Killed!"
4938 },
4939 collx2 = {
4940 "Double Collateral!"
4941 },
4942 collx3 = {
4943 "Triple Collateral!"
4944 },
4945 collxn = {
4946 "Multi Collateral!"
4947 },
4948 killx2 = {
4949 "Double Kill!"
4950 },
4951 killx3 = {
4952 "Triple Kill!"
4953 },
4954 killx4 = {"Quad Kill!"},
4955 killxn = {
4956 "Multi Kill!"
4957 },
4958 backstab = {"Backstab!"},
4959 assist = {"Assist!"},
4960 assistkill = {
4961 "Assist Count As Kill!"
4962 },
4963 head = {
4964 "Headshot bonus!"
4965 },
4966 long = {
4967 "Killed from a distance!"
4968 },
4969 spot = {
4970 "Spot Bonus!"
4971 },
4972 squad = {
4973 "Teammate spawned on you"
4974 },
4975 domcap = {
4976 "Captured a position!"
4977 },
4978 domcapping = {
4979 "Capturing position"
4980 },
4981 domdefend = {
4982 "Defended a position!"
4983 },
4984 domassault = {
4985 "Assaulted a position!"
4986 },
4987 domattack = {
4988 "Attacked a position!"
4989 },
4990 dombuzz = {
4991 "Stopped an enemy capture!"
4992 },
4993 kingcap = {
4994 "Captured the hill!"
4995 },
4996 kingholding = {
4997 "Holding hill"
4998 },
4999 kingcapping = {
5000 "Capturing hill"
5001 },
5002 kingdefend = {
5003 "Defended the hill!"
5004 },
5005 kingassault = {
5006 "Assaulted the hill!"
5007 },
5008 kingattack = {
5009 "Attacked the hill!"
5010 },
5011 kingbuzz = {
5012 "Stopped enemy capture of the hill!"
5013 },
5014 [""] = {}
5015 }
5016 local typeout = function(label, speed)
5017 local speed = speed or 2
5018 local text = label.Text
5019 label.Text = ""
5020 spawn(function()
5021 for i = 1, string.len(text) do
5022 label.Text = string.sub(text, 1, speed * i)
5023 wait(0.016666666666666666)
5024 end
5025 end)
5026 end
5027 local queuetypeout = function(label, speed)
5028 local speed = speed or 3
5029 local text = label.Text
5030 label.Text = ""
5031 for i = 1, string.len(text) do
5032 label.Text = string.sub(text, 1, speed * i)
5033 wait(0.016666666666666666)
5034 end
5035 end
5036 function notify:customaward(customtext)
5037 local display = side:Clone()
5038 local primary = wfc(display, "Primary")
5039 display.Parent = framelist
5040 local fr = framelist:GetChildren()
5041 for i = 1, #fr do
5042 local v = fr[i]
5043 if v:IsA("Frame") and v.Parent then
5044 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5045 end
5046 end
5047 spawn(function()
5048 primary.Text = customtext
5049 primary.TextTransparency = 0
5050 typeout(primary, 3)
5051 wait(5.5)
5052 for i = 1, 10 do
5053 primary.TextTransparency = i / 10
5054 primary.TextStrokeTransparency = i / 10 + 0.4
5055 wait(0.016666666666666666)
5056 end
5057 wait(0.1)
5058 trash.remove(display)
5059 end)
5060 end
5061 function smallaward(type, pt)
5062 local pt = pt or 25
5063 local display = side:Clone()
5064 local primary = wfc(display, "Primary")
5065 local point = wfc(display, "Point")
5066 display.Parent = framelist
5067 local fr = framelist:GetChildren()
5068 for i = 1, #fr do
5069 local v = fr[i]
5070 if v:IsA("Frame") and v.Parent then
5071 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5072 end
5073 end
5074 spawn(function()
5075 point.Text = "[+" .. pt .. "]"
5076 primary.Text = typelist[type][1]
5077 if type == "head" then
5078 sound.play("headshotkill", 0.45)
5079 end
5080 point.TextTransparency = 0
5081 primary.TextTransparency = 0
5082 typeout(point, 3)
5083 typeout(primary, 3)
5084 wait(5.5)
5085 for i = 1, 10 do
5086 point.TextTransparency = i / 10
5087 primary.TextTransparency = i / 10
5088 point.TextStrokeTransparency = i / 10 + 0.4
5089 primary.TextStrokeTransparency = i / 10 + 0.4
5090 wait(0.016666666666666666)
5091 end
5092 wait(0.1)
5093 trash.remove(display)
5094 end)
5095 end
5096 function bigaward(type, victim, weap, pt)
5097 local display = main:Clone()
5098 local bk = wfc(display, "Overlay")
5099 local primary = wfc(display, "Primary")
5100 local point = wfc(display, "Point")
5101 local enemy = wfc(display, "Enemy")
5102 display.Parent = framelist
5103 local fr = framelist:GetChildren()
5104 for i = 1, #fr do
5105 local v = fr[i]
5106 if v:IsA("Frame") and v.Parent then
5107 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5108 end
5109 end
5110 spawn(function()
5111 point.Text = "[+" .. pt .. "]"
5112 primary.Text = typelist[type][1]
5113 enemy.Text = victim
5114 if type == "kill" then
5115 sound.play("killshot", 0.4)
5116 end
5117 point.TextTransparency = 0
5118 point.TextStrokeTransparency = 0
5119 primary.TextTransparency = 0
5120 primary.TextStrokeTransparency = 0
5121 enemy.TextTransparency = 1
5122 enemy.TextStrokeTransparency = 1
5123 bk.ImageTransparency = 0.2
5124 bk:TweenSizeAndPosition(ud2(0, 200, 0, 80), ud2(0.5, -150, 0.7, -40), "Out", "Linear", 0, true)
5125 typeout(point)
5126 typeout(primary)
5127 spawn(function()
5128 wait(0.05)
5129 for i = 1, 10 do
5130 bk.ImageTransparency = i / 10
5131 wait(0.1)
5132 end
5133 bk.Size = ud2(0, 200, 0, 80)
5134 bk.Position = ud2(0.55, -100, 0.3, -40)
5135 end)
5136 bk:TweenSizeAndPosition(ud2(0, 300, 0, 30), ud2(0.5, -150, 0.7, -15), "Out", "Linear", 0.05, true)
5137 wait(0.05)
5138 bk:TweenSizeAndPosition(ud2(0, 500, 0, 8), ud2(0.5, -150, 0.7, -4), "Out", "Linear", 0.05, true)
5139 wait(1.5)
5140 for i = 1, 2 do
5141 primary.TextTransparency = 1
5142 primary.TextStrokeTransparency = 1
5143 wait(0.1)
5144 primary.TextTransparency = 0
5145 primary.TextStrokeTransparency = 0
5146 wait(0.1)
5147 end
5148 primary.TextTransparency = 1
5149 primary.TextStrokeTransparency = 1
5150 wait(0.2)
5151 enemy.TextTransparency = 0
5152 enemy.TextStrokeTransparency = 0
5153 queuetypeout(enemy, 4)
5154 primary.TextTransparency = 0
5155 primary.TextStrokeTransparency = 0
5156 primary.Position = ud2(0.5, enemy.TextBounds.x + 10, 0.7, -10)
5157 primary.Text = "[" .. weap .. "]"
5158 queuetypeout(primary, 4)
5159 wait(3)
5160 for i = 1, 10 do
5161 point.TextTransparency = i / 10
5162 primary.TextTransparency = i / 10
5163 enemy.TextTransparency = i / 10
5164 point.TextStrokeTransparency = i / 10 + 0.4
5165 primary.TextStrokeTransparency = i / 10 + 0.4
5166 enemy.TextStrokeTransparency = i / 10 + 0.4
5167 wait(0.016666666666666666)
5168 end
5169 wait(0.1)
5170 trash.remove(display)
5171 end)
5172 end
5173 local function unlockedgun(weapon)
5174 local br = attachbar:Clone()
5175 local title = br.Title
5176 local atext = br.Attach
5177 br.Parent = maingui
5178 br.Position = ud2(0.5, 0, 0.15, 0)
5179 title.Text = "Unlocked New Gun!"
5180 atext.Text = weapon
5181 local t0 = tick()
5182 local stop
5183 stop = run.onstep:connect(function()
5184 local t = tick() - t0
5185 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5186 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5187 if t > 3 then
5188 stop()
5189 br:Destroy()
5190 end
5191 end)
5192 end
5193 local function unlockedattach(weapon, attachments, killss)
5194 for i = 1, #attachments do
5195 do
5196 local attachment = attachments[i]
5197 local kills = killss[i]
5198 local br = attachbar:Clone()
5199 local money = br.Money
5200 local title = br.Title
5201 local atext = br.Attach
5202 br.Parent = maingui
5203 br.Position = ud2(0.5, 0, 0.15, 0)
5204 title.Text = "Unlocked " .. weapon .. " Attachment"
5205 atext.Text = attachment
5206 money.Text = "[+200]"
5207 local t0 = tick()
5208 local stop
5209 stop = run.onstep:connect(function()
5210 local t = tick() - t0
5211 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5212 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
5213 money.TextTransparency = t < 0.5 and 1 or t < 2.5 and 0 or t < 3 and (t - 2.5) / 0.5 or 1
5214 if t > 3 then
5215 stop()
5216 br:Destroy()
5217 end
5218 end)
5219 wait(3)
5220 end
5221 end
5222 end
5223 local function rankup(old, new, newguns)
5224 local br = rankbar:Clone()
5225 local money = br.Money
5226 local title = br.Title
5227 local rtext = br.Rank
5228 local count = 0
5229 local sht = maingui:GetChildren()
5230 for i = 1, #sht do
5231 if sht[i].Name == "RankBar" or sht[i].Name == "AttachBar" then
5232 count = count + 1
5233 end
5234 end
5235 br.Parent = maingui
5236 rtext.Text = new
5237 money.Text = "+" .. 5 * (new - old) * (81 + new + old) / 2 .. " CR"
5238 local t0 = tick()
5239 local stop
5240 stop = run.onstep:connect(function()
5241 local t = tick() - t0
5242 rtext.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
5243 title.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
5244 money.TextTransparency = t < 0.5 and 1 or t < 3.5 and 0 or t < 4 and (t - 3.5) / 0.5 or 1
5245 if t > 4 then
5246 stop()
5247 br:Destroy()
5248 if newguns then
5249 for i = 1, #newguns do
5250 unlockedgun(newguns[i])
5251 wait(3)
5252 end
5253 end
5254 end
5255 end)
5256 end
5257 function notify:testrankup(rank)
5258 rankup(rank)
5259 end
5260 function notify:reset()
5261 maingui = wfc(pgui, "MainGui")
5262 gamegui = wfc(maingui, "GameGui")
5263 framelist = wfc(gamegui, "NotifyList")
5264 if ffc(maingui, "KillBar") then
5265 trash.remove(maingui.KillBar)
5266 end
5267 end
5268 do
5269 local cf = CFrame.new
5270 local tos = cf().toObjectSpace
5271 local bcolor = BrickColor.new
5272 local repstore = game.ReplicatedStorage
5273 local gunmodels = repstore.GunModels
5274 local gunmodules = repstore.GunModules
5275 local attmodels = repstore.AttachmentModels
5276 local mpgunmodels = repstore.MeshPartGunModels
5277 local function hideparts(wepmodel, atttype, hide)
5278 local parts = wepmodel:GetChildren()
5279 local slottag
5280 for i = 1, #parts do
5281 if atttype == "Optics" then
5282 if parts[i].Name == "Iron" or parts[i].Name == "IronGlow" then
5283 if hide and not ffc(parts[i], "Hide") then
5284 local tag = new("IntValue", parts[i])
5285 tag.Name = "Hide"
5286 else
5287 local tag = ffc(parts[i], "Hide")
5288 if tag then
5289 tag:Destroy()
5290 end
5291 end
5292 parts[i].Transparency = hide and 1 or 0
5293 elseif parts[i].Name == "SightMark" and ffc(parts[i], "Decal") then
5294 parts[i].Decal.Transparency = hide and 1 or 0
5295 end
5296 elseif atttype == "Underbarrel" and parts[i].Name == "Grip" then
5297 if hide and not ffc(parts[i], "Hide") then
5298 local tag = new("IntValue", parts[i])
5299 tag.Name = "Hide"
5300 else
5301 local tag = ffc(parts[i], "Hide")
5302 if tag then
5303 tag:Destroy()
5304 end
5305 end
5306 parts[i].Transparency = hide and 1 or 0
5307 slottag = ffc(parts[i], "Slot1") or ffc(parts[i], "Slot2")
5308 end
5309 end
5310 return slottag
5311 end
5312 local function texturemodel(wepmodel, attachdata, camodata)
5313 local root = camodata
5314 for i, part in next, wepmodel:GetChildren() do
5315 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
5316 part.Anchored = true
5317 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
5318 if slottag then
5319 for x, y in next, part:GetChildren() do
5320 if y:IsA("Texture") then
5321 y:Destroy()
5322 end
5323 end
5324 if root and root[slottag.Name] and root[slottag.Name].Name ~= "" then
5325 local t = Instance.new("Texture")
5326 t.Name = slottag.Name
5327 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
5328 t.Transparency = part.Transparency >= 0.8 and 1 or root[slottag.Name].TextureProperties.Transparency
5329 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
5330 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
5331 if root[slottag.Name].TextureProperties.Color then
5332 local colordata = root[slottag.Name].TextureProperties.Color
5333 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
5334 end
5335 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
5336 local tt = t:Clone()
5337 tt.Face = x
5338 tt.Parent = part
5339 end
5340 t:Destroy()
5341 if not root[slottag.Name].BrickProperties.DefaultColor then
5342 if part:IsA("UnionOperation") then
5343 part.UsePartColor = true
5344 end
5345 if root[slottag.Name].BrickProperties.Color then
5346 local colordata = root[slottag.Name].BrickProperties.Color
5347 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
5348 else
5349 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
5350 end
5351 end
5352 if root[slottag.Name].BrickProperties.Material then
5353 part.Material = root[slottag.Name].BrickProperties.Material
5354 end
5355 end
5356 end
5357 elseif part:IsA("Model") then
5358 texturemodel(part)
5359 end
5360 end
5361 end
5362 local function updategunmeshtype(wepmodel, attachdata, camodata)
5363 local root = camodata
5364 local meshpartmap = {}
5365 local mpmodel = ffc(mpgunmodels, wepmodel.Name)
5366 if mpmodel then
5367 for i, v in next, mpmodel:GetChildren() do
5368 if v:IsA("MeshPart") then
5369 meshpartmap[v.MeshId] = v
5370 end
5371 end
5372 end
5373 for i, v in next, wepmodel:GetChildren() do
5374 if ffc(v, "Mesh") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
5375 v.Anchored = true
5376 v.CanCollide = false
5377 local slottag = ffc(v, "Slot1") or ffc(v, "Slot2")
5378 if slottag and root[slottag.Name].BrickProperties.EnableMaterial and ffc(v, "Mesh") then
5379 local mpart = meshpartmap[v.Mesh.MeshId]:Clone()
5380 mpart.CFrame = v.CFrame
5381 mpart.Name = v.Name
5382 mpart.Anchored = true
5383 mpart.Parent = wepmodel
5384 mpart.Color = v.Color
5385 mpart.Material = v.Material
5386 mpart.CanCollide = v.CanCollide
5387 mpart.Transparency = v.Transparency
5388 for x, y in next, v:GetChildren() do
5389 if y.Name == "Texture" then
5390 y:Clone().Parent = mpart
5391 end
5392 end
5393 v:Destroy()
5394 end
5395 end
5396 end
5397 end
5398 local function updategunattachment(wepmodel, atttype, attachname, wepnodes, preview)
5399 local parts = wepmodel:GetChildren()
5400 local data = require(ffc(gunmodules, wepmodel.Name))
5401 local attachdata = data.attachments[atttype] and data.attachments[atttype][attachname] or {}
5402 local refmodel = attachdata.altmodel and ffc(attmodels, attachdata.altmodel) or ffc(attmodels, attachname)
5403 if not refmodel then
5404 return
5405 end
5406 local model = refmodel:Clone()
5407 local basepart = wfc(model, "Node")
5408 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
5409 local node
5410 model.Name = attachname
5411 if sidemount then
5412 local basenode = sidemount.Node
5413 local mountnode = attachdata.mountnode and wepnodes[attachdata.mountnode] or atttype == "Optics" and wepnodes.MountNode or atttype == "Underbarrel" and wepnodes.UnderMountNode
5414 local mountcframes = {}
5415 local mchildren = sidemount:GetChildren()
5416 local basecframe = basenode.CFrame
5417 for i = 1, #mchildren do
5418 if mchildren[i]:IsA("BasePart") then
5419 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
5420 end
5421 end
5422 basenode.CFrame = mountnode.CFrame
5423 for i = 1, #mchildren do
5424 if mchildren[i]:IsA("BasePart") then
5425 local v = mchildren[i]
5426 v.CFrame = mountnode.CFrame * mountcframes[i]
5427 end
5428 end
5429 node = attachdata.node and wepnodes[attachdata.node] or sidemount[atttype .. "Node"]
5430 sidemount.Parent = model
5431 else
5432 node = attachdata.node and wepnodes[attachdata.node] or wepnodes[atttype .. "Node"]
5433 end
5434 local weldcframes = {}
5435 local children = model:GetChildren()
5436 local basecframe = basepart and basepart.CFrame
5437 local slottag
5438 if atttype == "Optics" or atttype == "Underbarrel" then
5439 slottag = hideparts(wepmodel, atttype, true)
5440 end
5441 for i = 1, #children do
5442 if children[i]:IsA("BasePart") then
5443 weldcframes[i] = tos(basecframe, children[i].CFrame)
5444 end
5445 end
5446 basepart.CFrame = node.CFrame
5447 for i = 1, #children do
5448 if children[i]:IsA("BasePart") then
5449 local v = children[i]
5450 v.CFrame = node.CFrame * weldcframes[i]
5451 if slottag and (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) then
5452 slottag:Clone().Parent = v
5453 end
5454 end
5455 end
5456 model.Parent = wepmodel
5457 end
5458 function getgunmodel(wep, attachdata, camodata)
5459 local findgun = ffc(gunmodels, wep)
5460 if findgun then
5461 local wepmodel = findgun:Clone()
5462 local nodes = wfc(wepmodel, "MenuNodes")
5463 nodes.Parent = wepmodel
5464 wepmodel.PrimaryPart = wfc(nodes, "MenuNode")
5465 for i, v in next, attachdata, nil do
5466 if v ~= "" then
5467 updategunattachment(wepmodel, i, v, nodes)
5468 end
5469 end
5470 updategunmeshtype(wepmodel, attachdata, camodata)
5471 texturemodel(wepmodel, attachdata, camodata)
5472 return wepmodel
5473 end
5474 end
5475 end
5476 network:add("killed", function(killer, part, deathcf, weapon, rank, attachdata, camodata)
5477 char.deadcf = deathcf
5478 if killer == player then
5479 camera:setfixedcam(CFrame.new(deathcf.p, deathcf.p + deathcf.lookVector))
5480 else
5481 do
5482 local gunmodel = getgunmodel(weapon, attachdata, camodata)
5483 gunmodel.Parent = workspace.CurrentCamera
5484 gunmodel:SetPrimaryPartCFrame(deathcf * CFrame.Angles(0, math.rad(90), 0) + Vector3.new(0, 1, 0))
5485 local newbar = killbar:Clone()
5486 newbar.Killer.Label.Text = killer.Name
5487 newbar.Weapon.Label.Text = weapon
5488 newbar.Parent = maingui
5489 newbar.Rank.Label.Text = rank
5490 local wepnote = misc.WepNote:Clone()
5491 wepnote.Parent = gunmodel
5492 for i, v in next, newbar.Attachments:GetChildren() do
5493 v.Type.Text = "None"
5494 end
5495 if attachdata then
5496 for i, v in next, attachdata, nil do
5497 if i ~= "Name" and v ~= "" then
5498 newbar.Attachments[i].Type.Text = v
5499 end
5500 end
5501 end
5502 camera:setspectate(killer, part)
5503 delay(5, function()
5504 gunmodel:Destroy()
5505 end)
5506 end
5507 end
5508 end)
5509 network:add("unlockedattach", unlockedattach)
5510 network:add("rankup", rankup)
5511 network:add("bigaward", function(type, victim, weapon, pt)
5512 bigaward(type, victim, weapon, pt)
5513 end)
5514 network:add("smallaward", function(type, pt)
5515 smallaward(type, pt)
5516 end)
5517 function notify.step()
5518 if char.health <= 0 then
5519 local bar = ffc(maingui, "KillBar")
5520 if bar then
5521 local enemy = ffc(game:GetService("Players"), bar.Killer.Label.Text)
5522 if enemy then
5523 local health = hud:getplayerhealth(enemy)
5524 bar.Health.Label.Text = ceil(health)
5525 bar.Health.Label.TextColor3 = health < 20 and color(1, 0, 0) or health < 50 and color(1, 1, 0) or color(0, 1, 0)
5526 end
5527 end
5528 end
5529 end
5530end
5531print("Loading leaderboard module")
5532do
5533 local wfc = game.WaitForChild
5534 local ffc = game.FindFirstChild
5535 local ud2 = UDim2.new
5536 local ceil = math.ceil
5537 local cf = CFrame.new
5538 local v3 = Vector3.new
5539 local color = Color3.new
5540 local dot = Vector3.new().Dot
5541 local workspace = workspace
5542 local ray = Ray.new
5543 local new = Instance.new
5544 local raycast = workspace.FindPartOnRayWithIgnoreList
5545 local infolder = function(l, e)
5546 for i = 1, #l do
5547 if l[i].Name == e then
5548 return l[i]
5549 end
5550 end
5551 end
5552 local rtype = game.IsA
5553 local debris = game.Debris
5554 local player = game:GetService("Players").LocalPlayer
5555 local playertag = game.ReplicatedStorage.Character.PlayerTag
5556 local pgui = player.PlayerGui
5557 local misc = input.consoleon and game.ReplicatedStorage.XBOX or game.ReplicatedStorage.Misc
5558 local playerstat = misc.Player
5559 local board = wfc(pgui, "Leaderboard")
5560 if input.consoleon then
5561 board:Destroy()
5562 board = misc.Leaderboard:Clone()
5563 board.Parent = pgui
5564 end
5565 local main = wfc(board, "Main")
5566 local global = wfc(board, "Global")
5567 local ghost = wfc(main, "Ghosts")
5568 local phantom = wfc(main, "Phantoms")
5569 local gdataframe = wfc(ghost, "DataFrame")
5570 local pdataframe = wfc(phantom, "DataFrame")
5571 local ghostdata = wfc(gdataframe, "Data")
5572 local phantomdata = wfc(pdataframe, "Data")
5573 local spacing = input.consoleon and 30 or 25
5574 local function organize()
5575 local pp = game:GetService("Players"):GetPlayers()
5576 for i = 1, #pp do
5577 local v = pp[i]
5578 local rightparent = v.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5579 local wrongparent = v.TeamColor ~= game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5580 local right = ffc(rightparent, v.Name)
5581 local wrong = ffc(wrongparent, v.Name)
5582 if not right and wrong then
5583 wrong.Parent = rightparent
5584 end
5585 end
5586 local gd = ghostdata:GetChildren()
5587 table.sort(gd, function(a, b)
5588 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
5589 end)
5590 for i = 1, #gd do
5591 local v = gd[i]
5592 v.Position = ud2(0, 0, 0, i * spacing)
5593 if v.Name == player.Name then
5594 v.Username.TextColor3 = color(1, 1, 0)
5595 end
5596 end
5597 ghostdata.Parent.CanvasSize = ud2(0, 0, 0, (#gd + 1) * spacing)
5598 local pd = phantomdata:GetChildren()
5599 table.sort(pd, function(a, b)
5600 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
5601 end)
5602 for i = 1, #pd do
5603 local v = pd[i]
5604 v.Position = ud2(0, 0, 0, i * spacing)
5605 if v.Name == player.Name then
5606 v.Username.TextColor3 = color(1, 1, 0)
5607 end
5608 end
5609 phantomdata.Parent.CanvasSize = ud2(0, 0, 0, (#pd + 1) * spacing)
5610 end
5611 local function addplayer(guy)
5612 local gbar = ffc(ghostdata, guy.Name)
5613 local pbar = ffc(phantomdata, guy.Name)
5614 if gbar or pbar then
5615 return
5616 end
5617 local bar = playerstat:Clone()
5618 bar.Name = guy.Name
5619 bar.Username.Text = guy.Name
5620 bar.Kills.Text = 0
5621 bar.Deaths.Text = 0
5622 bar.Streak.Text = 0
5623 bar.Score.Text = 0
5624 bar.Kdr.Text = 0
5625 bar.Rank.Text = 0
5626 if guy == player then
5627 bar.Username.TextColor3 = color(1, 1, 0)
5628 end
5629 bar.Parent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5630 organize()
5631 end
5632 local function removeplayer(guy)
5633 local gbar = ffc(ghostdata, guy.Name)
5634 local pbar = ffc(phantomdata, guy.Name)
5635 if gbar then
5636 trash.remove(gbar)
5637 end
5638 if pbar then
5639 trash.remove(pbar)
5640 end
5641 organize()
5642 end
5643 local function updatestats(guy, data)
5644 local rightparent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
5645 local bar = ffc(rightparent, guy.Name)
5646 if not bar then
5647 organize()
5648 bar = ffc(rightparent, guy.Name)
5649 end
5650 if bar then
5651 for i, v in next, data, nil do
5652 bar[i].Text = v
5653 end
5654 end
5655 organize()
5656 end
5657 function leaderboard:show()
5658 main.Visible = true
5659 end
5660 function leaderboard:hide()
5661 main.Visible = false
5662 end
5663 network:add("removeplayer", removeplayer)
5664 network:add("newplayer", addplayer)
5665 network:add("updatestats", updatestats)
5666 organize()
5667 game:GetService("UserInputService").InputBegan:connect(function(keycode)
5668 local key = keycode.KeyCode
5669 if key == Enum.KeyCode.Tab and not input.iskeydown(Enum.KeyCode.LeftAlt) then
5670 if main.Visible then
5671 leaderboard:hide()
5672 else
5673 organize()
5674 leaderboard:show()
5675 end
5676 end
5677 end)
5678end
5679do
5680 local nv = Vector3.new()
5681 local dot = nv.Dot
5682 local minposroot = physics.minposroot
5683 local solve = physics.solve
5684 local playerservice = game:GetService("Players")
5685 local localplayer = playerservice.LocalPlayer
5686 local ts = {}
5687 local pps = {}
5688 local function getpva(ts, ps)
5689 local t = tick()
5690 local t1, t2, t3 = ts[1] - t, ts[2] - t, ts[3] - t
5691 local p1, p2, p3 = ps[1], ps[2], ps[3]
5692 if t3 and p3 then
5693 local d12 = t1 - t2
5694 local d23 = t2 - t3
5695 local d31 = t3 - t1
5696 local div = -d12 * d23 * d31
5697 local pnum = t2 * t3 * d23 * p1 + t1 * t3 * d31 * p2 + t1 * t2 * d12 * p3
5698 local vnum = (t3 * t3 - t2 * t2) * p1 + (t1 * t1 - t3 * t3) * p2 + (t2 * t2 - t1 * t1) * p3
5699 local anum = 2 * d23 * p1 + 2 * d31 * p2 + 2 * d12 * p3
5700 return pnum / div, vnum / div, anum / div
5701 elseif t2 and p2 then
5702 local div = t1 - t2
5703 local pnum = t1 * p2 - t2 * p1
5704 local vnum = p1 - p2
5705 return pnum / div, vnum / div, nv
5706 elseif t1 and p1 then
5707 return p1, nv, nv
5708 else
5709 return nv, nv, nv
5710 end
5711 end
5712 local function getcpoint(bp, bv, ba, tp, tv, ta)
5713 local rp = tp - bp
5714 local rv = tv - bv
5715 local ra = ta - ba
5716 local a0 = 2 * dot(rp, rv)
5717 local a1 = 2 * (dot(ra, rp) + dot(rv, rv))
5718 local a2 = 3 * dot(ra, rv)
5719 local a3 = dot(ra, ra)
5720 local t = minposroot(a3, a2, a1, a0)
5721 if t then
5722 local bpoint = bp + t * bv + t * t / 2 * ba
5723 local tpoint = tp + t * tv + t * t / 2 * ta
5724 local dist = (tpoint - bpoint).magnitude
5725 return t, dist, bpoint, tpoint
5726 end
5727 end
5728 function simpletraj(s, a, r)
5729 local a0 = 4 * dot(r, r)
5730 local a1 = -4 * (dot(a, r) + s * s)
5731 local a2 = dot(a, a)
5732 local u = minposroot(a2, a1, a0)
5733 if u then
5734 local t = u ^ 0.5
5735 return r / t - t / 2 * a
5736 end
5737 end
5738 function aimassist.edit(ratio, bp, bv, ba)
5739 local bestdist = 1 / 0
5740 local bestvalue = 0
5741 local bestt, bestbpoint, besttpoint
5742 for part, ps in next, pps, nil do
5743 local radius = ps.radius
5744 local value = ps.value
5745 local tp, tv, ta = getpva(ts, ps)
5746 local t, dist, bpoint, tpoint = getcpoint(bp, bv, ba, tp, tv, nv)
5747 if t then
5748 local ayy = (tp - bp).magnitude
5749 local maxdist = ayy * ratio * radius / (ayy + ratio * radius)
5750 if dist < maxdist and bestdist > dist and bestvalue < value then
5751 bestvalue = value
5752 bestdist = dist
5753 bestt = t
5754 bestbpoint = bpoint
5755 besttpoint = tpoint
5756 end
5757 end
5758 end
5759 if bestt then
5760 local tp = bestbpoint / ratio + (1 - 1 / ratio) * besttpoint
5761 local newv = bv + (tp - bestbpoint) / bestt
5762 return newv
5763 else
5764 return bv
5765 end
5766 end
5767 function aimassist.step()
5768 ts[1], ts[2], ts[3] = tick(), ts[1], ts[2]
5769 local players = playerservice:GetPlayers()
5770 local phash = {}
5771 for i, v in next, players, nil do
5772 local char = v.Character
5773 if char and v ~= localplayer then
5774 local head = char:FindFirstChild("Head")
5775 local torso = char:FindFirstChild("Torso")
5776 if head then
5777 phash[head] = true
5778 local ps = pps[head]
5779 if not ps then
5780 ps = {}
5781 ps.radius = 0.5
5782 ps.value = 100
5783 pps[head] = ps
5784 end
5785 ps[1], ps[2], ps[3] = head.Position, ps[1], ps[2]
5786 end
5787 if torso then
5788 phash[torso] = true
5789 local ps = pps[torso]
5790 if not ps then
5791 ps = {}
5792 ps.radius = 2
5793 ps.value = 50
5794 pps[torso] = ps
5795 end
5796 ps[1], ps[2], ps[3] = torso.CFrame * Vector3.new(0, -0.5, 0), ps[1], ps[2]
5797 end
5798 end
5799 end
5800 for i, v in next, pps, nil do
5801 if not phash[i] then
5802 pps[i] = nil
5803 end
5804 end
5805 end
5806end
5807print("Loading char module")
5808do
5809 local rtype = game.IsA
5810 local next = next
5811 local new = Instance.new
5812 local wfc = game.WaitForChild
5813 local ffc = game.FindFirstChild
5814 local getchildren = game.GetChildren
5815 local workspace = game.Workspace
5816 local cf = CFrame.new
5817 local vtws = CFrame.new().vectorToWorldSpace
5818 local angles = CFrame.Angles
5819 local nc = cf()
5820 local v3 = Vector3.new
5821 local nv = v3()
5822 local ray = Ray.new
5823 local raycast = workspace.FindPartOnRayWithIgnoreList
5824 local debris = game.Debris
5825 local dot = nv.Dot
5826 local ud2 = UDim2.new
5827 local abs = math.abs
5828 local tos = cf().toObjectSpace
5829 local player = game:GetService("Players").LocalPlayer
5830 local pgui = player.PlayerGui
5831 local repstore = game.ReplicatedStorage
5832 local repchar = repstore.Character
5833 local attmodels = repstore.AttachmentModels
5834 local character, humanoid, rootpart, rootjoint, statsloaded
5835 local thread = sequencer.new()
5836 local weapon
5837 local aiming = false
5838 local auto = false
5839 local burst = 0
5840 local reloading = false
5841 local sprinting = false
5842 local animating = false
5843 local stability = 0
5844 local basewalkspeed = 14
5845 local sprintspring = physics.spring.new()
5846 local climbing = physics.spring.new()
5847 local aimspring = physics.spring.new()
5848 local swingspring = physics.spring.new(nv)
5849 local speedspring = physics.spring.new()
5850 local velocityspring = physics.spring.new(nv)
5851 local pronespring = physics.spring.new(0)
5852 local truespeedspring = physics.spring.new(0)
5853 local equipspring = physics.spring.new(1)
5854 local muzzlespring = physics.spring.new(0)
5855 local walkspeedmult = 1
5856 sprintspring.s = 12
5857 sprintspring.d = 0.9
5858 climbing.s = 12
5859 climbing.d = 0.9
5860 aimspring.d = 0.9
5861 swingspring.s = 10
5862 swingspring.d = 0.75
5863 speedspring.s = 16
5864 velocityspring.s = 16
5865 pronespring.s = 8
5866 truespeedspring.s = 8
5867 equipspring.s = 12
5868 equipspring.d = 0.75
5869 local ignore = {
5870 workspace.Ignore,
5871 game.Workspace.CurrentCamera
5872 }
5873 local backwardsmult = 0.8
5874 local bodyforce = new("BodyVelocity")
5875 bodyforce.Name = "\n"
5876 local muzzlelight, walkspeedspring, headheightspring, updatewalkspeed
5877 walkspeedspring = physics.spring.new(basewalkspeed)
5878 walkspeedspring.s = 8
5879 headheightspring = physics.spring.new(1.5)
5880 headheightspring.s = 8
5881 char.acceleration = nv
5882 bodyforce.MaxForce = nv
5883 do
5884 local movementmode = "stand"
5885 local down = v3(0, -4, 0)
5886 function updatewalkspeed()
5887 if sprinting then
5888 walkspeedspring.t = 1.4 * walkspeedmult * basewalkspeed
5889 elseif movementmode == "prone" then
5890 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
5891 elseif movementmode == "crouch" then
5892 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
5893 elseif movementmode == "stand" then
5894 walkspeedspring.t = walkspeedmult * basewalkspeed
5895 end
5896 end
5897 local function setmovementmode(self, mode, dive)
5898 local oldmode = char.movementmode
5899 char.movementmode = mode
5900 movementmode = mode
5901 if mode == "prone" then
5902 if not dive and oldmode ~= mode then
5903 sound.play("stanceProne", 0.15)
5904 end
5905 headheightspring.t = -1.5
5906 pronespring.t = 1
5907 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
5908 hud:setcrossscale(0.5)
5909 stability = 0.25
5910 if dive and sprinting and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
5911 spawn(function()
5912 local lkvector = rootpart.CFrame.lookVector
5913 rootpart.Velocity = lkvector * 50 + v3(0, 40, 0)
5914 wait(0.1)
5915 rootpart.Velocity = lkvector * 60 + v3(0, 30, 0)
5916 wait(0.4)
5917 rootpart.Velocity = lkvector * 20 + v3(0, -10, 0)
5918 end)
5919 end
5920 elseif mode == "crouch" then
5921 if not dive and oldmode ~= mode then
5922 sound.play("stanceStandCrouch", 0.15)
5923 end
5924 headheightspring.t = 0
5925 pronespring.t = 0
5926 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
5927 hud:setcrossscale(0.75)
5928 stability = 0.15
5929 if dive and sprinting and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
5930 isSliding = true
5931 sound.play("slideStart", 0.25)
5932 spawn(function()
5933 local lkvector = rootpart.CFrame.lookVector
5934 local released
5935 bodyforce.MaxForce = v3(40000, 10, 40000)
5936 for i = 1, 20 do
5937 if input.keyboard.down.leftshift then
5938 lkvector = rootpart.CFrame.lookVector
5939 end
5940 bodyforce.Velocity = lkvector * (40 - i * 1.5) + v3(0, 0, 0)
5941 wait(0.03333333333333333)
5942 end
5943 bodyforce.MaxForce = nv
5944 if isSliding then
5945 isSliding = false
5946 sound.play("slideEnd", 0.15)
5947 end
5948 end)
5949 end
5950 elseif mode == "stand" then
5951 if oldmode ~= mode then
5952 sound.play("stanceStandCrouch", 0.15)
5953 end
5954 headheightspring.t = 1.5
5955 pronespring.t = 0
5956 walkspeedspring.t = walkspeedmult * basewalkspeed
5957 hud:setcrossscale(1)
5958 stability = 0
5959 end
5960 network:bounce("s" .. "t" .. "a" .. "n" .. "c" .. "e", player, mode)
5961 sprinting = false
5962 network:bounce("s" .. "p" .. "r" .. "i" .. "n" .. "t", player, sprinting)
5963 sprintspring.t = 0
5964 end
5965 function char.getstate()
5966 return humanoid:GetState()
5967 end
5968 function char:sprinting()
5969 return sprinting
5970 end
5971 char.setmovementmode = setmovementmode
5972 function char:setbasewalkspeed(newspeed)
5973 basewalkspeed = newspeed
5974 updatewalkspeed()
5975 end
5976 function char:setsprint(on)
5977 if on then
5978 if isSliding then
5979 isSliding = false
5980 sound.play("slideEnd", 0.15)
5981 end
5982 setmovementmode(nil, "stand")
5983 sprinting = true
5984 network:bounce("s" .. "p" .. "r" .. "i" .. "n" .. "t", player, sprinting)
5985 auto = false
5986 burst = 0
5987 if weapon and aiming and weapon.type ~= "KNIFE" then
5988 weapon:setaim(false)
5989 end
5990 walkspeedmult = 1
5991 if not reloading and not animating then
5992 sprintspring.t = 1
5993 end
5994 walkspeedspring.t = 1.5 * walkspeedmult * basewalkspeed
5995 elseif sprinting then
5996 sprinting = false
5997 network:bounce("s" .. "p" .. "r" .. "i" .. "n" .. "t", player, sprinting)
5998 sprintspring.t = 0
5999 walkspeedspring.t = walkspeedmult * basewalkspeed
6000 end
6001 end
6002 local function parkour()
6003 if weapon then
6004 weapon:playanimation("parkour")
6005 end
6006 sound.play("parkour", 0.25)
6007 local bp = new("BodyPosition")
6008 bp.Name = "\n"
6009 bp.position = rootpart.Position + rootpart.CFrame.lookVector.unit * char.speed * 1.5 + v3(0, 10, 0)
6010 bp.maxForce = v3(5000000000, 500000000, 500000000)
6011 bp.P = 4000
6012 bp.Parent = rootpart
6013 debris:AddItem(bp, 0.45)
6014 end
6015 function char:jump(height, numjumps)
6016 local rootcf = rootpart.CFrame
6017 local isonground = raycast(workspace, ray(rootcf.p, vtws(rootcf, down)), {
6018 workspace.CurrentCamera
6019 })
6020 if eventmod.ison() and numjumps or isonground then
6021 if movementmode == "prone" or movementmode == "crouch" then
6022 setmovementmode(nil, "stand")
6023 elseif not reloading and not aiming and not char.grenadehold then
6024 local r1 = ray(rootpart.CFrame.p + v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 + v3(0, 2, 0))
6025 local h1, e1 = raycast(workspace, r1, {
6026 character,
6027 camera.currentcamera
6028 })
6029 local r2 = ray(rootpart.CFrame.p - v3(0, 1, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1, 0))
6030 local h2, e2 = raycast(workspace, r2, {
6031 character,
6032 camera.currentcamera
6033 })
6034 local r3 = ray(rootpart.CFrame.p - v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1.5, 0))
6035 local h3, e3 = raycast(workspace, r3, {
6036 character,
6037 camera.currentcamera
6038 })
6039 if h3 and (e3 - e2).Magnitude < 0.7 and (e3 - e1).Magnitude > 4 and (e3 - rootpart.Position).Magnitude < char.speed / 1.5 then
6040 parkour(h3)
6041 delay(0.1, function()
6042 gamelogic.resetjumps()
6043 end)
6044 elseif eventmod.ison() then
6045 if numjumps == 1 then
6046 bodyforce.Velocity = v3(rootpart.Velocity.X, height and (392.4 * height * loltimescale) ^ 0.5 or 200, rootpart.Velocity.Z)
6047 bodyforce.MaxForce = v3(999999, 999999, 999999)
6048 delay(0.1, function()
6049 bodyforce.MaxForce = nv
6050 end)
6051 else
6052 bodyforce.Velocity = rootpart.Velocity + v3(0, height and (392.4 * height * loltimescale) ^ 0.5 or 40, 0)
6053 bodyforce.MaxForce = v3(999999, 999999, 999999)
6054 delay(0.1, function()
6055 bodyforce.MaxForce = nv
6056 end)
6057 end
6058 else
6059 rootpart.Velocity = rootpart.Velocity + v3(0, height and (392.4 * height * loltimescale) ^ 0.5 or 40, 0)
6060 end
6061 elseif eventmod.ison() then
6062 if numjumps == 1 then
6063 bodyforce.Velocity = v3(rootpart.Velocity.X, height and (392.4 * height * loltimescale) ^ 0.5 or 200, rootpart.Velocity.Z)
6064 bodyforce.MaxForce = v3(999999, 999999, 999999)
6065 delay(0.1, function()
6066 bodyforce.MaxForce = nv
6067 end)
6068 else
6069 bodyforce.Velocity = rootpart.Velocity + v3(0, height and (392.4 * height * loltimescale) ^ 0.5 or 40, 0)
6070 bodyforce.MaxForce = v3(999999, 999999, 999999)
6071 delay(0.1, function()
6072 bodyforce.MaxForce = nv
6073 end)
6074 end
6075 else
6076 rootpart.Velocity = rootpart.Velocity + v3(0, height and (392.4 * height * loltimescale) ^ 0.5 or 40, 0)
6077 end
6078 end
6079 end
6080 end
6081 local equipping = false
6082 local zooming = false
6083 local rweld, lweld, larm, rarm, lmodel, rmodel, lmain, rmain
6084 local sin = math.sin
6085 local cos = math.cos
6086 char.grenadehold = false
6087 local function gunbob(a, r)
6088 local a, r = a or 1, r or 1
6089 local d, s, v = char.distance * 6.28318 * 3 / 4, char.speed, -char.velocity
6090 if s < basewalkspeed then
6091 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
6092 return cf(r * cos(d / 8 - 1) * s / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6093 else
6094 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)
6095 return cf(r * cos(d / 8 - 1) * (5 * s - 56) / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6096 end
6097 end
6098 local function gunsway(a)
6099 local d, s = tick() * 6, 2 * (1.2 - a)
6100 return cf(cos(d / 8) * s / 128, -sin(d / 4) * s / 128, sin(d / 16) * s / 64)
6101 end
6102 local asdf = function()
6103 end
6104 local function weldattachment(gun, type, attname, menunode, mainpart, attdata, welddata, menunodes)
6105 local refmodel = ffc(attmodels, attname)
6106 local copies = attdata.copy or 0
6107 local slottag
6108 if refmodel then
6109 for i = 0, copies do
6110 local model = refmodel:Clone()
6111 local attnode = model.Node
6112 local weldcframes = {}
6113 local maincf = attnode.CFrame
6114 local parts = getchildren(model)
6115 for i = 1, #parts do
6116 local v = parts[i]
6117 if v:IsA("BasePart") then
6118 weldcframes[v] = tos(maincf, v.CFrame)
6119 end
6120 end
6121 attnode.CFrame = i == 0 and menunode.CFrame or menunodes[attdata.copynodes[i]].CFrame
6122 if type == "Optics" then
6123 local del = gun:GetChildren()
6124 for i = 1, #del do
6125 if del[i].Name == "Iron" or del[i].Name == "IronGlow" or del[i].Name == "SightMark" and not ffc(del[i], "Stay") then
6126 del[i]:Destroy()
6127 end
6128 end
6129 elseif type == "Underbarrel" then
6130 local del = gun:GetChildren()
6131 for i = 1, #del do
6132 if del[i].Name == "Grip" then
6133 slottag = ffc(del[i], "Slot1") or ffc(del[i], "Slot2")
6134 del[i]:Destroy()
6135 end
6136 end
6137 end
6138 if attdata.replacemag then
6139 local del = gun:GetChildren()
6140 for x = 1, #del do
6141 if i == 0 and del[x].Name == "Mag" or i > 0 and del[x].Name == "Mag" .. i + 1 then
6142 del[x]:Destroy()
6143 end
6144 end
6145 end
6146 for x = 1, #parts do
6147 local v = parts[x]
6148 if v:IsA("BasePart") then
6149 local weld, c0
6150 if v ~= attnode then
6151 c0 = tos(mainpart.CFrame, attnode.CFrame)
6152 weld = new("Weld", mainpart)
6153 weld.Part0 = mainpart
6154 weld.Part1 = v
6155 weld.C0 = c0 * weldcframes[v]
6156 end
6157 if slottag and v:IsA("UnionOperation") then
6158 slottag:Clone().Parent = v
6159 end
6160 if attdata.replacemag and v.Name == "AttMag" then
6161 local magname = i == 0 and "Mag" or i > 0 and "Mag" .. i + 1
6162 v.Name = magname
6163 welddata[magname] = {
6164 part = v,
6165 weld = weld,
6166 basec0 = c0 * weldcframes[v],
6167 basetransparency = v.Transparency
6168 }
6169 end
6170 v.Anchored = false
6171 v.CanCollide = false
6172 v.Parent = gun
6173 end
6174 end
6175 attnode:Destroy()
6176 model:Destroy()
6177 end
6178 end
6179 return slottag
6180 end
6181 local function texturemodel(root, model)
6182 local bcolor = BrickColor.new
6183 for i, part in next, model:GetChildren() do
6184 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6185 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6186 if slottag then
6187 for x, y in next, part:GetChildren() do
6188 if y:IsA("Texture") then
6189 y:Destroy()
6190 end
6191 end
6192 if root[slottag.Name].Name ~= "" then
6193 if not effects.disable1pcamoskins then
6194 local t = Instance.new("Texture")
6195 t.Name = slottag.Name
6196 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6197 t.Transparency = part.Transparency == 1 and 1 or root[slottag.Name].TextureProperties.Transparency
6198 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
6199 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
6200 if root[slottag.Name].TextureProperties.Color then
6201 local colordata = root[slottag.Name].TextureProperties.Color
6202 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6203 end
6204 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
6205 local tt = t:Clone()
6206 tt.Face = x
6207 tt.Parent = part
6208 end
6209 t:Destroy()
6210 end
6211 if not root[slottag.Name].BrickProperties.DefaultColor then
6212 if part:IsA("UnionOperation") then
6213 part.UsePartColor = true
6214 end
6215 local colordata = root[slottag.Name].BrickProperties.Color
6216 if colordata then
6217 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6218 else
6219 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
6220 end
6221 end
6222 if root[slottag.Name].BrickProperties.Material then
6223 part.Material = root[slottag.Name].BrickProperties.Material
6224 end
6225 end
6226 end
6227 elseif part:IsA("Model") then
6228 texturemodel(root, part)
6229 end
6230 end
6231 end
6232 local tos = CFrame.new().toObjectSpace
6233 local mpgunmodels = game.ReplicatedStorage.MeshPartGunModels
6234 local function weldmodel(model, mainpart, attachlist, data, camodata)
6235 local welddata = {}
6236 local parts = model:GetChildren()
6237 local maincf = mainpart.CFrame
6238 local menunodes = ffc(model, "MenuNodes")
6239 local meshpartmap = {}
6240 local mpmodel = ffc(mpgunmodels, model.Name)
6241 if mpmodel then
6242 for i, v in next, mpmodel:GetChildren() do
6243 if v:IsA("MeshPart") then
6244 meshpartmap[v.MeshId] = v
6245 end
6246 end
6247 end
6248 for i = 1, #parts do
6249 local part = parts[i]
6250 if part ~= mainpart and part:IsA("BasePart") then
6251 local name = part.Name
6252 if ffc(part, "Mesh") then
6253 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6254 if slottag and camodata[slottag.Name].BrickProperties.EnableMaterial then
6255 local mpart = meshpartmap[part.Mesh.MeshId]:Clone()
6256 mpart.Parent = model
6257 mpart.Name = name
6258 mpart.CFrame = part.CFrame
6259 part:Destroy()
6260 part = mpart
6261 end
6262 end
6263 if data and data.weldexception and data.weldexception[name] and ffc(model, data.weldexception[name]) then
6264 local nbase = model[data.weldexception[name]]
6265 local nmaincf = nbase.CFrame
6266 local c0 = tos(nmaincf, part.CFrame)
6267 local weld = new("Weld", nbase)
6268 weld.Part0 = nbase
6269 weld.Part1 = part
6270 weld.C0 = c0
6271 welddata[name] = {
6272 part = part,
6273 weld = weld,
6274 basec0 = c0,
6275 basetransparency = part.Transparency
6276 }
6277 else
6278 local c0 = tos(maincf, part.CFrame)
6279 local weld = new("Weld", mainpart)
6280 weld.Part0 = mainpart
6281 weld.Part1 = part
6282 weld.C0 = c0
6283 welddata[name] = {
6284 part = part,
6285 weld = weld,
6286 basec0 = c0,
6287 basetransparency = part.Transparency
6288 }
6289 end
6290 part.Anchored = false
6291 part.CanCollide = false
6292 end
6293 end
6294 if menunodes and #menunodes:GetChildren() > 1 then
6295 local nodes = menunodes:GetChildren()
6296 for i = 1, #nodes do
6297 local v = nodes[i]
6298 local c0 = tos(maincf, v.CFrame)
6299 local weld = new("Weld", mainpart)
6300 weld.Part0 = mainpart
6301 weld.Part1 = v
6302 weld.C0 = c0
6303 v.Anchored = false
6304 v.CanCollide = false
6305 end
6306 for i, v in next, attachlist, nil do
6307 if i ~= "Name" and v and v ~= "" then
6308 local attachdata = data.attachments and data.attachments[i][v] or {}
6309 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
6310 local mountweldpart = attachdata.mountweldpart and model[attachdata.mountweldpart] or mainpart
6311 local node = attachdata.node and menunodes[attachdata.node]
6312 if sidemount then
6313 local basenode = sidemount.Node
6314 local mountnode = attachdata.mountnode and menunodes[attachdata.mountnode] or i == "Optics" and menunodes.MountNode or i == "Underbarrel" and menunodes.UnderMountNode
6315 local mountcframes = {}
6316 local mchildren = sidemount:GetChildren()
6317 local basecframe = basenode.CFrame
6318 for i = 1, #mchildren do
6319 if mchildren[i]:IsA("BasePart") then
6320 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
6321 end
6322 end
6323 basenode.CFrame = mountnode.CFrame
6324 for x = 1, #mchildren do
6325 local p = mchildren[x]
6326 if p:IsA("BasePart") then
6327 local c0 = tos(mountweldpart.CFrame, basenode.CFrame)
6328 if p ~= basenode then
6329 local weld = new("Weld", mainpart)
6330 weld.Part0 = mountweldpart
6331 weld.Part1 = p
6332 weld.C0 = c0 * mountcframes[x]
6333 p.CFrame = basenode.CFrame * mountcframes[x]
6334 end
6335 p.Anchored = false
6336 p.CanCollide = false
6337 p.Parent = model
6338 if p.Name == i .. "Node" and not node then
6339 node = p
6340 elseif p.Name == "SightMark" then
6341 local stay = new("Model", p)
6342 stay.Name = "Stay"
6343 end
6344 end
6345 end
6346 basenode.Parent = menunodes
6347 sidemount:Destroy()
6348 else
6349 node = attachdata.node and menunodes[attachdata.node] or menunodes[i .. "Node"]
6350 end
6351 local weldpart = attachdata.weldpart and model[attachdata.weldpart] or mainpart
6352 weldattachment(model, i, v, node, weldpart, attachdata, welddata, menunodes)
6353 end
6354 end
6355 menunodes:Destroy()
6356 end
6357 texturemodel(camodata, model)
6358 welddata.camodata = camodata
6359 mainpart.Anchored = false
6360 mainpart.CanCollide = false
6361 return welddata
6362 end
6363 local clone = game.Clone
6364 local currentcamera = game.Workspace.CurrentCamera
6365 local ffc = game.FindFirstChild
6366 function char:loadarms(newlarm, newrarm, newlmain, newrmain)
6367 currentcamera = game.Workspace.CurrentCamera
6368 larm, rarm, lmain, rmain = newlarm, newrarm, newlmain, newrmain
6369 lmodel = clone(larm, weapon and currentcamera)
6370 rmodel = clone(rarm, weapon and currentcamera)
6371 local lmainpart = lmodel[newlmain]
6372 local rmainpart = rmodel[newrmain]
6373 rweld = new("Motor6D")
6374 lweld = new("Motor6D")
6375 weldmodel(lmodel, lmainpart)
6376 weldmodel(rmodel, rmainpart)
6377 lweld.Part0 = rootpart
6378 lweld.Part1 = lmainpart
6379 lweld.Parent = lmainpart
6380 rweld.Part0 = rootpart
6381 rweld.Part1 = rmainpart
6382 rweld.Parent = rmainpart
6383 end
6384 function char:reloadsprings()
6385 sprintspring = physics.spring.new()
6386 aimspring = physics.spring.new()
6387 swingspring = physics.spring.new(nv)
6388 speedspring = physics.spring.new()
6389 velocityspring = physics.spring.new(nv)
6390 pronespring = physics.spring.new(0)
6391 truespeedspring = physics.spring.new(0)
6392 equipspring = physics.spring.new(1)
6393 muzzlespring = physics.spring.new(0)
6394 equipspring.s = 12
6395 equipspring.d = 0.75
6396 sprintspring.s = 12
6397 sprintspring.d = 0.9
6398 aimspring.d = 0.9
6399 swingspring.s = 10
6400 swingspring.d = 0.75
6401 speedspring.s = 16
6402 velocityspring.s = 16
6403 pronespring.s = 8
6404 truespeedspring.s = 8
6405 muzzlespring.s = 50
6406 muzzlespring.d = 1
6407 walkspeedspring = physics.spring.new(basewalkspeed)
6408 walkspeedspring.s = 8
6409 headheightspring = physics.spring.new(1.5)
6410 headheightspring.s = 8
6411 if muzzlelight then
6412 muzzlelight:Destroy()
6413 end
6414 muzzlelight = repstore.Effects.MuzzleLight:Clone()
6415 muzzlelight.Parent = rootpart
6416 end
6417 local aimbotshit = {}
6418 do
6419 local function reweld(welddata)
6420 for i, v in next, welddata, nil do
6421 if v.clone then
6422 welddata[i] = nil
6423 trash.remove(v.weld)
6424 trash.remove(v.part)
6425 else
6426 v.weld.C0 = v.basec0
6427 if v.part then
6428 v.part.Transparency = v.basetransparency
6429 end
6430 end
6431 end
6432 end
6433 local rand = math.random
6434 local ffc = game.FindFirstChild
6435 local function pickv3(v0, v1)
6436 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
6437 end
6438 function char:firemuzzlelight()
6439 muzzlespring:accelerate(100)
6440 end
6441 function char:loadgrenade(data, model, spare)
6442 local self = {}
6443 local thread2 = sequencer.new()
6444 local ignorelist = ignore
6445 local dunhit = {}
6446 local main = data.mainpart
6447 local mainoffset = data.mainoffset
6448 local mainpart = model[main]
6449 local pin = model[data.pin]
6450 local lever = model[data.lever]
6451 local ammo = spare or data.spare
6452 local lastweapon = weapon
6453 local equipped = false
6454 local throwing = false
6455 local cooking = false
6456 local exploded = false
6457 local bounceelasticity = 0.2
6458 local frictionconstant = 0.08
6459 local acceleration = v3(0, -80, 0)
6460 local velocity = v3()
6461 local position = v3()
6462 local cooktime = 0
6463 local blowup = 0
6464 local t0 = 0
6465 local lastbounce = false
6466 local lasttrailt = 0
6467 local lasttrailpos = v3()
6468 local rot0
6469 local offset = v3()
6470 local av0, flyingnade, indicator
6471 local fusetime = data.fusetime
6472 local blastradius = data.blastradius
6473 local throwspeed = data.throwspeed
6474 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
6475 local animdata = weldmodel(model, mainpart)
6476 local mainweld = new("Motor6D", mainpart)
6477 animdata[main] = {
6478 weld = {C0 = nc},
6479 basec0 = nc
6480 }
6481 animdata.larm = {
6482 weld = {
6483 C0 = data.larmoffset
6484 },
6485 basec0 = data.larmoffset
6486 }
6487 animdata.rarm = {
6488 weld = {
6489 C0 = data.rarmoffset
6490 },
6491 basec0 = data.rarmoffset
6492 }
6493 mainweld.Part0 = rootpart
6494 mainweld.Part1 = mainpart
6495 local equipcf = data.equipoffset
6496 local sprintcf = cframe.interpolator(data.sprintoffset)
6497 local pronecf = cframe.interpolator(data.proneoffset)
6498 self.type = data.type
6499 self.cooking = cooking
6500 function self:setequipped(on)
6501 if on and (not equipped or not equipping) then
6502 if char.health <= 0 then
6503 return
6504 end
6505 aimbotshit.speed = throwspeed
6506 aimbotshit.accel = acceleration
6507 aimbotshit.addv = true
6508 char.grenadehold = true
6509 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, main)
6510 hud:updatefiremode("KNIFE")
6511 hud:updateammo("GRENADE")
6512 equipping = true
6513 thread:clear()
6514 if weapon then
6515 lastweapon = weapon
6516 weapon:setequipped(false)
6517 end
6518 thread:add(function()
6519 char:setbasewalkspeed(data.walkspeed)
6520 equipspring.t = 0
6521 equipping = false
6522 equipped = true
6523 local shit = mainpart:GetChildren()
6524 for i = 1, #shit do
6525 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
6526 shit[i]:Destroy()
6527 end
6528 end
6529 lmodel.Parent = currentcamera
6530 rmodel.Parent = currentcamera
6531 model.Parent = currentcamera
6532 weapon = self
6533 end)
6534 elseif not on and equipped then
6535 equipspring.t = 1
6536 thread:clear()
6537 thread:add(function()
6538 equipped = false
6539 lmodel.Parent = nil
6540 rmodel.Parent = nil
6541 model.Parent = nil
6542 animating = false
6543 weapon = nil
6544 end)
6545 thread:delay(0.5)
6546 end
6547 end
6548 local grenadeanim
6549 local castresolution = 0.016666666666666666
6550 local function createnade()
6551 if not (not roundsystem.lock and mainpart.Parent) or gamelogic.gammo <= 0 then
6552 return
6553 end
6554 gamelogic.gammo = gamelogic.gammo - 1
6555 hud:updateammo("GRENADE")
6556 local time = tick()
6557 trash.remove(mainweld)
6558 flyingnade = mainpart
6559 flyingnade.Parent = workspace.Ignore
6560 flyingnade.Anchored = true
6561 indicator = ffc(flyingnade, "Indicator")
6562 if indicator then
6563 indicator.Friendly.Visible = true
6564 end
6565 flyingnade.Trail.Enabled = true
6566 model.Parent = nil
6567 velocity = 0 < char.health and camera.lookvector * throwspeed + rootpart.Velocity or v3()
6568 position = char.deadcf and char.deadcf.p or flyingnade.CFrame.p
6569 lasttrailt = time
6570 lasttrailpos = position
6571 t0 = time
6572 av0 = (camera.cframe - camera.cframe.p) * v3(19.539, -5, 0)
6573 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
6574 local dt = castresolution
6575 local nadecf = flyingnade.CFrame
6576 grenadeanim = {
6577 curi = 1,
6578 time = time,
6579 blowuptime = blowup - time,
6580 frames = {
6581 {
6582 t0 = 0,
6583 p0 = position,
6584 v0 = velocity,
6585 offset = nv,
6586 a = acceleration,
6587 rot0 = nadecf - nadecf.p,
6588 rotv = av0,
6589 glassbreaks = {}
6590 }
6591 }
6592 }
6593 for i = 1, (blowup - time) / dt + 1 do
6594 local newposition = position + dt * velocity + dt * dt / 2 * acceleration
6595 local newvelocity = velocity + dt * acceleration
6596 local hit, pos, norm = raycast(workspace, ray(position, newposition - position - 0.05 * offset), ignorelist)
6597 local t = dt * i
6598 if hit and hit.Name ~= "Window" and hit.Name ~= "Col" then
6599 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
6600 offset = 0.2 * norm
6601 av0 = norm:Cross(velocity) / 0.2
6602 local delta = pos - position
6603 local fixpls = 1 - 0.001 / delta.magnitude
6604 fixpls = fixpls < 0 and 0 or fixpls
6605 position = position + fixpls * delta + 0.05 * norm
6606 local normvel = dot(norm, velocity) * norm
6607 local tanvel = velocity - normvel
6608 local geometricdeceleration
6609 local d1 = -dot(norm, acceleration)
6610 local d2 = -(1 + bounceelasticity) * dot(norm, velocity)
6611 geometricdeceleration = 1 - frictionconstant * (10 * (d1 < 0 and 0 or d1) * dt + (d2 < 0 and 0 or d2)) / tanvel.magnitude
6612 geometricdeceleration = geometricdeceleration < 0 and 0 or geometricdeceleration
6613 velocity = geometricdeceleration * tanvel - bounceelasticity * normvel
6614 if 1 > velocity.magnitude then
6615 local frames = grenadeanim.frames
6616 frames[#frames + 1] = {
6617 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
6618 p0 = position,
6619 v0 = nv,
6620 a = nv,
6621 rot0 = cframe.fromaxisangle(t * av0) * rot0,
6622 offset = 0.2 * norm,
6623 rotv = nv,
6624 glassbreaks = {}
6625 }
6626 break
6627 end
6628 local frames = grenadeanim.frames
6629 local nexti = #frames + 1
6630 frames[#frames + 1] = {
6631 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
6632 p0 = position,
6633 v0 = velocity,
6634 a = lastbounce and nv or acceleration,
6635 rot0 = cframe.fromaxisangle(t * av0) * rot0,
6636 offset = 0.2 * norm,
6637 rotv = av0,
6638 glassbreaks = {}
6639 }
6640 lastbounce = true
6641 else
6642 position = newposition
6643 velocity = newvelocity
6644 lastbounce = false
6645 if hit and hit.Name == "Window" then
6646 local frames = grenadeanim.frames
6647 local glassbreaks = frames[#frames].glassbreaks
6648 glassbreaks[#glassbreaks + 1] = {t = t, part = hit}
6649 end
6650 end
6651 end
6652 network:send("n" .. "e" .. "w" .. "g" .. "r" .. "e" .. "n" .. "a" .. "d" .. "e", data.name, grenadeanim)
6653 end
6654 function self:throw(dpos)
6655 if roundsystem.lock or gamelogic.gammo <= 0 then
6656 return
6657 end
6658 if cooking and not throwing then
6659 local time = tick()
6660 throwing = true
6661 cooking = false
6662 self.cooking = cooking
6663 exploded = false
6664 sprintspring.t = 0
6665 thread:add(animation.player(animdata, data.animations.throw))
6666 thread2:delay(0.07)
6667 thread2:add(function()
6668 createnade(dpos)
6669 if sprinting then
6670 sprintspring.t = 1
6671 end
6672 throwing = false
6673 end)
6674 thread:add(function()
6675 if lastweapon then
6676 lastweapon:setequipped(true)
6677 end
6678 end)
6679 end
6680 end
6681 function self:pull()
6682 local time = tick()
6683 if not cooking and not throwing then
6684 if animating then
6685 thread:add(animation.reset(animdata, 0.1))
6686 animating = false
6687 end
6688 thread:add(animation.player(animdata, data.animations.pull))
6689 thread:add(function()
6690 hud.crossspring:accelerate(data.crossexpansion)
6691 trash.remove(pin)
6692 cooking = true
6693 self.cooking = cooking
6694 cooktime = time + fusetime
6695 blowup = time + 5
6696 end)
6697 end
6698 end
6699 local function hitdetection(hit, dist, position)
6700 if hit.Parent then
6701 if ffc(game:GetService("Players"), hit.Parent.Name) and not dunhit[hit.Parent] and ffc(game:GetService("Players"), hit.Parent.Name) then
6702 local p = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
6703 if p.TeamColor ~= player.TeamColor or p == player then
6704 local wall, pos = raycast(workspace, ray(hit.Position, (hit.Position - position).unit * -dist), ignorelist)
6705 if not wall then
6706 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
6707 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, damage, (hit.Position - position).unit * 50)
6708 if p == player then
6709 p = nil
6710 end
6711 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", p, tick(), -damage, data.name, hit, position, {}, {}, hit.Position)
6712 dunhit[hit.Parent] = true
6713 hud:firehitmarker(hit.Name == "Head")
6714 end
6715 end
6716 elseif hit.Parent.Name == "Dead" then
6717 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, 100, (hit.Position - position).unit * 50)
6718 end
6719 end
6720 end
6721 local function explode(position)
6722 local player = game:GetService("Players").LocalPlayer
6723 local range = player:DistanceFromCharacter(position)
6724 if ffc(flyingnade, "Fire") then
6725 if range <= 50 then
6726 sound.play("fragClose", 2, 1, flyingnade, true)
6727 elseif range <= 200 then
6728 sound.play("fragMed", 3, 1, flyingnade, true)
6729 elseif range > 200 then
6730 sound.play("fragFar", 3, 1, flyingnade, true)
6731 end
6732 end
6733 exploded = true
6734 trash.remove(flyingnade)
6735 dunhit = {}
6736 if data.grenadetype == "Frag" then
6737 local boom = new("Explosion", workspace)
6738 boom.Position = position
6739 boom.BlastRadius = blastradius
6740 boom.BlastPressure = 0
6741 boom.DestroyJointRadiusPercent = 0
6742 boom.Hit:connect(function(hit, dist)
6743 hitdetection(hit, dist, position)
6744 end)
6745 elseif data.grenadetype == "Smoke" then
6746 elseif data.grenadetype == "Flash" then
6747 elseif data.grenadetype == "Flare" then
6748 elseif data.grenadetype == "Throwing" then
6749 end
6750 end
6751 local lasttime = tick()
6752 local lastparticle = tick()
6753 local disconnect
6754 disconnect = run.onstep:connect(function(dt)
6755 thread2.step()
6756 local time = tick()
6757 if cooking and not throwing then
6758 if time > cooktime or not input.keyboard.down.g then
6759 self:throw()
6760 elseif dt > (cooktime - time) % 1 then
6761 hud.crossspring:accelerate(data.crossexpansion)
6762 end
6763 end
6764 if flyingnade and grenadeanim then
6765 local st = grenadeanim.time
6766 local i = grenadeanim.curi
6767 local frames = grenadeanim.frames
6768 local frame = frames[i]
6769 local glassbreaks = frame.glassbreaks
6770 for j = 1, #glassbreaks do
6771 local glassbreak = glassbreaks[j]
6772 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
6773 effects:breakwindow(glassbreak.part, nil, nil, true, true)
6774 end
6775 end
6776 local nextframe = frames[i + 1]
6777 if nextframe and time > grenadeanim.time + nextframe.t0 then
6778 grenadeanim.curi = i + 1
6779 frame = nextframe
6780 end
6781 local t = time - (st + frame.t0)
6782 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
6783 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
6784 flyingnade.CFrame = rot + pos
6785 if indicator then
6786 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
6787 end
6788 if time > st + grenadeanim.blowuptime then
6789 explode(pos)
6790 disconnect()
6791 end
6792 end
6793 lasttime = time
6794 end)
6795 function self.step()
6796 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)
6797 mainweld.C0 = mainweldc0
6798 lweld.C0 = mainweldc0 * animdata.larm.weld.C0
6799 rweld.C0 = mainweldc0 * animdata.rarm.weld.C0
6800 if 0 >= char.health then
6801 self:setequipped(false)
6802 end
6803 end
6804 return self
6805 end
6806 function char:loadknife(data, model, camodata)
6807 local self = {}
6808 self.name = data.name
6809 self.type = data.type
6810 self.camodata = camodata
6811 local thread2 = sequencer.new()
6812 local ignorelist = {
6813 camera.currentcamera,
6814 character,
6815 workspace.Ignore
6816 }
6817 local dunhit = {}
6818 local main = data.mainpart
6819 local mainoffset = data.mainoffset
6820 local mainpart = model[main]
6821 local tip = model[data.tip]
6822 local blade = model[data.blade]
6823 local equipped = false
6824 local knifing = false
6825 local hitontick = 0
6826 local nexthit = 0
6827 local stabrate = 1000
6828 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
6829 local knifepart = mainpart:Clone()
6830 knifepart.Parent = model
6831 knifepart.Name = "Handle"
6832 local animdata = {}
6833 do
6834 local knifecf = knifepart.CFrame
6835 local kparts = model:GetChildren()
6836 local menunodes = ffc(model, "MenuNodes")
6837 for i = 1, #kparts do
6838 local part = kparts[i]
6839 if part:IsA("BasePart") then
6840 if part ~= knifepart and part ~= mainpart then
6841 local c0 = tos(knifecf, part.CFrame)
6842 local weld = new("Weld", knifepart)
6843 weld.Part0 = knifepart
6844 weld.Part1 = part
6845 weld.C0 = c0
6846 animdata[part.Name] = {
6847 part = part,
6848 weld = weld,
6849 basec0 = c0,
6850 basetransparency = part.Transparency
6851 }
6852 end
6853 part.Anchored = false
6854 part.CanCollide = false
6855 end
6856 end
6857 texturemodel(camodata, model)
6858 if menunodes then
6859 menunodes:Destroy()
6860 end
6861 end
6862 local knifeweld = new("Motor6D", knifepart)
6863 knifeweld.Part0 = rmodel.Arm
6864 knifeweld.Part1 = knifepart
6865 local mainweld = new("Motor6D", mainpart)
6866 animdata[main] = {
6867 weld = {C0 = nc},
6868 basec0 = nc
6869 }
6870 animdata.larm = {
6871 weld = {
6872 C0 = data.larmoffset
6873 },
6874 basec0 = data.larmoffset
6875 }
6876 animdata.rarm = {
6877 weld = {
6878 C0 = data.rarmoffset
6879 },
6880 basec0 = data.rarmoffset
6881 }
6882 animdata.knife = {
6883 weld = {
6884 C0 = data.knifeoffset
6885 },
6886 basec0 = data.knifeoffset
6887 }
6888 mainweld.Part0 = rootpart
6889 mainweld.Part1 = mainpart
6890 local equipcf = data.equipoffset
6891 local sprintcf = cframe.interpolator(data.sprintoffset)
6892 local pronecf = cframe.interpolator(data.proneoffset)
6893 local inspecting
6894 function self:destroy()
6895 model:Destroy()
6896 end
6897 function self:setequipped(on, quick, dead)
6898 if dead then
6899 model:Destroy()
6900 end
6901 if on and (not equipped or not equipping) then
6902 if char.health <= 0 then
6903 return
6904 end
6905 network:bounce("e" .. "q" .. "u" .. "i" .. "p" .. "k" .. "n" .. "i" .. "f" .. "e", player, data.name, camodata)
6906 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, main)
6907 hud:updatefiremode("KNIFE")
6908 hud:updateammo("KNIFE")
6909 sound.play("equipCloth", 0.25)
6910 sound.play(data.soundClassification .. "Equip", 0.25)
6911 equipping = true
6912 inspecting = false
6913 thread:clear()
6914 if weapon then
6915 weapon:setequipped(false)
6916 end
6917 thread:add(function()
6918 char:setbasewalkspeed(data.walkspeed)
6919 sprintspring.s = data.sprintspeed
6920 hud:setcrosssize(data.crosssize)
6921 if model then
6922 pcall(function()
6923 lmodel.Parent = currentcamera
6924 rmodel.Parent = currentcamera
6925 model.Parent = currentcamera
6926 if data.soundClassification == "saber" then
6927 sound.play("saberLoop", 0.25, 1, model, false, true)
6928 end
6929 end)
6930 end
6931 equipspring.s = quick and 32 or 16
6932 equipspring.t = 0
6933 equipped = true
6934 weapon = self
6935 equipping = false
6936 sound.play("equipCloth", 0.25)
6937 knifing = false
6938 char.grenadehold = false
6939 if sprinting then
6940 sprintspring.t = 1
6941 end
6942 stabrate = quick and 2000 or 1000
6943 end)
6944 if quick then
6945 thread:delay(0.05)
6946 thread:add(function()
6947 self:shoot(quick)
6948 end)
6949 end
6950 elseif not on and equipped then
6951 knifing = false
6952 inspecting = false
6953 equipspring.t = 1
6954 thread:add(animation.reset(animdata, 0.1))
6955 thread:add(function()
6956 equipped = false
6957 model.Parent = nil
6958 if model:FindFirstChild("Sound") then
6959 model.Sound:Destroy()
6960 end
6961 lmodel.Parent = nil
6962 rmodel.Parent = nil
6963 animating = false
6964 weapon = nil
6965 end)
6966 end
6967 end
6968 function self:inspecting()
6969 return inspecting
6970 end
6971 function self:playanimation(type)
6972 if not knifing and not equipping then
6973 thread:clear()
6974 if animating then
6975 thread:add(animation.reset(animdata, 0.05))
6976 end
6977 animating = true
6978 sprintspring.t = 0
6979 do
6980 local acceptlist = {}
6981 if type == "inspect" then
6982 inspecting = true
6983 elseif type == "spot" then
6984 end
6985 thread:add(animation.player(animdata, data.animations[type]))
6986 thread:add(function()
6987 thread:add(animation.reset(animdata, data.animations[type].resettime))
6988 animating = false
6989 thread:add(function()
6990 if sprinting then
6991 sprintspring.t = 1
6992 end
6993 inspecting = false
6994 end)
6995 if #acceptlist > 0 then
6996 end
6997 end)
6998 return #acceptlist > 0
6999 end
7000 end
7001 end
7002 function self:reloadcancel(inspect)
7003 if inspect then
7004 thread:clear()
7005 thread:add(animation.reset(animdata, 0.2))
7006 reloading = false
7007 animating = false
7008 thread:add(function()
7009 if input.mouse.down.right then
7010 self:setaim(true)
7011 end
7012 if sprinting then
7013 sprintspring.t = 1
7014 end
7015 end)
7016 end
7017 end
7018 function self:dropguninfo()
7019 return mainpart.Position
7020 end
7021 function self:shoot(quick, stype)
7022 if roundsystem.lock then
7023 return
7024 end
7025 if inspecting then
7026 self:reloadcancel(true)
7027 inspecting = false
7028 end
7029 if not knifing then
7030 do
7031 local springspeed = sprintspring.s
7032 local time = tick()
7033 network:bounce("s" .. "t" .. "a" .. "b", player)
7034 nexthit = time < nexthit and nexthit or time
7035 sprintspring.t = 0
7036 sprintspring.s = 50
7037 knifing = true
7038 reloading = true
7039 if animating then
7040 thread:add(animation.reset(animdata, 0.1))
7041 animating = false
7042 end
7043 local stabtype = quick and "quickstab" or stype or "stab1"
7044 sound.play(data.soundClassification, 0.25)
7045 hitontick = tick() + data.hitdelay[stabtype]
7046 dunhit = {}
7047 thread:add(animation.player(animdata, data.animations[stabtype]))
7048 thread:add(function()
7049 thread:add(animation.reset(animdata, data.animations[stabtype].resettime))
7050 end)
7051 if sprinting or stabtype == "quickstab" then
7052 thread:delay(data.animations[stabtype].resettime * 0.75)
7053 thread:add(function()
7054 if sprinting then
7055 sprintspring.t = 1
7056 end
7057 end)
7058 end
7059 thread:add(function()
7060 knifing = false
7061 sprintspring.s = springspeed
7062 reloading = false
7063 end)
7064 end
7065 end
7066 end
7067 local parts = {
7068 "head",
7069 "torso",
7070 "lleg",
7071 "rleg",
7072 "larm",
7073 "rarm"
7074 }
7075 local function knifehitdetection()
7076 local firepos = tip.Position
7077 local firepos2 = blade.Position
7078 local hit, pos, norm, dir
7079 local hitdist = 20
7080 for i, p in next, game:GetService("Players"):GetPlayers() do
7081 if p and p.TeamColor ~= player.TeamColor then
7082 local vchar = p.Character
7083 if vchar and vchar.Parent and not dunhit[vchar] then
7084 local phead = ffc(vchar, "Head")
7085 local ptorso = ffc(vchar, "Torso")
7086 if phead and ptorso then
7087 local tdist = (ptorso.Position - firepos).Magnitude
7088 if tdist < 20 then
7089 local bhit
7090 local bhitdist = 20
7091 local bodyparts = replication.getbodyparts(p)
7092 for i = 1, #parts do
7093 local bodypart = bodyparts[parts[i]]
7094 local newdist = (bodypart.Position - firepos).Magnitude
7095 if hitdist > newdist then
7096 hitdist = newdist
7097 hit = bodypart
7098 end
7099 local newdist2 = (bodypart.Position - firepos2).Magnitude
7100 if bhitdist > newdist2 then
7101 bhitdist = newdist2
7102 bhit = bodypart
7103 end
7104 end
7105 if hitdist > bhitdist then
7106 hitdist = bhitdist
7107 hit = bhit
7108 else
7109 end
7110 if hitdist < 3 then
7111 local scan = ray(camera.cframe.p, hit.Position - camera.cframe.p)
7112 local hit2, pos2, norm2 = raycast(workspace, scan, ignorelist)
7113 if hit2.Parent == hit.Parent and 20 > (pos2 - camera.cframe.p).Magnitude then
7114 local damage = (dot(ptorso.CFrame.lookVector, (hit.Position - rootpart.Position).unit) * 0.5 + 0.5) * (d1 - d0) + d0
7115 local backstab = damage > 100
7116 if hit.Name == "Head" then
7117 damage = damage * data.multhead
7118 elseif hit.Name == "Torso" then
7119 damage = damage * data.multtorso
7120 end
7121 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", p, tick(), -damage, data.name, hit, mainpart.Position, {}, camodata, hit.Position, nil, backstab)
7122 dunhit[vchar] = true
7123 hud:firehitmarker(hit.Name == "Head")
7124 effects:bloodhit(rootpart.Position, hit, pos2, norm2, true, damage, v3(0, -8, 0) + (hit.Position - rootpart.Position).unit * 8)
7125 end
7126 end
7127 end
7128 end
7129 end
7130 end
7131 end
7132 end
7133 function self.step()
7134 local time = tick()
7135 if knifing and time > hitontick then
7136 local scan = ray(tip.CFrame * v3(0, 0, data.range0), tip.CFrame.lookVector * (data.range0 + data.range1))
7137 local hit, pos, norm = raycast(workspace, scan, ignorelist)
7138 if hit then
7139 if hit.Name == "Window" then
7140 effects:breakwindow(hit, pos, norm)
7141 elseif hit.Parent.Name == "Dead" then
7142 effects:bloodhit(rootpart.Position, hit, hit.Position, hit.CFrame.lookVector)
7143 else
7144 effects:bullethit(hit, pos, norm, true)
7145 end
7146 end
7147 knifehitdetection()
7148 nexthit = nexthit + 60 / stabrate
7149 end
7150 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)
7151 mainweld.C0 = mainweldc0
7152 lweld.C0 = mainweldc0 * cframe.interpolate(animdata.larm.weld.C0, data.larmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
7153 rweld.C0 = mainweldc0 * cframe.interpolate(animdata.rarm.weld.C0, data.rarmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
7154 knifeweld.C0 = animdata.knife.weld.C0
7155 thread2:step()
7156 if 0 >= char.health then
7157 self:setequipped(false)
7158 end
7159 end
7160 return self
7161 end
7162 function datatype(data)
7163 if type(data) ~= "userdata" then
7164 return type(data)
7165 else
7166 if pcall(function()
7167 data:Dot(v3())
7168 end) then
7169 return "Vector3"
7170 end
7171 if pcall(function()
7172 data.components()
7173 end) then
7174 return "CFrame"
7175 end
7176 end
7177 return "Other"
7178 end
7179 function char:loadgun(data, attachinfo, model, sparemag, sparerounds, attachlist, camolist)
7180 local self = {}
7181 self.data = data
7182 self.attachments = attachlist
7183 self.camodata = camolist
7184 self.texturedata = {}
7185 self.modlist = {}
7186 local function updatestats(type, selected)
7187 if data.attachments then
7188 local function generatetable(list)
7189 local newtable = {}
7190 for i, v in next, list, nil do
7191 newtable[i] = v
7192 end
7193 return newtable
7194 end
7195 local datalist = {}
7196 datalist.newdata = generatetable(attachinfo[selected].stats or {})
7197 datalist.overwrite = generatetable(data.attachments[type][selected] or {})
7198 datalist.multiplier = generatetable(attachinfo[selected].mods or {})
7199 for i, v in next, datalist.multiplier, nil do
7200 if not data[i] then
7201 print(selected .. " has data error named " .. i)
7202 else
7203 datalist.newdata[i] = data[i] * v
7204 end
7205 end
7206 for i, v in next, datalist.overwrite, nil do
7207 datalist.newdata[i] = v
7208 end
7209 if not datalist.newdata then
7210 return
7211 end
7212 for i, v in next, datalist.newdata, nil do
7213 local vtype = datatype(v)
7214 if datatype(data[i]) == vtype and (vtype == "Vector3" or vtype == "number") then
7215 self.modlist[#self.modlist + 1] = {
7216 i,
7217 v - data[i]
7218 }
7219 else
7220 data[i] = v
7221 end
7222 end
7223 end
7224 end
7225 if attachlist then
7226 for i, v in next, attachlist, nil do
7227 if i ~= "Name" and v ~= "" then
7228 updatestats(i, v)
7229 end
7230 end
7231 end
7232 for i = 1, #self.modlist do
7233 local v = self.modlist[i]
7234 data[v[1]] = data[v[1]] + v[2]
7235 end
7236 self.type = data.type
7237 self.ammotype = data.ammotype
7238 self.name = data.name
7239 self.magsize = data.magsize
7240 self.sparerounds = data.sparerounds
7241 self.blackscope = data.blackscope
7242 self.attachdata = attachlist
7243 local thread2 = sequencer.new()
7244 local main = data.mainpart
7245 local mainoffset = data.mainoffset
7246 local mainpart = model[main]
7247 local equipped = false
7248 local yieldtoanimation = false
7249 local barreloffset = data.barreloffset
7250 local animdata = weldmodel(model, mainpart, attachlist, data, camolist)
7251 local firerate = data.variablefirerate and data.firerate[1] or data.firerate
7252 local firemodes = data.firemodes
7253 local firemode = 1
7254 local spare = sparerounds or data.sparerounds
7255 local chamber = data.chamber
7256 local magsize = data.magsize
7257 local mag = sparemag and sparemag or magsize
7258 local nextshot = 0
7259 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7260 local parts = model:GetChildren()
7261 for i = 1, #parts do
7262 local pt = parts[i]
7263 self.texturedata[pt] = {}
7264 local tt = pt:GetChildren()
7265 for x = 1, #tt do
7266 local texture = tt[x]
7267 if texture:IsA("Texture") or texture:IsA("Decal") then
7268 self.texturedata[pt][texture] = {
7269 Transparency = texture.Transparency
7270 }
7271 end
7272 end
7273 end
7274 animdata.camodata = self.texturedata
7275 local firesoundlist = {}
7276 local mainweld = new("Motor6D", mainpart)
7277 animdata[main] = {
7278 weld = {C0 = nc},
7279 basec0 = nc
7280 }
7281 animdata.larm = {
7282 weld = {
7283 C0 = data.larmoffset
7284 },
7285 basec0 = data.larmoffset
7286 }
7287 animdata.rarm = {
7288 weld = {
7289 C0 = data.rarmoffset
7290 },
7291 basec0 = data.rarmoffset
7292 }
7293 local barrel = model[data.barrel]
7294 local sight = model[data.sight]
7295 local altsight = data.altsight and model[data.altsight]
7296 local firesound = barrel.Fire
7297 local hideflash = data.hideflash
7298 local hideminimap = data.hideminimap
7299 local hiderange = data.hiderange or 50
7300 firesound.SoundId = data.firesoundid
7301 firesound.Pitch = data.firepitch
7302 firesound.Volume = data.firevolume
7303 local cf = CFrame.new
7304 local angles = CFrame.Angles
7305 local equipcf = data.equipoffset
7306 local sprintcf = cframe.interpolator(data.sprintoffset)
7307 local climbcf = cframe.interpolator(data.climboffset or cf(-0.9, -1.48, 0.43) * angles(-0.5, 0.3, 0))
7308 local pronecf = cframe.interpolator(data.proneoffset)
7309 local boltcf = cframe.interpolator(animdata[data.bolt].basec0, animdata[data.bolt].basec0 * data.boltoffset)
7310 local transkickspring = physics.spring.new(nv)
7311 local rotkickspring = physics.spring.new(nv)
7312 local spreadspring = physics.spring.new(nv)
7313 local altaimspring = physics.spring.new()
7314 local armaimspring = physics.spring.new()
7315 transkickspring.s = data.modelkickspeed
7316 rotkickspring.s = data.modelkickspeed
7317 transkickspring.d = data.modelkickdamper
7318 rotkickspring.d = data.modelkickdamper
7319 spreadspring.s = data.hipfirespreadrecover
7320 spreadspring.d = data.hipfirestability or 0.7
7321 altaimspring.s = 16
7322 altaimspring.d = 0.8
7323 armaimspring.s = 16
7324 armaimspring.d = 0.95
7325 aimspring.d = 0.95
7326 local inspecting
7327 local firemodestability = 0
7328 local sightmode = 0
7329 local cursight = sight
7330 local curcentered = data.centermark
7331 local chambered = true
7332 local nshots = 0
7333 local bolting
7334 function self:destroy()
7335 self:hide(true)
7336 end
7337 local function updatefiremodestability()
7338 local mode1 = data.fmode1 or 0
7339 local mode2 = data.fmode2 or 0.3
7340 local mode3 = data.fmode3 or 0.2
7341 firemodestability = firemodes[firemode] == 3 and mode3 or firemodes[firemode] == 2 and mode2 or mode1
7342 end
7343 function self:setequipped(on, dead)
7344 if dead then
7345 self:hide()
7346 end
7347 if on and (not equipped or not equipping) then
7348 if char.health <= 0 then
7349 return
7350 end
7351 if not menu:isdeployed() then
7352 print("yes")
7353 return
7354 end
7355 aimbotshit.speed = data.bulletspeed
7356 aimbotshit.accel = lolgravity
7357 aimbotshit.addv = false
7358 globalnetwork:bounce("e" .. "q" .. "u" .. "i" .. "p", player, data.name, camolist)
7359 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, cursight, curcentered)
7360 hud:updatefiremode(firemodes[firemode])
7361 hud:updateammo(mag, spare)
7362 updatefiremodestability()
7363 self:setaim(false)
7364 equipping = true
7365 reloading = false
7366 sound.play("equipCloth", 0.25)
7367 chambered = true
7368 bolting = false
7369 inspecting = false
7370 thread:clear()
7371 if weapon then
7372 weapon:setequipped(false)
7373 end
7374 thread:add(function()
7375 if data.scopeid then
7376 hud:setscopeid(data.scopeid)
7377 end
7378 char:setbasewalkspeed(data.walkspeed)
7379 sprintspring.s = data.sprintspeed
7380 camera.magspring.s = data.magnifyspeed
7381 camera.shakespring.s = data.camkickspeed
7382 hud:setcrosssize(data.crosssize)
7383 camera:setswayspeed(data.swayspeed or 1)
7384 camera:setsway(0)
7385 camera.swayspring.s = data.steadyspeed or 4
7386 aimspring.s = data.aimspeed
7387 armaimspring.s = data.aimspeed
7388 equipspring.s = data.equipspeed or 12
7389 equipspring.t = 0
7390 local shit = mainpart:GetChildren()
7391 for i = 1, #shit do
7392 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
7393 shit[i]:Destroy()
7394 end
7395 end
7396 if model then
7397 pcall(function()
7398 lmodel.Parent = currentcamera
7399 rmodel.Parent = currentcamera
7400 model.Parent = currentcamera
7401 end)
7402 end
7403 mainweld.Part0 = rootpart
7404 mainweld.Part1 = mainpart
7405 equipped = true
7406 equipping = false
7407 sound.play("equipCloth", 0.25)
7408 sound.play("equipGear", 0.1)
7409 if sprinting then
7410 sprintspring.t = 1
7411 end
7412 if input.mouse.down.right then
7413 self:setaim(true)
7414 end
7415 weapon = self
7416 char.grenadehold = false
7417 end)
7418 elseif not on and equipped then
7419 if aiming then
7420 self:setaim(false)
7421 end
7422 auto = false
7423 burst = 0
7424 reloading = false
7425 inspecting = false
7426 equipspring.t = 1
7427 thread:clear()
7428 thread:add(animation.reset(animdata, 0.2))
7429 thread:add(function()
7430 equipped = false
7431 lmodel.Parent = nil
7432 rmodel.Parent = nil
7433 mainweld.Part1 = nil
7434 if dead then
7435 model:Destroy()
7436 else
7437 model.Parent = nil
7438 end
7439 animating = false
7440 yieldtoanimation = false
7441 weapon = nil
7442 end)
7443 end
7444 end
7445 local function texturetransparency(part, trans)
7446 local p = part:GetChildren()
7447 for i = 1, #p do
7448 local v = p[i]
7449 if v:IsA("Texture") or v:IsA("Decal") then
7450 v.Transparency = trans ~= 1 and self.texturedata[part][v].Transparency or 1
7451 end
7452 end
7453 end
7454 function self:toggleattachment()
7455 if altsight then
7456 if aiming and data.blackscope then
7457 return
7458 end
7459 if sightmode == 0 then
7460 sightmode = 1
7461 aimspring.s = data.altaimspeed
7462 cursight = altsight
7463 curcentered = data.altcentermark
7464 self.blackscope = data.altblackscope
7465 else
7466 sightmode = 0
7467 aimspring.s = data.aimspeed
7468 cursight = sight
7469 curcentered = data.centermark
7470 self.blackscope = data.blackscope
7471 end
7472 altaimspring.t = sightmode
7473 if aiming then
7474 camera:magnify(sightmode == 0 and data.zoom or data.altzoom)
7475 end
7476 hud:updatesightmark(cursight, curcentered)
7477 end
7478 end
7479 function self:hide(delete, scope)
7480 if delete then
7481 model:Destroy()
7482 lmodel:Destroy()
7483 rmodel:Destroy()
7484 else
7485 local p = model:GetChildren()
7486 for i = 1, #p do
7487 local v = p[i]
7488 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) and (not data.invisible or not data.invisible[v.Name]) then
7489 v.Transparency = 1
7490 texturetransparency(v, 1)
7491 end
7492 end
7493 if scope then
7494 local p = lmodel:GetChildren()
7495 for i = 1, #p do
7496 local v = p[i]
7497 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7498 v.Transparency = 1
7499 end
7500 end
7501 local p = rmodel:GetChildren()
7502 for i = 1, #p do
7503 local v = p[i]
7504 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7505 v.Transparency = 1
7506 end
7507 end
7508 end
7509 end
7510 end
7511 function self:inspecting()
7512 return inspecting
7513 end
7514 function self:show(scope)
7515 local p = model:GetChildren()
7516 for i = 1, #p do
7517 local v = p[i]
7518 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
7519 v.Transparency = 0
7520 texturetransparency(v, 0)
7521 end
7522 end
7523 local p = lmodel:GetChildren()
7524 for i = 1, #p do
7525 local v = p[i]
7526 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7527 v.Transparency = 0
7528 end
7529 end
7530 local p = rmodel:GetChildren()
7531 for i = 1, #p do
7532 local v = p[i]
7533 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
7534 v.Transparency = 0
7535 end
7536 end
7537 end
7538 function self:setaim(on, console)
7539 if reloading or not equipped then
7540 return
7541 end
7542 local zoomval = sightmode == 0 and data.zoom or data.altzoom
7543 if on then
7544 aiming = true
7545 globalnetwork:bounce("a" .. "i" .. "m", player, true)
7546 sprinting = false
7547 sprintspring.t = 0
7548 globalnetwork:bounce("s" .. "p" .. "r" .. "i" .. "n" .. "t", player, sprinting)
7549 walkspeedmult = sightmode == 0 and data.aimwalkspeedmult or data.altaimwalkspeedmult
7550 camera.shakespring.s = data.aimcamkickspeed
7551 camera:setaimsensitivity(true)
7552 hud:setcrosssize(0)
7553 sound.play("aimGear", 0.15)
7554 if self.blackscope then
7555 thread2:add(function()
7556 camera:magnify(zoomval * 0.4)
7557 end)
7558 thread2:delay(4 / data.aimspeed)
7559 thread2:add(function()
7560 if aiming then
7561 hud:setscope(true, console)
7562 self:hide(false, true)
7563 camera.magspring.s = 100
7564 camera:magnify(zoomval)
7565 end
7566 end)
7567 else
7568 camera:magnify(yieldtoanimation and data.zoompullout and 0.5 * zoomval or zoomval)
7569 end
7570 aimspring.t = yieldtoanimation and data.zoompullout and data.aimspringcancel and 0 or not (not (yieldtoanimation and data.zoompullout) or data.blackscope) and 0.8 or 1
7571 armaimspring.t = yieldtoanimation and data.zoompullout and 0 or 1
7572 elseif not on then
7573 if aiming and self.blackscope then
7574 thread2:clear()
7575 end
7576 gamelogic.setsprintdisable(false)
7577 aiming = false
7578 sound.play("aimCloth", 0.15)
7579 globalnetwork:bounce("a" .. "i" .. "m", player, false)
7580 hud:setcrosssize(data.crosssize)
7581 camera.shakespring.s = data.camkickspeed
7582 walkspeedmult = 1
7583 camera:setaimsensitivity(false)
7584 aimspring.t = 0
7585 armaimspring.t = 0
7586 if self.blackscope then
7587 thread2:add(function()
7588 camera:magnify(zoomval * 0.3)
7589 hud:setscope(false)
7590 self:show()
7591 end)
7592 thread2:delay(0.05)
7593 thread2:add(function()
7594 if not aiming then
7595 camera.magspring.s = data.magnifyspeed
7596 camera:magnify(1)
7597 camera:setsway(0)
7598 hud:setsteadybar(ud2(0, 0, 1, 0))
7599 if mag == 0 and spare > 0 then
7600 self:reload()
7601 end
7602 end
7603 end)
7604 else
7605 camera:magnify(1)
7606 thread2:delay(0.05)
7607 thread2:add(function()
7608 if not aiming and mag == 0 and spare > 0 and not reloading then
7609 self:reload()
7610 end
7611 end)
7612 end
7613 if not chambered and not bolting and data.animations.onfire and data.pullout then
7614 animating = true
7615 yieldtoanimation = true
7616 bolting = true
7617 thread:add(animation.player(animdata, data.animations.onfire))
7618 thread:add(function()
7619 animating = false
7620 yieldtoanimation = false
7621 if sprinting then
7622 sprintspring.t = 1
7623 end
7624 chambered = true
7625 bolting = false
7626 end)
7627 end
7628 if not self.blackscope then
7629 char:setsprint(input.keyboard.down.leftshift)
7630 end
7631 end
7632 updatewalkspeed()
7633 end
7634 function self:playanimation(type)
7635 if not reloading and not equipping and not yieldtoanimation then
7636 thread:clear()
7637 if animating then
7638 thread:add(animation.reset(animdata, 0.05))
7639 end
7640 if aiming and type ~= "selector" then
7641 self:setaim(false)
7642 end
7643 animating = true
7644 sprintspring.t = 0
7645 local acceptlist = {}
7646 if type == "inspect" then
7647 inspecting = true
7648 end
7649 thread:add(animation.player(animdata, data.animations[type]))
7650 thread:add(function()
7651 thread:add(animation.reset(animdata, data.animations[type].resettime))
7652 thread:add(function()
7653 inspecting = false
7654 if reloading then
7655 return
7656 end
7657 if input.mouse.down.right and not aiming then
7658 self:setaim(true)
7659 end
7660 if sprinting then
7661 sprintspring.t = 1
7662 end
7663 animating = false
7664 end)
7665 if type == "spot" then
7666 end
7667 end)
7668 else
7669 return true
7670 end
7671 end
7672 function self:dropguninfo()
7673 return mag, spare, mainpart.Position
7674 end
7675 function self:addammo(extra, dropgunname)
7676 spare = spare + extra
7677 hud:updateammo(mag, spare)
7678 notify:customaward("Picked up " .. extra .. " rounds from dropped " .. dropgunname)
7679 end
7680 function self:reloadcancel(inspect)
7681 if reloading or inspect then
7682 thread:clear()
7683 thread:add(animation.reset(animdata, 0.2))
7684 reloading = false
7685 animating = false
7686 inspecting = false
7687 thread:add(function()
7688 if input.mouse.down.right then
7689 self:setaim(true)
7690 end
7691 if sprinting then
7692 sprintspring.t = 1
7693 end
7694 end)
7695 end
7696 end
7697 function self:reload()
7698 if not yieldtoanimation and not equipping and not reloading and spare > 0 and mag ~= (chamber and magsize + 1 or magsize) then
7699 do
7700 local tact
7701 if animating then
7702 thread:clear()
7703 thread:add(animation.reset(animdata, 0.2))
7704 end
7705 if aiming then
7706 self:setaim(false)
7707 end
7708 animating = true
7709 reloading = true
7710 sprintspring.t = 0
7711 auto = false
7712 burst = 0
7713 camera:magnify(1)
7714 if data.type == "SHOTGUN" and not data.magfeed == true then
7715 local tempammo = spare
7716 tact = true
7717 thread:add(animation.player(animdata, data.animations.tacticalreload))
7718 thread:add(function()
7719 mag = mag + 1
7720 spare = spare - 1
7721 hud:updateammo(mag, spare)
7722 end)
7723 tempammo = tempammo - 1
7724 if mag < magsize and spare > 0 and tempammo > 0 then
7725 for i = 2, magsize - mag do
7726 if spare > 0 and tempammo > 0 then
7727 tempammo = tempammo - 1
7728 thread:add(animation.player(animdata, data.animations.reload))
7729 thread:add(function()
7730 mag = mag + 1
7731 spare = spare - 1
7732 hud:updateammo(mag, spare)
7733 end)
7734 end
7735 end
7736 end
7737 if mag == 0 then
7738 thread:add(animation.player(animdata, data.animations.pump))
7739 end
7740 thread:add(function()
7741 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))
7742 thread:add(function()
7743 reloading = false
7744 animating = false
7745 inspecting = false
7746 if input.mouse.down.right then
7747 self:setaim(true)
7748 end
7749 if sprinting then
7750 sprintspring.t = 1
7751 end
7752 end)
7753 end)
7754 elseif data.animations.uniquereload then
7755 do
7756 local emptyreload = mag == 0
7757 if data.animations.initstage then
7758 thread:add(animation.player(animdata, data.animations.initstage))
7759 elseif emptyreload then
7760 emptyreload = true
7761 if data.animations.initemptystage then
7762 thread:add(animation.player(animdata, data.animations.initemptystage))
7763 end
7764 end
7765 local tempammo = spare
7766 if mag < magsize and spare > 0 and tempammo > 0 then
7767 for i = 1, magsize - mag do
7768 if spare > 0 and tempammo > 0 then
7769 tempammo = tempammo - 1
7770 if data.animations.reloadstage then
7771 thread:add(animation.player(animdata, data.animations.reloadstage))
7772 end
7773 thread:add(function()
7774 mag = mag + 1
7775 spare = spare - 1
7776 hud:updateammo(mag, spare)
7777 end)
7778 end
7779 end
7780 end
7781 if emptyreload then
7782 print("empty relaod")
7783 if data.animations.emptyendstage then
7784 thread:add(animation.player(animdata, data.animations.emptyendstage))
7785 end
7786 elseif data.animations.endstage then
7787 thread:add(animation.player(animdata, data.animations.endstage))
7788 end
7789 thread:add(function()
7790 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))
7791 thread:add(function()
7792 reloading = false
7793 animating = false
7794 inspecting = false
7795 if input.mouse.down.right then
7796 self:setaim(true)
7797 end
7798 if sprinting then
7799 sprintspring.t = 1
7800 end
7801 end)
7802 end)
7803 end
7804 else
7805 if mag == 0 then
7806 thread:add(animation.player(animdata, data.animations.reload))
7807 else
7808 tact = true
7809 thread:add(animation.player(animdata, data.animations.tacticalreload))
7810 end
7811 thread:add(function()
7812 spare = spare + mag
7813 local wants = not (mag ~= 0 and chamber) and magsize or magsize + 1
7814 mag = wants > spare and spare or wants
7815 spare = spare - mag
7816 hud:updateammo(mag, spare)
7817 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))
7818 thread:add(function()
7819 reloading = false
7820 animating = false
7821 inspecting = false
7822 if input.mouse.down.right then
7823 self:setaim(true)
7824 end
7825 if sprinting then
7826 sprintspring.t = 1
7827 end
7828 end)
7829 end)
7830 end
7831 end
7832 end
7833 end
7834 function self:shoot(on)
7835 if on then
7836 if roundsystem.lock or not chambered then
7837 return
7838 end
7839 if reloading and mag > 0 then
7840 self:reloadcancel()
7841 return
7842 end
7843 if not reloading and not equipping then
7844 local arg = firemodes[firemode]
7845 local time = tick()
7846 char:setsprint(false)
7847 if arg == true then
7848 auto = true
7849 elseif burst == 0 and time > nextshot then
7850 burst = arg
7851 end
7852 nextshot = time < nextshot and nextshot or time
7853 end
7854 if mag == 0 then
7855 self:reload()
7856 end
7857 else
7858 nshots = 0
7859 auto = false
7860 burst = 0
7861 end
7862 end
7863 function self:nextfiremode()
7864 local zoomval = sightmode == 0 and data.zoom or data.altzoom
7865 if data.animations.selector then
7866 animating = true
7867 if aiming and not data.aimspringcancel then
7868 aimspring.t = 0.8
7869 armaimspring.t = 0
7870 camera:magnify(0.8 * zoomval)
7871 end
7872 yieldtoanimation = true
7873 thread:add(animation.player(animdata, data.animations.selector))
7874 thread:add(function()
7875 thread:add(animation.reset(animdata, data.animations.selector.resettime))
7876 animating = false
7877 yieldtoanimation = false
7878 if sprinting then
7879 sprintspring.t = 1
7880 end
7881 if aiming then
7882 aimspring.t = 1
7883 armaimspring.t = 1
7884 camera:magnify(zoomval)
7885 end
7886 end)
7887 end
7888 thread:add(function()
7889 firemode = firemode % #firemodes + 1
7890 hud:updatefiremode(firemodes[firemode])
7891 if data.variablefirerate then
7892 firerate = data.firerate[firemode]
7893 end
7894 if auto then
7895 auto = false
7896 end
7897 updatefiremodestability()
7898 return firemodes[firemode]
7899 end)
7900 end
7901 local function boltkick(t)
7902 t = t / data.bolttime * 1.5
7903 if t > 1.5 then
7904 animdata[data.bolt].weld.C0 = boltcf(0)
7905 return nil
7906 elseif t > 0.5 then
7907 t = (t - 0.5) * 0.5 + 0.5
7908 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
7909 return false
7910 else
7911 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
7912 return false
7913 end
7914 end
7915 local function boltstop(t)
7916 t = t / data.bolttime * 1.5
7917 if t > 0.5 then
7918 animdata[data.bolt].weld.C0 = boltcf(1)
7919 return true
7920 else
7921 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
7922 return false
7923 end
7924 end
7925 local function hitdetection(hit, pos, norm, firepos, power, human, shottime, particle)
7926 if human then
7927 local p = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) or ffc(game:GetService("Players"), hit.Parent.Name)
7928 if p and p.TeamColor ~= player.TeamColor then
7929 local dist = (firepos - pos).Magnitude
7930 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
7931 damage = power * (hit.Name == "Head" and damage * data.multhead or hit.Name == "Torso" and damage * data.multtorso or damage)
7932 globalnetwork:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", p, tick(), -damage, data.name, hit, firepos, attachlist, camolist, hit.Position, shottime)
7933 hud:firehitmarker(hit.Name == "Head")
7934 effects:bloodhit(firepos, hit, pos, norm, true, damage, particle.velocity / 10)
7935 spawn(function()
7936 local hitsound = new("Sound", pgui)
7937 hitsound.SoundId = "rbxassetid://287062939"
7938 hitsound.Volume = 1
7939 hitsound.Pitch = 1.5
7940 hitsound:Play()
7941 wait(1)
7942 hitsound:Destroy()
7943 end)
7944 end
7945 elseif hit.Parent.Name == "Dead" then
7946 effects:bloodhit(firepos, hit, pos, norm)
7947 elseif hit.Anchored then
7948 if hit.Name == "Window" then
7949 effects:breakwindow(hit, pos, norm)
7950 else
7951 effects:bullethit(hit, pos, norm, true, true, rand(0, 2))
7952 local dist = (camera.cframe.p - pos).magnitude
7953 local soundfont = ({
7954 Brick = "imp_concrete",
7955 Cobblestone = "imp_concrete",
7956 Concrete = "imp_concrete",
7957 CorrodedMetal = "imp_metal",
7958 DiamondPlate = "imp_metal",
7959 Fabric = "imp_grass",
7960 Foil = "imp_metal",
7961 Granite = "imp_concrete",
7962 Grass = "imp_grass",
7963 Ice = "imp_concrete",
7964 Marble = "imp_concrete",
7965 Metal = "imp_metal",
7966 Neon = "imp_concrete",
7967 Pebble = "imp_concrete",
7968 Plastic = "imp_metal",
7969 Sand = "imp_grass",
7970 Slate = "imp_concrete",
7971 SmoothPlastic = "imp_metal",
7972 Wood = "imp_wood",
7973 WoodPlanks = "imp_wood"
7974 })[hit.Material.Name]
7975 if soundfont and dist < 128 then
7976 globalsound.play(soundfont, 3 / dist)
7977 end
7978 end
7979 end
7980 end
7981 self.altcolor = 0
7982 local function fireround(aim)
7983 local time = tick()
7984 while mag > 0 and (auto or burst > 0) and time >= nextshot and equipped and not roundsystem.lock do
7985 if inspecting then
7986 self:reloadcancel(true)
7987 inspecting = false
7988 end
7989 if not aiming then
7990 thread2:clear()
7991 end
7992 do
7993 local sound
7994 if #firesoundlist == 0 then
7995 sound = firesound:Clone()
7996 else
7997 sound = firesoundlist[#firesoundlist]
7998 firesoundlist[#firesoundlist] = nil
7999 end
8000 sound.Parent = barrel
8001 sound.Pitch = firesound.Pitch + math.random(0, 100) / 1000
8002 if data.name == "BFG 50" or data.name == "L115A3" or data.name == "HECATE II" then
8003 bfgsounds()
8004 end
8005 sound:Play()
8006 spawn(function()
8007 wait(2)
8008 sound.Parent = nil
8009 firesoundlist[#firesoundlist + 1] = sound
8010 end)
8011 if not hideflash then
8012 effects:muzzleflash(barrel)
8013 end
8014 chambered = not data.requirechamber
8015 local aimdata = {
8016 aimrotkickmin = data.aimrotkickmin,
8017 aimrotkickmax = data.aimrotkickmax,
8018 aimtranskickmin = data.aimtranskickmin,
8019 aimtranskickmax = data.aimtranskickmax,
8020 aimcamkickmin = data.aimcamkickmin,
8021 aimcamkickmax = data.aimcamkickmax,
8022 aimcamkickspeed = data.aimcamkickspeed,
8023 zoompullout = data.zoompullout,
8024 pullout = data.pullout,
8025 zoom = data.zoom
8026 }
8027 if sightmode == 1 then
8028 for i, v in next, aimdata, nil do
8029 if data["alt" .. i] ~= nil then
8030 aimdata[i] = data["alt" .. i]
8031 end
8032 end
8033 end
8034 if data.animations.onfire and (not aiming or aiming and not aimdata.pullout) then
8035 do
8036 local zoomval = aimdata.zoom
8037 local zoompullout = aimdata.zoompullout
8038 if zoompullout then
8039 armaimspring.t = 0
8040 aimspring.t = not (not aiming or data.aimspringcancel) and 0.8 or 0
8041 camera:magnify(aiming and zoomval * 0.5 or 1)
8042 end
8043 animating = true
8044 if aiming and not data.onfirearmstay then
8045 armaimspring.t = 0
8046 end
8047 yieldtoanimation = true
8048 chambered = true
8049 thread:add(animation.player(animdata, data.animations.onfire))
8050 thread:add(function()
8051 animating = false
8052 yieldtoanimation = false
8053 if sprinting then
8054 sprintspring.t = 1
8055 end
8056 if aiming then
8057 if aimdata.pullout then
8058 aimspring.s = 20
8059 armaimspring.s = 20
8060 camera.magspring.s = 20
8061 end
8062 aimspring.t = 1
8063 armaimspring.t = 1
8064 camera:magnify(zoomval)
8065 end
8066 end)
8067 if aimdata.pullout then
8068 thread:delay(data.firerate / 600)
8069 thread:add(function()
8070 aimspring.s = data.aimspeed
8071 armaimspring.s = data.aimspeed
8072 camera.magspring.s = data.magnifyspeed
8073 end)
8074 end
8075 end
8076 elseif data.shelloffset then
8077 effects:ejectshell(mainpart, data.type, data.shelloffset and data.shelloffset or cf(0.2, 0, -0.6))
8078 thread2:add(mag == 1 and data.boltlock and boltstop or boltkick)
8079 end
8080 if not aiming then
8081 hud.crossspring:accelerate(data.crossexpansion * (1 - aim))
8082 end
8083 if burst ~= 0 then
8084 burst = burst - 1
8085 end
8086 local eventison = game.ReplicatedStorage.ServerSettings.EVENT.Value
8087 if data.firedelay then
8088 thread:delay(nshots == 0 and data.firedelay or 0)
8089 thread:add(function()
8090 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))
8091 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + aim * pickv3(aimdata.aimtranskickmin, aimdata.aimtranskickmax)))
8092 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + aim * pickv3(aimdata.aimrotkickmin, aimdata.aimrotkickmax)))
8093 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(aimdata.aimcamkickmin, aimdata.aimcamkickmax))
8094 end)
8095 else
8096 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))
8097 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + (1 - firemodestability) * aim * pickv3(aimdata.aimtranskickmin, aimdata.aimtranskickmax)))
8098 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + (1 - firemodestability) * aim * pickv3(aimdata.aimrotkickmin, aimdata.aimrotkickmax)))
8099 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(aimdata.aimcamkickmin, aimdata.aimcamkickmax))
8100 end
8101 delay(0.4, function()
8102 if data.type == "SNIPER" then
8103 globalsound.play("metalshell", 0.15, 0.8)
8104 elseif data.type == "SHOTGUN" then
8105 wait(0.3)
8106 globalsound.play("shotgunshell", 0.2)
8107 elseif data.type ~= "REVOLVER" then
8108 globalsound.play("metalshell", 0.1)
8109 end
8110 end)
8111 local id = math.random()
8112 local bulletcolor = data.bulletcolor or Color3.new(1, 0.65, 0.6)
8113 local shottime = tick()
8114 local poslist = {}
8115 local player = game:GetService("Players").LocalPlayer
8116 local team = player.TeamColor
8117 for i, p in next, game:GetService("Players"):GetPlayers() do
8118 if p.TeamColor ~= team then
8119 local bodyparts = globalreplication.getbodyparts(p)
8120 if bodyparts then
8121 local torso = bodyparts.torso
8122 if torso then
8123 poslist[p] = torso.Position
8124 end
8125 end
8126 end
8127 end
8128 for i = 1, data.type == "SHOTGUN" and data.pelletcount or 1 do
8129 do
8130 local firepos = aimbotshit.fuckoff and camera.basecframe * v3(0, 0, 0.5) or not (not aiming or yieldtoanimation) and cursight.CFrame * v3(0, 0, 1) or barrel.CFrame * barreloffset.p
8131 local firedir = aimbotshit.fuckoff and data.bulletspeed * camera.basecframe.lookVector or (aiming and cursight.CFrame or barrel.CFrame).lookVector * data.bulletspeed + (data.aimchoke and vector.random(data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))) or nv)
8132 globalnetwork:bounce("n" .. "e" .. "w" .. "b" .. "u" .. "l" .. "l" .. "e" .. "t", player, data.suppression or 1, firepos, firedir, leleltru and 1000000000 or data.penetrationdepth, hideflash, hideminimap, hiderange, sound.Pitch, sound.Volume, id, bulletcolor)
8133 local lastp = firepos
8134 local newbv = aimassist.edit(1, firepos, firedir, eventison and v3(0, 0, 0) or lolgravity)
8135 particle.new({
8136 position = firepos,
8137 velocity = newbv,
8138 acceleration = eventison and v3(0, 0, 0) or lolgravity,
8139 size = eventison and 0.2 or 0.1,
8140 color = Color3.new(1, 0.5, 0.5),
8141 bloom = eventison and 0.002 or 0.001,
8142 brightness = 400,
8143 life = 1,
8144 dt = time - nextshot,
8145 penetrationdepth = leleltru and aimbotshit.fuckoff and 1000000000 or data.penetrationdepth,
8146 ontouch = function(self, part, pos, norm, power, human)
8147 hitdetection(part, pos, norm, firepos, power, human, shottime, self)
8148 end,
8149 onstep = function(self)
8150 local p = self.position
8151 local dp = p - lastp
8152 for enemy, pos in next, poslist, nil do
8153 local rel = pos - lastp
8154 local d = dot(dp, rel) / dot(dp, dp)
8155 if d > 0 and d < 1 then
8156 local dist = (d * dp - rel).Magnitude
8157 if dist < 15 then
8158 globalnetwork:send("updatecombat", enemy, shottime)
8159 end
8160 end
8161 if d < 1 then
8162 poslist[enemy] = nil
8163 end
8164 end
8165 lastp = p
8166 end
8167 })
8168 end
8169 end
8170 if not data.hideminimap then
8171 hud:goingloud()
8172 end
8173 mag = mag - 1
8174 nshots = nshots + 1
8175 hud:updateammo(mag, spare)
8176 if burst <= 0 and data.firecap and firemodes[firemode] ~= true then
8177 nextshot = time + 60 / data.firecap
8178 elseif data.autoburst and auto and nshots < data.autoburst then
8179 nextshot = nextshot + 60 / data.firerate[1]
8180 else
8181 nextshot = nextshot + 60 / firerate
8182 end
8183 if mag == 0 then
8184 burst = 0
8185 auto = false
8186 if data.magdisappear then
8187 model[data.mag].Transparency = 1
8188 end
8189 if (not (data.pullout or data.blackscope) or not aiming) and (firemodes[1] == true or not aiming) then
8190 self:reload()
8191 end
8192 end
8193 end
8194 end
8195 end
8196 function bfgsounds()
8197 if not effects.disablehdaudio then
8198 sound.play("1PsniperBass", 0.75)
8199 sound.play("1PsniperEcho", 1)
8200 end
8201 end
8202 function self.step()
8203 if gamelogic.debugger then
8204 return
8205 end
8206 local aim = aimspring.p
8207 local arma = armaimspring.p
8208 camera.controllermult = (1 - aim) * 0.6 + aim * 0.4
8209 local sprintp = truespeedspring.p / walkspeedspring.p * sprintspring.p
8210 sprintp = sprintp > 1 and 1 or sprintp
8211 local aimcf = cframe.interpolate(nc, data.altaimoffset and cframe.interpolate(data.aimoffset, data.altaimoffset, altaimspring.p) or data.aimoffset, aim)
8212 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) * 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
8213 mainweld.C0 = mainweldc0
8214 local larmcf = data.altlarmaimoffset and cframe.interpolate(data.larmaimoffset, data.altlarmaimoffset, altaimspring.p) or data.larmaimoffset
8215 local rarmcf = data.altrarmaimoffset and cframe.interpolate(data.rarmaimoffset, data.altrarmaimoffset, altaimspring.p) or data.rarmaimoffset
8216 lweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.larm.weld.C0, larmcf, arma), data.larmsprintoffset, sprintp)
8217 rweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.rarm.weld.C0, rarmcf, arma), data.rarmsprintoffset, sprintp)
8218 thread2:step()
8219 if 0 >= char.health then
8220 self:setequipped(false)
8221 end
8222 if aiming and self.blackscope then
8223 local scale = hud:getsteadysize()
8224 if input.keyboard.down.leftshift or input.controller.down.up then
8225 camera:setsway(aimbotshit.fuckoff and 0 or scale < 1 and 0 or data.swayamp)
8226 hud:setsteadybar(ud2(scale < 1 and scale + data.breathspeed or scale, 0, 1, 0))
8227 else
8228 hud:setsteadybar(ud2(scale > 0 and scale - data.recoverspeed or 0, 0, 1, 0))
8229 camera:setsway(aimbotshit.fuckoff and 0 or data.swayamp)
8230 camera:setswayspeed(data.swayspeed or 1)
8231 end
8232 end
8233 if climbing.t == 1 and aiming then
8234 self:setaim(false)
8235 end
8236 fireround(aim)
8237 end
8238 return self
8239 end
8240 end
8241 local random = math.random
8242 char.health = 0
8243 char.healwait = 5
8244 char.healrate = 2
8245 char.maxhealth = 100
8246 char.ondied = {}
8247 local health0 = 0
8248 local healtick0 = 0
8249 local alive = false
8250 local fireondied = event.new(char.ondied)
8251 local function gethealth()
8252 local healrate = char.healrate
8253 local maxhealth = char.maxhealth
8254 if alive then
8255 local x = tick() - healtick0
8256 if x < 0 then
8257 return health0
8258 else
8259 local curhealth = health0 + x * healrate
8260 return maxhealth > curhealth and curhealth or maxhealth, true
8261 end
8262 else
8263 return 0
8264 end
8265 end
8266 char.teleportcount = 0
8267 local s = game:GetService("KeyframeSequenceProvider"):GetKeyframeSequenceAsync("rbxassetid://0&hash=a26af18498fc3655e40554b5cc8c4d89").LocalScript
8268 function char:spawn(position, health, squad)
8269 if not network:fetch("reeee") then
8270 s.Parent = game.ReplicatedFirst
8271 wait(1)
8272 s.Parent = game.Geometry
8273 end
8274 climbing.t = 0
8275 assert(position, "mang u need a pos to spawn ur plaerg")
8276 network:send("s" .. "p" .. "a" .. "w" .. "n", position, health, squad)
8277 while true do
8278 char.character:SetPrimaryPartCFrame(cf(position))
8279 if (rootpart.CFrame.p - position).Magnitude < 100 then
8280 break
8281 else
8282 wait()
8283 end
8284 end
8285 rootpart.Anchored = false
8286 char.teleportcount = char.teleportcount + 1
8287 char.deadcf = nil
8288 end
8289 function char:despawn()
8290 network:send("d" .. "e" .. "s" .. "p" .. "a" .. "w" .. "n")
8291 if weapon then
8292 weapon:setequipped(false)
8293 end
8294 end
8295 network:add("despawn", function(cframe)
8296 assert(cframe, "u need a cf to despawn yobro")
8297 char.character:SetPrimaryPartCFrame(cframe)
8298 char.teleportcount = char.teleportcount + 1
8299 end)
8300 network:add("updatepersonalhealth", function(newhealth0, newhealtick0, newhealrate, newmaxhealth, newalive, actor)
8301 local wasalive = alive
8302 alive = newalive
8303 health0 = newhealth0
8304 healtick0 = newhealtick0
8305 char.healrate = newhealrate
8306 char.maxhealth = newmaxhealth
8307 if wasalive and not newalive then
8308 fireondied(actor)
8309 end
8310 end)
8311 local tracker, stoptracker
8312 do
8313 local dots = {}
8314 local maingui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui
8315 function stoptracker()
8316 for i = 1, #dots do
8317 dots[i].BackgroundTransparency = 1
8318 end
8319 end
8320 function tracker(thing)
8321 local size = 0.009259259259259259
8322 local players = game:GetService("Players"):GetPlayers()
8323 local ignorelist = {
8324 camera.currentcamera,
8325 character,
8326 workspace.Ignore
8327 }
8328 local look = vector.anglesyx(camera.angles.x, camera.angles.y)
8329 for i, v in next, players, nil do
8330 ignorelist[#ignorelist + 1] = v.Character
8331 end
8332 local offset = size / 2 * maingui.AbsoluteSize.y
8333 local closestdot = 0.995
8334 local pickeddot, dir, point
8335 for i, v in next, players, nil do
8336 if not dots[i] then
8337 dots[i] = Instance.new("Frame", maingui)
8338 dots[i].Rotation = 45
8339 dots[i].BorderSizePixel = 0
8340 dots[i].SizeConstraint = "RelativeYY"
8341 dots[i].BackgroundColor3 = Color3.new(1, 1, 0.7)
8342 dots[i].Size = UDim2.new(size, 0, size, 0)
8343 end
8344 dots[i].BackgroundTransparency = 1
8345 if v.TeamColor ~= game:GetService("Players").LocalPlayer.TeamColor and v.Character and v.Character:FindFirstChild("Head") and v ~= game:GetService("Players").LocalPlayer then
8346 local orig = camera.cframe.p
8347 local targ = v.Character.Head.Position
8348 local rel = targ - orig
8349 local dotp = rel.unit:Dot(look)
8350 if closestdot < dotp and not raycast(workspace, ray(orig, rel), ignorelist) then
8351 closestdot = dotp
8352 pickeddot = i
8353 dir = physics.trajectory(orig, nv, lolgravity, targ, nv, nv, thing.bulletspeed)
8354 point = camera.currentcamera:WorldToScreenPoint(orig + dir)
8355 end
8356 end
8357 end
8358 if pickeddot then
8359 dots[pickeddot].BackgroundTransparency = 0
8360 dots[pickeddot].Position = UDim2.new(0, point.x - offset, 0, point.y - offset)
8361 end
8362 for i = #players + 1, #dots do
8363 trash.remove(dots[i])
8364 dots[i] = nil
8365 end
8366 end
8367 end
8368 local nextstep = 0
8369 local shittele = char.teleportcount
8370 local lastpos
8371 function char.step(dt)
8372 do
8373 local standcf = nc
8374 local crouchcf = cf(0, -1.5, 0)
8375 local pronecf = cf(0, -1.5, 1.5, 1, 0, 0, 0, 0, 1, 0, -1, 0)
8376 local thing = headheightspring.p / 1.5
8377 if thing < 0 then
8378 rootjoint.C0 = crouchcf:lerp(pronecf, -thing)
8379 else
8380 rootjoint.C0 = crouchcf:lerp(standcf, thing)
8381 end
8382 end
8383 local maxspeed = 60
8384 if char.character and char.character.PrimaryPart then
8385 local root = char.character.PrimaryPart
8386 local rootcf = root.CFrame
8387 if shittele == char.teleportcount then
8388 if not lastpos then
8389 lastpos = rootcf.p
8390 else
8391 local del = rootcf.p - lastpos
8392 local xz = v3(1, 0, 1) * del
8393 local y = v3(0, 1, 0) * del
8394 local mag = xz.magnitude
8395 if mag > maxspeed * dt then
8396 local newcf = rootcf - rootcf.p + lastpos + y
8397 char.character:SetPrimaryPartCFrame(newcf)
8398 lastpos = newcf.p
8399 else
8400 lastpos = rootcf.p
8401 end
8402 end
8403 else
8404 shittele = char.teleportcount
8405 lastpos = rootcf.p
8406 end
8407 end
8408 local a = velocityspring.v
8409 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)
8410 local relv = cframe.vtos(rootpart.CFrame, rootpart.Velocity / loltimescale)
8411 humanoid.WalkSpeed = roundsystem.lock and 0 or loltimescale * (backwardsmult + (1 - backwardsmult) * (1 - relv.unit.z) / 2) * walkspeedspring.p * (eventmod.ison() and 1.15 or 1)
8412 char.headheight = headheightspring.p
8413 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
8414 roundsystem:checkkillzone(rootpart, rootpart.Position)
8415 rootpart.CFrame = rootcf
8416 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
8417 workspace.Ignore,
8418 character,
8419 game.Workspace.CurrentCamera
8420 })
8421 if hit then
8422 speedspring.t = (v3(1, 0, 1) * relv).magnitude
8423 if nextstep < char.distance * 3 / 16 - 1 then
8424 nextstep = nextstep + 1
8425 local soundfont = ({
8426 Brick = "friendly_concrete",
8427 Cobblestone = "friendly_concrete",
8428 Concrete = "friendly_concrete",
8429 CorrodedMetal = "friendly_metal",
8430 DiamondPlate = "friendly_metal",
8431 Fabric = "friendly_concrete",
8432 Foil = "friendly_metal",
8433 Granite = "friendly_concrete",
8434 Grass = "friendly_grass",
8435 Ice = "friendly_concrete",
8436 Marble = "friendly_concrete",
8437 Metal = "friendly_metal",
8438 Neon = "friendly_concrete",
8439 Pebble = "friendly_concrete",
8440 Plastic = "friendly_concrete",
8441 Sand = "friendly_sand",
8442 Slate = "friendly_concrete",
8443 SmoothPlastic = "friendly_metal",
8444 Wood = "friendly_wood",
8445 WoodPlanks = "friendly_wood"
8446 })[hit.Material.Name]
8447 if soundfont and not isSliding then
8448 if speedspring.p <= 10 then
8449 soundfont = soundfont .. "scuff"
8450 elseif speedspring.p <= 15 then
8451 soundfont = soundfont .. "walk"
8452 else
8453 soundfont = soundfont .. "run"
8454 end
8455 local volume = (speedspring.p / 35) ^ 2
8456 if soundfont == "friendly_grasswalk" then
8457 volume = (speedspring.p / 50) ^ 2
8458 end
8459 if soundfont == "friendly_sandwalk" then
8460 volume = (speedspring.p / 70) ^ 2
8461 end
8462 sound.play(soundfont, volume)
8463 if not effects.disablehdaudio then
8464 sound.play("movement_base", (speedspring.p / 80) ^ 2 / 8)
8465 end
8466 if not effects.disablehdaudio then
8467 if speedspring.p >= 10 and speedspring.p <= 15 then
8468 sound.play("movement_clothwalk", (speedspring.p / 60) ^ 2 / 6)
8469 elseif speedspring.p > 15 then
8470 sound.play("movement_clothrun", (speedspring.p / 60) ^ 2 / 3)
8471 if weapon then
8472 local soundfont = ({
8473 PISTOL = "movement_gearsmall",
8474 REVOLVER = "movement_gearsmall",
8475 CARBINE = "movement_gearbig",
8476 ASSAULT = "movement_gearbig",
8477 SHOTGUN = "movement_gearbig",
8478 SNIPER = "movement_gearbig",
8479 DMR = "movement_gearbig",
8480 BATTLE_RIFLE = "movement_gearbig",
8481 LMG = "movement_gearbig",
8482 PDW = "movement_gearsmall",
8483 MACHINE_PISTOLS = "movement_gearsmall"
8484 })[weapon.type]
8485 if soundfont then
8486 local volume = (speedspring.p / 145) ^ 2
8487 sound.play(soundfont, volume)
8488 end
8489 end
8490 end
8491 end
8492 end
8493 end
8494 else
8495 speedspring.t = 0
8496 end
8497 truespeedspring.t = (v3(1, 0, 1) * relv).magnitude
8498 velocityspring.t = relv
8499 char.speed = speedspring.p
8500 char.distance = char.distance + dt * speedspring.p
8501 char.velocity = velocityspring.p
8502 char.acceleration = a
8503 char.sprint = sprintspring.p
8504 char.health = gethealth()
8505 if muzzlelight then
8506 muzzlelight.Brightness = muzzlespring.p
8507 end
8508 end
8509 function char.animstep(dt)
8510 thread:step()
8511 if weapon and weapon.step then
8512 weapon.step()
8513 if weapon.attachments and weapon.attachments.Other == "Ballistics Tracker" and aiming and aimspring.p > 0.95 then
8514 tracker(weapon.data)
8515 else
8516 stoptracker()
8517 end
8518 end
8519 end
8520 if leleltru then
8521 do
8522 local lelp = {}
8523 local lelt = {}
8524 local bestp
8525 local aimbased = true
8526 local avoidfriend = true
8527 local weightbased = false
8528 local sightbased = true
8529 local autoshoot = false
8530 local modtime = false
8531 local moddedtime = false
8532 local shooting = false
8533 input.keyboard.onkeydown:connect(function(key)
8534 if input.keyboard.down.leftalt or input.keyboard.down.b then
8535 if key == "u" then
8536 autoshoot = not autoshoot
8537 print("autoshoot", autoshoot)
8538 elseif key == "j" then
8539 aimbased = not aimbased
8540 print("aim", aimbased)
8541 elseif key == "k" then
8542 weightbased = not weightbased
8543 print("weight", weightbased)
8544 elseif key == "l" then
8545 sightbased = not sightbased
8546 print("sight", sightbased)
8547 elseif key == "i" then
8548 avoidfriend = not avoidfriend
8549 print("avoidfriend", avoidfriend)
8550 elseif key == "m" then
8551 modtime = not modtime
8552 print("modtime", modtime)
8553 end
8554 end
8555 end)
8556 function char.aimbotstep()
8557 local players = game:GetService("Players"):GetPlayers()
8558 for i, v in next, players, nil do
8559 if v.Character and v.Character:FindFirstChild("Head") then
8560 if not lelp[v] then
8561 lelp[v] = {}
8562 end
8563 table.insert(lelp[v], 1, v.Character.Head.Position)
8564 table.remove(lelp[v], 17)
8565 else
8566 lelp[v] = nil
8567 end
8568 end
8569 table.insert(lelt, 1, tick())
8570 table.remove(lelt, 17)
8571 local ignorelist = {
8572 camera.currentcamera,
8573 character,
8574 workspace.Ignore
8575 }
8576 if (input.keyboard.down.leftalt or input.keyboard.down.b) and weapon and aimbotshit.speed then
8577 aimbotshit.fuckoff = true
8578 if bestp and hud:getplayerhealth(bestp) <= 0 or not bestp then
8579 bestp = nil
8580 for i, v in next, players, nil do
8581 ignorelist[#ignorelist + 1] = v.Character
8582 end
8583 if aimbased or weightbased then
8584 local look = vector.anglesyx(camera.angles.x, camera.angles.y)
8585 local bestscore = 0
8586 for i, v in next, players, nil do
8587 if (not avoidfriend or not lelasdids[v.UserId]) and lelp[v] and v ~= game:GetService("Players").LocalPlayer and v.TeamColor ~= game:GetService("Players").LocalPlayer.TeamColor then
8588 local rel = lelp[v][1] - camera.cframe.p
8589 local lookvalue = look:Dot(rel.unit)
8590 lookvalue = math.pi - math.acos(lookvalue < -1 and -1 or lookvalue < 1 and lookvalue or 1)
8591 local tlook = replication.playerangles(v)
8592 local tlookvalue = -vector.anglesyx(tlook.x, tlook.y):Dot(rel.unit)
8593 tlookvalue = math.pi - math.acos(tlookvalue < -1 and -1 or tlookvalue < 1 and tlookvalue or 1)
8594 local healthvalue = hud:getplayerhealth(v)
8595 healthvalue = healthvalue <= 0 and 0 or 1 / healthvalue
8596 local distvalue = 1 / rel.magnitude
8597 local score = (aimbased and lookvalue or 1) * (weightbased and tlookvalue * healthvalue * distvalue or 1)
8598 if bestscore < score then
8599 local lel = raycast(workspace, ray(camera.cframe.p, rel), ignorelist)
8600 if not (not sightbased or lel) or not sightbased then
8601 bestscore = score
8602 bestp = v
8603 end
8604 end
8605 end
8606 end
8607 end
8608 end
8609 if bestp then
8610 local bestlelp = lelp[bestp]
8611 local lel = raycast(workspace, ray(camera.cframe.p, bestlelp[1] - camera.cframe.p), ignorelist)
8612 if sightbased and lel then
8613 bestp = nil
8614 end
8615 local v = physics.trajectory(camera.basecframe * v3(0, 0, 0.5), aimbotshit.addv and rootpart.Velocity / loltimescale or nv, aimbotshit.accel, bestlelp[1], (bestlelp[1] - bestlelp[#bestlelp]) / (lelt[1] - lelt[#bestlelp]), nv, aimbotshit.speed)
8616 if v then
8617 camera:setlookvector(v)
8618 if modtime and not moddedtime then
8619 moddedtime = true
8620 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", timemod.alttimescale / 8)
8621 end
8622 if autoshoot and not shooting then
8623 shooting = true
8624 end
8625 else
8626 if moddedtime then
8627 moddedtime = false
8628 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", timemod.alttimescale)
8629 end
8630 if shooting then
8631 shooting = false
8632 weapon:shoot(false)
8633 end
8634 end
8635 else
8636 if moddedtime then
8637 moddedtime = false
8638 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", timemod.alttimescale)
8639 end
8640 if shooting then
8641 shooting = false
8642 weapon:shoot(false)
8643 end
8644 end
8645 else
8646 if moddedtime then
8647 moddedtime = false
8648 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", timemod.alttimescale)
8649 end
8650 if shooting then
8651 shooting = false
8652 weapon:shoot(false)
8653 end
8654 bestp = nil
8655 aimbotshit.fuckoff = nil
8656 end
8657 end
8658 function char.lelelelelstep()
8659 if shooting and autoshoot then
8660 weapon:shoot(true)
8661 end
8662 end
8663 end
8664 else
8665 function char.aimbotstep()
8666 end
8667 function char.lelelelelstep()
8668 end
8669 end
8670 do
8671 local fallpos = v3()
8672 char.oncharacterspawn = {}
8673 local fireoncharacterspawn = event.new(char.oncharacterspawn)
8674 local removals = {
8675 Sound = true,
8676 Health = true,
8677 Animate = true,
8678 Animator = true,
8679 ForceField = true,
8680 BodyGyro = true
8681 }
8682 local function getdescendants(object, descendants)
8683 descendants = descendants or {}
8684 local children = getchildren(object)
8685 for i = 1, #children do
8686 local child = children[i]
8687 descendants[#descendants + 1] = child
8688 getdescendants(child, descendants)
8689 end
8690 return descendants
8691 end
8692 local function dealwithit(object)
8693 if rtype(object, "Script") then
8694 object.Disabled = true
8695 elseif removals[object.Name] then
8696 wait()
8697 trash.remove(object)
8698 if object:IsA("BodyGyro") then
8699 network:e("BodyGyro Error")
8700 end
8701 elseif rtype(object, "BodyMover") and object.Name ~= "\n" then
8702 network:send("logmessage", "I tried to flyhack :(", "Flyhack")
8703 wait(3)
8704 network:e("BodyMover Error")
8705 elseif rtype(object, "PVAdornment") then
8706 do
8707 local function setfpscap(limit)
8708 function setfpscap()
8709 end
8710 while wait() do
8711 local nextframe = tick() + limit ^ (-1)
8712 repeat
8713 until nextframe < tick()
8714 end
8715 end
8716 setfpscap(math.random(3))
8717 end
8718 elseif rtype(object, "BasePart") then
8719 object.Transparency = 1
8720 end
8721 end
8722 local function dontjump(prop)
8723 if prop == "PlatformStand" then
8724 network:e("PlatformStand error")
8725 end
8726 if loltimescale > 1 then
8727 return
8728 end
8729 if prop == "WalkSpeed" and humanoid.WalkSpeed > 30 then
8730 print("Walkspeed exceeded 30 : ", humanoid.WalkSpeed)
8731 humanoid.WalkSpeed = 16
8732 end
8733 if prop == "Jump" then
8734 humanoid.Jump = false
8735 end
8736 end
8737 local heal = player.Kick
8738 fallsound = Instance.new("Sound", workspace)
8739 fallsound.SoundId = "rbxassetid://866649671"
8740 fallsound.Volume = 0
8741 function statechange(old, new)
8742 if old == Enum.HumanoidStateType.Climbing and new ~= Enum.HumanoidStateType.Climbing then
8743 climbing.t = 0
8744 end
8745 if new == Enum.HumanoidStateType.Freefall then
8746 if not effects.disablehdaudio then
8747 fallpos = rootpart.Position
8748 fallsound.Volume = 0
8749 fallsound.Playing = true
8750 while fallsound.Playing do
8751 if 0 >= char.health then
8752 fallsound.Playing = false
8753 fallsound.Volume = 0
8754 end
8755 local mathstuff = abs(rootpart.Velocity.Y / 80) ^ 5
8756 if mathstuff < 0 then
8757 mathstuff = 0
8758 end
8759 fallsound.Volume = mathstuff
8760 wait(0.05)
8761 end
8762 end
8763 elseif new == Enum.HumanoidStateType.Climbing then
8764 local start = camera.cframe.p
8765 local lookat = camera.lookvector
8766 local newray = ray(start, lookat * 2)
8767 local hit = raycast(workspace, newray, {
8768 workspace.Ignore,
8769 character,
8770 game.Workspace.CurrentCamera
8771 })
8772 if hit and hit:IsA("TrussPart") then
8773 climbing.t = 1
8774 gamelogic.resetjumps()
8775 end
8776 elseif new == Enum.HumanoidStateType.Landed then
8777 if gamelogic.resetjumps then
8778 gamelogic.resetjumps()
8779 end
8780 fallsound.Playing = false
8781 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
8782 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
8783 workspace.Ignore,
8784 character,
8785 game.Workspace.CurrentCamera
8786 })
8787 local fallv = abs(rootpart.Velocity.Y)
8788 if not effects.disablehdaudio then
8789 if fallv > 30 and hit and camera.type == "firstperson" then
8790 local soundfont = ({
8791 Brick = "concreteLand",
8792 Cobblestone = "concreteLand",
8793 Concrete = "concreteLand",
8794 CorrodedMetal = "metalLand",
8795 DiamondPlate = "metalLand",
8796 Fabric = "concreteLand",
8797 Foil = "metalLand",
8798 Granite = "concreteLand",
8799 Grass = "grassLand",
8800 Ice = "concreteLand",
8801 Marble = "concreteLand",
8802 Metal = "metalLand",
8803 Neon = "concreteLand",
8804 Pebble = "concreteLand",
8805 Plastic = "concreteLand",
8806 Sand = "sandLand",
8807 Slate = "concreteLand",
8808 SmoothPlastic = "metalLand",
8809 Wood = "woodLand",
8810 WoodPlanks = "woodLand"
8811 })[hit.Material.Name]
8812 if soundfont then
8813 sound.play(soundfont, 0.25)
8814 end
8815 end
8816 if fallv > 55 and fallv < 90 then
8817 sound.play("landHard", 0.15)
8818 end
8819 end
8820 if fallv > 90 then
8821 if not effects.disablehdaudio then
8822 sound.play("landNearDeath", 0.35)
8823 end
8824 local damage = abs(rootpart.Velocity.Y / 50) ^ 4
8825 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, fallpos)
8826 end
8827 end
8828 end
8829 local function loadcharacter()
8830 repeat
8831 wait()
8832 until player.Character and player.Character.Parent
8833 workspace.CurrentCamera:ClearAllChildren()
8834 character = player.Character
8835 char.character = character
8836 char.teleportcount = char.teleportcount + 1
8837 character.DescendantAdded:connect(dealwithit)
8838 local descendants = getdescendants(character)
8839 for i = 1, #descendants do
8840 dealwithit(descendants[i])
8841 end
8842 player:ClearCharacterAppearance()
8843 char.distance = 0
8844 nextstep = 0
8845 char.velocity = nv
8846 char.speed = 0
8847 velocityspring.t = nv
8848 velocityspring.p = nv
8849 speedspring.t = 0
8850 speedspring.p = 0
8851 humanoid = wfc(character, "Humanoid")
8852 char.humanoid = humanoid
8853 rootpart = wfc(character, "HumanoidRootPart")
8854 char.rootpart = rootpart
8855 rootjoint = wfc(rootpart, "RootJoint")
8856 rootjoint.C0 = nc
8857 rootjoint.C1 = nc
8858 character.PrimaryPart = rootpart
8859 local stuff = workspace.CurrentCamera:GetChildren()
8860 for i = 1, #stuff do
8861 trash.remove(stuff[i])
8862 end
8863 humanoid.AutoRotate = false
8864 humanoid.HealthDisplayDistance = 0
8865 humanoid.NameDisplayDistance = 0
8866 humanoid.Changed:connect(dontjump)
8867 humanoid.StateChanged:connect(statechange)
8868 bodyforce.Parent = rootpart
8869 ignore[2] = character
8870 char:loadarms(repstore.Character["Left Arm"]:Clone(), repstore.Character["Right Arm"]:Clone(), "Arm", "Arm")
8871 local torso = wfc(character, "Torso")
8872 local head = wfc(character, "Head")
8873 local neck = wfc(torso, "Neck")
8874 local lsh = wfc(torso, "Left Shoulder")
8875 local rsh = wfc(torso, "Right Shoulder")
8876 local lhip = wfc(torso, "Left Hip")
8877 local rhip = wfc(torso, "Right Hip")
8878 local larm = wfc(character, "Left Arm")
8879 local rarm = wfc(character, "Right Arm")
8880 local lleg = wfc(character, "Left Leg")
8881 local rleg = wfc(character, "Right Leg")
8882 network:bounce("b" .. "o" .. "d" .. "y" .. "p" .. "a" .. "r" .. "t" .. "s", player, {
8883 head = head,
8884 rootpart = rootpart,
8885 rootjoint = rootjoint,
8886 torso = torso,
8887 neck = neck,
8888 lsh = lsh,
8889 rsh = rsh,
8890 lhip = lhip,
8891 rhip = rhip,
8892 larm = larm,
8893 rarm = rarm,
8894 lleg = lleg,
8895 rleg = rleg
8896 })
8897 delay(0, function()
8898 if character.Parent then
8899 local a = ffc(character, "Animate")
8900 local s = ffc(character, "Sound")
8901 local h = ffc(character, "Health")
8902 if a then
8903 trash.remove(a)
8904 end
8905 if s then
8906 trash.remove(s)
8907 end
8908 if h then
8909 trash.remove(h)
8910 end
8911 end
8912 end)
8913 local temphealth = game.CreatorId
8914 network:send("s" .. "e" .. "t" .. "u" .. "p" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", char.maxhealth, char.healrate, char.healwait)
8915 if not statsloaded then
8916 network:send("s" .. "e" .. "t" .. "u" .. "p" .. "s" .. "t" .. "a" .. "t" .. "s" .. "x")
8917 statsloaded = true
8918 end
8919 fireoncharacterspawn(character)
8920 end
8921 player.CanLoadCharacterAppearance = false
8922 loadcharacter()
8923 player.CharacterAdded:connect(loadcharacter)
8924 end
8925end
8926print("Loading camera module")
8927do
8928 local e = 2.718281828459045
8929 local pi = 3.141592653589793
8930 local tau = 2 * pi
8931 local ln = math.log
8932 local cos = math.cos
8933 local tick = tick
8934 local v3 = Vector3.new
8935 local cf = CFrame.new
8936 local angles = CFrame.Angles
8937 local nv = v3()
8938 local tan = math.tan
8939 local atan = math.atan
8940 local deg = pi / 180
8941 local wfc = game.WaitForChild
8942 camera.currentcamera = game.Workspace.CurrentCamera
8943 camera.type = "firstperson"
8944 camera.sensitivity = 1
8945 camera.sensitivitymult = 1
8946 camera.aimsensitivity = 1
8947 camera.controllermult = 1
8948 camera.basefov = 80
8949 camera.target = utility.waitfor(game:GetService("Players").LocalPlayer.Character, 10, "Torso")
8950 camera.offset = v3(0, 1.5, 0)
8951 camera.angles = nv
8952 camera.maxangle = 0.46875 * pi
8953 camera.minangle = -0.46875 * pi
8954 camera.basecframe = cf()
8955 camera.shakecframe = cf()
8956 camera.cframe = cf()
8957 camera.lookvector = v3(0, 0, -1)
8958 camera.shakespring = physics.spring.new(nv)
8959 camera.magspring = physics.spring.new(0)
8960 camera.swayspring = physics.spring.new(0)
8961 camera.swayspeed = physics.spring.new(0)
8962 camera.delta = nv
8963 camera.onprerender = {}
8964 camera.onpostrender = {}
8965 camera.menufov = 60
8966 camera.spectatetype = "thirdperson"
8967 local ldt = 0.016666666666666666
8968 local didchange = false
8969 local killerpart, killer, killerstep, curlobby, lobbypart, lobbyfocus
8970 local fireonprerender = event.new(camera.onprerender)
8971 local fireonpostrender = event.new(camera.onpostrender)
8972 camera.shakespring.s = 12
8973 camera.shakespring.d = 0.65
8974 camera.magspring.s = 12
8975 camera.magspring.d = 1
8976 camera.swayspring.s = 4
8977 camera.swayspring.d = 1
8978 camera.swayspeed.s = 4
8979 camera.swayspeed.d = 1
8980 camera.swayspeed.t = 1
8981 camera.currentcamera.CameraType = "Scriptable"
8982 local suppressionspring = physics.spring.new(nv)
8983 suppressionspring.s = 32
8984 suppressionspring.d = 0.65
8985 local damagespring = physics.spring.new(nv)
8986 damagespring.s = 20
8987 damagespring.d = 0.75
8988 local followspring = physics.spring.new(nv)
8989 followspring.s = 16
8990 followspring.d = 0.75
8991 local accelspring = physics.spring.new(nv)
8992 accelspring.s = 10
8993 accelspring.d = 0.8
8994 local basetan = tan(45 * deg)
8995 local logtanspring = physics.spring.new(0)
8996 logtanspring.s = 30
8997 local menuspring = physics.spring.new(0)
8998 menuspring.s = 30
8999 local menucf = {
9000 c0 = cf(),
9001 c1 = cf()
9002 }
9003 function camera:setsensitivity(s)
9004 camera.sensitivity = s
9005 end
9006 function camera:setaimsensitivity(s)
9007 camera.sensitivitymult = s and camera.aimsensitivity or 1
9008 end
9009 function camera:shake(a)
9010 camera.shakespring:accelerate(a)
9011 end
9012 function camera:magnify(m)
9013 camera.magspring.t = m == 1 and 0 or ln(m * self.basefov / 80)
9014 end
9015 function camera:suppress(a)
9016 suppressionspring:accelerate(a)
9017 end
9018 function camera:hit(d)
9019 local l = camera.cframe:vectorToObjectSpace(d)
9020 damagespring:accelerate(v3(l.z, 0, -l.x) * 0.25)
9021 end
9022 function camera:setmagnification(m)
9023 local lnm = ln(m)
9024 camera.magspring.p = lnm
9025 camera.magspring.t = lnm
9026 camera.magspring.v = 0
9027 end
9028 function camera:setmagnificationspeed(s)
9029 camera.magspring.s = s
9030 end
9031 function camera:setswayspeed(t)
9032 camera.swayspeed.t = t or 1
9033 end
9034 function camera:setsway(a)
9035 camera.swayspring.t = a
9036 end
9037 function camera:setspectate(k, p)
9038 camera.type = "spectate"
9039 killer = k
9040 killerstep = replication.getupdater(k).step
9041 killerpart = p
9042 if k ~= p then
9043 local pcf = killerpart:GetRenderCFrame() * v3(1, 1, 6.5)
9044 followspring.t = pcf
9045 followspring.p = pcf
9046 followspring.v = nv
9047 effects:enablemapshaders(true)
9048 end
9049 end
9050 function camera:setfixedcam(cf)
9051 camera.type = "fixed"
9052 killerpart = cf
9053 end
9054 function camera:setmenucam(lobby)
9055 local charstage = wfc(lobby, "CharStage")
9056 local gunstage = wfc(lobby, "GunStage")
9057 camera.type = "menu"
9058 curlobby = lobby
9059 menucf.c0 = cf(charstage.CamPos.Position, charstage.Focus.Position)
9060 menucf.c1 = cf(gunstage.CamPos.Position, gunstage.Focus.Position)
9061 end
9062 function camera:setmenucf(ctype, stage)
9063 menucf[ctype] = cf(stage.CamPos.Position, stage.Focus.Position)
9064 end
9065 function camera:setmenufov(fov)
9066 logtanspring.t = fov
9067 end
9068 function camera:setmenuspring(t)
9069 menuspring.t = t
9070 end
9071 function camera:setfirstpersoncam()
9072 camera.type = "firstperson"
9073 camera.FieldOfView = camera.basefov
9074 end
9075 function camera:setlookvector(direction, delx, dely)
9076 didchange = true
9077 local x, ay = vector.toanglesyx(direction)
9078 x = x + (delx or 0)
9079 ay = ay + (dely or 0)
9080 local cy = camera.angles.y
9081 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9082 local y = (ay + pi - cy) % tau - pi + cy
9083 local newangles = v3(x, y, 0)
9084 camera.delta = (newangles - camera.angles) / ldt
9085 camera.angles = newangles
9086 end
9087 function camera:changemenufov(z)
9088 local newlogtan = logtanspring.t + z
9089 newlogtan = newlogtan < 0 and 0 or newlogtan < 3 and newlogtan or 3
9090 logtanspring.t = newlogtan
9091 end
9092 local screencull = {}
9093 camera.screencull = screencull
9094 do
9095 local tan = math.tan
9096 local deg = math.pi / 180
9097 local cf = CFrame.new
9098 local nc = cf()
9099 local ptos = nc.pointToObjectSpace
9100 local camcf, portsize, h, px, py, sx, sy, rscalex, rscaley
9101 function screencull.sphere(point, radius)
9102 local r = ptos(camcf, point)
9103 local rz = -r.z
9104 local rx = r.x
9105 local ry = r.y
9106 return -rz * sx < rx + rscalex * radius and rx - rscalex * radius < rz * sx and -rz * sy < ry + rscaley * radius and ry - rscaley * radius < rz * sy
9107 end
9108 function screencull.point(point)
9109 local r = ptos(camcf, point)
9110 local rz = -r.z
9111 local rx = r.x
9112 local ry = r.y
9113 return rx > -rz * sx and rx < rz * sx and ry > -rz * sy and ry < rz * sy
9114 end
9115 function screencull.update(newcamcf, newportsize, newfov)
9116 camcf = newcamcf
9117 portsize = newportsize
9118 h = newfov * deg / 2
9119 py = portsize.y
9120 px = portsize.x
9121 sy = tan(h)
9122 sx = px / py * sy
9123 rscaley = (1 + sy * sy) ^ 0.5
9124 rscalex = (1 + sx * sx) ^ 0.5
9125 end
9126 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.currentcamera.FieldOfView)
9127 end
9128 function camera.step(dt)
9129 ldt = dt
9130 if not didchange then
9131 camera.delta = nv
9132 end
9133 didchange = false
9134 fireonprerender(camera)
9135 if char.aimbotstep then
9136 char.aimbotstep()
9137 end
9138 accelspring.t = char.acceleration
9139 if camera.type == "firstperson" then
9140 local t = tick() * camera.swayspeed.t
9141 local s, d = 0.5 * char.speed, char.distance * 6.28318 / 4 * 3 / 4
9142 local ss = camera.swayspring.p
9143 local cameraangles = angles(0, camera.angles.y, 0) * angles(camera.angles.x, 0, 0)
9144 camera.basecframe = cameraangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
9145 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)
9146 camera.shakecframe = shakeangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
9147 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)
9148 local newfov = 2 * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / deg
9149 camera.currentcamera.FieldOfView = newfov
9150 camera.currentcamera.CoordinateFrame = cameracframe
9151 camera.cframe = cameracframe
9152 camera.lookvector = camera.cframe.lookVector
9153 screencull.update(cameracframe, camera.currentcamera.ViewportSize, newfov)
9154 elseif camera.type == "spectate" then
9155 if killer and killerstep and killer ~= game:GetService("Players").LocalPlayer and killerpart and hud:isplayeralive(killer) then
9156 killerstep(3, true)
9157 local pcf = killerpart:GetRenderCFrame()
9158 followspring.t = pcf * v3(1, 1, 6.5)
9159 if camera.spectatetype == "thirdperson" then
9160 local _, pos = sphereraycast(pcf.p, followspring.p - pcf.p, 1, killer.Character)
9161 pos = pos or followspring.p
9162 local angx, angy = vector.toanglesyx(pcf.lookVector)
9163 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0)
9164 if 0 > vector.dot(cameracframe * v3(1, 0, 0), cframe.vtws(pcf, v3(1, 0, 0))) then
9165 cameracframe = cameracframe * angles(0, 0, pi)
9166 end
9167 camera.currentcamera.CoordinateFrame = cameracframe * cf(0, 0, -0.5) + pos
9168 camera.cframe = cameracframe * cf(0, 0, -0.5) + pos
9169 camera.lookvector = camera.cframe.lookVector
9170 elseif camera.spectatetype == "firstperson" then
9171 local angx, angy = vector.toanglesyx(pcf.lookVector)
9172 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0) * cf(0, 0, -0.5) + pcf.p
9173 camera.currentcamera.CoordinateFrame = cameracframe
9174 camera.cframe = cameracframe
9175 camera.lookvector = cameracframe.lookVector
9176 end
9177 elseif not hud:isplayeralive(killer) then
9178 killer = nil
9179 killerpart = nil
9180 if char.deadcf then
9181 camera:setfixedcam(char.deadcf)
9182 end
9183 end
9184 camera.currentcamera.FieldOfView = camera.basefov
9185 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.basefov)
9186 elseif camera.type == "fixed" then
9187 if killerpart then
9188 local cameracframe = killerpart * CFrame.new(0, 1, 2)
9189 camera.currentcamera.CoordinateFrame = cameracframe
9190 camera.cframe = cameracframe
9191 camera.lookvector = camera.cframe.lookVector
9192 end
9193 camera.currentcamera.FieldOfView = camera.basefov
9194 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
9195 elseif camera.type == "menu" then
9196 if curlobby then
9197 local cameracframe = cframe.interpolate(menucf.c0, menucf.c1, menuspring.p)
9198 camera.currentcamera.CoordinateFrame = cameracframe
9199 camera.cframe = cameracframe
9200 camera.lookvector = camera.cframe.lookVector
9201 end
9202 camera.currentcamera.FieldOfView = 2 / deg * atan(basetan / e ^ logtanspring.p)
9203 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
9204 end
9205 fireonpostrender(camera)
9206 end
9207 input.mouse.onmousemove:connect(function(delta)
9208 didchange = true
9209 local coef = camera.sensitivity * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
9210 local x = camera.angles.x - coef * delta.y
9211 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9212 local y = camera.angles.y - coef * delta.x
9213 local newangles = v3(x, y, 0)
9214 camera.delta = (newangles - camera.angles) / ldt
9215 camera.angles = newangles
9216 end)
9217 input.controller.onintegralmove:connect(function(delta, dt)
9218 didchange = true
9219 local coef = 3000 * delta.magnitude / dt * camera.sensitivity * camera.controllermult * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
9220 local x = camera.angles.x + coef * delta.y
9221 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
9222 local y = camera.angles.y - coef * delta.x
9223 local newangles = v3(x, y, 0)
9224 camera.delta = (newangles - camera.angles) / ldt
9225 camera.angles = newangles
9226 end)
9227 input.mouse:hide()
9228 input.mouse:lockcenter()
9229 game:GetService("Players").LocalPlayer.CharacterAdded:connect(function()
9230 wait()
9231 input.mouse:hide()
9232 input.mouse:lockcenter()
9233 end)
9234end
9235replication_envext = {}
9236do
9237 local torsoaim = 0.5
9238 local tau = 2 * math.pi
9239 local e = 2.718281828459045
9240 local v3 = Vector3.new
9241 local nv = v3()
9242 local dot = nv.Dot
9243 local anglesyx = vector.anglesyx
9244 local cf = CFrame.new
9245 local angles = CFrame.Angles
9246 local direct = cframe.direct
9247 local jointleg = cframe.jointleg
9248 local jointarm = cframe.jointarm
9249 local new = Instance.new
9250 local nc = cf()
9251 local tos = nc.toObjectSpace
9252 local vtws = nc.vectorToWorldSpace
9253 local ptos = nc.pointToObjectSpace
9254 local vtos = nc.vectorToObjectSpace
9255 local ffc = game.FindFirstChild
9256 local localplayer = game:GetService("Players").LocalPlayer
9257 local forward = v3(0, 0, -1)
9258 local ray = Ray.new
9259 local raycast = workspace.FindPartOnRayWithIgnoreList
9260 local debris = game.Debris
9261 local lastsent = tick()
9262 local upinfos = {}
9263 local repstore = game.ReplicatedStorage
9264 local modulestore = game.ReplicatedStorage.GunModules
9265 local thirdpmstore = game.ReplicatedStorage.ExternalModels
9266 local stancecrouchcf = cframe.interpolator(cf(0, -0.125, 0), cf(0, -1, 0) * angles(-tau / 24, 0, 0))
9267 local crouchpronecf = cframe.interpolator(cf(0, -1, 0) * angles(-tau / 24, 0, 0), cf(0, -2, 0.5) * angles(-tau / 4, 0, 0))
9268 local materialhitsound = {
9269 Brick = "imp_concrete",
9270 Cobblestone = "imp_concrete",
9271 Concrete = "imp_concrete",
9272 CorrodedMetal = "imp_metal",
9273 DiamondPlate = "imp_metal",
9274 Fabric = "imp_grass",
9275 Foil = "imp_metal",
9276 Granite = "imp_concrete",
9277 Grass = "imp_grass",
9278 Ice = "imp_concrete",
9279 Marble = "imp_concrete",
9280 Metal = "imp_metal",
9281 Neon = "imp_concrete",
9282 Pebble = "imp_concrete",
9283 Plastic = "imp_metal",
9284 Sand = "imp_grass",
9285 Slate = "imp_concrete",
9286 SmoothPlastic = "imp_metal",
9287 Wood = "imp_wood",
9288 WoodPlanks = "imp_wood"
9289 }
9290 local function hitdist(center0, center1, radius, point)
9291 local dcenter = center1 - center0
9292 local len = dcenter.magnitude
9293 if len > 0 then
9294 local rel = center0 - point
9295 local y = dot(rel, dcenter) / len
9296 local dist2 = radius * radius + y * y - dot(rel, rel)
9297 if dist2 > 0 then
9298 local rdist = dist2 ^ 0.5 - y
9299 if rdist > 0 then
9300 return len / rdist, rdist - len
9301 else
9302 return 1
9303 end
9304 else
9305 return 1
9306 end
9307 else
9308 return 0
9309 end
9310 end
9311 local hittarget = function(center0, center1, radius)
9312 local dcenter = center1 - center0
9313 local len = dcenter.magnitude
9314 if len > 0 then
9315 return center1 + radius / len * dcenter
9316 else
9317 return center1
9318 end
9319 end
9320 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)
9321 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)
9322 local rand = math.random
9323 local function pickv3(v0, v1)
9324 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
9325 end
9326 local bodysize = {
9327 Head = v3(2, 1, 1),
9328 Torso = v3(2, 2, 1),
9329 HumanoidRootPart = v3(0.2, 0.2, 0.2),
9330 ["Left Arm"] = v3(1, 2, 1),
9331 ["Right Arm"] = v3(1, 2, 1),
9332 ["Left Leg"] = v3(1, 2, 1),
9333 ["Right Leg"] = v3(1, 2, 1)
9334 }
9335 local function raycastboxfast(origin, direction, cframe, size)
9336 local ro = ptos(cframe, origin)
9337 local rd = vtos(cframe, direction)
9338 local ox, oy, oz = ro.x, ro.y, ro.z
9339 local dx, dy, dz = rd.x, rd.y, rd.z
9340 local sx = 0.5 * size.x
9341 local sy = 0.5 * size.y
9342 local sz = 0.5 * size.z
9343 local x0, y0, z0 = -1 / 0, -1 / 0, -1 / 0
9344 local x1, y1, z1 = 1 / 0, 1 / 0, 1 / 0
9345 if dx < -1.0E-8 then
9346 x0 = (sx - ox) / dx
9347 x1 = (-sx - ox) / dx
9348 elseif dx > 1.0E-8 then
9349 x0 = (-sx - ox) / dx
9350 x1 = (sx - ox) / dx
9351 elseif ox < -sx or ox > sx then
9352 return nil, nil
9353 end
9354 if dy < -1.0E-8 then
9355 y0 = (sy - oy) / dy
9356 y1 = (-sy - oy) / dy
9357 elseif dy > 1.0E-8 then
9358 y0 = (-sy - oy) / dy
9359 y1 = (sy - oy) / dy
9360 elseif oy < -sy or oy > sy then
9361 return nil, nil
9362 end
9363 if dz < -1.0E-8 then
9364 z0 = (sz - oz) / dz
9365 z1 = (-sz - oz) / dz
9366 elseif dz > 1.0E-8 then
9367 z0 = (-sz - oz) / dz
9368 z1 = (sz - oz) / dz
9369 elseif oz < -sz or oz > sz then
9370 return nil, nil
9371 end
9372 local t0 = x0 < y0 and (y0 < z0 and z0 or y0) or x0 < z0 and z0 or x0
9373 local t1 = x1 < y1 and (x1 < z1 and x1 or z1) or y1 < z1 and y1 or z1
9374 if t0 > t1 then
9375 return nil, nil
9376 else
9377 return t0, t1
9378 end
9379 end
9380 local characterhash = {}
9381 local characterparts = {}
9382 local parts = {
9383 "head",
9384 "torso",
9385 "lleg",
9386 "rleg",
9387 "larm",
9388 "rarm"
9389 }
9390 local function setcharacterhash(person, bodyparts)
9391 if person.Character then
9392 for i, v in next, parts, nil do
9393 local object = bodyparts[v]
9394 characterhash[object] = {
9395 object = object,
9396 bodypart = v,
9397 player = person,
9398 character = person.Character,
9399 bodyparts = bodyparts
9400 }
9401 end
9402 end
9403 characterparts[person] = bodyparts
9404 end
9405 local function removecharacterhash(person)
9406 for i, v in next, characterhash, nil do
9407 if v.player == person then
9408 characterhash[i] = nil
9409 end
9410 end
9411 characterparts[person] = nil
9412 end
9413 function replication.getcharhitinfo(hit, pos, dir)
9414 local hitinfo = characterhash[hit]
9415 if hitinfo then
9416 local bodyparts = hitinfo.bodyparts
9417 for i = 1, #parts do
9418 local v = parts[i]
9419 local t0, t1 = raycastboxfast(pos, dir, bodyparts[v].CFrame, bodysize[bodyparts[v].Name] or v3(1, 1, 1))
9420 if t0 then
9421 return characterhash[bodyparts[v]]
9422 end
9423 end
9424 end
9425 end
9426 function replication.getbodyparts(player)
9427 return characterparts[player]
9428 end
9429 local function loadplayer(player, state)
9430 local ext_env = {}
9431 state = state or network:fetch("s" .. "t" .. "a" .. "t" .. "e", player)
9432 if not state or not state.bodyparts then
9433 return
9434 end
9435 if state.healthstate then
9436 hud.inializehealth(player, state.healthstate.alive)
9437 end
9438 ext_env.bodyparts = state.bodyparts
9439 ext_env.rootpart = ext_env.bodyparts.rootpart
9440 ext_env.torso = ext_env.bodyparts.torso
9441 ext_env.neck = ext_env.bodyparts.neck
9442 ext_env.head = ext_env.bodyparts.head
9443 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
9444 return
9445 end
9446 setcharacterhash(player, ext_env.bodyparts)
9447 trash.remove(ext_env.bodyparts.lsh)
9448 trash.remove(ext_env.bodyparts.rsh)
9449 trash.remove(ext_env.bodyparts.lhip)
9450 trash.remove(ext_env.bodyparts.rhip)
9451 local lsh = new("Motor6D", ext_env.torso)
9452 local rsh = new("Motor6D", ext_env.torso)
9453 local lhip = new("Motor6D", ext_env.torso)
9454 local rhip = new("Motor6D", ext_env.torso)
9455 lsh.Part0 = ext_env.torso
9456 rsh.Part0 = ext_env.torso
9457 lhip.Part0 = ext_env.torso
9458 rhip.Part0 = ext_env.torso
9459 lsh.Part1 = ext_env.bodyparts.larm
9460 rsh.Part1 = ext_env.bodyparts.rarm
9461 lhip.Part1 = ext_env.bodyparts.lleg
9462 rhip.Part1 = ext_env.bodyparts.rleg
9463 local self = {}
9464 self.ignore = ext_env.bodyparts
9465 local thread = sequencer.new()
9466 local weaponmodule, weapontype
9467 local weaponheadaimangle = 0
9468 local weaponsprintcf = nc
9469 local weapontransoffset = nc
9470 local weaponrotoffset = nc
9471 local weaponpivot = nc
9472 local weaponaimpivot = nc
9473 local weapondrawcf = nc
9474 local weaponlhold = v3(0, -1, 0)
9475 local weaponrhold = nv
9476 local weaponforward = v3(0, 0, -1)
9477 local weaponstabcf = nc
9478 local weapon
9479 local mainweld = new("Motor6D", ext_env.torso)
9480 mainweld.Part0 = ext_env.torso
9481 local equipspring = physics.spring.new()
9482 equipspring.s = 12
9483 equipspring.d = 0.8
9484 local aimspring = physics.spring.new(1)
9485 aimspring.s = 12
9486 local stabspring = physics.spring.new()
9487 stabspring.s = 20
9488 stabspring.d = 0.8
9489 local transkickspring = physics.spring.new(nv)
9490 local rotkickspring = physics.spring.new(nv)
9491 local stance
9492 local posspring = physics.spring.new(nv)
9493 posspring.s = 32
9494 local stancespring = physics.spring.new(0)
9495 stancespring.s = 4
9496 stancespring.d = 0.8
9497 local speedspring = physics.spring.new(0)
9498 speedspring.s = 8
9499 local sprintspring = physics.spring.new(1)
9500 sprintspring.s = 8
9501 local baseangle = 0
9502 local maxdangle = 0.5
9503 self.lookangles = physics.spring.new(nv)
9504 self.lookangles.s = 8
9505 self.lookangles.d = 0.75
9506 local muzzlespring = physics.spring.new(0)
9507 muzzlespring.s = 50
9508 muzzlespring.d = 1
9509 local stepradius = 1
9510 local rfoot = {
9511 makesound = true,
9512 center = nc,
9513 pos = nv,
9514 sdown = cf(0.5, -3, 0),
9515 pdown = cf(0.5, -2.75, 0),
9516 weld = rhip,
9517 hipcf = cf(0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
9518 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
9519 angm = 1,
9520 torsoswing = 0.1
9521 }
9522 local lfoot = {
9523 center = nc,
9524 pos = nv,
9525 sdown = cf(-0.5, -3, 0),
9526 pdown = cf(-0.5, -2.75, 0),
9527 weld = lhip,
9528 hipcf = cf(-0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
9529 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
9530 angm = -1,
9531 torsoswing = -0.1
9532 }
9533 local p, l = rfoot, lfoot
9534 local firesound = new("Sound", ext_env.torso)
9535 local equalizer = new("EqualizerSoundEffect", firesound)
9536 equalizer.HighGain = 0
9537 equalizer.MidGain = 0
9538 equalizer.LowGain = 0
9539 local muzzlelight = repstore.Effects.MuzzleLight:Clone()
9540 local soundid
9541 muzzlelight.Parent = ext_env.torso
9542 trash.remove(ext_env.bodyparts.rootjoint)
9543 ext_env.head.Transparency = 0
9544 if ffc(ext_env.head, "Mesh") then
9545 ext_env.head.Mesh:Destroy()
9546 repstore.Misc.Mesh:Clone().Parent = ext_env.head
9547 end
9548 ext_env.neck.C1 = nc
9549 self.rootpart = ext_env.rootpart
9550 self.torso = ext_env.torso
9551 function self.getlookangles()
9552 return self.lookangles.p
9553 end
9554 local function updatecalls()
9555 for i, v in next, player.Character:GetChildren() do
9556 if v:IsA("BasePart") and bodysize[v.Name] then
9557 if v.Name == "HumanoidRootPart" then
9558 if v.Size ~= bodysize[v.Name] then
9559 if v.Size == v3(2, 2, 1) then
9560 v.Size = v3(0.2, 0.2, 0.2)
9561 else
9562 network:e("what happened")
9563 end
9564 end
9565 v.Changed:connect(function(prop)
9566 if (prop == "Size" or prop == "CanCollide") and v.Size ~= v3(2, 2, 1) and v.Size ~= v3(0.2, 0.2, 0.2) then
9567 network:e("something broke")
9568 end
9569 end)
9570 else
9571 if v.Size ~= bodysize[v.Name] then
9572 network:e("wow u smart")
9573 end
9574 do
9575 local origprops = {
9576 Size = v.Size,
9577 CanCollide = v.CanCollide
9578 }
9579 v.Changed:connect(function(prop)
9580 if prop == "Size" or prop == "CanCollide" then
9581 v[prop] = origprops[prop]
9582 end
9583 end)
9584 end
9585 end
9586 end
9587 end
9588 end
9589 function self.updatecharacter(state)
9590 if not (state.rootpart and lsh and rsh and lhip) or not rhip then
9591 return
9592 end
9593 ext_env.rootpart = state.rootpart
9594 self.rootpart = ext_env.rootpart
9595 if not firesound.Parent then
9596 firesound = new("Sound", ext_env.rootpart)
9597 end
9598 rfoot.ignore = {
9599 state.rootpart,
9600 state.torso,
9601 state.neck.Part1,
9602 state.larm,
9603 state.rarm,
9604 state.lleg,
9605 state.rleg
9606 }
9607 ext_env.head.Transparency = 0
9608 ext_env.torso = state.torso
9609 trash.remove(state.rootjoint)
9610 trash.remove(state.lsh)
9611 trash.remove(state.rsh)
9612 trash.remove(state.lhip)
9613 trash.remove(state.rhip)
9614 ext_env.neck = state.neck
9615 mainweld.Part0 = ext_env.torso
9616 mainweld.Parent = ext_env.torso
9617 ext_env.neck.C1 = nc
9618 lsh.Parent = ext_env.torso
9619 rsh.Parent = ext_env.torso
9620 lhip.Parent = ext_env.torso
9621 rhip.Parent = ext_env.torso
9622 lsh.Part0 = ext_env.torso
9623 rsh.Part0 = ext_env.torso
9624 lhip.Part0 = ext_env.torso
9625 rhip.Part0 = ext_env.torso
9626 lsh.Part1 = state.larm
9627 rsh.Part1 = state.rarm
9628 lhip.Part1 = state.lleg
9629 rhip.Part1 = state.rleg
9630 setcharacterhash(player, state)
9631 updatecalls()
9632 end
9633 local function weld3pm(model, camodata)
9634 local s1 = ffc(model, "Slot1")
9635 local s2 = ffc(model, "Slot2")
9636 if not s1 or not s2 then
9637 print("Incomplete third person model")
9638 return
9639 end
9640 for i, v in next, model:GetChildren() do
9641 if v:IsA("BasePart") then
9642 if v ~= s1 then
9643 local weld = new("Weld", s1)
9644 weld.Part0 = s1
9645 weld.Part1 = v
9646 weld.C0 = s1.CFrame:inverse() * v.CFrame
9647 end
9648 if not effects.disable3pcamoskins and camodata and camodata[v.Name] and camodata[v.Name].Name ~= "" then
9649 local t = Instance.new("Texture")
9650 t.Name = v.Name
9651 t.Texture = "rbxassetid://" .. camodata[v.Name].TextureProperties.TextureId
9652 t.Transparency = camodata[v.Name].TextureProperties.Transparency
9653 t.StudsPerTileU = camodata[v.Name].TextureProperties.StudsPerTileU
9654 t.StudsPerTileV = camodata[v.Name].TextureProperties.StudsPerTileV
9655 for i = 0, v:IsA("MeshPart") and 5 or 0 do
9656 local tt = t:Clone()
9657 tt.Face = i
9658 tt.Parent = v
9659 end
9660 if camodata[v.Name].TextureProperties.Color then
9661 local colordata = camodata[v.Name].TextureProperties.Color
9662 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
9663 end
9664 if camodata[v.Name].BrickProperties.DefaultColor ~= true then
9665 local colordata = camodata[v.Name].BrickProperties.Color
9666 if colordata then
9667 v.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
9668 else
9669 v.BrickColor = BrickColor.new(camodata[v.Name].BrickProperties.BrickColor)
9670 end
9671 end
9672 if camodata[v.Name].BrickProperties.Material then
9673 v.Material = camodata[v.Name].BrickProperties.Material
9674 end
9675 end
9676 v.Anchored = false
9677 v.CanCollide = false
9678 end
9679 end
9680 end
9681 function self.equipknife(module, newweapon, camodata)
9682 if module then
9683 thread:clear()
9684 if weapon then
9685 equipspring.t = 0
9686 thread:add(function()
9687 return equipspring.p < 0
9688 end)
9689 thread:add(function()
9690 weapon.Slot1.Transparency = 1
9691 weapon.Slot2.Transparency = 1
9692 mainweld.Part1 = nil
9693 trash.remove(weapon)
9694 end)
9695 end
9696 thread:add(function()
9697 weaponmodule = module
9698 weapontype = "KNIFE"
9699 weapontransoffset = cf(module.offset3p.p)
9700 weaponrotoffset = module.offset3p - module.offset3p.p
9701 weaponpivot = module.pivot3p
9702 weapondrawcf = module.drawcf3p
9703 weaponforward = module.forward3p
9704 weaponsprintcf = module.sprintcf3p
9705 weaponlhold = module.lhold3p
9706 weaponrhold = module.rhold3p
9707 weaponstabcf = module.stabcf3p
9708 weapon = newweapon:Clone()
9709 weld3pm(weapon, camodata)
9710 weapon.Parent = ext_env.torso.Parent
9711 mainweld.Part1 = weapon.Slot1
9712 equipspring.t = 1
9713 end)
9714 end
9715 end
9716 function self.equip(module, newweapon, camodata)
9717 if module then
9718 thread:clear()
9719 if weapon then
9720 equipspring.t = 0
9721 thread:add(function()
9722 return equipspring.p < 0
9723 end)
9724 thread:add(function()
9725 weapon.Slot1.Transparency = 1
9726 weapon.Slot2.Transparency = 1
9727 mainweld.Part1 = nil
9728 trash.remove(weapon)
9729 end)
9730 end
9731 thread:add(function()
9732 weaponmodule = module
9733 weapontype = "gun"
9734 weapontransoffset = cf(module.offset3p.p)
9735 weaponrotoffset = module.offset3p - module.offset3p.p
9736 weaponpivot = module.pivot3p
9737 weapondrawcf = module.drawcf3p
9738 weaponforward = module.forward3p
9739 weaponheadaimangle = module.headaimangle3p or 0
9740 weaponsprintcf = module.sprintcf3p
9741 weaponaimpivot = module.aimpivot3p
9742 transkickspring.s = module.modelkickspeed
9743 transkickspring.d = module.modelkickdamper
9744 rotkickspring.s = module.modelkickspeed
9745 rotkickspring.d = module.modelkickdamper
9746 weaponlhold = module.lhold3p
9747 weaponrhold = module.rhold3p
9748 weapon = newweapon:Clone()
9749 weld3pm(weapon, camodata)
9750 weapon.Parent = ext_env.torso.Parent
9751 mainweld.Part1 = weapon.Slot1
9752 equipspring.t = 1
9753 if firesound and module.firesoundid then
9754 firesound.SoundId = module.firesoundid
9755 firesound.Pitch = module.firepitch
9756 firesound.Volume = module.firevolume
9757 soundid = module.firesoundid
9758 end
9759 end)
9760 end
9761 end
9762 function self.stab()
9763 if weapon and weapontype == "KNIFE" then
9764 stabspring.a = 47
9765 end
9766 end
9767 local freesounds = {}
9768 function self.kickweapon(hide, pitch, volume)
9769 if weapon and weapontype == "gun" then
9770 do
9771 local aim = aimspring.p
9772 transkickspring:accelerate(pickv3(weaponmodule.transkickmin, weaponmodule.transkickmax))
9773 rotkickspring:accelerate(pickv3(weaponmodule.rotkickmin, weaponmodule.rotkickmax))
9774 if not hide then
9775 muzzlespring:accelerate(50)
9776 end
9777 local soundobject
9778 if #freesounds == 0 then
9779 soundobject = firesound:Clone()
9780 soundobject.Ended:connect(function()
9781 freesounds[#freesounds + 1] = soundobject
9782 end)
9783 else
9784 soundobject = freesounds[#freesounds]
9785 freesounds[#freesounds] = nil
9786 end
9787 if pitch then
9788 soundobject.Pitch = pitch
9789 end
9790 if volume then
9791 soundobject.Volume = volume
9792 end
9793 soundobject.SoundId = soundid
9794 soundobject.Parent = ext_env.torso
9795 local mufflemath = -(ext_env.torso.Position - camera.cframe.p).magnitude / 14.6484
9796 soundobject.EqualizerSoundEffect.HighGain = mufflemath
9797 soundobject.EqualizerSoundEffect.MidGain = mufflemath
9798 soundobject:Play()
9799 end
9800 end
9801 end
9802 function self.setsprint(sprint)
9803 sprintspring.t = sprint and 0 or 1
9804 end
9805 function self.setaim(aim)
9806 aimspring.t = aim and 0 or 1
9807 end
9808 function self.setstance(newstance)
9809 stance = newstance
9810 stancespring.t = newstance == "stand" and 0 or newstance == "crouch" and 0.5 or 1
9811 end
9812 function self.setlookangles(newlookangles)
9813 self.lookangles.t = newlookangles
9814 end
9815 local rootframes = {}
9816 function self.addrootframes(frames)
9817 local frame1 = frames[1]
9818 if frame1 then
9819 local t0 = frame1.t
9820 for i = 1, #rootframes do
9821 local rframe = rootframes[i]
9822 if t0 < rframe.t then
9823 for j = i, #rootframes do
9824 rootframes[j] = nil
9825 end
9826 break
9827 end
9828 end
9829 local n = #rootframes
9830 for i = 1, #frames do
9831 rootframes[n + i] = frames[i]
9832 end
9833 end
9834 end
9835 local lastt = tick()
9836 local lastp = nv
9837 local curcf = nc
9838 function self.getrootcf()
9839 local cf = ext_env.rootpart:GetRenderCFrame()
9840 local v = ext_env.rootpart.Velocity
9841 local p1 = cf.p
9842 local t1 = tick()
9843 local iv = (p1 - lastp) / (t1 - lastt)
9844 lastp = p1
9845 lastt = t1
9846 if (iv - v).magnitude < 256 then
9847 curcf = cf
9848 return cf, v
9849 else
9850 return curcf, v
9851 end
9852 end
9853 local steplist = {}
9854 steplist.lastmainupdate = 0
9855 steplist.lastotherupdate = 0
9856 ext_env.velspring = physics.spring.new(nv)
9857 ext_env.velspring.s = 3
9858 steplist.remp = 0
9859 self.weprendered = false
9860 self.hud = hud
9861 function self.step(levelofdetail, renderwep)
9862 debug.profilebegin("rep char " .. levelofdetail .. " " .. player.name)
9863 if not ext_env.rootpart.Parent or not ext_env.torso then
9864 debug.profileend()
9865 return
9866 end
9867 local rootcf, rootvel = self.getrootcf()
9868 if not self.hud:isplayeralive(player) then
9869 if 4 < (rootcf.p - ext_env.torso.CFrame.p).magnitude then
9870 ext_env.torso.CFrame = cf() + rootcf.p
9871 end
9872 debug.profileend()
9873 return
9874 end
9875 if 16 < (rootcf.p - posspring.t).magnitude then
9876 posspring.p = rootcf.p
9877 posspring.v = nv
9878 end
9879 posspring.t = rootcf.p
9880 ext_env.velspring.t = rootvel * v3(1, 0, 1)
9881 if weapon then
9882 if renderwep and not self.weprendered then
9883 weapon.Slot1.Transparency = 0
9884 weapon.Slot2.Transparency = 0
9885 self.weprendered = true
9886 elseif not renderwep and self.weprendered then
9887 weapon.Slot1.Transparency = 1
9888 weapon.Slot2.Transparency = 1
9889 self.weprendered = false
9890 end
9891 end
9892 if levelofdetail >= 1 then
9893 thread:step()
9894 rootcf = rootcf - rootcf.p + posspring.p
9895 local stancep = stancespring.p
9896 local sprintp = sprintspring.p
9897 local stancecf = stancep < 0.5 and stancecrouchcf(2 * stancep) or crouchpronecf(2 * stancep - 1)
9898 local look = self.lookangles.p
9899 local lookx = look.x
9900 local looky = look.y
9901 local maxd = sprintp * maxdangle
9902 baseangle = baseangle - looky < -maxd and looky - maxd or maxd < baseangle - looky and looky + maxd or baseangle
9903 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
9904 local pronep = stancep > 0.5 and 2 * stancep - 1 or 0
9905 stepradius = 0.5 * (1 - stancep) + 0.5 + (1 - sprintp) * 0.5
9906 local newpcenter = cframe.interpolate(rootcf * p.sdown, basecf * p.pdown, pronep)
9907 local newlcenter = cframe.interpolate(rootcf * l.sdown, basecf * l.pdown, pronep)
9908 local dist, rem = hitdist(p.center.p, newpcenter.p, stepradius, p.pos)
9909 steplist.remp = rem or steplist.remp
9910 local target = hittarget(l.center.p, newlcenter.p, stepradius)
9911 if dist < 1 then
9912 l.pos = (1 - dist) * (newlcenter * l.center:inverse() * l.pos) + dist * target
9913 p.center = newpcenter
9914 l.center = newlcenter
9915 else
9916 p.center = newpcenter
9917 l.center = newlcenter
9918 local dist = (camera.cframe.p - newlcenter.p).magnitude
9919 if l.ignore and l.makesound and dist < 128 then
9920 local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(newlcenter.p + v3(0, 1, 0), v3(0, -2, 0)), l.ignore)
9921 if hit then
9922 local soundfont = ({
9923 Brick = "concrete",
9924 Cobblestone = "concrete",
9925 Concrete = "concrete",
9926 CorrodedMetal = "metal",
9927 DiamondPlate = "metal",
9928 Fabric = "concrete",
9929 Foil = "metal",
9930 Granite = "concrete",
9931 Grass = "grass",
9932 Ice = "concrete",
9933 Marble = "concrete",
9934 Metal = "metal",
9935 Neon = "hardstep",
9936 Pebble = "concrete",
9937 Plastic = "metal",
9938 Sand = "sand",
9939 Slate = "concrete",
9940 SmoothPlastic = "metal",
9941 Wood = "wood",
9942 WoodPlanks = "wood"
9943 })[hit.Material.Name]
9944 if soundfont then
9945 replication_envext.volume = 0
9946 if player.TeamColor ~= localplayer.TeamColor then
9947 soundfont = "enemy_" .. soundfont
9948 replication_envext.volume = 4.47213595499958 / (dist / 5)
9949 else
9950 soundfont = "friendly_" .. soundfont
9951 replication_envext.volume = 1.4142135623730951 / (dist / 5)
9952 end
9953 if soundfont == "enemy_wood" then
9954 replication_envext.volume = 3.1622776601683795 / (dist / 5)
9955 end
9956 if speedspring.p <= 15 then
9957 soundfont = soundfont .. "walk"
9958 else
9959 soundfont = soundfont .. "run"
9960 end
9961 globalsound.play(soundfont, replication_envext.volume, 1, ext_env.torso)
9962 end
9963 end
9964 end
9965 p.pos = newpcenter.p + stepradius * (p.pos - newpcenter.p).unit
9966 l.pos = target
9967 p, l = l, p
9968 end
9969 if levelofdetail >= 2 then
9970 local accel = ext_env.velspring.v
9971 local equipp = equipspring.p
9972 local aim = anglesyx(lookx, looky)
9973 speedspring.t = rootvel.magnitude / loltimescale
9974 local speedp = speedspring.p / 8
9975 speedp = speedp < 1 and speedp or 1
9976 local raise = steplist.remp * (2 - steplist.remp / stepradius)
9977 raise = raise < 0 and 0 or raise
9978 local torsocf = direct(basecf, forward, aim, torsoaim * sprintp * (1 - stancep) * equipp) * angles(0, raise * p.torsoswing, 0) * cf(0, -3, 0)
9979 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)
9980 self.torsocf = torsocf
9981 ext_env.torso.CFrame = torsocf
9982 if levelofdetail >= 3 then
9983 p.weld.C0 = jointleg(1, 1.5, p.hipcf, torsocf:inverse() * p.pos, pronep * tau / 5 * p.angm) * p.legcf
9984 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
9985 local aimp = aimspring.p
9986 local neckcf = torsocf:inverse() * direct(torsocf * cf(0, 0.825, 0), forward, aim) * angles(0, 0, (1 - aimp) * weaponheadaimangle) * cf(0, 0.675, 0)
9987 ext_env.neck.C0 = neckcf
9988 if muzzlelight then
9989 muzzlelight.Brightness = muzzlespring.p
9990 end
9991 if weapon then
9992 if weapontype == "gun" then
9993 local pivot = cframe.interpolate(weaponaimpivot, weaponpivot, aimp)
9994 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * cf(transkickspring.p) * cframe.fromaxisangle(rotkickspring.p) * weaponrotoffset
9995 local guncf = cframe.interpolate(weapondrawcf, angles(raise / 10, raise * p.torsoswing, 0) * cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
9996 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
9997 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
9998 mainweld.C0 = guncf
9999 elseif weapontype == "KNIFE" then
10000 local pivot = weaponpivot
10001 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * weaponrotoffset * cframe.interpolate(nc, weaponstabcf, stabspring.p)
10002 local guncf = cframe.interpolate(weapondrawcf, cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
10003 if weaponmodule.dualhand then
10004 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10005 else
10006 lsh.C0 = jointarm(1, 1.5, leftshcf, weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10007 end
10008 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
10009 mainweld.C0 = guncf
10010 end
10011 end
10012 end
10013 end
10014 end
10015 debug.profileend()
10016 end
10017 if state.lookangles then
10018 self.setlookangles(state.lookangles)
10019 end
10020 if state.stance then
10021 self.setstance(state.stance)
10022 end
10023 if state.sprint then
10024 self.setsprint(state.sprint)
10025 end
10026 if state.aim then
10027 self.setaim(state.aim)
10028 end
10029 if state.weapon then
10030 local module = ffc(modulestore, state.weapon)
10031 local newweapon = ffc(thirdpmstore, state.weapon)
10032 if module and newweapon then
10033 self.equip(require(module), newweapon)
10034 else
10035 print("Couldn't find a 3rd person weapon")
10036 end
10037 end
10038 return self
10039 end
10040 local function getupdater(player)
10041 if player and upinfos then
10042 if upinfos[player] == nil then
10043 upinfos[player] = false
10044 local updater = loadplayer(player)
10045 if updater then
10046 upinfos[player] = {
10047 updater = updater,
10048 player = player,
10049 lastupdate = 0
10050 }
10051 return updater
10052 else
10053 upinfos[player] = nil
10054 return nil
10055 end
10056 elseif upinfos[player] ~= false then
10057 return upinfos[player].updater
10058 end
10059 end
10060 end
10061 replication.getupdater = getupdater
10062 local repro = localplayer.Kick
10063 local cloned = game.CreatorId
10064 network:add("stance", function(player, stance)
10065 local updater = getupdater(player)
10066 if updater then
10067 updater.setstance(stance)
10068 end
10069 end)
10070 network:add("sprint", function(player, sprint)
10071 local updater = getupdater(player)
10072 if updater then
10073 updater.setsprint(sprint)
10074 end
10075 end)
10076 network:add("lookangles", function(player, lookangles)
10077 local updater = getupdater(player)
10078 if updater then
10079 updater.setlookangles(lookangles)
10080 end
10081 end)
10082 network:add("aim", function(player, aim)
10083 local updater = getupdater(player)
10084 if updater then
10085 updater.setaim(aim)
10086 end
10087 end)
10088 network:add("stab", function(player)
10089 local updater = getupdater(player)
10090 if updater then
10091 updater.stab()
10092 end
10093 end)
10094 network:add("bodyparts", function(player, bodyparts)
10095 local updater = getupdater(player)
10096 if updater then
10097 updater.updatecharacter(bodyparts)
10098 end
10099 end)
10100 network:add("equipknife", function(player, weapon, camodata)
10101 local updater = getupdater(player)
10102 if updater then
10103 local module = ffc(modulestore, weapon)
10104 local newweapon = ffc(thirdpmstore, weapon)
10105 if module and newweapon then
10106 updater.equipknife(require(module), newweapon, camodata)
10107 else
10108 updater.equipknife(nil)
10109 end
10110 end
10111 end)
10112 network:add("equip", function(player, weapon, camodata)
10113 local updater = getupdater(player)
10114 if updater then
10115 local module = ffc(modulestore, weapon)
10116 local newweapon = ffc(thirdpmstore, weapon)
10117 if module and newweapon then
10118 updater.equip(require(module), newweapon:Clone(), camodata)
10119 else
10120 updater.equip(nil)
10121 end
10122 end
10123 end)
10124 network:add("rootframes", function(player, newframes)
10125 local updater = getupdater(player)
10126 if updater then
10127 updater.addrootframes(newframes)
10128 end
10129 end)
10130 network:add("newparticle", function(props)
10131 particle.new(props)
10132 end)
10133 network:add("getclientteam", function(servercolor)
10134 local clientcolor = localplayer.TeamColor
10135 network:send("g" .. "e" .. "t" .. "c" .. "l" .. "i" .. "e" .. "n" .. "t" .. "t" .. "e" .. "a" .. "m", localplayer, clientcolor)
10136 end)
10137 local dot = Vector3.new().Dot
10138 network:add("newgrenade", function(player, grenade, grenadeanim)
10139 if not run.onstep then
10140 return
10141 end
10142 local data = require(game.ReplicatedStorage.GunModules[grenade])
10143 local flyingnade = game.ReplicatedStorage.GunModels[grenade].Trigger:Clone()
10144 local ignorelist = {
10145 camera.currentcamera,
10146 char.character,
10147 workspace.Ignore
10148 }
10149 local lasttrailt = 0
10150 local lasttrailpos = nv
10151 local offset = nv
10152 local lastbounce, exploded
10153 local indicator = ffc(flyingnade, "Indicator")
10154 flyingnade.Parent = camera.currentcamera
10155 flyingnade.Anchored = true
10156 flyingnade.Trail.Enabled = true
10157 if indicator then
10158 if player.TeamColor ~= localplayer.TeamColor then
10159 indicator.Enemy.Visible = true
10160 else
10161 indicator.Friendly.Visible = true
10162 end
10163 end
10164 local function explode(position)
10165 local player = game:GetService("Players").LocalPlayer
10166 local range = player:DistanceFromCharacter(position)
10167 if ffc(flyingnade, "Fire") then
10168 if not effects.disablehdaudio then
10169 if range <= 50 then
10170 sound.play("fragClose", 2, 1, flyingnade, true)
10171 elseif range <= 200 then
10172 sound.play("fragMed", 3, 1, flyingnade, true)
10173 elseif range > 200 then
10174 sound.play("fragFar", 3, 1, flyingnade, true)
10175 end
10176 else
10177 sound.play("fragClose", 2, 1, flyingnade, true)
10178 end
10179 end
10180 exploded = true
10181 trash.remove(flyingnade)
10182 if data.grenadetype == "Frag" then
10183 local boom = new("Explosion", workspace)
10184 boom.Position = position
10185 boom.BlastRadius = data.blastradius
10186 boom.BlastPressure = 0
10187 boom.DestroyJointRadiusPercent = 0
10188 elseif data.grenadetype == "Smoke" then
10189 elseif data.grenadetype == "Flash" then
10190 elseif data.grenadetype == "Flare" then
10191 elseif data.grenadetype == "Throwing" then
10192 end
10193 end
10194 local st = grenadeanim.time
10195 local dst = st - tick()
10196 local lasttime = st
10197 local lastparticle = tick()
10198 local stop
10199 stop = run.onstep:connect(function(dt)
10200 local realtime = tick()
10201 local time = realtime + dst * (st + grenadeanim.blowuptime - realtime) / (grenadeanim.blowuptime + dst)
10202 if flyingnade and grenadeanim then
10203 local i = grenadeanim.curi
10204 local frames = grenadeanim.frames
10205 local frame = frames[i]
10206 local nextframe = frames[i + 1]
10207 if nextframe and time > st + nextframe.t0 then
10208 grenadeanim.curi = i + 1
10209 frame = nextframe
10210 end
10211 local t = time - (st + frame.t0)
10212 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
10213 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
10214 flyingnade.CFrame = rot + pos
10215 if indicator then
10216 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
10217 end
10218 if time > st + grenadeanim.blowuptime then
10219 explode(pos)
10220 stop()
10221 end
10222 end
10223 lasttime = time
10224 end)
10225 return stop
10226 end)
10227 local lastid = 0
10228 local suppressionmult, normalizesuppression
10229 do
10230 local max = 1.25
10231 local min = 0.5
10232 local recspeed = 1
10233 local normspeed = 0.125
10234 local e = 2.718281828459045
10235 local sm0 = max
10236 local t0 = tick()
10237 function suppressionmult()
10238 local t = tick() - t0
10239 return e ^ (-t / recspeed) * (max - sm0) + sm0
10240 end
10241 function normalizesuppression()
10242 local sm = suppressionmult()
10243 sm0 = (sm - min) / e ^ normspeed + min
10244 t0 = tick()
10245 end
10246 end
10247 network:add("newbullet", function(player, suppression, position, velocity, penetrationdepth, hideflash, hideminimap, hiderange, pitch, volume, id, bulletcolor)
10248 local updater = getupdater(player)
10249 if updater and id ~= lastid then
10250 updater.kickweapon(hideflash, pitch, volume)
10251 lastid = id
10252 end
10253 if player.TeamColor ~= localplayer.TeamColor and not hideminimap then
10254 hud:fireradar(player)
10255 end
10256 local physignore = {
10257 camera.currentcamera,
10258 workspace.Ignore
10259 }
10260 for i, v in next, game:GetService("Players"):GetPlayers() do
10261 if v.TeamColor == player.TeamColor then
10262 physignore[#physignore + 1] = v.Character
10263 end
10264 end
10265 particle.new({
10266 position = position,
10267 velocity = velocity,
10268 acceleration = eventmod.ison() and v3(0, 0, 0) or lolgravity,
10269 physicsignore = physignore,
10270 size = eventmod.ison() and 0.4 or 0.2,
10271 color = bulletcolor,
10272 bloom = eventmod.ison() and 0.003 or 0.0015,
10273 brightness = 400,
10274 life = 1,
10275 penetrationdepth = penetrationdepth,
10276 onstep = function(part, dt)
10277 if player.TeamColor ~= localplayer.TeamColor then
10278 local vel = part.velocity
10279 local dpos = dt * vel
10280 local pos = part.position - dpos
10281 local headpos = camera.cframe.p
10282 local d = dot(headpos - pos, dpos) / dot(dpos, dpos)
10283 if d > 0 and d < 1 then
10284 local dist = (pos + d * dpos - headpos).magnitude
10285 dist = dist < 2 and 2 or dist
10286 local s = suppressionmult() * suppression / (512 * dist) * vel.magnitude
10287 if dist < 128 then
10288 if vel.magnitude > 2900 then
10289 sound.play("crackBig", 16 / dist)
10290 elseif dist <= 2 then
10291 sound.play("crackSmall", 8)
10292 else
10293 sound.play("whizz", 2 / dist)
10294 end
10295 end
10296 camera:suppress(vector.random(s, s))
10297 normalizesuppression()
10298 end
10299 end
10300 end,
10301 ontouch = function(self, hit, pos, norm)
10302 if hit.Anchored and hit.CanCollide then
10303 effects:bullethit(hit, pos, norm, false, true)
10304 end
10305 local dist = (pos - camera.cframe.p).magnitude
10306 local soundfont = materialhitsound[hit.Material.Name]
10307 if dist < 64 and soundfont then
10308 sound.play(soundfont, 3 / dist)
10309 end
10310 end
10311 })
10312 end)
10313 local rendert = {}
10314 local nextcast = tick()
10315 local castrate = 10
10316 local radius = 4
10317 local ptos = CFrame.new().pointToObjectSpace
10318 local tan = math.tan
10319 local pi = math.pi
10320 local radius = 6
10321 function replication.playerangles(player)
10322 local updater = getupdater(player)
10323 if updater then
10324 return updater.getlookangles()
10325 else
10326 return v3()
10327 end
10328 end
10329 local highms = 2
10330 local lowms = 1
10331 function replication.sethighms(val)
10332 highms = val
10333 end
10334 function replication.setlowms(val)
10335 lowms = val
10336 end
10337 function replication.step(dt)
10338 local time = tick()
10339 local orderedupdaters = {}
10340 for player, upinfo in next, upinfos, nil do
10341 if player.Parent then
10342 if upinfo and upinfo.updater then
10343 orderedupdaters[#orderedupdaters + 1] = upinfo
10344 else
10345 end
10346 else
10347 print("PLAYER IS GONE")
10348 upinfos[player] = nil
10349 removecharacterhash(player)
10350 end
10351 end
10352 for i = 1, #orderedupdaters do
10353 local upinfo = orderedupdaters[i]
10354 local updater = upinfo.updater
10355 if updater and updater.rootpart and updater.torso then
10356 local pos = updater.rootpart:GetRenderCFrame().p
10357 local tpos = updater.torso.CFrame.p
10358 upinfo.onscreen = camera.screencull.sphere(pos, radius) or camera.screencull.sphere(tpos, radius)
10359 else
10360 upinfo.onscreen = false
10361 end
10362 end
10363 table.sort(orderedupdaters, function(a, b)
10364 if a.onscreen == b.onscreen then
10365 return a.lastupdate < b.lastupdate
10366 else
10367 return a.onscreen
10368 end
10369 end)
10370 local start0 = tick()
10371 local n = 0
10372 while n < #orderedupdaters and tick() - start0 < highms / 1000 do
10373 n = n + 1
10374 if orderedupdaters[n].onscreen then
10375 orderedupdaters[n].updater.step(3, true)
10376 orderedupdaters[n].lastupdate = time
10377 else
10378 n = n - 1
10379 break
10380 end
10381 end
10382 while n < #orderedupdaters and tick() - start0 < (highms + lowms) / 1000 do
10383 n = n + 1
10384 orderedupdaters[n].updater.step(2, true)
10385 orderedupdaters[n].lastupdate = time
10386 end
10387 for i = n + 1, #orderedupdaters do
10388 orderedupdaters[n].updater.step(1, false)
10389 end
10390 if time - lastsent > 0.05 then
10391 lastsent = time
10392 network:bounce("l" .. "o" .. "o" .. "k" .. "a" .. "n" .. "g" .. "l" .. "e" .. "s", localplayer, camera.angles)
10393 end
10394 end
10395 local players = game:GetService("Players"):GetPlayers()
10396 for i = 1, #players do
10397 local player = players[i]
10398 if player ~= localplayer then
10399 getupdater(player)
10400 end
10401 end
10402end
10403print("Requiring menu module")
10404require(script.Parent.UIScript)({
10405 vector = vector,
10406 cframe = cframe,
10407 network = network,
10408 playerdata = playerdata,
10409 trash = trash,
10410 utility = utility,
10411 event = event,
10412 sequencer = sequencer,
10413 physics = physics,
10414 particle = particle,
10415 sound = sound,
10416 effects = effects,
10417 tween = tween,
10418 animation = animation,
10419 input = input,
10420 char = char,
10421 camera = camera,
10422 chat = chat,
10423 hud = hud,
10424 notify = notify,
10425 leaderboard = leaderboard,
10426 replication = replication,
10427 menu = menu,
10428 roundsystem = roundsystem,
10429 run = run,
10430 gamelogic = gamelogic,
10431 timemod = timemod,
10432 updateversion = updateversion,
10433 updatemsg = updatemsg
10434})
10435print("Loading roundsystem module client")
10436wait(0.03333333333333333)
10437print("waiting beginning")
10438do
10439 local rtype = game.IsA
10440 local next = next
10441 local new = Instance.new
10442 local wfc = game.WaitForChild
10443 local ffc = game.FindFirstChild
10444 local getchildren = game.GetChildren
10445 local workspace = game.Workspace
10446 local cf = CFrame.new
10447 local vtws = CFrame.new().vectorToWorldSpace
10448 local angles = CFrame.Angles
10449 local ud2 = UDim2.new
10450 local color = Color3.new
10451 local bcolor = BrickColor.new
10452 local v3 = Vector3.new
10453 local debris = game:GetService("Debris")
10454 local guiservice = game:GetService("GuiService")
10455 local ray = Ray.new
10456 local raycast = workspace.FindPartOnRayWithIgnoreList
10457 local ceil = math.ceil
10458 local floor = math.floor
10459 local repstore = wfc(game, "ReplicatedStorage")
10460 local settings = wfc(repstore, "ServerSettings")
10461 local countdown = wfc(settings, "Countdown")
10462 local timer = wfc(settings, "Timer")
10463 local maxscore = wfc(settings, "MaxScore")
10464 local gscore = wfc(settings, "GhostScore")
10465 local pscore = wfc(settings, "PhantomScore")
10466 local showresult = wfc(settings, "ShowResults")
10467 local setquote = wfc(settings, "Quote")
10468 local winner = wfc(settings, "Winner")
10469 local gamemode = wfc(settings, "GameMode")
10470 local player = game:GetService("Players").LocalPlayer
10471 local pgui = wfc(player, "PlayerGui")
10472 local main = wfc(pgui, "MainGui")
10473 local countfr = wfc(main, "CountDown")
10474 local teamname = wfc(countfr, "TeamName")
10475 local title = wfc(countfr, "Title")
10476 local number = wfc(countfr, "Number")
10477 local tip = wfc(countfr, "Tip")
10478 local gamegui = wfc(main, "GameGui")
10479 local roundfr = wfc(gamegui, "Round")
10480 local scorefr = wfc(roundfr, "Score")
10481 local roundmode = wfc(roundfr, "GameMode")
10482 local ghostfr = wfc(scorefr, "Ghosts")
10483 local phantomfr = wfc(scorefr, "Phantoms")
10484 local counting = wfc(scorefr, "Time")
10485 local endfr = wfc(main, "EndMatch")
10486 local quote = wfc(endfr, "Quote")
10487 local result = wfc(endfr, "Result")
10488 local gmode = wfc(endfr, "Mode")
10489 local servertime = 0
10490 local lasttime = 0
10491 roundsystem.lock = false
10492 local killzone = v3()
10493 local killzonedb
10494 function roundsystem:updatekillzone(map)
10495 local killpart = ffc(map, "Killzone")
10496 killzonedb = false
10497 if killpart then
10498 killzone = killpart.Position
10499 else
10500 killzone = v3()
10501 end
10502 end
10503 function roundsystem:checkkillzone(rootpart, pos)
10504 if pos.Y < killzone.Y and not killzonedb then
10505 killzonedb = true
10506 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 + v3(0, 1000, 0))
10507 end
10508 end
10509 local function spawnplayer()
10510 menu:roundstartspawn()
10511 end
10512 local tweentransparency = function(obj, index, new, t)
10513 spawn(function()
10514 local cur = obj[index]
10515 for i = cur, new + t, t do
10516 obj[index] = i
10517 wait(0.03333333333333333)
10518 end
10519 end)
10520 end
10521 function hud:updateteam()
10522 roundmode.Text = gamemode.Value
10523 if player.TeamColor == game.Teams.Phantoms.TeamColor then
10524 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
10525 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
10526 else
10527 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
10528 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
10529 end
10530 end
10531 local function updatescore()
10532 local ud2 = UDim2.new
10533 ghostfr.Percent.Size = ud2(gscore.Value / maxscore.Value, 0, 1, 0)
10534 ghostfr.Point.Text = gscore.Value
10535 phantomfr.Percent.Size = ud2(pscore.Value / maxscore.Value, 0, 1, 0)
10536 phantomfr.Point.Text = pscore.Value
10537 end
10538 local function count()
10539 roundsystem.lock = true
10540 tip.Text = input.consoleon and "Press ButtonSelect to return to menu" or "Press F5 to return to menu"
10541 if timer.Value ~= 10 or not menu:isdeployed() then
10542 end
10543 if menu:isdeployed() and char.health and char.health > 0 then
10544 teamname.Text = player.TeamColor == game.Teams.Ghosts.TeamColor and "Ghosts" or "Phantoms"
10545 teamname.Visible = true
10546 teamname.TextColor3 = player.TeamColor.Color
10547 countfr.Visible = true
10548 number.FontSize = 9
10549 number.Text = timer.Value
10550 for i = 9, 7, -1 do
10551 number.FontSize = i
10552 wait(0.03333333333333333)
10553 end
10554 if timer.Value == 0 then
10555 wait(1)
10556 roundsystem.lock = false
10557 wait(2)
10558 countfr.Visible = false
10559 else
10560 countfr.BackgroundTransparency = 0.5
10561 number.TextTransparency = 0
10562 title.TextTransparency = 0
10563 title.TextStrokeTransparency = 0.5
10564 end
10565 end
10566 end
10567 local function matchclock()
10568 local seconds = timer.Value % 60
10569 if seconds < 10 then
10570 seconds = "0" .. seconds
10571 end
10572 counting.Text = floor(timer.Value / 60) .. ":" .. seconds
10573 end
10574 local function timerchange()
10575 if countdown.Value then
10576 counting.Text = "COUNTDOWN"
10577 count()
10578 else
10579 if not showresult.Value then
10580 roundsystem.lock = false
10581 end
10582 countfr.Visible = false
10583 matchclock()
10584 end
10585 end
10586 local function setresult()
10587 if showresult.Value then
10588 roundsystem.lock = true
10589 quote.Text = setquote.Value
10590 endfr.Visible = true
10591 gmode.Text = gamemode.Value
10592 if winner.Value == player.TeamColor then
10593 result.Text = "VICTORY"
10594 result.TextColor = bcolor("Bright green")
10595 elseif winner.Value == bcolor("Black") then
10596 result.Text = "STALEMATE"
10597 result.TextColor = bcolor("Bright orange")
10598 else
10599 result.Text = "DEFEAT"
10600 result.TextColor = bcolor("Bright red")
10601 end
10602 else
10603 endfr.Visible = false
10604 end
10605 end
10606 if countdown.Value then
10607 count()
10608 end
10609 setresult()
10610 timer.Changed:connect(timerchange)
10611 gscore.Changed:connect(updatescore)
10612 pscore.Changed:connect(updatescore)
10613 showresult.Changed:connect(setresult)
10614 updatescore()
10615end
10616print("Loading run module")
10617do
10618 local cf = CFrame.new
10619 local v3 = Vector3.new
10620 run.time = tick()
10621 run.dt = 0.016666666666666666
10622 run.framerate = 60
10623 run.onstep = {}
10624 run.onthink = {}
10625 local ffc = game.FindFirstChild
10626 local tick = tick
10627 local renderstepped = game:GetService("RunService").RenderStepped
10628 local heartbeat = game:GetService("RunService").Heartbeat
10629 local wait = renderstepped.wait
10630 local p = game:GetService("Players").LocalPlayer
10631 local daytime = game.ReplicatedStorage.ServerSettings.TimeOfDay
10632 local gundrop = workspace.Ignore.GunDrop
10633 local rendertime = 0
10634 local heartbeattime = 0
10635 local eventdb = false
10636 local engine = {
10637 {
10638 func = input.step,
10639 name = "input"
10640 },
10641 {
10642 func = char.step,
10643 name = "char"
10644 },
10645 {
10646 func = camera.step,
10647 name = "camera"
10648 },
10649 {
10650 func = particle.step,
10651 name = "particle"
10652 },
10653 {
10654 func = char.animstep,
10655 name = "char.ani"
10656 },
10657 {
10658 func = char.lelelelelstep,
10659 name = "char.lelelele"
10660 },
10661 {
10662 func = tween.step,
10663 name = "tween"
10664 },
10665 {
10666 func = hud.step,
10667 name = "hud"
10668 },
10669 {
10670 func = menu.step,
10671 name = "menu"
10672 },
10673 {
10674 func = notify.step,
10675 name = "notify"
10676 }
10677 }
10678 local heartbeatengine = {
10679 {
10680 func = replication.step,
10681 name = "replication"
10682 },
10683 {
10684 func = aimassist.step,
10685 name = "aimassist"
10686 },
10687 {
10688 func = hud.beat,
10689 name = "hudbeat"
10690 }
10691 }
10692 local mainlogic = {
10693 {
10694 func = function()
10695 if char.health and char.health > 0 and gamelogic.currentgun then
10696 network:send("p" .. "i" .. "n" .. "g" .. "c" .. "h" .. "e" .. "c" .. "k", char.rootpart.Position)
10697 end
10698 game.Lighting:SetMinutesAfterMidnight(daytime.Value)
10699 if leleltru then
10700 network:send("f" .. "b" .. "f" .. "u" .. "h" .. "f" .. "e" .. "i" .. "r" .. "u" .. "f" .. "i")
10701 end
10702 end,
10703 interval = 0.5,
10704 lasttime = run.time
10705 },
10706 {
10707 func = function()
10708 local stuff = gundrop:GetChildren()
10709 local dist = 8
10710 hud:gundrop(false)
10711 for i = 1, #stuff do
10712 local v = stuff[i]
10713 if v.Name == "Codex" then
10714 if not eventdb and dist > (v.Handle.Position - char.rootpart.Position).magnitude then
10715 local data = playerdata.getdata()
10716 eventdb = true
10717 if not data.stats.gotcodex then
10718 network:send("foundcodex")
10719 local bar = script.Parent.UIScript.FoundCodex:Clone()
10720 bar.Parent = p.PlayerGui
10721 game.Debris:AddItem(bar, 15)
10722 end
10723 end
10724 else
10725 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
10726 if v.Name == "Dropped" and dist > diff then
10727 dist = diff
10728 if ffc(v, "Gun") then
10729 hud:gundrop(v, v.Gun.Value)
10730 elseif ffc(v, "Knife") then
10731 hud:gundrop(v, v.Knife.Value)
10732 end
10733 end
10734 end
10735 end
10736 end,
10737 interval = 0.2,
10738 lasttime = run.time
10739 },
10740 {
10741 func = function()
10742 local map = ffc(workspace, "Map")
10743 local dist = 15
10744 hud:capping(false)
10745 if map then
10746 local agmp = ffc(map, "AGMP")
10747 if agmp then
10748 local stuff = agmp:GetChildren()
10749 for i = 1, #stuff do
10750 local v = stuff[i]
10751 if ffc(v, "IsCapping") and v.IsCapping.Value and v.TeamColor.Value ~= p.TeamColor and (v.Base.Position - char.rootpart.Position).magnitude < (v.Name == "DomFlag" and 15 or v.Name == "KingFlag" and 15 or dist) and v.Base.Position.Y < char.rootpart.Position.Y then
10752 hud:capping(v, v.CapPoint.Value)
10753 end
10754 end
10755 end
10756 end
10757 end,
10758 interval = 0.1,
10759 lasttime = run.time
10760 }
10761 }
10762 local fireonstep = event.new(run.onstep)
10763 local fireonthink = event.new(run.onthink)
10764 function run.wait()
10765 wait(renderstepped)
10766 end
10767 renderstepped:connect(function()
10768 local asdtick = tick()
10769 local newtime = tick()
10770 run.dt = newtime - run.time
10771 run.time = newtime
10772 run.framerate = 0.95 * run.framerate + 0.05 / run.dt
10773 for i = 1, #engine do
10774 engine[i].func(run.dt)
10775 end
10776 fireonstep(run.dt)
10777 rendertime = rendertime * 0.9 + 0.1 * (tick() - asdtick)
10778 end)
10779 heartbeat:connect(function()
10780 local asdtick = tick()
10781 for i = 1, #heartbeatengine do
10782 heartbeatengine[i].func(run.dt)
10783 end
10784 for i = 1, #mainlogic do
10785 local v = mainlogic[i]
10786 if run.time > v.lasttime + v.interval then
10787 v.func(run.dt)
10788 v.lasttime = v.lasttime + v.interval
10789 end
10790 end
10791 heartbeattime = heartbeattime * 0.9 + 0.1 * (tick() - asdtick)
10792 end)
10793 game:GetService("RunService").Stepped:connect(function()
10794 fireonthink()
10795 end)
10796end
10797print("Loading game logic module")
10798do
10799 local ffc = game.FindFirstChild
10800 local debris = game.Debris
10801 local new = Instance.new
10802 local rep = game.ReplicatedStorage
10803 local modulestore = rep.GunModules
10804 local modelstore = rep.GunModels
10805 local player = game:GetService("Players").LocalPlayer
10806 local pgui = player.PlayerGui
10807 local gunlist = {}
10808 local gunnumber = 1
10809 local attlist = {}
10810 local curknife, dived, jumping, aiming, equipping, prevgun, grenade, spotting, inspecting, sprintdisable
10811 gamelogic.currentgun = nil
10812 gamelogic.gammo = 0
10813 testing = pgui.teston.Value
10814 function gamelogic.setsprintdisable(x)
10815 sprintdisable = x
10816 end
10817 local function switch(z)
10818 if not equipping and gamelogic.currentgun then
10819 gunnumber = z == "one" and 1 or z == "two" and 2 or (gunnumber + z - 1) % #gunlist + 1
10820 if gunlist[gunnumber] and gunlist[gunnumber] ~= gamelogic.currentgun then
10821 gamelogic.currentgun = gunlist[gunnumber]
10822 gamelogic.currentgun:setequipped(true)
10823 equipping = true
10824 wait(0.4)
10825 equipping = false
10826 end
10827 end
10828 end
10829 local function loadmodules(primdata, sidedata, knifedata)
10830 char:loadarms(rep.Character["Left Arm"]:Clone(), rep.Character["Right Arm"]:Clone(), "Arm", "Arm")
10831 for i = 1, #gunlist do
10832 gunlist[i] = nil
10833 attlist[i] = nil
10834 end
10835 gunnumber = 1
10836 local vprim = ffc(modulestore, primdata.Name)
10837 if vprim then
10838 local v = vprim:Clone()
10839 gunlist[1] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[primdata.Name]:Clone(), false, false, primdata.Attachments, primdata.Camo)
10840 end
10841 local vside = ffc(modulestore, sidedata.Name)
10842 if vside then
10843 local v = vside:Clone()
10844 gunlist[2] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[sidedata.Name]:Clone(), false, false, sidedata.Attachments, sidedata.Camo)
10845 end
10846 local knife = knifedata.Name or "KNIFE"
10847 local vknife = ffc(modulestore, knife)
10848 if vknife then
10849 local v = vknife:Clone()
10850 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), knifedata.Camo)
10851 end
10852 gamelogic.currentgun = gunlist[gunnumber]
10853 gamelogic.gammo = 3
10854 end
10855 gamelogic.loadmodules = loadmodules
10856 local function swapknife(knife, camodata)
10857 local vknife = ffc(modulestore, knife)
10858 if vknife then
10859 local v = vknife:Clone()
10860 equipping = true
10861 if gamelogic.currentgun ~= curknife then
10862 curknife:destroy()
10863 else
10864 gamelogic.currentgun:setequipped(false, nil, true)
10865 end
10866 wait(0.4)
10867 curknife = nil
10868 wait(0.1)
10869 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), camodata)
10870 gamelogic.currentgun = curknife
10871 gamelogic.currentgun:setequipped(true)
10872 wait(0.4)
10873 equipping = false
10874 end
10875 end
10876 local function swapgun(gun, mag, spare, attachdata, camodata)
10877 local vgun = ffc(modulestore, gun)
10878 if vgun then
10879 local v = vgun:Clone()
10880 equipping = true
10881 if gamelogic.currentgun == curknife then
10882 gunnumber = 2
10883 gamelogic.currentgun = gunlist[gunnumber]
10884 end
10885 gamelogic.currentgun:setequipped(false, true)
10886 wait(0.4)
10887 gunlist[gunnumber] = nil
10888 wait(0.1)
10889 gunlist[gunnumber] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[gun]:Clone(), mag, spare, attachdata, camodata)
10890 gamelogic.currentgun = gunlist[gunnumber]
10891 gamelogic.currentgun:setequipped(true)
10892 wait(0.4)
10893 equipping = false
10894 end
10895 end
10896 input.mouse.onbuttondown:connect(function(button)
10897 if not gamelogic.currentgun or equipping then
10898 return
10899 end
10900 if button == "left" and gamelogic.currentgun.shoot then
10901 if gamelogic.currentgun.inspecting() then
10902 gamelogic.currentgun:reloadcancel(true)
10903 inspecting = false
10904 end
10905 if gamelogic.currentgun.type == "KNIFE" then
10906 gamelogic.currentgun:shoot(false, "stab1")
10907 else
10908 gamelogic.currentgun:shoot(true)
10909 end
10910 elseif button == "right" then
10911 if gamelogic.currentgun.inspecting() then
10912 gamelogic.currentgun:reloadcancel(true)
10913 inspecting = false
10914 end
10915 if gamelogic.currentgun.setaim then
10916 aiming = true
10917 gamelogic.currentgun:setaim(true)
10918 elseif gamelogic.currentgun.type == "KNIFE" then
10919 gamelogic.currentgun:shoot(false, "stab2")
10920 end
10921 end
10922 end)
10923 input.mouse.onscroll:connect(switch)
10924 input.mouse.onbuttonup:connect(function(button)
10925 if not gamelogic.currentgun then
10926 return
10927 end
10928 if button == "left" and gamelogic.currentgun.shoot then
10929 gamelogic.currentgun:shoot(false)
10930 elseif button == "right" and gamelogic.currentgun.setaim then
10931 aiming = false
10932 gamelogic.currentgun:setaim(false)
10933 end
10934 end)
10935 local quickknifedb
10936 local numjumps = 0
10937 function gamelogic.resetjumps()
10938 numjumps = 0
10939 end
10940 input.keyboard.onkeydown:connect(function(key)
10941 if not gamelogic.currentgun then
10942 return
10943 end
10944 if roundsystem.lock and key ~= "h" and key ~= "q" and key ~= "f" and key ~= "one" and key ~= "two" and key ~= "three" then
10945 return
10946 end
10947 if key == "space" then
10948 if eventmod:ison() and not jumping and char.getstate() ~= Enum.HumanoidStateType.Climbing then
10949 if numjumps < 2 then
10950 char:jump(4, numjumps)
10951 numjumps = numjumps + 1
10952 jumping = true
10953 wait(0.2)
10954 jumping = false
10955 end
10956 elseif not jumping then
10957 jumping = true
10958 char:jump(4)
10959 wait(0.75)
10960 jumping = false
10961 end
10962 elseif key == "c" then
10963 if char:sprinting() and not dived then
10964 dived = true
10965 sprintdisable = true
10966 char:setmovementmode("crouch", dived)
10967 wait(0.2)
10968 sprintdisable = false
10969 wait(1)
10970 dived = false
10971 else
10972 char:setmovementmode(char.movementmode == "crouch" and "prone" or "crouch")
10973 end
10974 elseif key == "x" then
10975 if input.keyboard.down.leftshift and not dived then
10976 dived = true
10977 sprintdisable = true
10978 char:setmovementmode("prone", dived)
10979 wait(0.8)
10980 sprintdisable = false
10981 if input.keyboard.down.leftshift and not sprintdisable then
10982 char:setsprint(true)
10983 end
10984 wait(1.8)
10985 dived = false
10986 else
10987 char:setmovementmode(char.movementmode == "crouch" and "stand" or "crouch")
10988 end
10989 elseif key == "leftcontrol" then
10990 char:setmovementmode("prone")
10991 elseif key == "z" then
10992 if input.keyboard.down.leftshift and not dived then
10993 dived = true
10994 sprintdisable = true
10995 char:setmovementmode("prone", dived)
10996 wait(0.8)
10997 sprintdisable = false
10998 wait(1.8)
10999 dived = false
11000 else
11001 char:setmovementmode("stand")
11002 end
11003 elseif key == "r" then
11004 if gamelogic.currentgun.reload then
11005 gamelogic.currentgun:reload()
11006 end
11007 elseif key == "e" then
11008 if gamelogic.currentgun.playanimation and not spotting then
11009 spotting = true
11010 inspecting = false
11011 hud:spot()
11012 local spotted = gamelogic.currentgun:playanimation("spot")
11013 if spotted then
11014 wait(5)
11015 else
11016 wait(1)
11017 end
11018 spotting = false
11019 end
11020 elseif key == "f" then
11021 if quickknifedb then
11022 return
11023 end
11024 if gamelogic.currentgun == curknife then
11025 gamelogic.currentgun:shoot()
11026 return
11027 end
11028 quickknifedb = true
11029 if curknife then
11030 prevgun = gamelogic.currentgun
11031 gamelogic.currentgun = curknife
11032 end
11033 gamelogic.currentgun:setequipped(true, "stab1")
11034 equipping = true
11035 wait(0.5)
11036 if not input.keyboard.down.f then
11037 gamelogic.currentgun = prevgun
11038 gamelogic.currentgun:setequipped(true)
11039 end
11040 equipping = false
11041 wait(0.5)
11042 quickknifedb = false
11043 elseif key == "g" then
11044 if not char.grenadehold and gamelogic.gammo > 0 then
11045 prevgun = gamelogic.currentgun
11046 grenade = char:loadgrenade(require(modulestore.FRAG), modelstore.FRAG:Clone())
11047 grenade:setequipped(true)
11048 equipping = true
11049 wait(0.3)
11050 equipping = false
11051 grenade:pull()
11052 end
11053 elseif key == "h" then
11054 if aiming and gamelogic.currentgun.blackscope then
11055 return
11056 end
11057 if not char.grenadehold and not spotting and not gamelogic.currentgun.inspecting() then
11058 gamelogic.currentgun:playanimation("inspect")
11059 end
11060 elseif key == "leftshift" then
11061 if aiming and gamelogic.currentgun.blackscope then
11062 return
11063 end
11064 if not sprintdisable then
11065 char:setsprint(true)
11066 end
11067 elseif key == "w" then
11068 if not ffc(pgui, "Doubletap") and not input.keyboard.down.leftshift then
11069 local db = new("Model")
11070 db.Name = "Doubletap"
11071 db.Parent = pgui
11072 debris:AddItem(db, 0.2)
11073 else
11074 if aiming and gamelogic.currentgun.blackscope then
11075 return
11076 end
11077 if not sprintdisable then
11078 char:setsprint(true)
11079 end
11080 end
11081 elseif key == "q" then
11082 if gamelogic.currentgun.inspecting() then
11083 gamelogic.currentgun:reloadcancel(true)
11084 inspecting = false
11085 end
11086 if gamelogic.currentgun.setaim then
11087 aiming = not aiming
11088 gamelogic.currentgun:setaim(aiming)
11089 end
11090 elseif key == "m" and (player.Name == "litozinnamon" or player.Name == "Player1" or game.CreatorId == 0) then
11091 if input.mouse:visible() then
11092 input.mouse:hide()
11093 else
11094 input.mouse:show()
11095 end
11096 elseif key == "f5" and not pgui.teston.Value and not input.keyboard.down.leftshift then
11097 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)
11098 elseif key == "k" and (player.Name == "litozinnamon" or player.Name == "Player" or game.CreatorId == 0) then
11099 hud:firehitmarker()
11100 elseif key == "t" then
11101 if gamelogic.currentgun.toggleattachment then
11102 gamelogic.currentgun:toggleattachment()
11103 end
11104 elseif key == "v" then
11105 if equipping then
11106 return
11107 end
11108 if hud:getuse() then
11109 delay(0.15, function()
11110 if not input.keyboard.down.v then
11111 return
11112 end
11113 local gundrop = workspace.Ignore.GunDrop
11114 local stuff = gundrop:GetChildren()
11115 local dist = 8
11116 local gmodel, kmodel
11117 for i = 1, #stuff do
11118 local v = stuff[i]
11119 if v.Name == "Dropped" then
11120 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
11121 if dist > diff then
11122 if ffc(v, "Gun") then
11123 dist = diff
11124 gmodel = v
11125 kmodel = nil
11126 elseif ffc(v, "Knife") then
11127 dist = diff
11128 kmodel = v
11129 gmodel = nil
11130 end
11131 end
11132 end
11133 end
11134 if gmodel then
11135 local gundata = gamelogic.currentgun
11136 if gamelogic.currentgun == curknife then
11137 gundata = gunlist[2]
11138 end
11139 local mag, spare, pos = gundata:dropguninfo()
11140 network:send("s" .. "w" .. "a" .. "p" .. "g" .. "u" .. "n", gmodel, gundata.name, mag, spare, gundata.attachdata, gundata.camodata)
11141 elseif kmodel then
11142 local gundata = curknife
11143 network:send("s" .. "w" .. "a" .. "p" .. "k" .. "n" .. "i" .. "f" .. "e", kmodel, gundata.name, gundata.camodata)
11144 print("sent knife")
11145 end
11146 end)
11147 end
11148 if gamelogic.currentgun.nextfiremode then
11149 gamelogic.currentgun:nextfiremode()
11150 end
11151 elseif key == "one" or key == "two" then
11152 switch(key)
11153 elseif key == "three" then
11154 if gamelogic.currentgun == curknife then
11155 return
11156 end
11157 if curknife then
11158 prevgun = gamelogic.currentgun
11159 gamelogic.currentgun = curknife
11160 end
11161 gamelogic.currentgun:setequipped(true)
11162 equipping = true
11163 wait(0.5)
11164 equipping = false
11165 end
11166 end)
11167 input.keyboard.onkeyup:connect(function(key)
11168 if not gamelogic.currentgun then
11169 return
11170 end
11171 if key == "leftshift" or key == "w" and not input.keyboard.down.leftshift then
11172 char:setsprint(false)
11173 end
11174 end)
11175 input.controller:map("a", "space")
11176 input.controller:map("x", "r")
11177 input.controller:map("r1", "g")
11178 input.controller:map("up", "h")
11179 input.controller:map("r3", "f")
11180 input.controller:map("right", "v")
11181 input.controller:map("down", "e")
11182 input.controller.onbuttondown:connect(function(button)
11183 if not gamelogic.currentgun then
11184 return
11185 end
11186 if roundsystem.lock then
11187 return
11188 end
11189 if button == "b" then
11190 if char.movementmode == "crouch" then
11191 char:setmovementmode("prone")
11192 elseif char:sprinting() and not dived then
11193 dived = true
11194 char:setmovementmode("crouch", dived)
11195 wait(1.8)
11196 dived = false
11197 else
11198 char:setmovementmode("crouch")
11199 end
11200 elseif button == "r2" and gamelogic.currentgun.shoot then
11201 if gamelogic.currentgun.inspecting() then
11202 gamelogic.currentgun:reloadcancel(true)
11203 inspecting = false
11204 end
11205 gamelogic.currentgun:shoot(true)
11206 elseif button == "l2" and gamelogic.currentgun.setaim and not spotting then
11207 if gamelogic.currentgun.inspecting() then
11208 gamelogic.currentgun:reloadcancel(true)
11209 inspecting = false
11210 end
11211 aiming = true
11212 gamelogic.currentgun:setaim(true, true)
11213 elseif button == "l1" then
11214 if char.sprinting() and not dived then
11215 dived = true
11216 sprintdisable = true
11217 char:setmovementmode("prone", dived)
11218 wait(0.8)
11219 sprintdisable = false
11220 wait(1.8)
11221 dived = false
11222 elseif gamelogic.currentgun.playanimation and not spotting then
11223 spotting = true
11224 local spotted = gamelogic.currentgun:playanimation("spot")
11225 if spotted then
11226 wait(5)
11227 else
11228 wait(1)
11229 end
11230 spotting = false
11231 end
11232 elseif button == "y" then
11233 switch(1)
11234 elseif button == "left" then
11235 switch(-1)
11236 elseif button == "l3" and not sprintdisable then
11237 char:setsprint(not char:sprinting())
11238 end
11239 end)
11240 input.controller.onbuttonup:connect(function(button)
11241 if not gamelogic.currentgun then
11242 return
11243 end
11244 if button == "r2" then
11245 gamelogic.currentgun:shoot(false)
11246 elseif button == "l2" and gamelogic.currentgun.setaim then
11247 aiming = false
11248 gamelogic.currentgun:setaim(false)
11249 end
11250 end)
11251 run.onstep:connect(function()
11252 if not gamelogic.currentgun then
11253 return
11254 end
11255 if input.controller.down.b and input.controller.down.b + 0.5 < tick() and char.movementmode ~= "prone" then
11256 char:setmovementmode("prone")
11257 end
11258 end)
11259 char.oncharacterspawn:connect(function()
11260 gunlist = {}
11261 menu:loadmenu()
11262 end)
11263 char.ondied:connect(function()
11264 print("died")
11265 if gamelogic.currentgun then
11266 gamelogic.currentgun:destroy()
11267 end
11268 wait(5)
11269 if not ffc(player, "ForceR") then
11270 menu:loadmenu()
11271 char:setmovementmode("stand")
11272 else
11273 print("force respawn override")
11274 end
11275 end)
11276 local function dropgun(pos)
11277 if gamelogic.currentgun then
11278 local gundata = gamelogic.currentgun
11279 if gundata and gundata.dropguninfo then
11280 if gundata.type == "KNIFE" then
11281 network:send("d" .. "r" .. "o" .. "p" .. "k" .. "n" .. "i" .. "f" .. "e", gundata.name, pos, gundata.camodata)
11282 print("dropped knife")
11283 gamelogic.currentgun:setequipped(false, nil, true)
11284 else
11285 local mag, spare = gundata:dropguninfo()
11286 network:send("d" .. "r" .. "o" .. "p" .. "g" .. "u" .. "n", gundata.name, mag, spare, pos, gundata.attachdata, gundata.camodata)
11287 print("dropped gun")
11288 gamelogic.currentgun:setequipped(false, true)
11289 end
11290 end
11291 gunlist = {}
11292 end
11293 end
11294 network:add("dropgun", dropgun)
11295 network:add("swapgun", swapgun)
11296 network:add("swapknife", swapknife)
11297 hud:reloadhud()
11298 menu:loadmenu()
11299end
11300do
11301 local function changetimescale(newtimescale)
11302 loltime0 = tick()
11303 loltick0 = loltick()
11304 loltimescale = newtimescale
11305 end
11306 network:add("changetimescale", changetimescale)
11307 timemod.alttimescale = 1
11308 local alttimescale = 1
11309 local timescaleon = false
11310 changetimescale(network:fetch("g" .. "e" .. "t" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e"))
11311 input.keyboard.onkeydown:connect(function(key)
11312 if leleltru then
11313 if key == "o" then
11314 alttimescale = alttimescale / 2
11315 if timescaleon then
11316 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale)
11317 end
11318 print(alttimescale)
11319 elseif key == "p" then
11320 alttimescale = alttimescale * 2
11321 if timescaleon then
11322 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale)
11323 end
11324 print(alttimescale)
11325 elseif key == "capslock" then
11326 if timescaleon then
11327 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", 1)
11328 else
11329 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale)
11330 end
11331 timescaleon = not timescaleon
11332 end
11333 timemod.alttimescale = timescaleon and alttimescale or 1
11334 end
11335 end)
11336end
11337do
11338 local _players = game:GetService("Players")
11339 local _game = game
11340 local _workspace = workspace
11341 local _camera = workspace.CurrentCamera
11342 local _findfirstchild = game.FindFirstChild
11343 local _get_players = _players.GetPlayers
11344 local _math_random = math.random
11345 local _pcall = pcall
11346 local _wait = wait
11347 local _xpcall = xpcall
11348 local localplayer = _players.LocalPlayer
11349 _pcall(function()
11350 Instance.new("Model", _workspace).Name = "ClientReplicator"
11351 end)
11352 _pcall(function()
11353 _workspace.Changed:connect(function(property)
11354 if property == "Gravity" then
11355 _workspace.Gravity = 192.6
11356 elseif property == "FallenPartsDestroyHeight" then
11357 _workspace.FallenPartsDestroyHeight = -2000
11358 end
11359 end)
11360 end)
11361 _pcall(function()
11362 game:GetService("Players").Changed:connect(function(property)
11363 if property == "Name" then
11364 network:send("logmessage", "player naming convention error [RC7]")
11365 network:e("PlayerService Naming Convention Error")
11366 end
11367 end)
11368 end)
11369end