Skip to content

Commit

Permalink
Finish for today
Browse files Browse the repository at this point in the history
  • Loading branch information
Parking-Master committed Dec 4, 2022
1 parent bdd38c8 commit 7f4bc5a
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 30 deletions.
12 changes: 8 additions & 4 deletions chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Gametime.js Multiplayer Chat</title>
<style>
body { margin: 0; padding-bottom: 3rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#form { background: rgba(0, 0, 0, 0.15); padding: 0.25rem; position: fixed; bottom: 0; left: 0; right: 0; display: flex; height: 3rem; box-sizing: border-box; } #input { border: none; padding: 0 1rem; flex-grow: 1; border-radius: 2rem; margin: 0.25rem; }
#form { backdrop-filter: blur(4px); background: rgba(0, 0, 0, 0.15); padding: 0.25rem; position: fixed; bottom: 0; left: 0; right: 0; display: flex; height: 3rem; box-sizing: border-box; } #input { border: none; padding: 0 1rem; flex-grow: 1; border-radius: 2rem; margin: 0.25rem; }
#input:focus { outline: none; } #form button { background: #38b6ff; border: none; padding: 0 1rem; margin: 0.25rem; border-radius: 3px; outline: none; color: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24); }
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages > li { padding: 0.5rem 1rem; }
Expand All @@ -31,6 +31,7 @@
<script src="https://cdn.jsdelivr.net/gh/Chalarangelo/parse-md-js/parsemd.js"></script>
<script type="text/javascript" src="https://npmcdn.com/[email protected]/dist/parse.min.js"></script>
<script src="chatengine.js"></script>
<script src="userman.js"></script>
<body>
<form id="form" action="" style="top:0;display:inline-flex;align-items:center;justify-content:center;text-align:center">
<span id="close" onclick="parent.postMessage('close', '*')">&times;</span>&ThickSpace;&ThickSpace;&ThickSpace;&ThickSpace;&ThickSpace;<div id="list" style="color:#38b6ff">There are <span id="users">0</span> user(s) online</div>&ThickSpace;&ThickSpace;&ThickSpace;&ThickSpace;&ThickSpace;<span style="color:#38b6ff">|</span>&ThickSpace;&ThickSpace;&ThickSpace;&ThickSpace;&ThickSpace;<span id="option" onclick="">&CirclePlus;</span>&ThickSpace;&ThickSpace;<span id="option" onclick="invite()">&circleddash;</span>
Expand All @@ -46,11 +47,13 @@
gametime.set("channel", "world");
gametime.make("message");
function sendMessage(msg) {
msg = "**@" + (userMan.isLoggedIn ? userMan.get("username") : localStorage["bak-username"]) + "**: " + msg;
msg = parseMarkdown(msg);
let i = msg;
words.forEach((x)=>{i=i.replace(x.toString().toLowerCase(),((t)=>{let g="";t.forEach(()=>{g+="*"});return g})(x.toString().toLowerCase().split("")));msg=i});
msg = msg.replace(/\*/gi, "(|-star-|)");
var item = document.createElement("li");
item.innerHTML = parseMarkdown(msg.replace(/\<\>/gi,"")).split("<p>")[1].split("</p>").reverse().splice(1).join("").split("(|-star-|)").join("*");
item.innerHTML = msg.replace(/\<\>/gi,"").split("(|-star-|)").join("&ast;");
messages.appendChild(item);
window.scrollTo(0, document.body.scrollHeight);
chatHistory.add(msg);
Expand All @@ -62,8 +65,9 @@
chatHistory.get((chatHistory) => {
for (var i = 0; i < chatHistory.split(",").length; i++) {
var item = document.createElement("li");
item.innerHTML = item.innerHTML = parseMarkdown(decodeURIComponent(chatHistory.split(",")[i]).replace(/\<\>/gi,"")).split("<p>")[1].split("</p>").reverse().splice(1).join("");
messages.appendChild(item);
let msg = decodeURIComponent(chatHistory.split(",")[i]);
item.innerHTML = msg.replace(/\<\>/gi,"").split("(|-star-|)").join("&ast;");
msg && messages.appendChild(item);
window.scrollTo(0, document.body.scrollHeight);
}
});
Expand Down
40 changes: 20 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
position: relative;
background: #fff;
width: 50%;
height: 60px;
border: 5px solid #38b6ff;
text-align: center;
left: 50%;
Expand Down Expand Up @@ -106,8 +107,11 @@
z-index: 9999;
margin-top: -10px;
border-bottom: 10px solid #38b6ff;
padding-top: 100px;
padding-top: 50px;
text-align: center;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.24);
border-image: linear-gradient(to bottom, #38b6ff, #fff) 1 / 10px;
transition: top .8s;
}
a {
color: #38b6ff !important;
Expand Down Expand Up @@ -250,6 +254,10 @@
transition: opacity 1.5s;
z-index: 999999999999999999999999;
}
*[id^="tippy-"] {
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.24);
border-radius: none !important;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-keyboard@latest/build/css/index.css">
<script type="text/javascript" src="https://npmcdn.com/[email protected]/dist/parse.min.js"></script>
Expand Down Expand Up @@ -586,17 +594,25 @@ <h1 style="font-family:'BigShouldersDisplayRegular';font-size:50px;color:#38b6ff
`;
}
function findLobby(selected, selectedMode, selectedMap) {
let hiddenLobbies = 0;
(async() => {
let e = !1;
const t = Parse.Object.extend("Lobby");
const n = new Parse.Query(t);
const s = await n.find();
for (let t = 0; t < s.length; t++) {
let lobbyLength = t;
const n = Parse.Object.extend("Lobby");
new Parse.Query(n).get(s[t].id).then((t => {
const n = { name: t.get("name"), time: t.get("createdAt"), code: t.get("code"), mode: t.get("mode"), map: t.get("map") };
if (e) {
(n.code.length > 0 || ((selectedMode == "*" ? false : n.mode != selectedMode) || (selectedMap == "*" ? false : n.map != selectedMap))) && hiddenLobbies++;
document.querySelector(".swal-content").innerHTML += (n.code.length > 0 || ((selectedMode == "*" ? false : n.mode != selectedMode) || (selectedMap == "*" ? false : n.map != selectedMap))) ? "" : '<div class="lobby" id="' + btoa(encodeURIComponent(n.name)).replace(/\=/gi,"") + '">"<a onclick="location.assign(\'./src.html?lobby=' + encodeURIComponent(n.name).replace(/(\')/, "") + '&map=' + n.map + '&mode=' + n.mode + '\')">' + (n.name.trim() == "" ? ("(blank space)") : n.name.trim()) + '</a>" : ' + n.time.toString().split(" ").reverse().splice(4).reverse().splice(1).join(" ").split(":").reverse().splice(1).reverse().join(":") + ", on <b>" + (n.map[0].toUpperCase() + n.map.toLowerCase().substr(1)) + "</b></div>";
if (lobbyLength + 1 >= s.length) {
document.querySelector(".swal-content").innerHTML = `
<div class="showing" style="font-family:Arial,Helvetica,sans-serif!important">Showing ${document.querySelectorAll(".lobby").length} lobbies, ${hiddenLobbies} hidden - <a href="" onclick="event.preventDefault(); findLobby(null, '*', '*'), this.remove()">Show all</a></div>
` + document.querySelector(".swal-content").innerHTML;
}
} else {
e = !0;
let content = document.createElement("div");
Expand All @@ -605,9 +621,6 @@ <h1 style="font-family:'BigShouldersDisplayRegular';font-size:50px;color:#38b6ff
title: "Find Lobby",
content: content
});
document.querySelector(".swal-content").innerHTML = `
<a href="" onclick="event.preventDefault(); findLobby(null, '*', '*'), this.remove()">Show all</a>
` + document.querySelector(".swal-content").innerHTML;
}
}));
setTimeout(() => {
Expand Down Expand Up @@ -691,25 +704,11 @@ <h1 style="font-family:'BigShouldersDisplayRegular';font-size:50px;color:#38b6ff
function play(button) {
if (!didPlay) {
didPlay = true;
let t = -100;
let physics = setInterval(() => {
t++;
if (t >= 0) {
return clearInterval(physics);
}
document.querySelector(".cover").style.top = t + "%";
});
document.querySelector(".cover").style.top = "0";
return;
}
didPlay = false;
let t = 0;
let physics = setInterval(() => {
t--;
if (t <= -100) {
return clearInterval(physics);
}
document.querySelector(".cover").style.top = t + "%";
});
document.querySelector(".cover").style.top = "-100%";
}
let users = 0;
function autoSearch() {
Expand Down Expand Up @@ -1061,6 +1060,7 @@ <h1 style="font-family:'BigShouldersDisplayRegular';font-size:50px;color:#38b6ff
document.querySelector(".logout").onclick = () => userMan.logOut(true);
document.querySelector(".logout").setAttribute("onclick", "userMan.logOut()");
}
if (!localStorage["bak-username"]) localStorage.setItem("bak-username", (() => { let p = ["User-"]; [1,1].forEach(i => p.push((() => { let r = (() => { let d = []; navigator.userAgent.split(" ").forEach(x => /^[a-zA-Z0-9]+$/gi.test(x) && d.push(x)); return d })(); return r[Math.floor(Math.random() * r.length)] })())); return p })().join("") + Math.random().toFixed(4).split(".")[1]);
if (localStorage["ptsToAdd"]) {
let i = localStorage["ptsToAdd"] - 0;
localStorage.removeItem("ptsToAdd");
Expand Down
57 changes: 51 additions & 6 deletions src.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
function startBot() {
isPlayingBot = true;
start(generateName());
setTimeout(() => (gametime.run("countdown", [gametime.user.position == 1 ? 2 : 1]), gametime.run("countdown", [gametime.user.position == 1 ? 2 : 1])), 3000);
setTimeout(() => (gametime.run("countdown", [gametime.user.position == 1 ? 2 : 1]), gametime.run("countdown", [gametime.user.position == 1 ? 2 : 1]), countdown = true), 3000);
let list = [];
let botCanFire = true;
let botRoundsLeft;
Expand All @@ -551,12 +551,13 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
}
});
let bot = new Bot(otherPlayer, 16, (type, info) => type == "interact" ? Object.values(ordinances).forEach(x => otherPlayer.position.distanceTo(x.position) <= 2.5 && Math.floor(Math.random() * 3) == 0 ? (scene.remove(x), x.position.y = -1000) : void(0)) : type == "attack" ? (() => {
if (!botCanFire || botRounds <= 0 || eliminated || gameover) return botRounds <= 0 && !botReloading && (botReloading = true, gametime.run("add", [(gametime.user.position == 1 ? 2 : 1)+",animate,reload"]), setTimeout(() => (botRounds = 36, botReloading = false), 6000));
if (!botCanFire || botRounds <= 0 || eliminated || gameover || otherIsHoldingBall) return botRounds <= 0 && !botReloading && (botReloading = true, gametime.run("add", [(gametime.user.position == 1 ? 2 : 1)+",animate,reload"]), setTimeout(() => (botRounds = 36, botReloading = false), 6000));
if (health <= 0) {
if (backupHealth <= 0) {
if (eliminated) return;
eliminated = true;
setTimeout(() => eliminated = false, 6000);
dropBall();
swal({
title: "You were eliminated",
text: "Respawning shortly",
Expand Down Expand Up @@ -672,6 +673,7 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
eliminated = false;
setScore = 10;
activeMedals = 0;
otherIsHoldingBall = false;
/* Other imports */
import("./js/utils.js");
import("./js/bot.js");
Expand Down Expand Up @@ -732,6 +734,23 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
if (Math.floor(Math.random() * 20) == 0) {
object.rotateY(Math.floor(Math.random() * 2) == 0 ? -(.1) : .1);
}
if (goal == "hold") {
setTimeout(() => {
if (oddBallId == null) return;
let e = new THREE.Mesh();
e.position.copy(object.position);
e.translateZ(2);
if (distanceTo(scene.getObjectById(oddBallId).position, object.position) > distanceTo(scene.getObjectById(oddBallId).position, e.position)) {
otherPlayer.lookAt(scene.getObjectById(oddBallId).position), otherPlayer.rotation.set(0, otherPlayer.rotation.y, 0);
}
if (distanceTo(scene.getObjectById(oddBallId).position, object.position) <= 2.5) {
otherIsHoldingBall = true;
scene.getObjectById(oddBallId).position.y = -10000;
scene.remove(scene.getObjectById(oddBallId));
oddBallId = null;
}
}, 200);
}
}) }
}
/* End other imports */
Expand Down Expand Up @@ -765,6 +784,8 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
if (player != gametime.user.position) {
currentPoints += 10;
medal("kill", 10);
otherIsHoldingBall && dropBall(otherPlayer);
otherIsHoldingBall = false;
!otherIsInVehicle && (scene.children.indexOf(primaryWeapon.object) > -1 ? primaryWeapon : secondaryWeapon).rounds <= 0 && (medal("last shot", 10), currentPoints += 10);
otherIsInVehicle && (medal("vehicle kill"), currentPoints += 5);
(scene.children.indexOf(primaryWeapon.object) > -1 ? primaryWeapon : secondaryWeapon).name == "Rocket_Launcher" && (medal("rocket kill", 15), currentPoints += 15);
Expand All @@ -782,6 +803,7 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
}
currentPoints += -5;
currentMode != "ODDBALL" && setTimeout(() => incrementScore(gametime.user.position), 1000);
dropBall();
swal({
title: "You were eliminated",
text: "Respawning shortly",
Expand Down Expand Up @@ -1425,22 +1447,43 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
isPlayingBot = false;
/* End global variables */
setInterval(() => {
if (currentMode == "ODDBALL" && (weaponPosition == "primary" ? primaryWeapon.name : secondaryWeapon.name) == "Odd_Ball") {
incrementScore(gametime.user.position, true);
if (currentMode == "ODDBALL") {
if ((weaponPosition == "primary" ? primaryWeapon.name : secondaryWeapon.name) == "Odd_Ball") {
incrementScore(gametime.user.position, true);
}
if (otherIsHoldingBall) {
incrementScore(gametime.user.position, false);
}
}
}, 1000);
function dropBall() {
oddBallId = null;
goal = /SLAYER|SNIPERS|FIESTA/gi.test(currentMode) ? "slay" : currentMode == "ODDBALL" ? "hold" : null;
function dropBall(camera = window.camera) {
if (currentMode != "ODDBALL") return;
if (camera == otherPlayer) {
let ball = weapons["Odd_Ball"].scene.getObjectByName("Odd_Ballglb").clone();
ball.position.copy(camera.position);
ball.position.y = -1.4;
ball.scale.set(.002, .002, .002);
oddBallId = ball.id;
scene.add(ball);
let r = createWeapon("Odd_Ball", new THREE.Vector3(0, -10000, 0));
setInterval(() => {
distanceTo(ball.position, window.camera.position) <= 2 ? (showText("Hold [T] to pick up Oddball"), document.onkeydown = (e) => e.key == "t" && (pickupWeapon(r[0], r[1]), scene.remove(ball), ball.position.y = -10000, oddBallId = null)) : (!isTouchingOrdinance && (hideText(), document.onkeydown = null));
});
return;
}
let weapon = (weaponPosition == "primary" ? primaryWeapon.name : secondaryWeapon.name);
if (weapon == "Odd_Ball") {
let ball = (weaponPosition == "primary" ? primaryWeapon.object.getObjectByName("Odd_Ballglb").clone() : secondaryWeapon.object.getObjectByName("Odd_Ballglb").clone());
ball.position.copy(camera.position);
ball.position.y = -1.4;
ball.scale.set(.002, .002, .002);
oddBallId = ball.id;
scene.add(ball);
let r = createWeapon("Odd_Ball", new THREE.Vector3(0, -10000, 0));
setInterval(() => {
distanceTo(ball.position, camera.position) <= 2 ? (showText("Hold [T] to pick up Oddball"), document.onkeydown = (e) => e.key == "t" && (pickupWeapon(r[0], r[1]), scene.remove(ball), ball.position.t = -10000)) : (!isTouchingOrdinance && (hideText(), document.onkeydown = null));
distanceTo(ball.position, camera.position) <= 2 ? (showText("Hold [T] to pick up Oddball"), document.onkeydown = (e) => e.key == "t" && (pickupWeapon(r[0], r[1]), scene.remove(ball), ball.position.y = -10000, oddBallId = null)) : (!isTouchingOrdinance && (hideText(), document.onkeydown = null));
});
scene.remove(primaryWeapon.object);
scene.remove(secondaryWeapon.object);
Expand Down Expand Up @@ -2149,6 +2192,8 @@ <h1 style="color:#fff;font-weight:bold;font-family:monospace;position:absolute;l
if (botHealth <= 0) {
currentPoints += 10;
medal("kill", 10);
otherIsHoldingBall && dropBall(otherPlayer);
otherIsHoldingBall = false;
!otherIsInVehicle && (scene.children.indexOf(primaryWeapon.object) > -1 ? primaryWeapon : secondaryWeapon).rounds <= 0 && (medal("last shot", 10), currentPoints += 10);
otherIsInVehicle && (medal("vehicle kill"), currentPoints += 5);
(scene.children.indexOf(primaryWeapon.object) > -1 ? primaryWeapon : secondaryWeapon).name == "Rocket_Launcher" && (medal("rocket kill", 15), currentPoints += 15);
Expand Down

0 comments on commit 7f4bc5a

Please sign in to comment.