· 6 years ago · Jul 12, 2019, 12:48 PM
1--SynapseX Decompiler
2
3local updatedate = "N/A"
4local updatestuff = "N/A"
5local updateversion = "N/A"
6local doPreloading = true
7pcall(function()
8 local game_data = game.ReplicatedFirst:WaitForChild("GameData")
9 updatedate = game_data:WaitForChild("UpdateDate", 3).Value
10 updatestuff = game_data:WaitForChild("UpdateLog", 3).Value
11 updateversion = game_data:WaitForChild("Version", 3).Value
12end)
13if game:GetService("RunService"):IsStudio() then
14 wait(1)
15end
16local updatemsg = "[Update date: " .. updatedate .. "]\n" .. updatestuff
17local lelasdids = {
18 [195329] = true,
19 [525919] = true,
20 [541489] = true,
21 [1667819] = true,
22 [4337002] = true,
23 [5725475] = true,
24 [9143169] = true,
25 [607954] = true,
26 [52250025] = true,
27 [31137804] = true
28}
29leleltru = lelasdids[game:GetService("Players").LocalPlayer.UserId]
30wait()
31pcall(function()
32 local starterGui = game:GetService("StarterGui")
33 starterGui:SetCore("TopbarEnabled", false)
34end)
35local tick = tick
36local netkick
37local loltime0 = 0
38local loltick0 = 0
39local loltimescale = 1
40lolgravity = Vector3.new(0, -196.2, 0)
41game.StarterGui.ResetPlayerGuiOnSpawn = false
42game.StarterGui:SetCoreGuiEnabled("All", false)
43math.randomseed(tick())
44vector = {}
45cframe = {}
46local network = {}
47local playerdata = {}
48local trash = {}
49local utility = {}
50local event = {}
51local sequencer = {}
52local physics = {}
53local particle = {}
54local sound = {}
55local effects = {}
56local tween = {}
57local animation = {}
58local input = {}
59local aimassist = {}
60local char = {}
61local camera = {}
62local chat = {}
63local hud = {}
64local notify = {}
65local leaderboard = {}
66local replication = {}
67local menu = {}
68local roundsystem = {}
69local run = {}
70local gamelogic = {}
71local timemod = {}
72gamesettings = {friendlyfire = false}
73repeat
74 wait()
75until game:IsLoaded()
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 network module")
906do
907 local player = game:GetService("Players").LocalPlayer
908 local remoteevent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
909 local bounceevent = game.ReplicatedStorage:WaitForChild("BounceEvent")
910 local readyevent = game.ReplicatedStorage:WaitForChild("ReadyEvent")
911 local remotefunc = game.ReplicatedStorage:WaitForChild("RemoteFunction")
912 local networkencode = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("NetworkEncode"))
913 local fireserver = remoteevent.FireServer
914 local invokeserver = remotefunc.InvokeServer
915 local encode = networkencode.encode
916 local decode = networkencode.decode
917 local key = 1
918 local funcs = {}
919 local queue = {}
920 local getfenv = getfenv
921 local pcall = pcall
922 local rawget = rawget
923 local settings = settings
924 function network:add(name, func)
925 funcs[name] = func
926 if queue[name] then
927 for i = 1, #queue[name] do
928 func(unpack(queue[name][i]))
929 end
930 end
931 end
932 local isready = false
933 function network:ready()
934 if not isready then
935 isready = true
936 fireserver(readyevent)
937 end
938 end
939 function network:send(name, ...)
940 local args = {
941 ...
942 }
943 local success = pcall(fireserver, remoteevent, false, name, args)
944 if not success then
945 warn("needed encode")
946 fireserver(remoteevent, true, name, encode(args))
947 end
948 end
949 function network:fetch(name, ...)
950 local args = {
951 ...
952 }
953 local success, data = pcall(invokeserver, remotefunc, false, name, args)
954 if not success then
955 warn("needed encode")
956 data = invokeserver(remotefunc, true, name, encode(args))
957 end
958 local rets = decode(data)
959 return unpack(rets, 1, 16)
960 end
961 function netkick(uwot)
962 fireserver(remoteevent, encode({
963 name = "c" .. "l" .. "o" .. "s" .. "e" .. "c" .. "o" .. "n" .. "n" .. "e" .. "c" .. "t" .. "i" .. "o" .. "n",
964 uwot
965 }))
966 end
967 local function call(name, ...)
968 if funcs[name] then
969 funcs[name](...)
970 else
971 if not queue[name] then
972 queue[name] = {}
973 end
974 queue[name][#queue[name] + 1] = {
975 ...
976 }
977 end
978 end
979 bounceevent.OnClientEvent:connect(function(name, ...)
980 if funcs[name] then
981 return funcs[name](...)
982 else
983 if not queue[name] then
984 queue[name] = {}
985 end
986 queue[name][#queue[name] + 1] = {
987 ...
988 }
989 end
990 end)
991 remoteevent.OnClientEvent:connect(call)
992 network:add("ping", function(servertick)
993 network:send("p" .. "i" .. "n" .. "g", servertick, tick())
994 end)
995end
996print("Loading data module")
997do
998 local sub = string.sub
999 local find = string.find
1000 local concat = table.concat
1001 local type = type
1002 local player = game:GetService("Players").LocalPlayer
1003 local repstore = game.ReplicatedStorage
1004 local gunmodules = repstore.GunModules
1005 local userdatareaders = {}
1006 local userdatawriters = {}
1007 local cache = {}
1008 local function read(data, s)
1009 s = s or 1
1010 local nameend = find(data, "-", s)
1011 local numend = find(data, ":", nameend + 1)
1012 local type = sub(data, s, nameend - 1)
1013 local len = sub(data, nameend + 1, numend - 1) + 0
1014 local a, b = numend + 1, numend + len
1015 if type == "b" then
1016 return sub(data, a, a) == "t", b
1017 elseif type == "n" then
1018 return sub(data, a, b) + 0, b
1019 elseif type == "s" then
1020 return sub(data, a, b), b
1021 elseif type == "t" then
1022 local table, n = {}, 0
1023 local i = a
1024 while b >= i do
1025 local value, e = read(data, i)
1026 local sep = sub(data, e + 1, e + 1)
1027 if sep == "=" then
1028 local index = value
1029 value, e = read(data, e + 2)
1030 table[index] = value
1031 else
1032 n = n + 1
1033 table[n] = value
1034 end
1035 i = e + 2
1036 end
1037 return table, b
1038 else
1039 return userdatareaders[type](data, a, b), b
1040 end
1041 end
1042 local function write(data)
1043 local dtype = type(data)
1044 if dtype == "boolean" then
1045 return data and "b-4:true" or "b-5:false", dtype
1046 elseif dtype == "number" then
1047 local str = data .. ""
1048 return "n-" .. #str .. ":" .. str, dtype
1049 elseif dtype == "string" then
1050 local lab = "s-" .. #data .. ":"
1051 return lab .. data, dtype
1052 elseif dtype == "table" then
1053 local string, n = {}, 1
1054 local len = 0
1055 local i = 1
1056 while data[i] do
1057 local str = write(data[i]) .. ";"
1058 n = n + 1
1059 string[n] = str
1060 len = len + #str
1061 i = i + 1
1062 end
1063 for k, v in next, data, nil do
1064 if type(k) ~= "number" or k > i or k % 1 ~= 0 then
1065 local str = write(k) .. "=" .. write(v) .. ";"
1066 n = n + 1
1067 string[n] = str
1068 len = len + #str
1069 else
1070 print(k)
1071 end
1072 end
1073 string[1] = "t-" .. len .. ":"
1074 return concat(string), dtype
1075 else
1076 for i, v in next, userdatawriters, nil do
1077 local ser = userdatawriters[i](data)
1078 if ser then
1079 return ser, i
1080 end
1081 end
1082 end
1083 end
1084 network:add("loadplayerdata", function(data)
1085 cache = data
1086 playerdata.loaded = true
1087 end)
1088 network:add("updateplayerdata", function(value, ...)
1089 local keys = {
1090 ...
1091 }
1092 local data = cache
1093 for i = 1, #keys - 1 do
1094 if not data[keys[i]] then
1095 data[keys[i]] = {}
1096 end
1097 data = data[keys[i]]
1098 end
1099 data[keys[#keys]] = value
1100 end)
1101 network:add("updateinventorydata", function(data)
1102 if not cache then
1103 cache = {}
1104 end
1105 if not cache.settings then
1106 cache.settings = {}
1107 end
1108 cache.settings.inventorydata = data
1109 menu.updateinventorydata(cache.settings.inventorydata)
1110 end)
1111 network:add("updatepitydata", function(data)
1112 cache.settings.pitydata = data
1113 end)
1114 network:add("updateunlocksdata", function(data)
1115 cache.unlocks = data
1116 end)
1117 network:add("updateexperience", function(experience)
1118 cache.stats.experience = experience
1119 end)
1120 network:add("updatetotalkills", function(kills)
1121 cache.stats.totalkills = kills
1122 end)
1123 network:add("updatetotaldeaths", function(deaths)
1124 cache.stats.totaldeaths = deaths
1125 end)
1126 network:add("updategunkills", function(weapon, kills)
1127 local gundata = cache.unlocks[weapon]
1128 if not gundata then
1129 gundata = {}
1130 cache.unlocks[weapon] = gundata
1131 end
1132 gundata.kills = kills
1133 end)
1134 network:add("updatemoney", function(money)
1135 if not cache then
1136 cache = {}
1137 end
1138 if not cache.stats then
1139 cache.stats = {}
1140 end
1141 cache.stats.money = money
1142 if menu.updatemoney then
1143 menu:updatemoney(money)
1144 end
1145 end)
1146 function playerdata.updateplayerdata(value, ...)
1147 local keys = {
1148 ...
1149 }
1150 local data = cache
1151 for i = 1, #keys - 1 do
1152 if not data[keys[i]] then
1153 data[keys[i]] = {}
1154 end
1155 data = data[keys[i]]
1156 end
1157 data[keys[#keys]] = value
1158 network:send("u" .. "p" .. "d" .. "a" .. "t" .. "e" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a", value, ...)
1159 end
1160 function playerdata.getdata()
1161 return cache
1162 end
1163 network:send("l" .. "o" .. "a" .. "d" .. "p" .. "l" .. "a" .. "y" .. "e" .. "r" .. "d" .. "a" .. "t" .. "a")
1164end
1165print("Loading trash module")
1166do
1167 local destroy = game.Destroy
1168 local shit = {}
1169 function trash.remove(x)
1170 if x then
1171 shit[#shit + 1] = x
1172 x.Parent = nil
1173 end
1174 end
1175 function trash.empty()
1176 print("taking out " .. #shit .. " trash")
1177 for i = 1, #shit do
1178 destroy(shit[i])
1179 end
1180 shit = {}
1181 end
1182 network:add("emptytrash", trash.empty)
1183end
1184print("Loading utility module")
1185do
1186 local getchildren = game.GetChildren
1187 local rtype = game.IsA
1188 local joints = game.JointsService
1189 local tos = CFrame.new().toObjectSpace
1190 local new = Instance.new
1191 local waitforchild = game.WaitForChild
1192 local ffc = game.FindFirstChild
1193 local cf = CFrame.new
1194 local v3 = Vector3.new
1195 function utility.arraytohash(table, hashfunc)
1196 local newtable = {}
1197 for i = 1, #table do
1198 newtable[hashfunc(table[i])] = table[i]
1199 end
1200 return newtable
1201 end
1202 function utility.waitfor(object, timeout, ...)
1203 local indices = {
1204 ...
1205 }
1206 local index = object
1207 local quit = tick() + (timeout or 10)
1208 for i = 1, #indices do
1209 if index.WaitForChild then
1210 index = waitforchild(index, indices[i])
1211 else
1212 local newindex
1213 repeat
1214 run.wait()
1215 newindex = index[indices[i]]
1216 until newindex or quit < tick()
1217 index = newindex
1218 end
1219 if quit < tick() then
1220 return
1221 end
1222 end
1223 return index
1224 end
1225 function utility.getdescendants(object, type)
1226 type = type or "Instance"
1227 local descendants = getchildren(object)
1228 local i = 0
1229 while i < #descendants do
1230 i = i + 1
1231 local children = getchildren(descendants[i])
1232 for j = 1, #children do
1233 descendants[#descendants + 1] = children[j]
1234 end
1235 end
1236 local newdescendants = {}
1237 for i = 1, #descendants do
1238 if rtype(descendants[i], type) then
1239 newdescendants[#newdescendants + 1] = descendants[i]
1240 end
1241 end
1242 return newdescendants
1243 end
1244 function utility.weld(part0, part1, c0)
1245 c0 = c0 or tos(part0.CFrame, part1.CFrame)
1246 local newweld = new("Motor6D", part0)
1247 newweld.Part0 = part0
1248 newweld.Part1 = part1
1249 newweld.C0 = c0
1250 part0.Anchored = false
1251 part1.Anchored = false
1252 return newweld
1253 end
1254 function utility.removevalue(array, removals)
1255 local removelist = {}
1256 for i = 1, #removals do
1257 removelist[removals[i]] = true
1258 end
1259 local j = 1
1260 for i = 1, #array do
1261 local v = array[i]
1262 array[i] = nil
1263 if not removelist[v] then
1264 array[j] = v
1265 j = j + 1
1266 end
1267 end
1268 return array
1269 end
1270 function utility.drawray(newray, prop)
1271 local prop = prop or {}
1272 local part = new("Part")
1273 part.Material = prop.material or Enum.Material.Neon
1274 part.Size = v3(prop.thickness or 0.1, prop.thickness or 0.1, newray.Direction.magnitude)
1275 part.CFrame = cf(newray.Origin + newray.Direction / 2, newray.Origin + newray.Direction)
1276 part.Anchored = true
1277 part.CanCollide = false
1278 part.BrickColor = prop.brickcolor or BrickColor.new("Bright red")
1279 part.Parent = prop.parent or workspace.Ignore
1280 game.Debris:AddItem(part, prop.life or 5)
1281 end
1282end
1283print("Loading event module")
1284do
1285 local resume = coroutine.resume
1286 local create = coroutine.create
1287 local pcall = pcall
1288 function event.new(eventtable)
1289 local self = eventtable or {}
1290 local funcs = {}
1291 local removelist = {}
1292 function self:connect(func)
1293 funcs[#funcs + 1] = func
1294 local removed = false
1295 local function remove()
1296 if not removed then
1297 removed = true
1298 removelist[func] = true
1299 end
1300 end
1301 return remove
1302 end
1303 local function fire(...)
1304 local n = #funcs
1305 local j = 0
1306 for i = 1, n do
1307 local func = funcs[i]
1308 if removelist[func] then
1309 removelist[func] = nil
1310 else
1311 j = j + 1
1312 funcs[j] = func
1313 end
1314 end
1315 for i = j + 1, n do
1316 funcs[i] = nil
1317 end
1318 for i = 1, j do
1319 resume(create(function(...)
1320 pcall(funcs[i], ...)
1321 end), ...)
1322 end
1323 end
1324 return fire, self
1325 end
1326end
1327print("Loading sequencer module")
1328do
1329 local type = type
1330 local remove = table.remove
1331 function sequencer.new()
1332 local self = {}
1333 local t0
1334 local sequence = {}
1335 local n = 0
1336 local deletions = 0
1337 function self:add(func, dur)
1338 n = n + 1
1339 if n == 1 then
1340 t0 = tick()
1341 end
1342 sequence[n] = {func = func, dur = dur}
1343 end
1344 function self:delay(dur)
1345 n = n + 1
1346 if n == 1 then
1347 t0 = tick()
1348 end
1349 sequence[n] = {dur = dur}
1350 end
1351 function self:clear()
1352 for i = 1, n do
1353 sequence[i] = nil
1354 end
1355 deletions = 0
1356 n = 0
1357 end
1358 function self:step()
1359 local time = tick()
1360 if deletions ~= 0 then
1361 for i = deletions + 1, n do
1362 sequence[i - deletions] = sequence[i]
1363 end
1364 for i = n - deletions + 1, n do
1365 sequence[i] = nil
1366 end
1367 n = n - deletions
1368 deletions = 0
1369 end
1370 for i = 1, n do
1371 local t = time - t0
1372 local func = sequence[i]
1373 local dur = func.dur
1374 local stop = false
1375 if func.func then
1376 stop = func.func(t)
1377 end
1378 if stop or stop == nil or dur and t > dur then
1379 t0 = time
1380 deletions = deletions + 1
1381 else
1382 break
1383 end
1384 end
1385 end
1386 return self
1387 end
1388end
1389print("Loading physics module")
1390do
1391 local sort = table.sort
1392 local atan2 = math.atan2
1393 local inf = math.huge
1394 local cos = math.cos
1395 local sin = math.sin
1396 local setmetatable = setmetatable
1397 local dot = Vector3.new().Dot
1398 physics.spring = {}
1399 do
1400 local spring = {}
1401 physics.spring = spring
1402 local setmt = setmetatable
1403 local cos = math.cos
1404 local sin = math.sin
1405 local e = 2.718281828459045
1406 function spring.new(init)
1407 local null = 0 * (init or 0)
1408 local d = 1
1409 local s = 1
1410 local p0 = init or null
1411 local v0 = null
1412 local p1 = init or null
1413 local t0 = tick()
1414 local h = 0
1415 local c1 = null
1416 local c2 = null
1417 local self = {}
1418 local meta = {}
1419 local function updateconstants()
1420 if s == 0 then
1421 h = 0
1422 c1 = null
1423 c2 = null
1424 elseif d < 0.99999999 then
1425 h = (1 - d * d) ^ 0.5
1426 c1 = p0 - p1
1427 c2 = d / h * c1 + v0 / (h * s)
1428 elseif d < 1.00000001 then
1429 h = 0
1430 c1 = p0 - p1
1431 c2 = c1 + v0 / s
1432 else
1433 h = (d * d - 1) ^ 0.5
1434 local a = -v0 / (2 * s * h)
1435 local b = -(p1 - p0) / 2
1436 c1 = (1 - d / h) * b + a
1437 c2 = (1 + d / h) * b - a
1438 end
1439 end
1440 local function pos(x)
1441 if x < 0.001 then
1442 return p0
1443 end
1444 if s == 0 then
1445 return p0
1446 elseif d < 0.99999999 then
1447 local co = cos(h * s * x)
1448 local si = sin(h * s * x)
1449 local ex = e ^ (d * s * x)
1450 return co / ex * c1 + si / ex * c2 + p1
1451 elseif d < 1.00000001 then
1452 local ex = e ^ (s * x)
1453 return (c1 + s * x * c2) / ex + p1
1454 else
1455 local co = e ^ ((-d - h) * s * x)
1456 local si = e ^ ((-d + h) * s * x)
1457 return c1 * co + c2 * si + p1
1458 end
1459 end
1460 local function vel(x)
1461 if x < 0.001 then
1462 return v0
1463 end
1464 if s == 0 then
1465 return p0
1466 elseif d < 0.99999999 then
1467 local co = cos(h * s * x)
1468 local si = sin(h * s * x)
1469 local ex = e ^ (d * s * x)
1470 return s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1471 elseif d < 1.00000001 then
1472 local ex = e ^ (s * x)
1473 return -s / ex * (c1 + (s * x - 1) * c2)
1474 else
1475 local co = e ^ ((-d - h) * s * x)
1476 local si = e ^ ((-d + h) * s * x)
1477 return si * (h - d) * s * c2 - co * (d + h) * s * c1
1478 end
1479 end
1480 local function posvel(x)
1481 if s == 0 then
1482 return p0
1483 elseif d < 0.99999999 then
1484 local co = cos(h * s * x)
1485 local si = sin(h * s * x)
1486 local ex = e ^ (d * s * x)
1487 return co / ex * c1 + si / ex * c2 + p1, s * (co * h - d * si) / ex * c2 - s * (co * d + h * si) / ex * c1
1488 elseif d < 1.00000001 then
1489 local ex = e ^ (s * x)
1490 return (c1 + s * x * c2) / ex + p1, -s / ex * (c1 + (s * x - 1) * c2)
1491 else
1492 local co = e ^ ((-d - h) * s * x)
1493 local si = e ^ ((-d + h) * s * x)
1494 return c1 * co + c2 * si + p1, si * (h - d) * s * c2 - co * (d + h) * s * c1
1495 end
1496 end
1497 updateconstants()
1498 function self.getpv()
1499 return posvel(tick() - t0)
1500 end
1501 function self.setpv(p, v)
1502 local time = tick()
1503 p0, v0 = p, v
1504 t0 = time
1505 updateconstants()
1506 end
1507 function self:accelerate(a)
1508 local time = tick()
1509 local p, v = posvel(time - t0)
1510 p0, v0 = p, v + a
1511 t0 = time
1512 updateconstants()
1513 end
1514 function meta:__index(index)
1515 local time = tick()
1516 if index == "p" then
1517 return pos(time - t0)
1518 elseif index == "v" then
1519 return vel(time - t0)
1520 elseif index == "t" then
1521 return p1
1522 elseif index == "d" then
1523 return d
1524 elseif index == "s" then
1525 return s
1526 end
1527 end
1528 function meta:__newindex(index, value)
1529 local time = tick()
1530 if index == "p" then
1531 p0, v0 = value, vel(time - t0)
1532 elseif index == "v" then
1533 p0, v0 = pos(time - t0), value
1534 elseif index == "t" then
1535 p0, v0 = posvel(time - t0)
1536 p1 = value
1537 elseif index == "d" then
1538 if value == nil then
1539 warn("nil value for d")
1540 warn(debug.traceback())
1541 value = d
1542 end
1543 p0, v0 = posvel(time - t0)
1544 d = value
1545 elseif index == "s" then
1546 if value == nil then
1547 warn("nil value for s")
1548 warn(debug.traceback())
1549 value = s
1550 end
1551 p0, v0 = posvel(time - t0)
1552 s = value
1553 elseif index == "a" then
1554 local p, v = posvel(time - t0)
1555 p0, v0 = p, v + value
1556 end
1557 t0 = time
1558 updateconstants()
1559 end
1560 return setmt(self, meta)
1561 end
1562 end
1563 do
1564 local nspring = {}
1565 physics.nspring = nspring
1566 local setmt = setmetatable
1567 local cos = math.cos
1568 local sin = math.sin
1569 local cosh = math.cosh
1570 local sinh = math.sinh
1571 local e = 2.718281828459045
1572 function nspring.new(n, d, s)
1573 local null = {}
1574 for i = 1, n do
1575 null[i] = 0
1576 end
1577 local t0 = tick()
1578 local p0 = null
1579 local v0 = null
1580 local p1 = null
1581 local d = d or 1
1582 local s = s or 1
1583 local self = {}
1584 local meta = {}
1585 local function getpv(w)
1586 local t = s * (w - t0)
1587 local d2 = d * d
1588 local h, si, co
1589 if d2 < 1 then
1590 h = (1 - d2) ^ 0.5
1591 co, si = cos(h * t), sin(h * t)
1592 elseif d2 == 1 then
1593 h = 1
1594 co, si = 1, t
1595 else
1596 h = (d2 - 1) ^ 0.5
1597 co, si = cosh(h * t), sinh(h * t)
1598 end
1599 local exp = e ^ (-d * t)
1600 local a0 = exp * (h * co + d * si) / h
1601 local a1 = 1 - exp * (h * co + d * si) / h
1602 local a2 = exp * si / (h * s)
1603 local b0 = -exp * si * s / h
1604 local b1 = exp * si * s / h
1605 local b2 = exp * (h * co - d * si) / h
1606 local p = {}
1607 local v = {}
1608 for i = 1, n do
1609 p[i] = a0 * p0[i] + a1 * p1[i] + a2 * v0[i]
1610 v[i] = b0 * p0[i] + b1 * p1[i] + b2 * v0[i]
1611 end
1612 return p, v
1613 end
1614 function self.setpv(p, v)
1615 t0 = tick()
1616 p0 = p
1617 v0 = v
1618 end
1619 function meta:__index(index)
1620 local time = tick()
1621 if index == "p" then
1622 local p, v = getpv(time)
1623 return p
1624 elseif index == "v" then
1625 local p, v = getpv(time)
1626 return v
1627 elseif index == "t" then
1628 return p1
1629 elseif index == "d" then
1630 return d
1631 elseif index == "s" then
1632 return s
1633 elseif index == "n" then
1634 return n
1635 end
1636 end
1637 function meta:__newindex(index, value)
1638 local time = tick()
1639 if index == "p" then
1640 local p, v = getpv(time)
1641 p0 = value
1642 v0 = v
1643 elseif index == "v" then
1644 local p, v = getpv(time)
1645 p0 = p
1646 v0 = value
1647 elseif index == "t" then
1648 local p, v = getpv(time)
1649 p0 = p
1650 v0 = v
1651 p1 = value
1652 elseif index == "d" then
1653 local p, v = getpv(time)
1654 p0 = p
1655 v0 = v
1656 d = value
1657 elseif index == "s" then
1658 local p, v = getpv(time)
1659 p0 = p
1660 v0 = v
1661 s = value
1662 elseif index == "n" then
1663 local p, v = getpv(time)
1664 p0 = p
1665 v0 = v
1666 for i = n + 1, value do
1667 p0[i] = 0
1668 v0[i] = 0
1669 p1[i] = 0
1670 end
1671 n = value
1672 end
1673 t0 = time
1674 end
1675 return setmt(self, meta)
1676 end
1677 end
1678 local err = 1.0E-10
1679 local function solve(a, b, c, d, e)
1680 if not a then
1681 return
1682 elseif a > -err and a < err then
1683 return solve(b, c, d, e)
1684 end
1685 if e then
1686 local k = -b / (4 * a)
1687 local p = (8 * a * c - 3 * b * b) / (8 * a * a)
1688 local q = (b * b * b + 8 * a * a * d - 4 * a * b * c) / (8 * a * a * a)
1689 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)
1690 local h0, h1, h2 = solve(1, 2 * p, p * p - 4 * r, -q * q)
1691 local s = h2 or h0
1692 if s < err then
1693 local f0, f1 = solve(1, p, r)
1694 if not f1 or f1 < 0 then
1695 return
1696 else
1697 local f = f1 ^ 0.5
1698 return k - f, k + f
1699 end
1700 else
1701 local h = s ^ 0.5
1702 local f = (h * h * h + h * p - q) / (2 * h)
1703 if f > -err and f < err then
1704 return k - h, k
1705 else
1706 local r0, r1 = solve(1, h, f)
1707 local r2, r3 = solve(1, -h, r / f)
1708 if r0 and r2 then
1709 return k + r0, k + r1, k + r2, k + r3
1710 elseif r0 then
1711 return k + r0, k + r1
1712 elseif r2 then
1713 return k + r2, k + r3
1714 else
1715 return
1716 end
1717 end
1718 end
1719 elseif d then
1720 local k = -b / (3 * a)
1721 local p = (3 * a * c - b * b) / (9 * a * a)
1722 local q = (2 * b * b * b - 9 * a * b * c + 27 * a * a * d) / (54 * a * a * a)
1723 local r = p * p * p + q * q
1724 local s = r ^ 0.5 + q
1725 if s > -err and s < err then
1726 if q < 0 then
1727 return k + (-2 * q) ^ 0.3333333333333333
1728 else
1729 return k - (2 * q) ^ 0.3333333333333333
1730 end
1731 elseif r < 0 then
1732 local m = (-p) ^ 0.5
1733 local d = atan2((-r) ^ 0.5, q) / 3
1734 local u = m * cos(d)
1735 local v = m * sin(d)
1736 return k - 2 * u, k + u - 1.7320508075688772 * v, k + u + 1.7320508075688772 * v
1737 elseif s < 0 then
1738 local m = -(-s) ^ 0.3333333333333333
1739 return k + p / m - m
1740 else
1741 local m = s ^ 0.3333333333333333
1742 return k + p / m - m
1743 end
1744 elseif c then
1745 local k = -b / (2 * a)
1746 local u2 = k * k - c / a
1747 if u2 < 0 then
1748 return
1749 else
1750 local u = u2 ^ 0.5
1751 return k - u, k + u
1752 end
1753 elseif b then
1754 return -b / a
1755 else
1756 return
1757 end
1758 end
1759 physics.solve = solve
1760 local minpos = function(a, b, c, d)
1761 if a and a >= 0 then
1762 return a
1763 elseif b and b >= 0 then
1764 return b
1765 elseif c and c >= 0 then
1766 return c
1767 elseif d and d >= 0 then
1768 return d
1769 end
1770 end
1771 physics.minpos = minpos
1772 local function minposroot(a, b, c, d, e)
1773 return minpos(solve(a, b, c, d, e))
1774 end
1775 physics.minposroot = minposroot
1776 function physics.cpoint_traj_point(v, a, r)
1777 local a0 = -2 * dot(r, v)
1778 local a1 = 2 * (dot(v, v) - dot(a, r))
1779 local a2 = 3 * dot(a, v)
1780 local a3 = dot(a, a)
1781 local t = minpos(solve(a3, a2, a1, a0))
1782 if t then
1783 return t, t * v + t * t / 2 * a
1784 end
1785 end
1786 function physics.simple_trajectory(s, a, r)
1787 local a0 = 4 * dot(r, r)
1788 local a1 = -4 * (dot(a, r) + s * s)
1789 local a2 = dot(a, a)
1790 local u = minpos(solve(a2, a1, a0))
1791 if u then
1792 local t = u ^ 0.5
1793 return r / t - t / 2 * a
1794 end
1795 end
1796 function physics.trajectory(pp, pv, pa, tp, tv, ta, s)
1797 local rp = tp - pp
1798 local rv = tv - pv
1799 local ra = ta - pa
1800 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))
1801 if t0 and t0 > 0 then
1802 return ra * t0 / 2 + tv + rp / t0, t0
1803 elseif t1 and t1 > 0 then
1804 return ra * t1 / 2 + tv + rp / t1, t1
1805 elseif t2 and t2 > 0 then
1806 return ra * t2 / 2 + tv + rp / t2, t2
1807 elseif t3 and t3 > 0 then
1808 return ra * t3 / 2 + tv + rp / t3, t3
1809 end
1810 end
1811end
1812print("Loading particle module")
1813do
1814 local setmt = setmetatable
1815 local remove = table.remove
1816 local new = Instance.new
1817 local c3 = Color3.new
1818 local ns = NumberSequence.new
1819 local v3 = Vector3.new
1820 local cf = CFrame.new
1821 local ray = Ray.new
1822 local nv = v3()
1823 local nc = cf()
1824 local dot = nv.Dot
1825 local ptos = nc.pointToObjectSpace
1826 local vtws = nc.vectorToWorldSpace
1827 local workspace = game.Workspace
1828 local camera = workspace.CurrentCamera
1829 local localplayer = game:GetService("Players").LocalPlayer
1830 local playergui = localplayer:WaitForChild("PlayerGui")
1831 local raycast = workspace.FindPartOnRayWithIgnoreList
1832 local raycastwl = workspace.FindPartOnRayWithWhitelist
1833 local ffc = game.FindFirstChild
1834 local players = game:GetService("Players")
1835 local particles = {}
1836 local removelist = {}
1837 local screen = ffc(playergui, "ScreenGui") or new("ScreenGui", playergui)
1838 local time = tick()
1839 local camcf = camera.CFrame
1840 local newbeam
1841 do
1842 local why = Instance.new("Part")
1843 why.Anchored = true
1844 why.Transparency = 1
1845 why.CanCollide = false
1846 why.Size = Vector3.new()
1847 why.CFrame = CFrame.new()
1848 why.Parent = game.Workspace
1849 function newbeam(w0)
1850 local t0, p0, v0
1851 local t1, p1, v1 = tick(), ptos(camcf, w0)
1852 local attach0 = Instance.new("Attachment", why)
1853 local attach1 = Instance.new("Attachment", why)
1854 local beam = Instance.new("Beam", why)
1855 beam.Attachment0 = attach0
1856 beam.Attachment1 = attach1
1857 beam.Segments = 16
1858 beam.TextureSpeed = 0
1859 beam.Transparency = NumberSequence.new(0)
1860 beam.FaceCamera = true
1861 local function update(w2, t2, size, bloom, brightness)
1862 local t2 = tick()
1863 local p2 = ptos(camcf, w2)
1864 local v2
1865 if t0 then
1866 v2 = 2 / (t2 - t1) * (p2 - p1) - (p2 - p0) / (t2 - t0)
1867 else
1868 v2 = (p2 - p1) / (t2 - t1)
1869 v1 = v2
1870 end
1871 t0, v0, p0 = t1, v1, p1
1872 t1, v1, p1 = t2, v2, p2
1873 local dt = t1 - t0
1874 local m0 = v0.magnitude
1875 local m1 = v1.magnitude
1876 local dist0 = -p0.z
1877 local dist1 = -p1.z
1878 if dist0 < 0 then
1879 dist0 = 0
1880 end
1881 if dist1 < 0 then
1882 dist1 = 0
1883 end
1884 local w0 = size + bloom * dist0
1885 local w1 = size + bloom * dist1
1886 local sl = (p1 - p0) * v3(1, 1, 0)
1887 local l = sl.magnitude
1888 local tr = 1 - 4 * size * size / ((w0 + w1) * (2 * l + w0 + w1)) * brightness
1889 beam.Width0 = w0
1890 beam.Width1 = w1
1891 beam.Transparency = ns(tr)
1892 beam.CurveSize0 = dt / 3 * m0
1893 beam.CurveSize1 = dt / 3 * m1
1894 attach0.Position = camcf * (p0 - w0 / (2 * l) * sl)
1895 attach1.Position = camcf * (p1 + w1 / (2 * l) * sl)
1896 if m0 > 1.0E-8 then
1897 attach0.Axis = vtws(camcf, v0 / m0)
1898 end
1899 if m1 > 1.0E-8 then
1900 attach1.Axis = vtws(camcf, v1 / m1)
1901 end
1902 end
1903 local function remove()
1904 attach0:Destroy()
1905 attach1:Destroy()
1906 beam:Destroy()
1907 end
1908 return beam, update, remove
1909 end
1910 end
1911 function particle.new(prop)
1912 local self = {}
1913 local position = prop.position or nv
1914 local velocity = prop.velocity or nv
1915 local acceleration = prop.acceleration or nv
1916 local culling = prop.culling == nil or prop.culling
1917 local size = prop.size or 1
1918 local bloom = prop.bloom or 0
1919 local brightness = prop.brightness or 1
1920 local cancollide = prop.cancollide == nil or prop.cancollide
1921 local elasticity = prop.elasticity or 0.3
1922 local physicsonly = prop.physicsonly or false
1923 local minexitvelocity = prop.minexitvelocity or 500
1924 local penetrationdepth = prop.penetrationdepth
1925 local visualorigin = prop.visualorigin or position
1926 local visualoffset = visualorigin - position
1927 local penetrationpower = penetrationdepth
1928 local life = tick() + (prop.life or 10)
1929 local physignore = prop.physicsignore or {
1930 workspace.Ignore,
1931 camera,
1932 char.character
1933 }
1934 local onstep = prop.onstep
1935 local ontouch = prop.ontouch
1936 local initpenetrationdepth = penetrationdepth
1937 local nopenetration = prop.nopenetration
1938 function self:remove()
1939 removelist[self] = true
1940 end
1941 local part, stopmotion
1942 local lastt = tick()
1943 local bullet, bulletupdate, bulletremove = newbeam(position + visualoffset)
1944 bullet.Texture = "http://www.roblox.com/asset/?id=2650195052"
1945 bullet.LightEmission = 1
1946 bullet.Color = ColorSequence.new(prop.color or c3(1, 1, 1))
1947 self.bullet = bullet
1948 self.bulletupdate = bulletupdate
1949 self.bulletremove = bulletremove
1950 function self.step(dt, time)
1951 dt = time - lastt
1952 lastt = time
1953 if life and time > life then
1954 removelist[self] = true
1955 return
1956 end
1957 if not stopmotion then
1958 local position0 = position
1959 local velocity0 = velocity
1960 local dposition = dt * velocity0 + dt * dt / 2 * acceleration
1961 if cancollide then
1962 local hit, enter, norm = raycast(workspace, ray(position0, dposition), physignore)
1963 if hit then
1964 local unit = dposition.unit
1965 local maxextent = hit.Size.magnitude * unit
1966 local _, exit, exitnorm = raycastwl(workspace, ray(enter + maxextent, -maxextent), {hit})
1967 local diff = exit - enter
1968 local dist = dot(unit, diff)
1969 local human = replication.getcharhitinfo(hit, enter, maxextent)
1970 local pass = not hit.CanCollide or hit.Transparency == 1 or human and human.player.TeamColor == localplayer.TeamColor
1971 local exited = false
1972 position = enter + 0.01 * unit
1973 local truedt = dot(dposition, enter - position0) / dot(dposition, dposition) * dt
1974 velocity = velocity0 + truedt * acceleration
1975 if not pass and not nopenetration then
1976 if dist < penetrationdepth then
1977 penetrationdepth = human and penetrationdepth or penetrationdepth - dist
1978 exited = true
1979 else
1980 removelist[self] = true
1981 end
1982 end
1983 if ontouch then
1984 ontouch(part, human and human.object or hit, enter, norm, exited and exit, exited and exitnorm, 1, human and human.player)
1985 end
1986 physignore[#physignore + 1] = human and human.character or hit
1987 else
1988 position = position0 + dposition
1989 velocity = velocity0 + dt * acceleration
1990 end
1991 else
1992 position = position0 + dposition
1993 velocity = velocity0 + dt * acceleration
1994 end
1995 end
1996 if onstep then
1997 onstep(part, dt)
1998 end
1999 bulletupdate(position + visualoffset, time, size, bloom, brightness)
2000 end
2001 particles[self] = true
2002 local get = {}
2003 local set = {}
2004 local meta = {}
2005 function meta.__index(table, index)
2006 return get[index]()
2007 end
2008 function meta.__newindex(table, index, value)
2009 return set[index](value)
2010 end
2011 function get.position()
2012 return position
2013 end
2014 function get.velocity()
2015 return velocity
2016 end
2017 function get.acceleration()
2018 return acceleration
2019 end
2020 function get.cancollide()
2021 return cancollide
2022 end
2023 function get.size()
2024 return size
2025 end
2026 function get.bloom()
2027 return bloom
2028 end
2029 function get.brightness()
2030 return brightness
2031 end
2032 function get.color()
2033 return bullet.Color
2034 end
2035 function get.life()
2036 return life - tick()
2037 end
2038 function get.distance()
2039 return 1
2040 end
2041 function get.hitwall()
2042 return penetrationdepth ~= initpenetrationdepth
2043 end
2044 function get.stopmotion()
2045 return stopmotion
2046 end
2047 function set.position(p)
2048 position = p
2049 end
2050 function set.velocity(v)
2051 velocity = v
2052 end
2053 function set.acceleration(a)
2054 acceleration = a
2055 end
2056 function set.cancollide(newcancollide)
2057 cancollide = newcancollide
2058 end
2059 function set.size(newsize)
2060 size = newsize
2061 end
2062 function set.bloom(newbloom)
2063 bloom = newbloom
2064 end
2065 function set.brightness(newbrightness)
2066 brightness = newbrightness
2067 end
2068 function set.color(newcolor)
2069 bullet.Color = newcolor
2070 end
2071 function set.life(newlife)
2072 life = tick() + newlife
2073 end
2074 function set.stopmotion(stop)
2075 stopmotion = stop
2076 end
2077 part = setmt(self, meta)
2078 if prop.dt then
2079 self.step(prop.dt, tick())
2080 end
2081 return part
2082 end
2083 function particle.step(dt)
2084 local newtime = tick()
2085 local dt = newtime - time
2086 time = newtime
2087 camcf = camera.CoordinateFrame
2088 for p in next, particles, nil do
2089 if removelist[p] then
2090 removelist[p] = nil
2091 particles[p] = nil
2092 p.bulletremove()
2093 else
2094 p.step(dt, time)
2095 end
2096 end
2097 end
2098 function particle:reset()
2099 screen:ClearAllChildren()
2100 for p in next, particles, nil do
2101 p.bulletremove()
2102 end
2103 particles = {}
2104 removelist = {}
2105 end
2106 screen.AncestryChanged:connect(function()
2107 wait()
2108 screen.Parent = playergui
2109 end)
2110end
2111print("Loading (new) sound module")
2112local AudioSystem = require(script.Audio)
2113AudioSystem.CreateSubset("friendly_concreterun", 2302070094, 2302070284, 2302070458, 2302070592, 2302070707, 2302070844, 2302070966, 2302071087)
2114AudioSystem.CreateSubset("friendly_concretewalk", 2302021208, 2302021335, 2302021551, 2302021657, 2302021782, 2302021878, 2302021984, 2302022108)
2115AudioSystem.CreateSubset("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2116AudioSystem.CreateSubset("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2117AudioSystem.CreateSubset("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2118AudioSystem.CreateSubset("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2119AudioSystem.CreateSubset("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2120AudioSystem.CreateSubset("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2121AudioSystem.CreateSubset("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2122AudioSystem.CreateSubset("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2123AudioSystem.CreateSubset("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2124AudioSystem.CreateSubset("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2125AudioSystem.CreateSubset("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2126AudioSystem.CreateSubset("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2127AudioSystem.CreateSubset("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2128AudioSystem.CreateSubset("cloth_walk", 2302150174, 2302150284, 2302150389)
2129AudioSystem.CreateSubset("cloth_run", 2302219003, 2302219089, 2302219185)
2130AudioSystem.CreateSubset("movement_extra", 2302255889, 2302256006, 2302256131, 2302256237, 2302256317, 2302256414, 2302256526, 2302256725, 2302256850)
2131AudioSystem.CreateSubset("concreteLand", 623307723, 623307791, 623307897)
2132AudioSystem.CreateSubset("grassLand", 623322852, 623322902, 623322960)
2133AudioSystem.CreateSubset("sandLand", 623308020, 623322719, 623322784)
2134AudioSystem.CreateSubset("woodLand", 623329224, 623329303, 623329368)
2135AudioSystem.CreateSubset("metalLand", 866618834, 866618870, 866618897, 866618921)
2136AudioSystem.CreateSubset("landHard", 866638867)
2137AudioSystem.CreateSubset("landNearDeath", 866639973)
2138game:GetService("ContentProvider"):PreloadAsync(AudioSystem.PreloadFolder:GetChildren())
2139AudioSystem.CreateSoundGroup("SelfFoley", 0.5)
2140print("Loading (old) sound module")
2141do
2142 local random = math.random
2143 local new = Instance.new
2144 local fonts = {}
2145 local free = {}
2146 if doPreloading then
2147 local preloadingFolder = Instance.new("Folder")
2148 preloadingFolder.Parent = workspace
2149 preloadingFolder.Name = "Preloading"
2150 end
2151 function sound.load(name, ...)
2152 local font = {
2153 ...
2154 }
2155 for i = 1, #font do
2156 font[i] = "rbxassetid://" .. font[i]
2157 if doPreloading then
2158 local newsound = Instance.new("Sound")
2159 newsound.Parent = workspace:FindFirstChild("Preloading")
2160 newsound.SoundId = font[i]
2161 end
2162 end
2163 fonts[name] = font
2164 end
2165 function sound.play(name, volume, pitch, parent, onDestroy, isLooped, destroySound)
2166 local font = fonts[name]
2167 if font then
2168 do
2169 local soundobject
2170 if #free == 0 then
2171 soundobject = new("Sound")
2172 soundobject.Ended:connect(function()
2173 free[#free + 1] = soundobject
2174 soundobject.Parent = workspace
2175 end)
2176 else
2177 soundobject = free[#free]
2178 free[#free] = nil
2179 end
2180 soundobject.SoundId = font[random(1, #font)]
2181 soundobject.Volume = volume or 1
2182 soundobject.Pitch = pitch or 1
2183 soundobject.Looped = isLooped
2184 soundobject.Parent = parent or workspace
2185 if onDestroy then
2186 soundobject.PlayOnRemove = true
2187 else
2188 soundobject:Play()
2189 end
2190 end
2191 end
2192 end
2193 sound.load("ui_begin", 2201625166)
2194 sound.load("ui_blink", 2201638398, 2201628272, 2201638578, 2201645683, 2201638926, 2201628742)
2195 sound.load("ui_typeoutwhoosh", 2201650206)
2196 sound.load("ui_typeout", 2201663791, 2201663994, 2201664220, 2201664369, 2201664545, 2201664693)
2197 sound.load("ui_smallaward", 2201705675)
2198 sound.load("equipCloth", 873041870, 873041900, 873041920, 873041944, 873041967, 873041996)
2199 sound.load("equipGear", 873042033, 873042054, 873042146, 873042186, 873042220, 873042247)
2200 sound.load("smallSharp", 1073249423, 1073249467, 1073249515)
2201 sound.load("smallSharpEquip", 1073252883, 1073252922)
2202 sound.load("bigSharp", 1073259492, 1073259546)
2203 sound.load("bigSharpEquip", 1073259576)
2204 sound.load("saber", 1073290506, 1073290552, 1073290611)
2205 sound.load("saberEquip", 1073290296, 1073290384, 1073290458)
2206 sound.load("saberLoop", 1073293116)
2207 sound.load("smallBluntEquip", 1073355154)
2208 sound.load("bigBluntEquip", 1073355392)
2209 sound.load("bigBlunt", 1073356333, 1073356365, 1073356402)
2210 sound.load("smallBlunt", 1073356781)
2211 sound.load("aimCloth", 873073597, 873073657, 873073703, 873073749, 873073824, 873073853)
2212 sound.load("aimGear", 873073890, 873073947, 873073999, 873074053, 873074075, 873074102)
2213 sound.load("parkour", 873084310, 873084337, 873084366, 873084394, 873084419, 873084440)
2214 sound.load("stanceProne", 619647373, 619647453)
2215 sound.load("stanceStandCrouch", 619647649, 619649245, 619649367)
2216 sound.load("slideStart", 873104808, 873104834, 873104858, 873104886, 873104915, 873104940)
2217 sound.load("slideEnd", 873101789, 873101811, 873101828)
2218 sound.load("heartBeatIn", 635546179)
2219 sound.load("heartBeatOut", 635546243)
2220 sound.load("useScope", 635546067)
2221 sound.load("killshot", 898398768, 898398730, 898398743)
2222 sound.load("headshotkill", 898398768, 898398785, 898398795, 898398809, 898398817, 898398837)
2223 sound.load("crackSmall", 873119768, 873119788, 873119811, 873119845, 873119886, 873119904)
2224 sound.load("crackBig", 873119597, 873119653, 873119679, 873119703, 873119724, 873119744)
2225 sound.load("whizz", 873121840, 873121858, 873121876, 873121896, 873121913, 873121936)
2226 sound.load("1PsniperBass", 725750810, 725750891, 725750973)
2227 sound.load("1PsniperEcho", 725751043, 725751110, 725751178)
2228 sound.load("fragClose", 873196488, 873196525, 873196559, 873196591, 873196633, 873196678)
2229 sound.load("fragMed", 873196719, 873196759, 873196789, 873196821, 873196855, 873196883, 873196918, 873196944)
2230 sound.load("fragFar", 873196972, 873196997, 873197013, 873197044, 873197083, 873197117)
2231 sound.load("friendly_concreterun", 738449694, 738449739, 738449789, 738449845, 738449901, 738449961)
2232 sound.load("friendly_concretewalk", 738450012, 738450072, 738450121, 738450173, 738450221, 738450271)
2233 sound.load("friendly_concretescuff", 738476779, 738476835, 738476883, 738476924)
2234 sound.load("friendly_grassrun", 738484818, 738484890, 738484962, 738485221, 738485290, 738485364)
2235 sound.load("friendly_grasswalk", 738486870, 738486925, 738486971, 738487026, 738487059, 738487106)
2236 sound.load("friendly_grassscuff", 738488265, 738488385, 738488447, 738488512)
2237 sound.load("friendly_woodrun", 739361221, 739361264, 739361281, 739361317, 739361357, 739361379)
2238 sound.load("friendly_woodwalk", 739361404, 739361426, 739361445, 739361473, 739361503, 739361526)
2239 sound.load("friendly_woodscuff", 739361547, 739361572, 739361584, 739361608)
2240 sound.load("friendly_sandrun", 743048910, 743048927, 743048941, 743048953, 743048965, 743048979)
2241 sound.load("friendly_sandwalk", 743049002, 743049031, 743049053, 743049073, 743049085, 743049103)
2242 sound.load("friendly_sandscuff", 743049123, 743049139, 743049153, 743049162)
2243 sound.load("friendly_metalrun", 744281043, 744281081, 744281118, 744281156, 744281205, 744281233)
2244 sound.load("friendly_metalwalk", 744281257, 744281287, 744281319, 744281350, 744281374, 744281411)
2245 sound.load("friendly_metalscuff", 758169120, 758169193, 758169297, 758169399)
2246 sound.load("concreteLand", 623307723, 623307791, 623307897)
2247 sound.load("grassLand", 623322852, 623322902, 623322960)
2248 sound.load("sandLand", 623308020, 623322719, 623322784)
2249 sound.load("woodLand", 623329224, 623329303, 623329368)
2250 sound.load("metalLand", 866618834, 866618870, 866618897, 866618921)
2251 sound.load("landHard", 866638867)
2252 sound.load("landNearDeath", 866639973)
2253 sound.load("enemy_concreterun", 739281446, 739281465, 739281494, 739281525, 739281543, 739281565)
2254 sound.load("enemy_concretewalk", 739281325, 739281342, 739281360, 739281381, 739281395, 739281423)
2255 sound.load("enemy_woodrun", 739377453, 739377475, 739377503, 739377526, 739377546, 739377556)
2256 sound.load("enemy_woodwalk", 739377579, 739377595, 739377625, 739377652, 739377685, 739377713)
2257 sound.load("enemy_grassrun", 739805543, 739805588, 739805641, 739805681, 739805724, 739805762)
2258 sound.load("enemy_grasswalk", 739805800, 739805889, 739805996, 739806047, 739806110, 739806155)
2259 sound.load("enemy_sandrun", 744274870, 744274901, 744274936, 744274967, 744275010, 744275043)
2260 sound.load("enemy_sandwalk", 744275075, 744275099, 744275126, 744275156, 744275192, 744275220)
2261 sound.load("enemy_metalrun", 758173026, 758173133, 758173185, 758173250, 758173441, 758173516)
2262 sound.load("enemy_metalwalk", 758173608, 758173682, 758173759, 758173891, 758173986, 758174065)
2263 sound.load("movement_gearsmall", 677006227, 677006264, 677006302, 677006342, 677006383, 677007056, 677007096, 677007128)
2264 sound.load("movement_gearbig", 677010268, 677010313, 677010351, 677010399, 677010436, 677010482, 677010520, 677010549)
2265 sound.load("movement_clothrun", 724561895, 724561958, 724561997, 724562031)
2266 sound.load("movement_clothwalk", 724559173, 724559198, 724559218, 724559241)
2267 sound.load("movement_base", 676998794, 676998859, 676998915, 676998993, 676999050, 676999094, 676999145, 676999188, 676999245, 676999327, 676999356, 676999395)
2268 sound.load("imp_concrete", 871701076, 871701134, 871701190, 871701241, 871701297, 871701346)
2269 sound.load("imp_metal", 871704182, 871704259, 871704297, 871704329, 871704362, 871704395)
2270 sound.load("imp_wood", 871705143, 871705174, 871705217, 871705237, 871705264)
2271 sound.load("imp_grass", 871709869, 871709832, 871709789, 871709755, 871709708, 871709643)
2272 sound.load("wizz", 342190005, 342190012, 342190017, 342190024)
2273 sound.load("snap", 342190488, 342190495, 342190504, 342190510)
2274 sound.load("woodhit", 342204157, 342204164, 342204170, 342204175)
2275 sound.load("stonehit", 342204189, 342204194, 342204197, 342204203)
2276 sound.load("metalhit", 342204233, 342204240, 342204244, 342204250)
2277 sound.load("woodstep", 169160364)
2278 sound.load("hardstep", 135923526, 342422087, 131436155)
2279 sound.load("softstep", 134456884)
2280 sound.load("fullmetalstep", 342421947, 342421958, 342421973, 342421997)
2281 sound.load("hollowmetalstep", 342421947, 342421958, 342421973, 342421997)
2282 sound.load("metalshell", 342423812, 342423826, 342423844, 342423860)
2283 sound.load("shotgunshell", 342423873, 342423885)
2284 if doPreloading then
2285 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)
2286 end
2287end
2288globalsound = sound
2289globalreplication = replication
2290print("Loading effects module")
2291do
2292 local wfc = game.WaitForChild
2293 local ffc = game.FindFirstChild
2294 local ud2 = UDim2.new
2295 local v3 = Vector3.new
2296 local nv = v3()
2297 local cf = CFrame.new
2298 local angles = CFrame.Angles
2299 local deg = math.pi / 180
2300 local random = math.random
2301 local color = Color3.new
2302 local colorseq = ColorSequence.new
2303 local spawn = function(F)
2304 coroutine.resume(coroutine.create(F))
2305 end
2306 local ray = Ray.new
2307 local raycast = workspace.FindPartOnRayWithIgnoreList
2308 local debris = game.Debris
2309 local new = Instance.new
2310 local dot = nv.Dot
2311 local nc = cf()
2312 local vtws = nc.vectorToWorldSpace
2313 local player = game:GetService("Players").LocalPlayer
2314 local light = game.Lighting
2315 local pgui = player.PlayerGui
2316 local repeffects = game.ReplicatedStorage.Effects
2317 local smoke = repeffects.Smoke
2318 local hole = repeffects.Hole
2319 local flash = repeffects.Muzzle
2320 local shell = repeffects.Shell
2321 local blood = repeffects.Blood
2322 local bloodsplat = repeffects.BloodSplat
2323 local ignore = workspace.Ignore
2324 local mapbloom = wfc(light, "MapBloom")
2325 local mapray = wfc(light, "MapRay")
2326 local mapsat = wfc(light, "MapSaturation")
2327 local smokelist = {}
2328 local holelist = {}
2329 local flashlist = {}
2330 local shelllist = {}
2331 local impactpool = {}
2332 local effectobjects = repeffects.effectobjects
2333 local materialtype = Enum.Material
2334 local materiallist = {
2335 [Enum.Material.Cobblestone] = {
2336 185234383,
2337 185234399,
2338 185234373,
2339 185234412
2340 },
2341 [Enum.Material.Wood] = {
2342 185238181,
2343 185238234,
2344 185238224,
2345 185238210,
2346 185238204
2347 },
2348 [Enum.Material.Brick] = {
2349 185237818,
2350 185237842,
2351 185237826,
2352 185237805
2353 },
2354 [Enum.Material.Plastic] = {
2355 185238152,
2356 185237945,
2357 185237930
2358 },
2359 [Enum.Material.Concrete] = {
2360 185237894,
2361 185237879,
2362 185237865,
2363 185237853
2364 },
2365 Tile = {
2366 185238332,
2367 185238308,
2368 185238298,
2369 185238288,
2370 185238271,
2371 185238257
2372 }
2373 }
2374 local splatter
2375 do
2376 local sort = table.sort
2377 local random = math.random
2378 local log = math.log
2379 local cos = math.cos
2380 local sin = math.sin
2381 local tau = 2 * math.pi
2382 local function gaussian()
2383 local r0 = 1 - random()
2384 local r1 = random() * tau
2385 local l = (-2 * log(r0)) ^ 0.5
2386 return l * cos(r1), l * sin(r1)
2387 end
2388 local function exponential()
2389 return -log(1 - random())
2390 end
2391 local boxn = {
2392 v3(1, 0, 0),
2393 v3(-1, 0, 0),
2394 v3(0, 1, 0),
2395 v3(0, -1, 0),
2396 v3(0, 0, 1),
2397 v3(0, 0, -1)
2398 }
2399 local boxl = {
2400 0.5,
2401 0.5,
2402 0.5,
2403 0.5,
2404 0.5,
2405 0.5
2406 }
2407 local function transform_mesh(meshn, meshl, cframe, size)
2408 local newn = {}
2409 local newl = {}
2410 for i = 1, #meshn do
2411 local n = meshn[i]
2412 local l = meshl[i]
2413 local tn = vtws(cframe, n / size).unit
2414 local tl = dot(cframe * (l * n * size), tn)
2415 newn[i] = tn
2416 newl[i] = tl
2417 end
2418 return newn, newl
2419 end
2420 local function distance_o_1(an, al, o)
2421 local oan = dot(o, an)
2422 return oan - al
2423 end
2424 local function distance_o_2(an, al, bn, bl, o)
2425 local anbn = dot(an, bn)
2426 local oan = dot(o, an)
2427 local obn = dot(o, bn)
2428 local m = (1 - anbn * anbn) ^ 0.5
2429 return (bl - al * anbn + anbn * oan - obn) / m
2430 end
2431 local function dist_from_edge(meshn, meshl, o)
2432 local besta
2433 local bestd = -1 / 0
2434 for i = 1, #meshn do
2435 local an = meshn[i]
2436 local al = meshl[i]
2437 local d = distance_o_1(an, al, o)
2438 if bestd < d then
2439 besta = i
2440 bestd = d
2441 end
2442 end
2443 if not besta then
2444 return 1 / 0
2445 end
2446 local an = meshn[besta]
2447 local al = meshl[besta]
2448 local r = 1 / 0
2449 for i = 1, #meshn do
2450 if i ~= besta then
2451 local bn = meshn[i]
2452 local bl = meshl[i]
2453 local d = distance_o_2(an, al, bn, bl, o)
2454 if r > d then
2455 r = d
2456 end
2457 end
2458 end
2459 return r
2460 end
2461 local meshcache = {}
2462 local function getmesh(part)
2463 local cache = meshcache[part]
2464 if cache then
2465 return cache.meshn, cache.meshl
2466 else
2467 do
2468 local cframe = part.CFrame
2469 local size = part.Size
2470 local meshn, meshl = transform_mesh(boxn, boxl, part.CFrame, part.Size)
2471 meshcache[part] = {meshn = meshn, meshl = meshl}
2472 local event
2473 event = part.Changed:connect(function()
2474 meshcache[part] = nil
2475 event:disconnect()
2476 end)
2477 return meshn, meshl
2478 end
2479 end
2480 end
2481 local function max_radius(part, pos)
2482 local meshn, meshl = getmesh(part)
2483 return dist_from_edge(meshn, meshl, pos)
2484 end
2485 local spartpool = {}
2486 local function getspart()
2487 local pooledpart = spartpool[#spartpool]
2488 if pooledpart then
2489 spartpool[#spartpool] = nil
2490 return pooledpart
2491 else
2492 local spart = Instance.new("Part")
2493 spart.Shape = "Cylinder"
2494 spart.Anchored = true
2495 spart.CanCollide = false
2496 spart.BrickColor = BrickColor.new("Crimson")
2497 return spart
2498 end
2499 end
2500 local function retirespart(part)
2501 spartpool[#spartpool + 1] = part
2502 end
2503 local function sortandmerge(slist, ulist, lt)
2504 sort(ulist, lt)
2505 local mlist = {}
2506 local m = #slist
2507 local n = #ulist
2508 local i = 1
2509 local j = 1
2510 local k = 0
2511 while m >= i and n >= j do
2512 k = k + 1
2513 local a = slist[i]
2514 local b = ulist[j]
2515 if lt(a, b) then
2516 i = i + 1
2517 mlist[k] = a
2518 else
2519 j = j + 1
2520 mlist[k] = b
2521 end
2522 end
2523 for l = i, m do
2524 k = k + 1
2525 mlist[k] = slist[l]
2526 end
2527 for l = j, n do
2528 k = k + 1
2529 mlist[k] = ulist[l]
2530 end
2531 return mlist
2532 end
2533 local queuedsplatters = {}
2534 local queuedretires = {}
2535 local nsplatters = 0
2536 local splatters = {}
2537 local nretires = 0
2538 local retires = {}
2539 local maxbloodt = 1
2540 local compt0 = function(a, b)
2541 return b.t0 < a.t0
2542 end
2543 local compt1 = function(a, b)
2544 return b.t1 < a.t1
2545 end
2546 function effects.setmaxbloodt(newt)
2547 maxbloodt = newt
2548 end
2549 game:GetService("RunService").RenderStepped:connect(function()
2550 debug.profilebegin("blood creation/removal")
2551 local t = tick()
2552 if nsplatters > 0 then
2553 queuedsplatters = sortandmerge(queuedsplatters, splatters, compt0)
2554 nsplatters = 0
2555 splatters = {}
2556 end
2557 for i = #queuedsplatters, 1, -1 do
2558 if maxbloodt / 1000 < tick() - t then
2559 break
2560 end
2561 local splat = queuedsplatters[i]
2562 if t > splat.t0 then
2563 queuedsplatters[i] = nil
2564 local spart = getspart()
2565 local size = splat.size
2566 local part = splat.part
2567 local norm = splat.norm
2568 local pos = splat.pos
2569 local maxsize = 2 * max_radius(part, pos)
2570 if size > maxsize then
2571 size = maxsize
2572 end
2573 local spart = getspart()
2574 spart.Size = v3(0.05, size, size)
2575 spart.CFrame = cf(pos, pos + norm) * angles(0, tau / 4, 0)
2576 spart.Parent = workspace.Ignore
2577 nretires = nretires + 1
2578 retires[nretires] = {
2579 t1 = splat.t1,
2580 spart = spart
2581 }
2582 else
2583 break
2584 end
2585 end
2586 if nretires > 0 then
2587 queuedretires = sortandmerge(queuedretires, retires, compt1)
2588 nretires = 0
2589 retires = {}
2590 end
2591 for i = #queuedretires, 1, -1 do
2592 if maxbloodt / 1000 < tick() - t then
2593 break
2594 end
2595 local retire = queuedretires[i]
2596 if t > retire.t1 then
2597 queuedretires[i] = nil
2598 retire.spart.Parent = nil
2599 retirespart(retire.spart)
2600 else
2601 break
2602 end
2603 end
2604 debug.profileend()
2605 end)
2606 function splatter(splots, avgsize, orig, velocity, spread, dist, ignorelist, life0, life1)
2607 debug.profilebegin("blood initialization")
2608 local ct = tick()
2609 local v = spread * velocity.magnitude
2610 for i = 1, splots do
2611 local r0, r1 = gaussian()
2612 local r2 = gaussian()
2613 local r3 = exponential()
2614 local dir = velocity + v3(v * r0, v * r1, v * r2)
2615 local size = avgsize * r3
2616 local part, pos, norm = raycast(workspace, ray(orig, dist * dir.unit), ignorelist)
2617 if part and part.Name ~= "Window" and part.Transparency ~= 1 then
2618 nsplatters = nsplatters + 1
2619 local t0 = ct + dot(dir, pos - orig) / dot(dir, dir)
2620 local t1 = t0 + random() * (life1 - life0) + life0
2621 splatters[nsplatters] = {
2622 t0 = t0,
2623 t1 = t1,
2624 size = size,
2625 part = part,
2626 norm = norm,
2627 pos = pos
2628 }
2629 end
2630 end
2631 debug.profileend()
2632 end
2633 end
2634 function effects:ejectshell(trigger, guntype, offset)
2635 local shellpart
2636 if #shelllist ~= 0 then
2637 shellpart = shelllist[#shelllist]
2638 shelllist[#shelllist] = nil
2639 else
2640 shellpart = shell:Clone()
2641 end
2642 delay(0.1, function()
2643 shellpart.CFrame = trigger.CFrame * angles((90 + random(-5, 5)) * deg, random(-5, 5) * deg, random(-5, 5) * deg) * offset
2644 shellpart.RotVelocity = v3(random(-5, 5), random(-5, 5), random(-5, 5))
2645 shellpart.Parent = ignore
2646 shellpart.BodyThrust.force = v3(3.5, 0.1, -3)
2647 wait(0.05)
2648 shellpart.BodyThrust.force = v3(-0.5, 0, 0)
2649 wait(0.1)
2650 shellpart.BodyThrust.force = v3(0, 0, 0)
2651 wait(0.1)
2652 shellpart.Velocity = v3()
2653 shellpart.Parent = nil
2654 shelllist[#shelllist + 1] = shellpart
2655 end)
2656 end
2657 function effects:muzzleflash(barrel)
2658 local flashpart
2659 if #flashlist ~= 0 then
2660 flashpart = flashlist[#flashlist]
2661 flashlist[#flashlist] = nil
2662 else
2663 flashpart = flash:Clone()
2664 end
2665 local flare = ffc(flashpart, "Flare")
2666 local spark = ffc(flashpart, "Spark")
2667 if not flare or not spark then
2668 trash.remove(flashpart)
2669 flashpart = flash:Clone()
2670 flare = ffc(flashpart, "Flare")
2671 spark = ffc(flashpart, "Spark")
2672 end
2673 flashpart.Enabled = true
2674 flashpart.Parent = pgui
2675 flashpart.Adornee = barrel
2676 flare.Rotation = random(0, 360)
2677 flare.Size = ud2(0, 20, 0, 20)
2678 flare.Position = ud2(0.5, -10, 0.5, -10)
2679 spark.Rotation = random(0, 360)
2680 spark.Size = ud2(0, 200, 0, 200)
2681 spark.Position = ud2(0.5, -100, 0.5, -100)
2682 spark.Visible = true
2683 flare:TweenSizeAndPosition(ud2(0, 1000, 0, 1000), ud2(0.5, -500, 0.5, -500), "Out", "Sine", 0.2)
2684 spark:TweenSizeAndPosition(ud2(0, 500, 0, 500), ud2(0.5, -250, 0.5, -250), "Out", "Sine", 0.15)
2685 delay(0.05, function()
2686 spark.Visible = false
2687 wait(0.05)
2688 flashpart.Enabled = false
2689 wait(0.5)
2690 flashpart.Parent = nil
2691 flashlist[#flashlist + 1] = flashpart
2692 end)
2693 char:firemuzzlelight()
2694 end
2695 function effects:breakwindow(hit, pos, norm, vel, force, nobulleteffect)
2696 hit.Parent = ignore
2697 hit.CanCollide = false
2698 local breakSound = "Break" .. math.random(1, 3)
2699 local soundfont = ({
2700 Break1 = "http://roblox.com/asset/?id=627558532",
2701 Break2 = "http://roblox.com/asset/?id=627558611",
2702 Break3 = "http://roblox.com/asset/?id=627558676"
2703 })[breakSound]
2704 local shat = new("Sound", hit)
2705 shat.SoundId = soundfont
2706 shat.Volume = 0.75
2707 shat.MaxDistance = 200
2708 local winshatter = repeffects.WindowShatter:Clone()
2709 winshatter.Parent = hit
2710 winshatter.Color = ColorSequence.new(hit.Color)
2711 winshatter.Transparency = NumberSequence.new(hit.Transparency)
2712 winshatter.Enabled = true
2713 local size = hit.Size.Magnitude / 15
2714 local kp1 = NumberSequenceKeypoint.new(0, size, size / 4)
2715 local kp2 = NumberSequenceKeypoint.new(1, size, size / 4)
2716 winshatter.Size = NumberSequence.new({kp1, kp2})
2717 shat.Ended:connect(function()
2718 shat:Destroy()
2719 end)
2720 shat:Play()
2721 hit.Transparency = 1
2722 game.Debris:AddItem(hit, 1)
2723 if not nobulleteffect then
2724 effects:bullethit(hit, pos, norm, nil, nil, vel, false, false, 3)
2725 end
2726 delay(0.1, function()
2727 winshatter.Enabled = false
2728 end)
2729 end
2730 function effects:breakwindows(windows)
2731 for i, window in next, windows, nil do
2732 effects:breakwindow(window, window.Position, nv, nv, nv, true)
2733 end
2734 end
2735 function effects:bloodhit(start, hit, pos, norm, enablesplatter, damage, velocity)
2736 local damage = damage or 20
2737 if damage > 100 then
2738 damage = 100
2739 end
2740 network:send("b" .. "l" .. "o" .. "o" .. "d" .. "h" .. "i" .. "t", start, hit, pos, norm, enablesplatter, damage / 3, velocity)
2741 createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2742 end
2743 function effects:enablemapshaders(on)
2744 local shaderlist = {mapsat, mapray}
2745 for i = 1, #shaderlist do
2746 if effects.disableshaders then
2747 shaderlist[i].Enabled = false
2748 else
2749 shaderlist[i].Enabled = on
2750 end
2751 end
2752 end
2753 function createblood(start, hit, pos, norm, enablesplatter, damage, velocity)
2754 if input.consoleon or effects.disableblood then
2755 return
2756 end
2757 local size = 1
2758 local ignorelist = {
2759 ignore,
2760 workspace.DeadBody,
2761 workspace.CurrentCamera
2762 }
2763 local pp = game:GetService("Players"):GetPlayers()
2764 for i = 1, #pp do
2765 ignorelist[#ignorelist + 1] = pp[i].Character
2766 end
2767 if enablesplatter then
2768 local damage = damage or 20
2769 local splots = damage / 2
2770 splatter(splots, 0.5, pos, velocity, 0.125, 20, ignorelist, 7, 15)
2771 end
2772 local bloodpart = hole:Clone()
2773 bloodpart.Parent = ignore
2774 bloodpart.CFrame = cf(pos)
2775 bloodpart.Transparency = 1
2776 bloodpart:ClearAllChildren()
2777 local test = repeffects.BloodTest:Clone()
2778 test.Parent = bloodpart
2779 test.Rate = test.Rate * size
2780 test.Enabled = true
2781 spawn(function()
2782 wait(0.1)
2783 test.Enabled = false
2784 end)
2785 debris:AddItem(bloodpart, 3)
2786 end
2787 network:add("createblood", createblood)
2788 local function makeimpact(hit, pos, norm)
2789 local impacttype
2790 if hit.Name == "Terrain" then
2791 impacttype = "ImpactWater"
2792 elseif hit.Material == Enum.Material.Grass then
2793 impacttype = "ImpactGrass"
2794 else
2795 impacttype = "ImpactDefault"
2796 end
2797 local impact
2798 local pool = impactpool[impacttype]
2799 if not pool then
2800 impactpool[impacttype] = {}
2801 pool = impactpool[impacttype]
2802 end
2803 if #pool == 0 then
2804 impact = effectobjects[impacttype]:Clone()
2805 impact.Parent = ignore
2806 else
2807 impact = pool[#pool]
2808 pool[#pool] = nil
2809 end
2810 impact.CFrame = cf(pos, pos + 2 * norm + vector.random(1))
2811 local pt = impact:GetChildren()
2812 for i = 1, #pt do
2813 if pt[i]:IsA("ParticleEmitter") then
2814 pt[i].Acceleration = v3(5 * (random() - 0.5), pt[i].Acceleration.Y, 5 * (random() - 0.5))
2815 pt[i].EmissionDirection = "Front"
2816 pt[i]:Emit(pt[i].Rate / 10)
2817 end
2818 end
2819 if impacttype == "Impact1" then
2820 impact.effcloud.EmissionDirection = random(0, 5)
2821 end
2822 delay(0.05, function()
2823 pool[#pool + 1] = impact
2824 end)
2825 end
2826 local function makehole(hit, pos, norm)
2827 local holepart
2828 if #holelist ~= 0 then
2829 holepart = holelist[#holelist]
2830 holelist[#holelist] = nil
2831 else
2832 holepart = hole:Clone()
2833 end
2834 holepart:BreakJoints()
2835 holepart.Parent = ignore
2836 holepart.CFrame = cf(pos, pos - norm) * angles(-90 * deg, random(0, 360) * deg, 0)
2837 local materials = materiallist[Enum.Material.Cobblestone]
2838 if materiallist[hit.Material] then
2839 materials = materiallist[hit.Material]
2840 end
2841 local randId = "http://www.roblox.com/asset/?id=" .. materials[random(1, #materials)]
2842 holepart.Decal1.Texture = randId
2843 holepart.Decal2.Texture = randId
2844 delay(10, function()
2845 holepart.Parent = nil
2846 holelist[#holelist + 1] = holepart
2847 end)
2848 end
2849 function effects:bullethit(hit, pos, norm, exit, exitnorm, vel, smokeon, holeon, sparkson)
2850 if hit.Transparency == 1 then
2851 return
2852 end
2853 local showeffects = camera.screencull.sphere(pos, 16)
2854 if sparkson and showeffects and hit.Material ~= Enum.Material.Sand and hit.Material ~= Enum.Material.Grass and hit.Material ~= Enum.Material.Wood then
2855 local initalsize = 0.1
2856 local initalbrightness = 20 * random()
2857 for i = 1, sparkson * 2 + 1 do
2858 particle.new({
2859 position = pos,
2860 nopenetration = true,
2861 velocity = (vel - 1.2 * norm:Dot(vel) / norm:Dot(norm) * norm) * 0.1 + vector.random(50),
2862 acceleration = v3(0, -196.2, 0),
2863 cancollide = true,
2864 size = initalsize,
2865 brightness = initalbrightness,
2866 color = Color3.new(1, 1, 0.8),
2867 bloom = 0.005 * random(),
2868 life = -0.25 * math.log(1 - random()),
2869 physicsonly = true,
2870 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
2871 if not self.stopmotion then
2872 local vel = self.velocity
2873 local newpos = pos + 0.1 * norm
2874 local elasticity = 0.3
2875 local friction = 0.4
2876 local nvel = norm:Dot(vel) * norm
2877 local tvel = vel - nvel
2878 local newvel = (1 - friction) * tvel - elasticity * nvel
2879 self.position = newpos
2880 self.velocity = newvel
2881 if newvel.magnitude < 2 then
2882 self.stopmotion = true
2883 end
2884 end
2885 end,
2886 onstep = function(self, dt)
2887 self.brightness = self.brightness - 0.7 * dt
2888 self.size = self.size - 0.2 * dt
2889 if self.brightness < 0 then
2890 self.brightness = 0
2891 end
2892 if self.size < 0 then
2893 self.size = 0
2894 end
2895 end
2896 })
2897 end
2898 if exit and exitnorm then
2899 for i = 1, sparkson * 2 + 1 do
2900 particle.new({
2901 position = exit,
2902 nopenetration = true,
2903 velocity = (vel - 1.2 * exitnorm:Dot(vel) / exitnorm:Dot(exitnorm) * exitnorm) * 0.1 + vector.random(50),
2904 acceleration = v3(0, -196.2, 0),
2905 cancollide = true,
2906 size = initalsize,
2907 brightness = initalbrightness,
2908 color = Color3.new(1, 1, 0.8),
2909 bloom = 0.005 * random(),
2910 life = -0.25 * math.log(1 - random()),
2911 physicsonly = true,
2912 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
2913 if not self.stopmotion then
2914 local vel = self.velocity
2915 local newpos = pos + 0.1 * norm
2916 local elasticity = 0.3
2917 local friction = 0.4
2918 local nvel = norm:Dot(vel) * norm
2919 local tvel = vel - nvel
2920 local newvel = (1 - friction) * tvel - elasticity * nvel
2921 self.position = newpos
2922 self.velocity = newvel
2923 if newvel.magnitude < 2 then
2924 self.stopmotion = true
2925 end
2926 end
2927 end,
2928 onstep = function(self, dt)
2929 self.brightness = self.brightness - 0.7 * dt
2930 self.size = self.size - 0.2 * dt
2931 if self.brightness < 0 then
2932 self.brightness = 0
2933 end
2934 if self.size < 0 then
2935 self.size = 0
2936 end
2937 end
2938 })
2939 end
2940 end
2941 end
2942 local light = hit:FindFirstChildOfClass("SpotLight") or hit:FindFirstChildOfClass("PointLight") or hit:FindFirstChildOfClass("SurfaceLight")
2943 if light then
2944 light:Destroy()
2945 for i = 1, 10 do
2946 particle.new({
2947 position = pos,
2948 nopenetration = true,
2949 velocity = norm * 30 + vector.random(10),
2950 acceleration = v3(0, -30, 0),
2951 cancollide = true,
2952 size = 0.1,
2953 brightness = 5 * random(),
2954 color = Color3.new(1, 1, 0.8),
2955 bloom = 0.005 * random(),
2956 life = -3 * math.log(1 - random()),
2957 physicsonly = true,
2958 ontouch = function(self, part, pos, norm, exit, exitnorm, power, human)
2959 if not self.stopmotion then
2960 local vel = self.velocity
2961 local newpos = pos + 0.1 * norm
2962 local elasticity = 0.3
2963 local friction = 0.4
2964 local nvel = norm:Dot(vel) * norm
2965 local tvel = vel - nvel
2966 local newvel = (1 - friction) * tvel - elasticity * nvel
2967 self.position = newpos
2968 self.velocity = newvel
2969 if newvel.magnitude < 2 then
2970 self.stopmotion = true
2971 end
2972 end
2973 end,
2974 onstep = function(self, dt)
2975 self.brightness = self.brightness - 0.17 * dt
2976 self.size = self.size - 0.035 * dt
2977 if self.brightness < 0 then
2978 self.brightness = 0
2979 end
2980 if self.size < 0 then
2981 self.size = 0
2982 end
2983 end
2984 })
2985 end
2986 hit.Material = Enum.Material.SmoothPlastic
2987 end
2988 if not effects.disablerobloxparticles and smokeon and showeffects then
2989 makeimpact(hit, pos, norm)
2990 if exit and exitnorm then
2991 makeimpact(hit, exit, exitnorm)
2992 end
2993 end
2994 if holeon and hit.Transparency == 0 and hit.CanCollide then
2995 makehole(hit, pos, norm)
2996 if exit and exitnorm then
2997 makehole(hit, exit, exitnorm)
2998 end
2999 end
3000 end
3001 function effects:reload()
3002 smokelist = {}
3003 holelist = {}
3004 flashlist = {}
3005 shelllist = {}
3006 end
3007 effects:reload()
3008end
3009print("Loading tween module")
3010do
3011 local type = type
3012 local halfpi = math.pi / 2
3013 local acos = math.acos
3014 local sin = math.sin
3015 local cf = CFrame.new
3016 local tos = cf().toObjectSpace
3017 local components = cf().components
3018 local tweendata = {}
3019 local equations = {
3020 linear = {
3021 p0 = 0,
3022 v0 = 1,
3023 p1 = 1,
3024 v1 = 1
3025 },
3026 smooth = {
3027 p0 = 0,
3028 v0 = 0,
3029 p1 = 1,
3030 v1 = 0
3031 },
3032 accelerate = {
3033 p0 = 0,
3034 v0 = 0,
3035 p1 = 1,
3036 v1 = 1
3037 },
3038 decelerate = {
3039 p0 = 0,
3040 v0 = 1,
3041 p1 = 1,
3042 v1 = 0
3043 },
3044 bump = {
3045 p0 = 0,
3046 v0 = 4,
3047 p1 = 0,
3048 v1 = -4
3049 },
3050 acceleratebump = {
3051 p0 = 0,
3052 v0 = 0,
3053 p1 = 0,
3054 v1 = -6.75
3055 },
3056 deceleratebump = {
3057 p0 = 0,
3058 v0 = 6.75,
3059 p1 = 0,
3060 v1 = 0
3061 }
3062 }
3063 local updater = {}
3064 tween.step = event.new(updater)
3065 function tween.tweencframe(object, index, time, equation, nextcframe)
3066 if tweendata[object] then
3067 tweendata[object]()
3068 end
3069 local t0 = tick()
3070 local p0, v0, p1, v1
3071 if type(equation) == "table" then
3072 p0 = equation[1]
3073 v0 = equation[2]
3074 p1 = equation[3]
3075 v1 = equation[4]
3076 else
3077 local eq = equations[equation]
3078 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3079 end
3080 local interpolator = cframe.interpolator(object[index], nextcframe)
3081 local stop
3082 stop = updater:connect(function()
3083 local u = (tick() - t0) / time
3084 if u > 1 then
3085 object[index] = interpolator(p1)
3086 stop()
3087 tweendata[object] = nil
3088 else
3089 local v = 1 - u
3090 local t = p0 * v * v * v + (3 * p0 + v0) * u * v * v + (3 * p1 - v1) * u * u * v + p1 * u * u * u
3091 object[index] = interpolator(t)
3092 end
3093 end)
3094 tweendata[object] = stop
3095 return stop
3096 end
3097 function tween.freebody(object, index, life, cframe0, velocity0, rotation0, acceleration)
3098 local position0 = cframe0.p
3099 local matrix0 = cframe0 - position0
3100 local tick0 = tick()
3101 local stop
3102 stop = updater:connect(function()
3103 local t = tick() - tick0
3104 if life and t > life then
3105 stop()
3106 trash.remove(object)
3107 end
3108 object[index] = cframe.fromaxisangle(t * rotation0) * matrix0 + position0 + t * velocity0 + t * t * acceleration
3109 end)
3110 return stop
3111 end
3112end
3113print("Loading input module")
3114do
3115 local lower = string.lower
3116 local nv = Vector3.new()
3117 local userinput = game:GetService("UserInputService")
3118 local abbreviation = {
3119 ButtonX = "x",
3120 ButtonY = "y",
3121 ButtonA = "a",
3122 ButtonB = "b",
3123 ButtonR1 = "r1",
3124 ButtonL1 = "l1",
3125 ButtonR2 = "r2",
3126 ButtonL2 = "l2",
3127 ButtonR3 = "r3",
3128 ButtonL3 = "l3",
3129 ButtonStart = "start",
3130 ButtonSelect = "select",
3131 DPadLeft = "left",
3132 DPadRight = "right",
3133 DPadUp = "up",
3134 DPadDown = "down"
3135 }
3136 input.keyboard = {}
3137 input.keyboard.down = {}
3138 input.keyboard.onkeydown = {}
3139 input.keyboard.onkeyup = {}
3140 input.mouse = {}
3141 input.mouse.Position = nv
3142 input.mouse.down = {}
3143 input.mouse.onbuttondown = {}
3144 input.mouse.onbuttonup = {}
3145 input.mouse.onmousemove = {}
3146 input.mouse.onscroll = {}
3147 input.controller = {}
3148 input.controller.down = {}
3149 input.controller.onbuttondown = {}
3150 input.controller.onbuttonup = {}
3151 input.controller.onintegralmove = {}
3152 input.consoleon = not userinput.KeyboardEnabled
3153 local fireonkeydown = event.new(input.keyboard.onkeydown)
3154 local fireonkeyup = event.new(input.keyboard.onkeyup)
3155 local fireonbuttondown = event.new(input.mouse.onbuttondown)
3156 local fireonbuttonup = event.new(input.mouse.onbuttonup)
3157 local fireonmousemove = event.new(input.mouse.onmousemove)
3158 local fireonscroll = event.new(input.mouse.onscroll)
3159 local fireoncbuttondown = event.new(input.controller.onbuttondown)
3160 local fireoncbuttonup = event.new(input.controller.onbuttonup)
3161 local fireonintegralmove = event.new(input.controller.onintegralmove)
3162 local clicks = 0
3163 local maxcps = 20
3164 local reset = 0
3165 local keymap = {}
3166 local triggerthreshold = 0.2
3167 local stickthreshold = 0.25
3168 local gamepadpos
3169 local triggeron = {}
3170 local typing
3171 function input.iskeydown(key)
3172 return userinput:GetKeysPressed()[key]
3173 end
3174 userinput.TextBoxFocused:connect(function()
3175 typing = true
3176 end)
3177 userinput.TextBoxFocusReleased:connect(function()
3178 typing = false
3179 end)
3180 userinput.InputChanged:connect(function(object)
3181 local type = object.UserInputType.Name
3182 local pos = object.Position
3183 if type == "MouseMovement" then
3184 input.mouse.position = pos
3185 fireonmousemove(object.Delta)
3186 elseif type == "MouseWheel" then
3187 fireonscroll(pos.z)
3188 elseif type == "Gamepad1" then
3189 local key = object.KeyCode.Name
3190 if key == "Thumbstick2" then
3191 local m = pos.magnitude
3192 if m > stickthreshold then
3193 gamepadpos = (1 - stickthreshold / m) / (1 - stickthreshold) * pos
3194 elseif gamepadpos then
3195 gamepadpos = nil
3196 end
3197 elseif key == "ButtonL2" or key == "ButtonR2" then
3198 local abv = abbreviation[key]
3199 if triggerthreshold < pos.z and not input.controller.down[abv] then
3200 local mappedkey = keymap[abv]
3201 if mappedkey then
3202 input.keyboard.down[mappedkey] = tick()
3203 fireonkeydown(mappedkey)
3204 end
3205 input.controller.down[abv] = tick()
3206 fireoncbuttondown(abv)
3207 elseif pos.z < triggerthreshold and input.controller.down[abv] then
3208 local mappedkey = keymap[abv]
3209 if mappedkey then
3210 input.keyboard.down[mappedkey] = nil
3211 fireonkeyup(mappedkey)
3212 end
3213 input.controller.down[abv] = nil
3214 fireoncbuttonup(abv)
3215 end
3216 end
3217 end
3218 end)
3219 userinput.InputBegan:connect(function(object)
3220 local t = tick()
3221 if typing or char.health and char.health <= 0 then
3222 return
3223 end
3224 local type = object.UserInputType.Name
3225 if type == "Keyboard" then
3226 local key = lower(object.KeyCode.Name)
3227 input.keyboard.down[key] = t
3228 fireonkeydown(key)
3229 elseif type == "Gamepad1" then
3230 local key = abbreviation[object.KeyCode.Name]
3231 if key and key ~= "l2" and key ~= "r2" or not input.controller.down[key] then
3232 local mappedkey = keymap[key]
3233 if mappedkey then
3234 input.keyboard.down[mappedkey] = t
3235 fireonkeydown(mappedkey)
3236 end
3237 input.controller.down[key] = t
3238 fireoncbuttondown(key)
3239 end
3240 elseif type == "MouseButton1" then
3241 if t > reset then
3242 clicks = 0
3243 reset = t + 1
3244 end
3245 clicks = clicks + 1
3246 if clicks <= maxcps then
3247 input.mouse.down.left = t
3248 fireonbuttondown("left")
3249 end
3250 elseif type == "MouseButton2" then
3251 input.mouse.down.right = t
3252 fireonbuttondown("right")
3253 elseif type == "MouseButton3" then
3254 input.mouse.down.middle = t
3255 fireonbuttondown("middle")
3256 end
3257 end)
3258 userinput.InputEnded:connect(function(object)
3259 if typing then
3260 return
3261 end
3262 local type = object.UserInputType.Name
3263 if type == "Keyboard" then
3264 local key = lower(object.KeyCode.Name)
3265 input.keyboard.down[key] = nil
3266 fireonkeyup(key)
3267 elseif type == "Gamepad1" then
3268 local key = abbreviation[object.KeyCode.Name]
3269 if key and key ~= "l2" and key ~= "r2" or input.controller.down[key] then
3270 local mappedkey = keymap[key]
3271 if mappedkey then
3272 input.keyboard.down[mappedkey] = nil
3273 fireonkeyup(mappedkey)
3274 end
3275 input.controller.down[key] = nil
3276 fireoncbuttonup(key)
3277 end
3278 elseif type == "MouseButton1" then
3279 input.mouse.down.left = nil
3280 fireonbuttonup("left")
3281 elseif type == "MouseButton2" then
3282 input.mouse.down.right = nil
3283 fireonbuttonup("right")
3284 elseif type == "MouseButton3" then
3285 input.mouse.down.middle = nil
3286 fireonbuttonup("middle")
3287 end
3288 end)
3289 function input.mouse:hide()
3290 userinput.MouseIconEnabled = false
3291 end
3292 function input.mouse:show()
3293 userinput.MouseIconEnabled = true
3294 end
3295 function input.mouse.visible()
3296 return userinput.MouseIconEnabled
3297 end
3298 function input.mouse:lockcenter()
3299 userinput.MouseBehavior = "LockCenter"
3300 end
3301 function input.mouse:free()
3302 userinput.MouseBehavior = "Default"
3303 end
3304 function input.mouse:lock()
3305 userinput.MouseBehavior = "LockCurrentPosition"
3306 end
3307 function input.controller:map(button, key)
3308 keymap[button] = key
3309 end
3310 function input.controller:unmap(button)
3311 keymap[button] = nil
3312 end
3313 function input.step(dt)
3314 if gamepadpos then
3315 fireonintegralmove(dt * gamepadpos, dt)
3316 end
3317 end
3318end
3319print("Loading animation module")
3320do
3321 local sin = math.sin
3322 local acos = math.acos
3323 local type = type
3324 local next = next
3325 local cf = CFrame.new
3326 local v3 = vector.new
3327 local nv = v3()
3328 local inverse = CFrame.new().inverse
3329 local tos = CFrame.new().toObjectSpace
3330 local toquaternion = cframe.toquaternion
3331 local clone = game.Clone
3332 local new = Instance.new
3333 local play = new("Sound").Play
3334 local stop = new("Sound").Stop
3335 local equations = {
3336 linear = {
3337 p0 = 0,
3338 v0 = 1,
3339 p1 = 1,
3340 v1 = 1
3341 },
3342 smooth = {
3343 p0 = 0,
3344 v0 = 0,
3345 p1 = 1,
3346 v1 = 0
3347 },
3348 accelerate = {
3349 p0 = 0,
3350 v0 = 0,
3351 p1 = 1,
3352 v1 = 1
3353 },
3354 decelerate = {
3355 p0 = 0,
3356 v0 = 1,
3357 p1 = 1,
3358 v1 = 0
3359 },
3360 bump = {
3361 p0 = 0,
3362 v0 = 4,
3363 p1 = 0,
3364 v1 = -4
3365 },
3366 acceleratebump = {
3367 p0 = 0,
3368 v0 = 0,
3369 p1 = 0,
3370 v1 = -6.75
3371 },
3372 deceleratebump = {
3373 p0 = 0,
3374 v0 = 6.75,
3375 p1 = 0,
3376 v1 = 0
3377 }
3378 }
3379 local function interpolator(c0, c1, t0, dur, eq, pivot)
3380 pivot = pivot or nv
3381 c0 = c0 * cf(pivot)
3382 c1 = c1 * cf(pivot)
3383 local p0, v0, p1, v1
3384 if type(eq) == "table" then
3385 p0, v0, p1, v1 = eq[1], eq[2], eq[3], eq[4]
3386 else
3387 local eq = equations[eq or "smooth"]
3388 p0, v0, p1, v1 = eq.p0, eq.v0, eq.p1, eq.v1
3389 end
3390 return function(t)
3391 t = (t - t0) / dur
3392 t = t < 1 and t or 1
3393 local i = 1 - t
3394 local v = p0 * i * i * i + (3 * p0 + v0) * t * i * i + (3 * p1 - v1) * t * t * i + p1 * t * t * t
3395 return cframe.interpolate(c0, c1, v) * cf(-pivot), 1 == t
3396 end
3397 end
3398 function animation.player(modeldata, sequence)
3399 local interpolators = {}
3400 local framenumber = 1
3401 local t0 = 0
3402 local lasttime = t0
3403 local stdtimescale = sequence.stdtimescale
3404 local timescale = sequence.timescale
3405 local cframes = {}
3406 local lastcframes = {}
3407 local ignore = workspace.Ignore
3408 local player = game:GetService("Players").LocalPlayer
3409 for i, v in next, modeldata, nil do
3410 if v.part then
3411 lastcframes[i] = v.part.CFrame
3412 cframes[i] = v.part.CFrame
3413 end
3414 end
3415 return function(time)
3416 local dt = time - lasttime
3417 lasttime = time
3418 for i = framenumber, #sequence do
3419 local frame = sequence[i]
3420 if time > t0 then
3421 for i = 1, #frame do
3422 local data = frame[i]
3423 local partname = data.part
3424 if not modeldata[partname] then
3425 error("Error in frame: " .. framenumber .. ". " .. partname .. " is not in modeldata")
3426 end
3427 if data.c0 then
3428 interpolators[partname] = nil
3429 modeldata[partname].weld.C0 = data.c0 == "base" and modeldata[partname].basec0 or data.c0
3430 end
3431 if data.c1 then
3432 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)
3433 end
3434 if data.clone then
3435 if modeldata[data.clone] then
3436 error("Error in frame: " .. framenumber .. ". Cannot clone " .. partname .. ". " .. data.clone .. " already exists.")
3437 end
3438 local part = clone(modeldata[partname].part)
3439 part.Parent = ignore
3440 part:ClearAllChildren()
3441 local tt = modeldata[partname].part:GetChildren()
3442 for i = 1, #tt do
3443 if tt[i]:IsA("Texture") then
3444 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3445 local hackytt = tt[i]:Clone()
3446 hackytt.Transparency = trans
3447 hackytt.Parent = part
3448 elseif tt[i]:IsA("FileMesh") or tt[i]:IsA("CylinderMesh") or tt[i]:IsA("BlockMesh") or tt[i]:IsA("SpecialMesh") then
3449 tt[i]:Clone().Parent = part
3450 end
3451 end
3452 local weld = new("Motor6D", part)
3453 local part0 = data.part0 and modeldata[data.part0].part or modeldata[partname].weld.Part0
3454 weld.Part0 = part0
3455 weld.Part1 = part
3456 weld.C0 = part0.CFrame:inverse() * modeldata[partname].weld.Part0.CFrame * modeldata[partname].weld.C0
3457 modeldata[data.clone] = {
3458 part = part,
3459 weld = weld,
3460 clone = true
3461 }
3462 cframes[data.clone] = cframes[partname]
3463 lastcframes[data.clone] = lastcframes[partname]
3464 end
3465 if data.transparency then
3466 modeldata[partname].part.Transparency = data.transparency
3467 if modeldata.camodata and modeldata.camodata[modeldata[partname].part] then
3468 local tt = modeldata[partname].part:GetChildren()
3469 for i = 1, #tt do
3470 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3471 local trans = modeldata.camodata[modeldata[partname].part][tt[i]].Transparency
3472 tt[i].Transparency = data.transparency ~= 1 and trans or 1
3473 end
3474 end
3475 end
3476 end
3477 if data.sound then
3478 do
3479 local sound = new("Sound")
3480 if data.soundid then
3481 sound.SoundId = data.soundid
3482 end
3483 if data.v then
3484 sound.Volume = data.v
3485 end
3486 if data.p then
3487 sound.Pitch = data.p
3488 end
3489 if data.tp then
3490 sound.TimePosition = data.tp
3491 else
3492 sound.TimePosition = 0
3493 end
3494 if data.head then
3495 sound.Parent = player.Character.Head
3496 else
3497 sound.Parent = modeldata[partname].part
3498 end
3499 sound:Play()
3500 if data.d then
3501 delay(data.d, function()
3502 sound:Stop()
3503 end)
3504 end
3505 end
3506 end
3507 if data.drop then
3508 if not modeldata[partname].clone then
3509 error("Error in frame: " .. framenumber .. ". Cannot drop " .. partname .. ". Part is not a clone")
3510 end
3511 local lastcf = lastcframes[partname]
3512 local curcf = cframes[partname]
3513 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))
3514 trash.remove(modeldata[partname].weld)
3515 modeldata[partname] = nil
3516 interpolators[partname] = nil
3517 end
3518 if data.delete then
3519 trash.remove(modeldata[partname].weld)
3520 trash.remove(modeldata[partname].part)
3521 modeldata[partname] = nil
3522 interpolators[partname] = nil
3523 end
3524 end
3525 t0 = t0 + frame.delay * timescale
3526 framenumber = framenumber + 1
3527 else
3528 break
3529 end
3530 end
3531 for i, v in next, interpolators, nil do
3532 local newcf, stop, t = v(time)
3533 modeldata[i].weld.C0 = newcf
3534 if stop then
3535 interpolators[i] = nil
3536 end
3537 end
3538 for i, v in next, modeldata, nil do
3539 if v.part then
3540 lastcframes[i] = cframes[i]
3541 cframes[i] = v.part.CFrame
3542 end
3543 end
3544 if time > t0 then
3545 for i, v in next, modeldata, nil do
3546 if v.clone then
3547 trash.remove(v.weld)
3548 trash.remove(v.part)
3549 modeldata[i] = nil
3550 end
3551 end
3552 end
3553 return time > t0
3554 end
3555 end
3556 function animation.reset(modeldata, t, keepvisible, resetboltlock)
3557 resetboltlock = resetboltlock or not modeldata.boltlock
3558 local interpolators = {}
3559 for i, v in next, modeldata, nil do
3560 if v.clone then
3561 modeldata[i] = nil
3562 trash.remove(v.weld)
3563 trash.remove(v.part)
3564 else
3565 if not keepvisible and v.part then
3566 v.part.Transparency = v.basetransparency
3567 if modeldata.camodata and modeldata.camodata[v.part] then
3568 local tt = v.part:GetChildren()
3569 for i = 1, #tt do
3570 if tt[i]:IsA("Texture") or tt[i]:IsA("Decal") then
3571 local trans = modeldata.camodata[v.part][tt[i]].Transparency
3572 tt[i].Transparency = trans
3573 end
3574 end
3575 end
3576 end
3577 if v.weld and (i ~= "Bolt" or i == "Bolt" and resetboltlock) then
3578 interpolators[i] = interpolator(v.weld.C0, v.basec0, 0, t or 1)
3579 end
3580 end
3581 end
3582 return function(time)
3583 for i, v in next, interpolators, nil do
3584 if i ~= "Bolt" or i == "Bolt" and resetboltlock then
3585 local newcf, stop = v(time)
3586 modeldata[i].weld.C0 = newcf
3587 end
3588 end
3589 return time > t
3590 end
3591 end
3592end
3593print("Loading chat module")
3594do
3595 local wfc = game.WaitForChild
3596 local ffc = game.FindFirstChild
3597 local ud2 = UDim2.new
3598 local ceil = math.ceil
3599 local cf = CFrame.new
3600 local v3 = Vector3.new
3601 local color = Color3.new
3602 local dot = Vector3.new().Dot
3603 local workspace = workspace
3604 local ray = Ray.new
3605 local new = Instance.new
3606 local rtype = game.IsA
3607 local debris = game.Debris
3608 local sub = string.sub
3609 local len = string.len
3610 local lower = string.lower
3611 local find = string.find
3612 local insert = table.insert
3613 local match = string.match
3614 local player = game:GetService("Players").LocalPlayer
3615 local pgui = player.PlayerGui
3616 local misc = game.ReplicatedStorage.Misc
3617 local msg = wfc(misc, "Msger")
3618 local chatgui = wfc(pgui, "ChatGame")
3619 local chatbox = wfc(chatgui, "TextBox")
3620 local warn = wfc(chatgui, "Warn")
3621 local version = wfc(chatgui, "Version")
3622 local globalchat = wfc(chatgui, "GlobalChat")
3623 local guesttip = wfc(chatgui, "GuestTip")
3624 version.Text = "Server version: " .. updateversion
3625 local admin, moderator
3626 local adminlist = {
3627 525919,
3628 1667819,
3629 5725475,
3630 4337002
3631 }
3632 local moderatorlist = {66366193, 70273584}
3633 local banlist = {}
3634 local canchat = true
3635 local chatspam = 0
3636 local totalspam = 0
3637 local maxchar = 400
3638 local lines = 8
3639 local chatting
3640 local isguest = player.UserId < 0 and not game:GetService("RunService"):IsStudio()
3641 for i = 1, #adminlist do
3642 if adminlist[i] == player.userId then
3643 admin = true
3644 end
3645 end
3646 for i = 1, #moderatorlist do
3647 if moderatorlist[i] == player.userId then
3648 moderator = true
3649 end
3650 end
3651 for i = 1, #banlist do
3652 if banlist[i] == player.Name then
3653 player:kick("Banlist kick")
3654 end
3655 end
3656 network:add("console", function(message)
3657 local mes = msg:Clone()
3658 local mtag = wfc(mes, "Tag")
3659 local offset = 5
3660 mes.Parent = globalchat
3661 mes.Text = "[Console]: "
3662 mes.TextColor3 = Color3.new(0.4, 0.4, 0.4)
3663 mes.Msg.Text = message
3664 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3665 end)
3666 network:add("announce", function(message)
3667 local mes = msg:Clone()
3668 local mtag = wfc(mes, "Tag")
3669 local offset = 5
3670 mes.Parent = globalchat
3671 mes.Text = "[ANNOUNCEMENT]: "
3672 mes.TextColor3 = Color3.new(0.9803921568627451, 0.6509803921568628, 0.10196078431372549)
3673 mes.Msg.Text = message
3674 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3675 end)
3676 network:add("chatted", function(chatter, text, tag, tagcolor, teamchat, chattername)
3677 if teamchat and chatter.TeamColor ~= player.TeamColor then
3678 return
3679 end
3680 local mes = msg:Clone()
3681 local mtag = wfc(mes, "Tag")
3682 mes.Parent = globalchat
3683 local offset = 5
3684 mtag.Text = tag and tag .. " " or ""
3685 if tag then
3686 if string.sub(tag, 0, 1) == "$" then
3687 local imgid = string.sub(tag, 2)
3688 mes.Position = ud2(0.01, 50, 1, 20)
3689 mtag.Staff.Visible = true
3690 mtag.Staff.Image = "rbxassetid://" .. imgid
3691 mtag.Text = " "
3692 else
3693 offset = mtag.TextBounds.x + 5
3694 mes.Position = ud2(0.01, offset, 1, 20)
3695 mtag.Position = ud2(0, -offset + 5, 0, 0)
3696 if tagcolor then
3697 mtag.TextColor3 = tagcolor
3698 end
3699 end
3700 end
3701 mes.Text = chattername .. " : "
3702 mes.TextColor = chatter.TeamColor
3703 mes.Msg.Text = text
3704 mes.Msg.Position = ud2(0, mes.TextBounds.x, 0, 0)
3705 end)
3706 local eval
3707 do
3708 local math = math
3709 local byte = string.byte
3710 local find = string.find
3711 local lparen = byte("(")
3712 local rparen = byte(")")
3713 local add = byte("+")
3714 local sub = byte("-")
3715 local mul = byte("*")
3716 local div = byte("/")
3717 local pow = byte("^")
3718 local mod = byte("%")
3719 local zero = byte("0")
3720 local nine = byte("9")
3721 local dot = byte(".")
3722 local space = byte(" ")
3723 local tab = byte("\t")
3724 local newl = byte("\n")
3725 local arith = {
3726 [add] = function(a, b)
3727 return a + b
3728 end,
3729 [sub] = function(a, b)
3730 return a - b
3731 end,
3732 [mul] = function(a, b)
3733 return a * b
3734 end,
3735 [div] = function(a, b)
3736 return a / b
3737 end,
3738 [pow] = function(a, b)
3739 return a ^ b
3740 end,
3741 [mod] = function(a, b)
3742 return a % b
3743 end
3744 }
3745 local whitespace = {
3746 [space] = true,
3747 [tab] = true,
3748 [newl] = true
3749 }
3750 local function f(eq, i)
3751 local neq = #eq
3752 local n = 0
3753 local op = add
3754 local func, m, x, _
3755 while i <= neq do
3756 local c = byte(eq, i)
3757 if arith[c] then
3758 op = c
3759 elseif c == rparen then
3760 break
3761 elseif whitespace[c] then
3762 else
3763 if c == lparen then
3764 m, i = f(eq, i + 1)
3765 elseif c >= zero and c <= nine or c == dot then
3766 _, i, m = find(eq, "(%d*%.?%d*)", i)
3767 else
3768 _, i, func = find(eq, "(%a*)%(", i)
3769 if i then
3770 x, i = f(eq, i + 1)
3771 m = math[func](x)
3772 else
3773 return
3774 end
3775 end
3776 n = arith[op](n, m)
3777 end
3778 i = i + 1
3779 end
3780 return n, i
3781 end
3782 function eval(eq)
3783 return (f(eq, 1))
3784 end
3785 end
3786 local function findplayer(name, speaker)
3787 if lower(name) == "all" then
3788 local chars = {}
3789 local c = game:GetService("Players"):GetPlayers()
3790 for i = 1, #c do
3791 insert(chars, c[i])
3792 end
3793 return chars
3794 elseif lower(name) == "me" then
3795 return {speaker}
3796 elseif lower(name) == "others" then
3797 local chars = {}
3798 local c = game:GetService("Players"):GetPlayers()
3799 for i = 1, #c do
3800 if c ~= speaker then
3801 insert(chars, c[i])
3802 end
3803 end
3804 return chars
3805 else
3806 local chars = {}
3807 local commalist = {}
3808 local ssn = 0
3809 local lownum = 1
3810 local highestnum = 1
3811 local foundone
3812 while true do
3813 ssn = ssn + 1
3814 if sub(name, ssn, ssn) == "" then
3815 insert(commalist, lownum)
3816 insert(commalist, ssn - 1)
3817 highestnum = ssn - 1
3818 break
3819 end
3820 if string.sub(name, ssn, ssn) == "," then
3821 foundone = true
3822 table.insert(commalist, lownum)
3823 table.insert(commalist, ssn)
3824 lownum = ssn + 1
3825 end
3826 end
3827 if foundone then
3828 for ack = 1, #commalist, 2 do
3829 local cnum = 0
3830 local char
3831 local c = game:GetService("Players"):GetPlayers()
3832 for i = 1, #c do
3833 if find(lower(c[i].Name), sub(lower(name), commalist[ack], commalist[ack + 1] - 1)) == 1 then
3834 char = c[i]
3835 cnum = cnum + 1
3836 end
3837 end
3838 if cnum == 1 then
3839 table.insert(chars, char)
3840 end
3841 end
3842 return #chars ~= 0 and chars or 0
3843 else
3844 local cnum = 0
3845 local char
3846 local c = game:GetService("Players"):GetPlayers()
3847 for i = 1, #c do
3848 if find(lower(c[i].Name), lower(name)) == 1 then
3849 char = {
3850 c[i]
3851 }
3852 cnum = cnum + 1
3853 end
3854 end
3855 return cnum == 1 and char or 0
3856 end
3857 end
3858 end
3859 network:add("printstring", function(...)
3860 local ss = {
3861 ...
3862 }
3863 local s = ""
3864 for i = 1, #s do
3865 s = s .. "\t" .. ss[i]
3866 end
3867 s = s .. "\n"
3868 local i = 0
3869 local lel = ""
3870 for str in string.gmatch(s, [[
3871(^[
3872]*)
3873]]) do
3874 i = i + 1
3875 lel = lel .. "\n" .. str
3876 if i == 64 then
3877 print(lel)
3878 i = 0
3879 lel = ""
3880 end
3881 end
3882 end)
3883 local function newchat()
3884 local message = chatbox.Text
3885 chatbox.Text = "Press '/' or click here to chat"
3886 chatting = false
3887 chatbox.ClearTextOnFocus = true
3888 chatbox.Active = false
3889 if sub(message, 1, 1) == "/" then
3890 network:send("m" .. "o" .. "d" .. "c" .. "m" .. "d", message)
3891 chatbox.Text = "Press '/' or click here to chat"
3892 chatting = false
3893 chatbox.ClearTextOnFocus = true
3894 return
3895 end
3896 message = string.gsub(message, [[
3897
3898+]], "")
3899 message = string.gsub(message, " +", " ")
3900 local teamchat, teamswitch, admincommand
3901 if sub(message, 1, 1) == "%" then
3902 teamchat = true
3903 message = sub(message, 2, len(message))
3904 end
3905 message = string.gsub(message, "{(.-)}", eval)
3906 if chatspam > 5 and not moderator and not admin then
3907 warn.Visible = true
3908 chatspam = chatspam + 1
3909 totalspam = totalspam + 1
3910 warn.Text = "You have been blocked temporarily for spamming. WARNING : " .. totalspam .. " out of 3"
3911 if totalspam > 3 then
3912 netkick("player was kicked for repeated spamming")
3913 end
3914 delay(5, function()
3915 chatspam = chatspam - 5
3916 warn.Visible = false
3917 end)
3918 return
3919 end
3920 local teamtype
3921 if network:fetch("s" .. "e" .. "r" .. "v" .. "e" .. "r" .. "t" .. "y" .. "p" .. "e") == "VIP" then
3922 if sub(lower(message), 1, 5) == "join/" or sub(lower(message), 1, 5) == "swap/" or sub(lower(message), 1, 5) == "team/" then
3923 teamtype = 6
3924 elseif sub(lower(message), 1, 6) == ":join " or sub(lower(message), 1, 6) == ":team " then
3925 teamtype = 7
3926 elseif sub(lower(message), 1, 7) == "switch/" then
3927 teamtype = 8
3928 end
3929 if teamtype then
3930 local theteam
3931 local tnum = 0
3932 local t = game.Teams:GetChildren()
3933 for i = 1, #t do
3934 local v = t[i]
3935 if find(lower(v.Name), sub(lower(message), teamtype)) == 1 then
3936 theteam = v
3937 tnum = tnum + 1
3938 end
3939 end
3940 if tnum == 1 and player.TeamColor ~= theteam.TeamColor then
3941 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "e" .. "a" .. "m", theteam)
3942 game.ReplicatedStorage.Events.Respawn:FireServer()
3943 end
3944 elseif message == "switch" or message == "switchteam" then
3945 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"))
3946 end
3947 end
3948 if admin or moderator then
3949 if sub(message, 1, 5) == "kick/" then
3950 admincommand = true
3951 local guys = findplayer(match(message, "/(.*)"), player)
3952 if guys ~= 0 then
3953 for i = 1, #guys do
3954 network:send("k" .. "i" .. "c" .. "k", guys[i])
3955 end
3956 end
3957 elseif sub(message, 1, 8) == "credits/" then
3958 admincommand = true
3959 local guys = findplayer(match(message, "/(.-),"), player)
3960 if guys ~= 0 then
3961 for i = 1, #guys do
3962 network:send("x" .. "y" .. "z", guys[i], eval(match(message, ",(.*)") or 0) or 0)
3963 end
3964 end
3965 elseif sub(message, 1, 11) == "experience/" then
3966 admincommand = true
3967 local guys = findplayer(match(message, "/(.-),"), player)
3968 if guys ~= 0 then
3969 for i = 1, #guys do
3970 network:send("z" .. "y" .. "x", guys[i], eval(match(message, ",(.*)") or 0))
3971 end
3972 end
3973 elseif sub(message, 1, 10) == "timescale/" then
3974 admincommand = true
3975 network:send("c" .. "h" .. "a" .. "n" .. "g" .. "e" .. "t" .. "i" .. "m" .. "e" .. "s" .. "c" .. "a" .. "l" .. "e", eval(match(message, "/(.*)") or 0))
3976 end
3977 end
3978 if len(message) > 256 then
3979 message = sub(message, 1, 256)
3980 end
3981 local header = teamchat and "(TEAM CHAT)" or admincommand and "[ADMIN COMMAND]" or teamswitch and "[TEAMSWITCH]" or ""
3982 message = header .. " " .. message
3983 chatspam = chatspam + 1
3984 network:send("c" .. "h" .. "a" .. "t" .. "t" .. "e" .. "d", message, teamchat, admincommand)
3985 spawn(function()
3986 wait(10)
3987 chatspam = chatspam - 1
3988 end)
3989 end
3990 function chat:disable(isGuest)
3991 canchat = false
3992 guesttip.Visible = isGuest
3993 chatbox.Visible = false
3994 end
3995 function chat:hidechat(on)
3996 if not isguest then
3997 canchat = not on
3998 globalchat.Visible = not on
3999 chatbox.Visible = not on
4000 end
4001 end
4002 function chat:inmenu()
4003 globalchat.Position = ud2(0, 20, 1, -100)
4004 chatbox.Position = ud2(0, 10, 1, -20)
4005 end
4006 function chat:ingame()
4007 globalchat.Position = ud2(0, 150, 1, -50)
4008 chatbox.Position = ud2(0, 10, 1, -20)
4009 end
4010 globalchat.ChildAdded:connect(function(child)
4011 wait()
4012 local m = globalchat:GetChildren()
4013 for i = 1, #m do
4014 local v = m[i]
4015 local tag = wfc(v, "Tag")
4016 local tagoff = 5
4017 if tag.Text ~= "" then
4018 tagoff = 5 + tag.TextBounds.x
4019 v.Position = ud2(0.01, tagoff, 1, v.Position.Y.Offset)
4020 end
4021 if v.Parent then
4022 v:TweenPosition(ud2(0.01, tagoff, 1, (i - #m) * 20), "Out", "Sine", 0.2, true)
4023 end
4024 if #m > lines and i <= #m - lines and v.Name ~= "Deleted" then
4025 v.Name = "Deleted"
4026 wfc(v, "Msg")
4027 wfc(v, "Tag")
4028 for x = 1, 5 do
4029 if ffc(v, "Msg") and ffc(v, "Tag") then
4030 v.TextTransparency = x * 2 / 10
4031 v.TextStrokeTransparency = x * 2 / 10 + 0.1
4032 v.Msg.TextTransparency = x * 2 / 10
4033 v.Msg.TextStrokeTransparency = x * 2 / 10 + 0.1
4034 v.Tag.TextTransparency = x * 2 / 10
4035 v.Tag.TextStrokeTransparency = x * 2 / 10 + 0.1
4036 wait(0.03333333333333333)
4037 end
4038 if v and v.Parent then
4039 trash.remove(v)
4040 end
4041 end
4042 end
4043 end
4044 end)
4045 chatbox.Focused:connect(function()
4046 chatbox.Active = true
4047 end)
4048 chatbox.FocusLost:connect(function(enter)
4049 chatbox.Active = false
4050 if enter and chatbox.Text ~= "" then
4051 newchat()
4052 end
4053 end)
4054 game:GetService("UserInputService").InputBegan:connect(function(keycode)
4055 if not canchat then
4056 chatbox.Visible = false
4057 return
4058 end
4059 if warn.Visible then
4060 return
4061 end
4062 local key = keycode.KeyCode
4063 if not chatbox.Active then
4064 if key == Enum.KeyCode.Slash then
4065 wait(0.03333333333333333)
4066 chatbox:CaptureFocus()
4067 chatbox.ClearTextOnFocus = false
4068 elseif key == Enum.KeyCode[hud.voteyes] then
4069 hud:vote("yes")
4070 elseif key == Enum.KeyCode[hud.votedismiss] then
4071 hud:vote("dismiss")
4072 elseif key == Enum.KeyCode[hud.voteno] then
4073 hud:vote("no")
4074 end
4075 end
4076 end)
4077 if player.UserId < 0 or input.consoleon then
4078 chat:disable(player.userId < 0)
4079 end
4080end
4081print("Loading hud module")
4082do
4083 local wfc = game.WaitForChild
4084 local ffc = game.FindFirstChild
4085 local ud2 = UDim2.new
4086 local ceil = math.ceil
4087 local cf = CFrame.new
4088 local v3 = Vector3.new
4089 local color = Color3.new
4090 local dot = Vector3.new().Dot
4091 local cos = math.cos
4092 local workspace = workspace
4093 local ray = Ray.new
4094 local new = Instance.new
4095 local raycast = workspace.FindPartOnRayWithIgnoreList
4096 local infolder = function(l, e)
4097 for i = 1, #l do
4098 if l[i].Name == e then
4099 return l[i]
4100 end
4101 end
4102 end
4103 local rtype = game.IsA
4104 local debris = game.Debris
4105 local player = game:GetService("Players").LocalPlayer
4106 local playertag = game.ReplicatedStorage.Character.PlayerTag
4107 local pgui = player.PlayerGui
4108 local repstore = game.ReplicatedStorage
4109 local modulestore = repstore.GunModules
4110 local misc = repstore.Misc
4111 local xboxmisc = repstore.XBOX
4112 local bloodarc = misc.BloodArc
4113 local spotdot = misc.Spot
4114 local rfeed = input.consoleon and xboxmisc.Feed or misc.Feed
4115 local hsht = misc.Headshot
4116 local maingui = wfc(pgui, "MainGui")
4117 if input.consoleon then
4118 maingui:Destroy()
4119 maingui = repstore.XBOX.MainGui:Clone()
4120 maingui.Parent = pgui
4121 end
4122 local spot = wfc(pgui, "Spot")
4123 local gamegui = wfc(maingui, "GameGui")
4124 local crossframe = wfc(gamegui, "CrossHud")
4125 local crossparts = {
4126 wfc(crossframe, "HR"),
4127 wfc(crossframe, "HL"),
4128 wfc(crossframe, "VD"),
4129 wfc(crossframe, "VU")
4130 }
4131 local ammohud = wfc(gamegui, "AmmoHud")
4132 local scopefr = wfc(maingui, "ScopeFrame")
4133 local hitmarker = wfc(gamegui, "Hitmarker")
4134 local tagfr = wfc(gamegui, "NameTag")
4135 local capfr = wfc(gamegui, "Capping")
4136 local bloodscreen = wfc(gamegui, "BloodScreen")
4137 local radar = wfc(gamegui, "Radar")
4138 local killfeed = wfc(gamegui, "Killfeed")
4139 local steady = wfc(gamegui, "Steady")
4140 local use = wfc(gamegui, "Use")
4141 local round = wfc(gamegui, "Round")
4142 local spotted = wfc(gamegui, "Spotted")
4143 local chatfr = wfc(pgui.ChatGame, "GlobalChat")
4144 local steadyfull = wfc(steady, "Full")
4145 local steadybar = wfc(steadyfull, "Bar")
4146 local rme = wfc(radar, "Me")
4147 local rfolder = wfc(radar, "Folder")
4148 local distance = 300
4149 local offset = -rme.Size.X.Offset / 2
4150 local ammofr = wfc(ammohud, "Frame")
4151 local ammotext = wfc(ammofr, "Ammo")
4152 local gammo = wfc(ammofr, "GAmmo")
4153 local magtext = wfc(ammofr, "Mag")
4154 local healthtext = wfc(ammofr, "Health")
4155 local fmodetext = wfc(ammofr, "FMode")
4156 local healthbar = wfc(ammofr, "healthbar_back")
4157 local healthbarFill = wfc(healthbar, "healthbar_fill")
4158 local newGUIColors = {
4159 Color3.new(0.14901960784313725, 0.3137254901960784, 0.2784313725490196),
4160 Color3.new(0.17647058823529413, 0.5019607843137255, 0.43137254901960786),
4161 Color3.new(0.8745098039215686, 0.12156862745098039, 0.12156862745098039),
4162 Color3.new(0.5333333333333333, 0.06666666666666667, 0.06666666666666667)
4163 }
4164 local cbar = wfc(capfr, "Percent")
4165 local sightmark, scopemark, centermark
4166 local nametags = {}
4167 local dotlist = {}
4168 local healthlist = {}
4169 local lastcombat = {}
4170 local prevhealth = 0
4171 local rtime = 0
4172 local stime = 0
4173 local renderinterval = 0.016666666666666666
4174 local spotinterval = 0.1
4175 local cinamode = false
4176 local cinalist = {
4177 ammohud,
4178 radar,
4179 killfeed,
4180 crossframe,
4181 round
4182 }
4183 hud.crossscale = physics.spring.new(0)
4184 hud.crossscale.s = 10
4185 hud.crossscale.d = 0.8
4186 hud.crossscale.t = 1
4187 hud.crossspring = physics.spring.new(0)
4188 hud.crossspring.s = 12
4189 hud.crossspring.d = 0.65
4190 hud.hitspring = physics.spring.new(1)
4191 hud.hitspring.s = 5
4192 hud.hitspring.d = 0.7
4193 do
4194 local kickfr = wfc(pgui.ChatGame, "Votekick")
4195 local title = wfc(kickfr, "Title")
4196 local timer = wfc(kickfr, "Timer")
4197 local votes = wfc(kickfr, "Votes")
4198 local yes = wfc(kickfr, "Yes")
4199 local no = wfc(kickfr, "No")
4200 local dismiss = wfc(kickfr, "Dismiss")
4201 local choice = wfc(kickfr, "Choice")
4202 local votereq = 0
4203 local votecount = 0
4204 local votetick = 0
4205 local voting, voted
4206 hud.voteyes = "Y"
4207 hud.voteno = "N"
4208 hud.votedismiss = "J"
4209 yes.Text = "Yes [" .. string.upper(hud.voteyes) .. "]"
4210 no.Text = "No [" .. string.upper(hud.voteno) .. "]"
4211 dismiss.Text = "Dismiss [" .. string.upper(hud.votedismiss) .. "]"
4212 function hud.votestep()
4213 if voting then
4214 kickfr.Visible = true
4215 timer.Text = "Time left: 0:" .. string.format("%.2d", (votetick - tick()) % 60)
4216 votes.Text = "Votes: " .. votecount .. " out of " .. votereq .. " required"
4217 if votetick <= tick() or votecount >= votereq then
4218 voting = false
4219 kickfr.Visible = false
4220 end
4221 else
4222 kickfr.Visible = false
4223 end
4224 end
4225 function hud:vote(votecard)
4226 if voting and not voted then
4227 yes.Visible = false
4228 no.Visible = false
4229 dismiss.Visible = false
4230 choice.Visible = true
4231 voted = true
4232 if votecard == "yes" then
4233 choice.Text = "Voted Yes"
4234 choice.TextColor3 = yes.TextColor3
4235 elseif votecard == "dismiss" then
4236 choice.Text = "Vote Dismissed"
4237 choice.TextColor3 = dismiss.TextColor3
4238 voting = false
4239 kickfr.Visible = false
4240 else
4241 choice.Text = "Voted No"
4242 choice.TextColor3 = no.TextColor3
4243 end
4244 network:send("votefromUI", votecard)
4245 end
4246 end
4247 network:add("startvotekick", function(name, countdown, endtick, reqs)
4248 if not hud.disablevotekick then
4249 title.Text = "Votekick " .. name .. " out of the server?"
4250 kickfr.Visible = true
4251 yes.Visible = true
4252 no.Visible = true
4253 dismiss.Visible = true
4254 choice.Visible = false
4255 votereq = reqs
4256 votecount = 0
4257 votetick = endtick
4258 voting = true
4259 voted = false
4260 hud.votestep()
4261 end
4262 end)
4263 network:add("updatenumvotes", function(numvotes)
4264 votecount = numvotes
4265 end)
4266 end
4267 network:add("updateothershealth", function(player, health0, healtick0, healrate, maxhealth, alive)
4268 if not healthlist[player] then
4269 healthlist[player] = {}
4270 end
4271 healthlist[player].health0 = health0
4272 healthlist[player].healtick0 = healtick0
4273 healthlist[player].healrate = healrate
4274 healthlist[player].maxhealth = maxhealth
4275 healthlist[player].alive = alive
4276 if menu.updatelist then
4277 menu.updatelist(player, "Toggle")
4278 end
4279 end)
4280 network:add("killfeed", function(killer, victim, dist, weapon, head)
4281 local spacing = input.consoleon and 20 or 15
4282 local newfeed = rfeed:Clone()
4283 newfeed.Text = killer.Name
4284 newfeed.TextColor = killer.TeamColor
4285 newfeed.GunImg.Text = weapon
4286 newfeed.Victim.Text = victim.Name
4287 newfeed.Victim.TextColor = victim.TeamColor
4288 newfeed.GunImg.Dist.Text = "Dist: " .. dist .. " studs"
4289 newfeed.Parent = killfeed
4290 newfeed.GunImg.Size = UDim2.new(0, newfeed.GunImg.TextBounds.x, 0, 30)
4291 newfeed.GunImg.Position = UDim2.new(0, spacing + newfeed.TextBounds.x, 0, -5)
4292 newfeed.Victim.Position = UDim2.new(0, spacing * 2 + newfeed.TextBounds.x + newfeed.GunImg.TextBounds.x, 0, 0)
4293 if head then
4294 local headnote = hsht:Clone()
4295 headnote.Parent = newfeed.Victim
4296 headnote.Position = ud2(0, 10 + newfeed.Victim.TextBounds.x, 0, -5)
4297 end
4298 spawn(function()
4299 newfeed.Visible = true
4300 wait(20)
4301 for i = 1, 10 do
4302 if newfeed.Parent then
4303 newfeed.TextTransparency = i / 10
4304 newfeed.TextStrokeTransparency = i / 10 + 0.5
4305 newfeed.GunImg.TextStrokeTransparency = i / 10 + 0.5
4306 newfeed.GunImg.TextTransparency = i / 10
4307 newfeed.Victim.TextStrokeTransparency = i / 10 + 0.5
4308 newfeed.Victim.TextTransparency = i / 10
4309 wait(0.03333333333333333)
4310 end
4311 end
4312 if newfeed and newfeed.Parent then
4313 trash.remove(newfeed)
4314 end
4315 end)
4316 local kb = killfeed:GetChildren()
4317 for i = 1, #kb do
4318 local v = kb[i]
4319 v:TweenPosition(ud2(0.01, 5, 1, (i - #kb) * 25 - 25), "Out", "Sine", 0.2, true)
4320 if #kb > 5 and #kb - i >= 5 then
4321 spawn(function()
4322 if kb[1].Name ~= "Deleted" then
4323 for i = 1, 10 do
4324 if ffc(kb[1], "Victim") then
4325 kb[1].TextTransparency = i / 10
4326 kb[1].TextStrokeTransparency = i / 10 + 0.5
4327 kb[1].Victim.TextTransparency = i / 10
4328 kb[1].Victim.TextStrokeTransparency = i / 10 + 0.5
4329 kb[1].Name = "Deleted"
4330 kb[1].GunImg.TextTransparency = i / 10
4331 kb[1].GunImg.TextStrokeTransparency = i / 10 + 0.5
4332 wait(0.03333333333333333)
4333 end
4334 end
4335 trash.remove(kb[1])
4336 end
4337 end)
4338 end
4339 end
4340 end)
4341 do
4342 local deg = math.pi / 180
4343 local angles = CFrame.Angles
4344 local gamemode = repstore.ServerSettings.GameMode
4345 local caplightref = repstore.GamemodeProps.FlagDrop.Base.PointLight
4346 local flagcarryref = repstore.GamemodeProps.FlagCarry
4347 local flagdropref = repstore.GamemodeProps.FlagDrop
4348 local tphan = BrickColor.new("Bright blue")
4349 local tghost = BrickColor.new("Bright orange")
4350 local teams = {tphan, tghost}
4351 local captured = wfc(gamegui, "Captured")
4352 local revealed = wfc(gamegui, "Revealed")
4353 local ctf = {
4354 caplight = nil,
4355 [tphan.Name] = {
4356 revealtime = 0,
4357 droptime = 0,
4358 carrier = nil,
4359 carrymodel = nil,
4360 dropped = false,
4361 basecf = cf()
4362 },
4363 [tghost.Name] = {
4364 revealtime = 0,
4365 droptime = 0,
4366 carrier = nil,
4367 carrymodel = nil,
4368 dropped = false,
4369 basecf = cf()
4370 }
4371 }
4372 local function resetflag(flagcolor, droppedplayer)
4373 local tdata = ctf[flagcolor.Name]
4374 tdata.revealtime = 0
4375 tdata.carrier = nil
4376 if droppedplayer == player and ctf.caplight and ctf.caplight.Parent then
4377 ctf.caplight:Destroy()
4378 ctf.caplight = nil
4379 elseif tdata.carrymodel and tdata.carrymodel.Parent then
4380 tdata.carrymodel:Destroy()
4381 tdata.carrymodel = nil
4382 end
4383 end
4384 local function dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4385 local flagd
4386 if ctf[flagcolor.Name].dropmodel and ctf[flagcolor.Name].dropmodel.Parent then
4387 flagd = ctf[flagcolor.Name].dropmodel
4388 else
4389 flagd = flagdropref:Clone()
4390 end
4391 local base = ffc(flagd, "Base")
4392 if not base then
4393 print("no base", flagd)
4394 return
4395 end
4396 local tag = ffc(flagd, "Tag")
4397 local bgui = ffc(base, "BillboardGui")
4398 local light = ffc(base, "PointLight")
4399 tag.BrickColor = flagcolor
4400 flagd.TeamColor.Value = flagcolor
4401 bgui.Display.BackgroundColor = flagcolor
4402 light.Color = flagcolor.Color
4403 if flagcolor == player.TeamColor then
4404 bgui.Status.Text = secured and "Protect" or "Dropped"
4405 else
4406 bgui.Status.Text = secured and "Capture" or "Pick Up"
4407 end
4408 flagd:SetPrimaryPartCFrame(dropcf)
4409 flagd.Location.Value = dropcf
4410 flagd.Parent = workspace.Ignore.GunDrop
4411 ctf[flagcolor.Name].dropmodel = flagd
4412 ctf[flagcolor.Name].droptime = droptime
4413 ctf[flagcolor.Name].dropped = not secured
4414 if secured then
4415 ctf[flagcolor.Name].basecf = dropcf
4416 end
4417 end
4418 local function attachflag(stealer)
4419 if not (stealer and stealer.Parent) or not replication.getbodyparts then
4420 return
4421 end
4422 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4423 local bodyparts = replication.getbodyparts(stealer)
4424 if bodyparts and bodyparts.torso then
4425 local carrymodel = flagcarryref:Clone()
4426 carrymodel.Tag.BrickColor = oppositeteam
4427 carrymodel.Tag.BillboardGui.Display.BackgroundColor3 = oppositeteam.Color
4428 carrymodel.Tag.BillboardGui.AlwaysOnTop = false
4429 carrymodel.Base.PointLight.Color = oppositeteam.Color
4430 for i, v in next, carrymodel:GetChildren() do
4431 if v ~= carrymodel.Base then
4432 local weld = new("Weld", carrymodel.Base)
4433 weld.Part0 = carrymodel.Base
4434 weld.Part1 = v
4435 weld.C0 = carrymodel.Base.CFrame:inverse() * v.CFrame
4436 end
4437 if v:IsA("BasePart") then
4438 v.Anchored = false
4439 v.CanCollide = false
4440 end
4441 end
4442 local playerweld = new("Weld", carrymodel.Base)
4443 playerweld.Part0 = bodyparts.torso
4444 playerweld.Part1 = carrymodel.Base
4445 carrymodel.Parent = workspace.Ignore
4446 ctf[oppositeteam.Name].carrymodel = carrymodel
4447 end
4448 end
4449 function hud:nearenemyflag(stealer)
4450 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4451 if ctf[oppositeteam.Name] and ctf[oppositeteam.Name].basecf then
4452 local playerpos = hud:getplayerpos(stealer)
4453 if playerpos then
4454 local dist = (ctf[oppositeteam.Name].basecf.p - playerpos).Magnitude
4455 if dist < 100 then
4456 return true
4457 end
4458 end
4459 end
4460 return false
4461 end
4462 local rotspeed = 4
4463 local bouncespeed = 5
4464 function hud.gamemodestep()
4465 captured.Visible = false
4466 revealed.Visible = false
4467 if gamemode.Value == "Capture the Flag" then
4468 local oppositeteam = player.TeamColor == tphan and tghost or tphan
4469 if ctf[oppositeteam.Name].carrier == player and ctf[oppositeteam.Name].revealtime then
4470 captured.Visible = true
4471 captured.Text = "Capturing Enemy Flag!"
4472 revealed.Visible = true
4473 local revealtime = ctf[oppositeteam.Name].revealtime
4474 if revealtime > tick() then
4475 revealed.Text = "Position revealed in " .. math.ceil(revealtime - tick()) .. " seconds"
4476 else
4477 revealed.Text = "Flag position revealed to all enemies!"
4478 end
4479 end
4480 for i, v in next, teams, nil do
4481 local tdata = ctf[v.Name]
4482 if tdata.carrier ~= player then
4483 if tdata.carrier and not tdata.carrier.Parent then
4484 resetflag(v, nil)
4485 end
4486 if tdata.carrier and not tdata.carrymodel then
4487 attachflag(tdata.carrier)
4488 end
4489 if tdata.carrymodel and tdata.carrymodel.Parent and tdata.revealtime then
4490 local bg = tdata.carrymodel.Tag.BillboardGui
4491 local caption = player.TeamColor == tdata.carrier.TeamColor and "Capturing!" or "Stolen!"
4492 bg.AlwaysOnTop = player.TeamColor == tdata.carrier.TeamColor or tdata.revealtime < tick()
4493 bg.Distance.Text = caption
4494 end
4495 end
4496 end
4497 end
4498 end
4499 local t = 0
4500 local flagrespawntime = 60
4501 function hud.gamemoderenderstep()
4502 t = t + 1
4503 if gamemode.Value == "Capture the Flag" then
4504 for i, v in next, workspace.Ignore.GunDrop:GetChildren() do
4505 if v.Name == "FlagDrop" then
4506 local basecf = v.Location.Value
4507 v:SetPrimaryPartCFrame(basecf * cf(0, 0.2 * math.sin(t * bouncespeed * deg), 0) * angles(0, t * rotspeed * deg, 0))
4508 if ctf[v.TeamColor.Value.Name].dropped then
4509 local bgui = ffc(v.Base, "BillboardGui")
4510 local droptime = ctf[v.TeamColor.Value.Name].droptime
4511 if bgui and droptime and droptime + flagrespawntime > tick() then
4512 local count = math.floor(droptime + flagrespawntime - tick())
4513 bgui.Status.Text = (player.TeamColor ~= v.TeamColor.Value and "Pick up in: " or "Returning in:") .. count
4514 end
4515 end
4516 end
4517 end
4518 end
4519 end
4520 hud.attachflag = attachflag
4521 network:add("stealflag", function(stealer, timestamp)
4522 local oppositeteam = stealer.TeamColor == tphan and tghost or tphan
4523 ctf[oppositeteam.Name].revealtime = timestamp
4524 ctf[oppositeteam.Name].carrier = stealer
4525 if ctf[oppositeteam.Name].dropmodel then
4526 ctf[oppositeteam.Name].dropmodel:Destroy()
4527 ctf[oppositeteam.Name].dropmodel = nil
4528 end
4529 if stealer == player and char.rootpart then
4530 ctf.caplight = caplightref:Clone()
4531 ctf.caplight.Color = oppositeteam.Color
4532 ctf.caplight.Parent = char.rootpart
4533 else
4534 attachflag(stealer)
4535 end
4536 end)
4537 network:add("updateflagrecover", function(flagcolor, capping, progress)
4538 local tdata = ctf[flagcolor.Name]
4539 if tdata.dropmodel then
4540 local iscapping = ffc(tdata.dropmodel, "IsCapping")
4541 local cappoint = ffc(tdata.dropmodel, "CapPoint")
4542 if iscapping and cappoint then
4543 iscapping.Value = capping
4544 cappoint.Value = progress
4545 end
4546 end
4547 end)
4548 network:add("dropflag", function(flagcolor, droppedplayer, dropcf, droptime, secured)
4549 dropflag(flagcolor, droppedplayer, dropcf, droptime, secured)
4550 resetflag(flagcolor, droppedplayer)
4551 end)
4552 local function clearmap()
4553 print("Clearing map")
4554 for i, v in next, teams, nil do
4555 resetflag(v)
4556 end
4557 workspace.Ignore.GunDrop:ClearAllChildren()
4558 workspace.DeadBody:ClearAllChildren()
4559 workspace.Ignore.Bullets:ClearAllChildren()
4560 end
4561 network:add("getrounddata", function(gamevars)
4562 print("received game round data")
4563 local curmode = game.ReplicatedStorage.ServerSettings.GameMode.Value
4564 if curmode == "Capture the Flag" and gamevars.ctf then
4565 for i, v in next, teams, nil do
4566 local tdata = gamevars.ctf[v.Name]
4567 if tdata and ctf[v.Name] then
4568 ctf[v.Name].basecf = tdata.basecf
4569 if tdata.carrier and not tdata.dropped then
4570 ctf[v.Name].carrier = tdata.carrier
4571 ctf[v.Name].revealtime = tdata.revealtime
4572 attachflag(tdata.carrier)
4573 elseif tdata.dropped then
4574 ctf[v.Name].dropped = true
4575 dropflag(v, nil, tdata.dropcf, tdata.droptime, false)
4576 else
4577 ctf[v.Name].dropped = false
4578 dropflag(v, nil, tdata.basecf, tdata.droptime, true)
4579 end
4580 end
4581 end
4582 end
4583 end)
4584 network:add("clearmap", clearmap)
4585 end
4586 function hud.inializehealth(player, alive)
4587 if not healthlist[player] then
4588 healthlist[player] = {}
4589 end
4590 healthlist[player].health0 = alive and 100 or 0
4591 healthlist[player].healtick0 = 0
4592 healthlist[player].healrate = 0
4593 healthlist[player].maxhealth = 100
4594 healthlist[player].healwait = 5
4595 healthlist[player].alive = alive
4596 end
4597 local function gethealth(player)
4598 local healthstat = healthlist[player]
4599 if healthstat then
4600 local health0 = healthlist[player].health0
4601 local healtick0 = healthlist[player].healtick0
4602 local healrate = healthlist[player].healrate
4603 local maxhealth = healthlist[player].maxhealth
4604 local alive = healthlist[player].alive
4605 if alive then
4606 local x = tick() - healtick0
4607 if x < 0 then
4608 return health0
4609 else
4610 local curhealth = health0 + x * healrate
4611 return maxhealth > curhealth and curhealth or maxhealth
4612 end
4613 else
4614 return 0
4615 end
4616 else
4617 return 0
4618 end
4619 end
4620 local function changehealthlocally(player, dhealth)
4621 local healthstat = healthlist[player]
4622 if healthstat then
4623 local health0 = healthlist[player].health0
4624 local healtick0 = healthlist[player].healtick0
4625 local healrate = healthlist[player].healrate
4626 local maxhealth = healthlist[player].maxhealth
4627 local healwait = healthlist[player].healwait
4628 local alive = healthlist[player].alive
4629 if alive then
4630 local time = tick()
4631 local x = time - healtick0
4632 local curhealth
4633 if x < 0 then
4634 curhealth = health0
4635 else
4636 curhealth = health0 + x * healrate
4637 curhealth = maxhealth > curhealth and curhealth or maxhealth
4638 end
4639 healthlist[player].health0 = curhealth + dhealth
4640 if dhealth < 0 then
4641 healthlist[player].healtick0 = time + healwait
4642 else
4643 healthlist[player].healtick0 = time
4644 end
4645 end
4646 end
4647 end
4648 function hud:changehealthlocally(player, dhealth)
4649 changehealthlocally(player, dhealth)
4650 end
4651 do
4652 local padding = 40
4653 local sightfront = scopefr.SightFront
4654 local sightrear = scopefr.SightRear
4655 local sightreticle = sightrear.ReticleImage
4656 local scopeupdate = function()
4657 end
4658 scopefr.Changed:connect(scopeupdate)
4659 scopeupdate()
4660 function hud.updatescope(fpos, rpos, fsize, rsize)
4661 sightfront.Position = fpos
4662 sightrear.Position = rpos
4663 sightfront.Size = fsize
4664 sightrear.Size = rsize
4665 end
4666 function hud:setscopesettings(data)
4667 sightfront.BackgroundColor3 = data.scopelenscolor or Color3.new(0, 0, 0)
4668 sightfront.BackgroundTransparency = data.scopelenstrans or 1
4669 local imagesize = data.scopeimagesize or 1
4670 sightreticle.Image = data.scopeid
4671 sightreticle.ImageColor3 = data.scopecolor or Color3.new(1, 1, 1)
4672 sightreticle.Size = ud2(imagesize, 0, imagesize, 0)
4673 sightreticle.Position = ud2((1 - imagesize) / 2, 0, (1 - imagesize) / 2, 0)
4674 scopeupdate()
4675 end
4676 end
4677 function hud:gundrop(dropmodel, gunname)
4678 if not gamelogic.currentgun then
4679 return
4680 end
4681 if dropmodel and not ffc(dropmodel, "DB") then
4682 local dropdata = require(modulestore[gunname])
4683 if dropdata then
4684 use.Text = (input.consoleon and "Press DPadRight" or "Hold V") .. " to pick up [" .. (dropdata.displayname or gunname) .. "]"
4685 if dropdata.type == gamelogic.currentgun.type or dropdata.ammotype == gamelogic.currentgun.ammotype then
4686 local sparev = ffc(dropmodel, "Spare")
4687 if sparev and sparev.Value > 0 then
4688 local diff = 0
4689 local _, curspare = gamelogic.currentgun:dropguninfo()
4690 if curspare + sparev.Value > gamelogic.currentgun.sparerounds then
4691 diff = gamelogic.currentgun.sparerounds - curspare
4692 else
4693 diff = sparev.Value
4694 end
4695 if diff > 0 then
4696 local db = new("Model", dropmodel)
4697 db.Name = "DB"
4698 debris:AddItem(db, 1)
4699 gamelogic.currentgun:addammo(diff, gunname)
4700 network:send("g" .. "e" .. "t" .. "a" .. "m" .. "m" .. "o", dropmodel, diff)
4701 end
4702 end
4703 end
4704 end
4705 else
4706 use.Text = ""
4707 end
4708 end
4709 function hud:getuse()
4710 return use.Text ~= ""
4711 end
4712 function hud:enablegamegui(on)
4713 gamegui.Visible = on
4714 end
4715 function hud:togglecinema(on)
4716 cinamode = on
4717 for i, v in next, cinalist, nil do
4718 v.Visible = not on
4719 end
4720 end
4721 function hud:isplayeralive(p)
4722 local healthstat = healthlist[p]
4723 if healthstat then
4724 return healthlist[p].alive
4725 end
4726 end
4727 function hud:timesinceplayercombat(p)
4728 return tick() - (lastcombat[p] or 0)
4729 end
4730 function hud:getplayerpos(p)
4731 local char = p.Character
4732 if char.Parent and hud:isplayeralive(p) then
4733 local torso = ffc(char, "Torso")
4734 if torso then
4735 return torso.Position
4736 end
4737 end
4738 end
4739 function hud:getplayerhealth(p)
4740 return gethealth(p)
4741 end
4742 local function updatecross()
4743 if not char.speed or not char.sprint then
4744 return
4745 end
4746 local size = hud.crossspring.p * 4 * hud.crossscale.p * (char.speed / 14 * 0.19999999999999996 * 2 + 0.8) * (char.sprint + 1) / 2
4747 for i = 1, 4 do
4748 crossparts[i].BackgroundTransparency = 1 - size / 20
4749 end
4750 crossparts[1].Position = ud2(0, size, 0, 0)
4751 crossparts[2].Position = ud2(0, -size - 7, 0, 0)
4752 crossparts[3].Position = ud2(0, 0, 0, size)
4753 crossparts[4].Position = ud2(0, 0, 0, -size - 7)
4754 if not centermark and hud.crossspring.t == 0 and sightmark and sightmark.Parent then
4755 local pos = camera.currentcamera:WorldToViewportPoint(sightmark.Position)
4756 hitmarker.Position = ud2(0, pos.x - 125, 0, pos.y - 125)
4757 else
4758 hitmarker.Position = ud2(0.5, -125, 0.5, -125)
4759 end
4760 end
4761 function hud:getplayervisible(guy)
4762 local state = nametags[guy]
4763 if state then
4764 return state.Visible
4765 end
4766 end
4767 local localplayer = game:GetService("Players").LocalPlayer
4768 local nametagupdates = {}
4769 local function addnametag(player)
4770 if player == localplayer then
4771 return
4772 end
4773 local head, torso
4774 local function newchar(char)
4775 head = char:WaitForChild("Head")
4776 torso = char:WaitForChild("Torso")
4777 end
4778 local tag, taghealth
4779 local function playerchanged(prop)
4780 if prop == "TeamColor" and tag and tag.Parent then
4781 if player.TeamColor == localplayer.TeamColor then
4782 tag.Visible = true
4783 taghealth.Visible = false
4784 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4785 tag.Dot.BackgroundTransparency = 1
4786 else
4787 tag.Visible = false
4788 taghealth.Visible = false
4789 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4790 tag.Dot.BackgroundTransparency = 1
4791 end
4792 end
4793 end
4794 local function newtag()
4795 tag = playertag:Clone()
4796 tag.Text = player.Name
4797 tag.Parent = tagfr
4798 tag.Visible = false
4799 taghealth = wfc(tag, "Health")
4800 tag.Dot.BackgroundTransparency = 1
4801 tag.TextTransparency = 1
4802 tag.TextStrokeTransparency = 1
4803 playerchanged("TeamColor")
4804 nametags[player] = tag
4805 end
4806 newtag()
4807 local function update()
4808 if not tag.Parent or not taghealth.Parent then
4809 return
4810 end
4811 if hud:isplayeralive(player) and head and head.Parent and torso and torso.Parent then
4812 local torsopos = torso.CFrame * v3(0, -0.25, 0)
4813 if camera.screencull.sphere(torsopos, 4) then
4814 local camcf = camera.cframe
4815 local headpos = head.Position
4816 local spos = camera.currentcamera:WorldToScreenPoint(headpos + cframe.vtws(camcf, v3(0, 0.625, 0)))
4817 local center = camera.currentcamera.ViewportSize / 2
4818 local dist = (torsopos - camcf.p).magnitude
4819 local d = dot(camera.lookvector, (torsopos - camcf.p).unit)
4820 local diff = (1 / (d * d) - 1) ^ 0.5 * dist
4821 tag.Position = ud2(0, spos.x - 75, 0, spos.y)
4822 if player.TeamColor == localplayer.TeamColor then
4823 tag.Visible = true
4824 taghealth.Visible = hud:isplayeralive(player)
4825 tag.TextColor3 = color(0, 1, 0.9176470588235294)
4826 tag.Dot.BackgroundColor3 = color(0, 1, 0.9176470588235294)
4827 if diff < 4 then
4828 tag.TextTransparency = 0.125
4829 taghealth.BackgroundTransparency = 0.75
4830 taghealth.Percent.BackgroundTransparency = 0.25
4831 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4832 tag.Dot.BackgroundTransparency = 1
4833 elseif diff < 8 then
4834 tag.TextTransparency = 0.125 + 0.875 * (diff - 4) / 4
4835 taghealth.BackgroundTransparency = 0.75 + 0.25 * (diff - 4) / 4
4836 taghealth.Percent.BackgroundTransparency = 0.25 + 0.75 * (diff - 4) / 4
4837 taghealth.Percent.Size = ud2(gethealth(player) / 100, 0, 1, 0)
4838 tag.Dot.BackgroundTransparency = 1
4839 else
4840 tag.Dot.BackgroundTransparency = 0.125
4841 tag.TextTransparency = 1
4842 taghealth.BackgroundTransparency = 1
4843 taghealth.Percent.BackgroundTransparency = 1
4844 end
4845 else
4846 tag.Dot.BackgroundTransparency = 1
4847 taghealth.Visible = false
4848 tag.TextColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4849 tag.Dot.BackgroundColor3 = color(1, 0.0392156862745098, 0.0784313725490196)
4850 if hud:isspotted(player) and hud:isinsight(player) then
4851 local visible = true
4852 tag.Visible = visible
4853 if visible then
4854 if diff < 4 then
4855 tag.TextTransparency = 0
4856 else
4857 tag.TextTransparency = 1
4858 tag.Dot.BackgroundTransparency = 0
4859 end
4860 end
4861 elseif not hud:isspotted(player) and diff < 4 then
4862 local visible
4863 local tempignore = {
4864 camera.currentcamera,
4865 localplayer.Character,
4866 player.Character
4867 }
4868 local scan, pos = nil, camera.cframe.p
4869 while true do
4870 scan, pos = raycast(workspace, ray(pos, torsopos - pos), tempignore)
4871 if scan then
4872 if scan.Transparency ~= 0 then
4873 tempignore[#tempignore + 1] = scan
4874 else
4875 visible = false
4876 break
4877 end
4878 else
4879 visible = true
4880 break
4881 end
4882 end
4883 tag.Visible = visible
4884 if visible then
4885 if diff < 2 then
4886 tag.Visible = true
4887 tag.TextTransparency = 0.125
4888 elseif diff < 4 then
4889 tag.Visible = true
4890 tag.TextTransparency = 0.4375 * diff - 0.75
4891 else
4892 tag.Visible = false
4893 end
4894 end
4895 else
4896 tag.Visible = false
4897 taghealth.Visible = false
4898 end
4899 end
4900 else
4901 tag.Visible = false
4902 taghealth.Visible = false
4903 end
4904 else
4905 tag.Visible = false
4906 taghealth.Visible = false
4907 end
4908 end
4909 player.CharacterAdded:connect(newchar)
4910 player.Changed:connect(playerchanged)
4911 localplayer.Changed:connect(playerchanged)
4912 nametagupdates[player] = update
4913 delay(1, function()
4914 print("Awaiting char for", player.Name)
4915 while not player.Character do
4916 wait(0.1)
4917 end
4918 print(player.Name .. "'s character has loaded")
4919 newchar(player.Character)
4920 end)
4921 end
4922 game:GetService("Players").PlayerAdded:connect(addnametag)
4923 game:GetService("Players").PlayerRemoving:connect(function(player)
4924 nametagupdates[player] = nil
4925 if nametags[player] then
4926 nametags[player]:Destroy()
4927 end
4928 nametags[player] = nil
4929 end)
4930 for i, player in next, game:GetService("Players"):GetPlayers() do
4931 addnametag(player)
4932 end
4933 local function updateplayernames()
4934 for player, func in next, nametagupdates, nil do
4935 if not player or not player.Parent then
4936 nametagupdates[player] = nil
4937 if nametags[player] then
4938 nametags[player]:Destroy()
4939 end
4940 nametags[player] = nil
4941 else
4942 nametagupdates[player]()
4943 end
4944 end
4945 end
4946 function hud:capping(flag, progress, mode)
4947 local maxcappoint = mode == "ctf" and 100 or 50
4948 if flag then
4949 capfr.Visible = true
4950 capfr.Note.Text = mode == "ctf" and "Recovering..." or "Capturing..."
4951 cbar.Size = ud2(progress / maxcappoint, 0, 1, 0)
4952 else
4953 capfr.Visible = false
4954 end
4955 end
4956 function hud:setsteadybar(size)
4957 steadybar.Size = size
4958 end
4959 function hud:getsteadysize()
4960 return steadybar.Size.X.Scale
4961 end
4962 function hud:setcrossscale(scale)
4963 hud.crossscale.t = scale
4964 end
4965 function hud:setcrosssize(size)
4966 hud.crossspring.t = size
4967 end
4968 function hud:setscope(visible, nosway)
4969 scopefr.Visible = visible
4970 steady.Visible = visible and not nosway
4971 steady.Text = "Hold Shift to steady"
4972 if visible then
4973 sound.play("useScope", 0.25)
4974 doScopeBeat = true
4975 delay(0.5, heartIn)
4976 end
4977 if not visible then
4978 doScopeBeat = false
4979 end
4980 end
4981 function heartIn()
4982 if doScopeBeat then
4983 local setdelay
4984 setdelay = hud:getsteadysize() / 5
4985 sound.play("heartBeatIn", 0.05 + setdelay)
4986 delay(0.3 + setdelay, heartOut)
4987 end
4988 end
4989 function heartOut()
4990 if doScopeBeat then
4991 local setdelay
4992 setdelay = hud:getsteadysize() / 4
4993 sound.play("heartBeatOut", 0.05 + setdelay)
4994 delay(0.5 + setdelay, heartIn)
4995 end
4996 end
4997 function hud:setcrosssettings(size, speed, damper, sight, centered)
4998 hud.crossspring.t = size
4999 hud.crossspring.s = speed
5000 hud.crossspring.d = damper
5001 sightmark = sight
5002 centermark = centered
5003 end
5004 function hud:updatesightmark(sight, centered)
5005 sightmark = sight
5006 centermark = centered
5007 end
5008 function hud:updatescopemark(sight)
5009 scopemark = sight
5010 end
5011 function hud:updateammo(mag, ammo)
5012 if mag == "KNIFE" then
5013 ammotext.Text = "- - -"
5014 magtext.Text = "- - -"
5015 elseif mag == "GRENADE" then
5016 ammotext.Text = "- - -"
5017 magtext.Text = "- - -"
5018 gammo.Text = gamelogic.gammo .. "x"
5019 else
5020 ammotext.Text = ammo
5021 magtext.Text = mag
5022 end
5023 end
5024 function hud:updatefiremode(mode)
5025 fmodetext.Text = mode == "KNIFE" and "- - -" or mode == true and "AUTO" or mode == 1 and "SEMI" or "BURST"
5026 end
5027 function hud:firehitmarker(head)
5028 hud.hitspring.p = -3
5029 if head then
5030 hitmarker.ImageColor3 = Color3.new(1, 0, 0)
5031 else
5032 hitmarker.ImageColor3 = Color3.new(1, 1, 1)
5033 end
5034 end
5035 do
5036 local deg = math.pi / 180
5037 local minimapfiles = wfc(repstore, "MiniMapModels")
5038 local mapname = wfc(repstore.ServerSettings, "MapName")
5039 local temp_minimap = wfc(minimapfiles, "Temp")
5040 local arrow_size = 14
5041 local selfsize = 16
5042 local fov = 45
5043 local height = 50
5044 local rel_height = 0
5045 local scale = 0.2
5046 local static_rotate = false
5047 local y_orientation = 0
5048 local minimapfr = wfc(gamegui, "MiniMapFrame")
5049 local minimap, minicenter, minimapcam, mapmodel, mapcenter, mapprops, refcenter
5050 local radarhash = {
5051 players = {},
5052 objectives = {},
5053 rings = {}
5054 }
5055 local radarfr = wfc(gamegui, "Radar")
5056 local rfolder = wfc(radarfr, "Folder")
5057 local x_res = maingui.AbsoluteSize.X
5058 local y_res = maingui.AbsoluteSize.Y
5059 local rf_x_res = radarfr.AbsoluteSize.X
5060 local rf_y_res = radarfr.AbsoluteSize.Y
5061 local gunshotlist = {}
5062 local ringshotlist = {}
5063 local last_alive_data = {}
5064 local ring_id = "rbxassetid://2925606552"
5065 local arrow_id = "rbxassetid://2911984939"
5066 local triangle_id = "rbxassetid://2910531391"
5067 local height_id = "rbxassetid://2911984609"
5068 local death_id = "rbxassetid://3116912054"
5069 local self_arrow = wfc(radarfr, "Me")
5070 self_arrow.Size = ud2(0, selfsize, 0, selfsize)
5071 self_arrow.Position = ud2(0.5, -selfsize / 2, 0.5, -selfsize / 2)
5072 local ref_arrow_list = {
5073 players = self_arrow,
5074 objectives = wfc(radarfr, "Objective")
5075 }
5076 function hud:reset_minimap()
5077 end
5078 function hud:set_minimap()
5079 print("seting up minimap")
5080 mapmodel = ffc(workspace, "Map")
5081 if mapmodel then
5082 mapcenter = mapmodel.PrimaryPart
5083 mapprops = ffc(mapmodel, "AGMP")
5084 if not mapcenter then
5085 mapcenter = mapmodel.Teleport.B1
5086 end
5087 minimapcam = ffc(minimapfr, "Camera") or new("Camera")
5088 minimapcam.Parent = minimapfr
5089 minimapcam.FieldOfView = fov
5090 minimapfr.CurrentCamera = minimapcam
5091 if not minimap or minimap.Name ~= mapname.Value then
5092 if minimap then
5093 minimap:Destroy()
5094 end
5095 local ref_minimap = ffc(minimapfiles, mapname.Value)
5096 if ref_minimap then
5097 minimap = ref_minimap:Clone()
5098 minimap.Parent = minimapfr
5099 minicenter = minimap.PrimaryPart
5100 else
5101 minimap = temp_minimap:Clone()
5102 minimap.Parent = minimapfr
5103 minicenter = minimap.PrimaryPart
5104 end
5105 else
5106 end
5107 else
5108 print("Did not find map")
5109 end
5110 end
5111 local function gen_minimap_pos(objectcf)
5112 local rel_cf = mapcenter.CFrame:inverse() * objectcf
5113 local scaled_v3 = rel_cf.p * scale
5114 local scaled_pos = scaled_v3 + minicenter.Position
5115 local screenpos, visible = minimapcam:WorldToViewportPoint(scaled_pos)
5116 local scaled_x = screenpos.X
5117 local scaled_y = screenpos.Y
5118 local rel_x = scaled_x - 0.5
5119 local rel_y = 0.5 - scaled_y
5120 local angle = math.atan(rel_x / rel_y) * 180 / math.pi
5121 if rel_y < 0 then
5122 angle = angle - 180
5123 end
5124 local clip_buffer = 0
5125 if scaled_x > 1 - clip_buffer then
5126 scaled_x = 1 - clip_buffer
5127 end
5128 if scaled_x < 0 + clip_buffer then
5129 scaled_x = 0 + clip_buffer
5130 end
5131 if scaled_y > 1 - clip_buffer then
5132 scaled_y = 1 - clip_buffer
5133 end
5134 if scaled_y < 0 + clip_buffer then
5135 scaled_y = 0 + clip_buffer
5136 end
5137 local height_diff = math.abs(objectcf.p.Y - refcenter.CFrame.p.Y)
5138 return scaled_x, scaled_y, height_diff, visible, angle
5139 end
5140 local function get_ring(index)
5141 if not radarhash.rings[index] then
5142 local new_ring = self_arrow:Clone()
5143 new_ring.Parent = rfolder
5144 new_ring.Size = ud2(0, 0, 0, 0)
5145 new_ring.ImageColor3 = Color3.new(0.7843137254901961, 0.19607843137254902, 0.19607843137254902)
5146 new_ring.Image = ring_id
5147 new_ring.Height.Visible = false
5148 radarhash.rings[index] = new_ring
5149 end
5150 return radarhash.rings[index]
5151 end
5152 local function get_arrow(index, mtype)
5153 if not radarhash[mtype][index] then
5154 local new_arrow = ref_arrow_list[mtype]:Clone()
5155 new_arrow.Parent = rfolder
5156 new_arrow.Size = ud2(0, arrow_size, 0, arrow_size)
5157 radarhash[mtype][index] = new_arrow
5158 print("creating new arrow", mtype, index)
5159 end
5160 return radarhash[mtype][index]
5161 end
5162 local updatelastfired = function(object)
5163 end
5164 local function update_minimap_ring(index, ring_data)
5165 local scaled_x, scaled_y, height_diff, visible = gen_minimap_pos(ring_data.refpart.CFrame)
5166 local ring = get_ring(index)
5167 local ring_size0 = ring_data.size0 or 4
5168 local ring_size1 = ring_data.size1 or 30
5169 local ring_size
5170 local ring_trans = (tick() - ring_data.shottime) / ring_data.lifetime
5171 local delta = (ring_size1 - ring_size0) * ring_trans
5172 ring_size = ring_size0 + delta
5173 ring.ImageColor3 = ring_data.teamcolor == localplayer.TeamColor and color(0, 0.7843137254901961, 1) or Color3.new(0.7843137254901961, 0.19607843137254902, 0.19607843137254902)
5174 ring.ImageTransparency = ring_trans
5175 ring.Size = ud2(0, ring_size, 0, ring_size)
5176 ring.Position = ud2(scaled_x, -ring_size / 2, scaled_y, -ring_size / 2)
5177 ring.Visible = true
5178 end
5179 local function update_minimap_object(data)
5180 local scaled_x, scaled_y, height_diff, visible, rel_angle = gen_minimap_pos(data.partcf)
5181 local cur_arrow_size = arrow_size
5182 local height_trans = 0.002 * height_diff ^ 2.5
5183 local arrow = get_arrow(data.index, data.mtype)
5184 local arrow_color
5185 if data.mtype == "players" then
5186 arrow.Image = data.isalive and arrow_id or death_id
5187 arrow_color = data.teamcolor == player.TeamColor and color(0, 0.7843137254901961, 1) or color(1, 0, 0)
5188 if data.isself then
5189 arrow_color = color(0, 1, 0.2)
5190 end
5191 arrow.ImageColor3 = arrow_color
5192 arrow.Height.ImageColor3 = arrow.ImageColor3
5193 arrow.Height.Visible = not data.isself and data.isalive
5194 arrow.Height.ImageTransparency = data.trans or 0
5195 local _, y, _ = data.partcf:ToOrientation()
5196 local py_angle = y * 180 / math.pi
5197 local rel_y = y_orientation
5198 if static_rotate then
5199 rel_y = mapcenter.Orientation.Y
5200 end
5201 if visible then
5202 arrow.Rotation = rel_y - py_angle
5203 arrow.ImageTransparency = data.trans or height_trans
5204 else
5205 arrow.Rotation = rel_angle
5206 cur_arrow_size = arrow_size - 2
5207 arrow.Image = data.isalive and triangle_id or death_id
5208 arrow.ImageTransparency = data.trans or 0
5209 end
5210 arrow.Size = ud2(0, cur_arrow_size, 0, cur_arrow_size)
5211 elseif data.mtype == "objectives" then
5212 arrow_color = data.teamcolor.Color
5213 arrow.Label.Text = data.text
5214 arrow.Label.TextColor3 = arrow_color
5215 arrow.Label.Visible = true
5216 end
5217 arrow.ImageColor3 = arrow_color
5218 arrow.Position = ud2(scaled_x, -cur_arrow_size / 2, scaled_y, -cur_arrow_size / 2)
5219 arrow.Visible = true
5220 end
5221 function hud:fireradar(guy, suppressed, pingdata)
5222 local gunshotdata = gunshotlist[guy]
5223 if not gunshotdata and guy.TeamColor ~= localplayer.TeamColor then
5224 local refpart = new("Part")
5225 gunshotdata = {
5226 refpart = refpart,
5227 shottime = 0,
5228 lifetime = 0
5229 }
5230 gunshotlist[guy] = gunshotdata
5231 end
5232 local ringshotdata = ringshotlist[guy]
5233 if not ringshotdata then
5234 local refpart = new("Part")
5235 ringshotdata = {
5236 refpart = refpart,
5237 shottime = 0,
5238 lifetime = 0,
5239 teamcolor = guy.TeamColor
5240 }
5241 ringshotlist[guy] = ringshotdata
5242 end
5243 local rootpart = ffc(guy.Character, "HumanoidRootPart")
5244 local alive = hud:isplayeralive(guy)
5245 if rootpart and alive then
5246 ringshotdata.refpart.CFrame = rootpart.CFrame
5247 ringshotdata.teamcolor = guy.TeamColor
5248 ringshotdata.lifetime = pingdata.pinglife or 0.5
5249 ringshotdata.size0 = pingdata.size0
5250 ringshotdata.size1 = pingdata.size1
5251 if tick() > ringshotdata.shottime + ringshotdata.lifetime then
5252 ringshotdata.shottime = tick()
5253 end
5254 if not suppressed and guy.TeamColor ~= localplayer.TeamColor then
5255 gunshotdata.refpart.CFrame = rootpart.CFrame
5256 gunshotdata.lifetime = 5
5257 gunshotdata.shottime = tick()
5258 end
5259 end
5260 end
5261 function hud:set_rel_height()
5262 rel_height = rel_height == 0 and 1 or 0
5263 end
5264 function hud:set_minimap_style()
5265 static_rotate = not static_rotate
5266 end
5267 local function updateminimap()
5268 if not mapcenter then
5269 return print("No map found")
5270 end
5271 if not minicenter then
5272 return print("No minimap found")
5273 end
5274 refcenter = camera:isspectating() or camera.currentcamera
5275 if char.health > 0 then
5276 self_arrow.Visible = true
5277 self_arrow.ImageColor3 = color(0, 200, 255)
5278 else
5279 self_arrow.Visible = camera:isspectating()
5280 self_arrow.ImageColor3 = color(1, 0, 0)
5281 end
5282 self_arrow.Height.ImageColor3 = self_arrow.ImageColor3
5283 local rel_cf = mapcenter.CFrame:inverse() * refcenter.CFrame
5284 local scaled_v3 = rel_cf.p * scale * v3(1, rel_height, 1)
5285 local _, y_angle, _ = camera.cframe:ToOrientation()
5286 y_orientation = y_angle * 180 / math.pi
5287 local angle = mapcenter.Orientation.Y - y_orientation
5288 local scaled_pos = scaled_v3 + minicenter.Position
5289 if static_rotate then
5290 minimapcam.CFrame = CFrame.new(scaled_pos + Vector3.new(0, height, 0)) * CFrame.Angles(-90 * deg, 0, 0)
5291 self_arrow.Rotation = angle
5292 else
5293 minimapcam.CFrame = CFrame.new(scaled_pos + Vector3.new(0, height, 0)) * CFrame.Angles(0, -angle * deg, 0) * CFrame.Angles(-90 * deg, 0, 0)
5294 self_arrow.Rotation = 0
5295 end
5296 local p_index = 0
5297 local ppl = game:GetService("Players"):GetPlayers()
5298 for i = 1, #ppl do
5299 local v = ppl[i]
5300 local rootpart = ffc(v.Character, "HumanoidRootPart")
5301 local alive = hud:isplayeralive(v) or localplayer == v and char.health > 0
5302 if not last_alive_data[v] then
5303 last_alive_data[v] = {
5304 lastcf = cf(),
5305 alivetick = 0
5306 }
5307 end
5308 if rootpart and alive then
5309 last_alive_data[v].lastcf = rootpart.CFrame
5310 last_alive_data[v].alivetick = tick()
5311 end
5312 local diff = 0
5313 local transparency
5314 local show = localplayer ~= v and v.TeamColor == localplayer.TeamColor
5315 if not alive then
5316 diff = (tick() - last_alive_data[v].alivetick) / 5
5317 transparency = math.min(diff > 0.1 and diff ^ 0.5 or 0, 1)
5318 show = true
5319 elseif not show and hud:isspotted(v) and hud:isinsight(v) and localplayer ~= v then
5320 transparency = 0
5321 show = true
5322 end
5323 local rootcf = last_alive_data[v].lastcf
5324 if rootcf and show then
5325 p_index = p_index + 1
5326 update_minimap_object({
5327 isself = v == localplayer,
5328 isalive = alive,
5329 index = p_index,
5330 partcf = rootcf,
5331 teamcolor = v.TeamColor,
5332 mtype = "players",
5333 trans = transparency
5334 })
5335 end
5336 end
5337 for v, shotdata in next, gunshotlist, nil do
5338 local lifetime = shotdata.shottime + shotdata.lifetime - tick()
5339 if not v.Parent then
5340 if shotdata.refpart then
5341 shotdata.refpart:Destroy()
5342 end
5343 gunshotlist[v] = nil
5344 elseif lifetime > 0 then
5345 local alive = hud:isplayeralive(v)
5346 local diff = (tick() - shotdata.shottime) / shotdata.lifetime
5347 local arrow_trans = diff > 0.1 and diff ^ 0.5 or 0
5348 if alive then
5349 p_index = p_index + 1
5350 update_minimap_object({
5351 isalive = alive,
5352 index = p_index,
5353 partcf = shotdata.refpart.CFrame,
5354 teamcolor = v.TeamColor,
5355 mtype = "players",
5356 trans = arrow_trans
5357 })
5358 end
5359 end
5360 end
5361 local r_index = 0
5362 for v, shotdata in next, ringshotlist, nil do
5363 local lifetime = shotdata.shottime + shotdata.lifetime - tick()
5364 if not v.Parent then
5365 if shotdata.refpart then
5366 shotdata.refpart:Destroy()
5367 end
5368 ringshotlist[v] = nil
5369 elseif lifetime > 0 then
5370 r_index = r_index + 1
5371 update_minimap_ring(r_index, shotdata)
5372 end
5373 end
5374 local m_index = 0
5375 if mapprops then
5376 local stuff = mapprops:GetChildren()
5377 for i = 1, #stuff do
5378 local v = stuff[i]
5379 local base = ffc(v, "Base")
5380 local teamcolor = ffc(v, "TeamColor")
5381 local letter = ffc(v, "Letter")
5382 local text
5383 if v.Name == "KingFlag" then
5384 text = "H"
5385 elseif v.Name == "FlagBase" then
5386 text = "F"
5387 elseif v.Name == "DomFlag" then
5388 text = letter and letter.Value or ""
5389 end
5390 if base then
5391 m_index = m_index + 1
5392 update_minimap_object({
5393 index = m_index,
5394 partcf = base.CFrame,
5395 teamcolor = teamcolor.Value,
5396 mtype = "objectives",
5397 text = text
5398 })
5399 end
5400 end
5401 end
5402 end
5403 local function reset_radar_pool()
5404 local old = rfolder:GetChildren()
5405 for i = 1, #old do
5406 old[i].Visible = false
5407 end
5408 for i, v in next, last_alive_data, nil do
5409 if not i.Parent then
5410 last_alive_data[i] = nil
5411 end
5412 end
5413 end
5414 function radarstep()
5415 reset_radar_pool()
5416 updateminimap()
5417 end
5418 end
5419 local function updatehealth()
5420 local health = char.health
5421 healthtext.Text = health + -health % 1
5422 if health < prevhealth then
5423 local damage = prevhealth - health
5424 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency - damage / prevhealth * 0.7
5425 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency - damage / prevhealth * 0.5 + 0.3
5426 elseif health > prevhealth or health == 100 then
5427 bloodscreen.ImageTransparency = bloodscreen.ImageTransparency + 0.001
5428 bloodscreen.BackgroundTransparency = bloodscreen.BackgroundTransparency + 0.001
5429 elseif health <= 0 then
5430 bloodscreen.ImageTransparency = 1
5431 bloodscreen.BackgroundTransparency = 1
5432 end
5433 prevhealth = health
5434 if health <= 25 then
5435 healthbar.BackgroundColor3 = newGUIColors[4]
5436 healthbarFill.BackgroundColor3 = newGUIColors[3]
5437 else
5438 healthbar.BackgroundColor3 = newGUIColors[1]
5439 healthbarFill.BackgroundColor3 = newGUIColors[2]
5440 end
5441 healthbarFill.Size = UDim2.new(math.floor(health) / 100, 0, 1, 0)
5442 end
5443 do
5444 local spottedlist = {}
5445 local sightlist = {}
5446 local brokensight = {}
5447 function hud:spot()
5448 local spotlist = {}
5449 if char.health > 0 then
5450 local camcf = camera.cframe
5451 local dir = camcf.lookVector.unit
5452 local ppl = game:GetService("Players"):GetPlayers()
5453 local lteam = player.TeamColor
5454 local ignoretable = {
5455 camera.currentcamera,
5456 workspace.Ignore,
5457 workspace.DeadBody,
5458 player.Character
5459 }
5460 for i = 1, #ppl do
5461 local guy = ppl[i]
5462 if hud:isplayeralive(guy) and guy.TeamColor ~= lteam then
5463 local bodyparts = replication.getbodyparts(guy)
5464 if bodyparts and bodyparts.head then
5465 local rel = bodyparts.head.Position - camera.cframe.p
5466 local unit = rel.unit
5467 local d = dot(dir, unit)
5468 if d > 0.96592582628 then
5469 local origin = camcf.p
5470 local newray = ray(origin, rel)
5471 ignoretable[5] = bodyparts.head.Parent
5472 local hit = raycast(workspace, newray, ignoretable)
5473 if not hit then
5474 sightlist[guy] = true
5475 spotlist[#spotlist + 1] = guy
5476 end
5477 end
5478 end
5479 end
5480 end
5481 if #spotlist > 0 then
5482 network:send("spotplayers", spotlist)
5483 return true
5484 end
5485 end
5486 end
5487 network:add("brokensight", function(spottedplayer, status)
5488 if spottedplayer then
5489 brokensight[spottedplayer] = status
5490 end
5491 end)
5492 network:add("spotplayer", function(spottedplayer)
5493 if spottedplayer then
5494 spottedlist[spottedplayer] = true
5495 end
5496 end)
5497 network:add("unspotplayer", function(spottedplayer)
5498 if spottedplayer then
5499 spottedlist[spottedplayer] = nil
5500 end
5501 end)
5502 function hud:isspotted(spottedplayer)
5503 return spottedlist[spottedplayer]
5504 end
5505 function hud:isinsight(spottedplayer)
5506 return not brokensight[spottedplayer] or sightlist[player]
5507 end
5508 function hud.spotstep()
5509 local ignoretable = {
5510 camera.currentcamera,
5511 workspace.Ignore,
5512 workspace.DeadBody,
5513 player.Character
5514 }
5515 for spottedplayer in next, spottedlist, nil do
5516 local playerseen = false
5517 if char.health > 0 and spottedplayer.TeamColor ~= player.TeamColor then
5518 local bodyparts = replication.getbodyparts(spottedplayer)
5519 if bodyparts and bodyparts.torso and camera.screencull.sphere(bodyparts.torso.Position, 4) then
5520 local rel = bodyparts.head.Position - camera.cframe.p
5521 local origin = camera.cframe.p
5522 local newray = ray(origin, rel)
5523 ignoretable[5] = bodyparts.head.Parent
5524 local hit = raycast(workspace, newray, ignoretable)
5525 if not hit then
5526 playerseen = true
5527 if not sightlist[spottedplayer] then
5528 sightlist[spottedplayer] = true
5529 network:send("updatesight", spottedplayer, true, tick())
5530 end
5531 end
5532 end
5533 end
5534 if not playerseen and sightlist[spottedplayer] then
5535 sightlist[spottedplayer] = false
5536 network:send("updatesight", spottedplayer, false, tick())
5537 end
5538 end
5539 if hud:isspotted(player) then
5540 spotted.Visible = true
5541 if hud:isinsight(player) then
5542 spotted.Text = "Spotted by enemy!"
5543 spotted.TextColor3 = Color3.new(1, 0.125, 0.125)
5544 else
5545 spotted.Text = "Hiding from enemy..."
5546 spotted.TextColor3 = Color3.new(0.125, 1, 0.125)
5547 end
5548 else
5549 local spottag = ffc(spotted, "Spottimer")
5550 if spottag and 0 < spottag.Timer.Value then
5551 spotted.Visible = true
5552 spotted.Text = "On Radar!"
5553 spotted.TextColor3 = Color3.new(1, 0.8, 0)
5554 else
5555 spotted.Visible = false
5556 end
5557 end
5558 end
5559 function hud:goingloud()
5560 local spottag = ffc(spotted, "Spottimer")
5561 local timer
5562 if not spottag then
5563 spottag = new("Model", spotted)
5564 spottag.Name = "Spottimer"
5565 timer = new("IntValue", spottag)
5566 timer.Name = "Timer"
5567 else
5568 timer = spottag.Timer
5569 end
5570 timer.Value = timer.Value <= 30 and 30 or timer.Value + 30 > 200 and 200 or timer.Value + 30
5571 end
5572 end
5573 network:add("firehitmarker", function()
5574 hud:firehitmarker()
5575 end)
5576 network:add("shot", function(shooter, pos, damage)
5577 local bars = gamegui:GetChildren()
5578 for i = 1, #bars do
5579 if bars[i].Name == "BloodArc" and bars[i].Player.Value == shooter.Name then
5580 trash.remove(bars[i])
5581 end
5582 end
5583 local br = bloodarc:Clone()
5584 br.Pos.Value = pos
5585 br.Player.Value = shooter.Name
5586 br.Parent = gamegui
5587 local dir = (camera.cframe.p - pos).unit
5588 camera:hit((-damage / 12 + 4.166666666666667) * dir)
5589 end)
5590 network:add("updatecombat", function(guy, time)
5591 if guy then
5592 lastcombat[guy] = time
5593 end
5594 end)
5595 function hud:reloadhud()
5596 pgui = player.PlayerGui
5597 maingui = wfc(pgui, "MainGui")
5598 gamegui = wfc(maingui, "GameGui")
5599 bloodscreen = wfc(gamegui, "BloodScreen")
5600 crossframe = wfc(gamegui, "CrossHud")
5601 crossparts = {
5602 wfc(crossframe, "HR"),
5603 wfc(crossframe, "HL"),
5604 wfc(crossframe, "VD"),
5605 wfc(crossframe, "VU")
5606 }
5607 ammohud = wfc(gamegui, "AmmoHud")
5608 ammofr = wfc(ammohud, "Frame")
5609 scopefr = wfc(maingui, "ScopeFrame")
5610 ammotext = wfc(ammofr, "Ammo")
5611 magtext = wfc(ammofr, "Mag")
5612 healthtext = wfc(ammofr, "Health")
5613 fmodetext = wfc(ammofr, "FMode")
5614 hitmarker = wfc(gamegui, "Hitmarker")
5615 tagfr = wfc(gamegui, "NameTag")
5616 healthbar = wfc(ammofr, "healthbar_back")
5617 healthbarFill = wfc(healthbar, "healthbar_fill")
5618 radar = wfc(gamegui, "Radar")
5619 rme = wfc(radar, "Me")
5620 rfolder = wfc(radar, "Folder")
5621 dotlist = {}
5622 hud:reset_minimap()
5623 hud:setscope(false)
5624 effects:reload()
5625 notify:reset()
5626 particle:reset()
5627 local bars = gamegui:GetChildren()
5628 for i = 1, #bars do
5629 if bars[i].Name == "BloodArc" then
5630 trash.remove(bars[i])
5631 end
5632 end
5633 local bar = ffc(maingui, "KillBar")
5634 if bar then
5635 trash.remove(bar)
5636 end
5637 wait(0.1)
5638 end
5639 function hud.beat()
5640 updateplayernames()
5641 updatehealth()
5642 end
5643 function hud.step()
5644 if gamegui.Visible then
5645 updatecross()
5646 hitmarker.ImageTransparency = hud.hitspring.p
5647 radarstep()
5648 if run.time > rtime + renderinterval then
5649 hud.gamemoderenderstep()
5650 rtime = run.time + renderinterval
5651 end
5652 if run.time > stime + spotinterval then
5653 hud.spotstep()
5654 hud.votestep()
5655 hud.gamemodestep()
5656 local sht = spot:GetChildren()
5657 for i = 1, #sht do
5658 local v = sht[i]
5659 if rtype(v, "BillboardGui") then
5660 if v.Time.Value <= 0 then
5661 trash.remove(v)
5662 else
5663 v.Time.Value = v.Time.Value - 1
5664 end
5665 end
5666 end
5667 local spottag = ffc(spotted, "Spottimer")
5668 if spottag and 0 < spottag.Timer.Value then
5669 spottag.Timer.Value = spottag.Timer.Value - 1
5670 end
5671 stime = run.time + spotinterval
5672 end
5673 end
5674 end
5675end
5676print("Loading notify module")
5677do
5678 local wfc = game.WaitForChild
5679 local ffc = game.FindFirstChild
5680 local ud2 = UDim2.new
5681 local ceil = math.ceil
5682 local v3 = Vector3.new
5683 local color = Color3.new
5684 local dot = Vector3.new().Dot
5685 local workspace = workspace
5686 local ray = Ray.new
5687 local raycast = workspace.FindPartOnRayWithIgnoreList
5688 local new = Instance.new
5689 local player = game:GetService("Players").LocalPlayer
5690 local repstore = game.ReplicatedStorage
5691 local misc = repstore.Misc
5692 local pgui = player.PlayerGui
5693 local maingui = wfc(pgui, "MainGui")
5694 local gamegui = wfc(maingui, "GameGui")
5695 local framelist = wfc(gamegui, "NotifyList")
5696 local main = misc.Main
5697 local side = misc.Side
5698 local killbar = misc.KillBar
5699 local rankbar = misc.RankBar
5700 local attachbar = misc.AttachBar
5701 local typelist = {
5702 kill = {
5703 "Enemy Killed!"
5704 },
5705 collx2 = {
5706 "Double Collateral!"
5707 },
5708 collx3 = {
5709 "Triple Collateral!"
5710 },
5711 collxn = {
5712 "Multi Collateral!"
5713 },
5714 killx2 = {
5715 "Double Kill!"
5716 },
5717 killx3 = {
5718 "Triple Kill!"
5719 },
5720 killx4 = {"Quad Kill!"},
5721 killxn = {
5722 "Multi Kill!"
5723 },
5724 backstab = {"Backstab!"},
5725 assist = {"Assist!"},
5726 suppression = {
5727 "Suppressed Enemy!"
5728 },
5729 assistkill = {
5730 "Assist Count As Kill!"
5731 },
5732 head = {
5733 "Headshot Bonus!"
5734 },
5735 wall = {
5736 "Wallbang Bonus!"
5737 },
5738 spot = {
5739 "Spot Bonus!"
5740 },
5741 long = {
5742 "Killed from a distance!"
5743 },
5744 squad = {
5745 "Teammate spawned on you"
5746 },
5747 flagsteal = {
5748 "Acquired Enemy Flag!"
5749 },
5750 flagcapture = {
5751 "Captured Enemy Flag!"
5752 },
5753 flagteamcap = {
5754 "Team Captured Enemy Flag!"
5755 },
5756 flagrecover = {
5757 "Recovered Team Flag!"
5758 },
5759 flagdef1 = {
5760 "Killed Enemy Flag Carrier!"
5761 },
5762 flagdef2 = {
5763 "Protected Flag Carrier!"
5764 },
5765 flagdef3 = {
5766 "Denied Enemy Capture!"
5767 },
5768 flagdef4 = {
5769 "Denied Enemy Pick Up!"
5770 },
5771 flagdef5 = {
5772 "Flag Guard Kill!"
5773 },
5774 flagdef6 = {
5775 "Flag Recover Kill!"
5776 },
5777 flagsup1 = {
5778 "Flag Escort Kill!"
5779 },
5780 flagsup2 = {
5781 "Killed Enemy Flag Escort!"
5782 },
5783 flagsup3 = {
5784 "Assisted by Teammate!"
5785 },
5786 flagsup4 = {
5787 "Protected Flag Carrier Under Fire!"
5788 },
5789 flagsup5 = {
5790 "Saved by Teammate!"
5791 },
5792 flagsup6 = {
5793 "Protected by Teammate!"
5794 },
5795 flagoff1 = {
5796 "Offensive Flag Kill!"
5797 },
5798 flagoff2 = {
5799 "Denied Enemy Flag Recovery!"
5800 },
5801 flagoff3 = {
5802 "Killed Enemy Flag Guard!"
5803 },
5804 dogtagself = {
5805 "Secured Personal Tag!"
5806 },
5807 dogtagconfirm = {
5808 "Kill Confirmed!"
5809 },
5810 dogtagteam = {
5811 "Teammate Confirmed Kill!"
5812 },
5813 dogtagdeny = {
5814 "Denied Enemy Kill!"
5815 },
5816 domcap = {
5817 "Captured a position!"
5818 },
5819 domcapping = {
5820 "Capturing position"
5821 },
5822 domdefend = {
5823 "Defended a position!"
5824 },
5825 domassault = {
5826 "Assaulted a position!"
5827 },
5828 domattack = {
5829 "Attacked a position!"
5830 },
5831 dombuzz = {
5832 "Stopped an enemy capture!"
5833 },
5834 kingcap = {
5835 "Captured the hill!"
5836 },
5837 kingholding = {
5838 "Holding hill"
5839 },
5840 kingcapping = {
5841 "Capturing hill"
5842 },
5843 kingdefend = {
5844 "Defended the hill!"
5845 },
5846 kingassault = {
5847 "Assaulted the hill!"
5848 },
5849 kingattack = {
5850 "Attacked the hill!"
5851 },
5852 kingbuzz = {
5853 "Stopped enemy capture of the hill!"
5854 },
5855 [""] = {}
5856 }
5857 local function typeout(label, speed)
5858 local speed = speed or 2
5859 local text = label.Text
5860 label.Text = ""
5861 spawn(function()
5862 for i = 1, string.len(text) do
5863 if i % 2 == 0 then
5864 sound.play("ui_typeout", 0.2)
5865 end
5866 label.Text = string.sub(text, 1, speed * i)
5867 wait(0.016666666666666666)
5868 end
5869 end)
5870 end
5871 local function queuetypeout(label, speed)
5872 local speed = speed or 3
5873 local text = label.Text
5874 label.Text = ""
5875 for i = 1, string.len(text) do
5876 if i % 2 == 0 then
5877 sound.play("ui_typeout", 0.2)
5878 end
5879 label.Text = string.sub(text, 1, speed * i)
5880 wait(0.016666666666666666)
5881 end
5882 end
5883 function notify:customaward(customtext)
5884 local display = side:Clone()
5885 local primary = wfc(display, "Primary")
5886 display.Parent = framelist
5887 sound.play("ui_smallaward", 0.2)
5888 local fr = framelist:GetChildren()
5889 for i = 1, #fr do
5890 local v = fr[i]
5891 if v:IsA("Frame") and v.Parent then
5892 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5893 end
5894 end
5895 spawn(function()
5896 primary.Text = customtext
5897 primary.TextTransparency = 0
5898 typeout(primary, 3)
5899 wait(5.5)
5900 for i = 1, 10 do
5901 primary.TextTransparency = i / 10
5902 primary.TextStrokeTransparency = i / 10 + 0.4
5903 wait(0.016666666666666666)
5904 end
5905 wait(0.1)
5906 trash.remove(display)
5907 end)
5908 end
5909 function smallaward(type, pt)
5910 local pt = pt or 25
5911 local display = side:Clone()
5912 local primary = wfc(display, "Primary")
5913 local point = wfc(display, "Point")
5914 sound.play("ui_smallaward", 0.2)
5915 display.Parent = framelist
5916 local fr = framelist:GetChildren()
5917 for i = 1, #fr do
5918 local v = fr[i]
5919 if v:IsA("Frame") and v.Parent then
5920 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5921 end
5922 end
5923 spawn(function()
5924 point.Text = "[+" .. pt .. "]"
5925 primary.Text = typelist[type][1]
5926 if type == "head" then
5927 sound.play("headshotkill", 0.45)
5928 end
5929 point.TextTransparency = 0
5930 primary.TextTransparency = 0
5931 typeout(point, 3)
5932 typeout(primary, 3)
5933 wait(5.5)
5934 for i = 1, 10 do
5935 point.TextTransparency = i / 10
5936 primary.TextTransparency = i / 10
5937 point.TextStrokeTransparency = i / 10 + 0.4
5938 primary.TextStrokeTransparency = i / 10 + 0.4
5939 wait(0.016666666666666666)
5940 end
5941 wait(0.1)
5942 trash.remove(display)
5943 end)
5944 end
5945 function bigaward(type, victim, weap, pt, extradata)
5946 local display = main:Clone()
5947 local bk = wfc(display, "Overlay")
5948 local primary = wfc(display, "Primary")
5949 local point = wfc(display, "Point")
5950 local enemy = wfc(display, "Enemy")
5951 display.Parent = framelist
5952 local fr = framelist:GetChildren()
5953 for i = 1, #fr do
5954 local v = fr[i]
5955 if v:IsA("Frame") and v.Parent then
5956 v:TweenPosition(ud2(0, 0, 0, (#fr - i) * 20), "Out", "Sine", 0.05, true)
5957 end
5958 end
5959 spawn(function()
5960 point.Text = "[+" .. pt .. "]"
5961 primary.Text = typelist[type][1]
5962 enemy.Text = victim or ""
5963 sound.play("ui_begin", 0.4)
5964 if type == "kill" then
5965 sound.play("killshot", 0.2)
5966 else
5967 end
5968 point.TextTransparency = 0
5969 point.TextStrokeTransparency = 0
5970 primary.TextTransparency = 0
5971 primary.TextStrokeTransparency = 0
5972 enemy.TextTransparency = 1
5973 enemy.TextStrokeTransparency = 1
5974 bk.ImageTransparency = 0.2
5975 bk:TweenSizeAndPosition(ud2(0, 200, 0, 80), ud2(0.5, -150, 0.7, -40), "Out", "Linear", 0, true)
5976 typeout(point)
5977 typeout(primary)
5978 spawn(function()
5979 wait(0.05)
5980 for i = 1, 10 do
5981 bk.ImageTransparency = i / 10
5982 wait(0.1)
5983 end
5984 bk.Size = ud2(0, 200, 0, 80)
5985 bk.Position = ud2(0.55, -100, 0.3, -40)
5986 end)
5987 bk:TweenSizeAndPosition(ud2(0, 300, 0, 30), ud2(0.5, -150, 0.7, -15), "Out", "Linear", 0.05, true)
5988 wait(0.05)
5989 bk:TweenSizeAndPosition(ud2(0, 500, 0, 8), ud2(0.5, -150, 0.7, -4), "Out", "Linear", 0.05, true)
5990 wait(1.5)
5991 for i = 1, 2 do
5992 primary.TextTransparency = 1
5993 primary.TextStrokeTransparency = 1
5994 sound.play("ui_blink", 0.4)
5995 wait(0.1)
5996 primary.TextTransparency = 0
5997 primary.TextStrokeTransparency = 0
5998 wait(0.1)
5999 end
6000 primary.TextTransparency = 1
6001 primary.TextStrokeTransparency = 1
6002 wait(0.2)
6003 enemy.TextTransparency = 0
6004 enemy.TextStrokeTransparency = 0
6005 queuetypeout(enemy, 4)
6006 primary.TextTransparency = 0
6007 primary.TextStrokeTransparency = 0
6008 primary.Position = ud2(0.5, enemy.TextBounds.x + 10, 0.7, -10)
6009 if type == "kill" then
6010 primary.Text = "[" .. weap .. "]"
6011 else
6012 primary.Text = weap
6013 end
6014 queuetypeout(primary, 4)
6015 wait(3)
6016 for i = 1, 10 do
6017 point.TextTransparency = i / 10
6018 primary.TextTransparency = i / 10
6019 enemy.TextTransparency = i / 10
6020 point.TextStrokeTransparency = i / 10 + 0.4
6021 primary.TextStrokeTransparency = i / 10 + 0.4
6022 enemy.TextStrokeTransparency = i / 10 + 0.4
6023 wait(0.016666666666666666)
6024 end
6025 wait(0.1)
6026 trash.remove(display)
6027 end)
6028 end
6029 local function unlockedgun(weapon)
6030 local br = attachbar:Clone()
6031 local title = br.Title
6032 local atext = br.Attach
6033 br.Parent = maingui
6034 br.Position = ud2(0.5, 0, 0.15, 0)
6035 title.Text = "Unlocked New Gun!"
6036 atext.Text = weapon
6037 local t0 = tick()
6038 local stop
6039 stop = run.onstep:connect(function()
6040 local t = tick() - t0
6041 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6042 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6043 if t > 3 then
6044 stop()
6045 br:Destroy()
6046 end
6047 end)
6048 end
6049 local function unlockedattach(weapon, attachments, killss)
6050 for i = 1, #attachments do
6051 do
6052 local attachment = attachments[i]
6053 local kills = killss[i]
6054 local br = attachbar:Clone()
6055 local money = br.Money
6056 local title = br.Title
6057 local atext = br.Attach
6058 br.Parent = maingui
6059 br.Position = ud2(0.5, 0, 0.15, 0)
6060 title.Text = "Unlocked " .. weapon .. " Attachment"
6061 atext.Text = attachment
6062 money.Text = "[+200]"
6063 local t0 = tick()
6064 local stop
6065 stop = run.onstep:connect(function()
6066 local t = tick() - t0
6067 atext.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6068 title.TextTransparency = t < 2 and 0 or t < 2.5 and (t - 2) / 0.5 or 1
6069 money.TextTransparency = t < 0.5 and 1 or t < 2.5 and 0 or t < 3 and (t - 2.5) / 0.5 or 1
6070 if t > 3 then
6071 stop()
6072 br:Destroy()
6073 end
6074 end)
6075 wait(3)
6076 end
6077 end
6078 end
6079 local function rankup(old, new, newguns)
6080 local br = rankbar:Clone()
6081 local money = br.Money
6082 local title = br.Title
6083 local rtext = br.Rank
6084 local count = 0
6085 local sht = maingui:GetChildren()
6086 for i = 1, #sht do
6087 if sht[i].Name == "RankBar" or sht[i].Name == "AttachBar" then
6088 count = count + 1
6089 end
6090 end
6091 br.Parent = maingui
6092 rtext.Text = new
6093 money.Text = "+" .. 5 * (new - old) * (81 + new + old) / 2 .. " CR"
6094 local t0 = tick()
6095 local stop
6096 stop = run.onstep:connect(function()
6097 local t = tick() - t0
6098 rtext.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
6099 title.TextTransparency = t < 3 and 0 or t < 3.5 and (t - 3) / 0.5 or 1
6100 money.TextTransparency = t < 0.5 and 1 or t < 3.5 and 0 or t < 4 and (t - 3.5) / 0.5 or 1
6101 if t > 4 then
6102 stop()
6103 br:Destroy()
6104 if newguns then
6105 for i = 1, #newguns do
6106 unlockedgun(newguns[i])
6107 wait(3)
6108 end
6109 end
6110 end
6111 end)
6112 end
6113 function notify:testrankup(rank)
6114 rankup(rank)
6115 end
6116 function notify:reset()
6117 maingui = wfc(pgui, "MainGui")
6118 gamegui = wfc(maingui, "GameGui")
6119 framelist = wfc(gamegui, "NotifyList")
6120 if ffc(maingui, "KillBar") then
6121 trash.remove(maingui.KillBar)
6122 end
6123 end
6124 do
6125 local cf = CFrame.new
6126 local tos = cf().toObjectSpace
6127 local bcolor = BrickColor.new
6128 local repstore = game.ReplicatedStorage
6129 local gunmodels = repstore.GunModels
6130 local gunmodules = repstore.GunModules
6131 local attmodels = repstore.AttachmentModels
6132 local function hideparts(wepmodel, atttype, hide)
6133 local parts = wepmodel:GetChildren()
6134 local slottag
6135 for i = 1, #parts do
6136 if atttype == "Optics" then
6137 if parts[i].Name == "Iron" or parts[i].Name == "IronGlow" then
6138 if hide and not ffc(parts[i], "Hide") then
6139 local tag = new("IntValue", parts[i])
6140 tag.Name = "Hide"
6141 else
6142 local tag = ffc(parts[i], "Hide")
6143 if tag then
6144 tag:Destroy()
6145 end
6146 end
6147 parts[i].Transparency = hide and 1 or 0
6148 elseif parts[i].Name == "SightMark" and ffc(parts[i], "Decal") then
6149 parts[i].Decal.Transparency = hide and 1 or 0
6150 end
6151 elseif atttype == "Underbarrel" and parts[i].Name == "Grip" then
6152 if hide and not ffc(parts[i], "Hide") then
6153 local tag = new("IntValue", parts[i])
6154 tag.Name = "Hide"
6155 else
6156 local tag = ffc(parts[i], "Hide")
6157 if tag then
6158 tag:Destroy()
6159 end
6160 end
6161 parts[i].Transparency = hide and 1 or 0
6162 slottag = ffc(parts[i], "Slot1") or ffc(parts[i], "Slot2")
6163 end
6164 end
6165 return slottag
6166 end
6167 local function texturemodel(wepmodel, attachdata, camodata)
6168 local root = camodata
6169 for i, part in next, wepmodel:GetChildren() do
6170 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6171 part.Anchored = true
6172 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6173 if slottag then
6174 for x, y in next, part:GetChildren() do
6175 if y:IsA("Texture") then
6176 y:Destroy()
6177 end
6178 end
6179 if root and root[slottag.Name] and root[slottag.Name].Name ~= "" then
6180 local t = Instance.new("Texture")
6181 t.Name = slottag.Name
6182 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6183 t.Transparency = part.Transparency >= 0.8 and 1 or root[slottag.Name].TextureProperties.Transparency
6184 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
6185 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
6186 if root[slottag.Name].TextureProperties.Color then
6187 local colordata = root[slottag.Name].TextureProperties.Color
6188 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6189 end
6190 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
6191 local tt = t:Clone()
6192 tt.Face = x
6193 tt.Parent = part
6194 end
6195 t:Destroy()
6196 if not root[slottag.Name].BrickProperties.DefaultColor then
6197 if part:IsA("UnionOperation") then
6198 part.UsePartColor = true
6199 end
6200 if root[slottag.Name].BrickProperties.Color then
6201 local colordata = root[slottag.Name].BrickProperties.Color
6202 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6203 else
6204 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
6205 end
6206 end
6207 if root[slottag.Name].BrickProperties.Material then
6208 part.Material = root[slottag.Name].BrickProperties.Material
6209 end
6210 if root[slottag.Name].BrickProperties.Reflectance then
6211 part.Reflectance = root[slottag.Name].BrickProperties.Reflectance
6212 end
6213 end
6214 end
6215 elseif part:IsA("Model") then
6216 texturemodel(part)
6217 end
6218 end
6219 end
6220 local updategunmeshtype = function(wepmodel, attachdata, camodata)
6221 end
6222 local function updategunattachment(wepmodel, atttype, attachname, wepnodes, preview)
6223 local parts = wepmodel:GetChildren()
6224 local data = require(ffc(gunmodules, wepmodel.Name))
6225 local attachdata = data.attachments[atttype] and data.attachments[atttype][attachname] or {}
6226 local refmodel = attachdata.altmodel and ffc(attmodels, attachdata.altmodel) or ffc(attmodels, attachname)
6227 if not refmodel then
6228 return
6229 end
6230 local model = refmodel:Clone()
6231 local basepart = wfc(model, "Node")
6232 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
6233 local node
6234 model.Name = attachname
6235 if sidemount then
6236 local basenode = sidemount.Node
6237 local mountnode = attachdata.mountnode and wepnodes[attachdata.mountnode] or atttype == "Optics" and wepnodes.MountNode or atttype == "Underbarrel" and wepnodes.UnderMountNode
6238 local mountcframes = {}
6239 local mchildren = sidemount:GetChildren()
6240 local basecframe = basenode.CFrame
6241 for i = 1, #mchildren do
6242 if mchildren[i]:IsA("BasePart") then
6243 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
6244 end
6245 end
6246 basenode.CFrame = mountnode.CFrame
6247 for i = 1, #mchildren do
6248 if mchildren[i]:IsA("BasePart") then
6249 local v = mchildren[i]
6250 v.CFrame = mountnode.CFrame * mountcframes[i]
6251 end
6252 end
6253 node = attachdata.node and wepnodes[attachdata.node] or sidemount[atttype .. "Node"]
6254 sidemount.Parent = model
6255 else
6256 node = attachdata.node and wepnodes[attachdata.node] or wepnodes[atttype .. "Node"]
6257 end
6258 local weldcframes = {}
6259 local children = model:GetChildren()
6260 local basecframe = basepart and basepart.CFrame
6261 local slottag
6262 if atttype == "Optics" or atttype == "Underbarrel" then
6263 slottag = hideparts(wepmodel, atttype, true)
6264 end
6265 for i = 1, #children do
6266 if children[i]:IsA("BasePart") then
6267 weldcframes[i] = tos(basecframe, children[i].CFrame)
6268 end
6269 end
6270 basepart.CFrame = node.CFrame
6271 for i = 1, #children do
6272 if children[i]:IsA("BasePart") then
6273 local v = children[i]
6274 v.CFrame = node.CFrame * weldcframes[i]
6275 if slottag and (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) then
6276 slottag:Clone().Parent = v
6277 end
6278 end
6279 end
6280 model.Parent = wepmodel
6281 end
6282 function getgunmodel(wep, attachdata, camodata)
6283 local findgun = ffc(gunmodels, wep)
6284 print("Finding weapon", wep)
6285 if findgun then
6286 local wepmodel = findgun:Clone()
6287 local nodes = wfc(wepmodel, "MenuNodes")
6288 nodes.Parent = wepmodel
6289 wepmodel.PrimaryPart = wfc(nodes, "MenuNode")
6290 for i, v in next, attachdata, nil do
6291 if v ~= "" then
6292 updategunattachment(wepmodel, i, v, nodes)
6293 end
6294 end
6295 texturemodel(wepmodel, attachdata, camodata)
6296 return wepmodel
6297 else
6298 error("Failed to find weapon model for", wep)
6299 end
6300 end
6301 end
6302 network:add("killed", function(killer, part, deathcf, weapon, weapondisplayname, rank, attachdata, camodata)
6303 char.deadcf = deathcf
6304 if killer == player then
6305 camera:setfixedcam(CFrame.new(deathcf.p, deathcf.p + deathcf.lookVector))
6306 else
6307 do
6308 local gunmodel = getgunmodel(weapon, attachdata, camodata)
6309 gunmodel.Parent = workspace.CurrentCamera
6310 gunmodel:SetPrimaryPartCFrame(deathcf * CFrame.Angles(0, math.rad(90), 0) + Vector3.new(0, 1, 0))
6311 local newbar = killbar:Clone()
6312 newbar.Killer.Label.Text = killer.Name
6313 newbar.Weapon.Label.Text = weapondisplayname
6314 newbar.Parent = maingui
6315 newbar.Rank.Label.Text = rank
6316 local wepnote = misc.WepNote:Clone()
6317 wepnote.Parent = gunmodel
6318 for i, v in next, newbar.Attachments:GetChildren() do
6319 v.Type.Text = "None"
6320 end
6321 if attachdata then
6322 for i, v in next, attachdata, nil do
6323 if i ~= "Name" and v ~= "" then
6324 newbar.Attachments[i].Type.Text = v
6325 end
6326 end
6327 end
6328 camera:setspectate(killer, part)
6329 delay(5, function()
6330 gunmodel:Destroy()
6331 end)
6332 end
6333 end
6334 end)
6335 network:add("unlockedattach", unlockedattach)
6336 network:add("rankup", rankup)
6337 network:add("bigaward", function(type, victim, weapon, pt, extradata)
6338 bigaward(type, victim, weapon, pt, extradata)
6339 end)
6340 network:add("smallaward", function(type, pt)
6341 smallaward(type, pt)
6342 end)
6343 function notify.step()
6344 if char.health <= 0 then
6345 local bar = ffc(maingui, "KillBar")
6346 if bar then
6347 local enemy = ffc(game:GetService("Players"), bar.Killer.Label.Text)
6348 if enemy then
6349 local health = hud:getplayerhealth(enemy)
6350 bar.Health.Label.Text = ceil(health)
6351 bar.Health.Label.TextColor3 = health < 20 and color(1, 0, 0) or health < 50 and color(1, 1, 0) or color(0, 1, 0)
6352 end
6353 end
6354 end
6355 end
6356end
6357print("Loading leaderboard module")
6358do
6359 local wfc = game.WaitForChild
6360 local ffc = game.FindFirstChild
6361 local ud2 = UDim2.new
6362 local ceil = math.ceil
6363 local cf = CFrame.new
6364 local v3 = Vector3.new
6365 local color = Color3.new
6366 local dot = Vector3.new().Dot
6367 local workspace = workspace
6368 local ray = Ray.new
6369 local new = Instance.new
6370 local raycast = workspace.FindPartOnRayWithIgnoreList
6371 local infolder = function(l, e)
6372 for i = 1, #l do
6373 if l[i].Name == e then
6374 return l[i]
6375 end
6376 end
6377 end
6378 local rtype = game.IsA
6379 local debris = game.Debris
6380 local player = game:GetService("Players").LocalPlayer
6381 local playertag = game.ReplicatedStorage.Character.PlayerTag
6382 local pgui = player.PlayerGui
6383 local misc = input.consoleon and game.ReplicatedStorage.XBOX or game.ReplicatedStorage.Misc
6384 local playerstat = misc.Player
6385 local board = wfc(pgui, "Leaderboard")
6386 if input.consoleon then
6387 board:Destroy()
6388 board = misc.Leaderboard:Clone()
6389 board.Parent = pgui
6390 end
6391 local main = wfc(board, "Main")
6392 local global = wfc(board, "Global")
6393 local ghost = wfc(main, "Ghosts")
6394 local phantom = wfc(main, "Phantoms")
6395 local gdataframe = wfc(ghost, "DataFrame")
6396 local pdataframe = wfc(phantom, "DataFrame")
6397 local ghostdata = wfc(gdataframe, "Data")
6398 local phantomdata = wfc(pdataframe, "Data")
6399 local spacing = input.consoleon and 30 or 25
6400 local function organize()
6401 local pp = game:GetService("Players"):GetPlayers()
6402 for i = 1, #pp do
6403 local v = pp[i]
6404 local rightparent = v.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6405 local wrongparent = v.TeamColor ~= game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6406 local right = ffc(rightparent, v.Name)
6407 local wrong = ffc(wrongparent, v.Name)
6408 if not right and wrong then
6409 wrong.Parent = rightparent
6410 end
6411 end
6412 local gd = ghostdata:GetChildren()
6413 table.sort(gd, function(a, b)
6414 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
6415 end)
6416 for i = 1, #gd do
6417 local v = gd[i]
6418 v.Position = ud2(0, 0, 0, i * spacing)
6419 if v.Name == player.Name then
6420 v.Username.TextColor3 = color(1, 1, 0)
6421 end
6422 end
6423 ghostdata.Parent.CanvasSize = ud2(0, 0, 0, (#gd + 1) * spacing)
6424 local pd = phantomdata:GetChildren()
6425 table.sort(pd, function(a, b)
6426 return tonumber(a.Score.Text) > tonumber(b.Score.Text)
6427 end)
6428 for i = 1, #pd do
6429 local v = pd[i]
6430 v.Position = ud2(0, 0, 0, i * spacing)
6431 if v.Name == player.Name then
6432 v.Username.TextColor3 = color(1, 1, 0)
6433 end
6434 end
6435 phantomdata.Parent.CanvasSize = ud2(0, 0, 0, (#pd + 1) * spacing)
6436 end
6437 local function addplayer(guy)
6438 local gbar = ffc(ghostdata, guy.Name)
6439 local pbar = ffc(phantomdata, guy.Name)
6440 if gbar or pbar then
6441 return
6442 end
6443 local bar = playerstat:Clone()
6444 bar.Name = guy.Name
6445 bar.Username.Text = guy.Name
6446 bar.Kills.Text = 0
6447 bar.Deaths.Text = 0
6448 bar.Streak.Text = 0
6449 bar.Score.Text = 0
6450 bar.Kdr.Text = 0
6451 bar.Rank.Text = 0
6452 if guy == player then
6453 bar.Username.TextColor3 = color(1, 1, 0)
6454 end
6455 bar.Parent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6456 organize()
6457 end
6458 local function removeplayer(guy)
6459 local gbar = ffc(ghostdata, guy.Name)
6460 local pbar = ffc(phantomdata, guy.Name)
6461 if gbar then
6462 trash.remove(gbar)
6463 end
6464 if pbar then
6465 trash.remove(pbar)
6466 end
6467 organize()
6468 end
6469 local function updatestats(guy, data)
6470 local rightparent = guy.TeamColor == game.Teams.Ghosts.TeamColor and ghostdata or phantomdata
6471 local bar = ffc(rightparent, guy.Name)
6472 if not bar then
6473 organize()
6474 bar = ffc(rightparent, guy.Name)
6475 end
6476 if bar then
6477 for i, v in next, data, nil do
6478 bar[i].Text = v
6479 end
6480 end
6481 organize()
6482 end
6483 function leaderboard:show()
6484 main.Visible = true
6485 end
6486 function leaderboard:hide()
6487 main.Visible = false
6488 end
6489 network:add("removeplayer", removeplayer)
6490 network:add("newplayer", addplayer)
6491 network:add("updatestats", updatestats)
6492 organize()
6493 game:GetService("UserInputService").InputBegan:connect(function(keycode)
6494 local key = keycode.KeyCode
6495 if key == Enum.KeyCode.Tab and not input.iskeydown(Enum.KeyCode.LeftAlt) then
6496 if main.Visible then
6497 leaderboard:hide()
6498 else
6499 organize()
6500 leaderboard:show()
6501 end
6502 end
6503 end)
6504end
6505print("Loading char module")
6506do
6507 local rtype = game.IsA
6508 local next = next
6509 local new = Instance.new
6510 local wfc = game.WaitForChild
6511 local ffc = game.FindFirstChild
6512 local getchildren = game.GetChildren
6513 local workspace = game.Workspace
6514 local cf = CFrame.new
6515 local vtws = CFrame.new().vectorToWorldSpace
6516 local angles = CFrame.Angles
6517 local nc = cf()
6518 local v3 = Vector3.new
6519 local nv = v3()
6520 local ray = Ray.new
6521 local raycast = workspace.FindPartOnRayWithIgnoreList
6522 local debris = game.Debris
6523 local dot = nv.Dot
6524 local ud2 = UDim2.new
6525 local abs = math.abs
6526 local tos = cf().toObjectSpace
6527 local player = game:GetService("Players").LocalPlayer
6528 local pgui = player.PlayerGui
6529 local repstore = game.ReplicatedStorage
6530 local attmodels = repstore.AttachmentModels
6531 local character, humanoid, rootpart, rootjoint
6532 local thread = sequencer.new()
6533 local weapon
6534 local aiming = false
6535 local auto = false
6536 local burst = 0
6537 local reloading = false
6538 local sprinting = false
6539 local animating = false
6540 local stability = 0
6541 local basewalkspeed = 14
6542 local sprintspring = physics.spring.new()
6543 local climbing = physics.spring.new()
6544 local curgunid = 0
6545 local aimspring = physics.spring.new()
6546 local zoommodspring = physics.spring.new(1)
6547 zoommodspring.s = 12
6548 zoommodspring.d = 0.95
6549 local loadedgundata = {}
6550 char.unaimedfov = 80
6551 function char.setunaimedfov(value)
6552 char.unaimedfov = value
6553 end
6554 function char.addgun(gundata)
6555 for i = 1, curgunid do
6556 if loadedgundata[i] == gundata then
6557 warn("Error, tried to add gun twice")
6558 return
6559 end
6560 end
6561 curgunid = curgunid + 1
6562 loadedgundata[curgunid] = gundata
6563 gundata.id = curgunid
6564 return curgunid
6565 end
6566 function char.removegun(gundata)
6567 local found
6568 for i = 1, curgunid do
6569 if loadedgundata[i] == gundata then
6570 found = true
6571 break
6572 end
6573 end
6574 if not found then
6575 warn("Error, tried to remove gun twice")
6576 return
6577 end
6578 local gunid = gundata.id
6579 gundata.id = nil
6580 loadedgundata[gunid] = loadedgundata[curgunid]
6581 loadedgundata[curgunid] = nil
6582 curgunid = curgunid - 1
6583 local replacement = loadedgundata[gunid]
6584 if replacement then
6585 replacement.id = gunid
6586 end
6587 end
6588 function char.unloadguns()
6589 curgunid = 0
6590 loadedgundata = {}
6591 end
6592 local swingspring = physics.spring.new(nv)
6593 local speedspring = physics.spring.new()
6594 local velocityspring = physics.spring.new(nv)
6595 local pronespring = physics.spring.new(0)
6596 local truespeedspring = physics.spring.new(0)
6597 local equipspring = physics.spring.new(1)
6598 local muzzlespring = physics.spring.new(0)
6599 local walkspeedmult = 1
6600 sprintspring.s = 12
6601 sprintspring.d = 0.9
6602 climbing.s = 12
6603 climbing.d = 0.9
6604 aimspring.d = 0.9
6605 swingspring.s = 10
6606 swingspring.d = 0.75
6607 speedspring.s = 16
6608 velocityspring.s = 16
6609 pronespring.s = 8
6610 truespeedspring.s = 8
6611 equipspring.s = 12
6612 equipspring.d = 0.75
6613 local ignore = {
6614 workspace.Ignore,
6615 game.Workspace.CurrentCamera
6616 }
6617 local backwardsmult = 0.8
6618 local bodyforce = new("BodyVelocity")
6619 bodyforce.Name = "\n"
6620 local muzzlelight, walkspeedspring, headheightspring, updatewalkspeed
6621 walkspeedspring = physics.spring.new(basewalkspeed)
6622 walkspeedspring.s = 8
6623 headheightspring = physics.spring.new(1.5)
6624 headheightspring.s = 8
6625 char.acceleration = nv
6626 bodyforce.MaxForce = nv
6627 local jumpallowed
6628 do
6629 local movementmode = "stand"
6630 local down = v3(0, -5, 0)
6631 function updatewalkspeed()
6632 if sprinting then
6633 walkspeedspring.t = 1.4 * walkspeedmult * basewalkspeed
6634 elseif movementmode == "prone" then
6635 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6636 elseif movementmode == "crouch" then
6637 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6638 elseif movementmode == "stand" then
6639 walkspeedspring.t = walkspeedmult * basewalkspeed
6640 end
6641 end
6642 local function setmovementmode(self, mode, dive)
6643 local oldmode = char.movementmode
6644 char.movementmode = mode
6645 movementmode = mode
6646 if mode == "prone" then
6647 if not dive and oldmode ~= mode then
6648 sound.play("stanceProne", 0.15)
6649 end
6650 headheightspring.t = -1.5
6651 pronespring.t = 1
6652 walkspeedspring.t = walkspeedmult * basewalkspeed / 4
6653 hud:setcrossscale(0.5)
6654 stability = 0.25
6655 if dive and sprinting and rootpart.Velocity.y > -5 then
6656 spawn(function()
6657 local lkvector = rootpart.CFrame.lookVector
6658 rootpart.Velocity = lkvector * (50 * loltimescale) + v3(0, 40 * loltimescale, 0)
6659 wait(0.1 / loltimescale)
6660 rootpart.Velocity = lkvector * (60 * loltimescale) + v3(0, 30 * loltimescale, 0)
6661 wait(0.4 / loltimescale)
6662 rootpart.Velocity = lkvector * (20 * loltimescale) + v3(0, -10 * loltimescale, 0)
6663 end)
6664 end
6665 elseif mode == "crouch" then
6666 if not dive and oldmode ~= mode then
6667 sound.play("stanceStandCrouch", 0.15)
6668 end
6669 headheightspring.t = 0
6670 pronespring.t = 0
6671 walkspeedspring.t = walkspeedmult * basewalkspeed / 2
6672 hud:setcrossscale(0.75)
6673 stability = 0.15
6674 if dive and sprinting and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
6675 isSliding = true
6676 sound.play("slideStart", 0.25)
6677 spawn(function()
6678 local lkvector = rootpart.CFrame.lookVector
6679 local released
6680 bodyforce.MaxForce = v3(40000, 10, 40000)
6681 for i = 1, 20 do
6682 if input.keyboard.down.leftshift then
6683 lkvector = rootpart.CFrame.lookVector
6684 end
6685 bodyforce.Velocity = lkvector * (40 * loltimescale - i * 1.5 * loltimescale) + v3(0, 0, 0)
6686 wait(0.03333333333333333 / loltimescale)
6687 end
6688 bodyforce.MaxForce = nv
6689 bodyforce.Velocity = nv
6690 if isSliding then
6691 isSliding = false
6692 sound.play("slideEnd", 0.15)
6693 end
6694 end)
6695 end
6696 elseif mode == "stand" then
6697 if oldmode ~= mode then
6698 sound.play("stanceStandCrouch", 0.15)
6699 end
6700 headheightspring.t = 1.5
6701 pronespring.t = 0
6702 walkspeedspring.t = walkspeedmult * basewalkspeed
6703 hud:setcrossscale(1)
6704 stability = 0
6705 end
6706 network:send("s" .. "t" .. "a" .. "n" .. "c" .. "e", mode)
6707 sprinting = false
6708 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6709 sprintspring.t = 0
6710 end
6711 function char.getstate()
6712 return humanoid:GetState()
6713 end
6714 function char:sprinting()
6715 return sprinting
6716 end
6717 char.setmovementmode = setmovementmode
6718 function char:setbasewalkspeed(newspeed)
6719 basewalkspeed = newspeed
6720 updatewalkspeed()
6721 end
6722 function char:setsprint(on)
6723 if on then
6724 if isSliding then
6725 isSliding = false
6726 sound.play("slideEnd", 0.15)
6727 end
6728 setmovementmode(nil, "stand")
6729 sprinting = true
6730 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6731 auto = false
6732 burst = 0
6733 if weapon and aiming and weapon.type ~= "KNIFE" then
6734 print("un aim herE")
6735 weapon:setaim(false)
6736 end
6737 walkspeedmult = 1
6738 if not reloading and not animating then
6739 sprintspring.t = 1
6740 end
6741 walkspeedspring.t = 1.5 * walkspeedmult * basewalkspeed
6742 elseif sprinting then
6743 sprinting = false
6744 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
6745 sprintspring.t = 0
6746 walkspeedspring.t = walkspeedmult * basewalkspeed
6747 if input.mouse.down.right and weapon and weapon.type ~= "KNIFE" then
6748 weapon:setaim(true)
6749 end
6750 end
6751 end
6752 local function parkour()
6753 if weapon and not reloading and not char.grenadehold then
6754 weapon:playanimation("parkour")
6755 end
6756 sound.play("parkour", 0.25)
6757 bodyforce.MaxForce = nv
6758 local bp = new("BodyPosition")
6759 bp.Name = "\n"
6760 bp.position = rootpart.Position + rootpart.CFrame.lookVector.unit * (char.speed * loltimescale) * 1.5 + v3(0, 10, 0)
6761 bp.maxForce = v3(5000000, 500000, 500000)
6762 bp.P = 4000
6763 bp.Parent = rootpart
6764 debris:AddItem(bp, 0.45)
6765 end
6766 function char:jump(height)
6767 local rootcf = rootpart.CFrame
6768 local isonground = raycast(workspace, ray(rootcf.p, vtws(rootcf, down)), {
6769 workspace.CurrentCamera
6770 })
6771 local v = rootpart.Velocity.y
6772 local j = height and (2 * game.Workspace.Gravity * height) ^ 0.5 or 40
6773 local jumppower
6774 if v < 0 then
6775 jumppower = j
6776 else
6777 jumppower = (v * v + j * j) ^ 0.5
6778 end
6779 if isonground then
6780 if movementmode == "prone" or movementmode == "crouch" then
6781 setmovementmode(nil, "stand")
6782 elseif not aiming then
6783 local r1 = ray(rootpart.CFrame.p + v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 + v3(0, 2, 0))
6784 local h1, e1 = raycast(workspace, r1, {
6785 character,
6786 camera.currentcamera
6787 })
6788 local r2 = ray(rootpart.CFrame.p - v3(0, 1, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1, 0))
6789 local h2, e2 = raycast(workspace, r2, {
6790 character,
6791 camera.currentcamera
6792 })
6793 local r3 = ray(rootpart.CFrame.p - v3(0, 1.5, 0), rootpart.CFrame.lookVector * 25 - v3(0, 1.5, 0))
6794 local h3, e3 = raycast(workspace, r3, {
6795 character,
6796 camera.currentcamera
6797 })
6798 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
6799 parkour()
6800 delay(0.1, function()
6801 end)
6802 else
6803 humanoid.JumpPower = jumppower
6804 jumpallowed = true
6805 humanoid.Jump = true
6806 jumpallowed = false
6807 end
6808 else
6809 humanoid.JumpPower = jumppower
6810 jumpallowed = true
6811 humanoid.Jump = true
6812 jumpallowed = false
6813 end
6814 end
6815 end
6816 end
6817 local equipping = false
6818 local rweld, lweld, larm, rarm, lmodel, rmodel, lmain, rmain
6819 local sin = math.sin
6820 local cos = math.cos
6821 char.grenadehold = false
6822 local function gunbob(a, r)
6823 local a, r = a or 1, r or 1
6824 local d, s, v = char.distance * 6.28318 * 3 / 4, char.speed, -char.velocity
6825 if s < basewalkspeed then
6826 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
6827 return cf(r * cos(d / 8 - 1) * s / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6828 else
6829 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)
6830 return cf(r * cos(d / 8 - 1) * (5 * s - 56) / 196, 1.25 * a * sin(d / 4) * s / 512, 0) * cframe.fromaxisangle(w)
6831 end
6832 end
6833 local function gunsway(a)
6834 local d, s = tick() * 6, 2 * (1.1 - a)
6835 return cf(cos(d / 8) * s / 128, -sin(d / 4) * s / 128, sin(d / 16) * s / 64)
6836 end
6837 function weldattachment(gun, type, attname, menunode, mainpart, attdata, welddata, menunodes)
6838 local refmodel = attdata.altmodel and ffc(attmodels, attdata.altmodel) or ffc(attmodels, attname)
6839 local copies = attdata.copy or 0
6840 local slottag
6841 if refmodel then
6842 for i = 0, copies do
6843 local model = refmodel:Clone()
6844 local attnode = model.Node
6845 local weldcframes = {}
6846 local maincf = attnode.CFrame
6847 local parts = getchildren(model)
6848 for i = 1, #parts do
6849 local v = parts[i]
6850 if v:IsA("BasePart") then
6851 weldcframes[v] = tos(maincf, v.CFrame)
6852 end
6853 end
6854 attnode.CFrame = i == 0 and menunode.CFrame or menunodes[attdata.copynodes[i]].CFrame
6855 if type == "Optics" then
6856 local del = gun:GetChildren()
6857 for i = 1, #del do
6858 if del[i].Name == "Iron" or del[i].Name == "IronGlow" or del[i].Name == "SightMark" and not ffc(del[i], "Stay") then
6859 del[i]:Destroy()
6860 end
6861 end
6862 elseif type == "Underbarrel" then
6863 local del = gun:GetChildren()
6864 for i = 1, #del do
6865 if del[i].Name == "Grip" then
6866 slottag = ffc(del[i], "Slot1") or ffc(del[i], "Slot2")
6867 del[i]:Destroy()
6868 end
6869 end
6870 end
6871 if attdata.replacemag then
6872 local del = gun:GetChildren()
6873 for x = 1, #del do
6874 if i == 0 and del[x].Name == "Mag" or i > 0 and del[x].Name == "Mag" .. i + 1 then
6875 del[x]:Destroy()
6876 end
6877 end
6878 end
6879 if attdata.replacepart then
6880 local del = gun:GetChildren()
6881 for x = 1, #del do
6882 if del[x].Name == attdata.replacepart then
6883 del[x]:Destroy()
6884 end
6885 end
6886 end
6887 for x = 1, #parts do
6888 local v = parts[x]
6889 if v:IsA("BasePart") then
6890 local weld, c0
6891 if v ~= attnode then
6892 c0 = tos(mainpart.CFrame, attnode.CFrame)
6893 weld = new("Weld", mainpart)
6894 weld.Part0 = mainpart
6895 weld.Part1 = v
6896 weld.C0 = c0 * weldcframes[v]
6897 v.CFrame = mainpart.CFrame * weld.C0
6898 end
6899 if slottag and v:IsA("UnionOperation") then
6900 slottag:Clone().Parent = v
6901 end
6902 if attdata.replacemag and v.Name == "AttMag" then
6903 local magname = i == 0 and "Mag" or i > 0 and "Mag" .. i + 1
6904 v.Name = magname
6905 welddata[magname] = {
6906 part = v,
6907 weld = weld,
6908 basec0 = c0 * weldcframes[v],
6909 basetransparency = v.Transparency
6910 }
6911 end
6912 if attdata.replacepart and v.Name == "Part" then
6913 local pname = attdata.replacepart
6914 v.Name = pname
6915 welddata[pname] = {
6916 part = v,
6917 weld = weld,
6918 basec0 = c0 * weldcframes[v],
6919 basetransparency = v.Transparency
6920 }
6921 end
6922 v.Anchored = false
6923 v.CanCollide = false
6924 v.Parent = gun
6925 end
6926 end
6927 attnode:Destroy()
6928 model:Destroy()
6929 end
6930 end
6931 return slottag
6932 end
6933 local function texturemodel(root, model)
6934 local bcolor = BrickColor.new
6935 for i, part in next, model:GetChildren() do
6936 if ffc(part, "Mesh") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
6937 local slottag = ffc(part, "Slot1") or ffc(part, "Slot2")
6938 if slottag and slottag.Name then
6939 for x, y in next, part:GetChildren() do
6940 if y:IsA("Texture") then
6941 y:Destroy()
6942 end
6943 end
6944 if root[slottag.Name] and root[slottag.Name].Name ~= "" then
6945 if not effects.disable1pcamoskins then
6946 local t = Instance.new("Texture")
6947 t.Name = slottag.Name
6948 t.Texture = "rbxassetid://" .. root[slottag.Name].TextureProperties.TextureId
6949 t.Transparency = part.Transparency == 1 and 1 or root[slottag.Name].TextureProperties.Transparency
6950 t.StudsPerTileU = root[slottag.Name].TextureProperties.StudsPerTileU
6951 t.StudsPerTileV = root[slottag.Name].TextureProperties.StudsPerTileV
6952 if root[slottag.Name].TextureProperties.Color then
6953 local colordata = root[slottag.Name].TextureProperties.Color
6954 t.Color3 = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6955 end
6956 for x = 0, (part:IsA("MeshPart") or part:IsA("UnionOperation")) and 5 or 0 do
6957 local tt = t:Clone()
6958 tt.Face = x
6959 tt.Parent = part
6960 end
6961 t:Destroy()
6962 end
6963 if not root[slottag.Name].BrickProperties.DefaultColor then
6964 if part:IsA("UnionOperation") then
6965 part.UsePartColor = true
6966 end
6967 local colordata = root[slottag.Name].BrickProperties.Color
6968 if colordata then
6969 part.Color = Color3.new(colordata.r / 255, colordata.g / 255, colordata.b / 255)
6970 else
6971 part.BrickColor = bcolor(root[slottag.Name].BrickProperties.BrickColor)
6972 end
6973 end
6974 if root[slottag.Name].BrickProperties.Material then
6975 part.Material = root[slottag.Name].BrickProperties.Material
6976 end
6977 if root[slottag.Name].BrickProperties.Reflectance then
6978 part.Reflectance = root[slottag.Name].BrickProperties.Reflectance
6979 end
6980 end
6981 end
6982 elseif part:IsA("Model") then
6983 texturemodel(root, part)
6984 end
6985 end
6986 end
6987 local tos = CFrame.new().toObjectSpace
6988 local function weldmodel(model, mainpart, attachlist, data, camodata, attachonly)
6989 local welddata = {}
6990 local parts = model:GetChildren()
6991 local maincf = mainpart.CFrame
6992 local menunodes = ffc(model, "MenuNodes")
6993 if not attachonly then
6994 for i = 1, #parts do
6995 local part = parts[i]
6996 if part ~= mainpart and part:IsA("BasePart") then
6997 local name = part.Name
6998 if data and data.transparencymod and data.transparencymod[name] then
6999 part.Transparency = data.transparencymod[name]
7000 end
7001 if data and data.weldexception and data.weldexception[name] and ffc(model, data.weldexception[name]) then
7002 local nbase = model[data.weldexception[name]]
7003 local nmaincf = nbase.CFrame
7004 local c0 = tos(nmaincf, part.CFrame)
7005 local weld = new("Weld", mainpart)
7006 weld.Part0 = nbase
7007 weld.Part1 = part
7008 weld.C0 = c0
7009 part.CFrame = maincf * c0
7010 welddata[name] = {
7011 part = part,
7012 weld = weld,
7013 basec0 = c0,
7014 basetransparency = part.Transparency
7015 }
7016 else
7017 local c0 = tos(maincf, part.CFrame)
7018 local weld = new("Weld", mainpart)
7019 weld.Part0 = mainpart
7020 weld.Part1 = part
7021 weld.C0 = c0
7022 part.CFrame = maincf * c0
7023 welddata[name] = {
7024 part = part,
7025 weld = weld,
7026 basec0 = c0,
7027 basetransparency = part.Transparency
7028 }
7029 end
7030 part.Anchored = false
7031 part.CanCollide = false
7032 end
7033 end
7034 end
7035 if menunodes and #menunodes:GetChildren() > 1 then
7036 local nodes = menunodes:GetChildren()
7037 for i = 1, #nodes do
7038 local v = nodes[i]
7039 local c0 = tos(maincf, v.CFrame)
7040 local weld = new("Weld", mainpart)
7041 weld.Part0 = mainpart
7042 weld.Part1 = v
7043 weld.C0 = c0
7044 v.Anchored = false
7045 v.CanCollide = false
7046 end
7047 for i, v in next, attachlist, nil do
7048 if i ~= "Name" and v and v ~= "" then
7049 local attachdata = data.attachments and data.attachments[i][v] or {}
7050 local sidemount = attachdata.sidemount and attmodels[attachdata.sidemount]:Clone()
7051 local mountweldpart = attachdata.mountweldpart and model[attachdata.mountweldpart] or mainpart
7052 local node = attachdata.node and menunodes[attachdata.node]
7053 if sidemount then
7054 local basenode = sidemount.Node
7055 local mountnode = attachdata.mountnode and menunodes[attachdata.mountnode] or i == "Optics" and menunodes.MountNode or i == "Underbarrel" and menunodes.UnderMountNode
7056 local mountcframes = {}
7057 local mchildren = sidemount:GetChildren()
7058 local basecframe = basenode.CFrame
7059 for i = 1, #mchildren do
7060 if mchildren[i]:IsA("BasePart") then
7061 mountcframes[i] = tos(basecframe, mchildren[i].CFrame)
7062 end
7063 end
7064 basenode.CFrame = mountnode.CFrame
7065 for x = 1, #mchildren do
7066 local p = mchildren[x]
7067 if p:IsA("BasePart") then
7068 local c0 = tos(mountweldpart.CFrame, basenode.CFrame)
7069 if p ~= basenode then
7070 local weld = new("Weld", mainpart)
7071 weld.Part0 = mountweldpart
7072 weld.Part1 = p
7073 weld.C0 = c0 * mountcframes[x]
7074 p.CFrame = basenode.CFrame * mountcframes[x]
7075 end
7076 p.Anchored = false
7077 p.CanCollide = false
7078 p.Parent = model
7079 if p.Name == i .. "Node" and not node then
7080 node = p
7081 elseif p.Name == "SightMark" then
7082 local stay = new("Model", p)
7083 stay.Name = "Stay"
7084 end
7085 end
7086 end
7087 basenode.Parent = menunodes
7088 sidemount:Destroy()
7089 else
7090 node = attachdata.node and menunodes[attachdata.node] or menunodes[i .. "Node"]
7091 end
7092 local weldpart = attachdata.weldpart and model[attachdata.weldpart] or mainpart
7093 weldattachment(model, i, v, node, weldpart, attachdata, welddata, menunodes)
7094 end
7095 end
7096 menunodes:Destroy()
7097 end
7098 if not attachonly then
7099 texturemodel(camodata, model)
7100 welddata.camodata = camodata
7101 mainpart.Anchored = false
7102 mainpart.CanCollide = false
7103 end
7104 return welddata
7105 end
7106 local clone = game.Clone
7107 local currentcamera = game.Workspace.CurrentCamera
7108 local ffc = game.FindFirstChild
7109 function char:loadarms(newlarm, newrarm, newlmain, newrmain)
7110 currentcamera = game.Workspace.CurrentCamera
7111 if larm and rarm then
7112 larm:Destroy()
7113 rarm:Destroy()
7114 end
7115 larm, rarm, lmain, rmain = newlarm, newrarm, newlmain, newrmain
7116 lmodel = clone(larm, weapon and currentcamera)
7117 rmodel = clone(rarm, weapon and currentcamera)
7118 local lmainpart = lmodel[newlmain]
7119 local rmainpart = rmodel[newrmain]
7120 rweld = new("Motor6D")
7121 lweld = new("Motor6D")
7122 weldmodel(lmodel, lmainpart)
7123 weldmodel(rmodel, rmainpart)
7124 lweld.Part0 = rootpart
7125 lweld.Part1 = lmainpart
7126 lweld.Parent = lmainpart
7127 rweld.Part0 = rootpart
7128 rweld.Part1 = rmainpart
7129 rweld.Parent = rmainpart
7130 end
7131 function char:reloadsprings()
7132 sprintspring = physics.spring.new()
7133 aimspring = physics.spring.new()
7134 swingspring = physics.spring.new(nv)
7135 speedspring = physics.spring.new()
7136 velocityspring = physics.spring.new(nv)
7137 pronespring = physics.spring.new(0)
7138 truespeedspring = physics.spring.new(0)
7139 equipspring = physics.spring.new(1)
7140 muzzlespring = physics.spring.new(0)
7141 equipspring.s = 12
7142 equipspring.d = 0.75
7143 sprintspring.s = 12
7144 sprintspring.d = 0.9
7145 aimspring.d = 0.9
7146 swingspring.s = 10
7147 swingspring.d = 0.75
7148 speedspring.s = 16
7149 velocityspring.s = 16
7150 pronespring.s = 8
7151 truespeedspring.s = 8
7152 muzzlespring.s = 50
7153 muzzlespring.d = 1
7154 walkspeedspring = physics.spring.new(basewalkspeed)
7155 walkspeedspring.s = 8
7156 headheightspring = physics.spring.new(1.5)
7157 headheightspring.s = 8
7158 if muzzlelight then
7159 muzzlelight:Destroy()
7160 end
7161 muzzlelight = repstore.Effects.MuzzleLight:Clone()
7162 muzzlelight.Parent = rootpart
7163 end
7164 aimbotshit = {}
7165 do
7166 local rand = math.random
7167 local ffc = game.FindFirstChild
7168 local function pickv3(v0, v1)
7169 return v0 + v3(rand(), rand(), rand()) * (v1 - v0)
7170 end
7171 function char:firemuzzlelight()
7172 muzzlespring:accelerate(100)
7173 end
7174 function char:loadgrenade(data, model, spare)
7175 local self = {}
7176 local thread2 = sequencer.new()
7177 local ignorelist = {character}
7178 for i = 1, #ignore do
7179 local obj = ignore[i]
7180 ignorelist[#ignorelist + 1] = obj
7181 end
7182 local dunhit = {}
7183 local main = data.mainpart
7184 local mainoffset = data.mainoffset
7185 local mainpart = model[main]
7186 local pin = model[data.pin]
7187 local lever = model[data.lever]
7188 local ammo = spare or data.spare
7189 local lastweapon = weapon
7190 local equipped = false
7191 local throwing = false
7192 local cooking = false
7193 local exploded = false
7194 local bounceelasticity = 0.2
7195 local frictionconstant = 0.08
7196 local acceleration = v3(0, -80, 0)
7197 local velocity = v3()
7198 local position = v3()
7199 local cooktime = 0
7200 local blowup = 0
7201 local t0 = 0
7202 local lastbounce = false
7203 local lasttrailt = 0
7204 local lasttrailpos = v3()
7205 local rot0
7206 local offset = v3()
7207 local av0, flyingnade, indicator
7208 local fusetime = data.fusetime
7209 local blastradius = data.blastradius
7210 local throwspeed = data.throwspeed
7211 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7212 local animdata = weldmodel(model, mainpart)
7213 local mainweld = new("Motor6D", mainpart)
7214 animdata[main] = {
7215 weld = {C0 = nc},
7216 basec0 = nc
7217 }
7218 animdata.larm = {
7219 weld = {
7220 C0 = data.larmoffset
7221 },
7222 basec0 = data.larmoffset
7223 }
7224 animdata.rarm = {
7225 weld = {
7226 C0 = data.rarmoffset
7227 },
7228 basec0 = data.rarmoffset
7229 }
7230 mainweld.Part0 = rootpart
7231 mainweld.Part1 = mainpart
7232 local equipcf = data.equipoffset
7233 local sprintcf = cframe.interpolator(data.sprintoffset)
7234 local pronecf = cframe.interpolator(data.proneoffset)
7235 self.type = data.type
7236 self.cooking = cooking
7237 function self:setequipped(on)
7238 if on and (not equipped or not equipping) then
7239 if char.health <= 0 then
7240 return
7241 end
7242 char.grenadehold = true
7243 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, main)
7244 hud:updatefiremode("KNIFE")
7245 hud:updateammo("GRENADE")
7246 equipping = true
7247 thread:clear()
7248 if weapon then
7249 lastweapon = weapon
7250 weapon:setequipped(false)
7251 end
7252 thread:add(function()
7253 char:setbasewalkspeed(data.walkspeed)
7254 equipspring.t = 0
7255 equipping = false
7256 equipped = true
7257 local shit = mainpart:GetChildren()
7258 for i = 1, #shit do
7259 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
7260 shit[i]:Destroy()
7261 end
7262 end
7263 lmodel.Parent = currentcamera
7264 rmodel.Parent = currentcamera
7265 model.Parent = currentcamera
7266 weapon = self
7267 end)
7268 elseif not on and equipped then
7269 equipspring.t = 1
7270 thread:clear()
7271 thread:add(function()
7272 equipped = false
7273 lmodel.Parent = nil
7274 rmodel.Parent = nil
7275 model.Parent = nil
7276 animating = false
7277 weapon = nil
7278 end)
7279 thread:delay(0.5)
7280 end
7281 end
7282 local grenadeanim
7283 local castresolution = 0.016666666666666666
7284 local function createnade(deaddrop)
7285 if not deaddrop and roundsystem.lock then
7286 return
7287 end
7288 if not mainpart.Parent or gamelogic.gammo <= 0 then
7289 return
7290 end
7291 gamelogic.gammo = gamelogic.gammo - 1
7292 hud:updateammo("GRENADE")
7293 local time = tick()
7294 trash.remove(mainweld)
7295 flyingnade = mainpart
7296 flyingnade.Parent = workspace.Ignore
7297 flyingnade.Anchored = true
7298 indicator = ffc(flyingnade, "Indicator")
7299 if indicator then
7300 indicator.Friendly.Visible = true
7301 end
7302 flyingnade.Trail.Enabled = true
7303 model.Parent = nil
7304 local aimcf = camera.cframe * angles(math.rad(data.throwangle or 0), 0, 0)
7305 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))
7306 position = char.deadcf and char.deadcf.p or flyingnade.CFrame.p
7307 lasttrailt = time
7308 lasttrailpos = position
7309 t0 = time
7310 av0 = (camera.cframe - camera.cframe.p) * v3(19.539, -5, 0)
7311 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
7312 local dt = castresolution
7313 local nadecf = flyingnade.CFrame
7314 grenadeanim = {
7315 curi = 1,
7316 time = time,
7317 blowuptime = blowup - time,
7318 frames = {
7319 {
7320 t0 = 0,
7321 p0 = position,
7322 v0 = velocity,
7323 offset = nv,
7324 a = acceleration,
7325 rot0 = nadecf - nadecf.p,
7326 rotv = av0,
7327 glassbreaks = {}
7328 }
7329 }
7330 }
7331 for i = 1, (blowup - time) / dt + 1 do
7332 local newposition = position + dt * velocity + dt * dt / 2 * acceleration
7333 local newvelocity = velocity + dt * acceleration
7334 local hit, pos, norm = raycast(workspace, ray(position, newposition - position - 0.05 * offset), ignorelist)
7335 local t = dt * i
7336 if hit and hit.Name ~= "Window" and hit.Name ~= "Col" then
7337 rot0 = flyingnade.CFrame - flyingnade.CFrame.p
7338 offset = 0.2 * norm
7339 av0 = norm:Cross(velocity) / 0.2
7340 local delta = pos - position
7341 local fixpls = 1 - 0.001 / delta.magnitude
7342 fixpls = fixpls < 0 and 0 or fixpls
7343 position = position + fixpls * delta + 0.05 * norm
7344 local normvel = dot(norm, velocity) * norm
7345 local tanvel = velocity - normvel
7346 local geometricdeceleration
7347 local d1 = -dot(norm, acceleration)
7348 local d2 = -(1 + bounceelasticity) * dot(norm, velocity)
7349 geometricdeceleration = 1 - frictionconstant * (10 * (d1 < 0 and 0 or d1) * dt + (d2 < 0 and 0 or d2)) / tanvel.magnitude
7350 geometricdeceleration = geometricdeceleration < 0 and 0 or geometricdeceleration
7351 velocity = geometricdeceleration * tanvel - bounceelasticity * normvel
7352 if 1 > velocity.magnitude then
7353 local frames = grenadeanim.frames
7354 frames[#frames + 1] = {
7355 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
7356 p0 = position,
7357 v0 = nv,
7358 a = nv,
7359 rot0 = cframe.fromaxisangle(t * av0) * rot0,
7360 offset = 0.2 * norm,
7361 rotv = nv,
7362 glassbreaks = {}
7363 }
7364 break
7365 end
7366 local frames = grenadeanim.frames
7367 local nexti = #frames + 1
7368 frames[#frames + 1] = {
7369 t0 = t - dt * (newposition - pos).magnitude / (newposition - position).magnitude,
7370 p0 = position,
7371 v0 = velocity,
7372 a = lastbounce and nv or acceleration,
7373 rot0 = cframe.fromaxisangle(t * av0) * rot0,
7374 offset = 0.2 * norm,
7375 rotv = av0,
7376 glassbreaks = {}
7377 }
7378 lastbounce = true
7379 else
7380 position = newposition
7381 velocity = newvelocity
7382 lastbounce = false
7383 if hit and hit.Name == "Window" then
7384 local frames = grenadeanim.frames
7385 local glassbreaks = frames[#frames].glassbreaks
7386 glassbreaks[#glassbreaks + 1] = {t = t, part = hit}
7387 end
7388 end
7389 end
7390 network:send("n" .. "e" .. "w" .. "g" .. "r" .. "e" .. "n" .. "a" .. "d" .. "e", data.name, grenadeanim)
7391 end
7392 function self:throw()
7393 if roundsystem.lock or gamelogic.gammo <= 0 then
7394 return
7395 end
7396 if cooking and not throwing then
7397 local time = tick()
7398 throwing = true
7399 cooking = false
7400 self.cooking = cooking
7401 exploded = false
7402 sprintspring.t = 0
7403 thread:add(animation.player(animdata, data.animations.throw))
7404 thread2:delay(0.07)
7405 thread2:add(function()
7406 createnade()
7407 if sprinting then
7408 sprintspring.t = 1
7409 end
7410 throwing = false
7411 end)
7412 thread:add(function()
7413 if lastweapon then
7414 lastweapon:setequipped(true)
7415 end
7416 end)
7417 end
7418 end
7419 function self:pull()
7420 local time = tick()
7421 if not cooking and not throwing then
7422 if animating then
7423 thread:add(animation.reset(animdata, 0.1))
7424 animating = false
7425 end
7426 thread:add(animation.player(animdata, data.animations.pull))
7427 thread:add(function()
7428 hud.crossspring:accelerate(data.crossexpansion)
7429 trash.remove(pin)
7430 cooking = true
7431 self.cooking = cooking
7432 cooktime = time + fusetime
7433 blowup = time + 5
7434 end)
7435 end
7436 end
7437 local function hitdetection(hit, dist, position)
7438 if hit.Parent then
7439 if ffc(game:GetService("Players"), hit.Parent.Name) and not dunhit[hit.Parent] and ffc(game:GetService("Players"), hit.Parent.Name) then
7440 local p = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
7441 if p.TeamColor ~= player.TeamColor or p == player then
7442 local wall, pos = raycast(workspace, ray(hit.Position, (hit.Position - position).unit * -dist), ignorelist)
7443 if not wall then
7444 local damage = dist < r0 and d0 or dist < r1 and (d1 - d0) / (r1 - r0) * (dist - r0) + d0 or d1
7445 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, damage, (hit.Position - position).unit * 50)
7446 if p == player then
7447 p = nil
7448 end
7449 dunhit[hit.Parent] = true
7450 hud:firehitmarker(hit.Name == "Head")
7451 end
7452 end
7453 elseif hit.Parent.Name == "Dead" then
7454 effects:bloodhit(position, hit, hit.Position, hit.CFrame.lookVector, true, 100, (hit.Position - position).unit * 50)
7455 end
7456 end
7457 end
7458 local function explode(position)
7459 local player = game:GetService("Players").LocalPlayer
7460 local range = player:DistanceFromCharacter(position)
7461 if ffc(flyingnade, "Fire") then
7462 if range <= 50 then
7463 sound.play("fragClose", 2, 1, flyingnade, true)
7464 elseif range <= 200 then
7465 sound.play("fragMed", 3, 1, flyingnade, true)
7466 elseif range > 200 then
7467 sound.play("fragFar", 3, 1, flyingnade, true)
7468 end
7469 end
7470 exploded = true
7471 dunhit = {}
7472 if data.grenadetype == "Frag" then
7473 local boom = new("Explosion", workspace)
7474 boom.Position = position
7475 boom.BlastRadius = blastradius
7476 boom.BlastPressure = 0
7477 boom.DestroyJointRadiusPercent = 0
7478 boom.Hit:connect(function(hit, dist)
7479 hitdetection(hit, dist, position)
7480 end)
7481 elseif data.grenadetype == "Smoke" then
7482 elseif data.grenadetype == "Flash" then
7483 elseif data.grenadetype == "Flare" then
7484 elseif data.grenadetype == "Throwing" then
7485 end
7486 trash.remove(flyingnade)
7487 end
7488 local lasttime = tick()
7489 local lastparticle = tick()
7490 local disconnect
7491 disconnect = run.onstep:connect(function(dt)
7492 thread2.step()
7493 local time = tick()
7494 if cooking and not throwing then
7495 if char.health <= 0 then
7496 cooking = false
7497 self.cooking = cooking
7498 throwing = true
7499 exploded = false
7500 print("nou")
7501 createnade(true)
7502 throwing = false
7503 self:setequipped(false)
7504 elseif time > cooktime or not input.keyboard.down.g then
7505 self:throw()
7506 elseif dt > (cooktime - time) % 1 then
7507 hud.crossspring:accelerate(data.crossexpansion)
7508 end
7509 end
7510 if flyingnade and grenadeanim then
7511 local st = grenadeanim.time
7512 local i = grenadeanim.curi
7513 local frames = grenadeanim.frames
7514 local frame = frames[i]
7515 local glassbreaks = frame.glassbreaks
7516 for j = 1, #glassbreaks do
7517 local glassbreak = glassbreaks[j]
7518 if lasttime < st + glassbreak.t and time >= st + glassbreak.t then
7519 effects:breakwindow(glassbreak.part, nil, nil, v3(), true, true)
7520 end
7521 end
7522 local nextframe = frames[i + 1]
7523 if nextframe and time > grenadeanim.time + nextframe.t0 then
7524 grenadeanim.curi = i + 1
7525 frame = nextframe
7526 end
7527 local t = time - (st + frame.t0)
7528 local pos = frame.p0 + t * frame.v0 + t * t / 2 * frame.a + frame.offset
7529 local rot = cframe.fromaxisangle(t * frame.rotv) * frame.rot0
7530 flyingnade.CFrame = rot + pos
7531 if indicator then
7532 indicator.Enabled = not raycast(workspace, ray(pos, camera.cframe.p - pos), ignorelist)
7533 end
7534 if time > st + grenadeanim.blowuptime then
7535 explode(pos)
7536 disconnect()
7537 end
7538 end
7539 lasttime = time
7540 end)
7541 function self.step()
7542 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)
7543 mainweld.C0 = mainweldc0
7544 lweld.C0 = mainweldc0 * animdata.larm.weld.C0
7545 rweld.C0 = mainweldc0 * animdata.rarm.weld.C0
7546 end
7547 return self
7548 end
7549 function char:loadknife(data, model, camodata)
7550 local self = {}
7551 self.name = data.name
7552 self.type = data.type
7553 self.camodata = camodata
7554 local thread2 = sequencer.new()
7555 local ignorelist = {
7556 camera.currentcamera,
7557 character,
7558 workspace.Ignore
7559 }
7560 local dunhit = {}
7561 local main = data.mainpart
7562 local mainoffset = data.mainoffset
7563 local mainpart = model[main]
7564 local tip = model[data.tip]
7565 local blade = model[data.blade]
7566 local equipped = false
7567 local knifing = false
7568 local hitontick = 0
7569 local nexthit = 0
7570 local stabrate = 1000
7571 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7572 local knifepart = mainpart:Clone()
7573 knifepart.Parent = model
7574 knifepart.Name = "Handle"
7575 local animdata = {}
7576 do
7577 local knifecf = knifepart.CFrame
7578 local kparts = model:GetChildren()
7579 local menunodes = ffc(model, "MenuNodes")
7580 for i = 1, #kparts do
7581 local part = kparts[i]
7582 if part:IsA("BasePart") then
7583 if part ~= knifepart and part ~= mainpart then
7584 local c0 = tos(knifecf, part.CFrame)
7585 local weld = new("Weld", knifepart)
7586 weld.Part0 = knifepart
7587 weld.Part1 = part
7588 weld.C0 = c0
7589 animdata[part.Name] = {
7590 part = part,
7591 weld = weld,
7592 basec0 = c0,
7593 basetransparency = part.Transparency
7594 }
7595 end
7596 part.Anchored = false
7597 part.CanCollide = false
7598 end
7599 end
7600 texturemodel(camodata, model)
7601 if menunodes then
7602 menunodes:Destroy()
7603 end
7604 end
7605 local knifeweld = new("Motor6D", knifepart)
7606 knifeweld.Part0 = rmodel.Arm
7607 knifeweld.Part1 = knifepart
7608 local mainweld = new("Motor6D", mainpart)
7609 animdata[main] = {
7610 weld = {C0 = nc},
7611 basec0 = nc
7612 }
7613 animdata.larm = {
7614 weld = {
7615 C0 = data.larmoffset
7616 },
7617 basec0 = data.larmoffset
7618 }
7619 animdata.rarm = {
7620 weld = {
7621 C0 = data.rarmoffset
7622 },
7623 basec0 = data.rarmoffset
7624 }
7625 animdata.knife = {
7626 weld = {
7627 C0 = data.knifeoffset
7628 },
7629 basec0 = data.knifeoffset
7630 }
7631 mainweld.Part0 = rootpart
7632 mainweld.Part1 = mainpart
7633 local equipcf = data.equipoffset
7634 local sprintcf = cframe.interpolator(data.sprintoffset)
7635 local pronecf = cframe.interpolator(data.proneoffset)
7636 local inspecting
7637 function self:destroy()
7638 model:Destroy()
7639 end
7640 function self:setequipped(on, quick, dead)
7641 if dead then
7642 model:Destroy()
7643 end
7644 if on and (not equipped or not equipping) then
7645 if char.health <= 0 then
7646 return
7647 end
7648 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, main)
7649 hud:updatefiremode("KNIFE")
7650 hud:updateammo("KNIFE")
7651 sound.play("equipCloth", 0.25)
7652 sound.play(data.soundClassification .. "Equip", 0.25)
7653 equipping = true
7654 inspecting = false
7655 thread:clear()
7656 if weapon then
7657 weapon:setequipped(false)
7658 end
7659 thread:add(function()
7660 char:setbasewalkspeed(data.walkspeed)
7661 sprintspring.s = data.sprintspeed
7662 hud:setcrosssize(data.crosssize)
7663 if model then
7664 pcall(function()
7665 lmodel.Parent = currentcamera
7666 rmodel.Parent = currentcamera
7667 model.Parent = currentcamera
7668 if data.soundClassification == "saber" then
7669 sound.play("saberLoop", 0.25, 1, model, false, true)
7670 end
7671 end)
7672 end
7673 equipspring.s = quick and 32 or 16
7674 equipspring.t = 0
7675 equipped = true
7676 weapon = self
7677 equipping = false
7678 sound.play("equipCloth", 0.25)
7679 network:send("e" .. "q" .. "u" .. "i" .. "p", 3)
7680 knifing = false
7681 char.grenadehold = false
7682 if sprinting then
7683 sprintspring.t = 1
7684 end
7685 stabrate = quick and 2000 or 1000
7686 end)
7687 if quick then
7688 thread:delay(0.05)
7689 thread:add(function()
7690 self:shoot(quick)
7691 end)
7692 end
7693 elseif not on and equipped then
7694 knifing = false
7695 inspecting = false
7696 equipspring.t = 1
7697 thread:add(animation.reset(animdata, 0.1))
7698 thread:add(function()
7699 equipped = false
7700 model.Parent = nil
7701 if model:FindFirstChild("Sound") then
7702 model.Sound:Destroy()
7703 end
7704 lmodel.Parent = nil
7705 rmodel.Parent = nil
7706 animating = false
7707 weapon = nil
7708 end)
7709 end
7710 end
7711 function self:inspecting()
7712 return inspecting
7713 end
7714 function self:playanimation(type)
7715 if not knifing and not equipping then
7716 thread:clear()
7717 if animating then
7718 thread:add(animation.reset(animdata, 0.05))
7719 end
7720 animating = true
7721 sprintspring.t = 0
7722 do
7723 local acceptlist = {}
7724 if type == "inspect" then
7725 inspecting = true
7726 elseif type == "spot" then
7727 end
7728 thread:add(animation.player(animdata, data.animations[type]))
7729 thread:add(function()
7730 thread:add(animation.reset(animdata, data.animations[type].resettime))
7731 animating = false
7732 thread:add(function()
7733 if sprinting then
7734 sprintspring.t = 1
7735 end
7736 inspecting = false
7737 end)
7738 if #acceptlist > 0 then
7739 end
7740 end)
7741 return #acceptlist > 0
7742 end
7743 end
7744 end
7745 function self:reloadcancel(inspect)
7746 if inspect then
7747 thread:clear()
7748 thread:add(animation.reset(animdata, 0.2))
7749 reloading = false
7750 animating = false
7751 thread:add(function()
7752 if sprinting then
7753 sprintspring.t = 1
7754 end
7755 end)
7756 end
7757 end
7758 function self:dropguninfo()
7759 return mainpart.Position
7760 end
7761 function self:shoot(quick, stype)
7762 if roundsystem.lock then
7763 return
7764 end
7765 if inspecting then
7766 self:reloadcancel(true)
7767 inspecting = false
7768 end
7769 if not knifing then
7770 do
7771 local springspeed = sprintspring.s
7772 local time = tick()
7773 network:send("s" .. "t" .. "a" .. "b")
7774 nexthit = time < nexthit and nexthit or time
7775 sprintspring.t = 0
7776 sprintspring.s = 50
7777 knifing = true
7778 reloading = true
7779 if animating then
7780 thread:add(animation.reset(animdata, 0.1))
7781 animating = false
7782 end
7783 local stabtype = quick and "quickstab" or stype or "stab1"
7784 sound.play(data.soundClassification, 0.25)
7785 hitontick = tick() + data.hitdelay[stabtype]
7786 dunhit = {}
7787 thread:add(animation.player(animdata, data.animations[stabtype]))
7788 thread:add(function()
7789 thread:add(animation.reset(animdata, data.animations[stabtype].resettime))
7790 end)
7791 if sprinting or stabtype == "quickstab" then
7792 thread:delay(data.animations[stabtype].resettime * 0.75)
7793 thread:add(function()
7794 if sprinting then
7795 sprintspring.t = 1
7796 end
7797 end)
7798 end
7799 thread:add(function()
7800 knifing = false
7801 sprintspring.s = springspeed
7802 reloading = false
7803 end)
7804 end
7805 end
7806 end
7807 local parts = {
7808 "head",
7809 "torso",
7810 "lleg",
7811 "rleg",
7812 "larm",
7813 "rarm"
7814 }
7815 local function knifehitdetection()
7816 local firepos = tip.Position
7817 local firepos2 = blade.Position
7818 local hit, pos, norm, dir
7819 local hitdist = 20
7820 for i, p in next, game:GetService("Players"):GetPlayers() do
7821 if p and p.TeamColor ~= player.TeamColor then
7822 local vchar = p.Character
7823 if vchar and vchar.Parent and not dunhit[vchar] then
7824 local phead = ffc(vchar, "Head")
7825 local ptorso = ffc(vchar, "Torso")
7826 if phead and ptorso then
7827 local tdist = (ptorso.Position - firepos).Magnitude
7828 if tdist < 20 then
7829 local bhit
7830 local bhitdist = 20
7831 local bodyparts = replication.getbodyparts(p)
7832 for i = 1, #parts do
7833 local bodypart = bodyparts[parts[i]]
7834 local newdist = (bodypart.Position - firepos).Magnitude
7835 if hitdist > newdist then
7836 hitdist = newdist
7837 hit = bodypart
7838 end
7839 local newdist2 = (bodypart.Position - firepos2).Magnitude
7840 if bhitdist > newdist2 then
7841 bhitdist = newdist2
7842 bhit = bodypart
7843 end
7844 end
7845 if hitdist > bhitdist then
7846 hitdist = bhitdist
7847 hit = bhit
7848 else
7849 end
7850 if hitdist < 3 then
7851 local scan = ray(camera.cframe.p, hit.Position - camera.cframe.p)
7852 local hit2, pos2, norm2 = raycast(workspace, scan, ignorelist)
7853 if hit2.Parent == hit.Parent and 20 > (pos2 - camera.cframe.p).Magnitude then
7854 local damage = ((dot(ptorso.CFrame.lookVector, (hit.Position - rootpart.Position).unit) * 0.5 + 0.5) * (d1 - d0) + d0) * 0.9
7855 local backstab = damage > 100 and "backstab" or nil
7856 if hit.Name == "Head" then
7857 damage = damage * data.multhead
7858 elseif hit.Name == "Torso" then
7859 damage = damage * data.multtorso
7860 end
7861 network:send("knifehit", p, tick(), mainpart.Position, hit, backstab)
7862 dunhit[vchar] = true
7863 hud:firehitmarker(hit.Name == "Head")
7864 effects:bloodhit(rootpart.Position, hit, pos2, norm2, true, damage, v3(0, -8, 0) + (hit.Position - rootpart.Position).unit * 8)
7865 end
7866 end
7867 end
7868 end
7869 end
7870 end
7871 end
7872 end
7873 function self.step()
7874 local time = tick()
7875 if knifing and time > hitontick then
7876 local scan = ray(tip.CFrame * v3(0, 0, data.range0), tip.CFrame.lookVector * (data.range0 + data.range1))
7877 local hit, pos, norm = raycast(workspace, scan, ignorelist)
7878 if hit then
7879 if hit.Name == "Window" then
7880 effects:breakwindow(hit, pos, norm, v3())
7881 elseif hit.Parent.Name == "Dead" then
7882 effects:bloodhit(rootpart.Position, hit, hit.Position, hit.CFrame.lookVector)
7883 else
7884 effects:bullethit(hit, pos, norm, nil, nil, v3(), true)
7885 end
7886 end
7887 knifehitdetection()
7888 nexthit = nexthit + 60 / stabrate
7889 end
7890 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)
7891 mainweld.C0 = mainweldc0
7892 lweld.C0 = mainweldc0 * cframe.interpolate(animdata.larm.weld.C0, data.larmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
7893 rweld.C0 = mainweldc0 * cframe.interpolate(animdata.rarm.weld.C0, data.rarmsprintoffset, truespeedspring.p / walkspeedspring.p * sprintspring.p)
7894 knifeweld.C0 = animdata.knife.weld.C0
7895 thread2:step()
7896 if 0 >= char.health then
7897 self:setequipped(false)
7898 end
7899 end
7900 return self
7901 end
7902 local modifydata = require(game.ReplicatedStorage:WaitForChild("SharedModules"):WaitForChild("ModifyData"))
7903 function char:loadgun(data, attachinfo, model, sparemag, sparerounds, attachlist, camolist, gunn)
7904 local self = {}
7905 self.attachments = attachlist
7906 self.camodata = camolist
7907 self.texturedata = {}
7908 self.transparencydata = {}
7909 data = modifydata(data, attachinfo, attachlist, {
7910 "Optics",
7911 "Barrel",
7912 "Underbarrel",
7913 "Other"
7914 })
7915 self.data = data
7916 self.type = data.type
7917 self.ammotype = data.ammotype
7918 self.name = data.name
7919 self.magsize = data.magsize
7920 self.sparerounds = data.sparerounds
7921 self.attachdata = attachlist
7922 self.gunnumber = gunn
7923 local thread2 = sequencer.new()
7924 local main = data.mainpart
7925 local mainoffset = data.mainoffset
7926 local mainpart = model[main]
7927 local equipped = false
7928 local yieldtoanimation = false
7929 local animdata = weldmodel(model, mainpart, attachlist, data, camolist)
7930 local firerate = data.variablefirerate and data.firerate[1] or data.firerate
7931 local firemodes = data.firemodes
7932 local firemode = 1
7933 local spare = math.ceil(sparerounds or data.sparerounds)
7934 local chamber = data.chamber
7935 local magsize = data.magsize
7936 local mag = sparemag and sparemag or magsize
7937 local nextshot = 0
7938 local r0, r1, d0, d1 = data.range0, data.range1, data.damage0, data.damage1
7939 char.addgun(self)
7940 function self:remove()
7941 char.removegun(self)
7942 end
7943 local wepmod = require(script.WepScript)
7944 local parts = model:GetChildren()
7945 for i = 1, #parts do
7946 local pt = parts[i]
7947 self.texturedata[pt] = {}
7948 self.transparencydata[pt] = pt.Transparency
7949 local tt = pt:GetChildren()
7950 for x = 1, #tt do
7951 local texture = tt[x]
7952 if texture:IsA("Texture") or texture:IsA("Decal") then
7953 self.texturedata[pt][texture] = {
7954 Transparency = texture.Transparency
7955 }
7956 end
7957 end
7958 if pt.Name == "LaserLight" then
7959 wepmod:addlaser(pt)
7960 end
7961 if pt:IsA("BasePart") then
7962 pt.CastShadow = false
7963 end
7964 end
7965 animdata.camodata = self.texturedata
7966 local firesoundlist = {}
7967 local mainweld = new("Motor6D", mainpart)
7968 animdata[main] = {
7969 weld = {C0 = nc},
7970 basec0 = nc
7971 }
7972 animdata.larm = {
7973 weld = {
7974 C0 = data.larmoffset
7975 },
7976 basec0 = data.larmoffset
7977 }
7978 animdata.rarm = {
7979 weld = {
7980 C0 = data.rarmoffset
7981 },
7982 basec0 = data.rarmoffset
7983 }
7984 local barrel = model[data.barrel]
7985 local sight = model[data.sight]
7986 local altsight = data.altsight and model[data.altsight]
7987 local firesound = barrel.Fire
7988 local hideflash = data.hideflash
7989 local hideminimap = data.hideminimap
7990 local hiderange = data.hiderange or 50
7991 firesound.SoundId = data.firesoundid
7992 firesound.Pitch = data.firepitch
7993 firesound.Volume = data.firevolume
7994 local cf = CFrame.new
7995 local angles = CFrame.Angles
7996 local sprintcf = cframe.interpolator(data.sprintoffset)
7997 local climbcf = cframe.interpolator(data.climboffset or cf(-0.9, -1.48, 0.43) * angles(-0.5, 0.3, 0))
7998 local pronecf = cframe.interpolator(data.proneoffset)
7999 local boltcf = cframe.interpolator(animdata[data.bolt].basec0, animdata[data.bolt].basec0 * data.boltoffset)
8000 local transkickspring = physics.spring.new(nv)
8001 local rotkickspring = physics.spring.new(nv)
8002 local spreadspring = physics.spring.new(nv)
8003 local aimsightdata = {}
8004 self.aimsightdata = aimsightdata
8005 local curaimdata = {}
8006 local inspecting
8007 local firemodestability = 0
8008 local sightmode = 1
8009 local wasblackscoped, blackscoped
8010 local boltopen = false
8011 local bolting = false
8012 local ishidden = false
8013 local chambered = true
8014 local chambertick = 0
8015 local nshots = 0
8016 local function updateaimstatus()
8017 curaimdata = aimsightdata[sightmode]
8018 firerate = curaimdata.variablefirerate and curaimdata.firerate[firemode] or curaimdata.firerate
8019 for i = 1, #aimsightdata do
8020 aimsightdata[i].sightspring.t = aiming and i == sightmode and aimspring.t or 0
8021 aimsightdata[i].sightspring.s = curaimdata.aimspeed
8022 end
8023 walkspeedmult = aiming and curaimdata.aimwalkspeedmult or 1
8024 camera.shakespring.s = aiming and curaimdata.aimcamkickspeed or data.camkickspeed
8025 if curaimdata.blackscope then
8026 hud:setscopesettings(curaimdata)
8027 end
8028 hud:updatesightmark(curaimdata.sightpart, curaimdata.centermark)
8029 updatewalkspeed()
8030 end
8031 do
8032 local defaultsight = {
8033 sight = data.sight,
8034 sightpart = model[data.sight],
8035 aimoffset = cf(),
8036 aimrotkickmin = data.aimrotkickmin,
8037 aimrotkickmax = data.aimrotkickmax,
8038 aimtranskickmin = data.aimtranskickmin * v3(1, 1, 0.5),
8039 aimtranskickmax = data.aimtranskickmax * v3(1, 1, 0.5),
8040 larmaimoffset = data.larmaimoffset,
8041 rarmaimoffset = data.rarmaimoffset,
8042 aimcamkickmin = data.aimcamkickmin,
8043 aimcamkickmax = data.aimcamkickmax,
8044 aimcamkickspeed = data.aimcamkickspeed,
8045 aimspeed = data.aimspeed,
8046 aimwalkspeedmult = data.aimwalkspeedmult,
8047 magnifyspeed = data.magnifyspeed,
8048 zoom = data.zoom,
8049 prezoom = data.prezoom or data.zoom ^ 0.25,
8050 scopebegin = data.scopebegin or 0.9,
8051 firerate = data.firerate,
8052 aimedfirerate = data.aimedfirerate,
8053 variablefirerate = data.variablefirerate,
8054 onfireanim = data.onfireanim or "",
8055 aimreloffset = data.aimreloffset,
8056 aimzdist = data.aimzdist,
8057 aimzoffset = data.aimzoffset,
8058 aimspringcancel = data.aimspringcancel,
8059 sightsize = data.sightsize,
8060 sightr = data.sightr,
8061 nosway = data.nosway,
8062 swayamp = data.swayamp,
8063 swayspeed = data.swayspeed,
8064 steadyspeed = data.steadyspeed,
8065 breathspeed = data.breathspeed,
8066 recoverspeed = data.recoverspeed,
8067 scopeid = data.scopeid,
8068 scopecolor = data.scopecolor,
8069 scopelenscolor = data.lenscolor,
8070 scopelenstrans = data.lenstrans,
8071 scopeimagesize = data.scopeimagesize,
8072 scopesize = data.scopesize,
8073 reddot = data.reddot,
8074 midscope = data.midscope,
8075 blackscope = data.blackscope,
8076 centermark = data.centermark,
8077 pullout = data.pullout,
8078 zoompullout = data.zoompullout
8079 }
8080 local function addnewsight(newsightdata)
8081 local newsight = {}
8082 for i, v in next, defaultsight, nil do
8083 newsight[i] = v
8084 end
8085 for i, v in next, newsightdata, nil do
8086 newsight[i] = v
8087 end
8088 local aimoffset = mainoffset:inverse() * model[newsight.sight].CFrame:inverse() * mainpart.CFrame
8089 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))
8090 aimoffset = aimoffset * (newsight.aimreloffset or cf())
8091 newsight.sightpart = model[newsight.sight]
8092 newsight.aimoffset = aimoffset
8093 newsight.aimoffsetp = aimoffset.p
8094 newsight.aimoffsetr = cframe.toaxisangle(aimoffset)
8095 newsight.larmaimoffsetp = newsight.larmaimoffset.p
8096 newsight.larmaimoffsetr = cframe.toaxisangle(newsight.larmaimoffset)
8097 newsight.rarmaimoffsetp = newsight.rarmaimoffset.p
8098 newsight.rarmaimoffsetr = cframe.toaxisangle(newsight.rarmaimoffset)
8099 local sightspring = physics.spring.new(0)
8100 newsight.sightspring = sightspring
8101 aimsightdata[#aimsightdata + 1] = newsight
8102 end
8103 addnewsight(defaultsight)
8104 local altaimdata = data.altaimdata or {}
8105 for i, v in next, altaimdata, nil do
8106 addnewsight(v)
8107 end
8108 updateaimstatus()
8109 end
8110 local armaimspring = physics.spring.new()
8111 transkickspring.s = data.modelkickspeed
8112 rotkickspring.s = data.modelkickspeed
8113 transkickspring.d = data.modelkickdamper
8114 rotkickspring.d = data.modelkickdamper
8115 spreadspring.s = data.hipfirespreadrecover
8116 spreadspring.d = data.hipfirestability or 0.7
8117 aimspring.d = 0.95
8118 armaimspring.s = 16
8119 armaimspring.d = 0.95
8120 function self:destroy()
8121 wepmod:deactivatelasers("death", model)
8122 wepmod:destroysights("death", model)
8123 model:Destroy()
8124 lmodel:Destroy()
8125 rmodel:Destroy()
8126 end
8127 do
8128 local function updatefiremodestability()
8129 local mode1 = data.fmode1 or 0
8130 local mode2 = data.fmode2 or 0.3
8131 local mode3 = data.fmode3 or 0.2
8132 firemodestability = firemodes[firemode] == 3 and mode3 or firemodes[firemode] == 2 and mode2 or mode1
8133 end
8134 function self:setequipped(on, dead)
8135 function aimbotshit.addammo()
8136 magsize = 2 * magsize
8137 mag = magsize
8138 spare = 1000000
8139 firerate = 1000
8140 end
8141 if dead then
8142 self:hide()
8143 end
8144 if on and (not equipped or not equipping) then
8145 if char.health <= 0 then
8146 return
8147 end
8148 if not menu:isdeployed() then
8149 print("yes")
8150 char:despawn()
8151 return
8152 end
8153 network:send("e" .. "q" .. "u" .. "i" .. "p", self.gunnumber)
8154 hud:setcrosssettings(data.crosssize, data.crossspeed, data.crossdamper, curaimdata.sightpart, curaimdata.centermark)
8155 hud:updatefiremode(firemodes[firemode])
8156 hud:updateammo(mag, spare)
8157 updatefiremodestability()
8158 self:setaim(false)
8159 equipping = true
8160 reloading = false
8161 sound.play("equipCloth", 0.25)
8162 bolting = false
8163 inspecting = false
8164 thread:clear()
8165 if weapon then
8166 weapon:setequipped(false)
8167 end
8168 thread:add(function()
8169 char:setbasewalkspeed(data.walkspeed)
8170 sprintspring.s = data.sprintspeed
8171 camera.magspring.s = data.magnifyspeed
8172 camera.shakespring.s = data.camkickspeed
8173 hud:setcrosssize(data.crosssize)
8174 camera:setswayspeed(curaimdata.swayspeed or 1)
8175 camera.swayspring.s = curaimdata.steadyspeed or 4
8176 camera:setsway(0)
8177 aimspring.s = curaimdata.aimspeed
8178 armaimspring.s = curaimdata.aimspeed
8179 wepmod:activatelasers(false, model)
8180 equipspring.s = data.equipspeed or 12
8181 equipspring.t = 0
8182 local shit = mainpart:GetChildren()
8183 for i = 1, #shit do
8184 if shit[i]:IsA("Weld") and (not shit[i].Part1 or shit[i].Part1.Parent ~= model) then
8185 shit[i]:Destroy()
8186 end
8187 end
8188 if model then
8189 pcall(function()
8190 lmodel.Parent = currentcamera
8191 rmodel.Parent = currentcamera
8192 model.Parent = currentcamera
8193 end)
8194 end
8195 mainweld.Part0 = rootpart
8196 mainweld.Part1 = mainpart
8197 equipped = true
8198 equipping = false
8199 sound.play("equipCloth", 0.25)
8200 sound.play("equipGear", 0.1)
8201 if boltopen then
8202 animdata[data.bolt].weld.C0 = boltcf(1)
8203 end
8204 if not chambered and chambertick > tick() then
8205 self:chambergun()
8206 else
8207 chambered = true
8208 if input.mouse.down.right then
8209 self:setaim(true)
8210 end
8211 if sprinting then
8212 sprintspring.t = 1
8213 end
8214 end
8215 weapon = self
8216 char.grenadehold = false
8217 end)
8218 elseif not on and equipped then
8219 if aiming then
8220 self:setaim(false)
8221 end
8222 auto = false
8223 burst = 0
8224 reloading = false
8225 inspecting = false
8226 equipspring.t = 1
8227 thread:clear()
8228 thread:add(animation.reset(animdata, 0.2))
8229 thread:add(function()
8230 camera:magnify(1)
8231 wepmod:deactivatelasers(dead, model)
8232 wepmod:destroysights(dead, model)
8233 equipped = false
8234 lmodel.Parent = nil
8235 rmodel.Parent = nil
8236 mainweld.Part1 = nil
8237 if dead then
8238 model:Destroy()
8239 else
8240 model.Parent = nil
8241 end
8242 animating = false
8243 yieldtoanimation = false
8244 weapon = nil
8245 end)
8246 end
8247 end
8248 local function texturetransparency(part, trans)
8249 local p = part:GetChildren()
8250 for i = 1, #p do
8251 local v = p[i]
8252 if v:IsA("Texture") or v:IsA("Decal") then
8253 v.Transparency = trans ~= 1 and self.texturedata[part][v].Transparency or 1
8254 elseif v:IsA("SurfaceGui") then
8255 v.Enabled = trans ~= 1
8256 end
8257 end
8258 end
8259 function self:toggleattachment()
8260 sightmode = sightmode % #aimsightdata + 1
8261 updateaimstatus()
8262 if not chambered and wasblackscoped and not curaimdata.blackscope and data.animations.onfire then
8263 self:chambergun()
8264 end
8265 end
8266 function self:hide(scope)
8267 if scope then
8268 if ishidden then
8269 return
8270 end
8271 ishidden = true
8272 local p = model:GetChildren()
8273 for i = 1, #p do
8274 local v = p[i]
8275 if (ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart")) and (not data.invisible or not data.invisible[v.Name]) then
8276 v.Transparency = 1
8277 texturetransparency(v, 1)
8278 end
8279 end
8280 texturetransparency(curaimdata.sightpart, 1)
8281 local p = lmodel:GetChildren()
8282 for i = 1, #p do
8283 local v = p[i]
8284 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8285 v.Transparency = 1
8286 end
8287 end
8288 local p = rmodel:GetChildren()
8289 for i = 1, #p do
8290 local v = p[i]
8291 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8292 v.Transparency = 1
8293 end
8294 end
8295 end
8296 end
8297 function self:inspecting()
8298 return inspecting
8299 end
8300 function self:isblackscope()
8301 return curaimdata.blackscope
8302 end
8303 function self:show(scope)
8304 if not ishidden or blackscoped then
8305 return
8306 end
8307 ishidden = false
8308 local p = model:GetChildren()
8309 for i = 1, #p do
8310 local v = p[i]
8311 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
8312 v.Transparency = self.transparencydata[v]
8313 texturetransparency(v, 0)
8314 end
8315 end
8316 print("show gun scope again")
8317 for i, v in next, aimsightdata, nil do
8318 texturetransparency(v.sightpart, 0)
8319 end
8320 local p = lmodel:GetChildren()
8321 for i = 1, #p do
8322 local v = p[i]
8323 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8324 v.Transparency = 0
8325 end
8326 end
8327 local p = rmodel:GetChildren()
8328 for i = 1, #p do
8329 local v = p[i]
8330 if ffc(v, "Mesh") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("BasePart") then
8331 v.Transparency = 0
8332 end
8333 end
8334 end
8335 function self:updatescope()
8336 if blackscoped and not wasblackscoped then
8337 wasblackscoped = true
8338 self:hide(true)
8339 hud:setscope(true, curaimdata.nosway)
8340 elseif not blackscoped and wasblackscoped then
8341 wasblackscoped = false
8342 self:show()
8343 hud:setscope(false)
8344 end
8345 end
8346 function self:setaim(on, console)
8347 if reloading or not equipped then
8348 return
8349 end
8350 local zoomval = curaimdata.zoom
8351 if on and not bolting then
8352 network:send("a" .. "i" .. "m", true)
8353 aiming = true
8354 sprinting = false
8355 sprintspring.t = 0
8356 network:send("s" .. "p" .. "r" .. "i" .. "n" .. "t", sprinting)
8357 walkspeedmult = curaimdata.aimwalkspeedmult
8358 camera.shakespring.s = curaimdata.aimcamkickspeed
8359 camera:setaimsensitivity(true)
8360 hud:setcrosssize(0)
8361 sound.play("aimGear", 0.15)
8362 aimspring.t = 1
8363 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
8364 armaimspring.t = yieldtoanimation and curaimdata.zoompullout and 0 or 1
8365 updateaimstatus()
8366 elseif not on then
8367 if aiming and curaimdata.blackscope then
8368 thread2:clear()
8369 end
8370 gamelogic.setsprintdisable(false)
8371 aiming = false
8372 sound.play("aimCloth", 0.15)
8373 network:send("a" .. "i" .. "m", false)
8374 hud:setcrosssize(data.crosssize)
8375 camera.shakespring.s = data.camkickspeed
8376 walkspeedmult = 1
8377 camera:setaimsensitivity(false)
8378 aimspring.t = 0
8379 armaimspring.t = 0
8380 updateaimstatus()
8381 thread2:add(function()
8382 if not aiming and mag == 0 and spare > 0 and not reloading then
8383 self:reload()
8384 end
8385 end)
8386 if mag > 0 and not chambered and not bolting and data.animations.onfire and curaimdata.pullout then
8387 animating = true
8388 yieldtoanimation = true
8389 bolting = true
8390 thread:add(animation.player(animdata, data.animations.onfire))
8391 thread:add(function()
8392 chambered = true
8393 thread:add(animation.reset(animdata, data.animations.onfire.resettime, aiming))
8394 thread:add(function()
8395 animating = false
8396 yieldtoanimation = false
8397 bolting = false
8398 if sprinting then
8399 sprintspring.t = 1
8400 end
8401 if input.mouse.down.right then
8402 self:setaim(true)
8403 end
8404 end)
8405 end)
8406 end
8407 if not curaimdata.blackscope then
8408 char:setsprint(not input.keyboard.down.leftshift and input.keyboard.down.w and ffc(pgui, "Doubletap"))
8409 end
8410 end
8411 updatewalkspeed()
8412 end
8413 function self:chambergun()
8414 print("pretend to chamber gun")
8415 if mag > 0 and data.animations.pullbolt then
8416 reloading = true
8417 yieldtoanimation = true
8418 if sprinting then
8419 sprintspring.t = 0
8420 end
8421 thread:add(animation.player(animdata, data.animations.pullbolt))
8422 thread:add(function()
8423 chambered = true
8424 thread:add(animation.reset(animdata, data.animations.pullbolt.resettime, aiming))
8425 thread:add(function()
8426 animating = false
8427 yieldtoanimation = false
8428 reloading = false
8429 if sprinting then
8430 sprintspring.t = 1
8431 end
8432 if input.mouse.down.right then
8433 self:setaim(true)
8434 end
8435 end)
8436 end)
8437 else
8438 chambered = true
8439 end
8440 end
8441 function self:playanimation(type)
8442 if not reloading and not equipping and not yieldtoanimation then
8443 thread:clear()
8444 if animating then
8445 thread:add(animation.reset(animdata, 0.05))
8446 end
8447 if aiming and type ~= "selector" then
8448 self:setaim(false)
8449 end
8450 animating = true
8451 sprintspring.t = 0
8452 local acceptlist = {}
8453 if type == "inspect" then
8454 inspecting = true
8455 end
8456 thread:add(animation.player(animdata, data.animations[type]))
8457 thread:add(function()
8458 thread:add(animation.reset(animdata, data.animations[type].resettime, blackscoped))
8459 thread:add(function()
8460 inspecting = false
8461 if reloading then
8462 return
8463 end
8464 if input.mouse.down.right and not aiming then
8465 self:setaim(true)
8466 end
8467 if sprinting then
8468 sprintspring.t = 1
8469 end
8470 animating = false
8471 end)
8472 if type == "spot" then
8473 end
8474 end)
8475 else
8476 return true
8477 end
8478 end
8479 function self:dropguninfo()
8480 return mag, spare, mainpart.Position
8481 end
8482 function self:addammo(extra, dropgunname)
8483 spare = spare + extra
8484 hud:updateammo(mag, spare)
8485 notify:customaward("Picked up " .. extra .. " rounds from dropped " .. dropgunname)
8486 end
8487 function self:reloadcancel(inspect)
8488 if reloading or inspect then
8489 thread:clear()
8490 thread:add(animation.reset(animdata, 0.2))
8491 reloading = false
8492 animating = false
8493 inspecting = false
8494 if not chambered then
8495 self:chambergun()
8496 else
8497 thread:add(function()
8498 if input.mouse.down.right then
8499 self:setaim(true)
8500 end
8501 if sprinting then
8502 sprintspring.t = 1
8503 end
8504 end)
8505 end
8506 end
8507 end
8508 function self:reload()
8509 if not yieldtoanimation and not equipping and not reloading and spare > 0 and mag ~= (chamber and magsize + 1 or magsize) then
8510 do
8511 local tact
8512 if animating then
8513 thread:clear()
8514 thread2:clear()
8515 thread:add(animation.reset(animdata, 0.2))
8516 end
8517 if aiming then
8518 self:setaim(false)
8519 end
8520 animating = true
8521 reloading = true
8522 sprintspring.t = 0
8523 auto = false
8524 burst = 0
8525 if data.type == "SHOTGUN" and not data.magfeed == true then
8526 local tempammo = spare
8527 tact = true
8528 thread:add(animation.player(animdata, data.animations.tacticalreload))
8529 thread:add(function()
8530 mag = mag + 1
8531 spare = spare - 1
8532 chambered = true
8533 network:send("reload")
8534 hud:updateammo(mag, spare)
8535 end)
8536 tempammo = tempammo - 1
8537 if mag < magsize and spare > 0 and tempammo > 0 then
8538 for i = 2, magsize - mag do
8539 if spare > 0 and tempammo > 0 then
8540 tempammo = tempammo - 1
8541 local reloadanim = data.altreload and data.animations[data.altreload .. "reload"] or data.animations.reload
8542 thread:add(animation.player(animdata, reloadanim))
8543 thread:add(function()
8544 mag = mag + 1
8545 spare = spare - 1
8546 network:send("reload")
8547 hud:updateammo(mag, spare)
8548 end)
8549 end
8550 end
8551 end
8552 if mag == 0 then
8553 thread:add(animation.player(animdata, data.animations.pump))
8554 end
8555 thread:add(function()
8556 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))
8557 thread:add(function()
8558 reloading = false
8559 animating = false
8560 inspecting = false
8561 boltopen = false
8562 chambered = true
8563 if sprinting then
8564 sprintspring.t = 1
8565 end
8566 if input.mouse.down.right then
8567 self:setaim(true)
8568 end
8569 end)
8570 end)
8571 elseif data.animations.uniquereload then
8572 do
8573 local emptyreload = mag == 0
8574 if data.animations.initstage then
8575 thread:add(animation.player(animdata, data.animations.initstage))
8576 elseif emptyreload then
8577 emptyreload = true
8578 if data.animations.initemptystage then
8579 thread:add(animation.player(animdata, data.animations.initemptystage))
8580 end
8581 end
8582 local tempammo = spare
8583 if mag < magsize and spare > 0 and tempammo > 0 then
8584 for i = 1, magsize - mag do
8585 if spare > 0 and tempammo > 0 then
8586 tempammo = tempammo - 1
8587 if data.animations.reloadstage then
8588 thread:add(animation.player(animdata, data.animations.reloadstage))
8589 end
8590 thread:add(function()
8591 mag = mag + 1
8592 spare = spare - 1
8593 network:send("reload")
8594 hud:updateammo(mag, spare)
8595 end)
8596 end
8597 end
8598 end
8599 if emptyreload then
8600 print("empty relaod")
8601 if data.animations.emptyendstage then
8602 thread:add(animation.player(animdata, data.animations.emptyendstage))
8603 end
8604 elseif data.animations.endstage then
8605 thread:add(animation.player(animdata, data.animations.endstage))
8606 end
8607 thread:add(function()
8608 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))
8609 thread:add(function()
8610 reloading = false
8611 animating = false
8612 inspecting = false
8613 boltopen = false
8614 chambered = true
8615 if sprinting then
8616 sprintspring.t = 1
8617 end
8618 if input.mouse.down.right then
8619 self:setaim(true)
8620 end
8621 end)
8622 end)
8623 end
8624 else
8625 do
8626 local reloadanim
8627 if mag == 0 then
8628 reloadanim = data.altreload and data.animations[data.altreload .. "reload"] or data.animations.reload
8629 else
8630 reloadanim = data.altreload and data.animations[data.altreload .. "tacticalreload"] or data.animations.tacticalreload
8631 tact = true
8632 end
8633 thread:add(animation.player(animdata, reloadanim))
8634 thread:add(function()
8635 spare = spare + mag
8636 local wants = not (mag ~= 0 and chamber) and magsize or magsize + 1
8637 mag = wants > spare and spare or wants
8638 spare = spare - mag
8639 boltopen = false
8640 network:send("reload")
8641 hud:updateammo(mag, spare)
8642 thread:add(animation.reset(animdata, reloadanim.resettime or 0.5))
8643 thread:add(function()
8644 reloading = false
8645 animating = false
8646 inspecting = false
8647 chambered = true
8648 if sprinting then
8649 sprintspring.t = 1
8650 end
8651 if input.mouse.down.right then
8652 self:setaim(true)
8653 end
8654 end)
8655 end)
8656 end
8657 end
8658 end
8659 end
8660 end
8661 function self:shoot(on)
8662 if on then
8663 if roundsystem.lock then
8664 return
8665 end
8666 if mag == 0 then
8667 self:reload()
8668 end
8669 if not chambered then
8670 return
8671 end
8672 if reloading and mag > 0 then
8673 self:reloadcancel()
8674 return
8675 end
8676 if not reloading and not equipping then
8677 local arg = firemodes[firemode]
8678 local time = tick()
8679 char:setsprint(false)
8680 if arg == true then
8681 auto = true
8682 elseif burst == 0 and time > nextshot then
8683 burst = arg
8684 end
8685 nextshot = time < nextshot and nextshot or time
8686 end
8687 else
8688 nshots = 0
8689 auto = false
8690 burst = 0
8691 end
8692 end
8693 function self:nextfiremode()
8694 if reloading then
8695 return
8696 end
8697 local zoomval = curaimdata.zoom
8698 if data.animations.selector then
8699 if animating then
8700 thread:clear()
8701 thread:add(animation.reset(animdata, 0.2))
8702 end
8703 animating = true
8704 if aiming and not curaimdata.aimspringcancel then
8705 zoommodspring.t = 0.5
8706 armaimspring.t = 0
8707 updateaimstatus()
8708 end
8709 if sprinting then
8710 sprintspring.t = 0.5
8711 end
8712 yieldtoanimation = true
8713 thread:add(animation.player(animdata, data.animations.selector))
8714 thread:add(function()
8715 thread:add(animation.reset(animdata, data.animations.selector.resettime, blackscoped))
8716 animating = false
8717 inspecting = false
8718 yieldtoanimation = false
8719 if sprinting then
8720 sprintspring.t = 1
8721 end
8722 if aiming then
8723 zoommodspring.t = 1
8724 armaimspring.t = 1
8725 updateaimstatus()
8726 end
8727 end)
8728 end
8729 thread:add(function()
8730 firemode = firemode % #firemodes + 1
8731 hud:updatefiremode(firemodes[firemode])
8732 if curaimdata.variablefirerate then
8733 firerate = curaimdata.firerate[firemode]
8734 end
8735 if auto then
8736 auto = false
8737 end
8738 updatefiremodestability()
8739 return firemodes[firemode]
8740 end)
8741 end
8742 end
8743 local function boltkick(t)
8744 t = t / data.bolttime * 1.5
8745 boltopen = false
8746 if t > 1.5 then
8747 animdata[data.bolt].weld.C0 = boltcf(0)
8748 return nil
8749 elseif t > 0.5 then
8750 t = (t - 0.5) * 0.5 + 0.5
8751 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8752 return false
8753 else
8754 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8755 return false
8756 end
8757 end
8758 local function boltstop(t)
8759 t = t / data.bolttime * 1.5
8760 if t > 0.5 then
8761 animdata[data.bolt].weld.C0 = boltcf(1)
8762 boltopen = true
8763 return true
8764 else
8765 animdata[data.bolt].weld.C0 = boltcf(1 - 4 * (t - 0.5) * (t - 0.5))
8766 boltopen = false
8767 return false
8768 end
8769 end
8770 local function hitdetection(self, hit, pos, norm, exit, exitnorm, firepos, firevel, power, human, shottime, particle)