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