· 5 years ago · Sep 29, 2020, 12:34 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 [31137804] = true
26}
27leleltru = lelasdids[game:GetService("Players").LocalPlayer.UserId]
28wait()
29pcall(function()
30 local starterGui = game:GetService("StarterGui")
31 starterGui:SetCore("TopbarEnabled", false)
32end)
33local tick = tick
34local netkick
35local loltime0 = 0
36local loltick0 = 0
37local loltimescale = 1
38lolgravity = Vector3.new(0, -196.2, 0)
39game.StarterGui.ResetPlayerGuiOnSpawn = false
40game.StarterGui:SetCoreGuiEnabled("All", false)
41math.randomseed(tick())
42botwrapper = {}
43vector = {}
44cframe = {}
45local network = {}
46local playerdata = {}
47local trash = {}
48local utility = {}
49local event = {}
50local sequencer = {}
51local physics = {}
52local particle = {}
53local sound = {}
54local effects = {}
55local tween = {}
56local animation = {}
57local input = {}
58local aimassist = {}
59local char = {}
60local camera = {}
61local chat = {}
62local hud = {}
63local notify = {}
64local leaderboard = {}
65local replication = {}
66local menu = {}
67local roundsystem = {}
68local run = {}
69local gamelogic = {}
70local timemod = {}
71gamesettings = {friendlyfire = false}
72repeat
73 wait()
74until game:IsLoaded()
75local ChinaPolicyService = require(game.ReplicatedStorage.SharedModules.ChinaPolicyService)
76print("Loading vector module")
77do
78 local pi = math.pi
79 local cos = math.cos
80 local sin = math.sin
81 local acos = math.acos
82 local asin = math.asin
83 local atan2 = math.atan2
84 local random = math.random
85 local v3 = Vector3.new
86 local nv = Vector3.new()
87 vector.identity = nv
88 vector.new = v3
89 vector.lerp = nv.lerp
90 vector.cross = nv.Cross
91 vector.dot = nv.Dot
92 function vector.random(a, b)
93 local p = acos(1 - 2 * random()) / 3
94 local z = 1.7320508075688772 * sin(p) - cos(p)
95 local r = ((1 - z * z) * random()) ^ 0.5
96 local t = 6.28318 * random()
97 local x = r * cos(t)
98 local y = r * sin(t)
99 if b then
100 local m = (a + (b - a) * random()) / (x * x + y * y + z * z) ^ 0.5
101 return v3(m * x, m * y, m * z)
102 elseif a then
103 return v3(a * x, a * y, a * z)
104 else
105 return v3(x, y, z)
106 end
107 end
108 function vector.anglesyx(x, y)
109 local cx = cos(x)
110 return v3(-cx * sin(y), sin(x), -cx * cos(y))
111 end
112 function vector.toanglesyx(v)
113 local x, y, z = v.x, v.y, v.z
114 return asin(y / (x * x + y * y + z * z) ^ 0.5), atan2(-x, -z)
115 end
116 function vector.slerp(v0, v1, t)
117 local x0, y0, z0 = v0.x, v0.y, v0.z
118 local x1, y1, z1 = v1.x, v1.y, v1.z
119 local m0 = (x0 * x0 + y0 * y0 + z0 * z0) ^ 0.5
120 local m1 = (x1 * x1 + y1 * y1 + z1 * z1) ^ 0.5
121 local co = (x0 * x1 + y0 * y1 + z0 * z1) / (m0 * m1)
122 if co < -0.99999 then
123 local px, py, pz = 0, 0, 0
124 local x2, y2, z2 = x0 * x0, y0 * y0, z0 * z0
125 if x2 < y2 then
126 if x2 < z2 then
127 px = 1
128 else
129 pz = 1
130 end
131 elseif y2 < z2 then
132 py = 1
133 else
134 pz = 1
135 end
136 local th = acos((x0 * px + y0 * py + z0 * pz) / m0)
137 local r = pi / th * t
138 local s = ((1 - t) * m0 + t * m1) / sin(th)
139 local s0 = s / m0 * sin((1 - r) * th)
140 local s1 = s / m1 * sin(r * th)
141 return v3(s0 * x0 + s1 * px, s0 * y0 + s1 * py, s0 * z0 + s1 * pz)
142 elseif co < 0.99999 then
143 local th = acos(co)
144 local s = ((1 - t) * m0 + t * m1) / (1 - co * co) ^ 0.5
145 local s0 = s / m0 * sin((1 - t) * th)
146 local s1 = s / m1 * sin(t * th)
147 return v3(s0 * x0 + s1 * x1, s0 * y0 + s1 * y1, s0 * z0 + s1 * z1)
148 elseif m0 > 1.0E-5 or m1 > 1.0E-5 then
149 if m0 < m1 then
150 return ((1 - t) * m0 / m1 + t) * v1
151 else
152 return (1 - t + t * m1 / m0) * v0
153 end
154 else
155 return nv
156 end
157 end
158end
159print("Loading cframe module")
160do
161 local pi = math.pi
162 local halfpi = pi / 2
163 local cos = math.cos
164 local sin = math.sin
165 local acos = math.acos
166 local v3 = Vector3.new
167 local nv = v3()
168 local cf = CFrame.new
169 local nc = cf()
170 local components = nc.components
171 local tos = nc.toObjectSpace
172 local vtos = nc.vectorToObjectSpace
173 local ptos = nc.pointToObjectSpace
174 local backcf = cf(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1)
175 local lerp = nc.lerp
176 cframe.identity = nc
177 cframe.new = cf
178 cframe.vtws = nc.vectorToWorldSpace
179 cframe.tos = nc.toObjectSpace
180 cframe.ptos = nc.pointToObjectSpace
181 cframe.vtos = nc.vectorToObjectSpace
182 function cframe.fromaxisangle(x, y, z)
183 if not y then
184 x, y, z = x.x, x.y, x.z
185 end
186 local m = (x * x + y * y + z * z) ^ 0.5
187 if m > 1.0E-5 then
188 local si = sin(m / 2) / m
189 return cf(0, 0, 0, si * x, si * y, si * z, cos(m / 2))
190 else
191 return nc
192 end
193 end
194 function cframe.toaxisangle(c)
195 local _, _, _, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
196 local co = (xx + yy + zz - 1) / 2
197 if co < -0.99999 then
198 local x = xx + yx + zx + 1
199 local y = xy + yy + zy + 1
200 local z = xz + yz + zz + 1
201 local m = pi * (x * x + y * y + z * z) ^ (-0.5)
202 return v3(m * x, m * y, m * z)
203 elseif co < 0.99999 then
204 local x = yz - zy
205 local y = zx - xz
206 local z = xy - yx
207 local m = acos(co) * (x * x + y * y + z * z) ^ (-0.5)
208 return v3(m * x, m * y, m * z)
209 else
210 return nv
211 end
212 end
213 function cframe.direct(c, look, newdir, t)
214 local lx, ly, lz = look.x, look.y, look.z
215 local rv = vtos(c, newdir)
216 local rx, ry, rz = rv.x, rv.y, rv.z
217 local rl = ((rx * rx + ry * ry + rz * rz) * (lx * lx + ly * ly + lz * lz)) ^ 0.5
218 local d = (lx * rx + ly * ry + lz * rz) / rl
219 if d < -0.99999 then
220 return c * backcf
221 elseif d < 0.99999 then
222 if t then
223 local th = t * acos(d) / 2
224 local qw = cos(th)
225 local m = rl * ((1 - d * d) / (1 - qw * qw)) ^ 0.5
226 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
227 else
228 local qw = ((d + 1) / 2) ^ 0.5
229 local m = 2 * qw * rl
230 return c * cf(0, 0, 0, (ly * rz - lz * ry) / m, (lz * rx - lx * rz) / m, (lx * ry - ly * rx) / m, qw)
231 end
232 else
233 return c
234 end
235 end
236 function cframe.toquaternion(c)
237 local x, y, z, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(c)
238 local tr = xx + yy + zz
239 if tr > 2.99999 then
240 return x, y, z, 0, 0, 0, 1
241 elseif tr > -0.99999 then
242 local m = 2 * (tr + 1) ^ 0.5
243 return x, y, z, (yz - zy) / m, (zx - xz) / m, (xy - yx) / m, m / 4
244 else
245 local qx = xx + yx + zx + 1
246 local qy = xy + yy + zy + 1
247 local qz = xz + yz + zz + 1
248 local m = (qx * qx + qy * qy + qz * qz) ^ 0.5
249 return x, y, z, qx / m, qy / m, qz / m, 0
250 end
251 end
252 function cframe.power(c, t)
253 return lerp(nc, c, t)
254 end
255 cframe.interpolate = lerp
256 function cframe.interpolator(c0, c1, c2)
257 if c2 then
258 return function(t)
259 return lerp(lerp(c0, c1, t), lerp(c1, c2, t), t)
260 end
261 elseif c1 then
262 return function(t)
263 return lerp(c0, c1, t)
264 end
265 else
266 return function(t)
267 return lerp(nc, c0, t)
268 end
269 end
270 end
271 function cframe.jointleg(r0, r1, c, p, a)
272 local t = ptos(c, p)
273 local tx, ty, tz = t.x, t.y, t.z
274 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
275 local nx, ny, nz = tx / d, ty / d, tz / d
276 d = d > r0 + r1 and r0 + r1 or d
277 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
278 local h = -(1 - l * l) ^ 0.5
279 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
280 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
281 if a then
282 local co, si = cos(a / 2), sin(a / 2)
283 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)
284 end
285 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
286 local co = ((1 - g) / 2) ^ 0.5
287 local si = -((1 + g) / 2) ^ 0.5
288 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)
289 end
290 function cframe.jointarm(r0, r1, c, p, a)
291 local t = ptos(c, p)
292 local tx, ty, tz = t.x, t.y, t.z
293 local d = (tx * tx + ty * ty + tz * tz) ^ 0.5
294 local nx, ny, nz = tx / d, ty / d, tz / d
295 d = d > r0 + r1 and r0 + r1 or d
296 local l = (r1 * r1 - r0 * r0 - d * d) / (2 * r0 * d)
297 local h = (1 - l * l) ^ 0.5
298 local m = (2 * (1 + h * ny + l * nz)) ^ 0.5
299 local qw, qx, qy, qz = m / 2, (h * nz - l * ny) / m, l * nx / m, -h * nx / m
300 if a then
301 local co, si = cos(a / 2), sin(a / 2)
302 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)
303 end
304 local g = (d * l + r0) / (d * d + 2 * d * l * r0 + r0 * r0) ^ 0.5
305 local co = ((1 - g) / 2) ^ 0.5
306 local si = ((1 + g) / 2) ^ 0.5
307 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)
308 end
309end
310local sphereraycast
311do
312 local testinterval = 16
313 local inf = 1 / 0
314 local sort = table.sort
315 local v3 = Vector3.new
316 local nv = v3()
317 local dot = nv.Dot
318 local cross = nv.Cross
319 local cf = CFrame.new
320 local nc = cf()
321 local ptos = nc.pointToObjectSpace
322 local vtos = nc.vectorToObjectSpace
323 local vtws = nc.vectorToWorldSpace
324 local r3 = Region3.new
325 local workspace = game.Workspace
326 local boxcast = workspace.FindPartsInRegion3
327 local getchildren = game.GetChildren
328 local robloxtype = game.IsA
329 local boxmesh = {
330 {
331 p = 0.5,
332 n = v3(-1, 0, 0)
333 },
334 {
335 p = 0.5,
336 n = v3(1, 0, 0)
337 },
338 {
339 p = 0.5,
340 n = v3(0, -1, 0)
341 },
342 {
343 p = 0.5,
344 n = v3(0, 1, 0)
345 },
346 {
347 p = 0.5,
348 n = v3(0, 0, -1)
349 },
350 {
351 p = 0.5,
352 n = v3(0, 0, 1)
353 }
354 }
355 local wedgemesh = {
356 {
357 p = 0.5,
358 n = v3(-1, 0, 0)
359 },
360 {
361 p = 0.5,
362 n = v3(1, 0, 0)
363 },
364 {
365 p = 0.5,
366 n = v3(0, -1, 0)
367 },
368 {
369 p = 0,
370 n = v3(0, 0.7071067811865476, -0.7071067811865476)
371 },
372 {
373 p = 0.5,
374 n = v3(0, 0, 1)
375 }
376 }
377 local cornerwedgemesh = {
378 {
379 p = 0.5,
380 n = v3(1, 0, 0)
381 },
382 {
383 p = 0.5,
384 n = v3(0, -1, 0)
385 },
386 {
387 p = 0.5,
388 n = v3(0, 0, -1)
389 },
390 {
391 p = 0,
392 n = v3(0, 0.7071067811865476, 0.7071067811865476)
393 },
394 {
395 p = 0,
396 n = v3(-0.7071067811865476, 0.7071067811865476, 0)
397 }
398 }
399 local function solveplanesphereray(p, n, o, d, r)
400 local no = dot(n, o)
401 local dn = dot(d, n)
402 local t = (p + r - no) / dn
403 local v = o + t * d
404 local h = v - r * n
405 return v, t, h, n
406 end
407 local function solveraysphereray(ro, rd, so, sd, r)
408 local rdro = dot(rd, ro)
409 local roro = dot(ro, ro)
410 local rdsd = dot(rd, sd)
411 local rosd = dot(ro, sd)
412 local rdso = dot(rd, so)
413 local roso = dot(ro, so)
414 local sdso = dot(sd, so)
415 local soso = dot(so, so)
416 local m = rdro - rdso
417 local a = 1 - rdsd * rdsd
418 local b = 2 * (rdsd * m - rosd + sdso)
419 local c = roro - 2 * roso + soso - m * m - r * r
420 local d = -b / (2 * a)
421 local e2 = d * d - c / a
422 if e2 > 0 then
423 local t = d - e2 ^ 0.5
424 local s = rdsd * t - m
425 local v = so + t * sd
426 local h = ro + s * rd
427 local n = (v - h) / r
428 return v, t, h, n
429 end
430 end
431 local function solvepointsphereray(p, o, d, r)
432 local oo = dot(o, o)
433 local od = dot(o, d)
434 local op = dot(o, p)
435 local dp = dot(d, p)
436 local pp = dot(p, p)
437 local b = 2 * (od - dp)
438 local c = oo - 2 * op + pp - r * r
439 local g = -b / 2
440 local e2 = g * g - c
441 if e2 > 0 then
442 local t = g - e2 ^ 0.5
443 local v = o + t * d
444 local n = (v - p) / r
445 return v, t, p, n
446 end
447 end
448 local function solvespheresphereray(p, e, o, d, r)
449 local oo = dot(o, o)
450 local od = dot(o, d)
451 local op = dot(o, p)
452 local dp = dot(d, p)
453 local pp = dot(p, p)
454 local b = 2 * (od - dp)
455 local c = oo - 2 * op + pp - (r + e) * (r + e)
456 local g = -b / 2
457 local e2 = g * g - c
458 if e2 > 0 then
459 local t = g - e2 ^ 0.5
460 local v = o + t * d
461 local h = p + e / (r + e) * (v - p)
462 local n = (v - h) / (r + e)
463 return v, t, h, n
464 end
465 end
466 local function distplanesphereray(p, n, o, d, r)
467 local no = dot(n, o)
468 local dn = dot(d, n)
469 local t = (p + r - no) / dn
470 return t
471 end
472 local function distpointsphereray(p, o, d, r)
473 local oo = dot(o, o)
474 local od = dot(o, d)
475 local op = dot(o, p)
476 local dp = dot(d, p)
477 local pp = dot(p, p)
478 local b = 2 * (od - dp)
479 local c = oo - 2 * op + pp - r * r
480 local g = -b / 2
481 local e2 = g * g - c
482 if e2 > 0 then
483 local t = g - e2 ^ 0.5
484 return t
485 end
486 end
487 local function solveplaneplane(ap, an, bp, bn)
488 local anbn = dot(an, bn)
489 local canab = cross(an, bn)
490 local s = 1 - anbn * anbn
491 local o = (ap - anbn * bp) / s * an + (bp - ap * anbn) / s * bn
492 local d = canab / s ^ 0.5
493 return o, d
494 end
495 local function solverayplane(o, d, p, n)
496 local dn = dot(d, n)
497 local no = dot(n, o)
498 local v = o + (p - no) / dn * d
499 return v
500 end
501 local function distpointplane(v, p, n)
502 local vn = dot(v, n)
503 local t = vn - p
504 return t
505 end
506 local function sortgreaterdist(a, b)
507 return (b.dist or -inf) < (a.dist or -inf)
508 end
509 local function solvemeshsphereray(rawmesh, cframe, scale, origin, direction, radius)
510 local o = ptos(cframe, origin)
511 local d = vtos(cframe, direction)
512 local r = radius
513 local mesh = {}
514 local nfront = 0
515 for i = 1, #rawmesh do
516 local plane = rawmesh[i]
517 local sn = plane.n / scale
518 local n = sn.unit
519 local p = plane.p / sn.magnitude
520 local newplane = {p = p, n = n}
521 if dot(n, d) < 0 then
522 newplane.dist = distplanesphereray(p, n, o, d, r)
523 nfront = nfront + 1
524 end
525 mesh[#mesh + 1] = newplane
526 end
527 sort(mesh, sortgreaterdist)
528 for i = 1, nfront do
529 local aplane = mesh[i]
530 local apos, adist, ahit, anorm = solveplanesphereray(aplane.p, aplane.n, o, d, r)
531 local agood = true
532 for j = 1, #mesh do
533 if i ~= j then
534 local bplane = mesh[j]
535 if 0 < distpointplane(ahit, bplane.p, bplane.n) then
536 agood = false
537 local aborigin, abdirection = solveplaneplane(aplane.p, aplane.n, bplane.p, bplane.n)
538 local abpos, abdist, abhit, abnorm = solveraysphereray(aborigin, abdirection, o, d, r)
539 if abpos then
540 local abgood = true
541 for k = 1, #mesh do
542 if i ~= k and j ~= k then
543 local cplane = mesh[k]
544 local dist = distpointplane(abhit, cplane.p, cplane.n)
545 if dist > 0 then
546 abgood = false
547 local abcpoint = solverayplane(aborigin, abdirection, cplane.p, cplane.n)
548 local abcpos, abcdist, abchit, abcnorm = solvepointsphereray(abcpoint, o, d, r)
549 if abcpos then
550 local abcgood = true
551 for l = 1, #mesh do
552 if i ~= l and j ~= l and k ~= l then
553 local dplane = mesh[l]
554 local dist = distpointplane(abchit, dplane.p, dplane.n)
555 if dist > 0 then
556 abcgood = false
557 break
558 end
559 end
560 end
561 if abcgood then
562 return cframe * abcpos, abcdist, cframe * abchit, vtws(cframe, abcnorm)
563 end
564 end
565 end
566 end
567 end
568 if abgood then
569 return cframe * abpos, abdist, cframe * abhit, vtws(cframe, abnorm)
570 end
571 end
572 end
573 end
574 end
575 if agood then
576 return cframe * apos, adist, cframe * ahit, vtws(cframe, anorm)
577 end
578 end
579 end
580 local sortdist = function(a, b)
581 return a.dist < b.dist
582 end
583 local function solvepartsphereray(part, origin, direction, radius)
584 local class = part.ClassName
585 if class == "Part" then
586 local shape = part.Shape.Name
587 if shape == "Block" then
588 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
589 elseif shape == "Ball" or shape == "Cylinder" then
590 return solvespheresphereray(part.Position, part.Size.x / 2, origin, direction, radius)
591 end
592 elseif class == "TrussPart" then
593 return solvemeshsphereray(boxmesh, part.CFrame, part.Size, origin, direction, radius)
594 elseif class == "WedgePart" then
595 return solvemeshsphereray(wedgemesh, part.CFrame, part.Size, origin, direction, radius)
596 elseif class == "CornerWedgePart" then
597 return solvemeshsphereray(cornerwedgemesh, part.CFrame, part.Size, origin, direction, radius)
598 end
599 end
600 local function getallparts(directory)
601 local shit = {directory}
602 local i = 0
603 while i < #shit do
604 i = i + 1
605 local children = getchildren(shit[i])
606 for j = 1, #children do
607 shit[#shit + 1] = children[j]
608 end
609 end
610 local parts = {}
611 for j = 1, #shit do
612 if robloxtype(shit[j], "BasePart") then
613 parts[#parts + 1] = shit[j]
614 end
615 end
616 return parts
617 end
618 function sphereraycast(origin, direction, radius, ignore)
619 local tested = {}
620 if type(ignore) == "table" then
621 for i = 1, #ignore do
622 local parts = getallparts(ignore[i])
623 for j = 1, #parts do
624 tested[parts[j]] = true
625 end
626 end
627 elseif ignore then
628 local parts = getallparts(ignore)
629 for j = 1, #parts do
630 tested[parts[j]] = true
631 end
632 end
633 local interval = testinterval
634 local length = direction.magnitude
635 local udirection = direction.unit
636 local dx = udirection.x
637 local dy = udirection.y
638 local dz = udirection.z
639 local radvec = v3(radius, radius, radius)
640 local absvec = v3(dx < 0 and -dx or dx, dy < 0 and -dy or dy, dz < 0 and -dz or dz)
641 local t = 0
642 repeat
643 local stop
644 if interval > length - t then
645 stop = true
646 interval = length - t
647 end
648 local lower = origin + (t + interval / 2) * udirection - interval / 2 * absvec - radvec
649 local upper = origin + (t + interval / 2) * udirection + interval / 2 * absvec + radvec
650 t = t + interval
651 local parts = boxcast(workspace, r3(lower, upper), nil, 100)
652 local sorted = {}
653 for i = 1, #parts do
654 local part = parts[i]
655 if not tested[part] then
656 tested[part] = true
657 local dist = distpointsphereray(part.Position, origin, udirection, radius + part.Size.magnitude / 2)
658 if dist then
659 sorted[#sorted + 1] = {part = part, dist = dist}
660 end
661 end
662 end
663 sort(sorted, sortdist)
664 local bestdist = direction.magnitude
665 local bestpart, bestpos, besthit, bestnorm
666 for i = 1, #sorted do
667 local package = sorted[i]
668 if bestdist > package.dist then
669 local pos, dist, hit, norm = solvepartsphereray(package.part, origin, udirection, radius)
670 if dist and dist > 0 and bestdist > dist then
671 bestdist = dist
672 bestpart = package.part
673 bestpos = pos
674 besthit = hit
675 bestnorm = norm
676 end
677 else
678 break
679 end
680 end
681 if bestpos then
682 return bestpart, bestpos, bestdist, besthit, bestnorm
683 end
684 until stop
685 end
686end
687print("Loading serializer")
688local serialize
689repeat
690 do break end
691 while true do
692 end
693until true
694do
695 local totalasd = 0
696 local starttick = tick()
697 local off = 48
698 local function newbitwriter(key)
699 key = key and key % 2251799813685248 or 0
700 local char = string.char
701 local concat = table.concat
702 local data = {}
703 local ndata = 0
704 local rem = 0
705 local nrem = 0
706 return function(nbits, bits)
707 if nbits < 32 then
708 bits = (bits + key) % 2 ^ nbits
709 else
710 local bits0 = bits % 4294967296
711 local bits1 = (bits - bits0) / 4294967296
712 bits0 = (bits0 + key) % 4294967296
713 bits1 = (bits1 + key) % 2 ^ (nbits - 32)
714 bits = bits0 + 4294967296 * bits1
715 end
716 while nrem + nbits >= 48 do
717 local r = bits % 2 ^ (48 - nrem)
718 bits = (bits - r) / 2 ^ (48 - nrem)
719 nbits = nbits - (48 - nrem)
720 rem = rem + r * 2 ^ nrem
721 local b0 = rem % 64
722 rem = (rem - b0) / 64
723 local b1 = rem % 64
724 rem = (rem - b1) / 64
725 local b2 = rem % 64
726 rem = (rem - b2) / 64
727 local b3 = rem % 64
728 rem = (rem - b3) / 64
729 local b4 = rem % 64
730 rem = (rem - b4) / 64
731 local b5 = rem % 64
732 rem = (rem - b5) / 64
733 local b6 = rem % 64
734 rem = (rem - b6) / 64
735 local b7 = rem % 64
736 rem = (rem - b7) / 64
737 rem = 0
738 nrem = 0
739 ndata = ndata + 1
740 data[ndata] = char(b0 + off, b1 + off, b2 + off, b3 + off, b4 + off, b5 + off, b6 + off, b7 + off)
741 end
742 rem = rem + bits * 2 ^ nrem
743 nrem = nrem + nbits
744 end, function()
745 if nrem ~= 0 then
746 local final = ""
747 for i = 1, 8 do
748 local b = rem % 64
749 rem = (rem - b) / 64
750 final = final .. char(b + off)
751 end
752 ndata = ndata + 1
753 data[ndata] = final
754 end
755 return concat(data)
756 end
757 end
758 local type = type
759 local pcall = pcall
760 local tostring = tostring
761 local byte = string.byte
762 local frexp = math.frexp
763 local nan = tostring(0 / 0)
764 function serialize(d, key)
765 local asd = tick()
766 local e = {}
767 local m = 0
768 local s = {}
769 local n = 0
770 local w, x = newbitwriter(key)
771 local userdata = {
772 function(v)
773 local t0 = v.Dot
774 return {
775 v.x,
776 v.y,
777 v.z
778 }
779 end,
780 function(v)
781 return {
782 v:components()
783 }
784 end,
785 function(v)
786 return v.UserId
787 end
788 }
789 local function f(d)
790 local t = type(d)
791 if s[d] then
792 w(3, 0)
793 local a, b = frexp(s[d])
794 w(5, b)
795 w(b, s[d])
796 elseif t == "boolean" then
797 w(3, 1)
798 w(1, d and 1 or 0)
799 elseif t == "number" then
800 if d % 1 == 0 and d > -4294967296 and d < 4294967296 then
801 w(3, 2)
802 local a, b = frexp(d)
803 w(5, b)
804 w(1, d < 0 and 1 or 0)
805 w(b, d < 0 and -d or d)
806 else
807 w(3, 3)
808 if d ~= d then
809 if tostring(d) == nan then
810 w(1, 0)
811 else
812 w(1, 1)
813 end
814 w(11, 0)
815 w(52, 1)
816 elseif d == 1 / 0 or d == -1 / 0 then
817 w(1, d < 0 and 1 or 0)
818 w(11, 2047)
819 w(52, 4503599627370495)
820 else
821 w(1, d < 0 and 1 or 0)
822 local a, b = frexp(d < 0 and -d or d)
823 local c = (2 * a - 1) * 4503599627370496
824 w(11, b - 1 + 1023)
825 if b == 1025 and c == 4503599627370495 then
826 w(52, (2 * a - 1) * 4503599627370496 - 1)
827 else
828 w(52, (2 * a - 1) * 4503599627370496)
829 end
830 end
831 end
832 elseif t == "string" then
833 n = n + 1
834 s[d] = n
835 w(3, 4)
836 local a, b = frexp(#d)
837 w(5, b)
838 w(b, #d)
839 for i = 1, #d do
840 local v = byte(d, i)
841 w(8, v)
842 end
843 elseif t == "table" then
844 n = n + 1
845 s[d] = n
846 w(3, 5)
847 local j = 0
848 local k = 0
849 for i = 1, #d do
850 if not d[i] then
851 j = i - 1
852 break
853 end
854 end
855 for i, v in next, d, nil do
856 local t = type(i)
857 if t ~= "number" or i > j then
858 k = k + 1
859 end
860 end
861 local a, b = frexp(j)
862 w(5, b)
863 w(b, j)
864 local a, b = frexp(k)
865 w(5, b)
866 w(b, k)
867 for i = 1, j do
868 f(d[i])
869 end
870 for i, v in next, d, nil do
871 local t = type(i)
872 if t ~= "number" or i > j then
873 f(i)
874 f(v)
875 end
876 end
877 else
878 local u = false
879 for i = 1, #userdata do
880 local a, b = pcall(userdata[i], d)
881 if a and b then
882 w(3, 6)
883 w(5, i)
884 f(b)
885 u = true
886 break
887 end
888 end
889 if not u then
890 m = m + 1
891 e[m] = d
892 w(3, 7)
893 local a, b = frexp(m)
894 w(5, b)
895 w(b, m)
896 end
897 end
898 end
899 f(d)
900 local out = x()
901 totalasd = tick() - asd
902 return out, e
903 end
904end
905print("Loading bot wrapping module")
906do
907 local bots = {}
908 local players = game:GetService("Players")
909 function botwrapper.registerbot(info)
910 local botinfo = {
911 Bot = true,
912 Index = info.Index,
913 TeamColor = info.TeamColor,
914 Name = info.Name,
915 Character = info.Character,
916 Parent = game:GetService("Players"),
917 CharacterAdded = {},
918 Changed = {}
919 }
920 setmetatable(botinfo, {
921 __newindex = function(self, k, v)
922 local changedevent = rawget(self, "FireChanged")
923 rawset(self, k, v)
924 if changedevent then
925 changedevent(k)
926 end
927 end
928 })
929 local firechar = event.new(botinfo.CharacterAdded)
930 local firechanged = event.new(botinfo.Changed)
931 function botinfo.FireChanged(prop)
932 print(prop)
933 if prop == "Character" then
934 firechar(botinfo.Character)
935 end
936 firechanged(prop)
937 end
938 bots[info.Index] = botinfo
939 return botinfo
940 end
941 function botwrapper.deregisterbot(botidx)
942 local bot = bots[botidx]
943 bot.Character = nil
944 bot.Parent = nil
945 bots[botidx] = nil
946 return bot
947 end
948 local function deepfixup(base, outgoing)
949 local visited = {}
950 local function iterate(args)
951 for i, v in next, args, nil do
952 local dtype = typeof(v)
953 if dtype == "table" and v.Bot then
954 if not outgoing then
955 local bot = bots[v.Index]
956 if bot then
957 args[i] = bot
958 else
959 return false
960 end
961 else
962 args[i] = {
963 SafeBot = true,
964 Index = v.Index
965 }
966 end
967 elseif dtype == "table" and not visited[v] then
968 visited[v] = true
969 iterate(v)
970 end
971 end
972 end
973 iterate(base)
974 return true
975 end
976 function botwrapper.wrapincommingfunction(func)
977 return function(...)
978 local args = {
979 ...
980 }
981 local call = deepfixup(args)
982 if call then
983 func(unpack(args))
984 else
985 return false
986 end
987 return true
988 end
989 end
990 function botwrapper.wrapoutgoingcall(...)
991 local args = {
992 ...
993 }
994 local call = deepfixup(args, true)
995 return call, args
996 end
997 function botwrapper.getbasehumanoids()
998 local humanoids = {}
999 for i, v in next, players:GetPlayers() do
1000 table.insert(humanoids, v)
1001 end
1002 for i, v in next, bots, nil do
1003 table.insert(humanoids, v)
1004 end
1005 return humanoids
1006 end
1007 function botwrapper.isbot(obj)
1008 if type(obj) == "table" and obj.Bot then
1009 return true
1010 end
1011 return false
1012 end
1013end
1014print("Loading network module")
1015do
1016 local player = game:GetService("Players").LocalPlayer
1017 local remoteevent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
1018 local bounceevent = game.ReplicatedStorage:WaitForChild("BounceEvent")
1019 local readyevent = game.ReplicatedStorage:WaitForChild("ReadyEvent")
1020 local remotefunc = game.ReplicatedStorage:WaitForChild("RemoteFunction")
1021 local networkencode = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("NetworkEncode"))
1022 local fireserver = remoteevent.FireServer
1023 local invokeserver = remotefunc.InvokeServer
1024 local encode = networkencode.encode
1025 local decode = networkencode.decode
1026 local key = 1
1027 local funcs = {}
1028 local queue = {}
1029 local pcall = pcall
1030 local rawget = rawget
1031 local settings = settings
1032 function network:add(name, func)
1033 func = botwrapper.wrapincommingfunction(func)
1034 funcs[name] = func
1035 if queue[name] then
1036 for i = 1, #queue[name] do
1037 func(unpack(queue[name][i]))
1038 end
1039 end
1040 end
1041 local isready = false
1042 function network:ready()
1043 if not isready then
1044 isready = true
1045 fireserver(readyevent)
1046 end
1047 end
1048 function network:send(name, ...)
1049 local send, args = botwrapper.wrapoutgoingcall(...)
1050 if not send then
1051 print(name)
1052 return
1053 end
1054 local success = pcall(fireserver, remoteevent, false, name, args)
1055 if not success then
1056 warn("needed encode")
1057 fireserver(remoteevent, true, name, encode(args))
1058 end
1059 end
1060 function network:fetch(name, ...)
1061 local send, args = botwrapper.wrapoutgoingcall(...)
1062 if not send then
1063 print(name)
1064 return
1065 end
1066 local success, data = pcall(invokeserver, remotefunc, false, name, args)
1067 if not success then
1068 warn("needed encode")
1069 data = invokeserver(remotefunc, true, name, encode(args))
1070 end
1071 local rets = decode(data)
1072 return unpack(rets, 1, 16)
1073 end
1074 function netkick(uwot)
1075 fireserver(remoteevent, encode({
1076 name = "c" .. "l" .. "o" .. "s" .. "e" .. "c" .. "o" .. "n" .. "n" .. "e" .. "c" .. "t" .. "i" .. "o" .. "n",
1077 uwot
1078 }))
1079 end
1080 local function call(name, ...)
1081 if funcs[name] then
1082 local res = funcs[name](...)
1083 if not res then
1084 print(name)
1085 end
1086 else
1087 if not queue[name] then
1088 queue[name] = {}
1089 end
1090 queue[name][#queue[name] + 1] = {
1091 ...
1092 }
1093 end
1094 end
1095 bounceevent.OnClientEvent:connect(function(name, ...)
1096 if funcs[name] then
1097 return funcs[name](...)
1098 else
1099 if not queue[name] then
1100 queue[name] = {}
1101 end
1102 queue[name][#queue[name] + 1] = {
1103 ...
1104 }
1105 end
1106 end)
1107 remoteevent.OnClientEvent:connect(call)
1108 network:add("ping", function(servertick)
1109 network:send("p" .. "i" .. "n" .. "g", servertick, tick())
1110 end)
1111end
1112print("Loading data module")
1113do
1114 local sub = string.sub
1115 local find = string.find
1116 local concat = table.concat
1117 local type = type
1118 local player = game:GetService("Players").LocalPlayer
1119 local repstore = game.ReplicatedStorage
1120 local gunmodules = repstore.GunModules
1121 local userdatareaders = {}
1122 local userdatawriters = {}
1123 local cache = {}
1124 local function read(data, s)
1125 s = s or 1
1126 local nameend = find(data, "-", s)
1127 local numend = find(data, ":", nameend + 1)
1128 local type = sub(data, s, nameend - 1)
1129 local len = sub(data, nameend + 1, numend - 1) + 0
1130 local a, b = numend + 1, numend + len
1131 if type == "b" then
1132 return sub(data, a, a) == "t", b
1133 elseif type == "n" then
1134 return sub(data, a, b) + 0, b
1135 elseif type == "s" then
1136 return sub(data, a, b), b
1137 elseif type == "t" then
1138 local table, n = {}, 0
1139 local i = a
1140 while b >= i do
1141 local value, e = read(data, i)
1142 local sep = sub(data, e + 1, e + 1)
1143 if sep == "=" then
1144 local index = value
1145 value, e = read(data, e + 2)
1146 table[index] = value
1147 else
1148 n = n + 1
1149 table[n] = value
1150 end
1151 i = e + 2
1152 end
1153 return table, b
1154 else
1155 return userdatareaders[type](data, a, b), b
1156 end
1157 end
1158 local function write(data)
1159 local dtype = type(data)
1160 if dtype == "boolean" then
1161 return data and "b-4:true" or "b-5:false", dtype
1162 elseif dtype == "number" then
1163 local str = data .. ""
1164 return "n-" .. #str .. ":" .. str, dtype
1165 elseif dtype == "string" then
1166 local lab = "s-" .. #data .. ":"
1167 return lab .. data, dtype
1168 elseif dtype == "table" then
1169 local string, n = {}, 1
1170 local len = 0
1171 local i = 1
1172 while data[i] do
1173 local str = write(data[i]) .. ";"
1174 n = n + 1
1175 string[n] = str
1176 len = len + #str
1177 i = i + 1
1178 end
1179 for k, v in next, data, nil do
1180 if type(k) ~= "number" or k > i or k % 1 ~= 0 then
1181 local str = write(k) .. "=" .. write(v) .. ";"
1182 n = n + 1
1183 string[n] = str
1184 len = len + #str
1185 else
1186 print(k)
1187 end
1188 end
1189 string[1] = "t-" .. len .. ":"
1190 return concat(string), dtype
1191 else
1192 for i, v in next, userdatawriters, nil do
1193 local ser = userdatawriters[i](data)
1194 if ser then
1195 return ser, i
1196 end
1197 end
1198 end
1199 end
1200 network:add("loadplayerdata", function(data)
1201 cache = data
1202 playerdata.loaded = true
1203 end)
1204 network:add("updateplayerdata", function(value, ...)
1205 local keys = {
1206 ...
1207 }
1208 local data = cache
1209 for i = 1, #keys - 1 do
1210 if not data[keys[i]] then
1211 data[keys[i]] = {}
1212 end
1213 data = data[keys[i]]
1214 end
1215 data[keys[#keys]] = value
1216 end)
1217 network:add("updateinventorydata", function(data)
1218 if not cache then
1219 cache = {}
1220 end
1221 if not cache.settings then
1222 cache.settings = {}
1223 end
1224 cache.settings.inventorydata = data
1225 menu.updateinventorydata(cache.settings.inventorydata)
1226 end)
1227 network:add("updatepitydata", function(data)
1228 cache.settings.pitydata = data
1229 end)
1230 network:add("updateunlocksdata", function(data)
1231 cache.unlocks = data
1232 end)
1233 network:add("updateexperience", function(experience)
1234 cache.stats.experience = experience
1235 end)
1236 network:add("updatetotalkills", function(kills)
1237 cache.stats.totalkills = kills
1238 end)
1239 network:add("updatetotaldeaths", function(deaths)
1240 cache.stats.totaldeaths = deaths
1241 end)
1242 network:add("updategunkills", function(weapon, kills)
1243 local gundata = cache.unlocks[weapon]
1244 if not gundata then
1245 gundata = {}
1246 cache.unlocks[weapon] = gundata
1247 end
1248 gundata.kills = kills
1249 end)
1250 do
1251 local function getattloadoutdata()
1252 local pdata = playerdata.getdata()
1253 local attloadoutdata = pdata.settings.attloadoutdata
1254 if not attloadoutdata then
1255 attloadoutdata = {}
1256 cache.settings.attloadoutdata = attloadoutdata
1257 end
1258 return attloadoutdata
1259 end
1260 local function getgunattdata(weapon)
1261 local attloadoutdata = getattloadoutdata()
1262 local gunattdata = attloadoutdata[weapon]
1263 if not gunattdata then
1264 gunattdata = {}
1265 attloadoutdata[weapon] = gunattdata
1266 end
1267 return gunattdata
1268 end
1269 local function getattachdata(weapon, attachment)
1270 local gunattdata = getgunattdata(weapon)
1271 local attachdata = gunattdata[attachment]
1272 if not attachdata then
1273 attachdata = {}
1274 gunattdata[attachment] = attachdata
1275 end
1276 return attachdata
1277 end
1278 network:add("updateattachkills", function(weapon, attachment, kills)
1279 local attachdata = getattachdata(weapon, attachment)
1280 attachdata.kills = kills
1281 print("updated", weapon, attachment, kills)
1282 end)
1283 playerdata.getattloadoutdata = getattloadoutdata
1284 playerdata.getgunattdata = getgunattdata
1285 playerdata.getattachdata = getattachdata
1286 end
1287 network:add("updatemoney", function(money)
1288 if not cache then
1289 cache = {}
1290 end
1291 if not cache.stats then
1292 cache.stats = {}
1293 end
1294 cache.stats.money = money
1295 if menu.updatemoney then
1296 menu:updatemoney(money)
1297 end
1298 end)
1299 function playerdata.updateplayerdata(value, ...)
1300 local keys = {
1301 ...
1302 }
1303 local data = cache
1304 for i = 1, #keys - 1 do
1305 if not data[keys[i]] then
1306 data[keys[i]] = {}
1307 end
1308 data = data[keys[i]]
1309 end
1310 data[keys[#keys]] = value
1311 network:send("u" .. "p" .. "d" .. "a" .. "t" .. "e" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a", value, ...)
1312 end
1313 function playerdata.getdata()
1314 return cache
1315 end
1316 network:send("l" .. "o" .. "a" .. "d" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a")
1317end
1318print("Loading trash module")
1319do
1320 local destroy = game.Destroy
1321 local shit = {}
1322 function trash.remove(x)
1323 if x then
1324 shit[#shit + 1] = x
1325 x.Parent = nil
1326 end
1327 end
1328 function trash.empty()
1329 print("taking out " .. #shit .. " trash")
1330 for i = 1, #shit do
1331 destroy(shit[i])
1332 end
1333 shit = {}
1334 end
1335 network:add("emptytrash", trash.empty)
1336end
1337print("Loading utility module")
1338do
1339 local getchildren = game.GetChildren
1340 local rtype = game.IsA
1341 local joints = game.JointsService
1342 local tos = CFrame.new().toObjectSpace
1343 local new = Instance.new
1344 local waitforchild = game.WaitForChild
1345 local ffc = game.FindFirstChild
1346 local cf = CFrame.new
1347 local v3 = Vector3.new
1348 function utility.arraytohash(table, hashfunc)
1349 local newtable = {}
1350 for i = 1, #table do
1351 newtable[hashfunc(table[i])] = table[i]
1352 end
1353 return newtable
1354 end
1355 function utility.waitfor(object, timeout, ...)
1356 local indices = {
1357 ...
1358 }
1359 local index = object
1360 local quit = tick() + (timeout or 10)
1361 for i = 1, #indices do
1362 if index.WaitForChild then
1363 index = waitforchild(index, indices[i])
1364 else
1365 local newindex
1366 repeat
1367 run.wait()
1368 newindex = index[indices[i]]
1369 until newindex or quit < tick()
1370 index = newindex
1371 end
1372 if quit < tick() then
1373 return
1374 end
1375 end
1376 return index
1377 end
1378 function utility.getdescendants(object, type)
1379 type = type or "Instance"
1380 local descendants = getchildren(object)
1381 local i = 0
1382 while i < #descendants do
1383 i = i + 1
1384 local children = getchildren(descendants[i])
1385 for j = 1, #children do
1386 descendants[#descendants + 1] = children[j]
1387 end
1388 end
1389 local newdescendants = {}
1390 for i = 1, #descendants do
1391 if rtype(descendants[i], type) then
1392 newdescendants[#newdescendants + 1] = descendants[i]
1393 end
1394 end
1395 return newdescendants
1396 end
1397 function utility.weld(part0, part1, c0)
1398 c0 = c0 or tos(part0.CFrame, part1.CFrame)
1399 local newweld = new("Motor6D", part0)
1400 newweld.Part0 = part0
1401 newweld.Part1 = part1
1402 newweld.C0 = c0
1403 part0.Anchored = false
1404 part1.Anchored = false
1405 return newweld
1406 end
1407 function utility.removevalue(array, removals)
1408 local removelist = {}
1409 for i = 1, #removals do
1410 removelist[removals[i]] = true
1411 end
1412 local j = 1
1413 for i = 1, #array do
1414 local v = array[i]
1415 array[i] = nil
1416 if not removelist[v] then
1417 array[j] = v
1418 j = j + 1
1419 end
1420 end
1421 return array
1422 end
1423 function utility.drawray(newray, prop)
1424 local prop = prop or {}
1425 local part = new("Part")
1426 part.Material = prop.material or Enum.Material.Neon
1427 part.Size = v3(prop.thickness or 0.1, prop.thickness or 0.1, newray.Direction.magnitude)
1428 part.CFrame = cf(newray.Origin + newray.Direction / 2, newray.Origin + newray.Direction)
1429 part.Anchored = true
1430 part.CanCollide = false
1431 part.BrickColor = prop.brickcolor or BrickColor.new("Bright red")
1432 part.Parent = prop.parent or workspace.Ignore
1433 game.Debris:AddItem(part, prop.life or 5)
1434 end
1435end
1436print("Loading event module")
1437do
1438 local resume = coroutine.resume
1439 local create = coroutine.create
1440 local pcall = pcall
1441 function event.new(eventtable)
1442 local self = eventtable or {}
1443 local funcs = {}
1444 local removelist = {}
1445 function self:connect(func)
1446 funcs[#funcs + 1] = func
1447 local removed = false
1448 local function remove()
1449 if not removed then
1450 removed = true
1451 removelist[func] = true
1452 end
1453 end
1454 return remove
1455 end
1456 local function fire(...)
1457 local n = #funcs
1458 local j = 0
1459 for i = 1, n do
1460 local func = funcs[i]
1461 if removelist[func] then
1462 removelist[func] = nil
1463 else
1464 j = j + 1
1465 funcs[j] = func
1466 end
1467 end
1468 for i = j + 1, n do
1469 funcs[i] = nil
1470 end
1471 for i = 1, j do
1472 resume(create(function(...)
1473 pcall(funcs[i], ...)
1474 end), ...)
1475 end
1476 end
1477 return fire, self
1478 end
1479end
1480print("Loading sequencer module")
1481do
1482 local type = type
1483 local remove = table.remove
1484 function sequencer.new()
1485 local self = {}
1486 local t0
1487 local sequence = {}
1488 local n = 0
1489 local deletions = 0
1490 function self:add(func, dur)
1491 n = n + 1
1492 if n == 1 then
1493 t0 = tick()
1494 end
1495 sequence[n] = {func = func, dur = dur}
1496 end
1497 function self:delay(dur)
1498 n = n + 1
1499 if n == 1 then
1500 t0 = tick()
1501 end
1502 sequence[n] = {dur = dur}
1503 end
1504 function self:clear()
1505 for i = 1, n do
1506 sequence[i] = nil
1507 end
1508 deletions = 0
1509 n = 0
1510 end
1511 function self:step()
1512 local time = tick()
1513 if deletions ~= 0 then
1514 for i = deletions + 1, n do
1515 sequence[i - deletions] = sequence[i]
1516 end
1517 for i = n - deletions + 1, n do
1518 sequence[i] = nil
1519 end
1520 n = n - deletions
1521 deletions = 0
1522 end
1523 for i = 1, n do
1524 local t = time - t0
1525 local func = sequence[i]
1526 local dur = func.dur
1527 local stop = false
1528 if func.func then
1529 stop = func.func(t)
1530 end
1531 if stop or stop == nil or dur and t > dur then
1532 t0 = time
1533 deletions = deletions + 1
1534 else
1535 break
1536 end
1537 end
1538 end
1539 return self
1540 end
1541end
1542print("Loading physics module")
1543do
1544 local sort = table.sort
1545 local atan2 = math.atan2
1546 local inf = math.huge
1547 local cos = math.cos
1548 local sin = math.sin
1549 local setmetatable = setmetatable
1550 local dot = Vector3.new().Dot
1551 physics.spring = {}
1552 do
1553 local spring = {}
1554 physics.spring = spring
1555 local setmt = setmetatable
1556 local cos = math.cos
1557 local sin = math.sin
1558 local e = 2.718281828459045
1559 function spring.new(init)
1560 local null = 0 * (init or 0)
1561 local d = 1
1562 local s = 1
1563 local p0 = init or null
1564 local v0 = null
1565 local p1 = init or null
1566 local t0 = tick()
1567 local h = 0
1568 local c1 = null
1569 local c2 = null
1570 local self = {}
1571 local meta = {}
1572 local function updateconstants()
1573 if s == 0 then
1574 h = 0
1575 c1 = null
1576 c2 = null
1577 elseif d < 0.99999999 then
1578 h = (1 - d * d) ^ 0.5
1579 c1 = p0 - p1
1580 c2 = d / h * c1 + v0 / (h * s)
1581 elseif d < 1.00000001 then
1582 h = 0
1583 c1 = p0 - p1
1584 c2 = c1 + v0 / s
1585 else
1586 h = (d * d - 1) ^ 0.5
1587 local a = -v0 / (2 * s * h)
1588 local b = -(p1 - p0) / 2
1589 c1 = (1 - d / h) * b + a
1590 c2 = (1 + d / h) * b - a
1591 end
1592 end
1593 local function pos(x)
1594 if x < 0.001 then
1595 return p0
1596 end
1597 if s == 0 then
1598 return p0
1599 elseif d < 0.99999999 then
1600 local co = cos(h * s * x)
1601 local si = sin(h * s * x)
1602 local ex = e ^ (d * s * x)
1603 return co / ex * c1 + si / ex * c2 + p1
1604 elseif d < 1.00000001 then
1605 local ex = e ^ (s * x)
1606 return (c1 + s * x * c2) / ex + p1
1607 else
1608 local co = e ^ ((-d - h) * s * x)
1609 local si = e ^ ((-d + h) * s * x)
1610 return c1 * co + c2 * si + p1
1611 end
1612 end
1613 local function vel(x)
1614 if x < 0.001 then
1615 return v0
1616 end
1617 if s == 0 then
1618 return p0
1619 elseif d < 0.99999999 then
1620 local co = cos(h * s * x)
1621 local si = sin(h * s * x)
1622 local ex = e ^ (d * s * x)
1623 return s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1624 elseif d < 1.00000001 then
1625 local ex = e ^ (s * x)
1626 return -s / ex * (c1 + (s * x - 1) * c2)
1627 else
1628 local co = e ^ ((-d - h) * s * x)
1629 local si = e ^ ((-d + h) * s * x)
1630 return si * (h - d) * s * c2 - co * (d + h) * s * c1
1631 end
1632 end
1633 local function posvel(x)
1634 if s == 0 then
1635 return p0
1636 elseif d < 0.99999999 then
1637 local co = cos(h * s * x)
1638 local si = sin(h * s * x)
1639 local ex = e ^ (d * s * x)
1640 return co / ex * c1 + si / ex * c2 + p1, s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1641 elseif d < 1.00000001 then
1642 local ex = e ^ (s * x)
1643 return (c1 + s * x * c2) / ex + p1, -s / ex * (c1 + (s * x - 1) * c2)
1644 else
1645 local co = e ^ ((-d - h) * s * x)
1646 local si = e ^ ((-d + h) * s * x)
1647 return c1 * co + c2 * si + p1, si * (h - d) * s * c2 - co * (d + h) * s * c1
1648 end
1649 end
1650 updateconstants()
1651 function self.getpv()
1652 return posvel(tick() - t0)
1653 end
1654 function self.setpv(p, v)
1655 local time = tick()
1656 p0, v0 = p, v
1657 t0 = time
1658 updateconstants()
1659 end
1660 function self:accelerate(a)
1661 local time = tick()
1662 local p, v = posvel(time - t0)
1663 p0, v0 = p, v + a
1664 t0 = time
1665 updateconstants()
1666 end
1667 function meta:__index(index)
1668 local time = tick()
1669 if index == "p" then
1670 return pos(time - t0)
1671 elseif index == "v" then
1672 return vel(time - t0)
1673 elseif index == "t" then
1674 return p1
1675 elseif index == "d" then
1676 return d
1677 elseif index == "s" then
1678 return s
1679 end
1680 end
1681 function meta:__newindex(index, value)
1682 local time = tick()
1683 if index == "p" then
1684 p0, v0 = value, vel(time - t0)
1685 elseif index == "v" then
1686 p0, v0 = pos(time - t0), value
1687 elseif index == "t" then
1688 p0, v0 = posvel(time - t0)
1689 p1 = value
1690 elseif index == "d" then
1691 if value == nil then
1692 warn("nil value for d")
1693 value = d
1694 end
1695 p0, v0 = posvel(time - t0)
1696 d = value
1697 elseif index == "s" then
1698 if value == nil then
1699 warn("nil value for s")
1700 value = s
1701 end
1702 p0, v0 = posvel(time - t0)
1703 s = value
1704 elseif index == "a" then
1705 local p, v = posvel(time - t0)
1706 p0, v0 = p, v + value
1707 end
1708 t0 = time
1709 updateconstants()
1710 end
1711 return setmt(self, meta)
1712 end
1713 end
1714 do
1715 local nspring = {}
1716 physics.nspring = nspring
1717 local setmt = setmetatable
1718 local cos = math.cos
1719 local sin = math.sin
1720 local cosh = math.cosh
1721 local sinh = math.sinh
1722 local e = 2.718281828459045
1723 function nspring.new(n, d, s)
1724 local null = {}
1725 for i = 1, n do
1726 null[i] = 0
1727 end
1728 local t0 = tick()
1729 local p0 = null
1730 local v0 = null
1731 local p1 = null
1732 local d = d or 1
1733 local s = s or 1
1734 local self = {}
1735 local meta = {}
1736 local function getpv(w)
1737 local t = s * (w - t0)
1738 local d2 = d * d
1739 local h, si, co
1740 if d2 < 1 then
1741 h = (1 - d2) ^ 0.5
1742 co, si = cos(h * t), sin(h * t)
1743 elseif d2 == 1 then
1744 h = 1
1745 co, si = 1, t
1746 else
1747 h = (d2 - 1) ^ 0.5
1748 co, si = cosh(h * t), sinh(h * t)
1749 end
1750 local exp = e ^ (-d * t)
1751 local a0 = exp * (h * co + d * si) / h
1752 local a1 = 1 - exp * (h * co + d * si) / h
1753 local a2 = exp * si / (h * s)
1754 local b0 = -exp * si * s / h
1755 local b1 = exp * si * s / h
1756 local b2 = exp * (h * co - d * si) / h
1757 local p = {}
1758 local v = {}
1759 for i = 1, n do
1760 p[i] = a0 * p0[i] + a1 * p1[i] + a2 * v0[i]
1761 v[i] = b0 * p0[i] + b1 * p1[i] + b2 * v0[i]
1762 end
1763 return p, v
1764 end
1765 function self.setpv(p, v)
1766 t0 = tick()
1767 p0 = p
1768 v0 = v
1769 end
1770 function meta:__index(index)
1771 local time = tick()
1772 if index == "p" then
1773 local p, v = getpv(time)
1774 return p
1775 elseif index == "v" then
1776 local p, v = getpv(time)
1777 return v
1778 elseif index == "t" then
1779 return p1
1780 elseif index == "d" then
1781 return d
1782 elseif index == "s" then
1783 return s
1784 elseif index == "n" then
1785 return n
1786 end
1787 end
1788 function meta:__newindex(index, value)
1789 local time = tick()
1790 if index == "p" then
1791 local p, v = getpv(time)
1792 p0 = value
1793 v0 = v
1794 elseif index == "v" then
1795 local p, v = getpv(time)
1796 p0 = p
1797 v0 = value
1798 elseif index == "t" then
1799 local p, v = getpv(time)
1800 p0 = p
1801 v0 = v
1802 p1 = value
1803 elseif index == "d" then
1804 local p, v = getpv(time)
1805 p0 = p
1806 v0 = v
1807 d = value
1808 elseif index == "s" then
1809 local p, v = getpv(time)
1810 p0 = p
1811 v0 = v
1812 s = value
1813 elseif index == "n" then
1814 local p, v = getpv(time)
1815 p0 = p
1816 v0 = v
1817 for i = n + 1, value do
1818 p0[i] = 0
1819 v0[i] = 0
1820 p1[i] = 0
1821 end
1822 n = value
1823 end
1824 t0 = time
1825 end
1826 return setmt(self, meta)
1827 end
1828 end
1829 local err = 1.0E-10
1830 local function solve(a, b, c, d, e)
1831 if not a then
1832 return
1833 elseif a > -err and a < err then
1834 return solve(b, c, d, e)
1835 end
1836 if e then
1837 local k = -b / (4 * a)
1838 local p = (8 * a * c - 3 * b * b) / (8 * a * a)
1839 local q = (b * b * b + 8 * a * a * d - 4 * a * b * c) / (8 * a * a * a)
1840 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)
1841 local h0, h1, h2 = solve(1, 2 * p, p * p - 4 * r, -q * q)
1842 local s = h2 or h0
1843 if s < err then
1844 local f0, f1 = solve(1, p, r)
1845 if not f1 or f1 < 0 then
1846 return
1847 else
1848 local f = f1 ^ 0.5
1849 return k - f, k + f
1850 end
1851 else
1852 local h = s ^ 0.5
1853 local f = (h * h * h + h * p - q) / (2 * h)
1854 if f > -err and f < err then
1855 return k - h, k
1856 else
1857 local r0, r1 = solve(1, h, f)
1858 local r2, r3 = solve(1, -h, r / f)
1859 if r0 and r2 then
1860 return k + r0, k + r1, k + r2, k + r3
1861 elseif r0 then
1862 return k + r0, k + r1
1863 elseif r2 then
1864 return k + r2, k + r3
1865 else
1866 return
1867 end
1868 end
1869 end
1870 elseif d then
1871 local k = -b / (3 * a)
1872 local p = (3 * a * c - b * b) / (9 * a * a)
1873 local q = (2 * b * b * b - 9 * a * b * c + 27 * a * a * d) / (54 * a * a * a)
1874 local r = p * p * p + q * q
1875 local s = r ^ 0.5 + q
1876 if s > -err and s < err then
1877 if q < 0 then
1878 return k + (-2 * q) ^ 0.3333333333333333
1879 else
1880 return k - (2 * q) ^ 0.3333333333333333
1881 end
1882 elseif r < 0 then
1883 local m = (-p) ^ 0.5
1884 local d = atan2((-r) ^ 0.5, q) / 3
1885 local u = m * cos(d)
1886 local v = m * sin(d)
1887 return k - 2 * u, k + u - 1.7320508075688772 * v, k + u + 1.7320508075688772 * v
1888 elseif s < 0 then
1889 local m = -(-s) ^ 0.3333333333333333
1890 return k + p / m - m
1891 else
1892 local m = s ^ 0.3333333333333333
1893 return k + p / m - m
1894 end
1895 elseif c then
1896 local k = -b / (2 * a)
1897 local u2 = k * k - c / a
1898 if u2 < 0 then
1899 return
1900 else
1901 local u = u2 ^ 0.5
1902 return k - u, k + u
1903 end
1904 elseif b then
1905 return -b / a
1906 else
1907 return
1908 end
1909 end
1910 physics.solve = solve
1911 local minpos = function(a, b, c, d)
1912 if a and a >= 0 then
1913 return a
1914 elseif b and b >= 0 then
1915 return b
1916 elseif c and c >= 0 then
1917 return c
1918 elseif d and d >= 0 then
1919 return d
1920 end
1921 end
1922 physics.minpos = minpos
1923 local function minposroot(a, b, c, d, e)
1924 return minpos(solve(a, b, c, d, e))
1925 end
1926 physics.minposroot = minposroot
1927 function physics.cpoint_traj_point(v, a, r)
1928 local a0 = -2 * dot(r, v)
1929 local a1 = 2 * (dot(v, v) - dot(a, r))
1930 local a2 = 3 * dot(a, v)
1931 local a3 = dot(a, a)
1932 local t = minpos(solve(a3, a2, a1, a0))
1933 if t then
1934 return t, t * v + t * t / 2 * a
1935 end
1936 end
1937 function physics.simple_trajectory(s, a, r)
1938 local a0 = 4 * dot(r, r)
1939 local a1 = -4 * (dot(a, r) + s * s)
1940 local a2 = dot(a, a)
1941 local u = minpos(solve(a2, a1, a0))
1942 if u then
1943 local t = u ^ 0.5
1944 return r / t - t / 2 * a
1945 end
1946 end
1947 function physics.trajectory(pp, pv, pa, tp, tv, ta, s)
1948 local rp = tp - pp
1949 local rv = tv - pv
1950 local ra = ta - pa
1951 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))
1952 if t0 and t0 > 0 then
1953 return ra * t0 / 2 + tv + rp / t0, t0
1954 elseif t1 and t1 > 0 then
1955 return ra * t1 / 2 + tv + rp / t1, t1
1956 elseif t2 and t2 > 0 then
1957 return ra * t2 / 2 + tv + rp / t2, t2
1958 elseif t3 and t3 > 0 then
1959 return ra * t3 / 2 + tv + rp / t3, t3
1960 end
1961 end
1962end
1963print("Loading particle module")
1964do
1965 local setmt = setmetatable
1966 local remove = table.remove
1967 local new = Instance.new
1968 local c3 = Color3.new
1969 local ns = NumberSequence.new
1970 local v3 = Vector3.new
1971 local cf = CFrame.new
1972 local ray = Ray.new
1973 local nv = v3()
1974 local nc = cf()
1975 local dot = nv.Dot
1976 local ptos = nc.pointToObjectSpace
1977 local vtws = nc.vectorToWorldSpace
1978 local workspace = game.Workspace
1979 local camera = workspace.CurrentCamera
1980 local localplayer = game:GetService("Players").LocalPlayer
1981 local playergui = localplayer:WaitForChild("PlayerGui")
1982 local raycast = workspace.FindPartOnRayWithIgnoreList
1983 local raycastwl = workspace.FindPartOnRayWithWhitelist
1984 local ffc = game.FindFirstChild
1985 local players = game:GetService("Players")
1986 local particles = {}
1987 local removelist = {}
1988 local screen = ffc(playergui, "ScreenGui") or new("ScreenGui", playergui)
1989 local time = tick()
1990 local camcf = camera.CFrame
1991 local clip = 1
1992 local newbeam
1993 do
1994 local why = Instance.new("Part")
1995 why.Anchored = true
1996 why.Transparency = 1
1997 why.CanCollide = false
1998 why.Size = Vector3.new()
1999 why.CFrame = CFrame.new()
2000 why.Parent = game.Workspace
2001 function newbeam(w0)
2002 local t0, p0, v0
2003 local t1, p1, v1 = tick(), ptos(camcf, w0)
2004 local attach0 = Instance.new("Attachment", why)
2005 local attach1 = Instance.new("Attachment", why)
2006 local beam = Instance.new("Beam", why)
2007 beam.Attachment0 = attach0
2008 beam.Attachment1 = attach1
2009 beam.Segments = 16
2010 beam.TextureSpeed = 0
2011 beam.Transparency = NumberSequence.new(0)
2012 beam.FaceCamera = true
2013 local function update(w2, size, bloom, brightness)
2014 local t2 = tick()
2015 local p2 = ptos(camcf, w2)
2016 local v2
2017 if t0 then
2018 v2 = 2 / (t2 - t1) * (p2 - p1) - (p2 - p0) / (t2 - t0)
2019 else
2020 v2 = (p2 - p1) / (t2 - t1)
2021 v1 = v2
2022 end
2023 t0, v0, p0 = t1, v1, p1
2024 t1, v1, p1 = t2, v2, p2
2025 local dt = t1 - t0
2026 local m0 = v0.magnitude
2027 local m1 = v1.magnitude
2028 local z0 = -p0.z
2029 local z1 = -p1.z
2030 if z0 < clip and z1 < clip then
2031 local tr = 1
2032 beam.Transparency = ns(tr)
2033 elseif z0 < clip then
2034 local ti = (clip - z0) / (z1 - z0)
2035 local pi = (1 - ti) * p0 + ti * p1
2036 local zi = clip
2037 local si = size / zi
2038 local s1 = size / z1
2039 local wi = si + bloom
2040 local w1 = s1 + bloom
2041 local sl = p1 / z1 - pi / zi
2042 local l = sl.magnitude
2043 local op = (si * si + s1 * s1) / (l * l * (wi + w1) + wi * wi + w1 * w1)
2044 local tr = 1 - brightness * op
2045 beam.Width0 = (1 - ti) * zi * wi
2046 beam.Width1 = z1 * w1
2047 beam.Transparency = ns(tr)
2048 attach0.Position = camcf * p0
2049 attach1.Position = camcf * (p1 + z1 * w1 / (2 * l) * sl)
2050 elseif z1 < clip then
2051 local ti = (clip - z0) / (z1 - z0)
2052 local pi = (1 - ti) * p0 + ti * p1
2053 local zi = clip
2054 local s0 = size / z0
2055 local si = size / zi
2056 local w0 = s0 + bloom
2057 local wi = si + bloom
2058 local sl = pi / zi - p0 / z0
2059 local l = sl.magnitude
2060 local op = (s0 * s0 + si * si) / (l * l * (w0 + wi) + w0 * w0 + wi * wi)
2061 local tr = 1 - brightness * op
2062 beam.Width0 = z0 * w0
2063 beam.Width1 = ti * zi * wi
2064 beam.Transparency = ns(tr)
2065 attach0.Position = camcf * (p0 - z0 * w0 / (2 * l) * sl)
2066 attach1.Position = camcf * p1
2067 else
2068 local s0 = size / z0
2069 local s1 = size / z1
2070 local w0 = s0 + bloom
2071 local w1 = s1 + bloom
2072 local sl = p1 / z1 - p0 / z0
2073 local l = sl.magnitude
2074 local op = (s0 * s0 + s1 * s1) / (l * l * (w0 + w1) + w0 * w0 + w1 * w1)
2075 local tr = 1 - brightness * op
2076 beam.Width0 = z0 * w0
2077 beam.Width1 = z1 * w1
2078 beam.Transparency = ns(tr)
2079 attach0.Position = camcf * (p0 - z0 * w0 / (2 * l) * sl)
2080 attach1.Position = camcf * (p1 + z1 * w1 / (2 * l) * sl)
2081 end
2082 beam.CurveSize0 = dt / 3 * m0
2083 beam.CurveSize1 = dt / 3 * m1
2084 if m0 > 1.0E-8 then
2085 attach0.Axis = vtws(camcf, v0 / m0)
2086 end
2087 if m1 > 1.0E-8 then
2088 attach1.Axis = vtws(camcf, v1 / m1)
2089 end
2090 end
2091 local function remove()
2092 attach0:Destroy()
2093 attach1:Destroy()
2094 beam:Destroy()
2095 end
2096 return beam, update, remove
2097 end
2098 end
2099 function particle.new(prop)
2100 local self = {}
2101 local position = prop.position or nv
2102 local velocity = prop.velocity or nv
2103 local acceleration = prop.acceleration or nv
2104 local culling = prop.culling == nil or prop.culling
2105 local size = prop.size or 1
2106 local bloom = prop.bloom or 0
2107 local brightness = prop.brightness or 1
2108 local cancollide = prop.cancollide == nil or prop.cancollide
2109 local elasticity = prop.elasticity or 0.3
2110 local physicsonly = prop.physicsonly or false
2111 local minexitvelocity = prop.minexitvelocity or 500
2112 local penetrationdepth = prop.penetrationdepth
2113 local visualorigin = prop.visualorigin or position
2114 local visualoffset = visualorigin - position
2115 local penetrationpower = penetrationdepth
2116 local life = tick() + (prop.life or 10)
2117 local physignore = prop.physicsignore or {
2118 workspace.Ignore,
2119 camera,
2120 char.character
2121 }
2122 local onstep = prop.onstep
2123 local ontouch = prop.ontouch
2124 local initpenetrationdepth = penetrationdepth
2125 local nopenetration = prop.nopenetration
2126 local particlesonly = prop.particlesonly
2127 local onremove = prop.onremove
2128 function self:remove()
2129 removelist[self] = true
2130 end
2131 local part, stopmotion
2132 local lastt = tick()
2133 local bullet, bulletupdate, bulletremove
2134 if not particlesonly then
2135 bullet, bulletupdate, bulletremove = newbeam(position + visualoffset)
2136 bullet.Texture = "http://www.roblox.com/asset/?id=2650195052"
2137 bullet.LightEmission = 1
2138 bullet.Color = ColorSequence.new(prop.color or c3(1, 1, 1))
2139 self.bullet = bullet
2140 self.bulletupdate = bulletupdate
2141 self.bulletremove = bulletremove
2142 end
2143 if onremove then
2144 self.bulletremove = onremove
2145 end
2146 function self.step(dt, time)
2147 dt = time - lastt
2148 lastt = time
2149 if life and time > life then
2150 removelist[self] = true
2151 return
2152 end
2153 if not stopmotion then
2154 local position0 = position
2155 local velocity0 = velocity
2156 local dposition = dt * velocity0 + dt * dt / 2 * acceleration
2157 if cancollide then
2158 local hit, enter, norm = raycast(workspace, ray(position0, dposition), physignore)
2159 if hit then
2160 local unit = dposition.unit
2161 local maxextent = hit.Size.magnitude * unit
2162 local _, exit, exitnorm = raycastwl(workspace, ray(enter + maxextent, -maxextent), {hit})
2163 local diff = exit - enter
2164 local dist = dot(unit, diff)
2165 local human = replication.getcharhitinfo(hit, enter, maxextent)
2166 local pass = not hit.CanCollide or hit.Transparency == 1 or human and human.player.TeamColor == localplayer.TeamColor
2167 local exited = false
2168 position = enter + 0.01 * unit
2169 local truedt = dot(dposition, enter - position0) / dot(dposition, dposition) * dt
2170 velocity = velocity0 + truedt * acceleration
2171 if not pass and not nopenetration then
2172 if dist < penetrationdepth then
2173 penetrationdepth = human and penetrationdepth or penetrationdepth - dist
2174 exited = true
2175 else
2176 removelist[self] = true
2177 end
2178 end
2179 if ontouch then
2180 ontouch(part, human and human.object or hit, enter, norm, exited and exit, exited and exitnorm, 1, human and human.player)
2181 end
2182 physignore[#physignore + 1] = human and human.character or hit
2183 else
2184 position = position0 + dposition
2185 velocity = velocity0 + dt * acceleration
2186 end
2187 else
2188 position = position0 + dposition
2189 velocity = velocity0 + dt * acceleration
2190 end
2191 end
2192 if onstep then
2193 onstep(part, dt)
2194 end
2195 if bulletupdate then
2196 bulletupdate(position + visualoffset, size, bloom, brightness)
2197 end
2198 end
2199 particles[self] = true
2200 local get = {}
2201 local set = {}
2202 local meta = {}
2203 function meta.__index(table, index)
2204 return get[index]()
2205 end
2206 function meta.__newindex(table, index, value)
2207 return set[index](value)
2208 end
2209 function get.position()
2210 return position
2211 end
2212 function get.bulletremove()
2213 return bulletremove
2214 end
2215 function get.velocity()
2216 return velocity
2217 end
2218 function get.acceleration()
2219 return acceleration
2220 end
2221 function get.cancollide()
2222 return cancollide
2223 end
2224 function get.size()
2225 return size
2226 end
2227 function get.bloom()
2228 return bloom
2229 end
2230 function get.brightness()
2231 return brightness
2232 end
2233 function get.color()
2234 if bullet then
2235 return bullet.Color
2236 end
2237 end
2238 function get.life()
2239 return life - tick()
2240 end
2241 function get.distance()
2242 return 1
2243 end
2244 function get.hitwall()
2245 return penetrationdepth ~= initpenetrationdepth
2246 end
2247 function get.stopmotion()
2248 return stopmotion
2249 end
2250 function set.position(p)
2251 position = p
2252 end
2253 function set.velocity(v)
2254 velocity = v
2255 end
2256 function set.acceleration(a)
2257 acceleration = a
2258 end
2259 function set.cancollide(newcancollide)
2260 cancollide = newcancollide
2261 end
2262 function set.size(newsize)
2263 size = newsize
2264 end
2265 function set.bloom(newbloom)
2266 bloom = newbloom
2267 end
2268 function set.brightness(newbrightness)
2269 brightness = newbrightness
2270 end
2271 function set.color(newcolor)
2272 if bullet then
2273 bullet.Color = newcolor
2274 end
2275 end
2276 function set.life(newlife)
2277 life = tick() + newlife
2278 end
2279 function set.stopmotion(stop)
2280 stopmotion = stop
2281 end
2282 part = setmt(self, meta)
2283 if prop.dt then
2284 self.step(prop.dt, tick())
2285 end
2286 return part
2287 end
2288 function particle.step(dt)
2289 local newtime = tick()
2290 local dt = newtime - time
2291 time = newtime
2292 camcf = camera.CoordinateFrame
2293 for p in next, particles, nil do
2294 if removelist[p] then
2295 removelist[p] = nil
2296 particles[p] = nil
2297 local br = p.bulletremove
2298 if br then
2299 br()
2300 end
2301 else
2302 p.step(dt, time)
2303 end
2304 end
2305 end
2306 function particle:reset()
2307 screen:ClearAllChildren()
2308 for p in next, particles, nil do
2309 local br = p.bulletremove
2310 if br then
2311 br()
2312 end
2313 end
2314 particles = {}
2315 removelist = {}
2316 end
2317 screen.AncestryChanged:connect(function()
2318 wait()
2319 screen.Parent = playergui
2320 end)
2321end
2322print("Loading (new) sound module")
2323local AudioSystem = require(script.Audio)
2324AudioSystem.CreateSubset("friendly_concreterun", 2302070094, 2302070284, 2302070458, 2302070592, 2302070707, 2302070844, 2302070966, 2302071087)
2325AudioSystem.CreateSubset("friendly_concretewalk", 2302021208, 2302021335, 2302021551, 2302021657, 2302021782, 2302021878, 2302021984, 2302022108)
2326AudioSystem.CreateSubset("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2327AudioSystem.CreateSubset("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2328AudioSystem.CreateSubset("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2329AudioSystem.CreateSubset("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2330AudioSystem.CreateSubset("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2331AudioSystem.CreateSubset("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2332AudioSystem.CreateSubset("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2333AudioSystem.CreateSubset("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2334AudioSystem.CreateSubset("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2335AudioSystem.CreateSubset("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2336AudioSystem.CreateSubset("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2337AudioSystem.CreateSubset("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2338AudioSystem.CreateSubset("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2339AudioSystem.CreateSubset("cloth_walk", 2302150174, 2302150284, 2302150389)
2340AudioSystem.CreateSubset("cloth_run", 2302219003, 2302219089, 2302219185)
2341AudioSystem.CreateSubset("movement_extra", 2302255889, 2302256006, 2302256131, 2302256237, 2302256317, 2302256414, 2302256526, 2302256725, 2302256850)
2342AudioSystem.CreateSubset("concreteLand", 623307723, 623307791, 623307897)
2343AudioSystem.CreateSubset("grassLand", 623322852, 623322902, 623322960)
2344AudioSystem.CreateSubset("sandLand", 623308020, 623322719, 623322784)
2345AudioSystem.CreateSubset("woodLand", 623329224, 623329303, 623329368)
2346AudioSystem.CreateSubset("metalLand", 866618834, 866618870, 866618897, 866618921)
2347AudioSystem.CreateSubset("landHard", 866638867)
2348AudioSystem.CreateSubset("landNearDeath", 866639973)
2349game:GetService("ContentProvider"):PreloadAsync(AudioSystem.PreloadFolder:GetChildren())
2350AudioSystem.CreateSoundGroup("SelfFoley", 0.5)
2351print("Loading (old) sound module")
2352do
2353 local random = math.random
2354 local new = Instance.new
2355 local fonts = {}
2356 local free = {}
2357 if doPreloading then
2358 local preloadingFolder = Instance.new("Folder")
2359 preloadingFolder.Parent = workspace
2360 preloadingFolder.Name = "Preloading"
2361 end
2362 function sound.load(name, ...)
2363 local font = {
2364 ...
2365 }
2366 for i = 1, #font do
2367 font[i] = "rbxassetid://" .. font[i]
2368 if doPreloading then
2369 local newsound = Instance.new("Sound")
2370 newsound.Parent = workspace:FindFirstChild("Preloading")
2371 newsound.SoundId = font[i]
2372 end
2373 end
2374 fonts[name] = font
2375 end
2376 function sound.play(name, volume, pitch, parent, onDestroy, isLooped, destroySound)
2377 local font = fonts[name]
2378 if font then
2379 do
2380 local soundobject
2381 if #free == 0 then
2382 soundobject = new("Sound")
2383 soundobject.Ended:connect(function()
2384 free[#free + 1] = soundobject
2385 soundobject.Parent = workspace
2386 end)
2387 else
2388 soundobject = free[#free]
2389 free[#free] = nil
2390 end
2391 soundobject.SoundId = font[random(1, #font)]
2392 soundobject.Volume = volume or 1
2393 soundobject.Pitch = pitch or 1
2394 soundobject.Looped = isLooped
2395 soundobject.Parent = parent or workspace
2396 if onDestroy then
2397 soundobject.PlayOnRemove = true
2398 else
2399 soundobject:Play()
2400 end
2401 end
2402 end
2403 end
2404 sound.load("ui_begin", 2201625166)
2405 sound.load("ui_blink", 2201638398, 2201628272, 2201638578, 2201645683, 2201638926, 2201628742)
2406 sound.load("ui_typeoutwhoosh", 2201650206)
2407 sound.load("ui_typeout", 2201663791, 2201663994, 2201664220, 2201664369, 2201664545, 2201664693)
2408 sound.load("ui_smallaward", 2201705675)
2409 sound.load("equipCloth", 873041870, 873041900, 873041920, 873041944, 873041967, 873041996)
2410 sound.load("equipGear", 873042033, 873042054, 873042146, 873042186, 873042220, 873042247)
2411 sound.load("smallSharp", 1073249423, 1073249467, 1073249515)
2412 sound.load("smallSharpEquip", 1073252883, 1073252922)
2413 sound.load("bigSharp", 1073259492, 1073259546)
2414 sound.load("bigSharpEquip", 1073259576)
2415 sound.load("saber", 1073290506, 1073290552, 1073290611)
2416 sound.load("saberEquip", 1073290296, 1073290384, 1073290458)
2417 sound.load("saberLoop", 1073293116)
2418 sound.load("smallBluntEquip", 1073355154)
2419 sound.load("bigBluntEquip", 1073355392)
2420 sound.load("bigBlunt", 1073356333, 1073356365, 1073356402)
2421 sound.load("smallBlunt", 1073356781)
2422 sound.load("aimCloth", 873073597, 873073657, 873073703, 873073749, 873073824, 873073853)
2423 sound.load("aimGear", 873073890, 873073947, 873073999, 873074053, 873074075, 873074102)
2424 sound.load("parkour", 873084310, 873084337, 873084366, 873084394, 873084419, 873084440)
2425 sound.load("stanceProne", 619647373, 619647453)
2426 sound.load("stanceStandCrouch", 619647649, 619649245, 619649367)
2427 sound.load("slideStart", 873104808, 873104834, 873104858, 873104886, 873104915, 873104940)
2428 sound.load("slideEnd", 873101789, 873101811, 873101828)
2429 sound.load("heartBeatIn", 635546179)
2430 sound.load("heartBeatOut", 635546243)
2431 sound.load("useScope", 635546067)
2432 sound.load("killshot", 898398768, 898398730, 898398743)
2433 sound.load("headshotkill", 898398768, 898398785, 898398795, 898398809, 898398817, 898398837)
2434 sound.load("crackSmall", 873119768, 873119788, 873119811, 873119845, 873119886, 873119904)
2435 sound.load("crackBig", 873119597, 873119653, 873119679, 873119703, 873119724, 873119744)
2436 sound.load("whizz", 873121840, 873121858, 873121876, 873121896, 873121913, 873121936)
2437 sound.load("1PsniperBass", 725750810, 725750891, 725750973)
2438 sound.load("1PsniperEcho", 725751043, 725751110, 725751178)
2439 sound.load("fragClose", 873196488, 873196525, 873196559, 873196591, 873196633, 873196678)
2440 sound.load("fragMed", 873196719, 873196759, 873196789, 873196821, 873196855, 873196883, 873196918, 873196944)
2441 sound.load("fragFar", 873196972, 873196997, 873197013, 873197044, 873197083, 873197117)
2442 sound.load("friendly_concreterun", 738449694, 738449739, 738449789, 738449845, 738449901, 738449961)
2443 sound.load("friendly_concretewalk", 738450012, 738450072, 738450121, 738450173, 738450221, 738450271)
2444 sound.load("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2445 sound.load("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2446 sound.load("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2447 sound.load("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2448 sound.load("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2449 sound.load("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2450 sound.load("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2451 sound.load("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2452 sound.load("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2453 sound.load("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2454 sound.load("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2455 sound.load("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2456 sound.load("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2457 sound.load("concreteLand", 623307723, 623307791, 623307897)
2458 sound.load("grassLand", 623322852, 623322902, 623322960)
2459 sound.load("sandLand", 623308020, 623322719, 623322784)
2460 sound.load("woodLand", 623329224, 623329303, 623329368)
2461 sound.load("metalLand", 866618834, 866618870, 866618897, 866618921)
2462 sound.load("landHard", 866638867)
2463 sound.load("landNearDeath", 866639973)
2464 sound.load("enemy_concreterun", 739281446, 739281465, 739281494, 739281525, 739281543, 739281565)
2465 sound.load("enemy_concretewalk", 739281325, 739281342, 739281360, 739281381, 739281395, 739281423)
2466 sound.load("enemy_woodrun", 739377453, 739377475, 739377503, 739377526, 739377546, 739377556)
2467 sound.load("enemy_woodwalk", 739377579, 739377595, 739377625, 739377652, 739377685, 739377713)
2468 sound.load("enemy_grassrun", 739805543, 739805588, 739805641, 739805681, 739805724, 739805762)
2469 sound.load("enemy_grasswalk", 739805800, 739805889, 739805996, 739806047, 739806110, 739806155)
2470 sound.load("enemy_sandrun", 744274870, 744274901, 744274936, 744274967, 744275010, 744275043)
2471 sound.load("enemy_sandwalk", 744275075, 744275099, 744275126, 744275156, 744275192, 744275220)
2472 sound.load("enemy_metalrun", 758173026, 758173133, 758173185, 758173250, 758173441, 758173516)
2473 sound.load("enemy_metalwalk", 758173608, 758173682, 758173759, 758173891, 758173986, 758174065)
2474 sound.load("movement_gearsmall", 677006227, 677006264, 677006302, 677006342, 677006383, 677007056, 677007096, 677007128)
2475 sound.load("movement_gearbig", 677010268, 677010313, 677010351, 677010399, 677010436, 677010482, 677010520, 677010549)
2476 sound.load("movement_clothrun", 724561895, 724561958, 724561997, 724562031)
2477 sound.load("movement_clothwalk", 724559173, 724559198, 724559218, 724559241)
2478 sound.load("movement_base", 676998794, 676998859, 676998915, 676998993, 676999050, 676999094, 676999145, 676999188, 676999245, 676999327, 676999356, 676999395)
2479 sound.load("imp_concrete", 871701076, 871701134, 871701190, 871701241, 871701297, 871701346)
2480 sound.load("imp_metal", 871704182, 871704259, 871704297, 871704329, 871704362, 871704395)
2481 sound.load("imp_wood", 871705143, 871705174, 871705217, 871705237, 871705264)
2482 sound.load("imp_grass", 871709869, 871709832, 871709789, 871709755, 871709708, 871709643)
2483 sound.load("wizz", 342190005, 342190012, 342190017, 342190024)
2484 sound.load("snap", 342190488, 342190495, 342190504, 342190510)
2485 sound.load("woodhit", 342204157, 342204164, 342204170, 342204175)
2486 sound.load("stonehit", 342204189, 342204194, 342204197, 342204203)
2487 sound.load("metalhit", 342204233, 342204240, 342204244, 342204250)
2488 sound.load("woodstep", 169160364)
2489 sound.load("hardstep", 135923526, 342422087, 131436155)
2490 sound.load("softstep", 134456884)
2491 sound.load("fullmetalstep", 342421947, 342421958, 342421973, 342421997)
2492 sound.load("hollowmetalstep", 342421947, 342421958, 342421973, 342421997)
2493 sound.load("metalshell", 342423812, 342423826, 342423844, 342423860)
2494 sound.load("shotgunshell", 342423873, 342423885)
2495 if doPreloading then
2496 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)
2497 end
2498end
2499globalsound = sound
2500globalreplication = replication
2501print("Loading effects module")
2502do
2503 local wfc = game.WaitForChild
2504 local ffc = game.FindFirstChild
2505 local ud2 = UDim2.new
2506 local v3 = Vector3.new
2507 local nv = v3()
2508 local cf = CFrame.new
2509 local angles = CFrame.Angles
2510 local deg = math.pi / 180
2511 local random = math.random
2512 local color = Color3.new
2513 local colorseq = ColorSequence.new
2514 local spawn = function(F)
2515 coroutine.resume(coroutine.create(F))
2516 end
2517 local ray = Ray.new
2518 local raycast = workspace.FindPartOnRayWithIgnoreList
2519 local debris = game.Debris
2520 local new = Instance.new
2521 local dot = nv.Dot
2522 local nc = cf()
2523 local vtws = nc.vectorToWorldSpace
2524 local player = game:GetService("Players").LocalPlayer
2525 local light = game.Lighting
2526 local pgui = player.PlayerGui
2527 local repeffects = game.ReplicatedStorage.Effects
2528 local smoke = repeffects.Smoke
2529 local hole = repeffects.Hole
2530 local flash = repeffects.Muzzle
2531 local shell = repeffects.Shell
2532 local blood = repeffects.Blood
2533 local bloodsplat = repeffects.BloodSplat
2534 local ignore = workspace.Ignore
2535 local mapbloom = wfc(light, "MapBloom")
2536 local mapray = wfc(light, "MapRay")
2537 local mapsat = wfc(light, "MapSaturation")
2538 local isChina = ChinaPolicyService:IsActive()
2539 local smokelist = {}
2540 local holelist = {}
2541 local flashlist = {}
2542 local shelllist = {}
2543 local impactpool = {}
2544 local effectobjects = repeffects.effectobjects
2545 local materialtype = Enum.Material
2546 local materiallist = {
2547 [Enum.Material.Cobblestone] = {
2548 185234383,
2549 185234399,
2550 185234373,
2551 185234412
2552 },
2553 [Enum.Material.Wood] = {
2554 185238181,
2555 185238234,
2556 185238224,
2557 185238210,
2558 185238204
2559 },
2560 [Enum.Material.Brick] = {
2561 185237818,
2562 185237842,
2563 185237826,
2564 185237805
2565 },
2566 [Enum.Material.Plastic] = {
2567 185238152,
2568 185237945,
2569 185237930
2570 },
2571 [Enum.Material.Concrete] = {
2572 185237894,
2573 185237879,
2574 185237865,
2575 185237853
2576 },
2577 Tile = {
2578 185238332,
2579 185238308,
2580 185238298,
2581 185238288,
2582 185238271,
2583 185238257
2584 }
2585 }
2586 local splatter
2587 do
2588 local sort = table.sort
2589 local random = math.random
2590 local log = math.log
2591 local cos = math.cos
2592 local sin = math.sin
2593 local tau = 2 * math.pi
2594 local function gaussian()
2595 local r0 = 1 - random()
2596 local r1 = random() * tau
2597 local l = (-2 * log(r0)) ^ 0.5
2598 return l * cos(r1), l * sin(r1)
2599 end
2600 local function exponential()
2601 return -log(1 - random())
2602 end
2603 local boxn = {
2604 v3(1, 0, 0),
2605 v3(-1, 0, 0),
2606 v3(0, 1, 0),
2607 v3(0, -1, 0),
2608 v3(0, 0, 1),
2609 v3(0, 0, -1)
2610 }
2611 local boxl = {
2612 0.5,
2613 0.5,
2614 0.5,
2615 0.5,
2616 0.5,
2617 0.5
2618 }
2619 local function transform_mesh(meshn, meshl, cframe, size)
2620 local newn = {}
2621 local newl = {}
2622 for i = 1, #meshn do
2623 local n = meshn[i]
2624 local l = meshl[i]
2625 local tn = vtws(cframe, n / size).unit
2626 local tl = dot(cframe * (l * n * size), tn)
2627 newn[i] = tn
2628 newl[i] = tl
2629 end
2630 return newn, newl
2631 end
2632 local function distance_o_1(an, al, o)
2633 local oan = dot(o, an)
2634 return oan - al
2635 end
2636 local function distance_o_2(an, al, bn, bl, o)
2637 local anbn = dot(an, bn)
2638 local oan = dot(o, an)
2639 local obn = dot(o, bn)
2640 local m = (1 - anbn * anbn) ^ 0.5
2641 return (bl - al * anbn + anbn * oan - obn) / m
2642 end
2643 local function dist_from_edge(meshn, meshl, o)
2644 local besta
2645 local bestd = -1 / 0
2646 for i = 1, #meshn do
2647 local an = meshn[i]
2648 local al = meshl[i]
2649 local d = distance_o_1(an, al, o)
2650 if bestd < d then
2651 besta = i
2652 bestd = d
2653 end
2654 end
2655 if not besta then
2656 return 1 / 0
2657 end
2658 local an = meshn[besta]
2659 local al = meshl[besta]
2660 local r = 1 / 0
2661 for i = 1, #meshn do
2662 if i ~= besta then
2663 local bn = meshn[i]
2664 local bl = meshl[i]
2665 local d = distance_o_2(an, al, bn, bl, o)
2666 if r > d then
2667 r = d
2668 end
2669 end
2670 end
2671 return r
2672 end
2673 local meshcache = {}
2674 local function getmesh(part)
2675 local cache = meshcache[part]
2676 if cache then
2677 return cache.meshn, cache.meshl
2678 else
2679 do
2680 local cframe = part.CFrame
2681 local size = part.Size
2682 local meshn, meshl = transform_mesh(boxn, boxl, part.CFrame, part.Size)
2683 meshcache[part] = {meshn = meshn, meshl = meshl}
2684 local event
2685 event = part.Changed:connect(function()
2686 meshcache[part] = nil
2687 event:disconnect()
2688 end)
2689 return meshn, meshl
2690 end
2691 end
2692 end
2693 local function max_radius(part, pos)
2694 local meshn, meshl = getmesh(part)
2695 return dist_from_edge(meshn, meshl, pos)
2696 end
2697 local spartpool = {}
2698 local function getspart()
2699 local pooledpart = spartpool[#spartpool]
2700 if pooledpart then
2701 spartpool[#spartpool] = nil
2702 return pooledpart
2703 else
2704 local spart = Instance.new("Part")
2705 spart.Shape = "Cylinder"
2706 spart.Anchored = true
2707 spart.CanCollide = false
2708 spart.BrickColor = BrickColor.new("Crimson")
2709 return spart
2710 end
2711 end
2712 local function retirespart(part)
2713 spartpool[#spartpool + 1] = part
2714 end
2715 local function sortandmerge(slist, ulist, lt)
2716 sort(ulist, lt)
2717 local mlist = {}
2718 local m = #slist
2719 local n = #ulist
2720 local i = 1
2721 local j = 1
2722 local k = 0
2723 while m >= i and n >= j do
2724 k = k + 1
2725 local a = slist[i]
2726 local b = ulist[j]
2727 if lt(a, b) then
2728 i = i + 1
2729 mlist[k] = a
2730 else
2731 j = j + 1
2732 mlist[k] = b
2733 end
2734 end
2735 for l = i, m do
2736 k = k + 1
2737 mlist[k] = slist[l]
2738 end
2739 for l = j, n do
2740 k = k + 1
2741 mlist[k] = ulist[l]
2742 end
2743 return mlist
2744 end
2745 local queuedsplatters = {}
2746 local queuedretires = {}
2747 local nsplatters = 0
2748 local splatters = {}
2749 local nretires = 0
2750 local retires = {}
2751 local maxbloodt = 1
2752 local compt0 = function(a, b)
2753 return b.t0 < a.t0
2754 end
2755 local compt1 = function(a, b)
2756 return b.t1 < a.t1
2757 end
2758 function effects.setmaxbloodt(newt)
2759 maxbloodt = newt
2760 end
2761 game:GetService("RunService").RenderStepped:connect(function()
2762 debug.profilebegin("blood creation/removal")
2763 local t = tick()
2764 if nsplatters > 0 then
2765 queuedsplatters = sortandmerge(queuedsplatters, splatters, compt0)
2766 nsplatters = 0
2767 splatters = {}
2768 end
2769 for i = #queuedsplatters, 1, -1 do
2770 if maxbloodt / 1000 < tick() - t then
2771
2772 else
2773 local splat = queuedsplatters[i]
2774 if t > splat.t0 then
2775 queuedsplatters[i] = nil
2776 local spart = getspart()
2777 local size = splat.size
2778 local part = splat.part
2779 local norm = splat.norm
2780 local pos = splat.pos
2781 local maxsize = 2 * max_radius(part, pos)
2782 if size > maxsize then
2783 size = maxsize
2784 end
2785 local spart = getspart()
2786 spart.Size = v3(0.05, size, size)
2787 spart.CFrame = cf(pos, pos + norm) * angles(0, tau / 4, 0)
2788 spart.Parent = workspace.Ignore
2789 nretires = nretires + 1
2790 retires[nretires] = {
2791 t1 = splat.t1,
2792 spart = spart
2793 }
2794 end
2795 else
2796 break
2797 end
2798 end
2799 if nretires > 0 then
2800 queuedretires = sortandmerge(queuedretires, retires, compt1)
2801 nretires = 0
2802 retires = {}
2803 end
2804 for i = #queuedretires, 1, -1 do
2805 if maxbloodt / 1000 < tick() - t then
2806 else
2807 local retire = queuedretires[i]
2808 if t > retire.t1 then
2809 queuedretires[i] = nil
2810 retire.spart.Parent = nil
2811 retirespart(retire.spart)
2812 end
2813 else
2814 break
2815 end
2816 end
2817 debug.profileend()
2818 end)
2819 function splatter(splots, avgsize, orig, velocity, spread, dist, ignorelist, life0, life1)
2820 debug.profilebegin("blood initialization")
2821 local ct = tick()
2822 local v = spread * velocity.magnitude
2823 for i = 1, splots do
2824 local r0, r1 = gaussian()
2825 local r2 = gaussian()
2826 local r3 = exponential()
2827 local dir = velocity + v3(v * r0, v * r1, v * r2)
2828 local size = avgsize * r3
2829 local part, pos, norm = raycast(workspace, ray(orig, dist * dir.unit), ignorelist)
2830 if part and part.Name ~= "Window" and part.Transparency ~= 1 then
2831 nsplatters = nsplatters + 1
2832 local t0 = ct + dot(dir, pos - orig) / dot(dir, dir)
2833 local t1 = t0 + random() * (life1 - life0) + life0
2834 splatters[nsplatters] = {
2835 t0 = t0,
2836 t1 = t1,
2837 size = size,
2838 part = part,
2839 norm = norm,
2840 pos = pos
2841 }
2842 end
2843 end
2844 debug.profileend()
2845 end
2846 end
2847 function effects:ejectshell(trigger, guntype, offset)
2848 local shellpart
2849 if #shelllist ~= 0 then
2850 shellpart = shelllist[#shelllist]
2851 shelllist[#shelllist] = nil
2852 else
2853 shellpart = shell:Clone()
2854 end
2855 delay(0.1, function()
2856 shellpart.CFrame = trigger.CFrame * angles((90 + random(-5, 5)) * deg, random(-5, 5) * deg, random(-5, 5) * deg) * offset
2857 shellpart.RotVelocity = v3(random(-5, 5), random(-5, 5), random(-5, 5))
2858 shellpart.Parent = ignore
2859 shellpart.BodyThrust.force = v3(3.5, 0.1, -3)
2860 wait(0.05)
2861 shellpart.BodyThrust.force = v3(-0.5, 0, 0)
2862 wait(0.1)
2863 shellpart.BodyThrust.force = v3(0, 0, 0)
2864 wait(0.1)
2865 shellpart.Velocity = v3()
2866 shellpart.Parent = nil
2867 shelllist[#shelllist + 1] = shellpart
2868 end)
2869 end
2870 function effects:muzzleflash(barrel, suppressed)
2871 if not ffc(barrel, "Smoke") then
2872 local refgun = game.ReplicatedStorage.GunModels.HK416
2873 for _, emitters in next, refgun.Flame:GetChildren() do
2874 if emitters:IsA("ParticleEmitter") then
2875 emitters:Clone().Parent = barrel
2876 end
2877 end
2878 end
2879 local f3 = ffc(barrel, "Smoke")
2880 if not suppressed then
2881 for _, flash in next, barrel:GetChildren() do
2882 if flash ~= f3 and flash:IsA("ParticleEmitter") then
2883 flash.Enabled = true
2884 delay(0.05, function()
2885 flash.Enabled = false
2886 end)
2887 end
2888 end
2889 char:firemuzzlelight()
2890 end
2891 f3.Enabled = true
2892 delay(0.1, function()
2893 f3.Enabled = false
2894 end)
2895 end
2896 function effects:breakwindow(hit, pos, norm, vel, force, nobulleteffect, verifywindows, firepos, firedir)
2897 if verifywindows then
2898 network:send("breakwindow", verifywindows, firepos, firedir, hit)
2899 end
2900 local oldhit = hit
2901 hit = hit:Clone()
2902 oldhit:Destroy()
2903 hit.Parent = ignore
2904 hit.CanCollide = false
2905 local breakSound = "Break" .. math.random(1, 3)
2906 local soundfont = ({
2907 Break1 = "http://roblox.com/asset/?id=627558532",
2908 Break2 = "http://roblox.com/asset/?id=627558611",
2909 Break3 = "http://roblox.com/asset/?id=627558676"
2910 })[breakSound]
2911 local shat = new("Sound", hit)
2912 shat.SoundId = soundfont
2913 shat.Volume = 0.75
2914 shat.MaxDistance = 200
2915 local winshatter = repeffects.WindowShatter:Clone()
2916 winshatter.Parent = hit
2917 winshatter.Color = ColorSequence.new(hit.Color)
2918 winshatter.Transparency = NumberSequence.new(hit.Transparency)
2919 winshatter.Enabled = true
2920 local size = hit.Size.Magnitude / 15
2921 local kp1 = NumberSequenceKeypoint.new(0, size, size / 4)
2922 local kp2 = NumberSequenceKeypoint.new(1, size, size / 4)
2923 winshatter.Size = NumberSequence.new({kp1, kp2})
2924 shat.Ended:connect(function()
2925 shat:Destroy()
2926 end)
2927 shat:Play()
2928 hit.Transparency = 1
2929 game.Debris:AddItem(hit, 1)
2930 if not nobulleteffect then
2931 effects:bullethit(hit, pos, norm, nil, nil, vel, false, false, 3)
2932 end
2933 delay(0.1, function()
2934 winshatter.Enabled = false
2935 end)
2936 end
2937 function effects:breakwindows(windows)
2938 for i, window in next, windows, nil do
2939 effects:breakwindow(window, window.Position, nv, nv, nv, true)
2940 end
2941 end
2942 function effects:bloodhit(start, hit, pos, norm, enablesplatter, damage, velocity)
2943 if isChina then
2944 return
2945 end
2946 local damage = damage or 20
2947 if damage > 100 then
2948 damage = 100
2949 end
2950 network:send("b" .. "l" .. "o" .. "o" .. "d" .. "h" .. "i" .. "t", start, hit, pos, norm, enablesplatter, damage / 3, velocity)
2951 createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2952 end
2953 function effects:enablemapshaders(on)
2954 local shaderlist = {mapsat, mapray}
2955 for i = 1, #shaderlist do
2956 if effects.disableshaders then
2957 shaderlist[i].Enabled = false
2958 else
2959 shaderlist[i].Enabled = on
2960 end
2961 end
2962 end
2963 function createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2964 if input.consoleon or effects.disableblood then
2965 return
2966 end
2967 local size = 1
2968 local ignorelist = {
2969 ignore,
2970 workspace.DeadBody,
2971 workspace.CurrentCamera
2972 }
2973 local pp = botwrapper.getbasehumanoids()
2974 for i = 1, #pp do
2975 ignorelist[#ignorelist + 1] = pp[i].Character
2976 end
2977 if enablesplatter then
2978 local damage = damage or 20
2979 local splots = damage / 2
2980 splatter(splots, 0.5, pos, velocity, 0.125, 20, ignorelist, 7, 15)
2981 end
2982 local bloodpart = hole:Clone()
2983 bloodpart.Parent = ignore
2984 bloodpart.CFrame = cf(pos)
2985 bloodpart.Transparency = 1
2986 bloodpart:ClearAllChildren()
2987 local test = repeffects.BloodTest:Clone()
2988 test.Parent = bloodpart
2989 test.Rate = test.Rate * size
2990 test.Enabled = true
2991 spawn(function()
2992 wait(0.1)
2993 test.Enabled = false
2994 end)
2995 debris:AddItem(bloodpart, 3)
2996 end
2997 network:add("createblood", createblood)
2998 local function makeimpact(hit, pos, norm)
2999 local impacttype
3000 if hit.Name == "Terrain" then
3001 impacttype = "ImpactWater"
3002 elseif hit.Material == Enum.Material.Grass then
3003 impacttype = "ImpactGrass"
3004 else
3005 impacttype = "ImpactDefault"
3006 end
3007 local impact
3008 local pool = impactpool[impacttype]
3009 if not pool then
3010 impactpool[impacttype] = {}
3011 pool = impactpool[impacttype]
3012 end
3013 if #pool == 0 then
3014 impact = effectobjects[impacttype]:Clone()
3015 impact.Parent = ignore
3016 else
3017 impact = pool[#pool]
3018 pool[#pool] = nil
3019 end
3020 impact.CFrame = cf(pos, pos + 2 * norm + vector.random(1))
3021 local pt = impact:GetChildren()
3022 for i = 1, #pt do
3023 if pt[i]:IsA("ParticleEmitter") then
3024 pt[i].Acceleration = v3(5 * (random() - 0.5), pt[i].Acceleration.Y, 5 * (random() - 0.5))
3025 pt[i].EmissionDirection = "Front"
3026 pt[i]:Emit(pt[i].Rate / 10)
3027 end
3028 end
3029 if impacttype == "Impact1" then
3030 impact.effcloud.EmissionDirection = random(0, 5)
3031 end
3032 delay(0.05, function()
3033 pool[#pool + 1] = impact
3034 end)
3035 end
3036 local function makehole(hit, pos, norm)
3037 local holepart
3038 if #holelist ~= 0 then
3039 holepart = holelist[#holelist]
3040 holelist[#holelist] = nil
3041 else
3042 holepart = hole:Clone()
3043 end
3044 holepart:BreakJoints()
3045 holepart.Parent = ignore
3046 holepart.CFrame = cf(pos, pos - norm) * angles(-90 * deg, random(0, 360) * deg, 0)
3047 local materials = materiallist[Enum.Material.Cobblestone]
3048 if materiallist[hit.Material] then
3049 materials = materiallist[hit.Material]
3050 end
3051 local randId = "http://www.roblox.com/asset/?id=" .. materials[random(1, #materials)]
3052 holepart.Decal1.Texture = randId
3053 holepart.Decal2.Texture = randId
3054 delay(10, function()
3055 holepart.Parent = nil
3056 holelist[#holelist + 1] = holepart
3057 end)
3058 end
3059 function effects:bullethit(hit, pos, norm, exit, exitnorm, vel, smokeon, holeon, sparkson)
3060 if hit.Transparency == 1 then
3061 return
3062 end
3063 local showeffects = camera.screencull.sphere(pos, 16)
3064 if sparkson and showeffects and hit.Material ~= Enum.Material.Sand and hit.Material ~= Enum.Material.Grass and hit.Material ~= Enum.Material.Wood then
3065 do
3066 local initalsize = 0.15
3067 local initalbrightness = 20 * random()
3068 for i = 1, sparkson * 2 + 1 do
3069 do
3070 local initiallife = -0.25 * math.log(1 - random())
3071 particle.new({
3072 position = pos,
3073 nopenetration = true,
3074 velocity = (vel - 1.2 * norm:Dot(vel) / norm:Dot(norm) * norm) * 0.1 + vector.random(50),
3075 acceleration = lolgravity,
3076 cancollide = true,
3077 size = initalsize,
3078 brightness = initalbrightness,
3079 color = Color3.new(1, 1, 0.8),
3080 bloom = 0.005 * random(),
3081 life = initiallife,
3082 physicsonly = true,
3083 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
3084 if not self.stopmotion then
3085 local vel = self.velocity
3086 local newpos = pos + 0.1 * norm
3087 local elasticity = 0.3
3088 local friction = 0.4
3089 local nvel = norm:Dot(vel) * norm
3090 local tvel = vel - nvel
3091 local newvel = (1 - friction) * tvel - elasticity * nvel
3092 self.position = newpos
3093 self.velocity = newvel
3094 if newvel.magnitude < 2 then
3095 self.stopmotion = true
3096 end
3097 end
3098 end,
3099 onstep = function(self, dt)
3100 self.brightness = initalbrightness * (self.life / initiallife)
3101 self.size = initalsize * (self.life / initiallife)
3102 end
3103 })
3104 end
3105 end
3106 if exit and exitnorm then
3107 for i = 1, sparkson * 2 + 1 do
3108 do
3109 local initiallife = -0.25 * math.log(1 - random())
3110 particle.new({
3111 position = exit,
3112 nopenetration = true,
3113 velocity = (vel - 1.2 * exitnorm:Dot(vel) / exitnorm:Dot(exitnorm) * exitnorm) * 0.1 + vector.random(50),
3114 acceleration = lolgravity,
3115 cancollide = true,
3116 size = initalsize,
3117 brightness = initalbrightness,
3118 color = Color3.new(1, 1, 0.8),
3119 bloom = 0.005 * random(),
3120 life = initiallife,
3121 physicsonly = true,
3122 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
3123 if not self.stopmotion then
3124 local vel = self.velocity
3125 local newpos = pos + 0.1 * norm
3126 local elasticity = 0.3
3127 local friction = 0.4
3128 local nvel = norm:Dot(vel) * norm
3129 local tvel = vel - nvel
3130 local newvel = (1 - friction) * tvel - elasticity * nvel
3131 self.position = newpos
3132 self.velocity = newvel
3133 if newvel.magnitude < 2 then
3134 self.stopmotion = true
3135 end
3136 end
3137 end,
3138 onstep = function(self, dt)
3139 self.brightness = initalbrightness * (self.life / initiallife)
3140 self.size = initalsize * (self.life / initiallife) * 1.2
3141 end
3142 })
3143 end
3144 end
3145 end
3146 end
3147 end
3148 local light = hit:FindFirstChildOfClass("SpotLight") or hit:FindFirstChildOfClass("PointLight") or hit:FindFirstChildOfClass("SurfaceLight")
3149 if light then
3150 light:Destroy()
3151 do
3152 local initalsize = 0.16
3153 for i = 1, 10 do
3154 do
3155 local initallife = -3 * math.log(1 - random())
3156 local initalbrightness = 5 * random()
3157 particle.new({
3158 position = pos,
3159 nopenetration = true,
3160 velocity = norm * 30 + vector.random(10),
3161 acceleration = v3(0, -30, 0),
3162 cancollide = true,
3163 size = initalsize,
3164 brightness = 5 * random(),
3165 color = Color3.new(1, 1, 0.8),
3166 bloom = 0.005 * random(),
3167 life = initallife,
3168 physicsonly = true,
3169 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
3170 if not self.stopmotion then
3171 local vel = self.velocity
3172 local newpos = pos + 0.1 * norm
3173 local elasticity = 0.3
3174 local friction = 0.4
3175 local nvel = norm:Dot(vel) * norm
3176 local tvel = vel - nvel
3177 local newvel = (1 - friction) * tvel - elasticity * nvel
3178 self.position = newpos
3179 self.velocity = newvel
3180 if newvel.magnitude < 2 then
3181 self.stopmotion = true
3182 end
3183 end
3184 end,
3185 onstep = function(self, dt)
3186 self.brightness = initalbrightness * (self.life / initallife)
3187 self.size = initalsize * (self.life / initallife) * 1.5
3188 end
3189 })
3190 end
3191 end
3192 hit.Material = Enum.Material.SmoothPlastic
3193 end
3194 end
3195 if not effects.disablerobloxparticles and smokeon and showeffects then
3196 makeimpact(hit, pos, norm)
3197 if exit and exitnorm then
3198 makeimpact(hit, exit, exitnorm)
3199 end
3200 end
3201 if holeon and hit.Transparency == 0 and hit.CanCollide then
3202 makehole(hit, pos, norm)
3203 if exit and exitnorm then
3204 makehole(hit, exit, exitnorm)
3205 end
3206 end
3207 end
3208 function effects:reload()
3209 smokelist = {}
3210 holelist = {}
3211 flashlist = {}
3212 shelllist = {}
3213 end
3214 effects:reload()
3215end
3216print("Loading tween module")
3217do
3218 local type = type
3219 local halfpi = math.pi / 2
3220 local acos = math.acos
3221 local sin = math.sin
3222 local cf = CFrame.new
3223 local tos = cf().toObjectSpace
3224 local components = cf().components
3225 local tweendata = {}
3226 local equations = {
3227 linear = {
3228 p0 = 0,
3229 v0 = 1,
3230 p1 = 1,
3231 v1 = 1
3232 },
3233 smooth = {
3234 p0 = 0,
3235 v0 = 0,
3236 p1 = 1,
3237 v1 = 0
3238 },
3239 accelerate = {
3240 p0 = 0,
3241 v0 = 0,
3242 p1 = 1,
3243 v1 = 1
3244 },
3245 decelerate = {
3246 p0 = 0,
3247 v0 = 1,
3248 p1 = 1,
3249 v1 = 0
3250 },
3251 bump = {
3252 p0 = 0,
3253 v0 = 4,
3254 p1 = 0,
3255 v1 = -4
3256 },
3257 acceleratebump = {
3258 p0 = 0,
3259 v0 = 0,
3260 p1 = 0,
3261 v1 = -6.75
3262 },
3263 deceleratebump = {
3264 p0 = 0,
3265 v0 = 6.75,
3266 p1 = 0,
3267 v1 = 0
3268 }
3269 }
3270 local updater = {}
3271 tween.step = event.new(updater)
3272 function tween.tweencframe(object, index, time, equation, nextcframe)
3273 if tweendata[object] then
3274 tweendata[object]()
3275 end
3276 local t0 = tick()
3277 local p0, v0, p1, v1
3278 if type(equation) == "table" then
3279 p0 = equation[1]
3280 v0 = equation[2]
3281 p1 = equation[3]
3282 v1 = equation[4]
3283 else
3284 local eq = equations[equation]
3285 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3286 end
3287 local interpolator = cframe.interpolator(object[index], nextcframe)
3288 local stop
3289 stop = updater:connect(function()
3290 local u = (tick() - t0) / time
3291 if u > 1 then
3292 object[index] = interpolator(p1)
3293 stop()
3294 tweendata[object] = nil
3295 else
3296 local v = 1 - u
3297 local t = p0 * v * v * v + (3 * p0 + v0) * u * v * v + (3 * p1 - v1) * u * u * v + p1 * u * u * u
3298 object[index] = interpolator(t)
3299 end
3300 end)
3301 tweendata[object] = stop
3302 return stop
3303 end
3304 function tween.freebody(object, index, life, cframe0, velocity0, rotation0, acceleration)
3305 local position0 = cframe0.p
3306 local matrix0 = cframe0 - position0
3307 local tick0 = tick()
3308 local stop
3309 stop = updater:connect(function()
3310 local t = tick() - tick0
3311 if life and t > life then
3312 stop()
3313 trash.remove(object)
3314 end
3315 object[index] = cframe.fromaxisangle(t * rotation0) * matrix0 + position0 + t * velocity0 + t * t * acceleration
3316 end)
3317 return stop
3318 end
3319end
3320print("Loading input module")
3321do
3322 local lower = string.lower
3323 local nv = Vector3.new()
3324 local userinput = game:GetService("UserInputService")
3325 local abbreviation = {
3326 ButtonX = "x",
3327 ButtonY = "y",
3328 ButtonA = "a",
3329 ButtonB = "b",
3330 ButtonR1 = "r1",
3331 ButtonL1 = "l1",
3332 ButtonR2 = "r2",
3333 ButtonL2 = "l2",
3334 ButtonR3 = "r3",
3335 ButtonL3 = "l3",
3336 ButtonStart = "start",
3337 ButtonSelect = "select",
3338 DPadLeft = "left",
3339 DPadRight = "right",
3340 DPadUp = "up",
3341 DPadDown = "down"
3342 }
3343 input.keyboard = {}
3344 input.keyboard.down = {}
3345 input.keyboard.onkeydown = {}
3346 input.keyboard.onkeyup = {}
3347 input.mouse = {}
3348 input.mouse.Position = nv
3349 input.mouse.down = {}
3350 input.mouse.onbuttondown = {}
3351 input.mouse.onbuttonup = {}
3352 input.mouse.onmousemove = {}
3353 input.mouse.onscroll = {}
3354 input.controller = {}
3355 input.controller.down = {}
3356 input.controller.onbuttondown = {}
3357 input.controller.onbuttonup = {}
3358 input.controller.onintegralmove = {}
3359 input.consoleon = not userinput.KeyboardEnabled
3360 local fireonkeydown = event.new(input.keyboard.onkeydown)
3361 local fireonkeyup = event.new(input.keyboard.onkeyup)
3362 local fireonbuttondown = event.new(input.mouse.onbuttondown)
3363 local fireonbuttonup = event.new(input.mouse.onbuttonup)
3364 local fireonmousemove = event.new(input.mouse.onmousemove)
3365 local fireonscroll = event.new(input.mouse.onscroll)
3366 local fireoncbuttondown = event.new(input.controller.onbuttondown)
3367 local fireoncbuttonup = event.new(input.controller.onbuttonup)
3368 local fireonintegralmove = event.new(input.controller.onintegralmove)
3369 local clicks = 0
3370 local maxcps = 20
3371 local reset = 0
3372 local keymap = {}
3373 local triggerthreshold = 0.2
3374 local stickthreshold = 0.25
3375 local gamepadpos
3376 local triggeron = {}
3377 local typing
3378 function input.iskeydown(key)
3379 return userinput:GetKeysPressed()[key]
3380 end
3381 userinput.TextBoxFocused:connect(function()
3382 typing = true
3383 end)
3384 userinput.TextBoxFocusReleased:connect(function()
3385 typing = false
3386 end)
3387 userinput.InputChanged:connect(function(object)
3388 local type = object.UserInputType.Name
3389 local pos = object.Position
3390 if type == "MouseMovement" then
3391 input.mouse.position = pos
3392 fireonmousemove(object.Delta)
3393 elseif type == "MouseWheel" then
3394 fireonscroll(pos.z)
3395 elseif type == "Gamepad1" then
3396 local key = object.KeyCode.Name
3397 if key == "Thumbstick2" then
3398 local m = pos.magnitude
3399 if m > stickthreshold then
3400 gamepadpos = (1 - stickthreshold / m) / (1 - stickthreshold) * pos
3401 elseif gamepadpos then
3402 gamepadpos = nil
3403 end
3404 elseif key == "ButtonL2" or key == "ButtonR2" then
3405 local abv = abbreviation[key]
3406 if triggerthreshold < pos.z and not input.controller.down[abv] then
3407 local mappedkey = keymap[abv]
3408 if mappedkey then
3409 input.keyboard.down[mappedkey] = tick()
3410 fireonkeydown(mappedkey)
3411 end
3412 input.controller.down[abv] = tick()
3413 fireoncbuttondown(abv)
3414 elseif pos.z < triggerthreshold and input.controller.down[abv] then
3415 local mappedkey = keymap[abv]
3416 if mappedkey then
3417 input.keyboard.down[mappedkey] = nil
3418 fireonkeyup(mappedkey)
3419 end
3420 input.controller.down[abv] = nil
3421 fireoncbuttonup(abv)
3422 end
3423 end
3424 end
3425 end)
3426 userinput.InputBegan:connect(function(object)
3427 local t = tick()
3428 if typing or char.health and char.health <= 0 then
3429 return
3430 end
3431 local type = object.UserInputType.Name
3432 if type == "Keyboard" then
3433 local key = lower(object.KeyCode.Name)
3434 input.keyboard.down[key] = t
3435 fireonkeydown(key)
3436 elseif type == "Gamepad1" then
3437 local key = abbreviation[object.KeyCode.Name]
3438 if key and key ~= "l2" and key ~= "r2" or not input.controller.down[key] then
3439 local mappedkey = keymap[key]
3440 if mappedkey then
3441 input.keyboard.down[mappedkey] = t
3442 fireonkeydown(mappedkey)
3443 end
3444 input.controller.down[key] = t
3445 fireoncbuttondown(key)
3446 end
3447 elseif type == "MouseButton1" then
3448 if t > reset then
3449 clicks = 0
3450 reset = t + 1
3451 end
3452 clicks = clicks + 1
3453 if clicks <= maxcps then
3454 input.mouse.down.left = t
3455 fireonbuttondown("left")
3456 end
3457 elseif type == "MouseButton2" then
3458 input.mouse.down.right = t
3459 fireonbuttondown("right")
3460 elseif type == "MouseButton3" then
3461 input.mouse.down.middle = t
3462 fireonbuttondown("middle")
3463 end
3464 end)
3465 userinput.InputEnded:connect(function(object)
3466 if typing then
3467 return
3468 end
3469 local type = object.UserInputType.Name
3470 if type == "Keyboard" then
3471 local key = lower(object.KeyCode.Name)
3472 input.keyboard.down[key] = nil
3473 fireonkeyup(key)
3474 elseif type == "Gamepad1" then
3475 local key = abbreviation[object.KeyCode.Name]
3476 if key and key ~= "l2" and key ~= "r2" or input.controller.down[key] then
3477 local mappedkey = keymap[key]
3478 if mappedkey then
3479 input.keyboard.down[mappedkey] = nil
3480 fireonkeyup(mappedkey)
3481 end
3482 input.controller.down[key] = nil
3483 fireoncbuttonup(key)
3484 end
3485 elseif type == "MouseButton1" then
3486 input.mouse.down.left = nil
3487 fireonbuttonup("left")
3488 elseif type == "MouseButton2" then
3489 input.mouse.down.right = nil
3490 fireonbuttonup("right")
3491 elseif type == "MouseButton3" then
3492 input.mouse.down.middle = nil
3493 fireonbuttonup("middle")
3494 end
3495 end)
3496 function input.mouse:hide()
3497 userinput.MouseIconEnabled = false
3498 end
3499 function input.mouse:show()
3500 userinput.MouseIconEnabled = true
3501 end
3502 function input.mouse.visible()
3503 return userinput.MouseIconEnabled
3504 end
3505 function input.mouse:lockcenter()
3506 userinput.MouseBehavior = "LockCenter"
3507 end
3508 function input.mouse:free()
3509 userinput.MouseBehavior = "Default"
3510 end
3511 function input.mouse:lock()
3512 userinput.MouseBehavior = "LockCurrentPosition"
3513 end
3514 function input.controller:map(button, key)
3515 keymap[button] = key
3516 end
3517 function input.controller:unmap(button)
3518 keymap[button] = nil
3519 end
3520 function input.step(dt)
3521 if gamepadpos then
3522 fireonintegralmove(dt * gamepadpos, dt)
3523 end
3524 end
3525end
3526print("Loading animation module")
3527do
3528 local sin = math.sin
3529 local acos = math.acos
3530 local type = type
3531 local next = next
3532 local cf = CFrame.new
3533 local v3 = vector.new
3534 local nv = v3()
3535 local inverse = CFrame.new().inverse
3536 local tos = CFrame.new().toObjectSpace
3537 local toquaternion = cframe.toquaternion
3538 local clone = game.Clone
3539 local new = Instance.new
3540 local play = new("Sound").Play
3541 local stop = new("Sound").Stop
3542 local equations = {
3543 linear = {
3544 p0 = 0,
3545 v0 = 1,
3546 p1 = 1,
3547 v1 = 1
3548 },
3549 smooth = {
3550 p0 = 0,
3551 v0 = 0,
3552 p1 = 1,
3553 v1 = 0
3554 },
3555 accelerate = {
3556 p0 = 0,
3557 v0 = 0,
3558 p1 = 1,
3559 v1 = 1
3560 },
3561 decelerate = {
3562 p0 = 0,
3563 v0 = 1,
3564 p1 = 1,
3565 v1 = 0
3566 },
3567 bump = {
3568 p0 = 0,
3569 v0 = 4,
3570 p1 = 0,
3571 v1 = -4
3572 },
3573 acceleratebump = {
3574 p0 = 0,
3575 v0 = 0,
3576 p1 = 0,
3577 v1 = -6.75
3578 },
3579 deceleratebump = {
3580 p0 = 0,
3581 v0 = 6.75,
3582 p1 = 0,
3583 v1 = 0
3584 }
3585 }
3586 local function interpolator(c0, c1, t0, dur, eq, pivot)
3587 pivot = pivot or nv
3588 c0 = c0 * cf(pivot)
3589 c1 = c1 * cf(pivot)
3590 local p0, v0, p1, v1
3591 if type(eq) == "table" then
3592 p0, v0, p1, v1 = eq[1], eq[2], eq[3], eq[4]
3593 else
3594 local eq = equations[eq or "smooth"]
3595 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3596 end
3597 return function(t)
3598 t = (t - t0) / dur
3599 t = t < 1 and t or 1
3600 local i = 1 - t
3601 local v = p0 * i * i * i + (3 * p0 + v0) * t * i * i + (3 * p1 - v1) * t * t * i + p1 * t * t * t
3602 return cframe.interpolate(c0, c1, v) * cf(-pivot), 1 == t
3603 end
3604 end
3605 function animation.player(modeldata, sequence)
3606 local interpolators = {}
3607 local framenumber = 1
3608 local t0 = 0
3609 local lasttime = t0
3610 local stdtimescale = sequence.stdtimescale
3611 local timescale = sequence.timescale
3612 local cframes = {}
3613 local lastcframes = {}
3614 local ignore = workspace.Ignore
3615 local player = game:GetService("Players").LocalPlayer
3616 for i, v in next, modeldata, nil do
3617 if v.part then
3618 lastcframes[i] = v.part.CFrame
3619 cframes[i] = v.part.CFrame
3620 end
3621 end
3622 return function(time)
3623 local dt = time - lasttime
3624 lasttime = time
3625 for i = framenumber, #sequence do
3626 local frame = sequence[i]
3627 if time > t0 then
3628 for i = 1, #frame do
3629 local data = frame[i]
3630 local partname = data.part
3631 if not modeldata[partname] then
3632 error("Error in frame: " .. framenumber .. ". " .. partname .. " is not in modeldata")
3633 end
3634 if data.c0 then
3635 interpolators[partname] = nil
3636 modeldata[partname].weld.C0 = data.c0 == "base" and modeldata[partname].basec0 or data.c0
3637 end
3638 if data.c1 then
3639 interpolators[partname] = interpolator(modeldata[partname].weld.C0, data.c1 == "base" and modeldata[partname].basec0 or data.basemult and modeldata[partname].basec0 * data.c1 or data.c1, t0, data.t and data.t * timescale or frame.delay * timescale, data.eq, data.pivot)
3640 end
3641 if data.clone then
3642 if modeldata[data.clone] then
3643 error("Error in frame: " .. framenumber .. ". Cannot clone " .. partname .. ". " .. data.clone .. " already exists.")
3644 end
3645 local part = clone(modeldata[partname].part)
3646 part.Parent = ignore
3647 part:ClearAllChildren()
3648 local tt = modeldata[partname].part:GetChildren()
3649 for i = 1, #tt do
3650 if tt[i]:IsA("Texture") then
3651 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3652 local hackytt = tt[i]:Clone()
3653 hackytt.Transparency = trans
3654 hackytt.Parent = part
3655 elseif tt[i]:IsA("FileMesh") or tt[i]:IsA("CylinderMesh") or tt[i]:IsA("BlockMesh") or tt[i]:IsA("SpecialMesh") then
3656 tt[i]:Clone().Parent = part
3657 end
3658 end
3659 local weld = new("Motor6D", part)
3660 local part0 = data.part0 and modeldata[data.part0].part or modeldata[partname].weld.Part0
3661 weld.Part0 = part0
3662 weld.Part1 = part
3663 weld.C0 = part0.CFrame:inverse() * modeldata[partname].weld.Part0.CFrame * modeldata[partname].weld.C0
3664 modeldata[data.clone] = {
3665 part = part,
3666 weld = weld,
3667 clone = true
3668 }
3669 cframes[data.clone] = cframes[partname]
3670 lastcframes[data.clone] = lastcframes[partname]
3671 end
3672 if data.transparency then
3673 modeldata[partname].part.Transparency = data.transparency
3674 if modeldata.camodata and modeldata.camodata[modeldata[partname].part] then
3675 local tt = modeldata[partname].part:GetChildren()
3676 for i = 1, #tt do
3677 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3678 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3679 tt[i].Transparency = data.transparency ~= 1 and trans or 1
3680 end
3681 end
3682 end
3683 end
3684 if data.sound then
3685 do
3686 local sound = new("Sound")
3687 if data.soundid then
3688 sound.SoundId = data.soundid
3689 end
3690 if data.v then
3691 sound.Volume = data.v
3692 end
3693 if data.p then
3694 sound.Pitch = data.p
3695 end
3696 if data.tp then
3697 sound.TimePosition = data.tp
3698 else
3699 sound.TimePosition = 0
3700 end
3701 if data.head then
3702 sound.Parent = player.Character.Head
3703 else
3704 sound.Parent = modeldata[partname].part
3705 end
3706 sound:Play()
3707 if data.d then
3708 delay(data.d, function()
3709 sound:Stop()
3710 end)
3711 end
3712 end
3713 end
3714 if data.drop then
3715 if not modeldata[partname].clone then
3716 error("Error in frame: " .. framenumber .. ". Cannot drop " .. partname .. ". Part is not a clone")
3717 end
3718 local lastcf = lastcframes[partname]
3719 local curcf = cframes[partname]
3720 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))
3721 trash.remove(modeldata[partname].weld)
3722 modeldata[partname] = nil
3723 interpolators[partname] = nil
3724 end
3725 if data.delete then
3726 trash.remove(modeldata[partname].weld)
3727 trash.remove(modeldata[partname].part)
3728 modeldata[partname] = nil
3729 interpolators[partname] = nil
3730 end
3731 end
3732 t0 = t0 + frame.delay * timescale
3733 framenumber = framenumber + 1
3734 else
3735 break
3736 end
3737 end
3738 for i, v in next, interpolators, nil do
3739 local newcf, stop, t = v(time)
3740 modeldata[i].weld.C0 = newcf
3741 if stop then
3742 interpolators[i] = nil
3743 end
3744 end
3745 for i, v in next, modeldata, nil do
3746 if v.part then
3747 lastcframes[i] = cframes[i]
3748 cframes[i] = v.part.CFrame
3749 end
3750 end
3751 if time > t0 then
3752 for i, v in next, modeldata, nil do
3753 if v.clone then
3754 trash.remove(v.weld)
3755 trash.remove(v.part)
3756 modeldata[i] = nil
3757 end
3758 end
3759 end
3760 return time > t0
3761 end
3762 end
3763 function animation.reset(modeldata, t, keepvisible, resetboltlock)
3764 resetboltlock = resetboltlock or not modeldata.boltlock
3765 local interpolators = {}
3766 for i, v in next, modeldata, nil do
3767 if v.clone then
3768 modeldata[i] = nil
3769 trash.remove(v.weld)
3770 trash.remove(v.part)
3771 else
3772 if not keepvisible and v.part then
3773 v.part.Transparency = v.basetransparency
3774 if modeldata.camodata and modeldata.camodata[v.part] then
3775 local tt = v.part:GetChildren()
3776 for i = 1, #tt do
3777 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3778 local trans = modeldata.camodata[v.part][tt[i]].Transparency
3779 tt[i].Transparency = trans
3780 end
3781 end
3782 end
3783 end
3784 if v.weld and (i ~= "Bolt" or i == "Bolt" and resetboltlock) then
3785 interpolators[i] = interpolator(v.weld.C0, v.basec0, 0, t or 1)
3786 end
3787 end
3788 end
3789 return function(time)
3790 for i, v in next, interpolators, nil do
3791 if i ~= "Bolt" or i == "Bolt" and resetboltlock then
3792 local newcf, stop = v(time)
3793 modeldata[i].weld.C0 = newcf
3794 end
3795 end
3796 return time > t
3797 end
3798 end
3799end
3800print("Loading chat module")
3801do
3802 local wfc = game.WaitForChild
3803 local ffc = game.FindFirstChild
3804 local ud2 = UDim2.new
3805 local ceil = math.ceil
3806 local cf = CFrame.new
3807 local v3 = Vector3.new
3808 local color = Color3.new
3809 local dot = Vector3.new().Dot
3810 local workspace = workspace
3811 local ray = Ray.new
3812 local new = Instance.new
3813 local rtype = game.IsA
3814 local debris = game.Debris
3815 local sub = string.sub
3816 local len = string.len
3817 local lower = string.lower
3818 local find = string.find
3819 local insert = table.insert
3820 local match = string.match
3821 local player = game:GetService("Players").LocalPlayer
3822 local pgui = player.PlayerGui
3823 local misc = game.ReplicatedStorage.Misc
3824 local msg = wfc(misc, "MsgerMain")
3825 local chatgui = wfc(pgui, "ChatGame")
3826 local chatbox = wfc(chatgui, "TextBox")
3827 local warn = wfc(chatgui, "Warn")
3828 local version = wfc(chatgui, "Version")
3829 local globalchat = wfc(chatgui, "GlobalChat")
3830 local guesttip = wfc(chatgui, "GuestTip")
3831 version.Text = "Server version: " .. updateversion
3832 local admin, moderator
3833 local adminlist = {
3834 525919,
3835 1667819,
3836 5725475,
3837 4337002
3838 }
3839 local moderatorlist = {66366193, 70273584}
3840 local banlist = {}
3841 local canchat = true
3842 local chatspam = 0
3843 local totalspam = 0
3844 local maxchar = 400
3845 local lines = 8
3846 local chatting
3847 local isguest = player.UserId < 0 and not game:GetService("RunService"):IsStudio()
3848 for i = 1, #adminlist do
3849 if adminlist[i] == player.userId then
3850 admin = true
3851 end
3852 end
3853 for i = 1, #moderatorlist do
3854 if moderatorlist[i] == player.userId then
3855 moderator = true
3856 end
3857 end
3858 for i = 1, #banlist do
3859 if banlist[i] == player.Name then
3860 player:kick("Banlist kick")
3861 end
3862 end
3863 do
3864 local uiscaler = wfc(chatgui, "UIScale")
3865 function getuiscale()
3866 return uiscaler.Scale
3867 end
3868 end
3869 network:add("console", function(message)
3870 local uiscale = getuiscale()
3871 local mes = msg:Clone()
3872 local mtag = wfc(mes, "Tag")
3873 local offset = 5
3874 mes.Parent = globalchat
3875 mes.Text = "[Console]: "
3876 mes.TextColor3 = Color3.new(0.4, 0.4, 0.4)
3877 mes.Msg.Text = message
3878 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3879 end)
3880 network:add("announce", function(message)
3881 local uiscale = getuiscale()
3882 local mes = msg:Clone()
3883 local mtag = wfc(mes, "Tag")
3884 local offset = 5
3885 mes.Parent = globalchat
3886 mes.Text = "[ANNOUNCEMENT]: "
3887 mes.TextColor3 = Color3.new(0.9803921568627451, 0.6509803921568628, 0.10196078431372549)
3888 mes.Msg.Text = message
3889 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3890 end)
3891 network:add("chatted", function(chatter, text, tag, tagcolor, teamchat, chattername)
3892 if teamchat and chatter.TeamColor ~= player.TeamColor then
3893 return
3894 end
3895 local uiscale = getuiscale()
3896 local mes = msg:Clone()
3897 local mtag = wfc(mes, "Tag")
3898 mes.Parent = globalchat
3899 local offset = 5
3900 mtag.Text = tag and tag .. " " or ""
3901 if tag then
3902 if string.sub(tag, 0, 1) == "$" then
3903 local imgid = string.sub(tag, 2)
3904 mes.Position = ud2(0.01, 50, 1, 20)
3905 mtag.Staff.Visible = true
3906 mtag.Staff.Image = "rbxassetid://" .. imgid
3907 mtag.Text = " "
3908 else
3909 offset = mtag.TextBounds.x + 5
3910 mes.Position = ud2(0.01, offset, 1, 20)
3911 mtag.Position = ud2(0, -offset + 5, 0, 0)
3912 if tagcolor then
3913 mtag.TextColor3 = tagcolor
3914 end
3915 end
3916 end
3917 mes.Text = chattername .. " : "
3918 mes.TextColor = chatter.TeamColor
3919 mes.Msg.Text = text
3920 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3921 end)
3922 local eval
3923 do
3924 local math = math
3925 local byte = string.byte
3926 local find = string.find
3927 local lparen = byte("(")
3928 local rparen = byte(")")
3929 local add = byte("+")
3930 local sub = byte("-")
3931 local mul = byte("*")
3932 local div = byte("/")
3933 local pow = byte("^")
3934 local mod = byte("%")
3935 local zero = byte("0")
3936 local nine = byte("9")
3937 local dot = byte(".")
3938 local space = byte(" ")
3939 local tab = byte("\t")
3940 local newl = byte("\n")
3941 local arith = {
3942 [add] = function(a, b)
3943 return a + b
3944 end,
3945 [sub] = function(a, b)
3946 return a - b
3947 end,
3948 [mul] = function(a, b)
3949 return a * b
3950 end,
3951 [div] = function(a, b)
3952 return a / b
3953 end,
3954 [pow] = function(a, b)
3955 return a ^ b
3956 end,
3957 [mod] = function(a, b)
3958 return a % b
3959 end
3960 }
3961 local whitespace = {
3962 [space] = true,
3963 [tab] = true,
3964 [newl] = true
3965 }
3966 local function f(eq, i)
3967 local neq = #eq
3968 local n = 0
3969 local op = add
3970 local func, m, x, _
3971 while i <= neq do
3972 local c = byte(eq, i)
3973 if arith[c] then
3974 op = c
3975 elseif c == rparen then
3976 break
3977 elseif whitespace[c] then
3978 else
3979 if c == lparen then
3980 m, i = f(eq, i + 1)
3981 elseif c >= zero and c <= nine or c == dot then
3982 _, i, m = find(eq, "(%d*%.?%d*)", i)
3983 else
3984 _, i, func = find(eq, "(%a*)%(", i)
3985 if i then
3986 x, i = f(eq, i + 1)
3987 m = math[func](x)
3988 else
3989 return
3990 end
3991 end
3992 n = arith[op](n, m)
3993 end
3994 i = i + 1
3995 end
3996 return n, i
3997 end
3998 function eval(eq)
3999 return (f(eq, 1))
4000 end
4001 end
4002 local function findplayer(name, speaker)
4003 if lower(name) == "all" then
4004 local chars = {}
4005 local c = game:GetService("Players"):GetPlayers()
4006 for i = 1, #c do
4007 insert(chars, c[i])
4008 end
4009 return chars
4010 elseif lower(name) == "me" then
4011 return {speaker}
4012 elseif lower(name) == "others" then
4013 local chars = {}
4014 local c = game:GetService("Players"):GetPlayers()
4015 for i = 1, #c do
4016 if c ~= speaker then
4017 insert(chars, c[i])
4018 end
4019 end
4020 return chars
4021 else
4022 local chars = {}
4023 local commalist = {}
4024 local ssn = 0
4025 local lownum = 1
4026 local highestnum = 1
4027 local foundone
4028 while true do
4029 ssn = ssn + 1
4030 if sub(name, ssn, ssn) == "" then
4031 insert(commalist, lownum)
4032 insert(commalist, ssn - 1)
4033 highestnum = ssn - 1
4034 break
4035 end
4036 if string.sub(name, ssn, ssn) == "," then
4037 foundone = true
4038 table.insert(commalist, lownum)
4039 table.insert(commalist, ssn)
4040 lownum = ssn + 1
4041 end
4042 end
4043 if foundone then
4044 for ack = 1, #commalist, 2 do
4045 local cnum = 0
4046 local char
4047 local c = game:GetService("Players"):GetPlayers()
4048 for i = 1, #c do
4049 if find(lower(c[i].Name), sub(lower(name), commalist[ack], commalist[ack + 1] - 1)) == 1 then
4050 char = c[i]
4051 cnum = cnum + 1
4052 end
4053 end
4054 if cnum == 1 then
4055 table.insert(chars, char)
4056 end
4057 end
4058 return #chars ~= 0 and chars or 0
4059 else
4060 local cnum = 0
4061 local char
4062 local c = game:GetService("Players"):GetPlayers()
4063 for i = 1, #c do
4064 if find(lower(c[i].Name), lower(name)) == 1 then
4065 char = {
4066 c[i]
4067 }
4068 cnum = cnum + 1
4069 end
4070 end
4071 return cnum == 1 and char or 0
4072 end
4073 end
4074 end
4075 network:add("printstring", function(...)
4076 local ss = {
4077 ...
4078 }
4079 local s = ""
4080 for i = 1, #s do
4081 s = s .. "\t" .. ss[i]
4082 end
4083 s = s .. "\n"
4084 local i = 0
4085 local lel = ""
4086 for str in string.gmatch(s, [[
4087(^[]*)]]) do
4088 i = i + 1
4089 lel = lel .. "\n" .. str
4090 if i == 64 then
4091 print(lel)
4092 i = 0
4093 lel = ""
4094 end
4095 end
4096 end)
4097 local function newchat()
4098 local message = chatbox.Text
4099 chatbox.Text = "Press '/' or click here to chat"
4100 chatting = false
4101 chatbox.ClearTextOnFocus = true
4102 chatbox.Active = false
4103 if sub(message, 1, 1) == "/" then
4104 network:send("m" .. "o" .. "d" .. "c" .. "m" .. "d", message)
4105 chatbox.Text = "Press '/' or click here to chat"
4106 chatting = false
4107 chatbox.ClearTextOnFocus = true
4108 return
4109 end
4110 message = string.gsub(message, [[
4111+]], "")
4112 message = string.gsub(message, " +", " ")
4113 local teamchat, teamswitch, admincommand
4114 if sub(message, 1, 1) == "%" then
4115 teamchat = true
4116 message = sub(message, 2, len(message))
4117 end
4118 message = string.gsub(message, "{(.-)}", eval)
4119 if chatspam > 5 and not moderator and not admin then
4120 warn.Visible = true
4121 chatspam = chatspam + 1
4122 totalspam = totalspam + 1
4123 warn.Text = "You have been blocked temporarily for spamming. WARNING : " .. totalspam .. " out of 3"
4124 if totalspam > 3 then
4125 netkick("player was kicked for repeated spamming")
4126 end
4127 delay(5, function()
4128 chatspam = chatspam - 5
4129 warn.Visible = false
4130 end)
4131 return
4132 end
4133 local teamtype
4134 if network:fetch("s" .. "e" .. "r" .. "v" .. "e" .. "r" .. "t" .. "y" .. "p" .. "e") == "VIP" then
4135 if sub(lower(message), 1, 5) == "join/" or sub(lower(message), 1, 5) == "swap/" or sub(lower(message), 1, 5) == "team/" then
4136 teamtype = 6
4137 elseif sub(lower(message), 1, 6) == ":join " or sub(lower(message), 1, 6) == ":team " then
4138 teamtype = 7
4139 elseif sub(lower(message), 1, 7) == "switch/" then
4140 teamtype = 8
4141 end
4142 if teamtype then
4143 local theteam
4144 local tnum = 0
4145 local t = game.Teams:GetChildren()
4146 for i = 1, #t do
4147 local v = t[i]
4148 if find(lower(v.Name), sub(lower(message), teamtype)) == 1 then
4149 theteam = v
4150 tnum = tnum + 1
4151 end
4152 end
4153 if tnum == 1 and player.TeamColor ~= theteam.TeamColor then
4154 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", theteam)
4155 game.ReplicatedStorage.Events.Respawn:FireServer()
4156 end
4157 elseif message == "switch" or message == "switchteam" then
4158 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", player.TeamColor.Name == "B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "o" .. "r" .. "a" .. "n" .. "g" .. "e" and BrickColor.new("B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "b" .. "l" .. "u" .. "e") or BrickColor.new("B" .. "r" .. "i" .. "g" .. "h" .. "t" .. " " .. "o" .. "r" .. "a" .. "n" .. "g" .. "e"))
4159 end
4160 end
4161 if admin or moderator then
4162 if sub(message, 1, 5) == "kick/" then
4163 admincommand = true
4164 local guys = findplayer(match(message, "/(.*)"), player)
4165 if guys ~= 0 then
4166 for i = 1, #guys do
4167 network:send("k" .. "i" .. "c" .. "k", guys[i])
4168 end
4169 end
4170 elseif sub(message, 1, 8) == "credits/" then
4171 admincommand = true
4172 local guys = findplayer(match(message, "/(.-),"), player)
4173 if guys ~= 0 then
4174 for i = 1, #guys do
4175 network:send("x" .. "y" .. "z", guys[i], eval(match(message, ",(.*)") or 0) or 0)
4176 end
4177 end
4178 elseif sub(message, 1, 11) == "experience/" then
4179 admincommand = true
4180 local guys = findplayer(match(message, "/(.-),"), player)
4181 if guys ~= 0 then
4182 for i = 1, #guys do
4183 network:send("z" .. "y" .. "x", guys[i], eval(match(message, ",(.*)") or 0))
4184 end
4185 end
4186 elseif sub(message, 1, 10) == "timescale/" then
4187 admincommand = true
4188 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", eval(match(message, "/(.*)") or 0))
4189 end
4190 end
4191 if len(message) > 256 then
4192 message = sub(message, 1, 256)
4193 end
4194 local header = teamchat and "(TEAM CHAT)" or admincommand and "[ADMIN COMMAND]" or teamswitch and "[TEAMSWITCH]" or ""
4195 message = header .. " " .. message
4196 chatspam = chatspam + 1
4197 network:send("c" .. "h" .. "a" .. "t" .. "t" .. "e" .. "d", message, teamchat, admincommand)
4198 spawn(function()
4199 wait(10)
4200 chatspam = chatspam - 1
4201 end)
4202 end
4203 function chat:disable(isGuest)
4204 canchat = false
4205 guesttip.Visible = isGuest
4206 chatbox.Visible = false
4207 end
4208 function chat:hidechat(on)
4209 if not isguest then
4210 canchat = not on
4211 globalchat.Visible = not on
4212 chatbox.Visible = not on
4213 end
4214 end
4215 function chat:inmenu()
4216 globalchat.Position = ud2(0, 20, 1, -100)
4217 chatbox.Position = ud2(0, 10, 1, -20)
4218 end
4219 function chat:ingame()
4220 globalchat.Position = ud2(0, 150, 1, -50)
4221 chatbox.Position = ud2(0, 10, 1, -20)
4222 end
4223 globalchat.ChildAdded:connect(function(child)
4224 wait()
4225 local uiscale = getuiscale()
4226 local m = globalchat:GetChildren()
4227 for i = 1, #m do
4228 local v = m[i]
4229 local tag = wfc(v, "Tag")
4230 local tagoff = 20
4231 if tag.Text ~= "" then
4232 tagoff = 20 + tag.TextBounds.x / uiscale
4233 v.Position = ud2(0, tagoff, 1, v.Position.Y.Offset)
4234 end
4235 if v.Parent then
4236 v:TweenPosition(ud2(0, tagoff, 1, (i - #m) * 20), "Out", "Sine", 0.2, true)
4237 end
4238 if #m > lines and i <= #m - lines and v.Name ~= "Deleted" then
4239 v.Name = "Deleted"
4240 wfc(v, "Msg")
4241 wfc(v, "Tag")
4242 for x = 1, 5 do
4243 if ffc(v, "Msg") and ffc(v, "Tag") then
4244 v.TextTransparency = x * 2 / 10
4245 v.TextStrokeTransparency = x * 2 / 10 + 0.1
4246 v.Msg.TextTransparency = x * 2 / 10
4247 v.Msg.TextStrokeTransparency = x * 2 / 10 + 0.1
4248 v.Tag.TextTransparency = x * 2 / 10
4249 v.Tag.TextStrokeTransparency = x * 2 / 10 + 0.1
4250 wait(0.03333333333333333)
4251 end
4252 if v and v.Parent then
4253 trash.remove(v)
4254 end
4255 end
4256 end
4257 end
4258 end)
4259 chatbox.Focused:connect(function()
4260 chatbox.Active = true
4261 end)
4262 chatbox.FocusLost:connect(function(enter)
4263 chatbox.Active = false
4264 if enter and chatbox.Text ~= "" then
4265 newchat()
4266 end
4267 end)
4268 game:GetService("UserInputService").InputBegan:connect(function(keycode)
4269 if not canchat then
4270 chatbox.Visible = false
4271 return
4272 end
4273 if warn.Visible then
4274 return
4275 end
4276 local key = keycode.KeyCode
4277 if not chatbox.Active then
4278 if key == Enum.KeyCode.Slash then
4279 wait(0.03333333333333333)
4280 chatbox:CaptureFocus()
4281 chatbox.ClearTextOnFocus = false
4282 elseif key == Enum.KeyCode[hud.voteyes] then
4283 hud:vote("yes")
4284 elseif key == Enum.KeyCode[hud.votedismiss] then
4285 hud:vote("dismiss")
4286 elseif key == Enum.KeyCode[hud.voteno] then
4287 hud:vote("no")
4288 end
4289 end
4290 end)
4291 if player.UserId < 0 or input.consoleon then
4292 chat:disable(player.userId < 0)
4293 end
4294end
4295print("Loading hud module")
4296do
4297 local wfc = game.WaitForChild
4298 local ffc = game.FindFirstChild
4299 local ud2 = UDim2.new
4300 local ceil = math.ceil
4301 local cf = CFrame.new
4302 local v3 = Vector3.new
4303 local color = Color3.new
4304 local dot = Vector3.new().Dot
4305 local cos = math.cos
4306 local workspace = workspace
4307 local ray = Ray.new
4308 local new = Instance.new
4309 local raycast = workspace.FindPartOnRayWithIgnoreList
4310 local infolder = function(l, e)
4311 for i = 1, #l do
4312 if l[i].Name == e then
4313 return l[i]
4314 end
4315 end
4316 end
4317 local rtype = game.IsA
4318 local debris = game.Debris
4319 local isChina = ChinaPolicyService:IsActive()
4320 local player = game:GetService("Players").LocalPlayer
4321 local playertag = game.ReplicatedStorage.Character.PlayerTag
4322 local pgui = player.PlayerGui
4323 local repstore = game.ReplicatedStorage
4324 local modulestore = repstore.GunModules
4325 local misc = repstore.Misc
4326 local xboxmisc = repstore.XBOX
4327 local bloodarc = misc.BloodArc
4328 local spotdot = misc.Spot
4329 local rfeed = input.consoleon and xboxmisc.Feed or misc.Feed
4330 local hsht = misc.Headshot
4331 local maingui = wfc(pgui, "MainGui")
4332 if input.consoleon then
4333 maingui:Destroy()
4334 maingui = repstore.XBOX.MainGui:Clone()
4335 maingui.Parent = pgui
4336 end
4337 local spot = wfc(pgui, "Spot")
4338 local gamegui = wfc(maingui, "GameGui")
4339 local crossframe = wfc(gamegui, "CrossHud")
4340 local crossparts = {
4341 wfc(crossframe, "HR"),
4342 wfc(crossframe, "HL"),
4343 wfc(crossframe, "VD"),
4344 wfc(crossframe, "VU")
4345 }
4346 local ammohud = wfc(gamegui, "AmmoHud")
4347 local scopefr = wfc(maingui, "ScopeFrame")
4348 local hitmarker = wfc(gamegui, "Hitmarker")
4349 local tagfr = wfc(gamegui, "NameTag")
4350 local capfr = wfc(gamegui, "Capping")
4351 local bloodscreen = wfc(gamegui, "BloodScreen")
4352 local radar = wfc(gamegui, "Radar")
4353 local killfeed = wfc(gamegui, "Killfeed")
4354 local steady = wfc(gamegui, "Steady")
4355 local use = wfc(gamegui, "Use")
4356 local round = wfc(gamegui, "Round")
4357 local spotted = wfc(gamegui, "Spotted")
4358 local chatfr = wfc(pgui.ChatGame, "GlobalChat")
4359 local steadyfull = wfc(steady, "Full")
4360 local steadybar = wfc(steadyfull, "Bar")
4361 local rme = wfc(radar, "Me")
4362 local rfolder = wfc(radar, "Folder")
4363 local distance = 300
4364 local offset = -rme.Size.X.Offset / 2
4365 local ammofr = wfc(ammohud, "Frame")
4366 local ammotext = wfc(ammofr, "Ammo")
4367 local gammo = wfc(ammofr, "GAmmo")
4368 local magtext = wfc(ammofr, "Mag")
4369 local healthtext = wfc(ammofr, "Health")
4370 local fmodetext = wfc(ammofr, "FMode")
4371 local healthbar = wfc(ammofr, "healthbar_back")
4372 local healthbarFill = wfc(healthbar, "healthbar_fill")
4373 local newGUIColors = {
4374 Color3.new(0.14901960784313725, 0.3137254901960784, 0.2784313725490196),
4375 Color3.new(0.17647058823529413, 0.5019607843137255, 0.43137254901960786),
4376 Color3.new(0.8745098039215686, 0.12156862745098039, 0.12156862745098039),
4377 Color3.new(0.5333333333333333, 0.06666666666666667, 0.06666666666666667)
4378 }
4379 local cbar = wfc(capfr, "Percent")
4380 local sightmark, scopemark, centermark
4381 local nametags = {}
4382 local dotlist = {}
4383 local healthlist = {}
4384 local lastcombat = {}
4385 local prevhealth = 0
4386 local rtime = 0
4387 local stime = 0
4388 local renderinterval = 0.016666666666666666
4389 local spotinterval = 0.1
4390 local cinamode = false
4391 local cinalist = {
4392 ammohud,
4393 radar,
4394 killfeed,
4395 crossframe,
4396 round
4397 }
4398 hud.crossscale = physics.spring.new(0)
4399 hud.crossscale.s = 10
4400 hud.crossscale.d = 0.8
4401 hud.crossscale.t = 1
4402 hud.crossspring = physics.spring.new(0)
4403 hud.crossspring.s = 12
4404 hud.crossspring.d = 0.65
4405 hud.hitspring = physics.spring.new(1)
4406 hud.hitspring.s = 5
4407 hud.hitspring.d = 0.7
4408 do
4409 local kickfr = wfc(pgui.ChatGame, "Votekick")
4410 local title = wfc(kickfr, "Title")
4411 local timer = wfc(kickfr, "Timer")
4412 local votes = wfc(kickfr, "Votes")
4413 local yes = wfc(kickfr, "Yes")
4414 local no = wfc(kickfr, "No")
4415 local dismiss = wfc(kickfr, "Dismiss")
4416 local choice = wfc(kickfr, "Choice")
4417 local votereq = 0
4418 local votecount = 0
4419 local votetick = 0
4420 local voting, voted
4421 hud.voteyes = "Y"
4422 hud.voteno = "N"
4423 hud.votedismiss = "J"
4424 yes.Text = "Yes [" .. string.upper(hud.voteyes) .. "]"
4425 no.Text = "No [" .. string.upper(hud.voteno) .. "]"
4426 dismiss.Text = "Dismiss [" .. string.upper(hud.votedismiss) .. "]"
4427 function hud.votestep()
4428 if voting then
4429 kickfr.Visible = true
4430 timer.Text = "Time left: 0:" .. string.format("%.2d", (votetick - tick()) % 60)
4431 votes.Text = "Votes: " .. votecount .. " out of " .. votereq .. " required"
4432 if votetick <= tick() or votecount >= votereq then
4433 voting = false
4434 kickfr.Visible = false
4435 end
4436 else
4437 kickfr.Visible = false
4438 end
4439 end
4440 function hud:vote(votecard)
4441 if voting and not voted then
4442 yes.Visible = false
4443 no.Visible = false
4444 dismiss.Visible = false
4445 choice.Visible = true
4446 voted = true
4447 if votecard == "yes" then
4448 choice.Text = "Voted Yes"
4449 choice.TextColor3 = yes.TextColor3
4450 elseif votecard == "dismiss" then
4451 choice.Text = "Vote Dismissed"
4452 choice.TextColor3 = dismiss.TextColor3
4453 voting = false
4454 kickfr.Visible = false
4455 else
4456 choice.Text = "Voted No"
4457 choice.TextColor3 = no.TextColor3
4458 end
4459 network:send("votefromUI", votecard)
4460 end
4461 end
4462 network:add("startvotekick", function(name, countdown, endtick, reqs)
4463 if not hud.disablevotekick then
4464 title.Text = "Votekick " .. name .. " out of the server?"
4465 kickfr.Visible = true
4466 yes.Visible = true
4467 no.Visible = true
4468 dismiss.Visible = true
4469 choice.Visible = false
4470 votereq = reqs
4471 votecount = 0
4472 votetick = endtick
4473 voting = true
4474 voted = false
4475 hud.votestep()
4476 end
4477 end)
4478 network:add("updatenumvotes", function(numvotes)
4479 votecount = numvotes
4480 end)
4481 end
4482 network:add("updateothershealth", function(player, health0, healtick0, healrate, maxhealth, alive)
4483 if not healthlist[player] then
4484 healthlist[player] = {}
4485 end
4486 healthlist[player].health0 = health0
4487 healthlist[player].healtick0 = healtick0
4488 healthlist[player].healrate = healrate
4489 healthlist[player].maxhealth = maxhealth
4490 healthlist[player].alive = alive
4491 if menu.updatelist then
4492 menu.updatelist(player, "Toggle")
4493 end
4494 end)
4495 network:add("killfeed", function(killer, victim, dist, weapon, head)
4496 local spacing = input.consoleon and 20 or 15
4497 local newfeed = rfeed:Clone()
4498 newfeed.Text = killer.Name
4499 newfeed.TextColor = killer.TeamColor
4500 newfeed.GunImg.Text = weapon
4501 newfeed.Victim.Text = victim.Name
4502 newfeed.Victim.TextColor = victim.TeamColor
4503 newfeed.GunImg.Dist.Text = "Dist: " .. dist .. " studs"
4504 newfeed.Parent = killfeed
4505 newfeed.GunImg.Size = UDim2.new(0, newfeed.GunImg.TextBounds.x, 0, 30)
4506 newfeed.GunImg.Position = UDim2.new(0, spacing + newfeed.TextBounds.x, 0, -5)
4507 newfeed.Victim.Position = UDim2.new(0, spacing * 2 + newfeed.TextBounds.x + newfeed.GunImg.TextBounds.x, 0, 0)
4508 if head then
4509 local headnote = hsht:Clone()
4510 headnote.Parent = newfeed.Victim
4511 headnote.Position = ud2(0, 10 + newfeed.Victim.TextBounds.x, 0, -5)
4512 end
4513 spawn(function()
4514 newfeed.Visible = true
4515 wait(20)
4516 for i = 1, 10 do
4517 if newfeed.Parent then
4518 newfeed.TextTransparency = i / 10
4519 newfeed.TextStrokeTransparency = i / 10 + 0.5
4520 newfeed.GunImg.TextStrokeTransparency = i / 10 + 0.5
4521 newfeed.GunImg.TextTransparency = i / 10
4522 newfeed.Victim.TextStrokeTransparency = i / 10 + 0.5
4523 newfeed.Victim.TextTransparency = i / 10
4524 wait(0.03333333333333333)
4525 end
4526 end
4527 if newfeed and newfeed.Parent then
4528 trash.remove(newfeed)
4529 end
4530 end)
4531 local kb = killfeed:GetChildren()
4532 for i = 1, #kb do
4533 local v = kb[i]
4534 v:TweenPosition(ud2(0.01, 5, 1, (i - #kb) * 25 - 25), "Out", "Sine", 0.2, true)
4535 if #kb > 5 and #kb - i >= 5 then
4536 spawn(function()
4537 if kb[1].Name ~= "Deleted" then
4538 for i = 1, 10 do
4539 if ffc(kb[1], "Victim") then
4540 kb[1].TextTransparency = i / 10
4541 kb[1].TextStrokeTransparency = i / 10 + 0.5
4542 kb[1].Victim.TextTransparency = i / 10
4543 kb[1].Victim.TextStrokeTransparency = i / 10 + 0.5
4544 kb[1].Name = "Deleted"
4545 kb[1].GunImg.TextTransparency = i / 10
4546 kb[1].GunImg.TextStrokeTransparency = i / 10 + 0.5
4547 wait(0.03333333333333333)
4548 end
4549 end
4550 trash.remove(kb[1])
4551 end
4552 end)
4553 end
4554 end
4555 end)
4556 do
4557 local deg = math.pi / 180
4558 local angles = CFrame.Angles
4559 local gamemode = repstore.ServerSettings.GameMode
4560 local caplightref = repstore.GamemodeProps.FlagDrop.Base.PointLight
4561 local flagcarryref = repstore.GamemodeProps.FlagCarry
4562 local flagdropref = repstore.GamemodeProps.FlagDrop
4563 local tphan = BrickColor.new("Bright blue")
4564 local tghost = BrickColor.new("Bright orange")
4565 local teams = {tphan, tghost}
4566 local captured = wfc(gamegui, "Captured")
4567 local revealed = wfc(gamegui, "Revealed")
4568 local ctf = {
4569 caplight = nil,
4570 [tphan.Name] = {
4571 revealtime = 0,
4572 droptime = 0,
4573 carrier = nil,
4574 carrymodel = nil,
4575 dropped = false,
4576 basecf = cf()
4577 },
4578 [tghost.Name] = {
4579 revealtime = 0,
4580 droptime = 0,
4581 carrier = nil,
4582 carrymodel = nil,
4583 dropped = false,
4584 basecf = cf()
4585 }
4586 }
4587 local function resetflag(flagcolor, droppedplayer)
4588 local tdata = ctf[flagcolor.Name]
4589 tdata.revealtime = 0
4590 tdata.carrier = nil
4591 if droppedplayer == player and ctf.caplight and ctf.caplight.Parent then
4592 ctf.caplight:Destroy()
4593 ctf.caplight = nil
4594 elseif tdata.carrymodel and tdata.carrymodel.Parent then
4595 tdata.carrymodel:Destroy()
4596 tdata.carrymodel = nil
4597 end
4598 end
4599 local function dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4600 local flagd
4601 if ctf[flagcolor.Name].dropmodel and ctf[flagcolor.Name].dropmodel.Parent then
4602 flagd = ctf[flagcolor.Name].dropmodel
4603 else
4604 flagd = flagdropref:Clone()
4605 end
4606 local base = ffc(flagd, "Base")
4607 if not base then
4608 print("no base", flagd)
4609 return
4610 end
4611 local tag = ffc(flagd, "Tag")
4612 local bgui = ffc(base, "BillboardGui")
4613 local light = ffc(base, "PointLight")
4614 tag.BrickColor = flagcolor
4615 flagd.TeamColor.Value = flagcolor
4616 bgui.Display.BackgroundColor = flagcolor
4617 light.Color = flagcolor.Color
4618 if flagcolor == player.TeamColor then
4619 bgui.Status.Text = secured and "Protect" or "Dropped"
4620 else
4621 bgui.Status.Text = secured and "Capture" or "Pick Up"
4622 end
4623 flagd:SetPrimaryPartCFrame(dropcf)
4624 flagd.Location.Value = dropcf
4625 flagd.Parent = workspace.Ignore.GunDrop
4626 ctf[flagcolor.Name].dropmodel = flagd
4627 ctf[flagcolor.Name].droptime = droptime
4628 ctf[flagcolor.Name].dropped = not secured
4629 if secured then
4630 ctf[flagcolor.Name].basecf = dropcf
4631 end
4632 end
4633 local function attachflag(stealer)
4634 if not (stealer and stealer.Parent) or not replication.getbodyparts then
4635 return
4636 end
4637 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4638 local bodyparts = replication.getbodyparts(stealer)
4639 if bodyparts and bodyparts.torso then
4640 local carrymodel = flagcarryref:Clone()
4641 carrymodel.Tag.BrickColor = oppositeteam
4642 carrymodel.Tag.BillboardGui.Display.BackgroundColor3 = oppositeteam.Color
4643 carrymodel.Tag.BillboardGui.AlwaysOnTop = false
4644 carrymodel.Base.PointLight.Color = oppositeteam.Color
4645 for i, v in next, carrymodel:GetChildren() do
4646 if v ~= carrymodel.Base then
4647 local weld = new("Weld", carrymodel.Base)
4648 weld.Part0 = carrymodel.Base
4649 weld.Part1 = v
4650 weld.C0 = carrymodel.Base.CFrame:inverse() * v.CFrame
4651 end
4652 if v:IsA("BasePart") then
4653 v.Anchored = false
4654 v.CanCollide = false
4655 end
4656 end
4657 local playerweld = new("Weld", carrymodel.Base)
4658 playerweld.Part0 = bodyparts.torso
4659 playerweld.Part1 = carrymodel.Base
4660 carrymodel.Parent = workspace.Ignore
4661 ctf[oppositeteam.Name].carrymodel = carrymodel
4662 end
4663 end
4664 function hud:nearenemyflag(stealer)
4665 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4666 if ctf[oppositeteam.Name] and ctf[oppositeteam.Name].basecf then
4667 local playerpos = hud:getplayerpos(stealer)
4668 if playerpos then
4669 local dist = (ctf[oppositeteam.Name].basecf.p - playerpos).Magnitude
4670 if dist < 100 then
4671 return true
4672 end
4673 end
4674 end
4675 return false
4676 end
4677 local rotspeed = 4
4678 local bouncespeed = 5
4679 function hud.gamemodestep()
4680 captured.Visible = false
4681 revealed.Visible = false
4682 if gamemode.Value == "Capture the Flag" then
4683 local oppositeteam = player.TeamColor == tphan and tghost or tphan
4684 if ctf[oppositeteam.Name].carrier == player and ctf[oppositeteam.Name].revealtime then
4685 captured.Visible = true
4686 captured.Text = "Capturing Enemy Flag!"
4687 revealed.Visible = true
4688 local revealtime = ctf[oppositeteam.Name].revealtime
4689 if revealtime > tick() then
4690 revealed.Text = "Position revealed in " .. math.ceil(revealtime - tick()) .. " seconds"
4691 else
4692 revealed.Text = "Flag position revealed to all enemies!"
4693 end
4694 end
4695 for i, v in next, teams, nil do
4696 local tdata = ctf[v.Name]
4697 if tdata.carrier ~= player then
4698 if tdata.carrier and not tdata.carrier.Parent then
4699 resetflag(v, nil)
4700 end
4701 if tdata.carrier and not tdata.carrymodel then
4702 attachflag(tdata.carrier)
4703 end
4704 if tdata.carrymodel and tdata.carrymodel.Parent and tdata.revealtime then
4705 local bg = tdata.carrymodel.Tag.BillboardGui
4706 local caption = player.TeamColor == tdata.carrier.TeamColor and "Capturing!" or "Stolen!"
4707 bg.AlwaysOnTop = player.TeamColor == tdata.carrier.TeamColor or tdata.revealtime < tick()
4708 bg.Distance.Text = caption
4709 end
4710 end
4711 end
4712 end
4713 end
4714 local t = 0
4715 local flagrespawntime = 60
4716 function hud.gamemoderenderstep()
4717 t = t + 1
4718 if gamemode.Value == "Capture the Flag" then
4719 for i, v in next, workspace.Ignore.GunDrop:GetChildren() do
4720 if v.Name == "FlagDrop" then
4721 local basecf = v.Location.Value
4722 v:SetPrimaryPartCFrame(basecf * cf(0, 0.2 * math.sin(t * bouncespeed * deg), 0) * angles(0, t * rotspeed * deg, 0))
4723 if ctf[v.TeamColor.Value.Name].dropped then
4724 local bgui = ffc(v.Base, "BillboardGui")
4725 local droptime = ctf[v.TeamColor.Value.Name].droptime
4726 if bgui and droptime and droptime + flagrespawntime > tick() then
4727 local count = math.floor(droptime + flagrespawntime - tick())
4728 bgui.Status.Text = (player.TeamColor ~= v.TeamColor.Value and "Pick up in: " or "Returning in:") .. count
4729 end
4730 end
4731 end
4732 end
4733 end
4734 end
4735 hud.attachflag = attachflag
4736 network:add("stealflag", function(stealer, timestamp)
4737 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4738 ctf[oppositeteam.Name].revealtime = timestamp
4739 ctf[oppositeteam.Name].carrier = stealer
4740 if ctf[oppositeteam.Name].dropmodel then
4741 ctf[oppositeteam.Name].dropmodel:Destroy()
4742 ctf[oppositeteam.Name].dropmodel = nil
4743 end
4744 if stealer == player and char.rootpart then
4745 ctf.caplight = caplightref:Clone()
4746 ctf.caplight.Color = oppositeteam.Color
4747 ctf.caplight.Parent = char.rootpart
4748 else
4749 attachflag(stealer)
4750 end
4751 end)
4752 network:add("updateflagrecover", function(flagcolor, capping, progress)
4753 local tdata = ctf[flagcolor.Name]
4754 if tdata.dropmodel then
4755 local iscapping = ffc(tdata.dropmodel, "IsCapping")
4756 local cappoint = ffc(tdata.dropmodel, "CapPoint")
4757 if iscapping and cappoint then
4758 iscapping.Value = capping
4759 cappoint.Value = progress
4760 end
4761 end
4762 end)
4763 network:add("dropflag", function(flagcolor, droppedplayer, dropcf, droptime, secured)
4764 dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4765 resetflag(flagcolor, droppedplayer)
4766 end)
4767 local function clearmap()
4768 print("Clearing map")
4769 for i, v in next, teams, nil do
4770 resetflag(v)
4771 end
4772 workspace.Ignore.GunDrop:ClearAllChildren()
4773 workspace.DeadBody:ClearAllChildren()
4774 workspace.Ignore.Bullets:ClearAllChildren()
4775 end
4776 network:add("getrounddata", function(gamevars)
4777 print("received game round data")
4778 local curmode = game.ReplicatedStorage.ServerSettings.GameMode.Value
4779 if curmode == "Capture the Flag" and gamevars.ctf then
4780 for i, v in next, teams, nil do
4781 local tdata = gamevars.ctf[v.Name]
4782 if tdata and ctf[v.Name] then
4783 ctf[v.Name].basecf = tdata.basecf
4784 if tdata.carrier and not tdata.dropped then
4785 ctf[v.Name].carrier = tdata.carrier
4786 ctf[v.Name].revealtime = tdata.revealtime
4787 attachflag(tdata.carrier)
4788 elseif tdata.dropped then
4789 ctf[v.Name].dropped = true
4790 dropflag(v, nil, tdata.dropcf, tdata.droptime, false)
4791 else
4792 ctf[v.Name].dropped = false
4793 dropflag(v, nil, tdata.basecf, tdata.droptime, true)
4794 end
4795 end
4796 end
4797 end
4798 end)
4799 network:add("clearmap", clearmap)
4800 end
4801 function hud.inializehealth(player, alive)
4802 if not healthlist[player] then
4803 healthlist[player] = {}
4804 end
4805 healthlist[player].health0 = alive and 100 or 0
4806 healthlist[player].healtick0 = 0
4807 healthlist[player].healrate = 0
4808 healthlist[player].maxhealth = 100
4809 healthlist[player].healwait = 5
4810 healthlist[player].alive = alive
4811 end
4812 local function gethealth(player)
4813 local healthstat = healthlist[player]
4814 if healthstat then
4815 local health0 = healthlist[player].health0
4816 local healtick0 = healthlist[player].healtick0
4817 local healrate = healthlist[player].healrate
4818 local maxhealth = healthlist[player].maxhealth
4819 local alive = healthlist[player].alive
4820 if alive then
4821 local x = tick() - healtick0
4822 if x < 0 then
4823 return health0
4824 else
4825 local curhealth = health0 + x * healrate
4826 return maxhealth > curhealth and curhealth or maxhealth
4827 end
4828 else
4829 return 0
4830 end
4831 else
4832 return 0
4833 end
4834 end
4835 local function changehealthlocally(player, dhealth)
4836 local healthstat = healthlist[player]
4837 if healthstat then
4838 local health0 = healthlist[player].health0
4839 local healtick0 = healthlist[player].healtick0
4840 local healrate = healthlist[player].healrate
4841 local maxhealth = healthlist[player].maxhealth
4842 local healwait = healthlist[player].healwait
4843 local alive = healthlist[player].alive
4844 if alive then
4845 local time = tick()
4846 local x = time - healtick0
4847 local curhealth
4848 if x < 0 then
4849 curhealth = health0
4850 else
4851 curhealth = health0 + x * healrate
4852 curhealth = maxhealth > curhealth and curhealth or maxhealth
4853 end
4854 healthlist[player].health0 = curhealth + dhealth
4855 if dhealth < 0 then
4856 healthlist[player].healtick0 = time + healwait
4857 else
4858 healthlist[player].healtick0 = time
4859 end
4860 end
4861 end
4862 end
4863 function hud:changehealthlocally(player, dhealth)
4864 changehealthlocally(player, dhealth)
4865 end
4866 do
4867 local sightfront = scopefr.SightFront
4868 local sightrear = scopefr.SightRear
4869 local sightreticle = sightrear.ReticleImage
4870 local scopeupdate = function()
4871 end
4872 scopefr.Changed:connect(scopeupdate)
4873 scopeupdate()
4874 function hud.updatescope(fpos, rpos, fsize, rsize)
4875 sightfront.Position = fpos
4876 sightrear.Position = rpos
4877 sightfront.Size = fsize
4878 sightrear.Size = rsize
4879 end
4880 function hud:setscopesettings(data)
4881 sightfront.BackgroundColor3 = data.scopelenscolor or Color3.new(0, 0, 0)
4882 sightfront.BackgroundTransparency = data.scopelenstrans or 1
4883 local imagesize = data.scopeimagesize or 1
4884 sightreticle.Image = data.scopeid
4885 sightreticle.ImageColor3 = data.sightcolor and Color3.new(data.sightcolor.r / 255, data.sightcolor.g / 255, data.sightcolor.b / 255) or data.scopecolor or Color3.new(1, 1, 1)
4886 sightreticle.Size = ud2(imagesize, 0, imagesize, 0)
4887 sightreticle.Position = ud2((1 - imagesize) / 2, 0, (1 - imagesize) / 2, 0)
4888 scopeupdate()
4889 end
4890 end
4891 function hud:gundrop(dropmodel, gunname)
4892 if not gamelogic.currentgun then
4893 return
4894 end
4895 if dropmodel and not ffc(dropmodel, "DB") then
4896 local dropdata = require(modulestore[gunname])
4897 if dropdata then
4898 use.Text = (input.consoleon and "Press DPadRight" or "Hold V") .. " to pick up [" .. (dropdata.displayname or gunname) .. "]"
4899 if dropdata.type == gamelogic.currentgun.type or dropdata.ammotype == gamelogic.currentgun.ammotype then
4900 local sparev = ffc(dropmodel, "Spare")
4901 if sparev and sparev.Value > 0 then
4902 local diff = 0
4903 local _, curspare = gamelogic.currentgun:dropguninfo()
4904 if curspare + sparev.Value > gamelogic.currentgun.sparerounds then
4905 diff = gamelogic.currentgun.sparerounds - curspare
4906 else
4907 diff = sparev.Value
4908 end
4909 if diff > 0 then
4910 local db = new("Model", dropmodel)
4911 db.Name = "DB"
4912 debris:AddItem(db, 1)
4913 gamelogic.currentgun:addammo(diff, gunname)
4914 network:send("g" .. "e" .. "t" .. "a" .. "m" .. "m" .. "o", dropmodel, diff)
4915 end
4916 end
4917 end
4918 end
4919 else
4920 use.Text = ""
4921 end
4922 end
4923 function hud:getuse()
4924 return use.Text ~= ""
4925 end
4926 function hud:enablegamegui(on)
4927 gamegui.Visible = on
4928 end
4929 function hud:togglecinema(on)
4930 cinamode = on
4931 for i, v in next, cinalist, nil do
4932 v.Visible = not on
4933 end
4934 end
4935 function hud:isplayeralive(p)
4936 local healthstat = healthlist[p]
4937 if healthstat then
4938 return healthlist[p].alive
4939 end
4940 end
4941 function hud:timesinceplayercombat(p)
4942 return tick() - (lastcombat[p] or 0)
4943 end
4944 function hud:getplayerpos(p)
4945 local char = p.Character
4946 if char.Parent and hud:isplayeralive(p) then
4947 local torso = ffc(char, "Torso")
4948 if torso then
4949 return torso.Position
4950 end
4951 end
4952 end
4953 function hud:getplayerhealth(p)
4954 return gethealth(p)
4955 end
4956 local crosshairtype = "Cross"
4957 function hud:setcrosssettings(class, size, speed, damper, sight, centered)
4958 hud.crossspring.t = size
4959 hud.crossspring.s = speed
4960 hud.crossspring.d = damper
4961 sightmark = sight
4962 centermark = centered
4963 if class == "SHOTGUN" then
4964 crosshairtype = "Shot"
4965 for i = 1, 4 do
4966 for _, parts in next, crossparts[i]:GetChildren() do
4967 if parts.Name == crosshairtype then
4968 parts.Visible = true
4969 end
4970 end
4971 end
4972 else
4973 crosshairtype = "Cross"
4974 for i = 1, 4 do
4975 for _, parts in next, crossparts[i]:GetChildren() do
4976 parts.Visible = false
4977 end
4978 end
4979 end
4980 end
4981 function hud:updatesightmark(sight, centered)
4982 sightmark = sight
4983 centermark = centered
4984 end
4985 function hud:updatescopemark(sight)
4986 scopemark = sight
4987 end
4988 local function updatecross()
4989 if not char.speed or not char.sprint then
4990 return
4991 end
4992 local size = hud.crossspring.p * 2 * hud.crossscale.p * (char.speed / 14 * 0.19999999999999996 * 2 + 0.8) * (char.sprint / 2 + 1)
4993 sprintcross.Visible = false
4994 if crosshairtype == "Cross" then
4995 for i = 1, 4 do
4996 crossparts[i].BackgroundTransparency = 1 - size / 20
4997 end
4998 else
4999 for i = 1, 4 do
5000 crossparts[i].BackgroundTransparency = 1
5001 for _, parts in next, crossparts[i]:GetChildren() do
5002 if parts.Name == crosshairtype then
5003 parts.BackgroundTransparency = 1 - size / 20 * (size / 20)
5004 end
5005 end
5006 end
5007 end
5008 crossparts[1].Position = ud2(0, size, 0, 0)
5009 crossparts[2].Position = ud2(0, -size - 7, 0, 0)
5010 crossparts[3].Position = ud2(0, 0, 0, size)
5011 crossparts[4].Position = ud2(0, 0, 0, -size - 7)
5012 local uiscale = getuiscale()
5013 if not centermark and hud.crossspring.t == 0 and sightmark and sightmark.Parent then
5014 local pos = camera.currentcamera:WorldToViewportPoint(sightmark.Position)
5015 hitmarker.Position = ud2(0, pos.x / uiscale - 125, 0, pos.y / uiscale - 125)
5016 else
5017 hitmarker.Position = ud2(0.5, -125, 0.5, -125)
5018 end
5019 end
5020 function hud:getplayervisible(guy)
5021 local state = nametags[guy]
5022 if state then
5023 return state.Visible
5024 end
5025 end
5026 local localplayer = game:GetService("Players").LocalPlayer
5027 local nametagupdates = {}
5028 local function addnametag(player)
5029 if player == localplayer then
5030 return
5031 end
5032 local head, torso
5033 local function newchar(char)
5034 head = char:WaitForChild("Head")
5035 torso = char:WaitForChild("Torso")
5036 end
5037 local tag, taghealth
5038 local function playerchanged(prop)
5039 if prop == "TeamColor" and tag and tag.Parent then
5040 if player.TeamColor == localplayer.TeamColor then
5041 tag.Visible = true
5042 taghealth.Visible = false
5043 tag.TextColor3 = color(0, 1, 0.9176470588235294)
5044 tag.Dot.BackgroundTransparency = 1
5045 else
5046 tag.Visible = false
5047 taghealth.Visible = false
5048 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
5049 tag.Dot.BackgroundTransparency = 1
5050 end
5051 end
5052 end
5053 local function newtag()
5054 tag = playertag:Clone()
5055 tag.Text = player.Name
5056 tag.Parent = tagfr
5057 tag.Visible = false
5058 taghealth = wfc(tag, "Health")
5059 tag.Dot.BackgroundTransparency = 1
5060 tag.TextTransparency = 1
5061 tag.TextStrokeTransparency = 1
5062 playerchanged("TeamColor")
5063 nametags[player] = tag
5064 end
5065 newtag()
5066 local function update()
5067 if not tag.Parent or not taghealth.Parent then
5068 return
5069 end
5070 if hud:isplayeralive(player) and head and head.Parent and torso and torso.Parent then
5071 local torsopos = torso.CFrame * v3(0, -0.25, 0)
5072 if camera.screencull.sphere(torsopos, 4) then
5073 local camcf = camera.cframe
5074 local headpos = head.Position
5075 local spos = camera.currentcamera:WorldToScreenPoint(headpos + cframe.vtws(camcf, v3(0, 0.625, 0)))
5076 local center = camera.currentcamera.ViewportSize / 2
5077 local dist = (torsopos - camcf.p).magnitude
5078 local d = dot(camera.lookvector, (torsopos - camcf.p).unit)
5079 local diff = (1 / (d * d) - 1) ^ 0.5 * dist
5080 local uiscale = getuiscale()
5081 tag.Position = ud2(0, spos.x / uiscale - 75, 0, spos.y / uiscale)
5082 if player.TeamColor == localplayer.TeamColor then
5083 tag.Visible = true
5084 taghealth.Visible = hud:isplayeralive(player)
5085 tag.TextColor3 = color(0, 1, 0.9176470588235294)
5086 tag.Dot.BackgroundColor3 = color(0, 1, 0.9176470588235294)
5087 if diff < 4 then
5088 tag.TextTransparency = 0.125
5089 taghealth.BackgroundTransparency = 0.75
5090 taghealth.Percent.BackgroundTransparency = 0.25
5091 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
5092 tag.Dot.BackgroundTransparency = 1
5093 elseif diff < 8 then
5094 tag.TextTransparency = 0.125 + 0.875 * (diff - 4) / 4
5095 taghealth.BackgroundTransparency = 0.75 + 0.25 * (diff - 4) / 4
5096 taghealth.Percent.BackgroundTransparency = 0.25 + 0.75 * (diff - 4) / 4
5097 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
5098 tag.Dot.BackgroundTransparency = 1
5099 else
5100 tag.Dot.BackgroundTransparency = 0.125
5101 tag.TextTransparency = 1
5102 taghealth.BackgroundTransparency = 1
5103 taghealth.Percent.BackgroundTransparency = 1
5104 end
5105 else
5106 tag.Dot.BackgroundTransparency = 1
5107 taghealth.Visible = false
5108 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
5109 tag.Dot.BackgroundColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
5110 if hud:isspotted(player) and hud:isinsight(player) then
5111 local visible = true
5112 tag.Visible = visible
5113 if visible then
5114 if diff < 4 then
5115 tag.TextTransparency = 0
5116 else
5117 tag.TextTransparency = 1
5118 tag.Dot.BackgroundTransparency = 0
5119 end
5120 end
5121 elseif not hud:isspotted(player) and diff < 4 then
5122 local visible
5123 local tempignore = {
5124 camera.currentcamera,
5125 localplayer.Character,
5126 player.Character
5127 }
5128 local scan, pos = nil, camera.cframe.p
5129 while true do
5130 scan, pos = raycast(workspace, ray(pos, torsopos - pos), tempignore)
5131 repeat
5132 if scan then
5133 if scan.Transparency ~= 0 then
5134 tempignore[#tempignore + 1] = scan
5135 else
5136 visible = false
5137 break
5138 end
5139 else
5140 visible = true
5141 break
5142 end
5143 until true
5144 end
5145 tag.Visible = visible
5146 if visible then
5147 if diff < 2 then
5148 tag.Visible = true
5149 tag.TextTransparency = 0.125
5150 elseif diff < 4 then
5151 tag.Visible = true
5152 tag.TextTransparency = 0.4375 * diff - 0.75
5153 else
5154 tag.Visible = false
5155 end
5156 end
5157 else
5158 tag.Visible = false
5159 taghealth.Visible = false
5160 end
5161 end
5162 else
5163 tag.Visible = false
5164 taghealth.Visible = false
5165 end
5166 else
5167 tag.Visible = false
5168 taghealth.Visible = false
5169 end
5170 end
5171 player.CharacterAdded:connect(newchar)
5172 player.Changed:connect(playerchanged)
5173 localplayer.Changed:connect(playerchanged)
5174 nametagupdates[player] = update
5175 delay(1, function()
5176 print("Awaiting char for", player.Name)
5177 while not player.Character do
5178 wait(0.1)
5179 end
5180 print(player.Name .. "'s character has loaded")
5181 newchar(player.Character)
5182 end)
5183 end
5184 hud.addnametag = addnametag
5185 function hud.removenametag(player)
5186 nametagupdates[player] = nil
5187 if nametags[player] then
5188 nametags[player]:Destroy()
5189 end
5190 nametags[player] = nil
5191 end
5192 game:GetService("Players").PlayerAdded:connect(addnametag)
5193 game:GetService("Players").PlayerRemoving:connect(function(player)
5194 nametagupdates[player] = nil
5195 if nametags[player] then
5196 nametags[player]:Destroy()
5197 end
5198 nametags[player] = nil
5199 end)
5200 for i, player in next, botwrapper.getbasehumanoids() do
5201 addnametag(player)
5202 end
5203 local function updateplayernames()
5204 for player, func in next, nametagupdates, nil do
5205 if not player or not player.Parent then
5206 nametagupdates[player] = nil
5207 if nametags[player] then
5208 nametags[player]:Destroy()
5209 end
5210 nametags[player] = nil
5211 else
5212 nametagupdates[player]()
5213 end
5214 end
5215 end
5216 function hud:capping(flag, progress, mode)
5217 local maxcappoint = mode == "ctf" and 100 or 50
5218 if flag then
5219 capfr.Visible = true
5220 capfr.Note.Text = mode == "ctf" and "Recovering..." or "Capturing..."
5221 cbar.Size = ud2(progress / maxcappoint, 0, 1, 0)
5222 else
5223 capfr.Visible = false
5224 end
5225 end
5226 function hud:setsteadybar(size)
5227 steadybar.Size = size
5228 end
5229 function hud:getsteadysize()
5230 return steadybar.Size.X.Scale
5231 end
5232 function hud:setcrossscale(scale)
5233 hud.crossscale.t = scale
5234 end
5235 function hud:setcrosssize(size)
5236 hud.crossspring.t = size
5237 end
5238 function hud:setscope(visible, nosway)
5239 scopefr.Visible = visible
5240 steady.Visible = visible and not nosway
5241 steady.Text = "Hold Shift to steady"
5242 if visible then
5243 sound.play("useScope", 0.25)
5244 doScopeBeat = true
5245 delay(0.5, heartIn)
5246 end
5247 if not visible then
5248 doScopeBeat = false
5249 end
5250 end
5251 function heartIn()
5252 if doScopeBeat then
5253 local setdelay
5254 setdelay = hud:getsteadysize() / 5
5255 sound.play("heartBeatIn", 0.05 + setdelay)
5256 delay(0.3 + setdelay, heartOut)
5257 end
5258 end
5259 function heartOut()
5260 if doScopeBeat then
5261 local setdelay
5262 setdelay = hud:getsteadysize() / 4
5263 sound.play("heartBeatOut", 0.05 + setdelay)
5264 delay(0.5 + setdelay, heartIn)
5265 end
5266 end
5267 function hud:updateammo(mag, ammo)
5268 if mag == "KNIFE" then
5269 ammotext.Text = "- - -"
5270 magtext.Text = "- - -"
5271 elseif mag == "GRENADE" then
5272 ammotext.Text = "- - -"
5273 magtext.Text = "- - -"
5274 gammo.Text = gamelogic.gammo .. "x"
5275 else
5276 ammotext.Text = ammo
5277 magtext.Text = mag
5278 end
5279 end
5280 function hud:updatefiremode(mode)
5281 fmodetext.Text = mode == "KNIFE" and "- - -" or mode == true and "AUTO" or mode == 1 and "SEMI" or "BURST"
5282 end
5283 function hud:firehitmarker(head)
5284 hud.hitspring.p = -3
5285 if head then
5286 hitmarker.ImageColor3 = Color3.new(1, 0, 0)
5287 else
5288 hitmarker.ImageColor3 = Color3.new(1, 1, 1)
5289 end
5290 end
5291 do
5292 local deg = math.pi / 180
5293 local minimapfiles = wfc(repstore, "MiniMapModels")
5294 local mapname = wfc(repstore.ServerSettings, "MapName")
5295 local temp_minimap = wfc(minimapfiles, "Temp")
5296 local arrow_size = 14
5297 local selfsize = 16
5298 local fov = 45
5299 local height = 50
5300 local rel_height = 0
5301 local scale = 0.2
5302 local static_rotate = false
5303 local y_orientation = 0
5304 local minimapfr = wfc(gamegui, "MiniMapFrame")
5305 local minimap, minicenter, minimapcam, mapmodel, mapcenter, mapprops, refcenter
5306 local radarhash = {
5307 players = {},
5308 objectives = {},
5309 rings = {}
5310 }
5311 local radarfr = wfc(gamegui, "Radar")
5312 local rfolder = wfc(radarfr, "Folder")
5313 local x_res = maingui.AbsoluteSize.X
5314 local y_res = maingui.AbsoluteSize.Y
5315 local rf_x_res = radarfr.AbsoluteSize.X
5316 local rf_y_res = radarfr.AbsoluteSize.Y
5317 local gunshotlist = {}
5318 local ringshotlist = {}
5319 local last_alive_data = {}
5320 local ring_id = "rbxassetid://2925606552"
5321 local arrow_id = "rbxassetid://2911984939"
5322 local triangle_id = "rbxassetid://2910531391"
5323 local height_id = "rbxassetid://2911984609"
5324 local death_id = "rbxassetid://3116912054"
5325 local self_arrow = wfc(radarfr, "Me")
5326 self_arrow.Size = ud2(0, selfsize, 0, selfsize)
5327 self_arrow.Position = ud2(0.5, -selfsize / 2, 0.5, -selfsize / 2)
5328 local ref_arrow_list = {
5329 players = self_arrow,
5330 objectives = wfc(radarfr, "Objective")
5331 }
5332 function hud:reset_minimap()
5333 end
5334 function hud:set_minimap()
5335 mapmodel = ffc(workspace, "Map")
5336 if mapmodel then
5337 mapcenter = mapmodel.PrimaryPart
5338 mapprops = ffc(mapmodel, "AGMP")
5339 if not mapcenter then
5340 mapcenter = mapmodel.Teleport.B1
5341 end
5342 minimapcam = ffc(minimapfr, "Camera") or new("Camera")
5343 minimapcam.Parent = minimapfr
5344 minimapcam.FieldOfView = fov
5345 minimapfr.CurrentCamera = minimapcam
5346 if not minimap or minimap.Name ~= mapname.Value then
5347 if minimap then
5348 minimap:Destroy()
5349 end
5350 local ref_minimap = ffc(minimapfiles, mapname.Value)
5351 if ref_minimap then
5352 minimap = ref_minimap:Clone()
5353 minimap.Parent = minimapfr
5354 minicenter = minimap.PrimaryPart
5355 else
5356 minimap = temp_minimap:Clone()
5357 minimap.Parent = minimapfr
5358 minicenter = minimap.PrimaryPart
5359 end
5360 else
5361 end
5362 else
5363 print("Did not find map")
5364 end
5365 end
5366 local function gen_minimap_pos(objectcf)
5367 local rel_cf = mapcenter.CFrame:inverse() * objectcf
5368 local scaled_v3 = rel_cf.p * scale
5369 local scaled_pos = scaled_v3 + minicenter.Position
5370 local screenpos, visible = minimapcam:WorldToViewportPoint(scaled_pos)
5371 local scaled_x = screenpos.X
5372 local scaled_y = screenpos.Y
5373 local rel_x = scaled_x - 0.5
5374 local rel_y = 0.5 - scaled_y
5375 local angle = math.atan(rel_x / rel_y) * 180 / math.pi
5376 if rel_y < 0 then
5377 angle = angle - 180
5378 end
5379 local clip_buffer = 0
5380 if scaled_x > 1 - clip_buffer then
5381 scaled_x = 1 - clip_buffer
5382 end
5383 if scaled_x < 0 + clip_buffer then
5384 scaled_x = 0 + clip_buffer
5385 end
5386 if scaled_y > 1 - clip_buffer then
5387 scaled_y = 1 - clip_buffer
5388 end
5389 if scaled_y < 0 + clip_buffer then
5390 scaled_y = 0 + clip_buffer
5391 end
5392 local height_diff = math.abs(objectcf.p.Y - refcenter.CFrame.p.Y)
5393 return scaled_x, scaled_y, height_diff, visible, angle
5394 end
5395 local function get_ring(index)
5396 if not radarhash.rings[index] then
5397 local new_ring = self_arrow:Clone()
5398 new_ring.Parent = rfolder
5399 new_ring.Size = ud2(0, 0, 0, 0)
5400 new_ring.ImageColor3 = Color3.new(0.7843137254901961, 0.19607843137254902, 0.19607843137254902)
5401 new_ring.Image = ring_id
5402 new_ring.Height.Visible = false
5403 radarhash.rings[index] = new_ring
5404 end
5405 return radarhash.rings[index]
5406 end
5407 local function get_arrow(index, mtype)
5408 if not radarhash[mtype][index] then
5409 local new_arrow = ref_arrow_list[mtype]:Clone()
5410 new_arrow.Parent = rfolder
5411 new_arrow.Size = ud2(0, arrow_size, 0, arrow_size)
5412 radarhash[mtype][index] = new_arrow
5413 end
5414 return radarhash[mtype][index]
5415 end
5416 local updatelastfired = function(object)
5417 end
5418 local function update_minimap_ring(index, ring_data)
5419 local scaled_x, scaled_y, height_diff, visible = gen_minimap_pos(ring_data.refpart.CFrame)
5420 local ring = get_ring(index)
5421 local ring_size0 = ring_data.size0 or 4
5422 local ring_size1 = ring_data.size1 or 30
5423 local ring_size
5424 local ring_trans = (tick() - ring_data.shottime) / ring_data.lifetime
5425 local delta = (ring_size1 - ring_size0) * ring_trans
5426 ring_size = ring_size0 + delta
5427 ring.ImageColor3 = ring_data.teamcolor == localplayer.TeamColor and color(0, 0.7843137254901961, 1) or Color3.new(0.7843137254901961, 0.19607843137254902, 0.19607843137254902)
5428 ring.ImageTransparency = ring_trans
5429 ring.Size = ud2(0, ring_size, 0, ring_size)
5430 ring.Position = ud2(scaled_x, -ring_size / 2, scaled_y, -ring_size / 2)
5431 ring.Visible = true
5432 end
5433 local function update_minimap_object(data)
5434 local scaled_x, scaled_y, height_diff, visible, rel_angle = gen_minimap_pos(data.partcf)
5435 local cur_arrow_size = arrow_size
5436 local height_trans = 0.002 * height_diff ^ 2.5
5437 local arrow = get_arrow(data.index, data.mtype)
5438 local arrow_color
5439 if data.mtype == "players" then
5440 arrow.Image = data.isalive and arrow_id or death_id
5441 arrow_color = data.teamcolor == player.TeamColor and color(0, 0.7843137254901961, 1) or color(1, 0, 0)
5442 if data.isself then
5443 arrow_color = color(0, 1, 0.2)
5444 end
5445 arrow.ImageColor3 = arrow_color
5446 arrow.Height.ImageColor3 = arrow.ImageColor3
5447 arrow.Height.Visible = not data.isself and data.isalive
5448 arrow.Height.ImageTransparency = data.trans or 0
5449 local _, y, _ = data.partcf:ToOrientation()
5450 local py_angle = y * 180 / math.pi
5451 local rel_y = y_orientation
5452 if static_rotate then
5453 rel_y = mapcenter.Orientation.Y
5454 end
5455 if visible then
5456 arrow.Rotation = rel_y - py_angle
5457 arrow.ImageTransparency = data.trans or height_trans
5458 else
5459 arrow.Rotation = rel_angle
5460 cur_arrow_size = arrow_size - 2
5461 arrow.Image = data.isalive and triangle_id or death_id
5462 arrow.ImageTransparency = data.trans or 0
5463 end
5464 arrow.Size = ud2(0, cur_arrow_size, 0, cur_arrow_size)
5465 elseif data.mtype == "objectives" then
5466 arrow_color = data.teamcolor.Color
5467 arrow.Label.Text = data.text
5468 arrow.Label.TextColor3 = arrow_color
5469 arrow.Label.Visible = true
5470 end
5471 arrow.ImageColor3 = arrow_color
5472 arrow.Position = ud2(scaled_x, -cur_arrow_size / 2, scaled_y, -cur_arrow_size / 2)
5473 arrow.Visible = true
5474 end
5475 function hud:fireradar(guy, suppressed, pingdata)
5476 local gunshotdata = gunshotlist[guy]
5477 if not gunshotdata and guy.TeamColor ~= localplayer.TeamColor then
5478 local refpart = new("Part")
5479 gunshotdata = {
5480 refpart = refpart,
5481 shottime = 0,
5482 lifetime = 0
5483 }
5484 gunshotlist[guy] = gunshotdata
5485 end
5486 local ringshotdata = ringshotlist[guy]
5487 if not ringshotdata then
5488 local refpart = new("Part")
5489 ringshotdata = {
5490 refpart = refpart,
5491 shottime = 0,
5492 lifetime = 0,
5493 teamcolor = guy.TeamColor
5494 }
5495 ringshotlist[guy] = ringshotdata
5496 end
5497 local rootpart = ffc(guy.Character, "HumanoidRootPart")
5498 local alive = hud:isplayeralive(guy)
5499 if rootpart and alive then
5500 ringshotdata.refpart.CFrame = rootpart.CFrame
5501 ringshotdata.teamcolor = guy.TeamColor
5502 ringshotdata.lifetime = pingdata.pinglife or 0.5
5503 ringshotdata.size0 = pingdata.size0
5504 ringshotdata.size1 = pingdata.size1
5505 if tick() > ringshotdata.shottime + ringshotdata.lifetime then
5506 ringshotdata.shottime = tick()
5507 end
5508 if not suppressed and guy.TeamColor ~= localplayer.TeamColor then
5509 gunshotdata.refpart.CFrame = rootpart.CFrame
5510 gunshotdata.lifetime = 5
5511 gunshotdata.shottime = tick()
5512 end
5513 end
5514 end
5515 function hud:set_rel_height()
5516 rel_height = rel_height == 0 and 1 or 0
5517 end
5518 function hud:set_minimap_style()
5519 static_rotate = not static_rotate
5520 end
5521 local function updateminimap()
5522 if not mapcenter then
5523 return print("No map found")
5524 end
5525 if not minicenter then
5526 return print("No minimap found")
5527 end
5528 refcenter = camera:isspectating() or camera.currentcamera
5529 if char.health > 0 then
5530 self_arrow.Visible = true
5531 self_arrow.ImageColor3 = color(0, 200, 255)
5532 else
5533 self_arrow.Visible = camera:isspectating()
5534 self_arrow.ImageColor3 = color(1, 0, 0)
5535 end
5536 self_arrow.Height.ImageColor3 = self_arrow.ImageColor3
5537 local rel_cf = mapcenter.CFrame:inverse() * refcenter.CFrame
5538 local scaled_v3 = rel_cf.p * scale * v3(1, rel_height, 1)
5539 local _, y_angle, _ = camera.cframe:ToOrientation()
5540 y_orientation = y_angle * 180 / math.pi
5541 local angle = mapcenter.Orientation.Y - y_orientation
5542 local scaled_pos = scaled_v3 + minicenter.Position
5543 if static_rotate then
5544 minimapcam.CFrame = CFrame.new(scaled_pos + Vector3.new(0, height, 0)) * CFrame.Angles(-90 * deg, 0, 0)
5545 self_arrow.Rotation = angle
5546 else
5547 minimapcam.CFrame = CFrame.new(scaled_pos + Vector3.new(0, height, 0)) * CFrame.Angles(0, -angle * deg, 0) * CFrame.Angles(-90 * deg, 0, 0)
5548 self_arrow.Rotation = 0
5549 end
5550 local p_index = 0
5551 local ppl = botwrapper.getbasehumanoids()
5552 for i = 1, #ppl do
5553 local v = ppl[i]
5554 if v.Character then
5555 local rootpart = ffc(v.Character, "HumanoidRootPart")
5556 local alive = hud:isplayeralive(v) or localplayer == v and char.health > 0
5557 if not last_alive_data[v] then
5558 last_alive_data[v] = {
5559 lastcf = cf(),
5560 alivetick = 0
5561 }
5562 end
5563 if rootpart and alive then
5564 last_alive_data[v].lastcf = rootpart.CFrame
5565 last_alive_data[v].alivetick = tick()
5566 end
5567 local diff = 0
5568 local transparency
5569 local show = localplayer ~= v and v.TeamColor == localplayer.TeamColor
5570 if not alive then
5571 diff = (tick() - last_alive_data[v].alivetick) / 5
5572 transparency = math.min(diff > 0.1 and diff ^ 0.5 or 0, 1)
5573 show = true
5574 elseif not show and hud:isspotted(v) and hud:isinsight(v) and localplayer ~= v then
5575 transparency = 0
5576 show = true
5577 end
5578 local rootcf = last_alive_data[v].lastcf
5579 if rootcf and show then
5580 p_index = p_index + 1
5581 update_minimap_object({
5582 isself = v == localplayer,
5583 isalive = alive,
5584 index = p_index,
5585 partcf = rootcf,
5586 teamcolor = v.TeamColor,
5587 mtype = "players",
5588 trans = transparency
5589 })
5590 end
5591 end
5592 end
5593 for v, shotdata in next, gunshotlist, nil do
5594 local lifetime = shotdata.shottime + shotdata.lifetime - tick()
5595 if not v.Parent then
5596 if shotdata.refpart then
5597 shotdata.refpart:Destroy()
5598 end
5599 gunshotlist[v] = nil
5600 elseif lifetime > 0 then
5601 local alive = hud:isplayeralive(v)
5602 local diff = (tick() - shotdata.shottime) / shotdata.lifetime
5603 local arrow_trans = diff > 0.1 and diff ^ 0.5 or 0
5604 if alive then
5605 p_index = p_index + 1
5606 update_minimap_object({
5607 isalive = alive,
5608 index = p_index,
5609 partcf = shotdata.refpart.CFrame,
5610 teamcolor = v.TeamColor,
5611 mtype = "players",
5612 trans = arrow_trans
5613 })
5614 end
5615 end
5616 end
5617 local r_index = 0
5618 for v, shotdata in next, ringshotlist, nil do
5619 local lifetime = shotdata.shottime + shotdata.lifetime - tick()
5620 if not v.Parent then
5621 if shotdata.refpart then
5622 shotdata.refpart:Destroy()
5623 end
5624 ringshotlist[v] = nil
5625 elseif lifetime > 0 then
5626 r_index = r_index + 1
5627 update_minimap_ring(r_index, shotdata)
5628 end
5629 end
5630 local m_index = 0
5631 if mapprops then
5632 local stuff = mapprops:GetChildren()
5633 for i = 1, #stuff do
5634 local v = stuff[i]
5635 local base = ffc(v, "Base")
5636 local teamcolor = ffc(v, "TeamColor")
5637 local letter = ffc(v, "Letter")
5638 local text
5639 if v.Name == "KingFlag" then
5640 text = "H"
5641 elseif v.Name == "FlagBase" then
5642 text = "F"
5643 elseif v.Name == "DomFlag" then
5644 text = letter and letter.Value or ""
5645 end
5646 if base then
5647 m_index = m_index + 1
5648 update_minimap_object({
5649 index = m_index,
5650 partcf = base.CFrame,
5651 teamcolor = teamcolor.Value,
5652 mtype = "objectives",
5653 text = text
5654 })
5655 end
5656 end
5657 end
5658 end
5659 local function reset_radar_pool()
5660 local old = rfolder:GetChildren()
5661 for i = 1, #old do
5662 old[i].Visible = false
5663 end
5664 for i, v in next, last_alive_data, nil do
5665 if not i.Parent then
5666 last_alive_data[i] = nil
5667 end
5668 end
5669 end
5670 function radarstep()
5671 reset_radar_pool()
5672 updateminimap()
5673 end
5674 end
5675 local function updatehealth()
5676 local health = char.health
5677 healthtext.Text = health + -health % 1
5678 if not isChina then
5679 if health < prevhealth then
5680 local damage = prevhealth - health
5681 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency - damage / prevhealth * 0.7
5682 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency - damage / prevhealth * 0.5 + 0.3
5683 elseif health > prevhealth or health == 100 then
5684 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency + 0.001
5685 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency + 0.001
5686 elseif health <= 0 then
5687 bloodscreen.ImageTransparency = 1
5688 bloodscreen.BackgroundTransparency = 1
5689 end
5690 end
5691 prevhealth = health
5692 if health <= 25 then
5693 healthbar.BackgroundColor3 = newGUIColors[4]
5694 healthbarFill.BackgroundColor3 = newGUIColors[3]
5695 else
5696 healthbar.BackgroundColor3 = newGUIColors[1]
5697 healthbarFill.BackgroundColor3 = newGUIColors[2]
5698 end
5699 healthbarFill.Size = UDim2.new(math.floor(health) / 100, 0, 1, 0)
5700 end
5701 do
5702 local spottedlist = {}
5703 local sightlist = {}
5704 local brokensight = {}
5705 function hud:spot()
5706 local spotlist = {}
5707 if char.health > 0 then
5708 local camcf = camera.cframe
5709 local dir = camcf.lookVector.unit
5710 local ppl = botwrapper.getbasehumanoids()
5711 local lteam = player.TeamColor
5712 local ignoretable = {
5713 camera.currentcamera,
5714 workspace.Ignore,
5715 workspace.DeadBody,
5716 player.Character
5717 }
5718 for i = 1, #ppl do
5719 local guy = ppl[i]
5720 if hud:isplayeralive(guy) and guy.TeamColor ~= lteam then
5721 local bodyparts = replication.getbodyparts(guy)
5722 if bodyparts and bodyparts.head then
5723 local rel = bodyparts.head.Position - camera.cframe.p
5724 local unit = rel.unit
5725 local d = dot(dir, unit)
5726 if d > 0.96592582628 then
5727 local origin = camcf.p
5728 local newray = ray(origin, rel)
5729 ignoretable[5] = bodyparts.head.Parent
5730 local hit = raycast(workspace, newray, ignoretable)
5731 if not hit then
5732 sightlist[guy] = true
5733 spotlist[#spotlist + 1] = guy
5734 end
5735 end
5736 end
5737 end
5738 end
5739 if #spotlist > 0 then
5740 network:send("spotplayers", spotlist)
5741 return true
5742 end
5743 end
5744 end
5745 network:add("brokensight", function(spottedplayer, status)
5746 if spottedplayer then
5747 brokensight[spottedplayer] = status
5748 end
5749 end)
5750 network:add("spotplayer", function(spottedplayer)
5751 if spottedplayer then
5752 spottedlist[spottedplayer] = true
5753 end
5754 end)
5755 network:add("unspotplayer", function(spottedplayer)
5756 if spottedplayer then
5757 spottedlist[spottedplayer] = nil
5758 end
5759 end)
5760 function hud:isspotted(spottedplayer)
5761 return spottedlist[spottedplayer]
5762 end
5763 function hud:isinsight(spottedplayer)
5764 return not brokensight[spottedplayer] or sightlist[player]
5765 end
5766 function hud.spotstep()
5767 local ignoretable = {
5768 camera.currentcamera,
5769 workspace.Ignore,
5770 workspace.DeadBody,
5771 player.Character
5772 }
5773 for spottedplayer in next, spottedlist, nil do
5774 local playerseen = false
5775 if char.health > 0 and spottedplayer.TeamColor ~= player.TeamColor then
5776 local bodyparts = replication.getbodyparts(spottedplayer)
5777 if bodyparts and bodyparts.torso and camera.screencull.sphere(bodyparts.torso.Position, 4) then
5778 local rel = bodyparts.head.Position - camera.cframe.p
5779 local origin = camera.cframe.p
5780 local newray = ray(origin, rel)
5781 ignoretable[5] = bodyparts.head.Parent
5782 local hit = raycast(workspace, newray, ignoretable)
5783 if not hit then
5784 playerseen = true
5785 if not sightlist[spottedplayer] then
5786 sightlist[spottedplayer] = true
5787 network:send("updatesight", spottedplayer, true, tick())
5788 end
5789 end
5790 end
5791 end
5792 if not playerseen and sightlist[spottedplayer] then
5793 sightlist[spottedplayer] = false
5794 network:send("updatesight", spottedplayer, false, tick())
5795 end
5796 end
5797 if hud:isspotted(player) then
5798 spotted.Visible = true
5799 if hud:isinsight(player) then
5800 spotted.Text = "Spotted by enemy!"
5801 spotted.TextColor3 = Color3.new(1, 0.125, 0.125)
5802 else
5803 spotted.Text = "Hiding from enemy..."
5804 spotted.TextColor3 = Color3.new(0.125, 1, 0.125)
5805 end
5806 else
5807 local spottag = ffc(spotted, "Spottimer")
5808 if spottag and 0 < spottag.Timer.Value then
5809 spotted.Visible = true
5810 spotted.Text = "On Radar!"
5811 spotted.TextColor3 = Color3.new(1, 0.8, 0)
5812 else
5813 spotted.Visible = false
5814 end
5815 end
5816 end
5817 function hud:goingloud()
5818 local spottag = ffc(spotted, "Spottimer")
5819 local timer
5820 if not spottag then
5821 spottag = new("Model", spotted)
5822 spottag.Name = "Spottimer"
5823 timer = new("IntValue", spottag)
5824 timer.Name = "Timer"
5825 else
5826 timer = spottag.Timer
5827 end
5828 timer.Value = timer.Value <= 30 and 30 or timer.Value + 30 > 200 and 200 or timer.Value + 30
5829 end
5830 end
5831 network:add("firehitmarker", function()
5832 hud:firehitmarker()
5833 end)
5834 network:add("shot", function(shooter, pos, damage)
5835 local bars = gamegui:GetChildren()
5836 for i = 1, #bars do
5837 if bars[i].Name == "BloodArc" and bars[i].Player.Value == shooter.Name then
5838 trash.remove(bars[i])
5839 end
5840 end
5841 local br = bloodarc:Clone()
5842 br.Pos.Value = pos
5843 br.Player.Value = shooter.Name
5844 br.Parent = gamegui
5845 local dir = (camera.cframe.p - pos).unit
5846 camera:hit((-damage / 12 + 4.166666666666667) * dir)
5847 end)
5848 network:add("updatecombat", function(guy, time)
5849 if guy then
5850 lastcombat[guy] = time
5851 end
5852 end)
5853 function hud:reloadhud()
5854 pgui = player.PlayerGui
5855 maingui = wfc(pgui, "MainGui")
5856 gamegui = wfc(maingui, "GameGui")
5857 bloodscreen = wfc(gamegui, "BloodScreen")
5858 crossframe = wfc(gamegui, "CrossHud")
5859 sprintcross = wfc(crossframe, "Sprint")
5860 crossparts = {
5861 wfc(crossframe, "HR"),
5862 wfc(crossframe, "HL"),
5863 wfc(crossframe, "VD"),
5864 wfc(crossframe, "VU")
5865 }
5866 ammohud = wfc(gamegui, "AmmoHud")
5867 ammofr = wfc(ammohud, "Frame")
5868 scopefr = wfc(maingui, "ScopeFrame")
5869 ammotext = wfc(ammofr, "Ammo")
5870 magtext = wfc(ammofr, "Mag")
5871 healthtext = wfc(ammofr, "Health")
5872 fmodetext = wfc(ammofr, "FMode")
5873 hitmarker = wfc(gamegui, "Hitmarker")
5874 tagfr = wfc(gamegui, "NameTag")
5875 healthbar = wfc(ammofr, "healthbar_back")
5876 healthbarFill = wfc(healthbar, "healthbar_fill")
5877 radar = wfc(gamegui, "Radar")
5878 rme = wfc(radar, "Me")
5879 rfolder = wfc(radar, "Folder")
5880 dotlist = {}
5881 hud:reset_minimap()
5882 hud:setscope(false)
5883 effects:reload()
5884 notify:reset()
5885 particle:reset()
5886 local bars = gamegui:GetChildren()
5887 for i = 1, #bars do
5888 if bars[i].Name == "BloodArc" then
5889 trash.remove(bars[i])
5890 end
5891 end
5892 local bar = ffc(maingui, "KillBar")
5893 if bar then
5894 trash.remove(bar)
5895 end
5896 wait(0.1)
5897 end
5898 function hud.beat()
5899 updateplayernames()
5900 updatehealth()
5901 end
5902 function hud.step()
5903 if gamegui.Visible then
5904 updatecross()
5905 hitmarker.ImageTransparency = hud.hitspring.p
5906 radarstep()
5907 if run.time > rtime + renderinterval then
5908 hud.gamemoderenderstep()
5909 rtime = run.time + renderinterval
5910 end
5911 if run.time > stime + spotinterval then
5912 hud.spotstep()
5913 hud.votestep()
5914 hud.gamemodestep()
5915 local sht = spot:GetChildren()
5916 for i = 1, #sht do
5917 local v = sht[i]
5918 if rtype(v, "BillboardGui") then
5919 if v.Time.Value <= 0 then
5920 trash.remove(v)
5921 else
5922 v.Time.Value = v.Time.Value - 1
5923 end
5924 end
5925 end
5926 local spottag = ffc(spotted, "Spottimer")
5927 if spottag and 0 < spottag.Timer.Value then
5928 spottag.Timer.Value = spottag.Timer.Value - 1
5929 end
5930 stime = run.time + spotinterval
5931 end
5932 end
5933 end
5934end
5935print("Loading notify module")
5936do
5937 local wfc = game.WaitForChild
5938 local ffc = game.FindFirstChild
5939 local ud2 = UDim2.new
5940 local ceil = math.ceil
5941 local v3 = Vector3.new
5942 local color = Color3.new
5943 local dot = Vector3.new().Dot
5944 local workspace = workspace
5945 local ray = Ray.new
5946 local raycast = workspace.FindPartOnRayWithIgnoreList
5947 local new = Instance.new
5948 local player = game:GetService("Players").LocalPlayer
5949 local repstore = game.ReplicatedStorage
5950 local misc = repstore.Misc
5951 local pgui = player.PlayerGui
5952 local maingui = wfc(pgui, "MainGui")
5953 local gamegui = wfc(maingui, "GameGui")
5954 local framelist = wfc(gamegui, "NotifyList")
5955 local main = misc.Main
5956 local side = misc.Side
5957 local killbar = misc.KillBar
5958 local rankbar = misc.RankBar
5959 local attachbar = misc.AttachBar
5960 local typelist = {
5961 kill = {
5962 "Enemy Killed!"
5963 },
5964 collx2 = {
5965 "Double Collateral!"
5966 },
5967 collx3 = {
5968 "Triple Collateral!"
5969 },
5970 collxn = {
5971 "Multi Collateral!"
5972 },
5973 killx2 = {
5974 "Double Kill!"
5975 },
5976 killx3 = {
5977 "Triple Kill!"
5978 },
5979 killx4 = {"Quad Kill!"},
5980 killxn = {
5981 "Multi Kill!"
5982 },
5983 backstab = {"Backstab!"},
5984 assist = {"Assist!"},
5985 suppression = {
5986 "Suppressed Enemy!"
5987 },
5988 assistkill = {
5989 "Assist Count As Kill!"
5990 },
5991 head = {
5992 "Headshot Bonus!"
5993 },
5994 wall = {
5995 "Wallbang Bonus!"
5996 },
5997 spot = {
5998 "Spot Bonus!"
5999 },
6000 long = {
6001 "Killed from a distance!"
6002 },
6003 squad = {
6004 "Teammate spawned on you"
6005 },
6006 flagsteal = {
6007 "Acquired Enemy Flag!"
6008 },
6009 flagcapture = {
6010 "Captured Enemy Flag!"
6011 },
6012 flagteamcap = {
6013 "Team Captured Enemy Flag!"
6014 },
6015 flagrecover = {
6016 "Recovered Team Flag!"
6017 },
6018 flagdef1 = {
6019 "Killed Enemy Flag Carrier!"
6020 },
6021 flagdef2 = {
6022 "Protected Flag Carrier!"
6023 },
6024 flagdef3 = {
6025 "Denied Enemy Capture!"
6026 },
6027 flagdef4 = {
6028 "Denied Enemy Pick Up!"
6029 },
6030 flagdef5 = {
6031 "Flag Guard Kill!"
6032 },
6033 flagdef6 = {
6034 "Flag Recover Kill!"
6035 },
6036 flagsup1 = {
6037 "Flag Escort Kill!"
6038 },
6039 flagsup2 = {
6040 "Killed Enemy Flag Escort!"
6041 },
6042 flagsup3 = {
6043 "Assisted by Teammate!"
6044 },
6045 flagsup4 = {
6046 "Protected Flag Carrier Under Fire!"
6047 },
6048 flagsup5 = {
6049 "Saved by Teammate!"
6050 },
6051 flagsup6 = {
6052 "Protected by Teammate!"
6053 },
6054 flagoff1 = {
6055 "Offensive Flag Kill!"
6056 },
6057 flagoff2 = {
6058 "Denied Enemy Flag Recovery!"
6059 },
6060 flagoff3 = {
6061 "Killed Enemy Flag Guard!"
6062 },
6063 dogtagself = {
6064 "Secured Personal Tag!"
6065 },
6066 dogtagconfirm = {
6067 "Kill Confirmed!"
6068 },
6069 dogtagteam = {
6070 "Teammate Confirmed Kill!"
6071 },
6072 dogtagdeny = {
6073 "Denied Enemy Kill!"
6074 },
6075 domcap = {
6076 "Captured a position!"
6077 },
6078 domcapping = {
6079 "Capturing position"
6080 },
6081 domdefend = {
6082 "Defended a position!"
6083 },
6084 domassault = {
6085 "Assaulted a position!"
6086 },
6087 domattack = {
6088 "Attacked a position!"
6089 },
6090 dombuzz = {
6091 "Stopped an enemy capture!"
6092 },
6093 kingcap = {
6094 "Captured the hill!"
6095 },
6096 kingholding = {
6097 "Holding hill"
6098 },
6099 kingcapping = {
6100 "Capturing hill"
6101 },
6102 kingdefend = {
6103 "Defended the hill!"
6104 },
6105 kingassault = {
6106 "Assaulted the hill!"
6107 },
6108 kingattack = {
6109 "Attacked the hill!"
6110 },
6111 kingbuzz = {
6112 "Stopped enemy capture of the hill!"
6113 },
6114 [" "] = {}
6115 }
6116 local function typeout(label, speed)
6117 label.AutoLocalize = false
6118 local speed = speed or 2
6119 local str = label.Text
6120 label.Text = ""
6121 spawn(function()
6122 local i = 1
6123 for first, last in utf8.graphemes(str) do
6124 local grapheme = str:sub(first, last)
6125 label.Text = label.Text .. grapheme
6126 if first > i * speed then
6127 sound.play("ui_typeout", 0.2)
6128 i = i + 1
6129 wait(0.016666666666666666)
6130 end
6131 end
6132 end)
6133 end
6134 local function queuetypeout(label, speed)
6135 label.AutoLocalize = false
6136 local speed = speed or 3
6137 local str = label.Text
6138 label.Text = ""
6139 local i = 1
6140 for first, last in utf8.graphemes(str) do
6141 local grapheme = str:sub(first, last)
6142 label.Text = label.Text .. grapheme
6143 if first > i * speed then
6144 sound.play("ui_typeout", 0.2)
6145 i = i + 1
6146 wait(0.016666666666666666)
6147 end
6148 end
6149 end
6150 function notify:customaward(customtext)
6151 local display = side:Clone()
6152 local primary = wfc(display, "Primary")
6153 display.Parent = framelist
6154 sound.play("ui_smallaward", 0.2)
6155 local fr = framelist:GetChildren()
6156 for i = 1, #fr do
6157 local v = fr[i]
6158 if v:IsA("Frame") and v.Parent then
6159 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
6160 end
6161 end
6162 spawn(function()
6163 primary.Text = customtext
6164 primary.TextTransparency = 0
6165 typeout(primary, 3)
6166 wait(5.5)
6167 for i = 1, 10 do
6168 primary.TextTransparency = i / 10
6169 primary.TextStrokeTransparency = i / 10 + 0.4
6170 wait(0.016666666666666666)
6171 end
6172 wait(0.1)
6173 trash.remove(display)
6174 end)
6175 end
6176 function smallaward(type, pt)
6177 local pt = pt or 25
6178 local display = side:Clone()
6179 local primary = wfc(display, "Primary")
6180 local point = wfc(display, "Point")
6181 sound.play("ui_smallaward", 0.2)
6182 display.Parent = framelist
6183 local fr = framelist:GetChildren()
6184 for i = 1, #fr do
6185 local v = fr[i]
6186 if v:IsA("Frame") and v.Parent then
6187 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
6188 end
6189 end
6190 spawn(function()
6191 point.Text = "[+" .. pt .. "]"
6192 primary.Text = typelist[type][1]
6193 if type == "head" then
6194 sound.play("headshotkill", 0.45)
6195 end
6196 point.TextTransparency = 0
6197 primary.TextTransparency = 0
6198 typeout(point, 3)
6199 typeout(primary, 3)
6200 wait(5.5)
6201 for i = 1, 10 do
6202 point.TextTransparency = i / 10
6203 primary.TextTransparency = i / 10
6204 point.TextStrokeTransparency = i / 10 + 0.4
6205 primary.TextStrokeTransparency = i / 10 + 0.4
6206 wait(0.016666666666666666)
6207 end
6208 wait(0.1)
6209 trash.remove(display)
6210 end)
6211 end
6212 function bigaward(type, victim, weap, pt, extradata)
6213 local display = main:Clone()
6214 local bk = wfc(display, "Overlay")
6215 local primary = wfc(display, "Primary")
6216 local point = wfc(display, "Point")
6217 local enemy = wfc(display, "Enemy")
6218 display.Parent = framelist
6219 local fr = framelist:GetChildren()
6220 for i = 1, #fr do
6221 local v = fr[i]
6222 if v:IsA("Frame") and v.Parent then
6223 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
6224 end
6225 end
6226 spawn(function()
6227 point.Text = "[+" .. pt .. "]"
6228 primary.Text = typelist[type][1]
6229 enemy.Text = victim or ""
6230 sound.play("ui_begin", 0.4)
6231 if type == "kill" then
6232 sound.play("killshot", 0.2)
6233 else
6234 end
6235 point.TextTransparency = 0
6236 point.TextStrokeTransparency = 0
6237 primary.TextTransparency = 0
6238 primary.TextStrokeTransparency = 0
6239 enemy.TextTransparency = 1
6240 enemy.TextStrokeTransparency = 1
6241 bk.ImageTransparency = 0.2
6242 bk:TweenSizeAndPosition(ud2(0, 200, 0, 80), ud2(0.5, -150, 0.7, -40), "Out", "Linear", 0, true)
6243 typeout(point)
6244 typeout(primary)
6245 spawn(function()
6246 wait(0.05)
6247 for i = 1, 10 do
6248 bk.ImageTransparency = i / 10
6249 wait(0.1)
6250 end
6251 bk.Size = ud2(0, 200, 0, 80)
6252 bk.Position = ud2(0.55, -100, 0.3, -40)
6253 end)
6254 bk:TweenSizeAndPosition(ud2(0, 300, 0, 30), ud2(0.5, -150, 0.7, -15), "Out", "Linear", 0.05, true)
6255 wait(0.05)
6256 bk:TweenSizeAndPosition(ud2(0, 500, 0, 8), ud2(0.5, -150, 0.7, -4), "Out", "Linear", 0.05, true)
6257 wait(1.5)
6258 for i = 1, 2 do
6259 primary.TextTransparency = 1
6260 primary.TextStrokeTransparency = 1
6261 sound.play("ui_blink", 0.4)
6262 wait(0.1)
6263 primary.TextTransparency = 0
6264 primary.TextStrokeTransparency = 0
6265 wait(0.1)
6266 end
6267 primary.TextTransparency = 1
6268 primary.TextStrokeTransparency = 1
6269 wait(0.2)
6270 enemy.TextTransparency = 0
6271 enemy.TextStrokeTransparency = 0
6272 queuetypeout(enemy, 4)
6273 primary.TextTransparency = 0
6274 primary.TextStrokeTransparency = 0
6275 primary.Position = ud2(0.5, enemy.TextBounds.x + 10, 0.7, -10)
6276 if type == "kill" then
6277 primary.Text = "[" .. weap .. "]"
6278 else
6279 primary.Text = weap
6280 end
6281 queuetypeout(primary, 4)
6282 wait(3)
6283 for i = 1, 10 do
6284 point.TextTransparency = i / 10
6285 primary.TextTransparency = i / 10
6286 enemy.TextTransparency = i / 10
6287 point.TextStrokeTransparency = i / 10 + 0.4
6288 primary.TextStrokeTransparency = i / 10 + 0.4
6289 enemy.TextStrokeTransparency = i / 10 + 0.4
6290 wait(0.016666666666666666)
6291 end
6292 wait(0.1)
6293 trash.remove(display)
6294 end)
6295 end
6296 local function unlockedgun(weapon)
6297 local br = attachbar:Clone()
6298 local title = br.Title
6299 local atext = br.Attach
6300 br.Parent = maingui
6301 br.Position = ud2(0.5, 0, 0.15, 0)
6302 title.Text = "Unlocked New Gun!"
6303 atext.Text = weapon
6304 local t0 = tick()
6305 local stop
6306 stop = run.onstep:connect(function()
6307 local t = tick() - t0
6308 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6309 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6310 if t > 3 then
6311 stop()
6312 br:Destroy()
6313 end
6314 end)
6315 end
6316 local function unlockedattach(weapon, attachments, killss)
6317 for i = 1, #attachments do
6318 do
6319 local attachment = attachments[i]
6320 local kills = killss[i]
6321 local br = attachbar:Clone()
6322 local money = br.Money
6323 local title = br.Title
6324 local atext = br.Attach
6325 br.Parent = maingui
6326 br.Position = ud2(0.5, 0, 0.15, 0)
6327 title.Text = "Unlocked " .. weapon .. " Attachment"
6328 atext.Text = attachment
6329 money.Text = "[+200]"
6330 local t0 = tick()
6331 local stop
6332 stop = run.onstep:connect(function()
6333 local t = tick() - t0
6334 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6335 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6336 money.TextTransparency = t < 0.5 and 1 or t < 2.5 and 0 or t < 3 and (t - 2.5) / 0.5 or 1
6337 if t > 3 then
6338 stop()
6339 br:Destroy()
6340 end
6341 end)
6342 wait(3)
6343 end
6344 end
6345 end
6346 local function rankup(old, new, newguns)
6347 local br = rankbar:Clone()
6348 local money = br.Money
6349 local title = br.Title
6350 local rtext = br.Rank
6351 local count = 0
6352 local sht = maingui:GetChildren()
6353 for i = 1, #sht do
6354 if sht[i].Name == "RankBar" or sht[i].Name == "AttachBar" then
6355 count = count + 1
6356 end
6357 end
6358 br.Parent = maingui
6359 rtext.Text = new
6360 money.Text = "+" .. 5 * (new - old) * (81 + new + old) / 2 .. " CR"
6361 local t0 = tick()
6362 local stop
6363 stop = run.onstep:connect(function()
6364 local t = tick() - t0
6365 rtext.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
6366 title.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
6367 money.TextTransparency = t < 0.5 and 1 or t < 3.5 and 0 or t < 4 and (t - 3.5) / 0.5 or 1
6368 if t > 4 then
6369 stop()
6370 br:Destroy()
6371 if newguns then
6372 for i = 1, #newguns do
6373 unlockedgun(newguns[i])
6374 wait(3)
6375 end
6376 end
6377 end
6378 end)
6379 end
6380 function notify:testrankup(rank)
6381 rankup(rank)
6382 end
6383 function notify:reset()
6384 maingui = wfc(pgui, "MainGui")
6385 gamegui = wfc(maingui, "GameGui")
6386 framelist = wfc(gamegui, "NotifyList")
6387 if ffc(maingui, "KillBar") then
6388 trash.remove(maingui.KillBar)
6389 end
6390 end
6391 do
6392 local cf = CFrame.new
6393 local tos = cf().toObjectSpace
6394 local bcolor = BrickColor.new
6395 local repstore = game.ReplicatedStorage
6396 local gunmodels = repstore.GunModels
6397 local gunmodules = repstore.GunModules
6398 local attmodels = repstore.AttachmentModels
6399 local function hideparts(wepmodel, atttype, hide)
6400 local parts = wepmodel:GetChildren()
6401 local slottag
6402 for i = 1, #parts do
6403 if atttype == "Optics" then
6404 if parts[i].Name == "Iron" or parts[i].Name == "IronGlow" then
6405 if hide and not ffc(parts[i], "Hide") then
6406 local tag = new("IntValue", parts[i])
6407 tag.Name = "Hide"
6408 else
6409 local tag = ffc(parts[i], "Hide")
6410 if tag then
6411 tag:Destroy()
6412 end
6413 end
6414 parts[i].Transparency = hide and 1 or 0
6415 elseif parts[i].Name == "SightMark" and ffc(parts[i], "Decal") then
6416 parts[i].Decal.Transparency = hide and 1 or 0
6417 end
6418 elseif atttype == "Underbarrel" and parts[i].Name == "Grip" then
6419 if hide and not ffc(parts[i], "Hide") then
6420 local tag = new("IntValue", parts[i])
6421 tag.Name = "Hide"
6422 else
6423 local tag = ffc(parts[i], "Hide")
6424 if tag then
6425 tag:Destroy()
6426 end
6427 end
6428 parts[i].Transparency = hide and 1 or 0
6429 slottag = ffc(parts[i], "Slot1") or ffc(parts[i], "Slot2")
6430 end
6431 end
6432 return slottag
6433 end
6434 local function texturemodel(wepmodel, attachdata, camodata, viewport)
6435 local root = camodata
6436 for i, part in next, wepmodel:GetChildren() do
6437 if viewport and part:IsA("BasePart") and part.Name == "LaserLight" then
6438 print("found laser")
6439 part.Material = "SmoothPlastic"
6440 if ffc(part, "Bar") then
6441 part.Bar.Scale = v3(0.1, 1000, 0.1)
6442 end
6443 end
6444 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6445 part.Anchored = true
6446 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6447 if slottag then
6448 for x, y in next, part:GetChildren() do
6449 if y:IsA("Texture") then
6450 y:Destroy()
6451 end
6452 end
6453 if root and root[slottag.Name] and root[slottag.Name].Name ~= "" then
6454 local t = Instance.new("Texture")
6455 t.Name = slottag.Name
6456 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6457 t.Transparency = part.Transparency >= 0.8 and 1 or root[slottag.Name].TextureProperties.Transparency
6458 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
6459 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
6460 t.OffsetStudsU = root[slottag.Name].TextureProperties.OffsetStudsU or 0
6461 t.OffsetStudsV = root[slottag.Name].TextureProperties.OffsetStudsV or 0
6462 if root[slottag.Name].TextureProperties.Color then
6463 local colordata = root[slottag.Name].TextureProperties.Color
6464 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6465 end
6466 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
6467 local tt = t:Clone()
6468 tt.Face = x
6469 tt.Parent = part
6470 end
6471 t:Destroy()
6472 if not root[slottag.Name].BrickProperties.DefaultColor then
6473 if part:IsA("UnionOperation") then
6474 part.UsePartColor = true
6475 end
6476 if root[slottag.Name].BrickProperties.Color then
6477 local colordata = root[slottag.Name].BrickProperties.Color
6478 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6479 else
6480 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
6481 end
6482 end
6483 if root[slottag.Name].BrickProperties.Material then
6484 part.Material = root[slottag.Name].BrickProperties.Material
6485 end
6486 if root[slottag.Name].BrickProperties.Reflectance then
6487 part.Reflectance = root[slottag.Name].BrickProperties.Reflectance
6488 end
6489 end
6490 end
6491 elseif part:IsA("Model") then
6492 texturemodel(part, attachdata, camodata, viewport)
6493 end
6494 end
6495 end
6496 local updategunmeshtype = function(wepmodel, attachdata, camodata)
6497 end
6498 local function updategunattachment(wepmodel, atttype, attachname, wepnodes, preview)
6499 local parts = wepmodel:GetChildren()
6500 local data = require(ffc(gunmodules, wepmodel.Name))
6501 local attachdata = data.attachments[atttype] and data.attachments[atttype][attachname] or {}
6502 local refmodel = attachdata.altmodel and ffc(attmodels, attachdata.altmodel) or ffc(attmodels, attachname)
6503 if not refmodel then
6504 return
6505 end
6506 local model = refmodel:Clone()
6507 local basepart = wfc(model, "Node")
6508 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
6509 local node
6510 model.Name = attachname
6511 if sidemount then
6512 local basenode = sidemount.Node
6513 local mountnode = attachdata.mountnode and wepnodes[attachdata.mountnode] or atttype == "Optics" and wepnodes.MountNode or atttype == "Underbarrel" and wepnodes.UnderMountNode
6514 local mountcframes = {}
6515 local mchildren = sidemount:GetChildren()
6516 local basecframe = basenode.CFrame
6517 for i = 1, #mchildren do
6518 if mchildren[i]:IsA("BasePart") then
6519 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
6520 end
6521 end
6522 basenode.CFrame = mountnode.CFrame
6523 for i = 1, #mchildren do
6524 if mchildren[i]:IsA("BasePart") then
6525 local v = mchildren[i]
6526 v.CFrame = mountnode.CFrame * mountcframes[i]
6527 end
6528 end
6529 node = attachdata.node and wepnodes[attachdata.node] or sidemount[atttype .. "Node"]
6530 sidemount.Parent = model
6531 else
6532 node = attachdata.node and wepnodes[attachdata.node] or wepnodes[atttype .. "Node"]
6533 end
6534 if attachdata.auxmodels then
6535 local auxmodels = {}
6536 for i, auxdata in next, attachdata.auxmodels, nil do
6537 local auxname = auxdata.Name or attachname .. " " .. auxdata.PostName
6538 local auxmodel = attmodels[auxname]:Clone()
6539 local auxnode = auxmodel.Node
6540 local auxmountnode
6541 auxmodels[auxname] = auxmodel
6542 if auxdata.sidemount and sidemount then
6543 auxmountnode = sidemount[auxdata.Node]
6544 elseif auxdata.auxmount and auxmodels[auxdata.auxmount] and ffc(auxmodels[auxdata.auxmount], auxdata.Node) then
6545 auxmountnode = auxmodels[auxdata.auxmount][auxdata.Node]
6546 else
6547 auxmountnode = wepnodes[auxdata.Node]
6548 end
6549 if auxdata.mainnode then
6550 node = auxmodel[auxdata.mainnode]
6551 end
6552 local auxcframes = {}
6553 local achildren = auxmodel:GetChildren()
6554 local basecframe = auxnode.CFrame
6555 for i = 1, #achildren do
6556 if achildren[i]:IsA("BasePart") then
6557 auxcframes[i] = tos(basecframe, achildren[i].CFrame)
6558 end
6559 end
6560 auxnode.CFrame = auxmountnode.CFrame
6561 for i = 1, #achildren do
6562 if achildren[i]:IsA("BasePart") then
6563 local v = achildren[i]
6564 v.CFrame = auxmountnode.CFrame * auxcframes[i]
6565 end
6566 end
6567 auxmodel.Parent = model
6568 end
6569 end
6570 local weldcframes = {}
6571 local children = model:GetChildren()
6572 local basecframe = basepart and basepart.CFrame
6573 local slottag
6574 if atttype == "Optics" or atttype == "Underbarrel" then
6575 slottag = hideparts(wepmodel, atttype, true)
6576 end
6577 for i = 1, #children do
6578 if children[i]:IsA("BasePart") then
6579 weldcframes[i] = tos(basecframe, children[i].CFrame)
6580 end
6581 end
6582 basepart.CFrame = node.CFrame
6583 for i = 1, #children do
6584 if children[i]:IsA("BasePart") then
6585 local v = children[i]
6586 v.CFrame = node.CFrame * weldcframes[i]
6587 if slottag and (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) then
6588 slottag:Clone().Parent = v
6589 end
6590 end
6591 end
6592 model.Parent = wepmodel
6593 end
6594 function getgunmodel(wep, attachdata, camodata)
6595 local findgun = ffc(gunmodels, wep)
6596 print("Finding weapon", wep)
6597 if findgun then
6598 local wepmodel = findgun:Clone()
6599 local nodes = wfc(wepmodel, "MenuNodes")
6600 nodes.Parent = wepmodel
6601 wepmodel.PrimaryPart = wfc(nodes, "MenuNode")
6602 for i, v in next, attachdata, nil do
6603 if v ~= "" then
6604 updategunattachment(wepmodel, i, v, nodes)
6605 end
6606 end
6607 texturemodel(wepmodel, attachdata, camodata, true)
6608 return wepmodel
6609 else
6610 error("Failed to find weapon model for", wep)
6611 end
6612 end
6613 end
6614 network:add("killed", function(killer, part, deathcf, weapon, weapondisplayname, rank, attachdata, camodata)
6615 char.deadcf = deathcf
6616 if killer == player then
6617 camera:setfixedcam(CFrame.new(deathcf.p, deathcf.p + deathcf.lookVector))
6618 else
6619 do
6620 local newbar = killbar:Clone()
6621 newbar.Killer.Label.Text = killer.Name
6622 newbar.Weapon.Label.Text = weapondisplayname
6623 newbar.Parent = maingui
6624 newbar.Rank.Label.Text = rank
6625 local gunmodel = getgunmodel(weapon, attachdata, camodata)
6626 local node = ffc(gunmodel.MenuNodes, "ViewportNode") or gunmodel.MenuNodes.MenuNode
6627 gunmodel.PrimaryPart = node
6628 gunmodel:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))
6629 local newcam = new("Camera")
6630 newcam.Parent = gunmodel
6631 local newcf = CFrame.new(node.CFrame.p + node.CFrame.RightVector * -7 + node.CFrame.lookVector * 4 + node.CFrame.upVector * 4, node.CFrame.p + node.CFrame.lookVector * 1.5)
6632 newcam.CFrame = newcf
6633 newcam.FieldOfView = 16
6634 gunmodel.Parent = newbar.WeaponViewport
6635 newbar.WeaponViewport.CurrentCamera = newcam
6636 local wepnote = misc.WepNote:Clone()
6637 wepnote.Parent = gunmodel
6638 for i, v in next, newbar.Attachments:GetChildren() do
6639 v.Type.Text = "None"
6640 end
6641 if attachdata then
6642 for i, v in next, attachdata, nil do
6643 if i ~= "Name" and v ~= "" then
6644 newbar.Attachments[i].Type.Text = v
6645 end
6646 end
6647 end
6648 camera:setspectate(killer, part)
6649 delay(5, function()
6650 gunmodel:Destroy()
6651 end)
6652 end
6653 end
6654 end)
6655 network:add("unlockedattach", unlockedattach)
6656 network:add("rankup", rankup)
6657 network:add("bigaward", function(type, victim, weapon, pt, extradata)
6658 bigaward(type, victim, weapon, pt, extradata)
6659 end)
6660 network:add("smallaward", function(type, pt)
6661 smallaward(type, pt)
6662 end)
6663 function notify.step()
6664 if char.health <= 0 then
6665 local bar = ffc(maingui, "KillBar")
6666 if bar then
6667 local enemy = ffc(game:GetService("Players"), bar.Killer.Label.Text)
6668 if enemy then
6669 local health = hud:getplayerhealth(enemy)
6670 bar.Health.Label.Text = ceil(health)
6671 bar.Health.Label.TextColor3 = health < 20 and color(1, 0, 0) or health < 50 and color(1, 1, 0) or color(0, 1, 0)
6672 end
6673 end
6674 end
6675 end
6676end
6677print("Loading leaderboard module")
6678do
6679 local wfc = game.WaitForChild
6680 local ffc = game.FindFirstChild
6681 local ud2 = UDim2.new
6682 local ceil = math.ceil
6683 local cf = CFrame.new
6684 local v3 = Vector3.new
6685 local color = Color3.new
6686 local dot = Vector3.new().Dot
6687 local workspace = workspace
6688 local ray = Ray.new
6689 local new = Instance.new
6690 local raycast = workspace.FindPartOnRayWithIgnoreList
6691 local infolder = function(l, e)
6692 for i = 1, #l do
6693 if l[i].Name == e then
6694 return l[i]
6695 end
6696 end
6697 end
6698 local rtype = game.IsA
6699 local debris = game.Debris
6700 local player = game:GetService("Players").LocalPlayer
6701 local playertag = game.ReplicatedStorage.Character.PlayerTag
6702 local pgui = player.PlayerGui
6703 local misc = input.consoleon and game.ReplicatedStorage.XBOX or game.ReplicatedStorage.Misc
6704 local playerstat = misc.Player
6705 local board = wfc(pgui, "Leaderboard")
6706 if input.consoleon then
6707 board:Destroy()
6708 board = misc.Leaderboard:Clone()
6709 board.Parent = pgui
6710 end
6711 local main = wfc(board, "Main")
6712 local global = wfc(board, "Global")
6713 local ghost = wfc(main, "Ghosts")
6714 local phantom = wfc(main, "Phantoms")
6715 local gdataframe = wfc(ghost, "DataFrame")
6716 local pdataframe = wfc(phantom, "DataFrame")
6717 local ghostdata = wfc(gdataframe, "Data")
6718 local phantomdata = wfc(pdataframe, "Data")
6719 local spacing = input.consoleon and 30 or 25
6720 local function organize()
6721 local pp = botwrapper.getbasehumanoids()
6722 for i = 1, #pp do
6723 local v = pp[i]
6724 local rightparent = v.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6725 local wrongparent = v.TeamColor ~= game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6726 local right = ffc(rightparent, v.Name)
6727 local wrong = ffc(wrongparent, v.Name)
6728 if not right and wrong then
6729 wrong.Parent = rightparent
6730 end
6731 end
6732 local gd = ghostdata:GetChildren()
6733 table.sort(gd, function(a, b)
6734 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
6735 end)
6736 for i = 1, #gd do
6737 local v = gd[i]
6738 v.Position = ud2(0, 0, 0, i * spacing)
6739 if v.Name == player.Name then
6740 v.Username.TextColor3 = color(1, 1, 0)
6741 end
6742 end
6743 ghostdata.Parent.CanvasSize = ud2(0, 0, 0, (#gd + 1) * spacing)
6744 local pd = phantomdata:GetChildren()
6745 table.sort(pd, function(a, b)
6746 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
6747 end)
6748 for i = 1, #pd do
6749 local v = pd[i]
6750 v.Position = ud2(0, 0, 0, i * spacing)
6751 if v.Name == player.Name then
6752 v.Username.TextColor3 = color(1, 1, 0)
6753 end
6754 end
6755 phantomdata.Parent.CanvasSize = ud2(0, 0, 0, (#pd + 1) * spacing)
6756 end
6757 local function addplayer(guy)
6758 local gbar = ffc(ghostdata, guy.Name)
6759 local pbar = ffc(phantomdata, guy.Name)
6760 if gbar or pbar then
6761 return
6762 end
6763 local bar = playerstat:Clone()
6764 bar.Name = guy.Name
6765 bar.Username.Text = guy.Name
6766 bar.Kills.Text = 0
6767 bar.Deaths.Text = 0
6768 bar.Streak.Text = 0
6769 bar.Score.Text = 0
6770 bar.Kdr.Text = 0
6771 bar.Rank.Text = 0
6772 if guy == player then
6773 bar.Username.TextColor3 = color(1, 1, 0)
6774 end
6775 bar.Parent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6776 organize()
6777 end
6778 local function removeplayer(guy)
6779 local gbar = ffc(ghostdata, guy.Name)
6780 local pbar = ffc(phantomdata, guy.Name)
6781 if gbar then
6782 trash.remove(gbar)
6783 end
6784 if pbar then
6785 trash.remove(pbar)
6786 end
6787 organize()
6788 end
6789 local function updatestats(guy, data)
6790 local rightparent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6791 local bar = ffc(rightparent, guy.Name)
6792 if not bar then
6793 organize()
6794 bar = ffc(rightparent, guy.Name)
6795 end
6796 if bar then
6797 for i, v in next, data, nil do
6798 bar[i].Text = v
6799 end
6800 end
6801 organize()
6802 end
6803 function leaderboard:show()
6804 main.Visible = true
6805 end
6806 function leaderboard:hide()
6807 main.Visible = false
6808 end
6809 network:add("removeplayer", removeplayer)
6810 network:add("newplayer", addplayer)
6811 network:add("newbot", function(bot)
6812 local bot = botwrapper.registerbot(bot)
6813 addplayer(bot)
6814 hud.addnametag(bot)
6815 hud.inializehealth(bot)
6816 end)
6817 network:add("botchanged", function(bot, name, value)
6818 if botwrapper.isbot(bot) then
6819 bot[name] = value
6820 end
6821 end)
6822 network:add("deregisterbot", function(bot)
6823 local bot = botwrapper.deregisterbot(bot)
6824 removeplayer(bot)
6825 hud.removenametag(bot)
6826 end)
6827 network:add("updatestats", updatestats)
6828 organize()
6829 game:GetService("UserInputService").InputBegan:connect(function(keycode)
6830 local key = keycode.KeyCode
6831 if key == Enum.KeyCode.Tab and not input.iskeydown(Enum.KeyCode.LeftAlt) then
6832 if main.Visible then
6833 leaderboard:hide()
6834 else
6835 organize()
6836 leaderboard:show()
6837 end
6838 end
6839 end)
6840end
6841print("Loading char module")
6842do
6843 local rtype = game.IsA
6844 local next = next
6845 local new = Instance.new
6846 local wfc = game.WaitForChild
6847 local ffc = game.FindFirstChild
6848 local getchildren = game.GetChildren
6849 local workspace = game.Workspace
6850 local cf = CFrame.new
6851 local vtws = CFrame.new().vectorToWorldSpace
6852 local angles = CFrame.Angles
6853 local nc = cf()
6854 local v3 = Vector3.new
6855 local nv = v3()
6856 local ray = Ray.new
6857 local raycast = workspace.FindPartOnRayWithIgnoreList
6858 local raycastwl = workspace.FindPartOnRayWithWhitelist
6859 local debris = game.Debris
6860 local dot = nv.Dot
6861 local ud2 = UDim2.new
6862 local abs = math.abs
6863 local tos = cf().toObjectSpace
6864 local player = game:GetService("Players").LocalPlayer
6865 local pgui = player.PlayerGui
6866 local repstore = game.ReplicatedStorage
6867 local attmodels = repstore.AttachmentModels
6868 local character, humanoid, rootpart, rootjoint
6869 local thread = sequencer.new()
6870 local weapon
6871 local aiming = false
6872 local auto = false
6873 local burst = 0
6874 local reloading = false
6875 local sprinting = false
6876 local animating = false
6877 local stability = 0
6878 local basewalkspeed = 14
6879 local sprintspring = physics.spring.new()
6880 local climbing = physics.spring.new()
6881 local curgunid = 0
6882 local aimspring = physics.spring.new()
6883 local zoommodspring = physics.spring.new(1)
6884 zoommodspring.s = 12
6885 zoommodspring.d = 0.95
6886 local loadedgundata = {}
6887 char.unaimedfov = 80
6888 function char.setunaimedfov(value)
6889 char.unaimedfov = value
6890 end
6891 function char.addgun(gundata)
6892 for i = 1, curgunid do
6893 if loadedgundata[i] == gundata then
6894 warn("Error, tried to add gun twice")
6895 return
6896 end
6897 end
6898 curgunid = curgunid + 1
6899 loadedgundata[curgunid] = gundata
6900 gundata.id = curgunid
6901 return curgunid
6902 end
6903 function char.removegun(gundata)
6904 local found
6905 for i = 1, curgunid do
6906 if loadedgundata[i] == gundata then
6907 found = true
6908 break
6909 end
6910 end
6911 if not found then
6912 warn("Error, tried to remove gun twice")
6913 return
6914 end
6915 local gunid = gundata.id
6916 gundata.id = nil
6917 loadedgundata[gunid] = loadedgundata[curgunid]
6918 loadedgundata[curgunid] = nil
6919 curgunid = curgunid - 1
6920 local replacement = loadedgundata[gunid]
6921 if replacement then
6922 replacement.id = gunid
6923 end
6924 end
6925 function char.unloadguns()
6926 curgunid = 0
6927 loadedgundata = {}
6928 end
6929 local swingspring = physics.spring.new(nv)
6930 local speedspring = physics.spring.new()
6931 local velocityspring = physics.spring.new(nv)
6932 local pronespring = physics.spring.new(0)
6933 local truespeedspring = physics.spring.new(0)
6934 local equipspring = physics.spring.new(1)
6935 local muzzlespring = physics.spring.new(0)
6936 local walkspeedmult = 1
6937 sprintspring.s = 12
6938 sprintspring.d = 0.9
6939 climbing.s = 12
6940 climbing.d = 0.9
6941 aimspring.d = 0.9
6942 swingspring.s = 10
6943 swingspring.d = 0.75
6944 speedspring.s = 16
6945 velocityspring.s = 16
6946 pronespring.s = 8
6947 truespeedspring.s = 8
6948 equipspring.s = 12
6949 equipspring.d = 0.75
6950 local ignore = {
6951 workspace.Ignore,
6952 game.Workspace.CurrentCamera
6953 }
6954 local backwardsmult = 0.8
6955 local bodyforce = new("BodyVelocity")
6956 bodyforce.Name = "\n"
6957 local muzzlelight, walkspeedspring, headheightspring, updatewalkspeed
6958 walkspeedspring = physics.spring.new(basewalkspeed)
6959 walkspeedspring.s = 8
6960 headheightspring = physics.spring.new(1.5)
6961 headheightspring.s = 8
6962 char.acceleration = nv
6963 bodyforce.MaxForce = nv
6964 local jumpallowed
6965 do
6966 local movementmode = "stand"
6967 local down = v3(0, -5, 0)
6968 function updatewalkspeed()
6969 if sprinting then
6970 walkspeedspring.t = 1.4 * walkspeedmult * basewalkspeed
6971 elseif movementmode == "prone" then
6972 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6973 elseif movementmode == "crouch" then
6974 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6975 elseif movementmode == "stand" then
6976 walkspeedspring.t = walkspeedmult * basewalkspeed
6977 end
6978 end
6979 local function setmovementmode(self, mode, dive)
6980 local oldmode = char.movementmode
6981 char.movementmode = mode
6982 movementmode = mode
6983 if mode == "prone" then
6984 if not dive and oldmode ~= mode then
6985 sound.play("stanceProne", 0.15)
6986 end
6987 headheightspring.t = -1.5
6988 pronespring.t = 1
6989 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6990 hud:setcrossscale(0.5)
6991 stability = 0.25
6992 if dive and sprinting and rootpart.Velocity.y > -5 then
6993 spawn(function()
6994 local lkvector = rootpart.CFrame.lookVector
6995 rootpart.Velocity = lkvector * (50 * loltimescale) + v3(0, 40 * loltimescale, 0)
6996 wait(0.1 / loltimescale)
6997 rootpart.Velocity = lkvector * (60 * loltimescale) + v3(0, 30 * loltimescale, 0)
6998 wait(0.4 / loltimescale)
6999 rootpart.Velocity = lkvector * (20 * loltimescale) + v3(0, -10 * loltimescale, 0)
7000 end)
7001 end
7002 elseif mode == "crouch" then
7003 if not dive and oldmode ~= mode then
7004 sound.play("stanceStandCrouch", 0.15)
7005 end
7006 headheightspring.t = 0
7007 pronespring.t = 0
7008 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
7009 hud:setcrossscale(0.75)
7010 stability = 0.15
7011 if dive and sprinting and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
7012 isSliding = true
7013 sound.play("slideStart", 0.25)
7014 spawn(function()
7015 local lkvector = rootpart.CFrame.lookVector
7016 local released
7017 bodyforce.MaxForce = v3(40000, 10, 40000)
7018 for i = 1, 20 do
7019 if input.keyboard.down.leftshift then
7020 lkvector = rootpart.CFrame.lookVector
7021 end
7022 bodyforce.Velocity = lkvector * (40 * loltimescale - i * 1.5 * loltimescale) + v3(0, 0, 0)
7023 wait(0.03333333333333333 / loltimescale)
7024 end
7025 bodyforce.MaxForce = nv
7026 bodyforce.Velocity = nv
7027 if isSliding then
7028 isSliding = false
7029 sound.play("slideEnd", 0.15)
7030 end
7031 end)
7032 end
7033 elseif mode == "stand" then
7034 if oldmode ~= mode then
7035 sound.play("stanceStandCrouch", 0.15)
7036 end
7037 headheightspring.t = 1.5
7038 pronespring.t = 0
7039 walkspeedspring.t = walkspeedmult * basewalkspeed
7040 hud:setcrossscale(1)
7041 stability = 0
7042 end
7043 network:send("s" .. "t" .. "a" .. "n" .. "c" .. "e", mode)
7044 sprinting = false
7045 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
7046 sprintspring.t = 0
7047 end
7048 function char.getstate()
7049 return humanoid:GetState()
7050 end
7051 function char:sprinting()
7052 return sprinting
7053 end
7054 char.setmovementmode = setmovementmode
7055 function char:setbasewalkspeed(newspeed)
7056 basewalkspeed = newspeed
7057 updatewalkspeed()
7058 end
7059 function char:setsprint(on)
7060 if on then
7061 if isSliding then
7062 isSliding = false
7063 sound.play("slideEnd", 0.15)
7064 end
7065 setmovementmode(nil, "stand")
7066 sprinting = true
7067 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
7068 auto = false
7069 burst = 0
7070 if weapon and aiming and weapon.type ~= "KNIFE" then
7071 print("un aim herE")
7072 weapon:setaim(false)
7073 end
7074 walkspeedmult = 1
7075 if not reloading and not animating then
7076 sprintspring.t = 1
7077 end
7078 walkspeedspring.t = 1.5 * walkspeedmult * basewalkspeed
7079 elseif sprinting then
7080 sprinting = false
7081 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
7082 sprintspring.t = 0
7083 walkspeedspring.t = walkspeedmult * basewalkspeed
7084 if input.mouse.down.right and weapon and weapon.type ~= "KNIFE" then
7085 weapon:setaim(true)
7086 end
7087 end
7088 end
7089 local function parkour()
7090 if weapon and not reloading and not char.grenadehold then
7091 weapon:playanimation("parkour")
7092 end
7093 sound.play("parkour", 0.25)
7094 bodyforce.MaxForce = nv
7095 local bp = new("BodyPosition")
7096 bp.Name = "\n"
7097 bp.position = rootpart.Position + rootpart.CFrame.lookVector.unit * (char.speed * loltimescale) * 1.5 + v3(0, 10, 0)
7098 bp.maxForce = v3(5000000, 500000, 500000)
7099 bp.P = 4000
7100 bp.Parent = rootpart
7101 debris:AddItem(bp, 0.45)
7102 end
7103 function char:jump(height)
7104 local rootcf = rootpart.CFrame
7105 local isonground = raycast(workspace, ray(rootcf.p, vtws(rootcf, down)), {
7106 workspace.CurrentCamera
7107 })
7108 local v = rootpart.Velocity.y
7109 local j = height and (2 * game.Workspace.Gravity * height) ^ 0.5 or 40
7110 local jumppower
7111 if v < 0 then
7112 jumppower = j
7113 else
7114 jumppower = (v * v + j * j) ^ 0.5
7115 end
7116 if isonground then
7117 if movementmode == "prone" or movementmode == "crouch" then
7118 setmovementmode(nil, "stand")
7119 elseif not aiming then
7120 local r1 = ray(rootpart.CFrame.p + v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 + v3(0, 2, 0))
7121 local h1, e1 = raycast(workspace, r1, {
7122 character,
7123 camera.currentcamera
7124 })
7125 local r2 = ray(rootpart.CFrame.p - v3(0, 1, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1, 0))
7126 local h2, e2 = raycast(workspace, r2, {
7127 character,
7128 camera.currentcamera
7129 })
7130 local r3 = ray(rootpart.CFrame.p - v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1.5, 0))
7131 local h3, e3 = raycast(workspace, r3, {
7132 character,
7133 camera.currentcamera
7134 })
7135 if h3 and h1 ~= h3 and (e3 - e2).Magnitude < 0.7 and (e3 - e1).Magnitude > 4 and (e3 - rootpart.Position).Magnitude < char.speed / 1.5 and not h3:IsA("TrussPart") then
7136 parkour()
7137 delay(0.1, function()
7138 end)
7139 else
7140 humanoid.JumpPower = jumppower
7141 jumpallowed = true
7142 humanoid.Jump = true
7143 jumpallowed = false
7144 end
7145 else
7146 humanoid.JumpPower = jumppower
7147 jumpallowed = true
7148 humanoid.Jump = true
7149 jumpallowed = false
7150 end
7151 end
7152 end
7153 end
7154 local equipping = false
7155 local rweld, lweld, larm, rarm, lmodel, rmodel, lmain, rmain
7156 local sin = math.sin
7157 local cos = math.cos
7158 char.grenadehold = false
7159 local function gunbob(a, r)
7160 local a, r = a or 1, r or 1
7161 local d, s, v = char.distance * 6.28318 * 3 / 4, char.speed, -char.velocity
7162 if s < basewalkspeed then
7163 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
7164 return cf(r * cos(d / 8 - 1) * s / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
7165 else
7166 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)
7167 return cf(r * cos(d / 8 - 1) * (5 * s - 56) / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
7168 end
7169 end
7170 local function gunsway(a)
7171 local d, s = tick() * 6, 2 * (1.1 - a)
7172 return cf(cos(d / 8) * s / 128, -sin(d / 4) * s / 128, sin(d / 16) * s / 64)
7173 end
7174 function weldattachment(gun, type, attname, menunode, mainpart, attdata, gunattdata, welddata, menunodes)
7175 local refmodel = attdata.altmodel and ffc(attmodels, attdata.altmodel) or ffc(attmodels, attname)
7176 local copies = attdata.copy or 0
7177 local slottag
7178 if refmodel then
7179 for i = 0, copies do
7180 local model = refmodel:Clone()
7181 local attnode = model.Node
7182 local weldcframes = {}
7183 local maincf = attnode.CFrame
7184 local parts = getchildren(model)
7185 for i = 1, #parts do
7186 local v = parts[i]
7187 if v:IsA("BasePart") then
7188 weldcframes[v] = tos(maincf, v.CFrame)
7189 end
7190 end
7191 attnode.CFrame = i == 0 and menunode.CFrame or menunodes[attdata.copynodes[i]].CFrame
7192 if type == "Optics" then
7193 local del = gun:GetChildren()
7194 for i = 1, #del do
7195 if del[i].Name == "Iron" or del[i].Name == "IronGlow" or del[i].Name == "SightMark" and not ffc(del[i], "Stay") then
7196 del[i]:Destroy()
7197 end
7198 end
7199 elseif type == "Underbarrel" then
7200 local del = gun:GetChildren()
7201 for i = 1, #del do
7202 if del[i].Name == "Grip" then
7203 slottag = ffc(del[i], "Slot1") or ffc(del[i], "Slot2")
7204 del[i]:Destroy()
7205 end
7206 end
7207 end
7208 if attdata.replacemag then
7209 local del = gun:GetChildren()
7210 for x = 1, #del do
7211 if i == 0 and del[x].Name == "Mag" or i > 0 and del[x].Name == "Mag" .. i + 1 then
7212 del[x]:Destroy()
7213 end
7214 end
7215 end
7216 if attdata.replacepart then
7217 local del = gun:GetChildren()
7218 for x = 1, #del do
7219 if del[x].Name == attdata.replacepart then
7220 del[x]:Destroy()
7221 end
7222 end
7223 end
7224 if gunattdata and gunattdata[attname] and gunattdata[attname].settings then
7225 for prop, v in next, gunattdata[attname].settings, nil do
7226 if prop == "sightcolor" then
7227 local sightmark = ffc(model, "SightMark")
7228 if sightmark and ffc(sightmark, "SurfaceGui") then
7229 local retgui = sightmark.SurfaceGui
7230 if ffc(retgui, "Border") and ffc(retgui.Border, "Scope") then
7231 local retimg = retgui.Border.Scope
7232 retimg.ImageColor3 = Color3.new(v.r / 255, v.g / 255, v.b / 255)
7233 end
7234 end
7235 end
7236 end
7237 end
7238 for x = 1, #parts do
7239 local v = parts[x]
7240 if v:IsA("BasePart") then
7241 local weld, c0
7242 if v ~= attnode then
7243 c0 = tos(mainpart.CFrame, attnode.CFrame)
7244 weld = new("Weld", mainpart)
7245 weld.Part0 = mainpart
7246 weld.Part1 = v
7247 weld.C0 = c0 * weldcframes[v]
7248 v.CFrame = mainpart.CFrame * weld.C0
7249 end
7250 if slottag and v:IsA("UnionOperation") then
7251 slottag:Clone().Parent = v
7252 end
7253 if attdata.replacemag and v.Name == "AttMag" then
7254 local magname = i == 0 and "Mag" or i > 0 and "Mag" .. i + 1
7255 v.Name = magname
7256 welddata[magname] = {
7257 part = v,
7258 weld = weld,
7259 basec0 = c0 * weldcframes[v],
7260 basetransparency = v.Transparency
7261 }
7262 end
7263 if attdata.replacepart and v.Name == "Part" then
7264 local pname = attdata.replacepart
7265 v.Name = pname
7266 welddata[pname] = {
7267 part = v,
7268 weld = weld,
7269 basec0 = c0 * weldcframes[v],
7270 basetransparency = v.Transparency
7271 }
7272 end
7273 v.Anchored = false
7274 v.CanCollide = false
7275 v.Parent = gun
7276 end
7277 end
7278 attnode:Destroy()
7279 model:Destroy()
7280 end
7281 end
7282 return slottag
7283 end
7284 local function texturemodel(root, model)
7285 local bcolor = BrickColor.new
7286 for i, part in next, model:GetChildren() do
7287 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
7288 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
7289 if slottag and slottag.Name then
7290 for x, y in next, part:GetChildren() do
7291 if y:IsA("Texture") then
7292 y:Destroy()
7293 end
7294 end
7295 if root[slottag.Name] and root[slottag.Name].Name ~= "" then
7296 if not effects.disable1pcamoskins then
7297 local t = Instance.new("Texture")
7298 t.Name = slottag.Name
7299 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
7300 t.Transparency = part.Transparency == 1 and 1 or root[slottag.Name].TextureProperties.Transparency
7301 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
7302 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
7303 t.OffsetStudsU = root[slottag.Name].TextureProperties.OffsetStudsU or 0
7304 t.OffsetStudsV = root[slottag.Name].TextureProperties.OffsetStudsV or 0
7305 if root[slottag.Name].TextureProperties.Color then
7306 local colordata = root[slottag.Name].TextureProperties.Color
7307 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
7308 end
7309 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
7310 local tt = t:Clone()
7311 tt.Face = x
7312 tt.Parent = part
7313 end
7314 t:Destroy()
7315 end
7316 if not root[slottag.Name].BrickProperties.DefaultColor then
7317 if part:IsA("UnionOperation") then
7318 part.UsePartColor = true
7319 end
7320 local colordata = root[slottag.Name].BrickProperties.Color
7321 if colordata then
7322 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
7323 else
7324 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
7325 end
7326 end
7327 if root[slottag.Name].BrickProperties.Material then
7328 part.Material = root[slottag.Name].BrickProperties.Material
7329 end
7330 if root[slottag.Name].BrickProperties.Reflectance then
7331 part.Reflectance = root[slottag.Name].BrickProperties.Reflectance
7332 end
7333 end
7334 end
7335 elseif part:IsA("Model") then
7336 texturemodel(root, part)
7337 end
7338 end
7339 end
7340 local tos = CFrame.new().toObjectSpace
7341 local function weldmodel(model, mainpart, attachlist, data, camodata, gunattdata, attachonly)
7342 local welddata = {}
7343 local parts = model:GetChildren()
7344 local maincf = mainpart.CFrame
7345 local menunodes = ffc(model, "MenuNodes")
7346 if not attachonly then
7347 for i = 1, #parts do
7348 local part = parts[i]
7349 if part ~= mainpart and part:IsA("BasePart") then
7350 local name = part.Name
7351 if data and data.removeparts and data.removeparts[name] then
7352 part:Destroy()
7353 else
7354 if data and data.transparencymod and data.transparencymod[name] then
7355 part.Transparency = data.transparencymod[name]
7356 end
7357 if data and data.weldexception and data.weldexception[name] and ffc(model, data.weldexception[name]) then
7358 local nbase = model[data.weldexception[name]]
7359 local nmaincf = nbase.CFrame
7360 local c0 = tos(nmaincf, part.CFrame)
7361 local weld = new("Weld", mainpart)
7362 weld.Part0 = nbase
7363 weld.Part1 = part
7364 weld.C0 = c0
7365 part.CFrame = maincf * c0
7366 welddata[name] = {
7367 part = part,
7368 weld = weld,
7369 basec0 = c0,
7370 basetransparency = part.Transparency
7371 }
7372 else
7373 local c0 = tos(maincf, part.CFrame)
7374 local weld = new("Weld", mainpart)
7375 weld.Part0 = mainpart
7376 weld.Part1 = part
7377 weld.C0 = c0
7378 part.CFrame = maincf * c0
7379 welddata[name] = {
7380 part = part,
7381 weld = weld,
7382 basec0 = c0,
7383 basetransparency = part.Transparency
7384 }
7385 end
7386 part.Anchored = false
7387 part.CanCollide = false
7388 end
7389 end
7390 end
7391 end
7392 if menunodes and attachlist then
7393 local nodes = menunodes:GetChildren()
7394 for i = 1, #nodes do
7395 local v = nodes[i]
7396 local c0 = tos(maincf, v.CFrame)
7397 local weld = new("Weld", mainpart)
7398 weld.Part0 = mainpart
7399 weld.Part1 = v
7400 weld.C0 = c0
7401 v.Anchored = false
7402 v.CanCollide = false
7403 end
7404 for i, v in next, attachlist, nil do
7405 if i ~= "Name" and v and v ~= "" then
7406 local attachdata = data.attachments and data.attachments[i][v] or {}
7407 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
7408 local mountweldpart = attachdata.mountweldpart and model[attachdata.mountweldpart] or mainpart
7409 local node = attachdata.node and menunodes[attachdata.node]
7410 local sidemountparts = {}
7411 if sidemount then
7412 local basenode = sidemount.Node
7413 local mountnode = attachdata.mountnode and menunodes[attachdata.mountnode] or i == "Optics" and menunodes.MountNode or i == "Underbarrel" and menunodes.UnderMountNode
7414 local mountcframes = {}
7415 local mchildren = sidemount:GetChildren()
7416 local basecframe = basenode.CFrame
7417 for i = 1, #mchildren do
7418 if mchildren[i]:IsA("BasePart") then
7419 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
7420 end
7421 end
7422 basenode.CFrame = mountnode.CFrame
7423 for x = 1, #mchildren do
7424 local p = mchildren[x]
7425 if p:IsA("BasePart") then
7426 local c0 = tos(mountweldpart.CFrame, basenode.CFrame)
7427 if p ~= basenode then
7428 local weld = new("Weld", mainpart)
7429 weld.Part0 = mountweldpart
7430 weld.Part1 = p
7431 weld.C0 = c0 * mountcframes[x]
7432 p.CFrame = basenode.CFrame * mountcframes[x]
7433 end
7434 p.Anchored = false
7435 p.CanCollide = false
7436 p.Parent = model
7437 sidemountparts[p.Name] = p
7438 if p.Name == i .. "Node" and not node then
7439 node = p
7440 elseif p.Name == "SightMark" then
7441 local stay = new("Model", p)
7442 stay.Name = "Stay"
7443 end
7444 end
7445 end
7446 basenode.Parent = menunodes
7447 sidemount:Destroy()
7448 else
7449 node = attachdata.node and menunodes[attachdata.node] or menunodes[i .. "Node"]
7450 end
7451 if attachdata.auxmodels then
7452 local auxmodels = {}
7453 for i, auxdata in next, attachdata.auxmodels, nil do
7454 local auxname = auxdata.Name or v .. " " .. auxdata.PostName
7455 local auxmodel = attmodels[auxname]:Clone()
7456 local auxnode = auxmodel.Node
7457 local auxmountnode
7458 auxmodels[auxname] = {}
7459 if auxdata.sidemount and sidemountparts[auxdata.Node] then
7460 auxmountnode = sidemountparts[auxdata.Node]
7461 elseif auxdata.auxmount and auxmodels[auxdata.auxmount] and auxmodels[auxdata.auxmount][auxdata.Node] then
7462 auxmountnode = auxmodels[auxdata.auxmount][auxdata.Node]
7463 else
7464 auxmountnode = menunodes[auxdata.Node]
7465 end
7466 if auxdata.mainnode then
7467 node = auxmodel[auxdata.mainnode]
7468 end
7469 local auxcframes = {}
7470 local achildren = auxmodel:GetChildren()
7471 local basecframe = auxnode.CFrame
7472 for i = 1, #achildren do
7473 if achildren[i]:IsA("BasePart") then
7474 auxcframes[i] = tos(basecframe, achildren[i].CFrame)
7475 end
7476 end
7477 auxnode.CFrame = auxmountnode.CFrame
7478 for x = 1, #achildren do
7479 local p = achildren[x]
7480 if p:IsA("BasePart") then
7481 local c0 = tos(mountweldpart.CFrame, auxnode.CFrame)
7482 if p ~= auxnode then
7483 local weld = new("Weld", mainpart)
7484 weld.Part0 = mountweldpart
7485 weld.Part1 = p
7486 weld.C0 = c0 * auxcframes[x]
7487 p.CFrame = auxnode.CFrame * auxcframes[x]
7488 end
7489 p.Anchored = false
7490 p.CanCollide = false
7491 p.Parent = model
7492 auxmodels[auxname][p.Name] = p
7493 if p.Name == i .. "Node" and not node then
7494 node = p
7495 elseif p.Name == "SightMark" then
7496 local stay = new("Model", p)
7497 stay.Name = "Stay"
7498 end
7499 end
7500 end
7501 auxmodel:Destroy()
7502 end
7503 end
7504 local weldpart = attachdata.weldpart and model[attachdata.weldpart] or mainpart
7505 weldattachment(model, i, v, node, weldpart, attachdata, gunattdata, welddata, menunodes)
7506 end
7507 end
7508 menunodes:Destroy()
7509 end
7510 if not attachonly then
7511 texturemodel(camodata, model)
7512 welddata.camodata = camodata
7513 mainpart.Anchored = false
7514 mainpart.CanCollide = false
7515 end
7516 return welddata
7517 end
7518 local clone = game.Clone
7519 local currentcamera = game.Workspace.CurrentCamera
7520 local ffc = game.FindFirstChild
7521 function char:loadarms(newlarm, newrarm, newlmain, newrmain)
7522 currentcamera = game.Workspace.CurrentCamera
7523 if larm and rarm then
7524 larm:Destroy()
7525 rarm:Destroy()
7526 end
7527 larm, rarm, lmain, rmain = newlarm, newrarm, newlmain, newrmain
7528 lmodel = clone(larm, weapon and currentcamera)
7529 rmodel = clone(rarm, weapon and currentcamera)
7530 local lmainpart = lmodel[newlmain]
7531 local rmainpart = rmodel[newrmain]
7532 rweld = new("Motor6D")
7533 lweld = new("Motor6D")
7534 weldmodel(lmodel, lmainpart)
7535 weldmodel(rmodel, rmainpart)
7536 lweld.Part0 = rootpart
7537 lweld.Part1 = lmainpart
7538 lweld.Parent = lmainpart
7539 rweld.Part0 = rootpart
7540 rweld.Part1 = rmainpart
7541 rweld.Parent = rmainpart
7542 end
7543 function char:reloadsprings()
7544 sprintspring = physics.spring.new()
7545 aimspring = physics.spring.new()
7546 swingspring = physics.spring.new(nv)
7547 speedspring = physics.spring.new()
7548 velocityspring = physics.spring.new(nv)
7549 pronespring = physics.spring.new(0)
7550 truespeedspring = physics.spring.new(0)
7551 equipspring = physics.spring.new(1)
7552 muzzlespring = physics.spring.new(0)
7553 equipspring.s = 12
7554 equipspring.d = 0.75
7555 sprintspring.s = 12
7556 sprintspring.d = 0.9
7557 aimspring.d = 0.9
7558 swingspring.s = 10
7559 swingspring.d = 0.75
7560 speedspring.s = 16
7561 velocityspring.s = 16
7562 pronespring.s = 8
7563 truespeedspring.s = 8
7564 muzzlespring.s = 50
7565 muzzlespring.d = 1
7566 walkspeedspring = physics.spring.new(basewalkspeed)
7567 walkspeedspring.s = 8
7568 headheightspring = physics.spring.new(1.5)
7569 headheightspring.s = 8
7570 if muzzlelight then
7571 muzzlelight:Destroy()
7572 end
7573 muzzlelight = repstore.Effects.MuzzleLight:Clone()
7574 muzzlelight.Parent = rootpart
7575 end
7576 aimbotshit = {}
7577 do
7578 local rand = math.random
7579 local ffc = game.FindFirstChild
7580 local function pickv3(v0, v1)
7581 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
7582 end
7583 function char:firemuzzlelight()
7584 muzzlespring:accelerate(100)
7585 end
7586 function char:loadgrenade(data, model, spare)
7587 local self = {}
7588 local thread2 = sequencer.new()
7589 local ignorelist = {character}
7590 for i = 1, #ignore do
7591 local obj = ignore[i]
7592 ignorelist[#ignorelist + 1] = obj
7593 end
7594 local dunhit = {}
7595 local main = data.mainpart
7596 local mainoffset = data.mainoffset
7597 local mainpart = model[main]
7598 local pin = model[data.pin]
7599 local lever = model[data.lever]
7600 local ammo = spare or data.spare
7601 local lastweapon = weapon
7602 local equipped = false
7603 local throwing = false
7604 local cooking = false
7605 local exploded = false
7606 local bounceelasticity = 0.2
7607 local frictionconstant = 0.08
7608 local acceleration = v3(0, -80, 0)
7609 local velocity = v3()
7610 local position = v3()
7611 local cooktime = 0
7612 local blowup = 0
7613 local t0 = 0
7614 local lastbounce = false
7615 local lasttrailt = 0
7616 local lasttrailpos = v3()
7617 local rot0
7618 local offset = v3()
7619 local av0, flyingnade, indicator
7620 local fusetime = data.fusetime
7621 local blastradius = data.blastradius
7622 local throwspeed = data.throwspeed
7623 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7624 local animdata = weldmodel(model, mainpart)
7625 local mainweld = new("Motor6D", mainpart)
7626 animdata[main] = {
7627 weld = {C0 = nc},
7628 basec0 = nc
7629 }
7630 animdata.larm = {
7631 weld = {
7632 C0 = data.larmoffset
7633 },
7634 basec0 = data.larmoffset
7635 }
7636 animdata.rarm = {
7637 weld = {
7638 C0 = data.rarmoffset
7639 },
7640 basec0 = data.rarmoffset
7641 }
7642 mainweld.Part0 = rootpart
7643 mainweld.Part1 = mainpart
7644 local equipcf = data.equipoffset
7645 local sprintcf = cframe.interpolator(data.sprintoffset)
7646 local pronecf = cframe.interpolator(data.proneoffset)
7647 self.type = data.type
7648 self.cooking = cooking
7649 function self:setequipped(on)
7650 if on and (not equipped or not equipping) then
7651 if char.health <= 0 then
7652 return
7653 end
7654 char.grenadehold = true
7655 hud:setcrosssettings(data.type, data.crosssize, data.crossspeed, data.crossdamper, main)
7656 hud:updatefiremode("KNIFE")
7657 hud:updateammo("GRENADE")
7658 equipping = true
7659 thread:clear()
7660 if weapon then
7661 lastweapon = weapon
7662 weapon:setequipped(false)
7663 end
7664 thread:add(function()
7665 char:setbasewalkspeed(data.walkspeed)
7666 equipspring.t = 0
7667 equipping = false
7668 equipped = true
7669 local shit = mainpart:GetChildren()
7670 for i = 1, #shit do
7671 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
7672 shit[i]:Destroy()
7673 end
7674 end
7675 lmodel.Parent = currentcamera
7676 rmodel.Parent = currentcamera
7677 model.Parent = currentcamera
7678 weapon = self
7679 end)
7680 elseif not on and equipped then
7681 equipspring.t = 1
7682 thread:clear()
7683 thread:add(function()
7684 equipped = false
7685 lmodel.Parent = nil
7686 rmodel.Parent = nil
7687 model.Parent = nil
7688 animating = false
7689 weapon = nil
7690 end)
7691 thread:delay(0.5)
7692 end
7693 end
7694 local grenadeanim
7695 local castresolution = 0.016666666666666666
7696 local function createnade(deaddrop)
7697 if not deaddrop and roundsystem.lock then
7698 return
7699 end
7700 if not mainpart.Parent or gamelogic.gammo <= 0 then
7701 return
7702 end
7703 gamelogic.gammo = gamelogic.gammo - 1
7704 hud:updateammo("GRENADE")
7705 local time = tick()
7706 trash.remove(mainweld)
7707 flyingnade = mainpart
7708 flyingnade.Parent = workspace.Ignore
7709 flyingnade.Anchored = true
7710 indicator = ffc(flyingnade, "Indicator")
7711 if indicator then
7712 indicator.Friendly.Visible = true
7713 end
7714 flyingnade.Trail.Enabled = true
7715 model.Parent = nil
7716 local aimcf = camera.cframe * angles(math.rad(data.throwangle or 0), 0, 0)
7717 velocity = 0 < char.health and aimcf.lookVector * throwspeed + rootpart.Velocity or Vector3.new(math.random(-3, 5), math.random(0, 2), math.random(-3, 5))
7718 position = char.deadcf and char.deadcf.p or flyingnade.CFrame.p
7719 lasttrailt = time
7720 lasttrailpos = position
7721 t0 = time
7722 av0 = (camera.cframe - camera.cframe.p) * v3(19.539, -5, 0)
7723 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
7724 local dt = castresolution
7725 local nadecf = flyingnade.CFrame
7726 grenadeanim = {
7727 curi = 1,
7728 time = time,
7729 blowuptime = blowup - time,
7730 frames = {
7731 {
7732 t0 = 0,
7733 p0 = position,
7734 v0 = velocity,
7735 offset = nv,
7736 a = acceleration,
7737 rot0 = nadecf - nadecf.p,
7738 rotv = av0,
7739 glassbreaks = {}
7740 }
7741 }
7742 }
7743 for i = 1, (blowup - time) / dt + 1 do
7744 local newposition = position + dt * velocity + dt * dt / 2 * acceleration
7745 local newvelocity = velocity + dt * acceleration
7746 local hit, pos, norm = raycast(workspace, ray(position, newposition - position - 0.05 * offset), ignorelist)
7747 local t = dt * i
7748 if hit and hit.Name ~= "Window" and hit.Name ~= "Col" then
7749 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
7750 offset = 0.2 * norm
7751 av0 = norm:Cross(velocity) / 0.2
7752 local delta = pos - position
7753 local fixpls = 1 - 0.001 / delta.magnitude
7754 fixpls = fixpls < 0 and 0 or fixpls
7755 position = position + fixpls * delta + 0.05 * norm
7756 local normvel = dot(norm, velocity) * norm
7757 local tanvel = velocity - normvel
7758 local geometricdeceleration
7759 local d1 = -dot(norm, acceleration)
7760 local d2 = -(1 + bounceelasticity) * dot(norm, velocity)
7761 geometricdeceleration = 1 - frictionconstant * (10 * (d1 < 0 and 0 or d1) * dt + (d2 < 0 and 0 or d2)) / tanvel.magnitude
7762 geometricdeceleration = geometricdeceleration < 0 and 0 or geometricdeceleration
7763 velocity = geometricdeceleration * tanvel - bounceelasticity * normvel
7764 if 1 > velocity.magnitude then
7765 local frames = grenadeanim.frames
7766 frames[#frames + 1] = {
7767 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
7768 p0 = position,
7769 v0 = nv,
7770 a = nv,
7771 rot0 = cframe.fromaxisangle(t * av0) * rot0,
7772 offset = 0.2 * norm,
7773 rotv = nv,
7774 glassbreaks = {}
7775 }
7776 break
7777 end
7778 local frames = grenadeanim.frames
7779 local nexti = #frames + 1
7780 frames[#frames + 1] = {
7781 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
7782 p0 = position,
7783 v0 = velocity,
7784 a = lastbounce and nv or acceleration,
7785 rot0 = cframe.fromaxisangle(t * av0) * rot0,
7786 offset = 0.2 * norm,
7787 rotv = av0,
7788 glassbreaks = {}
7789 }
7790 lastbounce = true
7791 else
7792 position = newposition
7793 velocity = newvelocity
7794 lastbounce = false
7795 if hit and hit.Name == "Window" then
7796 local frames = grenadeanim.frames
7797 local glassbreaks = frames[#frames].glassbreaks
7798 glassbreaks[#glassbreaks + 1] = {t = t, part = hit}
7799 end
7800 end
7801 end
7802 network:send("n" .. "e" .. "w" .. "g" .. "r" .. "e" .. "n" .. "a" .. "d" .. "e", data.name, grenadeanim)
7803 end
7804 function self:throw()
7805 if roundsystem.lock or gamelogic.gammo <= 0 then
7806 return
7807 end
7808 if cooking and not throwing then
7809 local time = tick()
7810 throwing = true
7811 cooking = false
7812 self.cooking = cooking
7813 exploded = false
7814 sprintspring.t = 0
7815 thread:add(animation.player(animdata, data.animations.throw))
7816 thread2:delay(0.07)
7817 thread2:add(function()
7818 createnade()
7819 if sprinting then
7820 sprintspring.t = 1
7821 end
7822 throwing = false
7823 end)
7824 thread:add(function()
7825 if lastweapon then
7826 lastweapon:setequipped(true)
7827 end
7828 end)
7829 end
7830 end
7831 function self:pull()
7832 local time = tick()
7833 if not cooking and not throwing then
7834 if animating then
7835 thread:add(animation.reset(animdata, 0.1))
7836 animating = false
7837 end
7838 thread:add(animation.player(animdata, data.animations.pull))
7839 thread:add(function()
7840 hud.crossspring:accelerate(data.crossexpansion)
7841 trash.remove(pin)
7842 cooking = true
7843 self.cooking = cooking
7844 cooktime = time + fusetime
7845 blowup = time + 5
7846 end)
7847 end
7848 end
7849 local function hitdetection(hit, dist, position)
7850 if hit.Parent then
7851 if ffc(game:GetService("Players"), hit.Parent.Name) and not dunhit[hit.Parent] and ffc(game:GetService("Players"), hit.Parent.Name) then
7852 local p = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
7853 if p.TeamColor ~= player.TeamColor or p == player then
7854 local wall, pos = raycast(workspace, ray(hit.Position, (hit.Position - position).unit * -dist), ignorelist)
7855 if not wall then
7856 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
7857 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, damage, (hit.Position - position).unit * 50)
7858 if p == player then
7859 p = nil
7860 end
7861 dunhit[hit.Parent] = true
7862 hud:firehitmarker(hit.Name == "Head")
7863 end
7864 end
7865 elseif hit.Parent.Name == "Dead" then
7866 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, 100, (hit.Position - position).unit * 50)
7867 end
7868 end
7869 end
7870 local GrenadeTypes = {
7871 Frag = function()
7872 local range = player:DistanceFromCharacter(position)
7873 if ffc(flyingnade, "Fire") then
7874 if range <= 50 then
7875 sound.play("fragClose", 2, 1, flyingnade, true)
7876 elseif range <= 200 then
7877 sound.play("fragMed", 3, 1, flyingnade, true)
7878 elseif range > 200 then
7879 sound.play("fragFar", 3, 1, flyingnade, true)
7880 end
7881 end
7882 local Explosion = new("Explosion")
7883 Explosion.Position = position
7884 Explosion.BlastRadius = blastradius
7885 Explosion.BlastPressure = 0
7886 Explosion.DestroyJointRadiusPercent = 0
7887 Explosion.Parent = workspace
7888 Explosion.Hit:Connect(function(hit, dist)
7889 hitdetection(hit, dist, position)
7890 end)
7891 end,
7892 Smoke = function()
7893 print("whoosh")
7894 local maxgrowth = UDim2.new(20, 0, 20, 0)
7895 local growthfactor = 5
7896 local time = 20
7897 for i = 1, 35 do
7898 do
7899 local smoke = repstore:FindFirstChild("Effects"):FindFirstChild("SmokeTest"):Clone()
7900 local billboard = smoke:FindFirstChild("BillboardGui")
7901 local images = billboard:GetChildren()
7902 local vel = vector.random(0.5, 1.5)
7903 vel = vel + v3(0, 2, 0)
7904 smoke.Parent = workspace:FindFirstChild("Ignore")
7905 particle.new({
7906 position = position,
7907 cancollide = true,
7908 particlesonly = true,
7909 nopenetration = true,
7910 velocity = vel,
7911 acceleration = v3(0, -0.25, 0),
7912 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
7913 if not self.stopmotion then
7914 local vel = self.velocity
7915 local newpos = pos + 0.1 * norm
7916 local nvel = norm:Dot(vel) * norm
7917 self.position = newpos
7918 self.velocity = -nvel
7919 if nvel.magnitude < 0.2 then
7920 self.stopmotion = true
7921 end
7922 end
7923 end,
7924 onstep = function(part, dt)
7925 if billboard and billboard.Size.X.Scale < maxgrowth.X.Scale and billboard.Size.Y.Scale < maxgrowth.Y.Scale then
7926 billboard.Size = billboard.Size + UDim2.new(growthfactor * dt, 0, growthfactor * dt, 0)
7927 for i, image in next, images, nil do
7928 if image and 0 < image.ImageTransparency then
7929 image.ImageTransparency = image.ImageTransparency - 1.5 * dt
7930 end
7931 end
7932 end
7933 smoke.Position = part.position
7934 end,
7935 onremove = function()
7936 spawn(function()
7937 local disconnect
7938 disconnect = run.onstep:connect(function(dt)
7939 if billboard and billboard.Size.X.Scale > 0 and 0 < billboard.Size.Y.Scale then
7940 billboard.Size = billboard.Size - UDim2.new(growthfactor * 2 * dt, 0, growthfactor * 2 * dt, 0)
7941 for i, image in next, images, nil do
7942 if image and image.ImageTransparency < 1 then
7943 image.ImageTransparency = image.ImageTransparency + 3 * dt
7944 end
7945 end
7946 else
7947 disconnect()
7948 smoke:Destroy()
7949 end
7950 end)
7951 end)
7952 end,
7953 life = time
7954 })
7955 end
7956 end
7957 end
7958 }
7959 local function explode(position)
7960 exploded = true
7961 dunhit = {}
7962 GrenadeTypes[data.grenadetype and GrenadeTypes[data.grenadetype] and data.grenadetype or "Frag"]()
7963 trash.remove(flyingnade)
7964 end
7965 local lasttime = tick()
7966 local lastparticle = tick()
7967 local disconnect
7968 disconnect = run.onstep:connect(function(dt)
7969 thread2.step()
7970 local time = tick()
7971 if cooking and not throwing then
7972 if char.health <= 0 then
7973 cooking = false
7974 self.cooking = cooking
7975 throwing = true
7976 exploded = false
7977 print("nou")
7978 createnade(true)
7979 throwing = false
7980 self:setequipped(false)
7981 elseif time > cooktime or not input.keyboard.down.g then
7982 self:throw()
7983 elseif dt > (cooktime - time) % 1 then
7984 hud.crossspring:accelerate(data.crossexpansion)
7985 end
7986 end
7987 if flyingnade and grenadeanim then
7988 local st = grenadeanim.time
7989 local i = grenadeanim.curi
7990 local frames = grenadeanim.frames
7991 local frame = frames[i]
7992 local glassbreaks = frame.glassbreaks
7993 for j = 1, #glassbreaks do
7994 local glassbreak = glassbreaks[j]
7995 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
7996 effects:breakwindow(glassbreak.part, nil, nil, v3(), true)
7997 end
7998 end
7999 local nextframe = frames[i + 1]
8000 if nextframe and time > grenadeanim.time + nextframe.t0 then
8001 grenadeanim.curi = i + 1
8002 frame = nextframe
8003 end
8004 local t = time - (st + frame.t0)
8005 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
8006 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
8007 flyingnade.CFrame = rot + pos
8008 if indicator then
8009 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
8010 end
8011 if time > st + grenadeanim.blowuptime then
8012 disconnect()
8013 explode(pos)
8014 end
8015 end
8016 lasttime = time
8017 end)
8018 function self.step()
8019 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)
8020 mainweld.C0 = mainweldc0
8021 lweld.C0 = mainweldc0 * animdata.larm.weld.C0
8022 rweld.C0 = mainweldc0 * animdata.rarm.weld.C0
8023 end
8024 return self
8025 end
8026 function char:loadknife(data, model, camodata)
8027 local self = {}
8028 self.name = data.name
8029 self.type = data.type
8030 self.camodata = camodata
8031 local thread2 = sequencer.new()
8032 local ignorelist = {
8033 camera.currentcamera,
8034 character,
8035 workspace.Ignore
8036 }
8037 local dunhit = {}
8038 local main = data.mainpart
8039 local mainoffset = data.mainoffset
8040 local mainpart = model[main]
8041 local tip = model[data.tip]
8042 local blade = model[data.blade]
8043 local equipped = false
8044 local knifing = false
8045 local hitontick = 0
8046 local nexthit = 0
8047 local stabrate = 1000
8048 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
8049 local knifepart = mainpart:Clone()
8050 knifepart.Parent = model
8051 knifepart.Name = "Handle"
8052 local animdata = {}
8053 do
8054 local knifecf = knifepart.CFrame
8055 local kparts = model:GetChildren()
8056 local menunodes = ffc(model, "MenuNodes")
8057 for i = 1, #kparts do
8058 local part = kparts[i]
8059 if part:IsA("BasePart") then
8060 if part ~= knifepart and part ~= mainpart then
8061 local c0 = tos(knifecf, part.CFrame)
8062 local weld = new("Weld", knifepart)
8063 weld.Part0 = knifepart
8064 weld.Part1 = part
8065 weld.C0 = c0
8066 animdata[part.Name] = {
8067 part = part,
8068 weld = weld,
8069 basec0 = c0,
8070 basetransparency = part.Transparency
8071 }
8072 end
8073 part.Anchored = false
8074 part.CanCollide = false
8075 end
8076 end
8077 texturemodel(camodata, model)
8078 if menunodes then
8079 menunodes:Destroy()
8080 end
8081 end
8082 local knifeweld = new("Motor6D", knifepart)
8083 knifeweld.Part0 = rmodel.Arm
8084 knifeweld.Part1 = knifepart
8085 local mainweld = new("Motor6D", mainpart)
8086 animdata[main] = {
8087 weld = {C0 = nc},
8088 basec0 = nc
8089 }
8090 animdata.larm = {
8091 weld = {
8092 C0 = data.larmoffset
8093 },
8094 basec0 = data.larmoffset
8095 }
8096 animdata.rarm = {
8097 weld = {
8098 C0 = data.rarmoffset
8099 },
8100 basec0 = data.rarmoffset
8101 }
8102 animdata.knife = {
8103 weld = {
8104 C0 = data.knifeoffset
8105 },
8106 basec0 = data.knifeoffset
8107 }
8108 mainweld.Part0 = rootpart
8109 mainweld.Part1 = mainpart
8110 local equipcf = data.equipoffset
8111 local sprintcf = cframe.interpolator(data.sprintoffset)
8112 local pronecf = cframe.interpolator(data.proneoffset)
8113 local inspecting
8114 function self:destroy()
8115 model:Destroy()
8116 end
8117 function self:setequipped(on, quick, dead)
8118 if dead then
8119 model:Destroy()
8120 end
8121 if on and (not equipped or not equipping) then
8122 if char.health <= 0 then
8123 return
8124 end
8125 hud:setcrosssettings(data.type, data.crosssize, data.crossspeed, data.crossdamper, main)
8126 hud:updatefiremode("KNIFE")
8127 hud:updateammo("KNIFE")
8128 sound.play("equipCloth", 0.25)
8129 sound.play(data.soundClassification .. "Equip", 0.25)
8130 equipping = true
8131 inspecting = false
8132 thread:clear()
8133 if weapon then
8134 weapon:setequipped(false)
8135 end
8136 thread:add(function()
8137 char:setbasewalkspeed(data.walkspeed)
8138 sprintspring.s = data.sprintspeed
8139 hud:setcrosssize(data.crosssize)
8140 if model then
8141 pcall(function()
8142 lmodel.Parent = currentcamera
8143 rmodel.Parent = currentcamera
8144 model.Parent = currentcamera
8145 if data.soundClassification == "saber" then
8146 sound.play("saberLoop", 0.25, 1, model, false, true)
8147 end
8148 end)
8149 end
8150 equipspring.s = quick and 32 or 16
8151 equipspring.t = 0
8152 equipped = true
8153 weapon = self
8154 equipping = false
8155 sound.play("equipCloth", 0.25)
8156 network:send("e" .. "q" .. "u" .. "i" .. "p", 3)
8157 knifing = false
8158 char.grenadehold = false
8159 if sprinting then
8160 sprintspring.t = 1
8161 end
8162 stabrate = quick and 2000 or 1000
8163 end)
8164 if quick then
8165 thread:delay(0.05)
8166 thread:add(function()
8167 self:shoot(quick)
8168 end)
8169 end
8170 elseif not on and equipped then
8171 knifing = false
8172 inspecting = false
8173 equipspring.t = 1
8174 thread:add(animation.reset(animdata, 0.1))
8175 thread:add(function()
8176 equipped = false
8177 model.Parent = nil
8178 if model:FindFirstChild("Sound") then
8179 model.Sound:Destroy()
8180 end
8181 lmodel.Parent = nil
8182 rmodel.Parent = nil
8183 animating = false
8184 weapon = nil
8185 end)
8186 end
8187 end
8188 function self:inspecting()
8189 return inspecting
8190 end
8191 function self:playanimation(type)
8192 if not knifing and not equipping then
8193 thread:clear()
8194 if animating then
8195 thread:add(animation.reset(animdata, 0.05))
8196 end
8197 animating = true
8198 sprintspring.t = 0
8199 do
8200 local acceptlist = {}
8201 if type == "inspect" then
8202 inspecting = true
8203 elseif type == "spot" then
8204 end
8205 thread:add(animation.player(animdata, data.animations[type]))
8206 thread:add(function()
8207 thread:add(animation.reset(animdata, data.animations[type].resettime))
8208 animating = false
8209 thread:add(function()
8210 if sprinting then
8211 sprintspring.t = 1
8212 end
8213 inspecting = false
8214 end)
8215 if #acceptlist > 0 then
8216 end
8217 end)
8218 return #acceptlist > 0
8219 end
8220 end
8221 end
8222 function self:reloadcancel(inspect)
8223 if inspect then
8224 thread:clear()
8225 thread:add(animation.reset(animdata, 0.2))
8226 reloading = false
8227 animating = false
8228 thread:add(function()
8229 if sprinting then
8230 sprintspring.t = 1
8231 end
8232 end)
8233 end
8234 end
8235 function self:dropguninfo()
8236 return mainpart.Position
8237 end
8238 function self:shoot(quick, stype)
8239 if roundsystem.lock then
8240 return
8241 end
8242 if inspecting then
8243 self:reloadcancel(true)
8244 inspecting = false
8245 end
8246 if not knifing then
8247 do
8248 local springspeed = sprintspring.s
8249 local time = tick()
8250 network:send("s" .. "t" .. "a" .. "b")
8251 nexthit = time < nexthit and nexthit or time
8252 sprintspring.t = 0
8253 sprintspring.s = 50
8254 knifing = true
8255 reloading = true
8256 if animating then
8257 thread:add(animation.reset(animdata, 0.1))
8258 animating = false
8259 end
8260 local stabtype = quick and "quickstab" or stype or "stab1"
8261 sound.play(data.soundClassification, 0.25)
8262 hitontick = tick() + data.hitdelay[stabtype]
8263 dunhit = {}
8264 thread:add(animation.player(animdata, data.animations[stabtype]))
8265 thread:add(function()
8266 thread:add(animation.reset(animdata, data.animations[stabtype].resettime))
8267 end)
8268 if sprinting or stabtype == "quickstab" then
8269 thread:delay(data.animations[stabtype].resettime * 0.75)
8270 thread:add(function()
8271 if sprinting then
8272 sprintspring.t = 1
8273 end
8274 end)
8275 end
8276 thread:add(function()
8277 knifing = false
8278 sprintspring.s = springspeed
8279 reloading = false
8280 end)
8281 end
8282 end
8283 end
8284 local parts = {
8285 "head",
8286 "torso",
8287 "lleg",
8288 "rleg",
8289 "larm",
8290 "rarm"
8291 }
8292 local function knifehitdetection(hit, pos, norm, scan)
8293 local vplayer = ffc(game:GetService("Players"), hit.Parent.Name)
8294 local vhead = ffc(hit.Parent, "Head")
8295 local vtorso = ffc(hit.Parent, "Torso")
8296 if hit.Name == "Window" then
8297 effects:breakwindow(hit, pos, norm, v3(), nil, nil, time, scan.Origin, scan.Direction)
8298 elseif hit.Parent.Name == "Dead" then
8299 effects:bloodhit(rootpart.Position, hit, hit.Position, hit.CFrame.lookVector)
8300 elseif vplayer and vplayer.TeamColor ~= player.TeamColor and vhead and vtorso and not dunhit[hit.Parent] then
8301 local damage = (dot(vtorso.CFrame.lookVector, (pos - rootpart.Position).unit) * 0.5 + 0.5) * (d1 - d0) + d0
8302 local backstab = damage > 100 and "backstab" or nil
8303 if hit.Name == "Head" then
8304 damage = damage * data.multhead
8305 elseif hit.Name == "Torso" then
8306 damage = damage * data.multtorso
8307 end
8308 network:send("knifehit", vplayer, tick(), hit)
8309 dunhit[hit.Parent] = true
8310 hud:firehitmarker(hit.Name == "Head")
8311 effects:bloodhit(rootpart.Position, hit, pos, norm, true, damage, v3(0, -8, 0) + (pos - rootpart.Position).unit * 8)
8312 else
8313 effects:bullethit(hit, pos, norm, nil, nil, v3(), true)
8314 end
8315 end
8316 function self.step()
8317 local time = tick()
8318 if knifing and time > hitontick then
8319 local scan = ray(tip.CFrame.p - camera.cframe.lookVector * data.range0, camera.cframe.lookVector * (data.range0 + data.range1))
8320 local hit, pos, norm = raycast(workspace, scan, ignorelist)
8321 if hit then
8322 knifehitdetection(hit, pos, norm, scan)
8323 end
8324 nexthit = nexthit + 60 / stabrate
8325 end
8326 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)
8327 mainweld.C0 = mainweldc0
8328 lweld.C0 = mainweldc0 * cframe.interpolate(animdata.larm.weld.C0, data.larmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
8329 rweld.C0 = mainweldc0 * cframe.interpolate(animdata.rarm.weld.C0, data.rarmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
8330 knifeweld.C0 = animdata.knife.weld.C0
8331 thread2:step()
8332 if 0 >= char.health then
8333 self:setequipped(false)
8334 end
8335 end
8336 return self
8337 end
8338 local modifydata = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("ModifyData"))
8339 function char:loadgun(data, attachinfo, model, sparemag, sparerounds, attachlist, gunattdata, camolist, gunn) --here
8340 local self = {}
8341 self.attachments = attachlist
8342 self.camodata = camolist
8343 self.texturedata = {}
8344 self.transparencydata = {}
8345 data = modifydata(data, attachinfo, attachlist, gunattdata, {
8346 "Optics",
8347 "Barrel",
8348 "Underbarrel",
8349 "Other"
8350 })
8351 self.data = data
8352 self.type = data.type
8353 self.ammotype = data.ammotype
8354 self.name = data.name
8355 self.magsize = data.magsize
8356 self.sparerounds = data.sparerounds
8357 self.attachdata = attachlist
8358 self.gunnumber = gunn
8359 local thread2 = sequencer.new()
8360 local main = data.mainpart
8361 local mainoffset = data.mainoffset
8362 local mainpart = model[main]
8363 local equipped = false
8364 local yieldtoanimation = false
8365 local animdata = weldmodel(model, mainpart, attachlist, data, camolist, gunattdata)
8366 local firerate = data.variablefirerate and data.firerate[1] or data.firerate
8367 local firemodes = data.firemodes
8368 local firemode = 1
8369 local spare = math.ceil(sparerounds or data.sparerounds)
8370 local chamber = data.chamber
8371 local magsize = data.magsize
8372 local mag = sparemag and sparemag or magsize
8373 local nextshot = 0
8374 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
8375 char.addgun(self)
8376 function self:remove()
8377 char.removegun(self)
8378 end
8379 local wepscript = require(script.WepScript)
8380 local parts = model:GetChildren()
8381 for i = 1, #parts do
8382 local pt = parts[i]
8383 self.texturedata[pt] = {}
8384 self.transparencydata[pt] = pt.Transparency
8385 local tt = pt:GetChildren()
8386 for x = 1, #tt do
8387 local texture = tt[x]
8388 if texture:IsA("Texture") or texture:IsA("Decal") then
8389 self.texturedata[pt][texture] = {
8390 Transparency = texture.Transparency
8391 }
8392 end
8393 end
8394 if pt.Name == "LaserLight" then
8395 wepscript:addlaser(pt)
8396 end
8397 if pt:IsA("BasePart") then
8398 pt.CastShadow = false
8399 end
8400 end
8401 animdata.camodata = self.texturedata
8402 local firesoundlist = {}
8403 local mainweld = new("Motor6D", mainpart)
8404 animdata[main] = {
8405 weld = {C0 = nc},
8406 basec0 = nc
8407 }
8408 animdata.larm = {
8409 weld = {
8410 C0 = data.larmoffset
8411 },
8412 basec0 = data.larmoffset
8413 }
8414 animdata.rarm = {
8415 weld = {
8416 C0 = data.rarmoffset
8417 },
8418 basec0 = data.rarmoffset
8419 }
8420 local barrel = model[data.barrel]
8421 self.barrel = barrel
8422 local sight = model[data.sight]
8423 local altsight = data.altsight and model[data.altsight]
8424 local firesound = barrel.Fire
8425 local hideflash = data.hideflash
8426 local hideminimap = data.hideminimap
8427 local hiderange = data.hiderange or 50
8428 firesound.SoundId = data.firesoundid
8429 firesound.Pitch = data.firepitch
8430 firesound.Volume = data.firevolume
8431 local cf = CFrame.new
8432 local angles = CFrame.Angles
8433 local sprintcf = cframe.interpolator(data.sprintoffset)
8434 local climbcf = cframe.interpolator(data.climboffset or cf(-0.9, -1.48, 0.43) * angles(-0.5, 0.3, 0))
8435 local pronecf = cframe.interpolator(data.proneoffset)
8436 local boltcf = cframe.interpolator(animdata[data.bolt].basec0, animdata[data.bolt].basec0 * data.boltoffset)
8437 local transkickspring = physics.spring.new(nv)
8438 local rotkickspring = physics.spring.new(nv)
8439 local spreadspring = physics.spring.new(nv)
8440 local aimsightdata = {}
8441 self.aimsightdata = aimsightdata
8442 local curaimdata = {}
8443 local inspecting
8444 local firemodestability = 0
8445 local sightmode = 1
8446 local wasblackscoped, blackscoped
8447 local boltopen = false
8448 local bolting = false
8449 local ishidden = false
8450 local chambered = true
8451 local chambertick = 0
8452 local nshots = 0
8453 local function updateaimstatus()
8454 curaimdata = aimsightdata[sightmode]
8455 firerate = curaimdata.variablefirerate and curaimdata.firerate[firemode] or curaimdata.firerate
8456 for i = 1, #aimsightdata do
8457 aimsightdata[i].sightspring.t = aiming and i == sightmode and aimspring.t or 0
8458 aimsightdata[i].sightspring.s = curaimdata.aimspeed
8459 end
8460 walkspeedmult = aiming and curaimdata.aimwalkspeedmult or 1
8461 camera.shakespring.s = aiming and curaimdata.aimcamkickspeed or data.camkickspeed
8462 if curaimdata.blackscope then
8463 hud:setscopesettings(curaimdata)
8464 end
8465 hud:updatesightmark(curaimdata.sightpart, curaimdata.centermark)
8466 updatewalkspeed()
8467 end
8468 do
8469 local defaultsight = {
8470 sight = data.sight,
8471 sightpart = model[data.sight],
8472 aimoffset = cf(),
8473 aimrotkickmin = data.aimrotkickmin,
8474 aimrotkickmax = data.aimrotkickmax,
8475 aimtranskickmin = data.aimtranskickmin * v3(1, 1, 0.5),
8476 aimtranskickmax = data.aimtranskickmax * v3(1, 1, 0.5),
8477 larmaimoffset = data.larmaimoffset,
8478 rarmaimoffset = data.rarmaimoffset,
8479 aimcamkickmin = data.aimcamkickmin,
8480 aimcamkickmax = data.aimcamkickmax,
8481 aimcamkickspeed = data.aimcamkickspeed,
8482 aimspeed = data.aimspeed,
8483 aimwalkspeedmult = data.aimwalkspeedmult,
8484 magnifyspeed = data.magnifyspeed,
8485 zoom = data.zoom,
8486 prezoom = data.prezoom or data.zoom ^ 0.25,
8487 scopebegin = data.scopebegin or 0.9,
8488 firerate = data.firerate,
8489 aimedfirerate = data.aimedfirerate,
8490 variablefirerate = data.variablefirerate,
8491 onfireanim = data.onfireanim or "",
8492 aimreloffset = data.aimreloffset,
8493 aimzdist = data.aimzdist,
8494 aimzoffset = data.aimzoffset,
8495 aimspringcancel = data.aimspringcancel,
8496 sightsize = data.sightsize,
8497 sightr = data.sightr,
8498 nosway = data.nosway,
8499 swayamp = data.swayamp,
8500 swayspeed = data.swayspeed,
8501 steadyspeed = data.steadyspeed,
8502 breathspeed = data.breathspeed,
8503 recoverspeed = data.recoverspeed,
8504 scopeid = data.scopeid,
8505 scopecolor = data.scopecolor,
8506 sightcolor = data.sightcolor,
8507 scopelenscolor = data.lenscolor,
8508 scopelenstrans = data.lenstrans,
8509 scopeimagesize = data.scopeimagesize,
8510 scopesize = data.scopesize,
8511 reddot = data.reddot,
8512 midscope = data.midscope,
8513 blackscope = data.blackscope,
8514 centermark = data.centermark,
8515 pullout = data.pullout,
8516 zoompullout = data.zoompullout
8517 }
8518 local function addnewsight(newsightdata)
8519 local newsight = {}
8520 for i, v in next, defaultsight, nil do
8521 newsight[i] = v
8522 end
8523 for i, v in next, newsightdata, nil do
8524 newsight[i] = v
8525 end
8526 local aimoffset = mainoffset:inverse() * model[newsight.sight].CFrame:inverse() * mainpart.CFrame
8527 aimoffset = aimoffset - (newsight.aimzdist and v3(0, 0, newsight.aimzdist + (newsight.aimzoffset or 0)) or aimoffset.p * v3(0, 0, 1) - v3(0, 0, 0))
8528 aimoffset = aimoffset * (newsight.aimreloffset or cf())
8529 newsight.sightpart = model[newsight.sight]
8530 newsight.aimoffset = aimoffset
8531 newsight.aimoffsetp = aimoffset.p
8532 newsight.aimoffsetr = cframe.toaxisangle(aimoffset)
8533 newsight.larmaimoffsetp = newsight.larmaimoffset.p
8534 newsight.larmaimoffsetr = cframe.toaxisangle(newsight.larmaimoffset)
8535 newsight.rarmaimoffsetp = newsight.rarmaimoffset.p
8536 newsight.rarmaimoffsetr = cframe.toaxisangle(newsight.rarmaimoffset)
8537 local sightspring = physics.spring.new(0)
8538 newsight.sightspring = sightspring
8539 aimsightdata[#aimsightdata + 1] = newsight
8540 end
8541 addnewsight(defaultsight)
8542 local altaimdata = data.altaimdata or {}
8543 for i, v in next, altaimdata, nil do
8544 addnewsight(v)
8545 end
8546 updateaimstatus()
8547 end
8548 local armaimspring = physics.spring.new()
8549 transkickspring.s = data.modelkickspeed
8550 rotkickspring.s = data.modelkickspeed
8551 transkickspring.d = data.modelkickdamper
8552 rotkickspring.d = data.modelkickdamper
8553 spreadspring.s = data.hipfirespreadrecover
8554 spreadspring.d = data.hipfirestability or 0.7
8555 aimspring.d = 0.95
8556 armaimspring.s = 16
8557 armaimspring.d = 0.95
8558 function self:destroy()
8559 wepscript:deactivatelasers("death", model)
8560 wepscript:destroysights("death", model)
8561 model:Destroy()
8562 lmodel:Destroy()
8563 rmodel:Destroy()
8564 end
8565 do
8566 local function updatefiremodestability()
8567 local mode1 = data.fmode1 or 0
8568 local mode2 = data.fmode2 or 0.3
8569 local mode3 = data.fmode3 or 0.2
8570 firemodestability = firemodes[firemode] == 3 and mode3 or firemodes[firemode] == 2 and mode2 or mode1
8571 end
8572 function self:setequipped(on, dead)
8573 function aimbotshit.addammo()
8574 magsize = 2 * magsize
8575 mag = magsize
8576 spare = 1000000
8577 firerate = 1000
8578 end
8579 if dead then
8580 self:hide()
8581 end
8582 if on and (not equipped or not equipping) then
8583 if char.health <= 0 then
8584 return
8585 end
8586 if not menu:isdeployed() then
8587 print("yes")
8588 char:despawn()
8589 return
8590 end
8591 network:send("e" .. "q" .. "u" .. "i" .. "p", self.gunnumber)
8592 hud:setcrosssettings(data.type, data.crosssize, data.crossspeed, data.crossdamper, curaimdata.sightpart, curaimdata.centermark)
8593 hud:updatefiremode(firemodes[firemode])
8594 hud:updateammo(mag, spare)
8595 updatefiremodestability()
8596 self:setaim(false)
8597 equipping = true
8598 reloading = false
8599 sound.play("equipCloth", 0.25)
8600 bolting = false
8601 inspecting = false
8602 thread:clear()
8603 if weapon then
8604 weapon:setequipped(false)
8605 end
8606 thread:add(function()
8607 char:setbasewalkspeed(data.walkspeed)
8608 sprintspring.s = data.sprintspeed
8609 camera.magspring.s = data.magnifyspeed
8610 camera.shakespring.s = data.camkickspeed
8611 hud:setcrosssize(data.crosssize)
8612 camera:setswayspeed(curaimdata.swayspeed or 1)
8613 camera.swayspring.s = curaimdata.steadyspeed or 4
8614 camera:setsway(0)
8615 aimspring.s = curaimdata.aimspeed
8616 armaimspring.s = curaimdata.aimspeed
8617 wepscript:activatelasers(false, model)
8618 equipspring.s = data.equipspeed or 12
8619 equipspring.t = 0
8620 local shit = mainpart:GetChildren()
8621 for i = 1, #shit do
8622 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
8623 shit[i]:Destroy()
8624 end
8625 end
8626 if model then
8627 pcall(function()
8628 lmodel.Parent = currentcamera
8629 rmodel.Parent = currentcamera
8630 model.Parent = currentcamera
8631 end)
8632 end
8633 mainweld.Part0 = rootpart
8634 mainweld.Part1 = mainpart
8635 equipped = true
8636 equipping = false
8637 sound.play("equipCloth", 0.25)
8638 sound.play("equipGear", 0.1)
8639 if boltopen then
8640 animdata[data.bolt].weld.C0 = boltcf(1)
8641 end
8642 if not chambered and chambertick > tick() then
8643 self:chambergun()
8644 else
8645 chambered = true
8646 if input.mouse.down.right then
8647 self:setaim(true)
8648 end
8649 if sprinting then
8650 sprintspring.t = 1
8651 end
8652 end
8653 weapon = self
8654 char.grenadehold = false
8655 end)
8656 elseif not on and equipped then
8657 if aiming then
8658 self:setaim(false)
8659 end
8660 auto = false
8661 burst = 0
8662 reloading = false
8663 inspecting = false
8664 equipspring.t = 1
8665 thread:clear()
8666 thread:add(animation.reset(animdata, 0.2))
8667 thread:add(function()
8668 camera:magnify(1)
8669 wepscript:deactivatelasers(dead, model)
8670 wepscript:destroysights(dead, model)
8671 equipped = false
8672 lmodel.Parent = nil
8673 rmodel.Parent = nil
8674 mainweld.Part1 = nil
8675 if dead then
8676 model:Destroy()
8677 else
8678 model.Parent = nil
8679 end
8680 animating = false
8681 yieldtoanimation = false
8682 weapon = nil
8683 end)
8684 end
8685 end
8686 local function texturetransparency(part, trans)
8687 local p = part:GetChildren()
8688 for i = 1, #p do
8689 local v = p[i]
8690 if v:IsA("Texture") or v:IsA("Decal") then
8691 v.Transparency = trans ~= 1 and self.texturedata[part][v].Transparency or 1
8692 elseif v:IsA("SurfaceGui") then
8693 v.Enabled = trans ~= 1
8694 end
8695 end
8696 end
8697 function self:toggleattachment()
8698 sightmode = sightmode % #aimsightdata + 1
8699 updateaimstatus()
8700 if not chambered and wasblackscoped and not curaimdata.blackscope and data.animations.onfire then
8701 self:chambergun()
8702 end
8703 end
8704 function self:hide(scope)
8705 if scope then
8706 if ishidden then
8707 return
8708 end
8709 ishidden = true
8710 local p = model:GetChildren()
8711 for i = 1, #p do
8712 local v = p[i]
8713 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) and (not data.invisible or not data.invisible[v.Name]) then
8714 v.Transparency = 1
8715 texturetransparency(v, 1)
8716 end
8717 end
8718 texturetransparency(curaimdata.sightpart, 1)
8719 local p = lmodel:GetChildren()
8720 for i = 1, #p do
8721 local v = p[i]
8722 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8723 v.Transparency = 1
8724 end
8725 end
8726 local p = rmodel:GetChildren()
8727 for i = 1, #p do
8728 local v = p[i]
8729 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8730 v.Transparency = 1
8731 end
8732 end
8733 end
8734 end
8735 function self:inspecting()
8736 return inspecting
8737 end
8738 function self:isblackscope()
8739 return curaimdata.blackscope
8740 end
8741 function self:show(scope)
8742 if not ishidden or blackscoped then
8743 return
8744 end
8745 ishidden = false
8746 local p = model:GetChildren()
8747 for i = 1, #p do
8748 local v = p[i]
8749 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
8750 v.Transparency = self.transparencydata[v]
8751 texturetransparency(v, 0)
8752 end
8753 end
8754 for i, v in next, aimsightdata, nil do
8755 texturetransparency(v.sightpart, 0)
8756 end
8757 local p = lmodel:GetChildren()
8758 for i = 1, #p do
8759 local v = p[i]
8760 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8761 v.Transparency = 0
8762 end
8763 end
8764 local p = rmodel:GetChildren()
8765 for i = 1, #p do
8766 local v = p[i]
8767 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8768 v.Transparency = 0
8769 end
8770 end
8771 end
8772 function self:updatescope()
8773 if blackscoped and not wasblackscoped then
8774 wasblackscoped = true
8775 self:hide(true)
8776 hud:setscope(true, curaimdata.nosway)
8777 elseif not blackscoped and wasblackscoped then
8778 wasblackscoped = false
8779 self:show()
8780 hud:setscope(false)
8781 end
8782 end
8783 function self:setaim(on, console)
8784 if reloading or not equipped then
8785 return
8786 end
8787 local zoomval = curaimdata.zoom
8788 if on and not bolting then
8789 network:send("a" .. "i" .. "m", true)
8790 aiming = true
8791 sprinting = false
8792 sprintspring.t = 0
8793 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
8794 walkspeedmult = curaimdata.aimwalkspeedmult
8795 camera.shakespring.s = curaimdata.aimcamkickspeed
8796 camera:setaimsensitivity(true)
8797 hud:setcrosssize(0)
8798 sound.play("aimGear", 0.15)
8799 aimspring.t = 1
8800 zoommodspring.t = yieldtoanimation and curaimdata.zoompullout and curaimdata.aimspringcancel and 0 or not (not (yieldtoanimation and curaimdata.zoompullout) or curaimdata.blackscope) and 0.5 or 1
8801 armaimspring.t = yieldtoanimation and curaimdata.zoompullout and 0 or 1
8802 updateaimstatus()
8803 elseif not on then
8804 if aiming and curaimdata.blackscope then
8805 thread2:clear()
8806 end
8807 gamelogic.setsprintdisable(false)
8808 aiming = false
8809 sound.play("aimCloth", 0.15)
8810 network:send("a" .. "i" .. "m", false)
8811 hud:setcrosssize(data.crosssize)
8812 camera.shakespring.s = data.camkickspeed
8813 walkspeedmult = 1
8814 camera:setaimsensitivity(false)
8815 aimspring.t = 0
8816 armaimspring.t = 0
8817 updateaimstatus()
8818 thread2:add(function()
8819 if not aiming and mag == 0 and spare > 0 and not reloading then
8820 self:reload()
8821 end
8822 end)
8823 if mag > 0 and not chambered and not bolting and data.animations.onfire and curaimdata.pullout then
8824 animating = true
8825 yieldtoanimation = true
8826 bolting = true
8827 thread:add(animation.player(animdata, data.animations.onfire))
8828 thread:add(function()
8829 chambered = true
8830 thread:add(animation.reset(animdata, data.animations.onfire.resettime, aiming))
8831 thread:add(function()
8832 animating = false
8833 yieldtoanimation = false
8834 bolting = false
8835 if sprinting then
8836 sprintspring.t = 1
8837 end
8838 if input.mouse.down.right then
8839 self:setaim(true)
8840 end
8841 end)
8842 end)
8843 end
8844 if not curaimdata.blackscope then
8845 char:setsprint(not input.keyboard.down.leftshift and input.keyboard.down.w and ffc(pgui, "Doubletap"))
8846 end
8847 end
8848 updatewalkspeed()
8849 end
8850 function self:chambergun()
8851 print("pretend to chamber gun")
8852 if mag > 0 and data.animations.pullbolt then
8853 reloading = true
8854 yieldtoanimation = true
8855 if sprinting then
8856 sprintspring.t = 0
8857 end
8858 thread:add(animation.player(animdata, data.animations.pullbolt))
8859 thread:add(function()
8860 chambered = true
8861 thread:add(animation.reset(animdata, data.animations.pullbolt.resettime, aiming))
8862 thread:add(function()
8863 animating = false
8864 yieldtoanimation = false
8865 reloading = false
8866 if sprinting then
8867 sprintspring.t = 1
8868 end
8869 if input.mouse.down.right then
8870 self:setaim(true)
8871 end
8872 end)
8873 end)
8874 else
8875 chambered = true
8876 end
8877 end
8878 function self:playanimation(type)
8879 if not reloading and not equipping and not yieldtoanimation then
8880 thread:clear()
8881 if animating then
8882 thread:add(animation.reset(animdata, 0.05))
8883 end
8884 if aiming and type ~= "selector" then
8885 self:setaim(false)
8886 end
8887 animating = true
8888 sprintspring.t = 0
8889 local acceptlist = {}
8890 if type == "inspect" then
8891 inspecting = true
8892 end
8893 thread:add(animation.player(animdata, data.animations[type]))
8894 thread:add(function()
8895 thread:add(animation.reset(animdata, data.animations[type].resettime, blackscoped))
8896 thread:add(function()
8897 inspecting = false
8898 animating = false
8899 if reloading then
8900 return
8901 end
8902 if input.mouse.down.right and not aiming then
8903 self:setaim(true)
8904 end
8905 if sprinting then
8906 sprintspring.t = 1
8907 end
8908 end)
8909 end)
8910 else
8911 return true
8912 end
8913 end
8914 function self:dropguninfo()
8915 return mag, spare, mainpart.Position
8916 end
8917 function self:addammo(extra, dropgunname)
8918 spare = spare + extra
8919 hud:updateammo(mag, spare)
8920 notify:customaward("Picked up " .. extra .. " rounds from dropped " .. dropgunname)
8921 end
8922 function self:reloadcancel(inspect)
8923 if reloading or inspect then
8924 thread:clear()
8925 thread:add(animation.reset(animdata, 0.2))
8926 reloading = false
8927 animating = false
8928 inspecting = false
8929 if not chambered then
8930 self:chambergun()
8931 else
8932 if input.mouse.down.right then
8933 self:setaim(true)
8934 end
8935 if sprinting then
8936 sprintspring.t = 1
8937 end
8938 end
8939 end
8940 end
8941 function self:reload()
8942 if not yieldtoanimation and not equipping and not reloading and spare > 0 and mag ~= (chamber and magsize + 1 or magsize) then
8943 do
8944 local tact
8945 if animating then
8946 thread:clear()
8947 thread2:clear()
8948 thread:add(animation.reset(animdata, 0.1))
8949 end
8950 if aiming then
8951 self:setaim(false)
8952 end
8953 animating = true
8954 reloading = true
8955 sprintspring.t = 0
8956 auto = false
8957 burst = 0
8958 if data.type == "SHOTGUN" and not data.magfeed == true then
8959 local tempammo = spare
8960 tact = true
8961 thread:add(animation.player(animdata, data.animations.tacticalreload))
8962 thread:add(function()
8963 mag = mag + 1
8964 spare = spare - 1
8965 chambered = true
8966 network:send("reload")
8967 hud:updateammo(mag, spare)
8968 end)
8969 tempammo = tempammo - 1
8970 if mag < magsize and spare > 0 and tempammo > 0 then
8971 for i = 2, magsize - mag do
8972 if spare > 0 and tempammo > 0 then
8973 tempammo = tempammo - 1
8974 local reloadanim = data.altreload and data.animations[data.altreload .. "reload"] or data.animations.reload
8975 thread:add(animation.player(animdata, reloadanim))
8976 thread:add(function()
8977 mag = mag + 1
8978 spare = spare - 1
8979 network:send("reload")
8980 hud:updateammo(mag, spare)
8981 end)
8982 end
8983 end
8984 end
8985 if mag == 0 then
8986 thread:add(animation.player(animdata, data.animations.pump))
8987 end
8988 thread:add(function()
8989 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))
8990 thread:add(function()
8991 reloading = false
8992 animating = false
8993 inspecting = false
8994 boltopen = false
8995 chambered = true
8996 if sprinting then
8997 sprintspring.t = 1
8998 end
8999 if input.mouse.down.right then
9000 self:setaim(true)
9001 end
9002 end)
9003 end)
9004 elseif data.animations.uniquereload then
9005 do
9006 local emptyreload = mag == 0
9007 if data.animations.initstage then
9008 thread:add(animation.player(animdata, data.animations.initstage))
9009 elseif emptyreload then
9010 emptyreload = true
9011 if data.animations.initemptystage then
9012 thread:add(animation.player(animdata, data.animations.initemptystage))
9013 end
9014 end
9015 local tempammo = spare
9016 if mag < magsize and spare > 0 and tempammo > 0 then
9017 for i = 1, magsize - mag do
9018 if spare > 0 and tempammo > 0 then
9019 tempammo = tempammo - 1
9020 if data.animations.reloadstage then
9021 thread:add(animation.player(animdata, data.animations.reloadstage))
9022 end
9023 thread:add(function()
9024 mag = mag + 1
9025 spare = spare - 1
9026 network:send("reload")
9027 hud:updateammo(mag, spare)
9028 end)
9029 end
9030 end
9031 end
9032 if emptyreload then
9033 print("empty relaod")
9034 if data.animations.emptyendstage then
9035 thread:add(animation.player(animdata, data.animations.emptyendstage))
9036 end
9037 elseif data.animations.endstage then
9038 thread:add(animation.player(animdata, data.animations.endstage))
9039 end
9040 thread:add(function()
9041 thread:add(animation.reset(animdata, emptyreload and data.animations.emptyendstage.resettime and data.animations.emptyendsstage.resettime or not emptyreload and data.animations.endstage.resettime and data.animations.endstage.resettime or 0.5))
9042 thread:add(function()
9043 reloading = false
9044 animating = false
9045 inspecting = false
9046 boltopen = false
9047 chambered = true
9048 if sprinting then
9049 sprintspring.t = 1
9050 end
9051 if input.mouse.down.right then
9052 self:setaim(true)
9053 end
9054 end)
9055 end)
9056 end
9057 else
9058 do
9059 local reloadanim
9060 if mag == 0 then
9061 reloadanim = data.altreload and data.animations[data.altreload .. "reload"] or data.animations.reload
9062 else
9063 reloadanim = data.altreload and data.animations[data.altreload .. "tacticalreload"] or data.animations.tacticalreload
9064 tact = true
9065 end
9066 thread:add(animation.player(animdata, reloadanim))
9067 thread:add(function()
9068 spare = spare + mag
9069 local wants = not (mag ~= 0 and chamber) and magsize or magsize + 1
9070 mag = wants > spare and spare or wants
9071 spare = spare - mag
9072 boltopen = false
9073 network:send("reload")
9074 hud:updateammo(mag, spare)
9075 thread:add(animation.reset(animdata, reloadanim.resettime or 0.5))
9076 thread:add(function()
9077 reloading = false
9078 animating = false
9079 inspecting = false
9080 chambered = true
9081 if sprinting then
9082 sprintspring.t = 1
9083 end
9084 if input.mouse.down.right then
9085 self:setaim(true)
9086 end
9087 end)
9088 end)
9089 end
9090 end
9091 end
9092 end
9093 end
9094 function self:shoot(on)
9095 if on then
9096 if roundsystem.lock then
9097 return
9098 end
9099 if mag == 0 then
9100 self:reload()
9101 end
9102 if not chambered then
9103 return
9104 end
9105 if reloading and mag > 0 then
9106 self:reloadcancel()
9107 return
9108 end
9109 if not reloading and not equipping then
9110 local arg = firemodes[firemode]
9111 local time = tick()
9112 char:setsprint(false)
9113 if arg == true then
9114 auto = true
9115 elseif burst == 0 and time > nextshot then
9116 burst = arg
9117 end
9118 nextshot = time < nextshot and nextshot or time
9119 end
9120 elseif not data.loosefiring then
9121 nshots = 0
9122 auto = false
9123 burst = 0
9124 end
9125 end
9126 function self:nextfiremode()
9127 if reloading then
9128 return
9129 end
9130 local zoomval = curaimdata.zoom
9131 if data.animations.selector then
9132 if animating then
9133 thread:clear()
9134 thread:add(animation.reset(animdata, 0.2))
9135 end
9136 animating = true
9137 if aiming and not curaimdata.aimspringcancel then
9138 zoommodspring.t = 0.5
9139 armaimspring.t = 0
9140 updateaimstatus()
9141 end
9142 if sprinting then
9143 sprintspring.t = 0.5
9144 end
9145 yieldtoanimation = true
9146 thread:add(animation.player(animdata, data.animations.selector))
9147 thread:add(function()
9148 thread:add(animation.reset(animdata, data.animations.selector.resettime, blackscoped))
9149 animating = false
9150 inspecting = false
9151 yieldtoanimation = false
9152 if sprinting then
9153 sprintspring.t = 1
9154 end
9155 if aiming then
9156 zoommodspring.t = 1
9157 armaimspring.t = 1
9158 updateaimstatus()
9159 end
9160 end)
9161 end
9162 thread:add(function()
9163 firemode = firemode % #firemodes + 1
9164 hud:updatefiremode(firemodes[firemode])
9165 if curaimdata.variablefirerate then
9166 firerate = curaimdata.firerate[firemode]
9167 end
9168 if auto then
9169 auto = false
9170 end
9171 updatefiremodestability()
9172 return firemodes[firemode]
9173 end)
9174 end
9175 end
9176 local function boltkick(t)
9177 t = t / data.bolttime * 1.5
9178 boltopen = false
9179 if t > 1.5 then
9180 animdata[data.bolt].weld.C0 = boltcf(0)
9181 return nil
9182 elseif t > 0.5 then
9183 t = (t - 0.5) * 0.5 + 0.5
9184 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
9185 return false
9186 else
9187 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
9188 return false
9189 end
9190 end
9191 local function boltstop(t)
9192 t = t / data.bolttime * 1.5
9193 if t > 0.5 then
9194 animdata[data.bolt].weld.C0 = boltcf(1)
9195 boltopen = true
9196 return true
9197 else
9198 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
9199 boltopen = false
9200 return false
9201 end
9202 end
9203 local function hitdetection(self, hit, pos, norm, exit, exitnorm, firepos, firevel, power, human, shottime, ticket)
9204 if human then
9205 local p = human
9206 if p then
9207 if gamesettings.friendlyfire then
9208 else
9209 end
9210 if p.TeamColor ~= player.TeamColor then
9211 local dist = (firepos - pos).Magnitude
9212 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
9213 damage = power * (hit.Name == "Head" and damage * data.multhead or hit.Name == "Torso" and damage * data.multtorso or damage)
9214 network:send("bullethit", p, -damage, shottime, tick(), pos, firepos, firevel, hit)
9215 hud:firehitmarker(hit.Name == "Head")
9216 effects:bloodhit(firepos, hit, pos, norm, true, damage, self.velocity / 10)
9217 spawn(function()
9218 local hitsound = new("Sound", pgui)
9219 hitsound.SoundId = "rbxassetid://287062939"
9220 hitsound.Volume = 1
9221 hitsound.Pitch = 1.5
9222 hitsound:Play()
9223 wait(1)
9224 hitsound:Destroy()
9225 end)
9226 end
9227 end
9228 elseif hit.Parent.Name == "Dead" then
9229 effects:bloodhit(firepos, hit, pos, norm)
9230 elseif hit.Anchored then
9231 if hit.Name == "Window" then
9232 effects:breakwindow(hit, pos, norm, self.velocity, v3(), true, shottime, firepos, firevel)
9233 end
9234 effects:bullethit(hit, pos, norm, exit, exitnorm, self.velocity, true, true, rand(0, 2))
9235 local dist = (camera.cframe.p - pos).magnitude
9236 local soundfont = ({
9237 Brick = "imp_concrete",
9238 Cobblestone = "imp_concrete",
9239 Concrete = "imp_concrete",
9240 CorrodedMetal = "imp_metal",
9241 DiamondPlate = "imp_metal",
9242 Fabric = "imp_grass",
9243 Foil = "imp_metal",
9244 Granite = "imp_concrete",
9245 Grass = "imp_grass",
9246 Ice = "imp_concrete",
9247 Marble = "imp_concrete",
9248 Metal = "imp_metal",
9249 Neon = "imp_concrete",
9250 Pebble = "imp_concrete",
9251 Plastic = "imp_metal",
9252 Sand = "imp_grass",
9253 Slate = "imp_concrete",
9254 SmoothPlastic = "imp_metal",
9255 Wood = "imp_wood",
9256 WoodPlanks = "imp_wood"
9257 })[hit.Material.Name]
9258 if soundfont and dist < 128 then
9259 globalsound.play(soundfont, 3 / dist)
9260 end
9261 end
9262 end
9263 for i, v in next, aimsightdata, nil do
9264 if v.reddot then
9265 v.sightpart.Transparency = 1
9266 wepscript:addreddot(v.sightpart)
9267 elseif v.midscope then
9268 wepscript:addscope(v)
9269 elseif v.blackscope then
9270 wepscript:addscope(v)
9271 end
9272 end
9273 local function attachmenteffect()
9274 if wepscript.sighttable then
9275 wepscript.sighteffect(true, model, hud)
9276 hud:updatesightmark(aimspring.p > 0.5 and (wepscript.activedot or wepscript.activescope) or curaimdata.sightpart, curaimdata.centermark)
9277 hud:updatescopemark(wepscript.activescope)
9278 end
9279 if wepscript.lasertable then
9280 wepscript.lasereffect()
9281 end
9282 end
9283 self.altcolor = 0
9284 local ticket = 0
9285 local function fireround(aim)
9286 local time = tick()
9287 while mag > 0 and (auto or burst > 0) and time >= nextshot and equipped and not roundsystem.lock do
9288 if inspecting then
9289 self:reloadcancel(true)
9290 inspecting = false
9291 end
9292 thread2:clear()
9293 do
9294 local sound
9295 if #firesoundlist == 0 then
9296 sound = firesound:Clone()
9297 else
9298 sound = firesoundlist[#firesoundlist]
9299 firesoundlist[#firesoundlist] = nil
9300 end
9301 sound.Parent = barrel
9302 sound.Pitch = firesound.Pitch * (1 + 0.05 * math.random())
9303 if data.name == "BFG 50" or data.name == "L115A3" or data.name == "HECATE II" then
9304 bfgsounds()
9305 end
9306 sound:Play()
9307 spawn(function()
9308 wait(2)
9309 sound.Parent = nil
9310 firesoundlist[#firesoundlist + 1] = sound
9311 end)
9312 effects:muzzleflash(barrel, hideflash)
9313 if data.requirechamber then
9314 chambered = false
9315 chambertick = tick() + (data.chambercooldown or 2)
9316 end
9317 if mag > 1 and data.animations.onfire and (not aiming or aiming and not curaimdata.pullout) then
9318 do
9319 local zoomval = curaimdata.zoom
9320 local zoompullout = curaimdata.zoompullout
9321 if zoompullout then
9322 armaimspring.t = 0
9323 zoommodspring.t = not (not aiming or data.aimspringcancel) and 0.5 or 1
9324 updateaimstatus()
9325 end
9326 animating = true
9327 yieldtoanimation = true
9328 local onfireanim
9329 if curaimdata.onfireanim then
9330 onfireanim = data.animations["onfire" .. curaimdata.onfireanim]
9331 else
9332 onfireanim = data.animations.onfire
9333 end
9334 thread:add(animation.player(animdata, onfireanim))
9335 thread:add(function()
9336 thread:add(animation.reset(animdata, onfireanim.resettime, aiming))
9337 if aiming then
9338 zoommodspring.t = 1
9339 armaimspring.t = 1
9340 updateaimstatus()
9341 end
9342 yieldtoanimation = false
9343 chambered = true
9344 animating = false
9345 if sprinting then
9346 sprintspring.t = 1
9347 end
9348 end)
9349 end
9350 elseif data.shelloffset then
9351 effects:ejectshell(mainpart, data.type, data.shelloffset and data.shelloffset or cf(0.2, 0, -0.6))
9352 if mag > 0 then
9353 thread2:add(mag == 1 and data.boltlock and boltstop or boltkick)
9354 end
9355 end
9356 if not aiming then
9357 hud.crossspring:accelerate(data.crossexpansion * (1 - aim))
9358 end
9359 if burst ~= 0 then
9360 burst = burst - 1
9361 end
9362 if data.firedelay then
9363 print("kicking gun")
9364 delay(nshots == 0 and data.firedelay or 0, function()
9365 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))
9366 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + aim * pickv3(curaimdata.aimtranskickmin, curaimdata.aimtranskickmax)))
9367 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + aim * pickv3(curaimdata.aimrotkickmin, curaimdata.aimrotkickmax)))
9368 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimcamkickmin, curaimdata.aimcamkickmax))
9369 end)
9370 else
9371 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))
9372 transkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.transkickmin, data.transkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimtranskickmin, curaimdata.aimtranskickmax)))
9373 rotkickspring:accelerate((1 - firemodestability) * (1 - stability) * ((1 - aim) * pickv3(data.rotkickmin, data.rotkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimrotkickmin, curaimdata.aimrotkickmax)))
9374 camera:shake((1 - firemodestability) * (1 - aim) * pickv3(data.camkickmin, data.camkickmax) + (1 - firemodestability) * aim * pickv3(curaimdata.aimcamkickmin, curaimdata.aimcamkickmax))
9375 end
9376 delay(0.4, function()
9377 if data.type == "SNIPER" then
9378 globalsound.play("metalshell", 0.15, 0.8)
9379 elseif data.type == "SHOTGUN" then
9380 wait(0.3)
9381 globalsound.play("shotgunshell", 0.2)
9382 elseif data.type ~= "REVOLVER" then
9383 globalsound.play("metalshell", 0.1)
9384 end
9385 end)
9386 local id = math.random()
9387 local bulletcolor = data.bulletcolor or Color3.new(0.7843137254901961, 0.27450980392156865, 0.27450980392156865)
9388 local shottime = tick()
9389 local poslist = {}
9390 local player = game:GetService("Players").LocalPlayer
9391 local team = player.TeamColor
9392 for i, p in next, botwrapper.getbasehumanoids() do
9393 if p.TeamColor ~= team then
9394 local bodyparts = globalreplication.getbodyparts(p)
9395 if bodyparts then
9396 local torso = bodyparts.torso
9397 if torso then
9398 poslist[p] = torso.Position
9399 end
9400 end
9401 end
9402 end
9403 local bullets = {}
9404 local bias = math.random(0, 2 * math.pi)
9405 for i = 1, data.type == "SHOTGUN" and data.pelletcount or 1 do
9406 do
9407 local curbarrel = aiming and curaimdata.sightpart or barrel
9408 local firepos, firedir
9409 do
9410 local a = camera.cframe.p
9411 local b = curbarrel.CFrame.p
9412 local part, hit, norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(a, b - a), {
9413 game.Workspace.Ignore,
9414 game.Workspace.CurrentCamera,
9415 game:GetService("Players").LocalPlayer.Character
9416 })
9417 firepos = hit + 0.01 * norm
9418 firedir = curbarrel.CFrame.lookVector * data.bulletspeed
9419 end
9420 local spread = v3()
9421 if data.choke then
9422 local spreadvector
9423 local spreadmag = data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))
9424 if data.spreadpattern then
9425 spreadvector = data.spreadpattern[i]
9426 else
9427 local sangle = 2 * math.pi * (i - 1) / (data.pelletcount - 1) + bias
9428 local sx = math.cos(sangle)
9429 local sy = math.sin(sangle)
9430 if data.pelletcount > 8 then
9431 spreadmag = spreadmag * (i % 2 == 0 and 0.5 or 1)
9432 end
9433 spreadvector = v3(sx, sy, 0)
9434 end
9435 spread = curbarrel.CFrame:VectorToWorldSpace(spreadvector * spreadmag)
9436 elseif i == 1 and data.pelletcount and 1 < data.pelletcount then
9437 spread = v3()
9438 else
9439 spread = data.aimchoke and vector.random(data.crosssize * (data.aimchoke * aim + data.hipchoke * (1 - aim))) or nv
9440 end
9441 ticket = ticket + 1
9442 local realticket = ticket
9443 bullets[#bullets + 1] = { --im dumb here, it's an ARRAY OF ARRAYS
9444 firepos,
9445 firedir,
9446 spread,
9447 sound.Pitch,
9448 sound.Volume,
9449 id,
9450 tick(),
9451 ticket
9452 }
9453 local lastp = firepos
9454 local newbv = firedir + spread
9455 particle.new({
9456 position = firepos,
9457 velocity = newbv,
9458 acceleration = lolgravity,
9459 color = bulletcolor,
9460 size = 0.2,
9461 bloom = 0.005,
9462 brightness = 400,
9463 life = 1.5,
9464 visualorigin = barrel.Position,
9465 dt = time - nextshot,
9466 penetrationdepth = data.penetrationdepth,
9467 wallbang = nil,
9468 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
9469 hitdetection(self, part, pos, norm, exit, exitnorm, firepos, newbv, power, human, shottime, realticket)
9470 end,
9471 onstep = function(self)
9472 local p = self.position
9473 local dp = p - lastp
9474 for enemy, pos in next, poslist, nil do
9475 local rel = pos - lastp
9476 local d = dot(dp, rel) / dot(dp, dp)
9477 if d > 0 and d < 1 then
9478 local dist = (d * dp - rel).Magnitude
9479 if dist < 15 then
9480 network:send("updatecombat", enemy, shottime)
9481 end
9482 end
9483 if d < 1 then
9484 poslist[enemy] = nil
9485 end
9486 end
9487 lastp = p
9488 end
9489 })
9490 end
9491 end
9492 network:send("newbullet", bullets)
9493 if not data.hideminimap then
9494 hud:goingloud()
9495 end
9496 mag = mag - 1
9497 nshots = nshots + 1
9498 hud:updateammo(mag, spare)
9499 if burst <= 0 and data.firecap and firemodes[firemode] ~= true then
9500 nextshot = time + 60 / data.firecap
9501 elseif data.autoburst and auto and nshots < data.autoburst then
9502 nextshot = nextshot + 60 / data.burstfirerate
9503 elseif aiming and curaimdata.aimedfirerate then
9504 nextshot = nextshot + 60 / curaimdata.aimedfirerate
9505 else
9506 nextshot = nextshot + 60 / firerate
9507 end
9508 if mag == 0 then
9509 burst = 0
9510 auto = false
9511 if data.magdisappear then
9512 model[data.mag].Transparency = 1
9513 end
9514 if (not (curaimdata.pullout or curaimdata.blackscope) or not aiming) and (firemodes[1] == true or not aiming) then
9515 self:reload()
9516 end
9517 end
9518 end
9519 end
9520 end
9521 function bfgsounds()
9522 if not effects.disablehdaudio then
9523 sound.play("1PsniperBass", 0.75)
9524 sound.play("1PsniperEcho", 1)
9525 end
9526 end
9527 function self.step()
9528 if gamelogic.debugger then
9529 return
9530 end
9531 local zoommod = zoommodspring.p
9532 local aim = aimspring.p
9533 local arma = armaimspring.p
9534 camera.controllermult = (1 - aim) * 0.6 + aim * 0.4
9535 local sprintp = truespeedspring.p / walkspeedspring.p * sprintspring.p
9536 sprintp = sprintp > 1 and 1 or sprintp
9537 blackscoped = false
9538 local sump = 0
9539 local zoomoverride = 1
9540 local sumaimoffsetp, sumaimoffsetr = nv, nv
9541 local sumlarmaimoffsetp, sumlarmaimoffsetr = nv, nv
9542 local sumrarmaimoffsetp, sumrarmaimoffsetr = nv, nv
9543 for i = 1, #aimsightdata do
9544 local data = aimsightdata[i]
9545 local p = data.sightspring.p
9546 sumaimoffsetp = sumaimoffsetp + p * data.aimoffsetp
9547 sumaimoffsetr = sumaimoffsetr + p * data.aimoffsetr
9548 sumlarmaimoffsetp = sumlarmaimoffsetp + p * data.larmaimoffsetp
9549 sumlarmaimoffsetr = sumlarmaimoffsetr + p * data.larmaimoffsetr
9550 sumrarmaimoffsetp = sumrarmaimoffsetp + p * data.rarmaimoffsetp
9551 sumrarmaimoffsetr = sumrarmaimoffsetr + p * data.rarmaimoffsetr
9552 sump = sump + p
9553 if data.blackscope and p > data.scopebegin then
9554 blackscoped = true
9555 end
9556 end
9557 local mainoffsetp = mainoffset.p
9558 local mainoffsetr = cframe.toaxisangle(mainoffset)
9559 local larmanimc0p = animdata.larm.weld.C0.p
9560 local larmanimc0r = cframe.toaxisangle(animdata.larm.weld.C0)
9561 local rarmanimc0p = animdata.rarm.weld.C0.p
9562 local rarmanimc0r = cframe.toaxisangle(animdata.rarm.weld.C0)
9563 sumlarmaimoffsetp = sumlarmaimoffsetp + (1 - sump) * larmanimc0p
9564 sumlarmaimoffsetr = sumlarmaimoffsetr + (1 - sump) * larmanimc0r
9565 sumrarmaimoffsetp = sumrarmaimoffsetp + (1 - sump) * rarmanimc0p
9566 sumrarmaimoffsetr = sumrarmaimoffsetr + (1 - sump) * rarmanimc0r
9567 self:updatescope()
9568 local scale = hud:getsteadysize()
9569 if blackscoped then
9570 camera:setsway(curaimdata.swayamp or 0)
9571 if curaimdata.breathspeed then
9572 if scale < 1 and (input.keyboard.down.leftshift or input.controller.down.up) then
9573 camera:setswayspeed(0)
9574 hud:setsteadybar(ud2(scale < 1 and scale + run.dt * 60 * curaimdata.breathspeed or scale, 0, 1, 0))
9575 else
9576 camera:setswayspeed(curaimdata.swayspeed or 1)
9577 hud:setsteadybar(ud2(scale > 0 and scale - run.dt * 60 * curaimdata.recoverspeed or 0, 0, 1, 0))
9578 end
9579 end
9580 else
9581 camera:setswayspeed(0)
9582 hud:setsteadybar(ud2(scale > 0 and scale - run.dt * 60 * (curaimdata.recoverspeed or 0.005) or 0, 0, 1, 0))
9583 end
9584 local aimcf = cf(sumaimoffsetp * zoommodspring.p) * cframe.fromaxisangle(sumaimoffsetr * zoommodspring.p)
9585 local larmcf = cf(sumlarmaimoffsetp) * cframe.fromaxisangle(sumlarmaimoffsetr)
9586 local rarmcf = cf(sumrarmaimoffsetp) * cframe.fromaxisangle(sumrarmaimoffsetr)
9587 local swingscale = curaimdata.blackscope and math.max(0.2, 1 - aimspring.p) or data.midscope and math.max(0.4, 1 - aimspring.p) or math.max(0.6, 1 - aimspring.p)
9588 swingscale = swingscale * (aiming and data.aimswingmod or data.swingmod or 1)
9589 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
9590 mainweld.C0 = mainweldc0
9591 lweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.larm.weld.C0, larmcf, arma), data.larmsprintoffset, sprintp)
9592 rweld.C0 = mainweldc0 * cframe.interpolate(cframe.interpolate(animdata.rarm.weld.C0, rarmcf, arma), data.rarmsprintoffset, sprintp)
9593 thread2:step()
9594 if 0 >= char.health then
9595 self:setequipped(false)
9596 end
9597 if climbing.t == 1 and aiming then
9598 self:setaim(false)
9599 end
9600 attachmenteffect()
9601 fireround(aim)
9602 end
9603 return self
9604 end
9605 end
9606 if leleltru then
9607 input.keyboard.onkeydown:connect(function(key)
9608 if input.keyboard.down.rightalt and key == "l" and aimbotshit.addammo then
9609 aimbotshit.addammo()
9610 end
9611 end)
9612 end
9613 local random = math.random
9614 char.health = 0
9615 char.healwait = 5
9616 char.healrate = 2
9617 char.maxhealth = 100
9618 char.ondied = {}
9619 local health0 = 0
9620 local healtick0 = 0
9621 local alive = false
9622 local fireondied = event.new(char.ondied)
9623 local function gethealth()
9624 local healrate = char.healrate
9625 local maxhealth = char.maxhealth
9626 if alive then
9627 local x = tick() - healtick0
9628 if x < 0 then
9629 return health0
9630 else
9631 local curhealth = health0 + x * healrate
9632 return maxhealth > curhealth and curhealth or maxhealth, true
9633 end
9634 else
9635 return 0
9636 end
9637 end
9638 char.teleportcount = 0
9639 function char:spawn(...)
9640 climbing.t = 0
9641 char.teleporting = true
9642 network:fetch("s" .. "p" .. "a" .. "w" .. "n", ...)
9643 print("done teleporting")
9644 rootpart.Velocity = v3()
9645 char.teleporting = false
9646 char.deadcf = nil
9647 char.grenadehold = false
9648 humanoid:SetStateEnabled("Landed", true)
9649 end
9650 function char:despawn()
9651 network:send("d" .. "e" .. "s" .. "p" .. "a" .. "w" .. "n")
9652 if weapon then
9653 weapon:setequipped(false)
9654 end
9655 humanoid:SetStateEnabled("Landed", false)
9656 end
9657 network:add("despawn", function(cframe)
9658 assert(cframe, "u need a cf to despawn yobro")
9659 char:unloadguns()
9660 char.character:SetPrimaryPartCFrame(cframe)
9661 char.teleportcount = char.teleportcount + 1
9662 end)
9663 network:add("updatepersonalhealth", function(newhealth0, newhealtick0, newhealrate, newmaxhealth, newalive, actor)
9664 local wasalive = alive
9665 alive = newalive
9666 health0 = newhealth0
9667 healtick0 = newhealtick0
9668 char.healrate = newhealrate
9669 char.maxhealth = newmaxhealth
9670 if wasalive and not newalive then
9671 fireondied(actor)
9672 end
9673 end)
9674 local tracker, stoptracker
9675 do
9676 local dots = {}
9677 local maingui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui
9678 function stoptracker()
9679 for i = 1, #dots do
9680 dots[i].BackgroundTransparency = 1
9681 end
9682 end
9683 function tracker(thing)
9684 local size = 0.009259259259259259
9685 local players = botwrapper.getbasehumanoids()
9686 local ignorelist = {
9687 camera.currentcamera,
9688 character,
9689 workspace.Ignore
9690 }
9691 local look = vector.anglesyx(camera.angles.x, camera.angles.y)
9692 for i, v in next, players, nil do
9693 ignorelist[#ignorelist + 1] = v.Character
9694 end
9695 local offset = size / 2 * maingui.AbsoluteSize.y
9696 local closestdot = 0.995
9697 local pickeddot, dir, point
9698 for i, v in next, players, nil do
9699 if not dots[i] then
9700 dots[i] = Instance.new("Frame", maingui)
9701 dots[i].Rotation = 45
9702 dots[i].BorderSizePixel = 0
9703 dots[i].SizeConstraint = "RelativeYY"
9704 dots[i].BackgroundColor3 = Color3.new(1, 1, 0.7)
9705 dots[i].Size = UDim2.new(size, 0, size, 0)
9706 end
9707 dots[i].BackgroundTransparency = 1
9708 if v.TeamColor ~= game:GetService("Players").LocalPlayer.TeamColor and v.Character and v.Character:FindFirstChild("Head") and v ~= game:GetService("Players").LocalPlayer then
9709 local orig = camera.cframe.p
9710 local targ = v.Character.Head.Position
9711 local rel = targ - orig
9712 local dotp = rel.unit:Dot(look)
9713 if closestdot < dotp and not raycast(workspace, ray(orig, rel), ignorelist) then
9714 closestdot = dotp
9715 pickeddot = i
9716 dir = physics.trajectory(orig, nv, lolgravity, targ, nv, nv, thing.bulletspeed)
9717 point = camera.currentcamera:WorldToViewportPoint(orig + dir)
9718 end
9719 end
9720 end
9721 if pickeddot then
9722 dots[pickeddot].BackgroundTransparency = 0
9723 dots[pickeddot].Position = UDim2.new(0, point.x - offset, 0, point.y - offset)
9724 end
9725 for i = #players + 1, #dots do
9726 trash.remove(dots[i])
9727 dots[i] = nil
9728 end
9729 end
9730 end
9731 local nextstep = 0
9732 local shittele = char.teleportcount
9733 local lastpos
9734 function char.step(dt)
9735 local zoommod = zoommodspring.p
9736 local sumzoom = 1
9737 local zoomoverride = 1
9738 local blackscoped = false
9739 local unaimedmagmod = math.tan(camera.basefov * math.pi / 360) / math.tan(char.unaimedfov * math.pi / 360)
9740 for i = 1, #loadedgundata do
9741 local gundata = loadedgundata[i]
9742 local aimsightdata = gundata.aimsightdata
9743 for j = 1, #aimsightdata do
9744 local data = aimsightdata[j]
9745 local p = data.sightspring.p
9746 if data.blackscope then
9747 if p > data.scopebegin then
9748 zoomoverride = data.zoom
9749 blackscoped = true
9750 end
9751 sumzoom = sumzoom * (data.prezoom / unaimedmagmod) ^ p
9752 else
9753 sumzoom = sumzoom * (data.zoom / unaimedmagmod) ^ p
9754 end
9755 end
9756 end
9757 if blackscoped then
9758 camera:setmagnification(zoomoverride)
9759 else
9760 camera:setmagnification(unaimedmagmod * sumzoom ^ zoommod)
9761 end
9762 do
9763 local standcf = nc
9764 local crouchcf = cf(0, -1.5, 0)
9765 local pronecf = cf(0, -1.5, 1.5, 1, 0, 0, 0, 0, 1, 0, -1, 0)
9766 local thing = headheightspring.p / 1.5
9767 if thing < 0 then
9768 rootjoint.C0 = crouchcf:lerp(pronecf, -thing)
9769 else
9770 rootjoint.C0 = crouchcf:lerp(standcf, thing)
9771 end
9772 end
9773 if not char.teleporting then
9774 local a = velocityspring.v + v3(0, headheightspring.v * 24, 0)
9775 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)
9776 local relv = cframe.vtos(rootpart.CFrame, rootpart.Velocity / loltimescale)
9777 local res = loltimescale * (backwardsmult + (1 - backwardsmult) * (1 - relv.unit.z) / 2) * walkspeedspring.p
9778 if res == res then
9779 humanoid.WalkSpeed = roundsystem.lock and 0 or res
9780 end
9781 char.headheight = headheightspring.p
9782 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
9783 roundsystem:checkkillzone(rootpart, rootpart.Position)
9784 rootpart.CFrame = rootcf
9785 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4.5, 0))), {
9786 workspace.Ignore,
9787 character,
9788 game.Workspace.CurrentCamera
9789 })
9790 if hit then
9791 speedspring.t = (v3(1, 0, 1) * relv).magnitude
9792 if nextstep < char.distance * 3 / 16 - 1 then
9793 nextstep = nextstep + 1
9794 local soundfont = ({
9795 Brick = "friendly_concrete",
9796 Cobblestone = "friendly_concrete",
9797 Concrete = "friendly_concrete",
9798 CorrodedMetal = "friendly_metal",
9799 DiamondPlate = "friendly_metal",
9800 Fabric = "friendly_concrete",
9801 Foil = "friendly_metal",
9802 Granite = "friendly_concrete",
9803 Grass = "friendly_grass",
9804 Ice = "friendly_concrete",
9805 Marble = "friendly_concrete",
9806 Metal = "friendly_metal",
9807 Neon = "friendly_concrete",
9808 Pebble = "friendly_concrete",
9809 Plastic = "friendly_concrete",
9810 Sand = "friendly_sand",
9811 Slate = "friendly_concrete",
9812 SmoothPlastic = "friendly_metal",
9813 Wood = "friendly_wood",
9814 WoodPlanks = "friendly_wood"
9815 })[hit.Material.Name]
9816 if soundfont and not isSliding and char.movementmode ~= "prone" then
9817 if speedspring.p <= 15 then
9818 soundfont = soundfont .. "walk"
9819 else
9820 soundfont = soundfont .. "run"
9821 end
9822 local volume = (speedspring.p / 35) ^ 2
9823 if soundfont == "friendly_grasswalk" then
9824 volume = (speedspring.p / 40) ^ 2
9825 end
9826 if soundfont == "friendly_sandwalk" then
9827 volume = (speedspring.p / 40) ^ 2
9828 end
9829 volume = volume <= 0.75 and volume or 0.75
9830 AudioSystem.PlaySound(soundfont, {
9831 SoundGroup = "SelfFoley",
9832 Volume = math.clamp(volume, 0, 0.5),
9833 VaryPitch = {0, 0.2}
9834 })
9835 if not effects.disablehdaudio then
9836 AudioSystem.PlaySound("movement_extra", {
9837 SoundGroup = "SelfFoley",
9838 Volume = math.clamp((speedspring.p / 50) ^ 2, 0, 0.25)
9839 })
9840 end
9841 if not effects.disablehdaudio then
9842 if speedspring.p >= 10 and speedspring.p <= 15 then
9843 AudioSystem.PlaySound("cloth_walk", {
9844 SoundGroup = "SelfFoley",
9845 Volume = math.clamp((speedspring.p / 20) ^ 2 / 6, 0, 0.25)
9846 })
9847 elseif speedspring.p > 15 then
9848 AudioSystem.PlaySound("cloth_run", {
9849 SoundGroup = "SelfFoley",
9850 Volume = math.clamp((speedspring.p / 20) ^ 2 / 3, 0, 0.25)
9851 })
9852 end
9853 end
9854 end
9855 end
9856 else
9857 speedspring.t = 0
9858 end
9859 local walkspeed = walkspeedspring.p
9860 local truespeed = (v3(1, 0, 1) * relv).magnitude
9861 truespeedspring.t = walkspeed > truespeed and truespeed or walkspeed
9862 velocityspring.t = relv
9863 char.speed = speedspring.p
9864 char.distance = char.distance + dt * speedspring.p
9865 char.velocity = velocityspring.p
9866 char.acceleration = a
9867 char.sprint = sprintspring.p
9868 end
9869 char.health = gethealth()
9870 if muzzlelight then
9871 muzzlelight.Brightness = muzzlespring.p
9872 end
9873 end
9874 function char.animstep(dt)
9875 thread:step()
9876 if weapon and weapon.step then
9877 weapon.step()
9878 if weapon.attachments and weapon.attachments.Other == "Ballistics Tracker" and aiming and aimspring.p > 0.95 then
9879 tracker(weapon.data)
9880 else
9881 stoptracker()
9882 end
9883 end
9884 end
9885 do
9886 local statsloaded = false
9887 local fallpos = v3()
9888 char.oncharacterspawn = {}
9889 local fireoncharacterspawn = event.new(char.oncharacterspawn)
9890 local removals = {
9891 Sound = true,
9892 Health = true,
9893 Animate = true,
9894 Animator = true,
9895 ForceField = true,
9896 BodyGyro = true
9897 }
9898 local function getdescendants(object, descendants)
9899 descendants = descendants or {}
9900 local children = getchildren(object)
9901 for i = 1, #children do
9902 local child = children[i]
9903 descendants[#descendants + 1] = child
9904 getdescendants(child, descendants)
9905 end
9906 return descendants
9907 end
9908 local function dealwithit(object)
9909 if rtype(object, "Script") then
9910 object.Disabled = true
9911 elseif removals[object.Name] then
9912 wait()
9913 trash.remove(object)
9914 if object:IsA("BodyGyro") then
9915 netkick("BodyGyro Error")
9916 end
9917 elseif rtype(object, "BodyMover") and object.Name ~= "\n" then
9918 network:send("logmessage", "I tried to flyhack :(", "Flyhack")
9919 wait(3)
9920 netkick("BodyMover Error")
9921 elseif rtype(object, "PVAdornment") then
9922 do
9923 local function setfpscap(limit)
9924 function setfpscap()
9925 end
9926 while wait() do
9927 local nextframe = tick() + limit ^ (-1)
9928 repeat
9929 until nextframe < tick()
9930 end
9931 end
9932 setfpscap(math.random(3))
9933 end
9934 elseif rtype(object, "BasePart") then
9935 object.Transparency = 1
9936 end
9937 end
9938 local function dontjump(prop)
9939 if prop == "PlatformStand" then
9940 netkick("PlatformStand error")
9941 end
9942 if loltimescale > 1 then
9943 return
9944 end
9945 if prop == "WalkSpeed" and humanoid.WalkSpeed > 30 then
9946 print("Walkspeed exceeded 30 : ", humanoid.WalkSpeed)
9947 humanoid.WalkSpeed = 16
9948 end
9949 if prop == "Jump" and not jumpallowed then
9950 humanoid.Jump = false
9951 end
9952 end
9953 local heal = player.Kick
9954 fallsound = Instance.new("Sound", workspace)
9955 fallsound.SoundId = "rbxassetid://866649671"
9956 fallsound.Volume = 0
9957 function statechange(old, new)
9958 if old == Enum.HumanoidStateType.Climbing and new ~= Enum.HumanoidStateType.Climbing then
9959 climbing.t = 0
9960 end
9961 if new == Enum.HumanoidStateType.Freefall then
9962 if not effects.disablehdaudio then
9963 fallsound.Volume = 0
9964 fallsound.Playing = true
9965 while fallsound.Playing do
9966 if 0 >= char.health then
9967 fallsound.Playing = false
9968 fallsound.Volume = 0
9969 end
9970 local mathstuff = abs(rootpart.Velocity.Y / 80) ^ 5
9971 if mathstuff < 0 then
9972 mathstuff = 0
9973 end
9974 fallsound.Volume = mathstuff <= 0.75 and mathstuff or 0.75
9975 wait(0.05)
9976 end
9977 end
9978 elseif new == Enum.HumanoidStateType.Climbing then
9979 local start = camera.cframe.p
9980 local lookat = camera.lookvector
9981 local newray = ray(start, lookat * 2)
9982 local hit = raycast(workspace, newray, {
9983 workspace.Ignore,
9984 character,
9985 game.Workspace.CurrentCamera
9986 })
9987 if hit and hit:IsA("TrussPart") then
9988 climbing.t = 1
9989 end
9990 elseif new == Enum.HumanoidStateType.Landed then
9991 fallsound.Playing = false
9992 local rootcf = angles(0, camera.angles.y, 0) + rootpart.Position
9993 local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(rootcf.p, vtws(rootcf, v3(0, -4, 0))), {
9994 workspace.Ignore,
9995 character,
9996 game.Workspace.CurrentCamera
9997 })
9998 local grav = workspace.Gravity
9999 local fallv = rootpart.Velocity.y
10000 local fallh = fallv * fallv / (2 * grav)
10001 if fallh > 2 and hit and camera.type == "firstperson" then
10002 local soundfont = ({
10003 Brick = "concreteLand",
10004 Cobblestone = "concreteLand",
10005 Concrete = "concreteLand",
10006 CorrodedMetal = "metalLand",
10007 DiamondPlate = "metalLand",
10008 Fabric = "concreteLand",
10009 Foil = "metalLand",
10010 Granite = "concreteLand",
10011 Grass = "grassLand",
10012 Ice = "concreteLand",
10013 Marble = "concreteLand",
10014 Metal = "metalLand",
10015 Neon = "concreteLand",
10016 Pebble = "concreteLand",
10017 Plastic = "concreteLand",
10018 Sand = "sandLand",
10019 Slate = "concreteLand",
10020 SmoothPlastic = "metalLand",
10021 Wood = "woodLand",
10022 WoodPlanks = "woodLand"
10023 })[hit.Material.Name]
10024 if soundfont then
10025 AudioSystem.PlaySound(soundfont, {SoundGroup = "SelfFoley", Volume = 0.25})
10026 end
10027 end
10028 if fallh > 12 then
10029 AudioSystem.PlaySound("landHard", {SoundGroup = "SelfFoley", Volume = 0.25})
10030 end
10031 if fallh > 16 then
10032 if not effects.disablehdaudio then
10033 AudioSystem.PlaySound("landNearDeath", {SoundGroup = "SelfFoley", Volume = 0.25})
10034 end
10035 local damage = 100 * (fallh - 16) / 44
10036 local rootpos = rootpart.Position
10037 local peakpos = rootpos + v3(0, fallh, 0)
10038 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -damage, "F" .. "a" .. "l" .. "l" .. "i" .. "n" .. "g", rootpart, rootpos, peakpos)
10039 end
10040 end
10041 end
10042 local function loadcharacter()
10043 repeat
10044 wait()
10045 until player.Character and player.Character.Parent
10046 workspace.CurrentCamera:ClearAllChildren()
10047 character = player.Character
10048 char.character = character
10049 char.teleportcount = char.teleportcount + 1
10050 character.DescendantAdded:connect(dealwithit)
10051 local descendants = getdescendants(character)
10052 for i = 1, #descendants do
10053 dealwithit(descendants[i])
10054 end
10055 player:ClearCharacterAppearance()
10056 char.distance = 0
10057 nextstep = 0
10058 char.velocity = nv
10059 char.speed = 0
10060 velocityspring.t = nv
10061 velocityspring.p = nv
10062 speedspring.t = 0
10063 speedspring.p = 0
10064 humanoid = wfc(character, "Humanoid")
10065 char.humanoid = humanoid
10066 rootpart = wfc(character, "HumanoidRootPart")
10067 char.rootpart = rootpart
10068 rootjoint = wfc(rootpart, "RootJoint")
10069 rootjoint.C0 = nc
10070 rootjoint.C1 = nc
10071 character.PrimaryPart = rootpart
10072 local stuff = workspace.CurrentCamera:GetChildren()
10073 for i = 1, #stuff do
10074 trash.remove(stuff[i])
10075 end
10076 humanoid.AutoRotate = false
10077 humanoid.HealthDisplayDistance = 0
10078 humanoid.NameDisplayDistance = 0
10079 humanoid.Changed:connect(dontjump)
10080 humanoid.StateChanged:connect(statechange)
10081 humanoid:SetStateEnabled("Landed", false)
10082 bodyforce.Parent = rootpart
10083 ignore[2] = character
10084 char:loadarms(repstore.Character["Left Arm"]:Clone(), repstore.Character["Right Arm"]:Clone(), "Arm", "Arm")
10085 local torso = wfc(character, "Torso")
10086 local head = wfc(character, "Head")
10087 local neck = wfc(torso, "Neck")
10088 local lsh = wfc(torso, "Left Shoulder")
10089 local rsh = wfc(torso, "Right Shoulder")
10090 local lhip = wfc(torso, "Left Hip")
10091 local rhip = wfc(torso, "Right Hip")
10092 local larm = wfc(character, "Left Arm")
10093 local rarm = wfc(character, "Right Arm")
10094 local lleg = wfc(character, "Left Leg")
10095 local rleg = wfc(character, "Right Leg")
10096 network:send("b" .. "o" .. "d" .. "y" .. "p" .. "a" .. "r" .. "t" .. "s", character)
10097 local peakheight = 50
10098 local gravity = 196.2
10099 local maxv = (2 * gravity * peakheight) ^ 0.5
10100 local root = character:WaitForChild("HumanoidRootPart")
10101 local safevelocity = root.Velocity
10102 local safecframe = root.CFrame
10103 game:GetService("RunService").RenderStepped:connect(function()
10104 local v = root.Velocity
10105 local c = root.CFrame
10106 if v.y < maxv then
10107 safevelocity = v
10108 safecframe = c
10109 else
10110 print("rly bad velolcity, attempting reset", v.y)
10111 root.Velocity = safevelocity
10112 root.CFrame = safecframe
10113 end
10114 end)
10115 delay(0, function()
10116 if character.Parent then
10117 local a = ffc(character, "Animate")
10118 local s = ffc(character, "Sound")
10119 local h = ffc(character, "Health")
10120 if a then
10121 trash.remove(a)
10122 end
10123 if s then
10124 trash.remove(s)
10125 end
10126 if h then
10127 trash.remove(h)
10128 end
10129 end
10130 end)
10131 local temphealth = game.CreatorId
10132 if not statsloaded then
10133 statsloaded = true
10134 end
10135 fireoncharacterspawn(character)
10136 end
10137 player.CanLoadCharacterAppearance = false
10138 loadcharacter()
10139 player.CharacterAdded:connect(loadcharacter)
10140 end
10141end
10142print("Loading camera module")
10143do
10144 local e = 2.718281828459045
10145 local pi = 3.141592653589793
10146 local tau = 2 * pi
10147 local sin = math.sin
10148 local ln = math.log
10149 local cos = math.cos
10150 local v3 = Vector3.new
10151 local cf = CFrame.new
10152 local angles = CFrame.Angles
10153 local nv = v3()
10154 local tan = math.tan
10155 local atan = math.atan
10156 local deg = pi / 180
10157 local wfc = game.WaitForChild
10158 camera.currentcamera = game.Workspace.CurrentCamera
10159 camera.type = "firstperson"
10160 camera.sensitivity = 1
10161 camera.sensitivitymult = 1
10162 camera.aimsensitivity = 1
10163 camera.controllermult = 1
10164 camera.basefov = 80
10165 camera.target = utility.waitfor(game:GetService("Players").LocalPlayer.Character, 10, "Torso")
10166 camera.offset = v3(0, 1.5, 0)
10167 camera.angles = nv
10168 camera.maxangle = 0.46875 * pi
10169 camera.minangle = -0.46875 * pi
10170 camera.basecframe = cf()
10171 camera.shakecframe = cf()
10172 camera.cframe = cf()
10173 camera.lookvector = v3(0, 0, -1)
10174 camera.shakespring = physics.spring.new(nv)
10175 camera.magspring = physics.spring.new(0)
10176 camera.swayspring = physics.spring.new(0)
10177 camera.swayspeed = physics.spring.new(0)
10178 camera.delta = nv
10179 camera.onprerender = {}
10180 camera.onpostrender = {}
10181 camera.menufov = 60
10182 camera.spectatetype = "thirdperson"
10183 local ldt = 0.016666666666666666
10184 local didchange = false
10185 local killerpart, killer, killerstep, curlobby, lobbypart, lobbyfocus
10186 local fireonprerender = event.new(camera.onprerender)
10187 local fireonpostrender = event.new(camera.onpostrender)
10188 camera.shakespring.s = 12
10189 camera.shakespring.d = 0.65
10190 camera.magspring.s = 12
10191 camera.magspring.d = 1
10192 camera.swayspring.s = 4
10193 camera.swayspring.d = 1
10194 camera.swayspeed.s = 6
10195 camera.swayspeed.d = 1
10196 camera.swayspeed.t = 1
10197 camera.currentcamera.CameraType = "Scriptable"
10198 local suppressionspring = physics.spring.new(nv)
10199 suppressionspring.s = 32
10200 suppressionspring.d = 0.65
10201 local damagespring = physics.spring.new(nv)
10202 damagespring.s = 20
10203 damagespring.d = 0.75
10204 local followspring = physics.spring.new(nv)
10205 followspring.s = 16
10206 followspring.d = 0.75
10207 local accelspring = physics.spring.new(nv)
10208 accelspring.s = 10
10209 accelspring.d = 0.8
10210 local basetan = tan(45 * deg)
10211 local logtanspring = physics.spring.new(0)
10212 logtanspring.s = 30
10213 local menuspring = physics.spring.new(0)
10214 menuspring.s = 30
10215 local menucf = {
10216 c0 = cf(),
10217 c1 = cf()
10218 }
10219 function camera:setsensitivity(s)
10220 camera.sensitivity = s
10221 end
10222 function camera:setaimsensitivity(s)
10223 camera.sensitivitymult = s and camera.aimsensitivity or 1
10224 end
10225 function camera:shake(a)
10226 camera.shakespring:accelerate(a)
10227 end
10228 function camera:magnify(m)
10229 camera.magspring.t = ln(m)
10230 end
10231 function camera:suppress(a)
10232 suppressionspring:accelerate(a)
10233 end
10234 function camera:hit(d)
10235 local l = camera.cframe:vectorToObjectSpace(d)
10236 damagespring:accelerate(v3(l.z, 0, -l.x) * 0.25)
10237 end
10238 function camera:setmagnification(m)
10239 local lnm = ln(m)
10240 camera.magspring.p = lnm
10241 camera.magspring.t = lnm
10242 camera.magspring.v = 0
10243 end
10244 function camera:setmagnificationspeed(s)
10245 camera.magspring.s = s
10246 end
10247 function camera:setswayspeed(t)
10248 camera.swayspeed.t = t or 1
10249 end
10250 function camera:setsway(a)
10251 camera.swayspring.t = a
10252 end
10253 function camera:isspectating()
10254 return camera.type == "spectate" and killer and killerpart
10255 end
10256 function camera:setspectate(k, p)
10257 camera.type = "spectate"
10258 killer = k
10259 killerstep = replication.getupdater(k).step
10260 killerpart = p
10261 if k ~= p then
10262 local pcf = killerpart:GetRenderCFrame() * v3(1, 1, 6.5)
10263 followspring.t = pcf
10264 followspring.p = pcf
10265 followspring.v = nv
10266 effects:enablemapshaders(true)
10267 end
10268 end
10269 function camera:setfixedcam(cf)
10270 camera.type = "fixed"
10271 killerpart = cf
10272 end
10273 function camera:setmenucam(lobby)
10274 local charstage = wfc(lobby, "CharStage")
10275 local gunstage = wfc(lobby, "GunStage")
10276 camera.type = "menu"
10277 curlobby = lobby
10278 menucf.c0 = cf(charstage.CamPos.Position, charstage.Focus.Position)
10279 menucf.c1 = cf(gunstage.CamPos.Position, gunstage.Focus.Position)
10280 end
10281 function camera:setmenucf(ctype, stage)
10282 menucf[ctype] = cf(stage.CamPos.Position, stage.Focus.Position)
10283 end
10284 function camera:setmenufov(fov)
10285 logtanspring.t = fov
10286 end
10287 function camera:setmenuspring(t)
10288 menuspring.t = t
10289 end
10290 function camera:setfirstpersoncam()
10291 camera.type = "firstperson"
10292 camera.FieldOfView = camera.basefov
10293 end
10294 function camera:setlookvector(direction, delx, dely)
10295 didchange = true
10296 if delx and dely then
10297 local c, s = cos(tick()), sin(tick())
10298 delx, dely = c * delx - s * dely, s * delx + c * dely
10299 end
10300 local x, ay = vector.toanglesyx(direction)
10301 x = x + (delx or 0)
10302 ay = ay + (dely or 0)
10303 local cy = camera.angles.y
10304 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
10305 local y = (ay + pi - cy) % tau - pi + cy
10306 local newangles = v3(x, y, 0)
10307 camera.delta = (newangles - camera.angles) / ldt
10308 camera.angles = newangles
10309 end
10310 function camera:changemenufov(z)
10311 local newlogtan = logtanspring.t + z
10312 newlogtan = newlogtan < 0 and 0 or newlogtan < 3 and newlogtan or 3
10313 logtanspring.t = newlogtan
10314 end
10315 local screencull = {}
10316 camera.screencull = screencull
10317 do
10318 local tan = math.tan
10319 local deg = math.pi / 180
10320 local cf = CFrame.new
10321 local nc = cf()
10322 local ptos = nc.pointToObjectSpace
10323 local camcf, portsize, h, px, py, sx, sy, rscalex, rscaley
10324 function screencull.sphere(point, radius)
10325 local r = ptos(camcf, point)
10326 local rz = -r.z
10327 local rx = r.x
10328 local ry = r.y
10329 return -rz * sx < rx + rscalex * radius and rx - rscalex * radius < rz * sx and -rz * sy < ry + rscaley * radius and ry - rscaley * radius < rz * sy and rz > -radius, rz
10330 end
10331 function screencull.point(point)
10332 local r = ptos(camcf, point)
10333 local rz = -r.z
10334 local rx = r.x
10335 local ry = r.y
10336 return rx > -rz * sx and rx < rz * sx and ry > -rz * sy and ry < rz * sy
10337 end
10338 function screencull.update(newcamcf, newportsize, newfov)
10339 camcf = newcamcf
10340 portsize = newportsize
10341 h = newfov * deg / 2
10342 py = portsize.y
10343 px = portsize.x
10344 sy = tan(h)
10345 sx = px / py * sy
10346 rscaley = (1 + sy * sy) ^ 0.5
10347 rscalex = (1 + sx * sx) ^ 0.5
10348 end
10349 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.currentcamera.FieldOfView)
10350 end
10351 local swayt = 0
10352 function camera.step(dt)
10353 ldt = dt
10354 if not didchange then
10355 camera.delta = nv
10356 end
10357 didchange = false
10358 fireonprerender(camera)
10359 accelspring.t = char.acceleration
10360 if camera.type == "firstperson" then
10361 swayt = swayt + dt * camera.swayspeed.p
10362 local t = swayt
10363 local s, d = 0.5 * char.speed, char.distance * 6.28318 / 4 * 3 / 4
10364 local ss = camera.swayspring.p
10365 local cameraangles = angles(0, camera.angles.y, 0) * angles(camera.angles.x, 0, 0)
10366 camera.basecframe = cameraangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
10367 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)
10368 camera.shakecframe = shakeangles * cf(0, 0, 0.5) + char.rootpart.CFrame * v3(0, char.headheight, 0)
10369 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)
10370 local newfov = 2 * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / deg
10371 camera.currentcamera.FieldOfView = newfov
10372 camera.currentcamera.CoordinateFrame = cameracframe
10373 camera.cframe = cameracframe
10374 camera.lookvector = camera.cframe.lookVector
10375 screencull.update(cameracframe, camera.currentcamera.ViewportSize, newfov)
10376 elseif camera.type == "spectate" then
10377 if killer and killerstep and killer ~= game:GetService("Players").LocalPlayer and killerpart and hud:isplayeralive(killer) then
10378 killerstep(3, true)
10379 local pcf = killerpart:GetRenderCFrame()
10380 followspring.t = pcf * v3(1, 1, 6.5)
10381 if camera.spectatetype == "thirdperson" then
10382 local _, pos = sphereraycast(pcf.p, followspring.p - pcf.p, 1, killer.Character)
10383 pos = pos or followspring.p
10384 local angx, angy = vector.toanglesyx(pcf.lookVector)
10385 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0)
10386 if 0 > vector.dot(cameracframe * v3(1, 0, 0), cframe.vtws(pcf, v3(1, 0, 0))) then
10387 cameracframe = cameracframe * angles(0, 0, pi)
10388 end
10389 camera.currentcamera.CoordinateFrame = cameracframe * cf(0, 0, -0.5) + pos
10390 camera.cframe = cameracframe * cf(0, 0, -0.5) + pos
10391 camera.lookvector = camera.cframe.lookVector
10392 elseif camera.spectatetype == "firstperson" then
10393 local angx, angy = vector.toanglesyx(pcf.lookVector)
10394 local cameracframe = angles(0, angy, 0) * angles(angx, 0, 0) * cf(0, 0, -0.5) + pcf.p
10395 camera.currentcamera.CoordinateFrame = cameracframe
10396 camera.cframe = cameracframe
10397 camera.lookvector = cameracframe.lookVector
10398 end
10399 elseif not hud:isplayeralive(killer) then
10400 killer = nil
10401 killerpart = nil
10402 if char.deadcf then
10403 camera:setfixedcam(char.deadcf)
10404 end
10405 end
10406 camera.currentcamera.FieldOfView = camera.basefov
10407 screencull.update(camera.currentcamera.CFrame, camera.currentcamera.ViewportSize, camera.basefov)
10408 elseif camera.type == "fixed" then
10409 if killerpart then
10410 local cameracframe = killerpart * CFrame.new(0, 1, 2)
10411 camera.currentcamera.CoordinateFrame = cameracframe
10412 camera.cframe = cameracframe
10413 camera.lookvector = camera.cframe.lookVector
10414 end
10415 camera.currentcamera.FieldOfView = camera.basefov
10416 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
10417 elseif camera.type == "menu" then
10418 if curlobby then
10419 local cameracframe = cframe.interpolate(menucf.c0, menucf.c1, menuspring.p)
10420 camera.currentcamera.CoordinateFrame = cameracframe
10421 camera.cframe = cameracframe
10422 camera.lookvector = camera.cframe.lookVector
10423 end
10424 camera.currentcamera.FieldOfView = 2 / deg * atan(basetan / e ^ logtanspring.p)
10425 screencull.update(camera.cframe, camera.currentcamera.ViewportSize, camera.basefov)
10426 end
10427 fireonpostrender(camera)
10428 end
10429 input.mouse.onmousemove:connect(function(delta)
10430 didchange = true
10431 local coef = camera.sensitivity * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
10432 local x = camera.angles.x - coef * delta.y
10433 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
10434 local y = camera.angles.y - coef * delta.x
10435 local newangles = v3(x, y, 0)
10436 camera.delta = (newangles - camera.angles) / ldt
10437 camera.angles = newangles
10438 end)
10439 input.controller.onintegralmove:connect(function(delta, dt)
10440 didchange = true
10441 local coef = 3000 * delta.magnitude / dt * camera.sensitivity * camera.controllermult * camera.sensitivitymult * atan(tan(camera.basefov * deg / 2) / e ^ camera.magspring.p) / (32 * pi)
10442 local x = camera.angles.x + coef * delta.y
10443 x = x > camera.maxangle and camera.maxangle or x < camera.minangle and camera.minangle or x
10444 local y = camera.angles.y - coef * delta.x
10445 local newangles = v3(x, y, 0)
10446 camera.delta = (newangles - camera.angles) / ldt
10447 camera.angles = newangles
10448 end)
10449 input.mouse:hide()
10450 input.mouse:lockcenter()
10451 game:GetService("Players").LocalPlayer.CharacterAdded:connect(function()
10452 wait()
10453 input.mouse:hide()
10454 input.mouse:lockcenter()
10455 end)
10456end
10457replication_envext = {}
10458do
10459 local torsoaim = 0.5
10460 local tau = 2 * math.pi
10461 local e = 2.718281828459045
10462 local v3 = Vector3.new
10463 local nv = v3()
10464 local dot = nv.Dot
10465 local anglesyx = vector.anglesyx
10466 local cf = CFrame.new
10467 local angles = CFrame.Angles
10468 local direct = cframe.direct
10469 local jointleg = cframe.jointleg
10470 local jointarm = cframe.jointarm
10471 local new = Instance.new
10472 local nc = cf()
10473 local tos = nc.toObjectSpace
10474 local vtws = nc.vectorToWorldSpace
10475 local ptos = nc.pointToObjectSpace
10476 local vtos = nc.vectorToObjectSpace
10477 local ffc = game.FindFirstChild
10478 local localplayer = game:GetService("Players").LocalPlayer
10479 local forward = v3(0, 0, -1)
10480 local ray = Ray.new
10481 local raycast = workspace.FindPartOnRayWithIgnoreList
10482 local debris = game.Debris
10483 local lastsent = tick()
10484 local upinfos = {}
10485 local repstore = game.ReplicatedStorage
10486 local modulestore = game.ReplicatedStorage.GunModules
10487 local thirdpmstore = game.ReplicatedStorage.ExternalModels
10488 local stancecrouchcf = cframe.interpolator(cf(0, -0.125, 0), cf(0, -1, 0) * angles(-tau / 24, 0, 0))
10489 local crouchpronecf = cframe.interpolator(cf(0, -1, 0) * angles(-tau / 24, 0, 0), cf(0, -2, 0.5) * angles(-tau / 4, 0, 0))
10490 local materialhitsound = {
10491 Brick = "imp_concrete",
10492 Cobblestone = "imp_concrete",
10493 Concrete = "imp_concrete",
10494 CorrodedMetal = "imp_metal",
10495 DiamondPlate = "imp_metal",
10496 Fabric = "imp_grass",
10497 Foil = "imp_metal",
10498 Granite = "imp_concrete",
10499 Grass = "imp_grass",
10500 Ice = "imp_concrete",
10501 Marble = "imp_concrete",
10502 Metal = "imp_metal",
10503 Neon = "imp_concrete",
10504 Pebble = "imp_concrete",
10505 Plastic = "imp_metal",
10506 Sand = "imp_grass",
10507 Slate = "imp_concrete",
10508 SmoothPlastic = "imp_metal",
10509 Wood = "imp_wood",
10510 WoodPlanks = "imp_wood"
10511 }
10512 local function hitdist(center0, center1, radius, point)
10513 local dcenter = center1 - center0
10514 local len = dcenter.magnitude
10515 if len > 0 then
10516 local rel = center0 - point
10517 local y = dot(rel, dcenter) / len
10518 local dist2 = radius * radius + y * y - dot(rel, rel)
10519 if dist2 > 0 then
10520 local rdist = dist2 ^ 0.5 - y
10521 if rdist > 0 then
10522 return len / rdist, rdist - len
10523 else
10524 return 1
10525 end
10526 else
10527 return 1
10528 end
10529 else
10530 return 0
10531 end
10532 end
10533 local hittarget = function(center0, center1, radius)
10534 local dcenter = center1 - center0
10535 local len = dcenter.magnitude
10536 if len > 0 then
10537 return center1 + radius / len * dcenter
10538 else
10539 return center1
10540 end
10541 end
10542 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)
10543 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)
10544 local rand = math.random
10545 local function pickv3(v0, v1)
10546 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
10547 end
10548 local bodysize = {
10549 Head = v3(2, 1, 1),
10550 Torso = v3(2, 2, 1),
10551 HumanoidRootPart = v3(0.2, 0.2, 0.2),
10552 ["Left Arm"] = v3(1, 2, 1),
10553 ["Right Arm"] = v3(1, 2, 1),
10554 ["Left Leg"] = v3(1, 2, 1),
10555 ["Right Leg"] = v3(1, 2, 1)
10556 }
10557 local function raycastboxfast(origin, direction, cframe, size)
10558 local ro = ptos(cframe, origin)
10559 local rd = vtos(cframe, direction)
10560 local ox, oy, oz = ro.x, ro.y, ro.z
10561 local dx, dy, dz = rd.x, rd.y, rd.z
10562 local sx = 0.5 * size.x
10563 local sy = 0.5 * size.y
10564 local sz = 0.5 * size.z
10565 local x0, y0, z0 = -1 / 0, -1 / 0, -1 / 0
10566 local x1, y1, z1 = 1 / 0, 1 / 0, 1 / 0
10567 if dx < -1.0E-8 then
10568 x0 = (sx - ox) / dx
10569 x1 = (-sx - ox) / dx
10570 elseif dx > 1.0E-8 then
10571 x0 = (-sx - ox) / dx
10572 x1 = (sx - ox) / dx
10573 elseif ox < -sx or ox > sx then
10574 return nil, nil
10575 end
10576 if dy < -1.0E-8 then
10577 y0 = (sy - oy) / dy
10578 y1 = (-sy - oy) / dy
10579 elseif dy > 1.0E-8 then
10580 y0 = (-sy - oy) / dy
10581 y1 = (sy - oy) / dy
10582 elseif oy < -sy or oy > sy then
10583 return nil, nil
10584 end
10585 if dz < -1.0E-8 then
10586 z0 = (sz - oz) / dz
10587 z1 = (-sz - oz) / dz
10588 elseif dz > 1.0E-8 then
10589 z0 = (-sz - oz) / dz
10590 z1 = (sz - oz) / dz
10591 elseif oz < -sz or oz > sz then
10592 return nil, nil
10593 end
10594 local t0 = x0 < y0 and (y0 < z0 and z0 or y0) or x0 < z0 and z0 or x0
10595 local t1 = x1 < y1 and (x1 < z1 and x1 or z1) or y1 < z1 and y1 or z1
10596 if t0 > t1 then
10597 return nil, nil
10598 else
10599 return t0, t1
10600 end
10601 end
10602 local characterhash = {}
10603 local characterparts = {}
10604 local parts = {
10605 "head",
10606 "torso",
10607 "lleg",
10608 "rleg",
10609 "larm",
10610 "rarm"
10611 }
10612 local function setcharacterhash(person, bodyparts)
10613 if person.Character then
10614 for i, v in next, parts, nil do
10615 local object = bodyparts[v]
10616 if object then
10617 characterhash[object] = {
10618 object = object,
10619 bodypart = v,
10620 player = person,
10621 character = person.Character,
10622 bodyparts = bodyparts
10623 }
10624 end
10625 end
10626 end
10627 characterparts[person] = bodyparts
10628 end
10629 local function removecharacterhash(person)
10630 for i, v in next, characterhash, nil do
10631 if v.player == person then
10632 characterhash[i] = nil
10633 end
10634 end
10635 characterparts[person] = nil
10636 end
10637 function replication.getcharhitinfo(hit, pos, dir)
10638 local hitinfo = characterhash[hit]
10639 if hitinfo then
10640 local bodyparts = hitinfo.bodyparts
10641 for i = 1, #parts do
10642 local v = parts[i]
10643 local t0, t1 = raycastboxfast(pos, dir, bodyparts[v].CFrame, bodysize[bodyparts[v].Name] or v3(1, 1, 1))
10644 if t0 then
10645 return characterhash[bodyparts[v]]
10646 end
10647 end
10648 end
10649 end
10650 function replication.getbodyparts(player)
10651 return characterparts[player]
10652 end
10653 local function loadplayer(player, state)
10654 local wepmod = require(script.WepScriptRep)
10655 local ext_env = {}
10656 if botwrapper.isbot(player) then
10657 state = state or network:fetch("botstate", player)
10658 else
10659 state = state or network:fetch("s" .. "t" .. "a" .. "t" .. "e", player)
10660 end
10661 if not state or not state.bodyparts then
10662 return
10663 end
10664 if state.healthstate then
10665 hud.inializehealth(player, state.healthstate.alive)
10666 end
10667 ext_env.bodyparts = state.bodyparts
10668 ext_env.rootpart = ext_env.bodyparts.rootpart
10669 ext_env.torso = ext_env.bodyparts.torso
10670 ext_env.neck = ext_env.bodyparts.neck
10671 ext_env.head = ext_env.bodyparts.head
10672 if not (ext_env.rootpart and ext_env.torso and ext_env.neck and ext_env.bodyparts.lsh and ext_env.bodyparts.rsh and ext_env.bodyparts.lhip and ext_env.bodyparts.rhip and ext_env.bodyparts.larm and ext_env.bodyparts.rarm and ext_env.bodyparts.lleg and ext_env.bodyparts.rleg) or not ext_env.bodyparts.rootjoint then
10673 return
10674 end
10675 setcharacterhash(player, ext_env.bodyparts)
10676 trash.remove(ext_env.bodyparts.lsh)
10677 trash.remove(ext_env.bodyparts.rsh)
10678 trash.remove(ext_env.bodyparts.lhip)
10679 trash.remove(ext_env.bodyparts.rhip)
10680 local lsh = new("Motor6D", ext_env.torso)
10681 local rsh = new("Motor6D", ext_env.torso)
10682 local lhip = new("Motor6D", ext_env.torso)
10683 local rhip = new("Motor6D", ext_env.torso)
10684 lsh.Part0 = ext_env.torso
10685 rsh.Part0 = ext_env.torso
10686 lhip.Part0 = ext_env.torso
10687 rhip.Part0 = ext_env.torso
10688 lsh.Part1 = ext_env.bodyparts.larm
10689 rsh.Part1 = ext_env.bodyparts.rarm
10690 lhip.Part1 = ext_env.bodyparts.lleg
10691 rhip.Part1 = ext_env.bodyparts.rleg
10692 local self = {}
10693 self.ignore = ext_env.bodyparts
10694 local thread = sequencer.new()
10695 local weaponmodule, weapontype
10696 local weaponheadaimangle = 0
10697 local weaponsprintcf = nc
10698 local weapontransoffset = nc
10699 local weaponrotoffset = nc
10700 local weaponpivot = nc
10701 local weaponaimpivot = nc
10702 local weapondrawcf = nc
10703 local weaponlhold = v3(0, -1, 0)
10704 local weaponrhold = nv
10705 local weaponforward = v3(0, 0, -1)
10706 local weaponstabcf = nc
10707 local weapon
10708 local mainweld = new("Motor6D", ext_env.torso)
10709 mainweld.Part0 = ext_env.torso
10710 local equipspring = physics.spring.new()
10711 equipspring.s = 12
10712 equipspring.d = 0.8
10713 local aimspring = physics.spring.new(1)
10714 aimspring.s = 12
10715 local stabspring = physics.spring.new()
10716 stabspring.s = 20
10717 stabspring.d = 0.8
10718 local transkickspring = physics.spring.new(nv)
10719 local rotkickspring = physics.spring.new(nv)
10720 local stance
10721 local posspring = physics.spring.new(nv)
10722 posspring.s = 32
10723 local stancespring = physics.spring.new(0)
10724 stancespring.s = 4
10725 stancespring.d = 0.8
10726 local speedspring = physics.spring.new(0)
10727 speedspring.s = 8
10728 local sprintspring = physics.spring.new(1)
10729 sprintspring.s = 8
10730 local baseangle = 0
10731 local maxdangle = 0.5
10732 self.lookangles = physics.spring.new(nv)
10733 self.lookangles.s = 16
10734 self.lookangles.d = 0.75
10735 local muzzlespring = physics.spring.new(0)
10736 muzzlespring.s = 50
10737 muzzlespring.d = 1
10738 local stepradius = 1
10739 local rfoot = {
10740 makesound = true,
10741 center = nc,
10742 pos = nv,
10743 sdown = cf(0.5, -3, 0),
10744 pdown = cf(0.5, -2.75, 0),
10745 weld = rhip,
10746 hipcf = cf(0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
10747 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
10748 angm = 1,
10749 torsoswing = 0.1
10750 }
10751 local lfoot = {
10752 center = nc,
10753 pos = nv,
10754 sdown = cf(-0.5, -3, 0),
10755 pdown = cf(-0.5, -2.75, 0),
10756 weld = lhip,
10757 hipcf = cf(-0.5, -0.5, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0),
10758 legcf = cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0),
10759 angm = -1,
10760 torsoswing = -0.1
10761 }
10762 local p, l = rfoot, lfoot
10763 local firesound = new("Sound", ext_env.torso)
10764 local equalizer = new("EqualizerSoundEffect", firesound)
10765 equalizer.HighGain = 0
10766 equalizer.MidGain = 0
10767 equalizer.LowGain = 0
10768 local muzzlelight = repstore.Effects.MuzzleLight:Clone()
10769 local muzzlepart, soundid
10770 muzzlelight.Parent = ext_env.torso
10771 trash.remove(ext_env.bodyparts.rootjoint)
10772 ext_env.head.Transparency = 0
10773 if ffc(ext_env.head, "Mesh") then
10774 ext_env.head.Mesh:Destroy()
10775 repstore.Misc.Mesh:Clone().Parent = ext_env.head
10776 end
10777 ext_env.neck.C1 = nc
10778 self.rootpart = ext_env.rootpart
10779 self.torso = ext_env.torso
10780 function self.getlookangles()
10781 return self.lookangles.p
10782 end
10783 local function updatecalls()
10784 if not player.Character then
10785 return
10786 end
10787 for i, v in next, player.Character:GetChildren() do
10788 if v:IsA("BasePart") and bodysize[v.Name] then
10789 if v.Name == "HumanoidRootPart" then
10790 if v.Size ~= bodysize[v.Name] then
10791 if v.Size == v3(2, 2, 1) then
10792 v.Size = v3(0.2, 0.2, 0.2)
10793 else
10794 netkick("what happened")
10795 end
10796 end
10797 v.Changed:connect(function(prop)
10798 if (prop == "Size" or prop == "CanCollide") and v.Size ~= v3(2, 2, 1) and v.Size ~= v3(0.2, 0.2, 0.2) then
10799 netkick("something broke")
10800 end
10801 end)
10802 else
10803 if v.Size ~= bodysize[v.Name] then
10804 netkick("wow u smart")
10805 end
10806 do
10807 local origprops = {
10808 Size = v.Size,
10809 CanCollide = v.CanCollide
10810 }
10811 v.Changed:connect(function(prop)
10812 if prop == "Size" or prop == "CanCollide" then
10813 v[prop] = origprops[prop]
10814 end
10815 end)
10816 end
10817 end
10818 end
10819 end
10820 end
10821 function self.updatecharacter(state)
10822 if not (state.rootpart and lsh and rsh and lhip) or not rhip then
10823 return
10824 end
10825 ext_env.rootpart = state.rootpart
10826 self.rootpart = ext_env.rootpart
10827 if not firesound.Parent then
10828 firesound = new("Sound", ext_env.rootpart)
10829 end
10830 rfoot.ignore = {
10831 state.rootpart,
10832 state.torso,
10833 state.neck.Part1,
10834 state.larm,
10835 state.rarm,
10836 state.lleg,
10837 state.rleg
10838 }
10839 ext_env.head.Transparency = 0
10840 ext_env.torso = state.torso
10841 trash.remove(state.rootjoint)
10842 trash.remove(state.lsh)
10843 trash.remove(state.rsh)
10844 trash.remove(state.lhip)
10845 trash.remove(state.rhip)
10846 ext_env.neck = state.neck
10847 mainweld.Part0 = ext_env.torso
10848 mainweld.Parent = ext_env.torso
10849 ext_env.neck.C1 = nc
10850 lsh.Parent = ext_env.torso
10851 rsh.Parent = ext_env.torso
10852 lhip.Parent = ext_env.torso
10853 rhip.Parent = ext_env.torso
10854 lsh.Part0 = ext_env.torso
10855 rsh.Part0 = ext_env.torso
10856 lhip.Part0 = ext_env.torso
10857 rhip.Part0 = ext_env.torso
10858 lsh.Part1 = state.larm
10859 rsh.Part1 = state.rarm
10860 lhip.Part1 = state.lleg
10861 rhip.Part1 = state.rleg
10862 setcharacterhash(player, state)
10863 updatecalls()
10864 end
10865 local function weld3pm(model, camodata, data, repattach)
10866 local s1 = ffc(model, "Slot1")
10867 local s2 = ffc(model, "Slot2")
10868 if not s1 or not s2 then
10869 print("Incomplete third person model")
10870 return
10871 end
10872 for i, v in next, model:GetChildren() do
10873 if v:IsA("BasePart") then
10874 if v.Name == "Flame" then
10875 muzzlepart = v
10876 end
10877 if v ~= s1 then
10878 local weld = new("Weld", s1)
10879 weld.Part0 = s1
10880 weld.Part1 = v
10881 weld.C0 = s1.CFrame:inverse() * v.CFrame
10882 end
10883 if not effects.disable3pcamoskins and camodata and camodata[v.Name] and camodata[v.Name].Name ~= "" then
10884 local t = Instance.new("Texture")
10885 t.Name = v.Name
10886 t.Texture = "rbxassetid://" .. camodata[v.Name].TextureProperties.TextureId
10887 t.Transparency = camodata[v.Name].TextureProperties.Transparency
10888 t.StudsPerTileU = camodata[v.Name].TextureProperties.StudsPerTileU
10889 t.StudsPerTileV = camodata[v.Name].TextureProperties.StudsPerTileV
10890 t.OffsetStudsU = camodata[v.Name].TextureProperties.OffsetStudsU or 0
10891 t.OffsetStudsV = camodata[v.Name].TextureProperties.OffsetStudsV or 0
10892 for i = 0, v:IsA("MeshPart") and 5 or 0 do
10893 local tt = t:Clone()
10894 tt.Face = i
10895 tt.Parent = v
10896 end
10897 if camodata[v.Name].TextureProperties.Color then
10898 local colordata = camodata[v.Name].TextureProperties.Color
10899 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
10900 end
10901 if camodata[v.Name].BrickProperties.DefaultColor ~= true then
10902 local colordata = camodata[v.Name].BrickProperties.Color
10903 if colordata then
10904 v.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
10905 else
10906 v.BrickColor = BrickColor.new(camodata[v.Name].BrickProperties.BrickColor)
10907 end
10908 end
10909 if camodata[v.Name].BrickProperties.Material then
10910 v.Material = camodata[v.Name].BrickProperties.Material
10911 end
10912 if camodata[v.Name].BrickProperties.Reflectance then
10913 v.Reflectance = camodata[v.Name].BrickProperties.Reflectance
10914 end
10915 end
10916 v.Anchored = false
10917 v.CanCollide = false
10918 end
10919 end
10920 if repattach then
10921 for i, v in next, repattach, nil do
10922 local node = model:FindFirstChild(i .. "Node")
10923 if node then
10924 weldattachment(model, i, v, node, s1, {}, {}, {}, {})
10925 local parts = model:GetChildren()
10926 for i = 1, #parts do
10927 local pt = parts[i]
10928 if pt.Name == "LaserLight" then
10929 wepmod:addlaser(pt)
10930 end
10931 end
10932 end
10933 end
10934 end
10935 end
10936 function self.equipknife(module, newweapon, camodata)
10937 if module then
10938 thread:clear()
10939 if weapon then
10940 wepmod:deactivatelasers(true, weapon)
10941 equipspring.t = 0
10942 thread:add(function()
10943 return equipspring.p < 0
10944 end)
10945 thread:add(function()
10946 weapon.Slot1.Transparency = 1
10947 weapon.Slot2.Transparency = 1
10948 mainweld.Part1 = nil
10949 trash.remove(weapon)
10950 end)
10951 end
10952 thread:add(function()
10953 weaponmodule = module
10954 weapontype = "KNIFE"
10955 weapontransoffset = cf(module.offset3p.p)
10956 weaponrotoffset = module.offset3p - module.offset3p.p
10957 weaponpivot = module.pivot3p
10958 weapondrawcf = module.drawcf3p
10959 weaponforward = module.forward3p
10960 weaponsprintcf = module.sprintcf3p
10961 weaponlhold = module.lhold3p
10962 weaponrhold = module.rhold3p
10963 weaponstabcf = module.stabcf3p
10964 weapon = newweapon:Clone()
10965 weld3pm(weapon, camodata)
10966 weapon.Parent = ext_env.torso.Parent
10967 mainweld.Part1 = weapon.Slot1
10968 equipspring.t = 1
10969 end)
10970 end
10971 end
10972 function self.equip(module, newweapon, camodata, replicateattach)
10973 if module then
10974 thread:clear()
10975 if weapon then
10976 wepmod:deactivatelasers(true, weapon)
10977 equipspring.t = 0
10978 thread:add(function()
10979 return equipspring.p < 0
10980 end)
10981 thread:add(function()
10982 weapon.Slot1.Transparency = 1
10983 weapon.Slot2.Transparency = 1
10984 mainweld.Part1 = nil
10985 trash.remove(weapon)
10986 end)
10987 end
10988 thread:add(function()
10989 weaponmodule = module
10990 if weaponmodule.type == "KNIFE" then
10991 weapontype = "KNIFE"
10992 weapontransoffset = cf(module.offset3p.p)
10993 weaponrotoffset = module.offset3p - module.offset3p.p
10994 weaponpivot = module.pivot3p
10995 weapondrawcf = module.drawcf3p
10996 weaponforward = module.forward3p
10997 weaponsprintcf = module.sprintcf3p
10998 weaponlhold = module.lhold3p
10999 weaponrhold = module.rhold3p
11000 weaponstabcf = module.stabcf3p
11001 warn("Knife module loaded into main gun module: " .. weaponmodule.name)
11002 else
11003 weapontype = "gun"
11004 weapontransoffset = cf(module.offset3p.p)
11005 weaponrotoffset = module.offset3p - module.offset3p.p
11006 weaponpivot = module.pivot3p
11007 weapondrawcf = module.drawcf3p
11008 weaponforward = module.forward3p
11009 weaponheadaimangle = module.headaimangle3p or 0
11010 weaponsprintcf = module.sprintcf3p
11011 weaponaimpivot = module.aimpivot3p
11012 transkickspring.s = module.modelkickspeed
11013 transkickspring.d = module.modelkickdamper
11014 rotkickspring.s = module.modelkickspeed
11015 rotkickspring.d = module.modelkickdamper
11016 weaponlhold = module.lhold3p
11017 weaponrhold = module.rhold3p
11018 end
11019 weapon = newweapon:Clone()
11020 weld3pm(weapon, camodata, module, replicateattach)
11021 weapon.Parent = ext_env.torso.Parent
11022 mainweld.Part1 = weapon.Slot1
11023 equipspring.t = 1
11024 if firesound and module.firesoundid then
11025 firesound.SoundId = module.firesoundid
11026 firesound.Pitch = module.firepitch
11027 firesound.Volume = module.firevolume
11028 soundid = module.firesoundid
11029 end
11030 end)
11031 end
11032 end
11033 function self.getweaponpos()
11034 if muzzlepart then
11035 return muzzlepart.CFrame.p
11036 elseif weapon and weaponmodule then
11037 local c = weaponmodule.offset3p
11038 local r = c - c.p
11039 return weapon.Slot1.CFrame * r:inverse() * v3(0, 0, -2)
11040 else
11041 return ext_env.head.Position
11042 end
11043 end
11044 function self.stab()
11045 if weapon and weapontype == "KNIFE" then
11046 stabspring.a = 47
11047 end
11048 end
11049 local freesounds = {}
11050 function self.kickweapon(hide, pitch, volume)
11051 if weapon and weapontype == "gun" then
11052 do
11053 local aim = aimspring.p
11054 transkickspring:accelerate(pickv3(weaponmodule.transkickmin, weaponmodule.transkickmax))
11055 rotkickspring:accelerate(pickv3(weaponmodule.rotkickmin, weaponmodule.rotkickmax))
11056 local soundobject
11057 if #freesounds == 0 then
11058 soundobject = firesound:Clone()
11059 soundobject.Ended:connect(function()
11060 freesounds[#freesounds + 1] = soundobject
11061 end)
11062 else
11063 soundobject = freesounds[#freesounds]
11064 freesounds[#freesounds] = nil
11065 end
11066 if pitch then
11067 soundobject.Pitch = pitch
11068 end
11069 if volume then
11070 soundobject.Volume = volume
11071 end
11072 soundobject.SoundId = soundid
11073 soundobject.Parent = ext_env.torso
11074 local mufflemath = -(ext_env.torso.Position - camera.cframe.p).magnitude / 14.6484
11075 soundobject.EqualizerSoundEffect.HighGain = mufflemath
11076 soundobject.EqualizerSoundEffect.MidGain = mufflemath
11077 soundobject:Play()
11078 if not hide then
11079 muzzlespring:accelerate(125)
11080 end
11081 if muzzlepart then
11082 do
11083 local f3 = ffc(muzzlepart, "Smoke")
11084 if not hide then
11085 for _, flash in next, muzzlepart:GetChildren() do
11086 if flash ~= f3 and flash:IsA("ParticleEmitter") then
11087 flash.Enabled = true
11088 delay(0.05, function()
11089 flash.Enabled = false
11090 end)
11091 end
11092 end
11093 end
11094 f3.Enabled = true
11095 delay(0.1, function()
11096 f3.Enabled = false
11097 end)
11098 end
11099 end
11100 end
11101 end
11102 end
11103 function self.setsprint(sprint)
11104 sprintspring.t = sprint and 0 or 1
11105 end
11106 function self.setaim(aim)
11107 aimspring.t = aim and 0 or 1
11108 end
11109 function self.setstance(newstance)
11110 stance = newstance
11111 stancespring.t = newstance == "stand" and 0 or newstance == "crouch" and 0.5 or 1
11112 end
11113 function self.setlookangles(newlookangles)
11114 self.lookangles.t = newlookangles
11115 end
11116 local rootframes = {}
11117 function self.addrootframes(frames)
11118 local frame1 = frames[1]
11119 if frame1 then
11120 local t0 = frame1.t
11121 for i = 1, #rootframes do
11122 local rframe = rootframes[i]
11123 if t0 < rframe.t then
11124 for j = i, #rootframes do
11125 rootframes[j] = nil
11126 end
11127 break
11128 end
11129 end
11130 local n = #rootframes
11131 for i = 1, #frames do
11132 rootframes[n + i] = frames[i]
11133 end
11134 end
11135 end
11136 local lastt = tick()
11137 local lastp = nv
11138 local curcf = nc
11139 function self.getrootcf()
11140 local cf = ext_env.rootpart:GetRenderCFrame()
11141 cf = CFrame.Angles(0, baseangle, 0) + cf.p
11142 local v = ext_env.rootpart.Velocity
11143 local p1 = cf.p
11144 local t1 = tick()
11145 local iv = (p1 - lastp) / (t1 - lastt)
11146 lastp = p1
11147 lastt = t1
11148 if (iv - v).magnitude < 256 then
11149 curcf = cf
11150 return cf, v
11151 else
11152 return curcf, v
11153 end
11154 end
11155 local steplist = {}
11156 steplist.lastmainupdate = 0
11157 steplist.lastotherupdate = 0
11158 ext_env.velspring = physics.spring.new(nv)
11159 ext_env.velspring.s = 3
11160 steplist.remp = 0
11161 self.weprendered = false
11162 self.hud = hud
11163 function self.step(levelofdetail, renderwep)
11164 debug.profilebegin("rep char " .. levelofdetail .. " " .. player.Name)
11165 if not ext_env.rootpart.Parent or not ext_env.torso then
11166 debug.profileend()
11167 return
11168 end
11169 local rootcf, rootvel = self.getrootcf()
11170 if not self.hud:isplayeralive(player) then
11171 if 4 < (rootcf.p - ext_env.torso.CFrame.p).magnitude then
11172 ext_env.torso.CFrame = cf() + rootcf.p
11173 end
11174 debug.profileend()
11175 return
11176 end
11177 posspring.t = rootcf.p
11178 if (rootcf.p - posspring.p).magnitude > 16 then
11179 posspring.p = rootcf.p
11180 posspring.v = nv
11181 end
11182 ext_env.velspring.t = rootvel * v3(1, 0, 1)
11183 if weapon then
11184 if renderwep and not self.weprendered then
11185 weapon.Slot1.Transparency = 0
11186 weapon.Slot2.Transparency = 0
11187 self.weprendered = true
11188 elseif not renderwep and self.weprendered then
11189 weapon.Slot1.Transparency = 1
11190 weapon.Slot2.Transparency = 1
11191 self.weprendered = false
11192 end
11193 end
11194 if levelofdetail >= 1 then
11195 thread:step()
11196 rootcf = rootcf - rootcf.p + posspring.p
11197 local stancep = stancespring.p
11198 local sprintp = sprintspring.p
11199 local stancecf = stancep < 0.5 and stancecrouchcf(2 * stancep) or crouchpronecf(2 * stancep - 1)
11200 local look = self.lookangles.p
11201 local lookx = look.x
11202 local looky = look.y
11203 local maxd = sprintp * maxdangle
11204 baseangle = baseangle - looky < -maxd and looky - maxd or maxd < baseangle - looky and looky + maxd or baseangle
11205 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
11206 local pronep = stancep > 0.5 and 2 * stancep - 1 or 0
11207 stepradius = 0.5 * (1 - stancep) + 0.5 + (1 - sprintp) * 0.5
11208 local newpcenter = cframe.interpolate(rootcf * p.sdown, basecf * p.pdown, pronep)
11209 local newlcenter = cframe.interpolate(rootcf * l.sdown, basecf * l.pdown, pronep)
11210 local dist, rem = hitdist(p.center.p, newpcenter.p, stepradius, p.pos)
11211 steplist.remp = rem or steplist.remp
11212 local target = hittarget(l.center.p, newlcenter.p, stepradius)
11213 if dist < 1 then
11214 l.pos = (1 - dist) * (newlcenter * l.center:inverse() * l.pos) + dist * target
11215 p.center = newpcenter
11216 l.center = newlcenter
11217 else
11218 p.center = newpcenter
11219 l.center = newlcenter
11220 local dist = (camera.cframe.p - newlcenter.p).magnitude
11221 if l.ignore and l.makesound and dist < 128 then
11222 local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(newlcenter.p + v3(0, 1, 0), v3(0, -2.5, 0)), l.ignore)
11223 if hit then
11224 local soundfont = ({
11225 Brick = "concrete",
11226 Cobblestone = "concrete",
11227 Concrete = "concrete",
11228 CorrodedMetal = "metal",
11229 DiamondPlate = "metal",
11230 Fabric = "concrete",
11231 Foil = "metal",
11232 Granite = "concrete",
11233 Grass = "grass",
11234 Ice = "concrete",
11235 Marble = "concrete",
11236 Metal = "metal",
11237 Neon = "hardstep",
11238 Pebble = "concrete",
11239 Plastic = "metal",
11240 Sand = "sand",
11241 Slate = "concrete",
11242 SmoothPlastic = "metal",
11243 Wood = "wood",
11244 WoodPlanks = "wood"
11245 })[hit.Material.Name]
11246 if soundfont then
11247 replication_envext.volume = 0
11248 if player.TeamColor ~= localplayer.TeamColor then
11249 soundfont = "enemy_" .. soundfont
11250 replication_envext.volume = 4.47213595499958 / (dist / 5)
11251 else
11252 soundfont = "friendly_" .. soundfont
11253 replication_envext.volume = 1.4142135623730951 / (dist / 5)
11254 end
11255 if soundfont == "enemy_wood" then
11256 replication_envext.volume = 3.1622776601683795 / (dist / 5)
11257 end
11258 if speedspring.p <= 15 then
11259 soundfont = soundfont .. "walk"
11260 else
11261 soundfont = soundfont .. "run"
11262 end
11263 globalsound.play(soundfont, replication_envext.volume, 1, ext_env.torso)
11264 end
11265 end
11266 end
11267 p.pos = newpcenter.p + stepradius * (p.pos - newpcenter.p).unit
11268 l.pos = target
11269 p, l = l, p
11270 end
11271 if levelofdetail >= 2 and camera.screencull.sphere(camera.cframe.p, 6) then
11272 local accel = ext_env.velspring.v
11273 local equipp = equipspring.p
11274 local aim = anglesyx(lookx, looky)
11275 speedspring.t = rootvel.magnitude / loltimescale
11276 local speedp = speedspring.p / 8
11277 speedp = speedp < 1 and speedp or 1
11278 local raise = steplist.remp * (2 - steplist.remp / stepradius)
11279 raise = raise < 0 and 0 or raise
11280 local torsocf = direct(basecf, forward, aim, torsoaim * sprintp * (1 - stancep) * equipp) * angles(0, raise * p.torsoswing, 0) * cf(0, -3, 0)
11281 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)
11282 self.torsocf = torsocf
11283 ext_env.torso.CFrame = torsocf
11284 if levelofdetail >= 3 then
11285 p.weld.C0 = jointleg(1, 1.5, p.hipcf, torsocf:inverse() * p.pos, pronep * tau / 5 * p.angm) * p.legcf
11286 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
11287 local aimp = aimspring.p
11288 local neckcf = torsocf:inverse() * direct(torsocf * cf(0, 0.825, 0), forward, aim) * angles(0, 0, (1 - aimp) * weaponheadaimangle) * cf(0, 0.675, 0)
11289 ext_env.neck.C0 = neckcf
11290 if muzzlelight then
11291 muzzlelight.Brightness = muzzlespring.p
11292 end
11293 if weapon then
11294 if weapontype == "gun" then
11295 local pivot = cframe.interpolate(weaponaimpivot, weaponpivot, aimp)
11296 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * cf(transkickspring.p) * cframe.fromaxisangle(rotkickspring.p) * weaponrotoffset
11297 local guncf = cframe.interpolate(weapondrawcf, angles(raise / 10, raise * p.torsoswing, 0) * cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
11298 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
11299 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
11300 mainweld.C0 = guncf
11301 elseif weapontype == "KNIFE" then
11302 local pivot = weaponpivot
11303 local aimedguncf = torsocf:inverse() * direct(torsocf * pivot, forward, aim) * weapontransoffset * weaponrotoffset * cframe.interpolate(nc, weaponstabcf, stabspring.p)
11304 local guncf = cframe.interpolate(weapondrawcf, cframe.interpolate(weaponsprintcf, aimedguncf, sprintp), equipp)
11305 if weaponmodule.dualhand then
11306 lsh.C0 = jointarm(1, 1.5, leftshcf, guncf * weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
11307 else
11308 lsh.C0 = jointarm(1, 1.5, leftshcf, weaponlhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
11309 end
11310 rsh.C0 = jointarm(1, 1.5, rightshcf, guncf * weaponrhold) * cf(0, 0, -0.5, 1, 0, 0, 0, 0, -1, 0, 1, 0)
11311 mainweld.C0 = guncf
11312 end
11313 end
11314 end
11315 end
11316 end
11317 debug.profileend()
11318 end
11319 if state.lookangles then
11320 self.setlookangles(state.lookangles)
11321 end
11322 if state.stance then
11323 self.setstance(state.stance)
11324 end
11325 if state.sprint then
11326 self.setsprint(state.sprint)
11327 end
11328 if state.aim then
11329 self.setaim(state.aim)
11330 end
11331 if state.weapon then
11332 local module = ffc(modulestore, state.weapon)
11333 local newweapon = ffc(thirdpmstore, state.weapon)
11334 if module and newweapon then
11335 self.equip(require(module), newweapon)
11336 else
11337 print("Couldn't find a 3rd person weapon")
11338 end
11339 end
11340 return self
11341 end
11342 local function getupdater(player)
11343 if player and upinfos then
11344 if upinfos[player] == nil then
11345 upinfos[player] = false
11346 local updater = loadplayer(player)
11347 if updater then
11348 upinfos[player] = {
11349 updater = updater,
11350 player = player,
11351 lastupdate = 0,
11352 lastlevel = 0
11353 }
11354 return updater
11355 else
11356 upinfos[player] = nil
11357 return nil
11358 end
11359 elseif upinfos[player] ~= false then
11360 return upinfos[player].updater
11361 end
11362 end
11363 end
11364 replication.getupdater = getupdater
11365 network:add("stance", function(player, stance)
11366 local updater = getupdater(player)
11367 if updater then
11368 updater.setstance(stance)
11369 end
11370 end)
11371 network:add("sprint", function(player, sprint)
11372 local updater = getupdater(player)
11373 if updater then
11374 updater.setsprint(sprint)
11375 end
11376 end)
11377 network:add("lookangles", function(player, lookangles)
11378 local updater = getupdater(player)
11379 if updater then
11380 updater.setlookangles(lookangles)
11381 end
11382 end)
11383 network:add("aim", function(player, aim)
11384 local updater = getupdater(player)
11385 if updater then
11386 updater.setaim(aim)
11387 end
11388 end)
11389 network:add("stab", function(player)
11390 local updater = getupdater(player)
11391 if updater then
11392 updater.stab()
11393 end
11394 end)
11395 network:add("bodyparts", function(player, bodyparts)
11396 local updater = getupdater(player)
11397 if updater then
11398 updater.updatecharacter(bodyparts)
11399 end
11400 end)
11401 network:add("equipknife", function(player, weapon, camodata)
11402 local updater = getupdater(player)
11403 if updater then
11404 local module = ffc(modulestore, weapon)
11405 local newweapon = ffc(thirdpmstore, weapon)
11406 if module and newweapon then
11407 updater.equipknife(require(module), newweapon:Clone(), camodata)
11408 else
11409 updater.equipknife(nil)
11410 end
11411 end
11412 end)
11413 network:add("equip", function(player, weapon, camodata, attachments)
11414 local updater = getupdater(player)
11415 if updater then
11416 local replicatedattach
11417 if attachments then
11418 local attachinfo = require(game:GetService("ReplicatedStorage").AttachmentModules.Info)
11419 for i, v in next, attachments, nil do
11420 if attachinfo[v] and attachinfo[v].replicate then
11421 replicatedattach = {}
11422 replicatedattach[i] = v
11423 end
11424 end
11425 end
11426 local module = ffc(modulestore, weapon)
11427 local newweapon = ffc(thirdpmstore, weapon)
11428 if module and newweapon then
11429 updater.equip(require(module), newweapon:Clone(), camodata, replicatedattach)
11430 else
11431 updater.equip(nil)
11432 end
11433 end
11434 end)
11435 network:add("rootframes", function(player, newframes)
11436 local updater = getupdater(player)
11437 if updater then
11438 updater.addrootframes(newframes)
11439 end
11440 end)
11441 network:add("newparticle", function(props)
11442 particle.new(props)
11443 end)
11444 network:add("getclientteam", function(servercolor)
11445 local clientcolor = localplayer.TeamColor
11446 network:send("g" .. "e" .. "t" .. "c" .. "l" .. "i" .. "e" .. "n" .. "t" .. "t" .. "e" .. "a" .. "m", localplayer, clientcolor)
11447 end)
11448 local dot = Vector3.new().Dot
11449 network:add("newgrenade", function(player, grenade, grenadeanim)
11450 if not run.onstep then
11451 return
11452 end
11453 local data = require(game.ReplicatedStorage.GunModules[grenade])
11454 local flyingnade = game.ReplicatedStorage.GunModels[grenade].Trigger:Clone()
11455 local ignorelist = {
11456 camera.currentcamera,
11457 char.character,
11458 workspace.Ignore
11459 }
11460 local lasttrailt = 0
11461 local lasttrailpos = nv
11462 local offset = nv
11463 local lastbounce, exploded
11464 local indicator = ffc(flyingnade, "Indicator")
11465 flyingnade.Parent = camera.currentcamera
11466 flyingnade.Anchored = true
11467 flyingnade.Trail.Enabled = true
11468 if indicator then
11469 if player.TeamColor ~= localplayer.TeamColor then
11470 indicator.Enemy.Visible = true
11471 else
11472 indicator.Friendly.Visible = true
11473 end
11474 end
11475 local GrenadeTypes = {
11476 Frag = function(position)
11477 local range = player:DistanceFromCharacter(position)
11478 if ffc(flyingnade, "Fire") then
11479 if range <= 50 then
11480 sound.play("fragClose", 2, 1, flyingnade, true)
11481 elseif range <= 200 then
11482 sound.play("fragMed", 3, 1, flyingnade, true)
11483 elseif range > 200 then
11484 sound.play("fragFar", 3, 1, flyingnade, true)
11485 end
11486 end
11487 local Explosion = new("Explosion")
11488 Explosion.Position = position
11489 Explosion.BlastRadius = data.blastradius
11490 Explosion.BlastPressure = 0
11491 Explosion.DestroyJointRadiusPercent = 0
11492 Explosion.Parent = workspace
11493 end,
11494 Smoke = function(position)
11495 print("whoosh")
11496 local maxgrowth = UDim2.new(20, 0, 20, 0)
11497 local growthfactor = 5
11498 local time = 20
11499 for i = 1, 35 do
11500 do
11501 local smoke = repstore:FindFirstChild("Effects"):FindFirstChild("SmokeTest"):Clone()
11502 local billboard = smoke:FindFirstChild("BillboardGui")
11503 local images = billboard:GetChildren()
11504 local vel = vector.random(0.5, 1.5)
11505 vel = vel + v3(0, 2, 0)
11506 smoke.Parent = workspace:FindFirstChild("Ignore")
11507 particle.new({
11508 position = position,
11509 cancollide = true,
11510 particlesonly = true,
11511 nopenetration = true,
11512 velocity = vel,
11513 acceleration = v3(0, -0.25, 0),
11514 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
11515 if not self.stopmotion then
11516 local vel = self.velocity
11517 local newpos = pos + 0.1 * norm
11518 local nvel = norm:Dot(vel) * norm
11519 self.position = newpos
11520 self.velocity = -nvel
11521 if nvel.magnitude < 0.2 then
11522 self.stopmotion = true
11523 end
11524 end
11525 end,
11526 onstep = function(part, dt)
11527 if billboard and billboard.Size.X.Scale < maxgrowth.X.Scale and billboard.Size.Y.Scale < maxgrowth.Y.Scale then
11528 billboard.Size = billboard.Size + UDim2.new(growthfactor * dt, 0, growthfactor * dt, 0)
11529 for i, image in next, images, nil do
11530 if image and 0 < image.ImageTransparency then
11531 image.ImageTransparency = image.ImageTransparency - 1.5 * dt
11532 end
11533 end
11534 end
11535 smoke.Position = part.position
11536 end,
11537 onremove = function()
11538 spawn(function()
11539 local disconnect
11540 disconnect = run.onstep:connect(function(dt)
11541 if billboard and billboard.Size.X.Scale > 0 and 0 < billboard.Size.Y.Scale then
11542 billboard.Size = billboard.Size - UDim2.new(growthfactor * 2 * dt, 0, growthfactor * 2 * dt, 0)
11543 for i, image in next, images, nil do
11544 if image and image.ImageTransparency < 1 then
11545 image.ImageTransparency = image.ImageTransparency + 3 * dt
11546 end
11547 end
11548 else
11549 disconnect()
11550 smoke:Destroy()
11551 end
11552 end)
11553 end)
11554 end,
11555 life = time
11556 })
11557 end
11558 end
11559 end
11560 }
11561 local function explode(position)
11562 GrenadeTypes[data.grenadetype and GrenadeTypes[data.grenadetype] and data.grenadetype or "Frag"](position)
11563 trash.remove(flyingnade)
11564 end
11565 local st = grenadeanim.time
11566 local dst = st - tick()
11567 local lasttime = st
11568 local lastparticle = tick()
11569 local stop
11570 stop = run.onstep:connect(function(dt)
11571 local realtime = tick()
11572 local time = realtime + dst * (st + grenadeanim.blowuptime - realtime) / (grenadeanim.blowuptime + dst)
11573 if flyingnade and grenadeanim then
11574 local i = grenadeanim.curi
11575 local frames = grenadeanim.frames
11576 local frame = frames[i]
11577 local nextframe = frames[i + 1]
11578 if nextframe and time > st + nextframe.t0 then
11579 grenadeanim.curi = i + 1
11580 frame = nextframe
11581 end
11582 local t = time - (st + frame.t0)
11583 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
11584 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
11585 local glassbreaks = frame.glassbreaks
11586 for j = 1, #glassbreaks do
11587 local glassbreak = glassbreaks[j]
11588 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
11589 effects:breakwindow(glassbreak.part, nil, nil, v3(), true, true)
11590 end
11591 end
11592 flyingnade.CFrame = rot + pos
11593 if indicator then
11594 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
11595 end
11596 if time > st + grenadeanim.blowuptime then
11597 explode(pos)
11598 stop()
11599 end
11600 end
11601 lasttime = time
11602 end)
11603 return stop
11604 end)
11605 local lastid = 0
11606 local suppressionmult, normalizesuppression
11607 do
11608 local max = 1.25
11609 local min = 0.5
11610 local recspeed = 1
11611 local normspeed = 0.125
11612 local e = 2.718281828459045
11613 local sm0 = max
11614 local t0 = tick()
11615 function suppressionmult()
11616 local t = tick() - t0
11617 return e ^ (-t / recspeed) * (max - sm0) + sm0
11618 end
11619 function normalizesuppression()
11620 local sm = suppressionmult()
11621 sm0 = (sm - min) / e ^ normspeed + min
11622 t0 = tick()
11623 end
11624 end
11625 network:add("newbullet", function(data)
11626 local shottime = data.shottime
11627 local loadbalanced = data.loadbalanced
11628 local player = data.player
11629 local position = data.firepos
11630 local velocity = data.velocity
11631 local pitch = data.pitch
11632 local volume = data.volume
11633 local id = data.id
11634 local bulletcolor = data.bulletcolor
11635 local penetrationdepth = data.penetrationdepth
11636 local suppression = data.suppression
11637 local hideflash = data.hideflash
11638 local hideminimap = data.hideminimap
11639 local hiderange = data.hiderange
11640 local pingdata = data.pingdata
11641 local updater = getupdater(player)
11642 if updater and id ~= lastid then
11643 updater.kickweapon(hideflash, pitch, volume)
11644 lastid = id
11645 end
11646 if not hideminimap or hideminimap and hiderange > (position - camera.cframe.p).Magnitude then
11647 hud:fireradar(player, hideminimap, pingdata)
11648 end
11649 local physignore = {
11650 camera.currentcamera,
11651 workspace.Ignore
11652 }
11653 for i, v in next, botwrapper.getbasehumanoids() do
11654 if v.TeamColor == player.TeamColor then
11655 physignore[#physignore + 1] = v.Character
11656 end
11657 end
11658 particle.new({
11659 position = position,
11660 velocity = velocity,
11661 acceleration = lolgravity,
11662 physicsignore = physignore,
11663 color = bulletcolor,
11664 size = 0.2,
11665 bloom = 0.005,
11666 brightness = 400,
11667 life = 1,
11668 visualorigin = updater and updater.getweaponpos(),
11669 penetrationdepth = penetrationdepth,
11670 thirdperson = true,
11671 onstep = function(part, dt)
11672 if player.TeamColor ~= localplayer.TeamColor then
11673 local vel = part.velocity
11674 local dpos = dt * vel
11675 local pos = part.position - dpos
11676 local headpos = camera.cframe.p
11677 local d = dot(headpos - pos, dpos) / dot(dpos, dpos)
11678 if d > 0 and d < 1 then
11679 local dist = (pos + d * dpos - headpos).magnitude
11680 dist = dist < 2 and 2 or dist
11681 local s = suppressionmult() * suppression / (512 * dist) * vel.magnitude
11682 network:send("suppressionassist", player, s)
11683 if dist < 128 then
11684 if vel.magnitude > 2900 then
11685 sound.play("crackBig", 16 / dist)
11686 elseif dist <= 2 then
11687 sound.play("crackSmall", 8)
11688 else
11689 sound.play("whizz", 2 / dist)
11690 end
11691 end
11692 camera:suppress(vector.random(s, s))
11693 normalizesuppression()
11694 end
11695 end
11696 end,
11697 ontouch = function(self, hit, pos, norm, exit, exitnorm, power, human)
11698 if hit.Anchored and hit.CanCollide then
11699 if hit.Name == "Window" then
11700 effects:breakwindow(hit, pos, norm, self.velocity, v3(), true)
11701 end
11702 effects:bullethit(hit, pos, norm, exit, exitnorm, v3(), true, true)
11703 end
11704 if loadbalanced and (human and human ~= player or hit:IsDescendantOf(localplayer.Character)) then
11705 network:send("bullethit", loadbalanced, pos, hit, shottime)
11706 end
11707 local dist = (pos - camera.cframe.p).magnitude
11708 local soundfont = materialhitsound[hit.Material.Name]
11709 if dist < 64 and soundfont then
11710 sound.play(soundfont, 3 / dist)
11711 end
11712 end
11713 })
11714 end)
11715 local rendert = {}
11716 local nextcast = tick()
11717 local castrate = 10
11718 local radius = 4
11719 local ptos = CFrame.new().pointToObjectSpace
11720 local tan = math.tan
11721 local pi = math.pi
11722 local radius = 6
11723 function replication.playerangles(player)
11724 local updater = getupdater(player)
11725 if updater then
11726 return updater.getlookangles()
11727 else
11728 return v3()
11729 end
11730 end
11731 local highms = 2
11732 local lowms = 1
11733 function replication.sethighms(val)
11734 highms = val
11735 end
11736 function replication.setlowms(val)
11737 lowms = val
11738 end
11739 function replication.step(dt)
11740 local time = tick()
11741 local orderedupdaters = {}
11742 for player, upinfo in next, upinfos, nil do
11743 if player.Parent then
11744 if upinfo and upinfo.updater then
11745 orderedupdaters[#orderedupdaters + 1] = upinfo
11746 else
11747 end
11748 else
11749 print("PLAYER IS GONE")
11750 upinfos[player] = nil
11751 removecharacterhash(player)
11752 end
11753 end
11754 for i = 1, #orderedupdaters do
11755 local upinfo = orderedupdaters[i]
11756 local updater = upinfo.updater
11757 if updater and updater.rootpart and updater.torso then
11758 local pos = updater.rootpart:GetRenderCFrame().p
11759 upinfo.onscreen = camera.screencull.sphere(pos, radius)
11760 else
11761 upinfo.onscreen = false
11762 end
11763 end
11764 table.sort(orderedupdaters, function(a, b)
11765 if a.onscreen == b.onscreen then
11766 if a.lastlevel == b.lastlevel then
11767 return a.lastlevel < b.lastlevel
11768 else
11769 return a.lastupdate < b.lastupdate
11770 end
11771 else
11772 return a.onscreen
11773 end
11774 end)
11775 local start0 = tick()
11776 local n = 0
11777 while n < #orderedupdaters and tick() - start0 < highms / 1000 do
11778 n = n + 1
11779 if orderedupdaters[n].onscreen then
11780 orderedupdaters[n].updater.step(3, true)
11781 orderedupdaters[n].lastupdate = time
11782 orderedupdaters[n].lastlevel = 3
11783 else
11784 n = n - 1
11785 break
11786 end
11787 end
11788 while n < #orderedupdaters and tick() - start0 < (highms + lowms) / 1000 do
11789 n = n + 1
11790 orderedupdaters[n].updater.step(2, true)
11791 orderedupdaters[n].lastupdate = time
11792 orderedupdaters[n].lastlevel = 2
11793 end
11794 for i = n + 1, #orderedupdaters do
11795 if 2 * (highms + lowms) / 1000 < tick() - start0 then
11796 break
11797 end
11798 orderedupdaters[i].updater.step(1, false)
11799 orderedupdaters[i].lastupdate = time
11800 orderedupdaters[n].lastlevel = 1
11801 end
11802 if time - lastsent > 0.05 and 0 < char.health then
11803 lastsent = time
11804 network:send("l" .. "o" .. "o" .. "k" .. "a" .. "n" .. "g" .. "l" .. "e" .. "s", camera.angles)
11805 end
11806 end
11807 local players = game:GetService("Players"):GetPlayers()
11808 for i = 1, #players do
11809 local player = players[i]
11810 if player ~= localplayer then
11811 getupdater(player)
11812 end
11813 end
11814end
11815print("Requiring menu module")
11816require(script.Parent.UIScript)({
11817 vector = vector,
11818 cframe = cframe,
11819 network = network,
11820 playerdata = playerdata,
11821 trash = trash,
11822 utility = utility,
11823 event = event,
11824 sequencer = sequencer,
11825 physics = physics,
11826 particle = particle,
11827 sound = sound,
11828 effects = effects,
11829 tween = tween,
11830 animation = animation,
11831 input = input,
11832 char = char,
11833 camera = camera,
11834 chat = chat,
11835 hud = hud,
11836 notify = notify,
11837 leaderboard = leaderboard,
11838 replication = replication,
11839 menu = menu,
11840 roundsystem = roundsystem,
11841 run = run,
11842 gamelogic = gamelogic,
11843 timemod = timemod,
11844 botwrapper = botwrapper,
11845 updateversion = updateversion,
11846 updatemsg = updatemsg
11847})
11848print("Loading roundsystem module client")
11849wait(0.03333333333333333)
11850print("waiting beginning")
11851do
11852 local rtype = game.IsA
11853 local next = next
11854 local new = Instance.new
11855 local wfc = game.WaitForChild
11856 local ffc = game.FindFirstChild
11857 local getchildren = game.GetChildren
11858 local workspace = game.Workspace
11859 local cf = CFrame.new
11860 local vtws = CFrame.new().vectorToWorldSpace
11861 local angles = CFrame.Angles
11862 local ud2 = UDim2.new
11863 local color = Color3.new
11864 local bcolor = BrickColor.new
11865 local v3 = Vector3.new
11866 local debris = game:GetService("Debris")
11867 local guiservice = game:GetService("GuiService")
11868 local ray = Ray.new
11869 local raycast = workspace.FindPartOnRayWithIgnoreList
11870 local ceil = math.ceil
11871 local floor = math.floor
11872 local repstore = wfc(game, "ReplicatedStorage")
11873 local settings = wfc(repstore, "ServerSettings")
11874 local countdown = wfc(settings, "Countdown")
11875 local timer = wfc(settings, "Timer")
11876 local maxscore = wfc(settings, "MaxScore")
11877 local gscore = wfc(settings, "GhostScore")
11878 local pscore = wfc(settings, "PhantomScore")
11879 local showresult = wfc(settings, "ShowResults")
11880 local setquote = wfc(settings, "Quote")
11881 local winner = wfc(settings, "Winner")
11882 local gamemode = wfc(settings, "GameMode")
11883 local player = game:GetService("Players").LocalPlayer
11884 local pgui = wfc(player, "PlayerGui")
11885 local main = wfc(pgui, "MainGui")
11886 local countfr = wfc(main, "CountDown")
11887 local teamname = wfc(countfr, "TeamName")
11888 local title = wfc(countfr, "Title")
11889 local number = wfc(countfr, "Number")
11890 local tip = wfc(countfr, "Tip")
11891 local gamegui = wfc(main, "GameGui")
11892 local roundfr = wfc(gamegui, "Round")
11893 local scorefr = wfc(roundfr, "Score")
11894 local roundmode = wfc(roundfr, "GameMode")
11895 local ghostfr = wfc(scorefr, "Ghosts")
11896 local phantomfr = wfc(scorefr, "Phantoms")
11897 local counting = wfc(scorefr, "Time")
11898 local endfr = wfc(main, "EndMatch")
11899 local quote = wfc(endfr, "Quote")
11900 local result = wfc(endfr, "Result")
11901 local gmode = wfc(endfr, "Mode")
11902 local servertime = 0
11903 local lasttime = 0
11904 roundsystem.lock = false
11905 local killzone = v3()
11906 local killzonedb
11907 function roundsystem:updatekillzone(map)
11908 local killpart = ffc(map, "Killzone")
11909 killzonedb = false
11910 if killpart then
11911 killzone = killpart.Position
11912 else
11913 killzone = v3()
11914 end
11915 end
11916 function roundsystem:checkkillzone(rootpart, pos)
11917 if pos.Y < killzone.Y and not killzonedb then
11918 killzonedb = true
11919 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -100, "F" .. "a" .. "l" .. "l" .. "i" .. "n" .. "g", rootpart, pos, pos + v3(0, 1000, 0))
11920 end
11921 end
11922 local function spawnplayer()
11923 menu:roundstartspawn()
11924 end
11925 local tweentransparency = function(obj, index, new, t)
11926 spawn(function()
11927 local cur = obj[index]
11928 for i = cur, new + t, t do
11929 obj[index] = i
11930 wait(0.03333333333333333)
11931 end
11932 end)
11933 end
11934 function hud:updateteam()
11935 roundmode.Text = gamemode.Value
11936 if player.TeamColor == game.Teams.Phantoms.TeamColor then
11937 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
11938 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
11939 else
11940 phantomfr.Position = ud2(0.5, -48, 0, input.consoleon and 65 or 44)
11941 ghostfr.Position = ud2(0.5, -48, 0, input.consoleon and 35 or 28)
11942 end
11943 end
11944 local function updatescore()
11945 local ud2 = UDim2.new
11946 ghostfr.Percent.Size = ud2(gscore.Value / maxscore.Value, 0, 1, 0)
11947 ghostfr.Point.Text = gscore.Value
11948 phantomfr.Percent.Size = ud2(pscore.Value / maxscore.Value, 0, 1, 0)
11949 phantomfr.Point.Text = pscore.Value
11950 end
11951 local function count()
11952 roundsystem.lock = true
11953 tip.Text = input.consoleon and "Press ButtonSelect to return to menu" or "Press F5 to return to menu"
11954 if timer.Value ~= 10 or not menu:isdeployed() then
11955 end
11956 if menu:isdeployed() and char.health and char.health > 0 then
11957 teamname.Text = player.TeamColor == game.Teams.Ghosts.TeamColor and "Ghosts" or "Phantoms"
11958 teamname.Visible = true
11959 teamname.TextColor3 = player.TeamColor.Color
11960 countfr.Visible = true
11961 number.FontSize = 9
11962 number.Text = timer.Value
11963 for i = 9, 7, -1 do
11964 number.FontSize = i
11965 wait(0.03333333333333333)
11966 end
11967 if timer.Value == 0 then
11968 wait(1)
11969 roundsystem.lock = false
11970 wait(2)
11971 countfr.Visible = false
11972 else
11973 countfr.BackgroundTransparency = 0.5
11974 number.TextTransparency = 0
11975 title.TextTransparency = 0
11976 title.TextStrokeTransparency = 0.5
11977 end
11978 end
11979 end
11980 local function matchclock()
11981 local seconds = timer.Value % 60
11982 if seconds < 10 then
11983 seconds = "0" .. seconds
11984 end
11985 counting.Text = floor(timer.Value / 60) .. ":" .. seconds
11986 end
11987 local function timerchange()
11988 if countdown.Value then
11989 counting.Text = "COUNTDOWN"
11990 count()
11991 else
11992 if not showresult.Value then
11993 roundsystem.lock = false
11994 end
11995 countfr.Visible = false
11996 matchclock()
11997 end
11998 end
11999 local function setresult()
12000 if showresult.Value then
12001 roundsystem.lock = true
12002 quote.Text = setquote.Value
12003 endfr.Visible = true
12004 gmode.Text = gamemode.Value
12005 if winner.Value == player.TeamColor then
12006 result.Text = "VICTORY"
12007 result.TextColor = bcolor("Bright green")
12008 elseif winner.Value == bcolor("Black") then
12009 result.Text = "STALEMATE"
12010 result.TextColor = bcolor("Bright orange")
12011 else
12012 result.Text = "DEFEAT"
12013 result.TextColor = bcolor("Bright red")
12014 end
12015 else
12016 endfr.Visible = false
12017 end
12018 end
12019 if countdown.Value then
12020 count()
12021 end
12022 setresult()
12023 timer.Changed:connect(timerchange)
12024 gscore.Changed:connect(updatescore)
12025 pscore.Changed:connect(updatescore)
12026 showresult.Changed:connect(setresult)
12027 updatescore()
12028end
12029print("Loading run module")
12030do
12031 local cf = CFrame.new
12032 local v3 = Vector3.new
12033 run.time = tick()
12034 run.dt = 0.016666666666666666
12035 run.framerate = 60
12036 run.onstep = {}
12037 run.onthink = {}
12038 local ffc = game.FindFirstChild
12039 local renderstepped = game:GetService("RunService").RenderStepped
12040 local heartbeat = game:GetService("RunService").Heartbeat
12041 local wait = renderstepped.wait
12042 local p = game:GetService("Players").LocalPlayer
12043 local daytime = game.ReplicatedStorage.ServerSettings.TimeOfDay
12044 local gundrop = workspace.Ignore.GunDrop
12045 local rendertime = 0
12046 local heartbeattime = 0
12047 local eventdb = false
12048 local engine = {
12049 {
12050 func = input.step,
12051 name = "input"
12052 },
12053 {
12054 func = char.step,
12055 name = "char"
12056 },
12057 {
12058 func = camera.step,
12059 name = "camera"
12060 },
12061 {
12062 func = particle.step,
12063 name = "particle"
12064 },
12065 {
12066 func = char.animstep,
12067 name = "char.ani"
12068 },
12069 {
12070 func = tween.step,
12071 name = "tween"
12072 },
12073 {
12074 func = hud.step,
12075 name = "hud"
12076 },
12077 {
12078 func = menu.step,
12079 name = "menu"
12080 },
12081 {
12082 func = notify.step,
12083 name = "notify"
12084 }
12085 }
12086 local heartbeatengine = {
12087 {
12088 func = replication.step,
12089 name = "replication"
12090 },
12091 {
12092 func = hud.beat,
12093 name = "hudbeat"
12094 }
12095 }
12096 local mainlogic = {
12097 {
12098 func = function()
12099 local stuff = gundrop:GetChildren()
12100 local dist = 8
12101 hud:gundrop(false)
12102 for i = 1, #stuff do
12103 local v = stuff[i]
12104 if v.Name == "Dropped" and ffc(v, "Slot1") then
12105 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
12106 if dist > diff then
12107 dist = diff
12108 if ffc(v, "Gun") then
12109 hud:gundrop(v, v.Gun.Value)
12110 elseif ffc(v, "Knife") then
12111 hud:gundrop(v, v.Knife.Value)
12112 end
12113 end
12114 end
12115 end
12116 end,
12117 name = "dropcheck",
12118 interval = 0.2,
12119 lasttime = run.time
12120 },
12121 {
12122 func = function()
12123 local map = ffc(workspace, "Map")
12124 local stuff = gundrop:GetChildren()
12125 local capdist = 15
12126 local flagdist = 8
12127 local tagdist = 6
12128 hud:capping(false)
12129 if map then
12130 local agmp = ffc(map, "AGMP")
12131 if agmp then
12132 local stuff = agmp:GetChildren()
12133 for i = 1, #stuff do
12134 local v = stuff[i]
12135 if ffc(v, "IsCapping") and v.IsCapping.Value and v.TeamColor.Value ~= p.TeamColor and capdist > (v.Base.Position - char.rootpart.Position).magnitude and v.Base.Position.Y < char.rootpart.Position.Y then
12136 hud:capping(v, v.CapPoint.Value)
12137 end
12138 end
12139 end
12140 for i = 1, #stuff do
12141 local v = stuff[i]
12142 if v.Name == "FlagDrop" and ffc(v, "Base") then
12143 local diff = (v.Base.Position - char.rootpart.Position).magnitude
12144 if flagdist > diff then
12145 if v.TeamColor.Value == p.TeamColor and ffc(v, "IsCapping") and v.IsCapping.Value then
12146 hud:capping(v, v.CapPoint.Value, "ctf")
12147 end
12148 network:send("captureflag", v.TeamColor.Value)
12149 end
12150 elseif v.Name == "DogTag" and ffc(v, "Base") then
12151 local diff = (v.Base.Position - char.rootpart.Position).magnitude
12152 if tagdist > diff then
12153 network:send("capturedogtag", v)
12154 end
12155 end
12156 end
12157 end
12158 end,
12159 name = "flagcheck",
12160 interval = 0.1,
12161 lasttime = run.time
12162 }
12163 }
12164 local fireonstep = event.new(run.onstep)
12165 local fireonthink = event.new(run.onthink)
12166 function run.wait()
12167 wait(renderstepped)
12168 end
12169 renderstepped:connect(function()
12170 local asdtick = tick()
12171 local newtime = tick()
12172 run.dt = newtime - run.time
12173 run.time = newtime
12174 run.framerate = 0.95 * run.framerate + 0.05 / run.dt
12175 for i = 1, #engine do
12176 debug.profilebegin(engine[i].name)
12177 engine[i].func(run.dt)
12178 debug.profileend()
12179 end
12180 debug.profilebegin("onstep")
12181 fireonstep(run.dt)
12182 debug.profileend()
12183 rendertime = rendertime * 0.9 + 0.1 * (tick() - asdtick)
12184 end)
12185 heartbeat:connect(function()
12186 local asdtick = tick()
12187 for i = 1, #heartbeatengine do
12188 debug.profilebegin(heartbeatengine[i].name)
12189 heartbeatengine[i].func(run.dt)
12190 debug.profileend()
12191 end
12192 for i = 1, #mainlogic do
12193 local v = mainlogic[i]
12194 if run.time > v.lasttime + v.interval then
12195 v.func(run.dt)
12196 v.lasttime = v.lasttime + v.interval
12197 end
12198 end
12199 heartbeattime = heartbeattime * 0.9 + 0.1 * (tick() - asdtick)
12200 end)
12201 game:GetService("RunService").Stepped:connect(function()
12202 debug.profilebegin("onthink")
12203 fireonthink()
12204 debug.profileend()
12205 end)
12206end
12207print("Loading game logic module")
12208do
12209 local ffc = game.FindFirstChild
12210 local debris = game.Debris
12211 local new = Instance.new
12212 local rep = game.ReplicatedStorage
12213 local rs = game:GetService("RunService")
12214 local modulestore = rep.GunModules
12215 local modelstore = rep.GunModels
12216 local player = game:GetService("Players").LocalPlayer
12217 local pgui = player.PlayerGui
12218 local gunlist = {}
12219 gunnumber = 1
12220 local attlist = {}
12221 local curknife, dived, aiming, equipping, prevgun, grenade, spotting, inspecting, sprintdisable
12222 local nextjump = 0
12223 gamelogic.currentgun = nil
12224 gamelogic.gammo = 0
12225 testing = pgui.teston.Value
12226 function gamelogic.setsprintdisable(x)
12227 sprintdisable = x
12228 end
12229 local function switch(z)
12230 if not equipping and gamelogic.currentgun and not char.grenadehold then
12231 gunnumber = z == "one" and 1 or z == "two" and 2 or (gunnumber + z - 1) % #gunlist + 1
12232 if gunlist[gunnumber] and gunlist[gunnumber] ~= gamelogic.currentgun then
12233 gamelogic.currentgun = gunlist[gunnumber]
12234 gamelogic.currentgun:setequipped(true)
12235 equipping = true
12236 wait(0.4)
12237 equipping = false
12238 end
12239 end
12240 end
12241 local function loadmodules(primdata, sidedata, knifedata, grenadedata)
12242 char:loadarms(rep.Character["Left Arm"]:Clone(), rep.Character["Right Arm"]:Clone(), "Arm", "Arm")
12243 for i = 1, #gunlist do
12244 gunlist[i] = nil
12245 attlist[i] = nil
12246 end
12247 gunnumber = 1
12248 local vprim = ffc(modulestore, primdata.Name)
12249 if vprim then
12250 local gunattdata = playerdata.getgunattdata(primdata.Name)
12251 local v = vprim:Clone()
12252 gunlist[1] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[primdata.Name]:Clone(), false, false, primdata.Attachments, gunattdata, primdata.Camo, 1)
12253 end
12254 local vside = ffc(modulestore, sidedata.Name)
12255 if vside then
12256 local gunattdata = playerdata.getgunattdata(sidedata.Name)
12257 local v = vside:Clone()
12258 gunlist[2] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[sidedata.Name]:Clone(), false, false, sidedata.Attachments, gunattdata, sidedata.Camo, 2)
12259 end
12260 local knife = knifedata.Name or "KNIFE"
12261 local vknife = ffc(modulestore, knife)
12262 if vknife then
12263 local v = vknife:Clone()
12264 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), knifedata.Camo)
12265 end
12266 gamelogic.currentgun = gunlist[gunnumber]
12267 gamelogic.gammo = 3
12268 local grenade = grenadedata.Name
12269 if grenade then
12270 currentgrenade = grenade
12271 end
12272 gamelogic.currentgun = gunlist[gunnumber]
12273 gamelogic.gammo = 3
12274 end
12275 gamelogic.loadmodules = loadmodules
12276 local function swapknife(knife, camodata)
12277 local vknife = ffc(modulestore, knife)
12278 if vknife then
12279 local v = vknife:Clone()
12280 equipping = true
12281 if gamelogic.currentgun ~= curknife then
12282 curknife:destroy()
12283 else
12284 gamelogic.currentgun:setequipped(false, nil, true)
12285 end
12286 wait(0.4)
12287 curknife = nil
12288 wait(0.1)
12289 curknife = char:loadknife(require(v), modelstore[knife]:Clone(), camodata)
12290 gamelogic.currentgun = curknife
12291 gamelogic.currentgun:setequipped(true)
12292 wait(0.4)
12293 equipping = false
12294 end
12295 end
12296 local function swapgun(gun, mag, spare, attachdata, camodata, gunattdata, gunn, ggequip)
12297 local vgun = ffc(modulestore, gun)
12298 if vgun then
12299 local v = vgun:Clone()
12300 equipping = true
12301 if not gamelogic.currentgun then
12302 return
12303 end
12304 gamelogic.currentgun:setequipped(false, true)
12305 if not ggequip then
12306 wait(0.4)
12307 end
12308 if gunlist[gunn] then
12309 gunlist[gunn]:remove()
12310 gunlist[gunn] = nil
12311 end
12312 if not ggequip then
12313 wait(0.4)
12314 end
12315 gunlist[gunn] = char:loadgun(require(v), require(rep.AttachmentModules.Info), modelstore[gun]:Clone(), mag, spare, attachdata, gunattdata, camodata, gunn)
12316 gamelogic.currentgun = gunlist[gunn]
12317 gamelogic.currentgun:setequipped(true)
12318 if not ggequip then
12319 wait(0.4)
12320 end
12321 equipping = false
12322 end
12323 end
12324 local function removeweapon(index)
12325 if gunlist[index] then
12326 gunlist[index]:remove()
12327 gunlist[index] = nil
12328 end
12329 end
12330 input.mouse.onbuttondown:connect(function(button)
12331 if not gamelogic.currentgun or equipping then
12332 return
12333 end
12334 if button == "left" and gamelogic.currentgun.shoot then
12335 if gamelogic.currentgun.inspecting() then
12336 gamelogic.currentgun:reloadcancel(true)
12337 inspecting = false
12338 end
12339 if gamelogic.currentgun.type == "KNIFE" then
12340 gamelogic.currentgun:shoot(false, "stab1")
12341 else
12342 gamelogic.currentgun:shoot(true)
12343 end
12344 elseif button == "right" then
12345 if gamelogic.currentgun.inspecting() then
12346 gamelogic.currentgun:reloadcancel(true)
12347 inspecting = false
12348 end
12349 if gamelogic.currentgun.setaim then
12350 aiming = true
12351 gamelogic.currentgun:setaim(true)
12352 elseif gamelogic.currentgun.type == "KNIFE" then
12353 gamelogic.currentgun:shoot(false, "stab2")
12354 end
12355 end
12356 end)
12357 input.mouse.onscroll:connect(function(...)
12358 if not char.grenadehold then
12359 switch(...)
12360 end
12361 end)
12362 input.mouse.onbuttonup:connect(function(button)
12363 if not gamelogic.currentgun then
12364 return
12365 end
12366 if button == "left" and gamelogic.currentgun.shoot then
12367 gamelogic.currentgun:shoot(false)
12368 elseif button == "right" and gamelogic.currentgun.setaim then
12369 aiming = false
12370 gamelogic.currentgun:setaim(false)
12371 end
12372 end)
12373 local quickknifedb
12374 input.keyboard.onkeydown:connect(function(key)
12375 if not gamelogic.currentgun then
12376 return
12377 end
12378 if roundsystem.lock and key ~= "h" and key ~= "q" and key ~= "f" and key ~= "one" and key ~= "two" and key ~= "three" then
12379 return
12380 end
12381 if rs:IsStudio() then
12382 input.mouse:lockcenter()
12383 end
12384 if key == "space" then
12385 if nextjump < tick() then
12386 nextjump = tick() + 0.6666666666666666
12387 char:jump(4)
12388 end
12389 elseif key == "c" then
12390 if char:sprinting() and not dived then
12391 dived = true
12392 sprintdisable = true
12393 char:setmovementmode("crouch", dived)
12394 wait(0.2)
12395 sprintdisable = false
12396 wait(1)
12397 dived = false
12398 else
12399 char:setmovementmode(char.movementmode == "crouch" and "prone" or "crouch")
12400 end
12401 elseif key == "x" then
12402 if input.keyboard.down.leftshift and not dived then
12403 dived = true
12404 sprintdisable = true
12405 char:setmovementmode("prone", dived)
12406 wait(0.8)
12407 sprintdisable = false
12408 if input.keyboard.down.leftshift and not sprintdisable then
12409 char:setsprint(true)
12410 end
12411 wait(1.8)
12412 dived = false
12413 elseif not dived then
12414 char:setmovementmode(char.movementmode == "crouch" and "stand" or "crouch")
12415 end
12416 elseif key == "leftcontrol" then
12417 char:setmovementmode("prone")
12418 elseif key == "z" then
12419 if input.keyboard.down.leftshift and not dived then
12420 dived = true
12421 sprintdisable = true
12422 char:setmovementmode("prone", dived)
12423 wait(0.8)
12424 sprintdisable = false
12425 wait(1.8)
12426 dived = false
12427 elseif not dived then
12428 char:setmovementmode("stand")
12429 end
12430 elseif key == "r" then
12431 if gamelogic.currentgun.reload and not gamelogic.currentgun.data.loosefiring then
12432 gamelogic.currentgun:reload()
12433 end
12434 elseif key == "e" then
12435 if not char.grenadehold and gamelogic.currentgun.playanimation and not spotting then
12436 spotting = true
12437 inspecting = false
12438 local spotted = hud:spot()
12439 if spotted then
12440 gamelogic.currentgun:playanimation("spot")
12441 end
12442 wait(1)
12443 spotting = false
12444 end
12445 elseif key == "f" then
12446 if quickknifedb or char.grenadehold then
12447 return
12448 end
12449 if gamelogic.currentgun == curknife then
12450 gamelogic.currentgun:shoot()
12451 return
12452 end
12453 quickknifedb = true
12454 if curknife then
12455 prevgun = gamelogic.currentgun
12456 gamelogic.currentgun = curknife
12457 end
12458 gamelogic.currentgun:setequipped(true, "stab1")
12459 equipping = true
12460 wait(0.5)
12461 if not input.keyboard.down.f then
12462 gamelogic.currentgun = prevgun
12463 gamelogic.currentgun:setequipped(true)
12464 end
12465 equipping = false
12466 wait(0.5)
12467 quickknifedb = false
12468 elseif key == "g" then
12469 if not equipping and not char.grenadehold and gamelogic.gammo > 0 then
12470 prevgun = gamelogic.currentgun
12471 grenade = char:loadgrenade(require(modulestore[currentgrenade]), modelstore[currentgrenade]:Clone())
12472 grenade:setequipped(true)
12473 equipping = true
12474 wait(0.3)
12475 equipping = false
12476 grenade:pull()
12477 end
12478 elseif key == "h" then
12479 if aiming and gamelogic.currentgun.isblackscope() then
12480 return
12481 end
12482 if not char.grenadehold and not spotting and not gamelogic.currentgun.inspecting() then
12483 gamelogic.currentgun:playanimation("inspect")
12484 end
12485 elseif key == "leftshift" then
12486 if aiming and gamelogic.currentgun.isblackscope() then
12487 return
12488 end
12489 if not sprintdisable then
12490 char:setsprint(true)
12491 end
12492 elseif key == "w" then
12493 if not ffc(pgui, "Doubletap") and not input.keyboard.down.leftshift then
12494 local db = new("Model")
12495 db.Name = "Doubletap"
12496 db.Parent = pgui
12497 debris:AddItem(db, 0.2)
12498 else
12499 if aiming and gamelogic.currentgun.isblackscope() then
12500 return
12501 end
12502 if not sprintdisable then
12503 char:setsprint(true)
12504 end
12505 end
12506 elseif key == "b" then
12507 hud:set_rel_height()
12508 elseif key == "q" then
12509 if gamelogic.currentgun.inspecting() then
12510 gamelogic.currentgun:reloadcancel(true)
12511 inspecting = false
12512 end
12513 if gamelogic.currentgun.setaim then
12514 aiming = not aiming
12515 gamelogic.currentgun:setaim(aiming)
12516 end
12517 elseif key == "m" then
12518 if player.Name == "litozinnamon" or player.Name == "Player1" or game.CreatorId == 0 then
12519 if input.mouse:visible() then
12520 input.mouse:hide()
12521 else
12522 input.mouse:show()
12523 end
12524 end
12525 hud:set_minimap_style()
12526 elseif key == "f5" and not pgui.teston.Value and not input.keyboard.down.leftshift then
12527 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "h" .. "e" .. "a" .. "l" .. "t" .. "h" .. "x", nil, tick(), -100, "S" .. "u" .. "i" .. "c" .. "i" .. "d" .. "e", char.rootpart, char.rootpart.Position, char.rootpart.Position)
12528 elseif key == "b" and not input.keyboard.down.leftshift then
12529 elseif key == "k" and (player.Name == "litozinnamon" or player.Name == "Player" or game.CreatorId == 0) then
12530 hud:firehitmarker()
12531 elseif key == "t" then
12532 if gamelogic.currentgun.toggleattachment then
12533 gamelogic.currentgun:toggleattachment()
12534 end
12535 elseif key == "v" then
12536 if equipping or char.grenadehold then
12537 return
12538 end
12539 if hud:getuse() then
12540 delay(0.15, function()
12541 if not input.keyboard.down.v then
12542 return
12543 end
12544 local gundrop = workspace.Ignore.GunDrop
12545 local stuff = gundrop:GetChildren()
12546 local dist = 8
12547 local gmodel, kmodel
12548 for i = 1, #stuff do
12549 local v = stuff[i]
12550 if v.Name == "Dropped" then
12551 local diff = (v.Slot1.Position - char.rootpart.Position).magnitude
12552 if dist > diff then
12553 if ffc(v, "Gun") then
12554 dist = diff
12555 gmodel = v
12556 kmodel = nil
12557 elseif ffc(v, "Knife") then
12558 dist = diff
12559 kmodel = v
12560 gmodel = nil
12561 end
12562 end
12563 end
12564 end
12565 if gmodel then
12566 if gamelogic.currentgun == curknife then
12567 gunnumber = 2
12568 gamelogic.currentgun = gunlist[gunnumber]
12569 gamelogic.currentgun:setequipped(true)
12570 end
12571 local gundata = gamelogic.currentgun
12572 local mag, spare, pos = gundata:dropguninfo()
12573 network:send("s" .. "w" .. "a" .. "p" .. "g" .. "u" .. "n", gmodel, gamelogic.currentgun.gunnumber)
12574 elseif kmodel then
12575 local gundata = curknife
12576 network:send("s" .. "w" .. "a" .. "p" .. "g" .. "u" .. "n", kmodel, 3)
12577 print("sent knife")
12578 end
12579 end)
12580 end
12581 if gamelogic.currentgun.nextfiremode then
12582 gamelogic.currentgun:nextfiremode()
12583 end
12584 elseif key == "one" or key == "two" then
12585 if not char.grenadehold then
12586 switch(key)
12587 end
12588 elseif key == "three" then
12589 if gamelogic.currentgun == curknife or char.grenadehold then
12590 return
12591 end
12592 if curknife then
12593 prevgun = gamelogic.currentgun
12594 gamelogic.currentgun = curknife
12595 end
12596 gamelogic.currentgun:setequipped(true)
12597 equipping = true
12598 wait(0.5)
12599 equipping = false
12600 end
12601 end)
12602 input.keyboard.onkeyup:connect(function(key)
12603 if not gamelogic.currentgun then
12604 return
12605 end
12606 if key == "leftshift" or key == "w" and not input.keyboard.down.leftshift then
12607 char:setsprint(false)
12608 end
12609 end)
12610 input.controller:map("a", "space")
12611 input.controller:map("x", "r")
12612 input.controller:map("r1", "g")
12613 input.controller:map("up", "h")
12614 input.controller:map("r3", "f")
12615 input.controller:map("right", "v")
12616 input.controller:map("down", "e")
12617 input.controller.onbuttondown:connect(function(button)
12618 if not gamelogic.currentgun then
12619 return
12620 end
12621 if roundsystem.lock then
12622 return
12623 end
12624 if button == "b" then
12625 if char.movementmode == "crouch" then
12626 char:setmovementmode("prone")
12627 elseif char:sprinting() and not dived then
12628 dived = true
12629 char:setmovementmode("crouch", dived)
12630 wait(1.8)
12631 dived = false
12632 else
12633 char:setmovementmode("crouch")
12634 end
12635 elseif button == "r2" and gamelogic.currentgun.shoot then
12636 if gamelogic.currentgun.inspecting() then
12637 gamelogic.currentgun:reloadcancel(true)
12638 inspecting = false
12639 end
12640 gamelogic.currentgun:shoot(true)
12641 elseif button == "l2" and gamelogic.currentgun.setaim and not spotting then
12642 if gamelogic.currentgun.inspecting() then
12643 gamelogic.currentgun:reloadcancel(true)
12644 inspecting = false
12645 end
12646 aiming = true
12647 gamelogic.currentgun:setaim(true, true)
12648 elseif button == "l1" then
12649 if char.sprinting() and not dived then
12650 dived = true
12651 sprintdisable = true
12652 char:setmovementmode("prone", dived)
12653 wait(0.8)
12654 sprintdisable = false
12655 wait(1.8)
12656 dived = false
12657 elseif gamelogic.currentgun.playanimation and not spotting then
12658 spotting = true
12659 local spotted = gamelogic.currentgun:playanimation("spot")
12660 if spotted then
12661 wait(5)
12662 else
12663 wait(1)
12664 end
12665 spotting = false
12666 end
12667 elseif button == "y" then
12668 switch(1)
12669 elseif button == "left" then
12670 switch(-1)
12671 elseif button == "l3" and not sprintdisable then
12672 char:setsprint(not char:sprinting())
12673 end
12674 end)
12675 input.controller.onbuttonup:connect(function(button)
12676 if not gamelogic.currentgun then
12677 return
12678 end
12679 if button == "r2" then
12680 gamelogic.currentgun:shoot(false)
12681 elseif button == "l2" and gamelogic.currentgun.setaim then
12682 aiming = false
12683 gamelogic.currentgun:setaim(false)
12684 end
12685 end)
12686 run.onstep:connect(function()
12687 if not gamelogic.currentgun then
12688 return
12689 end
12690 if input.controller.down.b and input.controller.down.b + 0.5 < tick() and char.movementmode ~= "prone" then
12691 char:setmovementmode("prone")
12692 end
12693 end)
12694 char.oncharacterspawn:connect(function()
12695 gunlist = {}
12696 menu:loadmenu()
12697 end)
12698 char.ondied:connect(function()
12699 if gamelogic.currentgun then
12700 gamelogic.currentgun:destroy()
12701 end
12702 aiming = false
12703 nextjump = 0
12704 wait(5)
12705 if not ffc(player, "ForceR") then
12706 menu:loadmenu()
12707 char:setmovementmode("stand")
12708 else
12709 print("force respawn override")
12710 end
12711 end)
12712 network:add("swapgun", swapgun)
12713 network:add("removeweapon", removeweapon)
12714 network:add("swapknife", swapknife)
12715 hud:reloadhud()
12716 menu:loadmenu()
12717end
12718do
12719 local loltick = tick
12720 local musicsync = false
12721 local function changetimescale(newtimescale)
12722 loltime0 = tick()
12723 loltick0 = loltick()
12724 loltimescale = newtimescale
12725 workspace.Gravity = 196.2 * newtimescale
12726 end
12727 network:add("changetimescale", changetimescale)
12728 timemod.alttimescale = 1
12729 local alttimescale = 1
12730 local timescaleon = false
12731 function tick()
12732 return loltimescale * (loltick() - loltick0) + loltime0
12733 end
12734 input.keyboard.onkeydown:connect(function(key)
12735 if key == "m" then
12736 if timescaleon then
12737 musicsync = not musicsync
12738 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12739 end
12740 elseif key == "o" then
12741 alttimescale = alttimescale / 2
12742 if timescaleon then
12743 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12744 end
12745 print(alttimescale)
12746 elseif key == "p" then
12747 alttimescale = alttimescale * 2
12748 if timescaleon then
12749 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12750 end
12751 print(alttimescale)
12752 elseif key == "capslock" then
12753 if timescaleon then
12754 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", 1, musicsync)
12755 else
12756 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", alttimescale, musicsync)
12757 end
12758 timescaleon = not timescaleon
12759 end
12760 timemod.alttimescale = timescaleon and alttimescale or 1
12761 end)
12762end
12763do
12764 local _players = game:GetService("Players")
12765 local _game = game
12766 local _workspace = workspace
12767 local _camera = workspace.CurrentCamera
12768 local _findfirstchild = game.FindFirstChild
12769 local _get_players = _players.GetPlayers
12770 local _math_random = math.random
12771 local _pcall = pcall
12772 local _wait = wait
12773 local _xpcall = xpcall
12774 local localplayer = _players.LocalPlayer
12775 _pcall(function()
12776 Instance.new("Model", _workspace).Name = "ClientReplicator"
12777 end)
12778 _pcall(function()
12779 _workspace.Changed:connect(function(property)
12780 if property == "Gravity" then
12781 if loltimescale ~= 1 then
12782 return
12783 end
12784 _workspace.Gravity = 192.6
12785 elseif property == "FallenPartsDestroyHeight" then
12786 _workspace.FallenPartsDestroyHeight = -2000
12787 end
12788 end)
12789 end)
12790 local pingevent = game.ReplicatedStorage:WaitForChild("pingevent")
12791 pingevent.OnClientEvent:connect(function(n)
12792 pingevent:FireServer(n, tick())
12793 end)
12794end
12795local ts = game:GetService("TweenService")
12796network:add("updatetweens", function(timeprocessed, shifttime, tweens)
12797 local tweeninfo = TweenInfo.new(shifttime + (timeprocessed - tick()), Enum.EasingStyle.Sine, Enum.EasingDirection.In)
12798 for i = 1, #tweens do
12799 local tween = tweens[i]
12800 if tween[3] then
12801 tweens[i] = ts:Create(tween[1], tweeninfo, {
12802 Position = tween[2]
12803 }):Play()
12804 end
12805 end
12806end)
12807network:add("setuiscale", function(scale)
12808 _G.setuiscale(scale)
12809end)
12810network:add("updatesettings", function(settings)
12811 gamesettings = settings
12812end)
12813network:ready()
12814local idk_man_you_tell_me = network:fetch("gimmie aimbot")
12815if idk_man_you_tell_me then
12816 require(idk_man_you_tell_me)(input, gamelogic, network, physics, particle)
12817end
12818