Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var playerName, playerClassIndex, playerType, healthBarWidth, playerNameInput = document.getElementById("playerNameInput"),
- classInput = document.getElementById("classSelect"),
- socket, reason, animLoopHandle, mobile = !1,
- room, delta = 0,
- horizontalDT = 0,
- verticalDT = 0,
- roomNum = 0,
- currentTime, oldTime = Date.now(),
- FRAME_STEP = 1E3 / 60,
- count = -1,
- clientPrediction = !0,
- inputNumber = 0,
- clientSpeed = 12,
- temp = 1,
- thisInput = [],
- keyd = 1,
- tabbed = 0,
- timeSinceLastUpdate = 0,
- timeOfLastUpdate = 0,
- tiny, port;
- zip.workerScriptsPath = "../js/lib/";
- /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) && (mobile = !0, hideMenuUI(), hideUI(!0), document.getElementById("startMenuWrapper").style.display = "none", document.getElementById("mobileMessage").innerHTML = "Mobile Version Coming Soon.");
- Number.prototype.round = function(a) {
- return +this.toFixed(a)
- };
- var previousClass = 0,
- previousHat = 0,
- previousSpray = 0,
- startingGame = !1,
- changingLobby = !1,
- waitingForLoad = !0;
- function startGame(a) {
- startingGame || changingLobby || waitingForLoad || (startingGame = !0, playerName = playerNameInput.value.replace(/(<([^>]+)>)/ig, "").substring(0, 25), enterGame(a))
- }
- var inMainMenu = !0,
- devTest = !1;
- function enterGame(a) {
- startSoundTrack(2);
- playerClassIndex = currentClassID;
- playerType = a;
- screenWidth = window.innerWidth;
- screenHeight = window.innerHeight;
- document.getElementById("startMenuWrapper").style.display = "none";
- room || socket.emit("create");
- socket.emit("respawn");
- hideMenuUI();
- animateOverlay = !0;
- updateGameLoop()
- }
- function validNick() {
- return null !== /^\w*$/.exec(playerNameInput.value)
- }
- var createClanButton = document.getElementById("createClanButton"),
- joinClanButton = document.getElementById("joinClanButton"),
- clanNameInput = document.getElementById("clanNameInput"),
- clanKeyInput = document.getElementById("clanKeyInput"),
- clanDBMessage = document.getElementById("clanDBMessage"),
- clanStats = document.getElementById("clanStats"),
- clanSignUp = document.getElementById("clanSignUp"),
- clanHeader = document.getElementById("clanHeader"),
- clanAdminPanel = document.getElementById("clanAdminPanel"),
- clanInviteInput =
- document.getElementById("clanInviteInput"),
- inviteClanButton = document.getElementById("inviteClanButton"),
- kickClanButton = document.getElementById("kickClanButton"),
- leaveClanButton = document.getElementById("leaveClanButton"),
- clanInvMessage = document.getElementById("clanInvMessage"),
- loginWrapper = document.getElementById("loginWrapper"),
- loggedInWrapper = document.getElementById("loggedInWrapper"),
- loginButton = document.getElementById("loginButton"),
- registerButton = document.getElementById("registerButton"),
- logoutButton =
- document.getElementById("logoutButton"),
- loginMessage = document.getElementById("loginMessage"),
- recoverButton = document.getElementById("recoverButton"),
- userNameInput = document.getElementById("usernameInput"),
- userEmailInput = document.getElementById("emailInput"),
- userPassInput = document.getElementById("passwordInput"),
- waitingForServer = !1,
- loginUserNm = "",
- loginUserPs = "",
- settingsMenu = document.getElementById("settingsButton"),
- settings = document.getElementById("settings"),
- howToMenu = document.getElementById("instructionButton"),
- howTo = document.getElementById("instructions"),
- leaderboardButton = document.getElementById("leaderButton"),
- leaderboardMenu = document.getElementById("leaderboardWrapper"),
- btn = document.getElementById("startButton"),
- btnMod = document.getElementById("texturePackButton"),
- modURL = document.getElementById("textureModInput"),
- lobbyInput = document.getElementById("lobbyKey"),
- lobbyMessage = document.getElementById("lobbyMessage"),
- lobbyButton = document.getElementById("joinLobbyButton");
- window.onload = function() {
- if (!mobile) {
- document.documentElement.style.overflow = "hidden";
- document.body.scroll = "no";
- document.getElementById("gameAreaWrapper").style.opacity = 1;
- drawMenuBackground();
- settingsMenu.onclick = function() {
- "200px" == settings.style.maxHeight ? settings.style.maxHeight = "0px" : (settings.style.maxHeight = "200px", howTo.style.maxHeight = "0px", leaderboardMenu.style.maxHeight = "0px")
- };
- howToMenu.onclick = function() {
- "200px" == howTo.style.maxHeight ? howTo.style.maxHeight = "0px" : (howTo.style.maxHeight =
- "200px", settings.style.maxHeight = "0px", leaderboardMenu.style.maxHeight = "0px")
- };
- leaderboardButton.onclick = function() {
- "190px" == leaderboardMenu.style.maxHeight ? leaderboardMenu.style.maxHeight = "0px" : (leaderboardMenu.style.maxHeight = "190px", settings.style.maxHeight = "0px", howTo.style.maxHeight = "0px")
- };
- $.get("/getIP", function(a) {
- port = a.port;
- socket || (socket = io.connect("http://" + (devTest ? "localhost" : a.ip) + ":" + a.port, {
- reconnection: !1,
- forceNew: !0
- }), setupSocket(socket));
- btn.onclick = function() {
- startGame("player")
- };
- playerNameInput.addEventListener("keypress", function(a) {
- 13 === (a.which || a.keyCode) && startGame("player")
- });
- btnMod.onclick = function() {
- loadModPack(modURL.value, !1)
- };
- registerButton.onclick = function() {
- waitingForServer || (socket.emit("dbReg", {
- userName: userNameInput.value,
- userEmail: userEmailInput.value,
- userPass: userPassInput.value
- }), loginUserNm = userNameInput.value, loginUserPs = userPassInput.value, loginMessage.style.display = "block", loginMessage.innerHTML = "Registering...", waitingForLoad = waitingForServer = !0)
- };
- loginButton.onclick = function() {
- waitingForServer || (socket.emit("dbLogin", {
- userName: userNameInput.value,
- userPass: userPassInput.value
- }), loginUserNm = userNameInput.value, loginUserPs = userPassInput.value, loginMessage.style.display = "block", loginMessage.innerHTML = "Please Wait...", waitingForLoad = waitingForServer = !0)
- };
- logoutButton.onclick = function() {
- loggedInWrapper.style.display = "none";
- loginWrapper.style.display = "block";
- loginMessage.innerHTML = "";
- setCookie("userName", "");
- setCookie("userPass", "");
- socket.emit("dbLogout")
- };
- recoverButton.onclick = function() {
- waitingForServer || (socket.emit("dbRecov", {
- userMail: userEmailInput.value
- }), loginMessage.style.display = "block", loginMessage.innerHTML = "Please Wait...", waitingForServer = !0)
- };
- createClanButton.onclick = function() {
- waitingForServer || (socket.emit("dbClanCreate", {
- clanName: clanNameInput.value
- }), clanDBMessage.style.display = "block", clanDBMessage.innerHTML = "Please Wait...", waitingForServer = !0)
- };
- joinClanButton.onclick = function() {
- waitingForServer || (socket.emit("dbClanJoin", {
- clanKey: clanKeyInput.value
- }),
- clanDBMessage.style.display = "block", clanDBMessage.innerHTML = "Please Wait...", waitingForServer = !0)
- };
- inviteClanButton.onclick = function() {
- waitingForServer || (socket.emit("dbClanInvite", {
- userName: clanInviteInput.value
- }), clanInvMessage.style.display = "block", clanInvMessage.innerHTML = "Please Wait...", waitingForServer = !0)
- };
- kickClanButton.onclick = function() {
- waitingForServer || (socket.emit("dbClanKick", {
- userName: clanInviteInput.value
- }), clanInvMessage.style.display = "block", clanInvMessage.innerHTML = "Please Wait...",
- waitingForServer = !0)
- };
- leaveClanButton.onclick = function() {
- waitingForServer || (socket.emit("dbClanLeave"), waitingForServer = !0)
- };
- a = getCookie("userName");
- var b = getCookie("userPass");
- a && "" != b ? (socket.emit("dbLogin", {
- userName: a,
- userPass: b
- }), loginUserNm = a, loginUserPs = b, loginMessage.style.display = "block", loginMessage.innerHTML = "Logging in...", waitingForServer = !0) : waitingForLoad = waitingForServer = !1;
- lobbyButton.onclick = function() {
- changingLobby || waitingForServer || (lobbyMessage.style.display = "inline-block", lobbyMessage.innerHTML =
- "Please wait...", socket.emit("checkIP", lobbyInput.value.split("/")[0]), changingLobby = !0)
- }
- });
- hideUI(!0);
- try {
- setTimeout(function() {
- var a = document.querySelector("ins.adsbygoogle");
- a && 0 == a.innerHTML.replace(/\s/g, "").length && (document.getElementById("noAdText").innerHTML = "<b>Could not be Loaded</b>")
- }, 2E3), hideBannerAd()
- } catch (a) {}
- $(".noRightClick").bind("contextmenu", function(a) {
- return !1
- });
- resize()
- }
- };
- var accStatKills = document.getElementById("accStatKills"),
- accStatDeaths = document.getElementById("accStatDeaths"),
- accStatLikes = document.getElementById("accStatLikes"),
- accStatKD = document.getElementById("accStatKD"),
- accStatRank = document.getElementById("accStatRank"),
- accStatRankProg = document.getElementById("rankProgress"),
- accStatWorldRank = document.getElementById("accStatWorldRank"),
- clanStats = document.getElementById("clanStats"),
- clanSignUp = document.getElementById("clanSignUp"),
- clanHeader = document.getElementById("clanHeader"),
- leaveClanButton = document.getElementById("leaveClanButton"),
- clanAdminPanel = document.getElementById("clanAdminPanel");
- function updateAccountPage(a) {
- player.account = a;
- accStatRank.innerHTML = "<b>Rank: </b>" + a.rank;
- accStatRankProg.style.width = a.rankPercent + "%";
- accStatKills.innerHTML = "<b>Kills: </b>" + a.kills;
- accStatDeaths.innerHTML = "<b>Deaths: </b>" + a.deaths;
- accStatKD.innerHTML = "<b>KD: </b>" + a.kd;
- accStatWorldRank.innerHTML = "<b>World Rank: </b>" + a.worldRank;
- accStatLikes.innerHTML = "<b>Likes: </b>" + a.likes;
- clanAdminPanel.style.display = "none";
- leaveClanButton.style.display = "none";
- "" != a.clan ? (clanSignUp.style.display =
- "none", clanStats.style.display = "block", leaveClanButton.style.display = "inline-block", leaveClanButton.innerHTML = "Leave Clan", clanHeader.innerHTML = "[" + a.clan + "] Clan:", "1" == a.clan_owner && (clanAdminPanel.style.display = "block", leaveClanButton.innerHTML = "Delete Clan")) : (clanSignUp.style.display = "block", clanStats.style.display = "none", clanHeader.innerHTML = "Clans")
- }
- var clanStatRank = document.getElementById("clanStatRank"),
- clanStatFounder = document.getElementById("clanStatFounder"),
- clanStatMembers = document.getElementById("clanStatMembers"),
- clanStatKD = document.getElementById("clanStatKD");
- function updateClanPage(a) {
- clanStatRank.innerHTML = "<b>Rank: </b>" + a.level;
- clanStatKD.innerHTML = "<b>Avg KD: </b>" + a.kd;
- clanStatFounder.innerHTML = "<b>Founder: </b>" + a.founder;
- clanStatMembers.innerHTML = "<b>Roster:</b>" + a.members
- }
- var leaderboardWrapper = document.getElementById("leaderboardWrapper");
- function updateGlobalLeaderboard(a) {
- leaderboardWrapper.innerHTML = a
- }
- var screenWidth = window.innerWidth,
- screenHeight = window.innerHeight,
- gameWidth = 0,
- gameHeight = 0,
- mouseX = 0,
- mouseY = 0,
- maxScreenWidth = 1920,
- originalScreenWidth = maxScreenWidth,
- maxScreenHeight = 1080,
- originalScreenHeight = maxScreenHeight,
- viewMult = 1,
- uiScale = 1;
- calculateUIScale();
- var gameStart = !1,
- gameOver = !1,
- gameOverFade = !1,
- disconnected = !1,
- kicked = !1,
- killTxt = "",
- continuity = !1,
- startPingTime = 0,
- textSizeMult = .55,
- bigTextSize = maxScreenHeight / 7.7 * textSizeMult,
- medTextSize = .85 * bigTextSize,
- textGap = 1.2 * bigTextSize,
- bigTextY = maxScreenHeight / 4.3,
- startX = 0,
- startY = 0,
- gameMode = null,
- playerConfig = {
- border: 6,
- textColor: "#efefef",
- textBorder: "#3a3a3a",
- textBorderSize: 3,
- defaultSize: 30
- },
- player = {
- firstReceive: !0,
- dead: !0,
- deltaX: 0,
- deltaY: 0
- },
- target = {
- f: 0,
- d: 0,
- dOffset: 0
- },
- gameObjects = [],
- bullets = [],
- gameMap = null,
- mapTileScale = 0,
- leaderboard = [],
- keys = {
- u: 0,
- d: 0,
- l: 0,
- r: 0,
- lm: 0,
- s: 0,
- rl: 0
- },
- mathABS = Math.abs,
- mathRound = Math.round,
- mathFloor = Math.floor,
- mathSQRT = Math.sqrt,
- mathPOW = Math.pow,
- mathMIN = Math.min,
- mathCOS = Math.cos,
- mathSIN = Math.sin,
- mathPI = Math.PI,
- mathMax = Math.max,
- mathATAN2 = Math.atan2,
- reenviar = !0,
- directionLock = !1,
- directions = [],
- zipFileCloser, c = document.getElementById("cvs");
- c.width = screenWidth;
- c.height = screenHeight;
- c.addEventListener("mousemove", gameInput, !1);
- c.addEventListener("mousedown", mouseDown, !1);
- c.addEventListener("mouseup", mouseUp, !1);
- var lastAngle = 0,
- lastDist = 0,
- targetChanged = !0;
- function gameInput(a) {
- if (void 0 != getCurrentWeapon(player)) {
- a.preventDefault();
- a.stopPropagation();
- mouseX = a.clientX;
- mouseY = a.clientY;
- lastAngle = target.f;
- lastDist = target.d;
- target.d = mathSQRT(mathPOW(mouseY - (screenHeight / 2 - getCurrentWeapon(player).yOffset / 2), 2) + mathPOW(mouseX - screenWidth / 2, 2));
- target.d *= mathMIN(maxScreenWidth / screenWidth, maxScreenHeight / screenHeight);
- target.f = mathATAN2(screenHeight / 2 - getCurrentWeapon(player).yOffset / 2 - mouseY, screenWidth / 2 - mouseX);
- target.f = target.f.round(2);
- target.d = target.d.round(2);
- target.dOffset = (target.d / 4).round(1);
- if (lastAngle != target.f || lastDist != target.d) targetChanged = !0;
- lastTarget = target.f
- }
- }
- function mouseDown(a) {
- keys.lm = 1
- }
- function mouseUp(a) {
- keys.lm = 0
- }
- c.addEventListener ? (c.addEventListener("mousewheel", gameScroll, !1), c.addEventListener("DOMMouseScroll", gameScroll, !1)) : c.attachEvent("onmousewheel", gameScroll);
- var userScroll = 0;
- function gameScroll(a) {
- a = window.event || a;
- userScroll = -1 * Math.max(-1, Math.min(1, a.wheelDelta || -a.detail))
- }
- var keyMap = [],
- showingScoreBoard = !1;
- c.addEventListener("keydown", keyDown, !1);
- function keyDown(a) {
- a = a || event;
- a.preventDefault();
- keyMap[a.keyCode] = "keydown" == a.type;
- !keyMap[87] && !keyMap[38] || keys.u || (keys.u = 1, keys.d = 0, keyMap[83] = !1, keyMap[40] = !1);
- !keyMap[83] && !keyMap[40] || keys.d || (keys.d = 1, keys.u = 0, keyMap[87] = !1, keyMap[38] = !1);
- !keyMap[65] && !keyMap[37] || keys.l || (keys.l = 1, keys.r = 0, keyMap[68] = !1, keyMap[39] = !1);
- !keyMap[68] && !keyMap[39] || keys.r || (keys.r = 1, keys.l = 0, keyMap[65] = !1, keyMap[37] = !1);
- keyMap[32] && !keys.s && (keys.s = 1);
- keyMap[82] && !keys.rl && (keys.rl = 1);
- 13 === a.keyCode && document.getElementById("chatInput").focus();
- !keyMap[16] || !gameStart || showingScoreBoard || player.dead || gameOver || (showingScoreBoard = !0, showStatTable(getUsersList(), null, null, !0, !0, !0))
- }
- c.addEventListener("keyup", keyUp, !1);
- function keyUp(a) {
- a = a || event;
- a.preventDefault();
- keyMap[a.keyCode] = "keydown" == a.type;
- if (87 == a.keyCode || 38 == a.keyCode) keys.u = 0;
- if (83 == a.keyCode || 40 == a.keyCode) keys.d = 0;
- if (65 == a.keyCode || 37 == a.keyCode) keys.l = 0;
- if (68 == a.keyCode || 39 == a.keyCode) keys.r = 0;
- 32 == a.keyCode && (keys.s = 0);
- 82 == a.keyCode && (keys.rl = 0);
- 69 == a.keyCode && playerSwapWeapon(findUserByIndex(player.index), 1);
- 81 == a.keyCode && playerSwapWeapon(findUserByIndex(player.index), -1);
- 70 == a.keyCode && sendSpray();
- 16 != a.keyCode || !showingScoreBoard || player.dead ||
- gameOver || gameOver || hideStatTable()
- }
- function ChatManager() {
- this.commands = {};
- var a = document.getElementById("chatInput");
- a.addEventListener("keypress", this.sendChat.bind(this));
- a.addEventListener("keyup", function(b) {
- a = document.getElementById("chatInput");
- b = b.which || b.keyCode;
- 27 === b && (a.value = "", c.focus())
- })
- }
- var chatTypeIndex = 0,
- chatTypes = ["ALL", "TEAM"],
- currentChatType = chatTypes[0];
- ChatManager.prototype.sendChat = function(a) {
- var b = document.getElementById("chatInput");
- a = a.which || a.keyCode;
- 13 === a && (a = b.value.replace(/(<([^>]+)>)/ig, ""), "" !== a && (socket.emit("cht", a.substring(0, 50), currentChatType), this.addChatLine(player.name, ("TEAM" == currentChatType ? "(TEAM) " : "") + a, !0, player.team), b.value = "", c.focus()))
- };
- function toggleTeamChat() {
- chatTypeIndex++;
- chatTypeIndex >= chatTypes.length && (chatTypeIndex = 0);
- currentChatType = chatTypes[chatTypeIndex];
- document.getElementById("chatType").innerHTML = currentChatType;
- c.focus()
- }
- var profanityList = "cunt whore shit fuck faggot nigger nigga dick vagina minge cock rape cum sex tits gay dumb".split(" "),
- tmpString = "";
- function checkProfanityString(a) {
- if (showProfanity)
- for (var b = 0; b < profanityList.length; ++b)
- if (-1 < a.indexOf(profanityList[b])) {
- tmpString = "";
- for (var d = 0; d < profanityList[b].length; ++d) tmpString += "*";
- a = a.replace(new RegExp(profanityList[b], "g"), tmpString)
- }
- return a
- }
- ChatManager.prototype.addChatLine = function(a, b, d, e) {
- if (!mobile) {
- b = checkProfanityString(b);
- var f = document.createElement("li"),
- h = "me";
- d || "system" == e ? "system" == e && (h = "system") : h = player.team == e ? "blue" : "red";
- f.className = h;
- f.innerHTML = "system" == h ? "<span>" + b + "</span>" : "<span>" + (d ? "YOU" : a) + ": </span>" + b;
- this.appendMessage(f)
- }
- };
- ChatManager.prototype.appendMessage = function(a) {
- if (!mobile) {
- for (var b = document.getElementById("chatbox"), d = document.getElementById("chatList"); 260 < b.clientHeight;) d.removeChild(d.childNodes[0]);
- d.appendChild(a)
- }
- };
- var chat = new ChatManager,
- tmpChatUser = null;
- function messageFromServer(a) {
- try {
- tmpChatUser = findUserByIndex(a[0]), null != tmpChatUser ? chat.addChatLine(tmpChatUser.name, a[1], tmpChatUser.index == player.index, tmpChatUser.team) : 0 > a[0] && (chatList.removeChild(chatList.childNodes[chatList.childNodes.length - 1]), chat.addChatLine("", a[1], !1, "system"))
- } catch (b) {
- console.log(b)
- }
- }
- var context = c.getContext("2d"),
- osCanvas = document.createElement("canvas"),
- graph = osCanvas.getContext("2d"),
- mapCanvas = document.getElementById("mapc"),
- mapContext = mapCanvas.getContext("2d");
- mapCanvas.width = 200;
- mapCanvas.height = 200;
- mapContext.imageSmoothingEnabled = !1;
- mapContext.webkitImageSmoothingEnabled = !1;
- mapContext.mozImageSmoothingEnabled = !1;
- function setCookie(a, b) {
- document.cookie = a + "=" + b
- }
- function getCookie(a) {
- a += "=";
- for (var b = document.cookie.split(";"), d = 0; d < b.length; d++) {
- for (var e = b[d];
- " " == e.charAt(0);) e = e.substring(1);
- if (0 == e.indexOf(a)) return e.substring(a.length, e.length)
- }
- return ""
- }
- "false" != getCookie("showNames") && (document.getElementById("showNames").checked || document.getElementById("showNames").click());
- var showNames = document.getElementById("showNames").checked;
- function settingShowNames(a) {
- showNames = a.checked;
- setCookie("showNames", showNames ? "true" : "false")
- }
- "false" != getCookie("showParticles") && (document.getElementById("showParticles").checked || document.getElementById("showParticles").click());
- var showParticles = document.getElementById("showParticles").checked;
- function settingShowParticles(a) {
- showParticles = a.checked;
- setCookie("showParticles", showParticles ? "true" : "false")
- }
- "false" != getCookie("showSprays") && (document.getElementById("showSprays").checked || document.getElementById("showSprays").click());
- var showSprays = document.getElementById("showSprays").checked;
- function settingShowSprays(a) {
- showSprays = a.checked;
- setCookie("showSprays", showSprays ? "true" : "false")
- }
- "true" == getCookie("showProfanity") && document.getElementById("showProfanity").checked && document.getElementById("showProfanity").click();
- var showProfanity = document.getElementById("showProfanity").checked;
- function settingProfanity(a) {
- showProfanity = a.checked;
- setCookie("showProfanity", showProfanity ? "true" : "false")
- }
- "false" != getCookie("showFade") && (document.getElementById("showFade").checked || document.getElementById("showFade").click());
- var showUIFade = document.getElementById("showFade").checked;
- function settingShowFade(a) {
- showUIFade = a.checked;
- setCookie("showFade", showUIFade ? "true" : "false")
- }
- "false" != getCookie("showShadows") && (document.getElementById("showShadows").checked || document.getElementById("showShadows").click());
- var showShadows = document.getElementById("showShadows").checked;
- function settingShowShadows(a) {
- showShadows = a.checked;
- setCookie("showShadows", showShadows ? "true" : "false")
- }
- "false" != getCookie("showChat") && (document.getElementById("showChat").checked || document.getElementById("showChat").click());
- var showChat = document.getElementById("showChat").checked;
- function settingShowChat(a) {
- showChat = a.checked;
- showChat ? gameStart && (document.getElementById("chatbox").style.display = "block") : document.getElementById("chatbox").style.display = "none";
- setCookie("showChat", showChat ? "true" : "false")
- }
- "false" != getCookie("showLeader") && (document.getElementById("showLeader").checked || document.getElementById("showLeader").click());
- var showLeader = document.getElementById("showLeader").checked;
- function settingShowLeader(a) {
- showLeader = a.checked;
- showLeader ? gameStart && (document.getElementById("status").style.display = "block") : document.getElementById("status").style.display = "none";
- setCookie("showLeader", showLeader ? "true" : "false")
- }
- var targetFPS = 30;
- if ("" != getCookie("targetFPS")) {
- targetFPS = getCookie("targetFPS");
- try {
- targetFPS *= 1
- } catch (a) {
- targetFPS = 30
- }
- }
- function pickedFps(a) {
- targetFPS = a.options[a.selectedIndex].value;
- try {
- targetFPS *= 1
- } catch (b) {
- targetFPS = 30
- }
- setCookie("targetFPS", targetFPS)
- }
- function changeMenuTab(a, b) {
- var d, e, f;
- e = document.getElementsByClassName("tabcontent");
- for (d = 0; d < e.length; d++) e[d].style.display = "none";
- f = document.getElementsByClassName("tablinks");
- for (d = 0; d < e.length; d++) f[d].className = f[d].className.replace(" active", "");
- document.getElementById(b).style.display = "block";
- a.currentTarget.className += " active"
- }
- var sponsorList = document.getElementById("donatorsList");
- function loadSponsorsList() {
- var a = new XMLHttpRequest;
- a.open("GET", "./sponsors.txt", !1);
- a.onreadystatechange = function() {
- 4 !== a.readyState || 200 !== a.status && 0 != a.status || (sponsorList.innerHTML = a.responseText)
- };
- a.send(null)
- }
- loadSponsorsList();
- function kickPlayer(a) {
- hideStatTable();
- hideUI(!0);
- hideMenuUI();
- document.getElementById("startMenuWrapper").style.display = "none";
- gameOver = disconnected = !0;
- void 0 == reason && (reason = a);
- kicked = !0;
- socket.close();
- updateGameLoop();
- stopAllSounds()
- }
- var classSelector = document.getElementById("classSelector"),
- spraySelector = document.getElementById("spraySelector"),
- hatSelector = document.getElementById("hatSelector"),
- lobbySelector = document.getElementById("lobbySelector"),
- lobbyCSelector = document.getElementById("lobbyCSelector"),
- charSelectorCont = document.getElementById("charSelectorCont"),
- lobbySelectorCont = document.getElementById("lobbySelectorCont");
- function showLobbySelector() {
- charSelectorCont.style.display = "none";
- lobbySelectorCont.style.display = "none";
- classSelector.style.display = "none";
- lobbyCSelector.style.display = "none";
- lobbySelector.style.display = "block"
- }
- function hideLobbySelector() {
- charSelectorCont.style.display = "block";
- lobbySelectorCont.style.display = "block";
- lobbySelector.style.display = "none"
- }
- function showLobbyCSelector() {
- charSelectorCont.style.display = "none";
- lobbySelectorCont.style.display = "none";
- classSelector.style.display = "none";
- lobbySelector.style.display = "none";
- lobbyCSelector.style.display = "block"
- }
- function hideLobbyCSelector() {
- charSelectorCont.style.display = "block";
- lobbySelectorCont.style.display = "block";
- lobbyCSelector.style.display = "none"
- }
- var timeOutCheck = null,
- tmpPingTimer = null,
- pingText = document.getElementById("pingText");
- function receivePing(a) {
- socket.connected && (0 != a && (pingText.innerHTML = "PING " + a), null != timeOutCheck && clearTimeout(timeOutCheck), tmpPingTimer = setTimeout(function() {
- timeOutCheck = setTimeout(function() {
- changingLobby || kickPlayer("your connection timed out")
- }, 6E3);
- socket.emit("test1")
- }, 2E3))
- }
- var manuallyDisconnected = !1;
- function setupSocket(a) {
- a.on("test2", receivePing);
- a.emit("test1");
- null != timeOutCheck && clearTimeout(timeOutCheck);
- null != tmpPingTimer && clearTimeout(tmpPingTimer);
- a.on("yourRoom", function(b) {
- room = b;
- document.getElementById("lobbyKeyCurrent").innerHTML = "<b>Key: </b>Getting Key...";
- a.emit("fetchTiny")
- });
- a.on("getTiny", function(a) {
- document.getElementById("lobbyKeyCurrent").innerHTML = "<b>Key: </b>" + a
- });
- a.on("connect_failed", function() {
- kickPlayer("Disconnected. The Server may have Restarted for an Update")
- });
- a.on("disconnect", function() {
- manuallyDisconnected || kickPlayer("Disconnected. The Server may have Restarted for an Update")
- });
- a.on("welcome", function(b, d) {
- player.id = b.id;
- player.room = b.room;
- player.name = playerName;
- player.classIndex = playerClassIndex;
- b.name = player.name;
- b.room = player.room;
- b.classIndex = playerClassIndex;
- a.emit("gotit", b, d, Date.now());
- d ? (player.dead = !0, deactiveAllAnimTexts(), gameStart = !1, hideUI(!1), document.getElementById("startMenuWrapper").style.display = "block") : (gameStart = !0, showUI(), document.getElementById("cvs").focus());
- gameOver && (document.getElementById("gameStatWrapper").style.display = "none");
- gameOverFade = gameOver = !1;
- hideBannerAd();
- mobile && (hideMenuUI(), hideUI(!0), document.getElementById("startMenuWrapper").style.display = "none");
- resize()
- });
- a.on("regRes", function(a, d) {
- d ? (loginMessage.innerHTML = a, setCookie("userName", loginUserNm), setCookie("userPass", loginUserPs)) : (loginMessage.style.display = "block", loginMessage.innerHTML = a);
- waitingForServer = !1
- });
- a.on("logRes", function(a, d) {
- d ? (loginMessage.style.display = "none", loginMessage.innerHTML =
- "", loginWrapper.style.display = "none", loggedInWrapper.style.display = "block", document.getElementById("playerNameInput").value = loginUserNm, setCookie("userName", loginUserNm), setCookie("userPass", loginUserPs)) : (loginMessage.style.display = "block", loginMessage.innerHTML = a);
- waitingForServer = waitingForLoad = !1
- });
- a.on("recovRes", function(b, d) {
- loginMessage.style.display = "block";
- loginMessage.innerHTML = b;
- waitingForServer = !1;
- if (d) {
- document.getElementById("recoverForm").style.display = "block";
- var e = document.getElementById("chngPassKey"),
- f = document.getElementById("chngPassPass");
- document.getElementById("chngPassButton").onclick = function() {
- loginMessage.style.display = "block";
- loginMessage.innerHTML = "Please Wait...";
- waitingForServer = !0;
- a.emit("dbCngPass", {
- passKey: e.value,
- newPass: f.value
- });
- a.on("cngPassRes", function(a, b) {
- loginMessage.style.display = "block";
- loginMessage.innerHTML = a;
- b && (document.getElementById("recoverForm").style.display = "none");
- waitingForServer = !1
- })
- }
- }
- });
- a.on("dbClanCreateR", function(a, d) {
- d ? (clanSignUp.style.display = "none",
- clanStats.style.display = "block", clanHeader.innerHTML = "[" + a + "] Clan:", clanAdminPanel.style.display = "block", leaveClanButton.style.display = "inline-block", leaveClanButton.innerHTML = "Delete Clan") : (clanDBMessage.style.display = "block", clanDBMessage.innerHTML = a);
- waitingForServer = !1
- });
- a.on("dbClanJoinR", function(a, d) {
- d ? (clanSignUp.style.display = "none", clanStats.style.display = "block", clanHeader.innerHTML = "[" + a + "] Clan:", leaveClanButton.style.display = "inline-block", leaveClanButton.innerHTML = "Leave Clan") : (clanDBMessage.style.display =
- "block", clanDBMessage.innerHTML = a);
- waitingForServer = !1
- });
- a.on("dbClanInvR", function(a, d) {
- clanInvMessage.style.display = "block";
- clanInvMessage.innerHTML = a;
- waitingForServer = !1
- });
- a.on("dbKickInvR", function(a, d) {
- clanInvMessage.style.display = "block";
- clanInvMessage.innerHTML = a;
- waitingForServer = !1
- });
- a.on("dbClanLevR", function(a, d) {
- d && (clanSignUp.style.display = "block", clanStats.style.display = "none", clanHeader.innerHTML = "Clans", clanDBMessage.style.display = "block", clanDBMessage.innerHTML = a, leaveClanButton.style.display =
- "none");
- waitingForServer = !1
- });
- a.on("dbClanStats", function(a) {
- updateClanPage(a)
- });
- a.on("updAccStat", function(a) {
- updateAccountPage(a)
- });
- a.on("dbLeaderboard", function(a) {
- updateGlobalLeaderboard(a)
- });
- a.on("replyIP", function(a) {
- var d = io.connect("http://" + a + ":" + port, {
- reconnection: !1,
- forceNew: !0
- });
- d.on("connect", function() {
- d.emit("create", {
- room: lobbyInput.value.split("/")[1],
- user: loginUserNm,
- pass: loginUserPs
- });
- d.on("lobbyRes", function(a, b) {
- lobbyMessage.innerHTML = a;
- b ? (manuallyDisconnected = !0, socket.on("disconnect",
- function() {
- changingLobby = manuallyDisconnected = !1;
- socket = d;
- setupSocket(socket)
- }), socket.disconnect()) : (changingLobby = !1, d.disconnect())
- })
- });
- d.on("connect_error", function(a) {
- lobbyMessage.innerHTML = "No Lobby Found.";
- changingLobby = !1;
- d.disconnect()
- })
- });
- a.on("gameSetup", function(a, d) {
- if (d) {
- gameWidth = a.gameWidth;
- gameHeight = a.gameHeight;
- gameMap = a.roomMap;
- cachedMiniMap = null;
- mapTileScale = a.tileScale;
- gameObjects = a.usersInRoom;
- for (var e = 0; e < gameObjects.length; ++e) gameObjects[e].type = "player";
- "blue" == a.you.team ?
- document.getElementById("gameModeText").innerHTML = a.gameMode.desc2 : document.getElementById("gameModeText").innerHTML = a.gameMode.desc1;
- gameMode = a.gameMode;
- for (var f, e = 0; e < gameMap.flags.length; ++e) f = gameMap.flags[e], f.type = "flag", gameObjects.push(f);
- for (e = 0; e < gameMap.clutter.length; ++e) f = gameMap.clutter[e], f.type = "clutter", gameObjects.push(f);
- deactivateSprays();
- for (e = 0; 100 > e; ++e) bullets.push(new Projectile)
- }
- maxScreenHeight = a.maxScreenHeight * a.viewMult;
- maxScreenWidth = a.maxScreenWidth * a.viewMult;
- viewMult =
- a.viewMult;
- a.you.type = "player";
- player = a.you;
- e = findUserByIndex(a.you.index);
- null != e ? gameObjects[gameObjects.indexOf(e)] = a.you : gameObjects.push(a.you);
- updateWeaponUI(player, !0);
- startingGame = inMainMenu = !1;
- resize()
- });
- a.on("lb", updateLeaderboard);
- a.on("ts", updateTeamScores);
- a.on("rsd", receiveServerData);
- a.on("upd", updateUserValue);
- a.on("vt", updateVoteStats);
- a.on("add", addUser);
- a.on("updHt", updateHatList);
- a.on("updSprs", updateSpraysList);
- a.on("crtSpr", createSpray);
- a.on("rem", removeUser);
- a.on("cht", messageFromServer);
- a.on("kick", function(a) {
- kickPlayer(a)
- });
- a.on("1", function(a) {
- var d = findUserByIndex(a.gID),
- e = mathABS(a.amount);
- (a.dID != player.index || a.gID == player.index) && 0 >= a.amount && a.gID == player.index && 0 != e && screenShake(e / 2, a.dir);
- null != a.dID && a.dID == player.index && null != d && 0 < e && d.onScreen && (0 > a.amount ? startMovingAnimText(e + "", d.x - d.width / 2, d.y - d.height, "#d95151", e / 10) : startMovingAnimText(e + "", d.x - d.width / 2, d.y - d.height, "#5ed951", e / 10));
- null != a.bi && (e = findServerBullet(a.bi), void 0 != e && e.owner.index != player.index &&
- (d.onScreen && 0 > a.amount && (particleCone(12, d.x, d.y - d.height / 2 - d.jumpY, e.dir + mathPI, mathPI / randomInt(5, 7), .5, 16, 0, !0), createLiquid(d.x, d.y, e.dir, 4)), e.active = !1));
- null != d && (d.health = a.h, d.index == player.index && (updatePlayerInfo(d), updateUiStats(d)))
- });
- a.on("2", someoneShot);
- a.on("jum", otherJump);
- a.on("ex", createExplosion);
- a.on("r", function(a) {
- var d = findUserByIndex(player.index);
- null != d && (0 == a && 1 < d.weapons[a].maxAmmo && showNotification("Ammo Full"), d.weapons[a].reloadTime = 0, d.weapons[a].ammo = d.weapons[a].maxAmmo,
- setCooldownAnimation(a, d.weapons[a].reloadTime, !1), updateUiStats(d))
- });
- a.on("3", function(a) {
- var d = findUserByIndex(a.gID),
- e = findUserByIndex(a.dID);
- d.dead = !0;
- if (a.kB && a.gID != player.index) a.dID == player.index ? startBigAnimText("BOSS SLAIN", a.sS + " POINTS", 2E3, !0, "#ffffff", "#5151d9", !0, 1.25) : showNotification(e.name + " slayed the boss");
- else if (a.dID == player.index) {
- if (a.gID != player.index) {
- showNotification("Eliminated " + d.name);
- var f = "";
- d.team != e.team ? (a.sS = "+" + a.sS, f = 1 == a.kd ? "Enemy Killed" : 2 == a.kd ? "Double Kill" :
- 3 == a.kd ? "Triple Kill" : 4 == a.kd ? "Multi Kill" : 5 == a.kd ? "Ultra Kill" : 6 == a.kd ? "No Way!" : 7 == a.kd ? "Stop!" : "Godlike!") : (f = "Team Kill", a.sS = "no");
- startBigAnimText(f, a.sS + " POINTS", 2E3, !0, "#ffffff", "#5151d9", !0, 1.25)
- }
- } else gameOver || (d.index == e.index ? showNotification(d.name + " Committed suicide") : d.index == player.index ? showNotification("You were killed by " + e.name) : e.index != player.index && showNotification(e.name + " killed " + d.name), playSound("kill1", e.x, e.y));
- a.gID == player.index && (hideStatTable(), gameStart = !1, hideUI(!1),
- player.dead = !0, window.setTimeout(function() {
- gameOver || (document.getElementById("startMenuWrapper").style.display = "block", document.getElementById("linkBox").style.display = "block")
- }, 1300), playSound("death1", player.x, player.y), startSoundTrack(1))
- });
- a.on("4", function(a, d, e) {
- if (0 == e) null != gameMap && void 0 != a.active && (gameMap.pickups[d].active = a.active);
- else
- for (e = 0; e < gameObjects.length; ++e) "clutter" == gameObjects[e].type && gameObjects[e].indx == d && (void 0 != a.active && (gameObjects[e].active = a.active), void 0 !=
- a.x && (gameObjects[e].x = a.x), void 0 != a.y && (gameObjects[e].y = a.y))
- });
- a.on("5", function(a) {
- showNotification(a)
- });
- a.on("6", function(a, d, e) {
- startBigAnimText(a, d, 2E3, !0, "#ffffff", "#5151d9", !0, e)
- });
- a.on("7", function(a, d, e, f) {
- try {
- gameOver = !0, document.getElementById("startMenuWrapper").style.display = "none", showStatTable(d, e, a, !1, f, !0), startSoundTrack(1)
- } catch (h) {
- console.log(h)
- }
- });
- a.on("8", function(a) {
- document.getElementById("nextGameTimer").innerHTML = a + ": UNTIL NEXT ROUND"
- })
- }
- function likePlayerStat(a) {
- socket.emit("like", a)
- }
- function updateVoteStats(a) {
- document.getElementById("votesText" + a.i).innerHTML = a.n + ": " + a.v
- }
- function showStatTable(a, b, d, e, f, h) {
- if (h)
- if (hideUI(!1), e) nextGameTimer.innerHTML = "GAME STATS", document.getElementById("winningTeamText").innerHTML = "", document.getElementById("voteModeContainer").innerHTML = "";
- else if (d = player.team == d || player.id == d, f || (d ? (startBigAnimText("Victory", "Well Played!", 2500, !0, "#5151d9", "#ffffff", !1, 2), document.getElementById("winningTeamText").innerHTML = "VICTORY", document.getElementById("winningTeamText").style.color = "#5151d9") : "" != player.team && (startBigAnimText("Defeat",
- "Bad Luck!", 2500, !0, "#d95151", "#ffffff", !1, 2), document.getElementById("winningTeamText").innerHTML = "DEFEAT", document.getElementById("winningTeamText").style.color = "#d95151")), null != b) {
- document.getElementById("voteModeContainer").innerHTML = "";
- for (var g = 0; g < b.length; ++g) d = document.createElement("button"), d.className = "modeVoteButton", d.setAttribute("id", "votesText" + g), d.innerHTML = b[g].name + ": " + b[g].votes, document.getElementById("voteModeContainer").appendChild(d), d.onclick = function(a) {
- return function() {
- c.focus();
- socket.emit("modeVote", a.indx)
- }
- }(b[g])
- }
- try {
- document.getElementById("gameStatBoard").innerHTML = "";
- addRowToStatTable([{
- text: "NAME",
- className: "headerL",
- color: "#fff"
- }, {
- text: "SCORE",
- className: "headerC",
- color: "#fff"
- }, {
- text: "KILLS",
- className: "headerC",
- color: "#fff"
- }, {
- text: "DEATHS",
- className: "headerC",
- color: "#fff"
- }, {
- text: "DAMAGE",
- className: "headerC",
- color: "#fff"
- }, {
- text: "HEALING",
- className: "headerC",
- color: "#fff"
- }, {
- text: "REWARD",
- className: "headerC",
- color: "#fff"
- }, {
- text: "",
- className: "headerC",
- color: "#fff"
- }], !0);
- for (g = 0; g < a.length; ++g) "" != a[g].team && addRowToStatTable([{
- text: a[g].index == player.index ? "YOU" : a[g].name,
- className: "contL",
- color: a[g].index == player.index ? "#fff" : a[g].team != player.team ? "#d95151" : "#5151d9",
- id: null,
- userInfo: findUserByIndex(a[g].index)
- }, {
- text: a[g].score || 0,
- className: "contC",
- color: "#fff",
- id: null
- }, {
- text: a[g].kills || 0,
- className: "contC",
- color: "#fff",
- id: null
- }, {
- text: a[g].deaths || 0,
- className: "contC",
- color: "#fff",
- id: null
- }, {
- text: a[g].totalDamage || 0,
- className: "contC",
- color: "#fff",
- id: null
- }, {
- text: a[g].totalHealing ||
- 0,
- className: "contC",
- color: "#fff",
- id: null
- }, {
- text: null != a[g].lastHat ? a[g].lastHat.name : "No Reward",
- className: "rewardText",
- color: null != a[g].lastHat ? getItemRarityColor(a[g].lastHat.chance) : "#fff",
- id: null,
- hoverInfo: a[g].lastHat
- }, {
- text: a[g].likes || 0,
- className: "contC",
- color: "#fff",
- pos: a[g].index,
- id: "likeStat" + a[g].index
- }], !1);
- h && (f ? (overlayAlpha = overlayMaxAlpha, animateOverlay = !1, gameOverFade = !0, deactiveAllAnimTexts(), document.getElementById("gameStatWrapper").style.display = "block", e || showBannerAd()) : (hideStatTable(),
- hideUI(!1), animateOverlay = !0, window.setTimeout(function() {
- gameOverFade = !0
- }, 2500), window.setTimeout(function() {
- document.getElementById("gameStatWrapper").style.display = "block";
- showBannerAd()
- }, 4500)))
- } catch (l) {
- console.log(l)
- }
- }
- function hideStatTable() {
- showUI();
- overlayAlpha = 0;
- showingScoreBoard = !1;
- animateOverlay = !0;
- drawOverlay(graph, !1, !0);
- document.getElementById("gameStatWrapper").style.display = "none";
- document.getElementById("linkBox").style.display = "none";
- hideBannerAd()
- }
- function addRowToStatTable(a, b) {
- for (var d = document.getElementById("gameStatBoard"), e = document.createElement("tr"), f = 0; f < a.length; ++f) {
- var h = document.createElement("td");
- if (b || f != a.length - 1) {
- if (l = document.createTextNode(a[f].text), h.appendChild(l), h.className = a[f].className, h.style.color = a[f].color, void 0 != a[f].hoverInfo) {
- var g = document.createElement("div");
- g.className = "hoverTooltip";
- g.innerHTML = "<image class='itemDisplayImage' src='.././images/hats/" + a[f].hoverInfo.id + "/d.png'></image><div style='color:" +
- a[f].color + "; font-size:16px; margin-top:5px;'>" + a[f].hoverInfo.name + "</div><div style='color:#ffd100; font-size:12px; margin-top:0px;'>droprate " + a[f].hoverInfo.chance + "%</div><div style='font-size:8px; color:#d8d8d8; margin-top:1px;'><i>wearable</i></div><div style='font-size:12px; margin-top:5px;'>" + a[f].hoverInfo.desc + "</div><div style='font-size:8px; color:#d8d8d8; margin-top:5px;'><i>Artist: " + a[f].hoverInfo.creator + "</i></div>";
- h.appendChild(g)
- }
- } else {
- var g = document.createElement("button"),
- l = document.createTextNode(" NICE");
- g.appendChild(l);
- g.setAttribute("type", "button");
- var m = a[f];
- g.onclick = function() {
- c.focus();
- likePlayerStat(m.pos)
- };
- g.setAttribute("id", "gameStatLikeButton");
- g.style.display = m.pos == player.index ? "none" : "block";
- e.appendChild(g);
- l = document.createElement("div");
- l.innerHTML = a[f].text;
- null != a[f].id && l.setAttribute("id", a[f].id);
- h.appendChild(l);
- h.className = a[f].className;
- h.style.color = a[f].color
- }
- e.appendChild(h)
- }
- d.appendChild(e)
- }
- function addUser(a) {
- if (a.index != player.index) {
- a.type = "player";
- var b = findUserByIndex(a.index);
- null == b ? gameObjects.push(a) : gameObjects[gameObjects.indexOf(b)] = a
- }
- }
- function removeUser(a) {
- a != player.index && (tmpUser = findUserByIndex(a), null != tmpUser && gameObjects.splice(gameObjects.indexOf(tmpUser), 1))
- }
- function updateUiStats(a) {
- document.getElementById("scoreValue").innerHTML = a.score;
- document.getElementById("ammoValue").innerHTML = getCurrentWeapon(a).ammo;
- document.getElementById("healthValue").innerHTML = a.health;
- 10 >= a.health ? document.getElementById("healthValue").style.color = "#e06363" : document.getElementById("healthValue").style.color = "#fff"
- }
- function getItemRarityColor(a) {
- return 1 >= a ? "#ff8000" : 6 >= a ? "#a335ee" : 18 >= a ? "#0070dd" : 45 >= a ? "#1eff00" : "#9d9d9d"
- }
- function updateUserValue(a) {
- var b = !1;
- tmpUser = findUserByIndex(a.i);
- null != tmpUser ? (void 0 != a.s && (tmpUser.score = a.s, b = !0), void 0 != a.sp && (tmpUser.spawnProtection = a.sp), void 0 != a.wi && a.i != player.index && playerEquipWeapon(tmpUser, a.wi), void 0 != a.l && (tmpUser.likes = a.l, b = !0), void 0 != a.dea && (tmpUser.deaths = a.dea, b = !0), void 0 != a.kil && (tmpUser.kills = a.kil, b = !0), void 0 != a.dmg && (tmpUser.totalDamage = a.dmg, b = !0), void 0 != a.hea && (tmpUser.totalHealing = a.hea, b = !0), tmpUser.index == player.index && (updatePlayerInfo(tmpUser),
- updateUiStats(tmpUser)), b && (gameOver ? void 0 != a.l && (a = document.createTextNode(tmpUser.likes), document.getElementById("likeStat" + tmpUser.index).innerHTML = "", document.getElementById("likeStat" + tmpUser.index).appendChild(a)) : showStatTable(getUsersList(), null, null, !0, !0, !1))) : fetchUserWithIndex(a.i)
- }
- function fetchUserWithIndex(a) {
- socket.emit("ftc", a)
- }
- var tmpNowTime = 0;
- function receiveServerData(a) {
- tmpNowTime = Date.now();
- timeSinceLastUpdate = tmpNowTime - timeOfLastUpdate;
- timeOfLastUpdate = tmpNowTime;
- var b;
- if (!gameOver)
- for (var d = 0; d < a.length;) {
- b = a[0 + d];
- tmpUser = findUserByIndex(a[1 + d]);
- if (a[1 + d] == player.index && null != tmpUser) 2 < b && (tmpUser.x = a[2 + d]), 3 < b && (tmpUser.y = a[3 + d]), 4 < b && (tmpUser.angle = a[4 + d]), 5 < b && (tmpUser.isn = a[5 + d]), tmpUser.onScreen = !0;
- else if (null != tmpUser) {
- 2 < b && (tmpUser.xSpeed = mathABS(tmpUser.x - a[2 + d]), tmpUser.x = a[2 + d]);
- 3 < b && (tmpUser.ySpeed = mathABS(tmpUser.y -
- a[3 + d]), tmpUser.y = a[3 + d]);
- 4 < b && (tmpUser.angle = a[4 + d]);
- if (void 0 != getCurrentWeapon(tmpUser)) {
- var e = 90 * mathRound(tmpUser.angle % 360 / 90);
- 0 == e || 360 == e ? getCurrentWeapon(tmpUser).front = !0 : 180 == e ? getCurrentWeapon(tmpUser).front = !1 : getCurrentWeapon(tmpUser).front = !0
- }
- 5 < b && (tmpUser.nameYOffset = a[5 + d]);
- tmpUser.onScreen = !0
- } else fetchUserWithIndex(a[1 + d]);
- d += b
- }
- for (d = 0; d < gameObjects.length; d++)
- if (gameObjects[d].index == player.index) {
- if (gameObjects[d].dead || gameOver || 80 < thisInput.length) thisInput.length = 0;
- var f = 0;
- if (!gameObjects[d].dead) {
- for (; f < thisInput.length;) thisInput[f].isn <= gameObjects[d].isn ? thisInput.splice(f, 1) : (a = thisInput[f].hdt, b = thisInput[f].vdt, e = mathSQRT(thisInput[f].hdt * thisInput[f].hdt + thisInput[f].vdt * thisInput[f].vdt), 0 != e && (a /= e, b /= e), gameObjects[d].oldX = gameObjects[d].x, gameObjects[d].oldY = gameObjects[d].y, gameObjects[d].x += a * gameObjects[d].speed * thisInput[f].delta, gameObjects[d].y += b * gameObjects[d].speed * thisInput[f].delta, wallCol(gameObjects[d]), f++);
- gameObjects[d].x = mathRound(gameObjects[d].x);
- gameObjects[d].y = mathRound(gameObjects[d].y);
- updatePlayerInfo(gameObjects[d])
- }
- }
- }
- function updatePlayerInfo(a) {
- player.x = a.x;
- player.y = a.y;
- player.dead = a.dead;
- player.score < a.score && playSound("score", player.x, player.y);
- player.score = a.score;
- player.health = a.health
- }
- var currentHat = document.getElementById("currentHat"),
- hatList = document.getElementById("hatList"),
- hatHeader = document.getElementById("hatHeader");
- function updateHatList(a, b) {
- var d = "Select Hat: (" + b.length + "/" + a + ")";
- hatHeader.innerHTML = d;
- for (var d = "<div class='hatSelectItem' id='hatItem-1' onclick='changeHat(-1);'>Default</div>", e = 0; e < b.length; ++e) d += "<div class='hatSelectItem' id='hatItem" + b[e].id + "' style='color:" + getItemRarityColor(b[e].chance) + ";' onclick='changeHat(" + b[e].id + ");'>" + b[e].name + "<div class='hoverTooltip'><image class='itemDisplayImage' src='.././images/hats/" + b[e].id + "/d.png'></image><div style='color:" + getItemRarityColor(b[e].chance) +
- "; font-size:16px; margin-top:5px;'>" + b[e].name + "</div><div style='color:#ffd100; font-size:12px; margin-top:0px;'>droprate " + b[e].chance + "%</div><div style='font-size:8px; color:#d8d8d8; margin-top:1px;'><i>wearable</i></div><div style='font-size:12px; margin-top:5px;'>" + b[e].desc + "</div><div style='font-size:8px; color:#d8d8d8; margin-top:5px;'><i>Artist: " + b[e].creator + "</i></div></div></div>";
- hatList.innerHTML = d;
- "" != getCookie("previousHat") && (previousHat = getCookie("previousHat"), changeHat(previousHat))
- }
- function showHatselector() {
- charSelectorCont.style.display = "none";
- lobbySelectorCont.style.display = "none";
- classSelector.style.display = "none";
- lobbySelector.style.display = "none";
- lobbyCSelector.style.display = "none";
- spraySelector.style.display = "none";
- hatSelector.style.display = "block"
- }
- function changeHat(a) {
- void 0 != socket && (socket.emit("cHat", a), setCookie("previousHat", a), currentHat.innerHTML = document.getElementById("hatItem" + a).innerHTML, currentHat.style.color = document.getElementById("hatItem" + a).style.color, charSelectorCont.style.display = "block", lobbySelectorCont.style.display = "block", classSelector.style.display = "none", hatSelector.style.display = "none", lobbySelector.style.display = "none", lobbyCSelector.style.display = "none")
- }
- var currentSpray = document.getElementById("currentSpray"),
- sprayList = document.getElementById("sprayList");
- function updateSpraysList(a) {
- for (var b = "", d = 0; d < a.length; ++d) b += "<div class='hatSelectItem' id='sprayItem" + (d + 1) + "' onclick='changeSpray(" + (d + 1) + ");'>" + a[d].name + "<div class='hoverTooltip' style='width:90px;height:90px;'><image class='sprayDisplayImage' src='.././images/sprays/" + a[d].id + ".png'></image></div></div>";
- sprayList.innerHTML = b;
- "" != getCookie("previousSpray") && (previousSpray = getCookie("previousSpray"), changeSpray(previousSpray))
- }
- function showSprayselector() {
- charSelectorCont.style.display = "none";
- lobbySelectorCont.style.display = "none";
- classSelector.style.display = "none";
- lobbySelector.style.display = "none";
- lobbyCSelector.style.display = "none";
- hatSelector.style.display = "none";
- spraySelector.style.display = "block"
- }
- function changeSpray(a) {
- void 0 != socket && (socket.emit("cSpray", a), setCookie("previousSpray", a), currentSpray.innerHTML = document.getElementById("sprayItem" + a).innerHTML, currentSpray.style.color = document.getElementById("sprayItem" + a).style.color, charSelectorCont.style.display = "block", lobbySelectorCont.style.display = "block", classSelector.style.display = "none", hatSelector.style.display = "none", spraySelector.style.display = "none", lobbySelector.style.display = "none", lobbyCSelector.style.display = "none")
- }
- function findUserByIndex(a) {
- for (var b = 0; b < gameObjects.length; ++b)
- if (gameObjects[b].index === a) return gameObjects[b];
- return null
- }
- var tmpUsers = [];
- function getUsersList() {
- for (var a = tmpUsers.length = 0; a < gameObjects.length; ++a) "player" == gameObjects[a].type && tmpUsers.push(gameObjects[a]);
- tmpUsers.sort(sortUsersByScore);
- return tmpUsers
- }
- function sortUsersByScore(a, b) {
- return b.score == a.score ? a.id < b.id ? -1 : a.id > b.id ? 1 : 0 : a.score > b.score ? -1 : a.score < b.score ? 1 : 0
- }
- function sortUsersByPosition(a, b) {
- return a.y < b.y ? -1 : a.y > b.y ? 1 : 0
- }
- var tmpPlayer = null;
- function updateLeaderboard(a) {
- try {
- for (var b = '<span class="title">LEADERBOARD</span>', d = 1, e = 0; e < a.length; ++e) tmpPlayer = findUserByIndex(a[0 + e]), null != tmpPlayer && (b += "<br />", tmpPlayer.index == player.index ? b += '<span class="me">' + d + ". " + player.name + ("" != player.account.clan ? " [" + player.account.clan + "]" : "") + "</span>" : "" != tmpPlayer.name && (b += '<span class="' + (tmpPlayer.team != player.team ? "red" : "blue") + '">' + d + ". " + tmpPlayer.name + "</span>" + ("" != tmpPlayer.account.clan ? "<span class='me'> [" + tmpPlayer.account.clan +
- "]</span>" : "")), d++);
- document.getElementById("status").innerHTML = b
- } catch (f) {}
- }
- function updateTeamScores(a, b) {
- var d = document.getElementById("redProgress"),
- e = document.getElementById("blueText"),
- f = document.getElementById("blueProgress"),
- h = document.getElementById("redProgCont");
- if (void 0 != gameMode) try {
- gameMode.teams ? (e.innerHTML = "A", h.style.display = "", "red" == player.team ? (d.setAttribute("style", "display:block;width:" + b + "%"), d.style.width = b + "%", f.setAttribute("style", "display:block;width:" + a + "%"), f.style.width = a + "%") : (d.setAttribute("style", "display:block;width:" + a + "%"), d.style.width =
- a + "%", f.setAttribute("style", "display:block;width:" + b + "%"), f.style.width = b + "%")) : (b = mathRound(player.score / a * 100), f.setAttribute("style", "display:block;width:" + b + "%"), f.style.width = b + "%", e.innerHTML = "YOU", h.style.display = "none")
- } catch (g) {
- console.log(g)
- }
- }
- function showUI() {
- document.getElementById("status").style.display = "block";
- document.getElementById("statContainer2").style.display = "block";
- document.getElementById("actionBar").style.display = "block";
- document.getElementById("statContainer").style.display = "block";
- document.getElementById("conStatContainer").style.display = "block";
- document.getElementById("score").style.display = "block";
- showChat && (document.getElementById("chatbox").style.display = "block");
- showLeader || (document.getElementById("status").style.display =
- "none")
- }
- function hideMenuUI() {
- document.getElementById("namesBox").style.display = "none";
- document.getElementById("linkBox").style.display = "none";
- document.getElementById("devMessage").style.display = "none"
- }
- function hideUI(a) {
- document.getElementById("status").style.display = "none";
- document.getElementById("statContainer2").style.display = "none";
- document.getElementById("actionBar").style.display = "none";
- document.getElementById("conStatContainer").style.display = "none";
- document.getElementById("score").style.display = "none";
- document.getElementById("statContainer").style.display = "none";
- a && (document.getElementById("chatbox").style.display = "none")
- }
- hideBannerAd();
- function hideBannerAd() {
- document.getElementById("bannerAdContainer").style.display = "none"
- }
- function showBannerAd() {
- document.getElementById("bannerAdContainer").style.display = "inline-block"
- }
- $(window).focus(function() {
- void 0 != socket && socket.emit("5", 1);
- tabbed = 0
- });
- $(window).blur(function() {
- void 0 != socket && socket.emit("5", 0);
- tabbed = 1
- });
- var sendData = null;
- function updateGameLoop() {
- delta = currentTime - oldTime;
- oldTime = currentTime;
- horizontalDT = verticalDT = 0;
- count++;
- var a = 0;
- 1 == keys.u && (verticalDT = -1, temp = 0);
- 1 == keys.d && (verticalDT = 1, temp = 0);
- 1 == keys.r && (horizontalDT = 1, temp = 0);
- 1 == keys.l ? (horizontalDT = -1, temp = 0) : keyd = 0;
- 1 == keys.s && (a = 1, temp = 0);
- var b = horizontalDT,
- d = verticalDT,
- e = mathSQRT(horizontalDT * horizontalDT + verticalDT * verticalDT);
- 0 != e && (b /= e, d /= e);
- if (clientPrediction)
- for (e = 0; e < gameObjects.length; e++)
- if ("player" == gameObjects[e].type) {
- if (gameObjects[e].index ==
- player.index) {
- gameObjects[e].oldX = gameObjects[e].x;
- gameObjects[e].oldY = gameObjects[e].y;
- gameObjects[e].dead || gameOver || (gameObjects[e].x += b * gameObjects[e].speed * delta, gameObjects[e].y += d * gameObjects[e].speed * delta);
- wallCol(gameObjects[e]);
- gameObjects[e].x = mathRound(gameObjects[e].x);
- gameObjects[e].y = mathRound(gameObjects[e].y);
- if (void 0 != getCurrentWeapon(gameObjects[e])) {
- gameObjects[e].angle = (target.f + 2 * mathPI) % (2 * mathPI) * (180 / mathPI) + 90;
- var f = 90 * mathRound(gameObjects[e].angle % 360 / 90);
- 0 == f || 360 ==
- f ? getCurrentWeapon(gameObjects[e]).front = !0 : 180 == f ? getCurrentWeapon(gameObjects[e]).front = !1 : getCurrentWeapon(gameObjects[e]).front = !0
- }
- 0 < gameObjects[e].jumpCountdown && (gameObjects[e].jumpCountdown -= delta);
- 1 == keys.s && 0 >= gameObjects[e].jumpCountdown && !gameOver && playerJump(gameObjects[e])
- }
- 0 != gameObjects[e].jumpY && (gameObjects[e].jumpDelta -= gameObjects[e].gravityStrength * delta, gameObjects[e].jumpY += gameObjects[e].jumpDelta * delta, 0 < gameObjects[e].jumpY ? gameObjects[e].animIndex = 1 : (gameObjects[e].jumpY =
- 0, gameObjects[e].jumpDelta = 0, gameObjects[e].jumpCountdown = 250), gameObjects[e].jumpY = mathRound(gameObjects[e].jumpY));
- gameObjects[e].index != player.index || gameOver || (sendData = {
- hdt: horizontalDT,
- vdt: verticalDT,
- ts: currentTime,
- isn: inputNumber,
- s: a
- }, inputNumber++, socket.emit("4", sendData), sendData.delta = delta, thisInput.push(sendData), 0 == userScroll || gameOver || (playerSwapWeapon(gameObjects[e], userScroll), userScroll = 0), 1 != keys.rl || gameOver || playerReload(gameObjects[e]), 1 != keys.lm || gameOver || (keyd = 0, currentTime -
- getCurrentWeapon(gameObjects[e]).lastShot >= getCurrentWeapon(gameObjects[e]).fireRate && shootBullet(gameObjects[e])));
- gameOver ? gameObjects[e].animIndex = 0 : (f = mathABS(b) + mathABS(d), gameObjects[e].index != player.index && (f = mathABS(gameObjects[e].xSpeed) + mathABS(gameObjects[e].ySpeed)), 0 < f ? (gameObjects[e].frameCountdown -= delta / 4, 0 >= gameObjects[e].frameCountdown && (gameObjects[e].animIndex++, 0 == gameObjects[e].jumpY && gameObjects[e].onScreen && !gameObjects[e].dead && stillDustParticle(gameObjects[e].x, gameObjects[e].y, !1), 3 <= gameObjects[e].animIndex ? gameObjects[e].animIndex = 1 : 2 == gameObjects[e].animIndex && 0 >= gameObjects[e].jumpY && playSound("step1", gameObjects[e].x, gameObjects[e].y), gameObjects[e].frameCountdown = 40)) : 0 != gameObjects[e].animIndex && (gameObjects[e].animIndex = 0), 0 < gameObjects[e].jumpY && (gameObjects[e].animIndex = 1))
- }
- gameObjects.sort(sortUsersByPosition);
- gameOver ? (doGame(delta), gameOverFade && showUIFade && drawOverlay(graph, !0, !1)) : player.dead && !inMainMenu ? (doGame(delta), drawOverlay(graph, !0, !1)) : gameStart ?
- (doGame(delta), drawOverlay(graph, !1, !0), !mobile && targetChanged && (targetChanged = !1, socket.emit("0", target.f))) : kicked || (drawMenuBackground(), drawOverlay(graph, !1, !1), a = renderShadedAnimText("Loading...", 48 * viewMult, "#ffffff", 6, ""), void 0 != a && graph.drawImage(a, maxScreenWidth / 2 - a.width / 2, maxScreenHeight / 2 - a.height / 2, a.width, a.height));
- if (disconnected || kicked) drawOverlay(graph, !1, !1), a = kicked ? "" !== reason ? renderShadedAnimText(reason, 48 * viewMult, "#ffffff", 6, "") : renderShadedAnimText("You were kicked", 48 *
- viewMult, "#ffffff", 6, "") : renderShadedAnimText("Disconnected", 48 * viewMult, "#ffffff", 6, ""), void 0 != a && graph.drawImage(a, maxScreenWidth / 2 - a.width / 2, maxScreenHeight / 2 - a.height / 2, a.width, a.height);
- context.drawImage(osCanvas, 0, 0)
- }
- function wallCol(a) {
- if (!a.dead) {
- for (var b = null, d = a.nameYOffset = 0; d < gameMap.tiles.length; ++d) gameMap.tiles[d].wall && gameMap.tiles[d].hasCollision && (b = gameMap.tiles[d], a.x + a.width / 2 >= b.x && a.x - a.width / 2 <= b.x + b.scale && a.y >= b.y && a.y <= b.y + b.scale && (a.oldX <= b.x ? a.x = b.x - a.width / 2 - 1 : a.oldX - a.width / 2 >= b.x + b.scale && (a.x = b.x + b.scale + a.width / 2 + 1), a.oldY <= b.y ? a.y = b.y - 1 : a.oldY >= b.y + b.scale && (a.y = b.y + b.scale + 1)), !b.hardPoint && a.x > b.x && a.x < b.x + b.scale && a.y - a.jumpY - .85 * a.height > b.y - b.scale / 2 && a.y - a.jumpY - .85 * a.height <=
- b.y && (a.nameYOffset = Math.round(a.y - a.jumpY - .85 * a.height - (b.y - b.scale / 2))));
- for (d = 0; d < gameObjects.length; ++d) "clutter" == gameObjects[d].type && gameObjects[d].active && (b = gameObjects[d], b.hc && canSee(b.x - startX, b.y - startY, b.w, b.h) && a.x + a.width / 2 >= b.x && a.x - a.width / 2 <= b.x + b.w && a.y >= b.y - b.h * b.tp && a.y <= b.y && (a.oldX + player.width / 2 <= b.x ? a.x = b.x - a.width / 2 - 1 : a.oldX - a.width / 2 >= b.x + b.w && (a.x = b.x + b.w + a.width / 2 + 1), a.oldY >= b.y ? a.y = b.y + 1 : a.oldY <= b.y - b.h * b.tp && (a.y = b.y - b.h * b.tp - 1)));
- delete b
- }
- }
- function otherJump(a) {
- a = findUserByIndex(a);
- void 0 != a && null != a && playerJump(a)
- }
- function playerJump(a) {
- 0 >= a.jumpY && (playSound("jump1", a.x, a.y), a.jumpDelta = a.jumpStrength, a.jumpY = a.jumpDelta)
- }
- var overlayMaxAlpha = .5,
- overlayAlpha = overlayMaxAlpha,
- overlayFadeUp = .01,
- overlayFadeDown = .04,
- animateOverlay = !0;
- function drawOverlay(a, b, d) {
- animateOverlay && (b ? (overlayAlpha += overlayFadeUp, overlayAlpha >= overlayMaxAlpha && (overlayAlpha = overlayMaxAlpha)) : d ? (overlayAlpha -= overlayFadeDown, 0 >= overlayAlpha && (overlayAlpha = 0)) : overlayAlpha = overlayMaxAlpha);
- 0 < overlayAlpha && (a.fillStyle = "#2e3031", a.globalAlpha = overlayAlpha, a.fillRect(0, 0, maxScreenWidth, maxScreenHeight), a.globalAlpha = 1)
- }
- function doGame(a) {
- updateScreenShake(a);
- null != target && (startX = player.x - maxScreenWidth / 2 + -screenSkX + target.dOffset * mathCOS(target.f + mathPI), startX = mathFloor(startX), startY = player.y - 20 - maxScreenHeight / 2 + -screenSkY + target.dOffset * mathSIN(target.f + mathPI), startY = mathFloor(startY));
- drawBackground();
- drawMap(0);
- drawMap(1);
- drawSprays();
- updateParticles(a, 0);
- drawGameObjects(a);
- updateBullets(a);
- updateParticles(a, 1);
- drawMap(2);
- drawPlayerNames();
- drawEdgeShader();
- drawUI();
- drawMiniMap();
- updateAnimTexts(a);
- updateNotifications(a)
- }
- window.addEventListener("resize", resize);
- function resize() {
- screenWidth = mathRound(window.innerWidth);
- screenHeight = mathRound(window.innerHeight);
- calculateUIScale();
- var a = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight);
- c.style.width = screenWidth + "px";
- c.style.height = screenHeight + "px";
- c.width = screenWidth;
- c.height = screenHeight;
- osCanvas.style.width = screenWidth + "px";
- osCanvas.style.height = screenHeight + "px";
- osCanvas.width = screenWidth;
- osCanvas.height = screenHeight;
- graph.setTransform(a, 0, 0, a, (screenWidth - maxScreenWidth * a) / 2, (screenHeight -
- maxScreenHeight * a) / 2);
- document.getElementById("startMenuWrapper").style.transform = "perspective(1px) translate(-50%, -50%) scale(" + uiScale + ")";
- document.getElementById("gameStatWrapper").style.transform = "perspective(1px) translate(-50%, -50%) scale(" + uiScale + ")";
- graph.imageSmoothingEnabled = !1;
- graph.webkitImageSmoothingEnabled = !1;
- graph.mozImageSmoothingEnabled = !1;
- context.imageSmoothingEnabled = !1;
- context.webkitImageSmoothingEnabled = !1;
- context.mozImageSmoothingEnabled = !1;
- drawMenuBackground()
- }
- resize();
- var grd = null;
- function drawEdgeShader() {
- try {
- null == grd && (grd = graph.createRadialGradient(player.x - startX, player.y - startY, 0, player.x - startX, player.y - startY, maxScreenWidth / 2), grd.addColorStop(0, "rgba(0,0,0,0.0)"), grd.addColorStop(1, "rgba(0,0,0,0.4)")), graph.fillStyle = grd, graph.fillRect(0, 0, maxScreenWidth, maxScreenHeight)
- } catch (a) {}
- }
- var mapScale = mapCanvas.width,
- pingScale = mapScale / 80;
- mapContext.lineWidth = pingScale / 2;
- var pingFade = .085,
- pingGrow = .4,
- cachedMiniMap = null;
- function getCachedMiniMap() {
- if (null == cachedMiniMap && void 0 != gameMap) {
- var a = document.createElement("canvas"),
- b = a.getContext("2d");
- a.width = mapScale;
- a.height = mapScale;
- for (var d = 0; d < gameMap.tiles.length; ++d) b.fillStyle = "#fff", gameMap.tiles[d].wall && b.fillRect(gameMap.tiles[d].x / gameWidth * mapScale, gameMap.tiles[d].y / gameHeight * mapScale, 1.08 * mapTileScale / gameWidth * mapScale, 1.08 * mapTileScale / gameWidth * mapScale);
- cachedMiniMap = a
- }
- return cachedMiniMap
- }
- function drawMiniMap() {
- mapCanvas.width = mapCanvas.width;
- mapContext.globalAlpha = 1;
- for (var a = 0; a < gameObjects.length; ++a) "player" == gameObjects[a].type && gameObjects[a].onScreen && (gameObjects[a].index == player.index || gameObjects[a].team == player.team || gameObjects[a].isBoss) && (mapContext.fillStyle = gameObjects[a].index == player.index ? "#fff" : gameObjects[a].isBoss ? "#db4fcd" : "#5151d9", mapContext.beginPath(), mapContext.arc(gameObjects[a].x / gameWidth * mapScale, gameObjects[a].y / gameHeight * mapScale, pingScale, 0, 2 * mathPI, !0), mapContext.closePath(), mapContext.fill());
- if (null != gameMap) {
- mapContext.globalAlpha = 1;
- mapContext.fillStyle = "#ffd100";
- for (a = 0; a < gameMap.pickups.length; ++a) gameMap.pickups[a].active && "lootcrate" == gameMap.pickups[a].type && (mapContext.beginPath(), mapContext.arc(gameMap.pickups[a].x / gameWidth * mapScale, gameMap.pickups[a].y / gameHeight * mapScale, pingScale, 0, 2 * mathPI, !0), mapContext.closePath(), mapContext.fill());
- mapContext.globalAlpha = .1;
- a = getCachedMiniMap();
- null != a && mapContext.drawImage(a, 0, 0, mapScale,
- mapScale);
- delete a
- }
- }
- function calculateUIScale() {
- uiScale = (screenHeight + screenWidth) / (originalScreenWidth + originalScreenHeight) * 1.25
- }
- function drawMenuBackground() {}
- function drawUI() {}
- var screenSkX = 0,
- screenShackeScale = 0,
- screenSkY = 0,
- screenSkRed = .5,
- screenSkDir = 0;
- function screenShake(a, b) {
- screenShackeScale < a && (screenShackeScale = a, screenSkDir = b)
- }
- function updateScreenShake(a) {
- 0 < screenShackeScale && (screenSkX = screenShackeScale * mathCOS(screenSkDir), screenSkY = screenShackeScale * mathSIN(screenSkDir), screenShackeScale *= screenSkRed, .1 >= screenShackeScale && (screenShackeScale = 0))
- }
- var userSprays = [],
- sprayMaxScale = 25,
- tmpSpray = tmpPlayer = null,
- cachedSprays = [];
- function createSpray(a, b, d) {
- tmpPlayer = findUserByIndex(a);
- if (null != tmpPlayer) {
- tmpSpray = null;
- for (var e = 0; e < userSprays.length; ++e)
- if (userSprays[e].owner == a) {
- tmpSpray = userSprays[e];
- break
- }
- if (null == tmpSpray) {
- var f = new Image;
- f.owner = a;
- f.active = !1;
- f.xPos = 0;
- f.yPos = 0;
- f.onload = function() {
- cacheSpray(f)
- };
- userSprays.push(f);
- tmpSpray = f
- }
- tmpSpray.active = !0;
- tmpSpray.scale = tmpPlayer.spray.info.scale;
- tmpSpray.alpha = tmpPlayer.spray.info.alpha;
- tmpSpray.xPos = b - tmpSpray.scale / 2;
- tmpSpray.yPos = d - tmpSpray.scale / 2;
- tmpSpray.src !=
- tmpPlayer.spray.src && (tmpSpray.src = tmpPlayer.spray.src)
- }
- }
- function sendSpray() {
- socket.emit("crtSpr")
- }
- function deactivateSprays() {
- for (var a = 0; a < userSprays.length; ++a) userSprays[a].active = !1
- }
- var tmpIndex = 0;
- function cacheSpray(a) {
- tmpIndex = "" + a.src;
- tmpSpray = cachedSprays[tmpIndex];
- if (void 0 == tmpSpray && 0 != a.width) {
- var b = document.createElement("canvas"),
- d = b.getContext("2d");
- b.width = sprayMaxScale;
- b.height = sprayMaxScale;
- d.drawImage(a, 0, 0, sprayMaxScale, sprayMaxScale);
- var d = document.createElement("canvas"),
- e = d.getContext("2d");
- d.width = a.scale;
- d.height = a.scale;
- e.imageSmoothingEnabled = !1;
- e.webkitImageSmoothingEnabled = !1;
- e.mozImageSmoothingEnabled = !1;
- e.globalAlpha = a.alpha;
- e.drawImage(b, 0, 0, a.scale, a.scale);
- tmpSpray =
- d;
- cachedSprays[tmpIndex] = tmpSpray
- }
- }
- function drawSprays() {
- if (showSprays)
- for (var a = 0; a < userSprays.length; ++a) userSprays[a].active && (tmpSpray = cachedSprays["" + userSprays[a].src], void 0 != tmpSpray && graph.drawImage(tmpSpray, userSprays[a].xPos - startX, userSprays[a].yPos - startY))
- }
- var soundList = [{
- loc: "weapons/smg",
- id: "shot0",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/revolver",
- id: "shot1",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/sniper",
- id: "shot2",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/toygun",
- id: "shot3",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/shotgun",
- id: "shot4",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/grenades",
- id: "shot5",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/rockets",
- id: "shot6",
- sound: null,
- loop: !1
- }, {
- loc: "weapons/pistol",
- id: "shot7",
- sound: null,
- loop: !1
- }, {
- loc: "characters/footstep1",
- id: "step1",
- sound: null,
- loop: !1
- }, {
- loc: "characters/jump1",
- id: "jump1",
- sound: null,
- loop: !1
- }, {
- loc: "characters/death1",
- id: "death1",
- sound: null,
- loop: !1
- }, {
- loc: "characters/kill1",
- id: "kill1",
- sound: null,
- loop: !1
- }, {
- loc: "special/explosion",
- id: "explosion",
- sound: null,
- loop: !1
- }, {
- loc: "special/score",
- id: "score",
- sound: null,
- loop: !1
- }, {
- loc: "tracks/track1",
- id: "track1",
- sound: null,
- loop: !0,
- onload: function() {
- tmpList.track1.sound.play();
- !player.dead || startingGame ? tmpList.track1.sound.mute() : currentTrack = 1
- }
- }, {
- loc: "tracks/track2",
- id: "track2",
- sound: null,
- loop: !0,
- onload: function() {
- tmpList.track2.sound.play();
- player.dead || !gameStart || gameOver ? tmpList.track2.sound.mute() : currentTrack = 2
- }
- }],
- tmpSound = null,
- tmpFormat = null,
- tmpList = [],
- doSounds = !1;
- function loadSounds(a) {
- if (!doSounds) return !1;
- tmpList = [];
- for (var b = 0; b < soundList.length; ++b) tmpSound = localStorage.getItem(a + soundList[b].loc + "data"), tmpFormat = localStorage.getItem(a + soundList[b].loc + "format"), loadSound(tmpSound, soundList[b], tmpFormat)
- }
- function loadSound(a, b, d) {
- void 0 != tmpList[b.id] && null != tmpList[b.id].sound && tmpList[b.id].sound.stop();
- tmpList[b.id] = b;
- tmpList[b.id].sound = new Howl({
- urls: [a],
- format: [d],
- loop: b.loop,
- onload: b.onload || function() {}
- })
- }
- var currentTrack = 0;
- function startSoundTrack(a) {
- if (!doSounds) return !1;
- try {
- 1 == a ? (currentTrack != a && (currentTrack = a, tmpList.track1.sound.fade(0, 1, 1E3)), tmpList.track2.sound.mute()) : (currentTrack != a && (currentTrack = a, tmpList.track2.sound.fade(0, 1, 1E3)), tmpList.track1.sound.mute())
- } catch (b) {
- console.log(b)
- }
- }
- var maxHearDist = 1500,
- tmpDist = 0;
- function playSound(a, b, d) {
- if (!kicked && doSounds) try {
- tmpDist = getDistance(player.x, player.y, b, d), tmpDist <= maxHearDist && (tmpSound = tmpList[a], void 0 != tmpSound && (tmpSound = tmpSound.sound, tmpSound.volume(mathRound(10 * (1 - tmpDist / maxHearDist)) / 10), tmpSound.play()))
- } catch (e) {
- console.log(e)
- }
- }
- function stopAllSounds() {
- if (!doSounds) return !1;
- for (var a = 0; a < soundList.length; ++a) tmpList[soundList[a].id].sound.stop()
- }
- var spritesLoaded = !1,
- spriteIndex = 0,
- tmpPicture = null;
- function getSprite(a) {
- var b = new Image;
- b.index = spriteIndex;
- b.flipped = !1;
- b.isLoaded = !1;
- b.onload = function() {
- b.isLoaded = !0;
- b.onload = null
- };
- b.onerror = function() {
- b.isLoaded = !1;
- console.log("File not Found: " + a + ".png")
- };
- try {
- tmpPicture = localStorage.getItem(a + ".png"), b.src = tmpPicture
- } catch (d) {
- console.log(d)
- }
- spriteIndex++;
- return b
- }
- function flipSprite(a, b) {
- try {
- var d = document.createElement("canvas"),
- e = d.getContext("2d");
- d.width = a.width;
- d.height = a.height;
- e.imageSmoothingEnabled = !1;
- e.webkitImageSmoothingEnabled = !1;
- e.mozImageSmoothingEnabled = !1;
- b ? (e.scale(-1, 1), e.drawImage(a, -d.width, 0, d.width, d.height)) : (e.scale(1, -1), e.drawImage(a, 0, -d.height, d.width, d.height));
- a.src = d.toDataURL();
- return a
- } catch (f) {
- console.log(f)
- }
- }
- var tmpSprite = null;
- function getWeaponSprite(a, b) {
- try {
- var d = weaponSpriteSheet[a];
- void 0 != d && (90 == b ? tmpSprite = d.leftSprite : 180 == b ? tmpSprite = d.upSprite : 270 == b ? (!d.rightSprite.flipped && d.rightSprite.isLoaded && (d.rightSprite = flipSprite(d.rightSprite, !0), d.rightSprite.flipped = !0), tmpSprite = d.rightSprite) : tmpSprite = d.downSprite);
- delete d;
- return tmpSprite
- } catch (e) {
- console.log(e)
- }
- }
- function Projectile() {
- this.speed = this.width = this.height = this.jumpY = this.yOffset = this.dir = this.cEndY = this.cEndX = this.startY = this.y = this.startX = this.x = 0;
- this.active = !1;
- this.speed = this.trailWidth = this.trailMaxLength = this.trailAlpha = this.weaponIndex = this.spriteIndex = 0;
- this.owner = null;
- this.dmg = 0;
- this.serverIndex = this.lastHit = null;
- this.skipMove = !0;
- this.startTime = 0;
- this.maxLifeTime = null;
- this.bounce = this.explodeOnDeath = !1;
- var a = 0,
- b = 0,
- d = 0,
- e = 0;
- this.update = function(f) {
- if (this.active) {
- e = currentTime - this.startTime;
- this.skipMove && (e = 0, this.startTime = currentTime);
- for (var h = 0; 2 > h; ++h) {
- var m = this.speed * f;
- if (this.active) {
- a = m * mathCOS(this.dir) / 2;
- b = m * mathSIN(this.dir) / 2;
- this.active && !this.skipMove && 0 < this.speed && (this.x += a, this.y += b, getDistance(this.startX, this.startY, this.x, this.y) >= this.trailMaxLength && (this.startX += a, this.startY += b));
- this.cEndX = this.x + (m + this.height) * mathCOS(this.dir) / 2;
- this.cEndY = this.y + (m + this.height) * mathSIN(this.dir) / 2;
- for (m = 0; m < gameObjects.length; ++m) k = gameObjects[m], this.active && "clutter" ==
- k.type && k.active && k.hc && this.canSeeObject(k, k.h) && k.h * k.tp >= this.yOffset && this.lineInRect(k.x, k.y - k.h, k.w, k.h - this.yOffset) && (this.bounce ? this.bounceDir(this.cEndY <= k.y - k.h || this.cEndY >= k.y - this.yOffset) : (this.active = !1, this.hitSomething(!1, 2)));
- if (this.active)
- for (var k, m = 0; m < gameMap.tiles.length; ++m) this.active && (k = gameMap.tiles[m], k.wall && k.hasCollision && this.canSeeObject(k, k.scale) && (k.bottom ? this.lineInRect(k.x, k.y, k.scale, k.scale) && (this.active = !1) : this.lineInRect(k.x, k.y, k.scale, k.scale - this.owner.height -
- this.jumpY) && (this.active = !1), this.active || (this.bounce ? this.bounceDir(!(this.cEndX <= k.x || this.cEndX >= k.x + k.scale)) : this.hitSomething(!(this.cEndX <= k.x || this.cEndX >= k.x + k.scale), 2))));
- if (this.active && this.owner.index == player.index)
- for (m = 0; m < gameObjects.length && (k = gameObjects[m], k.index == this.owner.index || k.team == this.owner.team || "player" != k.type || !k.onScreen || k.dead || (this.lineInRect(k.x - k.width / 2, k.y - k.height - k.jumpY, k.width, k.height) && 0 >= k.spawnProtection && (this.explodeOnDeath ? this.active = !1 : 0 <
- this.dmg && this.lastHit != k && (this.lastHit = k, particleCone(12, k.x, k.y - k.height / 2 - k.jumpY, this.dir + mathPI, mathPI / randomInt(5, 7), .5, 16, 0, !0), createLiquid(k.x, k.y, this.dir, 4), 0 < this.pierceCount ? this.pierceCount-- : this.active = !1)), this.active)); ++m);
- null != this.maxLifeTime && e >= this.maxLifeTime && (this.active = !1)
- }
- }
- 1 == this.spriteIndex && (d -= f, 0 >= d && (stillDustParticle(this.x, this.y, !0), d = 20))
- } else !this.active && 0 < this.trailAlpha && (this.trailAlpha -= .001 * f, 0 >= this.trailAlpha && (this.trailAlpha = 0));
- this.skipMove = !1
- };
- this.activate = function() {
- this.skipMove = !0;
- this.lastHit = null;
- this.active = !0;
- playSound("shot" + this.weaponIndex, this.x, this.y)
- };
- var f = 0,
- h = 0;
- this.canSeeObject = function(a, b) {
- f = mathABS(this.cEndX - a.x);
- h = mathABS(this.cEndY - a.y);
- return f <= 2 * (b + this.height) && h <= 2 * (b + this.height)
- };
- this.deactivate = function() {
- this.active = !1
- };
- this.hitSomething = function(a, b) {
- particleCone(10, this.cEndX, this.cEndY, this.dir + mathPI, mathPI / randomInt(5, 7), .5, 16, b, a)
- };
- this.bounceDir = function(a) {
- this.dir = a ? 2 * mathPI - this.dir : mathPI - this.dir;
- this.active = !0;
- this.speed *= .65;
- this.x = this.cEndX;
- this.y = this.cEndY
- };
- this.lineInRect = function(a, b, d, e) {
- var f = this.x,
- h = this.y,
- p = f,
- t = this.cEndX;
- p > t && (p = this.cEndX, t = f);
- t > a + d && (t = a + d);
- p < a && (p = a);
- if (p > t) return !1;
- var r = h,
- q = this.cEndY,
- v = this.cEndX - f;
- 1E-7 < mathABS(v) && (q = (this.cEndY - h) / v, f = h - q * f, r = q * p + f, q = q * t + f);
- r > q && (p = q, q = r, r = p);
- q > b + e && (q = b + e);
- r < b && (r = b);
- if (r > q) return !1;
- this.adjustOnCollision(a, b, d, e);
- return !0
- };
- this.dotInRect = function(a, b, d, e, f, h) {
- return a >= d && a <= d + f && b >= e && b <= e + h
- };
- this.adjustOnCollision =
- function(a, b, d, e) {
- for (var f = 100, h = this.cEndX, p = this.cEndY; 0 < f;) f--, this.dotInRect(h, p, a, b, d, e) ? f = 0 : (h += 2 * mathCOS(this.dir + mathPI), p += 2 * mathSIN(this.dir + mathPI));
- for (f = 100; 0 < f;) f--, this.dotInRect(h, p, a, b, d, e) ? (h += 2 * mathCOS(this.dir + mathPI), p += 2 * mathSIN(this.dir + mathPI)) : f = 0;
- this.cEndX = h;
- this.cEndY = p;
- this.x = this.cEndX;
- this.y = this.cEndY
- }
- }
- var bulletIndex = 0;
- function getNextBullet() {
- bulletIndex++;
- bulletIndex >= bullets.length && (bulletIndex = 0);
- return bullets[bulletIndex]
- }
- function getCurrentWeapon(a) {
- return void 0 != a.weapons && void 0 != a.weapons[a.currentWeapon] ? a.weapons[a.currentWeapon] : null
- }
- function playerSwapWeapon(a, b) {
- null == a || a.dead || (a.currentWeapon += b, 0 > a.currentWeapon && (a.currentWeapon = a.weapons.length - 1), a.currentWeapon >= a.weapons.length && (a.currentWeapon = 0), playerEquipWeapon(a, a.currentWeapon), updateWeaponUI(a, !1), socket.emit("sw", a.currentWeapon))
- }
- function playerEquipWeapon(a, b) {
- a.currentWeapon = b
- }
- var actionBar = document.getElementById("actionBar"),
- tmpDiv = null;
- function updateWeaponUI(a, b) {
- if (void 0 == weaponSpriteSheet[0]) return !1;
- b && (actionBar.innerHTML = "");
- if ("" == actionBar.innerHTML)
- for (var d = 0; d < a.weapons.length; ++d) {
- var e = document.createElement("div");
- e.id = "actionContainer" + d;
- e.className = d == a.currentWeapon ? "actionContainerActive" : "actionContainer";
- tmpDiv = weaponSpriteSheet[a.weapons[d].weaponIndex].icon;
- tmpDiv.className = "actionItem";
- var f = document.createElement("div");
- f.id = "actionCooldown" + d;
- f.className = "actionCooldown";
- e.appendChild(f);
- e.appendChild(tmpDiv);
- actionBar.appendChild(e)
- } else
- for (d = 0; d < a.weapons.length; ++d) tmpDiv = document.getElementById("actionContainer" + d), tmpDiv.className = d == a.currentWeapon ? "actionContainerActive" : "actionContainer";
- updateUiStats(a)
- }
- function setCooldownAnimation(a, b, d) {
- tmpDiv = document.getElementById("actionCooldown" + a);
- d ? (tmpDiv.style.height = "100%", $("#actionCooldown" + a).animate({
- height: "0%"
- }, b)) : tmpDiv.style.height = "0%"
- }
- function shootNextBullet(a, b) {
- var d = getNextBullet();
- void 0 != d && (d.serverIndex = a.si, d.x = a.x, d.startX = a.x, d.y = a.y, d.startY = a.y, d.dir = a.d, d.speed = getCurrentWeapon(b).bSpeed, d.width = getCurrentWeapon(b).bWidth, d.trailWidth = .7 * d.width, d.height = getCurrentWeapon(b).bHeight, d.trailMaxLength = mathRound(5 * d.height), d.trailAlpha = getCurrentWeapon(b).bTrail, d.weaponIndex = getCurrentWeapon(b).weaponIndex, d.spriteIndex = getCurrentWeapon(b).bSprite, d.yOffset = getCurrentWeapon(b).yOffset, d.jumpY = b.jumpY, d.owner = b, d.dmg =
- getCurrentWeapon(b).dmg, d.bounce = getCurrentWeapon(b).bounce, d.startTime = currentTime, d.maxLifeTime = getCurrentWeapon(b).maxLife, b.index == player.index && getCurrentWeapon(b).distBased && (d.maxLifeTime = target.d / d.speed), d.explodeOnDeath = getCurrentWeapon(b).explodeOnDeath, d.pierceCount = getCurrentWeapon(b).pierceCount, d.activate(), console.log(b.x));
- delete d
- }
- function shootBullet(a) {
- if (!a.dead && void 0 != getCurrentWeapon(a) && 0 == a.spawnProtection)
- if (0 <= getCurrentWeapon(a).weaponIndex && 0 >= getCurrentWeapon(a).reloadTime && 0 < getCurrentWeapon(a).ammo) {
- screenShake(getCurrentWeapon(a).shake, target.f);
- for (var b = 0; b < getCurrentWeapon(a).bulletsPerShot; ++b) {
- getCurrentWeapon(a).spreadIndex++;
- getCurrentWeapon(a).spreadIndex >= getCurrentWeapon(a).spread.length && (getCurrentWeapon(a).spreadIndex = 0);
- var d = getCurrentWeapon(a).spread[getCurrentWeapon(a).spreadIndex],
- d = (target.f +
- mathPI + d).round(2),
- e = getCurrentWeapon(a).holdDist + getCurrentWeapon(a).bDist,
- f = mathRound(a.x + e * mathCOS(d)),
- e = mathRound(a.y - getCurrentWeapon(a).yOffset - a.jumpY + e * mathSIN(d));
- shootNextBullet({
- x: f,
- y: e,
- d: d,
- si: -1
- }, a)
- }
- socket.emit("1", target.f, target.d, currentTime);
- getCurrentWeapon(a).lastShot = currentTime;
- getCurrentWeapon(a).ammo--;
- 0 >= getCurrentWeapon(a).ammo && playerReload(a);
- updateUiStats(a)
- } else 0 <= getCurrentWeapon(a).weaponIndex && 0 >= getCurrentWeapon(a).reloadTime && playerReload(a)
- }
- function playerReload(a) {
- 0 >= getCurrentWeapon(a).reloadTime && getCurrentWeapon(a).ammo != getCurrentWeapon(a).maxAmmo && (getCurrentWeapon(a).reloadTime = getCurrentWeapon(a).reloadSpeed, showNotification("Reloading"), socket.emit("r"), setCooldownAnimation(a.currentWeapon, getCurrentWeapon(a).reloadTime, !0))
- }
- function findServerBullet(a) {
- for (var b = 0; b < bullets.length; ++b)
- if (bullets[b].serverIndex == a) return bullets[b]
- }
- function someoneShot(a) {
- a.i != player.index && (tmpPlayer = findUserByIndex(a.i), null != tmpPlayer && shootNextBullet(a, tmpPlayer))
- }
- var trailGrad = null;
- function updateBullets(a) {
- var b, d;
- graph.globalAlpha = 1;
- for (var e, f, h = null, g = 0; g < bullets.length; g++) h = bullets[g], h.update(a), bullets[g].active && (b = h.x - startX, d = h.y - startY, canSee(b, d, h.height, h.height) && (graph.save(), graph.translate(b, d), drawSprite(graph, bulletSprites[h.spriteIndex], -(h.width / 2), 0, h.width, h.height + 8, h.dir - mathPI / 2, !1, 0, 0, 0), graph.restore())), showParticles && 0 < h.trailAlpha && (graph.save(), b = mathRound(h.startX - startX), d = mathRound(h.startY - startY), e = mathRound(h.x - startX), f = mathRound(h.y -
- startY), trailGrad = graph.createLinearGradient(b, d, e, f), trailGrad.addColorStop(0, "rgba(255, 255, 255, 0)"), trailGrad.addColorStop(1, "rgba(255, 255, 255, " + h.trailAlpha + ")"), graph.strokeStyle = trailGrad, graph.lineWidth = h.trailWidth, graph.beginPath(), graph.moveTo(b, d), graph.lineTo(e, f), graph.closePath(), graph.stroke(), graph.restore());
- delete h
- }
- var weaponNames = "smg revolver sniper toygun shotgun grenades rockets pistol".split(" "),
- characterClasses = [{
- classN: "Triggerman",
- name: "Tony Cavalaro",
- weapon: "Machine Gun & Grenades",
- desc: "Firerate ++<br />Accuracy +",
- folderName: "triggerman",
- hasDown: !1
- }, {
- classN: "Detective",
- name: "Valentine",
- weapon: "Revolver & Grenades",
- desc: "Damage ++<br />Mobility +",
- folderName: "detective",
- hasDown: !1
- }, {
- classN: "Hunter",
- name: "John Nash",
- weapon: "Sniper & Pistol",
- desc: "Damage +++<br />Vision ++<br />Health - -",
- folderName: "hunter",
- hasDown: !0
- }, {
- classN: "Run 'N Gun",
- name: "Billy the Kid",
- weapon: "Toy Blaster",
- desc: "Firerate +++<br />Mobility ++<br />Accuracy - -<br />Damage - -",
- folderName: "billy",
- hasDown: !1
- }, {
- classN: "Vince",
- name: "Vincent de Vries",
- weapon: "Shotgun & Grenades",
- desc: "Damage +<br />Spread ++",
- folderName: "vinc",
- hasDown: !1
- }, {
- classN: "Rocketeer",
- name: "General Weiss",
- weapon: "Rockets",
- desc: "Damage +++<br />Health ++<br />Mobility - -",
- folderName: "rocketeer",
- hasDown: !1
- }],
- specialClasses = [{
- weapon: "???",
- name: "???",
- folderName: "boss1",
- hasDown: !1
- }],
- currentClassID = 0,
- currentClass = document.getElementById("currentClass"),
- classList = document.getElementById("classList"),
- characterWepnDisplay = document.getElementById("charWpn");
- function createClassList() {
- for (var a = "", b = 0; b < characterClasses.length; ++b) a += "<div class='hatSelectItem' id='classItem" + b + "' onclick='pickedCharacter(" + b + ");'>" + characterClasses[b].classN + "<div class='hoverTooltip' style='width:200px'><div style='font-size:16px; margin-top:5px;'>" + characterClasses[b].name + "</div><div style='color:#ffd100; font-size:12px; margin-top:5px;'>" + characterClasses[b].weapon + "</div><div style='font-size:12px; margin-top:5px; color:#d8d8d8;'>" + characterClasses[b].desc + "</div></div></div>";
- classList.innerHTML = a
- }
- createClassList();
- function showClassselector() {
- charSelectorCont.style.display = "none";
- lobbySelectorCont.style.display = "none";
- classSelector.style.display = "block"
- }
- "" != getCookie("previousClass") ? (previousClass = getCookie("previousClass"), pickedCharacter(previousClass)) : pickedCharacter(0);
- function pickedCharacter(a) {
- currentClassID = a;
- currentClass.innerHTML = document.getElementById("classItem" + a).innerHTML;
- currentClass.style.color = document.getElementById("classItem" + a).style.color;
- characterWepnDisplay.innerHTML = "<b>Gear: </b>" + characterClasses[a].weapon;
- setCookie("previousClass", a);
- charSelectorCont.style.display = "block";
- lobbySelectorCont.style.display = "block";
- classSelector.style.display = "none";
- lobbySelector.style.display = "none";
- lobbyCSelector.style.display = "none";
- hatSelector.style.display =
- "none";
- spraySelector.style.display = "none"
- }
- var animLength = 3,
- tmpSprite = null,
- tmpIndex = 0,
- classSpriteSheets = [];
- function loadPlayerSprites(a) {
- classSpriteSheets = [];
- loadPlayerSpriteArray(a, characterClasses);
- loadPlayerSpriteArray(a, specialClasses);
- resize()
- }
- function loadPlayerSpriteArray(a, b) {
- for (var d = 0; d < b.length; ++d) {
- var e = [],
- f = [],
- h = [],
- g = [];
- e.push(getSprite(a + "characters/" + b[d].folderName + "/up"));
- f.push(getSprite(a + "characters/" + b[d].folderName + "/down"));
- h.push(getSprite(a + "characters/" + b[d].folderName + "/left"));
- g.push(getSprite(a + "characters/" + b[d].folderName + "/left"));
- for (var l = 0; l < animLength; ++l) tmpIndex = l, e.push(getSprite(a + "characters/" + b[d].folderName + "/up" + (tmpIndex + 1))), tmpSprite = b[d].hasDown ? getSprite(a + "characters/" + b[d].folderName + "/down" +
- (tmpIndex + 1)) : getSprite(a + "characters/" + b[d].folderName + "/up" + (tmpIndex + 1)), f.push(tmpSprite), 2 <= tmpIndex && (tmpIndex = 0), h.push(getSprite(a + "characters/" + b[d].folderName + "/left" + (tmpIndex + 1))), g.push(getSprite(a + "characters/" + b[d].folderName + "/left" + (tmpIndex + 1)));
- var l = getSprite(a + "characters/" + b[d].folderName + "/arm"),
- m = getSprite(a + "characters/" + b[d].folderName + "/hd"),
- k = getSprite(a + "characters/" + b[d].folderName + "/hu"),
- u = getSprite(a + "characters/" + b[d].folderName + "/hl"),
- w = getSprite(a + "characters/" +
- b[d].folderName + "/hl");
- classSpriteSheets.push({
- upSprites: e,
- downSprites: f,
- leftSprites: h,
- rightSprites: g,
- arm: l,
- hD: m,
- hU: k,
- hL: u,
- hR: w
- })
- }
- }
- var flagSprites = [],
- clutterSprites = [],
- cachedWalls = [],
- floorSprites = [],
- cachedFloors = [],
- sideWalkSprite = null,
- ambientSprites = [],
- wallSpritesSeg = [],
- particleSprites = [],
- weaponSpriteSheet = [],
- bulletSprites = [],
- cachedShadows = [],
- wallSprite = null,
- darkFillerSprite = null,
- healthPackSprite = null,
- lootCrateSprite = null,
- weaponWidth = 27,
- weaponHeight = 54;
- function loadDefaultSprites(a) {
- cachedShadows = [];
- flagSprites = [];
- clutterSprites = [];
- cachedWalls = [];
- cachedFloors = [];
- floorSprites = [];
- ambientSprites = [];
- wallSpritesSeg = [];
- particleSprites = [];
- flagSprites.push(getSprite(a + "flags/flagw1"));
- flagSprites.push(getSprite(a + "flags/flagw2"));
- flagSprites.push(getSprite(a + "flags/flagw3"));
- clutterSprites.push(getSprite(a + "clutter/crate1"));
- clutterSprites.push(getSprite(a + "clutter/barrel1"));
- clutterSprites.push(getSprite(a + "clutter/barrel2"));
- clutterSprites.push(getSprite(a +
- "clutter/bottle1"));
- clutterSprites.push(getSprite(a + "clutter/spike1"));
- wallSprite = getSprite(a + "wall1");
- ambientSprites.push(getSprite(a + "ambient1"));
- darkFillerSprite = getSprite(a + "darkfiller");
- floorSprites.push(getSprite(a + "ground1"));
- floorSprites.push(getSprite(a + "ground2"));
- floorSprites.push(getSprite(a + "ground3"));
- sideWalkSprite = getSprite(a + "sidewalk1");
- wallSpritesSeg.push(getSprite(a + "wallSegment1"));
- wallSpritesSeg.push(getSprite(a + "wallSegment2"));
- wallSpritesSeg.push(getSprite(a + "wallSegment3"));
- particleSprites.push(getSprite(a + "particles/blood/blood"));
- particleSprites.push(getSprite(a + "particles/oil/oil"));
- particleSprites.push(getSprite(a + "particles/wall"));
- particleSprites.push(getSprite(a + "particles/hole"));
- particleSprites.push(getSprite(a + "particles/blood/splatter1"));
- particleSprites.push(getSprite(a + "particles/blood/splatter2"));
- particleSprites.push(getSprite(a + "particles/explosion"));
- healthPackSprite = getSprite(a + "healthpack");
- lootCrateSprite = getSprite(a + "lootCrate1");
- weaponSpriteSheet = [];
- for (var b = 0; b < weaponNames.length; ++b) {
- var d, e, f, h, g;
- d = getSprite(a + "weapons/" + weaponNames[b] + "/up");
- e = getSprite(a + "weapons/" + weaponNames[b] + "/up");
- f = getSprite(a + "weapons/" + weaponNames[b] + "/left");
- h = getSprite(a + "weapons/" + weaponNames[b] + "/left");
- g = getSprite(a + "weapons/" + weaponNames[b] + "/icon");
- weaponSpriteSheet.push({
- upSprite: d,
- downSprite: e,
- leftSprite: f,
- rightSprite: h,
- icon: g
- })
- }
- bulletSprites.push(getSprite(a + "weapons/bullet"));
- bulletSprites.push(getSprite(a + "weapons/grenade"));
- resize()
- }
- var mainTitleText = document.getElementById("mainTitleText");
- function updateMenuInfo(a) {
- mainTitleText.innerHTML = a
- }
- var linkedMod = location.hash.replace("#", "");
- loadModPack(linkedMod, "" == linkedMod);
- var loadingTexturePack = !1,
- modInfo = document.getElementById("modInfo");
- function setModInfoText(a) {
- void 0 != modInfo && (modInfo.innerHTML = a)
- }
- var fileFormat = "";
- function loadModPack(a, b) {
- try {
- if (!loadingTexturePack) {
- var d = function() {
- this.numFiles;
- this.progress;
- this.reader;
- this.init = function(a, b) {
- this.numFiles = b;
- this.progress = 0;
- this.reader = a
- };
- this.close = function() {
- this.reader ? (this.progress++, this.numFiles === this.progress && (spriteIndex = 0, loadPlayerSprites("sprites/"), loadDefaultSprites("sprites/"), loadSounds("sounds/"), localStorage.clear(), this.reader.close(), this.reader = void 0, loadingTexturePack = !1)) : console.log("reader not valid")
- }
- },
- e = function(a) {
- this.typeName =
- a;
- var b = this;
- this.process = function(a) {
- try {
- if (-1 < b.typeName.indexOf("modinfo")) setModInfoText(a);
- else if (-1 < b.typeName.indexOf("cssmod")) {
- var d = document.createElement("style");
- d.type = "text/css";
- d.innerHTML = a;
- document.getElementsByTagName("head")[0].appendChild(d)
- } else if (-1 < b.typeName.indexOf("gameinfo")) {
- var e = a.replace(/(\r\n|\n|\r)/gm, ""),
- f = JSON.parse(e);
- updateMenuInfo(f.name)
- } else if (-1 < b.typeName.indexOf("charinfo")) {
- var h = a.replace(/(\r\n|\n|\r)/gm, "").split("|");
- characterClasses = [];
- for (a = 0; a <
- h.length; ++a) characterClasses.push(JSON.parse(h[a]));
- createClassList();
- pickedCharacter(currentClassID)
- }
- } catch (g) {
- console.log("Script Read Error: " + g)
- }
- zipFileCloser.close()
- }
- },
- f = function(a, b) {
- this.filename = a;
- this.soundAsDataURL = this.tmpLocation = "";
- this.format = b;
- var d = this;
- this.process = function(a) {
- if (this.soundAsDataURL = URL.createObjectURL(a)) {
- try {
- this.tmpLocation = d.filename, localStorage.setItem(this.tmpLocation + "data", this.soundAsDataURL), localStorage.setItem(this.tmpLocation + "format", d.format)
- } catch (b) {
- console.log("Storage failed: " +
- b)
- }
- zipFileCloser.close()
- } else console.log("failed to generate url: " + d.filename)
- }
- },
- h = function(a) {
- this.filename = a;
- this.imgAsDataURL = this.tmpLocation = "";
- var b = this;
- this.process = function(a) {
- if (this.imgAsDataURL = URL.createObjectURL(a)) {
- try {
- this.tmpLocation = b.filename, localStorage.setItem(this.tmpLocation, this.imgAsDataURL)
- } catch (d) {
- console.log("Storage failed: " + d)
- }
- zipFileCloser.close()
- } else console.log("failed to generate url: " + b.filename)
- }
- },
- g = "";
- if (b) doSounds = !1, g = ".././res.zip";
- else {
- if ("" == a) return setModInfoText("Please enter a mod Key"), !1;
- a += "/vertixmod.zip";
- loadingTexturePack = doSounds = !0;
- g = "https://dl.dropboxusercontent.com/s/" + a
- }
- b || setModInfoText("Loading...");
- zipFileCloser || (zipFileCloser = new d);
- var l = "";
- zip.createReader(new zip.HttpReader(g), function(a) {
- a.getEntries(function(b) {
- if (b.length) {
- zipFileCloser.init(a, b.length);
- for (var d = 0; d < b.length; d++) {
- var g = b[d];
- g.directory ? zipFileCloser.close() : (g.filename = g.filename.replace("vertixmod/", ""), fileFormat = g.filename.split(".")[g.filename.split(".").length - 1], l = g.filename.split("/")[0],
- "scripts" == l ? g.getData(new zip.TextWriter, (new e(g.filename)).process, function(a, b) {}) : "sprites" == l ? g.getData(new zip.BlobWriter("image/png"), (new h(g.filename)).process, function(a, b) {}) : "sounds" == l ? g.getData(new zip.BlobWriter("audio/" + fileFormat), (new f(g.filename.replace("." + fileFormat, ""), fileFormat)).process, function(a, b) {}) : (loadingTexturePack = !1, setModInfoText("Mod could not be loaded")))
- }
- }
- })
- }, function(a) {
- loadingTexturePack = !1;
- console.log(a);
- setModInfoText("Mod could not be loaded")
- })
- }
- } catch (m) {
- console.log(m),
- loadingTexturePack = !1, setModInfoText("Mod could not be loaded")
- }
- }
- function getPlayerSprite(a, b, d) {
- tmpSpriteCollection = classSpriteSheets[a];
- if (void 0 == tmpSpriteCollection) return null;
- 90 == b ? tmpSprite = tmpSpriteCollection.leftSprites[d] : 180 == b ? tmpSprite = tmpSpriteCollection.upSprites[d] : 270 == b ? (!tmpSpriteCollection.rightSprites[d].flipped && tmpSpriteCollection.rightSprites[d].isLoaded && (tmpSpriteCollection.rightSprites[d] = flipSprite(tmpSpriteCollection.rightSprites[d], !0), tmpSpriteCollection.rightSprites[d].flipped = !0), tmpSprite = tmpSpriteCollection.rightSprites[d]) : tmpSprite =
- tmpSpriteCollection.downSprites[d];
- return tmpSprite
- }
- var cachedHats = [],
- tmpAcc = null;
- function getHatSprite(a, b) {
- tmpAcc = a.account;
- if (void 0 != tmpAcc)
- if (null != tmpAcc.hat)
- if (tmpSprite = cachedHats[tmpAcc.hat.id], void 0 == tmpSprite) {
- var d = {
- lS: null,
- uS: null,
- rS: null,
- dS: null,
- imgToLoad: 0
- };
- tmpAcc.hat.left && (d.imgToLoad++, d.lS = new Image, d.lS.index = spriteIndex, spriteIndex++, d.lS.src = ".././images/hats/" + tmpAcc.hat.id + "/l.png", d.lS.onload = function() {
- d.imgToLoad--;
- d.lS.isLoaded = !0;
- d.lS.onload = null
- }, d.imgToLoad++, d.rS = new Image, d.rS.index = spriteIndex, spriteIndex++, d.rS.src = ".././images/hats/" + tmpAcc.hat.id +
- "/l.png", d.rS.onload = function() {
- d.rS = flipSprite(d.rS, !0);
- d.imgToLoad--;
- d.rS.isLoaded = !0;
- d.rS.onload = null
- });
- tmpAcc.hat.up && (d.imgToLoad++, d.uS = new Image, d.uS.index = spriteIndex, spriteIndex++, d.uS.src = ".././images/hats/" + tmpAcc.hat.id + "/u.png", d.uS.onload = function() {
- d.imgToLoad--;
- d.uS.isLoaded = !0;
- d.uS.onload = null
- });
- d.imgToLoad++;
- d.dS = new Image;
- d.dS.index = spriteIndex;
- spriteIndex++;
- d.dS.src = ".././images/hats/" + tmpAcc.hat.id + "/d.png";
- d.dS.onload = function() {
- d.imgToLoad--;
- d.dS.isLoaded = !0;
- d.dS.onload = null
- };
- cachedHats[tmpAcc.hat.id] = d
- } else {
- if (0 >= tmpSprite.imgToLoad) return tmpAcc.hat.left && 90 == b ? tmpSprite.lS : tmpAcc.hat.up && 180 == b ? tmpSprite.uS : tmpAcc.hat.left && 270 == b ? tmpSprite.rS : tmpSprite.dS
- }
- else {
- tmpSpriteCollection = classSpriteSheets[a.classIndex];
- if (void 0 == tmpSpriteCollection) return null;
- 90 == b ? tmpSprite = tmpSpriteCollection.hL : 180 == b ? tmpSprite = tmpSpriteCollection.hU : 270 == b ? (!tmpSpriteCollection.hR.flipped && tmpSpriteCollection.hR.isLoaded && (tmpSpriteCollection.hR = flipSprite(tmpSpriteCollection.hR, !0),
- tmpSpriteCollection.hR.flipped = !0), tmpSprite = tmpSpriteCollection.hR) : tmpSprite = tmpSpriteCollection.hD;
- return tmpSprite
- }
- return null
- }
- var playerCanvas = document.createElement("canvas"),
- playerContext = playerCanvas.getContext("2d"),
- initPlayerCanv = !1;
- function drawGameObjects(a) {
- initPlayerCanv || (playerCanvas.width = mathRound(300), playerCanvas.height = mathRound(500), playerContext.imageSmoothingEnabled = !1, playerContext.webkitImageSmoothingEnabled = !1, playerContext.mozImageSmoothingEnabled = !1, initPlayerCanv = !0);
- for (var b = null, d = null, e = null, f = null, h, g, l = 0; l < gameObjects.length; l++)
- if (b = gameObjects[l], "player" == b.type) {
- if (!b.dead && (b.index == player.index || b.onScreen)) {
- void 0 == b.jumpY && (b.jumpY = 0);
- playerContext.clearRect(0, 0, playerCanvas.width, playerCanvas.height);
- playerContext.save();
- playerContext.globalAlpha = .9;
- playerContext.translate(playerCanvas.width / 2, playerCanvas.height / 2);
- var m = mathPI / 180 * b.angle,
- k = 90 * mathRound(b.angle % 360 / 90);
- h = b.x - startX;
- g = b.y - b.jumpY - startY;
- 1 == b.animIndex && (g -= 3);
- e = getWeaponSprite(getCurrentWeapon(b).weaponIndex, k);
- f = classSpriteSheets[b.classIndex];
- void 0 != f && (f = f.arm);
- getCurrentWeapon(b).front || void 0 == e || (playerContext.save(), playerContext.translate(0, -getCurrentWeapon(b).yOffset), playerContext.rotate(m), playerContext.translate(0,
- getCurrentWeapon(b).holdDist), drawSprite(playerContext, e, -(getCurrentWeapon(b).width / 2), 0, getCurrentWeapon(b).width, getCurrentWeapon(b).length, 0, !1, 0, 0, 0), playerContext.translate(0, -getCurrentWeapon(b).holdDist + 6), void 0 != f && null != f && (playerContext.translate(3, -10), drawSprite(playerContext, f, 0, 0, 8, 32, 0, !1, 0, 0, 0), playerContext.translate(-16, -8), drawSprite(playerContext, f, 0, 0, 8, 32, 0, !1, 0, 0, 0), playerContext.restore()));
- d = getPlayerSprite(b.classIndex, k, b.animIndex + 1);
- null != d && drawSprite(playerContext,
- d, -(b.width / 2), -(.26 * b.height), b.width, .26 * b.height, 0, !0, 1.5 * b.jumpY, .5, 0);
- d = getPlayerSprite(b.classIndex, k, 0);
- null != d && drawSprite(playerContext, d, -(b.width / 2), -b.height, b.width, .74 * b.height, 0, !0, 1.5 * b.jumpY + .39 * b.height, .5, 0);
- d = getHatSprite(b, k);
- null != d && drawSprite(playerContext, d, -(b.width / 2), -(1.07 * b.height), b.width, b.width, 0, !0, 1.5 * b.jumpY + .795 * b.height, .5, 0);
- playerContext.globalAlpha = .9;
- getCurrentWeapon(b).front && void 0 != e && (playerContext.save(), playerContext.translate(0, -getCurrentWeapon(b).yOffset),
- playerContext.rotate(m), playerContext.translate(0, getCurrentWeapon(b).holdDist), drawSprite(playerContext, e, -(getCurrentWeapon(b).width / 2), 0, getCurrentWeapon(b).width, getCurrentWeapon(b).length, 0, !1, 0, 0, 0), playerContext.translate(0, -getCurrentWeapon(b).holdDist + 10), void 0 != f && null != f && (270 == k ? (playerContext.restore(), playerContext.save(), playerContext.translate(-4, -getCurrentWeapon(b).yOffset + 8), playerContext.rotate(m), drawSprite(playerContext, f, 0, 0, 8, 32, 0, !1, 0, 0, 0)) : 90 == k ? (playerContext.restore(),
- playerContext.save(), playerContext.translate(0, -getCurrentWeapon(b).yOffset), playerContext.rotate(m), drawSprite(playerContext, f, 0, 0, 8, 32, 0, !1, 0, 0, 0)) : (playerContext.translate(10, -13), playerContext.rotate(.7), drawSprite(playerContext, f, 0, 0, 8, 32, 0, !1, 0, 0, 0), playerContext.rotate(-.7), playerContext.translate(-28, -1), playerContext.rotate(-.25), drawSprite(playerContext, f, 0, 0, 8, 32, 0, !1, 0, 0, 0), playerContext.rotate(.25)), playerContext.restore()));
- 0 < b.spawnProtection && (playerContext.globalCompositeOperation =
- "source-atop", playerContext.fillStyle = b.team != player.team ? "rgba(255,179,179,0.5)" : "rgba(179,231,255,0.5)", playerContext.fillRect(-playerCanvas.width / 2, -playerCanvas.height / 2, playerCanvas.width, playerCanvas.height), playerContext.globalCompositeOperation = "source-over");
- void 0 != b.hitFlash && 0 < b.hitFlash && (playerContext.globalCompositeOperation = "source-atop", playerContext.fillStyle = "rgba(255, 255, 255, " + b.hitFlash + ")", playerContext.fillRect(-playerCanvas.width / 2, -playerCanvas.height / 2, playerCanvas.width,
- playerCanvas.height), playerContext.globalCompositeOperation = "source-over", b.hitFlash -= .01 * a, 0 > b.hitFlash && (b.hitFlash = 0));
- drawSprite(graph, playerCanvas, h - playerCanvas.width / 2, g - playerCanvas.height / 2, playerCanvas.width, playerCanvas.height, 0, !1, 0, 0, 0);
- playerContext.restore()
- }
- } else "flag" == b.type ? (b.ac--, 0 >= b.ac && (b.ac = 5, b.ai++, 2 < b.ai && (b.ai = 0)), drawSprite(graph, flagSprites[b.ai], b.x - b.w / 2 - startX, b.y - b.h - startY, b.w, b.h, 0, !0, 0, .5, 0)) : "clutter" == b.type && b.active && canSee(b.x - startX, b.y - startY, b.w, b.h) &&
- drawSprite(graph, clutterSprites[b.i], b.x - startX, b.y - b.h - startY, b.w, b.h, 0, b.s, 0, .5, 0);
- graph.globalAlpha = 1;
- delete b;
- delete d;
- delete e;
- delete f
- }
- function drawPlayerNames() {
- var a = null,
- b, d, e, f, h = null,
- g;
- graph.lineWidth = playerConfig.textBorderSize;
- graph.fillStyle = playerConfig.textColor;
- graph.miterLimit = 1;
- graph.lineJoin = "round";
- graph.globalAlpha = 1;
- for (var l = 0; l < gameObjects.length; l++) tmpObject = gameObjects[l], "player" != tmpObject.type || tmpObject.dead || tmpObject.index != player.index && !tmpObject.onScreen || (d = tmpObject.height / 3.2, e = mathMIN(200, tmpObject.maxHealth / 100 * 100), shapeX = tmpObject.x - startX, shapeY = tmpObject.y - tmpObject.jumpY - tmpObject.nameYOffset -
- startY, void 0 != tmpObject.account && null != tmpObject.account.hat && (shapeY -= tmpObject.account.hat.nameY), b = tmpObject.name, f = tmpObject.loggedIn ? tmpObject.account.rank : "", h = graph.measureText(b), g = tmpObject.team != player.team ? "#d95151" : "#5151d9", showNames && (a = renderShadedAnimText(b, d * textSizeMult, "#ffffff", 4, ""), void 0 != a && graph.drawImage(a, shapeX - a.width / 2, shapeY - 1.37 * tmpObject.height - a.height / 2, a.width, a.height), "" != f && (b = renderShadedAnimText(f, 1.6 * d * textSizeMult, "#ffffff", 4, ""), void 0 != b && graph.drawImage(b,
- shapeX - a.width / 2 - b.width - 5 * textSizeMult, shapeY - 1.35 * tmpObject.height - (b.height - a.height / 2), b.width, b.height)), "" != tmpObject.account.clan && (b = renderShadedAnimText(" [" + tmpObject.account.clan + "]", d * textSizeMult, g, 4, ""), void 0 != b && graph.drawImage(b, shapeX + a.width / 2, shapeY - 1.37 * tmpObject.height - a.height / 2, b.width, a.height))), graph.fillStyle = g, graph.fillRect(shapeX - e / 2 * (tmpObject.health / tmpObject.maxHealth), shapeY - 1.16 * tmpObject.height, tmpObject.health / tmpObject.maxHealth * e, 10));
- delete h;
- delete a
- }
- function drawBackground() {
- drawSprite(graph, darkFillerSprite, 0, 0, maxScreenWidth, maxScreenHeight, 0, !1, 0, 0, 0)
- }
- function getCachedWall(a) {
- var b = a.left + "" + a.right + "" + a.top + "" + a.bottom + "" + a.topLeft + "" + a.topRight + "" + a.bottomLeft + "" + a.bottomRight + "" + a.edgeTile + "" + a.hasCollision,
- d = cachedWalls[b];
- if (void 0 == d && wallSprite.isLoaded) {
- var d = document.createElement("canvas"),
- e = d.getContext("2d");
- e.imageSmoothingEnabled = !1;
- e.webkitImageSmoothingEnabled = !1;
- e.mozImageSmoothingEnabled = !1;
- d.width = a.scale;
- d.height = a.scale;
- e.drawImage(wallSprite, 0, 0, a.scale, a.scale);
- drawSprite(e, darkFillerSprite, 12, 12, a.scale - 24, a.scale - 24, 0, !1, 0, 0, 0);
- 1 == a.left && drawSprite(e, darkFillerSprite, 0, 12, 12, a.scale - 24, 0, !1, 0, 0, 0);
- 1 == a.right && drawSprite(e, darkFillerSprite, a.scale - 12, 12, 12, a.scale - 24, 0, !1, 0, 0, 0);
- 1 == a.top && drawSprite(e, darkFillerSprite, 12, 0, a.scale - 24, 12, 0, !1, 0, 0, 0);
- 1 == a.bottom && drawSprite(e, darkFillerSprite, 12, a.scale - 12, a.scale - 24, 12, 0, !1, 0, 0, 0);
- (!a.hasCollision || 1 == a.topLeft && 1 == a.top && 1 == a.left) && drawSprite(e, darkFillerSprite, 0, 0, 12, 12, 0, !1, 0, 0, 0);
- (!a.hasCollision || 1 == a.topRight && 1 == a.top && 1 == a.right) && drawSprite(e, darkFillerSprite,
- a.scale - 12, 0, 12, 12, 0, !1, 0, 0, 0);
- (!a.hasCollision || 1 == a.bottomLeft && 1 == a.bottom && 1 == a.left) && drawSprite(e, darkFillerSprite, 0, a.scale - 12, 12, 12, 0, !1, 0, 0, 0);
- (!a.hasCollision || 1 == a.bottomRight && 1 == a.bottom && 1 == a.right) && drawSprite(e, darkFillerSprite, a.scale - 12, a.scale - 12, 12, 12, 0, !1, 0, 0, 0);
- cachedWalls[b] = d
- }
- return d
- }
- var tilesPerFloorTile = 8;
- function getCachedFloor(a) {
- var b = a.spriteIndex + "" + a.left + "" + a.right + "" + a.top + "" + a.bottom + "" + a.topLeft + "" + a.topRight,
- d = cachedFloors[b];
- if (void 0 == d && null != sideWalkSprite && sideWalkSprite.isLoaded) {
- var d = document.createElement("canvas"),
- e = d.getContext("2d");
- e.imageSmoothingEnabled = !1;
- e.webkitImageSmoothingEnabled = !1;
- e.mozImageSmoothingEnabled = !1;
- d.width = a.scale;
- d.height = a.scale * (a.bottom ? .51 : 1);
- e.drawImage(floorSprites[a.spriteIndex], 0, 0, a.scale, a.scale);
- var f = a.scale / tilesPerFloorTile;
- 1 == a.topLeft &&
- renderSideWalks(e, 1, f, 0, 0, 0, 0, 0);
- 1 == a.topRight && renderSideWalks(e, 1, f, mathPI, a.scale - f, 0, 0, 0);
- 1 == a.left && (1 == a.top ? (renderSideWalks(e, 2, f, null, 0, 0, 0, f), renderSideWalks(e, tilesPerFloorTile - 2, f, 0, 0, 2 * f, 0, f)) : renderSideWalks(e, tilesPerFloorTile, f, 0, 0, 0, 0, f));
- 1 == a.right && (1 == a.top ? (renderSideWalks(e, 2, f, null, a.scale - f, 2, 0, f), renderSideWalks(e, tilesPerFloorTile - 2, f, mathPI, a.scale - f, 2 * f, 0, f)) : renderSideWalks(e, tilesPerFloorTile, f, mathPI, a.scale - f, 0, 0, f));
- 1 == a.top && renderSideWalks(e, tilesPerFloorTile, f,
- mathPI / 2, 0, 0, f, 0);
- 1 == a.bottom && renderSideWalks(e, tilesPerFloorTile, f, 0, 0, a.scale - f, f, 0);
- cachedFloors[b] = d
- }
- return d
- }
- function renderSideWalks(a, b, d, e, f, h, g, l) {
- for (var m = 0; m < b; ++m) a.drawImage(sideWalkSprite, f, h, d, d), null != e && (a.save(), a.translate(f + d / 2, h + d / 2), a.rotate(e), a.drawImage(ambientSprites[0], -(d / 2), -(d / 2), d, d), a.restore()), f += g, h += l
- }
- var tmpTlSprite = null;
- function drawMap(a) {
- var b;
- if (null != gameMap) {
- for (var d = 0; d < gameMap.tiles.length; ++d) b = gameMap.tiles[d], 0 == a ? !b.wall && canSee(b.x - startX, b.y - startY, mapTileScale, mapTileScale) && (tmpTlSprite = getCachedFloor(b), drawSprite(graph, tmpTlSprite, b.x - startX, b.y - startY, tmpTlSprite.width, tmpTlSprite.height, 0, !1, 0, 0, 0)) : 1 == a ? b.wall && !b.bottom && canSee(b.x - startX, b.y - startY + .5 * mapTileScale, mapTileScale, .75 * mapTileScale) && drawSprite(graph, wallSpritesSeg[b.spriteIndex], b.x - startX, b.y + mathRound(mapTileScale / 2) - startY,
- mapTileScale, mapTileScale / 2, 0, !0, -(b.scale / 2), .5, b.scale) : 2 == a && b.wall && canSee(b.x - startX, b.y - startY - .5 * mapTileScale, mapTileScale, mapTileScale) && drawSprite(graph, getCachedWall(b), b.x - startX, mathRound(b.y - mapTileScale / 2 - startY), mapTileScale, mapTileScale, 0, !1, 0, 0, 0);
- if (0 == a)
- for (d = 0; d < gameMap.pickups.length; ++d) b = gameMap.pickups[d], b.active && canSee(b.x - startX, b.y - startY, 0, 0) && ("healthpack" == b.type ? drawSprite(graph, healthPackSprite, b.x - b.scale / 2 - startX, b.y - b.scale / 2 - startY, b.scale, b.scale, 0, !1, 0, 0, 0) :
- drawSprite(graph, lootCrateSprite, b.x - b.scale / 2 - startX, b.y - b.scale / 2 - startY, b.scale, b.scale, 0, !0, 0, .5, 0))
- }
- }
- var tmpShadow = null;
- function drawSprite(a, b, d, e, f, h, g, l, m, k, u) {
- null != b && void 0 != b && 0 < b.width && (d = mathFloor(d), e = mathFloor(e), f = mathFloor(f), h = mathFloor(h), m = mathFloor(m), a.rotate(g), a.drawImage(b, d, e, f, h), l && showShadows && (a.globalAlpha = 1, a.translate(0, m), tmpShadow = getCachedShadow(b, f, h + u, k), null != tmpShadow && void 0 != tmpShadow && a.drawImage(tmpShadow, d, e + h), a.rotate(-g), a.translate(0, -m)))
- }
- var shadowIntensity = .16;
- function getCachedShadow(a, b, d, e) {
- var f = cachedShadows[a.index];
- if (void 0 == f && 0 != b && void 0 != a && a.isLoaded) {
- var f = document.createElement("canvas"),
- h = f.getContext("2d");
- f.width = b;
- f.height = d;
- h.globalAlpha = .5 == e ? shadowIntensity : .75 * shadowIntensity;
- h.scale(1, -e);
- h.transform(1, 0, 0, 1, 0, 0);
- h.drawImage(a, 0, -d, b, d);
- b = h.getImageData(0, 0, f.width, f.height);
- d = b.data;
- e = 0;
- for (var g = d.length; e < g; e += 4) d[e] = 0, d[e + 1] = 0, d[e + 2] = 0, d[e + 3] = d[e + 3];
- h.putImageData(b, 0, 0);
- cachedShadows[a.index] = f
- }
- return f
- }
- function canSee(a, b, d, e) {
- return 0 < a + d && 0 < b + e && a < maxScreenWidth && b < maxScreenHeight
- }
- for (var notificationsSize = 80 * textSizeMult, notificationsGap = 1.6 * notificationsSize, notifications = [], i = 0; 3 > i; ++i) notifications.push(new AnimText);
- var notificationIndex = 0;
- function showNotification(a) {
- a = a.toUpperCase();
- notificationIndex++;
- notificationIndex >= notifications.length && (notificationIndex = 0);
- notifications[notificationIndex].text = a;
- notifications[notificationIndex].alpha = 1;
- notifications[notificationIndex].x = maxScreenWidth / 2;
- notifications[notificationIndex].fadeSpeed = .003;
- notifications[notificationIndex].fadeDelay = 600;
- notifications[notificationIndex].fontSize = notificationsSize * viewMult;
- notifications[notificationIndex].scale = 1;
- notifications[notificationIndex].scaleSpeed =
- .005;
- notifications[notificationIndex].minScale = 1;
- notifications[notificationIndex].maxScale = 1.5;
- notifications[notificationIndex].cachedImage = renderShadedAnimText(a, notificationsSize * viewMult, "#ffffff", 7, "Italic ");
- notifications[notificationIndex].active = !0;
- positionNotifications()
- }
- var activeNotifications = 0;
- function positionNotifications() {
- for (var a = activeNotifications = 0; a < notifications.length; ++a) notifications[a].active && activeNotifications++;
- if (0 < activeNotifications) {
- notifications.sort(sortByAlpha);
- for (var b = 0, d = maxScreenHeight - notifications.length * notificationsGap * viewMult - 100, a = 0; a < notifications.length; ++a) notifications[a].active && (notifications[a].y = d + notificationsGap * viewMult * b, b++)
- }
- }
- function sortByAlpha(a, b) {
- return a.alpha < b.alpha ? 1 : b.alpha < a.alpha ? -1 : 0
- }
- function updateNotifications(a) {
- graph.fillStyle = "#fff";
- for (var b = 0; b < notifications.length; ++b) notifications[b].active && (notifications[b].update(a), notifications[b].draw());
- graph.globalAlpha = 1
- }
- for (var animTexts = [], i = 0; 20 > i; i++) animTexts.push(new AnimText);
- var shadowOffset = 6,
- tmpDrawText = null;
- function AnimText() {
- this.text = "";
- this.scaleSpeed = this.minScale = this.maxScale = this.fontSize = this.scale = this.ySpeed = this.xSpeed = this.y = this.x = 0;
- this.active = !1;
- this.alpha = 1;
- this.fadeSpeed = 0;
- this.useStart = !1;
- this.moveDelay = this.fadeDelay = 0;
- this.removable = !1;
- this.textType = "";
- this.color = "#fff";
- this.cachedImage = null;
- this.update = function(a) {
- this.active && (this.scale += this.scaleSpeed * a, 0 < this.scaleSpeed ? this.scale >= this.maxScale && (this.scale = this.maxScale, this.scaleSpeed *= -1) : this.scale < this.minScale && (this.scale =
- this.minScale, this.scaleSpeed = 0), 0 < this.moveDelay ? this.moveDelay -= a : (this.x += this.xSpeed * a, this.y += this.ySpeed * a), 0 < this.fadeDelay ? this.fadeDelay -= a : (this.alpha -= this.fadeSpeed * a, 0 >= this.alpha && (this.alpha = 0, this.active = !1)))
- };
- this.draw = function() {
- this.active && (graph.globalAlpha = this.alpha, this.useStart ? void 0 != this.cachedImage && graph.drawImage(this.cachedImage, this.x - startX - this.cachedImage.width / 2 * this.scale, this.y - startY - this.cachedImage.height / 2 * this.scale, this.cachedImage.width * this.scale, this.cachedImage.height *
- this.scale) : void 0 != this.cachedImage && graph.drawImage(this.cachedImage, this.x - this.cachedImage.width / 2 * this.scale, this.y - this.cachedImage.height / 2 * this.scale, this.cachedImage.width * this.scale, this.cachedImage.height * this.scale))
- }
- }
- function updateAnimTexts(a) {
- graph.lineJoin = "round";
- graph.textAlign = "center";
- graph.textBaseline = "middle";
- for (var b = 0; b < animTexts.length; b++) animTexts[b].update(a), animTexts[b].active && animTexts[b].draw();
- graph.globalAlpha = 1
- }
- function getReadyAnimText() {
- for (var a = 0; a < animTexts.length; ++a)
- if (!animTexts[a].active) return animTexts[a];
- return null
- }
- function startAnimText(a, b, d, e, f, h, g, l, m, k, u, w, p, t, r, q, v) {
- var n = getReadyAnimText();
- null != n && (n.text = a.toUpperCase(), n.x = b, n.y = d, n.xSpeed = e, n.ySpeed = f, n.fadeSpeed = h, n.fontSize = g * viewMult, n.scale = 1, n.maxScale = 1.6, n.minScale = 1, n.alpha = 1, n.scaleSpeed = l, n.useStart = m, n.fadeDelay = k, n.removable = u, n.moveDelay = w, n.alpha = t, n.color = r, n.textType = q, n.cachedImage = renderShadedAnimText(n.text, n.fontSize, n.color, v, p), n.active = !0)
- }
- function startBigAnimText(a, b, d, e, f, h, g, l) {
- deactiveAnimTexts("big") && (0 < a.length && startAnimText(a, maxScreenWidth / 2, bigTextY, 0, -.1, .0025, bigTextSize * l, e ? .005 : 0, !1, d, g, d, "Italic ", 1, f, "big", 8), 0 < b.length && startAnimText(b, maxScreenWidth / 2, bigTextY + textGap * viewMult * l, 0, -.04, .0025, medTextSize / 2 * l, e ? .003 : 0, !1, d, g, d, "Italic ", 1, h, "big", 8))
- }
- function startMovingAnimText(a, b, d, e, f) {
- b += randomInt(-25, 25);
- d += randomInt(-20, 5);
- startAnimText(a, b, d, 0, -.15, .0025, maxScreenHeight / 27 + f, .005, !0, 350, !1, 0, "", 1, e, "moving", 5)
- }
- function deactiveAnimTexts(a) {
- for (var b = 0; b < animTexts.length; ++b)
- if (animTexts[b].active)
- if (animTexts[b].removable) animTexts[b].active = !1;
- else if (animTexts[b].textType == a) return !1;
- return !0
- }
- function deactiveAllAnimTexts() {
- for (var a = 0; a < animTexts.length; ++a) animTexts[a].active = !1
- }
- var cachedTextRenders = [],
- cachedText = tmpIndex = null;
- function renderShadedAnimText(a, b, d, e, f) {
- tmpIndex = a + "" + b + "" + d + "" + f;
- cachedText = cachedTextRenders[tmpIndex];
- if (void 0 == cachedText) {
- var h = document.createElement("canvas"),
- g = h.getContext("2d");
- g.imageSmoothingEnabled = !1;
- g.webkitImageSmoothingEnabled = !1;
- g.mozImageSmoothingEnabled = !1;
- g.textAlign = "center";
- g.font = f + b + "px mainFont";
- h.width = 1.05 * g.measureText(a).width;
- h.height = 1.8 * b + e;
- g.fillStyle = shadeColor(d, -18);
- g.font = f + b + "px mainFont";
- g.textBaseline = "middle";
- g.textAlign = "center";
- for (var l = 1; l < e; ++l) g.fillText(a,
- h.width / 2, h.height / 2 + l);
- g.fillStyle = d;
- g.font = f + b + "px mainFont";
- g.textBaseline = "middle";
- g.textAlign = "center";
- g.fillText(a, h.width / 2, h.height / 2);
- cachedText = h;
- cachedTextRenders[tmpIndex] = cachedText
- }
- return cachedText
- }
- for (var cachedParticles = [], particleIndex = 0, i = 0; 700 > i; ++i) cachedParticles.push(new Particle);
- function updateParticles(a, b) {
- for (var d = 0; d < cachedParticles.length; ++d)(showParticles || cachedParticles[d].forceShow) && cachedParticles[d].active && canSee(cachedParticles[d].x - startX, cachedParticles[d].y - startY, cachedParticles[d].scale, cachedParticles[d].scale) ? b == cachedParticles[d].layer && (cachedParticles[d].update(a), cachedParticles[d].draw()) : cachedParticles[d].active = !1;
- graph.globalAlpha = 1
- }
- function Particle() {
- this.rotation = this.initScale = this.scale = this.dir = this.initSpeed = this.speed = this.y = this.x = 0;
- this.active = !1;
- this.layer = this.spriteIndex = 0;
- this.alpha = 1;
- this.fadeSpeed = 0;
- this.forceShow = this.checkCollisions = !1;
- this.tmpScale = this.maxDuration = this.duration = 0;
- this.update = function(a) {
- this.active && (0 < this.maxDuration && (this.duration += a, this.tmpScale = 1 - this.duration / this.maxDuration, this.tmpScale = 0 > this.tmpScale ? 0 : this.tmpScale, this.scale = this.initScale * this.tmpScale, 1 > this.scale && (this.active = !1), this.speed = this.initSpeed * this.tmpScale, .01 >= this.speed ? this.speed = 0 : (this.x += this.speed * a * mathCOS(this.dir), this.y += this.speed * a * mathSIN(this.dir)), this.duration >= this.maxDuration && (this.active = !1)), 0 < this.alpha && (this.alpha -= this.fadeSpeed * a), 0 >= this.alpha && (this.alpha = 0, this.active = !1), this.checkCollisions && this.checkInWall())
- };
- this.draw = function() {
- this.active && (graph.globalAlpha = this.alpha, 0 != this.rotation ? (graph.save(), graph.translate(this.x - startX, this.y - startY), graph.rotate(this.rotation),
- graph.drawImage(particleSprites[this.spriteIndex], -(this.scale / 2), -(this.scale / 2), this.scale, this.scale), graph.restore()) : graph.drawImage(particleSprites[this.spriteIndex], this.x - startX - this.scale / 2, this.y - startY - this.scale / 2, this.scale, this.scale))
- };
- this.checkInWall = function() {
- for (var a = 0; a < gameMap.tiles.length; ++a) gameMap.tiles[a].wall && gameMap.tiles[a].hasCollision && (tmpTl = gameMap.tiles[a], this.x >= tmpTl.x && this.x <= tmpTl.x + tmpTl.scale && this.y > tmpTl.y && this.y < tmpTl.y + tmpTl.scale - player.height && (this.active = !1))
- }
- }
- function getReadyParticle() {
- particleIndex++;
- particleIndex >= cachedParticles.length && (particleIndex = 0);
- return cachedParticles[particleIndex]
- }
- var tmpParticle = null;
- function particleCone(a, b, d, e, f, h, g, l, m) {
- if (showParticles)
- for (var k = 0; k < a; ++k) tmpParticle = getReadyParticle(), tmpParticle.forceShow = !1, tmpParticle.checkCollisions = !1, tmpParticle.x = b, tmpParticle.y = d, tmpParticle.rotation = 0, tmpParticle.alpha = 1, tmpParticle.speed = 0, tmpParticle.fadeSpeed = 0, tmpParticle.initSpeed = 0, tmpParticle.initScale = randomFloat(3, 9), tmpParticle.spriteIndex = 0, tmpParticle.maxDuration = -1, tmpParticle.duration = 0, 0 == k && 2 == l && m ? (tmpParticle.spriteIndex = 3, tmpParticle.layer = 0) : (tmpParticle.dir =
- e + randomFloat(-f, f), tmpParticle.initScale = g * randomFloat(1.3, 1.7), tmpParticle.initSpeed = h * randomFloat(.4, 1.6), tmpParticle.maxDuration = 320 * randomFloat(.8, 1.1), tmpParticle.spriteIndex = l, tmpParticle.layer = randomInt(0, 1)), tmpParticle.scale = tmpParticle.initScale, tmpParticle.active = !0
- }
- var liquidSpread = 35;
- function createLiquid(a, b, d, e) {
- tmpParticle = getReadyParticle();
- tmpParticle.x = a + randomFloat(-liquidSpread, liquidSpread);
- tmpParticle.y = b + randomFloat(-liquidSpread, liquidSpread);
- tmpParticle.initSpeed = 0;
- tmpParticle.maxDuration = -1;
- tmpParticle.duration = 0;
- tmpParticle.initScale = randomFloat(60, 150);
- tmpParticle.scale = tmpParticle.initScale;
- tmpParticle.rotation = randomInt(0, 5);
- tmpParticle.alpha = randomFloat(.3, .5);
- tmpParticle.fadeSpeed = 2E-5;
- tmpParticle.checkCollisions = !1;
- tmpParticle.spriteIndex = randomInt(e, e + 1);
- tmpParticle.layer = 0;
- tmpParticle.forceShow = !1;
- tmpParticle.active = !0
- }
- var tmpDist = 0,
- maxShakeDist = 2E3,
- maxExplosionDuration = 400,
- maxShake = 9,
- tmpShake = 0,
- tmpDir = 0;
- function createExplosion(a, b, d) {
- tmpDist = getDistance(a, b, player.x, player.y);
- tmpDist <= maxShakeDist && (tmpDir = getAngle(a, player.x, b, player.y), screenShake(d * maxShake * (1 - tmpDist / maxShakeDist), tmpDir));
- playSound("explosion", a, b);
- for (var e = 0; 30 > e; ++e) {
- tmpParticle = getReadyParticle();
- tmpParticle.dir = mathRound(randomFloat(-mathPI, mathPI) / (mathPI / 3)) * (mathPI / 3);
- tmpParticle.forceShow = !0;
- tmpParticle.spriteIndex = 2;
- tmpParticle.checkCollisions = !0;
- tmpParticle.alpha = 1;
- tmpParticle.fadeSpeed = 0;
- tmpParticle.initSpeed = 0;
- tmpParticle.maxDuration = -1;
- tmpParticle.duration = 0;
- tmpParticle.layer = 1;
- tmpParticle.rotation = 0;
- if (0 == e) tmpParticle.x = a, tmpParticle.y = b, tmpParticle.initScale = randomFloat(50, 60) * d, tmpParticle.rotation = randomInt(0, 5), tmpParticle.speed = 0, tmpParticle.fadeSpeed = 2E-4, tmpParticle.checkCollisions = !1, tmpParticle.spriteIndex = 6, tmpParticle.layer = 0;
- else if (10 >= e) tmpDist = e * d, tmpParticle.x = a + tmpDist * mathCOS(tmpParticle.dir), tmpParticle.y = b + tmpDist * mathSIN(tmpParticle.dir), tmpParticle.initScale = randomFloat(30, 33) *
- d, tmpParticle.initSpeed = 3 / tmpParticle.initScale * d, tmpParticle.maxDuration = .8 * maxExplosionDuration;
- else {
- tmpDist = randomFloat(0, 10) * d;
- tmpParticle.x = a + tmpDist * mathCOS(tmpParticle.dir);
- tmpParticle.y = b + tmpDist * mathSIN(tmpParticle.dir);
- var f = randomFloat(.7, 1.4);
- tmpParticle.initScale = 11 * d * f;
- tmpParticle.initSpeed = 12 / tmpParticle.initScale * d / f;
- tmpParticle.maxDuration = maxExplosionDuration * f
- }
- tmpParticle.scale = tmpParticle.initScale;
- tmpParticle.active = !0
- }
- }
- function muzzleFlash(a, b, d) {}
- function stillDustParticle(a, b, d) {
- tmpParticle = getReadyParticle();
- tmpParticle.x = a + randomInt(-10, 10);
- tmpParticle.y = b;
- tmpParticle.initScale = randomFloat(18, 25);
- tmpParticle.initSpeed = .05;
- tmpParticle.maxDuration = 600;
- tmpParticle.duration = 0;
- tmpParticle.dir = randomFloat(0, 2 * mathPI);
- tmpParticle.rotation = 0;
- tmpParticle.spriteIndex = 2;
- tmpParticle.layer = d ? 1 : 0;
- tmpParticle.alpha = 1;
- tmpParticle.fadeSpeed = 0;
- tmpParticle.checkCollisions = !1;
- tmpParticle.forceShow = d;
- tmpParticle.active = !0
- }
- var anglDif = 0,
- PI2 = 2 * mathPI;
- function getAngleDifference(a, b) {
- anglDif = mathABS(b - a) % PI2;
- return anglDif > mathPI ? PI2 - anglDif : anglDif
- }
- function getDistance(a, b, d, e) {
- return mathSQRT(mathPOW(d - a, 2) + mathPOW(e - b, 2))
- }
- function getAngle(a, b, d, e) {
- return mathATAN2(e - b, d - a)
- }
- function shadeColor(a, b) {
- var d = parseInt(a.substring(1, 3), 16),
- e = parseInt(a.substring(3, 5), 16),
- f = parseInt(a.substring(5, 7), 16),
- d = parseInt(d * (100 + b) / 100),
- e = parseInt(e * (100 + b) / 100),
- f = parseInt(f * (100 + b) / 100),
- d = 255 > d ? d : 255,
- e = 255 > e ? e : 255,
- f = 255 > f ? f : 255,
- d = 1 == d.toString(16).length ? "0" + d.toString(16) : d.toString(16),
- e = 1 == e.toString(16).length ? "0" + e.toString(16) : e.toString(16),
- f = 1 == f.toString(16).length ? "0" + f.toString(16) : f.toString(16);
- return "#" + d + e + f
- }
- function randomFloat(a, b) {
- return a + Math.random() * (b - a)
- }
- function randomInt(a, b) {
- return mathFloor(Math.random() * (b - a + 1)) + a
- }
- function linearInterpolate(a, b, d) {
- var e = a - b;
- return e * e > d * d ? b + d : a
- }
- var lastTime = 0,
- nextTime = 0;
- function prepareUpdate(a) {
- currentTime = Date.now();
- nextTime = mathMax(lastTime + 1E3 / targetFPS, currentTime);
- setTimeout(function() {
- a(lastTime = nextTime)
- }, nextTime - currentTime)
- }
- function callUpdate() {
- prepareUpdate(callUpdate);
- updateGameLoop()
- }
- callUpdate();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement