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