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